problem
stringlengths
26
131k
labels
class label
2 classes
EXCEL, If column terms match text In range b equal to or less then, the insert other column : I racking my brain, the attached photo illustrates roughly what Im trying to do, top and bottom images illustrates a collection if 12k pictures I need to associated the id depicted in the middle portion of the attached image.... what I have ... i know im going the wrong way and my job is kinda depending on this... lol HELP! I know ive been going VBA but if a formula would work... I just need this bad. Buy ya a coffee if you can help me out in anyway. [What Im trying to accomplish][1] Sub Find_Matches() Dim CompareRange As Variant, ToCompare As Variant, x As Variant, y As Variant Set CompareRange = Worksheets("ID_proptitle").Range("B1:A500") Set ToCompare = Worksheets("pictures").Range("B1:C500") For Each x In ToCompare For Each y In CompareRange If x = y Then [1]: http://i.stack.imgur.com/c1BXe.png
0debug
C++ destructor for class contains array of ptr to objects : <p>For example if we have 2 classes</p> <pre><code>class A{ int size; A** arr; } class B{ int size; A** arr; } </code></pre> <p>For A's constructor I wrote:</p> <pre><code>A::A(){ this-&gt;arr=new A* [20]; } </code></pre> <p>For B's constructor I wrote:</p> <pre><code>B:B(){ this-&gt;arr=new A* [20]; } </code></pre> <p>For A's destroctor I wrote: </p> <pre><code>A:~A(){ for(int i=0;i&lt;this-&gt;size;i++){ delete this-&gt;arr[i]; } delete [] this-&gt;arr; } </code></pre> <p>For B's destructor I wrote:</p> <pre><code> B:~B(){ for(int i=0;i&lt;this-&gt;size;i++){ delete this-&gt;arr[i]; } delete [] this-&gt;arr; } </code></pre> <p>Note that the size will grow as I put more obj into the arr. Now my question is, while I am testing, there's nothing wrong, but after the main program returns, it gives me segfault?</p>
0debug
make gin golang and python communicate : : Here is my golang gin code : package main import ( "fmt" "github.com/gin-gonic/gin" ) type Data struct { Test string `json:"test"` } func getData(c *gin.Context) { var data Data err := c.BindJSON(&data) if err != nil { panic(err) } fmt.Println(data) c.JSON(200, gin.H{ "message": "pong", }) } func main() { r := gin.Default() r.POST("/test", getData) r.Run() // listen and serve on 0.0.0.0:8080 } and my python code : import requests r = requests.post("http://127.0.0.1:8080/test",json={"test":"ok"}) print(r) But when i execute my python script i have a 403 error : <Response [403]> The panic (err) display nothing. Any idea why i get this error ? Regards
0debug
css: what does '>' sign mean between two elements ? : <p>For example, in this code: </p> <pre><code>tr:last-child&gt;td:first-child { -webkit-border-radius: 0 0 0 25px; border-radius: 0 0 0 25px; } </code></pre> <p>'tr:last-child' means the last element of type tr. 'td:first-child' means the last element of type td. What does the '>' sign between them mean? </p>
0debug
static void omap_prcm_write(void *opaque, hwaddr addr, uint64_t value, unsigned size) { struct omap_prcm_s *s = (struct omap_prcm_s *) opaque; if (size != 4) { omap_badwidth_write32(opaque, addr, value); return; } switch (addr) { case 0x000: case 0x054: case 0x084: case 0x1e4: case 0x220: case 0x224: case 0x22c: case 0x2c8: case 0x2e4: case 0x320: case 0x3e4: case 0x420: case 0x520: case 0x820: case 0x8e4: OMAP_RO_REG(addr); return; case 0x010: s->sysconfig = value & 1; break; case 0x018: s->irqst[0] &= ~value; omap_prcm_int_update(s, 0); break; case 0x01c: s->irqen[0] = value & 0x3f; omap_prcm_int_update(s, 0); break; case 0x050: s->voltctrl = value & 0xf1c3; break; case 0x060: s->clksrc[0] = value & 0xdb; break; case 0x070: s->clkout[0] = value & 0xbbbb; break; case 0x078: s->clkemul[0] = value & 1; break; case 0x080: break; case 0x090: s->setuptime[0] = value & 0xffff; break; case 0x094: s->setuptime[1] = value & 0xffff; break; case 0x098: s->clkpol[0] = value & 0x701; break; case 0x0b0: case 0x0b4: case 0x0b8: case 0x0bc: case 0x0c0: case 0x0c4: case 0x0c8: case 0x0cc: case 0x0d0: case 0x0d4: case 0x0d8: case 0x0dc: case 0x0e0: case 0x0e4: case 0x0e8: case 0x0ec: case 0x0f0: case 0x0f4: case 0x0f8: case 0x0fc: s->scratch[(addr - 0xb0) >> 2] = value; break; case 0x140: s->clksel[0] = value & 0x1f; break; case 0x148: s->clkctrl[0] = value & 0x1f; break; case 0x158: s->rst[0] &= ~value; break; case 0x1c8: s->wkup[0] = value & 0x15; break; case 0x1d4: s->ev = value & 0x1f; break; case 0x1d8: s->evtime[0] = value; break; case 0x1dc: s->evtime[1] = value; break; case 0x1e0: s->power[0] = value & 0xc0f; break; case 0x200: s->clken[0] = value & 0xbfffffff; break; case 0x204: s->clken[1] = value & 0x00000007; break; case 0x210: s->clken[2] = value & 0xfffffff9; break; case 0x214: s->clken[3] = value & 0x00000007; break; case 0x21c: s->clken[4] = value & 0x0000001f; break; case 0x230: s->clkidle[0] = value & 0xfffffff9; break; case 0x234: s->clkidle[1] = value & 0x00000007; break; case 0x238: s->clkidle[2] = value & 0x00000007; break; case 0x23c: s->clkidle[3] = value & 0x0000001f; break; case 0x240: s->clksel[1] = value & 0x0fffbf7f; break; case 0x244: s->clksel[2] = value & 0x00fffffc; break; case 0x248: s->clkctrl[1] = value & 0x7; break; case 0x2a0: s->wken[0] = value & 0x04667ff8; break; case 0x2a4: s->wken[1] = value & 0x00000005; break; case 0x2b0: s->wkst[0] &= ~value; break; case 0x2b4: s->wkst[1] &= ~value; break; case 0x2e0: s->power[1] = (value & 0x00fc3f) | (1 << 2); break; case 0x300: s->clken[5] = value & 6; break; case 0x310: s->clken[6] = value & 1; break; case 0x340: s->clksel[3] = value & 7; break; case 0x348: s->clkctrl[2] = value & 1; break; case 0x350: s->rstctrl[0] = value & 1; break; case 0x358: s->rst[1] &= ~value; break; case 0x3c8: s->wkup[1] = value & 0x13; break; case 0x3e0: s->power[2] = (value & 0x00c0f) | (3 << 2); break; case 0x400: s->clken[7] = value & 0xd; break; case 0x410: s->clken[8] = value & 0x3f; break; case 0x430: s->clkidle[4] = value & 0x0000003f; break; case 0x440: s->clksel[4] = value & 3; break; case 0x450: if (value & 2) qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); break; case 0x454: s->rsttime_wkup = value & 0x1fff; break; case 0x458: s->rst[2] &= ~value; break; case 0x4a0: s->wken[2] = value & 0x00000005; break; case 0x4b0: s->wkst[2] &= ~value; break; case 0x500: if (value & 0xffffff30) fprintf(stderr, "%s: write 0s in CM_CLKEN_PLL for " "future compatibility\n", __FUNCTION__); if ((s->clken[9] ^ value) & 0xcc) { s->clken[9] &= ~0xcc; s->clken[9] |= value & 0xcc; omap_prcm_apll_update(s); } if ((s->clken[9] ^ value) & 3) { s->clken[9] &= ~3; s->clken[9] |= value & 3; omap_prcm_dpll_update(s); } break; case 0x530: s->clkidle[5] = value & 0x000000cf; break; case 0x540: if (value & 0xfc4000d7) fprintf(stderr, "%s: write 0s in CM_CLKSEL1_PLL for " "future compatibility\n", __FUNCTION__); if ((s->clksel[5] ^ value) & 0x003fff00) { s->clksel[5] = value & 0x03bfff28; omap_prcm_dpll_update(s); } s->clksel[5] = value & 0x03bfff28; break; case 0x544: if (value & ~3) fprintf(stderr, "%s: write 0s in CM_CLKSEL2_PLL[31:2] for " "future compatibility\n", __FUNCTION__); if (s->clksel[6] != (value & 3)) { s->clksel[6] = value & 3; omap_prcm_dpll_update(s); } break; case 0x800: s->clken[10] = value & 0x501; break; case 0x810: s->clken[11] = value & 0x2; break; case 0x830: s->clkidle[6] = value & 0x2; break; case 0x840: s->clksel[7] = value & 0x3fff; break; case 0x848: s->clkctrl[3] = value & 0x101; break; case 0x850: break; case 0x858: s->rst[3] &= ~value; break; case 0x8c8: s->wkup[2] = value & 0x13; break; case 0x8e0: s->power[3] = (value & 0x03017) | (3 << 2); break; case 0x8f0: s->irqst[1] &= ~value; omap_prcm_int_update(s, 1); break; case 0x8f4: s->irqen[1] = value & 0x7; omap_prcm_int_update(s, 1); break; case 0x8f8: s->irqst[2] &= ~value; omap_prcm_int_update(s, 2); break; case 0x8fc: s->irqen[2] = value & 0x7; omap_prcm_int_update(s, 2); break; default: OMAP_BAD_REG(addr); return; } }
1threat
Check if object is in the array? : <p>var obj = [{ username: 'kim'}, { username: 'ryan'} ];</p> <p>I want to create an if statement where if theres a 'kim' value on the var obj, it returns true;</p>
0debug
How to unit test React Component shouldComponentUpdate method : <p>I have a React Component that implements the <a href="https://facebook.github.io/react/docs/react-component.html#shouldcomponentupdate" rel="noreferrer">shouldComponentUpdate</a> method and I'd like to unit test it. Ideally I could change some prop or state on the component in a unit test and verify it either re-rendered or not. I am using <a href="https://github.com/airbnb/enzyme" rel="noreferrer">enzyme</a> if that helps.</p>
0debug
How can I get an editor to proofread my JavaScript to tell me when a variable name isn't correct? : <p>I want a way to proofread my JavaScript to make sure I've entered all my variable names correctly. So when I have something like this:</p> <pre><code>var foo = 1; var bar = fooo + 1; </code></pre> <p>I want <code>fooo</code> to have a red underline.</p> <p>Is there a way to do this? I thought Visual Studio Code would be ideal but I'm not too particular about what editor I use.</p>
0debug
what does putting this '|' on function parameter do? : im learning how to write SDL program in C++, but i came across this code: SDL_Renderer *ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); ^i have no idea what this means?? i dont know if this is a specific c++ stuff because i didnt use c++ for a very long time and i almost forget everything.... my guess coming from shell scripting background suggests its a pipe(i know its obviously not that :p), or its just a bitwise OR(idk if thats it either). what does this '|' mean when putting it on a function parameter like the code above?
0debug
static av_always_inline void idct(uint8_t *dst, int stride, int16_t *input, int type) { int16_t *ip = input; uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; int A, B, C, D, Ad, Bd, Cd, Dd, E, F, G, H; int Ed, Gd, Add, Bdd, Fd, Hd; int i; for (i = 0; i < 8; i++) { if ( ip[0] | ip[1] | ip[2] | ip[3] | ip[4] | ip[5] | ip[6] | ip[7] ) { A = M(xC1S7, ip[1]) + M(xC7S1, ip[7]); B = M(xC7S1, ip[1]) - M(xC1S7, ip[7]); C = M(xC3S5, ip[3]) + M(xC5S3, ip[5]); D = M(xC3S5, ip[5]) - M(xC5S3, ip[3]); Ad = M(xC4S4, (A - C)); Bd = M(xC4S4, (B - D)); Cd = A + C; Dd = B + D; E = M(xC4S4, (ip[0] + ip[4])); F = M(xC4S4, (ip[0] - ip[4])); G = M(xC2S6, ip[2]) + M(xC6S2, ip[6]); H = M(xC6S2, ip[2]) - M(xC2S6, ip[6]); Ed = E - G; Gd = E + G; Add = F + Ad; Bdd = Bd - H; Fd = F - Ad; Hd = Bd + H; ip[0] = Gd + Cd ; ip[7] = Gd - Cd ; ip[1] = Add + Hd; ip[2] = Add - Hd; ip[3] = Ed + Dd ; ip[4] = Ed - Dd ; ip[5] = Fd + Bdd; ip[6] = Fd - Bdd; } ip += 8; } ip = input; for ( i = 0; i < 8; i++) { if ( ip[1 * 8] | ip[2 * 8] | ip[3 * 8] | ip[4 * 8] | ip[5 * 8] | ip[6 * 8] | ip[7 * 8] ) { A = M(xC1S7, ip[1*8]) + M(xC7S1, ip[7*8]); B = M(xC7S1, ip[1*8]) - M(xC1S7, ip[7*8]); C = M(xC3S5, ip[3*8]) + M(xC5S3, ip[5*8]); D = M(xC3S5, ip[5*8]) - M(xC5S3, ip[3*8]); Ad = M(xC4S4, (A - C)); Bd = M(xC4S4, (B - D)); Cd = A + C; Dd = B + D; E = M(xC4S4, (ip[0*8] + ip[4*8])) + 8; F = M(xC4S4, (ip[0*8] - ip[4*8])) + 8; if(type==1){ E += 16*128; F += 16*128; } G = M(xC2S6, ip[2*8]) + M(xC6S2, ip[6*8]); H = M(xC6S2, ip[2*8]) - M(xC2S6, ip[6*8]); Ed = E - G; Gd = E + G; Add = F + Ad; Bdd = Bd - H; Fd = F - Ad; Hd = Bd + H; if(type==0){ ip[0*8] = (Gd + Cd ) >> 4; ip[7*8] = (Gd - Cd ) >> 4; ip[1*8] = (Add + Hd ) >> 4; ip[2*8] = (Add - Hd ) >> 4; ip[3*8] = (Ed + Dd ) >> 4; ip[4*8] = (Ed - Dd ) >> 4; ip[5*8] = (Fd + Bdd ) >> 4; ip[6*8] = (Fd - Bdd ) >> 4; }else if(type==1){ dst[0*stride] = cm[(Gd + Cd ) >> 4]; dst[7*stride] = cm[(Gd - Cd ) >> 4]; dst[1*stride] = cm[(Add + Hd ) >> 4]; dst[2*stride] = cm[(Add - Hd ) >> 4]; dst[3*stride] = cm[(Ed + Dd ) >> 4]; dst[4*stride] = cm[(Ed - Dd ) >> 4]; dst[5*stride] = cm[(Fd + Bdd ) >> 4]; dst[6*stride] = cm[(Fd - Bdd ) >> 4]; }else{ dst[0*stride] = cm[dst[0*stride] + ((Gd + Cd ) >> 4)]; dst[7*stride] = cm[dst[7*stride] + ((Gd - Cd ) >> 4)]; dst[1*stride] = cm[dst[1*stride] + ((Add + Hd ) >> 4)]; dst[2*stride] = cm[dst[2*stride] + ((Add - Hd ) >> 4)]; dst[3*stride] = cm[dst[3*stride] + ((Ed + Dd ) >> 4)]; dst[4*stride] = cm[dst[4*stride] + ((Ed - Dd ) >> 4)]; dst[5*stride] = cm[dst[5*stride] + ((Fd + Bdd ) >> 4)]; dst[6*stride] = cm[dst[6*stride] + ((Fd - Bdd ) >> 4)]; } } else { if(type==0){ ip[0*8] = ip[1*8] = ip[2*8] = ip[3*8] = ip[4*8] = ip[5*8] = ip[6*8] = ip[7*8] = ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20); }else if(type==1){ dst[0*stride]= dst[1*stride]= dst[2*stride]= dst[3*stride]= dst[4*stride]= dst[5*stride]= dst[6*stride]= dst[7*stride]= cm[128 + ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20)]; }else{ if(ip[0*8]){ int v= ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20); dst[0*stride] = cm[dst[0*stride] + v]; dst[1*stride] = cm[dst[1*stride] + v]; dst[2*stride] = cm[dst[2*stride] + v]; dst[3*stride] = cm[dst[3*stride] + v]; dst[4*stride] = cm[dst[4*stride] + v]; dst[5*stride] = cm[dst[5*stride] + v]; dst[6*stride] = cm[dst[6*stride] + v]; dst[7*stride] = cm[dst[7*stride] + v]; } } } ip++; dst++; } }
1threat
static void spapr_phb_remove_pci_device_cb(DeviceState *dev, void *opaque) { pci_device_reset(PCI_DEVICE(dev)); object_unparent(OBJECT(dev)); }
1threat
static inline void RENAME(yuv2yuyv422_2)(SwsContext *c, const uint16_t *buf0, const uint16_t *buf1, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, const uint16_t *abuf1, uint8_t *dest, int dstW, int yalpha, int uvalpha, int y) { x86_reg uv_off = c->uv_off << 1; __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2PACKED(%%REGBP, %5, %6) WRITEYUY2(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither), "m"(uv_off) ); }
1threat
regular expression to find in wpf xaml : <p>I want to find in visual studio (C#) in WPF all the occurrences of the pattern:</p> <p>Content="</p> <p>and after the " I want to find only the occurrences that do not continue with {</p> <p>for example:</p> <p>I <strong>want</strong> to find: Content="This is a button"</p> <p>I <strong>do not</strong> want to find: Content="{StaticResource ThisIsAButton}"</p> <p>I am very bad at regular expression.</p> <p>Any Idea ? Thanks</p>
0debug
static void gen_spr_970_pmu_sup(CPUPPCState *env) { spr_register(env, SPR_970_PMC7, "PMC7", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_970_PMC8, "PMC8", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); }
1threat
static int vnc_tls_initialize(void) { static int tlsinitialized = 0; if (tlsinitialized) return 1; if (gnutls_global_init () < 0) return 0; if (gnutls_dh_params_init (&dh_params) < 0) return 0; if (gnutls_dh_params_generate2 (dh_params, DH_BITS) < 0) return 0; #if defined(_VNC_DEBUG) && _VNC_DEBUG >= 2 gnutls_global_set_log_level(10); gnutls_global_set_log_function(vnc_debug_gnutls_log); #endif tlsinitialized = 1; return 1; }
1threat
static void bdrv_ioctl_bh_cb(void *opaque) { BdrvIoctlCompletionData *data = opaque; bdrv_co_io_em_complete(data->co, -ENOTSUP); qemu_bh_delete(data->bh); }
1threat
Device.OnPlatform deprecated : <p>Inside the constructor of my <code>ContentPage</code> I try to set a platform dependent padding value:</p> <pre><code>Padding = new Thickness(5, Device.OnPlatform(20, 5, 5), 5, 5); </code></pre> <p>Visual Studio underlines <code>Device.OnPlatform</code> and when I hover the mouse pointer over the method call I get the following warning:</p> <blockquote> <p>Devide.OnPlatform(T, T, T) is obsolete: 'Use switch(RuntimePlatform) instead'.</p> </blockquote> <p>The code initially used is from the <a href="https://developer.xamarin.com/guides/xamarin-forms/creating-mobile-apps-xamarin-forms/" rel="noreferrer"><strong>e-book</strong></a> 'Creating Mobile Apps with Xamarin.Forms Book' published in 2016. I 'm really surprised how fast this platform evolves! </p> <p>Unfortunately I'm not aware of how <code>Device.OnPlatform</code> should be replaced using the way suggested by the warning. </p>
0debug
slice a string in java and manipulate it : var filePath = "C:\\Libraries\\Documents\\123_test\\Report_11071991"; I have a variable as above in java Can I have some code to get only the numeric part(11071991) from the last folder(Report_11071991)?
0debug
What is the diffference between these three types of variable declaration in javascript? : <p>I am new to JS and i have facing some issue on declaration of the Variables in three ways</p> <p><a href="https://i.stack.imgur.com/P3xCX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P3xCX.png" alt="These are test cases i have tried"></a></p> <p>as my understanding </p> <pre><code>a = "a"; </code></pre> <p>and </p> <pre><code>var a = "var a"; </code></pre> <p>are (global declaration) same thing </p> <p>but </p> <pre><code>let a = "let a" </code></pre> <p>is declare as local variable </p> <p>so as i have tested some combinations </p> <pre><code>let a ="let a" a ="a" </code></pre> <p>workes </p> <p>but </p> <pre><code>let a = "let a" var a = "var a" </code></pre> <p>not works </p> <p>could you tell me why is that ?</p>
0debug
My listview is not displayin its content : Here is the code for MainActivity How to view listview products please suggest me as soon as possible public class ProductList extends AppCompatActivity { public static ArrayList<ItemProductList> values1=new ArrayList<ItemProductList>(); ListView list_productlist; Context context = this; public ItenProductAdapter mAdapter; String category,name1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_product_list); list_productlist = (ListView) findViewById(R.id.list_productlist); category=getIntent().getStringExtra("category"); name1=getIntent().getStringExtra("name"); loadJSON(); mAdapter= new ItenProductAdapter(context,values1); list_productlist.setAdapter(mAdapter); } private void loadJSON() { StringRequest jsonObjReq = new StringRequest(Request.Method.POST, "http://arshinfosystems.co.in/demo/AoneRubber/productlist.php", new Response.Listener<String>() { @Override public void onResponse(String response) { try { JSONObject jObject = new JSONObject(response); JSONArray jsonArray = jObject.getJSONArray("cart"); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jbjct = jsonArray.getJSONObject(i); ItemProductList itemListModel = new ItemProductList(); itemListModel.thickness1 = jbjct.getString("thickness"); itemListModel.id1 = jbjct.getString("id"); itemListModel.price1 = jbjct.getString("price"); itemListModel.category1 = jbjct.getString("category"); itemListModel.name1=jbjct.getString("name"); itemListModel.sr_no=jbjct.getString("sr_no"); values1.add(itemListModel); } } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(ProductList.this, error.toString(), Toast.LENGTH_SHORT).show(); } }) { @Override protected Map<String, String> getParams() { Map<String, String> params = new HashMap<String, String>(); params.put("category", category); params.put("name", name1); return params; } }; jsonObjReq.setRetryPolicy(new DefaultRetryPolicy(50000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); RequestQueue requestQueue = Volley.newRequestQueue(this); requestQueue.add(jsonObjReq); } } Here is the code for Adapter How to view listview products please suggest me as soon as possible please guys public class ItenProductAdapter extends BaseAdapter { public static ArrayList<ItemProductList> list1; String idValues = ""; Context context; public static Integer total; Bitmap mIcon11 = null; ViewHolder holder; public ItenProductAdapter(Context context, ArrayList<ItemProductList> list) { super(); this.list1 = list; this.context = context; } @Override public int getCount() { return 0; } @Override public Object getItem(int position) { return null; } @Override public long getItemId(int position) { return 0; } static class ViewHolder { TextView txt_sr_no; TextView txt_thickness; TextView txt_rates; } @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { holder=new ViewHolder(); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.product_list_item, null); holder.txt_sr_no= (TextView) convertView.findViewById(R.id.txt_sr_no); holder.txt_thickness= (TextView) convertView.findViewById(R.id.txt_thickness); holder.txt_rates= (TextView) convertView.findViewById(R.id.txt_rates); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.txt_sr_no.setText(list1.get(position).sr_no+")"); holder.txt_thickness.setText(""+ list1.get(position).thickness1); holder.txt_rates.setText("RS "+list1.get(position).price1); return convertView; } }
0debug
static int decode_cabac_mb_dqp( H264Context *h) { MpegEncContext * const s = &h->s; int mbn_xy; int ctx = 0; int val = 0; if( s->mb_x > 0 ) mbn_xy = s->mb_x + s->mb_y*s->mb_stride - 1; else mbn_xy = s->mb_width - 1 + (s->mb_y-1)*s->mb_stride; if( h->last_qscale_diff != 0 ) ctx++; while( get_cabac( &h->cabac, &h->cabac_state[60 + ctx] ) ) { if( ctx < 2 ) ctx = 2; else ctx = 3; val++; if(val > 102) return INT_MIN; } if( val&0x01 ) return (val + 1)/2; else return -(val + 1)/2; }
1threat
jquery finding and add clss to element : How do i add class to the span element. For instant - class="fa fa-close" I need to do it with jquert - finding the "sec" by id (i.e: id="sec2") and than by attribute (i.e: data-id="attrac-24") HTML example <div class="well dropZone" id="sec2"> <div class="panel panel-info attrac ui-widget-content" data-id="attrac-24" > <div class="panel-heading"><?PHP echo mb_substr ($attracIndex['title'], 0, 45, "utf-8") ?> <span class="pull-right"><i class="fa"></i></span></div> <div class="panel-body"><?PHP echo mb_substr ($attracIndex['des'], 0, 120, "utf-8")?></div> </div> </div> <div class="well dropZone" id="sec3"> <div class="panel panel-info attrac ui-widget-content" data-id="attrac-24" > <div class="panel-heading"><?PHP echo mb_substr ($attracIndex['title'], 0, 45, "utf-8") ?> <span class="pull-right"><i class="fa"></i></span></div> <div class="panel-body"><?PHP echo mb_substr ($attracIndex['des'], 0, 120, "utf-8")?></div> </div> <div class="panel panel-info attrac ui-widget-content" data-id="attrac-35" > <div class="panel-heading"><?PHP echo mb_substr ($attracIndex['title'], 0, 45, "utf-8") ?> <span class="pull-right"><i class="fa"></i></span></div> <div class="panel-body"><?PHP echo mb_substr ($attracIndex['des'], 0, 120, "utf-8")?></div> </div> </div> JQUERY var secID = event.target.id; var attacID = ui.item.data('id'); I tried this: $("#"+secID + " [data-id='"+attacID+"']" ).find("fa").addClass("fa-close");
0debug
Angular include CDN in component usage : <p>I have CDN URL and I want to use it inside of the Component TypeScript file.</p> <p>What would be the "right" way of dealing with CDN's in Angular 2 and greater versions?</p>
0debug
ViewPager with Navigation architecture components : <p>Are there any uses for navigation with the viewpager? I can not find information about this and I do not understand how this can be done.</p> <p>I have an simple two fragments which is need to put inside viewpager and if its possible via navigation.</p>
0debug
static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_t *pkt_pts) { AVFrame *decoded_frame, *filtered_frame = NULL; void *buffer_to_free = NULL; int i, ret = 0; float quality; #if CONFIG_AVFILTER int frame_available = 1; #endif if (!ist->decoded_frame && !(ist->decoded_frame = avcodec_alloc_frame())) return AVERROR(ENOMEM); else avcodec_get_frame_defaults(ist->decoded_frame); decoded_frame = ist->decoded_frame; pkt->pts = *pkt_pts; pkt->dts = ist->last_dts; *pkt_pts = AV_NOPTS_VALUE; ret = avcodec_decode_video2(ist->st->codec, decoded_frame, got_output, pkt); if (ret < 0) return ret; quality = same_quant ? decoded_frame->quality : 0; if (!*got_output) { return ret; } decoded_frame->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pkt_pts, decoded_frame->pkt_dts); pkt->size = 0; pre_process_video_frame(ist, (AVPicture *)decoded_frame, &buffer_to_free); rate_emu_sleep(ist); for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = &output_streams[i]; int frame_size, resample_changed; if (!check_output_constraints(ist, ost) || !ost->encoding_needed) continue; #if CONFIG_AVFILTER resample_changed = ost->resample_width != decoded_frame->width || ost->resample_height != decoded_frame->height || ost->resample_pix_fmt != decoded_frame->format; if (resample_changed) { av_log(NULL, AV_LOG_INFO, "Input stream #%d:%d frame changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n", ist->file_index, ist->st->index, ost->resample_width, ost->resample_height, av_get_pix_fmt_name(ost->resample_pix_fmt), decoded_frame->width, decoded_frame->height, av_get_pix_fmt_name(decoded_frame->format)); avfilter_graph_free(&ost->graph); if (configure_video_filters(ist, ost)) { av_log(NULL, AV_LOG_FATAL, "Error reinitializing filters!\n"); exit_program(1); } ost->resample_width = decoded_frame->width; ost->resample_height = decoded_frame->height; ost->resample_pix_fmt = decoded_frame->format; } if (ist->st->sample_aspect_ratio.num) decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio; if (ist->st->codec->codec->capabilities & CODEC_CAP_DR1) { FrameBuffer *buf = decoded_frame->opaque; AVFilterBufferRef *fb = avfilter_get_video_buffer_ref_from_arrays( decoded_frame->data, decoded_frame->linesize, AV_PERM_READ | AV_PERM_PRESERVE, ist->st->codec->width, ist->st->codec->height, ist->st->codec->pix_fmt); avfilter_copy_frame_props(fb, decoded_frame); fb->buf->priv = buf; fb->buf->free = filter_release_buffer; buf->refcount++; av_buffersrc_buffer(ost->input_video_filter, fb); } else av_vsrc_buffer_add_frame(ost->input_video_filter, decoded_frame, decoded_frame->pts, decoded_frame->sample_aspect_ratio); if (!ist->filtered_frame && !(ist->filtered_frame = avcodec_alloc_frame())) { av_free(buffer_to_free); return AVERROR(ENOMEM); } else avcodec_get_frame_defaults(ist->filtered_frame); filtered_frame = ist->filtered_frame; frame_available = avfilter_poll_frame(ost->output_video_filter->inputs[0]); while (frame_available) { AVRational ist_pts_tb; if (ost->output_video_filter) get_filtered_video_frame(ost->output_video_filter, filtered_frame, &ost->picref, &ist_pts_tb); if (ost->picref) filtered_frame->pts = av_rescale_q(ost->picref->pts, ist_pts_tb, AV_TIME_BASE_Q); if (ost->picref->video && !ost->frame_aspect_ratio) ost->st->codec->sample_aspect_ratio = ost->picref->video->pixel_aspect; #else filtered_frame = decoded_frame; #endif do_video_out(output_files[ost->file_index].ctx, ost, ist, filtered_frame, &frame_size, same_quant ? quality : ost->st->codec->global_quality); if (vstats_filename && frame_size) do_video_stats(output_files[ost->file_index].ctx, ost, frame_size); #if CONFIG_AVFILTER frame_available = ost->output_video_filter && avfilter_poll_frame(ost->output_video_filter->inputs[0]); if (ost->picref) avfilter_unref_buffer(ost->picref); } #endif } av_free(buffer_to_free); return ret; }
1threat
How to detect if the app is running on Google Play Pre-Launch report devices? : <p>As I upload a new version of my app to Google Play I get a Pre-Launch testing report that's pretty nice and fine, but the issue is that most of the time the AI just wanders around the setup and does not test the actual UI. I'd like to pre-complete the setup quickly and randomly for those devices.</p> <p>So my question is, is there a way to detect that it's running on those test devices? </p>
0debug
Website IP Address through terminal : <p>In windows we can find IP address of any website though following command: </p> <p><code>tracert www.example.com</code></p> <p>What is the replacement of this command in linux??</p> <p>I am using 'elementary os loki'.</p>
0debug
C# - How to shorten a string : <p>I have a piece of code and I need to shorten a string that I have in a variable. I was wondering how could I do this. My code is below.</p> <pre><code>string test = Console.ReadLine(); if(string.Length &gt; 5) { //shorten string } Console.WriteLine(test); Console.ReadLine(); </code></pre>
0debug
qemu_irq *openpic_init (PCIBus *bus, int *pmem_index, int nb_cpus, qemu_irq **irqs, qemu_irq irq_out) { openpic_t *opp; uint8_t *pci_conf; int i, m; if (nb_cpus != 1) return NULL; if (bus) { opp = (openpic_t *)pci_register_device(bus, "OpenPIC", sizeof(openpic_t), -1, NULL, NULL); if (opp == NULL) return NULL; pci_conf = opp->pci_dev.config; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_IBM); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_IBM_OPENPIC2); pci_config_set_class(pci_conf, PCI_CLASS_SYSTEM_OTHER); pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; pci_conf[0x3d] = 0x00; pci_register_bar((PCIDevice *)opp, 0, 0x40000, PCI_BASE_ADDRESS_SPACE_MEMORY, &openpic_map); } else { opp = qemu_mallocz(sizeof(openpic_t)); } opp->mem_index = cpu_register_io_memory(openpic_read, openpic_write, opp); opp->nb_cpus = nb_cpus; opp->max_irq = OPENPIC_MAX_IRQ; opp->irq_ipi0 = OPENPIC_IRQ_IPI0; opp->irq_tim0 = OPENPIC_IRQ_TIM0; for (i = 0; i < OPENPIC_EXT_IRQ; i++) { opp->src[i].type = IRQ_EXTERNAL; } for (; i < OPENPIC_IRQ_TIM0; i++) { opp->src[i].type = IRQ_SPECIAL; } #if MAX_IPI > 0 m = OPENPIC_IRQ_IPI0; #else m = OPENPIC_IRQ_DBL0; #endif for (; i < m; i++) { opp->src[i].type = IRQ_TIMER; } for (; i < OPENPIC_MAX_IRQ; i++) { opp->src[i].type = IRQ_INTERNAL; } for (i = 0; i < nb_cpus; i++) opp->dst[i].irqs = irqs[i]; opp->irq_out = irq_out; opp->need_swap = 1; register_savevm("openpic", 0, 2, openpic_save, openpic_load, opp); qemu_register_reset(openpic_reset, opp); opp->irq_raise = openpic_irq_raise; opp->reset = openpic_reset; if (pmem_index) *pmem_index = opp->mem_index; return qemu_allocate_irqs(openpic_set_irq, opp, opp->max_irq); }
1threat
int ff_pcm_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, size; size= RAW_SAMPLES*s->streams[0]->codec->block_align; if (size <= 0) return AVERROR(EINVAL); ret= av_get_packet(s->pb, pkt, size); pkt->flags &= ~AV_PKT_FLAG_CORRUPT; pkt->stream_index = 0; if (ret < 0) return ret; return ret; }
1threat
powershell script to zip users home folder and move it to share drive : I want to move users home folder to share drive who has left the company but before that I want to ZIP it using powershell script. Could you please suggest me or write me quick powershell script which ZIPs the folder and move to share drive creating a same folder name with zip file also same name in destination folder. For instance if source folder is C:\test and destination is \\share\test\ Thanks in Advance,
0debug
Vue2 navigate to external url with location.href : <p>I tried to go to 'www.mytargeturl.org' using router.go, router.push, router.replace and window.location.href to redirect my vuejs app but i always get myVueapp.com/www.mytargeturl.org Here's my route:</p> <pre><code> routes:[ {path: '/', component: App, children:[ { path: 'detail', component: ItemDetail, props: true }, { path: 'search', component: Middle } ] }, { path: '/test', component: Test }, { path: '/a', redirect: 'www.mytargeturl.org' } // also tried this but didnt work </code></pre> <p>]</p>
0debug
How to split sentence on first space in Apache Spark? : I am new to Apache Spark, I have a file, where every sentences which has first 10 characters as a key and rest is a value, how do I apply spark on it to extract the first 10 characters of each sentence as a key and rest as a data, so in the end I get a [key,value] pair Rdd as a output.
0debug
How to update Eclipse from 2018-09 to 2018-12 : <p>I have Eclipse 2018-09. My impressions was that Eclipse was moving to a rolling quarterly release, and by that I presumed I'd magically be offered updates every quarter to the newest. But now that 2018-12 is out, my instance does not detect any new updates.</p> <p>Looking at the update sites in Windows -> Preferences, Install/Update -> Available Software Sites (incompletely listed below), I notice they seemed to be pinned to specific versions:</p> <ul> <li><strong>The Eclipse Project Updates</strong>: <a href="http://download.eclipse.org/eclipse/updates/4.9" rel="noreferrer">http://download.eclipse.org/eclipse/updates/4.9</a></li> <li><strong>The Eclipse Project Updates</strong>: <a href="http://download.eclipse.org/eclipse/updates/4.9/categories" rel="noreferrer">http://download.eclipse.org/eclipse/updates/4.9/categories</a></li> <li><strong>Eclipse Project Repository for 2018-09</strong>: <a href="http://download.eclipse.org/eclipse/updates/4.9/R-4.9-201809060745" rel="noreferrer">http://download.eclipse.org/eclipse/updates/4.9/R-4.9-201809060745</a></li> <li><strong>2018-09</strong>: <a href="http://download.eclipse.org/releases/2018-09" rel="noreferrer">http://download.eclipse.org/releases/2018-09</a></li> <li><strong>Oracle Enterprise Pack for Eclipse 12.2.1.8 Dependencies</strong>: <a href="http://download.oracle.com/otn_software/oepe/12.2.1.8/oxygen/repository/dependencies/" rel="noreferrer">http://download.oracle.com/otn_software/oepe/12.2.1.8/oxygen/repository/dependencies/</a></li> </ul> <p>I've noticed there is also now <a href="https://www.eclipse.org/downloads/packages/installer" rel="noreferrer">an Eclipse Installer</a>, which says it is "The easiest way to install and update your Eclipse Development Environment.". However, there is no description of updating, and when running it and pointing to the existing folder for 2018-09 (yes, I made a backup first to be safe), it does not update that folder but instead just creates a new sub-folder under the existing 2018-09 version called "eclipse" with presumably a complete copy of the new eclipse. So that's a failed attempt.</p> <p>What is the recommended way of upgrading from 2018-09 to 2018-12? Is it:</p> <ol> <li>Manually download a new copy of Eclipse and spend hours configuring it to hopefully be almost the same as the configurations in 2018-09</li> <li>Run the Eclipse installer in some other manner than I already have.</li> <li>Manually updating the update sites (to what values?). If the so, is there a way to specify to always use the latest on the update train?</li> <li>Other?</li> </ol>
0debug
direct url access in php : Suppose, I have several pages in project(login.php,terms.php,profile.php, add_user.php etc).login & terms are consecutive pages. After entering correct credential user will come to terms.php page to accept T&C which include a checkbox. So my requirement is when user accept T&C then redirect to profile page and its working fine. Now i want if user try to change url of any different page which is related to profile section(eg.profile.php,add_user.php..... any page) without accepting T&C then it should redirect to same page.i.e terms.php. I want to restrict user to access any page without accepting T&C by direct changing the url.[enter image description here][1] [1]: https://i.stack.imgur.com/P14B1.png
0debug
PHP img src (simple) : <p>I am trying to add an image file to my PHP so when I echo, the picture will appear alongside the message. However I am getting a syntax error on line 3. Any help would be appreciated.</p> <pre><code>&lt;?php echo "President has been killed"; &lt;IMG SRC = "D:/User Data\Documents/Sheridan/Summer Year 3/Enterprise Java Development/Projects/PhpAssignment/skull.png;"/&gt; ?&gt; </code></pre>
0debug
How to Resume C# Application After the Windows Restart : <p>I am Trying to Install IIS and SQL Server one by one using Winforms... But After Installing the IIS.System Needs to be Restarted,After Restarting It Just again Start installing the Same IIS.</p> <p>So I Need to Know how to Resume the Application After Restarting.. Does Anyone help me with Nice Example???</p>
0debug
Python Word to Number Calculator? : <p>So I have a project in one of my classes where we have to create a calculator that takes the word of a number and adds it to another word of a number and generates the product as a word. (I.E. ten + ten = twenty, or five + four = nine, etc.) I know how to make basic calculators in python but I have absolutely no clue where to start on this one. Any help or just a start would be great!</p>
0debug
matplotlib: AttributeError: 'AxesSubplot' object has no attribute 'add_axes' : <p>Not sure exactly sure how to fix the following attribute error:</p> <pre><code>AttributeError: 'AxesSubplot' object has no attribute 'add_axes' </code></pre> <p>The offending problem seems to be linked to the way I have set up my plot:</p> <pre><code>gridspec_layout = gridspec.GridSpec(3,3) pyplot_2 = fig.add_subplot(gridspec_layout[2]) ax = WCSAxes(fig, [0.1, 0.1, 0.8, 0.8], wcs=wcs) pyplot_2.add_axes(ax) </code></pre> <p>Does anybody know how to solve this? Many thanks.</p>
0debug
static void tcg_out_ri32(TCGContext *s, int const_arg, TCGArg arg) { if (const_arg) { assert(const_arg == 1); tcg_out8(s, TCG_CONST); tcg_out32(s, arg); } else { tcg_out_r(s, arg); } }
1threat
How to grab headers in python selenium-webdriver : <p>I am trying to grab the headers in selenium webdriver. Something similar to the following:</p> <pre><code>&gt;&gt;&gt; import requests &gt;&gt;&gt; res=requests.get('http://google.com') &gt;&gt;&gt; print res.headers </code></pre> <p>I need to use the <code>Chrome</code> webdriver because it supports flash and some other things that I need to test a web page. Here is what I have so far in Selenium:</p> <pre><code>from selenium import webdriver driver = webdriver.Chrome() driver.get('https://login.comcast.net/login?r=comcast.net&amp;s=oauth&amp;continue=https%3A%2F%2Flogin.comcast.net%2Foauth%2Fauthorize%3Fclient_id%3Dxtv-account-selector%26redirect_uri%3Dhttps%3A%2F%2Fxtv-pil.xfinity.com%2Fxtv-authn%2Fxfinity-cb%26response_type%3Dcode%26scope%3Dopenid%2520https%3A%2F%2Flogin.comcast.net%2Fapi%2Flogin%26state%3Dhttps%3A%2F%2Ftv.xfinity.com%2Fpartner-success.html%26prompt%3Dlogin%26response%3D1&amp;reqId=18737431-624b-44cb-adf0-2a85d91bd662&amp;forceAuthn=1&amp;client_id=xtv-account-selector') driver.find_element_by_css_selector('#user').send_keys('XY@comcast.net') driver.find_element_by_css_selector('#passwd').send_keys('XXY') driver.find_element_by_css_selector('#passwd').submit() print driver.headers ### How to do this? </code></pre> <p>I have seen some other answers that recommend running an entire selenium server to get this information (<a href="https://github.com/derekargueta/selenium-profiler">https://github.com/derekargueta/selenium-profiler</a>). How would I get it using something similar to the above with Webdriver?</p>
0debug
Which is better between angularJs and angular2 for enterprise big product (startup)? : <p>We are planning to create an enterprise startup product that will release 3 or 4 years later. Recently we have planed to create our UI. Now question is that what will be a wise decision to choose AngularJs or Angular 2? Why?</p>
0debug
static int mov_write_header(AVFormatContext *s) { AVIOContext *pb = s->pb; MOVMuxContext *mov = s->priv_data; AVDictionaryEntry *t; int i, hint_track = 0; mov->mode = MODE_MP4; if (s->oformat != NULL) { if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP; else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3GP|MODE_3G2; else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV; else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP; else if (!strcmp("ipod",s->oformat->name)) mov->mode = MODE_IPOD; else if (!strcmp("ismv",s->oformat->name)) mov->mode = MODE_ISM; } if (mov->max_fragment_duration || mov->max_fragment_size || mov->mode == MODE_ISM || mov->flags & (FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_FRAG_KEYFRAME | FF_MOV_FLAG_FRAG_CUSTOM)) mov->flags |= FF_MOV_FLAG_FRAGMENT; if (mov->flags & FF_MOV_FLAG_FASTSTART) { if ((mov->flags & FF_MOV_FLAG_FRAGMENT) || (s->flags & AVFMT_FLAG_CUSTOM_IO)) { av_log(s, AV_LOG_WARNING, "The faststart flag is incompatible " "with fragmentation and custom IO, disabling faststart\n"); mov->flags &= ~FF_MOV_FLAG_FASTSTART; } } if (!s->pb->seekable && (!(mov->flags & FF_MOV_FLAG_FRAGMENT) || mov->ism_lookahead)) { av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); return -1; } mov_write_ftyp_tag(pb,s); if (mov->mode == MODE_PSP) { if (s->nb_streams != 2) { av_log(s, AV_LOG_ERROR, "PSP mode need one video and one audio stream\n"); return -1; } mov_write_uuidprof_tag(pb, s); } mov->nb_streams = s->nb_streams; if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters) mov->chapter_track = mov->nb_streams++; if (mov->flags & FF_MOV_FLAG_RTP_HINT) { hint_track = mov->nb_streams; for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO || st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { mov->nb_streams++; } } } mov->tracks = av_mallocz((mov->nb_streams + 1) * sizeof(*mov->tracks)); if (!mov->tracks) return AVERROR(ENOMEM); for (i = 0; i < s->nb_streams; i++) { AVStream *st= s->streams[i]; MOVTrack *track= &mov->tracks[i]; AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0); track->enc = st->codec; track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV); if (track->language < 0) track->language = 0; track->mode = mov->mode; track->tag = mov_find_codec_tag(s, track); if (!track->tag) { av_log(s, AV_LOG_ERROR, "track %d: could not find tag, " "codec not currently supported in container\n", i); goto error; } track->hint_track = -1; track->start_dts = AV_NOPTS_VALUE; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') || track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') || track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) { if (st->codec->width != 720 || (st->codec->height != 608 && st->codec->height != 512)) { av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n"); goto error; } track->height = track->tag >> 24 == 'n' ? 486 : 576; } track->timescale = st->codec->time_base.den; if (track->mode == MODE_MOV && track->timescale > 100000) av_log(s, AV_LOG_WARNING, "WARNING codec timebase is very high. If duration is too long,\n" "file may not be playable by quicktime. Specify a shorter timebase\n" "or choose different container.\n"); } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { track->timescale = st->codec->sample_rate; if (av_get_bits_per_sample(st->codec->codec_id) || st->codec->codec_id == AV_CODEC_ID_ILBC) { if (!st->codec->block_align) { av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set\n", i); goto error; } track->sample_size = st->codec->block_align; } if (av_get_bits_per_sample(st->codec->codec_id) < 8) { track->audio_vbr = 1; } if (track->mode != MODE_MOV && track->enc->codec_id == AV_CODEC_ID_MP3 && track->timescale < 16000) { av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not supported\n", i, track->enc->sample_rate); goto error; } } else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { track->timescale = st->codec->time_base.den; } else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) { track->timescale = st->codec->time_base.den; } if (!track->height) track->height = st->codec->height; if (mov->mode == MODE_ISM) track->timescale = 10000000; avpriv_set_pts_info(st, 64, 1, track->timescale); if (st->codec->extradata_size) { track->vos_len = st->codec->extradata_size; track->vos_data = av_malloc(track->vos_len); memcpy(track->vos_data, st->codec->extradata, track->vos_len); } } enable_tracks(s); if (mov->mode == MODE_ISM) { if (!(mov->flags & (FF_MOV_FLAG_FRAG_KEYFRAME | FF_MOV_FLAG_FRAG_CUSTOM)) && !mov->max_fragment_duration && !mov->max_fragment_size) mov->max_fragment_duration = 5000000; mov->flags |= FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_SEPARATE_MOOF; } if (!(mov->flags & FF_MOV_FLAG_FRAGMENT)) { if (mov->flags & FF_MOV_FLAG_FASTSTART) mov->reserved_moov_pos = avio_tell(pb); mov_write_mdat_tag(pb, mov); } if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) mov->time = ff_iso8601_to_unix_time(t->value); if (mov->time) mov->time += 0x7C25B080; if (mov->chapter_track) if (mov_create_chapter_track(s, mov->chapter_track) < 0) goto error; if (mov->flags & FF_MOV_FLAG_RTP_HINT) { for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO || st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { ff_mov_init_hinting(s, hint_track, i); hint_track++; } } } avio_flush(pb); if (mov->flags & FF_MOV_FLAG_ISML) mov_write_isml_manifest(pb, mov); if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV) { mov_write_moov_tag(pb, mov, s); mov->fragments++; } return 0; error: mov_free(s); return -1; }
1threat
What is the 'Subtract Days' equivalent of DateTimePicker.Value.AddDays()? : <p>I have a DateTimePicker and two buttons on a form. The buttons are intended to allow a user to cycle backwards and forwards through the dates displayed in the picker.</p> <p>The code DateTimePicker.Value.AddDays(1); increments the value displayed and DateTimePicker.Value.AddDays(-1); decrements it. It seems a bit clunky to me but this works as expected, is passing in a value of -1 the correct way to decrement the displayed date?</p> <p>Why isn't there a SubtractDays() method? </p>
0debug
How to view logs for a docker image? : <p>In the docker world, one can easily see logs for docker container (that is, a running image). But during image creation, one usually issues multiple commands. For example npm install commands in node projects. It would be beneficial to see logs for those commands as well. I quickly searched from the documentation, but didn't find how one can obtain logs for docker image. Is it possible?</p>
0debug
only assignment, call, increment, decrement, await, and new object, expressions can be used as a statement : <p>Error</p> <blockquote> <p>only assignment, call, increment, decrement, await, and new object, expressions can be used as a statement</p> </blockquote> <pre><code>**Code Line* bool IsShiny() { get; set; } </code></pre>
0debug
static void uart_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) { CadenceUARTState *s = opaque; DB_PRINT(" offset:%x data:%08x\n", (unsigned)offset, (unsigned)value); offset >>= 2; switch (offset) { case R_IER: s->r[R_IMR] |= value; break; case R_IDR: s->r[R_IMR] &= ~value; break; case R_IMR: break; case R_CISR: s->r[R_CISR] &= ~value; break; case R_TX_RX: switch (s->r[R_MR] & UART_MR_CHMODE) { case NORMAL_MODE: uart_write_tx_fifo(s, (uint8_t *) &value, 1); break; case LOCAL_LOOPBACK: uart_write_rx_fifo(opaque, (uint8_t *) &value, 1); break; break; default: s->r[offset] = value; switch (offset) { case R_CR: uart_ctrl_update(s); break; case R_MR: uart_parameters_setup(s); break; uart_update_status(s);
1threat
Convert indefinitely running Runnable from java to kotlin : <p>I have some code like this in java that monitors a certain file:</p> <pre><code>private Handler mHandler = new Handler(); private final Runnable monitor = new Runnable() { public void run() { // Do my stuff mHandler.postDelayed(monitor, 1000); // 1 second } }; </code></pre> <p>This is my kotlin code:</p> <pre><code>private val mHandler = Handler() val monitor: Runnable = Runnable { // do my stuff mHandler.postDelayed(whatToDoHere, 1000) // 1 second } </code></pre> <p>I dont understand what <code>Runnable</code> I should pass into <code>mHandler.postDelayed</code>. What is the right solution? Another interesting thing is that the kotlin to java convertor freezes when I feed this code.</p>
0debug
static int disas_coproc_insn(DisasContext *s, uint32_t insn) { int cpnum, is64, crn, crm, opc1, opc2, isread, rt, rt2; const ARMCPRegInfo *ri; cpnum = (insn >> 8) & 0xf; if (arm_dc_feature(s, ARM_FEATURE_XSCALE) && (cpnum < 2)) { if (extract32(s->c15_cpar, cpnum, 1) == 0) { return 1; } if (arm_dc_feature(s, ARM_FEATURE_IWMMXT)) { return disas_iwmmxt_insn(s, insn); } else if (arm_dc_feature(s, ARM_FEATURE_XSCALE)) { return disas_dsp_insn(s, insn); } return 1; } is64 = (insn & (1 << 25)) == 0; if (!is64 && ((insn & (1 << 4)) == 0)) { return 1; } crm = insn & 0xf; if (is64) { crn = 0; opc1 = (insn >> 4) & 0xf; opc2 = 0; rt2 = (insn >> 16) & 0xf; } else { crn = (insn >> 16) & 0xf; opc1 = (insn >> 21) & 7; opc2 = (insn >> 5) & 7; rt2 = 0; } isread = (insn >> 20) & 1; rt = (insn >> 12) & 0xf; ri = get_arm_cp_reginfo(s->cp_regs, ENCODE_CP_REG(cpnum, is64, s->ns, crn, crm, opc1, opc2)); if (ri) { if (!cp_access_ok(s->current_el, ri, isread)) { return 1; } if (ri->accessfn || (arm_dc_feature(s, ARM_FEATURE_XSCALE) && cpnum < 14)) { TCGv_ptr tmpptr; TCGv_i32 tcg_syn; uint32_t syndrome; switch (cpnum) { case 14: if (is64) { syndrome = syn_cp14_rrt_trap(1, 0xe, opc1, crm, rt, rt2, isread, s->thumb); } else { syndrome = syn_cp14_rt_trap(1, 0xe, opc1, opc2, crn, crm, rt, isread, s->thumb); } break; case 15: if (is64) { syndrome = syn_cp15_rrt_trap(1, 0xe, opc1, crm, rt, rt2, isread, s->thumb); } else { syndrome = syn_cp15_rt_trap(1, 0xe, opc1, opc2, crn, crm, rt, isread, s->thumb); } break; default: assert(!arm_dc_feature(s, ARM_FEATURE_V8)); syndrome = syn_uncategorized(); break; } gen_set_pc_im(s, s->pc); tmpptr = tcg_const_ptr(ri); tcg_syn = tcg_const_i32(syndrome); gen_helper_access_check_cp_reg(cpu_env, tmpptr, tcg_syn); tcg_temp_free_ptr(tmpptr); tcg_temp_free_i32(tcg_syn); } switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) { case ARM_CP_NOP: return 0; case ARM_CP_WFI: if (isread) { return 1; } gen_set_pc_im(s, s->pc); s->is_jmp = DISAS_WFI; return 0; default: break; } if (use_icount && (ri->type & ARM_CP_IO)) { gen_io_start(); } if (isread) { if (is64) { TCGv_i64 tmp64; TCGv_i32 tmp; if (ri->type & ARM_CP_CONST) { tmp64 = tcg_const_i64(ri->resetvalue); } else if (ri->readfn) { TCGv_ptr tmpptr; tmp64 = tcg_temp_new_i64(); tmpptr = tcg_const_ptr(ri); gen_helper_get_cp_reg64(tmp64, cpu_env, tmpptr); tcg_temp_free_ptr(tmpptr); } else { tmp64 = tcg_temp_new_i64(); tcg_gen_ld_i64(tmp64, cpu_env, ri->fieldoffset); } tmp = tcg_temp_new_i32(); tcg_gen_trunc_i64_i32(tmp, tmp64); store_reg(s, rt, tmp); tcg_gen_shri_i64(tmp64, tmp64, 32); tmp = tcg_temp_new_i32(); tcg_gen_trunc_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); store_reg(s, rt2, tmp); } else { TCGv_i32 tmp; if (ri->type & ARM_CP_CONST) { tmp = tcg_const_i32(ri->resetvalue); } else if (ri->readfn) { TCGv_ptr tmpptr; tmp = tcg_temp_new_i32(); tmpptr = tcg_const_ptr(ri); gen_helper_get_cp_reg(tmp, cpu_env, tmpptr); tcg_temp_free_ptr(tmpptr); } else { tmp = load_cpu_offset(ri->fieldoffset); } if (rt == 15) { gen_set_nzcv(tmp); tcg_temp_free_i32(tmp); } else { store_reg(s, rt, tmp); } } } else { if (ri->type & ARM_CP_CONST) { return 0; } if (is64) { TCGv_i32 tmplo, tmphi; TCGv_i64 tmp64 = tcg_temp_new_i64(); tmplo = load_reg(s, rt); tmphi = load_reg(s, rt2); tcg_gen_concat_i32_i64(tmp64, tmplo, tmphi); tcg_temp_free_i32(tmplo); tcg_temp_free_i32(tmphi); if (ri->writefn) { TCGv_ptr tmpptr = tcg_const_ptr(ri); gen_helper_set_cp_reg64(cpu_env, tmpptr, tmp64); tcg_temp_free_ptr(tmpptr); } else { tcg_gen_st_i64(tmp64, cpu_env, ri->fieldoffset); } tcg_temp_free_i64(tmp64); } else { if (ri->writefn) { TCGv_i32 tmp; TCGv_ptr tmpptr; tmp = load_reg(s, rt); tmpptr = tcg_const_ptr(ri); gen_helper_set_cp_reg(cpu_env, tmpptr, tmp); tcg_temp_free_ptr(tmpptr); tcg_temp_free_i32(tmp); } else { TCGv_i32 tmp = load_reg(s, rt); store_cpu_offset(tmp, ri->fieldoffset); } } } if (use_icount && (ri->type & ARM_CP_IO)) { gen_io_end(); gen_lookup_tb(s); } else if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { gen_lookup_tb(s); } return 0; } if (is64) { qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch32 " "64 bit system register cp:%d opc1: %d crm:%d " "(%s)\n", isread ? "read" : "write", cpnum, opc1, crm, s->ns ? "non-secure" : "secure"); } else { qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch32 " "system register cp:%d opc1:%d crn:%d crm:%d opc2:%d " "(%s)\n", isread ? "read" : "write", cpnum, opc1, crn, crm, opc2, s->ns ? "non-secure" : "secure"); } return 1; }
1threat
void visit_type_uint64(Visitor *v, uint64_t *obj, const char *name, Error **errp) { int64_t value; if (!error_is_set(errp)) { if (v->type_uint64) { v->type_uint64(v, obj, name, errp); } else { value = *obj; v->type_int(v, &value, name, errp); *obj = value; } } }
1threat
SELECT SM THEN UPDATE LOOP : i want to make the sum of the column FLAN01+FLAN02+FLAN03+FLAN04 AND PUT THE SUM IN FLAWTD FOR EACH FLNUMB; NEED YOUR HELP THANKS FLAID FLCTRY FLFY FLLT FLAPYC FLAN01 FLAN02 FLAN03 FLAN04 FLAWTD FLNUMB 2749023 20 17 AA -2832227 0 0 0 0 0 1 2524 20 17 AA -164999 0 0 0 0 0 2 2749023 20 17 AA -2460920 0 0 0 0 0 3 2749023 20 17 AA -2756040 0 0 0 0 0 4 2524 20 17 AA -197730 0 0 0 0 0 5 2749277 20 17 AA -133875 0 0 0 0 0 6 2749091 20 17 AA -957654 -8619 -8619 -8620 -8619 -94812 7 2749091 20 17 AA -957654 -8619 -8619 -8620 -8619 -94812 8 2749091 20 17 AA -957654 -8619 -8619 -8620 -8619 -94812 9 2749091 20 17 AA -957654 -8619 -8619 -8620 -8619 -94812 10 2749091 20 17 AA -957654 -8619 -8619 -8620 -8619 -94812 11 2749091 20 17 AA -921543 -9314 -9314 -9314 -9314 -102453 12 2749091 20 17 AA -957654 -8619 -8619 -8620 -8619 -94812 13 2749091 20 17 AA -921543 -9314 -9314 -9314 -9314 -102453 14 2749091 20 17 AA -921543 -9314 -9314 -9314 -9314 -102453 15
0debug
static int ape_read_header(AVFormatContext * s) { AVIOContext *pb = s->pb; APEContext *ape = s->priv_data; AVStream *st; uint32_t tag; int i; int total_blocks, final_size = 0; int64_t pts, file_size; ape->junklength = avio_tell(pb); tag = avio_rl32(pb); if (tag != MKTAG('M', 'A', 'C', ' ')) return AVERROR_INVALIDDATA; ape->fileversion = avio_rl16(pb); if (ape->fileversion < APE_MIN_VERSION || ape->fileversion > APE_MAX_VERSION) { av_log(s, AV_LOG_ERROR, "Unsupported file version - %d.%02d\n", ape->fileversion / 1000, (ape->fileversion % 1000) / 10); return AVERROR_PATCHWELCOME; } if (ape->fileversion >= 3980) { ape->padding1 = avio_rl16(pb); ape->descriptorlength = avio_rl32(pb); ape->headerlength = avio_rl32(pb); ape->seektablelength = avio_rl32(pb); ape->wavheaderlength = avio_rl32(pb); ape->audiodatalength = avio_rl32(pb); ape->audiodatalength_high = avio_rl32(pb); ape->wavtaillength = avio_rl32(pb); avio_read(pb, ape->md5, 16); if (ape->descriptorlength > 52) avio_skip(pb, ape->descriptorlength - 52); ape->compressiontype = avio_rl16(pb); ape->formatflags = avio_rl16(pb); ape->blocksperframe = avio_rl32(pb); ape->finalframeblocks = avio_rl32(pb); ape->totalframes = avio_rl32(pb); ape->bps = avio_rl16(pb); ape->channels = avio_rl16(pb); ape->samplerate = avio_rl32(pb); } else { ape->descriptorlength = 0; ape->headerlength = 32; ape->compressiontype = avio_rl16(pb); ape->formatflags = avio_rl16(pb); ape->channels = avio_rl16(pb); ape->samplerate = avio_rl32(pb); ape->wavheaderlength = avio_rl32(pb); ape->wavtaillength = avio_rl32(pb); ape->totalframes = avio_rl32(pb); ape->finalframeblocks = avio_rl32(pb); if (ape->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) { avio_skip(pb, 4); ape->headerlength += 4; } if (ape->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) { ape->seektablelength = avio_rl32(pb); ape->headerlength += 4; ape->seektablelength *= sizeof(int32_t); } else ape->seektablelength = ape->totalframes * sizeof(int32_t); if (ape->formatflags & MAC_FORMAT_FLAG_8_BIT) ape->bps = 8; else if (ape->formatflags & MAC_FORMAT_FLAG_24_BIT) ape->bps = 24; else ape->bps = 16; if (ape->fileversion >= 3950) ape->blocksperframe = 73728 * 4; else if (ape->fileversion >= 3900 || (ape->fileversion >= 3800 && ape->compressiontype >= 4000)) ape->blocksperframe = 73728; else ape->blocksperframe = 9216; if (!(ape->formatflags & MAC_FORMAT_FLAG_CREATE_WAV_HEADER)) avio_skip(pb, ape->wavheaderlength); } if(!ape->totalframes){ av_log(s, AV_LOG_ERROR, "No frames in the file!\n"); return AVERROR(EINVAL); } if(ape->totalframes > UINT_MAX / sizeof(APEFrame)){ av_log(s, AV_LOG_ERROR, "Too many frames: %"PRIu32"\n", ape->totalframes); return AVERROR_INVALIDDATA; } if (ape->seektablelength / sizeof(*ape->seektable) < ape->totalframes) { av_log(s, AV_LOG_ERROR, "Number of seek entries is less than number of frames: %zu vs. %"PRIu32"\n", ape->seektablelength / sizeof(*ape->seektable), ape->totalframes); return AVERROR_INVALIDDATA; } ape->frames = av_malloc(ape->totalframes * sizeof(APEFrame)); if(!ape->frames) return AVERROR(ENOMEM); ape->firstframe = ape->junklength + ape->descriptorlength + ape->headerlength + ape->seektablelength + ape->wavheaderlength; if (ape->fileversion < 3810) ape->firstframe += ape->totalframes; ape->currentframe = 0; ape->totalsamples = ape->finalframeblocks; if (ape->totalframes > 1) ape->totalsamples += ape->blocksperframe * (ape->totalframes - 1); if (ape->seektablelength > 0) { ape->seektable = av_malloc(ape->seektablelength); if (!ape->seektable) return AVERROR(ENOMEM); for (i = 0; i < ape->seektablelength / sizeof(uint32_t) && !pb->eof_reached; i++) ape->seektable[i] = avio_rl32(pb); if (ape->fileversion < 3810) { ape->bittable = av_malloc(ape->totalframes); if (!ape->bittable) return AVERROR(ENOMEM); for (i = 0; i < ape->totalframes && !pb->eof_reached; i++) ape->bittable[i] = avio_r8(pb); } } ape->frames[0].pos = ape->firstframe; ape->frames[0].nblocks = ape->blocksperframe; ape->frames[0].skip = 0; for (i = 1; i < ape->totalframes; i++) { ape->frames[i].pos = ape->seektable[i] + ape->junklength; ape->frames[i].nblocks = ape->blocksperframe; ape->frames[i - 1].size = ape->frames[i].pos - ape->frames[i - 1].pos; ape->frames[i].skip = (ape->frames[i].pos - ape->frames[0].pos) & 3; } ape->frames[ape->totalframes - 1].nblocks = ape->finalframeblocks; file_size = avio_size(pb); if (file_size > 0) { final_size = file_size - ape->frames[ape->totalframes - 1].pos - ape->wavtaillength; final_size -= final_size & 3; } if (file_size <= 0 || final_size <= 0) final_size = ape->finalframeblocks * 8; ape->frames[ape->totalframes - 1].size = final_size; for (i = 0; i < ape->totalframes; i++) { if(ape->frames[i].skip){ ape->frames[i].pos -= ape->frames[i].skip; ape->frames[i].size += ape->frames[i].skip; } ape->frames[i].size = (ape->frames[i].size + 3) & ~3; } if (ape->fileversion < 3810) { for (i = 0; i < ape->totalframes; i++) { if (i < ape->totalframes - 1 && ape->bittable[i + 1]) ape->frames[i].size += 4; ape->frames[i].skip <<= 3; ape->frames[i].skip += ape->bittable[i]; } } ape_dumpinfo(s, ape); av_log(s, AV_LOG_DEBUG, "Decoding file - v%d.%02d, compression level %"PRIu16"\n", ape->fileversion / 1000, (ape->fileversion % 1000) / 10, ape->compressiontype); st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); total_blocks = (ape->totalframes == 0) ? 0 : ((ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = AV_CODEC_ID_APE; st->codec->codec_tag = MKTAG('A', 'P', 'E', ' '); st->codec->channels = ape->channels; st->codec->sample_rate = ape->samplerate; st->codec->bits_per_coded_sample = ape->bps; st->nb_frames = ape->totalframes; st->start_time = 0; st->duration = total_blocks; avpriv_set_pts_info(st, 64, 1, ape->samplerate); if (ff_alloc_extradata(st->codec, APE_EXTRADATA_SIZE)) return AVERROR(ENOMEM); AV_WL16(st->codec->extradata + 0, ape->fileversion); AV_WL16(st->codec->extradata + 2, ape->compressiontype); AV_WL16(st->codec->extradata + 4, ape->formatflags); pts = 0; for (i = 0; i < ape->totalframes; i++) { ape->frames[i].pts = pts; av_add_index_entry(st, ape->frames[i].pos, ape->frames[i].pts, 0, 0, AVINDEX_KEYFRAME); pts += ape->blocksperframe; } if (pb->seekable) { ff_ape_parse_tag(s); avio_seek(pb, 0, SEEK_SET); } return 0; }
1threat
Java - possible lossy conversion from double to int : <p>I am attempting to write a program that pick s a random value that the user inputs and I am getting the error - possible lossy conversion from double to int. Here is my code. Any help is appreciated.</p> <pre><code>public class Driver { public static void main(String [] args)throws IOException{ int random; int options; Scanner input = new Scanner(System.in); int randy; System.out.print("Please enter the number of options you would like to use: "); String [] choices = new String [input.nextInt()]; int min = 1; int max = choices.length; random = (Math.random() * ((max - min) + 1)) + min; for(int i = 0; i &lt; choices.length; i++){ System.out.print("Enter option " + (i+1) + ": "); choices[i] = input.next(); } System.out.print("The random option chosen is: " + choices[random]); } } </code></pre>
0debug
Removing letters from words in javascript : <p>I want to output words that have deleted duplicates. For example:</p> <pre><code>"thisss iss aa senttence" =&gt; expected output = "this is a sentence" </code></pre>
0debug
void ff_put_h264_qpel4_mc11_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_hv_qrt_4w_msa(src - 2, src - (stride * 2), stride, dst, stride, 4); }
1threat
static void channel_store_c(struct fs_dma_ctrl *ctrl, int c) { target_phys_addr_t addr = channel_reg(ctrl, c, RW_GROUP_DOWN); D(printf("%s ch=%d addr=" TARGET_FMT_plx "\n", __func__, c, addr)); D(dump_d(c, &ctrl->channels[c].current_d)); cpu_physical_memory_write (addr, (void *) &ctrl->channels[c].current_c, sizeof ctrl->channels[c].current_c); }
1threat
Read files in C : <p>Can any one tell me that, how do we read a specific portion of file using c.</p> <p>I have a file of 1000 Characters and I want to read it in parts eg: First 0 to 100 Characters and then 101 to 200 and so on. I have tried fread() and fseek() but couldn't do it.</p> <p>I want something like a pointer starts from the beginning of file and reads 100 chars and then moves to 101 position and then again reads 100 chars and so on.</p>
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
How to access Javascript module with Duktape in Android : <p>I am successfully parsing and evaluating a javascript file with Duktape in my Android application using Kotlin.</p> <pre><code>val file_name = "lib.js" val js_string = application.assets.open(file_name).bufferedReader().use { it.readText() } val duktape = Duktape.create() try { Log.d("Greeting", duktape.evaluate("'hello world'.toUpperCase();").toString()) duktape.evaluate(js_string) } finally { duktape.close() } </code></pre> <p>The javascript file was created with Browserify, so it is one single file with everything and it is working fine. But I need to request a module and a method from the module, example:</p> <pre><code>var test = require('testjs-lib'); test.EVPair.makeRandom().toWTF(); </code></pre> <p>I have no idea of how to do it and have not found any example, besides this link: <a href="http://wiki.duktape.org/HowtoModules.html" rel="noreferrer">http://wiki.duktape.org/HowtoModules.html</a></p> <p>It tells me to use a modsearch, but I don't have a clue how to do it or where it should be placed, not even if it is applicable for the Duktape Android (<a href="https://github.com/square/duktape-android" rel="noreferrer">https://github.com/square/duktape-android</a>).</p> <p>Has anybody done it successfully that could shed some light on this matter?</p>
0debug
int av_image_get_linesize(enum PixelFormat pix_fmt, int width, int plane) { const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; int max_step [4]; int max_step_comp[4]; int s; if (desc->flags & PIX_FMT_BITSTREAM) return (width * (desc->comp[0].step_minus1+1) + 7) >> 3; av_image_fill_max_pixsteps(max_step, max_step_comp, desc); s = (max_step_comp[plane] == 1 || max_step_comp[plane] == 2) ? desc->log2_chroma_w : 0; return max_step[plane] * (((width + (1 << s) - 1)) >> s); }
1threat
static void vfio_rtl8168_window_quirk_write(void *opaque, hwaddr addr, uint64_t data, unsigned size) { VFIOQuirk *quirk = opaque; VFIOPCIDevice *vdev = quirk->vdev; switch (addr) { case 4: if ((data & 0x7fff0000) == 0x10000) { if (data & 0x80000000U && vdev->pdev.cap_present & QEMU_PCI_CAP_MSIX) { trace_vfio_rtl8168_window_quirk_write_table( memory_region_name(&quirk->mem), vdev->vbasedev.name); memory_region_dispatch_write(&vdev->pdev.msix_table_mmio, (hwaddr)(data & 0xfff), (uint64_t)quirk->data.address_mask, size, MEMTXATTRS_UNSPECIFIED); } quirk->data.flags = 1; quirk->data.address_match = data; return; } quirk->data.flags = 0; break; case 0: quirk->data.address_mask = data; break; } trace_vfio_rtl8168_window_quirk_write_direct( memory_region_name(&quirk->mem), vdev->vbasedev.name); vfio_region_write(&vdev->bars[quirk->data.bar].region, addr + 0x70, data, size); }
1threat
How does compareTo() works : I read some answers regarding compareTo() function but still not clear about how it works internally. I have below code snippet which I am trying to understand. public class Employee implements Comparable<Employee> { private int id; private String name; private int age; private long salary; public int getId() { return id; } public String getName() { return name; } public int getAge() { return age; } public long getSalary() { return salary; } public Employee(int id, String name, int age, int salary) { this.id = id; this.name = name; this.age = age; this.salary = salary; } @Override public int compareTo(Employee emp) { //let's sort the employee based on id in ascending order //returns a negative integer, zero, or a positive integer as this employee id //is less than, equal to, or greater than the specified object. return (this.id - emp.id); } } And one CompareClass as: public class CompareClass { public static void main(String[] args) { // TODO Auto-generated method stub Employee[] empArr = new Employee[4]; empArr[0] = new Employee(10, "Mikey", 25, 10000); empArr[1] = new Employee(20, "Arun", 29, 20000); empArr[2] = new Employee(5, "Lisa", 35, 5000); empArr[3] = new Employee(1, "Pankaj", 32, 50000); //sorting employees array using Comparable interface implementation Arrays.sort(empArr); System.out.println("Default Sorting of Employees list:\n"+Arrays.toString(empArr)); } } So when Arrays.sort(empArr) is called then inside compareTo() which is the this.id and which is emp.id. Basically I am trying to understand , when compareTo() is called then employee object from empArr becomes the current object and then with which object it is getting compared. return (this.id - emp.id); so what is "this" and "emp" ?
0debug
Sql Server Table data Retrival : I have attended a Interview recently interviewer asked me a Question i.e. **UserId UserName**<br/> 1 Name1 <br/> 1 Name2<br/> 2 Name3 Here he want to retrieve either Name1 or Name2 using where conditon? how cai i get the result i wrote like select Username from Users where Username='Name1' or Username='Name2' but here both the consditions are satisfying so two records coming...what will be the query to retrive the data please give your answers.. Thanks in Advance
0debug
c# Getting runtime error. Why? : <p>Hey im trying to solve this problem but Kattis says i get runtime error which means uncaught exception. <a href="https://open.kattis.com/problems/fizzbuzz" rel="nofollow noreferrer">https://open.kattis.com/problems/fizzbuzz</a></p> <p>Is there anything that ive missed in my code that crashes the app?</p> <pre><code>public static void Main(string[] args) { string line = ""; while ((line = Console.ReadLine()) != "0") { var numbers = line.Split(' ').Select(int.Parse).ToList(); int x = numbers[0]; int y = numbers[1]; int N = numbers[2]; for(int i = 1; i &lt;= N; i++) { bool found = false; bool found2 = false; if(i % x == 0) { if(i % y==0) { Console.WriteLine("FizzBuzz"); found2 = true; } else { Console.WriteLine("Fizz"); found = true; } } if(i % y == 0 &amp;&amp; !found2) { Console.WriteLine("Buzz"); found = true; } if(!found &amp;&amp; !found2) { Console.WriteLine(i); } } } } </code></pre>
0debug
how to get vaule of function if return type is class : I am new in c# dot net and i am using trying to calling soap web service. one of function in webservice returning class type. I am not able to get how I will return the value to type class. Below is my function AuthenticateUser(string user_name, string password); this function is returning class EQUser. class consist of varialbles user_id int user_name string level int user_group_id int password string extended_permissions int email_id string email_username string guid string how i typecast AuthenticateUser function to get these above value I have tried ServiceReference1.EqClient user = new ServiceReference1.EqClient(); ServiceReference1.EQUsers equsr = new ServiceReference1.EQUsers(); user.EQAuthenticateUser("admin", ""); how i will typecast user.EQAuthenticateUser("admin", ""); to ServiceReference1.EQUsers class
0debug
Handle dynamic language change within the app on android app bundle : <p>I have used the latest android packing format bundle and shipped my app to beta channel,bundles reduced ~60% of app size which was really awesome ,</p> <p>my app has support for english and arabic (can be switched within the app on fly)</p> <p>now the problem : AFAIK the base apk will only have resources for the users language during app download (if at time of download,if the language was english.only string-en.xml gets downlaoded) </p> <p>so how do i handle the situation where in user switch the language within the app ..</p> <p>please let me know.. </p>
0debug
for loop error while dropiing column in dataframe : i am facing some error in r please do find the below code for (i in 1:64) { if (sum(is.na(prop_train$nam[i]))/length(prop_train$nam[i]) > .3) {prop_train$nam[i] <- NULL} } about code : i am writing this code for droping the columns which are have NA more tha 30% in dataframe , but i am facing this error:Error in if (sum(is.na(prop_train$nam[i]))/length(prop_train$nam[i]) > : missing value where TRUE/FALSE needed In addition: Warning message: In is.na(prop_train$nam[i]) :
0debug
stop a java program within a java program : I wanted to stop a java program that has been run with command prompt in windows. How is it possible to shutdown it provided that there are some other running java programs. This should be with a java program not manually. p.s: I searched a lot for answer and I did not find an answer even here and my question is clear. please do not add unrelated comments.
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
I tried everything but not found the mistake to insert the query on the table. Please anyone help me : [php code didnt insert. click here to view the code][1] '$conn = mysqli_conncect("localhost","root","","auth");' [1]: https://i.stack.imgur.com/obui2.png
0debug
void do_divdo (void) { if (likely(!(((int64_t)T0 == INT64_MIN && (int64_t)T1 == -1ULL) || (int64_t)T1 == 0))) { xer_ov = 0; T0 = (int64_t)T0 / (int64_t)T1; } else { xer_so = 1; xer_ov = 1; T0 = (-1ULL) * ((uint64_t)T0 >> 63); } }
1threat
coroutine_fn iscsi_co_pdiscard(BlockDriverState *bs, int64_t offset, int count) { IscsiLun *iscsilun = bs->opaque; struct IscsiTask iTask; struct unmap_list list; if (!is_byte_request_lun_aligned(offset, count, iscsilun)) { return -ENOTSUP; } if (!iscsilun->lbp.lbpu) { return 0; } list.lba = offset / iscsilun->block_size; list.num = count / iscsilun->block_size; iscsi_co_init_iscsitask(iscsilun, &iTask); retry: if (iscsi_unmap_task(iscsilun->iscsi, iscsilun->lun, 0, 0, &list, 1, iscsi_co_generic_cb, &iTask) == NULL) { return -ENOMEM; } while (!iTask.complete) { iscsi_set_events(iscsilun); qemu_coroutine_yield(); } if (iTask.task != NULL) { scsi_free_scsi_task(iTask.task); iTask.task = NULL; } if (iTask.do_retry) { iTask.complete = 0; goto retry; } if (iTask.status == SCSI_STATUS_CHECK_CONDITION) { return 0; } if (iTask.status != SCSI_STATUS_GOOD) { return iTask.err_code; } iscsi_allocmap_set_invalid(iscsilun, offset >> BDRV_SECTOR_BITS, count >> BDRV_SECTOR_BITS); return 0; }
1threat
void do_subfmeo (void) { T1 = T0; T0 = ~T0 + xer_ca - 1; if (likely(!((uint32_t)~T1 & ((uint32_t)~T1 ^ (uint32_t)T0) & (1UL << 31)))) { xer_ov = 0; } else { xer_so = 1; xer_ov = 1; } if (likely((uint32_t)T1 != UINT32_MAX)) xer_ca = 1; }
1threat
static int channelmap_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf) { AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; const ChannelMapContext *s = ctx->priv; const int nch_in = av_get_channel_layout_nb_channels(inlink->channel_layout); const int nch_out = s->nch; int ch; uint8_t *source_planes[MAX_CH]; memcpy(source_planes, buf->extended_data, nch_in * sizeof(source_planes[0])); if (nch_out > nch_in) { if (nch_out > FF_ARRAY_ELEMS(buf->data)) { uint8_t **new_extended_data = av_mallocz(nch_out * sizeof(*buf->extended_data)); if (!new_extended_data) { avfilter_unref_buffer(buf); return AVERROR(ENOMEM); } if (buf->extended_data == buf->data) { buf->extended_data = new_extended_data; } else { buf->extended_data = new_extended_data; av_free(buf->extended_data); } } else if (buf->extended_data != buf->data) { av_free(buf->extended_data); buf->extended_data = buf->data; } } for (ch = 0; ch < nch_out; ch++) { buf->extended_data[s->map[ch].out_channel_idx] = source_planes[s->map[ch].in_channel_idx]; } if (buf->data != buf->extended_data) memcpy(buf->data, buf->extended_data, FFMIN(FF_ARRAY_ELEMS(buf->data), nch_out) * sizeof(buf->data[0])); return ff_filter_samples(outlink, buf); }
1threat
How to disable push notification capability in xcode project? : <p>I use a free Apple developer account, so no push notification support. So when I get an existing xcode project and try to run it on my phone, I get "Your development team, "xxx", does not support the Push Notifications capability."</p> <p>But when I go to "Capabilities" tab, I don't see it there to disable (It said "10 capabilities Unavailable"). So I guess it hides them? But the project still require the capabilities somewhere?</p> <p>So how do I disable the push notification capability of the project, so I can run it?</p>
0debug
static int draw_slice(AVFilterLink *inlink, int y0, int h, int slice_dir) { AlphaExtractContext *extract = inlink->dst->priv; AVFilterBufferRef *cur_buf = inlink->cur_buf; AVFilterBufferRef *out_buf = inlink->dst->outputs[0]->out_buf; if (extract->is_packed_rgb) { int x, y; uint8_t *pin, *pout; for (y = y0; y < (y0 + h); y++) { pin = cur_buf->data[0] + y * cur_buf->linesize[0] + extract->rgba_map[A]; pout = out_buf->data[0] + y * out_buf->linesize[0]; for (x = 0; x < out_buf->video->w; x++) { *pout = *pin; pout += 1; pin += 4; } } } else if (cur_buf->linesize[A] == out_buf->linesize[Y]) { const int linesize = cur_buf->linesize[A]; memcpy(out_buf->data[Y] + y0 * linesize, cur_buf->data[A] + y0 * linesize, linesize * h); } else { const int linesize = FFMIN(out_buf->linesize[Y], cur_buf->linesize[A]); int y; for (y = y0; y < (y0 + h); y++) { memcpy(out_buf->data[Y] + y * out_buf->linesize[Y], cur_buf->data[A] + y * cur_buf->linesize[A], linesize); } } return ff_draw_slice(inlink->dst->outputs[0], y0, h, slice_dir); }
1threat
How to use user secrets in a dotnet core test project : <p>I want to store a database connection string for my integration tests as a user secret. My project.json looks like this:</p> <pre><code>{ ... "dependencies": { ... "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0" }, "tools": { "Microsoft.Extensions.SecretManager.Tools": "1.1.0-preview4-final" }, "userSecretsId": "dc5b4f9c-8b0e-4b99-9813-c86ce80c39e6" } </code></pre> <p>I've added the following to the constructor of my test class:</p> <pre><code>IConfigurationBuilder configurationBuilder = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .AddUserSecrets(); </code></pre> <p>However when I run the tests the following exception is thrown when it hits that line:</p> <pre><code>An exception of type 'System.InvalidOperationException' occurred in Microsoft.Extensions.Configuration.UserSecrets.dll but was not handled in user code Additional information: Could not find 'UserSecretsIdAttribute' on assembly 'dotnet-test-nunit, Version=3.4.0.0, Culture=neutral, PublicKeyToken=null'. </code></pre> <p>Have I missed something or is what I'm trying to do not supported?</p>
0debug
static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx) { return ff_vaapi_encode_init(avctx, &vaapi_encode_type_h264); }
1threat
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { H264Context *h = avctx->priv_data; MpegEncContext *s = &h->s; AVFrame *pict = data; int buf_index; s->flags= avctx->flags; s->flags2= avctx->flags2; if (buf_size == 0) { return 0; } if(s->flags&CODEC_FLAG_TRUNCATED){ int next= find_frame_end(h, buf, buf_size); if( ff_combine_frame(&s->parse_context, next, &buf, &buf_size) < 0 ) return buf_size; } if(h->is_avc && !h->got_avcC) { int i, cnt, nalsize; unsigned char *p = avctx->extradata; if(avctx->extradata_size < 7) { av_log(avctx, AV_LOG_ERROR, "avcC too short\n"); return -1; } if(*p != 1) { av_log(avctx, AV_LOG_ERROR, "Unknown avcC version %d\n", *p); return -1; } h->nal_length_size = 2; cnt = *(p+5) & 0x1f; p += 6; for (i = 0; i < cnt; i++) { nalsize = BE_16(p) + 2; if(decode_nal_units(h, p, nalsize) < 0) { av_log(avctx, AV_LOG_ERROR, "Decoding sps %d from avcC failed\n", i); return -1; } p += nalsize; } cnt = *(p++); for (i = 0; i < cnt; i++) { nalsize = BE_16(p) + 2; if(decode_nal_units(h, p, nalsize) != nalsize) { av_log(avctx, AV_LOG_ERROR, "Decoding pps %d from avcC failed\n", i); return -1; } p += nalsize; } h->nal_length_size = ((*(((char*)(avctx->extradata))+4))&0x03)+1; h->got_avcC = 1; } if(!h->is_avc && s->avctx->extradata_size && s->picture_number==0){ if(decode_nal_units(h, s->avctx->extradata, s->avctx->extradata_size) < 0) return -1; } buf_index=decode_nal_units(h, buf, buf_size); if(buf_index < 0) return -1; if(!s->current_picture_ptr){ av_log(h->s.avctx, AV_LOG_DEBUG, "error, NO frame\n"); return -1; } { Picture *out = s->current_picture_ptr; #if 0 *data_size = sizeof(AVFrame); #else Picture *cur = s->current_picture_ptr; Picture *prev = h->delayed_output_pic; int out_idx = 0; int pics = 0; int out_of_order; int cross_idr = 0; int dropped_frame = 0; int i; if(h->sps.bitstream_restriction_flag && s->avctx->has_b_frames < h->sps.num_reorder_frames){ s->avctx->has_b_frames = h->sps.num_reorder_frames; s->low_delay = 0; } while(h->delayed_pic[pics]) pics++; h->delayed_pic[pics++] = cur; if(cur->reference == 0) cur->reference = 1; for(i=0; h->delayed_pic[i]; i++) if(h->delayed_pic[i]->key_frame || h->delayed_pic[i]->poc==0) cross_idr = 1; out = h->delayed_pic[0]; for(i=1; h->delayed_pic[i] && !h->delayed_pic[i]->key_frame; i++) if(h->delayed_pic[i]->poc < out->poc){ out = h->delayed_pic[i]; out_idx = i; } out_of_order = !cross_idr && prev && out->poc < prev->poc; if(prev && pics <= s->avctx->has_b_frames) out = prev; else if((out_of_order && pics-1 == s->avctx->has_b_frames && pics < 15) || (s->low_delay && ((!cross_idr && prev && out->poc > prev->poc + 2) || cur->pict_type == B_TYPE))) { s->low_delay = 0; s->avctx->has_b_frames++; out = prev; } else if(out_of_order) out = prev; if(out_of_order || pics > s->avctx->has_b_frames){ dropped_frame = (out != h->delayed_pic[out_idx]); for(i=out_idx; h->delayed_pic[i]; i++) h->delayed_pic[i] = h->delayed_pic[i+1]; } if(prev == out && !dropped_frame) *data_size = 0; else *data_size = sizeof(AVFrame); if(prev && prev != out && prev->reference == 1) prev->reference = 0; h->delayed_output_pic = out; #endif if(out) *pict= *(AVFrame*)out; else av_log(avctx, AV_LOG_DEBUG, "no picture\n"); } assert(pict->data[0] || !*data_size); ff_print_debug_info(s, pict); #if 0 avctx->frame_number = s->picture_number - 1; #endif return get_consumed_bytes(s, buf_index, buf_size); }
1threat
Find the list of Google Container Registry public images : <p>Where can I find the list of GCR public images? In case of docker images, we can list it in hub.docker.com. But I couldn't find anything like that for GCR.</p>
0debug
duplicate entry: com/android/volley/AuthFailureError.class while compiling project in android studio : <p>I am using external libraries payu money sdk and linkedin-sdk, both uses volley libraries, which while compiling project gives duplicate entry of AuthFailureError.class</p> <p>Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.</p> <blockquote> <p>java.util.zip.ZipException: duplicate entry: com/android/volley/AuthFailureError.class"</p> </blockquote> <p>i have also added following code to exclude module, but still same error</p> <p><code>configurations{ all*.exclude module: 'com.android.volley' }</code></p> <p>please help</p>
0debug
C# Create message box for ComboBox : I can not see the full names of the data in the C # form application because I can not extend the width of the ComboBox due to the design of my screen. Before I make a selection, I want to show it in the ComboBox as shown below. How do I do this in the combo box? [enter image description here][1] [1]: https://i.stack.imgur.com/THivf.png
0debug
static void tcg_out_ld (TCGContext *s, TCGType type, int ret, int arg1, tcg_target_long arg2) { if (type == TCG_TYPE_I32) tcg_out_ldst (s, ret, arg1, arg2, LWZ, LWZX); else tcg_out_ldst (s, ret, arg1, arg2, LD, LDX); }
1threat
How to conditionally require form inputs in angular 4? : <p>I am using template driven forms for adding the task, and there are 2 input fields of type number for estimated mins to complete task, </p> <ul> <li>one field is for estimated number of hrs and</li> <li>another is for estimated minutes to complete the task</li> </ul> <p>since the task estimate can be done either in hours like <strong>1hrs</strong> , or in hours and minutes like <strong>1Hrs 30Mins</strong> , so i want to set attribute <strong>required</strong> to inputs conditionally. So one of the 2 inputs must be set or form validation error will occur if both inputs are empty when submitting form. </p> <p>so far i have done this but validation is not working </p> <pre><code>&lt;form class="add-task" (ngSubmit)="onSubmit(newtask)" #newtask="ngForm"&gt; &lt;div class="estimate-container"&gt; &lt;input type="number" min="0" max="10" id="estimate_hrs" ngModel name="estimate_hrs" mdInput [required]="!estimateMins.valid" placeholder="Estimated Hours" #estimateHrs="ngModel" &gt; &lt;div class="error-msg" *ngIf="!estimateHrs.valid &amp;&amp; !estimateMins.valid"&gt; Please enter estimated hours &lt;/div&gt; &lt;input type="number" min="0" max="60" id="estimate_min" ngModel name="estimate_min" mdInput [required]="!estimateHrs.valid" placeholder="Estimated Minutes" #estimateMins="ngModel" &gt; &lt;div class="error-msg" *ngIf="!estimateMins.valid &amp;&amp; !estimateHrs.valid"&gt; Please enter estimated minutes &lt;/div&gt; &lt;/div&gt; &lt;button type='submit' [disabled]="!newtask.valid" &gt;Submit&lt;/button&gt; &lt;/form&gt; </code></pre>
0debug
static int cpu_sparc_find_by_name(sparc_def_t *cpu_def, const char *cpu_model) { unsigned int i; const sparc_def_t *def = NULL; char *s = strdup(cpu_model); char *featurestr, *name = strtok(s, ","); uint32_t plus_features = 0; uint32_t minus_features = 0; uint64_t iu_version; uint32_t fpu_version, mmu_version, nwindows; for (i = 0; i < ARRAY_SIZE(sparc_defs); i++) { if (strcasecmp(name, sparc_defs[i].name) == 0) { def = &sparc_defs[i]; } } if (!def) { goto error; } memcpy(cpu_def, def, sizeof(*def)); featurestr = strtok(NULL, ","); while (featurestr) { char *val; if (featurestr[0] == '+') { add_flagname_to_bitmaps(featurestr + 1, &plus_features); } else if (featurestr[0] == '-') { add_flagname_to_bitmaps(featurestr + 1, &minus_features); } else if ((val = strchr(featurestr, '='))) { *val = 0; val++; if (!strcmp(featurestr, "iu_version")) { char *err; iu_version = strtoll(val, &err, 0); if (!*val || *err) { fprintf(stderr, "bad numerical value %s\n", val); goto error; } cpu_def->iu_version = iu_version; #ifdef DEBUG_FEATURES fprintf(stderr, "iu_version %" PRIx64 "\n", iu_version); #endif } else if (!strcmp(featurestr, "fpu_version")) { char *err; fpu_version = strtol(val, &err, 0); if (!*val || *err) { fprintf(stderr, "bad numerical value %s\n", val); goto error; } cpu_def->fpu_version = fpu_version; #ifdef DEBUG_FEATURES fprintf(stderr, "fpu_version %x\n", fpu_version); #endif } else if (!strcmp(featurestr, "mmu_version")) { char *err; mmu_version = strtol(val, &err, 0); if (!*val || *err) { fprintf(stderr, "bad numerical value %s\n", val); goto error; } cpu_def->mmu_version = mmu_version; #ifdef DEBUG_FEATURES fprintf(stderr, "mmu_version %x\n", mmu_version); #endif } else if (!strcmp(featurestr, "nwindows")) { char *err; nwindows = strtol(val, &err, 0); if (!*val || *err || nwindows > MAX_NWINDOWS || nwindows < MIN_NWINDOWS) { fprintf(stderr, "bad numerical value %s\n", val); goto error; } cpu_def->nwindows = nwindows; #ifdef DEBUG_FEATURES fprintf(stderr, "nwindows %d\n", nwindows); #endif } else { fprintf(stderr, "unrecognized feature %s\n", featurestr); goto error; } } else { fprintf(stderr, "feature string `%s' not in format " "(+feature|-feature|feature=xyz)\n", featurestr); goto error; } featurestr = strtok(NULL, ","); } cpu_def->features |= plus_features; cpu_def->features &= ~minus_features; #ifdef DEBUG_FEATURES print_features(stderr, fprintf, cpu_def->features, NULL); #endif free(s); return 0; error: free(s); return -1; }
1threat
Python Call a Function With Arguments From a User Input : So this may seem like a duplicate, as there are many posts on this topic. However, I am actually asking for something different. So I would like to call a function from a user input, *but include arguments in the parenthesis.* EG: `def var(value): print(value)` I would like to ask the user for a function, `input("Command: ")`, which should be executed, *with the argument*. `Command: var("Test")` This should print `test`. I have heard this is a bad idea, for security reasons, but as I'm just using this to write HTML, I don't think it's a problem.
0debug
Assignment in lambda : <p>I'm looking at the following (presumably C++14) piece of code</p> <pre><code>auto min_on = [](auto&amp;&amp; f) { return [f=decltype(f)(f)](auto&amp;&amp; arg0, auto&amp;&amp;...args) { // call your function here, using decltype(args)(args) to perfect forward }; } </code></pre> <p>what is the weird assignment in the lambda capture list? I've never seen an assignment in a capture list</p> <pre><code>f=decltype(f)(f) </code></pre> <p>How does this work?</p>
0debug
how to target an element without class or id : <p>how can i target the 5th td with nth of type ? or any other way without using classes or id's </p> <pre><code>&lt;body&gt; &lt;h1&gt;aaaa&lt;/h1&gt; &lt;table&gt; &lt;tr&gt; &lt;td &gt;&lt;/td&gt; &lt;td &gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td &gt;&lt;/td&gt; &lt;td &gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td &gt;&lt;/td&gt; &lt;td &gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; </code></pre>
0debug
static PCIINTxRoute gpex_route_intx_pin_to_irq(void *opaque, int pin) { PCIINTxRoute route; GPEXHost *s = opaque; route.mode = PCI_INTX_ENABLED; route.irq = s->irq_num[pin]; return route; }
1threat
Creating an object without parantheses : Title sound kinda silly but I couldn't find anything that suits better. According to [this site][1] the syntax for creating a Java object is: <JavaType> <variable> = new <JavaObject>(); Though you don't use any parantheses when creating an Array object and instead type brackets which contains the length of each dimension. Example: String[][] stringMatrix = new String[5][10]; What I am wondering is if this syntax is specifically and only for creating an Array object or I can make a custom class whose objects are created in a different way then usual new <JavaObject>(); statement. [1]: https://en.wikibooks.org/wiki/Java_Programming/Keywords/new
0debug
Manually decode OAuth bearer token in c# : <p>In my Web Api 2.2 OWIN based application I have a situation where I manually need to decode the bearer token but I don't know how to do this. This is my startup.cs </p> <pre><code>public class Startup { public static OAuthAuthorizationServerOptions OAuthServerOptions { get; private set; } public static UnityContainer IoC; public void Configuration(IAppBuilder app) { //Set Auth configuration ConfigureOAuth(app); ....and other stuff } public void ConfigureOAuth(IAppBuilder app) { OAuthServerOptions = new OAuthAuthorizationServerOptions() { AllowInsecureHttp = true, TokenEndpointPath = new PathString("/token"), AccessTokenExpireTimeSpan = TimeSpan.FromDays(1), Provider = new AuthProvider(IoC.Resolve&lt;IUserService&gt;(), IoC.Resolve&lt;IAppSettings&gt;()) }; // Token Generation app.UseOAuthAuthorizationServer(OAuthServerOptions); app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions()); } } </code></pre> <p>In my controller Im sending the bearer token as a parameter </p> <pre><code>[RoutePrefix("api/EP")] public class EPController : MasterController { [HttpGet] [AllowAnonymous] [Route("DC")] public async Task&lt;HttpResponseMessage&gt; GetDC(string token) { //Get the claim identity from the token here //Startup.OAuthServerOptions... //..and other stuff } } </code></pre> <p>How to manually decode and get the claims from the token passed as a parameter? </p> <p><strong>NOTE</strong>: I know I can send the token in the header and use [Authorize] and (ClaimsIdentity)User.Identity etc but the question is how to read the token when it's not presented in the header. </p>
0debug
static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res, uint16_t *refcount_table, int64_t refcount_table_size, int64_t l2_offset, int flags) { BDRVQcowState *s = bs->opaque; uint64_t *l2_table, l2_entry; uint64_t next_contiguous_offset = 0; int i, l2_size, nb_csectors, ret; l2_size = s->l2_size * sizeof(uint64_t); l2_table = g_malloc(l2_size); ret = bdrv_pread(bs->file, l2_offset, l2_table, l2_size); if (ret < 0) { fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n"); res->check_errors++; goto fail; } for(i = 0; i < s->l2_size; i++) { l2_entry = be64_to_cpu(l2_table[i]); switch (qcow2_get_cluster_type(l2_entry)) { case QCOW2_CLUSTER_COMPRESSED: if (l2_entry & QCOW_OFLAG_COPIED) { fprintf(stderr, "ERROR: cluster %" PRId64 ": " "copied flag must never be set for compressed " "clusters\n", l2_entry >> s->cluster_bits); l2_entry &= ~QCOW_OFLAG_COPIED; res->corruptions++; } nb_csectors = ((l2_entry >> s->csize_shift) & s->csize_mask) + 1; l2_entry &= s->cluster_offset_mask; ret = inc_refcounts(bs, res, refcount_table, refcount_table_size, l2_entry & ~511, nb_csectors * 512); if (ret < 0) { goto fail; } if (flags & CHECK_FRAG_INFO) { res->bfi.allocated_clusters++; res->bfi.compressed_clusters++; res->bfi.fragmented_clusters++; } break; case QCOW2_CLUSTER_ZERO: if ((l2_entry & L2E_OFFSET_MASK) == 0) { break; } case QCOW2_CLUSTER_NORMAL: { uint64_t offset = l2_entry & L2E_OFFSET_MASK; if (flags & CHECK_FRAG_INFO) { res->bfi.allocated_clusters++; if (next_contiguous_offset && offset != next_contiguous_offset) { res->bfi.fragmented_clusters++; } next_contiguous_offset = offset + s->cluster_size; } ret = inc_refcounts(bs, res, refcount_table, refcount_table_size, offset, s->cluster_size); if (ret < 0) { goto fail; } if (offset_into_cluster(s, offset)) { fprintf(stderr, "ERROR offset=%" PRIx64 ": Cluster is not " "properly aligned; L2 entry corrupted.\n", offset); res->corruptions++; } break; } case QCOW2_CLUSTER_UNALLOCATED: break; default: abort(); } } g_free(l2_table); return 0; fail: g_free(l2_table); return ret; }
1threat
Java Map to JSON to Typescript Map : <p>on my server side I have a Java object that contains a HashMap. I want to serialize it to JSON, return it to my Angular2 client and use it as a Map/Dictionary there. </p> <p>Here's the class:</p> <pre><code>public class FileUploadResult { String timestamp; String message; String status; HashMap&lt;String, String&gt; parameters; public FileUploadResult(String status, String message, String timestamp, HashMap parameters) { this.status = status; this.message = message; this.timestamp = timestamp; this.parameters = parameters; } </code></pre> <p>}</p> <p>Here's the JSON that I receive on the client side:</p> <pre><code>{"timestamp":"","message":"Test","status":"1","parameters":{"myKey":"Value","mySecondKey":"Another Value"}} </code></pre> <p>Here's my receiving Angular2 http call:</p> <pre><code>this.http.post(this.uploadURL, formData).map((res:Response) =&gt; res.json() as FileUploadResult).catch(this.handleError); </code></pre> <p>FileUploadResult on the client looks like this:</p> <pre><code>export class FileUploadResult { status: string; timestamp: string; message: string; parameters: Map&lt;string, string&gt;; constructor() { this.parameters = new Map&lt;string, string&gt;(); } addParameter(key: string, value: string) { this.parameters.set(key, value); } getParameters() { return this.parameters; } } </code></pre> <p>By using the "as FileUploadResult" in the http.map call, I expected to get an object on where I can call <code>result.getParameters().get("myKey")</code>. But that's not happening. I get an unspecified object where the only call that works is <code>result.parameters.myKey</code>. Is there a way to achieve what I want and to cast the JSON object to the FileUploadResult including the Angular2 map?</p>
0debug
I keep getting the same answer, no matter what I put in : <p>We're doing an assignment in my computer science class that requires us to find the future value of an investment after "n" number of years that the user inputs. It's written in C++. This is the code as I have it now:</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main() { int P=1000; int i=0.0275; int FV; int n; cout &lt;&lt; "enter number of years:"&lt;&lt; endl; cin &gt;&gt; n; cout &lt;&lt; "the future value is:"&lt;&lt; endl; FV = P*(1+(i*n)); cout &lt;&lt; FV &lt;&lt; endl; return 0; } </code></pre> <p>I keep ending up with an answer of 1000 no matter what "n" I input. Can someone tell me what's wrong with the code?</p>
0debug
opts_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp) { OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v); const QemuOpt *opt; int64_t val; char *endptr; opt = lookup_scalar(ov, name, errp); if (!opt) { return; } val = strtosz_suffix(opt->str ? opt->str : "", &endptr, STRTOSZ_DEFSUFFIX_B); if (val != -1 && *endptr == '\0') { *obj = val; processed(ov, name); return; } error_set(errp, QERR_INVALID_PARAMETER_VALUE, opt->name, "a size value representible as a non-negative int64"); }
1threat
angular 5 template forms detect change of form validity status : <p>are <a href="https://angular.io/guide/reactive-forms#observe-control-changes" rel="noreferrer">reactive forms</a> the way to go in order to have a component that can listen for changes in the validity status of the form it contains and execute some compoment's methods?</p> <p>It is easy to disable the submit button in the template using templateRef like <code>[disabled]="#myForm.invalid"</code>, but this does not involve the component's logic.</p> <p>Looking at <a href="https://angular.io/guide/forms" rel="noreferrer">template forms' doc</a> I did not find a way </p>
0debug
@SafeVarargs on interface method : <p>In this code,</p> <pre><code>package com.example; interface CollectorIF&lt;T&gt; { // @SafeVarargs // Error: @SafeVarargs annotation cannot be applied to non-final instance method addAll void addAll(T... values); } class Collector&lt;T&gt; implements CollectorIF&lt;T&gt; { @SafeVarargs public final void addAll(T... values) { } } class Component&lt;T&gt; { public void compute(T value) { Collector&lt;T&gt; col1 = new Collector&lt;&gt;(); col1.addAll(value); // No warning CollectorIF&lt;T&gt; col2 = new Collector&lt;&gt;(); col2.addAll(value); // Type safety: A generic array of T is created for a varargs parameter } } </code></pre> <p>the <code>Type safety: A generic array of T is created for a varargs parameter</code> warning does not occur when using a <code>Collector&lt;T&gt;</code> reference, due to the <code>@SafeVarargs</code> annotation.</p> <p>However, the warning <strong>does</strong> occur when accessing the method through the <code>CollectorIF&lt;T&gt;</code> interface. On interface methods, <code>@SafeVarargs</code> is not valid (which is obvious since the compiler can not perform any checks on the usage of the parameter in the method body).</p> <p>How can the warning be avoided when accessing the method through an interface?</p>
0debug
In Tensorflow, what is the difference between a tensor that has a type ending in _ref and a tensor that does not? : <p>The docs say:</p> <blockquote> <p>In addition, variants of these types with the _ref suffix are defined for reference-typed tensors.</p> </blockquote> <p>What exactly does this mean? What are reference-typed tensors and how do they differ from standard ones?</p>
0debug
enum AVCodecID ff_guess_image2_codec(const char *filename) { return av_str2id(img_tags, filename); }
1threat
How to change the label from back button in Ionic 2? : <p>With the code:</p> <pre><code>&lt;ion-navbar *navbar&gt; &lt;/ion-navbar&gt; </code></pre> <p>the back button is enabled. But I need to customize it (the icon or the label). Is it possible? Can't find anything in the docs/api.</p>
0debug