problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
How to concatenate constant string with jsonpath : <p>I have AWS step machine and one of the step is used to notify failure using SNS service. I want to select some metadata from <code>input</code> json into outgoing message. So i am trying to concatenate constant string with jsonpath like below</p>
<pre><code>"Notify Failure": {
"Type": "Task",
"Resource": "arn:aws:states:::sns:publish",
"Parameters": {
"Message.$": "A job submitted through Step Functions failed for document id $.document_id",
"Subject":"Job failed",
"TopicArn": "arn:aws:sns:us-west-2:xxxxxxx:xxxxxxxx"
},
"End": true
}
</code></pre>
<p>where <code>document_id</code> is one of the property in input json</p>
<p>However when i try save state machine defination i get error</p>
<blockquote>
<p>There is a problem with your ASL definition, please review it and try
again The value for the field 'Message.$' must be a valid JSONPath</p>
</blockquote>
| 0debug |
Properties of __proto__ in Javascript : <p>I have the below code</p>
<pre><code>var person={
firstname:"Geet",
getFullName:function(){
return this.firstname;
}
}
var test={
firstname:"Test"
}
test.__proto__=person;
for (var prop in test){
console.log(prop + ': '+test[prop]);
}
</code></pre>
<p>Output:-</p>
<pre><code> firstname: Test
getFullName: function (){
return this.firstname;
}
</code></pre>
<p>How the chain stops there. Why it does not print the properties of <strong>proto</strong> Object of person.How is this handled.</p>
| 0debug |
qemu_irq isa_reserve_irq(int isairq)
{
if (isairq < 0 || isairq > 15) {
hw_error("isa irq %d invalid", isairq);
}
if (isabus->assigned & (1 << isairq)) {
hw_error("isa irq %d already assigned", isairq);
}
isabus->assigned |= (1 << isairq);
return isabus->irqs[isairq];
}
| 1threat |
Como modificar, apenas via CSS, uma cor já definida no HTML? : olá
estou tentando modificar uma cor em um texto, marcado que a pela tag "U" com a cor ja definida no html.
está assim no html:
<u> <font color="#0000c0">somente no seu e-commerce</font> </u>
tentei da seguinte maneira no css:
u{ color:rgb(20,20,20) !important; }
porém não aceita a cor, creio que pelo fato de está definida no código fonte.
o detalhe importante, eu NAO TENHO acesso a modificar o html, pois é gerado por software web. toda modificação de layout tem q ser feita APENAS por CSS.
agradeço desde já.
[1]: https://i.stack.imgur.com/cwFuo.jpg | 0debug |
Why doesn't time() from time.h have a syscall to sys_time? : <p>I wrote a very simple program with calls <code>time()</code> to illustrate the use of<code>strace</code>, but I'm having a problem; the <code>time()</code> call doesn't seem to actually produce a syscall!</p>
<p>I ended up stepping into the <code>time()</code> function in GDB and now I'm more confused than ever. From the disassembly of the <code>time()</code> function:</p>
<pre><code>0x7ffff7ffad90 <time>: push rbp
0x7ffff7ffad91 <time+1>: test rdi,rdi
0x7ffff7ffad94 <time+4>: mov rax,QWORD PTR [rip+0xffffffffffffd30d] # 0x7ffff7ff80a8
0x7ffff7ffad9b <time+11>: mov rbp,rsp
0x7ffff7ffad9e <time+14>: je 0x7ffff7ffada3 <time+19>
0x7ffff7ffada0 <time+16>: mov QWORD PTR [rdi],rax
0x7ffff7ffada3 <time+19>: pop rbp
0x7ffff7ffada4 <time+20>: ret
</code></pre>
<p>How is this function actually getting the current time if it does not call the kernel? Its flow is:</p>
<ul>
<li>Prologue</li>
<li>Get some value from <code>(0x7ffff7ffad94 + 0xffffffffffffd30d)</code> (<code>0x7ffff7ff80a8</code>) and put it in rax (to be returned)</li>
<li>Check if rdi (first argument) was null</li>
<li>If not put the value in rax (return value) there also</li>
<li>Epilogue</li>
</ul>
<p>This makes sense with the functionality of <code>time()</code>; if the argument is null, it just returns the value, but if not it also puts it in the argument. The question I have is, where is it getting the time value? What's so magical about address <code>0x7ffff7ff80a8</code>, and how does it do this without a syscall?</p>
<p>I'm using GCC 6.3.0 and Ubuntu GLIBC 2.24-9ubuntu2.2.</p>
| 0debug |
static int decode_coeffs(WMAProDecodeCtx *s, int c)
{
static const int fval_tab[16] = {
0x00000000, 0x3f800000, 0x40000000, 0x40400000,
0x40800000, 0x40a00000, 0x40c00000, 0x40e00000,
0x41000000, 0x41100000, 0x41200000, 0x41300000,
0x41400000, 0x41500000, 0x41600000, 0x41700000,
};
int vlctable;
VLC* vlc;
WMAProChannelCtx* ci = &s->channel[c];
int rl_mode = 0;
int cur_coeff = 0;
int num_zeros = 0;
const uint16_t* run;
const float* level;
av_dlog(s->avctx, "decode coefficients for channel %i\n", c);
vlctable = get_bits1(&s->gb);
vlc = &coef_vlc[vlctable];
if (vlctable) {
run = coef1_run;
level = coef1_level;
} else {
run = coef0_run;
level = coef0_level;
}
while ((s->transmit_num_vec_coeffs || !rl_mode) &&
(cur_coeff + 3 < ci->num_vec_coeffs)) {
int vals[4];
int i;
unsigned int idx;
idx = get_vlc2(&s->gb, vec4_vlc.table, VLCBITS, VEC4MAXDEPTH);
if (idx == HUFF_VEC4_SIZE - 1) {
for (i = 0; i < 4; i += 2) {
idx = get_vlc2(&s->gb, vec2_vlc.table, VLCBITS, VEC2MAXDEPTH);
if (idx == HUFF_VEC2_SIZE - 1) {
int v0, v1;
v0 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH);
if (v0 == HUFF_VEC1_SIZE - 1)
v0 += ff_wma_get_large_val(&s->gb);
v1 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH);
if (v1 == HUFF_VEC1_SIZE - 1)
v1 += ff_wma_get_large_val(&s->gb);
((float*)vals)[i ] = v0;
((float*)vals)[i+1] = v1;
} else {
vals[i] = fval_tab[symbol_to_vec2[idx] >> 4 ];
vals[i+1] = fval_tab[symbol_to_vec2[idx] & 0xF];
}
}
} else {
vals[0] = fval_tab[ symbol_to_vec4[idx] >> 12 ];
vals[1] = fval_tab[(symbol_to_vec4[idx] >> 8) & 0xF];
vals[2] = fval_tab[(symbol_to_vec4[idx] >> 4) & 0xF];
vals[3] = fval_tab[ symbol_to_vec4[idx] & 0xF];
}
for (i = 0; i < 4; i++) {
if (vals[i]) {
int sign = get_bits1(&s->gb) - 1;
*(uint32_t*)&ci->coeffs[cur_coeff] = vals[i] ^ sign<<31;
num_zeros = 0;
} else {
ci->coeffs[cur_coeff] = 0;
rl_mode |= (++num_zeros > s->subframe_len >> 8);
}
++cur_coeff;
}
}
if (cur_coeff < s->subframe_len) {
memset(&ci->coeffs[cur_coeff], 0,
sizeof(*ci->coeffs) * (s->subframe_len - cur_coeff));
if (ff_wma_run_level_decode(s->avctx, &s->gb, vlc,
level, run, 1, ci->coeffs,
cur_coeff, s->subframe_len,
s->subframe_len, s->esc_len, 0))
return AVERROR_INVALIDDATA;
}
return 0;
}
| 1threat |
Open actovity by verify text of textview : I have button and text view in mainactivity and i have another three activities like one.java, two.java, three.java, four.java so i want when text is 'hi' in textview then on button click the one.java will be open and with text 'hello'
Avtivity two.java, with 'nice' text activity three.java and with 'thanks' text activity four.java will be opened please help me someone please | 0debug |
OutofBounds Exception : <p>I am trying here to measure how many white spaces there are in text typed in a JTextArea. I am getting an outofbounds exception. Why so? </p>
<pre><code>Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at ClassTest.main(ClassTest.java:11)
import javax.swing.*;
public class ClassTest {
public static void main(String [] args) {
JFrame frame = new JFrame();
JTextArea textarea = new JTextArea();
frame.setSize(300, 300);
frame.add(textarea);
frame.setVisible(true);
String text=textarea.getText();
int count = 0;
for(int i=0;i>=text.length();i++) {
char spacecount = text.charAt(i);
if(spacecount==' ') {
System.out.print(count++);
}
}
}
}
</code></pre>
| 0debug |
Div can't be resized beyond content : <p><a href="https://i.stack.imgur.com/9MEQD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9MEQD.png" alt="enter image description here"></a></p>
<p>The Div didn't stretch to the end of the screen</p>
<p>CSS:</p>
<pre><code>#page {
background-color:white;
color:black;
position:absolute;
top:0vh;
left:2vw;
width:96vw:
height:100vh;
}
</code></pre>
<p>The height is supposed to be 100 viewport-heights.
The width is supposed to be 96 viewport-widths.</p>
<p>HTML:</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<title>SpaceOS</title>
<style>
#page {
background-color:white;
color:black;
position:absolute;
top:0vh;
left:2vw;
width:96vw:
height:100vh;
}
</style>
</head>
<body>
<div id="page">
<h1 class="title">SpaceOS</h1>
<p class="error">Raspberry pi compatibility coming soon.</p>
</div>
</body>
</html>
</code></pre>
<p>And now for the cliché, pls help.</p>
| 0debug |
OpenALPR not work with PyQt : <p>I tried to build a GUI app with PyQt and openalpr, but there are an issue with my code. A simple example:</p>
<pre><code>from openalpr import Alpr
from PyQt4 import QtCore, QtGui
class AnalizePlate(object):
def __init__(self):
self.alpr = None
try:
self.alpr = Alpr("eu", "/etc/openalpr/openalpr.conf", "/usr/share/openalpr/runtime_data")
if not self.alpr.is_loaded():
print("Error loading OpenALPR")
except:
print "Error"
def proccess(self):
self.alpr.set_top_n(7)
self.alpr.set_default_region("md")
results = self.alpr.recognize_file("/tmp/1487428945.14.jpg")
print results
a = AnalizePlate()
a.proccess()
</code></pre>
<p>Above code works like a charm, but if GUI is involved, strange behavior occurs.</p>
<pre><code>from openalpr import Alpr
from PyQt4 import QtCore, QtGui
class AnalizePlate(object):
def __init__(self):
self.alpr = None
try:
self.alpr = Alpr("eu", "/etc/openalpr/openalpr.conf", "/usr/share/openalpr/runtime_data")
if not self.alpr.is_loaded():
print("Error loading OpenALPR")
except:
print "Error"
def proccess(self):
self.alpr.set_top_n(7)
self.alpr.set_default_region("md")
results = self.alpr.recognize_file("/tmp/1487428945.14.jpg")
print results
class Window(QtGui.QWidget):
def __init__(self):
super(Window, self).__init__()
self.resize(1198, 651)
self.analize = AnalizePlate()
self.analize.proccess()
QtCore.QMetaObject.connectSlotsByName(self)
if __name__ == "__main__":
import sys
import sip
app = QtGui.QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())
</code></pre>
<p>It's a basic example, but error is still here. Tried to implement <code>openalpr</code> code directly to <code>Window</code> class with no luck. So basicly, if there is no gui, code works. Using <code>openALPR version 2.2.4</code> and <code>PyQT4</code>. Also, checked the image, it's there. The same apply when <code>recognize_array()</code> is used instead of <code>recognize file</code>. Error I got is:</p>
<blockquote>
<p>OpenCV Error: Assertion failed (scaleFactor > 1 && image.depth() ==
CV_8U) in detectMultiScale, file
/build/opencv-SviWsf/opencv-2.4.9.1+dfsg/modules/objdetect/src/cascadedetect.cpp,
line 1081 Caught exception in OpenALPR recognize:
/build/opencv-SviWsf/opencv-2.4.9.1+dfsg/modules/objdetect/src/cascadedetect.cpp:1081:
error: (-215) scaleFactor > 1 && image.depth() == CV_8U in function
detectMultiScale</p>
<p>Traceback (most recent call last): File "analize.py", line 39, in
window = Window() File "analize.py", line 31, in <strong>init</strong>
self.analize.proccess() File "analize.py", line 22, in proccess
results = self.alpr.recognize_file("/tmp/1487428945.14.jpg") File "/usr/lib/python2.7/dist-packages/openalpr/openalpr.py", line
132, in recognize_file
response_obj = json.loads(json_data) File "/usr/lib/python2.7/json/<strong>init</strong>.py", line 339, in loads
return _default_decoder.decode(s) File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python2.7/json/decoder.py", line 380, in raw_decode
obj, end = self.scan_once(s, idx) ValueError: Expecting property name: line 1 column 122 (char 121)</p>
</blockquote>
| 0debug |
Android Studio pref Editor.putString identifier expected : <p>Getting a - cannot resolve symbol "putString" "putInt" "commit" - in the code below.Help please.</p>
<pre><code> public class Alpha extends Activity {
public static final String GAME_PREFERENCES = "GamePrefs";
SharedPreferences settings =getSharedPreferences(GAME_PREFERENCES,MODE_PRIVATE);
SharedPreferences.Editor prefEditor = settings.edit();
prefEditor.putString("Gama x","Blue Spec");
prefEditor.putInt("Wave",292);
prefEditor.commit();
}
</code></pre>
| 0debug |
static void virtio_pci_device_plugged(DeviceState *d, Error **errp)
{
VirtIOPCIProxy *proxy = VIRTIO_PCI(d);
VirtioBusState *bus = &proxy->bus;
bool legacy = virtio_pci_legacy(proxy);
bool modern;
bool modern_pio = proxy->flags & VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY;
uint8_t *config;
uint32_t size;
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
if (!proxy->ignore_backend_features &&
!virtio_has_feature(vdev->host_features, VIRTIO_F_VERSION_1)) {
virtio_pci_disable_modern(proxy);
if (!legacy) {
error_setg(errp, "Device doesn't support modern mode, and legacy"
" mode is disabled");
error_append_hint(errp, "Set disable-legacy to off\n");
return;
}
}
modern = virtio_pci_modern(proxy);
config = proxy->pci_dev.config;
if (proxy->class_code) {
pci_config_set_class(config, proxy->class_code);
}
if (legacy) {
if (virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM)) {
error_setg(errp, "VIRTIO_F_IOMMU_PLATFORM was supported by"
"neither legacy nor transitional device.");
return ;
}
pci_set_word(config + PCI_SUBSYSTEM_VENDOR_ID,
pci_get_word(config + PCI_VENDOR_ID));
pci_set_word(config + PCI_SUBSYSTEM_ID, virtio_bus_get_vdev_id(bus));
} else {
pci_set_word(config + PCI_VENDOR_ID,
PCI_VENDOR_ID_REDHAT_QUMRANET);
pci_set_word(config + PCI_DEVICE_ID,
0x1040 + virtio_bus_get_vdev_id(bus));
pci_config_set_revision(config, 1);
}
config[PCI_INTERRUPT_PIN] = 1;
if (modern) {
struct virtio_pci_cap cap = {
.cap_len = sizeof cap,
};
struct virtio_pci_notify_cap notify = {
.cap.cap_len = sizeof notify,
.notify_off_multiplier =
cpu_to_le32(virtio_pci_queue_mem_mult(proxy)),
};
struct virtio_pci_cfg_cap cfg = {
.cap.cap_len = sizeof cfg,
.cap.cfg_type = VIRTIO_PCI_CAP_PCI_CFG,
};
struct virtio_pci_notify_cap notify_pio = {
.cap.cap_len = sizeof notify,
.notify_off_multiplier = cpu_to_le32(0x0),
};
struct virtio_pci_cfg_cap *cfg_mask;
virtio_pci_modern_regions_init(proxy);
virtio_pci_modern_mem_region_map(proxy, &proxy->common, &cap);
virtio_pci_modern_mem_region_map(proxy, &proxy->isr, &cap);
virtio_pci_modern_mem_region_map(proxy, &proxy->device, &cap);
virtio_pci_modern_mem_region_map(proxy, &proxy->notify, ¬ify.cap);
if (modern_pio) {
memory_region_init(&proxy->io_bar, OBJECT(proxy),
"virtio-pci-io", 0x4);
pci_register_bar(&proxy->pci_dev, proxy->modern_io_bar_idx,
PCI_BASE_ADDRESS_SPACE_IO, &proxy->io_bar);
virtio_pci_modern_io_region_map(proxy, &proxy->notify_pio,
¬ify_pio.cap);
}
pci_register_bar(&proxy->pci_dev, proxy->modern_mem_bar_idx,
PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_PREFETCH |
PCI_BASE_ADDRESS_MEM_TYPE_64,
&proxy->modern_bar);
proxy->config_cap = virtio_pci_add_mem_cap(proxy, &cfg.cap);
cfg_mask = (void *)(proxy->pci_dev.wmask + proxy->config_cap);
pci_set_byte(&cfg_mask->cap.bar, ~0x0);
pci_set_long((uint8_t *)&cfg_mask->cap.offset, ~0x0);
pci_set_long((uint8_t *)&cfg_mask->cap.length, ~0x0);
pci_set_long(cfg_mask->pci_cfg_data, ~0x0);
}
if (proxy->nvectors) {
int err = msix_init_exclusive_bar(&proxy->pci_dev, proxy->nvectors,
proxy->msix_bar_idx, NULL);
if (err) {
if (err != -ENOTSUP) {
error_report("unable to init msix vectors to %" PRIu32,
proxy->nvectors);
}
proxy->nvectors = 0;
}
}
proxy->pci_dev.config_write = virtio_write_config;
proxy->pci_dev.config_read = virtio_read_config;
if (legacy) {
size = VIRTIO_PCI_REGION_SIZE(&proxy->pci_dev)
+ virtio_bus_get_vdev_config_len(bus);
size = pow2ceil(size);
memory_region_init_io(&proxy->bar, OBJECT(proxy),
&virtio_pci_config_ops,
proxy, "virtio-pci", size);
pci_register_bar(&proxy->pci_dev, proxy->legacy_io_bar_idx,
PCI_BASE_ADDRESS_SPACE_IO, &proxy->bar);
}
}
| 1threat |
passing data from web form PHP application to Java web application : There is two WEB applications based on two different servers. How I can pass data from the web form, which consist 5-10 fields (php web application) to Java application(Struts2, Spring2) in the most elegant and safe way. please give me suggestions | 0debug |
How to delete specific file with command prompt/bacth file : I have 2 file in the same folder.
These file names is
**test.xlsx**
and
**test.xlsx.jhdrsx**
I want to delete secondary file.( test.xlsx.jhdrsx)
it's mean,
I should say , If file extension lenght is 6 character then "delete to file"
or
If there is 6 character till "." , then delete
or somethingelse.
I have 60k file like that
How could it be?
| 0debug |
How to get data from 100 txt files in a folder, and put it in a single file(need file name as a column)? : I have a folder with 80 txt files and their names are years they were created(example 2008P1,2008P2 2009 P1 etc). Each file has a single column of data with more than 100000 rows. I want to put all these data in a single file in a sequence of their name(year wise).
The sequence would be the year they were created, oldest first, latest last.
Also I need an additional column in new file with the name of the file they were taken from.
Need to do this with Python or R.. Please help.
files:
2008
2008P1
2008p2
2009P1
2009p3
.
.
.
.
.
2019P3
Data in file:
$h|fffff|P|....
$C|fffff|P|....
.
.
.
.
. | 0debug |
Updating a colum in tableA with values from colum in table B : I'm trying to make an update of a multiple colums in table1 with values from a table that i've created
so i declare a table like this :
TYPE mon_tableau IS VARRAY (2) OF FLOAT;
v_tab mon_tableau;
i give it some values like this
v_tab := mon_tableau (10000, 20000);
then i make an sql statement that gets the values that i want to update with the two values (10000 and 20000) in my v_tab
is there a solution that it makes me do that update
i've tried a cursor in a loop
any suggestion please
thank you
| 0debug |
When using conemu with Windows 10 bash shell, why doesn't the UP key show the previous command? : <p>The up arrow scrolls through command history, but it doesn't work after I launch bash shell.</p>
| 0debug |
is LEAD a reserved word in MySQL SQL? : For this simple table, created in MySQL 8.012
CREATE TABLE `lead` (
`ID` int(11) NOT NULL,
`TS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`RS` json DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
The statement
*INSERT INTO lead (ID,RS) VALUES (1397,'{"ID":"1397","TITLE":"John Lenon -TESTE ZAPIER 54","HONORIFIC":"0"}')
ON DUPLICATE KEY UPDATE RS = VALUES(RS);*
FAILS when submitted through PhpMysqladmin with error
Static analysis:
3 errors were found during analysis.
Unrecognized keyword. (near "ON" at position 111)
Unrecognized keyword. (near "DUPLICATE" at position 114)
Unrecognized keyword. (near "KEY" at position 124)
SQL query:
INSERT INTO lead (ID,RS) VALUES (1397,'{"ID":"1397","TITLE":"John Lenon -TESTE ZAPIER 54","HONORIFIC":"0"}') ON DUPLICATE KEY UPDATE RS = VALUES(RS)
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'lead (ID,RS) VALUES (1397,'{"ID":"1397","TITLE":"John Lenon -TESTE ZAPIER 54","H' at line 1
HOWEVER, if the table name is changed, say, to "myleader", the statement works like a charm.
Any thoughts?
Thanks
Ronaldo
| 0debug |
void cpu_reset(CPUX86State *env)
{
int i;
memset(env, 0, offsetof(CPUX86State, breakpoints));
tlb_flush(env, 1);
env->old_exception = -1;
#ifdef CONFIG_SOFTMMU
env->hflags |= HF_SOFTMMU_MASK;
#endif
env->hflags2 |= HF2_GIF_MASK;
cpu_x86_update_cr0(env, 0x60000010);
env->a20_mask = ~0x0;
env->smbase = 0x30000;
env->idt.limit = 0xffff;
env->gdt.limit = 0xffff;
env->ldt.limit = 0xffff;
env->ldt.flags = DESC_P_MASK | (2 << DESC_TYPE_SHIFT);
env->tr.limit = 0xffff;
env->tr.flags = DESC_P_MASK | (11 << DESC_TYPE_SHIFT);
cpu_x86_load_seg_cache(env, R_CS, 0xf000, 0xffff0000, 0xffff,
DESC_P_MASK | DESC_S_MASK | DESC_CS_MASK | DESC_R_MASK);
cpu_x86_load_seg_cache(env, R_DS, 0, 0, 0xffff,
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK);
cpu_x86_load_seg_cache(env, R_ES, 0, 0, 0xffff,
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK);
cpu_x86_load_seg_cache(env, R_SS, 0, 0, 0xffff,
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK);
cpu_x86_load_seg_cache(env, R_FS, 0, 0, 0xffff,
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK);
cpu_x86_load_seg_cache(env, R_GS, 0, 0, 0xffff,
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK);
env->eip = 0xfff0;
env->regs[R_EDX] = env->cpuid_version;
env->eflags = 0x2;
for(i = 0;i < 8; i++)
env->fptags[i] = 1;
env->fpuc = 0x37f;
env->mxcsr = 0x1f80;
memset(env->dr, 0, sizeof(env->dr));
env->dr[6] = DR6_FIXED_1;
env->dr[7] = DR7_FIXED_1;
cpu_breakpoint_remove_all(env, BP_CPU);
cpu_watchpoint_remove_all(env, BP_CPU); | 1threat |
static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
{
AVFilterContext *ctx = inlink->dst;
AVFilterLink *outlink = ctx->outputs[0];
AVFilterBufferRef *outpicref = outlink->out_buf;
OverlayContext *over = ctx->priv;
if (over->overpicref &&
!(over->x >= outpicref->video->w || over->y >= outpicref->video->h ||
y+h < over->y || y >= over->y + over->overpicref->video->h)) {
blend_slice(ctx, outpicref, over->overpicref, over->x, over->y,
over->overpicref->video->w, over->overpicref->video->h,
y, outpicref->video->w, h);
}
avfilter_draw_slice(outlink, y, h, slice_dir);
}
| 1threat |
why this PHP and SQL code with HTML ( drop-down) select item do nothing? : <p>I write this code to retrieve data from the database table and insert the data in "select" drop-down menu, the below code do nothing and the select list empty, the table contains records. I guess there is something wrong with the code. any help? </p>
<pre><code><select class = "input100" name="C_Number" placeholder=" Select Course Number">
<span class="focus-input100"></span>
<span class="symbol-input100">
<i class="fa fa-envelope-o" aria-hidden="true"></i>
<?php
$Query = "SELECT * FROM `courses`";
$CrPost = mysqli_query($db,$Query) Or die($Query);
$post = mysqli_fetch_array($CrPost,MSQL_ASSOC);
do { ?>
<option value="<?php echo $post['C_ID'];?>"><?php echo $post['C_Title']; ?></option>
<?php } while ($post = mysqli_fetch_array($rsPost,MSQL_ASSOC)); ?>
</span> </select>
</code></pre>
| 0debug |
I made a game with Ruby, How do I make it playable on the internet?[Ruby] : <p>It is a very simple game, only consisting of about 80 lines of code, and 2 images. I am a new developer, so pardon my ignorance.
I uploaded the three files to a domain, but when I visit the location, it just downloads the file.
What do I need to do in order to have the file be executed opposed to just downloaded? What other information is relevant to running it as a 'web app'?
Thanks</p>
| 0debug |
Ruby: Use the return of the conditional for variable assignment and comparison : <p>I have a method and in order to check whether it is being passed a block, I do the following:</p>
<pre><code>if block_given?
res = yield(array[i], array[i+1])
else
res = array[i] - array[i+1]
end
</code></pre>
<p>However RuboCop is giving me a warning which I don't really understand in the <code>if block_given?</code> line: </p>
<blockquote>
<p>Use the return of the conditional for variable assignment and comparison</p>
</blockquote>
<p>Is there any other more rubyist way of doing this?</p>
<p>Thanks</p>
| 0debug |
How to remove text from String : <p>I have string as </p>
<p>------=_Part_0_rtkakab</p>
<p>Hello Testing1.
------=_Part_0_rtkakab</p>
<p>I want to change to
<strong>Hello Testing1.</strong> </p>
<p>What is the best way to do this.</p>
| 0debug |
Jar files not opening : <p>Okay so im not sure this is the place to ask, But all .jar files on my PC wont open, I don't understand why</p>
<p>I've tried reinstalling java, and messed with enviroment variables</p>
<p>Thank you for any help</p>
| 0debug |
How to make dropdown menu that only loads the text not whole new page? : <p>For my F.A.Q page I want the questions displayed in a drop menu where they click on it and then it displays the questions and then depending on which question they choose it shows the answer below.</p>
<p>I want to make it so that it does not take you to a whole new page I just want it to display the answer to the question.</p>
| 0debug |
rearrangement based on matching text in excel? : I will try and keep this as simple as possible. I have a list of names (first, last) in one column (A), then I get a second list which is usually about a quarter of the list in column A. **I want the cells in column b (the short list) to automatically rearrange so that the names are next to the name that matches in column A**. If there is anyone nice enough to tell me, if this match happens how I would go about getting the word present to be entered in the very next Column corresponding to the name on another sheet in the same work book, PLEASE. Thank You in advance for help. | 0debug |
Difference between min_samples_split and min_samples_leaf in sklearn DecisionTreeClassifier : <p>I was going through sklearn class <a href="http://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html" rel="noreferrer">DecisionTreeClassifier</a>.</p>
<p>Looking at parameters for the class, we have two parameters <strong>min_samples_split</strong> and <strong>min_samples_leaf</strong>. Basic idea behind them looks similar, you specify a minimum number of samples required to decide a node to be leaf or split further. </p>
<p>Why do we need two parameters when one implies the other?. Is there any reason or scenario which distinguish them?. </p>
| 0debug |
How to create an new instance of an Object in React? : <p>Obviously in normal JS I can do this</p>
<pre><code>var Card = function(rank, suit){
this.rank = rank;
this.suit = suit
}
var cardOne = new Card('3', 'H');
cardOne // Card {rank: "3", suit: "H"}
</code></pre>
<p>So how would I do that in react and ES6 land?</p>
<p>I have tried something like this:</p>
<pre><code>class ReactApp extends React.Component{
Card = (rank, suit) => {
this.rank = rank;
this.suit = suit;
};
createCard = () => {
let CardObj = {};
let card = new this.Card('3', 'Hearts');
console.log(card);
};
}
</code></pre>
<p>(not showing render method for now)</p>
<p>but how can I get that to log the correct thing in react?
how are functions treated inside React? (key value pairs?) and how do i define objects etc?</p>
| 0debug |
static int32_t parse_gain(const char *gain)
{
char *fraction;
int scale = 10000;
int32_t mb = 0;
int db;
if (!gain)
return INT32_MIN;
gain += strspn(gain, " \t");
db = strtol(gain, &fraction, 0);
if (*fraction++ == '.') {
while (av_isdigit(*fraction) && scale) {
mb += scale * (*fraction - '0');
scale /= 10;
fraction++;
}
}
if (abs(db) > (INT32_MAX - mb) / 100000)
return INT32_MIN;
return db * 100000 + FFSIGN(db) * mb;
}
| 1threat |
How to add a name column of character vectors to a data frame in R : <p>I have a data frame built as such:</p>
<pre><code>dput(au.weighted.scores)
structure(list(AUDIT = c(0.283333333333333, 0.283333333333333,
0.183333333333333, 0.3, 0.2625), CORC = c(0.2, 0, 0.76, 0.82,
0.545), GOV = c(0.82, 0.82, 0.74, 0.66, 0.76), PPS = c(0.2, 0.2,
0.2, 0.266666666666667, 0.216666666666667), TMSC = c(0.525, 0.525,
0.25, 0.158333333333333, 0.189583333333333), TRAIN = c(0.233333333333333,
0.233333333333333, 0.216666666666667, 0.266666666666667, 0.2375
)), .Names = c("AUDIT", "CORC", "GOV", "PPS", "TMSC", "TRAIN"
), row.names = c(NA, -5L), class = "data.frame")
</code></pre>
<p>I need to add a column of names that accompany the rows of this data frame. The column is c("Group1", "Group2", "Group3", "Group4", "Group5").</p>
<p>How can I add this column of names in with it's own column name like "Group_Name"?</p>
<p>The end result would look like this:</p>
<pre><code>au.weighted.scores
Group_Name AUDIT CORC GOV PPS TMSC TRAIN
1 Group1 0.2833333 0.200 0.82 0.2000000 0.5250000 0.2333333
2 Group2 0.2833333 0.000 0.82 0.2000000 0.5250000 0.2333333
3 Group3 0.1833333 0.760 0.74 0.2000000 0.2500000 0.2166667
4 Group4 0.3000000 0.820 0.66 0.2666667 0.1583333 0.2666667
5 Group5 0.2625000 0.545 0.76 0.2166667 0.1895833 0.2375000
</code></pre>
| 0debug |
Why this code return segmentation fault error : Im writing these code to optimize the time of problem and it is a dp problem
Given string S is .574674546476
for index 1
Number of even numbers from 5 to end of the string is 7 so the result of index 1 is 7.
for index 2
Number of even numbers from 7 to end of the string is 7 so the result of index 2 is 7.
for index 3
Number of even numbers from 4 to end of the string is 7 so the result of index 3 is 7.
for index 3
Number of even numbers from 6 to end of the string is 6 so the result of index 4 is 6.....
.
This is the code which ive tried but it show segmentation fault in this code
#include<bits/stdc++.h>
using namespace std;
int main(){
char str[10005];
int i;
cin>>str;
int n=strlen(str);
int arr[10005];
for(i=0;i<n;i++){
arr[i+1]=str[i]-48;
}
int tab[n+1];
if(arr[n]%2==0){
tab[n]=1;
}else{
tab[n]=0;
}
for(i=n-1;i>=1;i++){
if(arr[i]%2==0){
tab[i]=tab[i+1]+1;
}
else{
tab[i]=tab[i+1];
}
}
for(i=1;i<=n;i++){
cout<<tab[i]<<" ";
}
}
I expect output should be
7 7 7 6 5 5 4 4 3 2 1 1
when im giving input
574674546476 and i want to solve using dp i write the code but it show
segmentation fault. | 0debug |
static void mxf_write_multi_descriptor(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
AVIOContext *pb = s->pb;
const uint8_t *ul;
int i;
mxf_write_metadata_key(pb, 0x014400);
PRINT_KEY(s, "multiple descriptor key", pb->buf_ptr - 16);
klv_encode_ber_length(pb, 64 + 16 * s->nb_streams);
mxf_write_local_tag(pb, 16, 0x3C0A);
mxf_write_uuid(pb, MultipleDescriptor, 0);
PRINT_KEY(s, "multi_desc uid", pb->buf_ptr - 16);
mxf_write_local_tag(pb, 8, 0x3001);
avio_wb32(pb, mxf->time_base.den);
avio_wb32(pb, mxf->time_base.num);
mxf_write_local_tag(pb, 16, 0x3004);
if (mxf->essence_container_count > 1)
ul = multiple_desc_ul;
else {
MXFStreamContext *sc = s->streams[0]->priv_data;
ul = mxf_essence_container_uls[sc->index].container_ul;
}
avio_write(pb, ul, 16);
mxf_write_local_tag(pb, s->nb_streams * 16 + 8, 0x3F01);
mxf_write_refs_count(pb, s->nb_streams);
for (i = 0; i < s->nb_streams; i++)
mxf_write_uuid(pb, SubDescriptor, i);
}
| 1threat |
Promise vs setTimeout : <p>I've observed that in the following code:</p>
<pre><code>setTimeout(function(){console.log('setTimeout')});
Promise.resolve(1).then(function(){console.log('promise resolve')})
</code></pre>
<p>No matter how many times I execute this, the promise callback always logs before the setTimeout.</p>
<p>My understanding is that both callbacks are scheduled to be executed to the next tick, and I don't really understand what is going on that makes the promise always take precendence over the timeout.</p>
| 0debug |
window.outerWidth is 0 in Safari on iOS 10 beta : <p>Using an iPad with iOS 10 installed, I entered <code>window.outerWidth</code> in the browser console and got a value of <code>0</code>. OTOH, <code>window.innerWidth</code> correctly produced <code>1024</code> (landscape mode).</p>
<p>In iOS 9, <code>window.outerWidth</code> correctly produced <code>1024</code>, so is this just a bug in the iOS 10 beta or is there a subtlety to this property that I'm missing?</p>
| 0debug |
Can't break lines on Wordpress / Never programmed before, be patient : I'm totally a newbie in programming. In fact, I never programmed before. I'm creating a WordPress and everytime that I insert a code that was supposed to work in breaking a line doesn't and it turns off my WordPress.
If you could, ***please***, would you care to teach me, step by step, how to break a line from the WordPress Title?
I tried a lot, I read a lot, I even asked on Reddit but no one couldn't help me. | 0debug |
db.execute('SELECT * FROM products WHERE product_id = ' + product_input) | 1threat |
How do I check the last integer in the file in C? : <p>I need some help in finding the last integer in the file for my program. I have a file called "sample.txt" and I have a bunch of numbers in the file so I just want to get the last integer in the file and for example print it. Can somebody help me?</p>
| 0debug |
CLI error permission denied when connecting to MS SQL server via SAS ODBC : [enter image description here][1]
[1]: https://i.stack.imgur.com/fZckL.png
The user I am using has the highest allowed privilege in the db. We've also tested the script against the DB and we are able to delete but when running it in SAS this happens.
Would apprecite your help, guys! | 0debug |
static void vfio_map_bar(VFIOPCIDevice *vdev, int nr)
{
VFIOBAR *bar = &vdev->bars[nr];
uint64_t size = bar->region.size;
char name[64];
uint32_t pci_bar;
uint8_t type;
int ret;
if (!size) {
return;
}
snprintf(name, sizeof(name), "VFIO %04x:%02x:%02x.%x BAR %d",
vdev->host.domain, vdev->host.bus, vdev->host.slot,
vdev->host.function, nr);
ret = pread(vdev->vbasedev.fd, &pci_bar, sizeof(pci_bar),
vdev->config_offset + PCI_BASE_ADDRESS_0 + (4 * nr));
if (ret != sizeof(pci_bar)) {
error_report("vfio: Failed to read BAR %d (%m)", nr);
return;
}
pci_bar = le32_to_cpu(pci_bar);
bar->ioport = (pci_bar & PCI_BASE_ADDRESS_SPACE_IO);
bar->mem64 = bar->ioport ? 0 : (pci_bar & PCI_BASE_ADDRESS_MEM_TYPE_64);
type = pci_bar & (bar->ioport ? ~PCI_BASE_ADDRESS_IO_MASK :
~PCI_BASE_ADDRESS_MEM_MASK);
memory_region_init_io(&bar->region.mem, OBJECT(vdev), &vfio_region_ops,
bar, name, size);
pci_register_bar(&vdev->pdev, nr, type, &bar->region.mem);
if (vdev->msix && vdev->msix->table_bar == nr) {
size = vdev->msix->table_offset & qemu_host_page_mask;
}
strncat(name, " mmap", sizeof(name) - strlen(name) - 1);
if (vfio_mmap_region(OBJECT(vdev), &bar->region, &bar->region.mem,
&bar->region.mmap_mem, &bar->region.mmap,
size, 0, name)) {
error_report("%s unsupported. Performance may be slow", name);
}
if (vdev->msix && vdev->msix->table_bar == nr) {
uint64_t start;
start = HOST_PAGE_ALIGN(vdev->msix->table_offset +
(vdev->msix->entries * PCI_MSIX_ENTRY_SIZE));
size = start < bar->region.size ? bar->region.size - start : 0;
strncat(name, " msix-hi", sizeof(name) - strlen(name) - 1);
if (vfio_mmap_region(OBJECT(vdev), &bar->region, &bar->region.mem,
&vdev->msix->mmap_mem,
&vdev->msix->mmap, size, start, name)) {
error_report("%s unsupported. Performance may be slow", name);
}
}
vfio_bar_quirk_setup(vdev, nr);
}
| 1threat |
How can I do some functions in Ruby : In ruby
Using the oliver.txt ---> http://hills.ccsf.edu/~dputnam/oliver.txt
write a function called count_paragraphs() that counts the number of paragraphs in the text.
In oliver.txt the paragraph delimiter consists of two or more consecutive newline characters, like this: \n\n, \n\n\n, or even \n\n\n\n.
Your function should return either the number of paragraphs or nil.
I have this code but it doesn't work:
def count_paragraphs(some_file)
file_content = open(some_file).read()
count = 0
file_content_split = file_content.split('')
file_content_split.each_index do |index|
count += 1 if file_content_split[index] == "\n" &&
file_content_split[index + 1] == "\n"
end
return count
end
# test code
p count_paragraphs("oliver.txt") | 0debug |
static void lsi_do_msgout(LSIState *s)
{
uint8_t msg;
int len;
uint32_t current_tag;
SCSIDevice *current_dev;
lsi_request *p, *p_next;
int id;
if (s->current) {
current_tag = s->current->tag;
} else {
current_tag = s->select_tag;
}
id = (current_tag >> 8) & 0xf;
current_dev = s->bus.devs[id];
DPRINTF("MSG out len=%d\n", s->dbc);
while (s->dbc) {
msg = lsi_get_msgbyte(s);
s->sfbr = msg;
switch (msg) {
case 0x04:
DPRINTF("MSG: Disconnect\n");
lsi_disconnect(s);
break;
case 0x08:
DPRINTF("MSG: No Operation\n");
lsi_set_phase(s, PHASE_CMD);
break;
case 0x01:
len = lsi_get_msgbyte(s);
msg = lsi_get_msgbyte(s);
(void)len;
DPRINTF("Extended message 0x%x (len %d)\n", msg, len);
switch (msg) {
case 1:
DPRINTF("SDTR (ignored)\n");
lsi_skip_msgbytes(s, 2);
break;
case 3:
DPRINTF("WDTR (ignored)\n");
lsi_skip_msgbytes(s, 1);
break;
default:
goto bad;
}
break;
case 0x20:
s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
DPRINTF("SIMPLE queue tag=0x%x\n", s->select_tag & 0xff);
break;
case 0x21:
BADF("HEAD queue not implemented\n");
s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
break;
case 0x22:
BADF("ORDERED queue not implemented\n");
s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
break;
case 0x0d:
DPRINTF("MSG: ABORT TAG tag=0x%x\n", current_tag);
current_dev->info->cancel_io(current_dev, current_tag);
lsi_disconnect(s);
break;
case 0x06:
case 0x0e:
case 0x0c:
if (msg == 0x06) {
DPRINTF("MSG: ABORT tag=0x%x\n", current_tag);
}
if (msg == 0x0e) {
DPRINTF("MSG: CLEAR QUEUE tag=0x%x\n", current_tag);
}
if (msg == 0x0c) {
DPRINTF("MSG: BUS DEVICE RESET tag=0x%x\n", current_tag);
}
current_dev->info->cancel_io(current_dev, current_tag);
id = current_tag & 0x0000ff00;
QTAILQ_FOREACH_SAFE(p, &s->queue, next, p_next) {
if ((p->tag & 0x0000ff00) == id) {
current_dev->info->cancel_io(current_dev, p->tag);
QTAILQ_REMOVE(&s->queue, p, next);
}
}
lsi_disconnect(s);
break;
default:
if ((msg & 0x80) == 0) {
goto bad;
}
s->current_lun = msg & 7;
DPRINTF("Select LUN %d\n", s->current_lun);
lsi_set_phase(s, PHASE_CMD);
break;
}
}
return;
bad:
BADF("Unimplemented message 0x%02x\n", msg);
lsi_set_phase(s, PHASE_MI);
lsi_add_msg_byte(s, 7);
s->msg_action = 0;
}
| 1threat |
How to resolve the undefined reference error to readimagefile in dev C++ : <p>I am getting an error in Dev C++ with the function readimagefile.
It says 'undefined reference to readimagefile' whenever I try to use the function included in the header file 'graphics.h'. Here is my code to show an image:</p>
<pre><code>int main()
{
initwindow(600,600,"Trial");
readimagefile("alpha.jpg",0,0,500,500);
getch();
return 0;
}
</code></pre>
<p>It would be really helpful if someone could provide me with its correction or a substitute code to show an image.
Also if I input this image, would I be able to use this as a background? If not then what is the best way to import an image as a background in C++.</p>
<p>I have seen many people asking for help about this and fair enough, these errors doesn't show up on other compilers like code blocks or visual studio but I have to use Dev C++ so please make sure that your code is applicable in Dev C++.</p>
| 0debug |
React Router v4 nested routes props.children : <p>I'm updating my universal react redux app to use react router v4. I have nested routes under a main layout route. Previously I used {props.children} to show contents of child routes, but this doesn't work anymore. How does this work in V4? </p>
<pre><code><Provider store={store} key="provider">
<div>
<Route component={Layout} />
<Switch>
<Route path="/" component={HomePage} />
<Route component={Error404} />
</Switch>
</div>
</Provider>
</code></pre>
<p>or </p>
<pre><code><Provider store={store} key="provider">
<Layout>
<Route path="/" component={HomePage} />
<Route component={Error404} />
</Layout>
</Provider>
</code></pre>
<p>This is how my Layout file looks</p>
<pre><code>const Layout = props => (
<div className="o-container">
<Header />
<main>
{props.children}
</main>
<Footer />
</div>
);
</code></pre>
| 0debug |
How does this simple program not represent recursion? : <p>How does this "not" demonstrate recursion? It is a simple high/low find where I set "mid" to be the guess of the program's randomly selected number within the range. I am in a pissing match with an instructor. What do you think?</p>
<pre><code>#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
int main()
{
// define variables
int left = 1, mid, range, secret, y = 0;
// query user defined range, assign to variable range
cout << "Please enter top of range: " << endl;
cin >> range;
// seed random number generator with time
srand(time(NULL));
// generate secret number based between left and range
secret = rand() % range;
do {
// define and assign primary value of mid updating on each
iteration
mid = ((range + left) / 2);
if (mid > secret) {
// set range to mid
range = mid;
// iterate
y++;
} else if (mid < secret) {
// set left to mid
left = mid;
// iterate
y++;
} else {
// escape condition met
cout << "Found secret number " << secret << " in " << y
<< " tries. " << endl;
return 0;
}
} while (mid != secret);
return 0;
}
</code></pre>
| 0debug |
How to give jupyter cell standard input in python? : <p>I am trying to run a program on a jupyter notebook that accepts user input, and I cannot figure out how to get it to read standard input. For example, if I run the code with shift-enter:</p>
<pre><code>a = input()
print(a)
</code></pre>
<p>the cell indicates it is running, but does not accept input from me. How do I get it to accept input?</p>
| 0debug |
static int parse_picture_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
PGSSubContext *ctx = avctx->priv_data;
uint8_t sequence_desc;
unsigned int rle_bitmap_len, width, height;
if (buf_size <= 4)
return -1;
buf_size -= 4;
buf += 3;
sequence_desc = bytestream_get_byte(&buf);
if (!(sequence_desc & 0x80)) {
if (buf_size > ctx->picture.rle_remaining_len)
return -1;
memcpy(ctx->picture.rle + ctx->picture.rle_data_len, buf, buf_size);
ctx->picture.rle_data_len += buf_size;
ctx->picture.rle_remaining_len -= buf_size;
return 0;
}
if (buf_size <= 7)
return -1;
buf_size -= 7;
rle_bitmap_len = bytestream_get_be24(&buf) - 2*2;
width = bytestream_get_be16(&buf);
height = bytestream_get_be16(&buf);
if (avctx->width < width || avctx->height < height) {
av_log(avctx, AV_LOG_ERROR, "Bitmap dimensions larger than video.\n");
return -1;
}
ctx->picture.w = width;
ctx->picture.h = height;
av_fast_malloc(&ctx->picture.rle, &ctx->picture.rle_buffer_size, rle_bitmap_len);
if (!ctx->picture.rle)
return -1;
memcpy(ctx->picture.rle, buf, buf_size);
ctx->picture.rle_data_len = buf_size;
ctx->picture.rle_remaining_len = rle_bitmap_len - buf_size;
return 0;
}
| 1threat |
How to get all the details from multiple tables in Cake php? : I have two different tables as Post and Post_Info.
I want to get all the details using post_id in cake php from both the tables. The Post_Info table having post_id as foreign key and other related details.
I am new to cakephp and i don't know how to get data from multiple tables in cakephp. Please help me out.
I can get data from Post table using following query in cakephp.
Following code is getting data from Post table.
$userdata = $this->Post->find('first', array(
'conditions' => array('Post.post_id' => $post_id)
));
| 0debug |
static void blkverify_aio_bh(void *opaque)
{
BlkverifyAIOCB *acb = opaque;
if (acb->buf) {
qemu_iovec_destroy(&acb->raw_qiov);
qemu_vfree(acb->buf);
}
acb->common.cb(acb->common.opaque, acb->ret);
qemu_aio_unref(acb);
}
| 1threat |
Cooperative Scheduling vs Preemptive Scheduling? : <p>In the book <em>Core Java : Volume 1 Fundamentals -> chapter MultiThreading</em> . </p>
<p>The Author wrote as follows :</p>
<blockquote>
<p>"All modern desktop and server operating systems use preemptive
scheduling. However, smaller devices such as cell phones may use
cooperative scheduling...."</p>
</blockquote>
<p>I am aware of the definitions/workings of both types of scheduling , but want to understand reasons why cooperative scheduling is preferred over preemptive in smaller devices.</p>
<p>Can anyone explain the reasons why ? </p>
| 0debug |
cursor.execute('SELECT * FROM users WHERE username = ' + user_input) | 1threat |
static void handle_arg_cpu(const char *arg)
{
cpu_model = strdup(arg);
if (cpu_model == NULL || strcmp(cpu_model, "?") == 0) {
#if defined(cpu_list_id)
cpu_list_id(stdout, &fprintf, "");
#elif defined(cpu_list)
cpu_list(stdout, &fprintf);
#endif
exit(1);
}
}
| 1threat |
How to remove an instance of object from a list in python? : <p>I'm working on implementing Dijkstra's algorithm in python and I was wondering how I can remove an instance of an object from a list ?
Here's a part of my code in which I get an error: "list.remove(x): x not in list".</p>
<pre><code>class Vertex:
def __init__(self, id, name):
self.id = id
self.name = name
self.minDistance = float("inf")
self.previousVertex = None
self.edges = []
def computePath(self, sourceId):
for i in self.vertexes:
if i.id == sourceId:
startVertex = i
startVertex.minDistance=0
break
else:
continue
unvisited = []
for vertex in self.vertexes:
unvisited.append(vertex)
while len(unvisited)!=0:
self.visited.append(startVertex)
unvisited.remove(startVertex)
</code></pre>
| 0debug |
static void digic_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
dc->realize = digic_realize;
} | 1threat |
def odd_values_string(str):
result = ""
for i in range(len(str)):
if i % 2 == 0:
result = result + str[i]
return result | 0debug |
firebase.initializeApp callback/promise? : <p>This is my web page</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Calcolo Diliuzioni</title>
</head>
<body>
<h1>My app</h1>
<!-- Libreria per gestire l'autenticazione con google -->
<script src="https://apis.google.com/js/platform.js" async defer></script>
<!-- Firebae config -->
<script src="https://www.gstatic.com/firebasejs/live/3.0/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "",
authDomain: "",
databaseURL: "",
storageBucket: "",
};
firebase.initializeApp(config);
</script>
<script type="text/javascript">
var user = firebase.auth().currentUser;
if (user) {
console.log(user);
} else {
console.log(user);
}
</script>
</body>
</html>
</code></pre>
<p>Let's assume I have an already logged user. When I load the page in the console I got <code>null</code>. While I'm expecting to have the current user's object.</p>
<p>If I run the same code in the browser console</p>
<pre><code>var user = firebase.auth().currentUser;
if (user) {
console.log(user);
} else {
console.log(user);
}
</code></pre>
<p>I'm able to get the current user's object. </p>
<p>I think that the <code>firebase.initializeApp(config);</code> has some async behavior. What's the right way to work around it? Should I use a promise or something on the <code>firebase.initializeApp(config);</code> function? A sort of callback..</p>
| 0debug |
static void core_rtas_register_types(void)
{
spapr_rtas_register(RTAS_DISPLAY_CHARACTER, "display-character",
rtas_display_character);
spapr_rtas_register(RTAS_GET_TIME_OF_DAY, "get-time-of-day",
rtas_get_time_of_day);
spapr_rtas_register(RTAS_SET_TIME_OF_DAY, "set-time-of-day",
rtas_set_time_of_day);
spapr_rtas_register(RTAS_POWER_OFF, "power-off", rtas_power_off);
spapr_rtas_register(RTAS_SYSTEM_REBOOT, "system-reboot",
rtas_system_reboot);
spapr_rtas_register(RTAS_QUERY_CPU_STOPPED_STATE, "query-cpu-stopped-state",
rtas_query_cpu_stopped_state);
spapr_rtas_register(RTAS_START_CPU, "start-cpu", rtas_start_cpu);
spapr_rtas_register(RTAS_STOP_SELF, "stop-self", rtas_stop_self);
spapr_rtas_register(RTAS_IBM_GET_SYSTEM_PARAMETER,
"ibm,get-system-parameter",
rtas_ibm_get_system_parameter);
spapr_rtas_register(RTAS_IBM_SET_SYSTEM_PARAMETER,
"ibm,set-system-parameter",
rtas_ibm_set_system_parameter);
} | 1threat |
static int coroutine_fn iscsi_co_flush(BlockDriverState *bs)
{
IscsiLun *iscsilun = bs->opaque;
struct IscsiTask iTask;
if (bs->sg) {
return 0;
}
if (!iscsilun->force_next_flush) {
return 0;
}
iscsilun->force_next_flush = false;
iscsi_co_init_iscsitask(iscsilun, &iTask);
retry:
if (iscsi_synchronizecache10_task(iscsilun->iscsi, iscsilun->lun, 0, 0, 0,
0, iscsi_co_generic_cb, &iTask) == NULL) {
return -ENOMEM;
}
while (!iTask.complete) {
iscsi_set_events(iscsilun);
qemu_coroutine_yield();
}
if (iTask.task != NULL) {
scsi_free_scsi_task(iTask.task);
iTask.task = NULL;
}
if (iTask.do_retry) {
iTask.complete = 0;
goto retry;
}
if (iTask.status != SCSI_STATUS_GOOD) {
return -EIO;
}
return 0;
}
| 1threat |
int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt,
AVFormatContext *src)
{
AVPacket local_pkt;
local_pkt = *pkt;
local_pkt.stream_index = dst_stream;
if (pkt->pts != AV_NOPTS_VALUE)
local_pkt.pts = av_rescale_q(pkt->pts,
src->streams[pkt->stream_index]->time_base,
dst->streams[dst_stream]->time_base);
if (pkt->dts != AV_NOPTS_VALUE)
local_pkt.dts = av_rescale_q(pkt->dts,
src->streams[pkt->stream_index]->time_base,
dst->streams[dst_stream]->time_base);
if (pkt->duration)
local_pkt.duration = av_rescale_q(pkt->duration,
src->streams[pkt->stream_index]->time_base,
dst->streams[dst_stream]->time_base);
return av_write_frame(dst, &local_pkt);
}
| 1threat |
Angular-cli 8 - Is it possible to build only on es2015? : <p>In version 8 of angular-cli, the build is done 2x. One in es5 and one in es2015.</p>
<p>Is it possible to build only on es2015?</p>
<p>Changing the target to es5, it is done only in es5 .. But I have not found a way to do it only in es2015.</p>
| 0debug |
I want to create a word macro for table farmatting : I want to create a word macro that can do the following task at a single click.
Please help me.
I have a large document thats a trouble for me.
**The task includes a table formatting such as**
table width 11 cm,
left aligned,
font TNR 10,
border black,
indent from left is zero. | 0debug |
static void tosa_init(ram_addr_t ram_size, int vga_ram_size,
const char *boot_device,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
struct pxa2xx_state_s *cpu;
struct tc6393xb_s *tmio;
struct scoop_info_s *scp0, *scp1;
if (ram_size < (TOSA_RAM + TOSA_ROM + PXA2XX_INTERNAL_SIZE + TC6393XB_RAM)) {
fprintf(stderr, "This platform requires %i bytes of memory\n",
TOSA_RAM + TOSA_ROM + PXA2XX_INTERNAL_SIZE);
exit(1);
}
if (!cpu_model)
cpu_model = "pxa255";
cpu = pxa255_init(tosa_binfo.ram_size);
cpu_register_physical_memory(0, TOSA_ROM,
qemu_ram_alloc(TOSA_ROM) | IO_MEM_ROM);
tmio = tc6393xb_init(0x10000000,
pxa2xx_gpio_in_get(cpu->gpio)[TOSA_GPIO_TC6393XB_INT]);
scp0 = scoop_init(cpu, 0, 0x08800000);
scp1 = scoop_init(cpu, 1, 0x14800040);
tosa_gpio_setup(cpu, scp0, scp1, tmio);
tosa_microdrive_attach(cpu);
tosa_tg_init(cpu);
cpu->env->regs[15] = tosa_binfo.loader_start;
tosa_binfo.kernel_filename = kernel_filename;
tosa_binfo.kernel_cmdline = kernel_cmdline;
tosa_binfo.initrd_filename = initrd_filename;
tosa_binfo.board_id = 0x208;
arm_load_kernel(cpu->env, &tosa_binfo);
sl_bootparam_write(SL_PXA_PARAM_BASE);
}
| 1threat |
Unable to Remove Nan values. From dataset : When I am tring to predict the values for z , I am getting an error of
"ValueError: Input contains NaN, infinity or a value too large for dtype('float32')." Am i making a mistake in line data.fillna(0, inplace=True) or is there something else?
import pandas as pd
import numpy as np
from sklearn import cross_validation
from sklearn.ensemble import RandomForestClassifier
data = pd.read_csv("C:/Users/Animkush/Desktop/train.csv")
data.replace("?", -99999, inplace=True)
data.drop(["Id"], 1, inplace=True)
data.convert_objects(convert_numeric=True)
data.fillna(0, inplace=True)
data1 = pd.read_csv("C:/Users/Animkush/Desktop/test.csv")
data1.replace("?", -99999, inplace=True)
data1.drop(["Id"], 1, inplace=True)
data.convert_objects(convert_numeric=True)
data.fillna(0, inplace=True)
def handle_non_numerical_data(data):
columns = data.columns.values
for column in columns:
text_digit_vals = {}
def convert_to_int(val):
return text_digit_vals[val]
if data[column].dtype != np.int64 and data[column].dtype != np.float64:
column_contents = data[column].values.tolist()
unique_elements = set(column_contents)
x = 0
for unique in unique_elements:
if unique not in text_digit_vals:
text_digit_vals[unique] = x
x += 1
data[column] = list(map(convert_to_int, data[column]))
return data
data = handle_non_numerical_data(data)
data1 = handle_non_numerical_data(data1)
x = np.array(data.drop(["SalePrice"], 1))
y = np.array(data["SalePrice"])
z = np.array(data1)
X_train, X_test, Y_train, Y_test = cross_validation.train_test_split(x, y,test_size=0.1)
clf = RandomForestClassifier()
clf.fit(X_train, Y_train)
print(clf.score(X_train, Y_train))
print(clf.predict(z))
| 0debug |
static int decode_codestream(Jpeg2000DecoderContext *s)
{
Jpeg2000CodingStyle *codsty = s->codsty;
Jpeg2000QuantStyle *qntsty = s->qntsty;
uint8_t *properties = s->properties;
for (;;){
int oldpos, marker, len, ret = 0;
if (bytestream2_get_bytes_left(&s->g) < 2) {
av_log(s->avctx, AV_LOG_ERROR, "Missing EOC\n");
break;
}
marker = bytestream2_get_be16u(&s->g);
av_dlog(s->avctx, "marker 0x%.4X at pos 0x%x\n", marker, bytestream2_tell(&s->g) - 4);
oldpos = bytestream2_tell(&s->g);
if (marker == JPEG2000_SOD){
Jpeg2000Tile *tile = s->tile + s->curtileno;
if (ret = init_tile(s, s->curtileno)) {
av_log(s->avctx, AV_LOG_ERROR, "tile initialization failed\n");
return ret;
}
if (ret = jpeg2000_decode_packets(s, tile)) {
av_log(s->avctx, AV_LOG_ERROR, "packets decoding failed\n");
return ret;
}
continue;
}
if (marker == JPEG2000_EOC)
break;
if (bytestream2_get_bytes_left(&s->g) < 2)
return AVERROR(EINVAL);
len = bytestream2_get_be16u(&s->g);
switch (marker){
case JPEG2000_SIZ:
ret = get_siz(s);
break;
case JPEG2000_COC:
ret = get_coc(s, codsty, properties);
break;
case JPEG2000_COD:
ret = get_cod(s, codsty, properties);
break;
case JPEG2000_QCC:
ret = get_qcc(s, len, qntsty, properties);
break;
case JPEG2000_QCD:
ret = get_qcd(s, len, qntsty, properties);
break;
case JPEG2000_SOT:
if (!(ret = get_sot(s))){
codsty = s->tile[s->curtileno].codsty;
qntsty = s->tile[s->curtileno].qntsty;
properties = s->tile[s->curtileno].properties;
}
break;
case JPEG2000_COM:
bytestream2_skip(&s->g, len - 2);
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "unsupported marker 0x%.4X at pos 0x%x\n", marker, bytestream2_tell(&s->g) - 4);
bytestream2_skip(&s->g, len - 2);
break;
}
if (bytestream2_tell(&s->g) - oldpos != len || ret){
av_log(s->avctx, AV_LOG_ERROR, "error during processing marker segment %.4x\n", marker);
return ret ? ret : -1;
}
}
return 0;
} | 1threat |
Removing disabled from checkbox : <p>I have 2 checkboxes styled as toggle buttons.
The 2nd checkbox is by default <code>disabled</code>.
When the 1st checkbox is to ja I would like the 2nd checkbox to have <code>disabled</code> removed.</p>
<p>I have tried this with 2 codes but I did not succeed.
In my console I see no errors.</p>
<p><a href="https://i.stack.imgur.com/k39FT.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k39FT.jpg" alt=""></a></p>
<pre><code><div class="checkbox">
<label>
<input type="checkbox" id="email_user" name="email_user" data-toggle="toggle" data-size="small" data-on="Ja" data-off="Nee" onclick="remove_disabled()">
Verstuur melding ook per e-mail naar collega.
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" id="email_relatie" name="email_relatie" data-toggle="toggle" data-size="small" data-on="Ja" data-off="Nee" disabled>
Verstuur een kopie van deze melding naar de relatie.
</label>
</div>
</code></pre>
<p><strong>Option 1</strong></p>
<pre><code><script type="text/javascript">
function remove_disabled() {
document.getElementById('email_relatie').disabled = false;
}
</script>
</code></pre>
<p><strong>Option 2</strong></p>
<pre><code><script type="text/javascript">
function remove_disabled() {
document.getElementById('email_relatie').removeAttr('disabled')
}
</script>
</code></pre>
| 0debug |
static TCGv gen_vfp_mrs(void)
{
TCGv tmp = new_tmp();
tcg_gen_mov_i32(tmp, cpu_F0s);
return tmp;
}
| 1threat |
static int vp3_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
Vp3DecodeContext *s = avctx->priv_data;
GetBitContext gb;
static int counter = 0;
*data_size = 0;
init_get_bits(&gb, buf, buf_size * 8);
s->keyframe = get_bits(&gb, 1);
s->keyframe ^= 1;
skip_bits(&gb, 1);
s->last_quality_index = s->quality_index;
s->quality_index = get_bits(&gb, 6);
if (s->quality_index != s->last_quality_index)
init_dequantizer(s);
debug_vp3(" VP3 frame #%d: Q index = %d", counter, s->quality_index);
counter++;
if (s->keyframe) {
if ((s->golden_frame.data[0]) &&
(s->last_frame.data[0] == s->golden_frame.data[0]))
avctx->release_buffer(avctx, &s->golden_frame);
else if (s->last_frame.data[0])
avctx->release_buffer(avctx, &s->last_frame);
s->golden_frame.reference = 0;
if(avctx->get_buffer(avctx, &s->golden_frame) < 0) {
printf("vp3: get_buffer() failed\n");
return -1;
}
memcpy(&s->current_frame, &s->golden_frame, sizeof(AVFrame));
if (!s->pixel_addresses_inited)
vp3_calculate_pixel_addresses(s);
} else {
s->current_frame.reference = 0;
if(avctx->get_buffer(avctx, &s->current_frame) < 0) {
printf("vp3: get_buffer() failed\n");
return -1;
}
}
if (s->keyframe) {
debug_vp3(", keyframe\n");
skip_bits(&gb, 16);
} else
debug_vp3("\n");
init_frame(s, &gb);
#if KEYFRAMES_ONLY
if (!s->keyframe) {
memcpy(s->current_frame.data[0], s->golden_frame.data[0],
s->current_frame.linesize[0] * s->height);
memcpy(s->current_frame.data[1], s->golden_frame.data[1],
s->current_frame.linesize[1] * s->height / 2);
memcpy(s->current_frame.data[2], s->golden_frame.data[2],
s->current_frame.linesize[2] * s->height / 2);
} else {
#endif
if (unpack_superblocks(s, &gb) ||
unpack_modes(s, &gb) ||
unpack_vectors(s, &gb) ||
unpack_dct_coeffs(s, &gb)) {
printf(" vp3: could not decode frame\n");
return -1;
}
reverse_dc_prediction(s, 0, s->fragment_width, s->fragment_height);
reverse_dc_prediction(s, s->u_fragment_start,
s->fragment_width / 2, s->fragment_height / 2);
reverse_dc_prediction(s, s->v_fragment_start,
s->fragment_width / 2, s->fragment_height / 2);
render_fragments(s, 0, s->width, s->height, 0);
render_fragments(s, s->u_fragment_start, s->width / 2, s->height / 2, 1);
render_fragments(s, s->v_fragment_start, s->width / 2, s->height / 2, 2);
#if KEYFRAMES_ONLY
}
#endif
*data_size=sizeof(AVFrame);
*(AVFrame*)data= s->current_frame;
if ((s->last_frame.data[0]) &&
(s->last_frame.data[0] != s->golden_frame.data[0]))
avctx->release_buffer(avctx, &s->last_frame);
memcpy(&s->last_frame, &s->current_frame, sizeof(AVFrame));
return buf_size;
}
| 1threat |
int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f)
{
SaveStateEntry *se;
QTAILQ_FOREACH(se, &savevm_handlers, entry) {
if (se->save_live_state == NULL)
continue;
qemu_put_byte(f, QEMU_VM_SECTION_END);
qemu_put_be32(f, se->section_id);
se->save_live_state(mon, f, QEMU_VM_SECTION_END, se->opaque);
}
QTAILQ_FOREACH(se, &savevm_handlers, entry) {
int len;
if (se->save_state == NULL && se->vmsd == NULL)
continue;
qemu_put_byte(f, QEMU_VM_SECTION_FULL);
qemu_put_be32(f, se->section_id);
len = strlen(se->idstr);
qemu_put_byte(f, len);
qemu_put_buffer(f, (uint8_t *)se->idstr, len);
qemu_put_be32(f, se->instance_id);
qemu_put_be32(f, se->version_id);
vmstate_save(f, se);
}
qemu_put_byte(f, QEMU_VM_EOF);
if (qemu_file_has_error(f))
return -EIO;
return 0;
} | 1threat |
How to position a text below an ImageView that takes up entire screen? : I am trying to code one of my first android apps. I am trying to position a text below an image, but the image takes up most of the screen and any of the textviews which are supposed to be below it are not displayed. I am using a Relative Layout.
Here is my code snippet-
<RelativeLayout
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.jsk.myapp.MainActivity">
<TextView
android:id="@+id/t1"
android:layout_width="wrap_content"
android:text="My App"
android:layout_centerHorizontal="true"
android:textSize="30sp"
android:layout_alignParentTop="true"
android:layout_height="wrap_content" />
<ImageView
android:scaleType="centerCrop"
android:id="@+id/img"
android:layout_below="@id/t1"
android:layout_width="match_parent"
android:layout_height="200dp"
android:src="@drawable/i1"
/>
<TextView
android:id="@+id/t2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/img"
android:textSize="24sp"
android:text="Description"/>
</RelativeLayout>
I have also tried changing the scale type of the imageview, but it doesnt work. Only when I explicitly specify the width and height parameters of the image, the text is visible below the image.
What changes can I make in this code to get the desired output ? | 0debug |
static int get_physical_address_data(CPUState *env,
target_phys_addr_t *physical, int *prot,
target_ulong address, int rw, int is_user)
{
target_ulong mask;
unsigned int i;
if ((env->lsu & DMMU_E) == 0) {
*physical = address;
*prot = PAGE_READ | PAGE_WRITE;
return 0;
}
for (i = 0; i < 64; i++) {
switch ((env->dtlb_tte[i] >> 61) & 3) {
default:
case 0x0:
mask = 0xffffffffffffe000ULL;
break;
case 0x1:
mask = 0xffffffffffff0000ULL;
break;
case 0x2:
mask = 0xfffffffffff80000ULL;
break;
case 0x3:
mask = 0xffffffffffc00000ULL;
break;
}
if (env->dmmuregs[1] == (env->dtlb_tag[i] & 0x1fff) &&
(address & mask) == (env->dtlb_tag[i] & mask) &&
(env->dtlb_tte[i] & 0x8000000000000000ULL)) {
if (((env->dtlb_tte[i] & 0x4) && is_user) ||
(!(env->dtlb_tte[i] & 0x2) && (rw == 1))) {
if (env->dmmuregs[3])
env->dmmuregs[3] = 2;
env->dmmuregs[3] |= (is_user << 3) | ((rw == 1) << 2) | 1;
env->dmmuregs[4] = address;
env->exception_index = TT_DFAULT;
#ifdef DEBUG_MMU
printf("DFAULT at 0x%" PRIx64 "\n", address);
#endif
return 1;
}
*physical = ((env->dtlb_tte[i] & mask) | (address & ~mask)) &
0x1ffffffe000ULL;
*prot = PAGE_READ;
if (env->dtlb_tte[i] & 0x2)
*prot |= PAGE_WRITE;
return 0;
}
}
#ifdef DEBUG_MMU
printf("DMISS at 0x%" PRIx64 "\n", address);
#endif
env->dmmuregs[6] = (address & ~0x1fffULL) | (env->dmmuregs[1] & 0x1fff);
env->exception_index = TT_DMISS;
return 1;
}
| 1threat |
React component render is called multiple times when pushing new URL : <p>I am building a PhotoViewer that changes photos when the user presses left or right. I am using React, Redux, react-router, and react-router-redux. When the user presses left or right, I do two things, I update the url using <code>this.context.replace()</code> and I dispatch an action to update the currently viewed photo, <code>this.props.dispatch(setPhoto(photoId))</code>. I am subscribing to state changes for debugging.</p>
<p>Each of the above lines triggers a new state change. Dispatching an action updates the store since I update the <code>currentlyViewedPhoto</code> and updating the url updates the store because react-router-redux updates the url in the store. When I dispatch the action, in the first rerendering cycle, the component's <code>render</code> function gets called twice. In the second rerendering cycle, the component's <code>render</code> function gets called once. Is this normal? Here is the relevant code:</p>
<pre><code>class PhotoViewer extends Component {
pressLeftOrRightKey(e) {
... code to detect that left or right arrow was pressed ...
// Dispatching the action triggers a state update
// render is called once after the following line
this.props.dispatch(setPhoto(photoId)) // assume photoId is correct
// Changing the url triggers a state update
// render is called twice
this.context.router.replace(url) // assume url is correct
return
}
render() {
return (
<div>Test</div>
)
}
}
function select(state) {
return state
}
export default connect(select)(PhotoViewer)
</code></pre>
<p>Is this normal that render is called three times? It seems like overkill because React will have to do the DOM diffing three times. I guess it won't really matter because nothing has changed. I am new to this toolset, so feel free to ask any more questions about this problem.</p>
| 0debug |
destructor in Kotlin programming language : <p>I am new to Kotlin, have written a class in kotlin to perform database operation</p>
<p>I have defined database connection in constructor using init but I want to close database connection using destructor.</p>
<p>Any Idea of how to achieve this using kotlin destructor?</p>
<p>Currently I have wrote a separate function to close connection, which i want to have it using destructor like any other programming language like php,etc</p>
| 0debug |
How to use generator function in typescript : <p>I am trying to use generator function in typescript. But the compiler throws error</p>
<p><code>
error TS2339: Property 'next' does not exist on type
</code></p>
<p>Below is an closest sample of my code.</p>
<pre><code>export default class GeneratorClass {
constructor() {
this.generator(10);
this.generator.next();
}
*generator(count:number): Iterable<number | undefined> {
while(true)
yield count++;
}
}
</code></pre>
<p><a href="http://www.typescriptlang.org/play/#src=export%20default%20class%20GeneratorClass%20%7B%0D%0A%20%20%20%20constructor()%20%7B%0D%0A%20%20%20%20%20%20%20%20this.generator(10)%3B%0D%0A%20%20%20%20%20%20%20%20this.generator.next()%3B%0D%0A%20%20%20%20%7D%0D%0A%20%20%20%20*generator(count%3Anumber)%3A%20Iterable%3Cnumber%20%7C%20undefined%3E%20%7B%0D%0A%20%20%20%20%20%20%20%20while(true)%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20yield%20count%2B%2B%3B%0D%0A%20%20%20%20%7D%20%20%20%0D%0A%7D" rel="noreferrer">Here is the playground link for the same</a></p>
| 0debug |
How to set stroke color to draw a rectangle on canvas? : <p>I want to draw a round rectangle which its stroke is blue and its fill is red, but I can't find a method in Paint class to set stroke color. How can I do that?</p>
<pre><code> mCanvas.drawColor(mBackgroundColor, PorterDuff.Mode.CLEAR);
mCanvas.setDrawFilter(mPaintFlagsDrawFilter);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mPaint.setColor(Color.RED);
mPaint.setStrokeWidth(2);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mRectF.set(0, 0, mWidth, mHeight);
mCanvas.drawRoundRect(mRectF, 10, 10, mPaint);
</code></pre>
| 0debug |
How to scale Lambda when /tmp is reused? : <p>I have a lambda function that reads from DynamoDB and creates a large file (~500M) in /tmp that finally uploaded to s3. Once uploaded the lambda clears the file from /tmp (since there is a high probability that the instance may be reused)</p>
<p>This function takes about 1 minute to execute, even if you ignore the latencies.</p>
<p>In this scenario, when i try to invoke the function again, in < 1m, i have no control if i will have enough space to write to /tmp. My function fails.</p>
<p>Questions:
1. What are the known work arounds in these kind of scenario?
(Potentially give more space in /tmp or ensure a clean /tmp is given for each new execution)
2. What are the best practices regarding file creation and management in Lambda?
3. Can i attach another EBS or other storage to Lambda for execution ?
4. Is there a way to have file system like access to s3 so that my function instead of using /tmp can write directly to s3?</p>
| 0debug |
Installing odoo-12 on ubuntu-16.04 : <p>** ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
File "/home/eslammofreh/.local/lib/python3.5/site-packages/werkzeug/serving.py", line 270, in run_wsgi
execute(self.server.app)
File "/home/eslammofreh/.local/lib/python3.5/site-packages/werkzeug/serving.py", line 258, in execute
application_iter = app(environ, start_response)
File "/home/workplace/odoo/odoo/service/server.py", line 350, in app
return self.app(e, s)
File "/home/workplace/odoo/odoo/service/wsgi_server.py", line 128, in application
return application_unproxied(environ, start_response)
File "/home/workplace/odoo/odoo/service/wsgi_server.py", line 117, in application_unproxied
result = odoo.http.root(environ, start_response)
File "/home/workplace/odoo/odoo/http.py", line 1318, in <strong>call</strong>
return self.dispatch(environ, start_response)
File "/home/workplace/odoo/odoo/http.py", line 1291, in <strong>call</strong>
return self.app(environ, start_wrapped)
File "/home/eslammofreh/.local/lib/python3.5/site-packages/werkzeug/wsgi.py", line 766, in <strong>call</strong>
return self.app(environ, start_response)
File "/home/workplace/odoo/odoo/http.py", line 1451, in dispatch
self.setup_db(httprequest)
File "/home/workplace/odoo/odoo/http.py", line 1374, in setup_db
httprequest.session.db = db_monodb(httprequest)
File "/home/workplace/odoo/odoo/http.py", line 1535, in db_monodb
dbs = db_list(True, httprequest)
File "/home/workplace/odoo/odoo/http.py", line 1502, in db_list
dbs = odoo.service.db.list_dbs(force)
File "/home/workplace/odoo/odoo/service/db.py", line 375, in list_dbs
with closing(db.cursor()) as cr:
File "/home/workplace/odoo/odoo/sql_db.py", line 657, in cursor
return Cursor(self.<strong>pool, self.dbname, self.dsn, serialized=serialized)
File "/home/workplace/odoo/odoo/sql_db.py", line 171, in __init</strong>
self._cnx = pool.borrow(dsn)
File "/home/workplace/odoo/odoo/sql_db.py", line 540, in _locked
return fun(self, *args, <strong>kwargs)
File "/home/workplace/odoo/odoo/sql_db.py", line 608, in borrow
**connection_info)
File "/home/eslammofreh/.local/lib/python3.5/site-packages/psycopg2/__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL: role "eslammofreh" does not exist - - -
2019-03-09 18:18:59,091 1892 INFO ? odoo.sql_db: Connection to the database failed
2019-03-09 18:18:59,093 1892 INFO ? werkzeug: 127.0.0.1 - - [09/Mar/2019 18:18:59] "GET /favicon.ico HTTP/1.1" 500 - 0 0.000 0.005
2019-03-09 18:18:59,098 1892 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
File "/home/eslammofreh/.local/lib/python3.5/site-packages/werkzeug/serving.py", line 270, in run_wsgi
execute(self.server.app)
File "/home/eslammofreh/.local/lib/python3.5/site-packages/werkzeug/serving.py", line 258, in execute
application_iter = app(environ, start_response)
File "/home/workplace/odoo/odoo/service/server.py", line 350, in app
return self.app(e, s)
File "/home/workplace/odoo/odoo/service/wsgi_server.py", line 128, in application
return application_unproxied(environ, start_response)
File "/home/workplace/odoo/odoo/service/wsgi_server.py", line 117, in application_unproxied
result = odoo.http.root(environ, start_response)
File "/home/workplace/odoo/odoo/http.py", line 1318, in __call__
return self.dispatch(environ, start_response)
File "/home/workplace/odoo/odoo/http.py", line 1291, in __call__
return self.app(environ, start_wrapped)
File "/home/eslammofreh/.local/lib/python3.5/site-packages/werkzeug/wsgi.py", line 766, in __call__
return self.app(environ, start_response)
File "/home/workplace/odoo/odoo/http.py", line 1451, in dispatch
self.setup_db(httprequest)
File "/home/workplace/odoo/odoo/http.py", line 1374, in setup_db
httprequest.session.db = db_monodb(httprequest)
File "/home/workplace/odoo/odoo/http.py", line 1535, in db_monodb
dbs = db_list(True, httprequest)
File "/home/workplace/odoo/odoo/http.py", line 1502, in db_list
dbs = odoo.service.db.list_dbs(force)
File "/home/workplace/odoo/odoo/service/db.py", line 375, in list_dbs
with closing(db.cursor()) as cr:
File "/home/workplace/odoo/odoo/sql_db.py", line 657, in cursor
return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
File "/home/workplace/odoo/odoo/sql_db.py", line 171, in __init__
self._cnx = pool.borrow(dsn)
File "/home/workplace/odoo/odoo/sql_db.py", line 540, in _locked
return fun(self, *args, **kwargs)
File "/home/workplace/odoo/odoo/sql_db.py", line 608, in borrow
**connection_info)
File "/home/eslammofreh/.local/lib/python3.5/site-packages/psycopg2/__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL: role "eslammofreh" does not exist -</strong></p>
| 0debug |
how to do a column split and dcast in r : <p>I have following dataframe in r</p>
<pre><code> Date Weather
2018-01-01 Rain,Fog
2018-01-02 Fog,Rain
2018-01-03 Rain
2018-01-04 Thunderstorm
2018-01-05 Rain,Fog
2018-01-06 Rain,Thunderstorm
</code></pre>
<p>My desired dataframe would be</p>
<pre><code> Date Rain Fog Thunderstorm
2018-01-01 1 1 0
2018-01-02 1 1 0
2018-01-03 1 0 0
2018-01-04 0 0 1
2018-01-05 1 1 0
2018-01-06 1 0 1
</code></pre>
<p>How can I do it in R? </p>
| 0debug |
void spapr_tce_reset(sPAPRTCETable *tcet)
{
size_t table_size = (tcet->window_size >> SPAPR_TCE_PAGE_SHIFT)
* sizeof(sPAPRTCE);
tcet->bypass = false;
memset(tcet->table, 0, table_size);
}
| 1threat |
int av_parse_color(uint8_t *rgba_color, const char *color_string, void *log_ctx)
{
if (!strcasecmp(color_string, "random") || !strcasecmp(color_string, "bikeshed")) {
int rgba = ff_random_get_seed();
rgba_color[0] = rgba >> 24;
rgba_color[1] = rgba >> 16;
rgba_color[2] = rgba >> 8;
rgba_color[3] = rgba;
} else
if (!strncmp(color_string, "0x", 2)) {
char *tail;
int len = strlen(color_string);
int rgba = strtol(color_string, &tail, 16);
if (*tail || (len != 8 && len != 10)) {
av_log(log_ctx, AV_LOG_ERROR, "Invalid 0xRRGGBB[AA] color string: '%s'\n", color_string);
return -1;
}
if (len == 10) {
rgba_color[3] = rgba;
rgba >>= 8;
}
rgba_color[0] = rgba >> 16;
rgba_color[1] = rgba >> 8;
rgba_color[2] = rgba;
} else {
const ColorEntry *entry = bsearch(color_string,
color_table,
FF_ARRAY_ELEMS(color_table),
sizeof(ColorEntry),
color_table_compare);
if (!entry) {
av_log(log_ctx, AV_LOG_ERROR, "Cannot find color '%s'\n", color_string);
return -1;
}
memcpy(rgba_color, entry->rgba_color, 4);
}
return 0;
}
| 1threat |
i have a json data in controller i am passing it to twig file . i want to loop json data in twig file to create equal attributes like shown below : ** this is my controller where i am creating json data and passing it to twigfile**
/**
*this route is for inserting data into datatable of modal of bootstrap
*@Route("/pagerduty/edit_team_datatable")
*@return Response
*/
public function edit_teble(Request $request){
$edit = new team_details();
$row_id = $request->query->get('row_id');
$query= ("SELECT tr.id, GROUP_CONCAT(u.usrName SEPARATOR ',') AS team_members FROM team_details td
INNER JOIN team_registration tr ON tr.id=td.team_name
INNER JOIN user u ON u.usrid=td.team_members_names
where td.team_name=$row_id
GROUP BY td.team_name");
$em = $this->getDoctrine()->getManager();
$statement = $em->getConnection()->prepare($query);
$statement->execute();
$result = $statement->fetch();
// print_r($result);die;
//return $this->render("team_display.html.twig",array('edit_table'=>$result));
return new JsonResponse($result);
}
<!-- begin snippet: js hide: false console: true babel: false -->
** i am receiving json response in this manner where id is only "1" and team_members is "8" .so,now i want to create 8 id for 8 team members plz help me in achieving this
**
this is json data :
{"id":"21","team_members":"teja,preetham,kick,preetham,teja,meuser,kick,preetham"}
what i need is this format using looping plz help me :
{"id":"21,21,21,21,21,21,21,21","team_members":"teja,preetham,kick,preetham,teja,meuser,kick,preetham"}
<!-- end snippet -->
| 0debug |
Retrieve Xml attribute value using XElement and modified and send back c# : <p>I have below mention input. I found this xml input as string and fetch datetime field as desired and change there datetime to utcdatetime and also want to change in diffrent UTC format.After change modify this xml and send back for peocess. using c#</p>
<p>
<br>
</p>
| 0debug |
static int nvdec_hevc_decode_init(AVCodecContext *avctx)
{
const HEVCContext *s = avctx->priv_data;
const HEVCSPS *sps = s->ps.sps;
return ff_nvdec_decode_init(avctx, sps->temporal_layer[sps->max_sub_layers - 1].max_dec_pic_buffering + 1);
}
| 1threat |
(PHP) Array push string with variable : <p>I'm new to PHP, I tried to use the array push function which I would like to combine the string with variable but it turns out strange result.</p>
<p>I applied it to Google Chart which it will create the chart.</p>
<pre><code>for($i = 0; $i < $table_counter; $i++){
array_push($pieData1, array( "Available seat(s) of " + $pos_chart[$i], $slot_chart[$i]));
}
</code></pre>
<p>This is the code that I use for array that it use to create the chart. The chart is generated, the header of the chart should be "Available seat(s) of xxx position" but it turns out as "0". </p>
<p>So, what I should change?</p>
| 0debug |
NPM - Failed to replace env in config: ${NPM_TOKEN} : <p>I am trying to build a react app, but when I execute the command <code>npm -i</code> it gives me the following error:</p>
<pre><code>Error: Failed to replace env in config: ${NPM_TOKEN}
at /usr/local/lib/node_modules/npm/lib/config/core.js:415:13
at String.replace (<anonymous>)
at envReplace (/usr/local/lib/node_modules/npm/lib/config/core.js:411:12)
at parseField (/usr/local/lib/node_modules/npm/lib/config/core.js:389:7)
at /usr/local/lib/node_modules/npm/lib/config/core.js:330:24
at Array.forEach (<anonymous>)
at Conf.add (/usr/local/lib/node_modules/npm/lib/config/core.js:328:23)
at ConfigChain.addString (/usr/local/lib/node_modules/npm/node_modules/config-chain/index.js:244:8)
at Conf.<anonymous> (/usr/local/lib/node_modules/npm/lib/config/core.js:316:10)
at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16
/usr/local/lib/node_modules/npm/lib/npm.js:61
throw new Error('npm.load() required')
^
Error: npm.load() required
at Object.get (/usr/local/lib/node_modules/npm/lib/npm.js:61:13)
at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205:18)
at process.emit (events.js:182:13)
at process._fatalException (internal/bootstrap/node.js:448:27)
</code></pre>
<p>I am using MacOS High Sierra. I tried to set the NPM_TOKEN as an environment variable with following command:</p>
<pre><code>set -x NPM_TOKEN = xyz
</code></pre>
<p>but it doesn't work.
What is the problem?</p>
| 0debug |
Export more than one variable in ES6? : <p>I'm trying to export more than one variable in ES6:</p>
<p>exports.js</p>
<pre><code>var TestObject = Parse.Object.extend('TestObject')
var Post = Parse.Object.extend('Post')
export default TestObject
export Post
</code></pre>
<p>main.js:</p>
<pre><code>import TestObject from '../store'
import Post from '../store'
var testObject = new TestObject() // use Post in the same way
testObject.save(json).then(object => {
console.log('yay! it worked', object)
})
</code></pre>
<p>I understand that there's only one default value so I only used <code>default</code> in the first item.</p>
<p>However, I get this error message:</p>
<pre><code>Module build failed: SyntaxError: /home/alex/node/my-project/src/store/index.js: Unexpected token (9:7)
7 |
8 | export default TestObject
> 9 | export Post
</code></pre>
<p>Maybe I'm doing it the wrong way?</p>
| 0debug |
int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
BlockDriver *drv)
{
int ret, open_flags;
char tmp_filename[PATH_MAX];
char backing_filename[PATH_MAX];
bs->is_temporary = 0;
bs->encrypted = 0;
bs->valid_key = 0;
bs->buffer_alignment = 512;
if (flags & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
int64_t total_size;
int is_protocol = 0;
BlockDriver *bdrv_qcow2;
QEMUOptionParameter *options;
bs1 = bdrv_new("");
ret = bdrv_open2(bs1, filename, 0, drv);
if (ret < 0) {
bdrv_delete(bs1);
return ret;
}
total_size = bdrv_getlength(bs1) >> BDRV_SECTOR_BITS;
if (bs1->drv && bs1->drv->protocol_name)
is_protocol = 1;
bdrv_delete(bs1);
get_tmp_filename(tmp_filename, sizeof(tmp_filename));
if (is_protocol)
snprintf(backing_filename, sizeof(backing_filename),
"%s", filename);
else if (!realpath(filename, backing_filename))
return -errno;
bdrv_qcow2 = bdrv_find_format("qcow2");
options = parse_option_parameters("", bdrv_qcow2->create_options, NULL);
set_option_parameter_int(options, BLOCK_OPT_SIZE, total_size * 512);
set_option_parameter(options, BLOCK_OPT_BACKING_FILE, backing_filename);
if (drv) {
set_option_parameter(options, BLOCK_OPT_BACKING_FMT,
drv->format_name);
}
ret = bdrv_create(bdrv_qcow2, tmp_filename, options);
if (ret < 0) {
return ret;
}
filename = tmp_filename;
drv = bdrv_qcow2;
bs->is_temporary = 1;
}
pstrcpy(bs->filename, sizeof(bs->filename), filename);
if (flags & BDRV_O_FILE) {
drv = find_protocol(filename);
} else if (!drv) {
drv = find_hdev_driver(filename);
if (!drv) {
drv = find_image_format(filename);
}
}
if (!drv) {
ret = -ENOENT;
goto unlink_and_fail;
}
bs->drv = drv;
bs->opaque = qemu_mallocz(drv->instance_size);
if (flags & (BDRV_O_CACHE_WB|BDRV_O_NOCACHE))
bs->enable_write_cache = 1;
bs->read_only = (flags & BDRV_O_RDWR) == 0;
if (!(flags & BDRV_O_FILE)) {
open_flags = (flags & (BDRV_O_RDWR | BDRV_O_CACHE_MASK|BDRV_O_NATIVE_AIO));
if (bs->is_temporary) {
open_flags |= BDRV_O_RDWR;
}
} else {
open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT);
}
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv)) {
ret = -ENOTSUP;
} else {
ret = drv->bdrv_open(bs, filename, open_flags);
}
if (ret < 0) {
qemu_free(bs->opaque);
bs->opaque = NULL;
bs->drv = NULL;
unlink_and_fail:
if (bs->is_temporary)
unlink(filename);
return ret;
}
if (drv->bdrv_getlength) {
bs->total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;
}
#ifndef _WIN32
if (bs->is_temporary) {
unlink(filename);
}
#endif
if ((flags & BDRV_O_NO_BACKING) == 0 && bs->backing_file[0] != '\0') {
BlockDriver *back_drv = NULL;
bs->backing_hd = bdrv_new("");
path_combine(backing_filename, sizeof(backing_filename),
filename, bs->backing_file);
if (bs->backing_format[0] != '\0')
back_drv = bdrv_find_format(bs->backing_format);
ret = bdrv_open2(bs->backing_hd, backing_filename, open_flags,
back_drv);
bs->backing_hd->read_only = (open_flags & BDRV_O_RDWR) == 0;
if (ret < 0) {
bdrv_close(bs);
return ret;
}
}
if (!bdrv_key_required(bs)) {
bs->media_changed = 1;
if (bs->change_cb)
bs->change_cb(bs->change_opaque);
}
return 0;
}
| 1threat |
alert('Hello ' + user_input); | 1threat |
static av_cold int nvenc_check_cuda(AVCodecContext *avctx)
{
int device_count = 0;
CUdevice cu_device = 0;
char gpu_name[128];
int smminor = 0, smmajor = 0;
int i, smver, target_smver;
NvencContext *ctx = avctx->priv_data;
NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs;
switch (avctx->codec->id) {
case AV_CODEC_ID_H264:
target_smver = ctx->data_pix_fmt == AV_PIX_FMT_YUV444P ? 0x52 : 0x30;
break;
case AV_CODEC_ID_H265:
target_smver = 0x52;
break;
default:
av_log(avctx, AV_LOG_FATAL, "Unknown codec name\n");
goto error;
}
if (ctx->preset >= PRESET_LOSSLESS_DEFAULT)
target_smver = 0x52;
if (!nvenc_dyload_cuda(avctx))
return 0;
if (dl_fn->nvenc_device_count > 0)
return 1;
check_cuda_errors(dl_fn->cu_init(0));
check_cuda_errors(dl_fn->cu_device_get_count(&device_count));
if (!device_count) {
av_log(avctx, AV_LOG_FATAL, "No CUDA capable devices found\n");
goto error;
}
av_log(avctx, AV_LOG_VERBOSE, "%d CUDA capable devices found\n", device_count);
dl_fn->nvenc_device_count = 0;
for (i = 0; i < device_count; ++i) {
check_cuda_errors(dl_fn->cu_device_get(&cu_device, i));
check_cuda_errors(dl_fn->cu_device_get_name(gpu_name, sizeof(gpu_name), cu_device));
check_cuda_errors(dl_fn->cu_device_compute_capability(&smmajor, &smminor, cu_device));
smver = (smmajor << 4) | smminor;
av_log(avctx, AV_LOG_VERBOSE, "[ GPU #%d - < %s > has Compute SM %d.%d, NVENC %s ]\n", i, gpu_name, smmajor, smminor, (smver >= target_smver) ? "Available" : "Not Available");
if (smver >= target_smver)
dl_fn->nvenc_devices[dl_fn->nvenc_device_count++] = cu_device;
}
if (!dl_fn->nvenc_device_count) {
av_log(avctx, AV_LOG_FATAL, "No NVENC capable devices found\n");
goto error;
}
return 1;
error:
dl_fn->nvenc_device_count = 0;
return 0;
}
| 1threat |
static int ffm_write_packet(AVFormatContext *s, AVPacket *pkt)
{
FFMContext *ffm = s->priv_data;
AVStream *st = s->streams[pkt->stream_index];
int64_t pts;
uint8_t header[FRAME_HEADER_SIZE];
pts = ffm->start_time + pkt->pts;
header[0] = pkt->stream_index;
header[1] = 0;
if (pkt->flags & PKT_FLAG_KEY)
header[1] |= FLAG_KEY_FRAME;
AV_WB24(header+2, pkt->size);
AV_WB24(header+5, pkt->duration);
ffm_write_data(s, header, FRAME_HEADER_SIZE, pts, 1);
ffm_write_data(s, pkt->data, pkt->size, pts, 0);
return 0;
}
| 1threat |
How do I import the pytest monkeypatch plugin? : <p>I want to use the <a href="https://pytest.org/latest/monkeypatch.html" rel="noreferrer">pytest monkeypatch</a> plugin, but I can't figure out how to import it. I've tried:</p>
<ul>
<li><code>import monkeypath</code></li>
<li><code>import pytest.monkeypatch</code></li>
<li><code>from pytest import monkeypatch</code></li>
</ul>
| 0debug |
PHP Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in line 24 : <p>I have just moved from windows 5.2.0 to Linux 5.5.34 and have countered this error message within my code. It states that the error is on "line 24"</p>
<p>Here is a screenshot to my code...</p>
<p><a href="https://ibb.co/gQzWLk" rel="nofollow noreferrer">https://ibb.co/gQzWLk</a></p>
| 0debug |
Copying the location of file names : I have a root folder called "Project" below that I have hundreds of sub folders and I want to export the location of those folder which ever consists a excel file to a separate text file.how can i achieve that in python..?
**Example**
D:\Project\Folder1
D:\Project\Folder2\Folder3 | 0debug |
static void reset_codec(WmallDecodeCtx *s)
{
int ich, ilms;
s->mclms_recent = s->mclms_order * s->num_channels;
for (ich = 0; ich < s->num_channels; ich++) {
for (ilms = 0; ilms < s->cdlms_ttl[ich]; ilms++)
s->cdlms[ich][ilms].recent = s->cdlms[ich][ilms].order;
s->channel[ich].transient_counter = s->samples_per_frame;
s->transient[ich] = 1;
}
}
| 1threat |
loop never ends in sql server using While Exists : [Question is in the image][1]
[1]: http://i.stack.imgur.com/0Gdd7.jpg
I was unable to post the code so had to put it in the form of image. Thanks | 0debug |
Timestamp from Mysql Database into readable : <p>Hi to everyone please Help me with this problem I am new to android programming.
I am developing an android application that the person can post something and as it is needed the post should have a time that shows when it is posted and I have set a column for the time inside mysql database with TIMESTAMP data type and when the post is inserted in the database it also inserts the full time and date that when it is posted but when I get the data from the server it shows the date and time fully like this : 17/5/2016 20:54:34
But I want to show it like readable format like this for Example : 4 hours ago or 3 days ago or 3 months ago
Please don't mark my Question as duplicate because I searched and I didn't find anything</p>
| 0debug |
static int vpc_open(BlockDriverState *bs, int flags)
{
BDRVVPCState *s = bs->opaque;
int i;
struct vhd_footer* footer;
struct vhd_dyndisk_header* dyndisk_header;
uint8_t buf[HEADER_SIZE];
uint32_t checksum;
int err = -1;
int disk_type = VHD_DYNAMIC;
if (bdrv_pread(bs->file, 0, s->footer_buf, HEADER_SIZE) != HEADER_SIZE)
goto fail;
footer = (struct vhd_footer*) s->footer_buf;
if (strncmp(footer->creator, "conectix", 8)) {
int64_t offset = bdrv_getlength(bs->file);
if (offset < HEADER_SIZE) {
goto fail;
}
if (bdrv_pread(bs->file, offset-HEADER_SIZE, s->footer_buf, HEADER_SIZE)
!= HEADER_SIZE) {
goto fail;
}
if (strncmp(footer->creator, "conectix", 8)) {
goto fail;
}
disk_type = VHD_FIXED;
}
checksum = be32_to_cpu(footer->checksum);
footer->checksum = 0;
if (vpc_checksum(s->footer_buf, HEADER_SIZE) != checksum)
fprintf(stderr, "block-vpc: The header checksum of '%s' is "
"incorrect.\n", bs->filename);
footer->checksum = be32_to_cpu(checksum);
bs->total_sectors = (int64_t)
be16_to_cpu(footer->cyls) * footer->heads * footer->secs_per_cyl;
if (bs->total_sectors >= 65535LL * 255 * 255) {
err = -EFBIG;
goto fail;
}
if (disk_type == VHD_DYNAMIC) {
if (bdrv_pread(bs->file, be64_to_cpu(footer->data_offset), buf,
HEADER_SIZE) != HEADER_SIZE) {
goto fail;
}
dyndisk_header = (struct vhd_dyndisk_header *) buf;
if (strncmp(dyndisk_header->magic, "cxsparse", 8)) {
goto fail;
}
s->block_size = be32_to_cpu(dyndisk_header->block_size);
s->bitmap_size = ((s->block_size / (8 * 512)) + 511) & ~511;
s->max_table_entries = be32_to_cpu(dyndisk_header->max_table_entries);
s->pagetable = g_malloc(s->max_table_entries * 4);
s->bat_offset = be64_to_cpu(dyndisk_header->table_offset);
if (bdrv_pread(bs->file, s->bat_offset, s->pagetable,
s->max_table_entries * 4) != s->max_table_entries * 4) {
goto fail;
}
s->free_data_block_offset =
(s->bat_offset + (s->max_table_entries * 4) + 511) & ~511;
for (i = 0; i < s->max_table_entries; i++) {
be32_to_cpus(&s->pagetable[i]);
if (s->pagetable[i] != 0xFFFFFFFF) {
int64_t next = (512 * (int64_t) s->pagetable[i]) +
s->bitmap_size + s->block_size;
if (next > s->free_data_block_offset) {
s->free_data_block_offset = next;
}
}
}
s->last_bitmap_offset = (int64_t) -1;
#ifdef CACHE
s->pageentry_u8 = g_malloc(512);
s->pageentry_u32 = s->pageentry_u8;
s->pageentry_u16 = s->pageentry_u8;
s->last_pagetable = -1;
#endif
}
qemu_co_mutex_init(&s->lock);
error_set(&s->migration_blocker,
QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
"vpc", bs->device_name, "live migration");
migrate_add_blocker(s->migration_blocker);
return 0;
fail:
return err;
}
| 1threat |
R dataframe: How to slpit by 2 colums and calculate the mean : I have a dataframe with several columns like that: (I ha ve lots of columns from which I want to calculate the mean, so I cannot adress them by name)
df:
A B C D E F....
1 1 10 ... ... ...
1 1 30 ... ... ...
1 2 100 ... ... ...
1 2 300 ... ... ...
2 1 4 ... ... ...
2 1 6 ... ... ...
2 1 8 ... ... ...
Now I want to split this dataFrame into Groups of A and B and calculate the mean like that:
A=1:
B=1: mean = 20
B=2: mean = 200
A=2:
B=1: mean = 6
How would I do that ?
Thank you! | 0debug |
Can't Parse Regex : For some reason I can't parse this regex, which works in a live demonstration.
I took the code from the live demo, pasted it into a new PHP file, saved it and ran it in my server.
Works here: [live demo](https://3v4l.org/fKIqa)
My code + the error: [here](http://image.prntscr.com/image/d498412b29e8480db33bf30f68888dfb.png)
My `phpinfo`: [here](http://www.filedropper.com/temporaryphpinfo)
| 0debug |
My Java Code Throws java.lang.NullPointerException : <p>I'm writing a Java code that would run a simple automation scenario in Chrome or Firefox - depending on the user's input. It starts running (opens a browser), but then throws java.lang.NullPointerException. I thought then the null I assigned the driver variable would later be overridden, but it isn't. How can this be fixed? Thanks!</p>
<pre><code>package com.selenium;
import java.util.Scanner;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Main {
public static void main(String[] args) throws InterruptedException {
// environment variable
System.setProperty("webdriver.chrome.driver", "C:\\Automation\\libs\\Drivers\\chromedriver.exe");
//WebDriver chromeDriver = new ChromeDriver();
System.setProperty("webdriver.gecko.driver", "C:\\Automation\\libs\\Drivers\\geckodriver.exe");
WebDriver driver = null;
Scanner scanner = new Scanner(System.in);
int option = scanner.nextInt();
System.out.println("Please enter 1 for Chrome or 2 for Firefox " + option);
if (option == 1)
{
WebDriver driver1= new FirefoxDriver();
}
else if
(option == 2)
{
WebDriver driver2 = new ChromeDriver();
}
else
System.out.println("Please enter a correct number " + option);
String baseURL = "https://login.salesforce.com/?locale=eu";
driver.get(baseURL);
WebElement userName = driver.findElement(By.id("username"));
userName.sendKeys("Yan");
WebElement password = driver.findElement(By.id("password"));
password.sendKeys("123456");
WebElement rememberCheckbox = driver.findElement(By.id("rememberUn"));
rememberCheckbox.click();
WebElement bLogin = driver.findElement(By.id("Login"));
bLogin.click();
}
}
</code></pre>
| 0debug |
static int pci_pcnet_init(PCIDevice *pci_dev)
{
PCIPCNetState *d = PCI_PCNET(pci_dev);
PCNetState *s = &d->state;
uint8_t *pci_conf;
#if 0
printf("sizeof(RMD)=%d, sizeof(TMD)=%d\n",
sizeof(struct pcnet_RMD), sizeof(struct pcnet_TMD));
#endif
pci_conf = pci_dev->config;
pci_set_word(pci_conf + PCI_STATUS,
PCI_STATUS_FAST_BACK | PCI_STATUS_DEVSEL_MEDIUM);
pci_set_word(pci_conf + PCI_SUBSYSTEM_VENDOR_ID, 0x0);
pci_set_word(pci_conf + PCI_SUBSYSTEM_ID, 0x0);
pci_conf[PCI_INTERRUPT_PIN] = 1;
pci_conf[PCI_MIN_GNT] = 0x06;
pci_conf[PCI_MAX_LAT] = 0xff;
memory_region_init_io(&d->state.mmio, OBJECT(d), &pcnet_mmio_ops, s,
"pcnet-mmio", PCNET_PNPMMIO_SIZE);
memory_region_init_io(&d->io_bar, OBJECT(d), &pcnet_io_ops, s, "pcnet-io",
PCNET_IOPORT_SIZE);
pci_register_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &d->io_bar);
pci_register_bar(pci_dev, 1, 0, &s->mmio);
s->irq = pci_allocate_irq(pci_dev);
s->phys_mem_read = pci_physical_memory_read;
s->phys_mem_write = pci_physical_memory_write;
s->dma_opaque = pci_dev;
return pcnet_common_init(DEVICE(pci_dev), s, &net_pci_pcnet_info);
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.