problem
stringlengths
26
131k
labels
class label
2 classes
Using Java, How do I check using orignal image that if shape01(circle) exists in image02(square) after converting both into binary images? : I am newbie to openCV and JAVA. It is been two days I am searching for the solutions continuously. I want to check form this [Image][1] that red circle exists inside the square after convert getting following binary images. See Binary Images of [circle and square][1] Please help me ASAP. Thanks in advance. [1]: http://i.stack.imgur.com/WrZXq.png
0debug
void qemu_co_queue_restart_all(CoQueue *queue) { while (qemu_co_queue_next(queue)) { } }
1threat
Query to find names of all users who are not friends to each other : Friendship database contains two tables, one that keeps track of all the users, and one that maintains friendship relationships between users CREATE TABLE users ( ID int, Name varchar(255) ); CREATE TABLE friends ( ID1 int, ID2 int ); For each friendship there is exactly one entry in the friends table, containing the primary keys in users of the two friends. And i want find names of all users who are not friends to each other
0debug
ruby integer range and running through classes : I have started with the below but the `@limit` is throwing with 'params' not found. Also, how can I run my num variable through both my classes `Range` and `Multiply` before it puts. class Range def clamp(min, max) self < min ? min : self > max ? max : self end end class Multiply def initialize(id, squared, cubed) @id = num @squared = (num * num) @cubed = (num * num * num) end end # @limit = (params[:limit] || 10).clamp(0, 100) puts 'Please insert your favorite number between 1 and 100.' num = gets.to_i puts 'You picked ' + num.to_s + '?' puts 'You picked ' + num.to_s.Multiply.squared + '?'
0debug
I need to redirect page after registration in php : <p>I would like to redirect my registration page automatically to the login page automatically. Any idea on this?</p>
0debug
static void bt_dummy_lmp_connection_complete(struct bt_link_s *link) { if (link->slave->reject_reason) fprintf(stderr, "%s: stray LMP_not_accepted received, fixme\n", __func__); else fprintf(stderr, "%s: stray LMP_accepted received, fixme\n", __func__); exit(-1); }
1threat
I do not understand the next return of heroku logs : I did a app in ruby on rails and work fine but when i up the app to heroku, they give me the next error and i realy don t know what thats mean [here is the photo of the error][1]and here[it is my page in localhosting][2],is my first question so if you need more information ask me please. [1]: https://i.stack.imgur.com/qJTJK.png [2]: https://i.stack.imgur.com/GKYom.png
0debug
static int64_t migration_get_rate_limit(void *opaque) { MigrationState *s = opaque; return s->xfer_limit; }
1threat
Oracle groupby of worlds from text field : I have a table of Full Name - varchar2(200) Age - Number can I get the count of name for example that inside the textfield and I dont mean to `Select Count(*) from table;` thank you
0debug
How display logo on each page on the print? : <p>I work on design of the report for my customer. I need to display logo on each page when customer prints the report.</p> <p>here is my html row that I want to put on the header of each page when I on print mode:</p> <pre><code>&lt;img style="page-break-before:always" src="/somepath/Content/images/logo.png" class="visible-print" style="width:200px;height:100px" alt="" /&gt; </code></pre> <p>Is there any way to implement it?</p>
0debug
static void nvme_init_sq(NvmeSQueue *sq, NvmeCtrl *n, uint64_t dma_addr, uint16_t sqid, uint16_t cqid, uint16_t size) { int i; NvmeCQueue *cq; sq->ctrl = n; sq->dma_addr = dma_addr; sq->sqid = sqid; sq->size = size; sq->cqid = cqid; sq->head = sq->tail = 0; sq->io_req = g_malloc(sq->size * sizeof(*sq->io_req)); QTAILQ_INIT(&sq->req_list); QTAILQ_INIT(&sq->out_req_list); for (i = 0; i < sq->size; i++) { sq->io_req[i].sq = sq; QTAILQ_INSERT_TAIL(&(sq->req_list), &sq->io_req[i], entry); } sq->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, nvme_process_sq, sq); assert(n->cq[cqid]); cq = n->cq[cqid]; QTAILQ_INSERT_TAIL(&(cq->sq_list), sq, entry); n->sq[sqid] = sq; }
1threat
What is the difference between Observable.lift and Observable.pipe in rxjs? : <p><a href="http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html" rel="noreferrer">The docs</a> define <code>Observable.lift(operator: Operator)</code> as:</p> <blockquote> <p>Creates a new Observable, with this Observable as the source, and the passed operator defined as the new observable's operator.</p> </blockquote> <p>and <code>Observable.pipe(operations: ...*)</code> as:</p> <blockquote> <p>Used to stitch together functional operators into a chain. Returns the Observable result of all of the operators having been called in the order they were passed in.</p> </blockquote> <p>So clearly <code>.pipe</code> can accept multiple operators, which <code>.lift</code> cannot. But <code>pipe</code> can also accept a single operator, so this cannot be the only difference. From the docs alone it isn't clear to me what they are both for and why they exist. <strong>Can someone please explain the purpose of each of these functions, and when each of them should be used?</strong></p> <hr> <h3>Observations so far</h3> <p>The following code (typescript):</p> <pre><code>let myObservable = Observable.of(1, 2, 3); let timesByTwoPiped = myObservable.pipe(map(n =&gt; n * 2)); let timesByTwoLift = myObservable.lift(new TimesByTwoOperator()); timesByTwoPiped.subscribe(a =&gt; console.log('pipe:' + a)); timesByTwoLift.subscribe(a =&gt; console.log('lift:' + a)); </code></pre> <p>and <code>TimesByTwoOperator</code>:</p> <pre><code>class TimesByTwoOperator implements Operator&lt;number, number&gt; { call(subscriber: Subscriber&lt;number&gt;, source: Observable&lt;number&gt;): void | Function | AnonymousSubscription { source.subscribe(n =&gt; { subscriber.next(n * 2); }); } } </code></pre> <p>Seems to achieve the same result using both <code>.lift</code> and <code>.pipe</code>. This experiment shows I'm correct in thinking that both lift and pipe can be used to achieve the same thing, albeit with the pipe version being more succinct in this case.</p> <p>As the <code>Operator</code> type that is passed in to <code>.lift</code> is given full access to the source observable and subscriptions, clearly powerful things could be achieved with it; for example keeping state. But I'm aware that the same sort of power can also be achieved with <code>.pipe</code>, for example with the <a href="https://www.learnrxjs.io/operators/transformation/buffer.html" rel="noreferrer"><code>buffer</code> operator</a>.</p> <p>It's still not clear to me why they both exist and what each is designed for.</p>
0debug
static inline bool cpu_handle_interrupt(CPUState *cpu, TranslationBlock **last_tb) { CPUClass *cc = CPU_GET_CLASS(cpu); int interrupt_request = cpu->interrupt_request; if (unlikely(interrupt_request)) { if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) { interrupt_request &= ~CPU_INTERRUPT_SSTEP_MASK; } if (interrupt_request & CPU_INTERRUPT_DEBUG) { cpu->interrupt_request &= ~CPU_INTERRUPT_DEBUG; cpu->exception_index = EXCP_DEBUG; return true; } if (replay_mode == REPLAY_MODE_PLAY && !replay_has_interrupt()) { } else if (interrupt_request & CPU_INTERRUPT_HALT) { replay_interrupt(); cpu->interrupt_request &= ~CPU_INTERRUPT_HALT; cpu->halted = 1; cpu->exception_index = EXCP_HLT; return true; } #if defined(TARGET_I386) else if (interrupt_request & CPU_INTERRUPT_INIT) { X86CPU *x86_cpu = X86_CPU(cpu); CPUArchState *env = &x86_cpu->env; replay_interrupt(); cpu_svm_check_intercept_param(env, SVM_EXIT_INIT, 0, 0); do_cpu_init(x86_cpu); cpu->exception_index = EXCP_HALTED; return true; } #else else if (interrupt_request & CPU_INTERRUPT_RESET) { replay_interrupt(); cpu_reset(cpu); return true; } #endif else { if (cc->cpu_exec_interrupt(cpu, interrupt_request)) { replay_interrupt(); *last_tb = NULL; } interrupt_request = cpu->interrupt_request; } if (interrupt_request & CPU_INTERRUPT_EXITTB) { cpu->interrupt_request &= ~CPU_INTERRUPT_EXITTB; *last_tb = NULL; } } if (unlikely(atomic_read(&cpu->exit_request) || replay_has_interrupt())) { atomic_set(&cpu->exit_request, 0); cpu->exception_index = EXCP_INTERRUPT; return true; } return false; }
1threat
verilog, i have to define 31 "and" gates , it is showing error g[i]? is there any other way? : [it is showing error[\]\[1\]][1] [enter image description here][1] [1]: https://i.stack.imgur.com/pTnzd.png
0debug
Swift: Get the count of an array that includes subscripts : <p>I have an array of strings that have superscripts attached to each element. See the example below.</p> <pre><code>var myArray = ["first": ["1", "2", "3"], "second": ["4", "5", "6"], "third": ["7", "8", "9"]] </code></pre> <p>Now all I want to do is get the count of elements, like <code>myArray.count</code> but this is throwing the error <code>Dictionary&lt;String, [String]&gt;.Index' does not conform to protocol 'Sequence'</code>. I'm guessing it's the superscripts causing the problem but I'm new to Swift so I don't know how to get around this and just count the top elements.</p>
0debug
Jupyter Notebook (only) Memory Error, same code run in a conventional .py and works : <p>I have an assignment for a Deep Learning class, and they provide a Jupyter notebook as a base code, the thing is that after running the data import and reshape, jupyter notebook through a "Memory Error", after some analysis y tried to compile the same code in a normal .py file, and everything runs well.</p> <p>The thing is that I'm required (preferably) to use the Jupyter notebook as the base for development, since is more interactive for the kind of task.</p> <pre><code>&lt;ipython-input-2-846f80a40ce2&gt; in &lt;module&gt;() 2 # Load the raw CIFAR-10 data 3 cifar10_dir = 'datasets\\' ----&gt; 4 X, y = load_CIFAR10(cifar10_dir) C:\path\data_utils.pyc in load_CIFAR10(ROOT) 18 f = os.path.join(ROOT, 'cifar10_train.p') 19 print('Path: ' + f ); ---&gt; 20 Xtr, Ytr = load_CIFAR_batch(f) 21 return Xtr, Ytr 22 C:\path\data_utils.pyc in load_CIFAR_batch(filename) 10 X = np.array(datadict['data']) 11 Y = np.array(datadict['labels']) ---&gt; 12 X = X.reshape(-1, 3, 32, 32).transpose(0,2,3,1).astype("float") 13 return X, Y 14 MemoryError: </code></pre> <p>The error occurs in the line 12, i know is a memory consuming assignment, but that doesn't mean that 4 GB of RAM wont suffice, and that was confirmed when the code run without problems outside Jupyter.</p> <p>My Guess is it has something to do with the memory limit either by Jupyter or by Chrome, but I'm not sure and also dont know how to solve it.</p> <p>By the way:</p> <ul> <li>I have a Windows 10 laptop with 4GB of RAM</li> <li>and Chrome Version 57.0.2987.133 (64-bit)</li> </ul>
0debug
Difference between static web page and dynamic web page? : <p>I want to know the example describing the difference between static web page and dynamic web page??</p>
0debug
void ff_put_h264_qpel4_mc23_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_midv_qrt_4w_msa(src - (2 * stride) - 2, stride, dst, stride, 4, 1); }
1threat
static inline void RENAME(rgb16ToY)(uint8_t *dst, uint8_t *src, int width) { int i; for(i=0; i<width; i++) { int d= ((uint16_t*)src)[i]; int r= d&0x1F; int g= (d>>5)&0x3F; int b= (d>>11)&0x1F; dst[i]= ((2*RY*r + GY*g + 2*BY*b)>>(RGB2YUV_SHIFT-2)) + 16; } }
1threat
Ability to use firestore db only in offline mode : <p>I am mobile developer. I want to have just one instrument for saving data in app (no other DB ). For example: Non-premium user use data in app only in offline mode, when he become a premium user we may sync data with cloud. Is this ability exist? How to implement it?</p>
0debug
How to verify if checkbox is checked or unchecked in java for android studio? : <p>I have in my quiz a question (q7) with 4 possible answers checkbox ( answer71, answer72, answer73 and answer74). The right answers ar answer72 and answer73. How can I verify (in java on android studio) if only the 2 good answers ar checked (and the 2 wrong answers ar not checked) and then to make the score =+1. Thank you.</p>
0debug
jQuery replace click() with document.ready() : <p>SO I found this jquery function: <a href="http://codepen.io/niklas-r/pen/HsjEv" rel="nofollow">http://codepen.io/niklas-r/pen/HsjEv</a></p> <p>html: </p> <pre><code>&lt;p id="el"&gt;0%&lt;/p&gt; &lt;button id="startCount"&gt;Count&lt;/button&gt; </code></pre> <p>JS:</p> <pre><code>$("#startCount").on("click", function (evt) { var $el = $("#el"), value = 56.4; evt.preventDefault(); $({percentage: 0}).stop(true).animate({percentage: value}, { duration : 2000, easing: "easeOutExpo", step: function () { // percentage with 1 decimal; var percentageVal = Math.round(this.percentage * 10) / 10; $el.text(percentageVal + '%'); } }).promise().done(function () { // hard set the value after animation is done to be // sure the value is correct $el.text(value + "%"); }); }); </code></pre> <p>It increment numbers with animation. It doesnt work though, when I replace click with document.ready(). How do I make it work?</p>
0debug
static av_cold int mm_decode_init(AVCodecContext *avctx) { MmContext *s = avctx->priv_data; s->avctx = avctx; avctx->pix_fmt = AV_PIX_FMT_PAL8; s->frame = av_frame_alloc(); if (!s->frame) return AVERROR(ENOMEM); return 0;
1threat
how to check if a int is dvisible by another int : so im trying to have a program that checks if a integer is divisible by another int: divide 8 / 2 or 8/3 and im using if statements. This is what im using: if(int1 / 2){ printf("2:yes \n"); } else{ printf("2:no \n"); } The result I get is as long as the scanned number is below or equal to the divisor it prints the first output.
0debug
static void RENAME(yuv2yuvX_ar)(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, int dstW, int chrDstW) { if (uDest) { x86_reg uv_off = c->uv_off; YSCALEYUV2YV12X_ACCURATE(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0) YSCALEYUV2YV12X_ACCURATE(CHR_MMX_FILTER_OFFSET, vDest - uv_off, chrDstW + uv_off, uv_off) } if (CONFIG_SWSCALE_ALPHA && aDest) { YSCALEYUV2YV12X_ACCURATE(ALP_MMX_FILTER_OFFSET, aDest, dstW, 0) } YSCALEYUV2YV12X_ACCURATE(LUM_MMX_FILTER_OFFSET, dest, dstW, 0) }
1threat
ExoPlayer HlsMediaSource() deprecated : <p>The <code>HlsMediaSource()</code> method is deprecated (I'm currently on <code>exoplayer:2.6.1</code>). What is the recommended method to use for HLS-media instead?</p>
0debug
How to calculate same name as one? : I'm trying to calculate how many lines are there and my code is working but I failed to calculate if there is same name in each line as one for example john 01/2 john 02/3 def number_people(path): x = 0 with open(path) as f: for line in f: if line.strip(): x += 1 return x
0debug
static void test_parse_invalid_path(void) { g_test_trap_subprocess ("/logging/parse_invalid_path/subprocess", 0, 0); g_test_trap_assert_passed(); g_test_trap_assert_stdout(""); g_test_trap_assert_stderr("Bad logfile format: /tmp/qemu-%d%d.log\n"); }
1threat
static int guess_disk_lchs(BlockDriverState *bs, int *pcylinders, int *pheads, int *psectors) { uint8_t buf[BDRV_SECTOR_SIZE]; int i, heads, sectors, cylinders; struct partition *p; uint32_t nr_sects; uint64_t nb_sectors; bdrv_get_geometry(bs, &nb_sectors); if (bdrv_read_unthrottled(bs, 0, buf, 1) < 0) { return -1; } if (buf[510] != 0x55 || buf[511] != 0xaa) { return -1; } for (i = 0; i < 4; i++) { p = ((struct partition *)(buf + 0x1be)) + i; nr_sects = le32_to_cpu(p->nr_sects); if (nr_sects && p->end_head) { heads = p->end_head + 1; sectors = p->end_sector & 63; if (sectors == 0) { continue; } cylinders = nb_sectors / (heads * sectors); if (cylinders < 1 || cylinders > 16383) { continue; } *pheads = heads; *psectors = sectors; *pcylinders = cylinders; trace_hd_geometry_lchs_guess(bs, cylinders, heads, sectors); return 0; } } return -1; }
1threat
Two same words in string : <p>I have problem and I dont have any idea how solve it. I have strings for example this.</p> <pre><code>$string = "car apple computer car" $string2 = "car apple computer" </code></pre> <p>I need function, which can to distinguish if string contain two same words. So for $string return 1 and for $string2 return 0</p>
0debug
Why does the program run the lines after line 13 : I want to make a program that gets a number input and finds the closest perfect square to determine the square length. Thus, the closest perfect square has to be less than the input. For example, if the input is 8, the largest side length of the square is 2. import java.util.Scanner; public class J1 { public static void main(String[] args) { int a; int a1; Scanner number = new Scanner(System.in); System.out.println("Number: "); a = number.nextInt(); int n = (int) Math.sqrt(a1); for (int a1=a; a1<a; a1--) { if (Math.floor(a1)==0) System.out.println("The largest square has side length" + a1); } } }
0debug
void OPPROTO op_addzeo (void) { do_addzeo(); RETURN(); }
1threat
Getting an error on decoding JSON Expected to decode Array<Any> but found a dictionary instead : Getting an error on decoding JSON in swift 4.2, if you like to help me out. Expected to decode Array<Any> but found a dictionary instead. Tried Various search and code change but useless. Failed to decode. TypeMismatch <br> Many Thanks!!! Model: public struct NewsSource: Equatable, Decodable { public let id: String? public let name: String? public let sourceDescription: String? public let url: URL? enum CodingKeys: String, CodingKey { case id case name case sourceDescription = "description" case url } public init(id: String, name: String, sourceDescription: String, url: URL, category: NewsCategory, language: NewsLanguage, country: NewsCountry) { self.id = id self.name = name self.sourceDescription = sourceDescription self.url = url } } Function: func fetchJSON() { let urlString = "https://newsapi.org/v2/sources?apiKey=176a4fe177c4461ba3b8fbd1774dbdea" guard let url = URL(string: urlString) else { return } URLSession.shared.dataTask(with: url) { (data, _, err) in DispatchQueue.main.async { if let err = err { print("Failed to get data from url:", err) return } guard let data = data else { return } print(data) do { // link in description for video on JSONDecoder let decoder = JSONDecoder() // Swift 4.1 decoder.keyDecodingStrategy = .convertFromSnakeCase self.Sources = try decoder.decode([NewsSource].self, from: data) self.tableView.reloadData() } catch let jsonErr { print("Failed to decode:", jsonErr) } } }.resume() }
0debug
def frequency_lists(list1): list1 = [item for sublist in list1 for item in sublist] dic_data = {} for num in list1: if num in dic_data.keys(): dic_data[num] += 1 else: key = num value = 1 dic_data[key] = value return dic_data
0debug
static int ioreq_map(struct ioreq *ioreq) { XenGnttab gnt = ioreq->blkdev->xendev.gnttabdev; uint32_t domids[BLKIF_MAX_SEGMENTS_PER_REQUEST]; uint32_t refs[BLKIF_MAX_SEGMENTS_PER_REQUEST]; void *page[BLKIF_MAX_SEGMENTS_PER_REQUEST]; int i, j, new_maps = 0; PersistentGrant *grant; if (ioreq->v.niov == 0 || ioreq->mapped == 1) { return 0; } if (ioreq->blkdev->feature_persistent) { for (i = 0; i < ioreq->v.niov; i++) { grant = g_tree_lookup(ioreq->blkdev->persistent_gnts, GUINT_TO_POINTER(ioreq->refs[i])); if (grant != NULL) { page[i] = grant->page; xen_be_printf(&ioreq->blkdev->xendev, 3, "using persistent-grant %" PRIu32 "\n", ioreq->refs[i]); } else { domids[new_maps] = ioreq->domids[i]; refs[new_maps] = ioreq->refs[i]; page[i] = NULL; new_maps++; } } ioreq->prot = PROT_WRITE | PROT_READ; } else { memcpy(refs, ioreq->refs, sizeof(refs)); memcpy(domids, ioreq->domids, sizeof(domids)); memset(page, 0, sizeof(page)); new_maps = ioreq->v.niov; } if (batch_maps && new_maps) { ioreq->pages = xc_gnttab_map_grant_refs (gnt, new_maps, domids, refs, ioreq->prot); if (ioreq->pages == NULL) { xen_be_printf(&ioreq->blkdev->xendev, 0, "can't map %d grant refs (%s, %d maps)\n", new_maps, strerror(errno), ioreq->blkdev->cnt_map); return -1; } for (i = 0, j = 0; i < ioreq->v.niov; i++) { if (page[i] == NULL) { page[i] = ioreq->pages + (j++) * XC_PAGE_SIZE; } } ioreq->blkdev->cnt_map += new_maps; } else if (new_maps) { for (i = 0; i < new_maps; i++) { ioreq->page[i] = xc_gnttab_map_grant_ref (gnt, domids[i], refs[i], ioreq->prot); if (ioreq->page[i] == NULL) { xen_be_printf(&ioreq->blkdev->xendev, 0, "can't map grant ref %d (%s, %d maps)\n", refs[i], strerror(errno), ioreq->blkdev->cnt_map); ioreq->mapped = 1; ioreq_unmap(ioreq); return -1; } ioreq->blkdev->cnt_map++; } for (i = 0, j = 0; i < ioreq->v.niov; i++) { if (page[i] == NULL) { page[i] = ioreq->page[j++]; } } } if (ioreq->blkdev->feature_persistent) { while ((ioreq->blkdev->persistent_gnt_count < ioreq->blkdev->max_grants) && new_maps) { grant = g_malloc0(sizeof(*grant)); new_maps--; if (batch_maps) { grant->page = ioreq->pages + (new_maps) * XC_PAGE_SIZE; } else { grant->page = ioreq->page[new_maps]; } grant->blkdev = ioreq->blkdev; xen_be_printf(&ioreq->blkdev->xendev, 3, "adding grant %" PRIu32 " page: %p\n", refs[new_maps], grant->page); g_tree_insert(ioreq->blkdev->persistent_gnts, GUINT_TO_POINTER(refs[new_maps]), grant); ioreq->blkdev->persistent_gnt_count++; } } for (i = 0; i < ioreq->v.niov; i++) { ioreq->v.iov[i].iov_base += (uintptr_t)page[i]; } ioreq->mapped = 1; ioreq->num_unmap = new_maps; return 0; }
1threat
I don't get latitute and logitude : **"Actually I don't get latitude and longitude from this code.Help me anyone to solve my problem."** package com.example.reyadmahabub.location; import android.Manifest; import android.content.pm.PackageManager; import android.location.Location; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.Toast; import com.google.android.gms.location.FusedLocationProviderClient; import com.google.android.gms.location.LocationCallback; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationResult; import com.google.android.gms.location.LocationServices; public class MainActivity extends AppCompatActivity { private LocationCallback callback; private LocationRequest request; private FusedLocationProviderClient client; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate( savedInstanceState ); setContentView( R.layout.activity_main ); client = LocationServices.getFusedLocationProviderClient( this ); callback = new LocationCallback() { @Override public void onLocationResult(LocationResult locationResult) { super.onLocationResult( locationResult ); for (Location location:locationResult.getLocations()){ double lat=location.getLatitude(); double lon=location.getLongitude(); Toast.makeText( MainActivity.this,lat+","+lon, Toast.LENGTH_SHORT ).show(); } } }; createLocationRequest(); } private void createLocationRequest() { request = new LocationRequest().setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY ) .setInterval( 2500 ).setFastestInterval( 5000 ); if (ActivityCompat.checkSelfPermission( this, Manifest.permission.ACCESS_FINE_LOCATION ) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission( this, Manifest.permission.ACCESS_COARSE_LOCATION ) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions( this,new String[]{Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.ACCESS_COARSE_LOCATION},1 ); return; } client.requestLocati onUpdates( request, callback, null ); } }
0debug
static void vc1_mc_4mv_chroma4(VC1Context *v, int dir, int dir2, int avg) { MpegEncContext *s = &v->s; H264ChromaContext *h264chroma = &v->h264chroma; uint8_t *srcU, *srcV; int uvsrc_x, uvsrc_y; int uvmx_field[4], uvmy_field[4]; int i, off, tx, ty; int fieldmv = v->blk_mv_type[s->block_index[0]]; static const int s_rndtblfield[16] = { 0, 0, 1, 2, 4, 4, 5, 6, 2, 2, 3, 8, 6, 6, 7, 12 }; int v_dist = fieldmv ? 1 : 4; int v_edge_pos = s->v_edge_pos >> 1; int use_ic; uint8_t (*lutuv)[256]; if (s->flags & CODEC_FLAG_GRAY) return; for (i = 0; i < 4; i++) { int d = i < 2 ? dir: dir2; tx = s->mv[d][i][0]; uvmx_field[i] = (tx + ((tx & 3) == 3)) >> 1; ty = s->mv[d][i][1]; if (fieldmv) uvmy_field[i] = (ty >> 4) * 8 + s_rndtblfield[ty & 0xF]; else uvmy_field[i] = (ty + ((ty & 3) == 3)) >> 1; } for (i = 0; i < 4; i++) { off = (i & 1) * 4 + ((i & 2) ? v_dist * s->uvlinesize : 0); uvsrc_x = s->mb_x * 8 + (i & 1) * 4 + (uvmx_field[i] >> 2); uvsrc_y = s->mb_y * 8 + ((i & 2) ? v_dist : 0) + (uvmy_field[i] >> 2); uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1); uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1); if (i < 2 ? dir : dir2) { srcU = s->next_picture.f.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x; srcV = s->next_picture.f.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x; lutuv = v->next_lutuv; use_ic = v->next_use_ic; } else { srcU = s->last_picture.f.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x; srcV = s->last_picture.f.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x; lutuv = v->last_lutuv; use_ic = v->last_use_ic; } uvmx_field[i] = (uvmx_field[i] & 3) << 1; uvmy_field[i] = (uvmy_field[i] & 3) << 1; if (fieldmv && !(uvsrc_y & 1)) v_edge_pos--; if (fieldmv && (uvsrc_y & 1) && uvsrc_y < 2) uvsrc_y--; if (use_ic || s->h_edge_pos < 10 || v_edge_pos < (5 << fieldmv) || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 5 || (unsigned)uvsrc_y > v_edge_pos - (5 << fieldmv)) { s->vdsp.emulated_edge_mc(s->edge_emu_buffer, srcU, s->uvlinesize, s->uvlinesize, 5, (5 << fieldmv), uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos); s->vdsp.emulated_edge_mc(s->edge_emu_buffer + 16, srcV, s->uvlinesize, s->uvlinesize, 5, (5 << fieldmv), uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos); srcU = s->edge_emu_buffer; srcV = s->edge_emu_buffer + 16; if (use_ic) { int i, j; uint8_t *src, *src2; src = srcU; src2 = srcV; for (j = 0; j < 5; j++) { int f = (uvsrc_y + (j << fieldmv)) & 1; for (i = 0; i < 5; i++) { src[i] = lutuv[f][src[i]]; src2[i] = lutuv[f][src2[i]]; } src += s->uvlinesize << fieldmv; src2 += s->uvlinesize << fieldmv; } } } if (avg) { if (!v->rnd) { h264chroma->avg_h264_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]); h264chroma->avg_h264_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]); } else { v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]); v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]); } } else { if (!v->rnd) { h264chroma->put_h264_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]); h264chroma->put_h264_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]); } else { v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]); v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]); } } } }
1threat
int pci_parse_devaddr(const char *addr, int *domp, int *busp, unsigned int *slotp, unsigned int *funcp) { const char *p; char *e; unsigned long val; unsigned long dom = 0, bus = 0; unsigned int slot = 0; unsigned int func = 0; p = addr; val = strtoul(p, &e, 16); if (e == p) return -1; if (*e == ':') { bus = val; p = e + 1; val = strtoul(p, &e, 16); if (e == p) return -1; if (*e == ':') { dom = bus; bus = val; p = e + 1; val = strtoul(p, &e, 16); if (e == p) return -1; } } slot = val; if (funcp != NULL) { if (*e != '.') return -1; p = e + 1; val = strtoul(p, &e, 16); if (e == p) return -1; func = val; } if (dom > 0xffff || bus > 0xff || slot > 0x1f || func > 7) return -1; if (*e) return -1; if (!pci_find_bus(pci_find_root_bus(dom), bus)) return -1; *domp = dom; *busp = bus; *slotp = slot; if (funcp != NULL) *funcp = func; return 0; }
1threat
How to echo html in php with link to database? : <p>below is what i had tried:</p> <pre><code>echo "&lt;input class='form-control' type='text' name='jobID' value='.$result['jobID'].' readonly&gt;"; </code></pre> <p>or </p> <pre><code>echo "&lt;input class='form-control' type='text' name='jobID' value=&lt;?php $result['jobID'];?&gt;readonly&gt;"; </code></pre> <p>thank you so much </p>
0debug
static gboolean gd_enter_event(GtkWidget *widget, GdkEventCrossing *crossing, gpointer opaque) { VirtualConsole *vc = opaque; GtkDisplayState *s = vc->s; if (!gd_is_grab_active(s) && gd_grab_on_hover(s)) { gd_grab_keyboard(vc); } return TRUE; }
1threat
How do I determine why ghc is looking for a particular type class instance? : <p>When conditional type class instances run deep, it can be difficult to figure out why ghc is complaining about a missing type class instance. For instance:</p> <pre><code>class MyClass1 c class MyClass2 c class MyClass3 c data MyType1 a data MyType2 a instance MyClass1 a =&gt; MyClass2 (MyType1 a) instance MyClass2 a =&gt; MyClass3 (MyType2 a) foo :: (MyClass3 c) =&gt; c foo = undefined bar :: MyType2 (MyType1 Int) bar = foo </code></pre> <p>GHC gives the following error:</p> <pre><code>Example.hs:149:7-9: error: • No instance for (MyClass1 Int) arising from a use of ‘foo’ • In the expression: foo In an equation for ‘bar’: bar = foo | 149 | bar = foo | ^^^ </code></pre> <p>Supposing I only wrote the definitions for <code>foo</code> and <code>bar</code>, and everything else was imported code which I did not write, I may be very confused as to why ghc is attempting to find a <code>MyClass1</code> instance for <code>Int</code>. This might even be the first time I've ever heard of the <code>MyClass1</code> class, if so far I've been relying on imported instances. It would be nice if ghc could give me a "stack trace" of the type class instance chain, e.g.</p> <pre><code>Sought (MyClass2 (MyType1 Int)) to satisfy (MyClass3 (MyType2 (MyType1 Int))) from conditional type class instance OtherModule.hs:37:1-18 Sought (MyClass1 Int) to satisfy (MyClass2 (MyType1 Int)) from conditional type class instance OtherModule.hs:36:1-18 </code></pre> <p>Does ghc have a command line option for this? If not, how do I debug this?</p> <p>Keep in mind that my real problem is much more complicated than this simple example. e.g.</p> <pre><code>Search.hs:110:31-36: error: • Could not deduce (Ord (Vars (DedupingMap (Rep (Index gc)) (IndexedProblem ac)))) arising from a use of ‘search’ from the context: (PP gc (IndexedProblem ac), Show (Vars (DedupingMap (Rep (Index gc)) (IndexedProblem ac))), Foldable f, MonadNotify m) bound by the type signature for: searchIndexedReplicaProblem :: forall gc ac (f :: * -&gt; *) (m :: * -&gt; *). (PP gc (IndexedProblem ac), Show (Vars (DedupingMap (Rep (Index gc)) (IndexedProblem ac))), Foldable f, MonadNotify m) =&gt; f (Index (Clzs (PartitionedProblem gc (IndexedProblem ac)))) -&gt; m (Maybe (Vars (PartitionedProblem gc (IndexedProblem ac)))) at Search.hs:(103,1)-(109,131) • In the expression: search In an equation for ‘searchIndexedReplicaProblem’: searchIndexedReplicaProblem = search | 110 | searchIndexedReplicaProblem = search | ^^^^^^ </code></pre> <p>There are five coverage conditions for PP, and I'm using type families and undecidable instances, so it's extremely not obvious why ghc is giving me its error. What tools can I use to track down the problem?</p>
0debug
int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal) { int count, i; if (avctx->bits_per_coded_sample > 8) { av_log(avctx, AV_LOG_ERROR, "bit_per_coded_sample > 8 not supported\n"); return AVERROR_INVALIDDATA; } count = 1 << avctx->bits_per_coded_sample; if (avctx->extradata_size < count * 3) { av_log(avctx, AV_LOG_ERROR, "palette data underflow\n"); return AVERROR_INVALIDDATA; } for (i=0; i < count; i++) { pal[i] = 0xFF000000 | AV_RB24( avctx->extradata + i*3 ); } return 0; }
1threat
delphi schematic for high i/o usage : i have a program that uses 5 com port for get data from hardware and save them in MySQL database and also transfer them to a third place with tcp/ip for com ports i use Async so the have separated threads.so thay cant make the system ui lagy.but if i use MySQL connection in com threads it waste the time to read from buffer and make buffer over load error on the other hand if i send data process and MySQL store to an Anonymous thread it cause a many working threads in queue what is best way to handle this kind of apps?
0debug
Get the highest value of property in Class : <p>I'm trying to get the highest number of all propreties in my class: </p> <pre><code>public class aClass{ public int PropA{ get; set; } = 1; public int PropB{ get; set; } = 18; public int PropC{ get; set; } = 25; } </code></pre> <p>Here's my code: </p> <pre><code>public int GetMaxConfiguratableColumns() { int _HighestNumber = 0; PropertyInfo[] _Info = this.GetType().GetProperties(); foreach(PropertyInfo _PropretyInfo in _Info) { //I'm lost here!!!!!!! } return _HighestNumber; } </code></pre> <p>Any suggestions? Thanks!</p>
0debug
how to proxy to backend server on certain path? : <p>Here is the routes config:</p> <pre><code>&lt;Route path='/' component={CoreLayout}&gt; &lt;IndexRoute component={HomeView}/&gt; &lt;Route path='/404' component={NotFoundView}/&gt; &lt;Redirect from='*' to='/404'/&gt; &lt;/Route&gt; </code></pre> <p>Here is the proxy config for webpack-dev-server:</p> <pre><code>proxy: { '/service': 'http://localhost:8080' } </code></pre> <p>The express server listens on 3000 port.</p> <p>I hope that all the requests send to <a href="http://localhost:3000/service" rel="noreferrer">http://localhost:3000/service</a> would be transferred to <a href="http://localhost:8080" rel="noreferrer">http://localhost:8080</a>, but it seems that react-router handles all the requests and the proxy does not work.</p> <p>Any body knows how to fix this? Thank you in advance</p>
0debug
json data alerting undefined : i have this json via ajax >[{"tid":"1","itemID":"Camry","item_type":"Carf","vendor_id":"ogbueli"},{"tid":"2","itemID":"Samsung","item_type":"Electronics","vendor_id":"Chizoba"},{"tid":"3","itemID":"Panasonic","item_type":"Electronics","vendor_id":"Mourinho"}] i have already parsed it arr = JSON.parse(response); now i want to access it like this for (var i in arr){ newitems=arr[0]; alert(newitems); } the alert is returning 'undefined'. i want to get something like this newitems={'1','camry','carf','ogbueli'}; hope someone can help me out...thanks
0debug
Method App\Http\Requests\EndTripRequest::rules() : Hello I'm new on Laravel and while i'm working with a code i found an error when i try to call an API from the application on android I'm really lost with it i don't even know what is the problem I don't know where to start ReflectionException: Method App\Http\Requests\EndTripRequest::rules() does not exist in file /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php on line 142 Stack trace: 1. ReflectionException-&gt;() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:142 2. ReflectionMethod-&gt;__construct() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:142 3. Illuminate\Container\BoundMethod-&gt;getCallReflector() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:120 4. Illuminate\Container\BoundMethod-&gt;getMethodDependencies() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32 5. Illuminate\Container\BoundMethod-&gt;Illuminate\Container\{closure}() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:90 6. Illuminate\Container\BoundMethod-&gt;callBoundMethod() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:34 7. Illuminate\Container\BoundMethod-&gt;call() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Container/Container.php:576 8. Illuminate\Container\Container-&gt;call() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Foundation/Http/FormRequest.php:105 9. Illuminate\Foundation\Http\FormRequest-&gt;createDefaultValidator() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Foundation/Http/FormRequest.php:84 10. Illuminate\Foundation\Http\FormRequest-&gt;getValidatorInstance() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Validation/ValidatesWhenResolvedTrait.php:23 11. Illuminate\Foundation\Http\FormRequest-&gt;validateResolved() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Foundation/Providers/FormRequestServiceProvider.php:30 12. Illuminate\Foundation\Providers\FormRequestServiceProvider-&gt;Illuminate\Foundation\Providers\{closure}() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Container/Container.php:1082 13. Illuminate\Container\Container-&gt;fireCallbackArray() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Container/Container.php:1046 14. Illuminate\Container\Container-&gt;fireAfterResolvingCallbacks() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Container/Container.php:1031 15. Illuminate\Container\Container-&gt;fireResolvingCallbacks() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Container/Container.php:687 16. Illuminate\Container\Container-&gt;resolve() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Container/Container.php:615 17. Illuminate\Container\Container-&gt;make() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:757 18. Illuminate\Foundation\Application-&gt;make() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Routing/RouteDependencyResolverTrait.php:79 19. Illuminate\Routing\ControllerDispatcher-&gt;transformDependency() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Routing/RouteDependencyResolverTrait.php:46 20. Illuminate\Routing\ControllerDispatcher-&gt;resolveMethodDependencies() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Routing/RouteDependencyResolverTrait.php:27 21. Illuminate\Routing\ControllerDispatcher-&gt;resolveClassMethodDependencies() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:41 22. Illuminate\Routing\ControllerDispatcher-&gt;dispatch() /home/********/domains/hilove.tech/vendor/laravel/framework/src/Illuminate/Routing/Route.php:2 responseFromServerError D/errror: null D/error: [Ljava.lang.StackTraceElement;@33928b1 null
0debug
how to get multiple <Td> text using jquery? : how can i get text for each Td (first one) that created by this loop using jQuery? @foreach (string item in Model) { <tr> <td id="td_name" style="border-left: thin">@item</td> <td ><input type="text" id="txtGrade_@item" onclick="" style="width: 40px;border-left: thin"/></td> <td><input type="checkbox" id="chkStudent_@item" value="@item" /></td> </tr> }
0debug
can u tell me a little change in my own written pascal logic : i have just take the format and spacing but can any one tell me a single change to get the values which print in actual pascal triangle program in java... /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package patterns; /** * * @author Love Poet */ public class p11 { public static void main(String args[]) { int row, col, count = 0; for (row = 1; row <= 5; row++) { for (col = 1; col <= 9; col++) { if (((row + col) % 2 == 0) && (row + col >= 6)) { System.out.print("* "); count++; } else if (count == row) { break; } else { System.out.print(" "); } } count = 0; System.out.println(); } } } **Output:**- * * * * * * * * * * * * * * *
0debug
How do I turn the fucntion sumVec into a template function : <p>I got this code (I know it's in Spanish I can translate if needed) where they give me the function SumVec. What the function does is it receives as parameters two arrays (integer pointers) and an integer (size) and returns a pointer to the sum of the two vectors or arrays. I have to convert it so it can receive any type, not just integer. I know that you do that with a template by using "template " but I've only done simple classes I don't know how to do it with pointers. Any help?</p> <p>The code</p> <pre><code>#include &lt;iostream&gt; #include &lt;cstdlib&gt; using namespace std; int * sumVec(int*, int*, int); int main() { int n, nCol, nFil = 0; //Arreglo unidimensional din�mico int *ptr, *suma, size; cout &lt;&lt; "Cuantos Items va a procesar:"; cin &gt;&gt; size; ptr = new int[size];//Asignando memoria al arreglo //input for (int i = 0;i&lt;size;i++) { cout &lt;&lt; "Ingrese el numero de Items NO." &lt;&lt; i + 1 &lt;&lt; " :"; cin &gt;&gt; ptr[i]; } //Mostrando el contenido del archivo for (int i = 0;i&lt;size;i++) cout &lt;&lt; "\nItem. NO." &lt;&lt; i + 1 &lt;&lt; " :" &lt;&lt; ptr[i]; cout &lt;&lt; endl; suma = sumVec(ptr, ptr, size); //Mostrando el contenido de la suma for (int i = 0;i&lt;size;i++) cout &lt;&lt; "\nSuma Item. NO." &lt;&lt; i + 1 &lt;&lt; " :" &lt;&lt; suma[i]; cout &lt;&lt; endl; delete[]ptr;//Liberando la memoria asignada al arreglo unidimensional. return 0; } int * sumVec(int* Array1, int* Array2, int Size){ int *ptr = new int[Size]; for(int i=0; i&lt;Size; i++) ptr[i]= Array1[i] + Array2[i]; return ptr; } </code></pre>
0debug
I have a c source, I want to change my code to java. : guys. Thank for your Questions. This is my c code int test(unsigned char* input, unsigned char* output, int in_len) { int i, out_len = 0; for(i = 0; i < in_len; i++) { if (*(input+i) == 0x23) { i++; *output++ = *(input+i) ^ 0x40; } else { *output++ = *(input+i); } out_len++; } return(out_len); } I want to change my code to java. I have base64 values before calling test method. after decoding, I am calling test method by char* but java has no char* How Can I use this code by java? Help me.... Thanks.. public static byte[] test(byte[] input, byte[] output, int in_len) { in t i, out_len = 0; for(i = 0; i < in_len; i++) { if ((input[i]) == 0x23) i++; output[i] = (byte) (input[i] ^ 0x40); } else { output[i] = input[i]; } out_len++; } return(output); }
0debug
void ppc_tlb_invalidate_one(CPUPPCState *env, target_ulong addr) { #if !defined(FLUSH_ALL_TLBS) PowerPCCPU *cpu = ppc_env_get_cpu(env); CPUState *cs; addr &= TARGET_PAGE_MASK; switch (env->mmu_model) { case POWERPC_MMU_SOFT_6xx: case POWERPC_MMU_SOFT_74xx: ppc6xx_tlb_invalidate_virt(env, addr, 0); if (env->id_tlbs == 1) { ppc6xx_tlb_invalidate_virt(env, addr, 1); } break; case POWERPC_MMU_32B: case POWERPC_MMU_601: addr &= ~((target_ulong)-1ULL << 28); cs = CPU(cpu); #if 0 tlb_flush_page(cs, addr | (0x0 << 28)); tlb_flush_page(cs, addr | (0x1 << 28)); tlb_flush_page(cs, addr | (0x2 << 28)); tlb_flush_page(cs, addr | (0x3 << 28)); tlb_flush_page(cs, addr | (0x4 << 28)); tlb_flush_page(cs, addr | (0x5 << 28)); tlb_flush_page(cs, addr | (0x6 << 28)); tlb_flush_page(cs, addr | (0x7 << 28)); tlb_flush_page(cs, addr | (0x8 << 28)); tlb_flush_page(cs, addr | (0x9 << 28)); tlb_flush_page(cs, addr | (0xA << 28)); tlb_flush_page(cs, addr | (0xB << 28)); tlb_flush_page(cs, addr | (0xC << 28)); tlb_flush_page(cs, addr | (0xD << 28)); tlb_flush_page(cs, addr | (0xE << 28)); tlb_flush_page(cs, addr | (0xF << 28)); break; #if defined(TARGET_PPC64) case POWERPC_MMU_64B: case POWERPC_MMU_2_03: case POWERPC_MMU_2_06: case POWERPC_MMU_2_06a: case POWERPC_MMU_2_07: case POWERPC_MMU_2_07a: env->tlb_need_flush = 1; break; #endif default: assert(0); } ppc_tlb_invalidate_all(env); }
1threat
static int pcm_dvd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { AVFrame *frame = data; const uint8_t *src = avpkt->data; int buf_size = avpkt->size; PCMDVDContext *s = avctx->priv_data; int retval; int blocks; void *dst; if (buf_size < 3) { av_log(avctx, AV_LOG_ERROR, "PCM packet too small\n"); return AVERROR_INVALIDDATA; if ((retval = pcm_dvd_parse_header(avctx, src))) return retval; src += 3; buf_size -= 3; blocks = (buf_size + s->extra_sample_count) / s->block_size; frame->nb_samples = blocks * s->samples_per_block; if ((retval = ff_get_buffer(avctx, frame, 0)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return retval; dst = frame->data[0]; if (s->extra_sample_count) { int missing_samples = s->block_size - s->extra_sample_count; if (buf_size >= missing_samples) { memcpy(s->extra_samples + s->extra_sample_count, src, missing_samples); dst = pcm_dvd_decode_samples(avctx, s->extra_samples, dst, 1); src += missing_samples; buf_size -= missing_samples; blocks--; } else { memcpy(s->extra_samples + s->extra_sample_count, src, buf_size); s->extra_sample_count += buf_size; return avpkt->size; if (blocks) { pcm_dvd_decode_samples(avctx, src, dst, blocks); buf_size -= blocks * s->block_size; if (buf_size) { src += blocks * s->block_size; memcpy(s->extra_samples, src, buf_size); s->extra_sample_count = buf_size; *got_frame_ptr = 1; return avpkt->size;
1threat
How to get a standalone / unmanaged RealmObject using Realm Xamarin : <p>Is there a way that when I read an object from Realm that it can become a standalone or unmanaged object? In EF, this is called no tracking. The usage for this would be when I want to implement more business logic on my data objects before they are updated on the persistent data storage. I may want to give the RealmObject to a ViewModel, but when the changes come back from the ViewModel, I want to compare the disconnected object to the object in the datastore to determine what was changed, so If there was a way that I could disconnect the object from Realm when I give it to the ViewModel, then I can better manage what properties have changed, using my biz logic to do what I need, then save the changes back to realm. </p> <p>I understand Realm does a lot of magic and many people will not want to add a layer like this but in my app, I cant really have the UI directly updating the datastore, unless there is a event that is raised that I can subscribe too and then attach my business logic this way.</p> <p>I only saw one event and it does not appear to perform this action.</p> <p>Thanks for your assistance.</p>
0debug
static int target_pread(int fd, abi_ulong ptr, abi_ulong len, abi_ulong offset) { void *buf; int ret; buf = lock_user(VERIFY_WRITE, ptr, len, 0); ret = pread(fd, buf, len, offset); unlock_user(buf, ptr, len); return ret;
1threat
Whats wrong? I have to output for eg. if input is Hello World the output should be World Hello : void word_swap(char *arr){ int tmp1[10], tmp2[10], j = 0, k = 0, a, b, z,i; // must use pointers for (i=0; i<MAX; i++) { if(arr[i] == ' ') //if there's a space, store the characters before the space to another array and after the space to another { for(j = 0; j<i; j++) // tmp1 tmp1[j] = arr[j]; for( j = 0; j<MAX-i; j++) //MAX - i would be range of j for(k = i+1; k<MAX; k++) //tmp2 tmp2[j] = arr[k]; } } i = 0; while(1) { while(tmp2[i] != '\0' && i<sizeof(tmp2)) // finding the size of tmp2 a++; } for(j=0; j<a; j++) // overwriting the original array arr[j] = tmp2[j]; j++; // incrementing j so that there would be a space between the new array z = j; i=0; while(1) //finding the size of tmp1 { while(tmp1[i] != '\0' && i<sizeof(tmp1)) b++; } //idk pls help for( z=0 ; z<MAX; z++) //overwriting the original array for(k = 0; k<b; k++) arr[z] = tmp1[k]; //idk pls help for (i = 0; i < MAX; i++) // outputting the required result printf("%c", *(arr+i)); printf("\n");}//eg if input is Hello World the output should be World Hello//idk pls help so basically I have Hello World output should be World Hello another example is Cats Kitten out is Kitten Cats must use pointers. the main function passes the function as word_swap(word1) where word1 is char word1[] = {'h','e', etc)
0debug
static void spapr_pci_unplug_request(HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { sPAPRPHBState *phb = SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler)); PCIDevice *pdev = PCI_DEVICE(plugged_dev); sPAPRDRConnectorClass *drck; sPAPRDRConnector *drc = spapr_phb_get_pci_drc(phb, pdev); if (!phb->dr_enabled) { error_setg(errp, QERR_BUS_NO_HOTPLUG, object_get_typename(OBJECT(phb))); return; } g_assert(drc); g_assert(drc->dev == plugged_dev); drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); if (!drck->release_pending(drc)) { PCIBus *bus = PCI_BUS(qdev_get_parent_bus(DEVICE(pdev))); uint32_t slotnr = PCI_SLOT(pdev->devfn); sPAPRDRConnector *func_drc; sPAPRDRConnectorClass *func_drck; sPAPRDREntitySense state; int i; if (PCI_FUNC(pdev->devfn) == 0) { for (i = 1; i < 8; i++) { func_drc = spapr_phb_get_pci_func_drc(phb, pci_bus_num(bus), PCI_DEVFN(slotnr, i)); func_drck = SPAPR_DR_CONNECTOR_GET_CLASS(func_drc); state = func_drck->dr_entity_sense(func_drc); if (state == SPAPR_DR_ENTITY_SENSE_PRESENT && !func_drck->release_pending(func_drc)) { error_setg(errp, "PCI: slot %d, function %d still present. " "Must unplug all non-0 functions first.", slotnr, i); return; } } } spapr_drc_detach(drc); if (PCI_FUNC(pdev->devfn) == 0) { for (i = 7; i >= 0; i--) { func_drc = spapr_phb_get_pci_func_drc(phb, pci_bus_num(bus), PCI_DEVFN(slotnr, i)); func_drck = SPAPR_DR_CONNECTOR_GET_CLASS(func_drc); state = func_drck->dr_entity_sense(func_drc); if (state == SPAPR_DR_ENTITY_SENSE_PRESENT) { spapr_hotplug_req_remove_by_index(func_drc); } } } } }
1threat
Can i make this code a bit smaller : I have created this code to see how many textboxs have something inputed in it and then to display the total in a message box, i want to know if i can make my below code any smaller by may putting it in a loop? Thanks Dim TotalRooms = 0 If String.IsNullOrEmpty(txtRoom1.Text) Then TotalRooms = TotalRooms + 0 Else TotalRooms = TotalRooms + 1 End If If String.IsNullOrEmpty(txtRoom2.Text) Then TotalRooms = TotalRooms + 0 Else TotalRooms = TotalRooms + 1 End If If String.IsNullOrEmpty(txtRoom3.Text) Then TotalRooms = TotalRooms + 0 Else TotalRooms = TotalRooms + 1 End If If String.IsNullOrEmpty(txtRoom4.Text) Then TotalRooms = TotalRooms + 0 Else TotalRooms = TotalRooms + 1 End If If String.IsNullOrEmpty(txtRoom5.Text) Then TotalRooms = TotalRooms + 0 Else TotalRooms = TotalRooms + 1 End If If String.IsNullOrEmpty(txtRoom6.Text) Then TotalRooms = TotalRooms + 0 Else TotalRooms = TotalRooms + 1 End If If String.IsNullOrEmpty(txtRoom7.Text) Then TotalRooms = TotalRooms + 0 Else TotalRooms = TotalRooms + 1 End If If String.IsNullOrEmpty(txtRoom8.Text) Then TotalRooms = TotalRooms + 0 Else TotalRooms = TotalRooms + 1 End If If String.IsNullOrEmpty(txtRoom9.Text) Then TotalRooms = TotalRooms + 0 Else TotalRooms = TotalRooms + 1 End If If String.IsNullOrEmpty(txtRoom10.Text) Then TotalRooms = TotalRooms + 0 Else TotalRooms = TotalRooms + 1 End If MessageBox.Show(TotalRooms)
0debug
Refer to type in different file in JSDoc without importing : <p>I'm writing JavaScript (ES6) code in Visual Studio Code and enabled VSCode's type checking as explained in the <a href="https://code.visualstudio.com/docs/languages/javascript#_type-checking-and-quick-fixes-for-javascript-files" rel="noreferrer">VSCode docs</a>.</p> <p>When referring to a type that is defined in another file (<code>Track</code> in the example below), I get an error like <em>[js] Cannot find name 'Track'</em> at the JSDoc reference to that type unless I import it. When I import this type, I get an error from ESLint: <em>[eslint] 'Track' is defined but never used. (no-unused-vars)</em></p> <p>I don't want to disable the ESLint rule. Is there a way to import the type <em>only</em> for the type checks in VSCode?</p> <pre><code>import Track from './Track'; export default class TrackList { /** * Creates a new track list. * @param {Iterable&lt;Track&gt;} tracks the tracks to include */ constructor(tracks) { this._tracks = tracks ? Array.from(tracks) : []; } ... </code></pre>
0debug
def add_pairwise(test_tup): res = tuple(i + j for i, j in zip(test_tup, test_tup[1:])) return (res)
0debug
Oracle-Making Optional Constraint in Select : How to make a constraint optional? That is, if a codition of the consraint is FALSE, how to ignore the constraint in a simplest way? The expected result of my code is, RR -- 100 200 My Code is, WITH DATASET AS ( SELECT 1 A, 10 B, 100 RR FROM DUAL UNION SELECT NULL A, 10 B, 200 RR FROM DUAL ) SELECT RR FROM DATASET WHERE A=2 -- How to make this constraint optional(that is, if this is FALSE,ignoring this constraint?) AND B=10 ;
0debug
void qemu_thread_self(QemuThread *thread) { thread->thread = pthread_self(); }
1threat
Is it possible to import fonts from the directory with scss? : <p>I have a scss file with font import implemented this way:</p> <pre><code>@import url(https://fonts.googleapis.com/css?family=PT+Sans+Caption:400,700&amp;subset=latin-ext,cyrillic); </code></pre> <p>I understand that using CDN gives advantages in caching for user but this is internal site and it could be used on server without access to the <code>wide web</code>. And I'm not sure that user machine will have access to the Internet too. So I want to serve fronts with other pages static files. </p> <p>Is there a way in SCSS to import fonts from the some directory on server? Something like:</p> <pre><code>@import dir(/path/to/fonts/file) </code></pre> <p>Or SCSS has not this feature?</p>
0debug
PHP MYSQLI not updating : So I have been trying to make a form where I can update two fields one field is going be admin_welcomebox and admin_author and I'm trying update it by the id so here go my code <div class="col-lg-6"> <div class="panel panel-color panel-inverse"> <div class="panel-heading"> <h3 class="panel-title">Welcome Box Update</h3> </div> <?php if(isset($_POST["submit"])){ $servername = "localhost"; $username = "trres"; $password = "sss"; $dbname = "txxxs"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "UPDATE admin_news SET welcomebox = '{$admin_news}' SET author = {$admin_author} id='{$id}'"; if ($conn->query($sql) === TRUE) { echo "<h4 class='bg-success'>You have updated admin welcome box.</h4>"; } else { echo "<script type= 'text/javascript'>alert('Error: " . $sql . "<br>" . $conn->error."');</script>"; } $conn->close(); } ?> <div class="panel-body"> <form method="post" action=""> <div class="form-group"> <label for="welcomebox">Welcome Box</label> <textarea type="text" name="welcomebox" id="welcomebox" placeholder="Enter Your Message" class="form-control"></textarea> </div> <div class="form-group"> <label for="author">Author Name</label> <input type="text" name="author" id="author" placeholder="Author Name" class="form-control" / > </div> <div class="form-group text-right m-b-0"> <button class="btn btn-primary waves-effect waves-light" type="submit" name="submit" id="submit"> Update Info </button> </div> </form> </div> </div> </div> When i try update it just refresh the page nothing else.
0debug
Problems with Java Arrays.sort() on sub-arrays -- is this a bug? : <p>I have noticed odd behavior when using Java Arrays.sort() on sub-arrays. Here is a demo program. Is this a bug in Java?</p> <pre><code>package sorted_subsegments; import java.util.Arrays; public class sortTest { public static void main(String[] args) { int A[] = {3, 2, 1}; System.out.format("A: %s\n", Arrays.toString(A)); Arrays.sort(A, 0, 1); System.out.format(" after sub array sort on A: %s\n", Arrays.toString(A)); System.out.println("Should be A: [2, 3, 1]"); Arrays.sort(A); System.out.format(" whole array sort on A: %s\n", Arrays.toString(A)); } } </code></pre>
0debug
How to read every 100 lines from a large file : <p>How do I read every 100 lines in a larger file of around 100000 lines. I want to read every 100 lines in one iteration and make them coma seperated, run some code and next iteration, it should pick from 101 to 200.</p> <p>I have searched internet, everywhere there is a solution for picking nth line and not n lines.</p>
0debug
static int vtd_dev_to_context_entry(IntelIOMMUState *s, uint8_t bus_num, uint8_t devfn, VTDContextEntry *ce) { VTDRootEntry re; int ret_fr; X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s); ret_fr = vtd_get_root_entry(s, bus_num, &re); if (ret_fr) { return ret_fr; } if (!vtd_root_entry_present(&re)) { trace_vtd_re_not_present(bus_num); return -VTD_FR_ROOT_ENTRY_P; } if (re.rsvd || (re.val & VTD_ROOT_ENTRY_RSVD(VTD_HOST_ADDRESS_WIDTH))) { trace_vtd_re_invalid(re.rsvd, re.val); return -VTD_FR_ROOT_ENTRY_RSVD; } ret_fr = vtd_get_context_entry_from_root(&re, devfn, ce); if (ret_fr) { return ret_fr; } if (!vtd_ce_present(ce)) { trace_vtd_ce_not_present(bus_num, devfn); return -VTD_FR_CONTEXT_ENTRY_P; } if ((ce->hi & VTD_CONTEXT_ENTRY_RSVD_HI) || (ce->lo & VTD_CONTEXT_ENTRY_RSVD_LO(VTD_HOST_ADDRESS_WIDTH))) { trace_vtd_ce_invalid(ce->hi, ce->lo); return -VTD_FR_CONTEXT_ENTRY_RSVD; } if (!vtd_is_level_supported(s, vtd_ce_get_level(ce))) { trace_vtd_ce_invalid(ce->hi, ce->lo); return -VTD_FR_CONTEXT_ENTRY_INV; } if (!vtd_ce_type_check(x86_iommu, ce)) { trace_vtd_ce_invalid(ce->hi, ce->lo); return -VTD_FR_CONTEXT_ENTRY_INV; } return 0; }
1threat
Save multiple Edittext : Hello I'm trying to build an app where someone can fill in there personal data like there name, telephonenumber, Email. I am there that they can do that. I used an .xml file with the EditText. Now I'm tying to save the edittext so they dont have to fill it in every time they use the app. I found some codes here but most off then are just for one Edittext. Like this one... I can not get this working for multiple Edittext http://stackoverflow.com/questions/18658308/save-entered-text-in-edittext-via-button This is my xml file <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Vul dit compleet in" android:textAppearance="?android:attr/textAppearanceMedium" android:paddingLeft="10dp" android:paddingRight="10dp" android:textColor="#000066" android:textStyle="bold"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Naam: " android:textAppearance="?android:attr/textAppearanceMedium" android:paddingLeft="10dp" android:paddingRight="10dp" android:textColor="#000066" android:textStyle="bold"/> <EditText android:id="@+id/edit_Naam" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingLeft="10dp" android:paddingRight="10dp" android:textColor="#000066" android:hint="Vul uw naam in"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Functie: " android:textAppearance="?android:attr/textAppearanceMedium" android:paddingLeft="10dp" android:paddingRight="10dp" android:textColor="#000066" android:textStyle="bold"/> <EditText android:id="@+id/edit_Functie" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingLeft="10dp" android:paddingRight="10dp" android:textColor="#000066" android:hint="Vul uw functie in"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Personeelsnummer " android:textAppearance="?android:attr/textAppearanceMedium" android:paddingLeft="10dp" android:paddingRight="10dp" android:textColor="#000066" android:textStyle="bold"/> <EditText android:id="@+id/edit_Plnr" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingLeft="10dp" android:paddingRight="10dp" android:textColor="#000066" android:hint="Vul uw plnr in"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Email: " android:textAppearance="?android:attr/textAppearanceMedium" android:paddingLeft="10dp" android:paddingRight="10dp" android:textColor="#000066" android:textStyle="bold"/> <EditText android:id="@+id/edit_Email" android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="textEmailAddress" android:paddingLeft="10dp" android:paddingRight="10dp" android:textColor="#000066" android:hint="NS mail"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Telefoon: " android:textAppearance="?android:attr/textAppearanceMedium" android:paddingLeft="10dp" android:paddingRight="10dp" android:textColor="#000066" android:textStyle="bold"/> <EditText android:id="@+id/edit_Telefoon" android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="number" android:paddingLeft="10dp" android:paddingRight="10dp" android:textColor="#000066" android:hint="zonder +31"/> <Button android:id="@+id/button_Opslaan" android:layout_width="match_parent" android:layout_height="50dp" android:layout_below="@+id/edit_Bericht" android:layout_centerHorizontal="true" android:layout_marginBottom="48dp" android:layout_weight="0.03" android:background="#009CDE" android:drawableLeft="@drawable/ic_launcher" android:text="Opslaan" android:textColor="#FFFFFF"/> </LinearLayout> </ScrollView>
0debug
Javascript: insert array in another array at a specific index : <p>I have two arrays:</p> <pre><code>a = [1,2,3] b = [4,5,6] </code></pre> <p>I'd like to insert b at index 1 of a, to have :</p> <pre><code>c = [1,4,5,6,2,3] </code></pre> <p>Is there a builtin function to do this ? I found the answer for a single element, but not for a whole array. I imagine something like <code>concat</code> but with an additional parameter which would be the index of insertion. </p>
0debug
Optomise the performance of : I would like to build the following table every day, to store some aggregate data on page performance of a website. However, each days worth of data is over 15 million rows. What steps can I take to improve performance? I am intending to save them as sharded tables, but I would like to improve further, could I nest the data within each table to improve performance further? What would be the best way to do this? SELECT device.devicecategory AS device, hits_product.productListName AS list_name, UPPER(hits_product.productSKU) AS SKU, AVG(hits_product.productListPosition) AS avg_plp_position FROM `mindful-agency-136314.43786551.ga_sessions_20*` AS t CROSS JOIN UNNEST(hits) AS hits CROSS JOIN UNNEST(hits.product) AS hits_product WHERE parse_date('%y%m%d', _table_suffix) between DATE_sub(current_date(), interval 1 day) and DATE_sub(current_date(), interval 1 day) AND hits_product.productListName != "(not set)" GROUP BY device, list_name, SKU
0debug
static int vc9_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { VC9Context *v = avctx->priv_data; MpegEncContext *s = &v->s; int ret = FRAME_SKIPED, len, start_code; AVFrame *pict = data; uint8_t *tmp_buf; v->s.avctx = avctx; if (!buf_size) return 0; len = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); tmp_buf = (uint8_t *)av_mallocz(len); avpicture_fill((AVPicture *)pict, tmp_buf, avctx->pix_fmt, avctx->width, avctx->height); if (avctx->codec_id == CODEC_ID_VC9) { #if 0 uint32_t scp = 0; int scs = 0, i = 0; while (i < buf_size) { for (; i < buf_size && scp != 0x000001; i++) scp = ((scp<<8)|buf[i])&0xffffff; if (scp != 0x000001) break; scs = buf[i++]; init_get_bits(gb, buf+i, (buf_size-i)*8); switch(scs) { case 0x0A: return 0; case 0x0B: av_log(avctx, AV_LOG_ERROR, "Slice coding not supported\n"); return -1; case 0x0C: av_log(avctx, AV_LOG_ERROR, "Interlaced coding not supported\n"); return -1; case 0x0D: break; case 0x0E: if (v->profile <= MAIN_PROFILE) av_log(avctx, AV_LOG_ERROR, "Found an entry point in profile %i\n", v->profile); advanced_entry_point_process(avctx, gb); break; case 0x0F: decode_sequence_header(avctx, gb); break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported IDU suffix %lX\n", scs); } i += get_bits_count(gb)*8; } #else av_abort(); #endif } else init_get_bits(&v->s.gb, buf, buf_size*8); s->flags= avctx->flags; s->flags2= avctx->flags2; if (buf_size == 0) { if (s->low_delay==0 && s->next_picture_ptr) { *pict= *(AVFrame*)s->next_picture_ptr; s->next_picture_ptr= NULL; *data_size = sizeof(AVFrame); } return 0; } s->bitstream_buffer_size=0; if (!s->context_initialized) { if (MPV_common_init(s) < 0) return -1; } if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){ s->current_picture_ptr= &s->picture[ff_find_unused_picture(s, 0)]; } #if HAS_ADVANCED_PROFILE if (v->profile > PROFILE_MAIN) ret= advanced_decode_picture_primary_header(v); else #endif ret= standard_decode_picture_primary_header(v); if (ret == FRAME_SKIPED) return buf_size; if (ret < 0){ av_log(s->avctx, AV_LOG_ERROR, "header damaged\n"); return -1; } if (v->profile <= PROFILE_MAIN && v->multires){ } s->current_picture.pict_type= s->pict_type; s->current_picture.key_frame= s->pict_type == I_TYPE; if(s->last_picture_ptr==NULL && (s->pict_type==B_TYPE || s->dropable)) return buf_size; if(avctx->hurry_up && s->pict_type==B_TYPE) return buf_size; if(avctx->hurry_up>=5) return buf_size; if(s->next_p_frame_damaged){ if(s->pict_type==B_TYPE) return buf_size; else s->next_p_frame_damaged=0; } if(MPV_frame_start(s, avctx) < 0) return -1; ff_er_frame_start(s); #if HAS_ADVANCED_PROFILE if (v->profile > PROFILE_MAIN) ret= advanced_decode_picture_secondary_header(v); else #endif ret = standard_decode_picture_secondary_header(v); if (ret<0) return FRAME_SKIPED; #if HAS_ADVANCED_PROFILE if (v->profile > PROFILE_MAIN) { switch(s->pict_type) { case I_TYPE: ret = advanced_decode_i_mbs(v); break; case P_TYPE: ret = decode_p_mbs(v); break; case B_TYPE: case BI_TYPE: ret = decode_b_mbs(v); break; default: ret = FRAME_SKIPED; } if (ret == FRAME_SKIPED) return buf_size; } else #endif { switch(s->pict_type) { case I_TYPE: ret = standard_decode_i_mbs(v); break; case P_TYPE: ret = decode_p_mbs(v); break; case B_TYPE: case BI_TYPE: ret = decode_b_mbs(v); break; default: ret = FRAME_SKIPED; } if (ret == FRAME_SKIPED) return buf_size; } ff_er_frame_end(s); MPV_frame_end(s); assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type); assert(s->current_picture.pict_type == s->pict_type); if(s->pict_type==B_TYPE || s->low_delay){ *pict= *(AVFrame*)&s->current_picture; ff_print_debug_info(s, pict); } else { *pict= *(AVFrame*)&s->last_picture; if(pict) ff_print_debug_info(s, pict); } avctx->frame_number = s->picture_number - 1; if(s->last_picture_ptr || s->low_delay) *data_size = sizeof(AVFrame); av_log(avctx, AV_LOG_DEBUG, "Consumed %i/%i bits\n", get_bits_count(&s->gb), buf_size*8); *data_size = len; return buf_size; }
1threat
PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint16_t vid, uint16_t did, pci_map_irq_fn map_irq, const char *name) { PCIDevice *dev; PCIBridge *s; dev = pci_create(bus, devfn, "pci-bridge"); qdev_prop_set_uint32(&dev->qdev, "vendorid", vid); qdev_prop_set_uint32(&dev->qdev, "deviceid", did); qdev_init(&dev->qdev); s = DO_UPCAST(PCIBridge, dev, dev); pci_register_secondary_bus(&s->bus, &s->dev, map_irq, name); return &s->bus; }
1threat
Bean validation size of a List? : <p>How can I set a bean validation constraint that a <code>List</code> should at minimum contain 1 and at maximum contain 10 elements?</p> <p>None of the following works:</p> <pre><code>@Min(1) @Max(10) @Size(min=1, max=10) private List&lt;String&gt; list; </code></pre>
0debug
In hapijs ' property register of undefined ' is comming : Packages are---> "dependencies": { "handlebars": "^4.0.11", "hapi": "^16.6.2", "inert": "^4.2.1", "vision": "^5.3.2" } } ------------------------------------------------------------------------------ //Vision templates server.register(require('vision'),function (err) { if(err){ throw err; } server.views({ engines:{ html:require('handlebars') }, path:__dirname+'/views' }); }); I am getting property 'register' of undefined in vision and handlebars in node.js. i have provide with dependencies as well, please help
0debug
How do I update a Kubernetes autoscaler? : <p>I have created a <a href="http://kubernetes.io/v1.1/docs/user-guide/horizontal-pod-autoscaler.html" rel="noreferrer">Kubernetes autoscaler</a>, but I need to change its parameters. How do I update it?</p> <p>I've tried the following, but it fails:</p> <pre><code>✗ kubectl autoscale -f docker/production/web-controller.yaml --min=2 --max=6 Error from server: horizontalpodautoscalers.extensions "web" already exists </code></pre>
0debug
List topic in c++, output Explanation : This is a question from a past paper that I am having issues with, the question and output is displayed below but I don't understand how this is achieved. Can someone please explain. int main (){ int a[5] = { 1 }, b[] = { 3, -1, 2, 0, 4 }; for (int i = 0; i<5; i++) { if (!(a[i] = b[i])) // note: = not == break; cout << a[i] << endl; } } Output: 3 -1 2
0debug
Regex to get event start and end times : I'm webscraping with webscraper.io and From 'Time: 12:00 PM to 9:00 PM' I'm trying to grab '12:00 PM' and '9:00 PM'. I'm trying to get them as separate items, so I think two regex expressions are in order. Any regex wizards willing to lend a hand? I tried this: https://forum.sublimetext.com/t/regex-match-everything-after-this-word/20764 to grab everything after 'to' but it isn't working for some reason.
0debug
CSS buttom align bottom : I'm developing a webapp mobile using the Bootstrap. I have a screen with a text and a button. When the text is small the button should be on the bottom of the page, but when the text is large the button should be after to the end of text. How to do this with CSS?
0debug
static int qcow2_open(BlockDriverState *bs, QDict *options, int flags) { BDRVQcowState *s = bs->opaque; int len, i, ret = 0; QCowHeader header; QemuOpts *opts; Error *local_err = NULL; uint64_t ext_end; uint64_t l1_vm_state_index; ret = bdrv_pread(bs->file, 0, &header, sizeof(header)); if (ret < 0) { be32_to_cpus(&header.magic); be32_to_cpus(&header.version); be64_to_cpus(&header.backing_file_offset); be32_to_cpus(&header.backing_file_size); be64_to_cpus(&header.size); be32_to_cpus(&header.cluster_bits); be32_to_cpus(&header.crypt_method); be64_to_cpus(&header.l1_table_offset); be32_to_cpus(&header.l1_size); be64_to_cpus(&header.refcount_table_offset); be32_to_cpus(&header.refcount_table_clusters); be64_to_cpus(&header.snapshots_offset); be32_to_cpus(&header.nb_snapshots); if (header.magic != QCOW_MAGIC) { ret = -EMEDIUMTYPE; if (header.version < 2 || header.version > 3) { report_unsupported(bs, "QCOW version %d", header.version); ret = -ENOTSUP; s->qcow_version = header.version; if (header.version == 2) { header.incompatible_features = 0; header.compatible_features = 0; header.autoclear_features = 0; header.refcount_order = 4; header.header_length = 72; } else { be64_to_cpus(&header.incompatible_features); be64_to_cpus(&header.compatible_features); be64_to_cpus(&header.autoclear_features); be32_to_cpus(&header.refcount_order); be32_to_cpus(&header.header_length); if (header.header_length > sizeof(header)) { s->unknown_header_fields_size = header.header_length - sizeof(header); s->unknown_header_fields = g_malloc(s->unknown_header_fields_size); ret = bdrv_pread(bs->file, sizeof(header), s->unknown_header_fields, s->unknown_header_fields_size); if (ret < 0) { if (header.backing_file_offset) { ext_end = header.backing_file_offset; } else { ext_end = 1 << header.cluster_bits; s->incompatible_features = header.incompatible_features; s->compatible_features = header.compatible_features; s->autoclear_features = header.autoclear_features; if (s->incompatible_features & ~QCOW2_INCOMPAT_MASK) { void *feature_table = NULL; qcow2_read_extensions(bs, header.header_length, ext_end, &feature_table); report_unsupported_feature(bs, feature_table, s->incompatible_features & ~QCOW2_INCOMPAT_MASK); ret = -ENOTSUP; if (header.refcount_order != 4) { report_unsupported(bs, "%d bit reference counts", 1 << header.refcount_order); ret = -ENOTSUP; if (header.cluster_bits < MIN_CLUSTER_BITS || header.cluster_bits > MAX_CLUSTER_BITS) { ret = -EINVAL; if (header.crypt_method > QCOW_CRYPT_AES) { ret = -EINVAL; s->crypt_method_header = header.crypt_method; if (s->crypt_method_header) { bs->encrypted = 1; s->cluster_bits = header.cluster_bits; s->cluster_size = 1 << s->cluster_bits; s->cluster_sectors = 1 << (s->cluster_bits - 9); s->l2_bits = s->cluster_bits - 3; s->l2_size = 1 << s->l2_bits; bs->total_sectors = header.size / 512; s->csize_shift = (62 - (s->cluster_bits - 8)); s->csize_mask = (1 << (s->cluster_bits - 8)) - 1; s->cluster_offset_mask = (1LL << s->csize_shift) - 1; s->refcount_table_offset = header.refcount_table_offset; s->refcount_table_size = header.refcount_table_clusters << (s->cluster_bits - 3); s->snapshots_offset = header.snapshots_offset; s->nb_snapshots = header.nb_snapshots; s->l1_size = header.l1_size; l1_vm_state_index = size_to_l1(s, header.size); if (l1_vm_state_index > INT_MAX) { ret = -EFBIG; s->l1_vm_state_index = l1_vm_state_index; if (s->l1_size < s->l1_vm_state_index) { ret = -EINVAL; s->l1_table_offset = header.l1_table_offset; if (s->l1_size > 0) { s->l1_table = g_malloc0( align_offset(s->l1_size * sizeof(uint64_t), 512)); ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)); if (ret < 0) { for(i = 0;i < s->l1_size; i++) { be64_to_cpus(&s->l1_table[i]); s->l2_table_cache = qcow2_cache_create(bs, L2_CACHE_SIZE); s->refcount_block_cache = qcow2_cache_create(bs, REFCOUNT_CACHE_SIZE); s->cluster_cache = g_malloc(s->cluster_size); s->cluster_data = qemu_blockalign(bs, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size + 512); s->cluster_cache_offset = -1; s->flags = flags; ret = qcow2_refcount_init(bs); if (ret != 0) { QLIST_INIT(&s->cluster_allocs); QTAILQ_INIT(&s->discards); if (qcow2_read_extensions(bs, header.header_length, ext_end, NULL)) { ret = -EINVAL; if (header.backing_file_offset != 0) { len = header.backing_file_size; if (len > 1023) { len = 1023; ret = bdrv_pread(bs->file, header.backing_file_offset, bs->backing_file, len); if (ret < 0) { bs->backing_file[len] = '\0'; ret = qcow2_read_snapshots(bs); if (ret < 0) { if (!bs->read_only && s->autoclear_features != 0) { s->autoclear_features = 0; ret = qcow2_update_header(bs); if (ret < 0) { qemu_co_mutex_init(&s->lock); if (!(flags & BDRV_O_CHECK) && !bs->read_only && (s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) { BdrvCheckResult result = {0}; ret = qcow2_check(bs, &result, BDRV_FIX_ERRORS); if (ret < 0) { opts = qemu_opts_create_nofail(&qcow2_runtime_opts); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { qerror_report_err(local_err); error_free(local_err); ret = -EINVAL; s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; s->discard_passthrough[QCOW2_DISCARD_REQUEST] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, flags & BDRV_O_UNMAP); s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); s->discard_passthrough[QCOW2_DISCARD_OTHER] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); qemu_opts_del(opts); if (s->use_lazy_refcounts && s->qcow_version < 3) { qerror_report(ERROR_CLASS_GENERIC_ERROR, "Lazy refcounts require " "a qcow2 image with at least qemu 1.1 compatibility level"); ret = -EINVAL; #ifdef DEBUG_ALLOC { BdrvCheckResult result = {0}; qcow2_check_refcounts(bs, &result, 0); #endif return ret; fail: g_free(s->unknown_header_fields); cleanup_unknown_header_ext(bs); qcow2_free_snapshots(bs); qcow2_refcount_close(bs); g_free(s->l1_table); if (s->l2_table_cache) { qcow2_cache_destroy(bs, s->l2_table_cache); g_free(s->cluster_cache); qemu_vfree(s->cluster_data); return ret;
1threat
how to search for words in a string in a text file : Trying to match words from user input with a string from a text file. Basically, the text file is a single string containing numerous words, which acts as a "dictionary". The goal is to match all possible user inputted words with words from the text file(dictionary). [1]: http://i.stack.imgur.com/sjcTH.jpg
0debug
responsive grid using flex with equals cells size : I have this html code in: [jsfiddle][1] and i want to make the all the cells equals responsive. This example works fine but....i want all the cells to be equal when resizing the browser. In this example there are 5 cells which occupies all the contaier (4 logo and 1 text). The last 2 cells (the second row) are not equals (2 cells occupied the whole row). I want to be the same size as the first row (this means: cell cell empty_space). Is this possible using flex:1 ? flex: 1 I hope i make my self clear :) [1]: https://jsfiddle.net/aq9Laaew/100131/
0debug
WebAPI Selfhost: Can't bind multiple parameters to the request's content : <p>The below code are simplified to show the necessity. May I know what is wrong? I can't seems to retrieve two Parameters (A and B in this case) using the [FromBody] attribute.</p> <p>The error message is "Can't bind multiple parameters ('A' and 'B') to the request's content"</p> <p>It is perfectly fine if I have either A or B only.</p> <p>Web API:</p> <pre><code>[Route("API/Test"), HttpPost] public IHttpActionResult Test([FromBody] int A, [FromBody] int B) </code></pre> <p>Client:</p> <pre><code>HttpClient client = new HttpClient(); var content = new FormUrlEncodedContent( new Dictionary&lt;string, string&gt; { { "A", "123" }, { "B", "456" } }); client.PostAsync("http://localhost/API/Test", content).Result; </code></pre>
0debug
Cannot inject Templating on Symfony 4 Service : <p>I have the following class:</p> <p><strong>EmailNotification</strong></p> <pre><code>namespace App\Component\Notification\RealTimeNotification; use Symfony\Bridge\Twig\TwigEngine; use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use App\Component\Notification\NotificationInterface; class EmailNotification implements NotificationInterface { private $logNotification; public function __construct(LogNotification $logNotification, \Swift_Mailer $mailer, EngineInterface $twigEngine) { $this-&gt;logNotification = $logNotification; } public function send(array $options): void { $this-&gt;logNotification-&gt;send($options); dump('Sent to email'); } } </code></pre> <p>I have the following service definition on my yml:</p> <pre><code>app.email_notification: class: App\Component\Notification\RealTimeNotification\EmailNotification decorates: app.log_notification decoration_inner_name: app.log_notification.inner arguments: ['@app.log_notification.inner', '@mailer', '@templating'] </code></pre> <p>However, when i tried to run my app it throws an Exception saying:</p> <blockquote> <p>Cannot autowire service "App\Component\Notification\RealTimeNotification\EmailNotification": argument "$twigEngine" of method "__construct()" has type "Symfony\Bundle\FrameworkBundle\Templating\EngineInterface" but this class was not found.</p> </blockquote> <p>Why is that so?</p> <p>Thanks!</p>
0debug
size_t slirp_socket_can_recv(Slirp *slirp, struct in_addr guest_addr, int guest_port) { struct iovec iov[2]; struct socket *so; so = slirp_find_ctl_socket(slirp, guest_addr, guest_port); if (!so || so->so_state & SS_NOFDREF) return 0; if (!CONN_CANFRCV(so) || so->so_snd.sb_cc >= (so->so_snd.sb_datalen/2)) return 0; return sopreprbuf(so, iov, NULL); }
1threat
How do I tell IntelliJ IdeaVim to re-source the .ideavimrc : <p>I made some changes to my <code>.ideavimrc</code> and I want IntelliJ IdeaVim to reload the file. I can obviously close and reopen IntelliJ, but that sucks.</p> <p>How can I re-source my <code>.ideavimrc</code> without restarting IntelliJ?</p>
0debug
void ff_restore_parser_state(AVFormatContext *s, AVParserState *state) { int i; AVStream *st; AVParserStreamState *ss; ff_read_frame_flush(s); if (!state) return; avio_seek(s->pb, state->fpos, SEEK_SET); s->cur_st = state->cur_st; s->packet_buffer = state->packet_buffer; s->raw_packet_buffer = state->raw_packet_buffer; s->raw_packet_buffer_remaining_size = state->raw_packet_buffer_remaining_size; for (i = 0; i < state->nb_streams; i++) { st = s->streams[i]; ss = &state->stream_states[i]; st->parser = ss->parser; st->last_IP_pts = ss->last_IP_pts; st->cur_dts = ss->cur_dts; st->reference_dts = ss->reference_dts; st->cur_ptr = ss->cur_ptr; st->cur_len = ss->cur_len; st->probe_packets = ss->probe_packets; st->cur_pkt = ss->cur_pkt; } av_free(state->stream_states); av_free(state); }
1threat
static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out) { CharDriverState *chr; FDCharDriver *s; chr = qemu_chr_alloc(); s = g_malloc0(sizeof(FDCharDriver)); s->fd_in = io_channel_from_fd(fd_in); s->fd_out = io_channel_from_fd(fd_out); qemu_set_nonblock(fd_out); s->chr = chr; chr->opaque = s; chr->chr_add_watch = fd_chr_add_watch; chr->chr_write = fd_chr_write; chr->chr_update_read_handler = fd_chr_update_read_handler; chr->chr_close = fd_chr_close; return chr; }
1threat
Handling window pop up with selenium : <p>I am currently working on a bot that logs into instagram, I currently have the script to log in and turn on notifications but when then I get a window pop the code does not click on allow. I have been stuck for quite some time. Thank you in advance for your help. <a href="https://i.stack.imgur.com/M1P9L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M1P9L.png" alt="Window Popup"></a></p> <pre><code>def allow_noti(): allow_noti = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[contains(.,'Turn On')]"))) allow_noti.click() allow_browser = WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.XPATH, '//* [text()="Allow"]'))).click() allow_browser.click() </code></pre>
0debug
Test if function is called react and enzyme : <p>I am trying to test one of the methods in my react component. It is being called after a button click so I have the simulation in place with enzyme </p> <pre><code> it('clone should call handleCloneClick when clicked', () =&gt; { const cloneButton = wrapper.find('#clone-btn'); cloneButton.simulate('click'); }); </code></pre> <p>My component method is here: </p> <pre><code>_handleCloneClick(event) { event.preventDefault(); event.stopPropagation(); this.props.handleClone(this.props.user.id); } </code></pre> <p>The _handleCloneClick is being called when the user clicks on the button thats in the simulation, how can I go about testing that its been called successfully? </p>
0debug
Kotlin when with multiple values not working when value is an android view : <p>I implemented a function that is used in anko's apply recursively:</p> <pre><code>fun applyTemplateViewStyles(view: View) { when(view) { is EditText, TextView -&gt; { .... } } } </code></pre> <p>And I receive an error saying that "Function invocation 'TextView(...)' expected"</p> <p>Since I can write an when with a clause like is 0, 1, why I can't do the same with an Android View? </p>
0debug
I am thinking to move from Aurelia to React! Is it a good decision? : <h1>I am thinking to move from Aurelia to React! Is it a good decision?</h1> <p>Can react will perform better where I am using Aurelia?</p>
0debug
document.write('<script src="evil.js"></script>');
1threat
Visual studio code auto-complete : <p>I have just downloaded unity and saw that now it supports Visual studio code, I downloaded it and made it the default editor.</p> <p>After trying to edit a script, it prompted me to download c# extension and I did, but there is no auto-complete for unity functions. How can I get that? I'm on Mac. Any help is appreciated.</p>
0debug
opts_next_list(Visitor *v, GenericList **list, Error **errp) { OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v); GenericList **link; if (ov->repeated_opts_first) { ov->repeated_opts_first = false; link = list; } else { const QemuOpt *opt; opt = g_queue_pop_head(ov->repeated_opts); if (g_queue_is_empty(ov->repeated_opts)) { g_hash_table_remove(ov->unprocessed_opts, opt->name); return NULL; } link = &(*list)->next; } *link = g_malloc0(sizeof **link); return *link; }
1threat
Cohabitation Docker & VirtualBox on Windows : <p>Docker uses the Hyper V functionality so it has to be enabled for Docker to work properly. However, the Hyper V functionality has to be disabled for VirtualBox to work properly (it's possible to create guests and emulate them but only if they're 32bits machines it seems).</p> <p>Is there any way to have an healthy cohabitation with the two and for them to work at the same time? Instead of enable/disabling the Hyper V option and reboot every time?</p>
0debug
Make website span to user? : <p>How would I make a website adopt the dimensions of a user's device who is browsing it, in order to avoid problems that would deter from aesthetics like scrolling the width of the page in order to see full content.</p> <p>If that is not possible what are the best dimensions?</p>
0debug
static void ff_h264_idct_add16intra_mmx2(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){ int i; for(i=0; i<16; i++){ if(nnzc[ scan8[i] ]) ff_h264_idct_add_mmx (dst + block_offset[i], block + i*16, stride); else if(block[i*16]) ff_h264_idct_dc_add_mmx2(dst + block_offset[i], block + i*16, stride); } }
1threat
How to control md-select drop down position in Angular Material : <p>I need to customize a md-select so that the option list acts more like a traditional select. The options should show up below the select element instead of hovering over top of the element. Does anyone know of something like this that exists, or how to accomplish this?</p>
0debug
Double variable to setlatitude error : NullPointerException this error happens when i try to set `location2.setLatitude(latitudeclick);` I test the app and i receive when i click the value out of latitudeclick @Override public void onResult(PlaceBuffer places) { if (places.getCount() == 1) { localizacao = (places.get(0).getLatLng()); Double latitudeclick = localizacao.latitude; Double longitudeclick = localizacao.longitude; Location location2 = null; location2.setLatitude(latitudeclick); location2.setLatitude(longitudeclick); }
0debug
static void shifter_out_im(TCGv var, int shift) { TCGv tmp = new_tmp(); if (shift == 0) { tcg_gen_andi_i32(tmp, var, 1); } else { tcg_gen_shri_i32(tmp, var, shift); if (shift != 31) tcg_gen_andi_i32(tmp, tmp, 1); } gen_set_CF(tmp); dead_tmp(tmp); }
1threat