problem
stringlengths
26
131k
labels
class label
2 classes
static int decode_tile(J2kDecoderContext *s, J2kTile *tile) { int compno, reslevelno, bandno; int x, y, *src[4]; uint8_t *line; J2kT1Context t1; for (compno = 0; compno < s->ncomponents; compno++){ J2kComponent *comp = tile->comp + compno; J2kCodingStyle *codsty = tile->codsty + compno; for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){ J2kResLevel *rlevel = comp->reslevel + reslevelno; for (bandno = 0; bandno < rlevel->nbands; bandno++){ J2kBand *band = rlevel->band + bandno; int cblkx, cblky, cblkno=0, xx0, x0, xx1, y0, yy0, yy1, bandpos; bandpos = bandno + (reslevelno > 0); yy0 = bandno == 0 ? 0 : comp->reslevel[reslevelno-1].coord[1][1] - comp->reslevel[reslevelno-1].coord[1][0]; y0 = yy0; yy1 = FFMIN(ff_j2k_ceildiv(band->coord[1][0] + 1, band->codeblock_height) * band->codeblock_height, band->coord[1][1]) - band->coord[1][0] + yy0; if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1]) continue; for (cblky = 0; cblky < band->cblkny; cblky++){ if (reslevelno == 0 || bandno == 1) xx0 = 0; else xx0 = comp->reslevel[reslevelno-1].coord[0][1] - comp->reslevel[reslevelno-1].coord[0][0]; x0 = xx0; xx1 = FFMIN(ff_j2k_ceildiv(band->coord[0][0] + 1, band->codeblock_width) * band->codeblock_width, band->coord[0][1]) - band->coord[0][0] + xx0; for (cblkx = 0; cblkx < band->cblknx; cblkx++, cblkno++){ int y, x; decode_cblk(s, codsty, &t1, band->cblk + cblkno, xx1 - xx0, yy1 - yy0, bandpos); if (codsty->transform == FF_DWT53){ for (y = yy0; y < yy1; y+=s->cdy[compno]){ int *ptr = t1.data[y-yy0]; for (x = xx0; x < xx1; x+=s->cdx[compno]){ comp->data[(comp->coord[0][1] - comp->coord[0][0]) * y + x] = *ptr++ >> 1; } } } else{ for (y = yy0; y < yy1; y+=s->cdy[compno]){ int *ptr = t1.data[y-yy0]; for (x = xx0; x < xx1; x+=s->cdx[compno]){ int tmp = ((int64_t)*ptr++) * ((int64_t)band->stepsize) >> 13, tmp2; tmp2 = FFABS(tmp>>1) + FFABS(tmp&1); comp->data[(comp->coord[0][1] - comp->coord[0][0]) * y + x] = tmp < 0 ? -tmp2 : tmp2; } } } xx0 = xx1; xx1 = FFMIN(xx1 + band->codeblock_width, band->coord[0][1] - band->coord[0][0] + x0); } yy0 = yy1; yy1 = FFMIN(yy1 + band->codeblock_height, band->coord[1][1] - band->coord[1][0] + y0); } } } ff_j2k_dwt_decode(&comp->dwt, comp->data); src[compno] = comp->data; } if (tile->codsty[0].mct) mct_decode(s, tile); if (s->avctx->pix_fmt == PIX_FMT_BGRA) FFSWAP(int *, src[0], src[2]); if (s->precision <= 8) { for (compno = 0; compno < s->ncomponents; compno++){ y = tile->comp[compno].coord[1][0] - s->image_offset_y; line = s->picture.data[0] + y * s->picture.linesize[0]; for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]){ uint8_t *dst; x = tile->comp[compno].coord[0][0] - s->image_offset_x; dst = line + x * s->ncomponents + compno; for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s->cdx[compno]) { *src[compno] += 1 << (s->cbps[compno]-1); if (*src[compno] < 0) *src[compno] = 0; else if (*src[compno] >= (1 << s->cbps[compno])) *src[compno] = (1 << s->cbps[compno]) - 1; *dst = *src[compno]++; dst += s->ncomponents; } line += s->picture.linesize[0]; } } } else { for (compno = 0; compno < s->ncomponents; compno++) { y = tile->comp[compno].coord[1][0] - s->image_offset_y; line = s->picture.data[0] + y * s->picture.linesize[0]; for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) { uint16_t *dst; x = tile->comp[compno].coord[0][0] - s->image_offset_x; dst = line + (x * s->ncomponents + compno) * 2; for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s-> cdx[compno]) { int32_t val; val = *src[compno]++ << (16 - s->cbps[compno]); val += 1 << 15; val = av_clip(val, 0, (1 << 16) - 1); *dst = val; dst += s->ncomponents; } line += s->picture.linesize[0]; } } } return 0; }
1threat
static av_noinline void emulated_edge_mc_mmxext(uint8_t *buf, const uint8_t *src, ptrdiff_t buf_stride, ptrdiff_t src_stride, int block_w, int block_h, int src_x, int src_y, int w, int h) { emulated_edge_mc(buf, src, buf_stride, src_stride, block_w, block_h, src_x, src_y, w, h, vfixtbl_mmx, &ff_emu_edge_vvar_mmx, hfixtbl_mmxext, &ff_emu_edge_hvar_mmxext); }
1threat
static void gen_ori(DisasContext *ctx) { target_ulong uimm = UIMM(ctx->opcode); if (rS(ctx->opcode) == rA(ctx->opcode) && uimm == 0) { return; } tcg_gen_ori_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], uimm); }
1threat
How to get spotify access token -Spotify Web API Node : I reffered the link https://www.npmjs.com/package/spotify-web-api-node **code sample** var SpotifyWebApi = require('spotify-web-api-node'); // credentials are optional var spotifyApi = new SpotifyWebApi({ clientId: 'fcecfc72172e4cd267473117a17cbd4d', clientSecret: 'a6338157c9bb5ac9c71924cb2940e1a7', redirectUri: 'http://www.example.com/callback' }); In this how can i get the access token..? Please help me
0debug
Doctrine - How to bind array to the SQL? : <p>My SQL looks something like this:</p> <pre><code>$sql = "select * from user where id in (:userId) and status = :status"; $em = $this-&gt;getEntityManager(); $stmt = $em-&gt;getConnection()-&gt;prepare($sql); $stmt-&gt;bindValue(':userId', $accounts, \Doctrine\DBAL\Connection::PARAM_INT_ARRAY); $stmt-&gt;bindValue(':status', 'declined'); $stmt-&gt;execute(); $result = $stmt-&gt;fetchAll(); </code></pre> <p>But it returns:</p> <blockquote> <p>An exception occurred while executing (...) </p> <p>with params [[1,2,3,4,5,6,7,8,11,12,13,14], "declined"]</p> <p>Notice: Array to string conversion</p> </blockquote> <p>I cannot user <code>queryBuilder</code> because my real SQL is more complicated (ex. contains joined select, unions and so on)</p>
0debug
set a html option selected in a dropdown conatining optgroup tag using javascript : I'm working With Html(JSP) and Javascript. I have a dropdown box with id "examcenter" containing many optgroup as shown in the following code. in the function loadDrivingSchool() in javascript, I would like to set selected the value of the selected element. the loadDrivingSchool() function calls a controller in a server and when I return the view, the dropdown list does not have a selected value. I want to set this selected value to the value that the user choose before the reloading of the page <select id="examcenter" onchange="loadDrivingSchool();"> <option value="0">All</option> <optgroup label="ADAMAOUA"> <option value="1">TIBATI</option> <option value="2">TIGNERE</option> <option value="3">MEIGANGA</option> <option value="4">BANYO</option> <option value="5">NGAOUNDERE</option> </optgroup> <optgroup label="CENTRE"> <option value="6">YAOUNDE</option> <option value="7">ESEKA</option> <option value="8">AKONOLINGA</option> <option value="9">NANGA EBOKO</option> <option value="10">MONATELE</option> <option value="11">MBALMAYO</option> <option value="12">MFOU</option> <option value="13">NGOUMOU</option> <option value="14">BAFIA</option> <option value="15">NTUI</option> </optgroup> <optgroup label="EXTREME NORD"> <option value="20">MAROUA</option> <option value="21">KAELE</option> <option value="22">KOUSSERI</option> <option value="23">MORA</option> <option value="24">YAGOUA</option> <option value="25">MOKOLO</option> </optgroup> <optgroup label="EST"> <option value="16">YOKADOUMA</option> <option value="17">ABONG-MBANG</option> <option value="18">BATOURI</option> <option value="19">BERTOUA</option> <option value="62">NGUELEMENDOUKA</option> </optgroup> </select>
0debug
Python: IndentationError: unexpected indent : <p>Been pulling what hair I have left over this :-(</p> <pre><code>if tIn.find("play again") != -1: tn.write("yes\n") print tn.read_until("WordsWeNeverSee",1.0) tn.write("O\n") </code></pre> <p>I get the error</p> <pre><code>root@kali:~# ./TTT.py File "./TTT.py", line 79 print tn.read_until("WordsWeNeverSee",1.0) ^ IndentationError: unexpected indent </code></pre> <p>Any idea how to resolve?</p>
0debug
How to check if a char is in the alphabet in C# : <p>I think the title says enough.</p> <pre><code>void onClickSubmit(char submit) { if(submit.//check if it is alphabetical) { //some code } } </code></pre> <p>how can i check if the char submit is in the alphabet?</p>
0debug
Why do we need to return state from reducer in React : I am new to Redux and was trying to get how to work with Redux properly but I encountered a confusion on why we need to return state in reducer. Here is the code: const initialState = { counter: 0 }; const reducer = (state = initialState, action) => { if (action.type === "INCREMENT") { return { counter: state.counter + 1 }; } return state; why do we need to use this code? }; export default reducer;
0debug
static void mct_decode(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile) { int i, csize = 1; int32_t *src[3], i0, i1, i2; float *srcf[3], i0f, i1f, i2f; for (i = 0; i < 3; i++) if (tile->codsty[0].transform == FF_DWT97) srcf[i] = tile->comp[i].f_data; else src [i] = tile->comp[i].i_data; for (i = 0; i < 2; i++) csize *= tile->comp[0].coord[i][1] - tile->comp[0].coord[i][0]; switch (tile->codsty[0].transform) { case FF_DWT97: for (i = 0; i < csize; i++) { i0f = *srcf[0] + (f_ict_params[0] * *srcf[2]); i1f = *srcf[0] - (f_ict_params[1] * *srcf[1]) - (f_ict_params[2] * *srcf[2]); i2f = *srcf[0] + (f_ict_params[3] * *srcf[1]); *srcf[0]++ = i0f; *srcf[1]++ = i1f; *srcf[2]++ = i2f; break; case FF_DWT97_INT: for (i = 0; i < csize; i++) { i0 = *src[0] + (((i_ict_params[0] * *src[2]) + (1 << 15)) >> 16); i1 = *src[0] - (((i_ict_params[1] * *src[1]) + (1 << 15)) >> 16) - (((i_ict_params[2] * *src[2]) + (1 << 15)) >> 16); i2 = *src[0] + (((i_ict_params[3] * *src[1]) + (1 << 15)) >> 16); *src[0]++ = i0; *src[1]++ = i1; *src[2]++ = i2; break; case FF_DWT53: for (i = 0; i < csize; i++) { i1 = *src[0] - (*src[2] + *src[1] >> 2); i0 = i1 + *src[2]; i2 = i1 + *src[1]; *src[0]++ = i0; *src[1]++ = i1; *src[2]++ = i2; break;
1threat
Saving the text entered in page to a server : <p>I am creating a journal website, i am going to have a text box in it. I need to store the text entered in the website by the user to my file. I have an online free server.please help me to store it in a simple way</p>
0debug
How to i hide/show user controls in form : <p>I need to change between different displays for my game. I need to show different screens where a player can choose what they want to play and what difficulty they want it. Before user control, I wanted to use panels but, they were really hard to customize because I need to add a lot of picture boxes, so I got myself user controls.<br></p> <p>Now the problem is that panels were easy to manage with the visible property but, I just can't find the way to make user controls visible and later hide them if a button is clicked.<br></p> <p>Is there an actual way to change those controls if first, I click the button in the form to make control1 visible, then click the button in control1 to hide control1 and make control2 visible?</p> <p>the form name is form1 and my current Uc name is UCmilline (info to make it more clear for me cause Im used to video tutorials or live)</p>
0debug
Css fille issue : I have tried too many times to link the css file externally but it doesn't work yet. It is working fine with internal css and inline css but not with external css. I have checked too many times the name, location and folder of that file but still not find any solution. Here are some codes of mine. <!-- language: lang-html --> <!doctype html> <html> <head> <title>My Webpage</title> <link rel="stylesheet" type="text/css" href="Samar/s.css"/> </head> <body> <img src="samar.jpg" width="300" height="370" align="right" alt="My Image"/> <h1><center><i> Welcome to Samar Club </i></center></h1> <p> Hello Everyone, My name is Samar. I am here to give you guys the solutions of NCERT Maths problems.</p> </body> </html> <!-- end snippet --> </body> Here is my css file <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-css --> h1{ font-family: Arial; font-size: 37px; border: 12px double grey; color:maroon; } p{ text-align:right; font-family:sans-serif; font-weight:bold; font-size:25px; margin-top:35px; background-color:yellow; } <!-- end snippet -->
0debug
Binary operation not working in C : I have 24 bits stored as a string. I'm using C and I want to store each set of 8 bits, starting at position 0, as an element of a u8int_t vector. I've tried different things to no avail. This is my code: #include <stdio.h> #include <stdlib.h> #define SIZE 8 uint8_t send[SIZE/8]; char data[] = "10101010"; printf ("Data is = %s\n", data); for ( int i = 0; i < SIZE/8; i++) { for ( int j = 0; j < 8; j++) { send[i] |= (data[j+8*i] == '1') << (7-i); } printf("%d\n",send[i]); } The value printed is 128, but 10101010 in decimal is 170. Am I missing something?
0debug
void usb_cancel_packet(USBPacket * p) { assert(p->owner != NULL); usb_device_cancel_packet(p->owner->dev, p); p->owner = NULL; }
1threat
void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, const char *boot_device, BusState *idebus0, BusState *idebus1, FDCtrl *floppy_controller, ISADevice *s) { int val, nb; FDriveType fd0, fd1; static pc_cmos_init_late_arg arg; val = 640; rtc_set_memory(s, 0x15, val); rtc_set_memory(s, 0x16, val >> 8); val = (ram_size / 1024) - 1024; if (val > 65535) val = 65535; rtc_set_memory(s, 0x17, val); rtc_set_memory(s, 0x18, val >> 8); rtc_set_memory(s, 0x30, val); rtc_set_memory(s, 0x31, val >> 8); if (above_4g_mem_size) { rtc_set_memory(s, 0x5b, (unsigned int)above_4g_mem_size >> 16); rtc_set_memory(s, 0x5c, (unsigned int)above_4g_mem_size >> 24); rtc_set_memory(s, 0x5d, (uint64_t)above_4g_mem_size >> 32); } if (ram_size > (16 * 1024 * 1024)) val = (ram_size / 65536) - ((16 * 1024 * 1024) / 65536); else val = 0; if (val > 65535) val = 65535; rtc_set_memory(s, 0x34, val); rtc_set_memory(s, 0x35, val >> 8); rtc_set_memory(s, 0x5f, smp_cpus - 1); if (set_boot_dev(s, boot_device, fd_bootchk)) { exit(1); } fd0 = fdctrl_get_drive_type(floppy_controller, 0); fd1 = fdctrl_get_drive_type(floppy_controller, 1); val = (cmos_get_fd_drive_type(fd0) << 4) | cmos_get_fd_drive_type(fd1); rtc_set_memory(s, 0x10, val); val = 0; nb = 0; if (fd0 < FDRIVE_DRV_NONE) { nb++; } if (fd1 < FDRIVE_DRV_NONE) { nb++; } switch (nb) { case 0: break; case 1: val |= 0x01; break; case 2: val |= 0x41; break; } val |= 0x02; val |= 0x04; rtc_set_memory(s, REG_EQUIPMENT_BYTE, val); arg.rtc_state = s; arg.idebus0 = idebus0; arg.idebus1 = idebus1; qemu_register_reset(pc_cmos_init_late, &arg); }
1threat
My splash screen keeps on crashing and forceclosing the app : My app keeps on crashing upon startup please check my code.I was doing an automatic login on my splash screen. Please help me, this is for my thesis. **splash.class** import android.content.Intent; import android.database.Cursor; import android.os.Handler; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import static com.example.mgimoro.dietgo.Database.TABLE_NAME; public class Splash extends AppCompatActivity { SQLiteDatabase db; SQLiteOpenHelper helper; Database database; int id=0; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); initialize(); } public void initialize(){ db=helper.getReadableDatabase(); String query = "SELECT ID FROM " + TABLE_NAME + " WHERE ID = (ID)"; Cursor c = db.rawQuery(query, null); if (c.moveToFirst()) { id=c.getInt(c.getColumnIndex(query)); }else{} if (id<0){ Intent homeIntent = new Intent(Splash.this, Onboard.class); startActivity(homeIntent); finish(); }else{ Intent homeIntent = new Intent(Splash.this, mainmenu.class); startActivity(homeIntent); finish(); } } }
0debug
static void test_qemu_strtoll_invalid(void) { const char *str = " xxxx \t abc"; char f = 'X'; const char *endptr = &f; int64_t res = 999; int err; err = qemu_strtoll(str, &endptr, 0, &res); g_assert_cmpint(err, ==, 0); g_assert(endptr == str); }
1threat
Must both right-hand expressions of a ternary operator be of compatible types? : <p>My Practice Tests book contains this question on the ternary operator:</p> <pre><code>// What is the output of the following application? public class Transportation { public static String travel(int distance) { return(distance &lt; 1000 ? "train" : 10); } public static void main(String[] args) { travel(500); } } </code></pre> <p>It does not compile. The explanation given is the following:</p> <blockquote> <p>Ternary operations require both right-hand expressions to be of compatible data types. In this example, the first right-hand expression of the outer ternary operation is of type String, while the second right-hand expression is of type int. Since these data types are incompatible, the code does not compile, and Option C is the correct answer.</p> </blockquote> <p>Is that really the reason? It looks to me like this example doesn't compile because 10 is not a String and a String is what the method must return. I'm asking because <code>System.out.println(distance &lt; 1000 ? "train" : 10);</code> compiles and runs without a problem.</p>
0debug
Why would we use two servers for one website : <p>I am relatively new to Web development. I was reading about Remote files in PHP, and I came across this question at <a href="https://www.quora.com/How-do-I-store-data-in-a-JSON-file-on-a-remote-server" rel="nofollow noreferrer">Quara</a></p> <p>My question is why would we require to use a second server in general?</p>
0debug
static int64_t get_clock(void) { #if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \ || defined(__DragonFly__) if (use_rt_clock) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return ts.tv_sec * 1000000000LL + ts.tv_nsec; } else #endif { struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec * 1000000000LL + (tv.tv_usec * 1000); } }
1threat
how to pass the sessions and sessions auth of the App laravel to package And vice versa? : Do you know how to pass the sessions and session auth of the App laravel to package And vice versa ? It does not work for me, I do not know what I'm missing. Thank you
0debug
void helper_fcmp_gt_FT(CPUSH4State *env, float32 t0, float32 t1) { int relation; set_float_exception_flags(0, &env->fp_status); relation = float32_compare(t0, t1, &env->fp_status); if (unlikely(relation == float_relation_unordered)) { update_fpscr(env, GETPC()); } else { env->sr_t = (relation == float_relation_greater); } }
1threat
static int buffer_needs_copy(PadContext *s, AVFrame *frame, AVBufferRef *buf) { int planes[4] = { -1, -1, -1, -1}, *p = planes; int i, j; for (i = 0; i < FF_ARRAY_ELEMS(planes) && frame->data[i]; i++) { if (av_frame_get_plane_buffer(frame, i) == buf) *p++ = i; } for (i = 0; i < FF_ARRAY_ELEMS(planes) && planes[i] >= 0; i++) { int hsub = s->draw.hsub[planes[i]]; int vsub = s->draw.vsub[planes[i]]; uint8_t *start = frame->data[planes[i]]; uint8_t *end = start + (frame->height >> vsub) * frame->linesize[planes[i]]; ptrdiff_t req_start = (s->x >> hsub) * s->draw.pixelstep[planes[i]] + (s->y >> vsub) * frame->linesize[planes[i]]; ptrdiff_t req_end = ((s->w - s->x - frame->width) >> hsub) * s->draw.pixelstep[planes[i]] + (s->y >> vsub) * frame->linesize[planes[i]]; if (frame->linesize[planes[i]] < (s->w >> hsub) * s->draw.pixelstep[planes[i]]) return 1; if (start - buf->data < req_start || (buf->data + buf->size) - end < req_end) return 1; for (j = 0; j < FF_ARRAY_ELEMS(planes) && planes[j] >= 0; j++) { int vsub1 = s->draw.vsub[planes[j]]; uint8_t *start1 = frame->data[planes[j]]; uint8_t *end1 = start1 + (frame->height >> vsub1) * frame->linesize[planes[j]]; if (i == j) continue; if (FFSIGN(start - end1) != FFSIGN(start - end1 - req_start) || FFSIGN(end - start1) != FFSIGN(end - start1 + req_end)) return 1; } } return 0; }
1threat
“does not name a type” error c++ : <p>I have a class declared as below, and I keep getting "Segment does not name a type" error. I've looked at other similar questions but I can't seem to find a solution to my problem. Any help? Thanks in advance! :)</p> <pre><code>#ifndef ENTRANCE_H #define ENTRANCE_H #include "Segment.h" #include &lt;vector&gt; #include "Diodio.h" class Entrance { public: Entrance(); ~Entrance(); void operate(); protected: Segment *givesEntryTo; std::vector&lt;Diodio&gt; elBooths; std::vector&lt;Diodio&gt; manBooths; private: }; #endif // ENTRANCE_H </code></pre>
0debug
static int mov_read_header(AVFormatContext *s) { MOVContext *mov = s->priv_data; AVIOContext *pb = s->pb; int err; MOVAtom atom = { AV_RL32("root") }; int i; mov->fc = s; if (pb->seekable) atom.size = avio_size(pb); else atom.size = INT64_MAX; if ((err = mov_read_default(mov, pb, atom)) < 0) { av_log(s, AV_LOG_ERROR, "error reading header: %d\n", err); mov_read_close(s); return err; } if (!mov->found_moov) { av_log(s, AV_LOG_ERROR, "moov atom not found\n"); mov_read_close(s); return AVERROR_INVALIDDATA; } av_dlog(mov->fc, "on_parse_exit_offset=%"PRId64"\n", avio_tell(pb)); if (pb->seekable && mov->chapter_track > 0) mov_read_chapters(s); for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; MOVStreamContext *sc = st->priv_data; if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { if (st->codec->width <= 0 && st->codec->width <= 0) { st->codec->width = sc->width; st->codec->height = sc->height; } if (st->codec->codec_id == AV_CODEC_ID_DVD_SUBTITLE) { if ((err = mov_rewrite_dvd_sub_extradata(st)) < 0) return err; } } } if (mov->trex_data) { for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; MOVStreamContext *sc = st->priv_data; if (st->duration > 0) st->codec->bit_rate = sc->data_size * 8 * sc->time_scale / st->duration; } } for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; MOVStreamContext *sc = st->priv_data; switch (st->codec->codec_type) { case AVMEDIA_TYPE_AUDIO: err = ff_replaygain_export(st, s->metadata); if (err < 0) { mov_read_close(s); return err; } break; case AVMEDIA_TYPE_VIDEO: if (sc->display_matrix) { AVPacketSideData *sd, *tmp; tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp)); if (!tmp) return AVERROR(ENOMEM); st->side_data = tmp; st->nb_side_data++; sd = &st->side_data[st->nb_side_data - 1]; sd->type = AV_PKT_DATA_DISPLAYMATRIX; sd->size = sizeof(int32_t) * 9; sd->data = (uint8_t*)sc->display_matrix; sc->display_matrix = NULL; } break; } } return 0; }
1threat
static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) { uint_fast16_t cb; uint8_t *tmp_vlc_bits; uint32_t *tmp_vlc_codes; GetBitContext *gb=&vc->gb; vc->codebook_count=get_bits(gb,8)+1; AV_DEBUG(" Codebooks: %d \n", vc->codebook_count); vc->codebooks=(vorbis_codebook *)av_mallocz(vc->codebook_count * sizeof(vorbis_codebook)); tmp_vlc_bits=(uint8_t *)av_mallocz(V_MAX_VLCS * sizeof(uint8_t)); tmp_vlc_codes=(uint32_t *)av_mallocz(V_MAX_VLCS * sizeof(uint32_t)); for(cb=0;cb<vc->codebook_count;++cb) { vorbis_codebook *codebook_setup=&vc->codebooks[cb]; uint_fast8_t ordered; uint_fast32_t t, used_entries=0; uint_fast32_t entries; AV_DEBUG(" %d. Codebook \n", cb); if (get_bits(gb, 24)!=0x564342) { av_log(vc->avccontext, AV_LOG_ERROR, " %"PRIdFAST16". Codebook setup data corrupt. \n", cb); goto error; } codebook_setup->dimensions=get_bits(gb, 16); if (codebook_setup->dimensions>16) { av_log(vc->avccontext, AV_LOG_ERROR, " %"PRIdFAST16". Codebook's dimension is too large (%d). \n", cb, codebook_setup->dimensions); goto error; } entries=get_bits(gb, 24); if (entries>V_MAX_VLCS) { av_log(vc->avccontext, AV_LOG_ERROR, " %"PRIdFAST16". Codebook has too many entries (%"PRIdFAST32"). \n", cb, entries); goto error; } ordered=get_bits1(gb); AV_DEBUG(" codebook_dimensions %d, codebook_entries %d \n", codebook_setup->dimensions, entries); if (!ordered) { uint_fast16_t ce; uint_fast8_t flag; uint_fast8_t sparse=get_bits1(gb); AV_DEBUG(" not ordered \n"); if (sparse) { AV_DEBUG(" sparse \n"); used_entries=0; for(ce=0;ce<entries;++ce) { flag=get_bits1(gb); if (flag) { tmp_vlc_bits[ce]=get_bits(gb, 5)+1; ++used_entries; } else tmp_vlc_bits[ce]=0; } } else { AV_DEBUG(" not sparse \n"); used_entries=entries; for(ce=0;ce<entries;++ce) { tmp_vlc_bits[ce]=get_bits(gb, 5)+1; } } } else { uint_fast16_t current_entry=0; uint_fast8_t current_length=get_bits(gb, 5)+1; AV_DEBUG(" ordered, current length: %d \n", current_length); used_entries=entries; for(;current_entry<used_entries;++current_length) { uint_fast16_t i, number; AV_DEBUG(" number bits: %d ", ilog(entries - current_entry)); number=get_bits(gb, ilog(entries - current_entry)); AV_DEBUG(" number: %d \n", number); for(i=current_entry;i<number+current_entry;++i) { if (i<used_entries) tmp_vlc_bits[i]=current_length; } current_entry+=number; } if (current_entry>used_entries) { av_log(vc->avccontext, AV_LOG_ERROR, " More codelengths than codes in codebook. \n"); goto error; } } codebook_setup->lookup_type=get_bits(gb, 4); AV_DEBUG(" lookup type: %d : %s \n", codebook_setup->lookup_type, codebook_setup->lookup_type ? "vq" : "no lookup" ); if (codebook_setup->lookup_type==1) { uint_fast16_t i, j, k; uint_fast16_t codebook_lookup_values=ff_vorbis_nth_root(entries, codebook_setup->dimensions); uint_fast16_t codebook_multiplicands[codebook_lookup_values]; float codebook_minimum_value=vorbisfloat2float(get_bits_long(gb, 32)); float codebook_delta_value=vorbisfloat2float(get_bits_long(gb, 32)); uint_fast8_t codebook_value_bits=get_bits(gb, 4)+1; uint_fast8_t codebook_sequence_p=get_bits1(gb); AV_DEBUG(" We expect %d numbers for building the codevectors. \n", codebook_lookup_values); AV_DEBUG(" delta %f minmum %f \n", codebook_delta_value, codebook_minimum_value); for(i=0;i<codebook_lookup_values;++i) { codebook_multiplicands[i]=get_bits(gb, codebook_value_bits); AV_DEBUG(" multiplicands*delta+minmum : %e \n", (float)codebook_multiplicands[i]*codebook_delta_value+codebook_minimum_value); AV_DEBUG(" multiplicand %d \n", codebook_multiplicands[i]); } codebook_setup->codevectors=(float *)av_mallocz(used_entries*codebook_setup->dimensions * sizeof(float)); for(j=0, i=0;i<entries;++i) { uint_fast8_t dim=codebook_setup->dimensions; if (tmp_vlc_bits[i]) { float last=0.0; uint_fast32_t lookup_offset=i; #ifdef V_DEBUG av_log(vc->avccontext, AV_LOG_INFO, "Lookup offset %d ,", i); #endif for(k=0;k<dim;++k) { uint_fast32_t multiplicand_offset = lookup_offset % codebook_lookup_values; codebook_setup->codevectors[j*dim+k]=codebook_multiplicands[multiplicand_offset]*codebook_delta_value+codebook_minimum_value+last; if (codebook_sequence_p) { last=codebook_setup->codevectors[j*dim+k]; } lookup_offset/=codebook_lookup_values; } tmp_vlc_bits[j]=tmp_vlc_bits[i]; #ifdef V_DEBUG av_log(vc->avccontext, AV_LOG_INFO, "real lookup offset %d, vector: ", j); for(k=0;k<dim;++k) { av_log(vc->avccontext, AV_LOG_INFO, " %f ", codebook_setup->codevectors[j*dim+k]); } av_log(vc->avccontext, AV_LOG_INFO, "\n"); #endif ++j; } } if (j!=used_entries) { av_log(vc->avccontext, AV_LOG_ERROR, "Bug in codevector vector building code. \n"); goto error; } entries=used_entries; } else if (codebook_setup->lookup_type>=2) { av_log(vc->avccontext, AV_LOG_ERROR, "Codebook lookup type not supported. \n"); goto error; } if (ff_vorbis_len2vlc(tmp_vlc_bits, tmp_vlc_codes, entries)) { av_log(vc->avccontext, AV_LOG_ERROR, " Invalid code lengths while generating vlcs. \n"); goto error; } codebook_setup->maxdepth=0; for(t=0;t<entries;++t) if (tmp_vlc_bits[t]>=codebook_setup->maxdepth) codebook_setup->maxdepth=tmp_vlc_bits[t]; if(codebook_setup->maxdepth > 3*V_NB_BITS) codebook_setup->nb_bits=V_NB_BITS2; else codebook_setup->nb_bits=V_NB_BITS; codebook_setup->maxdepth=(codebook_setup->maxdepth+codebook_setup->nb_bits-1)/codebook_setup->nb_bits; if (init_vlc(&codebook_setup->vlc, codebook_setup->nb_bits, entries, tmp_vlc_bits, sizeof(*tmp_vlc_bits), sizeof(*tmp_vlc_bits), tmp_vlc_codes, sizeof(*tmp_vlc_codes), sizeof(*tmp_vlc_codes), INIT_VLC_LE)) { av_log(vc->avccontext, AV_LOG_ERROR, " Error generating vlc tables. \n"); goto error; } } av_free(tmp_vlc_bits); av_free(tmp_vlc_codes); return 0; error: av_free(tmp_vlc_bits); av_free(tmp_vlc_codes); return 1; }
1threat
static void migration_bitmap_sync_range(ram_addr_t start, ram_addr_t length) { unsigned long *bitmap; bitmap = atomic_rcu_read(&migration_bitmap); migration_dirty_pages += cpu_physical_memory_sync_dirty_bitmap(bitmap, start, length); }
1threat
Vagrant - Not Supported the capability 'change_host_name' : <p>The problem is about the capability 'change_host_name' isn't supported by the guest when I try to execute the following command line:</p> <pre><code>vagrant up </code></pre> <p>It gives me an error as the following: </p> <pre><code>Vagrant attempted to execute the capability 'change_host_name' on the detect guest OS 'linux', but the guest doesn't support that capability. This capability is required for your configuration of Vagrant. Please either reconfigure Vagrant to avoid this capability or fix the issue by creating the capability. </code></pre> <p>Note that my OS is: OS X Yosemite 10.10.5</p> <p>Guest Additions Version: 4.2.0 and VirtualBox Version: 5.0</p> <p>I've tried many solutions of others who face this issue, but I couldn't fix it. </p>
0debug
How to wrap height of Android ViewPager2 to height of current item? : <p>This question is for the new <strong>ViewPager2</strong> class.</p> <p>There is a <a href="https://stackoverflow.com/questions/34484833/how-to-wrap-the-height-of-a-viewpager-to-the-height-of-its-current-fragment">similar question for the old ViewPager</a>, but the solution requires extending <strong>ViewPager</strong>. However, ViewPager2 is final so cannot be extended.</p> <p>In my situation, I have a ViewPager2 that contains three different fragments. One of these fragments is much taller than the other two, which means when you swipe to one of the shorter fragments, there is a lot of empty space. So how do I effectively wrap the ViewPager2 to the height of the current fragment?</p>
0debug
long do_rt_sigreturn(CPUM68KState *env) { struct target_rt_sigframe *frame; abi_ulong frame_addr = env->aregs[7] - 4; target_sigset_t target_set; sigset_t set; int d0; if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) goto badframe; target_to_host_sigset_internal(&set, &target_set); sigprocmask(SIG_SETMASK, &set, NULL); if (target_rt_restore_ucontext(env, &frame->uc, &d0)) goto badframe; if (do_sigaltstack(frame_addr + offsetof(struct target_rt_sigframe, uc.tuc_stack), 0, get_sp_from_cpustate(env)) == -EFAULT) goto badframe; unlock_user_struct(frame, frame_addr, 0); return d0; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; }
1threat
str' object has no attribute 'get' attribute : How can I solve it... Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\Mani\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 1699, in __call__ return self.func(*args) File "F:\Monu\Work\python\PROJECT\New folder\LMS.py", line 262, in onDoubalclick cursor.execute("SELECT * FROM `TRANSECTION` WHERE Book_Id=?",(val1.get(),)) AttributeError: 'str' object has no attribute 'get' I already convert it in string or integer but not working def onDoubalclick(event): test=treeview.item(treeview.selection()) print(test) items=treeview.selection()[0] val1=str(treeview.item(items)['values'][0]) print(type(val1)) popsearch() DataBase() cursor.execute("SELECT * FROM `TRANSECTION` WHERE Book_Id=?",(val1.get(),)) info=cursor.fetchall() for ROW1 in info: print(rows) treeview2.insert("",END,value=ROW1) I want to get a value that stores in val1 and search that value in the database
0debug
static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **options) { AVCodec *codec; int got_picture = 1, ret = 0; AVFrame picture; AVPacket pkt = *avpkt; if(!st->codec->codec){ AVDictionary *thread_opt = NULL; codec = avcodec_find_decoder(st->codec->codec_id); if (!codec) return -1; av_dict_set(options ? options : &thread_opt, "threads", "1", 0); ret = avcodec_open2(st->codec, codec, options ? options : &thread_opt); if (!options) av_dict_free(&thread_opt); if (ret < 0) return ret; } while ((pkt.size > 0 || (!pkt.data && got_picture)) && ret >= 0 && (!has_codec_parameters(st->codec) || !has_decode_delay_been_guessed(st) || (!st->codec_info_nb_frames && st->codec->codec->capabilities & CODEC_CAP_CHANNEL_CONF))) { got_picture = 0; avcodec_get_frame_defaults(&picture); switch(st->codec->codec_type) { case AVMEDIA_TYPE_VIDEO: ret = avcodec_decode_video2(st->codec, &picture, &got_picture, &pkt); break; case AVMEDIA_TYPE_AUDIO: ret = avcodec_decode_audio4(st->codec, &picture, &got_picture, &pkt); break; default: break; } if (ret >= 0) { if (got_picture) st->info->nb_decoded_frames++; pkt.data += ret; pkt.size -= ret; ret = got_picture; } } return ret; }
1threat
How to delete ios simulator safari cache : <p>I'm trying to test a website on the iphone simulator, I made some javascript changes and my javascript files are being loaded from cache.</p> <p>I see the old version files with safari web inspector, resources tab (on simulator window), also the network calls have status 304. I already disabled cache on macos Safari. I already tried deleting the safari cache on the simulator settings. Safari outside the emulator is loading the new files correctly (I emptied/disabled the cache).</p> <p>I'm using Simulator (10.0 SimulatorAPP-745.10 with iOS 10.3) from XCode on Sierra</p> <p>How do I delete or disable the simulator cache?</p>
0debug
Java - what should be basic stuff is giving errors every line : <p>The objective is to receive in a string of letters and return a string of 1's and 0's that correspond for each. So "100000" for 'a' for example. But it refuses to compile, and I'm unsure what is wrong. The errors are popping up practically every line. I am not sure if I broke some fundamental rule of Java or why it is upset with me. Any direction or tips would be swell. I apologize for the large code blocks, once you hit the series of else if in my code, after the 2nd one they're all the same.</p> <p>Here is my code:</p> <pre><code>package com.google.challenges; public class Answer { public static String answer(String plaintext) { String[] braille = new String[50]; String answer = ""; char j = 'a'; for(int i=0; i&lt;plaintext.length();i++){ j = plaintext.charAt(i); j = switch(j); braille[i] = j; }//close for for(int i=0; i&lt;plaintext.length(); i++){ answer = answer+braille[i]; } return answer; } //close answer public static String switch (char x) { String a = "100000"; String b = "110000"; String c = "100100"; String d = "100110"; String e = "100010"; String f = "110100"; String g = "110110"; String h = "110010"; String i = "010100"; String j = "010110"; String k = "101000"; String l = "111000"; String m = "101100"; String n = "101110"; String o = "101010"; String p = "111100"; String q = "111110"; String r = "111010"; String s = "011100"; String t = "011110"; String u = "101001"; String v = "111001"; String w = "010111"; String x = "101101"; String y = "101111"; String z = "101011"; String cap = "000001"; String space = "000000"; if (x == 'a' || x == 'A'){ if(x=='a'){ return a; } return cap + a; } else if (x == 'b' || x == 'B'){ if(x=='b') { return b; } return cap + b; } else if (x == 'c' || x == 'C'){ if(x=='c'){ return c; } return cap + c; } else if (x == 'd' || x == 'D'){ if(x=='d'){ return d; } return cap + d; } else if (x == 'e' || x == 'E'){ if(x=='e'){ return e; } return cap + e; } else if (x == 'f' || x == 'F'){ if(x=='f'){ return f; } return cap + f; } else if (x == 'g' || x == 'G'){ if(x=='g'){ return g; } return cap + g; } else if (x == 'h' || x == 'H'){ if(x=='h'){ return h; } return cap + h; } else if (x == 'i' || x == 'I'){ if(x=='i'){ return i; } return cap + i; } else if (x == 'j' || x == 'J'){ if(x=='j'){ return j; } return cap + j; } else if (x == 'k' || x == 'K'){ if(x=='k'){ return k; } return cap + k; } else if (x == 'l' || x == 'L'){ if(x=='l'){ return l; } return cap + l; } else if (x == 'm' || x == 'M'){ if(x=='m'){ return m; } return cap + m; } else if (x == 'n' || x == 'N'){ if(x=='n'){ return n; } return cap + n; } else if (x == 'o' || x == 'O'){ if(x=='o'){ return o; } return cap + o; } else if (x == 'p' || x == 'P'){ if(x=='p'){ return p; } return cap + p; } else if (x == 'q' || x == 'Q'){ if(x=='q'){ return q; } return cap + q; } else if (x == 'r' || x == 'R'){ if(x=='r'){ return r; } return cap + r; } else if (x == 's' || x == 'S'){ if(x=='s'){ return s; } return cap + s; } else if (x == 't' || x == 'T'){ if(x=='t'){ return t; } return cap + t; } else if (x == 'u' || x == 'U'){ if(x=='u'){ return u; } return cap + u; } else if (x == 'v' || x == 'V'){ if(x=='v'){ return v; } return cap + v; } else if (x == 'w' || x == 'W'){ if(x=='w'){ return w; } return cap + w; } else if (x == 'x' || x == 'X'){ if(x=='x'){ return x; } return cap + x; } else if (x == 'y' || x == 'Y'){ if(x=='y'){ return y; } return cap + y; } else if (x == 'z' || x == 'Z'){ if(x=='z'){ return z; } return cap + z; } else{ return space; } }//close switch }//close class </code></pre> <p>And here are my errors:</p> <pre><code>/Answer.java:12: error: illegal start of expression j = switch(j); ^ /Answer.java:12: error: not a statement j = switch(j); ^ /Answer.java:22: error: &lt;identifier&gt; expected public static String switch (char x) ^ /Answer.java:22: error: illegal start of type public static String switch (char x) ^ /Answer.java:22: error: &lt;identifier&gt; expected public static String switch (char x) ^ /Answer.java:22: error: ';' expected public static String switch (char x) ^ /Answer.java:22: error: illegal start of type public static String switch (char x) ^ /Answer.java:22: error: &lt;identifier&gt; expected public static String switch (char x) ^ /Answer.java:23: error: ';' expected { ^ /Answer.java:24: error: &lt;identifier&gt; expected String a = "100000"; ^ /Answer.java:53: error: illegal start of type if (x == 'a' || x == 'A'){ ^ /Answer.java:53: error: &lt;identifier&gt; expected if (x == 'a' || x == 'A'){ ^ /Answer.java:53: error: ';' expected if (x == 'a' || x == 'A'){ ^ /Answer.java:53: error: illegal start of type if (x == 'a' || x == 'A'){ ^ /Answer.java:53: error: ';' expected if (x == 'a' || x == 'A'){ ^ /Answer.java:59: error: illegal start of type else if (x == 'b' || x == 'B'){ ^ /Answer.java:59: error: ';' expected else if (x == 'b' || x == 'B'){ ^ /Answer.java:59: error: illegal start of type else if (x == 'b' || x == 'B'){ ^ /Answer.java:59: error: ';' expected else if (x == 'b' || x == 'B'){ ^ /Answer.java:59: error: &lt;identifier&gt; expected else if (x == 'b' || x == 'B'){ ^ /Answer.java:59: error: illegal start of type else if (x == 'b' || x == 'B'){ ^ /Answer.java:59: error: &lt;identifier&gt; expected else if (x == 'b' || x == 'B'){ ^ /Answer.java:59: error: ';' expected else if (x == 'b' || x == 'B'){ ^ /Answer.java:60: error: illegal start of type if(x=='b') ^ /Answer.java:60: error: &lt;identifier&gt; expected if(x=='b') ^ /Answer.java:60: error: ';' expected if(x=='b') ^ /Answer.java:60: error: illegal start of type if(x=='b') ^ /Answer.java:60: error: &lt;identifier&gt; expected if(x=='b') ^ /Answer.java:60: error: ';' expected if(x=='b') ^ /Answer.java:64: error: illegal start of type return cap + b; ^ /Answer.java:64: error: ';' expected return cap + b; ^ /Answer.java:64: error: illegal start of type return cap + b; ^ /Answer.java:66: error: class, interface, or enum expected else if (x == 'c' || x == 'C'){ ^ /Answer.java:69: error: class, interface, or enum expected } ^ /Answer.java:71: error: class, interface, or enum expected } ^ /Answer.java:75: error: class, interface, or enum expected } ^ /Answer.java:77: error: class, interface, or enum expected } ^ /Answer.java:81: error: class, interface, or enum expected } ^ /Answer.java:83: error: class, interface, or enum expected } ^ /Answer.java:87: error: class, interface, or enum expected } ^ /Answer.java:89: error: class, interface, or enum expected } ^ </code></pre> <p>The error continues on just like the line 89 error for another 100 lines.</p>
0debug
int ff_mediacodec_dec_close(AVCodecContext *avctx, MediaCodecDecContext *s) { if (s->codec) { ff_AMediaCodec_delete(s->codec); s->codec = NULL; } if (s->format) { ff_AMediaFormat_delete(s->format); s->format = NULL; } return 0; }
1threat
How to insert a character at a certain position in a number without converting it into a string? : <p>I have to insert "/" between 2020 and 0001 in the number 20200001. I know how to do it by converting the number to string, but I am unable to do it by not converting it.</p>
0debug
Can I create a mySQL DatabaBase from Java code? : <p>I'm learning about JDBC.</p> <p>Can I create a mysql database from a java code?</p> <p>How can I make the connection?</p> <p>Thanks.</p>
0debug
sorecvoob(struct socket *so) { struct tcpcb *tp = sototcpcb(so); DEBUG_CALL("sorecvoob"); DEBUG_ARG("so = %p", so); soread(so); tp->snd_up = tp->snd_una + so->so_snd.sb_cc; tp->t_force = 1; tcp_output(tp); tp->t_force = 0; }
1threat
How to replace the buttons (attachment) only w/ Slack interactive buttons response : <p>I've managed to create a simple interactive button Slack app using a Google Apps Script (GAS). </p> <p>I know how to replace the original message w/ the response, but I would like to replace only the buttons, as demonstrated (but not clearly explained) multiple places in the Slack Interactive Button documentation:<br> <a href="https://api.slack.com/docs/message-buttons#crafting_your_message" rel="noreferrer">https://api.slack.com/docs/message-buttons#crafting_your_message</a></p> <p>I'd like to do what's demonstrated here: <a href="https://a.slack-edge.com/dcb1/img/api/message_guidelines/Example_6.gif" rel="noreferrer">https://a.slack-edge.com/dcb1/img/api/message_guidelines/Example_6.gif</a></p> <p>Is this an update of the original message, a replacement of the original message with identical text but different attachment, ...?</p> <p>My current interactive buttons message code looks like this: </p> <pre><code>function sendMsgWithButton() { // slack channel url (where to send the message) var slackUrl = "https://hooks.slack.com/services/..."; // message text var messageData = { "text": "Here's your interactive buttons message.", "attachments": [ { "text": "Can you click the button?", "fallback": "Sorry, no support for buttons.", "callback_id": "ptNotificationButtonResponse", "color": "#3AA3E3", "attachment_type": "default", "actions": [ { "name": "userResponse", "text": "OK", "style": "primary", "type": "button", "value": "ok" } ] } ] } // format for Slack var options = { 'method' : 'post', 'contentType': 'application/json', // Convert the JavaScript object to a JSON string. 'payload' : JSON.stringify(messageData) }; // post to Slack UrlFetchApp.fetch(slackUrl, options); } </code></pre> <p>My current action URL code right now looks like this:</p> <pre><code>function doPost() { var replyMessage = {"replace_original": true, "response_type": "in_channel", "text": "I see you clicked the button." }; return ContentService.createTextOutput(JSON.stringify(replyMessage)).setMimeType(ContentService.MimeType.JSON); } </code></pre> <p>Instead of replacing the entire original message, I'd like to replace just the buttons with something like a checkbox and confirmation message as demonstrated in the gif above.</p> <p>Thanks!</p>
0debug
uint8_t qpci_io_readb(QPCIDevice *dev, void *data) { uintptr_t addr = (uintptr_t)data; if (addr < QPCI_PIO_LIMIT) { return dev->bus->pio_readb(dev->bus, addr); } else { uint8_t val; dev->bus->memread(dev->bus, addr, &val, sizeof(val)); return val; } }
1threat
void qmp_block_dirty_bitmap_remove(const char *node, const char *name, Error **errp) { AioContext *aio_context; BlockDriverState *bs; BdrvDirtyBitmap *bitmap; bitmap = block_dirty_bitmap_lookup(node, name, &bs, &aio_context, errp); if (!bitmap || !bs) { return; } if (bdrv_dirty_bitmap_frozen(bitmap)) { error_setg(errp, "Bitmap '%s' is currently frozen and cannot be removed", name); goto out; } bdrv_dirty_bitmap_make_anon(bitmap); bdrv_release_dirty_bitmap(bs, bitmap); out: aio_context_release(aio_context); }
1threat
Char assignment to *char not working : <p>Here is a function used in my main. The issue lies in <code>char</code> assignment. </p> <pre><code>void takeTurn(int *iap, int *tile, char *cap) { //*iap is 1 right now printf("\nThe current active player is %d. His character is %c", *iap, *cap); //prints The current active player is 1. His character is q. if (*iap == 1) *cap == 'X'; if (*iap == 2) *cap == 'O'; printf("\nThe current active player is %d. His character is %c", *iap, *cap);. //prints The current active player is 1. His character is q. . . . } </code></pre> <p>What needs to be done so the <code>*cap</code> assigns the proper <code>char</code> to the proper active player? </p>
0debug
How does one detect if one is running within a docker container within Python? : <p>I was trying to find out if my script was running inside a docker container or not within the python script.</p> <p>Something like:</p> <pre><code>if inside_docker(): do_stuff() else: do_some_other_stuff() </code></pre> <p>to do this the only hacky way I found out how to do it is that I can inspect the hostname (with <code>platform.node()</code>) and if the hostname is not the same as my computer then its not in docker (since hostnames docker are some weird hash or something).</p> <p>Instead I was thinking something a bit more programatic as follows:</p> <ol> <li>first detect docker with <code>cat /proc/1/cgroup</code></li> <li>then compare the name those hierarchies with the docker id/hash.</li> </ol> <p>Something like:</p> <pre><code>from subprocess import call import platform hash = call('cat /proc/1/cgroup') hostname = hostname = platform.node() docker_boolean = does_hostname_contain_docker_hash(hash, hostname) # true or false </code></pre> <p>I thought something like that would work but I can't even get to call the <code>cat /proc/1/cgroup</code> without an error. If I am in docker I get the error:</p> <pre><code>&gt;&gt;&gt; from subprocess import call &gt;&gt;&gt; call('from subprocess import call') Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "/usr/lib/python2.7/subprocess.py", line 523, in call return Popen(*popenargs, **kwargs).wait() File "/usr/lib/python2.7/subprocess.py", line 711, in __init__ errread, errwrite) File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory </code></pre> <p>any ideas how to fix that?</p> <hr> <p>as a side node I was thinking of making my solution portable but docker is suppose to be portable already so if I am in docker this should always work...</p>
0debug
How to open modal ? : <p>I have a link in the top menu to add a new event. When I am on the events list page, this link open a modal with the new event form. Howether if I am on an other page, I would like this link (in the top menu) to redirect on this events list page with the modal new event form open.</p> <p>Is it possible ?</p> <p>Thanks for your help</p>
0debug
C++ alternative virtual typedef without templates : As many (relatively new?) users of C++, I would like to write virtual typedef something my_virtual_type; inside classes definitions. The most popular alternative seems to be templates, as for instance in http://stackoverflow.com/questions/14741442/alternative-to-virtual-typedef which provides a nice sum up. However I am not sure it covers everything a virtual typedef would. I present below a problem, for which I would like to have virtual typedefs. I have a (temporary?) working solution using overloading and not templates. I want to create a fancy tree structure, including iterators. 1) I define a `NodeIndex` type, ancestor of my future iterators. (`NodeIndex` is in my case `std::vector<unsigned int>`, but it doesn't matter.) 2) I define an abstract `BaseTree` class, used in my iterators bellow. The class includes in particular virtual methods which returns `NodeIndex` indexes to move in the tree (e.g. `NodeIndex begin()`), and `operator[](NodeIndex const&)`. 3) I define a `TreeBasicIterator` class, inheriting from `NodeIndex`, which for coherence purpose includes a const reference to a `BaseTree`, and implements various iterators methods (making use of the virtual methods provided by `BaseTree`). (I have actually two classes: `TreeBasicIterator`, and `Const_TreeBasicIterator` with a const reference to a `const BaseTree`; I use preprocessor macros to mimic a template based on const-ness, but this is another problem.) 4) I have defined a `TreeNode<T>` template class (`T` is the node content), inheriting from `BaseTree`. For now its `begin()` method returns a `NodeIndex`, and its `operator[]` takes a `NodeIndex` as argument, and everything works fine. 5) However I want to include my `TreeBasicIterator` in my `TreeNode` class. I would like to include a virtual typedef NodeIndex Iterator; in my `BaseTree` class, and modify the virtual `begin()` method signature to `Iterator begin()`. Then `TreeNode` would include a virtual typedef TreeBasicIterator Iterator; its `begin()` method signature would be `Iterator begin()`, and everything would be hopefully fine :) 6) I do not wish to use templates on `TreeBasicIterator`: it is now compiled once for all. Making `BaseTree` a template would make `TreeBasicIterator` a template, and so loose a part of the benefits of the abstraction in `BaseTree`. Instanciating `BaseTree` with `NodeIndex` as `Iterator` type would be superfluous: in practice nobody would inherit from that particular instance. 7) Prospective: I will use trees with a fixed or rarely modified structure, but more frequently modified node contents, and even much more frequently read accesses. To optimize access, I intend to further derive from `TreeNode` a `TreeVector` class, which will include a sorted exhaustive `std::vector` of `NodeIndex` (or `BasicTreeIterator`?) indexes. The `Iterator` virtual type in `TreeVector` would be std::iterator. 8) Current (temporary?) working solution: `TreeNode` defines (via a usual `typedef`) an `Iterator` type (my `TreeBasicIterator` class). It does not override an `Iterator` type from `BaseTree`, but it could. `BaseTree` has a `NodeIndex begin() const` method, which is both un-hidden, and overloaded in `TreeNode` by a `Iterator begin() const` method. Similarly, I have a `NodeIndex next_index(NodeIndex) const` in `BaseTree`, which is both un-hidden, and overloaded in `TreeNode` by a `Iterator next_index(Iterator) const` method.
0debug
int qcow2_backing_read1(BlockDriverState *bs, QEMUIOVector *qiov, int64_t sector_num, int nb_sectors) { int n1; if ((sector_num + nb_sectors) <= bs->total_sectors) return nb_sectors; if (sector_num >= bs->total_sectors) n1 = 0; else n1 = bs->total_sectors - sector_num; qemu_iovec_memset(qiov, 0, 512 * (nb_sectors - n1)); return n1; }
1threat
filter object_list in django templete : I am new in Django and have some problem: I create a template with object_list table and run in each object with loop: but I also need to have filter by substring then when the user will filter the table will updates online. I attch part from my code .. only the relvant I debug the code and get the expected querset both in server print to log and in response ajax call but I still need to refresh point_list in some way or to determine the filters inside the templete and not in the server? Any help??? -------------------------------------------- 1. I create view for this filter get the ajax request with substring value def filters_points(request): point_list = Point.objects.all() try: req = request.GET.get("filterData") if req: point_list = Point.objects.filter(onsitePointName__icontains=req) except AttributeError: print("failed") #qs_json = serializers.serialize('json', point_list) #return HttpResponse(qs_json, content_type='application/json') return render_to_response('point/point_list_update.html', {'point_list': point_list}) 2. in HTML templete: <input type="text" id="substring"> {% for point in point_list %} ... <td> {{ point.mangoId }} </td> <td> {{ point.onsitePointName }} </td> ....
0debug
static void mv88w8618_eth_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) { mv88w8618_eth_state *s = opaque; switch (offset) { case MP_ETH_SMIR: s->smir = value; break; case MP_ETH_PCXR: s->vlan_header = ((value >> MP_ETH_PCXR_2BSM_BIT) & 1) * 2; break; case MP_ETH_SDCMR: if (value & MP_ETH_CMD_TXHI) { eth_send(s, 1); } if (value & MP_ETH_CMD_TXLO) { eth_send(s, 0); } if (value & (MP_ETH_CMD_TXHI | MP_ETH_CMD_TXLO) && s->icr & s->imr) { qemu_irq_raise(s->irq); } break; case MP_ETH_ICR: s->icr &= value; break; case MP_ETH_IMR: s->imr = value; if (s->icr & s->imr) { qemu_irq_raise(s->irq); } break; case MP_ETH_FRDP0 ... MP_ETH_FRDP3: s->frx_queue[(offset - MP_ETH_FRDP0)/4] = value; break; case MP_ETH_CRDP0 ... MP_ETH_CRDP3: s->rx_queue[(offset - MP_ETH_CRDP0)/4] = s->cur_rx[(offset - MP_ETH_CRDP0)/4] = value; break; case MP_ETH_CTDP0 ... MP_ETH_CTDP3: s->tx_queue[(offset - MP_ETH_CTDP0)/4] = value; break; } }
1threat
C++ regex matching a single character : I'm trying to match a single character '=' in a line of code with regex. Example if(y == 5 || x = 1) { Do something ... } I want to match to the single '=', and not the "==". I've tried alot of combination of regex strings but I still can't get a match on the correct position.
0debug
Sort multiple arrays simultaneously "in place" : <p>I have the following 3 arrays: </p> <pre><code>int[] indexes = new int[]{0,2,8,5}; String[] sources = new String[]{"how", "are", "today", "you"}; String[] targets = new String[]{"I", "am", "thanks", "fine"}; </code></pre> <p>I want to sort the three arrays based on the indexes:</p> <pre><code>indexes -&gt; {0,2,5,8} sources -&gt; {"how", "are", "you", "today"} targets -&gt; {"I", "am", "fine", "thanks"} </code></pre> <p>I can create a new class <code>myClass</code> with all three elements:</p> <pre><code>class myClass { int x; String source; String target; } </code></pre> <p>Reassign everything to myClass, then sort <code>myClass</code> using <code>x</code>. However, this would required additional spaces. I am wondering if it is possible to do <code>in place</code> sorting? Thanks!</p>
0debug
What is event pooling in react? : <blockquote> <p>The SyntheticEvent is pooled. This means that the SyntheticEvent object will be reused and all properties will be nullified after the event callback has been invoked. This is for performance reasons. As such, you cannot access the event in an asynchronous way.</p> </blockquote> <p>refer : <a href="https://facebook.github.io/react/docs/events.html" rel="noreferrer">Event System in React</a></p>
0debug
static void test_visitor_in_errors(TestInputVisitorData *data, const void *unused) { TestStruct *p = NULL; Error *err = NULL; Visitor *v; strList *q = NULL; UserDefTwo *r = NULL; WrapAlternate *s = NULL; v = visitor_input_test_init(data, "{ 'integer': false, 'boolean': 'foo', " "'string': -42 }"); visit_type_TestStruct(v, NULL, &p, &err); error_free_or_abort(&err); g_assert(!p); v = visitor_input_test_init(data, "[ '1', '2', false, '3' ]"); visit_type_strList(v, NULL, &q, &err); error_free_or_abort(&err); assert(!q); v = visitor_input_test_init(data, "{ 'str':'hi' }"); visit_type_UserDefTwo(v, NULL, &r, &err); error_free_or_abort(&err); assert(!r); v = visitor_input_test_init(data, "{ }"); visit_type_WrapAlternate(v, NULL, &s, &err); error_free_or_abort(&err); assert(!s); }
1threat
static void gen_neon_zip_u8(TCGv t0, TCGv t1) { TCGv rd, rm, tmp; rd = new_tmp(); rm = new_tmp(); tmp = new_tmp(); tcg_gen_andi_i32(rd, t0, 0xff); tcg_gen_shli_i32(tmp, t1, 8); tcg_gen_andi_i32(tmp, tmp, 0xff00); tcg_gen_or_i32(rd, rd, tmp); tcg_gen_shli_i32(tmp, t0, 16); tcg_gen_andi_i32(tmp, tmp, 0xff0000); tcg_gen_or_i32(rd, rd, tmp); tcg_gen_shli_i32(tmp, t1, 24); tcg_gen_andi_i32(tmp, tmp, 0xff000000); tcg_gen_or_i32(rd, rd, tmp); tcg_gen_andi_i32(rm, t1, 0xff000000); tcg_gen_shri_i32(tmp, t0, 8); tcg_gen_andi_i32(tmp, tmp, 0xff0000); tcg_gen_or_i32(rm, rm, tmp); tcg_gen_shri_i32(tmp, t1, 8); tcg_gen_andi_i32(tmp, tmp, 0xff00); tcg_gen_or_i32(rm, rm, tmp); tcg_gen_shri_i32(tmp, t0, 16); tcg_gen_andi_i32(tmp, tmp, 0xff); tcg_gen_or_i32(t1, rm, tmp); tcg_gen_mov_i32(t0, rd); dead_tmp(tmp); dead_tmp(rm); dead_tmp(rd); }
1threat
What are the pros and cons of using AWS Code Deploy Vs Jenkins? : <p>We are using a bunch of EC2 instances which might scale in the future (around 100 instances), now we are looking towards auto deployments using either Jenkins or AWS Code deploy.</p> <p>I found that we can use AWS Code deploy plugin with Jenkins, but What are the pros and cons of following?</p> <p>1) Standalone AWS Code Deploy 2) Jenkins with AWS Code Deploy plugin.</p>
0debug
SQL distinc issues : Hi everyone I have a sql table in this format Screenname|realname|followers|tweet bob |jim |5 |hi bob |jim |20 |hello tom |joe |15 |JOETHECAT tim |joe |16 |TEST I need to write a query that displays each uniques screenname along with there realname and totalnumber of followers. Screename realname followers bob jim 25 tom joe 15 tim joe 16
0debug
Program that tells to delete a name in an arraylist when that name is on the list more than once : <p>Program that tells to delete a name on an ArrayList when that name is on the list twice. This is the part of the programIi need help on:</p> <pre><code>if (list.contains(nameToFind) &amp;&amp; int i = 1; i &lt; THIS IS WHERE I NEED HELP) System.out.println("Hey, that name is written twice on the list, edit or delete one of them!"); } else { System.out.println(" This name is only written once"); </code></pre>
0debug
static int realloc_refcount_array(BDRVQcowState *s, uint16_t **array, int64_t *size, int64_t new_size) { size_t old_byte_size, new_byte_size; uint16_t *new_ptr; old_byte_size = size_to_clusters(s, refcount_array_byte_size(s, *size)) * s->cluster_size; new_byte_size = size_to_clusters(s, refcount_array_byte_size(s, new_size)) * s->cluster_size; if (new_byte_size == old_byte_size) { *size = new_size; return 0; } assert(new_byte_size > 0); new_ptr = g_try_realloc(*array, new_byte_size); if (!new_ptr) { return -ENOMEM; } if (new_byte_size > old_byte_size) { memset((void *)((uintptr_t)new_ptr + old_byte_size), 0, new_byte_size - old_byte_size); } *array = new_ptr; *size = new_size; return 0; }
1threat
Edit a model comment Django : <p>I am stuck because I want to add a comment in my model and I do not know how to do it.</p> <p>Can you help me please ?</p> <p>Here is my form in forms.py:</p> <pre><code>class UpdateActu(forms.ModelForm): class Meta: model = models.Actu fields = ['commentaire'] widgets = { 'commentaire': forms.Textarea(attrs={'class': 'form-control', 'id': 'exampleTextarea'}) } </code></pre> <p>Here is my model :</p> <pre><code>class Actu(models.Model): commentaire = models.TextField(max_length=200, null=True) region = models.CharField(max_length=30, null=True) def __str__(self): return self.region </code></pre> <p>And here is my view :</p> <pre><code>def index_region(request,region): \\I delete the other part to have better visibility form = UpdateActu() context = { 'form': form, } return render(request, '../templates/index.html', context) </code></pre> <p>I know that currently, I just send my form but I do not know how to do the treatment to modify the old comment by the new one.</p> <p>Thank you in advance.</p>
0debug
var some = []['forEach']['constructor']; : <p>Im not able to understand this peice of javascript code please can anyone help me understand this.</p> <pre><code>var some = []['forEach']['constructor']; </code></pre>
0debug
def sector_area(r,a): pi=22/7 if a >= 360: return None sectorarea = (pi*r**2) * (a/360) return sectorarea
0debug
static av_cold int find_component(OMXContext *omx_context, void *logctx, const char *role, char *str, int str_size) { OMX_U32 i, num = 0; char **components; int ret = 0; #if CONFIG_OMX_RPI if (av_strstart(role, "video_encoder.", NULL)) { av_strlcpy(str, "OMX.broadcom.video_encode", str_size); return 0; } #endif omx_context->ptr_GetComponentsOfRole((OMX_STRING) role, &num, NULL); if (!num) { av_log(logctx, AV_LOG_WARNING, "No component for role %s found\n", role); return AVERROR_ENCODER_NOT_FOUND; } components = av_mallocz(sizeof(char*) * num); if (!components) return AVERROR(ENOMEM); for (i = 0; i < num; i++) { components[i] = av_mallocz(OMX_MAX_STRINGNAME_SIZE); if (!components) { ret = AVERROR(ENOMEM); goto end; } } omx_context->ptr_GetComponentsOfRole((OMX_STRING) role, &num, (OMX_U8**) components); av_strlcpy(str, components[0], str_size); end: for (i = 0; i < num; i++) av_free(components[i]); av_free(components); return ret; }
1threat
Are these lines acceptable to be inlined in C++? : <p>I am working on a mathematical vector. </p> <p>I usually inline these types of class function members:</p> <pre><code>float getY() const { return m_y; } </code></pre> <p>But are these suitable to be inlined? </p> <pre><code>float getLength() const { return sqrt(m_x * m_x + m_y * m_y); } bool isUnitVector() const { return getLength() == 1.0f; } Vector2D getZeroVector() const { return Vector2D(); } </code></pre>
0debug
static bool remove_objects(BDRVSheepdogState *s) { int fd, i = 0, nr_objs = 0; Error *local_err = NULL; int ret = 0; bool result = true; SheepdogInode *inode = &s->inode; fd = connect_to_sdog(s, &local_err); if (fd < 0) { error_report_err(local_err); return false; } nr_objs = count_data_objs(inode); while (i < nr_objs) { int start_idx, nr_filled_idx; while (i < nr_objs && !inode->data_vdi_id[i]) { i++; } start_idx = i; nr_filled_idx = 0; while (i < nr_objs && nr_filled_idx < NR_BATCHED_DISCARD) { if (inode->data_vdi_id[i]) { inode->data_vdi_id[i] = 0; nr_filled_idx++; } i++; } ret = write_object(fd, s->bs, (char *)&inode->data_vdi_id[start_idx], vid_to_vdi_oid(s->inode.vdi_id), inode->nr_copies, (i - start_idx) * sizeof(uint32_t), offsetof(struct SheepdogInode, data_vdi_id[start_idx]), false, s->cache_flags); if (ret < 0) { error_report("failed to discard snapshot inode."); result = false; goto out; } } out: closesocket(fd); return result; }
1threat
mysqldump syntax error - password being used as database name : <p>I'm trying to duplicate a MySQL (5.5.64-MariaDB) database on the same server by following this guide: <a href="https://stackoverflow.com/questions/675289/cloning-a-mysql-database-on-the-same-mysql-instance">Cloning a MySQL database on the same MySql instance</a></p> <p>The accepted answer didn't work so I reviewed the docs over at MySQL and found that the <a href="https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#mysqldump-option-summary" rel="nofollow noreferrer">mysqldump Options</a> used <code>--user</code> and <code>--password</code> instead of the <code>-u</code> and <code>-p</code> flags on the linked post.</p> <p>When I execute this:</p> <pre><code>mysqldump --user myUser --password myPassword dev_db | mysql -umyUser -pmyPassword staging_db </code></pre> <p>It firstly asks me to enter a password:</p> <blockquote> <p>Enter password: </p> </blockquote> <p>So I enter <code>myPassword</code> although unsure why as it's given in the arguments list.</p> <p>Then it gives the following error:</p> <blockquote> <p>mysqldump: Got error: 1049: "Unknown database 'myPassword'" when selecting the database</p> </blockquote> <p>If I try entering the <code>--username</code> and <code>--password</code> <em>without spaces</em>:</p> <pre><code>mysqldump --usermyUser --passwordmyPassword dev_db | mysql -umyUser -pmyPassword staging_db </code></pre> <p>It errors</p> <blockquote> <p>mysqldump: unknown option '--usermyUser'</p> </blockquote> <p>The intention of this is to copy <code>dev_db</code> into a database called <code>staging_db</code>. Both of these databases exist on the same server. The username/password I'm using has full access to every database on the MySQL instance.</p> <p>Why doesn't this work?</p> <p>If I use:</p> <pre><code>$ mysql -umyUser -pmyPassword </code></pre> <p>It connects without any issue and gives me the MariaDB command prompt.</p> <p>Server is running CentOS Linux release 7.7.1908 (Core) </p> <p>Database version:</p> <pre><code>$ mysql -V mysql Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1 </code></pre>
0debug
Strange behaviour (for me) with ifPresentOrElse of an Optional. (JAVA8) : I have the following code: Optional<Person> oldestPerson = personenListe.stream().collect(Collectors.reducing(maxAge)); Consumer<Person> personPrinter = p -> System.out.println("The oldest is : " + p.getName()); Runnable noPersonMessagePrinter = () -> System.out.println("There is no person"); oldestPerson.ifPresentOrElse(personPrinter,noPersonMessagePrinter ); My IDE underlines ifPresentOrElse as red, because it doesn't find the signiture, but from my view it should be correct. Any guess ?
0debug
Why is my asynchronous writeFile method behaving sychronously? : I have a simple .js file that reads a text file and the writes it and reads the changed file. For learning purposes, I have implemented the below code. When the control reaches writeFile, shouldn't it be running in the background and the control should go to the console.log("Test") line and then back to the writeFile ? But it actually fully exceutes the writeFile and control goes to the log line which is basically a synchronous behaviour. Am I missing something here ? `console.log("Begin") var fs = require("fs"); fs.readFile("input.txt", function(err, data){ if(err){ console.log(err); } else{ console.log("Inside Read " + data.toString()); fs.writeFile("input.txt", "Replaced Text" , function(err){ if(err){ console.log(err); } else{ console.log("Inside Write"); var data = fs.readFileSync("Input.txt") console.log(data + " is the replaced text"); } console.log("Test2"); } ); } } ); console.log("Ended");`
0debug
I am doing spring and hibernet integration example getting the below exception. Please advise me that how to solve it : log4j:WARN No appenders could be found for logger (org.springframework.beans.factory.xml.XmlBeanDefinitionReader). log4j:WARN Please initialize the log4j system properly. Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'd' is defined at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:509) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1041) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:273) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) at com.javatpoint.InsertTest.main(InsertTest.java:14)
0debug
Whats is the difference between mysql and sql? : <p>Whats is the difference between mysql and sql ? Please explain with code.</p>
0debug
AddressSpace *pci_device_iommu_address_space(PCIDevice *dev) { PCIBus *bus = PCI_BUS(dev->bus); if (bus->iommu_fn) { return bus->iommu_fn(bus, bus->iommu_opaque, dev->devfn); } if (bus->parent_dev) { return pci_device_iommu_address_space(bus->parent_dev); } return &address_space_memory; }
1threat
I have a function in java which may have bug and I can not find it : <p>I have this code which suppose to do the following task: For example , given M=3, and array built like this:</p> <pre><code>A[0]=1 A[1]=1 A[2]=3 A[3]=3 A[4]=5 A[5]=1 A[6]=3 </code></pre> <p>the function may return 1 or 3</p> <pre><code>import java.util.*; class Solution { int solution(int M, int[] A) { int N = A.length; int[] count = new int[M + 1]; for (int i = 0; i &lt;= M; i++) count[i] = 0; int maxOccurence = 1; int index = -1; for (int i = 0; i &lt; N; i++) { if (count[A[i]] &gt; 0) { int tmp = count[A[i]]; if (tmp &gt; maxOccurence) { maxOccurence = tmp; index = i; } count[A[i]] = tmp + 1; } else { count[A[i]] = 1; } } return A[index]; } } </code></pre> <p>what could be the problem because it is not always working and I can see there is a bug in my program.</p>
0debug
Object.assign—override nested property : <p>I have an Object <code>a</code> like that:</p> <pre><code>const a = { user: { … groups: […] … } } </code></pre> <p>whereby there are a lot more properties in <code>a.user</code></p> <p>And I would like to change only the <code>a.user.groups</code> value. If I do this:</p> <pre><code>const b = Object.assign({}, a, { user: { groups: {} } }); </code></pre> <p><code>b</code> doesn't have any other Property except <code>b.user.groups</code>, all others are deleted. Is there any ES6 way to only change the nested property, without loosing all the other, with <code>Object.assign</code>?</p>
0debug
Why have to use value.length? : <p>guys.....Please help!!!</p> <p><a href="https://i.stack.imgur.com/ZFaRN.png" rel="nofollow noreferrer">This is the picture of a textbook page that I'm reading</a></p> <p>So I'm reading this textbook which is totally horrible, they just give codes out without any explanation.....And this is my first class in Java, I've never coded in any language before......So like a textbook without explanation just totally....you know....give me a super hard time....</p> <p>Back to topic, in the picture, there are 2 sets of codes, A and B.....I understand B......But I do not get why in A, it used <code>value.length</code> instead of <code>inputs.length</code>? Isn't the array name in this code is <code>inputs</code>??? Is there any specific reason has to use <code>value.length</code> instead of <code>array name.length</code>???</p>
0debug
static void gen_flt3_arith (DisasContext *ctx, uint32_t opc, int fd, int fr, int fs, int ft) { const char *opn = "flt3_arith"; gen_op_cp1_64bitmode(); switch (opc) { case OPC_ALNV_PS: GEN_LOAD_REG_TN(T0, fr); GEN_LOAD_FREG_FTN(DT0, fs); GEN_LOAD_FREG_FTN(DT1, ft); gen_op_float_alnv_ps(); GEN_STORE_FTN_FREG(fd, DT2); opn = "alnv.ps"; break; case OPC_MADD_S: GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WT1, ft); GEN_LOAD_FREG_FTN(WT2, fr); gen_op_float_muladd_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "madd.s"; break; case OPC_MADD_D: GEN_LOAD_FREG_FTN(DT0, fs); GEN_LOAD_FREG_FTN(DT1, ft); GEN_LOAD_FREG_FTN(DT2, fr); gen_op_float_muladd_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "madd.d"; break; case OPC_MADD_PS: GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); GEN_LOAD_FREG_FTN(WT1, ft); GEN_LOAD_FREG_FTN(WTH1, ft); GEN_LOAD_FREG_FTN(WT2, fr); GEN_LOAD_FREG_FTN(WTH2, fr); gen_op_float_muladd_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "madd.ps"; break; case OPC_MSUB_S: GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WT1, ft); GEN_LOAD_FREG_FTN(WT2, fr); gen_op_float_mulsub_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "msub.s"; break; case OPC_MSUB_D: GEN_LOAD_FREG_FTN(DT0, fs); GEN_LOAD_FREG_FTN(DT1, ft); GEN_LOAD_FREG_FTN(DT2, fr); gen_op_float_mulsub_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "msub.d"; break; case OPC_MSUB_PS: GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); GEN_LOAD_FREG_FTN(WT1, ft); GEN_LOAD_FREG_FTN(WTH1, ft); GEN_LOAD_FREG_FTN(WT2, fr); GEN_LOAD_FREG_FTN(WTH2, fr); gen_op_float_mulsub_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "msub.ps"; break; case OPC_NMADD_S: GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WT1, ft); GEN_LOAD_FREG_FTN(WT2, fr); gen_op_float_nmuladd_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "nmadd.s"; break; case OPC_NMADD_D: GEN_LOAD_FREG_FTN(DT0, fs); GEN_LOAD_FREG_FTN(DT1, ft); GEN_LOAD_FREG_FTN(DT2, fr); gen_op_float_nmuladd_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "nmadd.d"; break; case OPC_NMADD_PS: GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); GEN_LOAD_FREG_FTN(WT1, ft); GEN_LOAD_FREG_FTN(WTH1, ft); GEN_LOAD_FREG_FTN(WT2, fr); GEN_LOAD_FREG_FTN(WTH2, fr); gen_op_float_nmuladd_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "nmadd.ps"; break; case OPC_NMSUB_S: GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WT1, ft); GEN_LOAD_FREG_FTN(WT2, fr); gen_op_float_nmulsub_s(); GEN_STORE_FTN_FREG(fd, WT2); opn = "nmsub.s"; break; case OPC_NMSUB_D: GEN_LOAD_FREG_FTN(DT0, fs); GEN_LOAD_FREG_FTN(DT1, ft); GEN_LOAD_FREG_FTN(DT2, fr); gen_op_float_nmulsub_d(); GEN_STORE_FTN_FREG(fd, DT2); opn = "nmsub.d"; break; case OPC_NMSUB_PS: GEN_LOAD_FREG_FTN(WT0, fs); GEN_LOAD_FREG_FTN(WTH0, fs); GEN_LOAD_FREG_FTN(WT1, ft); GEN_LOAD_FREG_FTN(WTH1, ft); GEN_LOAD_FREG_FTN(WT2, fr); GEN_LOAD_FREG_FTN(WTH2, fr); gen_op_float_nmulsub_ps(); GEN_STORE_FTN_FREG(fd, WT2); GEN_STORE_FTN_FREG(fd, WTH2); opn = "nmsub.ps"; break; default: MIPS_INVAL(opn); generate_exception (ctx, EXCP_RI); return; } MIPS_DEBUG("%s %s, %s, %s, %s", opn, fregnames[fd], fregnames[fr], fregnames[fs], fregnames[ft]); }
1threat
static int xio3130_upstream_initfn(PCIDevice *d) { PCIBridge* br = DO_UPCAST(PCIBridge, dev, d); PCIEPort *p = DO_UPCAST(PCIEPort, br, br); int rc; int tmp; rc = pci_bridge_initfn(d); if (rc < 0) { return rc; } pcie_port_init_reg(d); pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_TI); pci_config_set_device_id(d->config, PCI_DEVICE_ID_TI_XIO3130U); d->config[PCI_REVISION_ID] = XIO3130_REVISION; rc = msi_init(d, XIO3130_MSI_OFFSET, XIO3130_MSI_NR_VECTOR, XIO3130_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_64BIT, XIO3130_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_MASKBIT); if (rc < 0) { goto err_bridge; } rc = pci_bridge_ssvid_init(d, XIO3130_SSVID_OFFSET, XIO3130_SSVID_SVID, XIO3130_SSVID_SSID); if (rc < 0) { goto err_bridge; } rc = pcie_cap_init(d, XIO3130_EXP_OFFSET, PCI_EXP_TYPE_UPSTREAM, p->port); if (rc < 0) { goto err_msi; } pcie_cap_flr_init(d); pcie_cap_deverr_init(d); rc = pcie_aer_init(d, XIO3130_AER_OFFSET); if (rc < 0) { goto err; } return 0; err: pcie_cap_exit(d); err_msi: msi_uninit(d); err_bridge: tmp = pci_bridge_exitfn(d); assert(!tmp); return rc; }
1threat
Calling parent method inside child class python : <p>Here is my code:</p> <pre><code>class GUI(playGame): def __init__(self): import tkinter as tk home=tk.Tk() home.title("Tic Tac Toe") home.geometry("160x180") w,h=6,3 self.c1r1=tk.Button(text='',width=w, height=h, command=lambda: userTurn(self.c1r1)) self.c1r1.grid(column=1,row=1) home.mainloop() </code></pre> <p>So, userTurn has been defined in the parent class playGame but when I run this and click on the button c1r1, I get NameError: name 'userTurn' is not defined</p>
0debug
How do I hash the password? : <p>I'm making custom registration form in laravel. When I submit this, in database the password is not being hashed. How do I hash the following password?</p> <pre><code>&lt;div class="form-group"&gt; {{ Form::label('password', 'Password:') }} {{ Form::password('password', ['class' =&gt; 'form-control', 'placeholder' =&gt; 'Password', 'required' =&gt; 'true']) }} &lt;/div&gt; </code></pre> <p>Thank you</p>
0debug
void qht_statistics_init(struct qht *ht, struct qht_stats *stats) { struct qht_map *map; int i; map = atomic_rcu_read(&ht->map); stats->head_buckets = map->n_buckets; stats->used_head_buckets = 0; stats->entries = 0; qdist_init(&stats->chain); qdist_init(&stats->occupancy); for (i = 0; i < map->n_buckets; i++) { struct qht_bucket *head = &map->buckets[i]; struct qht_bucket *b; unsigned int version; size_t buckets; size_t entries; int j; do { version = seqlock_read_begin(&head->sequence); buckets = 0; entries = 0; b = head; do { for (j = 0; j < QHT_BUCKET_ENTRIES; j++) { if (atomic_read(&b->pointers[j]) == NULL) { break; } entries++; } buckets++; b = atomic_rcu_read(&b->next); } while (b); } while (seqlock_read_retry(&head->sequence, version)); if (entries) { qdist_inc(&stats->chain, buckets); qdist_inc(&stats->occupancy, (double)entries / QHT_BUCKET_ENTRIES / buckets); stats->used_head_buckets++; stats->entries += entries; } else { qdist_inc(&stats->occupancy, 0); } } }
1threat
Does Elm have a debugging function that can print an object to the console? : <p>I would like to be able to examine a runtime javascript object. Can I print an object to the console instead of a string?</p>
0debug
Python code looping when I don't want it to : <pre><code>x = 0 while True: choice = int(input ("Choose 1 or 2")) if choice == 2: print("You chose 2") x == 1 if choice == 1: print("You chose 1") x == 1 if choice &gt;2: print("I said 1 or 2.") x == 0 if choice &lt;1: print("I said 1 or 2") x == 0 </code></pre> <p>So if I choose 1 or 2 I want it to stop but if I choose otherwise I want it to loop but it's looping always no matter what could somebody help with this?</p>
0debug
static inline void RENAME(rgb32to15)(const uint8_t *src, uint8_t *dst, long src_size) { const uint8_t *s = src; const uint8_t *end; #ifdef HAVE_MMX const uint8_t *mm_end; #endif uint16_t *d = (uint16_t *)dst; end = s + src_size; #ifdef HAVE_MMX mm_end = end - 15; #if 1 asm volatile( "movq %3, %%mm5 \n\t" "movq %4, %%mm6 \n\t" "movq %5, %%mm7 \n\t" "jmp 2f \n\t" ASMALIGN(4) "1: \n\t" PREFETCH" 32(%1) \n\t" "movd (%1), %%mm0 \n\t" "movd 4(%1), %%mm3 \n\t" "punpckldq 8(%1), %%mm0 \n\t" "punpckldq 12(%1), %%mm3 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm3, %%mm4 \n\t" "pand %%mm6, %%mm0 \n\t" "pand %%mm6, %%mm3 \n\t" "pmaddwd %%mm7, %%mm0 \n\t" "pmaddwd %%mm7, %%mm3 \n\t" "pand %%mm5, %%mm1 \n\t" "pand %%mm5, %%mm4 \n\t" "por %%mm1, %%mm0 \n\t" "por %%mm4, %%mm3 \n\t" "psrld $6, %%mm0 \n\t" "pslld $10, %%mm3 \n\t" "por %%mm3, %%mm0 \n\t" MOVNTQ" %%mm0, (%0) \n\t" "add $16, %1 \n\t" "add $8, %0 \n\t" "2: \n\t" "cmp %2, %1 \n\t" " jb 1b \n\t" : "+r" (d), "+r"(s) : "r" (mm_end), "m" (mask3215g), "m" (mask3216br), "m" (mul3215) ); #else __asm __volatile(PREFETCH" %0"::"m"(*src):"memory"); __asm __volatile( "movq %0, %%mm7\n\t" "movq %1, %%mm6\n\t" ::"m"(red_15mask),"m"(green_15mask)); while(s < mm_end) { __asm __volatile( PREFETCH" 32%1\n\t" "movd %1, %%mm0\n\t" "movd 4%1, %%mm3\n\t" "punpckldq 8%1, %%mm0\n\t" "punpckldq 12%1, %%mm3\n\t" "movq %%mm0, %%mm1\n\t" "movq %%mm0, %%mm2\n\t" "movq %%mm3, %%mm4\n\t" "movq %%mm3, %%mm5\n\t" "psrlq $3, %%mm0\n\t" "psrlq $3, %%mm3\n\t" "pand %2, %%mm0\n\t" "pand %2, %%mm3\n\t" "psrlq $6, %%mm1\n\t" "psrlq $6, %%mm4\n\t" "pand %%mm6, %%mm1\n\t" "pand %%mm6, %%mm4\n\t" "psrlq $9, %%mm2\n\t" "psrlq $9, %%mm5\n\t" "pand %%mm7, %%mm2\n\t" "pand %%mm7, %%mm5\n\t" "por %%mm1, %%mm0\n\t" "por %%mm4, %%mm3\n\t" "por %%mm2, %%mm0\n\t" "por %%mm5, %%mm3\n\t" "psllq $16, %%mm3\n\t" "por %%mm3, %%mm0\n\t" MOVNTQ" %%mm0, %0\n\t" :"=m"(*d):"m"(*s),"m"(blue_15mask):"memory"); d += 4; s += 16; } #endif __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); #endif while(s < end) { register int rgb = *(uint32_t*)s; s += 4; *d++ = ((rgb&0xFF)>>3) + ((rgb&0xF800)>>6) + ((rgb&0xF80000)>>9); } }
1threat
static inline void mpeg_motion(MpegEncContext *s, UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr, int dest_offset, UINT8 **ref_picture, int src_offset, int field_based, op_pixels_func *pix_op, int motion_x, int motion_y, int h) { UINT8 *ptr; int dxy, offset, mx, my, src_x, src_y, height, linesize; if(s->quarter_sample) { motion_x>>=1; motion_y>>=1; } dxy = ((motion_y & 1) << 1) | (motion_x & 1); src_x = s->mb_x * 16 + (motion_x >> 1); src_y = s->mb_y * (16 >> field_based) + (motion_y >> 1); height = s->height >> field_based; src_x = clip(src_x, -16, s->width); if (src_x == s->width) dxy &= ~1; src_y = clip(src_y, -16, height); if (src_y == height) dxy &= ~2; linesize = s->linesize << field_based; ptr = ref_picture[0] + (src_y * linesize) + (src_x) + src_offset; dest_y += dest_offset; pix_op[dxy](dest_y, ptr, linesize, h); pix_op[dxy](dest_y + 8, ptr + 8, linesize, h); if (s->out_format == FMT_H263) { dxy = 0; if ((motion_x & 3) != 0) dxy |= 1; if ((motion_y & 3) != 0) dxy |= 2; mx = motion_x >> 2; my = motion_y >> 2; } else { mx = motion_x / 2; my = motion_y / 2; dxy = ((my & 1) << 1) | (mx & 1); mx >>= 1; my >>= 1; } src_x = s->mb_x * 8 + mx; src_y = s->mb_y * (8 >> field_based) + my; src_x = clip(src_x, -8, s->width >> 1); if (src_x == (s->width >> 1)) dxy &= ~1; src_y = clip(src_y, -8, height >> 1); if (src_y == (height >> 1)) dxy &= ~2; offset = (src_y * (linesize >> 1)) + src_x + (src_offset >> 1); ptr = ref_picture[1] + offset; pix_op[dxy](dest_cb + (dest_offset >> 1), ptr, linesize >> 1, h >> 1); ptr = ref_picture[2] + offset; pix_op[dxy](dest_cr + (dest_offset >> 1), ptr, linesize >> 1, h >> 1); }
1threat
static int mpjpeg_read_probe(AVProbeData *p) { AVIOContext *pb; char line[128] = { 0 }; int ret = 0; pb = avio_alloc_context(p->buf, p->buf_size, 0, NULL, NULL, NULL, NULL); if (!pb) return AVERROR(ENOMEM); if (p->buf_size < 2 || p->buf[0] != '-' || p->buf[1] != '-') return 0; while (!pb->eof_reached) { ret = get_line(pb, line, sizeof(line)); if (ret < 0) break; ret = check_content_type(line); if (!ret) { ret = AVPROBE_SCORE_MAX; break; } } av_free(pb); return ret; }
1threat
static int do_cont(Monitor *mon, const QDict *qdict, QObject **ret_data) { struct bdrv_iterate_context context = { mon, 0 }; if (incoming_expected) { qerror_report(QERR_MIGRATION_EXPECTED); return -1; } bdrv_iterate(encrypted_bdrv_it, &context); if (!context.err) { vm_start(); return 0; } else { return -1; } }
1threat
static unsigned int mszh_decomp(unsigned char * srcptr, int srclen, unsigned char * destptr, unsigned int destsize) { unsigned char *destptr_bak = destptr; unsigned char *destptr_end = destptr + destsize; unsigned char mask = 0; unsigned char maskbit = 0; unsigned int ofs, cnt; while (srclen > 0 && destptr < destptr_end) { if (maskbit == 0) { mask = *srcptr++; maskbit = 8; srclen--; continue; } if ((mask & (1 << (--maskbit))) == 0) { if (destptr + 4 > destptr_end) break; memcpy(destptr, srcptr, 4); srclen -= 4; destptr += 4; srcptr += 4; } else { ofs = *srcptr++; cnt = *srcptr++; ofs += cnt * 256; cnt = ((cnt >> 3) & 0x1f) + 1; ofs &= 0x7ff; srclen -= 2; cnt *= 4; if (destptr + cnt > destptr_end) { cnt = destptr_end - destptr; } for (; cnt > 0; cnt--) { *destptr = *(destptr - ofs); destptr++; } } } return destptr - destptr_bak; }
1threat
Error in global variable : <p>When I start my game and it opens to the menu I keep getting the error. "SyntaxWarning: name 'finishes' is assigned to before global declaration". I doesn't disrupt the game but it is just annoying, any ideas on how to fix it?</p> <pre><code>def load_level(level): walls = [] players = [] finishes = [] x = y = 0 for row in levels[level]: for col in row: if col == "W": walls.append(Wall((x, y))) if col == "P": players.append(Player((x, y))) if col == "F": finishes.append(Finish1((x, y))) if col == "G": finishes.append(Finish2((x, y))) if col == "H": finishes.append(Finish3((x, y))) if col == "I": finishes.append(Finish4((x, y))) x += 40.96 y += 30.72 x = 0 return walls, players, finishes walls, players, finishes = load_level(currentLevel) def Menu(): runnin = True while runnin: clock.tick(60) screen.fill(BLACK) mouseclick = pygame.mouse.get_pressed() for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit(0) if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: pygame.quit() sys.exit(0) for option in options: if option.rect.collidepoint(pygame.mouse.get_pos()): option.hovered = True if mouseclick[0] == 1: if option.text == "Easy": walls, players, finishes = load_level(0) global currentlevel, walls, players, finishes currentlevel = 0 main() elif option.text == "Medium": walls, players, finishes = load_level(1) global currentlevel, walls, players, finishes currentlevel = 1 main() elif option.text == "Hard": walls, players, finishes = load_level(2) global currentlevel, walls, players, finishes currentlevel = 2 main() else: runnin = False else: option.hovered = False option.draw() pygame.display.update() pygame.quit() sys.exit(0) </code></pre>
0debug
Seaborn Heatmap Colorbar Label as Percentage : <p>Given this heat map:</p> <pre><code>import numpy as np; np.random.seed(0) import seaborn as sns; sns.set() uniform_data = np.random.rand(10, 12) ax = sns.heatmap(uniform_data) </code></pre> <p>How would I go about making the color bar values display in percent format? Also, what if I just wanted to show the first and last values on the color bar?</p> <p>Thanks in advance!</p>
0debug
Python slicing explained : <p>OK I understand the basics, but can someone explain code copied from Greg's answer <a href="https://stackoverflow.com/questions/509211/understanding-pythons-slice-notation">here</a>:</p> <pre><code>a[1::-1] # the first two items, reversed a[:-3:-1] # the last two items a[-3::-1] # everything except the last two items, reversed </code></pre> <p>To me the first one reads: slice from 2nd position to end, then reverse it.</p> <p>The second one is slice from beginning to the -2 position then reverse it.</p> <p>The third one is slice from -3rd position to end then reverse it.</p> <p>Obviously I am wrong since they work as suggested, but can you please tell me why?</p>
0debug
cannot resolve method setcontentview(android.widget.TextView) : <p>How to setContentView in a fragment? I having error with setContentView(tvv); Any helps will be appreciated. </p> <p><a href="http://i.stack.imgur.com/sGpxy.png" rel="nofollow">image</a></p> <p>Continue</p> <pre><code> Button btnBF = (Button) view.findViewById(R.id.btnBF); btnBF.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(v.getContext(),SelectImage.class); startActivityForResult(intent, 0); } }); return view; } } </code></pre>
0debug
how to silence warnings about ignored files in eslint : <p>After setting up <code>eslint</code> and adding some files in the ignore list, every time that eslint is run it produces warnings about files that are ignored:</p> <pre><code> /path/to/file/name.min.js 0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override </code></pre> <p>How can this warning be silenced?</p>
0debug
How would I modify this to put it into a function? : <pre><code>question_prompts = [ "What color are Apples?\n(a) Red/Green\n(b) Purple\n(c) Orange\n\n", "What color are Bananas?\n(a) Blue\n(b) Yellow\n(c) Green\n\n", "What color are Strawberries?\n(a) Red\n(b) Blue\n(c) Green\n\n" ] def main_questions(): </code></pre> <p>These are a set of three questions, and they have three answers which I didn't post. I'm trying to figure out how I would put this in the function called main_questions(): I am a beginner, I've looked at multiple articles but can't seem to understand them. Help please?</p>
0debug
void do_405_check_ov (void) { if (likely(((T1 ^ T2) >> 31) || !((T0 ^ T2) >> 31))) { xer_ov = 0; } else { xer_ov = 1; xer_so = 1; } }
1threat
I Copied the code recommended by google, howeverI receive a syntax error : So I copied the python code that google cloud recommends to you, iv tried it in Jyputer notebooks and as a python file but I still get syntax error def predict(content, project_id, model_id): print predict("1.jpg", ispace-254720, ICN886814670746214838) File "<ipython-input-16-a9c7141e2bf3>", line 1 print predict("1.jpg", ispace-254720, ICN886814670746214838) ^ SyntaxError: invalid syntax
0debug
Can I have multiple service workers both intercept the same fetch request? : <p>I'm writing a library which I will provide for 3rd parties to run a service worker on their site. It needs to intercept all network requests but I want to allow them to build their own service worker if they like.</p> <p>Can I have both service workers intercept the same fetches and provide some kind of priority/ordering between them? Alternatively is there some other pattern I should be using?</p> <p>Thanks</p>
0debug
php write succesful logins and unsuccesful to text file : Hey guys i've been trying to write my succesful logins/failed logins to a txt file but it doesn't work. Can anyone please take a look at the code? if($_POST['username']==$username && $_POST['password']==$password) // Check Given user name, password and Variable user name password are same { $_SESSION['username']=$username; // set session from given user name header('location:mainpage.php'); $logInData = date('Ymd-H:i:s'); $logLogIn = fopen("../logs/logins.txt", "a"); $txt = "\r\n$logInData, You logged in Succesfully"; fwrite($logLogIn, $txt); fclose($logLogIn); } else { $err="Authentication Failed Try again!"; $logInData = date('Ymd-H:i:s'); $logLogIn = fopen("../logs/logins.txt", "a"); $txt = "\r\n$logInData, Login failed wrong username or password"; fwrite($logLogIn, $txt); fclose($logLogIn); } I get the following errors : Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/rans1600/public_html/D093G/moment2/index.php on line 32 Warning: fclose() expects parameter 1 to be resource, boolean given in /home/rans1600/public_html/D093G/moment2/index.php on line 33 Authentication Failed Try again!
0debug
DataGrip: how to connect to Oracle as SYSDBA : <p>I tried to setup in <a href="https://www.jetbrains.com/datagrip/" rel="noreferrer">DataGrip</a> an Oracle connection under SYS user.</p> <p>But got error:</p> <blockquote> <p>ORA-28009: connection as SYS should be as SYSDBA or SYSOPER</p> </blockquote> <p>But there is no option in GUI to choose <code>as SYSDBA</code> option.</p>
0debug
C++ delete a pointer (free memory) : <p>Consider the following code:</p> <pre><code>int a = 10; int * b = &amp;a; int * c = b; delete b; // equivalent to delete c; </code></pre> <p>Am I correct to understand in the last line, <code>delete b</code> and <code>delete c</code> are equivalent, and that both will free the memory space holding <code>a</code>, thus <code>a</code> is no longer accessible?</p>
0debug
Rounding numbers to a specific value in Python : <p>I would like to do in python rounding to the specified value. Rounded to a tip or .99, 9.99 or other value. The value can by dynamic. Example:</p> <p>Rounded to .99</p> <pre><code>20.11 =&gt; 20.99 11.33 = 11.99 1.00 = 1.99 </code></pre> <p>Rounded to 9.99</p> <pre><code>100 =&gt; 109.99 293.33 =&gt; 299.99 </code></pre> <p>Rounded to 0.33</p> <pre><code>1 =&gt; 1.33 34.44 =&gt; 35.33 </code></pre> <p>How do that?</p>
0debug
set_mdic(E1000State *s, int index, uint32_t val) { uint32_t data = val & E1000_MDIC_DATA_MASK; uint32_t addr = ((val & E1000_MDIC_REG_MASK) >> E1000_MDIC_REG_SHIFT); if ((val & E1000_MDIC_PHY_MASK) >> E1000_MDIC_PHY_SHIFT != 1) val = s->mac_reg[MDIC] | E1000_MDIC_ERROR; else if (val & E1000_MDIC_OP_READ) { DBGOUT(MDIC, "MDIC read reg 0x%x\n", addr); if (!(phy_regcap[addr] & PHY_R)) { DBGOUT(MDIC, "MDIC read reg %x unhandled\n", addr); val |= E1000_MDIC_ERROR; } else val = (val ^ data) | s->phy_reg[addr]; } else if (val & E1000_MDIC_OP_WRITE) { DBGOUT(MDIC, "MDIC write reg 0x%x, value 0x%x\n", addr, data); if (!(phy_regcap[addr] & PHY_W)) { DBGOUT(MDIC, "MDIC write reg %x unhandled\n", addr); val |= E1000_MDIC_ERROR; } else { if (addr < NPHYWRITEOPS && phyreg_writeops[addr]) { phyreg_writeops[addr](s, index, data); } s->phy_reg[addr] = data; } } s->mac_reg[MDIC] = val | E1000_MDIC_READY; if (val & E1000_MDIC_INT_EN) { set_ics(s, 0, E1000_ICR_MDAC); } }
1threat
WHERE clause not working for SQLite Android : I am currently doing an Android application with a SQLite database and I want to create a method that will retrieve all tasks that are associated to one owner, but the application cannot retrieve them but instead return me an exception. How can I solve this? This is the code for the database: public class SchedulerDbHelper extends SQLiteOpenHelper { public static final int DATABASE_VERSION = 1; public static final String DATABASE_NAME = "scheduler.db"; public static final String TABLE_NAME = "SCHEDULER_TABLE"; public static final String TASK_NAME = "NAME"; public static final String TASK_YEAR = "YEAR"; public static final String TASK_MONTH = "MONTH"; public static final String TASK_DAY = "DAY"; public static final String TASK_HOUR = "HOUR"; public static final String TASK_MINUTE = "MINUTE"; public static final String TASK_DESCRIPTION = "DESCRIPTION"; public static final String TASK_OWNER = "OWNER"; public SchedulerDbHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase sqLiteDatabase) { String query = "CREATE TABLE " + TABLE_NAME + "(" + TASK_NAME + " TEXT PRIMARY KEY, " + TASK_YEAR + " INTEGER, " + TASK_MONTH + " INTEGER, " + TASK_DAY + " INTEGER, " + TASK_HOUR + " INTEGER, " + TASK_MINUTE + " INTEGER, " + TASK_DESCRIPTION + " TEXT, " + TASK_OWNER + " TEXT" + ")"; sqLiteDatabase.execSQL(query); } @Override public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) { String query = "DROP TABLE IF EXISTS " + TABLE_NAME; sqLiteDatabase.execSQL(query); onCreate(sqLiteDatabase); } public void addTask(Task task) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(TASK_NAME, task.getTaskName()); values.put(TASK_YEAR, task.getYear()); values.put(TASK_MONTH, task.getMonth()); values.put(TASK_DAY, task.getDay()); values.put(TASK_HOUR, task.getHour()); values.put(TASK_MINUTE, task.getMinute()); values.put(TASK_DESCRIPTION, task.getDescription()); values.put(TASK_OWNER, loginID); db.insert(TABLE_NAME, null, values); db.close(); } public Task getTask(String taskName){ SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.query(TABLE_NAME, new String[]{TASK_NAME, TASK_YEAR, TASK_MONTH, TASK_DAY, TASK_HOUR, TASK_MINUTE, TASK_DESCRIPTION, TASK_OWNER}, TASK_NAME + " =?", new String[]{taskName}, null, null, null, null); if (cursor != null){ cursor.moveToFirst(); } Task task = new Task(cursor.getString(0), Integer.parseInt(cursor.getString(1)), Integer.parseInt(cursor.getString(2)), Integer.parseInt(cursor.getString(3)), Integer.parseInt(cursor.getString(4)), Integer.parseInt(cursor.getString(5)), cursor.getString(6)) ; return task; } public ArrayList<Task> getAllTask(){ ArrayList<Task> taskList = new ArrayList<>(); String selectQuery = "SELECT * FROM " + TABLE_NAME; SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { Task task = new Task(); task.setTaskName(cursor.getString(0)); task.setYear(Integer.parseInt(cursor.getString(1))); task.setMonth(Integer.parseInt(cursor.getString(2))); task.setDay(Integer.parseInt(cursor.getString(3))); task.setHour(Integer.parseInt(cursor.getString(4))); task.setMinute(Integer.parseInt(cursor.getString(5))); task.setDescription(cursor.getString(6)); taskList.add(task); } while (cursor.moveToNext()); } return taskList; } public int updateTask(Task task){ SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(TASK_NAME, task.getTaskName()); values.put(TASK_YEAR, task.getYear()); values.put(TASK_MONTH, task.getMonth()); values.put(TASK_DAY, task.getDay()); values.put(TASK_HOUR, task.getHour()); values.put(TASK_MINUTE, task.getMinute()); values.put(TASK_DESCRIPTION, task.getDescription()); return db.update(TABLE_NAME, values, TASK_NAME + "=?", new String[]{task.getTaskName()}); } public void deleteTask(Task task){ SQLiteDatabase db = this.getWritableDatabase(); db.delete(TABLE_NAME, TASK_NAME + "=?", new String[]{task.getTaskName()}); db.close(); } public int getTaskCount() { String countQuery = "SELECT * FROM " + TABLE_NAME; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(countQuery, null); cursor.close(); return cursor.getCount(); } public ArrayList<Task> getAllTaskForUser(){ ArrayList<Task> taskList = new ArrayList<>(); String selectQuery = "SELECT * FROM " + TABLE_NAME + " WHERE " + TASK_OWNER + " = " + loginID; SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { Task task = new Task(); task.setTaskName(cursor.getString(0)); task.setYear(Integer.parseInt(cursor.getString(1))); task.setMonth(Integer.parseInt(cursor.getString(2))); task.setDay(Integer.parseInt(cursor.getString(3))); task.setHour(Integer.parseInt(cursor.getString(4))); task.setMinute(Integer.parseInt(cursor.getString(5))); task.setDescription(cursor.getString(6)); taskList.add(task); loginID = cursor.getString(7); } while (cursor.moveToNext()); } return taskList; } } This is the code for the main fragment running the database: public class SchedulerFragment extends android.support.v4.app.Fragment { ListView listViewTaskList; ArrayList<Task> taskList; SchedulerDbHelper taskDb; public static String taskPrimary; public SchedulerFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_scheduler, container, false); } @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); getActivity().setTitle("Scheduler"); taskDb = new SchedulerDbHelper(getActivity()); taskList = taskDb.getAllTaskForUser(); Iterator<Task> i = taskList.iterator(); String[] taskNameArray = new String[taskList.size()]; int index = 0; FloatingActionButton floatingActionButtonNewTask = getView().findViewById(R.id.floatingActionButtonNewTask); listViewTaskList = getView().findViewById(R.id.listViewTaskList); while(i.hasNext()){ Task t = i.next(); taskNameArray[index] = t.getTaskName(); index++; } try { ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, taskNameArray); listViewTaskList.setAdapter(adapter); } catch (RuntimeException r1) { } listViewTaskList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { String taskName = adapterView.getItemAtPosition(i).toString(); taskPrimary = taskName; TaskDetailFragment tdf = new TaskDetailFragment(); FragmentManager manager = getFragmentManager(); manager.beginTransaction().replace(R.id.frameLayoutContent, tdf, tdf.getTag()).commit(); } }); floatingActionButtonNewTask.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { NewSchedulerFragment nsf = new NewSchedulerFragment(); FragmentManager manager = getFragmentManager(); manager.beginTransaction().replace(R.id.frameLayoutContent, nsf, nsf.getTag()).commit(); } }); } } And this is the exception that I got: E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.android.eduhub, PID: 6873 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.eduhub/com.example.android.eduhub.ContentMainActivity}: android.database.sqlite.SQLiteException: no such column: tth980409 (code 1): , while compiling: SELECT * FROM SCHEDULER_TABLE WHERE OWNER = tth980409 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) Caused by: android.database.sqlite.SQLiteException: no such column: tth980409 (code 1): , while compiling: SELECT * FROM SCHEDULER_TABLE WHERE OWNER = tth980409 at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889) at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500) at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58) at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37) at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44) at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1318) at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1257) at com.example.android.eduhub.SchedulerDbHelper.getAllTaskForUser(SchedulerDbHelper.java:143) at com.example.android.eduhub.SchedulerFragment.onViewCreated(SchedulerFragment.java:55) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1430) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809) at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799) at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367) at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229) at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3221) at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3171) at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:192) at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:560) at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:177) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1248) at android.app.Activity.performStart(Activity.java:6679) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2609) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)  at android.app.ActivityThread.-wrap12(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6077)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)  Application terminated.
0debug