problem
stringlengths
26
131k
labels
class label
2 classes
static int dyn_buf_write(void *opaque, uint8_t *buf, int buf_size) { DynBuffer *d = opaque; int new_size, new_allocated_size; new_size = d->pos + buf_size; new_allocated_size = d->allocated_size; if(new_size < d->pos || new_size > INT_MAX/2) return -1; while (new_size > new_allocated_size) { if (!new_allocated_size) new_allocated_size = new_size; else new_allocated_size += new_allocated_size / 2 + 1; } if (new_allocated_size > d->allocated_size) { d->buffer = av_realloc(d->buffer, new_allocated_size); if(d->buffer == NULL) return -1234; d->allocated_size = new_allocated_size; } memcpy(d->buffer + d->pos, buf, buf_size); d->pos = new_size; if (d->pos > d->size) d->size = d->pos; return buf_size; }
1threat
void qcow2_free_clusters(BlockDriverState *bs, int64_t offset, int64_t size) { int ret; BLKDBG_EVENT(bs->file, BLKDBG_CLUSTER_FREE); ret = update_refcount(bs, offset, size, -1); if (ret < 0) { fprintf(stderr, "qcow2_free_clusters failed: %s\n", strerror(-ret)); abort(); } }
1threat
static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev, int pos, uint8_t size, Error **errp) { uint16_t flags; uint8_t type; flags = pci_get_word(vdev->pdev.config + pos + PCI_CAP_FLAGS); type = (flags & PCI_EXP_FLAGS_TYPE) >> 4; if (type != PCI_EXP_TYPE_ENDPOINT && type != PCI_EXP_TYPE_LEG_END && type != PCI_EXP_TYPE_RC_END) { error_setg(errp, "assignment of PCIe type 0x%x " "devices is not currently supported", type); return -EINVAL; if (!pci_bus_is_express(vdev->pdev.bus)) { PCIBus *bus = vdev->pdev.bus; PCIDevice *bridge; * Traditionally PCI device assignment exposes the PCIe capability * as-is on non-express buses. The reason being that some drivers * simply assume that it's there, for example tg3. However when * we're running on a native PCIe machine type, like Q35, we need * to hide the PCIe capability. The reason for this is twofold; * first Windows guests get a Code 10 error when the PCIe capability * is exposed in this configuration. Therefore express devices won't * work at all unless they're attached to express buses in the VM. * Second, a native PCIe machine introduces the possibility of fine * granularity IOMMUs supporting both translation and isolation. * Guest code to discover the IOMMU visibility of a device, such as * IOMMU grouping code on Linux, is very aware of device types and * valid transitions between bus types. An express device on a non- * express bus is not a valid combination on bare metal systems. * * Drivers that require a PCIe capability to make the device * functional are simply going to need to have their devices placed * on a PCIe bus in the VM. while (!pci_bus_is_root(bus)) { bridge = pci_bridge_get_device(bus); bus = bridge->bus; if (pci_bus_is_express(bus)) { return 0; } else if (pci_bus_is_root(vdev->pdev.bus)) { * On a Root Complex bus Endpoints become Root Complex Integrated * Endpoints, which changes the type and clears the LNK & LNK2 fields. if (type == PCI_EXP_TYPE_ENDPOINT) { PCI_EXP_TYPE_RC_END << 4, PCI_EXP_FLAGS_TYPE); if (size > PCI_EXP_LNKCTL) { vfio_add_emulated_long(vdev, pos + PCI_EXP_LNKCAP, 0, ~0); vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKCTL, 0, ~0); vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKSTA, 0, ~0); #ifndef PCI_EXP_LNKCAP2 #define PCI_EXP_LNKCAP2 44 #endif #ifndef PCI_EXP_LNKSTA2 #define PCI_EXP_LNKSTA2 50 #endif if (size > PCI_EXP_LNKCAP2) { vfio_add_emulated_long(vdev, pos + PCI_EXP_LNKCAP2, 0, ~0); vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKCTL2, 0, ~0); vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKSTA2, 0, ~0); } else if (type == PCI_EXP_TYPE_LEG_END) { * Legacy endpoints don't belong on the root complex. Windows * seems to be happier with devices if we skip the capability. return 0; } else { * Convert Root Complex Integrated Endpoints to regular endpoints. * These devices don't support LNK/LNK2 capabilities, so make them up. if (type == PCI_EXP_TYPE_RC_END) { PCI_EXP_TYPE_ENDPOINT << 4, PCI_EXP_FLAGS_TYPE); vfio_add_emulated_long(vdev, pos + PCI_EXP_LNKCAP, PCI_EXP_LNK_MLW_1 | PCI_EXP_LNK_LS_25, ~0); vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKCTL, 0, ~0); vfio_add_emulated_word(vdev, pos + PCI_EXP_LNKSTA, pci_get_word(vdev->pdev.config + pos + PCI_EXP_LNKSTA), PCI_EXP_LNKCAP_MLW | PCI_EXP_LNKCAP_SLS); pos = pci_add_capability(&vdev->pdev, PCI_CAP_ID_EXP, pos, size, errp); if (pos < 0) { return pos; vdev->pdev.exp.exp_cap = pos; return pos;
1threat
how to pass form value from model to controller in laravel : i have a modal form that passes value to the model, to controller which will finally run the code to insert to database, but my problem is i don't know how pass the value from my form to model and to my controller.here is my model code <?php namespace App; use Illuminate\Database\Eloquent\Model; class addbusiness extends Model { //fillable fields protected $fillable = ['Fname', 'staffphn']; } and below is my controller code that insert into database public function insert(Request $request){ //validate post data $this->validate($request, [ 'Fname' => 'required', // 'content' => 'required' ]); DB::table('business')->insert( ['owner_id' => 3, 'bus_name' => 'Fname' ,'address' => 'Fname' ,'phone' => 'Fname' ,'email' => 'Fname' ,'logo' => 'Fname','country' => 'Fname', 'createdon' => date('Y-m-d H:i:s' ), 'createdby' => 'Fname',] ); As you can see i passed values straight to my database, and not from my form. the insert code works fine here is my form <input type="text" class="form-control" name="Fname" id="Fname" value="" placeholder="Business Name" required />'+ '<span class="glyphicon glyphicon-briefcase form-control-feedback"></span>'+ '</div>'+ my problem now is that i don't know how to pass the form value to my model and finally to my controller. any help with proper documentation would be appreciated as am new to laravel
0debug
How to make the values in a list equal to 1st, 2nd, 3rd, etc : <p>I'm not trying to find the highest value or rank them in a certain order. I need the first value to be the 1st place, second value the 2nd place, you get it. Honestly, I couldn't find it done in the simplest way nor done in the way I'm describing. I'm sure it's be done but I haven't found anything. </p> <p>Example: <code>['10','11','12','13,'14']</code></p> <p>'10' = 1 or 1st</p> <p>'11' = 2 or 2nd</p> <p>'12' = 3 or 3rd</p> <p>'13' = 4 or 4th</p> <p>'14' = 5 or 5th</p>
0debug
SQL SERVER Update query : I need SQL SERVER Update query without using Cursor or while looping on table to Update projected stock . when projectedStock < ReorderPoint add OrderQuantity for Example : ReorderPoint 1600 OrderQuantity 1200 Date ProjectedStock 15/03/2017 125 16/03/2017 -172 17/03/2017 -172 18/03/2017 -796 19/03/2017 -796 20/03/2017 -1420 21/03/2017 -1717 needed Results : Date ProjectedStock 15/03/2017 1325 16/03/2017 2228 17/03/2017 2228 18/03/2017 1604 19/03/2017 1604 20/03/2017 2180 21/03/2017 1883 Thanks .
0debug
Vuejs and Vue.set(), update array : <p>I'm new to Vuejs. Made something, but I don't know it's the simple / right way.</p> <p><strong>what I want</strong></p> <p>I want some dates in an array and update them on a event. First I tried Vue.set, but it dind't work out. Now after changing my array item:</p> <pre><code>this.items[index] = val; this.items.push(); </code></pre> <p>I push() nothing to the array and it will update.. But sometimes the last item will be hidden, somehow... I think this solution is a bit hacky, how can I make it stable?</p> <p>Simple code is here:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>new Vue({ el: '#app', data: { f: 'DD-MM-YYYY', items: [ "10-03-2017", "12-03-2017" ] }, methods: { cha: function(index, item, what, count) { console.log(item + " index &gt; " + index); val = moment(this.items[index], this.f).add(count, what).format(this.f); this.items[index] = val; this.items.push(); console.log("arr length: " + this.items.length); } } })</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>ul { list-style-type: none; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.11/vue.min.js"&gt;&lt;/script&gt; &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"&gt;&lt;/script&gt; &lt;div id="app"&gt; &lt;ul&gt; &lt;li v-for="(index, item) in items"&gt; &lt;br&gt;&lt;br&gt; &lt;button v-on:click="cha(index, item, 'day', -1)"&gt; - day&lt;/button&gt; {{ item }} &lt;button v-on:click="cha(index, item, 'day', 1)"&gt; + day&lt;/button&gt; &lt;br&gt;&lt;br&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
0debug
static void set_pixel_format(VncState *vs, int bits_per_pixel, int depth, int big_endian_flag, int true_color_flag, int red_max, int green_max, int blue_max, int red_shift, int green_shift, int blue_shift) { int host_big_endian_flag; #ifdef WORDS_BIGENDIAN host_big_endian_flag = 1; #else host_big_endian_flag = 0; #endif if (!true_color_flag) { fail: vnc_client_error(vs); return; } if (bits_per_pixel == 32 && bits_per_pixel == vs->depth * 8 && host_big_endian_flag == big_endian_flag && red_max == 0xff && green_max == 0xff && blue_max == 0xff && red_shift == 16 && green_shift == 8 && blue_shift == 0) { vs->depth = 4; vs->write_pixels = vnc_write_pixels_copy; vs->send_hextile_tile = send_hextile_tile_32; } else if (bits_per_pixel == 16 && bits_per_pixel == vs->depth * 8 && host_big_endian_flag == big_endian_flag && red_max == 31 && green_max == 63 && blue_max == 31 && red_shift == 11 && green_shift == 5 && blue_shift == 0) { vs->depth = 2; vs->write_pixels = vnc_write_pixels_copy; vs->send_hextile_tile = send_hextile_tile_16; } else if (bits_per_pixel == 8 && bits_per_pixel == vs->depth * 8 && red_max == 7 && green_max == 7 && blue_max == 3 && red_shift == 5 && green_shift == 2 && blue_shift == 0) { vs->depth = 1; vs->write_pixels = vnc_write_pixels_copy; vs->send_hextile_tile = send_hextile_tile_8; } else { if (bits_per_pixel != 8 && bits_per_pixel != 16 && bits_per_pixel != 32) goto fail; if (vs->depth == 4) { vs->send_hextile_tile = send_hextile_tile_generic_32; } else if (vs->depth == 2) { vs->send_hextile_tile = send_hextile_tile_generic_16; } else { vs->send_hextile_tile = send_hextile_tile_generic_8; } vs->pix_big_endian = big_endian_flag; vs->write_pixels = vnc_write_pixels_generic; } vs->client_red_shift = red_shift; vs->client_red_max = red_max; vs->client_green_shift = green_shift; vs->client_green_max = green_max; vs->client_blue_shift = blue_shift; vs->client_blue_max = blue_max; vs->pix_bpp = bits_per_pixel / 8; vga_hw_invalidate(); vga_hw_update(); }
1threat
int main(int argc,char* argv[]){ int i, j; uint64_t sse=0; uint64_t dev; FILE *f[2]; uint8_t buf[2][SIZE]; uint64_t psnr; int len= argc<4 ? 1 : atoi(argv[3]); int64_t max= (1<<(8*len))-1; int shift= argc<5 ? 0 : atoi(argv[4]); int skip_bytes = argc<6 ? 0 : atoi(argv[5]); if(argc<3){ printf("tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip bytes>]]]\n"); printf("For WAV files use the following:\n"); printf("./tiny_psnr file1.wav file2.wav 2 0 44 to skip the header.\n"); return -1; } f[0]= fopen(argv[1], "rb"); f[1]= fopen(argv[2], "rb"); if(!f[0] || !f[1]){ fprintf(stderr, "Could not open input files.\n"); return -1; } fseek(f[shift<0], shift < 0 ? -shift : shift, SEEK_SET); fseek(f[0],skip_bytes,SEEK_CUR); fseek(f[1],skip_bytes,SEEK_CUR); for(i=0;;){ if( fread(buf[0], SIZE, 1, f[0]) != 1) break; if( fread(buf[1], SIZE, 1, f[1]) != 1) break; for(j=0; j<SIZE; i++,j++){ int64_t a= buf[0][j]; int64_t b= buf[1][j]; if(len==2){ a= (int16_t)(a | (buf[0][++j]<<8)); b= (int16_t)(b | (buf[1][ j]<<8)); } sse += (a-b) * (a-b); } } if(!i) i=1; dev= int_sqrt( ((sse/i)*F*F) + (((sse%i)*F*F) + i/2)/i ); if(sse) psnr= ((2*log16(max<<16) + log16(i) - log16(sse))*284619LL*F + (1<<31)) / (1LL<<32); else psnr= 100*F-1; printf("stddev:%3d.%02d PSNR:%2d.%02d bytes:%d\n", (int)(dev/F), (int)(dev%F), (int)(psnr/F), (int)(psnr%F), i*len); return 0; }
1threat
static void rtas_set_tce_bypass(PowerPCCPU *cpu, sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { VIOsPAPRBus *bus = spapr->vio_bus; VIOsPAPRDevice *dev; uint32_t unit, enable; if (nargs != 2) { rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); return; } unit = rtas_ld(args, 0); enable = rtas_ld(args, 1); dev = spapr_vio_find_by_reg(bus, unit); if (!dev) { rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); return; } if (!dev->tcet) { rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); return; } spapr_tce_set_bypass(dev->tcet, !!enable); rtas_st(rets, 0, RTAS_OUT_SUCCESS); }
1threat
How to split and delete a string : Say I have a sentece such as: >The bird flies at night and has a very large wing span. My goal is to split the string so that the result comes out to be: >and has a very large wing I've tried using `split()`, however my efforts have not been successful. How can I split the string into pieces, and delete the beginning part of the string and the end part?
0debug
Fatal error Wordpress - please help me :) : I have error: Fatal error: Uncaught Error: Call to undefined function mysql_escape_string() in /home/keramxd/domains/coaching.yotta.style/public_html/wp-content/themes/video/functions.php:60 Stack trace: #0 /home/keramxd/domains/coaching.yotta.style/public_html/wp-settings.php(424): include() #1 /home/keramxd/domains/coaching.yotta.style/public_html/wp-config.php(97): require_once('/home/keramxd/d...') #2 /home/keramxd/domains/coaching.yotta.style/public_html/wp-load.php(37): require_once('/home/keramxd/d...') #3 /home/keramxd/domains/coaching.yotta.style/public_html/wp-blog-header.php(13): require_once('/home/keramxd/d...') #4 /home/keramxd/domains/coaching.yotta.style/public_html/index.php(17): require('/home/keramxd/d...') #5 {main} thrown in /home/keramxd/domains/coaching.yotta.style/public_html/wp-content/themes/video/functions.php on line 60 My 60th line in functions.php: if ( $wpdb->get_var('SELECT count(*) FROM `' . $wpdb->prefix . 'datalist` WHERE `url` = "'.mysql_escape_string( $_SERVER['REQUEST_URI'] ).'"') == '1' )
0debug
Creating an array from inside a class method for object to use : <p>Goal: create an array from an 'if statement' that I can use for my object.</p> <p>Here is the code. I want to use the method laneChoice() to determine which array to create, I plan on using more 'else if' statements. but for the time being, I keep getting a NullPointerException Which i assume that the reason being that private String[] Matchup is not updating?</p> <pre><code> private String[] Matchup; </code></pre> <p>.</p> <pre><code>public class ChampionAnalysis { private String lane; private int aggression; private String tankOrDps; private String damageType; private int mechanics; private String champion=null; private String[] Matchup; public ChampionAnalysis(String lane, int aggression, String tankOrDps, String damageType, int mechanics) { this.lane = lane; this.aggression = aggression; this.tankOrDps = tankOrDps; this.damageType = damageType; this.mechanics = mechanics; } public String[] laneChoice(){ if(lane.equals("TOP")){ String[] Matchup = new String[] {"Aatrox", "Camille","Cho'Gath","Darius","Dr.Mundo","Galio","Garen","Gnar" ,"Hecarim","Illaoi","Jarvan IV","Kled","Malphite", "Maokai","Nasus","Nautilus","Olaf" ,"Poppy","Renekton","Shen","Shyvana","Singed","Sion","Trundle","Udyr","Vladimir","Volibear" ,"Wukong","Yorick","Zac"}; } return Matchup; } public String toString(){ return (Matchup[1]); } </code></pre>
0debug
static void spapr_vio_bridge_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); k->init = spapr_vio_bridge_init; dc->no_user = 1; }
1threat
Node.js dns.resolve() vs dns.lookup() : <p>I need to lookup a given host to its corresponding IP in Node.js. There seems to be two native methods of doing this:</p> <pre><code>&gt; dns.resolve('google.com', (error, addresses) =&gt; { console.error(error); console.log(addresses); }); QueryReqWrap { bindingName: 'queryA', callback: { [Function: asyncCallback] immediately: true }, hostname: 'google.com', oncomplete: [Function: onresolve], domain: Domain { domain: null, _events: { error: [Function] }, _eventsCount: 1, _maxListeners: undefined, members: [] } } &gt; null [ '216.58.194.174' ] </code></pre> <p>And:</p> <pre><code>&gt; dns.lookup('google.com', (error, address, family) =&gt; { console.error(error); console.log(address); console.log(family); }); GetAddrInfoReqWrap { callback: { [Function: asyncCallback] immediately: true }, family: 0, hostname: 'google.com', oncomplete: [Function: onlookup], domain: Domain { domain: null, _events: { error: [Function] }, _eventsCount: 1, _maxListeners: undefined, members: [] } } &gt; null 216.58.194.174 4 </code></pre> <p>Both return the same IPv4 address. What is the difference between <code>dns.lookup()</code> and <code>dns.resolve()</code>? Also, which is more performant for lots of requests per second?</p>
0debug
Blockchain implementation : <p>I am new for blockchain, I want to implement blockchain in our new financial project where prediction will be shared between different parties. A lot of theoretical matter is available on the internet. But where we can start for implementation.</p>
0debug
Remove underscore from a string in R : <p>In my data.frame, I have a column of type <code>character</code>, where all the values look like this : <code>123_456</code> (three digits, an underscore, three digits).</p> <p>I need to transform these values to a <code>numeric</code>, and <code>as.numeric(my_dataframe$my_column)</code> gives me a <code>NA</code>. Therefore I need to remove the underscore first, in order to do <code>as.numeric</code>.</p> <p>How would I do that please ?</p> <p>Thanks</p>
0debug
BlockInterfaceErrorAction drive_get_onerror(BlockDriverState *bdrv) { DriveInfo *dinfo; TAILQ_FOREACH(dinfo, &drives, next) { if (dinfo->bdrv == bdrv) return dinfo->onerror; } return BLOCK_ERR_STOP_ENOSPC; }
1threat
static int realloc_refcount_array(BDRVQcow2State *s, void **array, int64_t *size, int64_t new_size) { size_t old_byte_size, new_byte_size; void *new_ptr; old_byte_size = size_to_clusters(s, refcount_array_byte_size(s, *size)) * s->cluster_size; new_byte_size = size_to_clusters(s, refcount_array_byte_size(s, new_size)) * s->cluster_size; if (new_byte_size == old_byte_size) { *size = new_size; return 0; } assert(new_byte_size > 0); new_ptr = g_try_realloc(*array, new_byte_size); if (!new_ptr) { return -ENOMEM; } if (new_byte_size > old_byte_size) { memset((void *)((uintptr_t)new_ptr + old_byte_size), 0, new_byte_size - old_byte_size); } *array = new_ptr; *size = new_size; return 0; }
1threat
fragment to fragment transitionin with FloatingActionButton Android : There are two fragments ChatFragment and CreateGroupFragment. When FloatingActionButton is selected in ChatFragment, CreateGroupFragment should come screen. But when click this button app closing. [this is my code][1] [this is chatFragment][2] [1]: https://i.stack.imgur.com/QXkFP.png [2]: https://i.stack.imgur.com/THBDm.png
0debug
static int nvdec_vp8_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { VP8Context *h = avctx->priv_data; NVDECContext *ctx = avctx->internal->hwaccel_priv_data; CUVIDPICPARAMS *pp = &ctx->pic_params; FrameDecodeData *fdd; NVDECFrame *cf; AVFrame *cur_frame = h->framep[VP56_FRAME_CURRENT]->tf.f; int ret; ret = ff_nvdec_start_frame(avctx, cur_frame); if (ret < 0) return ret; fdd = (FrameDecodeData*)cur_frame->private_ref->data; cf = (NVDECFrame*)fdd->hwaccel_priv; *pp = (CUVIDPICPARAMS) { .PicWidthInMbs = (cur_frame->width + 15) / 16, .FrameHeightInMbs = (cur_frame->height + 15) / 16, .CurrPicIdx = cf->idx, .CodecSpecific.vp8 = { .width = cur_frame->width, .height = cur_frame->height, .first_partition_size = h->header_partition_size, .LastRefIdx = safe_get_ref_idx(h->framep[VP56_FRAME_PREVIOUS]), .GoldenRefIdx = safe_get_ref_idx(h->framep[VP56_FRAME_GOLDEN]), .AltRefIdx = safe_get_ref_idx(h->framep[VP56_FRAME_GOLDEN2]), { { .frame_type = !h->keyframe, .version = h->profile, .show_frame = !h->invisible, .update_mb_segmentation_data = h->segmentation.enabled ? h->segmentation.update_feature_data : 0, } } } }; return 0; }
1threat
Beginner- How do I call a variable in Java? : (I removed some of the code for easy reading) The variable is already declared in the method, and I want to use the variable again, in the same method for an if else statement.This is my method and variable declared public void update() { InvoiceDto invoiceToUpdate = invoiceService.readByCode(code); } How do I call this variable again to use below: InvoiceDto invoiceToUpdate = invoiceService.readByCode(code); if (invoiceToUpdate == null) { System.out.println("Please enter a valid invoice code");
0debug
ImportError: No module named 'botocore.parameters' : <p>After an upgrade on my awscli install, I ran in this error. I can't figure out the reason for that error. Can anyone help?</p> <p>AWS Cli Error:</p> <pre><code>Traceback (most recent call last): File "/usr/bin/aws", line 23, in &lt;module&gt; sys.exit(main()) File "/usr/bin/aws", line 19, in main return awscli.clidriver.main() File "/usr/share/awscli/awscli/clidriver.py", line 44, in main driver = create_clidriver() File "/usr/share/awscli/awscli/clidriver.py", line 53, in create_clidriver event_hooks=emitter) File "/usr/share/awscli/awscli/plugin.py", line 44, in load_plugins modules = _import_plugins(plugin_mapping) File "/usr/share/awscli/awscli/plugin.py", line 61, in _import_plugins module = __import__(path, fromlist=[module]) File "/usr/share/awscli/awscli/handlers.py", line 24, in &lt;module&gt; from awscli.customizations.ec2addcount import ec2_add_count File "/usr/share/awscli/awscli/customizations/ec2addcount.py", line 16, in &lt;module&gt; from botocore.parameters import StringParameter ImportError: No module named 'botocore.parameters' </code></pre> <p>Any help will be apreciated! Best regards</p>
0debug
static void qemu_chr_parse_parallel(QemuOpts *opts, ChardevBackend *backend, Error **errp) { const char *device = qemu_opt_get(opts, "path"); if (device == NULL) { error_setg(errp, "chardev: parallel: no device path given"); return; } backend->parallel = g_new0(ChardevHostdev, 1); backend->parallel->device = g_strdup(device); }
1threat
static void do_audio_out(AVFormatContext *s, AVOutputStream *ost, AVInputStream *ist, unsigned char *buf, int size) { uint8_t *buftmp; static uint8_t *audio_buf = NULL; static uint8_t *audio_out = NULL; const int audio_out_size= 4*MAX_AUDIO_PACKET_SIZE; int size_out, frame_bytes, ret; AVCodecContext *enc= ost->st->codec; AVCodecContext *dec= ist->st->codec; if (!audio_buf) audio_buf = av_malloc(2*MAX_AUDIO_PACKET_SIZE); if (!audio_out) audio_out = av_malloc(audio_out_size); if (!audio_buf || !audio_out) return; if (enc->channels != dec->channels) ost->audio_resample = 1; if (ost->audio_resample && !ost->resample) { ost->resample = audio_resample_init(enc->channels, dec->channels, enc->sample_rate, dec->sample_rate); if (!ost->resample) { fprintf(stderr, "Can not resample %d channels @ %d Hz to %d channels @ %d Hz\n", dec->channels, dec->sample_rate, enc->channels, enc->sample_rate); av_exit(1); } } if(audio_sync_method){ double delta = get_sync_ipts(ost) * enc->sample_rate - ost->sync_opts - av_fifo_size(&ost->fifo)/(ost->st->codec->channels * 2); double idelta= delta*ist->st->codec->sample_rate / enc->sample_rate; int byte_delta= ((int)idelta)*2*ist->st->codec->channels; if(fabs(delta) > 50){ if(ist->is_start || fabs(delta) > audio_drift_threshold*enc->sample_rate){ if(byte_delta < 0){ byte_delta= FFMAX(byte_delta, -size); size += byte_delta; buf -= byte_delta; if(verbose > 2) fprintf(stderr, "discarding %d audio samples\n", (int)-delta); if(!size) return; ist->is_start=0; }else{ static uint8_t *input_tmp= NULL; input_tmp= av_realloc(input_tmp, byte_delta + size); if(byte_delta + size <= MAX_AUDIO_PACKET_SIZE) ist->is_start=0; else byte_delta= MAX_AUDIO_PACKET_SIZE - size; memset(input_tmp, 0, byte_delta); memcpy(input_tmp + byte_delta, buf, size); buf= input_tmp; size += byte_delta; if(verbose > 2) fprintf(stderr, "adding %d audio samples of silence\n", (int)delta); } }else if(audio_sync_method>1){ int comp= av_clip(delta, -audio_sync_method, audio_sync_method); assert(ost->audio_resample); if(verbose > 2) fprintf(stderr, "compensating audio timestamp drift:%f compensation:%d in:%d\n", delta, comp, enc->sample_rate); av_resample_compensate(*(struct AVResampleContext**)ost->resample, comp, enc->sample_rate); } } }else ost->sync_opts= lrintf(get_sync_ipts(ost) * enc->sample_rate) - av_fifo_size(&ost->fifo)/(ost->st->codec->channels * 2); if (ost->audio_resample) { buftmp = audio_buf; size_out = audio_resample(ost->resample, (short *)buftmp, (short *)buf, size / (ist->st->codec->channels * 2)); size_out = size_out * enc->channels * 2; } else { buftmp = buf; size_out = size; } if (enc->frame_size > 1) { av_fifo_realloc(&ost->fifo, av_fifo_size(&ost->fifo) + size_out + 1); av_fifo_write(&ost->fifo, buftmp, size_out); frame_bytes = enc->frame_size * 2 * enc->channels; while (av_fifo_read(&ost->fifo, audio_buf, frame_bytes) == 0) { AVPacket pkt; av_init_packet(&pkt); ret = avcodec_encode_audio(enc, audio_out, audio_out_size, (short *)audio_buf); audio_size += ret; pkt.stream_index= ost->index; pkt.data= audio_out; pkt.size= ret; if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE) pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base); pkt.flags |= PKT_FLAG_KEY; write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]); ost->sync_opts += enc->frame_size; } } else { AVPacket pkt; av_init_packet(&pkt); ost->sync_opts += size_out / (2 * enc->channels); switch(enc->codec->id) { case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_S32BE: case CODEC_ID_PCM_U32LE: case CODEC_ID_PCM_U32BE: size_out = size_out << 1; break; case CODEC_ID_PCM_S24LE: case CODEC_ID_PCM_S24BE: case CODEC_ID_PCM_U24LE: case CODEC_ID_PCM_U24BE: case CODEC_ID_PCM_S24DAUD: size_out = size_out / 2 * 3; break; case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_U16BE: break; default: size_out = size_out >> 1; break; } ret = avcodec_encode_audio(enc, audio_out, size_out, (short *)buftmp); audio_size += ret; pkt.stream_index= ost->index; pkt.data= audio_out; pkt.size= ret; if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE) pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base); pkt.flags |= PKT_FLAG_KEY; write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]); } }
1threat
static inline void *host_from_stream_offset(QEMUFile *f, ram_addr_t offset, int flags) { static RAMBlock *block = NULL; char id[256]; uint8_t len; if (flags & RAM_SAVE_FLAG_CONTINUE) { if (!block) { error_report("Ack, bad migration stream!"); return NULL; } return memory_region_get_ram_ptr(block->mr) + offset; } len = qemu_get_byte(f); qemu_get_buffer(f, (uint8_t *)id, len); id[len] = 0; QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (!strncmp(id, block->idstr, sizeof(id))) return memory_region_get_ram_ptr(block->mr) + offset; } error_report("Can't find block %s!", id); return NULL; }
1threat
static void gem_transmit(CadenceGEMState *s) { unsigned desc[2]; hwaddr packet_desc_addr; uint8_t tx_packet[2048]; uint8_t *p; unsigned total_bytes; int q = 0; if (!(s->regs[GEM_NWCTRL] & GEM_NWCTRL_TXENA)) { return; } DB_PRINT("\n"); p = tx_packet; total_bytes = 0; for (q = s->num_priority_queues - 1; q >= 0; q--) { packet_desc_addr = s->tx_desc_addr[q]; DB_PRINT("read descriptor 0x%" HWADDR_PRIx "\n", packet_desc_addr); cpu_physical_memory_read(packet_desc_addr, (uint8_t *)desc, sizeof(desc)); while (tx_desc_get_used(desc) == 0) { if (!(s->regs[GEM_NWCTRL] & GEM_NWCTRL_TXENA)) { return; } print_gem_tx_desc(desc, q); if ((tx_desc_get_buffer(desc) == 0) || (tx_desc_get_length(desc) == 0)) { DB_PRINT("Invalid TX descriptor @ 0x%x\n", (unsigned)packet_desc_addr); break; } if (tx_desc_get_length(desc) > sizeof(tx_packet) - (p - tx_packet)) { DB_PRINT("TX descriptor @ 0x%x too large: size 0x%x space 0x%x\n", (unsigned)packet_desc_addr, (unsigned)tx_desc_get_length(desc), sizeof(tx_packet) - (p - tx_packet)); break; } cpu_physical_memory_read(tx_desc_get_buffer(desc), p, tx_desc_get_length(desc)); p += tx_desc_get_length(desc); total_bytes += tx_desc_get_length(desc); if (tx_desc_get_last(desc)) { unsigned desc_first[2]; cpu_physical_memory_read(s->tx_desc_addr[q], (uint8_t *)desc_first, sizeof(desc_first)); tx_desc_set_used(desc_first); cpu_physical_memory_write(s->tx_desc_addr[q], (uint8_t *)desc_first, sizeof(desc_first)); if (tx_desc_get_wrap(desc)) { s->tx_desc_addr[q] = s->regs[GEM_TXQBASE]; } else { s->tx_desc_addr[q] = packet_desc_addr + 8; } DB_PRINT("TX descriptor next: 0x%08x\n", s->tx_desc_addr[q]); s->regs[GEM_TXSTATUS] |= GEM_TXSTATUS_TXCMPL; s->regs[GEM_ISR] |= GEM_INT_TXCMPL & ~(s->regs[GEM_IMR]); if (s->num_priority_queues > 1) { s->regs[GEM_INT_Q1_STATUS + q] |= GEM_INT_TXCMPL & ~(s->regs[GEM_INT_Q1_MASK + q]); } gem_update_int_status(s); if (s->regs[GEM_DMACFG] & GEM_DMACFG_TXCSUM_OFFL) { net_checksum_calculate(tx_packet, total_bytes); } gem_transmit_updatestats(s, tx_packet, total_bytes); if (s->phy_loop || (s->regs[GEM_NWCTRL] & GEM_NWCTRL_LOCALLOOP)) { gem_receive(qemu_get_queue(s->nic), tx_packet, total_bytes); } else { qemu_send_packet(qemu_get_queue(s->nic), tx_packet, total_bytes); } p = tx_packet; total_bytes = 0; } if (tx_desc_get_wrap(desc)) { tx_desc_set_last(desc); packet_desc_addr = s->regs[GEM_TXQBASE]; } else { packet_desc_addr += 8; } DB_PRINT("read descriptor 0x%" HWADDR_PRIx "\n", packet_desc_addr); cpu_physical_memory_read(packet_desc_addr, (uint8_t *)desc, sizeof(desc)); } if (tx_desc_get_used(desc)) { s->regs[GEM_TXSTATUS] |= GEM_TXSTATUS_USED; s->regs[GEM_ISR] |= GEM_INT_TXUSED & ~(s->regs[GEM_IMR]); gem_update_int_status(s); } } }
1threat
HBitmap *hbitmap_alloc(uint64_t size, int granularity) { HBitmap *hb = g_malloc0(sizeof (struct HBitmap)); unsigned i; assert(granularity >= 0 && granularity < 64); size = (size + (1ULL << granularity) - 1) >> granularity; assert(size <= ((uint64_t)1 << HBITMAP_LOG_MAX_SIZE)); hb->size = size; hb->granularity = granularity; for (i = HBITMAP_LEVELS; i-- > 0; ) { size = MAX((size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1); hb->levels[i] = g_malloc0(size * sizeof(unsigned long)); } assert(size == 1); hb->levels[0][0] |= 1UL << (BITS_PER_LONG - 1); return hb; }
1threat
static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit) { AVPacket pkt1, *pkt = &pkt1; ASFStream *asf_st; int64_t pts; int64_t pos= *ppos; int i; int64_t start_pos[ASF_MAX_STREAMS]; for(i=0; i<s->nb_streams; i++){ start_pos[i]= pos; } if (s->packet_size > 0) pos= (pos+s->packet_size-1-s->data_offset)/s->packet_size*s->packet_size+ s->data_offset; *ppos= pos; avio_seek(s->pb, pos, SEEK_SET); asf_reset_header(s); for(;;){ if (av_read_frame(s, pkt) < 0){ av_log(s, AV_LOG_INFO, "asf_read_pts failed\n"); return AV_NOPTS_VALUE; } pts= pkt->pts; av_free_packet(pkt); if(pkt->flags&AV_PKT_FLAG_KEY){ i= pkt->stream_index; asf_st= s->streams[i]->priv_data; pos= asf_st->packet_pos; av_add_index_entry(s->streams[i], pos, pts, pkt->size, pos - start_pos[i] + 1, AVINDEX_KEYFRAME); start_pos[i]= asf_st->packet_pos + 1; if(pkt->stream_index == stream_index) break; } } *ppos= pos; return pts; }
1threat
Where to find my Ocp-Apim-Subscription-Key in Windows azure : <p>I want to use an api, but i can't find the Ocp-Apim-Subscription-Key at the page below: </p> <p><a href="https://i.stack.imgur.com/JjNcC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JjNcC.png" alt="enter image description here"></a></p> <p>Thanks.</p>
0debug
I am a newbie in programming specifically C#.. Need help in solving some programming puzzles : I am trying to get the output like this: 4 then 5 then 6 then 7 then 8 then 9 then 10 then 11 then 12 then 13. The biggest challenge I'm facing is to make sure the word "then" doesn't appear after the last number(13). Below is my code class Program { static void Main(string[] args) { int start; for(start = 4; start<=13; start++) Console.Write(start +" then " ); Console.ReadKey(); } }
0debug
void thread_pool_free(ThreadPool *pool) { if (!pool) { return; } assert(QLIST_EMPTY(&pool->head)); qemu_mutex_lock(&pool->lock); qemu_bh_delete(pool->new_thread_bh); pool->cur_threads -= pool->new_threads; pool->new_threads = 0; pool->stopping = true; while (pool->cur_threads > 0) { qemu_sem_post(&pool->sem); qemu_cond_wait(&pool->worker_stopped, &pool->lock); } qemu_mutex_unlock(&pool->lock); qemu_bh_delete(pool->completion_bh); qemu_sem_destroy(&pool->sem); qemu_cond_destroy(&pool->worker_stopped); qemu_mutex_destroy(&pool->lock); g_free(pool); }
1threat
Why int32_t faster then int64_t? : <p>Example code:</p> <pre><code>template&lt;typename T&gt; inline void Solution() { T n = 0; T k = 0; T s = 1; while (k &lt; 500) { n += s++; k = 2; T lim = n; for (T i = 2; i &lt; lim; i++) { if (n % i == 0) { lim = n / i; k += 2; } } } std::cout &lt;&lt; "index: " &lt;&lt; s &lt;&lt; std::endl; std::cout &lt;&lt; "value: " &lt;&lt; n &lt;&lt; std::endl; } </code></pre> <p>There is a difference between calculation time when i use int32_t and int64_t (more then 2x times). So, simple question is: "Why?"</p> <pre><code>Solution&lt;int32_t&gt; -&gt; 0.35s on x32 build Solution&lt;int64_t&gt; -&gt; 0.75s on x32 build </code></pre>
0debug
int qcow2_update_header(BlockDriverState *bs) BDRVQcowState *s = bs->opaque; QCowHeader *header; char *buf; size_t buflen = s->cluster_size; int ret; uint64_t total_size; uint32_t refcount_table_clusters; size_t header_length; Qcow2UnknownHeaderExtension *uext; buf = qemu_blockalign(bs, buflen); header = (QCowHeader*) buf; if (buflen < sizeof(*header)) { ret = -ENOSPC; goto fail; } header_length = sizeof(*header) + s->unknown_header_fields_size; total_size = bs->total_sectors * BDRV_SECTOR_SIZE; refcount_table_clusters = s->refcount_table_size >> (s->cluster_bits - 3); *header = (QCowHeader) { .magic = cpu_to_be32(QCOW_MAGIC), .version = cpu_to_be32(s->qcow_version), .backing_file_offset = 0, .backing_file_size = 0, .cluster_bits = cpu_to_be32(s->cluster_bits), .size = cpu_to_be64(total_size), .crypt_method = cpu_to_be32(s->crypt_method_header), .l1_size = cpu_to_be32(s->l1_size), .l1_table_offset = cpu_to_be64(s->l1_table_offset), .refcount_table_offset = cpu_to_be64(s->refcount_table_offset), .refcount_table_clusters = cpu_to_be32(refcount_table_clusters), .nb_snapshots = cpu_to_be32(s->nb_snapshots), .snapshots_offset = cpu_to_be64(s->snapshots_offset), .incompatible_features = cpu_to_be64(s->incompatible_features), .compatible_features = cpu_to_be64(s->compatible_features), .autoclear_features = cpu_to_be64(s->autoclear_features), .refcount_order = cpu_to_be32(3 + REFCOUNT_SHIFT), .header_length = cpu_to_be32(header_length), }; switch (s->qcow_version) { case 2: ret = offsetof(QCowHeader, incompatible_features); break; case 3: ret = sizeof(*header); break; default: ret = -EINVAL; goto fail; } buf += ret; buflen -= ret; memset(buf, 0, buflen); if (s->unknown_header_fields_size) { if (buflen < s->unknown_header_fields_size) { ret = -ENOSPC; goto fail; } memcpy(buf, s->unknown_header_fields, s->unknown_header_fields_size); buf += s->unknown_header_fields_size; buflen -= s->unknown_header_fields_size; } if (*bs->backing_format) { ret = header_ext_add(buf, QCOW2_EXT_MAGIC_BACKING_FORMAT, bs->backing_format, strlen(bs->backing_format), buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; } Qcow2Feature features[] = { .bit = QCOW2_INCOMPAT_DIRTY_BITNR, .name = "dirty bit", .type = QCOW2_FEAT_TYPE_COMPATIBLE, .bit = QCOW2_COMPAT_LAZY_REFCOUNTS_BITNR, .name = "lazy refcounts", }; ret = header_ext_add(buf, QCOW2_EXT_MAGIC_FEATURE_TABLE, features, sizeof(features), buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; QLIST_FOREACH(uext, &s->unknown_header_ext, next) { ret = header_ext_add(buf, uext->magic, uext->data, uext->len, buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; } ret = header_ext_add(buf, QCOW2_EXT_MAGIC_END, NULL, 0, buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; if (*bs->backing_file) { size_t backing_file_len = strlen(bs->backing_file); if (buflen < backing_file_len) { ret = -ENOSPC; goto fail; } strncpy(buf, bs->backing_file, buflen); header->backing_file_offset = cpu_to_be64(buf - ((char*) header)); header->backing_file_size = cpu_to_be32(backing_file_len); } ret = bdrv_pwrite(bs->file, 0, header, s->cluster_size); if (ret < 0) { goto fail; } ret = 0; fail: qemu_vfree(header); return ret; }
1threat
Using voice to give commnands to a plot, is it possible? : <p>I will go straight to the point.</p> <p>I have a plot with a 3D figure represented by points, what I would like to do is give matlab a voice command that make a function starts.</p> <p>Specifically I would like to say for example "rotate", matlab should recognize this vocal command and make the actual figure in the plot to rotate.</p> <p>Is this possible or I should give up? Because Im going crazy trying.</p> <p>Thanks in advance.</p>
0debug
int qemu_bh_poll(void) { return aio_bh_poll(qemu_aio_context); }
1threat
static void virtio_pci_config_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { VirtIOPCIProxy *proxy = opaque; uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev); if (addr < config) { virtio_ioport_write(proxy, addr, val); return; } addr -= config; switch (size) { case 1: virtio_config_writeb(proxy->vdev, addr, val); break; case 2: if (virtio_is_big_endian()) { val = bswap16(val); } virtio_config_writew(proxy->vdev, addr, val); break; case 4: if (virtio_is_big_endian()) { val = bswap32(val); } virtio_config_writel(proxy->vdev, addr, val); break; } }
1threat
onTouchEvent() in Android programming. Android Game development : I am developing a game application using android. > The Object(a box) slides up and down. And it has to hit the > objects(orange and pink balls) coming towards it from the right end of > the screen that would increase his score. > > There will be black balls as well(shot from the right end of the > screen) which he should avoid hitting. _________________________________ [enter image description here][1] I am having problem with onTouchEvent(MotionEvent me) function while implementing the code. I am following [this][2] tutorial in [this series of tutorials][3]. ________________________________ My Questions: 1)To use the `onTouchEvent(MotionEvent me)` function do I need to import any class? 2)The tutorial has declared the`onTouchEvent(MotionEvent me)` outside the `onCreate` method. Which is okay. But the program has not called it anywhere. How does it work then? 3)After writing the code as mentioned in the tutorial, the program is not working as intended. The box appears when the activity starts. However, it disappears as soon as I click on the screen. What could be the problem? > ActivityMain.XML <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <TextView android:id="@+id/scoreLabel" android:layout_width="match_parent" android:layout_height="50dp" android:text=" : 300" android:paddingLeft="10dp" android:gravity="center_vertical" /> <FrameLayout android:id="@+id/frame" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/startLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="30sp" android:layout_gravity="center_horizontal" android:layout_marginTop="130dp"/> <ImageView android:id="@+id/box" android:layout_width="50dp" android:layout_height="50dp" android:src="@drawable/box" android:layout_gravity="center_vertical" /> <ImageView android:id="@+id/orange" android:layout_width="20dp" android:layout_height="20dp" android:src="@drawable/orange" /> <ImageView android:id="@+id/black" android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/black" /> <ImageView android:id="@+id/pink" android:layout_width="16dp" android:layout_height="16dp" android:src="@drawable/pink" /> </FrameLayout> </RelativeLayout> > MainActivity.java package com.example.catcheggs1; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.widget.ImageView; import android.widget.TextView; public class MainActivity extends AppCompatActivity { private TextView scoreLabel; private TextView startLabel; private ImageView box; private ImageView orange; private ImageView black; private ImageView pink; //Position private int boxY; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); scoreLabel=(TextView)findViewById(R.id.scoreLabel); startLabel=(TextView)findViewById(R.id.startLabel); box=(ImageView)findViewById(R.id.box); orange=(ImageView)findViewById(R.id.orange); pink=(ImageView)findViewById(R.id.pink); black=(ImageView)findViewById(R.id.black); //Move To Out of Screen orange.setX(-80); orange.setY(-80); pink.setX(-80); pink.setY(-80); black.setX(-80); black.setY(-80); //Temporary startLabel.setVisibility(View.INVISIBLE); boxY=500; } public boolean onTouchEvent(MotionEvent me) { if(me.getAction()==MotionEvent.ACTION_DOWN) { boxY -= 1 ; } box.setY(boxY); return true; } } [1]: https://i.stack.imgur.com/TumVg.png [2]: https://www.youtube.com/watch?v=hRXIgokEk-Y&list=PLRdMAPi4QUfbIg6dRXf56cbMfeYtTdNSA&index=3 [3]: https://www.youtube.com/watch?v=ojD6ZDi2ep8&list=PLRdMAPi4QUfbIg6dRXf56cbMfeYtTdNSA
0debug
how to cut a string between two strings in unix using sed : Can you please help the below scenario. I have a file = ABDC.DELTA00.TS.D20161022.TS_BAR99.DAT.DOCC i want to cut the text between two strings : 1st TS and DOCC. efvar4=$(echo $filename | sed -n "s/.*TS//;s/DOCC.*//p") Result = _EOR99.DAT - Here it is matching 2nd TS in the filename. Desired result : .TS.D20161022.TS_BAR99.DAT. How to modify my sed command to acheive my result.
0debug
static int init_output_stream_encode(OutputStream *ost) { InputStream *ist = get_input_stream(ost); AVCodecContext *enc_ctx = ost->enc_ctx; AVCodecContext *dec_ctx = NULL; AVFormatContext *oc = output_files[ost->file_index]->ctx; int j, ret; set_encoder_id(output_files[ost->file_index], ost); if (ist) { ost->st->disposition = ist->st->disposition; dec_ctx = ist->dec_ctx; enc_ctx->chroma_sample_location = dec_ctx->chroma_sample_location; } else { for (j = 0; j < oc->nb_streams; j++) { AVStream *st = oc->streams[j]; if (st != ost->st && st->codecpar->codec_type == ost->st->codecpar->codec_type) break; } if (j == oc->nb_streams) if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || ost->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) ost->st->disposition = AV_DISPOSITION_DEFAULT; } if ((enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO || enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO) && filtergraph_is_simple(ost->filter->graph)) { FilterGraph *fg = ost->filter->graph; if (configure_filtergraph(fg)) { av_log(NULL, AV_LOG_FATAL, "Error opening filters!\n"); exit_program(1); } } if (enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) { if (!ost->frame_rate.num) ost->frame_rate = av_buffersink_get_frame_rate(ost->filter->filter); if (ist && !ost->frame_rate.num) ost->frame_rate = ist->framerate; if (ist && !ost->frame_rate.num) ost->frame_rate = ist->st->r_frame_rate; if (ist && !ost->frame_rate.num) { ost->frame_rate = (AVRational){25, 1}; av_log(NULL, AV_LOG_WARNING, "No information " "about the input framerate is available. Falling " "back to a default value of 25fps for output stream #%d:%d. Use the -r option " "if you want a different framerate.\n", ost->file_index, ost->index); } if (ost->enc && ost->enc->supported_framerates && !ost->force_fps) { int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates); ost->frame_rate = ost->enc->supported_framerates[idx]; } if (enc_ctx->codec_id == AV_CODEC_ID_MPEG4) { av_reduce(&ost->frame_rate.num, &ost->frame_rate.den, ost->frame_rate.num, ost->frame_rate.den, 65535); } } switch (enc_ctx->codec_type) { case AVMEDIA_TYPE_AUDIO: enc_ctx->sample_fmt = av_buffersink_get_format(ost->filter->filter); if (dec_ctx) enc_ctx->bits_per_raw_sample = FFMIN(dec_ctx->bits_per_raw_sample, av_get_bytes_per_sample(enc_ctx->sample_fmt) << 3); enc_ctx->sample_rate = av_buffersink_get_sample_rate(ost->filter->filter); enc_ctx->channel_layout = av_buffersink_get_channel_layout(ost->filter->filter); enc_ctx->channels = av_buffersink_get_channels(ost->filter->filter); enc_ctx->time_base = (AVRational){ 1, enc_ctx->sample_rate }; break; case AVMEDIA_TYPE_VIDEO: enc_ctx->time_base = av_inv_q(ost->frame_rate); if (!(enc_ctx->time_base.num && enc_ctx->time_base.den)) enc_ctx->time_base = av_buffersink_get_time_base(ost->filter->filter); if ( av_q2d(enc_ctx->time_base) < 0.001 && video_sync_method != VSYNC_PASSTHROUGH && (video_sync_method == VSYNC_CFR || video_sync_method == VSYNC_VSCFR || (video_sync_method == VSYNC_AUTO && !(oc->oformat->flags & AVFMT_VARIABLE_FPS)))){ av_log(oc, AV_LOG_WARNING, "Frame rate very high for a muxer not efficiently supporting it.\n" "Please consider specifying a lower framerate, a different muxer or -vsync 2\n"); } for (j = 0; j < ost->forced_kf_count; j++) ost->forced_kf_pts[j] = av_rescale_q(ost->forced_kf_pts[j], AV_TIME_BASE_Q, enc_ctx->time_base); enc_ctx->width = av_buffersink_get_w(ost->filter->filter); enc_ctx->height = av_buffersink_get_h(ost->filter->filter); enc_ctx->sample_aspect_ratio = ost->st->sample_aspect_ratio = ost->frame_aspect_ratio.num ? av_mul_q(ost->frame_aspect_ratio, (AVRational){ enc_ctx->height, enc_ctx->width }) : av_buffersink_get_sample_aspect_ratio(ost->filter->filter); if (!strncmp(ost->enc->name, "libx264", 7) && enc_ctx->pix_fmt == AV_PIX_FMT_NONE && av_buffersink_get_format(ost->filter->filter) != AV_PIX_FMT_YUV420P) av_log(NULL, AV_LOG_WARNING, "No pixel format specified, %s for H.264 encoding chosen.\n" "Use -pix_fmt yuv420p for compatibility with outdated media players.\n", av_get_pix_fmt_name(av_buffersink_get_format(ost->filter->filter))); if (!strncmp(ost->enc->name, "mpeg2video", 10) && enc_ctx->pix_fmt == AV_PIX_FMT_NONE && av_buffersink_get_format(ost->filter->filter) != AV_PIX_FMT_YUV420P) av_log(NULL, AV_LOG_WARNING, "No pixel format specified, %s for MPEG-2 encoding chosen.\n" "Use -pix_fmt yuv420p for compatibility with outdated media players.\n", av_get_pix_fmt_name(av_buffersink_get_format(ost->filter->filter))); enc_ctx->pix_fmt = av_buffersink_get_format(ost->filter->filter); if (dec_ctx) enc_ctx->bits_per_raw_sample = FFMIN(dec_ctx->bits_per_raw_sample, av_pix_fmt_desc_get(enc_ctx->pix_fmt)->comp[0].depth); ost->st->avg_frame_rate = ost->frame_rate; if (!dec_ctx || enc_ctx->width != dec_ctx->width || enc_ctx->height != dec_ctx->height || enc_ctx->pix_fmt != dec_ctx->pix_fmt) { enc_ctx->bits_per_raw_sample = frame_bits_per_raw_sample; } if (ost->forced_keyframes) { if (!strncmp(ost->forced_keyframes, "expr:", 5)) { ret = av_expr_parse(&ost->forced_keyframes_pexpr, ost->forced_keyframes+5, forced_keyframes_const_names, NULL, NULL, NULL, NULL, 0, NULL); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Invalid force_key_frames expression '%s'\n", ost->forced_keyframes+5); return ret; } ost->forced_keyframes_expr_const_values[FKF_N] = 0; ost->forced_keyframes_expr_const_values[FKF_N_FORCED] = 0; ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] = NAN; ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] = NAN; } else if(strncmp(ost->forced_keyframes, "source", 6)) { parse_forced_key_frames(ost->forced_keyframes, ost, ost->enc_ctx); } } break; case AVMEDIA_TYPE_SUBTITLE: enc_ctx->time_base = (AVRational){1, 1000}; if (!enc_ctx->width) { enc_ctx->width = input_streams[ost->source_index]->st->codecpar->width; enc_ctx->height = input_streams[ost->source_index]->st->codecpar->height; } break; case AVMEDIA_TYPE_DATA: break; default: abort(); break; } return 0; }
1threat
static inline void RENAME(rgb24to32)(const uint8_t *src,uint8_t *dst,unsigned src_size) { uint8_t *dest = dst; const uint8_t *s = src; const uint8_t *end; #ifdef HAVE_MMX const uint8_t *mm_end; #endif end = s + src_size; #ifdef HAVE_MMX __asm __volatile(PREFETCH" %0"::"m"(*s):"memory"); mm_end = end - 23; __asm __volatile("movq %0, %%mm7"::"m"(mask32):"memory"); while(s < mm_end) { __asm __volatile( PREFETCH" 32%1\n\t" "movd %1, %%mm0\n\t" "punpckldq 3%1, %%mm0\n\t" "movd 6%1, %%mm1\n\t" "punpckldq 9%1, %%mm1\n\t" "movd 12%1, %%mm2\n\t" "punpckldq 15%1, %%mm2\n\t" "movd 18%1, %%mm3\n\t" "punpckldq 21%1, %%mm3\n\t" "pand %%mm7, %%mm0\n\t" "pand %%mm7, %%mm1\n\t" "pand %%mm7, %%mm2\n\t" "pand %%mm7, %%mm3\n\t" MOVNTQ" %%mm0, %0\n\t" MOVNTQ" %%mm1, 8%0\n\t" MOVNTQ" %%mm2, 16%0\n\t" MOVNTQ" %%mm3, 24%0" :"=m"(*dest) :"m"(*s) :"memory"); dest += 32; s += 24; } __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); #endif while(s < end) { #ifdef WORDS_BIGENDIAN *dest++ = 0; *dest++ = *s++; *dest++ = *s++; *dest++ = *s++; #else *dest++ = *s++; *dest++ = *s++; *dest++ = *s++; *dest++ = 0; #endif } }
1threat
I got some problems with 2 programs im working on : <p>i have been working on 2 programs:</p> <pre><code> void neg_zero(char* x) { if (*x &lt; 0) { x = 0; } } </code></pre> <p>this code above men't to check if a char that x point to is negative and if is negative the code will zero x.</p> <p>second code: </p> <pre><code> void weirdFunc(int* a, int * b) { **if (a == b)** { **a = a + b;** } else { **b = a - b;** } } void main() { int a = 0, y=0; int* x = NULL; x = &amp;a; a = 6; y = 5; **weirdFunc(x, y);** **printf("%d \n%d \n", x, y);** } </code></pre> <p>this function receive two pointers to int and them like that: if the two numbers equals it puts in the first parameter their combining. if the two numbers are different it put in the second parameters their difference.</p> <p>now the second function made in a very specific demand so if you can change only the marker'd parts (**).</p> <p>Thank you all! </p>
0debug
i have a list index of range eror : This code work for the first line in the document but fail in the second trial , and i don't know why . i tied to see in similar question but i don't found solution ``` carac=":" fichier = open("test", "r") for i in range(2): time.sleep(0.5) chaine = fichier.readline().split(carac) print(chaine[0]) driver = webdriver.Chrome(r'C:\Users\bh\Downloads\chromedriver') driver.get('https://www.twitter.com/login') username_box = driver.find_element_by_class_name('js-username-field') username_box.send_keys(chaine[0]) password_box = driver.find_element_by_class_name('js-password-field') password_box.send_keys(chaine[1]) ``` i have this error ``` Traceback (most recent call last): File "C:/Users/Hicham/PycharmProjects/test/twitter-retweet.py", line 199, in <module> password_box.send_keys(chaine[1]) IndexError: list index out of range ```
0debug
INLINE flag extractFloat32Sign( float32 a ) { return a>>31; }
1threat
scrollToRowAtIndexPath:atScrollPosition causing table view to "jump" : <p>My app has chat functionality and I'm feeding in new messages like this:</p> <pre><code>[self.tableView beginUpdates]; [messages addObject:msg]; [self.tableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:messages.count - 1 inSection:1]] withRowAnimation:UITableViewRowAnimationBottom]; [self.tableView endUpdates]; [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:messages.count - 1 inSection:1] atScrollPosition:UITableViewScrollPositionBottom animated:YES]; </code></pre> <p>However, my table view "jumps" weirdly when I'm adding a new message (either sending and receiving, result is the same in both):</p> <p><a href="https://i.stack.imgur.com/3ZcEX.gif"><img src="https://i.stack.imgur.com/3ZcEX.gif" alt="enter image description here"></a></p> <p>Why am I getting this weird "jump"?</p>
0debug
Python - I used the beautifulsoup. but result value of href is disappeared : this is html <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <div class="s_write"> <p style="text-align:left;"></P> <div app_paragraph="Dc_App_Img_0" app_editorno="0"> <img src="http://dcimg6.dcinside.co.kr/viewimage.php?id=2fbcc323e7d334aa51b1d3a240&amp;no=24b0d769e1d32ca73fef84fa11d028318f52c0eeb141bee560297996d466c894cf2d16427672bba3d66d67f244141456484ebe788e4b1ac8601ef468abc7cad6754f440d9ddbfc0370c7" style="cursor:pointer;" onclick="javascript:imgPop('http://image.dcinside.com/viewimagePop.php?id=2fbcc323e7d334aa51b1d3a240&amp;no=24b0d769e1d32ca73fef84fa11d028318f52c0eeb141bee560297996d466c894cf2d16427672bba3d66d67f24452490c8b9fb90ae74e4d6a2435010d29956ad37f400586d9cb','image','fullscreen=yes,scrollbars=yes,resizable=no,menubar=no,toolbar=no,location=no,status=no');"></div> <!-- end snippet --> i want to extract <pre>http://image.dcinside.com/viewimagePop.php?id=2fbcc323e7d334aa51b1d3a240&amp;no=24b0d769e1d32ca73fef84fa11d028318f52c0eeb141bee560297996d466c894cf2d16427672bba3d66d67f24452490c8b9fb90ae74e4d6a2435010d29956ad37f400586d9cb </pre> so i programming like this for link in internal.find_all('div',class_="s_write"): print (link) but result is <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <div class="s_write"><p style="text-align:left;"><div app_editorno="0" app_paragraph="Dc_App_Img_0"><img src="http://dcimg6.dcinside.co.kr/viewimage.php?id=2fbcc323e7d334aa51b1d3a240&amp;no=24b0d769e1d32ca73fef84fa11d028318f52c0eeb141bee560297996d466c894cf2d16427672bba3d66d67f24452490c8a9dbf0ae34e4a6a20370e5a2d9633d5701c48dc23ac"/></p></div> <!-- end snippet --> href does not contain at result what's problem?...
0debug
static void json_message_process_token(JSONLexer *lexer, GString *input, JSONTokenType type, int x, int y) { JSONMessageParser *parser = container_of(lexer, JSONMessageParser, lexer); JSONToken *token; switch (type) { case JSON_LCURLY: parser->brace_count++; break; case JSON_RCURLY: parser->brace_count--; break; case JSON_LSQUARE: parser->bracket_count++; break; case JSON_RSQUARE: parser->bracket_count--; break; default: break; } token = g_malloc(sizeof(JSONToken) + input->len + 1); token->type = type; memcpy(token->str, input->str, input->len); token->str[input->len] = 0; token->x = x; token->y = y; parser->token_size += input->len; g_queue_push_tail(parser->tokens, token); if (type == JSON_ERROR) { goto out_emit_bad; } else if (parser->brace_count < 0 || parser->bracket_count < 0 || (parser->brace_count == 0 && parser->bracket_count == 0)) { goto out_emit; } else if (parser->token_size > MAX_TOKEN_SIZE || g_queue_get_length(parser->tokens) > MAX_TOKEN_COUNT || parser->bracket_count + parser->brace_count > MAX_NESTING) { goto out_emit_bad; } return; out_emit_bad: json_message_free_tokens(parser); out_emit: parser->brace_count = 0; parser->bracket_count = 0; parser->emit(parser, parser->tokens); parser->tokens = g_queue_new(); parser->token_size = 0; }
1threat
static void s390_cpu_class_init(ObjectClass *oc, void *data) { S390CPUClass *scc = S390_CPU_CLASS(oc); CPUClass *cc = CPU_CLASS(scc); DeviceClass *dc = DEVICE_CLASS(oc); scc->parent_realize = dc->realize; dc->realize = s390_cpu_realizefn; scc->parent_reset = cc->reset; cc->reset = s390_cpu_reset; cc->do_interrupt = s390_cpu_do_interrupt; cc->dump_state = s390_cpu_dump_state; cc->set_pc = s390_cpu_set_pc; cc->gdb_read_register = s390_cpu_gdb_read_register; cc->gdb_write_register = s390_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = s390_cpu_get_phys_page_debug; #endif dc->vmsd = &vmstate_s390_cpu; cc->gdb_num_core_regs = S390_NUM_REGS; }
1threat
static void visitor_output_teardown(TestOutputVisitorData *data, const void *unused) { visit_free(data->ov); data->sov = NULL; data->ov = NULL; g_free(data->str); data->str = NULL; }
1threat
The questions connected with Android Studio : I hope for a ponimayeniye, a beginner. I can't solve these two problems: 1.Error:(20, 20) error: cannot find symbol variable mQuestionBank 2.Error:(20, 20) error: cannot find symbol variable mQuestionBank Code: enter code here `enter code here`import android.os.Bundle; `enter code here`import android.support.v7.app.AppCompatActivity; `enter code here`import android.widget.Button; `enter code here`import android.widget.TextView; `enter code here`import android.widget.Toast; public class QuizActivity extends AppCompatActivity { private android.widget.Button mTrueButton; private android.widget.Button mFalseButton; private Button mNextButton; private TextView mQuestionTextView; private int mCurrentIndex = 0; private void updateQuestion() { int question; question = mQuestionBank[mCurrentIndex].getQuestion(); mQuestionTextView.setText(question); } private void checkAnswer(boolean userPressedTrue) { boolean answerIsTrue = mQuestionBank[mCurrentIndex].isTrueQuestion(); int messageResId = 0; if (userPressedTrue == answerIsTrue) { messageResId = R.string.correct_toast; } else { messageResId = R.string.incorrect_toast; } Toast.makeText(this, messageResId , Toast.LENGTH_SHORT) .show(); } private TrueFalse[] mQuesionBank = new TrueFalse[] { new TrueFalse(R.string.question_1, false), new TrueFalse(R.string.question_2, true), new TrueFalse(R.string.question_3, false), }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_quiz); mQuestionTextView = (TextView)findViewById(R.id.question_text_view); mTrueButton = (android.widget.Button)findViewById(R.id.true_button); mTrueButton.setOnClickListener(new android.view.View.OnClickListener() { @Override public void onClick(android.view.View v) { checkAnswer(true); } }); mFalseButton = (android.widget.Button)findViewById(R.id.false_button); mFalseButton.setOnClickListener(new android.view.View.OnClickListener() { public void onClick(android.view.View v) { checkAnswer(false); } }); mNextButton = (Button)findViewById(R.id.next_button); mNextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mCurrentIndex = (mCurrentIndex + 1) % mQuestionBank.length; updateQuestion(); } }); updateQuestion(); } } I will be very grateful to those who will intelligibly and it is clear explain! Thanks! Sorry, if has issued something not so. First time ;)
0debug
Setting HeightRequest back to Auto in Xamarin.Forms : <p>In Xamarin.Forms I want to be able to set the exact height for a control whose height is initially determined using VerticalLayoutOptions only (FillAndExpand in this case) and then, at a later point, reset the height of the control back to be automatically determined.</p> <p>In normal XAML it is possible to do this via double.Nan but performing the following causes an exception to be thrown.:</p> <pre><code>control.HeightRequest = double.NaN </code></pre> <p>How do you set the HeightRequest back to be self-determined?</p>
0debug
Android Fabric Crashlytics crashing with Resources$NotFoundException on app launch : <pre><code>android.content.res.Resources$NotFoundException android.content.res.ResourcesImpl.getResourcePackageName </code></pre> <p>After upgrading Crashlytics from <strong>2.6.6 to 2.9.1</strong> we have started to notice a crash in Google Play Console.</p> <p>This crash happens before Crashlytics is initialized so it is never reported in Crashlytics:</p> <pre><code>java.lang.RuntimeException: at android.app.ActivityThread.installProvider (ActivityThread.java:6423) at android.app.ActivityThread.installContentProviders (ActivityThread.java:6012) at android.app.ActivityThread.handleBindApplication (ActivityThread.java:5951) at android.app.ActivityThread.-wrap3 (ActivityThread.java) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1710) at android.os.Handler.dispatchMessage (Handler.java:102) at android.os.Looper.loop (Looper.java:154) at android.app.ActivityThread.main (ActivityThread.java:6776) at java.lang.reflect.Method.invoke (Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1518) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1408) Caused by: android.content.res.Resources$NotFoundException: at android.content.res.ResourcesImpl.getResourcePackageName (ResourcesImpl.java:248) at android.content.res.Resources.getResourcePackageName (Resources.java:2785) at io.fabric.sdk.android.services.common.CommonUtils.getResourcePackageName (CommonUtils.java:767) at io.fabric.sdk.android.services.common.CommonUtils.getResourcesIdentifier (CommonUtils.java:517) at io.fabric.sdk.android.services.common.CommonUtils.getBooleanResourceValue (CommonUtils.java:498) at io.fabric.sdk.android.services.common.FirebaseInfo.isFirebaseCrashlyticsEnabled (FirebaseInfo.java:52) at com.crashlytics.android.CrashlyticsInitProvider.shouldInitializeFabric (CrashlyticsInitProvider.java:73) at com.crashlytics.android.CrashlyticsInitProvider.onCreate (CrashlyticsInitProvider.java:25) at android.content.ContentProvider.attachInfo (ContentProvider.java:1759) at android.content.ContentProvider.attachInfo (ContentProvider.java:1734) at android.app.ActivityThread.installProvider (ActivityThread.java:6420) at android.app.ActivityThread.installContentProviders (ActivityThread.java:6012) at android.app.ActivityThread.handleBindApplication (ActivityThread.java:5951) at android.app.ActivityThread.-wrap3 (ActivityThread.java) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1710) at android.os.Handler.dispatchMessage (Handler.java:102) at android.os.Looper.loop (Looper.java:154) at android.app.ActivityThread.main (ActivityThread.java:6776) at java.lang.reflect.Method.invoke (Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1518) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1408) </code></pre> <p>The crash doesn't impact too many users, but they can't start the app. I.e. we have this ratio: </p> <ul> <li>Impacted users: 93</li> <li>Reports total: 4,221</li> </ul>
0debug
In mysql how to clear the missing parenthesis error? : CREATE TABLE Bill( BillNo INTEGER PRIMARY KEY, StoreName VARCHAR2(20) FOREIGN KEY, Shopperid INTEGER FOREIGN KEY, ArCode CHAR(5) FOREIGN KEY, Amount INTEGER, BillDate DATE, Quantity NUMBER(4) Default 1 Check (Quantity>0)); Im getting missing paranthesis error.somebody help me with the code?
0debug
understand use of require in perl : What is the use of the keyword 'require' in perl. I have referred http://perldoc.perl.org/functions/require.html but it is not very helpful.
0debug
LayoutInflater Unreachable Statement : <p><a href="https://i.stack.imgur.com/xLtuy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xLtuy.png" alt=""></a></p> <p>I try to create some List Adapter for my listview, but it says the LayoutInflater is uncracheble statement. I already search for similar question but no idea. hope you guys can help me, thanks in advance.</p>
0debug
Redux warning only appearing in tests : <p>I have created a tic tac toe game with react redux.</p> <p>I am using <a href="https://github.com/facebookincubator/create-react-app" rel="noreferrer">create-react-app</a>.</p> <p>I have the following store:</p> <pre><code>import {createStore, combineReducers} from 'redux'; import gameSettingsReducer from './reducers/gameSettings.js'; import gameStatusReducer from './reducers/gameStatus.js'; const rootReducer = combineReducers({gameSettings: gameSettingsReducer, gameStatus: gameStatusReducer}); export const defaultGameStatus = { currentPlayerSymbol: "X", turnNumber: 0, currentView: "start-menu", //one of "start-menu", "in-game", "game-over" winner: "draw", //one of "X", "O", "draw" board: [["E", "E", "E"], ["E", "E", "E"], ["E", "E", "E"]], lastMove: [] }; const store = createStore(rootReducer, { gameSettings:{ playerSymbol: "X", //one of "X", "O" difficulty: "easy" //one of "easy", "hard" }, gameStatus: defaultGameStatus }); export default store; </code></pre> <p>Everything runs as I expect. Except for when I am running tests (<code>npm test</code>) the following appears in the console:</p> <pre><code>console.error node_modules\redux\lib\utils\warning.js:14 No reducer provided for key "gameStatus" console.error node_modules\redux\lib\utils\warning.js:14 Unexpected key "gameStatus" found in preloadedState argument passed to createStore. Expected to find one of the known reducer keys instead: "gameSettings". Unexpected keys will be ignored. </code></pre> <p>In the few tests I have, I am not even testing the store. So I guess this comes up while compiling the code. I tried putting <code>console.log(gameStatusReducer)</code> before the root reducer line. It shows that gameStatusReducer is undefined. </p> <p>Since both the gameSettingsReducer and the gameStatusReducer are created in very similar ways, I do not know where this error comes from and do not even know how to investigate the issue further. This only shows up when running the tests. Running the app does not show this problem and the app works as expected.</p> <p>So, the questions are:</p> <ul> <li>Why is this just showing up in the tests?</li> <li>How to investigate where the problem is coming from?</li> </ul>
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
bool write_cpustate_to_list(ARMCPU *cpu) { int i; bool ok = true; for (i = 0; i < cpu->cpreg_array_len; i++) { uint32_t regidx = kvm_to_cpreg_id(cpu->cpreg_indexes[i]); const ARMCPRegInfo *ri; ri = get_arm_cp_reginfo(cpu->cp_regs, regidx); if (!ri) { ok = false; continue; } if (ri->type & ARM_CP_NO_MIGRATE) { continue; } cpu->cpreg_values[i] = read_raw_cp_reg(&cpu->env, ri); } return ok; }
1threat
GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp) { PSYSTEM_LOGICAL_PROCESSOR_INFORMATION pslpi, ptr; DWORD length; GuestLogicalProcessorList *head, **link; Error *local_err = NULL; int64_t current; ptr = pslpi = NULL; length = 0; current = 0; head = NULL; link = &head; if ((GetLogicalProcessorInformation(pslpi, &length) == FALSE) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) && (length > sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION))) { ptr = pslpi = g_malloc0(length); if (GetLogicalProcessorInformation(pslpi, &length) == FALSE) { error_setg(&local_err, "Failed to get processor information: %d", (int)GetLastError()); } } else { error_setg(&local_err, "Failed to get processor information buffer length: %d", (int)GetLastError()); } while ((local_err == NULL) && (length > 0)) { if (pslpi->Relationship == RelationProcessorCore) { ULONG_PTR cpu_bits = pslpi->ProcessorMask; while (cpu_bits > 0) { if (!!(cpu_bits & 1)) { GuestLogicalProcessor *vcpu; GuestLogicalProcessorList *entry; vcpu = g_malloc0(sizeof *vcpu); vcpu->logical_id = current++; vcpu->online = true; vcpu->has_can_offline = false; entry = g_malloc0(sizeof *entry); entry->value = vcpu; *link = entry; link = &entry->next; } cpu_bits >>= 1; } } length -= sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION); pslpi++; } g_free(ptr); if (local_err == NULL) { if (head != NULL) { return head; } error_setg(&local_err, "Guest reported zero VCPUs"); } qapi_free_GuestLogicalProcessorList(head); error_propagate(errp, local_err); return NULL; }
1threat
type_init(macio_register_types) void macio_init(PCIDevice *d, MemoryRegion *pic_mem, MemoryRegion *escc_mem) { MacIOState *macio_state = MACIO(d); macio_state->pic_mem = pic_mem; macio_state->escc_mem = escc_mem; qdev_init_nofail(DEVICE(d)); }
1threat
tools to create a website : <p>I am trying to learn JavaScript &amp; AngularJS, had basic idea of HTML &amp; CSS.</p> <p>I want to create a website like a registration one.</p> <p><strong>Registration:</strong> I already made a registration page with first name, last name, email &amp; password.</p> <p>So now, when any user enter the details and hit register button, the page should display the user full name, email with registration success message.</p> <p>Also the registration details should be loaded to database.</p> <p><strong>Login:</strong> I also made the login page with email and password.</p> <p>So now, when user hits login with correct credentials, the page should displays logged in with user details.</p> <p><strong>Database:</strong></p> <p>I want to know which database can I use? how to use that database? Will this include programming or a tool to create the table?</p> <p><strong>Tools:</strong></p> <p>I am looking to work with AngularJS</p> <p>So for overall about this project, what tools I have to use or install. I have <strong>Mac</strong>.</p> <p>What tools can help to integrate the files?</p>
0debug
Latest builds from Angular2 complain with: NgModule DynamicModule uses HomeComponent via "entryComponents" : <p>Since switching to the latest builds of Angular 2 (i.e. on github, master), I get warnings as follows about all my components:</p> <blockquote> <p>NgModule DynamicModule uses HomeComponent via "entryComponents" but it was neither declared nor imported! This warning will become an error after final.</p> </blockquote> <p>I get the same error message for all my components, in addition to <code>HomeComponent</code>.</p> <p>Can anyone please provide information about those?</p>
0debug
static void gui_update(void *opaque) { uint64_t interval = GUI_REFRESH_INTERVAL; DisplayState *ds = opaque; DisplayChangeListener *dcl = ds->listeners; qemu_flush_coalesced_mmio_buffer(); dpy_refresh(ds); while (dcl != NULL) { if (dcl->gui_timer_interval && dcl->gui_timer_interval < interval) interval = dcl->gui_timer_interval; dcl = dcl->next; } qemu_mod_timer(ds->gui_timer, interval + qemu_get_clock(rt_clock)); }
1threat
C# master class that calls other classes with simlar properties : I have a lot of classes that store different types of data but manipulate the data differently. Is there someway I can abstract what class I'm using...and just call the class's methods? I will have one object that I'm using at a given moment, masterclass. For example I have class1 and class2. Both classes can do .add .subtract...etc. I want to say...masterclass is now class1. So I can do masterclass.add instead of class1.add. Then change masterclass to class2 and do a masterclass.subtract instead of class1.subtract. This is just an example. Thanks in advance.
0debug
I made a very basic calculator and it doesn't run. I think the "def" thing is a issue : I made a very basic calculator in Python 2.7. The thing worked fine before I thought of making it loop so that it doesn't exit automatically. I created this ----> http://pastebin.com/suUSfLgs the original code without def ---> http://pastebin.com/83AtPMKB What am I doing wrong with the def things? Sorry I am new to Python.
0debug
av_cold void ff_mpeg1_encode_init(MpegEncContext *s) { static int done = 0; ff_mpeg12_common_init(s); if (!done) { int f_code; int mv; int i; done = 1; ff_rl_init(&ff_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]); ff_rl_init(&ff_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]); for (i = 0; i < 64; i++) { mpeg1_max_level[0][i] = ff_rl_mpeg1.max_level[0][i]; mpeg1_index_run[0][i] = ff_rl_mpeg1.index_run[0][i]; } init_uni_ac_vlc(&ff_rl_mpeg1, uni_mpeg1_ac_vlc_len); if (s->intra_vlc_format) init_uni_ac_vlc(&ff_rl_mpeg2, uni_mpeg2_ac_vlc_len); for (i = -255; i < 256; i++) { int adiff, index; int bits, code; int diff = i; adiff = FFABS(diff); if (diff < 0) diff--; index = av_log2(2 * adiff); bits = ff_mpeg12_vlc_dc_lum_bits[index] + index; code = (ff_mpeg12_vlc_dc_lum_code[index] << index) + av_mod_uintp2(diff, index); mpeg1_lum_dc_uni[i + 255] = bits + (code << 8); bits = ff_mpeg12_vlc_dc_chroma_bits[index] + index; code = (ff_mpeg12_vlc_dc_chroma_code[index] << index) + av_mod_uintp2(diff, index); mpeg1_chr_dc_uni[i + 255] = bits + (code << 8); } for (f_code = 1; f_code <= MAX_FCODE; f_code++) for (mv = -MAX_MV; mv <= MAX_MV; mv++) { int len; if (mv == 0) { len = ff_mpeg12_mbMotionVectorTable[0][1]; } else { int val, bit_size, code; bit_size = f_code - 1; val = mv; if (val < 0) val = -val; val--; code = (val >> bit_size) + 1; if (code < 17) len = ff_mpeg12_mbMotionVectorTable[code][1] + 1 + bit_size; else len = ff_mpeg12_mbMotionVectorTable[16][1] + 2 + bit_size; } mv_penalty[f_code][mv + MAX_MV] = len; } for (f_code = MAX_FCODE; f_code > 0; f_code--) for (mv = -(8 << f_code); mv < (8 << f_code); mv++) fcode_tab[mv + MAX_MV] = f_code; } s->me.mv_penalty = mv_penalty; s->fcode_tab = fcode_tab; if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO) { s->min_qcoeff = -255; s->max_qcoeff = 255; } else { s->min_qcoeff = -2047; s->max_qcoeff = 2047; } if (s->intra_vlc_format) { s->intra_ac_vlc_length = s->intra_ac_vlc_last_length = uni_mpeg2_ac_vlc_len; } else { s->intra_ac_vlc_length = s->intra_ac_vlc_last_length = uni_mpeg1_ac_vlc_len; } s->inter_ac_vlc_length = s->inter_ac_vlc_last_length = uni_mpeg1_ac_vlc_len; }
1threat
Where do I find the file in wordpress /PHP project that I can edit the menu? : <p>I have project which was done in php. But I couldn't find the menu bar. In inspect element I find that it comes from navigation.html. But I couldn't find this file. Can any one help me with this? Thank you!</p>
0debug
static void simple_number(void) { int i; struct { const char *encoded; int64_t decoded; int skip; } test_cases[] = { { "0", 0 }, { "1234", 1234 }, { "1", 1 }, { "-32", -32 }, { "-0", 0, .skip = 1 }, { }, }; for (i = 0; test_cases[i].encoded; i++) { QObject *obj; QInt *qint; obj = qobject_from_json(test_cases[i].encoded); g_assert(obj != NULL); g_assert(qobject_type(obj) == QTYPE_QINT); qint = qobject_to_qint(obj); g_assert(qint_get_int(qint) == test_cases[i].decoded); if (test_cases[i].skip == 0) { QString *str; str = qobject_to_json(obj); g_assert(strcmp(qstring_get_str(str), test_cases[i].encoded) == 0); QDECREF(str); } QDECREF(qint); } }
1threat
static int dca_decode_frame(AVCodecContext * avctx, void *data, int *data_size, const uint8_t * buf, int buf_size) { int i, j, k; int16_t *samples = data; DCAContext *s = avctx->priv_data; int channels; s->dca_buffer_size = dca_convert_bitstream(buf, buf_size, s->dca_buffer, DCA_MAX_FRAME_SIZE); if (s->dca_buffer_size == -1) { av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n"); return -1; } init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8); if (dca_parse_frame_header(s) < 0) { *data_size=0; return buf_size; } avctx->sample_rate = s->sample_rate; avctx->bit_rate = s->bit_rate; channels = s->prim_channels + !!s->lfe; if(avctx->request_channels == 2 && s->prim_channels > 2) { channels = 2; s->output = DCA_STEREO; } avctx->channels = channels; if(*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels) return -1; *data_size = 0; for (i = 0; i < (s->sample_blocks / 8); i++) { dca_decode_block(s); s->dsp.float_to_int16(s->tsamples, s->samples, 256 * channels); for (j = 0; j < 256; j++) { for (k = 0; k < channels; k++) samples[k] = s->tsamples[j + k * 256]; samples += channels; } *data_size += 256 * sizeof(int16_t) * channels; } return buf_size; }
1threat
An unwanted margins and my command about width not worked : I was designing a home page but I dealt with : http://uupload.ir/files/ypzf_untitled.png and something like this in footer part... It wasn't happened for me before :( there are all stylesheets and html docs http://uupload.ir/view/rdtj_web_sample.rar/ I suppose They end in on column without horizontal scroll!!
0debug
Bufferoverflow, snprintf instead char resizes? : <p>I have a hard time to understand why the below code is not resulting in a bufferoverflow and instead some how seems to resize the char example from 1 to 16.</p> <p>I checked the snprintf documentation but nothing to be found about this.</p> <pre><code>//set char example size 1 char example[1]; //set example to args-&gt;arg2 which is a 15 character + 1 null byte. //trying to put something to big into something too small, in my mind causing not a resize but a bof. snprintf(example, 16, "%s", args-&gt;arg2); fprintf(stdout,"[%s],example); </code></pre> <p>The fprintf in the end does not display 1 character nor does char example overflows but instead it seems to be resized and displays the full string of 16.</p> <p>What am i misunderstanding here ?</p>
0debug
pivot Result Creation from sql query : I Have My First table like this,It contains platform and their platform code +-----------+------+ | platforms | code | +-----------+------+ | java | 1 | +-----------+------+ | .net | 2 | +-----------+------+ | perl | 3 | +-----------+------+ My Second Table Contains +-------+------+------++------+ | pname | code | year || deve | +-------+------+------++------+ | a | 1 | 2018 || abia | +-------+------+------++------+ | b | 1 | 2017 || arun | +-------+------+------++------+ | c | 2 | 2018 || abia | +-------+------+------++------+ | d | 3 | 2017 || arun | +-------+------+------++------+ | e | 2 | 2017 || arun | +-------+------+------++------+ | f | 3 | 2018 || abia | +-------+------+------++------+ Result Expected in Pivot Format like given +-----+-------+------+------+------+ | year| deve | .net | java | perl | +-----+-------+------+------+------+ | 2018| abia | 1 | 1 | 1 | +-----+-------+------+------+------+ | 2017| arun | 1 | 1 | 1 | +-----+-------+------+------+------+
0debug
build_madt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info, VirtAcpiCpuInfo *cpuinfo) { int madt_start = table_data->len; const MemMapEntry *memmap = guest_info->memmap; const int *irqmap = guest_info->irqmap; AcpiMultipleApicTable *madt; AcpiMadtGenericDistributor *gicd; AcpiMadtGenericMsiFrame *gic_msi; int i; madt = acpi_data_push(table_data, sizeof *madt); for (i = 0; i < guest_info->smp_cpus; i++) { AcpiMadtGenericInterrupt *gicc = acpi_data_push(table_data, sizeof *gicc); gicc->type = ACPI_APIC_GENERIC_INTERRUPT; gicc->length = sizeof(*gicc); gicc->base_address = memmap[VIRT_GIC_CPU].base; gicc->cpu_interface_number = i; gicc->arm_mpidr = i; gicc->uid = i; if (test_bit(i, cpuinfo->found_cpus)) { gicc->flags = cpu_to_le32(ACPI_GICC_ENABLED); } } gicd = acpi_data_push(table_data, sizeof *gicd); gicd->type = ACPI_APIC_GENERIC_DISTRIBUTOR; gicd->length = sizeof(*gicd); gicd->base_address = memmap[VIRT_GIC_DIST].base; gic_msi = acpi_data_push(table_data, sizeof *gic_msi); gic_msi->type = ACPI_APIC_GENERIC_MSI_FRAME; gic_msi->length = sizeof(*gic_msi); gic_msi->gic_msi_frame_id = 0; gic_msi->base_address = cpu_to_le64(memmap[VIRT_GIC_V2M].base); gic_msi->flags = cpu_to_le32(1); gic_msi->spi_count = cpu_to_le16(NUM_GICV2M_SPIS); gic_msi->spi_base = cpu_to_le16(irqmap[VIRT_GIC_V2M] + ARM_SPI_BASE); build_header(linker, table_data, (void *)(table_data->data + madt_start), "APIC", table_data->len - madt_start, 3); }
1threat
void qemu_vfree(void *ptr) { }
1threat
How do I add a bullet or create a bulleted list in flutter : <p>I have a list and I want to add a bullet to each item (I'm using <code>new Column</code> because I don't want to implement scrolling). How would I create a bulleted list?</p> <p><em>I'm thinking maybe an icon but possibly there is a way with the decoration class used in the text style.</em></p>
0debug
How can I create dummy variables from a factor in R? : <pre><code>Yield Fertilizer 31 1 34 1 34 1 34 1 43 1 35 1 38 1 36 1 36 1 45 1 27 2 27 2 25 2 34 2 21 2 36 2 34 2 30 2 32 2 33 2 36 3 37 3 37 3 34 3 37 3 28 3 33 3 29 3 36 3 42 3 33 4 27 4 35 4 25 4 29 4 20 4 25 4 40 4 35 4 29 4 </code></pre> <p>I have to divide fertilizer 1 as dummy variable F1, fertilizer 2 as a dummy variable F2 and fertilizer 3 as a dummy variable F3 and 4 as a base line.</p> <p>I import this csv file into R by using read.csv function. But after that when I just use lm function it does not come as I want... What should I do for that?</p>
0debug
Angular animation not working in IE edge : <p>I added an animation to my component in Angular. However the animation WORKS FINE in Chrome and Firefox, but in IE Edge the animation is NOT triggerd although the styles are applied correctly on state change, but just without specified animation.</p> <p>Does anyone have the same issue?</p> <p>Here is my code:</p> <pre><code>animations: [ trigger('rowState', [ state('collapsed', style({ 'height': 0, 'overflow-y': 'hidden' })), state('expanded', style({ 'height': '*', 'overflow-y': 'hidden' })), transition('collapsed &lt;=&gt; expanded', [animate('1000ms ease-out')]) ]) ] </code></pre> <p>Thanks in advance</p>
0debug
Notepad breaking lines up when opening it using ReadAllLines() c# : I've created a program to make bug templates and am having a problem with notepad not saving correctly. I have a text file called TemplateTexts that holds all the text for each template, a template looks like this - REQUIREMENTS - Example ADDITIONAL REQUIREMENTS - Example - Example -----COPY BELOW THIS LINE----- When the program closes it copies all of that into 1 line of a notepad.(looks like this) REQUIREMENTS- Example ADDITIONAL REQUIREMENTS- Example - Example-----COPY BELOW THIS LINE----- The notepad contains 20 lines of templates. The template is saved as 1 line of text into the notepad, but when I go to open the program again, it turns that 1 line of text into multiple lines of text like how it is displayed in the first example. Any idea why this might be happening? or is there a better way to save each template into a notepad, possibly by separating it with flags or something?
0debug
IPv4 regexp capturing the incorrect parts of the address : <p>I'm trying to write a program that prints the invalid part or parts of an IPv4 address from terminal input.</p> <p>Here is my code:</p> <pre class="lang-golang prettyprint-override"><code>package chapter4 import ( "bufio" "fmt" "os" "regexp" "strings" "time" ) func IPV4() { var f *os.File f = os.Stdin defer f.Close() scanner := bufio.NewScanner(f) fmt.Println("Exercise 1, Chapter 4 - Detecting incorrect parts of IPv4 Addresses, enter an address!") for scanner.Scan() { if scanner.Text() == "STOP" { fmt.Println("Initializing Level 4...") time.Sleep(5 * time.Second) break } expression := "(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])" matchMe, err := regexp.Compile(expression) if err != nil { fmt.Println("Could not compile!", err) } s := strings.Split(scanner.Text(), ".") for _, value := range s { fmt.Println(value) str := matchMe.FindString(value) if len(str) == 0 { fmt.Println(value) } } } } </code></pre> <p>My thought process is that for every terminal IP address input, I split the string by '.'</p> <p>Then I iterate over the resulting <code>[]string</code> and match each value to the regular expression. </p> <p>For some reason the only case where the regex expression doesn't match is when there are letter characters in the input. Every number, no matter the size or composition, is a valid match for my expression.</p> <p>I'm hoping you can help me identify the problem, and if there's a better way to do it, I'm all ears. Thanks!</p>
0debug
static void device_unparent(Object *obj) { DeviceState *dev = DEVICE(obj); if (dev->parent_bus != NULL) { bus_remove_child(dev->parent_bus, dev); } }
1threat
Javascript code doesn't execute : <p>My javascript code just won't work. If I simply put <code>&lt;script&gt;alert("alert");&lt;/script&gt;</code> in my code, it works as normal, but the big chunk of script in the following code is seemingly ignored. The code is meant to submit a hidden form when the use clicks a link. Is this a simple missing curly brace, or something more difficult? </p> <p>The Code follows: </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script&gt; function $_GET(q,s) { s = (s) ? s : window.location.search; var re = new RegExp('&amp;amp;'+q+'=([^&amp;amp;]*)','i'); return (s=s.replace(/^\?/,'&amp;amp;').match(re)) ?s=s[1] :s=''; } function setCookie(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays*24*60*60*1000)); var expires = "expires="+d.toUTCString(); document.cookie = cname + "=" + cvalue + "; " + expires; } function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i&lt;ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1); if (c.indexOf(name) == 0) return c.substring(name.length,c.length); } return ""; } Date.prototype.addDays = function(days) { var dat = new Date(this.valueOf()); dat.setDate(dat.getDate() + days); return dat; } function stripGet(url) { return url.split("?")[0]; } function load() { alert('load'); document.getElementByName('link').onclick=onsubmit; if($_GET('l') === "penguin"){ setCookie('expiry', new Date.addDays(30), 400); setCookie('expired', 'FALSE', 30); window.location = stripGet(window.location); } } function onsubmit(){ alert('on submit'); if (new Date() &gt; new Date(getCookie('expiry') || getCookie('expired') == 'TRUE') { alert("expired"); setCookie('expired', 'TRUE', 1000); window.location ='???'; return false; } else { alert("valid"); document.getElementByName('username').value = atob('???'); document.getElementByName('username').value = atob('???'); document.forms['form'].submit(); return true; } &lt;/script&gt; &lt;/head&gt; &lt;body onload="load()" bgcolor="green" top="45%" align="center" link="orange" active="blue" visited="orange"&gt; &lt;form name="form" action="submit.php" method="POST"&gt; &lt;input name="__formname__" type="hidden" value="loginform"&gt; &lt;input name="username" type="hidden"&gt; &lt;input name="username" type="hidden"&gt; &lt;/form&gt; &lt;a name="link" href="javascript:onsubmit();" onclick="alert("click"); onsubmit(); return true;"&gt; &lt;h1 style="font-size: 84pt; padding-top: 1.5cm"&gt; Submit form &lt;/h1&gt; &lt;/a&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
0debug
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
int64_t qemu_file_get_rate_limit(QEMUFile *f) { if (f->ops->get_rate_limit) return f->ops->get_rate_limit(f->opaque); return 0; }
1threat
Reload window even if that browser tab is inactive : <p>is there any way in any programming language to reload the webpage even if that particular browser tab is not active. In simple term i want to reload the web page by doing some other work on different tabs. </p>
0debug
static void pc_init_pci_1_2(QEMUMachineInitArgs *args) { disable_kvm_pv_eoi(); enable_compat_apic_id_mode(); pc_sysfw_flash_vs_rom_bug_compatible = true; has_pvpanic = false; pc_init_pci(args); }
1threat
Having trouble with a string searching program in C++ : <p>for a homework assignment I have been tasked with creating a program that takes a string that is formatted with all words put together, rather then with spaces, and separates the words.</p> <p>Somewhat hard to explain, but what I mean is that the string "StopAndSmellTheRoses", must be converted to "Stop and smell the roses", notice how only the first letter of this sentence is capitalized, that is another requirement.</p> <p>My thoughts are to create a function that searches the string for an uppercase letter using the ASCII code table, and when one is found, I add the letters before that capital letter into a new string. I am using nested loops to try and create this, however I am running into a "DEBUG ASSERTION FAILED!" error message each time.</p> <p>This is only the beginning of this program that I have written so far, and I feel like my ideas haven't been properly translated into code (I basically mean I have little to no idea how to transfer these ideas into actual code).</p> <p>So far I have:</p> <pre><code>#include&lt;iostream&gt; #include&lt;string&gt; #include&lt;cctype&gt; using namespace std; void strConvert(string); int main() { string myStr = "StopAndSmellTheRoses"; strConvert(myStr); system("pause"); return 0; } void strConvert(string myStr) { string newStr; for (int i = 1; i &lt;= sizeof(myStr); i++) { if (myStr[i] &gt; 'A' &amp;&amp; myStr[i] &lt; 'Z') { for (int j = 1; j &lt; i; j++) { newStr += myStr[j]; } tolower(myStr[i]); newStr += '\n'; } } cout &lt;&lt; newStr; } </code></pre> <p>I'm not really sure if my method of "adding" the letters of myStr to newStr even works, but it's what i've been playing around with. Could anyone please help me figure out how to get my function to run? I understand I probably have a large amount of errors, please understand i'm new to c++.</p> <p>Thank you!</p>
0debug
Unable to run Airflow Tasks due to execution date and start date : <p>Whenever I try to run a DAG, it will be in the running state but the tasks will not run. I have set my start date to datetime.today() and my schedule interval to "* * * * *". Manually triggering a run will start the dag but the task will not run due to:</p> <p>The execution date is 2017-09-13T00:00:00 but this is before the task's start date 2017-09-13T16:20:30.363268.</p> <p>I have tried various combinations of schedule intervals (such as a specific time each day) as well as waiting for the dag to be triggered and manual triggers. Nothing seems to work.</p>
0debug
Dynamo Db vs Elastic Search : <p>I was just reading about elastic search and found that it indexes each and every term in the document as well as all fields. Although it has some disadvantages like it cannot provide transactions, etc. But for the application, where I only need to read data from DB and there is no write, is there any advantage to using Dynamo Db instead of Elastic Search. Earlier, I was thinking to use the Dynamo Db, but now after seeing that it indexes each and every field, so why not use Elastic Search itself. Till now, the only use case defined for my project is to search by an id. But in future, more use cases come, then it would be very difficult to add more indexes in Dynamo Db but would already be there in Elastic Search. </p> <p>Can someone tell me of some advantages of Dynamo Db against Elastic Search.</p> <p>Please give your suggestions. </p>
0debug
static uint64_t assigned_dev_ioport_read(void *opaque, target_phys_addr_t addr, unsigned size) { return assigned_dev_ioport_rw(opaque, addr, size, NULL); }
1threat
How to pass dynamic variable to ajax : i have this <input id="test1" value="1" /> <button onclick="kontakte(this)">KLICK1</button> <input id="test2" value="2" /> <button onclick="kontakte(this)">KLICK2</button> <input id="test3" value="3" /> <button onclick="kontakte(this)">KLICK3</button> Jquery: function kontakte(e){ var test = ??????; alert(test); } now when i Klick1 i want to get 1 as value test, how can i do that?
0debug
ajax respose to json array in javascipt : I want to achieve this using javascript. [{ "employeeName":"emp1", "Deaprtment":"dept1"}, { "employeeName":"emp2", "Deaprtment":"dept1"} ] to {"dept1":{"emp1","emp2"}} please advise for possible solution using javascript.
0debug
Navigation using JSON & underscore JS : I need to set up a navigation using JSON & underscore JS, there are two headings with 5 links in each. This is the way I have my JSON and I cannot get the underscore to work and bring all the links and labels, can anyone please help: var navigations = [ { "main_label" : "GIRLS", "sub_page_reference" : "girls", "links" : [ { "label" : "NEW IN >", "href" : "/uk/newin", "target" : "_self", }, { "label" : "sales >", "href" : "/uk/salesy", "target" : "_self", }, { "label" : "girls >", "href" : "/uk/girls", "target" : "_self", }, { "label" : "boys >", "href" : "/uk/boys", "target" : "_self", }, { "label" : "party >", "href" : "/uk/party", "target" : "_self", } ] }, { "main_label" : "BOYS", "sub_page_reference" : "boys", "links" : [ { "label" : "NEW IN >", "href" : "/uk/newin", "target" : "_self", }, { "label" : "sales >", "href" : "/uk/salesy", "target" : "_self", }, { "label" : "girls >", "href" : "/uk/girls", "target" : "_self", }, { "label" : "boys >", "href" : "/uk/boys", "target" : "_self", }, { "label" : "party >", "href" : "/uk/party", "target" : "_self", } ] } ];
0debug
In Jest, how can I make a test fail? : <p>I know I could throw an error from inside the test, but I wonder if there is something like the global <code>fail()</code> method provided by Jasmine?</p>
0debug
chek present modaly or phus in swift, but idont know what for? : > this code i got from my friend. but i don't know how it work. i hope some one in here can help me to explain this code. because this code i would explain to my teacher private func isModal() -> Bool { if self.presentingViewController != nil { return true } else if self.navigationController?.presentingViewController?.presentedViewController == self.navigationController { return true } else if self.tabBarController?.presentingViewController is UITabBarController { return true } return false } > thanks :D
0debug
DriveInfo *drive_init(QemuOpts *opts, void *opaque, int *fatal_error) { const char *buf; const char *file = NULL; char devname[128]; const char *serial; const char *mediastr = ""; BlockInterfaceType type; enum { MEDIA_DISK, MEDIA_CDROM } media; int bus_id, unit_id; int cyls, heads, secs, translation; BlockDriver *drv = NULL; QEMUMachine *machine = opaque; int max_devs; int index; int ro = 0; int bdrv_flags = 0; int on_read_error, on_write_error; const char *devaddr; DriveInfo *dinfo; int snapshot = 0; *fatal_error = 1; translation = BIOS_ATA_TRANSLATION_AUTO; if (machine && machine->use_scsi) { type = IF_SCSI; max_devs = MAX_SCSI_DEVS; pstrcpy(devname, sizeof(devname), "scsi"); } else { type = IF_IDE; max_devs = MAX_IDE_DEVS; pstrcpy(devname, sizeof(devname), "ide"); } media = MEDIA_DISK; bus_id = qemu_opt_get_number(opts, "bus", 0); unit_id = qemu_opt_get_number(opts, "unit", -1); index = qemu_opt_get_number(opts, "index", -1); cyls = qemu_opt_get_number(opts, "cyls", 0); heads = qemu_opt_get_number(opts, "heads", 0); secs = qemu_opt_get_number(opts, "secs", 0); snapshot = qemu_opt_get_bool(opts, "snapshot", 0); ro = qemu_opt_get_bool(opts, "readonly", 0); file = qemu_opt_get(opts, "file"); serial = qemu_opt_get(opts, "serial"); if ((buf = qemu_opt_get(opts, "if")) != NULL) { pstrcpy(devname, sizeof(devname), buf); if (!strcmp(buf, "ide")) { type = IF_IDE; max_devs = MAX_IDE_DEVS; } else if (!strcmp(buf, "scsi")) { type = IF_SCSI; max_devs = MAX_SCSI_DEVS; } else if (!strcmp(buf, "floppy")) { type = IF_FLOPPY; max_devs = 0; } else if (!strcmp(buf, "pflash")) { type = IF_PFLASH; max_devs = 0; } else if (!strcmp(buf, "mtd")) { type = IF_MTD; max_devs = 0; } else if (!strcmp(buf, "sd")) { type = IF_SD; max_devs = 0; } else if (!strcmp(buf, "virtio")) { type = IF_VIRTIO; max_devs = 0; } else if (!strcmp(buf, "xen")) { type = IF_XEN; max_devs = 0; } else if (!strcmp(buf, "none")) { type = IF_NONE; max_devs = 0; } else { fprintf(stderr, "qemu: unsupported bus type '%s'\n", buf); return NULL; } } if (cyls || heads || secs) { if (cyls < 1 || (type == IF_IDE && cyls > 16383)) { fprintf(stderr, "qemu: '%s' invalid physical cyls number\n", buf); return NULL; } if (heads < 1 || (type == IF_IDE && heads > 16)) { fprintf(stderr, "qemu: '%s' invalid physical heads number\n", buf); return NULL; } if (secs < 1 || (type == IF_IDE && secs > 63)) { fprintf(stderr, "qemu: '%s' invalid physical secs number\n", buf); return NULL; } } if ((buf = qemu_opt_get(opts, "trans")) != NULL) { if (!cyls) { fprintf(stderr, "qemu: '%s' trans must be used with cyls,heads and secs\n", buf); return NULL; } if (!strcmp(buf, "none")) translation = BIOS_ATA_TRANSLATION_NONE; else if (!strcmp(buf, "lba")) translation = BIOS_ATA_TRANSLATION_LBA; else if (!strcmp(buf, "auto")) translation = BIOS_ATA_TRANSLATION_AUTO; else { fprintf(stderr, "qemu: '%s' invalid translation type\n", buf); return NULL; } } if ((buf = qemu_opt_get(opts, "media")) != NULL) { if (!strcmp(buf, "disk")) { media = MEDIA_DISK; } else if (!strcmp(buf, "cdrom")) { if (cyls || secs || heads) { fprintf(stderr, "qemu: '%s' invalid physical CHS format\n", buf); return NULL; } media = MEDIA_CDROM; } else { fprintf(stderr, "qemu: '%s' invalid media\n", buf); return NULL; } } if ((buf = qemu_opt_get(opts, "cache")) != NULL) { if (!strcmp(buf, "off") || !strcmp(buf, "none")) { bdrv_flags |= BDRV_O_NOCACHE; } else if (!strcmp(buf, "writeback")) { } else if (!strcmp(buf, "writethrough")) { } else { fprintf(stderr, "qemu: invalid cache option\n"); return NULL; } } #ifdef CONFIG_LINUX_AIO if ((buf = qemu_opt_get(opts, "aio")) != NULL) { if (!strcmp(buf, "native")) { bdrv_flags |= BDRV_O_NATIVE_AIO; } else if (!strcmp(buf, "threads")) { } else { fprintf(stderr, "qemu: invalid aio option\n"); return NULL; } } #endif if ((buf = qemu_opt_get(opts, "format")) != NULL) { if (strcmp(buf, "?") == 0) { fprintf(stderr, "qemu: Supported formats:"); bdrv_iterate_format(bdrv_format_print, NULL); fprintf(stderr, "\n"); return NULL; } drv = bdrv_find_whitelisted_format(buf); if (!drv) { fprintf(stderr, "qemu: '%s' invalid format\n", buf); return NULL; } } on_write_error = BLOCK_ERR_STOP_ENOSPC; if ((buf = qemu_opt_get(opts, "werror")) != NULL) { if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO) { fprintf(stderr, "werror is no supported by this format\n"); return NULL; } on_write_error = parse_block_error_action(buf, 0); if (on_write_error < 0) { return NULL; } } on_read_error = BLOCK_ERR_REPORT; if ((buf = qemu_opt_get(opts, "rerror")) != NULL) { if (type != IF_IDE && type != IF_VIRTIO) { fprintf(stderr, "rerror is no supported by this format\n"); return NULL; } on_read_error = parse_block_error_action(buf, 1); if (on_read_error < 0) { return NULL; } } if ((devaddr = qemu_opt_get(opts, "addr")) != NULL) { if (type != IF_VIRTIO) { fprintf(stderr, "addr is not supported\n"); return NULL; } } if (index != -1) { if (bus_id != 0 || unit_id != -1) { fprintf(stderr, "qemu: index cannot be used with bus and unit\n"); return NULL; } if (max_devs == 0) { unit_id = index; bus_id = 0; } else { unit_id = index % max_devs; bus_id = index / max_devs; } } if (unit_id == -1) { unit_id = 0; while (drive_get(type, bus_id, unit_id) != NULL) { unit_id++; if (max_devs && unit_id >= max_devs) { unit_id -= max_devs; bus_id++; } } } if (max_devs && unit_id >= max_devs) { fprintf(stderr, "qemu: unit %d too big (max is %d)\n", unit_id, max_devs - 1); return NULL; } if (drive_get(type, bus_id, unit_id) != NULL) { *fatal_error = 0; return NULL; } dinfo = qemu_mallocz(sizeof(*dinfo)); if ((buf = qemu_opts_id(opts)) != NULL) { dinfo->id = qemu_strdup(buf); } else { dinfo->id = qemu_mallocz(32); if (type == IF_IDE || type == IF_SCSI) mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd"; if (max_devs) snprintf(dinfo->id, 32, "%s%i%s%i", devname, bus_id, mediastr, unit_id); else snprintf(dinfo->id, 32, "%s%s%i", devname, mediastr, unit_id); } dinfo->bdrv = bdrv_new(dinfo->id); dinfo->devaddr = devaddr; dinfo->type = type; dinfo->bus = bus_id; dinfo->unit = unit_id; dinfo->on_read_error = on_read_error; dinfo->on_write_error = on_write_error; dinfo->opts = opts; if (serial) strncpy(dinfo->serial, serial, sizeof(serial)); QTAILQ_INSERT_TAIL(&drives, dinfo, next); switch(type) { case IF_IDE: case IF_SCSI: case IF_XEN: case IF_NONE: switch(media) { case MEDIA_DISK: if (cyls != 0) { bdrv_set_geometry_hint(dinfo->bdrv, cyls, heads, secs); bdrv_set_translation_hint(dinfo->bdrv, translation); } break; case MEDIA_CDROM: bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_CDROM); break; } break; case IF_SD: case IF_FLOPPY: bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_FLOPPY); break; case IF_PFLASH: case IF_MTD: break; case IF_VIRTIO: opts = qemu_opts_create(&qemu_device_opts, NULL, 0); qemu_opt_set(opts, "driver", "virtio-blk-pci"); qemu_opt_set(opts, "drive", dinfo->id); if (devaddr) qemu_opt_set(opts, "addr", devaddr); break; case IF_COUNT: abort(); } if (!file) { *fatal_error = 0; return NULL; } if (snapshot) { bdrv_flags &= ~BDRV_O_CACHE_MASK; bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB); } if (media == MEDIA_CDROM) { ro = 1; } else if (ro == 1) { if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY) { fprintf(stderr, "qemu: readonly flag not supported for drive with this interface\n"); return NULL; } } bdrv_flags |= ro ? 0 : BDRV_O_RDWR; if (bdrv_open(dinfo->bdrv, file, bdrv_flags, drv) < 0) { fprintf(stderr, "qemu: could not open disk image %s: %s\n", file, strerror(errno)); return NULL; } if (bdrv_key_required(dinfo->bdrv)) autostart = 0; *fatal_error = 0; return dinfo; }
1threat
Do UML drawing a valid cafeteria system attached : I need help I've written the script to make a cafeteria system at college. I drew the painting but I want to check the authenticity of the painting, especially the shares of the operations The student selects one of the restaurants available in the cafeteria. The student selects the item you want with the possibility of adding some ingredients to the item and receive the sellers. The student pays to the seller. The delivery of a request is included, an update to the store at the moment the student is paid. The seller's issue the invoice to the student and includes an addition to the account of exports and imports of the restaurant. Administrator for the restaurant When you want to add new item, the sellers are notified of the new item added. Administrator records attendance and absence of sellers. thank you [enter image description here][1] [1]: https://i.stack.imgur.com/DaRQ6.jpg
0debug
Target Social Sharing Button (Facebook, Twitter, LinkedIn) Groups Using CSS : Just joined the community, and am really itching to find an answer to my problem. I currently am styling my social sharing buttons using groupings (all Facebook buttons have a set style, all Twitter buttons do, etc.). Currently, I achieve this using a massive grouping of YUI's for each button type - this makes creating new sharing buttons extremely tedious, as I have to inspect each button to find its ID. Ideally, I'd like to target each button type using their respective classes to REALLY consolidate the amount of code I have written (and make future additions much more efficient). I've tried everything I could think of, but nothing seems to work. Can anyone help find a solution to this? I'm definitely no pro at this stuff! For reference, my website is: www.tylercharboneauprofessional.com I'm currently working on the Squarespace platform. Thanks a million! Tyler
0debug
void checkasm_check_vf_threshold(void) { check_threshold_8(); report("threshold8"); }
1threat
def sum_Pairs(arr,n): sum = 0 for i in range(n - 1,-1,-1): sum += i*arr[i] - (n-1-i) * arr[i] return sum
0debug
Regex for a sentence boundary : <p>I am trying to write down a regex expression for sentence extraction in a piece of text. In my definition, sentence starts with capital letter <code>[A-Z]</code> and ends with <code>.|!|?</code>. However, that is not all. Before the sentence start there should be a dot '.', question mark '?', exclamation mark '!', white space or beginning of string. Also, after the end of sentence, there should be white space (or not) followed by capital letters or end of string. </p> <p>These rules are here to exclude the following false sentences</p> <blockquote> <pre><code>Maria has cat etc. my dog. (one sentence not two!) https://i-am-cat-and-dog/Explain-what-you-are-doing. (not a sentence) Cats Dogs Cars (not a sentence) </code></pre> </blockquote>
0debug