problem
stringlengths
26
131k
labels
class label
2 classes
Did I make a mistake with my first binary search? what is wrong in my codes? : <pre><code>public static void main(String[] args){ } public final static int NOT_FOUND = -1; public int binarySearch (int[] number, int searchValue){ int low = 0, high = number.length - 1, mid = (low + high) / 2; while(low &lt;= high &amp;&amp; number[mid] != searchValue){ if(number[mid] &lt; searchValue){ low = mid + 1; } else { high = mid -1; } mid = (low + high) / 2; } if(low &gt; high){ mid = NOT_FOUND; } return mid; } } </code></pre> <p>I made a binary search but it didn't run. what is the problem in the codes? There is no error but when I run it theres nothing.</p>
0debug
MS Access: find rows with different fields in from two tables : In MS Access: I am trying to compare two tables with: - TABLE1.docnumb1 = TABLE2.docnumb2 - looking for: TABLE1.sum <> TABLE2.sum2 But query retrieves an error: syntax error in from clause (or when creating left join I get an error that JOIN isn't supported): SELECT docnumb1, sum FROM Table1 JOIN Table2 ON docnumb1 = docnumb2; How do I query the rows with different values? [example][1] [1]: https://i.stack.imgur.com/3O0Ae.png
0debug
How to write hello world in Python : <p>I am new to Python language. Please how can I write "hello world" using Python? I've try IF "Hello" PRINT "hello world", but it didn't work. So please help me out. Anybody.</p>
0debug
static void unterminated_dict(void) { QObject *obj = qobject_from_json("{'abc':32", NULL); g_assert(obj == NULL); }
1threat
Convert ttimestamp with zone to local time - BASH : I am trying to do basic time math in bash, having following timestamps from OpenDj: createtimestamp: 20161123165725Z I don't know what time zone the system will be set with, it can be with "Zulu" timezone (UTC) as above or might be with some other timezone. The above timestamps is for the users in LDAP servers , what I need to do is to compare the timestamp of the user with certain time stamp. Question: How do I convert the timestamp with zone (Z) above to local timestamp or epoch time in BASH? Thanks, Jorge
0debug
C# How to run my two function at same time asynchronously : <p>Below is sample program i have written. i am learning usage of async/await. when i execute the code then i saw first <code>GetAllTheCats</code> execute and when complete then <code>GetAllTheFood</code> execute. so this is not parallel. Tell me how could i run two routine at same time asynchronously which will update two different label control. if possible please restructure my code.</p> <pre><code>private async void button1_Click(object sender, EventArgs e) { await Task.Run(() =&gt; GetAllTheCats()); await Task.Run(() =&gt; GetAllTheFood()); } public string GetAllTheCats() { // Do stuff, like hit the Db, spin around, dance, jump, etc... // It all takes some time. Thread.Sleep(2000); return ""; } public string GetAllTheFood() { // Do more stuff, like hit the Db, nom nom noms... // It all takes some time. Thread.Sleep(2000); return ""; } </code></pre>
0debug
How to send FCM to entire app using ARC : I cant find any information regarding how to target just the app, I don't have any topics and I don't want to merely target a single user. The documentation states that a to is optional but I just receive a missingregistration error: >This parameter specifies the recipient of a message. > >The value can be a device's registration token, a device group's notification key, or a single topic (prefixed with /topics/). To send to multiple topics, use the condition parameter. This is my current setup: https://i.stack.imgur.com/CRlVe.png Removing the "to" field just gives me an error and the message is merely "to".
0debug
How would I make a program that only prints to lines in a file after it reads a "+" sign in the file : <p>I need my program to store a lot of login information for different users. I can not get it, however, when it is writing, to only write to the lines after the "+" sign.</p> <p>So, I need it to skip until it see's the plus sign in the file, then, on the next three lines, put data in the file, then on the fourth line put the plus sign, and remove it from it's original location.</p> <p>I have tried absolutely everything that involves that part of the code.</p> <p>It needs to work like this </p> <p>Run #1</p> <pre><code>bla bla bla + </code></pre> <p>Run #2</p> <pre><code>bla bla bla bla bla bla + I want this thing to finally work. </code></pre>
0debug
Windows Task Scheduler OR TaskService Functions in WebApi : <p>I want to create some functions in ASP.NET Web API, which should be executed daily at specific time and do specific task like update statuses/Records/Generating Emails, SMS. </p> <p>Should i create a TaskService in Code</p> <pre><code>using System; using Microsoft.Win32.TaskScheduler; class Program { static void Main(string[] args) { // Get the service on the local machine using (TaskService ts = new TaskService()) { // Create a new task definition and assign properties TaskDefinition td = ts.NewTask(); td.RegistrationInfo.Description = "Does something"; // Create a trigger that will fire the task at this time every other day td.Triggers.Add(new DailyTrigger { DaysInterval = 2 }); // Create an action that will launch Notepad whenever the trigger fires td.Actions.Add(new ExecAction("notepad.exe", "c:\\test.log", null)); // Register the task in the root folder ts.RootFolder.RegisterTaskDefinition(@"Test", td); // Remove the task we just created ts.RootFolder.DeleteTask("Test"); } } } </code></pre> <p>or should i create a .bat file and create a new task in Task Scheduler.</p>
0debug
Installing node with brew fails on Mac OS Sierra : <p>I'm trying to install node with homebrew on macOS Sierra. I run </p> <pre><code> brew install node </code></pre> <p>After a seemingly successful install I get the following when trying to run <code>node</code>:</p> <pre><code>dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.58.dylib Referenced from: /usr/local/bin/node Reason: image not found Abort trap: 6 </code></pre>
0debug
Generate timestamp for each ID in R in ascending order : <p>I tried to generate timestamp in R for my data and I'm having problem to create them in order where each ID will take group of timestamp for the period of 14 days and I need to create them in ascending order.</p> <p>My data looks like :</p> <pre><code>ID Lat Long Traffic Time 1 -80.424 40.4242 54 1am 2 -80.114 40.4131 30 1am 3 -80.784 40.1142 12 1am 1 -80.424 40.4242 22 2am 2 -80.114 40.4131 31 2am 3 -80.784 40.1142 53 2am </code></pre> <p>And I want my data to be like this :</p> <pre><code>ID Lat Long Traffic Time_New 1 -80.424 40.4242 54 2018/01/01 01:00 2 -80.114 40.4131 30 2018/01/01 01:00 3 -80.784 40.1142 12 2018/01/01 01:00 1 -80.424 40.4242 22 2018/01/02 02:00 2 -80.114 40.4131 31 2018/01/02 02:00 3 -80.784 40.1142 53 2018/01/02 02:00 </code></pre> <p>I used the code below to 24 hrs for each ID for the period time of 2 weeks but I got this output but the order of the timestamp is not what I want plus it added the value of traffic from the previous values and I want to generate the new values of the new timestamp based on the average of the traffic flow of each ID.</p> <pre><code>library(data.table) Data&lt;- setDT(Data)[, .SD[rep(1:.N, ID)]][,Time_New:= seq(as.POSIXct("2018-01-01 01:00"), as.POSIXct("2018-01-14 00:00"),by = "hour"),by = .(Lat, Long)][] ID Lat Long Traffic Time_New Time 1 -80.424 40.4242 54 2018/01/01 01:00 1am 2 -80.114 40.4131 30 2018/01/01 01:00 1am 3 -80.784 40.1142 12 2018/01/01 01:00 1am 1 -80.424 40.4242 54 2018/01/02 02:00 2am 2 -80.114 40.4131 54 2018/01/02 03:00 2am 1 -80.424 40.4242 54 2018/01/01 02:00 2am 2 -80.114 40.4131 54 2018/01/01 03:00 2qm 3 -80.784 40.1142 30 2018/01/01 01:00 3am 3 -80.784 40.1142 30 2018/01/01 02:00 3am 3 -80.784 40.1142 30 2018/01/01 03:00 3am </code></pre> <p>As you see It listed the first 3 IDs in the order I want then, it starts repeating ID 1, 2 and for ID 3 it put list of time from 1-3, and copy same traffic value.</p> <p>Anyone has idea how to do generate the timestamp for each Id group in ascending order?</p> <p>it will be much appreciated. </p>
0debug
Creating UI of Microsoft Bot Framework : <p>Is it possible to create my own UI on the top of Microsoft chatbot emulator ? If yes, i want to design my chatbot's UI as complete different from the BLUE-WHITES boring micorosft's UI. Help me to achieve this geeks.</p>
0debug
"tag start is not closed" error in AndroidManifest : <p>I'm making a small app to copy a link of a video from the intent menu, but when i try to compile the app, i get the error "tag start is not closed" in my androidmanifest:</p> <p>the error appears at the end of line 10. Thanks in advance for any replies!</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.reshare.copyurl"&gt; &lt;application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@android:style/Theme.NoDisplay" &lt;activity android:name=".MainActivity" android:excludeFromRecents="true"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.SEND" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;data android:mimeType="text/plain" /&gt; &lt;/intent-filter&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.VIEW"/&gt; &lt;category android:name="android.intent.category.DEFAULT"/&gt; &lt;category android:name="android.intent.category.BROWSABLE"/&gt; &lt;data android:scheme="rtsp"/&gt; &lt;/intent-filter&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.VIEW"/&gt; &lt;category android:name="android.intent.category.DEFAULT"/&gt; &lt;category android:name="android.intent.category.BROWSABLE"/&gt; &lt;data android:scheme="http"/&gt; &lt;data android:scheme="https"/&gt; &lt;data android:scheme="content"/&gt; &lt;data android:mimeType="video/mpeg4"/&gt; &lt;data android:mimeType="video/mp4"/&gt; &lt;data android:mimeType="video/3gp"/&gt; &lt;data android:mimeType="video/3gpp"/&gt; &lt;data android:mimeType="video/3gpp2"/&gt; &lt;data android:mimeType="video/webm"/&gt; &lt;data android:mimeType="video/avi"/&gt; &lt;data android:mimeType="application/sdp"/&gt; &lt;/intent-filter&gt; &lt;intent-filter&gt; !-- HTTP live support --&gt;; &lt;action android:name="android.intent.action.VIEW"/&gt; &lt;category android:name="android.intent.category.DEFAULT"/&gt; &lt;category android:name="android.intent.category.BROWSABLE"/&gt; &lt;data android:scheme="http"/&gt; &lt;data android:scheme="https"/&gt; &lt;data android:mimeType="audio/x-mpegurl"/&gt; &lt;data android:mimeType="audio/mpegurl"/&gt; &lt;data android:mimeType="application/vnd.apple.mpegurl"/&gt; &lt;data android:mimeType="application/x-mpegurl"/&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre>
0debug
How to get the Main Activity to run after using a Splash Screen in Android Studio 2.1.3 : I am just starting to learn about Android Development and in an exercise, I have to use a splash screen prior to starting my main activity in Android Studio. I currently have my splash screen coded by using the activity theme method as opposed to using the layout method. Everything in my code looks good in both the .java and .xml files (according to the software) because I have no errors yet every time I click the app icon in the emulator, it brings up the splash screen then the app exits without showing my main activity. Here's my code so far: SplashActivity.java package com.example.healthylife; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.content.Intent; public class SplashActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); Intent intent = new Intent(this, MainActivity.class); startActivity(intent); finish(); } } MainActivity.java: package com.example.healthylife; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } Here's my manifest.xml: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.healthylife" > <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme" > <activity android:name=".SplashActivity" android:label="@string/app_name" android:theme="@style/SplashTheme"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name=".MainActivity" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> Any advice would be greatly appreciated.
0debug
how can I convert that php array to a javascript array : <p>how can I convert that php array to a javascript array, please help</p> <p><a href="https://i.stack.imgur.com/YWdjS.png" rel="nofollow noreferrer">enter image description here</a></p>
0debug
Elasticsearch Fuzzy Phrases : <p>I have the following query to add fuzziness to my search. However, I now realize that the match query doesn't consider the order of the words in the search string, as the match_phrase does. However, I can't get match_phrase to give me results with fuzziness. Is there a way to tell match to consider the order and distance between words?</p> <pre><code>{ "query": { "match": { "content": { "query": "some search terms like this", "fuzziness": 1, "operator": "and" } } } } </code></pre>
0debug
The best way to create an html email newsletter : <p>How do you compose an html newsletter that renders correctly in MS Outlook? My html looks bad, but good as a web page. I have the html written, and it looks good in chrome and IE, but within outlook, the styling is botched. I have used all inline CSS, as directed by other websites. Do you need special software, or are there any good training resources to help? In short, what is the best way to send out an html email newsletter? Here is a small snippet of my code, enough to give you the idea:</p> <pre><code>&lt;!DOCTYPE html&gt; </code></pre> <p></p> <pre><code>&lt;head&gt; &lt;charset="utf-8"&gt; &lt;title&gt;GPA Newsletter&lt;/title&gt; &lt;/head&gt; </code></pre> <p></p> <pre><code> &lt;div style="padding: 0px; margin: 0px; background: gray; padding: 10px"&gt; &lt;div style="padding-bottom: 80px; background: linear-gradient(gray, white);"&gt; &lt;h1 style="margin-top: 0;"&gt;Here is your September 2017 GPA Maintenance Newsletter&lt;/h1&gt; &lt;img src="https://i.imgur.com/5xskeoF.jpg" alt="The newsletter logo" style="margin-top: 30px; border-radius: 30px; border: 5px solid black; max-width: 100%; display: block; margin: auto; width: 50%; argin-bottom: 40px;"&gt; &lt;img src="https://i.imgur.com/uhdSAow.jpg" alt="The comcast logo" style="max-width: 100%; display: inline; float: left; margin-left: 12%; margin-bottom: 20px;"&gt; &lt;h2 style="text-align: right; padding-right: 15%; margin-bottom: 0;"&gt;September 2017&lt;/h2&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p> </p>
0debug
static void kvm_mce_inj_srao_memscrub(CPUState *env, target_phys_addr_t paddr) { struct kvm_x86_mce mce = { .bank = 9, .status = MCI_STATUS_VAL | MCI_STATUS_UC | MCI_STATUS_EN | MCI_STATUS_MISCV | MCI_STATUS_ADDRV | MCI_STATUS_S | 0xc0, .mcg_status = MCG_STATUS_MCIP | MCG_STATUS_RIPV, .addr = paddr, .misc = (MCM_ADDR_PHYS << 6) | 0xc, }; int r; r = kvm_set_mce(env, &mce); if (r < 0) { fprintf(stderr, "kvm_set_mce: %s\n", strerror(errno)); abort(); } kvm_mce_broadcast_rest(env); }
1threat
Need Example of Poor Encapsulation : <p>I want to see an example of reaching directly into the code from a class that uses publicly declared data members to see an example of poor encapsulation so I can understand the good examples of encapsulation in OOP by contrasting with a bad example.(Being told to use encapsulation without a bad example is like being told not to steal without understanding what stealing is to me.) Thanks.</p>
0debug
Parsing the command and paasing the filepath into fopen : The issues is in the pointer I guess. suggest any method to receive a command like "cat serverpath or filepath" and parse the command and to pass the path into fopen(filepath, "r"). to here is the code for server: time_t start; char buf[BUFSIZ], *command, content; int n,i; FILE *fptr; start = time(0); (void) pthread_mutex_lock(&stats.st_mutex); stats.st_concount++; (void) pthread_mutex_unlock(&stats.st_mutex); while (1) { bzero(buf, BUFSIZ); n = recv(fd, buf, BUFSIZ, 0); if (n < 0){ errexit("echo read: %s\n", strerror(errno)); } else{ printf("The client message: %s\n",buf); } strtok_r (buf, " ", &command); printf("%s\n", buf); printf("%s\n",command); //char filename[100], c; // printf("Enter the filename to open \n"); // scanf("%s", command); // Open file fptr = fopen(command, "r"); if (fptr == NULL) { printf("Cannot open file \n"); exit(0); } // Read contents from file content = fgetc(fptr); while (content != EOF) { printf ("%c", content); content = fgetc(fptr); } error in fopen.
0debug
build_fadt(GArray *table_data, BIOSLinker *linker, unsigned dsdt) { AcpiFadtDescriptorRev5_1 *fadt = acpi_data_push(table_data, sizeof(*fadt)); fadt->flags = cpu_to_le32(1 << ACPI_FADT_F_HW_REDUCED_ACPI); fadt->arm_boot_flags = cpu_to_le16((1 << ACPI_FADT_ARM_USE_PSCI_G_0_2) | (1 << ACPI_FADT_ARM_PSCI_USE_HVC)); fadt->minor_revision = 0x1; fadt->dsdt = cpu_to_le32(dsdt); bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, ACPI_BUILD_TABLE_FILE, &fadt->dsdt, sizeof fadt->dsdt); build_header(linker, table_data, (void *)fadt, "FACP", sizeof(*fadt), 5, NULL, NULL); }
1threat
int qdev_device_help(QemuOpts *opts) { Error *local_err = NULL; const char *driver; DevicePropertyInfoList *prop_list; DevicePropertyInfoList *prop; driver = qemu_opt_get(opts, "driver"); if (driver && is_help_option(driver)) { qdev_print_devinfos(false); return 1; } if (!driver || !qemu_opt_has_help_opt(opts)) { return 0; } qdev_get_device_class(&driver, &local_err); if (local_err) { goto error; } prop_list = qmp_device_list_properties(driver, &local_err); if (local_err) { goto error; } for (prop = prop_list; prop; prop = prop->next) { error_printf("%s.%s=%s", driver, prop->value->name, prop->value->type); if (prop->value->has_description) { error_printf(" (%s)\n", prop->value->description); } else { error_printf("\n"); } } qapi_free_DevicePropertyInfoList(prop_list); return 1; error: error_printf("%s\n", error_get_pretty(local_err)); error_free(local_err); return 1; }
1threat
Non-whitespace before first tag error : <p>I can not build cordova application,and I receive the following error:</p> <pre><code>Error: Non-whitespace before first tag. Line: 0 Column: 1 Char: </code></pre> <p>I am using <code>cordova 6.2.0</code>, and trying to build the <code>android</code> platform.</p>
0debug
Why should I inject IHttpContextAccessor as a Singleton : <p>In all examples that i've seen of <code>IHttpContextAccessor</code> injection, it is set as a Singleton.</p> <p>Examples: </p> <p><a href="https://stackoverflow.com/questions/38184583/how-to-add-ihttpcontextaccessor-in-the-startup-class-in-the-di-in-asp-net-core-1">How to add IHttpContextAccessor in the Startup class in the DI in ASP.NET Core 1.0?</a> <a href="https://stackoverflow.com/questions/39131925/injecting-ihttpcontextaccessor-into-applicationdbcontext-asp-net-core-1-0">Injecting IHttpContextAccessor into ApplicationDbContext ASP.NET Core 1.0</a> <a href="https://stackoverflow.com/questions/40303982/net-core-ihttpcontextaccessor-issue">.NET Core IHttpContextAccessor issue</a></p> <p>I find it kinda weird, since <code>HttpContext</code> really looks like something that maps to requests. Wouldn't <code>AddScoped</code> be more appropriate in this case?</p> <p>Is Singleton really the recomended way? Am I not seeeing something?</p>
0debug
Replace text with regular expresion : <p>I have this text on a txt file.</p> <pre><code>2019-08-09T15:00:00Z 2019-08-09T15:05:00Z 2019-08-09T15:06:00Z 2019-08-09T15:09:00Z 2019-08-09T15:10:00Z </code></pre> <p>But I want to delete some part of the text, only de date. I need a code o a example on powershell or cmd.</p> <pre><code>15:00:00Z 15:05:00Z 15:06:00Z 15:09:00Z 15:10:00Z </code></pre> <p>Thanks!</p>
0debug
static void test_visitor_out_native_list_uint8(TestOutputVisitorData *data, const void *unused) { test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_U8); }
1threat
Is there a flexible method in Rails to convert string to XXX : Thanks to view this question, actually **XXX** is not real XXX, I just don't know how to call it. What I wanna know is : `string = "id: 2"` How can I use `User.where(string)` Thanks to talented friends, hope useful answer! BTW, pls let me know how to call the **XXX** :)
0debug
How to make thread run existing class´ function? c++ : <p>I have an existing class with an function</p> <pre><code>void Foo::startSimulation(std::string system_cmd) { //Calling a simulation script from system //After simulation, there is nothing to do. //Thread self-terminates. } </code></pre> <p>My goal is to make a thread which runs the Foo function. I have tried <code>std::thread thread1(myFoo.startSimulation(message);</code> However this returns </p> <pre><code>: error: no matching constructor for initialization of 'std::thread' candidate constructor not viable: cannot convert argument of incomplete type 'void' to 'const std::__1::thread' </code></pre> <p>So my function returns void which the thread can´t run. How can I make the thread exist, and then run the processes the class function would do within that thread.</p> <p>Is it in any way possible to make the thread. </p> <pre><code>std::thread thread1; // Creating the thread thread1.start(myFoo.startSimulation("system cmd"); thread1.detach(); </code></pre> <p><strong>I know the above three lines of code are not working code in c++. std::thread has no .start() function.</strong></p> <p><em>However, is there a way to make threads behave in that way?</em></p>
0debug
How to check in android that the Edit Text has correct answer or not? : I am making a quiz , in which I allows user to enter the answer in Edit Text form. My question is how can I tell the Computer that whether the answer entered is right or not?
0debug
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) { int ret; switch (avctx->codec_type) { case AVMEDIA_TYPE_VIDEO: if (!frame->width) frame->width = avctx->width; if (!frame->height) frame->height = avctx->height; if (frame->format < 0) frame->format = avctx->pix_fmt; if (!frame->sample_aspect_ratio.num) frame->sample_aspect_ratio = avctx->sample_aspect_ratio; if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0) return ret; break; case AVMEDIA_TYPE_AUDIO: if (!frame->sample_rate) frame->sample_rate = avctx->sample_rate; if (frame->format < 0) frame->format = avctx->sample_fmt; if (!frame->channel_layout) frame->channel_layout = avctx->channel_layout; break; default: return AVERROR(EINVAL); } frame->pkt_pts = avctx->pkt ? avctx->pkt->pts : AV_NOPTS_VALUE; frame->reordered_opaque = avctx->reordered_opaque; #if FF_API_GET_BUFFER if (avctx->get_buffer) { CompatReleaseBufPriv *priv = NULL; AVBufferRef *dummy_buf = NULL; int planes, i, ret; if (flags & AV_GET_BUFFER_FLAG_REF) frame->reference = 1; ret = avctx->get_buffer(avctx, frame); if (ret < 0) return ret; if (frame->buf[0]) return 0; priv = av_mallocz(sizeof(*priv)); if (!priv) { ret = AVERROR(ENOMEM); goto fail; } priv->avctx = *avctx; priv->frame = *frame; dummy_buf = av_buffer_create(NULL, 0, compat_free_buffer, priv, 0); if (!dummy_buf) { ret = AVERROR(ENOMEM); goto fail; } #define WRAP_PLANE(ref_out, data, data_size) \ do { \ AVBufferRef *dummy_ref = av_buffer_ref(dummy_buf); \ if (!dummy_ref) { \ ret = AVERROR(ENOMEM); \ goto fail; \ } \ ref_out = av_buffer_create(data, data_size, compat_release_buffer, \ dummy_ref, 0); \ if (!ref_out) { \ av_frame_unref(frame); \ ret = AVERROR(ENOMEM); \ goto fail; \ } \ } while (0) if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); if (!desc) { ret = AVERROR(EINVAL); goto fail; } planes = (desc->flags & PIX_FMT_PLANAR) ? desc->nb_components : 1; for (i = 0; i < planes; i++) { int h_shift = (i == 1 || i == 2) ? desc->log2_chroma_h : 0; int plane_size = (frame->width >> h_shift) * frame->linesize[i]; WRAP_PLANE(frame->buf[i], frame->data[i], plane_size); } } else { int planar = av_sample_fmt_is_planar(frame->format); planes = planar ? avctx->channels : 1; if (planes > FF_ARRAY_ELEMS(frame->buf)) { frame->nb_extended_buf = planes - FF_ARRAY_ELEMS(frame->buf); frame->extended_buf = av_malloc(sizeof(*frame->extended_buf) * frame->nb_extended_buf); if (!frame->extended_buf) { ret = AVERROR(ENOMEM); goto fail; } } for (i = 0; i < FFMIN(planes, FF_ARRAY_ELEMS(frame->buf)); i++) WRAP_PLANE(frame->buf[i], frame->extended_data[i], frame->linesize[0]); for (i = 0; i < planes - FF_ARRAY_ELEMS(frame->buf); i++) WRAP_PLANE(frame->extended_buf[i], frame->extended_data[i + FF_ARRAY_ELEMS(frame->buf)], frame->linesize[0]); } av_buffer_unref(&dummy_buf); return 0; fail: avctx->release_buffer(avctx, frame); av_freep(&priv); av_buffer_unref(&dummy_buf); return ret; } #endif return avctx->get_buffer2(avctx, frame, flags); }
1threat
static void string_output_free(Visitor *v) { StringOutputVisitor *sov = to_sov(v); string_output_visitor_cleanup(sov); }
1threat
uint64_t hbitmap_serialization_granularity(const HBitmap *hb) { assert(hb->granularity < 64 - 6); return UINT64_C(64) << hb->granularity; }
1threat
JQuery What is core.js (in jQuery 3.3.1) : <p>I just downloaded the latest version of jQuery via <code>npm install jquery</code> and it includes three uncompressed files namely:</p> <pre><code>dist/core.js dist/jquery.js dist/jquery.slim.js </code></pre> <p><strong>I'm wondering what the core.js file is</strong> and couldn't find anything documented about it. A google search on <strong>core.js</strong> and <strong>jquery core.js</strong> don't return relevant answers.</p> <p>Also, I don't see any core.min.js. So what is it? Would I ever use it? </p> <p>NOTE: It uses define() which requires an AMD loader (see <a href="https://requirejs.org/docs/whyamd.html#definition" rel="noreferrer">https://requirejs.org/docs/whyamd.html#definition</a> ) so it can't just be included straight into an html file.</p> <p>One jQuery CDN is at <a href="https://code.jquery.com" rel="noreferrer">https://code.jquery.com</a>, but it doesn't include core.js (from what I saw).</p> <p>Looking at the code it only defines a small number of functions some of which are:</p> <pre><code>extend, each, map, slice, first, last, eq, end </code></pre> <p>It looks like these are <strong>also</strong> defined in jquery.js and jquery.slim.js.</p> <p>The jQuery documentation for <strong>core</strong> at <a href="https://api.jquery.com/category/core/" rel="noreferrer">https://api.jquery.com/category/core/</a> doesn't match what is in the core.js file.</p>
0debug
Suggest me best validation package for API in NodeJs : <p>I previously works in laravel and inbuilt library of laravel is very efficient for handle all kind of errors. is ther any library in node also which handle most of errors with proper code structure - I don't like code structure like below -</p> <pre><code>check('price').not().isEmpty().withMessage('must not empty').isInt().withMessage("Must be a Integer") </code></pre>
0debug
Cannot modify example for ESP8266 provided by espressif : <p>My setup consists of the Espressif SDK using eclipse and a nodemcu, which I want to program in C.</p> <p>I have followed all he steps and I can compile and flash the board from the eclipse environment. I don't press any buttons to load the flash because the board can handle it by itself (at least that's what I read). According to <a href="http://www.cnx-software.com/2015/10/29/getting-started-with-nodemcu-board-powered-by-esp8266-wisoc/">this</a> apparently I have a nodemcu 0.9, but the board I have doesn't look quite like the one in the picture (the microstrip antenna looks weird .. and on the back of the board it says www.doit.am ESP12E devkit V2 ... the antenna on mine doesn't even look like the one on the site listed behind the board).</p> <p>I looked past everything and kept on going. I compiled the blinky example on espressif and flashed it. I saw that it created the eagle.flash.bin and eagle.irom0text.bin and loads them in 0x00000 and 0x10000 respectively (according to documents I've read this is ok). When i reset the board I can see that it really flashed and there is a program in it since the led is blinking. Then I tried the hello_world example. Everything went accordingly and after I reset the board I see that the led keeps on blinking at the same frequency and when I connect to the board via the terminal.exe provided by espressif I can only see garbage in the output, even though the baud is correct according to the code (even so I tried all different bauds possible in terminal.exe).</p> <p>Ok ... then I went to the blinky example again and increased the delay between blinks. Flashed it and the the frequency stayed the same. I know that it created new .bin files, but still, nothing changed. This led me to create a new project. I did it, following the instructions provided by Mikhail Grigorev. I just put an infinite loop, expecting to get nothing, but after flashing the newly compiled firmware I can still see the led blinking at the same frequency even though there is absolutely nothing in the code, I even wiped the flash before (yes, I verified the flash was empty).</p> <p>So this lead me to test every single example I could compile. I noticed that some didn't blink the led and others did, like nothing happened. After that i downloaded the nodemcu firmware, and after loading it I noticed that it worked properly and I could even see the ESP in the available wifi networks.</p> <p>I really don't understand what's happening. Why do some examples work and others don't? Why can't I modify the source code of a simple blinky and see the change? I really prefer to use the esp module this way, since I don't like the arduino interface or the way that it uses a static setup and loop functions, and I don't want to program it in LUA.</p> <p>I even checked the makefiles provided by espressif and the only difference I can see are the BOOT and APP variables. I even tried modifying them, but still .. no changes. </p> <p>Can anybody help me?</p>
0debug
static void envelope_peak16(WaveformContext *s, AVFrame *out, int plane, int component) { const int dst_linesize = out->linesize[component] / 2; const int bg = s->bg_color[component] * (s->size / 256); const int limit = s->size - 1; const int is_chroma = (component == 1 || component == 2); const int shift_w = (is_chroma ? s->desc->log2_chroma_w : 0); const int shift_h = (is_chroma ? s->desc->log2_chroma_h : 0); const int dst_h = FF_CEIL_RSHIFT(out->height, shift_h); const int dst_w = FF_CEIL_RSHIFT(out->width, shift_w); const int start = s->estart[plane]; const int end = s->eend[plane]; int *emax = s->emax[plane][component]; int *emin = s->emin[plane][component]; uint16_t *dst; int x, y; if (s->mode) { for (x = 0; x < dst_w; x++) { for (y = start; y < end && y < emin[x]; y++) { dst = (uint16_t *)out->data[component] + y * dst_linesize + x; if (dst[0] != bg) { emin[x] = y; break; } } for (y = end - 1; y >= start && y >= emax[x]; y--) { dst = (uint16_t *)out->data[component] + y * dst_linesize + x; if (dst[0] != bg) { emax[x] = y; break; } } } if (s->envelope == 3) envelope_instant16(s, out, plane, component); for (x = 0; x < dst_w; x++) { dst = (uint16_t *)out->data[component] + emin[x] * dst_linesize + x; dst[0] = limit; dst = (uint16_t *)out->data[component] + emax[x] * dst_linesize + x; dst[0] = limit; } } else { for (y = 0; y < dst_h; y++) { dst = (uint16_t *)out->data[component] + y * dst_linesize; for (x = start; x < end && x < emin[y]; x++) { if (dst[x] != bg) { emin[y] = x; break; } } for (x = end - 1; x >= start && x >= emax[y]; x--) { if (dst[x] != bg) { emax[y] = x; break; } } } if (s->envelope == 3) envelope_instant16(s, out, plane, component); for (y = 0; y < dst_h; y++) { dst = (uint16_t *)out->data[component] + y * dst_linesize + emin[y]; dst[0] = limit; dst = (uint16_t *)out->data[component] + y * dst_linesize + emax[y]; dst[0] = limit; } } }
1threat
php mysqli search db hat contains using % Wildcard : I have looked up many responses on hear in regards to searching using LIKE % and also CONCAT but they are not working for me. Basically i am trying to find in the database words like % "Croyden" and "Surrey" The below script works fine, however I want to use % for words that contain "Croyden" and "Surrey". I have tried various ways but nothing work. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> $locTown = "Croydon"; $locCounty = "Surrey"; if ($stmt = mysqli_prepare($link, 'SELECT locTown, locCounty FROM location where locTown LIKE ? AND locCounty LIKE ? ')) { mysqli_stmt_bind_param($stmt, "ss", $locTown, $locCounty); mysqli_stmt_execute($stmt); mysqli_stmt_bind_result($stmt, $locTown, $locCounty); /* fetch value */ mysqli_stmt_fetch($stmt); while (mysqli_stmt_fetch($stmt)) { } echo "Location: $locTown - $locCounty\n"; /* close statement */ mysqli_stmt_close($stmt); } mysqli_close($link); ?> <!-- end snippet -->
0debug
Java 8 LocalDate - How do I get all dates between two dates? : <p>Is there a usablility to get <strong>all dates between two dates</strong> in the new <code>java.time</code> API?</p> <p>Let's say I have this part of code:</p> <pre><code>@Test public void testGenerateChartCalendarData() { LocalDate startDate = LocalDate.now(); LocalDate endDate = startDate.plusMonths(1); endDate = endDate.withDayOfMonth(endDate.lengthOfMonth()); } </code></pre> <p>Now I need all dates between <code>startDate</code> and <code>endDate</code>.</p> <p>I was thinking to get the <code>daysBetween</code> of the two dates and iterate over:</p> <pre><code>long daysBetween = ChronoUnit.DAYS.between(startDate, endDate); for(int i = 0; i &lt;= daysBetween; i++){ startDate.plusDays(i); //...do the stuff with the new date... } </code></pre> <p>Is there a better way to get the dates?</p>
0debug
Use Derived/Temporary column in Where Clause : <p>Here Is my query. The Issue is that I am trying to apply the derived 'LineNo' field as the where clause. The query below does not work. Simply put, if the Value of a LineHrs column is > 0 it will set this derived column to a given value (eg If Line5Hrs = 1.4 then 'LineNo' for the row = 'Line 5'). I want to use this value to search for all jobs on a specific line.</p> <pre><code>SELECT tblA.PROJECT_ID, tblB.Line1Hrs, tblB.Line2Hrs, tblB.Line3Hrs, tblB.Line4Hrs, tblB.Line5Hrs, tblB.Line6Hrs, tblB.Line7Hrs, "LineNo" = CASE WHen tblB.Line1Hrs &gt; 0 Then 'Line1' WHen tblB.Line2Hrs &gt; 0 Then 'Line2' WHen tblB.Line3Hrs &gt; 0 Then 'Line3' WHen tblB.Line4Hrs &gt; 0 Then 'Line4' WHen tblB.Line5Hrs &gt; 0 Then 'Line5' WHen tblB.Line6Hrs &gt; 0 Then 'Line6' WHen tblB.Line7Hrs &gt; 0 Then 'Line7' End FROM tblA INNER JOIN tblB ON tblA.blah = tblB.blah AND tblA.blab = tblB.blab WHERE LineNo = 'Line5' </code></pre>
0debug
static char *shorts2str(int *sp, int count, const char *sep) { int i; char *ap, *ap0; if (!sep) sep = ", "; ap = av_malloc((5 + strlen(sep)) * count); if (!ap) return NULL; ap0 = ap; ap[0] = '\0'; for (i = 0; i < count; i++) { int l = snprintf(ap, 5 + strlen(sep), "%d%s", sp[i], sep); ap += l; } ap0[strlen(ap0) - strlen(sep)] = '\0'; return ap0; }
1threat
static int seek_frame_generic(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { int index; int64_t ret; AVStream *st; AVIndexEntry *ie; st = s->streams[stream_index]; index = av_index_search_timestamp(st, timestamp, flags); if(index < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp) return -1; if(index < 0 || index==st->nb_index_entries-1){ AVPacket pkt; int nonkey=0; if(st->nb_index_entries){ assert(st->index_entries); ie= &st->index_entries[st->nb_index_entries-1]; if ((ret = avio_seek(s->pb, ie->pos, SEEK_SET)) < 0) return ret; ff_update_cur_dts(s, st, ie->timestamp); }else{ if ((ret = avio_seek(s->pb, s->data_offset, SEEK_SET)) < 0) return ret; } for (;;) { int read_status; do{ read_status = av_read_frame(s, &pkt); } while (read_status == AVERROR(EAGAIN)); if (read_status < 0) break; av_free_packet(&pkt); if(stream_index == pkt.stream_index && pkt.dts > timestamp){ if(pkt.flags & AV_PKT_FLAG_KEY) break; if(nonkey++ > 1000){ av_log(s, AV_LOG_ERROR,"seek_frame_generic failed as this stream seems to contain no keyframes after the target timestamp, %d non keyframes found\n", nonkey); break; } } } index = av_index_search_timestamp(st, timestamp, flags); } if (index < 0) return -1; ff_read_frame_flush(s); AV_NOWARN_DEPRECATED( if (s->iformat->read_seek){ if(s->iformat->read_seek(s, stream_index, timestamp, flags) >= 0) return 0; } ) ie = &st->index_entries[index]; if ((ret = avio_seek(s->pb, ie->pos, SEEK_SET)) < 0) return ret; ff_update_cur_dts(s, st, ie->timestamp); return 0; }
1threat
Robo 3T Error : Network is unreachable : <p>I am trying to connect Robo 3T to my online database and it doesn't seem to be working. I am able to connect to local database with it. I tried connecting using MongoDB Compass and the Details and Auth are working fine and I am able to connect. But when I connect with the same details in Robo 3T, it doesn't seem to be working. How do I fix this? I am using Robo 3T Version 1.1 I tried same with Robomongo 1.0, and still getting the same error</p> <p><a href="https://i.stack.imgur.com/RNwQ2.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/RNwQ2.jpg" alt="Error Dialog"></a></p>
0debug
I want to create an array of objects at runtime : <p>I am creating a version of the Tower of Hanoi puzzle. The way it is represented in the Unity hierarchy is</p> <p>-Game Objects<br> -----PegA<br> ---------Arm<br> ---------Base<br></p> <p>Sorry I didn't know how to represent the hierarchy.</p> <p>There are 3 "pegs" and have 7 "rings" as objects in the scene. The pegs and rings are on the same level in the hierarchy.</p> <p>It is obvious that I can "SerializeField" the ring class and just click and drag each Peg onto them in the inspector but what I want to do is just add them at runtime in the code. This is what I tried.</p> <p>This is part of my ring class</p> <pre><code>public class ring : MonoBehaviour { public bool locked, resting; private float startX, startY, deltaX, deltaY; private Vector3 mousePos, beforeDrag; private List&lt;GameObject&gt; pegs; // Start is called before the first frame update void Start() { startX = transform.position.x; startY = transform.position.y; locked = false; pegs.Add(GameObject.Find("PegA")); pegs.Add(GameObject.Find("PegB")); pegs.Add(GameObject.Find("PegC")); } } </code></pre> <p>The error I'm getting is "Object reference not set to an instance of an object"</p> <p>Can someone possibly explain?</p>
0debug
Custom sort based on 3 objects : <p>I would like to sort a 2D array based on the similarity between elements compared to the element at index 0.</p> <p>How is a custom sort function defined that can use the external 3rd object, the element at index 0?</p> <p>The compare function needs to do the following</p> <pre><code>bool compare(float *a, float *b) { float *source = 2DArray[0]; return distance(source, a) &gt; distance(source, b); } </code></pre> <p>when calling it </p> <pre><code>std::sort(std::begin(2DArray), std::end(2DArray), compare); </code></pre> <p>there is obviously no access to 2DArray.</p> <p>How can this be written so that an object can call a function to call the sort function and give access to the 2DArray[0]?</p>
0debug
static void bdrv_qed_refresh_limits(BlockDriverState *bs, Error **errp) { BDRVQEDState *s = bs->opaque; bs->bl.write_zeroes_alignment = s->header.cluster_size >> BDRV_SECTOR_BITS; }
1threat
How to read values from the querystring with ASP.NET Core? : <p>I'm building one RESTful API using ASP.NET Core MVC and I want to use querystring parameters to specify filtering and paging on a resource that returns a collection.</p> <p>In that case, I need to read the values passed in the querystring to filter and select the results to return. </p> <p>I've already found out that inside the controller <code>Get</code> action accessing <code>HttpContext.Request.Query</code> returns one <code>IQueryCollection</code>.</p> <p>The problem is that I don't know how it is used to retrieve the values. In truth, I thought the way to do was by using, for example</p> <pre><code>string page = HttpContext.Request.Query["page"] </code></pre> <p>The problem is that <code>HttpContext.Request.Query["page"]</code> doesn't return a string, but a <code>StringValues</code>.</p> <p>Anyway, how does one use the <code>IQueryCollection</code> to actually read the querystring values?</p>
0debug
Python mathematical operators sequence : <pre><code>a=0 b=5 </code></pre> <p>And when we try to get result of this:</p> <pre><code>print str((23-11)/a*b) </code></pre> <p>We get the divide by zero error.</p> <blockquote> <p>Traceback (most recent call last): File "", line 1, in print str((23-11)/a*b) ZeroDivisionError: integer division or modulo by zero But if we change positions: </p> </blockquote> <pre><code>print str((23-11)/b*a) </code></pre> <p>The result is zero:</p> <blockquote> <p>0</p> </blockquote> <p>Should we get always divide y zero error (because (b*a) is zero)?</p>
0debug
Use Project Reference in Debug and Nuget in Release : <p>I would like to work in my project (A) and a dependent Nuget package (B) at the same time, without the need to release the nuget package on each change.</p> <p>Is it possible to do a project-reference the Nuget project (B) from the Solution (A) when building Debug. And when building Release use the Nuget package from Source?</p>
0debug
How to insert an item every x position using std C++? : <p>I have the following vector:</p> <pre><code> std::vector&lt;int&gt; v = {1,1,1,1,1,1,1,1,1,1,1,1}; </code></pre> <p>I would like to insert 9 every 3 positions </p> <pre><code> w = {1,1,1,9,1,1,1,9,1,1,1,9,1,1,1,9}; </code></pre> <p>Could you provide a oneliner using std algorithm in c++ ? </p>
0debug
Adding to an Array in C/C++ with no size : <p>The following code compiles and outputs <code>6</code>:</p> <pre><code>#include &lt;stdio.h&gt; int main(){ int a[]={}; a[0] = 5; a[1] = 6; printf("%d\n", a[1]); return 0; } </code></pre> <p>Is this correct or am I getting into undefined behaviour and this code woks by luck? Can I add to an array with no size?</p>
0debug
Disabling Entity Framework proxy creation : <p>From what I've read, setting <code>ProxyCreationEnabled = false</code> will prevent change tracking and lazy loading. However, I'm not clear on what change tracking covers. </p> <p>If I disable it and get an entity from the database, make changes to it and commit, then those changes are saved. I'm also still able to get modified entries from the ChangeTracker:</p> <pre><code>ChangeTracker.Entries&lt;IAuditable&gt;().Where(x =&gt; x.State == EntityState.Modified).ToList() </code></pre> <p>Should this be possible when I've disabled proxy creation? I want to disable it, but I want to be clear on what I'm disabling.</p>
0debug
How to save a javascrip event in the browser? : This pop-up window. After the client visited the site in 30 seconds, a window will automatically appear. After closing the window disappears. But when the client goes to another page, the script starts to work ( after refreshing the page). How to remember closing the modal window at the time of visiting the client's site? <div id="parent_popup"> <div id="popup"> message message message message message message message <a class="close"title="close" onclick="document.getElementById('parent_popup').style.display='none';">X</a> </div> </div> #parent_popup{ padding: 20px; background-color: rgba(0, 0, 0, 0.8); display: none; position: fixed; z-index: 99999; top: 0; right: 0; bottom: 0; left: 0; } #popup{ background: #fff; max-width: 520px; margin: 10% auto; padding: 5px 20px 13px 20px; border: 10px solid #ddd; position: relative; -webkit-box-shadow: 0px 0px 20px #000; -moz-box-shadow: 0px 0px 20px #000; box-shadow: 0px 0px 20px #000; -webkit-border-radius: 15px; -moz-border-radius: 15px; border-radius: 15px; } .close{ background-color: rgba(0, 0, 0, 0.8); border: 2px solid #ccc; height: 24px; line-height: 24px; position: absolute; right: -24px; cursor: pointer; font-weight: bold; text-align: center; text-decoration: none; color: rgba(255, 255, 255, 0.9); font-size: 14px; text-shadow: 0 -1px rgba(0, 0, 0, 0.9); top: -24px; width: 24px; -webkit-border-radius: 15px; -moz-border-radius: 15px; -ms-border-radius: 15px; -o-border-radius: 15px; border-radius: 15px; -moz-box-shadow: 1px 1px 3px #000; -webkit-box-shadow: 1px 1px 3px #000; box-shadow: 1px 1px 3px #000; } .close:hover{ background-color: rgba(0, 122, 200, 0.8); } <script type="text/javascript"> var delay_popup = 5000;setTimeout("document.getElementById('parent_popup').style.display='block'", delay_popup); </script>
0debug
How can this button is developed in android : This button has outer white boundary and inner grey background. The inner background contains an image(right tick) and a text(Apply). https://files.slack.com/files-tmb/T0AHMUM8E-F1G9Y8U94-5bfa307623/screenshot_2016-06-13-16-02-01_720.png I am able to make a shape like this (below). https://files.slack.com/files-pri/T0AHMUM8E-F1GAD8FHP/screenshot_2016-06-13-16-09-52.png I am using a shape in drawable(button.xml) given below <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="oval"> <size android:height="85dp" android:width="90dp"/> <solid android:color="@color/grey"/> <stroke android:color="@color/white" android:width="4dp"></stroke> </shape> </item> <item android:drawable="@drawable/checkmark_filled" android:bottom="20dp" android:left="20dp" android:right="20dp" android:top="20dp"/> </layer-list> and using imageview to use the shape <ImageView android:id="@+id/button_apply" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/button"/> but i am not able to make a text in shape. Am i missing something or is there any way possible?? please help.
0debug
Bind an amp-state's initial value : <p>I want to initialise an amp-state as follows:</p> <pre><code>&lt;amp-state id="tabs"&gt; &lt;script type="application/json"&gt; { "selected": "latest" } &lt;/script&gt; &lt;/amp-state&gt; </code></pre> <p>Then have this initialised value shown on first page request:</p> <pre><code>&lt;p [text]="tabs.selected"&gt;&lt;p&gt; </code></pre> <p>This doesn't work. The contents of the p tag are only updated when there is a state change. Eg from a button:</p> <pre><code>&lt;button on="tap:AMP.setState({tabs: {selected: 'top'}})"&gt;Press me&lt;/button&gt; </code></pre> <p>I would like elements on the page to reflect the initialised state before further user interaction.</p> <p>Codepen: <a href="https://codepen.io/powlo/pen/VMpVRm/?editors=1000" rel="noreferrer">https://codepen.io/powlo/pen/VMpVRm/?editors=1000</a></p>
0debug
def sorted_dict(dict1): sorted_dict = {x: sorted(y) for x, y in dict1.items()} return sorted_dict
0debug
I have a 1* vector created with a symbol in matlab. Because of the symbol (x) all values are converted to integers such as : I have a 1*1 vector created with a symbol in Matlab. Because of the symbol (t) all values are converted to integers such as (142731759660517923771*exp(t))/2814749767106560000 - (2384496775230702879947559372750244401*exp(2*t))/30948500982134506872478105600000000 But I want this expression as 50.7085*exp(t)- 77.0472*exp(2*t)
0debug
int spapr_h_cas_compose_response(sPAPRMachineState *spapr, target_ulong addr, target_ulong size, sPAPROptionVector *ov5_updates) { void *fdt, *fdt_skel; sPAPRDeviceTreeUpdateHeader hdr = { .version_id = 1 }; if (spapr_hotplugged_dev_before_cas()) { return 1; size -= sizeof(hdr); fdt_skel = g_malloc0(size); _FDT((fdt_create(fdt_skel, size))); _FDT((fdt_begin_node(fdt_skel, ""))); _FDT((fdt_end_node(fdt_skel))); _FDT((fdt_finish(fdt_skel))); fdt = g_malloc0(size); _FDT((fdt_open_into(fdt_skel, fdt, size))); g_free(fdt_skel); _FDT((spapr_fixup_cpu_dt(fdt, spapr))); if (spapr_dt_cas_updates(spapr, fdt, ov5_updates)) { return -1; _FDT((fdt_pack(fdt))); if (fdt_totalsize(fdt) + sizeof(hdr) > size) { trace_spapr_cas_failed(size); return -1; cpu_physical_memory_write(addr, &hdr, sizeof(hdr)); cpu_physical_memory_write(addr + sizeof(hdr), fdt, fdt_totalsize(fdt)); trace_spapr_cas_continue(fdt_totalsize(fdt) + sizeof(hdr)); g_free(fdt); return 0;
1threat
setTimeout in javascript executing timeout code right away and not waiting : <p>I have the following line in my javascript code</p> <pre><code>setTimeout(reload(), 30000); </code></pre> <p>Which I expect to wait 30 seconds then call the reload function. </p> <p>The issue is that the reload function is being called right away and not waiting for the timeout, why is the <code>setTimeout</code> calling the reload function right away and not waiting the specified amount of time? The <code>setTimeout</code> call is also being done in an <code>onloadend</code> <code>FileReader</code> function if that would make any difference.</p>
0debug
void address_space_sync_dirty_bitmap(AddressSpace *as) { FlatView *view; FlatRange *fr; view = as->current_map; FOR_EACH_FLAT_RANGE(fr, view) { MEMORY_LISTENER_UPDATE_REGION(fr, as, Forward, log_sync); } }
1threat
How to use funcion inside other function? : I dont know how to make function 'bot_turn' work after function 'player_turn' Maybe there are some problems with two 'while' functions <!DOCTYPE html> <html> <head> <meta charset ="utf-8"> <title>Tic Tac Toe</title> </head> <body> <script type="text/javascript"> var asasa=0; var lal=-1; var end_game=0; var asass=0 </script> <table border='1px' width='500px' height='500px' align="center"> <tr> <td id='tables1' class="one" style="font-size: 50px; text-align:center;" onclick="this.style.backgroundColor = '#045d99';asasa=1; player_turn(); "></td> <td id='tables2' class="two" style="font-size: 50px; text-align:center;" onclick="this.style.backgroundColor = '#045d99';asasa=2; player_turn();"></td> <td id='tables3' class="three" style="font-size: 50px; text-align:center;" onclick="this.style.backgroundColor = '#045d99';asasa=3; player_turn();"></td> </tr> <tr style='border-color: red'> <td id='tables4' class="four" style="font-size: 50px; text-align:center;" onclick="this.style.backgroundColor = '#045d99';asasa=4; player_turn(); " ></td> <td id='tables5' class="five" style="font-size: 50px; text-align:center;" onclick="this.style.backgroundColor = '#045d99';asasa=5; player_turn();"></td> <td id='tables6' class="six" style="font-size: 50px; text-align:center;" onclick="this.style.backgroundColor = '#045d99';asasa=6; player_turn();"></td> </tr> <tr style='border-color: red'> <td id='tables7' class="seven" style="font-size: 50px; text-align:center;" onclick="this.style.backgroundColor = '#045d99';asasa=7; player_turn();"></td> <td id='tables8' class="eight" style="font-size: 50px; text-align:center;" onclick="this.style.backgroundColor = '#045d99';asasa=8; player_turn();"></td> <td id='tables9' class="nine" style="font-size: 50px; text-align:center;" onclick="this.style.backgroundColor = '#045d99';asasa=9; player_turn();"></td> </tr> <script type="text/javascript"> asasa=0; function player_turn() { if (document.getElementById('tables1').className == 'one' & asasa==1) { document.getElementById('tables1').className = 'none' alert("Bot turn") end_game=end_game+1; bot_turn() } else if (document.getElementById('tables2').className == 'two' && asasa==2) { document.getElementById('tables2').className = 'none' alert("Bot turn") end_game=end_game+1; bot_turn() } else if (document.getElementById('tables3').className == 'three' && asasa==3) { document.getElementById('tables3').className = 'none' alert("Bot turn") end_game=end_game+1; bot_turn() } else if (document.getElementById('tables4').className == 'four' && asasa==4) { document.getElementById('tables4').className = 'none' alert("Bot turn") end_game=end_game+1; bot_turn() } else if (document.getElementById('tables5').className == 'five' && asasa==5) { document.getElementById('tables5').className = 'none' alert("Bot turn") end_game=end_game+1; bot_turn() } else if (document.getElementById('tables6').className == 'six' && asasa==6) { document.getElementById('tables6').className = 'none' alert("Bot turn") end_game=end_game+1; bot_turn() } else if (document.getElementById('tables7').className == 'seven' && asasa==7) { document.getElementById('tables7').className = 'none' alert("Bot turn") end_game=end_game+1; bot_turn() } else if (document.getElementById('tables8').className == 'eight' && asasa==8) { document.getElementById('tables8').className = 'none' alert("Bot turn") end_game=end_game+1; bot_turn() } else if (document.getElementById('tables9').className == 'nine' && asasa==9) { document.getElementById('tables9').className = 'none' alert("Bot turn") end_game=end_game+1; bot_turn() } console.log(asasa) } var randomik=0; function bot_turn() { while (asass=0) { lal=0 while (lal=0) { randomik=Math.floor((Math.random() * 9) + 1); console.log(randomik) if (randomik==1) { if(document.getElementById('tables1').className == 'one') { document.getElementById('tables1').className = 'none' document.getElementById('tables1').style.backgroundColor = '#FF2400' alert("Player turn") lal=1 end_game+=1 } } else if (randomik==2) { if(document.getElementById('tables2').className == 'two') { document.getElementById('tables2').className = 'none' document.getElementById('tables2').style.backgroundColor = '#FF2400' alert("Player turn") lal=1; end_game+=1 } } else if (randomik==3) { if(document.getElementById('tables3').className == 'three') { document.getElementById('tables3').className = 'none' document.getElementById('tables3').style.backgroundColor = '#FF2400' alert("Player turn") lal=1; end_game+=1 } } else if (randomik==4) { if(document.getElementById('tables4').className == 'four') { document.getElementById('tables4').className = 'none' document.getElementById('tables4').style.backgroundColor = '#FF2400' alert("Player turn") lal=1; end_game+=1 } } else if (randomik==5) { if(document.getElementById('tables5').className == 'five') { document.getElementById('tables5').className = 'none' document.getElementById('tables5').style.backgroundColor = '#FF2400' alert("Player turn") lal=1; end_game+=1 } } else if (randomik==6) { if(document.getElementById('tables6').className == 'six') { document.getElementById('tables6').className = 'none' document.getElementById('tables6').style.backgroundColor = '#FF2400' alert("Player turn") lal=1; end_game+=1 } } else if (randomik==7) { if(document.getElementById('tables7').className == 'seven') { document.getElementById('tables7').className = 'none' document.getElementById('tables7').style.backgroundColor = '#FF2400' alert("Player turn") lal=1; end_game+=1 } } else if (randomik==8) { if(document.getElementById('tables8').className == 'eight') { document.getElementById('tables8').className = 'none' document.getElementById('tables8').style.backgroundColor = '#FF2400' alert("Player turn") lal=1; end_game+=1 } } else if (randomik==9) { if(document.getElementById('tables9').className == 'nine') { document.getElementById('tables9').className = 'none' document.getElementById('tables9').style.backgroundColor = '#FF2400' alert("Player turn") lal=1; end_game+=1 } } else if (end_game==9) { asass=1 alert('It works!') } } } } </script> </body> </html> When i click bot must choose another cell where i hadnt click and paint it in red. When all cells are painted alert "It works!" should appear and random numbers in consol must stop generating.
0debug
JS array group items by comparing items : i have array like this var oArr = [ { id: "d1", x: 2, y: 2 }, { id: "d1", x: 3, y: 3 }, { id: "d1", x: 5, y: 3 }, { id: "d1", x: 5, y: 7 }, { id: "d1", x: 3, y: 6 }, ]; i want to subtract all items' "y" properties to each other and test if it is smaller then the given threshold value.And finally group items in nested-arrays... var threshold =2; So my expected output is var result= [ [ { id: "d1", x: 2, y: 2 },{ id: "d1", x: 3, y: 3 }, { id: "d1", x: 5, y: 3 }], [ { id: "d1", x: 5, y: 7 }, { id: "d1", x: 3, y: 6 }] ]; in the second part of the problem , i want to find minimum y value of each item and reduce array to 2 elements. My second expected output var result= [ { id: "d1", x: 2, y: 2 }, { id: "d1", x: 3, y: 6 }] ]; Second part is reather simple(reduce/filter and Math.min).My main problem is first part. Any suggestion or advice would be appriciated
0debug
void helper_icbi(target_ulong addr) { addr &= ~(env->dcache_line_size - 1); ldl(addr); tb_invalidate_page_range(addr, addr + env->icache_line_size); }
1threat
Golang to iterate over N files concurrently inorder to count occurence of unique word : This is my code written in Golang to count the occurrence of all the unique word in a file: `package main import ( "bufio" "fmt" "log" "os" ) func main(){ file, err := os.Open("file1.txt") if err != nil { log.Fatal(err) } words := make(map[string]int) /*asking scanner to split into words*/ scanner := bufio.NewScanner(file) scanner.Split(bufio.ScanWords) count := 0 //scan the inpurt for scanner.Scan() { //get input token - in our case a word and update it's frequence words[scanner.Text()]++ count++ } if err := scanner.Err(); err != nil { fmt.Fprintln(os.Stderr, "reading input:", err) } for k, v := range words { fmt.Printf("%s:%d\n", k, v) } } ` **I have to iterate this map over N files concurrently in order to calculate the occurrence of all the unique words...(PS: NOOB at Golang and this is my first program)**
0debug
How to disable user interaction on SwiftUI view? : <p>Let's say I have a SwiftUI view hierarchy that looks like this:</p> <pre><code>ZStack() { ScrollView { ... } Text("Hello.") } </code></pre> <p>The <code>Text</code> view blocks touch events from reaching the underlying <code>ScrollView</code>.</p> <p>With UIKit, I'd use something like <code>.isUserInteractionEnabled</code> to control this, but I can't find any way to do this with SwiftUI.</p> <p>I've tried adding a <code>Gesture</code> with a <code>GestureMask</code> of <code>.none</code> on the text view, but that doesn't seem to work.</p> <p>I hope I'm missing something obvious here, because I need to put some status information on top of the scroll view. </p>
0debug
HTML/PHP redirect to page with parameter when link doesn't exist : I'm trying to program an URL Shortener in the style of [bitLY][1], but I don't know how to redirect a user to a given site if he uses the shortened Link in a style of sampleurl.com/[ID here] **Example:** A user generates a short version for youtube.com let's say the ID is qzUdijE now I want that another user is able to visit sampleurl.com/qzUdijE for being redirected to youtube.com (I save the ID (in this case 'qzUdijE') together with the URL (in this case 'youtube.com') in a Database.) Thanks for all answers. (Sorry for bad English, I'm german) ~ justMarvin [1]: https://bit.ly/
0debug
How to reinitialize SIM card from application? : <p>I have a problem writing application for android phone. I need my app to reinitialize all data from SIM card onto a phone - so it would be like a restart without a restart of the phone itself.</p> <p>I know that going to plane mode and back does not help - it has to be like the real restart. How can I achive it from the app?</p>
0debug
C# Array Difrent indexes : Hi i want to search for Charracter in string array but i need to search Betwwen 2 indexes for example between index 2 to 10 how can i do that? foreach (var item in currentline[2 to 10]) { if (item == ',' || item == ';') { c++; break; } else { data += item; c++; } }
0debug
Write a program in java to print the sum of all numbers from 50 to 250(inclusive of 50 and 250) that are multiples of 3 and not divisible by 9. : /* when I run this code there is no error in fact output generated is also correct but I want to know what is the logical error in this code? please can any one explain what is the logical error. */ class abc { public static void main(String arg[]){ int sum=0; //for-loop for numbers 50-250 for(int i=50;i<251;i++){ // condition to check if number should be divided by 3 and not divided by 9 if(i%3==0 & i%9!=0){ //individual number which are selected in loop System.out.println(i); //adding values of array so that total sum can be calculated sum=sum+i; } } //final display output for the code System.out.println("the sum of intergers from 50 to 250 that are multiples of 3 and not divisible by 9 \n"+sum); } }
0debug
Transition error when checking-in work item for VS2015 : <p>Here's the error I was getting in VS2015: "One or more checked work items failed the transition testing due to invalid field values. Please correct the values and retry the check-in."</p>
0debug
void helper_set_alarm(CPUAlphaState *env, uint64_t expire) { if (expire) { env->alarm_expire = expire; qemu_mod_timer(env->alarm_timer, expire); } else { qemu_del_timer(env->alarm_timer); } }
1threat
bool bdrv_debug_is_suspended(BlockDriverState *bs, const char *tag) { while (bs && bs->drv && !bs->drv->bdrv_debug_is_suspended) { bs = bs->file; } if (bs && bs->drv && bs->drv->bdrv_debug_is_suspended) { return bs->drv->bdrv_debug_is_suspended(bs, tag); } return false; }
1threat
Array elements getting lost between server and browser : <p>I have a Java Tomcat server that sends an array to a browser where it will be displayed in a table. This was all working perfectly until I added two more elements to the array, and now those two elements never make it to the browser. I can list out in the log all of the elements before they leave the server and they're all there. But when I look at the array in the browser after the ajax call, the new elements are missing. ???</p>
0debug
Find specific subfolder in VB.NET? : So currently I have an area on a shared network containing subfolders of each product. So right now my hierarchy of folders looks like this: Test Root Folder <--- This is my master folder Category 1 Product 1 <--- this is the folder I'm trying to find Product 2 Product 3 Category 2 Product 6 Product 7 Category 3 Category 4 Product 12 The product folders are always in this format "1234 - Product 1", Normally when I'm searching for it I know the beginning so I know the '1234' in this instance however I'm not sure what category it is in nor what the title 'Product 1' is only the 1234. **How can I automate this search?** Right now I've got a textbox1 for the '1234' a button to click to enable a search and a textbox2 for a hyperlink opening that subfolder so I can access the files inside.
0debug
`This` is undefined in vue.js watcher : <p>I have component with watcher</p> <pre><code>props: { propShow: { required: true, type: Boolean } }, data() { return { show: this.propShow } }, watch: { propShow: { handler: (val, oldVal) =&gt; { this.show = val; } } } </code></pre> <p>Whenever <code>parent</code> component changes <code>propShow</code> this component must update it's <code>show</code> property. <code>This</code> component also modifies <code>show</code> property, that's why I need both: <code>show</code> and <code>propShow</code>, because Vue.js does not allow to change properties directly.</p> <p>This line</p> <pre><code>this.show = val; </code></pre> <p>causes error</p> <pre><code>TypeError: Cannot set property 'show' of undefined </code></pre> <p>because <code>this</code> inside handler is <code>undefined</code>.</p> <p>Why?</p>
0debug
static int probe_file(const char *filename) { AVFormatContext *fmt_ctx; int ret, i; if ((ret = open_input_file(&fmt_ctx, filename))) return ret; if (do_show_packets) show_packets(fmt_ctx); if (do_show_streams) for (i = 0; i < fmt_ctx->nb_streams; i++) show_stream(fmt_ctx, i); if (do_show_format) show_format(fmt_ctx); close_input_file(&fmt_ctx); return 0; }
1threat
Fortnite Tracker API Only Runs On Local Machine? : <p>I'm currently creating a bootstrap website using my Fortnite stats as data and eventually posting it on my twitch feed. However, I've managed to get it to work perfectly when I run on my local machine but when I uploaded it to my hostgator directory the site loads fine it just has no data. The error I'm getting I believe refers to my JSON file but I'm assuming the only reason this error is occurring is because there is no data in there as it's not working with the Fortnite API when ran on anything other than my local machine. Has anyone else ever experienced anything like this before?</p> <p>The Error:</p> <blockquote> <p>Source map error: SyntaxError: JSON.parse: unexpected character at line 2 column 1 of the JSON data</p> <p>Source Map URL: bootstrap.min.css.map</p> </blockquote> <p>This is my code I assume there's not much point in posting it as if it runs on my local machine logic says it's fine, right?</p> <pre><code>&lt;?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.fortnitetracker.com/v1/profile/psn/myusername"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'TRN-Api-Key: mykey' )); $response = curl_exec($ch); curl_close($ch); $fp = fopen("stats.json", "w"); fwrite($fp, $response); fclose($fp); $data = json_decode(file_get_contents("stats.json")); $solo = $data-&gt;stats-&gt;p2;//solos data $duos = $data-&gt;stats-&gt;p10;//duos data $squads = $data-&gt;stats-&gt;p9;//squads data $solo_wins = $solo-&gt;top1-&gt;valueInt; $duos_wins = $duos-&gt;top1-&gt;valueInt; $squads_wins = $squads-&gt;top1-&gt;valueInt; $solo_matches = $solo-&gt;matches-&gt;valueInt; $duos_matches = $duos-&gt;matches-&gt;valueInt; $squads_matches = $squads-&gt;matches-&gt;valueInt; $solo_kd = $solo-&gt;kd-&gt;valueDec; $duos_kd = $duos-&gt;kd-&gt;valueDec; $squads_kd = $squads-&gt;kd-&gt;valueDec; $solo_games = $solo-&gt;matches-&gt;valueInt; $duos_games = $duos-&gt;matches-&gt;valueInt; $squads_games = $squads-&gt;matches-&gt;valueInt; $solo_kills = $solo-&gt;kills-&gt;valueInt; $duos_kills = $duos-&gt;kills-&gt;valueInt; $squads_kills = $squads-&gt;kills-&gt;valueInt; ?&gt; </code></pre>
0debug
Function inside render and class in reactjs : <p>I'm trying to learn reactjs and i have some uncertainties. I was refering react DOCS and some other tutorials and i saw functions are written inside render function and also inside class. What things should we do inside render function in react?</p> <p>1st way</p> <pre><code>class App extends Component { test(user) { return user.firstName; } render() { const user = { firstName: 'Harper', lastName: 'Perez' }; return ( &lt;div&gt; &lt;h1&gt;{this.test(user)}&lt;/h1&gt; &lt;/div&gt; ) } } </code></pre> <p>2nd way</p> <pre><code>class App extends Component { render() { const user = { firstName: 'Harper', lastName: 'Perez' }; function test(user) { return user.firstName; } return ( &lt;div&gt; &lt;h1&gt;{test(user)}&lt;/h1&gt; &lt;/div&gt; ) } } </code></pre> <p>Both this methods work. But i want to know what is the best method to do this? Most importantly i want to know what kind of things i can do inside render function.</p> <p>Thanks.</p>
0debug
DisplaySurface *qemu_create_displaysurface_guestmem(int width, int height, pixman_format_code_t format, int linesize, uint64_t addr) { DisplaySurface *surface; hwaddr size; void *data; if (linesize == 0) { linesize = width * PIXMAN_FORMAT_BPP(format) / 8; } size = linesize * height; data = cpu_physical_memory_map(addr, &size, 0); if (size != linesize * height) { cpu_physical_memory_unmap(data, size, 0, 0); return NULL; } surface = qemu_create_displaysurface_from (width, height, format, linesize, data); pixman_image_set_destroy_function (surface->image, qemu_unmap_displaysurface_guestmem, NULL); return surface; }
1threat
is it possible to use JavaScriptSpellCheck in jsp pages? : <p>I would like to perform Spell Checking on textarea and like to show invalid words onchange. For this i found JavaScriptSpellCheck plugin but looks it will not support for jsp pages. is it? if, yes please suggest one good plugin to make my work easier.</p>
0debug
I wrote a php code to upload a Image file with type validation and save in folder and save path in database. but getting error. Here is my code. : $conn = mysqli_connect("localhost","root","","vfssite"); if (isset($_POST['submit'])) { $filetemp = $_FILES['file']['tmp_name']; $filename = $filepath . basename($_FILES["fileToUpload"]["name"]); $filepath = "uploads/galleryuploadwedding/".$filename; $uploadOk = 1; $imageFileType = pathinfo($filename,PATHINFO_EXTENSION); move_uploaded_file($filetemp, $filepath); if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) { echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; $uploadOk = 0; } $sql = "INSERT INTO gallerywedding (imagename) values ('$filename')"; if ($result = mysqli_query($conn, $sql)) { echo "<script type='text/javascript'>alert('submitted successfully!')</script>"; } else echo "Error"; }
0debug
START_TEST(qdict_put_obj_test) { QInt *qi; QDict *qdict; QDictEntry *ent; const int num = 42; qdict = qdict_new(); qdict_put_obj(qdict, "", QOBJECT(qint_from_int(num))); fail_unless(qdict_size(qdict) == 1); ent = QLIST_FIRST(&qdict->table[12345 % QDICT_BUCKET_MAX]); qi = qobject_to_qint(ent->value); fail_unless(qint_get_int(qi) == num); QDECREF(qi); g_free(ent->key); g_free(ent); g_free(qdict); }
1threat
Gensim saved dictionary has no id2token : <p>I have saved a Gensim dictionary to disk. When I load it, the <code>id2token</code> attribute dict is not populated.</p> <p>A simple piece of the code that saves the dictionary:</p> <pre><code>dictionary = corpora.Dictionary(tag_docs) dictionary.save("tag_dictionary_lda.pkl") </code></pre> <p>Now when I load it (I'm loading it in an jupyter notebook), it still works fine for mapping tokens to IDs, but <code>id2token</code> does not work (I cannot map IDs to tokens) and in fact <code>id2token</code> is not populated at all.</p> <pre><code>&gt; dictionary = corpora.Dictionary.load("../data/tag_dictionary_lda.pkl") &gt; dictionary.token2id["love"] Out: 1613 &gt; dictionary.doc2bow(["love"]) Out: [(1613, 1)] &gt; dictionary.id2token[1613] Out: --------------------------------------------------------------------------- KeyError Traceback (most recent call last) &lt;ipython-input&gt; in &lt;module&gt;() ----&gt; 1 dictionary.id2token[1613] KeyError: 1613 &gt; list(dictionary.id2token.keys()) Out: [] </code></pre> <p>Any thoughts? </p>
0debug
Searching for help to learn : <p>I'm started to study by myself informatics, beginning with html and css and keep going to reach real programming languages. Sometimes I fell like lost while i'm learning and studying something, so I was looking for suggestions about references, about software to use, (now i'm learning on w3schools and sololearn) or books. thanks again to all! </p>
0debug
def sum_Of_Primes(n): prime = [True] * (n + 1) p = 2 while p * p <= n: if prime[p] == True: i = p * 2 while i <= n: prime[i] = False i += p p += 1 sum = 0 for i in range (2,n + 1): if(prime[i]): sum += i return sum
0debug
Converting Hive to spark[Need Suggestion] : I have a project which had hive scripts to process hadoop data on daily basis. want to change hive to spark to process on hourly basis or live processing . what is the best approach to convert hive scripts to spark
0debug
C++ vektor of objects : im learning the concept of OOP , i made simple program that reads names of students and store them inside vektor of objects ; a created a class students class student{ public: student(string,int); string getName() const{ return name; } int getAge() const{ return age; } private: string name; int age; }; student::student(string name,int age){ name=name; age=age; } and in main i read lines as vector<student> myClass; string var; int index=0; while(getline(cin,var)){ student newStudent(var,index); myClass.push_back(newStudent); } for( int i = 0; i < 5; i++){ cout << myClass[i].getName() << endl; } return 0; But as i want to print names ,it only prints blank lines , i tried to print name right after inicializing class in while loop and it also print blank lines. Im quite new to OOP and i do not see any problem here, what did i overlook? Where is a bug in my little program?
0debug
Why are the RVO requirements so restrictive? : <p>Yet another "why must <code>std::move</code> prevent the (unnamed) return-value-optimization?" question:</p> <p><a href="https://stackoverflow.com/questions/19267408/why-does-stdmove-prevent-rvo">Why does std::move prevent RVO?</a> explains that the standard specifically requires that the function's declared return type must match the type of the expression in the <code>return</code> statement. That explains the behavior of conforming compilers; however, it does not explain the rationale for the restriction.</p> <p>Why do the rules for RVO not make an exception for the case where the function's return type is <code>T</code> and the type of the <code>return</code> expression is <code>T&amp;&amp;</code>?</p> <p>I also am aware that implementing such things in compilers doesn't come for free. I am suggesting only that such an exception be allowed but not required.</p> <p>I also am aware that <code>return std::move(...)</code> is unnecessary since C++11 <a href="https://youtu.be/AKtHxKJRwp4?t=2359" rel="noreferrer">already requires that move semantics be used when the RVO can't be applied</a>. Nevertheless, why not tolerate an explicit request for optimization instead of turning it into a pessimization?</p> <hr> <p>(Aside: Why are the <code>return-value-optimization</code> and <code>rvo</code> tags not synonyms?)</p>
0debug
e1000_autoneg_timer(void *opaque) { E1000State *s = opaque; if (!qemu_get_queue(s->nic)->link_down) { e1000_link_up(s); } s->phy_reg[PHY_STATUS] |= MII_SR_AUTONEG_COMPLETE; DBGOUT(PHY, "Auto negotiation is completed\n"); }
1threat
save aws glacier downloaded file to amazon s3 location : I am creating a PHP api's using glacier php sdk for initiating and downloading. and i have successfully downloaded file in my local server. Now I want to save downloaded archive file from Glacier to S3 location. I have done some research and didn't find any possible way please help. Thanks,
0debug
static void compute_pkt_fields(AVFormatContext *s, AVStream *st, AVCodecParserContext *pc, AVPacket *pkt) { int num, den, presentation_delayed, delay, i; int64_t offset; if (s->flags & AVFMT_FLAG_NOFILLIN) return; if((s->flags & AVFMT_FLAG_IGNDTS) && pkt->pts != AV_NOPTS_VALUE) pkt->dts= AV_NOPTS_VALUE; if (st->codec->codec_id != CODEC_ID_H264 && pc && pc->pict_type == AV_PICTURE_TYPE_B) st->codec->has_b_frames = 1; delay= st->codec->has_b_frames; presentation_delayed = 0; if (delay && st->codec->active_thread_type&FF_THREAD_FRAME) delay -= st->codec->thread_count-1; if (delay && pc && pc->pict_type != AV_PICTURE_TYPE_B) presentation_delayed = 1; if(pkt->pts != AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE && pkt->dts - (1LL<<(st->pts_wrap_bits-1)) > pkt->pts && st->pts_wrap_bits<63){ pkt->dts -= 1LL<<st->pts_wrap_bits; } if(delay==1 && pkt->dts == pkt->pts && pkt->dts != AV_NOPTS_VALUE && presentation_delayed){ av_log(s, AV_LOG_DEBUG, "invalid dts/pts combination %"PRIi64"\n", pkt->dts); pkt->dts= pkt->pts= AV_NOPTS_VALUE; } if (pkt->duration == 0) { compute_frame_duration(&num, &den, st, pc, pkt); if (den && num) { pkt->duration = av_rescale_rnd(1, num * (int64_t)st->time_base.den, den * (int64_t)st->time_base.num, AV_ROUND_DOWN); if(pkt->duration != 0 && s->packet_buffer) update_initial_durations(s, st, pkt); } } if(pc && st->need_parsing == AVSTREAM_PARSE_TIMESTAMPS && pkt->size){ offset = av_rescale(pc->offset, pkt->duration, pkt->size); if(pkt->pts != AV_NOPTS_VALUE) pkt->pts += offset; if(pkt->dts != AV_NOPTS_VALUE) pkt->dts += offset; } if (pc && pc->dts_sync_point >= 0) { int64_t den = st->codec->time_base.den * (int64_t) st->time_base.num; if (den > 0) { int64_t num = st->codec->time_base.num * (int64_t) st->time_base.den; if (pkt->dts != AV_NOPTS_VALUE) { st->reference_dts = pkt->dts - pc->dts_ref_dts_delta * num / den; pkt->pts = pkt->dts + pc->pts_dts_delta * num / den; } else if (st->reference_dts != AV_NOPTS_VALUE) { pkt->dts = st->reference_dts + pc->dts_ref_dts_delta * num / den; pkt->pts = pkt->dts + pc->pts_dts_delta * num / den; } if (pc->dts_sync_point > 0) st->reference_dts = pkt->dts; } } if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts > pkt->dts) presentation_delayed = 1; if((delay==0 || (delay==1 && pc)) && st->codec->codec_id != CODEC_ID_H264){ if (presentation_delayed) { if (pkt->dts == AV_NOPTS_VALUE) pkt->dts = st->last_IP_pts; update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts); if (pkt->dts == AV_NOPTS_VALUE) pkt->dts = st->cur_dts; if (st->last_IP_duration == 0) st->last_IP_duration = pkt->duration; if(pkt->dts != AV_NOPTS_VALUE) st->cur_dts = pkt->dts + st->last_IP_duration; st->last_IP_duration = pkt->duration; st->last_IP_pts= pkt->pts; } else if(pkt->pts != AV_NOPTS_VALUE || pkt->dts != AV_NOPTS_VALUE || pkt->duration){ if(pkt->pts != AV_NOPTS_VALUE && pkt->duration){ int64_t old_diff= FFABS(st->cur_dts - pkt->duration - pkt->pts); int64_t new_diff= FFABS(st->cur_dts - pkt->pts); if(old_diff < new_diff && old_diff < (pkt->duration>>3)){ pkt->pts += pkt->duration; } } if(pkt->pts == AV_NOPTS_VALUE) pkt->pts = pkt->dts; update_initial_timestamps(s, pkt->stream_index, pkt->pts, pkt->pts); if(pkt->pts == AV_NOPTS_VALUE) pkt->pts = st->cur_dts; pkt->dts = pkt->pts; if(pkt->pts != AV_NOPTS_VALUE) st->cur_dts = pkt->pts + pkt->duration; } } if(pkt->pts != AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY){ st->pts_buffer[0]= pkt->pts; for(i=0; i<delay && st->pts_buffer[i] > st->pts_buffer[i+1]; i++) FFSWAP(int64_t, st->pts_buffer[i], st->pts_buffer[i+1]); if(pkt->dts == AV_NOPTS_VALUE) pkt->dts= st->pts_buffer[0]; if(st->codec->codec_id == CODEC_ID_H264){ update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts); } if(pkt->dts > st->cur_dts) st->cur_dts = pkt->dts; } if(is_intra_only(st->codec)) pkt->flags |= AV_PKT_FLAG_KEY; else if (pc) { pkt->flags = 0; if (pc->key_frame == 1) pkt->flags |= AV_PKT_FLAG_KEY; else if (pc->key_frame == -1 && pc->pict_type == AV_PICTURE_TYPE_I) pkt->flags |= AV_PKT_FLAG_KEY; } if (pc) pkt->convergence_duration = pc->convergence_duration; }
1threat
Can't figue out why the value didn't change : <p>I'm new to OOP and C#.</p> <p>I've tried to use inheritance and encapsulation concepts and get stuck.</p> <p>Can't figue out why a Deposit method din't work when i call it through Atm_1 class.</p> <hr> <p><strong><em>parent class</em></strong></p> <pre><code> class Atm { public int TotalBalance { get; private set; } = 1000; public Atm() { } public void DepoSit(int deposit) { TotalBalance += deposit; } } </code></pre> <p><strong><em>child class</em></strong></p> <pre><code> class Atm_1:Atm { } </code></pre> <p><strong><em>main</em></strong></p> <pre><code> class Program { static void Main() { var atm = new Atm(); var atm_1 = new Atm_1(); //Before Deposit Console.WriteLine("Total Balance is "+atm.TotalBalance); //1000 //Deposit atm_1.DepoSit(20); //After Deposit Console.WriteLine("Total Balance is " + atm.TotalBalance); //Still 1000 ?? atm.DepoSit(500); Console.WriteLine("Total Balance is " + atm.TotalBalance); //Now 1500 //This Works -why the above didn't work? } } </code></pre>
0debug
static void qxl_spice_destroy_surfaces(PCIQXLDevice *qxl, qxl_async_io async) { if (async) { #if SPICE_INTERFACE_QXL_MINOR < 1 abort(); #else spice_qxl_destroy_surfaces_async(&qxl->ssd.qxl, 0); #endif } else { qxl->ssd.worker->destroy_surfaces(qxl->ssd.worker); qxl_spice_destroy_surfaces_complete(qxl); } }
1threat
void tlb_fill(unsigned long addr, int is_write, int is_user, void *retaddr) { TranslationBlock *tb; CPUState *saved_env; unsigned long pc; int ret; saved_env = env; env = cpu_single_env; { unsigned long tlb_addrr, tlb_addrw; int index; index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); tlb_addrr = env->tlb_read[is_user][index].address; tlb_addrw = env->tlb_write[is_user][index].address; #if 0 if (loglevel) { fprintf(logfile, "%s 1 %p %p idx=%d addr=0x%08lx tbl_addr=0x%08lx 0x%08lx " "(0x%08lx 0x%08lx)\n", __func__, env, &env->tlb_read[is_user][index], index, addr, tlb_addrr, tlb_addrw, addr & TARGET_PAGE_MASK, tlb_addrr & (TARGET_PAGE_MASK | TLB_INVALID_MASK)); } #endif } ret = cpu_ppc_handle_mmu_fault(env, addr, is_write, is_user, 1); if (ret) { if (retaddr) { pc = (unsigned long)retaddr; tb = tb_find_pc(pc); if (tb) { cpu_restore_state(tb, env, pc, NULL); } } do_raise_exception_err(env->exception_index, env->error_code); } { unsigned long tlb_addrr, tlb_addrw; int index; index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); tlb_addrr = env->tlb_read[is_user][index].address; tlb_addrw = env->tlb_write[is_user][index].address; #if 0 printf("%s 2 %p %p idx=%d addr=0x%08lx tbl_addr=0x%08lx 0x%08lx " "(0x%08lx 0x%08lx)\n", __func__, env, &env->tlb_read[is_user][index], index, addr, tlb_addrr, tlb_addrw, addr & TARGET_PAGE_MASK, tlb_addrr & (TARGET_PAGE_MASK | TLB_INVALID_MASK)); #endif } env = saved_env; }
1threat
How to reference a JButton with a string (or an integer)? : Let's say we have 3 JButtons(or some other objects) : JButton button1 = new JButton() , button2 = new JButton(), button3 = new JButton(); Now let's say that as a result of some function we have an integer from 1 to 3. Is it possible , for example, to decide what button to manipulate based on the given integer. So, if I came up with number 3, to select button3 like this : button(3).setIcon(etc..); Thanks in advance :)
0debug
How to get complete git commit hash from short hash? : <p>I have a short git commit hash of length 8 characters. I want to get a complete hash from remote server. I tried getting the branch name from the commit hash and then getting the full commit hash from branch name but it only works for the latest commit. What could be the best possible way to achieve what I want? </p>
0debug
def split_two_parts(list1, L): return list1[:L], list1[L:]
0debug
Trouble whit pip : Fatal error in launcher: Unable to create process using '"c:\program files (x86)\python38-32\python.exe" "C:\Program Files (x86)\Python38-32\Scripts\pip.exe" install virtualenv venv1'
0debug
how to connect to an ftp server? : <p>How do I connect to an FTP server using a command prompt?</p> <p>The ftp site I am trying to connect to is </p> <p>ftp.bom.gov.au/anon/gen/</p> <p>I used to be able to type in ftp ftp.bom.gov.au/anon/gen/ in the command prompt and it would challange me for a username and password</p> <p>but now it says unknown host.</p> <p>I can still get to it from a browser </p> <p><a href="ftp://ftp.bom.gov.au/anon/gen/" rel="nofollow noreferrer">ftp://ftp.bom.gov.au/anon/gen/</a></p> <p>Is there something I am missing?</p> <p>Thanks</p>
0debug
testing spring boot rest application with restAssured : <p>I've been struggling with this for some time now. I'd like to use restAssured to test my SpringBoot REST application.</p> <p>While it looks like container spins up properly, rest assured (and anything else seems to have problems reaching out to it.</p> <p>All the time I'm getting Connection refused exception.</p> <pre><code>java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) ... </code></pre> <p>my test class:</p> <pre><code>@RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class SizesRestControllerIT { @Autowired private TestRestTemplate restTemplate; @Test public void test() { System.out.println(this.restTemplate.getForEntity("/clothes", List.class)); } @Test public void test2() throws InterruptedException { given().basePath("/clothes").when().get("").then().statusCode(200); } } </code></pre> <p>and now for the weird part, <code>test</code> passes and prints what it should, but <code>test2</code> is getting Connection refused exception.</p> <p>Any ideas what is wrong with this setup?</p>
0debug
PPC_OP(cmp) { if (Ts0 < Ts1) { T0 = 0x08; } else if (Ts0 > Ts1) { T0 = 0x04; } else { T0 = 0x02; } RETURN(); }
1threat