problem
stringlengths
26
131k
labels
class label
2 classes
void virtqueue_discard(VirtQueue *vq, const VirtQueueElement *elem, unsigned int len) { vq->last_avail_idx--; virtqueue_unmap_sg(vq, elem, len); }
1threat
UISearchBar disappears from tableHeaderView when using beginUpdates/endUpdates : <p>I have a table view controller with a <code>UISearchController</code> that sets <code>UISearchBar</code> as the <code>tableView.tableHeaderView</code>. When updating the search results, I use the <code>beginUpdates</code> and <code>endUpdates</code> and related methods to update the data for the table view.</p> <p>This makes the search bar disappear; the <code>tableHeaderView</code> is set to an empty, generic <code>UIView</code> of the same size as the search bar. If I simply use <code>reloadData</code> instead of the whole <code>beginUpdates</code>/<code>endUpdates</code> procedure, everything is fine.</p> <p>The table view controller is embedded in a regular view controller; there is no navigation controller involved. This is the entire implementation of the table view controller necessary to reproduce the issue:</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; self.searchController.searchResultsUpdater = self; self.searchController.dimsBackgroundDuringPresentation = NO; self.tableView.tableHeaderView = self.searchController.searchBar; } - (void)updateSearchResultsForSearchController:(UISearchController *)searchController { [self.tableView beginUpdates]; [self.tableView endUpdates]; } </code></pre> <p>Why does this cause the search bar to be replaced with a blank view, and how can it be avoided?</p>
0debug
How to rewrite the Path of a Website? : <p>actually I'm trying to build up a website to get better in coding but no matter how much i am reading, I dont get how to rewrite paths.</p> <p>Any tipps how to rewrite <a href="http://domain/login/php/login.php" rel="nofollow noreferrer">http://domain/login/php/login.php</a> to <a href="http://domain/login.php" rel="nofollow noreferrer">http://domain/login.php</a> ?</p> <p>Best regards, a Saltyy noob :c</p>
0debug
static inline uint32_t vtd_slpt_level_shift(uint32_t level) { return VTD_PAGE_SHIFT_4K + (level - 1) * VTD_SL_LEVEL_BITS; }
1threat
chai-http not exiting after running tests : <p>I ran into a problem where my mocha tests were not finishing after running with chai-http. Mocha just hangs after the tests and eventually runs into a timeout (at least on my CI).</p>
0debug
int ppc_get_compat_smt_threads(PowerPCCPU *cpu) { int ret = smp_threads; PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); switch (cpu->cpu_version) { case CPU_POWERPC_LOGICAL_2_05: ret = 2; break; case CPU_POWERPC_LOGICAL_2_06: ret = 4; break; case CPU_POWERPC_LOGICAL_2_07: ret = 8; break; default: if (pcc->pcr_mask & PCR_COMPAT_2_06) { ret = 4; } else if (pcc->pcr_mask & PCR_COMPAT_2_05) { ret = 2; } break; } return MIN(ret, smp_threads); }
1threat
static void usb_msd_realize_storage(USBDevice *dev, Error **errp) { MSDState *s = DO_UPCAST(MSDState, dev, dev); BlockDriverState *bs = s->conf.bs; SCSIDevice *scsi_dev; Error *err = NULL; if (!bs) { error_setg(errp, "drive property not set"); return; } blkconf_serial(&s->conf, &dev->serial); bdrv_detach_dev(bs, &s->dev.qdev); s->conf.bs = NULL; usb_desc_create_serial(dev); usb_desc_init(dev); scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev), &usb_msd_scsi_info_storage, NULL); scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0, !!s->removable, s->conf.bootindex, dev->serial, &err); if (!scsi_dev) { error_propagate(errp, err); return; } s->bus.qbus.allow_hotplug = 0; usb_msd_handle_reset(dev); if (bdrv_key_required(bs)) { if (cur_mon) { monitor_read_bdrv_key_start(cur_mon, bs, usb_msd_password_cb, s); s->dev.auto_attach = 0; } else { autostart = 0; } } }
1threat
How to use remote config from Google for this? (Android studio) : How can I change whenever I need the Videoview URL using the Google Firebase Remote config method? - More details: I have a VideoView that uses URL to show video or stream but I want to be able to change these links whenever I need. Without having to create a new application update! - My activity: -- package tk.protvapp.protv; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.view.Window; import android.widget.MediaController; import android.widget.VideoView; public class FoxActivity extends Activity { VideoView myVideoView; View v; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_fox); myVideoView = (VideoView)this.findViewById(R.id.videofox1); MediaController mc = new MediaController(this); myVideoView.setMediaController(mc); final String urlStream = "//Search the link in remote config for paste here"; myVideoView.start(); myVideoView.findFocus(); runOnUiThread(new Runnable() { @Override public void run() { myVideoView.setVideoURI(Uri.parse(urlStream)); } }); } public void voltarhomefox(View v){ Intent intent = new Intent(FoxActivity.this, HomeActivity.class); startActivity(intent); } } My Layout: ------- <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:ads="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#000" tools:context="tk.protvapp.protv.FoxActivity"> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:onClick="voltarhomefox" android:text="VOLTAR" /> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/button2" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:id="@+id/frameLayout"> <VideoView android:id="@+id/videofox1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </FrameLayout> </RelativeLayout>
0debug
static hwaddr ppc_hash64_pteg_search(PowerPCCPU *cpu, hwaddr hash, bool secondary, target_ulong ptem, ppc_hash_pte64_t *pte) { CPUPPCState *env = &cpu->env; int i; uint64_t token; target_ulong pte0, pte1; target_ulong pte_index; pte_index = (hash & env->htab_mask) * HPTES_PER_GROUP; token = ppc_hash64_start_access(cpu, pte_index); if (!token) { return -1; } for (i = 0; i < HPTES_PER_GROUP; i++) { pte0 = ppc_hash64_load_hpte0(cpu, token, i); pte1 = ppc_hash64_load_hpte1(cpu, token, i); if ((pte0 & HPTE64_V_VALID) && (secondary == !!(pte0 & HPTE64_V_SECONDARY)) && HPTE64_V_COMPARE(pte0, ptem)) { pte->pte0 = pte0; pte->pte1 = pte1; ppc_hash64_stop_access(cpu, token); return (pte_index + i) * HASH_PTE_SIZE_64; } } ppc_hash64_stop_access(cpu, token); return -1; }
1threat
Internal woking of Arrays.sort by debugging in eclipse : <p>I want to know how Arrays.sort method works internally and I started to debug the program but I am not able to stepin into the Arrays.sort method . I am getting the following error "source not found"</p> <p>However I added my project into source look up path . Can someone help me to debug the program so that I can know internal working of Arrays.sort method in runtime . <a href="https://drive.google.com/file/d/0B7n2ckO7qXq8Tk41OG9maTlsZGM/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/0B7n2ckO7qXq8Tk41OG9maTlsZGM/view?usp=sharing</a> <a href="https://drive.google.com/file/d/0B7n2ckO7qXq8NzFQUGtpd0VTUWc/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/0B7n2ckO7qXq8NzFQUGtpd0VTUWc/view?usp=sharing</a></p> <p>Here goes the code to Sort array </p> <pre><code> String[] stringArray = { "Barbara", "James", "Mary", "John", "Patricia", "Robert", "Michael", "Linda" }; Arrays.sort(stringArray, String::compareToIgnoreCase); for(String s:stringArray) System.out.print(s + " "); </code></pre> <p>Thank you </p>
0debug
how to return a value in method inside a loop? : its actually can't be returned. because it have loop in it. private int IsPrime (int startNumb , int endNumb) { bool bilPrima = true; for (int i = startNumb; i<= endNumb; i++) { for (int j = 2; j <= i; j++) { if (i%j==0) { bilPrima = false; break; } } if (bilPrima) { bilPrima = true; return i; } else { return 0; } } } help me pls :(
0debug
void pc_system_firmware_init(MemoryRegion *rom_memory) { DriveInfo *pflash_drv; PcSysFwDevice *sysfw_dev; sysfw_dev = (PcSysFwDevice*) qdev_create(NULL, "pc-sysfw"); qdev_init_nofail(DEVICE(sysfw_dev)); if (sysfw_dev->rom_only) { old_pc_system_rom_init(rom_memory); return; } pflash_drv = drive_get(IF_PFLASH, 0, 0); if (pc_sysfw_flash_vs_rom_bug_compatible && kvm_enabled()) { if (pflash_drv != NULL) { fprintf(stderr, "qemu: pflash cannot be used with kvm enabled\n"); exit(1); } else { sysfw_dev->rom_only = 1; old_pc_system_rom_init(rom_memory); return; } } if (pflash_drv == NULL) { pc_fw_add_pflash_drv(); pflash_drv = drive_get(IF_PFLASH, 0, 0); } if (pflash_drv != NULL) { pc_system_flash_init(rom_memory, pflash_drv); } else { fprintf(stderr, "qemu: PC system firmware (pflash) not available\n"); exit(1); } }
1threat
Api blockchain not works : <p>I've a little Bot to use the api for <a href="https://www.blockchain.com/" rel="nofollow noreferrer">https://www.blockchain.com/</a>. It's work until recently, but now the service respose with: erver returned HTTP response code: 429 . I have recevided the api-key for use the service. But is not present documentation to describe how use this api.</p> <p>Can you help me?? Thanks</p>
0debug
null object reference error in action script : used resize handler to resize my component/. But it is throwing error: <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" resize="application2_resizeHandler(event)" > <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <fx:Script> <![CDATA[ import mx.events.FlexEvent; import mx.events.ResizeEvent; private var employeeName:String = 'ravi'; protected function application2_resizeHandler(event:ResizeEvent):void { mainGroup.width = stage.width - 10; mainGroup.x = 5; } ]]> </fx:Script> <s:Group width="100%" height="100%"> <s:VGroup id="mainGroup" > <s:Label id="employeeNameLabel" text="{employeeName}" /> <s:Label id="departmentLabel" /> </s:VGroup> <s:Button id="getData" /> </s:Group> </s:Application>
0debug
How to generate new image using deep learning, from new features : <p>If i have a dataset consisting by a list of images each associated with a series of features; there is a model that, once trained, generates new images upon entering a new list of features?</p>
0debug
how to change badge number when user receive notification in background mode ( this is my code ) : func application(_ application: UIApplication, didReceiveRemoteNotification notification: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { /* let aps = userInfo["aps"] as! [String: AnyObject] if let count = aps["badge"] as? Int { application.applicationIconBadgeNumber = 2 } */ let custom = notification["custom"] as! [String: AnyObject] if let home = custom["a"]!["home"] as? String, home == "1" { incrementBadgeNumberBy(badgeNumberIncrement: 1) } }
0debug
How do I create an array from a JSON data without repeating the values? : <p>I retrieved a JSON from an API that looks like this:</p> <pre><code>{ "status": "success", "response": [ { "id": 1, "name": "SEA BUSES", "image": null }, { "id": 2, "name": "BEN BUSES", "image": null }, { "id": 3, "name": "CAPE BUSES", "image": null } ] } </code></pre> <p>I want to create an array of the IDs in this form ids = [1,2,3] </p> <p>this is my javascript:</p> <pre><code>companyid = response.data.response var ids = []; for (var i = 0; i &lt; companyid.length; i++){ ids.push(companyid[i].id) console.log(ids) } </code></pre> <p>but the output is not what I expected. It shows this way:</p> <pre><code>[ 1 ] [ 1, 2 ] [ 1, 2, 3 ] </code></pre> <p>Any help please?</p>
0debug
Line indentor - Length of java between classes being set to 0 : I have the task of making an indentor for some javaline. The idea is that first I have to split the java from the comment. I then have to find the longest line and use that for the max length of java. However I have run into the issue of that its returning with 0 every time and not the longest line in an array. The first piece of code is the class that holds the method for working out the longest length of javaline. The method is called findMaxJavaLineLength(): import java.util.*; class Program { private ArrayList<JavaLine> stored = new ArrayList<>(); /** * Constructor */ public Program() { stored.clear(); } /** * Add the next line of Java code to the stored program * @param line A line of Java code */ public void addLine( String line ) { stored.add( new JavaLine( line) ); } public String indentProgram() { String res = ""; for ( JavaLine line: stored ) { res += line.returnLineWithCommentAt() + "\n"; } return res; } public int findMaxJavaLineLength() { int max = 0; for ( JavaLine line: stored ) { int lineLength = line.getJavaLineLength(); if ( lineLength > max) max = lineLength; } return max; } } and the second piece of code is the JavaLine class which splits the code into parts and returns the length of java: class JavaLine { private String java = ""; // Java code on line private String comment = ""; // The single line comment private String javaSpace = ""; private int lenJava = 0; // The line length of just the java cod public JavaLine( String line ) { String[] splitted = line.split("// "); java = splitted[0]; int slashCount = line.length() - line.replaceAll("//","").length(); if (slashCount >= 1) { comment = "// " + splitted[1]; } } public int getJavaLineLength() { lenJava = java.length(); return lenJava; } public String returnLineWithCommentAt( ) { String output = ""; Program t = new Program(); int maxLenJavaLine = t.findMaxJavaLineLength(); int number = maxLenJavaLine - getJavaLineLength(); String javaSpace = ""; for (int n = 0; n < number; n++){ javaSpace = javaSpace + " "; } String commentOutput = comment; if ( java.contains("}")){ output = java; }else if ( java.contains("{")){ output = java; } else { output = java + javaSpace + commentOutput + "test: " + t.findMaxJavaLineLength(); } return output; } } I have tested it and it seems like the lenJava bit in the getjavalength is working out the length of the javaline correctly when I grab it from the same class. However it sets to 0 when I grab it from the other class when trying to work out the longest line. It seems as if the length just doesn't get passed to the other class from the javaline class. Below is the output that I am currently receiving. import java.lang.Thread;// Use External classtest: 0 class Countdowntest: 0 { public static void main( String args[] )test: 0 { // Start from 10test: 0 while ( countdown > 0 )// While greater than 0test: 0 { System.out.println(countdown);// Write contents of countdowntest: 0 if ( countdown == 3 )// If equal to 3test: 0 { System.out.println("Ignition");// Write Ignitiontest: 0 } countdown--;// Decrement countdown by 1test: 0 try { Thread.sleep( 100 );// 1000 milliseconds delaytest: 0 } catch( InterruptedException e ) {} } System.out.println( "Blast Off");// Write Blast offtest: 0 } } The bit of the output where it says "test: 0" is where I am expecting the length of the javaline which is the longest. so it should be "test: 50" or whatever instead of "test: 0". Thank you
0debug
static void new_subtitle_stream(AVFormatContext *oc) { AVStream *st; AVCodec *codec=NULL; AVCodecContext *subtitle_enc; st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); if (!st) { fprintf(stderr, "Could not alloc stream\n"); ffmpeg_exit(1); } subtitle_enc = st->codec; output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output_codecs, nb_output_codecs + 1); if(!subtitle_stream_copy){ subtitle_enc->codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1, avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->strict_std_compliance); codec= output_codecs[nb_output_codecs-1] = avcodec_find_encoder_by_name(subtitle_codec_name); } avcodec_get_context_defaults3(st->codec, codec); bitstream_filters[nb_output_files] = grow_array(bitstream_filters[nb_output_files], sizeof(*bitstream_filters[nb_output_files]), &nb_bitstream_filters[nb_output_files], oc->nb_streams); bitstream_filters[nb_output_files][oc->nb_streams - 1]= subtitle_bitstream_filters; subtitle_bitstream_filters= NULL; subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE; if(subtitle_codec_tag) subtitle_enc->codec_tag= subtitle_codec_tag; if (subtitle_stream_copy) { st->stream_copy = 1; } else { set_context_opts(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], subtitle_enc, AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec); } if (subtitle_language) { av_metadata_set2(&st->metadata, "language", subtitle_language, 0); av_freep(&subtitle_language); } subtitle_disable = 0; av_freep(&subtitle_codec_name); subtitle_stream_copy = 0; }
1threat
casting a vector's size() as int does not work : <p>I am learning C++ on the fly and am having problems with vectors so I am writing some programs that use vectors to familiarize myself with them.</p> <p>I was following the advice from this post regarding printing out the value of a vector's size() call:</p> <p><a href="https://stackoverflow.com/questions/31196443/how-can-i-get-the-size-of-an-stdvector-as-an-int">How can I get the size of an std::vector as an int?</a></p> <p>My code is a simple C++ code:</p> <pre><code>#include &lt;vector&gt; int main(int argc, char ** argv) { /* create an int vector of size 10, initialized to 0 */ std::vector&lt;int&gt; int_list[10]; int int_list_size; int_list_size = static_cast&lt;int&gt;(int_list.size()); // &lt;-- compilation error here } // End main() </code></pre> <p>I'm on Ubuntu 16.04 and I get this error:</p> <pre><code>"error: request for member 'size' in 'int_list', which is of non-class type 'std::vector&lt;int&gt; [10]' </code></pre> <p>Since the size of the vector int_list is 10, shouldn't size() return 10, which I can then cast to an int?</p>
0debug
Is there any way to generate sequence diagram from android studio : <p>I have created sample android project. Now i have to create sequence diagram for that. Is there any way to automatically generate sequence diagram for android project from android studio.</p>
0debug
Using @Headers with dynamic values in Feign client + Spring Cloud (Brixton RC2) : <p>Is it possible to set dynamic values to a header ?</p> <pre><code>@FeignClient(name="Simple-Gateway") interface GatewayClient { @Headers("X-Auth-Token: {token}") @RequestMapping(method = RequestMethod.GET, value = "/gateway/test") String getSessionId(@Param("token") String token); } </code></pre> <p>Registering an implementation of RequestInterceptor adds the header but there is no way of setting the header value dynamically</p> <pre><code>@Bean public RequestInterceptor requestInterceptor() { return new RequestInterceptor() { @Override public void apply(RequestTemplate template) { template.header("X-Auth-Token", "some_token"); } }; } </code></pre> <p>I found the following issue on github and one of the commenters (<strong>lpborges</strong>) was trying to do something similar using headers in <code>@RequestMapping</code> annotation.</p> <p><a href="https://github.com/spring-cloud/spring-cloud-netflix/issues/288" rel="noreferrer">https://github.com/spring-cloud/spring-cloud-netflix/issues/288</a></p> <p>Kind Regards</p>
0debug
C# Sort an array by absolute value dose not work as intend with a input array : Sorting arrays by absolute value using a input array refuses to work but replacing it with a simple array works. I have no idea why it wont work, I just dont see whats wrong. I need the result to be like this: Input: -5 4 8 -2 1 Output: 1 -2 4 -5 8 static void Main() { var sampleInput = Console.ReadLine().Split().Select(int.Parse).ToArray(); int[] x = sampleInput; int n = sampleInput.Length; int[] output = new int[n]; string sOutput = string.Empty; int start = 0; int last = n - 1; while (last >= start) { n--; if (Math.Abs(x[start]) > Math.Abs(x[last])) { output[n] = x[start++]; } else { output[n] = x[last--]; } sOutput = output[n].ToString() + " " + sOutput; } Console.Write(sOutput); }
0debug
static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos, int *outFilterSize, int xInc, int srcW, int dstW, int filterAlign, int one, int flags, int cpu_flags, SwsVector *srcFilter, SwsVector *dstFilter, double param[2], int is_horizontal) { int i; int filterSize; int filter2Size; int minFilterSize; int64_t *filter = NULL; int64_t *filter2 = NULL; const int64_t fone = 1LL << 54; int ret = -1; emms_c(); FF_ALLOC_OR_GOTO(NULL, *filterPos, (dstW + 3) * sizeof(**filterPos), fail); if (FFABS(xInc - 0x10000) < 10) { int i; filterSize = 1; FF_ALLOCZ_OR_GOTO(NULL, filter, dstW * sizeof(*filter) * filterSize, fail); for (i = 0; i < dstW; i++) { filter[i * filterSize] = fone; (*filterPos)[i] = i; } } else if (flags & SWS_POINT) { int i; int xDstInSrc; filterSize = 1; FF_ALLOC_OR_GOTO(NULL, filter, dstW * sizeof(*filter) * filterSize, fail); xDstInSrc = xInc / 2 - 0x8000; for (i = 0; i < dstW; i++) { int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16; (*filterPos)[i] = xx; filter[i] = fone; xDstInSrc += xInc; } } else if ((xInc <= (1 << 16) && (flags & SWS_AREA)) || (flags & SWS_FAST_BILINEAR)) { int i; int xDstInSrc; filterSize = 2; FF_ALLOC_OR_GOTO(NULL, filter, dstW * sizeof(*filter) * filterSize, fail); xDstInSrc = xInc / 2 - 0x8000; for (i = 0; i < dstW; i++) { int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16; int j; (*filterPos)[i] = xx; / linear interpolate / area averaging for (j = 0; j < filterSize; j++) { int64_t coeff = fone - FFABS((xx << 16) - xDstInSrc) * (fone >> 16); if (coeff < 0) coeff = 0; filter[i * filterSize + j] = coeff; xx++; } xDstInSrc += xInc; } } else { int64_t xDstInSrc; int sizeFactor; if (flags & SWS_BICUBIC) sizeFactor = 4; else if (flags & SWS_X) sizeFactor = 8; else if (flags & SWS_AREA) sizeFactor = 1; else if (flags & SWS_GAUSS) sizeFactor = 8; else if (flags & SWS_LANCZOS) sizeFactor = param[0] != SWS_PARAM_DEFAULT ? ceil(2 * param[0]) : 6; else if (flags & SWS_SINC) sizeFactor = 20; else if (flags & SWS_SPLINE) sizeFactor = 20; else if (flags & SWS_BILINEAR) sizeFactor = 2; else { sizeFactor = 0; assert(0); } if (xInc <= 1 << 16) filterSize = 1 + sizeFactor; else filterSize = 1 + (sizeFactor * srcW + dstW - 1) / dstW; filterSize = FFMIN(filterSize, srcW - 2); filterSize = FFMAX(filterSize, 1); FF_ALLOC_OR_GOTO(NULL, filter, dstW * sizeof(*filter) * filterSize, fail); xDstInSrc = xInc - 0x10000; for (i = 0; i < dstW; i++) { int xx = (xDstInSrc - ((filterSize - 2) << 16)) / (1 << 17); int j; (*filterPos)[i] = xx; for (j = 0; j < filterSize; j++) { int64_t d = (FFABS(((int64_t)xx << 17) - xDstInSrc)) << 13; double floatd; int64_t coeff; if (xInc > 1 << 16) d = d * dstW / srcW; floatd = d * (1.0 / (1 << 30)); if (flags & SWS_BICUBIC) { int64_t B = (param[0] != SWS_PARAM_DEFAULT ? param[0] : 0) * (1 << 24); int64_t C = (param[1] != SWS_PARAM_DEFAULT ? param[1] : 0.6) * (1 << 24); if (d >= 1LL << 31) { coeff = 0.0; } else { int64_t dd = (d * d) >> 30; int64_t ddd = (dd * d) >> 30; if (d < 1LL << 30) coeff = (12 * (1 << 24) - 9 * B - 6 * C) * ddd + (-18 * (1 << 24) + 12 * B + 6 * C) * dd + (6 * (1 << 24) - 2 * B) * (1 << 30); else coeff = (-B - 6 * C) * ddd + (6 * B + 30 * C) * dd + (-12 * B - 48 * C) * d + (8 * B + 24 * C) * (1 << 30); } coeff *= fone >> (30 + 24); } #if 0 else if (flags & SWS_X) { double p = param ? param * 0.01 : 0.3; coeff = d ? sin(d * M_PI) / (d * M_PI) : 1.0; coeff *= pow(2.0, -p * d * d); } #endif else if (flags & SWS_X) { double A = param[0] != SWS_PARAM_DEFAULT ? param[0] : 1.0; double c; if (floatd < 1.0) c = cos(floatd * M_PI); else c = -1.0; if (c < 0.0) c = -pow(-c, A); else c = pow(c, A); coeff = (c * 0.5 + 0.5) * fone; } else if (flags & SWS_AREA) { int64_t d2 = d - (1 << 29); if (d2 * xInc < -(1LL << (29 + 16))) coeff = 1.0 * (1LL << (30 + 16)); else if (d2 * xInc < (1LL << (29 + 16))) coeff = -d2 * xInc + (1LL << (29 + 16)); else coeff = 0.0; coeff *= fone >> (30 + 16); } else if (flags & SWS_GAUSS) { double p = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0; coeff = (pow(2.0, -p * floatd * floatd)) * fone; } else if (flags & SWS_SINC) { coeff = (d ? sin(floatd * M_PI) / (floatd * M_PI) : 1.0) * fone; } else if (flags & SWS_LANCZOS) { double p = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0; coeff = (d ? sin(floatd * M_PI) * sin(floatd * M_PI / p) / (floatd * floatd * M_PI * M_PI / p) : 1.0) * fone; if (floatd > p) coeff = 0; } else if (flags & SWS_BILINEAR) { coeff = (1 << 30) - d; if (coeff < 0) coeff = 0; coeff *= fone >> 30; } else if (flags & SWS_SPLINE) { double p = -2.196152422706632; coeff = getSplineCoeff(1.0, 0.0, p, -p - 1.0, floatd) * fone; } else { coeff = 0.0; assert(0); } filter[i * filterSize + j] = coeff; xx++; } xDstInSrc += 2 * xInc; } } assert(filterSize > 0); filter2Size = filterSize; if (srcFilter) filter2Size += srcFilter->length - 1; if (dstFilter) filter2Size += dstFilter->length - 1; assert(filter2Size > 0); FF_ALLOCZ_OR_GOTO(NULL, filter2, filter2Size * dstW * sizeof(*filter2), fail); for (i = 0; i < dstW; i++) { int j, k; if (srcFilter) { for (k = 0; k < srcFilter->length; k++) { for (j = 0; j < filterSize; j++) filter2[i * filter2Size + k + j] += srcFilter->coeff[k] * filter[i * filterSize + j]; } } else { for (j = 0; j < filterSize; j++) filter2[i * filter2Size + j] = filter[i * filterSize + j]; } (*filterPos)[i] += (filterSize - 1) / 2 - (filter2Size - 1) / 2; } av_freep(&filter); minFilterSize = 0; for (i = dstW - 1; i >= 0; i--) { int min = filter2Size; int j; int64_t cutOff = 0.0; for (j = 0; j < filter2Size; j++) { int k; cutOff += FFABS(filter2[i * filter2Size]); if (cutOff > SWS_MAX_REDUCE_CUTOFF * fone) break; if (i < dstW - 1 && (*filterPos)[i] >= (*filterPos)[i + 1]) break; for (k = 1; k < filter2Size; k++) filter2[i * filter2Size + k - 1] = filter2[i * filter2Size + k]; filter2[i * filter2Size + k - 1] = 0; (*filterPos)[i]++; } cutOff = 0; for (j = filter2Size - 1; j > 0; j--) { cutOff += FFABS(filter2[i * filter2Size + j]); if (cutOff > SWS_MAX_REDUCE_CUTOFF * fone) break; min--; } if (min > minFilterSize) minFilterSize = min; } if (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC) { if (minFilterSize < 5) filterAlign = 4; if (minFilterSize < 3) filterAlign = 1; } if (INLINE_MMX(cpu_flags)) { if (minFilterSize == 1 && filterAlign == 2) filterAlign = 1; } assert(minFilterSize > 0); filterSize = (minFilterSize + (filterAlign - 1)) & (~(filterAlign - 1)); assert(filterSize > 0); filter = av_malloc(filterSize * dstW * sizeof(*filter)); if (filterSize >= MAX_FILTER_SIZE * 16 / ((flags & SWS_ACCURATE_RND) ? APCK_SIZE : 16) || !filter) goto fail; *outFilterSize = filterSize; if (flags & SWS_PRINT_INFO) av_log(NULL, AV_LOG_VERBOSE, "SwScaler: reducing / aligning filtersize %d -> %d\n", filter2Size, filterSize); for (i = 0; i < dstW; i++) { int j; for (j = 0; j < filterSize; j++) { if (j >= filter2Size) filter[i * filterSize + j] = 0; else filter[i * filterSize + j] = filter2[i * filter2Size + j]; if ((flags & SWS_BITEXACT) && j >= minFilterSize) filter[i * filterSize + j] = 0; } } if (is_horizontal) { for (i = 0; i < dstW; i++) { int j; if ((*filterPos)[i] < 0) { to compensate for filterPos for (j = 1; j < filterSize; j++) { int left = FFMAX(j + (*filterPos)[i], 0); filter[i * filterSize + left] += filter[i * filterSize + j]; filter[i * filterSize + j] = 0; } (*filterPos)[i] = 0; } if ((*filterPos)[i] + filterSize > srcW) { int shift = (*filterPos)[i] + filterSize - srcW; for (j = filterSize - 2; j >= 0; j--) { int right = FFMIN(j + shift, filterSize - 1); filter[i * filterSize + right] += filter[i * filterSize + j]; filter[i * filterSize + j] = 0; } (*filterPos)[i] = srcW - filterSize; } } } FF_ALLOCZ_OR_GOTO(NULL, *outFilter, *outFilterSize * (dstW + 3) * sizeof(int16_t), fail); for (i = 0; i < dstW; i++) { int j; int64_t error = 0; int64_t sum = 0; for (j = 0; j < filterSize; j++) { sum += filter[i * filterSize + j]; } sum = (sum + one / 2) / one; for (j = 0; j < *outFilterSize; j++) { int64_t v = filter[i * filterSize + j] + error; int intV = ROUNDED_DIV(v, sum); (*outFilter)[i * (*outFilterSize) + j] = intV; error = v - intV * sum; } } (*filterPos)[dstW + 0] = (*filterPos)[dstW + 1] = (*filterPos)[dstW + 2] = (*filterPos)[dstW - 1]; for (i = 0; i < *outFilterSize; i++) { int k = (dstW - 1) * (*outFilterSize) + i; (*outFilter)[k + 1 * (*outFilterSize)] = (*outFilter)[k + 2 * (*outFilterSize)] = (*outFilter)[k + 3 * (*outFilterSize)] = (*outFilter)[k]; } ret = 0; fail: av_free(filter); av_free(filter2); return ret; }
1threat
how to Regexp in case of single and double quotes (' and ") : let strTest = ` "The issue": "L'oggetto ", "issue": "oggetto", "issue": 'oggetto "novo" ', `; I'm trying to tokenize a string like the one above: I try with this regexp: let regExp = /["'](.*?)["']\s*?:\s*?['"](.*?)["']/gm; That works fine except in the case where I have a (') inside a (") group or viceversa. Can it be possible to do it in only one regexp sentence? TIA
0debug
Run one file or map in phpunit : <p>I'm using laravel and I've written some test files. But how can I exec only one file? When I do for example: <code>phpunit tests/resulttesting/school/deleteSchoolForRealTest</code> It throws an error:</p> <blockquote> <p>Cannot open file "tests/resulttesting/school/deleteSchoolForRealTest.php".</p> </blockquote> <p>When I run phpunit it runs all my tests. And how can I exec only one folder? I'm on a mac. </p>
0debug
C# datagridview check if checkbox is checked in column : I have datagridview column with checkboxes. I want to check if there is a selected Row in this column. If its not i want to display msgbox. I can check columns by this but im receving multiple msgboxes for every unchecked row. How to change it to receive only one msgbox? Thanks foreach (DataGridViewRow row in dataGridView1.Rows) { DataGridViewCheckBoxCell cell = row.Cells[5] as DataGridViewCheckBoxCell; //We don't want a null exception! if (cell.Value == null) { MessageBox.Show("Nie zaznaczono pola!"); } }
0debug
Enumerable and Enumerator : <p>Enumerable support foreach and enumerator support movenext, current and reset but this question is having single correct answer what will be the answer I am not getting. <a href="https://i.stack.imgur.com/6jTlO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6jTlO.png" alt="enter image description here"></a></p>
0debug
static void dpy_refresh(DisplayState *s) { DisplayChangeListener *dcl; QLIST_FOREACH(dcl, &s->listeners, next) { if (dcl->ops->dpy_refresh) { dcl->ops->dpy_refresh(dcl); } } }
1threat
static always_inline int dv_rl2vlc_size(int run, int l) { int level = (l ^ (l >> 8)) - (l >> 8); int size; if (run < DV_VLC_MAP_RUN_SIZE && level < DV_VLC_MAP_LEV_SIZE) { size = dv_vlc_map[run][level].size; } else { size = (level < DV_VLC_MAP_LEV_SIZE) ? dv_vlc_map[0][level].size : 16; if (run) { size += (run < 16) ? dv_vlc_map[run-1][0].size : 13; } } return size; }
1threat
Linq mapp table to list<int> : I am using c# and Enterprise Library to retrieve data from Store Procedure. I am using Linq to mapp Table to Entity like this. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> List<ActivitySearchEntity> result = db.ExecuteDataSet(dbCommand).Tables[0].AsEnumerable().ToList().ConvertAll(dr => new ActivitySearchEntity { Activity_Id = Convert.ToInt32(dr["Activity_ID"].ToString()), User_id = Convert.ToInt32(dr["User_ID"].ToString()) }); <!-- end snippet --> It Works fine... when I mapp to entity it works fine, what I need is to mapp to al List<int> List<ActivitySearchEntity> result = db.ExecuteDataSet(dbCommand).Tables[0].AsEnumerable().ToList<int>() or somethig like this.. but it does not work. How can I mapp to an `List<int>`
0debug
trying to insert image into my data base all the time saving the same thing? : While i am trying to insert image into my data base it all the time saves this: > 0xFFD8FFE145AB4578696600004D4D002A00000008000A011200030000000100000000021300030000000100010000011A0005000000010000018E011B0005000000010000019601280003000000010002000001320002000000140000019E010F000200000064000001B201100002000000640000021687690004000000010000 even if the image is null plss helpppp the c#: if (FileUpload1.PostedFile.FileName!="") { Byte[] image; Stream s = FileUpload1.PostedFile.InputStream; BinaryReader br = new BinaryReader(s); image = br.ReadBytes((Int32)s.Length); SqlCommand NewUser = new SqlCommand("INSERT INTO [User] Values (@username,@password,@name,@lastname,@location,@profesion,@email,@gender,@money,@pro,@xp,@lv,@m1,@m2,@m3,@m4,@m5,@d1,@d2,@d3,@d4,@d5,@im,@phone);", c); NewUser.Connection = c; NewUser.Parameters.AddWithValue("@username", txtuser.Text); NewUser.Parameters.AddWithValue("@password", txtpass.Text); NewUser.Parameters.AddWithValue("@name", txtFName.Text); NewUser.Parameters.AddWithValue("@lastname", txtLName.Text); NewUser.Parameters.AddWithValue("@location", ddlcountry.SelectedItem.Text); NewUser.Parameters.AddWithValue("@profesion", txtprofession.Text); NewUser.Parameters.AddWithValue("@email", txtemail.Text); NewUser.Parameters.AddWithValue("@gender", rbgendere.SelectedItem.Text); NewUser.Parameters.AddWithValue("@money", 0); NewUser.Parameters.AddWithValue("@pro", DBNull.Value); NewUser.Parameters.AddWithValue("@xp", 0); NewUser.Parameters.AddWithValue("@lv", 1); NewUser.Parameters.AddWithValue("@m1", 0); NewUser.Parameters.AddWithValue("@m2", 0); NewUser.Parameters.AddWithValue("@m3", 0); NewUser.Parameters.AddWithValue("@m4", 0); NewUser.Parameters.AddWithValue("@m5", 0); NewUser.Parameters.AddWithValue("@d1", 0); NewUser.Parameters.AddWithValue("@d2", 0); NewUser.Parameters.AddWithValue("@d3", 0); NewUser.Parameters.AddWithValue("@d4", 0); NewUser.Parameters.AddWithValue("@d5", 0); NewUser.Parameters.AddWithValue("@im", image); NewUser.Parameters.AddWithValue("@phone", PhoneNumber.Text); Session["CurentUserid"] = txtuser.Text; c.Open(); int row=NewUser.ExecuteNonQuery(); c.Close(); if (row>0) { LabelError.Text = "success"; } Session["Conect"] = (bool)true; Response.Redirect("Finish Had Member.aspx", true); } else { SqlCommand NewUser = new SqlCommand("INSERT INTO [User] Values (@username,@password,@name,@lastname,@location,@profesion,@email,@gender,@money,@pro,@xp,@lv,@m1,@m2,@m3,@m4,@m5,@d1,@d2,@d3,@d4,@d5,@im,@phone);", c); NewUser.Connection = c; NewUser.Parameters.AddWithValue("@username", txtuser.Text); NewUser.Parameters.AddWithValue("@password", txtpass.Text); NewUser.Parameters.AddWithValue("@name", txtFName.Text); NewUser.Parameters.AddWithValue("@lastname", txtLName.Text); NewUser.Parameters.AddWithValue("@location", ddlcountry.SelectedItem.Text); NewUser.Parameters.AddWithValue("@profesion", txtprofession.Text); NewUser.Parameters.AddWithValue("@email", txtemail.Text); NewUser.Parameters.AddWithValue("@gender", rbgendere.SelectedItem.Text); NewUser.Parameters.AddWithValue("@money", 0); NewUser.Parameters.AddWithValue("@pro", DBNull.Value); NewUser.Parameters.AddWithValue("@xp", 0); NewUser.Parameters.AddWithValue("@lv", 1); NewUser.Parameters.AddWithValue("@m1", 0); NewUser.Parameters.AddWithValue("@m2", 0); NewUser.Parameters.AddWithValue("@m3", 0); NewUser.Parameters.AddWithValue("@m4", 0); NewUser.Parameters.AddWithValue("@m5", 0); NewUser.Parameters.AddWithValue("@d1", 0); NewUser.Parameters.AddWithValue("@d2", 0); NewUser.Parameters.AddWithValue("@d3", 0); NewUser.Parameters.AddWithValue("@d4", 0); NewUser.Parameters.AddWithValue("@d5", 0); NewUser.Parameters.AddWithValue("@im", DBNull.Value); NewUser.Parameters.AddWithValue("@phone", PhoneNumber.Text); Session["CurentUserid"] = txtuser.Text; c.Open(); NewUser.ExecuteNonQuery(); c.Close(); Session["Conect"] = (bool)true; Response.Redirect("Finish Had Member.aspx", true); }
0debug
av_cold void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx) { c->clear_block = clear_block_8_c; c->clear_blocks = clear_blocks_8_c; c->fill_block_tab[0] = fill_block16_c; c->fill_block_tab[1] = fill_block8_c; if (ARCH_ARM) ff_blockdsp_init_arm(c); if (ARCH_PPC) ff_blockdsp_init_ppc(c); if (ARCH_X86) #if FF_API_XVMC ff_blockdsp_init_x86(c, avctx); #else ff_blockdsp_init_x86(c); #endif }
1threat
PHP Accessing nested json elements in square brackets : <p>I am trying to access the amount property in the below json file. </p> <pre><code>{ "id": "evt_1EQZxID5bcg", "data": { "object": { "id": "cs_0G452PD7eY8ddrtuyo0KZ5sSRk", "display_items": [ { "amount": 300, "currency": "gbp", "custom": { "name": "Purchase" }, "type": "custom" } ], "livemode": false, "payment_method_types": [ "card" ], "subscription": null, "success_url": "" } }, "livemode": false, "request": { "idempotency_key": null }, "type": "checkout.session.completed" } </code></pre> <p>I have tried using this code to access the peroperty</p> <pre><code>$object-&gt;data-&gt;object-&gt;display_items-&gt;amount </code></pre> <p>However, this returns no data.</p> <p>I am thinking this has to do with the square brackets, but when I try access that alone I get an array.</p>
0debug
static void do_audio_out(AVFormatContext *s, AVOutputStream *ost, AVInputStream *ist, unsigned char *buf, int size) { uint8_t *buftmp; uint8_t audio_buf[2*MAX_AUDIO_PACKET_SIZE]; uint8_t audio_out[4*MAX_AUDIO_PACKET_SIZE]; int size_out, frame_bytes, ret; AVCodecContext *enc; enc = &ost->st->codec; if (ost->audio_resample) { buftmp = audio_buf; size_out = audio_resample(ost->resample, (short *)buftmp, (short *)buf, size / (ist->st->codec.channels * 2)); size_out = size_out * enc->channels * 2; } else { buftmp = buf; size_out = size; } if (enc->frame_size > 1) { fifo_write(&ost->fifo, buftmp, size_out, &ost->fifo.wptr); frame_bytes = enc->frame_size * 2 * enc->channels; while (fifo_read(&ost->fifo, audio_buf, frame_bytes, &ost->fifo.rptr) == 0) { ret = avcodec_encode_audio(enc, audio_out, sizeof(audio_out), (short *)audio_buf); av_write_frame(s, ost->index, audio_out, ret); } } else { switch(enc->codec->id) { case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_U16BE: break; default: size_out = size_out >> 1; break; } ret = avcodec_encode_audio(enc, audio_out, size_out, (short *)buftmp); av_write_frame(s, ost->index, audio_out, ret); } }
1threat
error: This is probably not a problem with npm. There is likely additional logging output above : <p>In my project, I'm using Angular6 for the frontend. Now what I'm trying to do is deploy my project which is in remote server into the actual server. I'm using <code>npm run build -prod</code> command to build the frontend first. But I can't build my project since the following error occurs again and again,</p> <pre><code>npm ERR! code ELIFECYCLE npm ERR! errno 134 npm ERR! Trackit-Revamp@6.0.0 build: `ng build --prod --build-optimizer --aot` npm ERR! Exit status 134 npm ERR! npm ERR! Failed at the Trackit-Revamp@6.0.0 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Indrajith.E\AppData\Roaming\npm-cache\_logs\2019-08-22T08_41_00_271Z-debug.log </code></pre> <p>My error log in the <code>C:\Users\Indrajith.E\AppData\Roaming\npm-cache\_logs\2019-08-22T08_41_00_271Z-debug.log</code> file path contains the same error details mentioned above.</p> <p>How can I resolve this problem?</p>
0debug
What is wrong with my Java? (Icon is not triggering the function.) : Okay so this is basically exactly the code from https://www.w3schools.com/howto/howto_js_topnav_responsive.asp I have everything working except for some reason I cannot get the hamburger icon to load the other menu links when clicked... I've tried everything and have stared at it till my eyes are square, any suggestions would be greatly appreciated. My HTML: <body style= margin:20%;> <link rel="stylesheet" type="text/css" href="PeterPanStyle.css"> <div class="topnav" id="myTopnav"> <a href="Cover.html">Home</a> <a href="About.html"> About</a> <a href="XContents.html"> Contents</a> <a href="#">Glossary </a> <a href="#">Quiz! </a> <a href="javascript:void(0);" class="icon" onclick="myFunction()">&#9776;</a> </div> <script> function myFunction() { var x = document.getElementById("myTopnav"); if (x.className === "topnav") { x.className += "responsive"; } else { x.className = "topnav"; } </script> My CSS: .topnav { overflow: hidden; background-color: #333; } .topnav a { float: left; display: block; color: #f2f2f2; text-align: center; padding: 14px 16px; text-decoration: none; font-size: 17px; } .topnav a:hover { background-color: #ddd; color: black; } .topnav .icon { display: none; } @media screen and (max-width: 600px) { .topnav a:not(:first-child) {display: none;} .topnav a.icon { float: right; display: block; } } @media screen and (max-width: 600px) { .topnav.responsive {position: relative;} .topnav.responsive .icon { position: absolute; right: 0; top: 0; } .topnav.responsive a { float: none; display: block; text-align: left; } }
0debug
static void hScale16_c(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *_src, const int16_t *filter, const int16_t *filterPos, int filterSize) { int i; int32_t *dst = (int32_t *) _dst; const uint16_t *src = (const uint16_t *) _src; int bits = av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1; int sh = (bits <= 7) ? 11 : (bits - 4); for (i = 0; i < dstW; i++) { int j; int srcPos = filterPos[i]; unsigned int val = 0; for (j = 0; j < filterSize; j++) { val += src[srcPos + j] * filter[filterSize * i + j]; } dst[i] = FFMIN(val >> sh, (1 << 19) - 1); } }
1threat
static uint64_t xilinx_spips_read(void *opaque, hwaddr addr, unsigned size) { XilinxSPIPS *s = opaque; uint32_t mask = ~0; uint32_t ret; addr >>= 2; switch (addr) { case R_CONFIG: mask = 0x0002FFFF; break; case R_INTR_STATUS: ret = s->regs[addr] & IXR_ALL; s->regs[addr] = 0; DB_PRINT("addr=" TARGET_FMT_plx " = %x\n", addr * 4, ret); return ret; case R_INTR_MASK: mask = IXR_ALL; break; case R_EN: mask = 0x1; break; case R_SLAVE_IDLE_COUNT: mask = 0xFF; break; case R_MOD_ID: mask = 0x01FFFFFF; break; case R_INTR_EN: case R_INTR_DIS: case R_TX_DATA: mask = 0; break; case R_RX_DATA: rx_data_bytes(s, &ret, s->num_txrx_bytes); DB_PRINT("addr=" TARGET_FMT_plx " = %x\n", addr * 4, ret); xilinx_spips_update_ixr(s); return ret; } DB_PRINT("addr=" TARGET_FMT_plx " = %x\n", addr * 4, s->regs[addr] & mask); return s->regs[addr] & mask; }
1threat
static int wavpack_encode_block(WavPackEncodeContext *s, int32_t *samples_l, int32_t *samples_r, uint8_t *out, int out_size) { int block_size, start, end, data_size, tcount, temp, m = 0; int i, j, ret = 0, got_extra = 0, nb_samples = s->block_samples; uint32_t crc = 0xffffffffu; struct Decorr *dpp; PutByteContext pb; if (!(s->flags & WV_MONO) && s->optimize_mono) { int32_t lor = 0, diff = 0; for (i = 0; i < nb_samples; i++) { lor |= samples_l[i] | samples_r[i]; diff |= samples_l[i] - samples_r[i]; if (lor && diff) break; } if (i == nb_samples && lor && !diff) { s->flags &= ~(WV_JOINT_STEREO | WV_CROSS_DECORR); s->flags |= WV_FALSE_STEREO; if (!s->false_stereo) { s->false_stereo = 1; s->num_terms = 0; CLEAR(s->w); } } else if (s->false_stereo) { s->false_stereo = 0; s->num_terms = 0; CLEAR(s->w); } } if (s->flags & SHIFT_MASK) { int shift = (s->flags & SHIFT_MASK) >> SHIFT_LSB; int mag = (s->flags & MAG_MASK) >> MAG_LSB; if (s->flags & WV_MONO_DATA) shift_mono(samples_l, nb_samples, shift); else shift_stereo(samples_l, samples_r, nb_samples, shift); if ((mag -= shift) < 0) s->flags &= ~MAG_MASK; else s->flags -= (1 << MAG_LSB) * shift; } if ((s->flags & WV_FLOAT_DATA) || (s->flags & MAG_MASK) >> MAG_LSB >= 24) { av_fast_padded_malloc(&s->orig_l, &s->orig_l_size, sizeof(int32_t) * nb_samples); memcpy(s->orig_l, samples_l, sizeof(int32_t) * nb_samples); if (!(s->flags & WV_MONO_DATA)) { av_fast_padded_malloc(&s->orig_r, &s->orig_r_size, sizeof(int32_t) * nb_samples); memcpy(s->orig_r, samples_r, sizeof(int32_t) * nb_samples); } if (s->flags & WV_FLOAT_DATA) got_extra = scan_float(s, samples_l, samples_r, nb_samples); else got_extra = scan_int32(s, samples_l, samples_r, nb_samples); s->num_terms = 0; } else { scan_int23(s, samples_l, samples_r, nb_samples); if (s->shift != s->int32_zeros + s->int32_ones + s->int32_dups) { s->shift = s->int32_zeros + s->int32_ones + s->int32_dups; s->num_terms = 0; } } if (!s->num_passes && !s->num_terms) { s->num_passes = 1; if (s->flags & WV_MONO_DATA) ret = wv_mono(s, samples_l, 1, 0); else ret = wv_stereo(s, samples_l, samples_r, 1, 0); s->num_passes = 0; } if (s->flags & WV_MONO_DATA) { for (i = 0; i < nb_samples; i++) crc += (crc << 1) + samples_l[i]; if (s->num_passes) ret = wv_mono(s, samples_l, !s->num_terms, 1); } else { for (i = 0; i < nb_samples; i++) crc += (crc << 3) + (samples_l[i] << 1) + samples_l[i] + samples_r[i]; if (s->num_passes) ret = wv_stereo(s, samples_l, samples_r, !s->num_terms, 1); } if (ret < 0) return ret; if (!s->ch_offset) s->flags |= WV_INITIAL_BLOCK; s->ch_offset += 1 + !(s->flags & WV_MONO); if (s->ch_offset == s->avctx->channels) s->flags |= WV_FINAL_BLOCK; bytestream2_init_writer(&pb, out, out_size); bytestream2_put_le32(&pb, MKTAG('w', 'v', 'p', 'k')); bytestream2_put_le32(&pb, 0); bytestream2_put_le16(&pb, 0x410); bytestream2_put_le16(&pb, 0); bytestream2_put_le32(&pb, 0); bytestream2_put_le32(&pb, s->sample_index); bytestream2_put_le32(&pb, nb_samples); bytestream2_put_le32(&pb, s->flags); bytestream2_put_le32(&pb, crc); if (s->flags & WV_INITIAL_BLOCK && s->avctx->channel_layout != AV_CH_LAYOUT_MONO && s->avctx->channel_layout != AV_CH_LAYOUT_STEREO) { put_metadata_block(&pb, WP_ID_CHANINFO, 5); bytestream2_put_byte(&pb, s->avctx->channels); bytestream2_put_le32(&pb, s->avctx->channel_layout); bytestream2_put_byte(&pb, 0); } if ((s->flags & SRATE_MASK) == SRATE_MASK) { put_metadata_block(&pb, WP_ID_SAMPLE_RATE, 3); bytestream2_put_le24(&pb, s->avctx->sample_rate); bytestream2_put_byte(&pb, 0); } put_metadata_block(&pb, WP_ID_DECTERMS, s->num_terms); for (i = 0; i < s->num_terms; i++) { struct Decorr *dpp = &s->decorr_passes[i]; bytestream2_put_byte(&pb, ((dpp->value + 5) & 0x1f) | ((dpp->delta << 5) & 0xe0)); } if (s->num_terms & 1) bytestream2_put_byte(&pb, 0); #define WRITE_DECWEIGHT(type) do { \ temp = store_weight(type); \ bytestream2_put_byte(&pb, temp); \ type = restore_weight(temp); \ } while (0) bytestream2_put_byte(&pb, WP_ID_DECWEIGHTS); bytestream2_put_byte(&pb, 0); start = bytestream2_tell_p(&pb); for (i = s->num_terms - 1; i >= 0; --i) { struct Decorr *dpp = &s->decorr_passes[i]; if (store_weight(dpp->weightA) || (!(s->flags & WV_MONO_DATA) && store_weight(dpp->weightB))) break; } tcount = i + 1; for (i = 0; i < s->num_terms; i++) { struct Decorr *dpp = &s->decorr_passes[i]; if (i < tcount) { WRITE_DECWEIGHT(dpp->weightA); if (!(s->flags & WV_MONO_DATA)) WRITE_DECWEIGHT(dpp->weightB); } else { dpp->weightA = dpp->weightB = 0; } } end = bytestream2_tell_p(&pb); out[start - 2] = WP_ID_DECWEIGHTS | (((end - start) & 1) ? WP_IDF_ODD: 0); out[start - 1] = (end - start + 1) >> 1; if ((end - start) & 1) bytestream2_put_byte(&pb, 0); #define WRITE_DECSAMPLE(type) do { \ temp = log2s(type); \ type = wp_exp2(temp); \ bytestream2_put_le16(&pb, temp); \ } while (0) bytestream2_put_byte(&pb, WP_ID_DECSAMPLES); bytestream2_put_byte(&pb, 0); start = bytestream2_tell_p(&pb); for (i = 0; i < s->num_terms; i++) { struct Decorr *dpp = &s->decorr_passes[i]; if (i == 0) { if (dpp->value > MAX_TERM) { WRITE_DECSAMPLE(dpp->samplesA[0]); WRITE_DECSAMPLE(dpp->samplesA[1]); if (!(s->flags & WV_MONO_DATA)) { WRITE_DECSAMPLE(dpp->samplesB[0]); WRITE_DECSAMPLE(dpp->samplesB[1]); } } else if (dpp->value < 0) { WRITE_DECSAMPLE(dpp->samplesA[0]); WRITE_DECSAMPLE(dpp->samplesB[0]); } else { for (j = 0; j < dpp->value; j++) { WRITE_DECSAMPLE(dpp->samplesA[j]); if (!(s->flags & WV_MONO_DATA)) WRITE_DECSAMPLE(dpp->samplesB[j]); } } } else { CLEAR(dpp->samplesA); CLEAR(dpp->samplesB); } } end = bytestream2_tell_p(&pb); out[start - 1] = (end - start) >> 1; #define WRITE_CHAN_ENTROPY(chan) do { \ for (i = 0; i < 3; i++) { \ temp = wp_log2(s->w.c[chan].median[i]); \ bytestream2_put_le16(&pb, temp); \ s->w.c[chan].median[i] = wp_exp2(temp); \ } \ } while (0) put_metadata_block(&pb, WP_ID_ENTROPY, 6 * (1 + (!(s->flags & WV_MONO_DATA)))); WRITE_CHAN_ENTROPY(0); if (!(s->flags & WV_MONO_DATA)) WRITE_CHAN_ENTROPY(1); if (s->flags & WV_FLOAT_DATA) { put_metadata_block(&pb, WP_ID_FLOATINFO, 4); bytestream2_put_byte(&pb, s->float_flags); bytestream2_put_byte(&pb, s->float_shift); bytestream2_put_byte(&pb, s->float_max_exp); bytestream2_put_byte(&pb, 127); } if (s->flags & WV_INT32_DATA) { put_metadata_block(&pb, WP_ID_INT32INFO, 4); bytestream2_put_byte(&pb, s->int32_sent_bits); bytestream2_put_byte(&pb, s->int32_zeros); bytestream2_put_byte(&pb, s->int32_ones); bytestream2_put_byte(&pb, s->int32_dups); } if (s->flags & WV_MONO_DATA && !s->num_passes) { for (i = 0; i < nb_samples; i++) { int32_t code = samples_l[i]; for (tcount = s->num_terms, dpp = s->decorr_passes; tcount--; dpp++) { int32_t sam; if (dpp->value > MAX_TERM) { if (dpp->value & 1) sam = 2 * dpp->samplesA[0] - dpp->samplesA[1]; else sam = (3 * dpp->samplesA[0] - dpp->samplesA[1]) >> 1; dpp->samplesA[1] = dpp->samplesA[0]; dpp->samplesA[0] = code; } else { sam = dpp->samplesA[m]; dpp->samplesA[(m + dpp->value) & (MAX_TERM - 1)] = code; } code -= APPLY_WEIGHT(dpp->weightA, sam); UPDATE_WEIGHT(dpp->weightA, dpp->delta, sam, code); } m = (m + 1) & (MAX_TERM - 1); samples_l[i] = code; } if (m) { for (tcount = s->num_terms, dpp = s->decorr_passes; tcount--; dpp++) if (dpp->value > 0 && dpp->value <= MAX_TERM) { int32_t temp_A[MAX_TERM], temp_B[MAX_TERM]; int k; memcpy(temp_A, dpp->samplesA, sizeof(dpp->samplesA)); memcpy(temp_B, dpp->samplesB, sizeof(dpp->samplesB)); for (k = 0; k < MAX_TERM; k++) { dpp->samplesA[k] = temp_A[m]; dpp->samplesB[k] = temp_B[m]; m = (m + 1) & (MAX_TERM - 1); } } } } else if (!s->num_passes) { if (s->flags & WV_JOINT_STEREO) { for (i = 0; i < nb_samples; i++) samples_r[i] += ((samples_l[i] -= samples_r[i]) >> 1); } for (i = 0; i < s->num_terms; i++) { struct Decorr *dpp = &s->decorr_passes[i]; if (((s->flags & MAG_MASK) >> MAG_LSB) >= 16 || dpp->delta != 2) decorr_stereo_pass2(dpp, samples_l, samples_r, nb_samples); else decorr_stereo_pass_id2(dpp, samples_l, samples_r, nb_samples); } } bytestream2_put_byte(&pb, WP_ID_DATA | WP_IDF_LONG); init_put_bits(&s->pb, pb.buffer + 3, bytestream2_get_bytes_left_p(&pb)); if (s->flags & WV_MONO_DATA) { for (i = 0; i < nb_samples; i++) wavpack_encode_sample(s, &s->w.c[0], s->samples[0][i]); } else { for (i = 0; i < nb_samples; i++) { wavpack_encode_sample(s, &s->w.c[0], s->samples[0][i]); wavpack_encode_sample(s, &s->w.c[1], s->samples[1][i]); } } encode_flush(s); flush_put_bits(&s->pb); data_size = put_bits_count(&s->pb) >> 3; bytestream2_put_le24(&pb, (data_size + 1) >> 1); bytestream2_skip_p(&pb, data_size); if (data_size & 1) bytestream2_put_byte(&pb, 0); if (got_extra) { bytestream2_put_byte(&pb, WP_ID_EXTRABITS | WP_IDF_LONG); init_put_bits(&s->pb, pb.buffer + 7, bytestream2_get_bytes_left_p(&pb)); if (s->flags & WV_FLOAT_DATA) pack_float(s, s->orig_l, s->orig_r, nb_samples); else pack_int32(s, s->orig_l, s->orig_r, nb_samples); flush_put_bits(&s->pb); data_size = put_bits_count(&s->pb) >> 3; bytestream2_put_le24(&pb, (data_size + 5) >> 1); bytestream2_put_le32(&pb, s->crc_x); bytestream2_skip_p(&pb, data_size); if (data_size & 1) bytestream2_put_byte(&pb, 0); } block_size = bytestream2_tell_p(&pb); AV_WL32(out + 4, block_size - 8); av_assert0(put_bits_left(&s->pb) > 0); return block_size; }
1threat
Xcode 11.4 Circular Reference errors : <p>When compiling project on Xcode 11.4 (on previous Xcode project is building fine) I get following 999+ errors (Did clean build and deleted derived data):</p> <pre><code>&lt;unknown&gt;:0: error: circular reference &lt;unknown&gt;:0: error: circular reference &lt;unknown&gt;:0: note: through reference here &lt;unknown&gt;:0: error: circular reference &lt;unknown&gt;:0: error: circular reference &lt;unknown&gt;:0: note: through reference here &lt;unknown&gt;:0: note: through reference here &lt;unknown&gt;:0: error: circular reference &lt;unknown&gt;:0: note: through reference here &lt;unknown&gt;:0: error: circular reference &lt;unknown&gt;:0: error: circular reference &lt;unknown&gt;:0: note: through reference here </code></pre> <p>Is this a problem with Xcode 11.4? Is it possible to disable <code>circular reference</code> checking option when compiling a project?.</p>
0debug
Pass interface between activities in intent - interface fails to be Serializable or Parcelable : <p>I want to pass an interface from 1st activity to 2nd activity.</p> <p>I want to initiate methods from the interface from the 2nd activity which will affect the 1st activity.</p> <p><strong>I'm well aware that it's very overkilling not using the <a href="https://developer.android.com/training/basics/intents/result.html" rel="noreferrer">onActivityResult</a> mechanism, and that it might not be good programming, but roll with me please.</strong> </p> <p>Here's the issue - my interface can't implement <a href="https://docs.oracle.com/javase/7/docs/api/java/io/Serializable.html" rel="noreferrer">Serializable</a> / <a href="https://developer.android.com/reference/android/os/Parcelable.html" rel="noreferrer">Parcelable</a> since interface can't implement another class.</p> <p>This is my interface : </p> <pre><code>public interface ITest { void onSuccess(String text); } </code></pre> <p>But, i can't start my activity with this interface since it's not <a href="https://developer.android.com/reference/android/os/Parcelable.html" rel="noreferrer">Parcelable</a>. </p> <pre><code>intent.putExtra("testInterface", new ITest() { @Override void onSuccess(String text) { } } </code></pre> <p>Obviously, i receive a compilation error : <code>Cannot resolve method 'putExtra(java.lang.String, ITest)'</code></p>
0debug
Visual Basic How to make a button that can only be clicked once : In visual basic I'm trying to make a button that can only be clicked once, I want to be able to see the button, its just I want it so you can only click it once. ----------------------------------------------- This is my code so far: Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) End Sub End Class ----------------------------------------------------- So if you can help that would be awesome! Thanks.
0debug
Code Required to achieve vertical slider effect in Wordpress (examples included) : <p>I'm wondering how I can achieve an effect similar to that of <a href="http://eng.getlost-getnatural.ru/" rel="nofollow">http://eng.getlost-getnatural.ru/</a> or <a href="http://rnbtheme.com/sixteenth/" rel="nofollow">http://rnbtheme.com/sixteenth/</a>. I've contacted various support forums supplied through Wordpress and all they've been able to tell me is that I need to get a web developer and that the effect was possible. I, however, don't have the money for a web developer and went searching online to try to find what I was looking for and haven't been able to find anything yet. I can make code changes to my Wordpress site using javascript or css. Thank you so much to everyone who helps and answers!</p>
0debug
Adjust size of leaflet map in rmarkdown html : <p>I'd like to change the height and width of <code>leaflet</code> map outputs in html document. Is there a simple way to do this in R markdown without getting into whole CSS business?</p> <pre><code>```{r} library(leaflet) library(dplyr) m &lt;- leaflet() %&gt;% setView(lng = -71.0589, lat = 42.3601, zoom = 12) m %&gt;% addTiles() ``` </code></pre> <p>Ideally, I want the width of map to be the same width of code block as shown below.</p> <p><a href="https://i.stack.imgur.com/NzgJE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NzgJE.png" alt="enter image description here"></a></p>
0debug
how to download source version of a package : <p>How can I download the source version of an R package so I can see the source code . Let's say I'd like to see the code of the quantreg pacakge.</p> <p>Thank you.</p>
0debug
static int set_string_number(void *obj, void *target_obj, const AVOption *o, const char *val, void *dst) { int ret = 0; int num, den; char c; if (sscanf(val, "%d%*1[:/]%d%c", &num, &den, &c) == 2) { if ((ret = write_number(obj, o, dst, 1, den, num)) >= 0) return ret; ret = 0; } for (;;) { int i = 0; char buf[256]; int cmd = 0; double d; int64_t intnum = 1; if (o->type == AV_OPT_TYPE_FLAGS) { if (*val == '+' || *val == '-') cmd = *(val++); for (; i < sizeof(buf) - 1 && val[i] && val[i] != '+' && val[i] != '-'; i++) buf[i] = val[i]; buf[i] = 0; } { const AVOption *o_named = av_opt_find(target_obj, buf, o->unit, 0, 0); int res; int ci = 0; double const_values[64]; const char * const_names[64]; if (o_named && o_named->type == AV_OPT_TYPE_CONST) d = DEFAULT_NUMVAL(o_named); else { if (o->unit) { for (o_named = NULL; o_named = av_opt_next(target_obj, o_named); ) { if (o_named->type == AV_OPT_TYPE_CONST && o_named->unit && !strcmp(o_named->unit, o->unit)) { if (ci + 6 >= FF_ARRAY_ELEMS(const_values)) { av_log(obj, AV_LOG_ERROR, "const_values array too small for %s\n", o->unit); return AVERROR_PATCHWELCOME; } const_names [ci ] = o_named->name; const_values[ci++] = DEFAULT_NUMVAL(o_named); } } } const_names [ci ] = "default"; const_values[ci++] = DEFAULT_NUMVAL(o); const_names [ci ] = "max"; const_values[ci++] = o->max; const_names [ci ] = "min"; const_values[ci++] = o->min; const_names [ci ] = "none"; const_values[ci++] = 0; const_names [ci ] = "all"; const_values[ci++] = ~0; const_names [ci] = NULL; const_values[ci] = 0; res = av_expr_parse_and_eval(&d, i ? buf : val, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, obj); if (res < 0) { av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\"\n", val); return res; } } } if (o->type == AV_OPT_TYPE_FLAGS) { read_number(o, dst, NULL, NULL, &intnum); if (cmd == '+') d = intnum | (int64_t)d; else if (cmd == '-') d = intnum &~(int64_t)d; } if ((ret = write_number(obj, o, dst, d, 1, 1)) < 0) return ret; val += i; if (!i || !*val) return 0; } return 0; }
1threat
static int dca_parse_params(DCAParseContext *pc1, const uint8_t *buf, int buf_size, int *duration, int *sample_rate, int *profile) { DCAExssAsset *asset = &pc1->exss.assets[0]; GetBitContext gb; DCACoreFrameHeader h; uint8_t hdr[DCA_CORE_FRAME_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 }; int ret, frame_size; if (buf_size < DCA_CORE_FRAME_HEADER_SIZE) return AVERROR_INVALIDDATA; if (AV_RB32(buf) == DCA_SYNCWORD_SUBSTREAM) { if ((ret = ff_dca_exss_parse(&pc1->exss, buf, buf_size)) < 0) return ret; if (asset->extension_mask & DCA_EXSS_LBR) { if ((ret = init_get_bits8(&gb, buf + asset->lbr_offset, asset->lbr_size)) < 0) return ret; if (get_bits_long(&gb, 32) != DCA_SYNCWORD_LBR) return AVERROR_INVALIDDATA; switch (get_bits(&gb, 8)) { case DCA_LBR_HEADER_DECODER_INIT: pc1->sr_code = get_bits(&gb, 8); case DCA_LBR_HEADER_SYNC_ONLY: break; default: return AVERROR_INVALIDDATA; } if (pc1->sr_code >= FF_ARRAY_ELEMS(ff_dca_sampling_freqs)) return AVERROR_INVALIDDATA; *sample_rate = ff_dca_sampling_freqs[pc1->sr_code]; *duration = 1024 << ff_dca_freq_ranges[pc1->sr_code]; *profile = FF_PROFILE_DTS_EXPRESS; return 0; } if (asset->extension_mask & DCA_EXSS_XLL) { int nsamples_log2; if ((ret = init_get_bits8(&gb, buf + asset->xll_offset, asset->xll_size)) < 0) return ret; if (get_bits_long(&gb, 32) != DCA_SYNCWORD_XLL) return AVERROR_INVALIDDATA; if (get_bits(&gb, 4)) return AVERROR_INVALIDDATA; skip_bits(&gb, 8); skip_bits_long(&gb, get_bits(&gb, 5) + 1); skip_bits(&gb, 4); nsamples_log2 = get_bits(&gb, 4) + get_bits(&gb, 4); if (nsamples_log2 > 24) return AVERROR_INVALIDDATA; *sample_rate = asset->max_sample_rate; *duration = (1 + (*sample_rate > 96000)) << nsamples_log2; *profile = FF_PROFILE_DTS_HD_MA; return 0; } return AVERROR_INVALIDDATA; } if ((ret = avpriv_dca_convert_bitstream(buf, DCA_CORE_FRAME_HEADER_SIZE, hdr, DCA_CORE_FRAME_HEADER_SIZE)) < 0) return ret; if ((ret = init_get_bits8(&gb, hdr, ret)) < 0) return ret; if (avpriv_dca_parse_core_frame_header(&gb, &h) < 0) return AVERROR_INVALIDDATA; *duration = h.npcmblocks * DCA_PCMBLOCK_SAMPLES; *sample_rate = avpriv_dca_sample_rates[h.sr_code]; if (*profile != FF_PROFILE_UNKNOWN) return 0; *profile = FF_PROFILE_DTS; if (h.ext_audio_present) { switch (h.ext_audio_type) { case DCA_EXT_AUDIO_XCH: case DCA_EXT_AUDIO_XXCH: *profile = FF_PROFILE_DTS_ES; break; case DCA_EXT_AUDIO_X96: *profile = FF_PROFILE_DTS_96_24; break; } } frame_size = FFALIGN(h.frame_size, 4); if (buf_size - 4 < frame_size) return 0; buf += frame_size; buf_size -= frame_size; if (AV_RB32(buf) != DCA_SYNCWORD_SUBSTREAM) return 0; if (ff_dca_exss_parse(&pc1->exss, buf, buf_size) < 0) return 0; if (asset->extension_mask & DCA_EXSS_XLL) *profile = FF_PROFILE_DTS_HD_MA; else if (asset->extension_mask & (DCA_EXSS_XBR | DCA_EXSS_XXCH | DCA_EXSS_X96)) *profile = FF_PROFILE_DTS_HD_HRA; return 0; }
1threat
static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_t *pkt_pts, int64_t *pkt_dts) { AVFrame *decoded_frame, *filtered_frame = NULL; void *buffer_to_free = NULL; int i, ret = 0; float quality = 0; #if CONFIG_AVFILTER int frame_available = 1; #endif int duration=0; int64_t *best_effort_timestamp; AVRational *frame_sample_aspect; if (!ist->decoded_frame && !(ist->decoded_frame = avcodec_alloc_frame())) return AVERROR(ENOMEM); else avcodec_get_frame_defaults(ist->decoded_frame); decoded_frame = ist->decoded_frame; pkt->pts = *pkt_pts; pkt->dts = *pkt_dts; *pkt_pts = AV_NOPTS_VALUE; if (pkt->duration) { duration = av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q); } else if(ist->st->codec->time_base.num != 0) { int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame; duration = ((int64_t)AV_TIME_BASE * ist->st->codec->time_base.num * ticks) / ist->st->codec->time_base.den; } if(*pkt_dts != AV_NOPTS_VALUE && duration) { *pkt_dts += duration; }else *pkt_dts = AV_NOPTS_VALUE; ret = avcodec_decode_video2(ist->st->codec, decoded_frame, got_output, pkt); if (ret < 0) return ret; quality = same_quant ? decoded_frame->quality : 0; if (!*got_output) { return ret; } best_effort_timestamp= av_opt_ptr(avcodec_get_frame_class(), decoded_frame, "best_effort_timestamp"); if(*best_effort_timestamp != AV_NOPTS_VALUE) ist->next_pts = ist->pts = *best_effort_timestamp; ist->next_pts += duration; pkt->size = 0; pre_process_video_frame(ist, (AVPicture *)decoded_frame, &buffer_to_free); #if CONFIG_AVFILTER frame_sample_aspect= av_opt_ptr(avcodec_get_frame_class(), decoded_frame, "sample_aspect_ratio"); for(i=0;i<nb_output_streams;i++) { OutputStream *ost = ost = &output_streams[i]; if(check_output_constraints(ist, ost)){ if (!frame_sample_aspect->num) *frame_sample_aspect = ist->st->sample_aspect_ratio; decoded_frame->pts = ist->pts; av_vsrc_buffer_add_frame(ost->input_video_filter, decoded_frame, AV_VSRC_BUF_FLAG_OVERWRITE); } } #endif rate_emu_sleep(ist); for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = &output_streams[i]; int frame_size; if (!check_output_constraints(ist, ost) || !ost->encoding_needed) continue; #if CONFIG_AVFILTER if (ost->input_video_filter) { frame_available = av_buffersink_poll_frame(ost->output_video_filter); } while (frame_available) { if (ost->output_video_filter) { AVRational ist_pts_tb = ost->output_video_filter->inputs[0]->time_base; if (av_buffersink_get_buffer_ref(ost->output_video_filter, &ost->picref, 0) < 0){ av_log(0, AV_LOG_WARNING, "AV Filter told us it has a frame available but failed to output one\n"); goto cont; } if (!ist->filtered_frame && !(ist->filtered_frame = avcodec_alloc_frame())) { av_free(buffer_to_free); return AVERROR(ENOMEM); } else avcodec_get_frame_defaults(ist->filtered_frame); filtered_frame = ist->filtered_frame; *filtered_frame= *decoded_frame; if (ost->picref) { avfilter_fill_frame_from_video_buffer_ref(filtered_frame, ost->picref); ist->pts = av_rescale_q(ost->picref->pts, ist_pts_tb, AV_TIME_BASE_Q); } } if (ost->picref->video && !ost->frame_aspect_ratio) ost->st->codec->sample_aspect_ratio = ost->picref->video->sample_aspect_ratio; #else filtered_frame = decoded_frame; #endif do_video_out(output_files[ost->file_index].ctx, ost, ist, filtered_frame, &frame_size, same_quant ? quality : ost->st->codec->global_quality); if (vstats_filename && frame_size) do_video_stats(output_files[ost->file_index].ctx, ost, frame_size); #if CONFIG_AVFILTER cont: frame_available = ost->output_video_filter && av_buffersink_poll_frame(ost->output_video_filter); avfilter_unref_buffer(ost->picref); } #endif } av_free(buffer_to_free); return ret; }
1threat
Use existing DbContext of a Webapplication in ConsoleApp : <p>I've finished programming my asp.net Core Webapplication. Additionaly I would like to add a console app to my solution which should handle some cronjobs.</p> <p>Unfortunately I got absolutely stuck on how to use my DbContext-Class from the Webapplication in the console app. I've added the reference and can now access the namespaces.</p> <p>But how do I access my DbContext in the console app an be able to reuse it in additional classes?</p> <p>Thanks to all for your hints. Patrick</p>
0debug
static int adx_decode_header(AVCodecContext *avctx, const uint8_t *buf, int bufsize) { int offset; if (buf[0] != 0x80) return 0; offset = (AV_RB32(buf) ^ 0x80000000) + 4; if (bufsize < offset || memcmp(buf + offset - 6, "(c)CRI", 6)) return 0; avctx->channels = buf[7]; avctx->sample_rate = AV_RB32(buf + 8); avctx->bit_rate = avctx->sample_rate * avctx->channels * 18 * 8 / 32; return offset; }
1threat
Angular 5 reactive form set mat-checkbox to check : <p>I am trying to use mat-checkbox with reactive forms on Angular 5.1.2 and Angular Material 5.0.2.</p> <p>Everything is working well except that when I use patchValue({amateur: [false]) it is still checked. What is weird is I have other forms where I am doing the same thing and they work fine. It also isn't just the amateur checkbox, it is all the checkboxes are checked. Just using "amateur" as an example.</p> <p>The formControl amateur.value is always false. However once the patched value is executed, the control is checked.</p> <p>What am I missing?</p> <p>HTML5</p> <pre><code> &lt;form [formGroup]="showClassGrp"&gt; &lt;mat-checkbox id="amateur" class="amateur" color="primary" formControlName="amateur"&gt;Amateur&lt;/mat-checkbox&gt; &lt;/form&gt; </code></pre> <p>TypeScript</p> <p>FormBuilder works and display is correct.</p> <pre><code>this.showClassGrp = this.fb.group({ ... amateur: [false], ... }); </code></pre> <p>patch showClassGrp and all the checkboxes are checked even thou the formControl value for them are false. </p> <pre><code> this.showClassGrp.patchValue({ className: [this.showClass.className], //this works amateur: [false], // this changed the display to checked. ... }); </code></pre>
0debug
static int blk_prw(BlockBackend *blk, int64_t offset, uint8_t *buf, int64_t bytes, CoroutineEntry co_entry, BdrvRequestFlags flags) { AioContext *aio_context; QEMUIOVector qiov; struct iovec iov; Coroutine *co; BlkRwCo rwco; iov = (struct iovec) { .iov_base = buf, .iov_len = bytes, }; qemu_iovec_init_external(&qiov, &iov, 1); rwco = (BlkRwCo) { .blk = blk, .offset = offset, .qiov = &qiov, .flags = flags, .ret = NOT_DONE, }; co = qemu_coroutine_create(co_entry, &rwco); qemu_coroutine_enter(co); aio_context = blk_get_aio_context(blk); while (rwco.ret == NOT_DONE) { aio_poll(aio_context, true); } return rwco.ret; }
1threat
well this progeam is showing error : def arearectangle(length, breadth): totalarea = length * breadth return totalarea def areasqr(side): ''' Objective : To compute the area of circle Input parameters : Length and Breadth Return Value : area - numeric Value :rtype: int''' area = side*side return area def addition(num1, num2): '''The objective of this proram is to find the sum of two integers input through keyboard''' total = num1 + num2 return total def main (): print ("enter the length and breadth to find the area of rectangle") l1 = input(int('enter the length:')) l2 = input(int('enter the breadth')) rectarea = arearectangle(l1, l2) print("area of the rectangle is", rectarea) print("enter the following values to obtain the area of square") s1 = int(input('first side of square : intiger value :')) areas = areasqr(s1) print("Area of Square is ", areas) print("enter the following value to find out the sum") i = int(input('enter the first intiger : ')) j = int(input('enter the seoond intiger : ')) newtotal = addition(i, j) print('the sum of the entered intger is ', newtotal) if __name__ == '__main__': main()
0debug
How to change background with day/night time in Android : In my application I want change background with **Day/Night** time.<br> My mean is I want check **time** if time is **night** set **night background** from `drawable` and when **time is Day** set day **background** from `drawable`.<br> Sorry for my bad question, I am amateur and really need your helps.<br> How can I it in android?
0debug
why C++ template function do not support returning a pointer? : <p>I have a function like this:</p> <pre><code>#include &lt;iostream&gt; using namespace std; // function to generate and retrun random numbers. template&lt;typename T&gt; T * getRandom( ) { static T r[10]; for (int i = 0; i &lt; 10; ++i) { r[i] = 111; cout &lt;&lt; r[i] &lt;&lt; endl; } return r; } // main function to call above defined function. int main () { // a pointer to an int. int *p; p = getRandom(); for ( int i = 0; i &lt; 10; i++ ) { cout &lt;&lt; "*(p + " &lt;&lt; i &lt;&lt; ") : "; cout &lt;&lt; *(p + i) &lt;&lt; endl; } return 0; } </code></pre> <p>However, when I compile the code using g++5.4 and c++11. The compiler gives me this error:</p> <pre><code>main.cpp: In function 'int main()': main.cpp:25:18: error: no matching function for call to 'getRandom()' p = getRandom(); ^ main.cpp:25:18: note: candidate is: main.cpp:8:5: note: template&lt;class T&gt; T* getRandom() T * getRandom( ) { ^ main.cpp:8:5: note: template argument deduction/substitution failed: main.cpp:25:18: note: couldn't deduce template parameter 'T' p = getRandom(); ^ </code></pre> <p>It seems that C++ does not support to return a pointer that point to a template?</p> <p>Could anyone please tell me what's wrong with my toy example, thanks in advance!!</p>
0debug
vsprintf_len(string, format, args) char *string; const char *format; va_list args; { vsprintf(string, format, args); return strlen(string); }
1threat
Empty diff window with Apply Patch in TortoiseSVN : <p>Steps:</p> <ol> <li>Use TortoiseSVN's context menu to select "Create Patch"</li> <li>On another machine do the same but select "Apply Patch" and select the file generated in step 1.</li> <li>A blank merge window is opened.</li> </ol> <p>It looks like this:</p> <p><img src="https://i.imgur.com/0CosaaN.png" alt="Screenshot"></p> <p>The patch file is valid and I can use unix patch to apply it successfully (with some line-ending tinkering).</p> <p>I'm on Windows 10 and TortoiseSVN/TortoiseMerge 1.9.5</p>
0debug
static void uhci_process_frame(UHCIState *s) { uint32_t frame_addr, link, old_td_ctrl, val, int_mask; uint32_t curr_qh; int cnt, ret; UHCI_TD td; UHCI_QH qh; QhDb qhdb; frame_addr = s->fl_base_addr + ((s->frnum & 0x3ff) << 2); DPRINTF("uhci: processing frame %d addr 0x%x\n" , s->frnum, frame_addr); cpu_physical_memory_read(frame_addr, (uint8_t *)&link, 4); le32_to_cpus(&link); int_mask = 0; curr_qh = 0; qhdb_reset(&qhdb); for (cnt = FRAME_MAX_LOOPS; is_valid(link) && cnt; cnt--) { if (is_qh(link)) { if (qhdb_insert(&qhdb, link)) { DPRINTF("uhci: detected loop. qh 0x%x\n", link); break; } cpu_physical_memory_read(link & ~0xf, (uint8_t *) &qh, sizeof(qh)); le32_to_cpus(&qh.link); le32_to_cpus(&qh.el_link); DPRINTF("uhci: QH 0x%x load. link 0x%x elink 0x%x\n", link, qh.link, qh.el_link); if (!is_valid(qh.el_link)) { curr_qh = 0; link = qh.link; } else { curr_qh = link; link = qh.el_link; } continue; } cpu_physical_memory_read(link & ~0xf, (uint8_t *) &td, sizeof(td)); le32_to_cpus(&td.link); le32_to_cpus(&td.ctrl); le32_to_cpus(&td.token); le32_to_cpus(&td.buffer); DPRINTF("uhci: TD 0x%x load. link 0x%x ctrl 0x%x token 0x%x qh 0x%x\n", link, td.link, td.ctrl, td.token, curr_qh); old_td_ctrl = td.ctrl; ret = uhci_handle_td(s, link, &td, &int_mask); if (old_td_ctrl != td.ctrl) { val = cpu_to_le32(td.ctrl); cpu_physical_memory_write((link & ~0xf) + 4, (const uint8_t *)&val, sizeof(val)); } if (ret < 0) { break; } if (ret == 2 || ret == 1) { DPRINTF("uhci: TD 0x%x %s. link 0x%x ctrl 0x%x token 0x%x qh 0x%x\n", link, ret == 2 ? "pend" : "skip", td.link, td.ctrl, td.token, curr_qh); link = curr_qh ? qh.link : td.link; continue; } DPRINTF("uhci: TD 0x%x done. link 0x%x ctrl 0x%x token 0x%x qh 0x%x\n", link, td.link, td.ctrl, td.token, curr_qh); link = td.link; if (curr_qh) { qh.el_link = link; val = cpu_to_le32(qh.el_link); cpu_physical_memory_write((curr_qh & ~0xf) + 4, (const uint8_t *)&val, sizeof(val)); if (!depth_first(link)) { DPRINTF("uhci: QH 0x%x done. link 0x%x elink 0x%x\n", curr_qh, qh.link, qh.el_link); curr_qh = 0; link = qh.link; } } } s->pending_int_mask |= int_mask; }
1threat
def Average(lst): return sum(lst) / len(lst)
0debug
How do I know if my code is running as React Native : <p>I want to be able to export a package for all platforms, but I am using some native bindings with a plain JS fallback. Normally I would notice the difference checking if object <code>window</code> or <code>exports</code> exist.</p> <p>How can I achieve this on React Native?</p>
0debug
static void destroy_buffers(SANMVideoContext *ctx) { av_freep(&ctx->frm0); av_freep(&ctx->frm1); av_freep(&ctx->frm2); av_freep(&ctx->stored_frame); av_freep(&ctx->rle_buf); ctx->frm0_size = ctx->frm1_size = ctx->frm2_size = 0; }
1threat
How to view docker-compose healthcheck logs? : <p>Inside my <code>docker-compose.yml</code>, I have the following <code>service</code> <code>healthcheck</code> section. I want to know if MariaDB is actually ready to handle queries. A <code>service</code> named <code>cmd</code> is configured to depend on <code>condition: service_healthy</code>.</p> <pre><code> db: image: mariadb:10 environment: MYSQL_RANDOM_ROOT_PASSWORD: 1 MYSQL_USER: user MYSQL_PASSWORD: password MYSQL_DATABASE: database healthcheck: test: ["CMD", "mysql", "--user=user", "--password=password", "--execute='SELECT 1'", "--host=127.0.0.1", "--port=3306"] interval: 1s retries: 30 </code></pre> <p>This healthcheck does not work, shows that the service is unhealthy.</p> <p>How do I check the output of the <code>test</code> CMD?</p>
0debug
org.hibernate.QueryException: JPA-style positional param was not an integral ordinal : <p>I have the following JPQL request;</p> <pre><code>@Query(value = "select req_t " + "from TransactionRelation tr " + "inner join tr.requestTransaction req_t " + "inner join req_t.transactionStateHistory req_t_h " + "inner join tr.responseTransaction resp_t " + "inner join resp_t.transactionStateHistory resp_t_h " + "where req_t.id &gt;?1 " + "and req_t.receiver.id=?2 and req_t.requestType in ?3" + "and NOT EXISTS (select t from resp_t_h t where t.transactionState = 'REPLIED' )" + "and EXISTS (select tt from req_t_h tt where tt.transactionState = 'WAITING_PROVIDER' )" ) List&lt;Transaction&gt; queryTrabsactions(Long transactionId, Long providerId, Collection&lt;RequestType&gt; requestTypes); </code></pre> <p>But it prints following error:</p> <pre><code>Caused by: java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.finvale.repositories.TransactionRepository.queryTransactions(java.lang.Long,java.lang.Long,java.util.Collection)! at org.springframework.data.jpa.repository.query.SimpleJpaQuery.validateQuery(SimpleJpaQuery.java:92) ~[spring-data-jpa-1.11.1.RELEASE.jar:na] at org.springframework.data.jpa.repository.query.SimpleJpaQuery.&lt;init&gt;(SimpleJpaQuery.java:62) ~[spring-data-jpa-1.11.1.RELEASE.jar:na] at org.springframework.data.jpa.repository.query.JpaQueryFactory.fromMethodWithQueryString(JpaQueryFactory.java:72) ~[spring-data-jpa-1.11.1.RELEASE.jar:na] at org.springframework.data.jpa.repository.query.JpaQueryFactory.fromQueryAnnotation(JpaQueryFactory.java:53) ~[spring-data-jpa-1.11.1.RELEASE.jar:na] at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:144) ~[spring-data-jpa-1.11.1.RELEASE.jar:na] at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:212) ~[spring-data-jpa-1.11.1.RELEASE.jar:na] at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:77) ~[spring-data-jpa-1.11.1.RELEASE.jar:na] at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.&lt;init&gt;(RepositoryFactorySupport.java:436) ~[spring-data-commons-1.13.1.RELEASE.jar:na] at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:221) ~[spring-data-commons-1.13.1.RELEASE.jar:na] at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:277) ~[spring-data-commons-1.13.1.RELEASE.jar:na] at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:263) ~[spring-data-commons-1.13.1.RELEASE.jar:na] at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:101) ~[spring-data-jpa-1.11.1.RELEASE.jar:na] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] ... 47 common frames omitted Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryException: JPA-style positional param was not an integral ordinal at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:131) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:162) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:663) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:23) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_111] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_111] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_111] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_111] at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:347) ~[spring-orm-4.3.7.RELEASE.jar:4.3.7.RELEASE] at com.sun.proxy.$Proxy112.createQuery(Unknown Source) ~[na:na] at org.springframework.data.jpa.repository.query.SimpleJpaQuery.validateQuery(SimpleJpaQuery.java:86) ~[spring-data-jpa-1.11.1.RELEASE.jar:na] ... 60 common frames omitted Caused by: org.hibernate.QueryException: JPA-style positional param was not an integral ordinal at org.hibernate.engine.query.spi.ParameterParser.parse(ParameterParser.java:192) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at org.hibernate.engine.query.spi.ParamLocationRecognizer.parseLocations(ParamLocationRecognizer.java:59) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at org.hibernate.engine.query.spi.HQLQueryPlan.buildParameterMetadata(HQLQueryPlan.java:381) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at org.hibernate.engine.query.spi.HQLQueryPlan.&lt;init&gt;(HQLQueryPlan.java:134) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at org.hibernate.engine.query.spi.HQLQueryPlan.&lt;init&gt;(HQLQueryPlan.java:77) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:153) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:546) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:655) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] ... 68 common frames omitted </code></pre> <p>What the reason of my problem?</p>
0debug
int inet_connect(const char *str, bool block, Error **errp) { QemuOpts *opts; int sock = -1; opts = qemu_opts_create(&dummy_opts, NULL, 0, NULL); if (inet_parse(opts, str) == 0) { if (block) { qemu_opt_set(opts, "block", "on"); } sock = inet_connect_opts(opts, errp); } else { error_set(errp, QERR_SOCKET_CREATE_FAILED); } qemu_opts_del(opts); return sock; }
1threat
Kotlin - equivalence to Swift's combination of "if let + cast" : <p>I'm trying to find out how to achieve the combination of "if let + cast" in kotlin:</p> <p>in swift:</p> <pre><code>if let user = getUser() as? User { // user is not nil and is an instance of User } </code></pre> <p>I saw some documentation but they say nothing regarding this combination</p> <p><a href="https://medium.com/@adinugroho/unwrapping-sort-of-optional-variable-in-kotlin-9bfb640dc709" rel="noreferrer">https://medium.com/@adinugroho/unwrapping-sort-of-optional-variable-in-kotlin-9bfb640dc709</a> <a href="https://kotlinlang.org/docs/reference/null-safety.html" rel="noreferrer">https://kotlinlang.org/docs/reference/null-safety.html</a></p>
0debug
table tr Undefined value is storing in datase : [![enter image description here][1]][1] [1]: http://i.stack.imgur.com/5VdcJ.png here is my form table: <table id="jobSkills" "> <tbody> <tr><td class="col-xs-4"> Skill </td> </tbody> </table> jquery Add+++ More script: var skillcount=0; $(".addSkills").click(function(){ $('#jobSkills tr:last').after('<tr><td><input name="skill['+skillcount+'][title]" type="text" "></td></tr>'); skillcount++; }); Controller code to strore in db: foreach($_POST["skill"] as $k=>$key) { $conn->query("INSERT INTO r_job_skill (id_job,title) values ('".$jobId."','".$key["title"]."')"); }
0debug
int av_asrc_buffer_add_buffer(AVFilterContext *ctx, uint8_t *buf, int buf_size, int sample_rate, int sample_fmt, int64_t channel_layout, int planar, int64_t pts, int av_unused flags) { uint8_t *data[8]; int linesize[8]; int nb_channels = av_get_channel_layout_nb_channels(channel_layout), nb_samples = buf_size / nb_channels / av_get_bytes_per_sample(sample_fmt); av_samples_fill_arrays(data, linesize, buf, nb_channels, nb_samples, sample_fmt, 16); return av_asrc_buffer_add_samples(ctx, data, linesize, nb_samples, sample_rate, sample_fmt, channel_layout, planar, pts, flags); }
1threat
static void spapr_phb_vfio_finish_realize(sPAPRPHBState *sphb, Error **errp) { sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb); struct vfio_iommu_spapr_tce_info info = { .argsz = sizeof(info) }; int ret; sPAPRTCETable *tcet; uint32_t liobn = svphb->phb.dma_liobn; if (svphb->iommugroupid == -1) { error_setg(errp, "Wrong IOMMU group ID %d", svphb->iommugroupid); return; } ret = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid, VFIO_CHECK_EXTENSION, (void *) VFIO_SPAPR_TCE_IOMMU); if (ret != 1) { error_setg_errno(errp, -ret, "spapr-vfio: SPAPR extension is not supported"); return; } ret = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid, VFIO_IOMMU_SPAPR_TCE_GET_INFO, &info); if (ret) { error_setg_errno(errp, -ret, "spapr-vfio: get info from container failed"); return; } tcet = spapr_tce_new_table(DEVICE(sphb), liobn, info.dma32_window_start, SPAPR_TCE_PAGE_SHIFT, info.dma32_window_size >> SPAPR_TCE_PAGE_SHIFT, true); if (!tcet) { error_setg(errp, "spapr-vfio: failed to create VFIO TCE table"); return; } memory_region_add_subregion(&sphb->iommu_root, tcet->bus_offset, spapr_tce_get_iommu(tcet)); }
1threat
static int nbd_send_option_request(QIOChannel *ioc, uint32_t opt, uint32_t len, const char *data, Error **errp) { nbd_option req; QEMU_BUILD_BUG_ON(sizeof(req) != 16); if (len == -1) { req.length = len = strlen(data); } TRACE("Sending option request %" PRIu32", len %" PRIu32, opt, len); stq_be_p(&req.magic, NBD_OPTS_MAGIC); stl_be_p(&req.option, opt); stl_be_p(&req.length, len); if (write_sync(ioc, &req, sizeof(req), errp) < 0) { error_prepend(errp, "Failed to send option request header"); return -1; } if (len && write_sync(ioc, (char *) data, len, errp) < 0) { error_prepend(errp, "Failed to send option request data"); return -1; } return 0; }
1threat
mysql procedure keeps inserting replicated fields : i need help urgently in regards to the below , it keeps inserting already existing fields although it shouldn't. hope to get some help on this urgently. BEGIN INSERT INTO ohrm_attendance_raw_data (punch_time, device_id, card_number) SELECT punch_time, device_id, card_number FROM ohrm_attendance_master WHERE ohrm_attendance_master.punch_time >= DATE_SUB(now(), INTERVAL 1 MONTH) AND NOT EXISTS ( SELECT 1 FROM ohrm_attendance_record WHERE ohrm_attendance_record.punch_in_user_time = ohrm_attendance_master.punch_time) AND NOT EXISTS ( SELECT 1 FROM ohrm_attendance_record WHERE ohrm_attendance_record.punch_out_user_time = punch_time); end
0debug
Recursively check if all digit's of a number are different : How can I check recursively if all the digits of an integer are different numbers in C++
0debug
How to replace a letter in a string with another letter in ruby : so for instance when i type "elijah".my_method() in the irb command i want it to return "3lijah" because i want to replace the letter "e" with the number "3" I've tried using sub and gsub methods along with replace but none of these are allowing me to replace that letter. Here is my code class String define_method(:leet_speak) do containsE = self.include?("e") whereIsE = self.index("e") whereIsE.replace("3") end end
0debug
How to find unique identifier for an android device? : <p>Sorry if the title is not adequate, but I couldn't think of what else to call it. Anyway, Iv'e been searching how to find a particular android id but when I search "device ID android" or "android ID android", most solutions lead me to the ANDROID_ID which is "A 64-bit number (as a hex string) that is randomly generated when the user first sets up the device". </p> <p>I am trying to find another type of device ID (which I'm pretty sure is unique and doesn't change) which looks similar to this: android:36e32805-d44a-20fd-72dd-dc1366ec8a71.</p> <p>Any help with finding this ID would be greatly appreciated!</p> <p>Thanks!</p>
0debug
Getting started with encryption in Objective-C/iOS : <p>I'm starting to learn more about public and private keys with encryption and how security and encryption works. I have been looking on Google for good tutorials about how to secure data and build encryption into iOS applications. Does anyone know of any good open source APIs/code or tutorials that have examples for iOS encryption? Specifically I'm looking to figure out a way to be able to encrypt data send the encrypted data to another device or service and be able to decode that data.</p> <p>I was looking at <a href="https://github.com/ideawu/Objective-C-RSA" rel="nofollow">this Github repo</a> and under the usage section it shows example of how to encrypt a string with the public key. How would one go about generating that key to be able to encrypt the data?</p> <p>Any getting started pointers would be much appreciated!</p>
0debug
void ff_aac_update_ltp(AACEncContext *s, SingleChannelElement *sce) { int i, j, lag; float corr, s0, s1, max_corr = 0.0f; float *samples = &s->planar_samples[s->cur_channel][1024]; float *pred_signal = &sce->ltp_state[0]; int samples_num = 2048; if (s->profile != FF_PROFILE_AAC_LTP) return; for (i = 0; i < samples_num; i++) { s0 = s1 = 0.0f; for (j = 0; j < samples_num; j++) { if (j + 1024 < i) continue; s0 += samples[j]*pred_signal[j-i+1024]; s1 += pred_signal[j-i+1024]*pred_signal[j-i+1024]; } corr = s1 > 0.0f ? s0/sqrt(s1) : 0.0f; if (corr > max_corr) { max_corr = corr; lag = i; } } lag = av_clip(lag, 0, 2048); if (!lag) { sce->ics.ltp.lag = lag; return; } s0 = s1 = 0.0f; for (i = 0; i < lag; i++) { s0 += samples[i]; s1 += pred_signal[i-lag+1024]; } sce->ics.ltp.coef_idx = quant_array_idx(s0/s1, ltp_coef, 8); sce->ics.ltp.coef = ltp_coef[sce->ics.ltp.coef_idx]; if (lag < 1024) samples_num = lag + 1024; for (i = 0; i < samples_num; i++) pred_signal[i+1024] = sce->ics.ltp.coef*pred_signal[i-lag+1024]; memset(&pred_signal[samples_num], 0, (2048 - samples_num)*sizeof(float)); sce->ics.ltp.lag = lag; }
1threat
The wait operation timed out. ASP : <p>I created an internal website for our company. It run smoothly for several months and then I made a major update due to user suggestion. When I run in live, it run normally. Then suddenly one of my user from japan sending me an "The Wait operation timed out." error. When I check access that certain link, It run normally for me and some other who I ask to check if they access that page. I already update the httpRuntime executionTimeout but still no luck. Is it the error come from database connection? If I increase the timeout in the database connection it will be fix the problem? </p>
0debug
Python call function with same name as input : Is there a way in python (without using switch statements or if's and an array) to call a function with the same name as an input. E.g. x=input("string input") def foo(): print("foo") def bar(): print("bar") if x is foo I want to call foo()
0debug
Wuestion about iTextSharp : I am coding a program that i need to save texts(from a rich text box) to a pdf. I use iTextSharp and the code that i use is this: Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35); PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream("TitleOfPdf.pdf", FileMode.Create));//textBox1(in the form) assign here the title of the document doc.Open(); //open the document in order to write inside. Paragraph paragraph = new Paragraph(richTextBox1.Text); // Now adds the above created text using different class object to our pdf document doc.Add(paragraph); doc.Close(); Now the problem is that i would like the title of the file to be "flexible" and be assigned by the user(from a text box). The problem is that if i change the line: PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream("TitleOfPdf.pdf", FileMode.Create)); To: PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream(textBox1.Text, FileMode.Create)); Works fine. BUT the file it hasnt extension .pdf It is only a random file. How i can make the title of the document "flexible" so the user can assign it, and the extension will be .pdf ?? Thanks !!
0debug
C++ overload float parameters error : ive programing a C++ function couple using overload setting. one waiting 2 integer parameters, and the other, 2 floats. but codeblocks compliler says : "error: call of overloaded 'func(double, double)' is ambiguous". why double if im specifing a float? im using the two functions to sum their values showing result on cout inside them. float values given as arguments are 1.14 and 3.33, not big floating numbers... someone knowa? thx!
0debug
Refreshing Sql Connection Azure AD access token inside long-lived Entity Framework Context : <p>I'm trying to set up a few .NET applications to use certificate-based authentication to Azure Active Directory and then use Active Directory to authorize my access to a Sql Azure DB.</p> <p>The problem I'm running into is that some parts of the application use a DbContext that might live a little too long. The ADAL library tries to refresh the access token if you request it within 5 mins of it's expiration. Trouble is that some of my DbContexts might live for longer than 5 mins. Hence, halfway through the life of the DbContext the access token is no longer good and when I try to SaveChanges I get a database connection exception.</p> <p>Apart from refactoring to make my DbContexts live shorter than 5 mins, is there anything I can do to fix this?</p> <p>One thing I tried was to find some hooks in Entity Framework where I could catch the expired access token exception and then replace the current connection with a newly created one that has a new access token. I tried passing EF a custom connection factory and then using an Execution Strategy to retry when I get an expired token exception. This isn't working for me though because I can't modify or recreate the current connection from a custom execution strategy.</p> <p>Any ideas would be greatly appreciated.</p> <p>Thanks!</p>
0debug
Curved header with pure CSS : <p>Trying to nail this curved header with pure CSS but using border radius isn't keeping the left &amp; right border edges as sharp as they are in the image. Any help would be appreciated.<a href="https://i.stack.imgur.com/Bj4ge.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bj4ge.png" alt="Curved header"></a></p>
0debug
Stop angular cli asking for collecting analytics when I use ng build : <p>Angluar CLI is asking the following question when I am trying to build and deploy my project using gitlab CI/CD:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&gt; @angular/cli@8.0.0 postinstall /workspace/node_modules/@angular/cli &gt; node ./bin/postinstall/script.js ? Would you like to share anonymous usage data with the Angular Team at Google u nder Google’s Privacy Policy at https://policies.google.com/privacy? For more details and how to change this setting, see http://angular.io/analytics. (y/N) </code></pre> </div> </div> </p> <p>Of course I cannot input anything in the CI/CD pipeline. How can I can prevent angular cli from asking this question?</p>
0debug
What's the best way to check for permissions at runtime using MVP architecture? : <p>I'm developing an android app in which I have to ask for permissions at runtime. I'm wondering about the best way to implement that using Model-View-Presenter architecture.</p> <p>My initial thought was to have the presenter call a component responsible for permissions(say a <code>PermissionHandler</code>), and update view accordingly.</p> <p>The issue is that the code to check for permissions is tightly coupled with the Activity class. Here are some of the methods involved that require an Activity or Context:</p> <ul> <li><code>ContextCompat.checkSelfPermission()</code></li> <li><code>ActivityCompat.shouldShowRequestPermissionRationale()</code></li> <li><code>ActivityCompat.requestPermissions()</code></li> <li><code>onRequestPermissionsResult()</code>(callback)</li> </ul> <p>This means I would have to pass an activity object to the presenter, which I didn't like much because I've heard that keeping your presenter free from Android code is good for testing.</p> <p>Due to that, I then thought about handling permissions at view level(in an activity), but then I guess this would hurt the purpose of leaving the view responsible only for UI updates, without business logic.</p> <p>I'm not sure what would be the best approach to tackle that keeping the code as decoupled and maintainable as possible. Any ideas?</p>
0debug
How to extract a substring How to extract a substring beginning with a specific substring and ends with another specific substring : I have something like that: "1111Austria9999Salzburg (SZG)Vienna (VIE)1111Bosnia-Herzegovina9999Sarajevo (SJJ)1111Bulgaria9999Bourgas (BOJ)Varna (VAR)" and I want to extract Salzburg (SZG), Sarajevo (SJJ), Bourgas (BOJ), Varna (VAR)
0debug
Is there a way to delete a user via API for OneSignal? : <p>When I delete a user from my backend I also want to delete the entry from the OneSignal database to keep my numbers and pushes precise (also important for A/B testing). Is there a way to do that? I searched the API but I couldn't seem to find anything to delete an entry.</p> <p>Thanks!</p>
0debug
static void tpm_passthrough_cancel_cmd(TPMBackend *tb) { }
1threat
long do_sigreturn(CPUCRISState *env) { struct target_signal_frame *frame; abi_ulong frame_addr; target_sigset_t target_set; sigset_t set; int i; frame_addr = env->regs[R_SP]; if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 1)) goto badframe; if (__get_user(target_set.sig[0], &frame->sc.oldmask)) goto badframe; for(i = 1; i < TARGET_NSIG_WORDS; i++) { if (__get_user(target_set.sig[i], &frame->extramask[i - 1])) goto badframe; } target_to_host_sigset_internal(&set, &target_set); sigprocmask(SIG_SETMASK, &set, NULL); restore_sigcontext(&frame->sc, env); unlock_user_struct(frame, frame_addr, 0); return env->regs[10]; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); }
1threat
How to add every four elements in a 1D column array (1,35040) in Python : <p>I tried it using array indexing method in for loop. But it is raising 'ValueError: too many values to unpack(expected 1)'</p>
0debug
What machine learning algorithm to use for face matching? : <p>I want your opinion on what would be the best machine learning algorithm, or even better, library, to use if I wanted to match two faces that look similar. Kind of like how google photos can put photos of the same people in their own album automatically. What's the best way to tackle this?</p>
0debug
from itertools import product A=((1,2),(3,4)) : from itertools import product A=((1,2),(3,4)) B= list(product(*A)) print (B) my output is [(1, 3), (1, 4), (2, 3), (2, 4)] but I want my output (1, 3) (1, 4) (2, 3) (2, 4) please help
0debug
static void mb_add_mod(MultibootState *s, target_phys_addr_t start, target_phys_addr_t end, target_phys_addr_t cmdline_phys) { char *p; assert(s->mb_mods_count < s->mb_mods_avail); p = (char *)s->mb_buf + s->offset_mbinfo + MB_MOD_SIZE * s->mb_mods_count; stl_p(p + MB_MOD_START, start); stl_p(p + MB_MOD_END, end); stl_p(p + MB_MOD_CMDLINE, cmdline_phys); mb_debug("mod%02d: "TARGET_FMT_plx" - "TARGET_FMT_plx"\n", s->mb_mods_count, start, end); s->mb_mods_count++; }
1threat
Put a 2d Array into a Pandas Series : <p>I have a 2D Numpy array that I would like to put in a pandas Series (not a DataFrame):</p> <pre><code>&gt;&gt;&gt; import pandas as pd &gt;&gt;&gt; import numpy as np &gt;&gt;&gt; a = np.zeros((5, 2)) &gt;&gt;&gt; a array([[ 0., 0.], [ 0., 0.], [ 0., 0.], [ 0., 0.], [ 0., 0.]]) </code></pre> <p>But this throws an error:</p> <pre><code>&gt;&gt;&gt; s = pd.Series(a) Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "/miniconda/envs/pyspark/lib/python3.4/site-packages/pandas/core/series.py", line 227, in __init__ raise_cast_failure=True) File "/miniconda/envs/pyspark/lib/python3.4/site-packages/pandas/core/series.py", line 2920, in _sanitize_array raise Exception('Data must be 1-dimensional') Exception: Data must be 1-dimensional </code></pre> <p>It is possible with a hack:</p> <pre><code>&gt;&gt;&gt; s = pd.Series(map(lambda x:[x], a)).apply(lambda x:x[0]) &gt;&gt;&gt; s 0 [0.0, 0.0] 1 [0.0, 0.0] 2 [0.0, 0.0] 3 [0.0, 0.0] 4 [0.0, 0.0] </code></pre> <p>Is there a better way?</p>
0debug
I need help debugging a basic c program to calculate fibonacci numbers : #include <stdio.h> int main(); { int a; int b; int var_z; a = 1; b = 1; c= 2; for () { a = c + b; printf(a,"\n"); b = c + a; printf(b,"\n"); c = a + b; printf(c,"\n"); } } I am a beginner at c and am trying to write a program to list the fibonacci sequence. This is what I have so far. I know I have at least two issues, one being the for loop. How would I make it an infinite loop? My second issue that I'm running into is this error message "prog.c:3:1: error: expected identifier or '(' before '{' token { ^" If someone could help that would be much appreciated.
0debug
PHPUnit: What does syntaxCheck configuration parameter stands for exactly : <p>I can't find it in documentation nor on google search which is strange.</p> <p>What does <code>syntaxCheck</code> configuration parameter stands for exactly in PHPUnit configuration XML file?</p>
0debug
gitlab: how to update to latest minor version : <p>I tried to update my gitlab-CE from 10.3.2 to the latest one (currently the 11.4). And it gives me this honestly safe error. </p> <pre><code>[...] gitlab preinstall: It seems you are upgrading from 10.x version series gitlab preinstall: to 11.x series. It is recommended to upgrade gitlab preinstall: to the last minor version in a major version series first before gitlab preinstall: jumping to the next major version. gitlab preinstall: Please follow the upgrade documentation at https://docs.gitlab.com/ee/policy/maintenance.html#upgrade-recommendations gitlab preinstall: and upgrade to 10.8 first. dpkg: error processing archive /var/cache/apt/archives/gitlab-ce_11.2.3-ce.0_amd64.deb (--unpack): subprocess new pre-installation script returned error exit status 1 Errors were encountered while processing: /var/cache/apt/archives/gitlab-ce_11.2.3-ce.0_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1) root@this-vm# apt-cache policy gitlab-ce | grep Installed Installed: 10.3.2-ce.0 </code></pre> <p>But how to install to the latest minor version ? The documentation they are referring to, doesn't say how to do it. Do you guys encounter any problem like this ? </p>
0debug
How to convert a camel-case string to dashes in JavaScript? : <p>I want to convert these strings:</p> <pre><code>fooBar FooBar </code></pre> <p>into:</p> <pre><code>foo-bar -foo-bar </code></pre> <p>How would I do this in JavaScript the most elegant and performant way for any given string?</p>
0debug
def decreasing_trend(nums): if (sorted(nums)== nums): return True else: return False
0debug
Element adaptive-icon must be declared : <p>I use Android Studio 2.3.3 stable and trying to create adaptive icon for Android O</p> <p>I've created folder <code>mipmap-anydpi-v26</code> and file <code>ic_launcher.xml</code> with following content</p> <pre><code>&lt;adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;background android:drawable="@color/colorAccent"/&gt; &lt;foreground android:drawable="@drawable/ic_launcher_adaptive"/&gt; &lt;/adaptive-icon&gt; </code></pre> <p>But it says "Element adaptive-icon must be declared". Target SDK and build tools are both set to 26.</p> <p>It builds successfully, but I don't have any device to test it, so my question is - does it works?</p> <p>P.S.: Foreground is valid VectorDrawable</p>
0debug
No sqlite3.exe in SQLite3 Download Folder For Windows 64 Bit : <p>This is kind of silly question but I am trying to install SQLlite 3 on my Windows 10 64 bit from <a href="https://www.sqlite.org/download.html" rel="noreferrer">SQLite download page</a> and I tried the <code>sqlite-dll-win64-x64-3170000.zip</code> from <code>Precompiled Binaries for Windows</code> section i the page </p> <p><a href="https://i.stack.imgur.com/xu2SL.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xu2SL.png" alt="enter image description here"></a></p> <p>but when unzip the file there are only two files "sqlite3.def<code>and</code>sqlite3.dll` </p> <p><a href="https://i.stack.imgur.com/b7oE9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/b7oE9.png" alt="enter image description here"></a></p> <p>can someone please let me know where is the <code>sqlite3.exe</code>? As far as I know we should have all these three files together?</p> <pre><code>sqlite3.def sqlite3.dll sqlite3.exe </code></pre>
0debug