problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
static void test_visitor_out_alternate(TestOutputVisitorData *data,
const void *unused)
{
QObject *arg;
UserDefAlternate *tmp;
QDict *qdict;
tmp = g_new0(UserDefAlternate, 1);
tmp->type = QTYPE_QINT;
tmp->u.i = 42;
visit_type_UserDefAlternate(data->ov, NULL, &tmp, &error_abort);
arg = qmp_output_get_qobject(data->qov);
g_assert(qobject_type(arg) == QTYPE_QINT);
g_assert_cmpint(qint_get_int(qobject_to_qint(arg)), ==, 42);
qapi_free_UserDefAlternate(tmp);
qobject_decref(arg);
tmp = g_new0(UserDefAlternate, 1);
tmp->type = QTYPE_QSTRING;
tmp->u.s = g_strdup("hello");
visit_type_UserDefAlternate(data->ov, NULL, &tmp, &error_abort);
arg = qmp_output_get_qobject(data->qov);
g_assert(qobject_type(arg) == QTYPE_QSTRING);
g_assert_cmpstr(qstring_get_str(qobject_to_qstring(arg)), ==, "hello");
qapi_free_UserDefAlternate(tmp);
qobject_decref(arg);
tmp = g_new0(UserDefAlternate, 1);
tmp->type = QTYPE_QDICT;
tmp->u.udfu.integer = 1;
tmp->u.udfu.string = g_strdup("str");
tmp->u.udfu.enum1 = ENUM_ONE_VALUE1;
tmp->u.udfu.u.value1 = g_new0(UserDefA, 1);
tmp->u.udfu.u.value1->boolean = true;
visit_type_UserDefAlternate(data->ov, NULL, &tmp, &error_abort);
arg = qmp_output_get_qobject(data->qov);
g_assert_cmpint(qobject_type(arg), ==, QTYPE_QDICT);
qdict = qobject_to_qdict(arg);
g_assert_cmpint(qdict_size(qdict), ==, 4);
g_assert_cmpint(qdict_get_int(qdict, "integer"), ==, 1);
g_assert_cmpstr(qdict_get_str(qdict, "string"), ==, "str");
g_assert_cmpstr(qdict_get_str(qdict, "enum1"), ==, "value1");
g_assert_cmpint(qdict_get_bool(qdict, "boolean"), ==, true);
qapi_free_UserDefAlternate(tmp);
qobject_decref(arg);
}
| 1threat |
static uint32_t m5206_mbar_readb(void *opaque, target_phys_addr_t offset)
{
m5206_mbar_state *s = (m5206_mbar_state *)opaque;
offset &= 0x3ff;
if (offset > 0x200) {
hw_error("Bad MBAR read offset 0x%x", (int)offset);
}
if (m5206_mbar_width[offset >> 2] > 1) {
uint16_t val;
val = m5206_mbar_readw(opaque, offset & ~1);
if ((offset & 1) == 0) {
val >>= 8;
}
return val & 0xff;
}
return m5206_mbar_read(s, offset, 1);
}
| 1threat |
static void test_qemu_strtoll_full_max(void)
{
const char *str = g_strdup_printf("%lld", LLONG_MAX);
int64_t res;
int err;
err = qemu_strtoll(str, NULL, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, LLONG_MAX);
}
| 1threat |
std::vector<std::vector<T>>::end() does not have members? : [Screenshot of the problem][1]
Have no idea why it's so.
[Screenshot of headers][2]
[1]: https://i.stack.imgur.com/p8rrV.png
[2]: https://i.stack.imgur.com/b4W5O.png | 0debug |
Implicit return from lambda in Kotlin : <p>It seems that the last line of a lambda always returns that value even if you omit the <code>return</code> statement. Is this correct? Is it documented anywhere?</p>
<pre><code>fun main(args: Array<String>) {
val nums = arrayOf(1, 2, 3)
val numsPlusOne = nums.map { it ->
val r = it + 1
r
}
// numsPlusOne = [2, 3, 4]
}
</code></pre>
| 0debug |
static int mov_text_decode_frame(AVCodecContext *avctx,
void *data, int *got_sub_ptr, AVPacket *avpkt)
{
AVSubtitle *sub = data;
MovTextContext *m = avctx->priv_data;
int ret;
AVBPrint buf;
char *ptr = avpkt->data;
char *end;
int text_length, tsmb_type, ret_tsmb;
uint64_t tsmb_size;
const uint8_t *tsmb;
if (!ptr || avpkt->size < 2)
return AVERROR_INVALIDDATA;
if (avpkt->size == 2)
return AV_RB16(ptr) == 0 ? 0 : AVERROR_INVALIDDATA;
text_length = AV_RB16(ptr);
end = ptr + FFMIN(2 + text_length, avpkt->size);
ptr += 2;
tsmb_size = 0;
m->tracksize = 2 + text_length;
m->style_entries = 0;
m->box_flags = 0;
m->count_s = 0;
av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
if (text_length + 2 != avpkt->size) {
while (m->tracksize + 8 <= avpkt->size) {
tsmb = ptr + m->tracksize - 2;
tsmb_size = AV_RB32(tsmb);
tsmb += 4;
tsmb_type = AV_RB32(tsmb);
tsmb += 4;
if (tsmb_size == 1) {
if (m->tracksize + 16 > avpkt->size)
break;
tsmb_size = AV_RB64(tsmb);
tsmb += 8;
m->size_var = 16;
} else
m->size_var = 8;
if (tsmb_size == 0) {
av_log(avctx, AV_LOG_ERROR, "tsmb_size is 0\n");
return AVERROR_INVALIDDATA;
}
if (tsmb_size > avpkt->size - m->tracksize)
break;
for (size_t i = 0; i < box_count; i++) {
if (tsmb_type == box_types[i].type) {
if (m->tracksize + m->size_var + box_types[i].base_size > avpkt->size)
break;
ret_tsmb = box_types[i].decode(tsmb, m, avpkt);
if (ret_tsmb == -1)
break;
}
}
m->tracksize = m->tracksize + tsmb_size;
}
text_to_ass(&buf, ptr, end, m);
} else
text_to_ass(&buf, ptr, end, m);
ret = ff_ass_add_rect(sub, buf.str, m->readorder++, 0, NULL, NULL);
av_bprint_finalize(&buf, NULL);
if (ret < 0)
return ret;
*got_sub_ptr = sub->num_rects > 0;
return avpkt->size;
} | 1threat |
If I use variables as indexes to access a char * [] [], the content of the elements is (null) : <p>I'm writing a program to play battleship.
I have a string matrix representing the battlefield.</p>
<pre><code>#define NUM_CASELLE 6
char* campo[NUM_CASELLE][NUM_CASELLE];
</code></pre>
<p>At the beginning of the program each element of the matrix is initialized with "-".</p>
<p>I noticed that I have problems accessing the matrix elements so I did some debugging to better understand what the problem was and I noticed this: if I write</p>
<pre><code>printf("The content is %s\n", campo[3][1]);
</code></pre>
<p>the result is</p>
<blockquote>
<p>The content is - </p>
</blockquote>
<p>and that's right.</p>
<p>But if I enter coordinates from stdin and memorize them in variables, </p>
<pre><code>printf("row is %c\n", row);
printf("col is %d\n", col);
printf("The content is %s\n", campo[row][col]);
</code></pre>
<p>the result is as follows:</p>
<blockquote>
<p>The content is (null)</p>
</blockquote>
<p>Where am I wrong?</p>
<p>Anyway, I post the whole code because maybe the error is elsewhere.
In fact, the coordinates are entered as they are in battleship, for example, a3 or b5 or f1 etc .. and then I convert the letter to the respective row index.</p>
<pre><code>#define NUM_CASELLE 6
#define NUM_NAVI 7
int pos_size = 256;
char* campo[NUM_CASELLE][NUM_CASELLE];
void posizionaNavi(){
char pos[pos_size];
int i = 0;
int col;
int row;
printf("Scegli dove posizionare le navi...\n");
while(i < NUM_NAVI){
printf("Posizionare nave numero %d...\n", i + 1);
fgets(pos, pos_size, stdin);
col = isCommandValid(pos);
row = pos[1];
if(col == -1){
printf("\n");
printf(">> ATTENZIONE: formato errato.\n");
printf(">> Le colonne vanno dalla lettera A alla lettera F\n");
printf(">> Le righe vanno dal numero 1 al numero 6\n");
printf(">> Esempi di comando valido: a3 - b6 - f1\n");
printf("\n");
}
else{
printf("row is %c\n", row);
printf("col is %d\n", col);
printf("The content is %s\n", campo[row][col]);
printf("The content is %s\n", campo[3][1]);
if(campo[row][col] = " - "){
campo[row][col] = " x ";
printf("Nave %d posizionata in %s\n", i + 1, pos);
i++;
}
else{
printf(">> ATTENZIONE: casella già occupata da una nave.");
printf(">> Riprovare...\n");
printf("\n");
}
}
}
}
int isCommandValid(char* pos){
int ret;
if(strlen(pos) != 3 || pos[1] > '6' || pos[1] < '1')
return -1;
switch(pos[0]){
case 'a':
ret = 1;
break;
case 'A':
ret = 1;
break;
case 'b':
ret = 2;
break;
case 'B':
ret = 2;
break;
case 'c':
ret = 3;
break;
case 'C':
ret = 3;
break;
case 'd':
ret = 4;
break;
case 'D':
ret = 4;
break;
case 'e':
ret = 5;
break;
case 'E':
ret = 5;
break;
case 'f':
ret = 6;
break;
case 'F':
ret = 6;
break;
default:
ret = -1;
break;
}
return ret;
}
</code></pre>
| 0debug |
static target_ulong h_get_term_char(CPUState *env, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
target_ulong reg = args[0];
target_ulong *len = args + 0;
target_ulong *char0_7 = args + 1;
target_ulong *char8_15 = args + 2;
VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
uint8_t buf[16];
if (!sdev) {
return H_PARAMETER;
}
*len = vty_getchars(sdev, buf, sizeof(buf));
if (*len < 16) {
memset(buf + *len, 0, 16 - *len);
}
*char0_7 = be64_to_cpu(*((uint64_t *)buf));
*char8_15 = be64_to_cpu(*((uint64_t *)buf + 1));
return H_SUCCESS;
}
| 1threat |
Install Certbot letsencrypt without interaction : <p>I am writing a bash script which bootstraps the whole project infrastructure in the freshly installed server and i want to configure ssl installation with letcecrypt certbot. After I execute line:</p>
<pre><code>certbot --nginx -d $( get_server_name ) -d www.$( get_server_name ).com
</code></pre>
<p>I get prompted for few questions. Can certbot be run without any interactions while passing some of the params as arguments or something ?</p>
| 0debug |
static void uninit(struct vf_instance *vf)
{
free(vf->priv);
}
| 1threat |
I need to add a number from right to left in the decimal value using javascript : <p>I am trying to display decimal value in calculator using javascript.
if i click any buttons in the calculator, the button value added to decimal value from the right to left and it should be display in the screen.<br>
For Eg: <strong><code>The default value is 0.00 if i click 2, it should be 0.02 and if i click 3, it should be 0.23 and if i click 4, it should be 2.34 and if i click 5, it should be 23.45 and so on.</code></strong> </p>
| 0debug |
static inline void scoop_gpio_handler_update(ScoopInfo *s) {
uint32_t level, diff;
int bit;
level = s->gpio_level & s->gpio_dir;
for (diff = s->prev_level ^ level; diff; diff ^= 1 << bit) {
bit = ffs(diff) - 1;
qemu_set_irq(s->handler[bit], (level >> bit) & 1);
}
s->prev_level = level;
}
| 1threat |
JS Won't Redirect : <p>I have this code that I have made and have been trying to fix it for days. I am trying to make it redirect to whatever the $link variable is set to. All it does is just give me a blank page. Any answers?</p>
<pre><code><?php
$l = $_GET['l'];
$db = new mysqli('localhost', 'root', 'password', 'link');
$sql = "SELECT * FROM links WHERE new_url='$l'";
$result = $db->query($sql);
if($result->num_rows > 0) {
$row = $result->fetch_assoc();
$link = $row['website'];
$string = $row['new_url'];
echo '<script type="text/javascript">',
'window.location = $link;',
'</script>';
} else {
@include('./error.php');
}
?>
</code></pre>
| 0debug |
Is it possible to determine programmatically whether a file move will result in a copy? : <p>My Java program needs to synchronously move a file on a server, ie. within the same set of local file systems. The obvious solution is to use <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#move-java.nio.file.Path-java.nio.file.Path-java.nio.file.CopyOption...-" rel="noreferrer">Files.move()</a>. However, I've read that in some cases, eg. across file systems, a move will fall-back to copy-and-delete. As I'm moving large files I'd like to be able to report progress to the user if a copy take places (as there will be a noticeable delay).</p>
<p>However, I cannot find a simple way to do this with the Java API. I could potentially write my own copy routine that reports progress, but then I would need to know if the move is going to result in a copy.</p>
<p>One possibility seems to be something like:</p>
<pre><code>try {
Files.move(src, dest, CopyOption.ATOMIC_MOVE);
} catch (AtomicMoveNotSupportedException e) {
// Perform a copy instead (and report progress)
}
</code></pre>
<p>However it's not clear to me from the Java doco if this would be correct in all cases. Is this indeed a correct solution? If not, is there another way?</p>
| 0debug |
static void event_notifier_ready(EventNotifier *notifier)
{
ThreadPool *pool = container_of(notifier, ThreadPool, notifier);
ThreadPoolElement *elem, *next;
event_notifier_test_and_clear(notifier);
restart:
QLIST_FOREACH_SAFE(elem, &pool->head, all, next) {
if (elem->state != THREAD_CANCELED && elem->state != THREAD_DONE) {
continue;
}
if (elem->state == THREAD_DONE) {
trace_thread_pool_complete(pool, elem, elem->common.opaque,
elem->ret);
}
if (elem->state == THREAD_DONE && elem->common.cb) {
QLIST_REMOVE(elem, all);
smp_rmb();
elem->common.cb(elem->common.opaque, elem->ret);
qemu_aio_release(elem);
goto restart;
} else {
QLIST_REMOVE(elem, all);
qemu_aio_release(elem);
}
}
}
| 1threat |
How to place the div in the zig zag order based on the window width? : As im trying the align the div in zig zag order in the for loop.
So on the fifth div i need to wrap the div and start from right to left so on..
Please refer to the image.
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/7qHSe.png
So please suggest how to achieve this based on the width on the window.
| 0debug |
How to get row value to map with columns in sql : Table: fieldTable (only one column "ColumnFileName")
ColumnFileName: (Values are as below).
f1
f2
f3
f4,
f5
Table: ValueTable (9 columns as below).
Columns: Id, f1, f2, f3, f4,f5,f6,f7,comments
Values: 1, Name,Id,Salary,Interest,Offer,value,Salary,''
How to get result as below: (to map Table 1 row's value to column value of Table2).
f1,Name,
f2,Id
f3,Salary
f4,Interest
f5,Offer,
f6,value,
f7,Salary,
| 0debug |
how to generate one hundred million like int data type fastly? : I want to generate one hundred million digital data like int using php,but my code is too slow to run.
<?php
$arr=array();
while(count($arr)<100000000)
{
$arr[]=rand(1,100000000);
$arr=array_unique($arr);
}
echo implode(" ",$arr);
?>
have any way to improve it? | 0debug |
static uint64_t pchip_read(void *opaque, target_phys_addr_t addr, unsigned size)
{
TyphoonState *s = opaque;
uint64_t ret = 0;
if (addr & 4) {
return s->latch_tmp;
}
switch (addr) {
case 0x0000:
ret = s->pchip.win[0].base_addr;
break;
case 0x0040:
ret = s->pchip.win[1].base_addr;
break;
case 0x0080:
ret = s->pchip.win[2].base_addr;
break;
case 0x00c0:
ret = s->pchip.win[3].base_addr;
break;
case 0x0100:
ret = s->pchip.win[0].mask;
break;
case 0x0140:
ret = s->pchip.win[1].mask;
break;
case 0x0180:
ret = s->pchip.win[2].mask;
break;
case 0x01c0:
ret = s->pchip.win[3].mask;
break;
case 0x0200:
ret = (uint64_t)s->pchip.win[0].translated_base_pfn << 10;
break;
case 0x0240:
ret = (uint64_t)s->pchip.win[1].translated_base_pfn << 10;
break;
case 0x0280:
ret = (uint64_t)s->pchip.win[2].translated_base_pfn << 10;
break;
case 0x02c0:
ret = (uint64_t)s->pchip.win[3].translated_base_pfn << 10;
break;
case 0x0300:
ret = s->pchip.ctl;
break;
case 0x0340:
break;
case 0x03c0:
break;
case 0x0400:
break;
case 0x0440:
break;
case 0x0480:
break;
case 0x04c0:
break;
case 0x0500:
case 0x0540:
case 0x0800:
break;
default:
cpu_unassigned_access(cpu_single_env, addr, 0, 0, 0, size);
return -1;
}
s->latch_tmp = ret >> 32;
return ret;
}
| 1threat |
Can you ping a LAN IP from Chrome or any other browser? : A program I'm developing connects directly over the LAN between 2 computers. Sometimes, a user will have 2 computers on different networks, so the computers won't be able to ping each other. I want to give the user the possibility of testing this LAN-to-LAN connectivity before downloading and installing the main program.
Is it possible to ping (or connect to) one computer from another over LAN using Chrome or any other browser? This would also involve detecting the local IP address.
My hunch is that Chrome (and other browsers) won't provide this sort of access to the OS (i.e. with JavaScript or an extension), but maybe there's an alternative (dare I say, a Java Applet, if that's still a thing). A bonus would be if this could work on Windows, macOS, and Linux.
Any ideas? | 0debug |
I need some advide about user type with hashmap : <p>I wrote user type as below</p>
<pre><code>class Item {
int first;
int second;
public boolean equals(Item p) {
if(first == p.first && second == p.second )
return true;
else if(first == p.second && second == p.first)
return true;
else
return false;
}
public int hashcode() {
return Objects.hash(first, second);
}
public void set(Object first, Object second) {
this.first = Integer.parseInt(first.toString());
this.second = Integer.parseInt(second.toString());
}
</code></pre>
<p>}</p>
<p>However, It doesn't work at all. Did I design the duplicate test incorrectly?</p>
| 0debug |
Frequency of a number in array less than bigo n time : Find the frequency of a number in array in less than bigo n time
Array 1,2,2,3,4,5,5,5,2
Input 5
Output 3
Array 1,1,1,1,
Input 1
Output 4
Keep in mind less than bigo n
Thanks | 0debug |
Having some problems, not sure if it's even possible : <p>I'm currently new(ish) at HTML. What I'm trying to do is Make a centered "Hello!" That has the font of Georgia and the font color of purple. This is what I have right now: </p>
<pre><code><div style="<font face="Georgia" color="purple"">
<center><h1>Hello!</h1></center>
</div>
</code></pre>
<p>I'm not even sure if I'm doing it correctly, but right now it's hard to find an anwser without having to use CSS, and I have no idea how CSS works.</p>
| 0debug |
static void nvdimm_build_fit_buffer(NvdimmFitBuffer *fit_buf)
{
qemu_mutex_lock(&fit_buf->lock);
g_array_free(fit_buf->fit, true);
fit_buf->fit = nvdimm_build_device_structure();
fit_buf->dirty = true;
qemu_mutex_unlock(&fit_buf->lock);
}
| 1threat |
Python rolling log to a variable : <p>I have an application that makes use of multi-threading and is run in the background on a server. In order to monitor the application without having to log on to the server, I decided to include <a href="http://bottlepy.org" rel="noreferrer">Bottle</a> in order to respond to a few HTTP endpoints and report status, perform remote shutdown, etc.</p>
<p>I also wanted to add a way to consult the logfile. I could log using the <code>FileHandler</code> and send the destination file when the URL is requested (e.g. <code>/log</code>).</p>
<p>However, I was wondering if it'd be possible to implement something like a <code>RotatingFileHandler</code>, but instead of logging to a file, logging to a variable (e.g. <code>BytesIO</code>). This way, I could limit the log to the most recent information, while at the same time being able to return it to the browser as text instead of as a separate file download.</p>
<p>The <code>RotatingFileHandler</code> requires a filename, so it's not an option to pass it a <code>BytesIO</code> stream. Logging to a variable itself is perfectly doable (e.g. <a href="http://alanwsmith.com/capturing-python-log-output-in-a-variable" rel="noreferrer">Capturing Python Log Output In A Variable</a>), but I'm a bit stumped on how to do the <em>rolling</em> part.</p>
<p>Any thoughts, hints, suggestions would be greatly appreciated.</p>
| 0debug |
python core programming concepts for beginers : alphabet = 'abcdefghijklmnopqrstuvwxyz'
orig_list = [ "bat", "act", "cat", "rat", "abs" ]
for i in alphabet:
for j in orig_list:
for l in j:
print(l)
I very new to programming and am currently struggling with this concept. So in this example, I am using a for loop and having j iterate through the org_list and then in the next line I am having l iterate through j so I get the alphabets but my output on the shell prints out all the alphabets in j but it repeats itself. I am providing the output below. Kindly let me know what I am doing wrong. Cheers!
b
a
t
a
c
t
c
a
t
r
a
t
a
b
s
b
a
t
a
c
t
c
a
t
r
a
t
a
b
s
..... and continues for many more lines | 0debug |
Need help for a game, php form and mysql : <p>I have many problems with a form that I have to create...</p>
<pre><code><form method="post" action="target.php" id="myForm">
<span class="form_col">Name</span>
<input />
<br /><br />
<span class="form_col">Gender :</span>
<label><input name="sex" type="radio" value="H" />Male</label>
<label><input name="sex" type="radio" value="F" />Female</label>
<br /><br />
<label class="form_col">Race :</label>
<label><input type="radio" value="Human" />Human</label>
<label><input type="radio" value="Elf" />Elf</label>
<label><input type="radio" value="Orc" />Orc</label>
<br /><br />
<label class="form_col">Primary color :</label>
<select name="prcolor" id="prcolor">
<option value="none">Select the primary color</option>
<option value="blue">Blue</option>
<option value="red">Red</option>
<option value="yellow">Yellow</option>
<option value="black">Black</option>
</select>
<br /><br />
<label class="form_col" for="firstName">Body color :</label>
<select name="bcolor" id="bcolor">
<option value="base">Base</option>
<option value="redb">Red</option>
<option value="brownb">Brown</option>
<option value="blackb">Black</option>
</select>
<br /><br />
<label class="form_col">Hair color :</label>
<select name="hair" id="hair">
<option value="none">Select the color</option>
<option value="blackh">Black</option>
<option value="greyh">Grey</option>
<option value="brownh">Brown</option>
</select>
<br /><br />
<span class="form_col">Weapon :</span>
<label><input type="radio" value="sword" />Sword</label>
<label><input type="radio" value="shield" />Shield</label>
<label><input type="radio" value="knife" />Knife</label>
<label><input type="radio" value="wand" />Wand</label>
<br /><br />
<span class="form_col">Clothes :</span>
<label><input type="checkbox" value="armor" />Armor</label>
<label><input type="checkbox" value="coat" />coat</label>
<label><input type="checkbox" value="dress" />Dress</label>
<br /><br />
<span class="form_col">Accessory :</span>
<label><input type="checkbox" value="hat" />Hat</label>
<label><input type="checkbox" value="helmet" />Helmet</label>
<label><input type="checkbox" value="glasses" />Glasses</label>
<br /><br />
<span class="form_col">Pet :</span>
<label><input name="sex" type="radio" value="mount" />Mount</label>
<label><input name="sex" type="radio" value="pet" />Pet</label>
<label><input name="sex" type="radio" value="none" />None</label>
<br /><br />
<span class="form_col"></span>
<input type="submit" value="Send" />
</form>
</code></pre>
<p>I need to send these informations to a database, but i don't know how to do...
And on mysql i don't know which type i need to use for each information...</p>
<p>Anyone can help me to make this form functional ?
Actually i really don't know how to do, I did some research but no results..</p>
<p>Thanks in advance</p>
| 0debug |
Writing to a txt file without clearing the previous content : <p>I want to know how do I write a line to a file without clearing or flushing it. What classes and packages do I need?
I've tried with FileOutputStream and PrintStream (using println) and with BufferedWriter and OutputStreamWriter (using write) but they erase the previous content from the file. </p>
<pre><code>try
{
File txt = new File("marcos.txt");
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
writer.write(registro);
writer.newLine();
writer.close();
}
catch(Exception e)
{
System.out.println("Error en la escritura al archivo.");
}
</code></pre>
| 0debug |
jquery ajax submit callback get this closet : <pre><code>$(document).on('click', '#file-submit', function () {
$.ajax({
url: url,
type: 'POST',
cache: false,
data: formData,
processData: false,
contentType: false
}).done(function (data, status, jqxhr) {
//here will be get a error
var nextId = $(this).parents('.tab-pane').next().attr("id");
alert(nextId);
}).fail(function (data, status, jqxhr) {
console.log("error");
});
})
</code></pre>
<p>threr is a button in page, when the page submited,
i will get the value in the form element,
but the i cant get,
please give some point ,thanks.</p>
| 0debug |
Minikube default CPU/Memory : <p>I wonder what is the actual default memory and cpu for minikube in vm-driver=none mode:</p>
<pre><code> minikube config view memory && minikube config view cpu
</code></pre>
<p>is not showing anything when starting minikube without specifying them</p>
| 0debug |
ionic cordova run android adb command failed with exit code 137 : <p>i am new to ionic and i start basic tabs project using ionic cli. Everything is working fine, except when i tried "ionic cordova run android" command with redmi note 4 giving following error.</p>
<blockquote>
<p>Error: Failed to execute shell command "input,keyevent,82"" on device: Error: adb: Command failed with exit code 137</p>
</blockquote>
<p>it is working fine on redmi note 3, follow is log from terminal, Any help would be appreciated</p>
<pre><code>[INFO] Running app-scripts build: --platform android --target cordova
[23:22:39] build dev started ...
[23:22:39] clean started ...
[23:22:39] clean finished in 6 ms
[23:22:39] copy started ...
[23:22:39] deeplinks started ...
[23:22:39] deeplinks finished in 64 ms
[23:22:39] transpile started ...
[23:22:45] transpile finished in 5.99 s
[23:22:45] preprocess started ...
[23:22:45] copy finished in 6.38 s
[23:22:46] preprocess finished in 229 ms
[23:22:46] webpack started ...
[23:23:08] webpack finished in 22.92 s
[23:23:08] sass started ...
[23:23:12] sass finished in 3.52 s
[23:23:12] postprocess started ...
[23:23:12] postprocess finished in 11 ms
[23:23:12] lint started ...
[23:23:12] build dev finished in 32.98 s
> cordova run android --device
ANDROID_HOME=/home/rogers/android-sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle
Subproject Path: CordovaLib
[23:23:18] lint finished in 5.77 s
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
at build_rbfqc9qtl315khhol1quvz1g.run(/home/rogers/workspace/practice/myApp/platforms/android/build.gradle:141)
The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
Incremental java compilation is an incubating feature.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead.
:preBuild UP-TO-DATE
:preDebugBuild
UP-TO-DATE
:checkDebugManifest
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:compileLint UP-TO-DATE
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugShaders UP-TO-DATE
:CordovaLib:compileDebugShaders
UP-TO-DATE
:CordovaLib:generateDebugAssets
UP-TO-DATE
:CordovaLib:mergeDebugAssets
UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles
UP-TO-DATE
:CordovaLib:packageDebugRenderscript
UP-TO-DATE
:CordovaLib:compileDebugRenderscript
UP-TO-DATE
:CordovaLib:generateDebugResValues
UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources
UP-TO-DATE
:CordovaLib:processDebugManifest
UP-TO-DATE
:CordovaLib:generateDebugBuildConfig
UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:incrementalDebugJavaCompilationSafeguard
UP-TO-DATE
:CordovaLib:compileDebugJavaWithJavac
UP-TO-DATE
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug
UP-TO-DATE
:CordovaLib:mergeDebugJniLibFolders
UP-TO-DATE
:CordovaLib:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:CordovaLib:transformNative_libsWithSyncJniLibsForDebug UP-TO-DATE
:CordovaLib:bundleDebug
UP-TO-DATE
:prepareOrgApacheCordovaCordovaLib630DebugLibrary
UP-TO-DATE
:prepareDebugDependencies
:compileDebugAidl
UP-TO-DATE
:compileDebugRenderscript
UP-TO-DATE
:generateDebugBuildConfig
UP-TO-DATE
:generateDebugResValues
UP-TO-DATE
:generateDebugResources UP-TO-DATE
:mergeDebugResources
UP-TO-DATE
:processDebugManifest
UP-TO-DATE
:processDebugResources
UP-TO-DATE
:generateDebugSources
UP-TO-DATE
:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:compileDebugJavaWithJavac
UP-TO-DATE
:compileDebugNdk
UP-TO-DATE
:compileDebugSources UP-TO-DATE
:mergeDebugShaders UP-TO-DATE
:compileDebugShaders UP-TO-DATE
:generateDebugAssets
UP-TO-DATE
:mergeDebugAssets
UP-TO-DATE
:transformClassesWithDexForDebug
UP-TO-DATE
:mergeDebugJniLibFolders
UP-TO-DATE
:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:processDebugJavaRes
UP-TO-DATE
:transformResourcesWithMergeJavaResForDebug
UP-TO-DATE
:validateSigningDebug
:packageDebug
UP-TO-DATE
:assembleDebug
UP-TO-DATE
:cdvBuildDebug UP-TO-DATE
BUILD SUCCESSFUL
Total time: 3.045 secs
Built the following apk(s):
/home/rogers/workspace/practice/myApp/platforms/android/build/outputs/apk/android-debug.apk
ANDROID_HOME=/home/rogers/android-sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle
Skipping build...
Built the following apk(s):
/home/rogers/workspace/practice/myApp/platforms/android/build/outputs/apk/android-debug.apk
Using apk: /home/rogers/workspace/practice/myApp/platforms/android/build/outputs/apk/android-debug.apk
Package name: io.ionic.starter
Error: Failed to execute shell command "input,keyevent,82"" on device: Error: adb: Command failed with exit code 137
[ERROR] An error occurred while running cordova run android --device (exit code 1).
</code></pre>
| 0debug |
static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
{
HEVCLocalContext *lc = s->HEVClc;
int *ret = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int));
int *arg = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int));
int offset;
int startheader, cmpt = 0;
int i, j, res = 0;
if (!s->sList[1]) {
ff_alloc_entries(s->avctx, s->sh.num_entry_point_offsets + 1);
for (i = 1; i < s->threads_number; i++) {
s->sList[i] = av_malloc(sizeof(HEVCContext));
memcpy(s->sList[i], s, sizeof(HEVCContext));
s->HEVClcList[i] = av_mallocz(sizeof(HEVCLocalContext));
s->sList[i]->HEVClc = s->HEVClcList[i];
offset = (lc->gb.index >> 3);
for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_point_offset[0]; j < s->skipped_bytes; j++) {
if (s->skipped_bytes_pos[j] >= offset && s->skipped_bytes_pos[j] < startheader) {
startheader--;
cmpt++;
for (i = 1; i < s->sh.num_entry_point_offsets; i++) {
offset += (s->sh.entry_point_offset[i - 1] - cmpt);
for (j = 0, cmpt = 0, startheader = offset
+ s->sh.entry_point_offset[i]; j < s->skipped_bytes; j++) {
if (s->skipped_bytes_pos[j] >= offset && s->skipped_bytes_pos[j] < startheader) {
startheader--;
cmpt++;
s->sh.size[i - 1] = s->sh.entry_point_offset[i] - cmpt;
s->sh.offset[i - 1] = offset;
if (s->sh.num_entry_point_offsets != 0) {
offset += s->sh.entry_point_offset[s->sh.num_entry_point_offsets - 1] - cmpt;
s->sh.size[s->sh.num_entry_point_offsets - 1] = length - offset;
s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset;
s->data = nal;
for (i = 1; i < s->threads_number; i++) {
s->sList[i]->HEVClc->first_qp_group = 1;
s->sList[i]->HEVClc->qp_y = s->sList[0]->HEVClc->qp_y;
memcpy(s->sList[i], s, sizeof(HEVCContext));
s->sList[i]->HEVClc = s->HEVClcList[i];
avpriv_atomic_int_set(&s->wpp_err, 0);
ff_reset_entries(s->avctx);
for (i = 0; i <= s->sh.num_entry_point_offsets; i++) {
arg[i] = i;
ret[i] = 0;
if (s->pps->entropy_coding_sync_enabled_flag)
s->avctx->execute2(s->avctx, (void *) hls_decode_entry_wpp, arg, ret, s->sh.num_entry_point_offsets + 1);
for (i = 0; i <= s->sh.num_entry_point_offsets; i++)
res += ret[i];
return res; | 1threat |
cannot resolve symbol 'customAdapter' : i want to make a custom list but i am getting an error
"cannot resolve symbol 'customAdapter'".
it is not able to import or what i don't know because i am not an expert i am just a beginner
i want to make a custom list but i am getting an error
"cannot resolve symbol 'customAdapter'".
it is not able to import or what i don't know because i am not an expert i am just a beginner
i want to make a custom list but i am getting an error
"cannot resolve symbol 'customAdapter'".
it is not able to import or what i don't know because i am not an expert i am just a beginner
int[] IMAGES = {R.drawable.doctor_1, R.drawable.doctor_1, R.drawable.doctor_1, R.drawable.doctor_1, R.drawable.doctor_1, R.drawable.doctor_1, R.drawable.doctor_1,
R.drawable.doctor_1, R.drawable.doctor_1, R.drawable.doctor_1};
String[] NAMES = {"Doctor 1", "Doctor 2", "Doctor 3", "Doctor 4", "Doctor 5", "Doctor 6", "Doctor 7", "Doctor 8", "Doctor 9",
"Doctor 10"};
String[] DESCRIPTION = {"MBBS", "MBBS", "MBBS", "MBBS", "MBBS",
"MBBS", "MBBS", "MBBS", "MBBS", "MBBS"};
String[] TIME = {"4:00pm-10:00pm", "4:00pm-10:00pm", "4:00pm-10:00pm", "4:00pm-10:00pm", "4:00pm-10:00pm", "4:00pm-10:00pm", "4:00pm-10:00pm", "4:00pm-10:00pm",
"4:00pm-10:00pm", "4:00pm-10:00pm"};
String[] FEES = {"RS 2000", "RS 500", "RS 200", "RS 2000", "RS 500", "RS 200", "RS 2000", "RS 500", "RS 200", "RS 1000"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
android.app.ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
ListView listView = (ListView) findViewById(R.id.listview);
CustomAdapter customAdapter= new CustomAdapter();
listView.setAdapter(CustomAdapter);
class CustomAdapter extends BaseAdapter{
@Override
public int getCount() {
return IMAGES.length;
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
view = getLayoutInflater().inflate(R.layout.customlayout,null);
ImageView imageview = (ImageView)view.findViewById(R.id.imageView);
TextView textView_name=(TextView)view.findViewById(R.id.name);
TextView textView_description= (TextView)view.findViewById(R.id.description);
TextView textView_time= (TextView)view.findViewById(R.id.time);
TextView textView_fees= (TextView)view.findViewById(R.id.fees);
imageview.setImageResource(IMAGES[i]);
textView_name.setText(NAMES[i]);
textView_description.setText(DESCRIPTION[i]);
textView_time.setText(TIME[i]);
textView_fees.setText(FEES[i]);
return view;
}
}
| 0debug |
USBPacket *usb_ep_find_packet_by_id(USBDevice *dev, int pid, int ep,
uint64_t id)
{
struct USBEndpoint *uep = usb_ep_get(dev, pid, ep);
USBPacket *p;
while ((p = QTAILQ_FIRST(&uep->queue)) != NULL) {
if (p->id == id) {
return p;
}
}
return NULL;
}
| 1threat |
unzip list of tuples in pispark dataframe : I want unzip list of tuples in a column of a pyspark dataframe
Let's say a column as [(blue, 0.5), (red, 0.1), (green, 0.7)], I want to split into two columns, with first column as [blue, red, green] and second column as [0.5, 0.1, 0.7] | 0debug |
int ff_set_systematic_pal(uint32_t pal[256], enum PixelFormat pix_fmt){
int i;
for(i=0; i<256; i++){
int r,g,b;
switch(pix_fmt) {
case PIX_FMT_RGB8:
r= (i>>5 )*36;
g= ((i>>2)&7)*36;
b= (i&3 )*85;
break;
case PIX_FMT_BGR8:
b= (i>>6 )*85;
g= ((i>>3)&7)*36;
r= (i&7 )*36;
break;
case PIX_FMT_RGB4_BYTE:
r= (i>>3 )*255;
g= ((i>>1)&3)*85;
b= (i&1 )*255;
break;
case PIX_FMT_BGR4_BYTE:
b= (i>>3 )*255;
g= ((i>>1)&3)*85;
r= (i&1 )*255;
break;
case PIX_FMT_GRAY8:
r=b=g= i;
break;
}
pal[i] = b + (g<<8) + (r<<16);
}
return 0;
} | 1threat |
static bool aio_dispatch_handlers(AioContext *ctx, HANDLE event)
{
AioHandler *node;
bool progress = false;
node = QLIST_FIRST(&ctx->aio_handlers);
while (node) {
AioHandler *tmp;
ctx->walking_handlers++;
if (!node->deleted &&
(node->pfd.revents || event_notifier_get_handle(node->e) == event) &&
node->io_notify) {
node->pfd.revents = 0;
node->io_notify(node->e);
if (node->e != &ctx->notifier) {
progress = true;
}
}
tmp = node;
node = QLIST_NEXT(node, node);
ctx->walking_handlers--;
if (!ctx->walking_handlers && tmp->deleted) {
QLIST_REMOVE(tmp, node);
g_free(tmp);
}
}
return progress;
}
| 1threat |
jenkins pipeline: multiline shell commands with pipe : <p>I am trying to create a Jenkins pipeline where I need to execute multiple shell commands and use the result of one command in the next command or so. I found that wrapping the commands in a pair of three single quotes <code>'''</code> can accomplish the same. However, I am facing issues while using pipe to feed output of one command to another command. For example </p>
<pre><code> stage('Test') {
sh '''
echo "Executing Tests"
URL=`curl -s "http://localhost:4040/api/tunnels/command_line" | jq -r '.public_url'`
echo $URL
RESULT=`curl -sPOST "https://api.ghostinspector.com/v1/suites/[redacted]/execute/?apiKey=[redacted]&startUrl=$URL" | jq -r '.code'`
echo $RESULT
'''
}
</code></pre>
<p>Commands with pipe are not working properly. Here is the jenkins console output:</p>
<pre><code>+ echo Executing Tests
Executing Tests
+ curl -s http://localhost:4040/api/tunnels/command_line
+ jq -r .public_url
+ URL=null
+ echo null
null
+ curl -sPOST https://api.ghostinspector.com/v1/suites/[redacted]/execute/?apiKey=[redacted]&startUrl=null
</code></pre>
| 0debug |
static int wm8750_tx(I2CSlave *i2c, uint8_t data)
{
WM8750State *s = WM8750(i2c);
uint8_t cmd;
uint16_t value;
if (s->i2c_len >= 2) {
#ifdef VERBOSE
printf("%s: long message (%i bytes)\n", __func__, s->i2c_len);
#endif
return 1;
}
s->i2c_data[s->i2c_len ++] = data;
if (s->i2c_len != 2)
return 0;
cmd = s->i2c_data[0] >> 1;
value = ((s->i2c_data[0] << 8) | s->i2c_data[1]) & 0x1ff;
switch (cmd) {
case WM8750_LADCIN:
s->diff[0] = (((value >> 6) & 3) == 3);
if (s->diff[0])
s->in[0] = &s->adc_voice[0 + s->ds * 1];
else
s->in[0] = &s->adc_voice[((value >> 6) & 3) * 1 + 0];
break;
case WM8750_RADCIN:
s->diff[1] = (((value >> 6) & 3) == 3);
if (s->diff[1])
s->in[1] = &s->adc_voice[0 + s->ds * 1];
else
s->in[1] = &s->adc_voice[((value >> 6) & 3) * 1 + 0];
break;
case WM8750_ADCIN:
s->ds = (value >> 8) & 1;
if (s->diff[0])
s->in[0] = &s->adc_voice[0 + s->ds * 1];
if (s->diff[1])
s->in[1] = &s->adc_voice[0 + s->ds * 1];
s->monomix[0] = (value >> 6) & 3;
break;
case WM8750_ADCTL1:
s->monomix[1] = (value >> 1) & 1;
break;
case WM8750_PWR1:
s->enable = ((value >> 6) & 7) == 3;
wm8750_set_format(s);
break;
case WM8750_LINVOL:
s->invol[0] = value & 0x3f;
s->inmute[0] = (value >> 7) & 1;
wm8750_vol_update(s);
break;
case WM8750_RINVOL:
s->invol[1] = value & 0x3f;
s->inmute[1] = (value >> 7) & 1;
wm8750_vol_update(s);
break;
case WM8750_ADCDAC:
s->pol = (value >> 5) & 3;
s->mute = (value >> 3) & 1;
wm8750_vol_update(s);
break;
case WM8750_ADCTL3:
break;
case WM8750_LADC:
s->invol[2] = value & 0xff;
wm8750_vol_update(s);
break;
case WM8750_RADC:
s->invol[3] = value & 0xff;
wm8750_vol_update(s);
break;
case WM8750_ALC1:
s->alc = (value >> 7) & 3;
break;
case WM8750_NGATE:
case WM8750_3D:
break;
case WM8750_LDAC:
s->outvol[0] = value & 0xff;
wm8750_vol_update(s);
break;
case WM8750_RDAC:
s->outvol[1] = value & 0xff;
wm8750_vol_update(s);
break;
case WM8750_BASS:
break;
case WM8750_LOUTM1:
s->path[0] = (value >> 8) & 1;
wm8750_vol_update(s);
break;
case WM8750_LOUTM2:
s->path[1] = (value >> 8) & 1;
wm8750_vol_update(s);
break;
case WM8750_ROUTM1:
s->path[2] = (value >> 8) & 1;
wm8750_vol_update(s);
break;
case WM8750_ROUTM2:
s->path[3] = (value >> 8) & 1;
wm8750_vol_update(s);
break;
case WM8750_MOUTM1:
s->mpath[0] = (value >> 8) & 1;
wm8750_vol_update(s);
break;
case WM8750_MOUTM2:
s->mpath[1] = (value >> 8) & 1;
wm8750_vol_update(s);
break;
case WM8750_LOUT1V:
s->outvol[2] = value & 0x7f;
wm8750_vol_update(s);
break;
case WM8750_LOUT2V:
s->outvol[4] = value & 0x7f;
wm8750_vol_update(s);
break;
case WM8750_ROUT1V:
s->outvol[3] = value & 0x7f;
wm8750_vol_update(s);
break;
case WM8750_ROUT2V:
s->outvol[5] = value & 0x7f;
wm8750_vol_update(s);
break;
case WM8750_MOUTV:
s->outvol[6] = value & 0x7f;
wm8750_vol_update(s);
break;
case WM8750_ADCTL2:
break;
case WM8750_PWR2:
s->power = value & 0x7e;
wm8750_vol_update(s);
break;
case WM8750_IFACE:
s->format = value;
s->master = (value >> 6) & 1;
wm8750_clk_update(s, s->master);
break;
case WM8750_SRATE:
s->rate = &wm_rate_table[(value >> 1) & 0x1f];
wm8750_clk_update(s, 0);
break;
case WM8750_RESET:
wm8750_reset(I2C_SLAVE(s));
break;
#ifdef VERBOSE
default:
printf("%s: unknown register %02x\n", __FUNCTION__, cmd);
#endif
}
return 0;
}
| 1threat |
static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td, uint32_t *int_mask)
{
UHCIAsync *async;
int len = 0, max_len;
uint8_t pid;
USBDevice *dev;
USBEndpoint *ep;
if (!(td->ctrl & TD_CTRL_ACTIVE))
return TD_RESULT_NEXT_QH;
async = uhci_async_find_td(s, addr, td);
if (async) {
async->queue->valid = 32;
if (!async->done)
return TD_RESULT_ASYNC_CONT;
uhci_async_unlink(async);
goto done;
}
async = uhci_async_alloc(uhci_queue_get(s, td), addr);
if (!async)
return TD_RESULT_NEXT_QH;
async->queue->valid = 32;
async->isoc = td->ctrl & TD_CTRL_IOS;
max_len = ((td->token >> 21) + 1) & 0x7ff;
pid = td->token & 0xff;
dev = uhci_find_device(s, (td->token >> 8) & 0x7f);
ep = usb_ep_get(dev, pid, (td->token >> 15) & 0xf);
usb_packet_setup(&async->packet, pid, ep);
qemu_sglist_add(&async->sgl, td->buffer, max_len);
usb_packet_map(&async->packet, &async->sgl);
switch(pid) {
case USB_TOKEN_OUT:
case USB_TOKEN_SETUP:
len = usb_handle_packet(dev, &async->packet);
if (len >= 0)
len = max_len;
break;
case USB_TOKEN_IN:
len = usb_handle_packet(dev, &async->packet);
break;
default:
uhci_async_free(async);
s->status |= UHCI_STS_HCPERR;
uhci_update_irq(s);
return TD_RESULT_STOP_FRAME;
}
if (len == USB_RET_ASYNC) {
uhci_async_link(async);
return TD_RESULT_ASYNC_START;
}
async->packet.result = len;
done:
len = uhci_complete_td(s, td, async, int_mask);
usb_packet_unmap(&async->packet);
uhci_async_free(async);
return len;
}
| 1threat |
static void rtas_ibm_configure_connector(PowerPCCPU *cpu,
sPAPRMachineState *spapr,
uint32_t token, uint32_t nargs,
target_ulong args, uint32_t nret,
target_ulong rets)
{
uint64_t wa_addr;
uint64_t wa_offset;
uint32_t drc_index;
sPAPRDRConnector *drc;
sPAPRDRConnectorClass *drck;
sPAPRConfigureConnectorState *ccs;
sPAPRDRCCResponse resp = SPAPR_DR_CC_RESPONSE_CONTINUE;
int rc;
const void *fdt;
if (nargs != 2 || nret != 1) {
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
return;
wa_addr = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 0);
drc_index = rtas_ld(wa_addr, 0);
drc = spapr_dr_connector_by_index(drc_index);
if (!drc) {
DPRINTF("rtas_ibm_configure_connector: invalid DRC index: %xh\n",
rc = RTAS_OUT_PARAM_ERROR;
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
fdt = drck->get_fdt(drc, NULL);
ccs = spapr_ccs_find(spapr, drc_index);
if (!ccs) {
ccs = g_new0(sPAPRConfigureConnectorState, 1);
(void)drck->get_fdt(drc, &ccs->fdt_offset);
ccs->drc_index = drc_index;
spapr_ccs_add(spapr, ccs);
do {
uint32_t tag;
const char *name;
const struct fdt_property *prop;
int fdt_offset_next, prop_len;
tag = fdt_next_tag(fdt, ccs->fdt_offset, &fdt_offset_next);
switch (tag) {
case FDT_BEGIN_NODE:
ccs->fdt_depth++;
name = fdt_get_name(fdt, ccs->fdt_offset, NULL);
wa_offset = CC_VAL_DATA_OFFSET;
rtas_st(wa_addr, CC_IDX_NODE_NAME_OFFSET, wa_offset);
rtas_st_buffer_direct(wa_addr + wa_offset, CC_WA_LEN - wa_offset,
(uint8_t *)name, strlen(name) + 1);
resp = SPAPR_DR_CC_RESPONSE_NEXT_CHILD;
break;
case FDT_END_NODE:
ccs->fdt_depth--;
if (ccs->fdt_depth == 0) {
drck->set_configured(drc);
spapr_ccs_remove(spapr, ccs);
ccs = NULL;
resp = SPAPR_DR_CC_RESPONSE_SUCCESS;
} else {
resp = SPAPR_DR_CC_RESPONSE_PREV_PARENT;
break;
case FDT_PROP:
prop = fdt_get_property_by_offset(fdt, ccs->fdt_offset,
&prop_len);
name = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
wa_offset = CC_VAL_DATA_OFFSET;
rtas_st(wa_addr, CC_IDX_PROP_NAME_OFFSET, wa_offset);
rtas_st_buffer_direct(wa_addr + wa_offset, CC_WA_LEN - wa_offset,
(uint8_t *)name, strlen(name) + 1);
wa_offset += strlen(name) + 1,
rtas_st(wa_addr, CC_IDX_PROP_LEN, prop_len);
rtas_st(wa_addr, CC_IDX_PROP_DATA_OFFSET, wa_offset);
rtas_st_buffer_direct(wa_addr + wa_offset, CC_WA_LEN - wa_offset,
(uint8_t *)((struct fdt_property *)prop)->data,
prop_len);
resp = SPAPR_DR_CC_RESPONSE_NEXT_PROPERTY;
break;
case FDT_END:
resp = SPAPR_DR_CC_RESPONSE_ERROR;
default:
break;
if (ccs) {
ccs->fdt_offset = fdt_offset_next;
} while (resp == SPAPR_DR_CC_RESPONSE_CONTINUE);
rc = resp;
out:
rtas_st(rets, 0, rc);
| 1threat |
Python find max in list of lists and elements with undefined number of values : I have a big list of list. I am trying to find max and min in it. Previous questions on this consists lists with strings and this question is differen.t
big_list = [[1,2,3],4,[5,6,0,5,7,8],0,[2,1,4,5],[9,1,-2]]
My code:
max = max(list(map(max,boxs_list)))
Present output:
TypeError: 'numpy.float64' object is not iterable
| 0debug |
static void v9fs_rename(void *opaque)
{
int32_t fid;
ssize_t err = 0;
size_t offset = 7;
V9fsString name;
int32_t newdirfid;
V9fsFidState *fidp;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
pdu_unmarshal(pdu, offset, "dds", &fid, &newdirfid, &name);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -ENOENT;
goto out_nofid;
}
BUG_ON(fidp->fid_type != P9_FID_NONE);
if (!(pdu->s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT)) {
err = -EOPNOTSUPP;
goto out;
}
v9fs_path_write_lock(s);
err = v9fs_complete_rename(pdu, fidp, newdirfid, &name);
v9fs_path_unlock(s);
if (!err) {
err = offset;
}
out:
put_fid(pdu, fidp);
out_nofid:
complete_pdu(s, pdu, err);
v9fs_string_free(&name);
}
| 1threat |
static void usb_mtp_handle_data(USBDevice *dev, USBPacket *p)
{
MTPState *s = USB_MTP(dev);
MTPControl cmd;
mtp_container container;
uint32_t params[5];
int i, rc;
switch (p->ep->nr) {
case EP_DATA_IN:
if (s->data_out != NULL) {
trace_usb_mtp_stall(s->dev.addr, "awaiting data-out");
p->status = USB_RET_STALL;
return;
}
if (p->iov.size < sizeof(container)) {
trace_usb_mtp_stall(s->dev.addr, "packet too small");
p->status = USB_RET_STALL;
return;
}
if (s->data_in != NULL) {
MTPData *d = s->data_in;
int dlen = d->length - d->offset;
if (d->first) {
trace_usb_mtp_data_in(s->dev.addr, d->trans, d->length);
container.length = cpu_to_le32(d->length + sizeof(container));
container.type = cpu_to_le16(TYPE_DATA);
container.code = cpu_to_le16(d->code);
container.trans = cpu_to_le32(d->trans);
usb_packet_copy(p, &container, sizeof(container));
d->first = false;
if (dlen > p->iov.size - sizeof(container)) {
dlen = p->iov.size - sizeof(container);
}
} else {
if (dlen > p->iov.size) {
dlen = p->iov.size;
}
}
if (d->fd == -1) {
usb_packet_copy(p, d->data + d->offset, dlen);
} else {
if (d->alloc < p->iov.size) {
d->alloc = p->iov.size;
d->data = g_realloc(d->data, d->alloc);
}
rc = read(d->fd, d->data, dlen);
if (rc != dlen) {
memset(d->data, 0, dlen);
s->result->code = RES_INCOMPLETE_TRANSFER;
}
usb_packet_copy(p, d->data, dlen);
}
d->offset += dlen;
if (d->offset == d->length) {
usb_mtp_data_free(s->data_in);
s->data_in = NULL;
}
} else if (s->result != NULL) {
MTPControl *r = s->result;
int length = sizeof(container) + r->argc * sizeof(uint32_t);
if (r->code == RES_OK) {
trace_usb_mtp_success(s->dev.addr, r->trans,
(r->argc > 0) ? r->argv[0] : 0,
(r->argc > 1) ? r->argv[1] : 0);
} else {
trace_usb_mtp_error(s->dev.addr, r->code, r->trans,
(r->argc > 0) ? r->argv[0] : 0,
(r->argc > 1) ? r->argv[1] : 0);
}
container.length = cpu_to_le32(length);
container.type = cpu_to_le16(TYPE_RESPONSE);
container.code = cpu_to_le16(r->code);
container.trans = cpu_to_le32(r->trans);
for (i = 0; i < r->argc; i++) {
params[i] = cpu_to_le32(r->argv[i]);
}
usb_packet_copy(p, &container, sizeof(container));
usb_packet_copy(p, ¶ms, length - sizeof(container));
g_free(s->result);
s->result = NULL;
}
break;
case EP_DATA_OUT:
if (p->iov.size < sizeof(container)) {
trace_usb_mtp_stall(s->dev.addr, "packet too small");
p->status = USB_RET_STALL;
return;
}
usb_packet_copy(p, &container, sizeof(container));
switch (le16_to_cpu(container.type)) {
case TYPE_COMMAND:
if (s->data_in || s->data_out || s->result) {
trace_usb_mtp_stall(s->dev.addr, "transaction inflight");
p->status = USB_RET_STALL;
return;
}
cmd.code = le16_to_cpu(container.code);
cmd.argc = (le32_to_cpu(container.length) - sizeof(container))
/ sizeof(uint32_t);
cmd.trans = le32_to_cpu(container.trans);
if (cmd.argc > ARRAY_SIZE(cmd.argv)) {
cmd.argc = ARRAY_SIZE(cmd.argv);
}
if (p->iov.size < sizeof(container) + cmd.argc * sizeof(uint32_t)) {
trace_usb_mtp_stall(s->dev.addr, "packet too small");
p->status = USB_RET_STALL;
return;
}
usb_packet_copy(p, ¶ms, cmd.argc * sizeof(uint32_t));
for (i = 0; i < cmd.argc; i++) {
cmd.argv[i] = le32_to_cpu(params[i]);
}
trace_usb_mtp_command(s->dev.addr, cmd.code, cmd.trans,
(cmd.argc > 0) ? cmd.argv[0] : 0,
(cmd.argc > 1) ? cmd.argv[1] : 0,
(cmd.argc > 2) ? cmd.argv[2] : 0,
(cmd.argc > 3) ? cmd.argv[3] : 0,
(cmd.argc > 4) ? cmd.argv[4] : 0);
usb_mtp_command(s, &cmd);
break;
default:
p->status = USB_RET_STALL;
return;
}
break;
case EP_EVENT:
#ifdef __linux__
if (!QTAILQ_EMPTY(&s->events)) {
struct MTPMonEntry *e = QTAILQ_LAST(&s->events, events);
uint32_t handle;
int len = sizeof(container) + sizeof(uint32_t);
if (p->iov.size < len) {
trace_usb_mtp_stall(s->dev.addr,
"packet too small to send event");
p->status = USB_RET_STALL;
return;
}
QTAILQ_REMOVE(&s->events, e, next);
container.length = cpu_to_le32(len);
container.type = cpu_to_le32(TYPE_EVENT);
container.code = cpu_to_le16(e->event);
container.trans = 0;
handle = cpu_to_le32(e->handle);
usb_packet_copy(p, &container, sizeof(container));
usb_packet_copy(p, &handle, sizeof(uint32_t));
g_free(e);
return;
}
#endif
p->status = USB_RET_NAK;
return;
default:
trace_usb_mtp_stall(s->dev.addr, "invalid endpoint");
p->status = USB_RET_STALL;
return;
}
if (p->actual_length == 0) {
trace_usb_mtp_nak(s->dev.addr, p->ep->nr);
p->status = USB_RET_NAK;
return;
} else {
trace_usb_mtp_xfer(s->dev.addr, p->ep->nr, p->actual_length,
p->iov.size);
return;
}
}
| 1threat |
How do my router obtain normal ip address : <p>My <code>ifconfig</code> configuration is <code>inet addr:192.168.1.3</code> and when I try to get know the router ip by executing <code>ip route show | grep -i 'default via'| awk '{print $3 }'</code> i get <code>192.168.1.1</code></p>
<p>I remember this ipv4 addresses from provider handbook, so they are roughly the same for all ethernet and routers config in my district. </p>
<hr>
<p>The questions are:</p>
<ol>
<li>How can I get know my real <code>ip</code> address?</li>
<li>Who and where assigns me unique <code>ip</code>?</li>
<li>Why do provider assign this standard ip for everyone? </li>
<li>If I get know my unique id will I be able to establish TCP | UDP connection? How does transmission works <code>unique_ip</code> -> 'router_ip' -> 'ethernet_ip' will not it be passed to my friend why share with me router? </li>
</ol>
| 0debug |
SQL - How do I exclude results with the most recent date? : I am very new to SQL and have been learning as I go by just googling and experimenting. I am trying to get all workstation names, jobstream names and valid from dates where there are duplicates in both the workstation and jobstream columns. I currently have the below query:
SELECT T2.WORKSTATION_NAME,T2.JOB_STREAM_NAME,T2.JOB_STREAM_VALID_FROM
FROM (SELECT JOB_STREAM_REFS_V.WORKSTATION_NAME,
JOB_STREAM_REFS_V.JOB_STREAM_NAME
FROM MDL.JOB_STREAM_REFS_V AS JOB_STREAM_REFS_V
GROUP BY WORKSTATION_NAME,JOB_STREAM_NAME
HAVING COUNT(JOB_STREAM_NAME) > 1
ORDER BY WORKSTATION_NAME,JOB_STREAM_NAME) T1
JOIN MDL.JOB_STREAM_REFS_V T2 ON T1.WORKSTATION_NAME = T2.WORKSTATION_NAME AND T1.JOB_STREAM_NAME = T2.JOB_STREAM_NAME
This gives the below results which is what I'd expect:
WORKSTATION_NAME JOB_STREAM_NAME JOB_STREAM_VALID_FROM
-------------------------------------------------------------
STATION1 STREAMA 2015-04-26
STATION1 STREAMA 2015-04-27
STATION2 STREAMB 2016-04-05
STATION2 STREAMB 2016-07-25
STATION2 STREAMB 2016-09-05
STATION2 STREAMB 2017-07-25
STATION2 STREAMC 2016-09-21
STATION2 STREAMC 2016-10-21
STATION3 STREAMD 2016-08-08
STATION3 STREAMD
STATION3 STREAME 2016-09-04
STATION3 STREAME
However I want to exclude the most recent entry for each workstation/jobstream based on the valid from dates and only return results with older valid from dates or with no valid from date, so that I only get the below:
WORKSTATION_NAME JOB_STREAM_NAME JOB_STREAM_VALID_FROM
-------------------------------------------------------------
STATION1 STREAMA 2015-04-26
STATION2 STREAMB 2016-04-05
STATION2 STREAMB 2016-07-25
STATION2 STREAMB 2016-09-05
STATION2 STREAMC 2016-09-21
STATION3 STREAMD
STATION3 STREAME
I'm at a total loss at this point and not sure how to approach this. I've tried using MAX to get the latest dates and show only everything older than that using WHERE but I could not get it to work, I'm not sure where to even place those statements in my query and there is a slight chance I am in over my head.
Thanks in advance | 0debug |
static int yop_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt)
{
YopDecContext *s = avctx->priv_data;
int tag, firstcolor, is_odd_frame;
int ret, i;
uint32_t *palette;
if (s->frame.data[0])
avctx->release_buffer(avctx, &s->frame);
if (avpkt->size < 4 + 3*s->num_pal_colors) {
av_log(avctx, AV_LOG_ERROR, "packet of size %d too small\n", avpkt->size);
return AVERROR_INVALIDDATA;
}
ret = avctx->get_buffer(avctx, &s->frame);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
s->frame.linesize[0] = avctx->width;
s->dstbuf = s->frame.data[0];
s->dstptr = s->frame.data[0];
s->srcptr = avpkt->data + 4;
s->row_pos = 0;
s->low_nibble = NULL;
is_odd_frame = avpkt->data[0];
if(is_odd_frame>1){
av_log(avctx, AV_LOG_ERROR, "frame is too odd %d\n", is_odd_frame);
return AVERROR_INVALIDDATA;
}
firstcolor = s->first_color[is_odd_frame];
palette = (uint32_t *)s->frame.data[1];
for (i = 0; i < s->num_pal_colors; i++, s->srcptr += 3) {
palette[i + firstcolor] = (s->srcptr[0] << 18) |
(s->srcptr[1] << 10) |
(s->srcptr[2] << 2);
palette[i + firstcolor] |= 0xFF << 24 |
(palette[i + firstcolor] >> 6) & 0x30303;
}
s->frame.palette_has_changed = 1;
while (s->dstptr - s->dstbuf <
avctx->width * avctx->height &&
s->srcptr - avpkt->data < avpkt->size) {
tag = yop_get_next_nibble(s);
if (tag != 0xf) {
yop_paint_block(s, tag);
}else {
tag = yop_get_next_nibble(s);
ret = yop_copy_previous_block(s, tag);
if (ret < 0) {
avctx->release_buffer(avctx, &s->frame);
return ret;
}
}
yop_next_macroblock(s);
}
*data_size = sizeof(AVFrame);
*(AVFrame *) data = s->frame;
return avpkt->size;
}
| 1threat |
void ga_channel_free(GAChannel *c)
{
if (c->method == GA_CHANNEL_UNIX_LISTEN
&& c->listen_channel) {
ga_channel_listen_close(c);
}
if (c->client_channel) {
ga_channel_client_close(c);
}
g_free(c);
}
| 1threat |
Python syntax error in unit tests : Okay, so I hate doing this because it's the sort of thing that should be simple and not need SO questions but I'm not a Python dev and I'm trying to debug some unit tests that have been provided for testing an integration.
I'm sure this worked last time I tested it on my local machine, but that seems to have changed - the file hasn't been altered, so I don't know what's changed since then.
I have stripped out the identifying comments and changed some names from the original unit tests because it's proprietary software and I probably shouldn't be posting it at all but I'm out of patience right now.
The syntax error is:
File "unitTests.sh", line 39
gLastFullPath=`python -c "import os; print os.path.realpath('${1}')"`
^
SyntaxError: invalid syntax
The full script is here:
#!/bin/bash
# If non-zero, then run in debug mode, outputting debug information
debug=0
# Set the following to 1 to force an error for testing purposes
forceError=0
separator="===================================================================================================="
#-------------------------------------------------------------------------------
# Convert the specified path to a full path and return it in the gLastFullPath
# global variable.
#
# Input params:
# $1 - Path to convert to full
#
# Output params:
# $gLastFullPath - Set to the converted full path
gLastFullPath=""
getFullPath()
{
# Use Python (because it's easier than Bash) to convert the passed path to
# a full path.
gLastFullPath=`python -c "import os; print os.path.realpath('${1}')"`
}
#-------------------------------------------------------------------------------
fatalError()
{
echo "${separator}"
echo "Fatal Error: $1"
echo "${separator}"
exit 1
}
#-------------------------------------------------------------------------------
# If a file or folder exists at the specified path, then delete it. If it's a
# directory, then its entire contents is deleted.
#-------------------------------------------------------------------------------
deleteIfExists()
{
if [[ 0 -ne $debug ]]; then
echo "deleteIfExists called..."
fi
if [[ -e "$1" ]]; then
# If it's a directory, then make sure it contains no locked files
if [[ -d "$1" ]]; then
chflags -R nouchg "$1"
fi
if [[ 0 -ne $debug ]]; then
echo " Deleting the existing file or directory:"
echo " $1"
fi
# Do the remove and check for an error.
/bin/rm -rf "$1"
if [[ $? -ne 0 ]]; then
fatalError "Unable to delete $1."
fi
fi
if [[ 0 -ne $debug ]]; then
echo
fi
}
#-------------------------------------------------------------------------------
# Script starts here
#-------------------------------------------------------------------------------
# Get the full path to this script
scriptPath=`which "$0"`
getFullPath "${scriptPath}"
scriptFullPath="${gLastFullPath}"
scriptDir=`dirname "${scriptFullPath}"`
scriptName=`basename "${scriptFullPath}"`
if [[ 0 -ne $debug ]]; then
echo "$scriptName: Debug tracing is on."
echo
fi
# Get the SDK project root path
getFullPath "${scriptDir}/.."
projRoot="${gLastFullPath}"
# Get the top of the server tree
getFullPath "${projRoot}/SUBSYS_TOP"
subsysTop="${gLastFullPath}"
libPythonBase="${projRoot}/src/lib/py/devilsoftPy"
devilsoftPython="${libPythonBase}/devilsoftpy"
if [[ 0 -ne $debug ]]; then
echo "$scriptName: Project root dir: \"${projRoot}\""
echo "$scriptName: SUBSYS_TOP: \"${subsysTop}\""
echo "$scriptName: Lib python base: \"${libPythonBase}\""
echo "$scriptName: devilsoft python: \"${devilsoftPython}\""
echo
fi
# First we have to launch the test python server. This is used by some of the other client tests to
# run against.
testServer="${devilsoftPython}/test/TestServer.py"
if [[ ! -f "${testServer}" ]]; then
fatalError "Could not find the expected test server: \"${testServer}\""
fi
# Carve out a place for our test server log file
tempFolder="/tmp/devilsoft"
mkdir -p "${tempFolder}"
testServerLogFile="${tempFolder}/TestServer.log"
echo "Starting the test server: \"${testServer}\""
echo " Logging to this file: \"${testServerLogFile}\""
export PYTHONPATH="${libPythonBase}:${PYTHONPATH}"; "${testServer}" > "${testServerLogFile}" 2>&1 &
testServerPid=$!
echo " Server started with pid ${testServerPid}..."
echo
echo " Taking a little snooze to let the test server initialize..."
sleep 2
# If we're forcing errors for testing, then kill the test server. This will cause downstream scripts
# to fail because there will be no server to talk to.
if [[ $forceError -ne 0 ]]; then
echo "Forcing downstream errors by killing the test server..."
kill ${testServerPid}
wait ${testServerPid}
testServerPid=0
echo
fi
testResultsLogFile="${tempFolder}/TestResults.log"
echo "Testing each python script in the library..."
echo " Test results will be written to this log file: \"${testResultsLogFile}\""
echo
deleteIfExists "${testResultsLogFile}"
# Save and set the field separator so that we can handle spaces in paths
SAVEIFS=$IFS
IFS=$'\n'
failedScripts=()
lastError=0
pythonSources=($(find "${devilsoftPython}" -name '*.py' ! -name '*.svn*' ! -name '__init__.py' ! -name 'TestServer.py' ! -name 'ServerClient.py'))
for pythonSourceFile in ${pythonSources[*]}; do
echo " Testing python source \"${pythonSourceFile}\""
export PYTHONPATH="${libPythonBase}:${PYTHONPATH}"; "${pythonSourceFile}" >> "${testResultsLogFile}" 2>&1
result=$?
if [[ $result -ne 0 ]]; then
pythonSourceName=`basename "${pythonSourceFile}"`
echo " Error ${result} returned from the above script ${pythonSourceName}!"
lastError=${result}
failedScripts+=("${pythonSourceFile}")
fi
done
echo
# Restore the original field separator
IFS=$SAVEIFS
if [[ ${testServerPid} -ne 0 ]]; then
echo "Telling the test server to quit..."
kill ${testServerPid}
wait ${testServerPid}
echo
fi
# If we got an error, tell the user
if [[ $lastError -ne 0 ]]; then
echo "IMPORTANT! The following scripts failed with errors:"
for failedScript in "${failedScripts[@]}"; do
echo " \"${failedScript}\""
done
echo
fatalError "Review the log files to figure out why the above scripts failed."
fi
echo "${separator}"
echo " Hurray! All tests passed!"
echo "${separator}"
echo
exit 0
This is all being run in Python 2.7 | 0debug |
Should I make my code dependent on external libraries? : <p>Tl;dr: Stick to the bold text.</p>
<p><strong>Libraries</strong> provided by others can <strong>save</strong> a lot of <strong>programming time</strong>, because one does not have to solve problems that others already did. Furthermore, they often perform certain tasks much <strong>more efficient</strong> than one could ever achieve by oneself.</p>
<p>On the downside one adds a <strong>dependency</strong> to the program which can cause <strong>problems with licensing, compiling</strong> on other machines and so on. Also developments in the libraries may interfere with developments in ones own code. In extreme cases one is after some time <strong>restricted</strong> to the <strong>functionalities</strong> the library provides meaning that even a small extension might require the programmer to rewrite half of the library. In such a case one may rather want to <strong>exchange the library</strong> with a different one.</p>
<p>At this point one can be in big <strong>trouble</strong> if the whole code is cluttered with calls to the library. To prevent problems like this one can right from the start write a <strong>wrapper</strong> around the external library so that a library change reduces to changing the wrapper and no other code needs to be touched - in theory.</p>
<p>In practice, however, the <strong>interfaces</strong> through which the wrapper is called may <strong>not</strong> be <strong>compatible</strong> with the "new" library. Also a library might use <strong>data structures</strong> that are <strong>not</strong> directly <strong>compatible</strong> with the data types in ones own program. Then data needs to be reorganized and probably a lot of copying happens which was not necessary before.</p>
<p><strong>Questions:</strong></p>
<ul>
<li><strong>How can I avoid trouble with changing libraries?</strong></li>
<li><strong>Should I always wrap the functions external libraries provide?</strong></li>
<li><strong>Should I wrap data objects of external libraries as well?</strong></li>
<li><strong>Or should I instead completely decide for a library and stick with it?</strong></li>
</ul>
<p><strong>Example:</strong></p>
<p>I work on a huge program in which problems of linear algebra are ubiquitous. Recently, we started to switch to Eigen, an efficient library with broad linear algebra functionalities. Eigen comes with its own data objects. Now there are tons of <code>std::vector<double></code> objects present in the code which would need to be replaced with Eigen's <code>VectorXd</code> to be able to nicely work with Eigen. It would be a hell of a work to do all these replacements. However, it would probably be even more work to undo these changes if Eigen at some points turns out to be not the ideal solution. Now I'm not sure whether writing an own vector class which just wraps the Eigen data type would actually reduce the effort if the library will be exchanged someday, or whether I will just produce more problems that way.</p>
| 0debug |
Operator Overloading in Binary Tree c++ : I am writing various operator overloads for a binary tree function that I am creating, the specifications require an overload for
binary_tree& binary_tree::operator=(const binary_tree &other)
{
return binary_tree();
}
the test for the operator working is as follows,
int main(int argc, char **argv)
{
tree = new binary_tree(vector<int>{11, 5, 3, 7});
binary_tree temp = *tree;
temp.insert(12);
str = temp.inorder();
if (str != string("3 5 7 11 12") && temp.inorder() != tree->inorder())
cerr << "test failed (assignment operator)" << endl;
else
cout << "test passed (assignment operator)" << endl;
}
Obviously the point of this test is to create a new tree temp, which has the values of the original, but I can't seem to get it to work so that when .insert(12) is called, it doesn't alter the original tree. The operator has to work based on the test given in main, unedited.
I have tried various things inside the = operator but none of them seem to have any effect. I have methods that can copy values from one tree to another, but none that seem to work with the given test.
Thanks for any help | 0debug |
How to set image received from JSON in UIImageView in objective c : i Received following response from JSON:
{
age = 42;
city = Berlin;
country = Deutschland;
distance = "4.58";
"full_name" = Klaus;
gender = Male;
id = 654;
online = 0;
profile = "Klaus.png";
})
NSString *imageURL = [[_responsedic valueForKey:@"profile"]objectAtIndex:0];
_TopList_ImageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageURL]]];
i want to set profile value in UIImageView.
but this will do nothing. Any help .Thanx in advance.
| 0debug |
Beginner Please Help: How to pass variables in this code? : //Inventory Items classs
import java.util.Scanner;
public class InventoryItems {
public int sackrice = 4;
public int animalfeed = 12;
public int trayeggs = 15;
public int bottlemilk = 9;
ItemSupplier supple = new ItemSupplier();
public void inventoryItem() {
System.out.println("\nAvailable items:\n");
sackrice = sackrice + supple.getRice();
System.out.println("Sack of rice: " + sackrice);
if(sackrice < 10)
System.out.println("Sack of rice low, please restock");
System.out.println();
System.out.println("Animal feed: " + animalfeed);
if(animalfeed < 10)
System.out.println("Animal feed low, please restock");
System.out.println();
System.out.println("Tray of eggs: " + trayeggs);
if(trayeggs < 15)
System.out.println("Tray of eggs low, please restock");
System.out.println();
System.out.println("Bottle of milk: " + bottlemilk);
if(bottlemilk < 15)
System.out.println("Bottle of milk low, please restock");
System.out.println();
press();
}
public static void press(){
Scanner input = new Scanner(System.in);
System.out.println("Press Enter to continue...");
String enter = input.nextLine();
}
}
//Item Supplier class
import java.util.Scanner;
public class ItemSupplier {
public int z;
Scanner scan = new Scanner(System.in);
public void ricesupplier() {
System.out.println("How many sacks of rice would you like to
order?");
z = scan.nextInt();
}
public int getRice() {
return z;
}
public void feedsupplier() {
}
public void eggsupplier() {
}
public void milksupplier() {
}
}
The "z" I get from getRice() is 0. It only takes the declared but initialized z. How do I get the "z" that was inputed in ricesupplier() method? Specfically, here: System.out.println("How many sacks of rice would you like to order?");
z = scan.nextInt(); I'm really just a beginner please help me. | 0debug |
Can't see data in SQL server database table : I can't see data in SQL server database table. The column is of nvarchar(MAX) not null. It stores json string in string format. When I run query Select * from table, I can see the data in o/p window, but can't see when I open table using edit top 200 rows. | 0debug |
How can i convert to json :
I am using the below function, i need to use json object instead of javascript. How i can achieve it?
function ChangeIDToString(strCondition,id)
{
if (strCondition.indexOf("AssignedTo") > -1)
return GetUserName(id)
else if (strCondition.indexOf("ClaimStatusId") > -1)
return GetClaimStatus(id)
else if (strCondition.indexOf("ClaimTypeId") > -1)
return GetClaimType(id);
else
return id;
} | 0debug |
static int dvvideo_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
DVVideoContext *s = avctx->priv_data;
if(buf_size==0)
return 0;
s->sys = dv_frame_profile(buf);
if (!s->sys || buf_size < s->sys->frame_size)
return -1;
if(s->picture.data[0])
avctx->release_buffer(avctx, &s->picture);
s->picture.reference = 0;
avctx->pix_fmt = s->sys->pix_fmt;
avctx->width = s->sys->width;
avctx->height = s->sys->height;
if(avctx->get_buffer(avctx, &s->picture) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
s->picture.interlaced_frame = 1;
s->picture.top_field_first = 0;
s->buf = buf;
avctx->execute(avctx, dv_decode_mt, (void**)&dv_anchor[0], NULL,
s->sys->difseg_size * 27);
emms_c();
*data_size = sizeof(AVFrame);
*(AVFrame*)data= s->picture;
return s->sys->frame_size;
}
| 1threat |
Pass NTLM with Postman : <p>Is there a way to pass <code>Windows Authentication</code> with <code>postman</code>?</p>
<p>I have added this in header but still <code>401 Unauthorized</code>.</p>
<pre><code>Authorization: NTLM TkFcYWRtaW46dGVzdA==
</code></pre>
<p>As suggested by <a href="http://www.innovation.ch/personal/ronald/ntlm.html" rel="noreferrer">this</a> link. I've encrypted as <code>Unicode (UTF-16, little-endian)</code> but of no use.</p>
<p>Any Ideas?</p>
| 0debug |
Why is SQL Server Object Explorer in Visual Studio so slow? : <p>I just created a new SQL Server Database in Azure and then opened it in Visual Studio 2015 using the link in the Azure Portal. I had to add my IP to the firewall but otherwise the process went smoothly.</p>
<p>However, when I am trying to interact with the database server via SQL Server Object Explorer it is painfully slow. Expanding any of the folders in my Database (e.g., <code>Tables</code> folder) takes 10 to 30 seconds. The database is brand new, so the only things it has are whatever Azure creates when it instantiates a new DB.</p>
<p>This is the second Azure DB I have created and tried to view in Visual Studio and both have the same problem. With the first one I thought maybe I did something wrong during setup but this time I made sure to do everything by the book.</p>
<p>Running actual queries against the DB from within Visual Studio (right click the DB, <code>New Query ...</code>, <code>select * from INFORMATION_SCHEMA.TABLES;</code>) is very fast, so it doesn't appear to be a problem with my connection to Azure.</p>
<p>Why is it so painfully slow? What can I do to make it faster?</p>
<p>I am using Visual Studio 2015 Update 1 (<code>14.0.24720.00</code>) on Windows 10 (fully patched) and during database creation I checked the box to use the latest version.</p>
| 0debug |
React enzyme testing, Cannot read property 'have' of undefined : <p>I'm writing a test using <a href="https://github.com/airbnb/enzyme" rel="noreferrer">Enzyme</a> for React.</p>
<p>My test is extremely straightforward:</p>
<pre><code>import OffCanvasMenu from '../index';
import { Link } from 'react-router';
import expect from 'expect';
import { shallow, mount } from 'enzyme';
import sinon from 'sinon';
import React from 'react';
describe('<OffCanvasMenu />', () => {
it('contains 5 <Link /> components', () => {
const wrapper = shallow(<OffCanvasMenu />);
expect(wrapper.find(<Link />)).to.have.length(5);
});
});
</code></pre>
<p>This code is basically taken directly from <a href="https://github.com/airbnb/enzyme/blob/master/docs/api/shallow.md" rel="noreferrer">airbnb/enzyme docs</a>, but returns the error:</p>
<pre><code>FAILED TESTS:
<OffCanvasMenu />
✖ contains 5 <Link /> components
Chrome 52.0.2743 (Mac OS X 10.11.6)
TypeError: Cannot read property 'have' of undefined
</code></pre>
<p>I'm a little unclear on what I'm doing differently from the docs. Any guidance greatly appreciated.</p>
| 0debug |
Basic minesweeper. Bomb counter function not working. : I've been working on some code for a basic minesweeper program and at this point I'm complacently lost. The numbers around the bombs wont generate properly and there doesn't even seem to be a pattern to whats going wrong. I need help with finding a way to fix this issue without having to re-wright my enter program. my teacher cant figure out a way to help me and suggests that I use what i have to make a luck based game sense its due Tuesday. Please help.
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <conio.h>
#include <windows.h>
#include <ctime>
using namespace std;
int main()
{
int GameBoard [9] [9] = { };
int BombTracker [20] = { };
srand(time(0));
for (int c = 0; c <= 10; c++ ) //generates 10 bombs
{
int TX;
int TY;
int MX = rand() % 8;
int MY = rand() % 8;
for ( TY = 1, TX = 0; TY <= 19; TX+=2, TY+=2)
{
if (MY == BombTracker [TY] && MX == BombTracker [TX])
{
MX = rand() % 8;
MY = rand() % 8;
TY = -1;
TX = -2;
}
}
GameBoard [MX] [MY] = 9;
if (MY == 0 && MX == 0) //(0,0)
{
MX = MX + 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //5: my,mx+1
MY = MY + 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //7: my+1,mx+1
MX = MX - 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //6: my+1,mx
}
if (MY == 0 && MX == 8) //(8,0)
{
MX = MX - 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //1: my,mx-1
MY = MY -1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //2: my-1,mx-1
MY = MY + 2;
MX = MX + 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //6: my+1,mx
}
if (MY == 8 && MX == 0) //(0,8)
{
MY = MY - 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //3: my-1,mx
MX = MX + 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //4: my-1,mx+1
MY = MY + 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //5: my,mx+1
}
if (MY == 8 && MX == 8) //(8,8)
{
MX = MX - 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //1: my,mx-1
MY = MY -1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //2: my-1,mx-1
MX = MX + 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //3: my-1,mx
}
if ((MX >= 1 && MX < 8) && (MY > 7)) // bottom row
{
MX = MX - 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //1: my,mx-1
MY = MY -1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //2: my-1,mx-1
MX = MX + 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //3: my-1,mx
MX = MX + 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //4: my-1,mx+1
MY = MY + 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //5: my,mx+1
}
if ((MX >= 1 && MX < 8) && (MY < 1)) // top row
{
MX = MX - 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //1: my,mx-1
MX = MX + 2;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //5: my,mx+1
MY = MY + 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //7: my+1,mx+1
MX = MX - 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //6: my+1,mx
MX = MX - 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //8: my+1,mx-1
}
if ((MX > 7) && (MY >= 1 &&MY < 8)) // right collom
{
MX = MX - 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //1: my,mx-1
MY = MY -1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //2: my-1,mx-1
MX = MX + 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //3: my-1,mx
MY = MY + 2;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //6: my+1,mx
MX = MX - 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //8: my+1,mx-1
}
if ((MX > 7) && (MY >= 1 &&MY < 8)) // left collom
{
MY = MY - 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //3: my-1,mx
MX = MX + 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //4: my-1,mx+1
MY = MY + 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //5: my,mx+1
MY = MY + 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //7: my+1,mx+1
MX = MX - 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //6: my+1,mx
}
if ((MX >= 1 && MX < 8)&&(MY >= 1 && MY < 8)) // middle of the board
{
MX = MX - 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //1: my,mx-1
MY = MY -1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //2: my-1,mx-1
MX = MX + 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //3: my-1,mx
MX = MX + 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //4: my-1,mx+1
MY = MY + 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //5: my,mx+1
MY = MY + 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //7: my+1,mx+1
MX = MX - 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //6: my+1,mx
MX = MX - 1;
GameBoard [MY] [MX] = GameBoard [MY] [MX] + 1; //8: my+1,mx-1
}
}
int width = 9;
int height = 9;
for (int i = 0; i < height; ++i)
{
for (int j = 0; j < width; ++j)
{
cout <<GameBoard[i][j] << " ";
}
cout << endl;
}
}
| 0debug |
static void write_strip_header(CinepakEncContext *s, int y, int h, int keyframe, unsigned char *buf, int strip_size)
{
buf[0] = keyframe ? 0x11: 0x10;
AV_WB24(&buf[1], strip_size + STRIP_HEADER_SIZE);
AV_WB16(&buf[4], y);
AV_WB16(&buf[6], 0);
AV_WB16(&buf[8], h);
AV_WB16(&buf[10], s->w);
}
| 1threat |
How to display a text in one format without actually saving it : <p>I want to display text in one format to the user without actually saving it.</p>
<pre><code>string area = TextField.Text.Substring(0, 6);
string major = TextField.Text.Substring(6, 4);
string minor = TextField.Text.Substring(10, 4);
CardNumberTextField.Text = string.Format("{0} {1} {2}", area, major, minor);
</code></pre>
<p>This works fine where it displays as expected but now <code>TextField.Text</code> also stores the value in same format, is there a better way where it just displays the text in one way but stores in normal format without spaces.</p>
| 0debug |
static int vga_initfn(ISADevice *dev)
{
ISACirrusVGAState *d = DO_UPCAST(ISACirrusVGAState, dev, dev);
VGACommonState *s = &d->cirrus_vga.vga;
vga_common_init(s);
cirrus_init_common(&d->cirrus_vga, CIRRUS_ID_CLGD5430, 0,
isa_address_space(dev), isa_address_space_io(dev));
s->con = graphic_console_init(s->update, s->invalidate,
s->screen_dump, s->text_update,
s);
rom_add_vga(VGABIOS_CIRRUS_FILENAME);
return 0;
}
| 1threat |
Tensorflow set CUDA_VISIBLE_DEVICES within jupyter : <p>I have two GPUs and would like to run two different networks via ipynb simultaneously, however the first notebook always allocates both GPUs. </p>
<p>Using CUDA_VISIBLE_DEVICES, I can hide devices for python files, however I am unsure of how to do so within a notebook.</p>
<p>Is there anyway to hide different GPUs in to notebooks running on the same server?</p>
| 0debug |
Using semi-colons to close functions in JavaScript. Necessary? : <p>When executing a function in JavaScript, I've always ended my code block with a semi-colon by default, because that's what I've been taught to do. Coming from Java it felt a bit unorthodox at first, but syntax is syntax.</p>
<pre><code>function semiColon(args) {
// code block here
};
</code></pre>
<p>or</p>
<pre><code>function sloppyFunction(args) {
// code block here
}
</code></pre>
<p>Lately I've been seeing more and more code where the developer left the semi-colon out after functions, but the intended code still executed normally. So are they actually required? If not, why is it common practice to include them? Do they serve another purpose?</p>
| 0debug |
db.execute('SELECT * FROM products WHERE product_id = ' + product_input) | 1threat |
Packaging an Angular library with i18n support : <p>Angular's <a href="https://angular.io/guide/i18n" rel="noreferrer">i18n</a> is great, and tools like <a href="https://www.npmjs.com/package/ng-packagr" rel="noreferrer">ng-packagr</a> makes component library packaging extremely easy, but can they be combined?</p>
<p>What if i want to package and distribute a component library having translatable components? Is it possible? How do I package such a library? Will translation files be shipped together with the package, or should they be defined in the main app?</p>
<p>It'd be great if someone could point me at some doc.
Thanks</p>
| 0debug |
I need my dictionary to be updated every time I amend it : <p>I made a program which stores, updates, removes passwords for different accounts. However, although the program runs smoothly, whenever I restart the program, the PASSWORDS dictionary gets reset to the value in the program. Is there a way to update the dictionary every time I use the program from Windows CMD?</p>
<pre><code>from sys import *
from pyperclip import *
if argv[1] == 'CamelCase':
print('Entering program')
else:
print('Enter correct password for program')
exit()
PASSWORDS = {'email': 'F7minlBDDuvMJuxESSKHFhTxFtjVB6',
'blog': 'VmALvQyKAxiVH5G8v01if1MLZF3sdt',
'luggage': '12345'}
if len(argv) < 2:
print('No account named')
exit()
action = argv[2]
account = argv[3]
if len(argv) == 5:
password = argv[4]
else:
pass
if action == 'check':
if account in PASSWORDS:
print('The account exists.\nDo you want the password.\nEnter y / n')
response = input()
if response == 'y':
copy(PASSWORDS[account])
print('Password for ' + account + ' copied to clipboard.')
exit()
elif response == 'n':
print('Closing the program')
exit()
else:
print('Closing program due to invalid response')
exit()
if action == 'copy':
copy(PASSWORDS[account])
print('Password for ' + account + ' copied to clipboard.')
exit()
elif action == 'add':
PASSWORDS[account] = password
print('Password for ' + account + ' has been added')
exit()
elif action == 'remove':
PASSWORDS.pop(account)
print('Password for ' + account + ' has been removed')
exit()
elif action == 'update':
PASSWORDS[account] = password
print('Password for ' + account + ' has been updated')
exit()
</code></pre>
| 0debug |
Inserting an iframe to a specific location on top of a png : <p>I have a png:
<a href="https://i.stack.imgur.com/plSBJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/plSBJ.png" alt="enter image description here"></a></p>
<p>I need to insert the iframe into the laptop screen.</p>
| 0debug |
Create an array that prompts the user to enter five letters and sort alphabetically : <p>I am a first year student at Rhodes university and as part of my homework i have been tasked to Create a program that creates an array named sortAlpha. It should prompt a user to enter any five letters of the alphabets and arrange them in alphabetical order. I can't make it work, after so many attempts. </p>
| 0debug |
How to run Spark Scala code on Amazon EMR : <p>I am trying to run the following piece of Spark code written in Scala on Amazon EMR:</p>
<pre><code>import org.apache.spark.{SparkConf, SparkContext}
object TestRunner {
def main(args: Array[String]): Unit = {
val conf = new SparkConf().setAppName("Hello World")
val sc = new SparkContext(conf)
val words = sc.parallelize(Seq("a", "b", "c", "d", "e"))
val wordCounts = words.map(x => (x, 1)).reduceByKey(_ + _)
println(wordCounts)
}
}
</code></pre>
<p>This is the script I am using to deploy the above code into EMR:</p>
<pre><code>#!/usr/bin/env bash
set -euxo pipefail
cluster_id='j-XXXXXXXXXX'
app_name="HelloWorld"
main_class="TestRunner"
jar_name="HelloWorld-assembly-0.0.1-SNAPSHOT.jar"
jar_path="target/scala-2.11/${jar_name}"
s3_jar_dir="s3://jars/"
s3_jar_path="${s3_jar_dir}${jar_name}"
###################################################
sbt assembly
aws s3 cp ${jar_path} ${s3_jar_dir}
aws emr add-steps --cluster-id ${cluster_id} --steps Type=spark,Name=${app_name},Args=[--deploy-mode,cluster,--master,yarn-cluster,--class,${main_class},${s3_jar_path}],ActionOnFailure=CONTINUE
</code></pre>
<p>But, this exits with producing no output at all in AWS after few minutes!</p>
<p>Here's my controller's output:</p>
<pre><code>2016-10-20T21:03:17.043Z INFO Ensure step 3 jar file command-runner.jar
2016-10-20T21:03:17.043Z INFO StepRunner: Created Runner for step 3
INFO startExec 'hadoop jar /var/lib/aws/emr/step-runner/hadoop-jars/command-runner.jar spark-submit --deploy-mode cluster --class TestRunner s3://jars/mscheiber/HelloWorld-assembly-0.0.1-SNAPSHOT.jar'
INFO Environment:
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/opt/aws/bin
LESS_TERMCAP_md=[01;38;5;208m
LESS_TERMCAP_me=[0m
HISTCONTROL=ignoredups
LESS_TERMCAP_mb=[01;31m
AWS_AUTO_SCALING_HOME=/opt/aws/apitools/as
UPSTART_JOB=rc
LESS_TERMCAP_se=[0m
HISTSIZE=1000
HADOOP_ROOT_LOGGER=INFO,DRFA
JAVA_HOME=/etc/alternatives/jre
AWS_DEFAULT_REGION=us-east-1
AWS_ELB_HOME=/opt/aws/apitools/elb
LESS_TERMCAP_us=[04;38;5;111m
EC2_HOME=/opt/aws/apitools/ec2
TERM=linux
XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt
runlevel=3
LANG=en_US.UTF-8
AWS_CLOUDWATCH_HOME=/opt/aws/apitools/mon
MAIL=/var/spool/mail/hadoop
LESS_TERMCAP_ue=[0m
LOGNAME=hadoop
PWD=/
LANGSH_SOURCED=1
HADOOP_CLIENT_OPTS=-Djava.io.tmpdir=/mnt/var/lib/hadoop/steps/s-3UAS8JQ0KEOV3/tmp
_=/etc/alternatives/jre/bin/java
CONSOLETYPE=serial
RUNLEVEL=3
LESSOPEN=||/usr/bin/lesspipe.sh %s
previous=N
UPSTART_EVENTS=runlevel
AWS_PATH=/opt/aws
USER=hadoop
UPSTART_INSTANCE=
PREVLEVEL=N
HADOOP_LOGFILE=syslog
HOSTNAME=ip-10-17-186-102
NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat
HADOOP_LOG_DIR=/mnt/var/log/hadoop/steps/s-3UAS8JQ0KEOV3
EC2_AMITOOL_HOME=/opt/aws/amitools/ec2
SHLVL=5
HOME=/home/hadoop
HADOOP_IDENT_STRING=hadoop
INFO redirectOutput to /mnt/var/log/hadoop/steps/s-3UAS8JQ0KEOV3/stdout
INFO redirectError to /mnt/var/log/hadoop/steps/s-3UAS8JQ0KEOV3/stderr
INFO Working dir /mnt/var/lib/hadoop/steps/s-3UAS8JQ0KEOV3
INFO ProcessRunner started child process 24549 :
hadoop 24549 4780 0 21:03 ? 00:00:00 bash /usr/lib/hadoop/bin/hadoop jar /var/lib/aws/emr/step-runner/hadoop-jars/command-runner.jar spark-submit --deploy-mode cluster --class TestRunner s3://jars/TestRunner-assembly-0.0.1-SNAPSHOT.jar
2016-10-20T21:03:21.050Z INFO HadoopJarStepRunner.Runner: startRun() called for s-3UAS8JQ0KEOV3 Child Pid: 24549
INFO Synchronously wait child process to complete : hadoop jar /var/lib/aws/emr/step-runner/hadoop-...
INFO waitProcessCompletion ended with exit code 0 : hadoop jar /var/lib/aws/emr/step-runner/hadoop-...
INFO total process run time: 44 seconds
2016-10-20T21:04:03.102Z INFO Step created jobs:
2016-10-20T21:04:03.103Z INFO Step succeeded with exitCode 0 and took 44 seconds
</code></pre>
<p>The <code>syslog</code> and <code>stdout</code> is empty and this is in my <code>stderr</code>:</p>
<pre><code>16/10/20 21:03:20 INFO RMProxy: Connecting to ResourceManager at ip-10-17-186-102.ec2.internal/10.17.186.102:8032
16/10/20 21:03:21 INFO Client: Requesting a new application from cluster with 2 NodeManagers
16/10/20 21:03:21 INFO Client: Verifying our application has not requested more than the maximum memory capability of the cluster (53248 MB per container)
16/10/20 21:03:21 INFO Client: Will allocate AM container, with 53247 MB memory including 4840 MB overhead
16/10/20 21:03:21 INFO Client: Setting up container launch context for our AM
16/10/20 21:03:21 INFO Client: Setting up the launch environment for our AM container
16/10/20 21:03:21 INFO Client: Preparing resources for our AM container
16/10/20 21:03:21 WARN Client: Neither spark.yarn.jars nor spark.yarn.archive is set, falling back to uploading libraries under SPARK_HOME.
16/10/20 21:03:22 INFO Client: Uploading resource file:/mnt/tmp/spark-6fceeedf-0ad5-4df1-a63e-c1d7eb1b95b4/__spark_libs__5484581201997889110.zip -> hdfs://ip-10-17-186-102.ec2.internal:8020/user/hadoop/.sparkStaging/application_1476995377469_0002/__spark_libs__5484581201997889110.zip
16/10/20 21:03:24 INFO Client: Uploading resource s3://jars/HelloWorld-assembly-0.0.1-SNAPSHOT.jar -> hdfs://ip-10-17-186-102.ec2.internal:8020/user/hadoop/.sparkStaging/application_1476995377469_0002/DataScience-assembly-0.0.1-SNAPSHOT.jar
16/10/20 21:03:24 INFO S3NativeFileSystem: Opening 's3://jars/HelloWorld-assembly-0.0.1-SNAPSHOT.jar' for reading
16/10/20 21:03:26 INFO Client: Uploading resource file:/mnt/tmp/spark-6fceeedf-0ad5-4df1-a63e-c1d7eb1b95b4/__spark_conf__5724047842379101980.zip -> hdfs://ip-10-17-186-102.ec2.internal:8020/user/hadoop/.sparkStaging/application_1476995377469_0002/__spark_conf__.zip
16/10/20 21:03:26 INFO SecurityManager: Changing view acls to: hadoop
16/10/20 21:03:26 INFO SecurityManager: Changing modify acls to: hadoop
16/10/20 21:03:26 INFO SecurityManager: Changing view acls groups to:
16/10/20 21:03:26 INFO SecurityManager: Changing modify acls groups to:
16/10/20 21:03:26 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users with view permissions: Set(hadoop); groups with view permissions: Set(); users with modify permissions: Set(hadoop); groups with modify permissions: Set()
16/10/20 21:03:26 INFO Client: Submitting application application_1476995377469_0002 to ResourceManager
16/10/20 21:03:26 INFO YarnClientImpl: Submitted application application_1476995377469_0002
16/10/20 21:03:27 INFO Client: Application report for application_1476995377469_0002 (state: ACCEPTED)
16/10/20 21:03:27 INFO Client:
client token: N/A
diagnostics: N/A
ApplicationMaster host: N/A
ApplicationMaster RPC port: -1
queue: default
start time: 1476997406896
final status: UNDEFINED
tracking URL: http://ip-10-17-186-102.ec2.internal:20888/proxy/application_1476995377469_0002/
user: hadoop
16/10/20 21:03:28 INFO Client: Application report for application_1476995377469_0002 (state: ACCEPTED)
16/10/20 21:03:29 INFO Client: Application report for application_1476995377469_0002 (state: ACCEPTED)
16/10/20 21:03:30 INFO Client: Application report for application_1476995377469_0002 (state: ACCEPTED)
16/10/20 21:03:31 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:31 INFO Client:
client token: N/A
diagnostics: N/A
ApplicationMaster host: 10.17.181.184
ApplicationMaster RPC port: 0
queue: default
start time: 1476997406896
final status: UNDEFINED
tracking URL: http://ip-10-17-186-102.ec2.internal:20888/proxy/application_1476995377469_0002/
user: hadoop
16/10/20 21:03:32 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:33 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:34 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:35 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:36 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:37 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:38 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:39 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:40 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:41 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:42 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:43 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:44 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:45 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:46 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:47 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:48 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:49 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:50 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:51 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:52 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:53 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:54 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:55 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:56 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:57 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:58 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:03:59 INFO Client: Application report for application_1476995377469_0002 (state: RUNNING)
16/10/20 21:04:00 INFO Client: Application report for application_1476995377469_0002 (state: FINISHED)
16/10/20 21:04:00 INFO Client:
client token: N/A
diagnostics: N/A
ApplicationMaster host: 10.17.181.184
ApplicationMaster RPC port: 0
queue: default
start time: 1476997406896
final status: SUCCEEDED
tracking URL: http://ip-10-17-186-102.ec2.internal:20888/proxy/application_1476995377469_0002/
user: hadoop
16/10/20 21:04:00 INFO Client: Deleting staging directory hdfs://ip-10-17-186-102.ec2.internal:8020/user/hadoop/.sparkStaging/application_1476995377469_0002
16/10/20 21:04:00 INFO ShutdownHookManager: Shutdown hook called
16/10/20 21:04:00 INFO ShutdownHookManager: Deleting directory /mnt/tmp/spark-6fceeedf-0ad5-4df1-a63e-c1d7eb1b95b4
Command exiting with ret '0'
</code></pre>
<p>What am I missing?</p>
| 0debug |
Can I use JSR 380 annotation without spring or hibernate framework : Just tried to run my simple programme with the main method using JSR 380 annotation, but it is not working for me.
here is the code...
import javax.validation.constraints.Min;
public class MainClass {
public static void main(String[] args) {
Request request = new Request(5);
}
}
class Request{
public Request(int greaterThan10) {
super();
this.greaterThan10 = greaterThan10;
}
@Min(value = 10,message= "value should be greater than 10")
private int greaterThan10;
public int getOne2Ten() {
return greaterThan10;
}
public void setOne2Ten(int greaterThan10) {
this.greaterThan10 = greaterThan10;
}
}
| 0debug |
I am unable to understand below php Function code - : <p>How it will print hello - If hello is true, then the function must print hello, but if the function doesn’t receive hello or hello is false the function must print bye.</p>
<pre><code><?php
function showMessage($hello=false){
echo ($hello)?'hello':'bye';
}
?>
</code></pre>
| 0debug |
static inline int decode_alpha_block(const SHQContext *s, GetBitContext *gb, uint8_t last_alpha[16], uint8_t *dest, int linesize)
{
uint8_t block[128];
int i = 0, x, y;
memset(block, 0, sizeof(block));
{
OPEN_READER(re, gb);
for ( ;; ) {
int run, level;
UPDATE_CACHE_LE(re, gb);
GET_VLC(run, re, gb, ff_dc_alpha_run_vlc_le.table, ALPHA_VLC_BITS, 2);
if (run == 128) break;
i += run;
if (i >= 128)
return AVERROR_INVALIDDATA;
UPDATE_CACHE_LE(re, gb);
GET_VLC(level, re, gb, ff_dc_alpha_level_vlc_le.table, ALPHA_VLC_BITS, 2);
block[i++] = level;
}
CLOSE_READER(re, gb);
}
for (y = 0; y < 8; y++) {
for (x = 0; x < 16; x++) {
last_alpha[x] -= block[y * 16 + x];
}
memcpy(dest, last_alpha, 16);
dest += linesize;
}
return 0;
}
| 1threat |
Why is my code not compiling : <p>I am just learning Python and decided to write a really simple Python bot to reply on Reddit.</p>
<p>On compiling I am getting the following error:</p>
<blockquote>
<p>File "C:\Python35\Scripts\RedditBot\Reddit.py", line 28
except attributeerror:
^ SyntaxError: invalid syntax</p>
</blockquote>
<p>I am unable to see what is causing this as the code looks correct to me. </p>
<pre><code>import praw
USERAGENT = "BOT Name"
USERNAME = "Username"
PASSWORD = "Password"
SUBREDDIT = "Subreddit"
MAXPOSTS = 100
SETPHRASES = ["Phrase", "PhraseOne"]
SETRESPONSE = "This is the response."
print('Logging in to Reddit')
r = praw.Reddit(USERAGENT)
r.login (USERNAME, PASSWORD)
def replybot():
print('Fetching Subreddit ' + SUBREDDIT)
subreddit = r.get_subreddit(SUBREDDIT)
print('Fetching comments')
comments = subreddit.get_comments(limit=MAXPOSTS)
for comment in comments:
try:
cauthor = comment.author.name
cbody = comment.body.lower()
if any(key.lower() in cbody for key in SETPHRASES):
print("Replying to " + cauthor)
comment.reply(SETRESPONSE)
except attributeerror:
pass
replybot()
</code></pre>
| 0debug |
static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
ff_asf_guid mediatype, ff_asf_guid subtype,
ff_asf_guid formattype, int size)
{
WtvContext *wtv = s->priv_data;
AVIOContext *pb = wtv->pb;
if (!ff_guidcmp(subtype, ff_mediasubtype_cpfilters_processed) &&
!ff_guidcmp(formattype, ff_format_cpfilters_processed)) {
ff_asf_guid actual_subtype;
ff_asf_guid actual_formattype;
if (size < 32) {
av_log(s, AV_LOG_WARNING, "format buffer size underflow\n");
avio_skip(pb, size);
return NULL;
}
avio_skip(pb, size - 32);
ff_get_guid(pb, &actual_subtype);
ff_get_guid(pb, &actual_formattype);
avio_seek(pb, -size, SEEK_CUR);
st = parse_media_type(s, st, sid, mediatype, actual_subtype, actual_formattype, size - 32);
avio_skip(pb, 32);
return st;
} else if (!ff_guidcmp(mediatype, ff_mediatype_audio)) {
st = new_stream(s, st, sid, AVMEDIA_TYPE_AUDIO);
if (!st)
return NULL;
if (!ff_guidcmp(formattype, ff_format_waveformatex)) {
int ret = ff_get_wav_header(pb, st->codec, size);
if (ret < 0)
return NULL;
} else {
if (ff_guidcmp(formattype, ff_format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype));
avio_skip(pb, size);
}
if (!memcmp(subtype + 4, (const uint8_t[]){FF_MEDIASUBTYPE_BASE_GUID}, 12)) {
st->codec->codec_id = ff_wav_codec_get_id(AV_RL32(subtype), st->codec->bits_per_coded_sample);
} else if (!ff_guidcmp(subtype, mediasubtype_mpeg1payload)) {
if (st->codec->extradata && st->codec->extradata_size >= 22)
parse_mpeg1waveformatex(st);
else
av_log(s, AV_LOG_WARNING, "MPEG1WAVEFORMATEX underflow\n");
} else {
st->codec->codec_id = ff_codec_guid_get_id(ff_codec_wav_guids, subtype);
if (st->codec->codec_id == AV_CODEC_ID_NONE)
av_log(s, AV_LOG_WARNING, "unknown subtype:"FF_PRI_GUID"\n", FF_ARG_GUID(subtype));
}
return st;
} else if (!ff_guidcmp(mediatype, ff_mediatype_video)) {
st = new_stream(s, st, sid, AVMEDIA_TYPE_VIDEO);
if (!st)
return NULL;
if (!ff_guidcmp(formattype, ff_format_videoinfo2)) {
int consumed = parse_videoinfoheader2(s, st);
avio_skip(pb, FFMAX(size - consumed, 0));
} else if (!ff_guidcmp(formattype, ff_format_mpeg2_video)) {
int consumed = parse_videoinfoheader2(s, st);
int count;
avio_skip(pb, 4);
count = avio_rl32(pb);
avio_skip(pb, 12);
if (count && ff_get_extradata(st->codec, pb, count) < 0) {
ff_free_stream(s, st);
return NULL;
}
consumed += 20 + count;
avio_skip(pb, FFMAX(size - consumed, 0));
} else {
if (ff_guidcmp(formattype, ff_format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype));
avio_skip(pb, size);
}
if (!memcmp(subtype + 4, (const uint8_t[]){FF_MEDIASUBTYPE_BASE_GUID}, 12)) {
st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, AV_RL32(subtype));
} else {
st->codec->codec_id = ff_codec_guid_get_id(ff_video_guids, subtype);
}
if (st->codec->codec_id == AV_CODEC_ID_NONE)
av_log(s, AV_LOG_WARNING, "unknown subtype:"FF_PRI_GUID"\n", FF_ARG_GUID(subtype));
return st;
} else if (!ff_guidcmp(mediatype, mediatype_mpeg2_pes) &&
!ff_guidcmp(subtype, mediasubtype_dvb_subtitle)) {
st = new_stream(s, st, sid, AVMEDIA_TYPE_SUBTITLE);
if (!st)
return NULL;
if (ff_guidcmp(formattype, ff_format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype));
avio_skip(pb, size);
st->codec->codec_id = AV_CODEC_ID_DVB_SUBTITLE;
return st;
} else if (!ff_guidcmp(mediatype, mediatype_mstvcaption) &&
(!ff_guidcmp(subtype, mediasubtype_teletext) || !ff_guidcmp(subtype, mediasubtype_dtvccdata))) {
st = new_stream(s, st, sid, AVMEDIA_TYPE_SUBTITLE);
if (!st)
return NULL;
if (ff_guidcmp(formattype, ff_format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype));
avio_skip(pb, size);
st->codec->codec_id = !ff_guidcmp(subtype, mediasubtype_teletext) ? AV_CODEC_ID_DVB_TELETEXT : AV_CODEC_ID_EIA_608;
return st;
} else if (!ff_guidcmp(mediatype, mediatype_mpeg2_sections) &&
!ff_guidcmp(subtype, mediasubtype_mpeg2_sections)) {
if (ff_guidcmp(formattype, ff_format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype));
avio_skip(pb, size);
return NULL;
}
av_log(s, AV_LOG_WARNING, "unknown media type, mediatype:"FF_PRI_GUID
", subtype:"FF_PRI_GUID", formattype:"FF_PRI_GUID"\n",
FF_ARG_GUID(mediatype), FF_ARG_GUID(subtype), FF_ARG_GUID(formattype));
avio_skip(pb, size);
return NULL;
}
| 1threat |
static int usb_ohci_initfn_pci(struct PCIDevice *dev)
{
OHCIPCIState *ohci = DO_UPCAST(OHCIPCIState, pci_dev, dev);
int num_ports = 3;
pci_config_set_vendor_id(ohci->pci_dev.config, PCI_VENDOR_ID_APPLE);
pci_config_set_device_id(ohci->pci_dev.config,
PCI_DEVICE_ID_APPLE_IPID_USB);
ohci->pci_dev.config[PCI_CLASS_PROG] = 0x10;
pci_config_set_class(ohci->pci_dev.config, PCI_CLASS_SERIAL_USB);
ohci->pci_dev.config[PCI_INTERRUPT_PIN] = 0x01;
usb_ohci_init(&ohci->state, &dev->qdev, num_ports, 0);
ohci->state.irq = ohci->pci_dev.irq[0];
pci_register_bar_simple(&ohci->pci_dev, 0, 256, 0, ohci->state.mem);
return 0;
}
| 1threat |
static int udp_socket_create(UDPContext *s, struct sockaddr_storage *addr,
socklen_t *addr_len, const char *localaddr)
{
int udp_fd = -1;
struct addrinfo *res0 = NULL, *res = NULL;
int family = AF_UNSPEC;
if (((struct sockaddr *) &s->dest_addr)->sa_family)
family = ((struct sockaddr *) &s->dest_addr)->sa_family;
res0 = udp_resolve_host(localaddr[0] ? localaddr : NULL, s->local_port,
SOCK_DGRAM, family, AI_PASSIVE);
if (res0 == 0)
goto fail;
for (res = res0; res; res=res->ai_next) {
udp_fd = ff_socket(res->ai_family, SOCK_DGRAM, 0);
if (udp_fd != -1) break;
log_net_error(NULL, AV_LOG_ERROR, "socket");
}
if (udp_fd < 0)
goto fail;
memcpy(addr, res->ai_addr, res->ai_addrlen);
*addr_len = res->ai_addrlen;
freeaddrinfo(res0);
return udp_fd;
fail:
if (udp_fd >= 0)
closesocket(udp_fd);
if(res0)
freeaddrinfo(res0);
return -1;
}
| 1threat |
c # How to use selenium xpath feature : I want to access and click on the following HTML code elements:
I try
driver.FindElement(By.ClassName("all_excel")).Click();
But an error occurs.
I'd appreciate it if you could give me a solution.
<html>
<body>
<a href="#" class="btn all_excel _excelDownloadBtn _click(nmp.checkout_admin.order.n.sale.delivery.excelDownload()) _stopDefault"><span class="blind">all excel download</span></a>
</body>
</html> | 0debug |
creating Fire-base web chat with PHP : i have web application written in PHP , i want to build a Real-time chat module for my web app, someone suggest me to use fire-base but i am not able to figure out how to build a chat with fir-base and PHP so all my user can chat one to one , tough i have idea that i have to sync all my users to fire-base database to enable chat between them , but how it will work with PHP. if someone have done this before pleas help me out
Here what i found on codelab but it for node.js only can someone suggest me how to do it whit php ?
https://codelabs.developers.google.com/codelabs/firebase-web/#0 | 0debug |
How can a class template store either reference or value? : <p>Reading about <a href="https://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers" rel="noreferrer">universal references</a> led me to wonder: how can I construct a class template such that it stores by reference if possible, or by value if it must?</p>
<p>That is, can I do something like this</p>
<pre><code>template <class T>
class holder {
T obj_m; // should be a reference if possible...
public:
holder(T t) :obj_m { t } {}
}
auto
hold_this(T && t) { return holder<T>(t); }
</code></pre>
<p>Except that when <code>hold_this()</code> is given an <em>lvalue</em> the holder will hold a reference, and when given an <em>rvalue</em> the holder will make a copy?</p>
| 0debug |
Go tests: does using the same package pollute the compiled binary? : ###TL;DR:
Do test written within a package end up in the final exported package? Do they add any garbage or weight to a compiled binary?
###Longer version:
Let's say that I have a `foo` Go package:
```
pkg/
foo/
bar.go
bar_test.go
```
I'm aware of the [black box vs white box](https://stackoverflow.com/questions/19998250/proper-package-naming-for-testing-with-the-go-language/31443271#31443271) approaches to testing in go. A short recap is that I can either:
1. have `bar_test.go` declare a `foo_test` package, or
2. have it part of the main `foo` package.
Approach 1 is considered better because I get to focus on the public API of the package, as I can only access the exported identifiers of `foo`. Also, when application code imports the `foo` package with `import "pkg/foo"`, only the files containing the main `foo` package are compiled. That's nice.
However, there are cases where putting the tests in `foo` is a convenient compromise. I don't particularly like it myself, but I can see it in several codebases and I understand why at times it's necessary.
My question is about what happens to these tests. Since they're part of the package `foo`, when `foo` is imported somewhere, I'd expect the tests to be brought along. Or is the compiler smart enough to strip them?
| 0debug |
uint32_t HELPER(msa)(CPUS390XState *env, uint32_t r1, uint32_t r2, uint32_t r3,
uint32_t type)
{
const uintptr_t ra = GETPC();
const uint8_t mod = env->regs[0] & 0x80ULL;
const uint8_t fc = env->regs[0] & 0x7fULL;
CPUState *cs = CPU(s390_env_get_cpu(env));
uint8_t subfunc[16] = { 0 };
uint64_t param_addr;
int i;
switch (type) {
case S390_FEAT_TYPE_KMAC:
case S390_FEAT_TYPE_KIMD:
case S390_FEAT_TYPE_KLMD:
case S390_FEAT_TYPE_PCKMO:
case S390_FEAT_TYPE_PCC:
if (mod) {
cpu_restore_state(cs, ra);
program_interrupt(env, PGM_SPECIFICATION, 4);
return 0;
}
break;
}
s390_get_feat_block(type, subfunc);
if (!test_be_bit(fc, subfunc)) {
cpu_restore_state(cs, ra);
program_interrupt(env, PGM_SPECIFICATION, 4);
return 0;
}
switch (fc) {
case 0:
for (i = 0; i < 16; i++) {
param_addr = wrap_address(env, env->regs[1] + i);
cpu_stb_data_ra(env, param_addr, subfunc[i], ra);
}
break;
default:
g_assert_not_reached();
}
return 0;
}
| 1threat |
angular 2: using a service to broadcast an event : <p>I'm trying to get a button click in one component to put focus on an element on another component. (Frankly, I don't understand why this must be so complex, but I have not been able to implement any simpler way that actually works.)</p>
<p>I'm using a service. It doesn't need to pass any data except <em>that</em> the click occurred. I'm not sure how the listening component is meant to respond to the event.</p>
<p>app.component:</p>
<p>Skip to main content</p>
<pre><code>import { Component } from '@angular/core';
import { SkipToContentService } from './services/skip-to-content.service';
export class AppComponent {
constructor(
private skipToContent: SkipToContentService
) {}
}
skipLink() {
this.skipToContent.setClicked();
}
}
</code></pre>
<p>login component:</p>
<pre><code><input type="text" name="username" />
import { Component, OnInit } from '@angular/core';
import { SkipToContentService } from '../../../services/skip-to-content.service';
export class BaseLoginComponent implements OnInit {
constructor(
private skipToContent: SkipToContentService
) {
}
ngOnInit() {
this.skipToContent.skipClicked.subscribe(
console.log("!")
// should put focus() on input
);
}
}
</code></pre>
<p>skip-to-content.service:</p>
<pre><code>import { Injectable, EventEmitter } from '@angular/core';
@Injectable()
export class SkipToContentService {
skipClicked: EventEmitter<boolean> = new EventEmitter();
constructor() {
}
setClicked() {
console.log('clicked');
this.skipClicked.emit();
};
}
</code></pre>
<p>I'm a bit lost here as to how logon will "hear" the skipClicked event.</p>
| 0debug |
document.write('<script src="evil.js"></script>'); | 1threat |
static void guess_chs_for_size(BlockDriverState *bs,
uint32_t *pcyls, uint32_t *pheads, uint32_t *psecs)
{
uint64_t nb_sectors;
int cylinders;
bdrv_get_geometry(bs, &nb_sectors);
cylinders = nb_sectors / (16 * 63);
if (cylinders > 16383) {
cylinders = 16383;
} else if (cylinders < 2) {
cylinders = 2;
}
*pcyls = cylinders;
*pheads = 16;
*psecs = 63;
}
| 1threat |
Check wheter one string contains other or not in swift? : <p>I have a two strings.
I want to check if the letters of the 2nd string are a part of the first or not in swift?
How to do it?</p>
| 0debug |
static void bamboo_init(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
const char *cpu_model)
{
unsigned int pci_irq_nrs[4] = { 28, 27, 26, 25 };
PCIBus *pcibus;
CPUState *env;
uint64_t elf_entry;
uint64_t elf_lowaddr;
target_phys_addr_t entry = 0;
target_phys_addr_t loadaddr = 0;
target_long initrd_size = 0;
int success;
int i;
env = ppc440ep_init(&ram_size, &pcibus, pci_irq_nrs, 1, cpu_model);
if (pcibus) {
for (i = 0; i < nb_nics; i++) {
pci_nic_init_nofail(&nd_table[i], "e1000", NULL);
}
}
if (kernel_filename) {
success = load_uimage(kernel_filename, &entry, &loadaddr, NULL);
if (success < 0) {
success = load_elf(kernel_filename, NULL, NULL, &elf_entry,
&elf_lowaddr, NULL, 1, ELF_MACHINE, 0);
entry = elf_entry;
loadaddr = elf_lowaddr;
}
if (success < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
}
if (initrd_filename) {
initrd_size = load_image_targphys(initrd_filename, RAMDISK_ADDR,
ram_size - RAMDISK_ADDR);
if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load ram disk '%s' at %x\n",
initrd_filename, RAMDISK_ADDR);
exit(1);
}
}
if (kernel_filename) {
if (bamboo_load_device_tree(FDT_ADDR, ram_size, RAMDISK_ADDR,
initrd_size, kernel_cmdline) < 0) {
fprintf(stderr, "couldn't load device tree\n");
exit(1);
}
cpu_synchronize_state(env);
env->gpr[1] = (16<<20) - 8;
env->gpr[3] = FDT_ADDR;
env->nip = entry;
}
if (kvm_enabled())
kvmppc_init();
}
| 1threat |
Javascript - How to convert an array of objects to a string you can use with document.getElementByID : What I need is to be able to call on an Array, like this: "myArray[0]" and have the Object in that position come out as a readable string. Here is my code. The alert just says "object Object" - but you can't read it.
var test = [myObject = {name: 'tristyn',
bed: 'felicity',
quote: '$1,000'
},
myObject2 = {name: 'tristyn',
bed: 'felicity',
quote: '$1,000'
}
];
alert(test[0]); | 0debug |
int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,
int level)
{
VDPAUHWContext *hwctx = avctx->hwaccel_context;
VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
VdpVideoSurfaceQueryCapabilities *surface_query_caps;
VdpDecoderQueryCapabilities *decoder_query_caps;
VdpDecoderCreate *create;
void *func;
VdpStatus status;
VdpBool supported;
uint32_t max_level, max_mb, max_width, max_height;
VdpChromaType type;
uint32_t width;
uint32_t height;
vdctx->width = UINT32_MAX;
vdctx->height = UINT32_MAX;
if (av_vdpau_get_surface_parameters(avctx, &type, &width, &height))
return AVERROR(ENOSYS);
if (hwctx) {
hwctx->reset = 0;
if (hwctx->context.decoder != VDP_INVALID_HANDLE) {
vdctx->decoder = hwctx->context.decoder;
vdctx->render = hwctx->context.render;
vdctx->device = VDP_INVALID_HANDLE;
return 0;
}
vdctx->device = hwctx->device;
vdctx->get_proc_address = hwctx->get_proc_address;
if (hwctx->flags & AV_HWACCEL_FLAG_IGNORE_LEVEL)
level = 0;
if (!(hwctx->flags & AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH) &&
type != VDP_CHROMA_TYPE_420)
return AVERROR(ENOSYS);
} else {
AVHWFramesContext *frames_ctx = NULL;
AVVDPAUDeviceContext *dev_ctx;
if (avctx->hw_frames_ctx) {
frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
} else if (avctx->hw_device_ctx) {
int ret;
avctx->hw_frames_ctx = av_hwframe_ctx_alloc(avctx->hw_device_ctx);
if (!avctx->hw_frames_ctx)
return AVERROR(ENOMEM);
frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
frames_ctx->format = AV_PIX_FMT_VDPAU;
frames_ctx->sw_format = avctx->sw_pix_fmt;
frames_ctx->width = avctx->coded_width;
frames_ctx->height = avctx->coded_height;
ret = av_hwframe_ctx_init(avctx->hw_frames_ctx);
if (ret < 0) {
av_buffer_unref(&avctx->hw_frames_ctx);
return ret;
}
}
if (!frames_ctx) {
av_log(avctx, AV_LOG_ERROR, "A hardware frames context is "
"required for VDPAU decoding.\n");
return AVERROR(EINVAL);
}
dev_ctx = frames_ctx->device_ctx->hwctx;
vdctx->device = dev_ctx->device;
vdctx->get_proc_address = dev_ctx->get_proc_address;
if (avctx->hwaccel_flags & AV_HWACCEL_FLAG_IGNORE_LEVEL)
level = 0;
}
if (level < 0)
return AVERROR(ENOTSUP);
status = vdctx->get_proc_address(vdctx->device,
VDP_FUNC_ID_GET_INFORMATION_STRING,
&func);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
else
info = func;
status = info(&info_string);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
if (avctx->codec_id == AV_CODEC_ID_HEVC && strncmp(info_string, "NVIDIA ", 7) == 0 &&
!(avctx->hwaccel_flags & AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH)) {
av_log(avctx, AV_LOG_VERBOSE, "HEVC with NVIDIA VDPAU drivers is buggy, skipping.\n");
return AVERROR(ENOTSUP);
}
status = vdctx->get_proc_address(vdctx->device,
VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES,
&func);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
else
surface_query_caps = func;
status = surface_query_caps(vdctx->device, type, &supported,
&max_width, &max_height);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
if (supported != VDP_TRUE ||
max_width < width || max_height < height)
return AVERROR(ENOTSUP);
status = vdctx->get_proc_address(vdctx->device,
VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES,
&func);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
else
decoder_query_caps = func;
status = decoder_query_caps(vdctx->device, profile, &supported, &max_level,
&max_mb, &max_width, &max_height);
#ifdef VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE
if ((status != VDP_STATUS_OK || supported != VDP_TRUE) && profile == VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE) {
profile = VDP_DECODER_PROFILE_H264_MAIN;
status = decoder_query_caps(vdctx->device, profile, &supported,
&max_level, &max_mb,
&max_width, &max_height);
}
#endif
if (status != VDP_STATUS_OK)
return vdpau_error(status);
if (supported != VDP_TRUE || max_level < level ||
max_width < width || max_height < height)
return AVERROR(ENOTSUP);
status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_CREATE,
&func);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
else
create = func;
status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_RENDER,
&func);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
else
vdctx->render = func;
status = create(vdctx->device, profile, width, height, avctx->refs,
&vdctx->decoder);
if (status == VDP_STATUS_OK) {
vdctx->width = avctx->coded_width;
vdctx->height = avctx->coded_height;
}
return vdpau_error(status);
} | 1threat |
Empty space under my main page footer - Wordpress : <p>I have a weird problem,</p>
<p>My main page (Only) is showing long empty space under page footer and this happens when I use Google Chrome only.
IE, Firefox working without any problems.</p>
<p>PS :
1 - this weird space disappears from Google Chrome when i turn my homepage to static content page.</p>
<p>2 - I've tried to disable all plugins but still have the same problem</p>
<p>So how to solve this problem.?</p>
<p><a href="http://agyadinternational.com/style/" rel="nofollow">Site URL</a></p>
| 0debug |
c# LINQ) How to sum between dates in a DataTable? : Name issue_date free_coupon_days category
Einstein 25/Dec/2015 60 movie
Hellen Keller 01/Jan/2016 7 movie
Einstein 09/Jul/1999 9 movie
Einstein 14/Jun/2015 3 waterpark
Hellen Keller 19/Nov/1980 30 movie
Einstein 29/Sep/2015 19 movie
I have a DataTable dt, for example.
And I want to sum free_coupon_days with criteria as 'Eienstein', Date between '25/Sep/2015 ~ 25/Dec/2015', 'movie'.
The desirable output is **79** as calculated the rows as below.
Name issue_date free_coupon_days category
Einstein 25/Dec/2015 60 movie
Einstein 29/Sep/2015 19 movie
I've tried some ways But I'm beginner against complicated conditions.
How can I do this in LINQ ?
I always respect excellent people here.
Thank you so much ! | 0debug |
static void adpcm_compress_trellis(AVCodecContext *avctx,
const int16_t *samples, uint8_t *dst,
ADPCMChannelStatus *c, int n, int stride)
{
ADPCMEncodeContext *s = avctx->priv_data;
const int frontier = 1 << avctx->trellis;
const int version = avctx->codec->id;
TrellisPath *paths = s->paths, *p;
TrellisNode *node_buf = s->node_buf;
TrellisNode **nodep_buf = s->nodep_buf;
TrellisNode **nodes = nodep_buf;
TrellisNode **nodes_next = nodep_buf + frontier;
int pathn = 0, froze = -1, i, j, k, generation = 0;
uint8_t *hash = s->trellis_hash;
memset(hash, 0xff, 65536 * sizeof(*hash));
memset(nodep_buf, 0, 2 * frontier * sizeof(*nodep_buf));
nodes[0] = node_buf + frontier;
nodes[0]->ssd = 0;
nodes[0]->path = 0;
nodes[0]->step = c->step_index;
nodes[0]->sample1 = c->sample1;
nodes[0]->sample2 = c->sample2;
if (version == AV_CODEC_ID_ADPCM_IMA_WAV ||
version == AV_CODEC_ID_ADPCM_IMA_QT ||
version == AV_CODEC_ID_ADPCM_SWF)
nodes[0]->sample1 = c->prev_sample;
if (version == AV_CODEC_ID_ADPCM_MS)
nodes[0]->step = c->idelta;
if (version == AV_CODEC_ID_ADPCM_YAMAHA) {
if (c->step == 0) {
nodes[0]->step = 127;
nodes[0]->sample1 = 0;
} else {
nodes[0]->step = c->step;
nodes[0]->sample1 = c->predictor;
}
}
for (i = 0; i < n; i++) {
TrellisNode *t = node_buf + frontier*(i&1);
TrellisNode **u;
int sample = samples[i * stride];
int heap_pos = 0;
memset(nodes_next, 0, frontier * sizeof(TrellisNode*));
for (j = 0; j < frontier && nodes[j]; j++) {
const int range = (j < frontier / 2) ? 1 : 0;
const int step = nodes[j]->step;
int nidx;
if (version == AV_CODEC_ID_ADPCM_MS) {
const int predictor = ((nodes[j]->sample1 * c->coeff1) +
(nodes[j]->sample2 * c->coeff2)) / 64;
const int div = (sample - predictor) / step;
const int nmin = av_clip(div-range, -8, 6);
const int nmax = av_clip(div+range, -7, 7);
for (nidx = nmin; nidx <= nmax; nidx++) {
const int nibble = nidx & 0xf;
int dec_sample = predictor + nidx * step;
#define STORE_NODE(NAME, STEP_INDEX)\
int d;\
uint32_t ssd;\
int pos;\
TrellisNode *u;\
uint8_t *h;\
dec_sample = av_clip_int16(dec_sample);\
d = sample - dec_sample;\
ssd = nodes[j]->ssd + d*d;\
\
if (ssd < nodes[j]->ssd)\
goto next_##NAME;\
\
h = &hash[(uint16_t) dec_sample];\
if (*h == generation)\
goto next_##NAME;\
if (heap_pos < frontier) {\
pos = heap_pos++;\
} else {\
\
pos = (frontier >> 1) +\
(heap_pos & ((frontier >> 1) - 1));\
if (ssd > nodes_next[pos]->ssd)\
goto next_##NAME;\
heap_pos++;\
}\
*h = generation;\
u = nodes_next[pos];\
if (!u) {\
av_assert1(pathn < FREEZE_INTERVAL << avctx->trellis);\
u = t++;\
nodes_next[pos] = u;\
u->path = pathn++;\
}\
u->ssd = ssd;\
u->step = STEP_INDEX;\
u->sample2 = nodes[j]->sample1;\
u->sample1 = dec_sample;\
paths[u->path].nibble = nibble;\
paths[u->path].prev = nodes[j]->path;\
\
while (pos > 0) {\
int parent = (pos - 1) >> 1;\
if (nodes_next[parent]->ssd <= ssd)\
break;\
FFSWAP(TrellisNode*, nodes_next[parent], nodes_next[pos]);\
pos = parent;\
}\
next_##NAME:;
STORE_NODE(ms, FFMAX(16,
(ff_adpcm_AdaptationTable[nibble] * step) >> 8));
}
} else if (version == AV_CODEC_ID_ADPCM_IMA_WAV ||
version == AV_CODEC_ID_ADPCM_IMA_QT ||
version == AV_CODEC_ID_ADPCM_SWF) {
#define LOOP_NODES(NAME, STEP_TABLE, STEP_INDEX)\
const int predictor = nodes[j]->sample1;\
const int div = (sample - predictor) * 4 / STEP_TABLE;\
int nmin = av_clip(div - range, -7, 6);\
int nmax = av_clip(div + range, -6, 7);\
if (nmin <= 0)\
nmin--; \
if (nmax < 0)\
nmax--;\
for (nidx = nmin; nidx <= nmax; nidx++) {\
const int nibble = nidx < 0 ? 7 - nidx : nidx;\
int dec_sample = predictor +\
(STEP_TABLE *\
ff_adpcm_yamaha_difflookup[nibble]) / 8;\
STORE_NODE(NAME, STEP_INDEX);\
}
LOOP_NODES(ima, ff_adpcm_step_table[step],
av_clip(step + ff_adpcm_index_table[nibble], 0, 88));
} else {
LOOP_NODES(yamaha, step,
av_clip((step * ff_adpcm_yamaha_indexscale[nibble]) >> 8,
127, 24567));
#undef LOOP_NODES
#undef STORE_NODE
}
}
u = nodes;
nodes = nodes_next;
nodes_next = u;
generation++;
if (generation == 255) {
memset(hash, 0xff, 65536 * sizeof(*hash));
generation = 0;
}
if (nodes[0]->ssd > (1 << 28)) {
for (j = 1; j < frontier && nodes[j]; j++)
nodes[j]->ssd -= nodes[0]->ssd;
nodes[0]->ssd = 0;
}
if (i == froze + FREEZE_INTERVAL) {
p = &paths[nodes[0]->path];
for (k = i; k > froze; k--) {
dst[k] = p->nibble;
p = &paths[p->prev];
}
froze = i;
pathn = 0;
memset(nodes + 1, 0, (frontier - 1) * sizeof(TrellisNode*));
}
}
p = &paths[nodes[0]->path];
for (i = n - 1; i > froze; i--) {
dst[i] = p->nibble;
p = &paths[p->prev];
}
c->predictor = nodes[0]->sample1;
c->sample1 = nodes[0]->sample1;
c->sample2 = nodes[0]->sample2;
c->step_index = nodes[0]->step;
c->step = nodes[0]->step;
c->idelta = nodes[0]->step;
}
| 1threat |
Memory leak in recursive IO function - PAP : <p>I've written a library called <a href="https://hackage.haskell.org/package/amqp-worker" rel="nofollow noreferrer">amqp-worker</a> that provides a function called <code>worker</code> that polls a message queue (like <a href="https://www.rabbitmq.com/" rel="nofollow noreferrer">RabbitMQ</a>) for messages, calling a handler when a message is found. Then it goes back to polling. </p>
<p>It's leaking memory. I've profiled it and the graph says <code>PAP</code> (partial function application) is the culprit. <strong>Where is the leak in my code? How can I avoid leaks when looping in <code>IO</code> with <code>forever</code>?</strong></p>
<p><a href="https://i.stack.imgur.com/NIY2J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NIY2J.png" alt="enter image description here"></a></p>
<p>Here are some relevant functions. <a href="https://github.com/seanhess/amqp-worker" rel="nofollow noreferrer">The full source is here</a>.</p>
<p><a href="https://github.com/seanhess/amqp-worker/blob/master/test/Example.hs" rel="nofollow noreferrer">Example Program</a>. This leaks</p>
<pre><code>main :: IO ()
main = do
-- connect
conn <- Worker.connect (fromURI "amqp://guest:guest@localhost:5672")
-- initialize the queues
Worker.initQueue conn queue
Worker.initQueue conn results
-- publish a message
Worker.publish conn queue (TestMessage "hello world")
-- create a worker, the program loops here
Worker.worker def conn queue onError (onMessage conn)
</code></pre>
<p><a href="https://github.com/seanhess/amqp-worker/blob/master/src/Network/AMQP/Worker/Worker.hs#L35" rel="nofollow noreferrer">worker</a></p>
<pre><code>worker :: (FromJSON a, MonadBaseControl IO m, MonadCatch m) => WorkerOptions -> Connection -> Queue key a -> (WorkerException SomeException -> m ()) -> (Message a -> m ()) -> m ()
worker opts conn queue onError action =
forever $ do
eres <- consumeNext (pollDelay opts) conn queue
case eres of
Error (ParseError reason bd) ->
onError (MessageParseError bd reason)
Parsed msg ->
catch
(action msg)
(onError . OtherException (body msg))
liftBase $ threadDelay (loopDelay opts)
</code></pre>
<p><a href="https://github.com/seanhess/amqp-worker/blob/master/src/Network/AMQP/Worker/Message.hs#L100" rel="nofollow noreferrer">consumeNext</a></p>
<pre><code>consumeNext :: (FromJSON msg, MonadBaseControl IO m) => Microseconds -> Connection -> Queue key msg -> m (ConsumeResult msg)
consumeNext pd conn queue =
poll pd $ consume conn queue
</code></pre>
<p><a href="https://github.com/seanhess/amqp-worker/blob/master/src/Network/AMQP/Worker/Poll.hs#L9" rel="nofollow noreferrer">poll</a></p>
<pre><code>poll :: (MonadBaseControl IO m) => Int -> m (Maybe a) -> m a
poll us action = do
ma <- action
case ma of
Just a -> return a
Nothing -> do
liftBase $ threadDelay us
poll us action
</code></pre>
| 0debug |
static always_inline void gen_405_mulladd_insn (DisasContext *ctx,
int opc2, int opc3,
int ra, int rb, int rt, int Rc)
{
gen_op_load_gpr_T0(ra);
gen_op_load_gpr_T1(rb);
switch (opc3 & 0x0D) {
case 0x05:
gen_op_405_mulchw();
break;
case 0x04:
gen_op_405_mulchwu();
break;
case 0x01:
gen_op_405_mulhhw();
break;
case 0x00:
gen_op_405_mulhhwu();
break;
case 0x0D:
gen_op_405_mullhw();
break;
case 0x0C:
gen_op_405_mullhwu();
break;
}
if (opc2 & 0x02) {
gen_op_neg();
}
if (opc2 & 0x04) {
gen_op_load_gpr_T2(rt);
gen_op_move_T1_T0();
gen_op_405_add_T0_T2();
}
if (opc3 & 0x10) {
if (opc3 & 0x01)
gen_op_405_check_ov();
else
gen_op_405_check_ovu();
}
if (opc3 & 0x02) {
if (opc3 & 0x01)
gen_op_405_check_sat();
else
gen_op_405_check_satu();
}
gen_op_store_T0_gpr(rt);
if (unlikely(Rc) != 0) {
gen_set_Rc0(ctx);
}
}
| 1threat |
How to remotely trigger Jenkins multibranch pipeline project build? : <p>Title mostly says it. How can you trigger a Jenkins multibranch pipeline project build from a remote git repository?</p>
<p>The "Trigger builds remotely" build trigger option does not seem to work, since no tokens that you set are saved.</p>
| 0debug |
shortest code for printing backwards : <p>so I'm trying to create as short as possible code for printing an input backwards, and I want to go below 60B. My code takes 79B, and have no idea if it is actually possible to shorten it even more.</p>
<pre><code>tab=[i for i in map(int,input().split())]
print(" ".join(map(str, tab[::-1])))
</code></pre>
<p>So when I input:</p>
<pre><code>1 2 3 4 5
</code></pre>
<p>I get in output:</p>
<pre><code>5 4 3 2 1
</code></pre>
<p>Anybody got idea if it can be even shorter?</p>
| 0debug |
static void virtio_scsi_clear_aio(VirtIOSCSI *s)
{
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
int i;
if (s->ctrl_vring) {
aio_set_event_notifier(s->ctx, &s->ctrl_vring->host_notifier,
false, NULL);
}
if (s->event_vring) {
aio_set_event_notifier(s->ctx, &s->event_vring->host_notifier,
false, NULL);
}
if (s->cmd_vrings) {
for (i = 0; i < vs->conf.num_queues && s->cmd_vrings[i]; i++) {
aio_set_event_notifier(s->ctx, &s->cmd_vrings[i]->host_notifier,
false, NULL);
}
}
}
| 1threat |
static void vhost_user_stop(VhostUserState *s)
{
if (vhost_user_running(s)) {
vhost_net_cleanup(s->vhost_net);
}
s->vhost_net = 0;
}
| 1threat |
Pass deep link into iOS Simulator : <p>I would like to find an easier way to call deep links in the iOS simulator.<br>
On Android you can use ADB to pipe links into the simulator by using the console.<br>
Is there a similar way or a workaround to do that with the latest iOS simulator? </p>
<p>Best Regards and thank you very much!</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.