problem
stringlengths
26
131k
labels
class label
2 classes
how to design a algorithm to delete the duplicated 2D points in a points list in python : <p>I have a 2D point list like:</p> <p><strong>points_list = [[2,1],[3,1],[2,1],[2,2],[2,1],[2,2]]</strong></p> <p>I want to find the duplicated 2D points, and only leave one copy of each duplicated point in the list. Such that to get a result like:</p> <p><strong>result_list = [[2,1],[3,1],[2,2]]</strong></p> <p>I know a stupid method to solve the problem, but cannot find a elegant way. Hoping someone could provide some easy ways. Thanks!</p>
0debug
Is there an x86/x86_64 instruction which zeros all bits below the Most Significant Bit? : So for the following sequence: 0001000111000 The desired result would be: 0001000000000 I am fully aware that this is achievable by finding the MSB's index with assembly BSRL (or similar bit-twiddling hack) then >> bitshifting the number by (index - 1), then << shifting back by (index - 1), but I want to know whether there is, specifically, an assembly instruction, Not a Bit-twiddle, that can do this. Thanks
0debug
I have created UITextFields dynamically. Now i want to refer to the TextFields to check for some constraints. How do i do so? : func displayTextBox1(height: Int, placeHolder: String, xtb: Int, ytb: Int, lableName: String, xl: Int, yl: Int) { DispatchQueue.main.async{ self.textField = UITextField(frame: CGRect(x: xtb, y: ytb, width: 343, height: height)) self.textField.textAlignment = NSTextAlignment.left self.textField.textColor = UIColor.black self.textField.borderStyle = UITextBorderStyle.line self.textField.autocapitalizationType = UITextAutocapitalizationType.words self.textField.placeholder = placeHolder self.view.addSubview(self.textField) self.displayLabel(labelName: lableName, x: xl, y: yl) } }
0debug
How Static function in C reduce memory footprints? : <p>I've recently learned that declare functions or/and variables as static can reduce footprints, but I can't figured out why. Most article online focus on the scope and readability but not mentioned any benefit about memory allocation. Does "static" really improve performance?</p>
0debug
ConstraintLayout Problems using <include> : <p>I am trying to figure out why this does not work. I am adding nothing but two <code>&lt;include&gt;</code> sections in a <code>ConstraintLayout</code> and the layout is not following any of the constraints that I set up. I am trying to begin migrating to the use of <code>ConstraintLayout</code> as my go-to layout, but things like this keep pushing me back to <code>RelativeLayout</code> and <code>LinearLayout</code>.</p> <p>Here is the top level layout file (the ConstraintLayout), showing some of the constraints that are not working:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.constraint.ConstraintLayout 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:layout_editor_absoluteY="81dp" tools:layout_editor_absoluteX="0dp"&gt; &lt;include android:id="@+id/includeButton" layout="@layout/include_button_panel" android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintRight_toRightOf="parent" /&gt; &lt;include android:id="@+id/includeText" layout="@layout/include_text_panel" android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" /&gt; &lt;/android.support.constraint.ConstraintLayout </code></pre> <p>Here is the first included layout (include_button_panel):</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;merge xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;Button android:id="@+id/include_button_panel_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Touch me!" /&gt; &lt;/merge&gt; </code></pre> <p>Here is the second included layout (include_text_panel):</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;merge xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;TextView android:id="@+id/include_text_panel_text" android:layout_width="wrap_content" android:background="#7986cb" android:layout_height="wrap_content" android:text="This is the text panel" android:textColor="@android:color/black" android:textSize="18sp" /&gt; &lt;/merge&gt; </code></pre>
0debug
static void cpu_handle_debug_exception(CPUState *env) { CPUWatchpoint *wp; if (!env->watchpoint_hit) TAILQ_FOREACH(wp, &env->watchpoints, entry) wp->flags &= ~BP_WATCHPOINT_HIT; if (debug_excp_handler) debug_excp_handler(env); }
1threat
AWS SDK for PHP in scheduled task no working : I have a simple PHP script that I created to do some basic maintenance on my DynamoDB account and I would like it to run daily. I have it set up on my host which is GoDaddy Windows based / plesk. When I go directly to the page via a browser it runs perfectly and does exactly what I want. However I set it up as a scheduled task and I get this error every time it runs: Status: 500 Internal Server Error Content-type: text/html PHP Parse error: syntax error, unexpected '$value' (T_VARIABLE) in **path removed**\AWS\Aws\functions.php on line 36 I have googled and have found tons of sites with this error but they all say that it was related to the PHP version being earlier than 5.5 and PHP 5.5 minimum is required. However I am running PHP 5.6, plus like I said it runs fine if I just go through a browser, it's the scheduled task that doesn't work... I'm guessing there is something different about the way a task is pathed or run or something but I can't figure out what it is, does anyone have any insight?
0debug
filter_mirror_set_outdev(Object *obj, const char *value, Error **errp) { MirrorState *s = FILTER_MIRROR(obj); g_free(s->outdev); s->outdev = g_strdup(value); if (!s->outdev) { error_setg(errp, "filter filter mirror needs 'outdev' " "property set"); return; } }
1threat
static int raw_pwrite_aligned(BlockDriverState *bs, int64_t offset, const uint8_t *buf, int count) { BDRVRawState *s = bs->opaque; int ret; ret = fd_open(bs); if (ret < 0) return -errno; ret = pwrite(s->fd, buf, count, offset); if (ret == count) goto label__raw_write__success; DEBUG_BLOCK_PRINT("raw_pwrite(%d:%s, %" PRId64 ", %p, %d) [%" PRId64 "] write failed %d : %d = %s\n", s->fd, bs->filename, offset, buf, count, bs->total_sectors, ret, errno, strerror(errno)); label__raw_write__success: return (ret < 0) ? -errno : ret; }
1threat
static void pvpanic_fw_cfg(ISADevice *dev, FWCfgState *fw_cfg) { PVPanicState *s = ISA_PVPANIC_DEVICE(dev); fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", g_memdup(&s->ioport, sizeof(s->ioport)), sizeof(s->ioport)); }
1threat
Is there a way to jump to last edited cell in Jupyter? : <p>Often in Jupyter I'd move to different parts of the notebook to look at something, and when I am done I want to jump back to where I was working on previously. Right now I'd have to navigate to the closest Markdown section (through the Jupyter Notebook Extensions) and move up or down to get to where I was. Is there a way to jump directly to the last cell that I have made an edit (preferably through keyboard shortcut)? Thanks!</p>
0debug
Get Public IP Address on current EC2 Instance : <p>Using Amazon CLI, is there a way to get the public ip address of the current EC2? I'm just looking for the single string value, so not the json response describe-addresses returns. </p>
0debug
uint32_t net_checksum_add_cont(int len, uint8_t *buf, int seq) { uint32_t sum = 0; int i; for (i = seq; i < seq + len; i++) { if (i & 1) { sum += (uint32_t)buf[i - seq]; } else { sum += (uint32_t)buf[i - seq] << 8; } } return sum; }
1threat
Algorithmic puzzle asked in an interview : today i got stuck on the following problem.kindly provide some clue,the statement is following: Given an array A[] of size n.Maximize A[i]*A[j]*A[k] under the following constraints: a). i<j<k b).A[i]<A[j]<A[k] Thank u.
0debug
How to use cin "as a parameter" in a switch statement : <p>I want to be able to create a switch statement using cin, without having to create a variable to store the value inputed. For example:</p> <pre><code>switch(cin){ case 1: std::cout &lt;&lt; "Hello World"; break; default: break; } </code></pre>
0debug
beginner regular expressions( java) : s = s.replaceAll("\\\s+$" , ""); I am still a beginner in java but as far as I know to use regular expressions I have to write it in [ ] so why this works and how the Jvm knows it is regular expressions and not just some string
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
Css not working all the time : I created a webpage with a dynamic footer. In the footer I have a facebook icon. when I preview the page the image does not appear. All other css is working fine except for the footer. Could anyone tell me what I am missing? My footer template: <footer> <div class="icon-text"> <div class="icon-text-text"> <ul class="footer-nav"> <li><a href="tearms.php">Terms and Conditions</a></li> <li><a href="shipping_info">Shipping Information</a></li> </ul> </div> </div> <div class="icon-text"> <p class="email_text">Follow me on</p> <a href="#"> <img class="social-icon" src=../icons/facebook.png" alt="Facebook"> </a>> </footer> <footer class="second"> <p>&copy; All Rights Reserved</p> </footer> <!--End of Footer Section--> Here is my css for the footer section: footer { background-color: pink; border: 2px solid black; box-shadow: 5px 5px 3px rgba(0, 0, 0, .65); width: 1350px; max-height: 300px; overflow: hidden; } .icon-text { width: 50%; float: left; text-align: justify; text-align: center; } .icon-text-text { font-size: 150%; } img.social-icon { height: 45px; width: 45px; } .email_text { font-size: 150%; } And here in the php on the index page to add the footer: <?php include_once("templates/template_footer.php"); ?> There are other things wrong with the footer like I can't get the wording to move to the left but the image is whats important. Any ideas on how to fix this?
0debug
i am try to get my current location in android but this shows wrong. And also try to get my location following code but it's not working : > **i am usjing this code but it is not working.** > > > > locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); > if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) > { > if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != > PackageManager.PERMISSION_GRANTED && > ActivityCompat.checkSelfPermission(this, > Manifest.permission.ACCESS_COARSE_LOCATION) != > PackageManager.PERMISSION_GRANTED) { > // TODO: Consider calling > // ActivityCompat#requestPermissions > // here to request the missing permissions, and then overriding > // public void onRequestPermissionsResult(int requestCode, String[] permissions, > // int[] grantResults) > // to handle the case where the user grants the permission. See the documentation > // for ActivityCompat#requestPermissions for more details. > return; > } > locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, > 0, 0, new LocationListener() { > @Override > public void onLocationChanged(Location location) { > //get latitude > double latitude = location.getLatitude(); > //get Longtitude > double longitude = location.getLongitude(); > > > LatLng latLng = new LatLng(latitude, longitude); > > // Toast.makeText(getApplicationContext(), latitude+" "+longitude, > Toast.LENGTH_LONG).show(); > > Geocoder geocoder = new Geocoder(getApplicationContext()); > try { > List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1); > String str = addresses.get(0).getLocality() + ","; > str += addresses.get(0).getCountryName(); > mMap.addMarker(new MarkerOptions().position(latLng).title(str)); > mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 18)); > } catch (IOException e) { > e.printStackTrace(); > } > } > > @Override > public void onStatusChanged(String provider, int status, Bundle extras) { > > } > > @Override > public void onProviderEnabled(String provider) { > > } > > @Override > public void onProviderDisabled(String provider) { > > } > }); > } > else if(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) > { > locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, > 0, 0, new LocationListener() { > @Override > public void onLocationChanged(Location location) { > //get latitude > double latitude = location.getLatitude(); > //get Longtitude > double longitude = location.getLongitude(); > > LatLng latLng = new LatLng(latitude, longitude); > > > Geocoder geocoder = new Geocoder(getApplicationContext()); > try { > List<Address> addresses = geocoder.getFromLocation(latitude,longitude,1); > String str = addresses.get(0).getLocality()+","; > str +=addresses.get(0).getCountryName(); > mMap.addMarker(new MarkerOptions().position(latLng).title(str)); > mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 18)); > } catch (IOException e) { > e.printStackTrace(); > } > } > > @Override > public void onStatusChanged(String provider, int status, Bundle extras) { > > } > > @Override > public void onProviderEnabled(String provider) { > > } > > @Override > public void onProviderDisabled(String provider) { > > } > }); > > > **how to solve this problem**
0debug
How to fix Error: this class is not key value coding-compliant for the key tableView.' : <p>I made an app with <code>Table View</code> and <code>Segmented Control</code>, and this is my first time. I'm using some code and some tutorials, but It's not working. When I run my app It's crashing and it's showing this Error in logs:</p> <blockquote> <p>MyApplication[4928:336085] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key tableView.' * First throw call stack: ( 0 CoreFoundation 0x000000010516fd85 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x0000000105504deb objc_exception_throw + 48 2 CoreFoundation 0x000000010516f9c9 -[NSException raise] + 9 3 Foundation 0x000000010364e19b -[NSObject(NSKeyValueCoding) setValue:forKey:] + 288 4 UIKit 0x0000000103c37d0c -[UIViewController setValue:forKey:] + 88 5 UIKit 0x0000000103e6e7fb -[UIRuntimeOutletConnection connect] + 109 6 CoreFoundation 0x00000001050a9890 -[NSArray makeObjectsPerformSelector:] + 224 7 UIKit 0x0000000103e6d1de -[UINib instantiateWithOwner:options:] + 1864 8 UIKit 0x0000000103c3e8d6 -[UIViewController _loadViewFromNibNamed:bundle:] + 381 9 UIKit 0x0000000103c3f202 -[UIViewController loadView] + 178 10 UIKit 0x0000000103c3f560 -[UIViewController loadViewIfRequired] + 138 11 UIKit 0x0000000103c3fcd3 -[UIViewController view] + 27 12 UIKit 0x000000010440b024 -[_UIFullscreenPresentationController _setPresentedViewController:] + 87 13 UIKit 0x0000000103c0f5ca -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 133 14 UIKit 0x0000000103c525bb -[UIViewController _presentViewController:withAnimationController:completion:] + 4002 15 UIKit 0x0000000103c5585c -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 489 16 UIKit 0x0000000103c5536b -[UIViewController presentViewController:animated:completion:] + 179 17 UIKit 0x00000001041feb8d __67-[UIStoryboardModalSegueTemplate newDefaultPerformHandlerForSegue:]_block_invoke + 243 18 UIKit 0x00000001041ec630 -[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 460 19 UIKit 0x00000001041ec433 -[UIStoryboardSegueTemplate _perform:] + 82 20 UIKit 0x00000001041ec6f7 -[UIStoryboardSegueTemplate perform:] + 156 21 UIKit 0x0000000103aa6a8d -[UIApplication sendAction:to:from:forEvent:] + 92 22 UIKit 0x0000000103c19e67 -[UIControl sendAction:to:forEvent:] + 67 23 UIKit 0x0000000103c1a143 -[UIControl _sendActionsForEvents:withEvent:] + 327 24 UIKit 0x0000000103c19263 -[UIControl touchesEnded:withEvent:] + 601 25 UIKit 0x0000000103b1999f -[UIWindow _sendTouchesForEvent:] + 835 26 UIKit 0x0000000103b1a6d4 -[UIWindow sendEvent:] + 865 27 UIKit 0x0000000103ac5dc6 -[UIApplication sendEvent:] + 263 28 UIKit 0x0000000103a9f553 _UIApplicationHandleEventQueue + 6660 29 CoreFoundation 0x0000000105095301 _CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION_ + 17 30 CoreFoundation 0x000000010508b22c __CFRunLoopDoSources0 + 556 31 CoreFoundation 0x000000010508a6e3 __CFRunLoopRun + 867 32 CoreFoundation 0x000000010508a0f8 CFRunLoopRunSpecific + 488 33 GraphicsServices 0x000000010726dad2 GSEventRunModal + 161 34 UIKit 0x0000000103aa4f09 UIApplicationMain + 171 35 Dhikr 0x0000000101f26282 main + 114 36 libdyld.dylib 0x00000001064c392d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException</p> </blockquote> <p>The code that I used is: </p> <pre><code>class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { let foodList:[String] = ["Bread", "Meat", "Pizza", "Other"] let drinkList:[String] = ["Water", "Soda", "Juice", "Other"] @IBOutlet weak var mySegmentedControl: UISegmentedControl! @IBOutlet weak var myTableView: UITableView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int { var returnValue = 0 switch(mySegmentedControl.selectedSegmentIndex) { case 0: returnValue = foodList.count break case 1: returnValue = drinkList.count break default: break } return returnValue } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell { let myCell = tableView.dequeueReusableCellWithIdentifier("myCells", forIndexPath: indexPath) switch(mySegmentedControl.selectedSegmentIndex) { case 0: myCell.textLabel!.text = foodList[indexPath.row] break case 1: myCell.textLabel!.text = drinkList[indexPath.row] break default: break } return myCell } @IBAction func segmentedControlActionChanged(sender: AnyObject) { myTableView.reloadData() } </code></pre> <p>Here is <strong>main.Storyboard</strong></p> <p><a href="https://i.stack.imgur.com/Q1ig6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Q1ig6.png" alt="enter image description here"></a></p> <p>I checked the code many times, but it's not working. First I had to use only <code>Table View</code>, watching this tutorial (<a href="https://www.youtube.com/watch?v=ABVLSF3Vqdg" rel="noreferrer">https://www.youtube.com/watch?v=ABVLSF3Vqdg</a>) I thought it will work to use <code>Segmented Control</code> as in tutorial. But still doesn't work. Same code, same error. Can someone help me ?</p>
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
Dependency injection with abstract class and object in Play Framework 2.5 : <p>I'm trying to migrate from Play 2.4 to 2.5 avoiding deprecated stuff.</p> <p>I had an <code>abstract class Microservice</code> from which I created some objects. Some functions of the <code>Microservice</code> class used <code>play.api.libs.ws.WS</code> to make HTTP requests and also <code>play.Play.application.configuration</code> to read the configuration.</p> <p>Previously, all I needed was some imports like:</p> <pre><code>import play.api.libs.ws._ import play.api.Play.current import play.api.libs.concurrent.Execution.Implicits.defaultContext </code></pre> <p>But now you <a href="https://www.playframework.com/documentation/2.5.x/ScalaWS">should use dependency injection to use <code>WS</code></a> and also <a href="https://www.playframework.com/documentation/2.5.x/Migration25#Deprecated-play.Play-and-play.api.Play-methods">to use access the current Play application</a>.</p> <p>I have something like this (shortened):</p> <pre><code>abstract class Microservice(serviceName: String) { // ... protected lazy val serviceURL: String = play.Play.application.configuration.getString(s"microservice.$serviceName.url") // ...and functions using WS.url()... } </code></pre> <p>An object looks something like this (shortened):</p> <pre><code>object HelloWorldService extends Microservice("helloWorld") { // ... } </code></pre> <p>Unfortunately I don't understand how I get all the stuff (WS, configuration, ExecutionContect) into the abstract class to make it work.</p> <p>I tried to change it to:</p> <pre><code>abstract class Microservice @Inject() (serviceName: String, ws: WSClient, configuration: play.api.Configuration)(implicit context: scala.concurrent.ExecutionContext) { // ... } </code></pre> <p>But this doesn't solve the problem, because now I have to change the object too, and I can't figure out how.</p> <p>I tried to turn the <code>object</code> into a <code>@Singleton class</code>, like:</p> <pre><code>@Singleton class HelloWorldService @Inject() (implicit ec: scala.concurrent.ExecutionContext) extends Microservice ("helloWorld", ws: WSClient, configuration: play.api.Configuration) { /* ... */ } </code></pre> <p>I tried all sorts of combinations, but I'm not getting anywhere and I feel I'm not really on the right track here.</p> <p>Any ideas how I can use things like WS the proper way (not using deprecated methods) without making things so complicated?</p>
0debug
JS - Testing code that uses an IntersectionObserver : <p>I have a (rather poorly written) javascript component in my application that handles infinite scroll pagination, and i'm trying to rewrite it to use the <code>IntersectionObserver</code>, as described <a href="https://developers.google.com/web/updates/2016/04/intersectionobserver" rel="noreferrer">here</a>, however i'm having issues in testing it.</p> <p>Is there a way to drive the behavior of the observer in a QUnit test, i.e. to trigger the observer callback with some entries described in my tests?</p> <p>A possible solution I have come up with is to expose the callback function in the component's prototype and to invoke it directly in my test, something like this:</p> <pre><code>InfiniteScroll.prototype.observerCallback = function(entries) { //handle the infinite scroll } InfiniteScroll.prototype.initObserver = function() { var io = new IntersectionObserver(this.observerCallback); io.observe(someElements); } //In my test var component = new InfiniteScroll(); component.observerCallback(someEntries); //Do some assertions about the state after the callback has been executed </code></pre> <p>I don't really like this approach since it's exposing the fact that the component uses an <code>IntersectionObserver</code> internally, which is an implementation detail that in my opinion should not be visible to client code, so is there any better way to test this?</p> <p>Bonus love for solutions not using jQuery :)</p>
0debug
How fast can ECS fargate boot a container? : <p>What the the minimum/average time for AWS ECS Fargate to boot and run a docker image?<br> For arguments sake, the 45MB <code>anapsix/alpine-java</code> image.</p> <p>I would like to investigate using ECS Fargate to speed up the process of building software locally on a slow laptop/pc, by having the software built on a faster remote server.<br> As such the boot up time of the image is crucial in making the endevour worth while.</p>
0debug
Implement a function using sizeof : <p>I am new in C programming and using a specific library. I need to use this function:</p> <pre><code>le_result_t le_ecall_ExportMsd ( le_ecall_CallRef_t ecallRef, uint8_t * msdPtr, size_t * msdNumElementsPtr ) </code></pre> <p>Where the parameters:</p> <pre><code>[in] ecallRef eCall reference [out] msdPtr the encoded MSD [in,out] msdNumElementsPtr </code></pre> <p>In order to get que encoded MSD I developed this code (a little bit simplified):</p> <pre><code>static le_ecall_CallRef_t LastTestECallRef = NULL; uint8_t msd[] = NULL; void StarteCall (void) { le_ecall_ExportMsd(LastTestECallRef, msd, sizeof(msd)); } </code></pre> <p>Sizeof is returning size_t and I need size_t * so I am getting the following error:</p> <pre><code>expected 'size_t *' but argument is of type 'unsigned int' </code></pre> <p>I would be gratefull if somebody could help me. </p>
0debug
Updating web page content when continuous scrolling : <p>I want to ask how do i implement something like Facebook or Quora such that i keep scrolling the page and content gets updated automatically without having to refresh</p>
0debug
Terraform pass variables to a child module : <p>I am trying to pass a variable from the <code>root module</code> to a <code>child module</code> with the following syntax:</p> <p><strong>main.tf:</strong></p> <pre><code>provider "aws" { version = "~&gt; 1.11" access_key = "${var.aws_access_key}" secret_key = "${var.aws_secret_key}" region = "${var.aws_region}" } module "iam" { account_id = "${var.account_id}" source = "./modules/iam" } * account_id value is stored on variables.tf in the root folder </code></pre> <p><strong>/modules/iam/iam.tf</strong></p> <pre><code>resource "aws_iam_policy_attachment" "myName" { name = "myName" policy_arn = "arn:aws:iam::${var.account_id}:policy/myName" &lt;-- doesnt work groups = [] users = [] roles = [] } </code></pre> <p>when I try to access within the module to <code>account_id</code> an error is thrown.</p>
0debug
Creating a List of like Indicies : <p>new here and somewhat new to Python. I am having a blank and would appreciate some guidance.</p> <p>I am trying to write a nested list, then write a for loop to print a comma seperated list of the numbers using like indicies from each list to pair-up the numbers. I have my code below(2.7.14):</p> <pre><code>FirstNumbers = [1, 2, 3] SecondNumbers = [4, 5, 6] ThirdNumbers = [7, 8, 9] NestedNumbers = [FirstNumbers, SecondNumbers, ThirdNumbers] for i in range(0, 3): for each_number in NestedNumbers: print each_number[i], #Output </code></pre> <p><code>1 4 7 2 5 8 3 6 9</code></p> <p>My current issue is trying to get the numbers to read [1, 4, 7] and so on. I would appreciate any guidance.</p> <p>Thank you </p>
0debug
static int set_expr(AVExpr **pexpr, const char *expr, void *log_ctx) { int ret; if (*pexpr) av_expr_free(*pexpr); *pexpr = NULL; ret = av_expr_parse(pexpr, expr, var_names, NULL, NULL, NULL, NULL, 0, log_ctx); if (ret < 0) av_log(log_ctx, AV_LOG_ERROR, "Error when evaluating the expression '%s'\n", expr); return ret; }
1threat
How can I dismiss the on screen keyboard? : <p>I am collecting user input with a <code>TextFormField</code> and when the user presses a <code>FloatingActionButton</code> indicating they are done, I want to dismiss the on screen keyboard.</p> <p>How do I make the keyboard go away automatically?</p> <pre><code>import 'package:flutter/material.dart'; class MyHomePage extends StatefulWidget { MyHomePageState createState() =&gt; new MyHomePageState(); } class MyHomePageState extends State&lt;MyHomePage&gt; { TextEditingController _controller = new TextEditingController(); @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar(), floatingActionButton: new FloatingActionButton( child: new Icon(Icons.send), onPressed: () { setState(() { // send message // dismiss on screen keyboard here _controller.clear(); }); }, ), body: new Container( alignment: FractionalOffset.center, padding: new EdgeInsets.all(20.0), child: new TextFormField( controller: _controller, decoration: new InputDecoration(labelText: 'Example Text'), ), ), ); } } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( home: new MyHomePage(), ); } } void main() { runApp(new MyApp()); } </code></pre>
0debug
how to resolve async await inside a unit test - javascript : <p>I have a lambda for which I'd like to write unit tests for. I'm using async await but I'm getting issues with resolve promises. I'd like to test the different conditions, how can I write the test to resolve and stop seeing the timeouts?</p> <p>Thanks in advance.</p> <blockquote> <p>Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.</p> </blockquote> <p>--- unit </p> <pre><code>describe('tests', function() { describe('describe an error', () =&gt; { it('should return a 500', (done) =&gt; { handler('', {}, (err, response) =&gt; { expect(err.status).to.eq('failed') done() }) }) }) }); </code></pre> <p>-- handler</p> <pre><code>export const handler = async (event, context, callback) =&gt; { return callback(null, status: 500 ) }) </code></pre>
0debug
How to make a rounded view in android : <p>I want to make a rounded view as below</p> <p><a href="https://i.stack.imgur.com/P3W9U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P3W9U.png" alt="enter image description here"></a></p> <p>I expect to create that view with programmatically changed radius, color. Not from xml configured</p>
0debug
Angular2: Unsubscribe from http observable in Service : <p>What is the best practice to unsubscribe within a Angular2 service from a http subscription?</p> <p>Currently I do this but I'm not sure if this will be the best way.</p> <pre><code>import { Injectable } from "@angular/core"; import { Http } from "@angular/http"; import { Subject } from "rxjs/Subject"; import { ISubscription } from "rxjs/Subscription"; @Injectable() export class SearchService { private _searchSource = new Subject&lt;any&gt;(); public search$ = this._searchSource.asObservable(); constructor(private _http: Http) {} public search(value: string) { let sub: ISubscription = this._http.get("/api/search?value=" + value) .map(response =&gt; &lt;any&gt;response.json()) .do(data =&gt; this._searchSource.next(data)) .finally(() =&gt; sub.unsubscribe()).subscribe(); } } </code></pre>
0debug
static void qtrle_decode_32bpp(QtrleContext *s) { int stream_ptr; int header; int start_line; int lines_to_change; signed char rle_code; int row_ptr, pixel_ptr; int row_inc = s->frame.linesize[0]; unsigned char r, g, b; unsigned int argb; unsigned char *rgb = s->frame.data[0]; int pixel_limit = s->frame.linesize[0] * s->avctx->height; if (s->size < 8) return; stream_ptr = 4; CHECK_STREAM_PTR(2); header = BE_16(&s->buf[stream_ptr]); stream_ptr += 2; if (header & 0x0008) { CHECK_STREAM_PTR(8); start_line = BE_16(&s->buf[stream_ptr]); stream_ptr += 4; lines_to_change = BE_16(&s->buf[stream_ptr]); stream_ptr += 4; } else { start_line = 0; lines_to_change = s->avctx->height; } row_ptr = row_inc * start_line; while (lines_to_change--) { CHECK_STREAM_PTR(2); pixel_ptr = row_ptr + (s->buf[stream_ptr++] - 1) * 4; while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) { if (rle_code == 0) { CHECK_STREAM_PTR(1); pixel_ptr += (s->buf[stream_ptr++] - 1) * 4; CHECK_PIXEL_PTR(0); } else if (rle_code < 0) { rle_code = -rle_code; CHECK_STREAM_PTR(4); stream_ptr++; r = s->buf[stream_ptr++]; g = s->buf[stream_ptr++]; b = s->buf[stream_ptr++]; argb = (r << 16) | (g << 8) | (b << 0); CHECK_PIXEL_PTR(rle_code * 4); while (rle_code--) { *(unsigned int *)(&rgb[pixel_ptr]) = argb; pixel_ptr += 4; } } else { CHECK_STREAM_PTR(rle_code * 4); CHECK_PIXEL_PTR(rle_code * 4); while (rle_code--) { stream_ptr++; r = s->buf[stream_ptr++]; g = s->buf[stream_ptr++]; b = s->buf[stream_ptr++]; argb = (r << 16) | (g << 8) | (b << 0); *(unsigned int *)(&rgb[pixel_ptr]) = argb; pixel_ptr += 4; } } } row_ptr += row_inc; } }
1threat
uint64_t helper_addqv(CPUAlphaState *env, uint64_t op1, uint64_t op2) { uint64_t tmp = op1; op1 += op2; if (unlikely((tmp ^ op2 ^ (-1ULL)) & (tmp ^ op1) & (1ULL << 63))) { arith_excp(env, GETPC(), EXC_M_IOV, 0); } return op1; }
1threat
how can i validate this emaild "email@-domain.com" with regex : <p>i want to validate following email id </p> <pre><code>email@-domain.com </code></pre> <p>for that i am using following regex but it is not validating above email id , what type of change in my current regex works for me </p> <p>here is my regex </p> <pre><code> /^[A-Za-z0-9_\+-]+(\.[A-Za-z0-9_\+-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*\.([A-Za-z]{2,10})$/ </code></pre>
0debug
ASP.NET Core Identity change login URL : <p>I'm using ASP.NET Core 2.1 and I used scaffolding to add Identity, which is working OK Except that when I try to go to a page that requires login, it takes me to: <code>/Identity/Account/Login?ReturnUrl</code></p> <p>How do I change it to go to just /Account/Login which is my own login page i created.</p> <p>I tried this:</p> <pre><code>services.ConfigureApplicationCookie(options =&gt; { options.AccessDeniedPath = "/Account/AccessDenied"; options.Cookie.Name = "Cookie"; options.Cookie.HttpOnly = true; options.ExpireTimeSpan = TimeSpan.FromMinutes(720); options.LoginPath = "/Account/Login"; options.ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter; options.SlidingExpiration = true; }); </code></pre> <p>but it still goes to /Identity/</p>
0debug
how sort list names satisfying below : Only the first letter of each part of the name should be capital. All the parts of the name except the last part should be represented by only two characters. The first character should be the first letter of the part and should be capitalized. The second character should be ."
0debug
voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size) { VocDecContext *voc = s->priv_data; AVCodecContext *dec = st->codec; ByteIOContext *pb = s->pb; VocType type; int size, tmp_codec; int sample_rate = 0; int channels = 1; while (!voc->remaining_size) { type = get_byte(pb); if (type == VOC_TYPE_EOF) return AVERROR(EIO); voc->remaining_size = get_le24(pb); if (!voc->remaining_size) { if (url_is_streamed(s->pb)) return AVERROR(EIO); voc->remaining_size = url_fsize(pb) - url_ftell(pb); } max_size -= 4; switch (type) { case VOC_TYPE_VOICE_DATA: dec->sample_rate = 1000000 / (256 - get_byte(pb)); if (sample_rate) dec->sample_rate = sample_rate; dec->channels = channels; tmp_codec = ff_codec_get_id(ff_voc_codec_tags, get_byte(pb)); if (dec->codec_id == CODEC_ID_NONE) dec->codec_id = tmp_codec; else if (dec->codec_id != tmp_codec) av_log(s, AV_LOG_WARNING, "Ignoring mid-stream change in audio codec\n"); dec->bits_per_coded_sample = av_get_bits_per_sample(dec->codec_id); voc->remaining_size -= 2; max_size -= 2; channels = 1; break; case VOC_TYPE_VOICE_DATA_CONT: break; case VOC_TYPE_EXTENDED: sample_rate = get_le16(pb); get_byte(pb); channels = get_byte(pb) + 1; sample_rate = 256000000 / (channels * (65536 - sample_rate)); voc->remaining_size = 0; max_size -= 4; break; case VOC_TYPE_NEW_VOICE_DATA: dec->sample_rate = get_le32(pb); dec->bits_per_coded_sample = get_byte(pb); dec->channels = get_byte(pb); tmp_codec = ff_codec_get_id(ff_voc_codec_tags, get_le16(pb)); if (dec->codec_id == CODEC_ID_NONE) dec->codec_id = tmp_codec; else if (dec->codec_id != tmp_codec) av_log(s, AV_LOG_WARNING, "Ignoring mid-stream change in audio codec\n"); url_fskip(pb, 4); voc->remaining_size -= 12; max_size -= 12; break; default: url_fskip(pb, voc->remaining_size); max_size -= voc->remaining_size; voc->remaining_size = 0; break; } if (dec->codec_id == CODEC_ID_NONE) { av_log(s, AV_LOG_ERROR, "Invalid codec_id\n"); if (s->audio_codec_id == CODEC_ID_NONE) return AVERROR(EINVAL); } } dec->bit_rate = dec->sample_rate * dec->bits_per_coded_sample; if (max_size <= 0) max_size = 2048; size = FFMIN(voc->remaining_size, max_size); voc->remaining_size -= size; return av_get_packet(pb, pkt, size); }
1threat
void cpu_reset (CPUMIPSState *env) { memset(env, 0, offsetof(CPUMIPSState, breakpoints)); tlb_flush(env, 1); #if !defined(CONFIG_USER_ONLY) if (env->hflags & MIPS_HFLAG_BMASK) { env->CP0_ErrorEPC = env->PC - 4; env->hflags &= ~MIPS_HFLAG_BMASK; } else { env->CP0_ErrorEPC = env->PC; } env->PC = (int32_t)0xBFC00000; #if defined (MIPS_USES_R4K_TLB) env->CP0_Random = MIPS_TLB_NB - 1; env->tlb_in_use = MIPS_TLB_NB; #endif env->CP0_Wired = 0; env->CP0_EBase = (int32_t)0x80000000; env->CP0_Config0 = MIPS_CONFIG0; env->CP0_Config1 = MIPS_CONFIG1; env->CP0_Config2 = MIPS_CONFIG2; env->CP0_Config3 = MIPS_CONFIG3; env->CP0_Status = (1 << CP0St_BEV) | (1 << CP0St_ERL); env->CP0_WatchLo = 0; env->hflags = MIPS_HFLAG_ERL; env->CP0_Debug = (1 << CP0DB_CNT) | (0x1 << CP0DB_VER); env->CP0_PRid = MIPS_CPU; #endif env->exception_index = EXCP_NONE; #if defined(CONFIG_USER_ONLY) env->hflags |= MIPS_HFLAG_UM; env->user_mode_only = 1; #endif #ifdef MIPS_USES_FPU env->fcr0 = MIPS_FCR0; #endif env->SYNCI_Step = 16; env->CCRes = 2; }
1threat
static void hpet_ram_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { int i; HPETState *s = opaque; uint64_t old_val, new_val, val, index; DPRINTF("qemu: Enter hpet_ram_writel at %" PRIx64 " = %#x\n", addr, value); index = addr; old_val = hpet_ram_read(opaque, addr, 4); new_val = value; if (index >= 0x100 && index <= 0x3ff) { uint8_t timer_id = (addr - 0x100) / 0x20; HPETTimer *timer = &s->timer[timer_id]; DPRINTF("qemu: hpet_ram_writel timer_id = %#x\n", timer_id); if (timer_id > s->num_timers) { DPRINTF("qemu: timer id out of range\n"); return; } switch ((addr - 0x100) % 0x20) { case HPET_TN_CFG: DPRINTF("qemu: hpet_ram_writel HPET_TN_CFG\n"); if (activating_bit(old_val, new_val, HPET_TN_FSB_ENABLE)) { update_irq(timer, 0); } val = hpet_fixup_reg(new_val, old_val, HPET_TN_CFG_WRITE_MASK); timer->config = (timer->config & 0xffffffff00000000ULL) | val; if (new_val & HPET_TN_32BIT) { timer->cmp = (uint32_t)timer->cmp; timer->period = (uint32_t)timer->period; } if (activating_bit(old_val, new_val, HPET_TN_ENABLE)) { hpet_set_timer(timer); } else if (deactivating_bit(old_val, new_val, HPET_TN_ENABLE)) { hpet_del_timer(timer); } break; case HPET_TN_CFG + 4: DPRINTF("qemu: invalid HPET_TN_CFG+4 write\n"); break; case HPET_TN_CMP: DPRINTF("qemu: hpet_ram_writel HPET_TN_CMP\n"); if (timer->config & HPET_TN_32BIT) { new_val = (uint32_t)new_val; } if (!timer_is_periodic(timer) || (timer->config & HPET_TN_SETVAL)) { timer->cmp = (timer->cmp & 0xffffffff00000000ULL) | new_val; } if (timer_is_periodic(timer)) { new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1; timer->period = (timer->period & 0xffffffff00000000ULL) | new_val; } timer->config &= ~HPET_TN_SETVAL; if (hpet_enabled(s)) { hpet_set_timer(timer); } break; case HPET_TN_CMP + 4: high order DPRINTF("qemu: hpet_ram_writel HPET_TN_CMP + 4\n"); if (!timer_is_periodic(timer) || (timer->config & HPET_TN_SETVAL)) { timer->cmp = (timer->cmp & 0xffffffffULL) | new_val << 32; } else { new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1; timer->period = (timer->period & 0xffffffffULL) | new_val << 32; } timer->config &= ~HPET_TN_SETVAL; if (hpet_enabled(s)) { hpet_set_timer(timer); } break; case HPET_TN_ROUTE: timer->fsb = (timer->fsb & 0xffffffff00000000ULL) | new_val; break; case HPET_TN_ROUTE + 4: timer->fsb = (new_val << 32) | (timer->fsb & 0xffffffff); break; default: DPRINTF("qemu: invalid hpet_ram_writel\n"); break; } return; } else { switch (index) { case HPET_ID: return; case HPET_CFG: val = hpet_fixup_reg(new_val, old_val, HPET_CFG_WRITE_MASK); s->config = (s->config & 0xffffffff00000000ULL) | val; if (activating_bit(old_val, new_val, HPET_CFG_ENABLE)) { s->hpet_offset = ticks_to_ns(s->hpet_counter) - qemu_get_clock_ns(vm_clock); for (i = 0; i < s->num_timers; i++) { if ((&s->timer[i])->cmp != ~0ULL) { hpet_set_timer(&s->timer[i]); } } } else if (deactivating_bit(old_val, new_val, HPET_CFG_ENABLE)) { s->hpet_counter = hpet_get_ticks(s); for (i = 0; i < s->num_timers; i++) { hpet_del_timer(&s->timer[i]); } } if (activating_bit(old_val, new_val, HPET_CFG_LEGACY)) { qemu_set_irq(s->pit_enabled, 0); qemu_irq_lower(s->irqs[0]); qemu_irq_lower(s->irqs[RTC_ISA_IRQ]); } else if (deactivating_bit(old_val, new_val, HPET_CFG_LEGACY)) { qemu_irq_lower(s->irqs[0]); qemu_set_irq(s->pit_enabled, 1); qemu_set_irq(s->irqs[RTC_ISA_IRQ], s->rtc_irq_level); } break; case HPET_CFG + 4: DPRINTF("qemu: invalid HPET_CFG+4 write\n"); break; case HPET_STATUS: val = new_val & s->isr; for (i = 0; i < s->num_timers; i++) { if (val & (1 << i)) { update_irq(&s->timer[i], 0); } } break; case HPET_COUNTER: if (hpet_enabled(s)) { DPRINTF("qemu: Writing counter while HPET enabled!\n"); } s->hpet_counter = (s->hpet_counter & 0xffffffff00000000ULL) | value; DPRINTF("qemu: HPET counter written. ctr = %#x -> %" PRIx64 "\n", value, s->hpet_counter); break; case HPET_COUNTER + 4: if (hpet_enabled(s)) { DPRINTF("qemu: Writing counter while HPET enabled!\n"); } s->hpet_counter = (s->hpet_counter & 0xffffffffULL) | (((uint64_t)value) << 32); DPRINTF("qemu: HPET counter + 4 written. ctr = %#x -> %" PRIx64 "\n", value, s->hpet_counter); break; default: DPRINTF("qemu: invalid hpet_ram_writel\n"); break; } } }
1threat
Write a c++ function that will prompt a user for an integer and convert it to binary and print in reverse order : <p>Here is my code, and my error message is, "error C4716: 'decToBinary': must return a value" Basically, I want the user to input an integer and have the program return the binary expansion in reverse order. How do I go about fixing this? Thank you!</p> <p><a href="https://i.stack.imgur.com/ow5ss.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ow5ss.png" alt="enter image description here"></a></p>
0debug
void dsputil_init_armv4l(void) { }
1threat
int av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *frame) { BufferSinkContext *s = ctx->priv; AVFilterLink *link = ctx->inputs[0]; int ret; if ((ret = ff_request_frame(link)) < 0) return ret; if (!s->cur_frame) return AVERROR(EINVAL); av_frame_move_ref(frame, s->cur_frame); av_frame_free(&s->cur_frame); return 0; }
1threat
Accessing navigator in Actions with React-Native and Redux : <p>Using React-Native (0.19) and Redux, I'm able to navigate from scene to scene in React Components like so:</p> <pre><code>this.props.navigator.push({ title: "Registrations", component: RegistrationContainer }); </code></pre> <p>Additionally I'd like to be able push components to the navigator from anywhere in the app (reducers and/or actions).</p> <p>Example Flow:</p> <ol> <li>User fills out form and presses Submit</li> <li>We dispatch the form data to an action</li> <li>The action sets state that it has started to send data across the wire</li> <li>The action fetches the data</li> <li>When complete, action dispatches that the submission has ended</li> <li>Action navigates to the new data recently created</li> </ol> <p>Problems I'm seeing with my approach:</p> <ul> <li>The navigator is in the props, not the state. In the reducer, I do not have access to the props</li> <li>I need to pass <code>navigator</code> into any action that needs it. </li> </ul> <p>I feel like I'm missing something slightly simple on how to access Navigator from actions without sending in as a parameter. </p>
0debug
av_cold void ff_sws_init_input_funcs(SwsContext *c) { enum PixelFormat srcFormat = c->srcFormat; c->chrToYV12 = NULL; switch(srcFormat) { case PIX_FMT_YUYV422 : c->chrToYV12 = yuy2ToUV_c; break; case PIX_FMT_UYVY422 : c->chrToYV12 = uyvyToUV_c; break; case PIX_FMT_NV12 : c->chrToYV12 = nv12ToUV_c; break; case PIX_FMT_NV21 : c->chrToYV12 = nv21ToUV_c; break; case PIX_FMT_RGB8 : case PIX_FMT_BGR8 : case PIX_FMT_PAL8 : case PIX_FMT_BGR4_BYTE: case PIX_FMT_RGB4_BYTE: c->chrToYV12 = palToUV_c; break; case PIX_FMT_GBRP9LE: case PIX_FMT_GBRP10LE: case PIX_FMT_GBRP16LE: c->readChrPlanar = planar_rgb16le_to_uv; break; case PIX_FMT_GBRP9BE: case PIX_FMT_GBRP10BE: case PIX_FMT_GBRP16BE: c->readChrPlanar = planar_rgb16be_to_uv; break; case PIX_FMT_GBRP: c->readChrPlanar = planar_rgb_to_uv; break; #if HAVE_BIGENDIAN case PIX_FMT_YUV444P9LE: case PIX_FMT_YUV422P9LE: case PIX_FMT_YUV420P9LE: case PIX_FMT_YUV422P10LE: case PIX_FMT_YUV444P10LE: case PIX_FMT_YUV420P10LE: case PIX_FMT_YUV420P16LE: case PIX_FMT_YUV422P16LE: case PIX_FMT_YUV444P16LE: c->chrToYV12 = bswap16UV_c; break; #else case PIX_FMT_YUV444P9BE: case PIX_FMT_YUV422P9BE: case PIX_FMT_YUV420P9BE: case PIX_FMT_YUV444P10BE: case PIX_FMT_YUV422P10BE: case PIX_FMT_YUV420P10BE: case PIX_FMT_YUV420P16BE: case PIX_FMT_YUV422P16BE: case PIX_FMT_YUV444P16BE: c->chrToYV12 = bswap16UV_c; break; #endif } if (c->chrSrcHSubSample) { switch(srcFormat) { case PIX_FMT_RGBA64BE: c->chrToYV12 = rgb64BEToUV_half_c; break; case PIX_FMT_RGBA64LE: c->chrToYV12 = rgb64LEToUV_half_c; break; case PIX_FMT_RGB48BE : c->chrToYV12 = rgb48BEToUV_half_c; break; case PIX_FMT_RGB48LE : c->chrToYV12 = rgb48LEToUV_half_c; break; case PIX_FMT_BGR48BE : c->chrToYV12 = bgr48BEToUV_half_c; break; case PIX_FMT_BGR48LE : c->chrToYV12 = bgr48LEToUV_half_c; break; case PIX_FMT_RGB32 : c->chrToYV12 = bgr32ToUV_half_c; break; case PIX_FMT_RGB32_1 : c->chrToYV12 = bgr321ToUV_half_c; break; case PIX_FMT_BGR24 : c->chrToYV12 = bgr24ToUV_half_c; break; case PIX_FMT_BGR565LE: c->chrToYV12 = bgr16leToUV_half_c; break; case PIX_FMT_BGR565BE: c->chrToYV12 = bgr16beToUV_half_c; break; case PIX_FMT_BGR555LE: c->chrToYV12 = bgr15leToUV_half_c; break; case PIX_FMT_BGR555BE: c->chrToYV12 = bgr15beToUV_half_c; break; case PIX_FMT_BGR444LE: c->chrToYV12 = bgr12leToUV_half_c; break; case PIX_FMT_BGR444BE: c->chrToYV12 = bgr12beToUV_half_c; break; case PIX_FMT_BGR32 : c->chrToYV12 = rgb32ToUV_half_c; break; case PIX_FMT_BGR32_1 : c->chrToYV12 = rgb321ToUV_half_c; break; case PIX_FMT_RGB24 : c->chrToYV12 = rgb24ToUV_half_c; break; case PIX_FMT_RGB565LE: c->chrToYV12 = rgb16leToUV_half_c; break; case PIX_FMT_RGB565BE: c->chrToYV12 = rgb16beToUV_half_c; break; case PIX_FMT_RGB555LE: c->chrToYV12 = rgb15leToUV_half_c; break; case PIX_FMT_RGB555BE: c->chrToYV12 = rgb15beToUV_half_c; break; case PIX_FMT_GBR24P : c->chrToYV12 = gbr24pToUV_half_c; break; case PIX_FMT_RGB444LE: c->chrToYV12 = rgb12leToUV_half_c; break; case PIX_FMT_RGB444BE: c->chrToYV12 = rgb12beToUV_half_c; break; } } else { switch(srcFormat) { case PIX_FMT_RGB48BE : c->chrToYV12 = rgb48BEToUV_c; break; case PIX_FMT_RGB48LE : c->chrToYV12 = rgb48LEToUV_c; break; case PIX_FMT_BGR48BE : c->chrToYV12 = bgr48BEToUV_c; break; case PIX_FMT_BGR48LE : c->chrToYV12 = bgr48LEToUV_c; break; case PIX_FMT_RGB32 : c->chrToYV12 = bgr32ToUV_c; break; case PIX_FMT_RGB32_1 : c->chrToYV12 = bgr321ToUV_c; break; case PIX_FMT_BGR24 : c->chrToYV12 = bgr24ToUV_c; break; case PIX_FMT_BGR565LE: c->chrToYV12 = bgr16leToUV_c; break; case PIX_FMT_BGR565BE: c->chrToYV12 = bgr16beToUV_c; break; case PIX_FMT_BGR555LE: c->chrToYV12 = bgr15leToUV_c; break; case PIX_FMT_BGR555BE: c->chrToYV12 = bgr15beToUV_c; break; case PIX_FMT_BGR444LE: c->chrToYV12 = bgr12leToUV_c; break; case PIX_FMT_BGR444BE: c->chrToYV12 = bgr12beToUV_c; break; case PIX_FMT_BGR32 : c->chrToYV12 = rgb32ToUV_c; break; case PIX_FMT_BGR32_1 : c->chrToYV12 = rgb321ToUV_c; break; case PIX_FMT_RGB24 : c->chrToYV12 = rgb24ToUV_c; break; case PIX_FMT_RGB565LE: c->chrToYV12 = rgb16leToUV_c; break; case PIX_FMT_RGB565BE: c->chrToYV12 = rgb16beToUV_c; break; case PIX_FMT_RGB555LE: c->chrToYV12 = rgb15leToUV_c; break; case PIX_FMT_RGB555BE: c->chrToYV12 = rgb15beToUV_c; break; case PIX_FMT_RGB444LE: c->chrToYV12 = rgb12leToUV_c; break; case PIX_FMT_RGB444BE: c->chrToYV12 = rgb12beToUV_c; break; } } c->lumToYV12 = NULL; c->alpToYV12 = NULL; switch (srcFormat) { case PIX_FMT_GBRP9LE: case PIX_FMT_GBRP10LE: case PIX_FMT_GBRP16LE: c->readLumPlanar = planar_rgb16le_to_y; break; case PIX_FMT_GBRP9BE: case PIX_FMT_GBRP10BE: case PIX_FMT_GBRP16BE: c->readLumPlanar = planar_rgb16be_to_y; break; case PIX_FMT_GBRP: c->readLumPlanar = planar_rgb_to_y; break; #if HAVE_BIGENDIAN case PIX_FMT_YUV444P9LE: case PIX_FMT_YUV422P9LE: case PIX_FMT_YUV420P9LE: case PIX_FMT_YUV444P10LE: case PIX_FMT_YUV422P10LE: case PIX_FMT_YUV420P10LE: case PIX_FMT_YUV420P16LE: case PIX_FMT_YUV422P16LE: case PIX_FMT_YUV444P16LE: case PIX_FMT_GRAY16LE: c->lumToYV12 = bswap16Y_c; break; #else case PIX_FMT_YUV444P9BE: case PIX_FMT_YUV422P9BE: case PIX_FMT_YUV420P9BE: case PIX_FMT_YUV444P10BE: case PIX_FMT_YUV422P10BE: case PIX_FMT_YUV420P10BE: case PIX_FMT_YUV420P16BE: case PIX_FMT_YUV422P16BE: case PIX_FMT_YUV444P16BE: case PIX_FMT_GRAY16BE: c->lumToYV12 = bswap16Y_c; break; #endif case PIX_FMT_YUYV422 : case PIX_FMT_Y400A : c->lumToYV12 = yuy2ToY_c; break; case PIX_FMT_UYVY422 : c->lumToYV12 = uyvyToY_c; break; case PIX_FMT_BGR24 : c->lumToYV12 = bgr24ToY_c; break; case PIX_FMT_BGR565LE : c->lumToYV12 = bgr16leToY_c; break; case PIX_FMT_BGR565BE : c->lumToYV12 = bgr16beToY_c; break; case PIX_FMT_BGR555LE : c->lumToYV12 = bgr15leToY_c; break; case PIX_FMT_BGR555BE : c->lumToYV12 = bgr15beToY_c; break; case PIX_FMT_BGR444LE : c->lumToYV12 = bgr12leToY_c; break; case PIX_FMT_BGR444BE : c->lumToYV12 = bgr12beToY_c; break; case PIX_FMT_RGB24 : c->lumToYV12 = rgb24ToY_c; break; case PIX_FMT_RGB565LE : c->lumToYV12 = rgb16leToY_c; break; case PIX_FMT_RGB565BE : c->lumToYV12 = rgb16beToY_c; break; case PIX_FMT_RGB555LE : c->lumToYV12 = rgb15leToY_c; break; case PIX_FMT_RGB555BE : c->lumToYV12 = rgb15beToY_c; break; case PIX_FMT_RGB444LE : c->lumToYV12 = rgb12leToY_c; break; case PIX_FMT_RGB444BE : c->lumToYV12 = rgb12beToY_c; break; case PIX_FMT_RGB8 : case PIX_FMT_BGR8 : case PIX_FMT_PAL8 : case PIX_FMT_BGR4_BYTE: case PIX_FMT_RGB4_BYTE: c->lumToYV12 = palToY_c; break; case PIX_FMT_MONOBLACK: c->lumToYV12 = monoblack2Y_c; break; case PIX_FMT_MONOWHITE: c->lumToYV12 = monowhite2Y_c; break; case PIX_FMT_RGB32 : c->lumToYV12 = bgr32ToY_c; break; case PIX_FMT_RGB32_1: c->lumToYV12 = bgr321ToY_c; break; case PIX_FMT_BGR32 : c->lumToYV12 = rgb32ToY_c; break; case PIX_FMT_BGR32_1: c->lumToYV12 = rgb321ToY_c; break; case PIX_FMT_RGB48BE: c->lumToYV12 = rgb48BEToY_c; break; case PIX_FMT_RGB48LE: c->lumToYV12 = rgb48LEToY_c; break; case PIX_FMT_BGR48BE: c->lumToYV12 = bgr48BEToY_c; break; case PIX_FMT_BGR48LE: c->lumToYV12 = bgr48LEToY_c; break; case PIX_FMT_RGBA64BE:c->lumToYV12 = rgb64BEToY_c; break; case PIX_FMT_RGBA64LE:c->lumToYV12 = rgb64LEToY_c; break; } if (c->alpPixBuf) { switch (srcFormat) { case PIX_FMT_RGBA64LE: case PIX_FMT_RGBA64BE: c->alpToYV12 = rgba64ToA_c; break; case PIX_FMT_BGRA: case PIX_FMT_RGBA: c->alpToYV12 = rgbaToA_c; break; case PIX_FMT_ABGR: case PIX_FMT_ARGB: c->alpToYV12 = abgrToA_c; break; case PIX_FMT_Y400A: c->alpToYV12 = uyvyToY_c; break; case PIX_FMT_PAL8 : c->alpToYV12 = palToA_c; break; } } }
1threat
What to return if condition is not satisifed? : <p>The method looks as following:</p> <pre><code>private static List&lt;string&gt; SetPointObjectDefectRow(string[] row, string owner) { const int zone = 54; const string band = "U"; if (Helpers.NormalizeLocalizedString(row[7]).Contains(@"a") || Helpers.NormalizeLocalizedString(row[12]).Contains(@"b")) { var geoPosition = UtmConverter.StringUtmFormatToLocation(zone, band, Convert.ToDouble(row[15]), Convert.ToDouble(row[14])); var beginGeoPosition = geoPosition.LatString + ", " + geoPosition.LngString; var result = new List&lt;string&gt; { owner, row[4], beginGeoPosition }; return result; } } </code></pre> <p>It's obvious that not all paths return something and the issue is I can't return null.</p> <p>How to rearrange the method?</p>
0debug
void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, int is_write, int is_user, uintptr_t retaddr) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; int target_el; bool same_el; if (retaddr) { cpu_restore_state(cs, retaddr); } target_el = exception_target_el(env); same_el = (arm_current_el(env) == target_el); env->exception.vaddress = vaddr; if (arm_regime_using_lpae_format(env, cpu_mmu_index(env, false))) { env->exception.fsr = 0x21; } else { env->exception.fsr = 0x1; } if (is_write == 1 && arm_feature(env, ARM_FEATURE_V6)) { env->exception.fsr |= (1 << 11); } raise_exception(env, EXCP_DATA_ABORT, syn_data_abort(same_el, 0, 0, 0, is_write == 1, 0x21), target_el); }
1threat
int kvm_arch_insert_sw_breakpoint(CPUState *cpu, struct kvm_sw_breakpoint *bp) { return -EINVAL; }
1threat
How do I programmatically set an Angular 2 form control to dirty? : <p>How do I mark an Angular 2 Control as dirty in my code?</p> <p>When I do it like this:</p> <pre><code>control.dirty = true; </code></pre> <p>I get this error:</p> <pre><code>Cannot set property dirty of #&lt;AbstractControl&gt; which has only a getter </code></pre>
0debug
flutter's AutomaticKeepAliveClientMixin doesn't keep the page state after navigator.push : <p>was testing AutomaticKeepAliveClientMixin and run into an issue, page loses state after navigator.push anyone knows this issue? any workarounds? be glad for any info, cheers</p> <p>my goal is to keep the page state</p> <p>steps to reproduce: open app click PageOne's push button then go back swipe right and left and the page loses state <a href="https://i.stack.imgur.com/UQKe8.png" rel="noreferrer">image</a></p> <pre><code>import 'package:flutter/material.dart'; void main() =&gt; runApp(MaterialApp(home: MyApp())); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: DefaultTabController( initialIndex: 0, length: 2, child: Scaffold( body: TabBarView( children: &lt;Widget&gt;[Page1(), Page2()], ), bottomNavigationBar: Material( child: TabBar( labelColor: Colors.black, tabs: &lt;Widget&gt;[ Tab( icon: Icon(Icons.check), ), Tab( icon: Icon(Icons.check), ), ], ), ), ), ), ); } } class Page1 extends StatefulWidget { @override Page1State createState() { return new Page1State(); } } class Page1State extends State&lt;Page1&gt; with AutomaticKeepAliveClientMixin { @override Widget build(BuildContext context) { return ListView( children: &lt;Widget&gt;[ Container( height: 300, color: Colors.orange, ), Container( height: 300, color: Colors.pink, ), Container( height: 300, color: Colors.yellow, child: Center( child: Container(height: 26, child: MaterialButton( color: Colors.blue, child: Text('clicking this and back then swipe =&gt; page loses state'), onPressed: () { Navigator.push( context, MaterialPageRoute(builder: (context) =&gt; PushedPage()), ); }), ), ), ), ], ); } @override bool get wantKeepAlive =&gt; true; } class Page2 extends StatelessWidget { @override Widget build(BuildContext context) { return Container(height: 300, color: Colors.orange); } } class PushedPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(), body: Container( color: Colors.blue, ), ); } } </code></pre>
0debug
std::stringstream object unrecognized in std::to_string replacement function : <p>Since std::to_string doesn't work for me, and since I'm working on a very difficult environment at the moment (I'm working on Android using a Linux terminal emulator), I've decided to leave it broken and use a user-made function instead to replace it (I've found it online).</p> <p>Here's the exact code I'm using:</p> <pre><code>#include &lt;sstream&gt; namespace patch { template &lt;typename T&gt; std::string to_string(const T &amp;n); std::stringstream stm; stm &lt;&lt; n; return stm.str(); } } </code></pre> <p>I'm compiling it using these tags:</p> <pre><code>g++ -std=c++11 -g -Wall -Wextra -pedantic </code></pre> <p>And I'm getting these errors:</p> <pre><code>unknown type name 'stm'; did you mean 'tm'? stm &lt;&lt; n; ^~~ </code></pre> <p>(then a note on <code>tm</code> being declared somewhere in <code>include/time.h</code>)</p> <pre><code>expected unqualified-id return stm.str(); ^ </code></pre> <p>And then also an "extraneous closing brace" error for the last brace which closes the namespace brace.</p> <p>As I understand it, it doesn't recognize the line <code>stm &lt;&lt; n;</code> as the method <code>operator &lt;&lt;</code> used on a <code>std::stringstream</code> object, but instead as some variable declariation for some reason.</p> <p>Why exactly am I getting those errors? Is there a way to fix them? If not, what can I use to replace even this solution?</p>
0debug
Unable to change source branch in GitHub Pages : <p>I have created a simple web site for GitHub Pages. The source of the site is in the "master" branch and the generated web site (what I want to see published) is under the "gh-pages" branch.</p> <p><a href="https://i.stack.imgur.com/NQQpR.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NQQpR.png" alt="Branches"></a></p> <p>I was expecting to be able to change the source of the site in the settings. However, the setting is grayed out? I cannot change it (see screenshot below). What am I doing wrong? How do I switch to the "gh-pages" branch?</p> <p><a href="https://i.stack.imgur.com/rwWY9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rwWY9.png" alt="enter image description here"></a></p>
0debug
MongoDB geospatial: how to find if a point is within range from any other point : <p>I'm struggling with completing this query but maybe I'm using the wrong approach. Right now I'm doing it like this:</p> <pre><code>db.cells.find( { loc: { $nearSphere: { $geometry: { type : "Point", coordinates : [ 31.0, 31.0 ] }, $minDistance: 0, $maxDistance: $range } } } ) </code></pre> <p>Here <code>$range</code> should be a field of my document but in a previous answer they told me that there is no option to do that in MongoDB.</p> <p>So I would like to retrieve all the documents where the field <code>loc</code> is a point within distance inferior to field <code>range</code>. Is it possible to do it with a single query? I can restructure the document format if necessary.</p> <p>Thanks</p>
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
static int gdb_breakpoint_remove(CPUState *env, target_ulong addr, target_ulong len, int type) { switch (type) { case GDB_BREAKPOINT_SW: case GDB_BREAKPOINT_HW: return cpu_breakpoint_remove(env, addr, BP_GDB); #ifndef CONFIG_USER_ONLY case GDB_WATCHPOINT_WRITE: case GDB_WATCHPOINT_READ: case GDB_WATCHPOINT_ACCESS: return cpu_watchpoint_remove(env, addr, len, xlat_gdb_type[type]); #endif default: return -ENOSYS; } }
1threat
Split long string into an javascript array using regex : <p>I wish to split a long string into a smaller userID only javascript array, but I can't figure out how to do it.</p> <p>The string looks like this:</p> <pre>22;#Jimmy,, Love,#i:0#.w|towncountry.com\\LoveJimmy,#JLove@towncountry.com,#,#Jimmy,, Love,#,#,#;#334;#Jane Austin,#i:0#.w|towncountry.com\\JAustin,#JAustin@towncountry.com,#,#Jane Austin,#,#,#;#433;#Charlie Clearfolk,#i:0#.w|towncountry.com\\CClearfolk,#CClearfolk@towncountry.com,#,#Charlie Clearfolk,#,#,# </pre> <p>I wish to create an array that contain the userIDs, which are:</p> <pre><code>JLove, JAustin, CClearfolk </code></pre>
0debug
reading data from serial port c# : I'm trying to read char from port. writing to the port works perfectly, reading - not so much. here is my code: private void Com_Port_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { char val; try { val = Convert.ToChar(Com_Port.ReadByte()); // get the new byte from port label6.Text = Convert.ToString(val); } catch (Exception) { } } cracking my head over it for the past 4 hours.
0debug
How to remove old notification channels? : <p>My app now has 3 notification channels, I want to remove 2 of them.<br> I thought simply not registering 2 channels would do the trick but when I open the notification settings on the Android device, the old channels still appear.<br> Is it possible to remove them? They have no use and can confuse the users.</p>
0debug
Why is let=0 valid but not var=0? : <p>Why doesn't</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>let=0</code></pre> </div> </div> </p> <p>show any syntax errors but</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>var=0</code></pre> </div> </div> </p> <p>does? (I test it on Safari)</p> <p>However I tried</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>console.log(let)</code></pre> </div> </div> </p> <p>but it has errors and seems 'let' is not a already defined variable. Why would that happen?</p>
0debug
static int decode_frame_ilbm(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { IffContext *s = avctx->priv_data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; const uint8_t *buf_end = buf+buf_size; int y, plane; if (avctx->reget_buffer(avctx, &s->frame) < 0){ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } for(y = 0; y < avctx->height; y++ ) { uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ]; memset(row, 0, avctx->pix_fmt == PIX_FMT_PAL8 ? avctx->width : (avctx->width * 4)); for (plane = 0; plane < avctx->bits_per_coded_sample && buf < buf_end; plane++) { if (avctx->pix_fmt == PIX_FMT_PAL8) { decodeplane8(row, buf, FFMIN(s->planesize, buf_end - buf), avctx->bits_per_coded_sample, plane); } else { decodeplane32(row, buf, FFMIN(s->planesize, buf_end - buf), avctx->bits_per_coded_sample, plane); } buf += s->planesize; } } *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; return buf_size; }
1threat
static int latm_decode_frame(AVCodecContext *avctx, void *out, int *got_frame_ptr, AVPacket *avpkt) { struct LATMContext *latmctx = avctx->priv_data; int muxlength, err; GetBitContext gb; if ((err = init_get_bits8(&gb, avpkt->data, avpkt->size)) < 0) return err; if (get_bits(&gb, 11) != LOAS_SYNC_WORD) return AVERROR_INVALIDDATA; muxlength = get_bits(&gb, 13) + 3; if (muxlength > avpkt->size) return AVERROR_INVALIDDATA; if ((err = read_audio_mux_element(latmctx, &gb)) < 0) return err; if (!latmctx->initialized) { if (!avctx->extradata) { *got_frame_ptr = 0; return avpkt->size; } else { push_output_configuration(&latmctx->aac_ctx); if ((err = decode_audio_specific_config( &latmctx->aac_ctx, avctx, &latmctx->aac_ctx.oc[1].m4ac, avctx->extradata, avctx->extradata_size*8, 1)) < 0) { pop_output_configuration(&latmctx->aac_ctx); return err; } latmctx->initialized = 1; } } if (show_bits(&gb, 12) == 0xfff) { av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR, "ADTS header detected, probably as result of configuration " "misparsing\n"); return AVERROR_INVALIDDATA; } switch (latmctx->aac_ctx.oc[1].m4ac.object_type) { case AOT_ER_AAC_LC: case AOT_ER_AAC_LTP: case AOT_ER_AAC_LD: case AOT_ER_AAC_ELD: err = aac_decode_er_frame(avctx, out, got_frame_ptr, &gb); break; default: err = aac_decode_frame_int(avctx, out, got_frame_ptr, &gb, avpkt); } if (err < 0) return err; return muxlength; }
1threat
MySQL PHP - Returned column and split it into 2 arrays : <p>I'm using PHP and MySQL to pull some rows from a table. One column is called "item_notes" and this column has a dynamic number of comma-delimited values in it. If I printed 1 row, the column would look something like this: </p> <pre><code>item_1, new_item_1, ** note_1, ** note_2, item_2, ** note_3, old_item_1, new_item2 </code></pre> <p>Is there a way I can split this into 2 arrays using PHP, where 1 array is has only values that start with a ** and the ones that don't go into the other array?</p>
0debug
PhP regex, remove white spaces and all special characters from string : <p>I have a variable $name which can sometimes contain spaces and special characters like '%' '&amp;' etc.how can I remove all of those using regex or in any other way?</p> <pre><code> */ public function handle() { $urls = Business::pluck('ical'); $names = Business::pluck('name'); foreach ($urls as $url) { foreach ($names as $name) { $test= explode("\n", $name); dd($test); $response = Curl::to($url) -&gt;download('ical/'.$name.'.ics'); } </code></pre>
0debug
Trying to make a roblox group payout api. There is something wrong, but what? : >Well, I am working on a roblox group payout API, and if it works I am planning to set it open for public >>Problem: >>>It doesn't show any output, and it doesn't payout anything Before I could start working on this, I first needed to create a manual payout where I got all the POST parameters and headers. Here is what I got: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> METHOD: POST URL: https://web.roblox.com/groups/3182156/one-time-payout/false REQUEST BODY: percentages=%7B%22457792390%22:%221%22%7D HEADERS: User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36 Content-Type: application/x-www-form-urlencoded; charset=UTF-8 referer: https://web.roblox.com/my/groupadmin.aspx?gid=3182156&_=1528631875891 cookie: GuestData=UserID=-608861174; RBXMarketing=FirstHomePageVisit=1; RBXSource=rbx_acquisition_time=6/9/2018 6:18:42 AM&rbx_acquisition_referrer=https://v3rmillion.net/showthread.php?tid=583440&rbx_medium=Direct&rbx_source=v3rmillion.net&rbx_campaign=&rbx_adgroup=&rbx_keyword=&rbx_matchtype=&rbx_send_info=1; rbx-ip=; __utmc=200924205; __utmz=200924205.1528621282.6.4.utmcsr=robuxrewards.site|utmccn=(referral)|utmcmd=referral|utmcct=/; __utma=200924205.428322191.1519910430.1528621282.1528630905.7; RBXImageCache=timg=63313634633937632D393938342D346262642D613663612D333133653130363363373938253231372E3130332E32392E32303925362F31302F323031382031313A34333A303220414D3E2434B19B5881BB5B51486D88F43FC8F5D5787F; __utmt_b=1; gig_hasGmid=ver2; .ROBLOSECURITY=HERE_WAS_A_COOKIE; RBXEventTrackerV2=CreateDate=6/10/2018 6:52:37 AM&rbxid=455629576&browserid=15138233029; __RequestVerificationToken=w6L7tvgTk0c8TeMvuz8QnvVEoF7W7mMxk6UcefoCygoXk97mWkqQGKiLD6XLz5Bssx9FTqkFCzvclhqdrVyww9VcrNY1; RBXSessionTracker=sessionid=a45dce07-ff59-4590-8881-b4200425cf02; __utmb=200924205.11.10.1528630905 <!-- end snippet --> I deleted the `.ROBLOSECURITY` because with that you can login into my account. But that is all the info I got. With the request body: `percentages=%7B%22457792390%22:%221%22%7D`, When I decode that, I get this: `percentages={"457792390":"1"}` That is good, because my user id is `457792390` and the amount I payed out is `1`. So I created a code that should make this work, and make it automatic. Here it is: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> </php // Receive $module = $_GET['module']; $cookie = $_GET['cookie']; $amount = $_GET['amount']; $group_id = $_GET['group_id']; $user_id = $_GET['user_id']; /* https://freewebhost.fun/api.php?module=group_payout&cookie=YOUR_COOKIE_HERE&amount=YOUR_AMOUNT_HERE&group_id=YOUR_GROUP_ID_HERE&user_id=USERNAME_HERE */ // The function function group_payout($cookie, $amount, $group_id, $user_id) { // preset stuff $content_type = "application/x-www-form-urlencoded; charset=UTF-8"; // further $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"https://web.roblox.com/groups/".$group_id."/one-time-payout/false"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "percentages=%7B%22" . $user_id . "%22:%22" . $amount . "%22%7D"); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36"); curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: ".$content_type, "Cookie: .ROBLOSECURITY=".$cookie."; RBXViralAsquisition=time=1/24/2018 11:50:50 AM&referrer=https://www.google.nl/&originatingsite=www.google.nl&viraltarget=945929481; RBXSource=rbx_acquisition_time=6/11/2018 1:47:00 AM&rbx_acquisition_referrer=&rbx_medium=Direct&rbx_source=&rbx_campaign=&rbx_adgroup=&rbx_keyword=&rbx_matchtype=&rbx_send_info=1; __utzm=200924205.1516985949.4.3.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); ")); curl_setopt($ch, CURLOPT_REFERER, 'https://web.roblox.com/my/groupadmin.aspx?gid='.$group_id.'#nav-payouts'); // Lets go curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $server_output = curl_exec ($ch); curl_close ($ch); echo $server_output; } if ($module == "group_payout") { group_payout($cookie, $amount, $group_id, $user_id); } ?> <!-- end snippet --> I really don't know what the problem can be, please tell me if you can help in any way. Thanks!
0debug
void qemu_cond_destroy(QemuCond *cond) { BOOL result; result = CloseHandle(cond->continue_event); if (!result) { error_exit(GetLastError(), __func__); } cond->continue_event = 0; result = CloseHandle(cond->sema); if (!result) { error_exit(GetLastError(), __func__); } cond->sema = 0; }
1threat
VBA data extracting : please help me out to write a VBA to get extract whatsapp contact no Here bellow is URL <https://www.justdial.com/Ahmedabad/Kalon-Laser-Skin-And-Slimming-Across-Shell-Petrol-Pump-Prahladnagar/079PXX79-XX79-171119143016-Q7S9_BZDET?xid=QWhtZWRhYmFkIEJlYXV0eSBQYXJsb3Vycw> there is an hiden whatsapp contact no I want to extract this contact no. here bellow is my code. there is some mistake Public Sub GetValueFromBrowser() Dim Sn As Integer Dim ie As Object Dim url As String Dim Doc As HTMLDocument url = "https://www.justdial.com/Ahmedabad/Kalon-Laser-Skin-And-Slimming-Across-Shell-Petrol-Pump-Prahladnagar/079PXX79-XX79-171119143016-Q7S9_BZDET?xid=QWhtZWRhYmFkIEJlYXV0eSBQYXJsb3Vycw" Set ie = CreateObject("InternetExplorer.Application") With ie .Visible = 0 .navigate url While .Busy Or .readyState <> 4 DoEvents Wend End With Set Doc = ie.document Range("C13") = Trim(Doc.getElementsByID("whatsapptriggeer")(0).Value) End Sub [enter image description here][1] [1]: https://i.stack.imgur.com/5ihUk.jpg
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
Extracting specific parts of a line in a text file using C# : <p>I am making software to help keep track of work hours for volunteers. Right now I have a text file (with the name the same as the volunteer) that I am logging the date and time every time a someone signs in or out, like this:</p> <pre><code>Sign In - 04/04/16 23:51:55 Sign Out - 04/05/16 00:09:48 Sign In - 04/05/16 00:09:55 </code></pre> <p>But what i need to do is extract the date and time so i can say this volunteer worked x amount of hours on this date. This is what i have tried:</p> <pre><code>string datetimeStringDay1In = System.IO.File.ReadLines(@"C:/users/public/Volunteers/" + Form1.selectedUser + ".txt").Skip(23).Take(1).First(); int startPosDay1In = datetimeStringDay1In.LastIndexOf("Sign In - ") + "Sign In - ".Length + 10; int lengthDay1In = datetimeStringDay1In.IndexOf("PM") - startPosDay1In; string SignInDay1 = datetimeStringDay1In.Substring(startPosDay1In, lengthDay1In); </code></pre> <p>Then doing the same for the next signout line, then moving on to doing the math. As I am sure you are already thinking this takes forever to code and limits how many entries I can have. I need a better way. I am willing to try differnet file types as long as i can read the file outside the software incase something goes wrong. At some point I am going to use a database but as of right now this is a proof of concept. After I am able to prove this saves time, money, and for some people hair, I will. Thanks you for your help.</p>
0debug
static void do_sendkey(Monitor *mon, const QDict *qdict) { char keyname_buf[16]; char *separator; int keyname_len, keycode, i, idx; const char *keys = qdict_get_str(qdict, "keys"); int has_hold_time = qdict_haskey(qdict, "hold-time"); int hold_time = qdict_get_try_int(qdict, "hold-time", -1); if (nb_pending_keycodes > 0) { qemu_del_timer(key_timer); release_keys(NULL); } if (!has_hold_time) hold_time = 100; i = 0; while (1) { separator = strchr(keys, '-'); keyname_len = separator ? separator - keys : strlen(keys); if (keyname_len > 0) { pstrcpy(keyname_buf, sizeof(keyname_buf), keys); if (keyname_len > sizeof(keyname_buf) - 1) { monitor_printf(mon, "invalid key: '%s...'\n", keyname_buf); return; } if (i == MAX_KEYCODES) { monitor_printf(mon, "too many keys\n"); return; } if (!strncmp(keyname_buf, "<", 1) && keyname_len == 1) { pstrcpy(keyname_buf, sizeof(keyname_buf), "less"); keyname_len = 4; } keyname_buf[keyname_len] = 0; idx = index_from_key(keyname_buf); if (idx == Q_KEY_CODE_MAX) { monitor_printf(mon, "invalid parameter: %s\n", keyname_buf); return; } keycode = key_defs[idx]; if (keycode < 0) { monitor_printf(mon, "unknown key: '%s'\n", keyname_buf); return; } keycodes[i++] = keycode; } if (!separator) break; keys = separator + 1; } nb_pending_keycodes = i; for (i = 0; i < nb_pending_keycodes; i++) { keycode = keycodes[i]; if (keycode & 0x80) kbd_put_keycode(0xe0); kbd_put_keycode(keycode & 0x7f); } qemu_mod_timer(key_timer, qemu_get_clock_ns(vm_clock) + muldiv64(get_ticks_per_sec(), hold_time, 1000)); }
1threat
How to convert 1D CHW vector<float> to 1D HWC vector<float> in C++ : I would like to know how to convert a 1D vector<float> in format CHW to a 1D vector<float> in format HWC in C++. The format change is needed due to requirements of a neural network.
0debug
Continuous Deployment of a Node.js app to Heroku using GitLab : <p>There are tutorials covering the deployment of Ruby and Python apps but I can't find good documentation or examples for NodeJS. </p> <p><a href="http://docs.gitlab.com/ce/ci/examples/test-and-deploy-python-application-to-heroku.html" rel="noreferrer">http://docs.gitlab.com/ce/ci/examples/test-and-deploy-python-application-to-heroku.html</a></p> <p><a href="http://docs.gitlab.com/ce/ci/examples/test-and-deploy-ruby-application-to-heroku.html" rel="noreferrer">http://docs.gitlab.com/ce/ci/examples/test-and-deploy-ruby-application-to-heroku.html</a></p> <p>Does anyone have a <code>.gitlab-ci.yml</code> to share? </p>
0debug
My Strlen Syntax Not Written Well? : <p>if I write more than 20 charcters in my program it runs through it and skips my if statement if(length > 20). What did I do wrong? </p> <pre><code>printf("\nEnter Your Product:"); fgets(item_name, 20, stdin); length = strlen(item_name); if(length &gt; 20){ Errorlevel("Input Greater Than 20"); } </code></pre>
0debug
Android Certifications Recognized : <p>I am working as an Android developer for already more than 1 year and I was wondering, if there exists any Android certifications well-known as those from Oracle,Microsoft or Cisco ?</p>
0debug
static void render_slice(Vp3DecodeContext *s, int slice) { int x, y, i, j, fragment; LOCAL_ALIGNED_16(DCTELEM, block, [64]); int motion_x = 0xdeadbeef, motion_y = 0xdeadbeef; int motion_halfpel_index; uint8_t *motion_source; int plane, first_pixel; if (slice >= s->c_superblock_height) return; for (plane = 0; plane < 3; plane++) { uint8_t *output_plane = s->current_frame.data [plane] + s->data_offset[plane]; uint8_t * last_plane = s-> last_frame.data [plane] + s->data_offset[plane]; uint8_t *golden_plane = s-> golden_frame.data [plane] + s->data_offset[plane]; int stride = s->current_frame.linesize[plane]; int plane_width = s->width >> (plane && s->chroma_x_shift); int plane_height = s->height >> (plane && s->chroma_y_shift); int8_t (*motion_val)[2] = s->motion_val[!!plane]; int sb_x, sb_y = slice << (!plane && s->chroma_y_shift); int slice_height = sb_y + 1 + (!plane && s->chroma_y_shift); int slice_width = plane ? s->c_superblock_width : s->y_superblock_width; int fragment_width = s->fragment_width[!!plane]; int fragment_height = s->fragment_height[!!plane]; int fragment_start = s->fragment_start[plane]; int do_await = !plane && HAVE_THREADS && (s->avctx->active_thread_type&FF_THREAD_FRAME); if (!s->flipped_image) stride = -stride; if (CONFIG_GRAY && plane && (s->avctx->flags & CODEC_FLAG_GRAY)) continue; for (; sb_y < slice_height; sb_y++) { for (sb_x = 0; sb_x < slice_width; sb_x++) { for (j = 0; j < 16; j++) { x = 4*sb_x + hilbert_offset[j][0]; y = 4*sb_y + hilbert_offset[j][1]; fragment = y*fragment_width + x; i = fragment_start + fragment; if (x >= fragment_width || y >= fragment_height) continue; first_pixel = 8*y*stride + 8*x; if (do_await && s->all_fragments[i].coding_method != MODE_INTRA) await_reference_row(s, &s->all_fragments[i], motion_val[fragment][1], (16*y) >> s->chroma_y_shift); if (s->all_fragments[i].coding_method != MODE_COPY) { if ((s->all_fragments[i].coding_method == MODE_USING_GOLDEN) || (s->all_fragments[i].coding_method == MODE_GOLDEN_MV)) motion_source= golden_plane; else motion_source= last_plane; motion_source += first_pixel; motion_halfpel_index = 0; if ((s->all_fragments[i].coding_method > MODE_INTRA) && (s->all_fragments[i].coding_method != MODE_USING_GOLDEN)) { int src_x, src_y; motion_x = motion_val[fragment][0]; motion_y = motion_val[fragment][1]; src_x= (motion_x>>1) + 8*x; src_y= (motion_y>>1) + 8*y; motion_halfpel_index = motion_x & 0x01; motion_source += (motion_x >> 1); motion_halfpel_index |= (motion_y & 0x01) << 1; motion_source += ((motion_y >> 1) * stride); if(src_x<0 || src_y<0 || src_x + 9 >= plane_width || src_y + 9 >= plane_height){ uint8_t *temp= s->edge_emu_buffer; if(stride<0) temp -= 8*stride; s->dsp.emulated_edge_mc(temp, motion_source, stride, 9, 9, src_x, src_y, plane_width, plane_height); motion_source= temp; } } if (s->all_fragments[i].coding_method != MODE_INTRA) { if(motion_halfpel_index != 3){ s->dsp.put_no_rnd_pixels_tab[1][motion_halfpel_index]( output_plane + first_pixel, motion_source, stride, 8); }else{ int d= (motion_x ^ motion_y)>>31; s->dsp.put_no_rnd_pixels_l2[1]( output_plane + first_pixel, motion_source - d, motion_source + stride + 1 + d, stride, 8); } } s->dsp.clear_block(block); if (s->all_fragments[i].coding_method == MODE_INTRA) { int index; index = vp3_dequant(s, s->all_fragments + i, plane, 0, block); if (index > 63) continue; if(s->avctx->idct_algo!=FF_IDCT_VP3) block[0] += 128<<3; s->dsp.idct_put( output_plane + first_pixel, stride, block); } else { int index = vp3_dequant(s, s->all_fragments + i, plane, 1, block); if (index > 63) continue; if (index > 0) { s->dsp.idct_add( output_plane + first_pixel, stride, block); } else { s->dsp.vp3_idct_dc_add(output_plane + first_pixel, stride, block); } } } else { s->dsp.put_pixels_tab[1][0]( output_plane + first_pixel, last_plane + first_pixel, stride, 8); } } } if (!s->skip_loop_filter) apply_loop_filter(s, plane, 4*sb_y - !!sb_y, FFMIN(4*sb_y+3, fragment_height-1)); } } vp3_draw_horiz_band(s, FFMIN((32 << s->chroma_y_shift) * (slice + 1) -16, s->height-16)); }
1threat
static void test_visitor_in_alternate_number(TestInputVisitorData *data, const void *unused) { Visitor *v; Error *err = NULL; AltStrBool *asb; AltStrNum *asn; AltNumStr *ans; AltStrInt *asi; AltIntNum *ain; AltNumInt *ani; v = visitor_input_test_init(data, "42"); visit_type_AltStrBool(v, &asb, NULL, &err); g_assert(err); error_free(err); err = NULL; qapi_free_AltStrBool(asb); visitor_input_teardown(data, NULL); v = visitor_input_test_init(data, "42"); visit_type_AltStrNum(v, &asn, NULL, &err); g_assert(err); error_free(err); err = NULL; qapi_free_AltStrNum(asn); visitor_input_teardown(data, NULL); v = visitor_input_test_init(data, "42"); visit_type_AltNumStr(v, &ans, NULL, &error_abort); g_assert_cmpint(ans->kind, ==, ALT_NUM_STR_KIND_N); g_assert_cmpfloat(ans->n, ==, 42); qapi_free_AltNumStr(ans); visitor_input_teardown(data, NULL); v = visitor_input_test_init(data, "42"); visit_type_AltStrInt(v, &asi, NULL, &error_abort); g_assert_cmpint(asi->kind, ==, ALT_STR_INT_KIND_I); g_assert_cmpint(asi->i, ==, 42); qapi_free_AltStrInt(asi); visitor_input_teardown(data, NULL); v = visitor_input_test_init(data, "42"); visit_type_AltIntNum(v, &ain, NULL, &error_abort); g_assert_cmpint(ain->kind, ==, ALT_INT_NUM_KIND_I); g_assert_cmpint(ain->i, ==, 42); qapi_free_AltIntNum(ain); visitor_input_teardown(data, NULL); v = visitor_input_test_init(data, "42"); visit_type_AltNumInt(v, &ani, NULL, &error_abort); g_assert_cmpint(ani->kind, ==, ALT_NUM_INT_KIND_I); g_assert_cmpint(ani->i, ==, 42); qapi_free_AltNumInt(ani); visitor_input_teardown(data, NULL); v = visitor_input_test_init(data, "42.5"); visit_type_AltStrBool(v, &asb, NULL, &err); g_assert(err); error_free(err); err = NULL; qapi_free_AltStrBool(asb); visitor_input_teardown(data, NULL); v = visitor_input_test_init(data, "42.5"); visit_type_AltStrNum(v, &asn, NULL, &error_abort); g_assert_cmpint(asn->kind, ==, ALT_STR_NUM_KIND_N); g_assert_cmpfloat(asn->n, ==, 42.5); qapi_free_AltStrNum(asn); visitor_input_teardown(data, NULL); v = visitor_input_test_init(data, "42.5"); visit_type_AltNumStr(v, &ans, NULL, &error_abort); g_assert_cmpint(ans->kind, ==, ALT_NUM_STR_KIND_N); g_assert_cmpfloat(ans->n, ==, 42.5); qapi_free_AltNumStr(ans); visitor_input_teardown(data, NULL); v = visitor_input_test_init(data, "42.5"); visit_type_AltStrInt(v, &asi, NULL, &err); g_assert(err); error_free(err); err = NULL; qapi_free_AltStrInt(asi); visitor_input_teardown(data, NULL); v = visitor_input_test_init(data, "42.5"); visit_type_AltIntNum(v, &ain, NULL, &error_abort); g_assert_cmpint(ain->kind, ==, ALT_INT_NUM_KIND_N); g_assert_cmpfloat(ain->n, ==, 42.5); qapi_free_AltIntNum(ain); visitor_input_teardown(data, NULL); v = visitor_input_test_init(data, "42.5"); visit_type_AltNumInt(v, &ani, NULL, &error_abort); g_assert_cmpint(ani->kind, ==, ALT_NUM_INT_KIND_N); g_assert_cmpfloat(ani->n, ==, 42.5); qapi_free_AltNumInt(ani); visitor_input_teardown(data, NULL); }
1threat
static void ppc_hash64_set_dsi(CPUState *cs, CPUPPCState *env, uint64_t dar, uint64_t dsisr) { bool vpm; if (msr_dr) { vpm = !!(env->spr[SPR_LPCR] & LPCR_VPM1); } else { vpm = !!(env->spr[SPR_LPCR] & LPCR_VPM0); } if (vpm && !msr_hv) { cs->exception_index = POWERPC_EXCP_HDSI; env->spr[SPR_HDAR] = dar; env->spr[SPR_HDSISR] = dsisr; } else { cs->exception_index = POWERPC_EXCP_DSI; env->spr[SPR_DAR] = dar; env->spr[SPR_DSISR] = dsisr; } env->error_code = 0; }
1threat
Kotlin quadruple, quintuple, etc. for destructuring : <p>I am looking for a clean way to create destructurable objects in-line. <code>kotlin.Pair</code> and <code>kotlin.Triple</code> cover a lot of use cases, but sometimes there are more objects that are needed to be passed.</p> <p>One sample use case is RX's <code>zip</code> function, where the results of several I/O calls need to be mapped into another object:</p> <pre><code>Single .zip(repositoryA.loadData(someId), repositoryB.loadData(someId), repositoryC.loadAll(), repositoryD.loadAll()), { objectA, objectB, objectsC, objectsD -&gt; /*some Kotlin magic*/ } ) .map { (objectA, objectB, objectsC, objectsD) -&gt; /*do the mapping*/ } </code></pre> <p>I am trying to figure out what would go in the "some Kotlin magic" part. If there were only 3 repositories, it would be</p> <pre><code>Triple(objectA, objectB, objectsC) </code></pre> <p>Do I need to create a new data class for this, and for any n-tuple case, or is there another way?</p>
0debug
How to execute for loop between two numbers? : <p>I want to execute reverse for loop between two numbers.</p> <pre><code>for($m = 5 - 1; $m &gt;= 0; $m--){ echo $m . '&lt;br /&gt;'; } </code></pre> <p>Output </p> <pre><code>4 3 2 1 0 </code></pre> <p>Now how can i get below out put</p> <pre><code>9 8 7 6 5 </code></pre> <p>I would like to appreciate if someone help me.</p>
0debug
static void init_filter_param(AVFilterContext *ctx, FilterParam *fp, const char *effect_type, int width) { int z; const char *effect; effect = fp->amount == 0 ? "none" : fp->amount < 0 ? "blur" : "sharpen"; av_log(ctx, AV_LOG_VERBOSE, "effect:%s type:%s msize_x:%d msize_y:%d amount:%0.2f\n", effect, effect_type, fp->msize_x, fp->msize_y, fp->amount / 65535.0); for (z = 0; z < 2 * fp->steps_y; z++) fp->sc[z] = av_malloc(sizeof(*(fp->sc[z])) * (width + 2 * fp->steps_x)); }
1threat
Vba excel 2013 returning zero when executing rng.value="" : Function Delete_UDF(rng) ThisWorkbook.Application.Volatile rng.Value = "" End Function this is returning zero , anyone knows why?
0debug
static void virtio_pci_vmstate_change(DeviceState *d, bool running) { VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d); VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); if (running) { if ((vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) && !(proxy->pci_dev.config[PCI_COMMAND] & PCI_COMMAND_MASTER)) { proxy->flags |= VIRTIO_PCI_FLAG_BUS_MASTER_BUG; } virtio_pci_start_ioeventfd(proxy); } else { virtio_pci_stop_ioeventfd(proxy); } }
1threat
static uint32_t dma_rinvalid (void *opaque, target_phys_addr_t addr) { hw_error("Unsupported short raccess. reg=" TARGET_FMT_plx "\n", addr); return 0; }
1threat
static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *dst2, long dstWidth, const uint8_t *src1, const uint8_t *src2, int srcW, int xInc) { int32_t *filterPos = c->hChrFilterPos; int16_t *filter = c->hChrFilter; int canMMX2BeUsed = c->canMMX2BeUsed; void *mmx2FilterCode= c->chrMmx2FilterCode; int i; #if defined(PIC) DECLARE_ALIGNED(8, uint64_t, ebxsave); #endif __asm__ volatile( #if defined(PIC) "mov %%"REG_b", %7 \n\t" #endif "pxor %%mm7, %%mm7 \n\t" "mov %0, %%"REG_c" \n\t" "mov %1, %%"REG_D" \n\t" "mov %2, %%"REG_d" \n\t" "mov %3, %%"REG_b" \n\t" "xor %%"REG_a", %%"REG_a" \n\t" PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE "xor %%"REG_a", %%"REG_a" \n\t" "mov %5, %%"REG_c" \n\t" "mov %6, %%"REG_D" \n\t" PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE #if defined(PIC) "mov %7, %%"REG_b" \n\t" #endif :: "m" (src1), "m" (dst1), "m" (filter), "m" (filterPos), "m" (mmx2FilterCode), "m" (src2), "m"(dst2) #if defined(PIC) ,"m" (ebxsave) #endif : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D #if !defined(PIC) ,"%"REG_b #endif ); for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) { dst1[i] = src1[srcW-1]*128; dst2[i] = src2[srcW-1]*128; } }
1threat
How to mock RestTemplate in Java Spring? : <pre><code>public class ServiceTest { @Mock RestTemplate restTemplate = new RestTemplate(); @InjectMocks Service service = new Service(); ResponseEntity responseEntity = mock(ResponseEntity.class); @Test public void test() throws Exception { Mockito.when(restTemplate.getForEntity( Mockito.anyString(), Matchers.any(Class.class) )) .thenReturn(responseEntity); boolean res = service.isEnabled("something"); Assert.assertEquals(res, false); } </code></pre> <p>I tried to test a simple test for a service including a restclient. It looks I have not Mock the <code>RestTemplate</code> successfully. It looks like the code get the real data not the mock one. Anyone can help me with this.</p> <p>The service itself will looks as this:</p> <pre><code>public class Service{ public boolean isEnabled(String xxx) { RestTemplate restTemplate = new RestTemplate(); ResponseEntity&lt;String&gt; response = restTemplate.getForEntity("someurl",String.class); if(...)return true; return false; } } </code></pre>
0debug
void pit_set_gate(PITState *pit, int channel, int val) { PITChannelState *s = &pit->channels[channel]; switch(s->mode) { default: case 0: case 4: break; case 1: case 5: if (s->gate < val) { s->count_load_time = qemu_get_clock(vm_clock); pit_irq_timer_update(s, s->count_load_time); } break; case 2: case 3: if (s->gate < val) { s->count_load_time = qemu_get_clock(vm_clock); pit_irq_timer_update(s, s->count_load_time); } break; } s->gate = val; }
1threat
static av_always_inline void put_h264_qpel8or16_hv1_lowpass_sse2(int16_t *tmp, uint8_t *src, int tmpStride, int srcStride, int size){ int w = (size+8)>>3; src -= 2*srcStride+2; while(w--){ __asm__ volatile( "pxor %%xmm7, %%xmm7 \n\t" "movq (%0), %%xmm0 \n\t" "add %2, %0 \n\t" "movq (%0), %%xmm1 \n\t" "add %2, %0 \n\t" "movq (%0), %%xmm2 \n\t" "add %2, %0 \n\t" "movq (%0), %%xmm3 \n\t" "add %2, %0 \n\t" "movq (%0), %%xmm4 \n\t" "add %2, %0 \n\t" "punpcklbw %%xmm7, %%xmm0 \n\t" "punpcklbw %%xmm7, %%xmm1 \n\t" "punpcklbw %%xmm7, %%xmm2 \n\t" "punpcklbw %%xmm7, %%xmm3 \n\t" "punpcklbw %%xmm7, %%xmm4 \n\t" QPEL_H264HV_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, 0*48) QPEL_H264HV_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, 1*48) QPEL_H264HV_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, 2*48) QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 3*48) QPEL_H264HV_XMM(%%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, 4*48) QPEL_H264HV_XMM(%%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, 5*48) QPEL_H264HV_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, 6*48) QPEL_H264HV_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, 7*48) "cmpl $16, %3 \n\t" "jne 2f \n\t" QPEL_H264HV_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, 8*48) QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 9*48) QPEL_H264HV_XMM(%%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, 10*48) QPEL_H264HV_XMM(%%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, 11*48) QPEL_H264HV_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, 12*48) QPEL_H264HV_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, 13*48) QPEL_H264HV_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, 14*48) QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 15*48) "2: \n\t" : "+a"(src) : "c"(tmp), "S"((x86_reg)srcStride), "g"(size) : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7",) "memory" ); tmp += 8; src += 8 - (size+5)*srcStride; } }
1threat
C# thread with multiple methods : <p>I'm making an app that manages a library. Currently I'm making the code for the research of the books and I've just come across an issue. I've created a Thread that handles this research, in addition to the one that handles the rest of the execution. I was asking to my self, is it possible that a Thread manages multiple methods? If so how can you do that, as you can only put one method in the declaration of the Thread. For example, when the user presses the search button (in a menubox) I only want the app (through my researchThread) to go to the url, running a goToUrl() method. Then, when the user presses the search button (after writing the keyWord of the book) I want the same thread to run another method (the search() method). As I don't want to create a thousand threads for every function (and as I think that this isn't the right solution), how can I manage this situation? Thanks in advance.</p>
0debug
static int rac_get_model_sym(RangeCoder *c, Model *m) { int prob, prob2, helper, val; int end, end2; prob = 0; prob2 = c->range; c->range >>= MODEL_SCALE; val = 0; end = m->num_syms >> 1; end2 = m->num_syms; do { helper = m->freqs[end] * c->range; if (helper <= c->low) { val = end; prob = helper; } else { end2 = end; prob2 = helper; } end = (end2 + val) >> 1; } while (end != val); c->low -= prob; c->range = prob2 - prob; if (c->range < RAC_BOTTOM) rac_normalise(c); model_update(m, val); return val; }
1threat
Unit test on Kotlin Extension Function on Android SDK Classes : <p>Kotlin extension function is great. But how could I perform unit test on them? Especially those that is of Android SDK provided class (e.g. Context, Dialog).</p> <p>I provide two examples below, and if anyone could share how I could unit test them, or if I need to write them differently if I really want to unit test them.</p> <pre><code>fun Context.getColorById(colorId: Int): Int { if (Build.VERSION.SDK_INT &gt;= 23) return ContextCompat.getColor(this, colorId) else return resources.getColor(colorId) } </code></pre> <p>and </p> <pre><code>fun Dialog.setupErrorDialog(body : String, onOkFunc: () -&gt; Unit = {}): Dialog { window.requestFeature(Window.FEATURE_NO_TITLE) this.setContentView(R.layout.dialog_error_layout) (findViewById(R.id.txt_body) as TextView).text = body (findViewById(R.id.txt_header) as TextView).text = context.getString(R.string.dialog_title_error) (findViewById(R.id.txt_okay)).setOnClickListener{ onOkFunc() dismiss() } return this } </code></pre> <p>Any suggestion would help. Thanks!</p>
0debug
static void trigger_page_fault(CPUS390XState *env, target_ulong vaddr, uint32_t type, uint64_t asc, int rw, bool exc) { int ilen = ILEN_LATER; uint64_t tec; tec = vaddr | (rw == MMU_DATA_STORE ? FS_WRITE : FS_READ) | asc >> 46; DPRINTF("%s: trans_exc_code=%016" PRIx64 "\n", __func__, tec); if (!exc) { return; } if (rw == MMU_INST_FETCH) { ilen = 2; } trigger_access_exception(env, type, ilen, tec); }
1threat
static void ide_cfata_identify(IDEState *s) { uint16_t *p; uint32_t cur_sec; p = (uint16_t *) s->identify_data; if (s->identify_set) goto fill_buffer; memset(p, 0, sizeof(s->identify_data)); cur_sec = s->cylinders * s->heads * s->sectors; put_le16(p + 0, 0x848a); put_le16(p + 1, s->cylinders); put_le16(p + 3, s->heads); put_le16(p + 6, s->sectors); put_le16(p + 7, s->nb_sectors >> 16); put_le16(p + 8, s->nb_sectors); padstr((char *)(p + 10), s->drive_serial_str, 20); put_le16(p + 22, 0x0004); padstr((char *) (p + 23), s->version, 8); padstr((char *) (p + 27), "QEMU MICRODRIVE", 40); #if MAX_MULT_SECTORS > 1 put_le16(p + 47, 0x8000 | MAX_MULT_SECTORS); #else put_le16(p + 47, 0x0000); #endif put_le16(p + 49, 0x0f00); put_le16(p + 51, 0x0002); put_le16(p + 52, 0x0001); put_le16(p + 53, 0x0003); put_le16(p + 54, s->cylinders); put_le16(p + 55, s->heads); put_le16(p + 56, s->sectors); put_le16(p + 57, cur_sec); put_le16(p + 58, cur_sec >> 16); if (s->mult_sectors) put_le16(p + 59, 0x100 | s->mult_sectors); put_le16(p + 60, s->nb_sectors); put_le16(p + 61, s->nb_sectors >> 16); put_le16(p + 63, 0x0203); put_le16(p + 64, 0x0001); put_le16(p + 65, 0x0096); put_le16(p + 66, 0x0096); put_le16(p + 68, 0x00b4); put_le16(p + 82, 0x400c); put_le16(p + 83, 0x7068); put_le16(p + 84, 0x4000); put_le16(p + 85, 0x000c); put_le16(p + 86, 0x7044); put_le16(p + 87, 0x4000); put_le16(p + 91, 0x4060); put_le16(p + 129, 0x0002); put_le16(p + 130, 0x0005); put_le16(p + 131, 0x0001); put_le16(p + 132, 0x0000); put_le16(p + 160, 0x8100); put_le16(p + 161, 0x8001); s->identify_set = 1; fill_buffer: memcpy(s->io_buffer, p, sizeof(s->identify_data)); }
1threat
static void test_qga_guest_exec(gconstpointer fix) { const TestFixture *fixture = fix; QDict *ret, *val; const gchar *out; guchar *decoded; int64_t pid, now, exitcode; gsize len; bool exited; ret = qmp_fd(fixture->fd, "{'execute': 'guest-exec', 'arguments': {" " 'path': '/bin/echo', 'arg': [ '-n', '\" test_str \"' ]," " 'capture-output': true } }"); g_assert_nonnull(ret); qmp_assert_no_error(ret); val = qdict_get_qdict(ret, "return"); pid = qdict_get_int(val, "pid"); g_assert_cmpint(pid, >, 0); QDECREF(ret); now = g_get_monotonic_time(); do { ret = qmp_fd(fixture->fd, "{'execute': 'guest-exec-status'," " 'arguments': { 'pid': %" PRId64 " } }", pid); g_assert_nonnull(ret); val = qdict_get_qdict(ret, "return"); exited = qdict_get_bool(val, "exited"); if (!exited) { QDECREF(ret); } } while (!exited && g_get_monotonic_time() < now + 5 * G_TIME_SPAN_SECOND); g_assert(exited); exitcode = qdict_get_int(val, "exitcode"); g_assert_cmpint(exitcode, ==, 0); out = qdict_get_str(val, "out-data"); decoded = g_base64_decode(out, &len); g_assert_cmpint(len, ==, 12); g_assert_cmpstr((char *)decoded, ==, "\" test_str \""); g_free(decoded); QDECREF(ret); }
1threat
How to get a daily mean : <p>I got the following question. Currently I am working with RStudio and i want to get a daily mean, however I just started to learn Rstudio and don't know how to continue...</p> <p>my data set looks like this:</p> <ol> <li>row (day): 2019-12-01; 2019-12-01; 2019-12-02; 2019-12-02; 2019-12-02; 2019-12-03;.....</li> <li>row (value): 1; 2; 3; 1; 3; 3; 1;...</li> </ol> <p>And i want my dataset to look like this:</p> <ol> <li>row (day): 2019-12-01; 2019-12-02; 2019-12-03;.....</li> <li>row (average_value): 1; 2; 3;....</li> </ol> <p>Which Code do I need to get it like that? Can someone help me? Thank you very much!!</p>
0debug
static BlockAIOCB *hdev_aio_ioctl(BlockDriverState *bs, unsigned long int req, void *buf, BlockCompletionFunc *cb, void *opaque) { BDRVRawState *s = bs->opaque; RawPosixAIOData *acb; ThreadPool *pool; if (fd_open(bs) < 0) return NULL; acb = g_new(RawPosixAIOData, 1); acb->bs = bs; acb->aio_type = QEMU_AIO_IOCTL; acb->aio_fildes = s->fd; acb->aio_offset = 0; acb->aio_ioctl_buf = buf; acb->aio_ioctl_cmd = req; pool = aio_get_thread_pool(bdrv_get_aio_context(bs)); return thread_pool_submit_aio(pool, aio_worker, acb, cb, opaque);
1threat
How can I print a PID in Elixir? : <p>I tried to: </p> <pre><code>pid = spawn fn -&gt; 1 + 2 end IO.puts(pid) IO.puts(IO.inspect(pid)) </code></pre> <p>and both given a</p> <pre><code>** (Protocol.UndefinedError) protocol String.Chars not implemented for #PID&lt;0.59.0&gt; </code></pre> <p>There must be a way to get the "#PID&lt;0.59.0>" representation of the <code>pid</code>, since the REPL prints that <code>#PID&lt;0.59.0&gt;</code>. </p>
0debug
Angular 5 Jasmine Error: Expected one matching request for criteria found none : <p>I have a very simple service call and a jasmine test for it. </p> <p>Service call:</p> <pre><code>myServiceCall(testId: number) : void { const url = `${this.url}/paramX/${testId}`; this.http.put(url, {},{headers: this.headers}).subscribe(); } </code></pre> <p>My Test Method:</p> <pre><code>it('should call myServiceCall', inject([MyService], (service: MyService) =&gt; { let testId = undefined; service.myServiceCall(testId); let req = httpMock.expectOne(environment.baseUrl + "/paramX/123"); expect(req.request.url).toBe(environment.baseUrl + "/paramX/123"); expect(req.request.body).toEqual({}); req.flush({}); httpMock.verify(); })); </code></pre> <p>I get of course an exception as I expect the url parameter to be "123"and not undefined like in this test case scenario.</p> <blockquote> <p>Error: Expected one matching request for criteria "Match URL: <a href="http://localhost:8080/myservice/paramX/123" rel="noreferrer">http://localhost:8080/myservice/paramX/123</a>", found none.</p> </blockquote> <p>What I don't understand is why the test framework says </p> <blockquote> <p>found none</p> </blockquote> <p>although the request is made. Is there any possibility to let the test framework tell me what <strong>other actual calls were made</strong>, similar to mockito's verify?</p>
0debug
Replace hexadecimal subset with spaces in string : My string is `'MRK\xa0Software\xa0Services\xa0Private\xa0Limited'` and I want to replace the hexadecimal part (`\xa`) with spaces, such that I get `MRK Software Services Private Limited`
0debug
How to Insert background color in existing mp4 using Android programatically : I have a mp4 file, where the video is having the background color as a solid color like white/green/blue. with that background, a video is recorded. I want to change the background color. Please let me know how to change the color programatically using Android.
0debug
Is this possible to install node-sass offline proxy : <p>I'm trying to install node-sass module using npm but each time an error displayed about a problem in network configuration that's because i'm using proxy and private registry this is the error : </p> <pre><code>This is most likely not a problem with node-gyp or the package itself and is related to network connectivity In most cases you are behind a proxy or have bad network setting </code></pre> <p><a href="https://i.stack.imgur.com/KFMFf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/KFMFf.png" alt="enter image description here"></a></p> <p>Is it possible to install this module offline ? </p>
0debug