problem
stringlengths
26
131k
labels
class label
2 classes
void qemu_aio_wait(void) { int ret; if (qemu_bh_poll()) return; do { AioHandler *node; fd_set rdfds, wrfds; int max_fd = -1; walking_handlers = 1; FD_ZERO(&rdfds); FD_ZERO(&wrfds); LIST_FOREACH(node, &aio_handlers, node) { if (node->io_flush && node->io_flush(node->opaque) == 0) continue; if (!node->deleted && node->io_read) { FD_SET(node->fd, &rdfds); max_fd = MAX(max_fd, node->fd + 1); } if (!node->deleted && node->io_write) { FD_SET(node->fd, &wrfds); max_fd = MAX(max_fd, node->fd + 1); } } walking_handlers = 0; if (max_fd == -1) break; ret = select(max_fd, &rdfds, &wrfds, NULL, NULL); if (ret == -1 && errno == EINTR) continue; if (ret > 0) { walking_handlers = 1; node = LIST_FIRST(&aio_handlers); while (node) { AioHandler *tmp; if (!node->deleted && FD_ISSET(node->fd, &rdfds) && node->io_read) { node->io_read(node->opaque); } if (!node->deleted && FD_ISSET(node->fd, &wrfds) && node->io_write) { node->io_write(node->opaque); } tmp = node; node = LIST_NEXT(node, node); if (tmp->deleted) { LIST_REMOVE(tmp, node); qemu_free(tmp); } } walking_handlers = 0; } } while (ret == 0); }
1threat
static inline void t_gen_raise_exception(uint32_t index) { tcg_gen_helper_0_1(helper_raise_exception, tcg_const_tl(index)); }
1threat
Sum the occurance of the string in the json array and store it in separate json array : I have a JSON array as follows: var teamDetails=[ { "pType" : "Search Engines", "value" : 5}, { "pType" : "Content Server", "value" : 1}, { "pType" : "Content Server", "value" : 1}, { "pType" : "Search Engines", "value" : 1}, { "pType" : "Business", "value" : 1,}, { "pType" : "Content Server", "value" : 1}, { "pType" : "Internet Services", "value" : 1}, { "pType" : "Search Engines", "value" : 6}, { "pType" : "Search Engines", "value" : 1} ]; *I want to take the count of the ptype dynamically and individually and should be applied if there is a change in ptype.* **`Expected output:`** var output = [{"label":"Search Engines"},{"Occurance":4},{"label":"Content Server"},{"Occurance":3},{"label":"Business"},{"Occurance":1},{"label":"Internet Services"},{"Occurance":1}];
0debug
Can't open activities caused by: java.lang.NullPointerException : <p>I am developing app for kids drawing alphabet according to alphabet stroke. I cannot run DrawingActivity cause by java.lang.NullPointerException.I not really strong in coding. I feel that null error come from <code>getIntent().getExtras().getString("type");</code>.So,i change the code to <code>getIntent().getStringExtra("type");</code>,but still can't run DrawingActivity. Please help me guys. Really appreciate it.</p> <p>This is my error logcat:</p> <pre><code>12-05 23:47:29.498 9620-9620/com.example.user.mygame E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.user.mygame, PID: 9620 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.user.mygame/com.example.user.mygame.DrawingActivity}: java.lang.NullPointerException at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2247) at android.app.ActivityThread.access$800(ActivityThread.java:141) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5111) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:806) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.example.user.mygame.DrawingActivity.onCreate(DrawingActivity.java:156) at android.app.Activity.performCreate(Activity.java:5248) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2247)  at android.app.ActivityThread.access$800(ActivityThread.java:141)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:136)  at android.app.ActivityThread.main(ActivityThread.java:5111)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:806)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)  at dalvik.system.NativeStart.main(Native Method)  </code></pre> <p>This is my DrawingActivity.java:</p> <pre><code>package com.example.user.mygame; import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Paint.Cap; import android.graphics.Paint.Join; import android.graphics.Paint.Style; import android.graphics.Path; import android.graphics.Path.Direction; import android.graphics.Rect; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnTouchListener; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.RelativeLayout.LayoutParams; import com.google.android.gms.location.DetectedActivity; import com.google.android.gms.maps.model.BitmapDescriptorFactory; public class DrawingActivity extends Activity implements OnClickListener, OnTouchListener { View drawingView; DrawingView dv; LayoutParams params; ViewGroup parent; ImageView nextBtn; ImageView playBtn; ImageView prevBtn; private Paint mPaint; private Integer position; private int totalItem; private String type; public class DrawingView extends View { private static final float TOUCH_TOLERANCE = 4.0f; private Bitmap bm; private Paint circlePaint; private Path circlePath; Context context; private Bitmap mBitmap; private Paint mBitmapPaint; private Canvas mCanvas; private Path mPath; private float mX; private float mY; public DrawingView(Context c) { super(c); this.context = c; this.mPath = new Path(); this.mBitmapPaint = new Paint(4); this.circlePaint = new Paint(); this.circlePath = new Path(); this.circlePaint.setAntiAlias(true); this.circlePaint.setColor(Color.BLACK); this.circlePaint.setStyle(Style.STROKE); this.circlePaint.setStrokeJoin(Join.MITER); this.circlePaint.setStrokeWidth(TOUCH_TOLERANCE); } protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); this.mBitmap = Bitmap.createBitmap(w, h, Config.ARGB_8888); this.mCanvas = new Canvas(this.mBitmap); if (DrawingActivity.this.type.equals(Resource.DRAWING_ALPHABET)) { this.bm = BitmapFactory.decodeResource(getResources(), Resource.capitalStoke[DrawingActivity.this.position]); } this.mCanvas.drawBitmap(this.bm, new Rect(0, 0, this.bm.getWidth(), this.bm.getHeight()), new Rect(0, 0, this.mCanvas.getWidth(), this.mCanvas.getHeight()), this.mBitmapPaint); } protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawBitmap(this.mBitmap, 0.0f, 0.0f, this.mBitmapPaint); canvas.drawPath(this.mPath, DrawingActivity.this.mPaint); canvas.drawPath(this.circlePath, this.circlePaint); } private void touch_start(float x, float y) { this.mPath.reset(); this.mPath.moveTo(x, y); this.mX = x; this.mY = y; } private void touch_move(float x, float y) { float dx = Math.abs(x - this.mX); float dy = Math.abs(y - this.mY); if (dx &gt;= TOUCH_TOLERANCE || dy &gt;= TOUCH_TOLERANCE) { this.mPath.quadTo(this.mX, this.mY, (this.mX + x) / 2.0f, (this.mY + y) / 2.0f); this.mX = x; this.mY = y; this.circlePath.reset(); this.circlePath.addCircle(this.mX, this.mY, BitmapDescriptorFactory.HUE_ORANGE, Direction.CW); } } private void touch_up() { this.mPath.lineTo(this.mX, this.mY); this.circlePath.reset(); this.mCanvas.drawPath(this.mPath, DrawingActivity.this.mPaint); this.mPath.reset(); } public boolean onTouchEvent(MotionEvent event) { float x = event.getX(); float y = event.getY(); switch (event.getAction()) { case DetectedActivity.IN_VEHICLE /*0*/: touch_start(x, y); invalidate(); break; case DetectedActivity.ON_BICYCLE /*1*/: touch_up(); invalidate(); break; case DetectedActivity.ON_FOOT /*2*/: touch_move(x, y); invalidate(); break; } return true; } public void resetCanvas() { this.bm = null; this.mBitmap = null; System.gc(); } } public DrawingActivity() { this.type = ""; this.position = 0; this.totalItem = 0; this.nextBtn = null; this.playBtn = null; this.prevBtn = null; this.drawingView = null; this.parent = null; this.params = null; } protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(1); setContentView(R.layout.drawing_alphabet); this.type = getIntent().getExtras().getString("type"); this.nextBtn = (ImageView) findViewById(R.id.nextId); this.playBtn = (ImageView) findViewById(R.id.playId); this.prevBtn = (ImageView) findViewById(R.id.prevId); this.nextBtn.setOnClickListener(this); this.nextBtn.setOnTouchListener(this); this.prevBtn.setOnClickListener(this); this.prevBtn.setOnTouchListener(this); this.playBtn.setOnClickListener(this); this.playBtn.setOnTouchListener(this); this.drawingView = findViewById(R.id.drawingViewId); this.params = (LayoutParams) this.drawingView.getLayoutParams(); this.dv = new DrawingView(this); this.dv.setLayoutParams(this.params); this.parent = (ViewGroup) this.drawingView.getParent(); int index = this.parent.indexOfChild(this.drawingView); this.parent.removeView(this.drawingView); this.parent.addView(this.dv, index); if (this.type.equals(Resource.DRAWING_ALPHABET)) { this.totalItem = Resource.capitalStoke.length; } this.mPaint = new Paint(); this.mPaint.setAntiAlias(true); this.mPaint.setDither(true); this.mPaint.setColor(Color.BLACK); this.mPaint.setStyle(Style.STROKE); this.mPaint.setStrokeJoin(Join.ROUND); this.mPaint.setStrokeCap(Cap.ROUND); this.mPaint.setStrokeWidth(16.0f); updatePreviousButton(); } public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case DetectedActivity.IN_VEHICLE /*0*/: if (v.getId() == R.id.nextId || v.getId() == R.id.playId || v.getId() == R.id.prevId) { v.setAlpha(0.5f); break; } case DetectedActivity.ON_BICYCLE /*1*/: if (v.getId() == R.id.nextId || v.getId() == R.id.playId || v.getId() == R.id.prevId) { v.setAlpha(1.0f); break; } } return false; } public void onClick(View v) { switch (v.getId()) { case R.id.nextId: this.position = this.position + 1; changeStroke(); case R.id.playId: changeStroke(); case R.id.prevId: this.position = this.position - 1; changeStroke(); default: } } private void changeStroke() { updateNextButton(); updatePreviousButton(); int index = this.parent.indexOfChild(this.dv); this.dv.resetCanvas(); this.dv = null; this.parent.removeViewAt(index); this.dv = new DrawingView(this); this.dv.setLayoutParams(this.params); this.parent.addView(this.dv, index); } private void updateNextButton() { if (this.position == this.totalItem - 1) { this.nextBtn.setAlpha(0.5f); this.nextBtn.setClickable(false); return; } this.nextBtn.setAlpha(1.0f); this.nextBtn.setClickable(true); } private void updatePreviousButton() { if (this.position == 0) { this.prevBtn.setAlpha(0.5f); this.prevBtn.setClickable(false); return; } this.prevBtn.setAlpha(1.0f); this.prevBtn.setClickable(true); } } </code></pre> <p>This is my drawing_alphabet.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bg_drawing"&gt; &lt;View android:id="@+id/drawingViewId" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="0dp" android:layout_marginRight="64dp" android:layout_marginEnd="64dp"/&gt; &lt;ImageView android:id="@+id/prevId" android:layout_width="52dp" android:layout_height="52dp" android:src="@drawable/back_icon" android:layout_gravity="top" android:layout_marginTop="49dp" android:layout_alignParentTop="true" android:layout_alignLeft="@+id/nextId" android:layout_alignStart="@+id/nextId" /&gt; &lt;ImageView android:id="@+id/nextId" android:layout_width="52dp" android:layout_height="52dp" android:src="@drawable/next_icon" android:layout_gravity="bottom" android:layout_marginTop="61dp" android:layout_below="@+id/prevId" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" /&gt; / &lt;/RelativeLayout&gt; </code></pre> <p>This is my manifest.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.user.mygame"&gt; &lt;application android:allowBackup="false" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme" android:name="android.support.multidex.MultiDexApplication"&gt; &lt;activity android:name=".MainActivity" android:screenOrientation="landscape"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:label="@string/app_name" android:name="com.example.user.mygame.AlphabetActivity" android:screenOrientation="landscape" /&gt; &lt;activity android:label="@string/app_name" android:name="com.example.user.mygame.DrawingActivity" android:screenOrientation="landscape" /&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>This is my resource.java:</p> <pre><code>package com.example.user.mygame; public class Resource { public static String DRAWING_ALPHABET; public static Integer[] capitalStoke; Integer[] alphabetCapital; Integer[] alphabetSound; Integer[] alphabetImage; static { DRAWING_ALPHABET = "alphabet"; setCapitalStoke(new Integer[]{Integer.valueOf(R.drawable.capital_letters_stroke_01), Integer.valueOf(R.drawable.capital_letters_stroke_02), Integer.valueOf(R.drawable.capital_letters_stroke_03), Integer.valueOf(R.drawable.capital_letters_stroke_04), Integer.valueOf(R.drawable.capital_letters_stroke_05), Integer.valueOf(R.drawable.capital_letters_stroke_06), Integer.valueOf(R.drawable.capital_letters_stroke_07), Integer.valueOf(R.drawable.capital_letters_stroke_08), Integer.valueOf(R.drawable.capital_letters_stroke_09), Integer.valueOf(R.drawable.capital_letters_stroke_10), Integer.valueOf(R.drawable.capital_letters_stroke_11), Integer.valueOf(R.drawable.capital_letters_stroke_12), Integer.valueOf(R.drawable.capital_letters_stroke_13), Integer.valueOf(R.drawable.capital_letters_stroke_14), Integer.valueOf(R.drawable.capital_letters_stroke_15), Integer.valueOf(R.drawable.capital_letters_stroke_16), Integer.valueOf(R.drawable.capital_letters_stroke_17), Integer.valueOf(R.drawable.capital_letters_stroke_18), Integer.valueOf(R.drawable.capital_letters_stroke_19), Integer.valueOf(R.drawable.capital_letters_stroke_20), Integer.valueOf(R.drawable.capital_letters_stroke_21), Integer.valueOf(R.drawable.capital_letters_stroke_22), Integer.valueOf(R.drawable.capital_letters_stroke_23), Integer.valueOf(R.drawable.capital_letters_stroke_24), Integer.valueOf(R.drawable.capital_letters_stroke_25), Integer.valueOf(R.drawable.capital_letters_stroke_26)}); } public static Integer[] getCapitalStoke() { return capitalStoke; } public static void setCapitalStoke(Integer[] capitalStoke) { Resource.capitalStoke = capitalStoke; } public Resource() { this.alphabetCapital = new Integer[]{ Integer.valueOf(R.drawable.img_letter_001), Integer.valueOf(R.drawable.img_letter_002), Integer.valueOf(R.drawable.img_letter_003), Integer.valueOf(R.drawable.img_letter_004), Integer.valueOf(R.drawable.img_letter_005), Integer.valueOf(R.drawable.img_letter_006), Integer.valueOf(R.drawable.img_letter_007), Integer.valueOf(R.drawable.img_letter_008), Integer.valueOf(R.drawable.img_letter_009), Integer.valueOf(R.drawable.img_letter_010), Integer.valueOf(R.drawable.img_letter_011), Integer.valueOf(R.drawable.img_letter_012), Integer.valueOf(R.drawable.img_letter_013), Integer.valueOf(R.drawable.img_letter_014), Integer.valueOf(R.drawable.img_letter_015), Integer.valueOf(R.drawable.img_letter_016), Integer.valueOf(R.drawable.img_letter_017), Integer.valueOf(R.drawable.img_letter_018), Integer.valueOf(R.drawable.img_letter_019), Integer.valueOf(R.drawable.img_letter_020), Integer.valueOf(R.drawable.img_letter_021), Integer.valueOf(R.drawable.img_letter_022), Integer.valueOf(R.drawable.img_letter_023), Integer.valueOf(R.drawable.img_letter_024), Integer.valueOf(R.drawable.img_letter_025), Integer.valueOf(R.drawable.img_letter_026)}; this.alphabetSound = new Integer[]{ Integer.valueOf(R.raw.snd_a), Integer.valueOf(R.raw.snd_b), Integer.valueOf(R.raw.snd_c),}; this.alphabetImage = new Integer[]{ Integer.valueOf(R.drawable.image_1), Integer.valueOf(R.drawable.image_2), Integer.valueOf(R.drawable.image_3)}; } } </code></pre>
0debug
SYNTH_FILTER_FUNC(sse2) SYNTH_FILTER_FUNC(avx) av_cold void ff_synth_filter_init_x86(SynthFilterContext *s) { #if HAVE_YASM int cpu_flags = av_get_cpu_flags(); #if ARCH_X86_32 if (EXTERNAL_SSE(cpu_flags)) { s->synth_filter_float = synth_filter_sse; } if (EXTERNAL_SSE2(cpu_flags)) { s->synth_filter_float = synth_filter_sse2; } if (EXTERNAL_AVX(cpu_flags)) { s->synth_filter_float = synth_filter_avx; } }
1threat
C++ Calling constructor inside another class constructor : <p>On this line <code>Transaction t(name, x, Date d(a, b, c));</code> this codes generates an error: <code>expected primary-expression before 'd'|</code> </p> <p>Is it a valid code calling the constructor and passing another constructor call to it??!! </p> <pre><code>#include&lt;iostream&gt; #include&lt;cstring&gt; using namespace std; class Date{ private: int a; int b; int c; public: Date(int a =0, int b=0, int c =0){ this-&gt;a= a; this-&gt;b = b; this-&gt;c = c; } int getA(){ return a; } int getB(){ return b; } int getC(){ return c; } void setA(int a){ this-&gt;a = a; } void setB(int b){ this-&gt;b = b; } void setC(int c){ this-&gt;c = c; } }; class Transaction { private: char name[30]; char x[10]; Date *d; public: Transaction(char const *name = "", char const *x = "", const Date *d = 0) { strcpy(this-&gt;name, name); strcpy(this-&gt;x, x); // this-&gt;d.setA(d.getA()); // this-&gt;d.setB(d.getB()); // this-&gt;d.setC(d.getC()); } Date *getDate() { return d; } }; int main() { int a,b,c; char name[30]; char x[10]; a=1; b=2; c=3; cin&gt;&gt;name; cin&gt;&gt;x; Transaction t(name, x, Date d(a, b, c)); } </code></pre>
0debug
static int proxy_truncate(FsContext *ctx, V9fsPath *fs_path, off_t size) { int retval; retval = v9fs_request(ctx->private, T_TRUNCATE, NULL, "sq", fs_path, size); if (retval < 0) { errno = -retval; return -1; } return 0; }
1threat
int qemu_bh_poll(void) { QEMUBH *bh, **pbh; int ret; ret = 0; for(;;) { pbh = &first_bh; bh = *pbh; if (!bh) break; ret = 1; *pbh = bh->next; bh->scheduled = 0; bh->cb(bh->opaque); } return ret; }
1threat
static void sigp_stop_and_store_status(CPUState *cs, run_on_cpu_data arg) { S390CPU *cpu = S390_CPU(cs); SigpInfo *si = arg.host_ptr; struct kvm_s390_irq irq = { .type = KVM_S390_SIGP_STOP, }; if (s390_cpu_get_state(cpu) == CPU_STATE_OPERATING && cs->halted) { s390_cpu_set_state(CPU_STATE_STOPPED, cpu); } switch (s390_cpu_get_state(cpu)) { case CPU_STATE_OPERATING: cpu->env.sigp_order = SIGP_STOP_STORE_STATUS; kvm_s390_vcpu_interrupt(cpu, &irq); break; case CPU_STATE_STOPPED: cpu_synchronize_state(cs); kvm_s390_store_status(cpu, KVM_S390_STORE_STATUS_DEF_ADDR, true); break; } si->cc = SIGP_CC_ORDER_CODE_ACCEPTED; }
1threat
Line graph with ggplot2 in R Studio : <p>I am trying to learn the R programming language to analyse and visualize my data. I have made some good progress so far and I am really enjoying learning R but I am stomped here.</p> <p>I am having some trouble creating line graphs for products in specific categories. I have no problem creating graphs to show sales all categories but I would like to specify a particular category and show the <strong>product</strong> sales.</p> <p><a href="https://i.stack.imgur.com/dh6OK.png" rel="nofollow noreferrer">This is what my data set looks like.</a> </p> <p>Can someone show me how I could do this? E.g I would like to create a <strong>line</strong> graph to show the sales of Products in the <strong>Bakery</strong> category where the <strong>X</strong> axis would have the product name and the <strong>Y</strong> axis would have the quantity sold.</p> <p>Any help would be greatly appreciated.</p>
0debug
static int encode_slice(AVCodecContext *avctx, const AVFrame *pic, PutBitContext *pb, int sizes[4], int x, int y, int quant, int mbs_per_slice) { ProresContext *ctx = avctx->priv_data; int i, xp, yp; int total_size = 0; const uint16_t *src; int slice_width_factor = av_log2(mbs_per_slice); int num_cblocks, pwidth; int plane_factor, is_chroma; for (i = 0; i < ctx->num_planes; i++) { is_chroma = (i == 1 || i == 2); plane_factor = slice_width_factor + 2; if (is_chroma) plane_factor += ctx->chroma_factor - 3; if (!is_chroma || ctx->chroma_factor == CFACTOR_Y444) { xp = x << 4; yp = y << 4; num_cblocks = 4; pwidth = avctx->width; } else { xp = x << 3; yp = y << 4; num_cblocks = 2; pwidth = avctx->width >> 1; } src = (const uint16_t*)(pic->data[i] + yp * pic->linesize[i]) + xp; get_slice_data(ctx, src, pic->linesize[i], xp, yp, pwidth, avctx->height, ctx->blocks[0], mbs_per_slice, num_cblocks); sizes[i] = encode_slice_plane(ctx, pb, src, pic->linesize[i], mbs_per_slice, ctx->blocks[0], num_cblocks, plane_factor, ctx->quants[quant]); total_size += sizes[i]; } return total_size; }
1threat
How to mock Jodatime DateTime with Mockito : <p>I am currently trying to mock a DateTime object so that I can intercept it and make it create a constant (predetermined) DateTime object everytime a new DateTime object is made in my test.</p> <p>In my actual method, I am creating the DateTime object like this:</p> <p><code>DateTime start = new LocalDateTime().toDateTime().minusHours(1)</code></p> <p><code>DateTime end = new LocalDateTime().toDateTime()</code></p> <p>Right now, I am mocking the LocalDateTime object and DateTime object, but am not sure how to carry on:</p> <pre><code>@Mock DateTime dt; @Mock LocalDateTime ldt; @Test public void test() { when(new DateTime()).thenReturn( ???? ); // Stuck here. when(new LocalDateTime().toDateTime()).thenReturn(dt); } </code></pre> <p>Any help would be appreciated. Thanks!</p>
0debug
static inline void gen_op_addq_ESP_im(int32_t val) { tcg_gen_ld_tl(cpu_tmp0, cpu_env, offsetof(CPUState, regs[R_ESP])); tcg_gen_addi_tl(cpu_tmp0, cpu_tmp0, val); tcg_gen_st_tl(cpu_tmp0, cpu_env, offsetof(CPUState, regs[R_ESP])); }
1threat
java access modifier confussion why it is not visible? : [enter image description here][1] [1]: https://i.stack.imgur.com/fDVEH.jpg I can't understand few lines with //???. can you explain why those lines are not accessible?
0debug
static void print_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp) { StringOutputVisitor *sov = DO_UPCAST(StringOutputVisitor, visitor, v); static const char suffixes[] = { 'B', 'K', 'M', 'G', 'T' }; uint64_t div, val; char *out; int i; if (!sov->human) { out = g_strdup_printf("%llu", (long long) *obj); string_output_set(sov, out); return; } val = *obj; i = 64 - clz64(val); i /= 10; if (i >= ARRAY_SIZE(suffixes)) { i = ARRAY_SIZE(suffixes) - 1; } div = 1ULL << (i * 10); out = g_strdup_printf("%0.03f%c", (double)val/div, suffixes[i]); string_output_set(sov, out); }
1threat
Hey guys, i wrote this program and for some reason it won't compile. : i keep getting " Grades.java:10: error: illegal start of type" i can't figure out why. please help! import java.util.Scanner; public class Grades { final int StudentGrades = 3; int total; double average; int[] GradesArray = new int[StudentGrades]; Scanner keyboard = new Scanner(System.in); for (int i = 0; i < GradesArray.length; i++) { System.out.print("Enter grades for Student" + (i+1)); GradesArray[i] = keyboard.nextInt(); total += GradesArray[i]; } average = total/StudentGrades; if(average >= 90 && average <= 100) System.out.print("you Got a A"); else if(average >= 80 && average <= 89) System.out.print("you Got a B"); else if (average >= 70 && average <= 79) System.out.print("you Got a C"); else if (average >= 60 && average <= 69) System.out.print("you Got a D"); else System.out.print("you Got a F"); for(int i = 0; i < GradesArray.length; i++) { System.out.println("Grades for exam #" + (it1)+"are as follows " + GradesArray[i]); } }
0debug
Must I call parent::__construct() in the first line of the constructor? : <p>I know in Java, <code>super()</code> in a constructor has to be called as the first line of an overridden constructor.</p> <p>Does this also apply to the <code>parent::__construct()</code> call in PHP?</p> <p>I found myself writing an Exception class like this:</p> <pre><code>class MyException extends Exception { public function __construct($some_data) { $message = ''; $message .= format_data($some_data); $message .= ' was passed but was not expected'; parent::__construct($message); } } </code></pre> <p>and I wondered if this would be considered an error/bad practice in PHP.</p>
0debug
Get reference to element in method in Vue.js : <p>How can I get reference to the element that fired the method in Vue.js? I have HTML like this:</p> <pre><code> &lt;input type="text" v-model="dataField" v-bind:class="dataFieldClass" /&gt; </code></pre> <p>And in my Vue.js viewmodel I have a method:</p> <pre><code>dataFieldClass: function () { // Here I need the element and get its ID // Pseudo code var elementId = $element.id; } </code></pre> <p>I know that it's possible to get the element from event (v-on:click), but this is not an event, it's a simple method returning CSS class for the element according to few conditions of the viewmodel. It should be computable as well, but the problem is the same.</p>
0debug
please help my in update vb.net to mysql server : Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim con As New MySqlConnection("host=localhost; username=root; password=; database=wh_db") Dim cmd As New MySqlCommand Dim dr As MySqlDataReader con.Open() cmd.Connection = con cmd.CommandText = " select pass from user where pass ='" & oldpass.Text & "'" dr = cmd.ExecuteReader If dr.HasRows Then cmd.Connection = con cmd.CommandText = " UPDATE user SET pass ='" & newpass.Text & "' where user = '" & user.Text & "'" Else MsgBox("Password is not correct") End If End Sub End Class
0debug
static uint32_t nvram_readl (void *opaque, target_phys_addr_t addr) { M48t59State *NVRAM = opaque; uint32_t retval; retval = m48t59_read(NVRAM, addr) << 24; retval |= m48t59_read(NVRAM, addr + 1) << 16; retval |= m48t59_read(NVRAM, addr + 2) << 8; retval |= m48t59_read(NVRAM, addr + 3); return retval; }
1threat
Select range of data between two string vlaues : <p>I want select the data in between two string values AAA and DDD. There are data out of range of AAA and DDD that I do not want. Any ideas. Thanks.</p> <p><a href="https://i.stack.imgur.com/bOf7U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bOf7U.png" alt="enter image description here"></a></p>
0debug
Facebook Login not working in PWA app if app is in stand alone state : <p>I am building a PWA webiste. I am using Angular JS and I used javascript facebook login in my website. But if I view my app in browser, facebook login is working. But when I add shortcut to homescreen and launch the app from the homescreen, FB login is not working. Facebook page is loading. But after entering credentials it shows blank page. Can anyone help ?</p> <p>Here is my FB login code</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var doBrowserLogin = function(){ var deferred = $q.defer(); FB.login( function(response){ if (response.authResponse) { deferred.resolve(response); }else{ deferred.reject(response); } }, {scope:'email,public_profile'} ); return deferred.promise; }</code></pre> </div> </div> </p> <p>It is opening the facebook login screen and after entering the credentials, it is showing blank. Not coming back to app. <a href="https://i.stack.imgur.com/ZXMhl.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/ZXMhl.jpg" alt="Blank page"></a> In my manifest.json file, the display property is set to standalone. Please help.</p>
0debug
int cpu_exec(CPUState *cpu) { CPUClass *cc = CPU_GET_CLASS(cpu); #ifdef TARGET_I386 X86CPU *x86_cpu = X86_CPU(cpu); CPUArchState *env = &x86_cpu->env; #endif int ret, interrupt_request; TranslationBlock *tb; uint8_t *tc_ptr; uintptr_t next_tb; SyncClocks sc; if (cpu->halted) { #if defined(TARGET_I386) && !defined(CONFIG_USER_ONLY) if (cpu->interrupt_request & CPU_INTERRUPT_POLL) { apic_poll_irq(x86_cpu->apic_state); cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL); } #endif if (!cpu_has_work(cpu)) { return EXCP_HALTED; } cpu->halted = 0; } current_cpu = cpu; atomic_mb_set(&tcg_current_cpu, cpu); rcu_read_lock(); if (unlikely(atomic_mb_read(&exit_request))) { cpu->exit_request = 1; } cc->cpu_exec_enter(cpu); init_delay_params(&sc, cpu); for(;;) { if (sigsetjmp(cpu->jmp_env, 0) == 0) { if (cpu->exception_index >= 0) { if (cpu->exception_index >= EXCP_INTERRUPT) { ret = cpu->exception_index; if (ret == EXCP_DEBUG) { cpu_handle_debug_exception(cpu); } cpu->exception_index = -1; break; } else { #if defined(CONFIG_USER_ONLY) #if defined(TARGET_I386) cc->do_interrupt(cpu); #endif ret = cpu->exception_index; cpu->exception_index = -1; break; #else cc->do_interrupt(cpu); cpu->exception_index = -1; #endif } } next_tb = 0; for(;;) { interrupt_request = cpu->interrupt_request; if (unlikely(interrupt_request)) { if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) { interrupt_request &= ~CPU_INTERRUPT_SSTEP_MASK; } if (interrupt_request & CPU_INTERRUPT_DEBUG) { cpu->interrupt_request &= ~CPU_INTERRUPT_DEBUG; cpu->exception_index = EXCP_DEBUG; cpu_loop_exit(cpu); } if (interrupt_request & CPU_INTERRUPT_HALT) { cpu->interrupt_request &= ~CPU_INTERRUPT_HALT; cpu->halted = 1; cpu->exception_index = EXCP_HLT; cpu_loop_exit(cpu); } #if defined(TARGET_I386) if (interrupt_request & CPU_INTERRUPT_INIT) { cpu_svm_check_intercept_param(env, SVM_EXIT_INIT, 0); do_cpu_init(x86_cpu); cpu->exception_index = EXCP_HALTED; cpu_loop_exit(cpu); } #else if (interrupt_request & CPU_INTERRUPT_RESET) { cpu_reset(cpu); } #endif if (cc->cpu_exec_interrupt(cpu, interrupt_request)) { next_tb = 0; } if (cpu->interrupt_request & CPU_INTERRUPT_EXITTB) { cpu->interrupt_request &= ~CPU_INTERRUPT_EXITTB; next_tb = 0; } } if (unlikely(cpu->exit_request)) { cpu->exit_request = 0; cpu->exception_index = EXCP_INTERRUPT; cpu_loop_exit(cpu); } tb_lock(); tb = tb_find_fast(cpu); if (tcg_ctx.tb_ctx.tb_invalidated_flag) { next_tb = 0; tcg_ctx.tb_ctx.tb_invalidated_flag = 0; } if (qemu_loglevel_mask(CPU_LOG_EXEC)) { qemu_log("Trace %p [" TARGET_FMT_lx "] %s\n", tb->tc_ptr, tb->pc, lookup_symbol(tb->pc)); } if (next_tb != 0 && tb->page_addr[1] == -1 && !qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) { tb_add_jump((TranslationBlock *)(next_tb & ~TB_EXIT_MASK), next_tb & TB_EXIT_MASK, tb); } tb_unlock(); if (likely(!cpu->exit_request)) { trace_exec_tb(tb, tb->pc); tc_ptr = tb->tc_ptr; cpu->current_tb = tb; next_tb = cpu_tb_exec(cpu, tc_ptr); cpu->current_tb = NULL; switch (next_tb & TB_EXIT_MASK) { case TB_EXIT_REQUESTED: smp_rmb(); next_tb = 0; break; case TB_EXIT_ICOUNT_EXPIRED: { int insns_left = cpu->icount_decr.u32; if (cpu->icount_extra && insns_left >= 0) { cpu->icount_extra += insns_left; insns_left = MIN(0xffff, cpu->icount_extra); cpu->icount_extra -= insns_left; cpu->icount_decr.u16.low = insns_left; } else { if (insns_left > 0) { tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK); cpu_exec_nocache(cpu, insns_left, tb); align_clocks(&sc, cpu); } cpu->exception_index = EXCP_INTERRUPT; next_tb = 0; cpu_loop_exit(cpu); } break; } default: break; } } align_clocks(&sc, cpu); } } else { cpu = current_cpu; cc = CPU_GET_CLASS(cpu); cpu->can_do_io = 1; #ifdef TARGET_I386 x86_cpu = X86_CPU(cpu); env = &x86_cpu->env; #endif tb_lock_reset(); } } cc->cpu_exec_exit(cpu); rcu_read_unlock(); current_cpu = NULL; atomic_set(&tcg_current_cpu, NULL); return ret; }
1threat
Kotlin static methods and variables : <p>I want to be able to save a class instance to a public static variable but I can't figure out how to do this in Kotlin.</p> <pre><code>class Foo { public static Foo instance; public Foo() { instance = this; } } </code></pre>
0debug
Angular2 Directive: How to detect DOM changes : <p>I want to implement Skrollr as an Angular2 attribute directive.</p> <p>So, the format may be:</p> <pre><code>&lt;body my-skrollr&gt; &lt;/body&gt; </code></pre> <p>However, in order to implement this, I need to be able to detect changes in the DOM in child elements below the containing tag (in this case, &lt;body&gt;), so that I can call skrollr.init().refresh(); and update the library to work with the new content.</p> <p>Is there a straightforward way of doing this that I'm not aware of, or am I approaching this incorrectly?</p>
0debug
Use input of purrr's map function to create a named list as output in R : <p>I am using the map function of the purrr package in R which gives as output a list. Now I would like the output to be a named list based on the input. An example is given below.</p> <pre><code>input &lt;- c("a", "b", "c") output &lt;- purrr::map(input, function(x) {paste0("test-", x)}) </code></pre> <p>From this I would like to access elements of the list using:</p> <pre><code>output$a </code></pre> <p>Or</p> <pre><code>output$b </code></pre>
0debug
Passing char* to pthread crashing : <p>I am trying to get a time-based pooling system with threads. I managed to pull this off using fork(), now I am trying to implement it using threads. The timer thread seems to work fine, but for some reason I cannot pass a char* array to the thread (dumping core). </p> <p>Note: If I try to exit the thread with status 0, I get no warning about giving an integer to a function returning void*. BUT, when I am trying to return something else, let it be 1, I get a warning. I tried to cast them to void*, but with no impact. </p> <p>Now, for some code:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;pthread.h&gt; #include &lt;unistd.h&gt; #define COUNTING_SUCCESS 0 #define POOLING_SUCCESS 1 int size = 3; void *count(void *bound_arg){ int index = 0; int *bound = (int*)bound_arg; printf("Counting started...\n"); while(index &lt; *bound){ printf("You have %d seconds left\n",*bound - index); sleep(1); index++; } printf("Time's up!\n"); pthread_exit(COUNTING_SUCCESS); } void *pool(void *questions_ptr){ char *questions = (char*)questions_ptr; char *answer = calloc(sizeof(char*)*size,size); for(int i =0 ; i &lt; size ; i++){ printf("%s : ",questions[i]); scanf("%s",&amp;answer); } pthread_exit(0); } int main(){ char* questions[] = {"Q1","Q2","Q3"}; int limit = 3 ; int *countingLimit = &amp;limit; void *countingStatus; void *poolingStatus; pthread_t timerThread; int threadID = pthread_create(&amp;timerThread,NULL,count,(void*)countingLimit); pthread_join(timerThread,&amp;countingStatus); printf("%d\n",(int*)countingStatus); pthread_t poolingThread; int poolingThreadID = pthread_create(&amp;poolingThread,NULL,pool,(void*)questions); pthread_join(poolingThread,&amp;poolingStatus); printf("%d\n",(int*)poolingStatus); } </code></pre> <p>Sample output:</p> <pre><code>Counting started... You have 3 seconds left You have 2 seconds left You have 1 seconds left Time's up! 0 Segmentation fault (core dumped) //this is where i try to pass the char* </code></pre> <p>I cannot get it to enter the function.</p> <p>P.S. I am building the executable using:</p> <pre><code>gcc -o pool pool.c -pthread </code></pre>
0debug
mail attachments downloading in any mail server through programming : what i am trying to achieve is to download mail attachments of particular type from Gmail or yahoo or any other server through code.is it possible or any idea regarding this will be of great help
0debug
static void nbd_refresh_filename(BlockDriverState *bs, QDict *options) { BDRVNBDState *s = bs->opaque; QDict *opts = qdict_new(); QObject *saddr_qdict; Visitor *ov; const char *host = NULL, *port = NULL, *path = NULL; if (s->saddr->type == SOCKET_ADDRESS_KIND_INET) { const InetSocketAddress *inet = s->saddr->u.inet.data; if (!inet->has_ipv4 && !inet->has_ipv6 && !inet->has_to) { host = inet->host; port = inet->port; } } else if (s->saddr->type == SOCKET_ADDRESS_KIND_UNIX) { path = s->saddr->u.q_unix.data->path; } qdict_put(opts, "driver", qstring_from_str("nbd")); if (path && s->export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd+unix: } else if (path && !s->export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd+unix: } else if (host && s->export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd: } else if (host && !s->export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd: } ov = qobject_output_visitor_new(&saddr_qdict); visit_type_SocketAddress(ov, NULL, &s->saddr, &error_abort); visit_complete(ov, &saddr_qdict); assert(qobject_type(saddr_qdict) == QTYPE_QDICT); qdict_put_obj(opts, "server", saddr_qdict); if (s->export) { qdict_put(opts, "export", qstring_from_str(s->export)); } if (s->tlscredsid) { qdict_put(opts, "tls-creds", qstring_from_str(s->tlscredsid)); } qdict_flatten(opts); bs->full_open_options = opts; }
1threat
static struct pathelem *add_dir_maybe(struct pathelem *path) { DIR *dir; if ((dir = opendir(path->pathname)) != NULL) { struct dirent *dirent; while ((dirent = readdir(dir)) != NULL) { if (!streq(dirent->d_name,".") && !streq(dirent->d_name,"..")){ path = add_entry(path, dirent->d_name); } } closedir(dir); } return path; }
1threat
static int g2m_decode_frame(AVCodecContext *avctx, void *data, int *got_picture_ptr, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; G2MContext *c = avctx->priv_data; AVFrame *pic = data; GetByteContext bc, tbc; int magic; int got_header = 0; uint32_t chunk_size, cur_size; int chunk_type; int i; int ret; if (buf_size < 12) { av_log(avctx, AV_LOG_ERROR, "Frame should have at least 12 bytes, got %d instead\n", buf_size); return AVERROR_INVALIDDATA; } bytestream2_init(&bc, buf, buf_size); magic = bytestream2_get_be32(&bc); if ((magic & ~0xF) != MKBETAG('G', '2', 'M', '0') || (magic & 0xF) < 2 || (magic & 0xF) > 4) { av_log(avctx, AV_LOG_ERROR, "Wrong magic %08X\n", magic); return AVERROR_INVALIDDATA; } if ((magic & 0xF) != 4) { av_log(avctx, AV_LOG_ERROR, "G2M2 and G2M3 are not yet supported\n"); return AVERROR(ENOSYS); } while (bytestream2_get_bytes_left(&bc) > 5) { chunk_size = bytestream2_get_le32(&bc) - 1; chunk_type = bytestream2_get_byte(&bc); if (chunk_size > bytestream2_get_bytes_left(&bc)) { av_log(avctx, AV_LOG_ERROR, "Invalid chunk size %d type %02X\n", chunk_size, chunk_type); break; } switch (chunk_type) { case FRAME_INFO: c->got_header = 0; if (chunk_size < 21) { av_log(avctx, AV_LOG_ERROR, "Invalid frame info size %d\n", chunk_size); break; } c->width = bytestream2_get_be32(&bc); c->height = bytestream2_get_be32(&bc); if (c->width < 16 || c->width > avctx->width || c->height < 16 || c->height > avctx->height) { av_log(avctx, AV_LOG_ERROR, "Invalid frame dimensions %dx%d\n", c->width, c->height); c->width = c->height = 0; bytestream2_skip(&bc, bytestream2_get_bytes_left(&bc)); } if (c->width != avctx->width || c->height != avctx->height) avcodec_set_dimensions(avctx, c->width, c->height); c->compression = bytestream2_get_be32(&bc); if (c->compression != 2 && c->compression != 3) { av_log(avctx, AV_LOG_ERROR, "Unknown compression method %d\n", c->compression); return AVERROR_PATCHWELCOME; } c->tile_width = bytestream2_get_be32(&bc); c->tile_height = bytestream2_get_be32(&bc); if (!c->tile_width || !c->tile_height) { av_log(avctx, AV_LOG_ERROR, "Invalid tile dimensions %dx%d\n", c->tile_width, c->tile_height); return AVERROR_INVALIDDATA; } c->tiles_x = (c->width + c->tile_width - 1) / c->tile_width; c->tiles_y = (c->height + c->tile_height - 1) / c->tile_height; c->bpp = bytestream2_get_byte(&bc); chunk_size -= 21; bytestream2_skip(&bc, chunk_size); if (g2m_init_buffers(c)) return AVERROR(ENOMEM); got_header = 1; break; case TILE_DATA: if (!c->tiles_x || !c->tiles_y) { av_log(avctx, AV_LOG_WARNING, "No frame header - skipping tile\n"); bytestream2_skip(&bc, bytestream2_get_bytes_left(&bc)); break; } if (chunk_size < 2) { av_log(avctx, AV_LOG_ERROR, "Invalid tile data size %d\n", chunk_size); break; } c->tile_x = bytestream2_get_byte(&bc); c->tile_y = bytestream2_get_byte(&bc); if (c->tile_x >= c->tiles_x || c->tile_y >= c->tiles_y) { av_log(avctx, AV_LOG_ERROR, "Invalid tile pos %d,%d (in %dx%d grid)\n", c->tile_x, c->tile_y, c->tiles_x, c->tiles_y); break; } chunk_size -= 2; ret = 0; switch (c->compression) { case COMPR_EPIC_J_B: av_log(avctx, AV_LOG_ERROR, "ePIC j-b compression is not implemented yet\n"); return AVERROR(ENOSYS); case COMPR_KEMPF_J_B: ret = kempf_decode_tile(c, c->tile_x, c->tile_y, buf + bytestream2_tell(&bc), chunk_size); break; } if (ret && c->framebuf) av_log(avctx, AV_LOG_ERROR, "Error decoding tile %d,%d\n", c->tile_x, c->tile_y); bytestream2_skip(&bc, chunk_size); break; case CURSOR_POS: if (chunk_size < 5) { av_log(avctx, AV_LOG_ERROR, "Invalid cursor pos size %d\n", chunk_size); break; } c->cursor_x = bytestream2_get_be16(&bc); c->cursor_y = bytestream2_get_be16(&bc); bytestream2_skip(&bc, chunk_size - 4); break; case CURSOR_SHAPE: if (chunk_size < 8) { av_log(avctx, AV_LOG_ERROR, "Invalid cursor data size %d\n", chunk_size); break; } bytestream2_init(&tbc, buf + bytestream2_tell(&bc), chunk_size - 4); cur_size = bytestream2_get_be32(&tbc); c->cursor_w = bytestream2_get_byte(&tbc); c->cursor_h = bytestream2_get_byte(&tbc); c->cursor_hot_x = bytestream2_get_byte(&tbc); c->cursor_hot_y = bytestream2_get_byte(&tbc); c->cursor_fmt = bytestream2_get_byte(&tbc); if (cur_size >= chunk_size || c->cursor_w * c->cursor_h / 4 > cur_size) { av_log(avctx, AV_LOG_ERROR, "Invalid cursor data size %d\n", chunk_size); break; } g2m_load_cursor(c, &tbc); bytestream2_skip(&bc, chunk_size); break; case CHUNK_CC: case CHUNK_CD: bytestream2_skip(&bc, chunk_size); break; default: av_log(avctx, AV_LOG_WARNING, "Skipping chunk type %02X\n", chunk_type); bytestream2_skip(&bc, chunk_size); } } if (got_header) c->got_header = 1; if (c->width && c->height && c->framebuf) { if ((ret = ff_get_buffer(avctx, pic, 0)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } pic->key_frame = got_header; pic->pict_type = got_header ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; for (i = 0; i < avctx->height; i++) memcpy(pic->data[0] + i * pic->linesize[0], c->framebuf + i * c->framebuf_stride, c->width * 3); g2m_paint_cursor(c, pic->data[0], pic->linesize[0]); *got_picture_ptr = 1; } return buf_size; }
1threat
PHP For Loop in code : <p>I am having trouble getting my for loop to work in php. I am trying to make my code loop the time ten times with my css formating</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="clockloop.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="bodycontainer"&gt; &lt;h1&gt; Clock Loop &lt;/h1&gt;&lt;hr&gt; &lt;?php for($i=0;$i&lt;=10;$i++){ &lt;div id="border"&gt; &lt;span id = "font"&gt; &lt;?php echo date("G:i:s") ?&gt; &lt;/span&gt; &lt;/div&gt; &lt;h3&gt; Today is &lt;?php echo date("F,j,Y") ?&gt; &lt;/h3&gt; } ?&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
0debug
Pytest: run a function at the end of the tests : <p>I would like to run a function at the end of <strong>all</strong> the tests.</p> <p>A kind of global teardown function.</p> <p>I found an example <a href="https://gist.github.com/inklesspen/4555229" rel="noreferrer">here</a> and some clues <a href="http://doc.pytest.org/en/latest/fixture.html" rel="noreferrer">here</a> but it doesn't match my need. It runs the function at the beginning of the tests. I also saw the function <code>pytest_runtest_teardown()</code>, but it is called after each test.</p> <p>Plus: if the function could be called only if all the tests passed, it would be great.</p>
0debug
static inline uint32_t efsctsf(uint32_t val) { CPU_FloatU u; float32 tmp; u.l = val; if (unlikely(float32_is_nan(u.f))) return 0; tmp = uint64_to_float32(1ULL << 32, &env->vec_status); u.f = float32_mul(u.f, tmp, &env->vec_status); return float32_to_int32(u.f, &env->vec_status); }
1threat
trying to get perl regex to "find" multi-line AND single-line HTML comments in an HTML file.... : I'm reading in an html file, trying to find HTML comments, both single and multi-line. I've stripped it down to just a few examples, and some other content just to have something there. I've read a lot of the entries here, can't get a definitive answer to this... I'm reading in the html file in "slurp" mode, and doing a match of my pattern.. this code runs now and produce 1 (the first) match.. #!C:\Perl\bin\perl.exe BEGIN { unshift @INC, 'C:\rmhperl';} use warnings;no warnings 'uninitialized'; chdir 'c:\watts\html'; open FILE, "test.html" or print 'error opening file "test.html" '; my $text = do { local $/; <FILE> }; close(FILE); if ($text =~ m/(?s)(<!--.*?)(-->\n)/sg) { print "1 = $1 2= $2\n"; } exit; in my html file, I've set up single and multi-line html comments... I can get the first OR the last to appear, but not EVERY one (at least in "slurp" mode)... I'm told I should be able to accomplish this with one regex... so the objective is "find ALL HTML comments, regardless of their being single/multi-line comments"... so I built the regex to find both... it doesn't find the single-lines, and only finds 1 match... I'm trying to find switches/way to tell regex to find EVERY match, whether it occurs on one line, or is a multi-line... I can do it either/or, but can't get them to work with one regex... I can do non-slurp mode, and find the "<!--" tag, then loop until I see the "-->" tag, but wanted to see if I can get it to work... I've been reading about this, and trying to find relevant examples... can't see what I'm missing... Here's the HTML file snippet I have been using for the regex: #########################1st line of html file below ######################### <!DOCTYPE html> <script type="text/javascript" src="fadeslideshow.js"></script> <style> .divTable { display: block; width: 100%; } .divTableBody, .divTableRow{ clear: both; } .divTableCell { border: 1px solid #999999; float: left; overflow: hide; padding: 2%; width: 45%; } .divTable:after { display: block; font-size: 0; content: " "; clear: both; height: 100px; } </style> <style type="text/css"> <!-- a:link {color: #0000ff;} a:visited {color: #3563a8;} a:active {color: #000000;} a:hover {background-color: #000000;} a {text-decoration: none;} --> </style> </head> <body class="home"> <div id="white_back"> <div style="text-align: center"> </div> <div class="chromestyle" id="chromemenu"> <ul> <!-- <li><a href="xyz.com">Home</a></li> --> <li><a href="#" rel="dropmenu0">About Us</a></li> <li><a href="#" rel="dropmenu5">Publications</a></li> </ul> </div> <!--1st drop down menu --> <div id="dropmenu0" class="dropmenudiv"> </div> <!--2nd drop down menu --> <div id="dropmenu1" class="dropmenudiv"> </div> #########################last line of html file above##################### any help, or rtfm reference link appreciated... Mickey Holliday
0debug
How to form a new list except the strings in python : data = ["45", "56", "75", "ABC", "32"] how to get the result data_new=[45,56,75,32]? Thank you
0debug
void ff_sbrdsp_init_x86(SBRDSPContext *s) { if (HAVE_YASM) { int mm_flags = av_get_cpu_flags(); if (mm_flags & AV_CPU_FLAG_SSE) { s->sum_square = ff_sbr_sum_square_sse; s->hf_g_filt = ff_sbr_hf_g_filt_sse; } } }
1threat
static int mpeg_decode_postinit(AVCodecContext *avctx) { Mpeg1Context *s1 = avctx->priv_data; MpegEncContext *s = &s1->mpeg_enc_ctx; uint8_t old_permutation[64]; int ret; if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) { avctx->sample_aspect_ratio = av_d2q(1.0 / ff_mpeg1_aspect[s->aspect_ratio_info], 255); } else { aspect if (s->aspect_ratio_info > 1) { AVRational dar = av_mul_q(av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info], (AVRational) { s1->pan_scan.width, s1->pan_scan.height }), (AVRational) { s->width, s->height }); if ((s1->pan_scan.width == 0) || (s1->pan_scan.height == 0) || (av_cmp_q(dar, (AVRational) { 4, 3 }) && av_cmp_q(dar, (AVRational) { 16, 9 }))) { s->avctx->sample_aspect_ratio = av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info], (AVRational) { s->width, s->height }); } else { s->avctx->sample_aspect_ratio = av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info], (AVRational) { s1->pan_scan.width, s1->pan_scan.height }); ff_dlog(avctx, "aspect A %d/%d\n", ff_mpeg2_aspect[s->aspect_ratio_info].num, ff_mpeg2_aspect[s->aspect_ratio_info].den); ff_dlog(avctx, "aspect B %d/%d\n", s->avctx->sample_aspect_ratio.num, s->avctx->sample_aspect_ratio.den); } } else { s->avctx->sample_aspect_ratio = ff_mpeg2_aspect[s->aspect_ratio_info]; } } if (av_image_check_sar(s->width, s->height, avctx->sample_aspect_ratio) < 0) { av_log(avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n", avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den); avctx->sample_aspect_ratio = (AVRational){ 0, 1 }; } if ((s1->mpeg_enc_ctx_allocated == 0) || avctx->coded_width != s->width || avctx->coded_height != s->height || s1->save_width != s->width || s1->save_height != s->height || av_cmp_q(s1->save_aspect, s->avctx->sample_aspect_ratio) || (s1->save_progressive_seq != s->progressive_sequence && FFALIGN(s->height, 16) != FFALIGN(s->height, 32)) || 0) { if (s1->mpeg_enc_ctx_allocated) { ParseContext pc = s->parse_context; s->parse_context.buffer = 0; ff_mpv_common_end(s); s->parse_context = pc; s1->mpeg_enc_ctx_allocated = 0; } ret = ff_set_dimensions(avctx, s->width, s->height); if (ret < 0) return ret; if (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO && s->bit_rate) { avctx->rc_max_rate = s->bit_rate; } else if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO && s->bit_rate && (s->bit_rate != 0x3FFFF*400 || s->vbv_delay != 0xFFFF)) { avctx->bit_rate = s->bit_rate; } s1->save_aspect = s->avctx->sample_aspect_ratio; s1->save_width = s->width; s1->save_height = s->height; s1->save_progressive_seq = s->progressive_sequence; avctx->has_b_frames = !s->low_delay; if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) { avctx->framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index]; avctx->ticks_per_frame = 1; avctx->chroma_sample_location = AVCHROMA_LOC_CENTER; } else { fps av_reduce(&s->avctx->framerate.num, &s->avctx->framerate.den, ff_mpeg12_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num, ff_mpeg12_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den, 1 << 30); avctx->ticks_per_frame = 2; switch (s->chroma_format) { case 1: avctx->chroma_sample_location = AVCHROMA_LOC_LEFT; break; case 2: case 3: avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT; break; default: av_assert0(0); } } avctx->pix_fmt = mpeg_get_pixelformat(avctx); setup_hwaccel_for_pixfmt(avctx); memcpy(old_permutation, s->idsp.idct_permutation, 64 * sizeof(uint8_t)); ff_mpv_idct_init(s); if ((ret = ff_mpv_common_init(s)) < 0) return ret; quant_matrix_rebuild(s->intra_matrix, old_permutation, s->idsp.idct_permutation); quant_matrix_rebuild(s->inter_matrix, old_permutation, s->idsp.idct_permutation); quant_matrix_rebuild(s->chroma_intra_matrix, old_permutation, s->idsp.idct_permutation); quant_matrix_rebuild(s->chroma_inter_matrix, old_permutation, s->idsp.idct_permutation); s1->mpeg_enc_ctx_allocated = 1; } return 0; }
1threat
how to convert json data into a table format by use spark : <p>// how to convert json data into a table format by use spark .</p> <blockquote> <p>Blockquote</p> </blockquote> <p>Dataset list = session.read().json("/home/a.json").</p>
0debug
connection.query('SELECT * FROM users WHERE username = ' + input_string)
1threat
An empty snapshotView on iPhone 7/7plus : <p>My first question here:) Recently I update my Xcode to 8, and the <code>resizableSnapshotView</code> method doesn't work properly on some simulators. The snapshotView works well on all testing devices with iOS9/10 and simulators under iPhone6s, but it is empty on iPhone7/7p simulators. I think 7/7p may need some authorities for accessing snapshot, but I have no idea what they are.</p> <pre><code>let cell = self.tableView.cellForRow(at: IndexPath(row: 0, section: 0)) as! CalendarCell var topFrame = cell.frame topFrame.origin.y = tableView.contentOffset.y topFrame.size.height -= tableView.contentOffset.y topSnapshotView = tableView.resizableSnapshotView(from: topFrame, afterScreenUpdates: false, withCapInsets: UIEdgeInsets.zero) </code></pre>
0debug
static void usb_msd_cancel_io(USBPacket *p, void *opaque) { MSDState *s = opaque; s->scsi_dev->info->cancel_io(s->scsi_dev, s->tag); s->packet = NULL; s->scsi_len = 0; }
1threat
Python calling function in an other function from an other function : I want to call 1 precise function in an other function from an other function def exemple(): dostuff1(): print:('Stuff 1') dostuff2(): print:('Stuff 2') dostuff3(): print:('Stuff 3') def training(): #want to call ONLY Dostuff2
0debug
Set imageview photo dynamically : <p>I have +300 png pictures.Their names are like; aaa.png abka.png bxja.png daw.png.</p> <p>According to my setImage(String pictureName) function i want to set imageview View resource dynamically.</p> <pre><code>private void setImage(String pictureName){ myImgView.setBackgroundResource(R.drawable + picturename); } </code></pre> <p>My main idea is like this but as you can see it is imposible. What did i think to solve this problem is creating switch statemant for all +300 images but it will be really huge effort to implement this. </p> <p>What am i asking is; is there a any easy way to implement this.</p>
0debug
alert('Hello ' + user_input);
1threat
How to upload image file to remote server folder using php script : <p>Sir ..</p> <p>Please help me to find code to upload image file from one computer to remote server folder using php script.</p>
0debug
How Do I Run A Script On A Specific Wepbage Using A Chrome Extension? : <p>I have a script that I would like to run on a specific page. How would I go about doing this using a Google Chrome extension?</p>
0debug
Slim Framework: Some method is not resolvable : I am new on Slime. Work on API project. Everything good until I have to add a new endpoint (new method too) and I got this Error for my new endpoint, another endpoint run well. Below is error log: Type: RuntimeException Message: [{“container”:{}},“getNotification”] is not resolvable File: /opt/vestia/api/vendor/slim/slim/Slim/CallableResolver.php Line: 104 Trace #0 /opt/myanime/api/vendor/slim/slim/Slim/CallableResolver.php(62): Slim\CallableResolver->assertCallable(Array) #1 /opt/myanime/api/vendor/slim/slim/Slim/CallableResolverAwareTrait.php(45): Slim\CallableResolver->resolve(‘UserController:…’) #2 /opt/myanime/api/vendor/slim/slim/Slim/Route.php(333): Slim\Routable->resolveCallable(‘UserController:…’) #3 /opt/myanime/api/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(122): Slim\Route->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response)) #4 /opt/myanime/api/vendor/slim/slim/Slim/Route.php(316): Slim\Route->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response)) #5 /opt/myanime/api/vendor/slim/slim/Slim/App.php(476): Slim\Route->run(Object(Slim\Http\Request), Object(Slim\Http\Response)) #6 /opt/myanime/api/src/MyanimeMiddleware.php(121): Slim\App->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response)) #7 [internal function]: App\MyanimeMiddleware->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App)) #8 /opt/myanime/api/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array(Object(App\VestiaMiddleware), Array) #9 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App)) #10 /opt/myanime/api/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(73): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App)) #11 /opt/myanime/api/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(122): Slim\App->Slim{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response)) #12 /opt/myanime/api/vendor/slim/slim/Slim/App.php(370): Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response)) #13 /opt/myanime/api/vendor/slim/slim/Slim/App.php(295): Slim\App->process(Object(Slim\Http\Request), Object(Slim\Http\Response)) #14 /opt/myanime/api/public/index.php(35): Slim\App->run() #15 {main} My routes for new endpoit: $app->get('/user/notification', 'UserController:getNotification'); My class: class UserController{ public function __construct($container) { // make the container available in the class $this->container = $container; } public function getNotification($request, $response, $args){ //my code here } } tried to `composer dump-autoload` but that did not work. please help.
0debug
static inline void _t_gen_mov_TN_env(TCGv tn, int offset) { if (offset > sizeof(CPUCRISState)) { fprintf(stderr, "wrong load from env from off=%d\n", offset); } tcg_gen_ld_tl(tn, cpu_env, offset); }
1threat
Pytorch softmax: What dimension to use? : <p>The function <code>torch.nn.functional.softmax</code> takes two parameters: <code>input</code> and <code>dim</code>. According to its documentation, the softmax operation is applied to all slices of <code>input</code> along the specified <code>dim</code>, and will rescale them so that the elements lie in the range <code>(0, 1)</code> and sum to 1. </p> <p>Let input be:</p> <pre><code>input = torch.randn((3, 4, 5, 6)) </code></pre> <p>Suppose I want the following, so that every entry in that array is 1:</p> <pre><code>sum = torch.sum(input, dim = 3) # sum's size is (3, 4, 5, 1) </code></pre> <p>How should I apply softmax?</p> <pre><code>softmax(input, dim = 0) # Way Number 0 softmax(input, dim = 1) # Way Number 1 softmax(input, dim = 2) # Way Number 2 softmax(input, dim = 3) # Way Number 3 </code></pre> <p>My intuition tells me that is the last one, but I am not sure. English is not my first language and the use of the word <code>along</code> seemed confusing to me because of that.</p> <p>I am not very clear on what "along" means, so I will use an example that could clarify things. Suppose we have a tensor of size (s1, s2, s3, s4), and I want this to happen</p>
0debug
static int ram_save_page(RAMState *rs, PageSearchStatus *pss, bool last_stage) { int pages = -1; uint64_t bytes_xmit; ram_addr_t current_addr; uint8_t *p; int ret; bool send_async = true; RAMBlock *block = pss->block; ram_addr_t offset = pss->page << TARGET_PAGE_BITS; p = block->host + offset; trace_ram_save_page(block->idstr, (uint64_t)offset, p); bytes_xmit = 0; ret = ram_control_save_page(rs->f, block->offset, offset, TARGET_PAGE_SIZE, &bytes_xmit); if (bytes_xmit) { rs->bytes_transferred += bytes_xmit; pages = 1; } XBZRLE_cache_lock(); current_addr = block->offset + offset; if (ret != RAM_SAVE_CONTROL_NOT_SUPP) { if (ret != RAM_SAVE_CONTROL_DELAYED) { if (bytes_xmit > 0) { rs->norm_pages++; } else if (bytes_xmit == 0) { rs->zero_pages++; } } } else { pages = save_zero_page(rs, block, offset, p); if (pages > 0) { xbzrle_cache_zero_page(rs, current_addr); ram_release_pages(block->idstr, offset, pages); } else if (!rs->ram_bulk_stage && !migration_in_postcopy() && migrate_use_xbzrle()) { pages = save_xbzrle_page(rs, &p, current_addr, block, offset, last_stage); if (!last_stage) { send_async = false; } } } if (pages == -1) { rs->bytes_transferred += save_page_header(rs, block, offset | RAM_SAVE_FLAG_PAGE); if (send_async) { qemu_put_buffer_async(rs->f, p, TARGET_PAGE_SIZE, migrate_release_ram() & migration_in_postcopy()); } else { qemu_put_buffer(rs->f, p, TARGET_PAGE_SIZE); } rs->bytes_transferred += TARGET_PAGE_SIZE; pages = 1; rs->norm_pages++; } XBZRLE_cache_unlock(); return pages; }
1threat
scp fails with "protocol error: filename does not match request" : <p>I have a script that uses SCP to pull a file from a remote Linux host on AWS. After running the same code nightly for about 6 months without issue, it started failing today with <code>protocol error: filename does not match request</code>. I reproduced the issue on some simpler filenames below:</p> <pre><code>$ scp -i $IDENT $HOST_AND_DIR/"foobar" . # the file is copied successfully $ scp -i $IDENT $HOST_AND_DIR/"'foobar'" . protocol error: filename does not match request # used to work, i swear... $ scp -i $IDENT $HOST_AND_DIR/"'foobarbaz'" . scp: /home/user_redacted/foobarbaz: No such file or directory # less surprising... </code></pre> <p>The reason for my single quotes was that I was grabbing a file with spaces in the name originally. To deal with the spaces, I had done <code>$HOST_AND_DIR/"'foo bar'"</code> for many months, but starting today, it would only accept <code>$HOST_AND_DIR/"foo\ bar"</code>. So, my issue <em>is</em> fixed, but I'm still curious about what's going on.</p> <p>I Googled the error message, but I don't see any real mentions of it, which surprises me.</p> <p>Both hosts involved have <code>OpenSSL 1.0.2g</code> in the output of <code>ssh -v localhost</code>, and <code>bash --version</code> says <code>GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)</code> Any ideas?</p>
0debug
static int s302m_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { S302Context *s = avctx->priv_data; AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int block_size, ret; int i; int non_pcm_data_type = -1; int frame_size = s302m_parse_frame_header(avctx, buf, buf_size); if (frame_size < 0) return frame_size; buf_size -= AES3_HEADER_LEN; buf += AES3_HEADER_LEN; block_size = (avctx->bits_per_raw_sample + 4) / 4; frame->nb_samples = 2 * (buf_size / block_size) / avctx->channels; if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; avctx->bit_rate = 48000 * avctx->channels * (avctx->bits_per_raw_sample + 4) + 32 * 48000 / frame->nb_samples; buf_size = (frame->nb_samples * avctx->channels / 2) * block_size; if (avctx->bits_per_raw_sample == 24) { uint32_t *o = (uint32_t *)frame->data[0]; for (; buf_size > 6; buf_size -= 7) { *o++ = (ff_reverse[buf[2]] << 24) | (ff_reverse[buf[1]] << 16) | (ff_reverse[buf[0]] << 8); *o++ = (ff_reverse[buf[6] & 0xf0] << 28) | (ff_reverse[buf[5]] << 20) | (ff_reverse[buf[4]] << 12) | (ff_reverse[buf[3] & 0x0f] << 4); buf += 7; } o = (uint32_t *)frame->data[0]; if (avctx->channels == 2) for (i=0; i<frame->nb_samples * 2 - 6; i+=2) { if (o[i] || o[i+1] || o[i+2] || o[i+3]) break; if (o[i+4] == 0x96F87200U && o[i+5] == 0xA54E1F00) { non_pcm_data_type = (o[i+6] >> 16) & 0x1F; break; } } } else if (avctx->bits_per_raw_sample == 20) { uint32_t *o = (uint32_t *)frame->data[0]; for (; buf_size > 5; buf_size -= 6) { *o++ = (ff_reverse[buf[2] & 0xf0] << 28) | (ff_reverse[buf[1]] << 20) | (ff_reverse[buf[0]] << 12); *o++ = (ff_reverse[buf[5] & 0xf0] << 28) | (ff_reverse[buf[4]] << 20) | (ff_reverse[buf[3]] << 12); buf += 6; } o = (uint32_t *)frame->data[0]; if (avctx->channels == 2) for (i=0; i<frame->nb_samples * 2 - 6; i+=2) { if (o[i] || o[i+1] || o[i+2] || o[i+3]) break; if (o[i+4] == 0x6F872000U && o[i+5] == 0x54E1F000) { non_pcm_data_type = (o[i+6] >> 16) & 0x1F; break; } } } else { uint16_t *o = (uint16_t *)frame->data[0]; for (; buf_size > 4; buf_size -= 5) { *o++ = (ff_reverse[buf[1]] << 8) | ff_reverse[buf[0]]; *o++ = (ff_reverse[buf[4] & 0xf0] << 12) | (ff_reverse[buf[3]] << 4) | (ff_reverse[buf[2]] >> 4); buf += 5; } o = (uint16_t *)frame->data[0]; if (avctx->channels == 2) for (i=0; i<frame->nb_samples * 2 - 6; i+=2) { if (o[i] || o[i+1] || o[i+2] || o[i+3]) break; if (o[i+4] == 0xF872U && o[i+5] == 0x4E1F) { non_pcm_data_type = (o[i+6] & 0x1F); break; } } } if (non_pcm_data_type != -1) { if (s->non_pcm_mode == 3) { av_log(avctx, AV_LOG_ERROR, "S302 non PCM mode with data type %d not supported\n", non_pcm_data_type); return AVERROR_PATCHWELCOME; } if (s->non_pcm_mode & 1) { return avpkt->size; } } avctx->sample_rate = 48000; *got_frame_ptr = 1; return avpkt->size; }
1threat
static float get_band_cost_ESC_mips(struct AACEncContext *s, PutBitContext *pb, const float *in, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits) { const float Q34 = ff_aac_pow34sf_tab[POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512]; const float IQ = ff_aac_pow2sf_tab [POW_SF2_ZERO + scale_idx - SCALE_ONE_POS + SCALE_DIV_512]; const float CLIPPED_ESCAPE = 165140.0f * IQ; int i; float cost = 0; int qc1, qc2, qc3, qc4; int curbits = 0; uint8_t *p_bits = (uint8_t*)ff_aac_spectral_bits[cb-1]; float *p_codes = (float* )ff_aac_codebook_vectors[cb-1]; for (i = 0; i < size; i += 4) { const float *vec, *vec2; int curidx, curidx2; float t1, t2, t3, t4; float di1, di2, di3, di4; int cond0, cond1, cond2, cond3; int c1, c2, c3, c4; int t6, t7; qc1 = scaled[i ] * Q34 + ROUND_STANDARD; qc2 = scaled[i+1] * Q34 + ROUND_STANDARD; qc3 = scaled[i+2] * Q34 + ROUND_STANDARD; qc4 = scaled[i+3] * Q34 + ROUND_STANDARD; __asm__ volatile ( ".set push \n\t" ".set noreorder \n\t" "ori %[t6], $zero, 15 \n\t" "ori %[t7], $zero, 16 \n\t" "shll_s.w %[c1], %[qc1], 18 \n\t" "shll_s.w %[c2], %[qc2], 18 \n\t" "shll_s.w %[c3], %[qc3], 18 \n\t" "shll_s.w %[c4], %[qc4], 18 \n\t" "srl %[c1], %[c1], 18 \n\t" "srl %[c2], %[c2], 18 \n\t" "srl %[c3], %[c3], 18 \n\t" "srl %[c4], %[c4], 18 \n\t" "slt %[cond0], %[t6], %[qc1] \n\t" "slt %[cond1], %[t6], %[qc2] \n\t" "slt %[cond2], %[t6], %[qc3] \n\t" "slt %[cond3], %[t6], %[qc4] \n\t" "movn %[qc1], %[t7], %[cond0] \n\t" "movn %[qc2], %[t7], %[cond1] \n\t" "movn %[qc3], %[t7], %[cond2] \n\t" "movn %[qc4], %[t7], %[cond3] \n\t" ".set pop \n\t" : [qc1]"+r"(qc1), [qc2]"+r"(qc2), [qc3]"+r"(qc3), [qc4]"+r"(qc4), [cond0]"=&r"(cond0), [cond1]"=&r"(cond1), [cond2]"=&r"(cond2), [cond3]"=&r"(cond3), [c1]"=&r"(c1), [c2]"=&r"(c2), [c3]"=&r"(c3), [c4]"=&r"(c4), [t6]"=&r"(t6), [t7]"=&r"(t7) ); curidx = 17 * qc1; curidx += qc2; curidx2 = 17 * qc3; curidx2 += qc4; curbits += p_bits[curidx]; curbits += esc_sign_bits[curidx]; vec = &p_codes[curidx*2]; curbits += p_bits[curidx2]; curbits += esc_sign_bits[curidx2]; vec2 = &p_codes[curidx2*2]; curbits += (av_log2(c1) * 2 - 3) & (-cond0); curbits += (av_log2(c2) * 2 - 3) & (-cond1); curbits += (av_log2(c3) * 2 - 3) & (-cond2); curbits += (av_log2(c4) * 2 - 3) & (-cond3); t1 = fabsf(in[i ]); t2 = fabsf(in[i+1]); t3 = fabsf(in[i+2]); t4 = fabsf(in[i+3]); if (cond0) { if (t1 >= CLIPPED_ESCAPE) { di1 = t1 - CLIPPED_ESCAPE; } else { di1 = t1 - c1 * cbrtf(c1) * IQ; } } else di1 = t1 - vec[0] * IQ; if (cond1) { if (t2 >= CLIPPED_ESCAPE) { di2 = t2 - CLIPPED_ESCAPE; } else { di2 = t2 - c2 * cbrtf(c2) * IQ; } } else di2 = t2 - vec[1] * IQ; if (cond2) { if (t3 >= CLIPPED_ESCAPE) { di3 = t3 - CLIPPED_ESCAPE; } else { di3 = t3 - c3 * cbrtf(c3) * IQ; } } else di3 = t3 - vec2[0] * IQ; if (cond3) { if (t4 >= CLIPPED_ESCAPE) { di4 = t4 - CLIPPED_ESCAPE; } else { di4 = t4 - c4 * cbrtf(c4) * IQ; } } else di4 = t4 - vec2[1]*IQ; cost += di1 * di1 + di2 * di2 + di3 * di3 + di4 * di4; } if (bits) *bits = curbits; return cost * lambda + curbits; }
1threat
ViewCompat.setNestedScrollingEnabled not working kitkat Android : ViewCompat.setNestedScrollingEnabled not working kitkat and it is working fine Lollipop version. So help me plz. Scrolling issue ViewCompat.setNestedScrollingEnabled
0debug
If integer look like this `010` is first 0 consider integer? : <p>There was misunderstanding about this <code>int number = 010</code>, What I am saying is </p> <blockquote> <p>first 0 is not integer due to c# has no leading zero so <code>010</code> will be <code>10</code></p> </blockquote> <p>however one of stackoverflow user saying </p> <blockquote> <p>first 0 in <code>010</code> is integer </p> </blockquote> <p>so could anyone help to explain in details why first <code>0</code> in <code>010</code> is integer even though it has no value or it doesn't represent any mathematical integer !</p> <p>thanks in advance </p>
0debug
Is there a way to make RecyclerView requiresFadingEdge unaffected by paddingTop and paddingBottom : <p>Currently, I need to use <code>paddingTop</code> and <code>paddingBottom</code> of <code>RecyclerView</code>, as I want to avoid complex space calculation, in my first <code>RecyclerView</code> item and last item.</p> <p>However, I notice that, <code>requiresFadingEdge</code> effect will be affected as well.</p> <p>This is my XML</p> <pre><code>&lt;androidx.recyclerview.widget.RecyclerView android:requiresFadingEdge="vertical" android:paddingTop="0dp" android:paddingBottom="0dp" android:overScrollMode="always" android:background="?attr/recyclerViewBackground" android:id="@+id/recycler_view" android:layout_width="match_parent" android:layout_height="match_parent" android:clipToPadding="false" /&gt; </code></pre> <hr> <h2>When paddingTop and paddingBottom is 40dp</h2> <p><a href="https://i.stack.imgur.com/J8u20.png" rel="noreferrer"><img src="https://i.stack.imgur.com/J8u20.png" alt="enter image description here"></a></p> <p>As you can see, the fading effect shift down by 40dp, which is not what I want.</p> <hr> <h2>When paddingTop and paddingBottom is 0dp</h2> <p><a href="https://i.stack.imgur.com/LfDEv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LfDEv.png" alt="enter image description here"></a></p> <p>Fading effect looks fine. But, I need to have non-zero <code>paddingTop</code> and <code>paddingBottom</code>, for my <code>RecyclerView</code>.</p> <hr> <p>Is there a way to make <code>RecyclerView</code>'s <code>requiresFadingEdge</code> unaffected by <code>paddingTop</code> and <code>paddingBottom</code>?</p>
0debug
def sort_numeric_strings(nums_str): result = [int(x) for x in nums_str] result.sort() return result
0debug
code for bulk csv files in a directory to convert to xlsx : i use below code to convert from csv to xlsx. But it only convert single file at a time.I want this to convert all the files i directory at a time. $xl = new-object -comobject excel.application $xl.visible = $true $Workbook = $xl.workbooks.open("$loglocation\errors_$server.csv") $Worksheets = $Workbooks.worksheets $Workbook.SaveAs("$loglocation\errors_$server.xls",1) $Workbook.Saved = $True $xl.Quit()
0debug
static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret, void *arg) { GlusterAIOCB *acb = (GlusterAIOCB *)arg; BlockDriverState *bs = acb->common.bs; BDRVGlusterState *s = bs->opaque; int retval; acb->ret = ret; retval = qemu_write_full(s->fds[GLUSTER_FD_WRITE], &acb, sizeof(acb)); if (retval != sizeof(acb)) { error_report("Gluster failed to notify QEMU about IO completion"); qemu_mutex_lock_iothread(); acb->common.cb(acb->common.opaque, -EIO); qemu_aio_release(acb); close(s->fds[GLUSTER_FD_READ]); close(s->fds[GLUSTER_FD_WRITE]); qemu_aio_set_fd_handler(s->fds[GLUSTER_FD_READ], NULL, NULL, NULL); bs->drv = NULL; qemu_mutex_unlock_iothread(); } }
1threat
Get QuerySet in QuerySet Python : <p>I have a basic question about Python hope your guys help me. Get QuerySet in QuerySet Python</p> <p>I have a queryset:</p> <pre><code>qrs1 = [1, 3, 5, 6, 9, 11, 16, 22] </code></pre> <p>I want to <strong>get first, second and third object</strong> in this queryset and <strong>put it on a queryset</strong> like this result.</p> <pre><code>result = [1, 3, 5] </code></pre>
0debug
static CharDriverState *qemu_chr_open_ringbuf(const char *id, ChardevBackend *backend, ChardevReturn *ret, Error **errp) { ChardevRingbuf *opts = backend->u.ringbuf; CharDriverState *chr; RingBufCharDriver *d; chr = qemu_chr_alloc(); d = g_malloc(sizeof(*d)); d->size = opts->has_size ? opts->size : 65536; if (d->size & (d->size - 1)) { error_setg(errp, "size of ringbuf chardev must be power of two"); goto fail; } d->prod = 0; d->cons = 0; d->cbuf = g_malloc0(d->size); chr->opaque = d; chr->chr_write = ringbuf_chr_write; chr->chr_close = ringbuf_chr_close; return chr; fail: g_free(d); g_free(chr); return NULL; }
1threat
av_cold void ff_audio_convert_init_x86(AudioConvert *ac) { int cpu_flags = av_get_cpu_flags(); if (EXTERNAL_MMX(cpu_flags)) { ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, 0, 1, 8, "MMX", ff_conv_s32_to_s16_mmx); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP, 6, 1, 4, "MMX", ff_conv_fltp_to_flt_6ch_mmx); } if (EXTERNAL_SSE(cpu_flags)) { ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP, 6, 1, 2, "SSE", ff_conv_fltp_to_s16_6ch_sse); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP, 2, 16, 8, "SSE", ff_conv_fltp_to_flt_2ch_sse); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT, 2, 16, 4, "SSE", ff_conv_flt_to_fltp_2ch_sse); } if (EXTERNAL_SSE2(cpu_flags)) { if (!(cpu_flags & AV_CPU_FLAG_SSE2SLOW)) { ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, 0, 16, 16, "SSE2", ff_conv_s32_to_s16_sse2); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P, 6, 16, 8, "SSE2", ff_conv_s16p_to_s16_6ch_sse2); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP, 6, 16, 4, "SSE2", ff_conv_fltp_to_s16_6ch_sse2); } else { ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P, 6, 1, 4, "SSE2SLOW", ff_conv_s16p_to_s16_6ch_sse2slow); } ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16, 0, 16, 8, "SSE2", ff_conv_s16_to_s32_sse2); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, 0, 16, 8, "SSE2", ff_conv_s16_to_flt_sse2); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32, 0, 16, 8, "SSE2", ff_conv_s32_to_flt_sse2); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT, 0, 16, 16, "SSE2", ff_conv_flt_to_s16_sse2); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT, 0, 16, 16, "SSE2", ff_conv_flt_to_s32_sse2); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P, 2, 16, 16, "SSE2", ff_conv_s16p_to_s16_2ch_sse2); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P, 2, 16, 8, "SSE2", ff_conv_s16p_to_flt_2ch_sse2); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P, 6, 16, 4, "SSE2", ff_conv_s16p_to_flt_6ch_sse2); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP, 2, 16, 4, "SSE2", ff_conv_fltp_to_s16_2ch_sse2); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16, 2, 16, 8, "SSE2", ff_conv_s16_to_s16p_2ch_sse2); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16, 6, 16, 4, "SSE2", ff_conv_s16_to_s16p_6ch_sse2); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16, 2, 16, 8, "SSE2", ff_conv_s16_to_fltp_2ch_sse2); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16, 6, 16, 4, "SSE2", ff_conv_s16_to_fltp_6ch_sse2); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT, 2, 16, 8, "SSE2", ff_conv_flt_to_s16p_2ch_sse2); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT, 6, 16, 4, "SSE2", ff_conv_flt_to_s16p_6ch_sse2); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT, 6, 16, 4, "SSE2", ff_conv_flt_to_fltp_6ch_sse2); } if (EXTERNAL_SSSE3(cpu_flags)) { ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P, 6, 16, 4, "SSSE3", ff_conv_s16p_to_flt_6ch_ssse3); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP, 2, 16, 4, "SSSE3", ff_conv_fltp_to_s16_2ch_ssse3); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16, 2, 16, 8, "SSSE3", ff_conv_s16_to_s16p_2ch_ssse3); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16, 6, 16, 4, "SSSE3", ff_conv_s16_to_s16p_6ch_ssse3); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16, 6, 16, 4, "SSSE3", ff_conv_s16_to_fltp_6ch_ssse3); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT, 6, 16, 4, "SSSE3", ff_conv_flt_to_s16p_6ch_ssse3); } if (EXTERNAL_SSE4(cpu_flags)) { ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, 0, 16, 8, "SSE4", ff_conv_s16_to_flt_sse4); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP, 6, 16, 4, "SSE4", ff_conv_fltp_to_flt_6ch_sse4); } if (EXTERNAL_AVX(cpu_flags)) { ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32, 0, 32, 16, "AVX", ff_conv_s32_to_flt_avx); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT, 0, 32, 32, "AVX", ff_conv_flt_to_s32_avx); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P, 2, 16, 16, "AVX", ff_conv_s16p_to_s16_2ch_avx); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P, 6, 16, 8, "AVX", ff_conv_s16p_to_s16_6ch_avx); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P, 2, 16, 8, "AVX", ff_conv_s16p_to_flt_2ch_avx); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P, 6, 16, 4, "AVX", ff_conv_s16p_to_flt_6ch_avx); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP, 6, 16, 4, "AVX", ff_conv_fltp_to_s16_6ch_avx); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP, 6, 16, 4, "AVX", ff_conv_fltp_to_flt_6ch_avx); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16, 2, 16, 8, "AVX", ff_conv_s16_to_s16p_2ch_avx); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16, 6, 16, 4, "AVX", ff_conv_s16_to_s16p_6ch_avx); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16, 2, 16, 8, "AVX", ff_conv_s16_to_fltp_2ch_avx); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16, 6, 16, 4, "AVX", ff_conv_s16_to_fltp_6ch_avx); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT, 2, 16, 8, "AVX", ff_conv_flt_to_s16p_2ch_avx); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT, 6, 16, 4, "AVX", ff_conv_flt_to_s16p_6ch_avx); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT, 2, 16, 4, "AVX", ff_conv_flt_to_fltp_2ch_avx); ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT, 6, 16, 4, "AVX", ff_conv_flt_to_fltp_6ch_avx); } }
1threat
static void moxie_cpu_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); CPUClass *cc = CPU_CLASS(oc); MoxieCPUClass *mcc = MOXIE_CPU_CLASS(oc); mcc->parent_realize = dc->realize; dc->realize = moxie_cpu_realizefn; mcc->parent_reset = cc->reset; cc->reset = moxie_cpu_reset; cc->class_by_name = moxie_cpu_class_by_name; cc->has_work = moxie_cpu_has_work; cc->do_interrupt = moxie_cpu_do_interrupt; cc->dump_state = moxie_cpu_dump_state; cc->set_pc = moxie_cpu_set_pc; #ifdef CONFIG_USER_ONLY cc->handle_mmu_fault = moxie_cpu_handle_mmu_fault; #else cc->get_phys_page_debug = moxie_cpu_get_phys_page_debug; cc->vmsd = &vmstate_moxie_cpu; #endif cc->disas_set_info = moxie_cpu_disas_set_info; dc->cannot_destroy_with_object_finalize_yet = true; }
1threat
static av_cold void dcadec_flush(AVCodecContext *avctx) { DCAContext *s = avctx->priv_data; ff_dca_core_flush(&s->core); ff_dca_xll_flush(&s->xll); ff_dca_lbr_flush(&s->lbr); s->core_residual_valid = 0; }
1threat
static int disas_cp_insn(CPUState *env, DisasContext *s, uint32_t insn) { TCGv tmp, tmp2; uint32_t rd = (insn >> 12) & 0xf; uint32_t cp = (insn >> 8) & 0xf; if (IS_USER(s)) { return 1; } if (insn & ARM_CP_RW_BIT) { if (!env->cp[cp].cp_read) return 1; gen_set_pc_im(s->pc); tmp = new_tmp(); tmp2 = tcg_const_i32(insn); gen_helper_get_cp(tmp, cpu_env, tmp2); tcg_temp_free(tmp2); store_reg(s, rd, tmp); } else { if (!env->cp[cp].cp_write) return 1; gen_set_pc_im(s->pc); tmp = load_reg(s, rd); tmp2 = tcg_const_i32(insn); gen_helper_set_cp(cpu_env, tmp2, tmp); tcg_temp_free(tmp2); dead_tmp(tmp); } return 0; }
1threat
void qemu_spice_display_switch(SimpleSpiceDisplay *ssd, DisplaySurface *surface) { SimpleSpiceUpdate *update; bool need_destroy; if (surface && ssd->surface && surface_width(surface) == pixman_image_get_width(ssd->surface) && surface_height(surface) == pixman_image_get_height(ssd->surface)) { dprint(1, "%s/%d: fast (%dx%d)\n", __func__, ssd->qxl.id, surface_width(surface), surface_height(surface)); qemu_mutex_lock(&ssd->lock); ssd->ds = surface; pixman_image_unref(ssd->surface); ssd->surface = pixman_image_ref(ssd->ds->image); qemu_mutex_unlock(&ssd->lock); qemu_spice_display_update(ssd, 0, 0, surface_width(surface), surface_height(surface)); return; } dprint(1, "%s/%d: full (%dx%d -> %dx%d)\n", __func__, ssd->qxl.id, ssd->surface ? pixman_image_get_width(ssd->surface) : 0, ssd->surface ? pixman_image_get_height(ssd->surface) : 0, surface ? surface_width(surface) : 0, surface ? surface_height(surface) : 0); memset(&ssd->dirty, 0, sizeof(ssd->dirty)); if (ssd->surface) { pixman_image_unref(ssd->surface); ssd->surface = NULL; pixman_image_unref(ssd->mirror); ssd->mirror = NULL; } qemu_mutex_lock(&ssd->lock); need_destroy = (ssd->ds != NULL); ssd->ds = surface; while ((update = QTAILQ_FIRST(&ssd->updates)) != NULL) { QTAILQ_REMOVE(&ssd->updates, update, next); qemu_spice_destroy_update(ssd, update); } qemu_mutex_unlock(&ssd->lock); if (need_destroy) { qemu_spice_destroy_host_primary(ssd); } if (ssd->ds) { ssd->surface = pixman_image_ref(ssd->ds->image); ssd->mirror = qemu_pixman_mirror_create(ssd->ds->format, ssd->ds->image); qemu_spice_create_host_primary(ssd); } memset(&ssd->dirty, 0, sizeof(ssd->dirty)); ssd->notify++; }
1threat
Java newbie needs help again : my quick question is. how would i be able to allow this method to return it's damageDelt value? i want to use this value to be able to subtract from another class field variable hitpoint value. how can i do this? as i would like this method to reduce the hitpoints from another objects hitpoints. Thank you package com.DavidLee.Programming; public class Main { public static void main(String[] args) { new Main().railGunAttack(); System.out.println(); } public void railGunAttack() { int randomNumber = (int) (Math.random() * 100 + 1); if (randomNumber > 0 && randomNumber < 50) { int damageDelt = 2 * randomNumber; System.out.println("Railgun did " + damageDelt + " Damage"); } else if (randomNumber > 50 && randomNumber < 80) { int damageDelt = 4 * randomNumber; System.out.println("Railgun did " + damageDelt + " Damage"); } else if (randomNumber > 80 && randomNumber < 100) { int damageDelt = 50 - randomNumber; System.out.println("Railgun did " + damageDelt + " Damage " + "Railgun projectiles glazed the target"); } else System.out.println("Railgun missed target"); } }
0debug
static void scsi_flush_complete(void * opaque, int ret) { SCSIDiskReq *r = (SCSIDiskReq *)opaque; SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); if (r->req.aiocb != NULL) { r->req.aiocb = NULL; bdrv_acct_done(s->qdev.conf.bs, &r->acct); } if (ret < 0) { if (scsi_handle_rw_error(r, -ret)) { goto done; } } scsi_req_complete(&r->req, GOOD); done: if (!r->req.io_canceled) { scsi_req_unref(&r->req); } }
1threat
Should subscribeOn and observeOn only be invoked by the final subscriber? : <p>The <a href="http://www.introtorx.com/content/v1.0.10621.0/15_SchedulingAndThreading.html">Scheduling and Threading</a> section of <em>Intro to Rx</em> says that </p> <blockquote> <p>the use of SubscribeOn and ObserveOn should only be invoked by the final subscriber</p> </blockquote> <p>It also says that in an UI application, the presentation layer, which is normally the final subscriber, should be the one to invoke these methods.</p> <p>I am wondering if the advice is solid, since I see some situations in which this is not convenient:</p> <ol> <li>For starters, I don't believe that the presentation layer should decide where an Observable coming from the data layer should be subscribed. In my opinion, the presentation layer should be unaware if the data is coming from a database, from a REST API, or from memory. For this reason, it's convenient for the data layer to call <code>subscribeOn()</code> before returning the Observable, passing the IO Scheduler or the immediate Scheduler as convenient.</li> <li>If the presentation layer gets the Observable from some service or use case (which in turn gets it from the data layer) and this service decides that it needs to process the stream in some computation Scheduler, why should the presentation layer care about this?</li> <li>What about a stream that is originally coming from the UI, so it needs to be subscribed in the UI thread. Then it will be sent to some service to do some work and finally come back to the presentation layer to be observed in the UI thread. That would require the UI stream to be <code>subscribeOn()</code> the UI Scheduler, then <code>observeOn()</code> some other Scheduler, and finally <code>observeOn()</code> the UI Scheduler. In this case, being able to invoke <code>subscribeOn()</code> and <code>observeOn()</code> only in the final subscriber would mean that the stream can only be processed in the UI thread.</li> </ol> <p>Is there some good reason why I should sacrifice the architecture of my application and ignore Rx's ability to easily switch threads by invoking these two methods only by the final subscriber?</p>
0debug
def is_valid_parenthese( str1): stack, pchar = [], {"(": ")", "{": "}", "[": "]"} for parenthese in str1: if parenthese in pchar: stack.append(parenthese) elif len(stack) == 0 or pchar[stack.pop()] != parenthese: return False return len(stack) == 0
0debug
static void spr_write_decr(DisasContext *ctx, int sprn, int gprn) { if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_store_decr(cpu_env, cpu_gpr[gprn]); if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_end(); gen_stop_exception(ctx); } }
1threat
How can I speed up my 3D Euclidean distance matrix code : <p>I have created code to calculate the distance of all objects (tagID) from one another based on x, y, z coordinates (TX, TY, TZ) at each time step (Frame). While this code does work, it is too slow for what I need. My current test data, has about 538,792 rows of data, my actual data will be about 6,880,000 lines of data. Currently it takes a few minutes (maybe 10-15) to make these distance matrices, and since I will have 40 sets of data, I woud like to speed thigs up.</p> <p>The current code is as follows:</p> <pre><code># Sample data frame with correct columns: data2 = ({'Frame' :[1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7], 'tagID' : ['nb1','nb2','nb3','nb1','nb2','nb3','nb1','nb2','nb3','nb1','nb2','nb3','nb1','nb2','nb3','nb1','nb2','nb3','nb1','nb2','nb3'], 'TX':[5,2,3,4,5,6,7,5,np.nan,5,2,3,4,5,6,7,5,4,8,3,2], 'TY':[4,2,3,4,5,9,3,2,np.nan,5,2,3,4,5,6,7,5,4,8,3,2], 'TZ':[2,3,4,6,7,8,4,3,np.nan,5,2,3,4,5,6,7,5,4,8,3,2]}) df = pd.DataFrame(data2) Frame tagID TX TY TZ 0 1 nb1 5.0 4.0 2.0 1 1 nb2 2.0 2.0 3.0 2 1 nb3 3.0 3.0 4.0 3 2 nb1 4.0 4.0 6.0 4 2 nb2 5.0 5.0 7.0 5 2 nb3 6.0 9.0 8.0 6 3 nb1 7.0 3.0 4.0 7 3 nb2 5.0 2.0 3.0 8 3 nb3 NaN NaN NaN 9 4 nb1 5.0 5.0 5.0 10 4 nb2 2.0 2.0 2.0 11 4 nb3 3.0 3.0 3.0 12 5 nb1 4.0 4.0 4.0 13 5 nb2 5.0 5.0 5.0 14 5 nb3 6.0 6.0 6.0 15 6 nb1 7.0 7.0 7.0 16 6 nb2 5.0 5.0 5.0 17 6 nb3 4.0 4.0 4.0 18 7 nb1 8.0 8.0 8.0 19 7 nb2 3.0 3.0 3.0 20 7 nb3 2.0 2.0 2.0 # Calculate the squared distance between all x points: TXdf = [] for i in range(1,df['Frame'].max()+1): boox = df['Frame'] == i tempx = df[boox] tx=tempx['TX'].apply(lambda x : (tempx['TX']-x)**2) tx.columns=tempx.tagID tx['ID']=tempx.tagID tx['Frame'] = tempx.Frame TXdf.append(tx) TXdfFinal = pd.concat(TXdf) # once all df for every print(TXdfFinal) TXdfFinal.info() # Calculate the squared distance between all y points: print('y-diff sum') TYdf = [] for i in range(1,df['Frame'].max()+1): booy = df['Frame'] == i tempy = df[booy] ty=tempy['TY'].apply(lambda x : (tempy['TY']-x)**2) ty.columns=tempy.tagID ty['ID']=tempy.tagID ty['Frame'] = tempy.Frame TYdf.append(ty) TYdfFinal = pd.concat(TYdf) print(TYdfFinal) TYdfFinal.info() # Calculate the squared distance between all z points: print('z-diff sum') TZdf = [] for i in range(1,df['Frame'].max()+1): booz = df['Frame'] == i tempz = df[booz] tz=tempz['TZ'].apply(lambda x : (tempz['TZ']-x)**2) tz.columns=tempz.tagID tz['ID']=tempz.tagID tz['Frame'] = tempz.Frame TZdf.append(tz) TZdfFinal = pd.concat(TZdf) # Add all squared differences together: euSum = TXdfFinal + TYdfFinal + TZdfFinal # Square root the sum of the differences of each coordinate for Euclidean distance and add Frame and ID columns back on: euDist = euSum.loc[:, euSum.columns !='ID'].apply(lambda x: x**0.5) euDist['tagID'] = list(TXdfFinal['ID']) euDist['Frame'] = list(TXdfFinal['Frame']) # Add the distance matrix to the original dataframe based on Frame and ID columns: new_df = pd.merge(df, euDist, how='left', left_on=['Frame','tagID'], right_on = ['Frame','tagID']) Frame tagID TX TY TZ nb1 nb2 nb3 0 1 nb1 5.0 4.0 2.0 0.0000 3.7417 3.0000 1 1 nb2 2.0 2.0 3.0 3.7417 0.0000 1.7321 2 1 nb3 3.0 3.0 4.0 3.0000 1.7321 0.0000 3 2 nb1 4.0 4.0 6.0 0.0000 1.7321 5.7446 4 2 nb2 5.0 5.0 7.0 1.7321 0.0000 4.2426 5 2 nb3 6.0 9.0 8.0 5.7446 4.2426 0.0000 6 3 nb1 7.0 3.0 4.0 0.0000 2.4495 NaN 7 3 nb2 5.0 2.0 3.0 2.4495 0.0000 NaN 8 3 nb3 NaN NaN NaN NaN NaN NaN 9 4 nb1 5.0 5.0 5.0 0.0000 5.1962 3.4641 10 4 nb2 2.0 2.0 2.0 5.1962 0.0000 1.7321 11 4 nb3 3.0 3.0 3.0 3.4641 1.7321 0.0000 12 5 nb1 4.0 4.0 4.0 0.0000 1.7321 3.4641 13 5 nb2 5.0 5.0 5.0 1.7321 0.0000 1.7321 14 5 nb3 6.0 6.0 6.0 3.4641 1.7321 0.0000 15 6 nb1 7.0 7.0 7.0 0.0000 3.4641 5.1962 16 6 nb2 5.0 5.0 5.0 3.4641 0.0000 1.7321 17 6 nb3 4.0 4.0 4.0 5.1962 1.7321 0.0000 18 7 nb1 8.0 8.0 8.0 0.0000 8.6603 10.3923 19 7 nb2 3.0 3.0 3.0 8.6603 0.0000 1.7321 20 7 nb3 2.0 2.0 2.0 10.3923 1.7321 0.0000 </code></pre> <p>I have tried using both: euclidean() and pdist() with metric=’euclidean’ but can’t get the iteration correct.</p> <p>Any advice on how to get the same result but a lot faster would be greatly apprecieated.</p>
0debug
Access ms SQL Database Data From C# Plugin in CRM on-demand : It is possible to run a MS SQL query inside of a Dynamics 365 plug-in, if the SQL Server is externally exposed? (Online version) If it is possible then how?
0debug
ALTER TABLE DROP COLUMN failed because one or more objects access this column : <p>I am trying to do this:</p> <pre><code>ALTER TABLE CompanyTransactions DROP COLUMN Created </code></pre> <p>But I get this:</p> <blockquote> <p>Msg 5074, Level 16, State 1, Line 2 The object 'DF__CompanyTr__Creat__0CDAE408' is dependent on column 'Created'. Msg 4922, Level 16, State 9, Line 2 ALTER TABLE DROP COLUMN Created failed because one or more objects access this column.</p> </blockquote> <p>This is a code first table. Somehow the migrations have become all messed up and I am trying to manually roll back some changed.</p> <p>I have <em>no</em> idea what this is:</p> <pre><code>DF__CompanyTr__Creat__0CDAE408 </code></pre>
0debug
static int net_bridge_run_helper(const char *helper, const char *bridge) { sigset_t oldmask, mask; int pid, status; char *args[5]; char **parg; int sv[2]; sigemptyset(&mask); sigaddset(&mask, SIGCHLD); sigprocmask(SIG_BLOCK, &mask, &oldmask); if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1) { return -1; } pid = fork(); if (pid == 0) { int open_max = sysconf(_SC_OPEN_MAX), i; char fd_buf[6+10]; char br_buf[6+IFNAMSIZ] = {0}; char helper_cmd[PATH_MAX + sizeof(fd_buf) + sizeof(br_buf) + 15]; for (i = 3; i < open_max; i++) { if (i != sv[1]) { close(i); } } snprintf(fd_buf, sizeof(fd_buf), "%s%d", "--fd=", sv[1]); if (strrchr(helper, ' ') || strrchr(helper, '\t')) { if (strstr(helper, "--br=") == NULL) { snprintf(br_buf, sizeof(br_buf), "%s%s", "--br=", bridge); } snprintf(helper_cmd, sizeof(helper_cmd), "%s %s %s %s", helper, "--use-vnet", fd_buf, br_buf); parg = args; *parg++ = (char *)"sh"; *parg++ = (char *)"-c"; *parg++ = helper_cmd; *parg++ = NULL; execv("/bin/sh", args); } else { snprintf(br_buf, sizeof(br_buf), "%s%s", "--br=", bridge); parg = args; *parg++ = (char *)helper; *parg++ = (char *)"--use-vnet"; *parg++ = fd_buf; *parg++ = br_buf; *parg++ = NULL; execv(helper, args); } _exit(1); } else if (pid > 0) { int fd; close(sv[1]); do { fd = recv_fd(sv[0]); } while (fd == -1 && errno == EINTR); close(sv[0]); while (waitpid(pid, &status, 0) != pid) { } sigprocmask(SIG_SETMASK, &oldmask, NULL); if (fd < 0) { fprintf(stderr, "failed to recv file descriptor\n"); return -1; } if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { return fd; } } fprintf(stderr, "failed to launch bridge helper\n"); return -1; }
1threat
void ff_ivi_output_plane(IVIPlaneDesc *plane, uint8_t *dst, int dst_pitch) { int x, y; const int16_t *src = plane->bands[0].buf; uint32_t pitch = plane->bands[0].pitch; for (y = 0; y < plane->height; y++) { for (x = 0; x < plane->width; x++) dst[x] = av_clip_uint8(src[x] + 128); src += pitch; dst += dst_pitch; } }
1threat
static void qmp_input_type_int64(Visitor *v, const char *name, int64_t *obj, Error **errp) { QmpInputVisitor *qiv = to_qiv(v); QObject *qobj = qmp_input_get_object(qiv, name, true, errp); QInt *qint; if (!qobj) { return; } qint = qobject_to_qint(qobj); if (!qint) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", "integer"); return; } *obj = qint_get_int(qint); }
1threat
static void test_acpi_q35_tcg_memhp(void) { test_data data; memset(&data, 0, sizeof(data)); data.machine = MACHINE_Q35; data.variant = ".memhp"; test_acpi_one(" -m 128,slots=3,maxmem=1G -numa node", &data); free_test_data(&data); }
1threat
static int spapr_cpu_core_realize_child(Object *child, void *opaque) { Error **errp = opaque, *local_err = NULL; sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); CPUState *cs = CPU(child); PowerPCCPU *cpu = POWERPC_CPU(cs); object_property_set_bool(child, true, "realized", &local_err); if (local_err) { error_propagate(errp, local_err); return 1; } spapr_cpu_init(spapr, cpu, &local_err); if (local_err) { error_propagate(errp, local_err); return 1; } return 0; }
1threat
static int mpc8_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { AVStream *st = s->streams[stream_index]; MPCContext *c = s->priv_data; int index = av_index_search_timestamp(st, timestamp, flags); if(index < 0) return -1; avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET); c->frame = st->index_entries[index].timestamp; return 0; }
1threat
void isa_register_portio_list(ISADevice *dev, uint16_t start, const MemoryRegionPortio *pio_start, void *opaque, const char *name) { PortioList piolist; isa_init_ioport(dev, start); portio_list_init(&piolist, OBJECT(dev), pio_start, opaque, name); portio_list_add(&piolist, isabus->address_space_io, start); }
1threat
void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp) { int fd = monitor_get_fd(cur_mon, fdname, errp); if (fd == -1) { return; } s->file = qemu_fdopen(fd, "wb"); migrate_fd_connect(s); }
1threat
static int xvid_ff_2pass_create(xvid_plg_create_t * param, void ** handle) { struct xvid_ff_pass1 *x = (struct xvid_ff_pass1 *)param->param; char *log = x->context->twopassbuffer; if( log == NULL ) return XVID_ERR_FAIL; log[0] = 0; snprintf(log, BUFFER_REMAINING(log), "# avconv 2-pass log file, using xvid codec\n"); snprintf(BUFFER_CAT(log), BUFFER_REMAINING(log), "# Do not modify. libxvidcore version: %d.%d.%d\n\n", XVID_VERSION_MAJOR(XVID_VERSION), XVID_VERSION_MINOR(XVID_VERSION), XVID_VERSION_PATCH(XVID_VERSION)); *handle = x->context; return 0; }
1threat
static int parallels_create(const char *filename, QemuOpts *opts, Error **errp) { int64_t total_size, cl_size; uint8_t tmp[BDRV_SECTOR_SIZE]; Error *local_err = NULL; BlockBackend *file; uint32_t bat_entries, bat_sectors; ParallelsHeader header; int ret; total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE); cl_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_CLUSTER_SIZE, DEFAULT_CLUSTER_SIZE), BDRV_SECTOR_SIZE); ret = bdrv_create_file(filename, opts, &local_err); if (ret < 0) { return ret; file = blk_new_open(filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL, &local_err); if (file == NULL) { return -EIO; blk_set_allow_write_beyond_eof(file, true); ret = blk_truncate(file, 0); if (ret < 0) { goto exit; bat_entries = DIV_ROUND_UP(total_size, cl_size); bat_sectors = DIV_ROUND_UP(bat_entry_off(bat_entries), cl_size); bat_sectors = (bat_sectors * cl_size) >> BDRV_SECTOR_BITS; memset(&header, 0, sizeof(header)); memcpy(header.magic, HEADER_MAGIC2, sizeof(header.magic)); header.version = cpu_to_le32(HEADER_VERSION); header.heads = cpu_to_le32(16); header.cylinders = cpu_to_le32(total_size / BDRV_SECTOR_SIZE / 16 / 32); header.tracks = cpu_to_le32(cl_size >> BDRV_SECTOR_BITS); header.bat_entries = cpu_to_le32(bat_entries); header.nb_sectors = cpu_to_le64(DIV_ROUND_UP(total_size, BDRV_SECTOR_SIZE)); header.data_off = cpu_to_le32(bat_sectors); memset(tmp, 0, sizeof(tmp)); memcpy(tmp, &header, sizeof(header)); ret = blk_pwrite(file, 0, tmp, BDRV_SECTOR_SIZE, 0); if (ret < 0) { goto exit; ret = blk_pwrite_zeroes(file, BDRV_SECTOR_SIZE, (bat_sectors - 1) << BDRV_SECTOR_BITS, 0); if (ret < 0) { goto exit; ret = 0; done: blk_unref(file); return ret; exit: error_setg_errno(errp, -ret, "Failed to create Parallels image"); goto done;
1threat
How to convert a variable to bold in vba : I have the below vba code and "A" is holding some string , i want to change the format of string to "Bold". Set A = Worksheets("Mapping").Cells(rowNumber, columnNumber) ex: A="currency" expected o/p:-**currency** Please help me how can i do it.
0debug
What is favicon.ico ? Why is it required? : <p>I am new to Web Programming and browsing thru chrome dev tools, I always wondered what is favicon and why is it needed??</p>
0debug
How to swap multiple cells in excel : I was wondering if there is a method where I can swap/ switch data automatically in excell. For example: I have an excell sheet of almost 16.000 columns. Each columns have 5 rows. The 5 rows contain information such as A,B,C,D,E but the data is not in sequence, so I have the following: B,A,C,D,E or B,C,D,E. I want a function that can put all A's first and the rows that do not contain an A so (B,C,D,E) to add an blank row before B. Please I really need a solution, since there are a lot of columns it will cost me a lot of time and I had try google and youtube but only show me how to do it manually and with less data and columns.
0debug
How do I convert this JSON file from POJO and vice versa : <pre><code>{ "d": { "ComplaintNo": "", "Status": "", "UpdateDate": "", "UpdateTime": "", "ComplaintReason": "", "ClosureType": "", "Ibase": "", "Component": "", "ProductId": "", "ProductDescription": "", "Identification": "", "Cat1": "", "Cat2": "", "Cat3": "", "StatusReason": "", "VisitDate": "", "VisitTime": "", "NoOfVisit": "", "SerialNo": "", "OtherSpecify": "", "Complaint_product": [ { "SequenceNo": "", "SparepartId": "", "Quantity": "3.00", "Group": "", "Model": "" }, { "SequenceNo": "", "SparepartId": "", "Quantity": "3.00", "Group": "", "Model": "" } ], "Complaint_retuarn": [ {} ] } } </code></pre> <p>I have this above JSON String , I need this as my output from Android Code , ways to achieve it .</p> <p>The above Output has complex "Complaint_retuarn" and "Complaint_product" entities , How will I convert using those in POJO Class ?</p>
0debug
INVALID_ARGUMENT: Request payload size exceeds the limit: 10485760 bytes : <p>I'm using for the first time the GCS Speech API for a project to convert a series of audio files to text. Each file has around 60 minutes and is a person talking continuously during the whole time. I've installed the GC SDK and I'm using it to perform the requests as shown bellow:</p> <pre><code>gcloud ml speech recognize-long-running \ "/path/to/file/audio.flac" \ --language-code="pt-PT" --async </code></pre> <p>Every time I run this on one of my recording, it gives the following error message:</p> <pre><code>ERROR: (gcloud.ml.speech.recognize-long-running) INVALID_ARGUMENT: Request payload size exceeds the limit: 10485760 bytes. </code></pre> <p>It seems to be a very hard restriction because if the API is able to process files up to 180 minutes, there's no way it'll output a maximum of <a href="https://cloud.google.com/speech-to-text/quotas" rel="noreferrer">10,000</a> characters worth of speech.<br> I've tried to split the audio files into smaller pieces and reached up to four 15 minute samples and even so I've got the same error. Besides, even if it worked, it would be a very tedious and impractical task to split every new recording I make from here forward.</p> <p>I've been searching and so far I haven't reached any conclusion about how to increase or circumvent this limitation. I'm on a free trial account but I'm happy to upgrade to a paid subscription to have this limit increased. As far as I understood, this limitation will persist even if I'm on a paid subscription.</p> <p>Has anyone found any solution for this problem?</p>
0debug
def get_product(val) : res = 1 for ele in val: res *= ele return res def find_k_product(test_list, K): res = get_product([sub[K] for sub in test_list]) return (res)
0debug
'iostream.h' file not found, c++98 : Trying to compile old cpp project as per http://stackoverflow.com/questions/12606713/enforcing-the-c98-standard-in-gcc. When I run the command `g++ -std=c++98 -pedantic -ggdb -c file.cxx` it errs out with the error `fatal error: 'iostream.h' file not found`. I'm using brew, gcc5, on a mac El Capitan. gcc --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 8.0.0 (clang-800.0.38) Target: x86_64-apple-darwin15.6.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
0debug
Sublime Text 3 with Sass Support : <p>Since Bootstrap changed from less to sass... I have to use sass now. I somehow can't find an easy solution for having auto-completion and auto-compiling on save for Sublime Text 3.</p> <p>Does anyone know a Plugin or something which gives me these features?</p> <p>I want to be able to specify where the compiled css should go, where my custom-sass files are and where bootstrap is located. :)</p> <p>Thanks</p>
0debug
static int svq3_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; SVQ3Context *svq3 = avctx->priv_data; H264Context *h = &svq3->h; MpegEncContext *s = &h->s; int buf_size = avpkt->size; int m, mb_type; if (buf_size == 0) { if (s->next_picture_ptr && !s->low_delay) { *(AVFrame *) data = s->next_picture.f; s->next_picture_ptr = NULL; *got_frame = 1; } return 0; } init_get_bits(&s->gb, buf, 8 * buf_size); s->mb_x = s->mb_y = h->mb_xy = 0; if (svq3_decode_slice_header(avctx)) return -1; s->pict_type = h->slice_type; s->picture_number = h->slice_num; if (avctx->debug & FF_DEBUG_PICT_INFO) av_log(h->s.avctx, AV_LOG_DEBUG, "%c hpel:%d, tpel:%d aqp:%d qp:%d, slice_num:%02X\n", av_get_picture_type_char(s->pict_type), svq3->halfpel_flag, svq3->thirdpel_flag, s->adaptive_quant, s->qscale, h->slice_num); s->current_picture.f.pict_type = s->pict_type; s->current_picture.f.key_frame = (s->pict_type == AV_PICTURE_TYPE_I); if (s->last_picture_ptr == NULL && s->pict_type == AV_PICTURE_TYPE_B) return 0; if (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B || avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I || avctx->skip_frame >= AVDISCARD_ALL) return 0; if (s->next_p_frame_damaged) { if (s->pict_type == AV_PICTURE_TYPE_B) return 0; else s->next_p_frame_damaged = 0; } if (ff_h264_frame_start(h) < 0) return -1; if (s->pict_type == AV_PICTURE_TYPE_B) { h->frame_num_offset = h->slice_num - h->prev_frame_num; if (h->frame_num_offset < 0) h->frame_num_offset += 256; if (h->frame_num_offset == 0 || h->frame_num_offset >= h->prev_frame_num_offset) { av_log(h->s.avctx, AV_LOG_ERROR, "error in B-frame picture id\n"); return -1; } } else { h->prev_frame_num = h->frame_num; h->frame_num = h->slice_num; h->prev_frame_num_offset = h->frame_num - h->prev_frame_num; if (h->prev_frame_num_offset < 0) h->prev_frame_num_offset += 256; } for (m = 0; m < 2; m++) { int i; for (i = 0; i < 4; i++) { int j; for (j = -1; j < 4; j++) h->ref_cache[m][scan8[0] + 8 * i + j] = 1; if (i < 3) h->ref_cache[m][scan8[0] + 8 * i + j] = PART_NOT_AVAILABLE; } } for (s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) { for (s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++) { h->mb_xy = s->mb_x + s->mb_y * s->mb_stride; if ((get_bits_count(&s->gb) + 7) >= s->gb.size_in_bits && ((get_bits_count(&s->gb) & 7) == 0 || show_bits(&s->gb, -get_bits_count(&s->gb) & 7) == 0)) { skip_bits(&s->gb, svq3->next_slice_index - get_bits_count(&s->gb)); s->gb.size_in_bits = 8 * buf_size; if (svq3_decode_slice_header(avctx)) return -1; } mb_type = svq3_get_ue_golomb(&s->gb); if (s->pict_type == AV_PICTURE_TYPE_I) mb_type += 8; else if (s->pict_type == AV_PICTURE_TYPE_B && mb_type >= 4) mb_type += 4; if ((unsigned)mb_type > 33 || svq3_decode_mb(svq3, mb_type)) { av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y); return -1; } if (mb_type != 0) ff_h264_hl_decode_mb(h); if (s->pict_type != AV_PICTURE_TYPE_B && !s->low_delay) s->current_picture.f.mb_type[s->mb_x + s->mb_y * s->mb_stride] = (s->pict_type == AV_PICTURE_TYPE_P && mb_type < 8) ? (mb_type - 1) : -1; } ff_draw_horiz_band(s, 16 * s->mb_y, 16); } ff_MPV_frame_end(s); if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) *(AVFrame *)data = s->current_picture.f; else *(AVFrame *)data = s->last_picture.f; if (s->last_picture_ptr || s->low_delay) *got_frame = 1; return buf_size; }
1threat
static int v9fs_xattr_write(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp, uint64_t off, uint32_t count, struct iovec *sg, int cnt) { int i, to_copy; ssize_t err = 0; int write_count; int64_t xattr_len; size_t offset = 7; xattr_len = fidp->fs.xattr.len; write_count = xattr_len - off; if (write_count > count) { write_count = count; } else if (write_count < 0) { err = -ENOSPC; goto out; } offset += pdu_marshal(pdu, offset, "d", write_count); err = offset; fidp->fs.xattr.copied_len += write_count; for (i = 0; i < cnt; i++) { if (write_count > sg[i].iov_len) { to_copy = sg[i].iov_len; } else { to_copy = write_count; } memcpy((char *)fidp->fs.xattr.value + off, sg[i].iov_base, to_copy); off += to_copy; write_count -= to_copy; } out: return err; }
1threat
static int buffered_rate_limit(void *opaque) { QEMUFileBuffered *s = opaque; int ret; ret = qemu_file_get_error(s->file); if (ret) { return ret; } if (s->bytes_xfer > s->xfer_limit) return 1; return 0; }
1threat
Fixing "str" obejct is not callable -when using set() function Python 3.6.4 : I'm writing some code that is trying to remove duplicates in a string of characters and numbers. I was going to use the set() function to remove duplicate characters but it throws a error... I tried reworking things but nothing seemed to fix the issue... In this block of code I'm generating 10 character long string than after completing that running the string through the set() function. ``` while(list<=10): spacer=random.choice(charlist) final=str(final)+str(spacer) list+=1 print(final) set(final) ``` THE ERROR: ```Traceback (most recent call last): File "", line 45, in <module> set(final) TypeError: 'str' object is not callable```
0debug
Free word list for word game : <p>I am building a word game in English. Is there a free list of words that I can download and use of a free service that can help validate the word entered by the user?</p>
0debug
How would i create a regex for the following : <pre><code>some value {arg1} {arg2} {arg3} another value {arg1} idkhere {arg1} {arg2} </code></pre> <p>I'm looking to create a regex that will match each {arg\d} as a group, so if theres 3 args in a line it'll have 3 groups, if one then only one group. I'm new to regex so not sure how I'd do this.</p>
0debug
Enable remote errors with ASP.NET Core : <p>Normal ASP.NET (not core) applications could add this to the web.config to see errors from remote locations:</p> <pre><code>&lt;system.webServer&gt; &lt;httpErrors errorMode="Detailed" /&gt; &lt;/system.webServer&gt; </code></pre> <p>It was helpful for when you could not login to the actual server to see what the error message was.</p> <p>I can't seem to find the same setting in .Net Core.</p> <p><strong>How do I turn on remote error messages in ASP.NET Core?</strong></p>
0debug