problem
stringlengths
26
131k
labels
class label
2 classes
How to subtract military time in JavaScript/JQuery? : I have two time values that should subtract and output the difference in hours. For example I get the values in this format: 0530-2400 That value is string, I guess that converting to JavaScript date object is the first step. Here is what I have so far: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> var time = "0530-2400", arr = []; arr = time.split('-'); var dateObj = new Date(), hours1 = dateObj.setHours(Number(arr[0].substring(0, 2))), hours2 = dateObj.setHourse(Number(arr[1].substring(0, 2))), minutes1 = dateObj.setMinutes(Number(arr[0].substring(2, 4))), minutes2 = dateObj.setMinutes(Number(arr[1].substring(2, 4))); console.log(hours1); console.log(minutes1); console.log(hours2); console.log(minutes2); <!-- end snippet --> The output for the time I showed above should be `18.5` hours. If we subtract `24-5.5(530) = 18.5` The increments are always on `15,30 or 45` minutes. Is there a good way to convert string and then do the math in JS?
0debug
Ordering multi-dimensional Array in Python : Lets say I have a multidimensional array [A][B][C], and I want to order the array with respect to a, ofcourse the relationship of the values of B and C which corresponded to their neighbouring A needs to be maintained... Also assuming we have multiple A's with the same value, how do we order the B's so that we have A ordered primarily then B ordered if its possible. Something like ` (1,2,3) (1,3,7) (1,4,5) (1,5,2) (2,3,5) (2,4,9) (2,5,0) ...`
0debug
Javascript Json Search and get all possible node : I have a multi dimensional json. I need to search a string in each node and need to return an array of nodes contains the string
0debug
How to initialize an Int from a map Value, C++ : <p>I have a large global map in a header of weapon names and ID numbers from a video game . I am trying to find a way that I can take user input for the name and return the item number. For this I created a new int and would like to initialize it with the map value after searching for the name. What is the best way to do this?</p> <pre><code>//header #include &lt;map&gt; #include &lt;string&gt; using namespace std; typedef std:: map &lt;std :: string, int&gt; weaponMap; inline weaponMap &amp; globalMap() { static weaponMap theMap; static bool firstTime = true; if (firstTime) { firstTime = false; theMap["weaponOne"] = 854000; } } //Source.cpp #includes "globalMap" int swapWeapon = weaponMap::["weaponOne"]; cout &lt;&lt; swapWeapon; </code></pre>
0debug
How to use the onkeyup event to a TextField in Extjs 3 : I want to use onkeyup event of text field, so we can count that character when enter the text. Thanks in advanced !
0debug
Build error - targeted OS version does not support use of thread local variables : <p>What does the below error means? I've never seen this before.</p> <blockquote> <p>d: targeted OS version does not support use of thread local variables in __ZN12base_logging10LogMessage5FlushEv for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)</p> </blockquote> <p>I'm using cocoapod for google cast sdk and building in Xcode 10 beta and xcode 9.4.</p>
0debug
We need to rename highlighted tabs in Bitrix 24 self hosted due to business requirement. : We need to rename highlighted tabs in Bitrix 24 self hosted due to business requirement. Location: CRM>Quotes Requirement: <br> 1) Exact steps to edit/rename fields<br> 2) If possible, screenshot would be more helpful<br> 3) Location of lebels in Control Panel.<br> Please advice.<br> Thanks,
0debug
How to get real root url in PHP (without framework) : <p>I have 3 app in one public_html folder:</p> <ul> <li>/public_html/myapp_1</li> <li>/public_html/subfolder/myapp_2</li> <li>/public_html/subfolder3/small/myapp_3</li> </ul> <p>when I run myapp_1 as sample.dev => So I got root url: sample.dev</p> <p>when I run myapp_2 as sample.dev/subfolder => So I also got root url: sample.dev</p> <p>when I run myapp_3 as sample.dev/subfolder3/small => I also got root url: sample.dev</p> <p>But, I want to get:</p> <ul> <li>url of myapp_2 as "sample.dev/subfolder"</li> <li>url of myapp_3 as "sample.dev/subfolder/small".</li> </ul> <p>This active will auto get with real container folder (not fixed)</p> <p>Because I have a common function as:</p> <p>function getFullAssetUrl('style.css');</p> <p>This function will return:</p> <ul> <li><p>With myapp_1 => sample.dev/style.css</p></li> <li><p>With myapp_2 => sample.dev/subfolder/style.css</p></li> <li><p>With myapp_3 => sample.dev/subfolder3/small/style.css</p></li> </ul>
0debug
Save Time (NSDate) in NSUserDefaults [Swift 2] : please excuse my bad english skills. I am trying to save the time once the "user" reachs the Limit. So the limit is 10 for example and once he reachs this limit, i want to save the current time. Then he has to wait 1 hour to continue playing. I started doing this, but I already get an error, when I try this: var CurrentTime = NSDate() CurrentTime = NSUserDefaults.standardUserDefaults() Error: Cannot assign value of type 'NSUserDefaults' to type 'NSDate' It seems like swift cannot save a 'NSDate' as a 'NSUserDefault'. I would be happy if you could help me out :)
0debug
Argument of type 'HTMLElement' is not assignable to parameter of type 'CanvasImageSource' : <p>I am trying to get the same image to load into all of the canvas in my HTML. I had previously written my whole webpage in javascript but now I am learning angular and typescript.</p> <p>I am getting this error highlighted in Visual Studio Code:</p> <blockquote> <p>Argument of type 'HTMLElement' is not assignable to parameter of type 'CanvasImageSource'. Type 'HTMLElement' is missing the following properties from type 'HTMLVideoElement': height, msHorizontalMirror, msIsLayoutOptimalForPlayback, msIsStereo3D, and 80 more.ts(2345)</p> </blockquote> <p>But I get no error shown in the console. I can get the image to load on the HTML within the canvas (so it is working).</p> <p>This is my ts:</p> <pre><code>import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-map', templateUrl: './map.component.html', styleUrls: ['./map.component.scss'] }) export class MapComponent implements OnInit { constructor() { } ngOnInit() { document.querySelectorAll("canvas").forEach(c=&gt;{ var ctx = c.getContext("2d"); var img = document.getElementById("P43"); ctx.drawImage(img,0,0,106,50); //(image, offsetx, offsety, x, y) }); } } </code></pre> <p>VS Code highlights the error on this line <code>ctx.drawImage(img,0,0,106,50); //(image, offsetx, offsety, x, y)</code>, it highlights <strong>img</strong> and displays the error.</p> <p>I have tried to search this but the only solutions I have found are for when you had the ID for tag ( I don't as it is all canvas' on the page.) or if there is an input.</p> <p>Any help is appreciated.</p>
0debug
static uint32_t slavio_led_mem_reads(void *opaque, target_phys_addr_t addr) { MiscState *s = opaque; uint32_t ret = 0, saddr; saddr = addr & LED_MAXADDR; switch (saddr) { case 0: ret = s->leds; break; default: break; } MISC_DPRINTF("Read diagnostic LED reg 0x" TARGET_FMT_plx " = %x\n", addr, ret); return ret; }
1threat
Multithreading in professional projects : <p>To better understand concurrent computing, I would like to know the exact examples of multithreading in projects. Could you list some examples that you came across and describe what responsibilities each thread has?</p> <p>Please be patient. I'm still learning. :-)</p>
0debug
How to display the 5 images in UIImageview on one button click in iOS? : I have one UIImageview and one Button and one NSAarray .I have assigned 5 images to that array.Now my question is when we click the button first image should be displayed and if we click the that button second image should be displayed like that 5 images should be displayed .Thanks Sir
0debug
-> What does this mean in php? $blabla->blabla : <p>$blabla->blab, just wondering what this means something to do with an object going into another? </p> <p>Sorry for being a bit vague . </p>
0debug
my toggle button navgar not responding : When I click in the small size toggle button it doesn't work and doesn't respond. What seems to be the problem here could anyone tell me please? i try some solution ,its not working with me, here is the full code <html> <head> <link rel="stylesheet" href="bootstrap-4.0.0-alpha.6-dist/css/bootstrap.min.css" type="text/css"> </head> <body style="background-color:darkslategrey"> <!--navbar--> <nav class="navbar navbar-toggleable navbar-light bg-faded"> <!--intro navbar--> <button type="button" class="navbar-toggler navbar-toggler-icon navbar-toggler-right collapsed" data-toggle="collapse" data-target="#menu"><!--responsive collapse menu--></button> <span class="navbar-brand-icon">Bootstrap</span> <!--navbar logo--> <div class="collapse navbar-collapse" id="menu"> <!--in the item--> <ul class="nav navbar-nav"> <li class="nav-item active"><a href="" class="nav-link">Home</a></li> <li class="nav-item"><a href="" class="nav-link">About us</a></li> <li class="nav-item"><a href="" class="nav-link">Services</a></li> </ul> </div> </nav> <!--header--> <div class="container"> <div clss="header-page"> <div class="lead"> <h1>Welcome in Helper Classes</h1> </div> <hr> <script src="bootstrap-4.0.0-alpha.6-dist/js/bootstrap.min.js" type="text/javascript"></script> <script src="jquery.js" type="text/javascript"></script> </body> </html>
0debug
static inline void gen_evfsabs(DisasContext *ctx) { if (unlikely(!ctx->spe_enabled)) { gen_exception(ctx, POWERPC_EXCP_APU); return; } #if defined(TARGET_PPC64) tcg_gen_andi_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], ~0x8000000080000000LL); #else tcg_gen_andi_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], ~0x80000000); tcg_gen_andi_tl(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)], ~0x80000000); #endif }
1threat
How to log query String of a SQL statement if it fails to commit? : <p>Sometimes for any reason statement fails to commit to DB correctly. For example if the connection is closed statement.execute() fails. Does anyone know how to log the statement, in order to identify and log which query string failed to commit successfully?</p>
0debug
Steam OpenID Authentication on Laravel : <p>On the last weeks, I'm trying to implement a OpenID authentication on my laravel's website, but without success. I can't use <a href="https://github.com/laravel/socialite" rel="noreferrer">laravel/socialite</a> because the package doesn't support steam and think not support OpenID auths too. </p> <p>Then, I found the community driven <a href="https://socialiteproviders.github.io/" rel="noreferrer">project</a> for custom socialite adapters. But the adapters are a mess and uses obsolete dependencies.</p> <p>A answer will help a lot of people. Help us :c </p>
0debug
static void sd_cardchange(void *opaque, bool load) { SDState *sd = opaque; qemu_set_irq(sd->inserted_cb, blk_is_inserted(sd->blk)); if (blk_is_inserted(sd->blk)) { sd_reset(DEVICE(sd)); qemu_set_irq(sd->readonly_cb, sd->wp_switch); } }
1threat
What is the most convenient way to read from console in Java? : <p>I like to read from a console in Java. What is the most convenient way to do it for the sake of the processing of the input? For example I want to read a single char or an integer.</p>
0debug
void hmp_savevm(Monitor *mon, const QDict *qdict) { BlockDriverState *bs, *bs1; QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1; int ret; QEMUFile *f; int saved_vm_running; uint64_t vm_state_size; qemu_timeval tv; struct tm tm; const char *name = qdict_get_try_str(qdict, "name"); Error *local_err = NULL; AioContext *aio_context; if (!bdrv_all_can_snapshot(&bs)) { monitor_printf(mon, "Device '%s' is writable but does not " "support snapshots.\n", bdrv_get_device_name(bs)); return; } if (name && bdrv_all_delete_snapshot(name, &bs1, &local_err) < 0) { error_reportf_err(local_err, "Error while deleting snapshot on device '%s': ", bdrv_get_device_name(bs1)); return; } bs = bdrv_all_find_vmstate_bs(); if (bs == NULL) { monitor_printf(mon, "No block device can accept snapshots\n"); return; } aio_context = bdrv_get_aio_context(bs); saved_vm_running = runstate_is_running(); ret = global_state_store(); if (ret) { monitor_printf(mon, "Error saving global state\n"); return; } vm_stop(RUN_STATE_SAVE_VM); aio_context_acquire(aio_context); memset(sn, 0, sizeof(*sn)); qemu_gettimeofday(&tv); sn->date_sec = tv.tv_sec; sn->date_nsec = tv.tv_usec * 1000; sn->vm_clock_nsec = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); if (name) { ret = bdrv_snapshot_find(bs, old_sn, name); if (ret >= 0) { pstrcpy(sn->name, sizeof(sn->name), old_sn->name); pstrcpy(sn->id_str, sizeof(sn->id_str), old_sn->id_str); } else { pstrcpy(sn->name, sizeof(sn->name), name); } } else { localtime_r((const time_t *)&tv.tv_sec, &tm); strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", &tm); } f = qemu_fopen_bdrv(bs, 1); if (!f) { monitor_printf(mon, "Could not open VM state file\n"); goto the_end; } ret = qemu_savevm_state(f, &local_err); vm_state_size = qemu_ftell(f); qemu_fclose(f); if (ret < 0) { error_report_err(local_err); goto the_end; } ret = bdrv_all_create_snapshot(sn, bs, vm_state_size, &bs); if (ret < 0) { monitor_printf(mon, "Error while creating snapshot on '%s'\n", bdrv_get_device_name(bs)); } the_end: aio_context_release(aio_context); if (saved_vm_running) { vm_start(); } }
1threat
How to generate a whole number between 0-2? : <p>Ok so this is the code:</p> <pre><code> var i = prompt('Rock, Paper or scissors?'); var b = ['Rock', 'Paper', 'Scissors']; </code></pre> <p>Now, I need to generate (Correct me if I'm wrong please) a number between 0-2. My idea is (Well, was) this:</p> <pre><code>var i = prompt('Rock, Paper or scissors?'); var b = ['Rock', 'Paper', 'Scissors']; document.write(Math.random(0, 2)); var c = //the code I can't figure out document.write(b[c]); </code></pre> <p>Any thoughts?</p>
0debug
void cpu_register_physical_memory_offset(target_phys_addr_t start_addr, ram_addr_t size, ram_addr_t phys_offset, ram_addr_t region_offset) { target_phys_addr_t addr, end_addr; PhysPageDesc *p; CPUState *env; ram_addr_t orig_size = size; void *subpage; #ifdef CONFIG_KQEMU env = first_cpu; if (env->kqemu_enabled) { kqemu_set_phys_mem(start_addr, size, phys_offset); } #endif if (kvm_enabled()) kvm_set_phys_mem(start_addr, size, phys_offset); if (phys_offset == IO_MEM_UNASSIGNED) { region_offset = start_addr; } region_offset &= TARGET_PAGE_MASK; size = (size + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK; end_addr = start_addr + (target_phys_addr_t)size; for(addr = start_addr; addr != end_addr; addr += TARGET_PAGE_SIZE) { p = phys_page_find(addr >> TARGET_PAGE_BITS); if (p && p->phys_offset != IO_MEM_UNASSIGNED) { ram_addr_t orig_memory = p->phys_offset; target_phys_addr_t start_addr2, end_addr2; int need_subpage = 0; CHECK_SUBPAGE(addr, start_addr, start_addr2, end_addr, end_addr2, need_subpage); if (need_subpage || phys_offset & IO_MEM_SUBWIDTH) { if (!(orig_memory & IO_MEM_SUBPAGE)) { subpage = subpage_init((addr & TARGET_PAGE_MASK), &p->phys_offset, orig_memory, p->region_offset); } else { subpage = io_mem_opaque[(orig_memory & ~TARGET_PAGE_MASK) >> IO_MEM_SHIFT]; } subpage_register(subpage, start_addr2, end_addr2, phys_offset, region_offset); p->region_offset = 0; } else { p->phys_offset = phys_offset; if ((phys_offset & ~TARGET_PAGE_MASK) <= IO_MEM_ROM || (phys_offset & IO_MEM_ROMD)) phys_offset += TARGET_PAGE_SIZE; } } else { p = phys_page_find_alloc(addr >> TARGET_PAGE_BITS, 1); p->phys_offset = phys_offset; p->region_offset = region_offset; if ((phys_offset & ~TARGET_PAGE_MASK) <= IO_MEM_ROM || (phys_offset & IO_MEM_ROMD)) { phys_offset += TARGET_PAGE_SIZE; } else { target_phys_addr_t start_addr2, end_addr2; int need_subpage = 0; CHECK_SUBPAGE(addr, start_addr, start_addr2, end_addr, end_addr2, need_subpage); if (need_subpage || phys_offset & IO_MEM_SUBWIDTH) { subpage = subpage_init((addr & TARGET_PAGE_MASK), &p->phys_offset, IO_MEM_UNASSIGNED, addr & TARGET_PAGE_MASK); subpage_register(subpage, start_addr2, end_addr2, phys_offset, region_offset); p->region_offset = 0; } } } region_offset += TARGET_PAGE_SIZE; } for(env = first_cpu; env != NULL; env = env->next_cpu) { tlb_flush(env, 1); } }
1threat
C# Protect software : <p>I protect my software this way:</p> <ol> <li>Compare HDD and CPU serials with stored ones (I store them encrypted in program user settings)</li> <li>All data stored in DB encrypted by DES. DES key and IV I store in windows registry.</li> </ol> <p>I understand what this way protection is weak and store key and IV in registry not a good idea. Please give me some advice to improve this protection.</p>
0debug
how can i Disable button fo 30 Seconds in c# : I am New in C# i Want a button to disable for 30 second after click and enable it automatically and i found it here but the change is not in live time i want to get it like count down from 30 to 0 and i cant make it ? and i cant comment in the main topic cause i am new in this website Need 50 reputation System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); // event handler of your button private void button1_Click(object sender, EventArgs e) { timer.Interval = 30000; // here time in milliseconds timer.Tick += timer_Tick; timer.Start(); button1.Enabled = false; // place get random code here } void timer_Tick(object sender, System.EventArgs e) { button1.Enabled = true; timer.Stop(); }
0debug
Select 3 items or 4 items out of 8 items : I am trying to get 3 or 4 items out of an array of 8 numbers (1-8). If i try to print the array of the 3 or 4 items. Most of the trys it worked but some times I only get some numbers and a 0 which isn't in the array. Like this [2, 5, 3, 0]. private int[] randomPeople() { int[] result = {0, 0, 0, 0}; int[] arr = {1, 2, 3, 4, 5, 6, 7, 8}; return getRandomPeople(result, arr); } private int[] getRandomPeople(int[] result, int[] arr) { int number; for (int i = 0; i < result.length; i++) { number = (int) (Math.random() * arr.length + 1); for (int j = 0; j < result.length; j++) { if (number == result[j]) { //check if the random number is already in the list --> new random int j = 0; number = (int) (Math.random() * arr.length + 1); } } for (int j = 0; j < arr.length; j++) { // adds the number to the new array and delete it in the old if (number == arr[j]) { result[i] = number; arr = searchDelete(arr, number); } } } System.out.println(Arrays.toString(result)); return result; } This method is for deleting the searched ID. You have to hand over an array and the int which should be deleted. private int[] searchDelete(int[] arr, int SRID) { int pos; for (pos = 0; pos < arr.length - 1; pos++) { if (arr[pos] == SRID) break; } while (pos < arr.length - 1) { arr[pos] = arr[pos + 1]; pos++; } int[] arr2 = new int[arr.length - 1]; System.arraycopy(arr, 0, arr2, 0, arr.length - 1); return arr2; }
0debug
Where has 'django.core.context_processors.request' gone in Django 1.10? : <p>I used to use <code>django.core.context_processors.request</code> to get the <code>request</code> for a view in template without having to pass them in.</p> <p>However, this is no longer in Django 1.10.</p> <p>How to I access the request context processor in Django 1.10?</p>
0debug
static void gen_tlbre_40x(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); #else if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } switch (rB(ctx->opcode)) { case 0: gen_helper_4xx_tlbre_hi(cpu_gpr[rD(ctx->opcode)], cpu_env, cpu_gpr[rA(ctx->opcode)]); break; case 1: gen_helper_4xx_tlbre_lo(cpu_gpr[rD(ctx->opcode)], cpu_env, cpu_gpr[rA(ctx->opcode)]); break; default: gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); break; } #endif }
1threat
how to use chrome options is protractor framework? : I want to use this code in protractor framework `setPageLoadStrategy(org.openqa.selenium.PageLoadStrategy.NONE);` `setExperimentalOption("debuggerAddress", "127.0.0.1:12633");` Please help me in that.
0debug
Swift - "fatal error: unexpectedly found nil while unwrapping an Optional value" when trying to retrieve coordinates from Firebase : <p>I have this error in my project. I get this error when I'm running the app. That I want to do Is show the position on the map bases on the coordinates that I have in my Firebase Database. But I get this error: fatal error: unexpectedly found nil while unwrapping an Optional value. I have googled around a bit but I don't find anything that would help me... And I'm pretty new in Swift and Xcode!</p> <p>Here is my Firebase Database: </p> <p><a href="http://i.stack.imgur.com/s7Qem.png" rel="nofollow">Firebase Database</a></p> <p>And here Is my code: </p> <pre><code>class FeedCell: UICollectionViewCell, UICollectionViewDelegateFlowLayout, CLLocationManagerDelegate, MKMapViewDelegate { let users = [User]() var positions = [Position]() var wiindow: UIWindow? var mapView: MKMapView? let locationManager = CLLocationManager() let distanceSpan: Double = 500 var locationData: CLLocation! override init(frame: CGRect) { super.init(frame: frame) setupViews() } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } let nameLabel: UILabel = { let label = UILabel() label.font = UIFont.boldSystemFontOfSize(14) label.translatesAutoresizingMaskIntoConstraints = false return label }() let profileImageView: UIImageView = { let imageView = UIImageView() imageView.translatesAutoresizingMaskIntoConstraints = false imageView.layer.cornerRadius = 22 imageView.layer.masksToBounds = true imageView.backgroundColor = UIColor.blueColor() return imageView }() let separatorView: UIView = { let view = UIView() view.backgroundColor = UIColor(red: 192/255, green: 192/255, blue: 192/255, alpha: 1) view.translatesAutoresizingMaskIntoConstraints = false return view }() func setupViews() { addSubview(profileImageView) addSubview(nameLabel) addSubview(separatorView) addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-10-[v0(44)]-10-[v1]|", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": profileImageView, "v1": nameLabel])) addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-10-[v0(44)]", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": profileImageView])) addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[v0]-385-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": nameLabel])) addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[v0]|", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": separatorView])) addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:[v0(1)]|", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": separatorView])) self.wiindow = UIWindow(frame: UIScreen.mainScreen().bounds) self.backgroundColor = UIColor(white: 0.95, alpha: 1) self.mapView = MKMapView(frame: CGRectMake(0, 70, (self.wiindow?.frame.width)!, 355)) self.addSubview(self.mapView!) self.locationManager.delegate = self self.locationManager.desiredAccuracy = kCLLocationAccuracyBest self.locationManager.requestWhenInUseAuthorization() self.locationManager.startUpdatingLocation() self.mapView!.showsUserLocation = true self.mapView!.zoomEnabled = false self.mapView!.scrollEnabled = false self.mapView!.userInteractionEnabled = false } func locationManager(manager: CLLocationManager, didUpdateToLocation newLocation: CLLocation, fromLocation oldLocation: CLLocation) { if let mapView = self.mapView { let region = MKCoordinateRegionMakeWithDistance(newLocation.coordinate, self.distanceSpan, self.distanceSpan) mapView.setRegion(region, animated: true) mapView.showsUserLocation = true } } func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { FIRDatabase.database().reference().child("position").queryOrderedByChild("fromId").queryEqualToValue(FIRAuth.auth()!.currentUser!.uid).observeSingleEventOfType(.Value, withBlock: {(locationSnap) in if let locationDict = locationSnap.value as? [String:AnyObject]{ self.locationData = locations.last let lat = locationDict["latitude"] as! CLLocationDegrees //Here do I get the "Thread 1 EXC BAD INSTRUCTION" let long = locationDict["longitude"] as! CLLocationDegrees let center = CLLocationCoordinate2D(latitude: lat, longitude: long) let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01)) self.mapView!.setRegion(region, animated: true) self.locationManager.stopUpdatingLocation() } }) } } </code></pre>
0debug
Como realizar um insert em uma tabela utilizando um parâmetro fixo e um parâmetro "dinâmico" (resultado de um SELECT)) : Preciso fazer um INSERT populando dois campos de uma tabela, onde um parâmetro sempre irá ter o mesmo valor, e o outro parâmetro será resultado de um SELECT. Segue abaixo a QUERY que elaborei: INSERT INTO tabelaAlvo (cdCodigo, cdItem) VALUES (8, (SELECT cdItem FROM outraTabela WHERE cdXxx IN (27) AND cdYyy IN ( 3, 16, 63, 121, 256, 257, 258, 259, 260, 261, 262, 263, 264))) O primeiro atributo sempre deverá ser preenchido com o valor = 8, enquanto o segundo atributo deverá ser preenchido com o resultado do SELECT. Poderiam me ajudar, por gentileza? Tentei localizar alguma pergunta semelhante, mas não encontrei.
0debug
"Define is not defined" in Jest when testing es6 module with RequireJS dependency : <p>I have a Jest test suite that fails to run because the component it's trying to test depends on a RequireJS module. Here's the error I'm seeing:</p> <pre><code> FAIL __tests__/components/MyComponent.test.js ● Test suite failed to run ReferenceError: define is not defined at Object.&lt;anonymous&gt; (node_modules/private-npm-module/utils.js:1:90) </code></pre> <p>The component has the following import:</p> <pre><code>import utils from 'private-npm-module'; </code></pre> <p>And the <code>private-npm-module</code> is set up like so:</p> <pre><code>define('utils', [], function() { return {}; }); </code></pre> <p>When <code>MyComponent</code> is transpiled with babel and run in the browser, the dependency operates correctly. This issue only affects the unit test. How can I get my test suite to run on a component with a RequireJS dependency?</p> <p>I'm using <code>babel-jest</code> as my <code>scriptPreprocessor</code> in package.json's jest config. I'm using jest v0.15.1.</p>
0debug
void virtio_scsi_dataplane_stop(VirtIOSCSI *s) { BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s))); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); VirtIODevice *vdev = VIRTIO_DEVICE(s); VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s); int i; if (!s->dataplane_started || s->dataplane_stopping) { return; } error_free(s->blocker); s->blocker = NULL; s->dataplane_stopping = true; assert(s->ctx == iothread_get_aio_context(vs->conf.iothread)); aio_context_acquire(s->ctx); aio_set_event_notifier(s->ctx, &s->ctrl_vring->host_notifier, NULL); aio_set_event_notifier(s->ctx, &s->event_vring->host_notifier, NULL); for (i = 0; i < vs->conf.num_queues; i++) { aio_set_event_notifier(s->ctx, &s->cmd_vrings[i]->host_notifier, NULL); } blk_drain_all(); aio_context_release(s->ctx); vring_teardown(&s->ctrl_vring->vring, vdev, 0); vring_teardown(&s->event_vring->vring, vdev, 1); for (i = 0; i < vs->conf.num_queues; i++) { vring_teardown(&s->cmd_vrings[i]->vring, vdev, 2 + i); } for (i = 0; i < vs->conf.num_queues + 2; i++) { k->set_host_notifier(qbus->parent, i, false); } k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false); s->dataplane_stopping = false; s->dataplane_started = false; }
1threat
I want to create a sql query for calculating the running total for each customer on a daily basis : I want to write a sql query for calculating the running total for each customer on a daily basis . For example : CustomerID TranDate TranAmount RunningTotal ============================================== C1 8/1/17 $10 $10 =========================================== C2 8/1/17 $15 $15 ======================================== C1 8/2/17 $20 $30 ========================================== C2 8/2/17 $30 $45 ============================================= C3 8/3/17 $50 $50 ============================================ I was able to create running total If there is only 1 customer in the table but having difficulty when there are many . Thank you in advance. Please let me know if you need any further information .
0debug
I receive NULL values when trying to send Ajax Jquerry parameters in POST request - MVC CORE : so i'm a little new to MVC core. My requirement is the following: I have a "Contact.cshtml" view which contains a contact form. After the user fills the contact form and clicks the "submit" button, I want to send the entered form parameters to the controller with the Ajax Jquerry Post method, and then send feedback back to the user without refreshing the page. My Controller Method: [HttpPost] public IActionResult Contact(string name, string email, string subject, string message) { // Future code will be entered here and do some logic with the parameters // This will be replaced with a call to a partial View which contains a success message return View(); } Part of my Contact.cshtml file: <form method="post" role="form" id="contactForm"> <div class="form-group"> <label for="name">השם שלך</label> <input type="text" class="form-control" id="name"> </div> <div class="form-group"> <label for="email">כתובת מייל</label> <input type="email" class="form-control" id="email"> </div> <div class="form-group"> <label for="subject">נושא</label> <input type="text" class="form-control" id="subject"> </div> <div class="form-group"> <label for="message">הודעה</label> <textarea class="form-control" id="message" rows="3"></textarea> </div> <button type="submit" class="btn btn-theme">שלח</button> </form> @section scripts { <script> $('#contactForm').submit(function () { $.post('', { "name": $('#message').toString(), "email": $('#email').toString(), "subject": $('#subject').toString(), "message": $('#message').toString() }).done(function (response) { alert("success"); }) }); </script> } **I spent Hours on this issue, but I always, and i mean always, receive NULL values for ALL of the form fields in the controller handling method, so please help me, thanks**
0debug
static void cuda_writel (void *opaque, target_phys_addr_t addr, uint32_t value) { }
1threat
Passing an entire array from one method to another : <p>how do i pass an array from one method to another? Also in the main method, shuffled some array receive an error saying that it takes zero arguments, but what argument am i suppose to put in there? Some sample code is greatly appreciated </p> <pre><code> class Program { static void Main(string[] args) { ShuffledSomeArray(); DoSomethingWithArray(); Console.ReadLine(); } static string[] ShuffledSomeArray(string [] array) { array = new string[5] { "1", "2", "3", "4", "5" }; Random rnd = new Random(); for(int i = 4; i&gt;=0; i--) { int shuffle = rnd.Next(0, i); string rndpick = array[shuffle]; array[shuffle] = array[i]; array[i] = rndpick; Console.Write(array[i]); } } static void DoSomethingWithArray() { } } </code></pre>
0debug
C/C++ calculate length of double pointer array : I have a double pointer Array of a structure: typedef struct Position{ int x; int y; } Position; Position** array = (Position**)malloc(sizeof(Position)*10); //10 elements array[0] = (Position*)malloc(sizeof(Position)); array[0]->x = 10; array[0]->y = 5; Can I calculate the length of set array and if so, how? The normal way for arrays does not work : int length = sizeof(<array>)/sizeof(<array>[0]);
0debug
Stroustrup - Programming - Principles and Practice C++ (2nd) - TRY THIS - Sec 4.4.2.3 - For loops : The question asks: Rewrite the character value example from the previous Try this to use a for-statement. With that being said, what I wrote for the previous question was the following which runs fine as well: #include "pch.h" #include "iostream" #include "string" #include "vector" #include "algorithm" #include "cmath" using namespace std; int main() { char letter = 'a'; int i = 97; while (i < 123) { cout << letter << '\t' << i << '\n'; i = i + 1; letter = letter + 1; } Here is what I attempted for the current question: int main() { for ((int i = 97; i < 123; i = i+1; char letter = 'a'; i = i + 1, letter = letter + 1) cout << letter << '\t' << i << '\n'; } In essence what I had gathered from the example was that the difference between the two types of statements was including the control variables and statements within the parentheses of the FOR loop. What is it that I am doing wrong?
0debug
how transpose column to rows spreadsheet? : Ok so I have something like this: hello hi how are you hello how are you hello hi hi hi hello hi how how are hello you I want this column to transpose into rows like this: hello hi how are you hello how are you hello hi hi hi hello hi how how are hello you How do I achieve this?
0debug
static void v9fs_attach(void *opaque) { V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; int32_t fid, afid, n_uname; V9fsString uname, aname; V9fsFidState *fidp; size_t offset = 7; V9fsQID qid; ssize_t err; pdu_unmarshal(pdu, offset, "ddssd", &fid, &afid, &uname, &aname, &n_uname); trace_v9fs_attach(pdu->tag, pdu->id, fid, afid, uname.data, aname.data); fidp = alloc_fid(s, fid); if (fidp == NULL) { err = -EINVAL; goto out_nofid; } fidp->uid = n_uname; err = v9fs_co_name_to_path(pdu, NULL, "/", &fidp->path); if (err < 0) { err = -EINVAL; clunk_fid(s, fid); goto out; } err = fid_to_qid(pdu, fidp, &qid); if (err < 0) { err = -EINVAL; clunk_fid(s, fid); goto out; } offset += pdu_marshal(pdu, offset, "Q", &qid); err = offset; trace_v9fs_attach_return(pdu->tag, pdu->id, qid.type, qid.version, qid.path); s->root_fid = fid; error_set(&s->migration_blocker, QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION, s->ctx.fs_root, s->tag); migrate_add_blocker(s->migration_blocker); out: put_fid(pdu, fidp); out_nofid: complete_pdu(s, pdu, err); v9fs_string_free(&uname); v9fs_string_free(&aname); }
1threat
static MegasasCmd *megasas_next_frame(MegasasState *s, target_phys_addr_t frame) { MegasasCmd *cmd = NULL; int num = 0, index; cmd = megasas_lookup_frame(s, frame); if (cmd) { trace_megasas_qf_found(cmd->index, cmd->pa); return cmd; } index = s->reply_queue_head; num = 0; while (num < s->fw_cmds) { if (!s->frames[index].pa) { cmd = &s->frames[index]; break; } index = megasas_next_index(s, index, s->fw_cmds); num++; } if (!cmd) { trace_megasas_qf_failed(frame); } trace_megasas_qf_new(index, cmd); return cmd; }
1threat
static inline void IRQ_resetbit(IRQQueue *q, int n_IRQ) { reset_bit(q->queue, n_IRQ); }
1threat
How to send XML POST requests with Spring RestTemplate? : <p>Is it possible to send <code>XML</code> <code>POST</code> requests with <code>spring</code>, eg <code>RestTemplate</code>?</p> <p>I want to send the following xml to the url <code>localhost:8080/xml/availability</code></p> <pre><code>&lt;AvailReq&gt; &lt;hotelid&gt;123&lt;/hotelid&gt; &lt;/AvailReq&gt; </code></pre> <p>Also do I want to add custom http headers on each request dynamically(!).</p> <p>How could I achieve this with spring?</p>
0debug
In android, when do we need to put semicolon after curly brackets: }; : In Java, semicolon comes after curly brackets only for arrays and enum. But I found it different in Android coding. For example why there is a **;** after **}** in the following code: Thread myThread=new Thread(){ @Override public void run(){ // something } };
0debug
static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_output) { char buf[256]; int flags = (is_output ? ic->oformat->flags : ic->iformat->flags); AVStream *st = ic->streams[i]; AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0); char *separator = ic->dump_separator; char **codec_separator = av_opt_ptr(st->codec->av_class, st->codec, "dump_separator"); int use_format_separator = !*codec_separator; if (use_format_separator) *codec_separator = av_strdup(separator); avcodec_string(buf, sizeof(buf), st->codec, is_output); if (use_format_separator) av_freep(codec_separator); av_log(NULL, AV_LOG_INFO, " Stream #%d:%d", index, i); if (flags & AVFMT_SHOW_IDS) av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id); if (lang) av_log(NULL, AV_LOG_INFO, "(%s)", lang->value); av_log(NULL, AV_LOG_DEBUG, ", %d, %d/%d", st->codec_info_nb_frames, st->time_base.num, st->time_base.den); av_log(NULL, AV_LOG_INFO, ": %s", buf); if (st->sample_aspect_ratio.num && av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)) { AVRational display_aspect_ratio; av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, st->codec->width * st->sample_aspect_ratio.num, st->codec->height * st->sample_aspect_ratio.den, 1024 * 1024); av_log(NULL, AV_LOG_INFO, ", SAR %d:%d DAR %d:%d", st->sample_aspect_ratio.num, st->sample_aspect_ratio.den, display_aspect_ratio.num, display_aspect_ratio.den); } if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { int fps = st->avg_frame_rate.den && st->avg_frame_rate.num; int tbr = st->r_frame_rate.den && st->r_frame_rate.num; int tbn = st->time_base.den && st->time_base.num; int tbc = st->codec->time_base.den && st->codec->time_base.num; if (fps || tbr || tbn || tbc) av_log(NULL, AV_LOG_INFO, "%s", separator); if (fps) print_fps(av_q2d(st->avg_frame_rate), tbr || tbn || tbc ? "fps, " : "fps"); if (tbr) print_fps(av_q2d(st->r_frame_rate), tbn || tbc ? "tbr, " : "tbr"); if (tbn) print_fps(1 / av_q2d(st->time_base), tbc ? "tbn, " : "tbn"); if (tbc) print_fps(1 / av_q2d(st->codec->time_base), "tbc"); } if (st->disposition & AV_DISPOSITION_DEFAULT) av_log(NULL, AV_LOG_INFO, " (default)"); if (st->disposition & AV_DISPOSITION_DUB) av_log(NULL, AV_LOG_INFO, " (dub)"); if (st->disposition & AV_DISPOSITION_ORIGINAL) av_log(NULL, AV_LOG_INFO, " (original)"); if (st->disposition & AV_DISPOSITION_COMMENT) av_log(NULL, AV_LOG_INFO, " (comment)"); if (st->disposition & AV_DISPOSITION_LYRICS) av_log(NULL, AV_LOG_INFO, " (lyrics)"); if (st->disposition & AV_DISPOSITION_KARAOKE) av_log(NULL, AV_LOG_INFO, " (karaoke)"); if (st->disposition & AV_DISPOSITION_FORCED) av_log(NULL, AV_LOG_INFO, " (forced)"); if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED) av_log(NULL, AV_LOG_INFO, " (hearing impaired)"); if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED) av_log(NULL, AV_LOG_INFO, " (visual impaired)"); if (st->disposition & AV_DISPOSITION_CLEAN_EFFECTS) av_log(NULL, AV_LOG_INFO, " (clean effects)"); av_log(NULL, AV_LOG_INFO, "\n"); dump_metadata(NULL, st->metadata, " "); dump_sidedata(NULL, st, " "); }
1threat
void ff_put_h264_qpel8_mc03_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_vt_qrt_8w_msa(src - (stride * 2), stride, dst, stride, 8, 1); }
1threat
In C, convert 2 doubles to form one char : Hi I have these two variables in C: double predict_label = 6.0; double prob_estimates = 8.0; How do I convert these two variables in C to char and print out a string that says something like "The value for predict label is 6 and the value for probability estimates is 8."
0debug
can't install any go script in linux can any one help please : when i try to run any go script it show me this error i installed go lang step by step from this link https://www.tecmint.com/install-go-in-linux/ when i setup go script like this go get github.com/tomnomnom/waybackurls i got error like this github.com/tomnomnom/waybackurls src/github.com/tomnomnom/waybackurls/main.go:191: u.Hostname undefined (type *url.URL has no field or method Hostname)
0debug
static void gen_spr_40x (CPUPPCState *env) { spr_register(env, SPR_40x_DCCR, "DCCR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_40x_DCWR, "DCWR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_40x_ICCR, "ICCR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_BOOKE_ICBDR, "ICBDR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, SPR_NOACCESS, 0x00000000); spr_register(env, SPR_40x_SGR, "SGR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0xFFFFFFFF); spr_register(env, SPR_40x_ZPR, "ZPR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_40x_PID, "PID", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_40x_DEAR, "DEAR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_40x_ESR, "ESR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_40x_EVPR, "EVPR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_40x_SRR2, "SRR2", &spr_read_generic, &spr_write_generic, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_40x_SRR3, "SRR3", &spr_read_generic, &spr_write_generic, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_40x_PIT, "PIT", SPR_NOACCESS, SPR_NOACCESS, &spr_read_40x_pit, &spr_write_40x_pit, 0x00000000); spr_register(env, SPR_40x_TCR, "TCR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_booke_tcr, 0x00000000); spr_register(env, SPR_40x_TSR, "TSR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_booke_tsr, 0x00000000); spr_register(env, SPR_40x_DAC1, "DAC1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_40x_DAC2, "DAC2", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_40x_DBCR0, "DBCR0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_40x_dbcr0, 0x00000000); spr_register(env, SPR_40x_DBSR, "DBSR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_clear, 0x00000300); spr_register(env, SPR_40x_IAC1, "IAC1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_40x_IAC2, "IAC2", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); }
1threat
Dynamic Programming - Minimum number of coins in C : <p>I have looked through various questions on the site and I haven't managed to find anything which implements this by the following reasoning (so I hope this isn't a duplicate).</p> <p>The problem I'm trying to solve via a C program is the following:</p> <blockquote> <p>As the programmer of a vending machine controller your are required to compute the minimum number of coins that make up the required change to give back to customers. An efficient solution to this problem takes a dynamic programming approach, starting off computing the number of coins required for a 1 cent change, then for 2 cents, then for 3 cents, until reaching the required change and each time making use of the prior computed number of coins. Write a program containing the function <code>ComputeChange()</code>, that takes a list of valid coins and the required change. This program should repeatedly ask for the required change from the console and call <code>ComputeChange()</code> accordingly. It should also make use of “caching”, where any previously computed intermediate values are retained for subsequent look-up.</p> </blockquote> <p>After looking around online to find how others have solved it, I found the following example applied with pennies, nickels and dimes:</p> <p><a href="https://i.stack.imgur.com/dYlPp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dYlPp.png" alt="enter image description here"></a></p> <p>Which I tried to base my code upon. But first of all, my code isn't halting, and secondly, I'm not sure if I'm incorporating the <em>caching</em> element mentioned in the rubric above. (I'm not really sure how I need to go about that part). </p> <p>Can anyone help find the flaws in my code?</p> <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt; #include &lt;limits.h&gt; int computeChange(int[],int,int); int min(int[],int); int main(){ int cur[]={1,2,5,10,20,50,100,200}; int n = sizeof(cur)/sizeof(int); int v; printf("Enter a value in euro cents: "); scanf("%d", &amp;v); printf("The minimum number of euro coins required is %d", computeChange(cur, v, n)); return 0; } int computeChange(int cur[], int v, int n){ if(v &lt; 0) return -1; else if(v == 0) return 0; else{ int possible_mins[n], i; for(i = 0; i &lt; n; i++){ possible_mins[i]=computeChange(cur, v-cur[i], n); } return 1+min(possible_mins, n); }; } int min(int a[], int n){ int min = INT_MAX, i; for(i = 0; i &lt; n; i++){ if((i&gt;=0) &amp;&amp; (a[i]&lt; min)) min = a[i]; } return min; } </code></pre> <p>Any assistance will be greatly appreciated.</p>
0debug
send image and different data (integer,string) to server via REST API in adnroid : I am making an application and using Rest API to get and send data to server .now i want to send different type of data as image and string and integer and using POST method .So please write code for this. Thank you.
0debug
static int parse(AVCodecParserContext *ctx, AVCodecContext *avctx, const uint8_t **out_data, int *out_size, const uint8_t *data, int size) { VP9ParseContext *s = ctx->priv_data; int full_size = size; int marker; if (size <= 0) { *out_size = 0; *out_data = data; return 0; } if (s->n_frames > 0) { *out_data = data; *out_size = s->size[--s->n_frames]; parse_frame(ctx, *out_data, *out_size); return s->n_frames > 0 ? *out_size : size ; } marker = data[size - 1]; if ((marker & 0xe0) == 0xc0) { int nbytes = 1 + ((marker >> 3) & 0x3); int n_frames = 1 + (marker & 0x7), idx_sz = 2 + n_frames * nbytes; if (size >= idx_sz && data[size - idx_sz] == marker) { const uint8_t *idx = data + size + 1 - idx_sz; int first = 1; switch (nbytes) { #define case_n(a, rd) \ case a: \ while (n_frames--) { \ unsigned sz = rd; \ idx += a; \ if (sz > size) { \ s->n_frames = 0; \ *out_size = size; \ *out_data = data; \ av_log(avctx, AV_LOG_ERROR, \ "Superframe packet size too big: %u > %d\n", \ sz, size); \ return full_size; \ } \ if (first) { \ first = 0; \ *out_data = data; \ *out_size = sz; \ s->n_frames = n_frames; \ } else { \ s->size[n_frames] = sz; \ } \ data += sz; \ size -= sz; \ } \ parse_frame(ctx, *out_data, *out_size); \ return *out_size case_n(1, *idx); case_n(2, AV_RL16(idx)); case_n(3, AV_RL24(idx)); case_n(4, AV_RL32(idx)); } } } *out_data = data; *out_size = size; parse_frame(ctx, data, size); return size; }
1threat
static void quorum_aio_cb(void *opaque, int ret) { QuorumChildRequest *sacb = opaque; QuorumAIOCB *acb = sacb->parent; BDRVQuorumState *s = acb->common.bs->opaque; sacb->ret = ret; acb->count++; if (ret == 0) { acb->success_count++; } else { quorum_report_bad(acb, sacb->aiocb->bs->node_name, ret); } assert(acb->count <= s->num_children); assert(acb->success_count <= s->num_children); if (acb->count < s->num_children) { return; } if (acb->is_read) { quorum_vote(acb); } else { quorum_has_too_much_io_failed(acb); } quorum_aio_finalize(acb); }
1threat
How to Balance Quadcopter using L3G4200 and PID controll : <p>I'm in progress making a Quadcopter for my Microproccesor project in University. I have set up all the hardware and now I am stacking with Balancing Algorithm. I am very happy if anyone here who used be working on this project please Give me code of this part. By the way, I use sensor L3G4200. Thank you for reading.</p>
0debug
static CharDriverState *qemu_chr_open_null(void) { CharDriverState *chr; chr = g_malloc0(sizeof(CharDriverState)); chr->chr_write = null_chr_write; chr->explicit_be_open = true; return chr; }
1threat
Bipartity graph c++ : I have adjacency matrix and i wiil must check the graph on bipartion. I wrote some code, but he always return false value. Sorry for my English Example: INPUT 10 0 1 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 1 0 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 0 1 0 0 1 1 0 0 0 0 1 0 0 1 0 0 0 0 OUTPUT YES 1 3 6 9 #include <iostream> #include <fstream> #include <vector> #include <queue> using namespace std; bool bipartite=true; vector<vector<int>>g; vector<int>visit; vector<int>colour; int n; void dfs(int v) { visit[v] = 1; if (colour[v] == 0) { colour[v] = 1; } for (int i = 0; i < g[v].size(); i++) { if (visit[i] == 0) { if (colour[v] == 1) { colour[i] = 2; } else colour[i] = 1; dfs(i); } if (visit[i] == 1 && colour[i] == colour[v]) bipartite = false; } } int main() { ifstream fin("input.in"); ofstream fout("output.out"); int a; fin >> n; g.resize(n); visit.resize(n); colour.resize(n); for (int i = 0; i < g.size(); i++) { for (int j = 0; j < n; j++) { fin >> a; g[i].push_back(a); } } for (int i = 0; i < n; i++) { if (visit[i] == 0) dfs(i); } cout << bipartite; return 0; }
0debug
bool block_job_is_paused(BlockJob *job) { return job->paused; }
1threat
Write to file in javascript? : <p>I have made a simple site that generates random number. I want to record how many times a specific number comes up.</p> <p>Is there anyway I can use javascript to write to a Local .txt File on the server?</p> <p>or do I have to learn PHP?</p>
0debug
void qmp_block_commit(const char *device, bool has_base, const char *base, bool has_top, const char *top, bool has_backing_file, const char *backing_file, bool has_speed, int64_t speed, Error **errp) { BlockDriverState *bs; BlockDriverState *base_bs, *top_bs; Error *local_err = NULL; BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT; if (!has_speed) { speed = 0; } bdrv_drain_all(); bs = bdrv_find(device); if (!bs) { error_set(errp, QERR_DEVICE_NOT_FOUND, device); return; } if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_COMMIT, errp)) { return; } top_bs = bs; if (has_top && top) { if (strcmp(bs->filename, top) != 0) { top_bs = bdrv_find_backing_image(bs, top); } } if (top_bs == NULL) { error_setg(errp, "Top image file %s not found", top ? top : "NULL"); return; } if (has_base && base) { base_bs = bdrv_find_backing_image(top_bs, base); } else { base_bs = bdrv_find_base(top_bs); } if (base_bs == NULL) { error_set(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL"); return; } if (top_bs == base_bs) { error_setg(errp, "cannot commit an image into itself"); return; } if (top_bs == bs) { if (has_backing_file) { error_setg(errp, "'backing-file' specified," " but 'top' is the active layer"); return; } commit_active_start(bs, base_bs, speed, on_error, block_job_cb, bs, &local_err); } else { commit_start(bs, base_bs, top_bs, speed, on_error, block_job_cb, bs, has_backing_file ? backing_file : NULL, &local_err); } if (local_err != NULL) { error_propagate(errp, local_err); return; } }
1threat
What is this language construct in JS? : <p>Could you please help me to understand what is this in Javascript? What is <strong>a</strong>, what is <strong>a['b']</strong>? How to access the declared content of a construct in the iframe and in the parent window? </p> <pre><code>var a = window['parent']; if(a) { if(a['b']){ a['b']({ "c": 1, "d": { "e": "f", "g": false, "h": 1 }, "i": 0, "j": true }); } } </code></pre> <p>If it is possible give me please a link where I can read about this construction. </p> <p>Thanks a lot.</p>
0debug
int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, int n_start, int n_end, int *num, QCowL2Meta *m) { BDRVQcowState *s = bs->opaque; int l2_index, ret, sectors; uint64_t *l2_table; unsigned int nb_clusters, keep_clusters; uint64_t cluster_offset; trace_qcow2_alloc_clusters_offset(qemu_coroutine_self(), offset, n_start, n_end); again: ret = get_cluster_table(bs, offset, &l2_table, &l2_index); if (ret < 0) { return ret; } nb_clusters = MIN(size_to_clusters(s, n_end << BDRV_SECTOR_BITS), s->l2_size - l2_index); cluster_offset = be64_to_cpu(l2_table[l2_index]); if (qcow2_get_cluster_type(cluster_offset) == QCOW2_CLUSTER_NORMAL && (cluster_offset & QCOW_OFLAG_COPIED)) { keep_clusters = count_contiguous_clusters(nb_clusters, s->cluster_size, &l2_table[l2_index], 0, QCOW_OFLAG_COPIED | QCOW_OFLAG_ZERO); assert(keep_clusters <= nb_clusters); nb_clusters -= keep_clusters; } else { if (cluster_offset & QCOW_OFLAG_COMPRESSED) { nb_clusters = 1; } else { nb_clusters = count_cow_clusters(s, nb_clusters, l2_table, l2_index); } keep_clusters = 0; cluster_offset = 0; } cluster_offset &= L2E_OFFSET_MASK; ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); if (ret < 0) { return ret; } *m = (QCowL2Meta) { .cluster_offset = cluster_offset, .nb_clusters = 0, }; qemu_co_queue_init(&m->dependent_requests); if (nb_clusters > 0) { uint64_t alloc_offset; uint64_t alloc_cluster_offset; uint64_t keep_bytes = keep_clusters * s->cluster_size; alloc_offset = offset + keep_bytes; if (keep_clusters == 0) { alloc_cluster_offset = 0; } else { alloc_cluster_offset = cluster_offset + keep_bytes; } ret = do_alloc_cluster_offset(bs, alloc_offset, &alloc_cluster_offset, &nb_clusters); if (ret == -EAGAIN) { goto again; } else if (ret < 0) { goto fail; } if (nb_clusters > 0) { int requested_sectors = n_end - keep_clusters * s->cluster_sectors; int avail_sectors = (keep_clusters + nb_clusters) << (s->cluster_bits - BDRV_SECTOR_BITS); *m = (QCowL2Meta) { .cluster_offset = keep_clusters == 0 ? alloc_cluster_offset : cluster_offset, .alloc_offset = alloc_cluster_offset, .offset = alloc_offset, .n_start = keep_clusters == 0 ? n_start : 0, .nb_clusters = nb_clusters, .nb_available = MIN(requested_sectors, avail_sectors), }; qemu_co_queue_init(&m->dependent_requests); QLIST_INSERT_HEAD(&s->cluster_allocs, m, next_in_flight); } } sectors = (keep_clusters + nb_clusters) << (s->cluster_bits - 9); if (sectors > n_end) { sectors = n_end; } assert(sectors > n_start); *num = sectors - n_start; return 0; fail: if (m->nb_clusters > 0) { QLIST_REMOVE(m, next_in_flight); } return ret; }
1threat
programming to add a google sheet to someones drive by selecting there name in the sheet : Hi I am trying to create a system for work for when im choosing out of a list of people that i am the sales rep filling out the sheet on a copy. Just seeing if theres a way also that when i choose my name that it also adds that sheet to my own drive
0debug
Must use 'class' tag to refer to type '____' in this scope : <p>I have an error when trying to declare function in a .h file. The error is "Must use 'class' tag to refer to type 'Line' in this scope". Hope you can help me out with this.</p> <pre><code>#include "Position.h" #ifndef PACMAN_FANTOMES_H #define PACMAN_FANTOMES_H class Blinky { private: Position m_blinky; public: //Constructeur Blinky(Position); Position PositionCourante(); }; class Pinky{ private: Position m_pinky; public: //Constructeur Blinky(Position); Position PositionCourante(); // Here is the error, it underlines the word Position }; </code></pre>
0debug
Where should pre-processing and post-processing steps be executed when a TF model is served using TensorFlow serving? : <p>Typically to use a TF graph, it is necessary to convert raw data to numerical values. I refer to this process as a pre-processing step. For example, if the raw data is a sentence, one way is to do this is to tokenize the sentence and map each word to a unique number. This preprocessing creates a sequence of number for each sentence, which will be the input of the model. </p> <p>We need also to post-process the output of a model to interpret it. For example, converting a sequence of numbers generated by the model to words and then building a sentence.</p> <p><a href="https://www.tensorflow.org/serving/" rel="noreferrer">TF Serving</a> is a new technology that is recently introduced by Google to serve a TF model. My question is that:</p> <p>Where should pre-processing and post-processing be executed when a TF model is served using TensorFlow serving?</p> <p>Should I encapsulate pre-processing and post-processing steps in my TF Graph (e.g. using <a href="https://www.tensorflow.org/api_docs/python/tf/py_func" rel="noreferrer">py_fun</a> or <a href="https://www.tensorflow.org/api_docs/python/tf/map_fn" rel="noreferrer">map_fn</a>) or there is another TensorFlow technology that I am not aware of. </p>
0debug
How to insert objects from a List into a dataTable in sql server using linq to sql : i'm new in programming and i'm trying to insert a list of objects using linq to sql and only the last object from the list gets inserted into the dataBase. Can someone help me find the problem? This is my code: //this is the code in the orderDetailRepository class public List<OrderDetail> CreateOrderDetailRecords(List<OrderDetail> details) { FruitStoreDataContext db = new FruitStoreDataContext(); db.OrderDetails.InsertAllOnSubmit(details); db.SubmitChanges(); return details; } //this is the code in the Form.cs file when i press the "finish button" private void FinishButton_Click(object sender, EventArgs e) { OrderDetailRepository orderDetailRepo = new OrderDetailRepository(); orderDetailRepo.CreateOrderDetailRecords(Ord); //Ord is the name of the list of OrderDetail Objects that i created... TotalCostLabel.Visible = true; TotalCostLabel.Text = "$" + totalCost; }
0debug
ReInit в tinyMCE 4.7 (пересоздание элемента) : Нужно удалить часть DOM с элементам редактора. После будет создан новый кусок дерева в котором нужно инициализировать редактор. Я уже по всякому пробовал, но это все не работает (в консоле пусто): tinymce.remove(); window.tinymce.editors = []; tinymce.EditorManager.editors = []; tinymce.EditorManager.init({ ... some code ...}); console.log(tinymce.EditorManager.editors); Даже, если я пытаюсь удалить редактор после инициализации, эти методы вообще не работают.
0debug
projection not working with db.collection.find in mongo : <p>I have started to use mongodb just a day back and have encountered an issue. I searched on net and stackoverflow for how to hide _id value in final answer and following the answers provided I tried to get my code run but still the _id part shows.</p> <p>P.S.: I am using cloud9 as the ide.</p> <pre><code>var mongo = require('mongodb').MongoClient; mongo.connect('mongodb://localhost:27017/learnyoumongo', function(err, database) { if(err) throw err; const db = database.db('learnyoumongo'); var parrots = db.collection('parrots'); parrots.find({ age: { $gt: +process.argv[2] } },{ name: 1, age: 1, _id: 0 }).toArray(function(err, docs){ if(err) throw err; console.log(docs); database.close(); }); }); </code></pre>
0debug
secure-http flag in a composer.json doesn't work : <p>I need to use http composer registry for several packages:</p> <pre><code>... "repositories":[ {"type":"composer", "url":"http://&lt;url&gt;"} ], "secure-http":false, ... </code></pre> <p>But when I am trying to <code>composer update</code> to update lock file, I got:</p> <pre><code>[Composer\Downloader\TransportException] Your configuration does not allow connection to http://&lt;url&gt;. See https://getcomposer.org/doc/06-config.md#secure-http for details. </code></pre> <p>By responding url I found next information;</p> <pre><code>secure-http# Defaults to true. If set to true only HTTPS URLs are allowed to be downloaded via Composer. If you really absolutely need HTTP access to something then you can disable it ... </code></pre> <p>So I am confused what I am doing wrong.</p>
0debug
static void avc_luma_midh_qrt_16w_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, int32_t height, uint8_t horiz_offset) { uint32_t multiple8_cnt; for (multiple8_cnt = 4; multiple8_cnt--;) { avc_luma_midh_qrt_4w_msa(src, src_stride, dst, dst_stride, height, horiz_offset); src += 4; dst += 4; } }
1threat
static int mimic_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int swap_buf_size = buf_size - MIMIC_HEADER_SIZE; MimicContext *ctx = avctx->priv_data; GetByteContext gb; int is_pframe; int width, height; int quality, num_coeffs; int res; if (buf_size <= MIMIC_HEADER_SIZE) { av_log(avctx, AV_LOG_ERROR, "insufficient data\n"); return AVERROR_INVALIDDATA; } bytestream2_init(&gb, buf, MIMIC_HEADER_SIZE); bytestream2_skip(&gb, 2); quality = bytestream2_get_le16u(&gb); width = bytestream2_get_le16u(&gb); height = bytestream2_get_le16u(&gb); bytestream2_skip(&gb, 4); is_pframe = bytestream2_get_le32u(&gb); num_coeffs = bytestream2_get_byteu(&gb); bytestream2_skip(&gb, 3); if (!ctx->avctx) { int i; if (!(width == 160 && height == 120) && !(width == 320 && height == 240)) { av_log(avctx, AV_LOG_ERROR, "invalid width/height!\n"); return AVERROR_INVALIDDATA; } ctx->avctx = avctx; avctx->width = width; avctx->height = height; avctx->pix_fmt = AV_PIX_FMT_YUV420P; for (i = 0; i < 3; i++) { ctx->num_vblocks[i] = AV_CEIL_RSHIFT(height, 3 + !!i); ctx->num_hblocks[i] = width >> (3 + !!i); } } else if (width != ctx->avctx->width || height != ctx->avctx->height) { avpriv_request_sample(avctx, "Resolution changing"); return AVERROR_PATCHWELCOME; } if (is_pframe && !ctx->frames[ctx->prev_index].f->data[0]) { av_log(avctx, AV_LOG_ERROR, "decoding must start with keyframe\n"); return AVERROR_INVALIDDATA; } ff_thread_release_buffer(avctx, &ctx->frames[ctx->cur_index]); ctx->frames[ctx->cur_index].f->pict_type = is_pframe ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; if ((res = ff_thread_get_buffer(avctx, &ctx->frames[ctx->cur_index], AV_GET_BUFFER_FLAG_REF)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return res; } ctx->next_prev_index = ctx->cur_index; ctx->next_cur_index = (ctx->cur_index - 1) & 15; ff_thread_finish_setup(avctx); av_fast_padded_malloc(&ctx->swap_buf, &ctx->swap_buf_size, swap_buf_size); if (!ctx->swap_buf) return AVERROR(ENOMEM); ctx->bbdsp.bswap_buf(ctx->swap_buf, (const uint32_t *) (buf + MIMIC_HEADER_SIZE), swap_buf_size >> 2); init_get_bits(&ctx->gb, ctx->swap_buf, swap_buf_size << 3); res = decode(ctx, quality, num_coeffs, !is_pframe); ff_thread_report_progress(&ctx->frames[ctx->cur_index], INT_MAX, 0); if (res < 0) { if (!(avctx->active_thread_type & FF_THREAD_FRAME)) ff_thread_release_buffer(avctx, &ctx->frames[ctx->cur_index]); return res; } if ((res = av_frame_ref(data, ctx->frames[ctx->cur_index].f)) < 0) return res; *got_frame = 1; flip_swap_frame(data); ctx->prev_index = ctx->next_prev_index; ctx->cur_index = ctx->next_cur_index; ff_thread_release_buffer(avctx, &ctx->frames[ctx->cur_index]); return buf_size; }
1threat
static void put_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels, ptrdiff_t line_size) { int i; for (i = 0; i < 8; i++) { pixels[0] = av_clip_uint8(block[0]); pixels[1] = av_clip_uint8(block[1]); pixels[2] = av_clip_uint8(block[2]); pixels[3] = av_clip_uint8(block[3]); pixels[4] = av_clip_uint8(block[4]); pixels[5] = av_clip_uint8(block[5]); pixels[6] = av_clip_uint8(block[6]); pixels[7] = av_clip_uint8(block[7]); pixels += line_size; block += 8; } }
1threat
Chartjs Bar Chart showing old data when hovering : <p>I have a bar chart that's created using chart.js. Everything works fine on page load, but when I change the time frame using a daterangepicker, a glitch appears. The new data is brought in, but when I hover over it, the old data is shown. I'm new to javascript so I'm hoping to get some help. It looks like I need to incorporate .destroy(); somehow, but I don't know how. A snippet of my code is below:</p> <pre><code>function loadFTPRChart(startdate, enddate){ var BCData = { labels: [], datasets: [ { label: "Pass %", backgroundColor: "#536A7F", data: [], stack: 1 }, { label: "Fail %", backgroundColor: "#e6e6e6", data: [], stack: 1 }, { label: "Auto %", backgroundColor: "#286090", data: [], stack: 2 }, { label: "Manual %", backgroundColor: "#f0f0f0", data: [], stack: 2 } ] }; $.getJSON( "content/FTPR_AM_Graph_ajax.php", { startdate: startdate, enddate: enddate, location: "M" }) .done(function( data ) { console.log("data", data); $.each( data.aaData, function( key, val ) { if(val == ""){return true} BCData.labels.push("Coater " + val[0]); BCData.datasets[0].data.push(parseFloat(val[2])); BCData.datasets[1].data.push(parseFloat(100-val[2])); BCData.datasets[2].data.push(parseFloat(val[1])); BCData.datasets[3].data.push(parseFloat(100-val[1])); }); var option = { responsive:true, }; console.log("BCData", BCData); //console.log("PrevData", data); var ctx = document.getElementById("mybarChart2").getContext("2d"); new Chart(ctx, { type: 'groupableBar', data: BCData, options: { scales: { yAxes: [{ ticks: { max: 100, }, stacked: true, }] } } }); }); } loadFTPRChart($('#reportrange').data().daterangepicker.startDate.format('MM/DD/YYYY'), $('#reportrange').data().daterangepicker.endDate.format('MM/DD/YYYY')); </code></pre> <p>What is the best way to destroy the original data so that when I change the date range and hover over the new chart, the old data no longer flickers?</p> <p>Thanks</p>
0debug
Smart pointers as unorderd_map key and compare them by reference : I need `unorderd_map` which will compare elements by reference. I tried to do this by inserting smart pointers as a key (since I do not want to use row pointers) and I implemented `Equal` to compare underlying references of smart pointers. However, the map is not able to find elements correctly. #include <memory> #include <unordered_map> #include <iostream> using namespace std; class Node {}; typedef shared_ptr<Node> NodePtr; struct HashFunction { unsigned long operator()(const NodePtr& key) const{ return (unsigned long)key.get(); } }; struct EqualFunction { bool operator()(const NodePtr& t1, const NodePtr& t2) const { return t1.get() == t2.get(); } }; class Map { unordered_map<NodePtr, int, HashFunction, EqualFunction> map; public: void insert(NodePtr nodeToInsert, int val) { map.insert({nodeToInsert, val }); } bool exist(NodePtr node) { if (map.find(node) == map.end()) return false; return true; } }; int main() { Node node; Map map; auto nodePtr = make_shared<Node>(node); map.insert(nodePtr, 1); auto ptrToSameNode = make_shared<Node>(node); if (map.exist(ptrToSameNode)) cout << "Node exists."; else cout << "Node doesn't exist."; } Above code print "Node doesn't exist" even through I am searching for the same node.
0debug
static inline void xan_wc3_copy_pixel_run(XanContext *s, int x, int y, int pixel_count, int motion_x, int motion_y) { int stride; int line_inc; int curframe_index, prevframe_index; int curframe_x, prevframe_x; int width = s->avctx->width; unsigned char *palette_plane, *prev_palette_plane; palette_plane = s->current_frame.data[0]; prev_palette_plane = s->last_frame.data[0]; stride = s->current_frame.linesize[0]; line_inc = stride - width; curframe_index = y * stride + x; curframe_x = x; prevframe_index = (y + motion_y) * stride + x + motion_x; prevframe_x = x + motion_x; while(pixel_count && (curframe_index < s->frame_size)) { int count = FFMIN3(pixel_count, width - curframe_x, width - prevframe_x); memcpy(palette_plane + curframe_index, prev_palette_plane + prevframe_index, count); pixel_count -= count; curframe_index += count; prevframe_index += count; curframe_x += count; prevframe_x += count; if (curframe_x >= width) { curframe_index += line_inc; curframe_x = 0; } if (prevframe_x >= width) { prevframe_index += line_inc; prevframe_x = 0; } } }
1threat
def dif_Square(n): if (n % 4 != 2): return True return False
0debug
How to use PHP If statement comparing to SQL Date and Current Date? : <p>In my SQL Database i have a date column. I want to use a PHP if statement to show some text if the date from the DB equals todays date. Aswell as that, use an else to show something else if the date does not equal today.</p> <p>Running PHP 7</p> <p>I have lost count of what i have tried with this but don't seem to get anywhere.</p> <p>I am fetching the data here:</p> <pre><code> $sql1 = 'SELECT `date` FROM `operations`.`opsroom` ORDER BY `opsroom`.`date` ASC, `opsroom`.`starttime` ASC LIMIT 1'; $nextsession = mysqli_query($conn, $sql1); </code></pre> <p>Later on in the file is where i am using this:</p> <pre><code> &lt;?php while ($row = mysqli_fetch_assoc($nextsession)) { if( $row['date'] == DATE(date)){ echo "BOOKINGS TODAY"; } else { echo "No Bookings"; } } ?&gt; </code></pre> <p>Only error i get at the moment is PHP Warning: Use of undefined constant date - assumed 'date' (this will throw an Error in a future version of PHP)</p>
0debug
SKStoreReviewController requestReview() may or may not present and alert? : <p>I'm taking a look at the new <code>requestReview()</code> API that uses <code>SKStoreReviewController</code>. The documents state:</p> <p>"Although you should call this method when it makes sense in the user experience flow of your app, the actual display of a rating/review request view is governed by App Store policy. Because this method <strong><em>may or may not</em></strong> present an alert, it's not appropriate to call it in response to a button tap or other user action."</p> <p>Does anyone have any experience using this API. What exactly are the factors that determine if the rating view is shown or not? I'm guessing it's not shown if called too frequently.. Anybody have any insight on this? Thanks!</p>
0debug
def return_sum(dict): sum = 0 for i in dict.values(): sum = sum + i return sum
0debug
Email form validation to accept only one domain : <p>I know this is a relatively asked question but here goes. I have registration form where a user can sign up but I want it to be for a closed group of people so only people from my company can register. So only people with @company.com domain addresses can register. What I have so far is just a email validation code using patterns. How would I alter the below code to only allow @company.com emails? Cheers.</p> <pre><code>$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.&lt;br /&gt;'; } </code></pre>
0debug
why I get a wrong answer in this codes in C? : [enter image description here][1] [1]: https://i.stack.imgur.com/EEQMw.jpg #include <stdio.h> void fun(int a,int b,int c){ int *ret; ret = &a -1; (*ret)+=8; } int main(){ int x; x = 0; fun(1,2,3); x = 1; printf("x is %d\n",x ); return 0; } in my opinion, the x is 1, but it's actually 0. What cause this?
0debug
Machine learning query : <p>Please correct me if I am wrong. "Training Set is used for calculating parameters of a machine learning model, Validation data is used for calculating hyperparameters of the same model (we use same weights with different hyperparameters), and Test set is used for evaluating our model". If true, can someone explain the whole process in a little more detail. TIA.</p>
0debug
regex numbers like 1.1k : <p>in regex <code>\d+</code> match all numbers, but it doesn't match numbers like <code>1k</code> or <code>1.4k</code> how should I make a regex to count that numbers too?</p> <p>What i want:</p> <p>VALID:</p> <ul> <li>1.1K</li> <li>1.2K</li> <li>1.0K</li> <li>1K</li> </ul> <p>INVALID:</p> <ul> <li>1.1</li> </ul> <p>I am new to regex and I don't know how to start</p>
0debug
Add an anchor to Laravel redirect back : <p>In a Laravel controller I have this redirect:</p> <pre><code> return redirect()-&gt;back(); </code></pre> <p>Which returns me to my previous page (say <a href="http://domain/page" rel="noreferrer">http://domain/page</a>). However, I want to make the page jump to a particular anchor (say #section). So ultimately this page should be opened: <a href="http://domain/page#section" rel="noreferrer">http://domain/page#section</a>. How can I make this happen? I tried appending the anchor to the redirect but that doesn't work. </p>
0debug
Why is there some ambiguity in the way sizeof() function works in C++, when using struct : <pre><code>struct node { int data; struct node *next; } cout&lt;&lt;sizeof(struct node)&lt;&lt;sizeof(node)&lt;&lt;endl; //no error, C++ allows us to use sizeof(struct node) and sizeof(node) both. </code></pre> <p>Whereas we cannot do the same with int datatype</p> <pre><code>int a; cout&lt;&lt;sizeof(int) &lt;&lt;sizeof(a) &lt;&lt;endl;//there is no error here //BUT cout&lt;&lt;sizeof(int a) &lt;&lt;endl;//this throws an error </code></pre> <p>I understand that "struct node" itself is like a datatype which can be used to declare variable of type "struct node". Going by the behavior of how sizeof() works with int, it is understandable that sizeof(struct node) is equivalent to sizeof(datatype) and hence is correct usage. </p> <p>But how does sizeof(node) work as well ? It does not throw any error. "node" in itself cannot be used to declare any other variables, it needs to be "struct node" to declare a variable.</p>
0debug
Why my gradle projects creates separated modules for main and test in Intellij Idea : <p>Recently, I found all my gradle projects in Idea import separated modules for main and test. The modules look like this:</p> <p><a href="https://i.stack.imgur.com/386GG.png"><img src="https://i.stack.imgur.com/386GG.png" alt="enter image description here"></a></p> <p>As you can see, there is a "main" module which content root is the src/main and includes only main classes and resources, and there is a "test" module as well. The modules just don't look right. Is this an expected behavior?</p> <p>The Idea is <code>Intellij Idea 2016.1.1</code> and the gradle is <code>2.11</code></p> <p>Here is the content of build.gradle</p> <pre><code>apply plugin: 'idea' apply plugin: 'java' apply plugin: 'spring-boot' apply plugin: "jacoco" version = getVersion() sourceCompatibility = 1.8 targetCompatibility = 1.8 configurations { provided } sourceSets { main { compileClasspath += configurations.provided } test { resources { srcDir 'src/test/data' } compileClasspath += configurations.provided } } processResources { filter { String line -&gt; line.replace("{version}", getVersion()) } } processTestResources { filter { String line -&gt; line.replace("{version}", getVersion()) } } idea { module { scopes.PROVIDED.plus += [configurations.provided] } } repositories { mavenCentral() } </code></pre>
0debug
Add column headers to a very large csv doc : <p>I have a csv doc with hundreds of columns. I want to add a row at the top with headers f1,f2,f3,f4.....fn to give a name to each column</p> <p>How is it possible to do that automatically with excel?</p>
0debug
how to connect magento 2 webservices in iOS : I want to call API from magento 2.2 db.But as I don't have to knowledge how to create API in magento 2.2 and also how to make a connection between db and iOS programming.Anyone please provide some example or link and help me as I google lot but didn't got anything.
0debug
CSS / xpath selector to find h3 tag with text in a given class ? : CSS/xpath selector to achieve "//*[@class='body']//descendant::h3[contains(text(), sampletext]" ?
0debug
Flutter Tests: Waiting for a certain duration : <p>I'm trying to wait for some time after I tested tapping my button to then check the result with <code>expect</code>. I'm using <code>Future.delayed</code> for that. But that doesn't work for me. I'm getting a time out error.</p> <pre><code> TimeoutException after 0:00:05.000000: Test timed out after 5 seconds. </code></pre> <p>This is the code I use:</p> <pre><code>... // other tests await tester.tap(find.widgetWithText(GestureDetector, "ref size")); await new Future.delayed(new Duration(milliseconds: 50)); expect(testContainerState.childWidth, 50.0); </code></pre> <p>Does any one have an idea why this (imo) strange behavior occurs?</p>
0debug
static void xscom_write(void *opaque, hwaddr addr, uint64_t val, unsigned width) { PnvChip *chip = opaque; uint32_t pcba = pnv_xscom_pcba(chip, addr); MemTxResult result; if (xscom_write_default(chip, pcba, val)) { goto complete; } address_space_stq(&chip->xscom_as, pcba << 3, val, MEMTXATTRS_UNSPECIFIED, &result); if (result != MEMTX_OK) { qemu_log_mask(LOG_GUEST_ERROR, "XSCOM write failed at @0x%" HWADDR_PRIx " pcba=0x%08x data=0x%" PRIx64 "\n", addr, pcba, val); xscom_complete(current_cpu, HMER_XSCOM_FAIL | HMER_XSCOM_DONE); return; } complete: xscom_complete(current_cpu, HMER_XSCOM_DONE); }
1threat
Error when assigning new string value to char array : <p>When trying to assign a new string value to an existing char array in c, I get the following error:</p> <pre><code>assignment to expression with array type employees[id].FirstMiddleName = NewFirstMiddleName; ^ </code></pre> <p>I thought both variables were arrays of the same size so I don't understand what the error is referring to or how to fix it.</p> <pre><code>struct employee { char LastName[30]; char FirstMiddleName[35]; float Salary; int YearHired; }; int modify(int id) { char NewLastName[30]; char NewFirstMiddleName[35]; float NewSalary; int NewYearHired; printf("Enter new first (and middle) name(s): \n"); gets(NewFirstMiddleName); employees[id].FirstMiddleName = NewFirstMiddleName; printf("Enter new last name: \n"); gets(NewLastName); employees[id].LastName = NewLastName; .... } int main() { struct employee *ptr, person; ptr = &amp;person; ptr-&gt;LastName[0] = '\0'; ptr-&gt;FirstMiddleName[0] = '\0'; ptr-&gt;Salary = -1; ptr-&gt;YearHired = -1; for(int i = 0; i &lt; 20; i++) { employees[i] = person; //printf("%i\n", i); } .... } </code></pre>
0debug
int ioinst_handle_stsch(CPUS390XState *env, uint64_t reg1, uint32_t ipb) { int cssid, ssid, schid, m; SubchDev *sch; uint64_t addr; int cc; SCHIB *schib; hwaddr len = sizeof(*schib); if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { program_interrupt(env, PGM_OPERAND, 2); return -EIO; } trace_ioinst_sch_id("stsch", cssid, ssid, schid); addr = decode_basedisp_s(env, ipb); if (addr & 3) { program_interrupt(env, PGM_SPECIFICATION, 2); return -EIO; } schib = s390_cpu_physical_memory_map(env, addr, &len, 1); if (!schib || len != sizeof(*schib)) { program_interrupt(env, PGM_ADDRESSING, 2); cc = -EIO; goto out; } sch = css_find_subch(m, cssid, ssid, schid); if (sch) { if (css_subch_visible(sch)) { css_do_stsch(sch, schib); cc = 0; } else { cc = 3; } } else { if (css_schid_final(m, cssid, ssid, schid)) { cc = 3; } else { memset(schib, 0, sizeof(*schib)); cc = 0; } } out: s390_cpu_physical_memory_unmap(env, schib, len, 1); return cc; }
1threat
Best IDE for Python (One that auto / fixes indentation errors ?) : <p>What is the equivalent for eclipse for Python? I'm trying to get into Python and i'm struggling with the Syntax and indentation in particular. Looking for some recommendations, of an IDE that is similar to eclipse thanks!</p>
0debug
Where do Internal testers download Google Play Android apps? : <p>I thought I need just this link <code>https://play.google.com/store/apps/details?id=com.here.myapp.name</code> to download an app from Play Store, but when I click on it from tester account (which in tester list) I can only see <a href="https://i.stack.imgur.com/sG5RF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sG5RF.png" alt="enter image description here"></a></p>
0debug
int64_t helper_fqtox(CPUSPARCState *env) { int64_t ret; clear_float_exceptions(env); ret = float128_to_int64_round_to_zero(QT1, &env->fp_status); check_ieee_exceptions(env); return ret; }
1threat
static void update_sr (AC97LinkState *s, AC97BusMasterRegs *r, uint32_t new_sr) { int event = 0; int level = 0; uint32_t new_mask = new_sr & SR_INT_MASK; uint32_t old_mask = r->sr & SR_INT_MASK; uint32_t masks[] = {GS_PIINT, GS_POINT, GS_MINT}; if (new_mask ^ old_mask) { if (!new_mask) { event = 1; level = 0; } else { if ((new_mask & SR_LVBCI) && (r->cr & CR_LVBIE)) { event = 1; level = 1; } if ((new_mask & SR_BCIS) && (r->cr & CR_IOCE)) { event = 1; level = 1; } } } r->sr = new_sr; dolog ("IOC%d LVB%d sr=%#x event=%d level=%d\n", r->sr & SR_BCIS, r->sr & SR_LVBCI, r->sr, event, level); if (!event) return; if (level) { s->glob_sta |= masks[r - s->bm_regs]; dolog ("set irq level=1\n"); qemu_set_irq (s->pci_dev->irq[0], 1); } else { s->glob_sta &= ~masks[r - s->bm_regs]; dolog ("set irq level=0\n"); qemu_set_irq (s->pci_dev->irq[0], 0); } }
1threat
Display series of images like a gif in Swift : <p>I'm trying to show 100 images frame by frame similar to how a gif would work in my Swift app. Since gifs are not supported in UIImageView, I've read that its best to just switch the images rapidly with code. I've tried doing what some other tutorials say but it all comes up with errors. I'm pretty new to Swift, so I'm quite confused. I know I need to store them in an array of some sort but would some one be able to tell me the exact syntax? And also whatever I need to do in the actual storyboard along with the code. Thanks!</p>
0debug
Create matrix out of two lists while populating body of matrix using custom method in Python : <p>I have two lists that I would like to use to make a 2D matrix. I would like to call a custom method based on the combination of the two lists to populate the body of the matrix.</p> <p>How would I do this?</p> <p>Say I have a list of [A, B, C] and [1, 2, 3]. The result I want would be:</p> <pre><code> A B C 1 x 2 3 </code></pre> <p>where x is the return of my_method(A,1).</p> <p>Thank you.</p>
0debug
uint64_t ldq_be_phys(target_phys_addr_t addr) { return ldq_phys_internal(addr, DEVICE_BIG_ENDIAN); }
1threat