problem
stringlengths
26
131k
labels
class label
2 classes
How to share a list between two files : <p>So I have two .py files that need to share a list, but I can't get it to work as it always creates a second list in place of using the first that was created.</p>
0debug
I'm getting an error "Error type 'AuthResult' is not a subtype of type 'FirebaseUser' in type cast" when I'm trying to login or signup : <p>I'm making a flutter app for my college project, where I'm adding a login and signup page and authenticating it via Firebase, and when I click login the debug console says <strong>"Error type 'AuthResult' is not a subtype of type 'FirebaseUser' in type cast"</strong> and when I reload the app after this error it successfully logs in.</p> <p>Everything was working best before the update of the <strong>firebase_auth</strong> package to 0.12.0 after this update, the methods "signInWithEmailAndPassword()" and "createUserWithEmailAndPassword()" throwing an error <strong>"A value of type 'AuthResult' can't be assigned to a variable of type 'FirebaseUser'. Try changing the type of the variable, or casting the right-hand type to 'FirebaseUser'"</strong>, so I added a cast <strong>as FirebaseUser</strong> which fixed the error and the app was built successfully but when i clicked on login or create account, debug console said <strong>Error type 'AuthResult' is not a subtype of type 'FirebaseUser' in type cast</strong></p> <p>the main login and create account function code before the update of firebase_auth 0.12.0</p> <pre><code>Future&lt;String&gt; signIn(String email, String password) async { FirebaseUser user = await FirebaseAuth.instance.signInWithEmailAndPassword( email: email, password: password); return user.uid; } Future&lt;String&gt; createUser(String email, String password) async { FirebaseUser user = await FirebaseAuth.instance.createUserWithEmailAndPassword( email: email, password: password); return user.uid; } </code></pre> <p>the above code was working fine, after the update (firebase_auth 0.12.0) the same code started throwing this error,</p> <pre><code>A value of type 'AuthResult' can't be assigned to a variable of type 'FirebaseUser'. Try changing the type of the variable, or casting the right-hand type to 'FirebaseUser'.dart(invalid_assignment) </code></pre> <p>I fixed the error by casting "FirebaseUser" as shown below</p> <pre><code>Future&lt;String&gt; signIn(String email, String password) async { FirebaseUser user = await FirebaseAuth.instance.signInWithEmailAndPassword( email: email, password: password) as FirebaseUser; return user.uid; } Future&lt;String&gt; createUser(String email, String password) async { FirebaseUser user = await FirebaseAuth.instance.createUserWithEmailAndPassword( email: email, password: password) as FirebaseUser; return user.uid; } </code></pre> <p>this new code didn't threw an error in compilation but when I try to login or create new account it throws an error in debug console Error type 'AuthResult' is not a subtype of type 'FirebaseUser' in type cast and the new created account is successfully created on firebase but the app doesn't go on the next page but as soon as i reload it starts with the page that should come after login and creation of account(sign out is working perfectly)</p>
0debug
Limit max width of Container in Flutter : <pre><code> Widget build(context) { return Row( mainAxisSize: MainAxisSize.min, children: [ Container( width: 300, padding: EdgeInsets.all(10), decoration: BoxDecoration( color: color ?? Colors.blue, borderRadius: BorderRadius.circular(10) ), child: msg ) ], ); } </code></pre> <p>This is build method of my widget and It renders this UI depending on what I pass as <code>msg</code> paramter</p> <ol> <li>Loading text <a href="https://i.stack.imgur.com/JggN2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JggN2.png" alt="enter image description here"></a></li> <li>Some very long text <a href="https://i.stack.imgur.com/Pu2Yp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Pu2Yp.png" alt="enter image description here"></a></li> </ol> <p>Now the issue I am facing is that I am not able to wrap the text inside this container/blue box without setting it's width but If I set width of container/blue box then it will always stay that wide no matter how short the text is.</p> <p>Now is there a way to set maxWidth (like let's say 500) of container/blue box? So that the blue box will become as wide as required for small text like "Loading" and for long text it will expand till it reaches width of 500 units and then will wrap the text ?</p> <p><strong>Required output for long text:</strong></p> <p>For small text like loading I dont want any change in UI but for long text I want it to look like this. <a href="https://i.stack.imgur.com/yH6hw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yH6hw.png" alt="enter image description here"></a></p>
0debug
C#: I'm looking for a way to create new "primitive" types with additional constraints which are visible at coding time to users of the type : Suppose I have an entity in my universe of discourse called a `Widget`. Widgets are passed around between multiple distributed applications. All systems communicate through a messaging system. The messaging system passes a "common data model" (CDM) instance of the `Widget` around, where all applications translate to and from the CDM, and the communication follows the event-carried-state-transfer pattern.<sup>[1]</sup> Suppose the `Widget` has an attribute called a `WidgetCode`. This attribute is defined (by the system of record) to be an alphanumeric value of length exactly 8, and is exposed in the Common data model. I might implement that in the CDM as follows: ``` lang-cs class Widget { private string _WidgetCode; public string WidgetCode { get => _WidgetCode; set { if (value.Length != 8) throw new InvalidCastException(); _WidgetCode = value; } } } ``` This is OK, but not ideal. The constraint on length is not declarative, therefore it is not visible at design time to a consumer of this class. It will only be found if, at runtime, someone happens to try to write in a value which is not 8 characters long. There may also be other entities which have a `WidgetCode` as an attribute. For example, a `Sale` may contain the `WidgetCode` of the `Widget` which was sold <sup>[2]</sup>. So the data element `WidgetCode` appears in multiple places. So it would make sense to say "You know what, this `WidgetCode` thing is actually a type in its own right. In the context of the CDM it's a primitive<sup>[3]</sup>: ``` lang-cs struct WidgetCode { ... } class Widget { public WidgetCode widgetCode { get; set; } // ... } class Sale { // ... public WidgetCode widgetCode { get; set; } } ``` Now the length constraint on the WidgetCode type can be implemented by the type itself, but it's still going to be a runtime constraint, not a declarative constraint which is visible to the developer at coding-time. Is there any elegant way in C# to create a new "primitive", with constraints which are "declarative" and go beyond those inherent constraints provided by language primitives? --- [1] https://martinfowler.com/articles/201701-event-driven.html [2] I recognize that this is more like a DTO that exposes the structure of, for example, a table in a SQL database. I am not describing a `Sale` class which contains an instance of a `Widget` class like you might expect in, say, an ORM. But remember, what I'm describing is the *content of a message* representing a new sale. In other words, someone created a Sale in some system, and we want to send that data to another system in order to say "Hello other system, here is a Sale which was just created". When we do that, we're clearly cannot pass the lazily-loaded object graph as the message body. [3] Obviously there would be a naming problem here given conventional capitalization guidelines, so you'll have to excuse the camelCase name.
0debug
Concate Explanation : i have a question, please don't downvote it, i need clear explanation. Take a look at the code <?php $user_id = $_GET['user_id']; include "../database.php"; $query="SELECT name FROM user WHERE user_id='$user_id'"; $result=mysqli_query ($connect, $query); while($data = mysqli_fetch_array ($result)) { $name=$data['name']; echo"<tr><td>$name</td></tr>"; } ?> When i change into this one, the code still working. . { echo"<tr><td>".$data['name']."</td></tr>"; } But, when i change into this one, it is not working. . { echo"<tr><td>$data['name']</td></tr>"; } Why the " and . does really matter?
0debug
static void drive_backup_prepare(BlkTransactionState *common, Error **errp) { DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common); BlockBackend *blk; DriveBackup *backup; Error *local_err = NULL; assert(common->action->kind == TRANSACTION_ACTION_KIND_DRIVE_BACKUP); backup = common->action->drive_backup; blk = blk_by_name(backup->device); if (!blk) { error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found", backup->device); return; } state->aio_context = blk_get_aio_context(blk); aio_context_acquire(state->aio_context); qmp_drive_backup(backup->device, backup->target, backup->has_format, backup->format, backup->sync, backup->has_mode, backup->mode, backup->has_speed, backup->speed, backup->has_bitmap, backup->bitmap, backup->has_on_source_error, backup->on_source_error, backup->has_on_target_error, backup->on_target_error, &local_err); if (local_err) { error_propagate(errp, local_err); return; } state->bs = blk_bs(blk); state->job = state->bs->job; }
1threat
Whats the purpose of typescript's __awaiter : <p>consider this simple class</p> <pre><code>class Test { private foo(): Promise&lt;void&gt; { return new Promise&lt;void&gt;((resolve, reject) =&gt; { resolve(); }); } private async bar() { await this.foo(); } } </code></pre> <p>This get compiled into </p> <pre><code>var __awaiter = (this &amp;&amp; this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments)).next()); }); }; class Test { foo() { return new Promise((resolve, reject) =&gt; { resolve(); }); } bar() { return __awaiter(this, void 0, void 0, function* () { yield this.foo(); }); } } //# sourceMappingURL=Test.js.map </code></pre> <p>but ES6 supports the keyword await natively, why would typescript get rid of await and return another Promise wrapper? </p> <p>Whats the purpose of __awaiter </p>
0debug
void memory_region_init_rom_device(MemoryRegion *mr, const MemoryRegionOps *ops, void *opaque, const char *name, uint64_t size) { memory_region_init(mr, name, size); mr->ops = ops; mr->opaque = opaque; mr->terminates = true; mr->destructor = memory_region_destructor_rom_device; mr->ram_addr = qemu_ram_alloc(size, mr); mr->ram_addr |= cpu_register_io_memory(memory_region_read_thunk, memory_region_write_thunk, mr); mr->ram_addr |= IO_MEM_ROMD; mr->backend_registered = true; }
1threat
void laio_io_unplug(BlockDriverState *bs, void *aio_ctx, bool unplug) { struct qemu_laio_state *s = aio_ctx; assert(s->io_q.plugged > 0 || !unplug); if (unplug && --s->io_q.plugged > 0) { return; } if (!s->io_q.blocked && !QSIMPLEQ_EMPTY(&s->io_q.pending)) { ioq_submit(s); } }
1threat
static bool coroutine_fn do_perform_cow_encrypt(BlockDriverState *bs, uint64_t src_cluster_offset, unsigned offset_in_cluster, uint8_t *buffer, unsigned bytes) { if (bytes && bs->encrypted) { BDRVQcow2State *s = bs->opaque; int64_t sector = (src_cluster_offset + offset_in_cluster) >> BDRV_SECTOR_BITS; assert(s->cipher); assert((offset_in_cluster & ~BDRV_SECTOR_MASK) == 0); assert((bytes & ~BDRV_SECTOR_MASK) == 0); if (qcow2_encrypt_sectors(s, sector, buffer, bytes >> BDRV_SECTOR_BITS, true, NULL) < 0) { return false; } } return true; }
1threat
Emulator: audio: Failed to create voice `adc' : <p>[ while opening AVD Manager getting </p> <p>Emulator: qemu-system-i386.exe: warning: opening audio input failed</p> <p>Emulator: audio: Failed to create voice `adc'</p> <p>Emulator: audio: Failed to create voice `adc' got this error ? How to remove error ? ]<a href="https://i.stack.imgur.com/uhBKy.jpg" rel="noreferrer">1</a></p>
0debug
void OPPROTO op_decl_ECX(void) { ECX = (uint32_t)(ECX - 1); }
1threat
Easy jQuery issue : <p>If I have a table where a td has a class called "clicky" with the following jQuery code:</p> <pre><code>$(".clicky").click(function() { var td = $(this); $.post("http://URL/file.php", {val:value}) .done(function(data) { $(td).empty().append("hello"); }); }); </code></pre> <p>How can I replace the HTML in the td that was clicked with the HTML code returned in the data variable? I do not individually name my TDs, so I cannot reference it directly.</p> <p>Simply using $(this).innerHTML() seems to be out of scope or dysfunctional...</p>
0debug
C# how to remove the last index of an array and store it as a character : <p>i have a character array, I would like to remove the last index and store it as a separate character name checkDigit</p>
0debug
static inline uint16_t mipsdsp_sat16_sub(int16_t a, int16_t b, CPUMIPSState *env) { int16_t temp; temp = a - b; if (MIPSDSP_OVERFLOW(a, -b, temp, 0x8000)) { if (a > 0) { temp = 0x7FFF; } else { temp = 0x8000; } set_DSPControl_overflow_flag(1, 20, env); } return temp; }
1threat
static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr) { int sign, code; int pred, extquant; int extrabits = 0; int16_t *dc_val; pred = ff_msmpeg4_pred_dc(s, n, &dc_val, dir_ptr); if (n < 4) { *dc_val = level * s->y_dc_scale; } else { *dc_val = level * s->c_dc_scale; } level -= pred; if(s->msmpeg4_version<=2){ if (n < 4) { put_bits(&s->pb, ff_v2_dc_lum_table[level + 256][1], ff_v2_dc_lum_table[level + 256][0]); }else{ put_bits(&s->pb, ff_v2_dc_chroma_table[level + 256][1], ff_v2_dc_chroma_table[level + 256][0]); } }else{ sign = 0; if (level < 0) { level = -level; sign = 1; } code = level; if (code > DC_MAX) code = DC_MAX; else if( s->msmpeg4_version>=6 ) { if( s->qscale == 1 ) { extquant = (level + 3) & 0x3; code = ((level+3)>>2); } else if( s->qscale == 2 ) { extquant = (level + 1) & 0x1; code = ((level+1)>>1); } } if (s->dc_table_index == 0) { if (n < 4) { put_bits(&s->pb, ff_table0_dc_lum[code][1], ff_table0_dc_lum[code][0]); } else { put_bits(&s->pb, ff_table0_dc_chroma[code][1], ff_table0_dc_chroma[code][0]); } } else { if (n < 4) { put_bits(&s->pb, ff_table1_dc_lum[code][1], ff_table1_dc_lum[code][0]); } else { put_bits(&s->pb, ff_table1_dc_chroma[code][1], ff_table1_dc_chroma[code][0]); } } if(s->msmpeg4_version>=6 && s->qscale<=2) extrabits = 3 - s->qscale; if (code == DC_MAX) put_bits(&s->pb, 8 + extrabits, level); else if(extrabits > 0) put_bits(&s->pb, extrabits, extquant); if (level != 0) { put_bits(&s->pb, 1, sign); } } }
1threat
bash won't enter to else : <p>I have this code that expects string from the end user:</p> <pre><code>#!/bin/bash echo "You are about to deploy the site from STAGING to PRODUCTION, Are you sure? yes/no "; read continue if (( "$continue" == "yes" )) ; then echo "Yes" else echo "No" fi </code></pre> <p>The problem is that the else will never be.</p> <p>Thanks</p>
0debug
Multiply int in array list OCAML : Hi I'm trying to solve this problem in OCAML: I have two arrays of variable size like [1;4;5] [3;2;3] that rappresent TWO integer: 145 and 323. I would to multiply this two number (145*323). The result (46835) I want to rappresent how [4;6;8;3;5]. Can you help me please?
0debug
How do I center text vertically and horizontally in Flutter? : <p>I'd like to know how to center the contents a Text widget vertically and horizontally in Flutter. I only know how to center the widget itself using <code>Center(child: Text("test"))</code> but not the content itself, it's by default left aligned. In Android, I believe the property of a TextView that achieves this is called <code>gravity</code>.</p> <p>Example of what I want:</p> <p><a href="https://i.stack.imgur.com/mRIob.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mRIob.png" alt="centered text example"></a></p>
0debug
static av_cold int alac_encode_close(AVCodecContext *avctx) { AlacEncodeContext *s = avctx->priv_data; ff_lpc_end(&s->lpc_ctx); av_freep(&avctx->extradata); avctx->extradata_size = 0; av_freep(&avctx->coded_frame); return 0; }
1threat
pvscsi_ring_init_msg(PVSCSIRingInfo *m, PVSCSICmdDescSetupMsgRing *ri) { int i; uint32_t len_log2; uint32_t ring_size; if (ri->numPages > PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES) { return -1; } ring_size = ri->numPages * PVSCSI_MAX_NUM_MSG_ENTRIES_PER_PAGE; len_log2 = pvscsi_log2(ring_size - 1); m->msg_len_mask = MASK(len_log2); m->filled_msg_ptr = 0; for (i = 0; i < ri->numPages; i++) { m->msg_ring_pages_pa[i] = ri->ringPPNs[i] << VMW_PAGE_SHIFT; } RS_SET_FIELD(m, msgProdIdx, 0); RS_SET_FIELD(m, msgConsIdx, 0); RS_SET_FIELD(m, msgNumEntriesLog2, len_log2); trace_pvscsi_ring_init_msg(len_log2); smp_wmb(); return 0; }
1threat
static void qmp_input_start_struct(Visitor *v, const char *name, void **obj, size_t size, Error **errp) { QmpInputVisitor *qiv = to_qiv(v); QObject *qobj = qmp_input_get_object(qiv, name, true, errp); Error *err = NULL; if (obj) { *obj = NULL; } if (!qobj) { return; } if (qobject_type(qobj) != QTYPE_QDICT) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", "QDict"); return; } qmp_input_push(qiv, qobj, obj, &err); if (err) { error_propagate(errp, err); return; } if (obj) { *obj = g_malloc0(size); } }
1threat
static Suite *QList_suite(void) { Suite *s; TCase *qlist_public_tcase; s = suite_create("QList suite"); qlist_public_tcase = tcase_create("Public Interface"); suite_add_tcase(s, qlist_public_tcase); tcase_add_test(qlist_public_tcase, qlist_new_test); tcase_add_test(qlist_public_tcase, qlist_append_test); tcase_add_test(qlist_public_tcase, qobject_to_qlist_test); tcase_add_test(qlist_public_tcase, qlist_destroy_test); tcase_add_test(qlist_public_tcase, qlist_iter_test); return s; }
1threat
void arm_load_kernel(CPUState *env, struct arm_boot_info *info) { int kernel_size; int initrd_size; int n; int is_linux = 0; uint64_t elf_entry; target_phys_addr_t entry; int big_endian; if (!info->kernel_filename) { fprintf(stderr, "Kernel image must be specified\n"); exit(1); } if (!info->secondary_cpu_reset_hook) { info->secondary_cpu_reset_hook = default_reset_secondary; } if (!info->write_secondary_boot) { info->write_secondary_boot = default_write_secondary; } if (info->nb_cpus == 0) info->nb_cpus = 1; #ifdef TARGET_WORDS_BIGENDIAN big_endian = 1; #else big_endian = 0; #endif kernel_size = load_elf(info->kernel_filename, NULL, NULL, &elf_entry, NULL, NULL, big_endian, ELF_MACHINE, 1); entry = elf_entry; if (kernel_size < 0) { kernel_size = load_uimage(info->kernel_filename, &entry, NULL, &is_linux); } if (kernel_size < 0) { entry = info->loader_start + KERNEL_LOAD_ADDR; kernel_size = load_image_targphys(info->kernel_filename, entry, ram_size - KERNEL_LOAD_ADDR); is_linux = 1; } if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", info->kernel_filename); exit(1); } info->entry = entry; if (is_linux) { if (info->initrd_filename) { initrd_size = load_image_targphys(info->initrd_filename, info->loader_start + INITRD_LOAD_ADDR, ram_size - INITRD_LOAD_ADDR); if (initrd_size < 0) { fprintf(stderr, "qemu: could not load initrd '%s'\n", info->initrd_filename); exit(1); } } else { initrd_size = 0; } bootloader[1] |= info->board_id & 0xff; bootloader[2] |= (info->board_id >> 8) & 0xff; bootloader[5] = info->loader_start + KERNEL_ARGS_ADDR; bootloader[6] = entry; for (n = 0; n < sizeof(bootloader) / 4; n++) { bootloader[n] = tswap32(bootloader[n]); } rom_add_blob_fixed("bootloader", bootloader, sizeof(bootloader), info->loader_start); if (info->nb_cpus > 1) { info->write_secondary_boot(env, info); } info->initrd_size = initrd_size; } info->is_linux = is_linux; for (; env; env = env->next_cpu) { env->boot_info = info; qemu_register_reset(do_cpu_reset, env); } }
1threat
Why are the JCE Unlimited Strength not included by default? : <h2>Setup</h2> <ul> <li>Java doesn't offer out-of-the-box support for the JCE Unlimited Strength Policy Files</li> <li>This prevents users from using AES-256, the largest key size of a widely-used encryption standard</li> <li>Not including the policy files leads to many problems: <ul> <li><a href="https://stackoverflow.com/questions/6481627/java-security-illegal-key-size-or-default-parameters">Unexpected exceptions</a></li> <li><a href="https://stackoverflow.com/questions/1179672/how-to-avoid-installing-unlimited-strength-jce-policy-files-when-deploying-an">Unsatisfying workarounds</a>: <ul> <li>Just install them</li> <li>Use a different implementation</li> <li>Use reflection that may violate the Java License Agreement</li> </ul></li> <li><a href="https://stackoverflow.com/questions/5239974/java-jce-unlimited-strength-encryption-security-policy-files">Breakage after JRE updates</a></li> <li><a href="https://stackoverflow.com/questions/25320705/jce-unlimited-strength-installed-but-aes-256-is-not-supported">Confusion after installation</a></li> <li><a href="https://stackoverflow.com/search?q=%5Bjce%5D+unlimited">And more!</a></li> </ul></li> <li>All this noise leads to broken and/or buggy programs</li> </ul> <h2>Question</h2> <ul> <li>Why are these not provided and treated like a black sheep?</li> </ul>
0debug
int nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int bytes, BdrvRequestFlags flags) { NBDClientSession *client = nbd_get_client_session(bs); NBDRequest request = { .type = NBD_CMD_WRITE_ZEROES, .from = offset, .len = bytes, }; if (!(client->info.flags & NBD_FLAG_SEND_WRITE_ZEROES)) { return -ENOTSUP; } if (flags & BDRV_REQ_FUA) { assert(client->info.flags & NBD_FLAG_SEND_FUA); request.flags |= NBD_CMD_FLAG_FUA; } if (!(flags & BDRV_REQ_MAY_UNMAP)) { request.flags |= NBD_CMD_FLAG_NO_HOLE; } return nbd_co_request(bs, &request, NULL); }
1threat
int qcrypto_init(Error **errp) { int ret; ret = gnutls_global_init(); if (ret < 0) { error_setg(errp, "Unable to initialize GNUTLS library: %s", gnutls_strerror(ret)); return -1; } #ifdef DEBUG_GNUTLS gnutls_global_set_log_level(10); gnutls_global_set_log_function(qcrypto_gnutls_log); #endif #ifdef CONFIG_GNUTLS_GCRYPT if (!gcry_check_version(GCRYPT_VERSION)) { error_setg(errp, "Unable to initialize gcrypt"); return -1; } #ifdef QCRYPTO_INIT_GCRYPT_THREADS gcry_control(GCRYCTL_SET_THREAD_CBS, &qcrypto_gcrypt_thread_impl); #endif gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0); #endif return 0; }
1threat
Cluster autoscaler not downscaling : <p>I have a regional cluster set up in <strong>google kubernetes engine (GKE)</strong>. The node group is a single <strong>vm in each region (3 total)</strong>. I have a deployment with <strong>3 replicas minimum</strong> controlled by a HPA. The <strong>nodegroup is configured to be autoscaling</strong> (cluster autoscaling aka CA). The problem scenario:</p> <p>Update deployment image. Kubernetes automatically creates new pods and the CA identifies that a new node is needed. I now have 4. The old pods get removed when all new pods have started, which means I have the exact same CPU request as the minute before. But the after the 10 min maximum downscale time I still have 4 nodes.</p> <p>The CPU requests for the nodes is now:</p> <pre><code>CPU Requests CPU Limits Memory Requests Memory Limits ------------ ---------- --------------- ------------- 358m (38%) 138m (14%) 516896Ki (19%) 609056Ki (22%) -- CPU Requests CPU Limits Memory Requests Memory Limits ------------ ---------- --------------- ------------- 800m (85%) 0 (0%) 200Mi (7%) 300Mi (11%) -- CPU Requests CPU Limits Memory Requests Memory Limits ------------ ---------- --------------- ------------- 510m (54%) 100m (10%) 410Mi (15%) 770Mi (29%) -- CPU Requests CPU Limits Memory Requests Memory Limits ------------ ---------- --------------- ------------- 823m (87%) 158m (16%) 484Mi (18%) 894Mi (33%) </code></pre> <p>The 38% node is running:</p> <pre><code>Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits --------- ---- ------------ ---------- --------------- ------------- kube-system event-exporter-v0.1.9-5c8fb98cdb-8v48h 0 (0%) 0 (0%) 0 (0%) 0 (0%) kube-system fluentd-gcp-v2.0.17-q29t2 100m (10%) 0 (0%) 200Mi (7%) 300Mi (11%) kube-system heapster-v1.5.2-585f569d7f-886xx 138m (14%) 138m (14%) 301856Ki (11%) 301856Ki (11%) kube-system kube-dns-autoscaler-69c5cbdcdd-rk7sd 20m (2%) 0 (0%) 10Mi (0%) 0 (0%) kube-system kube-proxy-gke-production-cluster-default-pool-0fd62aac-7kls 100m (10%) 0 (0%) 0 (0%) 0 (0%) </code></pre> <p>I suspect it wont downscale because heapster or kube-dns-autoscaler. But the 85% pod contains:</p> <pre><code>Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits --------- ---- ------------ ---------- --------------- ------------- kube-system fluentd-gcp-v2.0.17-s25bk 100m (10%) 0 (0%) 200Mi (7%) 300Mi (11%) kube-system kube-proxy-gke-production-cluster-default-pool-7ffeacff-mh6p 100m (10%) 0 (0%) 0 (0%) 0 (0%) my-deploy my-deploy-54fc6b67cf-7nklb 300m (31%) 0 (0%) 0 (0%) 0 (0%) my-deploy my-deploy-54fc6b67cf-zl7mr 300m (31%) 0 (0%) 0 (0%) 0 (0%) </code></pre> <p>The fluentd and kube-proxy pods are present on every node, so I assume they are not needed without the node. Which means that my deployment could be relocated to the other nodes since it only has a request of 300m (31% since only 94% of node CPU is allocatable).</p> <p>So I figured that Ill check the logs. But if I run <code>kubectl get pods --all-namespaces</code> there are no pod visible on GKE for the CA. And if I use the command <code>kubectl get configmap cluster-autoscaler-status -n kube-system -o yaml</code> it only tells me if it is about to scale, not why or why not. Another option is to look at <code>/var/log/cluster-autoscaler.log</code> in the master node. I SSH:ed in the all 4 nodes and only found a <code>gcp-cluster-autoscaler.log.pos</code> file that says: <code>/var/log/cluster-autoscaler.log 0000000000000000 0000000000000000</code> meaning the file should be right there but is empty. Last option according to the <a href="https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md" rel="noreferrer">FAQ</a>, is to check the events for the pods, but as far as i can tell they are empty.</p> <p>Anyone know why it wont downscale or atleast where to find the logs?</p>
0debug
can you insert null value into date datatype in SQL (and if yes, how)? : I have been working on my SQL database for school project and i have a problem with my idea. I am doing a car service database (all made up) and i have a date data type for a collumn 'deadline' for a table 'order' (names for both in my language-'rok' and 'narocilo') and i am trying to insert null into some of rows where deadline isn't specified by the customer. <code>create table narocilo( id_narocila integer NOT null, opis varchar(50), cena integer, status varchar(20), datum_narocila date, rok date );</code> this is some ways i tried to insert null but none of them worked <code>to_date('dd-mm-yyyy', null) to_date(null) null to_date('null')</code> So, my question is, can i insert null into date column and if yes, how? Thank you in advance!
0debug
char* qdev_get_fw_dev_path(DeviceState *dev) { char path[128]; int l; l = qdev_get_fw_dev_path_helper(dev, path, 128); path[l-1] = '\0'; return strdup(path); }
1threat
static void tci_out_label(TCGContext *s, TCGArg arg) { TCGLabel *label = &s->labels[arg]; if (label->has_value) { tcg_out_i(s, label->u.value); assert(label->u.value); } else { tcg_out_reloc(s, s->code_ptr, sizeof(tcg_target_ulong), arg, 0); s->code_ptr += sizeof(tcg_target_ulong); } }
1threat
Why am i getting the wrong milliseconds for a given string? : DateFormat df1 = new SimpleDateFormat("kk:mm"); Date d = null; try { d = df1.parse("21:00"); } catch (ParseException e) { e.printStackTrace(); }
0debug
Matlab Error using .* Matrix dimensions must agree : I'm new in matlab, trying to apply high pass butterworth filter on my data images. I'm having this trouble, "Error using .* Matrix dimensions must agree." **Here's my code:** function[]=Preprocessing() I = imread('Photo0029.jpg'); imshow(I); imDouble=im2double(I); fftlogim=fft(log(imDouble+0.01)); f=butterhp(I,15,1); c=fftlogim.*f; h=real(ifft(c)); figure,ishow(h); h1=exp(h); ifftshow(h1); **and here's the butterhp function:-** function[out]=butterhp(im,d,n) h=size(im,1); w=size(im,2); [x,y]=meshgrid(-floor(w/2):floor(w-1)/2,-floor(h/2):floor(h-1)/2); out=1./(1.+(d./(x.^2+y.^2).^0.5).^(2*n)); end **Can anyone help me with this issue? I'll be grateful, Thanks in advance**
0debug
total price in label from Datagridvie c# : Here is calculation of the Total price in C# and I want to show the total price of products in the label [Like in an image below][1] **The row with the SalesForm.TotalPrice calculate total price** if (cbxProdTypeSwitch.SelectedIndex == 0) { //phones Smartphone ph = (Smartphone)dgvProds.SelectedRows[0].DataBoundItem; SalesForm.productName = ph.ProductName; SalesForm.price = ph.price; SalesForm.totalPrice = ph.price * Convert.ToInt32(nudAmount.Value); SalesForm.salesDate = DateTime.Now; SalesForm.amount = Convert.ToInt32(nudAmount.Value); SalesForm.clientName = tbxClient.Text; } [1]: https://i.stack.imgur.com/ofJia.png
0debug
Python while loop not working perfectly as expected : <pre><code>choice = " " while choice not 'Y' or choice not 'N' : choice = input("Y for Yes or N for No") </code></pre> <p>What is the mistake i have made in this while loop?</p>
0debug
onchange event handler exercise unclear : Im doing an exercise that is getting me used to onchange event handlers and arrays. I am having great trouble with what its asking me to do. Any help would greatly appreciated. Here is my code: document.getElementById('productID').onchange = function () { productID = this.value; iName = imageName[productID]; url = urlBase + iName; iPrice = imageName[productID]; document.getElementById('...').innerHTML = iPrice; }; Here are the instructions. 1. Handle the onchange event for the select list; id 'productID' 2. Get the productID of the selected fruit this way: productID = this.value; 3. Use parseInt() to ensure the productID value is a number. 4. Get the image name for the selected product by using productID to reference the array imageName this way: iName = imageName[productID]; 5. Combine urlBase + image's name to get the full url to the image. Do it this way: url = urlBase + iName; 6. Load url as the src for the <img> with id 'product image'. 7. Get the price of the product by using productID and the price array. Put the price of the product in the variable iPrice. Refer to #4 about how to do this. 8. Set the innerHTML of the span 'price display' to the price. Do it this way: document.getElementById('...').innerHTML = iPrice; Any help would be greatly appreciated. I am slowly learning more and more and I enjoy html a lot so far.
0debug
parameters from url using java and spring boot : I am using java and spring boot and i need to get information by a url and put them in my class java: my url is like that localhost:8080/send?adress=exempl. and i want to get just exemple in a variable java ?
0debug
int qemu_acl_insert(qemu_acl *acl, int deny, const char *match, int index) { qemu_acl_entry *entry; qemu_acl_entry *tmp; int i = 0; if (index <= 0) return -1; if (index > acl->nentries) { return qemu_acl_append(acl, deny, match); } entry = g_malloc(sizeof(*entry)); entry->match = g_strdup(match); entry->deny = deny; QTAILQ_FOREACH(tmp, &acl->entries, next) { i++; if (i == index) { QTAILQ_INSERT_BEFORE(tmp, entry, next); acl->nentries++; break; } } return i; }
1threat
int64_t qemu_file_get_rate_limit(QEMUFile *f) { return f->xfer_limit; }
1threat
Creating matrix by multiply columns (Python) : i want to create matrix as it is shown at pic: Creating new matrices by multiplying columns of matrix in elementwise Is it possible to create it without using 3 for loop? (https://i.stack.imgur.com/3TirY.jpg)
0debug
static bool blit_region_is_unsafe(struct CirrusVGAState *s, int32_t pitch, int32_t addr) { if (!pitch) { return true; } if (pitch < 0) { int64_t min = addr + ((int64_t)s->cirrus_blt_height-1) * pitch; int32_t max = addr + s->cirrus_blt_width; if (min < 0 || max > s->vga.vram_size) { return true; } } else { int64_t max = addr + ((int64_t)s->cirrus_blt_height-1) * pitch + s->cirrus_blt_width; if (max > s->vga.vram_size) { return true; } } return false; }
1threat
type hint for an instance of a non specific dataclass : <p>I have a function that accepts an instance of any <code>dataclass</code>. what would be an appropriate type hint for it ?</p> <p>haven't found something official in the python documentation </p> <hr> <p>this is what I have been doing, but i don't think it's correct</p> <pre><code>from typing import Any, NewType DataClass = NewType('DataClass', Any) def foo(obj: DataClass): ... </code></pre> <p>another idea is to use a <a href="https://www.python.org/dev/peps/pep-0544/#defining-a-protocol" rel="noreferrer"><code>Protocol</code></a> with these class attributes <code>__dataclass_fields__</code>, <code>__dataclass_params__</code>.</p>
0debug
I do not understand the template? can you help me? : <p>create a template function to exchange values ​​stored in the two variables that are passed to that function as arguments</p>
0debug
Making it so the first time you run the app you have to put in a code that can only be used once : <p>In trying to make a app and the first time you run it you would need to put in a code thats 12 digits I would have maybe 10000 diffrent codes but when someone uses a code it can not be used again PS: The app is for android</p>
0debug
static av_cold int gif_encode_init(AVCodecContext *avctx) { GIFContext *s = avctx->priv_data; if (avctx->width > 65535 || avctx->height > 65535) { av_log(avctx, AV_LOG_ERROR, "GIF does not support resolutions above 65535x65535\n"); return AVERROR(EINVAL); } #if FF_API_CODED_FRAME FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; FF_ENABLE_DEPRECATION_WARNINGS #endif s->transparent_index = -1; s->lzw = av_mallocz(ff_lzw_encode_state_size); s->buf = av_malloc(avctx->width*avctx->height*2); s->tmpl = av_malloc(avctx->width); if (!s->tmpl || !s->buf || !s->lzw) return AVERROR(ENOMEM); if (avpriv_set_systematic_pal2(s->palette, avctx->pix_fmt) < 0) av_assert0(avctx->pix_fmt == AV_PIX_FMT_PAL8); return 0; }
1threat
why string concatenation giving me error in this code? : <p>Basically I am writing a code to calculate CRC-16(modbus) value.</p> <p>I have a frame which I pass to my crc calculator method.It works fine when I define my input string as a whole frame.But when I use two string and then concatenate them into one then i get error!I will put my code here to show what is giving me error.I can't understand why it is giving me error when I use string concatenation.I used one texbox and one button to display calculated CRC value.Please help.Thank you.</p> <pre><code> using System; using System.ComponentModel; using System.Text; using System.Windows.Forms; using System.IO; namespace crccalculator1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void button5_Click(object sender, EventArgs e) { String frameValue = 5000;//value to covert to hex int decimalNumber, quotient; int i = 1, j, temp = 0,p=0,y=0; char[] hexadecimalNumber = new char[100]; char temp1; char[] chg = new char[100]; decimalNumber = int.Parse(frameValue); quotient = decimalNumber; while (quotient != 0) { temp = quotient % 16; if (temp &lt; 10) temp = temp + 48; else temp = temp + 55; temp1 = Convert.ToChar(temp); chg[p] = temp1; p++; hexadecimalNumber[i++] = temp1; quotient = quotient / 16; } for (j = i - 1; j &gt; 0; j--) { chg[y] = hexadecimalNumber[j]; y++; } string value = new string(chg);//here I get my hex value //string frame = "01060008"+value; // METHOD I TRIED ALSO DOES NOT WORK //string wholeframe = "010600081388" works!! // string gg = string.Concat("01060008", value); // METHOD I TRIED ALSO WHICH IS NOT WORKING! StringBuilder builder = new StringBuilder(); builder.Append("01060008"); builder.Append(value); string x = builder.ToString(); //GIVES ME WHOLE FRAME var bytes = HexToBytes(x); string hex = Crc16.ComputeCrc(bytes).ToString("X4"); textBox1.Text = hex; } static byte[] HexToBytes(string input) { byte[] result = new byte[input.Length / 2]; for (int i = 0; i &lt; result.Length; i++) { result[i] = Convert.ToByte(input.Substring(2 * i, 2), 16);//HERE I AM GETTING ERROR !! as An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll } return result; } public class Crc16 { private static ushort[] CrcTable = { 0X0000, 0XC0C1, 0XC181, 0X0140, 0XC301, 0X03C0, 0X0280, 0XC241, 0XC601, 0X06C0, 0X0780, 0XC741, 0X0500, 0XC5C1, 0XC481, 0X0440, 0XCC01, 0X0CC0, 0X0D80, 0XCD41, 0X0F00, 0XCFC1, 0XCE81, 0X0E40, 0X0A00, 0XCAC1, 0XCB81, 0X0B40, 0XC901, 0X09C0, 0X0880, 0XC841, 0XD801, 0X18C0, 0X1980, 0XD941, 0X1B00, 0XDBC1, 0XDA81, 0X1A40, 0X1E00, 0XDEC1, 0XDF81, 0X1F40, 0XDD01, 0X1DC0, 0X1C80, 0XDC41, 0X1400, 0XD4C1, 0XD581, 0X1540, 0XD701, 0X17C0, 0X1680, 0XD641, 0XD201, 0X12C0, 0X1380, 0XD341, 0X1100, 0XD1C1, 0XD081, 0X1040, 0XF001, 0X30C0, 0X3180, 0XF141, 0X3300, 0XF3C1, 0XF281, 0X3240, 0X3600, 0XF6C1, 0XF781, 0X3740, 0XF501, 0X35C0, 0X3480, 0XF441, 0X3C00, 0XFCC1, 0XFD81, 0X3D40, 0XFF01, 0X3FC0, 0X3E80, 0XFE41, 0XFA01, 0X3AC0, 0X3B80, 0XFB41, 0X3900, 0XF9C1, 0XF881, 0X3840, 0X2800, 0XE8C1, 0XE981, 0X2940, 0XEB01, 0X2BC0, 0X2A80, 0XEA41, 0XEE01, 0X2EC0, 0X2F80, 0XEF41, 0X2D00, 0XEDC1, 0XEC81, 0X2C40, 0XE401, 0X24C0, 0X2580, 0XE541, 0X2700, 0XE7C1, 0XE681, 0X2640, 0X2200, 0XE2C1, 0XE381, 0X2340, 0XE101, 0X21C0, 0X2080, 0XE041, 0XA001, 0X60C0, 0X6180, 0XA141, 0X6300, 0XA3C1, 0XA281, 0X6240, 0X6600, 0XA6C1, 0XA781, 0X6740, 0XA501, 0X65C0, 0X6480, 0XA441, 0X6C00, 0XACC1, 0XAD81, 0X6D40, 0XAF01, 0X6FC0, 0X6E80, 0XAE41, 0XAA01, 0X6AC0, 0X6B80, 0XAB41, 0X6900, 0XA9C1, 0XA881, 0X6840, 0X7800, 0XB8C1, 0XB981, 0X7940, 0XBB01, 0X7BC0, 0X7A80, 0XBA41, 0XBE01, 0X7EC0, 0X7F80, 0XBF41, 0X7D00, 0XBDC1, 0XBC81, 0X7C40, 0XB401, 0X74C0, 0X7580, 0XB541, 0X7700, 0XB7C1, 0XB681, 0X7640, 0X7200, 0XB2C1, 0XB381, 0X7340, 0XB101, 0X71C0, 0X7080, 0XB041, 0X5000, 0X90C1, 0X9181, 0X5140, 0X9301, 0X53C0, 0X5280, 0X9241, 0X9601, 0X56C0, 0X5780, 0X9741, 0X5500, 0X95C1, 0X9481, 0X5440, 0X9C01, 0X5CC0, 0X5D80, 0X9D41, 0X5F00, 0X9FC1, 0X9E81, 0X5E40, 0X5A00, 0X9AC1, 0X9B81, 0X5B40, 0X9901, 0X59C0, 0X5880, 0X9841, 0X8801, 0X48C0, 0X4980, 0X8941, 0X4B00, 0X8BC1, 0X8A81, 0X4A40, 0X4E00, 0X8EC1, 0X8F81, 0X4F40, 0X8D01, 0X4DC0, 0X4C80, 0X8C41, 0X4400, 0X84C1, 0X8581, 0X4540, 0X8701, 0X47C0, 0X4680, 0X8641, 0X8201, 0X42C0, 0X4380, 0X8341, 0X4100, 0X81C1, 0X8081, 0X4040 }; public static UInt16 ComputeCrc(byte[] data) { ushort crc = 0xFFFF; foreach (byte datum in data) { crc = (ushort)((crc &gt;&gt; 8) ^ CrcTable[(crc ^ datum) &amp; 0xFF]); } return crc; } } </code></pre>
0debug
How to exclude classes from the coverage calculation in EclEmma without actually excluding them from the coverage itself : <p>I am using EclEmma to test the coverage of my scenario tests and use case tests on my project. I have a Base package which contains the most general classes and the use case tests. The coverage looks like this:</p> <p><a href="https://i.stack.imgur.com/U1mJI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/U1mJI.png" alt="Code coverage in our project"></a></p> <p>What I want is to exclude the use case tests (e.g. BugReportTest) from the coverage calculation. But I do want the tests inside it to be considered. I know how to exclude the entire class from the coverage but if I do that, my coverage % drops because the actual tests that check which lines of my code are tested are forgotten. These use case tests do need to stay in the Base package because of privacy reasons.</p>
0debug
static inline void RENAME(yuv2nv12X)(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize, uint8_t *dest, uint8_t *uDest, int dstW, int chrDstW, enum PixelFormat dstFormat) { yuv2nv12XinC(lumFilter, lumSrc, lumFilterSize, chrFilter, chrSrc, chrFilterSize, dest, uDest, dstW, chrDstW, dstFormat); }
1threat
my C program doesnt work the way its supposed to : I made this program but it doesnt work. You enter two numbers. Then you press + or -. If you press + it should add the numbers. If you press - it should subtract. But that part doesnt work. ``` #include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char *argv[]) { char opt; int a,b,s; scanf("%d",&a); scanf("%c\n",&opt); scanf("%d",&b); if(opt=='+') { //this part doesnt work s=a+b; } else if(opt=='-') { s=a-b; } printf("%d",s); return 0; } ``` What should i do?
0debug
Center page content margin: 0 auto; not working? : <p>I am trying to centre the content on this page <a href="http://www.seoweather.com/google-cache-search/" rel="nofollow noreferrer">http://www.seoweather.com/google-cache-search/</a></p> <p>I tried adding the below but no luck.</p> <pre><code>.container_24 .grid_24 { margin: 0 auto; } </code></pre> <p>As I understand, if the margins are set to margin: 0 auto; and the width is defined which it is as per below, it should center?</p> <pre><code>.container_24 .grid_24 { width: 960px; } </code></pre> <p>I'm obviously going wrong somewhere, please enlighten me :)</p>
0debug
Google Firebase signin giving status 12501 (not working), in release build variant and jks SHA : <p><strong>I know this question has been asked by many and have been answered.</strong></p> <p>So, why am I asking this question again? Cuz I tried those solutions, and I did followed Google docs, followed tutorials and youtube. Still no luck.</p> <p>Oright, this is what I did in my project.</p> <p><strong>Project:</strong> GoogleSignIn</p> <pre><code>dependencies { classpath 'com.android.tools.build:gradle:2.2.0' classpath 'com.google.gms:google-services:3.0.0' } </code></pre> <p>Gradle (Module: app)</p> <pre><code>apply plugin: 'com.android.application' android { signingConfigs { config { keyAlias 'alias' keyPassword 'keypass' storeFile file('/home/reoxey/path/to/jks') storePassword 'storepass' } } compileSdkVersion 25 buildToolsVersion "25.0.0" defaultConfig { applicationId "reoxey.com.googlesignin" minSdkVersion 19 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { signingConfig signingConfigs.config } } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.0.0' compile 'com.android.support:design:25.0.0' compile 'com.google.firebase:firebase-auth:9.8.0' compile 'com.google.android.gms:play-services-auth:9.8.0' testCompile 'junit:junit:4.12' } apply plugin: 'com.google.gms.google-services' </code></pre> <p>LoginActivity.java</p> <pre><code>gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.web_client_key)) .requestEmail() .build(); mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this, this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); findViewById(R.id.sign_in_button).setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient); startActivityForResult(signInIntent, RC_SIGN_IN); } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RC_SIGN_IN){ GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); if (result.isSuccess()){ Toast.makeText(getApplicationContext(),"Nailed it",Toast.LENGTH_LONG).show(); }else { Snackbar.make(mLoginFormView,result.getStatus().toString(),Snackbar.LENGTH_LONG).show(); Toast.makeText(getApplicationContext(),"Messed",Toast.LENGTH_LONG).show(); } } } </code></pre> <p>string.xml</p> <pre><code>&lt;string name="web_client_key"&gt;123456789-clientwebapplication.apps.googleusercontent.com&lt;/string&gt; </code></pre> <p>There is no special configuration in manifest, and I believe that I am not missing anything there.</p> <p>google-services.json</p> <pre><code>{ "project_info": { "project_number": "{numeric-id}", "firebase_url": "https://project--123456789.firebaseio.com", "project_id": "project--123456789", "storage_bucket": "project--123456789.appspot.com" }, "client": [ { "client_info": { "mobilesdk_app_id": "1:{numeric-id}:android:sfdjgsdkdfgsfs", "android_client_info": { "package_name": "reoxey.com.googlesignin" } }, "oauth_client": [ { "client_id": "{numeric-id}-androidkey.apps.googleusercontent.com", "client_type": 1, "android_info": { "package_name": "reoxey.com.googlesignin", "certificate_hash": "{sha1-from-jks-file}" } }, { "client_id": "{numeric-id}-webapplication.apps.googleusercontent.com", "client_type": 3 } ], "api_key": [ { "current_key": "{android-key}" } ], "services": { "analytics_service": { "status": 1 }, "appinvite_service": { "status": 2, "other_platform_oauth_client": [ { "client_id": "{numeric-id}-webapplication.apps.googleusercontent.com", "client_type": 3 } ] }, "ads_service": { "status": 2 } } } ], "configuration_version": "1" } </code></pre> <p>Oright, now Firebase console.</p> <ul> <li><strong>created project with package name</strong></li> <li><strong>added sha1 fingerprint generated from jks file</strong></li> <li><strong>enabled authentication for google signin</strong></li> </ul> <p>that's it I guess, hope I provided everything,<br> so what am I missing here.</p> <p>When I click on google sign, it gives me an error with <strong>12501</strong> status code. I don't know what's wrong here. Anyone? </p> <p>Thanks in Advance.</p>
0debug
Uncaught (in promise): TypeError: Cannot read property 'component' of null : <p>Getting this error when trying to use nestet route in Angular 4:</p> <pre><code>ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'component' of null TypeError: Cannot read property 'component' of null at PreActivation.webpackJsonp.../../../router/@angular/router.es5.js.PreActivation.traverseRoutes (http://localhost:4200/vendor.bundle.js:77976:71) at http://localhost:4200/vendor.bundle.js:77954:19 at Array.forEach (native) at PreActivation.webpackJsonp.../../../router/@angular/router.es5.js.PreActivation.traverseChildRoutes (http://localhost:4200/vendor.bundle.js:77953:29) at PreActivation.webpackJsonp.../../../router/@angular/router.es5.js.PreActivation.traverseRoutes (http://localhost:4200/vendor.bundle.js:77985:22) </code></pre> <p>This is my routing code:</p> <pre><code>const appRoutes: Routes = [ { path: '', component: HomeComponent }, { path: 'sobre', component: SobreComponent }, { path: 'c/:concurso', component: ConcursoItemComponent , children: [ { path: ':cargo', component: CargoItemComponent, children: [ { path: ':disc', component: DisciplinaItemComponent, children: [{ path: ':assunto', component: AssuntoItemComponent }] } ] } ] }, ]; </code></pre> <p>I want to make the following nested rules, each one using the variables to inform the nested components of each route:</p> <p>/</p> <p>/c/:concurso/</p> <p>/c/:concurso/:cargo/</p> <p>/c/:concurso/:cargo/:disc/</p> <p>/c/:concurso/:cargo/:disc/:assunto</p> <p>On each level, I will need all the upper variables to make the correct querying of the related objects of the API.</p> <p>Thanks for any help!</p>
0debug
bool gs_allowed(void) { return get_machine_class()->gs_allowed; }
1threat
static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id) { VirtIOBalloon *s = opaque; if (version_id != 1) return -EINVAL; virtio_load(&s->vdev, f); s->num_pages = qemu_get_be32(f); s->actual = qemu_get_be32(f); qemu_get_buffer(f, (uint8_t *)&s->stats_vq_elem, sizeof(VirtQueueElement)); qemu_get_buffer(f, (uint8_t *)&s->stats_vq_offset, sizeof(size_t)); qemu_get_buffer(f, (uint8_t *)&s->stats_callback, sizeof(MonitorCompletion)); qemu_get_buffer(f, (uint8_t *)&s->stats_opaque_callback_data, sizeof(void)); return 0; }
1threat
static int64_t cvtnum(const char *s) { char *end; return qemu_strtosz_suffix(s, &end, QEMU_STRTOSZ_DEFSUFFIX_B); }
1threat
New build disappears after uploading it to iTunes Connect : <p>I'm trying to upload a build to iTunesConnect with Xcode 8. Xcode shows me that the uploading is successful. In Activity tab of iTunesConnect I see that my build is appears and it's marked as "processing...". But after a few minutes this build disappears and I cannot find it anywhere. I tried to upload it again by Xcode 8, but it says the build is already uploaded to iTunesConnect. So when I tried to upload build with increased version it says OK, but I still cannot see the build in iTunesConnect. I tried to upload with Application Loader, but there is the same issue.</p>
0debug
static void colored_fputs(int level, const char *str) { if (!*str) return; if (use_color < 0) { #if HAVE_SETCONSOLETEXTATTRIBUTE CONSOLE_SCREEN_BUFFER_INFO con_info; con = GetStdHandle(STD_ERROR_HANDLE); use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR") && !getenv("AV_LOG_FORCE_NOCOLOR"); if (use_color) { GetConsoleScreenBufferInfo(con, &con_info); attr_orig = con_info.wAttributes; background = attr_orig & 0xF0; } #elif HAVE_ISATTY use_color = !getenv("NO_COLOR") && !getenv("AV_LOG_FORCE_NOCOLOR") && (getenv("TERM") && isatty(2) || getenv("AV_LOG_FORCE_COLOR")); if (getenv("AV_LOG_FORCE_256COLOR")) use_color *= 256; #else use_color = getenv("AV_LOG_FORCE_COLOR") && !getenv("NO_COLOR") && !getenv("AV_LOG_FORCE_NOCOLOR"); #endif } #if HAVE_SETCONSOLETEXTATTRIBUTE if (use_color && level != AV_LOG_INFO/8) SetConsoleTextAttribute(con, background | color[level]); fputs(str, stderr); if (use_color && level != AV_LOG_INFO/8) SetConsoleTextAttribute(con, attr_orig); #else if (use_color == 1 && level != AV_LOG_INFO/8) { fprintf(stderr, "\033[%d;3%dm%s\033[0m", (color[level] >> 4) & 15, color[level] & 15, str); } else if (use_color == 256 && level != AV_LOG_INFO/8) { fprintf(stderr, "\033[48;5;%dm\033[38;5;%dm%s\033[0m", (color[level] >> 16) & 0xff, (color[level] >> 8) & 0xff, str); } else fputs(str, stderr); #endif }
1threat
I am getting this error "your cpu doesn't support vt-x or svm, android studio 2.1.1 in AMD 6300 processor" : <p>I have enabled the virtualization in bios setup but when i try to launch the emulator i am getting the error "your cpu doesn't support vt-x or svm"</p> <p>I have installed Intel haxm too.</p>
0debug
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) { ImgUtils imgutils = { &imgutils_class, log_offset, log_ctx }; if ((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8) return 0; av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", w, h); return AVERROR(EINVAL); }
1threat
refer to the month and year in postgresql : Hi all I'm trying to pass a script that is in mysql to PostgrSQL, but there is a sentancia this in mysql that generates me problems is this: $q1="select * from noticias where month(fecha)='".$elmes."' and year(fecha)='".$elanio."'"; I get the following error: > Warning: pg_query(): Query failed: ERROR: no existe la función > month(date) LINE 1: select * from noticias where month(fecha)='03' and > year(fech... ^ HINT: Ninguna función coincide en el nombre y tipos de > argumentos. Puede ser necesario agregar conversión explícita de > tipos. in C:\xampp\htdocs\calendario\index.php on line 131 How do you see the month and year with postgresql?
0debug
BigQuery: Pageviews, Sessions, Users by differents sources, medium, campaigns : <p>What is the query for Pageviews, Sessions, Users by differents sources, medium, campaigns?</p>
0debug
CNCopyCurrentNetworkInfo with iOS 13 : <p>Apple changed some things regarding WiFi with iOS 13. If you want to use CNCopyCurrentNetworkInfo your app needs to have one of the following</p> <ul> <li>Apps with permission to access location</li> <li>Your app is the currently enabled VPN app</li> <li>Your app configured the WiFi network the device is currently using via NEHotspotConfiguration</li> </ul> <p>Source: WWDC 19 session 713</p> <p>I am configuring a network using NEHotspotConfiguration but I can not get the current SSID anymore after doing so. </p> <p>The following code worked fine with iOS 12:</p> <pre><code>/// retrieve the current SSID from a connected Wifi network private func retrieveCurrentSSID() -&gt; String? { let interfaces = CNCopySupportedInterfaces() as? [String] let interface = interfaces? .compactMap { [weak self] in self?.retrieveInterfaceInfo(from: $0) } .first return interface } /// Retrieve information about a specific network interface private func retrieveInterfaceInfo(from interface: String) -&gt; String? { guard let interfaceInfo = CNCopyCurrentNetworkInfo(interface as CFString) as? [String: AnyObject], let ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String else { return nil } return ssid } </code></pre> <p>With iOS 13 <code>CNCopyCurrentNetworkInfo</code> always returns nil.</p> <p>My app has the Access WiFi Information Capability set.</p> <p>Thanks for your help!</p>
0debug
window.location.href = 'http://attack.com?user=' + user_input;
1threat
Local Storage not storing/retrieving value : <p>This is my code:</p> <pre><code> &lt;select name="category" id="category" value="category" class="form-control ddplaceholder" style="width:220px;font-size:18px;font-family:Roboto;" onchange="document.form.submit();"&gt; &lt;script&gt; var cat = localStorage.getItem('category'); localStorage.setItem('category', cat); &lt;/script&gt; &lt;option value="" disabled selected&gt;Select Category&lt;/option&gt; &lt;?php $sth = $conn-&gt;prepare('Select name From category'); $sth-&gt;execute(); $data = $sth-&gt;fetchAll(); foreach ($data as $row ){ if($row['name']!="") echo ' &lt;option id=\"CategoryName\" nameCategoryNameVendorName\" value="' .$row['name']. '"&gt;'.$row['name'].'&lt;/option&gt;'; } ?&gt; &lt;/select&gt; </code></pre> <p>I want the selected value of the drop down 'category' to be retrieved in the drop down even after the page is submitted by <code>onchange="document.form.submit();"</code>. Why isn't it happening?</p>
0debug
sorting a dictionary in descending order of (i) keys (ii) Values [IN PYTHON] : I have a dictionary: {1: 6, 2: 4, 3: 7} If I want to sort in in descending order of VALUES, I use: for w in sorted(dict_test, key=dict_test.get, reverse=True): print (w, dict_test[w]) What should I do for descending order of KEYS?
0debug
static int vp3_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; Vp3DecodeContext *s = avctx->priv_data; GetBitContext gb; int i; int ret; init_get_bits(&gb, buf, buf_size * 8); #if CONFIG_THEORA_DECODER if (s->theora && get_bits1(&gb)) { int type = get_bits(&gb, 7); skip_bits_long(&gb, 6*8); if (type == 0) { if (s->avctx->active_thread_type&FF_THREAD_FRAME) { av_log(avctx, AV_LOG_ERROR, "midstream reconfiguration with multithreading is unsupported, try -threads 1\n"); return AVERROR_PATCHWELCOME; } vp3_decode_end(avctx); ret = theora_decode_header(avctx, &gb); if (ret < 0) { vp3_decode_end(avctx); } else ret = vp3_decode_init(avctx); return ret; } else if (type == 2) { ret = theora_decode_tables(avctx, &gb); if (ret < 0) { vp3_decode_end(avctx); } else ret = vp3_decode_init(avctx); return ret; } av_log(avctx, AV_LOG_ERROR, "Header packet passed to frame decoder, skipping\n"); return -1; } #endif s->keyframe = !get_bits1(&gb); if (!s->all_fragments) { av_log(avctx, AV_LOG_ERROR, "Data packet without prior valid headers\n"); return -1; } if (!s->theora) skip_bits(&gb, 1); for (i = 0; i < 3; i++) s->last_qps[i] = s->qps[i]; s->nqps=0; do{ s->qps[s->nqps++]= get_bits(&gb, 6); } while(s->theora >= 0x030200 && s->nqps<3 && get_bits1(&gb)); for (i = s->nqps; i < 3; i++) s->qps[i] = -1; if (s->avctx->debug & FF_DEBUG_PICT_INFO) av_log(s->avctx, AV_LOG_INFO, " VP3 %sframe #%d: Q index = %d\n", s->keyframe?"key":"", avctx->frame_number+1, s->qps[0]); s->skip_loop_filter = !s->filter_limit_values[s->qps[0]] || avctx->skip_loop_filter >= (s->keyframe ? AVDISCARD_ALL : AVDISCARD_NONKEY); if (s->qps[0] != s->last_qps[0]) init_loop_filter(s); for (i = 0; i < s->nqps; i++) if (s->qps[i] != s->last_qps[i] || s->qps[0] != s->last_qps[0]) init_dequantizer(s, i); if (avctx->skip_frame >= AVDISCARD_NONKEY && !s->keyframe) return buf_size; s->current_frame.reference = 3; s->current_frame.pict_type = s->keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; s->current_frame.key_frame = s->keyframe; if (ff_thread_get_buffer(avctx, &s->current_frame) < 0) { av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); goto error; } if (!s->edge_emu_buffer) s->edge_emu_buffer = av_malloc(9*FFABS(s->current_frame.linesize[0])); if (s->keyframe) { if (!s->theora) { skip_bits(&gb, 4); skip_bits(&gb, 4); if (s->version) { s->version = get_bits(&gb, 5); if (avctx->frame_number == 0) av_log(s->avctx, AV_LOG_DEBUG, "VP version: %d\n", s->version); } } if (s->version || s->theora) { if (get_bits1(&gb)) av_log(s->avctx, AV_LOG_ERROR, "Warning, unsupported keyframe coding type?!\n"); skip_bits(&gb, 2); } } else { if (!s->golden_frame.data[0]) { av_log(s->avctx, AV_LOG_WARNING, "vp3: first frame not a keyframe\n"); s->golden_frame.reference = 3; s->golden_frame.pict_type = AV_PICTURE_TYPE_I; if (ff_thread_get_buffer(avctx, &s->golden_frame) < 0) { av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); goto error; } s->last_frame = s->golden_frame; s->last_frame.type = FF_BUFFER_TYPE_COPY; ff_thread_report_progress(&s->last_frame, INT_MAX, 0); } } memset(s->all_fragments, 0, s->fragment_count * sizeof(Vp3Fragment)); ff_thread_finish_setup(avctx); if (unpack_superblocks(s, &gb)){ av_log(s->avctx, AV_LOG_ERROR, "error in unpack_superblocks\n"); goto error; } if (unpack_modes(s, &gb)){ av_log(s->avctx, AV_LOG_ERROR, "error in unpack_modes\n"); goto error; } if (unpack_vectors(s, &gb)){ av_log(s->avctx, AV_LOG_ERROR, "error in unpack_vectors\n"); goto error; } if (unpack_block_qpis(s, &gb)){ av_log(s->avctx, AV_LOG_ERROR, "error in unpack_block_qpis\n"); goto error; } if (unpack_dct_coeffs(s, &gb)){ av_log(s->avctx, AV_LOG_ERROR, "error in unpack_dct_coeffs\n"); goto error; } for (i = 0; i < 3; i++) { int height = s->height >> (i && s->chroma_y_shift); if (s->flipped_image) s->data_offset[i] = 0; else s->data_offset[i] = (height-1) * s->current_frame.linesize[i]; } s->last_slice_end = 0; for (i = 0; i < s->c_superblock_height; i++) render_slice(s, i); for (i = 0; i < 3; i++) { int row = (s->height >> (3+(i && s->chroma_y_shift))) - 1; apply_loop_filter(s, i, row, row+1); } vp3_draw_horiz_band(s, s->avctx->height); *got_frame = 1; *(AVFrame*)data= s->current_frame; if (!HAVE_THREADS || !(s->avctx->active_thread_type&FF_THREAD_FRAME)) update_frames(avctx); return buf_size; error: ff_thread_report_progress(&s->current_frame, INT_MAX, 0); if (!HAVE_THREADS || !(s->avctx->active_thread_type&FF_THREAD_FRAME)) avctx->release_buffer(avctx, &s->current_frame); return -1; }
1threat
SQL that work on ORACLE and not work on DB2 : <p>I have an SQL that put the comma before house address number. This SQL work great on ORACLE but if I paste it in DB2 (vers. 7.2) is not work. </p> <pre><code>SELECT C, REGEXP_REPLACE(C,'(\s+\S*\d+\s*$)',',\1') FROM TABLE( VALUES ('VIA MILANO 123 '), ('VIA MILANO A123 '), ('VIA 11 MILANO AA123') ) AS T(C) </code></pre> <p>Is there anybody that can tell me why ? or if I can convert it please ? </p> <p>Thanks a lot Denis</p>
0debug
Google Play - Fully Shadowed apk : <p>I have an existing app on the PlayStore. I am releasing new version of the app as <strong>staged rollout</strong>. However, I am not able to publish the app due to "Fully Shadowed APK" error.</p> <p><a href="https://i.stack.imgur.com/XhhPS.png" rel="noreferrer"><img src="https://i.stack.imgur.com/XhhPS.png" alt="Fully shadowed APK error"></a></p> <p>So far, I haven't found any documentation as to how to resolve this error. Anyone else faced this?</p>
0debug
Websocket communication in a symfony project : <p>I want to send notification from server to browsers in a php symfony project. Is there a simple way to do this in symfony ?</p>
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
How to handle when VueJS computed properties return HTML code? : <p>I use <code>VueJS 2</code> to render and calculate form items. Now I need to show a number if a propertie is under 10, and I need show a text message if the propertie is over or equal 10.</p> <p>I use this code:</p> <pre><code>Vue.component('mycomponent', { template: '#mytemp', data: function() { // ... }, computed: { mycomputedprop: function() { if (this.model_a &lt; 10) { return '&lt;span class="numbervalue"&gt;' + this.model_a + '€&lt;/span&gt;'; } else { return '&lt;span class="textvalue"&gt;I\'ll contact you as soon as possible!&lt;/span&gt;'; } } } }); </code></pre> <p>I use this code to show the value:</p> <pre><code>&lt;div id="app"&gt; {{ mycomputedprop }} &lt;/div&gt; </code></pre> <p>The problem is: if I show this value it shows the HTML code as text, not as HTML. How can I show the returned value as a HTML code?</p>
0debug
how can Increase/Decrease Perticular Item quantity in Cart Functionality inside RecyclerView in android : I Have Working on a Cart Items Based Project. In which I have to Increase/Decrease Order item Quantity Two Button. EveryThing is Fine But on Perticular Item Increase/Decrease Value it cann't count from 1 .it can get Previous count Value. Here is My Recycler Adapter Code. Please Help me.enter image description here public class CheckOutAdapter extends RecyclerView.Adapter<CheckOutAdapter.MyVHolder> { ArrayList<CartModel> itemsList; Context context; OnItemClickListner mListner; int quantity; public CheckOutAdapter(ArrayList<CartModel> itemsList, Context context) { this.context = context; this.itemsList = itemsList; } @NonNull @Override public MyVHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.inflator_for_checkoutfrag, parent, false); return new MyVHolder(itemView); } @Override public void onBindViewHolder(@NonNull final MyVHolder holder, int position) { /*holder.catgry_txt_title.setText(itemsList.get(position).title); holder.catgry_img.setImageResource(itemsList.get(position).img);*/ holder.itemName.setText(itemsList.get(position).CartIteMname); holder.itemPartNo.setText(itemsList.get(position).cartItemno); holder.finalprice.setText(String.format("%s $", itemsList.get(position).totalprice)); Picasso.with(context).load(itemsList.get(position).carPart_imgURL).into(holder.itemIMG); quantity = Integer.parseInt(itemsList.get(position).cartQuantity); if (quantity == 1) { holder.txtQuantity.setText(String.valueOf(quantity)); } holder.btnIncrease.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //int count= Integer.parseInt(String.valueOf(holder.txtQuantity.getText())); quantity++; holder.txtQuantity.setText(String.valueOf(quantity)); } }); holder.btnDecrease.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int count= Integer.parseInt(String.valueOf(holder.txtQuantity.getText())); if (quantity>1) quantity--; holder.txtQuantity.setText(String.valueOf(quantity)); } }); } @Override public int getItemCount() { Log.e("adapterLSize",String.valueOf(itemsList.size())); return itemsList.size(); } class MyVHolder extends RecyclerView.ViewHolder { ImageView itemIMG, removeCart, btnIncrease, btnDecrease; TextView cartItemTitle, itemName, itemPartNo, finalprice, txtQuantity; LinearLayout addtoCart; MyVHolder(View itemView) { super(itemView); cartItemTitle = itemView.findViewById(R.id.cartItemTitle); itemName = itemView.findViewById(R.id.itemName); itemPartNo = itemView.findViewById(R.id.itemPartNo); finalprice = itemView.findViewById(R.id.finalprice); itemIMG = itemView.findViewById(R.id.itemIMG); txtQuantity = itemView.findViewById(R.id.txtQuantity); btnIncrease = itemView.findViewById(R.id.btnIncrease); btnDecrease = itemView.findViewById(R.id.btnDecrease); removeCart = itemView.findViewById(R.id.removeCart); } } }
0debug
The width of my Web page is 1680px. No matter how big the resolution of the other monitors is let the width of my Web page be same as 1680 px. : The width of my Web page is 1680px. No matter how big the resolution of the other monitors is (1920px, 2560px, 2880px,...), let the width of my Web page be same as 1680 px. I tried to make it by using "iframe", but problems occur. How can I do it using Jquery? [enter image description here][1] [1]: http://i.stack.imgur.com/KSglr.jpg
0debug
void FUNCC(ff_h264_idct8_add)(uint8_t *_dst, int16_t *_block, int stride){ int i; pixel *dst = (pixel*)_dst; dctcoef *block = (dctcoef*)_block; stride >>= sizeof(pixel)-1; block[0] += 32; for( i = 0; i < 8; i++ ) { const int a0 = block[i+0*8] + block[i+4*8]; const int a2 = block[i+0*8] - block[i+4*8]; const int a4 = (block[i+2*8]>>1) - block[i+6*8]; const int a6 = (block[i+6*8]>>1) + block[i+2*8]; const int b0 = a0 + a6; const int b2 = a2 + a4; const int b4 = a2 - a4; const int b6 = a0 - a6; const int a1 = -block[i+3*8] + block[i+5*8] - block[i+7*8] - (block[i+7*8]>>1); const int a3 = block[i+1*8] + block[i+7*8] - block[i+3*8] - (block[i+3*8]>>1); const int a5 = -block[i+1*8] + block[i+7*8] + block[i+5*8] + (block[i+5*8]>>1); const int a7 = block[i+3*8] + block[i+5*8] + block[i+1*8] + (block[i+1*8]>>1); const int b1 = (a7>>2) + a1; const int b3 = a3 + (a5>>2); const int b5 = (a3>>2) - a5; const int b7 = a7 - (a1>>2); block[i+0*8] = b0 + b7; block[i+7*8] = b0 - b7; block[i+1*8] = b2 + b5; block[i+6*8] = b2 - b5; block[i+2*8] = b4 + b3; block[i+5*8] = b4 - b3; block[i+3*8] = b6 + b1; block[i+4*8] = b6 - b1; } for( i = 0; i < 8; i++ ) { const int a0 = block[0+i*8] + block[4+i*8]; const int a2 = block[0+i*8] - block[4+i*8]; const int a4 = (block[2+i*8]>>1) - block[6+i*8]; const int a6 = (block[6+i*8]>>1) + block[2+i*8]; const int b0 = a0 + a6; const int b2 = a2 + a4; const int b4 = a2 - a4; const int b6 = a0 - a6; const int a1 = -block[3+i*8] + block[5+i*8] - block[7+i*8] - (block[7+i*8]>>1); const int a3 = block[1+i*8] + block[7+i*8] - block[3+i*8] - (block[3+i*8]>>1); const int a5 = -block[1+i*8] + block[7+i*8] + block[5+i*8] + (block[5+i*8]>>1); const int a7 = block[3+i*8] + block[5+i*8] + block[1+i*8] + (block[1+i*8]>>1); const int b1 = (a7>>2) + a1; const int b3 = a3 + (a5>>2); const int b5 = (a3>>2) - a5; const int b7 = a7 - (a1>>2); dst[i + 0*stride] = av_clip_pixel( dst[i + 0*stride] + ((b0 + b7) >> 6) ); dst[i + 1*stride] = av_clip_pixel( dst[i + 1*stride] + ((b2 + b5) >> 6) ); dst[i + 2*stride] = av_clip_pixel( dst[i + 2*stride] + ((b4 + b3) >> 6) ); dst[i + 3*stride] = av_clip_pixel( dst[i + 3*stride] + ((b6 + b1) >> 6) ); dst[i + 4*stride] = av_clip_pixel( dst[i + 4*stride] + ((b6 - b1) >> 6) ); dst[i + 5*stride] = av_clip_pixel( dst[i + 5*stride] + ((b4 - b3) >> 6) ); dst[i + 6*stride] = av_clip_pixel( dst[i + 6*stride] + ((b2 - b5) >> 6) ); dst[i + 7*stride] = av_clip_pixel( dst[i + 7*stride] + ((b0 - b7) >> 6) ); } memset(block, 0, 64 * sizeof(dctcoef)); }
1threat
static int nut_write_trailer(AVFormatContext *s) { NUTContext *nut = s->priv_data; ByteIOContext *bc = &s->pb; update_packetheader(nut, bc, 0); #if 0 int i; for (i = 0; s->nb_streams; i++) { put_be64(bc, INDEX_STARTCODE); put_packetheader(nut, bc, 64); put_v(bc, s->streams[i]->id); put_v(bc, ...); put_be32(bc, 0); update_packetheader(nut, bc, 0); } #endif put_flush_packet(bc); av_freep(&nut->stream); return 0; }
1threat
setup of collection view in horizontal format with an array of images in different cells : I have created a collection view and I want to set five cells with images in them. We can capture the images from camera. I want the cells to be kept like in the horizontal format. Here in the first image I add the imagePickerController to open the camera. [a cell with the did select action of opening camera][1] [each image captured should set in each cell like this!!!][2] [the 5th image should settle in place of the take photo cell!!!][3] Also, these above images are just a design of how I wanna set the collection view to look in the end. [1]: https://i.stack.imgur.com/aoaiT.png [2]: https://i.stack.imgur.com/ymCPC.png [3]: https://i.stack.imgur.com/Jw4Qh.png `import UIKit import AVKit class ViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UIImagePickerControllerDelegate, UINavigationControllerDelegate { // let reuseIdentifier = "cell" // also enter this string as the cell identifier in the storyboard var items: [UIImage] = [ UIImage(named: "user-icon")!, UIImage(named: "lock-icon")!, UIImage(named: "search.png")! ] var imgPicker = UIImagePickerController() // // // MARK: - UICollectionViewDataSource protocol // // // tell the collection view how many cells to make func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return self.items.count } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath as IndexPath) as! CollectionViewCell DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { print(self.items[indexPath.row]) } cell.imgPicker1.image = items[indexPath.row] return cell } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { return CGSize(width: 80, height: 80) } func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { } //MARK:- UI ImagePicker Delegate Methods func openCamera(){ if(UIImagePickerController .isSourceTypeAvailable(UIImagePickerController.SourceType.camera)) { let authStatus = AVCaptureDevice.authorizationStatus(for: .video) switch authStatus { case .authorized: showCamera() case .denied: let alert = UIAlertController(title: NSLocalizedString("Alert!", comment: "") + " \n" + NSLocalizedString("Please enable the Permission for Camera", comment: ""), message: NSLocalizedString("So that Group Icon can be set.", comment: ""), preferredStyle: .alert) alert.addAction(UIAlertAction(title: NSLocalizedString("Ok", comment: ""), style: .default) { action in self.openSettingToEnableNotification() }) self.present(alert, animated: true) case .notDetermined: AVCaptureDevice.requestAccess(for: AVMediaType.video, completionHandler: { (granted:Bool) -> Void in if granted { print("access granted", terminator: "") } else { print("access denied", terminator: "")} }) default: openSettingToEnableNotification() } } else { let alertController = UIAlertController(title: NSLocalizedString("Error", comment: ""), message: NSLocalizedString("Device has no camera", comment: ""), preferredStyle: .alert) let defaultAction = UIAlertAction(title: NSLocalizedString("Ok", comment: ""), style: .default, handler: { (alert) in }) alertController.addAction(defaultAction) present(alertController, animated: true, completion: nil) } } func openSettingToEnableNotification(){ UIApplication.shared.open(URL(string:UIApplication.openSettingsURLString)!) } func showCamera() {if(UIImagePickerController .isSourceTypeAvailable(UIImagePickerController.SourceType.camera)) { imgPicker.delegate = self imgPicker.sourceType = .camera //imgPicker.allowsEditing = true self.present(imgPicker, animated: true, completion: nil) } else { let alert = UIAlertController(title: NSLocalizedString("Warning", comment: ""), message: NSLocalizedString("You don't have camera", comment: ""), preferredStyle: .alert) alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: ""), style: .default, handler: nil)) self.present(alert, animated: true, completion: nil) } } // MARK: - UICollectionViewDelegate protocol func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { openCamera() } }`
0debug
How to reverse "?<=" in regexp : when I use: String s = "http://google.com, /home/roroco/Dropbox/jvs/ro-idea/META-INF/plugin.xml" ArrayList<String> ms = s.findAll(/(?<=\/)\/\S+/) println(ms) the output: [/google.com,] when I change to: s.findAll(/(?<!\/)\/\S+/) the output: [//google.com,, /home/roroco/Dropbox/jvs/ro-idea/META-INF/plugin.xml] In my understand, `/(?<!\/)\/\S+/` output should be same with `/(?<=\b)\/\S+/` output but in fact, i'm wrong, why?
0debug
Increase performance async Parallel.Foreach c# code : I have a deviceList of more than 10k items and want to send data by calling another method. I tried to use Parallel.Foreach but I'm not sure is this the correct way to do it. I have published this webapp on azure, I have tested this for 100 it works fine but for 10k it got timeout issue. Is my implementation need any tuning , thanks private List<Task> taskEventList = new List<Task>(); public async Task ProcessStart() { string messageData = "{"name":"DemoData","no":"111"}"; RegistryManager registryManager; Parallel.ForEach(deviceList, async (device) => { // get details for each device and use key to send message device = await registryManager.GetDeviceAsync(device.DeviceId); SendMessages(device.DeviceId, device.Key,messageData); }); if (taskEventList.Count > 0) { await Task.WhenAll(taskEventList); } } private void SendMessages(string deviceId, string Key,string messageData) { DeviceClient deviceClient = DeviceClient.Create(hostName, new DeviceAuthenticationWithRegistrySymmetricKey(deviceId, deviceKey), Microsoft.Azure.Devices.Client.TransportType.Mqtt); //created separate Task var taskEvents = Task.Run(() => ProcessMessages(deviceId, string messageData)); taskEventList.Add(taskEvents); } private async Task ProcessMessages(string deviceId, string messageData) { while (run 15 minutes) { await deviceClient.SendEventAsync(messageData); } }
0debug
void FUNCC(ff_h264_idct8_dc_add)(uint8_t *_dst, int16_t *block, int stride){ int i, j; int dc = (((dctcoef*)block)[0] + 32) >> 6; pixel *dst = (pixel*)_dst; stride >>= sizeof(pixel)-1; for( j = 0; j < 8; j++ ) { for( i = 0; i < 8; i++ ) dst[i] = av_clip_pixel( dst[i] + dc ); dst += stride; } }
1threat
static int pci_bridge_initfn(PCIDevice *dev) { PCIBridge *s = DO_UPCAST(PCIBridge, dev, dev); pci_config_set_vendor_id(s->dev.config, s->vid); pci_config_set_device_id(s->dev.config, s->did); s->dev.config[0x04] = 0x06; s->dev.config[0x05] = 0x00; s->dev.config[0x06] = 0xa0; s->dev.config[0x07] = 0x00; s->dev.config[0x08] = 0x00; s->dev.config[0x09] = 0x00; pci_config_set_class(s->dev.config, PCI_CLASS_BRIDGE_PCI); s->dev.config[0x0D] = 0x10; s->dev.config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_MULTI_FUNCTION | PCI_HEADER_TYPE_BRIDGE; s->dev.config[0x1E] = 0xa0; return 0; }
1threat
How index.html in Angular-CLI .NET Core is called? : <p>I have built an Angular-CLI .Net Core SPA with Visual Studio 2017 by using</p> <pre><code>dotnet new angular -o my-new-app </code></pre> <p>What I am struggling to find is how <code>index.html</code> which lies inside <code>ClientApp/src</code> folder is called by default when write e.g. </p> <pre><code>http://localhost:57782 </code></pre> <p><strong>startup.cs</strong> file has as follows:</p> <pre><code>using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.SpaServices.AngularCli; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace angular_cli { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //services.AddMvc(); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration =&gt; { configuration.RootPath = "ClientApp/dist"; }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseSpaStaticFiles(); //app.UseMvc(routes =&gt; //{ // routes.MapRoute( // name: "default", // template: "{controller}/{action=Index}/{id?}"); //}); app.UseSpa(spa =&gt; { // To learn more about options for serving an Angular SPA from ASP.NET Core, // see https://go.microsoft.com/fwlink/?linkid=864501 spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseAngularCliServer(npmScript: "start"); } }); } } } </code></pre> <p>On purpose, I have disabled MVC middleware and everything works fine. However, I have <code>no idea by which mechanism and settings index.html is called</code>... Any good explanations please?</p>
0debug
phpmyadmin Failed to set session cookie. Maybe you are using HTTP instead of HTTPS : <p>I install PHP, Apache, and MySQL done and worked. When I finish installing Phpmyadmin, then open it has an error.</p> <pre><code>Failed to set session cookie. Maybe you are using HTTP instead of HTTPS. </code></pre> <p>I don't know why. How can I fix this?</p>
0debug
What are the ways available for getting Database from SQL and display it in web page? : <ol> <li>I know JSP,PHP and ASP.Net are there apart from these what are the ways are there to get data from database. </li> <li>It is possible by using J query,Bootstrap and Angular JS. If any other way means suggest.</li> </ol>
0debug
Null pointer exception in setText : <p>I am trying to get name of a file using mediastore and display it in text view using <code>setText()</code> but <code>setText()</code> gives null pointer exception on running app. I am getting name from mediastore , saving it as string and passing the string to <code>setText()</code>. Can anyone help ? I am a beginner.</p> <pre><code>case R.id.action_properties: AlertDialog.Builder builder = new AlertDialog.Builder(PhotosActivity.this); LayoutInflater inflater = this.getLayoutInflater(); builder.setMessage("Properties"); builder.setView(R.layout.properties); String [] projection={MediaStore.Images.Media.DATA}; uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; cursor = getApplication().getContentResolver().query(uri, projection, null, null, null);// Order-by clause (ascending by name) int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); TextView displayname = (TextView) findViewById(R.id.displayname); displayname.setText(cursor.getString(column_index)); builder.setView(inflater.inflate(R.layout.properties, null)); builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog alert12 = builder.create(); alert12.show(); // location found return true; </code></pre> <p>LOGCAT :</p> <pre><code> java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference at com.example.dell_1.myapp3.ImageViewer.PhotosActivity.onOptionsItemSelected(PhotosActivity.java:302) at android.app.Activity.onMenuItemSelected(Activity.java:3245) at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:408) at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:195) at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:113) at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:113) at android.support.v7.app.ToolbarActionBar$2.onMenuItemClick(ToolbarActionBar.java:69) at android.support.v7.widget.Toolbar$1.onMenuItemClick(Toolbar.java:206) at android.support.v7.widget.ActionMenuView$MenuBuilderCallback.onMenuItemSelected(ActionMenuView.java:776) at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:822) at android.support.v7.view.menu.SubMenuBuilder.dispatchMenuItemSelected(SubMenuBuilder.java:88) at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:156) at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:969) at android.support.v7.view.menu.MenuPopup.onItemClick(MenuPopup.java:127) at android.widget.AdapterView.performItemClick(AdapterView.java:310) at android.widget.AbsListView.performItemClick(AbsListView.java:1155) at android.widget.AbsListView$PerformClick.run(AbsListView.java:3133) at android.widget.AbsListView$3.run(AbsListView.java:4048) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) </code></pre>
0debug
Visual Studio Code, Java Extension, howto add jar to classpath : <p>In Eclipse, I add a jar library using </p> <p>project -> build path ->configure build path</p> <p>What is the equivalent in VisualStudioCode? I had a look into launch.json. There is a classpath defined. Adding jars to this classpath (array) variable seems to have no effect. </p> <p>Essentially, this is a duplicate question of <a href="https://stackoverflow.com/questions/45282178/visual-studio-java-language-support-add-jar">Visual Studio Java Language Support add jar</a> But that question is unanswered. </p> <p>This is such an extremely basic question, that I really don't understand not to find a solution for it in Microsoft's documentation or via Google search.</p>
0debug
def remove_spaces(str1): str1 = str1.replace(' ','') return str1
0debug
How to make a button to press on Python 3 : <p>How would I make a button that would activate a program? Sort of like a video game. If you want to solve this question please take these requests into action. 1. It needs to be in <strong>Python 3</strong> 2.it needs to be fairly simple.</p> <p>Thanks</p>
0debug
static int vc1_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size) { VC1ParseContext *vpc = s->priv_data; int pic_found = vpc->pc.frame_start_found; uint8_t *unesc_buffer = vpc->unesc_buffer; size_t unesc_index = vpc->unesc_index; VC1ParseSearchState search_state = vpc->search_state; int start_code_found; int next = END_NOT_FOUND; int i = vpc->bytes_to_skip; if (pic_found && buf_size == 0) { memset(unesc_buffer + unesc_index, 0, UNESCAPED_THRESHOLD - unesc_index); vc1_extract_header(s, avctx, unesc_buffer, unesc_index); next = 0; } while (i < buf_size) { uint8_t b; start_code_found = 0; while (i < buf_size && unesc_index < UNESCAPED_THRESHOLD) { b = buf[i++]; unesc_buffer[unesc_index++] = b; if (search_state <= ONE_ZERO) search_state = b ? NO_MATCH : search_state + 1; else if (search_state == TWO_ZEROS) { if (b == 1) search_state = ONE; else if (b > 1) { if (b == 3) unesc_index--; search_state = NO_MATCH; } } else { search_state = NO_MATCH; start_code_found = 1; break; } } if ((s->flags & PARSER_FLAG_COMPLETE_FRAMES) && unesc_index >= UNESCAPED_THRESHOLD && vpc->prev_start_code == (VC1_CODE_FRAME & 0xFF)) { vc1_extract_header(s, avctx, unesc_buffer, unesc_index); break; } if (unesc_index >= UNESCAPED_THRESHOLD && !start_code_found) { while (i < buf_size) { if (search_state == NO_MATCH) { i += vpc->v.vc1dsp.startcode_find_candidate(buf + i, buf_size - i); if (i < buf_size) { search_state = ONE_ZERO; } i++; } else { b = buf[i++]; if (search_state == ONE_ZERO) search_state = b ? NO_MATCH : TWO_ZEROS; else if (search_state == TWO_ZEROS) { if (b >= 1) search_state = b == 1 ? ONE : NO_MATCH; } else { search_state = NO_MATCH; start_code_found = 1; break; } } } } if (start_code_found) { vc1_extract_header(s, avctx, unesc_buffer, unesc_index); vpc->prev_start_code = b; unesc_index = 0; if (!(s->flags & PARSER_FLAG_COMPLETE_FRAMES)) { if (!pic_found && (b == (VC1_CODE_FRAME & 0xFF) || b == (VC1_CODE_FIELD & 0xFF))) { pic_found = 1; } else if (pic_found && b != (VC1_CODE_FIELD & 0xFF) && b != (VC1_CODE_SLICE & 0xFF)) { next = i - 4; pic_found = b == (VC1_CODE_FRAME & 0xFF); break; } } } } vpc->pc.frame_start_found = pic_found; vpc->unesc_index = unesc_index; vpc->search_state = search_state; if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { next = buf_size; } else { if (ff_combine_frame(&vpc->pc, next, &buf, &buf_size) < 0) { vpc->bytes_to_skip = 0; *poutbuf = NULL; *poutbuf_size = 0; return buf_size; } } vpc->bytes_to_skip = 4; if (next < 0 && start_code_found) vpc->bytes_to_skip += next; *poutbuf = buf; *poutbuf_size = buf_size; return next; }
1threat
psycopg2.OperationalError: could not connect to server: Connection refused Is the server running on host "localhost" : <p>Got Error while doing docker-compose up.</p> <pre><code>conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError: could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5433? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5433? </code></pre> <p>docker-compose.yml:-</p> <pre><code>version: '3' services: dcs_web: build: . depends_on: - db ports: - "5000:5000" db: image: postgres:latest volumes: - db-data:/var/lib/postgresql/data ports: - "5433:5433" environment: - 'POSTGRES_DB:dcmDB' - 'POSTGRES_USER:postgres' - 'POSTGRES_PASSWORD:admin' volumes: db-data: </code></pre> <p>In App config.ini:</p> <pre><code>[DEFAULT] DB_NAME = user DB_PASSWORD = admin DB_USER = postgres DB_HOST = localhost DB_PORT = 5433 DEBUG = True </code></pre> <p>I have gone throught '/var/lib/postgresql/data' location 'listen adress = *' is there . Dont know how to deal with this.</p>
0debug
saving following array of object in a nodejs api : { "resourceID":"5963647f2bf14038f04d4f01", "privilegeID":["596363222bf14038f04d4efd","5963648b2bf14038f04d4f02","596364942bf14038f04d4f03","596364a02bf14038f04d4f04"] }
0debug
static int virtio_blk_pci_init(VirtIOPCIProxy *vpci_dev) { VirtIOBlkPCI *dev = VIRTIO_BLK_PCI(vpci_dev); DeviceState *vdev = DEVICE(&dev->vdev); virtio_blk_set_conf(vdev, &(dev->blk)); qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus)); if (qdev_init(vdev) < 0) { return -1; } return 0; }
1threat
Is there a way to overwrite log files in python 2.x : <p>I'm using python2.x logging module, like,</p> <pre><code>logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p', filename='logs.log', level=logging.INFO) </code></pre> <p>I want my program to overwrite logs.log file for each execution of the script, currently it just appends to old logs. I know the below code will overwrite, but if there is a way to do it via logging config, it'll look better.</p> <pre><code>with open("logs.log", 'w') as file: pass </code></pre>
0debug
thumb rule for using auto&& and const auto & : I have studied auto and I know it deduces types from initialized values. So if I try to write certain thumb rule for usage of auto, can I put below statements as rule- 1) Use auto && for all values (r-values and l-value, as It is universal ref)those are modifiable. 2)const auto & - for read only values. 3) Use auto wherever possible (individual preference for coding style)
0debug
static int tgv_decode_inter(TgvContext *s, AVFrame *frame, const uint8_t *buf, const uint8_t *buf_end) { int num_mvs; int num_blocks_raw; int num_blocks_packed; int vector_bits; int i,j,x,y; GetBitContext gb; int mvbits; const uint8_t *blocks_raw; if(buf_end - buf < 12) return AVERROR_INVALIDDATA; num_mvs = AV_RL16(&buf[0]); num_blocks_raw = AV_RL16(&buf[2]); num_blocks_packed = AV_RL16(&buf[4]); vector_bits = AV_RL16(&buf[6]); buf += 12; if (vector_bits > MIN_CACHE_BITS || !vector_bits) { av_log(s->avctx, AV_LOG_ERROR, "Invalid value for motion vector bits: %d\n", vector_bits); return AVERROR_INVALIDDATA; } if (num_mvs > s->num_mvs) { s->mv_codebook = av_realloc(s->mv_codebook, num_mvs*2*sizeof(int)); s->num_mvs = num_mvs; } if (num_blocks_packed > s->num_blocks_packed) { s->block_codebook = av_realloc(s->block_codebook, num_blocks_packed*16); s->num_blocks_packed = num_blocks_packed; } mvbits = (num_mvs * 2 * 10 + 31) & ~31; if (buf_end - buf < (mvbits>>3) + 16*num_blocks_raw + 8*num_blocks_packed) return AVERROR_INVALIDDATA; init_get_bits(&gb, buf, mvbits); for (i = 0; i < num_mvs; i++) { s->mv_codebook[i][0] = get_sbits(&gb, 10); s->mv_codebook[i][1] = get_sbits(&gb, 10); } buf += mvbits >> 3; blocks_raw = buf; buf += num_blocks_raw * 16; init_get_bits(&gb, buf, (buf_end - buf) << 3); for (i = 0; i < num_blocks_packed; i++) { int tmp[4]; for (j = 0; j < 4; j++) tmp[j] = get_bits(&gb, 8); for (j = 0; j < 16; j++) s->block_codebook[i][15-j] = tmp[get_bits(&gb, 2)]; } if (get_bits_left(&gb) < vector_bits * (s->avctx->height / 4) * (s->avctx->width / 4)) return AVERROR_INVALIDDATA; for (y = 0; y < s->avctx->height / 4; y++) for (x = 0; x < s->avctx->width / 4; x++) { unsigned int vector = get_bits(&gb, vector_bits); const uint8_t *src; int src_stride; if (vector < num_mvs) { int mx = x * 4 + s->mv_codebook[vector][0]; int my = y * 4 + s->mv_codebook[vector][1]; if (mx < 0 || mx + 4 > s->avctx->width || my < 0 || my + 4 > s->avctx->height) { av_log(s->avctx, AV_LOG_ERROR, "MV %d %d out of picture\n", mx, my); continue; } src = s->last_frame.data[0] + mx + my * s->last_frame.linesize[0]; src_stride = s->last_frame.linesize[0]; } else { int offset = vector - num_mvs; if (offset < num_blocks_raw) src = blocks_raw + 16*offset; else if (offset - num_blocks_raw < num_blocks_packed) src = s->block_codebook[offset - num_blocks_raw]; else continue; src_stride = 4; } for (j = 0; j < 4; j++) for (i = 0; i < 4; i++) frame->data[0][(y * 4 + j) * frame->linesize[0] + (x * 4 + i)] = src[j * src_stride + i]; } return 0; }
1threat
import re def is_valid_URL(str): regex = ("((http|https)://)(www.)?" + "[a-zA-Z0-9@:%._\\+~#?&//=]" + "{2,256}\\.[a-z]" + "{2,6}\\b([-a-zA-Z0-9@:%" + "._\\+~#?&//=]*)") p = re.compile(regex) if (str == None): return False if(re.search(p, str)): return True else: return False
0debug
static void h264_loop_filter_strength_mmx2( int16_t bS[2][4][4], uint8_t nnz[40], int8_t ref[2][40], int16_t mv[2][40][2], int bidir, int edges, int step, int mask_mv0, int mask_mv1, int field ) { __asm__ volatile( "movq %0, %%mm7 \n" "movq %1, %%mm6 \n" ::"m"(ff_pb_1), "m"(ff_pb_3) ); if(field) __asm__ volatile( "movq %0, %%mm6 \n" ::"m"(ff_pb_3_1) ); __asm__ volatile( "movq %%mm6, %%mm5 \n" "paddb %%mm5, %%mm5 \n" :); step <<= 3; edges <<= 3; h264_loop_filter_strength_iteration_mmx2(bS, nnz, ref, mv, bidir, edges, step, mask_mv1, 1, -8, 0); h264_loop_filter_strength_iteration_mmx2(bS, nnz, ref, mv, bidir, 32, 8, mask_mv0, 0, -1, -1); __asm__ volatile( "movq (%0), %%mm0 \n\t" "movq 8(%0), %%mm1 \n\t" "movq 16(%0), %%mm2 \n\t" "movq 24(%0), %%mm3 \n\t" TRANSPOSE4(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4) "movq %%mm0, (%0) \n\t" "movq %%mm3, 8(%0) \n\t" "movq %%mm4, 16(%0) \n\t" "movq %%mm2, 24(%0) \n\t" ::"r"(bS[0]) :"memory" ); }
1threat
static int amovie_get_samples(AVFilterLink *outlink) { MovieContext *movie = outlink->src->priv; AVPacket pkt; int ret, got_frame = 0; if (!movie->pkt.size && movie->is_done == 1) return AVERROR_EOF; if (!movie->pkt.size) { while ((ret = av_read_frame(movie->format_ctx, &pkt)) >= 0) { if (pkt.stream_index != movie->stream_index) { av_free_packet(&pkt); continue; } else { movie->pkt0 = movie->pkt = pkt; break; } } if (ret == AVERROR_EOF) { movie->is_done = 1; return ret; } } avcodec_get_frame_defaults(movie->frame); ret = avcodec_decode_audio4(movie->codec_ctx, movie->frame, &got_frame, &movie->pkt); if (ret < 0) { movie->pkt.size = 0; return ret; } movie->pkt.data += ret; movie->pkt.size -= ret; if (got_frame) { int nb_samples = movie->frame->nb_samples; int data_size = av_samples_get_buffer_size(NULL, movie->codec_ctx->channels, nb_samples, movie->codec_ctx->sample_fmt, 1); if (data_size < 0) return data_size; movie->samplesref = ff_get_audio_buffer(outlink, AV_PERM_WRITE, nb_samples); memcpy(movie->samplesref->data[0], movie->frame->data[0], data_size); movie->samplesref->pts = movie->pkt.pts; movie->samplesref->pos = movie->pkt.pos; movie->samplesref->audio->sample_rate = movie->codec_ctx->sample_rate; } if (movie->pkt.size <= 0) av_free_packet(&movie->pkt0); return 0; }
1threat
static void test_i440fx_pam(gconstpointer opaque) { const TestData *s = opaque; QPCIBus *bus; QPCIDevice *dev; int i; static struct { uint32_t start; uint32_t end; } pam_area[] = { { 0, 0 }, { 0xF0000, 0xFFFFF }, { 0xC0000, 0xC3FFF }, { 0xC4000, 0xC7FFF }, { 0xC8000, 0xCBFFF }, { 0xCC000, 0xCFFFF }, { 0xD0000, 0xD3FFF }, { 0xD4000, 0xD7FFF }, { 0xD8000, 0xDBFFF }, { 0xDC000, 0xDFFFF }, { 0xE0000, 0xE3FFF }, { 0xE4000, 0xE7FFF }, { 0xE8000, 0xEBFFF }, { 0xEC000, 0xEFFFF }, }; bus = test_start_get_bus(s); dev = qpci_device_find(bus, QPCI_DEVFN(0, 0)); g_assert(dev != NULL); for (i = 0; i < ARRAY_SIZE(pam_area); i++) { if (pam_area[i].start == pam_area[i].end) { continue; } g_test_message("Checking area 0x%05x..0x%05x", pam_area[i].start, pam_area[i].end); pam_set(dev, i, PAM_RE); g_assert(verify_area(pam_area[i].start, pam_area[i].end, 0)); pam_set(dev, i, PAM_RE | PAM_WE); write_area(pam_area[i].start, pam_area[i].end, 0x42); #ifndef BROKEN pam_set(dev, i, PAM_WE); g_assert(!verify_area(pam_area[i].start, pam_area[i].end, 0x42)); #endif g_assert(verify_area(pam_area[i].start, pam_area[i].end, 0x42)); write_area(pam_area[i].start, pam_area[i].end, 0x82); #ifndef BROKEN g_assert(!verify_area(pam_area[i].start, pam_area[i].end, 0x82)); pam_set(dev, i, PAM_RE | PAM_WE); #endif g_assert(verify_area(pam_area[i].start, pam_area[i].end, 0x82)); pam_set(dev, i, 0); g_assert(!verify_area(pam_area[i].start, pam_area[i].end, 0x82)); } qtest_end(); }
1threat
I am trying to remove exponential numbers from the results : <p>Help! I am completely new to coding as you can see...lol I need help removing the scientific notation that my code outputs. I would like the results to be displayed as only real numbers...i.e (removing the "e")...I would like to show only maybe 2-4 numbers after the decimal point. Please if anyone can help me with that it would be greatly appreciated.</p> <pre><code> Organism_A = 50 year = 1 for week in range(1,52*5 + 1): if week%2 == 0: Organism_A/=0.25 if week%4 == 0: Organism_A*=2 if week%52 == 0: print("At the end of year " + str(year) + " number of Organism A remaining = " + str(Organism_A)) year+=1 Organism_B = 250 year = 1 for week in range(1,52*5 + 1): if week%1 == 0: Organism_B/=0.25 if week%4 == 0: Organism_B*=3 if week%52 == 0: print("At the end of year " + str(year) + " number of Organism B remaining = " + str(Organism_B)) year+=1 Organism_C = 1000 year = 1 for week in range(1,52*5 + 1): if week%1 == 0: Organism_C/=0.13 if week%4 == 0: Organism_C*=0.75 if week%52 == 0: print("At the end of year " + str(year) + " number of Organism C remaining = " + str(Organism_C)) year+=1 </code></pre> <p><a href="https://i.stack.imgur.com/N2Yrg.jpg" rel="nofollow noreferrer">Code OUTPUT</a></p>
0debug
static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int is_meta, int64_t maxpos) { int count = ffio_read_varlen(bc); int skip_start = 0; int skip_end = 0; int channels = 0; int64_t channel_layout = 0; int sample_rate = 0; int width = 0; int height = 0; int i; for (i=0; i<count; i++) { uint8_t name[256], str_value[256], type_str[256]; int value; if (avio_tell(bc) >= maxpos) return AVERROR_INVALIDDATA; get_str(bc, name, sizeof(name)); value = get_s(bc); if (value == -1) { get_str(bc, str_value, sizeof(str_value)); av_log(s, AV_LOG_WARNING, "Unknown string %s / %s\n", name, str_value); } else if (value == -2) { uint8_t *dst = NULL; int64_t v64, value_len; get_str(bc, type_str, sizeof(type_str)); value_len = ffio_read_varlen(bc); if (avio_tell(bc) + value_len >= maxpos) return AVERROR_INVALIDDATA; if (!strcmp(name, "Palette")) { dst = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, value_len); } else if (!strcmp(name, "Extradata")) { dst = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, value_len); } else if (sscanf(name, "CodecSpecificSide%"SCNd64"", &v64) == 1) { dst = av_packet_new_side_data(pkt, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, value_len + 8); if(!dst) return AVERROR(ENOMEM); AV_WB64(dst, v64); dst += 8; } else if (!strcmp(name, "ChannelLayout") && value_len == 8) { channel_layout = avio_rl64(bc); continue; } else { av_log(s, AV_LOG_WARNING, "Unknown data %s / %s\n", name, type_str); avio_skip(bc, value_len); continue; } if(!dst) return AVERROR(ENOMEM); avio_read(bc, dst, value_len); } else if (value == -3) { value = get_s(bc); } else if (value == -4) { value = ffio_read_varlen(bc); } else if (value < -4) { get_s(bc); } else { if (!strcmp(name, "SkipStart")) { skip_start = value; } else if (!strcmp(name, "SkipEnd")) { skip_end = value; } else if (!strcmp(name, "Channels")) { channels = value; } else if (!strcmp(name, "SampleRate")) { sample_rate = value; } else if (!strcmp(name, "Width")) { width = value; } else if (!strcmp(name, "Height")) { height = value; } else { av_log(s, AV_LOG_WARNING, "Unknown integer %s\n", name); } } } if (channels || channel_layout || sample_rate || width || height) { uint8_t *dst = av_packet_new_side_data(pkt, AV_PKT_DATA_PARAM_CHANGE, 28); if (!dst) return AVERROR(ENOMEM); bytestream_put_le32(&dst, AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT*(!!channels) + AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT*(!!channel_layout) + AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE*(!!sample_rate) + AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS*(!!(width|height)) ); if (channels) bytestream_put_le32(&dst, channels); if (channel_layout) bytestream_put_le64(&dst, channel_layout); if (sample_rate) bytestream_put_le32(&dst, sample_rate); if (width || height){ bytestream_put_le32(&dst, width); bytestream_put_le32(&dst, height); } } if (skip_start || skip_end) { uint8_t *dst = av_packet_new_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, 10); if (!dst) return AVERROR(ENOMEM); AV_WL32(dst, skip_start); AV_WL32(dst+4, skip_end); } return 0; }
1threat