problem
stringlengths
26
131k
labels
class label
2 classes
Arrow functions best practice? : <p>Is it best practice to use arrow functions, when the function takes one parameter?</p> <p>I was told to use something like this</p> <pre><code>const volumeOfSphere = diameter =&gt; (1/6) * Math.PI * diameter * diameter * diameter; </code></pre> <p>Rather than this</p> <pre><code>const volumeOfSphere = (diameter) =&gt; { return (1/6) * Math.PI * diameter * diameter * diameter; }; </code></pre> <p>I know with time the first example will pop out to me as a function when skimming code, but the second example is more easily identifiable as a function to me. </p>
0debug
What is the logic behind Python's and operator? : <p>From Python:</p> <pre><code>&gt;&gt;&gt; 1 and 2 2 &gt;&gt;&gt; 1 and 2 and 3 3 &gt;&gt;&gt; 3 and 2 and 1 1 &gt;&gt;&gt; 'a' and 'b' 'b' </code></pre> <p>Why Python returns these result? What is the logic for that when dealing with pure numbers or strings?</p>
0debug
static void *qemu_tcg_rr_cpu_thread_fn(void *arg) { CPUState *cpu = arg; rcu_register_thread(); qemu_mutex_lock_iothread(); qemu_thread_get_self(cpu->thread); CPU_FOREACH(cpu) { cpu->thread_id = qemu_get_thread_id(); cpu->created = true; cpu->can_do_io = 1; } qemu_cond_signal(&qemu_cpu_cond); while (first_cpu->stopped) { qemu_cond_wait(first_cpu->halt_cond, &qemu_global_mutex); CPU_FOREACH(cpu) { current_cpu = cpu; qemu_wait_io_event_common(cpu); } } start_tcg_kick_timer(); cpu = first_cpu; cpu->exit_request = 1; while (1) { qemu_account_warp_timer(); if (!cpu) { cpu = first_cpu; } while (cpu && !cpu->queued_work_first && !cpu->exit_request) { atomic_mb_set(&tcg_current_rr_cpu, cpu); current_cpu = cpu; qemu_clock_enable(QEMU_CLOCK_VIRTUAL, (cpu->singlestep_enabled & SSTEP_NOTIMER) == 0); if (cpu_can_run(cpu)) { int r; r = tcg_cpu_exec(cpu); if (r == EXCP_DEBUG) { cpu_handle_guest_debug(cpu); break; } else if (r == EXCP_ATOMIC) { qemu_mutex_unlock_iothread(); cpu_exec_step_atomic(cpu); qemu_mutex_lock_iothread(); break; } } else if (cpu->stop) { if (cpu->unplug) { cpu = CPU_NEXT(cpu); } break; } cpu = CPU_NEXT(cpu); } atomic_set(&tcg_current_rr_cpu, NULL); if (cpu && cpu->exit_request) { atomic_mb_set(&cpu->exit_request, 0); } handle_icount_deadline(); qemu_tcg_wait_io_event(cpu ? cpu : QTAILQ_FIRST(&cpus)); deal_with_unplugged_cpus(); } return NULL; }
1threat
How to calculate differences between consecutive rows in pandas data frame? : <p>I've got a data frame, <code>df</code>, with three columns: <code>count_a</code>, <code>count_b</code> and <code>date</code>; the counts are floats, and the dates are consecutive days in 2015.</p> <p>I'm trying to figure out the difference between each day's counts in both the <code>count_a</code> and <code>count_b</code> columns — meaning, I'm trying to calculate the difference between each row and the preceding row for both of those columns. I've set the date as the index, but am having trouble figuring out how to do this; there were a couple of hints about using <code>pd.Series</code> and <code>pd.DataFrame.diff</code> but I haven't had any luck finding an applicable answer or set of instructions. </p> <p>I'm a bit stuck, and would appreciate some guidance here. </p> <p>Here's what my data frame looks like: </p> <pre><code>df=pd.Dataframe({'count_a': {Timestamp('2015-01-01 00:00:00'): 34175.0, Timestamp('2015-01-02 00:00:00'): 72640.0, Timestamp('2015-01-03 00:00:00'): 109354.0, Timestamp('2015-01-04 00:00:00'): 144491.0, Timestamp('2015-01-05 00:00:00'): 180355.0, Timestamp('2015-01-06 00:00:00'): 214615.0, Timestamp('2015-01-07 00:00:00'): 250096.0, Timestamp('2015-01-08 00:00:00'): 287880.0, Timestamp('2015-01-09 00:00:00'): 332528.0, Timestamp('2015-01-10 00:00:00'): 381460.0, Timestamp('2015-01-11 00:00:00'): 422981.0, Timestamp('2015-01-12 00:00:00'): 463539.0, Timestamp('2015-01-13 00:00:00'): 505395.0, Timestamp('2015-01-14 00:00:00'): 549027.0, Timestamp('2015-01-15 00:00:00'): 595377.0, Timestamp('2015-01-16 00:00:00'): 649043.0, Timestamp('2015-01-17 00:00:00'): 707727.0, Timestamp('2015-01-18 00:00:00'): 761287.0, Timestamp('2015-01-19 00:00:00'): 814372.0, Timestamp('2015-01-20 00:00:00'): 867096.0, Timestamp('2015-01-21 00:00:00'): 920838.0, Timestamp('2015-01-22 00:00:00'): 983405.0, Timestamp('2015-01-23 00:00:00'): 1067243.0, Timestamp('2015-01-24 00:00:00'): 1164421.0, Timestamp('2015-01-25 00:00:00'): 1252178.0, Timestamp('2015-01-26 00:00:00'): 1341484.0, Timestamp('2015-01-27 00:00:00'): 1427600.0, Timestamp('2015-01-28 00:00:00'): 1511549.0, Timestamp('2015-01-29 00:00:00'): 1594846.0, Timestamp('2015-01-30 00:00:00'): 1694226.0, Timestamp('2015-01-31 00:00:00'): 1806727.0, Timestamp('2015-02-01 00:00:00'): 1899880.0, Timestamp('2015-02-02 00:00:00'): 1987978.0, Timestamp('2015-02-03 00:00:00'): 2080338.0, Timestamp('2015-02-04 00:00:00'): 2175775.0, Timestamp('2015-02-05 00:00:00'): 2279525.0, Timestamp('2015-02-06 00:00:00'): 2403306.0, Timestamp('2015-02-07 00:00:00'): 2545696.0, Timestamp('2015-02-08 00:00:00'): 2672464.0, Timestamp('2015-02-09 00:00:00'): 2794788.0}, 'count_b': {Timestamp('2015-01-01 00:00:00'): nan, Timestamp('2015-01-02 00:00:00'): nan, Timestamp('2015-01-03 00:00:00'): nan, Timestamp('2015-01-04 00:00:00'): nan, Timestamp('2015-01-05 00:00:00'): nan, Timestamp('2015-01-06 00:00:00'): nan, Timestamp('2015-01-07 00:00:00'): nan, Timestamp('2015-01-08 00:00:00'): nan, Timestamp('2015-01-09 00:00:00'): nan, Timestamp('2015-01-10 00:00:00'): nan, Timestamp('2015-01-11 00:00:00'): nan, Timestamp('2015-01-12 00:00:00'): nan, Timestamp('2015-01-13 00:00:00'): nan, Timestamp('2015-01-14 00:00:00'): nan, Timestamp('2015-01-15 00:00:00'): nan, Timestamp('2015-01-16 00:00:00'): nan, Timestamp('2015-01-17 00:00:00'): nan, Timestamp('2015-01-18 00:00:00'): nan, Timestamp('2015-01-19 00:00:00'): nan, Timestamp('2015-01-20 00:00:00'): nan, Timestamp('2015-01-21 00:00:00'): nan, Timestamp('2015-01-22 00:00:00'): nan, Timestamp('2015-01-23 00:00:00'): nan, Timestamp('2015-01-24 00:00:00'): 71.0, Timestamp('2015-01-25 00:00:00'): 150.0, Timestamp('2015-01-26 00:00:00'): 236.0, Timestamp('2015-01-27 00:00:00'): 345.0, Timestamp('2015-01-28 00:00:00'): 1239.0, Timestamp('2015-01-29 00:00:00'): 2228.0, Timestamp('2015-01-30 00:00:00'): 7094.0, Timestamp('2015-01-31 00:00:00'): 16593.0, Timestamp('2015-02-01 00:00:00'): 27190.0, Timestamp('2015-02-02 00:00:00'): 37519.0, Timestamp('2015-02-03 00:00:00'): 49003.0, Timestamp('2015-02-04 00:00:00'): 63323.0, Timestamp('2015-02-05 00:00:00'): 79846.0, Timestamp('2015-02-06 00:00:00'): 101568.0, Timestamp('2015-02-07 00:00:00'): 127120.0, Timestamp('2015-02-08 00:00:00'): 149955.0, Timestamp('2015-02-09 00:00:00'): 171440.0}}) </code></pre>
0debug
Array Reverse is not working for me ... : <p>Consider the following code (React JS code):</p> <pre><code> poll() { var self = this; var url = "//" + location.hostname + "/api/v1/eve/history/historical-data/" + this.state.itemId + '/' + this.state.regionId + '/40'; $.get(url, function(result) { console.log(result.data, result.data.reverse()); self.setState({ error: null, historicalData: result.data.reverse(), isLoading: false }); }).fail(function(response) { self.setState({ error: 'Could not fetch average price data. Looks like something went wrong.', }); }); } </code></pre> <p>Notice the console.log. Lets see an image:</p> <p><a href="https://i.stack.imgur.com/yWnRm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yWnRm.png" alt="enter image description here"></a></p> <p>Last I checked, reverse should have reversed the order of the array. Yet it doesn't.</p> <p>Am I <a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse" rel="noreferrer">Using this wrong (official MDN Docs)</a>? Why isn't reverse working?</p>
0debug
SwipeRefreshLayout intercepts with ViewPager : <p>I have a ViewPager wrapped inside a SwipeRefreshLayout. Sometimes, when I swipe to the left/right the SRL get's triggered. This mostly happens when I'm at the top of my fragment. </p> <p>How do I solve this? Do I need to listen to some kind of event in order to disable the SRL during a certain time? I haven't really found anything about it so I doubt this is an actual bug by Google but rather am I implementing something incorrectly? Any ideas on this?</p> <p>That's my layout:</p> <pre><code>&lt;android.support.v4.widget.SwipeRefreshLayout android:id="@+id/mainSwipeContainer" android:layout_width="wrap_content" android:layout_height="match_parent"&gt; &lt;android.support.v4.view.ViewPager android:id="@+id/mainViewPager" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; &lt;/android.support.v4.widget.SwipeRefreshLayout&gt; </code></pre> <p>Thanks! Let me know if I'm missing out any information. </p>
0debug
VS Code Key Binding for quick switch between terminal screens? : <p>I'm trying to figure out if there is a way to set up a key binding to allow a quick switch between the terminal windows I have open in the built in terminal rather than having to click on the drop down selector each time. Does anyone know the command for this when making a personal key binding or where I can see a list of all the possible commands for VSC? Thank you in advance!</p>
0debug
Huge white gap in header when slimming page to mobile view : <p>If you go to this page (<a href="https://www.comparestonehengetours.com/" rel="nofollow noreferrer">https://www.comparestonehengetours.com/</a>) in Mobile or Tablet View the logo has loads of white space on top of it. Is there any way to remove all the white space so it just shows the logo nicely?</p> <p>I have attached an image to help explain better what I mean. </p> <p>Thanks, Chris <a href="https://i.stack.imgur.com/IRViQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IRViQ.jpg" alt="Mobile View"></a></p>
0debug
how to hide the path in website url using php : I have no idea of url coding please help me out. To Complete the stackoverflow validation i am just writing some random code, please ignore this. RewriteEngine On RewriteCond %{HTTP_HOST} ^www.yourdomain.com RewriteRule (.*) http://yourdomain.com/$1 [R=301,L] RewriteEngine On RewriteRule ^([a-zA-Z0-9_-]+)$ users.php?user=$1 RewriteRule ^([a-zA-Z0-9_-]+)/$ users.php?user=$1 RewriteEngine On RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)$ users.php?user=$1&page=$2 RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)/$ users.php?user=$1&page=$2
0debug
def answer(L,R): if (2 * L <= R): return (L ,2*L) else: return (-1)
0debug
Mysql (MariaDB 10.0.29): Set root password, but still can login without asking password? : <p>I want to secure mysql by setting root password. I reset root password successfully:</p> <pre><code>MariaDB [(none)]&gt; select Host, User, Password from mysql.user; +-----------+------+-------------------------------------------+ | Host | User | Password | +-----------+------+-------------------------------------------+ | localhost | root | *58319282EAB9E38D49CA25844B73DA62C80C2ABC | +-----------+------+-------------------------------------------+ 1 row in set (0.00 sec) </code></pre> <p>But, after flush privileges, restart Mysql, I can still login mysql (on local host) without typing password. </p> <pre><code>root@myhost:/# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 10 Server version: 10.0.29-MariaDB SLE 12 SP1 package Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]&gt; </code></pre> <p>How can I force mysql asking password when connect ? Thanks !</p>
0debug
Your app uses the “prefs:root=” non public URL scheme. Best plan to update old code? : <p>so I posted previously about this issue <a href="https://stackoverflow.com/questions/53755550/ios-app-store-rejection-your-app-uses-the-prefsroot-non-public-url-scheme?noredirect=1#comment94365312_53755550">here.</a></p> <p>As you can read I was rejected.</p> <p>My question is how do I update this code to use openSettingsURLString instead of UIApplication.shared.openURL</p> <p>After doing some asking and some research I found out I have to change this:</p> <pre><code>static func openSettingsAlert(_ title: String, message: String, settingsURL: String) -&gt; UIAlertController { let alertController = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert) let settingsAction = UIAlertAction(title: "Settings", style: .default) { (_) -&gt; Void in let settingsURL = URL(string: settingsURL) if let url = settingsURL { DispatchQueue.main.async(execute: { UIApplication.shared.openURL(url) }) } } let cancelAction = UIAlertAction(title: "Cancel", style: .default, handler: nil) alertController.addAction(cancelAction) alertController.addAction(settingsAction) return alertController } </code></pre> <p>into code that uses <a href="https://developer.apple.com/documentation/uikit/uiapplication/1623042-opensettingsurlstring" rel="nofollow noreferrer">this</a></p> <p>But I'm so confused because I can't find that class anywhere, and if it's a class why is isn't the class capitalized?</p> <p>How can I use it in the code snippet above.</p> <p>I think it is a subclass of String, but I have no idea where to find this, or how to incorporate the change into the existing code safely.</p> <p>Very confused on this and thank you for any insights.</p>
0debug
static int cdxl_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt) { CDXLVideoContext *c = avctx->priv_data; AVFrame * const p = data; int ret, w, h, encoding, aligned_width, buf_size = pkt->size; const uint8_t *buf = pkt->data; if (buf_size < 32) return AVERROR_INVALIDDATA; encoding = buf[1] & 7; c->format = buf[1] & 0xE0; w = AV_RB16(&buf[14]); h = AV_RB16(&buf[16]); c->bpp = buf[19]; c->palette_size = AV_RB16(&buf[20]); c->palette = buf + 32; c->video = c->palette + c->palette_size; c->video_size = buf_size - c->palette_size - 32; if (c->palette_size > 512) return AVERROR_INVALIDDATA; if (buf_size < c->palette_size + 32) return AVERROR_INVALIDDATA; if (c->bpp < 1) return AVERROR_INVALIDDATA; if (c->format != BIT_PLANAR && c->format != BIT_LINE && c->format != CHUNKY) { avpriv_request_sample(avctx, "Pixel format 0x%0x", c->format); return AVERROR_PATCHWELCOME; } if ((ret = ff_set_dimensions(avctx, w, h)) < 0) return ret; if (c->format == CHUNKY) aligned_width = avctx->width; else aligned_width = FFALIGN(c->avctx->width, 16); c->padded_bits = aligned_width - c->avctx->width; if (c->video_size < aligned_width * avctx->height * c->bpp / 8) return AVERROR_INVALIDDATA; if (!encoding && c->palette_size && c->bpp <= 8) { avctx->pix_fmt = AV_PIX_FMT_PAL8; } else if (encoding == 1 && (c->bpp == 6 || c->bpp == 8)) { if (c->palette_size != (1 << (c->bpp - 1))) return AVERROR_INVALIDDATA; avctx->pix_fmt = AV_PIX_FMT_BGR24; } else if (!encoding && c->bpp == 24 && c->format == CHUNKY && !c->palette_size) { avctx->pix_fmt = AV_PIX_FMT_RGB24; } else { avpriv_request_sample(avctx, "Encoding %d, bpp %d and format 0x%x", encoding, c->bpp, c->format); return AVERROR_PATCHWELCOME; } if ((ret = ff_get_buffer(avctx, p, 0)) < 0) return ret; p->pict_type = AV_PICTURE_TYPE_I; if (encoding) { av_fast_padded_malloc(&c->new_video, &c->new_video_size, h * w + AV_INPUT_BUFFER_PADDING_SIZE); if (!c->new_video) return AVERROR(ENOMEM); if (c->bpp == 8) cdxl_decode_ham8(c, p); else cdxl_decode_ham6(c, p); } else if (avctx->pix_fmt == AV_PIX_FMT_PAL8) { cdxl_decode_rgb(c, p); } else { cdxl_decode_raw(c, p); } *got_frame = 1; return buf_size; }
1threat
How to send an notification 15 days after user opens the app for the first time : <p>Hey is there anyway to send an notification every 15 day after the first time user opens the app ? Thanks in advance</p>
0debug
opening image file on c++ , PNG , JPEG : <p>I have tried to open bg.png file , but didn't work. There is no error , but nothing appears. Help Me!</p> <pre><code>int main() { initwindow(600,600,"GAME"); ifstream image("bg.png"); getimage(50, 50 , 450 , 450 , image); putimage(50,50,image,COPY_PUT); system("pause"); } </code></pre>
0debug
Array Sum Of All Elements? : I have an Array A with size N. I want to make a new array of size N*N such that my new Array B will be as follow with Time Complexity less than O(n^2): For A[0..N-1] , B= {A[0]+A[1], A[0]+A[2], ……., A[1]+A[0], A[1]+A[2], ……., A[N-1]+A[0], A[N-1]+A[1],..., A[N-1]+A[N-1]}. Example: A={1,2} The sequence B is { A1+A1, A1+A2, A2+A1, A2+A2 } = {2,3,3,4}.
0debug
Angular 2 New Router: Change / Set Query Params : <p>I have a component registered at <code>/contacts</code>, which displays a list of contacts. I've added an <code>&lt;input [value]="searchString"&gt;</code> for filtering the displayed list.</p> <hr> <p>Now I'd like to display the <code>searchString</code> within the URL in form of a Query Param. (Using the New Router 3.0.0 RC2)</p> <p>The official docs ( <a href="https://angular.io/docs/ts/latest/guide/router.html#!#query-parameters" rel="noreferrer">https://angular.io/docs/ts/latest/guide/router.html#!#query-parameters</a> ) show how to use <code>router.navigate</code> for changing the <code>queryParams</code>. But this seems awkward, because I just want to change the <code>queryParams</code> without having to know which route I'm currently at: <code>router.navigate(['/contacts'], {queryParams:{foo:42}})</code></p> <p>(I know that it doesn't reload the component if I'm just changing the <code>queryParams</code>, but still this doesn't feel right to write)</p> <hr> <p>After some attempts I figured out that <code>router.navigate([], {queryParams:{foo:42}})</code> works. This feels way better.</p> <p>But I'm still not sure if that's the right way. Or if I missed some method for this.</p> <hr> <p>How do you change your <code>queryParams</code>?</p>
0debug
static bool bdrv_drain_recurse(BlockDriverState *bs) { BdrvChild *child; bool waited; waited = BDRV_POLL_WHILE(bs, atomic_read(&bs->in_flight) > 0); if (bs->drv && bs->drv->bdrv_drain) { bs->drv->bdrv_drain(bs); } QLIST_FOREACH(child, &bs->children, next) { waited |= bdrv_drain_recurse(child->bs); } return waited; }
1threat
get responseText in ajax : <p>I just want to get ajax feedback</p> <pre><code>var result = $.ajax({ url : 'linkAPI', type : 'get', dataType: 'JSON' }); console.log(result); </code></pre> <p>and only responseTEXT appears.</p> <pre><code>Console.log(result.responseText); </code></pre> <p>// undefined</p>
0debug
Custom Card Shape Flutter SDK : <p>I just started learning Flutter and I have developed an app with GridView. GridView items are Card. Default card shape is Rectangle with a radius of 4.</p> <p>I know there is shape property for Card Widget and it takes ShapeBorder class. But I am unable to find how to use ShapeBorder class and customize my cards in GridView.</p> <p>Thanks in Advance.</p>
0debug
.toggle is not a function : <p>In my website I have a lot of buttons. When the page loads, I need the first button to be clicked.</p> <p>I tried getting the first button and then using the function .toggle('click').</p> <p>var $btn = $('.btn-personalizar-tamanho')[0]; if($btn != undefined) $btn.toggle('click');</p> <p>The console says .toggle it's not a function.</p>
0debug
static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *sc) { const struct MpegEncContext *s = avctx->priv_data; AVDXVAContext *ctx = avctx->hwaccel_context; struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; const int is_field = s->picture_structure != PICT_FRAME; const unsigned mb_count = s->mb_width * (s->mb_height >> is_field); void *dxva_data_ptr; uint8_t *dxva_data, *current, *end; unsigned dxva_size; unsigned i; unsigned type; #if CONFIG_D3D11VA if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { type = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM; if (FAILED(ID3D11VideoContext_GetDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, type, &dxva_size, &dxva_data_ptr))) return -1; } #endif #if CONFIG_DXVA2 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) { type = DXVA2_BitStreamDateBufferType; if (FAILED(IDirectXVideoDecoder_GetBuffer(DXVA2_CONTEXT(ctx)->decoder, type, &dxva_data_ptr, &dxva_size))) return -1; } #endif dxva_data = dxva_data_ptr; current = dxva_data; end = dxva_data + dxva_size; for (i = 0; i < ctx_pic->slice_count; i++) { DXVA_SliceInfo *slice = &ctx_pic->slice[i]; unsigned position = slice->dwSliceDataLocation; unsigned size = slice->dwSliceBitsInBuffer / 8; if (size > end - current) { av_log(avctx, AV_LOG_ERROR, "Failed to build bitstream"); break; } slice->dwSliceDataLocation = current - dxva_data; if (i < ctx_pic->slice_count - 1) slice->wNumberMBsInSlice = slice[1].wNumberMBsInSlice - slice[0].wNumberMBsInSlice; else slice->wNumberMBsInSlice = mb_count - slice[0].wNumberMBsInSlice; memcpy(current, &ctx_pic->bitstream[position], size); current += size; } #if CONFIG_D3D11VA if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) if (FAILED(ID3D11VideoContext_ReleaseDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, type))) return -1; #endif #if CONFIG_DXVA2 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) if (FAILED(IDirectXVideoDecoder_ReleaseBuffer(DXVA2_CONTEXT(ctx)->decoder, type))) return -1; #endif if (i < ctx_pic->slice_count) return -1; #if CONFIG_D3D11VA if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = bs; memset(dsc11, 0, sizeof(*dsc11)); dsc11->BufferType = type; dsc11->DataSize = current - dxva_data; dsc11->NumMBsInBuffer = mb_count; type = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL; } #endif #if CONFIG_DXVA2 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) { DXVA2_DecodeBufferDesc *dsc2 = bs; memset(dsc2, 0, sizeof(*dsc2)); dsc2->CompressedBufferType = type; dsc2->DataSize = current - dxva_data; dsc2->NumMBsInBuffer = mb_count; type = DXVA2_SliceControlBufferType; } #endif return ff_dxva2_commit_buffer(avctx, ctx, sc, type, ctx_pic->slice, ctx_pic->slice_count * sizeof(*ctx_pic->slice), mb_count); }
1threat
Creating multiple bundles using angular-cli webpack : <p>When i build the project using angular-cli, it bundles all project files into one big main bundle.</p> <p>I have used lazy routing in the application and i can navigate fine once application loads up.</p> <p>Is there a way in which main bundle is divided into multiple files based upon lazy loaded routes modules?</p> <p>below is the configuration in <code>angular-cli.json</code></p> <pre><code> { "project": { "version": "1.0.0-beta.15", "name": "maddy-test-project" }, "apps": [ { "root": "src", "outDir": "dist", "assets": "styles/content", "index": "default.htm", "main": "main.ts", "test": "test.ts", "tsconfig": "tsconfig.json", "prefix": "", "mobile": false, "styles": [ "styles.less" ], "scripts": [ "styles/wfa-myriad-pro-typekit.js" ], "environments": { "source": "environments/environment.ts", "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } } ], "addons": [], "packages": [], "e2e": { "protractor": { "config": "./protractor.conf.js" } }, "test": { "karma": { "config": "./karma.conf.js" } }, "defaults": { "styleExt": "less", "prefixInterfaces": false } } </code></pre> <p>below is package.json</p> <pre><code>{ "name": "maddy-test-project", "version": "0.0.1", "license": "MIT", "angular-cli": {}, "scripts": { "start": "ng serve", "lint": "tslint \"src/**/*.ts\"", "test": "ng test", "pree2e": "webdriver-manager update", "e2e": "protractor" }, "private": true, "dependencies": { "@angular/common": "2.0.0", "@angular/compiler": "2.0.0", "@angular/core": "2.0.0", "@angular/forms": "2.0.0", "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", "@angular/router": "3.0.0", "d3": "^4.2.3", "jquery": "^3.1.0", "lodash": "^4.15.0", "moment": "^2.15.0", "core-js": "^2.4.1", "rxjs": "5.0.0-beta.12", "toastr": "^2.1.2", "ts-helpers": "^1.1.1", "zone.js": "^0.6.23", "bootstrap-daterangepicker": "^2.1.24" }, "devDependencies": { "@types/d3": "^3.5.35", "@types/google-maps": "^3.1.27", "@types/jasmine": "^2.2.30", "@types/jquery": "^1.10.31", "@types/lodash": "^4.14.34", "@types/toastr": "^2.1.29", "angular-cli": "1.0.0-beta.15", "codelyzer": "~0.0.26", "jasmine-core": "2.4.1", "jasmine-spec-reporter": "2.5.0", "karma": "1.2.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", "karma-remap-istanbul": "^0.2.1", "protractor": "4.0.5", "ts-node": "1.2.1", "tslint": "3.13.0", "typescript": "2.0.2" } } </code></pre> <p>Thanks in advance!!</p>
0debug
static int unin_main_pci_host_init(PCIDevice *d) { pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE); pci_config_set_device_id(d->config, PCI_DEVICE_ID_APPLE_UNI_N_PCI); d->config[0x08] = 0x00; pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); d->config[0x0C] = 0x08; d->config[0x0D] = 0x10; d->config[0x34] = 0x00; return 0; }
1threat
static int xan_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { XanContext *s = avctx->priv_data; AVPaletteControl *palette_control = avctx->palctrl; int keyframe = 0; if (palette_control->palette_changed) { xan_wc3_build_palette(s, palette_control->palette); if (s->avctx->pix_fmt != PIX_FMT_PAL8) palette_control->palette_changed = 0; keyframe = 1; } if (avctx->get_buffer(avctx, &s->current_frame)) { av_log(s->avctx, AV_LOG_ERROR, " Xan Video: get_buffer() failed\n"); return -1; } s->current_frame.reference = 3; s->buf = buf; s->size = buf_size; if (avctx->codec->id == CODEC_ID_XAN_WC3) xan_wc3_decode_frame(s); else if (avctx->codec->id == CODEC_ID_XAN_WC4) xan_wc4_decode_frame(s); if (s->last_frame.data[0]) avctx->release_buffer(avctx, &s->last_frame); s->last_frame = s->current_frame; *data_size = sizeof(AVFrame); *(AVFrame*)data = s->current_frame; return buf_size; }
1threat
static void apply_loop_filter(Vp3DecodeContext *s) { int x, y, plane; int width, height; int fragment; int stride; unsigned char *plane_data; int bounding_values_array[256]; int *bounding_values= bounding_values_array+127; int filter_limit; for (x = 63; x >= 0; x--) { if (vp31_ac_scale_factor[x] >= s->quality_index) break; } filter_limit = vp31_filter_limit_values[s->quality_index]; memset(bounding_values_array, 0, 256 * sizeof(int)); for (x = 0; x < filter_limit; x++) { bounding_values[-x - filter_limit] = -filter_limit + x; bounding_values[-x] = -x; bounding_values[x] = x; bounding_values[x + filter_limit] = filter_limit - x; } for (plane = 0; plane < 3; plane++) { if (plane == 0) { fragment = 0; width = s->fragment_width; height = s->fragment_height; stride = s->current_frame.linesize[0]; plane_data = s->current_frame.data[0]; } else if (plane == 1) { fragment = s->u_fragment_start; width = s->fragment_width / 2; height = s->fragment_height / 2; stride = s->current_frame.linesize[1]; plane_data = s->current_frame.data[1]; } else { fragment = s->v_fragment_start; width = s->fragment_width / 2; height = s->fragment_height / 2; stride = s->current_frame.linesize[2]; plane_data = s->current_frame.data[2]; } for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { START_TIMER if ((x > 0) && (s->all_fragments[fragment].coding_method != MODE_COPY)) { horizontal_filter( plane_data + s->all_fragments[fragment].first_pixel - 7*stride, stride, bounding_values); } if ((y > 0) && (s->all_fragments[fragment].coding_method != MODE_COPY)) { vertical_filter( plane_data + s->all_fragments[fragment].first_pixel + stride, stride, bounding_values); } if ((x < width - 1) && (s->all_fragments[fragment].coding_method != MODE_COPY) && (s->all_fragments[fragment + 1].coding_method == MODE_COPY)) { horizontal_filter( plane_data + s->all_fragments[fragment + 1].first_pixel - 7*stride, stride, bounding_values); } if ((y < height - 1) && (s->all_fragments[fragment].coding_method != MODE_COPY) && (s->all_fragments[fragment + width].coding_method == MODE_COPY)) { vertical_filter( plane_data + s->all_fragments[fragment + width].first_pixel + stride, stride, bounding_values); } fragment++; STOP_TIMER("loop filter") } } } }
1threat
Get the id of the clicked link : <p><strong>I'd like to get the id of the clicked link with jQuery.</strong> Why does this return <code>Undefined</code> instead?</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>test = function(e) { alert($(e).attr('id')); return false; } $('.bleu').click(test)</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt; &lt;a href="" class="bleu" id="h12"&gt;azeaze12&lt;/a&gt; &lt;a href="" class="bleu" id="h13"&gt;azeaze13&lt;/a&gt; &lt;a href="" class="bleu" id="h14"&gt;azeaze14&lt;/a&gt;</code></pre> </div> </div> </p>
0debug
MongoError: The $subtract accumulator is a unary operator : <p>I can't seem to find any solutions for this problem. I just can't figure out what is wrong.</p> <p>I already tried this <a href="https://stackoverflow.com/questions/46722968/mongo-subtract-in-group-aggregation">Mongo subtract in group aggregation</a> but no hope. The post also failed to explain further.</p> <p>Here is my code: </p> <pre><code> var aggregateOptions; aggregateOptions = [{ $match: { } },{ $group: { _id: "$customerID", totalAmount: { $sum: "$amount" }, totalpaidAmount: { $sum: "$paidAmount" }, totalAmountDue: { $subtract: ["$totalAmount", "totalpaidAmount"] } } }]; Sale.sales.get(Sale.Schema, aggregateOptions, (err, saleRecord) =&gt; { if (err) throw err; console.log(saleRecord); res.json({ pageTitle: "Customer List", currentUser: req.user, saleRecord: saleRecord, }); }); </code></pre> <p>it prompts MongoError: The $subtract accumulator is a unary operator everytime I query it.</p>
0debug
variable changes when using if statement : <p>I've just started learning php an hour ago. I've made this code:</p> <pre><code>$x=2; $y=4; echo $x; echo $y; if($x=5) { echo "$x"; } else { echo "test"; } </code></pre> <p>I'm expecting the output: 24test</p> <p>I'm getting the output: 245</p> <p>x equals 2 in the beginning. Why is x then changing to 5 when the only thing I do is CHECKING whether x = 5?</p> <p>I've searched the web and this site for an answer but couldn't find anything. Thanks in advance!</p> <p>Tony</p>
0debug
Is there an API to detect which theme the OS is using - dark or light (or other)? : <h2>Background</h2> <p>On recent Android versions, ever since Android 8.1, the OS got more and more support for themes. More specifically dark theme.</p> <h2>The problem</h2> <p>Even though there is a lot of talk about dark mode in the point-of-view for users, there is almost nothing that's written for developers.</p> <h2>What I've found</h2> <p>Starting from Android 8.1, Google provided some sort of dark theme . If the user chooses to have a dark wallpaper, some UI components of the OS would turn black (article <a href="https://www.theandroidsoul.com/dark-theme-android-8-1-oreo/" rel="noreferrer"><strong>here</strong></a>). </p> <p>In addition, if you developed a live wallpaper app, you could tell the OS which colors it has (3 types of colors), which affected the OS colors too (at least on Vanilla based ROMs and on Google devices). That's why I even made an app that lets you have any wallpaper while still be able to choose the colors (<a href="https://play.google.com/store/apps/details?id=com.lb.lwp_plus" rel="noreferrer"><strong>here</strong></a>). This is done by calling <a href="https://developer.android.com/reference/android/service/wallpaper/WallpaperService.Engine.html#notifyColorsChanged()" rel="noreferrer"><strong>notifyColorsChanged</strong></a> and then provide them using <a href="https://developer.android.com/reference/android/service/wallpaper/WallpaperService.Engine.html#onComputeColors()" rel="noreferrer"><strong>onComputeColors</strong></a></p> <p>Starting from Android 9.0, it is now possible to choose which theme to have: light, dark or automatic (based on wallpaper) :</p> <p><a href="https://i.stack.imgur.com/CKZdV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/CKZdV.png" alt="enter image description here"></a></p> <p>And now on the near Android Q , it seems it went further, yet it's still unclear to what extent. Somehow a launcher called "Smart Launcher" has ridden on it, offering to use the theme right on itself (article <a href="https://www.androidcentral.com/smart-launcher-5-adds-android-q-dark-theme-support" rel="noreferrer"><strong>here</strong></a>). So, if you enable dark mode (manually, as written <a href="https://www.xda-developers.com/android-q-toggle-dark-theme/" rel="noreferrer"><strong>here</strong></a>) , you get the app's settings screen as such:</p> <p><a href="https://i.stack.imgur.com/W43vo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/W43vo.png" alt="enter image description here"></a></p> <p>The only thing I've found so far is the above articles, and that I'm following this kind of topic.</p> <p>I also know how to request the OS to change color using the live wallpaper, but this seems to be changing on Android Q, at least according to what I've seen when trying it (I think it's more based on time-of-day, but not sure).</p> <h2>The questions</h2> <ol> <li><p>Is there an API to get which colors the OS is set to use ? </p></li> <li><p>Is there any kind of API to get the theme of the OS ? From which version?</p></li> <li><p>Is the new API somehow related to night mode too? How do those work together?</p></li> <li><p>Is there a nice API for apps to handle the chosen theme? Meaning that if the OS is in certain theme, so will the current app?</p></li> </ol>
0debug
static int gdb_get_avr_reg(CPUState *env, uint8_t *mem_buf, int n) { if (n < 32) { #ifdef WORDS_BIGENDIAN stq_p(mem_buf, env->avr[n].u64[0]); stq_p(mem_buf+8, env->avr[n].u64[1]); #else stq_p(mem_buf, env->avr[n].u64[1]); stq_p(mem_buf+8, env->avr[n].u64[0]); #endif return 16; } if (n == 33) { stl_p(mem_buf, env->vscr); return 4; } if (n == 34) { stl_p(mem_buf, (uint32_t)env->spr[SPR_VRSAVE]); return 4; } return 0; }
1threat
find_c_packed_planar_out_funcs(SwsContext *c, yuv2planar1_fn *yuv2yuv1, yuv2planarX_fn *yuv2yuvX, yuv2packed1_fn *yuv2packed1, yuv2packed2_fn *yuv2packed2, yuv2packedX_fn *yuv2packedX) { enum PixelFormat dstFormat = c->dstFormat; if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) { *yuv2yuvX = yuv2nv12X_c; } else if (is16BPS(dstFormat)) { *yuv2yuvX = isBE(dstFormat) ? yuv2yuvX16BE_c : yuv2yuvX16LE_c; } else if (is9_OR_10BPS(dstFormat)) { if (av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1 == 8) { *yuv2yuvX = isBE(dstFormat) ? yuv2yuvX9BE_c : yuv2yuvX9LE_c; } else { *yuv2yuvX = isBE(dstFormat) ? yuv2yuvX10BE_c : yuv2yuvX10LE_c; } } else { *yuv2yuv1 = yuv2yuv1_c; *yuv2yuvX = yuv2yuvX_c; } if(c->flags & SWS_FULL_CHR_H_INT) { switch (dstFormat) { case PIX_FMT_RGBA: #if CONFIG_SMALL *yuv2packedX = yuv2rgba32_full_X_c; #else #if CONFIG_SWSCALE_ALPHA if (c->alpPixBuf) { *yuv2packedX = yuv2rgba32_full_X_c; } else #endif { *yuv2packedX = yuv2rgbx32_full_X_c; } #endif break; case PIX_FMT_ARGB: #if CONFIG_SMALL *yuv2packedX = yuv2argb32_full_X_c; #else #if CONFIG_SWSCALE_ALPHA if (c->alpPixBuf) { *yuv2packedX = yuv2argb32_full_X_c; } else #endif { *yuv2packedX = yuv2xrgb32_full_X_c; } #endif break; case PIX_FMT_BGRA: #if CONFIG_SMALL *yuv2packedX = yuv2bgra32_full_X_c; #else #if CONFIG_SWSCALE_ALPHA if (c->alpPixBuf) { *yuv2packedX = yuv2bgra32_full_X_c; } else #endif { *yuv2packedX = yuv2bgrx32_full_X_c; } #endif break; case PIX_FMT_ABGR: #if CONFIG_SMALL *yuv2packedX = yuv2abgr32_full_X_c; #else #if CONFIG_SWSCALE_ALPHA if (c->alpPixBuf) { *yuv2packedX = yuv2abgr32_full_X_c; } else #endif { *yuv2packedX = yuv2xbgr32_full_X_c; } #endif break; case PIX_FMT_RGB24: *yuv2packedX = yuv2rgb24_full_X_c; break; case PIX_FMT_BGR24: *yuv2packedX = yuv2bgr24_full_X_c; break; } } else { switch (dstFormat) { case PIX_FMT_GRAY16BE: *yuv2packed1 = yuv2gray16BE_1_c; *yuv2packed2 = yuv2gray16BE_2_c; *yuv2packedX = yuv2gray16BE_X_c; break; case PIX_FMT_GRAY16LE: *yuv2packed1 = yuv2gray16LE_1_c; *yuv2packed2 = yuv2gray16LE_2_c; *yuv2packedX = yuv2gray16LE_X_c; break; case PIX_FMT_MONOWHITE: *yuv2packed1 = yuv2monowhite_1_c; *yuv2packed2 = yuv2monowhite_2_c; *yuv2packedX = yuv2monowhite_X_c; break; case PIX_FMT_MONOBLACK: *yuv2packed1 = yuv2monoblack_1_c; *yuv2packed2 = yuv2monoblack_2_c; *yuv2packedX = yuv2monoblack_X_c; break; case PIX_FMT_YUYV422: *yuv2packed1 = yuv2yuyv422_1_c; *yuv2packed2 = yuv2yuyv422_2_c; *yuv2packedX = yuv2yuyv422_X_c; break; case PIX_FMT_UYVY422: *yuv2packed1 = yuv2uyvy422_1_c; *yuv2packed2 = yuv2uyvy422_2_c; *yuv2packedX = yuv2uyvy422_X_c; break; case PIX_FMT_RGB48LE: case PIX_FMT_RGB48BE: *yuv2packed1 = yuv2rgb48be_1_c; *yuv2packed2 = yuv2rgb48be_2_c; *yuv2packedX = yuv2rgb48be_X_c; break; case PIX_FMT_BGR48LE: case PIX_FMT_BGR48BE: *yuv2packed1 = yuv2bgr48be_1_c; *yuv2packed2 = yuv2bgr48be_2_c; *yuv2packedX = yuv2bgr48be_X_c; break; case PIX_FMT_RGB32: case PIX_FMT_BGR32: #if CONFIG_SMALL *yuv2packed1 = yuv2rgb32_1_c; *yuv2packed2 = yuv2rgb32_2_c; *yuv2packedX = yuv2rgb32_X_c; #else #if CONFIG_SWSCALE_ALPHA if (c->alpPixBuf) { *yuv2packed1 = yuv2rgba32_1_c; *yuv2packed2 = yuv2rgba32_2_c; *yuv2packedX = yuv2rgba32_X_c; } else #endif { *yuv2packed1 = yuv2rgbx32_1_c; *yuv2packed2 = yuv2rgbx32_2_c; *yuv2packedX = yuv2rgbx32_X_c; } #endif break; case PIX_FMT_RGB32_1: case PIX_FMT_BGR32_1: #if CONFIG_SMALL *yuv2packed1 = yuv2rgb32_1_1_c; *yuv2packed2 = yuv2rgb32_1_2_c; *yuv2packedX = yuv2rgb32_1_X_c; #else #if CONFIG_SWSCALE_ALPHA if (c->alpPixBuf) { *yuv2packed1 = yuv2rgba32_1_1_c; *yuv2packed2 = yuv2rgba32_1_2_c; *yuv2packedX = yuv2rgba32_1_X_c; } else #endif { *yuv2packed1 = yuv2rgbx32_1_1_c; *yuv2packed2 = yuv2rgbx32_1_2_c; *yuv2packedX = yuv2rgbx32_1_X_c; } #endif break; case PIX_FMT_RGB24: *yuv2packed1 = yuv2rgb24_1_c; *yuv2packed2 = yuv2rgb24_2_c; *yuv2packedX = yuv2rgb24_X_c; break; case PIX_FMT_BGR24: *yuv2packed1 = yuv2bgr24_1_c; *yuv2packed2 = yuv2bgr24_2_c; *yuv2packedX = yuv2bgr24_X_c; break; case PIX_FMT_RGB565: case PIX_FMT_BGR565: *yuv2packed1 = yuv2rgb16_1_c; *yuv2packed2 = yuv2rgb16_2_c; *yuv2packedX = yuv2rgb16_X_c; break; case PIX_FMT_RGB555: case PIX_FMT_BGR555: *yuv2packed1 = yuv2rgb15_1_c; *yuv2packed2 = yuv2rgb15_2_c; *yuv2packedX = yuv2rgb15_X_c; break; case PIX_FMT_RGB444: case PIX_FMT_BGR444: *yuv2packed1 = yuv2rgb12_1_c; *yuv2packed2 = yuv2rgb12_2_c; *yuv2packedX = yuv2rgb12_X_c; break; case PIX_FMT_RGB8: case PIX_FMT_BGR8: *yuv2packed1 = yuv2rgb8_1_c; *yuv2packed2 = yuv2rgb8_2_c; *yuv2packedX = yuv2rgb8_X_c; break; case PIX_FMT_RGB4: case PIX_FMT_BGR4: *yuv2packed1 = yuv2rgb4_1_c; *yuv2packed2 = yuv2rgb4_2_c; *yuv2packedX = yuv2rgb4_X_c; break; case PIX_FMT_RGB4_BYTE: case PIX_FMT_BGR4_BYTE: *yuv2packed1 = yuv2rgb4b_1_c; *yuv2packed2 = yuv2rgb4b_2_c; *yuv2packedX = yuv2rgb4b_X_c; break; } } }
1threat
void ff_wmv2_idct_c(short * block){ int i; for(i=0;i<64;i+=8){ wmv2_idct_row(block+i); } for(i=0;i<8;i++){ wmv2_idct_col(block+i); } }
1threat
Is there a way I can left pad a number in C#? : <p>I have this code:</p> <pre><code>phrasesPage.Title = "Timer: " + AS.timerSeconds.ToString(); </code></pre> <p>The number of seconds can be anything from 120 to 0. Is there a way that I can have that display as "Timer: " plus the numbers 120 ... 099 .. 002 ... 001 ... 000 . In other words I need the number to show as three digits with left padding of 0's</p>
0debug
void aio_set_event_notifier(AioContext *ctx, EventNotifier *e, EventNotifierHandler *io_notify) { AioHandler *node; QLIST_FOREACH(node, &ctx->aio_handlers, node) { if (node->e == e && !node->deleted) { break; } } if (!io_notify) { if (node) { g_source_remove_poll(&ctx->source, &node->pfd); if (ctx->walking_handlers) { node->deleted = 1; node->pfd.revents = 0; } else { QLIST_REMOVE(node, node); g_free(node); } } } else { if (node == NULL) { node = g_malloc0(sizeof(AioHandler)); node->e = e; node->pfd.fd = (uintptr_t)event_notifier_get_handle(e); node->pfd.events = G_IO_IN; QLIST_INSERT_HEAD(&ctx->aio_handlers, node, node); g_source_add_poll(&ctx->source, &node->pfd); } node->io_notify = io_notify; } aio_notify(ctx); }
1threat
How to Run Different Product Flavors in Android Studio : <p>I'm writing my first android app, and I'm just getting started with product flavors. I have an ad-supported app in beta, and I'm writing a paid version with no ads. I can compile both flavors, I think. When I open the gradle window, I see targets like "compile AdsDebugSources" and "compile PremiumDebugSources." </p> <p>Now, if I double-click on either of those, the build runs to completion without error, but I can't figure out how to run the results. If I click on the green "Run" arrow at the top of the screen, I can never run the premium app.</p> <p>There's only one entry, "app" that results in a an apk being installed and run on the attached device, and it's the AdsDebug version. I guess I need to add a new configuration, but I can't find any documentation that even mentions the word "flavor."</p> <p>I've tried adding a configuration, but I don't understand what the questions mean. I looked at the settings for the default app, but they don't seem to mean much. How do I tell it that I want the premium version of my app?</p> <p>Or does my problem have nothing to do with configurations? I've noticed that when I look at the <code>Build/Edit Flavors</code> the two flavors are listed, but none of the data fields are filled in. I would have thought that these would be copied from the manifest. Have I neglected something? </p> <p>All I did to set up the flavors was to add this code to the app level build.gradle file:</p> <pre><code>flavorDimensions "dummy" productFlavors { ads { dimension "dummy" applicationId 'com.example.myApp.ads' } premium { dimension "dummy" applicationId 'com.example.myApp.premium' } </code></pre> <p>}</p> <p>What else do I need to do?</p>
0debug
this is very simple program of collection but not running : <p>I am using latest jdk to run this program. i cant find the right solution here pls help.</p> <pre><code>import java.util.ArrayList; import java.util.Iterator; import java.util.List; class ArrayListDemo{ List&lt;String&gt; list = new ArrayList&lt;&gt;(); list.add("abc"); list.add("xyz"); Iterator&lt;String&gt; itr = list.iterator(); while(itr.){ System.out.println(itr.next()); } } </code></pre>
0debug
how to do average in R or xcel : I have a big data set something like this below image length angle DSC_0001.JPG 13 22.619865 DSC_0001.JPG 21.470911 27.758541 DSC_0001.JPG 10.198039 11.309933 DSC_0001.JPG 115.97414 60.561512 DSC_0001.JPG 16.27882 79.38035 DSC_0001.JPG 22.803509 15.255118 DSC_0001.JPG 22.825424 28.810793 DSC_0001.JPG 151.0298 1.138177 DSC_0001.JPG 13.038404 85.601295 DSC_0001.JPG 16.124516 7.125016 DSC_0001.JPG 18.027756 3.17983 DSC_0001.JPG 10.198039 11.309933 DSC_0001.JPG 26.832815 26.565052 DSC_0001.JPG 17 61.927513 DSC_0001.JPG 12.165525 80.53768 DSC_0001.JPG 12.206555 55.00798 DSC_0001.JPG 12.727922 45 DSC_0001.JPG 76.02631 63.434948 DSC_0001.JPG 18.248287 9.462322 DSC_0002.JPG 17.492855 59.036243 DSC_0002.JPG 28.160255 6.115504 DSC_0002.JPG 10.049875 84.289406 DSC_0002.JPG 33.970577 42.614056 DSC_0002.JPG 10.440307 16.699244 DSC_0002.JPG 15.231546 66.80141 DSC_0002.JPG 19.723083 30.465546 DSC_0002.JPG 75.802376 53.583622 DSC_0002.JPG 5.8309517 30.963757 I want to do average of "Length" and "angles" for each set(DSC_001 is one set, DSC_002 is another and so on) I can do it manually in excel but taking huge time when it around 4000 data point. I like to know how I do it in R or in excel in much smarter way?
0debug
av_cold int ff_MPV_common_init(MpegEncContext *s) { int i; int nb_slices = (HAVE_THREADS && s->avctx->active_thread_type & FF_THREAD_SLICE) ? s->avctx->thread_count : 1; if (s->encoding && s->avctx->slices) nb_slices = s->avctx->slices; if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO && !s->progressive_sequence) s->mb_height = (s->height + 31) / 32 * 2; else s->mb_height = (s->height + 15) / 16; if (s->avctx->pix_fmt == AV_PIX_FMT_NONE) { av_log(s->avctx, AV_LOG_ERROR, "decoding to AV_PIX_FMT_NONE is not supported.\n"); return -1; } if (nb_slices > MAX_THREADS || (nb_slices > s->mb_height && s->mb_height)) { int max_slices; if (s->mb_height) max_slices = FFMIN(MAX_THREADS, s->mb_height); else max_slices = MAX_THREADS; av_log(s->avctx, AV_LOG_WARNING, "too many threads/slices (%d)," " reducing to %d\n", nb_slices, max_slices); nb_slices = max_slices; } if ((s->width || s->height) && av_image_check_size(s->width, s->height, 0, s->avctx)) return -1; ff_dct_common_init(s); s->flags = s->avctx->flags; s->flags2 = s->avctx->flags2; av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt, &s->chroma_x_shift, &s->chroma_y_shift); s->codec_tag = avpriv_toupper4(s->avctx->codec_tag); s->stream_codec_tag = avpriv_toupper4(s->avctx->stream_codec_tag); FF_ALLOCZ_OR_GOTO(s->avctx, s->picture, MAX_PICTURE_COUNT * sizeof(Picture), fail); for (i = 0; i < MAX_PICTURE_COUNT; i++) { av_frame_unref(&s->picture[i].f); } memset(&s->next_picture, 0, sizeof(s->next_picture)); memset(&s->last_picture, 0, sizeof(s->last_picture)); memset(&s->current_picture, 0, sizeof(s->current_picture)); av_frame_unref(&s->next_picture.f); av_frame_unref(&s->last_picture.f); av_frame_unref(&s->current_picture.f); if (s->width && s->height) { if (init_context_frame(s)) goto fail; s->parse_context.state = -1; } s->context_initialized = 1; s->thread_context[0] = s; if (s->width && s->height) { if (nb_slices > 1) { for (i = 1; i < nb_slices; i++) { s->thread_context[i] = av_malloc(sizeof(MpegEncContext)); memcpy(s->thread_context[i], s, sizeof(MpegEncContext)); } for (i = 0; i < nb_slices; i++) { if (init_duplicate_context(s->thread_context[i]) < 0) goto fail; s->thread_context[i]->start_mb_y = (s->mb_height * (i) + nb_slices / 2) / nb_slices; s->thread_context[i]->end_mb_y = (s->mb_height * (i + 1) + nb_slices / 2) / nb_slices; } } else { if (init_duplicate_context(s) < 0) goto fail; s->start_mb_y = 0; s->end_mb_y = s->mb_height; } s->slice_context_count = nb_slices; } return 0; fail: ff_MPV_common_end(s); return -1; }
1threat
How to login webmail with Python ? : import requests import webbrowser s = requests.session() login_data = dict(username='***********', password= '*******') s.post("https://webmail..........................) webbrowser.get(using='chrome').open("https://webmail...............inbox") Hi , Here is my python code. I try to login my webmail via code. When I run this code login page is openning with Google Chrome but couldn't wrote the username and password. I know there have been a lot of entries about this topic but I really couldn't find the problem.
0debug
How to take particular key value pairs from json array : <p>I have a large amount of data in JSON array format. A shorter version of which is as shown below</p> <pre><code>[{"Item": "Item1", "Unit CP": 100, "Unit SP": 150, "Quantity": 1, "TotalSP": 150}, {"Item": "Item2", "Unit CP": 50, "Unit SP": 70, "Quantity": 7, "TotalSP": 490}, {"Item": "Item3", "Unit CP": 1000, "Unit SP": 900, "Quantity": 1, "TotalSP": 900}, {"Item": "Item4", "Unit CP": 200, "Unit SP": 500, "Quantity": 2, "TotalSP": 1000}, {"Item": "Item5", "Unit CP": 300, "Unit SP": 311, "Quantity": 3, "TotalSP": 933}, {"Item": "Item6", "Unit CP": 750, "Unit SP": 755, "Quantity": 2, "TotalSP": 1510}] </code></pre> <p>i want to get a JSON array of objects with keys "Item" and "Unit SP" only i.e</p> <pre><code>[{"Item": "Item1", "Unit SP": 150}, {"Item": "Item2", "Unit SP": 70}, {"Item": "Item3", "Unit SP": 900}, {"Item": "Item4", "Unit SP": 500}, {"Item": "Item5", "Unit SP": 311}, {"Item": "Item6", "Unit SP": 755}] </code></pre> <p>Is there a simpler way to do so in javascript without parsing through the whole array? Thanks in advance </p>
0debug
C# ASP get path string without user having to select a file : Friends, I want to use the equivalence of open file dialog box in windows forms (FolderBrowserDialog) in asp. I see the FileUpload class but the user is still forced to select a file. I only want the directory portion.
0debug
Golang: unit testing os.File.Write call : I want to unit test a function that calls `os.File.Write()` and want 100% coverage. This function returns `n` and an error. Inducing an error is easy. All I need is to close the file. How can I induce no write error and a value `n` different of the written data length ? It looks like I should create a dummy os.File on which I can control the error returned. Unfortunately, os.File is not an interface.
0debug
int udp_set_remote_url(URLContext *h, const char *uri) { UDPContext *s = h->priv_data; char hostname[256]; int port; url_split(NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri); if (resolve_host(&s->dest_addr.sin_addr, hostname) < 0) return AVERROR_IO; s->dest_addr.sin_family = AF_INET; s->dest_addr.sin_port = htons(port); return 0; }
1threat
Python weird loop in a CSV file parser : I have a Python that is going to read every **x** seconds a CSV file. what I do is: Open the file, read the info as CSV, loop every entry this is done in this PythonFile_: import csv import time import datetime CSV_PLAN = "./XoceKochPlan.csv" chargePlanFile = open(CSV_PLAN, 'rt') def loopMe(): try: for eachRow in reader: print (eachRow) except Exception, ex: print ("Error processFileing the Thread" + str(ex)) print ("opening file " + str(CSV_PLAN)) now = datetime.datetime.utcnow().strftime("%a %b %d %H %M %S %Z %Y") print ("Now " + str(now)) reader = csv.reader(chargePlanFile) loopMe() the output is so far so good but if I do loopMe() time.sleep(10) loopMe() then the file is only printed once! The question is Why?? what am I missing??? what is getting internally consumed, os the reader is emprty after the 1st loop??? thnks!
0debug
Is there an href attribute to add a contact, like “mailto:” or “tel:”? : <p>I want to add a contact to the user smartphone (like when someone send you a contact via WhatsApp) on a website.</p>
0debug
Autofac IComponentContext vs ILifetimeScope : <p>I was passing the IContainer in a service so I read that it is not good to pass this around but instead use it only to the root of the app and pass either IComponentContext or ILifetimeScope . So I am trying to understand which shall I use IComponentContext or ILifetimeScope. Dont understand the difference</p>
0debug
Regex R lookbehind : <p>How can I find the <code>n</code> words before the <code>colon</code> in this string in <code>R</code>? I'm using <code>stringr</code> but would regular expressions would be prefered.</p> <pre><code>Input on income economic activities: Small business, self-emp… </code></pre> <p>Thanks, E.</p>
0debug
Setting NSUnderlineStyle causes unrecogognized selector exception : <p>I am trying to underline a string with NSAttributed string. For some reason, my lines cause the exception: </p> <pre><code>-[_SwiftValue _getValue:forType:]: unrecognized selector sent to instance </code></pre> <p>The result is supposed to be used for a UILabel within a UITableView and is created as needed.</p> <p>This is the code:</p> <pre><code>attributedString = NSMutableAttributedString(string: message) if let actor = event.actor { let attributes = [NSUnderlineStyleAttributeName:NSUnderlineStyle.styleSingle] var attributedActorString = NSMutableAttributedString(string: actor.shirtName, attributes: attributes) attributedActorString.insert(NSAttributedString(string: " "), at: 0) attributedActorString.append(NSAttributedString(string: ". ")) attributedActorString.append(attributedImageStringForUrl(event.actor!.portraitImageUrl, indexPath: indexPath)) attributedString.append(attributedActorString) } </code></pre>
0debug
Why does Java 12 try to convert the result of a switch to a number? : <p>I agree that this code:</p> <pre><code>var y = switch (0) { case 0 -&gt; '0'; case 1 -&gt; 0.0F; case 2 -&gt; 2L; case 3 -&gt; true; default -&gt; 4; }; System.out.println(y); System.out.println(((Object) y).getClass().getName()); </code></pre> <p>returns this:</p> <pre><code>0 java.lang.Character </code></pre> <p>But if you remove boolean:</p> <pre><code>var y = switch (0) { case 0 -&gt; '0'; case 1 -&gt; 0.0F; case 2 -&gt; 2L; default -&gt; 4; }; System.out.println(y); System.out.println(((Object) y).getClass().getName()); </code></pre> <p>returns this:</p> <pre><code>48.0 java.lang.Float </code></pre> <p>I suppose this result is unexpected.</p>
0debug
Conversion from `java.time.Instant` to `java.util.Date` adds UTC offset : <p>I seem to misunderstand <code>java.util.Date</code>'s conversion from and to <code>java.time.Instance</code>. I have some legacy code I need to ineract with, and this code uses <code>java.util.Date</code> in its API.</p> <p>I am slightly confused when offsets are added in the <code>Date</code> API. It was my understand that <code>Date</code> is a UTC time ("the Date class is intended to reflect coordinated universal time (UTC)"), but when I create a <code>Date</code> from an <code>Instant</code> an offset is added:</p> <pre><code>public class TestDateInstant { @Test public void instantdate() { Instant i = Instant.now(); System.out.println(i); Date d = Date.from(i); System.out.println(d); assertThat(i, equalTo(d.toInstant())); } } </code></pre> <p>The assertion holds, but the output on the console is:</p> <pre><code>2017-09-26T08:24:40.858Z Tue Sep 26 10:24:40 CEST 2017 </code></pre> <p>I am wondering why <code>Date.from</code> uses an offset in this case.</p>
0debug
how to convert .bat file (batch) to .cmd file : i need a convert .bat file to .cmd file i have a file .bat and i want convert it to .cmd ex : rem^ &@echo off rem^ &call :'sub rem^ &exit /b :'sub rem^ &echo begin batch rem^ &cscript //nologo //e:vbscript "%~f0" rem^ &echo end batch rem^ &exit /b That all about It thanks
0debug
How can I do a telnet to a local HTTP server? : <p>I know how to do it to a remote server, it would be like: </p> <pre><code>telnet www.esqsoft.globalservers.com 80 </code></pre> <p>But I don't know to a local server (written in C).</p>
0debug
Best way to create an account system in C# : <p>I am trying to create a system like LinkedIn but a simplified one. I tried doing so, but I came to realization that it will not be possible until I create something like an account system because at the moment the user will login - ok but then what? How is he going to be able to upload CV under his name. I haven't totally understood how it should work and as you can already probably tell I am not very experienced. ;p</p> <p>So my question here is: How can create a system where the user will register and enter personal details, work experience and upload CV? Employers will have to register as employers and search employees with being able to filter them by keywords such as "good with computers". At the same time, be able to view their profile. Thank you in advance! </p>
0debug
size_t v9fs_marshal(struct iovec *in_sg, int in_num, size_t offset, int bswap, const char *fmt, ...) { int i; va_list ap; size_t old_offset = offset; va_start(ap, fmt); for (i = 0; fmt[i]; i++) { switch (fmt[i]) { case 'b': { uint8_t val = va_arg(ap, int); offset += v9fs_pack(in_sg, in_num, offset, &val, sizeof(val)); break; } case 'w': { uint16_t val; if (bswap) { cpu_to_le16w(&val, va_arg(ap, int)); } else { val = va_arg(ap, int); } offset += v9fs_pack(in_sg, in_num, offset, &val, sizeof(val)); break; } case 'd': { uint32_t val; if (bswap) { cpu_to_le32w(&val, va_arg(ap, uint32_t)); } else { val = va_arg(ap, uint32_t); } offset += v9fs_pack(in_sg, in_num, offset, &val, sizeof(val)); break; } case 'q': { uint64_t val; if (bswap) { cpu_to_le64w(&val, va_arg(ap, uint64_t)); } else { val = va_arg(ap, uint64_t); } offset += v9fs_pack(in_sg, in_num, offset, &val, sizeof(val)); break; } case 's': { V9fsString *str = va_arg(ap, V9fsString *); offset += v9fs_marshal(in_sg, in_num, offset, bswap, "w", str->size); offset += v9fs_pack(in_sg, in_num, offset, str->data, str->size); break; } case 'Q': { V9fsQID *qidp = va_arg(ap, V9fsQID *); offset += v9fs_marshal(in_sg, in_num, offset, bswap, "bdq", qidp->type, qidp->version, qidp->path); break; } case 'S': { V9fsStat *statp = va_arg(ap, V9fsStat *); offset += v9fs_marshal(in_sg, in_num, offset, bswap, "wwdQdddqsssssddd", statp->size, statp->type, statp->dev, &statp->qid, statp->mode, statp->atime, statp->mtime, statp->length, &statp->name, &statp->uid, &statp->gid, &statp->muid, &statp->extension, statp->n_uid, statp->n_gid, statp->n_muid); break; } case 'A': { V9fsStatDotl *statp = va_arg(ap, V9fsStatDotl *); offset += v9fs_marshal(in_sg, in_num, offset, bswap, "qQdddqqqqqqqqqqqqqqq", statp->st_result_mask, &statp->qid, statp->st_mode, statp->st_uid, statp->st_gid, statp->st_nlink, statp->st_rdev, statp->st_size, statp->st_blksize, statp->st_blocks, statp->st_atime_sec, statp->st_atime_nsec, statp->st_mtime_sec, statp->st_mtime_nsec, statp->st_ctime_sec, statp->st_ctime_nsec, statp->st_btime_sec, statp->st_btime_nsec, statp->st_gen, statp->st_data_version); break; } default: break; } } va_end(ap); return offset - old_offset; }
1threat
Real devices not showing in android studio : <p>Hi i am trying to run my app through usb i have turned on debug mode also install via usb but after connecting device to android studio i am not able to show the device in android studio Any help?</p> <p><a href="https://i.stack.imgur.com/ZjcOV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZjcOV.png" alt="enter image description here"></a></p>
0debug
PHP: Merge three variables (year, month, day) into one date : <p>I have three variables:</p> <p>1.) $year (e.g. "2018"),</p> <p>2.) $month (e.g. "9" or "12"),</p> <p>3.) $day (e.g. "5" or "21").</p> <p>I want to merge them into one single variable ($date) in the format of YYYY-mm-dd, i.e. "2018-09-14".</p> <p>Note that the month "9" and the day "5" now have "0" in front of them.</p> <p>What would be the best way to do so? </p> <p>Thank you!</p>
0debug
regrex required for fetching value in </span> : I need a regex for fetching the value in the </span> tag <span class="booking-id-value">U166097</span value required =U166097 can please someone suggest me. I have tried using <span class="booking-id-value">(.+?) but it is not deriving the desired result it display on "U" Please help me to get this desired value Thanks
0debug
java buble sort code problems : Write a computer program that prompts the user for a number, creates an array for that number of random integers, and then uses the bubble sort to order the array. The program should print out the array prior to the call to the sorting algorithm and afterwards. I have most of the buble sort working, it is just the implementation of the random integers and user input for the size of the array that I can't seem to figure out. import java.util.*; import java.lang.*; import java.io.*; import java.util.Random; class Test { public static void main (String[] args) throws java.lang.Exception { int n, c, d, swap; Scanner in = new Scanner(System.in); Random r = new Random(); System.out.println("enter number of elements to sort"); n = r.nextInt(); int array[] = new int[n]; for (c = 0; c < n; c++) array[c] = r.nextInt(); for (c = 0; c < ( n - 1 ); c++) { for (d = 0; d < n - c - 1; d++) { if (array[d] > array[d+1]) { swap = array[d]; array[d] = array[d+1]; array[d+1] = swap; } } } System.out.println("Sorted array :"); for (c = 0; c < n; c++) System.out.println(array[c]); } }
0debug
static int decode_blocks_ind(ALSDecContext *ctx, unsigned int ra_frame, unsigned int c, const unsigned int *div_blocks, unsigned int *js_blocks) { unsigned int b; ALSBlockData bd = { 0 }; bd.ra_block = ra_frame; bd.const_block = ctx->const_block; bd.shift_lsbs = ctx->shift_lsbs; bd.opt_order = ctx->opt_order; bd.store_prev_samples = ctx->store_prev_samples; bd.use_ltp = ctx->use_ltp; bd.ltp_lag = ctx->ltp_lag; bd.ltp_gain = ctx->ltp_gain[0]; bd.quant_cof = ctx->quant_cof[0]; bd.lpc_cof = ctx->lpc_cof[0]; bd.prev_raw_samples = ctx->prev_raw_samples; bd.raw_samples = ctx->raw_samples[c]; for (b = 0; b < ctx->num_blocks; b++) { bd.block_length = div_blocks[b]; if (read_decode_block(ctx, &bd)) { zero_remaining(b, ctx->num_blocks, div_blocks, bd.raw_samples); return -1; } bd.raw_samples += div_blocks[b]; bd.ra_block = 0; } return 0; }
1threat
How can I use "Apply Changes" if I use Crashlytics? : <p>I'm using Android Studio 3.5 Beta 1. I decided to try out "Apply Changes". Instant Run was problematic, so we've had it disabled for years. I hoped that this would work better.</p> <p>If I try the "Apply Code Changes" button, I get an error in the Run window:</p> <pre><code>Changes were not applied. Modifying resources requires an activity restart. Resource 'assets/crashlytics-build.properties' was modified. Apply changes and restart activity </code></pre> <p><code>crashlytics-build.properties</code> has comments that say</p> <pre><code>#This file is automatically generated by Crashlytics to uniquely #identify individual builds of your Android application </code></pre> <p>And indeed, it has a <code>build_id</code> property that presumably changes for every Gradle build. And since Gradle runs a build whenever I use the "Apply Code Changes" or "Apply Changes and Restart Activity" buttons, the Gradle build changes the file, which prevents Apply Run from completing.</p> <p>The only information I've found online related to this was one <a href="https://www.reddit.com/r/androiddev/comments/atlzmk/android_studio_project_marble_apply_changes/eh98465/" rel="noreferrer">Reddit comment</a> saying</p> <blockquote> <p>I learned the hard way that crashlytics + proguard breaks instant run</p> </blockquote> <p>So it would seem I'm not the only person with this problem. Removing Crashlytics isn't an option. Nor would I want to disable it every time I'm going to do some debugging, then re-enable it again.</p> <p>The "Apply Changes and Restart Activity" button does function. The Activity I'm using restarts and changes are visible. I tried comparing the timing of this to using the regular "Run" button. "Apply Changes and Restart Activity" takes just as long. The only benefit seems to be that instead of having to navigate through the app to that screen each time, I can remain on that screen and reload the changes. That is a nice benefit, I just expected more.</p> <p>Is there anything I can do to make "Apply Changes" work more effectively for me?</p>
0debug
static BlockDriverAIOCB *raw_aio_writev(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque) { return bdrv_aio_writev(bs->file, sector_num, qiov, nb_sectors, cb, opaque); }
1threat
Ambigious use of subscript compiler error : function below is for ELCImagePicker to pick multiple images and I added my code to, the code used to run probably and suddenly after installing Parse SDK it gave error "Ambigious use of subscript" at this line of code : if let image = item[UIImagePickerControllerOriginalImage] as? UIImage Code: func elcImagePickerController(_ picker: ELCImagePickerController!, didFinishPickingMediaWithInfo info: [Any]!) { self.dismiss(animated: true, completion: nil) var i = 0 var z = 0 var imageViews = [Any]() // array of any object used to save the selected imagesviews to it so we can display it on the viewcontroller for item in info as [AnyObject] { z += 0 //we used z = +0 as the arrays always starts at index 0 not 1 i += 1 //we used another var i += 1 as UIImagePickerControllerOriginalImage starts at 1 if let image = item[UIImagePickerControllerOriginalImage] as? UIImage { imagearray.insert(image, at: z) // array of images to be used in "Saved" function below to save the images selected to core data image_view = UIImageView(image: image) let currentImageView = UIImageView(frame: CGRect(x: 130 + (i * 10), y: 50 + (i * 5), width: 50, height: 100)) currentImageView.contentMode = .scaleAspectFit currentImageView.image = image_view.image imageViews.append(currentImageView) } } var y = 0 var imageview: AnyObject for _ in imageViews as [Any] { imageview = imageViews[y] as AnyObject view.addSubview(imageview as! UIView) y += 1 } }
0debug
Difference between InheritableThreadLocal<ConcurrentMap> vs InheritableThreadLocal<OwnCacheStorageEntity>? : I have two implementations of an `InheritableThreadLocal` cache. private final InheritableThreadLocal<CacheEntity<T>> cacheMap; @Inject public RequestCache() { this.cacheMap = new InheritableThreadLocal<CacheEntity<T>>() { @Override protected CacheEntity<T> initialValue() { return new CacheEntity<>(); } }; } @Getter @Setter private class CacheEntity<T> { private T value; } and private final InheritableThreadLocal<ConcurrentMap<String, T>> cacheMap; @Inject public RequestCache() { this.cacheMap = new InheritableThreadLocal<ConcurrentMap<String, T>>() { @Override protected ConcurrentMap<String, T> initialValue() { return new ConcurrentHashMap<>(); } }; } . ConcurrentMap one works, whereas the CacheEntity one does not work, for getting setting. I thought since everything happens on one thread, both would work. Any ideas of problems?
0debug
Does this code read the first 10000 lines from a file? : <pre><code>def read_text(bz2_loc, n=10000): with BZ2File(bz2_loc) as file_: for i, line in enumerate(file_): data = json.loads(line) yield data["body"] if i &gt;= n: break </code></pre> <p>I think it reads each line and return the result immediately, and when it reaches 10000 lines, it jumps out of the loop. This piece of code doesn't complete the reading of the whole file. Is that true?</p> <p>If I want to read the whole file, and yield once for each 10000, how to modify it? </p>
0debug
static int vnc_start_tls(struct VncState *vs) { static const int cert_type_priority[] = { GNUTLS_CRT_X509, 0 }; static const int protocol_priority[]= { GNUTLS_TLS1_1, GNUTLS_TLS1_0, GNUTLS_SSL3, 0 }; static const int kx_anon[] = {GNUTLS_KX_ANON_DH, 0}; static const int kx_x509[] = {GNUTLS_KX_DHE_DSS, GNUTLS_KX_RSA, GNUTLS_KX_DHE_RSA, GNUTLS_KX_SRP, 0}; VNC_DEBUG("Do TLS setup\n"); if (vnc_tls_initialize() < 0) { VNC_DEBUG("Failed to init TLS\n"); vnc_client_error(vs); return -1; } if (vs->tls_session == NULL) { if (gnutls_init(&vs->tls_session, GNUTLS_SERVER) < 0) { vnc_client_error(vs); return -1; } if (gnutls_set_default_priority(vs->tls_session) < 0) { gnutls_deinit(vs->tls_session); vs->tls_session = NULL; vnc_client_error(vs); return -1; } if (gnutls_kx_set_priority(vs->tls_session, NEED_X509_AUTH(vs) ? kx_x509 : kx_anon) < 0) { gnutls_deinit(vs->tls_session); vs->tls_session = NULL; vnc_client_error(vs); return -1; } if (gnutls_certificate_type_set_priority(vs->tls_session, cert_type_priority) < 0) { gnutls_deinit(vs->tls_session); vs->tls_session = NULL; vnc_client_error(vs); return -1; } if (gnutls_protocol_set_priority(vs->tls_session, protocol_priority) < 0) { gnutls_deinit(vs->tls_session); vs->tls_session = NULL; vnc_client_error(vs); return -1; } if (NEED_X509_AUTH(vs)) { gnutls_certificate_server_credentials x509_cred = vnc_tls_initialize_x509_cred(vs); if (!x509_cred) { gnutls_deinit(vs->tls_session); vs->tls_session = NULL; vnc_client_error(vs); return -1; } if (gnutls_credentials_set(vs->tls_session, GNUTLS_CRD_CERTIFICATE, x509_cred) < 0) { gnutls_deinit(vs->tls_session); vs->tls_session = NULL; gnutls_certificate_free_credentials(x509_cred); vnc_client_error(vs); return -1; } if (vs->vd->x509verify) { VNC_DEBUG("Requesting a client certificate\n"); gnutls_certificate_server_set_request (vs->tls_session, GNUTLS_CERT_REQUEST); } } else { gnutls_anon_server_credentials anon_cred = vnc_tls_initialize_anon_cred(); if (!anon_cred) { gnutls_deinit(vs->tls_session); vs->tls_session = NULL; vnc_client_error(vs); return -1; } if (gnutls_credentials_set(vs->tls_session, GNUTLS_CRD_ANON, anon_cred) < 0) { gnutls_deinit(vs->tls_session); vs->tls_session = NULL; gnutls_anon_free_server_credentials(anon_cred); vnc_client_error(vs); return -1; } } gnutls_transport_set_ptr(vs->tls_session, (gnutls_transport_ptr_t)vs); gnutls_transport_set_push_function(vs->tls_session, vnc_tls_push); gnutls_transport_set_pull_function(vs->tls_session, vnc_tls_pull); } VNC_DEBUG("Start TLS handshake process\n"); return vnc_continue_handshake(vs); }
1threat
PHP dates query malfunctioning : I cannot understand why the following isn't working, and I suspect its something to do with my 'Date' format? SELECT * FROM Scans WHERE (Date BETWEEN '$sdate' AND '$edate') $sdate and $edate are defined dates in format of 01/01/2018. This is also how they are stored in the database under the column 'Date'. It does fetch information, but between the dates of 01/01/2018 and 16/10/2018 there should be 239 outputs. But for some reason it only shows 137..? Is my formatting off? When I change 01/01/2018 to 1/1/2018 it then only shows 59 outputs? Pulling my hair out over something so simple - yet difficult things seem to be easy! AAARRRGGH!! Many thanks in advance.
0debug
int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) { int i; Picture *pic; s->mb_skipped = 0; assert(s->last_picture_ptr==NULL || s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3); if (s->pict_type != FF_B_TYPE && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->data[0]) { if(s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3){ free_frame_buffer(s, s->last_picture_ptr); if(!s->encoding){ for(i=0; i<MAX_PICTURE_COUNT; i++){ if(s->picture[i].data[0] && &s->picture[i] != s->next_picture_ptr && s->picture[i].reference){ av_log(avctx, AV_LOG_ERROR, "releasing zombie picture\n"); free_frame_buffer(s, &s->picture[i]); } } } } } alloc: if(!s->encoding){ for(i=0; i<MAX_PICTURE_COUNT; i++){ if(s->picture[i].data[0] && !s->picture[i].reference ){ free_frame_buffer(s, &s->picture[i]); } } if(s->current_picture_ptr && s->current_picture_ptr->data[0]==NULL) pic= s->current_picture_ptr; else{ i= ff_find_unused_picture(s, 0); pic= &s->picture[i]; } pic->reference= 0; if (!s->dropable){ if (s->codec_id == CODEC_ID_H264) pic->reference = s->picture_structure; else if (s->pict_type != FF_B_TYPE) pic->reference = 3; } pic->coded_picture_number= s->coded_picture_number++; if(ff_alloc_picture(s, pic, 0) < 0) return -1; s->current_picture_ptr= pic; s->current_picture_ptr->top_field_first= s->top_field_first; s->current_picture_ptr->interlaced_frame= !s->progressive_frame && !s->progressive_sequence; } s->current_picture_ptr->pict_type= s->pict_type; s->current_picture_ptr->key_frame= s->pict_type == FF_I_TYPE; ff_copy_picture(&s->current_picture, s->current_picture_ptr); if (s->pict_type != FF_B_TYPE) { s->last_picture_ptr= s->next_picture_ptr; if(!s->dropable) s->next_picture_ptr= s->current_picture_ptr; } if(s->last_picture_ptr) ff_copy_picture(&s->last_picture, s->last_picture_ptr); if(s->next_picture_ptr) ff_copy_picture(&s->next_picture, s->next_picture_ptr); if(s->pict_type != FF_I_TYPE && (s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL) && !s->dropable && s->codec_id != CODEC_ID_H264){ av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n"); assert(s->pict_type != FF_B_TYPE); goto alloc; } assert(s->pict_type == FF_I_TYPE || (s->last_picture_ptr && s->last_picture_ptr->data[0])); if(s->picture_structure!=PICT_FRAME && s->out_format != FMT_H264){ int i; for(i=0; i<4; i++){ if(s->picture_structure == PICT_BOTTOM_FIELD){ s->current_picture.data[i] += s->current_picture.linesize[i]; } s->current_picture.linesize[i] *= 2; s->last_picture.linesize[i] *=2; s->next_picture.linesize[i] *=2; } } s->hurry_up= s->avctx->hurry_up; s->error_recognition= avctx->error_recognition; if(s->mpeg_quant || s->codec_id == CODEC_ID_MPEG2VIDEO){ s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra; s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter; }else if(s->out_format == FMT_H263 || s->out_format == FMT_H261){ s->dct_unquantize_intra = s->dct_unquantize_h263_intra; s->dct_unquantize_inter = s->dct_unquantize_h263_inter; }else{ s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra; s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter; } if(s->dct_error_sum){ assert(s->avctx->noise_reduction && s->encoding); update_noise_reduction(s); } if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration) return ff_xvmc_field_start(s, avctx); return 0; }
1threat
webpack 4 - split chunks plugin for multiple entries : <p>Using <a href="https://webpack.js.org/plugins/split-chunks-plugin/" rel="noreferrer">split chunks plugin</a> with the following config :</p> <pre><code>{ entry: { entry1: [entry1.js], entry2: [entry2.js], entry3: [entry3.js], ... } optimization: { splitChunks: { chunks: "all" } } } </code></pre> <p>The code would get perfectly split into:</p> <pre><code>vendors-entry1-entry2-entry3.js // common for all vendors-entry1-entry3.js // vendors only required by both entry1, entry3 entry1-entry2.js // common code of entry1 and entry2 entry1.js // unique entry's code entry2.js entry3.js </code></pre> <p>Question is, <strong>how do i now use the specific vendors per entry in my html (or ejs in my specific case)</strong>?</p> <p>Using <a href="https://webpack.js.org/plugins/html-webpack-plugin/" rel="noreferrer">HtmlWebpackPlugin</a> as recommended would simply create an index.html which loads all of the above, although the use case is clearly:</p> <p>When rendering <strong>entry1</strong> page - load:</p> <pre><code>vendors-entry1-entry2-entry3.js vendors-entry1-entry3.js entry1-entry2.js entry1.js </code></pre> <p>When rendering <strong>entry2</strong> page - load:</p> <pre><code>vendors-entry1-entry2-entry3.js entry1-entry2.js entry2.js </code></pre> <p>etc..</p>
0debug
Node.js Socket.io page refresh multiple connections : <p>i have this simple node.js Servercode using socket.io (1.5):</p> <pre><code>var io = require('socket.io').listen(8080); io.on('connection', function(socket) { console.log(' %s sockets connected', io.engine.clientsCount); socket.on('disconnect', function() { console.log("disconnect: ", socket.id); }); }); </code></pre> <p>If i run this code und press F5 several times, in some cases new connection is created, before the old one is disconnected. After some time, i think its the Heartbeat Timout, all the connections will be closed. See the result:</p> <pre><code> 2 sockets connected 3 sockets connected 4 sockets connected 5 sockets connected 6 sockets connected 7 sockets connected 8 sockets connected 9 sockets connected 10 sockets connected 11 sockets connected disconnect: 0h_9pkbAaE3ftKT9AAAL 11 sockets connected 12 sockets connected 13 sockets connected 14 sockets connected disconnect: oB4HQRCOY1UIvvZkAAAP 14 sockets connected 15 sockets connected disconnect: LiIN0oDVoqbePgxFAAAR 15 sockets connected 16 sockets connected 17 sockets connected 18 sockets connected disconnect: zxvk-uhWABHzmu1uAAAV 18 sockets connected 19 sockets connected 20 sockets connected disconnect: FlboxgTzcjf6ScffAAAY 20 sockets connected 21 sockets connected disconnect: 9UGXbnzukfGX_UtWAAAa 21 sockets connected disconnect: pAfXOEz6RocKZdoZAAAb 21 sockets connected disconnect: DIhTyVgG2LYBawaiAAAc 21 sockets connected disconnect: W4XOc1iRymfTE2U0AAAd 21 sockets connected disconnect: WZzegGPcoGDNLRTGAAAe 21 sockets connected 22 sockets connected disconnect: KVR3-fYH0cz77BmgAAAC disconnect: ANQknhnxr4l-OAuIAAAD disconnect: KZE5orNx6u9MbOArAAAE disconnect: TS6LL3asXrcznfcPAAAF disconnect: SVNxS3I7KqecdqKhAAAG disconnect: IE2WE5Y0PJzvxgBfAAAH disconnect: v69bdJav9PjpThBGAAAI disconnect: mJKT1ggfOOTshZKgAAAJ disconnect: YlycVjdcWe0emCAcAAAK disconnect: MoIDJSzP_L-1RUwuAAAM disconnect: wAl0x5qwCkrnDDYQAAAN disconnect: eiTlPEk2Hx_X-L-fAAAO disconnect: KgkrXxzG_EpXOsPTAAAQ disconnect: Lvf3kK-6XXEbu3NWAAAS disconnect: -hOoGdYOIvVK04K_AAAT disconnect: 3EUmaAYpK-U3Ss9tAAAU disconnect: HQ6M98FebtKlU3OfAAAW disconnect: OwgrbRBYbS4j84nmAAAX disconnect: yN8FZAP4RjUNl2MeAAAZ disconnect: K9IFTjlgAWzdNfpUAAAf </code></pre> <p>My Question is: Is this a Bug or is this the normal behavior of socket.io? How can i prevent the connection flooding, simple pressing F5?</p> <p>Best Regards Marc</p>
0debug
Firebase Cloud Function Repeatedly Fails Due to Quota Error : <p>I have a Firebase Cloud Function that is triggered by an <code>onCreate</code> at a path in my Realtime database. Yesterday, after doing some basic testing, I began to get "quota exceeded" errors in the Cloud Functions Log. What was troubling though, is that the error kept coming, first every 2 seconds or so, then ramping up to every 8 seconds or so, for about 1.5 hours.</p> <p>Here's a small segment of the trouble:</p> <p><a href="https://i.stack.imgur.com/nH7Dg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nH7Dg.png" alt="Errors. Errors. More Errors. *Sigh*"></a></p> <p>I took a look at the documentation covering <a href="https://firebase.google.com/docs/functions/retries" rel="noreferrer">Retrying Asynchronous Functions</a> and it seems clear that in most cases a function will stop executing and the event will be discarded if an error occurs. The triggering event did not seem to be getting cleared in my case, perhaps because the error I was getting was coming from outside of my function. Here's the full error text:</p> <blockquote> <p>Error: quota exceeded (DNS resolutions : per 100 seconds); to increase quotas, enable billing in your project at <a href="https://console.cloud.google.com/billing?project=myproject" rel="noreferrer">https://console.cloud.google.com/billing?project=myproject</a>. Function cannot be executed.</p> </blockquote> <p><strong>Yes, I realize that a quota issue is easily solved by moving to the Blaze plan, which I will be doing soon, but before I do, I'd like to understand how to handle this case should it happen in the future.</strong> I had to re-deploy my functions to get the Error to stop happening. After studying the docs, it sounds as though I also could have deleted the function to stop the error, but neither re-deploying or deleting functions seems like a great path to take once my app reaches production.</p> <p>My thought is that I must have been stuck in a retry loop internal to the Firebase Cloud function service. None of my logging was being hit (some of which would happen on function start, and some during a function run), plus the message says "Function cannot be executed", which to me means that the Error happened before my code was ever executed. Another function which is triggered by the same event was logging an identical Error.</p> <p>So, to anyone in the know, my questions are as follows:</p> <ol> <li>For cases where functions seem to be stuck in a loop, is redeployment or deletion the ONLY path to recovery? What other possible approaches might I have taken?</li> <li>Is there a way I can handle an Error that is coming from outside my implementation? Can an Error like this be raised by the service or do Errors ONLY originate in my code? My guess is that I'm limited to monitoring the logs for such failures, but perhaps there are other possible actions that can be taken to make my service more robust.</li> </ol> <p>Finally, a few further notes to address follow-up questions some may have:</p> <ul> <li><p>Yes, the repeating Error did prevent any new invocations of the function in question to take place. Other functions could still be executed, except for the one other that is triggered by the same event.</p></li> <li><p>Yes, I can recreate the behavior to an extent. If I set the DNS Resolutions quota per 100 seconds to a low value (5, for example), and do a few executions, I get the same error, repeating every 8 seconds or so. Oddly though, when I recreate in this manner, it recovers on its own after about 10-20 throws, seemingly around the time the 100 seconds has elapsed, which makes sense. In the case of the original incident, the errors repeated for more than an hour, at which point I decided to re-deploy, stopping them.</p></li> <li><p>Yes, I do see the most recent <code>Function execution took ### ms, finished with status 'ok'</code> message in my logs before the Errors start rolling in. After the Errors are done repeating, I do see a the last-in triggering data get processed by the function successfully. This is what caused me to wonder if it was the triggering event that was causing Cloud Functions to keep trying.</p></li> <li><p>No, my function does not write to a location that would retrigger itself.</p></li> <li><p>Yes, I realize I could easily resolve this by <strong>moving to the Blaze plan</strong> to get a much higher quota. <strong>I will be doing that.</strong> First though, I'd like to understand the mechanics of what has gone wrong so I can make any available improvements.</p></li> </ul>
0debug
Convert Graphql to SQL? : <p>We have existing SQL Server database and we are using C#. Lets say our mobile client send a graphql to server. How can I convert this SQL, so that my client get the data what he expect?</p>
0debug
static int mxf_write_footer(AVFormatContext *s) { MXFContext *mxf = s->priv_data; AVIOContext *pb = s->pb; mxf->duration = mxf->last_indexed_edit_unit + mxf->edit_units_count; mxf_write_klv_fill(s); mxf->footer_partition_offset = avio_tell(pb); if (mxf->edit_unit_byte_count) { mxf_write_partition(s, 0, 0, footer_partition_key, 0); } else { mxf_write_partition(s, 0, 2, footer_partition_key, 0); mxf_write_klv_fill(s); mxf_write_index_table_segment(s); } mxf_write_klv_fill(s); mxf_write_random_index_pack(s); if (s->pb->seekable) { avio_seek(pb, 0, SEEK_SET); if (mxf->edit_unit_byte_count) { mxf_write_partition(s, 1, 2, header_closed_partition_key, 1); mxf_write_klv_fill(s); mxf_write_index_table_segment(s); } else { mxf_write_partition(s, 0, 0, header_closed_partition_key, 1); } } ff_audio_interleave_close(s); av_freep(&mxf->index_entries); av_freep(&mxf->body_partition_offset); av_freep(&mxf->timecode_track->priv_data); av_freep(&mxf->timecode_track); mxf_free(s); return 0; }
1threat
Can not find module “@angular-devkit/build-angular” : <p>Using npm, I followed the getting started directions on the Angular CLI quick start page. </p> <p><a href="https://angular.io/guide/quickstart" rel="noreferrer" title="Angular CLI Quickstart">Angular CLI Quickstart</a></p> <p>Running <code>ng serve --open</code> after creating and going into my new project "frontend" gave this error:</p> <pre><code>Could not find module "@angular-devkit/build-angular" from "C:\\Users\\Brandon\\project-name\\frontend". Error: Could not find module "@angular-devkit/build-angular" from "C:\\Users\\Brandon\\project-name\\frontend". at Object.resolve (C:\Users\Brandon\project-name\node_modules\@angular-devkit\core\node\resolve.js:141:11) at Observable.rxjs_1.Observable [as _subscribe] (C:\Users\Brandon\project-name\node_modules\@angular-devkit\architect\src\architect.js:132:40) </code></pre> <p>I have tried suggestions from the other question similar to mine but it did not work. Answer was to run <code>npm install --save-dev @angular-devkit/build-angular</code>.</p> <p><a href="https://stackoverflow.com/questions/50333003/could-not-find-module-angular-devkit-build-angular">Similar Question</a></p> <p>I have also deleted modules, cleared cache, then did an install which also did not work.</p> <p>package.json:</p> <pre><code>{ "name": "frontend", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "^6.0.2", "@angular/common": "^6.0.2", "@angular/compiler": "^6.0.2", "@angular/core": "^6.0.2", "@angular/forms": "^6.0.2", "@angular/http": "^6.0.2", "@angular/platform-browser": "^6.0.2", "@angular/platform-browser-dynamic": "^6.0.2", "@angular/router": "^6.0.2", "core-js": "^2.5.4", "rxjs": "^6.0.0", "zone.js": "^0.8.26" }, "devDependencies": { "@angular/compiler-cli": "^6.0.2", "@angular-devkit/build-angular": "~0.6.3", "typescript": "~2.7.2", "@angular/cli": "^6.0.3", "@angular/language-service": "^6.0.2", "@types/jasmine": "~2.8.6", "@types/jasminewd2": "~2.0.3", "@types/node": "~8.9.4", "codelyzer": "~4.2.1", "jasmine-core": "~2.99.1", "jasmine-spec-reporter": "~4.2.1", "karma": "~1.7.1", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~1.4.2", "karma-jasmine": "~1.1.1", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.3.0", "ts-node": "~5.0.1", "tslint": "~5.9.1" } } </code></pre> <p>angular.json:</p> <pre><code> { "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "newProjectRoot": "projects", "projects": { "frontend": { "root": "", "sourceRoot": "src", "projectType": "application", "prefix": "app", "schematics": {}, "architect": { "build": { "builder": "@angular-devkit/build-angular:browser", "options": { "outputPath": "dist/frontend", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", "tsConfig": "src/tsconfig.app.json", "assets": [ "src/favicon.ico", "src/assets" ], "styles": [ "src/styles.css" ], "scripts": [] }, "configurations": { "production": { "fileReplacements": [ { "replace": "src/environments/environment.ts", "with": "src/environments/environment.prod.ts" } ], "optimization": true, "outputHashing": "all", "sourceMap": false, "extractCss": true, "namedChunks": false, "aot": true, "extractLicenses": true, "vendorChunk": false, "buildOptimizer": true } } }, "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { "browserTarget": "frontend:build" }, "configurations": { "production": { "browserTarget": "frontend:build:production" } } }, "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { "browserTarget": "frontend:build" } }, "test": { "builder": "@angular-devkit/build-angular:karma", "options": { "main": "src/test.ts", "polyfills": "src/polyfills.ts", "tsConfig": "src/tsconfig.spec.json", "karmaConfig": "src/karma.conf.js", "styles": [ "src/styles.css" ], "scripts": [], "assets": [ "src/favicon.ico", "src/assets" ] } }, "lint": { "builder": "@angular-devkit/build-angular:tslint", "options": { "tsConfig": [ "src/tsconfig.app.json", "src/tsconfig.spec.json" ], "exclude": [ "**/node_modules/**" ] } } } }, "frontend-e2e": { "root": "e2e/", "projectType": "application", "architect": { "e2e": { "builder": "@angular-devkit/build-angular:protractor", "options": { "protractorConfig": "e2e/protractor.conf.js", "devServerTarget": "frontend:serve" } }, "lint": { "builder": "@angular-devkit/build-angular:tslint", "options": { "tsConfig": "e2e/tsconfig.e2e.json", "exclude": [ "**/node_modules/**" ] } } } } }, "defaultProject": "frontend" } </code></pre>
0debug
av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v) { MpegEncContext *s = &v->s; int i; int mb_height = FFALIGN(s->mb_height, 2); v->mv_type_mb_plane = av_malloc (s->mb_stride * mb_height); v->direct_mb_plane = av_malloc (s->mb_stride * mb_height); v->forward_mb_plane = av_malloc (s->mb_stride * mb_height); v->fieldtx_plane = av_mallocz(s->mb_stride * mb_height); v->acpred_plane = av_malloc (s->mb_stride * mb_height); v->over_flags_plane = av_malloc (s->mb_stride * mb_height); if (!v->mv_type_mb_plane || !v->direct_mb_plane || !v->forward_mb_plane || !v->fieldtx_plane || !v->acpred_plane || !v->over_flags_plane) goto error; v->n_allocated_blks = s->mb_width + 2; v->block = av_malloc(sizeof(*v->block) * v->n_allocated_blks); v->cbp_base = av_malloc(sizeof(v->cbp_base[0]) * 2 * s->mb_stride); if (!v->block || !v->cbp_base) goto error; v->cbp = v->cbp_base + s->mb_stride; v->ttblk_base = av_malloc(sizeof(v->ttblk_base[0]) * 2 * s->mb_stride); if (!v->ttblk_base) goto error; v->ttblk = v->ttblk_base + s->mb_stride; v->is_intra_base = av_mallocz(sizeof(v->is_intra_base[0]) * 2 * s->mb_stride); if (!v->is_intra_base) goto error; v->is_intra = v->is_intra_base + s->mb_stride; v->luma_mv_base = av_malloc(sizeof(v->luma_mv_base[0]) * 2 * s->mb_stride); if (!v->luma_mv_base) goto error; v->luma_mv = v->luma_mv_base + s->mb_stride; v->mb_type_base = av_malloc(s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2); if (!v->mb_type_base) goto error; v->mb_type[0] = v->mb_type_base + s->b8_stride + 1; v->mb_type[1] = v->mb_type_base + s->b8_stride * (mb_height * 2 + 1) + s->mb_stride + 1; v->mb_type[2] = v->mb_type[1] + s->mb_stride * (mb_height + 1); v->blk_mv_type_base = av_mallocz( s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2); if (!v->blk_mv_type_base) goto error; v->blk_mv_type = v->blk_mv_type_base + s->b8_stride + 1; v->mv_f_base = av_mallocz(2 * (s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2)); if (!v->mv_f_base) goto error; v->mv_f[0] = v->mv_f_base + s->b8_stride + 1; v->mv_f[1] = v->mv_f[0] + (s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2); v->mv_f_next_base = av_mallocz(2 * (s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2)); if (!v->mv_f_next_base) goto error; v->mv_f_next[0] = v->mv_f_next_base + s->b8_stride + 1; v->mv_f_next[1] = v->mv_f_next[0] + (s->b8_stride * (mb_height * 2 + 1) + s->mb_stride * (mb_height + 1) * 2); ff_intrax8_common_init(&v->x8,s); if (s->avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || s->avctx->codec_id == AV_CODEC_ID_VC1IMAGE) { for (i = 0; i < 4; i++) { v->sr_rows[i >> 1][i & 1] = av_malloc(v->output_width); if (!v->sr_rows[i >> 1][i & 1]) goto error; } } return 0; error: ff_vc1_decode_end(s->avctx); return AVERROR(ENOMEM); }
1threat
static void vp8_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe, VP8Frame *prev_frame) { VP8Context *s = avctx->priv_data; int mb_x, mb_y; s->mv_min.y = -MARGIN; s->mv_max.y = ((s->mb_height - 1) << 6) + MARGIN; for (mb_y = 0; mb_y < s->mb_height; mb_y++) { VP8Macroblock *mb = s->macroblocks_base + ((s->mb_width + 1) * (mb_y + 1) + 1); int mb_xy = mb_y * s->mb_width; AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED * 0x01010101); s->mv_min.x = -MARGIN; s->mv_max.x = ((s->mb_width - 1) << 6) + MARGIN; for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) { if (mb_y == 0) AV_WN32A((mb - s->mb_width - 1)->intra4x4_pred_mode_top, DC_PRED * 0x01010101); decode_mb_mode(s, mb, mb_x, mb_y, curframe->seg_map->data + mb_xy, prev_frame && prev_frame->seg_map ? prev_frame->seg_map->data + mb_xy : NULL, 1); s->mv_min.x -= 64; s->mv_max.x -= 64; } s->mv_min.y -= 64; s->mv_max.y -= 64; } }
1threat
The server returned HTTP 400 Bad Request. Response body: [b'{"ok":false,"error_code":400,"description":"Bad Request: message can\'t be deleted"}']" : Добрый день, при попытке удалить сообщение моим ботом, выдается ошибка: 2018-04-10 13:58:57,646 (__init__.py:292 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body: [b'{"ok":false,"error_code":400,"description":"Bad Request: message can\'t be deleted"}']" в чем тут может быть проблема? import config import telebot bot = telebot.TeleBot(config.token) @bot.message_handler(content_types=["text"]) def repeat_all_messages(message): bot.send_message(message.chat.id, 'Hello World') bot.delete_message(message.chat.id, message.message_id) if __name__ == '__main__': bot.polling(none_stop=True)
0debug
static int rd_frame(CinepakEncContext *s, AVFrame *frame, unsigned char *buf, int buf_size) { int num_strips, strip, h, i, y, size, temp_size, best_size; AVPicture last_pict, pict, scratch_pict; int64_t best_score = 0, score, score_temp; for(num_strips = MIN_STRIPS; num_strips <= MAX_STRIPS && num_strips <= s->h / MB_SIZE; num_strips++) { score = 0; size = 0; h = s->h / num_strips; h += 4 - (h & 3); for(strip = 0; strip < num_strips; strip++) { y = strip*h; get_sub_picture(s, 0, y, (AVPicture*)frame, &pict); get_sub_picture(s, 0, y, (AVPicture*)&s->last_frame, &last_pict); get_sub_picture(s, 0, y, (AVPicture*)&s->scratch_frame, &scratch_pict); if((temp_size = rd_strip(s, y, FFMIN(h, s->h - y), frame->key_frame, &last_pict, &pict, &scratch_pict, s->frame_buf + CVID_HEADER_SIZE, &score_temp)) < 0) return temp_size; score += score_temp; size += temp_size; } if(best_score == 0 || score < best_score) { best_score = score; best_size = size + write_cvid_header(s, s->frame_buf, num_strips, size); av_log(s->avctx, AV_LOG_INFO, "best number of strips so far: %2i, %12li, %i B\n", num_strips, score, best_size); FFSWAP(AVFrame, s->best_frame, s->scratch_frame); } } memcpy(buf, s->frame_buf, best_size); return best_size; }
1threat
int qemu_set_fd_handler(int fd, IOHandler *fd_read, IOHandler *fd_write, void *opaque) { return qemu_set_fd_handler2(fd, NULL, fd_read, fd_write, opaque); }
1threat
static void validate_test_add(const char *testpath, TestInputVisitorData *data, void (*test_func)(TestInputVisitorData *data, const void *user_data)) { g_test_add(testpath, TestInputVisitorData, data, NULL, test_func, validate_teardown); }
1threat
How/where C++ namespace std is defined (link to documentation/standard) : <p>This question seems to have been asked many times before but the answers just poo-poo or pee-pee around the issue. I want to find a source in official documentation and standards where this issue is addressed. Apparently, "std" is implied by the files included with #include. Does it mean that there is no explicit "namespace std {...}" anywhere and "std" is like a keyword? I want to know the official definition of this keyword. I want to know how and what is included in "std", everything that is not covered by the definition of a regular namespace with explicit "namespace name"</p>
0debug
QTestState *qtest_init_without_qmp_handshake(const char *extra_args) { QTestState *s; int sock, qmpsock, i; gchar *socket_path; gchar *qmp_socket_path; gchar *command; const char *qemu_binary; qemu_binary = getenv("QTEST_QEMU_BINARY"); g_assert(qemu_binary != NULL); s = g_malloc(sizeof(*s)); socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid()); qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid()); sock = init_socket(socket_path); qmpsock = init_socket(qmp_socket_path); qtest_add_abrt_handler(kill_qemu_hook_func, s); s->qemu_pid = fork(); if (s->qemu_pid == 0) { setenv("QEMU_AUDIO_DRV", "none", true); command = g_strdup_printf("exec %s " "-qtest unix:%s,nowait " "-qtest-log %s " "-qmp unix:%s,nowait " "-machine accel=qtest " "-display none " "%s", qemu_binary, socket_path, getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null", qmp_socket_path, extra_args ?: ""); execlp("/bin/sh", "sh", "-c", command, NULL); exit(1); } s->fd = socket_accept(sock); if (s->fd >= 0) { s->qmp_fd = socket_accept(qmpsock); } g_free(socket_path); g_free(qmp_socket_path); g_assert(s->fd >= 0 && s->qmp_fd >= 0); s->rx = g_string_new(""); for (i = 0; i < MAX_IRQ; i++) { s->irq_level[i] = false; } if (getenv("QTEST_STOP")) { kill(s->qemu_pid, SIGSTOP); } s->big_endian = qtest_query_target_endianness(s); return s; }
1threat
Turn formatted String into Date : <p>So I have a Date variable which I formatted using the following code:</p> <pre><code>SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date currentDate = new Date(); String date = format.format(currentDate); </code></pre> <p>I then put the String 'date' into my database.</p> <p>Now: I have to pull it out of the database. It comes out as, of course, a String in the format shown above.</p> <p>My question is how do I turn this String into a date variable? I'm very much struggling to find the most efficient way. </p> <p>Thank you.</p>
0debug
static int64_t run_opencl_bench(AVOpenCLExternalEnv *ext_opencl_env) { int i, arg = 0, width = 1920, height = 1088; int64_t start, ret = 0; cl_int status; size_t kernel_len; char *inbuf; int *mask; int buf_size = width * height * sizeof(char); int mask_size = sizeof(uint32_t) * 128; cl_mem cl_mask, cl_inbuf, cl_outbuf; cl_kernel kernel = NULL; cl_program program = NULL; size_t local_work_size_2d[2] = {16, 16}; size_t global_work_size_2d[2] = {(size_t)width, (size_t)height}; if (!(inbuf = av_malloc(buf_size)) || !(mask = av_malloc(mask_size))) { av_log(NULL, AV_LOG_ERROR, "Out of memory\n"); ret = AVERROR(ENOMEM); goto end; } fill_rand_int((int*)inbuf, buf_size/4); fill_rand_int(mask, mask_size/4); CREATEBUF(cl_mask, CL_MEM_READ_ONLY, mask_size); CREATEBUF(cl_inbuf, CL_MEM_READ_ONLY, buf_size); CREATEBUF(cl_outbuf, CL_MEM_READ_WRITE, buf_size); kernel_len = strlen(ocl_bench_source); program = clCreateProgramWithSource(ext_opencl_env->context, 1, &ocl_bench_source, &kernel_len, &status); if (status != CL_SUCCESS || !program) { av_log(NULL, AV_LOG_ERROR, "OpenCL unable to create benchmark program\n"); ret = AVERROR_EXTERNAL; goto end; } status = clBuildProgram(program, 1, &(ext_opencl_env->device_id), NULL, NULL, NULL); if (status != CL_SUCCESS) { av_log(NULL, AV_LOG_ERROR, "OpenCL unable to build benchmark program\n"); ret = AVERROR_EXTERNAL; goto end; } kernel = clCreateKernel(program, "unsharp_bench", &status); if (status != CL_SUCCESS) { av_log(NULL, AV_LOG_ERROR, "OpenCL unable to create benchmark kernel\n"); ret = AVERROR_EXTERNAL; goto end; } OCLCHECK(clEnqueueWriteBuffer, ext_opencl_env->command_queue, cl_inbuf, CL_TRUE, 0, buf_size, inbuf, 0, NULL, NULL); OCLCHECK(clEnqueueWriteBuffer, ext_opencl_env->command_queue, cl_mask, CL_TRUE, 0, mask_size, mask, 0, NULL, NULL); OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_mem), &cl_inbuf); OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_mem), &cl_outbuf); OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_mem), &cl_mask); OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_int), &width); OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_int), &height); start = av_gettime_relative(); for (i = 0; i < OPENCL_NB_ITER; i++) OCLCHECK(clEnqueueNDRangeKernel, ext_opencl_env->command_queue, kernel, 2, NULL, global_work_size_2d, local_work_size_2d, 0, NULL, NULL); clFinish(ext_opencl_env->command_queue); ret = (av_gettime_relative() - start)/OPENCL_NB_ITER; end: if (kernel) clReleaseKernel(kernel); if (program) clReleaseProgram(program); if (cl_inbuf) clReleaseMemObject(cl_inbuf); if (cl_outbuf) clReleaseMemObject(cl_outbuf); if (cl_mask) clReleaseMemObject(cl_mask); av_free(inbuf); av_free(mask); return ret; }
1threat
How do I merge two tables in sql server SPECIFICALLY using WINDOWS FORM C# and not SQL : I have two tables: StudentSection1 with the following fields and information: StudentID (int)(PK) StudentName (varchar(100)) StudentGender (varchar(100)) 1 Henry Male 2 Scarlette Female StudentSection2 with the following fields and information: StudentID (int)(PK) StudentName (varchar(100)) StudentGender (varchar(100)) 1 Jack Male 2 Elizabeth Female Name of database: StudentDB *I know that there are related questions here, but all I see are answers that only cater to manipulating sql directly and not windows form c#. And I know that there Student ID's should be different, but let's just say each section has it's own ID numbers for it's students (as impossible as it may seem) Anyway, what I want to know is how I can manipulate this SPECIFICALLY in c# WINDOWS FORM (not in sql server) in such a way that when I press a button in windows form, it will merge both tables together PERMANENTLY in sql server. I would prefer if maybe StudentSection2 is combined into StudentSection1, but any workaround is fine. I'm pretty sure this involves code which contains connectionstring etc, but I'm not really sure about this area. Any help would be really useful, thank you very much guys.
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
When should we use Web SQL or IndexedDB? What are the use cases? : <p>Recently I have come across Web SQL and IndexedDB provided by browsers. I want to understand the use cases when these can be used.</p>
0debug
static int nbd_send_negotiate(NBDClient *client) { int csock = client->sock; char buf[8 + 8 + 8 + 128]; int rc; const int myflags = (NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_TRIM | NBD_FLAG_SEND_FLUSH | NBD_FLAG_SEND_FUA); qemu_set_block(csock); rc = -EINVAL; TRACE("Beginning negotiation."); memset(buf, 0, sizeof(buf)); memcpy(buf, "NBDMAGIC", 8); if (client->exp) { assert ((client->exp->nbdflags & ~65535) == 0); cpu_to_be64w((uint64_t*)(buf + 8), NBD_CLIENT_MAGIC); cpu_to_be64w((uint64_t*)(buf + 16), client->exp->size); cpu_to_be16w((uint16_t*)(buf + 26), client->exp->nbdflags | myflags); } else { cpu_to_be64w((uint64_t*)(buf + 8), NBD_OPTS_MAGIC); cpu_to_be16w((uint16_t *)(buf + 16), NBD_FLAG_FIXED_NEWSTYLE); } if (client->exp) { if (write_sync(csock, buf, sizeof(buf)) != sizeof(buf)) { LOG("write failed"); goto fail; } } else { if (write_sync(csock, buf, 18) != 18) { LOG("write failed"); goto fail; } rc = nbd_receive_options(client); if (rc != 0) { LOG("option negotiation failed"); goto fail; } assert ((client->exp->nbdflags & ~65535) == 0); cpu_to_be64w((uint64_t*)(buf + 18), client->exp->size); cpu_to_be16w((uint16_t*)(buf + 26), client->exp->nbdflags | myflags); if (write_sync(csock, buf + 18, sizeof(buf) - 18) != sizeof(buf) - 18) { LOG("write failed"); goto fail; } } TRACE("Negotiation succeeded."); rc = 0; fail: qemu_set_nonblock(csock); return rc; }
1threat
static int omap2_validate_addr(struct omap_mpu_state_s *s, target_phys_addr_t addr) { return 1; }
1threat
static int ffm2_read_header(AVFormatContext *s) { FFMContext *ffm = s->priv_data; AVStream *st; AVIOContext *pb = s->pb; AVCodecContext *codec, *dummy_codec = NULL; AVCodecParameters *codecpar; const AVCodecDescriptor *codec_desc; int ret; int f_main = 0, f_cprv = -1, f_stvi = -1, f_stau = -1; AVCodec *enc; char *buffer; ffm->packet_size = avio_rb32(pb); if (ffm->packet_size != FFM_PACKET_SIZE) { av_log(s, AV_LOG_ERROR, "Invalid packet size %d, expected size was %d\n", ffm->packet_size, FFM_PACKET_SIZE); ret = AVERROR_INVALIDDATA; goto fail; } ffm->write_index = avio_rb64(pb); if (pb->seekable) { ffm->file_size = avio_size(pb); if (ffm->write_index && 0) adjust_write_index(s); } else { ffm->file_size = (UINT64_C(1) << 63) - 1; } dummy_codec = avcodec_alloc_context3(NULL); while(!avio_feof(pb)) { unsigned id = avio_rb32(pb); unsigned size = avio_rb32(pb); int64_t next = avio_tell(pb) + size; char rc_eq_buf[128]; if(!id) break; switch(id) { case MKBETAG('M', 'A', 'I', 'N'): if (f_main++) { ret = AVERROR(EINVAL); goto fail; } avio_rb32(pb); avio_rb32(pb); break; case MKBETAG('C', 'O', 'M', 'M'): f_cprv = f_stvi = f_stau = 0; st = avformat_new_stream(s, NULL); if (!st) { ret = AVERROR(ENOMEM); goto fail; } avpriv_set_pts_info(st, 64, 1, 1000000); codec = st->codec; codecpar = st->codecpar; codecpar->codec_id = avio_rb32(pb); codec_desc = avcodec_descriptor_get(codecpar->codec_id); if (!codec_desc) { av_log(s, AV_LOG_ERROR, "Invalid codec id: %d\n", codecpar->codec_id); codecpar->codec_id = AV_CODEC_ID_NONE; ret = AVERROR_INVALIDDATA; goto fail; } codecpar->codec_type = avio_r8(pb); if (codecpar->codec_type != codec_desc->type) { av_log(s, AV_LOG_ERROR, "Codec type mismatch: expected %d, found %d\n", codec_desc->type, codecpar->codec_type); codecpar->codec_id = AV_CODEC_ID_NONE; codecpar->codec_type = AVMEDIA_TYPE_UNKNOWN; ret = AVERROR_INVALIDDATA; goto fail; } codecpar->bit_rate = avio_rb32(pb); if (codecpar->bit_rate < 0) { av_log(codec, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", codecpar->bit_rate); ret = AVERROR_INVALIDDATA; goto fail; } codec->flags = avio_rb32(pb); codec->flags2 = avio_rb32(pb); codec->debug = avio_rb32(pb); if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { int size = avio_rb32(pb); if (size < 0 || size >= FF_MAX_EXTRADATA_SIZE) { av_log(s, AV_LOG_ERROR, "Invalid extradata size %d\n", size); ret = AVERROR_INVALIDDATA; goto fail; } codecpar->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE); if (!codecpar->extradata) return AVERROR(ENOMEM); codecpar->extradata_size = size; avio_read(pb, codecpar->extradata, size); } break; case MKBETAG('S', 'T', 'V', 'I'): if (f_stvi++) { ret = AVERROR(EINVAL); goto fail; } codec->time_base.num = avio_rb32(pb); codec->time_base.den = avio_rb32(pb); if (codec->time_base.num <= 0 || codec->time_base.den <= 0) { av_log(s, AV_LOG_ERROR, "Invalid time base %d/%d\n", codec->time_base.num, codec->time_base.den); ret = AVERROR_INVALIDDATA; goto fail; } codecpar->width = avio_rb16(pb); codecpar->height = avio_rb16(pb); ret = av_image_check_size(codecpar->width, codecpar->height, 0, s); if (ret < 0) goto fail; avio_rb16(pb); codecpar->format = avio_rb32(pb); if (!av_pix_fmt_desc_get(codecpar->format)) { av_log(s, AV_LOG_ERROR, "Invalid pix fmt id: %d\n", codecpar->format); codecpar->format = AV_PIX_FMT_NONE; goto fail; } avio_r8(pb); avio_r8(pb); avio_r8(pb); avio_rb16(pb); avio_rb16(pb); avio_rb32(pb); avio_get_str(pb, INT_MAX, rc_eq_buf, sizeof(rc_eq_buf)); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb64(pb); avio_rb64(pb); avio_rb64(pb); avio_rb64(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb64(pb); codecpar->codec_tag = avio_rb32(pb); avio_r8(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb64(pb); avio_rb64(pb); avio_rb32(pb); avio_rb32(pb); break; case MKBETAG('S', 'T', 'A', 'U'): if (f_stau++) { ret = AVERROR(EINVAL); goto fail; } codecpar->sample_rate = avio_rb32(pb); VALIDATE_PARAMETER(sample_rate, "sample rate", codecpar->sample_rate < 0) codecpar->channels = avio_rl16(pb); VALIDATE_PARAMETER(channels, "number of channels", codecpar->channels < 0) codecpar->frame_size = avio_rl16(pb); VALIDATE_PARAMETER(frame_size, "frame size", codecpar->frame_size < 0) break; case MKBETAG('C', 'P', 'R', 'V'): if (f_cprv++) { ret = AVERROR(EINVAL); goto fail; } enc = avcodec_find_encoder(codecpar->codec_id); if (enc && enc->priv_data_size && enc->priv_class) { buffer = av_malloc(size + 1); if (!buffer) { ret = AVERROR(ENOMEM); goto fail; } avio_get_str(pb, size, buffer, size + 1); if ((ret = ffm_append_recommended_configuration(st, &buffer)) < 0) goto fail; } break; case MKBETAG('S', '2', 'V', 'I'): if (f_stvi++ || !size) { ret = AVERROR(EINVAL); goto fail; } buffer = av_malloc(size); if (!buffer) { ret = AVERROR(ENOMEM); goto fail; } avio_get_str(pb, INT_MAX, buffer, size); avcodec_parameters_to_context(dummy_codec, codecpar); av_set_options_string(dummy_codec, buffer, "=", ","); avcodec_parameters_from_context(codecpar, dummy_codec); if ((ret = ffm_append_recommended_configuration(st, &buffer)) < 0) goto fail; break; case MKBETAG('S', '2', 'A', 'U'): if (f_stau++ || !size) { ret = AVERROR(EINVAL); goto fail; } buffer = av_malloc(size); if (!buffer) { ret = AVERROR(ENOMEM); goto fail; } avio_get_str(pb, INT_MAX, buffer, size); avcodec_parameters_to_context(dummy_codec, codecpar); av_set_options_string(dummy_codec, buffer, "=", ","); avcodec_parameters_from_context(codecpar, dummy_codec); if ((ret = ffm_append_recommended_configuration(st, &buffer)) < 0) goto fail; break; } avio_seek(pb, next, SEEK_SET); } while ((avio_tell(pb) % ffm->packet_size) != 0 && !pb->eof_reached) avio_r8(pb); ffm->packet_ptr = ffm->packet; ffm->packet_end = ffm->packet; ffm->frame_offset = 0; ffm->dts = 0; ffm->read_state = READ_HEADER; ffm->first_packet = 1; avcodec_free_context(&dummy_codec); return 0; fail: avcodec_free_context(&dummy_codec); return ret; }
1threat
Laravel How to display $hidden attribute on model on paginate : <p>I'm using Laravel 5.5. I read about this and know this function and it works <a href="https://laravel.com/docs/5.5/eloquent-serialization#hiding-attributes-from-json" rel="noreferrer">makeVisible</a> </p> <pre><code>$hidden = ['password', 'remember_token', 'email']; </code></pre> <p>I can display email using </p> <pre><code>$profile = auth()-&gt;user()-&gt;find($request-&gt;user()-&gt;id); $profile-&gt;makeVisible(['email']); </code></pre> <p>On the frontend email is displayed. But it not works on many results like</p> <pre><code> // Get all users $users = User::with('role', 'level')-&gt;makeVisible(['email'])-&gt;paginate(10); // Doesn't work </code></pre> <p>Also try this method <a href="https://laracasts.com/discuss/channels/laravel/dynamic-hiddenvisible-attribute" rel="noreferrer">from Laracasts toJson</a> it works but I can't do it using paginate. Can you provide other methods or how to solve this? My aim is to display <code>email</code> column that is hidden. Thanks.</p>
0debug
Selenium unable to locate my elements(buttons) : <p>I want to press buttons using selenium, i faced an issue yesterday where i couldn't and simply turned out that my button is inside an iframe circling the entire webpage. this fixed it:</p> <pre><code>from time import sleep driver.switch_to.frame(driver.find_element_by_id("includedPage")) sleep(10) element = driver.find_element_by_xpath("//input[contains(@id, 'workbenchLst:j_id_id507') and @value='Add']") element.click() </code></pre> <p>after clicking on it i wanted to do same with other buttons on the page after but couldn't i just keep getting <code>Unable to locate element</code> for the iframe and all other elements in the page( that page has an iframe too inside a td like this):</p> <pre><code>&lt;td id="rightTdId"&gt; &lt;iframe id="includedPage" style="width:100%;" onload="reRenderReportLOV();;tickleSession('pageNavigation:sessionLink');disableContextMenu();showHidPanelMenu('hide','leftMenuj_id_1');" name="includedPage" src=".." marginheight="0" marginwidth="0" height="531" frameborder="0"&gt;&lt;/iframe&gt; &lt;/td&gt; </code></pre> <p>how can i get my buttons in that page and disable iframe's effect affect after locating it?</p>
0debug
I'm trying to create a javascript to return different answers for a radio button. : I'm trying to create a javascript to return different answers for a radio button. I have set up the html for a radio button form like this: <ul> <li> <h5>Does the PURPLE card have your number?</h5> <input type="radio" name="card1" value="A">yes<br> <input type="radio" name="card1" value="B">no<br> </li> <li> <h5>Does the GREEN card have your number?</h5> <input type="radio" name="card2" value="A">yes<br> <input type="radio" name="card2" value="B">no<br> </li> <li> <h5>Does the BLUE card have your number?</h5> <input type="radio" name="card3" value="A">yes<br> <input type="radio" name="card3" value="B">no<br> </li> <li> <h5>Does the PINK card have your number?</h5> <input type="radio" name="card4" value="A">yes<br> <input type="radio" name="card4" value="B">no<br> </li> <li> <h5>Does the RED card have your number?</h5> <input type="radio" name="card5" value="A">yes<br> <input type="radio" name="card5" value="B">no<br> </li> <li> <h5>Does the ORANGE card have your number?</h5> <input type="radio" name="card6" value="A">yes<br> <input type="radio" name="card6" value="B">no<br> </li> </ul> <button onclick="returnScore()">View Results</button> I am trying to make it so that a different result will be returned based on the which answers are yes are no. For example yes no no no no no would return answer 1. yes yes no no no no would return answer 2. etc. for 36 possible returns. this problem is coming from the card game here: http://www.counton.org/explorer/mathsmagic/realmystery/
0debug
how to extract data in between parathasis and append at the end of the line using python programing. : File.txt first_name NVARCHAR2(15) NOT NULL, middle_name NVARCHAR2(20) NOT NULL, last_name NVARCHAR2(11) NOT NULL, output i need:->output.txt first_name NVARCHAR2(15) NOT NULL,15 middle_name NVARCHAR2(20) NOT NULL,20 last_name NVARCHAR2(11) NOT NULL,11 how to extract data in File between parathasis and append at the end of the line using python programing.
0debug
D3.js add heading to graph : I want to add heading to my graph. Something like this : [What i want to achieve...][1] I have tried append.svg , append.text....etc but nothing seems to work. I,m just not able to write the correct CSS for this i guess. This code here works: header= d3.select("svg").append("text") .attr("x", 70) .attr("y", 20) .style("font-size", "16px") .style("text-decoration", "underline") .text("My graph heading..."); but i have problems in this one as i am unable to assign it width and height and background fill. When i assign it width or height it just does,nt gets applied. Also changing the display to block is not working... Running the code above makes a figure like this : [My current graph picture...][2] [1]: http://i.stack.imgur.com/lkREE.png [2]: http://i.stack.imgur.com/CRsGH.png
0debug
static void spitz_gpio_setup(PXA2xxState *cpu, int slots) { qemu_irq lcd_hsync; spitz_hsync = 0; lcd_hsync = qemu_allocate_irqs(spitz_lcd_hsync_handler, cpu, 1)[0]; pxa2xx_gpio_read_notifier(cpu->gpio, lcd_hsync); pxa2xx_lcd_vsync_notifier(cpu->lcd, lcd_hsync); pxa2xx_mmci_handlers(cpu->mmc, qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_SD_WP), qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_SD_DETECT)); qemu_irq_raise(qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_BAT_COVER)); qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_ON_RESET, cpu->reset); if (slots >= 1) pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[0], qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF1_IRQ), qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF1_CD)); if (slots >= 2) pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[1], qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF2_IRQ), qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF2_CD)); }
1threat
How to remove one polyline of several with jquery.ui.map : <p> I have two polylines on the gmap:<br /> Polyline 1 as 'route'<br /> Polyline 2 as 'other'<br /> i want to clear only one. How can i do that?<br /> I have tried with $('#map_canvas').gmap('clear', 'overlays > Polyline').route<br /> but it does not work<br /> </p>
0debug
void msix_notify(PCIDevice *dev, unsigned vector) { MSIMessage msg; if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector]) return; if (msix_is_masked(dev, vector)) { msix_set_pending(dev, vector); return; } msg = msix_get_message(dev, vector); stl_le_phys(&address_space_memory, msg.address, msg.data); }
1threat
static inline void downmix_3f_2r_to_stereo(float *samples) { int i; for (i = 0; i < 256; i++) { samples[i] += (samples[i + 256] + samples[i + 768]); samples[i + 256] = (samples[i + 512] + samples[i + 1024]); samples[i + 512] = samples[i + 768] = samples[i + 1024] = 0; } }
1threat
Google Map API not rendering because of invalid Lng value : <p>The google maps api will not render a map because it says the co ordinates I have given in the lat and long sections is not a number. Returning this console error</p> <p>InvalidValueError: setCenter: not a LatLng or LatLngLiteral: in property lng: not a number</p> <p>function initMap() {</p> <pre><code>const mapHere = document.getElementById("map"); const marker0 = { lat: -38.414506, long: 144.851985 }; const marker1 = { lat: -38.404351, long: 144.841955 }; const line = [marker0, marker1]; if (mapHere) { const map = new google.maps.Map(mapHere, { zoom: 8, mapTypeId: google.maps.MapTypeId.HYBRID, center: marker0 }); const marker_0 = new google.maps.Marker({ position: marker0, map: map, title: "marker 0" }); const marker_1 = new google.maps.Marker({ position: marker1, map: map, title: "marker 1" }); const lineSymbol = { path: 'M 0,-1 0,1', strokeOpacity: 1, scale: 4 }; var flightPath = new google.maps.Polyline({ path: line, geodesic: true, strokeColor: '#f8fc09', strokeOpacity: 0, icons: [{ icon: lineSymbol, offset: '0', repeat: '20px' }], strokeWeight: 2 }); flightPath.setMap(map); } </code></pre> <p>}</p> <p>This is the code i am using to try and render the map, it is partly generated in a php for each loop.</p> <p>Any ideas?</p>
0debug