problem
stringlengths
26
131k
labels
class label
2 classes
static uint64_t hb_regs_read(void *opaque, hwaddr offset, unsigned size) { uint32_t *regs = opaque; uint32_t value = regs[offset/4]; if ((offset == 0x100) || (offset == 0x108) || (offset == 0x10C)) { value |= 0x30000000; } return value; }
1threat
Responsive Layout Design / Android : I finished the java codes and function of my little project. At the end, i check to support a big amount of android devices according to their size. But it was fail. While researching, i understand that i should use sp for textsizes and dp for all other parameters. The layout -xml- is existed via sp and dp. But it is not like that i expected. I create a new project for example. My xml; (in contraintlayout) <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="72dp" android:text="Hello World!" android:textSize="105sp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.502" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="144dp" android:text="Check" android:textSize="160sp" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@+id/textView" /> For 1080 x 1920 xxhdpi; [Click here to see layout][1] For 1440 x 2960 hdpi(samsung galaxy s8 ) [Click here to see layout][2] In galaxy s8, elements are really small and there is problem in view. I guess that i misunderstand a basic concept. Can you clear up my mind please? [1]: https://i.stack.imgur.com/ixL1W.png [2]: https://i.stack.imgur.com/2RUAK.png
0debug
Why does IF statement fail when OR || is used? : <p>My Ruby if statement fails when the or operator is used. </p> <pre><code>&lt;% if @body_id == 'plants' || 'trees' %&gt; &lt;meta name="robots" content="noindex, nofollow"&gt; &lt;% end %&gt; </code></pre>
0debug
static int usbredir_post_load(void *priv, int version_id) { USBRedirDevice *dev = priv; switch (dev->device_info.speed) { case usb_redir_speed_low: dev->dev.speed = USB_SPEED_LOW; break; case usb_redir_speed_full: dev->dev.speed = USB_SPEED_FULL; break; case usb_redir_speed_high: dev->dev.speed = USB_SPEED_HIGH; break; case usb_redir_speed_super: dev->dev.speed = USB_SPEED_SUPER; break; default: dev->dev.speed = USB_SPEED_FULL; dev->dev.speedmask = (1 << dev->dev.speed); usbredir_setup_usb_eps(dev); usbredir_check_bulk_receiving(dev);
1threat
void net_tx_pkt_init(struct NetTxPkt **pkt, PCIDevice *pci_dev, uint32_t max_frags, bool has_virt_hdr) { struct NetTxPkt *p = g_malloc0(sizeof *p); p->pci_dev = pci_dev; p->vec = g_malloc((sizeof *p->vec) * (max_frags + NET_TX_PKT_PL_START_FRAG)); p->raw = g_malloc((sizeof *p->raw) * max_frags); p->max_payload_frags = max_frags; p->max_raw_frags = max_frags; p->has_virt_hdr = has_virt_hdr; p->vec[NET_TX_PKT_VHDR_FRAG].iov_base = &p->virt_hdr; p->vec[NET_TX_PKT_VHDR_FRAG].iov_len = p->has_virt_hdr ? sizeof p->virt_hdr : 0; p->vec[NET_TX_PKT_L2HDR_FRAG].iov_base = &p->l2_hdr; p->vec[NET_TX_PKT_L3HDR_FRAG].iov_base = &p->l3_hdr; *pkt = p; }
1threat
static void DEF(put, pixels8_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h) { MOVQ_BFE(mm6); __asm__ volatile( "lea (%3, %3), %%"REG_a" \n\t" ".p2align 3 \n\t" "1: \n\t" "movq (%1), %%mm0 \n\t" "movq 1(%1), %%mm1 \n\t" "movq (%1, %3), %%mm2 \n\t" "movq 1(%1, %3), %%mm3 \n\t" PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5) "movq %%mm4, (%2) \n\t" "movq %%mm5, (%2, %3) \n\t" "add %%"REG_a", %1 \n\t" "add %%"REG_a", %2 \n\t" "movq (%1), %%mm0 \n\t" "movq 1(%1), %%mm1 \n\t" "movq (%1, %3), %%mm2 \n\t" "movq 1(%1, %3), %%mm3 \n\t" PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5) "movq %%mm4, (%2) \n\t" "movq %%mm5, (%2, %3) \n\t" "add %%"REG_a", %1 \n\t" "add %%"REG_a", %2 \n\t" "subl $4, %0 \n\t" "jnz 1b \n\t" :"+g"(h), "+S"(pixels), "+D"(block) :"r"((x86_reg)line_size) :REG_a, "memory"); }
1threat
Type error, cannot read property 'match' of undefined : <p>i got stuck in the Javascript code below, I don't know what's the problem. the code is always showing"Type error, cannot read property 'match' of undefined", Here IS THE CODE:</p> <pre><code>function keepletteronly(str) { str=str.toLowerCase();//Make the string to lower case arr=str.split(""); //This way I make an array out of the string arr1=[]; //make an new array for (i=1; i&lt;=arr.length;i++){ if (arr[i].match(/[a-z]/)!=null) { //This is where the problem is arr1.push(arr[i]); //retain only the letters and append to the arr1 } } newstring=arr1.join; return newstring; } keepletteronly("1eye"); </code></pre>
0debug
static int get_channel_idx(char **map, int *ch, char delim, int max_ch) { char *next = split(*map, delim); int len; int n = 0; if (!next && delim == '-') return AVERROR(EINVAL); if (!*map) return AVERROR(EINVAL); len = strlen(*map); sscanf(*map, "%d%n", ch, &n); if (n != len) return AVERROR(EINVAL); if (*ch < 0 || *ch > max_ch) return AVERROR(EINVAL); *map = next; return 0; }
1threat
Map roles to REST API : How to do role validation for REST API's. I have 2 roles called "admin" and "manager" REST API's : /users -> POST /users -> GET "admin" role can access both the API's but "manager" can access only GET API.
0debug
void vga_common_init(VGACommonState *s, Object *obj, bool global_vmstate) { int i, j, v, b; for(i = 0;i < 256; i++) { v = 0; for(j = 0; j < 8; j++) { v |= ((i >> j) & 1) << (j * 4); } expand4[i] = v; v = 0; for(j = 0; j < 4; j++) { v |= ((i >> (2 * j)) & 3) << (j * 4); } expand2[i] = v; } for(i = 0; i < 16; i++) { v = 0; for(j = 0; j < 4; j++) { b = ((i >> j) & 1); v |= b << (2 * j); v |= b << (2 * j + 1); } expand4to8[i] = v; } s->vram_size_mb = uint_clamp(s->vram_size_mb, 1, 512); s->vram_size_mb = pow2ceil(s->vram_size_mb); s->vram_size = s->vram_size_mb << 20; if (!s->vbe_size) { s->vbe_size = s->vram_size; } s->is_vbe_vmstate = 1; memory_region_init_ram(&s->vram, obj, "vga.vram", s->vram_size, &error_abort); vmstate_register_ram(&s->vram, global_vmstate ? NULL : DEVICE(obj)); xen_register_framebuffer(&s->vram); s->vram_ptr = memory_region_get_ram_ptr(&s->vram); s->get_bpp = vga_get_bpp; s->get_offsets = vga_get_offsets; s->get_resolution = vga_get_resolution; s->hw_ops = &vga_ops; switch (vga_retrace_method) { case VGA_RETRACE_DUMB: s->retrace = vga_dumb_retrace; s->update_retrace_info = vga_dumb_update_retrace_info; break; case VGA_RETRACE_PRECISE: s->retrace = vga_precise_retrace; s->update_retrace_info = vga_precise_update_retrace_info; break; } #ifdef TARGET_WORDS_BIGENDIAN s->default_endian_fb = true; #else s->default_endian_fb = false; #endif vga_dirty_log_start(s); }
1threat
Set WKWebViewConfiguration on WKWebView from Nib or Storyboard : <p>With iOS 11 Apple has added the ability set add WKWebViews outlets on your nibs and storyboards. It seems to work fine when using the default WKWebViewConfiguration that get set automatically. </p> <p>However, I'd like to be able to use a custom WKWebViewConfiguration. Is there anyway I can set this before, or after the WKWebView gets initialized from the nib?</p>
0debug
QError *qobject_to_qerror(const QObject *obj) { if (qobject_type(obj) != QTYPE_QERROR) { return NULL; } return container_of(obj, QError, base); }
1threat
static int get_segment (CPUState *env, mmu_ctx_t *ctx, target_ulong eaddr, int rw, int type) { target_phys_addr_t sdr, hash, mask, sdr_mask, htab_mask; target_ulong sr, vsid, vsid_mask, pgidx, page_mask; #if defined(TARGET_PPC64) int attr; #endif int ds, nx, vsid_sh, sdr_sh; int ret, ret2; #if defined(TARGET_PPC64) if (env->mmu_model == POWERPC_MMU_64B) { #if defined (DEBUG_MMU) if (loglevel != 0) { fprintf(logfile, "Check SLBs\n"); } #endif ret = slb_lookup(env, eaddr, &vsid, &page_mask, &attr); if (ret < 0) return ret; ctx->key = ((attr & 0x40) && msr_pr == 1) || ((attr & 0x80) && msr_pr == 0) ? 1 : 0; ds = 0; nx = attr & 0x20 ? 1 : 0; vsid_mask = 0x00003FFFFFFFFF80ULL; vsid_sh = 7; sdr_sh = 18; sdr_mask = 0x3FF80; } else #endif { sr = env->sr[eaddr >> 28]; page_mask = 0x0FFFFFFF; ctx->key = (((sr & 0x20000000) && msr_pr == 1) || ((sr & 0x40000000) && msr_pr == 0)) ? 1 : 0; ds = sr & 0x80000000 ? 1 : 0; nx = sr & 0x10000000 ? 1 : 0; vsid = sr & 0x00FFFFFF; vsid_mask = 0x01FFFFC0; vsid_sh = 6; sdr_sh = 16; sdr_mask = 0xFFC0; #if defined (DEBUG_MMU) if (loglevel != 0) { fprintf(logfile, "Check segment v=0x" ADDRX " %d 0x" ADDRX " nip=0x" ADDRX " lr=0x" ADDRX " ir=%d dr=%d pr=%d %d t=%d\n", eaddr, (int)(eaddr >> 28), sr, env->nip, env->lr, msr_ir, msr_dr, msr_pr, rw, type); } #endif } #if defined (DEBUG_MMU) if (loglevel != 0) { fprintf(logfile, "pte segment: key=%d ds %d nx %d vsid " ADDRX "\n", ctx->key, ds, nx, vsid); } #endif ret = -1; if (!ds) { if (type != ACCESS_CODE || nx == 0) { sdr = env->sdr1; pgidx = (eaddr & page_mask) >> TARGET_PAGE_BITS; #if defined(TARGET_PPC64) if (env->mmu_model == POWERPC_MMU_64B) { htab_mask = 0x0FFFFFFF >> (28 - (sdr & 0x1F)); hash = ((vsid ^ pgidx) << vsid_sh) & vsid_mask; } else #endif { htab_mask = sdr & 0x000001FF; hash = ((vsid ^ pgidx) << vsid_sh) & vsid_mask; } mask = (htab_mask << sdr_sh) | sdr_mask; #if defined (DEBUG_MMU) if (loglevel != 0) { fprintf(logfile, "sdr " PADDRX " sh %d hash " PADDRX " mask " PADDRX " " ADDRX "\n", sdr, sdr_sh, hash, mask, page_mask); } #endif ctx->pg_addr[0] = get_pgaddr(sdr, sdr_sh, hash, mask); hash = (~hash) & vsid_mask; #if defined (DEBUG_MMU) if (loglevel != 0) { fprintf(logfile, "sdr " PADDRX " sh %d hash " PADDRX " mask " PADDRX "\n", sdr, sdr_sh, hash, mask); } #endif ctx->pg_addr[1] = get_pgaddr(sdr, sdr_sh, hash, mask); #if defined(TARGET_PPC64) if (env->mmu_model == POWERPC_MMU_64B) { ctx->ptem = (vsid << 12) | ((pgidx >> 4) & 0x0F80); } else #endif { ctx->ptem = (vsid << 7) | (pgidx >> 10); } ctx->raddr = (target_ulong)-1; if (unlikely(env->mmu_model == POWERPC_MMU_SOFT_6xx || env->mmu_model == POWERPC_MMU_SOFT_74xx)) { ret = ppc6xx_tlb_check(env, ctx, eaddr, rw, type); } else { #if defined (DEBUG_MMU) if (loglevel != 0) { fprintf(logfile, "0 sdr1=0x" PADDRX " vsid=0x%06x " "api=0x%04x hash=0x%07x pg_addr=0x" PADDRX "\n", sdr, (uint32_t)vsid, (uint32_t)pgidx, (uint32_t)hash, ctx->pg_addr[0]); } #endif ret = find_pte(env, ctx, 0, rw); if (ret < 0) { #if defined (DEBUG_MMU) if (eaddr != 0xEFFFFFFF && loglevel != 0) { fprintf(logfile, "1 sdr1=0x" PADDRX " vsid=0x%06x api=0x%04x " "hash=0x%05x pg_addr=0x" PADDRX "\n", sdr, (uint32_t)vsid, (uint32_t)pgidx, (uint32_t)hash, ctx->pg_addr[1]); } #endif ret2 = find_pte(env, ctx, 1, rw); if (ret2 != -1) ret = ret2; } } #if defined (DEBUG_MMU) if (loglevel != 0) { target_phys_addr_t curaddr; uint32_t a0, a1, a2, a3; fprintf(logfile, "Page table: " PADDRX " len " PADDRX "\n", sdr, mask + 0x80); for (curaddr = sdr; curaddr < (sdr + mask + 0x80); curaddr += 16) { a0 = ldl_phys(curaddr); a1 = ldl_phys(curaddr + 4); a2 = ldl_phys(curaddr + 8); a3 = ldl_phys(curaddr + 12); if (a0 != 0 || a1 != 0 || a2 != 0 || a3 != 0) { fprintf(logfile, PADDRX ": %08x %08x %08x %08x\n", curaddr, a0, a1, a2, a3); } } } #endif } else { #if defined (DEBUG_MMU) if (loglevel != 0) fprintf(logfile, "No access allowed\n"); #endif ret = -3; } } else { #if defined (DEBUG_MMU) if (loglevel != 0) fprintf(logfile, "direct store...\n"); #endif switch (type) { case ACCESS_INT: break; case ACCESS_CODE: return -4; case ACCESS_FLOAT: return -4; case ACCESS_RES: return -4; case ACCESS_CACHE: ctx->raddr = eaddr; return 0; case ACCESS_EXT: return -4; default: if (logfile) { fprintf(logfile, "ERROR: instruction should not need " "address translation\n"); } return -4; } if ((rw == 1 || ctx->key != 1) && (rw == 0 || ctx->key != 0)) { ctx->raddr = eaddr; ret = 2; } else { ret = -2; } } return ret; }
1threat
What is the difference between "==" and "===" comparison operators in Julia? : <p>What is the difference between <code>==</code> and <code>===</code> comparison operators in Julia?</p>
0debug
how to use parent constructor? : <p>please help solve the problem. i have base class 'Unit':</p> <pre><code>var Unit = function() { this.x_coord = x_coord; this.y_coord = y_coord; this.color = color; }; </code></pre> <p>and child class 'playerUnit':</p> <pre><code>var playerUnit = function(gameObj, x_coord, y_coord, color) { Unit.apply(this, arguments); }; playerUnit.prototype = Object.create(Unit.prototype); var Game = function(options) { new playerUnit(this,1,1,'red'); }; var app = new Game(); </code></pre> <p>I plan in the future to do a lot of these child classes: 'enemyUnit', 'tankUnit', 'boatUnit', etc. and i need use common properties: x_coord, y_coord, color.</p> <pre><code>i try use Unit.apply(this, arguments); </code></pre> <p>but after start script i have in console follow error message: </p> <blockquote> <p>Uncaught ReferenceError: x_coord is not defined</p> </blockquote> <p>jsfiddle: <a href="https://jsfiddle.net/vzk73qah/2/" rel="nofollow">https://jsfiddle.net/vzk73qah/2/</a></p>
0debug
C method gives warning: expression result unused and freezes : <p>I have small problem with my home task. I have to create a method that sums an array, but with specific, given step. I did something like this: </p> <pre><code>int sum_step(int t[], int size, int step) { int i; int sum = 0; for(i=0; i &lt; size; i+step) { sum += t[i]; } return sum; } </code></pre> <p>and console returns warning:</p> <pre><code>warning: expression result unused [-Wunused-value] i + step; ~ ^ ~~~~ </code></pre> <p>Someone knows what is wrong? Thank in advance!</p>
0debug
static void decode_profile_tier_level(GetBitContext *gb, AVCodecContext *avctx, PTLCommon *ptl) { int i; ptl->profile_space = get_bits(gb, 2); ptl->tier_flag = get_bits1(gb); ptl->profile_idc = get_bits(gb, 5); if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN) av_log(avctx, AV_LOG_DEBUG, "Main profile bitstream\n"); else if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN_10) av_log(avctx, AV_LOG_DEBUG, "Main 10 profile bitstream\n"); else if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN_STILL_PICTURE) av_log(avctx, AV_LOG_DEBUG, "Main Still Picture profile bitstream\n"); else av_log(avctx, AV_LOG_WARNING, "Unknown HEVC profile: %d\n", ptl->profile_idc); for (i = 0; i < 32; i++) ptl->profile_compatibility_flag[i] = get_bits1(gb); ptl->progressive_source_flag = get_bits1(gb); ptl->interlaced_source_flag = get_bits1(gb); ptl->non_packed_constraint_flag = get_bits1(gb); ptl->frame_only_constraint_flag = get_bits1(gb); skip_bits(gb, 16); skip_bits(gb, 16); skip_bits(gb, 12); }
1threat
Twitter error code 429 with Tweepy : <p>I am trying to create a project that accesses a twitter account using the tweepy api but I am faced with status code 429. Now, I've looked around and I see that it means that I have too many requests. However, I am only ever for 10 tweets at a time and within those, only one should exist during my testing.</p> <pre><code>for tweet in tweepy.Cursor(api.search, q = '@realtwitchess ',lang = ' ').items(10): try: text = str(tweet.text) textparts = str.split(text) #convert tweet into string array to disect print(text) for x, string in enumerate(textparts): if (x &lt; len(textparts)-1): #prevents error that arises with an incomplete call of the twitter bot to start a game if string == "gamestart" and textparts[x+1][:1] == "@": #find games otheruser = api.get_user(screen_name = textparts[2][1:]) #drop the @ sign (although it might not matter) self.games.append((tweet.user.id,otheruser.id)) elif (len(textparts[x]) == 4): #find moves newMove = Move(tweet.user.id,string) print newMove.getMove() self.moves.append(newMove) if tweet.user.id == thisBot.id: #ignore self tweets continue except tweepy.TweepError as e: print(e.reason) sleep(900) continue except StopIteration: #stop iteration when last tweet is reached break </code></pre> <p>When the error does appear, it is in the first for loop line. The kinda weird part is that it doesn't complain every time, or even in consistent intervals. Sometimes it will work and other times, seemingly randomly, not work.</p> <p>We have tried adding longer sleep times in the loop and reducing the item count.</p>
0debug
@Html.TextBoxFor with default help text : <p>How can I get a Default help text ("Type your name here" ) in @Html.TextBoxFor/@Html.Editorfor</p> <p>When a user clicks the box for typing , then the text will disappear.</p>
0debug
How to properly access a StringVar() of a class from another class - Python - tkinter : <p>(I'm using mac 10.8.5 and Python3 with PyCharm)</p> <p>I have a tkinter GUI <code>TestMain()</code> class plus one <code>PageOne()</code> class and a <code>PageTwo()</code> class. I need <code>PageOne()</code> and <code>PageTwo()</code> to be different GUI windows cause they will handle different data. I minimized the code in order to set it as readable as possible. After many tests I tried to place the <code>tk.StringVar()</code> and a simple function in the global scope as you can see below, but there's still a problem.</p> <pre><code>import tkinter as tk page1_label = tk.StringVar() page2_entry = tk.StringVar() def set_ebdata(): data = page2_entry.get() page1_label.set(data) class TestMain(tk.Tk): def __init__(self, *args, **kwargs): tk.Tk.__init__(self, *args, **kwargs) tk.Tk.wm_title(self, 'TEST GUI') container = tk.Frame(self) container.pack(side='top') container.grid_rowconfigure(0, weight=1) container.grid_columnconfigure(0, weight=1) self.frames = {} for F in (PageOne, PageTwo): frame = F(container, self) self.frames[F] = frame frame.configure(background='lightgrey') frame.grid(row=0, column=0, sticky='nswe') self.show_frame(PageOne) def show_frame(self, cont): frame = self.frames[cont] frame.tkraise() class PageOne(tk.Frame): def __init__(self, parent, controller): tk.Frame.__init__(self, parent) frame_eb_data = tk.Frame(self, width=100, height=100, bg="orange", colormap="new") frame_eb_data.grid(row=0, column=0, sticky='w', padx=5, pady=5) frame_but_right = tk.Frame(self, width=240, height=60, bg="yellow", colormap="new") frame_but_right.grid(row=0, column=1, padx=5, pady=5, rowspan=2) lab_eb_data = tk.Label(frame_eb_data, background='#DDD4EF', textvariable=page1_label) lab_eb_data.grid(row=0, column=0, sticky='n') b_ebdata = tk.Button(frame_but_right, text="Page 2", width=10, height=2, command=lambda: controller.show_frame(PageTwo)) b_ebdata.grid(row=3, column=0) class PageTwo(tk.Frame): def __init__(self, parent, controller): tk.Frame.__init__(self, parent) frame_buttons = tk.Frame(self, width=455, bg="#DDD4EF", colormap="new") frame_buttons.grid(row=0, column=0, padx=5, pady=5, sticky='e') frame_up_left = tk.Frame(self, width=485, height=260, bg="#89E3FA", colormap="new") frame_up_left.grid(row=1, column=0, sticky='w', padx=5, pady=5) b_data = tk.Label(frame_buttons, text='Example GUI', font='TrebuchetMS 30 bold', background="#DDD4EF") b_data.grid(row=0, column=0, padx=13, pady=5, sticky='w') b5 = tk.Button(frame_buttons, text='Set Text', command=lambda: set_ebdata) b5.grid(row=0, column=2, padx=5, pady=5, sticky='e') b6 = tk.Button(frame_buttons, text='Page 1', command=lambda: controller.show_frame(PageOne)) b6.grid(row=0, column=3, padx=5, pady=5, sticky='e') label_2 = tk.Label(frame_up_left, text="Name:", font=("bold", 14)) label_2.grid(row=1, column=0, sticky='e') entry_nombre_fld = tk.Entry(frame_up_left, width=40, textvariable=page2_entry) entry_nombre_fld.grid(row=1, column=1, columnspan=3, sticky='w') app = TestMain() app.mainloop() </code></pre> <p>When you run the program a window with a "Page 2" button (<code>b_ebdata</code>) appears, by clicking it you enter Page 2 window which has a "Set Text" button (<code>b5</code>), a "Page 1" button (<code>b6</code>) and an entry field (<code>entry_nombre_fld</code>).</p> <p>I'd like to set the text I'll enter in the entry field (<code>entry_nombre_fld</code>) in the Page 1 label (<code>lab_eb_data</code>) by clicking the "Set Text" button (<code>b5</code>).</p> <p>Could a solution be to put <code>page1_label = tk.StringVar()</code> into <code>PageOne()</code> class and <code>page2_entry = tk.StringVar()</code> into <code>PageTwo()</code> class and make those accessible by each other?</p> <p>Any other suggestion ?</p> <p>Thx in advance for your help!</p>
0debug
What is the benefit of using '--strictFunctionTypes' in Typescript? : <p>As I understand it, <code>--strictFunctionTypes</code> compiler option in Typescript prevents a very common use case of polymorphism from working:</p> <pre><code>type Handler = (request: Request) =&gt; Response const myHandler: Handler = (request: Request &amp; { extraArg: boolean }) =&gt; { return !!request.extraArg } </code></pre> <p>Generally, I assume that all compiler options in the <code>strict</code> family have some great benefits, but in this case, all I see is that it prevents a very logical behavior from working.</p> <p>So what are the cases where this option actually gives some benefits? Which harmful scenarios does it prevent?</p>
0debug
Is it possibleto write a C program that functions differently according to argv[0] : Is it possible to write a C program that functions differently according to argv[0]? In fact, I am working on an exercise from a C textbook. The exercise is to write a program that converts upper case to lower or lower case to upper, depending on the name it is invoked with, as found in argv[0].
0debug
How should I configure create-react-app to serve app from subdirectory? : <p>I have classic web application rendered on server. I want to create admin panel as single page application in React. I want to server admin panel from <a href="https://smyapp.example.com/admin/" rel="noreferrer">https://smyapp.example.com/admin/</a>. I try to use <code>create-react-app</code> but it assumes that i serve SPA from root URL. How should I configure <code>create-react-app</code> to serve app from <code>"admin"</code> subdirectory? In documentation I found <code>"homepage"</code> property but if I properly understand it requires complete url. I can't give complete url because my app is deployed in few environments.</p>
0debug
How to use SonarQube web API? : <p>Previously, I asked about <a href="https://stackoverflow.com/questions/46198487/export-custom-sonarqube-report/46212879#46212879">how to export custom data from SonarQube Database</a>, and the Sonar Team suggests me that I should use Web API. </p> <p>After some research, I'm still struggling on how to use the Web API. ( I'm very unfamiliar with how the Web API works)</p> <p>After reading this <a href="https://stackoverflow.com/questions/30526187/how-to-get-a-json-from-api-metrics-of-sonarqube">post</a>, I realise that I can use Java code to do that. (I've just gone through how to use Apache Http Client) However, after run</p> <p><code>HttpGet httpGet = new HttpGet("http://localhost:9000/api/issues?metrics=lines");</code>(copied from that post)</p> <p>I got:</p> <p><code>HTTP/1.1 404 {"errors":[{"msg":"Unknown url : /api/issues"}]}</code></p> <p>After I change this line to:</p> <p><code>HttpGet httpGet = new HttpGet("http://localhost:9000/project/issues?facetMode=effort&amp;id=project%3Atesting&amp;resolved=false&amp;types=CODE_SMELL");</code></p> <p>I got:</p> <p><code>HTTP/1.1 200 &lt;!DOCTYPE html&gt;&lt;html lang="en"&gt;&lt;head&gt;&lt;meta http-equiv="content-type" content="text/html; charset=UTF-8" charset="UTF-8"/&gt;&lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;&lt;link rel="apple-touch-icon" href="/apple-touch-icon.png"&gt;&lt;link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png"&gt;&lt;link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png"&gt;&lt;link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png"&gt;&lt;link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png"&gt;&lt;link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png"&gt;&lt;link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png"&gt;&lt;link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144x144.png"&gt;&lt;link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png"&gt;&lt;link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon-180x180.png"&gt;&lt;link rel="icon" type="image/x-icon" href="/favicon.ico"&gt;&lt;meta name="application-name" content="SonarQube"/&gt;&lt;meta name="msapplication-TileColor" content="#FFFFFF"/&gt;&lt;meta name="msapplication-TileImage" content="/mstile-512x512.png"/&gt;&lt;link href="/css/sonar.bf342fee.css" rel="stylesheet"&gt;&lt;title&gt;SonarQube&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;div id="content"&gt;&lt;div class="global-loading"&gt;&lt;i class="spinner global-loading-spinner"&gt;&lt;/i&gt; &lt;span class="global-loading-text"&gt;Loading...&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;script&gt;window.baseUrl=""&lt;/script&gt;&lt;script src="/js/vendor.0ba4fd94.js"&gt;&lt;/script&gt;&lt;script src="/js/app.bf342fee.js"&gt;&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;</code></p> <p>Which is not what I expect as well.</p> <p>I'm wondering what's the right way to use the <a href="https://sonarcloud.io/web_api/" rel="noreferrer">Web API</a>? For example, if I want to get the code smells for a project. How the code should be in Java?</p> <p>Here is the code I'm using at the moment:</p> <pre><code>import java.io.IOException; import org.apache.http.HttpEntity; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; public class Test { public static void main(String[] args) throws ClientProtocolException, IOException { //HttpGet httpGet = new HttpGet("http://localhost:9000/api/issues?metrics=lines"); HttpGet httpGet = new HttpGet("http://localhost:9000/project/issues?facetMode=effort&amp;id=project%3Atesting&amp;resolved=false&amp;types=CODE_SMELL"); try(CloseableHttpClient httpClient = HttpClients.createDefault(); CloseableHttpResponse response = httpClient.execute(httpGet);) { System.out.println(response.getStatusLine()); HttpEntity entity = response.getEntity(); System.out.println(EntityUtils.toString(entity)); } } } </code></pre> <p>Appreciate for any help or guidance!</p>
0debug
static void verify_irqchip_in_kernel(Error **errp) { if (kvm_irqchip_in_kernel()) { return; } error_setg(errp, "pci-assign requires KVM with in-kernel irqchip enabled"); }
1threat
static SoftFloat sbr_sum_square_c(int (*x)[2], int n) { SoftFloat ret; uint64_t accu = 0, round; int i, nz; unsigned u; for (i = 0; i < n; i += 2) { av_assert2(FFABS(x[i + 0][0]) >> 29 == 0); accu += (int64_t)x[i + 0][0] * x[i + 0][0]; av_assert2(FFABS(x[i + 0][1]) >> 29 == 0); accu += (int64_t)x[i + 0][1] * x[i + 0][1]; av_assert2(FFABS(x[i + 1][0]) >> 29 == 0); accu += (int64_t)x[i + 1][0] * x[i + 1][0]; av_assert2(FFABS(x[i + 1][1]) >> 29 == 0); accu += (int64_t)x[i + 1][1] * x[i + 1][1]; } u = accu >> 32; if (u == 0) { nz = 1; } else { nz = -1; while (u < 0x80000000U) { u <<= 1; nz++; } nz = 32 - nz; } round = 1ULL << (nz-1); u = ((accu + round) >> nz); u >>= 1; ret = av_int2sf(u, 15 - nz); return ret; }
1threat
Python 3: Theoretical question about the use of variables in functions : <p>I have a theoretical question about Python 3.0 based on the example below:</p> <pre><code>def bookstore(book,price): return ("book Type: "+ book.capitalize() + " costs $" + price) book_entry=input('Enter book type: ') price_entry=input('Enter book type price: ') print (bookstore(book_entry,price_entry)) </code></pre> <p>By accident I got this script working, but I don't fully understand WHY it need to be done this way. It is about the following part: </p> <pre><code>def bookstore(book,price): AND print (bookstore(book_entry,price_entry)) </code></pre> <ol> <li><p>Why should the variables [<em>book_entry &amp; price_entry</em>] be entered in the print-funtion instead of in the definition-function [<em>book,price</em>]? </p></li> <li><p>How is communication possible between the variables? The def function is the only connection, but the variable name are different, how can the code accept this difference without giving an error? </p></li> </ol>
0debug
static int ppc_hash32_get_bat(CPUPPCState *env, struct mmu_ctx_hash32 *ctx, target_ulong virtual, int rw, int type) { target_ulong *BATlt, *BATut, *BATu, *BATl; target_ulong BEPIl, BEPIu, bl; int i, valid, prot; int ret = -1; LOG_BATS("%s: %cBAT v " TARGET_FMT_lx "\n", __func__, type == ACCESS_CODE ? 'I' : 'D', virtual); switch (type) { case ACCESS_CODE: BATlt = env->IBAT[1]; BATut = env->IBAT[0]; break; default: BATlt = env->DBAT[1]; BATut = env->DBAT[0]; break; } for (i = 0; i < env->nb_BATs; i++) { BATu = &BATut[i]; BATl = &BATlt[i]; BEPIu = *BATu & BATU32_BEPIU; BEPIl = *BATu & BATU32_BEPIL; if (unlikely(env->mmu_model == POWERPC_MMU_601)) { hash32_bat_601_size_prot(env, &bl, &valid, &prot, BATu, BATl); } else { hash32_bat_size_prot(env, &bl, &valid, &prot, BATu, BATl); } LOG_BATS("%s: %cBAT%d v " TARGET_FMT_lx " BATu " TARGET_FMT_lx " BATl " TARGET_FMT_lx "\n", __func__, type == ACCESS_CODE ? 'I' : 'D', i, virtual, *BATu, *BATl); if ((virtual & BATU32_BEPIU) == BEPIu && ((virtual & BATU32_BEPIL) & ~bl) == BEPIl) { if (valid != 0) { ctx->raddr = (*BATl & BATL32_BRPNU) | ((virtual & BATU32_BEPIL & bl) | (*BATl & BATL32_BRPNL)) | (virtual & 0x0001F000); ctx->prot = prot; ret = ppc_hash32_check_prot(ctx->prot, rw, type); if (ret == 0) { LOG_BATS("BAT %d match: r " TARGET_FMT_plx " prot=%c%c\n", i, ctx->raddr, ctx->prot & PAGE_READ ? 'R' : '-', ctx->prot & PAGE_WRITE ? 'W' : '-'); } break; } } } if (ret < 0) { #if defined(DEBUG_BATS) if (qemu_log_enabled()) { LOG_BATS("no BAT match for " TARGET_FMT_lx ":\n", virtual); for (i = 0; i < 4; i++) { BATu = &BATut[i]; BATl = &BATlt[i]; BEPIu = *BATu & BATU32_BEPIU; BEPIl = *BATu & BATU32_BEPIL; bl = (*BATu & 0x00001FFC) << 15; LOG_BATS("%s: %cBAT%d v " TARGET_FMT_lx " BATu " TARGET_FMT_lx " BATl " TARGET_FMT_lx "\n\t" TARGET_FMT_lx " " TARGET_FMT_lx " " TARGET_FMT_lx "\n", __func__, type == ACCESS_CODE ? 'I' : 'D', i, virtual, *BATu, *BATl, BEPIu, BEPIl, bl); } } #endif } return ret; }
1threat
How do I establish a gradient (drawable) as status bar color? : <p>How to do I establish a gradient as status bar background for Android Studio. </p> <p>.</p>
0debug
How to debug a Python package in PyCharm : <h1>Setup</h1> <p>I have the following tree structure in my project:</p> <pre><code>Cineaste/ β”œβ”€β”€ cineaste/ β”‚Β Β  β”œβ”€β”€ __init__.py β”‚Β Β  β”œβ”€β”€ metadata_errors.py β”‚Β Β  β”œβ”€β”€ metadata.py β”‚Β Β  └── tests/ β”‚Β Β  └── __init__.py β”œβ”€β”€ docs/ β”œβ”€β”€ LICENSE β”œβ”€β”€ README.md └── setup.py </code></pre> <p><code>metadata.py</code> imports <code>metadata_errors.py</code> with the expression:</p> <pre><code>from .metadata_errors.py import * </code></pre> <p>Thus setting a relative path to the module in the same directory (notice the dot prefix).</p> <p>I can run <code>metadata.py</code> in the PyCharm 2016 editor just fine with the following configuration:</p> <p><a href="https://i.stack.imgur.com/xu6kS.png"><img src="https://i.stack.imgur.com/xu6kS.png" alt="enter image description here"></a></p> <h1>Problem</h1> <p>However, <strong>with this configuration I cannot debug <code>metadata.py</code></strong>. PyCharm returns the following error message (partial stack trace):</p> <pre><code> from .metadata_errors import * SystemError: Parent module '' not loaded, cannot perform relative import </code></pre> <p>PyCharm debugger is being called like so:</p> <pre><code>/home/myself/.pyenv/versions/cineaste/bin/python /home/myself/bin/pycharm-2016.1.3/helpers/pydev/pydevd.py --multiproc --module --qt-support --client 127.0.0.1 --port 52790 --file cineaste.metadata </code></pre> <h1>Question</h1> <p>How can I setup this project so that PyCharm is able to run and debug a file that makes relative imports? </p>
0debug
Should I change @Html.Partial to @Html.PartialAsync as Visual Studio suggest? : <p>In my code I have <code>@Html.Partial("_StatusMessage", Model.StatusMessage)</code> but Visual Studio warning me that: <code>Error MVC1000: Use of IHtmlHelper.Partial may result in application deadlocks. Consider using &lt;partial&gt; Tag Helper or IHtmlHelper.PartialAsync.</code></p> <p>Should I disable this error or I should really change <code>@Html.Partial</code> to <code>@Html.PartialAsync</code>, and why?</p>
0debug
Program wont loop : <pre><code>def main(): ToDo = [] ToDo.append("shower") ToDo.append("make breakfast") ToDo.append("do homework") ToDo.append("walk dog") ToDo.append("eat dinner") ToDo.append("sleep") running = True ToDo = [] ToDo.append("shower") ToDo.append("make breakfast") ToDo.append("do homework") ToDo.append("walk dog") ToDo.append("eat dinner") ToDo.append("sleep") running = True while(running): print("\n1. add an element") print("2. delete an element") print("3. edit an element") print("4. print an element") print("5. exit") choice = int(input("Please enter 1-5: ")) if choice == 1: ToDo.append(input("Enter an element: ")) elif choice == 2: pos = int(input("Please enter the index of the element to delete (0-"+ str(len(ToDo) - 1)+"): ")) if pos &gt;=0 and pos &lt; len(ToDo): ToDo.pop(pos) else: print("Wrong index: " + pos) elif choice == 3: pos = int(input("Please enter the index of the element to delete (0-"+ str(len(ToDo) - 1)+"): ")) if pos &gt;=0 and pos &lt; len(ToDo): ToDo[pos] = input("Enter an element: ") else: print("Wrong index: " + pos) elif choice == 4: pos = int(input("Please enter the index of the element to delete (0-"+ str(len(ToDo) - 1)+"): ")) if pos &gt;=0 and pos &lt; len(ToDo): print(ToDo[pos]) else: print("Wrong index: " + pos) elif choice == 5: print("Exiting...") restart = input("Do you want to start again").lower() if restart == "yes": main() else: exit() else: print("Please enter a valid option") </code></pre> <p>My program works the way I want it to, however after adding the following code to loop the entire program, it does not run the program at all. It should run, and if the user enters 5, the program should ask whether they would like to start again. If they say yes then it will go to main otherwise it will end the program: </p> <pre><code> restart = input("Do you want to start again").lower() if restart == "yes": main() else: exit() </code></pre>
0debug
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
c# marshal , return uint value on parameters : I have c# code that call to c dll (dllimport) . I want the c return value on the parametes. c# code: uint x=0; Func(x); c code: void Func(size_t x) { x=8; } I want the c# get value 8 to x . I tried: [DllImport("1.dll")] public static extern void Func(size_t x); but after the c# finish with Func function the var x still 0 what can I do please?
0debug
Why is AES encryption / decryption more than 3x slower on Android 24+? : <p><strong>You can skip to TL;DR</strong></p> <p>We have an app, which strongly relies on AES encryption and decryption. We want to support as many devices as possible, but some of them (especially crappy tablets and I don't only mean Chinese no-names, but also some low-end tablets from Samsung or Lenovo) are simply slow to encrypt and decrypt.</p> <p>We have used Android 23 in our app and we were able to identify some kind of level below which our app will simply not work well for the end user (they would have to wait too long for the content to appear). It was a lot of tablets that we had to rule out for use with our app, but well, we were able to live with that.</p> <p>Recently some of our dependencies started to require a newer version of Android. For example, we wanted to switch to Facebook Core SDK, instead of the full Facebook SDK to save some space. But it depends on the Android support package v25 and we won't be able to build it because proguard refuses to process the sources.</p> <p>So a decision was made to move the project to a newer Android. It went quite smooth, apart from the performance impact it had on our encryption/decryption mechanism. Suddenly it was MUCH slower. Tablets we would rate as "working well enough" were extremely slow. </p> <p><strong>TL;DR</strong></p> <p>I've started to investigate what happened during our migration from Android 23 to Android 26, which would cause a HUGE performance drop in AES encryption/decryption.</p> <p>I've created an app, which works as kind of a benchmark. By making a simple change:</p> <ul> <li><code>compileSdkVersion 23-&gt;26</code></li> <li><code>targetSdkVersion 23-&gt;26</code></li> <li><code>compile 'com.android.support:appcompat-v7:VERSION' 23.4.0 -&gt; 26.+</code></li> </ul> <p>the performance drop is huge.</p> <p>Here's an example result from one of the tablets:</p> <pre><code>Android 23: 136959 B/s Android 26: 34419 B/s </code></pre> <p>That's almost 4x slower. I can reproduce these results on all of the devices I have to test. Sure, on new, high-performance devices it's barely visible, but on old devices, it's clear.</p> <p>I've searched the web for any details on this, but I have found nothing. I would really be grateful for someone to shed some light on this issue.</p> <p>I really hope I have made a mistake somewhere, but I wasn't able to find it.</p> <p>For encryption/decryption, we use the SpongyCastle library.</p> <p>The sources of my Crypto Tester app are available on GitHub: <a href="https://github.com/krstns/cryptoTester" rel="noreferrer">https://github.com/krstns/cryptoTester</a></p> <p>There's the <code>master</code> branch with Android 23 configuration and <code>master_26</code> branch with Android 26 configuration. </p> <p>For the sake of completeness, I will paste here the method which is used for decryption:</p> <pre><code>/** * Decrypt the given data with the given key * * @param data The data to decrypt * @return The decrypted bytes */ public static byte[] decrypt(byte[] data, byte[] key, byte[] iv) { if (key == null || iv == null) { throw new AssertionError("DECRYPT: Key or iv were not specified."); } // make sure key is AES256 byte[] bookKeyData = new byte[32]; byte[] outBuf; System.arraycopy(key, 0, bookKeyData, 0, key.length); try { PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine())); cipher.init(false, new ParametersWithIV(new KeyParameter(bookKeyData), iv)); int outputSize = cipher.getOutputSize(data.length); outBuf = new byte[cipher.getOutputSize(outputSize)]; int processed = cipher.processBytes(data, 0, data.length, outBuf, 0); if (processed &lt; outputSize) { processed += cipher.doFinal(outBuf, processed); } return Arrays.copyOfRange(outBuf, 0, processed); } catch (Exception e) { e.printStackTrace(); } return null; } </code></pre> <p>Oh and.. yes. I am aware this is CBC, I am aware of why it should not be used etc. Currently, it is done on purpose. This is not the topic of the question, so let's not go there.</p>
0debug
How can I convert this date format? : <p>An API I use provides a date in the object like <code>2018-02-14T17:00:00</code>. How can I convert this to make it say: <code>Tuesday, February 14th 7:00 pm</code></p> <p>I know how to use <code>.getMonth()</code> methods on a date object but is it possible to do something similar with a string in a date format like this in Javascript?</p>
0debug
yuv2yuvX_altivec_real(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize, int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW) { const vector signed int vini = {(1 << 18), (1 << 18), (1 << 18), (1 << 18)}; register int i, j; { int __attribute__ ((aligned (16))) val[dstW]; for (i = 0; i < (dstW -7); i+=4) { vec_st(vini, i << 2, val); } for (; i < dstW; i++) { val[i] = (1 << 18); } for (j = 0; j < lumFilterSize; j++) { vector signed short l1, vLumFilter = vec_ld(j << 1, lumFilter); vector unsigned char perm, perm0 = vec_lvsl(j << 1, lumFilter); vLumFilter = vec_perm(vLumFilter, vLumFilter, perm0); vLumFilter = vec_splat(vLumFilter, 0); perm = vec_lvsl(0, lumSrc[j]); l1 = vec_ld(0, lumSrc[j]); for (i = 0; i < (dstW - 7); i+=8) { int offset = i << 2; vector signed short l2 = vec_ld((i << 1) + 16, lumSrc[j]); vector signed int v1 = vec_ld(offset, val); vector signed int v2 = vec_ld(offset + 16, val); vector signed short ls = vec_perm(l1, l2, perm); vector signed int i1 = vec_mule(vLumFilter, ls); vector signed int i2 = vec_mulo(vLumFilter, ls); vector signed int vf1 = vec_mergeh(i1, i2); vector signed int vf2 = vec_mergel(i1, i2); vector signed int vo1 = vec_add(v1, vf1); vector signed int vo2 = vec_add(v2, vf2); vec_st(vo1, offset, val); vec_st(vo2, offset + 16, val); l1 = l2; } for ( ; i < dstW; i++) { val[i] += lumSrc[j][i] * lumFilter[j]; } } altivec_packIntArrayToCharArray(val,dest,dstW); } if (uDest != 0) { int __attribute__ ((aligned (16))) u[chrDstW]; int __attribute__ ((aligned (16))) v[chrDstW]; for (i = 0; i < (chrDstW -7); i+=4) { vec_st(vini, i << 2, u); vec_st(vini, i << 2, v); } for (; i < chrDstW; i++) { u[i] = (1 << 18); v[i] = (1 << 18); } for (j = 0; j < chrFilterSize; j++) { vector signed short l1, l1_V, vChrFilter = vec_ld(j << 1, chrFilter); vector unsigned char perm, perm0 = vec_lvsl(j << 1, chrFilter); vChrFilter = vec_perm(vChrFilter, vChrFilter, perm0); vChrFilter = vec_splat(vChrFilter, 0); perm = vec_lvsl(0, chrSrc[j]); l1 = vec_ld(0, chrSrc[j]); l1_V = vec_ld(2048 << 1, chrSrc[j]); for (i = 0; i < (chrDstW - 7); i+=8) { int offset = i << 2; vector signed short l2 = vec_ld((i << 1) + 16, chrSrc[j]); vector signed short l2_V = vec_ld(((i + 2048) << 1) + 16, chrSrc[j]); vector signed int v1 = vec_ld(offset, u); vector signed int v2 = vec_ld(offset + 16, u); vector signed int v1_V = vec_ld(offset, v); vector signed int v2_V = vec_ld(offset + 16, v); vector signed short ls = vec_perm(l1, l2, perm); vector signed short ls_V = vec_perm(l1_V, l2_V, perm); vector signed int i1 = vec_mule(vChrFilter, ls); vector signed int i2 = vec_mulo(vChrFilter, ls); vector signed int i1_V = vec_mule(vChrFilter, ls_V); vector signed int i2_V = vec_mulo(vChrFilter, ls_V); vector signed int vf1 = vec_mergeh(i1, i2); vector signed int vf2 = vec_mergel(i1, i2); vector signed int vf1_V = vec_mergeh(i1_V, i2_V); vector signed int vf2_V = vec_mergel(i1_V, i2_V); vector signed int vo1 = vec_add(v1, vf1); vector signed int vo2 = vec_add(v2, vf2); vector signed int vo1_V = vec_add(v1_V, vf1_V); vector signed int vo2_V = vec_add(v2_V, vf2_V); vec_st(vo1, offset, u); vec_st(vo2, offset + 16, u); vec_st(vo1_V, offset, v); vec_st(vo2_V, offset + 16, v); l1 = l2; l1_V = l2_V; } for ( ; i < chrDstW; i++) { u[i] += chrSrc[j][i] * chrFilter[j]; v[i] += chrSrc[j][i + 2048] * chrFilter[j]; } } altivec_packIntArrayToCharArray(u,uDest,chrDstW); altivec_packIntArrayToCharArray(v,vDest,chrDstW); } }
1threat
I am a begineer, unable to run a very simple android app on emulator : I am new to Android app development. I created a new a project on Android Studio, which can run on Ice cream sandwich and later versions. Just added one activity : "Basic activiy" from the list of activities. Then tried to run the app on emulator Nexus 5x. But the app did not run, and the gradle build shows 61 errors. I am listing some of the errors below: Error:java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0 Error: at java.lang.ClassLoader.defineClass1(Native Method) Error:java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0 Error: at java.lang.ClassLoader.defineClass(ClassLoader.java:800) Error: at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) Error: at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) Error: at java.net.URLClassLoader.access$100(URLClassLoader.java:71) Error: at java.net.URLClassLoader$1.run(URLClassLoader.java:361) Error: at java.net.URLClassLoader$1.run(URLClassLoader.java:355) Error: at java.security.AccessController.doPrivileged(Native Method) Error: at java.net.URLClassLoader.findClass(URLClassLoader.java:354) Error: at java.lang.ClassLoader.loadClass(ClassLoader.java:425) Error: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) Error: at java.lang.ClassLoader.loadClass(ClassLoader.java:358) Error: at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482) Error:Exception in thread "main" Error: at java.lang.ClassLoader.defineClass1(Native Method) Error: at java.lang.ClassLoader.defineClass(ClassLoader.java:800) Error: at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) Error: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) Error: at java.lang.ClassLoader.loadClass(ClassLoader.java:358) Error: at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482) Error:Exception in thread "main" Error:Execution failed for task ':app:transformClassesWithDexForDebug'. > com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1 I don't understand what these errors mean. Would be grateful if someone can help me out.
0debug
static void tcp_wait_for_connect(int fd, Error *err, void *opaque) { MigrationState *s = opaque; if (fd < 0) { DPRINTF("migrate connect error: %s\n", error_get_pretty(err)); s->to_dst_file = NULL; migrate_fd_error(s); } else { DPRINTF("migrate connect success\n"); s->to_dst_file = qemu_fopen_socket(fd, "wb"); migrate_fd_connect(s); } }
1threat
How to parse JSON Text in Java : <p>I have the following JSON text. How can I parse it to get response-code, response, result, DISPLAYNAME ,AVAILABILITYSEVERITY, RESOURCEID , ETC?</p> <p>{ "response-code":"4000", "response": { "result": [ { "DISPLAYNAME":"Backup Server", "AVAILABILITYSEVERITY":"5", "RESOURCEID":"10002239110", "TYPE":"SUN", "SHORTMESSAGE":"Clear" } ] ,"uri":"/json/ListAlarms" } }</p>
0debug
static int qcow2_make_empty(BlockDriverState *bs) { BDRVQcow2State *s = bs->opaque; uint64_t start_sector; int sector_step = INT_MAX / BDRV_SECTOR_SIZE; int l1_clusters, ret = 0; l1_clusters = DIV_ROUND_UP(s->l1_size, s->cluster_size / sizeof(uint64_t)); if (s->qcow_version >= 3 && !s->snapshots && 3 + l1_clusters <= s->refcount_block_size) { return make_completely_empty(bs); } for (start_sector = 0; start_sector < bs->total_sectors; start_sector += sector_step) { ret = qcow2_discard_clusters(bs, start_sector * BDRV_SECTOR_SIZE, MIN(sector_step, bs->total_sectors - start_sector), QCOW2_DISCARD_SNAPSHOT, true); if (ret < 0) { break; } } return ret; }
1threat
static void tpm_tis_mmio_write_intern(void *opaque, hwaddr addr, uint64_t val, unsigned size, bool hw_access) { TPMState *s = opaque; TPMTISEmuState *tis = &s->s.tis; uint16_t off = addr & 0xffc; uint8_t shift = (addr & 0x3) * 8; uint8_t locty = tpm_tis_locality_from_addr(addr); uint8_t active_locty, l; int c, set_new_locty = 1; uint16_t len; uint32_t mask = (size == 1) ? 0xff : ((size == 2) ? 0xffff : ~0); DPRINTF("tpm_tis: write.%u(%08x) = %08x\n", size, (int)addr, (uint32_t)val); if (locty == 4 && !hw_access) { DPRINTF("tpm_tis: Access to locality 4 only allowed from hardware\n"); return; } if (tpm_backend_had_startup_error(s->be_driver)) { return; } val &= mask; if (shift) { val <<= shift; mask <<= shift; } mask ^= 0xffffffff; switch (off) { case TPM_TIS_REG_ACCESS: if ((val & TPM_TIS_ACCESS_SEIZE)) { val &= ~(TPM_TIS_ACCESS_REQUEST_USE | TPM_TIS_ACCESS_ACTIVE_LOCALITY); } active_locty = tis->active_locty; if ((val & TPM_TIS_ACCESS_ACTIVE_LOCALITY)) { if (tis->active_locty == locty) { DPRINTF("tpm_tis: Releasing locality %d\n", locty); uint8_t newlocty = TPM_TIS_NO_LOCALITY; for (c = TPM_TIS_NUM_LOCALITIES - 1; c >= 0; c--) { if ((tis->loc[c].access & TPM_TIS_ACCESS_REQUEST_USE)) { DPRINTF("tpm_tis: Locality %d requests use.\n", c); newlocty = c; break; } } DPRINTF("tpm_tis: TPM_TIS_ACCESS_ACTIVE_LOCALITY: " "Next active locality: %d\n", newlocty); if (TPM_TIS_IS_VALID_LOCTY(newlocty)) { set_new_locty = 0; tpm_tis_prep_abort(s, locty, newlocty); } else { active_locty = TPM_TIS_NO_LOCALITY; } } else { tis->loc[locty].access &= ~TPM_TIS_ACCESS_REQUEST_USE; } } if ((val & TPM_TIS_ACCESS_BEEN_SEIZED)) { tis->loc[locty].access &= ~TPM_TIS_ACCESS_BEEN_SEIZED; } if ((val & TPM_TIS_ACCESS_SEIZE)) { while ((TPM_TIS_IS_VALID_LOCTY(tis->active_locty) && locty > tis->active_locty) || !TPM_TIS_IS_VALID_LOCTY(tis->active_locty)) { bool higher_seize = FALSE; if ((tis->loc[locty].access & TPM_TIS_ACCESS_SEIZE)) { break; } for (l = locty + 1; l < TPM_TIS_NUM_LOCALITIES; l++) { if ((tis->loc[l].access & TPM_TIS_ACCESS_SEIZE)) { higher_seize = TRUE; break; } } if (higher_seize) { break; } for (l = 0; l < locty - 1; l++) { tis->loc[l].access &= ~TPM_TIS_ACCESS_SEIZE; } tis->loc[locty].access |= TPM_TIS_ACCESS_SEIZE; DPRINTF("tpm_tis: TPM_TIS_ACCESS_SEIZE: " "Locality %d seized from locality %d\n", locty, tis->active_locty); DPRINTF("tpm_tis: TPM_TIS_ACCESS_SEIZE: Initiating abort.\n"); set_new_locty = 0; tpm_tis_prep_abort(s, tis->active_locty, locty); break; } } if ((val & TPM_TIS_ACCESS_REQUEST_USE)) { if (tis->active_locty != locty) { if (TPM_TIS_IS_VALID_LOCTY(tis->active_locty)) { tis->loc[locty].access |= TPM_TIS_ACCESS_REQUEST_USE; } else { active_locty = locty; } } } if (set_new_locty) { tpm_tis_new_active_locality(s, active_locty); } break; case TPM_TIS_REG_INT_ENABLE: if (tis->active_locty != locty) { break; } tis->loc[locty].inte &= mask; tis->loc[locty].inte |= (val & (TPM_TIS_INT_ENABLED | TPM_TIS_INT_POLARITY_MASK | TPM_TIS_INTERRUPTS_SUPPORTED)); break; case TPM_TIS_REG_INT_VECTOR: break; case TPM_TIS_REG_INT_STATUS: if (tis->active_locty != locty) { break; } if (((val & TPM_TIS_INTERRUPTS_SUPPORTED)) && (tis->loc[locty].ints & TPM_TIS_INTERRUPTS_SUPPORTED)) { tis->loc[locty].ints &= ~val; if (tis->loc[locty].ints == 0) { qemu_irq_lower(tis->irq); DPRINTF("tpm_tis: Lowering IRQ\n"); } } tis->loc[locty].ints &= ~(val & TPM_TIS_INTERRUPTS_SUPPORTED); break; case TPM_TIS_REG_STS: if (tis->active_locty != locty) { break; } val &= (TPM_TIS_STS_COMMAND_READY | TPM_TIS_STS_TPM_GO | TPM_TIS_STS_RESPONSE_RETRY); if (val == TPM_TIS_STS_COMMAND_READY) { switch (tis->loc[locty].state) { case TPM_TIS_STATE_READY: tis->loc[locty].w_offset = 0; tis->loc[locty].r_offset = 0; break; case TPM_TIS_STATE_IDLE: tis->loc[locty].sts = TPM_TIS_STS_COMMAND_READY; tis->loc[locty].state = TPM_TIS_STATE_READY; tpm_tis_raise_irq(s, locty, TPM_TIS_INT_COMMAND_READY); break; case TPM_TIS_STATE_EXECUTION: case TPM_TIS_STATE_RECEPTION: DPRINTF("tpm_tis: %s: Initiating abort.\n", __func__); tpm_tis_prep_abort(s, locty, locty); break; case TPM_TIS_STATE_COMPLETION: tis->loc[locty].w_offset = 0; tis->loc[locty].r_offset = 0; tis->loc[locty].state = TPM_TIS_STATE_READY; if (!(tis->loc[locty].sts & TPM_TIS_STS_COMMAND_READY)) { tis->loc[locty].sts = TPM_TIS_STS_COMMAND_READY; tpm_tis_raise_irq(s, locty, TPM_TIS_INT_COMMAND_READY); } tis->loc[locty].sts &= ~(TPM_TIS_STS_DATA_AVAILABLE); break; } } else if (val == TPM_TIS_STS_TPM_GO) { switch (tis->loc[locty].state) { case TPM_TIS_STATE_RECEPTION: if ((tis->loc[locty].sts & TPM_TIS_STS_EXPECT) == 0) { tpm_tis_tpm_send(s, locty); } break; default: break; } } else if (val == TPM_TIS_STS_RESPONSE_RETRY) { switch (tis->loc[locty].state) { case TPM_TIS_STATE_COMPLETION: tis->loc[locty].r_offset = 0; tis->loc[locty].sts = TPM_TIS_STS_VALID | TPM_TIS_STS_DATA_AVAILABLE; break; default: break; } } break; case TPM_TIS_REG_DATA_FIFO: case TPM_TIS_REG_DATA_XFIFO ... TPM_TIS_REG_DATA_XFIFO_END: if (tis->active_locty != locty) { break; } if (tis->loc[locty].state == TPM_TIS_STATE_IDLE || tis->loc[locty].state == TPM_TIS_STATE_EXECUTION || tis->loc[locty].state == TPM_TIS_STATE_COMPLETION) { } else { DPRINTF("tpm_tis: Data to send to TPM: %08x (size=%d)\n", val, size); if (tis->loc[locty].state == TPM_TIS_STATE_READY) { tis->loc[locty].state = TPM_TIS_STATE_RECEPTION; tis->loc[locty].sts = TPM_TIS_STS_EXPECT | TPM_TIS_STS_VALID; } val >>= shift; if (size > 4 - (addr & 0x3)) { size = 4 - (addr & 0x3); } while ((tis->loc[locty].sts & TPM_TIS_STS_EXPECT) && size > 0) { if (tis->loc[locty].w_offset < tis->loc[locty].w_buffer.size) { tis->loc[locty].w_buffer. buffer[tis->loc[locty].w_offset++] = (uint8_t)val; val >>= 8; size--; } else { tis->loc[locty].sts = TPM_TIS_STS_VALID; } } if (tis->loc[locty].w_offset > 5 && (tis->loc[locty].sts & TPM_TIS_STS_EXPECT)) { #ifdef RAISE_STS_IRQ bool needIrq = !(tis->loc[locty].sts & TPM_TIS_STS_VALID); #endif len = tpm_tis_get_size_from_buffer(&tis->loc[locty].w_buffer); if (len > tis->loc[locty].w_offset) { tis->loc[locty].sts = TPM_TIS_STS_EXPECT | TPM_TIS_STS_VALID; } else { tis->loc[locty].sts = TPM_TIS_STS_VALID; } #ifdef RAISE_STS_IRQ if (needIrq) { tpm_tis_raise_irq(s, locty, TPM_TIS_INT_STS_VALID); } #endif } } break; } }
1threat
static int local_mkdir(FsContext *fs_ctx, const char *path, FsCred *credp) { int err = -1; int serrno = 0; if (fs_ctx->fs_sm == SM_MAPPED) { err = mkdir(rpath(fs_ctx, path), SM_LOCAL_DIR_MODE_BITS); if (err == -1) { return err; } credp->fc_mode = credp->fc_mode|S_IFDIR; err = local_set_xattr(rpath(fs_ctx, path), credp); if (err == -1) { serrno = errno; goto err_end; } } else if (fs_ctx->fs_sm == SM_PASSTHROUGH) { err = mkdir(rpath(fs_ctx, path), credp->fc_mode); if (err == -1) { return err; } err = local_post_create_passthrough(fs_ctx, path, credp); if (err == -1) { serrno = errno; goto err_end; } } return err; err_end: remove(rpath(fs_ctx, path)); errno = serrno; return err; }
1threat
static CharDriverState *qemu_chr_open_pp_fd(int fd, ChardevCommon *backend, Error **errp) { CharDriverState *chr; ParallelCharDriver *drv; if (ioctl(fd, PPCLAIM) < 0) { error_setg_errno(errp, errno, "not a parallel port"); close(fd); return NULL; } drv = g_new0(ParallelCharDriver, 1); drv->fd = fd; drv->mode = IEEE1284_MODE_COMPAT; chr = qemu_chr_alloc(backend, errp); if (!chr) { return NULL; } chr->chr_write = null_chr_write; chr->chr_ioctl = pp_ioctl; chr->chr_close = pp_close; chr->opaque = drv; return chr; }
1threat
TreeMap implementation in java returns only last element : <p>This is a class whose object I want to put in a TreeMap. </p> <pre><code>public class JobDefinition { private static String jobDescription; private static String datasetName; private static String jobName; private static String responsiblePerson; public JobDefinition(String jobDesc, String dataSet, String jobName2, String person) { jobDescription=jobDesc; datasetName=dataSet; jobName=jobName2; responsiblePerson=person; } public String getJobDescription() { return jobDescription; } public String getDatasetName() { return datasetName; } public String getJobName() { return jobName; } public String getResponsiblePerson() { return responsiblePerson; } } </code></pre> <p>Here I am fetching values from Spreadsheet using POI library. TreeMap uses a integer as Key and Object of above class as its value.</p> <pre><code>for (int rowCount = rowStartIndex+1; rowCount &lt; rowEndIndex; rowCount++) { String jobDesc=spreadsheet.getRow(rowCount).getCell(0).toString(); String dataSet=spreadsheet.getRow(rowCount).getCell(1).toString(); String jobName=spreadsheet.getRow(rowCount).getCell(2).toString(); String person =spreadsheet.getRow(rowCount).getCell(3).toString(); if(!jobName.equals("N/A") &amp;&amp; jobName!=""){ validJobCount++; jobDefinitionInfo.put(validJobCount, new JobDefinition(jobDesc,dataSet,jobName,person)); } } for(Map.Entry&lt;Integer,JobDefinition&gt; entry : jobDefinitionInfo.entrySet()) { System.out.println(entry.getKey()+"::"+entry.getValue().getJobDescription()); } </code></pre> <p>When all value is set in Map. And I iterate over it. I get correct key but all corresponding values (which is an object of JobDefinition class) against it is the last value which was placed.</p> <p><strong>Output::</strong></p> <pre><code>1::Monthly UPDTMEND File 2::Monthly UPDTMEND File 3::Monthly UPDTMEND File 4::Monthly UPDTMEND File 5::Monthly UPDTMEND File 6::Monthly UPDTMEND File 7::Monthly UPDTMEND File 8::Monthly UPDTMEND File 9::Monthly UPDTMEND File 10::Monthly UPDTMEND File </code></pre> <p><strong>Expected Output</strong></p> <pre><code>1::VRSFEND - TRANSACTION SWEEP 2::XCTLOAD 3::CHEKDATE - TO IDENTIFY BACKDATED TRANSACTIONS 4::EDITALIVE 5::EDITB 6::PRICE LOAD 7::ACCTSIM - run manually 8::ACCTLIV - run manually by DVG 9::Check Sybase jobs 10::Monthly UPDTMEND File </code></pre> <p>I feel there is something wrong with Implementation. Please tell me what more should be added to make it run correctly.</p>
0debug
iOS TableView reload and scroll top : <p>the second day I can not solve the problem with the table.</p> <p>We have a segmentedControl which, when changed, changes the table. Suppose that there are 3 elements in the segment of the control and, correspondingly, 3 arrays (which is important, they are of different sizes) I need to scroll table up when segmentedControl is changed.</p> <p>And it seems like everything is simple: contentOffset = .zero and reloadData ()</p> <p>But. This does not work, I do not know why the table not scroll up.</p> <p>The only thing that worked:</p> <pre><code>UIView.animate (withDuration: 0.1, animations: { Β Β Β Β Β Β Β Β Β Β Β Β self.tableView.contentOffset = .zero Β Β Β Β Β Β Β Β }) {(_) in Β Β Β Β Β Β Β Β Β Β Β Β self.tableView.reloadData () } </code></pre> <p>But now there is another problem when the table goes up, a bug may occur, because the segmentedControl has changed, and the data in the other array may not be, we have not yet done reloadData ()</p> <p>Maybe I can not understand the obvious things)) Congrats on the upcoming holidays!</p>
0debug
Accidentally touch the cpu's fan paste : <p>I accidentally touch my new cpu's fan paste. In your opinion is it ok or i need to remove and put a new one?</p> <p><a href="https://ibb.co/j42qqb" rel="nofollow noreferrer">img1</a></p> <p><a href="https://ibb.co/gwXqqb" rel="nofollow noreferrer">img2</a></p>
0debug
static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg) { MpegEncContext *s = &v->s; uint8_t *srcY; int dxy, mx, my, src_x, src_y; int off; int fieldmv = (v->fcm == ILACE_FRAME) ? v->blk_mv_type[s->block_index[n]] : 0; int v_edge_pos = s->v_edge_pos >> v->field_mode; uint8_t (*luty)[256]; int use_ic; if ((!v->field_mode || (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) && !v->s.last_picture.f.data[0]) return; mx = s->mv[dir][n][0]; my = s->mv[dir][n][1]; if (!dir) { if (v->field_mode && (v->cur_field_type != v->ref_field_type[dir]) && v->second_field) { srcY = s->current_picture.f.data[0]; luty = v->curr_luty; use_ic = v->curr_use_ic; } else { srcY = s->last_picture.f.data[0]; luty = v->last_luty; use_ic = v->last_use_ic; } } else { srcY = s->next_picture.f.data[0]; luty = v->next_luty; use_ic = v->next_use_ic; } if (!srcY) { av_log(v->s.avctx, AV_LOG_ERROR, "Referenced frame missing.\n"); return; } if (v->field_mode) { if (v->cur_field_type != v->ref_field_type[dir]) my = my - 2 + 4 * v->cur_field_type; } if (s->pict_type == AV_PICTURE_TYPE_P && n == 3 && v->field_mode) { int same_count = 0, opp_count = 0, k; int chosen_mv[2][4][2], f; int tx, ty; for (k = 0; k < 4; k++) { f = v->mv_f[0][s->block_index[k] + v->blocks_off]; chosen_mv[f][f ? opp_count : same_count][0] = s->mv[0][k][0]; chosen_mv[f][f ? opp_count : same_count][1] = s->mv[0][k][1]; opp_count += f; same_count += 1 - f; } f = opp_count > same_count; switch (f ? opp_count : same_count) { case 4: tx = median4(chosen_mv[f][0][0], chosen_mv[f][1][0], chosen_mv[f][2][0], chosen_mv[f][3][0]); ty = median4(chosen_mv[f][0][1], chosen_mv[f][1][1], chosen_mv[f][2][1], chosen_mv[f][3][1]); break; case 3: tx = mid_pred(chosen_mv[f][0][0], chosen_mv[f][1][0], chosen_mv[f][2][0]); ty = mid_pred(chosen_mv[f][0][1], chosen_mv[f][1][1], chosen_mv[f][2][1]); break; case 2: tx = (chosen_mv[f][0][0] + chosen_mv[f][1][0]) / 2; ty = (chosen_mv[f][0][1] + chosen_mv[f][1][1]) / 2; break; } s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx; s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty; for (k = 0; k < 4; k++) v->mv_f[1][s->block_index[k] + v->blocks_off] = f; } if (v->fcm == ILACE_FRAME) { int qx, qy; int width = s->avctx->coded_width; int height = s->avctx->coded_height >> 1; if (s->pict_type == AV_PICTURE_TYPE_P) { s->current_picture.motion_val[1][s->block_index[n] + v->blocks_off][0] = mx; s->current_picture.motion_val[1][s->block_index[n] + v->blocks_off][1] = my; } qx = (s->mb_x * 16) + (mx >> 2); qy = (s->mb_y * 8) + (my >> 3); if (qx < -17) mx -= 4 * (qx + 17); else if (qx > width) mx -= 4 * (qx - width); if (qy < -18) my -= 8 * (qy + 18); else if (qy > height + 1) my -= 8 * (qy - height - 1); } if ((v->fcm == ILACE_FRAME) && fieldmv) off = ((n > 1) ? s->linesize : 0) + (n & 1) * 8; else off = s->linesize * 4 * (n & 2) + (n & 1) * 8; src_x = s->mb_x * 16 + (n & 1) * 8 + (mx >> 2); if (!fieldmv) src_y = s->mb_y * 16 + (n & 2) * 4 + (my >> 2); else src_y = s->mb_y * 16 + ((n > 1) ? 1 : 0) + (my >> 2); if (v->profile != PROFILE_ADVANCED) { src_x = av_clip(src_x, -16, s->mb_width * 16); src_y = av_clip(src_y, -16, s->mb_height * 16); } else { src_x = av_clip(src_x, -17, s->avctx->coded_width); if (v->fcm == ILACE_FRAME) { if (src_y & 1) src_y = av_clip(src_y, -17, s->avctx->coded_height + 1); else src_y = av_clip(src_y, -18, s->avctx->coded_height); } else { src_y = av_clip(src_y, -18, s->avctx->coded_height + 1); } } srcY += src_y * s->linesize + src_x; if (v->field_mode && v->ref_field_type[dir]) srcY += s->current_picture_ptr->f.linesize[0]; if (fieldmv && !(src_y & 1)) v_edge_pos--; if (fieldmv && (src_y & 1) && src_y < 4) src_y--; if (v->rangeredfrm || use_ic || s->h_edge_pos < 13 || v_edge_pos < 23 || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx & 3) - 8 - s->mspel * 2 || (unsigned)(src_y - (s->mspel << fieldmv)) > v_edge_pos - (my & 3) - ((8 + s->mspel * 2) << fieldmv)) { srcY -= s->mspel * (1 + (s->linesize << fieldmv)); s->vdsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, s->linesize, 9 + s->mspel * 2, (9 + s->mspel * 2) << fieldmv, src_x - s->mspel, src_y - (s->mspel << fieldmv), s->h_edge_pos, v_edge_pos); srcY = s->edge_emu_buffer; if (v->rangeredfrm) { int i, j; uint8_t *src; src = srcY; for (j = 0; j < 9 + s->mspel * 2; j++) { for (i = 0; i < 9 + s->mspel * 2; i++) src[i] = ((src[i] - 128) >> 1) + 128; src += s->linesize << fieldmv; } } if (use_ic) { int i, j; uint8_t *src; src = srcY; for (j = 0; j < 9 + s->mspel * 2; j++) { int f = v->field_mode ? v->ref_field_type[dir] : (((j<<fieldmv)+src_y - (s->mspel << fieldmv)) & 1); for (i = 0; i < 9 + s->mspel * 2; i++) src[i] = luty[f][src[i]]; src += s->linesize << fieldmv; } } srcY += s->mspel * (1 + (s->linesize << fieldmv)); } if (s->mspel) { dxy = ((my & 3) << 2) | (mx & 3); if (avg) v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize << fieldmv, v->rnd); else v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize << fieldmv, v->rnd); } else { dxy = (my & 2) | ((mx & 2) >> 1); if (!v->rnd) s->hdsp.put_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8); else s->hdsp.put_no_rnd_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8); } }
1threat
int usb_handle_packet(USBDevice *dev, USBPacket *p) { int ret; if (dev == NULL) { return USB_RET_NODEV; } assert(dev->addr == p->devaddr); assert(dev->state == USB_STATE_DEFAULT); assert(p->state == USB_PACKET_SETUP); if (p->devep == 0) { switch (p->pid) { case USB_TOKEN_SETUP: ret = do_token_setup(dev, p); break; case USB_TOKEN_IN: ret = do_token_in(dev, p); break; case USB_TOKEN_OUT: ret = do_token_out(dev, p); break; default: ret = USB_RET_STALL; break; } } else { ret = usb_device_handle_data(dev, p); } if (ret == USB_RET_ASYNC) { p->ep = usb_ep_get(dev, p->pid, p->devep); p->state = USB_PACKET_ASYNC; } return ret; }
1threat
Use sed to print lines that start with z and do not end in 03 : <p>I need to print the lines in a text file using the sed command that start with z and do not end in 03. Any help would be appreciated. </p>
0debug
ImportError: No module named 'google' : <p>This is not a duplicate. My scenario is a bit different and I could not find a solution from similar posts here. I installed Python 3.5. I ran the pip install google command and verified the modules. Google was present. I installed Anaconda 3.5 and tried to run z sample code. But I'm getting the import error. Please find the screen shot attached. What am I missing? Do I have to link my Spyder to Python installation directory in some way? Why is Spyder unable to google module?</p> <p>My Python installation directory: C:\Users\XXX\AppData\Local\Programs\Python\Python35 <a href="https://i.stack.imgur.com/3nhad.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/3nhad.jpg" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/YZ3PC.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/YZ3PC.jpg" alt="enter image description here"></a></p>
0debug
list comprehension of a nested list to update list element on that nested list in python : <p>I have below snippets. I have used <strong>for loop</strong> to get 'updated_orders'. How can I make list comprehension to get 'updated_orders'. </p> <pre><code>orders = [[30, 'Seana', 'Nutter', 5, 'Classic Leather Jacket', 7, '$94.26'], [13, 'Katy', 'Furmonger', 2, 'Yellow Wool Jumper', 1, '$175.31']] updated_orders = [] for order in orders: order.append(order[5] * float(order[6].split('$')[1])) updated_orders.append(order) print(updated_orders) </code></pre> <p>output:</p> <pre><code>[[30, 'Seana', 'Nutter', 5, 'Classic Leather Jacket', 7, '$94.26', 659.82], [13, 'Katy', 'Furmonger', 2, 'Yellow Wool Jumper', 1, '$175.31', 175.31]] </code></pre>
0debug
Proxy in package.json not affecting fetch request : <p>I am trying to fetch some data from the development server using React.</p> <p>I am running the client on <code>localhost:3001</code> and the backend on <code>port 3000</code>.</p> <p><strong>The fetch request :</strong> </p> <pre><code> const laina = fetch('/api/users'); laina.then((err,res) =&gt; { console.log(res); }) </code></pre> <p>When I run my development server and webpack-dev-server I get the following output:</p> <pre><code>GET http://localhost:3001/api/users 404 (Not Found) </code></pre> <p>I tried specifying the proxy in the <em>package.json</em> so it would proxy the request to the API server, however nothing has changed.</p> <p>Here is my <strong>package.json file</strong>: </p> <p><a href="https://i.stack.imgur.com/1RZta.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1RZta.png" alt="enter image description here"></a></p> <p>.. and the <strong>webpack.config</strong> : <a href="https://i.stack.imgur.com/54g3u.png" rel="noreferrer"><img src="https://i.stack.imgur.com/54g3u.png" alt="enter image description here"></a></p> <p>Please tell me, if you need to see anything else from my project. I apologies, if I'm missing something and not being thorough, I'm still quite new to using these technologies. </p>
0debug
void HELPER(crypto_aesmc)(CPUARMState *env, uint32_t rd, uint32_t rm, uint32_t decrypt) { static uint32_t const mc[][256] = { { 0x00000000, 0x03010102, 0x06020204, 0x05030306, 0x0c040408, 0x0f05050a, 0x0a06060c, 0x0907070e, 0x18080810, 0x1b090912, 0x1e0a0a14, 0x1d0b0b16, 0x140c0c18, 0x170d0d1a, 0x120e0e1c, 0x110f0f1e, 0x30101020, 0x33111122, 0x36121224, 0x35131326, 0x3c141428, 0x3f15152a, 0x3a16162c, 0x3917172e, 0x28181830, 0x2b191932, 0x2e1a1a34, 0x2d1b1b36, 0x241c1c38, 0x271d1d3a, 0x221e1e3c, 0x211f1f3e, 0x60202040, 0x63212142, 0x66222244, 0x65232346, 0x6c242448, 0x6f25254a, 0x6a26264c, 0x6927274e, 0x78282850, 0x7b292952, 0x7e2a2a54, 0x7d2b2b56, 0x742c2c58, 0x772d2d5a, 0x722e2e5c, 0x712f2f5e, 0x50303060, 0x53313162, 0x56323264, 0x55333366, 0x5c343468, 0x5f35356a, 0x5a36366c, 0x5937376e, 0x48383870, 0x4b393972, 0x4e3a3a74, 0x4d3b3b76, 0x443c3c78, 0x473d3d7a, 0x423e3e7c, 0x413f3f7e, 0xc0404080, 0xc3414182, 0xc6424284, 0xc5434386, 0xcc444488, 0xcf45458a, 0xca46468c, 0xc947478e, 0xd8484890, 0xdb494992, 0xde4a4a94, 0xdd4b4b96, 0xd44c4c98, 0xd74d4d9a, 0xd24e4e9c, 0xd14f4f9e, 0xf05050a0, 0xf35151a2, 0xf65252a4, 0xf55353a6, 0xfc5454a8, 0xff5555aa, 0xfa5656ac, 0xf95757ae, 0xe85858b0, 0xeb5959b2, 0xee5a5ab4, 0xed5b5bb6, 0xe45c5cb8, 0xe75d5dba, 0xe25e5ebc, 0xe15f5fbe, 0xa06060c0, 0xa36161c2, 0xa66262c4, 0xa56363c6, 0xac6464c8, 0xaf6565ca, 0xaa6666cc, 0xa96767ce, 0xb86868d0, 0xbb6969d2, 0xbe6a6ad4, 0xbd6b6bd6, 0xb46c6cd8, 0xb76d6dda, 0xb26e6edc, 0xb16f6fde, 0x907070e0, 0x937171e2, 0x967272e4, 0x957373e6, 0x9c7474e8, 0x9f7575ea, 0x9a7676ec, 0x997777ee, 0x887878f0, 0x8b7979f2, 0x8e7a7af4, 0x8d7b7bf6, 0x847c7cf8, 0x877d7dfa, 0x827e7efc, 0x817f7ffe, 0x9b80801b, 0x98818119, 0x9d82821f, 0x9e83831d, 0x97848413, 0x94858511, 0x91868617, 0x92878715, 0x8388880b, 0x80898909, 0x858a8a0f, 0x868b8b0d, 0x8f8c8c03, 0x8c8d8d01, 0x898e8e07, 0x8a8f8f05, 0xab90903b, 0xa8919139, 0xad92923f, 0xae93933d, 0xa7949433, 0xa4959531, 0xa1969637, 0xa2979735, 0xb398982b, 0xb0999929, 0xb59a9a2f, 0xb69b9b2d, 0xbf9c9c23, 0xbc9d9d21, 0xb99e9e27, 0xba9f9f25, 0xfba0a05b, 0xf8a1a159, 0xfda2a25f, 0xfea3a35d, 0xf7a4a453, 0xf4a5a551, 0xf1a6a657, 0xf2a7a755, 0xe3a8a84b, 0xe0a9a949, 0xe5aaaa4f, 0xe6abab4d, 0xefacac43, 0xecadad41, 0xe9aeae47, 0xeaafaf45, 0xcbb0b07b, 0xc8b1b179, 0xcdb2b27f, 0xceb3b37d, 0xc7b4b473, 0xc4b5b571, 0xc1b6b677, 0xc2b7b775, 0xd3b8b86b, 0xd0b9b969, 0xd5baba6f, 0xd6bbbb6d, 0xdfbcbc63, 0xdcbdbd61, 0xd9bebe67, 0xdabfbf65, 0x5bc0c09b, 0x58c1c199, 0x5dc2c29f, 0x5ec3c39d, 0x57c4c493, 0x54c5c591, 0x51c6c697, 0x52c7c795, 0x43c8c88b, 0x40c9c989, 0x45caca8f, 0x46cbcb8d, 0x4fcccc83, 0x4ccdcd81, 0x49cece87, 0x4acfcf85, 0x6bd0d0bb, 0x68d1d1b9, 0x6dd2d2bf, 0x6ed3d3bd, 0x67d4d4b3, 0x64d5d5b1, 0x61d6d6b7, 0x62d7d7b5, 0x73d8d8ab, 0x70d9d9a9, 0x75dadaaf, 0x76dbdbad, 0x7fdcdca3, 0x7cdddda1, 0x79dedea7, 0x7adfdfa5, 0x3be0e0db, 0x38e1e1d9, 0x3de2e2df, 0x3ee3e3dd, 0x37e4e4d3, 0x34e5e5d1, 0x31e6e6d7, 0x32e7e7d5, 0x23e8e8cb, 0x20e9e9c9, 0x25eaeacf, 0x26ebebcd, 0x2fececc3, 0x2cededc1, 0x29eeeec7, 0x2aefefc5, 0x0bf0f0fb, 0x08f1f1f9, 0x0df2f2ff, 0x0ef3f3fd, 0x07f4f4f3, 0x04f5f5f1, 0x01f6f6f7, 0x02f7f7f5, 0x13f8f8eb, 0x10f9f9e9, 0x15fafaef, 0x16fbfbed, 0x1ffcfce3, 0x1cfdfde1, 0x19fefee7, 0x1affffe5, }, { 0x00000000, 0x0b0d090e, 0x161a121c, 0x1d171b12, 0x2c342438, 0x27392d36, 0x3a2e3624, 0x31233f2a, 0x58684870, 0x5365417e, 0x4e725a6c, 0x457f5362, 0x745c6c48, 0x7f516546, 0x62467e54, 0x694b775a, 0xb0d090e0, 0xbbdd99ee, 0xa6ca82fc, 0xadc78bf2, 0x9ce4b4d8, 0x97e9bdd6, 0x8afea6c4, 0x81f3afca, 0xe8b8d890, 0xe3b5d19e, 0xfea2ca8c, 0xf5afc382, 0xc48cfca8, 0xcf81f5a6, 0xd296eeb4, 0xd99be7ba, 0x7bbb3bdb, 0x70b632d5, 0x6da129c7, 0x66ac20c9, 0x578f1fe3, 0x5c8216ed, 0x41950dff, 0x4a9804f1, 0x23d373ab, 0x28de7aa5, 0x35c961b7, 0x3ec468b9, 0x0fe75793, 0x04ea5e9d, 0x19fd458f, 0x12f04c81, 0xcb6bab3b, 0xc066a235, 0xdd71b927, 0xd67cb029, 0xe75f8f03, 0xec52860d, 0xf1459d1f, 0xfa489411, 0x9303e34b, 0x980eea45, 0x8519f157, 0x8e14f859, 0xbf37c773, 0xb43ace7d, 0xa92dd56f, 0xa220dc61, 0xf66d76ad, 0xfd607fa3, 0xe07764b1, 0xeb7a6dbf, 0xda595295, 0xd1545b9b, 0xcc434089, 0xc74e4987, 0xae053edd, 0xa50837d3, 0xb81f2cc1, 0xb31225cf, 0x82311ae5, 0x893c13eb, 0x942b08f9, 0x9f2601f7, 0x46bde64d, 0x4db0ef43, 0x50a7f451, 0x5baafd5f, 0x6a89c275, 0x6184cb7b, 0x7c93d069, 0x779ed967, 0x1ed5ae3d, 0x15d8a733, 0x08cfbc21, 0x03c2b52f, 0x32e18a05, 0x39ec830b, 0x24fb9819, 0x2ff69117, 0x8dd64d76, 0x86db4478, 0x9bcc5f6a, 0x90c15664, 0xa1e2694e, 0xaaef6040, 0xb7f87b52, 0xbcf5725c, 0xd5be0506, 0xdeb30c08, 0xc3a4171a, 0xc8a91e14, 0xf98a213e, 0xf2872830, 0xef903322, 0xe49d3a2c, 0x3d06dd96, 0x360bd498, 0x2b1ccf8a, 0x2011c684, 0x1132f9ae, 0x1a3ff0a0, 0x0728ebb2, 0x0c25e2bc, 0x656e95e6, 0x6e639ce8, 0x737487fa, 0x78798ef4, 0x495ab1de, 0x4257b8d0, 0x5f40a3c2, 0x544daacc, 0xf7daec41, 0xfcd7e54f, 0xe1c0fe5d, 0xeacdf753, 0xdbeec879, 0xd0e3c177, 0xcdf4da65, 0xc6f9d36b, 0xafb2a431, 0xa4bfad3f, 0xb9a8b62d, 0xb2a5bf23, 0x83868009, 0x888b8907, 0x959c9215, 0x9e919b1b, 0x470a7ca1, 0x4c0775af, 0x51106ebd, 0x5a1d67b3, 0x6b3e5899, 0x60335197, 0x7d244a85, 0x7629438b, 0x1f6234d1, 0x146f3ddf, 0x097826cd, 0x02752fc3, 0x335610e9, 0x385b19e7, 0x254c02f5, 0x2e410bfb, 0x8c61d79a, 0x876cde94, 0x9a7bc586, 0x9176cc88, 0xa055f3a2, 0xab58faac, 0xb64fe1be, 0xbd42e8b0, 0xd4099fea, 0xdf0496e4, 0xc2138df6, 0xc91e84f8, 0xf83dbbd2, 0xf330b2dc, 0xee27a9ce, 0xe52aa0c0, 0x3cb1477a, 0x37bc4e74, 0x2aab5566, 0x21a65c68, 0x10856342, 0x1b886a4c, 0x069f715e, 0x0d927850, 0x64d90f0a, 0x6fd40604, 0x72c31d16, 0x79ce1418, 0x48ed2b32, 0x43e0223c, 0x5ef7392e, 0x55fa3020, 0x01b79aec, 0x0aba93e2, 0x17ad88f0, 0x1ca081fe, 0x2d83bed4, 0x268eb7da, 0x3b99acc8, 0x3094a5c6, 0x59dfd29c, 0x52d2db92, 0x4fc5c080, 0x44c8c98e, 0x75ebf6a4, 0x7ee6ffaa, 0x63f1e4b8, 0x68fcedb6, 0xb1670a0c, 0xba6a0302, 0xa77d1810, 0xac70111e, 0x9d532e34, 0x965e273a, 0x8b493c28, 0x80443526, 0xe90f427c, 0xe2024b72, 0xff155060, 0xf418596e, 0xc53b6644, 0xce366f4a, 0xd3217458, 0xd82c7d56, 0x7a0ca137, 0x7101a839, 0x6c16b32b, 0x671bba25, 0x5638850f, 0x5d358c01, 0x40229713, 0x4b2f9e1d, 0x2264e947, 0x2969e049, 0x347efb5b, 0x3f73f255, 0x0e50cd7f, 0x055dc471, 0x184adf63, 0x1347d66d, 0xcadc31d7, 0xc1d138d9, 0xdcc623cb, 0xd7cb2ac5, 0xe6e815ef, 0xede51ce1, 0xf0f207f3, 0xfbff0efd, 0x92b479a7, 0x99b970a9, 0x84ae6bbb, 0x8fa362b5, 0xbe805d9f, 0xb58d5491, 0xa89a4f83, 0xa397468d, } }; union AES_STATE st = { .l = { float64_val(env->vfp.regs[rm]), float64_val(env->vfp.regs[rm + 1]) } }; int i; assert(decrypt < 2); for (i = 0; i < 16; i += 4) { st.cols[i >> 2] = cpu_to_le32( mc[decrypt][st.bytes[i]] ^ rol32(mc[decrypt][st.bytes[i + 1]], 8) ^ rol32(mc[decrypt][st.bytes[i + 2]], 16) ^ rol32(mc[decrypt][st.bytes[i + 3]], 24)); } env->vfp.regs[rd] = make_float64(st.l[0]); env->vfp.regs[rd + 1] = make_float64(st.l[1]); }
1threat
Javascript - can you throw an object in an Error? : <p>Is it possible to throw an object using Error? In the example below the console shows <code>undefined</code>.</p> <pre><code>try { throw Error({foo: 'bar'}); } catch (err) { console.log(err.message.foo); } </code></pre>
0debug
pandas get average of a groupby : <p>I am trying to find the average monthly cost per user_id but i am only able to get average cost per user or monthly cost per user. </p> <p>Because i group by user and month, there is no way to get the average of the second groupby (month) unless i transform the groupby output to something else.</p> <p>This is my df:</p> <pre><code> df = { 'id' : pd.Series([1,1,1,1,2,2,2,2]), 'cost' : pd.Series([10,20,30,40,50,60,70,80]), 'mth': pd.Series([3,3,4,5,3,4,4,5])} cost id mth 0 10 1 3 1 20 1 3 2 30 1 4 3 40 1 5 4 50 2 3 5 60 2 4 6 70 2 4 7 80 2 5 </code></pre> <p>I can get monthly sum but i want the average of the months for each user_id. </p> <pre><code>df.groupby(['id','mth'])['cost'].sum() id mth 1 3 30 4 30 5 40 2 3 50 4 130 5 80 </code></pre> <p>i want something like this:</p> <pre><code>id average_monthly 1 (30+30+40)/3 2 (50+130+80)/3 </code></pre>
0debug
static int h261_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; H261Context *h = avctx->priv_data; MpegEncContext *s = &h->s; int ret; AVFrame *pict = data; av_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size); av_dlog(avctx, "bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]); s->flags = avctx->flags; s->flags2 = avctx->flags2; h->gob_start_code_skipped = 0; retry: init_get_bits(&s->gb, buf, buf_size * 8); if (!s->context_initialized) if (ff_MPV_common_init(s) < 0) return -1; ret = h261_decode_picture_header(h); if (ret < 0) { av_log(s->avctx, AV_LOG_ERROR, "header damaged\n"); return -1; } if (s->width != avctx->coded_width || s->height != avctx->coded_height) { ParseContext pc = s->parse_context; s->parse_context.buffer = 0; ff_MPV_common_end(s); s->parse_context = pc; } if (!s->context_initialized) { ret = ff_set_dimensions(avctx, s->width, s->height); if (ret < 0) return ret; goto retry; } s->current_picture.f.pict_type = s->pict_type; s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I; if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) || (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) || avctx->skip_frame >= AVDISCARD_ALL) return get_consumed_bytes(s, buf_size); if (ff_MPV_frame_start(s, avctx) < 0) return -1; ff_mpeg_er_frame_start(s); s->mb_x = 0; s->mb_y = 0; while (h->gob_number < (s->mb_height == 18 ? 12 : 5)) { if (h261_resync(h) < 0) break; h261_decode_gob(h); } ff_MPV_frame_end(s); assert(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type); assert(s->current_picture.f.pict_type == s->pict_type); if ((ret = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->current_picture_ptr); *got_frame = 1; return get_consumed_bytes(s, buf_size); }
1threat
static void add_to_iovec(QEMUFile *f, const uint8_t *buf, int size) { if (f->iovcnt > 0 && buf == f->iov[f->iovcnt - 1].iov_base + f->iov[f->iovcnt - 1].iov_len) { f->iov[f->iovcnt - 1].iov_len += size; } else { f->iov[f->iovcnt].iov_base = (uint8_t *)buf; f->iov[f->iovcnt++].iov_len = size; } if (f->buf_index >= IO_BUF_SIZE || f->iovcnt >= MAX_IOV_SIZE) { qemu_fflush(f); } }
1threat
static void ppc_spapr_reset(void) { sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); PowerPCCPU *first_ppc_cpu; uint32_t rtas_limit; foreach_dynamic_sysbus_device(find_unknown_sysbus_device, NULL); spapr_reset_htab(spapr); qemu_devices_reset(); rtas_limit = MIN(spapr->rma_size, RTAS_MAX_ADDR); spapr->rtas_addr = rtas_limit - RTAS_MAX_SIZE; spapr->fdt_addr = spapr->rtas_addr - FDT_MAX_SIZE; spapr_finalize_fdt(spapr, spapr->fdt_addr, spapr->rtas_addr, spapr->rtas_size); cpu_physical_memory_write(spapr->rtas_addr, spapr->rtas_blob, spapr->rtas_size); first_ppc_cpu = POWERPC_CPU(first_cpu); first_ppc_cpu->env.gpr[3] = spapr->fdt_addr; first_ppc_cpu->env.gpr[5] = 0; first_cpu->halted = 0; first_ppc_cpu->env.nip = spapr->entry_point; }
1threat
Webpack ts-loader : change tsconfig filename : <p>I have 2 tsconfigs, one for my dev build and one for my prod build.<br> I choose the tsconfig with the <code>-p</code> flag :<br> <code>tsc -p dev.tsconfig.json</code></p> <p>Ts-loader is looking for a tsconfig.json file. How can I specify another filename with the ts-loader?</p> <pre><code>module.exports = { entry : __dirname + "/src/app/main.ts", output : { path : __dirname + "/dist", filename : "bundle.js" }, resolve : { extensions : ["", ".webpack.js", ".web.js", ".js", ".ts"] }, module: { loaders: [ { test: /\.ts?$/, loader: "ts" } ] } }; </code></pre>
0debug
FUSE inside Docker : <p>I'm trying to install and use FUSE inside a Docker container. My Dockerfile is the following:</p> <pre><code>FROM golang:1.8 WORKDIR /go/src/app COPY . . RUN apt-get update &amp;&amp; apt-get install -y fuse &amp;&amp; rm -rf /var/lib/apt/lists/* RUN go-wrapper download RUN go-wrapper install CMD ["go-wrapper", "run", "/mnt"] </code></pre> <p>When I run the program mounting FUSE, I get: <code>/bin/fusermount: fuse device not found, try 'modprobe fuse' first</code>.</p> <p>If I install <code>kmod</code> and run <code>modprobe fuse</code> during the build step, I get the error:</p> <p><code>modprobe: ERROR: ../libkmod/libkmod.c:557 kmod_search_moddep() could not open moddep file '/lib/modules/4.4.104-boot2docker/modules.dep.bin'</code></p> <p>How can I fix this?</p>
0debug
How to put minus (-) before some specific columns in R : I have a data frame containing 2000 columns. Majority of the columns have "X111, X222 ,X123" , all of this X111, X222, X333 are all numeric variables, and I want to convert all the positive values to negative values Before: Β¦ 1COL1 Β¦ 2COL Β¦ 3COL Β¦ XCOL Β¦ 4COL Β¦ XXCOL Β¦ All (+)ve values. After: Β¦ 1COL1 Β¦ 2COL Β¦ 3COL Β¦ XCOL Β¦ 4COL Β¦ XXCOL Β¦ + + + _ + _
0debug
def Check_Solution(a,b,c): if b == 0: return ("Yes") else: return ("No")
0debug
Create bool mask from filter results in Pandas : <p>I know how to create a mask to filter a dataframe when querying a single column:</p> <pre><code>import pandas as pd import datetime index = pd.date_range('2013-1-1',periods=100,freq='30Min') data = pd.DataFrame(data=list(range(100)), columns=['value'], index=index) data['value2'] = 'A' data['value2'].loc[0:10] = 'B' data value value2 2013-01-01 00:00:00 0 B 2013-01-01 00:30:00 1 B 2013-01-01 01:00:00 2 B 2013-01-01 01:30:00 3 B 2013-01-01 02:00:00 4 B 2013-01-01 02:30:00 5 B 2013-01-01 03:00:00 6 B </code></pre> <p>I use a simple mask here:</p> <pre><code>mask = data['value'] &gt; 4 data[mask] value value2 2013-01-01 02:30:00 5 B 2013-01-01 03:00:00 6 B 2013-01-01 03:30:00 7 B 2013-01-01 04:00:00 8 B 2013-01-01 04:30:00 9 B 2013-01-01 05:00:00 10 A </code></pre> <p>My question is how to create a mask with multiple columns? So if I do this:</p> <pre><code>data[data['value2'] == 'A' ][data['value'] &gt; 4] </code></pre> <p>This filters as I would expect but how do I create a bool mask from this as per my other example? I have provided the test data for this but I often want to create a mask on other types of data so Im looking for any pointers please. </p>
0debug
How do you enable word-wrap by default in Eclipse? : <p>Simple question: how do you enable word-wrap by default in Eclipse? I looked at <a href="http://dev.cdhq.de/eclipse/word-wrap/" rel="noreferrer">this plugin</a> but it only goes up to Luna. In addition, <a href="https://marketplace.eclipse.org/content/markdown-text-editor" rel="noreferrer">this plugin</a> is a separate text editor and does not have syntax highlighting or validation. I'm open to other suggestions.</p>
0debug
I want to learn the inbuilt classes and methods in java libraries? please guide : <p>Please give some to-do task and techniques to learn inbuilt classes and methods in packages! I want to became a successful java developer!</p>
0debug
how to total up all drop down menu : i need help im new to this but i have 3 drop down menus how would i total them all up to prompt the screen if the total is over 10 in total i have add the code im using below <table align="center" width="360" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="270" align="right">N1:</td> <td width="270" align="right"><select name="N1" id="N1"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select></td> <td width="270" align="right">N2:</td> <td width="270" align="right"><select name="N2" id="N2"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select></td> </tr> <td width="370" align="right">N3:</td> <td width="270" align="right"><select name="N3" id="N3"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </td> </tr> </table>
0debug
int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { Mpeg4DecContext *ctx = avctx->priv_data; MpegEncContext *s = &ctx->m; if (s->divx_packed) { int current_pos = s->gb.buffer == s->bitstream_buffer ? 0 : (get_bits_count(&s->gb) >> 3); int startcode_found = 0; if (buf_size - current_pos > 7) { int i; for (i = current_pos; i < buf_size - 4; i++) if (buf[i] == 0 && buf[i + 1] == 0 && buf[i + 2] == 1 && buf[i + 3] == 0xB6) { startcode_found = !(buf[i + 4] & 0x40); break; } } if (startcode_found) { av_fast_malloc(&s->bitstream_buffer, &s->allocated_bitstream_buffer_size, buf_size - current_pos + FF_INPUT_BUFFER_PADDING_SIZE); if (!s->bitstream_buffer) return AVERROR(ENOMEM); memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos); s->bitstream_buffer_size = buf_size - current_pos; } } return 0; }
1threat
av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale) { int n, n4, i; double alpha, theta; int tstep; memset(s, 0, sizeof(*s)); n = 1 << nbits; s->mdct_bits = nbits; s->mdct_size = n; n4 = n >> 2; s->permutation = FF_MDCT_PERM_NONE; if (ff_fft_init(s, s->mdct_bits - 2, inverse) < 0) goto fail; s->tcos = av_malloc(n/2 * sizeof(FFTSample)); if (!s->tcos) goto fail; switch (s->permutation) { case FF_MDCT_PERM_NONE: s->tsin = s->tcos + n4; tstep = 1; break; case FF_MDCT_PERM_INTERLEAVE: s->tsin = s->tcos + 1; tstep = 2; break; default: goto fail; } theta = 1.0 / 8.0 + (scale < 0 ? n4 : 0); scale = sqrt(fabs(scale)); for(i=0;i<n4;i++) { alpha = 2 * M_PI * (i + theta) / n; s->tcos[i*tstep] = -cos(alpha) * scale; s->tsin[i*tstep] = -sin(alpha) * scale; } return 0; fail: ff_mdct_end(s); return -1; }
1threat
PYQT5 self.close() will close the program even though selfEvent() has self.ignore() inside : when i click 'X' on my application, and press "No" from MessageBox, the program **will not be closed**. But when i click "Quit" from the Menu and click "No" from the MessageBox, the program **will still be closed** successfully.... my code is something like this: ``` exitAction = menu.addAction("Quit") exitAction.triggered.connect(self.close) ``` then my closeEvent() code is: ``` def closeEvent(self, event): reply = QMessageBox.question(self, 'Quit', 'Are You Sure to Quit?', QMessageBox.No | QMessageBox.Yes) if reply == QMessageBox.Yes: event.accept() else: event.ignore() ```
0debug
Nested less css for tags : <p>I am creating some tags -- and have a bit of markup like this</p> <pre><code>&lt;div class="tag"&gt;Tag&lt;/div&gt; </code></pre> <p>and this will create a small white border round tag. It could have different media variants and in this instance want to add an icon to the tag, I'm trying to architect the less but its not taking hold.</p> <pre><code>&lt;div class="tag .get_app"&gt;Tag&lt;/div&gt; &lt;div class="tag .get_app"&gt;Tag&lt;/div&gt; &lt;div class="tag .get_app"&gt;Tag&lt;/div&gt; </code></pre> <p><a href="http://jsfiddle.net/pg886/182/" rel="nofollow noreferrer">http://jsfiddle.net/pg886/182/</a></p> <pre><code>.tag { position: absolute; top: 0; left: 0; text-transform: uppercase; border-radius: 20px; padding: 11px 35px 9px 20px; color: pink; background: white; display: inline-block; text-shadow: none; font-size: 12px; font-weight: 700; line-height: 12px; font-family: Roboto, sans-serif; &amp;::after { position: absolute; top: 6px; right: 6px; border-radius: 50%; background: red; padding: 4px; display: inline-block; color: white; font-family: 'Material Icons'; font-weight: normal; font-style: normal; text-transform: none; .get_app &amp; { content: "\E884"; } .play_arrow &amp; { content: "\E037"; } .volume_up &amp; { content: "\E050"; } } } </code></pre>
0debug
joi_1.default.validate is not a function : <p>I want to validate my Express routes before calling the controller logic. I use joi and created a validator which is able to validate the Request object against the schema object</p> <pre><code>import { Request, Response, NextFunction } from 'express'; import joi, { SchemaLike, ValidationError, ValidationResult } from '@hapi/joi'; import { injectable } from 'inversify'; @injectable() export abstract class RequestValidator { protected validateRequest = (validationSchema: SchemaLike, request: Request, response: Response, next: NextFunction): void =&gt; { const validationResult: ValidationResult&lt;Request&gt; = joi.validate(request, validationSchema, { abortEarly: false }); const { error }: { error: ValidationError } = validationResult; if (error) { response.status(400).json({ message: 'The request validation failed.', details: error.details }); } else { next(); } } } </code></pre> <p>Next I created a deriving class which creates the validationSchema and calls the <code>validateRequest</code> method. For the sake of simplicity I will show the "deleteUserById" validation</p> <pre><code>import { Request, Response, NextFunction } from 'express'; import joi, { SchemaLike } from '@hapi/joi'; import { injectable } from 'inversify'; import { RequestValidator } from './RequestValidator'; @injectable() export class UserRequestValidator extends RequestValidator { public deleteUserByIdValidation = async (request: Request, response: Response, next: NextFunction): Promise&lt;void&gt; =&gt; { const validationSchema: SchemaLike = joi.object().keys({ params: joi.object().keys({ id: joi.number().required(), }) }); this.validateRequest(validationSchema, request, response, next); } } </code></pre> <p><strong>Important note:</strong> I create the <code>SchemaLike</code> that way because some routes might have <code>params, body, query</code> which need to get validated in one run. </p> <p>When calling the Route </p> <blockquote> <p>DELETE /users/1</p> </blockquote> <p>the validation always fails. I get this error</p> <blockquote> <p>UnhandledPromiseRejectionWarning: TypeError: joi_1.default.validate is not a function</p> </blockquote> <p>The error occurs with every validation, whether called correctly or not. Does someone know how to fix it?</p>
0debug
Exclude columns by names in mutate_at in dplyr : <p>I am trying to do something very simple, and yet can't figure out the right way to specify. I simply want to exclude some named columns from <code>mutate_at</code>. It works fine if I specify position, but I don't want to hard code positions.</p> <p>For example, I want the same output as this:</p> <pre><code>mtcars %&gt;% mutate_at(-c(1, 2), max) </code></pre> <p>But, by specifying <code>mpg</code> and <code>cyl</code> column names.</p> <p>I tried many things, including:</p> <pre><code>mtcars %&gt;% mutate_at(-c('mpg', 'cyl'), max) </code></pre> <p>Is there a way to work with names and exclusion in <code>mutate_at</code>?</p>
0debug
static int stellaris_sys_init(uint32_t base, qemu_irq irq, stellaris_board_info * board, uint8_t *macaddr) { ssys_state *s; s = (ssys_state *)g_malloc0(sizeof(ssys_state)); s->irq = irq; s->board = board; s->user0 = macaddr[0] | (macaddr[1] << 8) | (macaddr[2] << 16); s->user1 = macaddr[3] | (macaddr[4] << 8) | (macaddr[5] << 16); memory_region_init_io(&s->iomem, NULL, &ssys_ops, s, "ssys", 0x00001000); memory_region_add_subregion(get_system_memory(), base, &s->iomem); ssys_reset(s); vmstate_register(NULL, -1, &vmstate_stellaris_sys, s); return 0; }
1threat
static int read_ir(AVFilterLink *inlink, AVFrame *frame) { AVFilterContext *ctx = inlink->dst; HeadphoneContext *s = ctx->priv; int ir_len, max_ir_len, input_number; for (input_number = 0; input_number < s->nb_inputs; input_number++) if (inlink == ctx->inputs[input_number]) break; av_audio_fifo_write(s->in[input_number].fifo, (void **)frame->extended_data, frame->nb_samples); av_frame_free(&frame); ir_len = av_audio_fifo_size(s->in[input_number].fifo); max_ir_len = 65536; if (ir_len > max_ir_len) { av_log(ctx, AV_LOG_ERROR, "Too big length of IRs: %d > %d.\n", ir_len, max_ir_len); return AVERROR(EINVAL); } s->in[input_number].ir_len = ir_len; s->ir_len = FFMAX(ir_len, s->ir_len); return 0; }
1threat
static AddressSpace *virtio_pci_get_dma_as(DeviceState *d) { VirtIOPCIProxy *proxy = VIRTIO_PCI(d); PCIDevice *dev = &proxy->pci_dev; return pci_get_address_space(dev); }
1threat
Explain like I'm LITERALLY five...what does it mean to "format" a string? : <p>When you make a string...what does it mean to "format" that string?</p> <p>CHALLENGE: Explain this to me like I'm an absolute idiot. Like, take it to a condescending level. Be mean about it. I'm talking how you would explain a lemonade stand to a very, very stupid child.</p>
0debug
Using inputs and functions as a values in a dictionary : First, is there anyway to use input() as a value in a dictionary? I have tried: dictionary = {'1': input('Choose: [1]Red [2]Blue'), '2':input('Choose: [1]Green [2]Yellow)} but this returns the first input: 'Choose: [1]Red [2]Blue' Second, I know you can use functions in dictionaries but how would you give the argument for the function. For example: dictionary = {'1': func1(), '2': func2()} action = input('[1] or [2]') dictionary[action] Would I have to define a key for every argument possible for func1 or func2?
0debug
How to destructure object properties with key names that are invalid variable names? : <p>As object keys are strings they can contain any kind of characters and special characters. I recently stumbled upon an object which I receive from an API call. This object has '-' in it's key names.</p> <pre><code>const object = { "key-with-dash": [] } </code></pre> <p>Destructuring does not work in this case because <code>key-with-dash</code> is not a valid variable name.</p> <pre><code>const { key-with-dash } = object; </code></pre> <p>So one question came to my mind. How am I supposed to destructure the object in such cases? Is it even possible at all?</p>
0debug
Python - Dump ques about nest loop in Python : I got a dump question about nest loop in Python. I just wanna to figure out why that second statement will follow the fist statement to loop 5 times? Below are my loop code, hope someone can explanation to me. Thanks in advance! :) for steps1 in range(5): print('@@@') print('@@@') for steps2 in range(4): print('###') print('###')
0debug
Why ActiveMQ 5.14.x can't start embedded with camel-jms component 2.18.3 : <p>Here is the simple spring boot project (version <code>1.5.2</code>) to demonstrate the problem:</p> <p><a href="https://github.com/lanwen/camel-jms-activemq-test" rel="noreferrer">https://github.com/lanwen/camel-jms-activemq-test</a></p> <p>It has <strong>Apache Camel</strong> version <strong>2.18.3</strong></p> <p>On branch <code>master</code> all works fine because of <code>activemq-camel=5.14.4</code> and <code>camel-jms=2.16.3</code> (gets transitively from it)</p> <p>Spring boot application starts normally with log:</p> <pre><code>2017-04-22 00:53:19.647 INFO 97217 --- [ main] o.a.camel.spring.SpringCamelContext : Apache Camel 2.18.3 (CamelContext: camel-1) is starting 2017-04-22 00:53:19.662 INFO 97173 --- [ main] o.apache.activemq.broker.BrokerService : Apache ActiveMQ 5.14.4 (localhost, ID:lanwen-osx3.local-62145-1492811599544-0:1) is starting 2017-04-22 00:53:19.665 INFO 97173 --- [ main] o.apache.activemq.broker.BrokerService : Apache ActiveMQ 5.14.4 (localhost, ID:lanwen-osx3.local-62145-1492811599544-0:1) started 2017-04-22 00:53:19.665 INFO 97173 --- [ main] o.apache.activemq.broker.BrokerService : For help or more information please see: http://activemq.apache.org 2017-04-22 00:53:19.682 INFO 97173 --- [ main] o.a.activemq.broker.TransportConnector : Connector vm://localhost started 2017-04-22 00:53:19.702 INFO 97173 --- [ main] o.a.camel.spring.SpringCamelContext : Route: route1 started and consuming from: activemq://queue:to-write?asyncConsumer=true 2017-04-22 00:53:19.703 INFO 97173 --- [ main] o.a.camel.spring.SpringCamelContext : Total 1 routes, of which 1 are started. 2017-04-22 00:53:19.704 INFO 97173 --- [ main] o.a.camel.spring.SpringCamelContext : Apache Camel 2.18.3 (CamelContext: camel-1) started in 0.466 seconds 2017-04-22 00:53:19.709 INFO 97173 --- [ main] ru.yandex.test.writer.MyTestApplication : Started MyTestApplication in 2.437 seconds (JVM running for 2.911) </code></pre> <p>But when you start with <code>camel-jms=2.18.3</code> (as the main version of camel, on branch <a href="https://github.com/lanwen/camel-jms-activemq-test/tree/not_working" rel="noreferrer">not_working</a>)</p> <p>Things go wrong with this log:</p> <pre><code>2017-04-22 00:56:38.070 INFO 97195 --- [ main] o.a.camel.spring.SpringCamelContext : Apache Camel 2.18.3 (CamelContext: camel-1) is starting ... 2017-04-22 00:56:43.590 WARN 97195 --- [ActiveMQ Task-1] o.a.a.t.failover.FailoverTransport : Failed to connect to [tcp://localhost:61616] after: 10 attempt(s) continuing to retry. </code></pre> <p>But if we change <code>activemq-camel</code> to <code>5.13.4</code> with <code>camel-jms=2.18.3</code> it works fine again...</p> <p>Why ActiveMQ <strong>5.14.x</strong> doesn't work with camel-jms <strong>2.18.x</strong>?</p>
0debug
Detached entity passed to persist in Spring-Data : <p>I have two tables in my db <code>Brand</code> and <code>Product</code> with the next simple structure:</p> <p>| Brand | id PK | </p> <p>| Product | id PK | brand_id FK |</p> <p>and entities for that tables:</p> <pre><code>@Entity @Table(name = "Brand") public class Brand { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(name = "brand") private String brand; /* getters and setters */ } </code></pre> <hr> <pre><code>@Entity @Table(name = "Product") public class Product { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name = "brand_id") private Brand brand; /* getters and setters */ } </code></pre> <p>As I use Spring-Data I have repository and service with implementation for Brand:</p> <pre><code>@Repository public interface BrandRepository extends JpaRepository&lt;Brand, Long&gt; { Brand findByBrand(String brand); } </code></pre> <hr> <pre><code>public interface BrandService { Brand findByBrand(String brand); } </code></pre> <hr> <pre><code>@Service public class BrandServiceImpl implements BrandService { @Autowired private BrandRepository brandRepository; @Override public Brand findByBrand(String brand) { return brandRepository.findByBrand(brand); } } </code></pre> <p>and for Product:</p> <pre><code>@Repository public interface ProductRepository extends JpaRepository&lt;Product, Long&gt; { } </code></pre> <hr> <pre><code>public interface ProductService { Product save(Product product); } </code></pre> <hr> <pre><code>@Service public class ProductServiceImpl implements ProductService { @Autowired private ProductRepository productRepository; @Override public Product save(Product product) { return productRepository.save(product); } } </code></pre> <p>The goal is to save Product object. Brand object should be saved automatically if it doesn't exist in db or should be set to Product otherwise:</p> <pre><code>Brand brand = brandService.findByBrand(brandName); if (brand == null) { brand = new Brand(); brand.setBrand("Some name"); } product.setBrand(brand); productService.save(product); </code></pre> <p>It works fine if Brand object with specified brandName is not in my db. But if it is I get:</p> <pre><code>PersistentObjectException: detached entity passed to persist </code></pre> <p>for Brand.</p> <p>I can change cascade type to MERGE and it will work fine. But if I run the code with MERGE cascade type and Brand object with specified brandName is not in my db I get</p> <pre><code>IllegalStateException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing </code></pre> <p>for Brand (that's really not surprised).</p> <p>What Cascade Type should be? Ot what I did wrong?</p>
0debug
PRINTING CORRECT OUTPUT IN SHELL SCRIPT : I have this following code #!/bin/sh echo "hello" echo "enter salutation $abc" Read -r abc If [ "$abc" = "1" ] Then Echo "hiii" Elif [ "$abc" = "2"] Then Echo "no hi" Fi Echo "enter name $xyz" Read -r xyz If [ "$xyz" = "1" ] Then Echo "Chris" Elif ["$xyz" = "2" ] Then Echo "Morris" Fi Echo "final data" Echo " you entered salutation as " "$abc" Echo "you entered name as "$xyz" Out put comes as Hello Enter the number 1 Hiii Enter name 1 Chris You entered salutation as 1 You entered name as 1 What I want is You entered salutation as hii You entered name as chris
0debug
void qemu_system_killed(int signal, pid_t pid) { shutdown_signal = signal; shutdown_pid = pid; no_shutdown = 0; shutdown_requested = 1; qemu_notify_event(); }
1threat
Explanation why it doesn't return what it should : <p>I have function that gets info about students from a file "Curent.txt".</p> <p>That's the struct:</p> <pre><code>struct students { string CodSt; string NumeSt; string PrenSt; string DenDisc1; string MedCD1; string DenDisc2; string MedCD2; string DenDisc3; string MedCD3; } student[50]; </code></pre> <p>That's the function:</p> <pre><code>void getStudents() { int i = 0; ifstream ifs("Curenta.txt"); while(!ifs.eof()) { ifs &gt;&gt; student[i].CodSt &gt;&gt; student[i].NumeSt &gt;&gt; student[i].PrenSt &gt;&gt; student[i].DenDisc1 &gt;&gt; student[i].MedCD1 &gt;&gt; student[i].DenDisc2 &gt;&gt; student[i].MedCD2 &gt;&gt; student[i].DenDisc3 &gt;&gt; student[i].MedCD3; if(!ifs.eof()) { i++; cout &lt;&lt; i; } var = i; ifs.close(); } </code></pre> <p>And in "Curent.txt" i have only this:</p> <pre><code>9 8 1 1 6 1 1 1 1 3 1 1 1 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 1 </code></pre> <p>My question is why when I output variable "i", the value is just 1..</p> <p>Thanks in advance.</p>
0debug
compare Date in Android : Hello im trying to compare two date in android but im getting this notification [notification][1] when i write this SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyy"); String valid_until = "26052018"; final Date strDate = sdf.parse(valid_until); and if i put the try and catch like this [try n catch][2] i cant compare the date because it say i didnt declared strDate [cant compare][3] [1]: https://i.stack.imgur.com/DsNCX.png [2]: https://i.stack.imgur.com/FUwzz.png [3]: https://i.stack.imgur.com/neXZb.png
0debug
mysqli_query(): Empty query mysqli_error() expects exactly 1 parameter, 0 given : <p>I am creating a register page. the form has an email, password, confirm password, student ID, first name, second name, Course, Gender and DoB. I want the page to collect that information and store it in the database.</p> <p>2 Errors:</p> <p>mysqli_query(): Empty query</p> <p>mysqli_error() expects exactly 1 parameter, 0 given</p> <pre><code> $sql = mysqli_query($connection, "INSERT INTO tblaccounts (Email, Password, Student_ID, ID, FirstName, SecondName, Course, Gender, DoB) VALUES ('".$email."','".$password."','".$Student_ID."','".$id."','".$FN."','".$SN."','".$course."','".$gender."','".$dob."')"); $result = mysqli_query($connection, $sql) or die("Database Connection Failed" . mysqli_error()); $count = mysqli_num_rows($result); &lt;?php require_once 'connect.php'; require_once 'logincheck.php'; if (($_COOKIE['userID']) == null){ //true //show sign in ?&gt; &lt;li&gt;&lt;p&gt;&lt;center&gt;&lt;a class="btn btn-primary btn-lg" href="login.php" role="button"&gt;Sign In&lt;/a&gt;&lt;center&gt;&lt;/p&gt;&lt;/li&gt; &lt;?php //show register button ?&gt; &lt;li&gt;&lt;p&gt;&lt;center&gt;&lt;a class="btn btn-primary btn-lg" href="register.php" role="button"&gt;Register&lt;/a&gt;&lt;center&gt;&lt;/p&gt;&lt;/li&gt; &lt;?php } else { //false //show 'logged in as' ?&gt; &lt;li&gt;&lt;a href="#"&gt;Logged in as: &lt;?php echo ($_COOKIE['user']) ?&gt;&lt;/a&gt;&lt;/li&gt; &lt;?php//show 'my profile'?&gt; &lt;li&gt;&lt;a href="#"&gt;My Profile&lt;/a&gt;&lt;/li&gt; &lt;?php//show 'settings'.?&gt; &lt;li&gt;&lt;a href="#"&gt;Settings&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;p&gt;&lt;center&gt;&lt;a class="btn btn-primary btn-lg" href="logout.php" role="button"&gt;Sign Out&lt;/a&gt;&lt;center&gt;&lt;/p&gt;&lt;/li&gt; &lt;!--&lt;br/&gt;&lt;a href ="login.php"&gt;Go back to the login screen.&lt;/a&gt;--&gt; &lt;!--logged in menu--&gt; &lt;!--&lt;li&gt;&lt;a href="#"&gt;User ID: &lt;php echo ($_COOKIE['userID']) ?&gt;&lt;/a&gt;&lt;/li&gt;--&gt; &lt;/ul&gt; &lt;?php } ?&gt; </code></pre>
0debug
The mouse pointer manipulating code : <p>Suppose , I am in the year , let's say , in 1950's or 1960's . I don't have much facilities available in the programming languages available to me , like , PASCAL or FORTRAN OR ALGOL, and only recently "computer mouse " has been introduced and invented and only recently they are being supplied along with computer and when attached to one particular port in my computer I can see a "small arrow" on the computer screen (let it be even a CRT screen , hope you would allow relaxation for the lack of synchronization with actual chronology ) moving in accordance with the way I moved the mouse . </p> <p>Now I wanted to have computer programs that could control the mouse pointer on screen. Let's say I want to write a computer program which would move the mouse pointer in the direction opposite to the direction in which I am moving the mouse or a computer program to freeze the pointer on the mouse screen for few seconds or a computer program to change the shape of the mouse pointer when the mouse is moved to a specific part of the screen .</p> <p>Given this requirement how will my language interact with the system to control the mouse pointer . Will the compiler of my language be changed to add few more instructions (or methods or functions ) which will yield machine code controlling the mouse pointers ? </p>
0debug
static void dec_modu(DisasContext *dc) { int l1; LOG_DIS("modu r%d, r%d, %d\n", dc->r2, dc->r0, dc->r1); if (!(dc->env->features & LM32_FEATURE_DIVIDE)) { cpu_abort(dc->env, "hardware divider is not available\n"); } l1 = gen_new_label(); tcg_gen_brcondi_tl(TCG_COND_NE, cpu_R[dc->r1], 0, l1); tcg_gen_movi_tl(cpu_pc, dc->pc); t_gen_raise_exception(dc, EXCP_DIVIDE_BY_ZERO); gen_set_label(l1); tcg_gen_remu_tl(cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]); }
1threat
Regex Notepad++ - add quotes around timestamp : <p>I have many records in the format : 1900-01-03 00:00:00</p> <p>I want to modify all of them to '1900-01-03 00:00:00'</p> <p>I saw some posts on regex and tried some combinations but I can't seem to make it work. </p> <p>Thanks in advance.</p>
0debug
Use case of Google Colab over Jupyter Notebook? : <p>What are use cases of using Google Colab?, I mean i understand it gels well with Tensorflow, but why will someone prefer it over Jupyter notebook? </p>
0debug
Error on andriod xml layout : i am using this xml file to create a page in android : <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:background="@drawable/background" android:layout_height="match_parent" tools:context="ir.hiup.hadskalme.CategoryKids"> <android.support.constraint.ConstraintLayout android:id="@+id/constraintLayout" android:layout_width="0dp" android:layout_height="60dp" android:background="@drawable/backbala" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintHorizontal_bias="0.0"> <ImageView android:id="@+id/imageView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:layout_marginRight="16dp" android:layout_marginTop="16dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" app:srcCompat="@drawable/categorylogo" android:layout_marginEnd="16dp" /> <ImageView android:id="@+id/backbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" app:srcCompat="@drawable/backbutton" android:layout_marginLeft="16dp" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="8dp" app:layout_constraintBottom_toBottomOf="parent" android:layout_marginBottom="8dp" app:layout_constraintVertical_bias="0.545" android:layout_marginStart="16dp" /> </android.support.constraint.ConstraintLayout> <ScrollView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/constraintLayout" android:layout_marginLeft="0dp" app:layout_constraintLeft_toLeftOf="parent"> <LinearLayout android:layout_width="match_parent" android:orientation="vertical" android:layout_height="wrap_content"> <LinearLayout android:layout_width="match_parent" android:orientation="horizontal" android:layout_height="wrap_content"> <View android:id="@+id/c1k" android:layout_width="0dp" android:layout_weight="1" android:layout_marginRight="16dp" android:layout_marginLeft="16dp" android:background="@drawable/c1" android:layout_height="220dp" android:layout_marginTop="8dp" /> <View android:id="@+id/c2k" android:layout_width="0dp" android:layout_weight="1" android:layout_marginRight="16dp" android:layout_marginLeft="16dp" android:background="@drawable/c2" android:layout_height="220dp" android:layout_marginTop="8dp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:orientation="horizontal" android:layout_height="wrap_content"> <View android:id="@+id/c4k" android:layout_width="0dp" android:layout_weight="1" android:layout_marginRight="16dp" android:layout_marginLeft="16dp" android:background="@drawable/c4" android:layout_height="220dp" android:layout_marginTop="8dp" /> <View android:id="@+id/c6k" android:layout_width="0dp" android:layout_weight="1" android:layout_marginRight="16dp" android:layout_marginLeft="16dp" android:background="@drawable/c6" android:layout_height="220dp" android:layout_marginTop="8dp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:orientation="horizontal" android:layout_height="wrap_content"> <View android:id="@+id/c11k" android:layout_width="0dp" android:layout_weight="1" android:layout_marginRight="16dp" android:layout_marginLeft="16dp" android:background="@drawable/cf11" android:layout_height="220dp" android:layout_marginTop="8dp" /> <View android:id="@+id/c12k" android:layout_width="0dp" android:layout_weight="1" android:layout_marginRight="16dp" android:layout_marginLeft="16dp" android:background="@drawable/c12" android:layout_height="220dp" android:layout_marginTop="8dp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="300dp" /> </LinearLayout> </ScrollView> </android.support.constraint.ConstraintLayout> now on some devices i recive this error : lang.java.RuntimeException: (Unable to start activity ComponentInfo{ir.hiup.hadskalme/ir.hiup.hadskalme.CategoryKids}: android.view.InflateException: Binary XML file line #127: Error inflating class <unknown>) how can i solve this problem ? thanks for yout time
0debug
does a method used in main method need its own class? : im writing a code that checks password entries, my main method checks my secondary method and outputs a line depending on whether its true or false. my problem is when i compile it gives expected class error for my second method, but if i try to use the same class as my main it gives duplicate class error. i didnt think i needed a second class, anyone care to help me out? import java.util.Scanner; public class CheckPassword { public static void main(String[] args) { scanner input = new Scanner(System.in); System.out.println("Enter a password"); password = input.nextLine(); if (check(password)) { System.out.println("Valid Password"); } else{ System.out.println("Invalid Password"); } } } public class CheckPassword { public static boolean check(String password) { boolean check = true; if(password.length() < 8) { check = false; } int num = 0; for(int x = 0; i < password.length(); i++) { if(isLetter(password.charAt(x)) || isDigit(password.charAt(x))){ if(isDigit(password.charAt(x))){ num++; if (num >=2){ check = true; } else{ check = false; } } } } } }
0debug
Finding missing entries between two Dictionaries in C# : Suppose that I have two dictionaries as such: Dictionary<int, int> a = new Dictionary<int, int>(), b = new Dictionary<int, int>(); a.Add(1, 1); a.Add(2, 2); a.Add(3, 3); b.Add(1, 1); b.Add(2, 2); What's the best way to extract the difference here, returning a type `Dictionary<int, int>`?
0debug
static void serial_init_core(SerialState *s) { if (!s->chr) { fprintf(stderr, "Can't create serial device, empty char device\n"); exit(1); } s->modem_status_poll = qemu_new_timer(vm_clock, (QEMUTimerCB *) serial_update_msl, s); s->fifo_timeout_timer = qemu_new_timer(vm_clock, (QEMUTimerCB *) fifo_timeout_int, s); s->transmit_timer = qemu_new_timer(vm_clock, (QEMUTimerCB *) serial_xmit, s); qemu_register_reset(serial_reset, s); serial_reset(s); qemu_chr_add_handlers(s->chr, serial_can_receive1, serial_receive1, serial_event, s); }
1threat
POWERPC_FAMILY(POWER8E)(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); dc->fw_name = "PowerPC,POWER8"; dc->desc = "POWER8E"; dc->props = powerpc_servercpu_properties; pcc->pvr_match = ppc_pvr_match_power8; pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06; pcc->init_proc = init_proc_POWER8; pcc->check_pow = check_pow_nocheck; pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | PPC_FLOAT_FRSQRTES | PPC_FLOAT_STFIWX | PPC_FLOAT_EXT | PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | PPC_MEM_SYNC | PPC_MEM_EIEIO | PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_64B | PPC_64BX | PPC_ALTIVEC | PPC_SEGMENT_64B | PPC_SLBI | PPC_POPCNTB | PPC_POPCNTWD; pcc->insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX | PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 | PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 | PPC2_ISA205 | PPC2_ISA207S; pcc->msr_mask = (1ull << MSR_SF) | (1ull << MSR_TM) | (1ull << MSR_VR) | (1ull << MSR_VSX) | (1ull << MSR_EE) | (1ull << MSR_PR) | (1ull << MSR_FP) | (1ull << MSR_ME) | (1ull << MSR_FE0) | (1ull << MSR_SE) | (1ull << MSR_DE) | (1ull << MSR_FE1) | (1ull << MSR_IR) | (1ull << MSR_DR) | (1ull << MSR_PMM) | (1ull << MSR_RI) | (1ull << MSR_LE); pcc->mmu_model = POWERPC_MMU_2_06; #if defined(CONFIG_SOFTMMU) pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault; #endif pcc->excp_model = POWERPC_EXCP_POWER7; pcc->bus_model = PPC_FLAGS_INPUT_POWER7; pcc->bfd_mach = bfd_mach_ppc64; pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | POWERPC_FLAG_BE | POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR | POWERPC_FLAG_VSX; pcc->l1_dcache_size = 0x8000; pcc->l1_icache_size = 0x8000; pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr; }
1threat
static void fd_accept_incoming_migration(void *opaque) { QEMUFile *f = opaque; int ret; ret = qemu_loadvm_state(f); if (ret < 0) { fprintf(stderr, "load of migration failed\n"); goto err; } qemu_announce_self(); DPRINTF("successfully loaded vm state\n"); qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL); if (autostart) vm_start(); err: qemu_fclose(f); }
1threat
Navigation links dont work : <p>On <a href="https://bm-translations.de" rel="nofollow noreferrer">https://bm-translations.de</a> when I click on a link in navigation it doesnt link to the anchor (its doing nothing). </p> <p>I can see the error in the console, but I really dont know how to fix it. Maybe you can give me any helping advice, why exactly this error occurs and where to start looking for a solution?</p> <p>Maybe there is something to except the navigation links from all the javascript except 2 functions (one for smooth scrolling and one for changing active class)?</p>
0debug
static void mips_jazz_init(MachineState *machine, enum jazz_model_e jazz_model) { MemoryRegion *address_space = get_system_memory(); const char *cpu_model = machine->cpu_model; char *filename; int bios_size, n; MIPSCPU *cpu; CPUClass *cc; CPUMIPSState *env; qemu_irq *i8259; rc4030_dma *dmas; MemoryRegion *rc4030_dma_mr; MemoryRegion *isa_mem = g_new(MemoryRegion, 1); MemoryRegion *isa_io = g_new(MemoryRegion, 1); MemoryRegion *rtc = g_new(MemoryRegion, 1); MemoryRegion *i8042 = g_new(MemoryRegion, 1); MemoryRegion *dma_dummy = g_new(MemoryRegion, 1); NICInfo *nd; DeviceState *dev, *rc4030; SysBusDevice *sysbus; ISABus *isa_bus; ISADevice *pit; DriveInfo *fds[MAX_FD]; qemu_irq esp_reset, dma_enable; MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *bios = g_new(MemoryRegion, 1); MemoryRegion *bios2 = g_new(MemoryRegion, 1); if (cpu_model == NULL) { cpu_model = "R4000"; } cpu = cpu_mips_init(cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } env = &cpu->env; qemu_register_reset(main_cpu_reset, cpu); cc = CPU_GET_CLASS(cpu); real_do_unassigned_access = cc->do_unassigned_access; cc->do_unassigned_access = mips_jazz_do_unassigned_access; memory_region_allocate_system_memory(ram, NULL, "mips_jazz.ram", machine->ram_size); memory_region_add_subregion(address_space, 0, ram); memory_region_init_ram(bios, NULL, "mips_jazz.bios", MAGNUM_BIOS_SIZE, &error_abort); vmstate_register_ram_global(bios); memory_region_set_readonly(bios, true); memory_region_init_alias(bios2, NULL, "mips_jazz.bios", bios, 0, MAGNUM_BIOS_SIZE); memory_region_add_subregion(address_space, 0x1fc00000LL, bios); memory_region_add_subregion(address_space, 0xfff00000LL, bios2); if (bios_name == NULL) bios_name = BIOS_FILENAME; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { bios_size = load_image_targphys(filename, 0xfff00000LL, MAGNUM_BIOS_SIZE); g_free(filename); } else { bios_size = -1; } if ((bios_size < 0 || bios_size > MAGNUM_BIOS_SIZE) && !qtest_enabled()) { error_report("Could not load MIPS bios '%s'", bios_name); exit(1); } cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); rc4030 = rc4030_init(&dmas, &rc4030_dma_mr); sysbus = SYS_BUS_DEVICE(rc4030); sysbus_connect_irq(sysbus, 0, env->irq[6]); sysbus_connect_irq(sysbus, 1, env->irq[3]); memory_region_add_subregion(address_space, 0x80000000, sysbus_mmio_get_region(sysbus, 0)); memory_region_add_subregion(address_space, 0xf0000000, sysbus_mmio_get_region(sysbus, 1)); memory_region_init_io(dma_dummy, NULL, &dma_dummy_ops, NULL, "dummy_dma", 0x1000); memory_region_add_subregion(address_space, 0x8000d000, dma_dummy); memory_region_init(isa_io, NULL, "isa-io", 0x00010000); memory_region_init(isa_mem, NULL, "isa-mem", 0x01000000); memory_region_add_subregion(address_space, 0x90000000, isa_io); memory_region_add_subregion(address_space, 0x91000000, isa_mem); isa_bus = isa_bus_new(NULL, isa_mem, isa_io); i8259 = i8259_init(isa_bus, env->irq[4]); isa_bus_irqs(isa_bus, i8259); DMA_init(0); pit = pit_init(isa_bus, 0x40, 0, NULL); pcspk_init(isa_bus, pit); switch (jazz_model) { case JAZZ_MAGNUM: dev = qdev_create(NULL, "sysbus-g364"); qdev_init_nofail(dev); sysbus = SYS_BUS_DEVICE(dev); sysbus_mmio_map(sysbus, 0, 0x60080000); sysbus_mmio_map(sysbus, 1, 0x40000000); sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in(rc4030, 3)); { MemoryRegion *rom_mr = g_new(MemoryRegion, 1); memory_region_init_ram(rom_mr, NULL, "g364fb.rom", 0x80000, &error_abort); vmstate_register_ram_global(rom_mr); memory_region_set_readonly(rom_mr, true); uint8_t *rom = memory_region_get_ram_ptr(rom_mr); memory_region_add_subregion(address_space, 0x60000000, rom_mr); rom[0] = 0x10; } break; case JAZZ_PICA61: isa_vga_mm_init(0x40000000, 0x60000000, 0, get_system_memory()); break; default: break; } for (n = 0; n < nb_nics; n++) { nd = &nd_table[n]; if (!nd->model) nd->model = g_strdup("dp83932"); if (strcmp(nd->model, "dp83932") == 0) { qemu_check_nic_model(nd, "dp83932"); dev = qdev_create(NULL, "dp8393x"); qdev_set_nic_properties(dev, nd); qdev_prop_set_uint8(dev, "it_shift", 2); qdev_prop_set_ptr(dev, "dma_mr", rc4030_dma_mr); qdev_init_nofail(dev); sysbus = SYS_BUS_DEVICE(dev); sysbus_mmio_map(sysbus, 0, 0x80001000); sysbus_mmio_map(sysbus, 1, 0x8000b000); sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in(rc4030, 4)); break; } else if (is_help_option(nd->model)) { fprintf(stderr, "qemu: Supported NICs: dp83932\n"); exit(1); } else { fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model); exit(1); } } esp_init(0x80002000, 0, rc4030_dma_read, rc4030_dma_write, dmas[0], qdev_get_gpio_in(rc4030, 5), &esp_reset, &dma_enable); if (drive_get_max_bus(IF_FLOPPY) >= MAX_FD) { fprintf(stderr, "qemu: too many floppy drives\n"); exit(1); } for (n = 0; n < MAX_FD; n++) { fds[n] = drive_get(IF_FLOPPY, 0, n); } fdctrl_init_sysbus(qdev_get_gpio_in(rc4030, 1), 0, 0x80003000, fds); rtc_init(isa_bus, 1980, NULL); memory_region_init_io(rtc, NULL, &rtc_ops, NULL, "rtc", 0x1000); memory_region_add_subregion(address_space, 0x80004000, rtc); i8042_mm_init(qdev_get_gpio_in(rc4030, 6), qdev_get_gpio_in(rc4030, 7), i8042, 0x1000, 0x1); memory_region_add_subregion(address_space, 0x80005000, i8042); if (serial_hds[0]) { serial_mm_init(address_space, 0x80006000, 0, qdev_get_gpio_in(rc4030, 8), 8000000/16, serial_hds[0], DEVICE_NATIVE_ENDIAN); } if (serial_hds[1]) { serial_mm_init(address_space, 0x80007000, 0, qdev_get_gpio_in(rc4030, 9), 8000000/16, serial_hds[1], DEVICE_NATIVE_ENDIAN); } if (parallel_hds[0]) parallel_mm_init(address_space, 0x80008000, 0, qdev_get_gpio_in(rc4030, 0), parallel_hds[0]); dev = qdev_create(NULL, "ds1225y"); qdev_init_nofail(dev); sysbus = SYS_BUS_DEVICE(dev); sysbus_mmio_map(sysbus, 0, 0x80009000); sysbus_create_simple("jazz-led", 0x8000f000, NULL); }
1threat
static int dvvideo_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; DVVideoContext *s = avctx->priv_data; s->sys = dv_frame_profile(buf); if (!s->sys || buf_size < s->sys->frame_size || dv_init_dynamic_tables(s->sys)) return -1; if (s->picture.data[0]) avctx->release_buffer(avctx, &s->picture); s->picture.reference = 0; s->picture.key_frame = 1; s->picture.pict_type = FF_I_TYPE; avctx->pix_fmt = s->sys->pix_fmt; avctx->time_base = s->sys->time_base; avcodec_set_dimensions(avctx, s->sys->width, s->sys->height); if (avctx->get_buffer(avctx, &s->picture) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } s->picture.interlaced_frame = 1; s->picture.top_field_first = 0; s->buf = buf; avctx->execute(avctx, dv_decode_video_segment, s->sys->work_chunks, NULL, dv_work_pool_size(s->sys), sizeof(DVwork_chunk)); emms_c(); *data_size = sizeof(AVFrame); *(AVFrame*)data = s->picture; return s->sys->frame_size; }
1threat