Dataset Viewer
problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Where can I find the logs for my Electron app in production? : <p>I've built an app with <a href="http://electron.atom.io" rel="noreferrer">Electron</a> and used <a href="https://github.com/electron-userland/electron-builder" rel="noreferrer">Electron-Builder</a> to create a <a href="https://github.com/Squirrel/Squirrel.Windows" rel="noreferrer">Squirrel</a> windows installer and updater. It all works great but I'm having trouble debugging the production version of my app. </p>
<p>Are the logs created by a <code>console.log</code> written somewhere on disk when using the production version? If so, where can I find them? Or are those all removed when compiling the executable? There must be some kind of log file for my app right?</p>
<p>I've found the SquirrelSetupLog in <code>C:\Users\Tieme\AppData\Local\MyApp\SquirrelSetupLog</code> but that's not enough for debugging my production-only problem. </p>
<hr>
<p>Just came across <a href="https://www.npmjs.com/package/electron-log" rel="noreferrer">electron-log</a>. That could work if regular console logs are indeed not written to disk somewhere.. </p>
| 0debug
|
Making my own framework and using it as an upstream for projects : <p>I’m a freelancer making websites for clients. I have my own devstack based on React and Node. Currently, when I’m developing a new site, I just copy the last project that I’ve programmed and modify routes, pages and so on. When I add some new functionality (update webpack 1 to 2 and so on), I then have to do it manually at each project (or I don’t do it at all).</p>
<p>I’d like to have a more professional approach to this. Can you recommend me some materials or attitudes towards it? </p>
<p>My current goal is this: Have a repo (private github and after verification give it public) with my devstack (framework). Everytime I start a new project, I fork it (so that it stays as upstream origin) and start developing. Everytime I change some core functionality or add something that I want to have in other projects too, I want to push it somehow to the devstack repo. I could also copy this code to the devstack manually, but I don’t want to write it twice, so a better approach would help.</p>
<p>How can I do that, is my idea good? Basically, some recommendation if it makes sence at all and some link to an article would help me enough. Thank you.</p>
| 0debug
|
How to debug ShareLock in Postgres : <p>I am seeing quite a few occurrences of the following in my Postgres server log:</p>
<pre><code>LOG: process x still waiting for ShareLock on transaction y after 1000.109 ms
DETAIL: Process holding the lock: z. Wait queue: x.
CONTEXT: while inserting index tuple (a,b) in relation "my_test_table"
SQL function "my_test_function" statement 1
...
LOG: process x acquired ShareLock on transaction y after 1013.664 ms
CONTEXT: while inserting index tuple (a,b) in relation "my_test_table"
</code></pre>
<p>I am running Postgres <strong>9.5.3</strong>. In addition I am running on Heroku so I don't have access to the fine grained superuser-only debugging tools.</p>
<p>I am wondering how best to debug such an issue given these constraints and the fact each individual lock is relatively transient (generally 1000-2000ms).</p>
<p>Things I have tried:</p>
<ul>
<li>Monitoring <a href="https://www.postgresql.org/docs/9.5/static/view-pg-locks.html" rel="noreferrer"><code>pg_locks</code></a> (and joining to <a href="https://www.postgresql.org/docs/9.5/static/catalog-pg-class.html" rel="noreferrer"><code>pg_class</code></a> for context).</li>
<li>Investigating <a href="https://www.postgresql.org/docs/9.5/static/pageinspect.html" rel="noreferrer"><code>pageinspect</code></a>.</li>
<li>Replicating locally both by hand and with <a href="https://www.postgresql.org/docs/9.5/static/pgbench.html" rel="noreferrer"><code>pgbench</code></a> where I do have superuser perms. I have so far been unable to replicate the issue locally (I <em>suspect</em> due to having a much smaller data set but I can't be sure).</li>
</ul>
<p>It is worth noting that CPU utilisation appears high (load average of >1) when I see these issues so it's possible there is nothing wrong with the above per se and that I'm seeing it as a consequence of insufficient system resources being available. I would still like to understand how best to debug it though so I can understand what exactly is happening.</p>
| 0debug
|
I form field is blank then show error message and form does not submitted : I am trying to create a Api.I am trying to submit a form . Form is submitted and response message after form submission is Ok .but I am trying to validate this form if any filed is blank then form does not submitted and show validation message.
<?php
require('../../../../wp-blog-header.php');
header("HTTP/1.1 200 OK");
global $wpdb;
global $serverUrl;
global $current_user;
$id =isset($_REQUEST['store_id']) ? $_REQUEST['store_id'] : '';
$user_id =isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : '';
$unit_data = isset($_REQUEST['unit_data']) ? $_REQUEST['unit_data'] : '';
$product = isset($_REQUEST['product']) ? $_REQUEST['product'] : '';
$checked_by = isset($_REQUEST['checked_by']) ? $_REQUEST['checked_by'] : '';
$username = isset($_POST['username']) ? $_POST['username'] : '';
$option = "signup";
$data = array(
'store_id' =>$id,
'user_id' =>$uid,
'unit_data' =>$unit_data,
'category_name'=>'delivery_form',
'checked_by'=>$checked_by,
'product' =>$product,
'suppliers'=>$suppliers,
'username' =>$username,
);
$insert=$wpdb->insert('diary_user_form_storage', $data);
echo json_encode(
array(
"status" => "1",
'user_id' => $user->ID,
'message' => 'Data submitted',
"token" => $token,
'token' => $token.$device_id.$device_type,
'serverUrl' => $serverUrl,
$data = array(
'store_id' =>$id,
'user_id' =>$uid,
'unit_data' =>$unit_data,
'product' =>$product,
'suppliers'=>$suppliers,
'checked_by'=>$checked_by,
'username' =>$username,
'option'=>$option
)
));
exit();
?>
| 0debug
|
Java, array return : <p>I'm new at Java. I'm studying through Programming Hub app. When i read HeapSort code i find out that method fnSortHeap not return array but main method still can print out it. From informations that i found in main method must be smt like that: </p>
<blockquote>
<p>int arr2[]; </p>
<p>arr2 = fnSortHeap(arr, i - 1);</p>
</blockquote>
<p>and in fnSortHeap method must </p>
<blockquote>
<p>return array;</p>
</blockquote>
<pre><code>class HeapSort
{
public static void main(String a[])
{
int i;
int arr[] = {1, 3, 4, 5, 2};
System.out.println("\nUnsorted Array\n---------------");
for (i = 0; i < arr.length; i++)
{
System.out.print(" " + arr[i]);
}
for (i = arr.length; i > 1; i--)
{
fnSortHeap(arr, i - 1);
}
System.out.println("\n\nSorted array\n---------------");
for (i = 0; i < arr.length; i++)
{
System.out.print(" " + arr[i]);
}
}
public static void fnSortHeap(int array[], int arr_ubound)
{
int i, o;
int lChild, rChild, mChild, root, temp;
root = (arr_ubound - 1) / 2;
for (o = root; o >= 0; o--)
{
for (i = root; i >= 0; i--)
{
lChild = (2 * i) + 1;
rChild = (2 * i) + 2;
if ((lChild <= arr_ubound) && (rChild <= arr_ubound))
{
if (array[rChild] >= array[lChild])
mChild = rChild;
else
mChild = lChild;
}
else
{
if (rChild > arr_ubound)
mChild = lChild;
else
mChild = rChild;
}
if (array[i] < array[mChild])
{
temp = array[i];
array[i] = array[mChild];
array[mChild] = temp;
}
}
}
temp = array[0];
array[0] = array[arr_ubound];
array[arr_ubound] = temp;
return;
}
}
</code></pre>
| 0debug
|
Is it possible to create a mysql table with value that auto increments every 1 second ? if yes how to do this? : <p>Is it possible to create a table with value that auto increments every 1 second ? if yes it is appreciated to give a simple example.</p>
| 0debug
|
Twitter Streaming API limits? : <p>I understand the Twitter REST API has strict request limits (few hundred times per 15 minutes), and that the streaming API is sometimes better for retrieving live data. </p>
<p>My question is, what exactly are the streaming API limits? Twitter references a percentage on their docs, but not a specific amount. Any insight is greatly appreciated. </p>
<p>What I'm trying to do: </p>
<ul>
<li>Simple page for me to view the latest tweet (& date / time it was posted) from ~1000 twitter users. It seems I would rapidly hit the limit using the REST API, so would the streaming API be required for this application? </li>
</ul>
| 0debug
|
def is_key_present(d,x):
if x in d:
return True
else:
return False
| 0debug
|
How to print a funktion in python? : Hi i have follwoing code and want to print the functions.
{answer = "'Tis but a scratch!"
def black_knight():
if answer == "'Tis but a scratch!":
return True
else:
return False # Make sure this returns False
def french_soldier():
if answer == "Go away, or I shall taunt you a second time!":
return True
else:
return False}
**i tried it with
x = black_knight()
y = french_solider()
print (x,y)
but it won't work. Could somebody pleas help me?**
| 0debug
|
static void test_hba_spec(void)
{
AHCIQState *ahci;
ahci = ahci_boot();
ahci_pci_enable(ahci);
ahci_test_hba_spec(ahci);
ahci_shutdown(ahci);
}
| 1threat
|
InputEvent *replay_read_input_event(void)
{
InputEvent evt;
KeyValue keyValue;
InputKeyEvent key;
key.key = &keyValue;
InputBtnEvent btn;
InputMoveEvent rel;
InputMoveEvent abs;
evt.type = replay_get_dword();
switch (evt.type) {
case INPUT_EVENT_KIND_KEY:
evt.u.key = &key;
evt.u.key->key->type = replay_get_dword();
switch (evt.u.key->key->type) {
case KEY_VALUE_KIND_NUMBER:
evt.u.key->key->u.number = replay_get_qword();
evt.u.key->down = replay_get_byte();
break;
case KEY_VALUE_KIND_QCODE:
evt.u.key->key->u.qcode = (QKeyCode)replay_get_dword();
evt.u.key->down = replay_get_byte();
break;
case KEY_VALUE_KIND__MAX:
break;
}
break;
case INPUT_EVENT_KIND_BTN:
evt.u.btn = &btn;
evt.u.btn->button = (InputButton)replay_get_dword();
evt.u.btn->down = replay_get_byte();
break;
case INPUT_EVENT_KIND_REL:
evt.u.rel = &rel;
evt.u.rel->axis = (InputAxis)replay_get_dword();
evt.u.rel->value = replay_get_qword();
break;
case INPUT_EVENT_KIND_ABS:
evt.u.abs = &abs;
evt.u.abs->axis = (InputAxis)replay_get_dword();
evt.u.abs->value = replay_get_qword();
break;
case INPUT_EVENT_KIND__MAX:
break;
}
return qapi_clone_InputEvent(&evt);
}
| 1threat
|
Error 404 Pages : <p>I want to set up a broken link reporting in my custom 404 page. I want to make the document a php page, so I can capture and send the url that was requested, to my email. I have some very basic php code in it so far to send the email, so I got that. The problem is, how to I make the 404 page apear on the actual broken link page, not redirect it to the 404 page. E.g. You see Google's website has it to where if you find a broken link like this (<a href="https://www.google.com/asdfasdfasdfasdfasdf" rel="nofollow">https://www.google.com/asdfasdfasdfasdfasdf</a>) then it stays on that same page and echos the requested uri. How do they do that? I just use the .htaccess method like </p>
<blockquote>
<p><code>ErrorDocument 404 http://mydomain.domain/404</code></p>
</blockquote>
<p>But this redirects the 404 page to there. How do I make the 404 apear on the actual broken link page (non-existing page)?</p>
| 0debug
|
How to add class to multiple divs with same class, javascript? : <p>I have multiple classes with same class name, for example I have 10 classes that have class name test. I want to add new class, for example active, for each class.</p>
<p>So if I have this:</p>
<pre><code><div class="test"></div>
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
</code></pre>
<p>multiple times on page. How to add to each class active, so it looks like this</p>
<pre><code><div class="test active"></div>
<div class="test active"></div>
<div class="test active"></div>
<div class="test active"></div>
</code></pre>
| 0debug
|
static void virtio_blk_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
dc->exit = virtio_blk_device_exit;
dc->props = virtio_blk_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
vdc->init = virtio_blk_device_init;
vdc->get_config = virtio_blk_update_config;
vdc->set_config = virtio_blk_set_config;
vdc->get_features = virtio_blk_get_features;
vdc->set_status = virtio_blk_set_status;
vdc->reset = virtio_blk_reset;
}
| 1threat
|
static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds,
int is_async)
{
BlkMigBlock *blk;
BlockDriverState *bs = blk_bs(bmds->blk);
int64_t total_sectors = bmds->total_sectors;
int64_t sector;
int nr_sectors;
int ret = -EIO;
for (sector = bmds->cur_dirty; sector < bmds->total_sectors;) {
blk_mig_lock();
if (bmds_aio_inflight(bmds, sector)) {
blk_mig_unlock();
blk_drain(bmds->blk);
} else {
blk_mig_unlock();
}
if (bdrv_get_dirty(bs, bmds->dirty_bitmap, sector)) {
if (total_sectors - sector < BDRV_SECTORS_PER_DIRTY_CHUNK) {
nr_sectors = total_sectors - sector;
} else {
nr_sectors = BDRV_SECTORS_PER_DIRTY_CHUNK;
}
bdrv_reset_dirty_bitmap(bmds->dirty_bitmap, sector, nr_sectors);
blk = g_new(BlkMigBlock, 1);
blk->buf = g_malloc(BLOCK_SIZE);
blk->bmds = bmds;
blk->sector = sector;
blk->nr_sectors = nr_sectors;
if (is_async) {
blk->iov.iov_base = blk->buf;
blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE;
qemu_iovec_init_external(&blk->qiov, &blk->iov, 1);
blk->aiocb = blk_aio_preadv(bmds->blk,
sector * BDRV_SECTOR_SIZE,
&blk->qiov, 0, blk_mig_read_cb,
blk);
blk_mig_lock();
block_mig_state.submitted++;
bmds_set_aio_inflight(bmds, sector, nr_sectors, 1);
blk_mig_unlock();
} else {
ret = blk_pread(bmds->blk, sector * BDRV_SECTOR_SIZE, blk->buf,
nr_sectors * BDRV_SECTOR_SIZE);
if (ret < 0) {
goto error;
}
blk_send(f, blk);
g_free(blk->buf);
g_free(blk);
}
sector += nr_sectors;
bmds->cur_dirty = sector;
break;
}
sector += BDRV_SECTORS_PER_DIRTY_CHUNK;
bmds->cur_dirty = sector;
}
return (bmds->cur_dirty >= bmds->total_sectors);
error:
DPRINTF("Error reading sector %" PRId64 "\n", sector);
g_free(blk->buf);
g_free(blk);
return ret;
}
| 1threat
|
static QDictEntry *qdict_find(const QDict *qdict,
const char *key, unsigned int hash)
{
QDictEntry *entry;
LIST_FOREACH(entry, &qdict->table[hash], next)
if (!strcmp(entry->key, key))
return entry;
return NULL;
}
| 1threat
|
When giving user input I don't want to have to put quotations is this possible? : <p>I'm trying to get user input on something but it's not very user friendly to have to put quotations each time you type an answer.</p>
<pre><code> loop = True
while loop:
user_input = input("say hello \n")
if user_input == "hello":
print("True")
</code></pre>
<p>I want to be able to just type hello and not have to add the quotations (ex. "hello"). </p>
| 0debug
|
C# find the length of the longest substring : <p>I want to get the length of the longest substring in a string separated by ","</p>
<p>For example:</p>
<blockquote>
<p>test1,test11,test111 -> length of test111 -> 7</p>
</blockquote>
| 0debug
|
Javascript Function Call : <p>The question is really simple but i searched everywhere couldn't get an answer.</p>
<pre><code>add();
function add()
{
//function code here
}
</code></pre>
<p>The above code works in JavaScript even though function call is before function definition but wouldn't work in language such as C or C++. Could anyone tell me why?</p>
| 0debug
|
Jupyter nbextensions does not appear : <p>I tried to install jupyter_contrib_nbextensions : <a href="http://jupyter-contrib-nbextensions.readthedocs.io/en/latest/install.html" rel="noreferrer">http://jupyter-contrib-nbextensions.readthedocs.io/en/latest/install.html</a></p>
<p>Everything worked fine but when I open a notebook nothing changes. I can't see the new tool bar that I'm supposed to see. </p>
<p>When I reinstall the Extension, the process is the same (I don't have a message tellign me that the files already exists). I don't have an error. So I can't figure out why it doesn't work. </p>
<p>Thanks a lot.</p>
| 0debug
|
Android Glide: Show a blurred image before loading actual image : <p>I am developing an Android app which displays full screen images to the user. Images are fetched from the server. I am using Glide to show the image. But I want to display a very small size blurred image before displaying the actual image. Once the image is cached, directly full sized image should be shown.</p>
<p>Image Displaying flows goes like this:
- If image is downloaded for the first time, first download a small scaled image, and then download full resolution image.
- If image has been downloaded before, directly show full scale image.</p>
<p>I cannot find any method in Glide library, which tell me if a file exist in cache or not.</p>
<p>Any idea, how this can be done. </p>
| 0debug
|
Typescript getter and setter error : <p>Ok it's my first day doing some Angular 2 using typescript and I am try to make a simple getter and setter service.</p>
<pre><code>import {Injectable} from "angular2/core";
@Injectable()
export class TodoService {
private _todos:Array = [];
get todos():Array {
return this._todos;
}
set todos(value:Array) {
this._todos = value;
}
}
</code></pre>
<p>Can anyone explain why the Typescript compiler is throwing the following error as I think it should be ok.</p>
<pre><code>ERROR in [default] /Users/testguy/WebstormProjects/angular2-seed/src/app/services/todo-service.ts:6:17
Generic type 'Array<T>' requires 1 type argument(s).
ERROR in [default] /Users/testguy/WebstormProjects/angular2-seed/src/app/services/todo-service.ts:8:14
Generic type 'Array<T>' requires 1 type argument(s).
ERROR in [default] /Users/testguy/WebstormProjects/angular2-seed/src/app/services/todo-service.ts:12:18
Generic type 'Array<T>' requires 1 type argument(s).
</code></pre>
| 0debug
|
Abstract methods in Swift? : <p>I have few questions for Swift developers regarding the concept of abstract classes.</p>
<ol>
<li><strong>How do you define an abstract class in Swift?</strong> Is there any way to prevent a class from being instantiated, while providing an initializer for its subclasses to use?</li>
<li><strong>How do you define abstract methods, while implementing others?</strong> When defining abstract methods, Apple generally points you to protocols (interfaces). But they only solve the first part of my question, since <em>all</em> of the methods they define are abstract. What do you do when you want to have both abstract and non-abstract methods in your class?</li>
<li><strong>What about generics?</strong> You might have thought about using protocols together with extensions (categories). But then there is an issue with generics because protocols can't have generic types, only <em>typealiases</em>.</li>
</ol>
<p>I have done my homework and I know about solving these issues using methods, such as <code>fatalError()</code> or <code>preconditionFailure()</code> in the superclass and then overriding them in a base class. But that seems like <em>ugly</em> object design to me.</p>
<p>The reason I'm posting this is to find out whether there exists more general and universal solution.</p>
<p>Thanks in advance,
Petr.</p>
| 0debug
|
C++ Programming assignment program terminated with signal 6 : <p>This is the assignment:
Write a program that outputs a histogram of student grades for an assignment. First, the program will input the number of grades and create a dynamic array to store the grades. Then, the program should input each student's grade as an integer and store the grade in the dynamic array.</p>
<p>The program should then scan through the array and compute the histogram. In computing the histogram, the minimum value of a grade is 0 but your program should determine the maximum value entered by the user. Use a dynamic array to store the histogram. Output the histogram to the console.</p>
<p>For example, if the input is:</p>
<p>Enter number of grades:
6
Enter grades (each on a new line):
20
30
4
20
30
30
Then the output histogram should be:</p>
<p>4 *
20 **
30 ***</p>
<p>My program works fine for me but when I submit it online it tells me "Program terminated with signal 6." Im not sure what this is and im not sure what in my program is causing it. Here is my code:</p>
<pre><code>#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int numGrades;
int i,j;
int max = 0;
int *list, *hist;
cout << "Enter number of grades:" << endl;
cin >> numGrades;
list = new int[numGrades];
cout << "Enter grades (each on a new line):\n";
for(i=0;i<numGrades;i++)
{
cin >> *(list+i);
}
for(i=0;i<numGrades;i++)
{
if(max<*(list+i))
max = *(list+i);
}
hist = new int[max];
for(i=0;i<=max;i++)
{
int no=0;
for(int j=0;j<numGrades;j++)
{
if(i==*(list+j))
no++;
}
*(hist+i)=no;
}
cout << "Histogram:" << endl;
for(i=0;i<=max;i++)
{
if(*(hist+i)!=0)
{
cout << right << setw(3) << i << " ";
for(j=0;j<*(hist+i);j++)
cout << "*";
}
if(*(hist+i) != 0)
cout << endl;
}
delete []hist;
delete []list;
return 0;
}
</code></pre>
<p>Any help is appreciated, thank you.</p>
| 0debug
|
How do I get started with ReactJS? : <p>Need good resources for learning React - tutorials, video series, books, etc.</p>
<p>Some websites just provide the basics of React but I need guidance on how to get started with developing a full-fledged website with multiple react components.</p>
| 0debug
|
static CharDriverState *gd_vc_handler(ChardevVC *vc, Error **errp)
{
ChardevCommon *common = qapi_ChardevVC_base(vc);
CharDriverState *chr;
chr = qemu_chr_alloc(common, errp);
if (!chr) {
chr->chr_write = gd_vc_chr_write;
chr->chr_set_echo = gd_vc_chr_set_echo;
chr->opaque = g_new0(VirtualConsole, 1);
vcs[nb_vcs++] = chr;
return chr;
| 1threat
|
Android - Checking if a word from file matches a random character string from EditText : Hello everyone :) Would just like to ask how can i see if set of random characters from String of EditText matches a certain word from file
for example
EditText input: TINARSE
Can match word like NASTIER, STAINER.
Suppose a word in file is denoted by i.
I know how read strings from file just cant figure out how to match it with the random character input using IF statements.
**Note: Length of string should be same as length EditText**
Thanks in Advance! :)
| 0debug
|
how can I add right to left Icon : I have attached the below image URL , for that I have used below code,but I am not able to find the content for icon-align right. Can anyone please help me out to revert the image or particular icon for right to left. it is used for Right To Left user.
.icon-alignleft:before {
content: "\e00a";
}
thank you
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/DLcnj.jpg
| 0debug
|
How can I set <aside> element to the right of page? : <p>How can I put <code><aside></code> to the right, next to <code><body></code> ?
I tried <code><aside align=right></code> and <code>aside{ align-self: right}</code> in CSS and it doesn`t work.</p>
| 0debug
|
Create Regular Expression with exact 2 repetition of single charcter : I am fighting with regular expression - I want to create one for validation in REST resource, the id which is queried needs to have two : , for example key1:key2:key3
how can i create it?
the length of key1-3 can change and not equal
thanks
| 0debug
|
Make a website slow mo scroll like this https://www.mendo.nl/ if its jquery please how : hey guys is there a way i can make my website slide like lazily or slow mo when scrolling like this https://www.mendo.nl/
| 0debug
|
restore_sigcontext(CPUX86State *env, struct target_sigcontext *sc, int *peax)
{
unsigned int err = 0;
abi_ulong fpstate_addr;
unsigned int tmpflags;
cpu_x86_load_seg(env, R_GS, tswap16(sc->gs));
cpu_x86_load_seg(env, R_FS, tswap16(sc->fs));
cpu_x86_load_seg(env, R_ES, tswap16(sc->es));
cpu_x86_load_seg(env, R_DS, tswap16(sc->ds));
env->regs[R_EDI] = tswapl(sc->edi);
env->regs[R_ESI] = tswapl(sc->esi);
env->regs[R_EBP] = tswapl(sc->ebp);
env->regs[R_ESP] = tswapl(sc->esp);
env->regs[R_EBX] = tswapl(sc->ebx);
env->regs[R_EDX] = tswapl(sc->edx);
env->regs[R_ECX] = tswapl(sc->ecx);
env->eip = tswapl(sc->eip);
cpu_x86_load_seg(env, R_CS, lduw(&sc->cs) | 3);
cpu_x86_load_seg(env, R_SS, lduw(&sc->ss) | 3);
tmpflags = tswapl(sc->eflags);
env->eflags = (env->eflags & ~0x40DD5) | (tmpflags & 0x40DD5);
fpstate_addr = tswapl(sc->fpstate);
if (fpstate_addr != 0) {
if (!access_ok(VERIFY_READ, fpstate_addr,
sizeof(struct target_fpstate)))
goto badframe;
cpu_x86_frstor(env, fpstate_addr, 1);
}
*peax = tswapl(sc->eax);
return err;
badframe:
return 1;
}
| 1threat
|
static av_always_inline void h264_filter_mb_fast_internal(H264Context *h,
int mb_x, int mb_y,
uint8_t *img_y,
uint8_t *img_cb,
uint8_t *img_cr,
unsigned int linesize,
unsigned int uvlinesize,
int pixel_shift)
{
int chroma = !(CONFIG_GRAY && (h->flags&CODEC_FLAG_GRAY));
int chroma444 = CHROMA444(h);
int chroma422 = CHROMA422(h);
int mb_xy = h->mb_xy;
int left_type= h->left_type[LTOP];
int top_type= h->top_type;
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
int a = h->slice_alpha_c0_offset - qp_bd_offset;
int b = h->slice_beta_offset - qp_bd_offset;
int mb_type = h->cur_pic.mb_type[mb_xy];
int qp = h->cur_pic.qscale_table[mb_xy];
int qp0 = h->cur_pic.qscale_table[mb_xy - 1];
int qp1 = h->cur_pic.qscale_table[h->top_mb_xy];
int qpc = get_chroma_qp( h, 0, qp );
int qpc0 = get_chroma_qp( h, 0, qp0 );
int qpc1 = get_chroma_qp( h, 0, qp1 );
qp0 = (qp + qp0 + 1) >> 1;
qp1 = (qp + qp1 + 1) >> 1;
qpc0 = (qpc + qpc0 + 1) >> 1;
qpc1 = (qpc + qpc1 + 1) >> 1;
if( IS_INTRA(mb_type) ) {
static const int16_t bS4[4] = {4,4,4,4};
static const int16_t bS3[4] = {3,3,3,3};
const int16_t *bSH = FIELD_PICTURE(h) ? bS3 : bS4;
if(left_type)
filter_mb_edgev( &img_y[4*0<<pixel_shift], linesize, bS4, qp0, a, b, h, 1);
if( IS_8x8DCT(mb_type) ) {
filter_mb_edgev( &img_y[4*2<<pixel_shift], linesize, bS3, qp, a, b, h, 0);
if(top_type){
filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, a, b, h, 1);
}
filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, a, b, h, 0);
} else {
filter_mb_edgev( &img_y[4*1<<pixel_shift], linesize, bS3, qp, a, b, h, 0);
filter_mb_edgev( &img_y[4*2<<pixel_shift], linesize, bS3, qp, a, b, h, 0);
filter_mb_edgev( &img_y[4*3<<pixel_shift], linesize, bS3, qp, a, b, h, 0);
if(top_type){
filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, a, b, h, 1);
}
filter_mb_edgeh( &img_y[4*1*linesize], linesize, bS3, qp, a, b, h, 0);
filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, a, b, h, 0);
filter_mb_edgeh( &img_y[4*3*linesize], linesize, bS3, qp, a, b, h, 0);
}
if(chroma){
if(chroma444){
if(left_type){
filter_mb_edgev( &img_cb[4*0<<pixel_shift], linesize, bS4, qpc0, a, b, h, 1);
filter_mb_edgev( &img_cr[4*0<<pixel_shift], linesize, bS4, qpc0, a, b, h, 1);
}
if( IS_8x8DCT(mb_type) ) {
filter_mb_edgev( &img_cb[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
filter_mb_edgev( &img_cr[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
if(top_type){
filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1 );
filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1 );
}
filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, a, b, h, 0);
filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, a, b, h, 0);
} else {
filter_mb_edgev( &img_cb[4*1<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
filter_mb_edgev( &img_cr[4*1<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
filter_mb_edgev( &img_cb[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
filter_mb_edgev( &img_cr[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
filter_mb_edgev( &img_cb[4*3<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
filter_mb_edgev( &img_cr[4*3<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
if(top_type){
filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1);
filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1);
}
filter_mb_edgeh( &img_cb[4*1*linesize], linesize, bS3, qpc, a, b, h, 0);
filter_mb_edgeh( &img_cr[4*1*linesize], linesize, bS3, qpc, a, b, h, 0);
filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, a, b, h, 0);
filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, a, b, h, 0);
filter_mb_edgeh( &img_cb[4*3*linesize], linesize, bS3, qpc, a, b, h, 0);
filter_mb_edgeh( &img_cr[4*3*linesize], linesize, bS3, qpc, a, b, h, 0);
}
}else if(chroma422){
if(left_type){
filter_mb_edgecv(&img_cb[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1);
filter_mb_edgecv(&img_cr[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1);
}
filter_mb_edgecv(&img_cb[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0);
filter_mb_edgecv(&img_cr[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0);
if(top_type){
filter_mb_edgech(&img_cb[4*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1);
filter_mb_edgech(&img_cr[4*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1);
}
filter_mb_edgech(&img_cb[4*1*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
filter_mb_edgech(&img_cr[4*1*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
filter_mb_edgech(&img_cb[4*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
filter_mb_edgech(&img_cr[4*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
filter_mb_edgech(&img_cb[4*3*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
filter_mb_edgech(&img_cr[4*3*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
}else{
if(left_type){
filter_mb_edgecv( &img_cb[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1);
filter_mb_edgecv( &img_cr[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1);
}
filter_mb_edgecv( &img_cb[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0);
filter_mb_edgecv( &img_cr[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0);
if(top_type){
filter_mb_edgech( &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1);
filter_mb_edgech( &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1);
}
filter_mb_edgech( &img_cb[2*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
filter_mb_edgech( &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
}
}
return;
} else {
LOCAL_ALIGNED_8(int16_t, bS, [2], [4][4]);
int edges;
if( IS_8x8DCT(mb_type) && (h->cbp&7) == 7 && !chroma444 ) {
edges = 4;
AV_WN64A(bS[0][0], 0x0002000200020002ULL);
AV_WN64A(bS[0][2], 0x0002000200020002ULL);
AV_WN64A(bS[1][0], 0x0002000200020002ULL);
AV_WN64A(bS[1][2], 0x0002000200020002ULL);
} else {
int mask_edge1 = (3*(((5*mb_type)>>5)&1)) | (mb_type>>4);
int mask_edge0 = 3*((mask_edge1>>1) & ((5*left_type)>>5)&1);
int step = 1+(mb_type>>24);
edges = 4 - 3*((mb_type>>3) & !(h->cbp & 15));
h->h264dsp.h264_loop_filter_strength( bS, h->non_zero_count_cache, h->ref_cache, h->mv_cache,
h->list_count==2, edges, step, mask_edge0, mask_edge1, FIELD_PICTURE(h));
}
if( IS_INTRA(left_type) )
AV_WN64A(bS[0][0], 0x0004000400040004ULL);
if( IS_INTRA(top_type) )
AV_WN64A(bS[1][0], FIELD_PICTURE(h) ? 0x0003000300030003ULL : 0x0004000400040004ULL);
#define FILTER(hv,dir,edge,intra)\
if(AV_RN64A(bS[dir][edge])) { \
filter_mb_edge##hv( &img_y[4*edge*(dir?linesize:1<<pixel_shift)], linesize, bS[dir][edge], edge ? qp : qp##dir, a, b, h, intra );\
if(chroma){\
if(chroma444){\
filter_mb_edge##hv( &img_cb[4*edge*(dir?linesize:1<<pixel_shift)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\
filter_mb_edge##hv( &img_cr[4*edge*(dir?linesize:1<<pixel_shift)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\
} else if(!(edge&1)) {\
filter_mb_edgec##hv( &img_cb[2*edge*(dir?uvlinesize:1<<pixel_shift)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\
filter_mb_edgec##hv( &img_cr[2*edge*(dir?uvlinesize:1<<pixel_shift)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\
}\
}\
}
if(left_type)
FILTER(v,0,0,1);
if( edges == 1 ) {
if(top_type)
FILTER(h,1,0,1);
} else if( IS_8x8DCT(mb_type) ) {
FILTER(v,0,2,0);
if(top_type)
FILTER(h,1,0,1);
FILTER(h,1,2,0);
} else {
FILTER(v,0,1,0);
FILTER(v,0,2,0);
FILTER(v,0,3,0);
if(top_type)
FILTER(h,1,0,1);
FILTER(h,1,1,0);
FILTER(h,1,2,0);
FILTER(h,1,3,0);
}
#undef FILTER
}
}
| 1threat
|
int qcow2_pre_write_overlap_check(BlockDriverState *bs, int ign, int64_t offset,
int64_t size)
{
int ret = qcow2_check_metadata_overlap(bs, ign, offset, size);
if (ret < 0) {
return ret;
} else if (ret > 0) {
int metadata_ol_bitnr = ffs(ret) - 1;
char *message;
assert(metadata_ol_bitnr < QCOW2_OL_MAX_BITNR);
fprintf(stderr, "qcow2: Preventing invalid write on metadata (overlaps "
"with %s); image marked as corrupt.\n",
metadata_ol_names[metadata_ol_bitnr]);
message = g_strdup_printf("Prevented %s overwrite",
metadata_ol_names[metadata_ol_bitnr]);
qapi_event_send_block_image_corrupted(bdrv_get_device_name(bs),
message,
true,
offset,
true,
size,
true,
&error_abort);
g_free(message);
qcow2_mark_corrupt(bs);
bs->drv = NULL;
return -EIO;
}
return 0;
}
| 1threat
|
Type 'Observable<Object>' is not assignable to type 'Observable<IUser[]>' : <p>In my Api service I have this simple <code>getUsers</code> function to fetch all of the users on the api.</p>
<pre><code>public getUsers(url: string): Observable<IUser[]> {
return this._http.get(url);
}
</code></pre>
<p>This is my IUser interface, I have made all the field optional for now.</p>
<pre><code>export interface IUser {
id?: string;
first_name?: string;
last_name?: string;
location?: string;
followers?: string;
following?: string;
checkins?: string;
image?: string;
}
</code></pre>
<p>and here is how I have used the service in my component:</p>
<pre><code>export class SocialOverviewContainerComponent implements OnInit {
public userData = [];
public showForm = {};
private _apiService: ApiService;
constructor(apiService: ApiService) {
this._apiService = apiService
}
public ngOnInit(): void {
this.getUsersData();
}
public getUsersData() {
this._apiService.getUsers(ApiSettings.apiBasepath + 'users/')
.subscribe(users => {
this.userData = users;
})
}
}
</code></pre>
<p>and this is is the Type error I get when it compiles</p>
<pre><code>ERROR in src/app/services/api.service.ts(18,5): error TS2322: Type 'Observable<Object>' is not assignable to type 'Observable<IUser[]>'.
Type 'Object' is not assignable to type 'IUser[]'.
The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?
Property 'includes' is missing in type 'Object'.
</code></pre>
<p>I thought this might be because my response doesn't match the interface, which I have double check and it does. And I have also made the field optional for now to make sure.</p>
<p>I know I can fix this by casting the observable as any, but doesn't that defeat the point of using Typescript?</p>
<p>Any help on where I am going wrong would be great</p>
<p>Thanks in advance</p>
| 0debug
|
static void gen_debug(DisasContext *s, target_ulong cur_eip)
{
gen_update_cc_op(s);
gen_jmp_im(cur_eip);
gen_helper_debug(cpu_env);
s->is_jmp = DISAS_TB_JUMP;
}
| 1threat
|
int qemu_acl_append(qemu_acl *acl,
int deny,
const char *match)
{
qemu_acl_entry *entry;
entry = qemu_malloc(sizeof(*entry));
entry->match = qemu_strdup(match);
entry->deny = deny;
TAILQ_INSERT_TAIL(&acl->entries, entry, next);
acl->nentries++;
return acl->nentries;
}
| 1threat
|
How many Objects created in below code.? : String s1=new String("Java"); /* 1st object created */
String s2="Tech"; /* 2nd Object */
s1+=s2; /* I'm confusing here whether new object created or result stored in previous object */
/* Total how many Objects created */
| 0debug
|
What does % mean when typing in a file path : An example could be `%APP_LOCAL%\default` or `%APP_BASE%`.
Cheers.
| 0debug
|
static gboolean tcp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)
{
CharDriverState *chr = opaque;
TCPCharDriver *s = chr->opaque;
uint8_t buf[READ_BUF_LEN];
int len, size;
if (!s->connected || s->max_size <= 0) {
return FALSE;
}
len = sizeof(buf);
if (len > s->max_size)
len = s->max_size;
size = tcp_chr_recv(chr, (void *)buf, len);
if (size == 0) {
s->connected = 0;
if (s->listen_chan) {
s->listen_tag = g_io_add_watch(s->listen_chan, G_IO_IN, tcp_chr_accept, chr);
}
if (s->tag) {
g_source_remove(s->tag);
s->tag = 0;
}
g_io_channel_unref(s->chan);
s->chan = NULL;
closesocket(s->fd);
s->fd = -1;
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
} else if (size > 0) {
if (s->do_telnetopt)
tcp_chr_process_IAC_bytes(chr, s, buf, &size);
if (size > 0)
qemu_chr_be_write(chr, buf, size);
}
return TRUE;
}
| 1threat
|
talking to a network device with UDP on windows and on linux : I have an antenna dish pedestal. Something that looks like this (just one of these). Eventually pedestal will have an dish antenna connected to it.
[![enter image description here][1]][1]
This pedestal has two motors to rotate the dish horizontally and vertically. Each motor has an IP address. For the sake of the discussion let's assume they are 10.10.10.20 and 10.10.10.30
The company (can't disclose it) that makes the pedestals provides a Windows application to communicate with the pedestal over Ethernet (sends UDP packets).
We tried pining both of the motors from Windows and had no issues. However when we ping the motors from Linux there is no response.
We tried looking up online what could be the issue but didn't find any reasonable answers. To add to our problems, our project manager doesn't allow us to contact the pedestal manufacturer. We must find an explanation of the problem first and then we can let the manufacturer know what the issue is.
Has anyone encountered this type of problem before (able to ping from Windows but not able to ping from Linux)? If yes, then wow did you resolve the issue? What are we missing?
[1]: https://i.stack.imgur.com/WhkTY.jpg
| 0debug
|
Can you check whats wrong with my code? : package readexcel;
import java.io.File;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import org.apache.poi.hssf.usermodel.HSSFCell;
public class ReadExcel {
public static void main(String[] args) throws Exception
{
File f=new File("C:\\Users\\user1\\Desktop\\203132017.xls");
Workbook wb=Workbook.getWorkbook(f);
Sheet s=wb.getSheet(0);
int row=s.getRows();
int col=s.getColumns();
HSSFCell cell;
for (int j=0;j<200;j++){
Cell c=s.getCell(10,j);
c.getContents();
c.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
}}}
Im getting the following error:
run:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: jxl.Cell.setCellType
at readexcel.ReadExcel.main(ReadExcel.java:32)
| 0debug
|
static void FUNCC(pred8x8_dc)(uint8_t *_src, int stride){
int i;
int dc0, dc1, dc2;
pixel4 dc0splat, dc1splat, dc2splat, dc3splat;
pixel *src = (pixel*)_src;
stride /= sizeof(pixel);
dc0=dc1=dc2=0;
for(i=0;i<4; i++){
dc0+= src[-1+i*stride] + src[i-stride];
dc1+= src[4+i-stride];
dc2+= src[-1+(i+4)*stride];
}
dc0splat = PIXEL_SPLAT_X4((dc0 + 4)>>3);
dc1splat = PIXEL_SPLAT_X4((dc1 + 2)>>2);
dc2splat = PIXEL_SPLAT_X4((dc2 + 2)>>2);
dc3splat = PIXEL_SPLAT_X4((dc1 + dc2 + 4)>>3);
for(i=0; i<4; i++){
((pixel4*)(src+i*stride))[0]= dc0splat;
((pixel4*)(src+i*stride))[1]= dc1splat;
}
for(i=4; i<8; i++){
((pixel4*)(src+i*stride))[0]= dc2splat;
((pixel4*)(src+i*stride))[1]= dc3splat;
}
}
| 1threat
|
Why is one_of() called that? : <p>Why is <code>dplyr::one_of()</code> called that? All the other <code>select_helpers</code> names make sense to me, so I'm wondering if there's an aspect of <code>one_of()</code> that I don't understand.</p>
<p>My understanding of <code>one_of()</code> is that it just lets you select variables using a character vector of their names instead of putting their names into the <code>select()</code> call, but then you get all of the variables whose names are in the vector, not just <strong>one of</strong> them. Is that wrong, and if it's correct, where does the name <code>one_of()</code> come from?</p>
| 0debug
|
int ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab,
IVIHuffTab *huff_tab, AVCodecContext *avctx)
{
int i, result;
IVIHuffDesc new_huff;
if (!desc_coded) {
huff_tab->tab = (which_tab) ? &ff_ivi_blk_vlc_tabs[7]
: &ff_ivi_mb_vlc_tabs [7];
} else {
huff_tab->tab_sel = get_bits(gb, 3);
if (huff_tab->tab_sel == 7) {
new_huff.num_rows = get_bits(gb, 4);
for (i = 0; i < new_huff.num_rows; i++)
new_huff.xbits[i] = get_bits(gb, 4);
if (ff_ivi_huff_desc_cmp(&new_huff, &huff_tab->cust_desc)) {
ff_ivi_huff_desc_copy(&huff_tab->cust_desc, &new_huff);
if (huff_tab->cust_tab.table)
ff_free_vlc(&huff_tab->cust_tab);
result = ff_ivi_create_huff_from_desc(&huff_tab->cust_desc,
&huff_tab->cust_tab, 0);
if (result) {
av_log(avctx, AV_LOG_ERROR,
"Error while initializing custom vlc table!\n");
return -1;
}
}
huff_tab->tab = &huff_tab->cust_tab;
} else {
huff_tab->tab = (which_tab) ? &ff_ivi_blk_vlc_tabs[huff_tab->tab_sel]
: &ff_ivi_mb_vlc_tabs [huff_tab->tab_sel];
}
}
return 0;
}
| 1threat
|
static void test_qemu_strtoull_full_max(void)
{
char *str = g_strdup_printf("%lld", ULLONG_MAX);
uint64_t res = 999;
int err;
err = qemu_strtoull(str, NULL, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, ULLONG_MAX);
g_free(str);
}
| 1threat
|
Grouping 2D arrays & transforming to hash : I have a two dimensional array and I wanted to group it by one of the attributes within the array. The values in the attributes stored in the array are sales_user, user_id, month, and amount.
array = [[8765, 105191, 2.0, 1582.1],
[4321, 62770, 2.0, 603.24],
[4321, 105191, 2.0, 1900.8],
[1234, 62770, 2.0, 603.24]]
Index[0] in each array is the sales_user and I wanted to group by that.
I need to get it to:
[[8765, [105191, 2.0, 1582.1]]
[[4321, [[62770, 2.0, 603.24]],[[105191, 2.0, 1900.8]]]
[1234, [[62770, 2.0, 603.24]]]]
I tried doing this:
array.group_by(&:first).map { |c, xs| [c, xs] }
[[8765, [[8765, 105191, 2.0, 1582.1]]],
[4321, [[4321, 62770, 2.0, 603.24], ][4321, 105191, 2.0, 1900.8]]],
[1234, [[1234, 62770, 2.0, 603.24]]]]
It almost gave me what I wanted but it included the sales_user inner array as well :/
I would like to transform the grouped array to a hash as well. Is this easily possible in ruby? I'm fairly new to it ^^" Or maybe I need to conver the original array to a hash and then do the group by sales_user?
| 0debug
|
create a playbook test.yml that will install apache2 sqlite3 git ?? : ---
- name: install apache2, sqlite3, git pn remote server
hosts: host01
sudo: yes
tasks:
- name: Install list of packages
action: apt pkg={{item}} state=installed
with_items:
- apache2
- sqlite3
- git
INVENTORY FILE NAME: myhosts
$cat myhosts
[group1]
host01 ansible_ssh_user=ubuntu
COMMAND USED: ansible-playbook -i myhosts test.yml
ERROR is below one, I don't know what went wrong someone help me in this.
ERROR: Syntax Error while loading YAML script, test.yml
Note: The error may actually appear before this position: line 7, column 12
- name: Install list of packages
action: apt pkg={{item}} state=installed
^
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"
| 0debug
|
static void platform_fixed_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
{
PCIXenPlatformState *s = opaque;
switch (addr) {
case 0: {
PCIDevice *pci_dev = PCI_DEVICE(s);
if (val & UNPLUG_ALL_DISKS) {
DPRINTF("unplug disks\n");
pci_unplug_disks(pci_dev->bus);
}
if (val & UNPLUG_ALL_NICS) {
DPRINTF("unplug nics\n");
pci_unplug_nics(pci_dev->bus);
}
if (val & UNPLUG_AUX_IDE_DISKS) {
DPRINTF("unplug auxiliary disks not supported\n");
}
break;
}
case 2:
switch (val) {
case 1:
DPRINTF("Citrix Windows PV drivers loaded in guest\n");
break;
case 0:
DPRINTF("Guest claimed to be running PV product 0?\n");
break;
default:
DPRINTF("Unknown PV product %d loaded in guest\n", val);
break;
}
s->driver_product_version = val;
break;
}
}
| 1threat
|
Fixed height and width - cutting of child elements : I'm working on a online-shop for a winery. Link to the page is [http://develope.haimerl.at/shop][1]. In the shop page all wines are shown with some information. Every second product div should be a bit smaller which works fine in screen widths under 1000px but doesn't work from 1000px on.<br />
I'm working with a bought wordpress theme and was looking for any breakpoints in css that would explain this behavior. When I'm setting a fixed height with the :nth-child operator it just cuts of the child elements.<br />
Maybe anyone has an idea how i could manage that every second element is a bit smaller than the other ones.
Thanks in Advance
[1]: http://develope.haimerl.at/shop
| 0debug
|
Which is the best free data warehouse products : <p>I am developing a system which constains a lot of olap work. According to my research, column based data warehouse is the best choice. But I am puzzled to choose a good data warehouse product. </p>
<ol>
<li><p>All the data warehouse comparison article I see is befor 2012,and there seems little article about it. Is data warehouse out-of-date? Hadoop HBase is better?</p></li>
<li><p>As far as I know, InfiniDB is a high performance open source data warehouse product, but it has not been maintained for 2 years <a href="https://github.com/infinidb/infinidb" rel="nofollow">https://github.com/infinidb/infinidb</a>. And there is little document about InfiniDB . Has InfiniDB been abundanted by developers ?</p></li>
<li><p>Which is the best data warehouse product by now?</p></li>
<li><p>How do I incrementally move my Business data stored in the Mysql database to data warehouse ?</p></li>
</ol>
<p>Thank you for your answer!</p>
| 0debug
|
static void test_qga_file_ops(gconstpointer fix)
{
const TestFixture *fixture = fix;
const unsigned char helloworld[] = "Hello World!\n";
const char *b64;
gchar *cmd, *path, *enc;
unsigned char *dec;
QDict *ret, *val;
int64_t id, eof;
gsize count;
FILE *f;
char tmp[100];
ret = qmp_fd(fixture->fd, "{'execute': 'guest-file-open',"
" 'arguments': { 'path': 'foo', 'mode': 'w+' } }");
g_assert_nonnull(ret);
qmp_assert_no_error(ret);
id = qdict_get_int(ret, "return");
QDECREF(ret);
enc = g_base64_encode(helloworld, sizeof(helloworld));
cmd = g_strdup_printf("{'execute': 'guest-file-write',"
" 'arguments': { 'handle': %" PRId64 ","
" 'buf-b64': '%s' } }", id, enc);
ret = qmp_fd(fixture->fd, cmd);
g_assert_nonnull(ret);
qmp_assert_no_error(ret);
val = qdict_get_qdict(ret, "return");
count = qdict_get_int(val, "count");
eof = qdict_get_bool(val, "eof");
g_assert_cmpint(count, ==, sizeof(helloworld));
g_assert_cmpint(eof, ==, 0);
QDECREF(ret);
g_free(cmd);
cmd = g_strdup_printf("{'execute': 'guest-file-flush',"
" 'arguments': {'handle': %" PRId64 "} }",
id);
ret = qmp_fd(fixture->fd, cmd);
QDECREF(ret);
g_free(cmd);
cmd = g_strdup_printf("{'execute': 'guest-file-close',"
" 'arguments': {'handle': %" PRId64 "} }",
id);
ret = qmp_fd(fixture->fd, cmd);
QDECREF(ret);
g_free(cmd);
path = g_build_filename(fixture->test_dir, "foo", NULL);
f = fopen(path, "r");
g_assert_nonnull(f);
count = fread(tmp, 1, sizeof(tmp), f);
g_assert_cmpint(count, ==, sizeof(helloworld));
tmp[count] = 0;
g_assert_cmpstr(tmp, ==, (char *)helloworld);
fclose(f);
ret = qmp_fd(fixture->fd, "{'execute': 'guest-file-open',"
" 'arguments': { 'path': 'foo', 'mode': 'r' } }");
g_assert_nonnull(ret);
qmp_assert_no_error(ret);
id = qdict_get_int(ret, "return");
QDECREF(ret);
cmd = g_strdup_printf("{'execute': 'guest-file-read',"
" 'arguments': { 'handle': %" PRId64 "} }",
id);
ret = qmp_fd(fixture->fd, cmd);
val = qdict_get_qdict(ret, "return");
count = qdict_get_int(val, "count");
eof = qdict_get_bool(val, "eof");
b64 = qdict_get_str(val, "buf-b64");
g_assert_cmpint(count, ==, sizeof(helloworld));
g_assert(eof);
g_assert_cmpstr(b64, ==, enc);
QDECREF(ret);
g_free(cmd);
g_free(enc);
cmd = g_strdup_printf("{'execute': 'guest-file-read',"
" 'arguments': { 'handle': %" PRId64 "} }",
id);
ret = qmp_fd(fixture->fd, cmd);
val = qdict_get_qdict(ret, "return");
count = qdict_get_int(val, "count");
eof = qdict_get_bool(val, "eof");
b64 = qdict_get_str(val, "buf-b64");
g_assert_cmpint(count, ==, 0);
g_assert(eof);
g_assert_cmpstr(b64, ==, "");
QDECREF(ret);
g_free(cmd);
cmd = g_strdup_printf("{'execute': 'guest-file-seek',"
" 'arguments': { 'handle': %" PRId64 ", "
" 'offset': %d, 'whence': %d } }",
id, 6, SEEK_SET);
ret = qmp_fd(fixture->fd, cmd);
qmp_assert_no_error(ret);
val = qdict_get_qdict(ret, "return");
count = qdict_get_int(val, "position");
eof = qdict_get_bool(val, "eof");
g_assert_cmpint(count, ==, 6);
g_assert(!eof);
QDECREF(ret);
g_free(cmd);
cmd = g_strdup_printf("{'execute': 'guest-file-read',"
" 'arguments': { 'handle': %" PRId64 "} }",
id);
ret = qmp_fd(fixture->fd, cmd);
val = qdict_get_qdict(ret, "return");
count = qdict_get_int(val, "count");
eof = qdict_get_bool(val, "eof");
b64 = qdict_get_str(val, "buf-b64");
g_assert_cmpint(count, ==, sizeof(helloworld) - 6);
g_assert(eof);
dec = g_base64_decode(b64, &count);
g_assert_cmpint(count, ==, sizeof(helloworld) - 6);
g_assert_cmpmem(dec, count, helloworld + 6, sizeof(helloworld) - 6);
g_free(dec);
QDECREF(ret);
g_free(cmd);
cmd = g_strdup_printf("{'execute': 'guest-file-close',"
" 'arguments': {'handle': %" PRId64 "} }",
id);
ret = qmp_fd(fixture->fd, cmd);
QDECREF(ret);
g_free(cmd);
}
| 1threat
|
static int dca_find_frame_end(DCAParseContext * pc1, const uint8_t * buf,
int buf_size)
{
int start_found, i;
uint32_t state;
ParseContext *pc = &pc1->pc;
start_found = pc->frame_start_found;
state = pc->state;
i = 0;
if (!start_found) {
for (i = 0; i < buf_size; i++) {
state = (state << 8) | buf[i];
if (IS_MARKER(state, i, buf, buf_size)) {
if (!pc1->lastmarker || state == pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER) {
start_found = 1;
pc1->lastmarker = state;
break;
}
}
}
}
if (start_found) {
for (; i < buf_size; i++) {
pc1->size++;
state = (state << 8) | buf[i];
if (state == DCA_HD_MARKER && !pc1->hd_pos)
pc1->hd_pos = pc1->size;
if (IS_MARKER(state, i, buf, buf_size) && (state == pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER)) {
if(pc1->framesize > pc1->size)
continue;
if(!pc1->framesize){
pc1->framesize = pc1->hd_pos ? pc1->hd_pos : pc1->size;
}
pc->frame_start_found = 0;
pc->state = -1;
pc1->size = 0;
return i - 3;
}
}
}
pc->frame_start_found = start_found;
pc->state = state;
return END_NOT_FOUND;
}
| 1threat
|
static void toright(unsigned char *dst[3], unsigned char *src[3],
int dststride[3], int srcstride[3],
int w, int h, struct vf_priv_s* p)
{
int k;
for (k = 0; k < 3; k++) {
unsigned char* fromL = src[k];
unsigned char* fromR = src[k];
unsigned char* to = dst[k];
int src = srcstride[k];
int dst = dststride[k];
int ss;
unsigned int dd;
int i;
if (k > 0) {
i = h / 4 - p->skipline / 2;
ss = src * (h / 4 + p->skipline / 2);
dd = w / 4;
} else {
i = h / 2 - p->skipline;
ss = src * (h / 2 + p->skipline);
dd = w / 2;
}
fromR += ss;
for ( ; i > 0; i--) {
int j;
unsigned char* t = to;
unsigned char* sL = fromL;
unsigned char* sR = fromR;
if (p->scalew == 1) {
for (j = dd; j > 0; j--) {
*t++ = (sL[0] + sL[1]) / 2;
sL+=2;
}
for (j = dd ; j > 0; j--) {
*t++ = (sR[0] + sR[1]) / 2;
sR+=2;
}
} else {
for (j = dd * 2 ; j > 0; j--)
*t++ = *sL++;
for (j = dd * 2 ; j > 0; j--)
*t++ = *sR++;
}
if (p->scaleh == 1) {
fast_memcpy(to + dst, to, dst);
to += dst;
}
to += dst;
fromL += src;
fromR += src;
}
}
}
| 1threat
|
Uncaught DOMException: Failed to execute 'postMessage' on 'Window' : <p>I'm getting error </p>
<pre><code>content-script.js:24 Uncaught (in promise) DOMException: Failed to execute 'postMessage' on 'Window': An object could not be cloned.
at Object.t.messageJumpContext (chrome-extension://elgalmkoelokbchhkhacckoklkejnhcd/build/content-script.js:24:9921)
at chrome-extension://elgalmkoelokbchhkhacckoklkejnhcd/build/content-script.js:24:8583
</code></pre>
<p>I haven't used window.postMessage any where in my code. Any idea why this happens?</p>
| 0debug
|
Valgrind reporting a segment overflow : <p>When running my program with valgrind / callgrind I get the following message a lot:</p>
<p><code>==21734== brk segment overflow in thread #1: can't grow to 0x4a39000</code>
(with different addresses)</p>
<p>Note that it is not preceded by a stack overflow message.</p>
<p>I can't find any documentation on this message and I have no idea what is overflowing exactly.</p>
<p>Can anybody help me figure out what the problem is? Is this a problem of valgrind, or of my program?</p>
| 0debug
|
Segmentation fault (code dumped) in this line "dets[count].prob[j] = (prob > thresh) ? prob : 0;" in YOLOv3 : I want to use YOLOv3 algorithm for detection. I am using intel's DE10 Nano FPGA board with Linux installed. When I built YOLOv3 (from original source) and ran it, I am getting error "Segmentation fault(core dumped)". I did lot of googling and research but none of them helped to fix this issue.
I used pre-built weights and configuration files i.e I ran the below command
"./darknet detect cfg/yolov3-tiny.cfg yolov3-tiny.weights data/dog.jpg"
but got the error as stated above.But the same thing runs with out any hiccups on my computer and several others, but not on my Devboard.
Then I started debugging(lot of printf statements) the code from "darknet.py" in "python" directory and found that the error resides in "yolo_layer.c" file
line.no.336-> "dets[count].prob[j] = (prob > thresh) ? prob : 0;"
in "get_yolo_detections" function.
I have no idea how to fix this.
Please help.
I've followed function to function and file to file to see where the error is from.
int get_yolo_detections(layer l, int w, int h, int netw, int neth, float thresh, int *map, int relative, detection *dets)
{
int i,j,n;
float *predictions = l.output;
if (l.batch == 2) avg_flipped_yolo(l);
int count = 0;
for (i = 0; i < l.w*l.h; ++i){
int row = i / l.w;
int col = i % l.w;
for(n = 0; n < l.n; ++n){
int obj_index = entry_index(l, 0, n*l.w*l.h + i, 4);
float objectness = predictions[obj_index];
if(objectness <= thresh) continue;
int box_index = entry_index(l, 0, n*l.w*l.h + i, 0);
dets[count].bbox = get_yolo_box(predictions, l.biases, l.mask[n], box_index, col, row, l.w, l.h, netw, neth, l.w*l.h);
dets[count].objectness = objectness;
dets[count].classes = l.classes;
for(j = 0; j < l.classes; ++j){
int class_index = entry_index(l, 0, n*l.w*l.h + i, 4 + 1 + j);
float prob = objectness*predictions[class_index];
//|||||||error in below line||||||||
dets[count].prob[j] = (prob > thresh) ? prob : 0;
//^^--error in the above line(got from debugging)
}
++count;
}
}
correct_yolo_boxes(dets, count, w, h, netw, neth, relative);
return count;
}
| 0debug
|
Flutter Load Image from Firebase Storage : <p>I see there are a lot of examples on how to upload an image using flutter to firebase storage but nothing on actually downloading/reading/displaying one that's already been uploaded. </p>
<p>In Android, I simply used <code>Glide</code> to display the images, how do I do so in Flutter? Do I use the <code>NetworkImage</code> class and if so, how do I first get the url of the image stored in Storage?</p>
| 0debug
|
Spring boot component scan include a single class : <p>I am using spring component scan to auto detect beans as:</p>
<pre><code>@ComponentScan({"com.org.x, com.org.y"})
</code></pre>
<p>The issue is I want all classes in <code>com.org.x</code> to be scanned but I want a single class, <code>com.org.y.SomeService.class</code>, alone to be scanned from <code>com.org.y</code></p>
<p>How can I achieve this ?</p>
<p>Also apart from using context scan, how can I created this bean and inject in the application context ?</p>
| 0debug
|
static void gen_lwarx(DisasContext *ctx)
{
TCGv t0;
gen_set_access_type(ctx, ACCESS_RES);
t0 = tcg_temp_local_new();
gen_addr_reg_index(ctx, t0);
gen_check_align(ctx, t0, 0x03);
gen_qemu_ld32u(ctx, cpu_gpr[rD(ctx->opcode)], t0);
tcg_gen_mov_tl(cpu_reserve, t0);
tcg_temp_free(t0);
}
| 1threat
|
void watchdog_pc_init(PCIBus *pci_bus)
{
if (watchdog)
watchdog->wdt_pc_init(pci_bus);
}
| 1threat
|
what does this error mean ? :expected an indented block mean? : my code is the following
def value(one,two):
if one < two:
return two
else:
return one
every time i try to run it it give the following error :IndentationError: expected an indented block
i tried rewriting the code and still nothing happened
| 0debug
|
void helper_dcbz(CPUPPCState *env, target_ulong addr, uint32_t is_dcbzl)
{
int dcbz_size = env->dcache_line_size;
#if defined(TARGET_PPC64)
if (!is_dcbzl &&
(env->excp_model == POWERPC_EXCP_970) &&
((env->spr[SPR_970_HID5] >> 7) & 0x3) == 1) {
dcbz_size = 32;
}
#endif
do_dcbz(env, addr, dcbz_size, GETPC());
}
| 1threat
|
static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVVdiState *s = bs->opaque;
VdiHeader header;
size_t bmap_size;
int ret;
logout("\n");
ret = bdrv_read(bs->file, 0, (uint8_t *)&header, 1);
if (ret < 0) {
goto fail;
}
vdi_header_to_cpu(&header);
#if defined(CONFIG_VDI_DEBUG)
vdi_header_print(&header);
#endif
if (header.disk_size % SECTOR_SIZE != 0) {
logout("odd disk size %" PRIu64 " B, round up\n", header.disk_size);
header.disk_size += SECTOR_SIZE - 1;
header.disk_size &= ~(SECTOR_SIZE - 1);
}
if (header.signature != VDI_SIGNATURE) {
error_setg(errp, "Image not in VDI format (bad signature %08x)", header.signature);
ret = -EINVAL;
goto fail;
} else if (header.version != VDI_VERSION_1_1) {
error_setg(errp, "unsupported VDI image (version %u.%u)",
header.version >> 16, header.version & 0xffff);
ret = -ENOTSUP;
goto fail;
} else if (header.offset_bmap % SECTOR_SIZE != 0) {
error_setg(errp, "unsupported VDI image (unaligned block map offset "
"0x%x)", header.offset_bmap);
ret = -ENOTSUP;
goto fail;
} else if (header.offset_data % SECTOR_SIZE != 0) {
error_setg(errp, "unsupported VDI image (unaligned data offset 0x%x)",
header.offset_data);
ret = -ENOTSUP;
goto fail;
} else if (header.sector_size != SECTOR_SIZE) {
error_setg(errp, "unsupported VDI image (sector size %u is not %u)",
header.sector_size, SECTOR_SIZE);
ret = -ENOTSUP;
goto fail;
} else if (header.block_size != 1 * MiB) {
error_setg(errp, "unsupported VDI image (sector size %u is not %u)",
header.block_size, 1 * MiB);
ret = -ENOTSUP;
goto fail;
} else if (header.disk_size >
(uint64_t)header.blocks_in_image * header.block_size) {
error_setg(errp, "unsupported VDI image (disk size %" PRIu64 ", "
"image bitmap has room for %" PRIu64 ")",
header.disk_size,
(uint64_t)header.blocks_in_image * header.block_size);
ret = -ENOTSUP;
goto fail;
} else if (!uuid_is_null(header.uuid_link)) {
error_setg(errp, "unsupported VDI image (non-NULL link UUID)");
ret = -ENOTSUP;
goto fail;
} else if (!uuid_is_null(header.uuid_parent)) {
error_setg(errp, "unsupported VDI image (non-NULL parent UUID)");
ret = -ENOTSUP;
goto fail;
}
bs->total_sectors = header.disk_size / SECTOR_SIZE;
s->block_size = header.block_size;
s->block_sectors = header.block_size / SECTOR_SIZE;
s->bmap_sector = header.offset_bmap / SECTOR_SIZE;
s->header = header;
bmap_size = header.blocks_in_image * sizeof(uint32_t);
bmap_size = (bmap_size + SECTOR_SIZE - 1) / SECTOR_SIZE;
s->bmap = g_malloc(bmap_size * SECTOR_SIZE);
ret = bdrv_read(bs->file, s->bmap_sector, (uint8_t *)s->bmap, bmap_size);
if (ret < 0) {
goto fail_free_bmap;
}
error_set(&s->migration_blocker,
QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
"vdi", bs->device_name, "live migration");
migrate_add_blocker(s->migration_blocker);
return 0;
fail_free_bmap:
g_free(s->bmap);
fail:
return ret;
}
| 1threat
|
if data1.has_key('M_Flag')=="U": AttributeError: 'str' object has no attribute 'has_key' : import datetime
import xml.etree.cElementTree as etree
import xlsxwriter
import os
from csv import DictWriter
import urllib2
import time, sys
import pandas as pd
url = "http://farmer.gov.in/ForecastService.asmx/forecastservice?date=16-08-2017"
response = urllib2.urlopen(url)
xmlDocData = response.read()
xmlDocTree = etree.XML(xmlDocData)
sections = ['Srno',
'State','Statecd',
'District','IssuedOn','Day','normal_rainfall',
'normal_temp_max',
'normal_temp_min','normal_cloud_cover',
'normal_rh_max','normal_rh_min',
'normal_windspeed','normal_winddirection',
'M_rainfall','M_tempmax',
'M_Cloudcover','M_rhmax',
'M_rhmin','M_Windspeed',
'M_Winddirection','M_Flag']
fetched = dict()
for sec in sections:
fetched[sec]=[]
for item in xmlDocTree.iter(sec):
fetched[sec].append(item.text)
workbook = xlsxwriter.Workbook("data.xlsx")
worksheet = workbook.add_worksheet()
row = 0
col = 0
for sec in sections:
worksheet.write(row, col, str(sec) )
col = col+1
row = 1
col=0
maharashtra = []
maharashtradata = []
for sec in sections:
row = 1
for item in xmlDocTree.iter( sec ):
if "AHMEDNAGAR" in item.text:
maharashtra.append(row)
row = row + 1
col = col+1
for entry in maharashtra:
col=0
entrydata = {}
for sec in sections:
entrydata[sec] = fetched[sec][entry]
col = col + 1
#maharashtradata.append(entrydata)
for data1 in entrydata:
if data1.has_key('M_Flag')=="U":
print "Hello"
row = 1
col=0
for sec in sections:
row=1
for data in maharashtradata:
worksheet.write(row, col, data[sec])
row = row + 1
col = col+1
workbook.close()
I am trying to extract data from XML and applying filters I am successfully able put one filter as "if "AHMEDNAGAR" in item.text:" but not able to apply multiple filters
I am getting below error!
Where am I getting wrong?
if data1.has_key('M_Flag')=="U":
AttributeError: 'str' object has no attribute 'has_key'
| 0debug
|
static av_cold int adpcm_encode_init(AVCodecContext *avctx)
{
ADPCMEncodeContext *s = avctx->priv_data;
uint8_t *extradata;
int i;
if (avctx->channels > 2)
return -1;
if (avctx->trellis && (unsigned)avctx->trellis > 16U) {
av_log(avctx, AV_LOG_ERROR, "invalid trellis size\n");
return -1;
}
if (avctx->trellis) {
int frontier = 1 << avctx->trellis;
int max_paths = frontier * FREEZE_INTERVAL;
FF_ALLOC_OR_GOTO(avctx, s->paths,
max_paths * sizeof(*s->paths), error);
FF_ALLOC_OR_GOTO(avctx, s->node_buf,
2 * frontier * sizeof(*s->node_buf), error);
FF_ALLOC_OR_GOTO(avctx, s->nodep_buf,
2 * frontier * sizeof(*s->nodep_buf), error);
FF_ALLOC_OR_GOTO(avctx, s->trellis_hash,
65536 * sizeof(*s->trellis_hash), error);
}
avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id);
switch (avctx->codec->id) {
case CODEC_ID_ADPCM_IMA_WAV:
avctx->frame_size = (BLKSIZE - 4 * avctx->channels) * 8 /
(4 * avctx->channels) + 1;
avctx->block_align = BLKSIZE;
break;
case CODEC_ID_ADPCM_IMA_QT:
avctx->frame_size = 64;
avctx->block_align = 34 * avctx->channels;
break;
case CODEC_ID_ADPCM_MS:
avctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 /
avctx->channels + 2;
avctx->block_align = BLKSIZE;
avctx->extradata_size = 32;
extradata = avctx->extradata = av_malloc(avctx->extradata_size);
if (!extradata)
return AVERROR(ENOMEM);
bytestream_put_le16(&extradata, avctx->frame_size);
bytestream_put_le16(&extradata, 7);
for (i = 0; i < 7; i++) {
bytestream_put_le16(&extradata, ff_adpcm_AdaptCoeff1[i] * 4);
bytestream_put_le16(&extradata, ff_adpcm_AdaptCoeff2[i] * 4);
}
break;
case CODEC_ID_ADPCM_YAMAHA:
avctx->frame_size = BLKSIZE * avctx->channels;
avctx->block_align = BLKSIZE;
break;
case CODEC_ID_ADPCM_SWF:
if (avctx->sample_rate != 11025 &&
avctx->sample_rate != 22050 &&
avctx->sample_rate != 44100) {
av_log(avctx, AV_LOG_ERROR, "Sample rate must be 11025, "
"22050 or 44100\n");
goto error;
}
avctx->frame_size = 512 * (avctx->sample_rate / 11025);
break;
default:
goto error;
}
avctx->coded_frame = avcodec_alloc_frame();
return 0;
error:
av_freep(&s->paths);
av_freep(&s->node_buf);
av_freep(&s->nodep_buf);
av_freep(&s->trellis_hash);
return -1;
}
| 1threat
|
static void qdev_set_legacy_property(DeviceState *dev, Visitor *v, void *opaque,
const char *name, Error **errp)
{
Property *prop = opaque;
if (dev->state != DEV_STATE_CREATED) {
error_set(errp, QERR_PERMISSION_DENIED);
return;
}
if (prop->info->parse) {
Error *local_err = NULL;
char *ptr = NULL;
visit_type_str(v, &ptr, name, &local_err);
if (!local_err) {
int ret;
ret = prop->info->parse(dev, prop, ptr);
if (ret != 0) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE,
name, prop->info->name);
}
g_free(ptr);
} else {
error_propagate(errp, local_err);
}
} else {
error_set(errp, QERR_PERMISSION_DENIED);
}
}
| 1threat
|
static int net_init_nic(QemuOpts *opts,
Monitor *mon,
const char *name,
VLANState *vlan)
{
int idx;
NICInfo *nd;
const char *netdev;
idx = nic_get_free_idx();
if (idx == -1 || nb_nics >= MAX_NICS) {
qemu_error("Too Many NICs\n");
return -1;
}
nd = &nd_table[idx];
memset(nd, 0, sizeof(*nd));
if ((netdev = qemu_opt_get(opts, "netdev"))) {
nd->netdev = qemu_find_netdev(netdev);
if (!nd->netdev) {
qemu_error("netdev '%s' not found\n", netdev);
return -1;
}
} else {
assert(vlan);
nd->vlan = vlan;
}
if (name) {
nd->name = qemu_strdup(name);
}
if (qemu_opt_get(opts, "model")) {
nd->model = qemu_strdup(qemu_opt_get(opts, "model"));
}
if (qemu_opt_get(opts, "addr")) {
nd->devaddr = qemu_strdup(qemu_opt_get(opts, "addr"));
}
nd->macaddr[0] = 0x52;
nd->macaddr[1] = 0x54;
nd->macaddr[2] = 0x00;
nd->macaddr[3] = 0x12;
nd->macaddr[4] = 0x34;
nd->macaddr[5] = 0x56 + idx;
if (qemu_opt_get(opts, "macaddr") &&
net_parse_macaddr(nd->macaddr, qemu_opt_get(opts, "macaddr")) < 0) {
qemu_error("invalid syntax for ethernet address\n");
return -1;
}
nd->nvectors = qemu_opt_get_number(opts, "vectors", NIC_NVECTORS_UNSPECIFIED);
if (nd->nvectors != NIC_NVECTORS_UNSPECIFIED &&
(nd->nvectors < 0 || nd->nvectors > 0x7ffffff)) {
qemu_error("invalid # of vectors: %d\n", nd->nvectors);
return -1;
}
nd->used = 1;
if (vlan) {
nd->vlan->nb_guest_devs++;
}
nb_nics++;
return idx;
}
| 1threat
|
Multiprocessing example giving AttributeError : <p>I am trying to implement multiprocessing in my code, and so, I thought that I would start my learning with some examples. I used the first example found in this <a href="https://docs.python.org/3/library/multiprocessing.html#introduction" rel="noreferrer">documentation</a>.</p>
<pre><code>from multiprocessing import Pool
def f(x):
return x*x
if __name__ == '__main__':
with Pool(5) as p:
print(p.map(f, [1, 2, 3]))
</code></pre>
<p>When I run the above code I get an <code>AttributeError: can't get attribute 'f' on <module '__main__' (built-in)></code>. I do not know why I am getting this error. I am also using Python 3.5 if that helps.</p>
| 0debug
|
Asp.net 5 (and MVC 6) hosting : <p>So I just recently started developing a website in Asp.net 5 (mvc 6) and I went to host it on my WinHost site when I realized that they don't support it. At least that's what their technical support said. I assume Microsoft Azure supports it but for a small website and a SQL server, that is $15/month, which is over triple what I was paying for my WinHost. </p>
<p>Does anyone know of any other solutions for hosting a asp.net 5 site?</p>
<p>Thanks</p>
<p>syd</p>
| 0debug
|
static inline void gen_lods(DisasContext *s, int ot)
{
gen_string_movl_A0_ESI(s);
gen_op_ld_T0_A0(ot + s->mem_index);
gen_op_mov_reg_T0(ot, R_EAX);
gen_op_movl_T0_Dshift[ot]();
#ifdef TARGET_X86_64
if (s->aflag == 2) {
gen_op_addq_ESI_T0();
} else
#endif
if (s->aflag) {
gen_op_addl_ESI_T0();
} else {
gen_op_addw_ESI_T0();
}
}
| 1threat
|
Force to show invalid-feedback in Bootstrap 4 : <p>Let's say I have HTML like this:</p>
<pre><code>...
<div class="form-group">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="invalidCheck">
<label class="form-check-label" for="invalidCheck">
Agree to something
</label>
</div>
<div class="invalid-feedback">
I am outside of `form-check`!
</div>
</div>
...
</code></pre>
<p>I want to <strong>force</strong> to show the <code><div class="invalid-feedback">...</code> without using JavaScript (want to use Bootstrap CSS only). And I know I can use CSS classes like <code>was-validated</code> or <code>is-invalid</code>, but <code>invalid-feedback</code> is outside of <code>form-check</code>. Is there an easy and simple way to show <code>invalid-feedback</code> by adding Bootstrap related CSS classes?</p>
<p>I found one solution:</p>
<pre><code><div class="invalid-feedback d-block">
Now I am visible!
</div>
</code></pre>
<p>But I feel like it's a hacky solution. Please advise!</p>
| 0debug
|
What the general purpose when using cin.clear? : <p>I am a <strong>beginner</strong> to c++, and I just can't wrap my head around whats cin.ignore & cin.clear, they make absolutely no sense to me. When you explain this to me, please be <strong>very descriptive</strong> </p>
| 0debug
|
static int dvbsub_read_4bit_string(uint8_t *destbuf, int dbuf_len,
const uint8_t **srcbuf, int buf_size,
int non_mod, uint8_t *map_table)
{
GetBitContext gb;
int bits;
int run_length;
int pixels_read = 0;
init_get_bits(&gb, *srcbuf, buf_size << 3);
while (get_bits_count(&gb) < buf_size << 3 && pixels_read < dbuf_len) {
bits = get_bits(&gb, 4);
if (bits) {
if (non_mod != 1 || bits != 1) {
if (map_table)
*destbuf++ = map_table[bits];
else
*destbuf++ = bits;
}
pixels_read++;
} else {
bits = get_bits1(&gb);
if (bits == 0) {
run_length = get_bits(&gb, 3);
if (run_length == 0) {
(*srcbuf) += (get_bits_count(&gb) + 7) >> 3;
return pixels_read;
}
run_length += 2;
if (map_table)
bits = map_table[0];
else
bits = 0;
while (run_length-- > 0 && pixels_read < dbuf_len) {
*destbuf++ = bits;
pixels_read++;
}
} else {
bits = get_bits1(&gb);
if (bits == 0) {
run_length = get_bits(&gb, 2) + 4;
bits = get_bits(&gb, 4);
if (non_mod == 1 && bits == 1)
pixels_read += run_length;
else {
if (map_table)
bits = map_table[bits];
while (run_length-- > 0 && pixels_read < dbuf_len) {
*destbuf++ = bits;
pixels_read++;
}
}
} else {
bits = get_bits(&gb, 2);
if (bits == 2) {
run_length = get_bits(&gb, 4) + 9;
bits = get_bits(&gb, 4);
if (non_mod == 1 && bits == 1)
pixels_read += run_length;
else {
if (map_table)
bits = map_table[bits];
while (run_length-- > 0 && pixels_read < dbuf_len) {
*destbuf++ = bits;
pixels_read++;
}
}
} else if (bits == 3) {
run_length = get_bits(&gb, 8) + 25;
bits = get_bits(&gb, 4);
if (non_mod == 1 && bits == 1)
pixels_read += run_length;
else {
if (map_table)
bits = map_table[bits];
while (run_length-- > 0 && pixels_read < dbuf_len) {
*destbuf++ = bits;
pixels_read++;
}
}
} else if (bits == 1) {
pixels_read += 2;
if (map_table)
bits = map_table[0];
else
bits = 0;
if (pixels_read <= dbuf_len) {
*destbuf++ = bits;
*destbuf++ = bits;
}
} else {
if (map_table)
bits = map_table[0];
else
bits = 0;
*destbuf++ = bits;
pixels_read ++;
}
}
}
}
}
if (get_bits(&gb, 8))
av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n");
(*srcbuf) += (get_bits_count(&gb) + 7) >> 3;
return pixels_read;
}
| 1threat
|
How can I write a python code for this question? : <p>A snail falls at the bottom of a 125 cm well. Each day the snail rises 30 cm. But at night, while sleeping, slides 20 cm because the walls are wet. How many days does it take to escape from the well?</p>
| 0debug
|
I want given array of unique data given those example : <p>I have one array
like
var data= [1,1,3,4,2,4,5,6,7,5,4]
and I need the unique array of data without a loop or any Lodash and underscore js function</p>
| 0debug
|
static inline void RENAME(rgb32tobgr16)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#if COMPILE_TEMPLATE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm__ volatile(
"movq %0, %%mm7 \n\t"
"movq %1, %%mm6 \n\t"
::"m"(red_16mask),"m"(green_16mask));
mm_end = end - 15;
while (s < mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movd %1, %%mm0 \n\t"
"movd 4%1, %%mm3 \n\t"
"punpckldq 8%1, %%mm0 \n\t"
"punpckldq 12%1, %%mm3 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm3, %%mm4 \n\t"
"movq %%mm3, %%mm5 \n\t"
"psllq $8, %%mm0 \n\t"
"psllq $8, %%mm3 \n\t"
"pand %%mm7, %%mm0 \n\t"
"pand %%mm7, %%mm3 \n\t"
"psrlq $5, %%mm1 \n\t"
"psrlq $5, %%mm4 \n\t"
"pand %%mm6, %%mm1 \n\t"
"pand %%mm6, %%mm4 \n\t"
"psrlq $19, %%mm2 \n\t"
"psrlq $19, %%mm5 \n\t"
"pand %2, %%mm2 \n\t"
"pand %2, %%mm5 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm4, %%mm3 \n\t"
"por %%mm2, %%mm0 \n\t"
"por %%mm5, %%mm3 \n\t"
"psllq $16, %%mm3 \n\t"
"por %%mm3, %%mm0 \n\t"
MOVNTQ" %%mm0, %0 \n\t"
:"=m"(*d):"m"(*s),"m"(blue_16mask):"memory");
d += 4;
s += 16;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
#endif
while (s < end) {
register int rgb = *(const uint32_t*)s; s += 4;
*d++ = ((rgb&0xF8)<<8) + ((rgb&0xFC00)>>5) + ((rgb&0xF80000)>>19);
}
}
| 1threat
|
Convert Sql to Laravel Query Builder : how to convert this query to Laravel querry builder
SELECT request_product_attributes.product_id,
products.name,
COUNT(request_product_attributes.product_id) as no_of_count from request_product_attributes,products
where request_product_attributes.product_id=products.id
GROUP BY request_product_attributes.product_id
ORDER BY no_of_count
DESC LIMIT 0,10
| 0debug
|
static inline void tcg_out_tlb_load(TCGContext *s, TCGReg addrlo, TCGReg addrhi,
int mem_index, TCGMemOp opc,
tcg_insn_unit **label_ptr, int which)
{
const TCGReg r0 = TCG_REG_L0;
const TCGReg r1 = TCG_REG_L1;
TCGType ttype = TCG_TYPE_I32;
TCGType tlbtype = TCG_TYPE_I32;
int trexw = 0, hrexw = 0, tlbrexw = 0;
int s_mask = (1 << (opc & MO_SIZE)) - 1;
bool aligned = (opc & MO_AMASK) == MO_ALIGN || s_mask == 0;
if (TCG_TARGET_REG_BITS == 64) {
if (TARGET_LONG_BITS == 64) {
ttype = TCG_TYPE_I64;
trexw = P_REXW;
}
if (TCG_TYPE_PTR == TCG_TYPE_I64) {
hrexw = P_REXW;
if (TARGET_PAGE_BITS + CPU_TLB_BITS > 32) {
tlbtype = TCG_TYPE_I64;
tlbrexw = P_REXW;
}
}
}
tcg_out_mov(s, tlbtype, r0, addrlo);
if (aligned) {
tcg_out_mov(s, ttype, r1, addrlo);
} else {
tcg_out_modrm_offset(s, OPC_LEA + trexw, r1, addrlo, s_mask);
}
tcg_out_shifti(s, SHIFT_SHR + tlbrexw, r0,
TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS);
tgen_arithi(s, ARITH_AND + trexw, r1,
TARGET_PAGE_MASK | (aligned ? s_mask : 0), 0);
tgen_arithi(s, ARITH_AND + tlbrexw, r0,
(CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS, 0);
tcg_out_modrm_sib_offset(s, OPC_LEA + hrexw, r0, TCG_AREG0, r0, 0,
offsetof(CPUArchState, tlb_table[mem_index][0])
+ which);
tcg_out_modrm_offset(s, OPC_CMP_GvEv + trexw, r1, r0, 0);
tcg_out_mov(s, ttype, r1, addrlo);
tcg_out_opc(s, OPC_JCC_long + JCC_JNE, 0, 0, 0);
label_ptr[0] = s->code_ptr;
s->code_ptr += 4;
if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) {
tcg_out_modrm_offset(s, OPC_CMP_GvEv, addrhi, r0, 4);
tcg_out_opc(s, OPC_JCC_long + JCC_JNE, 0, 0, 0);
label_ptr[1] = s->code_ptr;
s->code_ptr += 4;
}
tcg_out_modrm_offset(s, OPC_ADD_GvEv + hrexw, r1, r0,
offsetof(CPUTLBEntry, addend) - which);
}
| 1threat
|
CSS Advanced Positioning; Need Help Please : I am creating a website and am working on a hover animation for css.
<html>
...
<body>
<div id ="outer_container">
<div id="inner_container">
<img id="imageOne"/>
</div>
</div>
...
</body>
<html>
** outer_container takes up the width of the page **
inner_container is a child of outer_container and is aligned in the center of it vertically.
The css animation displays a hidden element named 'blur' which is basically a background color block that takes up the width and height of the image. On hover "blur" appears on top of the <img/> tag inside of the inner_container div.
Unfortunately the block element "blur" is placed over the top of the the image tag using "position : relative / position : absolute" causing it to interfere with the display : inline-block used to align the inner_container div with the outer_container div.
I'm looking for a solution that would allow the hidden element to be displayed on top of the <img/> tag in the inner_container div without using position : relative / position : absolute so that I can still align the inner_container div inside of the outer_container div.
The actual page code can be found here :
http://jsbin.com/zawiqarijo/1/edit?html,css,output
Thank you for your help ahead of time!
| 0debug
|
how to send a list in python requests GET : <p>I'm trying to GET some data from the server. I'm doing a GET with the python requests library:</p>
<pre><code>my_list = #a list ['x', 'y', 'z']
payload = {'id_list': my_list}
requests.get(url, params=payload)
</code></pre>
<p>my server accepts a url: <code>https://url.com/download?id_list</code></p>
<p>but when I send this get request, I get an error:</p>
<blockquote>
<p><code><h1>400 Bad Request</h1>
The server cannot understand the request due to malformed syntax.
<br /><br /> Got multiple values for a parameter:<br />
<pre>id_list</pre></code></p>
</blockquote>
<p>I saw the log and the request looks like this:</p>
<p><code>url/download?id_list=x&id_list=y&id_list=z</code></p>
<p>how can I fix this?</p>
| 0debug
|
Remove duplicates from circular linked list : My code is given below. It appends some numbers to the circular list. My program works fine. It gives exact output of [5,3,3] or any numbers entered. But I want to make some changes in the output. without adding any new function what kind of changes to make in the def append(....) and def add_before(...) so it gives unique number which means it gets rid of the duplicates. for example will give [5,3]
class CirList:
def __init__(self):
head_node = NodeDLL(None)
head_node.next = head_node
head_node.prev = head_node
self.__head = head_node
def append(self, item):
curr = self.__head
new_node = NodeDLL(item, curr, curr.get_prev())
curr.set_prev(new_node)
new_node.get_prev().set_next(new_node)
def add_before(self, item, old_item):
curr = self.__head.next
found = False
while curr.get_data() != None and not found:
if curr.get_data() == old_item:
found = True
else:
curr = curr.get_next()
if found:
new_node = NodeDLL(item, curr, curr.get_prev())
curr.set_prev(new_node)
new_node.get_prev().set_next(new_node)
return found
def remove(self, item):
curr = self.__head.next
found = False
while curr.get_data() != None and not found:
if curr.get_data() == item:
found = True
else:
curr = curr.get_next()
if found:
curr.get_prev().set_next(curr.get_next())
curr.get_next().set_prev(curr.get_prev())
def printall(self):
curr = self.__head.next
while curr.get_data() != None:
print(curr.get_data(), end=" ")
curr = curr.get_next()
print()
def __str__(self):
result = "["
curr = self.__head.next
while curr.get_data() != None:
result += str(curr.get_data()) + " "
curr = curr.get_next()
result = result.rstrip(" ")
result += "]"
return result
Test
listA = CirList()
listA.append(5)
listA.append(3)
listA.append(3)
print(listA)
| 0debug
|
Why does Exception from async void crash the app but from async Task is swallowed : <p>I understand that an <code>async Task</code>'s Exceptions can be caught by:</p>
<pre><code>try { await task; }
catch { }
</code></pre>
<p>while an <code>async void</code>'s cannot because it cannot be awaited.</p>
<p>But why is it that when the async <strong>Task</strong> is not awaited (just like the async <strong>void</strong> one) the <code>Exception</code> is swallowed, while the <strong>void</strong>'s one crashes the application?</p>
<p><strong>Caller</strong>: <code>ex();</code></p>
<p><strong>Called</strong>:</p>
<pre><code>async void ex() { throw new Exception(); }
async Task ex() { throw new Exception(); }
</code></pre>
| 0debug
|
static uint64_t omap_tipb_bridge_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
struct omap_tipb_bridge_s *s = (struct omap_tipb_bridge_s *) opaque;
if (size < 2) {
return omap_badwidth_read16(opaque, addr);
}
switch (addr) {
case 0x00:
return s->control;
case 0x04:
return s->alloc;
case 0x08:
return s->buffer;
case 0x0c:
return s->enh_control;
case 0x10:
case 0x14:
case 0x18:
return 0xffff;
case 0x1c:
return 0x00f8;
}
OMAP_BAD_REG(addr);
return 0;
}
| 1threat
|
Filter data based on condition from collection in the fastest way in java : i have a custom array list with almost 600 entry what my requirement is i need to filter some value based on some condition i try basic loop stuff but its very time taking process, what i want is the fastest way to filter the data.
public class MyModel {
private boolean attempeted = false;
private String answer;
public MyModel(String answer) {
this.answer = answer;
}
public void setAttempted(boolean attempeted) {
this.attempeted = attempeted;
}
public String getAnswer() {
return answer;
}
public boolean isAttempeted() {
return attempeted;
}
}
The above is my model what i want is i need to get only data having **attempeted value true**
what i did is
ArrayList<TestAnswerModel>myMainArrayList=array which contain all my data
ArrayList<TestAnswerModel>filterArrayList=new ArrayList<>();
for(int i=0;i<myMainArrayList.size();i++)
{
if(myMainArrayList.get(i).isAttempeted()) {
filterArrayList.add(myMainArrayList.get(i))
}
}
The above is working fine but if my data is too large it is take lot of time also some times the data will be 600 and the attempted value only true for 2 or 3 values so this looping will happened without any result.
What i want any fastest method to filter the data,i search the web and stack overflow but i don't find a good solution am new to java and programming world please help me out.
Thank you
| 0debug
|
Entrypoint undefined = index.html using HtmlWebpackPlugin : <p>I'm using Webpack 4 and I'm creating the config file, when trying to use the <code>HtmlWebpackPlugin</code> it got this on the console: <code>Entrypoint undefined = index.html</code>, it opens the browser and the HTML does appear but I'm getting this weird message on the console, how to solve this?</p>
<p>That is how my config file looks like:</p>
<pre><code>'use strict'
const webpack = require('webpack')
const { join, resolve } = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
mode: 'development', // dev
devtool: 'cheap-module-eval-source-map', // dev
entry: join(__dirname, 'src', 'index.js'),
output: {
filename: 'bundle.js',
path: resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
}
]
},
resolve: {
extensions: ['*', '.js', '.jsx']
},
devServer: {
contentBase: resolve(__dirname, 'build')
},
plugins: [
new webpack.ProgressPlugin(),
new HtmlWebpackPlugin({
template: join(__dirname, 'public', 'index.html')
}),
new webpack.HotModuleReplacementPlugin(), // dev
new webpack.NoEmitOnErrorsPlugin() // dev
]
}
</code></pre>
| 0debug
|
Coroutine *qemu_coroutine_new(void)
{
CoroutineThreadState *s = coroutine_get_thread_state();
Coroutine *co;
co = QLIST_FIRST(&s->pool);
if (co) {
QLIST_REMOVE(co, pool_next);
s->pool_size--;
} else {
co = coroutine_new();
}
return co;
}
| 1threat
|
Detect "Ubuntu on Windows" vs native Ubuntu from bash script : <p>Can a bash script detect if it's running in "Ubuntu on Windows" vs native Ubuntu? If so, how?</p>
<p>I ran <code>env</code> on both machines and didn't see any obvious environmental variable differences. I could test for the existence of the <code>/mnt/c</code> directory, but that is not foolproof because that directory could potentially also be present on native Ubuntu.</p>
| 0debug
|
SSMS crashes when try to modify database diagram (v18.2) : <p>When I try to modify a database diagram created before the application restart and crashes when trying to access.
It happen only when I save the diagram and close the application. When I try to reopen it throws me an error then restart the SSMS.</p>
<p>I'm running SQL Server 14.0.100 Express Edition.</p>
<p>I reviewed the Microsoft Event Viewer and I get this:</p>
<blockquote>
<p>Faulting application name: Ssms.exe, version: 2019.150.18142.0, time stamp: 0x5d3573be
Faulting module name: DataDesigners.dll, version: 2019.150.18142.0, time stamp: 0x5d3573f0
Exception code: 0xc0000005
Fault offset: 0x00004be8
Faulting process id: 0x5ec8
Faulting application start time: 0x01d56d761e232f6c
Faulting application path: C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\Ssms.exe
Faulting module path: C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\Tools\VDT\DataDesigners.dll
Report Id: e797c8be-6448-4547-9f6f-146cd92d8178
Faulting package full name:
Faulting package-relative application ID: </p>
</blockquote>
| 0debug
|
Configure https agent to allow only TLS1.2 for outgoing requests : <p>I'm making HTTPS connections from a node app, using a client certificate: </p>
<pre><code>var options = {
hostname: 'https://my-server.com',
port: 443,
path: '/',
method: 'GET',
key: fs.readFileSync('client1-key.pem'),
cert: fs.readFileSync('client1-crt.pem'),
ca: fs.readFileSync('ca-crt.pem') };
var req = https.request(options, res => {
[...]
});
</code></pre>
<p>Everything is working fine, however I want to add code to ensure only TLS 1.2 connections are allowed. I cannot find any way to configure this in the <a href="https://nodejs.org/api/http.html#http_class_http_agent" rel="noreferrer">https.agent</a> options, or elsewhere. Is it possible to configure this, or do I have to make a connection and then <a href="https://nodejs.org/api/tls.html#tls_tlssocket_getprotocol" rel="noreferrer">query the protocol</a> version, with something like:</p>
<p><code>res.socket.getProtocol() === 'TLSv1.2'</code></p>
<p>and abort the connection if the protocol is not satisfactory?</p>
| 0debug
|
Creating a row for table name : <p>I have a table as such:</p>
<pre><code> +-----------+----------------+----------+
| | Type 1 | Type 2 |
+-----------+----------------+----------+
| Mean | 31,2 | 16,0 |
| Median | 51,3 | 16,0 |
| Max | 40,4 | 6,0 |
| Min | 100,0 | 16,0 |
| Q1 | 34,6 | 16,0 |
| Q3 | 16,0 | 16,0 |
+---+------------+-----------+----------+
</code></pre>
<p>How can I add a title to it, so it becomes:</p>
<pre><code> +-----------+----------------+----------+
| INSERT TABLE TITLE HERE |
+-----------+----------------+----------+
| | Type 1 | Type 2 |
+-----------+----------------+----------+
| Mean | 31,2 | 16,0 |
| Median | 51,3 | 16,0 |
| Max | 40,4 | 6,0 |
| Min | 100,0 | 16,0 |
| Q1 | 34,6 | 16,0 |
| Q3 | 16,0 | 16,0 |
+---+------------+-----------+----------+
</code></pre>
| 0debug
|
VBA Looping through a Collection : <p>I have a collection of files that I selected in the SelectManyFiles function and I want to run multiple private subs on each Drawing in the collection function. Here's my code:</p>
<pre><code>Sub Main()
Dim Drawing As Object
Dim Drawings As Collection
Set Drawings = SelectManyFiles()
For Each Drawing In Drawings
'Call multiple private subs to run on each drawing
Next Drawing
End Sub
</code></pre>
<p>I think there's something wrong with the loop but not sure exactly! Any help is appreciated.</p>
| 0debug
|
R Word Count - matching all combination of one string in another string : <p>I am trying to count all combinations of matching/fuzzy matching first string column to second string column in a data frame</p>
<p>Eg:<br>
string1 = "USA Canada UK Australia Japan India"
string2 = "USA Canada India UK Australia China Brazil France"</p>
<p>Expected results </p>
<ul>
<li><p>Single word match count = 5 (USA Canada UK Australia India) matched </p></li>
<li><p>Two word match count = 2 (USA Canada, UK Australia) consecutive words matched </p></li>
<li><p>Three word match count = 0 </p></li>
<li><p>Four word match count = 0 </p></li>
<li><p>Five word match count = 0 </p></li>
<li><p>Six word match count = 0 </p></li>
<li><p>In total = 5 + 2 = 7</p></li>
</ul>
<p>Thank you for your time and great someone can help to write this function or point me to use any existing package</p>
| 0debug
|
How to test spring configuration classes? : <p>I have a spring application whith configuration classes where instance the beans.</p>
<p>Aplication class:</p>
<pre><code>@Configuration
@EnableAspectJAutoProxy
@EnableSpringDataWebSupport
@EnableTransactionManagement
@ComponentScan(basePackageClasses = Application.class)
@PropertySource(value = {"classpath:foo.properties"})
@EnableJpaRepositories(basePackageClasses = Application.class)
@EnableJpaAuditing
public class Application {
@Inject
private Environment env;
@Bean
JndiTemplate jndiTemplate() {
return new JndiTemplate();
}
@Bean
public DataSource dataSource() {
DataSource dataSource = getDataSource();
if (dataSource == null) {
dataSource = new BasicDataSource();
((BasicDataSource) dataSource).setUsername(env.getProperty("jdbc.user"));
((BasicDataSource) dataSource).setPassword(env.getProperty("jdbc.password""));
((BasicDataSource) dataSource).setDriverClassName(env.getProperty("jdbc.driverClassName"));
((BasicDataSource) dataSource).setUrl(env.getProperty("jdbc.url"));
}
return dataSource;
}
@Bean
public PlatformTransactionManager transactionManager() {
EntityManagerFactory factory = entityManagerFactory().getObject();
return new JpaTransactionManager(factory);
}
//....
}
</code></pre>
<p>MvcConfiguration class:</p>
<pre><code>@Configuration
@ComponentScan(basePackageClasses = Application.class, includeFilters = @Filter({Controller.class, Component.class}), useDefaultFilters = true)
class MvcConfiguration extends WebMvcConfigurationSupport {
private static final String MESSAGES = "classpath:/i18n";
private static final String VIEW_PREFIX = "/WEB-INF/views/";
@Inject
private Environment env;
@Override
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
RequestMappingHandlerMapping requestMappingHandlerMapping = super.requestMappingHandlerMapping();
requestMappingHandlerMapping.setUseSuffixPatternMatch(false);
requestMappingHandlerMapping.setUseTrailingSlashMatch(true);
return requestMappingHandlerMapping;
}
@Bean(name = "messageSource")
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasename(MESSAGES);
messageSource.setCacheSeconds(5);
return messageSource;
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/").addResourceLocations("/static/**");
}
@Bean
public MultipartResolver filterMultipartResolver(){
CommonsMultipartResolver resolver = new CommonsMultipartResolver();
resolver.setMaxUploadSize(Long.parseLong(env.getProperty("multipart.max.size")));
return resolver;
}
//....
}
</code></pre>
<p>And SecurityConfiguration class:</p>
<pre><code>@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
//....
@Override
protected void configure(HttpSecurity http) throws Exception {
//Logout por POST con el valor de token csrf
http.authorizeRequests()
.antMatchers("/static/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.failureUrl("/login?error=1")
.loginProcessingUrl("/authenticate")
.and()
.logout()
.logoutUrl("/logout")
.logoutSuccessUrl("/signin")
.permitAll();
}
}
</code></pre>
<p>How I can test them with JUnit? How to test the beans are created in the spring context?</p>
| 0debug
|
e1000_mmio_write(void *opaque, target_phys_addr_t addr, uint64_t val,
unsigned size)
{
E1000State *s = opaque;
unsigned int index = (addr & 0x1ffff) >> 2;
if (index < NWRITEOPS && macreg_writeops[index]) {
macreg_writeops[index](s, index, val);
} else if (index < NREADOPS && macreg_readops[index]) {
DBGOUT(MMIO, "e1000_mmio_writel RO %x: 0x%04"PRIx64"\n", index<<2, val);
} else {
DBGOUT(UNKNOWN, "MMIO unknown write addr=0x%08x,val=0x%08"PRIx64"\n",
index<<2, val);
}
}
| 1threat
|
Find the kth smallest element in two sorted arrays with complexity of (logn)^2 : <p>S and T are two sorted arrays with n elements (integer) each ,describe an algorithm to find the kth smallest number in the union of two arrays(assuming no duplicates) with time complexity of (logn)^2. Note that it is fairly easy to find an algorithm with complexity of logn. </p>
| 0debug
|
This code does not work with localhost. css file is not found error : app.use('/public', express.static(path.join(__dirname,'public')));
app.use('/public', express.static(path.join(__dirname,'public')));
| 0debug
|
ssize_t pcnet_receive(VLANClientState *nc, const uint8_t *buf, size_t size_)
{
PCNetState *s = DO_UPCAST(NICState, nc, nc)->opaque;
int is_padr = 0, is_bcast = 0, is_ladr = 0;
uint8_t buf1[60];
int remaining;
int crc_err = 0;
int size = size_;
if (CSR_DRX(s) || CSR_STOP(s) || CSR_SPND(s) || !size)
return -1;
#ifdef PCNET_DEBUG
printf("pcnet_receive size=%d\n", size);
#endif
if (size < MIN_BUF_SIZE) {
memcpy(buf1, buf, size);
memset(buf1 + size, 0, MIN_BUF_SIZE - size);
buf = buf1;
size = MIN_BUF_SIZE;
}
if (CSR_PROM(s)
|| (is_padr=padr_match(s, buf, size))
|| (is_bcast=padr_bcast(s, buf, size))
|| (is_ladr=ladr_match(s, buf, size))) {
pcnet_rdte_poll(s);
if (!(CSR_CRST(s) & 0x8000) && s->rdra) {
struct pcnet_RMD rmd;
int rcvrc = CSR_RCVRC(s)-1,i;
target_phys_addr_t nrda;
for (i = CSR_RCVRL(s)-1; i > 0; i--, rcvrc--) {
if (rcvrc <= 1)
rcvrc = CSR_RCVRL(s);
nrda = s->rdra +
(CSR_RCVRL(s) - rcvrc) *
(BCR_SWSTYLE(s) ? 16 : 8 );
RMDLOAD(&rmd, nrda);
if (GET_FIELD(rmd.status, RMDS, OWN)) {
#ifdef PCNET_DEBUG_RMD
printf("pcnet - scan buffer: RCVRC=%d PREV_RCVRC=%d\n",
rcvrc, CSR_RCVRC(s));
#endif
CSR_RCVRC(s) = rcvrc;
pcnet_rdte_poll(s);
break;
}
}
}
if (!(CSR_CRST(s) & 0x8000)) {
#ifdef PCNET_DEBUG_RMD
printf("pcnet - no buffer: RCVRC=%d\n", CSR_RCVRC(s));
#endif
s->csr[0] |= 0x1000;
CSR_MISSC(s)++;
} else {
uint8_t *src = s->buffer;
target_phys_addr_t crda = CSR_CRDA(s);
struct pcnet_RMD rmd;
int pktcount = 0;
if (!s->looptest) {
memcpy(src, buf, size);
src[size] = 0;
src[size + 1] = 0;
src[size + 2] = 0;
src[size + 3] = 0;
size += 4;
} else if (s->looptest == PCNET_LOOPTEST_CRC ||
!CSR_DXMTFCS(s) || size < MIN_BUF_SIZE+4) {
uint32_t fcs = ~0;
uint8_t *p = src;
while (p != &src[size])
CRC(fcs, *p++);
*(uint32_t *)p = htonl(fcs);
size += 4;
} else {
uint32_t fcs = ~0;
uint8_t *p = src;
while (p != &src[size-4])
CRC(fcs, *p++);
crc_err = (*(uint32_t *)p != htonl(fcs));
}
#ifdef PCNET_DEBUG_MATCH
PRINT_PKTHDR(buf);
#endif
RMDLOAD(&rmd, PHYSADDR(s,crda));
SET_FIELD(&rmd.status, RMDS, STP, 1);
#define PCNET_RECV_STORE() do { \
int count = MIN(4096 - GET_FIELD(rmd.buf_length, RMDL, BCNT),remaining); \
target_phys_addr_t rbadr = PHYSADDR(s, rmd.rbadr); \
s->phys_mem_write(s->dma_opaque, rbadr, src, count, CSR_BSWP(s)); \
src += count; remaining -= count; \
SET_FIELD(&rmd.status, RMDS, OWN, 0); \
RMDSTORE(&rmd, PHYSADDR(s,crda)); \
pktcount++; \
} while (0)
remaining = size;
PCNET_RECV_STORE();
if ((remaining > 0) && CSR_NRDA(s)) {
target_phys_addr_t nrda = CSR_NRDA(s);
#ifdef PCNET_DEBUG_RMD
PRINT_RMD(&rmd);
#endif
RMDLOAD(&rmd, PHYSADDR(s,nrda));
if (GET_FIELD(rmd.status, RMDS, OWN)) {
crda = nrda;
PCNET_RECV_STORE();
#ifdef PCNET_DEBUG_RMD
PRINT_RMD(&rmd);
#endif
if ((remaining > 0) && (nrda=CSR_NNRD(s))) {
RMDLOAD(&rmd, PHYSADDR(s,nrda));
if (GET_FIELD(rmd.status, RMDS, OWN)) {
crda = nrda;
PCNET_RECV_STORE();
}
}
}
}
#undef PCNET_RECV_STORE
RMDLOAD(&rmd, PHYSADDR(s,crda));
if (remaining == 0) {
SET_FIELD(&rmd.msg_length, RMDM, MCNT, size);
SET_FIELD(&rmd.status, RMDS, ENP, 1);
SET_FIELD(&rmd.status, RMDS, PAM, !CSR_PROM(s) && is_padr);
SET_FIELD(&rmd.status, RMDS, LFAM, !CSR_PROM(s) && is_ladr);
SET_FIELD(&rmd.status, RMDS, BAM, !CSR_PROM(s) && is_bcast);
if (crc_err) {
SET_FIELD(&rmd.status, RMDS, CRC, 1);
SET_FIELD(&rmd.status, RMDS, ERR, 1);
}
} else {
SET_FIELD(&rmd.status, RMDS, OFLO, 1);
SET_FIELD(&rmd.status, RMDS, BUFF, 1);
SET_FIELD(&rmd.status, RMDS, ERR, 1);
}
RMDSTORE(&rmd, PHYSADDR(s,crda));
s->csr[0] |= 0x0400;
#ifdef PCNET_DEBUG
printf("RCVRC=%d CRDA=0x%08x BLKS=%d\n",
CSR_RCVRC(s), PHYSADDR(s,CSR_CRDA(s)), pktcount);
#endif
#ifdef PCNET_DEBUG_RMD
PRINT_RMD(&rmd);
#endif
while (pktcount--) {
if (CSR_RCVRC(s) <= 1)
CSR_RCVRC(s) = CSR_RCVRL(s);
else
CSR_RCVRC(s)--;
}
pcnet_rdte_poll(s);
}
}
pcnet_poll(s);
pcnet_update_irq(s);
return size_;
}
| 1threat
|
static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestamp)
{
if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE) {
int64_t addend;
int delta_timestamp;
delta_timestamp = timestamp - s->last_rtcp_timestamp;
addend = av_rescale(s->last_rtcp_ntp_time - s->first_rtcp_ntp_time, s->st->time_base.den, (uint64_t)s->st->time_base.num << 32);
pkt->pts = addend + delta_timestamp;
}
}
| 1threat
|
static void monitor_print_error(Monitor *mon)
{
qerror_print(mon->error);
QDECREF(mon->error);
mon->error = NULL;
}
| 1threat
|
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 9