problem
stringlengths
26
131k
labels
class label
2 classes
What is with the space in between these divs : <p>There is a space in between the two divs at the bottom of my <a href="http://rainbowhover.ml" rel="nofollow noreferrer">website</a>. How can I get them to get back together using CSS? The source code is <a href="https://github.com/talonbragg/RainbowHover" rel="nofollow noreferrer">here</a>.</p>
0debug
What's the syntax error in this simple mysql query ? : create table table1(date DATE PRIMARY KEY, open float(10,6), high float(10,6), low float(10,6), close float(10,6), volume INT(10), adj_close float(10,6);
0debug
static int adx_read_header(AVFormatContext *s) { ADXDemuxerContext *c = s->priv_data; AVCodecParameters *par; AVStream *st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); par = s->streams[0]->codecpar; if (avio_rb16(s->pb) != 0x8000) return AVERROR_INVALIDDATA; c->header_size = avio_rb16(s->pb) + 4; avio_seek(s->pb, -4, SEEK_CUR); if (ff_get_extradata(s, par, s->pb, c->header_size) < 0) return AVERROR(ENOMEM); if (par->extradata_size < 12) { av_log(s, AV_LOG_ERROR, "Invalid extradata size.\n"); return AVERROR_INVALIDDATA; } par->channels = AV_RB8 (par->extradata + 7); par->sample_rate = AV_RB32(par->extradata + 8); if (par->channels <= 0) { av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", par->channels); return AVERROR_INVALIDDATA; } if (par->sample_rate <= 0) { av_log(s, AV_LOG_ERROR, "Invalid sample rate %d\n", par->sample_rate); return AVERROR_INVALIDDATA; } par->codec_type = AVMEDIA_TYPE_AUDIO; par->codec_id = s->iformat->raw_codec_id; par->bit_rate = par->sample_rate * par->channels * BLOCK_SIZE * 8LL / BLOCK_SAMPLES; avpriv_set_pts_info(st, 64, BLOCK_SAMPLES, par->sample_rate); return 0; }
1threat
Python return statement error “ return outside function” : <p>When running the following code (in Python 3.6.1) </p> <pre><code>def compute_cost(X, y, theta): m = y.size #Nombre des exemples de l'apprentissage predictions = X.dot(theta) sqErrors = (predictions - y) J = (1.0 / (2 * m)) * sqErrors.T.dot(sqErrors) return J </code></pre> <p>I get the following error</p> <pre><code>SyntaxError: 'return' outside function </code></pre> <p>Any help would be appreciated. Thanks!</p>
0debug
File input on change in vue.js : <p>Using plain HTML/JS, it is possible to view the JavaScript File objects of selected files for an input element like so:</p> <pre><code>&lt;input type="file" id="input" multiple onchange="handleFiles(this.files)"&gt; </code></pre> <p>However, when converting it to the 'Vue' way it doesn't seem to work as intend and simply returns <code>undefined</code> instead of returning an Array of File objects. </p> <p>This is how it looks in my Vue template:</p> <pre><code>&lt;input type="file" id="file" class="custom-file-input" v-on:change="previewFiles(this.files)" multiple&gt; </code></pre> <p>Where the <code>previewFiles</code> function is simply the following (located in methods): </p> <pre><code> methods: { previewFiles: function(files) { console.log(files) } } </code></pre> <p>Is there an alternate/correct way of doing this? Thanks</p>
0debug
Handle multiple events in gpio : <p>I'm new to embedded programming and I apologise in advance for any confusion.</p> <p>I need to handle multiple events from different devices connected to a gpio. These events need to be monitored continually. This means that after one event is generated and handled, the code needs to keep monitoring the device for other events.</p> <p>I understand the concept of interruptions and polling in Linux (the kernel gets an interruption and dispatch it to the handler which goes on up to the callee of an epoll which is inside an infinite loop while(1)-like). </p> <p>This is fine for one-time, single-event toy models. In a embedded system with limited resources such as the <a href="https://www.digikey.com/eewiki/display/linuxonarm/AT91SAM9x5#AT91SAM9x5-LinuxKernel" rel="nofollow noreferrer">AT91SAM9x5</a> that runs at 400mhz and has 128mb of ram what can I do ? I believe that the while(1)-like pattern isn't the best choice. I've heard good things about thread pool solution but at the heart of each thread don't we find a while(1) ? </p> <p>What are my options to attack this problem ?</p> <p>Thank you in advance !</p>
0debug
static int flv_data_packet(AVFormatContext *s, AVPacket *pkt, int64_t dts, int64_t next) { AVIOContext *pb = s->pb; AVStream *st = NULL; char buf[20]; int ret = AVERROR_INVALIDDATA; int i, length = -1; switch (avio_r8(pb)) { case AMF_DATA_TYPE_MIXEDARRAY: avio_seek(pb, 4, SEEK_CUR); case AMF_DATA_TYPE_OBJECT: break; default: goto skip; } while ((ret = amf_get_string(pb, buf, sizeof(buf))) > 0) { AMFDataType type = avio_r8(pb); if (type == AMF_DATA_TYPE_STRING && !strcmp(buf, "text")) { length = avio_rb16(pb); ret = av_get_packet(pb, pkt, length); if (ret < 0) goto skip; else break; } else { if ((ret = amf_skip_tag(pb, type)) < 0) goto skip; } } if (length < 0) { ret = AVERROR_INVALIDDATA; goto skip; } for (i = 0; i < s->nb_streams; i++) { st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_DATA) break; } if (i == s->nb_streams) { st = create_stream(s, AVMEDIA_TYPE_DATA); if (!st) return AVERROR_INVALIDDATA; st->codec->codec_id = AV_CODEC_ID_TEXT; } pkt->dts = dts; pkt->pts = dts; pkt->size = ret; pkt->stream_index = st->index; pkt->flags |= AV_PKT_FLAG_KEY; skip: avio_seek(s->pb, next + 4, SEEK_SET); return ret; }
1threat
Finding a string within another string using C# : <p>How do I find out if one of my strings occurs in the other in C#?</p> <p>For example, there are 2 strings: string 1= "The red umbrella"; string 2= "red"; How would I find out if string 2 appears in string 1 or not?</p>
0debug
Java While avance x loops : I have an example of Java in Eclipse Mars. I will ilustrate it with a simplifier example: while( rowSet.next() ){ //OPERATIONS } I know that my rowset lenght is 50, I want to debug loop number 48, but for it I dont want to go through the while 48 times. do you know how to position my debug in loop 48? Thanks JP
0debug
Cannot create only IAM policy with cloudformation : <p>I am having issue with creating IAM policy in cloudformation.But when I run it I get the error that Groups,Roles,Users is required:</p> <p>Here is my code:</p> <pre><code>{ "AWSTemplateFormatVersion": "2010-09-09", "Description": "AWS CloudFormation Template IAM Groups and Policies", "Resources": { "PolicyAutoScalingLimitedOperation": { "Type": "AWS::IAM::Policy", "Properties": { "PolicyName": "AutoScaling-Limited-Operation", "PolicyDocument": { "Statement": [{ "Effect": "Allow", "Action": [ "dynamodb:*" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "cloudwatch:PutMetricData" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "xray:PutTraceSegments", "xray:PutTelemetryRecords" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "s3:Get*", "s3:List*", "s3:PutObject" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "logs:PutLogEvents", "logs:CreateLogStream" ], "Resource": "arn:aws:logs:*:*:log-group:/aws/elasticbeanstalk*" }, { "Effect": "Allow", "Action": [ "kms:ListAliases", "kms:ListKeys", "kms:Encrypt", "kms:Decrypt" ], "Resource": "*" } ] } } } } </code></pre> <p>}</p> <p>Now when I run it I get:</p> <pre><code>At least one of [Groups,Roles,Users] must be non-empty. </code></pre> <p>Does that mean I cannot create policy with cloudformation without adding user/role to it?</p>
0debug
how to split ruby code like c or c++ code : I'd like to split the long ruby code into another ruby source files, in c source file , I can put the code like this: ``` a.c if (xxx) #include "my_file.c" my_file.c printf("yes we are in xxx conditions"); ``` now in ruby code I can't do that like: ``` a.rb case condition when "a" puts "a" load (or include "b.rb") end b.rb when "b" puts "we are in b.rb" ``` so how to solve the ruby code just like in c source file. thanks
0debug
What is an intuitive explanation of np.unravel_index? : <p>Pretty much what the title says. I've read the documentation and I've played with the function for a while now but I can't discern what the physical manifestation of this transformation is. </p>
0debug
How do I make grouped data in R and create variables in the heading when reading a data table? : [enter image description here][1] [1]: https://i.stack.imgur.com/xPrJD.png Hi. I am trying to make a data table in R, where there is a heading with variables and a subheading with 4 "reps" grouped to each variable.. How do I do this? It does not look right at this moment...
0debug
static int armv7m_nvic_init(SysBusDevice *dev) { nvic_state *s = NVIC(dev); NVICClass *nc = NVIC_GET_CLASS(s); s->gic.num_cpu = 1; s->gic.revision = 0xffffffff; s->num_irq = s->gic.num_irq; nc->parent_init(dev); gic_init_irqs_and_distributor(&s->gic, s->num_irq); memory_region_init(&s->container, "nvic", 0x1000); memory_region_init_io(&s->sysregmem, &nvic_sysreg_ops, s, "nvic_sysregs", 0x1000); memory_region_add_subregion(&s->container, 0, &s->sysregmem); memory_region_init_alias(&s->gic_iomem_alias, "nvic-gic", &s->gic.iomem, 0x100, 0xc00); memory_region_add_subregion_overlap(&s->container, 0x100, &s->gic_iomem_alias, 1); memory_region_add_subregion(get_system_memory(), 0xe000e000, &s->container); s->systick.timer = qemu_new_timer_ns(vm_clock, systick_timer_tick, s); return 0; }
1threat
Is it ok to use ReactDOMServer.renderToString in the browser in areas where React isn't directly managing the DOM? : <p>I'm working on an app using <a href="http://leafletjs.com/" rel="noreferrer">Leaflet</a> (via <a href="https://github.com/PaulLeCam/react-leaflet" rel="noreferrer">react-leaflet</a>). Leaflet directly manipulates the DOM. The react-leaflet library doesn't change that, it just gives you React components that you can use to control your Leaflet map in a React-friendly way.</p> <p>In this app, I want to use custom map markers that are divs containing a few simple elements. The way to do that in Leaflet is to set your marker's <code>icon</code> property to a <a href="http://leafletjs.com/reference.html#divicon" rel="noreferrer">DivIcon</a>, in which you can set your custom HTML. You set that inner HTML by setting the DivIcon's <code>html</code> property to a string containing the HTML. In my case, I want that HTML to be rendered from a React component.</p> <p>In order to do that, it seems like the correct approach is to use <code>ReactDOMServer.renderToString()</code> to render the Component that I want inside the map marker into a string, which I would then set as the <code>html</code> property of the DivIcon:</p> <p><strong><em>MyMarker.js:</em></strong></p> <pre><code>import React, { Component } from 'react' import { renderToString } from 'react-dom/server' import { Marker } from 'react-leaflet' import { divIcon } from 'leaflet' import MarkerContents from './MarkerContents' export class MyMarker extends Component { render() { const markerContents = renderToString(&lt;MarkerContents data={this.props.data} /&gt;) const myDivIcon = divIcon({ className: 'my-marker', html: markerContents }) return ( &lt;Marker position={this.props.position} icon={myDivIcon} /&gt; ) } } </code></pre> <p>However, according to the <a href="https://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostring" rel="noreferrer">React docs</a>:</p> <blockquote> <p>This [renderToString] should only be used on the server.</p> </blockquote> <p>Is this a strict rule, or is it only meant to dissuade people from circumventing ReactDOM's efficient management of the DOM?</p> <p>I can't think of another (better) way to accomplish what I'm after. Any comments or ideas would be greatly appreciated.</p>
0debug
static void mxf_write_generic_sound_common(AVFormatContext *s, AVStream *st, const UID key, unsigned size) { AVIOContext *pb = s->pb; mxf_write_generic_desc(s, st, key, size+5+12+8+8); mxf_write_local_tag(pb, 1, 0x3D02); avio_w8(pb, 1); mxf_write_local_tag(pb, 8, 0x3D03); avio_wb32(pb, st->codec->sample_rate); avio_wb32(pb, 1); mxf_write_local_tag(pb, 4, 0x3D07); avio_wb32(pb, st->codec->channels); mxf_write_local_tag(pb, 4, 0x3D01); avio_wb32(pb, av_get_bits_per_sample(st->codec->codec_id)); }
1threat
int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transform, int ilv){ int i, t = 0; uint8_t *zero, *last, *cur; JLSState *state; int off = 0, stride = 1, width, shift; zero = av_mallocz(s->picture.linesize[0]); last = zero; cur = s->picture.data[0]; state = av_mallocz(sizeof(JLSState)); state->near = near; state->bpp = (s->bits < 2) ? 2 : s->bits; state->maxval = s->maxval; state->T1 = s->t1; state->T2 = s->t2; state->T3 = s->t3; state->reset = s->reset; ff_jpegls_reset_coding_parameters(state, 0); ff_jpegls_init_state(state); if(s->bits <= 8) shift = point_transform + (8 - s->bits); else shift = point_transform + (16 - s->bits); if (s->avctx->debug & FF_DEBUG_PICT_INFO) { av_log(s->avctx, AV_LOG_DEBUG, "JPEG-LS params: %ix%i NEAR=%i MV=%i T(%i,%i,%i) RESET=%i, LIMIT=%i, qbpp=%i, RANGE=%i\n", s->width, s->height, state->near, state->maxval, state->T1, state->T2, state->T3, state->reset, state->limit, state->qbpp, state->range); av_log(s->avctx, AV_LOG_DEBUG, "JPEG params: ILV=%i Pt=%i BPP=%i, scan = %i\n", ilv, point_transform, s->bits, s->cur_scan); } if(ilv == 0) { stride = (s->nb_components > 1) ? 3 : 1; off = av_clip(s->cur_scan - 1, 0, stride); width = s->width * stride; cur += off; for(i = 0; i < s->height; i++) { if(s->bits <= 8){ ls_decode_line(state, s, last, cur, t, width, stride, off, 8); t = last[0]; }else{ ls_decode_line(state, s, last, cur, t, width, stride, off, 16); t = *((uint16_t*)last); } last = cur; cur += s->picture.linesize[0]; if (s->restart_interval && !--s->restart_count) { align_get_bits(&s->gb); skip_bits(&s->gb, 16); } } } else if(ilv == 1) { int j; int Rc[3] = {0, 0, 0}; stride = (s->nb_components > 1) ? 3 : 1; memset(cur, 0, s->picture.linesize[0]); width = s->width * stride; for(i = 0; i < s->height; i++) { for(j = 0; j < stride; j++) { ls_decode_line(state, s, last + j, cur + j, Rc[j], width, stride, j, 8); Rc[j] = last[j]; if (s->restart_interval && !--s->restart_count) { align_get_bits(&s->gb); skip_bits(&s->gb, 16); } } last = cur; cur += s->picture.linesize[0]; } } else if(ilv == 2) { av_log(s->avctx, AV_LOG_ERROR, "Sample interleaved images are not supported.\n"); av_free(state); av_free(zero); return -1; } if(shift){ int x, w; w = s->width * s->nb_components; if(s->bits <= 8){ uint8_t *src = s->picture.data[0]; for(i = 0; i < s->height; i++){ for(x = off; x < w; x+= stride){ src[x] <<= shift; } src += s->picture.linesize[0]; } }else{ uint16_t *src = (uint16_t*) s->picture.data[0]; for(i = 0; i < s->height; i++){ for(x = 0; x < w; x++){ src[x] <<= shift; } src += s->picture.linesize[0]/2; } } } av_free(state); av_free(zero); return 0; }
1threat
how to add where clause with two values android : i want to check password also on where public Cursor signincheck(String email,String Password) { SQLiteDatabase db=this.getWritableDatabase(); String query="SELECT * FROM " + TABLE_NAME + " WHERE EMAIL = '" + email + "'"; Cursor cursor=db.rawQuery(query, null); return cursor; }
0debug
Efficient and simple comparison operators for structs : <p>The application I am working on currently has a large number structs which contain data which is input from various sources such as data bases and files. For example like this:</p> <pre><code>struct A { float val1; std::string val2; int val3; bool operator &lt; (const A&amp; other) const; }; </code></pre> <p>For processing, these structs are stored up in STL-containers, such as maps and therefore need a comparison operator. These are all the same and using simple boolean logic they can be written like this:</p> <pre><code>bool A:operator &lt; (const A&amp; o) const { return val1 &lt; o.val1 || (val1 == o.val1 &amp;&amp; ( val2 &lt; o.val2 || (val2 == o.val2 &amp;&amp; ( val3 &lt; o.val3 ) ) ); } </code></pre> <p>This seems efficient, but has several drawbacks:</p> <ol> <li>These expressions get huge if the structs as a dozen or more members.</li> <li>It is cumbersome to write and maintain if members change.</li> <li>It needs to be done for every struct separately.</li> </ol> <p>Is there a more maintainable way to compare structs like this?</p>
0debug
how can i listen to a thread (while ???) : I want to know when my thread die and after this, execute some code. I'm using WHILE but my program is showing a bad execution... (Sorry my poor english). The command while is holding the program.... Thanks a lot! ##########CODE################# public class Thread_para_Menu extends Thread{ public void run() { System.out.println("executando thread"); for (int i = 0; i < 100; i++) { try { Thread.sleep(200); } catch (InterruptedException ex) { Logger.getLogger(Teste_Inicio.class.getName()).log(Level.SEVERE, null, ex); } if (i % 2 == 0) { jlblAguarde.setForeground(Color.yellow); } else { jlblAguarde.setForeground(Color.orange); } } System.out.println("FIM DO RUN"); } } public void Pisca_Menu (){ int xx =0; Thread_para_Menu TEMPO_MENU = new Thread_para_Menu(); TEMPO_MENU.start(); while (TEMPO_MENU.isAlive()){ System.out.println("THRE`enter code here`AD VIVE"); } System.out.println("THREAD MORREU"); }
0debug
Using autoprefixer with postcss in webpack 2.x : <p>How to use <code>autoprefixer</code> with webpack 2.x. </p> <p>Previously, it used to be something like this...</p> <pre><code>... module: { loaders: [ { test: /\.scss$/, loader: 'style!css!sass!postcss' } ] }, postcss: () =&gt; { return [autoprefixer] }, ... </code></pre> <p>But, it's not working anymore. </p> <p>How to rewrite it to webpack@2.x.x?</p>
0debug
static int vhdx_create(const char *filename, QemuOpts *opts, Error **errp) { int ret = 0; uint64_t image_size = (uint64_t) 2 * GiB; uint32_t log_size = 1 * MiB; uint32_t block_size = 0; uint64_t signature; uint64_t metadata_offset; bool use_zero_blocks = false; gunichar2 *creator = NULL; glong creator_items; BlockBackend *blk; char *type = NULL; VHDXImageType image_type; Error *local_err = NULL; image_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE); log_size = qemu_opt_get_size_del(opts, VHDX_BLOCK_OPT_LOG_SIZE, 0); block_size = qemu_opt_get_size_del(opts, VHDX_BLOCK_OPT_BLOCK_SIZE, 0); type = qemu_opt_get_del(opts, BLOCK_OPT_SUBFMT); use_zero_blocks = qemu_opt_get_bool_del(opts, VHDX_BLOCK_OPT_ZERO, true); if (image_size > VHDX_MAX_IMAGE_SIZE) { error_setg_errno(errp, EINVAL, "Image size too large; max of 64TB"); ret = -EINVAL; goto exit; } if (type == NULL) { type = g_strdup("dynamic"); } if (!strcmp(type, "dynamic")) { image_type = VHDX_TYPE_DYNAMIC; } else if (!strcmp(type, "fixed")) { image_type = VHDX_TYPE_FIXED; } else if (!strcmp(type, "differencing")) { error_setg_errno(errp, ENOTSUP, "Differencing files not yet supported"); ret = -ENOTSUP; goto exit; } else { ret = -EINVAL; goto exit; } if (block_size == 0) { if (image_size > 32 * TiB) { block_size = 64 * MiB; } else if (image_size > (uint64_t) 100 * GiB) { block_size = 32 * MiB; } else if (image_size > 1 * GiB) { block_size = 16 * MiB; } else { block_size = 8 * MiB; } } log_size = ROUND_UP(log_size, MiB); block_size = ROUND_UP(block_size, MiB); block_size = block_size > VHDX_BLOCK_SIZE_MAX ? VHDX_BLOCK_SIZE_MAX : block_size; ret = bdrv_create_file(filename, opts, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto exit; } blk = blk_new_open(filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL, &local_err); if (blk == NULL) { error_propagate(errp, local_err); ret = -EIO; goto exit; } blk_set_allow_write_beyond_eof(blk, true); creator = g_utf8_to_utf16("QEMU v" QEMU_VERSION, -1, NULL, &creator_items, NULL); signature = cpu_to_le64(VHDX_FILE_SIGNATURE); ret = blk_pwrite(blk, VHDX_FILE_ID_OFFSET, &signature, sizeof(signature), 0); if (ret < 0) { goto delete_and_exit; } if (creator) { ret = blk_pwrite(blk, VHDX_FILE_ID_OFFSET + sizeof(signature), creator, creator_items * sizeof(gunichar2), 0); if (ret < 0) { goto delete_and_exit; } } ret = vhdx_create_new_headers(blk_bs(blk), image_size, log_size); if (ret < 0) { goto delete_and_exit; } ret = vhdx_create_new_region_table(blk_bs(blk), image_size, block_size, 512, log_size, use_zero_blocks, image_type, &metadata_offset); if (ret < 0) { goto delete_and_exit; } ret = vhdx_create_new_metadata(blk_bs(blk), image_size, block_size, 512, metadata_offset, image_type); if (ret < 0) { goto delete_and_exit; } delete_and_exit: blk_unref(blk); exit: g_free(type); g_free(creator); return ret; }
1threat
Check each collumn and row for duplicate C++ : I have to check if latin square is true by user input. But i can't figure out how to do the check part. Where it checks each collumn and row for duplicate numbers. This is what i came up with, but it doesn't seem to work properly // arr= input by user in array, and n= array length by user input bool latin(int**arr,int n) { int times=0; int s; for(int j=0;j<n;j++) { for(int i=0; i<n;i++){ if (arr[i][j]==s) times++; } } if (times != 1) return false; else return true; }
0debug
document.getElementByName returned undefined for all inputs in a form : I am trying to do some calculations with some form inputs but all the element (checkbox,text etc) returned[enter image description here][1] undefined when I try to get their value using document.getElementById('income').value. [1]: https://i.stack.imgur.com/S904M.png
0debug
int qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset, int64_t size) { BDRVQcowState *s = bs->opaque; int chk = QCOW2_OL_DEFAULT & ~ign; int i, j; if (!size) { return 0; } if (chk & QCOW2_OL_MAIN_HEADER) { if (offset < s->cluster_size) { return QCOW2_OL_MAIN_HEADER; } } size = align_offset(offset_into_cluster(s, offset) + size, s->cluster_size); offset = start_of_cluster(s, offset); if ((chk & QCOW2_OL_ACTIVE_L1) && s->l1_size) { if (overlaps_with(s->l1_table_offset, s->l1_size * sizeof(uint64_t))) { return QCOW2_OL_ACTIVE_L1; } } if ((chk & QCOW2_OL_REFCOUNT_TABLE) && s->refcount_table_size) { if (overlaps_with(s->refcount_table_offset, s->refcount_table_size * sizeof(uint64_t))) { return QCOW2_OL_REFCOUNT_TABLE; } } if ((chk & QCOW2_OL_SNAPSHOT_TABLE) && s->snapshots_size) { if (overlaps_with(s->snapshots_offset, s->snapshots_size)) { return QCOW2_OL_SNAPSHOT_TABLE; } } if ((chk & QCOW2_OL_INACTIVE_L1) && s->snapshots) { for (i = 0; i < s->nb_snapshots; i++) { if (s->snapshots[i].l1_size && overlaps_with(s->snapshots[i].l1_table_offset, s->snapshots[i].l1_size * sizeof(uint64_t))) { return QCOW2_OL_INACTIVE_L1; } } } if ((chk & QCOW2_OL_ACTIVE_L2) && s->l1_table) { for (i = 0; i < s->l1_size; i++) { if ((s->l1_table[i] & L1E_OFFSET_MASK) && overlaps_with(s->l1_table[i] & L1E_OFFSET_MASK, s->cluster_size)) { return QCOW2_OL_ACTIVE_L2; } } } if ((chk & QCOW2_OL_REFCOUNT_BLOCK) && s->refcount_table) { for (i = 0; i < s->refcount_table_size; i++) { if ((s->refcount_table[i] & REFT_OFFSET_MASK) && overlaps_with(s->refcount_table[i] & REFT_OFFSET_MASK, s->cluster_size)) { return QCOW2_OL_REFCOUNT_BLOCK; } } } if ((chk & QCOW2_OL_INACTIVE_L2) && s->snapshots) { for (i = 0; i < s->nb_snapshots; i++) { uint64_t l1_ofs = s->snapshots[i].l1_table_offset; uint32_t l1_sz = s->snapshots[i].l1_size; uint64_t l1_sz2 = l1_sz * sizeof(uint64_t); uint64_t *l1 = g_malloc(l1_sz2); int ret; ret = bdrv_pread(bs->file, l1_ofs, l1, l1_sz2); if (ret < 0) { g_free(l1); return ret; } for (j = 0; j < l1_sz; j++) { uint64_t l2_ofs = be64_to_cpu(l1[j]) & L1E_OFFSET_MASK; if (l2_ofs && overlaps_with(l2_ofs, s->cluster_size)) { g_free(l1); return QCOW2_OL_INACTIVE_L2; } } g_free(l1); } } return 0; }
1threat
how to get string most appears in text file c : <p>how do I get the string that appears most frequently in a text file in c?</p> <p>I need to create an algorithm that gets a string that has been cited more often in a text file and then writes it, but I have no idea where to start</p>
0debug
static void gen_div(DisasContext *dc, TCGv dest, TCGv srca, TCGv srcb) { TCGv sr_ov = tcg_temp_new(); TCGv t0 = tcg_temp_new(); tcg_gen_setcondi_tl(TCG_COND_EQ, sr_ov, srcb, 0); tcg_gen_or_tl(t0, srcb, sr_ov); tcg_gen_div_tl(dest, srca, t0); tcg_temp_free(t0); tcg_gen_deposit_tl(cpu_sr, cpu_sr, sr_ov, ctz32(SR_OV), 1); gen_ove_ov(dc, sr_ov); tcg_temp_free(sr_ov); }
1threat
Pandas Merge returns NaN : <p>I have issues with the merging of two large Dataframes since the merge returns NaN values though there are fitting values. The two dfs are shaped like:</p> <p><strong>df1</strong></p> <pre><code>Motor 2232 1524 2230 2230 2224 1516 1724 2224 1524 1624 1724 2224 2224 1524 1524 1516 1524 2224 1624 1724 1724 2224 2224 </code></pre> <p><strong>df2</strong> </p> <pre><code>Motor Output Torque (mNm) 0615 0,17 1219 0,72 1516 0,59 1624 2 2230 4,7 2233 5,9 0816 0,7 1016 0,92 1024 1,6 1224 1,7 1319 1,4 1331 3,8 1516 0,97 1524 2,9 1717 2,2 1724 4,5 2224 6,8 2232 10 1336 3,6 1727 4,9 1741 8,8 2237 12 2642 26 </code></pre> <p>I use the code:</p> <pre><code>MergeDat=MergeDat.merge(Motor,how="left") print(MergeDat) </code></pre> <p>where MergeDat= df1 and Motor= df2</p> <p>As <strong>result</strong> it returns:</p> <pre><code> Motor Output Torque (mNm) 0 2232 NaN 1 1524 NaN 2 2230 NaN 3 2230 NaN 4 2224 NaN 5 1516 NaN 6 1724 NaN 7 2224 NaN 8 1524 NaN 9 1624 NaN 10 1724 NaN 11 2224 NaN 12 2224 NaN 13 1524 NaN 14 1524 NaN 15 1516 NaN 16 1524 NaN 17 2224 NaN 18 1624 NaN 19 1724 NaN 20 1724 NaN 21 2224 NaN 22 2224 NaN 23 1524 NaN 24 1724 NaN 25 1841 NaN 26 2224 NaN </code></pre> <p>I have no idea why the Output Torque column is not merged...</p> <p>Appreciate any help!</p>
0debug
Reverse element in array without array reverse method : <p>I am new here and new to programming. I have an assignment which consists of reversing the elements of an array, but the array reverse method cannot be used. I do not know how I can achieve this. I tried using a for loop but it did not work. Thanks in advance.</p> <p>trying to reverse something like this: 1,4,9,16,9,7,4,9,11 into 11,9,4,7,9,16,9,4,1</p>
0debug
static void pflash_cfi02_realize(DeviceState *dev, Error **errp) { pflash_t *pfl = CFI_PFLASH02(dev); uint32_t chip_len; int ret; Error *local_err = NULL; chip_len = pfl->sector_len * pfl->nb_blocs; #if 0 if (total_len != (8 * 1024 * 1024) && total_len != (16 * 1024 * 1024) && total_len != (32 * 1024 * 1024) && total_len != (64 * 1024 * 1024)) return NULL; #endif memory_region_init_rom_device(&pfl->orig_mem, OBJECT(pfl), pfl->be ? &pflash_cfi02_ops_be : &pflash_cfi02_ops_le, pfl, pfl->name, chip_len, &local_err); if (local_err) { error_propagate(errp, local_err); vmstate_register_ram(&pfl->orig_mem, DEVICE(pfl)); pfl->storage = memory_region_get_ram_ptr(&pfl->orig_mem); pfl->chip_len = chip_len; if (pfl->blk) { ret = blk_pread(pfl->blk, 0, pfl->storage, chip_len); if (ret < 0) { vmstate_unregister_ram(&pfl->orig_mem, DEVICE(pfl)); error_setg(errp, "failed to read the initial flash content"); pflash_setup_mappings(pfl); pfl->rom_mode = 1; sysbus_init_mmio(SYS_BUS_DEVICE(dev), &pfl->mem); if (pfl->blk) { pfl->ro = blk_is_read_only(pfl->blk); } else { pfl->ro = 0; pfl->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, pflash_timer, pfl); pfl->wcycle = 0; pfl->cmd = 0; pfl->status = 0; pfl->cfi_len = 0x52; pfl->cfi_table[0x10] = 'Q'; pfl->cfi_table[0x11] = 'R'; pfl->cfi_table[0x12] = 'Y'; pfl->cfi_table[0x13] = 0x02; pfl->cfi_table[0x14] = 0x00; pfl->cfi_table[0x15] = 0x31; pfl->cfi_table[0x16] = 0x00; pfl->cfi_table[0x17] = 0x00; pfl->cfi_table[0x18] = 0x00; pfl->cfi_table[0x19] = 0x00; pfl->cfi_table[0x1A] = 0x00; pfl->cfi_table[0x1B] = 0x27; pfl->cfi_table[0x1C] = 0x36; pfl->cfi_table[0x1D] = 0x00; pfl->cfi_table[0x1E] = 0x00; pfl->cfi_table[0x1F] = 0x07; pfl->cfi_table[0x20] = 0x00; pfl->cfi_table[0x21] = 0x09; pfl->cfi_table[0x22] = 0x0C; pfl->cfi_table[0x23] = 0x01; pfl->cfi_table[0x24] = 0x00; pfl->cfi_table[0x25] = 0x0A; pfl->cfi_table[0x26] = 0x0D; pfl->cfi_table[0x27] = ctz32(chip_len); pfl->cfi_table[0x28] = 0x02; pfl->cfi_table[0x29] = 0x00; pfl->cfi_table[0x2A] = 0x00; pfl->cfi_table[0x2B] = 0x00; pfl->cfi_table[0x2C] = 0x01; pfl->cfi_table[0x2D] = pfl->nb_blocs - 1; pfl->cfi_table[0x2E] = (pfl->nb_blocs - 1) >> 8; pfl->cfi_table[0x2F] = pfl->sector_len >> 8; pfl->cfi_table[0x30] = pfl->sector_len >> 16; pfl->cfi_table[0x31] = 'P'; pfl->cfi_table[0x32] = 'R'; pfl->cfi_table[0x33] = 'I'; pfl->cfi_table[0x34] = '1'; pfl->cfi_table[0x35] = '0'; pfl->cfi_table[0x36] = 0x00; pfl->cfi_table[0x37] = 0x00; pfl->cfi_table[0x38] = 0x00; pfl->cfi_table[0x39] = 0x00; pfl->cfi_table[0x3a] = 0x00; pfl->cfi_table[0x3b] = 0x00; pfl->cfi_table[0x3c] = 0x00;
1threat
How many is too many for create dispatch_queues in GCD (grand central dispatch)? : <p>There is a wonderful article about a lightweight notification system built in Swift, by Mike Ash: (<a href="https://www.mikeash.com/pyblog/friday-qa-2015-01-23-lets-build-swift-notifications.html" rel="noreferrer">https://www.mikeash.com/pyblog/friday-qa-2015-01-23-lets-build-swift-notifications.html</a>).</p> <p>The basic idea is you create objects that you can "listen" to i.e. invoke a callback on when there is some state change. To make it thread-safe, each object created holds its own dispatch_queue. The dispatch_queue is simply used to gate critical sections:</p> <pre><code>dispatch_sync(self.myQueue) { // modify critical state in self } </code></pre> <p>and moreover it likely won't be in high contention. I was kind of struck by the fact that <em>every</em> single object you create that can be listened to makes its own dispatch queue, just for the purposes of locking a few lines of code.</p> <p>One poster suggested an OS_SPINLOCK would be faster and cheaper; maybe, but it would certainly use a lot less space.</p> <p>If my program creates hundreds or thousands (or even tens of thousands of objects) should I worry about creating so many dispatch queues? Probably most won't ever even be listened to, but some might.</p> <p>It certainly makes sense that two objects not block each other, i.e. have separate locks, and normally I wouldn't think twice about embedding, say, a pthread_mutex in each object, but an entire dispatch queue? is that really ok?</p>
0debug
error : php bin/console doctrine:database:create : <p>php bin/console doctrine:database:create</p> <p>In AbstractMySQLDriver.php line 112:</p> <p>An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused</p> <p>In PDOConnection.php line 50:</p> <p>SQLSTATE[HY000] [2002] Connection refused</p> <p>In PDOConnection.php line 46:</p> <p>SQLSTATE[HY000] [2002] Connection refused</p> <p>doctrine:database:create [--shard SHARD] [--connection [CONNECTION]] [--if-not-exists] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] </p> <p>amine@amine:/opt/lampp/htdocs/symphart$ sudo service apache2 restart [sudo] password for amine: amine@amine:/opt/lampp/htdocs/symphart$ php bin/console doctrine:database:create</p> <p>In AbstractMySQLDriver.php line 112:</p> <p>An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused</p> <p>In PDOConnection.php line 50:</p> <p>SQLSTATE[HY000] [2002] Connection refused</p> <p>In PDOConnection.php line 46:</p> <p>SQLSTATE[HY000] [2002] Connection refused</p> <p>doctrine:database:create [--shard SHARD] [--connection [CONNECTION]] [--if-not-exists] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] </p>
0debug
Where condition for joined table in Sequelize ORM : <p>I want to get query like this with sequelize ORM: </p> <pre><code>SELECT "A".*, FROM "A" LEFT OUTER JOIN "B" ON "A"."bId" = "B"."id" LEFT OUTER JOIN "C" ON "A"."cId" = "C"."id" WHERE ("B"."userId" = '100' OR "C"."userId" = '100') </code></pre> <p>The problem is that sequelise not letting me to reference "B" or "C" table in where clause. Following code</p> <pre><code>A.findAll({ include: [{ model: B, where: { userId: 100 }, required: false }, { model: C, where: { userId: 100 }, required: false }] ] </code></pre> <p>gives me</p> <pre><code>SELECT "A".*, FROM "A" LEFT OUTER JOIN "B" ON "A"."bId" = "B"."id" AND "B"."userId" = 100 LEFT OUTER JOIN "C" ON "A"."cId" = "C"."id" AND "C"."userId" = 100 </code></pre> <p>which is completely different query, and result of</p> <pre><code>A.findAll({ where: { $or: [ {'"B"."userId"' : 100}, {'"C"."userId"' : 100} ] }, include: [{ model: B, required: false }, { model: C, required: false }] ] </code></pre> <p>is no even a valid query:</p> <pre><code>SELECT "A".*, FROM "A" LEFT OUTER JOIN "B" ON "A"."bId" = "B"."id" LEFT OUTER JOIN "C" ON "A"."cId" = "C"."id" WHERE ("A"."B.userId" = '100' OR "A"."C.userId" = '100') </code></pre> <p>Is first query even possible with sequelize, or I should just stick to raw queries? </p>
0debug
BlockAIOCB *bdrv_aio_writev(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockCompletionFunc *cb, void *opaque) { trace_bdrv_aio_writev(bs, sector_num, nb_sectors, opaque); return bdrv_co_aio_rw_vector(bs, sector_num, qiov, nb_sectors, 0, cb, opaque, true); }
1threat
How to convert string to objectId in LocalField for $lookup Mongodb : <p>I want to add join collections using <code>$lookup</code> in mongodb. I am trying as below</p> <pre><code>{ $lookup:{ from:"User", localField:"assignedId", foreignField:"_id", as:"dataa"} } </code></pre> <p>Now I have two collections </p> <p><strong>User</strong> contains <code>objectid</code> of users like <code>"_id" : ObjectId("56ab6663d69d2d1100c074db"),</code></p> <p>and <strong>Tasks</strong> where it contains <code>assignedId</code> as a <code>string</code> <code>"assignedId":"56ab6663d69d2d1100c074db"</code></p> <p>Now, when applying $lookup in both collection its not working because Id's are not matching.</p> <p>For that I googled it and found a solution that to include</p> <p><code>{ $project: { assignedId: {$toObjectId: "$assignedId"} }}</code> </p> <p>but this solution is not working for me, Its throwing an error:</p> <pre><code>assert: command failed: { "ok" : 0, "errmsg" : "invalid operator '$toObjectId'", "code" : 15999 } : aggregate failed </code></pre> <p>Please help me how can I resolve this issue.</p> <p>Thanks</p>
0debug
I want to pass ajax request from themes folder/loyalty.tpl to /public_html/test/modules/loyalty/LoyaltyModule.php in prestashop 1.6.1.5 : <input id="Gcash_id" name="Gcash_id" type="text" class="form-control grey" placeholder="Enter your G cash code you will get Gcash amount" /><br> <div id="errorBoxgcash" style="color:#FF0000; font-size:16px;"> </div><br> <button type="submit" name="Submit" value="OK" onclick="return gcashValue();" class="btn btn-default button button-small"><span>{l s='Ok'}</span></button> <script type="text/javascript"> {literal} function gcashValue() { if ($.trim($("#Gcash_id").val()) == ''){ $("#Gcash_id").focus(); $("#errorBoxgcash").removeClass('hide'); $("#errorBoxgcash").html("Please enter GCash ID"); return false; } var gcashidVal=$('#Gcash_id').val(); //alert(gcashidVal); $.ajax({ url:'{$base_dir}modules/loyalty/LoyaltyModule/gcashId', type: 'POST', data: 'ajax=true&gcashidVal='+gcashidVal, success: function(response) { alert(response); console.log('success'); document.getElementById("Gcash_id").innerHTML=response; } }); return false; } {/literal} </script> I am not able to pass the ajax request using the url format of the ajax call of the prestashop loyalty module mentioned above So please give me the correct url format as the concerned to the error mentioned in the screenshot of post request error in the console of firebug I am getting error in the console when making ajax call from /public_html/test/themes/pf_newfashionstore/modules/loyalty/views/templates/front/loyalty.tpl to /public_html/test/modules/loyalty/LoyaltyModule.php http://imgur.com/a/kspSi
0debug
static void assert_codec_experimental(AVCodecContext *c, int encoder) { const char *codec_string = encoder ? "encoder" : "decoder"; AVCodec *codec; if (c->codec->capabilities & CODEC_CAP_EXPERIMENTAL && c->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { av_log(NULL, AV_LOG_FATAL, "%s '%s' is experimental and might produce bad " "results.\nAdd '-strict experimental' if you want to use it.\n", codec_string, c->codec->name); codec = encoder ? avcodec_find_encoder(c->codec->id) : avcodec_find_decoder(c->codec->id); if (!(codec->capabilities & CODEC_CAP_EXPERIMENTAL)) av_log(NULL, AV_LOG_FATAL, "Or use the non experimental %s '%s'.\n", codec_string, codec->name); exit(1); } }
1threat
static void process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eof) { int i; int repeating = 0; AVPacket avpkt; if (ist->next_dts == AV_NOPTS_VALUE) ist->next_dts = ist->last_dts; if (!pkt) { av_init_packet(&avpkt); avpkt.data = NULL; avpkt.size = 0; } else { avpkt = *pkt; } if (pkt && pkt->dts != AV_NOPTS_VALUE) ist->next_dts = ist->last_dts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q); while (ist->decoding_needed && (!pkt || avpkt.size > 0)) { int ret = 0; int got_output = 0; if (!repeating) ist->last_dts = ist->next_dts; switch (ist->dec_ctx->codec_type) { case AVMEDIA_TYPE_AUDIO: ret = decode_audio (ist, repeating ? NULL : &avpkt, &got_output); break; case AVMEDIA_TYPE_VIDEO: ret = decode_video (ist, repeating ? NULL : &avpkt, &got_output); if (repeating && !got_output) ; else if (pkt && pkt->duration) ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q); else if (ist->st->avg_frame_rate.num) ist->next_dts += av_rescale_q(1, av_inv_q(ist->st->avg_frame_rate), AV_TIME_BASE_Q); else if (ist->dec_ctx->framerate.num != 0) { int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 : ist->dec_ctx->ticks_per_frame; ist->next_dts += av_rescale_q(ticks, ist->dec_ctx->framerate, AV_TIME_BASE_Q); } break; case AVMEDIA_TYPE_SUBTITLE: if (repeating) break; ret = transcode_subtitles(ist, &avpkt, &got_output); break; default: return; } if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n", ist->file_index, ist->st->index); if (exit_on_error) exit_program(1); break; } if (!got_output) break; repeating = 1; } if (!pkt && ist->decoding_needed && !no_eof) { int ret = send_filter_eof(ist); if (ret < 0) { av_log(NULL, AV_LOG_FATAL, "Error marking filters as finished\n"); exit_program(1); } } if (!ist->decoding_needed) { ist->last_dts = ist->next_dts; switch (ist->dec_ctx->codec_type) { case AVMEDIA_TYPE_AUDIO: ist->next_dts += ((int64_t)AV_TIME_BASE * ist->dec_ctx->frame_size) / ist->dec_ctx->sample_rate; break; case AVMEDIA_TYPE_VIDEO: if (ist->dec_ctx->framerate.num != 0) { int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 : ist->dec_ctx->ticks_per_frame; ist->next_dts += ((int64_t)AV_TIME_BASE * ist->dec_ctx->framerate.den * ticks) / ist->dec_ctx->framerate.num; } break; } } for (i = 0; pkt && i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; if (!check_output_constraints(ist, ost) || ost->encoding_needed) continue; do_streamcopy(ist, ost, pkt); } return; }
1threat
How get current loaction system in rails website? : My requirement is user when click on 'Punch In' button,automatically get the current location of user where he click on 'Punch In' button.I am using rails : 5.0.1 and ruby 2.4.1 with PostgreSQL database.
0debug
static CharDriverState *qemu_chr_open_pty(QemuOpts *opts) { CharDriverState *chr; PtyCharDriver *s; struct termios tty; const char *label; int master_fd, slave_fd, len; #if defined(__OpenBSD__) || defined(__DragonFly__) char pty_name[PATH_MAX]; #define q_ptsname(x) pty_name #else char *pty_name = NULL; #define q_ptsname(x) ptsname(x) #endif if (openpty(&master_fd, &slave_fd, pty_name, NULL, NULL) < 0) { return NULL; } tcgetattr(slave_fd, &tty); cfmakeraw(&tty); tcsetattr(slave_fd, TCSAFLUSH, &tty); close(slave_fd); chr = g_malloc0(sizeof(CharDriverState)); len = strlen(q_ptsname(master_fd)) + 5; chr->filename = g_malloc(len); snprintf(chr->filename, len, "pty:%s", q_ptsname(master_fd)); qemu_opt_set(opts, "path", q_ptsname(master_fd)); label = qemu_opts_id(opts); fprintf(stderr, "char device redirected to %s%s%s%s\n", q_ptsname(master_fd), label ? " (label " : "", label ? label : "", label ? ")" : ""); s = g_malloc0(sizeof(PtyCharDriver)); chr->opaque = s; chr->chr_write = pty_chr_write; chr->chr_update_read_handler = pty_chr_update_read_handler; chr->chr_close = pty_chr_close; chr->chr_add_watch = pty_chr_add_watch; s->fd = io_channel_from_fd(master_fd); s->timer_tag = 0; return chr; }
1threat
What is the most efficient way to pass a non generic function? : <p>I am learning functional programming in C++. My intention is to pass a non generic function as argument. I know about the template method, however I would like to restrict the function signature as part of the API design. I worked out 4 different methods <a href="http://cpp.sh/2wds" rel="noreferrer">example on cpp.sh</a>:</p> <pre><code>// Example program #include &lt;iostream&gt; #include &lt;string&gt; #include &lt;functional&gt; typedef int(functor_type)(int); int by_forwarding(functor_type &amp;&amp;x) { return x(1); } int functor_by_value(functor_type x) { return x(1); } int std_func_by_value(std::function&lt;functor_type&gt; x) { return x(1); } int std_func_by_forwarding(std::function&lt;functor_type&gt; &amp;&amp;x) { return x(1); } int main() { std::cout &lt;&lt; functor_by_value([](int a){return a;}); // works std::cout &lt;&lt; std_func_by_value([](int a){return a;}); // works std::cout &lt;&lt; std_func_by_forwarding(std::move([](int a){return a;})); // works //std::cout &lt;&lt; by_forwarding([](int a){return a;}); // how to move lambda with forwarding ? } </code></pre> <p>Is any of the above attempts correct? If not, how do i achieve my goal?</p>
0debug
static int rv10_decode_init(AVCodecContext *avctx) { MpegEncContext *s = avctx->priv_data; static int done=0; MPV_decode_defaults(s); s->avctx= avctx; s->out_format = FMT_H263; s->codec_id= avctx->codec_id; s->width = avctx->width; s->height = avctx->height; switch(avctx->sub_id){ case 0x10000000: s->rv10_version= 0; s->h263_long_vectors=0; s->low_delay=1; break; case 0x10002000: s->rv10_version= 3; s->h263_long_vectors=1; s->low_delay=1; s->obmc=1; break; case 0x10003000: s->rv10_version= 3; s->h263_long_vectors=1; s->low_delay=1; break; case 0x10003001: s->rv10_version= 3; s->h263_long_vectors=0; s->low_delay=1; break; case 0x20001000: case 0x20100001: case 0x20101001: case 0x20103001: s->low_delay=1; break; case 0x20200002: case 0x20201002: case 0x30202002: case 0x30203002: s->low_delay=0; s->avctx->has_b_frames=1; break; default: av_log(s->avctx, AV_LOG_ERROR, "unknown header %X\n", avctx->sub_id); } if (MPV_common_init(s) < 0) return -1; h263_decode_init_vlc(s); if (!done) { init_vlc(&rv_dc_lum, DC_VLC_BITS, 256, rv_lum_bits, 1, 1, rv_lum_code, 2, 2); init_vlc(&rv_dc_chrom, DC_VLC_BITS, 256, rv_chrom_bits, 1, 1, rv_chrom_code, 2, 2); done = 1; } avctx->pix_fmt = PIX_FMT_YUV420P; return 0; }
1threat
Just some quick questions on using string input (Eclipse) : We have to make a program on printing initials, which seems pretty easy ik, but I don't know how to cut the string when the input is all on one line using the scanner class in.nextline();. I cant seem to find a way to cut the string using only string methods. Also another problem arose when I have to also be able to adjust if their isn't a middle name either. if anyone can help me or lead me in the right direction that would be nice.
0debug
Firebase Functions: "Failed to get status of functions deployments" : <p>I am getting a very strange error when I attempt to deploy my firebase functions. </p> <p>As a test to rule out my code, I deleted everything except the <code>require(firebase-functions);</code> statement in my <code>index.js</code> file and then tried to deploy, but I again received the same error message: </p> <pre><code>Error: Failed to get status of functions deployments. </code></pre> <p>It also prompts me to see my function log file, but there is nothing new or relevant outputted there. Anyone have any idea how to fix this? </p>
0debug
static void qemu_laio_process_completion(struct qemu_laiocb *laiocb) { int ret; ret = laiocb->ret; if (ret != -ECANCELED) { if (ret == laiocb->nbytes) { ret = 0; } else if (ret >= 0) { if (laiocb->is_read) { qemu_iovec_memset(laiocb->qiov, ret, 0, laiocb->qiov->size - ret); } else { ret = -ENOSPC; } } } laiocb->ret = ret; if (laiocb->co) { qemu_coroutine_enter(laiocb->co); } else { laiocb->common.cb(laiocb->common.opaque, ret); qemu_aio_unref(laiocb); } }
1threat
static int finish_frame(AVCodecContext *avctx, AVFrame *pict) { RV34DecContext *r = avctx->priv_data; MpegEncContext *s = &r->s; int got_picture = 0, ret; ff_er_frame_end(&s->er); ff_mpv_frame_end(s); s->mb_num_left = 0; if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) ff_thread_report_progress(&s->current_picture_ptr->tf, INT_MAX, 0); if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->current_picture_ptr); got_picture = 1; } else if (s->last_picture_ptr != NULL) { if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->last_picture_ptr); got_picture = 1; } return got_picture; }
1threat
What is meant by CLR (Common Language Runtime) in .NET? : <p>I want to know the purpose of CLR with some real examples as I am a non computer science student.</p>
0debug
Random Function Returns The Same Number When Called Inside A Loop! C++ : <p>I wanted to create a separate function inside my <code>ff</code> class to generate a random number and return that number. The function seems to work perfectly when used outside a loop. However, when I put the function inside a loop, it keeps generating the same number even though I am calling the random function each time! What exactly am I doing wrong?!</p> <pre><code> //return a random number int ff::random_number() const { srand((unsigned)time(NULL)); return (rand() % 20 + 1); //in the range of 1 to 20 } //creates an int list of random size and random elements int ff::create_random_list() { list_length = random_number(); //the list size list_of_numbers = new int[list_length]; //initilize the list for (int i = 0; i &lt; list_length; ++i) list_of_numbers[i] = random_number(); //insert a random number return 1; } </code></pre> <ul> <li><strong>Note</strong>: I've checked all similar questions that were posted before this question, but nothing answered my question. Just to be clear.</li> </ul>
0debug
Coming From EF TO EF Core How Do I use using statement correct : I must be doing something wrong in my Context I have my context below which I want to wrap up in my manager class. And I want to be able to use the using statement so that my context is used only once. public class xxxDbContext : DbContext { public xxxDbContext(DbContextOptions<xxxDbContext> options) : base(options) { } public DbSet<JobsList> JobListingss { get; set; } public DbSet<Clients> ClientListings { get; set; } public DbSet<Engineer> EngineerListing { get; set; } public DbSet<Case> CasesListing { get; set; } } But When I want to use my context in my using statement such as public class xxxContext { xxxDbContext _db = new xxxDbContext(); public List<Case> GetAllCases(int databaseId) { List<Case> q = new List<Case>(); using (var myContext = new xxxDbContext(what must I reference here ?))) { q = myContext.Cases.Where(w => w.databaseID == databaseId).OrderBy(o => o.CustomerName).ToList(); } return q; } } Before I was just able to make a parameter less construct can I do same here for core or does that override what is meant to be done. Also what is best practise should I have a separate class for all these functions or should I have a partial class based on my context?.
0debug
Are monitors deadlock free? : <p>If you are using monitors in your concurrent system design, is this sufficient to prevent deadlock? I know that in Java there are many ways to cause deadlock, but few of these examples are actually to do with monitors (most use mutexes).</p>
0debug
difference between s.size() and strlen : i recently did this question **Specification:** > Input Format The first line contains the number of testcases, T. Next, > T lines follow each containing a long string S. > > Output Format For each long string S, display the no. of times SUVO > and SUVOJIT appears in it. I wrote the following code for this : #include <bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--){ int suvo=0; int suvojit=0; string s; cin>>s; for(int i=0;i<=s.size()-7;i++){ if(s.substr(i,7)=="SUVOJIT")suvojit++; } for(int i=0;i<=s.size()-4;i++){ if(s.substr(i,4)=="SUVO")suvo++; } cout<<"SUVO = "<<suvo-suvojit<<", SUVOJIT = "<<suvojit<<"\n"; } return 0; } The code about gave out of bounds exception for substr() function for this test case: > 15 RSUVOYDSUVOJITNSUVOUSUVOJITESUVOSUVOSGSUVOKSUVOJIT > SUVOJITWSUVOSUVOJITTSUVOCKSUVOJITNSUVOSUVOJITSUVOJITSUVOSUVOSUVOJITTSUVOJ > SUVOSUVOSUVOJITASUVOJITGCEBISUVOJITKJSUVORSUVOQCGVHRQLFSUVOOHPFNJTNSUVOJITKSSUVO > SUVOJITSUVOJITJGKSUVOJITISUVOJITKJLUSUVOJITUBSUVOX > MMHBSUVOFSUVOFMSUVOJITUMSUVOJITPSVYBYPMCSUVOJIT > OASUVOSUVOJITSUVOSTDYYJSUVOJITSUVOJITSUVO > RLSUVOCPSUVOJITYSUVOSUVOOGSUVOOESUVOJITMSUVO > WVLFFSUVOJITSUVOVSUVORLESUVOJITPSUVOJITSUVO > RSUVOSUVOJITQWSUVOUMASUVOSUVOJITXNNRRUNUSUVOJIT > HYLSSUVOSUVOSUVOJITPOSUVOJIT DGMUCSSSUVOJITMJSUVOHSUVOCWTGSUVOJIT > OBNSSUVOYSUVOSUVOJITSUVOJITRHFDSUVODSUVOJITEGSUVOSUVOSUVOJITSUVOSUVOJITSSUVOSUVOSUVOSSUVOJIT > AG NSUVOJITSUVOSUVOJIT CGJGDSUVOEASUVOJITSGSUVO However , when instead of using the s.size() function , i converted the string into a char constant and took out the length of it using strlen , then the code caused no error and everything went smoothly .. **So, my question is ...Why did this happen?** This is my working code with the change : #include <bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--){ int suvo=0; int suvojit=0; string s; cin>>s; int le=strlen(&s[0]); for(int i=0;i<=le-7;i++){ if(s.substr(i,7)=="SUVOJIT")suvojit++; } for(int i=0;i<=le-4;i++){ if(s.substr(i,4)=="SUVO")suvo++; } cout<<"SUVO = "<<suvo-suvojit<<", SUVOJIT = "<<suvojit<<"\n"; } return 0; }
0debug
python filling an array with random amount [lb,ub] : I want to fill some array with size N with random variable between LB and UB in python 3.6. Would you please guide me?
0debug
C# class uses in classes wht it dosent work : I have class for connection to Database namespace DamianWprawka { class SQLcon { static SqlConnection konekt = new SqlConnection(); public SQLcon() { konekt.ConnectionString = "Data Source=.\\sqlexpress;" + "Initial Catalog=PRACA;" + "User id=sa;" + "Password=xxXXxx;"; } void open() { konekt.Open(); } void close() { konekt.Close(); } } } And other for query like insert, update, delete, dwonloadData itp: namespace DamianWprawka { class SQLquerry { SQLcon SQLcnn = new SQLcon(); public void PobierzPracownik { SQLcnn.Open(); } } } Why i can't call SQLcnn.Open(); i try with static field/class and i can only use it normaly in Main. I know i can do connection and querry in one class but i want understand this mistery for future.
0debug
PHP looping through MySQL array : <p>I have the following <strong>PHP query code</strong>:</p> <pre><code>$theirTable = $dbcon-&gt;query("SELECT * FROM dogbreed"); $theirRow = $theirTable-&gt;fetch_assoc(); </code></pre> <p>I am trying to understand the correct method for displaying all records in my chosen table in a loop. My request is done like so:</p> <pre><code> &lt;?php while ($fow = $theirRow){ echo $fow['dogtype']; } ?&gt; </code></pre> <p>This code proves problematic, as it repeats the first response endlessly. So I end up getting a result like <code>dobermandobermandobermandobermandoberman</code>continously. Not sure what my problem is from a logic standpoint. </p>
0debug
static int write_header(AVFormatContext *s) { AVCodecContext *codec = s->streams[0]->codec; if (s->nb_streams > 1) { av_log(s, AV_LOG_ERROR, "only one stream is supported\n"); return AVERROR(EINVAL); } if (codec->codec_id != AV_CODEC_ID_WAVPACK) { av_log(s, AV_LOG_ERROR, "unsupported codec\n"); return AVERROR(EINVAL); } if (codec->extradata_size > 0) { avpriv_report_missing_feature(s, "remuxing from matroska container"); return AVERROR_PATCHWELCOME; } avpriv_set_pts_info(s->streams[0], 64, 1, codec->sample_rate); return 0; }
1threat
How do I make the Kotlin compiler treat warnings as errors? : <p>I have a Kotlin project where I'd like to have Kotlin warnings treated as errors. How can I do that?</p>
0debug
Not able to convert date to epoch time : <p>This is my sample code</p> <pre><code> String dt = "Oct 24 2019 12:00:00.000 AM UTC"; String dt1="Oct 24 2019 11:59:59.000 PM UTC"; SimpleDateFormat df = new SimpleDateFormat("MMM dd yyyy HH:mm:ss.SSS aa zzz"); Date date = df.parse(dt); Date date1 = df.parse(dt1); long epoch = date.getTime(); long epoch1 = date1.getTime(); System.out.println(epoch); System.out.println(epoch1); </code></pre> <p>Here specifying the AM and PM but its not taking the value for that and throwing the exception as</p> <pre><code>{"error_code":"INVALID_PARAMETER_VALUE","message":"Time range must have a start time earlier than the end time"} </code></pre> <p>How to specify AM/PM in the java code. How can I take yesterday's date and time for today in java code as an input to convert to epoch.</p>
0debug
int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); AVPicture dummy_pict; int ret; if (!desc) return AVERROR(EINVAL); if ((ret = av_image_check_size(width, height, 0, NULL)) < 0) return ret; if (desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) return width * height; return avpicture_fill(&dummy_pict, NULL, pix_fmt, width, height); }
1threat
C++ switch statement calculator : <p>I need to make a calculator for C++ using switch statement. Exact instructions are: Part #1:</p> <p>Use a switch-case statement to write a basic calculator program which presents the user with the following menu:</p> <pre><code> Menu ============= +) Add -) Subtract *) Multiply /) Divide x) Exit ============== Enter your choice: </code></pre> <p>For a user selection of +, -, *, or /, the program prompts for two operands and then performs the calculation and displays the result If the user selects X or x, the program ends. If the user selects a character other than +, -, *, /, x, or X, the program displays an error message that the selection is invalid. Part #2:</p> <p>Add the following input validation to your solution to Calculator Part #1:</p> <p>If the user selects the divide choice, /, and second operand is zero, the program responds that “Division by zero is not possible.”</p> <p>I would love to go through all of my previous attempts but unfortunately I left my drive at home and now I'm down to the wire. I CAN however tell you I was using this type of format:</p> <pre><code>int main() { char choice; cout &lt;&lt; "Enter A, B, or C: "; cin &gt;&gt; choice; switch (choice) { case 'A': cout &lt;&lt; "You entered A.\n"; break; case 'B': cout &lt;&lt; "You entered B.\n"; break; case 'C': cout &lt;&lt; "You entered C.\n"; break; default: cout &lt;&lt; "You did not enter A, B, or C!\n"; } return 0; } </code></pre> <p>Any help would be greatly appreciated. Have no idea why I am so stumped on this one. </p>
0debug
Is it possible to have a condition on list iterations? : <p>I was playing around with python lists, and how to generate them on the fly with <code>for</code> statements.</p> <p>I came across this:</p> <pre><code>a = [0,1,2,3,4,5] x = 1/sum([1/b for b in a]) </code></pre> <p>This however produces a division by zero.</p> <p>Is it possible to do something like </p> <pre><code>x = 1/sum([1/b for b in a if b != 0]) </code></pre> <p>within the condition nested inside the list declaration?</p>
0debug
finding missing values in R? : I have a couple of questions as I am new to this. 1. How can I read in data using "\-\-" to look for missing values? 2. How can I determine how many values are missing in each variable? I tried using the summary command and is.na but cant's seem to get it right.
0debug
static bool pmsav7_needed(void *opaque) { ARMCPU *cpu = opaque; CPUARMState *env = &cpu->env; return arm_feature(env, ARM_FEATURE_PMSA) && arm_feature(env, ARM_FEATURE_V7); }
1threat
static void intra_predict_vert_16x16_msa(uint8_t *src, uint8_t *dst, int32_t dst_stride) { uint32_t row; v16u8 src0; src0 = LD_UB(src); for (row = 16; row--;) { ST_UB(src0, dst); dst += dst_stride; } }
1threat
How to return int and string attributes in a single java method : I would like to return the values of all the attributes from the Baseballplayer class. The method that needs to do this must be the public string getBaseballPlayer(int i) method (because I need to reference this method inside getBaseballPlayers() to return all the values as an arraylist of strings) I'm having trouble doing this because all the attributes have different datatypes (int, string, Height). Ive tried doing this public String getBaseballPlayer(int i){ ArrayList <String> bArray = new ArrayList <String>(); bArray.add(getHometown()); bArray.add(getState()); bArray.add(getHighSchool()); bArray.add(getPosition()); however it only works for the string methods, and doesn't necessarily return the actual values but rather the get methods for each string attribute. public class BaseballPlayer extends Player implements Table { private int num; private String pos; public BaseballPlayer( int a, String b, String c, int d, String e, String f, String g, Height h){ super(a,ft,in,c,d,e,f,ht); num = a; pos = b; } public BaseballPlayer(){} //Returns the value of a specific attribute. The input parameter start with 0 for the first attribute, then 1 for the second attribute and so on. //you can use getBaseballPlayer(int i) in getBaseballPlayers( ) with a for loop getting each getBaseballPlayer(int i). public String getBaseballPlayer(int i){ ArrayList <String> bArray = new ArrayList <String>(); bArray.add(getHometown()); bArray.add(getState()); bArray.add(getHighSchool()); bArray.add(getPosition()); return (bArray); } //Returns the value of all attributes as an ArrayList of Strings. public ArrayList <String> getBaseballPlayers(){ } I'm just looking for the simplest way to return each attributes value, then using that method return each value as an arraylist of strings in another method.
0debug
build_srat(GArray *table_data, GArray *linker) { AcpiSystemResourceAffinityTable *srat; AcpiSratProcessorAffinity *core; AcpiSratMemoryAffinity *numamem; int i; uint64_t curnode; int srat_start, numa_start, slots; uint64_t mem_len, mem_base, next_base; PCMachineState *pcms = PC_MACHINE(qdev_get_machine()); ram_addr_t hotplugabble_address_space_size = object_property_get_int(OBJECT(pcms), PC_MACHINE_MEMHP_REGION_SIZE, NULL); srat_start = table_data->len; srat = acpi_data_push(table_data, sizeof *srat); srat->reserved1 = cpu_to_le32(1); core = (void *)(srat + 1); for (i = 0; i < pcms->apic_id_limit; ++i) { core = acpi_data_push(table_data, sizeof *core); core->type = ACPI_SRAT_PROCESSOR; core->length = sizeof(*core); core->local_apic_id = i; curnode = pcms->node_cpu[i]; core->proximity_lo = curnode; memset(core->proximity_hi, 0, 3); core->local_sapic_eid = 0; core->flags = cpu_to_le32(1); } next_base = 0; numa_start = table_data->len; numamem = acpi_data_push(table_data, sizeof *numamem); acpi_build_srat_memory(numamem, 0, 640*1024, 0, MEM_AFFINITY_ENABLED); next_base = 1024 * 1024; for (i = 1; i < pcms->numa_nodes + 1; ++i) { mem_base = next_base; mem_len = pcms->node_mem[i - 1]; if (i == 1) { mem_len -= 1024 * 1024; } next_base = mem_base + mem_len; if (mem_base <= pcms->below_4g_mem_size && next_base > pcms->below_4g_mem_size) { mem_len -= next_base - pcms->below_4g_mem_size; if (mem_len > 0) { numamem = acpi_data_push(table_data, sizeof *numamem); acpi_build_srat_memory(numamem, mem_base, mem_len, i - 1, MEM_AFFINITY_ENABLED); } mem_base = 1ULL << 32; mem_len = next_base - pcms->below_4g_mem_size; next_base += (1ULL << 32) - pcms->below_4g_mem_size; } numamem = acpi_data_push(table_data, sizeof *numamem); acpi_build_srat_memory(numamem, mem_base, mem_len, i - 1, MEM_AFFINITY_ENABLED); } slots = (table_data->len - numa_start) / sizeof *numamem; for (; slots < pcms->numa_nodes + 2; slots++) { numamem = acpi_data_push(table_data, sizeof *numamem); acpi_build_srat_memory(numamem, 0, 0, 0, MEM_AFFINITY_NOFLAGS); } if (hotplugabble_address_space_size) { numamem = acpi_data_push(table_data, sizeof *numamem); acpi_build_srat_memory(numamem, pcms->hotplug_memory.base, hotplugabble_address_space_size, 0, MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED); } build_header(linker, table_data, (void *)(table_data->data + srat_start), "SRAT", table_data->len - srat_start, 1, NULL); }
1threat
SocketAddress *socket_local_address(int fd, Error **errp) { struct sockaddr_storage ss; socklen_t sslen = sizeof(ss); if (getsockname(fd, (struct sockaddr *)&ss, &sslen) < 0) { error_setg_errno(errp, errno, "%s", "Unable to query local socket address"); return NULL; } return socket_sockaddr_to_address(&ss, sslen, errp); }
1threat
Cast individual elements of a Tuple C# .Net 4.0 : I have this: Tuple<double?, double?, double?, int, int, int> R1; and need this: Tuple<double, double, double, int, int, int> R1a; How can this be done? I appreciate your help!
0debug
void usb_desc_create_serial(USBDevice *dev) { DeviceState *hcd = dev->qdev.parent_bus->parent; const USBDesc *desc = usb_device_get_usb_desc(dev); int index = desc->id.iSerialNumber; char serial[64]; char *path; int dst; if (dev->serial) { usb_desc_set_string(dev, index, dev->serial); return; } assert(index != 0 && desc->str[index] != NULL); dst = snprintf(serial, sizeof(serial), "%s", desc->str[index]); path = qdev_get_dev_path(hcd); if (path) { dst += snprintf(serial+dst, sizeof(serial)-dst, "-%s", path); } dst += snprintf(serial+dst, sizeof(serial)-dst, "-%s", dev->port->path); usb_desc_set_string(dev, index, serial); g_free(path); }
1threat
Calling another method inside antoher method? digital image processing : I am new into Java and I am trying to understand a piece of code: public class Image { ... public float getPixel(int height, int width) { return data[height][width]; } public void setPixel(float value, int height, int width) { if (value > getMax()) value = getMax(); if (value < 0) value = 0; data[height][width] = value; } private Image(String magicNumber, int height, int width, float max) { this.magicNumber = magicNumber; this.width = width; this.height = height; this.max = max; data = new float[height][width]; } ... public Image clone() { Image clone = new Image(getMagicNumber(), getHeight(), getWidth(), getMax()); for (int i = 0; i < getHeight(); i++) { for (int j = 0; j < getWidth(); j++) { clone.setPixel(getPixel(i, j), i, j); /** trying to understand this line */ } } return clone; } What does `clone.setPixel(getPixel(i, j), i, j);` exactly do? And what I mostly don't understand is what `clone.` which is before `setPixel(getPixel(i, j), i, j);` is doing?
0debug
static void add_to_iovec(QEMUFile *f, const uint8_t *buf, int size) { if (f->iovcnt > 0 && buf == f->iov[f->iovcnt - 1].iov_base + f->iov[f->iovcnt - 1].iov_len) { f->iov[f->iovcnt - 1].iov_len += size; } else { f->iov[f->iovcnt].iov_base = (uint8_t *)buf; f->iov[f->iovcnt++].iov_len = size; } if (f->iovcnt >= MAX_IOV_SIZE) { qemu_fflush(f); } }
1threat
Assingning Refrences in Java : <pre><code>class A{} class B extends A{} class C extends A{} public class Test { public static void main(String [] args){ A a = new A(); A b = new B(); A c = new C(); a = b; b = c; } } </code></pre> <p>Here how can we assign child reference to parent one ? and also b and c are different object types then how we can assign one to another ?</p>
0debug
Default constructor for IntentService (kotlin) : <p>I am new with Kotlin and little bit stack with intentService. Manifest shows me an error that my service doesn't contain default constructor, but inside service it looks ok and there are no errors.</p> <p>Here is my intentService:</p> <pre><code>class MyService : IntentService { constructor(name:String?) : super(name) { } override fun onCreate() { super.onCreate() } override fun onHandleIntent(intent: Intent?) { } } </code></pre> <p>I was also try another variant:</p> <pre><code>class MyService(name: String?) : IntentService(name) { </code></pre> <p>but when I try to run this service I still get an error:</p> <pre><code>java.lang.Class&lt;com.test.test.MyService&gt; has no zero argument constructor </code></pre> <p>Any ideas how to fix default constructor in Kotlin?</p> <p>Thanks!</p>
0debug
Xcode: Cannot parse the debug map for .. is a directory : <p>I'm trying to link my iPhone simulator project and I'm getting the following error at link time:</p> <pre><code>(null): error: cannot parse the debug map for "/Users/admin/Library/Developer/Xcode/DerivedData/TrainTracks-agvvryrtufplkxecblncwedcelck/Build/Products/Debug-iphonesimulator/TrainTracks.app/TrainTracks": Is a directory </code></pre> <p>Here's the linker output:</p> <pre><code>GenerateDSYMFile /Users/admin/Library/Developer/Xcode/DerivedData/TrainTracks-agvvryrtufplkxecblncwedcelck/Build/Products/Debug-iphonesimulator/TrainTracks.app.dSYM /Users/admin/Library/Developer/Xcode/DerivedData/TrainTracks-agvvryrtufplkxecblncwedcelck/Build/Products/Debug-iphonesimulator/TrainTracks.app/TrainTracks cd /Work/TrainTracks/TrainTracks export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil /Users/admin/Library/Developer/Xcode/DerivedData/TrainTracks-agvvryrtufplkxecblncwedcelck/Build/Products/Debug-iphonesimulator/TrainTracks.app/TrainTracks -o /Users/admin/Library/Developer/Xcode/DerivedData/TrainTracks-agvvryrtufplkxecblncwedcelck/Build/Products/Debug-iphonesimulator/TrainTracks.app.dSYM error: cannot parse the debug map for "/Users/admin/Library/Developer/Xcode/DerivedData/TrainTracks-agvvryrtufplkxecblncwedcelck/Build/Products/Debug-iphonesimulator/TrainTracks.app/TrainTracks": Is a directory </code></pre> <p>What would cause this problem?</p> <p>I started off with a Game template (Xcode 7.2.1) and deleted the main story board and AppDelegate.* files since this is an SDL cross-platform project.</p>
0debug
How to fix Worker Pool Deadlock : <p>I wrote a pool of workers, where the job is to receive an integer and return that number converted to string. However I faced a <code>fatal error: all goroutines are asleep - deadlock!</code> error. What am I doing wrong and how can I fix it?</p> <p><a href="https://play.golang.org/p/U814C2rV5na" rel="nofollow noreferrer">https://play.golang.org/p/U814C2rV5na</a></p>
0debug
static void l2cap_frame_in(struct l2cap_instance_s *l2cap, const l2cap_hdr *frame) { uint16_t cid = le16_to_cpu(frame->cid); uint16_t len = le16_to_cpu(frame->len); if (unlikely(cid >= L2CAP_CID_MAX || !l2cap->cid[cid])) { fprintf(stderr, "%s: frame addressed to a non-existent L2CAP " "channel %04x received.\n", __FUNCTION__, cid); return; } l2cap->cid[cid]->frame_in(l2cap->cid[cid], cid, frame, len); }
1threat
Log Non-fatal errors on Crashlytics : <p>On iOS it's possible to use <a href="https://docs.fabric.io/apple/crashlytics/logged-errors.html" rel="noreferrer">recordError(error)</a> to log non-fatal errors on Crashlytics but apparently this feature is not available for Android.</p> <p>The only alternative I found is to use <a href="https://docs.fabric.io/android/crashlytics/caught-exceptions.html" rel="noreferrer">logException(e)</a>. I manage errors on my app and I want to log when specifics errors codes are returned. So, on Crashlytics I'd like the non-fatal errors to be referenced by the errorCode. But using the <em>logException(e)</em> method, errors are referenced by the method where <em>logException(e)</em> has been called.</p> <p>How can I do that?</p>
0debug
void cpu_dump_state (CPUPPCState *env, FILE *f, fprintf_function cpu_fprintf, int flags) { #define RGPL 4 #define RFPL 4 int i; cpu_fprintf(f, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR " TARGET_FMT_lx " XER " TARGET_FMT_lx "\n", env->nip, env->lr, env->ctr, env->xer); cpu_fprintf(f, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " HF " TARGET_FMT_lx " idx %d\n", env->msr, env->spr[SPR_HID0], env->hflags, env->mmu_idx); #if !defined(NO_TIMER_DUMP) cpu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64 #if !defined(CONFIG_USER_ONLY) " DECR %08" PRIu32 #endif "\n", cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env) #if !defined(CONFIG_USER_ONLY) , cpu_ppc_load_decr(env) #endif ); #endif for (i = 0; i < 32; i++) { if ((i & (RGPL - 1)) == 0) cpu_fprintf(f, "GPR%02d", i); cpu_fprintf(f, " %016" PRIx64, ppc_dump_gpr(env, i)); if ((i & (RGPL - 1)) == (RGPL - 1)) cpu_fprintf(f, "\n"); } cpu_fprintf(f, "CR "); for (i = 0; i < 8; i++) cpu_fprintf(f, "%01x", env->crf[i]); cpu_fprintf(f, " ["); for (i = 0; i < 8; i++) { char a = '-'; if (env->crf[i] & 0x08) a = 'L'; else if (env->crf[i] & 0x04) a = 'G'; else if (env->crf[i] & 0x02) a = 'E'; cpu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' '); } cpu_fprintf(f, " ] RES " TARGET_FMT_lx "\n", env->reserve_addr); for (i = 0; i < 32; i++) { if ((i & (RFPL - 1)) == 0) cpu_fprintf(f, "FPR%02d", i); cpu_fprintf(f, " %016" PRIx64, *((uint64_t *)&env->fpr[i])); if ((i & (RFPL - 1)) == (RFPL - 1)) cpu_fprintf(f, "\n"); } cpu_fprintf(f, "FPSCR %08x\n", env->fpscr); #if !defined(CONFIG_USER_ONLY) cpu_fprintf(f, " SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FMT_lx " PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_lx "\n", env->spr[SPR_SRR0], env->spr[SPR_SRR1], env->spr[SPR_PVR], env->spr[SPR_VRSAVE]); cpu_fprintf(f, "SPRG0 " TARGET_FMT_lx " SPRG1 " TARGET_FMT_lx " SPRG2 " TARGET_FMT_lx " SPRG3 " TARGET_FMT_lx "\n", env->spr[SPR_SPRG0], env->spr[SPR_SPRG1], env->spr[SPR_SPRG2], env->spr[SPR_SPRG3]); cpu_fprintf(f, "SPRG4 " TARGET_FMT_lx " SPRG5 " TARGET_FMT_lx " SPRG6 " TARGET_FMT_lx " SPRG7 " TARGET_FMT_lx "\n", env->spr[SPR_SPRG4], env->spr[SPR_SPRG5], env->spr[SPR_SPRG6], env->spr[SPR_SPRG7]); if (env->excp_model == POWERPC_EXCP_BOOKE) { cpu_fprintf(f, "CSRR0 " TARGET_FMT_lx " CSRR1 " TARGET_FMT_lx " MCSRR0 " TARGET_FMT_lx " MCSRR1 " TARGET_FMT_lx "\n", env->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1], env->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1]); cpu_fprintf(f, " TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx " ESR " TARGET_FMT_lx " DEAR " TARGET_FMT_lx "\n", env->spr[SPR_BOOKE_TCR], env->spr[SPR_BOOKE_TSR], env->spr[SPR_BOOKE_ESR], env->spr[SPR_BOOKE_DEAR]); cpu_fprintf(f, " PIR " TARGET_FMT_lx " DECAR " TARGET_FMT_lx " IVPR " TARGET_FMT_lx " EPCR " TARGET_FMT_lx "\n", env->spr[SPR_BOOKE_PIR], env->spr[SPR_BOOKE_DECAR], env->spr[SPR_BOOKE_IVPR], env->spr[SPR_BOOKE_EPCR]); cpu_fprintf(f, " MCSR " TARGET_FMT_lx " SPRG8 " TARGET_FMT_lx " EPR " TARGET_FMT_lx "\n", env->spr[SPR_BOOKE_MCSR], env->spr[SPR_BOOKE_SPRG8], env->spr[SPR_BOOKE_EPR]); cpu_fprintf(f, " MCAR " TARGET_FMT_lx " PID1 " TARGET_FMT_lx " PID2 " TARGET_FMT_lx " SVR " TARGET_FMT_lx "\n", env->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1], env->spr[SPR_BOOKE_PID2], env->spr[SPR_E500_SVR]); } #if defined(TARGET_PPC64) if (env->flags & POWERPC_FLAG_CFAR) { cpu_fprintf(f, " CFAR " TARGET_FMT_lx"\n", env->cfar); } #endif switch (env->mmu_model) { case POWERPC_MMU_32B: case POWERPC_MMU_601: case POWERPC_MMU_SOFT_6xx: case POWERPC_MMU_SOFT_74xx: #if defined(TARGET_PPC64) case POWERPC_MMU_620: case POWERPC_MMU_64B: #endif cpu_fprintf(f, " SDR1 " TARGET_FMT_lx "\n", env->spr[SPR_SDR1]); break; case POWERPC_MMU_BOOKE206: cpu_fprintf(f, " MAS0 " TARGET_FMT_lx " MAS1 " TARGET_FMT_lx " MAS2 " TARGET_FMT_lx " MAS3 " TARGET_FMT_lx "\n", env->spr[SPR_BOOKE_MAS0], env->spr[SPR_BOOKE_MAS1], env->spr[SPR_BOOKE_MAS2], env->spr[SPR_BOOKE_MAS3]); cpu_fprintf(f, " MAS4 " TARGET_FMT_lx " MAS6 " TARGET_FMT_lx " MAS7 " TARGET_FMT_lx " PID " TARGET_FMT_lx "\n", env->spr[SPR_BOOKE_MAS4], env->spr[SPR_BOOKE_MAS6], env->spr[SPR_BOOKE_MAS7], env->spr[SPR_BOOKE_PID]); cpu_fprintf(f, "MMUCFG " TARGET_FMT_lx " TLB0CFG " TARGET_FMT_lx " TLB1CFG " TARGET_FMT_lx "\n", env->spr[SPR_MMUCFG], env->spr[SPR_BOOKE_TLB0CFG], env->spr[SPR_BOOKE_TLB1CFG]); break; default: break; } #endif #undef RGPL #undef RFPL }
1threat
Random picturebox on a pannel : Hi I want to generate a random position form my picturebox when which is in a Panel I load my page on csharp .This is my code for the picturebox.How can i have a random position for it?Thanks private void Form1_Load(object sender, EventArgs e) { PictureBox pictureboxtroll = new PictureBox(); pictureboxtroll.Size = new System.Drawing.Size(70, 70); pictureboxtroll.BackColor = Color.Green; this.Controls.Add(pictureboxtroll); }
0debug
php automatic redirect to a page : I am making a register form and when you succesfully filled in all the fields, it redirects to `thank_you_register.php`. But I want that after a few seconds, the `thank_you_register.php` page automatically redirects to another page. How do is do this? The HTML code is this: <form class="register form" action="../app/controller/authController.php" method="POST"> <div class="form-group"> <select name="region" id=""> <option value="Americas">Americas</option> <option value="Europe">Europe</option> <option value="Asia">Asia</option> </select> </div> <div class="form-group"> <input type="text" name="first_name" id="" placeholder="First Name"> <?php if(isset($_SESSION['first_name_error'] )) : ?> <span class="error"><?php echo $_SESSION['first_name_error']; ?></span> <?php unset($_SESSION['first_name_error']); endif; ?> </div> <div class="form-group"> <input type="text" name="last_name" id="" placeholder="Last Name"> <?php if(isset($_SESSION['last_name_error'] )) : ?> <span class="error"><?php echo $_SESSION['last_name_error']; ?></span> <?php unset($_SESSION['last_name_error']); endif; ?> </div> <div class="form-group"> <input type="email" name="email" id="" placeholder="E-mail Address"> <?php if(isset($_SESSION['email_error'] )) : ?> <span class="error"><?php echo $_SESSION['email_error']; ?></span> <?php unset($_SESSION['email_error']); endif; ?> </div> <div class="form-group"> <input type="email" name="confirm_email" id="" placeholder="Confirm E-mail Address"> <?php if(isset($_SESSION['confirm_email_error'])) : ?> <span class="error"><?php echo $_SESSION['confirm_email_error']; ?></span> <?php unset($_SESSION['confirm_email_error']); endif; ?> </div> <div class="form-group"> <input type="password" name="password" id="" placeholder="Password"> <?php if(isset($_SESSION['password_error'] )) : ?> <span class="error"><?php echo $_SESSION['password_error']; ?></span> <?php unset($_SESSION['password_error']); endif; ?> </div> <div class="form-group"> <input type="password" name="confirm_password" id="" placeholder="Confirm Password"> <?php if(isset($_SESSION['confirm_password_error'] )) : ?> <span class="error"><?php echo $_SESSION['confirm_password_error']; ?></span> <?php unset($_SESSION['confirm_password_error']); endif; ?> </div> <div class="form-group"> <input type="text" name="age" id="" placeholder="Age"> <?php if(isset($_SESSION['age_error'] )) : ?> <span class="error"><?php echo $_SESSION['age_error']; ?></span> <?php unset($_SESSION['age_error']); endif; ?> </div> <div class="form-group"> <input type="submit" name="type" value="Register" class="register button"> </div> </form> And the PHP code of the form is this: if ($_POST['type'] == 'Register') { $i=0; $names = array('first_name', 'last_name', 'email', 'confirm_email', 'password', 'confirm_password', 'age'); foreach($names as $field) { if (empty($_POST[$field])) { $_SESSION[$field.'_error'] = "Field cannot be empty!"; $i++; } else { unset($_SESSION[$field.'_error']); $user->redirect('register.php'); } } if (sizeof($names) == $i) { $user->redirect('register.php'); } if ($_POST['email'] != $_POST['confirm_email']) { $_SESSION['confirm_email_error'] = "E-mail Address does not match!"; exit(); } if ($_POST['password'] != $_POST['confirm_password']) { $_SESSION['confirm_password_error'] = "Password does not match!"; exit(); } function add($region, $first_name, $last_name, $email, $confirm_email, $password, $confirm_password, $age) { var_dump($_POST); $database = Database::getInstance(); $sql = "INSERT INTO `users` (`region`, `first_name`, `last_name`, `email`, `confirm_email`, `password`, `confirm_password`, `age`) VALUES (:region, :first_name, :last_name, :email, :confirm_email, :password, :confirm_password, :age)"; $stmt = $database->pdo->prepare($sql); $stmt->bindParam(':region', $region); $stmt->bindParam(':first_name', $first_name); $stmt->bindParam(':last_name', $last_name); $stmt->bindParam(':email', $email); $stmt->bindParam(':confirm_email', $confirm_email); $stmt->bindParam(':password', $password); $stmt->bindParam(':confirm_password', $confirm_password); $stmt->bindParam(':age', $age); $stmt->execute(); } $user->redirect(''); And the HTML code for the `thank_you_register` page is this: <?php require realpath(__DIR__ . '/header.php'); ?> <div class="main-content"> <div class="messageBox"> <div class="MB_head"> <h2>Thank You!</h2> </div> <div class="MB_content"> <p>You are registered.</p> </div> </div> </div> <?php require realpath(__DIR__ . '/footer.php'); ?>
0debug
When to provision in Packer vs Terraform? : <p>I am sitting with a situation where I need to provision EC2 instances with some packages on startup. There are a couple of (enterprise/corporate) constraints that exist:</p> <ul> <li>I need to provision on top of a specific AMI, which adds enterprisey stuff such as LDAP/AD access and so on</li> <li>These changes are intended to be used for all internal development machines</li> </ul> <p>Because of mainly the second constraint, I was wondering where is the best place to place the provisioning. This is what I've come up with</p> <p><strong>Provision in Terraform</strong></p> <p>As it states, I simply provision in terraform for the necessary instances. If I package these resources into modules, then provisioning won't "leak out". The disadvantages</p> <ul> <li>I won't be able to add a different set of provisioning steps on top of the module? </li> <li>A change in the provisioning will probably result in instances being destroyed on apply?</li> <li>Provisioning takes a long time because of the packages it tries to install</li> </ul> <p><strong>Provisioning in Packer</strong></p> <p>This is based on the <a href="https://www.packer.io/intro/getting-started/build-image.html" rel="noreferrer">assumption</a> that Packer allows you to provision on top of AMIs so that AMIs can be "extended". Also, this will only be used in AWS so it won't use other builders necessarily. Provisioning in Packer makes the Terraform Code much simpler and terraform applies will become faster because it's just an AMI that you fire up.</p> <p><strong>For me both of these methods have their place. But what I really want to know is when do you choose Packer Provisioning over Terraform Provisioning?</strong></p>
0debug
static av_cold int avui_encode_init(AVCodecContext *avctx) { avctx->coded_frame = av_frame_alloc(); if (avctx->width != 720 || avctx->height != 486 && avctx->height != 576) { av_log(avctx, AV_LOG_ERROR, "Only 720x486 and 720x576 are supported.\n"); return AVERROR(EINVAL); } if (!avctx->coded_frame) { av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n"); return AVERROR(ENOMEM); } if (!(avctx->extradata = av_mallocz(24 + FF_INPUT_BUFFER_PADDING_SIZE))) return AVERROR(ENOMEM); avctx->extradata_size = 24; memcpy(avctx->extradata, "\0\0\0\x18""APRGAPRG0001", 16); if (avctx->field_order > AV_FIELD_PROGRESSIVE) { avctx->extradata[19] = 2; } else { avctx->extradata[19] = 1; } return 0; }
1threat
How can I move 'wins', 'losses' and 'neither' to the column next to it, while copying the person's name down to the rows below it? : I need to make the data go from example 1 to example 2. [Example 1][1] [Example 2][2] [1]: https://i.stack.imgur.com/aizG4.png [2]: https://i.stack.imgur.com/iTwu9.png
0debug
Add ssl certificate to selenium-webdriver : <p>I use selenium for end-to-end test with chromeDriver. The websites to test require an ssl certificate. When I manually open the browser, there is a popup that lets me select an installed certificate. Different tests access different URLs and also need different certificates. However, if I run the tests in headless mode, there is no popup. So I need a way to programatically set a certificate (eg. set a <code>.pem</code> file) to be used for the current test.</p> <p>How can I achieve this? I tried setting up a <a href="https://github.com/lightbody/browsermob-proxy" rel="noreferrer">browserMob</a> proxy which I then configured as a proxy in selenium - however, this does not seem to do anything... Are there better approaches? What am I doing wrong? Here's what I tried:</p> <pre class="lang-java prettyprint-override"><code>PemFileCertificateSource pemFileCertificateSource = new PemFileCertificateSource( new File("myCertificate.pem"), new File("myPrivateKey.pem"), "myPrivateKeyPassword"); ImpersonatingMitmManager mitmManager = ImpersonatingMitmManager.builder() .rootCertificateSource(pemFileCertificateSource) .build(); BrowserMobProxy browserMobProxy = new BrowserMobProxyServer(); browserMobProxy.setTrustAllServers(true); browserMobProxy.setMitmManager(mitmManager); browserMobProxy.start(8080); ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setProxy(ClientUtil.createSeleniumProxy(browserMobProxy)); WebDriver webDriver = new ChromeDriver(chromeOptions); // use the webdriver for tests, e.g. assertEquals("foo", webDriver.findElement(...)) </code></pre>
0debug
connection.query('SELECT * FROM users WHERE username = ' + input_string)
1threat
Split With negative numbers as delimiter : <p>How to split with -ve numbers as delimiter in RUBY for example if x = 989-7516-354 if we use split now then it should print 9,8,9,5,1,6,5,4</p>
0debug
static int all_vcpus_paused(void) { CPUState *penv = first_cpu; while (penv) { if (!penv->stopped) return 0; penv = (CPUState *)penv->next_cpu; } return 1; }
1threat
how to return a string from a method in java : i wrote a few lines of code to find the multiples of a number in java using two classes.how to return a string from a method. `class Multiples{ String printMult(int x){ int i,j; for(i = 0;i <= x;i++){ for(j = 0;j <= x;j++){ return i + "*" + j; } } } } public class Chkmult{ public static void main(String[] args){ Multiples num = new Multiples(); System.out.println(num.printMult(8)) } } `
0debug
check logic 0 in reverse number program in java : <p>This is the logic to reverse a number. But this logic doesn't reverse the number having 0. for example i want to reverse 70 means it will give output as 7. so kindly give logic to reverse number having 0. Thanks.</p> <pre><code>while(num&gt;0) { rem=num%10; sum=(sum*10)+rem; num=num/10; } System.out.println("Output is:"+sum ); </code></pre>
0debug
How can i make <a href='$game_link' target='_blank'>$game_link</a> a button : <p>Hello I'm to trying to make this variable $game_link which is the url from the database a button, but seem not to get it right? I need help on it please. This is the code $game_link.</p>
0debug
how to "italic or bold" description tag in html : I am trying to bold keywords or text in meta description <meta name="description" content="> but I don't know how to do how to bold or italic text (keyword) in meta-description tag. and is it use-full trick for SEO or not
0debug
java arithmetic calculation : how this code evaluates. class Test{ public static void main(String[] args) { int i = 10 + + 11 - - 12 + + 13 - - 14 + + 15; System.out.println(i); } } Please, Explain this code .
0debug
int ff_query_formats_all(AVFilterContext *ctx) { return default_query_formats_common(ctx, ff_all_channel_counts); }
1threat
static void adb_keyboard_event(DeviceState *dev, QemuConsole *src, InputEvent *evt) { KBDState *s = (KBDState *)dev; int qcode, keycode; qcode = qemu_input_key_value_to_qcode(evt->u.key.data->key); if (qcode >= ARRAY_SIZE(qcode_to_adb_keycode)) { return; } keycode = qcode_to_adb_keycode[qcode]; if (keycode == NO_KEY) { ADB_DPRINTF("Ignoring NO_KEY\n"); return; } if (evt->u.key.data->down == false) { keycode = keycode | 0x80; } adb_kbd_put_keycode(s, keycode); }
1threat
store names values in array without duplicacy(first check whether it has same value if same then not add in array if not then added.) : [Hi guys please help me, i want to add names in array but without duplicacy at specific loaction. if the array has same value then it is not added into the array or vice versa Any kind of help is Appreciated.][1] [1]: https://i.stack.imgur.com/OPMK5.png
0debug
Type 'Element[]' is missing the following properties from type 'Element': type, props, key : <p>I have the standard arrow map ES7 function with Typescript and React environment:</p> <pre><code> const getItemList: Function = (groups: any[]): JSX.Element =&gt; group.map((item: any, i: number) =&gt; { const itemCardElemProps = { handleEvents: () =&gt; {}, ...item} return &lt;Item key={`${item.id}_${i}`} {...itemCardElemProps} /&gt; }) </code></pre> <p>and get the error:</p> <pre><code>TS2739: Type 'Element[]' is missing the following properties from type 'Element': type, props, key </code></pre> <p>Version: typescript 3.5.3</p>
0debug
Can we use the ES6 class syntax in AWS Lambda? : <p>I would like to use the ES6 class syntax in AWS Lambda using Node 6.10, but I cannot get it to work:</p> <pre><code>class widget { constructor(event, context, callback) { callback(null, `all seems well!`); } } // module.exports.handler = widget; // "Process exited before completing request" module.exports.handler = new widget(); // "callback is not a function" </code></pre> <p>Has anyone had success with using the class syntax? The class constructor does not get seen as a handler function apparently.</p>
0debug
Kubernetes: How to get disk / cpu metrics of a node : <p>Without using Heapster is there any way to collect like CPU or Disk metrics about a node within a Kubernetes cluster?</p> <p>How does Heapster even collect those metrics in the first place?</p>
0debug
Multiple WordPress sites with one shared DB using Docker : <p>I want to run multiple WordPress websites with one shared database using docker.</p> <p>Is it possible to specify a database and set an appropriate volume to a certain sql file to initialize WordPress for each container in its <code>docker-compose.yml</code> file?</p> <hr> <p>For example, I have three <code>docker-compose.yml</code> files for a shared container, siteA and siteB.</p> <p>When I run <code>docker-compose up</code> in <code>./shared</code>, two DBs will be created for the two sites (example_a and example_b).</p> <p>And when I run <code>docker-compose up</code> in <code>./siteA</code>, I want to change current DB to <code>example_a</code>, and initialize the site with a certain amount of data by sql volumed from <code>./siteA/mysql/setup.sql</code>.</p> <p>Same thing goes with siteB.</p> <p>I know I can specify a database and volume like <code>- WORDPRESS_DB_NAME: example_a</code> and <code>- ./db-data/mysql.dump.sql:/docker-entrypoint-initdb.d/install_wordpress.sql</code> in mysql section in <code>docker-compose.yml</code> but I only have one shared mysql and cannot specify DB and volume for each site.</p> <hr> <p>I have multiple <code>docker-compose.yml</code> files look something like below.</p> <p><strong>./shared/docker-compose.yml</strong></p> <pre><code>version: "2" services: proxy: image: jwilder/nginx-proxy privileged: true container_name: proxy ports: - 80:80 - 443:443 volumes: - /var/run/docker.sock:/tmp/docker.sock:ro - ./certs:/etc/nginx/certs:ro restart: always logging: options: max-size: 5m max-file: "10" mysql: image: mysql:5.7 container_name: mysql command: &gt; --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci --max-allowed-packet=128M ports: - "3306:3306" environment: - MYSQL_ROOT_PASSWORD=foobar restart: always volumes: - db-data:/var/lib/mysql - ./mysql/sql-setup.sql:/docker-entrypoint-initdb.d/sql-setup.sql # to create multiple databases (e.g. example_a, example_b) logging: options: max-size: 5m max-file: "10" volumes: db-data: driver: local networks: default: external: name: shared </code></pre> <p><strong>./siteA/docker-compose.yml</strong></p> <pre><code>version: "2" services: example_a_wordpress: image: wordpress container_name: a.example environment: WORDPRESS_DB_NAME=example_a WORDPRESS_DB_PASSWORD=foobar VIRTUAL_HOST: a.example.dev external_links: - mysql restart: always volumes: - ./dist/theme:/var/www/html/wp-content/themes/main - ./dist/assets:/var/www/html/assets logging: options: max-size: 5m max-file: "10" networks: default: external: name: shared </code></pre> <p><strong>./siteB/docker-compose.yml</strong></p> <pre><code>version: "2" services: example_b_wordpress: image: wordpress container_name: b.example environment: WORDPRESS_DB_NAME=example_b WORDPRESS_DB_PASSWORD=foobar VIRTUAL_HOST: b.example.dev external_links: - mysql restart: always volumes: - ./dist/theme:/var/www/html/wp-content/themes/main - ./dist/assets:/var/www/html/assets logging: options: max-size: 5m max-file: "10" networks: default: external: name: shared </code></pre>
0debug
static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix) { BDRVQcowState *s = bs->opaque; uint64_t *l2_table = qemu_blockalign(bs, s->cluster_size); int ret; int refcount; int i, j; for (i = 0; i < s->l1_size; i++) { uint64_t l1_entry = s->l1_table[i]; uint64_t l2_offset = l1_entry & L1E_OFFSET_MASK; bool l2_dirty = false; if (!l2_offset) { continue; } refcount = get_refcount(bs, l2_offset >> s->cluster_bits); if (refcount < 0) { continue; } if ((refcount == 1) != ((l1_entry & QCOW_OFLAG_COPIED) != 0)) { fprintf(stderr, "%s OFLAG_COPIED L2 cluster: l1_index=%d " "l1_entry=%" PRIx64 " refcount=%d\n", fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i, l1_entry, refcount); if (fix & BDRV_FIX_ERRORS) { s->l1_table[i] = refcount == 1 ? l1_entry | QCOW_OFLAG_COPIED : l1_entry & ~QCOW_OFLAG_COPIED; ret = qcow2_write_l1_entry(bs, i); if (ret < 0) { res->check_errors++; goto fail; } res->corruptions_fixed++; } else { res->corruptions++; } } ret = bdrv_pread(bs->file, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)); if (ret < 0) { fprintf(stderr, "ERROR: Could not read L2 table: %s\n", strerror(-ret)); res->check_errors++; goto fail; } for (j = 0; j < s->l2_size; j++) { uint64_t l2_entry = be64_to_cpu(l2_table[j]); uint64_t data_offset = l2_entry & L2E_OFFSET_MASK; int cluster_type = qcow2_get_cluster_type(l2_entry); if ((cluster_type == QCOW2_CLUSTER_NORMAL) || ((cluster_type == QCOW2_CLUSTER_ZERO) && (data_offset != 0))) { refcount = get_refcount(bs, data_offset >> s->cluster_bits); if (refcount < 0) { continue; } if ((refcount == 1) != ((l2_entry & QCOW_OFLAG_COPIED) != 0)) { fprintf(stderr, "%s OFLAG_COPIED data cluster: " "l2_entry=%" PRIx64 " refcount=%d\n", fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", l2_entry, refcount); if (fix & BDRV_FIX_ERRORS) { l2_table[j] = cpu_to_be64(refcount == 1 ? l2_entry | QCOW_OFLAG_COPIED : l2_entry & ~QCOW_OFLAG_COPIED); l2_dirty = true; res->corruptions_fixed++; } else { res->corruptions++; } } } } if (l2_dirty) { ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT & ~QCOW2_OL_ACTIVE_L2, l2_offset, s->cluster_size); if (ret < 0) { fprintf(stderr, "ERROR: Could not write L2 table; metadata " "overlap check failed: %s\n", strerror(-ret)); res->check_errors++; goto fail; } ret = bdrv_pwrite(bs->file, l2_offset, l2_table, s->cluster_size); if (ret < 0) { fprintf(stderr, "ERROR: Could not write L2 table: %s\n", strerror(-ret)); res->check_errors++; goto fail; } } } ret = 0; fail: qemu_vfree(l2_table); return ret; }
1threat
Different routes for different subdomains in Nuxt.js : <p>Suppose there're two subdomains working for one nuxt instance. They should have different pages structure. For example it can be:</p> <pre><code>pages/ index.vue // technical entry point that has some logic for determining what routes subtree should be used subdomain1/ index.vue // entry point for subdomain1.mysite.com/ page1.vue // entry point for subdomain1.mysite.com/page1 subdomain2/ index.vue // entry point for subdomain2.mysite.com/ page1.vue // entry point for subdomain2.mysite.com/page1 page2.vue // entry point for subdomain2.mysite.com/page2 </code></pre> <p>The folder structure can be different. The goal is to be able to load different pages for different subdomains. <code>subdomain1.mysite.com/page1</code> has to load one file (e.g. <code>pages/subdomain1/page1.vue</code>) while <code>subdomain2.mysite.com/page1</code> has to load the other file (e.g. <code>pages/subdomain2/page2.vue</code>).</p> <p>We can use <code>nuxtServerInit</code> action for determining the subdomain, so there's some <code>this.$store.state.ux.subdomain</code> variable that is eiter subdomain1 or subdomain2. But the rest is not clear for me. </p> <p>Is it possible to achieve in nuxt.js? If it is, I suppose we should use named views <code>&lt;nuxt-child :name="subdomain"/&gt;</code> and <code>extendRoutes</code> in nuxt.config.js somehow, but I was not able to achieve it so far. Any help would be appreciated.</p>
0debug