problem
stringlengths
26
131k
labels
class label
2 classes
How to change the hover color of material ui table : <p>I am using React and <a href="https://material-ui.com/" rel="noreferrer">Material UI</a> for my web application. I want to change the hover color of table row but cannot do that.</p> <p>Sample code </p> <pre><code>x={ hover:{ color:'green' } } &lt;TableRow hover key={lead.id} className={classes.row} classes={{ hover:x.hover }} onClick={() =&gt; {}}&gt; </code></pre>
0debug
static void v9fs_mknod(void *opaque) { int mode; gid_t gid; int32_t fid; V9fsQID qid; int err = 0; int major, minor; size_t offset = 7; V9fsString name; struct stat stbuf; V9fsString fullname; V9fsFidState *fidp; V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; v9fs_string_init(&fullname); pdu_unmarshal(pdu, offset, "dsdddd", &fid, &name, &mode, &major, &minor, &gid); fidp = get_fid(s, fid); if (fidp == NULL) { err = -ENOENT; goto out_nofid; } v9fs_string_sprintf(&fullname, "%s/%s", fidp->path.data, name.data); err = v9fs_co_mknod(s, &fullname, fidp->uid, gid, makedev(major, minor), mode); if (err < 0) { goto out; } err = v9fs_co_lstat(s, &fullname, &stbuf); if (err < 0) { goto out; } stat_to_qid(&stbuf, &qid); err = offset; err += pdu_marshal(pdu, offset, "Q", &qid); out: put_fid(s, fidp); out_nofid: complete_pdu(s, pdu, err); v9fs_string_free(&fullname); v9fs_string_free(&name); }
1threat
How to create simple Venn Diagram : <p>I need to know how to create a simple Venn diagram in rstudio. I have the following data: A=25, B=19, A&amp;B=7</p> <p>I have no idea wear to start.</p>
0debug
static int get_str(char *buf, int buf_size, const char **pp) { const char *p; char *q; int c; q = buf; p = *pp; while (qemu_isspace(*p)) p++; if (*p == '\0') { fail: *q = '\0'; *pp = p; return -1; } if (*p == '\"') { p++; while (*p != '\0' && *p != '\"') { if (*p == '\\') { p++; c = *p++; switch(c) { case 'n': c = '\n'; break; case 'r': c = '\r'; break; case '\\': case '\'': case '\"': break; default: qemu_printf("unsupported escape code: '\\%c'\n", c); goto fail; } if ((q - buf) < buf_size - 1) { *q++ = c; } } else { if ((q - buf) < buf_size - 1) { *q++ = *p; } p++; } } if (*p != '\"') { qemu_printf("unterminated string\n"); goto fail; } p++; } else { while (*p != '\0' && !qemu_isspace(*p)) { if ((q - buf) < buf_size - 1) { *q++ = *p; } p++; } } *q = '\0'; *pp = p; return 0; }
1threat
static inline void RENAME(planar2x)(const uint8_t *src, uint8_t *dst, int srcWidth, int srcHeight, int srcStride, int dstStride) { int x,y; dst[0]= src[0]; for (x=0; x<srcWidth-1; x++) { dst[2*x+1]= (3*src[x] + src[x+1])>>2; dst[2*x+2]= ( src[x] + 3*src[x+1])>>2; } dst[2*srcWidth-1]= src[srcWidth-1]; dst+= dstStride; for (y=1; y<srcHeight; y++) { const x86_reg mmxSize= srcWidth&~15; __asm__ volatile( "mov %4, %%"REG_a" \n\t" "movq "MANGLE(mmx_ff)", %%mm0 \n\t" "movq (%0, %%"REG_a"), %%mm4 \n\t" "movq %%mm4, %%mm2 \n\t" "psllq $8, %%mm4 \n\t" "pand %%mm0, %%mm2 \n\t" "por %%mm2, %%mm4 \n\t" "movq (%1, %%"REG_a"), %%mm5 \n\t" "movq %%mm5, %%mm3 \n\t" "psllq $8, %%mm5 \n\t" "pand %%mm0, %%mm3 \n\t" "por %%mm3, %%mm5 \n\t" "1: \n\t" "movq (%0, %%"REG_a"), %%mm0 \n\t" "movq (%1, %%"REG_a"), %%mm1 \n\t" "movq 1(%0, %%"REG_a"), %%mm2 \n\t" "movq 1(%1, %%"REG_a"), %%mm3 \n\t" PAVGB" %%mm0, %%mm5 \n\t" PAVGB" %%mm0, %%mm3 \n\t" PAVGB" %%mm0, %%mm5 \n\t" PAVGB" %%mm0, %%mm3 \n\t" PAVGB" %%mm1, %%mm4 \n\t" PAVGB" %%mm1, %%mm2 \n\t" PAVGB" %%mm1, %%mm4 \n\t" PAVGB" %%mm1, %%mm2 \n\t" "movq %%mm5, %%mm7 \n\t" "movq %%mm4, %%mm6 \n\t" "punpcklbw %%mm3, %%mm5 \n\t" "punpckhbw %%mm3, %%mm7 \n\t" "punpcklbw %%mm2, %%mm4 \n\t" "punpckhbw %%mm2, %%mm6 \n\t" MOVNTQ" %%mm5, (%2, %%"REG_a", 2) \n\t" MOVNTQ" %%mm7, 8(%2, %%"REG_a", 2) \n\t" MOVNTQ" %%mm4, (%3, %%"REG_a", 2) \n\t" MOVNTQ" %%mm6, 8(%3, %%"REG_a", 2) \n\t" "add $8, %%"REG_a" \n\t" "movq -1(%0, %%"REG_a"), %%mm4 \n\t" "movq -1(%1, %%"REG_a"), %%mm5 \n\t" " js 1b \n\t" :: "r" (src + mmxSize ), "r" (src + srcStride + mmxSize ), "r" (dst + mmxSize*2), "r" (dst + dstStride + mmxSize*2), "g" (-mmxSize) NAMED_CONSTRAINTS_ADD(mmx_ff) : "%"REG_a ); for (x=mmxSize-1; x<srcWidth-1; x++) { dst[2*x +1]= (3*src[x+0] + src[x+srcStride+1])>>2; dst[2*x+dstStride+2]= ( src[x+0] + 3*src[x+srcStride+1])>>2; dst[2*x+dstStride+1]= ( src[x+1] + 3*src[x+srcStride ])>>2; dst[2*x +2]= (3*src[x+1] + src[x+srcStride ])>>2; } dst[srcWidth*2 -1 ]= (3*src[srcWidth-1] + src[srcWidth-1 + srcStride])>>2; dst[srcWidth*2 -1 + dstStride]= ( src[srcWidth-1] + 3*src[srcWidth-1 + srcStride])>>2; dst+=dstStride*2; src+=srcStride; } dst[0]= src[0]; for (x=0; x<srcWidth-1; x++) { dst[2*x+1]= (3*src[x] + src[x+1])>>2; dst[2*x+2]= ( src[x] + 3*src[x+1])>>2; } dst[2*srcWidth-1]= src[srcWidth-1]; __asm__ volatile(EMMS" \n\t" SFENCE" \n\t" :::"memory"); }
1threat
Cannot implicitly convert type 'System.Data.Entity.DbSet<Logging.Models.Logs>' to 'Logging.Models.Logs' : I'm having issues with the following module in my dbcontext api method page, should I be trying to convert my Logs to Logs? > using System; using System.Collections.Generic; using > System.Data.Entity; using System.Linq; using System.Net; using > System.Net.Http; using System.Web.Http; namespace Logging.Models { > public class Log : DbContext { > > public Log() : base("name=LogContext") { > Database.SetInitializer<Log>(null); > > } > > public DbSet<Logs> Logs { get; set; } > > public Logs GetLog(int Id) { return Logs.Find(Id); } > > public Logs AddLog(Logs p) { Logs.Add(p); SaveChanges(); > return p; } public Logs GetLogsByName(string lookupname) { > List<Logs> mylist = new List<Logs>(); mylist = mylist.Where(p => > > > p.LoggerName.Contains(lookupname)).ToList(); foreach (var item in mylist) { > Logs.Add(item); } > > return Logs; }
0debug
Is there any way to use for loop to print values in certain range but with a specific order- java : <p>I'm sorry if my question is not very clear because i can't find any other way on how to explain it better. I want to do something like this by using for loop:</p> <blockquote> <p>First iteration : 0 , 1, 2, 3, 4,</p> <p>Second iteration: 1, 2, 3, 4, 0</p> <p>Third Iteration : 2, 3, 4, 0, 1</p> <p>Fourth Itertaion : 3, 4, 0, 1, 2</p> <p>Fifth iteration : 4, 0, 1, 2, 3</p> <p>Final Iteration : 0, 1, 2, 3, 4 </p> </blockquote> <p>It will print value from 0 to 4 on the first iteration.<br> And then for the second iteration and the followings the pattern will continue as shown above. Is it possible to do this using for loop in java?</p>
0debug
regex fpr .net needed : i would like to match recursively, all text that ends with : or / or ; or , and remove all these characters, along with any spaces left behind, in the end of the text. Example: some text : ; , / should become: some text What i have tried, just removes the first occurrence of any of these special characters found, how one can do this recursively, so as to delete all characters found that match?
0debug
How to log - the 12 factor application way : <p>I want to know the best practice behind logging my node application. I was reading the 12 factor app guidelines at <a href="https://12factor.net/logs" rel="noreferrer">https://12factor.net/logs</a> and it states that logs should always be sent to the <code>stdout</code>. Cool, but then how would someone manage logs in production? Is there an application that scoops up whatever is sent to <code>stdout</code>? In addition, is it recommended that I only be logging to <code>stdout</code> and not <code>stderr</code>? I would appreciate a perspective on this matter.</p>
0debug
How to have SBT re-run only failed tests : <p>Is there a way to have SBT re-run only the tests that have failed in the last run of the test suite? For example, if I run <code>sbt test</code> and 3 out of the 20 tests I run fail, is there any command I can run to have SBT just re-run those 3 tests that fail?</p> <p>Specifically I am using Scala Test and Scala Check for the tests I am running through SBT.</p>
0debug
static int iscsi_create(const char *filename, QEMUOptionParameter *options) { int ret = 0; int64_t total_size = 0; BlockDriverState bs; IscsiLun *iscsilun = NULL; QDict *bs_options; memset(&bs, 0, sizeof(BlockDriverState)); while (options && options->name) { if (!strcmp(options->name, "size")) { total_size = options->value.n / BDRV_SECTOR_SIZE; } options++; } bs.opaque = g_malloc0(sizeof(struct IscsiLun)); iscsilun = bs.opaque; bs_options = qdict_new(); qdict_put(bs_options, "filename", qstring_from_str(filename)); ret = iscsi_open(&bs, bs_options, 0); QDECREF(bs_options); if (ret != 0) { goto out; } if (iscsilun->nop_timer) { timer_del(iscsilun->nop_timer); timer_free(iscsilun->nop_timer); } if (iscsilun->type != TYPE_DISK) { ret = -ENODEV; goto out; } if (bs.total_sectors < total_size) { ret = -ENOSPC; goto out; } ret = 0; out: if (iscsilun->iscsi != NULL) { iscsi_destroy_context(iscsilun->iscsi); } g_free(bs.opaque); return ret; }
1threat
static QemuConsole *new_console(DisplayState *ds, console_type_t console_type) { Error *local_err = NULL; Object *obj; QemuConsole *s; int i; if (nb_consoles >= MAX_CONSOLES) return NULL; obj = object_new(TYPE_QEMU_CONSOLE); s = QEMU_CONSOLE(obj); object_property_add_link(obj, "device", TYPE_DEVICE, (Object **)&s->device, object_property_allow_set_link, OBJ_PROP_LINK_UNREF_ON_RELEASE, &local_err); object_property_add_uint32_ptr(obj, "head", &s->head, &local_err); if (!active_console || ((active_console->console_type != GRAPHIC_CONSOLE) && (console_type == GRAPHIC_CONSOLE))) { active_console = s; } s->ds = ds; s->console_type = console_type; if (console_type != GRAPHIC_CONSOLE) { s->index = nb_consoles; consoles[nb_consoles++] = s; } else { for (i = nb_consoles; i > 0; i--) { if (consoles[i - 1]->console_type == GRAPHIC_CONSOLE) break; consoles[i] = consoles[i - 1]; consoles[i]->index = i; } s->index = i; consoles[i] = s; nb_consoles++; } return s; }
1threat
Bootstrap does not be set to Django app : <p>Bootstrap does not be set to my Django app.In google console,Failed to load resource: the server responded with a status of 404 (Not Found) bootflat.min.css error happens.I wrote in settings.py </p> <pre><code>BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) DEBUG =True STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, "static/") STATICFILES_DIRS = [os.path.join(BASE_DIR,'bootflat.github.io'), ] </code></pre> <p>in PythonServer_nginx.conf</p> <pre><code>server { # the port your site will be served on listen 8000; # the domain name it will serve for server_name MyServerIPAdress; # substitute your machine's IP address or FQDN charset utf-8; # max upload size client_max_body_size 75M; # adjust to taste location /static { alias /home/ubuntu/PythonServer/PythonServer/accounts/static; # your Django project's static files - amend as required } # Finally, send all non-media requests to the Django server. location / { uwsgi_pass django; include /home/ubuntu/PythonServer/uwsgi_params; # the uwsgi_params file you installed } } </code></pre> <p>I do not know why Bootstrap does not be set to my Django app.I run command python manage.py collectstatic but no error happens.How should I fix this?What should I write it?</p>
0debug
C++, memset a double array failed : I am new to C, and I want to declare a doube type array dynamicly, so here is my code void function(int length, ...) { [snippet] double * a = (double *)malloc(sizeof(double) * length); memset(a, 1, sizeof(double) * length); for (int i = 0; i < length; i ++) { cout << a[i] << endl; } [snippet] } When I set the length to 2 and the code did not print all 1s. It just print the following outputs. 7.7486e-304 7.7486e-304 So, what should I do to fix it? Thank you!
0debug
static void apply_channel_coupling(AC3EncodeContext *s) { LOCAL_ALIGNED_16(CoefType, cpl_coords, [AC3_MAX_BLOCKS], [AC3_MAX_CHANNELS][16]); #if CONFIG_AC3ENC_FLOAT LOCAL_ALIGNED_16(int32_t, fixed_cpl_coords, [AC3_MAX_BLOCKS], [AC3_MAX_CHANNELS][16]); #else int32_t (*fixed_cpl_coords)[AC3_MAX_CHANNELS][16] = cpl_coords; #endif int av_uninit(blk), ch, bnd, i, j; CoefSumType energy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][16] = {{{0}}}; int cpl_start, num_cpl_coefs; memset(cpl_coords, 0, AC3_MAX_BLOCKS * sizeof(*cpl_coords)); #if CONFIG_AC3ENC_FLOAT memset(fixed_cpl_coords, 0, AC3_MAX_BLOCKS * sizeof(*cpl_coords)); #endif cpl_start = s->start_freq[CPL_CH] - 1; num_cpl_coefs = FFALIGN(s->num_cpl_subbands * 12 + 1, 32); cpl_start = FFMIN(256, cpl_start + num_cpl_coefs) - num_cpl_coefs; for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; CoefType *cpl_coef = &block->mdct_coef[CPL_CH][cpl_start]; if (!block->cpl_in_use) continue; memset(cpl_coef, 0, num_cpl_coefs * sizeof(*cpl_coef)); for (ch = 1; ch <= s->fbw_channels; ch++) { CoefType *ch_coef = &block->mdct_coef[ch][cpl_start]; if (!block->channel_in_cpl[ch]) continue; for (i = 0; i < num_cpl_coefs; i++) cpl_coef[i] += ch_coef[i]; } clip_coefficients(&s->adsp, cpl_coef, num_cpl_coefs); } bnd = 0; i = s->start_freq[CPL_CH]; while (i < s->cpl_end_freq) { int band_size = s->cpl_band_sizes[bnd]; for (ch = CPL_CH; ch <= s->fbw_channels; ch++) { for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; if (!block->cpl_in_use || (ch > CPL_CH && !block->channel_in_cpl[ch])) continue; for (j = 0; j < band_size; j++) { CoefType v = block->mdct_coef[ch][i+j]; MAC_COEF(energy[blk][ch][bnd], v, v); } } } i += band_size; bnd++; } for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; if (!block->cpl_in_use) continue; for (ch = 1; ch <= s->fbw_channels; ch++) { if (!block->channel_in_cpl[ch]) continue; for (bnd = 0; bnd < s->num_cpl_bands; bnd++) { cpl_coords[blk][ch][bnd] = calc_cpl_coord(energy[blk][ch][bnd], energy[blk][CPL_CH][bnd]); } } } for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; AC3Block *block0 = blk ? &s->blocks[blk-1] : NULL; memset(block->new_cpl_coords, 0, sizeof(block->new_cpl_coords)); if (block->cpl_in_use) { if (blk == 0 || !block0->cpl_in_use) { for (ch = 1; ch <= s->fbw_channels; ch++) block->new_cpl_coords[ch] = 1; } else { for (ch = 1; ch <= s->fbw_channels; ch++) { if (!block->channel_in_cpl[ch]) continue; if (!block0->channel_in_cpl[ch]) { block->new_cpl_coords[ch] = 1; } else { CoefSumType coord_diff = 0; for (bnd = 0; bnd < s->num_cpl_bands; bnd++) { coord_diff += FFABS(cpl_coords[blk-1][ch][bnd] - cpl_coords[blk ][ch][bnd]); } coord_diff /= s->num_cpl_bands; if (coord_diff > NEW_CPL_COORD_THRESHOLD) block->new_cpl_coords[ch] = 1; } } } } } for (bnd = 0; bnd < s->num_cpl_bands; bnd++) { blk = 0; while (blk < s->num_blocks) { int av_uninit(blk1); AC3Block *block = &s->blocks[blk]; if (!block->cpl_in_use) { blk++; continue; } for (ch = 1; ch <= s->fbw_channels; ch++) { CoefSumType energy_ch, energy_cpl; if (!block->channel_in_cpl[ch]) continue; energy_cpl = energy[blk][CPL_CH][bnd]; energy_ch = energy[blk][ch][bnd]; blk1 = blk+1; while (!s->blocks[blk1].new_cpl_coords[ch] && blk1 < s->num_blocks) { if (s->blocks[blk1].cpl_in_use) { energy_cpl += energy[blk1][CPL_CH][bnd]; energy_ch += energy[blk1][ch][bnd]; } blk1++; } cpl_coords[blk][ch][bnd] = calc_cpl_coord(energy_ch, energy_cpl); } blk = blk1; } } for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; if (!block->cpl_in_use) continue; #if CONFIG_AC3ENC_FLOAT s->ac3dsp.float_to_fixed24(fixed_cpl_coords[blk][1], cpl_coords[blk][1], s->fbw_channels * 16); #endif s->ac3dsp.extract_exponents(block->cpl_coord_exp[1], fixed_cpl_coords[blk][1], s->fbw_channels * 16); for (ch = 1; ch <= s->fbw_channels; ch++) { int bnd, min_exp, max_exp, master_exp; if (!block->new_cpl_coords[ch]) continue; min_exp = max_exp = block->cpl_coord_exp[ch][0]; for (bnd = 1; bnd < s->num_cpl_bands; bnd++) { int exp = block->cpl_coord_exp[ch][bnd]; min_exp = FFMIN(exp, min_exp); max_exp = FFMAX(exp, max_exp); } master_exp = ((max_exp - 15) + 2) / 3; master_exp = FFMAX(master_exp, 0); while (min_exp < master_exp * 3) master_exp--; for (bnd = 0; bnd < s->num_cpl_bands; bnd++) { block->cpl_coord_exp[ch][bnd] = av_clip(block->cpl_coord_exp[ch][bnd] - master_exp * 3, 0, 15); } block->cpl_master_exp[ch] = master_exp; for (bnd = 0; bnd < s->num_cpl_bands; bnd++) { int cpl_exp = block->cpl_coord_exp[ch][bnd]; int cpl_mant = (fixed_cpl_coords[blk][ch][bnd] << (5 + cpl_exp + master_exp * 3)) >> 24; if (cpl_exp == 15) cpl_mant >>= 1; else cpl_mant -= 16; block->cpl_coord_mant[ch][bnd] = cpl_mant; } } } if (CONFIG_EAC3_ENCODER && s->eac3) ff_eac3_set_cpl_states(s); }
1threat
javascript dependencies in python project : <p>I'm writing software that allows one to publish mathematical books as websites. It is based mostly on Python + Flask, but to deal with equations I'm using MathJax. MathJax can be used either client-side or server-side (through <a href="https://github.com/mathjax/MathJax-node" rel="noreferrer">MathJax-node</a>). In the latter case I have to use <code>npm</code> to install MathJax-node in some place accessible to my main Python script, then invoke it from the script. In the former case, I have to provide MathJax.js as an asset, available to client (currently I use Flask's <code>send_from_directory</code> function).</p> <p>My question is: what is the best practice of dealing with such heterogenous dependencies in Python? My goal is to make installation process as simple as possible at least on unix-like systems (Linux or MacOS), provided that <code>node</code> and <code>npm</code> are already available.</p> <p>I can just put all the javascript sources I need into my distribution itself, but maybe there's a better way to do it?</p>
0debug
Convert .Net Core to .Net Framework : <p>I have a .Net Core project web project, and for various reasons want to convert it to a .Net Framework project.</p> <p>Is there an easy way to do this, or do I have to start again and import the code from the previous projects</p>
0debug
Want to sum of values with same property name in object using javascript or jquery : <p>Hi I want to do sum of the quantity for each reason name.And I have 2 arrays as per below.</p> <pre><code>var allreasonsids=[]; allreasonsids = [ {reasonid: 1, reasonname: abc}, {reasonid: 2, reasonname: def}, {reasonid: 3, reasonname: ghi}, {reasonid: 4, reasonname: jkl} ]; var reasonsandcount=[]; reasonsandcount=[ {reasonid: 1, quantity: 5}, {reasonid: 2, quantity: 10}, {reasonid: 1, quantity: 3}, {reasonid: 3, quantity: 4}, {reasonid: 1, quantity: 2}, {reasonid: 2, quantity: 6} ]; </code></pre> <p>I want the result as per below:</p> <p><strong>Output:</strong> abc :10</p> <p>def:16</p> <p>ghi:4</p> <p>jkl:0</p> <p>Please suggest me any answer. Thank You.</p>
0debug
static void disas_simd_zip_trn(DisasContext *s, uint32_t insn) { unsupported_encoding(s, insn); }
1threat
What do these characters in Swift mean <>. If I wrapped a keyword In them, what would that mean exactly : <p>For example if I have:</p> <pre><code>var hostingController: UIHostingController&lt;Content&gt;! = nil </code></pre> <p>What does it example mean when I put content inside the greater than and less than signs?</p>
0debug
Date formatting error assistance in bash shell script issue : <p>I'm having issue identifying what exactly my issue is with this bash shell script. I copied exactly what my teacher has but cannot get it to run properly. Thank you in advance.</p> <p>Script: [Script code for the program<a href="https://i.stack.imgur.com/VYqAX.png" rel="nofollow noreferrer">1</a></p> <p>Outcome: <a href="https://i.stack.imgur.com/DdF9j.png" rel="nofollow noreferrer">Outcome</a></p>
0debug
Concatinate variable and string in perl Regex : I am saving a string in a variable. I want to use this variable in regex along with some other patterns. For example my variable is like this, my $value = 'COMPONENT' I want to use this variable in regex along with some pattern like 01,02. So my matching expressions will be like /COMPONENT01/ I am using something like this `/\Q$value/` But not sure how i can add 01 to it.
0debug
Writing in the same colone (csv file) C : I have a problem, to write data in a csv file. The data registers well, but all in the same column. FILE *fichier = NULL; fichier = fopen("ville_secu_informatique_centroide.csv", "a"); fwrite((pVille + iVille)->Commune, sizeof(char) * 100, 1, fichier); fwrite((pVille + iVille)->CodeInsee, sizeof(char) * 100, 1, fichier); fwrite((pVille + iVille)->url, sizeof(char) * 100, 1, fichier); fwrite((pVille + iVille)->Population, sizeof(char) * 100, 1, fichier); fwrite((pVille + iVille)->https, sizeof(char) * 100, 1, fichier); fwrite((pVille + iVille)->Serveur, sizeof(char) * 100, 1, fichier); fwrite((pVille + iVille)->Versionduserveur, sizeof(char) * 100, 1, fichier); fwrite((pVille + iVille)->Application, sizeof(char) * 100, 1, fichier); fwrite((pVille + iVille)->VersionApp, sizeof(char) * 100, 1, fichier); fwrite((pVille + iVille)->Langage, sizeof(char) * 100, 1, fichier); fwrite((pVille + iVille)->VersionLang, sizeof(char) * 100, 1, fichier); fwrite((pVille + iVille)->Latitude, sizeof(char) * 100, 1, fichier); fwrite((pVille + iVille)->Longitude, sizeof(char) * 100, 1, fichier); fclose(fichier); I would like to write in different columns in my csv file Thank for your Help
0debug
Why do you need to fold/unfold using coalesce for a conditional insert? : <p>I'm trying to understand how this pattern for a conditional insert works:</p> <pre><code>g.V() .hasLabel('person').has('name', 'John') .fold() .coalesce( __.unfold(), g.addV('person').property('name', 'John') ).next(); </code></pre> <p>What is the purpose of the fold/unfold? Why are these necessary, and why does this not work:</p> <pre><code>g.V() .coalesce( __.hasLabel('person').has('name', 'John'), g.addV('person').property('name', 'John') ).next(); </code></pre> <p>The fold-then-unfold pattern seems redundant to me and yet the above does not yield the same result.</p>
0debug
Need a little help in HTML Text Input Boxes. : Currently user is allowed to enter information to all the 5 input boxes. I am working on creating something where user to only be allowed to answer 3 questions from the form and as he answers the 3 questions of his choice the rest of the input text fields (boxes) in the form become disabled. <html> <h1>Security Questions</h1> <body> <p> Only Enter Answer 3 Security Questions. </p> <form action="/submitAnswer.php" method="POST"> <label>What City Was Your Mom Born In?</label><br> <input type="text" id="secQuestion01" name="secQuestion01"><br> <label>What Is Your Dream Car?</label><br> <input type="text" id="secQuestion02" name="secQuestion02"><br> <label>What Is Your Mother's Maidan Name?</label><br> <input type="text" name="secQuestion03"><br> <label>What's Your Dream Job?</label><br> <input type="text" name="secQuestion04"><br> <label>Name Your First Grade Teacher?</label><br> <input type="text" name="secQuestion05"><label><br> <label>Name Your First Pet?</label><br> <input type="text" name="secQuestion01"><label><br> </form> </body> </html>
0debug
static off_t read_uint32(int fd, int64_t offset) { uint32_t buffer; if (pread(fd, &buffer, 4, offset) < 4) return 0; return be32_to_cpu(buffer); }
1threat
Why is onResume called after onRequestPermissionsResult? : <p>I run into some problems with the android permissions. The problem is that onResume get called every time onRequestPermissionsResult has been called even if the user already said "Never ask again".</p> <p>An example:</p> <pre><code> @Override public void onResume() { super.onResume(); startLocationProvider(); } private void startLocationProvider() { if ( !locationService.requestLocationPermission( this, 0 ) ) { return; } @Override public void onRequestPermissionsResult( int requestCode, String[] permissions, int[] grantResults ) { if ( requestCode == 0 ) { if ( grantResults.length == 1 &amp;&amp; grantResults[ 0 ] == PackageManager.PERMISSION_GRANTED ) { startLocationProvider(); } } </code></pre> <p>It works fine until the user select "Never ask again" and deny. I don't know why onResume is called again and again although no dialog is shown to the user.</p>
0debug
Why am I getting null in onCreate? How can I intialise : it might be a trivial question, if so I'm sorry-I'm new to Java. Basically, I'm trying to set list equal to a sharedPreference that is saved. However the app keeps on crashing because the list is null to begin with. As you can see I have tried to initialise it. I need list to be public because I use it in another method. So the relevant code looks something like this public class SecondActivity extends AppCompatActivity { public int[] list = { 1, 1, 1, 1, 1, 1 }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_second); if (list == null) { for (int i : list) { i = 1; } } list = getFromPrefs("updateList"); Log.i("is Correct is ", Arrays.toString(list)); }}
0debug
firebase_messaging onResume and onLaunch not working : <p>I am getting the notification when the app is in the foreground but not when the app in the background. Also, I have google-ed/StackOverflow-ed for like 2 hours or more but able to resolves this.</p> <p>My Configurations are :</p> <pre><code> firebase_auth: ^0.10.0 firebase_messaging: ^5.0.0 </code></pre> <p>The manifest is like this:</p> <p><a href="https://i.stack.imgur.com/Y8IOB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Y8IOB.png" alt="Manifest"></a></p> <p>The code is like this:</p> <pre><code>final notifications = new FirebaseMessaging(); class AppNotifications { static String fcmToken = ''; static Future&lt;Null&gt; init() async { appLogs("AppNotifications init"); notifications.requestNotificationPermissions(const IosNotificationSettings(sound: true, badge: true, alert: true)); await configure(); fcmToken = await notifications.getToken(); appLogs("FCM TOKEN : " + fcmToken); notifications.onTokenRefresh.listen((newToken) { fcmToken = newToken; appLogs("FCM TOKEN onTokenRefresh: " + fcmToken); }); await updateFCMToken(); } static Future&lt;Null&gt; configure() async { appLogs("AppNotifications Configure"); notifications.configure(onMessage: (msg) { appLogs('FCM onMessage: ' + msg.toString()); }, onLaunch: (lun) { appLogs('FCM onLaunch: ' + lun.toString()); }, onResume: (res) { appLogs('FCM onResume: ' + res.toString()); }); } static Future&lt;Null&gt; updateFCMToken() async { auth.currentUser.fcmToken = fcmToken; await updateUserInSharedPreference(); } } </code></pre> <p>I am calling the function like this:</p> <pre><code>class HomeScreenState extends State&lt;HomeScreen&gt; { @override void initState() { super.initState(); Future.delayed(Duration(milliseconds: 100), () async { await AppNotifications.init(); }); } ..... .... </code></pre> <p>I am using postman for sending the notification :</p> <p><a href="https://i.stack.imgur.com/dYmEM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dYmEM.png" alt="Postman"></a> </p> <p>My logs : </p> <pre><code>**(App is Foreground)** I/flutter (31888): APPLOGS : FCM onMessage: {notification: {title: Test notification title, body: Test notification body}, data: {status: done, id: 1, foo: bar, click_action: FLUTTER_NOTIFICATION_CLICK}} **(App is Background)** W/FirebaseMessaging(31888): Missing Default Notification Channel metadata in AndroidManifest. Default value will be used. </code></pre> <p>Flutter doctor :</p> <pre><code>[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.14.4 18E226, locale en-GB) • Flutter version 1.2.1 at /Users/Ajay/SDK/flutter • Framework revision 8661d8aecd (3 months ago), 2019-02-14 19:19:53 -0800 • Engine revision 3757390fa4 • Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb) [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) • Android SDK at /Users/Ajay/Library/Android/sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-28, build-tools 28.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01) • All Android licenses accepted. [✓] iOS toolchain - develop for iOS devices (Xcode 10.2.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 10.2.1, Build version 10E1001 • ios-deploy 1.9.4 • CocoaPods version 1.6.0 [✓] Android Studio (version 3.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 34.0.1 • Dart plugin version 182.5215 • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01) [!] VS Code (version 1.33.1) • VS Code at /Applications/Visual Studio Code.app/Contents ✗ Flutter extension not installed; install from https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [✓] Connected device (1 available) • ONEPLUS A5000 • b47e8396 • android-arm64 • Android 9 (API 28) </code></pre>
0debug
static int64_t coroutine_fn vpc_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **file) { BDRVVPCState *s = bs->opaque; VHDFooter *footer = (VHDFooter*) s->footer_buf; int64_t start, offset; bool allocated; int64_t ret; int n; if (be32_to_cpu(footer->type) == VHD_FIXED) { *pnum = nb_sectors; *file = bs->file->bs; return BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID | (sector_num << BDRV_SECTOR_BITS); } qemu_co_mutex_lock(&s->lock); offset = get_image_offset(bs, sector_num << BDRV_SECTOR_BITS, false); start = offset; allocated = (offset != -1); *pnum = 0; ret = 0; do { n = ROUND_UP(sector_num + 1, s->block_size / BDRV_SECTOR_SIZE) - sector_num; n = MIN(n, nb_sectors); *pnum += n; sector_num += n; nb_sectors -= n; if (allocated) { *file = bs->file->bs; ret = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | start; break; } if (nb_sectors == 0) { break; } offset = get_image_offset(bs, sector_num << BDRV_SECTOR_BITS, false); } while (offset == -1); qemu_co_mutex_unlock(&s->lock); return ret; }
1threat
static int decode_pce(AACContext *ac, enum ChannelPosition new_che_pos[4][MAX_ELEM_ID], GetBitContext *gb) { int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc, sampling_index; skip_bits(gb, 2); sampling_index = get_bits(gb, 4); if (ac->m4ac.sampling_index != sampling_index) av_log(ac->avccontext, AV_LOG_WARNING, "Sample rate index in program config element does not match the sample rate index configured by the container.\n"); num_front = get_bits(gb, 4); num_side = get_bits(gb, 4); num_back = get_bits(gb, 4); num_lfe = get_bits(gb, 2); num_assoc_data = get_bits(gb, 3); num_cc = get_bits(gb, 4); if (get_bits1(gb)) skip_bits(gb, 4); if (get_bits1(gb)) skip_bits(gb, 4); if (get_bits1(gb)) skip_bits(gb, 3); decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_FRONT, gb, num_front); decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_SIDE, gb, num_side ); decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_BACK, gb, num_back ); decode_channel_map(NULL, new_che_pos[TYPE_LFE], AAC_CHANNEL_LFE, gb, num_lfe ); skip_bits_long(gb, 4 * num_assoc_data); decode_channel_map(new_che_pos[TYPE_CCE], new_che_pos[TYPE_CCE], AAC_CHANNEL_CC, gb, num_cc ); align_get_bits(gb); skip_bits_long(gb, 8 * get_bits(gb, 8)); return 0; }
1threat
Write longest and shortest palindrom from text file : i am trying to write a program what will write longest and shortest palindrom from words in text file. My code looks like this now: static void Main(string[] args) { string[] lines = System.IO.File.ReadAllLines(@"C:\palindromy.txt"); foreach (string line in lines) { char[] charArray = line.ToCharArray(); for (int i = 0; i < 1; i++) { Array.Reverse(charArray); bool a = charArray.SequenceEqual(line); while(a == true) { Console.WriteLine(line); /that will just write all palindroms break; } } } } I am curently just writing all palindroms, but i need to write just longest and shortest one.
0debug
static void report_unsupported_feature(BlockDriverState *bs, Error **errp, Qcow2Feature *table, uint64_t mask) { while (table && table->name[0] != '\0') { if (table->type == QCOW2_FEAT_TYPE_INCOMPATIBLE) { if (mask & (1 << table->bit)) { report_unsupported(bs, errp, "%.46s", table->name); mask &= ~(1 << table->bit); } } table++; } if (mask) { report_unsupported(bs, errp, "Unknown incompatible feature: %" PRIx64, mask); } }
1threat
Access Configuration/Settings on static class - Asp Core : <p>I have 3 solutions. Project.Web, Project.Core (Business), and Project.Layer(Models). </p> <p>In Project.Core, I have a static file that I can call like this <code>Business.GetAllData();</code> from Project.Web.Controller.</p> <p>This calls DAL/EF files and gets data(<code>BusinessDal.GetData()</code>). </p> <pre><code> using (DBContext db = new DBContext()) { return db.GetAllData().ToPOCO(); } </code></pre> <p>On my configuration/DbContext.cs, I have this:</p> <pre><code>protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { #if DEBUG optionsBuilder.UseSqlServer(@"connstring"); #else optionsBuilder.UseSqlServer(@"connstring"); #endif // How do I access configuration here? Configuration["ConnectionString"] } </code></pre> <p>What I'm trying to do is read settings from my appsettings.json. I made sure settings are loaded properly on startup.cs</p> <pre><code>public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); Configuration = builder.Build(); } </code></pre> <p>But now what?... <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?tabs=basicconfiguration" rel="noreferrer">MS Document</a> shows how to read it from controllers. And that part works fine, I can read my settings on Controllers. However, I am not sure how to pass it to another project and still be able to call it from a static class. </p>
0debug
Check time that is conflict on javascript : How to check time is conflict I have a enrolment project and user get subject on the list. Now how to check the time is conflict with others: var time1 = 10:00AM-12:00:PM; var time2 = 10:30:AM-11:00:AM; How to check the time2 is conflict with time1 ? Im using javascript and I cant find solution. Or you may suggest jquery libraries please help. Thanks
0debug
static void tftp_send_next_block(struct tftp_session *spt, struct tftp_t *recv_tp) { struct sockaddr_in saddr, daddr; struct mbuf *m; struct tftp_t *tp; int nobytes; m = m_get(spt->slirp); if (!m) { return; } memset(m->m_data, 0, m->m_size); m->m_data += IF_MAXLINKHDR; tp = (void *)m->m_data; m->m_data += sizeof(struct udpiphdr); tp->tp_op = htons(TFTP_DATA); tp->x.tp_data.tp_block_nr = htons((spt->block_nr + 1) & 0xffff); saddr.sin_addr = recv_tp->ip.ip_dst; saddr.sin_port = recv_tp->udp.uh_dport; daddr.sin_addr = spt->client_ip; daddr.sin_port = spt->client_port; nobytes = tftp_read_data(spt, spt->block_nr, tp->x.tp_data.tp_buf, 512); if (nobytes < 0) { m_free(m); tftp_send_error(spt, 1, "File not found", tp); return; } m->m_len = sizeof(struct tftp_t) - (512 - nobytes) - sizeof(struct ip) - sizeof(struct udphdr); udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY); if (nobytes == 512) { tftp_session_update(spt); } else { tftp_session_terminate(spt); } spt->block_nr++; }
1threat
Webpack console.log output? : <p>Can anyone direct me in the right direction? </p> <p>So i've setup the webpack-dev-server with the truffle suite demo, just to get a basis on the foundation of my app. So my config file includes index.html &amp; app.js, yet it try to display a console.log output to from app.js nothing shows via the console? </p> <p>webpack.config.js</p> <pre><code>const path = require('path'); const CopyWebpackPlugin = require('copy-webpack-plugin'); module.exports = { entry: './app/javascripts/app.js', output: { path: path.resolve(__dirname, 'build'), filename: 'app.js', }, plugins: [ // Copy our app's index.html to the build folder. new CopyWebpackPlugin([ { from: './app/index.html', to: "index.html" } ]) ], module: { rules: [ { test: /\.css$/, use: [ 'style-loader', 'css-loader' ] } ], loaders: [ { test: /\.json$/, use: 'json-loader' }, { test: /\.js$/, exclude: /(node_modules|bower_components)/, loader: 'babel-loader', query: { presets: ['es2015'], plugins: ['transform-runtime'] } } ] }, devServer: { compress: true, disableHostCheck: true, // That solved . quiet: false, noInfo: false, stats: { // Config for minimal console.log mess. colors: true, version: false, hash: false, timings: false, chunks: false, chunkModules: false } } } </code></pre> <p>app.js</p> <pre><code>// Import libraries we need. import { default as Web3} from 'web3'; import { default as contract } from 'truffle-contract' // Import our contract artifacts and turn them into usable abstractions. import metacoin_artifacts from '../../build/contracts/MetaCoin.json' import dextre_artifacts from '../../build/contracts/Dextre.json' console.log("starting!"); </code></pre> <p>Output when running webpack</p> <pre><code>Project is running at http://localhost:8080/ webpack output is served from / Asset Size Chunks Chunk Names app.js 1.93 MB 0 [emitted] [big] main index.html 19.8 kB [emitted] webpack: Compiled successfully. </code></pre> <p>Where can view the "starting!" output, this is a real annoyance as i need to tackle errors. I've tried viewing at <a href="http://localhost:8080//" rel="noreferrer">http://localhost:8080//</a> and <a href="http://localhost:8080/webpack-dev-server//" rel="noreferrer">http://localhost:8080/webpack-dev-server//</a>, but no luck.</p>
0debug
i was not able to get the output for this below coding in PL/SQL ..please help me to solve this : i have a table with 3 columns like eid,ename,salary.so i wanted to display all emplyes name with their salaries by using cursor and records. if there is any mistakes in my code please let me know.. DECLARE CURSOR emp_c IS select ename,salary from emp2; TYPE rec_2 IS RECORD { v_name varchar2(50); v_sal number(10); }; r1 rec_2; BEGIN open emp_c; loop fetch emp_c into r1; exit when emp_c%notfound; dbms_output.put_line('name='||r1.v_name||'salary='||r1.v_sal); end loop; END;
0debug
Popular special characters in git branch names : <p>I'm writing an application where I limit allowed characters in git branch names. Currently the limit is [a-zA-Z0-9/_-]+. What other special characters may be requested by users? I know that / is popular that's why I've included it, is there other such character?</p>
0debug
static av_cold int alac_decode_init(AVCodecContext * avctx) { ALACContext *alac = avctx->priv_data; alac->avctx = avctx; alac->context_initialized = 0; alac->numchannels = alac->avctx->channels; return 0; }
1threat
Electron Take Up 100% Of Screen (Not Full Screen) : <p>I've got an electron app, below is the <code>main.js</code> file:</p> <pre><code>var app = require('electron').app; var BrowserWindow = require('electron').BrowserWindow; app.on('ready', function() { mainWindow = new BrowserWindow({ height: 715, width: 1200, minWidth: 600, minHeight: 200, center: true }); mainWindow.loadURL('file://' + __dirname + '/index.html'); }); </code></pre> <p>As you can see, the width and height are specified. What I want is for the app to open, but take up all of the available screen (but <em>NOT</em> to be in full screen, such that the dock and tool bar of the OS are hidden).</p> <p>In simple CSS this is done by using </p> <pre><code>width:100%; height:100%; </code></pre> <p>I want to be able to reproduce this in my electron app, although cannot seem to find any details on how to do it</p> <p>Note: <code>fullscreen: true</code> is not what I am looking for, as that makes the app open so that the dock and toolbar are hidden</p> <p>Can anyone help?</p>
0debug
How does java know when in a PriorityQueue , an items key is changed in order to re-heapify the changed node : <pre><code> class PQItem implements Comparable&lt;PQItem&gt;{ public int key; public PQItem(int key) { this.key = key; } @Override public int compareTo(PQItem o) { return this.key - o.key; } public String toString(){ return this.key+""; } </code></pre> <p>}</p> <pre><code> PriorityQueue&lt;PQItem&gt; pq = new PriorityQueue&lt;&gt;(); PQItem pq1 = new PQItem(45); PQItem pq2 = new PQItem(1); PQItem pq3 = new PQItem(4); PQItem pq4 = new PQItem(3); pq.offer(pq1); pq.offer(pq2); pq.offer(pq3); pq.offer(pq4); pq1.key = 40; pq2.key = -4; System.out.println(pq.poll()); System.out.println(pq.poll()); System.out.println(pq.poll()); System.out.println(pq.poll()); </code></pre> <p>Above prints as expected in sorted order -4 3 4 40</p> <p>The question is I want to know if the operation of changing the key was done in O(lg n) with a Heapify on the changed node.If it was done, how does java detect me setting a property on one of the objects in order to trigger the heapify procedure on that node.</p>
0debug
How can I use Pipe symbol "|" from Java to Batch file? : <p>I'm using java in eclipse to call a .bat file using Runtime method. I have two options, send a variable or multiple variables. My unique option is to separate it with pipe "|".</p> <p>when I send a unique variable it assumes correct and run the .bat file, but when I add the symbol "|" to the string it doesn't open the .bat file, even when I only show what I send. (the problem actually I think, somehow the pipe cut the runtime process).</p> <p>The problem is that I need to send something like: 1st example .- a (Just a character it works fine.) 2nd example .- a|b|c|d|e (more than 1 variable separated by pipe, the .bat never opens)</p>
0debug
How to change lower case to upper using regular expressions in Visual Studio Code : <p>I'm using Visual Studio Code 1.14.2, and I'm trying to change name of variables to camelCase eg. <code>set_nominal_wavelength</code> to <code>setNominalWavelength</code>.</p> <p>Regular expression: <code>_([a-z])</code></p> <p>Replace: <code>\U$1\E</code></p> <p>does not work. Any idea how to achieve it?</p>
0debug
How to use SharedPreferences to save more than one Integer values? : <p>I want to store more than one Integer Values in Shared Preference. Is this possible to do it?</p>
0debug
use RecyclerView like vertical viewpager : <p>is this possible to use recyclerview like verticalpager .<br> what I want is when a user scrolls always the first item offset from the top be zero. like when you scroll in viewpager. is this possible?</p>
0debug
Android: Could not find com.android.support:support-v4:23.2.1 : <p>I add this library in my gradle file:</p> <pre><code>compile 'com.appeaser.sublimepickerlibrary:sublimepickerlibrary:2.0.0' </code></pre> <p>I've already these dependencies:</p> <pre><code>dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile "com.android.support:design:23.+" compile 'com.android.support:support-v4:23.+' compile 'com.android.support:support-v13:23.+' compile 'com.android.support:appcompat-v7:23.+' compile 'com.android.support:cardview-v7:23.+' compile 'com.android.support:recyclerview-v7:23.+' </code></pre> <p>Since, I've added SublimePicker library, I add this error:</p> <p>Error:Could not find com.android.support:support-v4:23.2.1. Required by: Android:app:unspecified</p> <p>Could you help me guys ?</p>
0debug
static char *SocketAddress_to_str(const char *prefix, SocketAddress *addr, bool is_listen, bool is_telnet) { switch (addr->type) { case SOCKET_ADDRESS_KIND_INET: return g_strdup_printf("%s%s:%s:%s%s", prefix, is_telnet ? "telnet" : "tcp", addr->u.inet->host, addr->u.inet->port, is_listen ? ",server" : ""); break; case SOCKET_ADDRESS_KIND_UNIX: return g_strdup_printf("%sunix:%s%s", prefix, addr->u.q_unix->path, is_listen ? ",server" : ""); break; case SOCKET_ADDRESS_KIND_FD: return g_strdup_printf("%sfd:%s%s", prefix, addr->u.fd->str, is_listen ? ",server" : ""); break; default: abort(); } }
1threat
how to get viewModel by viewModels? (fragment-ktx) : <p>I am working with Single viewModel for the Activity and all of it's fragment.</p> <p>So to initialise <code>viewmodel</code> if have to write this setup code in <code>onActivityCreated</code> of all the fragment's</p> <pre><code> override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) viewModel = ViewModelProviders.of(activity!!).get(NoteViewModel::class.java) } </code></pre> <p>I was going thorough the Android KTX extension page:(<a href="https://developer.android.com/kotlin/ktx#fragment" rel="noreferrer">refer here</a>) </p> <p>and i found i can initialise view model like this:</p> <pre><code> // Get a reference to the ViewModel scoped to this Fragment val viewModel by viewModels&lt;MyViewModel&gt;() // Get a reference to the ViewModel scoped to its Activity val viewModel by activityViewModels&lt;MyViewModel&gt;() </code></pre> <p>So I added below dependency's to my gradle(app):</p> <pre><code> //ktx android implementation 'androidx.core:core-ktx:1.0.2' implementation 'androidx.fragment:fragment-ktx:1.0.0' implementation "androidx.lifecycle:lifecycle-extensions:2.0.0" </code></pre> <p>But when i try to use <code>viewModels/activityViewModels</code> in my application their reference in not found.</p> <p>I want help in how to use these extension's with some basic example i tried searching for examples haven't found any.</p>
0debug
static int lance_init(SysBusDevice *sbd) { DeviceState *dev = DEVICE(sbd); SysBusPCNetState *d = SYSBUS_PCNET(dev); PCNetState *s = &d->state; memory_region_init_io(&s->mmio, OBJECT(d), &lance_mem_ops, d, "lance-mmio", 4); qdev_init_gpio_in(dev, parent_lance_reset, 1); sysbus_init_mmio(sbd, &s->mmio); sysbus_init_irq(sbd, &s->irq); s->phys_mem_read = ledma_memory_read; s->phys_mem_write = ledma_memory_write; return pcnet_common_init(dev, s, &net_lance_info); }
1threat
static int configure_accelerator(MachineClass *mc) { const char *p; char buf[10]; int i, ret; bool accel_initialised = false; bool init_failed = false; p = qemu_opt_get(qemu_get_machine_opts(), "accel"); if (p == NULL) { p = "tcg"; } while (!accel_initialised && *p != '\0') { if (*p == ':') { p++; } p = get_opt_name(buf, sizeof (buf), p, ':'); for (i = 0; i < ARRAY_SIZE(accel_list); i++) { if (strcmp(accel_list[i].opt_name, buf) == 0) { if (!accel_list[i].available()) { printf("%s not supported for this target\n", accel_list[i].name); break; } *(accel_list[i].allowed) = true; ret = accel_list[i].init(mc); if (ret < 0) { init_failed = true; fprintf(stderr, "failed to initialize %s: %s\n", accel_list[i].name, strerror(-ret)); *(accel_list[i].allowed) = false; } else { accel_initialised = true; } break; } } if (i == ARRAY_SIZE(accel_list)) { fprintf(stderr, "\"%s\" accelerator does not exist.\n", buf); } } if (!accel_initialised) { if (!init_failed) { fprintf(stderr, "No accelerator found!\n"); } exit(1); } if (init_failed) { fprintf(stderr, "Back to %s accelerator.\n", accel_list[i].name); } return !accel_initialised; }
1threat
Why do they call it a player? : <p>Dont get the reason behind why they call it a player in build settings.</p> <p><a href="https://i.stack.imgur.com/Q9qSC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Q9qSC.png" alt="enter image description here"></a></p>
0debug
Spring RestTemplate with paginated API : <p>Our REST APIs are returning results in Pages. Here is an example of one Controller</p> <pre><code>@RequestMapping(value = "/search", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=UTF-8") @ResponseStatus(HttpStatus.OK) public Page&lt;MyObject&gt; findAll(Pageable pageable) { ... } </code></pre> <p>Is there an easy way to consume that API with RestTemplate?</p> <p>if we do</p> <pre><code>ParameterizedTypeReference&lt;Page&lt;MyObject&gt;&gt; responseType = new ParameterizedTypeReference&lt;Page&lt;MyObject&gt;&gt;() { }; ResponseEntity&lt;Page&lt;MyObject&gt;&gt; result = restTemplate.exchange(url, HttpMethod.GET, null/*httpEntity*/, responseType); List&lt;MyObject&gt; searchResult = result.getBody().getContent(); </code></pre> <p>it throws an exception </p> <pre><code>org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Can not construct instance of org.springframework.data.domain.Page, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information at [Source: java.io.PushbackInputStream@3be1e1f2; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of org.springframework.data.domain.Page, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information </code></pre> <p>Thank you in advance</p>
0debug
Why can companies charge money for their JDK Version despite the GNU GPL v2 of OpenJDK? : <p>OpenJDK is released under the GNU General Public License v2.0 with a classpath exception. If you modify software under such license, you are obliged to release it under the GPL as well. So how come e.g. IBM can charge you for their modified version of the OpenJDK, which mostly includes bugfixes and minor optimizations by changing the existing OpenJDK (which means this doesn't fall under the classpath exception)? Don't they have to release it under the GPL as well which would make it free to use?</p> <p>The only way I could explain this is, that they release the bug fixes and optimizations to OpenJDK delayed to their payed version, but I didn't find any reference stating this to be allowed.</p>
0debug
Does PHP7's PDO ext read the entire result set into memory? : <p>I have noticed since I upgraded to PHP7 that some SQL statements no longer work and instead run out of memory.</p> <p>I have this code:</p> <pre><code>$query = Yii::$app-&gt;db-&gt;createCommand('select * from tbl_title')-&gt;query(); while ($row = $reader-&gt;read()) { var_dump($row); exit(); } </code></pre> <p>And Yii2's database abstraction is just an extremely thin layer over PDO's and does not do anything extra. <code>query()</code> does nothing extra except add a line to a log file (Yii2's) for profiling and <code>reader-&gt;read()</code> just calls the PDO stream's <code>fetch()</code> function.</p> <p>But it runs out of memory quoting the size (space used) of my table, i.e. trying to allocate 385 MB of process memory:</p> <blockquote> <p>Allowed memory size of 134217728 bytes exhausted (tried to allocate 385883840 bytes)</p> </blockquote> <p>As a spanner, if I use a query whose result set fits entirely in the 128 MB limit of the PHP process works.</p> <p>So, has PHP7 changed and can I change it back?</p>
0debug
static void get_sel_entry(IPMIBmcSim *ibs, uint8_t *cmd, unsigned int cmd_len, uint8_t *rsp, unsigned int *rsp_len, unsigned int max_rsp_len) { unsigned int val; IPMI_CHECK_CMD_LEN(8); if (cmd[6]) { IPMI_CHECK_RESERVATION(2, ibs->sel.reservation); } if (ibs->sel.next_free == 0) { rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; return; } if (cmd[6] > 15) { rsp[2] = IPMI_CC_INVALID_DATA_FIELD; return; } if (cmd[7] == 0xff) { cmd[7] = 16; } else if ((cmd[7] + cmd[6]) > 16) { rsp[2] = IPMI_CC_INVALID_DATA_FIELD; return; } else { cmd[7] += cmd[6]; } val = cmd[4] | (cmd[5] << 8); if (val == 0xffff) { val = ibs->sel.next_free - 1; } else if (val >= ibs->sel.next_free) { rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; return; } if ((val + 1) == ibs->sel.next_free) { IPMI_ADD_RSP_DATA(0xff); IPMI_ADD_RSP_DATA(0xff); } else { IPMI_ADD_RSP_DATA((val + 1) & 0xff); IPMI_ADD_RSP_DATA(((val + 1) >> 8) & 0xff); } for (; cmd[6] < cmd[7]; cmd[6]++) { IPMI_ADD_RSP_DATA(ibs->sel.sel[val][cmd[6]]); } }
1threat
static void tricore_testboard_init(MachineState *machine, int board_id) { TriCoreCPU *cpu; CPUTriCoreState *env; MemoryRegion *sysmem = get_system_memory(); MemoryRegion *ext_cram = g_new(MemoryRegion, 1); MemoryRegion *ext_dram = g_new(MemoryRegion, 1); MemoryRegion *int_cram = g_new(MemoryRegion, 1); MemoryRegion *int_dram = g_new(MemoryRegion, 1); MemoryRegion *pcp_data = g_new(MemoryRegion, 1); MemoryRegion *pcp_text = g_new(MemoryRegion, 1); if (!machine->cpu_model) { machine->cpu_model = "tc1796"; } cpu = cpu_tricore_init(machine->cpu_model); if (!cpu) { error_report("Unable to find CPU definition"); exit(1); } env = &cpu->env; memory_region_init_ram(ext_cram, NULL, "powerlink_ext_c.ram", 2*1024*1024, &error_abort); vmstate_register_ram_global(ext_cram); memory_region_init_ram(ext_dram, NULL, "powerlink_ext_d.ram", 4*1024*1024, &error_abort); vmstate_register_ram_global(ext_dram); memory_region_init_ram(int_cram, NULL, "powerlink_int_c.ram", 48*1024, &error_abort); vmstate_register_ram_global(int_cram); memory_region_init_ram(int_dram, NULL, "powerlink_int_d.ram", 48*1024, &error_abort); vmstate_register_ram_global(int_dram); memory_region_init_ram(pcp_data, NULL, "powerlink_pcp_data.ram", 16*1024, &error_abort); vmstate_register_ram_global(pcp_data); memory_region_init_ram(pcp_text, NULL, "powerlink_pcp_text.ram", 32*1024, &error_abort); vmstate_register_ram_global(pcp_text); memory_region_add_subregion(sysmem, 0x80000000, ext_cram); memory_region_add_subregion(sysmem, 0xa1000000, ext_dram); memory_region_add_subregion(sysmem, 0xd4000000, int_cram); memory_region_add_subregion(sysmem, 0xd0000000, int_dram); memory_region_add_subregion(sysmem, 0xf0050000, pcp_data); memory_region_add_subregion(sysmem, 0xf0060000, pcp_text); tricoretb_binfo.ram_size = machine->ram_size; tricoretb_binfo.kernel_filename = machine->kernel_filename; if (machine->kernel_filename) { tricore_load_kernel(env); } }
1threat
static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){ MpegEncContext * const s = &h->s; int b8_stride = 2; int b4_stride = h->b_stride; int mb_xy = h->mb_xy, mb_y = s->mb_y; int mb_type_col[2]; const int16_t (*l1mv0)[2], (*l1mv1)[2]; const int8_t *l1ref0, *l1ref1; const int is_b8x8 = IS_8X8(*mb_type); unsigned int sub_mb_type= MB_TYPE_L0L1; int i8, i4; int ref[2]; int mv[2]; int list; assert(h->ref_list[1][0].f.reference & 3); await_reference_mb_row(h, &h->ref_list[1][0], s->mb_y + !!IS_INTERLACED(*mb_type)); #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16|MB_TYPE_INTRA4x4|MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM) for(list=0; list<2; list++){ int left_ref = h->ref_cache[list][scan8[0] - 1]; int top_ref = h->ref_cache[list][scan8[0] - 8]; int refc = h->ref_cache[list][scan8[0] - 8 + 4]; const int16_t *C= h->mv_cache[list][ scan8[0] - 8 + 4]; if(refc == PART_NOT_AVAILABLE){ refc = h->ref_cache[list][scan8[0] - 8 - 1]; C = h-> mv_cache[list][scan8[0] - 8 - 1]; ref[list] = FFMIN3((unsigned)left_ref, (unsigned)top_ref, (unsigned)refc); if(ref[list] >= 0){ const int16_t * const A= h->mv_cache[list][ scan8[0] - 1 ]; const int16_t * const B= h->mv_cache[list][ scan8[0] - 8 ]; int match_count= (left_ref==ref[list]) + (top_ref==ref[list]) + (refc==ref[list]); if(match_count > 1){ mv[list]= pack16to32(mid_pred(A[0], B[0], C[0]), mid_pred(A[1], B[1], C[1]) ); }else { assert(match_count==1); if(left_ref==ref[list]){ mv[list]= AV_RN32A(A); }else if(top_ref==ref[list]){ mv[list]= AV_RN32A(B); }else{ mv[list]= AV_RN32A(C); }else{ int mask= ~(MB_TYPE_L0 << (2*list)); mv[list] = 0; ref[list] = -1; if(!is_b8x8) *mb_type &= mask; sub_mb_type &= mask; if(ref[0] < 0 && ref[1] < 0){ ref[0] = ref[1] = 0; if(!is_b8x8) *mb_type |= MB_TYPE_L0L1; sub_mb_type |= MB_TYPE_L0L1; if(!(is_b8x8|mv[0]|mv[1])){ fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1); fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1); fill_rectangle(&h->mv_cache[0][scan8[0]], 4, 4, 8, 0, 4); fill_rectangle(&h->mv_cache[1][scan8[0]], 4, 4, 8, 0, 4); *mb_type= (*mb_type & ~(MB_TYPE_8x8|MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_P1L0|MB_TYPE_P1L1))|MB_TYPE_16x16|MB_TYPE_DIRECT2; return; if (IS_INTERLACED(h->ref_list[1][0].f.mb_type[mb_xy])) { if (!IS_INTERLACED(*mb_type)) { mb_y = (s->mb_y&~1) + h->col_parity; mb_xy= s->mb_x + ((s->mb_y&~1) + h->col_parity)*s->mb_stride; b8_stride = 0; }else{ mb_y += h->col_fieldoff; mb_xy += s->mb_stride*h->col_fieldoff; goto single_col; }else{ if(IS_INTERLACED(*mb_type)){ mb_y = s->mb_y&~1; mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride; mb_type_col[0] = h->ref_list[1][0].f.mb_type[mb_xy]; mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy + s->mb_stride]; b8_stride = 2+4*s->mb_stride; b4_stride *= 6; sub_mb_type |= MB_TYPE_16x16|MB_TYPE_DIRECT2; if( (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA) && (mb_type_col[1] & MB_TYPE_16x16_OR_INTRA) && !is_b8x8){ *mb_type |= MB_TYPE_16x8 |MB_TYPE_DIRECT2; }else{ *mb_type |= MB_TYPE_8x8; }else{ single_col: mb_type_col[0] = mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy]; sub_mb_type |= MB_TYPE_16x16|MB_TYPE_DIRECT2; if(!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)){ *mb_type |= MB_TYPE_16x16|MB_TYPE_DIRECT2; }else if(!is_b8x8 && (mb_type_col[0] & (MB_TYPE_16x8|MB_TYPE_8x16))){ *mb_type |= MB_TYPE_DIRECT2 | (mb_type_col[0] & (MB_TYPE_16x8|MB_TYPE_8x16)); }else{ if(!h->sps.direct_8x8_inference_flag){ sub_mb_type += (MB_TYPE_8x8-MB_TYPE_16x16); *mb_type |= MB_TYPE_8x8; await_reference_mb_row(h, &h->ref_list[1][0], mb_y); l1mv0 = &h->ref_list[1][0].f.motion_val[0][h->mb2b_xy [mb_xy]]; l1mv1 = &h->ref_list[1][0].f.motion_val[1][h->mb2b_xy [mb_xy]]; l1ref0 = &h->ref_list[1][0].f.ref_index [0][4 * mb_xy]; l1ref1 = &h->ref_list[1][0].f.ref_index [1][4 * mb_xy]; if(!b8_stride){ if(s->mb_y&1){ l1ref0 += 2; l1ref1 += 2; l1mv0 += 2*b4_stride; l1mv1 += 2*b4_stride; if(IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])){ int n=0; for(i8=0; i8<4; i8++){ int x8 = i8&1; int y8 = i8>>1; int xy8 = x8+y8*b8_stride; int xy4 = 3*x8+y8*b4_stride; int a,b; if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8])) continue; h->sub_mb_type[i8] = sub_mb_type; fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[0], 1); fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[1], 1); if(!IS_INTRA(mb_type_col[y8]) && !h->ref_list[1][0].long_ref && ( (l1ref0[xy8] == 0 && FFABS(l1mv0[xy4][0]) <= 1 && FFABS(l1mv0[xy4][1]) <= 1) || (l1ref0[xy8] < 0 && l1ref1[xy8] == 0 && FFABS(l1mv1[xy4][0]) <= 1 && FFABS(l1mv1[xy4][1]) <= 1))){ a=b=0; if(ref[0] > 0) a= mv[0]; if(ref[1] > 0) b= mv[1]; n++; }else{ a= mv[0]; b= mv[1]; fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, a, 4); fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, b, 4); if(!is_b8x8 && !(n&3)) *mb_type= (*mb_type & ~(MB_TYPE_8x8|MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_P1L0|MB_TYPE_P1L1))|MB_TYPE_16x16|MB_TYPE_DIRECT2; }else if(IS_16X16(*mb_type)){ int a,b; fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1); fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1); if(!IS_INTRA(mb_type_col[0]) && !h->ref_list[1][0].long_ref && ( (l1ref0[0] == 0 && FFABS(l1mv0[0][0]) <= 1 && FFABS(l1mv0[0][1]) <= 1) || (l1ref0[0] < 0 && l1ref1[0] == 0 && FFABS(l1mv1[0][0]) <= 1 && FFABS(l1mv1[0][1]) <= 1 && h->x264_build>33U))){ a=b=0; if(ref[0] > 0) a= mv[0]; if(ref[1] > 0) b= mv[1]; }else{ a= mv[0]; b= mv[1]; fill_rectangle(&h->mv_cache[0][scan8[0]], 4, 4, 8, a, 4); fill_rectangle(&h->mv_cache[1][scan8[0]], 4, 4, 8, b, 4); }else{ int n=0; for(i8=0; i8<4; i8++){ const int x8 = i8&1; const int y8 = i8>>1; if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8])) continue; h->sub_mb_type[i8] = sub_mb_type; fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, mv[0], 4); fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, mv[1], 4); fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[0], 1); fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[1], 1); assert(b8_stride==2); if(!IS_INTRA(mb_type_col[0]) && !h->ref_list[1][0].long_ref && ( l1ref0[i8] == 0 || (l1ref0[i8] < 0 && l1ref1[i8] == 0 && h->x264_build>33U))){ const int16_t (*l1mv)[2]= l1ref0[i8] == 0 ? l1mv0 : l1mv1; if(IS_SUB_8X8(sub_mb_type)){ const int16_t *mv_col = l1mv[x8*3 + y8*3*b4_stride]; if(FFABS(mv_col[0]) <= 1 && FFABS(mv_col[1]) <= 1){ if(ref[0] == 0) fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4); if(ref[1] == 0) fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4); n+=4; }else{ int m=0; for(i4=0; i4<4; i4++){ const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*b4_stride]; if(FFABS(mv_col[0]) <= 1 && FFABS(mv_col[1]) <= 1){ if(ref[0] == 0) AV_ZERO32(h->mv_cache[0][scan8[i8*4+i4]]); if(ref[1] == 0) AV_ZERO32(h->mv_cache[1][scan8[i8*4+i4]]); m++; if(!(m&3)) h->sub_mb_type[i8]+= MB_TYPE_16x16 - MB_TYPE_8x8; n+=m; if(!is_b8x8 && !(n&15)) *mb_type= (*mb_type & ~(MB_TYPE_8x8|MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_P1L0|MB_TYPE_P1L1))|MB_TYPE_16x16|MB_TYPE_DIRECT2;
1threat
static void scsi_cmd_xfer_mode(SCSICommand *cmd) { if (!cmd->xfer) { cmd->mode = SCSI_XFER_NONE; return; } switch (cmd->buf[0]) { case WRITE_6: case WRITE_10: case WRITE_VERIFY_10: case WRITE_12: case WRITE_VERIFY_12: case WRITE_16: case WRITE_VERIFY_16: case COPY: case COPY_VERIFY: case COMPARE: case CHANGE_DEFINITION: case LOG_SELECT: case MODE_SELECT: case MODE_SELECT_10: case SEND_DIAGNOSTIC: case WRITE_BUFFER: case FORMAT_UNIT: case REASSIGN_BLOCKS: case SEARCH_EQUAL: case SEARCH_HIGH: case SEARCH_LOW: case UPDATE_BLOCK: case WRITE_LONG_10: case WRITE_SAME_10: case WRITE_SAME_16: case UNMAP: case SEARCH_HIGH_12: case SEARCH_EQUAL_12: case SEARCH_LOW_12: case MEDIUM_SCAN: case SEND_VOLUME_TAG: case SEND_CUE_SHEET: case SEND_DVD_STRUCTURE: case PERSISTENT_RESERVE_OUT: case MAINTENANCE_OUT: cmd->mode = SCSI_XFER_TO_DEV; break; default: cmd->mode = SCSI_XFER_FROM_DEV; break; } }
1threat
static int img_info(int argc, char **argv) { int c; OutputFormat output_format = OFORMAT_HUMAN; bool chain = false; const char *filename, *fmt, *output; ImageInfoList *list; bool image_opts = false; fmt = NULL; output = NULL; for(;;) { int option_index = 0; static const struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"format", required_argument, 0, 'f'}, {"output", required_argument, 0, OPTION_OUTPUT}, {"backing-chain", no_argument, 0, OPTION_BACKING_CHAIN}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "f:h", long_options, &option_index); if (c == -1) { break; } switch(c) { case '?': case 'h': help(); break; case 'f': fmt = optarg; break; case OPTION_OUTPUT: output = optarg; break; case OPTION_BACKING_CHAIN: chain = true; break; case OPTION_OBJECT: { QemuOpts *opts; opts = qemu_opts_parse_noisily(&qemu_object_opts, optarg, true); if (!opts) { return 1; } } break; case OPTION_IMAGE_OPTS: image_opts = true; break; } } if (optind != argc - 1) { error_exit("Expecting one image file name"); } filename = argv[optind++]; if (output && !strcmp(output, "json")) { output_format = OFORMAT_JSON; } else if (output && !strcmp(output, "human")) { output_format = OFORMAT_HUMAN; } else if (output) { error_report("--output must be used with human or json as argument."); return 1; } if (qemu_opts_foreach(&qemu_object_opts, user_creatable_add_opts_foreach, NULL, NULL)) { return 1; } list = collect_image_info_list(image_opts, filename, fmt, chain); if (!list) { return 1; } switch (output_format) { case OFORMAT_HUMAN: dump_human_image_info_list(list); break; case OFORMAT_JSON: if (chain) { dump_json_image_info_list(list); } else { dump_json_image_info(list->value); } break; } qapi_free_ImageInfoList(list); return 0; }
1threat
void OPPROTO op_srl_T0_T1 (void) { T0 = T0 >> T1; RETURN(); }
1threat
.finish() is not working inside a nested if statement : <p>For some reason, I cant use .finish() to end my previous activity inside a nested if statement.</p> <pre><code>if (id == R.id.nav_menu) { MenuFragment menuFragment = MenuFragment.newInstance("", ""); FragmentManager manager = getSupportFragmentManager(); manager.beginTransaction().replace( R.id.layout_for_fragment, menuFragment ).commit(); } else if (id == R.id.nav_report) { if(status == 1){ SharedPrefManager.getInstance(getApplicationContext()).logout(); getApplicationContext().finish(); startActivity(new Intent(getApplicationContext(), LoginActivity.class)); } } </code></pre>
0debug
How do you convert a two dimensional list into a list for each row : A=[[1,3,5,7],[2,5,8,12,16],[4,7,8,12]]. I would like the result to be [1,3,5,7][2,5,8,12,16][4,7,8,12]
0debug
static void test_visitor_in_alternate(TestInputVisitorData *data, const void *unused) { Visitor *v; Error *err = NULL; UserDefAlternate *tmp; v = visitor_input_test_init(data, "42"); visit_type_UserDefAlternate(v, &tmp, NULL, &error_abort); g_assert_cmpint(tmp->type, ==, USER_DEF_ALTERNATE_KIND_I); g_assert_cmpint(tmp->u.i, ==, 42); qapi_free_UserDefAlternate(tmp); v = visitor_input_test_init(data, "'string'"); visit_type_UserDefAlternate(v, &tmp, NULL, &error_abort); g_assert_cmpint(tmp->type, ==, USER_DEF_ALTERNATE_KIND_S); g_assert_cmpstr(tmp->u.s, ==, "string"); qapi_free_UserDefAlternate(tmp); v = visitor_input_test_init(data, "false"); visit_type_UserDefAlternate(v, &tmp, NULL, &err); g_assert(err); error_free(err); err = NULL; qapi_free_UserDefAlternate(tmp); }
1threat
int net_client_init(const char *device, const char *p) { static const char * const fd_params[] = { "vlan", "name", "fd", NULL }; char buf[1024]; int vlan_id, ret; VLANState *vlan; char *name = NULL; vlan_id = 0; if (get_param_value(buf, sizeof(buf), "vlan", p)) { vlan_id = strtol(buf, NULL, 0); } vlan = qemu_find_vlan(vlan_id); if (get_param_value(buf, sizeof(buf), "name", p)) { name = strdup(buf); } if (!strcmp(device, "nic")) { static const char * const nic_params[] = { "vlan", "name", "macaddr", "model", NULL }; NICInfo *nd; uint8_t *macaddr; int idx = nic_get_free_idx(); if (check_params(nic_params, p) < 0) { fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", buf, p); return -1; } if (idx == -1 || nb_nics >= MAX_NICS) { fprintf(stderr, "Too Many NICs\n"); ret = -1; goto out; } nd = &nd_table[idx]; macaddr = nd->macaddr; macaddr[0] = 0x52; macaddr[1] = 0x54; macaddr[2] = 0x00; macaddr[3] = 0x12; macaddr[4] = 0x34; macaddr[5] = 0x56 + idx; if (get_param_value(buf, sizeof(buf), "macaddr", p)) { if (parse_macaddr(macaddr, buf) < 0) { fprintf(stderr, "invalid syntax for ethernet address\n"); ret = -1; goto out; } } if (get_param_value(buf, sizeof(buf), "model", p)) { nd->model = strdup(buf); } nd->vlan = vlan; nd->name = name; nd->used = 1; name = NULL; nb_nics++; vlan->nb_guest_devs++; ret = idx; } else if (!strcmp(device, "none")) { if (*p != '\0') { fprintf(stderr, "qemu: 'none' takes no parameters\n"); return -1; } ret = 0; } else #ifdef CONFIG_SLIRP if (!strcmp(device, "user")) { static const char * const slirp_params[] = { "vlan", "name", "hostname", "restrict", "ip", NULL }; if (check_params(slirp_params, p) < 0) { fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", buf, p); return -1; } if (get_param_value(buf, sizeof(buf), "hostname", p)) { pstrcpy(slirp_hostname, sizeof(slirp_hostname), buf); } if (get_param_value(buf, sizeof(buf), "restrict", p)) { slirp_restrict = (buf[0] == 'y') ? 1 : 0; } if (get_param_value(buf, sizeof(buf), "ip", p)) { slirp_ip = strdup(buf); } vlan->nb_host_devs++; ret = net_slirp_init(vlan, device, name); } else if (!strcmp(device, "channel")) { long port; char name[20], *devname; struct VMChannel *vmc; port = strtol(p, &devname, 10); devname++; if (port < 1 || port > 65535) { fprintf(stderr, "vmchannel wrong port number\n"); ret = -1; goto out; } vmc = malloc(sizeof(struct VMChannel)); snprintf(name, 20, "vmchannel%ld", port); vmc->hd = qemu_chr_open(name, devname, NULL); if (!vmc->hd) { fprintf(stderr, "qemu: could not open vmchannel device" "'%s'\n", devname); ret = -1; goto out; } vmc->port = port; slirp_add_exec(3, vmc->hd, 4, port); qemu_chr_add_handlers(vmc->hd, vmchannel_can_read, vmchannel_read, NULL, vmc); ret = 0; } else #endif #ifdef _WIN32 if (!strcmp(device, "tap")) { static const char * const tap_params[] = { "vlan", "name", "ifname", NULL }; char ifname[64]; if (check_params(tap_params, p) < 0) { fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", buf, p); return -1; } if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) { fprintf(stderr, "tap: no interface name\n"); ret = -1; goto out; } vlan->nb_host_devs++; ret = tap_win32_init(vlan, device, name, ifname); } else #elif defined (_AIX) #else if (!strcmp(device, "tap")) { char ifname[64]; char setup_script[1024], down_script[1024]; int fd; vlan->nb_host_devs++; if (get_param_value(buf, sizeof(buf), "fd", p) > 0) { if (check_params(fd_params, p) < 0) { fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", buf, p); return -1; } fd = strtol(buf, NULL, 0); fcntl(fd, F_SETFL, O_NONBLOCK); net_tap_fd_init(vlan, device, name, fd); ret = 0; } else { static const char * const tap_params[] = { "vlan", "name", "ifname", "script", "downscript", NULL }; if (check_params(tap_params, p) < 0) { fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", buf, p); return -1; } if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) { ifname[0] = '\0'; } if (get_param_value(setup_script, sizeof(setup_script), "script", p) == 0) { pstrcpy(setup_script, sizeof(setup_script), DEFAULT_NETWORK_SCRIPT); } if (get_param_value(down_script, sizeof(down_script), "downscript", p) == 0) { pstrcpy(down_script, sizeof(down_script), DEFAULT_NETWORK_DOWN_SCRIPT); } ret = net_tap_init(vlan, device, name, ifname, setup_script, down_script); } } else #endif if (!strcmp(device, "socket")) { if (get_param_value(buf, sizeof(buf), "fd", p) > 0) { int fd; if (check_params(fd_params, p) < 0) { fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", buf, p); return -1; } fd = strtol(buf, NULL, 0); ret = -1; if (net_socket_fd_init(vlan, device, name, fd, 1)) ret = 0; } else if (get_param_value(buf, sizeof(buf), "listen", p) > 0) { static const char * const listen_params[] = { "vlan", "name", "listen", NULL }; if (check_params(listen_params, p) < 0) { fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", buf, p); return -1; } ret = net_socket_listen_init(vlan, device, name, buf); } else if (get_param_value(buf, sizeof(buf), "connect", p) > 0) { static const char * const connect_params[] = { "vlan", "name", "connect", NULL }; if (check_params(connect_params, p) < 0) { fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", buf, p); return -1; } ret = net_socket_connect_init(vlan, device, name, buf); } else if (get_param_value(buf, sizeof(buf), "mcast", p) > 0) { static const char * const mcast_params[] = { "vlan", "name", "mcast", NULL }; if (check_params(mcast_params, p) < 0) { fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", buf, p); return -1; } ret = net_socket_mcast_init(vlan, device, name, buf); } else { fprintf(stderr, "Unknown socket options: %s\n", p); ret = -1; goto out; } vlan->nb_host_devs++; } else #ifdef CONFIG_VDE if (!strcmp(device, "vde")) { static const char * const vde_params[] = { "vlan", "name", "sock", "port", "group", "mode", NULL }; char vde_sock[1024], vde_group[512]; int vde_port, vde_mode; if (check_params(vde_params, p) < 0) { fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", buf, p); return -1; } vlan->nb_host_devs++; if (get_param_value(vde_sock, sizeof(vde_sock), "sock", p) <= 0) { vde_sock[0] = '\0'; } if (get_param_value(buf, sizeof(buf), "port", p) > 0) { vde_port = strtol(buf, NULL, 10); } else { vde_port = 0; } if (get_param_value(vde_group, sizeof(vde_group), "group", p) <= 0) { vde_group[0] = '\0'; } if (get_param_value(buf, sizeof(buf), "mode", p) > 0) { vde_mode = strtol(buf, NULL, 8); } else { vde_mode = 0700; } ret = net_vde_init(vlan, device, name, vde_sock, vde_port, vde_group, vde_mode); } else #endif if (!strcmp(device, "dump")) { int len = 65536; if (get_param_value(buf, sizeof(buf), "len", p) > 0) { len = strtol(buf, NULL, 0); } if (!get_param_value(buf, sizeof(buf), "file", p)) { snprintf(buf, sizeof(buf), "qemu-vlan%d.pcap", vlan_id); } ret = net_dump_init(vlan, device, name, buf, len); } else { fprintf(stderr, "Unknown network device: %s\n", device); ret = -1; goto out; } if (ret < 0) { fprintf(stderr, "Could not initialize device '%s'\n", device); } out: if (name) free(name); return ret; }
1threat
static int raw_open_common(BlockDriverState *bs, QDict *options, int bdrv_flags, int open_flags, Error **errp) { BDRVRawState *s = bs->opaque; QemuOpts *opts; Error *local_err = NULL; const char *filename = NULL; BlockdevAioOptions aio, aio_default; int fd, ret; struct stat st; OnOffAuto locking; opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; } filename = qemu_opt_get(opts, "filename"); ret = raw_normalize_devicepath(&filename); if (ret != 0) { error_setg_errno(errp, -ret, "Could not normalize device path"); goto fail; } aio_default = (bdrv_flags & BDRV_O_NATIVE_AIO) ? BLOCKDEV_AIO_OPTIONS_NATIVE : BLOCKDEV_AIO_OPTIONS_THREADS; aio = qapi_enum_parse(BlockdevAioOptions_lookup, qemu_opt_get(opts, "aio"), BLOCKDEV_AIO_OPTIONS__MAX, aio_default, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; } s->use_linux_aio = (aio == BLOCKDEV_AIO_OPTIONS_NATIVE); locking = qapi_enum_parse(OnOffAuto_lookup, qemu_opt_get(opts, "locking"), ON_OFF_AUTO__MAX, ON_OFF_AUTO_AUTO, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; } switch (locking) { case ON_OFF_AUTO_ON: s->use_lock = true; #ifndef F_OFD_SETLK fprintf(stderr, "File lock requested but OFD locking syscall is unavailable, " "falling back to POSIX file locks.\n" "Due to the implementation, locks can be lost unexpectedly.\n"); #endif break; case ON_OFF_AUTO_OFF: s->use_lock = false; break; case ON_OFF_AUTO_AUTO: #ifdef F_OFD_SETLK s->use_lock = true; #else s->use_lock = false; #endif break; default: abort(); } s->open_flags = open_flags; raw_parse_flags(bdrv_flags, &s->open_flags); s->fd = -1; fd = qemu_open(filename, s->open_flags, 0644); if (fd < 0) { ret = -errno; error_setg_errno(errp, errno, "Could not open '%s'", filename); if (ret == -EROFS) { ret = -EACCES; } goto fail; } s->fd = fd; s->lock_fd = -1; if (s->use_lock) { fd = qemu_open(filename, s->open_flags); if (fd < 0) { ret = -errno; error_setg_errno(errp, errno, "Could not open '%s' for locking", filename); qemu_close(s->fd); goto fail; } s->lock_fd = fd; } s->perm = 0; s->shared_perm = BLK_PERM_ALL; #ifdef CONFIG_LINUX_AIO if (s->use_linux_aio && !(s->open_flags & O_DIRECT)) { error_setg(errp, "aio=native was specified, but it requires " "cache.direct=on, which was not specified."); ret = -EINVAL; goto fail; } #else if (s->use_linux_aio) { error_setg(errp, "aio=native was specified, but is not supported " "in this build."); ret = -EINVAL; goto fail; } #endif s->has_discard = true; s->has_write_zeroes = true; bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP; if ((bs->open_flags & BDRV_O_NOCACHE) != 0) { s->needs_alignment = true; } if (fstat(s->fd, &st) < 0) { ret = -errno; error_setg_errno(errp, errno, "Could not stat file"); goto fail; } if (S_ISREG(st.st_mode)) { s->discard_zeroes = true; s->has_fallocate = true; } if (S_ISBLK(st.st_mode)) { #ifdef BLKDISCARDZEROES unsigned int arg; if (ioctl(s->fd, BLKDISCARDZEROES, &arg) == 0 && arg) { s->discard_zeroes = true; } #endif #ifdef __linux__ if (!(bs->open_flags & BDRV_O_NOCACHE)) { s->discard_zeroes = false; s->has_write_zeroes = false; } #endif } #ifdef __FreeBSD__ if (S_ISCHR(st.st_mode)) { s->needs_alignment = true; } #endif #ifdef CONFIG_XFS if (platform_test_xfs_fd(s->fd)) { s->is_xfs = true; } #endif ret = 0; fail: if (filename && (bdrv_flags & BDRV_O_TEMPORARY)) { unlink(filename); } qemu_opts_del(opts); return ret; }
1threat
static int pxb_dev_initfn(PCIDevice *dev) { PXBDev *pxb = PXB_DEV(dev); DeviceState *ds, *bds; PCIBus *bus; const char *dev_name = NULL; if (pxb->numa_node != NUMA_NODE_UNASSIGNED && pxb->numa_node >= nb_numa_nodes) { error_report("Illegal numa node %d.", pxb->numa_node); return -EINVAL; } if (dev->qdev.id && *dev->qdev.id) { dev_name = dev->qdev.id; } ds = qdev_create(NULL, TYPE_PXB_HOST); bus = pci_bus_new(ds, "pxb-internal", NULL, NULL, 0, TYPE_PXB_BUS); bus->parent_dev = dev; bus->address_space_mem = dev->bus->address_space_mem; bus->address_space_io = dev->bus->address_space_io; bus->map_irq = pxb_map_irq_fn; bds = qdev_create(BUS(bus), "pci-bridge"); bds->id = dev_name; qdev_prop_set_uint8(bds, PCI_BRIDGE_DEV_PROP_CHASSIS_NR, pxb->bus_nr); qdev_prop_set_bit(bds, PCI_BRIDGE_DEV_PROP_SHPC, false); PCI_HOST_BRIDGE(ds)->bus = bus; if (pxb_register_bus(dev, bus)) { return -EINVAL; } qdev_init_nofail(ds); qdev_init_nofail(bds); pci_word_test_and_set_mask(dev->config + PCI_STATUS, PCI_STATUS_66MHZ | PCI_STATUS_FAST_BACK); pci_config_set_class(dev->config, PCI_CLASS_BRIDGE_HOST); pxb_dev_list = g_list_insert_sorted(pxb_dev_list, pxb, pxb_compare); return 0; }
1threat
copying same file to other folder multiple times : <p>i using this script to copying files to other folder when i clicked submit button</p> <pre><code>&lt;?php if (isset($_POST['upload']) &amp;&amp; isset($_POST['datae'])) { copy('../print/'.$_POST['datae'], '../Upload/'.$_POST['datae']); echo "&lt;meta http-equiv='refresh' content='1'&gt;"; } ?&gt; </code></pre> <p>and now im wondering what if i choose same filename and submitted twice or more. normally the filename i've already choose will copy and overwrite the same file that already stored in there. <br> <br> but what i want is whenever i submitted twice or more the file that already in destination folder, it will not replace or overwrite but it will duplicating same file and just different in file name like</p> <pre><code>//example in my folder img_7878.JPG img_7878_copy1.JPG img_7878_copy2.JPG </code></pre> <p>maybe i could get help from here.</p>
0debug
static void m5208_timer_write(void *opaque, target_phys_addr_t offset, uint64_t value, unsigned size) { m5208_timer_state *s = (m5208_timer_state *)opaque; int prescale; int limit; switch (offset) { case 0: if (value & PCSR_PIF) { s->pcsr &= ~PCSR_PIF; value &= ~PCSR_PIF; } if (((s->pcsr ^ value) & ~PCSR_PIE) == 0) { s->pcsr = value; m5208_timer_update(s); return; } if (s->pcsr & PCSR_EN) ptimer_stop(s->timer); s->pcsr = value; prescale = 1 << ((s->pcsr & PCSR_PRE_MASK) >> PCSR_PRE_SHIFT); ptimer_set_freq(s->timer, (SYS_FREQ / 2) / prescale); if (s->pcsr & PCSR_RLD) limit = s->pmr; else limit = 0xffff; ptimer_set_limit(s->timer, limit, 0); if (s->pcsr & PCSR_EN) ptimer_run(s->timer, 0); break; case 2: s->pmr = value; s->pcsr &= ~PCSR_PIF; if ((s->pcsr & PCSR_RLD) == 0) { if (s->pcsr & PCSR_OVW) ptimer_set_count(s->timer, value); } else { ptimer_set_limit(s->timer, value, s->pcsr & PCSR_OVW); } break; case 4: break; default: hw_error("m5208_timer_write: Bad offset 0x%x\n", (int)offset); break; } m5208_timer_update(s); }
1threat
void msix_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int len) { unsigned enable_pos = dev->msix_cap + MSIX_CONTROL_OFFSET; if (addr + len <= enable_pos || addr > enable_pos) return; if (msix_enabled(dev)) qemu_set_irq(dev->irq[0], 0); }
1threat
World *world_alloc(Rocker *r, size_t sizeof_private, enum rocker_world_type type, WorldOps *ops) { World *w = g_malloc0(sizeof(World) + sizeof_private); if (w) { w->r = r; w->type = type; w->ops = ops; if (w->ops->init) { w->ops->init(w); } } return w; }
1threat
Why the JSON bool data pass to the Django backend it turned into str? : The butt joint of `JSON data` and Python `request.params`: http://localhost:8000/api/physicalservertask/list_for_home_workpanel/?has_physicalserver=false you see I add the `has_physicalserver` param in the `url`, we know in the JSON, the Bool is `true` and `false`. but in my Django API I get it, it is `str`. has_physicalserver_list = query_params.pop('has_physicalserver') has_physicalserver = has_physicalserver_list[0] if (isinstance(has_physicalserver_list, list) and len(has_physicalserver_list) > 0) else '' <kbd>[![enter image description here][1]][1]</kbd> [1]: https://i.stack.imgur.com/wY8Lm.jpg
0debug
static void av_update_stream_timings(AVFormatContext *ic) { int64_t start_time, start_time1, end_time, end_time1; int64_t duration, duration1; int i; AVStream *st; start_time = INT64_MAX; end_time = INT64_MIN; duration = INT64_MIN; for(i = 0;i < ic->nb_streams; i++) { st = ic->streams[i]; if (st->start_time != AV_NOPTS_VALUE) { start_time1= av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q); if (start_time1 < start_time) start_time = start_time1; if (st->duration != AV_NOPTS_VALUE) { end_time1 = start_time1 + av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q); if (end_time1 > end_time) end_time = end_time1; } } if (st->duration != AV_NOPTS_VALUE) { duration1 = av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q); if (duration1 > duration) duration = duration1; } } if (start_time != INT64_MAX) { ic->start_time = start_time; if (end_time != INT64_MIN) { if (end_time - start_time > duration) duration = end_time - start_time; } } if (duration != INT64_MIN) { ic->duration = duration; if (ic->file_size > 0) { ic->bit_rate = (double)ic->file_size * 8.0 * AV_TIME_BASE / (double)ic->duration; } } }
1threat
Javascript return illegal statement : <pre><code>if(choice1 === choice2) { return"The result is a tie!"; </code></pre> <p>}</p> <p>else if (choice1 === "rock") {</p> <pre><code>if (choice2 === "scissors") { return "rock wins"; } else { return "paper wins"; } </code></pre> <p>}</p> <p>please help mee</p>
0debug
Problem with allocating memory in c++ and pointers : <p>So I am learning dynamic memory allocation nowadays and stuck in a problem(if it is).</p> <pre><code>int *p; p=(int*)calloc(5,sizeof(int)); </code></pre> <p>According to my intution p should point to memory location of 5*4 = 20byte and these 20bytes only belong to p. for *(p+0), <em>(p+1)....</em>(p+4) everything is fine. but when i do *(p+5) or *(p+12)=100; This should give me an error as i have exceeded the memory block allocated to *p.</p> <p>The confusion is : Why we need to even allocate memory when we can just do like :</p> <pre><code>int *p int s[]={1,2,3} p=&amp;s[0] //and then make an array of length &gt; s *(p+4)=....something </code></pre> <p>In every article i am seeing they are allocating memory before assigning . what's the need. I hope u understand my confusion.</p>
0debug
static void notdirty_mem_writew(void *opaque, target_phys_addr_t ram_addr, uint32_t val) { int dirty_flags; dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS]; if (!(dirty_flags & CODE_DIRTY_FLAG)) { #if !defined(CONFIG_USER_ONLY) tb_invalidate_phys_page_fast(ram_addr, 2); dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS]; #endif } stw_p(qemu_get_ram_ptr(ram_addr), val); #ifdef CONFIG_KQEMU if (cpu_single_env->kqemu_enabled && (dirty_flags & KQEMU_MODIFY_PAGE_MASK) != KQEMU_MODIFY_PAGE_MASK) kqemu_modify_page(cpu_single_env, ram_addr); #endif dirty_flags |= (0xff & ~CODE_DIRTY_FLAG); phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS] = dirty_flags; if (dirty_flags == 0xff) tlb_set_dirty(cpu_single_env, cpu_single_env->mem_io_vaddr); }
1threat
error in cast variable : i get an error when i want to cast a query:this is the code of the query. var query = ( from article in db.V_CLIENT_PRIX where article.CLIENT == Current_Client_Id select new { ID = article.ID, ARTICLE = article.Article, REFERENCE = article.Reference, REMISE = article.Remise, PRIXVHT = article.PrixVHT, CLIENT = article.CLIENT, }); and i cast it like that: ConventionList articlelistconvention = new ConventionList(); articlelistconvention = (ConventionList)query; and this is the code of my model:ConventionList public class Commandelist { public string ARTICLE { get; set; } public string CIN { get; set; } public decimal STOCK { get; set; } public string REFERENCE { get; set; } public decimal PRIXVHT { get; set; } public string IMAGE { get; set; } public double QUANTITE { get; set; } } Can someone help me how to fix it and thank you
0debug
static inline void decode(DisasContext *dc) { uint32_t ir; int i; if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP))) { tcg_gen_debug_insn_start(dc->pc); } dc->ir = ir = ldl_code(dc->pc); LOG_DIS("%8.8x\t", dc->ir); if (dc->ir) { dc->nr_nops = 0; } else { LOG_DIS("nr_nops=%d\t", dc->nr_nops); dc->nr_nops++; if (dc->nr_nops > 4) { cpu_abort(dc->env, "fetching nop sequence\n"); } } dc->opcode = EXTRACT_FIELD(ir, 26, 31); dc->imm5 = EXTRACT_FIELD(ir, 0, 4); dc->imm16 = EXTRACT_FIELD(ir, 0, 15); dc->imm26 = EXTRACT_FIELD(ir, 0, 25); dc->csr = EXTRACT_FIELD(ir, 21, 25); dc->r0 = EXTRACT_FIELD(ir, 21, 25); dc->r1 = EXTRACT_FIELD(ir, 16, 20); dc->r2 = EXTRACT_FIELD(ir, 11, 15); if (ir & (1 << 31)) { dc->format = OP_FMT_RR; } else { dc->format = OP_FMT_RI; } for (i = 0; i < ARRAY_SIZE(decinfo); i++) { if ((dc->opcode & decinfo[i].mask) == decinfo[i].bits) { decinfo[i].dec(dc); return; } } cpu_abort(dc->env, "unknown opcode 0x%02x\n", dc->opcode); }
1threat
Compare two ArrayList<String>(); and delete the different elements : <p>i wanted to compare two ArrayList arrays and delete the different elements. </p> <pre><code>List&lt;String&gt; al1 = new ArrayList&lt;String&gt;(); List&lt;String&gt; al2 = new ArrayList&lt;String&gt;(); al1.add("222"); al2.add("222"); al2.add("333"); System.out.println(al1); System.out.println(al2); </code></pre> <p>The output of println is:</p> <pre><code>[222] [222, 333] </code></pre> <p>I want to remove the 333 in the second array because it is not in the first one how can i achieve this ? </p> <p>Thanks in advance.</p>
0debug
how to use a friend function in cpp file? : > i have a header file and cpp file .. in the h file i declared an AA > class and added some private parameters and declared a friend function > but when i try to access the private parametrs an the cpp file a get > an error "within this context" and i get also in the heder file this error with the private parametrs : 'std::__cxx11::string x::y::ZZZ::ZZZ_name' is private #include <iostream> #include <string> using std::string; namespace X{ namespace Y{ class ZZZ{ private: string ZZZ_name; public: friend std::ostream & operator<<(std::ostream &output, const ZZZ &zzz); }; std::ostream &operator<<(std::ostream &output, const ZZZ &zzz; }} // ZZZ.cpp //and this is what i have in cpp file : #include "ZZZ.h" #include <stdbool.h> using namespace x::y; using std::cout; std::ostream& operator<<(std::ostream& output, const ZZZ& zzz){ output << zzz.ZZZ_name << "." ; return output; }
0debug
AttributeError: 'NoneType' object has no attribute 'title' : <p>Tried to run this code, but error says that I have made a mistake with .title . How can I fix this? (Please note that I am still an amateur in the world of Python, and am open to any suggestions which could improve my code. However, chances are that I will not understand it unless it is explained, if it is something new e.g. you could use __________ instead of _________ .)</p> <p>Here's my code:</p> <pre><code>import time import sys print("Welcome to my quiz") time.sleep(2) input('Press enter to continue') score = int(0) failed = int(0) def points(): print("Correct! Well done!") global score score = score + 1 def fail(): print("Oh no, that is incorrect") global failed failed = failed + 1 def printtotal(): global score global failed print("You have ",score,"points, and ",failed,"/3 lives used.") if failed == 5: sys.exit('Program terminated.') print('You will have 5 seconds to answer each question \nIf you fail 5 times or more, the program will exit') time.sleep(3) print('Good luck!') time.sleep(2) q1 = print(input("What is the capital of England?")).title if q1 == 'London': points() else: fail() printtotal() q2 = print(input("Who is the prime minister's wife?")).title if q2 == 'Samantha' or 'Samantha Cameron': points() else: fail() printtotal() print('How would you say \'I came, I saw, I conquered\' in latin?') print('a) veni, vidi, vici') print('b) veni, vedi, vici') print('c) vini, vedi, vici') q3 = print(input('Type the letter here:')) if q3 == 'a)' or 'a': points() else: fail() printtotal() </code></pre> <p>If I try to execute this code, this is the error I get:</p> <pre><code>Traceback (most recent call last): File "/root/Desktop/Python_Stuff/quiz.py", line 34, in &lt;module&gt; q1 = print(input("What is the capital of England?")).title AttributeError: 'NoneType' object has no attribute 'title' </code></pre> <p>If anyone happens to spot anymore errors, please do tell me. How can I fix this error?</p>
0debug
What is wrong with this code with interface and abstract class? : <pre><code>interface inf1{ //interface definition } abstract class abst{ //abstract definition } public class cls : inf1,abst { } </code></pre> <p>I am getting compilation error, But if i interchange the interface and abstarct class it is compiling.</p>
0debug
static void test_qemu_strtol_max(void) { const char *str = g_strdup_printf("%ld", LONG_MAX); char f = 'X'; const char *endptr = &f; long res = 999; int err; err = qemu_strtol(str, &endptr, 0, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, LONG_MAX); g_assert(endptr == str + strlen(str)); }
1threat
int ide_init_drive(IDEState *s, BlockDriverState *bs, const char *version, const char *serial) { int cylinders, heads, secs; uint64_t nb_sectors; s->bs = bs; bdrv_get_geometry(bs, &nb_sectors); bdrv_guess_geometry(bs, &cylinders, &heads, &secs); if (cylinders < 1 || cylinders > 16383) { error_report("cyls must be between 1 and 16383"); if (heads < 1 || heads > 16) { error_report("heads must be between 1 and 16"); if (secs < 1 || secs > 63) { error_report("secs must be between 1 and 63"); s->cylinders = cylinders; s->heads = heads; s->sectors = secs; s->nb_sectors = nb_sectors; s->smart_enabled = 1; s->smart_autosave = 1; s->smart_errors = 0; s->smart_selftest_count = 0; if (bdrv_get_type_hint(bs) == BDRV_TYPE_CDROM) { s->drive_kind = IDE_CD; bdrv_set_change_cb(bs, cdrom_change_cb, s); } else { if (bdrv_is_read_only(bs)) { error_report("Can't use a read-only drive"); if (serial) { strncpy(s->drive_serial_str, serial, sizeof(s->drive_serial_str)); } else { snprintf(s->drive_serial_str, sizeof(s->drive_serial_str), "QM%05d", s->drive_serial); if (version) { pstrcpy(s->version, sizeof(s->version), version); } else { pstrcpy(s->version, sizeof(s->version), QEMU_VERSION); ide_reset(s); bdrv_set_removable(bs, s->drive_kind == IDE_CD); return 0;
1threat
excell reference repitition at regular intervals; : ''' I have two excel sheets(1,2) in a single file, I want the data in sheet 2 is as follows a1(1) a2(2) a3(3) I want to reference this data in sheet1 as follows A2=sheet2!A1, A5=sheet2!A2 , A8=sheet2!A3 and so on, how do I achieve this? tried entering the sequence 4 times and dragging the formula untill the end. instead of maintaining the sequence, this is what happens; entered by me; ''' A2=sheet2!A1 A5=sheet2!A2 A8=sheet2!A3 "on dragging excel automatically enters;" A11=sheet2!A10 A14=sheet2!A11 A17=sheet2!A12 A20=sheet2!A19 A23=sheet2!A20 A26=sheet2!A21 what i want; i enter; A2=sheet2!A1 A5=sheet2!A2 A8=sheet2!A3 excel automatically enters these formulas ; A11=sheet2!A4 A14=sheet2!A5 A17=sheet2!A6 A20=sheet2!A7 A23=sheet2!A8 A26=sheet2!A9
0debug
Call to a member function move() on string : <p>Kindly assist me with the code below. I keep getting this error "Call to a member function move() on string" when am trying to upload multiple images.Thanks in advance.</p> <p>This is the code for my view page</p> <pre><code> {!!Form::open(['method'=&gt;'POST','action'=&gt;'ClientController@uploadLand','files'=&gt;true])!!} {{ csrf_field() }} &lt;div class="admin-form"&gt; &lt;div class="row"&gt; &lt;div id="maindiv"&gt; &lt;div id="formdiv"&gt; &lt;div id="filediv"&gt;&lt;input name="file[]" type="file" id="file"/&gt;&lt;/div&gt;&lt;br/&gt; &lt;input type="button" id="add_more" class="upload" value="Add More Files"/&gt; &lt;!-- &lt;input type="submit" value="Upload File" name="submit" id="upload" class="upload"/&gt; --&gt; &lt;br/&gt; &lt;br/&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; {!!Form::close()!!} </code></pre> <p>This the controller code</p> <pre><code>public function uploadLand(Request $request) { for($i=0;$i&lt;count($_FILES["file"]["name"]);$i++){ $image= ""; $file_path="images/uploads"; $imageName = $_FILES['file']['name'][$i]; $image-&gt;move(public_path($file_path),$imageName); //$image-&gt;move_uploaded_file("images/uploads".$imageName); } } </code></pre>
0debug
using functions in python.... help me! please : I had an assessment for my programming class about calculating insurance using functions. This is the code I was trying to get work but unfortunately I failed: import time def main(): print('Welcome to "Insurance Calculator" ') type_I, type_II, type_III = inputs() calculationAndDisplay() validation() time.sleep(3) def inputs(): try: type_I = int(input("How many Type I policies were sold? ")) type_II = int(input("How many Type II policies were sold? ")) type_III = int(input("How many Type III policies were sold? ")) except ValueError: print("Inputs must be an integer, please start again") inputs() return type_I, type_II, type_III def calculationAndDisplay(): type_I *= (500/1.1) type_II *= (650/1.1) type_III *= (800/1.1) print("The amount of annual earned for type_I is: $", type_I) print("The amount of annual earned for type_I is: $", type_II) print("The amount of annual earned for type_I is: $", type_III) def validation(): cont = input("Do you wish to repeat for another year? [Y/N]: ") if cont == 'Y' or cont == 'y': main() elif cont == 'N' or cont == 'n': print('Thank You! ------ See You Again!') else: print("I'm sorry, I couldn't understand your command.") validation() main() I eventually got it to work by cramming all of the input, calculation, and display into one function. I just want to know how I could have made it work the way intended.... Thanks (this is my first time posting so I apologise if I made any mistakes while posting).
0debug
NoClassDefFoundError: SparkSession - even though build is working : <p>I copied <a href="https://github.com/apache/spark/blob/master/examples/src/main/scala/org/apache/spark/examples/ml/RandomForestClassifierExample.scala" rel="noreferrer">https://github.com/apache/spark/blob/master/examples/src/main/scala/org/apache/spark/examples/ml/RandomForestClassifierExample.scala</a> into a new project and setup a build.sbt</p> <pre><code>name := "newproject" version := "1.0" scalaVersion := "2.11.8" javacOptions ++= Seq("-source", "1.8", "-target", "1.8") scalacOptions += "-deprecation" libraryDependencies ++= Seq( "org.apache.spark" % "spark-core_2.11" % "2.0.0" % "provided", "org.apache.spark" % "spark-sql_2.11" % "2.0.0" % "provided", "org.apache.spark" % "spark-mllib_2.11" % "2.0.0" % "provided", "org.jpmml" % "jpmml-sparkml" % "1.1.1", "org.apache.maven.plugins" % "maven-shade-plugin" % "2.4.3", "org.scalatest" %% "scalatest" % "3.0.0" ) </code></pre> <p>I am able to build it from IntelliJ 2016.2.5, but I when I get the error</p> <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/spark/sql/SparkSession$ at org.apache.spark.examples.ml.RandomForestClassifierExample$.main(RandomForestClassifierExample.scala:32) at org.apache.spark.examples.ml.RandomForestClassifierExample.main(RandomForestClassifierExample.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) Caused by: java.lang.ClassNotFoundException: org.apache.spark.sql.SparkSession$ at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 7 more </code></pre> <p>I am even able to click on SparkSession and get to the source code. What is the problem?</p>
0debug
static void *get_surface(const AVFrame *frame) { return frame->data[3]; }
1threat
static CharDriverState *net_vhost_parse_chardev(const NetdevVhostUserOptions *opts) { CharDriverState *chr = qemu_chr_find(opts->chardev); VhostUserChardevProps props; if (chr == NULL) { error_report("chardev \"%s\" not found", opts->chardev); return NULL; } memset(&props, 0, sizeof(props)); if (qemu_opt_foreach(chr->opts, net_vhost_chardev_opts, &props, NULL)) { return NULL; } if (!props.is_socket || !props.is_unix) { error_report("chardev \"%s\" is not a unix socket", opts->chardev); return NULL; } qemu_chr_fe_claim_no_fail(chr); return chr; }
1threat
static IsoBcSection *find_iso_bc_entry(void) { IsoBcEntry *e = (IsoBcEntry *)sec; uint32_t offset = find_iso_bc(); int i; if (!offset) { return NULL; } read_iso_sector(offset, sec, "Failed to read El Torito boot catalog"); if (!is_iso_bc_valid(e)) { virtio_panic("No valid boot catalog found!\n"); return NULL; } for (i = 1; i < ISO_BC_ENTRY_PER_SECTOR; i++) { if (e[i].id == ISO_BC_BOOTABLE_SECTION) { if (is_iso_bc_entry_compatible(&e[i].body.sect)) { return &e[i].body.sect; } } } virtio_panic("No suitable boot entry found on ISO-9660 media!\n"); return NULL; }
1threat
How to scrape all metrics from a federate endpoint? : <p>We have a hierachical prometheus setup with some server scraping others. We'd like to have some servers scrape all metrics from others.</p> <p>Currently we try to use <code>match[]="{__name__=~".*"}"</code> as a metric selector, but this gives the error <code>parse error at char 16: vector selector must contain at least one non-empty matcher</code>.</p> <p>Is there a way to scrape all metrics from a remote prometheus without listing each (prefix) as a match selector?</p>
0debug
Looking for filwever.exe for windows10 - to find out Windows file details on command prompt : <p>I have a ton of files of images and want to find out details about them. These details show up right clicking properties on Windows Explorer</p> <p>However there are thousands of such files and so I have to do it in either Powershell or Gnubash or DOS</p> <p>It seems filever.exe used to do it - but it is not available for windows10. <a href="https://support.microsoft.com/en-us/kb/913111" rel="nofollow">https://support.microsoft.com/en-us/kb/913111</a></p> <p>Can anyone help ?</p> <p>Thanks !</p>
0debug
Submit button won't work in PHP [Addresbook] : <!-- begin snippet: js hide: false --> <!-- language: lang-html --> <?php if (!isset($_SESSION)) { session_start(); } include "connect.php"; include "functions.php"; if (!isset($_SESSION['login']) || $_SESSION['login'] !== true) { header('location: no_acces.php'); exit(); } else { $id_user = $_SESSION['userid']; $q_user = mysqli_query($conn, "SELECT * FROM users WHERE id = $id_user"); if (mysqli_num_rows($q_user) === 1) { $r_user = mysqli_fetch_assoc($q_user); } else { unset($_SESSION['login']); unset($_SESSION['userid']); header('location: no_acces.php'); exit(); } } $error = ""; $userQuery = mysqli_query($conn, "SELECT username FROM users"); $user = mysqli_fetch_assoc($userQuery); $id = $_GET['id']; if (isset($_POST['edit_contact'])) { $roepnaam = $_POST['roepnaam']; $naam = $_POST['naam']; $land = $_POST['land']; $bedrijf = $_POST['bedrijf']; $adres1 = $_POST['adres1']; $adres2 = $_POST['adres2']; $stad = $_POST['stad']; $postcode = $_POST['postcode']; $provincie = $_POST['provincie']; $telefoon = $_POST['telefoon']; $email = $_POST['email']; $captcha= $_POST['g-recaptcha-response']; if(!$captcha){ $error = "Er is een fout opgetreden"; } if ($error == "") { $insertUser = ("UPDATE address SET roepnaam = '$roepnaam', naam = '$naam', bedrijf = '$bedrijf', telefoon = '$telefoon', email = '$email', adres1 = '$adres1', adres2 = '$adres2', stad = '$stad', postcode = '$postcode', provincie = '$provincie', land = '$land' WHERE id = $id"); if (mysqli_query($conn, $insertUser)) { $_SESSION['edit_contact'] = true; header('location: address_book.php'); } else { $error = "Er is een fout opgetreden"; } } } ?> <!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" type="text/css"> <link rel="stylesheet" href="css/stylesheet.css" type="text/css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <script src='https://www.google.com/recaptcha/api.js'></script> <script src="js/java.js"></script> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Contact wijzigen</title> <style> .error { color: darkred; font-weight: bold; } </style> </head> <body> <nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="index.php">SBRM National Bank</a> </div> <div class="collapse navbar-collapse" id="myNavbar"> <ul class="nav navbar-nav"> <li><a href="index.php">Home</a></li> <li><a href="details.php">Gegevens</a><li> <li><a href="bankaccounts.php">Rekeningoverzicht</a><li> <li class="active"><a href="address_book.php">Contacten</a><li> </ul> <ul class="nav navbar-nav navbar-right"> <li class-"active"><a href="details.php"><span class="glyphicon glyphicon-user"></span> U bent ingelogd als <?php echo $user['username']; ?></a></li> <li><a href="logout.php"><span class="glyphicon glyphicon-log-out"></span> Uitloggen</a></li> </ul> </div> </div> </nav> <div class="container-fluid hero-slide"> <div class="row"> <div id="myCarousel" class="carousel slide " data-ride="carousel"> <div class="carousel-inner" role="listbox"> <div class="item active"> <img src="images/tempc.jpg" alt="Ad"> <div class="carousel-caption"> <h3 class="caption">Contact wijzigen</h3> </div> </div> </div> </div> </div> </div> <div class="container padding-top-10"> <div class="panel col-md-6"> <div class="panel-heading "><h5>Nieuwe gegevens:</h5></div> <div class="panel-body"> <form action="" method="post"> <?php if ($error !== "") { ?> <div class="row"> <div class="col-md-12 error"> <?php echo $error; ?> </div> </div> <?php } ?> <label for="firstName" class="control-label">Naam:</label> <div class="row "> <div class="col-md-6"> <input type="text" class="form-control" id="firstName" placeholder="Roepnaam" name="roepnaam" value="<?php if (isset($_POST['roepnaam'])) { echo $_POST['roepnaam']; } ?>" required/> </div> <div class="col-md-6"> <input type="text" class="form-control" id="lastName" placeholder="Naam" name="naam" value="<?php if (isset($_POST['naam'])) { echo $_POST['naam']; } ?>" required/> </div> </div> <label for="username" class="control-label">Bedrijf:</label> <div class="row "> <div class="col-md-12"> <input type="text" class="form-control" id="username" placeholder="Bedrijf" name="bedrijf" value="<?php if (isset($_POST['bedrijf'])) { echo $_POST['bedrijf']; } ?>" required/> </div> </div> <label for="password" class="control-label">Telefoonnummer:</label> <div class="row "> <div class="col-md-12"> <input type="text" class="form-control" id="password" placeholder="Telefoonnummer" name="telefoon" value="<?php if (isset($_POST['telefoon'])) { echo $_POST['telefoon']; } ?>" required/> </div> </div> <label for="email" class="control-label">Email:</label> <div class="row "> <div class="col-md-12"> <input type="text" class="form-control" id="email" placeholder="E-mailadres" name="email" value="<?php if (isset($_POST['email'])) { echo $_POST['email']; } ?>" required/> </div> </div> <label for="adres1" class="control-label">Adres:</label> <div class="row"> <div class="col-md-12"> <input type="text" class="form-control" id="adres1" placeholder="Adres 1" name="adres1" value="<?php if (isset($_POST['adres1'])) { echo $_POST['adres1']; } ?>" required/> </div> </div> <div class="row padding-top-10"> <div class="col-md-12"> <input type="text" class="form-control" id="adres2" placeholder="Adres 2" name="adres2" value="<?php if (isset($_POST['adres2'])) { echo $_POST['adres2']; } ?>"/> </div> </div> <div class="row"> <div class="col-md-3"> <label for="postcode" class="control-label">Postcode:</label> </div> <div class="col-md-5"> <label for="city" class="control-label">Stad:</label> </div> <div class="col-md-4"> <label for="regio" class="control-label">Regio:</label> </div> </div> <div class="row "> <div class="col-md-3"> <input type="text" class="form-control" id="postcode" placeholder="Postcode" name="postcode" value="<?php if (isset($_POST['postcode'])) { echo $_POST['postcode']; } ?>" required/> </div> <div class="col-md-5"> <input type="text" class="form-control" id="city" placeholder="Stad" name="stad" value="<?php if (isset($_POST['stad'])) { echo $_POST['stad']; } ?>" required/> </div> <div class="col-md-4"> <input type="text" class="form-control" id="regio" placeholder="Provincie" name="provincie" value="<?php if (isset($_POST['provincie'])) { echo $_POST['provincie']; } ?>" required/> </div> </div> <label for="land" class="control-label">Land:</label> <div class="row "> <div class="col-md-12"> <input type="text" class="form-control" id="password" placeholder="Land" name="land" value="<?php if (isset($_POST['land'])) { echo $_POST['land']; } ?>" required/> </div> </div> <div class="row"> <div class="col-md-8 padding-top-10 "> <div class="g-recaptcha " data-sitekey="6LcCsBoTAAAAAK72uzyJSrgWwD8xuF6jFIfgFaHX"></div> </div> </div> <div class="row"> <div class="col-md-2 padding-top-10"> <input type="submit" name="edit_contact" class="btn btn-succes" value="Wijzigen"> </div> <div class="col-md-2 padding-top-10"> <input type="text" name="delete_contact" action="delete_contact.php" class="btn btn-succes" value="Contact verwijderen"> </div> </div> </form> </div> </div> </div> <footer> <div class="container"> <div class="row"> <div class="col-sm-3"> <h6>Copyright &copy; 2016</h6> <ul class="list-unstyled"> <li class="boss">Sander Bakker</li> <li class="unstyled">Bob Lansbergen</li> <li class="unstyled">Ronald van den Heuvel</li> <li class="unstyled">Max Donck</li> </ul> </div> <div class="col-sm-3"> <h6>Over Ons</h6> <p id="pfont">Dit is een website ontworpen om een banksysteem te simuleren met PHP en mySQL</p> </div> <div class="col-sm-2"> <h6>Navigatie</h6> <ul class="list-unstyled"> <li class="unstyled"><a href="#">Home</a></li> <li class="unstyled"><a href="#">Particulier</a></li> <li class="unstyled"><a href="#">Persoonlijk</a></li> <li class="unstyled"><a href="#">Privé</a></li> <li class="unstyled"><a href="#">Zakelijk</a></li> </uL> </div> <div class="col-sm-2"> <h6>Contact</h6> <ul class="list-unstyled"> <li class="unstyled"><a href="#">Google +</a></li> <li class="unstyled"><a href="#">Facebook</a></li> <li class="unstyled"><a href="#">Twitter</a></li> <li class="unstyled"><a href="#">YouTube</a></li> </uL> </div> </div> </div> </footer> </body> </head> </html> <!-- end snippet --> This is my html code <!-- begin snippet: js hide: false --> <!-- language: lang-html --> <?php if (!isset($_SESSION)) { session_start(); } include "connect.php"; include "functions.php"; if (!isset($_SESSION['login']) || $_SESSION['login'] !== true || !isset($_SESSION['userid']) || $_SESSION['userid'] == "") { header('location: login.php'); exit(); } else { session_regenerate_id(); } $id = $_GET['id']; $query = "DELETE FROM address WHERE id= $id"; mysqli_query ($query); if (mysql_affected_rows() == 1) { header('location: addressbook.php'); } else { echo "Verwijderen mislukt"; } ?> <!-- end snippet --> This is my PHP code. I'm trying to make a delete button for my contacts within the addressbook. but everytime I click "Contact verwijderen" the webpage resets it self and the contact won't be deleted. Could anyone help me to fix this?
0debug
static void pnv_icp_realize(DeviceState *dev, Error **errp) { PnvICPState *icp = PNV_ICP(dev); memory_region_init_io(&icp->mmio, OBJECT(dev), &pnv_icp_ops, icp, "icp-thread", 0x1000); }
1threat
How to transform a string of maps coordinates into an array javascript? : <p>I am drawing trails on a map and the coordinates of the trail are saved as string in a json file in the following format: (43.886758784865066, 24.226741790771484),(43.90271630763887, 24.234981536865234)</p> <p>I need to get these values and add them to an array: coordinates= [43.886758784865066, 24.226741790771484,43.90271630763887, 24.234981536865234];</p> <p>So how can I do this transition?</p>
0debug
How to fire browser back button event when I press a button inside the page? : <p>I want to load the previous page without postback when I click on a button in the current page.?</p> <p>The same event should occur when we click on browser back button.</p>
0debug
if/else statements for school project : <p>I'm just starting to learn C++ for school, and I'm having trouble completing a school project requiring the use of if/else statements. The project requires code that works as: <a href="https://i.stack.imgur.com/6xOmB.png" rel="nofollow noreferrer">example of working code</a> My code looks like this:</p> <pre><code>#include &lt;iostream&gt; using namespace std; int ontime; int zip; int work; int main() { cout &lt;&lt; "Welcome to the DIG3873 System." &lt;&lt; endl; cout &lt;&lt; "Did the student submit the exam on time (Y/N)? "; cin &gt;&gt; ontime; if (ontime == 'Y' || 'y') { cout &lt;&lt; "Did the student zip the file (Y/N)? "; cin &gt;&gt; zip; if (zip == 'Y' || 'y') { cout &lt;&lt; "Did the student's code work as requested (Y/N)? "; cin &gt;&gt; work; if (work == 'Y' || 'y') { cout &lt;&lt; "Congratulations, YOU PASS. "&lt;&lt; endl; } else if (work == 'N' || 'n') { cout &lt;&lt; "YOU FAIL " &lt;&lt; endl; } else { cout &lt;&lt; "Please enter a valid response. " &lt;&lt; endl; } } else if (zip == 'N' || 'n') { cout &lt;&lt; "YOU FAIL " &lt;&lt; endl; } else { cout &lt;&lt; "Please enter a valid response. " &lt;&lt; endl; } } else if (ontime == 'N' || 'n') { cout &lt;&lt; "YOU FAIL " &lt;&lt; endl; } else { cout &lt;&lt; "Please enter a valid response. " &lt;&lt; endl; } } </code></pre> <p>Unfortunately, it's not working as I would have hoped. When it runs, it lets me answer the first statement, then just drops all the other cout statements and a bunch of "YOU FAIL"s and ends the program. We haven't learned anything beyond if/else statements, so I was pretty lost looking at similar coding issues where people recommended using loops instead. Sorry for such a beginner's issue with not understanding if/else statements, thanks!</p>
0debug
static int cmp_pkt_sub_ts_pos(const void *a, const void *b) { const AVPacket *s1 = a; const AVPacket *s2 = b; if (s1->pts == s2->pts) { if (s1->pos == s2->pos) return 0; return s1->pos > s2->pos ? 1 : -1; } return s1->pts > s2->pts ? 1 : -1; }
1threat
iPhone X / 8 / 8 Plus CSS media queries : <p>What are the CSS media queries corresponding to Apple's new devices ? I need to set the <code>body</code>'s <code>background-color</code> to change the X's safe area background color.</p>
0debug