problem
stringlengths
26
131k
labels
class label
2 classes
Android-Studio cannot run my application : I'm trying to make a simple android application interface in Android studio. I'm following few tutorials online. here some images about something that i'm trying to accomplish: [![Gradle Preview][1]][1] I'm simply do not know where exactly where i'm wrong. I've checked multiple times, but my application won't run. here's the link for the code: [MainActivity.java][2], [activity_main.xml][4] here is inside my build.gradle (module.app) apply plugin: 'com.android.application' android { compileSdkVersion 26 defaultConfig { applicationId "pam.pohat_4" minSdkVersion 23 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' //Libary compile 'com.google.firebase:firebase-core:10.2.0' compile 'com.google.firebase:firebase-database:10.2.0' compile 'info.hoang8f:fbutton:1.0.5' compile 'com.rengwuxian.materialedittext:library:2.1.4' } apply plugin: 'com.google.gms.google-services' but i get this un-ending error: [![logcat][5]][5] [1]: https://i.stack.imgur.com/SBzvw.png [2]: https://pastebin.com/kAwMkmmg [3]: https://pastebin.com/3ntf4Cxq [4]: https://pastebin.com/50u9ettv [5]: https://i.stack.imgur.com/p2nMD.png
0debug
static void apic_init_ipi(APICState *s) { int i; s->tpr = 0; s->spurious_vec = 0xff; s->log_dest = 0; s->dest_mode = 0xf; memset(s->isr, 0, sizeof(s->isr)); memset(s->tmr, 0, sizeof(s->tmr)); memset(s->irr, 0, sizeof(s->irr)); for(i = 0; i < APIC_LVT_NB; i++) s->lvt[i] = 1 << 16; s->esr = 0; memset(s->icr, 0, sizeof(s->icr)); s->divide_conf = 0; s->count_shift = 0; s->initial_count = 0; s->initial_count_load_time = 0; s->next_time = 0; cpu_reset(s->cpu_env); s->cpu_env->halted = !(s->apicbase & MSR_IA32_APICBASE_BSP); }
1threat
Add an array as request parameter with Retrofit 2 : <p>I'm looking for way to add an int array (e.g [0,1,3,5]) as parameter in a <strong>GET</strong> request with retrofit 2. Then, the generated url should be like this : <a href="http://server/service?array=[0,1,3,5]" rel="noreferrer">http://server/service?array=[0,1,3,5]</a></p> <p>How to do this ?</p>
0debug
Create spring repository without entity : <p>I want to use spring data repository interface to execute native queries - I think this way is the simplest because of low complexity.</p> <p>But when extending interface ex. <code>CrudRepository&lt;T, ID&gt;</code> I need to write T - my entity, which is not available.</p> <p>My native queries does not return any concrete entity, so what is the best way to create spring repository without entity?</p>
0debug
I need help programming a Fahrenheit to Celsius Converter : I don't know what I'm doing wrong. ive looked but I cant find the answer. im trying to have a text box, and a button next to it. When you click the button, I want it to convert it to fahrenheit or celsius and display it in another text box. I only have the fahrenheit to celsius done and I can just copy the code over when Im done <!DOCTYPE html> <html> <head> <center> <h1> Fahrenheit to Celsius Converter</h1> <font size="+1" > <p> Fahrenheit to Celsius</p> <input type="text" name="ftc" id="ftc"/> <button type="button" onclick="fahrenheitCelsius()" /> Click to Convert </button> <p>Celsius to Fahrenheit </p> <input type="text" name="ctf" id="ctf" /> <button type="button" onclick="celsiusFahrenheit()" /> Click to Convert </button> <p> Answer </p> <input type="text" name="answer box" id="answer/> <script> function fahrenheitCelsius() { var fsc = parseFloat(document.getElementById('ftc').value); var cfc = (fsc-32) * (5/9); document.getElementById('answer box').value = cfc; return false; document.writeIn(<input type="text" name="answer box" id="answer"/>) } </script> </font> </head> </html>
0debug
Tensorflow Relu Misunderstanding : <p>I've recently been doing a Udacity Deep Learning course which is based around <code>TensorFlow</code>. I have a simple <code>MNIST</code> program which is about 92% accurate:</p> <pre> <code> from tensorflow.examples.tutorials.mnist import input_data import tensorflow as tf mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) x = tf.placeholder(tf.float32, [None, 784]) W = tf.Variable(tf.zeros([784, 10])) b = tf.Variable(tf.zeros([10])) y = tf.nn.softmax(tf.matmul(x, W) + b) y_ = tf.placeholder(tf.float32, [None, 10]) cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1])) train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy) init = tf.initialize_all_variables() sess = tf.Session() sess.run(init) for i in range(1000): batch_xs, batch_ys = mnist.train.next_batch(100) sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys}) correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) print(sess.run(accuracy, feed_dict={x: mnist.test.images, y_: mnist.test.labels})) </code> </pre> <p>My next assignment it to <code>Turn the logistic regression example with SGD into a 1-hidden layer neural network with rectified linear units nn.relu() and 1024 hidden nodes</code></p> <p>I am having a mental block about this. Currently I have a 784 x 10 Matrix of weights, and a 10 element long bias vector. I don't understand how I connect the resulting 10 element vector from <code>WX + Bias</code> to 1024 <code>Relu</code>s.</p> <p>If anyone could explain this to me I'd be very grateful.</p>
0debug
long do_rt_sigreturn(CPUX86State *env) { abi_ulong frame_addr; struct rt_sigframe *frame; sigset_t set; int eax; frame_addr = env->regs[R_ESP] - 4; if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) goto badframe; target_to_host_sigset(&set, &frame->uc.tuc_sigmask); sigprocmask(SIG_SETMASK, &set, NULL); if (restore_sigcontext(env, &frame->uc.tuc_mcontext, &eax)) goto badframe; if (do_sigaltstack(frame_addr + offsetof(struct rt_sigframe, uc.tuc_stack), 0, get_sp_from_cpustate(env)) == -EFAULT) goto badframe; unlock_user_struct(frame, frame_addr, 0); return eax; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; }
1threat
static void vapic_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->no_user = 1; dc->reset = vapic_reset; dc->vmsd = &vmstate_vapic; dc->realize = vapic_realize; }
1threat
static av_cold int init(AVFilterContext *ctx) { FormatContext *s = ctx->priv; char *cur, *sep; int nb_formats = 1; int i; int ret; cur = s->pix_fmts; while ((cur = strchr(cur, '|'))) { nb_formats++; if (*cur) cur++; } s->formats = av_malloc_array(nb_formats + 1, sizeof(*s->formats)); if (!s->formats) return AVERROR(ENOMEM); if (!s->pix_fmts) return AVERROR(EINVAL); cur = s->pix_fmts; for (i = 0; i < nb_formats; i++) { sep = strchr(cur, '|'); if (sep) *sep++ = 0; if ((ret = ff_parse_pixel_format(&s->formats[i], cur, ctx)) < 0) return ret; cur = sep; } s->formats[nb_formats] = AV_PIX_FMT_NONE; if (!strcmp(ctx->filter->name, "noformat")) { const AVPixFmtDescriptor *desc = NULL; enum AVPixelFormat *formats_allowed; int nb_formats_lavu = 0, nb_formats_allowed = 0; while ((desc = av_pix_fmt_desc_next(desc))) nb_formats_lavu++; formats_allowed = av_malloc_array(nb_formats_lavu + 1, sizeof(*formats_allowed)); if (!formats_allowed) return AVERROR(ENOMEM); while ((desc = av_pix_fmt_desc_next(desc))) { enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(desc); for (i = 0; i < nb_formats; i++) { if (s->formats[i] == pix_fmt) break; } if (i < nb_formats) continue; formats_allowed[nb_formats_allowed++] = pix_fmt; } formats_allowed[nb_formats_allowed] = AV_PIX_FMT_NONE; av_freep(&s->formats); s->formats = formats_allowed; } return 0; }
1threat
how did make code decompress java spring boot? : Hi everyone i'm Starting Beginner learning java springboot .my profressor give an assignment for me . that's decompress java springboot. the proposition has define input and out . following example Input1 : 2[abc]3[ab]c Output1 : abcabcabababc Input2 : 10[a]c2[ab] Output2 : aaaaaaaaaacabab Input3 : 2[3[a]b] Output3 : aaabaaab somebody help me please . that's very seriousry for me . can help and explain to me T_T
0debug
int find_itlb_entry(CPUState * env, target_ulong address, int use_asid, int update) { int e, n; e = find_tlb_entry(env, address, env->itlb, ITLB_SIZE, use_asid); if (e == MMU_DTLB_MULTIPLE) e = MMU_ITLB_MULTIPLE; else if (e == MMU_DTLB_MISS && update) { e = find_tlb_entry(env, address, env->utlb, UTLB_SIZE, use_asid); if (e >= 0) { n = itlb_replacement(env); env->itlb[n] = env->utlb[e]; e = n; } else if (e == MMU_DTLB_MISS) e = MMU_ITLB_MISS; } else if (e == MMU_DTLB_MISS) e = MMU_ITLB_MISS; if (e >= 0) update_itlb_use(env, e); return e; }
1threat
Convert string into several integer arrays : <p>How do i break down this " 01|15|59, 1|47|6, 01|17|20, 1|32|34, 2|3|1 " string into 5 integer arrays ?.</p> <p>For example:</p> <ol> <li><p>01|15|59 becomes [01,15,59]</p></li> <li><p>1|47|6 becomes [1,47,6]</p></li> </ol>
0debug
Error: JavaFX runtime components are missing, and are required to run this application with JDK 11 : <p>I'm trying to run the sample JavaFX project using IntelliJ but it fails with the exception :</p> <pre><code>Error: JavaFX runtime components are missing, and are required to run this application </code></pre> <p>I have downloaded JDK 11 here : <a href="http://jdk.java.net/11/" rel="noreferrer">http://jdk.java.net/11/</a> I have downloaded OpenJFX here : <a href="http://jdk.java.net/openjfx/" rel="noreferrer">http://jdk.java.net/openjfx/</a> I'm using : IntelliJ IDEA 2018.2 (Community Edition) Build #IC-182.3684.40, built on July 17, 2018 JRE: 1.8.0_152-release-1248-b8 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0</p> <p>I have created a new JavaFX project in IntelliJ using JDK 11. My JavaFX classes were not known so I have added the OpenJFX library by doing :</p> <ul> <li>File -> Project Structure -> Modules -> + -> Library -> Java</li> </ul> <p>I have the OpenJFX added with the 8 jars below "classes" and also the folders below "Sources" and the path to the bin folder under "Native Library Locations".</p> <p>When I'm building the project, it's good, but impossible to run it. </p> <p>What am I doing wrong?</p>
0debug
How to validate Jinja syntax without variable interpolation : <p>I have had no success in locating a good precommit hook I can use to validate that a Jinja2 formatted file is well-formed without attempting to substitute variables. The goal is something that will return a shell code of zero if the file is well-formed without regard to whether variable are available, 1 otherwise.</p>
0debug
import re regex = '^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$' def check_email(email): if(re.search(regex,email)): return ("Valid Email") else: return ("Invalid Email")
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
Error when adding butterknife plugin : When you add the butterknife plugin, which is like : 'com.jakewharton.butterknife', I will encounter the following error. Plugin with id 'com.jakewharton.butterknife' not found. Does anyone know where the problem is?
0debug
static void restore_sigcontext(CPUSH4State *regs, struct target_sigcontext *sc, target_ulong *r0_p) { int i; #define COPY(x) __get_user(regs->x, &sc->sc_##x) COPY(gregs[1]); COPY(gregs[2]); COPY(gregs[3]); COPY(gregs[4]); COPY(gregs[5]); COPY(gregs[6]); COPY(gregs[7]); COPY(gregs[8]); COPY(gregs[9]); COPY(gregs[10]); COPY(gregs[11]); COPY(gregs[12]); COPY(gregs[13]); COPY(gregs[14]); COPY(gregs[15]); COPY(gbr); COPY(mach); COPY(macl); COPY(pr); COPY(sr); COPY(pc); #undef COPY for (i=0; i<16; i++) { __get_user(regs->fregs[i], &sc->sc_fpregs[i]); } __get_user(regs->fpscr, &sc->sc_fpscr); __get_user(regs->fpul, &sc->sc_fpul); regs->tra = -1; __get_user(*r0_p, &sc->sc_gregs[0]); }
1threat
static QPCIBus *pci_test_start(int socket) { char *cmdline; cmdline = g_strdup_printf("-netdev socket,fd=%d,id=hs0 -device " "virtio-net-pci,netdev=hs0", socket); qtest_start(cmdline); g_free(cmdline); return qpci_init_pc(NULL); }
1threat
Array tableview use of : I have an array called diziTum diziTumm = [arac.description] diziTumm.forEach({ (item) in print(item) }) this is the end result { "YASSINIRLA" : "True", "KARBON" : "98" } { "YASSINIRLA" : "True", "KARBON" : "98" } { "YASSINIRLA" : "True", "KARBON" : "98" } have a question.how can i show tableview? Thanks cell.lblSonText.text = diziTumm[indexPath.row]["KARBON"] ???
0debug
How to make @angular/flex-layout wrap based on screensize : <p>I have 3 divs which i can make bigger or smaller based on the screen-size but cant get it to wrap like bootstrap. So for small screens i want the divs to be stacked vertically, large screen horizontally. eg <a href="https://i.stack.imgur.com/NRtXV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NRtXV.png" alt="enter image description here"></a> Anyone know how i do this with Angular2? I chose to use the @angular/flex-layout which i npm'd. </p> <p>Note: I dont think there is anything in the 'colored box' thats conflicting with anything.</p> <p>Here is my code...</p> <pre><code>import { Component } from '@angular/core'; @Component({ selector: 'my-app', //templateUrl: './app/app.component.html', template:` &lt;div class="flex-container" fxFlex=100&gt; &lt;div class="colored box" &gt; &lt;div fxFlex.lg=100 fxFlex.md=50&gt; flexible for screensize &lt;/div&gt; &lt;div fxFlex.lg=100&gt; fxFlex &lt;/div&gt; &lt;div fxFlex=33&gt; fxFlex &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="version"&gt;@angular/flex-layout (v2.0.0-beta.0)&lt;/div&gt; `, styleUrls: ['./app/app.component.css'] }) export class AppComponent { } </code></pre>
0debug
int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush, int (*get_packet)(AVFormatContext *, AVPacket *, AVPacket *, int), int (*compare_ts)(AVFormatContext *, AVPacket *, AVPacket *)) { int i; if (pkt) { AVStream *st = s->streams[pkt->stream_index]; AudioInterleaveContext *aic = st->priv_data; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { unsigned new_size = av_fifo_size(aic->fifo) + pkt->size; if (new_size > aic->fifo_size) { if (av_fifo_realloc2(aic->fifo, new_size) < 0) return -1; aic->fifo_size = new_size; } av_fifo_generic_write(aic->fifo, pkt->data, pkt->size, NULL); } else { pkt->pts = pkt->dts = aic->dts; aic->dts += pkt->duration; ff_interleave_add_packet(s, pkt, compare_ts); } pkt = NULL; } for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { AVPacket new_pkt; while (interleave_new_audio_packet(s, &new_pkt, i, flush)) ff_interleave_add_packet(s, &new_pkt, compare_ts); } } return get_packet(s, out, NULL, flush); }
1threat
How to get JSON error response and toast in android : Here's my code for when i trying to register user and need a toast which is response from server regarding user already exist. i can post successfully to server using json but if there's response i have to idea how to catch it the image shows example when using postman. public class RegisterActivity extends AppCompatActivity implements View.OnClickListener{ private EditText signupInputName, signupInputEmail, signupInputPassword, retypeInputPassword; private Button btnSignUp; private Button btnLinkLogin; private String message = ""; private int code = 0; Person person; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); signupInputName = (EditText) findViewById(R.id.signup_input_name); signupInputEmail = (EditText) findViewById(R.id.signup_input_email); signupInputPassword = (EditText) findViewById(R.id.signup_input_password); retypeInputPassword = (EditText) findViewById(R.id.signup_retype_password); btnSignUp = (Button) findViewById(R.id.btn_signup); btnLinkLogin = (Button) findViewById(R.id.btn_link_login); btnSignUp.setOnClickListener(this); btnLinkLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(getApplicationContext(),LoginActivity.class); startActivity(i); } }); } public String POST(String url, Person person) { InputStream inputStream = null; String result = ""; try { // 1. create HttpClient HttpClient httpclient = new DefaultHttpClient(); // 2. make POST request to the given URL HttpPost httppost = new HttpPost(url); String json = ""; // 3. build jsonObject JSONObject jsonObject = new JSONObject(); jsonObject.accumulate("user_name", person.getUsername()); jsonObject.accumulate("email", person.getEmail()); jsonObject.accumulate("password", person.getPassword()); // 4. convert JSONObject to JSON to String json = jsonObject.toString(); // ** Alternative way to convert Person object to JSON string usin Jackson Lib // ObjectMapper mapper = new ObjectMapper(); // json = mapper.writeValueAsString(person); // 5. set json to StringEntity StringEntity se = new StringEntity(json); // 6. set httpPost Entity httppost.setEntity(se); // 7. Set some headers to inform server about the type of the content httppost.setHeader("Accept", "application/json"); httppost.setHeader("Content-type", "application/json"); // 8. Execute POST request to the given URL HttpResponse httpResponse = httpclient.execute(httppost); // 9. receive response as inputStream inputStream = httpResponse.getEntity().getContent(); // 10. convert inputstream to string if(inputStream != null) result = convertInputStreamToString(inputStream); else result = "Error! email exist"; } catch (Exception e) { Log.d("InputStream", e.getLocalizedMessage()); } // 11. return result return result; } @Override public void onClick(View view) { if(validate() == 1) { Toast.makeText(getBaseContext(), message.toString(), Toast.LENGTH_SHORT).show(); } else if (validate() == 2) { Toast.makeText(getBaseContext(), message.toString(), Toast.LENGTH_SHORT).show(); } else if (validate() == 3) { Toast.makeText(getBaseContext(), message.toString(), Toast.LENGTH_SHORT).show(); } else if (validate() == 4) { //Toast.makeText(getBaseContext(), "Success", Toast.LENGTH_SHORT).show(); new HttpAsyncTask().execute("http://ip-addressses/api/register"); } } private class HttpAsyncTask extends AsyncTask<String, Void, String> { @Override protected String doInBackground(String... urls) { person = new Person(); person.setUsername(signupInputName.getText().toString()); person.setEmail(signupInputEmail.getText().toString()); person.setPassword(signupInputPassword.getText().toString()); return POST(urls[0],person); } // onPostExecute displays the results of the AsyncTask. @Override protected void onPostExecute(String result) { JSONObject jObject; try { jObject = new JSONObject(result); if (jObject.has("error")) { String aJsonString = jObject.getString("error"); Toast.makeText(getBaseContext(), aJsonString, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getBaseContext(), "Login Successful", Toast.LENGTH_SHORT).show(); } } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } private int validate() { if(signupInputName.getText().toString().trim().equals("") || signupInputEmail.getText().toString().trim().equals("") || signupInputPassword.getText().toString().trim().equals("") || retypeInputPassword.getText().toString().trim().equals("")) { code = 1; message = "Complete the form!"; } else if (!(signupInputPassword.getText().toString().equals(retypeInputPassword.getText().toString()))) { code = 2; message = "Re-check password"; } else if (!isValidEmail(signupInputEmail.getText().toString()) ) { code = 3; message = "Invalid email"; } else code = 4; return code; } public final static boolean isValidEmail(String target) { if (target == null) { return false; } else { Matcher match = Patterns.EMAIL_ADDRESS.matcher(target); return match.matches(); } } private static String convertInputStreamToString(InputStream inputStream) throws IOException{ BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream)); String line = ""; String result = ""; while((line = bufferedReader.readLine()) != null) result += line; inputStream.close(); return result; } } [Postman response when email exist][1] [1]: https://i.stack.imgur.com/wqesS.png
0debug
Elasticsearch error: cluster_block_exception [FORBIDDEN/12/index read-only / allow delete (api)], flood stage disk watermark exceeded : <p>When trying to post documents to Elasticsearch as normal I'm getting this error:</p> <pre><code>cluster_block_exception [FORBIDDEN/12/index read-only / allow delete (api)]; </code></pre> <p>I also see this message on the Elasticsearch logs:</p> <pre><code>flood stage disk watermark [95%] exceeded ... all indices on this node will marked read-only </code></pre>
0debug
An error occurred when attaching the database(s). Click the hyperlink in the Message column for details : <p>i am trying to attach external database named ( HaseebProject.mdf) but every time i got an error " An error occurred when attaching the database(s). Click the hyperlink in the Message column for details." What'sthe error is there..?? even there is any error message in message field as shown.<a href="http://i.stack.imgur.com/ds1db.png" rel="noreferrer">enter image description here</a> </p> <p>When i click on add button to add database there are two paths in directory for database. i have tried with both but he same error.<a href="http://i.stack.imgur.com/LfYL5.png" rel="noreferrer">enter image description here</a></p>
0debug
Flutter NotificationListener with ScrollNotification vs ScrollController : <p>There are two options to retrieve the scroll position for a CustomScrollView. The <a href="https://docs.flutter.io/flutter/widgets/CustomScrollView-class.html" rel="noreferrer">documentation</a> states the following: </p> <blockquote> <p>ScrollNotification and NotificationListener, which can be used to watch the scroll position without using a ScrollController.</p> </blockquote> <p>So we have the following options:</p> <ol> <li>NotificationListener with ScrollNotification</li> <li>ScrollController</li> </ol> <p>In which situation do you useNotificationListener with ScrollNotification vs ScrollController?</p> <p>Thank you :)</p>
0debug
static int arm946_prbs_read(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t *value) { if (ri->crm > 8) { return EXCP_UDEF; } *value = env->cp15.c6_region[ri->crm]; return 0; }
1threat
static void vnc_tight_stop(VncState *vs) { vs->tight = vs->output; vs->output = vs->tight_tmp; }
1threat
How BroadcastReceiver work belong to android app state : My question is about behavior of Receivers when app is 'Died' - does receivers die also with it, or they are still working in memory? My problem is about such situation - I can't listen action 'App is destroyed' and carefully do 'unregisterReciever'. **So i want to know - what happens with receivers in memory belong to app state.** PS - approachs like doing unregister in 'onstop' of Activity doesn't fit to my situation.
0debug
how store image in sqlite-database (statically) during installation or runing time ? : **Description** I develop the tailor-Management apps. to this apps i store some designs (cloths) images. some images is statically and some images is dynamically. dynamically means the user is also store the images through camera and Gallery this task i done but i confuse the another task. **Repeat The Question:** i want to store image in sqlite-databse during installation time .if the user install the apps and run apps. to this time store the images. and only once time save that images. not repeatedly. **i performed this coding** @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.update_design_activity); Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.kamee_elbow_imagey); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG,0, stream); byte[] bytearry=stream.toByteArray(); db.insertIntoImageTable("elbow",bytearry); }} for this code the image store is repeatedly i want to one time store the data and different images. [and i retrieve all the data in Gridview][1] [1]: https://i.stack.imgur.com/TI9Kj.png there is repeatedly store the images i want to store one images and different images. how to do.
0debug
static void mp3_parse_info_tag(AVFormatContext *s, AVStream *st, MPADecodeHeader *c, uint32_t spf) { #define LAST_BITS(k, n) ((k) & ((1 << (n)) - 1)) #define MIDDLE_BITS(k, m, n) LAST_BITS((k) >> (m), ((n) - (m))) uint16_t crc; uint32_t v; char version[10]; uint32_t peak = 0; int32_t r_gain = INT32_MIN, a_gain = INT32_MIN; MP3DecContext *mp3 = s->priv_data; static const int64_t xing_offtbl[2][2] = {{32, 17}, {17,9}}; uint64_t fsize = avio_size(s->pb); avio_skip(s->pb, xing_offtbl[c->lsf == 1][c->nb_channels == 1]); v = avio_rb32(s->pb); mp3->is_cbr = v == MKBETAG('I', 'n', 'f', 'o'); if (v != MKBETAG('X', 'i', 'n', 'g') && !mp3->is_cbr) return; v = avio_rb32(s->pb); if (v & XING_FLAG_FRAMES) mp3->frames = avio_rb32(s->pb); if (v & XING_FLAG_SIZE) mp3->header_filesize = avio_rb32(s->pb); if (fsize && mp3->header_filesize) { uint64_t min, delta; min = FFMIN(fsize, mp3->header_filesize); delta = FFMAX(fsize, mp3->header_filesize) - min; if (fsize > mp3->header_filesize && delta > min >> 4) { mp3->frames = 0; } else if (delta > min >> 4) { av_log(s, AV_LOG_WARNING, "filesize and duration do not match (growing file?)\n"); } } if (v & XING_FLAG_TOC) read_xing_toc(s, mp3->header_filesize, av_rescale_q(mp3->frames, (AVRational){spf, c->sample_rate}, st->time_base)); if(v & 8) avio_skip(s->pb, 4); memset(version, 0, sizeof(version)); avio_read(s->pb, version, 9); avio_r8(s->pb); avio_r8(s->pb); v = avio_rb32(s->pb); peak = av_rescale(v, 100000, 1 << 23); v = avio_rb16(s->pb); if (MIDDLE_BITS(v, 13, 15) == 1) { r_gain = MIDDLE_BITS(v, 0, 8) * 10000; if (v & (1 << 9)) r_gain *= -1; } v = avio_rb16(s->pb); if (MIDDLE_BITS(v, 13, 15) == 2) { a_gain = MIDDLE_BITS(v, 0, 8) * 10000; if (v & (1 << 9)) a_gain *= -1; } avio_r8(s->pb); avio_r8(s->pb); v= avio_rb24(s->pb); if(AV_RB32(version) == MKBETAG('L', 'A', 'M', 'E') || AV_RB32(version) == MKBETAG('L', 'a', 'v', 'f')) { mp3->start_pad = v>>12; mp3-> end_pad = v&4095; st->skip_samples = mp3->start_pad + 528 + 1; if (mp3->frames) st->end_discard_sample = -mp3->end_pad + 528 + 1 + mp3->frames * (int64_t)spf; if (!st->start_time) st->start_time = av_rescale_q(st->skip_samples, (AVRational){1, c->sample_rate}, st->time_base); av_log(s, AV_LOG_DEBUG, "pad %d %d\n", mp3->start_pad, mp3-> end_pad); } avio_r8(s->pb); avio_r8(s->pb); avio_rb16(s->pb); avio_rb32(s->pb); avio_rb16(s->pb); crc = ffio_get_checksum(s->pb); v = avio_rb16(s->pb); if (v == crc) { ff_replaygain_export_raw(st, r_gain, peak, a_gain, 0); av_dict_set(&st->metadata, "encoder", version, 0); } }
1threat
static void pcspk_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = pcspk_realizefn; set_bit(DEVICE_CATEGORY_SOUND, dc->categories); dc->no_user = 1; dc->props = pcspk_properties; }
1threat
static CharDriverState *qemu_chr_open_win_file(HANDLE fd_out) { CharDriverState *chr; WinCharState *s; chr = g_malloc0(sizeof(CharDriverState)); s = g_malloc0(sizeof(WinCharState)); s->hcom = fd_out; chr->opaque = s; chr->chr_write = win_chr_write; return chr; }
1threat
static int atrac1_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AT1Ctx *q = avctx->priv_data; int ch, ret, i; GetBitContext gb; float* samples = data; if (buf_size < 212 * q->channels) { av_log(q,AV_LOG_ERROR,"Not enought data to decode!\n"); return -1; } for (ch = 0; ch < q->channels; ch++) { AT1SUCtx* su = &q->SUs[ch]; init_get_bits(&gb, &buf[212 * ch], 212 * 8); ret = at1_parse_bsm(&gb, su->log2_block_count); if (ret < 0) return ret; ret = at1_unpack_dequant(&gb, su, q->spec); if (ret < 0) return ret; ret = at1_imdct_block(su, q); if (ret < 0) return ret; at1_subband_synthesis(q, su, q->out_samples[ch]); } if (q->channels == 1) { memcpy(samples, q->out_samples[0], AT1_SU_SAMPLES * 4); } else { for (i = 0; i < AT1_SU_SAMPLES; i++) { samples[i * 2] = q->out_samples[0][i]; samples[i * 2 + 1] = q->out_samples[1][i]; } } *data_size = q->channels * AT1_SU_SAMPLES * sizeof(*samples); return avctx->block_align; }
1threat
Not able to understand dagger dependency injection concepts - Dagger 2 on android : <p>I am trying to understand dagger2 and implement in my app. I have read a lot about its benefits. Unless and until I understand it completely, I cannot get the benefits of it in my app.</p> <p>I have understood @Module and @Inject. The one that confuses me is @Component. I have few questions related to that. </p> <ol> <li><p>Module provides object instances and Inject uses it. Why do we need component in between? Is it really necessary to bridge the gap? Can we have empty Interface components without any methods?</p></li> <li><p>Is constructor really necessary for module class? If there is no constructor in module class, Can we initialize module class using empty constructor?</p></li> <li><p>Why can't we directly instantiate module class and build dependency graph instead of creating component and then initializing it?</p></li> <li><p>I have seen only two kinds of methods in component interface so far</p> <p>a. void inject(Activity/Service/Fragment); - Why do we need to provide an instance of activity or service or fragment to this method? why can't we have something like this - </p> <p>void inject(); - Will the Component still generate dependency graph?</p> <p>Can we inject from some other class other than activity or service or fragment something like this - </p> <p>void inject(DataManager dataManager);</p> <p>What If DataManager was a singleton instance?</p> <p>b. Retrofit getRetrofit(); What is the difference between this method and above method? Why does not this take any input parameters?</p></li> <li><p>I read that @Singleton is just a scope in dagger. How can we actually create a singleton object that lives for lifetime of the application?</p></li> <li><p>Let's suppose there is a DataManager instance that I want to build using dagger. It is having only one dependency. I wrote a module class and a component interface for that. If I want to use this in let's say MainActivity, i use it as </p> <p>@Inject DataManager dataManager;</p> <p>...</p> <p>@Override</p> <p>protected void onCreate(Bundle savedInstanceState) {</p> <p>DataManagerComponent.Builder().DataManagerModule(new DataManagerModule()).build();</p> <p>}</p> <p>I want to use this datamanager in many other activities and I don't want it to be singleton. I want to keep it to the current activity scope where I use it. So I will use </p> <p>@Inject DataManager dataManager; </p> <p>to get that instance. Should I write </p> <pre><code>DataManagerComponent.Builder........... </code></pre> <p>in each and every activity oncreate() where I use @Inject DataManager dataManager? If I have to write that, Will it not create more boilerplate code than simply using </p> <p>DataManager dataManager = new DataManager(); </p></li> <li><p>Let's suppose there are 4 objects and they are dependent on each other like D dependent on C, C dependent on B etc.</p> <p>D -> C -> B -> A</p> <p>Let's suppose I have written module class and provides method for all 4. If I try to inject D in any ActivityA like</p> <p>@Inject D d;</p> <p>Will C, B, A instantiated automatically?</p> <p>Let's suppose in ActivityB I just need to inject B. If I inject B like </p> <p>@Inject B b;</p> <p>Will dagger create B and A again? Or will it use the ones which are already created ?</p></li> </ol> <p>I appreciate if someone takes time to answer all my questions. I don't expect detailed answer. It is fine if it clarifies the concept. Looking forward for the response. Thanks in advance. </p>
0debug
Unit tests in java : Im making an application in android studio. And for this project i have to make multiple unit tests. But i have no idea what i can unit test this application. Im really struggeling with unit testing so i would appreciate if someone could help me, or come up with some unit tests i can implement in my project. Its an app with a listview that retrieves data from a webservice. Code: public class MainActivity extends AppCompatActivity { ListView listView; ArrayAdapter<String> adapter; String[] data; String[] waarde; String[] hoog; String[] laag; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); listView = findViewById(R.id.listview); StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitNetwork().build()); getData(); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(MainActivity.this, Showdata.class); intent.putExtra("teeltbed", listView.getItemAtPosition(position).toString()); startActivity(intent); } }); } private void getData() { String getData = null; String dbResult = "empty"; dbConnect database = new dbConnect(this); try{ String query = "SELECT * FROM Lamp"; getData = "?query=" + URLEncoder.encode(query, "UTF-8"); //data += "&username=" + URLEncoder.encode(userName, "UTF-8"); String link = "http://10.247.240.53/kas/lampen.php"; dbResult = database.execute(link).get(); } catch (Exception e){ } try{ JSONObject jsonObject = new JSONObject(dbResult); JSONArray array = jsonObject.getJSONArray("Lamp"); waarde = new String[array.length()]; data = new String[array.length()]; hoog = new String[array.length()]; laag = new String[array.length()]; for (int i = 0; i < array.length(); i++) { jsonObject = array.getJSONObject(i); data[i] = jsonObject.getString("teeltbed"); waarde[i] = "A: " + jsonObject.getString("waarde") + " %"; hoog[i] = "H: " + jsonObject.getString("hoog") + " W/m2"; laag[i] = "L: " + jsonObject.getString("laag") + " W/m2"; } listView.setAdapter(new dataListAdapter(data, waarde, hoog, laag)); } catch (Exception e) { e.printStackTrace(); } } class dataListAdapter extends BaseAdapter{ String[] data, waarde; dataListAdapter(){ data = null; waarde = null; } public dataListAdapter(String[] sdata, String[]swaarde, String[]shoog, String[]slaag) { data = sdata; waarde = swaarde; hoog = shoog; laag = slaag; } public int getCount() { return data.length; } public Object getItem(int arg0) { // TODO Auto-generated method stub return null; } public long getItemId(int position) { // TODO Auto-generated method stub return position; } public View getView (int position, View convertView, ViewGroup parent) { LayoutInflater inflater = getLayoutInflater(); View row; row = inflater.inflate(R.layout.layout_list, parent, false); TextView t1, t2, t3, t4; t1 = (TextView) row.findViewById(R.id.list_item); t2 = (TextView) row.findViewById(R.id.list_item2); t3 = (TextView) row.findViewById(R.id.list_item3); t4 = (TextView) row.findViewById(R.id.list_item4); t1.setText(data[position]); t2.setText(waarde[position]); t3.setText(hoog[position]); t4.setText(laag[position]); return (row); } } class Sproeier { public int TeeltBed; public String Stand; public double Actueel; public double Hoog; public double Laag; public void Sproeier() { int teeltbed; double hoog; double laag; } } class Lamp { } public static class ScadaWebservice { } class Kas { public void kas() { } } }
0debug
Unable to modify column in MySQL table : <p>I have a requirement wherein I need to change the table structure as per the production environment on a lower environment. The table has a multi-column <strong>PRIMARY KEY as (<code>md_biobjectid</code>,<code>projectid</code>,<code>md_mapid</code>)</strong>, I want to modify column <strong>'md_mapid' to varchar(50) DEFAULT NULL</strong> from <strong>'md_mapid' varchar(50) NOT NULL</strong>.</p> <p>When I am running the query : <strong><em>alter table table_name modify column <code>md_mapid</code> varchar(50) DEFAULT NULL;</em></strong> it doesn't run and I am getting following error : Error Code: 1171. All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead.</p> <p>Other columns structure on both the environment is : 'md_biobjectid' varchar(50) NOT NULL DEFAULT '' </p> <p>'projectid' varchar(50) NOT NULL DEFAULT ''</p> <p>MySQL version : 5.7.21-log.</p>
0debug
Get/match text between brackets if prefix is some string in very big file : <p>I have a text file which is > 13GB and I need to parse only certen events from it.</p> <p>For example structure of the file is like:</p> <pre><code>events internal-soho-ds-missing-neighbour : { ue-context valid : 3533, rnc-module-id valid : 12, c-id-1 valid : 25472, rnc-id-1 valid : 721 } events rrc-measurement-report : { ue-context valid : 3533, rnc-module-id valid : 12, c-id-1 valid : 25472, } </code></pre> <p>After opening file in pythone I need only the part between brackets {} if prefix is "events internal-soho-ds-missing-neighbour :"</p> <p>What is the best way to do it considering that the file is huge 13.8 GB, regex?</p> <p>Thanks in advanced!</p>
0debug
javascript - dynamically create results pages for each table entry : <p>I am building an app that contains results for some tests. The results are kept in a cloud DB. I need to create a page for each entry in this DB that will show the specific results of the current entry. The template is the same for each entry, just need to change the data in it every time.</p> <p>How can I do something like that? Thanks very much, Tal</p>
0debug
int ff_h264_decode_mb_cavlc(const H264Context *h, H264SliceContext *sl) { int mb_xy; int partition_count; unsigned int mb_type, cbp; int dct8x8_allowed= h->ps.pps->transform_8x8_mode; int decode_chroma = h->ps.sps->chroma_format_idc == 1 || h->ps.sps->chroma_format_idc == 2; const int pixel_shift = h->pixel_shift; mb_xy = sl->mb_xy = sl->mb_x + sl->mb_y*h->mb_stride; ff_tlog(h->avctx, "pic:%d mb:%d/%d\n", h->poc.frame_num, sl->mb_x, sl->mb_y); cbp = 0; if (sl->slice_type_nos != AV_PICTURE_TYPE_I) { if (sl->mb_skip_run == -1) sl->mb_skip_run = get_ue_golomb_long(&sl->gb); if (sl->mb_skip_run--) { if (FRAME_MBAFF(h) && (sl->mb_y & 1) == 0) { if (sl->mb_skip_run == 0) sl->mb_mbaff = sl->mb_field_decoding_flag = get_bits1(&sl->gb); } decode_mb_skip(h, sl); return 0; } } if (FRAME_MBAFF(h)) { if ((sl->mb_y & 1) == 0) sl->mb_mbaff = sl->mb_field_decoding_flag = get_bits1(&sl->gb); } sl->prev_mb_skipped = 0; mb_type= get_ue_golomb(&sl->gb); if (sl->slice_type_nos == AV_PICTURE_TYPE_B) { if(mb_type < 23){ partition_count = ff_h264_b_mb_type_info[mb_type].partition_count; mb_type = ff_h264_b_mb_type_info[mb_type].type; }else{ mb_type -= 23; goto decode_intra_mb; } } else if (sl->slice_type_nos == AV_PICTURE_TYPE_P) { if(mb_type < 5){ partition_count = ff_h264_p_mb_type_info[mb_type].partition_count; mb_type = ff_h264_p_mb_type_info[mb_type].type; }else{ mb_type -= 5; goto decode_intra_mb; } }else{ av_assert2(sl->slice_type_nos == AV_PICTURE_TYPE_I); if (sl->slice_type == AV_PICTURE_TYPE_SI && mb_type) mb_type--; decode_intra_mb: if(mb_type > 25){ av_log(h->avctx, AV_LOG_ERROR, "mb_type %d in %c slice too large at %d %d\n", mb_type, av_get_picture_type_char(sl->slice_type), sl->mb_x, sl->mb_y); return -1; } partition_count=0; cbp = ff_h264_i_mb_type_info[mb_type].cbp; sl->intra16x16_pred_mode = ff_h264_i_mb_type_info[mb_type].pred_mode; mb_type = ff_h264_i_mb_type_info[mb_type].type; } if (MB_FIELD(sl)) mb_type |= MB_TYPE_INTERLACED; h->slice_table[mb_xy] = sl->slice_num; if(IS_INTRA_PCM(mb_type)){ const int mb_size = ff_h264_mb_sizes[h->ps.sps->chroma_format_idc] * h->ps.sps->bit_depth_luma; sl->intra_pcm_ptr = align_get_bits(&sl->gb); if (get_bits_left(&sl->gb) < mb_size) { av_log(h->avctx, AV_LOG_ERROR, "Not enough data for an intra PCM block.\n"); return AVERROR_INVALIDDATA; } skip_bits_long(&sl->gb, mb_size); h->cur_pic.qscale_table[mb_xy] = 0; memset(h->non_zero_count[mb_xy], 16, 48); h->cur_pic.mb_type[mb_xy] = mb_type; return 0; } fill_decode_neighbors(h, sl, mb_type); fill_decode_caches(h, sl, mb_type); if(IS_INTRA(mb_type)){ int pred_mode; if(IS_INTRA4x4(mb_type)){ int i; int di = 1; if(dct8x8_allowed && get_bits1(&sl->gb)){ mb_type |= MB_TYPE_8x8DCT; di = 4; } for(i=0; i<16; i+=di){ int mode = pred_intra_mode(h, sl, i); if(!get_bits1(&sl->gb)){ const int rem_mode= get_bits(&sl->gb, 3); mode = rem_mode + (rem_mode >= mode); } if(di==4) fill_rectangle(&sl->intra4x4_pred_mode_cache[ scan8[i] ], 2, 2, 8, mode, 1); else sl->intra4x4_pred_mode_cache[scan8[i]] = mode; } write_back_intra_pred_mode(h, sl); if (ff_h264_check_intra4x4_pred_mode(sl->intra4x4_pred_mode_cache, h->avctx, sl->top_samples_available, sl->left_samples_available) < 0) return -1; }else{ sl->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h->avctx, sl->top_samples_available, sl->left_samples_available, sl->intra16x16_pred_mode, 0); if (sl->intra16x16_pred_mode < 0) return -1; } if(decode_chroma){ pred_mode= ff_h264_check_intra_pred_mode(h->avctx, sl->top_samples_available, sl->left_samples_available, get_ue_golomb_31(&sl->gb), 1); if(pred_mode < 0) return -1; sl->chroma_pred_mode = pred_mode; } else { sl->chroma_pred_mode = DC_128_PRED8x8; } }else if(partition_count==4){ int i, j, sub_partition_count[4], list, ref[2][4]; if (sl->slice_type_nos == AV_PICTURE_TYPE_B) { for(i=0; i<4; i++){ sl->sub_mb_type[i]= get_ue_golomb_31(&sl->gb); if(sl->sub_mb_type[i] >=13){ av_log(h->avctx, AV_LOG_ERROR, "B sub_mb_type %u out of range at %d %d\n", sl->sub_mb_type[i], sl->mb_x, sl->mb_y); return -1; } sub_partition_count[i] = ff_h264_b_sub_mb_type_info[sl->sub_mb_type[i]].partition_count; sl->sub_mb_type[i] = ff_h264_b_sub_mb_type_info[sl->sub_mb_type[i]].type; } if( IS_DIRECT(sl->sub_mb_type[0]|sl->sub_mb_type[1]|sl->sub_mb_type[2]|sl->sub_mb_type[3])) { ff_h264_pred_direct_motion(h, sl, &mb_type); sl->ref_cache[0][scan8[4]] = sl->ref_cache[1][scan8[4]] = sl->ref_cache[0][scan8[12]] = sl->ref_cache[1][scan8[12]] = PART_NOT_AVAILABLE; } }else{ av_assert2(sl->slice_type_nos == AV_PICTURE_TYPE_P); for(i=0; i<4; i++){ sl->sub_mb_type[i]= get_ue_golomb_31(&sl->gb); if(sl->sub_mb_type[i] >=4){ av_log(h->avctx, AV_LOG_ERROR, "P sub_mb_type %u out of range at %d %d\n", sl->sub_mb_type[i], sl->mb_x, sl->mb_y); return -1; } sub_partition_count[i] = ff_h264_p_sub_mb_type_info[sl->sub_mb_type[i]].partition_count; sl->sub_mb_type[i] = ff_h264_p_sub_mb_type_info[sl->sub_mb_type[i]].type; } } for (list = 0; list < sl->list_count; list++) { int ref_count = IS_REF0(mb_type) ? 1 : sl->ref_count[list] << MB_MBAFF(sl); for(i=0; i<4; i++){ if(IS_DIRECT(sl->sub_mb_type[i])) continue; if(IS_DIR(sl->sub_mb_type[i], 0, list)){ unsigned int tmp; if(ref_count == 1){ tmp= 0; }else if(ref_count == 2){ tmp= get_bits1(&sl->gb)^1; }else{ tmp= get_ue_golomb_31(&sl->gb); if(tmp>=ref_count){ av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", tmp); return -1; } } ref[list][i]= tmp; }else{ ref[list][i] = -1; } } } if(dct8x8_allowed) dct8x8_allowed = get_dct8x8_allowed(h, sl); for (list = 0; list < sl->list_count; list++) { for(i=0; i<4; i++){ if(IS_DIRECT(sl->sub_mb_type[i])) { sl->ref_cache[list][ scan8[4*i] ] = sl->ref_cache[list][ scan8[4*i]+1 ]; continue; } sl->ref_cache[list][ scan8[4*i] ]=sl->ref_cache[list][ scan8[4*i]+1 ]= sl->ref_cache[list][ scan8[4*i]+8 ]=sl->ref_cache[list][ scan8[4*i]+9 ]= ref[list][i]; if(IS_DIR(sl->sub_mb_type[i], 0, list)){ const int sub_mb_type= sl->sub_mb_type[i]; const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE_16x8)) ? 2 : 1; for(j=0; j<sub_partition_count[i]; j++){ int mx, my; const int index= 4*i + block_width*j; int16_t (* mv_cache)[2]= &sl->mv_cache[list][ scan8[index] ]; pred_motion(h, sl, index, block_width, list, sl->ref_cache[list][ scan8[index] ], &mx, &my); mx += get_se_golomb(&sl->gb); my += get_se_golomb(&sl->gb); ff_tlog(h->avctx, "final mv:%d %d\n", mx, my); if(IS_SUB_8X8(sub_mb_type)){ mv_cache[ 1 ][0]= mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= mx; mv_cache[ 1 ][1]= mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= my; }else if(IS_SUB_8X4(sub_mb_type)){ mv_cache[ 1 ][0]= mx; mv_cache[ 1 ][1]= my; }else if(IS_SUB_4X8(sub_mb_type)){ mv_cache[ 8 ][0]= mx; mv_cache[ 8 ][1]= my; } mv_cache[ 0 ][0]= mx; mv_cache[ 0 ][1]= my; } }else{ uint32_t *p= (uint32_t *)&sl->mv_cache[list][ scan8[4*i] ][0]; p[0] = p[1]= p[8] = p[9]= 0; } } } }else if(IS_DIRECT(mb_type)){ ff_h264_pred_direct_motion(h, sl, &mb_type); dct8x8_allowed &= h->ps.sps->direct_8x8_inference_flag; }else{ int list, mx, my, i; we should set ref_idx_l? to 0 if we use that later ... if(IS_16X16(mb_type)){ for (list = 0; list < sl->list_count; list++) { unsigned int val; if(IS_DIR(mb_type, 0, list)){ unsigned rc = sl->ref_count[list] << MB_MBAFF(sl); if (rc == 1) { val= 0; } else if (rc == 2) { val= get_bits1(&sl->gb)^1; }else{ val= get_ue_golomb_31(&sl->gb); if (val >= rc) { av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", val); return -1; } } fill_rectangle(&sl->ref_cache[list][ scan8[0] ], 4, 4, 8, val, 1); } } for (list = 0; list < sl->list_count; list++) { if(IS_DIR(mb_type, 0, list)){ pred_motion(h, sl, 0, 4, list, sl->ref_cache[list][ scan8[0] ], &mx, &my); mx += get_se_golomb(&sl->gb); my += get_se_golomb(&sl->gb); ff_tlog(h->avctx, "final mv:%d %d\n", mx, my); fill_rectangle(sl->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4); } } } else if(IS_16X8(mb_type)){ for (list = 0; list < sl->list_count; list++) { for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ unsigned rc = sl->ref_count[list] << MB_MBAFF(sl); if (rc == 1) { val= 0; } else if (rc == 2) { val= get_bits1(&sl->gb)^1; }else{ val= get_ue_golomb_31(&sl->gb); if (val >= rc) { av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", val); return -1; } } }else val= LIST_NOT_USED&0xFF; fill_rectangle(&sl->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 1); } } for (list = 0; list < sl->list_count; list++) { for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ pred_16x8_motion(h, sl, 8*i, list, sl->ref_cache[list][scan8[0] + 16*i], &mx, &my); mx += get_se_golomb(&sl->gb); my += get_se_golomb(&sl->gb); ff_tlog(h->avctx, "final mv:%d %d\n", mx, my); val= pack16to32(mx,my); }else val=0; fill_rectangle(sl->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 4); } } }else{ av_assert2(IS_8X16(mb_type)); for (list = 0; list < sl->list_count; list++) { for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ optimize unsigned rc = sl->ref_count[list] << MB_MBAFF(sl); if (rc == 1) { val= 0; } else if (rc == 2) { val= get_bits1(&sl->gb)^1; }else{ val= get_ue_golomb_31(&sl->gb); if (val >= rc) { av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", val); return -1; } } }else val= LIST_NOT_USED&0xFF; fill_rectangle(&sl->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 1); } } for (list = 0; list < sl->list_count; list++) { for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ pred_8x16_motion(h, sl, i*4, list, sl->ref_cache[list][ scan8[0] + 2*i ], &mx, &my); mx += get_se_golomb(&sl->gb); my += get_se_golomb(&sl->gb); ff_tlog(h->avctx, "final mv:%d %d\n", mx, my); val= pack16to32(mx,my); }else val=0; fill_rectangle(sl->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 4); } } } } if(IS_INTER(mb_type)) write_back_motion(h, sl, mb_type); if(!IS_INTRA16x16(mb_type)){ cbp= get_ue_golomb(&sl->gb); if(decode_chroma){ if(cbp > 47){ av_log(h->avctx, AV_LOG_ERROR, "cbp too large (%u) at %d %d\n", cbp, sl->mb_x, sl->mb_y); return -1; } if (IS_INTRA4x4(mb_type)) cbp = ff_h264_golomb_to_intra4x4_cbp[cbp]; else cbp = ff_h264_golomb_to_inter_cbp[cbp]; }else{ if(cbp > 15){ av_log(h->avctx, AV_LOG_ERROR, "cbp too large (%u) at %d %d\n", cbp, sl->mb_x, sl->mb_y); return -1; } if(IS_INTRA4x4(mb_type)) cbp= golomb_to_intra4x4_cbp_gray[cbp]; else cbp= golomb_to_inter_cbp_gray[cbp]; } } else { if (!decode_chroma && cbp>15) { av_log(h->avctx, AV_LOG_ERROR, "gray chroma\n"); return AVERROR_INVALIDDATA; } } if(dct8x8_allowed && (cbp&15) && !IS_INTRA(mb_type)){ mb_type |= MB_TYPE_8x8DCT*get_bits1(&sl->gb); } sl->cbp= h->cbp_table[mb_xy]= cbp; h->cur_pic.mb_type[mb_xy] = mb_type; if(cbp || IS_INTRA16x16(mb_type)){ int i4x4, i8x8, chroma_idx; int dquant; int ret; GetBitContext *gb = &sl->gb; const uint8_t *scan, *scan8x8; const int max_qp = 51 + 6 * (h->ps.sps->bit_depth_luma - 8); if(IS_INTERLACED(mb_type)){ scan8x8 = sl->qscale ? h->field_scan8x8_cavlc : h->field_scan8x8_cavlc_q0; scan = sl->qscale ? h->field_scan : h->field_scan_q0; }else{ scan8x8 = sl->qscale ? h->zigzag_scan8x8_cavlc : h->zigzag_scan8x8_cavlc_q0; scan = sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0; } dquant= get_se_golomb(&sl->gb); sl->qscale += dquant; if (((unsigned)sl->qscale) > max_qp){ if (sl->qscale < 0) sl->qscale += max_qp + 1; else sl->qscale -= max_qp+1; if (((unsigned)sl->qscale) > max_qp){ av_log(h->avctx, AV_LOG_ERROR, "dquant out of range (%d) at %d %d\n", dquant, sl->mb_x, sl->mb_y); return -1; } } sl->chroma_qp[0] = get_chroma_qp(h->ps.pps, 0, sl->qscale); sl->chroma_qp[1] = get_chroma_qp(h->ps.pps, 1, sl->qscale); if ((ret = decode_luma_residual(h, sl, gb, scan, scan8x8, pixel_shift, mb_type, cbp, 0)) < 0 ) { return -1; } h->cbp_table[mb_xy] |= ret << 12; if (CHROMA444(h)) { if (decode_luma_residual(h, sl, gb, scan, scan8x8, pixel_shift, mb_type, cbp, 1) < 0 ) { return -1; } if (decode_luma_residual(h, sl, gb, scan, scan8x8, pixel_shift, mb_type, cbp, 2) < 0 ) { return -1; } } else { const int num_c8x8 = h->ps.sps->chroma_format_idc; if(cbp&0x30){ for(chroma_idx=0; chroma_idx<2; chroma_idx++) if (decode_residual(h, sl, gb, sl->mb + ((256 + 16*16*chroma_idx) << pixel_shift), CHROMA_DC_BLOCK_INDEX + chroma_idx, CHROMA422(h) ? ff_h264_chroma422_dc_scan : ff_h264_chroma_dc_scan, NULL, 4 * num_c8x8) < 0) { return -1; } } if(cbp&0x20){ for(chroma_idx=0; chroma_idx<2; chroma_idx++){ const uint32_t *qmul = h->ps.pps->dequant4_coeff[chroma_idx+1+(IS_INTRA( mb_type ) ? 0:3)][sl->chroma_qp[chroma_idx]]; int16_t *mb = sl->mb + (16*(16 + 16*chroma_idx) << pixel_shift); for (i8x8 = 0; i8x8<num_c8x8; i8x8++) { for (i4x4 = 0; i4x4 < 4; i4x4++) { const int index = 16 + 16*chroma_idx + 8*i8x8 + i4x4; if (decode_residual(h, sl, gb, mb, index, scan + 1, qmul, 15) < 0) return -1; mb += 16 << pixel_shift; } } } }else{ fill_rectangle(&sl->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1); fill_rectangle(&sl->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1); } } }else{ fill_rectangle(&sl->non_zero_count_cache[scan8[ 0]], 4, 4, 8, 0, 1); fill_rectangle(&sl->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1); fill_rectangle(&sl->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1); } h->cur_pic.qscale_table[mb_xy] = sl->qscale; write_back_non_zero_count(h, sl); return 0; }
1threat
How to add an event on a menu in C# visual basic project? : I have a C# Visual Basic Windows Forms App that contain a menu bar. I want to display a Help Message when I press on the "HELP" menu button. All that I can see when I press view code is this: private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { } I think that I need to create inside the function a MessageBox or an event that will display the desired message. Do you have any idea how should I do this, please?
0debug
Unique Identification number genrator using java : I am trying to create a uid genrator with java using file writer and reader i want it to generete id with serial 1 then 2 then 3 and so. on. but it isn't working correctly i want to store it in file so that it starts from last ended number when program starts again.
0debug
How do I find a shell script that accepts one or more arguments, and outputs a line for each argument that names an ASCII file? : I understand that I have to use an array of arguments, but have no experience doing so. I am using Emacs for my shell scripting. This is what I have so far: #!/bin/bash find $@ -type f -exec file {} + | grep ASCII
0debug
Get field from class using reflection c# : How to get all fields from `SuperClass1` by reflection? namespace ConsoleApplication9 { class Program { static void Main(string[] args) { SuperClass1.SubClass1 class1 = new SuperClass1.SubClass1(); SuperClass2.SubClass2 class2 = new SuperClass2.SubClass2(); PrintAllFields(class1); } public static void PrintAllFields(object obj) { var SuperClassType = obj.GetType(); SuperClassType.GetFields(); } } public class SuperClass1 { public int param1; public int param2; public int param3; public class SubClass1 { public int paramTest; } } public class SuperClass2 { public int param4; public int param5; public class SubClass2 { public int paramTest; } } }
0debug
import re def multiple_split(text): return (re.split('; |, |\*|\n',text))
0debug
why Context context = View.getRootView.getContext(); won't work? : i don't know how that code work. What's wrong with that ? Why its not work ? How i can replace it ? The android studio said that cannot resolve symbol getRootView. `@Override public void onClick(View v) { Context context = View.getRootView.getContext(); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View formElementsView = inflater.inflate(R.layout.activity_add_menu,null,false); final EditText menu_id = (EditText) formElementsView.findViewById(R.id.ed1); final EditText menu_name = (EditText) formElementsView.findViewById(R.id.ed2); final EditText menu_price = (EditText) formElementsView.findViewById(R.id.ed3); final EditText menu_desc = (EditText) formElementsView.findViewById(R.id.ed4); new AlertDialog.Builder(context) .setView(formElementsView) .setTitle("Create Menu") .setPositiveButton("Add", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).show(); }`
0debug
static int http_send_data(HTTPContext *c, long cur_time) { int len, ret; while (c->buffer_ptr >= c->buffer_end) { ret = http_prepare_data(c, cur_time); if (ret < 0) return -1; else if (ret == 0) { continue; } else { return 0; } } if (c->buffer_end > c->buffer_ptr) { len = write(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr); if (len < 0) { if (errno != EAGAIN && errno != EINTR) { return -1; } } else { c->buffer_ptr += len; c->data_count += len; if (c->stream) c->stream->bytes_served += len; } } return 0; }
1threat
How i Do video face Swapping in iOS? : <p>The face swap has become a time-honored tradition of Internet weirdness, and a new app lets you do it live, putting no wait time between the decision to do it and the feelings of regret that the results produce.</p>
0debug
Syntax Error Ocurring on the Data Adapter : [![Link-1 shows the Error][1]][1] [![Link-2 shows the Code][2]][2] [1]: https://i.stack.imgur.com/97gd6.png [2]: https://i.stack.imgur.com/csOXg.png `try { int i = 0; using (SqlConnection sqlCon = new SqlConnection(Form1.connectionString)) { string commandString = "INSERT INTO Logindetail (Account,ID,Logint,Logoutt) values ('" + acc + "'," + textbxID.Text + "," + null + ", SYSDATETIME()" + ");"; // MessageBox.Show(commandString); SqlCommand sqlCmd = new SqlCommand(commandString, sqlCon); sqlCon.Open(); SqlDataReader dr = sqlCmd.ExecuteReader(); i = 1; if (i == 0) { MessageBox.Show("Error in Logging In!", "Error"); } MessageBox.Show("Successfully Logged In"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); }` I'm making a LoginForm for a Project.I have created a table which shows the LoginDetails(Account,ID,LoginTime,LogoutTime).But when I run the Program,it doesn't runs successfully.I face an error which is in Pic-2.When I remove sql 'data adapter',the program runs without displaying the error.
0debug
calculate balance sheet with fastest algorithem : I am implementing accounting software, in calculating balance sheet of the Hirarchical self referenced topics please let me know the fastest algorithem , in following is my tables: --Topics table TopicID nvarchar(50) -- is Parent Field ParentID nvarchar(50) -- is Child Field Description nvarchar(512) ------------DocumentDetal table DocumentNumber nvarchar(50) TopicFK nvarchar(50) Debit decimal(18,0) Credit decimal(18,0) ------------ two table are related with TopicID and TopicFK columns , please let me know how I can calculate balance sheet by sql stored proc ???
0debug
How to divide the String into Similar repeating characters which are non repeating : > I have a String like "abcabcabcabc" I know it will be divided into 4 equal parts as the pattern repeats itself after every 3rd character so the breaking condition will be "a" repeating again. I was thinking if I can record the count and see if the count of all the repeating characters are equal so now I can divide my String from that point there are a lot of things running in my mind but unable to take the right approach, 2nd test case is "abccbaabccba", it should be divided from abccba - abccba import java.util.Arrays; public class EvenPattern { public static void FindPattern(String s){ for( Character c : ls){ System.out.print(c+" "); } int no_of_characters = 256; int[] count = new int[no_of_characters]; Arrays.fill(count,0); for( int i= 0 ; i < s.length();i++){ count[s.charAt(i)]++; } } public static void main(String[] args) { String s = "abcabcabd"; FindPattern(s); } }
0debug
How can I cancel a trade when another is open and keep the open trade for a given duration? : <p>I have written the code below that opens a buy and sell trade (a certain number of pips above and below the ask and bid price) at a specific time.</p> <ol> <li><p>How can I close/cancel one immediately when the other is opened?</p></li> <li><p>How can I close the opened trade if it's say X pips in profit or after a minute (depending on which condition is reached first)?</p></li> </ol> <p>I'm a not too sure I've done the right thing in the code below and would really appreciate some help.</p> <pre><code>double spread = Ask-Bid; extern datetime time; extern int pipGap = 7; extern int lotSize = 0.01; extern int closeTimeInSeconds = 60; int start() { if (TimeCurrent() &gt;= StrToTime(time)){ OrderSend(Symbol(),OP_BUYSTOP,lotSize, Ask + Point*pipGap, 0,0,0); OrderSend(Symbol(),OP_SELLSTOP,lotSize, Bid - Point*pipGap, 0,0,0); } for(int pos = OrdersTotal()-1; pos &gt;= 0 ; pos--) if ( OrderSelect(pos, SELECT_BY_POS) ){ int duration = TimeCurrent() - OrderOpenTime(); if (duration &gt;= closeTimeInSeconds) OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), 3*Point); } return(0); } </code></pre>
0debug
static int svq1_motion_inter_block(DSPContext *dsp, GetBitContext *bitbuf, uint8_t *current, uint8_t *previous, int pitch, svq1_pmv *motion, int x, int y) { uint8_t *src; uint8_t *dst; svq1_pmv mv; svq1_pmv *pmv[3]; int result; pmv[0] = &motion[0]; if (y == 0) { pmv[1] = pmv[2] = pmv[0]; } else { pmv[1] = &motion[x / 8 + 2]; pmv[2] = &motion[x / 8 + 4]; } result = svq1_decode_motion_vector(bitbuf, &mv, pmv); if (result != 0) return result; motion[0].x = motion[x / 8 + 2].x = motion[x / 8 + 3].x = mv.x; motion[0].y = motion[x / 8 + 2].y = motion[x / 8 + 3].y = mv.y; if (y + (mv.y >> 1) < 0) mv.y = 0; if (x + (mv.x >> 1) < 0) mv.x = 0; src = &previous[(x + (mv.x >> 1)) + (y + (mv.y >> 1)) * pitch]; dst = current; dsp->put_pixels_tab[0][(mv.y & 1) << 1 | (mv.x & 1)](dst, src, pitch, 16); return 0; }
1threat
I tried utilsing $_POST, $_GET and $_REQUEST but none of them work. What should I use to save answers from the inputs? : <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <!DOCTYPE html> <html> <head> <title>Sign Up</title> </head> <body> <form method="POST"> <input type="text" name="first" id='first'> <input type="text" name='last' id='last'> <button type='submit' name='submit'>Click</button> </form> //WHERE THE INFORMATION IS ASKED <?php //WHERE I ATTEMPT TO SAVE THE INFORMATION BUT I FAIL include_once 'dbh.inc.php'; $first = $_POST['first']; $last = $_POST['last']; /*Notice: Undefined index: first in C:\xampp\htdocs\index.php on line 14 Notice: Undefined index: last in C:\xampp\htdocs\index.php on line 15*/ $sql = "INSERT INTO keep1(Firstname, Lastname) VALUES('$first', '$last');"; mysqli_query($conn, $sql); ?> </body> </html> <!-- end snippet --> ------------------------------------------------------------------------
0debug
What is the base address of a c program environment from the execle command? : I am reading the book "Hacking: The art of exploitation" and I have some problems with the code of exploit_notesearch_env.c It is attempting to do a buffer overflow exploit by calling the program to be exploited with the "execle" command. That way the only environment variable of the program to be exploited will be the shellcode. My problem is that I can't figure the address of the shellcode environment variable out. The book says that the base address was 0xbffffffa and then subtracts the size of the shellcode and the length of the program name from it to obtain the shellcode address. This is the code of exploit_notesearch_env.c which calls the notesearch program: ``` #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdint.h> #include <unistd.h> char shellcode[]= "SHELLCODE=\x48\xbb\x2f\x2f\x62\x69\x6e\x2f\x73\x68\x48\xc1\xeb\x08\x53\x48\x89\xe7\x50\x57\x48\x89\xe6\xb0\x3b\x0f\x05"; int main(int argc, char *argv[]) { char *env[2] = {shellcode, (char *) 0}; uint64_t i, ret; char *buffer = (char *) malloc(160); ret = 0xbffffffa - (sizeof(shellcode)-1) - strlen("./notesearch"); memset(buffer, '\x90', 120); *((uint64_t *)(buffer+120)) = ret; execle("./notesearch", "notesearch", buffer, (char *) 0, env); free(buffer); } ``` By the way the book uses a 32 bit Linux distro while I am using Kali Linux 2019.4 64 bit version which might be the origin of the problem. The shellcode is already adjusted for 64 bits and the program correctly overflows the buffer but only with the wrong address. Does anyone know the right substitute for the address 0xbffffffa from the book?
0debug
How method look up works in Ruby? : From what I read, the method look up works scanning the object's class, and scanning for any method defined there. If it's not found there, we keep moving the hierarchial chain until we find it. It makes sense for this: Class A def hello p 'hello world' end end A.new.hello (hello is defined in A.new.class). But it doesn't work like this when we call a method on Class object. Eg: class A def self.hello p 'hello world' end end A.hello This should link A -> Eigen class with method `hello` -> Object --> BasicObject .. And how ruby find the method is by looking at object's class and then moving up the ladder. So it should have looked the method at `A.class` which is `Class`, and never found the method `hello`?
0debug
C# How to deal with arrays inside a struct? : I'm looking for a way to replace some of my List objects with arrays in my project to boost performance. The reasoning is that the List I would replace do not change size often (sometimes only once), so it would make sense to swap them out with arrays. Also, I would like to prevent allocations on the heap as much as possible. So my idea is to create a struct with two members "Count" and "Array". The struct would have some functions to add/remove/get/set/ect... elements in the array. The count would keep count of the elements that are usable in the array, and the array would only increase in size, never decrease. Note that this is for a very particular case because I know the array size won't be very big. So the main problem I have with that set up is when I use the assignment operator to copy the struct as the array is now shared between two variables instead of a having a new copy of the array. The only thing I could come up with as an idea was trying to override the assignment operator so that it would create a new array on assignment... but obviously that does not work. My ArrayStruct ```c# public struct ArrayStruct<T> { [SerializeField] private int m_Count; [SerializeField] private T[] m_Array; public int Count => m_Count; public void Initialize(int startSize) { m_Count = 0; m_Array = new T[startSize]; } public T GetAt(int index) { return m_Array[index]; } public void SetAt(int index, T newValue) { m_Array[index] = newValue; } public void Add(T newElement) { if (m_Array == null) { m_Array = new T[1]; } else if (m_Array.Length == m_Count) { System.Array.Resize(ref m_Array, m_Count + 1); } m_Array[m_Count] = newElement; m_Count++; } public void Remove(T element) { for (int i = 0; i < m_Count; ++i) { if (!element.Equals(m_Array[i])) { continue; } for (int j = index; j < m_Count - 1; ++j) { m_Array[j] = m_Array[j + 1]; } m_Count--; m_Array[m_Count] = default(T); break; } } //Trying to overload the = operating by creating a auto cast, this gives a compile error /*public static implicit operator ArrayStruct<T>(ArrayStruct<T> otherArray) { var newArray = new ArrayStruct<T>(); newArray.m_Count = otherArray.Count; newArray.m_Array = new T[otherArray.Length]; otherArray.m_Array.CopyTo(newArray.m_Array); return newArray; }*/ ``` An example showcasing the problem ```c# var a = new ArrayStruct<string>() a.Add("hello"); var b = a; print (b.GetAt(0)); //"hello" a.SetAt(0, "new value for a"); print(b.GetAt(0));//"new value for a" , changing a changed b because the array is the same in both, this is bad a.Add("resizing array"); print (b.GetAt(1)); //"Out of range exception" , because the array was resized for a but not for b therefore the connection broke ``` So do any of you have an idea of how I could make a new copy the array when I assign the struct to another variable? Of course, I know I could use a function to do something like so b = new ArrayStruct(a); But I want it to be implicit. Or if there was a way to prevent assignments that would also work for me. var a = new ArrayStruct();//let this work var b = a; //Prevent this from happening If you have any other solutions for replacing Lists with arrays conveniently please let me know
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
I want to Shorten this piece of code in C# : So Im working on a project and i did this huge loop that i want to shorten Here is the Loop is question : if (secound < 10) TimerLabel.Text = $"{Hour}:{Minute}:0{secound}"; if (Minute< 10) TimerLabel.Text = $"{Hour}:0{Minute}:{secound}"; if (Hour < 10) TimerLabel.Text = $"0{Hour}:{Minute}:{secound}"; if(secound <10 && Minute < 10) TimerLabel.Text = $"{Hour}:0{Minute}:0{secound}"; if (secound < 10 && Hour < 10) TimerLabel.Text = $"0{Hour}:{Minute}:0{secound}"; if(Minute < 10 && Hour < 10) TimerLabel.Text = $"0{Hour}:0{Minute}:{secound}"; if(Hour < 10 && Minute < 10 && secound < 10) TimerLabel.Text = $"0{Hour}:0{Minute}:0{secound}"; it long .
0debug
Google Chrome Create Extra space on Right Side of My Website : <p>I am working on a Responsive Layout for my Website. I have an extra space on the Right side for English and Left side for Arabic Version, I can not exactly determine were does it come from. this responsive it looks good in FireFox but in Google Chrome creates it. link of my website : <a href="http://kirkuknow.com/english/" rel="nofollow noreferrer">http://kirkuknow.com/english/</a> change the website to mobile version at inspect element</p> <p>Best<a href="https://i.stack.imgur.com/lleRN.png" rel="nofollow noreferrer">enter image description here</a></p>
0debug
Pandas cumulative count : <p>I have a data frame like this:</p> <pre><code>0 04:10 obj1 1 04:10 obj1 2 04:11 obj1 3 04:12 obj2 4 04:12 obj2 5 04:12 obj1 6 04:13 obj2 </code></pre> <p>Wanted to get a cumulative count for all the objects like this:</p> <pre><code>idx time object obj1_count obj2_count 0 04:10 obj1 1 0 1 04:10 obj1 2 0 2 04:11 obj1 3 0 3 04:12 obj2 3 1 4 04:12 obj2 3 2 5 04:12 obj1 4 2 6 04:13 obj2 4 3 </code></pre> <p>Tried playing with cumsum but not sure that is the right way. Any suggestions?</p>
0debug
Create Save And Load Functionality For A Winform : <p>I have a winform with 5 text boxes and 2 data grids. I need a way of being able to press a button (or adding a menu at the top with a file button and select save from there) and save all of the values to a file that the user selects location/name for. Then I need a button (or again a menu option) to load the file that was previously saved and all the values from the "save" will be generated on screen so that it looks as if you just input all values.</p> <p>How is this achieved in VS2017?</p>
0debug
static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu, TranslationBlock *tb, int search_pc) { struct DisasContext ctx, *dc = &ctx; uint16_t *gen_opc_end; uint32_t pc_start; int j, k; uint32_t next_page_start; int num_insns; int max_insns; qemu_log_try_set_file(stderr); pc_start = tb->pc; dc->tb = tb; gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE; dc->is_jmp = DISAS_NEXT; dc->ppc = pc_start; dc->pc = pc_start; dc->flags = cpu->env.cpucfgr; dc->mem_idx = cpu_mmu_index(&cpu->env); dc->synced_flags = dc->tb_flags = tb->flags; dc->delayed_branch = !!(dc->tb_flags & D_FLAG); dc->singlestep_enabled = cpu->env.singlestep_enabled; if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { qemu_log("-----------------------------------------\n"); log_cpu_state(&cpu->env, 0); } next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; k = -1; num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } gen_icount_start(); do { check_breakpoint(cpu, dc); if (search_pc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; if (k < j) { k++; while (k < j) { tcg_ctx.gen_opc_instr_start[k++] = 0; } } tcg_ctx.gen_opc_pc[k] = dc->pc; tcg_ctx.gen_opc_instr_start[k] = 1; tcg_ctx.gen_opc_icount[k] = num_insns; } if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) { tcg_gen_debug_insn_start(dc->pc); } if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) { gen_io_start(); } dc->ppc = dc->pc - 4; dc->npc = dc->pc + 4; tcg_gen_movi_tl(cpu_ppc, dc->ppc); tcg_gen_movi_tl(cpu_npc, dc->npc); disas_openrisc_insn(dc, cpu); dc->pc = dc->npc; num_insns++; if (dc->delayed_branch) { dc->delayed_branch--; if (!dc->delayed_branch) { dc->tb_flags &= ~D_FLAG; gen_sync_flags(dc); tcg_gen_mov_tl(cpu_pc, jmp_pc); tcg_gen_mov_tl(cpu_npc, jmp_pc); tcg_gen_movi_tl(jmp_pc, 0); tcg_gen_exit_tb(0); dc->is_jmp = DISAS_JUMP; break; } } } while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end && !cpu->env.singlestep_enabled && !singlestep && (dc->pc < next_page_start) && num_insns < max_insns); if (tb->cflags & CF_LAST_IO) { gen_io_end(); } if (dc->is_jmp == DISAS_NEXT) { dc->is_jmp = DISAS_UPDATE; tcg_gen_movi_tl(cpu_pc, dc->pc); } if (unlikely(cpu->env.singlestep_enabled)) { if (dc->is_jmp == DISAS_NEXT) { tcg_gen_movi_tl(cpu_pc, dc->pc); } gen_exception(dc, EXCP_DEBUG); } else { switch (dc->is_jmp) { case DISAS_NEXT: gen_goto_tb(dc, 0, dc->pc); break; default: case DISAS_JUMP: break; case DISAS_UPDATE: tcg_gen_exit_tb(0); break; case DISAS_TB_JUMP: break; } } gen_icount_end(tb, num_insns); *tcg_ctx.gen_opc_ptr = INDEX_op_end; if (search_pc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; k++; while (k <= j) { tcg_ctx.gen_opc_instr_start[k++] = 0; } } else { tb->size = dc->pc - pc_start; tb->icount = num_insns; } #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { qemu_log("\n"); log_target_disas(&cpu->env, pc_start, dc->pc - pc_start, 0); qemu_log("\nisize=%d osize=%td\n", dc->pc - pc_start, tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf); } #endif }
1threat
static void get_lag(float *buf, const float *new, LongTermPrediction *ltp) { int i, j, lag, max_corr = 0; float max_ratio; for (i = 0; i < 2048; i++) { float corr, s0 = 0.0f, s1 = 0.0f; const int start = FFMAX(0, i - 1024); for (j = start; j < 2048; j++) { const int idx = j - i + 1024; s0 += new[j]*buf[idx]; s1 += buf[idx]*buf[idx]; } corr = s1 > 0.0f ? s0/sqrt(s1) : 0.0f; if (corr > max_corr) { max_corr = corr; lag = i; max_ratio = corr/(2048-start); } } ltp->lag = FFMAX(av_clip_uintp2(lag, 11), 0); ltp->coef_idx = quant_array_idx(max_ratio, ltp_coef, 8); ltp->coef = ltp_coef[ltp->coef_idx]; }
1threat
Make a Div as Hexagon from one of it's sides : <p>How can I make a Div with it's background Image looks like a Hexagon from one side.<br> Here's an example of what I need exactly : <a href="http://livedemo00.template-help.com/wt_57806/" rel="nofollow">Demo</a></p> <p>The header in the example/Demo shaped as Hexagon from it's bottom side</p>
0debug
Cache function execution in javascript : I recently had an interview where I was asked that how could you cache execution of any function? I was stuck with answer as I heard about **Functional Caching in Javascript** only. I checked on [Stack overflow][1] but not getting any idea from this.Is there any way to cache execution of any function in javascript? [1]: https://stackoverflow.com/questions/6090391/how-is-this-javascript-function-caching-its-results
0debug
def is_subset_sum(set, n, sum): if (sum == 0): return True if (n == 0): return False if (set[n - 1] > sum): return is_subset_sum(set, n - 1, sum) return is_subset_sum(set, n-1, sum) or is_subset_sum(set, n-1, sum-set[n-1])
0debug
I want to call three.js inside a div : I was trying to call three.js webgl particles waves inside a <div> with custom size (responsive). I got a codepen exapmle [https://codepen.io/deathfang/pen/WxNVoq][1] but this example not meeting my requirements. <div id="container"></div> I want this inside my custom div [1]: https://codepen.io/deathfang/pen/WxNVoq
0debug
void cpu_x86_update_dr7(CPUX86State *env, uint32_t new_dr7) { int i; for (i = 0; i < DR7_MAX_BP; i++) { hw_breakpoint_remove(env, i); } env->dr[7] = new_dr7; for (i = 0; i < DR7_MAX_BP; i++) { hw_breakpoint_insert(env, i); } }
1threat
static int find_pte32(CPUPPCState *env, struct mmu_ctx_hash32 *ctx, target_ulong eaddr, int h, int rwx, int target_page_bits) { hwaddr pteg_off; target_ulong pte0, pte1; int i, good = -1; int ret, r; ret = -1; pteg_off = get_pteg_offset32(env, ctx->hash[h]); for (i = 0; i < HPTES_PER_GROUP; i++) { pte0 = ppc_hash32_load_hpte0(env, pteg_off + i*HASH_PTE_SIZE_32); pte1 = ppc_hash32_load_hpte1(env, pteg_off + i*HASH_PTE_SIZE_32); r = pte_check_hash32(ctx, pte0, pte1, h, rwx); LOG_MMU("Load pte from %08" HWADDR_PRIx " => " TARGET_FMT_lx " " TARGET_FMT_lx " %d %d %d " TARGET_FMT_lx "\n", pteg_off + (i * 8), pte0, pte1, (int)(pte0 >> 31), h, (int)((pte0 >> 6) & 1), ctx->ptem); switch (r) { case -3: return -1; case -2: ret = -2; good = i; break; case -1: default: break; case 0: ret = 0; good = i; goto done; } } if (good != -1) { done: LOG_MMU("found PTE at addr %08" HWADDR_PRIx " prot=%01x ret=%d\n", ctx->raddr, ctx->prot, ret); pte1 = ctx->raddr; if (ppc_hash32_pte_update_flags(ctx, &pte1, ret, rwx) == 1) { ppc_hash32_store_hpte1(env, pteg_off + good * HASH_PTE_SIZE_32, pte1); } } if (target_page_bits != TARGET_PAGE_BITS) { ctx->raddr |= (eaddr & ((1 << target_page_bits) - 1)) & TARGET_PAGE_MASK; } return ret; }
1threat
static void term_init(void) { struct termios tty; tcgetattr (0, &tty); oldtty = tty; tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP |INLCR|IGNCR|ICRNL|IXON); tty.c_oflag |= OPOST; tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN); tty.c_cflag &= ~(CSIZE|PARENB); tty.c_cflag |= CS8; tty.c_cc[VMIN] = 1; tty.c_cc[VTIME] = 0; tcsetattr (0, TCSANOW, &tty); atexit(term_exit); }
1threat
static void adb_kbd_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); ADBDeviceClass *adc = ADB_DEVICE_CLASS(oc); ADBKeyboardClass *akc = ADB_KEYBOARD_CLASS(oc); akc->parent_realize = dc->realize; dc->realize = adb_kbd_realizefn; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); adc->devreq = adb_kbd_request; dc->reset = adb_kbd_reset; dc->vmsd = &vmstate_adb_kbd; }
1threat
How to block screenshot when my app is active in IOS : <p><strong>NETFLIX</strong> app prevents screen shots and screen recording over its app in IOS devices. How to implement this feature in my app?</p>
0debug
insert elements in the collection based on multiple keys : <p>I Have a query result with many fields, and i have to insert only unique rows in the collection based on the 3 columns of the table using java code.</p> <p>Suppose query result is like below :</p> <p>Col A | Col B | Col C | Col D| Col E</p> <p>1 | 2 | 1 | V1 | A</p> <p>1 | 2 | 1 | V2 | A</p> <p>2 | 1 | 1 | V3 | B</p> <p>3 | 2 | 2 | V4 | C</p> <p>2 | 1 | 1 | V5 | B</p> <p>Here for row 1 and 2 are duplicate as per combination of col A + Col B + Col C and row 3 and row 5 are also duplicate.</p> <p>So i have to insert only unique values in the collection based on col A,col B and Col C</p> <p>Result :Row 1,3,4 should be interested in the collection rest shouldn't. Please suggest me solution. </p>
0debug
Build flutter app for desktops : <p>I saw a few peoples managed to build flutter apps for other OS than the usual Android/IOS</p> <p>My question here is simple : How ? What is the current process to build a flutter app for mac/windows ? There's no need for it to be <em>production ready</em>. Something experimental is enough</p>
0debug
i get an error when i run this code . : ij package demo; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.OutputStream; import org.apache.poi.openxml4j.opc.*; import org.apache.poi.xwpf.converter.pdf.PdfConverter; import org.apache.poi.xwpf.converter.pdf.PdfOptions; import org.apache.poi.xwpf.usermodel.XWPFDocument; public class DocxToPdf { public static void main(String[] args){ try { String inputFile = "F:\\MY WORK\\CollectionPractice\\WebContent\\APCR1.docx"; String outputFile = "F:\\MY WORK\\CollectionPractice\\WebContent\\APCR1.pdf"; System.out.println("inputFile:" + inputFile + ",outputFile:" + outputFile); FileInputStream in = new FileInputStream(inputFile); XWPFDocument document = new XWPFDocument(in); File outFile = new File(outputFile); OutputStream out = new FileOutputStream(outFile); PdfOptions options = null; PdfConverter.getInstance().convert(document, out, options); } catch (Exception e) { e.printStackTrace(); } } } when i run this code an error occur like these and i have used following jar files also. error: java.lang.NoSuchMethodError: org.apache.poi.POIXMLDocumentPart.getPackageRelationship()Lorg/apache/poi/openxml4j/opc/PackageRelationship; jars: [List of jar files][1] [1]: https://i.stack.imgur.com/qtF0S.png
0debug
static void search_for_quantizers_twoloop(AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce, const float lambda) { int start = 0, i, w, w2, g; int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / avctx->channels * (lambda / 120.f); float dists[128] = { 0 }, uplims[128] = { 0 }; float maxvals[128]; int fflag, minscaler; int its = 0; int allz = 0; float minthr = INFINITY; destbits = FFMIN(destbits, 5800); for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { for (g = 0; g < sce->ics.num_swb; g++) { int nz = 0; float uplim = 0.0f, energy = 0.0f; for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; uplim += band->threshold; energy += band->energy; if (band->energy <= band->threshold || band->threshold == 0.0f) { sce->zeroes[(w+w2)*16+g] = 1; continue; } nz = 1; } uplims[w*16+g] = uplim *512; sce->zeroes[w*16+g] = !nz; if (nz) minthr = FFMIN(minthr, uplim); allz |= nz; } } for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { for (g = 0; g < sce->ics.num_swb; g++) { if (sce->zeroes[w*16+g]) { sce->sf_idx[w*16+g] = SCALE_ONE_POS; continue; } sce->sf_idx[w*16+g] = SCALE_ONE_POS + FFMIN(log2f(uplims[w*16+g]/minthr)*4,59); } } if (!allz) return; abs_pow34_v(s->scoefs, sce->coeffs, 1024); for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { start = w*128; for (g = 0; g < sce->ics.num_swb; g++) { const float *scaled = s->scoefs + start; maxvals[w*16+g] = find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled); start += sce->ics.swb_sizes[g]; } } do { int tbits, qstep; minscaler = sce->sf_idx[0]; qstep = its ? 1 : 32; do { int prev = -1; tbits = 0; for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { start = w*128; for (g = 0; g < sce->ics.num_swb; g++) { const float *coefs = sce->coeffs + start; const float *scaled = s->scoefs + start; int bits = 0; int cb; float dist = 0.0f; if (sce->zeroes[w*16+g] || sce->sf_idx[w*16+g] >= 218) { start += sce->ics.swb_sizes[g]; continue; } minscaler = FFMIN(minscaler, sce->sf_idx[w*16+g]); cb = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]); for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { int b; dist += quantize_band_cost(s, coefs + w2*128, scaled + w2*128, sce->ics.swb_sizes[g], sce->sf_idx[w*16+g], cb, 1.0f, INFINITY, &b, 0); bits += b; } dists[w*16+g] = dist - bits; if (prev != -1) { bits += ff_aac_scalefactor_bits[sce->sf_idx[w*16+g] - prev + SCALE_DIFF_ZERO]; } tbits += bits; start += sce->ics.swb_sizes[g]; prev = sce->sf_idx[w*16+g]; } } if (tbits > destbits) { for (i = 0; i < 128; i++) if (sce->sf_idx[i] < 218 - qstep) sce->sf_idx[i] += qstep; } else { for (i = 0; i < 128; i++) if (sce->sf_idx[i] > 60 - qstep) sce->sf_idx[i] -= qstep; } qstep >>= 1; if (!qstep && tbits > destbits*1.02 && sce->sf_idx[0] < 217) qstep = 1; } while (qstep); fflag = 0; minscaler = av_clip(minscaler, 60, 255 - SCALE_MAX_DIFF); for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { for (g = 0; g < sce->ics.num_swb; g++) { int prevsc = sce->sf_idx[w*16+g]; if (dists[w*16+g] > uplims[w*16+g] && sce->sf_idx[w*16+g] > 60) { if (find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]-1)) sce->sf_idx[w*16+g]--; else sce->sf_idx[w*16+g]-=2; } sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], minscaler, minscaler + SCALE_MAX_DIFF); sce->sf_idx[w*16+g] = FFMIN(sce->sf_idx[w*16+g], 219); if (sce->sf_idx[w*16+g] != prevsc) fflag = 1; sce->band_type[w*16+g] = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]); } } its++; } while (fflag && its < 10); }
1threat
Handler to run task every 5 seconds Kotlin : <p>I would like to run a certain code every 5 seconds. I am having trouble achieving this with a handler. How can this be done in Kotlin? Here is what I have so far. Also to note, the variable Timer_Preview is a Handler.</p> <p><a href="https://i.stack.imgur.com/U9pAv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/U9pAv.png" alt="My Code"></a></p>
0debug
static void mem_info_32(Monitor *mon, CPUState *env) { int l1, l2, prot, last_prot; uint32_t pgd, pde, pte; target_phys_addr_t start, end; pgd = env->cr[3] & ~0xfff; last_prot = 0; start = -1; for(l1 = 0; l1 < 1024; l1++) { cpu_physical_memory_read(pgd + l1 * 4, &pde, 4); pde = le32_to_cpu(pde); end = l1 << 22; if (pde & PG_PRESENT_MASK) { if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { prot = pde & (PG_USER_MASK | PG_RW_MASK | PG_PRESENT_MASK); mem_print(mon, &start, &last_prot, end, prot); } else { for(l2 = 0; l2 < 1024; l2++) { cpu_physical_memory_read((pde & ~0xfff) + l2 * 4, &pte, 4); pte = le32_to_cpu(pte); end = (l1 << 22) + (l2 << 12); if (pte & PG_PRESENT_MASK) { prot = pte & (PG_USER_MASK | PG_RW_MASK | PG_PRESENT_MASK); } else { prot = 0; } mem_print(mon, &start, &last_prot, end, prot); } } } else { prot = 0; mem_print(mon, &start, &last_prot, end, prot); } } }
1threat
Dependency injection into abstract class typescript(Angular2) : <p>I have abstract class(without constructor) and I want to inject another class into it.</p> <p>Abstract class:</p> <pre><code>import { ErrorHandler } from '../../shared/services/errorHandler.service'; import { Inject } from '@angular/core'; export abstract class BaseApiComponent&lt;T&gt; { @Inject(ErrorHandler) errorHandler: ErrorHandler; this.errorHandler.test(); } </code></pre> <p>Injected class:</p> <pre><code>import { Injectable } from '@angular/core'; @Injectable() export class ErrorHandler { constructor() { } public test() { console.log('Test'); } } </code></pre> <p>And I have next error</p> <pre><code>ORIGINAL EXCEPTION: TypeError: Cannot read property 'test' of undefined </code></pre> <p>How i can fix this? </p>
0debug
How can I optimize a query that returns a lot of records, then order by a date field and return only the latest one? : <p>I am not so into database and I have the following doubt about the possible optimization of this query (defined on a <strong>MySql</strong> database):</p> <pre><code>SELECT MCPS.id AS series_id, MD_CD.market_details_id AS market_id, MD_CD.commodity_details_id AS commodity_id, MD.market_name AS market_name, MCPS.price_date AS price_date, MCPS.avg_price AS avg_price, CU.ISO_4217_cod AS currency, MU.unit_name AS measure_unit, CD.commodity_name_en, CN.commodity_name FROM Market_Commodity_Price_Series AS MCPS INNER JOIN MeasureUnit AS MU ON MCPS.measure_unit_id = MU.id INNER JOIN Currency AS CU ON MCPS.currency_id = CU.id INNER JOIN MarketDetails_CommodityDetails AS MD_CD ON MCPS.market_commodity_details_id = MD_CD.id INNER JOIN MarketDetails AS MD ON MD_CD.market_details_id = MD.id INNER JOIN CommodityDetails AS CD ON MD_CD.commodity_details_id = CD.id INNER JOIN CommodityName AS CN ON CD.id = CN.commodity_details_id INNER JOIN Languages AS LN ON CN.language_id = LN.id WHERE MD.id = 4 AND CD.id = 4 AND LN.id=1 ORDER BY price_date DESC LIMIT 1 </code></pre> <p>It contains a lot of join only because the information in the tables are very normalized.</p> <p>This query returns the information related the last price of a commodity (<strong>AND CD.id = 4</strong>) in a specific market (**WHERE MD.id = 4).</p> <p>So I am first retrieving the list of all prices of a specific commodity in a specific market (that can be a lot of records) and then I do:</p> <pre><code>ORDER BY price_date DESC LIMIT 1 </code></pre> <p>I think that maybe this way can be computationally expensive because the first part of the query (the entire query except the last <strong>ORDER BY</strong> statment will retrieve a lot of records that then have to be ordered.</p> <p>Is it a problem? Eventually what could be a smart strategy to optimize this query? (I have no idea...)</p>
0debug
i dont use maven, spring or hibernate, just simple web dynamic app...please help me : Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. i am update mysql server and workbench and now i lost connection in all applications in my workspace, sql server is 8.0.15; I put it connector8.0.15.jar in all applications but it does not work
0debug
SQL query to count but producing an error : I am writing a query to find the number of ED visits that were discharged from non-ED units. The column dep.ADT_UNIT_TYPE_C column stores 1 if the unit was an ED unit. NULL values are non-ED units in this query. Is this correct to produce this number? COUNT ( CASE WHEN dep.ADT_UNIT_TYPE_C is NULL or dep.ADT_UNIT_TYPE_C <> 1 ELSE NULL END )
0debug
drawerlayout's height does't work : I want make a map APP and I used Drawerlayout,my main layout is a Relativelayout and left drawer is a Linerlayout, my layout is as bellow. <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/main_drawer" android:layout_width="match_parent" android:layout_height="match_parent"> <RelativeLayout android:id="@+id/fragment_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <com.esri.arcgisruntime.mapping.view.MapView android:id="@+id/main_map" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentStart="true" android:layout_alignParentTop="true"></com.esri.arcgisruntime.mapping.view.MapView> <!--SearchBar部分--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="500dp" android:layout_height="50dp" android:layout_marginTop="20dp" android:focusable="true" android:focusableInTouchMode="true" android:layout_marginLeft="20dp"> <ImageButton android:id="@+id/searchbar_more_button" android:layout_width="50dp" android:layout_height="match_parent" android:src="@drawable/main_searchbar_more" android:background="@color/mainColor" android:scaleType="centerInside"/> <EditText android:id="@+id/searchbar_searchtext_textview" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@color/whiteColor" android:gravity="center" android:hint="请输入要查询的信息" android:textAlignment="viewStart" android:textSize="20dp" /> <ImageButton android:paddingTop="5dp" android:paddingBottom="5dp" android:id="@+id/searchbar_search_button" android:layout_width="50dp" android:layout_height="match_parent" android:background="@color/mainColor" android:src="@drawable/main_searchbar_search" android:scaleType="centerInside"/> </LinearLayout> <LinearLayout android:layout_width="40dp" android:layout_height="wrap_content" android:orientation="vertical" android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:layout_marginTop="70dp" android:layout_marginRight="20dp"> <ImageButton android:id="@+id/main_global_button" android:layout_width="40dp" android:layout_height="40dp" android:scaleType="centerInside" android:background="@color/mainColor" android:src="@drawable/main_global_button" /> <ImageButton android:id="@+id/main_layerswitch_button" android:layout_width="40dp" android:layout_height="40dp" android:layout_marginTop="20dp" android:scaleType="centerInside" android:background="@color/mainColor" android:src="@drawable/main_layerswitch_button" /> <ImageButton android:id="@+id/main_electricity_button" android:layout_width="40dp" android:layout_height="40dp" android:layout_marginTop="20dp" android:scaleType="centerInside" android:background="@color/mainColor" android:src="@drawable/main_electricity_button" /> <ImageButton android:id="@+id/main_measure_button" android:layout_width="40dp" android:layout_height="40dp" android:layout_marginTop="20dp" android:background="@color/mainColor" android:scaleType="centerInside" android:src="@drawable/main_measure_button" /> <ImageButton android:id="@+id/main_location_button" android:layout_width="40dp" android:layout_height="40dp" android:layout_marginTop="20dp" android:background="@color/mainColor" android:scaleType="centerInside" android:src="@drawable/main_location_button" /> </LinearLayout> </RelativeLayout> <!--左边抽屉菜单--> <LinearLayout android:id="@+id/menu_layout_left" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="left" android:orientation="vertical"> <include layout="@layout/left_drawer"></include> </LinearLayout> </android.support.v4.widget.DrawerLayout> But I find the drawer's height is depended on searchbar and image button's height,when I run the code on my tablet,the result is like this: [enter image description here][1] [1]: https://i.stack.imgur.com/Y8dFn.jpg You can see that the drawer's height is wrong. Is there anyone know the reason? Thanks very much.
0debug
How to filter Github PRs that are merged and closed but the branch hasn't been deleted : <p>After submitting a PR in Github, it gets approved and then it's merged into master. At this point I should delete my branch to keep things tidy. I'm no angel and often forget to do this!</p> <p>Github has a handy Pull requests page to keep track of all your open/closed PRs. What I would like to know is, can a filter my PRs by the following:</p> <p><code>is:pr author:myusername is:closed is:merged</code> then something like <code>is:branchAliveYouFool</code></p> <p>This would show me all PRs that I've created, that are closed, that have been merged and, crucially, that haven't had the branch deleted.</p> <p>I've searched through the terms that can be used but can't find what I'm looking for: <a href="https://help.github.com/articles/searching-issues-and-pull-requests/" rel="noreferrer">https://help.github.com/articles/searching-issues-and-pull-requests/</a></p> <p>Any thoughts would be appreciated. Thanks :)</p>
0debug
Python sum unique keys in dictionary : I have a bunch of data that I put into a dictionary dict = {'a' : '87', 'b': '72', 'a' : '39', 'b' : '84'} how can I quickly sum up all of the values that have the same keys? output: a = 126 b = 156
0debug
Serial console enabled Performance is impacted. To disable, check bootloader : <p>I recently created an Android emulator with Android version R. It showing an Android system notification </p> <p><strong>"Serial console enabled Performance is impacted. To disable, check bootloader"</strong></p> <p>Can someone explain, what this notification means?</p> <p><a href="https://i.stack.imgur.com/or1pC.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/or1pC.jpg" alt="enter image description here"></a>,</p>
0debug
static int sad_hpel_motion_search(MpegEncContext * s, int *mx_ptr, int *my_ptr, int dmin, int src_index, int ref_index, int size, int h) { MotionEstContext * const c= &s->me; const int penalty_factor= c->sub_penalty_factor; int mx, my, dminh; uint8_t *pix, *ptr; int stride= c->stride; LOAD_COMMON av_assert2(c->sub_flags == 0); if(c->skip){ *mx_ptr = 0; *my_ptr = 0; return dmin; } pix = c->src[src_index][0]; mx = *mx_ptr; my = *my_ptr; ptr = c->ref[ref_index][0] + (my * stride) + mx; dminh = dmin; if (mx > xmin && mx < xmax && my > ymin && my < ymax) { int dx=0, dy=0; int d, pen_x, pen_y; const int index= (my<<ME_MAP_SHIFT) + mx; const int t= score_map[(index-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)]; const int l= score_map[(index- 1 )&(ME_MAP_SIZE-1)]; const int r= score_map[(index+ 1 )&(ME_MAP_SIZE-1)]; const int b= score_map[(index+(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)]; mx<<=1; my<<=1; pen_x= pred_x + mx; pen_y= pred_y + my; ptr-= stride; if(t<=b){ CHECK_SAD_HALF_MV(y2 , 0, -1) if(l<=r){ CHECK_SAD_HALF_MV(xy2, -1, -1) if(t+r<=b+l){ CHECK_SAD_HALF_MV(xy2, +1, -1) ptr+= stride; }else{ ptr+= stride; CHECK_SAD_HALF_MV(xy2, -1, +1) } CHECK_SAD_HALF_MV(x2 , -1, 0) }else{ CHECK_SAD_HALF_MV(xy2, +1, -1) if(t+l<=b+r){ CHECK_SAD_HALF_MV(xy2, -1, -1) ptr+= stride; }else{ ptr+= stride; CHECK_SAD_HALF_MV(xy2, +1, +1) } CHECK_SAD_HALF_MV(x2 , +1, 0) } }else{ if(l<=r){ if(t+l<=b+r){ CHECK_SAD_HALF_MV(xy2, -1, -1) ptr+= stride; }else{ ptr+= stride; CHECK_SAD_HALF_MV(xy2, +1, +1) } CHECK_SAD_HALF_MV(x2 , -1, 0) CHECK_SAD_HALF_MV(xy2, -1, +1) }else{ if(t+r<=b+l){ CHECK_SAD_HALF_MV(xy2, +1, -1) ptr+= stride; }else{ ptr+= stride; CHECK_SAD_HALF_MV(xy2, -1, +1) } CHECK_SAD_HALF_MV(x2 , +1, 0) CHECK_SAD_HALF_MV(xy2, +1, +1) } CHECK_SAD_HALF_MV(y2 , 0, +1) } mx+=dx; my+=dy; }else{ mx<<=1; my<<=1; } *mx_ptr = mx; *my_ptr = my; return dminh; }
1threat
How to Authenticate each REST request with spring boot : <p>I am Building Spring Rest Application and need to Authenticate each request with header. please provide help.</p>
0debug
How to solve Echo in Android webRTC audio when connected to multiple audio channels : <p>I have been using libjingle to make peer connection between four users to share data and also start audio channel. It works ok most of the times but have issues of echo from one user which makes the call very unstable and hard to listen to users.</p> <p>I have tried adding</p> <pre><code>this.mediaConstraints.optional.add(new MediaConstraints.KeyValuePair("googNoiseSuppression", "true")); this.mediaConstraints.optional.add(new MediaConstraints.KeyValuePair("googEchoCancellation", "true")); </code></pre> <p>I am adding these constraints in the optional parameters in case I add these in mandatory it disconnects the call and throws onRenegotiationNeeded method.</p> <p>I have listed some cases such as :</p> <p>1) This might be the cause of 1 user is in loudspeaker(or earphone is loud enough) that voice registers in mic and creates the echo. (But sometimes it happens without this reason as well)</p> <p>2) There may be 1 audio channel registered twice and creating a reverb effect with same user sending data channel twice. (Cant find how to debug this, I count the audio channel and they are normal)</p> <p>3) Two users are in the same room and echo happens (This is a normal case which happens but it's not a concern as its unavoidable)</p> <p>I am looking for suggestions or solutions in case someone else got into such issue with Android webRTC library.</p> <pre><code>implementation 'io.pristine:libjingle:9694@aar' </code></pre> <p>The library I am suing is this, but I also found out that latest webRTC official library is updated recently, would migrating to that solve any such issue ?</p> <p>The latest library which I found is:</p> <pre><code>implementation 'org.webrtc:google-webrtc:1.0.22672' </code></pre> <p>Any help would be highly appreciated.</p> <p>Thanks</p>
0debug
static inline void mix_3f_2r_to_mono(AC3DecodeContext *ctx) { int i; float (*output)[256] = ctx->audio_block.block_output; for (i = 0; i < 256; i++) output[1][i] += (output[2][i] + output[3][i] + output[4][i] + output[5][i]); memset(output[2], 0, sizeof(output[2])); memset(output[3], 0, sizeof(output[3])); memset(output[4], 0, sizeof(output[4])); memset(output[5], 0, sizeof(output[5])); }
1threat
static int ipvideo_decode_block_opcode_0x7(IpvideoContext *s, AVFrame *frame) { int x, y; unsigned char P[2]; unsigned int flags; P[0] = bytestream2_get_byte(&s->stream_ptr); P[1] = bytestream2_get_byte(&s->stream_ptr); if (P[0] <= P[1]) { for (y = 0; y < 8; y++) { flags = bytestream2_get_byte(&s->stream_ptr) | 0x100; for (; flags != 1; flags >>= 1) *s->pixel_ptr++ = P[flags & 1]; s->pixel_ptr += s->line_inc; } else { flags = bytestream2_get_le16(&s->stream_ptr); for (y = 0; y < 8; y += 2) { for (x = 0; x < 8; x += 2, flags >>= 1) { s->pixel_ptr[x ] = s->pixel_ptr[x + 1 ] = s->pixel_ptr[x + s->stride] = s->pixel_ptr[x + 1 + s->stride] = P[flags & 1]; s->pixel_ptr += s->stride * 2; return 0;
1threat
NPM - How do I override one of my dependencies dependency? : <p>Recently, npm released the <a href="https://docs.npmjs.com/getting-started/running-a-security-audit" rel="noreferrer">npm audit</a> command. It runs automatically when you <code>npm i</code> letting you know of any vulnerabilities. I have a simple dependency tree, something like this:</p> <pre><code>package A package B package B dependency package C </code></pre> <p>My <code>package.json</code> includes A, B, and C in the <code>dependencies</code> field. B is requiring its own dependency, which npm warns has vulnerabilities. My question is, how can I override the <code>package B dependency</code> version so as to use the latest version? I've read around that this is either the job for <code>shrinkwrap.json</code> or manually editing <code>package-lock.json</code> but I can't find any concrete examples showing how to do it.</p> <p>I <em>did</em> see that Yarn supports a <code>resolutions</code> field in <code>package.json</code>, but I'm not using Yarn. Is there a way to accomplish this with npm out of the box?</p>
0debug
How to extract the source code from a *.jar file on a Mac? : <p>I'm very confused. I downloaded a *.jar file as a bit of software. So, I would like to extract the source code to look at it</p> <p>I used the command <code>jar xf filename.jar</code></p> <p>which returned two more <code>*.jar</code> files and a <code>*.class</code> file. I still cannot open these in the terminal with standard text editors. </p> <p>Perhaps this is not open source software? Is there an alternative to see what has been done here?</p>
0debug
regular expression (python) exclude no comma case : I have created this RE: ^[ ]{0,1}[^\s] to match: "1 min" 1 min, 2 min, 3 min but I don't know how to exclude this particular case: "1 min 2 min 3 min". Or I would like the strings to be only comma separated?
0debug
Multiple Lat/Long Coordinates to Miles : <p>I have a few x,y coordinates that I wanted to get the area of. I figured the best course of action is to convert the X,Y decimal coordinates into nautical miles and then do the area of a polygon. I've googled around, but really haven't found anything helpful for my problem. Not looking for the answer, but I just wanted to know how to approach this and what to potentially use for the conversion. </p> <p>These are the coordinates that are in an array:</p> <pre><code> Lat_Long = [60.8427194, -042.7969500; ... 60.8646972, -042.5323889; ... 60.7640417, -042.5178639; ... 60.5882139, -042.8185056; ... 60.8080111, -042.8507500; ... 60.8069889, -042.8374167; ... 60.8083028, -042.8278361; ... 60.8114056, -042.8186167; ... 60.8152306, -042.8117389; ... 60.8203694, -042.8055667; ... 60.8256528, -042.8013611; ... 60.8315167, -042.7985083; ... 60.8374056, -042.797078; ... 60.8427194, -042.7969500]; </code></pre>
0debug
undefined method respond_to in Rails 5 controller : <p>I'm upgrading an app from rails 3.something to rails 5. For some reason, I'm am getting undefindied method respond_to anytime I use that method in any of my controllers. This was working before and I was hoping someone here could help.</p> <pre><code>class StatusController &lt; ApplicationController #this throws an error 'undefined method respond_to respond_to :json, :html end </code></pre>
0debug
static void vc1_decode_skip_blocks(VC1Context *v) { MpegEncContext *s = &v->s; if (!v->s.last_picture.f.data[0]) return; ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, ER_MB_END); s->first_slice_line = 1; for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) { s->mb_x = 0; init_block_index(v); ff_update_block_index(s); memcpy(s->dest[0], s->last_picture.f.data[0] + s->mb_y * 16 * s->linesize, s->linesize * 16); memcpy(s->dest[1], s->last_picture.f.data[1] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8); memcpy(s->dest[2], s->last_picture.f.data[2] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8); ff_mpeg_draw_horiz_band(s, s->mb_y * 16, 16); s->first_slice_line = 0; } s->pict_type = AV_PICTURE_TYPE_P; }
1threat
int AC3_NAME(encode_frame)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { AC3EncodeContext *s = avctx->priv_data; int ret; if (s->options.allow_per_frame_metadata) { ret = ff_ac3_validate_metadata(s); if (ret) return ret; } if (s->bit_alloc.sr_code == 1 || s->eac3) ff_ac3_adjust_frame_size(s); copy_input_samples(s, (SampleType **)frame->extended_data); apply_mdct(s); if (s->fixed_point) scale_coefficients(s); clip_coefficients(&s->dsp, s->blocks[0].mdct_coef[1], AC3_MAX_COEFS * s->num_blocks * s->channels); s->cpl_on = s->cpl_enabled; ff_ac3_compute_coupling_strategy(s); if (s->cpl_on) apply_channel_coupling(s); compute_rematrixing_strategy(s); if (!s->fixed_point) scale_coefficients(s); ff_ac3_apply_rematrixing(s); ff_ac3_process_exponents(s); ret = ff_ac3_compute_bit_allocation(s); if (ret) { av_log(avctx, AV_LOG_ERROR, "Bit allocation failed. Try increasing the bitrate.\n"); return ret; } ff_ac3_group_exponents(s); ff_ac3_quantize_mantissas(s); if ((ret = ff_alloc_packet2(avctx, avpkt, s->frame_size))) return ret; ff_ac3_output_frame(s, avpkt->data); if (frame->pts != AV_NOPTS_VALUE) avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->delay); *got_packet_ptr = 1; return 0; }
1threat
If conditional statement Error: unexpected '}' in " }" in R programming : rankhospital <- function(state, outcome, num = "best"){ ## Read outcome data data <- read.csv("outcome-of-care-measures.csv", colClasses = "character") hospital <- data.frame(data[,2], #name data[,7], #state data[,11], #heart attack data[,17], # heart failure data[,23], stringsAsFactors = FALSE) #pneumonia colnames(hospital) <- c("name", "state", "heart attack", "heart failure", "pneumonia") ## Check that state and outcome are valid if (!state %in% hospital[, "state"]) { stop('invalid state')} else if (!outcome %in% c("heart attack", "heart failure", "pneumonia")){ stop('invalid outcome')} else if (is.character(num)){ if (num == "best") { chosen_state <- hospital[which(hospital[, "state"] == state), ] #select the state chosen_outcome <- chosen_state[ , outcome] #select the outcome from the state best_outcome <- chosen_state[which(chosen_outcome == min(chosen_outcome, na.rm = TRUE)),]["name"] best_hospital <- best_outcome[order(best_outcome)][ , "name"] #sort best_hospital } else (num == "worst") { chosen_state <- hospital[which(hospital[, "state"] == state), ] #select the state chosen_outcome <- chosen_state[ , outcome] #select the outcome from the state best_outcome <- chosen_state[which(chosen_outcome == max(chosen_outcome, na.rm = TRUE)),]["name"] best_hospital <- best_outcome[order(best_outcome)][ , "name"] #sort best_hospital } else (is.numeric(num)) { if (num =< length(hospital$name){ chosen_state <- hospital[which(hospital[, "state"] == state), ] #select the state chosen_outcome <- as.numeric(chosen_state[ , outcome]) #select the outcome from the state chosen_state[which(sort(chosen_outcome)) == num, ][,"name"] } else (num > length(hospital$name) { stop('NA')} } } When i run the code, it throws " Error: unexpected '}' in "}" " where else (num == "worst") part, so if i change this if from else, it'll go down and throws me an error again at else (is.numeric(num)). What have i done it wrong with this code? I thought If statement goes like this -------------------- If else if else if else -------------------- If else if if else else if if else else if else ----------------- Thanks in advance!
0debug