problem
stringlengths
26
131k
labels
class label
2 classes
static int mov_read_pasp(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { const int num = get_be32(pb); const int den = get_be32(pb); AVStream * const st = c->fc->streams[c->fc->nb_streams-1]; if (den != 0) { if ((st->sample_aspect_ratio.den != 1 || st->sample_aspect_ratio.num) && (den != st->sample_aspect_ratio.den || num != st->sample_aspect_ratio.num)) av_log(c->fc, AV_LOG_WARNING, "sample aspect ratio already set to %d:%d, overriding by 'pasp' atom\n", st->sample_aspect_ratio.num, st->sample_aspect_ratio.den); st->sample_aspect_ratio.num = num; st->sample_aspect_ratio.den = den; } return 0; }
1threat
Can you still use c++ in Xcode? : I want to learn c++ on my Mac computer. A lot of forums recommend using Xcode, but when I downloaded it I realized that it only has options for Swift or Objective c. Is there still a way to use c++ in Xcode? Or is Objective c or Swift very similar to c++?
0debug
How to populate a drop-down list from a SQL table in C# : <p>I have a table in my SQL database, and using MVC on a ASP.NET Core:</p> <pre><code>CREATE TABLE [dbo].[ProgramVersion] ( [ID] INT IDENTITY (1, 1) NOT NULL, [Ver] VARCHAR (10) NOT NULL, [Released] DATETIME NOT NULL ); </code></pre> <p>Very simple. I have a scaffolded Edit.cshtml file, has a form for editing a records from a different table. I just want to use the records in the ProgramVersion table to populate an HTML select input (i.e. drop down list).</p> <ol> <li>How do I execute a simple query that gives me a result-set?</li> <li>How do I iterate through the result-set and simply put the 'Ver' string value into the Options tags in the drop-down list?</li> </ol> <p>(In PHP, this is dead simple, but C# is really frustrating me.)</p>
0debug
How to use Domain Transform Edge-Preserving technique for Image Enhancement in Matlab : I am interested in using this Domain Transform Edge-Preserving Video filtering technique (http://inf.ufrgs.br/~eslgastal/DomainTransform/ - source code available there) for image enhancement in Matlab (2015a). At around 3:12 on a 5-minute video (on the site linked above), they perform detail enhancement. I'm not sure how to use the filtered image to sharpen/deblur my original image. I usually use: H = padarray(2,[2 2]) - fspecial('gaussian' ,[5 5],2); sharpened = imfilter(I,H); to sharpen images, but I can't use imfilter with the filtered image from the edge-preserving technique (I've been testing with the normalized convolution filter from the source code) that I'm interested in. Can anyone advise me on what I can do to make use of this filtered image for sharpening/deblurring? Providing a snippet of code would be appreciated as well if possible.
0debug
my this query is working but i want to group it by name? : select ID_Sale,SaleDate,Branch_Name,P_Name,P_UnitPrice,QuantitySold, sum (QuantitySold*P_UnitPrice) over (order by ID_Sale asc) AS RunningTotal from tblP_Sales INNER JOIN tblProduct_With_Img ON tblP_Sales.P_ID_Sales = tblProduct_With_Img.P_ID INNER JOIN tblBranches ON tblP_Sales.BranchID = tblBranches.BranchID
0debug
Strange expression I myself may have written: Java variable assignment syntax : Somewhere in my code today, I found that I had written the following line JsonArray environmentJsonArray = new JsonArray(), playerJsonArray, teamJsonArray; I am at a complete loss in understanding how this was even working. The basic question is this: What are the two variables on my RHS doing? I checked if I had declared them before. But I did not. The compiler still does not complain apparently indicating that the playerJsonArray and the teamJsonArray was being taken as fresh declarations. But then the declared variables are always on the LHS. Isn't that so? Has something changed in Java's basic syntax? Iam trying to go thru the specs to get to the bottom but just in case anyone has a quicker understanding please....
0debug
How do I debug a Python program (I am coming from a Ruby on Rails/JavaScript background)? : <p>I make web applications using Ruby on Rails as my backend. I use React and Flux on the frontend, which is JavaScript. I can fully use the debugging tools I need. I simply add the line of code "debugger" anywhere in my app, so that execution stops there. I use byebug gem in Rails. When the "debugger" line of code is executed on backend code, the debugging happens on the command line; when it happens in JavaScript code, the debugging happens in Chrome Dev Tools. In other words, I can work very quickly to debug.</p> <p>What is the equivalent convenient debugging tool in Python? In other words, what should a person who can already program in general, and just wants to rapidly be able to debug in Python use? I am using Atom editor (like I use when I am making a web app).</p>
0debug
static uint64_t gpio_read(void *opaque, target_phys_addr_t addr, unsigned size) { struct gpio_state_t *s = opaque; uint32_t r = 0; addr >>= 2; switch (addr) { case R_PA_DIN: r = s->regs[RW_PA_DOUT] & s->regs[RW_PA_OE]; r |= s->nand->rdy << 7; break; case R_PD_DIN: r = s->regs[RW_PD_DOUT] & s->regs[RW_PD_OE]; r |= (!!(s->tempsensor.shiftreg & 0x10000)) << 4; break; default: r = s->regs[addr]; break; } return r; D(printf("%s %x=%x\n", __func__, addr, r)); }
1threat
Android button style : My button looks like this [Button][1] How can i make a simple button same as this [desired][2] [1]: http://i.stack.imgur.com/xDcE1.png [2]: http://i.stack.imgur.com/oUYB7.png
0debug
C# XML ignore < and > characters in a node : <p>I'm getting an xml document from a PHP script.</p> <p>The XML schema looks something like this: </p> <pre><code>&lt;Items&gt; &lt;Item&gt; &lt;ID&gt; 123g8fdg &lt;/ID&gt; &lt;Name&gt; Michael &lt;/Name&gt; &lt;Note&gt; Some notes, for example a small xml snippet: &lt;randomxml&gt;&lt;... &lt;/Note&gt; &lt;/Item&gt; &lt;/Items&gt; </code></pre> <p>The Note node could have any value (even an XML snippet) While trying on getting the following XML data back from the server, I noticed, that the C# <strong>LoadXML</strong> function fails if the Note is the following: </p> <pre><code>"Finish date &lt;= Start date + 1 year" </code></pre> <p>The "&lt;" character breaks it up (I can see that even in the C# XML Visualizer while debugging)</p> <p>Any ways to ignore any specific XML element in the notes section, so it doesn't interfere with the parser and basic structure?</p>
0debug
What's the proper scheme file extension? : <p>Files of the programming language Scheme are by convention either of the extension <code>.scm</code> or <code>.ss</code>.</p> <p>I'm interested in what the history of these extensions is, and also in the proper use, though it seems the universal attitude is that it's just whatever you prefer and it doesn't matter, but maybe I'm wrong about that.</p>
0debug
static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame) { FramePool *pool = avctx->internal->pool; int i, ret; switch (avctx->codec_type) { case AVMEDIA_TYPE_VIDEO: { uint8_t *data[4]; int linesize[4]; int size[4] = { 0 }; int w = frame->width; int h = frame->height; int tmpsize, unaligned; if (pool->format == frame->format && pool->width == frame->width && pool->height == frame->height) return 0; avcodec_align_dimensions2(avctx, &w, &h, pool->stride_align); do { av_image_fill_linesizes(linesize, avctx->pix_fmt, w); w += w & ~(w - 1); unaligned = 0; for (i = 0; i < 4; i++) unaligned |= linesize[i] % pool->stride_align[i]; } while (unaligned); tmpsize = av_image_fill_pointers(data, avctx->pix_fmt, h, NULL, linesize); if (tmpsize < 0) return -1; for (i = 0; i < 3 && data[i + 1]; i++) size[i] = data[i + 1] - data[i]; size[i] = tmpsize - (data[i] - data[0]); for (i = 0; i < 4; i++) { av_buffer_pool_uninit(&pool->pools[i]); pool->linesize[i] = linesize[i]; if (size[i]) { pool->pools[i] = av_buffer_pool_init(size[i] + 16 + STRIDE_ALIGN - 1, CONFIG_MEMORY_POISONING ? NULL : av_buffer_allocz); if (!pool->pools[i]) { ret = AVERROR(ENOMEM); goto fail; } } } pool->format = frame->format; pool->width = frame->width; pool->height = frame->height; break; } case AVMEDIA_TYPE_AUDIO: { int ch = av_frame_get_channels(frame); int planar = av_sample_fmt_is_planar(frame->format); int planes = planar ? ch : 1; if (pool->format == frame->format && pool->planes == planes && pool->channels == ch && frame->nb_samples == pool->samples) return 0; av_buffer_pool_uninit(&pool->pools[0]); ret = av_samples_get_buffer_size(&pool->linesize[0], ch, frame->nb_samples, frame->format, 0); if (ret < 0) goto fail; pool->pools[0] = av_buffer_pool_init(pool->linesize[0], NULL); if (!pool->pools[0]) { ret = AVERROR(ENOMEM); goto fail; } pool->format = frame->format; pool->planes = planes; pool->channels = ch; pool->samples = frame->nb_samples; break; } default: av_assert0(0); } return 0; fail: for (i = 0; i < 4; i++) av_buffer_pool_uninit(&pool->pools[i]); pool->format = -1; pool->planes = pool->channels = pool->samples = 0; pool->width = pool->height = 0; return ret; }
1threat
Error unexpected '}] in "}" if else statement in R language : <p>I'm working on calculating Bond Value example in my Data Mining subject. I have problem with if else function. Here it is...</p> <pre><code>P&lt;-1000 #original value - Menh gia trai phieu T&lt;-20 #maturity - Thoi han trai phieu - semi r&lt;-.06 #annual rate - Lai suat yeu cau C&lt;-30 #present value of coupons - Lai dinh ki BV &lt;- function(P,C,r,t,T){ #t = -th year #Find coupon Bon Value at time t mat T - Gia trai phieu tmat &lt;- T-t # How many years have you get your bonds for? acrued &lt;- C*2*t #already paid if(tmat != 0) { #include interim coupons i &lt;- seq(1,2*tmat) #BVsemi - seq()=for loop acrued + sum(C/(1+r/2)^i) + P/(1+r/2)^(2*tmat) }else{ acrued + P/(1+r/2)^(2*tmat) } } </code></pre> <p>The error message is: **</p> <pre><code>&gt; } Error: unexpected '}' in "}" </code></pre> <p>**</p> <p>I've already read all the topics that related to my problem but none of them works well... Please show me the light in this problem...</p> <p>Thank you</p> <p>Hoang Anh</p>
0debug
How to fix 401 http response error using Wp cron in wordpress? : <p>There was a problem spawning a call to the WP-Cron system on your site. This means WP-Cron events on your site may not work. The problem was: Unexpected HTTP response code: 401</p> <p>I am getting this error while execute the cron job</p>
0debug
static void init_blk_migration(Monitor *mon, QEMUFile *f) { BlkMigDevState *bmds; BlockDriverState *bs; int64_t sectors; block_mig_state.submitted = 0; block_mig_state.read_done = 0; block_mig_state.transferred = 0; block_mig_state.total_sector_sum = 0; block_mig_state.prev_progress = -1; block_mig_state.bulk_completed = 0; block_mig_state.total_time = 0; block_mig_state.reads = 0; for (bs = bdrv_first; bs != NULL; bs = bs->next) { if (bs->type == BDRV_TYPE_HD) { sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS; if (sectors == 0) { continue; } bmds = qemu_mallocz(sizeof(BlkMigDevState)); bmds->bs = bs; bmds->bulk_completed = 0; bmds->total_sectors = sectors; bmds->completed_sectors = 0; bmds->shared_base = block_mig_state.shared_base; block_mig_state.total_sector_sum += sectors; if (bmds->shared_base) { monitor_printf(mon, "Start migration for %s with shared base " "image\n", bs->device_name); } else { monitor_printf(mon, "Start full migration for %s\n", bs->device_name); } QSIMPLEQ_INSERT_TAIL(&block_mig_state.bmds_list, bmds, entry); } } }
1threat
static av_cold int g722_decode_init(AVCodecContext * avctx) { G722Context *c = avctx->priv_data; if (avctx->channels != 1) { av_log(avctx, AV_LOG_ERROR, "Only mono tracks are allowed.\n"); return AVERROR_INVALIDDATA; } avctx->sample_fmt = AV_SAMPLE_FMT_S16; c->band[0].scale_factor = 8; c->band[1].scale_factor = 2; c->prev_samples_pos = 22; avcodec_get_frame_defaults(&c->frame); avctx->coded_frame = &c->frame; return 0; }
1threat
When or why should I use a Mutex over an RwLock? : <p>When I read the documentations of <a href="https://doc.rust-lang.org/std/sync/struct.Mutex.html" rel="noreferrer"><code>Mutex</code></a> and <a href="https://doc.rust-lang.org/std/sync/struct.RwLock.html" rel="noreferrer"><code>RwLock</code></a>, the difference I see is the following:</p> <ul> <li><code>Mutex</code> can have only one reader or writer at a time,</li> <li><code>RwLock</code> can have one writer or multiple reader at a time.</li> </ul> <p>When you put it that way, <code>RwLock</code> seems always better (less limited) than <code>Mutex</code>, why would I use it, then?</p>
0debug
void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, MemoryRegion *mr, uint64_t align, Error **errp) { int slot; MachineState *machine = MACHINE(qdev_get_machine()); PCDIMMDevice *dimm = PC_DIMM(dev); Error *local_err = NULL; uint64_t existing_dimms_capacity = 0; uint64_t addr; addr = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP, &local_err); if (local_err) { goto out; } addr = pc_dimm_get_free_addr(hpms->base, memory_region_size(&hpms->mr), !addr ? NULL : &addr, align, memory_region_size(mr), &local_err); if (local_err) { goto out; } existing_dimms_capacity = pc_existing_dimms_capacity(&local_err); if (local_err) { goto out; } if (existing_dimms_capacity + memory_region_size(mr) > machine->maxram_size - machine->ram_size) { error_setg(&local_err, "not enough space, currently 0x%" PRIx64 " in use of total hot pluggable 0x" RAM_ADDR_FMT, existing_dimms_capacity, machine->maxram_size - machine->ram_size); goto out; } object_property_set_int(OBJECT(dev), addr, PC_DIMM_ADDR_PROP, &local_err); if (local_err) { goto out; } trace_mhp_pc_dimm_assigned_address(addr); slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP, &local_err); if (local_err) { goto out; } slot = pc_dimm_get_free_slot(slot == PC_DIMM_UNASSIGNED_SLOT ? NULL : &slot, machine->ram_slots, &local_err); if (local_err) { goto out; } object_property_set_int(OBJECT(dev), slot, PC_DIMM_SLOT_PROP, &local_err); if (local_err) { goto out; } trace_mhp_pc_dimm_assigned_slot(slot); if (kvm_enabled() && !kvm_has_free_slot(machine)) { error_setg(&local_err, "hypervisor has no free memory slots left"); goto out; } if (!vhost_has_free_slot()) { error_setg(&local_err, "a used vhost backend has no free" " memory slots left"); goto out; } memory_region_add_subregion(&hpms->mr, addr - hpms->base, mr); vmstate_register_ram(mr, dev); numa_set_mem_node_id(addr, memory_region_size(mr), dimm->node); out: error_propagate(errp, local_err); }
1threat
static inline int mjpeg_decode_dc(MJpegDecodeContext *s, int dc_index) { int code; code = get_vlc2(&s->gb, s->vlcs[0][dc_index].table, 9, 2); if (code < 0) { av_log(s->avctx, AV_LOG_WARNING, "mjpeg_decode_dc: bad vlc: %d:%d (%p)\n", 0, dc_index, &s->vlcs[0][dc_index]); return 0xffff; } if (code) return get_xbits(&s->gb, code); else return 0; }
1threat
fetch returns promise when I expect an array : I am doing a simple api get request, but I cant seem to isolate the array on its own. its always inside of a promise and I'm not sure how to remove it or how to access the values stored in the array. ```javascript function getLocation(name) { let output = fetch(`http://dataservice.accuweather.com/locations/v1/cities/search?apikey=oqAor7Al7Fkcj7AudulUkk5WGoySmEu7&q=london`).then(data => data.json()); return output } function App() { var output = getLocation(`london`); console.log (output) ... ``` ```Promise {<pending>} __proto__: Promise [[PromiseStatus]]: "resolved" [[PromiseValue]]: Array(3)``` is what is displayed in the console.log I require just the Array(3)
0debug
What's the best module for interacting with HDFS with Python3? : <p>I see there is hdfs3, snakebite, and some others. Which one is the best supported and comprehensive?</p>
0debug
static int config(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ int i; AVCodec *enc= avcodec_find_encoder(AV_CODEC_ID_SNOW); for(i=0; i<3; i++){ int is_chroma= !!i; int w= ((width + 4*BLOCK-1) & (~(2*BLOCK-1)))>>is_chroma; int h= ((height + 4*BLOCK-1) & (~(2*BLOCK-1)))>>is_chroma; vf->priv->temp_stride[i]= w; vf->priv->temp[i]= malloc(vf->priv->temp_stride[i]*h*sizeof(int16_t)); vf->priv->src [i]= malloc(vf->priv->temp_stride[i]*h*sizeof(uint8_t)); } for(i=0; i< (1<<vf->priv->log2_count); i++){ AVCodecContext *avctx_enc; AVDictionary *opts = NULL; avctx_enc= vf->priv->avctx_enc[i]= avcodec_alloc_context3(NULL); avctx_enc->width = width + BLOCK; avctx_enc->height = height + BLOCK; avctx_enc->time_base= (AVRational){1,25}; avctx_enc->gop_size = 300; avctx_enc->max_b_frames= 0; avctx_enc->pix_fmt = AV_PIX_FMT_YUV420P; avctx_enc->flags = CODEC_FLAG_QSCALE | CODEC_FLAG_LOW_DELAY; avctx_enc->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; avctx_enc->global_quality= 123; av_dict_set(&opts, "no_bitstream", "1", 0); avcodec_open2(avctx_enc, enc, &opts); av_dict_free(&opts); assert(avctx_enc->codec); } vf->priv->frame= av_frame_alloc(); vf->priv->frame_dec= av_frame_alloc(); vf->priv->outbuf_size= (width + BLOCK)*(height + BLOCK)*10; vf->priv->outbuf= malloc(vf->priv->outbuf_size); return ff_vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); }
1threat
target_ulong helper_madd32_suov(CPUTriCoreState *env, target_ulong r1, target_ulong r2, target_ulong r3) { uint64_t t1 = extract64(r1, 0, 32); uint64_t t2 = extract64(r2, 0, 32); uint64_t t3 = extract64(r3, 0, 32); int64_t result; result = t2 + (t1 * t3); return suov32(env, result); }
1threat
Extracting Latitude and Longitude from a string using java regrex : "Tracking info Latitude: 3.9574667 Longitude: 7.44882167" The structure of the message string will not change only the figure will be changing. Or any link that can help will be apreciated.
0debug
Connect new celery periodic task in django : <p>It's not a question but help to those who will find that the declaration of periodic tasks described in celery 4.0.1 documentation is hard to integrate in django: <a href="http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html#entries" rel="noreferrer">http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html#entries</a></p> <p>copy paste celery config file <code>main_app/celery.py</code>:</p> <pre><code>from celery import Celery from celery.schedules import crontab app = Celery() @app.on_after_configure.connect def setup_periodic_tasks(sender, **kwargs): # Calls test('hello') every 10 seconds. sender.add_periodic_task(10.0, test.s('hello'), name='add every 10') # Calls test('world') every 30 seconds sender.add_periodic_task(30.0, test.s('world'), expires=10) # Executes every Monday morning at 7:30 a.m. sender.add_periodic_task( crontab(hour=7, minute=30, day_of_week=1), test.s('Happy Mondays!'), ) @app.task def test(arg): print(arg) </code></pre> <h3>Question</h3> <p>But what if we use django and our tasks are placed in another app? With celery <code>4.0.1</code> we no longer have <code>@periodic_task</code> decorator. So let's see what we can do. </p> <h3>First case</h3> <p>If you prefer to keep tasks and their schedule close to each other:</p> <p><code>main_app/some_app/tasks.py</code></p> <pre><code>from main_app.celery import app as celery_app @celery_app.on_after_configure.connect def setup_periodic_tasks(sender, **kwargs): # Calls test('hello') every 10 seconds. sender.add_periodic_task(10.0, test.s('hello')) @celery_app.task def test(arg): print(arg) </code></pre> <p>We can run <code>beat</code> in debug mode:</p> <pre><code>celery -A main_app beat -l debug </code></pre> <p>and we will see that there's no such periodic task.</p> <h3>Second case</h3> <p>We can try to describe all periodic tasks in config file like this:</p> <p><code>main_app/celery.py</code></p> <pre><code>... app = Celery() @app.on_after_configure.connect def setup_periodic_tasks(sender, **kwargs): # Calls test('hello') every 10 seconds. from main_app.some_app.tasks import test sender.add_periodic_task(10.0, test.s('hello')) ... </code></pre> <p>The result is the same. But it will behave differently that you can see with manual debugging via pdb. In first example <code>setup_periodic_tasks</code> callback will not be fired at all. But in second example we'll get <code>django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.</code> (this exception will not be print out)</p>
0debug
Heteroscedasticity Test for Random Effects Model : <p>everyone</p> <p>I'm running a random effects model using the <code>plm</code> package and now I need to test for the presence of heteroscedasticity, but I'm not sure how to process it in the mentioned package. </p> <p>My model:</p> <pre><code>random &lt;- plm(Y ~ X, data=panel_data, model= "random", effect = "twoways") </code></pre> <p>Thank you in advance!</p>
0debug
I'm using 64 Bit OS. How do I trick my browser that I'm using 32bit Operating System : Some websites detect my operating system architecture (eg. 32-bit / 64-bit OS) if I want to download something for Example Google Chrome website thinks that I'm using 64bit operating system and thus it downloads 'ChromeStandalone64.exe for me. If I want to download the 32bit, I need to be on the 32bit OS which I think the other way is to use another computer or setup Virtual Machine. How do I trick the browser that I use 32bit OS ?
0debug
python 2.5.4 str.endwith() return False in valid check : **I don't need alternate solution.** I want know why this happen. I write source parser for makefiles. ff = open("module.mk") f = ff.readlines() ff.close() for i in f: if ".o \\" in i[-5:]: print "Is %s for str: %s" %(i.endswith('.o \\'), i) I got: Is False for str: bitmap.o \ and so for every check. You can get module.mk from [github][1] [1]: https://github.com/scummvm/scummvm/blob/master/engines/access/module.mk
0debug
static int spapr_vga_init(PCIBus *pci_bus) { switch (vga_interface_type) { case VGA_STD: pci_std_vga_init(pci_bus); return 1; case VGA_NONE: return 0; default: fprintf(stderr, "This vga model is not supported," "currently it only supports -vga std\n"); exit(0); break; } }
1threat
Javascript function doesn't works well Can't set a property 'onclick' of null : I'v the following code : var exit = document.getElementById("exit"); exit.onclick = function() { "use strict"; document.getElementById("fadedDiv").style.display = "none" ; }; but in the console i get the following error: script.js:107 Uncaught TypeError: Cannot set property 'onclick' of null Although it works well with me before but,I don't no what the problem is plz help me
0debug
Accessing global variable value in python : <pre><code>def definition(): global storage_account_connection_string storage_account_connection_string="test" def load_config(): config = ConfigParser.ConfigParser() config.readfp(open(r'config.txt')) temp = config.get('API_Metrics','SCC') temp1 = temp.split("#") for conf in temp1: confTemp=conf.split(":") print "#########################################" print confTemp[0] print confTemp[1] print confTemp[2] storage_account_connection_string=confTemp[2] print storage_account_connection_string get_details() def get_details(): print storage_account_connection_string print "Blob",blob_name_filter if __name__ == '__main_`enter code here`_': definition() load_config()`enter code here` </code></pre> <p>My question is why connection string always prints "test" in get_details(), though it is assigned with some value in load_config(), AM I missing something? </p>
0debug
How i can read all data in this response? : <p>I have this JSON object</p> <pre><code>{ "0": { "id": "44", "date": "2016-06-24 10:53:08", "client_id": "44", "status": "waiting", "price": null, "paid": null, "client": false, "items": { "beirut": { "52": { "id": "52", "type": "Kerosene", "quantity": "50", "price": "20100", "address": "beirut" } } } }, "1": { "id": "42", "date": "2016-06-24 10:43:35", "client_id": "44", "status": "waiting", "price": null, "paid": null, "client": false, "items": { "beirut": { "50": { "id": "50", "type": "Super 98", "quantity": "60", "price": "34900", "address": "beirut" } } } }, "status": "ok" } </code></pre> <p>I want to <strong>read</strong> all data from that response in <strong>javascript</strong>.</p> <p>This is returned in a <code>jquery.ajax</code> call as <code>datatype:jsonp</code>. I am able to access <strong>data</strong> and that displays all the stores in html page.</p> <p><strong>How can I read this properly?</strong></p>
0debug
Flutter: Initialising variables on startup : <p>I'm trying to use the values saved in the SharedPreferences to initialise several variables in my app. In Flutter, the SharedPreferences are asynchronous so it results in the variables initialising later on in the code which is creating problems with my app as some of the variables are null when the build method is called.</p> <p>Here is a small test Flutter app I wrote to demonstrate this issue:</p> <pre><code>import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:path_provider/path_provider.dart'; import 'dart:io'; import 'dart:convert'; import 'package:shared_preferences/shared_preferences.dart'; class TestingApp extends StatefulWidget { TestingApp() {} @override State&lt;StatefulWidget&gt; createState() { // TODO: implement createState return new _CupertinoNavigationState(); } } class _CupertinoNavigationState extends State&lt;TestingApp&gt; { int itemNo; @override void initState() { super.initState(); // SharedPreferences.getInstance().then((sp) { // sp.setInt("itemNo", 3); // }); SharedPreferences.getInstance().then((sp) { print("sp " + sp.getInt("itemNo").toString()); setState(() { itemNo = sp.getInt("itemNo"); }); }); print("This is the item number " + itemNo.toString()); } @override Widget build(BuildContext context) { // TODO: implement build print("item number on build " + itemNo.toString()); return new Text("Hello"); } } </code></pre> <p>This is the result in the console:</p> <pre><code>Performing full restart... flutter: This is the item number null flutter: item number on build null // build method being called and variable is null Restarted app in 1 993ms. flutter: sp 3 flutter: item number on build 3 </code></pre> <p>You can see that when I tried to fetch the variable from SharedPreferences on startup, since SharedPreference is async, the itemNo is null. Then the app runs the build method and runs the build method on the itemNo = null which is resulting in crashes in the app.</p> <p>Once it fetches the value from SharedPreferences, I call setState which then calls the build method again with the correct value. However, the initial call to build with the itemNo = null should not have happened.</p> <p>I wish there was a synch method for SharedPreferences but it doesn't seem to exist. How do I run the app so that the variables are initialised properly in Flutter on startup?</p> <p>I tried to solve this through using a synchronous method to initialise my variables by writing to a json file and then reading from it using the following short Flutter test app - to me, this appears to be overkill for saving a variable to initialise but I still gave it a try:</p> <pre><code>import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:path_provider/path_provider.dart'; import 'dart:io'; import 'dart:convert'; import 'package:shared_preferences/shared_preferences.dart'; class TestingApp extends StatefulWidget { TestingApp() {} @override State&lt;StatefulWidget&gt; createState() { // TODO: implement createState return new _CupertinoNavigationState(); } } class _CupertinoNavigationState extends State&lt;TestingApp&gt; { int itemNo; File jsonFile; String fileName = "items.json"; Directory dir; bool fileExists = false; void createFile(Map content, Directory dir, String fileName) { // print("Creating file for category " + dir.path); File file = new File(dir.path + "/" + fileName); file.createSync(); fileExists = true; file.writeAsStringSync(json.encode(content)); } void writeToFile(int itemNo) { // print("Writing to category file"); Map itemMap = new Map(); itemMap['item'] = itemNo; if (fileExists) { print("category file exists"); Map jsonFileContent = json.decode(jsonFile.readAsStringSync()); jsonFileContent.addAll(itemMap); jsonFile.writeAsStringSync(json.encode(itemMap)); } else { print("category File does not exists"); getApplicationDocumentsDirectory().then((Directory directory) { dir = directory; createFile(itemMap, dir, fileName); }); } } fetchSavedItemNo() { //load the currency from the saved json file. getApplicationDocumentsDirectory().then((Directory directory) { dir = directory; jsonFile = new File(dir.path+ "/" + fileName); fileExists = jsonFile.existsSync(); setState(() { if (fileExists) itemNo = json.decode(jsonFile.readAsStringSync())['item']; print("fetching saved itemNo " +itemNo.toString()); if (itemNo == null) { itemNo = 0; } }); return itemNo; //else the itemNo will just be 0 }); } @override void initState() { super.initState(); writeToFile(3); setState(() { itemNo = fetchSavedItemNo(); }); } @override Widget build(BuildContext context) { // TODO: implement build print("item number on build " + itemNo.toString()); return new Text("Hello"); } } </code></pre> <p>I still have the results where the build method is being called before the variables are fully initialised which is causing app crashes.</p> <pre><code>Performing full restart... flutter: category File does not exists flutter: item number on build null // the build method is called here Restarted app in 1 894ms. flutter: fetching saved itemNo 3 flutter: item number on build 3 </code></pre> <p>How do I initialise variables in Flutter on app startup?</p>
0debug
Why the put method of a JSONObject throws JSONException? : <p>I found few answers here on how to handle this exception, but there was no explanation why would this happen in the first place. I have the following code:</p> <pre><code>for (Map.Entry&lt;String, Double&gt; entry: qosMap.entrySet()) { JSONObject qosEntry = new JSONObject(); try { qosEntry.put(entry.getKey(), entry.getValue()); } catch (JSONException ex) { Logger.getLogger(JSONUtil.class.getName()).log(Level.SEVERE, null, ex); } } </code></pre> <p>The qosMap will never be empty, and the data in this map will always be valid. </p> <p>What would be a case where the exception would thrown? Why do I need to have this extra code?</p>
0debug
How to hot key (Ctr+c+c) for VBA macro : i want to hot key(ctr+c+c) to call macro VBA excel. Please help me. i am trying use Application.Onkey but can not.
0debug
Object creating and accessing inside a jframe code behind not work : <p>I have created a class called player and beginner (<code>public class Beginner extends Player</code>)</p> <p>then I tried to access beginner from the main class. It worked. screenshot down below. <a href="https://i.stack.imgur.com/1vhfe.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1vhfe.jpg" alt="Main object create and access"></a></p> <p>Then I tried to create another object and access that object from the jframe. It allows me to create the object (<code>Beginner b1= new Beginner();</code>) But does not allow to access that object. It says <em>identifier expected</em>.</p> <p>Here's the screenshot inside the jframe. <a href="https://i.stack.imgur.com/SALPl.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SALPl.jpg" alt="Inside jframe"></a></p> <p>How can I access through the jframe code behind?? What causes this ?</p> <p>note: I am still a beginner to java. So please do not misunderstand me for asking these type of questions. Thank you ..!</p>
0debug
static void qed_read_l2_table_cb(void *opaque, int ret) { QEDReadL2TableCB *read_l2_table_cb = opaque; QEDRequest *request = read_l2_table_cb->request; BDRVQEDState *s = read_l2_table_cb->s; CachedL2Table *l2_table = request->l2_table; if (ret) { qed_unref_l2_cache_entry(l2_table); request->l2_table = NULL; } else { l2_table->offset = read_l2_table_cb->l2_offset; qed_commit_l2_cache_entry(&s->l2_cache, l2_table); request->l2_table = qed_find_l2_cache_entry(&s->l2_cache, l2_table->offset); assert(request->l2_table != NULL); } gencb_complete(&read_l2_table_cb->gencb, ret); }
1threat
static void blk_mig_read_cb(void *opaque, int ret) { BlkMigBlock *blk = opaque; blk_mig_lock(); blk->ret = ret; QSIMPLEQ_INSERT_TAIL(&block_mig_state.blk_list, blk, entry); bmds_set_aio_inflight(blk->bmds, blk->sector, blk->nr_sectors, 0); block_mig_state.submitted--; block_mig_state.read_done++; assert(block_mig_state.submitted >= 0); blk_mig_unlock(); }
1threat
SQL command for copy value in column with same id : <br> i need help to create the right SQL command.<br> As you can see in attachment ,<br> i need to copy string from column value with <strong>attribute_id 78</strong> in column value with <strong>attribute_id 77</strong> WHERE the <strong>entity_id</strong> is the same. can anyone help me write the right code? Thanks in advance [screenshot sql tabble][1] [1]: https://i.stack.imgur.com/alRJA.jpg
0debug
static int read_packet(AVFormatContext *s, AVPacket *pkt) { MmDemuxContext *mm = s->priv_data; AVIOContext *pb = s->pb; unsigned char preamble[MM_PREAMBLE_SIZE]; unsigned int type, length; while(1) { if (avio_read(pb, preamble, MM_PREAMBLE_SIZE) != MM_PREAMBLE_SIZE) { return AVERROR(EIO); } type = AV_RL16(&preamble[0]); length = AV_RL16(&preamble[2]); switch(type) { case MM_TYPE_PALETTE : case MM_TYPE_INTER : case MM_TYPE_INTRA : case MM_TYPE_INTRA_HH : case MM_TYPE_INTER_HH : case MM_TYPE_INTRA_HHV : case MM_TYPE_INTER_HHV : if (av_new_packet(pkt, length + MM_PREAMBLE_SIZE)) return AVERROR(ENOMEM); memcpy(pkt->data, preamble, MM_PREAMBLE_SIZE); if (avio_read(pb, pkt->data + MM_PREAMBLE_SIZE, length) != length) return AVERROR(EIO); pkt->size = length + MM_PREAMBLE_SIZE; pkt->stream_index = 0; pkt->pts = mm->video_pts; if (type!=MM_TYPE_PALETTE) mm->video_pts++; return 0; case MM_TYPE_AUDIO : if (av_get_packet(s->pb, pkt, length)<0) return AVERROR(ENOMEM); pkt->size = length; pkt->stream_index = 1; pkt->pts = mm->audio_pts++; return 0; default : av_log(s, AV_LOG_INFO, "unknown chunk type 0x%x\n", type); avio_skip(pb, length); } } }
1threat
void timerlistgroup_init(QEMUTimerListGroup *tlg, QEMUTimerListNotifyCB *cb, void *opaque) { QEMUClockType type; for (type = 0; type < QEMU_CLOCK_MAX; type++) { tlg->tl[type] = timerlist_new(type, cb, opaque); } }
1threat
static inline void iwmmxt_store_reg(TCGv var, int reg) { tcg_gen_st_i64(var, cpu_env, offsetof(CPUState, iwmmxt.regs[reg])); }
1threat
Is it possible to get all data from table and insert to another using single query? : <p>Is it possible to get all data from table and insert to another using single query?</p> <p>Provided that two tables are the same structure</p>
0debug
static void setup_rt_frame(int sig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUX86State *env) { abi_ulong frame_addr, addr; struct rt_sigframe *frame; int i, err = 0; frame_addr = get_sigframe(ka, env, sizeof(*frame)); if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) goto give_sigsegv; __put_user(current_exec_domain_sig(sig), &frame->sig); addr = frame_addr + offsetof(struct rt_sigframe, info); __put_user(addr, &frame->pinfo); addr = frame_addr + offsetof(struct rt_sigframe, uc); __put_user(addr, &frame->puc); err |= copy_siginfo_to_user(&frame->info, info); if (err) goto give_sigsegv; __put_user(0, &frame->uc.tuc_flags); __put_user(0, &frame->uc.tuc_link); __put_user(target_sigaltstack_used.ss_sp, &frame->uc.tuc_stack.ss_sp); __put_user(sas_ss_flags(get_sp_from_cpustate(env)), &frame->uc.tuc_stack.ss_flags); __put_user(target_sigaltstack_used.ss_size, &frame->uc.tuc_stack.ss_size); err |= setup_sigcontext(&frame->uc.tuc_mcontext, &frame->fpstate, env, set->sig[0], frame_addr + offsetof(struct rt_sigframe, fpstate)); for(i = 0; i < TARGET_NSIG_WORDS; i++) { if (__put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i])) goto give_sigsegv; } if (ka->sa_flags & TARGET_SA_RESTORER) { __put_user(ka->sa_restorer, &frame->pretcode); } else { uint16_t val16; addr = frame_addr + offsetof(struct rt_sigframe, retcode); __put_user(addr, &frame->pretcode); __put_user(0xb8, (char *)(frame->retcode+0)); __put_user(TARGET_NR_rt_sigreturn, (int *)(frame->retcode+1)); val16 = 0x80cd; __put_user(val16, (uint16_t *)(frame->retcode+5)); } if (err) goto give_sigsegv; env->regs[R_ESP] = frame_addr; env->eip = ka->_sa_handler; cpu_x86_load_seg(env, R_DS, __USER_DS); cpu_x86_load_seg(env, R_ES, __USER_DS); cpu_x86_load_seg(env, R_SS, __USER_DS); cpu_x86_load_seg(env, R_CS, __USER_CS); env->eflags &= ~TF_MASK; unlock_user_struct(frame, frame_addr, 1); return; give_sigsegv: unlock_user_struct(frame, frame_addr, 1); if (sig == TARGET_SIGSEGV) ka->_sa_handler = TARGET_SIG_DFL; force_sig(TARGET_SIGSEGV ); }
1threat
How does shallow compare work in react : <p>In <a href="https://facebook.github.io/react/docs/shallow-compare.html" rel="noreferrer">this documentation</a> of React, it is said that </p> <blockquote> <p>shallowCompare performs a shallow equality check on the current props and nextProps objects as well as the current state and nextState objects.</p> </blockquote> <p>The thing which I am unable to understand is If It shallowly compares the objects then shouldComponentUpdate method will always return true, as</p> <blockquote> <p>We should not mutate the states.</p> </blockquote> <p>and if we are not mutating the states then the comparison will always return false and so the shouldComponent update will always return true. I am confused about how it is working and how will we override this to boost the performance.</p>
0debug
what is the URL for JetBrains IDE plug-in repository? : <p>I thought this was a simple question, and still nothing works.</p> <p>My first use-case is that the IDEA 15 (<em>Community</em>) appears to NOT have a repository configured. The *Plugins" tab in the <strong><em>Settings</em></strong> window / dialogue supports three operation aside from clicking on a plugin.:</p> <ul> <li><p>A button for [<code>Install JetBrains plugins</code>] ... This seems to be things downloaded with the installer or updates;</p></li> <li><p>A [<code>Browse repositories plugins</code>] button ... which contains an "<em>empty</em>" list <br/>Further this dialogue contains two buttons for:</p> <ul> <li>A [<code>Manage repositories</code>] </li> <li>[<code>HTTP proxy settings</code>] - Proxy configuration / setup</li> </ul></li> <li>An [<code>Install plugins from disk</code>] button ... which does what it says ;-)</li> </ul> <p>This question to ask is, what URL do I need to put into that: * The [<code>Manage repositories</code>] </p> <p>... list because the clean install had "<em>nada</em>" in that list.</p> <p>The list of JetBrains plugins isn't the same as the list on the plugins repository web page:</p> <ul> <li><a href="https://plugins.jetbrains.com/" rel="noreferrer">https://plugins.jetbrains.com/</a></li> </ul> <p>In fact IDEA help pages recommend using the JetBrains repository... They do not seem to want to let one know the URL.</p> <p>Also, what is the "Community" plugins URL? At the very least I'd like to verify that/<em>IF</em> the JetBrains plugin-list is updating (as there's no "update list" option to be seen).</p> <p>Weird huh?</p>
0debug
R - What this command does ? subset(df, !duplicated(x)) : I came across this question in one of my interviews. Looking for detailed answer. > we have a dataframe(df) that contains three variables x, y, and z. > What the following command does? subset(df, !duplicated(x))
0debug
Distribute a Python package with a compiled dynamic shared library : <p>How do I package a Python module together with a precompiled <code>.so</code> library? Specifically, how do I write <code>setup.py</code> so that when I do this in Python</p> <pre><code>&gt;&gt;&gt; import top_secret_wrapper </code></pre> <p>It can easily find <code>top_secret.so</code> without having to set <code>LD_LIBRARY_PATH</code>?</p> <p>In my module development environment, I have the following file structure:</p> <pre><code>. ├── top_secret_wrapper │   ├── top_secret.so │   └── __init__.py └── setup.py </code></pre> <p>Inside <code>__init__.py</code>, I have something like:</p> <pre><code>import top_secret </code></pre> <p>Here's my <code>setup.py</code></p> <pre><code>from setuptools import setup, Extension setup( name = 'top_secret_wrapper', version = '0.1', description = 'A Python wrapper for a top secret algorithm', url = None, author = 'James Bond', author_email = 'James.Bond.007@mi6.org', license = 'Spy Game License', zip_safe = True, ) </code></pre> <p>I'm sure my <code>setup.py</code> is lacking a setting where I specify the location of <code>top_secret.so</code>, though I'm not sure how to do that.</p>
0debug
Non-invocable member 'Http SessionState.Timeout' cannot be used like a method : <pre><code> protected void Button1_Click(object sender, EventArgs e) { Session["Email"] = "sssaundatti@gmail.com"; Session.Timeout("200"); </code></pre> <blockquote> <p>Non-invocable member 'Http SessionState.Timeout' cannot be used like a method</p> </blockquote> <pre><code> } </code></pre> <blockquote> <p>How to solve this problem?</p> </blockquote> <pre><code> protected void Button2_Click(object sender, EventArgs e) { if (Session["Email"] !=null) { Email.Text = Session["Email"].ToString; } else { Email.Text = "Please Set Session"; } } </code></pre>
0debug
"return render" vs "render ... and return" in Rails : <p>Is there any functional difference in writing <code>return render 'edit'</code> and <code>render 'edit' and return</code>? Are both syntaxes safe to use?</p> <p>The <code>return render</code> syntax is slightly more concise, but the <code>render and return</code> is advocated officially here <a href="http://guides.rubyonrails.org/layouts_and_rendering.html#avoiding-double-render-errors" rel="noreferrer">Avoiding Double Render Errors</a>.</p> <p><code>return render</code> would return whatever value the render method return and <code>render and return</code> would return a <code>nil</code> from the controller method.</p>
0debug
static int ffmmal_read_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame) { MMALDecodeContext *ctx = avctx->priv_data; MMAL_BUFFER_HEADER_T *buffer = NULL; MMAL_STATUS_T status = 0; int ret = 0; if (ctx->eos_received) goto done; while (1) { if (ctx->frames_output || ctx->packets_sent > MAX_DELAYED_FRAMES || ctx->eos_sent) { buffer = mmal_queue_wait(ctx->queue_decoded_frames); } else { buffer = mmal_queue_get(ctx->queue_decoded_frames); } if (!buffer) goto done; ctx->eos_received |= !!(buffer->flags & MMAL_BUFFER_HEADER_FLAG_EOS); if (ctx->eos_received) goto done; if (buffer->cmd == MMAL_EVENT_FORMAT_CHANGED) { MMAL_COMPONENT_T *decoder = ctx->decoder; MMAL_EVENT_FORMAT_CHANGED_T *ev = mmal_event_format_changed_get(buffer); MMAL_BUFFER_HEADER_T *stale_buffer; av_log(avctx, AV_LOG_INFO, "Changing output format.\n"); if ((status = mmal_port_disable(decoder->output[0]))) goto done; while ((stale_buffer = mmal_queue_get(ctx->queue_decoded_frames))) mmal_buffer_header_release(stale_buffer); mmal_format_copy(decoder->output[0]->format, ev->format); if ((ret = ffmal_update_format(avctx)) < 0) goto done; if ((status = mmal_port_enable(decoder->output[0], output_callback))) goto done; if ((ret = ffmmal_fill_output_port(avctx)) < 0) goto done; if ((ret = ffmmal_fill_input_port(avctx)) < 0) goto done; mmal_buffer_header_release(buffer); continue; } else if (buffer->cmd) { char s[20]; av_get_codec_tag_string(s, sizeof(s), buffer->cmd); av_log(avctx, AV_LOG_WARNING, "Unknown MMAL event %s on output port\n", s); goto done; } else if (buffer->length == 0) { mmal_buffer_header_release(buffer); continue; } ctx->frames_output++; if ((ret = ffmal_copy_frame(avctx, frame, buffer)) < 0) goto done; *got_frame = 1; break; } done: if (buffer) mmal_buffer_header_release(buffer); if (status && ret >= 0) ret = AVERROR_UNKNOWN; return ret; }
1threat
static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx) { Flash *s = M25P80(ss); uint32_t r = 0; switch (s->state) { case STATE_PAGE_PROGRAM: DB_PRINT_L(1, "page program cur_addr=%#" PRIx64 " data=%" PRIx8 "\n", s->cur_addr, (uint8_t)tx); flash_write8(s, s->cur_addr, (uint8_t)tx); s->cur_addr++; break; case STATE_READ: r = s->storage[s->cur_addr]; DB_PRINT_L(1, "READ 0x%" PRIx64 "=%" PRIx8 "\n", s->cur_addr, (uint8_t)r); s->cur_addr = (s->cur_addr + 1) % s->size; break; case STATE_COLLECTING_DATA: case STATE_COLLECTING_VAR_LEN_DATA: s->data[s->len] = (uint8_t)tx; s->len++; if (s->len == s->needed_bytes) { complete_collecting_data(s); } break; case STATE_READING_DATA: r = s->data[s->pos]; s->pos++; if (s->pos == s->len) { s->pos = 0; s->state = STATE_IDLE; } break; default: case STATE_IDLE: decode_new_cmd(s, (uint8_t)tx); break; } return r; }
1threat
Hi guys! So i'm trying to use a slider to set values within the backend of my C# code. I've explained further below : Here is a snippet of my code of what I have tried so far. At the moment I have succesfully binded the value of the slider to a textbox. I want to bind this same value to a variable within my code. Such as when the slide position is at 1.5. The calculation within the code will use the value 1.5. The variable which I required to be updated is the flslidervalue. But after my research online, I've learnt that I would need to use a double due to the fact that my slider numbers contain decimals. Below is a snippet of my code with the relevant parts: float flradius; float flfactual; float flfmax; float flfos; float slvalue; private void btnCalculate_Click(object sender, RoutedEventArgs e) { flfactual = flfmax / flfos; //output Flfmax back to form txtFmax.Text = flfmax.ToString(); //output Flfactual back to form txtFactual.Text = flfactual.ToString(); } private void fosslider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) { txtSlider.Text = fosslider.Value.ToString(); Double slvalue = fosslider.Value.To } ******************************************************************** XAML CODE <Slider x:Name="fosslider" HorizontalAlignment="Left" Margin="403,258,0,0" VerticalAlignment="Top" Width="246" TickPlacement="BottomRight" Maximum="4" SmallChange="0.5" IsSnapToTickEnabled="True" ValueChanged="fosslider_ValueChanged" LargeChange="0.5" TickFrequency="0.5" /> <TextBox x:Name="txtSlider" HorizontalAlignment="Left" Height="23" Margin="431,310,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
0debug
static inline void dv_guess_qnos(EncBlockInfo* blks, int* qnos) { int size[5]; int i, j, k, a, prev, a2; EncBlockInfo* b; size[0] = size[1] = size[2] = size[3] = size[4] = 1<<24; do { b = blks; for (i=0; i<5; i++) { if (!qnos[i]) continue; qnos[i]--; size[i] = 0; for (j=0; j<6; j++, b++) { for (a=0; a<4; a++) { if (b->area_q[a] != dv_quant_shifts[qnos[i] + dv_quant_offset[b->cno]][a]) { b->bit_size[a] = 1; b->area_q[a]++; prev= b->prev[a]; for (k= b->next[prev] ; k<mb_area_start[a+1]; k= b->next[k]) { b->mb[k] >>= 1; if (b->mb[k]) { b->bit_size[a] += dv_rl2vlc_size(k - prev - 1, b->mb[k]); prev= k; } else { if(b->next[k] >= mb_area_start[a+1] && b->next[k]<64){ for(a2=a+1; b->next[k] >= mb_area_start[a2+1]; a2++) b->prev[a2] = prev; assert(a2<4); assert(b->mb[b->next[k]]); b->bit_size[a2] += dv_rl2vlc_size(b->next[k] - prev - 1, b->mb[b->next[k]]) -dv_rl2vlc_size(b->next[k] - k - 1, b->mb[b->next[k]]); for(; (b->prev[a2]==k) && (a2<4); a2++) b->prev[a2] = prev; } b->next[prev] = b->next[k]; } } b->prev[a+1]= prev; } size[i] += b->bit_size[a]; } } if(vs_total_ac_bits >= size[0] + size[1] + size[2] + size[3] + size[4]) return; } } while (qnos[0]|qnos[1]|qnos[2]|qnos[3]|qnos[4]); for(a=2; a==2 || vs_total_ac_bits < size[0]; a+=a){ b = blks; size[0] = 5*6*4; for (j=0; j<6*5; j++, b++) { prev= b->prev[0]; for (k= b->next[prev]; k<64; k= b->next[k]) { if(b->mb[k] < a && b->mb[k] > -a){ b->next[prev] = b->next[k]; }else{ size[0] += dv_rl2vlc_size(k - prev - 1, b->mb[k]); prev= k; } } } } }
1threat
void backup_do_checkpoint(BlockJob *job, Error **errp) { BackupBlockJob *backup_job = container_of(job, BackupBlockJob, common); int64_t len; assert(job->driver->job_type == BLOCK_JOB_TYPE_BACKUP); if (backup_job->sync_mode != MIRROR_SYNC_MODE_NONE) { error_setg(errp, "The backup job only supports block checkpoint in" " sync=none mode"); return; } len = DIV_ROUND_UP(backup_job->common.len, backup_job->cluster_size); bitmap_zero(backup_job->done_bitmap, len); }
1threat
static target_ulong h_client_architecture_support(PowerPCCPU *cpu_, sPAPRMachineState *spapr, target_ulong opcode, target_ulong *args) { target_ulong list = ppc64_phys_to_real(args[0]); target_ulong ov_table; PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu_); CPUState *cs; bool cpu_match = false, cpu_update = true; unsigned old_cpu_version = cpu_->cpu_version; unsigned compat_lvl = 0, cpu_version = 0; unsigned max_lvl = get_compat_level(cpu_->max_compat); int counter; sPAPROptionVector *ov5_guest, *ov5_cas_old, *ov5_updates; for (counter = 0; counter < 512; ++counter) { uint32_t pvr, pvr_mask; pvr_mask = ldl_be_phys(&address_space_memory, list); list += 4; pvr = ldl_be_phys(&address_space_memory, list); list += 4; trace_spapr_cas_pvr_try(pvr); if (!max_lvl && ((cpu_->env.spr[SPR_PVR] & pvr_mask) == (pvr & pvr_mask))) { cpu_match = true; cpu_version = 0; } else if (pvr == cpu_->cpu_version) { cpu_match = true; cpu_version = cpu_->cpu_version; } else if (!cpu_match) { cas_handle_compat_cpu(pcc, pvr, max_lvl, &compat_lvl, &cpu_version); } if (~pvr_mask & pvr) { break; } } trace_spapr_cas_pvr(cpu_->cpu_version, cpu_match, cpu_version, pcc->pcr_mask); if (old_cpu_version != cpu_version) { CPU_FOREACH(cs) { SetCompatState s = { .cpu_version = cpu_version, .err = NULL, }; run_on_cpu(cs, do_set_compat, RUN_ON_CPU_HOST_PTR(&s)); if (s.err) { error_report_err(s.err); return H_HARDWARE; } } } if (!cpu_version) { cpu_update = false; } ov_table = list; ov5_guest = spapr_ovec_parse_vector(ov_table, 5); ov5_cas_old = spapr_ovec_clone(spapr->ov5_cas); spapr_ovec_intersect(spapr->ov5_cas, spapr->ov5, ov5_guest); spapr_ovec_cleanup(ov5_guest); ov5_updates = spapr_ovec_new(); spapr->cas_reboot = spapr_ovec_diff(ov5_updates, ov5_cas_old, spapr->ov5_cas); if (!spapr->cas_reboot) { spapr->cas_reboot = (spapr_h_cas_compose_response(spapr, args[1], args[2], cpu_update, ov5_updates) != 0); } spapr_ovec_cleanup(ov5_updates); if (spapr->cas_reboot) { qemu_system_reset_request(); } return H_SUCCESS; }
1threat
Passing PHP value to a modal box : I want to pass a variable to a modal box I call on the same page but have not been able to do it. Code to open modal box is as below <li style="font-style:bold" title="rate on skill" class="skill_rating"><a data-toggle="modal" title="Add this item" class="open-AddBookDialog" href="#addBookDialog" data-id='<?php echo $skill_id2[$q]?>'><i class="fa fa-anchor" aria-hidden="true"></i> </a><?php echo $skilltemp2[$q2] ?></li> Modal Box code as below <div class="modal fade" id="addBookDialog" tabindex="-1" role="dialog" aria-labelledby="addBookDialog"><div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4 class="modal-title" id="myModalLabel">Search</h4> </div> <div class="modal-body"> <div class="form-group"> <input type="text" name="bookId" id="bookId" value=""/> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default"><span>Search</span></button> </div> </div> </div> </div> Javascript before the closing body tag is as below <script type="text/javascript"> $(document).on("click", ".open-AddBookDialog", function () { var myBookId = $(this).data('id'); $(".modal-body #bookId").val( myBookId ); }); </script> I saw a couple of answers at stackoverflow (example:http://stackoverflow.com/questions/10626885/passing-data-to-a-bootstrap-modal )but I have not been able to customize it for my requirement. Pardon me if its is too simple. I am a noob
0debug
Find a KeyValuePair inside a List : <p>Suppose I have</p> <pre><code> List&lt;KeyValuePair&lt;int, string&gt;&gt; d </code></pre> <p>I know the string but I want to find its integer. How do I find the keyvaluepair inside this List?</p>
0debug
static uint32_t unassigned_mem_readb(void *opaque, target_phys_addr_t addr) { #ifdef DEBUG_UNASSIGNED printf("Unassigned mem read " TARGET_FMT_plx "\n", addr); #endif #if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE) do_unassigned_access(addr, 0, 0, 0, 1); #endif return 0; }
1threat
What kind of data format should I use for storing http request (very large data set)? : I would like to store http request data in AWS S3 and might do queries on these data by using AWS Athena/Spark/Nexus. What format is recommand in this case? Choices are: JSON, CSV, TSV, Textfiles, Apache ORC, Apache Parquet, Compressed data. Currently I am consider these 3 aspects: time for serialization/de-serialization, Query speed, space. Any links might be helpful are welcomed! Thanks!
0debug
resizing window with gridBagLayout : <p>I am stuck on this a large amount of time and I dont know how to do it, despite seraching on Google lots of times. My problem is that, I have a program, with a container obtained from the JFrame. The thing is, I put my menuBar correctly, and just below my two buttons, but when I maximize the window, it appears a annoying white space that I dont want to be there. If i dont maximize the window, the components are fine placed, like this:</p> <p><a href="https://i.stack.imgur.com/vBvzp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vBvzp.png" alt="enter image description here"></a></p> <p>But when I maximize the window, it appears that annoying space (the one marked in red):</p> <p><a href="https://i.stack.imgur.com/Ca3XN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ca3XN.png" alt="enter image description here"></a></p> <p>And what I want is that the MenuBar and the buttons, stays stuck in that corner like the first picture. The code of the gridbaglayout of the menu bar and the buttons is the following:</p> <pre><code>//MenuBar gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 0.5; gbc.weighty = 0.0; // si no ponemos esto la barra NO se queda anclada en la esquina gbc.gridx = 0; gbc.gridy = 0; //gbc.anchor = GridBagConstraints.NORTHWEST; //gbc.gridwidth = 2; //gbc.gridheight = 1; menuBar.setBorder(BorderFactory.createLineBorder(Color.black)); pane.add(menuBar, gbc); //buttons gbc.gridx = 0; gbc.gridy = 1; gbc.anchor = GridBagConstraints.LINE_START;//reseteamos su valor gbc.gridwidth = GridBagConstraints.REMAINDER; // con esto indicamos que va a ser el ultimo componente de esa fila gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.fill = GridBagConstraints.NONE; gbc.gridwidth = 2; gbc.gridheight = 1; panel.setBorder(BorderFactory.createLineBorder(Color.black)); //luego quitar es para ver lo que ocupaba el panel pane.add(panel, gbc); </code></pre>
0debug
Visual Studio shows warning in vctmp file : <p>I have a C# project opened in visual studio. We are using TFS to manage our projects. In one source code file of the project I have configured a warning in the following way:</p> <pre><code>#warning expand for all properties </code></pre> <p>When I compile my project the warning is shown in the error list twice. Once in the original file, and once in a file called <code>vctmp2984_94722.cs</code>. I can open the temporary file in visual studio and it has a previous state of the file. Opening the file in explorer is not possible, cause the path of the temporary file points to a place that does not exist: C:\Users\developer\AppData\Local\Temp\TFSTemp\vctmp2984_94722.cs</p> <p>Does anybody nows how to solve this?</p>
0debug
from collections import defaultdict def grouping_dictionary(l): d = defaultdict(list) for k, v in l: d[k].append(v) return d
0debug
void uninit_opts(void) { int i; for (i = 0; i < AVMEDIA_TYPE_NB; i++) av_freep(&avcodec_opts[i]); av_freep(&avformat_opts->key); av_freep(&avformat_opts); #if CONFIG_SWSCALE av_freep(&sws_opts); #endif }
1threat
static int proxy_chmod(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp) { int retval; retval = v9fs_request(fs_ctx->private, T_CHMOD, NULL, "sd", fs_path, credp->fc_mode); if (retval < 0) { errno = -retval; } return retval; }
1threat
static void gen_tlbivax_booke206(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); #else TCGv t0; if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } t0 = tcg_temp_new(); gen_addr_reg_index(ctx, t0); gen_helper_booke206_tlbivax(cpu_env, t0); tcg_temp_free(t0); #endif }
1threat
static void yuv2yuv1_c(SwsContext *c, const int16_t *lumSrc, const int16_t *chrUSrc, const int16_t *chrVSrc, const int16_t *alpSrc, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, int dstW, int chrDstW) { int i; for (i=0; i<dstW; i++) { int val= (lumSrc[i]+64)>>7; dest[i]= av_clip_uint8(val); } if (uDest) for (i=0; i<chrDstW; i++) { int u=(chrUSrc[i]+64)>>7; int v=(chrVSrc[i]+64)>>7; uDest[i]= av_clip_uint8(u); vDest[i]= av_clip_uint8(v); } if (CONFIG_SWSCALE_ALPHA && aDest) for (i=0; i<dstW; i++) { int val= (alpSrc[i]+64)>>7; aDest[i]= av_clip_uint8(val); } }
1threat
static void gen_mfsrin(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); #else TCGv t0; if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); return; } t0 = tcg_temp_new(); tcg_gen_shri_tl(t0, cpu_gpr[rB(ctx->opcode)], 28); tcg_gen_andi_tl(t0, t0, 0xF); gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0); tcg_temp_free(t0); #endif }
1threat
static void virtio_scsi_reset(VirtIODevice *vdev) { VirtIOSCSI *s = VIRTIO_SCSI(vdev); VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev); if (s->ctx) { virtio_scsi_dataplane_stop(s); } s->resetting++; qbus_reset_all(&s->bus.qbus); s->resetting--; vs->sense_size = VIRTIO_SCSI_SENSE_DEFAULT_SIZE; vs->cdb_size = VIRTIO_SCSI_CDB_DEFAULT_SIZE; s->events_dropped = false; }
1threat
Not able to do proper path monitoring or querying with Firebase and ElasticSearch (with Flashlight) : <p>I'm trying to integrate ElasticSearch wit Firebase. I'm using the <a href="https://github.com/firebase/flashlight" rel="nofollow">Flashlight integration</a> from Firebase to set ut all up. I have deployed the code to Heroku as described in the Github repo linked above.</p> <p>It works in the sense that when I insert a query objet to <code>/search/request/</code> I get a <code>/search/response</code> result. But the results are a bit messy, not correct. But I can't figure out what is wrong.</p> <p>This is what is defined in <code>config.js</code> where I define the paths to monitor:</p> <pre><code>/** Paths to Monitor * * Each path can have these keys: * {string} path: [required] the Firebase path to be monitored, for example, `users/profiles` * would monitor https://&lt;instance&gt;.firebaseio.com/users/profiles * {string} index: [required] the name of the ES index to write data into * {string} type: [required] name of the ES object type this document will be stored as * {Array} fields: list of fields to be monitored and indexed (defaults to all fields, ignored if "parser" is specified) * {Array} omit: list of fields that should not be indexed in ES (ignored if "parser" is specified) * {Function} filter: if provided, only records that return true are indexed * {Function} parser: if provided, the results of this function are passed to ES, rather than the raw data (fields is ignored if this is used) * * To store your paths dynamically, rather than specifying them all here, you can store them in Firebase. * Format each path object with the same keys described above, and store the array of paths at whatever * location you specified in the FB_PATHS variable. Be sure to restrict that data in your Security Rules. ****************************************************/ exports.paths = [{ path: "users", index: "firebase", type: "user" }, { path: "messages", index: "firebase", type: "message", fields: ['msg', 'name'], filter: function(data) { return data.name !== 'system'; } }]; </code></pre> <p>This is the structure of the user node in Firebase (it's located at the root).</p> <pre><code>"users" : { "userid123" : { "friends" : { "userid42" : 1 }, "recs" : { "-recid1234" : 0 }, "user_info" : { "createdAt" : 1475157596, "email" : "e@male.org", "name" : "Firstname Lastname Johnson", "profilePicture" : "png.jpg", "pushId" : { }, "username" : "userLooser" } }, "userid42" : { "friends" : { "userid123" : 1, "test1" : 1 }, "recs" : { "-recid5678" : 0 }, "user_info" : { "email" : "email@icloud.com", "name" : "Firstname Lastname", "phoneNumber" : "", "profilePicture" : "jpg.png", "pushId" : { }, "username" : "userName" } } } } </code></pre> <p>What I want to achieve is to search for username, and return the top results. All i really need in return is the username and user id's.</p> <p><a href="https://i.stack.imgur.com/9iIDi.png" rel="nofollow"><img src="https://i.stack.imgur.com/9iIDi.png" alt="Image of firebase search query"></a></p> <p>But I get the response below, when I query with the object in the image above:</p> <pre><code> "search" : { "response" : { "index" : { ".priority" : 1.477326417519E12, "hits" : [ { "_id" : "test1", "_index" : "firebase", "_score" : 1, "_source" : { "friends" : { "test1" : 1 }, "recs" : { }, "user_info" : { "createdAt" : 1475157596, "name" : "Testbruker 1", "username" : "testuzer" } }, "_type" : "user" }, { "_id" : "userid123", "_index" : "firebase", "_score" : 1, "_source" : { "friends" : { }, "recs" : { }, "user_info" : { "email" : "", "name" : "Firstname Lastname", "phoneNumber" : "", "profilePicture" : "", "pushId" : { }, "username" : "profileName" } }, "_type" : "user" }, { "_id" : "userid42", "_index" : "firebase", "_score" : 1, "_source" : { "friends" : { }, "recs" : { }, "user_info" : { "createdAt" : 1475157596, "email" : "e@male.org", "name" : "Firstname Lastname Johnson", "profilePicture" : "", "pushId" : { }, "username" : "userLooser" } }, "_type" : "user" } ], "max_score" : 1, "total" : 3 }, "query" : { ".priority" : 1.477326417484E12, "hits" : [ { "_id" : "test1", "_index" : "firebase", "_score" : 1, "_source" : { "friends" : { "test1" : 1 }, "recs" : { }, "user_info" : { "createdAt" : 1475157596, "name" : "Testbruker 1", "username" : "testuzer" } }, "_type" : "user" }, { "_id" : "userid42", "_index" : "firebase", "_score" : 1, "_source" : { "friends" : { }, "recs" : { }, "user_info" : { "email" : "", "name" : "Firstname Lastname", "phoneNumber" : "", "profilePicture" : "", "pushId" : { }, "username" : "profileName" } }, "_type" : "user" }, { "_id" : "userid123", "_index" : "firebase", "_score" : 1, "_source" : { "friends" : { }, "recs" : { }, "user_info" : { "createdAt" : 1475157596, "email" : "e@male.org", "name" : "Firstname Lastname Johnson", "profilePicture" : "", "pushId" : { }, "username" : "userLooser" } }, "_type" : "user" } ], "max_score" : 1, "total" : 3 }, "type" : { ".priority" : 1.477326417503E12, "hits" : [ { "_id" : "test1", "_index" : "firebase", "_score" : 1, "_source" : { "friends" : { "test1" : 1 }, "recs" : { }, "user_info" : { "createdAt" : 1475157596, "name" : "Testbruker 1", "username" : "testuzer" } }, "_type" : "user" }, { "_id" : "userid42", // Same content as above }, { "_id" : "userid123", // Same content as above } ], "max_score" : 1, "total" : 3 } } } </code></pre> <p>Which:</p> <ul> <li><strong>A)</strong> Does not return the correct sorting. The first result didn't match my search query at all, it just looks like it returns all users in random order.</li> <li><strong>B)</strong> The response is really messy. under <code>/response</code> there is three nodes <code>query</code>, <code>type</code> and <code>index</code> all containing lot's of hits. </li> </ul> <p>So, anyone know what's wrong? How can I create a query, or craft the path monitor so the search will work? And maybe get a simpler response?</p>
0debug
I want to update at the condition if record is already exist in database in asp.net mvc. here is my code. it is not working : I want to update the condition if the record already exists in database in asp.net MVC. here is my code. it is not working. Here my code it is not working. [HttpPost] [ValidateAntiForgeryToken] public ActionResult ProductDiscount(ProductDiscount productDiscount) { if (!ModelState.IsValid) { var viewModel = new ViewModelProductDiscount() { Products = _context.Products.ToList() }; return View(viewModel); } var id = productDiscount.ProductId; var disInDb = _context.ProductDiscounts.FirstOrDefault(p => p.ProductId == id); if (disInDb==null) { _context.ProductDiscounts.Add(productDiscount); _context.SaveChanges(); } else { _context.ProductDiscounts.Add(disInDb); _context.SaveChanges(); return Content(disInDb.Id.ToString()); } return RedirectToAction("Products"); }
0debug
Where to write python code in anaconda : <p>I have downloaded the anaconda distribution for the python but now I didn't find that where to write python programs like I was writing python code using python IDLE. Please help me to get rid of this problem</p> <p>Thanks in Advance :)</p> <p>P.S:- I only have anaconda and I have not downloaded python from its website or I don't have any previous versions of python installed on my system.</p>
0debug
TypeError: Object of type 'float32' is not JSON serializable : <p>I'm working with <code>numpy.float32</code> numbers and they don't go into <code>JSON</code>. What's the right approach to overcome this issue? </p> <pre><code>import numpy as np import json a = np.float32(1) json.dumps(a) TypeError: Object of type 'float32' is not JSON serializable </code></pre>
0debug
why does the value of this code always return true and not false/else statement (for a password checker program)? : This piece of code uses isdigit() and islower() which both check if a string includes only numbers(isdigit) or only lowercase letters(islower). If the string given through password contains only numbers or lowercase letters the value should return true and print "only numbers" if the string only contains numbers or "only letters" if the string contains only letters, which it does, however if the password contains numbers and letters for example "12345qwerty" it should return the value false right and go onto the elif statement to check if it has a number or letter included to say add 5 points and if it still doesn't then it will say try again but it doesn't it stil returns the value as rue and print the if statements argument which doesnt make sense since the password "12345qwerty" contain both letters and numbers and should be returned as false. could someone explain why its doing this and solution's with it. Thank you. import re password = input("") if password.isdigit(): print("only numbers ") elif re.search("[1-9]", password): print("thats 5 points") else: print("try again") if password.islower(): print("only letters ") elif re.search("[a-z]", password): print("thats 5 points") else: print("try again")
0debug
Veritcal histogram without arrays - java : I have to write an app which will get 3 numbers from user and create a histogram. F.g: Input: 2, 4, 3 Output: * ** *** *** It's not that easy, because I can't use any array. I had an idea to find the biggest number and then create the loop for(int i = max; i > 0; i--) but I have no idea what to put in the loop.
0debug
how to redirect banner logo image to home.php in codeignitor : i want my website banner logo redirect to home.phppresently using this code in codeignitor header file <div class="fleft"> <h1 class="logo"> <a href="#"><img src="<?php echo base_url('assets/img/Green-Surfer-Png.png')?>" id ="Green Surfer Logo" alt="Green Surfer"></a> </h1> </div>
0debug
Please help me with my python homework : [Homework Requirement][1] [This is how the file I am supposed to open look like][2] Please help me with my python homework. I am supposed to make some exceptions to my calculations. For example, when I had something like 25/0 it will become an error. How am I suppose to make an exception? This is my current code: import os.path fLocation="//Users//Ivan//Desktop//" print("Assumed file location is at: ", fLocation) fName = input("\nPlease enter a file name with its extension (ex. XXX.txt): ") fin = open(fLocation + fName, 'r') fLinesList=fin.readlines() fin.close() print('*' * 50, "\nData items have been read from file:\n\t" + fLocation + fName + '\n') print('-' * 30, "\nThe list of the lines in the file:\n", fLinesList) print("\nThere are", len(fLinesList), "lines\n") # Print file content line by line print('\n' + '-' * 30 + '\nFile "' + fName + '" contains:\n') print(fLinesList[0].strip()) print(fLinesList[1].strip()) print(fLinesList[2].strip()) print(fLinesList[3].strip()) print(fLinesList[4].strip()) print(fLinesList[5].strip()) wordsInLine4 = fLinesList[4].split() print('-' * 30, "\nwords in line4 =", wordsInLine4) QualityPointsprevious=float(wordsInLine4[6]) HoursAttemptedprevious=float(wordsInLine4[2]) GPAprevious=format(QualityPointsprevious/HoursAttemptedprevious,'.2f') wordsInLine5 = fLinesList[5].split() print('-' * 30, "\nwords in line5 =", wordsInLine5) QualityPointsnow=float(wordsInLine5[6]) HoursAttemptednow=int(wordsInLine5[2]) GPAnow=format(QualityPointsnow/HoursAttemptednow,'.2f') if (OverallHoursAttempted==0,OverallQualityPoints!=0): OverallGPA==-1 else: if (OverallHoursAttempted==0,OverallQualityPoints==0): OverallGPA==0 else: if (GPAprevious==-1): OverallGPA==-1 OverallQualityPoints=QualityPointsprevious+QualityPointsnow OverallHoursAttempted=HoursAttemptedprevious+HoursAttemptednow OverallGPA=format(OverallQualityPoints/OverallHoursAttempted,'.2f') QualityPointsprevious=str(QualityPointsprevious) HoursAttemptedprevious=str(HoursAttemptedprevious) QualityPointsnow=str(QualityPointsnow) HoursAttemptednow=str(HoursAttemptednow) save_path='C:\\TEMP\\' text1=fLinesList[0] text2=fLinesList[1] text3=fLinesList[2] text4=fLinesList[3] text5=fLinesList[4] text51=fLinesList[5] text6="\n---------------------------" text7="\nPrevious GPA:\t"+GPAprevious text8="\nCurrent GPA:\t"+GPAnow text9="\nOverall GPA:\t"+OverallGPA text1=str(text1) text2=str(text2) text3=str(text3) text4=str(text4) text5=str(text5) text51=str(text51) text6=str(text6) text7=str(text7) text8=str(text8) text9=str(text9) wordsInLine0 = fLinesList[0].split() print('-' * 30, "\nwords in line0 =", wordsInLine0) lnameofstudent=wordsInLine0[2] fnameofstudent=wordsInLine0[1] lnameofstudent=str(wordsInLine0[2]) fnameofstudent=str(wordsInLine0[1]) name=fnameofstudent+" "+lnameofstudent saveFile=open("C://TEMP//"+name+".txt","w") saveFile.write(text1) saveFile.write(text2) saveFile.write(text3) saveFile.write(text4) saveFile.write(text5) saveFile.write(text51) saveFile.write(text6) saveFile.write(text7) saveFile.write(text8) saveFile.write(text9) saveFile.close() [1]: https://i.stack.imgur.com/zhnJI.png [2]: https://i.stack.imgur.com/ND3iR.png
0debug
Is this right format of JSON : **is this write format of json** { "success": "false", "http": "ok", "status_code": "200", "invoice_detail": { "notifications": [ { "quantity": "414", "price": "5412", "total_price": "15748", "name": "Axel_Item_5412" }, { "quantity": "414", "price": "5412", "total_price": "15748", "name": "Axel_Item_5412" }, { "quantity": "414", "price": "5412", "total_price": "15748", "name": "Axel_Item_5412" }, { "quantity": "414", "price": "5412", "total_price": "15748", "name": "Axel_Item_5412" }, { "quantity": "414", "price": "5412", "total_price": "15748", "name": "Axel_Item_5412" }, { "quantity": "414", "price": "5412", "total_price": "15748", "name": "Axel_Item_5412" }, { "quantity": "414", "price": "5412", "total_price": "15748", "name": "Axel_Item_5412" }, { "quantity": "414", "price": "5412", "total_price": "15748", "name": "Axel_Item_5412" } ] }, "sgst": "125478122" }
0debug
Get file extension with bash script : <p>i' m trying to extract the file extension in bash without using regex. i' ve tried the following </p> <pre><code>extension = $(echo $1 | cut -f 2 -d '.') </code></pre> <p>extension is the variable $1 contains something like: file.txt or file.pdf etc. this code is outputting:</p> <pre><code>./prova.sh: 3: ./prova.sh: extension: not found </code></pre>
0debug
Play JSON video : I have JSON Array. Here is my JSON data. { "product_id":1 "video":"<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/g1XPcFwyUts\" frameborder=\"0\" allowfullscreen></iframe>" } I need play this video(p.video). Kindly advice me, Thanks.
0debug
this method add a request to a queue but what is done in second line of code ? : public <T> void addToRequestQueue(Request<T> req, String tag) { req.setTag(TextUtils.isEmpty(tag) ? TAG : tag); getRequestQueue().add(req); } what is done in this second line i cant understand what is this (tag) ?TAG :tag ...I mean what is this code done
0debug
Exception Unhandled Error when trying to use function in catch block : <p>I am trying to run a simple code where an error is throw when the its looking for a vector position out of range. But when I run the code, I get an error</p> <pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; using namespace std; void error() { throw(" a standard exception was caught, with message \n"); } int main() { try { cout &lt;&lt; "Creating a vector of size 5... \n"; vector&lt;int&gt; v(5); cout &lt;&lt; "Accessing the 11th element of the vector...\n"; cout &lt;&lt; v.at(10); } catch (const exception&amp; e) { error(); } system("PAUSE"); return 0; } </code></pre>
0debug
How to secure a Firebase database if I don't want users to have a login? : <p>I want to store some user information without any authentication from Android. The information is not important, doesn't need to be secure and the users don't need to have a login. The only way I've figured out how to do it is to use these rules:</p> <pre><code>{ "rules": { ".read": "auth != null", ".write": "auth != null" } } </code></pre> <p>But firebase tells me that is not secure and I should secure it. So how can I secure it? I am using <code>signInAnonymously()</code> on the <code>FirebaseAuth</code> instance. </p>
0debug
bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs) { BlockDriverInfo bdi; if (bs->backing_hd || !(bs->open_flags & BDRV_O_UNMAP)) { return false; } if (bdrv_get_info(bs, &bdi) == 0) { return bdi.can_write_zeroes_with_unmap; } return false; }
1threat
static int v9fs_synth_chmod(FsContext *fs_ctx, V9fsPath *path, FsCred *credp) { errno = EPERM; return -1; }
1threat
VueJs router-view transitions : <p>I am trying to create some transitions on my router-view components every time I click a new link. The problem is that only one of the fade animations will work. For example, it will fade out, but the new page will appear immediately like normal. Basically I can only have either an enter-active-class or a leave-active-class, but not both at the same time.</p> <pre><code>&lt;template&gt; &lt;div class="tom-layout"&gt; &lt;navBar class="z-depth-0"&gt;&lt;/navBar&gt; &lt;div class="content-layout"&gt; &lt;transition name="fade"&gt; &lt;router-view&gt;&lt;/router-view&gt; &lt;/transition&gt; &lt;/div&gt; &lt;/div&gt; &lt;/template&gt; &lt;script&gt; import NavBar from './components/NavBar.vue'; export default { components: { navBar: NavBar } } &lt;/script&gt; &lt;style lang="scss"&gt; @import url('https://fonts.googleapis.com/css?family=Ek+Mukta'); body { overflow: hidden; .content-layout { margin-top: -64px; width: 100%; z-index: -5; } } .fade-enter { opacity: 0; } .fade-enter-active { transition: opacity 2s ease; } .fade-leave { } .fade-leave-active { transition: opacity 2s ease; opacity: 0; } </code></pre>
0debug
static inline void mix_2f_1r_to_stereo(AC3DecodeContext *ctx) { int i; float (*output)[256] = ctx->audio_block.block_output; for (i = 0; i < 256; i++) { output[1][i] += output[2][i]; output[2][i] += output[3][i]; } memset(output[3], 0, sizeof(output[3])); }
1threat
MUST iOS live video use HLS? : <p>I'd like to make an app that can play live video and start to learn hls, rtmp, rtsp.But documentation of Apple require developer use hls for live video, or will be rejected for distribution.Does any one use rtmp in your app and success to sale in AppStore?</p>
0debug
How to change button CSS click / drag color? : <p>You can checkout my website here: <a href="https://www.counterboosting.com/buy-csgo-rank-boosting/" rel="nofollow">https://www.counterboosting.com/buy-csgo-rank-boosting/</a></p> <p>When dragging the "Buy Now" button, it will randomly turn green. If anyone could help me keep it orange as it is. Thanks!</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.col-boosting .btn-pay-rank { height: 65px; font-weight: bold; background: #e06b38; border: none; box-shadow: 0 7px 0 0 #c7511f; } .col-boosting .btn-pay-rank:hover { height: 65px; background: #dd5a22; font-weight: bold; border: none; box-shadow: 0 7px 0 0 #c7511f; } .col-boosting .btn-pay-rank[disabled] { height: 65px; font-weight: bold; background: #e06b38; border: none; box-shadow: 0 7px 0 0 #c7511f; } .col-boosting .btn-default { height: 65px; font-weight: bold; background: #e06b38; border: none; box-shadow: 0 7px 0 0 #c7511f; } .col-boosting .btn { height: 65px; font-weight: bold; background: #e06b38; border: none; box-shadow: 0 7px 0 0 #c7511f; } .col-boosting .btn-primary { height: 65px; font-weight: bold; background: #e06b38; border: none; box-shadow: 0 7px 0 0 #c7511f; } .col-boosting .btn-pay-rank-primary:hover, .col-boosting .btn-pay-rank-primary:focus, .col-boosting .btn-pay-rank-primary:active, .col-boosting .btn-pay-rank-primary.active, .open &gt; .dropdown-toggle.btn-pay-rank-primary { height: 65px; font-weight: bold; background: #e06b38; border: none; box-shadow: 0 7px 0 0 #c7511f; } .col-boosting .btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active, .open &gt; .dropdown-toggle.btn-primary { height: 65px; font-weight: bold; background: #e06b38; border: none; box-shadow: 0 7px 0 0 #c7511f; } .col-boosting .btn-primary:active, .col-boosting .btn-primary.active { height: 65px; font-weight: bold; background: #e06b38; border: none; box-shadow: 0 7px 0 0 #c7511f; }</code></pre> </div> </div> </p> <p>As you can see, I pretty much tried everything and I can't seem to find a solution. Some help would be greatly appreciated. Thanks!</p>
0debug
for loops in C with incrementing a counter and short-hand counter++ : <pre><code>for i := 0 to 5 do begin i := i + 1; counter++ end; </code></pre> <p>I am trying to write the code for a loop in C that will increment a counter from 0 to 5, writing out the counter value with each iteration. Use the C short-hand: counter++ to increment counter by 1 in each iteration of the loop. Am I doing it right?</p>
0debug
From python 3 to Python 2 (print()) : <p>I think the piece of code below is written in python 3 and my python 2 cannot run it. There is some problem with 'end'. How could I fix it? I don't know what is the logic behind end an i am very new to python </p> <p>Any help much appreciated! </p> <pre><code>def myPrint(itp): for i in range(10): print("**",end=="") for j in range(10): print(itp[i][j],"**",end=="") print() </code></pre>
0debug
void do_POWER_divs (void) { if ((Ts0 == INT32_MIN && Ts1 == -1) || Ts1 == 0) { T0 = (long)((-1) * (T0 >> 31)); env->spr[SPR_MQ] = 0; } else { env->spr[SPR_MQ] = T0 % T1; T0 = Ts0 / Ts1; } }
1threat
comparison between various method to get size of a string : <p>which way of finding the size of the string in a loop is efficient. what is time complexity comparison of these methods?</p> <pre><code> for(int i = 0; i &lt; s.size(); i++) { //statements } for(int i = 0; s[i] != '\0'; i++) { //statements } for(int i = 0; i &lt; strlen(s); i++) { //statements } </code></pre> <p>how strlen different from size()?</p>
0debug
Best way of comparing two files in python and why? : <p>I have two files a.txt and b.txt, So i am trying to compare using hash like below.</p> <pre><code>#getting hash of files and comparing file1 = hashlib.md5(open('a.txt', 'rb').read()).hexdigest() file2 = hashlib.md5(open('b.txt', 'rb').read()).hexdigest() file1==file2--&gt; returns True or False </code></pre> <p>this is one way and also we can do using filecmp as below</p> <pre><code>filecmp.cmp('a.txt','b.txt')--&gt; returns True or False </code></pre> <p>In both of these ways which is better and why?</p>
0debug
ssize_t qemu_put_compression_data(QEMUFile *f, const uint8_t *p, size_t size, int level) { ssize_t blen = IO_BUF_SIZE - f->buf_index - sizeof(int32_t); if (blen < compressBound(size)) { return 0; } if (compress2(f->buf + f->buf_index + sizeof(int32_t), (uLongf *)&blen, (Bytef *)p, size, level) != Z_OK) { error_report("Compress Failed!"); return 0; } qemu_put_be32(f, blen); f->buf_index += blen; return blen + sizeof(int32_t); }
1threat
static void init_event_facility(Object *obj) { SCLPEventFacility *event_facility = EVENT_FACILITY(obj); DeviceState *sdev = DEVICE(obj); qbus_create_inplace(&event_facility->sbus, sizeof(event_facility->sbus), TYPE_SCLP_EVENTS_BUS, sdev, NULL); object_initialize(&event_facility->quiesce_event, sizeof(SCLPEvent), TYPE_SCLP_QUIESCE); qdev_set_parent_bus(DEVICE(&event_facility->quiesce_event), &event_facility->sbus.qbus); object_initialize(&event_facility->cpu_hotplug_event, sizeof(SCLPEvent), TYPE_SCLP_CPU_HOTPLUG); qdev_set_parent_bus(DEVICE(&event_facility->cpu_hotplug_event), &event_facility->sbus.qbus); }
1threat
Click On Image To Open New Tab In HTML Page : <p>Click On Image To Open New Tab In HTML Page how can i add clickable image to open new tab in html page?</p>
0debug
Extending 'if statement' to include an else clause : <p>How would I extent the following if statement so that the logic included an else clause. The pseudocode would function as follows.</p> <ul> <li>Ideal_Singers = each name that contains '(Beatle)' and either ('Paul', 'Yoko' or 'Ringo')</li> <li>if none of the names in the list meet these conditions, then Ideal_Singers = each name that contains 'Mick' </li> </ul> <p>So far, I have this code:</p> <pre><code>Names = ["John Lennon (Beatle)", "Paul McCartney (Beatle)", "Ringo Starr (Beatle)", "Yoko Ono (Beatle)", "Mick Jagger (Rolling Stone)", "Brian Jones (Rolling Stone)", "Alex Jones (na)", "Adam Smith (na)"] Ideal_Singers = [n for n in Names if "Beatle" in n and ("Paul" in n or "Ringo" in n or "Yoko" in n)] print Ideal_Singers </code></pre>
0debug
How to add the output of each html page into multiple files in python? : I created a code that would generate each html page as output to save in different files by iteration of for loop. import requests import urllib.request def crawlpages(): for i in range(1451720, 1451730): link = "https://www.mmo-champion.com/members/" + str(i) content = urllib.request.urlopen(link) mydata = content.read() with open('Newfile.html%s' %i,'wb') as file: file.write(mydata) crawlpages()
0debug
Which database to use to build an analytics app with PHP: what should have I to search for to find an answer : <p>I know the question I'm posting is a bit broad, but unfortunately I have no idea of what to search for.</p> <p>So, my real question is: what should have I to search for to understand how to store and read data that need to be processed to get reports about something?</p> <p>I'm referring to applications like Google Adwords, SemRush, Facebook Analytics and, in general, any kind of application that collect a very big amount of data and then use it to build reports.</p> <p>Currently I use MySQL but I've read many times that it isn't the best solution to choose when approaching such kind of tasks.</p> <p><strong>So, which should be my starting point to understand which alternatives I have and, after, to choose one?</strong></p>
0debug