problem
stringlengths
26
131k
labels
class label
2 classes
static inline void RENAME(yuy2ToY)(uint8_t *dst, uint8_t *src, int width) { #ifdef HAVE_MMXFIXME #else int i; for(i=0; i<width; i++) dst[i]= src[2*i]; #endif }
1threat
Undefined member variable : <p>I've created following class:</p> <pre><code>class NotFoundException extends Exception {} class Foo{ private $path; private $array; public static function load($name) { try { return new Foo($name); } catch (NotFoundException $unfe) { return null; } } public function __construct($name){ if (true){ $this-&gt;$path = 'public_html/'.$name.'/'; $this-&gt;$array= array('1','2','3'); } else throw new NotFoundException(); } public function getArray(){ return $this-&gt;$array; } } $foo = Foo::load('first'); print_r($foo-&gt;getArray()); </code></pre> <p>When I run my code, I get<br> <strong>NOTICE</strong> Undefined variable: <em>path on line number 18</em><br> <strong>FATAL ERROR</strong> Uncaught Error: <em>Cannot access empty property</em> </p> <p>I have no idea what is causing the problem.</p>
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
Is it possible to invert the order errors are displayed? : <p>When compiling a faulty program with GHC, errors are displayed in ascending line order. That causes the first errors to get pushed up the console, so you need to scroll up if you work by fixing the first errors first, which may be annoying. Is it possible to ask GHC to print errors in descending line order?</p>
0debug
Efficient string matching in Apache Spark : <p>Using an OCR tool I extracted texts from screenshots (about 1-5 sentences each). However, when manually verifying the extracted text, I noticed several errors that occur from time to time.</p> <p>Given the text "Hello there 😊! I really like Spark ❤️!", I noticed that:</p> <p>1) Letters like "I", "!", and "l" get replaced by "|".</p> <p>2) Emojis are not correctly extracted and replaced by other characters or are left out.</p> <p>3) Blank spaces are removed from time to time.</p> <p>As a result, I might end up with a string like this: "Hello there 7l | real|y like Spark!"</p> <p>Since I am trying to match these string against a dataset including the correct text (in thise case "Hello there 😊! I really like Spark ❤️!"), I am looking for an efficient way how to match the string in Spark.</p> <p>Can anyone suggest an efficient algorithm for Spark which allows me to compare the extract texts (~100.000) against my dataset (~100 million)?</p>
0debug
Create own widget in C# and add to Table : <p>I learning to create android app in C# (VisualStudio) and I need create table with my own widget. I upload data for my server SQL. Any idea how can I do this?</p> <p><a href="https://i.stack.imgur.com/3290t.png" rel="nofollow noreferrer">Presentation</a></p>
0debug
MATLAB how to query a name in google : <p>In MATLAB, we have table of movie information as follows:</p> <pre><code> movieId title genres _______ __________________ ___________________________ 10 'GoldenEye (1995)' 'Action|Adventure|Thriller' </code></pre> <p>The table contains many rows with many movie informarion.</p> <p><strong>Questions :</strong></p> <ul> <li><p>I would like to obtain some statistics about year distribution of movies. How can I do this with/without using loops. That is suggest a code please that extracts the years for all movies in the table (e.g. using regexp() etc.). All the years are with the partheneses.</p></li> <li><p>Another interesting question is for a given title (in this case 'GoldenEye') would it be possible to query that title in Google and obtain the resulting wikipedia page if it there exists. Once sucessful, I would like to import all the text in the wikipage. </p></li> </ul>
0debug
how to auto create new app in Google Play by API : <p><strong>Hi</strong>,</p> <p>I have to build many app from one source frequently.</p> <p>So i want to create new app auto in Google Play by API for convenient, and after that i will use Supply mobile in <a href="https://fastlane.tools/" rel="nofollow">Fastlane</a> to upload metadata.</p> <p>Anyone can help me solve this case :) Thanks for your investigating!</p>
0debug
Cannot invoke initializer for type 'Range<String.Index>' with an argument list of type '(Range<String.Index>)' : <p>After updating to Xcode 10 beta, which apparently comes with Swift 4.1.50, I'm seeing the following error which I'm not sure how to fix:</p> <blockquote> <p>Cannot invoke initializer for type 'Range&lt; String.Index>' with an argument list of type '(Range&lt; String.Index>)'</p> </blockquote> <p>in the following function at <code>Range&lt;Index&gt;(start..&lt;self.endIndex)</code> (line 3):</p> <pre><code>func index(of aString: String, startingFrom position: Int? = 0) -&gt; String.Index? { let start: String.Index = self.index(self.startIndex, offsetBy: position!) let range: Range&lt;Index&gt; = Range&lt;Index&gt;(start..&lt;self.endIndex) return self.range(of: aString, options: .literal, range: range, locale: nil)?.lowerBound } </code></pre> <p>Any idea how to fix the initializer?</p>
0debug
Html Website Going Crazy when Z00Med out : idk why but when I zoom out of my website, the code seems to fall apart and the whole thing just looks disgusting. I've checked out other answers to this question but NONE of the solutions really tailor towards MY code. Also im new to html so please understand :) AND NO ONE SEEMS TO BE ABLE TO SOLVE IT :((((((((( THIS WEBSITE IS DUE IN A COUPLE OF DAYS SO PLEASE HELP <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-css --> body { background-image: url(gradient.png); background-repeat: no-repeat; background-size: cover; } h1.heading { color: #046289; font-size: 50px; margin-top: 100px; text-align: center; font-family: 'Poppins', sans-serif; } p.heading { color: #046289; font-family: 'Poppins', sans-serif; font-size: 20.8px; font-weight: 600; position: relative; margin-left: 70px; top: 60px; } p.heading1 { color: #046289; font-family: 'Poppins', sans-serif; font-weight: 400; position: relative; margin-left: 70px; top: 50px; } img.aml { width:280px; height:280px; position: absolute; margin-left: 360px; bottom: 30px; } iframe.livevid { position: absolute; margin-left: 840px; } p.vid { color: #046289; font-family: 'Poppins', sans-serif; font-size: 20.8px; font-weight: 600; position: absolute; margin-left: 840px; top: 313px; } p.vid1 { color: #046289; font-family: 'Poppins', sans-serif; font-weight: 400; position: absolute; margin-left: 840px; top: 363px; } a { text-decoration: none; } p a:link { color: #4204a5; } p a:visited { color: #4204a5; } p a:hover { color: #71a3f2; } /* BELOW - NAVIGATION BAR */ ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; width: 100%; } li { float: left; } .spacefornav { margin-left: 462px; } li a:hover { color: #71a3f2; } div.nav { color: #046289; } li a { display: inline-block; color: #046289; text-align: center; padding: 8px 10px; text-decoration: none; font-family: 'Poppins'; sans-serif; margin: 0px 20px; font-weight: 500; cursor: pointer; } <!-- language: lang-html --> <!DOCTYPE html> <html lang="en-US"> <head> <title>Childish Gambino</title> <meta charset="UTF-8"> <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' /> <link href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700&amp;subset=devanagari,latin-ext" rel="stylesheet"> <link rel="stylesheet" type="text/css" href="stylesheet.css"> </head> <body> <h1 class="heading">CHILDISH GAMBINO</h1> <ul> <div class="nav"> <li class="spacefornav"><a href="home.html">Home</a></li> <li><a href="about.html">About</a></li> <li><a href="music.html">Music</a></li> <li><a href="contact.html">Contact</a></li> </div> </ul> <p class="heading">"AWAKEN MY LOVE!"</p> <p class="heading1"> Childish Gambino's latest <br> and freshest album is <br> AVAILABLE NOW on <a href="https://itunes.apple.com/us/album/awaken-my-love/id1173655524" target="_blank">iTunes</a>, <br> <a href="https://play.spotify.com/album/4xnq1L6P551Qcb9gBXNMK7" target="_blank">Spotify</a> and <a href="https://play.google.com/store/music/album?id=Bc3g3mmud6z3xm6todpsldagple&tid=song-Tdcdooebkcepkmj7amghovz2ncq&hl=en" target="_blank">Google Play Music</a> </p> <img src="images/awakenmylove.jpg" class="aml" title="'Awaken My Love!' album art" alt="'Awaken My Love' album art"> <<iframe width="280" height="158" src="https://www.youtube.com/embed/6v7W513Wj3g?rel=0" frameborder="0" allowfullscreen class=livevid></iframe> <p class="vid">Watch Now!</p> <p class="vid1">Childish Gambino performing '3005'<br>live at Splendor In The Grass!</p> </body> </html> <!-- end snippet -->
0debug
Google Play: Can't RELEASE TO PRODUCTION because "a draft release in production already", what to do? : <p>I am trying to release a new version of my app at Google Play Console.</p> <p>I have one version which I didn't release and then I uploaded a new one to Beta that I want to release.</p> <p>When I press on the "RELEASE TO PRODUCTION" button I get the following message:</p> <blockquote> <p>"To release to production, ensure that you don't have a draft release in production already"</p> </blockquote> <p>If I try to "RELEASE TO PRODUCTION" the former version I get the same message. How can I break this loop? any ideas?</p>
0debug
Screen size in PHP resolution : <p>I want to retrieve the screen size of my screen in PHP . I want to say in my file php : </p> <pre><code>if(screenSize==1024x600){ ... } </code></pre> <p>I know how i can retrieve resolution in JS but how i can use it in PHP ?! </p> <p>Thanks for advance !</p>
0debug
static int nsv_parse_NSVf_header(AVFormatContext *s) { NSVContext *nsv = s->priv_data; AVIOContext *pb = s->pb; unsigned int av_unused file_size; unsigned int size; int64_t duration; int strings_size; int table_entries; int table_entries_used; av_dlog(s, "%s()\n", __FUNCTION__); nsv->state = NSV_UNSYNC; size = avio_rl32(pb); if (size < 28) return -1; nsv->NSVf_end = size; file_size = (uint32_t)avio_rl32(pb); av_dlog(s, "NSV NSVf chunk_size %u\n", size); av_dlog(s, "NSV NSVf file_size %u\n", file_size); nsv->duration = duration = avio_rl32(pb); av_dlog(s, "NSV NSVf duration %"PRId64" ms\n", duration); strings_size = avio_rl32(pb); table_entries = avio_rl32(pb); table_entries_used = avio_rl32(pb); av_dlog(s, "NSV NSVf info-strings size: %d, table entries: %d, bis %d\n", strings_size, table_entries, table_entries_used); if (pb->eof_reached) return -1; av_dlog(s, "NSV got header; filepos %"PRId64"\n", avio_tell(pb)); if (strings_size > 0) { char *strings; char *p, *endp; char *token, *value; char quote; p = strings = av_mallocz(strings_size + 1); endp = strings + strings_size; avio_read(pb, strings, strings_size); while (p < endp) { while (*p == ' ') p++; if (p >= endp-2) break; token = p; p = strchr(p, '='); if (!p || p >= endp-2) break; *p++ = '\0'; quote = *p++; value = p; p = strchr(p, quote); if (!p || p >= endp) break; *p++ = '\0'; av_dlog(s, "NSV NSVf INFO: %s='%s'\n", token, value); av_dict_set(&s->metadata, token, value, 0); } av_free(strings); } if (pb->eof_reached) return -1; av_dlog(s, "NSV got infos; filepos %"PRId64"\n", avio_tell(pb)); if (table_entries_used > 0) { int i; nsv->index_entries = table_entries_used; if((unsigned)table_entries_used >= UINT_MAX / sizeof(uint32_t)) return -1; nsv->nsvs_file_offset = av_malloc((unsigned)table_entries_used * sizeof(uint32_t)); for(i=0;i<table_entries_used;i++) nsv->nsvs_file_offset[i] = avio_rl32(pb) + size; if(table_entries > table_entries_used && avio_rl32(pb) == MKTAG('T','O','C','2')) { nsv->nsvs_timestamps = av_malloc((unsigned)table_entries_used*sizeof(uint32_t)); for(i=0;i<table_entries_used;i++) { nsv->nsvs_timestamps[i] = avio_rl32(pb); } } } av_dlog(s, "NSV got index; filepos %"PRId64"\n", avio_tell(pb)); #ifdef DEBUG_DUMP_INDEX #define V(v) ((v<0x20 || v > 127)?'.':v) av_dlog(s, "NSV %d INDEX ENTRIES:\n", table_entries); av_dlog(s, "NSV [dataoffset][fileoffset]\n", table_entries); for (i = 0; i < table_entries; i++) { unsigned char b[8]; avio_seek(pb, size + nsv->nsvs_file_offset[i], SEEK_SET); avio_read(pb, b, 8); av_dlog(s, "NSV [0x%08lx][0x%08lx]: %02x %02x %02x %02x %02x %02x %02x %02x" "%c%c%c%c%c%c%c%c\n", nsv->nsvs_file_offset[i], size + nsv->nsvs_file_offset[i], b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], V(b[0]), V(b[1]), V(b[2]), V(b[3]), V(b[4]), V(b[5]), V(b[6]), V(b[7]) ); } #undef V #endif avio_seek(pb, nsv->base_offset + size, SEEK_SET); if (pb->eof_reached) return -1; nsv->state = NSV_HAS_READ_NSVF; return 0; }
1threat
How to get Current Location using SwiftUI, without ViewControllers? : <p>I've prepared in my project the following class to retrieve the user current location:</p> <pre><code>LocationManager.swift import Foundation import CoreLocation class LocationManager: NSObject { // - Private private let locationManager = CLLocationManager() // - API public var exposedLocation: CLLocation? { return self.locationManager.location } override init() { super.init() self.locationManager.delegate = self self.locationManager.desiredAccuracy = kCLLocationAccuracyBest self.locationManager.requestWhenInUseAuthorization() } } // MARK: - Core Location Delegate extension LocationManager: CLLocationManagerDelegate { func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) { switch status { case .notDetermined : print("notDetermined") // location permission not asked for yet case .authorizedWhenInUse : print("authorizedWhenInUse") // location authorized case .authorizedAlways : print("authorizedAlways") // location authorized case .restricted : print("restricted") // TODO: handle case .denied : print("denied") // TODO: handle default : print("unknown") // TODO: handle } } } // MARK: - Get Placemark extension LocationManager { func getPlace(for location: CLLocation, completion: @escaping (CLPlacemark?) -&gt; Void) { let geocoder = CLGeocoder() geocoder.reverseGeocodeLocation(location) { placemarks, error in guard error == nil else { print("*** Error in \(#function): \ (error!.localizedDescription)") completion(nil) return } guard let placemark = placemarks?[0] else { print("*** Error in \(#function): placemark is nil") completion(nil) return } completion(placemark) } } } </code></pre> <p>But I'm not sure how to use it, while using SwiftUI, from my ContentView file. How am I supposed to get the exposedLocation without using the approach I would have used in a standard ViewController (in this case the use of guard, let and return of course generates all kind of errors, since I'm not supposed to use returns in this context, if I got it right). Any hint about how to achieve this? I would like to get the user location whenever a button is pressed (at the moment I've used just mockup data). </p> <pre><code>ContentView.swift import SwiftUI struct Location: Identifiable { // When conforming to the protocol Identifiable we have to to implement a variable called id however this variable does not have to be an Int. The protocol only requires that the type of the variable id is actually Hashable. // Note: Int, Double, String and a lot more types are Hashable let id: Int let country: String let state: String let town: String } struct ContentView: View { // let’s make our variable a @State variable so that as soon as we change its value (by for eexample adding new elements) our view updates automagically. @State var locationList = [ Location(id: 0, country: "Italy", state: "", town: "Finale Emilia"), Location(id: 1, country: "Italy", state: "", town: "Bologna"), Location(id: 2, country: "Italy", state: "", town: "Modena"), Location(id: 3, country: "Italy", state: "", town: "Reggio Emilia"), Location(id: 4, country: "USA", state: "CA", town: "Los Angeles") ] // - Constants private let locationManager = LocationManager() // THIS IS NOT POSSIBLE WITH SWIFTUI AND GENERATES ERRORS guard let exposedLocation = self.locationManager.exposedLocation else { print("*** Error in \(#function): exposedLocation is nil") return } var body: some View { // Whenever we use a List based of an Array we have to let the List know how to identify each row as unique // When confirming to the Identifiable protocol we no longer have to explicitly tell the List how the elements in our Array (which are conforming to that protocol) are uniquely identified NavigationView { // let’s add a title to our Navigation view and make sure you always do so on the first child view inside of your Navigation view List(locationList) { location in NavigationLink(destination: LocationDetail(location: location)) { HStack { Text(location.country) Text(location.town).foregroundColor(.blue) } } } .navigationBarTitle(Text("Location")) .navigationBarItems( trailing: Button(action: addLocation, label: { Text("Add") })) } } func addLocation() { // We are using the native .randomElement() function of an Array to get a random element. The returned element however is optional. That is because in the case of the Array being empty that function would return nil. That’s why we append the returned value only in the case it doesn’t return nil. if let randomLocation = locationList.randomElement() { locationList.append(randomLocation) } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } </code></pre>
0debug
static int tcp_chr_write(CharDriverState *chr, const uint8_t *buf, int len) { TCPCharDriver *s = chr->opaque; if (s->connected) { return send_all(s->fd, buf, len); } else { tcp_chr_connect(chr); return 0; } }
1threat
How to pass an array by reference to a function in C : I am a beginner coder in C. I have the following code: int main() { struct* Array[malloc(10*sizeOf(struct)]; /*I then fill the struct. (int num,float points)*/ /*I then want to pass this array that I've filled up to a sortList function, which then outputs the sorted array back to main().*/ /*Then I want to output the array as: "number, points"*/ } struct struct { int number; float points; } My question is, how would I pass the array and then back? Any links or suggestions are greatly helpful, thanks!
0debug
static void rgba32_to_rgb24(AVPicture *dst, AVPicture *src, int width, int height) { const uint8_t *s; uint8_t *d; int src_wrap, dst_wrap, j, y; unsigned int v; s = src->data[0]; src_wrap = src->linesize[0] - width * 4; d = dst->data[0]; dst_wrap = dst->linesize[0] - width * 3; for(y=0;y<height;y++) { for(j = 0;j < width; j++) { v = *(uint32_t *)s; s += 4; d[0] = v >> 16; d[1] = v >> 8; d[2] = v; d += 3; } s += src_wrap; d += dst_wrap; } }
1threat
How to check whether any woocommerce order contains a product-ID? : I'm coding a plugin which should check whether an order contains an product-ID. How can I check all orders if any contains the product-ID and then mark this order as finished? I know how to check an order on thankyou-page, but the order-ID there is already given: Thank you all and @johnnyd23 for the code below. foreach ( $order_summary as $order ) { $order = wc_get_order( $order->order_id ); $order_id = $order->get_id(); $order_items = get_products_for_order( $order_id ); if ( $order->get_status() == 'processing' ) { foreach( $order_items as $item ) { if ( $item->is_featured() ) { echo 'Something'; } else { echo 'Something else'; } } } }
0debug
static int vp8_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr) { VP8Context *s = avctx->priv_data; VP8ThreadData *td = &s->thread_data[jobnr]; VP8ThreadData *next_td = NULL, *prev_td = NULL; VP8Frame *curframe = s->curframe; int mb_y, num_jobs = s->num_jobs; td->thread_nr = threadnr; for (mb_y = jobnr; mb_y < s->mb_height; mb_y += num_jobs) { if (mb_y >= s->mb_height) break; td->thread_mb_pos = mb_y << 16; vp8_decode_mb_row_no_filter(avctx, tdata, jobnr, threadnr); if (s->deblock_filter) vp8_filter_mb_row(avctx, tdata, jobnr, threadnr); update_pos(td, mb_y, INT_MAX & 0xFFFF); s->mv_min.y -= 64; s->mv_max.y -= 64; if (avctx->active_thread_type == FF_THREAD_FRAME) ff_thread_report_progress(&curframe->tf, mb_y, 0); } return 0; }
1threat
Convert PyTorch tensor to python list : <p>How do I convert a PyTorch <code>Tensor</code> into a python list?</p> <p>My current use case is to convert a tensor of size <code>[1, 2048, 1, 1]</code> into a list of 2048 elements.</p> <p>My tensor has floating point values. Is there a solution which also accounts for int and possibly other data types?</p>
0debug
Dynamically resolve property type based on another property value in TypeScript : <p>I have the following TypeScript interface:</p> <pre><code>interface SelectProps { options: Option[]; value: string[]; onChange: (value: string[]) =&gt; void; } </code></pre> <p>I want to add boolean called <code>isMultiple</code> that will change the types of the other properties.</p> <p>When <code>isMultiple=true</code></p> <ul> <li>enforce <code>value:string[]</code></li> <li>enforce <code>onChange: (value: string[]) =&gt; void;</code></li> </ul> <p>When <code>isMultiple=false</code></p> <ul> <li>enforce <code>value:string</code></li> <li>enforce <code>onChange: (value: string) =&gt; void;</code></li> </ul> <p>Is it possible to dynamically set the type of other properties based on the value of one property?</p>
0debug
Angular2 get ActivatedRoute url : <p>I want to get the url which comes from this:</p> <p><code>this.router.navigate(./somepath, { relativeTo: this.route })</code></p> <p><code>this.route</code> is of the type <code>ActivatedRoute</code>.</p> <p>I tried <code>url: string = route.snapshot.url.join('');</code> but this gives an empty string.</p>
0debug
static int do_compress_ram_page(CompressParam *param) { int bytes_sent, blen; uint8_t *p; RAMBlock *block = param->block; ram_addr_t offset = param->offset; p = block->host + (offset & TARGET_PAGE_MASK); bytes_sent = save_page_header(param->file, block, offset | RAM_SAVE_FLAG_COMPRESS_PAGE); blen = qemu_put_compression_data(param->file, p, TARGET_PAGE_SIZE, migrate_compress_level()); bytes_sent += blen; return bytes_sent; }
1threat
static void slirp_bootp_save(QEMUFile *f, Slirp *slirp) { int i; for (i = 0; i < NB_BOOTP_CLIENTS; i++) { qemu_put_be16(f, slirp->bootp_clients[i].allocated); qemu_put_buffer(f, slirp->bootp_clients[i].macaddr, 6); } }
1threat
using boolean to print invalid commands in java : I am trying to build my own command line interface. most confusing part is that to print out the invalid command base on user input. i tried using boolean function to each commands for its validity. I want my program to continue even if my command is invalid. **the question is , how do i get into a while loop again after i got out of it** String command; BufferedReader console = new BufferedReader(new InputStreamReader(System.in)); boolean R= true; while (R==true) { System.out.print("command: "); command = console.readLine(); R=false; ArrayList commandParams = new ArrayList(); String[] commandSplit = command.split(" "); if (commandSplit.length > 1) { for (int i = 1; i < commandSplit.length; i++) { commandParams.add(commandSplit[i]); } } if (commandSplit[0].equals("time")) { Date time = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss "); System.out.println(sdf.format(time)); R=true; } //Print today's date. if (commandSplit[0].equals("date")) { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat(" YYYY/MM/DD"); System.out.println(sdf.format(date)); R=true; } //Exit the console when "exit" is entered. if (commandSplit[0].equals("exit")) { System.exit(0); R=true; } } System.out.println("invalid command"); System.out.print("command:"); command = console.readLine(); } }
0debug
Cannot Acess internal directory created : When i try to create a directory in storage/emulator/0/ directory, it becomes invisible and inaccessible. I use `mkdir()` to create, and when i check its existence, `dir.exists()` return true, even though I can not access it. My device run in API 23, so i get the permissions in runtime, like this: boolean hasPermission = (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED); if (!hasPermission) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_READ_STORAGE); } i also create `onRequestPermissionsResult` funcion: @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); switch (requestCode) { case REQUEST_READ_STORAGE: { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { //reload my activity with permission granted or use the features what required the permission } else { Toast.makeText(this, "The app was not allowed to write to your storage. Hence, it cannot function properly. Please consider granting it this permission", Toast.LENGTH_LONG).show(); } } } } My `AndroidManifest.xml` <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.renan.appmemes"> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <application ... </application>
0debug
Can somebody please explain this php code to me? : <pre><code>&lt;?php $registers = array( "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3", "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "t8", "t9", "k0", "k1", "gp", "sp", "fp", "ra" ); $typeR = array( "add" =&gt; 32, "sub" =&gt; 34, "sll" =&gt; 0, "srl" =&gt; 2, "and" =&gt; 36, "or" =&gt; 37, "xor" =&gt; 38, "slt" =&gt; 42, "mul" =&gt; 24, "div" =&gt; 26, "jr" =&gt; 8 ); $typeI = array( "addi" =&gt; 8, "lui" =&gt; 15, "andi" =&gt; 12, "ori" =&gt; 13, "xori" =&gt; 14, "slti" =&gt; 10, "beq" =&gt; 4, "bne" =&gt; 5, "lw" =&gt; 35, "sw" =&gt; 43 ); $typeJ = array( "j" =&gt; 2, "jal" =&gt; 3 ); function typeR($address, $rs, $rt, $rd, $registers, $shamt, $typeR, $opfunc) { if ((empty($rd) || !ctype_digit($shamt)) &amp;&amp; $opfunc != "jr") { return -1; } return array( "address" =&gt; $address, "bin" =&gt; "000000" . sprintf("%05d", decbin(array_search($rs, $registers))) . sprintf("%05d", decbin(array_search($rt, $registers))) . sprintf("%05d", decbin(array_search($rd, $registers))) . sprintf("%05d", decbin($shamt)) . sprintf("%06d", decbin($typeR[$opfunc])) ); } function typeI($address, $rs, $rt, $imm, $registers, $typeI, $opfunc) { $is_hex = strpos($imm, "x"); $imm = $is_hex ? hexdec(substr($imm, $is_hex + 1)) : $imm; $imm = ($imm &lt; 0) ? substr(decbin($imm), -16) : sprintf("%016b", $imm); return array( "address" =&gt; $address, "bin" =&gt; sprintf("%06d", decbin($typeI[$opfunc])) . sprintf("%05d", decbin(array_search($rs, $registers))) . sprintf("%05d", decbin(array_search($rt, $registers))) . $imm ); } function typeJ($address, $addr, $typeJ, $opfunc) { return array( "address" =&gt; $address, "bin" =&gt; sprintf("%06d", decbin($typeJ[$opfunc])) . sprintf("%026d", decbin($addr)) ); } function blankLines($string) { $string = str_replace(array("\0", "\t", "\r", " ", "\n"), "", $string); return (strlen($string) ? 1 : 0); } function findLabel($array, $arrayLen, $label) { $label = $label . ":"; for ($i = 0; $i &lt; $arrayLen; $i++) { $array[$i] = explode(" ", $array[$i]); $subarrayLen = count($array[$i]); for ($j = 0; $j &lt; $subarrayLen; $j++) { if (!strcmp($label, trim($array[$i][$j]))) { return ($i * 4); } } } return -1; } function comments($string) { $commentI = ($string[0] == "#") ? -1 : strpos($string, "#"); return (($commentI) ? substr($string, 0, $commentI - strlen($string)) : $string); } function format($array) { $spaces = array(" ", " ", " ", " ", " ", " ", " ", " ", " "); $label = ""; for ($i = 0; $i &lt; count($array); $i++) { $array[$i] = str_replace(",", " ", $array[$i]); $array[$i] = @strtolower(trim(str_replace($spaces, " ", comments($array[$i])))); $inc = blankLines($array[$i]); $labelF = strpos($array[$i], ":"); $instr = $labelF ? substr($array[$i], $labelF + 1) : $array[$i]; if (!$inc || (!strlen($instr) &amp;&amp; $i &lt; (count($array) - 2))) { if (!strlen($instr) &amp;&amp; $labelF) { $label = str_replace(array("\0", "\t", "\r", " ", "\n"), "", $array[$i]); } unset($array[$i]); $array = array_values($array); $i--; } elseif (isset($label)) { $array[$i] = ($label . " " . trim($array[$i])); unset($label); $array = array_values($array); } } return $array; } function fileWrite($file, $instEnd, $count) { $arrayLen = count($instEnd); for ($i = 0; $i &lt; $arrayLen; $i++) { $instEnd[$i]["bin"] = substr($instEnd[$i]["bin"], -8, 8) . "+" . substr($instEnd[$i]["bin"], -16, 8) . "+" . substr($instEnd[$i]["bin"], -24, 8) . "+" . substr($instEnd[$i]["bin"], -32, 8); $instEnd[$i]["bin"] = explode("+", $instEnd[$i]["bin"]); $aux = 0; foreach ($instEnd[$i]["bin"] as $key =&gt; $value) { $instEnd[$i]["bin"][$key] = sprintf("%02X", bindec($value)); $str = "0x" . sprintf("%03X", ($instEnd[$i]["address"] + $aux)) . " 0x" . $instEnd[$i]["bin"][$key]; $str .= (((($count - 1) * 4) - 1) == (($i * 4) + $aux)) ? "\0" : "\n"; fwrite($file, $str); $aux++; } } echo "\n\nArquivo de saída gerado!\n\n"; } function assembler($arrayF, $typeR, $typeI, $typeJ, $registers, $argv) { $fileOut = (!empty($argv[2])) ? $argv[2] : "memoria.mif"; $file = fopen($fileOut, "w"); if (!$file) { echo "\n# Falha ao tentar criar o arquivo quickpatricia-eu.mif!\n"; } $instEnd = array(); $arrayF = format($arrayF); $arrayLen = count($arrayF); $output = ""; for ($i = 0; $i &lt; $arrayLen; $i++) { $sub = array(",", "$"); $address = ($i * 4); $labelF = strrpos($arrayF[$i], ":"); $instr = $labelF ? substr($arrayF[$i], $labelF + 1) : $arrayF[$i]; $instr = explode(" ", trim($instr)); if (array_key_exists($instr[0], $typeR)) { if ($instr[0] == "sll" || $instr[0] == "srl") { $rd = trim(str_replace($sub, "", $instr[1])); $rt = trim(str_replace($sub, "", $instr[2])); $shamt = $instr[3] ? trim(str_replace($sub, "", $instr[3])) : 0; $rs = "0"; } elseif ($instr[0] == "jr") { $rs = trim(str_replace($sub, "", $instr[1])); $rd = "0"; $rt = "0"; $shamt = "0"; } else { $rd = trim(str_replace($sub, "", $instr[1])); $rs = trim(str_replace($sub, "", $instr[2])); $rt = $instr[3] ? trim(str_replace($sub, "", $instr[3])) : 0; $shamt = "0"; } $return = typeR($address, $rs, $rt, $rd, $registers, $shamt, $typeR, $instr[0]); if ($return == -1) { $output .= "\nA linha " . ($i + 1) . " possui algum erro."; } else { $instEnd[$i] = $return; } } elseif (array_key_exists($instr[0], $typeI)) { if (strpos($instr[2], "(")) { $begin = strpos($instr[2], "("); $end = strpos($instr[2], ")"); $instr[3] = trim(substr($instr[2], $begin + 1, $end - strlen($instr[2]))); $instr[2] = trim(substr($instr[2], 0, $begin)); $imm = trim(str_replace($sub, "", $instr[2])); $rs = trim(str_replace($sub, "", $instr[3])); $rt = trim(str_replace($sub, "", $instr[1])); } elseif ($instr[0] == "lui") { $rs = "0"; $rt = trim(str_replace($sub, "", $instr[1])); $imm = trim(str_replace($sub, "", $instr[2])); } elseif ($instr[0] == "bne" || $instr[0] == "beq") { $rs = trim(str_replace($sub, "", $instr[1])); $rt = trim(str_replace($sub, "", $instr[2])); $imm = trim(str_replace($sub, "", $instr[3])); } else { $rs = trim(str_replace($sub, "", $instr[2])); $imm = trim(str_replace($sub, "", $instr[3])); $rt = trim(str_replace($sub, "", $instr[1])); } $labelDef = (ctype_digit($imm) || $imm &lt; 0) ? -1 : findLabel($arrayF, $arrayLen, $imm); if ($labelDef == -1) { $instEnd[$i] = typeI($address, $rs, $rt, $imm, $registers, $typeI, $instr[0]); } else { $instEnd[$i] = typeI($address, $rs, $rt, $labelDef, $registers, $typeI, $instr[0]); } } elseif (array_key_exists($instr[0], $typeJ)) { $addr = trim(str_replace($sub, "", $instr[1])); $labelDef = findLabel($arrayF, $arrayLen, $addr); if ($labelDef == -1) { $instEnd[$i] = typeJ($address, $addr, $typeJ, $instr[0]); } else { $instEnd[$i] = typeJ($address, $labelDef, $typeJ, $instr[0]); } } elseif (!$labelF) { $output .= "\nA linha " . ($i + 1) . " não possui uma instrução válida!\n"; } } if ($output) { echo "\n\n\nErros:" . $output . "\n"; }else { fileWrite($file, $instEnd, $arrayLen); } fclose($file); } $arrayF = ($argv[1]) ? file($argv[1]) : 0; if (!$arrayF) { echo "\n\n# Arquivo de dados não foi especificado pelo usuário!\n\n"; exit(1); } assembler($arrayF, $typeR, $typeI, $typeJ, $registers, $argv); </code></pre> <p>This I found when I was looking for an assembly-to-mif "mounter". The problem is I know nothing of php (only a little of c and java)... can somebody please explain to me all tags and functions here, maybe do some analogies? I have to understand this code to make sure I see through every instruction conversion and can convert this code to java. Please, it would be a serious amount of help if some of you guys explained that.</p>
0debug
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
Make an external function behave like a member function (C++) : Assuming I have a function like the following in C++: template<typename Container> void doNothing(Container * container) { for (auto element: container) { std::cout << element; } } Would it be possible to "simulate" methods on various classes that could implement this function by passing this to it instead of the first parameter. (E.g. a class like std::vector<int>, std::string ... etc). So basically instead of having to use it as: std::vector<double> a{1, 2, 0.5}: doNothing(a); I could call it as: std::vector<double> a{1, 2, 0.5}: a.doNothing();
0debug
static void decode_postinit(H264Context *h, int setup_finished) { const SPS *sps = h->ps.sps; H264Picture *out = h->cur_pic_ptr; H264Picture *cur = h->cur_pic_ptr; int i, pics, out_of_order, out_idx; int invalid = 0, cnt = 0; h->cur_pic_ptr->f->pict_type = h->pict_type; if (h->next_output_pic) return; if (cur->field_poc[0] == INT_MAX || cur->field_poc[1] == INT_MAX) { return; } cur->f->interlaced_frame = 0; cur->f->repeat_pict = 0; if (sps->pic_struct_present_flag) { H264SEIPictureTiming *pt = &h->sei.picture_timing; switch (pt->pic_struct) { case SEI_PIC_STRUCT_FRAME: break; case SEI_PIC_STRUCT_TOP_FIELD: case SEI_PIC_STRUCT_BOTTOM_FIELD: cur->f->interlaced_frame = 1; break; case SEI_PIC_STRUCT_TOP_BOTTOM: case SEI_PIC_STRUCT_BOTTOM_TOP: if (FIELD_OR_MBAFF_PICTURE(h)) cur->f->interlaced_frame = 1; else cur->f->interlaced_frame = h->prev_interlaced_frame; break; case SEI_PIC_STRUCT_TOP_BOTTOM_TOP: case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM: cur->f->repeat_pict = 1; break; case SEI_PIC_STRUCT_FRAME_DOUBLING: cur->f->repeat_pict = 2; break; case SEI_PIC_STRUCT_FRAME_TRIPLING: cur->f->repeat_pict = 4; break; } if ((pt->ct_type & 3) && pt->pic_struct <= SEI_PIC_STRUCT_BOTTOM_TOP) cur->f->interlaced_frame = (pt->ct_type & (1 << 1)) != 0; } else { cur->f->interlaced_frame = FIELD_OR_MBAFF_PICTURE(h); } h->prev_interlaced_frame = cur->f->interlaced_frame; if (cur->field_poc[0] != cur->field_poc[1]) { cur->f->top_field_first = cur->field_poc[0] < cur->field_poc[1]; } else { if (cur->f->interlaced_frame || sps->pic_struct_present_flag) { if (h->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM || h->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP) cur->f->top_field_first = 1; else cur->f->top_field_first = 0; } else { cur->f->top_field_first = 0; } } if (h->sei.frame_packing.present && h->sei.frame_packing.arrangement_type >= 0 && h->sei.frame_packing.arrangement_type <= 6 && h->sei.frame_packing.content_interpretation_type > 0 && h->sei.frame_packing.content_interpretation_type < 3) { H264SEIFramePacking *fp = &h->sei.frame_packing; AVStereo3D *stereo = av_stereo3d_create_side_data(cur->f); if (!stereo) return; switch (fp->arrangement_type) { case 0: stereo->type = AV_STEREO3D_CHECKERBOARD; break; case 1: stereo->type = AV_STEREO3D_COLUMNS; break; case 2: stereo->type = AV_STEREO3D_LINES; break; case 3: if (fp->quincunx_subsampling) stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX; else stereo->type = AV_STEREO3D_SIDEBYSIDE; break; case 4: stereo->type = AV_STEREO3D_TOPBOTTOM; break; case 5: stereo->type = AV_STEREO3D_FRAMESEQUENCE; break; case 6: stereo->type = AV_STEREO3D_2D; break; } if (fp->content_interpretation_type == 2) stereo->flags = AV_STEREO3D_FLAG_INVERT; } if (h->sei.display_orientation.present && (h->sei.display_orientation.anticlockwise_rotation || h->sei.display_orientation.hflip || h->sei.display_orientation.vflip)) { H264SEIDisplayOrientation *o = &h->sei.display_orientation; double angle = o->anticlockwise_rotation * 360 / (double) (1 << 16); AVFrameSideData *rotation = av_frame_new_side_data(cur->f, AV_FRAME_DATA_DISPLAYMATRIX, sizeof(int32_t) * 9); if (!rotation) return; av_display_rotation_set((int32_t *)rotation->data, angle); av_display_matrix_flip((int32_t *)rotation->data, o->hflip, o->vflip); } if (h->sei.afd.present) { AVFrameSideData *sd = av_frame_new_side_data(cur->f, AV_FRAME_DATA_AFD, sizeof(uint8_t)); if (!sd) return; *sd->data = h->sei.afd.active_format_description; h->sei.afd.present = 0; } if (h->sei.a53_caption.a53_caption) { H264SEIA53Caption *a53 = &h->sei.a53_caption; AVFrameSideData *sd = av_frame_new_side_data(cur->f, AV_FRAME_DATA_A53_CC, a53->a53_caption_size); if (!sd) return; memcpy(sd->data, a53->a53_caption, a53->a53_caption_size); av_freep(&a53->a53_caption); a53->a53_caption_size = 0; } if (sps->bitstream_restriction_flag || h->avctx->strict_std_compliance >= FF_COMPLIANCE_NORMAL) { h->avctx->has_b_frames = FFMAX(h->avctx->has_b_frames, sps->num_reorder_frames); } h->low_delay = !h->avctx->has_b_frames; pics = 0; while (h->delayed_pic[pics]) pics++; assert(pics <= MAX_DELAYED_PIC_COUNT); h->delayed_pic[pics++] = cur; if (cur->reference == 0) cur->reference = DELAYED_PIC_REF; for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++) { cnt += out->poc < h->last_pocs[i]; invalid += out->poc == INT_MIN; } if (!h->mmco_reset && !cur->f->key_frame && cnt + invalid == MAX_DELAYED_PIC_COUNT && cnt > 0) { h->mmco_reset = 2; if (pics > 1) h->delayed_pic[pics - 2]->mmco_reset = 2; } if (h->mmco_reset || cur->f->key_frame) { for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++) h->last_pocs[i] = INT_MIN; cnt = 0; invalid = MAX_DELAYED_PIC_COUNT; } out = h->delayed_pic[0]; out_idx = 0; for (i = 1; i < MAX_DELAYED_PIC_COUNT && h->delayed_pic[i] && !h->delayed_pic[i - 1]->mmco_reset && !h->delayed_pic[i]->f->key_frame; i++) if (h->delayed_pic[i]->poc < out->poc) { out = h->delayed_pic[i]; out_idx = i; } if (h->avctx->has_b_frames == 0 && (h->delayed_pic[0]->f->key_frame || h->mmco_reset)) h->next_outputed_poc = INT_MIN; out_of_order = !out->f->key_frame && !h->mmco_reset && (out->poc < h->next_outputed_poc); if (sps->bitstream_restriction_flag && h->avctx->has_b_frames >= sps->num_reorder_frames) { } else if (out_of_order && pics - 1 == h->avctx->has_b_frames && h->avctx->has_b_frames < MAX_DELAYED_PIC_COUNT) { if (invalid + cnt < MAX_DELAYED_PIC_COUNT) { h->avctx->has_b_frames = FFMAX(h->avctx->has_b_frames, cnt); } h->low_delay = 0; } else if (h->low_delay && ((h->next_outputed_poc != INT_MIN && out->poc > h->next_outputed_poc + 2) || cur->f->pict_type == AV_PICTURE_TYPE_B)) { h->low_delay = 0; h->avctx->has_b_frames++; } if (pics > h->avctx->has_b_frames) { out->reference &= ~DELAYED_PIC_REF; for (i = out_idx; h->delayed_pic[i]; i++) h->delayed_pic[i] = h->delayed_pic[i + 1]; } memmove(h->last_pocs, &h->last_pocs[1], sizeof(*h->last_pocs) * (MAX_DELAYED_PIC_COUNT - 1)); h->last_pocs[MAX_DELAYED_PIC_COUNT - 1] = cur->poc; if (!out_of_order && pics > h->avctx->has_b_frames) { h->next_output_pic = out; if (out->mmco_reset) { if (out_idx > 0) { h->next_outputed_poc = out->poc; h->delayed_pic[out_idx - 1]->mmco_reset = out->mmco_reset; } else { h->next_outputed_poc = INT_MIN; } } else { if (out_idx == 0 && pics > 1 && h->delayed_pic[0]->f->key_frame) { h->next_outputed_poc = INT_MIN; } else { h->next_outputed_poc = out->poc; } } h->mmco_reset = 0; } else { av_log(h->avctx, AV_LOG_DEBUG, "no picture\n"); } if (h->next_output_pic) { if (h->next_output_pic->recovered) { h->frame_recovered |= FRAME_RECOVERED_SEI; } h->next_output_pic->recovered |= !!(h->frame_recovered & FRAME_RECOVERED_SEI); } if (setup_finished && !h->avctx->hwaccel) { ff_thread_finish_setup(h->avctx); if (h->avctx->active_thread_type & FF_THREAD_FRAME) h->setup_finished = 1; } }
1threat
static int hls_start(AVFormatContext *s, VariantStream *vs) { HLSContext *c = s->priv_data; AVFormatContext *oc = vs->avf; AVFormatContext *vtt_oc = vs->vtt_avf; AVDictionary *options = NULL; char *filename, iv_string[KEYSIZE*2 + 1]; int err = 0; if (c->flags & HLS_SINGLE_FILE) { av_strlcpy(oc->filename, vs->basename, sizeof(oc->filename)); if (vs->vtt_basename) av_strlcpy(vtt_oc->filename, vs->vtt_basename, sizeof(vtt_oc->filename)); } else if (c->max_seg_size > 0) { if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename), #if FF_API_HLS_WRAP vs->basename, 'd', c->wrap ? vs->sequence % c->wrap : vs->sequence) < 1) { #else vs->basename, 'd', vs->sequence) < 1) { #endif av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s', you can try to use -use_localtime 1 with it\n", vs->basename); return AVERROR(EINVAL); } } else { if (c->use_localtime) { time_t now0; struct tm *tm, tmpbuf; time(&now0); tm = localtime_r(&now0, &tmpbuf); if (!strftime(oc->filename, sizeof(oc->filename), vs->basename, tm)) { av_log(oc, AV_LOG_ERROR, "Could not get segment filename with use_localtime\n"); return AVERROR(EINVAL); } err = sls_flag_use_localtime_filename(oc, c, vs); if (err < 0) { return AVERROR(ENOMEM); } if (c->use_localtime_mkdir) { const char *dir; char *fn_copy = av_strdup(oc->filename); if (!fn_copy) { return AVERROR(ENOMEM); } dir = av_dirname(fn_copy); if (mkdir_p(dir) == -1 && errno != EEXIST) { av_log(oc, AV_LOG_ERROR, "Could not create directory %s with use_localtime_mkdir\n", dir); av_free(fn_copy); return AVERROR(errno); } av_free(fn_copy); } } else if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename), #if FF_API_HLS_WRAP vs->basename, 'd', c->wrap ? vs->sequence % c->wrap : vs->sequence) < 1) { #else vs->basename, 'd', vs->sequence) < 1) { #endif av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s' you can try to use -use_localtime 1 with it\n", vs->basename); return AVERROR(EINVAL); } if( vs->vtt_basename) { if (replace_int_data_in_filename(vtt_oc->filename, sizeof(vtt_oc->filename), #if FF_API_HLS_WRAP vs->vtt_basename, 'd', c->wrap ? vs->sequence % c->wrap : vs->sequence) < 1) { #else vs->vtt_basename, 'd', vs->sequence) < 1) { #endif av_log(vtt_oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", vs->vtt_basename); return AVERROR(EINVAL); } } } vs->number++; set_http_options(s, &options, c); if (c->flags & HLS_TEMP_FILE) { av_strlcat(oc->filename, ".tmp", sizeof(oc->filename)); } if (c->key_info_file || c->encrypt) { if (c->key_info_file && c->encrypt) { av_log(s, AV_LOG_WARNING, "Cannot use both -hls_key_info_file and -hls_enc," " will use -hls_key_info_file priority\n"); } if (!c->encrypt_started || (c->flags & HLS_PERIODIC_REKEY)) { if (c->key_info_file) { if ((err = hls_encryption_start(s)) < 0) goto fail; } else { if ((err = do_encrypt(s, vs)) < 0) goto fail; } c->encrypt_started = 1; } if ((err = av_dict_set(&options, "encryption_key", c->key_string, 0)) < 0) goto fail; err = av_strlcpy(iv_string, c->iv_string, sizeof(iv_string)); if (!err) snprintf(iv_string, sizeof(iv_string), "%032"PRIx64, vs->sequence); if ((err = av_dict_set(&options, "encryption_iv", iv_string, 0)) < 0) goto fail; filename = av_asprintf("crypto:%s", oc->filename); if (!filename) { err = AVERROR(ENOMEM); goto fail; } err = hlsenc_io_open(s, &oc->pb, filename, &options); av_free(filename); av_dict_free(&options); if (err < 0) return err; } else if (c->segment_type != SEGMENT_TYPE_FMP4) { if ((err = hlsenc_io_open(s, &oc->pb, oc->filename, &options)) < 0) goto fail; } if (vs->vtt_basename) { set_http_options(s, &options, c); if ((err = hlsenc_io_open(s, &vtt_oc->pb, vtt_oc->filename, &options)) < 0) goto fail; } av_dict_free(&options); if (c->segment_type != SEGMENT_TYPE_FMP4) { if (oc->oformat->priv_class && oc->priv_data) { char period[21]; snprintf(period, sizeof(period), "%d", (INT_MAX / 2) - 1); av_opt_set(oc->priv_data, "mpegts_flags", "resend_headers", 0); av_opt_set(oc->priv_data, "sdt_period", period, 0); av_opt_set(oc->priv_data, "pat_period", period, 0); } } if (vs->vtt_basename) { err = avformat_write_header(vtt_oc,NULL); if (err < 0) return err; } return 0; fail: av_dict_free(&options); return err; }
1threat
CakePHP how to create functions : How can I create functions that can be called in view(like in the index.ctp)? I just wrote a function in one of my controllers but I'm getting this error message: "Error: Call to undefined function getWins()". Basically I want this function to search my database table "Matches" and return the total count of a specific record. I know my function code is right but I don't know how to call it in the view.
0debug
Java Gson Exclude fields during serialization : <p>I have a <code>ConfigInstance</code> class which contains a <code>password</code> and a <code>password_hash</code>. Now I want to serialize the object using gson but exclude the <code>password</code> field.</p> <pre><code>public class ConfigInstance { public String database_address; public int database_port; public String database_user; @Expose(serialize = false) private String database_pass; public String database_pass_hash; public String GetPass() { return database_pass; } public void Encrypt() { /* Creates the hash before serializing*/ } public void Decrypt() { /* Creates the password after deserializing */} } </code></pre> <p>As you can see, I have tried using <code>@Expose(serialize = false)</code> but it doesn't seem to do anything. Also I already set the field to private since I figured that this would "override" the <code>@Expose</code></p> <p>but running following code:</p> <pre><code>private void toFile(File file, ConfigInstance map) { map.Encrypt(); Gson gson = new GsonBuilder().setPrettyPrinting().create(); String jsonConfig = gson.toJson(map); FileWriter writer; try { writer = new FileWriter(file); writer.write(jsonConfig); writer.flush(); writer.close(); } catch (IOException e) { System.out.println("Error exporting config: " + e.toString()); } } </code></pre> <p>still results in the following file content without Errors:</p> <pre><code>{ "database_address": "127.0.0.1", "database_port": 1521, "database_user": "test", "database_pass": "test1234", "database_pass_hash": "B9FE2C011B59F0D0D383D70073E48A19" } </code></pre> <p>So what am I doing wrong? I am pretty clueless right now and would appreciate any help since <a href="http://www.javacreed.com/gson-annotations-example/" rel="noreferrer">THIS</a> doesn't seem to work.</p> <p>Thanks in advance.</p>
0debug
vpc_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { BDRVVPCState *s = bs->opaque; int64_t image_offset; int64_t n_bytes; int64_t bytes_done = 0; int ret; VHDFooter *footer = (VHDFooter *) s->footer_buf; QEMUIOVector local_qiov; if (be32_to_cpu(footer->type) == VHD_FIXED) { return bdrv_co_pwritev(bs->file->bs, offset, bytes, qiov, 0); } qemu_co_mutex_lock(&s->lock); qemu_iovec_init(&local_qiov, qiov->niov); while (bytes > 0) { image_offset = get_image_offset(bs, offset, true); n_bytes = MIN(bytes, s->block_size - (offset % s->block_size)); if (image_offset == -1) { image_offset = alloc_block(bs, offset); if (image_offset < 0) { ret = image_offset; goto fail; } } qemu_iovec_reset(&local_qiov); qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes); ret = bdrv_co_pwritev(bs->file->bs, image_offset, n_bytes, &local_qiov, 0); if (ret < 0) { goto fail; } bytes -= n_bytes; offset += n_bytes; bytes_done += n_bytes; } ret = 0; fail: qemu_iovec_destroy(&local_qiov); qemu_co_mutex_unlock(&s->lock); return ret; }
1threat
AVResampleContext *swr_resample_init(AVResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff){ double factor= FFMIN(out_rate * cutoff / in_rate, 1.0); int phase_count= 1<<phase_shift; if (!c || c->phase_shift != phase_shift || c->linear!=linear || c->factor != factor || c->filter_length != FFMAX((int)ceil(filter_size/factor), 1)) { c = av_mallocz(sizeof(AVResampleContext)); if (!c) return NULL; c->phase_shift = phase_shift; c->phase_mask = phase_count - 1; c->linear = linear; c->factor = factor; c->filter_length = FFMAX((int)ceil(filter_size/factor), 1); c->filter_bank = av_mallocz(c->filter_length*(phase_count+1)*sizeof(FELEM)); if (!c->filter_bank) goto error; if (build_filter(c->filter_bank, factor, c->filter_length, phase_count, 1<<FILTER_SHIFT, WINDOW_TYPE)) goto error; memcpy(&c->filter_bank[c->filter_length*phase_count+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM)); c->filter_bank[c->filter_length*phase_count]= c->filter_bank[c->filter_length - 1]; } c->compensation_distance= 0; c->src_incr= out_rate; c->ideal_dst_incr= c->dst_incr= in_rate * phase_count; c->index= -phase_count*((c->filter_length-1)/2); c->frac= 0; return c; error: av_free(c->filter_bank); av_free(c); return NULL; }
1threat
I don't know where to change my Wordpress header! Please help me! It's for my father's business : Firstly, i'm not a native speaker so please forgive me if i made any grammar or spelling mistake! I'm just a wordpress user, actually i've never used wp before until my dad give me his company's website, and i have a huge problem now that i can't find where to change my header image Here's the website [enter image description here][1] And themes customization I did a lot of researches, and i saw that there's an option called "header" in the customize section, but as you can see i can't find it! I know it's stupid but i really don't know anything and i'm really confused! Please help me, many thanks to you, please! I need it, 'cuz i'm an IT student and they always look at me like i know things, but not that much, it's especially i've only learned C++ not this, i have no ideas what's going on, but i'm afraid that they're gonna judge me and my father! Please help, thanks, thanks, thanks a lot! [1]: https://i.stack.imgur.com/S5qQI.jpg
0debug
How to make a document a HTML doctype : <p>I really do not know how to make a document HTML. It really confuses me. Does anyone know how to help me? I have already tried just saving it, but as I use atom it doesn't really work.</p>
0debug
static void test_qemu_strtosz_units(void) { const char *none = "1"; const char *b = "1B"; const char *k = "1K"; const char *m = "1M"; const char *g = "1G"; const char *t = "1T"; const char *p = "1P"; const char *e = "1E"; char *endptr = NULL; int64_t res; res = qemu_strtosz_MiB(none, &endptr); g_assert_cmpint(res, ==, M_BYTE); g_assert(endptr == none + 1); res = qemu_strtosz(b, &endptr); g_assert_cmpint(res, ==, 1); g_assert(endptr == b + 2); res = qemu_strtosz(k, &endptr); g_assert_cmpint(res, ==, K_BYTE); g_assert(endptr == k + 2); res = qemu_strtosz(m, &endptr); g_assert_cmpint(res, ==, M_BYTE); g_assert(endptr == m + 2); res = qemu_strtosz(g, &endptr); g_assert_cmpint(res, ==, G_BYTE); g_assert(endptr == g + 2); res = qemu_strtosz(t, &endptr); g_assert_cmpint(res, ==, T_BYTE); g_assert(endptr == t + 2); res = qemu_strtosz(p, &endptr); g_assert_cmpint(res, ==, P_BYTE); g_assert(endptr == p + 2); res = qemu_strtosz(e, &endptr); g_assert_cmpint(res, ==, E_BYTE); g_assert(endptr == e + 2); }
1threat
static uint32_t omap_l4_io_readb(void *opaque, target_phys_addr_t addr) { unsigned int i = (addr - OMAP2_L4_BASE) >> TARGET_PAGE_BITS; return omap_l4_io_readb_fn[i](omap_l4_io_opaque[i], addr); }
1threat
Why is this producing a segmentation fault? : <p>I'm not sure why the following is producing a segmentation fault. I've defined a structure and I'm trying to store a value to it.</p> <pre><code>typedef struct { int sourceid; int destid; } TEST_STRUCT; void main( int argc, char *argv[] ) { TEST_STRUCT *test; test-&gt;sourceid = 5; } </code></pre>
0debug
How to convert the OrderedDict to the normal dict but keey the order as the OrderedDict?? python : when i use the dict() the order is changed! how to get the dict follows the order of OrderedDict()?? >>> from collections import OrderedDict >>> OrderedDict([('method', 'constant'), ('data', '1.225')]) OrderedDict([('method', 'constant'), ('data', '1.225')]) >>> dict(OrderedDict([('method', 'constant'), ('data', '1.225')])) {'data': '1.225', 'method': 'constant'} >>> what i would like to get is : which is the same order as OrderedDict() {'method': 'constant','data': '1.225'}
0debug
static int ivshmem_setup_interrupts(IVShmemState *s) { s->msi_vectors = g_malloc0(s->vectors * sizeof(MSIVector)); if (ivshmem_has_feature(s, IVSHMEM_MSI)) { if (msix_init_exclusive_bar(PCI_DEVICE(s), s->vectors, 1)) { return -1; } IVSHMEM_DPRINTF("msix initialized (%d vectors)\n", s->vectors); ivshmem_msix_vector_use(s); } return 0; }
1threat
BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, int granularity, Error **errp) { int64_t bitmap_size; BdrvDirtyBitmap *bitmap; assert((granularity & (granularity - 1)) == 0); granularity >>= BDRV_SECTOR_BITS; assert(granularity); bitmap_size = bdrv_nb_sectors(bs); if (bitmap_size < 0) { error_setg_errno(errp, -bitmap_size, "could not get length of device"); errno = -bitmap_size; return NULL; } bitmap = g_new0(BdrvDirtyBitmap, 1); bitmap->bitmap = hbitmap_alloc(bitmap_size, ffs(granularity) - 1); QLIST_INSERT_HEAD(&bs->dirty_bitmaps, bitmap, list); return bitmap; }
1threat
static int writer_open(WriterContext **wctx, const Writer *writer, const char *args, const struct section *sections, int nb_sections) { int i, ret = 0; if (!(*wctx = av_malloc(sizeof(WriterContext)))) { ret = AVERROR(ENOMEM); goto fail; } if (!((*wctx)->priv = av_mallocz(writer->priv_size))) { ret = AVERROR(ENOMEM); goto fail; } (*wctx)->class = &writer_class; (*wctx)->writer = writer; (*wctx)->level = -1; (*wctx)->sections = sections; (*wctx)->nb_sections = nb_sections; if (writer->priv_class) { void *priv_ctx = (*wctx)->priv; *((const AVClass **)priv_ctx) = writer->priv_class; av_opt_set_defaults(priv_ctx); if (args && (ret = av_set_options_string(priv_ctx, args, "=", ":")) < 0) goto fail; } for (i = 0; i < SECTION_MAX_NB_LEVELS; i++) av_bprint_init(&(*wctx)->section_pbuf[i], 1, AV_BPRINT_SIZE_UNLIMITED); if ((*wctx)->writer->init) ret = (*wctx)->writer->init(*wctx); if (ret < 0) goto fail; return 0; fail: writer_close(wctx); return ret; }
1threat
please correct this connection string i dont know whats wrong in this query : SqlConnection con = new SqlConnection("Server=ACER-PC/SQLEXPRESS;Database=coupon;Integrated Security=true");,whats wrong in this please help me,and thank you in advance
0debug
Get Last Month's Adsense Profits Via PHP : This question is asked in various forms (none to specific) on this site and I'd like to build a solution once and for all that attempts to conquer what are a LOT of confusing steps. Loudly stated: I NEED TO EXTRACT MY TOTAL ADSENSE EARNINGS FROM LAST MONTH for use with my website. 1) I realize this will require the Adsense API 2) I realize I'll need to provide credentials A lot of existing Q&A on the matter refers to previous versions of Google's AdSense interface. I want to do this based on (as of) 2017. **THE QUESTION: Will someone please provide an accurate, step-by-step and even over-explanatory instructional on how to do this complete with WHICH APIs are necessary and also their configuration?** I've attempted to go through the motions MANY times over and all I ever get (when I'm lucky enough to make the server/server handshake happen) is an error suggesting "must login" within the JSON output. I've read some info on "solutions" for this but can't quite tell if either they don't work or my enabled API is incorrect (or misconfigured). In the end, it's a mess (in my opinion) by GUI standards. Help me get this noise working "once and for all"? (yeah, right)
0debug
static uint32_t get_elf_hwcap(void) { CPUState *e = thread_env; uint32_t features = 0; #define GET_FEATURE(flag, feature) \ do {if (e->insns_flags & flag) features |= feature; } while(0) GET_FEATURE(PPC_64B, PPC_FEATURE_64); GET_FEATURE(PPC_FLOAT, PPC_FEATURE_HAS_FPU); GET_FEATURE(PPC_ALTIVEC, PPC_FEATURE_HAS_ALTIVEC); GET_FEATURE(PPC_SPE, PPC_FEATURE_HAS_SPE); GET_FEATURE(PPC_SPE_SINGLE, PPC_FEATURE_HAS_EFP_SINGLE); GET_FEATURE(PPC_SPE_DOUBLE, PPC_FEATURE_HAS_EFP_DOUBLE); GET_FEATURE(PPC_BOOKE, PPC_FEATURE_BOOKE); GET_FEATURE(PPC_405_MAC, PPC_FEATURE_HAS_4xxMAC); #undef GET_FEATURE return features; }
1threat
void OPPROTO op_divd (void) { if (unlikely(((int64_t)T0 == INT64_MIN && (int64_t)T1 == -1) || (int64_t)T1 == 0)) { T0 = (int64_t)((-1ULL) * ((uint64_t)T0 >> 63)); } else { T0 = (int64_t)T0 / (int64_t)T1; } RETURN(); }
1threat
Android MVP, where check internet connection : <p>I'm implementing MVP pattern on an Andorid App and I have a doubt about where is the <strong>best place</strong> for <strong>checking the internet connection.</strong> I usually check if there is internet connection before doing any network call. </p> <p>So, where should I check it in the <strong>Activity</strong> or in the <strong>Presenter</strong>? I think the Presenter would be a nice place, so it decides what to do, however I'm not 100% sure If I should place it in the activity and avoid doing a call to the Presenter. </p>
0debug
how to append list which is inside a dict : new_dict = {'0/RP0': ['NCS1K4-CNTLR'], '0/PM1': ['NCS1K4-2KW-AC'], '0/PM0': ['NCS1K4-2KW-AC'], '0/FT2': ['NCS1K4-FAN'], '0/FT0': ['NCS1K4-FAN'], '0/FT1': ['NCS1K4-FAN']} list = ['OPERATIONAL', 'OPERATIONAL', 'OPERATIONAL', 'OPERATIONAL', 'FAILED', 'OPERATIONAL'] i want output like below: {'0/RP0': ['NCS1K4-CNTLR','OPERATIONAL'], '0/PM1': ['NCS1K4-2KW-AC','OPERATIONAL'], '0/PM0': ['NCS1K4-2KW-AC','OPERATIONAL'], '0/FT2': ['NCS1K4-FAN','OPERATIONAL'], '0/FT0': ['NCS1K4-FAN','FAILED'], '0/FT1': ['NCS1K4-FAN','OPERATIONAL']} i want to insert the values of list to the each value of a key
0debug
def set_middle_bits(n): n |= n >> 1; n |= n >> 2; n |= n >> 4; n |= n >> 8; n |= n >> 16; return (n >> 1) ^ 1 def toggle_middle_bits(n): if (n == 1): return 1 return n ^ set_middle_bits(n)
0debug
host 2 website in 1 IP : <p>i have one server with 1 ip without control panel </p> <p>i installed php/mysql/postfix...</p> <p>i followed this tutoriel to setup virtual host beause i have 2 domain </p> <p><a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-6" rel="nofollow">https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-6</a></p> <p>now i want to configure my 2 domain name in registrar to access to my 2 different website in server </p>
0debug
How to delete duplicate records in SQL? : <p>This my original table:</p> <p><a href="https://i.stack.imgur.com/zpd4S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zpd4S.png" alt="enter image description here"></a></p> <p>Intended table:</p> <p><a href="https://i.stack.imgur.com/0m2Lt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0m2Lt.png" alt="enter image description here"></a></p> <p>I can't add a new column to table. </p>
0debug
static void realview_init(ram_addr_t ram_size, const char *boot_device, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model, enum realview_board_type board_type) { CPUState *env = NULL; ram_addr_t ram_offset; DeviceState *dev, *sysctl, *gpio2; SysBusDevice *busdev; qemu_irq *irqp; qemu_irq pic[64]; qemu_irq mmc_irq[2]; PCIBus *pci_bus; NICInfo *nd; i2c_bus *i2c; int n; int done_nic = 0; qemu_irq cpu_irq[4]; int is_mpcore = 0; int is_pb = 0; uint32_t proc_id = 0; uint32_t sys_id; ram_addr_t low_ram_size; switch (board_type) { case BOARD_EB: break; case BOARD_EB_MPCORE: is_mpcore = 1; break; case BOARD_PB_A8: is_pb = 1; break; case BOARD_PBX_A9: is_mpcore = 1; is_pb = 1; break; } for (n = 0; n < smp_cpus; n++) { env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } irqp = arm_pic_init_cpu(env); cpu_irq[n] = irqp[ARM_PIC_CPU_IRQ]; } if (arm_feature(env, ARM_FEATURE_V7)) { if (is_mpcore) { proc_id = 0x0c000000; } else { proc_id = 0x0e000000; } } else if (arm_feature(env, ARM_FEATURE_V6K)) { proc_id = 0x06000000; } else if (arm_feature(env, ARM_FEATURE_V6)) { proc_id = 0x04000000; } else { proc_id = 0x02000000; } if (is_pb && ram_size > 0x20000000) { low_ram_size = ram_size - 0x20000000; ram_size = 0x20000000; ram_offset = qemu_ram_alloc(NULL, "realview.lowmem", low_ram_size); cpu_register_physical_memory(0x20000000, low_ram_size, ram_offset | IO_MEM_RAM); } ram_offset = qemu_ram_alloc(NULL, "realview.highmem", ram_size); low_ram_size = ram_size; if (low_ram_size > 0x10000000) low_ram_size = 0x10000000; cpu_register_physical_memory(0, low_ram_size, ram_offset | IO_MEM_RAM); if (is_pb) { cpu_register_physical_memory(0x70000000, ram_size, ram_offset | IO_MEM_RAM); } else { ram_size = low_ram_size; } sys_id = is_pb ? 0x01780500 : 0xc1400400; sysctl = qdev_create(NULL, "realview_sysctl"); qdev_prop_set_uint32(sysctl, "sys_id", sys_id); qdev_init_nofail(sysctl); qdev_prop_set_uint32(sysctl, "proc_id", proc_id); sysbus_mmio_map(sysbus_from_qdev(sysctl), 0, 0x10000000); if (is_mpcore) { dev = qdev_create(NULL, is_pb ? "a9mpcore_priv": "realview_mpcore"); qdev_prop_set_uint32(dev, "num-cpu", smp_cpus); qdev_init_nofail(dev); busdev = sysbus_from_qdev(dev); if (is_pb) { realview_binfo.smp_priv_base = 0x1f000000; } else { realview_binfo.smp_priv_base = 0x10100000; } sysbus_mmio_map(busdev, 0, realview_binfo.smp_priv_base); for (n = 0; n < smp_cpus; n++) { sysbus_connect_irq(busdev, n, cpu_irq[n]); } } else { uint32_t gic_addr = is_pb ? 0x1e000000 : 0x10040000; dev = sysbus_create_simple("realview_gic", gic_addr, cpu_irq[0]); } for (n = 0; n < 64; n++) { pic[n] = qdev_get_gpio_in(dev, n); } sysbus_create_simple("pl050_keyboard", 0x10006000, pic[20]); sysbus_create_simple("pl050_mouse", 0x10007000, pic[21]); sysbus_create_simple("pl011", 0x10009000, pic[12]); sysbus_create_simple("pl011", 0x1000a000, pic[13]); sysbus_create_simple("pl011", 0x1000b000, pic[14]); sysbus_create_simple("pl011", 0x1000c000, pic[15]); sysbus_create_simple("pl081", 0x10030000, pic[24]); sysbus_create_simple("sp804", 0x10011000, pic[4]); sysbus_create_simple("sp804", 0x10012000, pic[5]); sysbus_create_simple("pl061", 0x10013000, pic[6]); sysbus_create_simple("pl061", 0x10014000, pic[7]); gpio2 = sysbus_create_simple("pl061", 0x10015000, pic[8]); sysbus_create_simple("pl111", 0x10020000, pic[23]); dev = sysbus_create_varargs("pl181", 0x10005000, pic[17], pic[18], NULL); mmc_irq[0] = qemu_irq_split( qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT), qdev_get_gpio_in(gpio2, 1)); mmc_irq[1] = qemu_irq_split( qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_CARDIN), qemu_irq_invert(qdev_get_gpio_in(gpio2, 0))); qdev_connect_gpio_out(dev, 0, mmc_irq[0]); qdev_connect_gpio_out(dev, 1, mmc_irq[1]); sysbus_create_simple("pl031", 0x10017000, pic[10]); if (!is_pb) { dev = sysbus_create_varargs("realview_pci", 0x60000000, pic[48], pic[49], pic[50], pic[51], NULL); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci"); if (usb_enabled) { usb_ohci_init_pci(pci_bus, -1); } n = drive_get_max_bus(IF_SCSI); while (n >= 0) { pci_create_simple(pci_bus, -1, "lsi53c895a"); n--; } } for(n = 0; n < nb_nics; n++) { nd = &nd_table[n]; if (!done_nic && (!nd->model || strcmp(nd->model, is_pb ? "lan9118" : "smc91c111") == 0)) { if (is_pb) { lan9118_init(nd, 0x4e000000, pic[28]); } else { smc91c111_init(nd, 0x4e000000, pic[28]); } done_nic = 1; } else { pci_nic_init_nofail(nd, "rtl8139", NULL); } } dev = sysbus_create_simple("realview_i2c", 0x10002000, NULL); i2c = (i2c_bus *)qdev_get_child_bus(dev, "i2c"); i2c_create_slave(i2c, "ds1338", 0x68); ram_offset = qemu_ram_alloc(NULL, "realview.hack", 0x1000); cpu_register_physical_memory(SMP_BOOT_ADDR, 0x1000, ram_offset | IO_MEM_RAM); realview_binfo.ram_size = ram_size; realview_binfo.kernel_filename = kernel_filename; realview_binfo.kernel_cmdline = kernel_cmdline; realview_binfo.initrd_filename = initrd_filename; realview_binfo.nb_cpus = smp_cpus; realview_binfo.board_id = realview_board_id[board_type]; realview_binfo.loader_start = (board_type == BOARD_PB_A8 ? 0x70000000 : 0); arm_load_kernel(first_cpu, &realview_binfo); }
1threat
static void jpeg_init_destination(j_compress_ptr cinfo) { VncState *vs = cinfo->client_data; Buffer *buffer = &vs->tight_jpeg; cinfo->dest->next_output_byte = (JOCTET *)buffer->buffer + buffer->offset; cinfo->dest->free_in_buffer = (size_t)(buffer->capacity - buffer->offset); }
1threat
static int uhci_broadcast_packet(UHCIState *s, USBPacket *p) { int i, ret; DPRINTF("uhci: packet enter. pid %s addr 0x%02x ep %d len %d\n", pid2str(p->pid), p->devaddr, p->devep, p->len); if (p->pid == USB_TOKEN_OUT || p->pid == USB_TOKEN_SETUP) dump_data(p->data, p->len); ret = USB_RET_NODEV; for (i = 0; i < NB_PORTS && ret == USB_RET_NODEV; i++) { UHCIPort *port = &s->ports[i]; USBDevice *dev = port->port.dev; if (dev && (port->ctrl & UHCI_PORT_EN)) ret = usb_handle_packet(dev, p); } DPRINTF("uhci: packet exit. ret %d len %d\n", ret, p->len); if (p->pid == USB_TOKEN_IN && ret > 0) dump_data(p->data, ret); return ret; }
1threat
Label.text is not updating using ??? most solutions here did not work please heeelpppp? : Guys first of all I have been searching for a whole day trying to find a solution for this issue I found many people asking the same but non of the solutions worked for me ( NON ) .... I am not that expert in swift but I'm sure I did all of the solutions as they were and no luck -- The problem is label.text value became nil every time all the time accept in viewload :) .. I donet know what is the issue so please help me guys I have this code in swift 3 Xcode 8, I have a label as shown below [Label to be set later ][1] then I want to assign the label a value when the view loads as initial value [This is once view loads and it is working fine :)][2] later on I want to change the label value to the current Date which I would like it to be set when the user moves to another view the comes back , so I made the function open as you say .. Here is how I call the function [function call from secondViewController ][3] finally I want to set it to those values [last desired values][4] [1]: https://i.stack.imgur.com/pqRAz.png [2]: https://i.stack.imgur.com/z1ijS.png
0debug
void pci_device_hot_add(Monitor *mon, const QDict *qdict) { PCIDevice *dev = NULL; const char *pci_addr = qdict_get_str(qdict, "pci_addr"); const char *type = qdict_get_str(qdict, "type"); const char *opts = qdict_get_try_str(qdict, "opts"); if (!strncmp(pci_addr, "pci_addr=", 9)) { pci_addr += 9; } if (!opts) { opts = ""; } if (!strcmp(pci_addr, "auto")) pci_addr = NULL; if (strcmp(type, "nic") == 0) { dev = qemu_pci_hot_add_nic(mon, pci_addr, opts); } else if (strcmp(type, "storage") == 0) { dev = qemu_pci_hot_add_storage(mon, pci_addr, opts); } else { monitor_printf(mon, "invalid type: %s\n", type); } if (dev) { monitor_printf(mon, "OK domain %d, bus %d, slot %d, function %d\n", pci_find_domain(dev->bus), pci_bus_num(dev->bus), PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); } else monitor_printf(mon, "failed to add %s\n", opts); }
1threat
How to write websocket output to a text file? : I would like to write the output of a javascript websocket continously to a local textfile. How can I do this? Writing to files seem impossible for javascript (security reasons). That's why I am searching for another solution. This doesnt need to be a browser based solution. Windows cmd is good, too! Thank you :)
0debug
Keep an integer within bounds? : <p>To keep an integer within certain bounds, currently I'm doing:</p> <pre><code>frame.X = frame.X &lt;= 0 ? 0 : frame.X; frame.X = frame.X + frame.Width &gt; Image.Width ? Image.Width - frame.Width : frame.X; frame.Y = frame.Y &lt;= 0 ? 0 : frame.Y; frame.Y = frame.Y + frame.Height &gt; Image.Height ? Image.Height - frame.Height : frame.Y; </code></pre> <p>Is there a cleaner way for bound checking?</p>
0debug
I just want continue a program when end user press y key with do while loop in this code plz help me .. While('o'!=='y') also tried this : public class clac{ do{ System.out.println("\nwant to try again\n press y/n"); String o; o=sc.next(); }while(!o.contentEquals("y")); }
0debug
Swift 3D Touch iOS 10 Home screen quick actions share Item missing : <p>In my apps that use 3D touch home screen quick actions I do not have the new iOS 10 default sharing option that all apps got for free. </p> <p>I have seen some apps, for example Amazon, that have their 4 custom shortcut items (quick actions) and the 1 default sharing option.</p> <p>Is there a way I can get the default iOS 10 sharing option back? </p>
0debug
How to add delay in Reactjs : <p>I am new to Reactjs. I am not sure how to add <code>delay</code> to render in <code>Reactjs</code>.What is the best way to add delay.</p> <p>I am adding the following code in render but its not working.</p> <pre><code>setTimeout(function() { }, 1000); </code></pre>
0debug
int ff_h264_update_thread_context(AVCodecContext *dst, const AVCodecContext *src) { H264Context *h = dst->priv_data, *h1 = src->priv_data; int inited = h->context_initialized, err = 0; int need_reinit = 0; int i, ret; if (dst == src || !h1->context_initialized) return 0; if (!h1->ps.sps) return AVERROR_INVALIDDATA; if (inited && (h->width != h1->width || h->height != h1->height || h->mb_width != h1->mb_width || h->mb_height != h1->mb_height || !h->ps.sps || h->ps.sps->bit_depth_luma != h1->ps.sps->bit_depth_luma || h->ps.sps->chroma_format_idc != h1->ps.sps->chroma_format_idc || h->ps.sps->colorspace != h1->ps.sps->colorspace)) { need_reinit = 1; } for (i = 0; i < FF_ARRAY_ELEMS(h->ps.sps_list); i++) { av_buffer_unref(&h->ps.sps_list[i]); if (h1->ps.sps_list[i]) { h->ps.sps_list[i] = av_buffer_ref(h1->ps.sps_list[i]); if (!h->ps.sps_list[i]) return AVERROR(ENOMEM); } } for (i = 0; i < FF_ARRAY_ELEMS(h->ps.pps_list); i++) { av_buffer_unref(&h->ps.pps_list[i]); if (h1->ps.pps_list[i]) { h->ps.pps_list[i] = av_buffer_ref(h1->ps.pps_list[i]); if (!h->ps.pps_list[i]) return AVERROR(ENOMEM); } } h->ps.sps = h1->ps.sps; if (need_reinit || !inited) { h->width = h1->width; h->height = h1->height; h->mb_height = h1->mb_height; h->mb_width = h1->mb_width; h->mb_num = h1->mb_num; h->mb_stride = h1->mb_stride; h->b_stride = h1->b_stride; if ((err = h264_slice_header_init(h)) < 0) { av_log(h->avctx, AV_LOG_ERROR, "h264_slice_header_init() failed"); return err; } memcpy(h->block_offset, h1->block_offset, sizeof(h->block_offset)); } h->avctx->coded_height = h1->avctx->coded_height; h->avctx->coded_width = h1->avctx->coded_width; h->avctx->width = h1->avctx->width; h->avctx->height = h1->avctx->height; h->coded_picture_number = h1->coded_picture_number; h->first_field = h1->first_field; h->picture_structure = h1->picture_structure; h->droppable = h1->droppable; h->low_delay = h1->low_delay; for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) { ff_h264_unref_picture(h, &h->DPB[i]); if (h1->DPB[i].f->buf[0] && (ret = ff_h264_ref_picture(h, &h->DPB[i], &h1->DPB[i])) < 0) return ret; } h->cur_pic_ptr = REBASE_PICTURE(h1->cur_pic_ptr, h, h1); ff_h264_unref_picture(h, &h->cur_pic); if (h1->cur_pic.f->buf[0]) { ret = ff_h264_ref_picture(h, &h->cur_pic, &h1->cur_pic); if (ret < 0) return ret; } h->enable_er = h1->enable_er; h->workaround_bugs = h1->workaround_bugs; h->low_delay = h1->low_delay; h->droppable = h1->droppable; h->is_avc = h1->is_avc; h->nal_length_size = h1->nal_length_size; copy_fields(h, h1, poc_lsb, current_slice); copy_picture_range(h->short_ref, h1->short_ref, 32, h, h1); copy_picture_range(h->long_ref, h1->long_ref, 32, h, h1); copy_picture_range(h->delayed_pic, h1->delayed_pic, MAX_DELAYED_PIC_COUNT + 2, h, h1); if (!h->cur_pic_ptr) return 0; if (!h->droppable) { err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index); h->prev_poc_msb = h->poc_msb; h->prev_poc_lsb = h->poc_lsb; } h->prev_frame_num_offset = h->frame_num_offset; h->prev_frame_num = h->frame_num; h->recovery_frame = h1->recovery_frame; h->frame_recovered = h1->frame_recovered; return err; }
1threat
IOS Get content from Web page : I need help.I'm trying to get one value from my web page. When i execute first time returns value null but if I execute another time returns correct value... NSString *urlString = @"http://localhost/app/check.aspx"; NSURL *url = [NSURL URLWithString:urlString]; NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url]; [_WebView loadRequest:urlRequest]; NSString *html = [_WebView stringByEvaluatingJavaScriptFromString: @"document.getElementById('Contador').textContent"]; UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"Avisos Activos" message:html delegate: self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK",nil]; [alert setTag:1]; [alert show]; Thank's for your help
0debug
Avoiding "warning: There are too many unreachable loose objects" during git svn clone/fetch : <p>When running a <code>git svn clone</code> or <code>git svn fetch</code> against a large Subversion repository (100k+ commits), the fetch regularly stops with:</p> <pre><code>Auto packing the repository in background for optimum performance. See "git help gc" for manual housekeeping. error: The last gc run reported the following. Please correct the root cause and remove .git/gc.log. Automatic cleanup will not be performed until the file is removed. warning: There are too many unreachable loose objects; run 'git prune' to remove them. gc --auto: command returned error: 255 </code></pre> <p>In order to recover I have to follow the instructions, run a more aggressive prune and gc, remove the log-file and continue, only to have it happen again after another batch of say 10k commits are read.</p> <p>How can this problem be avoided?</p>
0debug
Sql Server Management Studio closes immediately after startup : <p>Sql Server Management Studio closes in about five seconds after startup. No messages are being displayed (even in a console) and no logs occur in a Windows Event Viewer. I have tried to install different SSMS versions , i.e. 16.X, 17.Y, but it have not helped. I have also tried to <i>repair</i> VS 2017 and SSMS.</p> <p>This problem occured for the first time, when I unistalled Visual Studio 2015 and its related components, like SSMS, and installed VS 2017 and newer version of SSMS (16.X).</p> <p>What can I do to make SSMS not closing immediately after startup?</p>
0debug
static int read_old_huffman_tables(HYuvContext *s) { GetBitContext gb; int i; init_get_bits(&gb, classic_shift_luma, classic_shift_luma_table_size * 8); if (read_len_table(s->len[0], &gb) < 0) return -1; init_get_bits(&gb, classic_shift_chroma, classic_shift_chroma_table_size * 8); if (read_len_table(s->len[1], &gb) < 0) return -1; for(i=0; i<256; i++) s->bits[0][i] = classic_add_luma [i]; for(i=0; i<256; i++) s->bits[1][i] = classic_add_chroma[i]; if (s->bitstream_bpp >= 24) { memcpy(s->bits[1], s->bits[0], 256 * sizeof(uint32_t)); memcpy(s->len[1] , s->len [0], 256 * sizeof(uint8_t)); } memcpy(s->bits[2], s->bits[1], 256 * sizeof(uint32_t)); memcpy(s->len[2] , s->len [1], 256 * sizeof(uint8_t)); for (i = 0; i < 3; i++) { ff_free_vlc(&s->vlc[i]); init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0); } generate_joint_tables(s); return 0; }
1threat
def tetrahedral_number(n): return (n * (n + 1) * (n + 2)) / 6
0debug
React Native ios build failed on react-native run-ios : <p>getting this error</p> <blockquote> <p>** BUILD FAILED **</p> <p>The following build commands failed: CompileC /Users/karthikn/AwesomeProject/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/React.build/Objects-normal/x86_64/RCTTabBarItem.o Views/RCTTabBarItem.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (1 failure)</p> <p>Installing build/Build/Products/Debug-iphonesimulator/AwesomeProject.app An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2): Failed to install the requested application An application bundle was not found at the provided path. Provide a valid path to the desired application bundle. Print: Entry, ":CFBundleIdentifier", Does Not Exist</p> <p>Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/AwesomeProject.app/Info.plist Print: Entry, ":CFBundleIdentifier", Does Not Exist</p> </blockquote>
0debug
what is the meaning of the following command and why its not given at help menu of nmap? : sample command:sudo nmap -sP -n 192.168.0.0-255 sample output: Starting Nmap 7.60 ( https://nmap.org ) at 2017-10-14 16:09 +06 Nmap scan report for 192.168.0.1 Host is up (0.0035s latency). MAC Address: 20:L6:A7:55:3D:44 (D-link Technologies) Nmap scan report for 192.168.0.104 Host is up (0.20s latency). MAC Address: 18:97:F8:15:26:D9 (Zen Mobile Communication Technology) Nmap scan report for 192.168.0.118 Host is up. Nmap done: 256 IP addresses (3 hosts up) scanned in 6.31 seconds what does -sP mean and why is it used? This command works properly but it is not listed to man and help menu...Please elaborate the circumstances
0debug
static void absolute_mouse_grab(void) { int mouse_x, mouse_y; if (SDL_GetAppState() & SDL_APPINPUTFOCUS) { SDL_GetMouseState(&mouse_x, &mouse_y); if (mouse_x > 0 && mouse_x < real_screen->w - 1 && mouse_y > 0 && mouse_y < real_screen->h - 1) { sdl_grab_start(); } } }
1threat
Python's global variable reference issue of multiple modules : Example code: The result is : {} in b {} in b {} in b ... It is assumed to be: {time1: 1} {time2: 1} {time3: 1} ... Could you tell me why?
0debug
Internal storage hidden : <p>In my android phone, I have both internal storage and SD card. But the internal storage isn't shown in the default write disk. If I download any new app, the app will be stored in internal device as well. But if I take pictures then the picture won't be able to see the internal storage and hence I won't be able to add picture in internal storage. So I formatted my phone. Internal storage came back in "default write disk" someday ago. But it has gone again now. </p>
0debug
Randomize stylesheet.css per page visit : <p>I have a quick question what the best practice approach is with JS or Jquery concerning the randomization of stylesheets.</p> <p>I plan to 5 to 6 different stylesheet.css documents handling only color elements (background, href, color). What I try to achieve is to randomize which stylesheet file (For example red, green, black, white) is loaded per user visit.</p> <p>Is there a JS library for this purpose or a common practice in use already? </p>
0debug
static void net_socket_accept(void *opaque) { NetSocketListenState *s = opaque; NetSocketState *s1; struct sockaddr_in saddr; socklen_t len; int fd; for(;;) { len = sizeof(saddr); fd = qemu_accept(s->fd, (struct sockaddr *)&saddr, &len); if (fd < 0 && errno != EINTR) { return; } else if (fd >= 0) { break; } } s1 = net_socket_fd_init(s->vlan, s->model, s->name, fd, 1); if (!s1) { closesocket(fd); } else { snprintf(s1->nc.info_str, sizeof(s1->nc.info_str), "socket: connection from %s:%d", inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port)); } }
1threat
Unit Testing on a c code which writes on files in a particular directory : <p>I've written a C code which takes a path to a directory and a string s. After opening the directory, the code looks for files with a particular extension and write the string given as a second argument to the last line of these files and a \n after it. This is all my function does (finding files with a particular extension and writing something at the end of the file). The C code for the function is done but I need to write some tests for the function using Cunit and I don't have any Idea how to write them. I've just written down what I want to test (below) but I don't know how to write them using Cunit. Can anyone help me with that? Thanks</p> <ul> <li>check if the user checks if the string 's' is nULL => segmentation fault</li> <li>check if bad address is given to the path argument of the function when there is no ".extension" file </li> <li>check if strcmp compares ".extension" and not "extension" </li> <li>check if the user uses == instead of strcmp to compare the extension</li> <li>check if the string 's' is written on a new line </li> <li>check the size of the string 's' sent to write => sent without \0 by strlen and the type is size_t</li> <li>check if the file is opened for writing (and not read only)</li> <li>check if string 's' is converted to void* before giving it to write function </li> <li>check if the return value of open ("fd") is checked </li> <li>check if the return value of opening a directory is checked (null or not)</li> <li>check if the return value of reading a directory is checked (null or not)</li> <li>check if the extension is checked (the string 's' is not added to all the files with other extensions</li> <li>check if the function ignores the '.' et '..' directories => DT_REG </li> <li>check if the file is closed after being opened</li> <li>check the return value of close </li> <li>check if the directory is closed after being opened</li> <li>check the return value of the directory</li> </ul>
0debug
Windows UI Automation doesn't recognize button controls : <p>I'm having problems trying to identify via <em>Windows UI Automation</em> the button controls that are inside the <em>Notification Area</em> window (classname: <strong>ToolbarWindow32</strong>):</p> <p><a href="https://i.stack.imgur.com/lwe5c.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lwe5c.png" alt="enter image description here"></a></p> <p>I verified via the <em>Windows UI Automation</em> tools deployed in the <em>Windows SDK</em> that those "icons" are controls of type <code>ControlType.Button</code>, however when I try to run the code below I get a null-reference exception because the search condition I use doesn't get any control.</p> <p>I'm doing something wrong, or maybe I found some kind of limitation in <em>Windows UI Automation</em> ?</p> <p>This is the code, I mixed it with WinAPI calls just to facilitate the task for the helper users who maybe preffers to use that methodology.</p> <pre><code>Dim tskBarClassName As String = "Shell_TrayWnd" Dim tskBarHwnd As IntPtr = NativeMethods.FindWindow(tskBarClassName, Nothing) Dim systrayBarClassName As String = "TrayNotifyWnd" Dim systrayBarHwnd As IntPtr = NativeMethods.FindWindowEx(tskBarHwnd, IntPtr.Zero, systrayBarClassName, Nothing) Dim ntfyBarClassName As String = "ToolbarWindow32" Dim ntfyBarHwnd As IntPtr = NativeMethods.FindWindowEx(systrayBarHwnd, IntPtr.Zero, ntfyBarClassName, Nothing) Dim window As AutomationElement = AutomationElement.FromHandle(ntfyBarHwnd) Dim condition As New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button) Dim button As AutomationElement = window.FindFirst(TreeScope.Descendants, condition) MsgBox(button.Current.Name) ' Here throws the null-reference exception. </code></pre> <p>Any solution for this?</p>
0debug
How can i access a char in string in at specific number? : <p>I tried this code but it is giving me errors. So how can i access a character in a string in kotlin. in java it can be done by charAt() method.</p> <pre><code>private fun abc(x: String) { var i: Int = 0 while (x[i].toString() != "+") { var y: Char = x[i] i++ } } </code></pre>
0debug
static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext *c) { int i, start_index = 0, start_number = 1; if (c->window_size) { start_index = FFMAX(os->nb_segments - c->window_size, 0); start_number = FFMAX(os->segment_index - c->window_size, 1); } if (c->use_template) { int timescale = c->use_timeline ? os->ctx->streams[0]->time_base.den : AV_TIME_BASE; avio_printf(out, "\t\t\t\t<SegmentTemplate timescale=\"%d\" ", timescale); if (!c->use_timeline) avio_printf(out, "duration=\"%d\" ", c->last_duration); avio_printf(out, "initialization=\"%s\" media=\"%s\" startNumber=\"%d\">\n", c->init_seg_name, c->media_seg_name, c->use_timeline ? start_number : 1); if (c->use_timeline) { avio_printf(out, "\t\t\t\t\t<SegmentTimeline>\n"); for (i = start_index; i < os->nb_segments; ) { Segment *seg = os->segments[i]; int repeat = 0; avio_printf(out, "\t\t\t\t\t\t<S "); if (i == start_index) avio_printf(out, "t=\"%"PRId64"\" ", seg->time); avio_printf(out, "d=\"%d\" ", seg->duration); while (i + repeat + 1 < os->nb_segments && os->segments[i + repeat + 1]->duration == seg->duration) repeat++; if (repeat > 0) avio_printf(out, "r=\"%d\" ", repeat); avio_printf(out, "/>\n"); i += 1 + repeat; } avio_printf(out, "\t\t\t\t\t</SegmentTimeline>\n"); } avio_printf(out, "\t\t\t\t</SegmentTemplate>\n"); } else if (c->single_file) { avio_printf(out, "\t\t\t\t<BaseURL>%s</BaseURL>\n", os->initfile); avio_printf(out, "\t\t\t\t<SegmentList timescale=\"%d\" duration=\"%d\" startNumber=\"%d\">\n", AV_TIME_BASE, c->last_duration, start_number); avio_printf(out, "\t\t\t\t\t<Initialization range=\"%"PRId64"-%"PRId64"\" />\n", os->init_start_pos, os->init_start_pos + os->init_range_length - 1); for (i = start_index; i < os->nb_segments; i++) { Segment *seg = os->segments[i]; avio_printf(out, "\t\t\t\t\t<SegmentURL mediaRange=\"%"PRId64"-%"PRId64"\" ", seg->start_pos, seg->start_pos + seg->range_length - 1); if (seg->index_length) avio_printf(out, "indexRange=\"%"PRId64"-%"PRId64"\" ", seg->start_pos, seg->start_pos + seg->index_length - 1); avio_printf(out, "/>\n"); } avio_printf(out, "\t\t\t\t</SegmentList>\n"); } else { avio_printf(out, "\t\t\t\t<SegmentList timescale=\"%d\" duration=\"%d\" startNumber=\"%d\">\n", AV_TIME_BASE, c->last_duration, start_number); avio_printf(out, "\t\t\t\t\t<Initialization sourceURL=\"%s\" />\n", os->initfile); for (i = start_index; i < os->nb_segments; i++) { Segment *seg = os->segments[i]; avio_printf(out, "\t\t\t\t\t<SegmentURL media=\"%s\" />\n", seg->file); } avio_printf(out, "\t\t\t\t</SegmentList>\n"); } }
1threat
static inline void gen_op_sdivx(TCGv dst, TCGv src1, TCGv src2) { int l1, l2; l1 = gen_new_label(); l2 = gen_new_label(); tcg_gen_mov_tl(cpu_cc_src, src1); tcg_gen_mov_tl(cpu_cc_src2, src2); gen_trap_ifdivzero_tl(cpu_cc_src2); tcg_gen_brcondi_tl(TCG_COND_NE, cpu_cc_src, INT64_MIN, l1); tcg_gen_brcondi_tl(TCG_COND_NE, cpu_cc_src2, -1, l1); tcg_gen_movi_i64(dst, INT64_MIN); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_div_i64(dst, cpu_cc_src, cpu_cc_src2); gen_set_label(l2); }
1threat
How can I get the FULL list of slack emoji through API? : <p>I am using the slack API to get the full list of emoji, so that when I get a message, I will just replace <code>:squirrel:</code> with the icon.</p> <p>The method <code>https://slack.com/api/emoji.list</code> works like a charm, but returns 30 icons only. I think this is correct since in the documentation page (<a href="https://api.slack.com/methods/emoji.list" rel="noreferrer">https://api.slack.com/methods/emoji.list</a>) they say:</p> <blockquote> <p>This method lists the custom emoji for a team.</p> </blockquote> <p>Fair enough, but how can I get the full list of the associations icon-name / icon URL ?</p>
0debug
void ff_rtp_send_mpegvideo(AVFormatContext *s1, const uint8_t *buf1, int size) { RTPDemuxContext *s = s1->priv_data; int len, h, max_packet_size; uint8_t *q; int begin_of_slice, end_of_slice, frame_type, temporal_reference; max_packet_size = s->max_payload_size; begin_of_slice = 1; end_of_slice = 0; frame_type = 0; temporal_reference = 0; while (size > 0) { int begin_of_sequence; begin_of_sequence = 0; len = max_packet_size - 4; if (len >= size) { len = size; end_of_slice = 1; } else { const uint8_t *r, *r1; int start_code; r1 = buf1; while (1) { start_code = -1; r = ff_find_start_code(r1, buf1 + size, &start_code); if((start_code & 0xFFFFFF00) == 0x100) { if (start_code == 0x100) { frame_type = (r[1] & 0x38) >> 3; temporal_reference = (int)r[0] << 2 | r[1] >> 6; } if (start_code == 0x1B8) { begin_of_sequence = 1; } if (r - buf1 < len) { if (begin_of_slice == 0) { end_of_slice = 1; len = r - buf1 - 4; break; } r1 = r; } else { if (r - r1 < max_packet_size) { len = r1 - buf1 - 4; end_of_slice = 1; } break; } } else { break; } } } h = 0; h |= temporal_reference << 16; h |= begin_of_sequence << 13; h |= begin_of_slice << 12; h |= end_of_slice << 11; h |= frame_type << 8; q = s->buf; *q++ = h >> 24; *q++ = h >> 16; *q++ = h >> 8; *q++ = h; memcpy(q, buf1, len); q += len; s->timestamp = s->cur_timestamp; ff_rtp_send_data(s1, s->buf, q - s->buf, (len == size)); buf1 += len; size -= len; begin_of_slice = end_of_slice; end_of_slice = 0; } }
1threat
window.location.href = 'http://attack.com?user=' + user_input;
1threat
How to obscure a line behind a surface plot in matplotlib? : <p>I want to plot data using Matplotlib via a colormap on the surface of a sphere. Additionally, I would like to add a 3D line plot. The code I have so far is this:</p> <pre><code>import matplotlib import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import numpy as np NPoints_Phi = 30 NPoints_Theta = 30 radius = 1 pi = np.pi cos = np.cos sin = np.sin phi_array = ((np.linspace(0, 1, NPoints_Phi))**1) * 2*pi theta_array = (np.linspace(0, 1, NPoints_Theta) **1) * pi phi, theta = np.meshgrid(phi_array, theta_array) x_coord = radius*sin(theta)*cos(phi) y_coord = radius*sin(theta)*sin(phi) z_coord = radius*cos(theta) #Make colormap the fourth dimension color_dimension = x_coord minn, maxx = color_dimension.min(), color_dimension.max() norm = matplotlib.colors.Normalize(minn, maxx) m = plt.cm.ScalarMappable(norm=norm, cmap='jet') m.set_array([]) fcolors = m.to_rgba(color_dimension) theta2 = np.linspace(-np.pi, 0, 1000) phi2 = np.linspace( 0 , 5 * 2*np.pi , 1000) x_coord_2 = radius * np.sin(theta2) * np.cos(phi2) y_coord_2 = radius * np.sin(theta2) * np.sin(phi2) z_coord_2 = radius * np.cos(theta2) # plot fig = plt.figure() ax = fig.gca(projection='3d') ax.plot(x_coord_2, y_coord_2, z_coord_2,'k|-', linewidth=1 ) ax.plot_surface(x_coord,y_coord,z_coord, rstride=1, cstride=1, facecolors=fcolors, vmin=minn, vmax=maxx, shade=False) fig.show() </code></pre> <p>This code produces an image that looks like this: <a href="https://i.stack.imgur.com/medST.png" rel="noreferrer"><img src="https://i.stack.imgur.com/medST.png" alt="this"></a> which is ALMOST what I want. However, the black line should be obscured by the surface plot when it is in the background and visible when it is in the foreground. In other words, the black line should not "shine through" the sphere. </p> <p>Can this be done in Matplotlib and without the use of Mayavi?</p>
0debug
Regex expressions : <p>What's the regex expression for:</p> <ul> <li>Begins with a certain String? such as: begins with "/retour,merci"</li> <li>Ends with a certain String? such as: ends with "/blog-accueils.html"</li> <li>And Contains String? such as: contains "data/"</li> </ul>
0debug
extract binary value of mantissa : <p>I have a bit problem. Given: some real number(for example -474.875) Task: extract BINARY value of mantissa For number -474.875 I need this value 1,<strong><em>11011010111</em></strong> * 2^8 I have a programm:</p> <pre><code>const float d = -474.875f; int exponent; const float mantissa = frexp(d, &amp;exponent); double prev = mantissa * pow(2, exponent); </code></pre> <p>It calculates decimal mantissa (for my number it is -0.927490234) and exponent (9). I'm tried to convert this mantissa to binary... but failed... I got other value. To get original value: mantissa* 2^exponent. QUESTION: How I can get binary value of mantissa? May be it is possible to do it in more pretty way?</p>
0debug
sql server queries for cleansing string data : i have a table with name and address columns. i need to create two new columns that will hold modified values from these two columns, with special characters cleansed. please help with the queries
0debug
no match for 'operator=' (operand types are 'String' and 'void') : iv been stuck on this for two days... i am querying a webpage that returns a json string using a nodeMCU ESP8266 microcontroller. response from the webpage looks like this: `{"1":true,"2":false,"3":false,"4":true,"5":true,"6":false,"7":false,"8":false}` the code i am using looks like this: #include <ESP8266WiFi.h> #include <ESP8266HTTPClient.h> #include <ArduinoJson.h> String payload = ""; const char* ssid = "ssid"; const char* password = "password"; String url = "example.com/data.json"; void setup() { Serial.begin(115200); delay(2000); while (!Serial); WiFi.begin(ssid, password); while (WiFi.status() !=WL_CONNECTED){ delay(500); Serial.print("."); } Serial.println(WiFi.localIP()); pinMode(D0, OUTPUT); } void loop() { StaticJsonBuffer<100> jsonBuffer; delay(5000); HTTPClient http; http.begin(url); int httpCode = http.GET(); Serial.println(httpCode); Serial.println(http.getString()); if (httpCode > 0) { payload = http.getString(); } http.end(); JsonObject& root = jsonBuffer.parseObject(payload); Serial.println(payload); if(!root.success()) { Serial.println("parseObject() failed"); } if(root["1"] == true) { Serial.println("true"); } digitalWrite(D0, !digitalRead(D0)); } i believe the reason it fails to parse is that the payload variable ends witth a trailing newline character. i then attempted `payload = payload.trim();` but then i get `no match for 'operator=' (operand types are 'String' and 'void')` so i tried `payload = payload.replace("\n,"");` same issue, then i tried `payload = String(payload);` again, failure. what am i doing wrong?
0debug
Designing a responsive web application that supposrts ie6 : <p>I am building a responsive web application for one of my client. the requirement of the client is that he wants the app to be also supported by internet explorer 6 and successors along with all other latest browsers. how do I start and what should I use for the responsiveness of the web app ?</p>
0debug
Rearrange Data in Python : I received data in the following format: Date ,20100423 Open ,1028.75 High ,1029.5 Low ,1026 Close ,1026 S1 ,1030.62082869339 R1 ,1033.6233971724 S2 ,1026.87917130661 R2 ,1023.8766028276 Date ,20100426 Open ,1037.75 High ,1040.5 Low ,1037 Close ,1038.75 S1 ,1043.86350963032 R1 ,1040.79138126515 S2 ,1031.63649036968 R2 ,1034.70861873485 Need to re-arrange in following format: Date Open High Low Close S1 R1 S2 R2 xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx How can I do this in Python using DF?
0debug
static void cirrus_invalidate_region(CirrusVGAState * s, int off_begin, int off_pitch, int bytesperline, int lines) { int y; int off_cur; int off_cur_end; for (y = 0; y < lines; y++) { off_cur = off_begin; off_cur_end = off_cur + bytesperline; off_cur &= TARGET_PAGE_MASK; while (off_cur < off_cur_end) { cpu_physical_memory_set_dirty(s->vram_offset + off_cur); off_cur += TARGET_PAGE_SIZE; } off_begin += off_pitch; } }
1threat
Upload from camera and gallery is not working properly in all the versions : <p>I am trying number of tutorials and sample codes for take an image from gallery or camera then crop the image and upload it to server. I was implemented the code for that in that code am facing few problems the are.</p> <ol> <li>In pre Lollipop devices when I crop the image using photos app the image is not getting reflected in image view but it's showing the message as image saved..</li> <li>In nexus phone both camera and gallery is not working.</li> <li><blockquote> <p>5.0 versions in few devices when I crop the image am getting the image like shown below <a href="https://i.stack.imgur.com/vBsgi.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/vBsgi.jpg" alt="image"></a></p> </blockquote></li> </ol> <p>below is my code snippet.`</p> <pre><code>public void getPhoto() { final String[] items = new String[] { "Take from camera", "Select from gallery" }; ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(getActivity(), android.R.layout.select_dialog_item, items); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Select Image"); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { // pick from // camera if (item == 0) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra( "android.intent.extras.CAMERA_FACING", android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT); mImageCaptureUri = Uri.fromFile(new File(Environment .getExternalStorageDirectory(), "tmp_avatar_" + String.valueOf(System.currentTimeMillis()) + ".jpg")); intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mImageCaptureUri); try { intent.putExtra("return-data", true); startActivityForResult(intent, PICK_FROM_CAMERA); } catch (ActivityNotFoundException e) { e.printStackTrace(); } } else { // pick from file Intent intent = new Intent(Intent.ACTION_PICK); intent.setType("image/*"); // startActivityForResult(intent, SELECT_PICTURE); startActivityForResult(intent, PICK_FROM_FILE); } } }); final AlertDialog dialog = builder.create(); dialog.show(); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != Activity.RESULT_OK) return; switch (requestCode) { case PICK_FROM_CAMERA: doCrop(); break; case PICK_FROM_FILE: mImageCaptureUri = data.getData(); doCrop(); break; case CROP_FROM_CAMERA: Bundle extras = data.getExtras(); if (extras != null) { photo = extras.getParcelable("data"); profile_image = encodeTobase64(photo); saveType = "photo"; try { JSONObject obj = new JSONObject(); obj.put("user_id", user_id); obj.put("mode", saveType); obj.put("photo", profile_image); obj.put("is_profile", 1); saveResponse(obj); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } } File f = new File(mImageCaptureUri.getPath()); if (f.exists()) f.delete(); break; } } private void doCrop() { final ArrayList&lt;CropOption&gt; cropOptions = new ArrayList&lt;CropOption&gt;(); Intent intent = new Intent("com.android.camera.action.CROP"); intent.setType("image/*"); List&lt;ResolveInfo&gt; list = getActivity().getPackageManager() .queryIntentActivities(intent, 0); int size = list.size(); if (size == 0) { Toast.makeText(getActivity(), "Can not find image crop app", Toast.LENGTH_SHORT).show(); return; } else { intent.setData(mImageCaptureUri); intent.putExtra("crop", "true"); intent.putExtra("outputX", 300); intent.putExtra("outputY", 300); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("scale", true); intent.putExtra("circleCrop", new String("")); intent.putExtra("return-data", true); if (size == 1) { Intent i = new Intent(intent); ResolveInfo res = list.get(0); i.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); startActivityForResult(i, CROP_FROM_CAMERA); } else { for (ResolveInfo res : list) { final CropOption co = new CropOption(); co.title = getActivity().getPackageManager() .getApplicationLabel( res.activityInfo.applicationInfo); co.icon = getActivity().getPackageManager() .getApplicationIcon( res.activityInfo.applicationInfo); co.appIntent = new Intent(intent); co.appIntent .setComponent(new ComponentName( res.activityInfo.packageName, res.activityInfo.name)); cropOptions.add(co); } CropOptionAdapter adapter = new CropOptionAdapter( getActivity(), cropOptions); AlertDialog.Builder builder = new AlertDialog.Builder( getActivity()); builder.setTitle("Choose Crop App"); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { startActivityForResult( cropOptions.get(item).appIntent, CROP_FROM_CAMERA); } }); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (mImageCaptureUri != null) { getActivity().getContentResolver().delete( mImageCaptureUri, null, null); mImageCaptureUri = null; } } }); AlertDialog alert = builder.create(); alert.show(); } } } public String encodeTobase64(Bitmap image) { Bitmap immagex = image; ByteArrayOutputStream baos = new ByteArrayOutputStream(); immagex.compress(Bitmap.CompressFormat.JPEG, 100, baos); image_Array = baos.toByteArray(); String imageEncoded = Base64 .encodeToString(image_Array, Base64.DEFAULT); return imageEncoded; } </code></pre> <p>` </p> <p>comment below before duplicating this question because i was checked a lot but didn't find any solution for this, please let me know if you need more information.</p>
0debug
How Can i found Nearst City by lat, lng using Google MAP API : I am trying to get City Name Using Google Map API but not getting. I have got Lat, Lng by using Google API now I want to get City Name in 10KM distance. I am using below URL to get Lat, Lng. https://maps.googleapis.com/maps/api/geocode/json?address=Coburg,Austrelia&key="" 2. I am using https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=".$lat.",".$long."&radius=10000&type=administrative_area_level_2&key="" Please Help
0debug
PHP insert ' into SQL : <pre><code>$type_of_poker = "hold'em no limit"; $sql = "INSERT INTO hands (type_of_poker) VALUES ('$type_of_poker')"; </code></pre> <p>Im trying to put <code>hold'em no limit</code> into a SQL database but it won't let me use <code>'</code> i cant upload <code>holdem no limit</code> for a long list resones that have to do with the rest of my code.</p>
0debug
Clone a variable in php : <p>I am trying to compute a streak of numbers, I have an array of containing 1 and 0 back to back, I am trying to find out the longest time one appeared consecutively, to calculate a winning streak I am trying this:</p> <pre class="lang- prettyprint-override"><code>$l = 56; $holder = 0; $streak = 0; for($i = 1;$i &lt;= $l;$i++){ // all classes is an array contain 1's and 0's. $class = $all_classes[$i]; if($class == 1){ $streak++; } if($class == 0 &amp;&amp; $streak &gt; 0 &amp;&amp; $holder == 0){ // here is the problem i want to hold the value of streak somewhere // before setting it back to 0 to count for next streak $holder == $streak; $streak = 0; } if($class == 0 &amp;&amp; $streak &gt; 0 &amp;&amp; $holder &gt; 0){ // compare both streaks and keep the larger number in holder if($streak &gt; $holder) { $holder = $streak; $streak = 0; } else { $streak = 0; } } } </code></pre> <p> I know my program is incorrect but any solution?</p>
0debug
static void ics_kvm_realize(DeviceState *dev, Error **errp) { ICSState *ics = ICS_SIMPLE(dev); if (!ics->nr_irqs) { error_setg(errp, "Number of interrupts needs to be greater 0"); return; } ics->irqs = g_malloc0(ics->nr_irqs * sizeof(ICSIRQState)); ics->qirqs = qemu_allocate_irqs(ics_kvm_set_irq, ics, ics->nr_irqs); qemu_register_reset(ics_kvm_reset, dev); }
1threat
xen_igd_passthrough_isa_bridge_create(XenPCIPassthroughState *s, XenHostPCIDevice *dev) { uint16_t gpu_dev_id; PCIDevice *d = &s->dev; gpu_dev_id = dev->device_id; igd_passthrough_isa_bridge_create(d->bus, gpu_dev_id); }
1threat
static void vtd_handle_gcmd_qie(IntelIOMMUState *s, bool en) { uint64_t iqa_val = vtd_get_quad_raw(s, DMAR_IQA_REG); trace_vtd_inv_qi_enable(en); if (en) { s->iq = iqa_val & VTD_IQA_IQA_MASK(VTD_HOST_ADDRESS_WIDTH); s->iq_size = 1UL << ((iqa_val & VTD_IQA_QS) + 8); s->qi_enabled = true; trace_vtd_inv_qi_setup(s->iq, s->iq_size); vtd_set_clear_mask_long(s, DMAR_GSTS_REG, 0, VTD_GSTS_QIES); if (s->iq_tail != 0) { trace_vtd_warn_invalid_qi_tail(s->iq_tail); if (!(vtd_get_long_raw(s, DMAR_FSTS_REG) & VTD_FSTS_IQE)) { vtd_fetch_inv_desc(s); } } } else { if (vtd_queued_inv_disable_check(s)) { vtd_set_quad_raw(s, DMAR_IQH_REG, 0); s->iq_head = 0; s->qi_enabled = false; vtd_set_clear_mask_long(s, DMAR_GSTS_REG, VTD_GSTS_QIES, 0); } else { trace_vtd_err_qi_disable(s->iq_head, s->iq_tail, s->iq_last_desc_type); } } }
1threat
static void vmsvga_update_display(void *opaque) { struct vmsvga_state_s *s = opaque; DisplaySurface *surface; bool dirty = false; if (!s->enable) { s->vga.update(&s->vga); return; } vmsvga_check_size(s); surface = qemu_console_surface(s->vga.con); vmsvga_fifo_run(s); vmsvga_update_rect_flush(s); if (memory_region_is_logging(&s->vga.vram)) { vga_sync_dirty_bitmap(&s->vga); dirty = memory_region_get_dirty(&s->vga.vram, 0, surface_stride(surface) * surface_height(surface), DIRTY_MEMORY_VGA); } if (s->invalidated || dirty) { s->invalidated = 0; memcpy(surface_data(surface), s->vga.vram_ptr, surface_stride(surface) * surface_height(surface)); dpy_gfx_update(s->vga.con, 0, 0, surface_width(surface), surface_height(surface)); } if (dirty) { memory_region_reset_dirty(&s->vga.vram, 0, surface_stride(surface) * surface_height(surface), DIRTY_MEMORY_VGA); } }
1threat