problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
static void cloop_refresh_limits(BlockDriverState *bs, Error **errp)
{
bs->request_alignment = BDRV_SECTOR_SIZE;
}
| 1threat |
void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd)
{
NE2000State *s;
qemu_check_nic_model(nd, "ne2k_isa");
s = qemu_mallocz(sizeof(NE2000State));
register_ioport_write(base, 16, 1, ne2000_ioport_write, s);
register_ioport_read(base, 16, 1, ne2000_ioport_read, s);
register_ioport_write(base + 0x10, 1, 1, ne2000_asic_ioport_write, s);
register_ioport_read(base + 0x10, 1, 1, ne2000_asic_ioport_read, s);
register_ioport_write(base + 0x10, 2, 2, ne2000_asic_ioport_write, s);
register_ioport_read(base + 0x10, 2, 2, ne2000_asic_ioport_read, s);
register_ioport_write(base + 0x1f, 1, 1, ne2000_reset_ioport_write, s);
register_ioport_read(base + 0x1f, 1, 1, ne2000_reset_ioport_read, s);
s->irq = irq;
memcpy(s->macaddr, nd->macaddr, 6);
ne2000_reset(s);
s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
ne2000_receive, ne2000_can_receive, s);
qemu_format_nic_info_str(s->vc, s->macaddr);
register_savevm("ne2000", -1, 2, ne2000_save, ne2000_load, s);
}
| 1threat |
How to pass the button value into my onclick event function? : <pre><code><input type="button" value="mybutton1" onclick="dosomething()">test
</code></pre>
<p>The dosomething function evoked when to click the button,how can pass the value of the button <code>mybutton1</code> into dosomething function as it's parameter ?</p>
| 0debug |
How can I store an object File that only exists in memory as a file inside of my storage system? : <p>My programm has just recieved an <em>Object</em> that is instance of <em>File</em>. How can I save said Object as a file?
I want the file to be stored in a human readable format which is why just writing the Object into a new file like <a href="https://stackoverflow.com/questions/2744962/load-store-objects-in-file-in-java">here</a> wont do the trick.</p>
<p>I also can't just copy the file like <a href="https://www.journaldev.com/861/java-copy-file" rel="nofollow noreferrer">here</a> because the file I allready know only exists in Memory, hence if I set it as source it wont be recocnized.</p>
| 0debug |
static void mainstone_common_init(ram_addr_t ram_size,
const char *kernel_filename,
const char *kernel_cmdline, const char *initrd_filename,
const char *cpu_model, enum mainstone_model_e model, int arm_id)
{
uint32_t sector_len = 256 * 1024;
target_phys_addr_t mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 };
PXA2xxState *cpu;
DeviceState *mst_irq;
DriveInfo *dinfo;
int i;
int be;
if (!cpu_model)
cpu_model = "pxa270-c5";
cpu = pxa270_init(mainstone_binfo.ram_size, cpu_model);
cpu_register_physical_memory(0, MAINSTONE_ROM,
qemu_ram_alloc(NULL, "mainstone.rom",
MAINSTONE_ROM) | IO_MEM_ROM);
#ifdef TARGET_WORDS_BIGENDIAN
be = 1;
#else
be = 0;
#endif
for (i = 0; i < 2; i ++) {
dinfo = drive_get(IF_PFLASH, 0, i);
if (!dinfo) {
fprintf(stderr, "Two flash images must be given with the "
"'pflash' parameter\n");
exit(1);
}
if (!pflash_cfi01_register(mainstone_flash_base[i],
qemu_ram_alloc(NULL, i ? "mainstone.flash1" :
"mainstone.flash0",
MAINSTONE_FLASH),
dinfo->bdrv, sector_len,
MAINSTONE_FLASH / sector_len, 4, 0, 0, 0, 0,
be)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
exit(1);
}
}
mst_irq = sysbus_create_simple("mainstone-fpga", MST_FPGA_PHYS,
cpu->pic[PXA2XX_PIC_GPIO_0]);
printf("map addr %p\n", &map);
pxa27x_register_keypad(cpu->kp, map, 0xe0);
pxa2xx_mmci_handlers(cpu->mmc, NULL, qdev_get_gpio_in(mst_irq, MMC_IRQ));
smc91c111_init(&nd_table[0], MST_ETH_PHYS,
qdev_get_gpio_in(mst_irq, ETHERNET_IRQ));
mainstone_binfo.kernel_filename = kernel_filename;
mainstone_binfo.kernel_cmdline = kernel_cmdline;
mainstone_binfo.initrd_filename = initrd_filename;
mainstone_binfo.board_id = arm_id;
arm_load_kernel(cpu->env, &mainstone_binfo);
}
| 1threat |
Problems accessing Calendar using EKEventStore on OSX Sierra with Swift 3 : <p>This appears very simple, but I've been struggling for several days to get access to the Calendar on OSX. I have switched on the App Sandbox capability, and I've ticked the "Calendar" box in App Data. I have created very simple app with the following view controller class:</p>
<pre><code>import Cocoa
import EventKit
class ViewController: NSViewController {
var eventControl = EKEventStore()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
}
}
}
</code></pre>
<p>As you can see, the only lines of code I've added are to import EventKit and to initialise eventControl.</p>
<p>When I run this in debug, I get an error at the eventControl initialisation line</p>
<pre><code>2016-10-28 15:02:00.056521 calendarTest[4105:847101] CoreData: XPC: Unable to load metadata: Error Domain=NSCocoaErrorDomain Code=134070 "An error occurred in the persistent store." UserInfo={Problem=request failed, insufficient permission}
2016-10-28 15:02:00.057742 calendarTest[4105:847101] [error] error: -addPersistentStoreWithType:NSXPCStore configuration:(null) URL:file:///Users/patrickramsden/Library/Calendars/Calendar%20Cache options:{
NSInferMappingModelAutomaticallyOption = 1;
NSMigratePersistentStoresAutomaticallyOption = 1;
agentOrDaemon = 1;
serviceName = "com.apple.CalendarAgent.database";
} ... returned error Error Domain=NSCocoaErrorDomain Code=134070 "An error occurred in the persistent store." UserInfo={Problem=request failed, insufficient permission} with userInfo dictionary {
Problem = "request failed, insufficient permission";
}
</code></pre>
<p>I can't work out how to get the right permissions. </p>
<p>I am using Xcode 8.1 and macOS Sierra 10.12.1 </p>
| 0debug |
int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl)
{
int list, index, pic_structure;
print_short_term(h);
print_long_term(h);
h264_initialise_ref_list(h, sl);
for (list = 0; list < sl->list_count; list++) {
if (get_bits1(&sl->gb)) {
int pred = h->curr_pic_num;
for (index = 0; ; index++) {
unsigned int modification_of_pic_nums_idc = get_ue_golomb_31(&sl->gb);
unsigned int pic_id;
int i;
H264Picture *ref = NULL;
if (modification_of_pic_nums_idc == 3)
break;
if (index >= sl->ref_count[list]) {
av_log(h->avctx, AV_LOG_ERROR, "reference count overflow\n");
return -1;
}
switch (modification_of_pic_nums_idc) {
case 0:
case 1: {
const unsigned int abs_diff_pic_num = get_ue_golomb(&sl->gb) + 1;
int frame_num;
if (abs_diff_pic_num > h->max_pic_num) {
av_log(h->avctx, AV_LOG_ERROR,
"abs_diff_pic_num overflow\n");
return AVERROR_INVALIDDATA;
}
if (modification_of_pic_nums_idc == 0)
pred -= abs_diff_pic_num;
else
pred += abs_diff_pic_num;
pred &= h->max_pic_num - 1;
frame_num = pic_num_extract(h, pred, &pic_structure);
for (i = h->short_ref_count - 1; i >= 0; i--) {
ref = h->short_ref[i];
assert(ref->reference);
assert(!ref->long_ref);
if (ref->frame_num == frame_num &&
(ref->reference & pic_structure))
break;
}
if (i >= 0)
ref->pic_id = pred;
break;
}
case 2: {
int long_idx;
pic_id = get_ue_golomb(&sl->gb);
long_idx = pic_num_extract(h, pic_id, &pic_structure);
if (long_idx > 31) {
av_log(h->avctx, AV_LOG_ERROR,
"long_term_pic_idx overflow\n");
return AVERROR_INVALIDDATA;
}
ref = h->long_ref[long_idx];
assert(!(ref && !ref->reference));
if (ref && (ref->reference & pic_structure) && !mismatches_ref(h, ref)) {
ref->pic_id = pic_id;
assert(ref->long_ref);
i = 0;
} else {
i = -1;
}
break;
}
default:
av_log(h->avctx, AV_LOG_ERROR,
"illegal modification_of_pic_nums_idc %u\n",
modification_of_pic_nums_idc);
return AVERROR_INVALIDDATA;
}
if (i < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"reference picture missing during reorder\n");
memset(&sl->ref_list[list][index], 0, sizeof(sl->ref_list[0][0]));
} else {
for (i = index; i + 1 < sl->ref_count[list]; i++) {
if (sl->ref_list[list][i].parent &&
ref->long_ref == sl->ref_list[list][i].parent->long_ref &&
ref->pic_id == sl->ref_list[list][i].pic_id)
break;
}
for (; i > index; i--) {
sl->ref_list[list][i] = sl->ref_list[list][i - 1];
}
ref_from_h264pic(&sl->ref_list[list][index], ref);
if (FIELD_PICTURE(h)) {
pic_as_field(&sl->ref_list[list][index], pic_structure);
}
}
}
}
}
for (list = 0; list < sl->list_count; list++) {
for (index = 0; index < sl->ref_count[list]; index++) {
if ( !sl->ref_list[list][index].parent
|| (!FIELD_PICTURE(h) && (sl->ref_list[list][index].reference&3) != 3)) {
int i;
av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture\n");
for (i = 0; i < FF_ARRAY_ELEMS(h->last_pocs); i++)
h->last_pocs[i] = INT_MIN;
return -1;
}
av_assert0(av_buffer_get_ref_count(sl->ref_list[list][index].parent->f->buf[0]) > 0);
}
}
return 0;
}
| 1threat |
static int rv10_decode_packet(AVCodecContext *avctx,
const uint8_t *buf, int buf_size, int buf_size2)
{
MpegEncContext *s = avctx->priv_data;
int mb_count, mb_pos, left, start_mb_x;
init_get_bits(&s->gb, buf, buf_size*8);
if(s->codec_id ==CODEC_ID_RV10)
mb_count = rv10_decode_picture_header(s);
else
mb_count = rv20_decode_picture_header(s);
if (mb_count < 0) {
av_log(s->avctx, AV_LOG_ERROR, "HEADER ERROR\n");
}
if (s->mb_x >= s->mb_width ||
s->mb_y >= s->mb_height) {
av_log(s->avctx, AV_LOG_ERROR, "POS ERROR %d %d\n", s->mb_x, s->mb_y);
}
mb_pos = s->mb_y * s->mb_width + s->mb_x;
left = s->mb_width * s->mb_height - mb_pos;
if (mb_count > left) {
av_log(s->avctx, AV_LOG_ERROR, "COUNT ERROR\n");
}
if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr==NULL) {
if(s->current_picture_ptr){
ff_er_frame_end(s);
MPV_frame_end(s);
s->mb_x= s->mb_y = s->resync_mb_x = s->resync_mb_y= 0;
}
if(MPV_frame_start(s, avctx) < 0)
ff_er_frame_start(s);
}
av_dlog(avctx, "qscale=%d\n", s->qscale);
if(s->codec_id== CODEC_ID_RV10){
if(s->mb_y==0) s->first_slice_line=1;
}else{
s->first_slice_line=1;
s->resync_mb_x= s->mb_x;
}
start_mb_x= s->mb_x;
s->resync_mb_y= s->mb_y;
if(s->h263_aic){
s->y_dc_scale_table=
s->c_dc_scale_table= ff_aic_dc_scale_table;
}else{
s->y_dc_scale_table=
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
}
if(s->modified_quant)
s->chroma_qscale_table= ff_h263_chroma_qscale_table;
ff_set_qscale(s, s->qscale);
s->rv10_first_dc_coded[0] = 0;
s->rv10_first_dc_coded[1] = 0;
s->rv10_first_dc_coded[2] = 0;
s->block_wrap[0]=
s->block_wrap[1]=
s->block_wrap[2]=
s->block_wrap[3]= s->b8_stride;
s->block_wrap[4]=
s->block_wrap[5]= s->mb_stride;
ff_init_block_index(s);
for(s->mb_num_left= mb_count; s->mb_num_left>0; s->mb_num_left--) {
int ret;
ff_update_block_index(s);
av_dlog(avctx, "**mb x=%d y=%d\n", s->mb_x, s->mb_y);
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
ret=ff_h263_decode_mb(s, s->block);
if (ret != SLICE_ERROR && s->gb.size_in_bits < get_bits_count(&s->gb) && 8*buf_size2 >= get_bits_count(&s->gb)){
av_log(avctx, AV_LOG_DEBUG, "update size from %d to %d\n", s->gb.size_in_bits, 8*buf_size2);
s->gb.size_in_bits= 8*buf_size2;
ret= SLICE_OK;
}
if (ret == SLICE_ERROR || s->gb.size_in_bits < get_bits_count(&s->gb)) {
av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y);
}
if(s->pict_type != AV_PICTURE_TYPE_B)
ff_h263_update_motion_val(s);
MPV_decode_mb(s, s->block);
if(s->loop_filter)
ff_h263_loop_filter(s);
if (++s->mb_x == s->mb_width) {
s->mb_x = 0;
s->mb_y++;
ff_init_block_index(s);
}
if(s->mb_x == s->resync_mb_x)
s->first_slice_line=0;
if(ret == SLICE_END) break;
}
ff_er_add_slice(s, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
return s->gb.size_in_bits;
} | 1threat |
static void test_io_rw_interface(enum AddrMode lba48, enum IOMode dma,
unsigned bufsize, uint64_t sector)
{
AHCIQState *ahci;
ahci = ahci_boot_and_enable();
ahci_test_io_rw_simple(ahci, bufsize, sector,
io_cmds[dma][lba48][IO_READ],
io_cmds[dma][lba48][IO_WRITE]);
ahci_shutdown(ahci);
}
| 1threat |
Conversion of array of double value in to a character array : I need to send an array of 4 double value in to a character buffer of size 8 byte and also
would like to extract the value from the character array in to double value for its usage.
-I am trying with the below code but not getting correct output as
char str is of size 8 byte is too little to store 4 double value !!
-There might be some bit operation could solve the issue!!
Ex:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
char str[8]={'\0'};
double x=-10.456678,p=12.678906,q=80.8956876,r=360.67,y,z,h,k;
sprintf(&str[0],"%2.6f",x);
sprintf(&str[1],"%2.6f",p);
sprintf(&str[2],"%2.6f",q);
sprintf(&str[3],%3.4f",r);
//Extracting the same from str
y=atof((char *)&str[0]);
z=atof((char *)&str[1]);
h=atof((char *)&str[2]);
k=atof((char *)&str[3]);
printf("\ny= %2.6f",y);
printf("\nz= %2.6f",z);
printf("\nh= %2.6f",h);
printf("\nk= %2.6f",k);
return 0;
}
Could anyone please answer
Thanks in Advance!!
| 0debug |
static inline void RENAME(yuy2ToY)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)
{
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
"movq "MANGLE(bm01010101)", %%mm2 \n\t"
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",2), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",2), %%mm1 \n\t"
"pand %%mm2, %%mm0 \n\t"
"pand %%mm2, %%mm1 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"movq %%mm0, (%2, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((x86_reg)-width), "r" (src+width*2), "r" (dst+width)
: "%"REG_a
);
#else
int i;
for (i=0; i<width; i++)
dst[i]= src[2*i];
#endif
}
| 1threat |
The API with ID does not include a resource with path /* having an integration LAMBDA on the ANY method : <p>.net core serverless web api
I am trying to do proxy integration with lambda and api gateway, everything is working fine with aws console </p>
<p>but i am facing issues with aws cli commands
i tried integrating with cli but the lambda is not properly integrated</p>
<pre><code>aws apigateway create-resource --rest-api-id id --parent-id id --path-part {proxy+}
aws apigateway put-method --rest-api-id id --resource-id id --http-method ANY --authorization-type "NONE"
aws apigateway put-integration --rest-api-id id --resource-id id --http-method ANY --type HTTP_PROXY --integration-http-method ANY --uri arn:aws:apigateway:us-east-2:lambda:path//2015-03-31/functions/arn:aws:lambda:us-east-2:account_id:function:helloworld/invocations
aws lambda add-permission --function-name helloworld --action lambda:InvokeFunction --principal apigateway.amazonaws.com --source-arn arn:aws:execute-api:us-east-2:account_id:apiid/*/*/* --statement-id 12345678
</code></pre>
| 0debug |
How to prevent pull-down-to-refresh of mobile chrome : <p>I want to prevent pull-down-to-refresh of mobile chrome(especially iOS chrome). My web application has vertical panning event with device-width and device-height viewport, but whenever panning down, mobile chrome refreshes itself because of browser's default function. Plus, on Safari browser, screen is rolling during panning event. I want to disable these moves.</p>
<p>Of course, I tried event.preventDefault(); and touch-action: none; But it doesn't look work. Should I add eventListner and touch-action "on body tag"? I expect useful answer with example.</p>
| 0debug |
static int parse_hex64(DeviceState *dev, Property *prop, const char *str)
{
uint64_t *ptr = qdev_get_prop_ptr(dev, prop);
if (sscanf(str, "%" PRIx64, ptr) != 1)
return -EINVAL;
return 0;
}
| 1threat |
Duplicate class found in the file '/activity_login.xml' DataBinding, BR not being generated : <p>I mostly being stuck with android data binding BR issue. There is single activity.xml always but generated binding class showing error. Please let me know how to resolve this issue.</p>
<p><a href="https://i.stack.imgur.com/HpHua.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/HpHua.jpg" alt="enter image description here"></a></p>
| 0debug |
count only letter abcdefghijklmnopqrstuvwxyz in a list : How to count only letter abcdefghijklmnopqrstuvwxyz in a list in alphabetical order without "Counter"??
For example
input
['Bro', 'lo', '27', 'b']
output
[['b', 1], ['l', 1], ['o', 2], ['r', 1]]
| 0debug |
how to count how many users and how many comments to every post in mysql? : here is my comments table
id(int) user_id(int) post_id(int) text(char)
I want to calculate how many users has comments to every post
and how many comments do every post have.
I've already done the latter one as following:
select count(*) from comments group by post_id;
but how about the first one? any ideas? | 0debug |
Service Workers not updating : <p>I have a service worker installed in my website, everything works fine, except when I push an update to the cached files, in fact; they stay catched forever and I seem to be unable to invalidate the cache unless I unsubscribe the worker from the `chrome://serviceworker-internals/</p>
<pre><code>const STATIC_CACHE_NAME = 'static-cache-v1';
const APP_CACHE_NAME = 'app-cache-#VERSION';
const CACHE_APP = [
'/',
'/app/app.js'
]
const CACHE_STATIC = [
'https://fonts.googleapis.com/css?family=Roboto:400,300,500,700',
'https://cdnjs.cloudflare.com/ajax/libs/normalize/4.1.1/normalize.min.css'
]
self.addEventListener('install',function(e){
e.waitUntil(
Promise.all([caches.open(STATIC_CACHE_NAME),caches.open(APP_CACHE_NAME)]).then(function(storage){
var static_cache = storage[0];
var app_cache = storage[1];
return Promise.all([static_cache.addAll(CACHE_STATIC),app_cache.addAll(CACHE_APP)]);
})
);
});
self.addEventListener('activate', function(e) {
e.waitUntil(
caches.keys().then(function(cacheNames) {
return Promise.all(
cacheNames.map(function(cacheName) {
if (cacheName !== APP_CACHE_NAME && cacheName !== STATIC_CACHE_NAME) {
console.log('deleting',cacheName);
return caches.delete(cacheName);
}
})
);
})
);
});
self.addEventListener('fetch',function(e){
const url = new URL(e.request.url);
if (url.hostname === 'static.mysite.co' || url.hostname === 'cdnjs.cloudflare.com' || url.hostname === 'fonts.googleapis.com'){
e.respondWith(
caches.match(e.request).then(function(response){
if (response) {
return response;
}
var fetchRequest = e.request.clone();
return fetch(fetchRequest).then(function(response) {
if (!response || response.status !== 200 || response.type !== 'basic') {
return response;
}
var responseToCache = response.clone();
caches.open(STATIC_CACHE_NAME).then(function(cache) {
cache.put(e.request, responseToCache);
});
return response;
});
})
);
} else if (CACHE_APP.indexOf(url.pathname) !== -1){
e.respondWith(caches.match(e.request));
}
});
</code></pre>
<p>where #VERSION is a version that is appended to the cache name at compile time; note that STATIC_CACHE_NAME never changes, as the files are thought to be static forever.</p>
<p>Also the behavior is erratic, I've been checking the delete function (the part where it logs) and it keeps logging about the deleting caches that have already been deleted (supposedly). when I run <code>caches.keys().then(function(k){console.log(k)})</code> I get a whole bunch of old caches that should've been removed.</p>
| 0debug |
QEMUFile *qemu_bufopen(const char *mode, QEMUSizedBuffer *input)
{
QEMUBuffer *s;
if (mode == NULL || (mode[0] != 'r' && mode[0] != 'w') ||
mode[1] != '\0') {
error_report("qemu_bufopen: Argument validity check failed");
return NULL;
}
s = g_malloc0(sizeof(QEMUBuffer));
if (mode[0] == 'r') {
s->qsb = input;
}
if (s->qsb == NULL) {
s->qsb = qsb_create(NULL, 0);
}
if (!s->qsb) {
g_free(s);
error_report("qemu_bufopen: qsb_create failed");
return NULL;
}
if (mode[0] == 'r') {
s->file = qemu_fopen_ops(s, &buf_read_ops);
} else {
s->file = qemu_fopen_ops(s, &buf_write_ops);
}
return s->file;
}
| 1threat |
static void quantize_and_encode_band_cost_ESC_mips(struct AACEncContext *s,
PutBitContext *pb, const float *in, float *out,
const float *scaled, int size, int scale_idx,
int cb, const float lambda, const float uplim,
int *bits, const float ROUNDING)
{
const float Q34 = ff_aac_pow34sf_tab[POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512];
const float IQ = ff_aac_pow2sf_tab [POW_SF2_ZERO + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
int i;
int qc1, qc2, qc3, qc4;
uint8_t *p_bits = (uint8_t* )ff_aac_spectral_bits[cb-1];
uint16_t *p_codes = (uint16_t*)ff_aac_spectral_codes[cb-1];
float *p_vectors = (float* )ff_aac_codebook_vectors[cb-1];
abs_pow34_v(s->scoefs, in, size);
scaled = s->scoefs;
if (cb < 11) {
for (i = 0; i < size; i += 4) {
int curidx, curidx2, sign1, count1, sign2, count2;
int *in_int = (int *)&in[i];
uint8_t v_bits;
unsigned int v_codes;
int t0, t1, t2, t3, t4;
const float *vec1, *vec2;
qc1 = scaled[i ] * Q34 + ROUNDING;
qc2 = scaled[i+1] * Q34 + ROUNDING;
qc3 = scaled[i+2] * Q34 + ROUNDING;
qc4 = scaled[i+3] * Q34 + ROUNDING;
__asm__ volatile (
".set push \n\t"
".set noreorder \n\t"
"ori %[t4], $zero, 16 \n\t"
"ori %[sign1], $zero, 0 \n\t"
"ori %[sign2], $zero, 0 \n\t"
"slt %[t0], %[t4], %[qc1] \n\t"
"slt %[t1], %[t4], %[qc2] \n\t"
"slt %[t2], %[t4], %[qc3] \n\t"
"slt %[t3], %[t4], %[qc4] \n\t"
"movn %[qc1], %[t4], %[t0] \n\t"
"movn %[qc2], %[t4], %[t1] \n\t"
"movn %[qc3], %[t4], %[t2] \n\t"
"movn %[qc4], %[t4], %[t3] \n\t"
"lw %[t0], 0(%[in_int]) \n\t"
"lw %[t1], 4(%[in_int]) \n\t"
"lw %[t2], 8(%[in_int]) \n\t"
"lw %[t3], 12(%[in_int]) \n\t"
"slt %[t0], %[t0], $zero \n\t"
"movn %[sign1], %[t0], %[qc1] \n\t"
"slt %[t2], %[t2], $zero \n\t"
"movn %[sign2], %[t2], %[qc3] \n\t"
"slt %[t1], %[t1], $zero \n\t"
"sll %[t0], %[sign1], 1 \n\t"
"or %[t0], %[t0], %[t1] \n\t"
"movn %[sign1], %[t0], %[qc2] \n\t"
"slt %[t3], %[t3], $zero \n\t"
"sll %[t0], %[sign2], 1 \n\t"
"or %[t0], %[t0], %[t3] \n\t"
"movn %[sign2], %[t0], %[qc4] \n\t"
"slt %[count1], $zero, %[qc1] \n\t"
"slt %[t1], $zero, %[qc2] \n\t"
"slt %[count2], $zero, %[qc3] \n\t"
"slt %[t2], $zero, %[qc4] \n\t"
"addu %[count1], %[count1], %[t1] \n\t"
"addu %[count2], %[count2], %[t2] \n\t"
".set pop \n\t"
: [qc1]"+r"(qc1), [qc2]"+r"(qc2),
[qc3]"+r"(qc3), [qc4]"+r"(qc4),
[sign1]"=&r"(sign1), [count1]"=&r"(count1),
[sign2]"=&r"(sign2), [count2]"=&r"(count2),
[t0]"=&r"(t0), [t1]"=&r"(t1), [t2]"=&r"(t2), [t3]"=&r"(t3),
[t4]"=&r"(t4)
: [in_int]"r"(in_int)
: "memory"
);
curidx = 17 * qc1;
curidx += qc2;
curidx2 = 17 * qc3;
curidx2 += qc4;
v_codes = (p_codes[curidx] << count1) | sign1;
v_bits = p_bits[curidx] + count1;
put_bits(pb, v_bits, v_codes);
v_codes = (p_codes[curidx2] << count2) | sign2;
v_bits = p_bits[curidx2] + count2;
put_bits(pb, v_bits, v_codes);
if (out) {
vec1 = &p_vectors[curidx*2 ];
vec2 = &p_vectors[curidx2*2];
out[i+0] = copysignf(vec1[0] * IQ, in[i+0]);
out[i+1] = copysignf(vec1[1] * IQ, in[i+1]);
out[i+2] = copysignf(vec2[0] * IQ, in[i+2]);
out[i+3] = copysignf(vec2[1] * IQ, in[i+3]);
}
}
} else {
for (i = 0; i < size; i += 4) {
int curidx, curidx2, sign1, count1, sign2, count2;
int *in_int = (int *)&in[i];
uint8_t v_bits;
unsigned int v_codes;
int c1, c2, c3, c4;
int t0, t1, t2, t3, t4;
const float *vec1, *vec2;
qc1 = scaled[i ] * Q34 + ROUNDING;
qc2 = scaled[i+1] * Q34 + ROUNDING;
qc3 = scaled[i+2] * Q34 + ROUNDING;
qc4 = scaled[i+3] * Q34 + ROUNDING;
__asm__ volatile (
".set push \n\t"
".set noreorder \n\t"
"ori %[t4], $zero, 16 \n\t"
"ori %[sign1], $zero, 0 \n\t"
"ori %[sign2], $zero, 0 \n\t"
"shll_s.w %[c1], %[qc1], 18 \n\t"
"shll_s.w %[c2], %[qc2], 18 \n\t"
"shll_s.w %[c3], %[qc3], 18 \n\t"
"shll_s.w %[c4], %[qc4], 18 \n\t"
"srl %[c1], %[c1], 18 \n\t"
"srl %[c2], %[c2], 18 \n\t"
"srl %[c3], %[c3], 18 \n\t"
"srl %[c4], %[c4], 18 \n\t"
"slt %[t0], %[t4], %[qc1] \n\t"
"slt %[t1], %[t4], %[qc2] \n\t"
"slt %[t2], %[t4], %[qc3] \n\t"
"slt %[t3], %[t4], %[qc4] \n\t"
"movn %[qc1], %[t4], %[t0] \n\t"
"movn %[qc2], %[t4], %[t1] \n\t"
"movn %[qc3], %[t4], %[t2] \n\t"
"movn %[qc4], %[t4], %[t3] \n\t"
"lw %[t0], 0(%[in_int]) \n\t"
"lw %[t1], 4(%[in_int]) \n\t"
"lw %[t2], 8(%[in_int]) \n\t"
"lw %[t3], 12(%[in_int]) \n\t"
"slt %[t0], %[t0], $zero \n\t"
"movn %[sign1], %[t0], %[qc1] \n\t"
"slt %[t2], %[t2], $zero \n\t"
"movn %[sign2], %[t2], %[qc3] \n\t"
"slt %[t1], %[t1], $zero \n\t"
"sll %[t0], %[sign1], 1 \n\t"
"or %[t0], %[t0], %[t1] \n\t"
"movn %[sign1], %[t0], %[qc2] \n\t"
"slt %[t3], %[t3], $zero \n\t"
"sll %[t0], %[sign2], 1 \n\t"
"or %[t0], %[t0], %[t3] \n\t"
"movn %[sign2], %[t0], %[qc4] \n\t"
"slt %[count1], $zero, %[qc1] \n\t"
"slt %[t1], $zero, %[qc2] \n\t"
"slt %[count2], $zero, %[qc3] \n\t"
"slt %[t2], $zero, %[qc4] \n\t"
"addu %[count1], %[count1], %[t1] \n\t"
"addu %[count2], %[count2], %[t2] \n\t"
".set pop \n\t"
: [qc1]"+r"(qc1), [qc2]"+r"(qc2),
[qc3]"+r"(qc3), [qc4]"+r"(qc4),
[sign1]"=&r"(sign1), [count1]"=&r"(count1),
[sign2]"=&r"(sign2), [count2]"=&r"(count2),
[c1]"=&r"(c1), [c2]"=&r"(c2),
[c3]"=&r"(c3), [c4]"=&r"(c4),
[t0]"=&r"(t0), [t1]"=&r"(t1), [t2]"=&r"(t2), [t3]"=&r"(t3),
[t4]"=&r"(t4)
: [in_int]"r"(in_int)
: "memory"
);
curidx = 17 * qc1;
curidx += qc2;
curidx2 = 17 * qc3;
curidx2 += qc4;
v_codes = (p_codes[curidx] << count1) | sign1;
v_bits = p_bits[curidx] + count1;
put_bits(pb, v_bits, v_codes);
if (p_vectors[curidx*2 ] == 64.0f) {
int len = av_log2(c1);
v_codes = (((1 << (len - 3)) - 2) << len) | (c1 & ((1 << len) - 1));
put_bits(pb, len * 2 - 3, v_codes);
}
if (p_vectors[curidx*2+1] == 64.0f) {
int len = av_log2(c2);
v_codes = (((1 << (len - 3)) - 2) << len) | (c2 & ((1 << len) - 1));
put_bits(pb, len*2-3, v_codes);
}
v_codes = (p_codes[curidx2] << count2) | sign2;
v_bits = p_bits[curidx2] + count2;
put_bits(pb, v_bits, v_codes);
if (p_vectors[curidx2*2 ] == 64.0f) {
int len = av_log2(c3);
v_codes = (((1 << (len - 3)) - 2) << len) | (c3 & ((1 << len) - 1));
put_bits(pb, len* 2 - 3, v_codes);
}
if (p_vectors[curidx2*2+1] == 64.0f) {
int len = av_log2(c4);
v_codes = (((1 << (len - 3)) - 2) << len) | (c4 & ((1 << len) - 1));
put_bits(pb, len * 2 - 3, v_codes);
}
if (out) {
vec1 = &p_vectors[curidx*2];
vec2 = &p_vectors[curidx2*2];
out[i+0] = copysignf(c1 * cbrtf(c1) * IQ, in[i+0]);
out[i+1] = copysignf(c2 * cbrtf(c2) * IQ, in[i+1]);
out[i+2] = copysignf(c3 * cbrtf(c3) * IQ, in[i+2]);
out[i+3] = copysignf(c4 * cbrtf(c4) * IQ, in[i+3]);
}
}
}
}
| 1threat |
How to make name be a variable in python? : <p>How should I do if I want to output "name[0] = 6" instead of "t"?</p>
<p><a href="https://i.stack.imgur.com/ctCBQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ctCBQ.png" alt="enter image description here"></a></p>
| 0debug |
EXCEL VBA IF CELL A2:A1000 CONTAINS ANY LETTER OR NUMBER, PUT TODAY'S DATE ON SAME ROW : working on the project at work and tried to search but can't find any answers.
Like the title says, if cell a2 to a1000 contains any letter or number, I would like to input today's date on row E (same row but today's date 4 rows over on column E). Please see example of what I want picture below.
Thanks in advance.
[enter image description here][1]
[1]: https://i.stack.imgur.com/EBP6u.png | 0debug |
void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
{
GArray *table_offsets;
unsigned facs, dsdt, rsdt;
AcpiCpuInfo cpu;
AcpiPmInfo pm;
AcpiMiscInfo misc;
AcpiMcfgInfo mcfg;
PcPciInfo pci;
uint8_t *u;
acpi_get_cpu_info(&cpu);
acpi_get_pm_info(&pm);
acpi_get_dsdt(&misc);
acpi_get_hotplug_info(&misc);
acpi_get_misc_info(&misc);
acpi_get_pci_info(&pci);
table_offsets = g_array_new(false, true ,
sizeof(uint32_t));
ACPI_BUILD_DPRINTF(3, "init ACPI tables\n");
bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE,
64 ,
false );
facs = tables->table_data->len;
build_facs(tables->table_data, tables->linker, guest_info);
dsdt = tables->table_data->len;
build_dsdt(tables->table_data, tables->linker, &misc);
acpi_add_table(table_offsets, tables->table_data);
build_fadt(tables->table_data, tables->linker, &pm, facs, dsdt);
acpi_add_table(table_offsets, tables->table_data);
build_ssdt(tables->table_data, tables->linker, &cpu, &pm, &misc, &pci,
guest_info);
acpi_add_table(table_offsets, tables->table_data);
build_madt(tables->table_data, tables->linker, &cpu, guest_info);
acpi_add_table(table_offsets, tables->table_data);
if (misc.has_hpet) {
build_hpet(tables->table_data, tables->linker);
}
if (guest_info->numa_nodes) {
acpi_add_table(table_offsets, tables->table_data);
build_srat(tables->table_data, tables->linker, &cpu, guest_info);
}
if (acpi_get_mcfg(&mcfg)) {
acpi_add_table(table_offsets, tables->table_data);
build_mcfg_q35(tables->table_data, tables->linker, &mcfg);
}
for (u = acpi_table_first(); u; u = acpi_table_next(u)) {
unsigned len = acpi_table_len(u);
acpi_add_table(table_offsets, tables->table_data);
g_array_append_vals(tables->table_data, u, len);
}
rsdt = tables->table_data->len;
build_rsdt(tables->table_data, tables->linker, table_offsets);
build_rsdp(tables->rsdp, tables->linker, rsdt);
acpi_align_size(tables->table_data, 0x1000);
acpi_align_size(tables->linker, 0x1000);
g_array_free(table_offsets, true);
}
| 1threat |
How to remove undefined values from array but keep 0 and null : <p>In javascript, I want to remove undefined values, but keep the values 0 and null from an array. </p>
<pre><code>[ 1, 2, 3, undefined, 0, null ]
</code></pre>
<p>How can I do it cleanly?</p>
| 0debug |
int arm_set_cpu_on(uint64_t cpuid, uint64_t entry, uint64_t context_id,
uint32_t target_el, bool target_aa64)
{
CPUState *target_cpu_state;
ARMCPU *target_cpu;
DPRINTF("cpu %" PRId64 " (EL %d, %s) @ 0x%" PRIx64 " with R0 = 0x%" PRIx64
"\n", cpuid, target_el, target_aa64 ? "aarch64" : "aarch32", entry,
context_id);
assert((target_el > 0) && (target_el < 4));
if (target_aa64 && (entry & 3)) {
return QEMU_ARM_POWERCTL_INVALID_PARAM;
}
target_cpu_state = arm_get_cpu_by_id(cpuid);
if (!target_cpu_state) {
return QEMU_ARM_POWERCTL_INVALID_PARAM;
}
target_cpu = ARM_CPU(target_cpu_state);
if (!target_cpu->powered_off) {
qemu_log_mask(LOG_GUEST_ERROR,
"[ARM]%s: CPU %" PRId64 " is already on\n",
__func__, cpuid);
return QEMU_ARM_POWERCTL_ALREADY_ON;
}
if (((target_el == 3) && !arm_feature(&target_cpu->env, ARM_FEATURE_EL3)) ||
((target_el == 2) && !arm_feature(&target_cpu->env, ARM_FEATURE_EL2))) {
return QEMU_ARM_POWERCTL_INVALID_PARAM;
}
if (!target_aa64 && arm_feature(&target_cpu->env, ARM_FEATURE_AARCH64)) {
qemu_log_mask(LOG_UNIMP,
"[ARM]%s: Starting AArch64 CPU %" PRId64
" in AArch32 mode is not supported yet\n",
__func__, cpuid);
return QEMU_ARM_POWERCTL_INVALID_PARAM;
}
cpu_reset(target_cpu_state);
target_cpu->powered_off = false;
target_cpu_state->halted = 0;
if (target_aa64) {
if ((target_el < 3) && arm_feature(&target_cpu->env, ARM_FEATURE_EL3)) {
target_cpu->env.cp15.scr_el3 |= SCR_RW;
}
if ((target_el < 2) && arm_feature(&target_cpu->env, ARM_FEATURE_EL2)) {
target_cpu->env.cp15.hcr_el2 |= HCR_RW;
}
target_cpu->env.pstate = aarch64_pstate_mode(target_el, true);
} else {
static uint32_t mode_for_el[] = { 0,
ARM_CPU_MODE_SVC,
ARM_CPU_MODE_HYP,
ARM_CPU_MODE_SVC };
cpsr_write(&target_cpu->env, mode_for_el[target_el], CPSR_M,
CPSRWriteRaw);
}
if (target_el == 3) {
target_cpu->env.cp15.scr_el3 &= ~SCR_NS;
} else {
target_cpu->env.cp15.scr_el3 |= SCR_NS;
}
assert(target_el == arm_current_el(&target_cpu->env));
if (target_aa64) {
target_cpu->env.xregs[0] = context_id;
target_cpu->env.thumb = false;
} else {
target_cpu->env.regs[0] = context_id;
target_cpu->env.thumb = entry & 1;
entry &= 0xfffffffe;
}
cpu_set_pc(target_cpu_state, entry);
qemu_cpu_kick(target_cpu_state);
return QEMU_ARM_POWERCTL_RET_SUCCESS;
}
| 1threat |
void qmp_block_job_complete(const char *device, Error **errp)
{
BlockJob *job = find_block_job(device);
if (!job) {
error_set(errp, QERR_BLOCK_JOB_NOT_ACTIVE, device);
return;
}
trace_qmp_block_job_complete(job);
block_job_complete(job, errp);
}
| 1threat |
static int rv30_decode_mb_info(RV34DecContext *r)
{
static const int rv30_p_types[6] = { RV34_MB_SKIP, RV34_MB_P_16x16, RV34_MB_P_8x8, -1, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 };
static const int rv30_b_types[6] = { RV34_MB_SKIP, RV34_MB_B_DIRECT, RV34_MB_B_FORWARD, RV34_MB_B_BACKWARD, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 };
MpegEncContext *s = &r->s;
GetBitContext *gb = &s->gb;
int code = svq3_get_ue_golomb(gb);
if(code > 11){
av_log(s->avctx, AV_LOG_ERROR, "Incorrect MB type code\n");
return -1;
}
if(code > 5){
av_log(s->avctx, AV_LOG_ERROR, "dquant needed\n");
code -= 6;
}
if(s->pict_type != AV_PICTURE_TYPE_B)
return rv30_p_types[code];
else
return rv30_b_types[code];
}
| 1threat |
static void test_io_channel_unix(bool async)
{
SocketAddress *listen_addr = g_new0(SocketAddress, 1);
SocketAddress *connect_addr = g_new0(SocketAddress, 1);
#define TEST_SOCKET "test-io-channel-socket.sock"
listen_addr->type = SOCKET_ADDRESS_KIND_UNIX;
listen_addr->u.q_unix = g_new0(UnixSocketAddress, 1);
listen_addr->u.q_unix->path = g_strdup(TEST_SOCKET);
connect_addr->type = SOCKET_ADDRESS_KIND_UNIX;
connect_addr->u.q_unix = g_new0(UnixSocketAddress, 1);
connect_addr->u.q_unix->path = g_strdup(TEST_SOCKET);
test_io_channel(async, listen_addr, connect_addr, true);
qapi_free_SocketAddress(listen_addr);
qapi_free_SocketAddress(connect_addr);
unlink(TEST_SOCKET);
}
| 1threat |
Different ports for frontend and backend. How to make a request? : <p>Using Angular-CLI as a frontend. 4200 port</p>
<p>Using Express as a backend. 8080 port</p>
<p>Directories look like:</p>
<pre><code>Application
- backend
- ...Express architecture
- frontend
-...Angular2 architecture
</code></pre>
<p>So I'm running two projects, two commanders, one for frontent, second one for backend. <code>node app.js</code> for backend (8080), <code>ng serve</code> for frontent (4200).</p>
<p>Let's assume that I have a layer in backend which returns some string.</p>
<pre><code>app.get('/hello', function(req, res) {
res.send("Hello!");
}
</code></pre>
<p>How can I make a request from frontend to backend and get that string? I don't want to know how exactly should I use Angular2 because that's not the point. I'm asking, what technology should I use to be able connect these two (frontent and backend) sides on different ports. If I just run them and make a request from frontend, I'll get an error because it can't find <code>/hello</code> url.</p>
| 0debug |
db.execute('SELECT * FROM products WHERE product_id = ' + product_input) | 1threat |
Amateur can't feel list with content of a file : namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
List<string> file1 = new List<string>();
Console.WriteLine("Enter the path to the folder");
string path1 = Console.ReadLine();
string text = System.IO.File.ReadAllText(path1);
I am trying to put the content of the file (text) into the list. I tried to look on this website for help but couldn't find anything.
| 0debug |
restore_sigcontext(CPUM68KState *env, struct target_sigcontext *sc, int *pd0)
{
int err = 0;
int temp;
__get_user(env->aregs[7], &sc->sc_usp);
__get_user(env->dregs[1], &sc->sc_d1);
__get_user(env->aregs[0], &sc->sc_a0);
__get_user(env->aregs[1], &sc->sc_a1);
__get_user(env->pc, &sc->sc_pc);
__get_user(temp, &sc->sc_sr);
env->sr = (env->sr & 0xff00) | (temp & 0xff);
*pd0 = tswapl(sc->sc_d0);
return err;
}
| 1threat |
how to execute linux command from C without printing output : i recently wrote this code to execute system command in c. However, I don't want the output results to be displayed upon executing this program. Can you please suggest ?
#include <stdio.h>
int main() {
system("ls");
} | 0debug |
Array doesn't save swift : getting a Json Object from a rest web service i get the data from the object and i want to show it in a tableview
`class TableViewController1: UITableViewController {
var nomProduit = ["ok"]
var prixProduit = [""]
var vt1 : String?
var vt2 : String?
var i : Int!
var compteur1:Int!
var resultat1:NSArray?
var x : AnyObject?
override func viewDidLoad() {
super.viewDidLoad()
// \(detectionString)
let str:String = "http://vps43623.ovh.net/yamoinscher/api/products/6194005492077"
let url = NSURL(string: str)!
let task = NSURLSession.sharedSession().dataTaskWithURL(url) { (data, response, error) -> Void in
if let urlContent = data {
do {
let jsonResult = try NSJSONSerialization.JSONObjectWithData(urlContent, options: NSJSONReadingOptions.MutableContainers)
self.resultat1 = jsonResult["meme_categorie"] as? NSArray
self.compteur1 = self.resultat1!.count
print(self.compteur1!)
//self.value = (compteur1 as? Int)!
for self.i=0 ; self.i < self.compteur1! ; self.i = self.i+1 {
if let aStatus = self.resultat1![self.i] as? NSDictionary{
self.vt1 = aStatus["libelle_prod"]! as? String
self.nomProduit.append(self.vt1!)
self.vt2 = aStatus["prix"]! as? String
self.prixProduit.append(self.vt2!)
//print(self.nomProduit[self.i])
}
}
} catch {
print("JSON serialization failed")
}
}
}
task.resume()
}`
Then My problem is that this array stays nil `self.prixProduit.append(self.vt2!)`
here is the rest of my code
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 17
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell1", forIndexPath: indexPath) as! customCell1
// cell.PrixSim.text = nomProduit[indexPath.row]
print(self.nomProduit[0])
return cell
} | 0debug |
int sclp_service_call(uint64_t sccb, uint32_t code)
{
int r = 0;
SCCB work_sccb;
hwaddr sccb_len = sizeof(SCCB);
if (cpu_physical_memory_is_io(sccb)) {
r = -PGM_ADDRESSING;
goto out;
}
if (sccb & ~0x7ffffff8ul) {
r = -PGM_SPECIFICATION;
goto out;
}
cpu_physical_memory_read(sccb, &work_sccb, sccb_len);
if (be16_to_cpu(work_sccb.h.length) < sizeof(SCCBHeader) ||
be16_to_cpu(work_sccb.h.length) > SCCB_SIZE) {
r = -PGM_SPECIFICATION;
goto out;
}
sclp_execute((SCCB *)&work_sccb, code);
cpu_physical_memory_write(sccb, &work_sccb,
be16_to_cpu(work_sccb.h.length));
sclp_service_interrupt(sccb);
out:
return r;
}
| 1threat |
static void bus_add_child(BusState *bus, DeviceState *child)
{
char name[32];
BusChild *kid = g_malloc0(sizeof(*kid));
if (qdev_hotplug) {
assert(bus->allow_hotplug);
}
kid->index = bus->max_index++;
kid->child = child;
object_ref(OBJECT(kid->child));
QTAILQ_INSERT_HEAD(&bus->children, kid, sibling);
snprintf(name, sizeof(name), "child[%d]", kid->index);
object_property_add_link(OBJECT(bus), name,
object_get_typename(OBJECT(child)),
(Object **)&kid->child,
NULL);
}
| 1threat |
static void virtio_ccw_balloon_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
VirtIOBalloonCcw *dev = VIRTIO_BALLOON_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
Error *err = NULL;
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
if (err) {
error_propagate(errp, err);
}
}
| 1threat |
static int archipelago_submit_request(BDRVArchipelagoState *s,
uint64_t bufidx,
size_t count,
off_t offset,
ArchipelagoAIOCB *aio_cb,
ArchipelagoSegmentedRequest *segreq,
int op)
{
int ret, targetlen;
char *target;
void *data = NULL;
struct xseg_request *req;
AIORequestData *reqdata = g_malloc(sizeof(AIORequestData));
targetlen = strlen(s->volname);
req = xseg_get_request(s->xseg, s->srcport, s->vportno, X_ALLOC);
if (!req) {
archipelagolog("Cannot get XSEG request\n");
goto err_exit2;
}
ret = xseg_prep_request(s->xseg, req, targetlen, count);
if (ret < 0) {
archipelagolog("Cannot prepare XSEG request\n");
goto err_exit;
}
target = xseg_get_target(s->xseg, req);
if (!target) {
archipelagolog("Cannot get XSEG target\n");
goto err_exit;
}
memcpy(target, s->volname, targetlen);
req->size = count;
req->offset = offset;
switch (op) {
case ARCHIP_OP_READ:
req->op = X_READ;
break;
case ARCHIP_OP_WRITE:
req->op = X_WRITE;
break;
case ARCHIP_OP_FLUSH:
req->op = X_FLUSH;
break;
}
reqdata->volname = s->volname;
reqdata->offset = offset;
reqdata->size = count;
reqdata->bufidx = bufidx;
reqdata->aio_cb = aio_cb;
reqdata->segreq = segreq;
reqdata->op = op;
xseg_set_req_data(s->xseg, req, reqdata);
if (op == ARCHIP_OP_WRITE) {
data = xseg_get_data(s->xseg, req);
if (!data) {
archipelagolog("Cannot get XSEG data\n");
goto err_exit;
}
qemu_iovec_to_buf(aio_cb->qiov, bufidx, data, count);
}
xport p = xseg_submit(s->xseg, req, s->srcport, X_ALLOC);
if (p == NoPort) {
archipelagolog("Could not submit XSEG request\n");
goto err_exit;
}
xseg_signal(s->xseg, p);
return 0;
err_exit:
g_free(reqdata);
xseg_put_request(s->xseg, req, s->srcport);
return -EIO;
err_exit2:
g_free(reqdata);
return -EIO;
}
| 1threat |
150 years ago today in PHP : <p>I am looking to have a one line return function to get the date 150 years ago from today.</p>
<p>I currently have,</p>
<pre><code>return date('Y-m-d', strtotime('-150 year'));
</code></pre>
<p>The problem is this returns 1970-01-01 instead of 150 years ago.</p>
<p>Why is this?</p>
| 0debug |
HTTPURLResponse allHeaderFields Swift 3 Capitalisation : <p>Converting to Swift 3 I noticed a strange bug occur reading a header field from HTTPURLResponse.</p>
<pre><code>let id = httpResponse.allHeaderFields["eTag"] as? String
</code></pre>
<p>no longer worked.</p>
<p>I printed out the all headers dictionary and all my header keys seem to be in Sentence case.</p>
<p>According to Charles proxy all my headers are in lower case. According to the backend team, in their code the headers are in Title-Case. According the docs: headers should be case-insensitive. </p>
<p>So I don't know which to believe. Is anyone else finding in Swift 3 that their headers are now being turned into Sentence case by iOS? If so is this behaviour we want?</p>
<p>Should I log a bug with Apple or should I just make a category on HTTPURLResponse to allow myself to case insensitively find a header value.</p>
| 0debug |
Using react with a html template : <p>I bought a HTML template on theme forest. I would like to use react with it. How do I go about implementing react with this template? I am able to do this with angular easy, but I would like to learn React.</p>
| 0debug |
Deleting a program after a certain amount of days using a batch file : <p>I wrote a PHP script for DevelStudio that creates a batch file, inserts commands and runs it, but it gives me an unexpected T_STRING error on 2nd line, but I cant understand whats exacly wrong</p>
<pre><code>$edit1 = c('Form2->edit1')->text;
$batcode = "forfiles -p "c:\kursach" -s -m *.* /D -$edit1 /C "cmd /c del @path""
//the code that will be inserted in run.bat
$file = 'run.bat'; //name of the batch file
file_put_contents($file, $batcode.'"'. EXE_NAME . '"'); //insert $batcode in $file (run.bat)
run($file); //starts a batch file
</code></pre>
| 0debug |
rstudio data column matching : I'm currently working on the project where I have about multiple CSV files need to match all combinations of events people attended by matching their customer id. They have been to multiple events. I need the events matched in a new column separated by comma. There is multiple data sets that need to be compared. Vlookup in excel was freezing due to the amount of data. How can I do this in Rstudio? I have tidyverse already installed. Any suggestions?
List 1 (one CSV file) List 2 (second CSV file)
LastName FirstName CustID Event LastName FirstName CustID Event
Robson Jonson 23019 NP5 Robson Jonson 23019 GRT2
Robson Jonson 23019 RTE3
Result Needed
LastName FirstName CustID Matched Events
Rob Jonson 23019 NPS, GRT2, RTE3 | 0debug |
def multiply_elements(test_tup):
res = tuple(i * j for i, j in zip(test_tup, test_tup[1:]))
return (res) | 0debug |
How can I make a React "If" component that acts like a real "if" in Typescript? : <p>I made a simple <code><If /></code> function component using React:</p>
<pre><code>import React, { ReactElement } from "react";
interface Props {
condition: boolean;
comment?: any;
}
export function If(props: React.PropsWithChildren<Props>): ReactElement | null {
if (props.condition) {
return <>{props.children}</>;
}
return null;
}
</code></pre>
<p>It lets me write a cleaner code, such as:</p>
<pre><code>render() {
...
<If condition={truthy}>
presnet if truthy
</If>
...
</code></pre>
<p>In most cases, it works good, But when I want to check for example if a given variable is not defined and then pass it as property, it becomes an issue. I'll give an example:</p>
<p>Let's say I have a component called <code><Animal /></code> which has the following Props:</p>
<pre><code>interface AnimalProps {
animal: Animal;
}
</code></pre>
<p>and now I have another component which renders the following DOM:</p>
<pre><code>const animal: Animal | undefined = ...;
return (
<If condition={animal !== undefined} comment="if animal is defined, then present it">
<Animal animal={animal} /> // <-- Error! expected Animal, but got Animal | undefined
</If>
);
</code></pre>
<p>As I commented, althought in fact animal is not defined, I've got no way of telling Typescript that I already checked it. Assertion of <code>animal!</code> would work, but that's not what I'm looking for.</p>
<p>Any ideas?</p>
| 0debug |
Php function creates new array (data) from input or references to it? : <p>I have a general php question. I have an array of size lets say size of 3. And I pass it as an input to a function in an included file. So, does it copy the array (more memory) or actually make the function to references it ?</p>
<pre><code>$arr = array('a', 'b', 'c');
include(functions.php); //doSomething() resides here
$result = doSomething($arr);
</code></pre>
| 0debug |
static av_cold void ffat_encode_flush(AVCodecContext *avctx)
{
ATDecodeContext *at = avctx->priv_data;
AudioConverterReset(at->converter);
av_frame_unref(&at->new_in_frame);
av_frame_unref(&at->in_frame);
}
| 1threat |
Scala REPL in Gradle : <p>At the moment Gradle's scala integration does not offer REPL functionality. How to ergonomically run a Scala REPL from Gradle with the appropriate classpath?</p>
| 0debug |
How to click on a ui-sref link in Protractor? : <p>I am using protractor and I wanted to know how to use ui-sref state to test. I tried using "by.linkUiSref" but it gave me error : by.linkUiSref is not a function</p>
| 0debug |
static int faac_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
FAACContext *s = (FAACContext *) avctx->priv_data;
#ifndef FAAD2_VERSION
unsigned long bytesconsumed;
short *sample_buffer = NULL;
unsigned long samples;
int out;
#else
faacDecFrameInfo frame_info;
void *out;
#endif
if(buf_size == 0)
return 0;
#ifndef FAAD2_VERSION
out = s->faacDecDecode(s->faac_handle,
(unsigned char*)buf,
&bytesconsumed,
data,
&samples);
samples *= s->sample_size;
if (data_size)
*data_size = samples;
return (buf_size < (int)bytesconsumed)
? buf_size : (int)bytesconsumed;
#else
if(!s->init){
unsigned long srate;
unsigned char channels;
int r = s->faacDecInit(s->faac_handle, buf, buf_size, &srate, &channels);
if(r < 0){
av_log(avctx, AV_LOG_ERROR, "faac: codec init failed: %s\n",
s->faacDecGetErrorMessage(frame_info.error));
return 0;
}
avctx->sample_rate = srate;
avctx->channels = channels;
s->init = 1;
}
out = s->faacDecDecode(s->faac_handle, &frame_info, (unsigned char*)buf, (unsigned long)buf_size);
if (frame_info.error > 0) {
av_log(avctx, AV_LOG_ERROR, "faac: frame decoding failed: %s\n",
s->faacDecGetErrorMessage(frame_info.error));
return 0;
}
frame_info.samples *= s->sample_size;
memcpy(data, out, frame_info.samples);
if (data_size)
*data_size = frame_info.samples;
return (buf_size < (int)frame_info.bytesconsumed)
? buf_size : (int)frame_info.bytesconsumed;
#endif
}
| 1threat |
Sending Email to SpecifiedPickupDirectory with MailKit : <p>I was using SmtpClient till now with ASP.NET MVC 5. For testing email send functionality on local system, I was using <code>client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;</code></p>
<p>Now, I want to do the same things in ASP.NET Core which does not have SmtpClient class implemented till now. All search for this ended up on <a href="https://github.com/jstedfast/MailKit" rel="noreferrer">MailKit</a>. I have used their send mail code which is working fine with gmail.</p>
<p>I do not want to send testing emails each time and there may be a lot of scenarios in my project where I need to send email. How can I use the local email sending functionality with MailKit. Any links or little source code will help. Thanks</p>
| 0debug |
I am getting a strange undefined reference to error for some of the methods in my ComplexNumber.cpp, I am very new to templates though : <p>Getting c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: main.o:main.cpp:(.text+0x2b): undefined reference to (<em>insert my methods in ComplexNumber.cpp</em>) when compiling using a makefile after the G++ main.o ComplexNumber.o -o output is being ran.</p>
<p>I have tried checking online for places I may have missed a and used my other header files I have done in the past for reference to check for errors there, but I have had no luck. I am using cygdrive on windows to compile, but have also tried just using mingw on regular command prompt as well. </p>
<p>Header File:
'''''''''''''</p>
<pre><code>#include <stdio.h>
#ifndef COMPLEXNUMBER_H_
#define COMPLEXNUMBER_H_
template<typename T>
class ComplexNumber
{
public:
// a is a real number, b is a complex number
T a;
T b;
ComplexNumber();
ComplexNumber(T, T);
void toString();
ComplexNumber operator +(ComplexNumber<T>& c);
ComplexNumber operator *(ComplexNumber<T>& c);
bool operator ==(ComplexNumber<T>& c);
};
#endif /* COMPLEXNUMBER_H_ */
</code></pre>
<p>''''''''''''''</p>
<p>ComplexNumber.cpp
''''''''''''''</p>
<pre><code>#include <iostream>
#include <stdlib.h>
#include <ctime>
#include "ComplexNumber.h"
using namespace std;
template <typename T>
ComplexNumber<T>::ComplexNumber()
{}
template <typename T>
ComplexNumber<T>::ComplexNumber(T a, T b)
{
this->a = a;
this->b = b;
}
template <typename T>
ComplexNumber<T> ComplexNumber<T>:: operator +(ComplexNumber& c)
{
ComplexNumber <T> temp;
// adds the complex numbers, (a+bi) + (c+di) = (a+b) + i(c+d)
temp.a = this->a + c.a;
temp.b = this->b + c.b;
return temp;
}
template <typename T>
ComplexNumber<T> ComplexNumber<T>:: operator *(ComplexNumber& c)
{
ComplexNumber<T> temp;
// multiplies complex numbers, (a+bi) + (c+di) = (a*c-b*d) + i(a*d + b*c)
temp.a = (this->a * c.a) - (temp.b * c.b);
temp.b = (temp.a * c.b) + (temp.b * c.a);
return temp;
}
template <typename T>
bool ComplexNumber<T>:: operator ==(ComplexNumber<T>& c)
{
ComplexNumber<T> temp;
// compares complex numbers to see if they're equal, (a+bi) == (c+di) -> if (a==c) & (b==d)
if (temp.a == c.a && temp.b == c.b)
{
cout<< "The complex numbers are equal."<<endl;
return true;
}
return false;
}
template <typename T>
void ComplexNumber<T>::toString()
{
cout<< "("<< this->a<< " + "<< this->b<< "i)"<<endl;
}
</code></pre>
<p>MakeFile:
''''''''''''''</p>
<pre><code>all: ComplexNumber
ComplexNumber: main.o ComplexNumber.o
g++ main.o ComplexNumber.o -o output
main.o: main.cpp
g++ -c main.cpp
ComplexNumber.o: ComplexNumber.cpp
g++ -c ComplexNumber.cpp
clean:
rm *.o output
</code></pre>
<p>''''''''''''''</p>
| 0debug |
Why Oninput function not work under javascript ? Please Help if possible or Suggest me alternative way : My Html Code
-----------------------------------------------------------------------
<div class="form-group col-sm-12">
<label for="input-text-help" >Select Vendor
</label>
<select name="vname" class="form-control">
<option value="">Select Vendor</option>
<?php
foreach($Fetchvendors as $Fetch){
?>
<option value="<?php echo $Fetch->id;?>"><?php echo $Fetch->name; ?>
</option>
<?php
}
?>
</select>
</div>
<div class="form-group col-sm-12">
<label for="input-text-help"> Date</label>
<input type="text" name="date" id="datepicker" class="form-control">
</div>
<table class="table">
<i class="fa fa-plus" style="margin-left:500px;">**Add More**</i>
<thead>
<th>Material Name</th>
<th>Quantity</th>
<th>Price</th>
</thead>
<tbody>
<tr >
<td>
<select name="mname[]" class="mname">
<option value=""> Select Material </option>
<?php
foreach($FetchMateril as $Fetch){
?>
<option value="<?php echo $Fetch->id;?>"><?php echo $Fetch->mname; ?></option>
<?php
}
?>
</select>
</td>
<td>
<input type="text" name="qty[]" class="quanitity" id="qty" placeholder="Material Unit">
<!--
<select name="qty[]" class="quanitity">
<option>Select Quanitity</option>
<?php for($i=1;$i<=50;$i++){?>
<option><?php echo $i;?></option>
<?php }?>
</select>
-->
</td>
<td>
<input type="text" name="price[]" class="price" id="**price**" *oninput="calculate()"*>
<input type="text" name="Totalprice[]" id="Totalprice" >
</td>
</tr>
</tbody>
</table>
<div class="form-group">
<div class="form-group">
<div class="col-sm-10">
<input type="submit" name="submit" class="btn btn-primary" id="input-text-help" style=" margin-left:300px;" >
</div>
</div>
</form>
</div>
</div>
In my html code have a option to add more row for multiple insert, When i click on add more option it add one row by javascript. in my input tage price **oninput** call calculate function, where calculate function calculate two input field and return in third field.
It Work on row one but in second row totalprice not wotk mean calculate not return any value in third field
My question can oninput="calculate()" function under javascript like
my code when i am click **Add more** option
<script>
$(document).ready(function(){
//alert();
var i = 0;
$(".fa-plus").click(function(){
$(".table").append('<tr><td><select name="mname[]"
class="mname"><option>Select Material</option><?php foreach($FetchMateril as
$Fetch){?><option value="<?php echo $Fetch->id;?>"><?php echo $Fetch-
>mname;?></option><?php }?></select></td><td><input type="text" name="qty[]"
></td><td><input type="text" name="price[]" class="price" value=""></td>
</tr>');
i++;
});
});
</script>
My calculate function
function calculate() {
var myBox1 = document.getElementById('qty').value;
var myBox2 = document.getElementById('price').value;
var result = document.getElementById('Totalprice');
var myResult = myBox1 * myBox2;
//alert(myResult);
document.getElementById('Totalprice').value = myResult;
}
In my html code have a option to add more row for multiple insert, When i click on add more option it add one row by javascript. in my input tage price **oninput** call calculate function, where calculate function calculate two input field and return in third field.
It Work on row one but in second row totalprice not wotk mean calculate not return any value in third field
In my html code have a option to add more row for multiple insert, When i click on add more option it add one row by javascript. in my input tage price **oninput** call calculate function, where calculate function calculate two input field and return in third field.
It Work on row one but in second row totalprice not wotk mean calculate not return any value in third field
In my html code have a option to add more row for multiple insert, When i click on add more option it add one row by javascript. in my input tage price **oninput** call calculate function, where calculate function calculate two input field and return in third field.
It Work on row one but in second row totalprice not wotk mean calculate not return any value in third field
Please help to solve this problem
Thank In Advance | 0debug |
CPP - Convert source code from Windows to Linux : <p>I have a single-file CPP app, built for Windows and is running in command line only.</p>
<p>I am trying to make it compilable also for Linux.</p>
<p>The only libraries the app is using are:</p>
<pre><code>#include <iostream>
#include "setjmp.h"
#include "windows.h"
#include "time.h"
</code></pre>
<p>It also uses all kinds of unsigned integers (uint8, uint16, uint32, uint64).</p>
<p>Other than this there aren't any other Windows-specific APIs.</p>
<p>My question is how to convert the code so it will be compatible with Linux?
Is there an easy way to do this?</p>
| 0debug |
static int tcp_get_msgfds(CharDriverState *chr, int *fds, int num)
{
TCPCharDriver *s = chr->opaque;
int to_copy = (s->read_msgfds_num < num) ? s->read_msgfds_num : num;
if (to_copy) {
memcpy(fds, s->read_msgfds, to_copy * sizeof(int));
g_free(s->read_msgfds);
s->read_msgfds = 0;
s->read_msgfds_num = 0;
return to_copy; | 1threat |
I have a JSON object returned from a web service and I want to extract elements from the object, specifically the first element which is "id"? : [{"id":2,"type":"Asset","assetNumber":"13723","macAddress":null,"networkName":"13723imsmid8","model":{"id":16,"type":"Model","modelName":"M73","manufacturer":{"id":10,"type":"Manufacturer"}}},{"id":3556,"type":"Asset","assetNumber":"13723","macAddress":null,"networkName":null,"model":{"id":16,"type":"Model","modelName":"M73","manufacturer":{"id":10,"type":"Manufacturer"}}},{"id":7196,"type":"Asset","assetNumber":"13723","macAddress":null,"networkName":null,"model":{"id":16,"type":"Model","modelName":"M73","manufacturer":{"id":10,"type":"Manufacturer"}}},{"id":9720,"type":"Asset","assetNumber":"13723","macAddress":null,"networkName":null,"model":{"id":16,"type":"Model","modelName":"M73","manufacturer":{"id":10,"type":"Manufacturer"}}},{"id":11689,"type":"Asset","assetNumber":"13723","macAddress":null,"networkName":null,"model":{"id":68,"type":"Model","modelName":"POC-W211","manufacturer":{"id":19,"type":"Manufacturer"}}},{"id":11906,"type":"Asset","assetNumber":"13723","macAddress":null,"networkName":null,"model":{"id":71,"type":"Model","modelName":"OptiPlex 780","manufacturer":{"id":5,"type":"Manufacturer"}}}] | 0debug |
Temperature symbols in facet labels : <p>I would like to have a facet plot, the labels should be "13℃","20℃","27℃". I tried to make it in data set, sometimes it works, but not always.
Is there some other solutions?
Thank you for any comments.
<a href="https://i.stack.imgur.com/RyU2O.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RyU2O.jpg" alt="facet plot"></a></p>
| 0debug |
C# for loop and encryption : <p>I'm Kind of new to C# but since i have learned other programming languages before, learning it is going pretty well, However I am stuck on this one part, I am trying to "port" my old python application that takes a string or the users input and encrypts it. the python code is below, My problem is doing everything after and including the for loop. How might i go about searching for each letter in the Character string.</p>
<pre><code>CHARACTER= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-=+_)(*&^%$#@!?><|:;}{]["
translated = ''
for uniqueKey in message:
if uniqueKey in CHARACTER:
num = CHARACTER.find(uniqueKey)
if mode == "encrypt":
num += key
elif mode == "decrypt":
num -= key
if num >= len(CHARACTER):
num -= len(CHARACTER)
elif num < 0:
num += len(CHARACTER)
translated = translated + CHARACTER[num]
else:
translated = translated + uniqueKey
</code></pre>
| 0debug |
static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr,
unsigned ch,
uint8_t *do_not_decode,
float *vec, unsigned vlen)
{
if (vr->type == 2)
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 2);
else if (vr->type == 1)
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 1);
else if (vr->type == 0)
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 0);
else {
av_log(vc->avccontext, AV_LOG_ERROR, " Invalid residue type while residue decode?! \n");
return AVERROR_INVALIDDATA;
}
}
| 1threat |
C# query in Linq : <p>I'm using C# in Visual Studio 2015.
I have a <code>List<MagicItem> magicItemList</code> and I'm trying to do a simple query using Linq to fetch an Object that matches the Id that the user inputs.
This is my code:</p>
<pre><code>int itemId = Convert.ToInt32(Console.ReadLine());
var query = from MagicItem magicItem in magicItemList
where magicItem.Id == itemId
select magicItem;
</code></pre>
<p>The thing that confuses me is that <code>query</code>'s type is <code>System.Collections.Generic.IEnumerable</code>, so I can't fetch any of its attributes as a normal Object.</p>
<p>Is there a way to cast it so I can use it as a normal Object? Thanks in advance.</p>
<p>This is my MagicItem Class:</p>
<pre><code>class MagicItem
{
public int Id { get; set; }
public string Name { get; set; }
public int StockLevel { get; set; }
}
</code></pre>
| 0debug |
Has anyone reversed engineered the protocol used by Apple's iOS Remote app for controlling an Apple TV over IP? : <p>I'm curious if it's possible for me to write programs that can control an Apple TV, specifically an Apple TV 4th gen running tvOS 9.1.1, like Apple's Remote app for iOS can. I'd like to send it commands for navigating in the four cardinal directions, selecting an item on the screen, going up the navigation stack -- essentially what Apple's Remote app can do.</p>
<p>Has anyone done any work reverse engineering the protocol it uses? Cursory Googling only has so far yielded out of date results about earlier generation Apple TVs and the DAAP protocol which looks like something different than what I want.</p>
| 0debug |
matlab execute script from command linux line : <p>is there a way to run a matlab script from linux command line?
For instance, I have the following simple script "test.m":</p>
<pre><code>x = [1,2,3];
y = [2;3;4];
prod = x*y
disp(prod)
</code></pre>
<p>So what I want is to be able to execute that script from the linux command line without opening the matlab GUI or the matlab command line. That is, I expect something like that:</p>
<pre><code>~$ matlab test.m
</code></pre>
<p>and I expect to see the result of the product on the linux command line.</p>
<p>I know that you can do that with python e.g.,</p>
<pre><code>~$ python test.py
</code></pre>
<p>but was wondering if the same can be achieved with matlab. </p>
| 0debug |
Postgres sessions are idle with query = COMMIT or ROLLBACK : <p>I have a Postgres 9.5 database for a web-based Java application. Sometimes, the number of sessions suddenly spikes up due to a long running query, and these sessions are not cleared immediately. When I check pg_stat_activity, query column shows COMMIT or ROLLBACK with a stage of idle. This is causing Postgres to hit high thresholds of max_connections, which can possibly cause Production outage.</p>
<p>query | ROLLBACK
state | idle
count | 167</p>
<p>query | COMMIT
state | idle
count | 280</p>
<ol>
<li>What are these COMMIT/ROLLBACK idle sessions? </li>
<li>How can I get these idle sessions to clear immediately? </li>
<li>How can I reduce the number of these idle sessions from being created?</li>
</ol>
<p>Thanks</p>
| 0debug |
If else condition in HTML : <p>I have an application where in index.cshtml file I am loading an external javascript file</p>
<pre><code><head>
<script scr="External Javascript" type="text/javascript"></script>
</head>
</code></pre>
<p>Now the problem is I want to restrict the loading of the file for a few users.
How can I achieve it here?</p>
| 0debug |
static void rtas_set_xive(sPAPREnvironment *spapr, uint32_t token,
uint32_t nargs, target_ulong args,
uint32_t nret, target_ulong rets)
{
struct ics_state *ics = spapr->icp->ics;
uint32_t nr, server, priority;
if ((nargs != 3) || (nret != 1)) {
rtas_st(rets, 0, -3);
return;
}
nr = rtas_ld(args, 0);
server = rtas_ld(args, 1);
priority = rtas_ld(args, 2);
if (!ics_valid_irq(ics, nr) || (server >= ics->icp->nr_servers)
|| (priority > 0xff)) {
rtas_st(rets, 0, -3);
return;
}
ics_write_xive(ics, nr, server, priority, priority);
rtas_st(rets, 0, 0);
}
| 1threat |
What is Promise in javascript? : <p>Before posing this question I have researched lots of related Promise on <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" rel="nofollow noreferrer">MDN</a>. </p>
<p>Can you please explain to me in a simple word like </p>
<ol>
<li>What is Promise?</li>
<li>How and when to use?</li>
<li>Any simple example</li>
</ol>
| 0debug |
C++ references and modification : <p>Lets say I have</p>
<pre><code>void swap(int &x, int &y){
//do swap here
}
</code></pre>
<p>Why is it legal to do: <code>x = y</code> inside of the function so that <strong>it assigns the VALUE of</strong> <code>y</code> to <code>x</code>?</p>
<p>Why isn't some sort of dereferencing needed?</p>
| 0debug |
how to compare two files , if same colum then replace , using awk or sed : Two files,
f1:
1 aaa 123
2 bbb 555
3 ccc 666
f2:
1 aaa 444
2 ddd 666
3 eee 777
When f2 have same as f1 like aaa value, then the r1c3 of f2 replace by r1c3 of f1 , using awk.
output:
1 aaa 123
2 ddd 666
3 eee 777
Thanks
| 0debug |
LocalStorage Saving as Strings : <p>I'm trying to make a speeding application that asks the user to input a pre-defined speed limit through an input, I have used local storage to store the number but it stores it like "number" instead of just the number it places quotation marks around them making it a string and useless in my application.</p>
<p>Here is the JS</p>
<pre><code> var limit = 20;
var limitfield = document.getElementById('limit1') //Places limit1 field from HTML into variable
limitfield.addEventListener('input', updateStorage); //Adds eventlistener to listen to input in limit1 field then call method
function updateStorage (){
localStorage.setItem('limitfield', limitfield.value); //After obtaining the input from eventlistener store the value in variable
setPreference();
}
function setPreference(){
limit = localStorage.getItem('limitfield'); //variable created that retrieves value
}
</code></pre>
| 0debug |
static ssize_t qemu_fill_buffer(QEMUFile *f)
{
int len;
int pending;
assert(!qemu_file_is_writable(f));
pending = f->buf_size - f->buf_index;
if (pending > 0) {
memmove(f->buf, f->buf + f->buf_index, pending);
}
f->buf_index = 0;
f->buf_size = pending;
len = f->ops->get_buffer(f->opaque, f->buf + pending, f->pos,
IO_BUF_SIZE - pending);
if (len > 0) {
f->buf_size += len;
f->pos += len;
} else if (len == 0) {
qemu_file_set_error(f, -EIO);
} else if (len != -EAGAIN) {
qemu_file_set_error(f, len);
}
return len;
}
| 1threat |
static uint16_t eepro100_read2(EEPRO100State * s, uint32_t addr)
{
uint16_t val;
if (addr <= sizeof(s->mem) - sizeof(val)) {
memcpy(&val, &s->mem[addr], sizeof(val));
}
switch (addr) {
case SCBStatus:
case SCBCmd:
TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
break;
case SCBeeprom:
val = eepro100_read_eeprom(s);
TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
break;
default:
logout("addr=%s val=0x%04x\n", regname(addr), val);
missing("unknown word read");
}
return val;
}
| 1threat |
Andrioid request to Server : <p>I am working on android application.
In that app i want, Application request the server on that time also if the application is not connected with the internet.</p>
<p>Is there any way to connect the server in offline time also.</p>
| 0debug |
Javascript setInterval(); does not work? : <p>I am trying to make a script that changes the header's color every second,
I have made a function that styles a HTML element with a random color whenever it's called, and when I use the setInterval(); it does not work!</p>
<pre><code>function randomColor(elementId) {
var colors = ["red","green","blue","purple","lightblue","cyan","yellow","brown","pink","grey"];
var randomNumber = Math.floor(Math.random() * 10) + 1;
document.getElementById(elementId).style.color = colors[randomNumber];
}
setInterval(randomColor("Header"), 1000);
</code></pre>
<p>Can someone help? thanks!</p>
<p>Note:
When I refresh the page it only changes the color once.</p>
| 0debug |
set_phy_ctrl(E1000State *s, int index, uint16_t val)
{
if ((val & MII_CR_AUTO_NEG_EN) && (val & MII_CR_RESTART_AUTO_NEG)) {
qemu_get_queue(s->nic)->link_down = true;
e1000_link_down(s);
s->phy_reg[PHY_STATUS] &= ~MII_SR_AUTONEG_COMPLETE;
DBGOUT(PHY, "Start link auto negotiation\n");
qemu_mod_timer(s->autoneg_timer, qemu_get_clock_ms(vm_clock) + 500);
}
}
| 1threat |
cursor.execute('SELECT * FROM users WHERE username = ' + user_input) | 1threat |
Having trouble compiling an ultimate tic tac to code I found because it is in a different coding language than what I am learning : <p>I have a code that I want to run (mega tic tac toe code) that I got from the description of a video, however its in a different language that i am used to (Im learning java and the code is in C#) so I don't know how I should go about compiling this code. I messed around with some of the more well known compilers like visual studio and mono, however both seemed confusing to me as I am used to the eclipse compiler for java. Here is the video I am referring to. the code should be in the description of the video <a href="https://www.youtube.com/watch?v=oJ3TQdgkfBQ&t=366s" rel="nofollow noreferrer">https://www.youtube.com/watch?v=oJ3TQdgkfBQ&t=366s</a>.
Please let me know any tips or solutions</p>
| 0debug |
static inline void conv_to_int32(int32_t *loc, float *samples, int num, float norm)
{
int i;
for (i = 0; i < num; i++)
loc[i] = ceilf((samples[i]/norm)*INT32_MAX);
}
| 1threat |
User IP address and location in Laravel 5.5 : <p>I am trying to get the ip address and location of user during registration...when user sign up for the first time I want to save the ip address and his location in the database in users table.</p>
<p>Please give me a solution to get the ip address and location of the new user...</p>
<p><strong>Below is the line which i am using but this gives me wrong IP address of localhost...</strong></p>
<pre><code>127.0.0.1
$user = new User([
'firstname' => $data['firstname'],
'lastname' => $data['lastname'],
'company' => $data['company'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
'phone' => $data['phone'],
'country' => $data['country'],
'zipcode' => $data['zipcode'],
'city' => $data['city'],
'state' => $data['state'] == "other" ? $data['custom_state'] : $data['state'],
'ip_address' => request()->ip(),
]);
</code></pre>
| 0debug |
nullptr read access violation while checking in loop : <p>I have this code:</p>
<pre><code>while (current->next->data <= temp->data && current->next != nullptr)
{
current = current->next;
}
</code></pre>
<p>when I run it i get the error:</p>
<p>Exception thrown: read access violation.
current->next was nullptr.</p>
<p>I believe I should not be receiving this error because it is the exact thing I check for; I am new to this, is there something I am doing wrong?</p>
| 0debug |
HTTP Get request from angular to spring backend being blocked by CORS policy : <p>I have a @RestController in my java spring backend:</p>
<pre><code>@GetMapping(value = "/getItems")
public List<Item> getItems()
{
System.out.println("Requested!");
return itemRepository.findAll();
}
</code></pre>
<p>I am trying to retreive the items in my Angular frontend but get the following error:</p>
<pre><code>Access to XMLHttpRequest at 'http://localhost:8080/api/getItems' from origin
'http://localhost:4200' has been blocked by CORS policy: Response to
preflight request doesn't pass access control check: No 'Access-Control-
Allow-Origin' header is present on the requested resource.
</code></pre>
<p>But I am not sure why, because I am adding the correct header in Angular:</p>
<pre><code>getItems() {
this.http.get('http://localhost:8080/api/getItems',
{headers: new HttpHeaders({
'Access-Control-Allow-Origin': 'http://localhost:4200',
'Access-Control-Allow-Methods': 'GET, POST, PUT',
'Access-Control-Allow-Headers': 'Content-Type'
}
)})
.subscribe(
data => {console.log(data);
});
}
</code></pre>
<p>The get request does work in Postman, but I know that the browser is what is causing the problem, and requires that the 'Access-Control-Allow-Origin' header to be present, which I added.
It compiles, but it seems like it's not adding the headers correctly. Does anyone know what's going on here?</p>
| 0debug |
static int qemu_balloon_status(BalloonInfo *info)
{
if (!balloon_stat_fn) {
return 0;
}
balloon_stat_fn(balloon_opaque, info);
return 1;
}
| 1threat |
I am newbie to python, and program I have written has no error but terminal open and close in 10th of second : Here is my code as follows.
# starting of Employee class
class Employee(object):
def __init__(self): #declaring Constructor
self.name = ""
self.iDnumber = ""
self.department = ""
self.jobTitle = ""
# setter methode for setting values to the class properties
def setName(self,name):
self.name=name
def setIDnumber(self,iDnumber):
self.iDnumber=iDnumber
def setDepartment(self,department):
self.department=department
def setJobTitle(self,jobTitle):
self.jobTitle=jobTitle
# getter methode for getting values of the class properties
def getName(self):
return self.name
def getIDnumber(self):
return self.iDnumber
def getDepartment(self):
return self.department
def getJobTitle(self):
return self.jobTitle
# methode which takes object as an argument and display its properties
def display(emp_object):
print("Name : ",emp_object.getName())
print("IDnumber : ",emp_object.getIDnumber())
print("Department : ",emp_object.getDepartment())
print("JobTitle : ",emp_object.getJobTitle())
# Main methode of the program
if __name__ == "__main__":
employeeList = [] #List to hold the Employee objects
emp1 = Employee()
emp2 = Employee()
emp3 = Employee()
# appending objects to the list
employeeList.append(emp1)
employeeList.append(emp2)
employeeList.append(emp3)
# Initializing each objects of the list
for employee in employeeList:
emp_name = input("Enter your Name ")
employee.setName(emp_name)
emp_iDnumber = input("Enter your iDnumber ")
employee.setIDnumber(emp_iDnumber)
emp_department = input("Enter your Department ")
employee.setDepartment(emp_department)
emp_jobTitle = input("Enter your JobTitle ")
employee.setJobTitle(emp_jobTitle)
# Displaying each objects of the list
for emp_object in employeeList:
display(emp_object)
and, when I run it termianl just flash for a 10th of seconds and do not ask for input.
Help me with this thank you.
I am trying to focus on
Display a message asking user to enter employee name, ID, department, and title
b. Read employee name into a variable
c. Call the set name method of the first object passing the name
d. Read employee ID into a variable | 0debug |
static uint32_t lan9118_readw(void *opaque, target_phys_addr_t offset)
{
lan9118_state *s = (lan9118_state *)opaque;
uint32_t val;
if (s->read_word_prev_offset != (offset & ~0x3)) {
s->read_word_n = 0;
s->read_word_prev_offset = offset & ~0x3;
}
s->read_word_n++;
if (s->read_word_n == 1) {
s->read_long = lan9118_readl(s, offset & ~3, 4);
} else {
s->read_word_n = 0;
}
if (offset & 2) {
val = s->read_long >> 16;
} else {
val = s->read_long & 0xFFFF;
}
return val;
}
| 1threat |
How to get month number by week number and year : <p>I want to find the month number by given year and given week number,
example- if my year: 2017 and week number is: 25 what will be the month.</p>
| 0debug |
How to keep footer at the bottom of the page and below content in AngularJS? : <p>I have tried to keep the footer below some content with various methods, but it seems that the solutions don't behave as expected with AngularJS's dynamic content.</p>
<ul>
<li><p>When the page is mostly blank, I want the footer to be at the bottom of the page</p></li>
<li><p>When the page expands (or just big in general), I want the footer to be pushed below the content (<em>not sticky to the page itself</em>)</p></li>
<li><ul>
<li>The same logic should follow when I redirect the page</li>
</ul></li>
</ul>
<p>Here is a small demo that I made to illustrate my attempt. I tried using <code>position: absolute;</code> for my footer, but I don't know how to change that (<em>or use alternatives</em>) once the content expands.</p>
<p><a href="https://plnkr.co/edit/UAzPBS8REGjKC6f5QoUa?p=preview" rel="nofollow noreferrer">Plunker</a></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var app = angular.module('myApp', ['ui.router']);
app.config(function($stateProvider, $urlRouterProvider) {
$stateProvider.
state("main", {
url: "/",
templateUrl: "main.html",
controller: "mainCtrl"
}).
state("small", {
url: "/other/small",
templateUrl: "other_small.html",
controller: "smallCtrl"
}).
state("big", {
url: "/other/big",
templateUrl: "other_big.html",
controller: "bigCtrl"
})
$urlRouterProvider.otherwise('/');
});
app.controller('mainCtrl', function($scope) {
$scope.small_text = "aaa";
$scope.big_text = new Array(100).fill("AAA");
});
app.controller('smallCtrl', function($scope) {
$scope.small_text = "aaa";
});
app.controller('bigCtrl', function($scope) {
$scope.big_text = new Array(100).fill("AAA");
});</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
height: 100%;
margin: 0;
}
footer {
background-color: #999999;
color: #F1F1F1;
text-align: center;
}
.footer {
position: absolute;
bottom: 0;
height: 60px;
width: 100%;
}
.main-view {
background-color: #F1F1F1;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html ng-app="myApp">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/1.0.20/angular-ui-router.min.js"></script>
<body>
<div>
<header>
<h4>Responsive header</h4>
<a ui-sref="main">Main page</a>
<a ui-sref="small">Small page</a>
<a ui-sref="big">Big page</a>
<hr>
</header>
<div class="main-view" ui-view></div>
<footer class="footer">
<h4>
<span>demo website</span> 2018 &copy;
</h4>
</footer>
</div>
<!-- Assume: separate files -->
<script type="text/ng-template" id="main.html">
{{::small_text}}
<div>
<button ng-click="show_big_text=!show_big_text">
{{show_big_text ? 'Hide' : 'Show'}} big text
</button>
<div ng-show="show_big_text" ng-repeat="text in ::big_text track by $index">
{{text}}
</div>
</div>
</script>
<script type="text/ng-template" id="other_small.html">
{{::small_text}}
</script>
<script type="text/ng-template" id="other_big.html">
<div ng-repeat="text in ::big_text track by $index">
{{text}}
</div>
</script>
</body>
</html></code></pre>
</div>
</div>
</p>
| 0debug |
Can somebody help improve this code for counting vowels in a string : <p>I need a code that counts the vowels in a given string, i can create the code that counts the vowels but the problem is that i can't build a code that will count the vowels till the end of the string , so far i have created this code , and i have to give everytime word.charAt(index) beacuse i cannot know how long the given word will be</p>
<pre><code>public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Give a word: ");
String word = scan.nextLine();
int aCounter = 0;
int eCounter = 0;
int iCounter = 0;
int oCounter = 0;
int uCounter = 0;
int yCounter = 0;
for (int i=0; i <= word.length(); i++){
switch(word.charAt(0)){
case 'a': aCounter++; break;
case 'e': eCounter++; break;
case 'i': iCounter++; break;
case 'o': oCounter++; break;
case 'u': uCounter++; break;
case 'y': yCounter++; break;
default:
System.out.println("Letter not found");
}
switch(word.charAt(1)){
case 'a': aCounter++; break;
case 'e': eCounter++; break;
case 'i': iCounter++; break;
case 'o': oCounter++; break;
case 'u': uCounter++; break;
case 'y': yCounter++; break;
default:
System.out.println("Letter not found");
}
}
if (aCounter > 0) System.out.println("In the given word " + word + " are " + aCounter + " a");
if (eCounter > 0) System.out.println("In the given word " + word + " are " + eCounter + " e");
if (iCounter > 0) System.out.println("In the given word " + word + " are " + iCounter + " i");
if (oCounter > 0) System.out.println("In the given word " + word + " are " + oCounter + " o");
if (uCounter > 0) System.out.println("In the given word " + word + " are " + uCounter + " u");
if (yCounter > 0) System.out.println("In the given word " + word + " are " + yCounter + " y");
}
</code></pre>
<p>}</p>
| 0debug |
static void msix_mmio_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
PCIDevice *dev = opaque;
unsigned int offset = addr & (MSIX_PAGE_SIZE - 1) & ~0x3;
int vector = offset / PCI_MSIX_ENTRY_SIZE;
if (vector >= dev->msix_entries_nr) {
return;
}
pci_set_long(dev->msix_table_page + offset, val);
msix_handle_mask_update(dev, vector);
}
| 1threat |
A segementation fault : So I am currently working on this project for school, where I am implementing an algorithm to find a solution for the 'knight game'( it's about finding the shortest way from the top left corner of the board to the bottom right corner), but I've been getting this segmentation fault for three days now, I've checked every pointer I used and everything seems right.
I implented " searching algorithms, bfs and dfs and ucs, the first two ones work fine, but ucs gives me the segmentation fault, even though they use the same thing except a popBest function.
Here are some pictures of the ucs and popBest function :
Item *popBest( list_t *list ) // and remove the best board from the list.
{
assert(list);
assert(list->numElements);
int min_f;
Item *item = list->first;
Item *best;
min_f = list->first->f;
while (item) {
if (item->f < min_f) {
min_f = item->f;
best = item;
}
item = item->next;
}
//item = onList(list, board);
delList(list, best);
return best;
}
void ucs(void)
{
Item *cur_node, *child_p, *temp;
while ( listCount(&openList_p) ) { /* While items are on the open list
printLt(openList_p );
/* Get the first item on the open list
cur_node = popBest(&openList_p);
//printf("%d %f\n", listCount(&openList_p), evaluateBoard( cur_node ));
printBoard(cur_node);
addFirst(&closedList_p, cur_node);
if ( evaluateBoard(cur_node) == 0.0 ) {
showSolution(cur_node);
printf("\nParcours en largeur (bfs)\n" );
return;
}
else {
for (int i = 0; i < MAX_BOARD; i++) {
child_p = getChildBoard( cur_node, i );
if (child_p != NULL) {
child_p->f = cur_node->f+1;
temp = onList(&openList_p, child_p->board);
if (temp ==NULL) addLast( &openList_p, temp);
else if (temp != NULL && child_p->f < temp->f )
{
delList(&openList_p, temp);
addLast( &openList_p, temp);
}
}
}
}
}
return;
}
All the functions work fine for bfs and dfs, the only difference is the popBest function.
It would be awesome if someone can guide me as I am still a beginner, thanks in advance.
PS : sorry for the poor English, I am not a native.
| 0debug |
Welcome page in Visual Studio Code How to get it : <p>I just downloaded <a href="https://code.visualstudio.com/" rel="noreferrer">Visual Studio Code</a> and started playing with it. </p>
<p>The you tube <a href="https://youtu.be/DmbvejtiyNo?t=133" rel="noreferrer">video here</a> recommends Quick Tour Videos. </p>
<p>So the question is how can I see the welcome page on Visual Studio code. When ever I open now, I am not seeing it. Probably when you open for the first time, you are shown this. But once you close that how do I reopen it?</p>
| 0debug |
How To Separate Mysqli Query After Coma : I am bit confused at one situation. I have a table called slam-book in which I have a column named favorite games. Now User enters their data like
"cricket, foot ball, hockey, basket ball"
Now I want to separate this result and want to give link to it like,
<a href="/game.php=cricket">Cricket</a>, <a href="/game.php=foot-ball">Foot Ball</a>, <a href="/game.php=hockey">Hockey</a>, <a href="/basket-ball.php=hockey">Basket Ball</a>
So, I can list all users with specific interest, Please help me to get such result. I want that code which can give me results like #2 code. | 0debug |
Internal Server Error in JSP using SpringMVC, SpringSecurity : I'm trying to check if any user is logged in and show Logout button if yes, and Login button otherwise.
**505**
Type Exception Report
Message An exception occurred processing [/index.jsp] at line [43]
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
org.apache.jasper.JasperException: An exception occurred processing [/index.jsp] at line [43]
40: <a class="btn btn-primary" href="/login" role="button">Login</a>
41: </security:authorize>
42: <security:authorize access="hasAnyRole('CLIENT', 'ADMIN', 'MANAGER')">
43: <form:form cssClass="form-inline m-0">
44: <h6>Hello, <security:authentication property="principal.username"/></h6>
45: <button class="btn btn-warning" formaction="${pageContext.request.contextPath}/logout" formmethod="post">Logout</button>
46: </form:form>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:593)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
I'm using the following code. It works perfectly on both other pages and not working here. Some kind of magic.
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
...
<security:authorize access="!hasAnyRole('CLIENT', 'ADMIN', 'MANAGER')">
<a class="btn btn-primary" href="/login" role="button">Login</a>
</security:authorize>
<security:authorize access="hasAnyRole('CLIENT', 'ADMIN', 'MANAGER')">
<form:form cssClass="form-inline m-0">
<h6>Hello, <security:authentication property="principal.username"/></h6>
<button class="btn btn-warning" formaction="${pageContext.request.contextPath}/logout" formmethod="post">Logout</button>
</form:form>
</security:authorize> | 0debug |
static int cirrus_bitblt_videotovideo_patterncopy(CirrusVGAState * s)
{
return cirrus_bitblt_common_patterncopy(s,
s->vram_ptr +
(s->cirrus_blt_srcaddr & ~7));
}
| 1threat |
storeprocedure why return statement in sqlserver? : general procedure are no return value Then store procedure why return | 0debug |
What is the appropriate machine learning algorithm for a restaurant's sales prediction? : <p>I want to estimate the sales of a restaurant three days in advance, so that the staff can order fresh ingredients in time. I started off using linear regression, but noticed the following:
For the restaurant it is worse, if a customer won't get the food he ordered, compared to the case that food that is eventually thrown away.
I figured I might just need a skewed cost function, but I am not sure. Maybe there is something already implemented. </p>
<p>Another question: Some days, there are some reservations (pre-orders) for the restaurant, so I know they will need at least a certain amount. How to include that?</p>
<p>Thank you!</p>
| 0debug |
static int mov_read_stco(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
unsigned int i, entries;
get_byte(pb);
get_be24(pb);
entries = get_be32(pb);
if(entries >= UINT_MAX/sizeof(int64_t))
return -1;
sc->chunk_offsets = av_malloc(entries * sizeof(int64_t));
if (!sc->chunk_offsets)
return AVERROR(ENOMEM);
sc->chunk_count = entries;
if (atom.type == MKTAG('s','t','c','o'))
for(i=0; i<entries; i++)
sc->chunk_offsets[i] = get_be32(pb);
else if (atom.type == MKTAG('c','o','6','4'))
for(i=0; i<entries; i++)
sc->chunk_offsets[i] = get_be64(pb);
else
return -1;
return 0;
}
| 1threat |
e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
{
E1000State *s = DO_UPCAST(NICState, nc, nc)->opaque;
struct e1000_rx_desc desc;
target_phys_addr_t base;
unsigned int n, rdt;
uint32_t rdh_start;
uint16_t vlan_special = 0;
uint8_t vlan_status = 0, vlan_offset = 0;
uint8_t min_buf[MIN_BUF_SIZE];
size_t desc_offset;
size_t desc_size;
size_t total_size;
if (!(s->mac_reg[RCTL] & E1000_RCTL_EN))
return -1;
if (size < sizeof(min_buf)) {
memcpy(min_buf, buf, size);
memset(&min_buf[size], 0, sizeof(min_buf) - size);
buf = min_buf;
size = sizeof(min_buf);
}
if (!receive_filter(s, buf, size))
return size;
if (vlan_enabled(s) && is_vlan_packet(s, buf)) {
vlan_special = cpu_to_le16(be16_to_cpup((uint16_t *)(buf + 14)));
memmove((uint8_t *)buf + 4, buf, 12);
vlan_status = E1000_RXD_STAT_VP;
vlan_offset = 4;
size -= 4;
}
rdh_start = s->mac_reg[RDH];
desc_offset = 0;
total_size = size + fcs_len(s);
do {
desc_size = total_size - desc_offset;
if (desc_size > s->rxbuf_size) {
desc_size = s->rxbuf_size;
}
if (s->mac_reg[RDH] == s->mac_reg[RDT] && s->check_rxov) {
s->mac_reg[RDH] = rdh_start;
set_ics(s, 0, E1000_ICS_RXO);
return -1;
}
base = ((uint64_t)s->mac_reg[RDBAH] << 32) + s->mac_reg[RDBAL] +
sizeof(desc) * s->mac_reg[RDH];
cpu_physical_memory_read(base, (void *)&desc, sizeof(desc));
desc.special = vlan_special;
desc.status |= (vlan_status | E1000_RXD_STAT_DD);
if (desc.buffer_addr) {
if (desc_offset < size) {
size_t copy_size = size - desc_offset;
if (copy_size > s->rxbuf_size) {
copy_size = s->rxbuf_size;
}
cpu_physical_memory_write(le64_to_cpu(desc.buffer_addr),
(void *)(buf + desc_offset + vlan_offset),
copy_size);
}
desc_offset += desc_size;
desc.length = cpu_to_le16(desc_size);
if (desc_offset >= total_size) {
desc.status |= E1000_RXD_STAT_EOP | E1000_RXD_STAT_IXSM;
} else {
desc.status &= ~E1000_RXD_STAT_EOP;
}
} else {
DBGOUT(RX, "Null RX descriptor!!\n");
}
cpu_physical_memory_write(base, (void *)&desc, sizeof(desc));
if (++s->mac_reg[RDH] * sizeof(desc) >= s->mac_reg[RDLEN])
s->mac_reg[RDH] = 0;
s->check_rxov = 1;
if (s->mac_reg[RDH] == rdh_start) {
DBGOUT(RXERR, "RDH wraparound @%x, RDT %x, RDLEN %x\n",
rdh_start, s->mac_reg[RDT], s->mac_reg[RDLEN]);
set_ics(s, 0, E1000_ICS_RXO);
return -1;
}
} while (desc_offset < total_size);
s->mac_reg[GPRC]++;
s->mac_reg[TPR]++;
n = s->mac_reg[TORL] + size + 4;
if (n < s->mac_reg[TORL])
s->mac_reg[TORH]++;
s->mac_reg[TORL] = n;
n = E1000_ICS_RXT0;
if ((rdt = s->mac_reg[RDT]) < s->mac_reg[RDH])
rdt += s->mac_reg[RDLEN] / sizeof(desc);
if (((rdt - s->mac_reg[RDH]) * sizeof(desc)) <= s->mac_reg[RDLEN] >>
s->rxbuf_min_shift)
n |= E1000_ICS_RXDMT0;
set_ics(s, 0, n);
return size;
}
| 1threat |
Laravel 5.3 Password Broker Customization : <p>Does anyone know how to override the functions used within laravel's password broker? I know the docs:</p>
<p><a href="https://laravel.com/docs/5.3/passwords#resetting-views" rel="noreferrer">https://laravel.com/docs/5.3/passwords#resetting-views</a></p>
<p>Give information on what to do for things like views and a few surface level things but it's not clear at all really or maybe I'm not reading it enough times. </p>
<p>I already know how to override the <code>ResetsPasswords.php</code> Trait but overriding the functionality of the <code>Password::broker()</code> is for the next layer in. </p>
<p>If there is more information needed I can kindly provide some. </p>
<p>Thank you in advance.</p>
| 0debug |
static GenericList *qapi_dealloc_next_list(Visitor *v, GenericList **list,
Error **errp)
{
GenericList *retval = *list;
g_free(retval->value);
*list = retval->next;
return retval;
}
| 1threat |
static int get_codec_data(AVIOContext *pb, AVStream *vst,
AVStream *ast, int myth)
{
nuv_frametype frametype;
if (!vst && !myth)
return 1;
while (!pb->eof_reached) {
int size, subtype;
frametype = avio_r8(pb);
switch (frametype) {
case NUV_EXTRADATA:
subtype = avio_r8(pb);
avio_skip(pb, 6);
size = PKTSIZE(avio_rl32(pb));
if (vst && subtype == 'R') {
vst->codec->extradata_size = size;
vst->codec->extradata = av_malloc(size);
avio_read(pb, vst->codec->extradata, size);
size = 0;
if (!myth)
return 1;
}
break;
case NUV_MYTHEXT:
avio_skip(pb, 7);
size = PKTSIZE(avio_rl32(pb));
if (size != 128 * 4)
break;
avio_rl32(pb);
if (vst) {
vst->codec->codec_tag = avio_rl32(pb);
vst->codec->codec_id =
ff_codec_get_id(ff_codec_bmp_tags, vst->codec->codec_tag);
if (vst->codec->codec_tag == MKTAG('R', 'J', 'P', 'G'))
vst->codec->codec_id = AV_CODEC_ID_NUV;
} else
avio_skip(pb, 4);
if (ast) {
int id;
ast->codec->codec_tag = avio_rl32(pb);
ast->codec->sample_rate = avio_rl32(pb);
ast->codec->bits_per_coded_sample = avio_rl32(pb);
ast->codec->channels = avio_rl32(pb);
ast->codec->channel_layout = 0;
id = ff_wav_codec_get_id(ast->codec->codec_tag,
ast->codec->bits_per_coded_sample);
if (id == AV_CODEC_ID_NONE) {
id = ff_codec_get_id(nuv_audio_tags, ast->codec->codec_tag);
if (id == AV_CODEC_ID_PCM_S16LE)
id = ff_get_pcm_codec_id(ast->codec->bits_per_coded_sample,
0, 0, ~1);
}
ast->codec->codec_id = id;
ast->need_parsing = AVSTREAM_PARSE_FULL;
} else
avio_skip(pb, 4 * 4);
size -= 6 * 4;
avio_skip(pb, size);
return 1;
case NUV_SEEKP:
size = 11;
break;
default:
avio_skip(pb, 7);
size = PKTSIZE(avio_rl32(pb));
break;
}
avio_skip(pb, size);
}
return 0;
}
| 1threat |
Download latest nuget during run-time : During runtime, I want to download the latest dll from nuget library using .net core and load it into the container. | 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.