problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
How to get alpha names for my program? : <p>When you see games in BETA and ALPHA, lets use Minecraft as example, Minecraft when it was in ALPHA the title for the ALPHA versions for Minecraft where like "Minecraft APLHA C1.2.2_C1.2" for example. Not that it's really important but how do they get the numbers and letters (C1.2.2_C1.2 <- these numbers and letters) and what do they represent for is it numbers that are just kinda random? and how does a person go about to getting those numbers for there program? I normally just go ALPHA 1 - how many updates there is but I find it more professional to have titles like this "Minecraft APLHA C1.2.2_C1.2"? Thanks</p>
| 0debug |
static void lan9118_writel(void *opaque, target_phys_addr_t offset,
uint32_t val)
{
lan9118_state *s = (lan9118_state *)opaque;
offset &= 0xff;
if (offset >= 0x20 && offset < 0x40) {
tx_fifo_push(s, val);
return;
}
switch (offset) {
case CSR_IRQ_CFG:
s->irq_cfg = (s->irq_cfg & IRQ_INT) | (val & IRQ_EN);
break;
case CSR_INT_STS:
s->int_sts &= ~val;
break;
case CSR_INT_EN:
s->int_en = val & ~RESERVED_INT;
s->int_sts |= val & SW_INT;
break;
case CSR_FIFO_INT:
DPRINTF("FIFO INT levels %08x\n", val);
s->fifo_int = val;
break;
case CSR_RX_CFG:
if (val & 0x8000) {
s->rx_fifo_used = 0;
s->rx_status_fifo_used = 0;
s->rx_packet_size_tail = s->rx_packet_size_head;
s->rx_packet_size[s->rx_packet_size_head] = 0;
}
s->rx_cfg = val & 0xcfff1ff0;
break;
case CSR_TX_CFG:
if (val & 0x8000) {
s->tx_status_fifo_used = 0;
}
if (val & 0x4000) {
s->txp->state = TX_IDLE;
s->txp->fifo_used = 0;
s->txp->cmd_a = 0xffffffff;
}
s->tx_cfg = val & 6;
break;
case CSR_HW_CFG:
if (val & 1) {
lan9118_reset(&s->busdev.qdev);
} else {
s->hw_cfg = val & 0x003f300;
}
break;
case CSR_RX_DP_CTRL:
if (val & 0x80000000) {
s->rxp_pad = 0;
s->rxp_offset = 0;
if (s->rxp_size == 0) {
rx_fifo_pop(s);
s->rxp_pad = 0;
s->rxp_offset = 0;
}
s->rx_fifo_head += s->rxp_size;
if (s->rx_fifo_head >= s->rx_fifo_size) {
s->rx_fifo_head -= s->rx_fifo_size;
}
}
break;
case CSR_PMT_CTRL:
if (val & 0x400) {
phy_reset(s);
}
s->pmt_ctrl &= ~0x34e;
s->pmt_ctrl |= (val & 0x34e);
break;
case CSR_GPIO_CFG:
s->gpio_cfg = val & 0x7777071f;
break;
case CSR_GPT_CFG:
if ((s->gpt_cfg ^ val) & GPT_TIMER_EN) {
if (val & GPT_TIMER_EN) {
ptimer_set_count(s->timer, val & 0xffff);
ptimer_run(s->timer, 0);
} else {
ptimer_stop(s->timer);
ptimer_set_count(s->timer, 0xffff);
}
}
s->gpt_cfg = val & (GPT_TIMER_EN | 0xffff);
break;
case CSR_WORD_SWAP:
s->word_swap = val;
break;
case CSR_MAC_CSR_CMD:
s->mac_cmd = val & 0x4000000f;
if (val & 0x80000000) {
if (val & 0x40000000) {
s->mac_data = do_mac_read(s, val & 0xf);
DPRINTF("MAC read %d = 0x%08x\n", val & 0xf, s->mac_data);
} else {
DPRINTF("MAC write %d = 0x%08x\n", val & 0xf, s->mac_data);
do_mac_write(s, val & 0xf, s->mac_data);
}
}
break;
case CSR_MAC_CSR_DATA:
s->mac_data = val;
break;
case CSR_AFC_CFG:
s->afc_cfg = val & 0x00ffffff;
break;
case CSR_E2P_CMD:
lan9118_eeprom_cmd(s, (val >> 28) & 7, val & 0xff);
break;
case CSR_E2P_DATA:
s->e2p_data = val & 0xff;
break;
default:
hw_error("lan9118_write: Bad reg 0x%x = %x\n", (int)offset, val);
break;
}
lan9118_update(s);
}
| 1threat |
int kqemu_init(CPUState *env)
{
struct kqemu_init kinit;
int ret, version;
#ifdef _WIN32
DWORD temp;
#endif
if (!kqemu_allowed)
return -1;
#ifdef _WIN32
kqemu_fd = CreateFile(KQEMU_DEVICE, GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
NULL);
if (kqemu_fd == KQEMU_INVALID_FD) {
fprintf(stderr, "Could not open '%s' - QEMU acceleration layer not activated: %lu\n",
KQEMU_DEVICE, GetLastError());
return -1;
}
#else
kqemu_fd = open(KQEMU_DEVICE, O_RDWR);
if (kqemu_fd == KQEMU_INVALID_FD) {
fprintf(stderr, "Could not open '%s' - QEMU acceleration layer not activated: %s\n",
KQEMU_DEVICE, strerror(errno));
return -1;
}
#endif
version = 0;
#ifdef _WIN32
DeviceIoControl(kqemu_fd, KQEMU_GET_VERSION, NULL, 0,
&version, sizeof(version), &temp, NULL);
#else
ioctl(kqemu_fd, KQEMU_GET_VERSION, &version);
#endif
if (version != KQEMU_VERSION) {
fprintf(stderr, "Version mismatch between kqemu module and qemu (%08x %08x) - disabling kqemu use\n",
version, KQEMU_VERSION);
goto fail;
}
pages_to_flush = qemu_vmalloc(KQEMU_MAX_PAGES_TO_FLUSH *
sizeof(uint64_t));
if (!pages_to_flush)
goto fail;
ram_pages_to_update = qemu_vmalloc(KQEMU_MAX_RAM_PAGES_TO_UPDATE *
sizeof(uint64_t));
if (!ram_pages_to_update)
goto fail;
modified_ram_pages = qemu_vmalloc(KQEMU_MAX_MODIFIED_RAM_PAGES *
sizeof(uint64_t));
if (!modified_ram_pages)
goto fail;
modified_ram_pages_table =
qemu_mallocz(kqemu_phys_ram_size >> TARGET_PAGE_BITS);
if (!modified_ram_pages_table)
goto fail;
memset(&kinit, 0, sizeof(kinit));
kinit.ram_base = kqemu_phys_ram_base;
kinit.ram_size = kqemu_phys_ram_size;
kinit.ram_dirty = phys_ram_dirty;
kinit.pages_to_flush = pages_to_flush;
kinit.ram_pages_to_update = ram_pages_to_update;
kinit.modified_ram_pages = modified_ram_pages;
#ifdef _WIN32
ret = DeviceIoControl(kqemu_fd, KQEMU_INIT, &kinit, sizeof(kinit),
NULL, 0, &temp, NULL) == TRUE ? 0 : -1;
#else
ret = ioctl(kqemu_fd, KQEMU_INIT, &kinit);
#endif
if (ret < 0) {
fprintf(stderr, "Error %d while initializing QEMU acceleration layer - disabling it for now\n", ret);
fail:
kqemu_closefd(kqemu_fd);
kqemu_fd = KQEMU_INVALID_FD;
return -1;
}
kqemu_update_cpuid(env);
env->kqemu_enabled = kqemu_allowed;
nb_pages_to_flush = 0;
nb_ram_pages_to_update = 0;
qpi_init();
return 0;
}
| 1threat |
System.out.println(-1); I know output will be -1 but what is -1 . Integer Or String? what Java Consider : when we write System.out.println(-1); then in this example? Java Consider -1 as Integer OR String? out of this Line is -1. | 0debug |
document.write('<script src="evil.js"></script>'); | 1threat |
Building Android Automotive from source : <h2>TL;DR</h2>
<p>After building Android Automotive from source, how do I</p>
<ol>
<li>Run the car-emulator? </li>
<li>"Install" the CarService and related packages onto a device?</li>
</ol>
<h2>Details</h2>
<p>I'm trying to build <a href="https://source.android.com/devices/automotive/" rel="noreferrer">Android Automotive</a> from source. I'm able to successfully build it using the following commands:</p>
<p><code>
$ repo init -u https://android.googlesource.com/platform/manifest -b android-8.0.0_r11
$ source build/envsetup.sh
$ lunch car_emu_x86_64-userdebug
$ make -j8 V=1 &>> make.log
</code></p>
<p>My question is how do I run the emulator? After googling and going through some stackoverflow posts, I came across this:</p>
<p>First, I set an env variable in the command-line (The emulator uses this to determine which emulator to launch)</p>
<p><code>export ANDROID_PRODUCT_OUT=/path/to/build_root</code></p>
<p>Next, I created a file <code>car-emulator.sh</code> and put this in it (the build was done on an Ubuntu machine)</p>
<pre><code>#!/usr/bin/env bash
ANDROID_BUILD_OUT=/path/to/build_root/out
PREBUILT=/path/to/build_root/prebuilts
EMULATOR_OUT=${ANDROID_BUILD_OUT}/target/product/car-x86_64
${PREBUILT}/android-emulator/linux-x86_64/emulator \
-sysdir ${EMULATOR_OUT} \
-system ${EMULATOR_OUT}/system.img \
-ramdisk ${EMULATOR_OUT}/ramdisk.img \
-data ${EMULATOR_OUT}/userdata.img \
-kernel ${PREBUILT}/qemu-kernel/x86_64/kernel-qemu \
-scale 0.7 \
-memory 512 \
-partition-size 1024
</code></pre>
<p>I also tried to download the relevant (darwin-x86_64) files from the build machine to my Mac laptop and tried running there. The emulator starts but crashes immediately with a huge native stack trace.</p>
<p>The next part of my question is how do I install this image on a device?
I see that the CarService.apk has been generated. Is it sufficient to install this APK on a device for it to work? Or should the CarService and related packages be part of a system image that needs to be flashed in its entirety?</p>
| 0debug |
How to decompile an apk and save project? : <p>I need to decompile .apk file, and save it. I'm using <a href="http://www.javadecompilers.com/" rel="nofollow">http://www.javadecompilers.com/</a> , but I don't know how to save the folders. </p>
| 0debug |
The meaning of Loop : I saw a loop in a demo code:
````
b <- 3
n <- 4
set.seed(1)
(i <- sample(rep(1:n,
b)) )
(g <- rep(1:b,
each=n) )
(x <- rnorm(n) )
m <- rep(NA, max(g))
for (j in 1:max(g) ) {
k <- i[ g == j ]
m[j] <- mean(x[k])
print (j)
print (k)
}
````
The max(g) = 3, so the loop run 3 times. but I don't understand the second row of the loop ` k <- i[ g == j ] `. What is the meaning of this part? Thank you! | 0debug |
How to check which subclass is object of superclass? : <p><strong>To explain my question:</strong>
Car, Boat, Airplane are subclasses from Toy class.
How can I check which subclass is object of Toy class?</p>
| 0debug |
static void hda_audio_command(HDACodecDevice *hda, uint32_t nid, uint32_t data)
{
HDAAudioState *a = HDA_AUDIO(hda);
HDAAudioStream *st;
const desc_node *node = NULL;
const desc_param *param;
uint32_t verb, payload, response, count, shift;
if ((data & 0x70000) == 0x70000) {
verb = (data >> 8) & 0xfff;
payload = data & 0x00ff;
} else {
verb = (data >> 8) & 0xf00;
payload = data & 0xffff;
}
node = hda_codec_find_node(a->desc, nid);
if (node == NULL) {
goto fail;
}
dprint(a, 2, "%s: nid %d (%s), verb 0x%x, payload 0x%x\n",
__FUNCTION__, nid, node->name, verb, payload);
switch (verb) {
case AC_VERB_PARAMETERS:
param = hda_codec_find_param(node, payload);
if (param == NULL) {
goto fail;
}
hda_codec_response(hda, true, param->val);
break;
case AC_VERB_GET_SUBSYSTEM_ID:
hda_codec_response(hda, true, a->desc->iid);
break;
case AC_VERB_GET_CONNECT_LIST:
param = hda_codec_find_param(node, AC_PAR_CONNLIST_LEN);
count = param ? param->val : 0;
response = 0;
shift = 0;
while (payload < count && shift < 32) {
response |= node->conn[payload] << shift;
payload++;
shift += 8;
}
hda_codec_response(hda, true, response);
break;
case AC_VERB_GET_CONFIG_DEFAULT:
hda_codec_response(hda, true, node->config);
break;
case AC_VERB_GET_PIN_WIDGET_CONTROL:
hda_codec_response(hda, true, node->pinctl);
break;
case AC_VERB_SET_PIN_WIDGET_CONTROL:
if (node->pinctl != payload) {
dprint(a, 1, "unhandled pin control bit\n");
}
hda_codec_response(hda, true, 0);
break;
case AC_VERB_SET_CHANNEL_STREAMID:
st = a->st + node->stindex;
if (st->node == NULL) {
goto fail;
}
hda_audio_set_running(st, false);
st->stream = (payload >> 4) & 0x0f;
st->channel = payload & 0x0f;
dprint(a, 2, "%s: stream %d, channel %d\n",
st->node->name, st->stream, st->channel);
hda_audio_set_running(st, a->running_real[st->output * 16 + st->stream]);
hda_codec_response(hda, true, 0);
break;
case AC_VERB_GET_CONV:
st = a->st + node->stindex;
if (st->node == NULL) {
goto fail;
}
response = st->stream << 4 | st->channel;
hda_codec_response(hda, true, response);
break;
case AC_VERB_SET_STREAM_FORMAT:
st = a->st + node->stindex;
if (st->node == NULL) {
goto fail;
}
st->format = payload;
hda_codec_parse_fmt(st->format, &st->as);
hda_audio_setup(st);
hda_codec_response(hda, true, 0);
break;
case AC_VERB_GET_STREAM_FORMAT:
st = a->st + node->stindex;
if (st->node == NULL) {
goto fail;
}
hda_codec_response(hda, true, st->format);
break;
case AC_VERB_GET_AMP_GAIN_MUTE:
st = a->st + node->stindex;
if (st->node == NULL) {
goto fail;
}
if (payload & AC_AMP_GET_LEFT) {
response = st->gain_left | (st->mute_left ? AC_AMP_MUTE : 0);
} else {
response = st->gain_right | (st->mute_right ? AC_AMP_MUTE : 0);
}
hda_codec_response(hda, true, response);
break;
case AC_VERB_SET_AMP_GAIN_MUTE:
st = a->st + node->stindex;
if (st->node == NULL) {
goto fail;
}
dprint(a, 1, "amp (%s): %s%s%s%s index %d gain %3d %s\n",
st->node->name,
(payload & AC_AMP_SET_OUTPUT) ? "o" : "-",
(payload & AC_AMP_SET_INPUT) ? "i" : "-",
(payload & AC_AMP_SET_LEFT) ? "l" : "-",
(payload & AC_AMP_SET_RIGHT) ? "r" : "-",
(payload & AC_AMP_SET_INDEX) >> AC_AMP_SET_INDEX_SHIFT,
(payload & AC_AMP_GAIN),
(payload & AC_AMP_MUTE) ? "muted" : "");
if (payload & AC_AMP_SET_LEFT) {
st->gain_left = payload & AC_AMP_GAIN;
st->mute_left = payload & AC_AMP_MUTE;
}
if (payload & AC_AMP_SET_RIGHT) {
st->gain_right = payload & AC_AMP_GAIN;
st->mute_right = payload & AC_AMP_MUTE;
}
hda_audio_set_amp(st);
hda_codec_response(hda, true, 0);
break;
case AC_VERB_SET_POWER_STATE:
case AC_VERB_GET_POWER_STATE:
case AC_VERB_GET_SDI_SELECT:
hda_codec_response(hda, true, 0);
break;
default:
goto fail;
}
return;
fail:
dprint(a, 1, "%s: not handled: nid %d (%s), verb 0x%x, payload 0x%x\n",
__FUNCTION__, nid, node ? node->name : "?", verb, payload);
hda_codec_response(hda, true, 0);
}
| 1threat |
Using Vue.set in object with multiple nested objects : <p>I am trying to use <code>Vue.set()</code> to update a state object in Vue 2. </p>
<p>This is what the object looks like: </p>
<pre><code>state: {
entries: [
// entry 1
fields: {
someProperties : ''
// here I would like to add another property named 'googleInfos'
}
], [
// entry 2
fields: {
someProperties : ''
// here I would like to add another property named 'googleInfos'
}
]
}
</code></pre>
<p>So far, I was updating it with this mutation. I'm mutating each entry separately because they have different content. </p>
<pre><code>ADD_GOOGLE_INFOS (state, {index, infos}) {
state.entries[index].fields.googleInfos = infos
}
</code></pre>
<p>Now, I'm trying to implement <code>Vue.set()</code> to avoid a <a href="https://vuejs.org/v2/guide/reactivity.html#Change-Detection-Caveats" rel="noreferrer">change detection caveat</a>.</p>
<p>My problem is that I can't find the proper way to add it.</p>
<p>Here's how Vue.set() is supposed to work : </p>
<pre><code>Vue.set(state.object, key, value)
</code></pre>
<p>So I tried this, which doesn't seem to work because <code>state.entries[index]</code> is not an object of first rank :</p>
<pre><code>Vue.set(state.entries[index], 'fields.googleInfos', infos)
</code></pre>
<p>But this doesn't work either :</p>
<pre><code>Vue.set(state.entries, '[index].fields.googleInfos', infos)
</code></pre>
<p>Any one has a clue what I'm doing wrong ?</p>
| 0debug |
polynomial Assingment through file in c : I want to assign the exponent and coefficient information input from the file to the circular linked list.
file "a.txt" is as follows
8 3
7 2
3 0
However, there are also strange values in the output like this. i wanted to make the list circular, but it doesn't.
coef expon
3 0
7 2
8 3
7887744 0
7900240 0
7864656 0
7869712 0
7900240 0
7864656 0
7869712 0
please, I can't find the solution.
#include <stdio.h>
#include <stdlib.h>
typedef struct polyNode* polyPointer;
typedef struct polyNode{
int coef;
int expon;
polyPointer link;
};
int main() {
polyPointer A, B, C = (polyPointer)malloc(sizeof(polyPointer)) ;
FILE *fa, *fb ;
int a;
fa = fopen("a.txt", "r");
if(fa==NULL){
printf("file open error\n");
return 1;
}
if(fb==NULL){
printf("file open error\n");
return 1;
}
A = create_circle_linked_poly(fa);
printf("coef expon\n");
int i;
for(A; i<10; A=A->link, i++)
printf("%d %d\n", A->coef, A->expon);
return 0;
}
polyPointer create_circle_linked_poly(FILE *a){
polyPointer head = malloc(sizeof(polyPointer));
polyPointer temp = malloc(sizeof(polyPointer));
first = head;
int res;
while(1){
polyPointer p =(polyPointer) malloc(sizeof(polyPointer));
res = fscanf(a, "%d %d", &p->coef, &p->expon);
if(res==EOF)break;
p->link = head;
head = p;
}
return head;
} | 0debug |
void stb_tce(VIOsPAPRDevice *dev, uint64_t taddr, uint8_t val)
{
spapr_tce_dma_write(dev, taddr, &val, sizeof(val));
}
| 1threat |
static int mov_write_audio_tag(ByteIOContext *pb, MOVTrack* track)
{
int pos = url_ftell(pb);
put_be32(pb, 0);
if(track->enc->codec_id == CODEC_ID_PCM_MULAW)
put_tag(pb, "ulaw");
else if(track->enc->codec_id == CODEC_ID_PCM_ALAW)
put_tag(pb, "alaw");
else if(track->enc->codec_id == CODEC_ID_ADPCM_IMA_QT)
put_tag(pb, "ima4");
else if(track->enc->codec_id == CODEC_ID_MACE3)
put_tag(pb, "MAC3");
else if(track->enc->codec_id == CODEC_ID_MACE6)
put_tag(pb, "MAC6");
else if(track->enc->codec_id == CODEC_ID_AAC)
put_tag(pb, "mp4a");
else if(track->enc->codec_id == CODEC_ID_AMR_NB)
put_tag(pb, "samr");
else
put_tag(pb, " ");
put_be32(pb, 0);
put_be16(pb, 0);
put_be16(pb, 1);
put_be16(pb, 0);
put_be16(pb, 0);
put_be32(pb, 0);
put_be16(pb, track->enc->channels);
put_be16(pb, 0x10);
put_be16(pb, 0);
put_be16(pb, 0);
put_be16(pb, track->timescale);
put_be16(pb, 0);
if(track->enc->codec_id == CODEC_ID_AAC)
mov_write_esds_tag(pb, track);
if(track->enc->codec_id == CODEC_ID_AMR_NB)
mov_write_damr_tag(pb);
return updateSize (pb, pos);
}
| 1threat |
static void xen_platform_ioport_writeb(void *opaque, uint32_t addr, uint32_t val)
{
PCIXenPlatformState *s = opaque;
addr &= 0xff;
val &= 0xff;
switch (addr) {
case 0:
platform_fixed_ioport_writeb(opaque, XEN_PLATFORM_IOPORT, val);
break;
case 8:
log_writeb(s, val);
break;
default:
break;
}
}
| 1threat |
void set_context_opts(void *ctx, void *opts_ctx, int flags, AVCodec *codec)
{
int i;
void *priv_ctx=NULL;
if(!strcmp("AVCodecContext", (*(AVClass**)ctx)->class_name)){
AVCodecContext *avctx= ctx;
if(codec && codec->priv_class && avctx->priv_data){
priv_ctx= avctx->priv_data;
}
} else if (!strcmp("AVFormatContext", (*(AVClass**)ctx)->class_name)) {
AVFormatContext *avctx = ctx;
if (avctx->oformat && avctx->oformat->priv_class) {
priv_ctx = avctx->priv_data;
}
}
for(i=0; i<opt_name_count; i++){
char buf[256];
const AVOption *opt;
const char *str= av_get_string(opts_ctx, opt_names[i], &opt, buf, sizeof(buf));
if(str && ((opt->flags & flags) == flags))
av_set_string3(ctx, opt_names[i], str, 1, NULL);
if(!str && priv_ctx) {
if (av_find_opt(priv_ctx, opt_names[i], NULL, flags, flags))
av_set_string3(priv_ctx, opt_names[i], opt_values[i], 0, NULL);
}
}
}
| 1threat |
static uint8_t get_sot(J2kDecoderContext *s)
{
if (s->buf_end - s->buf < 4)
return AVERROR(EINVAL);
s->curtileno = bytestream_get_be16(&s->buf);
if((unsigned)s->curtileno >= s->numXtiles * s->numYtiles){
s->curtileno=0;
return AVERROR(EINVAL);
}
s->buf += 4;
if (!bytestream_get_byte(&s->buf)){
J2kTile *tile = s->tile + s->curtileno;
memcpy(tile->codsty, s->codsty, s->ncomponents * sizeof(J2kCodingStyle));
memcpy(tile->qntsty, s->qntsty, s->ncomponents * sizeof(J2kQuantStyle));
}
bytestream_get_byte(&s->buf);
return 0;
}
| 1threat |
Remove part of an email with postgresql : I have emails like sales@joebloggs.com
I am looking to select out everything after the @ and before the .
Result should = joebloggs
| 0debug |
static int qcow_create2(const char *filename, int64_t total_size,
const char *backing_file, const char *backing_format,
int flags)
{
int fd, header_size, backing_filename_len, l1_size, i, shift, l2_bits;
int backing_format_len = 0;
QCowHeader header;
uint64_t tmp, offset;
QCowCreateState s1, *s = &s1;
QCowExtension ext_bf = {0, 0};
memset(s, 0, sizeof(*s));
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
if (fd < 0)
return -1;
memset(&header, 0, sizeof(header));
header.magic = cpu_to_be32(QCOW_MAGIC);
header.version = cpu_to_be32(QCOW_VERSION);
header.size = cpu_to_be64(total_size * 512);
header_size = sizeof(header);
backing_filename_len = 0;
if (backing_file) {
if (backing_format) {
ext_bf.magic = QCOW_EXT_MAGIC_BACKING_FORMAT;
backing_format_len = strlen(backing_format);
ext_bf.len = (backing_format_len + 7) & ~7;
header_size += ((sizeof(ext_bf) + ext_bf.len + 7) & ~7);
}
header.backing_file_offset = cpu_to_be64(header_size);
backing_filename_len = strlen(backing_file);
header.backing_file_size = cpu_to_be32(backing_filename_len);
header_size += backing_filename_len;
}
s->cluster_bits = 12;
s->cluster_size = 1 << s->cluster_bits;
header.cluster_bits = cpu_to_be32(s->cluster_bits);
header_size = (header_size + 7) & ~7;
if (flags & BLOCK_FLAG_ENCRYPT) {
header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES);
} else {
header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
}
l2_bits = s->cluster_bits - 3;
shift = s->cluster_bits + l2_bits;
l1_size = (((total_size * 512) + (1LL << shift) - 1) >> shift);
offset = align_offset(header_size, s->cluster_size);
s->l1_table_offset = offset;
header.l1_table_offset = cpu_to_be64(s->l1_table_offset);
header.l1_size = cpu_to_be32(l1_size);
offset += align_offset(l1_size * sizeof(uint64_t), s->cluster_size);
s->refcount_table = qemu_mallocz(s->cluster_size);
s->refcount_block = qemu_mallocz(s->cluster_size);
s->refcount_table_offset = offset;
header.refcount_table_offset = cpu_to_be64(offset);
header.refcount_table_clusters = cpu_to_be32(1);
offset += s->cluster_size;
s->refcount_table[0] = cpu_to_be64(offset);
s->refcount_block_offset = offset;
offset += s->cluster_size;
create_refcount_update(s, 0, header_size);
create_refcount_update(s, s->l1_table_offset, l1_size * sizeof(uint64_t));
create_refcount_update(s, s->refcount_table_offset, s->cluster_size);
create_refcount_update(s, s->refcount_block_offset, s->cluster_size);
write(fd, &header, sizeof(header));
if (backing_file) {
if (backing_format_len) {
char zero[16];
int d = ext_bf.len - backing_format_len;
memset(zero, 0, sizeof(zero));
cpu_to_be32s(&ext_bf.magic);
cpu_to_be32s(&ext_bf.len);
write(fd, &ext_bf, sizeof(ext_bf));
write(fd, backing_format, backing_format_len);
if (d>0) {
write(fd, zero, d);
}
}
write(fd, backing_file, backing_filename_len);
}
lseek(fd, s->l1_table_offset, SEEK_SET);
tmp = 0;
for(i = 0;i < l1_size; i++) {
write(fd, &tmp, sizeof(tmp));
}
lseek(fd, s->refcount_table_offset, SEEK_SET);
write(fd, s->refcount_table, s->cluster_size);
lseek(fd, s->refcount_block_offset, SEEK_SET);
write(fd, s->refcount_block, s->cluster_size);
qemu_free(s->refcount_table);
qemu_free(s->refcount_block);
close(fd);
return 0;
}
| 1threat |
how to implement fasthttp framework in golang : I'm new in golang and I want to start learning about the fasthttps server from this link https://github.com/valyala/fasthttp but I dont know that how will I implement a small piece of code in this framework. Can anybody tell me that how i will implement a small piece of code in this? example please.
Code I tried
package main
import "fmt"
type MyHandler struct {
foobar string
}
func main() {
// pass bound struct method to fasthttp
myHandler := &MyHandler{
foobar: "foobar",
}
fasthttp.ListenAndServe(":8080", myHandler.HandleFastHTTP)
// pass plain function to fasthttp
fasthttp.ListenAndServe(":8081", fastHTTPHandler)
}
// request handler in net/http style, i.e. method bound to MyHandler struct.
func (h *MyHandler) HandleFastHTTP(ctx *fasthttp.RequestCtx) {
// notice that we may access MyHandler properties here - see h.foobar.
fmt.Fprintf(ctx, "Hello, world! Requested path is %q. Foobar is %q",
ctx.Path(), h.foobar)
}
// request handler in fasthttp style, i.e. just plain function.
func fastHTTPHandler(ctx *fasthttp.RequestCtx) {
fmt.Fprintf(ctx, "Hi there! RequestURI is %q", ctx.RequestURI())
}
Can you please tell me that how I will implement this code. | 0debug |
Linux command to verify what is the switch connected to the machine : Good Morning,
On three different server, I want to verify if it's possible to check the name of the switch is connected to these servers. I would perform this with a Linux command if it's possible. Or maybe with some kind information found in the configuration files if they're present. My final goal is to check if 3 our machine of our server farm are connected to a single switch or two ( having in this case High Aivalability). Is it possible using a Specific Linux Command or to list info in a specific configuration Networking file? Or it's not possible in every case?
Many thanks in advance
Stefano
I found on the Internet this command: cat /proc/net/bonding/bond0 but is has not been usefull
cat /proc/net/bonding/bond0 of Linux Centos commands
With the command cat /proc/net/bonding/bond0 I have no Output, I would have some typical Linux output lines to analyze if a switch code or switch name is present | 0debug |
Calculation by group in one column R : <pre><code>group=c("A","A","B","A","B","C","C","A")
y=c(3,4,5,2,1,4,1,2)
df=data.frame(group,y)
</code></pre>
<p>using <code>aggregate</code>, I can get the average by </p>
<pre><code>aggregate(df$y, list(df$group), mean)
</code></pre>
<p>But my question is: How to do something like : <code>(y_ij-mean_i)</code>
where <code>mean_i</code> is the average for group <code>i</code></p>
<p>thank you.</p>
| 0debug |
Update json data in Swift Table View : Im new to swift programming.I created a simple webservice to connect with swift app.Then i retrieved json data as a list in to the table view and insert data in to the web service. Now I want to update json data row in the table view.Please anyone help me | 0debug |
It is possible to declare an ArrayList<Subject> of ArrayLists<Student>? : <p>I'm creating a java program where I have to make a database for an university.
There are two classes: Subject and Student, so I want to declare an ArrayList of ArrayLists, is that possible? If it is, how could I add elements? Thank's a lot!</p>
| 0debug |
How do you write a method defition for a method in java : This is my method signature and I'm writing this really long code that's supposed to update the student's mark and update the information in the grade book table given a student number and test number and yada yada yada. Anyway, before all of that, I'm going to have to write a method definition for a method, does anyone know a general format on how to do that? Heres my code so far by the way:
import java.util.Scanner;
public class GradeBook {
private int numberofStudents;
private int numberofTests;
private int studId;
private int [] [] table;
private GradeBook()
{
Scanner keyboard = new Scanner (System.in);
System.out.println("Enter the number of student in the class");
int numberofStudents = keyboard.nextInt();
System.out.println("Enter the number of tests taken for the term");
int numberOfTests = keyboard.nextInt();
table = new int [numberofStudents][numberofTests];
System.out.println("Enter the students marks by ID number");
System.out.println();
for(int studId = 1; studId <= numberofStudents; studId++) {
System.out.println('\n' + "Student ID: " + studId);
for(int testNo =1; testNo <= numberOfTests; testNo++) {
System.out.println(" Test Number: " + testNo + '\t');
table [studId -1] [testNo - 1] = keyboard.nextInt();
}
}
}
private void display()
{
int row, column;
for(row =0; row<table.length; row++);
{ System.out.print("Student ID: " + (row +1) + "Tests: ");
for(column = 0; column < table[row]. length; column++)
System.out.print(table[row] [column] + " ");
System.out.println();
}
}
public static void main(String[] args) {
GradeBook myBook = new GradeBook();
myBook.display();
// TODO Auto-generated method stub
}
}
| 0debug |
int chsc_sei_nt2_get_event(void *res)
{
ChscSeiNt2Res *nt2_res = (ChscSeiNt2Res *)res;
PciCcdfAvail *accdf;
PciCcdfErr *eccdf;
int rc = 1;
SeiContainer *sei_cont;
S390pciState *s = S390_PCI_HOST_BRIDGE(
object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));
if (!s) {
return rc;
}
sei_cont = QTAILQ_FIRST(&s->pending_sei);
if (sei_cont) {
QTAILQ_REMOVE(&s->pending_sei, sei_cont, link);
nt2_res->nt = 2;
nt2_res->cc = sei_cont->cc;
nt2_res->length = cpu_to_be16(sizeof(ChscSeiNt2Res));
switch (sei_cont->cc) {
case 1:
eccdf = (PciCcdfErr *)nt2_res->ccdf;
eccdf->fid = cpu_to_be32(sei_cont->fid);
eccdf->fh = cpu_to_be32(sei_cont->fh);
eccdf->e = cpu_to_be32(sei_cont->e);
eccdf->faddr = cpu_to_be64(sei_cont->faddr);
eccdf->pec = cpu_to_be16(sei_cont->pec);
break;
case 2:
accdf = (PciCcdfAvail *)nt2_res->ccdf;
accdf->fid = cpu_to_be32(sei_cont->fid);
accdf->fh = cpu_to_be32(sei_cont->fh);
accdf->pec = cpu_to_be16(sei_cont->pec);
break;
default:
abort();
}
g_free(sei_cont);
rc = 0;
}
return rc;
}
| 1threat |
Protractor : WebDriverError : could not initialize sun.security.ssl.SSLContextImpl$TLSContext : <p>I am just new to protractor, and I am blocked when starting the tutorial. I can't find the real source of the error ...</p>
<p><strong>What I did :</strong></p>
<ol>
<li>install protractor (<code>npm install -g protractor</code>)</li>
<li>update and run webdriver-manager</li>
<li>copy/paste example files from protractor tutorial</li>
<li>run 'protractor conf.js'</li>
</ol>
<p><strong>What I get :</strong></p>
<pre><code>[11:35:46] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[11:35:46] I/launcher - Running 1 instances of WebDriver
[11:35:46] E/launcher - Could not initialize class sun.security.ssl.SSLContextImpl$TLSContext
[11:35:46] E/launcher - WebDriverError: Could not initialize class sun.security.ssl.SSLContextImpl$TLSContext
at WebDriverError (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:27:5)
at Object.checkLegacyResponse (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:639:15)
at parseHttpResponse (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:538:13)
at client_.send.then.response (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:472:11)
at ManagedPromise.invokeCallback_ (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1379:14)
at TaskQueue.execute_ (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2913:14)
at TaskQueue.executeNext_ (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2896:21)
at asyncRun (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2820:25)
at /home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.createSession()
at Function.createSession (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:329:24)
at Builder.build (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/selenium-webdriver/builder.js:458:24)
at Hosted.DriverProvider.getNewDriver (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/built/driverProviders/driverProvider.js:37:33)
at Runner.createBrowser (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/built/runner.js:198:43)
at /home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/built/runner.js:277:30
at _fulfilled (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/q/q.js:796:13)
at /home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/q/q.js:556:49
at runSingle (/home/bmargogne/.nvm/versions/node/v6.8.1/lib/node_modules/protractor/node_modules/q/q.js:137:13)
[11:35:46] E/launcher - Process exited with error code 199
</code></pre>
<p><strong>Notes</strong></p>
<ol>
<li>Protractor : v4.0.14</li>
<li>Java : openjdk 9-Ubuntu 9b134 (?)</li>
<li>System : Ubuntu 16.04</li>
<li>NodeJS : v6.8.1</li>
<li>I get the same output by using "capabilities.browserName:'firefox'" in conf.js</li>
</ol>
<p>Any help would be welcome !</p>
| 0debug |
C language : 0xC0000374: A heap has been corrupted (parameters: 0x77AAB960) : The code bellow sometimes throws exceptions similar to:
Exception thrown at 0x779CC19E (ntdll.dll) in Matriks.exe: 0xC0000005: Access violation reading location 0x0000001D.
I'm new to C and just learned to use pointers. Any tips ? Are there other problems in my code that are worth criticizing ?
```
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
main()
{
int *Matrix_01, *Matrix_02;
int a, b, i, n,valid=1;
srand(time(0));
do
{
printf("Insert number of rows: ");
scanf("%d", &a);
printf("Insert number of columns: ");
scanf("%d", &b);
if (a >= 0 && b >= 0)
valid = 0;
else
{
printf("Invalid input!");
system("pause>null & cls");
}
} while (valid == 1);
Matrix_01 = (int *)malloc(a * b * sizeof(int)+1);
Matrix_02 = (int *)malloc(a * b * sizeof(int)+1);
for (i = 0; i < a; i++)
for (n = 0; n < b; n++)
{
Matrix_01[a*i + n] = rand() % 50;
Matrix_02[a*i + n] = rand() % 50;
}
printf("\nFirst matrix:\n");
for (i = 0; i < a; i++)
{
printf("\n");
for (n = 0; n < b; n++)
{
printf("%4d", Matrix_01[a*i + n]);
}
}
printf("\n\nSecond Matrix:\n");
for (i = 0; i < a; i++)
{
printf("\n");
for (n = 0; n < b; n++)
{
printf("%4d", Matrix_02[a*i + n]);
}
}
printf("\n\nAddition:\n");
for (i = 0; i < a; i++)
{
printf("\n");
for (n = 0; n < b; n++)
{
printf("%4d", Matrix_01[a*i + n]+Matrix_02[a*i + n]);
}
}
printf("\n\nSubtraction:\n");
for (i = 0; i < a; i++)
{
printf("\n");
for (n = 0; n < b; n++)
{
printf("%4d", Matrix_01[a*i + n] - Matrix_02[a*i + n]);
}
}
printf("\n");
system("pause>null");
}
``` | 0debug |
Better refresh of cmd c#? : You have some better options for refresh cmd?
public static void CheckStats()
{
while (true)
{
Colorful.Console.Write(" - Running XeroxCC!", Color.White);
Colorful.Console.WriteLine();
Colorful.Console.Write(" - CPM: ", Color.White);
Colorful.Console.Write("{0}", (object)(Data.CPM * 60), Color.MediumPurple);
Colorful.Console.WriteLine();
Colorful.Console.Write(" - Checked: [", Color.White);
Colorful.Console.Write("{0}", (object)Data.check, Color.MediumPurple);
Colorful.Console.Write("/", Color.White);
Colorful.Console.Write("{0}", (object)Data.total, Color.MediumPurple);
Colorful.Console.Write("]", Color.White);
Colorful.Console.WriteLine();
Colorful.Console.Write(" - Errors: ", Color.White);
Colorful.Console.Write("{0}", (object)Data.err, Color.MediumPurple);
Colorful.Console.WriteLine();
Colorful.Console.Write(" - Good: ", Color.White);
Colorful.Console.Write("{0}", (object)Data.hits, Color.MediumPurple);
Colorful.Console.WriteLine();
Colorful.Console.Write(" - Bad: ", Color.White);
Colorful.Console.Write("{0}", (object)Data.bad, Color.MediumPurple);
Colorful.Console.WriteLine();
Colorful.Console.Write(" - 2FA: ", (object)Data.twofas, Color.White);
Colorful.Console.Write("{0}", (object)Data.twofas, Color.MediumPurple);
Colorful.Console.WriteLine();
Colorful.Console.Write(" - Locked: ", (object)Data.twofas, Color.White);
Colorful.Console.Write("{0}", (object)Data.locked, Color.MediumPurple);
Colorful.Console.WriteLine();
Thread.Sleep(1000);
Colorful.Console.Clear();
}
}
Some thing like this (up) ??? | 0debug |
query = 'SELECT * FROM customers WHERE email = ' + email_input | 1threat |
complex numbers using struct : I want to write a program that reads an array of complex numbers until 0+0j is entered and calculates the absolute value of these numbers and gives the maximum value.
1. i create a struct which includes im and re.
2. i take numbers from user and check it whether it is equal to 0+0j
3. i send the inputs array to absc function
4. in absc function i created a new array which is equal to sqrt(re^2+im^2) and i send this new array to another function find_max
5. in find_max i find the max value of absolute array.
6. Then i print the max value.
However, i fail and i don't understand where should correct.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
#include<stdio.h>
#include<math.h>
#define SIZE 5
struct stComplex
{
int re, im;
};
typedef struct stComplex Complex;
float absc(float[]);
float find_max(float[]);
int main()
{
Complex inputs[SIZE]; //Array for inputs
int i;
float max;
for(i = 0; i < SIZE; i++
printf("Enter real part of complex number: ");
scanf("%d", &inputs[i].re);
printf("Enter imaginary part of complex number: ");
scanf("%d", &inputs[i].im);
if(inputs[i].re != 0 and inputs[i].im != 0)
{
continue;
}
else
{
return 1;
}
}
max = absc(Complex inputs[SIZE]); //Sending the real and imaginary parts to calculate absolute value
printf("The biggest absolute value is %f", max);
return 0;
}
float absc(Complex x[SIZE])
{
int i;
float absolute[SIZE], max;
for(i = 0; i < SIZE; i++)
{
absolute[i] = sqrt(pow(inputs[i].re, 2) + pow(inputs[i].im, 2));
}
max = find_max(absolute[SIZE]);
return max;
}
float find_max( float array[SIZE] )
{
int i, max;
max = array[0];
for( i = 1; i < SIZE; i++ )
{
if( max < array[ i ] )
max = array[ i ];
}
return max;
}
<!-- end snippet -->
| 0debug |
How to average summaries over multiple batches? : <p>Assuming I have a bunch of summaries defined like:</p>
<pre class="lang-py prettyprint-override"><code>loss = ...
tf.scalar_summary("loss", loss)
# ...
summaries = tf.merge_all_summaries()
</code></pre>
<p>I can evaluate the <code>summaries</code> tensor every few steps on the training data and pass the result to a <code>SummaryWriter</code>.
The result will be noisy summaries, because they're only computed on one batch.</p>
<p>However, I would like to compute the summaries on the entire validation dataset.
Of course, I can't pass the validation dataset as a single batch, because it would be too big.
So, I'll get summary outputs for each validation batch.</p>
<p>Is there a way to average those summaries so that it appears as if the summaries have been computed on the entire validation set?</p>
| 0debug |
C++ How Do I Write A 2Dimensional Array To A Text File? : I Am Trying To Write A Program That Receives Input From The User And Makes A 2 Dimensional Array With The Provided Input. It Saves The Values Into The Array Properly But The Program Isn't Able To Perform The Saving Properly.
Please Pardon My Cardinal Sins, Mistakes In The Code, And Disgusting Looking And Bad Looking Code. I'm A Beginner And Only 14 Years Old.
Anyways, It Saves Wrong Values. Here's The Code:
#include <iostream>
#include <fstream>
#include <unistd.h>
using namespace std;
int main()
{
int num;
int productId =1;
cout << "Welcome To The Store Manager Registry! \n ";
cout << "How Many Products Would You Like To Add To The Registry?\n";
cin >> num;
if (num <= 0)
cout << "Please Enter A Valid Input More Than 0";
int a[num-1][2]; //creates a two dimensional array for items
for (;productId-1<num;productId++)
{
cout << "\nPlease Enter The Cost Price For Product Id "<< productId << " (ONLY NUMBERS) \n";
cin >> a[productId-1][0];
cout << "\nPlease Enter The Selling Price For Product Id "<< productId << " (ONLY NUMBERS) \n";
cin >> a[productId-1][1];
a[productId-1][2]=a[productId-1][1]-a[productId-1][0];
} //Receives Input And Saves Values To Array
cout << "Saving Data...";
ofstream outputfile;
outputfile.open("Statistics.txt");
for (int b = 1;b<=num;b++){
outputfile <<a[b-1][0]<<","<<a[b-1][1]<<","<<a[b-1][2]<<endl;//saves values to file
}
outputfile.close();
/* Saves Array In This Format:
Product Id Cost Price Selling price Profit
1 10 20 10
2 20 20 0
3 30 10 -20
But, Prints In This Format
Product Id Cost Price Selling price Profit
1 10 20 20
2 20 20 30
3 30 10 -20
*/
}
Here's The Input:[![enter image description here][1]][1]
And Here's The .txt File It saves Into:[![enter image description here][2]][2]
So, Ultimately, The Values Don't Match And I'm Stuck With This Broken Program.
Please Help.
[1]: https://i.stack.imgur.com/df8KF.png
[2]: https://i.stack.imgur.com/Hdo0V.png | 0debug |
UUID primary key in Eloquent model is stored as uuid but returns as 0 : <p>I have a mysql table in which I'm using a UUID as the primary key. Here's the creation migration:</p>
<pre><code>Schema::create('people', function (Blueprint $table) {
$table->uuid('id');
$table->primary('id');
...
$table->timestamps();
}
</code></pre>
<p>Which generates the following MySQL schema:</p>
<pre><code>CREATE TABLE `people` (
`id` char(36) COLLATE utf8_unicode_ci NOT NULL,
...
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
</code></pre>
<p>In my Eloquent model I have a method for creating an instance which calls a method for generating the UUID:</p>
<pre><code>class Person extends Model
{
protected $fillable = [
...
];
public function make(array $personData){
$person = new Person;
$person->setUUID();
collect($personData)->each(function ($value, $columnName) use($person){
if(in_array($columnName, $this->fillable)){
$person->{$columnName} = $value;
}
});
$person->save();
return $person;
}
protected function setUUID(){
$this->id = preg_replace('/\./', '', uniqid('bpm', true));
}
}
</code></pre>
<p>When I create a new model instance it stores it fine in the database:</p>
<p><a href="https://i.stack.imgur.com/ZMQ2V.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZMQ2V.png" alt="uuids stored"></a></p>
<p>But when I try to access the new instance's id:</p>
<p><a href="https://i.stack.imgur.com/CVvHU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/CVvHU.png" alt="creating new instance and dumping id"></a></p>
<p>It returns as 0:</p>
<p><a href="https://i.stack.imgur.com/wr0or.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wr0or.png" alt="returned result"></a></p>
<p>What am I missing here?</p>
| 0debug |
Java: Converting 12 hour time to 24 hour time : <p>Is there a simple function to convert a time that's like this: 10:30pm 17 Aug 2016 NZST to 2016-8-17-2230</p>
| 0debug |
How to Convert Range of Integers into PHP Array : <p>I'm trying to convert these integers/numbers:</p>
<pre><code>$groups = '1707,1723,1733,16254,16256,18704,19792,29268,34956';
</code></pre>
<p>into an array in PHP array:</p>
<pre><code>array("1707","1723","1733","29268","34956");
</code></pre>
<p>I'm using this</p>
<pre><code> $tags = array();
foreach($groups as $index){
array_push($tags, $index);
}
</code></pre>
<p>But keep getting the below error.</p>
<pre><code> Error: Invalid argument supplied for foreach()
</code></pre>
| 0debug |
static int rice_count_exact(int32_t *res, int n, int k)
{
int i;
int count = 0;
for (i = 0; i < n; i++) {
int32_t v = -2 * res[i] - 1;
v ^= v >> 31;
count += (v >> k) + 1 + k;
}
return count;
}
| 1threat |
Structured Query Language : how can i compare two dates based on month field in sql...i tried all answers dat was given here but they did n't work.if you show any example of displaying employee names who have joined in those months when their managers joined....it will b helpful for me.. | 0debug |
def index_multiplication(test_tup1, test_tup2):
res = tuple(tuple(a * b for a, b in zip(tup1, tup2))
for tup1, tup2 in zip(test_tup1, test_tup2))
return (res) | 0debug |
<layout> <Edittext hint='enter your text'/> <layout>layout tag android not working hint : <layout>
<Edittext hint='enter your text'>
</Edittext?
</layout>
when I am using data binding library with tab layout that time Edit text hint not hide after typing. | 0debug |
how to remove random numbers generated if they are less than a certain value : <p>I'm generating random variates with <code>rnorm()</code> and need to remove any random variates that are less than 20. </p>
<p>for example:</p>
<pre><code>rnorm(4, mean=30, sd=18)
[1] 18 25 36 16
</code></pre>
<p>needs to become: </p>
<pre><code>[1] 25 36
</code></pre>
| 0debug |
Scrape YouTube video views : <p>I have a list of youtube video links like this <a href="https://www.youtube.com/watch?v=ywZevdHW5bQ" rel="nofollow noreferrer">https://www.youtube.com/watch?v=ywZevdHW5bQ</a> and I need to scrape the views count using BeautifulSoup and requests library</p>
| 0debug |
Does Spring create new thread per request in rest controllers? : <p>I wanted to learn non blocking REST, but first I wrote blocking controller for comparison. To my surprise Spring doesn't block incoming requests.</p>
<p>Simple blocking service:</p>
<pre><code>@Service
public class BlockingService {
public String blocking() {
try {
Thread.sleep(10000L);
} catch (InterruptedException ign) {}
return "Blocking response";
}
}
</code></pre>
<p>Simple REST controller:</p>
<pre><code>@Slf4j
@RestController
public class BlockingRestController {
private final BlockingService blockingService;
@Autowired
public BlockingRestController(BlockingService blockingService) {
this.blockingService = blockingService;
}
@GetMapping("blocking")
public String blocking() {
log.info("Starting blocking request processing...");
return blockingService.blocking();
}
}
</code></pre>
<p>And I was thinking that when I would send 4 requests using curl from 4 separated teriminals I get:</p>
<pre><code>1. Starting blocking request processing... (console where spring is running)
2. (4 terminals waiting)
3. "Blocking response" (in 1st terminal)
4. Starting blocking request processing... (console where spring is running)
5. (3 terminals waiting)
6. "Blocking response" (in 2nd terminal)
And so on...
</code></pre>
<p>But to my surprise I got:</p>
<pre><code>1. Starting blocking request processing... (console where spring is running)
2. Starting blocking request processing... (console where spring is running)
3. Starting blocking request processing... (console where spring is running)
4. Starting blocking request processing... (console where spring is running)
5. "Blocking response" (in 1st terminal)
6. "Blocking response" (in 2nd terminal)
7. "Blocking response" (in 3rd terminal)
8. "Blocking response" (in 4th terminal)
</code></pre>
<p>Why first request doesn't block processing requests? Yet I don't create new threads and I don't process anything asynchronous?</p>
<p>Why I ask about it? Because I wanted to learn use DeferredResult but now I don't see a need.</p>
| 0debug |
void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st,
DeviceState *dev, Error **errp)
{
MemStatus *mdev;
DeviceClass *dc = DEVICE_GET_CLASS(dev);
if (!dc->hotpluggable) {
return;
}
mdev = acpi_memory_slot_status(mem_st, dev, errp);
if (!mdev) {
return;
}
mdev->dimm = dev;
mdev->is_enabled = true;
if (dev->hotplugged) {
mdev->is_inserting = true;
acpi_send_event(DEVICE(hotplug_dev), ACPI_MEMORY_HOTPLUG_STATUS);
}
}
| 1threat |
My version of quicksort Algorithm as Wikipedia says do not sort nice : Yesterday I post the same question, a nice member called Prune helped my. But now, I do not know why it does not work.
def partition(A,lo,hi):
pivot = A[hi]
i=lo
#Swap
for j in range(lo,hi-1):
if (A[j] <= pivot):
val=A[i]
A[i]=A[j]
A[j]=val
i=i+1
val=A[i]
A[i]=A[hi]
A[hi]=val
return(i)
def quicksort(A,lo,hi):
if (lo<hi):
p=partition(A,lo,hi)
quicksort(A,lo,p-1)
quicksort(A,p+1,hi)
return(A)
If my input is [5,3,2,6,8,9,1] the output is [1, 2, 5, 3, 8, 9, 6], why is that?
| 0debug |
Azure functions: Installing Python modules and extensions on consumption plan : <p>I am trying to run a python script with Azure functions.
I had success updating the python version and installing modules on Azure functions under the App Services plan but I need to use it under the Consumption plan as my script will only execute once everyday and for only a few minutes, so I want to pay only for the time of execution. See: <a href="https://azure.microsoft.com/en-au/services/functions/" rel="noreferrer">https://azure.microsoft.com/en-au/services/functions/</a></p>
<p>Now I'm still new to this but from my understanding the consumption plan spins up the vm and terminates it after your script has been executed unlike the App Service plan which is always on.
I am not sure why this would mean that I can't have install anything on it. I thought that would just mean I have to install it every time I spin it up. </p>
<p>I have tried installing modules through the python script itself and the kudu command line with no success.</p>
<p>While under the app service plan it was simple, following this tutorial: <a href="https://prmadi.com/running-python-code-on-azure-functions-app/" rel="noreferrer">https://prmadi.com/running-python-code-on-azure-functions-app/</a></p>
| 0debug |
Is possible pass parameter to a property? : <p>if I've this property:</p>
<pre><code>public ListView GetCurrentListView
</code></pre>
<p>can I pass parameter such as </p>
<pre><code>public ListView GetCurrentListView(bool flag)
</code></pre>
<p>?</p>
| 0debug |
static void opt_audio_sample_fmt(const char *arg)
{
if (strcmp(arg, "list"))
audio_sample_fmt = av_get_sample_fmt(arg);
else {
list_fmts(av_get_sample_fmt_string, AV_SAMPLE_FMT_NB);
ffmpeg_exit(0);
}
}
| 1threat |
IE11 Windows 7 Print issue after kb4021558 : <p>Apologies for the slightly vague question but I'm pulling my hair out. Since this update we have had numerous calls regarding printing from our web app. Our web app uses an iframe and we use css @media print to hide all but this iframe for printing purposes. Since the update the user receives an Error 404--Not Found instead of the actual page. It would seem from the network trace that IE creates a temp .htm file in the local directory like D3CD911.htm, it then downloads css/js resources and then finally it makes this call /D3CD911.htm. This is making a call to www.mywebsite.co.uk/D3CD911.htm. This obviously does not exist on the website so the 404 is returned.
I struggling to find a pattern to the problem and it doesn't seem to be affecting other public sites. I think the issue is with window.print() method. I can semi reproduce it here at <a href="https://www.primefaces.org/showcase/ui/misc/printer.xhtml" rel="noreferrer">https://www.primefaces.org/showcase/ui/misc/printer.xhtml</a>. If you click the print button you will get the error. Although this is using the jqprint javascript function if you then use the browser print button it also fails.</p>
<p>Any guidance would be much appreciated.</p>
| 0debug |
Could someone please improve my code for me? (I'm a rookie) : <p>Just want a professionals view on this, thanks in advance if you edit this.
<em>(if you do)</em> I'd like this code to be focused on the same topic <em>(being a dungeon game.)</em> Thanks for even taking the time to look at this!</p>
<pre><code>import time
import random
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print("Text dungeon explorer!")
print("COMMANDS:")
print("inventory -- acceses your current inventory")
print("hold 'item' -- hold selected item")
print("attack -- attacks if enemy is approched")
print("eat -- eats current item held")
print("use -- uses item held")
print("open -- opens any available chests in said room")
print("pickup -- picks up any current items in said room")
print("drop -- drops held item")
print("throw -- throws held item")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
time.sleep(3)
print ("It's a dark in the dungeon, no food, no wepons. You don't even know where you are... There is an object on the floor, all you can make out of it is that it looks quite like a stick.")
time.sleep(11)
ch1 = str(input("Do you take it? [y/n]: "))
if ch1 in ['y', 'Y', 'Yes', 'YES', 'yes']:
print("You have taken the stick! A very odd feel to it.")
time.sleep(2)
backpack_stick = 1
else:
print ("You did not take the stick.")
backpack_stick = 0
print ("As you proceed further into the cave, you see a wooden door.")
time.sleep(6)
ch2 = str(input("Do you open the door? [y/n]"))
enmysleep_rat = int(random.randomint(1, 10))
enmychn_rat = int(random.randomint(1, 10))
chstchnc = int(random.randomint(1, 10))
if enmychn_rat == 1 or 2 or 3 or 4:
enmychance_rat = True
if enmychance_rat is True:
print("Oh no! A musipial rat! You take a closer look if it is sleeping.")
time.sleep(3)
if enmychance_rat is True and
enmysleep_rat = 1 or 2:
print("The rat is sleeping! I could take the availible loot without fighting!")
elif enmysleep_rat = 3 or 4 or 5 or 6 or 7 or 8 or 9 or 10:
print("The rat is not sleeping! Prepare for battle!")
</code></pre>
| 0debug |
static void decode_cabac_residual( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff) {
static const int significant_coeff_flag_offset[2][6] = {
{ 105+0, 105+15, 105+29, 105+44, 105+47, 402 },
{ 277+0, 277+15, 277+29, 277+44, 277+47, 436 }
};
static const int last_coeff_flag_offset[2][6] = {
{ 166+0, 166+15, 166+29, 166+44, 166+47, 417 },
{ 338+0, 338+15, 338+29, 338+44, 338+47, 451 }
};
static const int coeff_abs_level_m1_offset[6] = {
227+0, 227+10, 227+20, 227+30, 227+39, 426
};
static const uint8_t significant_coeff_flag_offset_8x8[2][63] = {
{ 0, 1, 2, 3, 4, 5, 5, 4, 4, 3, 3, 4, 4, 4, 5, 5,
4, 4, 4, 4, 3, 3, 6, 7, 7, 7, 8, 9,10, 9, 8, 7,
7, 6,11,12,13,11, 6, 7, 8, 9,14,10, 9, 8, 6,11,
12,13,11, 6, 9,14,10, 9,11,12,13,11,14,10,12 },
{ 0, 1, 1, 2, 2, 3, 3, 4, 5, 6, 7, 7, 7, 8, 4, 5,
6, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,11,12,11,
9, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,13,13, 9,
9,10,10, 8,13,13, 9, 9,10,10,14,14,14,14,14 }
};
static const uint8_t coeff_abs_level1_ctx[8] = { 1, 2, 3, 4, 0, 0, 0, 0 };
static const uint8_t coeff_abs_levelgt1_ctx[8] = { 5, 5, 5, 5, 6, 7, 8, 9 };
static const uint8_t coeff_abs_level_transition[2][8] = {
{ 1, 2, 3, 3, 4, 5, 6, 7 },
{ 4, 4, 4, 4, 5, 6, 7, 7 }
};
int index[64];
int av_unused last;
int coeff_count = 0;
int node_ctx = 0;
uint8_t *significant_coeff_ctx_base;
uint8_t *last_coeff_ctx_base;
uint8_t *abs_level_m1_ctx_base;
#ifndef ARCH_X86
#define CABAC_ON_STACK
#endif
#ifdef CABAC_ON_STACK
#define CC &cc
CABACContext cc;
cc.range = h->cabac.range;
cc.low = h->cabac.low;
cc.bytestream= h->cabac.bytestream;
#else
#define CC &h->cabac
#endif
if( cat != 5 ) {
if( get_cabac( CC, &h->cabac_state[85 + get_cabac_cbf_ctx( h, cat, n ) ] ) == 0 ) {
if( cat == 1 || cat == 2 )
h->non_zero_count_cache[scan8[n]] = 0;
else if( cat == 4 )
h->non_zero_count_cache[scan8[16+n]] = 0;
#ifdef CABAC_ON_STACK
h->cabac.range = cc.range ;
h->cabac.low = cc.low ;
h->cabac.bytestream= cc.bytestream;
#endif
return;
}
}
significant_coeff_ctx_base = h->cabac_state
+ significant_coeff_flag_offset[MB_FIELD][cat];
last_coeff_ctx_base = h->cabac_state
+ last_coeff_flag_offset[MB_FIELD][cat];
abs_level_m1_ctx_base = h->cabac_state
+ coeff_abs_level_m1_offset[cat];
if( cat == 5 ) {
#define DECODE_SIGNIFICANCE( coefs, sig_off, last_off ) \
for(last= 0; last < coefs; last++) { \
uint8_t *sig_ctx = significant_coeff_ctx_base + sig_off; \
if( get_cabac( CC, sig_ctx )) { \
uint8_t *last_ctx = last_coeff_ctx_base + last_off; \
index[coeff_count++] = last; \
if( get_cabac( CC, last_ctx ) ) { \
last= max_coeff; \
break; \
} \
} \
}\
if( last == max_coeff -1 ) {\
index[coeff_count++] = last;\
}
const uint8_t *sig_off = significant_coeff_flag_offset_8x8[MB_FIELD];
#if defined(ARCH_X86) && defined(HAVE_7REGS) && defined(HAVE_EBX_AVAILABLE) && !defined(BROKEN_RELOCATIONS)
coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index, sig_off);
} else {
coeff_count= decode_significance_x86(CC, max_coeff, significant_coeff_ctx_base, index);
#else
DECODE_SIGNIFICANCE( 63, sig_off[last], last_coeff_flag_offset_8x8[last] );
} else {
DECODE_SIGNIFICANCE( max_coeff - 1, last, last );
#endif
}
assert(coeff_count > 0);
if( cat == 0 )
h->cbp_table[h->mb_xy] |= 0x100;
else if( cat == 1 || cat == 2 )
h->non_zero_count_cache[scan8[n]] = coeff_count;
else if( cat == 3 )
h->cbp_table[h->mb_xy] |= 0x40 << n;
else if( cat == 4 )
h->non_zero_count_cache[scan8[16+n]] = coeff_count;
else {
assert( cat == 5 );
fill_rectangle(&h->non_zero_count_cache[scan8[n]], 2, 2, 8, coeff_count, 1);
}
for( coeff_count--; coeff_count >= 0; coeff_count-- ) {
uint8_t *ctx = coeff_abs_level1_ctx[node_ctx] + abs_level_m1_ctx_base;
int j= scantable[index[coeff_count]];
if( get_cabac( CC, ctx ) == 0 ) {
node_ctx = coeff_abs_level_transition[0][node_ctx];
if( !qmul ) {
block[j] = get_cabac_bypass_sign( CC, -1);
}else{
block[j] = (get_cabac_bypass_sign( CC, -qmul[j]) + 32) >> 6;
}
} else {
int coeff_abs = 2;
ctx = coeff_abs_levelgt1_ctx[node_ctx] + abs_level_m1_ctx_base;
node_ctx = coeff_abs_level_transition[1][node_ctx];
while( coeff_abs < 15 && get_cabac( CC, ctx ) ) {
coeff_abs++;
}
if( coeff_abs >= 15 ) {
int j = 0;
while( get_cabac_bypass( CC ) ) {
j++;
}
coeff_abs=1;
while( j-- ) {
coeff_abs += coeff_abs + get_cabac_bypass( CC );
}
coeff_abs+= 14;
}
if( !qmul ) {
if( get_cabac_bypass( CC ) ) block[j] = -coeff_abs;
else block[j] = coeff_abs;
}else{
if( get_cabac_bypass( CC ) ) block[j] = (-coeff_abs * qmul[j] + 32) >> 6;
else block[j] = ( coeff_abs * qmul[j] + 32) >> 6;
}
}
}
#ifdef CABAC_ON_STACK
h->cabac.range = cc.range ;
h->cabac.low = cc.low ;
h->cabac.bytestream= cc.bytestream;
#endif
}
| 1threat |
PPC_OP(test_ctr_true)
{
T0 = (regs->ctr != 0 && (T0 & PARAM(1)) != 0);
RETURN();
}
| 1threat |
void cpu_resume_from_signal(CPUState *cpu, void *puc)
{
cpu->exception_index = -1;
siglongjmp(cpu->jmp_env, 1);
}
| 1threat |
C language: is double parse exist? : <p>So i have this string:</p>
<pre><code>1, 3.8 , 4.0 , 2 e
</code></pre>
<p>And this function that split my <code>string</code> with <code>comma</code> and <code>tab</code> and print my numbers:</p>
<pre><code>void readuserinput(char *ch)
{
ch = strtok(ch, ", \t");
char *ptr;
double ret;
while (ch)
{
ret = strtod(ch, &ptr);
double d = atof(ch);
printf("%f", d);
ch = strtok(NULL, ", \t");
}
}
</code></pre>
<p>So in case i have non number for example <code>e</code>, any chance to check it and in case this is not number print error ?</p>
<p>Is C Language have <code>double</code> parse or something like that ?</p>
| 0debug |
static void ich9_lpc_update_apic(ICH9LPCState *lpc, int gsi)
{
int level = 0;
assert(gsi >= ICH9_LPC_PIC_NUM_PINS);
level |= pci_bus_get_irq_level(lpc->d.bus, ich9_gsi_to_pirq(gsi));
if (gsi == lpc->sci_gsi) {
level |= lpc->sci_level;
}
qemu_set_irq(lpc->gsi[gsi], level);
}
| 1threat |
def count_Pairs(arr,n):
cnt = 0;
for i in range(n):
for j in range(i + 1,n):
if (arr[i] == arr[j]):
cnt += 1;
return cnt; | 0debug |
static int mp_get_vlc(MotionPixelsContext *mp, GetBitContext *gb)
{
int i;
i = (mp->codes_count == 1) ? 0 : get_vlc2(gb, mp->vlc.table, mp->max_codes_bits, 1);
return mp->codes[i].delta;
} | 1threat |
static int vhost_user_set_owner(struct vhost_dev *dev)
{
VhostUserMsg msg = {
.request = VHOST_USER_SET_OWNER,
.flags = VHOST_USER_VERSION,
};
vhost_user_write(dev, &msg, NULL, 0);
return 0;
}
| 1threat |
static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
ByteIOContext *pb = &s->pb;
SmackerContext *smk = (SmackerContext *)s->priv_data;
AVStream *st, *ast[7];
int i, ret;
int tbase;
smk->magic = get_le32(pb);
if (smk->magic != MKTAG('S', 'M', 'K', '2') && smk->magic != MKTAG('S', 'M', 'K', '4'))
smk->width = get_le32(pb);
smk->height = get_le32(pb);
smk->frames = get_le32(pb);
smk->pts_inc = (int32_t)get_le32(pb);
smk->flags = get_le32(pb);
for(i = 0; i < 7; i++)
smk->audio[i] = get_le32(pb);
smk->treesize = get_le32(pb);
smk->mmap_size = get_le32(pb);
smk->mclr_size = get_le32(pb);
smk->full_size = get_le32(pb);
smk->type_size = get_le32(pb);
for(i = 0; i < 7; i++)
smk->rates[i] = get_le32(pb);
smk->pad = get_le32(pb);
if(smk->frames > 0xFFFFFF) {
av_log(s, AV_LOG_ERROR, "Too many frames: %i\n", smk->frames);
smk->frm_size = av_malloc(smk->frames * 4);
smk->frm_flags = av_malloc(smk->frames);
smk->is_ver4 = (smk->magic != MKTAG('S', 'M', 'K', '2'));
for(i = 0; i < smk->frames; i++) {
smk->frm_size[i] = get_le32(pb);
for(i = 0; i < smk->frames; i++) {
smk->frm_flags[i] = get_byte(pb);
st = av_new_stream(s, 0);
if (!st)
smk->videoindex = st->index;
st->codec->width = smk->width;
st->codec->height = smk->height;
st->codec->pix_fmt = PIX_FMT_PAL8;
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_SMACKVIDEO;
st->codec->codec_tag = smk->is_ver4;
if(smk->pts_inc < 0)
smk->pts_inc = -smk->pts_inc;
else
smk->pts_inc *= 100;
tbase = 100000;
av_reduce(&tbase, &smk->pts_inc, tbase, smk->pts_inc, (1UL<<31)-1);
av_set_pts_info(st, 33, smk->pts_inc, tbase);
for(i = 0; i < 7; i++) {
smk->indexes[i] = -1;
if((smk->rates[i] & 0xFFFFFF) && !(smk->rates[i] & SMK_AUD_BINKAUD)){
ast[i] = av_new_stream(s, 0);
smk->indexes[i] = ast[i]->index;
av_set_pts_info(ast[i], 33, smk->pts_inc, tbase);
ast[i]->codec->codec_type = CODEC_TYPE_AUDIO;
ast[i]->codec->codec_id = (smk->rates[i] & SMK_AUD_PACKED) ? CODEC_ID_SMACKAUDIO : CODEC_ID_PCM_U8;
ast[i]->codec->codec_tag = 0;
ast[i]->codec->channels = (smk->rates[i] & SMK_AUD_STEREO) ? 2 : 1;
ast[i]->codec->sample_rate = smk->rates[i] & 0xFFFFFF;
ast[i]->codec->bits_per_sample = (smk->rates[i] & SMK_AUD_16BITS) ? 16 : 8;
if(ast[i]->codec->bits_per_sample == 16 && ast[i]->codec->codec_id == CODEC_ID_PCM_U8)
ast[i]->codec->codec_id = CODEC_ID_PCM_S16LE;
st->codec->extradata = av_malloc(smk->treesize + 16);
st->codec->extradata_size = smk->treesize + 16;
if(!st->codec->extradata){
av_log(s, AV_LOG_ERROR, "Cannot allocate %i bytes of extradata\n", smk->treesize + 16);
av_free(smk->frm_size);
av_free(smk->frm_flags);
ret = get_buffer(pb, st->codec->extradata + 16, st->codec->extradata_size - 16);
if(ret != st->codec->extradata_size - 16){
av_free(smk->frm_size);
av_free(smk->frm_flags);
return AVERROR_IO;
((int32_t*)st->codec->extradata)[0] = le2me_32(smk->mmap_size);
((int32_t*)st->codec->extradata)[1] = le2me_32(smk->mclr_size);
((int32_t*)st->codec->extradata)[2] = le2me_32(smk->full_size);
((int32_t*)st->codec->extradata)[3] = le2me_32(smk->type_size);
smk->curstream = -1;
smk->nextpos = url_ftell(pb);
return 0; | 1threat |
Use data as list : <p>I hava data that looks like a list of dicts but i cannot use it as a list.
The output of data[0] is not the first dict but the first character.
How can i change that?
Here is the data:</p>
<pre><code>[{"0":null,"1":null,"2":null,"3":null,"4":null,"5":null,"6":null,"7":null,"8":null},{"0":null,"1":"+ 110 \u20ac Bonus zum Anbieter","2":"+ Wettbonus zum Anbieter","3":
"+ 100 \u20ac Bonus zum Anbieter","4":"+ 100 \u20ac Bonus zum Anbieter","5":"+ 100 \u20ac Bonus zum Anbieter","6":"+ 100 \u20ac Bonus zum Anbieter","7":"+ 150 \u20ac Bonus zum Anbieter","8":"+ 150 \u20ac Bonus zum Anbieter"},{"0":"Bayern M\u00fcnchen \u2013 VfB Stuttgart","1":null,"2":null,"3":null,"4":null,"5":null,"6":null,"7":nul
l,"8":null},{"0":"FC Bayern","1":"120","2":"116","3":"120","4":"117","5":"118","6":"120","7":"120","8":"120"},{"0":"Unentschieden","1":"700","2":"800","3":"700","4":"8
30","5":"850","6":"600","7":"800","8":"800"},{"0":"VfB Stuttgart","1":"125","2":"150","3":"120","4":"145","5":"140","6":"150","7":"110","8":"120"},{"0":null,"1":null,"
2":null,"3":null,"4":null,"5":null,"6":null,"7":null,"8":null},{"0":"TSG Hoffenheim \u2013 Borussia Dortmund","1":null,"2":null,"3":null,"4":null,"5":null,"6":null,"7"
:null,"8":null},{"0":"Hoffenheim","1":"240","2":"220","3":"220","4":"224","5":"220","6":"225","7":"220","8":"220"},{"0":"Unentschieden","1":"370","2":"380","3":"380","
4":"380","5":"400","6":"350","7":"380","8":"400"},{"0":"Dortmund","1":"270","2":"300","3":"300","4":"295","5":"300","6":"300","7":"300","8":"300"},{"0":null,"1":null,"
2":null,"3":null,"4":null,"5":null,"6":null,"7":null,"8":null},{"0":"Hertha BSC \u2013 RB Leipzig","1":null,"2":null,"3":null,"4":null,"5":null,"6":null,"7":null,"8":n
ull},{"0":"Hertha","1":"450","2":"420","3":"410","4":"395","5":"410","6":"380","7":"380","8":"420"},{"0":"Unentschieden","1":"360","2":"375","3":"400","4":"400","5":"4
00","6":"400","7":"420","8":"420"},{"0":"RB Leipzig","1":"180","2":"185","3":"180","4":"184","5":"183","6":"183","7":"183","8":"185"},{"0":null,"1":null,"2":null,"3":n
ull,"4":null,"5":null,"6":null,"7":null,"8":null},{"0":"SC Freiburg \u2013 FC Augsburg","1":null,"2":null,"3":null,"4":null,"5":null,"6":null,"7":null,"8":null},{"0":"
Freiburg","1":"200","2":"195","3":"195","4":"200","5":"190","6":"200","7":"195","8":"190"},{"0":"Unentschieden","1":"310","2":"340","3":"340","4":"340","5":"360","6":"
320","7":"350","8":"360"},{"0":"Augsburg","1":"430","2":"420","3":"410","4":"395","5":"400","6":"400","7":"400","8":"450"},{"0":null,"1":null,"2":null,"3":null,"4":nul
l,"5":null,"6":null,"7":null,"8":null},{"0":"Schalke 04 \u2013 Eintracht Frankfurt","1":null,"2":null,"3":null,"4":null,"5":null,"6":null,"7":null,"8":null},{"0":"Scha
lke","1":"250","2":"250","3":"250","4":"250","5":"250","6":"240","7":"250","8":"220"},{"0":"Unentschieden","1":"340","2":"350","3":"340","4":"340","5":"350","6":"340","7":"340","8":"380"},{"0":"E. Frankfurt","1":"275","2":"275","3":"270","4":"280","5":"287","6":"280","7":"280","8":"310"},{"0":null,"1":null,"2":null,"3":null,"4":null
,"5":null,"6":null,"7":null,"8":null},{"0":"Bayer 04 Leverkusen \u2013 Hannover 96","1":null,"2":null,"3":null,"4":null,"5":null,"6":null,"7":null,"8":null},{"0":"Leve
rkusen","1":"117","2":"120","3":"120","4":"122","5":"118","6":"122","7":"122","8":"127"},{"0":"Unentschieden","1":"750","2":"700","3":"700","4":"740","5":"750","6":"60
0","7":"750","8":"800"},{"0":"Hannover 96","1":"150","2":"130","3":"130","4":"110","5":"140","6":"130","7":"100","8":"100"},{"0":null,"1":null,"2":null,"3":null,"4":nu
ll,"5":null,"6":null,"7":null,"8":null},{"0":"Hamburger SV \u2013 M\u00f6nchengladbach","1":null,"2":null,"3":null,"4":null,"5":null,"6":null,"7":null,"8":null},{"0":"
HSV","1":"220","2":"230","3":"225","4":"234","5":"230","6":"240","7":"230","8":"200"},{"0":"Unentschieden","1":"370","2":"350","3":"370","4":"370","5":"375","6":"320",
"7":"380","8":"420"},{"0":"Gladbach","1":"300","2":"300","3":"300","4":"285","5":"300","6":"300","7":"287","8":"340"},{"0":null,"1":null,"2":null,"3":null,"4":null,"5"
:null,"6":null,"7":null,"8":null},{"0":"1. FSV Mainz 05 \u2013 Werder Bremen","1":null,"2":null,"3":null,"4":null,"5":null,"6":null,"7":null,"8":null},{"0":"Mainz 05",
"1":"230","2":"230","3":"230","4":"236","5":"230","6":"240","7":"230","8":"200"},{"0":"Unentschieden","1":"340","2":"360","3":"360","4":"365","5":"375","6":"320","7":"
375","8":"380"},{"0":"Werder Bremen","1":"305","2":"300","3":"300","4":"285","5":"290","6":"300","7":"287","8":"290"},{"0":null,"1":null,"2":null,"3":null,"4":null,"5"
:null,"6":null,"7":null,"8":null},{"0":"VfL Wolfsburg \u2013 1. FC K\u00f6ln","1":null,"2":null,"3":null,"4":null,"5":null,"6":null,"7":null,"8":null},{"0":"VfL Wolfsb
urg","1":"170","2":"165","3":"160","4":"164","5":"161","6":"167","7":"165","8":"170"},{"0":"Unentschieden","1":"350","2":"400","3":"430","4":"420","5":"433","6":"375",
"7":"420","8":"420"},{"0":"1. FC K\u00f6ln","1":"550","2":"525","3":"530","4":"505","5":"500","6":"500","7":"475","8":"500"},{"0":null,"1":null,"2":null,"3":null,"4":n
ull,"5":null,"6":null,"7":null,"8":null}]
</code></pre>
| 0debug |
docker for mac memory usage in com.docker.hyperkit : <p>I'm running docker desktop community 2.1.0.3 on MacOS Mojave. I've got 8GB of memory allocated to Docker, which already seems like a lot (that's half my RAM). Somehow even after exiting and then starting Docker for Mac again, which means no containers are running, docker is already exceeding the memory allocation by 1GB.</p>
<p>What is expected memory usage for docker with no containers running? Is there a memory leak in docker for mac or docker's hyperkit?</p>
<p><a href="https://i.stack.imgur.com/bHNKq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bHNKq.png" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/ZEWFw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZEWFw.png" alt="docker for mac memory leak"></a></p>
| 0debug |
Order array of objects by custom field, then alphabetically : <p>I have an array of objects, each object has 2 values, priority and name.</p>
<pre><code>var people = [
{
"name" : "Jim",
"priority" : "Low"
},
{
"name" : "Gary",
"priority" : "Medium"
},
{
"name" : "Andrew",
"priority" : "Medium"
},
{
"name" : "Bill",
"priority" : "High"
},
{
"name" : "Edward",
"priority" : "Medium"
}
]
</code></pre>
<p>I would like to sort this array, ordering by priority High to Low, and then within each priority, by name alphabetically.</p>
<p>Ordering alphabetically is easy enough: </p>
<pre><code>people = _.orderBy(people, 'name');
</code></pre>
<p>But how would I sort by priority in the way I want? </p>
| 0debug |
how to create an array of repeating object in kotlin? : <p>I know how to do it by creating a loop but I wanted to know if there's an easier way? </p>
<p>for example, I want to create an array of <code>Point</code> and they will all have <code>(0,0)</code> or increment <code>x,y</code> by their index. </p>
| 0debug |
github vulnerable dependencies per branch : <p>It seems to me that you can only see the vulnerable dependencies on the <code>master</code> branch. I fixed those mentioned in the alert on a separate branch and want to check if in fact the vulnerable dependencies are fixed, so what I really need is to be able to check the alert for the specific branch, can this be done?</p>
| 0debug |
need to write 2.5 million data into csv from resultset, what is the best approach to write these huge data in java : <p>Need to write 2.5 million data into csv from resultset, what is the best approach to write these huge data in java.Currently its taking 1.5 hours to write.
Sample Code:</p>
<pre><code>PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream("test.csv"), "UTF-8")), false);
int colcount= rs.getMetaData().getColumnCount();
while(rs.next()){
// working on some headers
for (int i= 1; i<= colcount; i++) {
Object value = rs.getObject(i);
pw.println(value.toString());
}
}
</code></pre>
<p>please help me</p>
| 0debug |
struct HCIInfo *hci_init(const char *str)
{
char *endp;
struct bt_scatternet_s *vlan = 0;
if (!strcmp(str, "null"))
return &null_hci;
else if (!strncmp(str, "host", 4) && (str[4] == '\0' || str[4] == ':'))
return bt_host_hci(str[4] ? str + 5 : "hci0");
else if (!strncmp(str, "hci", 3)) {
if (str[3]) {
if (!strncmp(str + 3, ",vlan=", 6)) {
vlan = qemu_find_bt_vlan(strtol(str + 9, &endp, 0));
if (*endp)
vlan = 0;
}
} else
vlan = qemu_find_bt_vlan(0);
if (vlan)
return bt_new_hci(vlan);
}
fprintf(stderr, "qemu: Unknown bluetooth HCI `%s'.\n", str);
return 0;
}
| 1threat |
Generic unique pointers : <p>Below is my sample code:</p>
<pre><code>#include <functional>
#include <iostream>
#include <memory>
using namespace std::placeholders;
template <typename recvtype, typename responsetype>
void myfunc(std::unique_ptr<recvtype> input, std::function<void(std::unique_ptr<responsetype>)> callback)
{
auto msg = std::make_unique<responsetype>();
callback(std::move(msg));
return;
}
class Ret
{
public:
Ret(){}
void BRet(std::unique_ptr<Ret> r)
{
std::cout << "Called Me!!!" << std::endl << std::fflush;
}
};
class In
{
public:
In(){}
};
void test(std::unique_ptr<In> input, std::function<void(std::unique_ptr<Ret>)> callback)
{
myfunc<In , Ret>(std::move(input), callback);
}
int main()
{
std::unique_ptr<In> a = std::make_unique<In>();
Ret r1;
std::function<void(std::unique_ptr<Ret>)> f = std::bind(&Ret::BRet, &r1, _1);
test(std::move(a),f);
}
</code></pre>
<p>When I compile and execute the code I get below output:</p>
<pre><code>$ c++ --std=c++14 -g try17.cpp
MINGW64 /c/test
$ ./a.exe
Called Me!!!
1
MINGW64 /c/test
$
</code></pre>
<p>I am not sure from where the <strong>'1'</strong> getting printed on console and how can I make <strong>test</strong> to accept generic unique pointers - I mean test method can now be called for any type instead of <strong>'In and Ret'</strong> types?</p>
| 0debug |
Webpage slides up when soft keyboard is active : <p>I've got a chat page layout web application with input at the bottom, and a header at the top. when the input is in focus the page moves up. </p>
<p>These headers are present in my page for preventing zoom or other unwanted behaviour.</p>
<p><code><meta name="viewport" content="width=device-width,initial-scale=1"></code></p>
<p><a href="https://i.stack.imgur.com/CpKKB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/CpKKB.png" alt="Representation of my question"></a></p>
<p>When trying to resize the window using javascript using <code>window.innerHeight</code> but that doesn't work as well even with a <code>setTimeout()</code></p>
<p>Is there a workaround for the browser to not pan the whole page up, or resize with subtracting height of keyboard?</p>
| 0debug |
sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
{
SDHCIState *s = (SDHCIState *)opaque;
unsigned shift = 8 * (offset & 0x3);
uint32_t mask = ~(((1ULL << (size * 8)) - 1) << shift);
uint32_t value = val;
value <<= shift;
switch (offset & ~0x3) {
case SDHC_SYSAD:
s->sdmasysad = (s->sdmasysad & mask) | value;
MASKED_WRITE(s->sdmasysad, mask, value);
if (!(mask & 0xFF000000) && TRANSFERRING_DATA(s->prnsts) && s->blkcnt &&
s->blksize && SDHC_DMA_TYPE(s->hostctl) == SDHC_CTRL_SDMA) {
sdhci_sdma_transfer_multi_blocks(s);
break;
case SDHC_BLKSIZE:
if (!TRANSFERRING_DATA(s->prnsts)) {
MASKED_WRITE(s->blksize, mask, value);
MASKED_WRITE(s->blkcnt, mask >> 16, value >> 16);
break;
case SDHC_ARGUMENT:
MASKED_WRITE(s->argument, mask, value);
break;
case SDHC_TRNMOD:
if (!(s->capareg & SDHC_CAN_DO_DMA)) {
value &= ~SDHC_TRNS_DMA;
MASKED_WRITE(s->trnmod, mask, value);
MASKED_WRITE(s->cmdreg, mask >> 16, value >> 16);
if ((mask & 0xFF000000) || !sdhci_can_issue_command(s)) {
break;
sdhci_send_command(s);
break;
case SDHC_BDATA:
if (sdhci_buff_access_is_sequential(s, offset - SDHC_BDATA)) {
sdhci_write_dataport(s, value >> shift, size);
break;
case SDHC_HOSTCTL:
if (!(mask & 0xFF0000)) {
sdhci_blkgap_write(s, value >> 16);
MASKED_WRITE(s->hostctl, mask, value);
MASKED_WRITE(s->pwrcon, mask >> 8, value >> 8);
MASKED_WRITE(s->wakcon, mask >> 24, value >> 24);
if (!(s->prnsts & SDHC_CARD_PRESENT) || ((s->pwrcon >> 1) & 0x7) < 5 ||
!(s->capareg & (1 << (31 - ((s->pwrcon >> 1) & 0x7))))) {
s->pwrcon &= ~SDHC_POWER_ON;
break;
case SDHC_CLKCON:
if (!(mask & 0xFF000000)) {
sdhci_reset_write(s, value >> 24);
MASKED_WRITE(s->clkcon, mask, value);
MASKED_WRITE(s->timeoutcon, mask >> 16, value >> 16);
if (s->clkcon & SDHC_CLOCK_INT_EN) {
s->clkcon |= SDHC_CLOCK_INT_STABLE;
} else {
s->clkcon &= ~SDHC_CLOCK_INT_STABLE;
break;
case SDHC_NORINTSTS:
if (s->norintstsen & SDHC_NISEN_CARDINT) {
value &= ~SDHC_NIS_CARDINT;
s->norintsts &= mask | ~value;
s->errintsts &= (mask >> 16) | ~(value >> 16);
if (s->errintsts) {
s->norintsts |= SDHC_NIS_ERR;
} else {
s->norintsts &= ~SDHC_NIS_ERR;
sdhci_update_irq(s);
break;
case SDHC_NORINTSTSEN:
MASKED_WRITE(s->norintstsen, mask, value);
MASKED_WRITE(s->errintstsen, mask >> 16, value >> 16);
s->norintsts &= s->norintstsen;
s->errintsts &= s->errintstsen;
if (s->errintsts) {
s->norintsts |= SDHC_NIS_ERR;
} else {
s->norintsts &= ~SDHC_NIS_ERR;
sdhci_update_irq(s);
break;
case SDHC_NORINTSIGEN:
MASKED_WRITE(s->norintsigen, mask, value);
MASKED_WRITE(s->errintsigen, mask >> 16, value >> 16);
sdhci_update_irq(s);
break;
case SDHC_ADMAERR:
MASKED_WRITE(s->admaerr, mask, value);
break;
case SDHC_ADMASYSADDR:
s->admasysaddr = (s->admasysaddr & (0xFFFFFFFF00000000ULL |
(uint64_t)mask)) | (uint64_t)value;
break;
case SDHC_ADMASYSADDR + 4:
s->admasysaddr = (s->admasysaddr & (0x00000000FFFFFFFFULL |
((uint64_t)mask << 32))) | ((uint64_t)value << 32);
break;
case SDHC_FEAER:
s->acmd12errsts |= value;
s->errintsts |= (value >> 16) & s->errintstsen;
if (s->acmd12errsts) {
s->errintsts |= SDHC_EIS_CMD12ERR;
if (s->errintsts) {
s->norintsts |= SDHC_NIS_ERR;
sdhci_update_irq(s);
break;
default:
ERRPRINT("bad %ub write offset: addr[0x%04x] <- %u(0x%x)\n",
size, (int)offset, value >> shift, value >> shift);
break;
DPRINT_L2("write %ub: addr[0x%04x] <- %u(0x%x)\n",
size, (int)offset, value >> shift, value >> shift); | 1threat |
How to use Mono.Cecil to create HelloWorld.exe : <p>How do you use Mono.Cecil to create a simple program from scratch? All the examples and tutorials I've been able to find so far, assume you are working with an existing assembly, reading or making small changes.</p>
| 0debug |
How to display <div> relative to the screen? : <p>How to display relative to the screen, but not the page. For example, I want to display a window with ads, this window should be centered and on top of other elements, as well as being centered on the screen, regardless of the page's scrolling.</p>
| 0debug |
Why function is not returning negative value in C? : <p>I am writing this code to return a value which I will pass through the parameter of the function and print that value.
here is my code: </p>
<pre><code>#include<stdio.h>
int abs(int x)
{
if(x<0)
return x;
}
int main()
{
int x = -6;
printf("Value of abs is %d\n",abs(x));
return 0;
}
</code></pre>
<p>This code giving me the output:</p>
<blockquote>
<p>Value of abs is 6</p>
</blockquote>
<p><em>Why this code is not returning -6 ?</em> </p>
<p>how to solve this ? </p>
<p>thanks in advance :)</p>
| 0debug |
static uint32_t get_features(VirtIODevice *vdev, uint32_t features)
{
VirtIOSerial *vser;
vser = VIRTIO_SERIAL(vdev);
if (vser->bus.max_nr_ports > 1) {
features |= (1 << VIRTIO_CONSOLE_F_MULTIPORT);
}
return features;
}
| 1threat |
static void report_config_error(const char *filename, int line_num, int log_level, int *errors, const char *fmt, ...)
{
va_list vl;
va_start(vl, fmt);
av_log(NULL, log_level, "%s:%d: ", filename, line_num);
av_vlog(NULL, log_level, fmt, vl);
va_end(vl);
(*errors)++;
}
| 1threat |
Tooltip <p:outputLabel> Primeface : I want to use tooltip in <p: outputLabel>, Right now I'm doing it this way but it does not work ...
<p:outputLabel for="#{idInput}" value="#{etiqueta}"
id="label-#{idInput}" title="#{etiqueta}">
</p:outputLabel> | 0debug |
Node/Express - Refused to apply style because its MIME type ('text/html') : <p>I've been having this issue for the past couple of days and can't seem to get to the bottom of this. We doing a very basic node/express app, and are trying to serve our static files using something like this:</p>
<pre><code>app.use(express.static(path.join(__dirname, "static")));
</code></pre>
<p>This does what I expect it to for the most part. We have a few folders in our static folder for our css and javascript. We're trying to load our css into our EJS view using this static path:</p>
<pre><code><link rel="stylesheet" type="text/css" href="/css/style.css">
</code></pre>
<p>When we hit our route <code>/</code>, we're getting all of the content but our CSS is not loading. We're getting this error in particular:</p>
<blockquote>
<p>Refused to apply style from '<a href="http://localhost:3000/css/style.css" rel="noreferrer">http://localhost:3000/css/style.css</a>'
because its MIME type ('text/html') is not a supported stylesheet MIME
type, and strict MIME checking is enabled.</p>
</blockquote>
<h2>What I've tried:</h2>
<ol>
<li>Clear NPM Cache / Fresh Install
<ul>
<li><code>npm verify cache</code></li>
<li><code>rm -rf node_modules</code></li>
<li><code>npm install</code></li>
</ul></li>
<li>Clear Browser Cache</li>
<li>Various modifications to folder names and references to that</li>
<li>Adding/removing forward slashes form the href</li>
<li>Moving the css folder into the root and serving it from there</li>
<li>Adding/removing slashes from <code>path.join(__dirname, '/static/')</code></li>
<li>There was a comment about a service worker possibly messing things up in a github issue report, and seemed to fix a lot of people's problems. There is no service worker for our localhost: <a href="https://github.com/facebook/create-react-app/issues/658" rel="noreferrer">https://github.com/facebook/create-react-app/issues/658</a>
<ul>
<li>We're not using react, but I'm grasping at any google search I can find</li>
</ul></li>
</ol>
<h2>The route:</h2>
<pre><code>app.get("/", function(req, res) {
res.render("search");
});
</code></pre>
<h2>The view:</h2>
<pre><code><!DOCTYPE html>
<html>
<head>
<title>Search for a Movie</title>
<link rel="stylesheet" type="text/css" href="/static/css/style.css">
</head>
<body>
<h1>Search for a movie</h1>
<form method="POST" action="/results">
<label for="movie-title">Enter a movie title:</label><br>
<input id="movie-title" type="text" name="title"><br>
<input type="submit" value="Submit Search">
</form>
</body>
</html>
</code></pre>
<h2>The package.json:</h2>
<pre><code>{
"name": "express-apis-omdb",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "nodemon index.js",
"lint:js": "node_modules/eslint/bin/eslint.js ./ ./**/*.js --fix; exit 0",
"lint:css": "node_modules/csslint/cli.js public/css/; exit 0"
},
"license": "ISC",
"devDependencies": {
"babel-eslint": "^6.0.4",
"csslint": "^0.10.0",
"eslint": "^2.11.1",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-import": "^1.8.1",
"eslint-plugin-jsx-a11y": "^1.3.0",
"eslint-plugin-react": "^5.1.1"
},
"dependencies": {
"body-parser": "^1.18.2",
"dotenv": "^5.0.0",
"ejs": "^2.5.7",
"express": "^4.13.4",
"morgan": "^1.7.0",
"path": "^0.12.7",
"request": "^2.83.0"
}
}
</code></pre>
<h2>The project structure:</h2>
<pre><code>-app
--node_modules
--static
---img
---css
---js
--views
---movie.ejs
---results.ejs
---search.ejs
--index.js
--package-lock.json
--package.json
</code></pre>
<p><strong>Note:</strong> We are currently not using a layout file for our EJS. </p>
<p>I'm happy to provide additional details if needed.</p>
| 0debug |
void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
ISADevice **rtc_state,
bool create_fdctrl,
bool no_vmport,
uint32 hpet_irqs)
{
int i;
DriveInfo *fd[MAX_FD];
DeviceState *hpet = NULL;
int pit_isa_irq = 0;
qemu_irq pit_alt_irq = NULL;
qemu_irq rtc_irq = NULL;
qemu_irq *a20_line;
ISADevice *i8042, *port92, *vmmouse, *pit = NULL;
qemu_irq *cpu_exit_irq;
MemoryRegion *ioport80_io = g_new(MemoryRegion, 1);
MemoryRegion *ioportF0_io = g_new(MemoryRegion, 1);
memory_region_init_io(ioport80_io, NULL, &ioport80_io_ops, NULL, "ioport80", 1);
memory_region_add_subregion(isa_bus->address_space_io, 0x80, ioport80_io);
memory_region_init_io(ioportF0_io, NULL, &ioportF0_io_ops, NULL, "ioportF0", 1);
memory_region_add_subregion(isa_bus->address_space_io, 0xf0, ioportF0_io);
if (!no_hpet && (!kvm_irqchip_in_kernel() || kvm_has_pit_state2())) {
hpet = qdev_try_create(NULL, TYPE_HPET);
if (hpet) {
uint8_t compat = object_property_get_int(OBJECT(hpet),
HPET_INTCAP, NULL);
if (!compat) {
qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs);
}
qdev_init_nofail(hpet);
sysbus_mmio_map(SYS_BUS_DEVICE(hpet), 0, HPET_BASE);
for (i = 0; i < GSI_NUM_PINS; i++) {
sysbus_connect_irq(SYS_BUS_DEVICE(hpet), i, gsi[i]);
}
pit_isa_irq = -1;
pit_alt_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT);
rtc_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_RTC_INT);
}
}
*rtc_state = rtc_init(isa_bus, 2000, rtc_irq);
qemu_register_boot_set(pc_boot_set, *rtc_state);
if (!xen_enabled()) {
if (kvm_irqchip_in_kernel()) {
pit = kvm_pit_init(isa_bus, 0x40);
} else {
pit = pit_init(isa_bus, 0x40, pit_isa_irq, pit_alt_irq);
}
if (hpet) {
qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(DEVICE(pit), 0));
}
pcspk_init(isa_bus, pit);
}
serial_hds_isa_init(isa_bus, MAX_SERIAL_PORTS);
parallel_hds_isa_init(isa_bus, MAX_PARALLEL_PORTS);
a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
i8042 = isa_create_simple(isa_bus, "i8042");
i8042_setup_a20_line(i8042, &a20_line[0]);
if (!no_vmport) {
vmport_init(isa_bus);
vmmouse = isa_try_create(isa_bus, "vmmouse");
} else {
vmmouse = NULL;
}
if (vmmouse) {
DeviceState *dev = DEVICE(vmmouse);
qdev_prop_set_ptr(dev, "ps2_mouse", i8042);
qdev_init_nofail(dev);
}
port92 = isa_create_simple(isa_bus, "port92");
port92_init(port92, &a20_line[1]);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
DMA_init(0, cpu_exit_irq);
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
create_fdctrl |= !!fd[i];
}
if (create_fdctrl) {
fdctrl_init_isa(isa_bus, fd);
}
}
| 1threat |
query = 'SELECT * FROM customers WHERE email = ' + email_input | 1threat |
Distinct Column gives me incorrect results : I have DISTINCT and wanted to use MIN and MAX functions in queries.
Just using DISTINCT it gives me proper results count: 1348
But if I just add MIN() and MAX() Function in query the query just returns one record having MAX column.
I want all those records proper but need to find MAX amount from price column as well.
Here is my query:
SELECT DISTINCT a.*, (a.price * 1) as calculatedPrice, py.package_id as py_package_id
FROM qd_posts as a
INNER JOIN qd_categories as c ON c.id=a.category_id AND c.active=1
LEFT JOIN qd_categories as cp ON cp.id=c.parent_id AND cp.active=1
LEFT JOIN (SELECT MAX(id) max_id, post_id FROM qd_payments WHERE active=1 GROUP BY post_id) mpy ON mpy.post_id = a.id AND a.featured=1
LEFT JOIN qd_payments as py ON py.id=mpy.max_id
LEFT JOIN qd_packages as p ON p.id=py.package_id
WHERE a.country_code = 'CA' AND (a.verified_email = 1 AND a.verified_phone = 1) AND a.archived != 1 AND a.deleted_at IS NULL
ORDER BY p.lft DESC, a.created_at DESC
After adding MAX to query
SELECT DISTINCT a.*, (a.price * 1) as calculatedPrice, py.package_id as py_package_id, MAX(a.price) as maxprice
FROM qd_posts as a
INNER JOIN qd_categories as c ON c.id=a.category_id AND c.active=1
LEFT JOIN qd_categories as cp ON cp.id=c.parent_id AND cp.active=1
LEFT JOIN (SELECT MAX(id) max_id, post_id FROM qd_payments WHERE active=1 GROUP BY post_id) mpy ON mpy.post_id = a.id AND a.featured=1
LEFT JOIN qd_payments as py ON py.id=mpy.max_id
LEFT JOIN qd_packages as p ON p.id=py.package_id
WHERE a.country_code = 'CA' AND (a.verified_email = 1 AND a.verified_phone = 1) AND a.archived != 1 AND a.deleted_at IS NULL
ORDER BY p.lft DESC, a.created_at DESC
Not sure what to do next. | 0debug |
static size_t handle_aiocb_flush(struct qemu_paiocb *aiocb)
{
int ret;
ret = qemu_fdatasync(aiocb->aio_fildes);
if (ret == -1)
return -errno;
return 0;
}
| 1threat |
Google GSutil create folder : <p>How can u create a new folder inside a bucket in google cloud storage using the gsutil command?</p>
<p>I tried using the same command in creating bucket but still got an error</p>
<pre><code>gsutil mb -l us-east1 gs://my-awesome-bucket/new_folder/
</code></pre>
<p>Thanks!</p>
| 0debug |
static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
{
CharDriverState *chr = dev->opaque;
uint8_t *p = (uint8_t *) msg;
int r, size = VHOST_USER_HDR_SIZE;
r = qemu_chr_fe_read_all(chr, p, size);
if (r != size) {
error_report("Failed to read msg header. Read %d instead of %d.", r,
size);
goto fail;
}
if (msg->flags != (VHOST_USER_REPLY_MASK | VHOST_USER_VERSION)) {
error_report("Failed to read msg header."
" Flags 0x%x instead of 0x%x.", msg->flags,
VHOST_USER_REPLY_MASK | VHOST_USER_VERSION);
goto fail;
}
if (msg->size > VHOST_USER_PAYLOAD_SIZE) {
error_report("Failed to read msg header."
" Size %d exceeds the maximum %zu.", msg->size,
VHOST_USER_PAYLOAD_SIZE);
goto fail;
}
if (msg->size) {
p += VHOST_USER_HDR_SIZE;
size = msg->size;
r = qemu_chr_fe_read_all(chr, p, size);
if (r != size) {
error_report("Failed to read msg payload."
" Read %d instead of %d.", r, msg->size);
goto fail;
}
}
return 0;
fail:
return -1;
}
| 1threat |
int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src, const AVFrame *frame)
{
int ret;
AVFilterBufferRef *picref =
avfilter_get_video_buffer_ref_from_frame(frame, AV_PERM_WRITE);
if (!picref)
return AVERROR(ENOMEM);
ret = av_vsrc_buffer_add_video_buffer_ref(buffer_src, picref);
picref->buf->data[0] = NULL;
avfilter_unref_buffer(picref);
return ret;
}
| 1threat |
C# Windows Mouse Control : <p>I am coding an application for a school project that said "Make something you are proud of without any prior knowledge or experience", and have encountered a situation where my lack of information counts as a roadblock.</p>
<p>I do not know and could not find any useful information on how the windows mouse wheel works, and how to include it in my program.</p>
<p>To simplify the issue: I need to control the mouse with code, the buttons work well, but I do not have a clue on how the mouse wheel works, and how I should implement it's movement.</p>
<p>The method I use for mouse events:</p>
<pre><code>[DllImport("user32.dll")]
private static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
</code></pre>
<p>If anyone could explain how the mouse wheel works in general, or how I should use the method to control it I would be very thankful.</p>
| 0debug |
How to recognize the meaning of a linked list function in c++ : <p>I'm currently stuck on some functions operating on single linked lists made with a struct in c++. </p>
<p>I am supposed to find out what do these functions do without compiling, but I cannot seem to have understood the theory behind it completely, since my guesses are all to generic.</p>
<p>Is there a way to guess the reason behind these function's existence just by looking at them? And what do they do?</p>
<p>Also, what will happen if I call q(la, lb) if la=(2, 3, 4, 5, 1, 6) and lb=(3, 4, 5)?</p>
<pre><code>bool u(List l, int x) {
if (l=nullptr) return false;
if (l->info == x) return true;
return u(l->next, x);
}
void v(List& l, int x) {
List tmp = new (cell);
tmp->info = x;
tmp -> next = l;
l = tmp;
}
List q(List l1, List l2) {
List aux = nullptr;
while (l1!=nullptr) {
if (!u(l2,l1->info)) v(aux,l1->info);
l1=l1->next;
}
return aux;
}
</code></pre>
| 0debug |
static target_long monitor_get_xer (const struct MonitorDef *md, int val)
{
CPUState *env = mon_get_cpu();
if (!env)
return 0;
return env->xer;
}
| 1threat |
Writing a function that takes date values and returns the time difference in seconds : I have to create a function that takes in two date and time values and returns the time difference between them in seconds.
This is what I have so far:
`var x = getTimeDiff((2019, 07, 04, 24, 00, 00), (2019, 06, 07, 24, 11, 00));`
`console.log(x);`
`function getTimeDiff(fdate, pdate) {`
var fSeconds = fdate.getTime();
var pSeconds = pdate.getTime();
var secondsLeft = (fSeconds - pSeconds) / 1000
return secondsLeft;
}
The first two lines of code are for me to test in my browser. I am confused as to how to enter dates in the parentheses so that they are recognized as dates. When I run the code my browser states that the getTime is not a function. How do I enter dates so that my function recognizes that I am entering a "new Date()"? Any help would be much appreciated! | 0debug |
static void apb_pci_bridge_init(PCIBus *b)
{
PCIDevice *dev = pci_bridge_get_device(b);
pci_set_word(dev->config + PCI_COMMAND,
PCI_COMMAND_MEMORY);
pci_set_word(dev->config + PCI_STATUS,
PCI_STATUS_FAST_BACK | PCI_STATUS_66MHZ |
PCI_STATUS_DEVSEL_MEDIUM);
pci_set_byte(dev->config + PCI_REVISION_ID, 0x11);
pci_set_byte(dev->config + PCI_HEADER_TYPE,
pci_get_byte(dev->config + PCI_HEADER_TYPE) |
PCI_HEADER_TYPE_MULTI_FUNCTION);
}
| 1threat |
What does the * mean in my css? : <p>Does the * indicate that its styling will apply to all my other tags?</p>
<pre><code> * {
margin:0;
padding:0;
outline:none;
list-style:none;
text-decoration:none;
box-sizing:border-box;
color:#fff;
background: transparent;
border:none;
}
</code></pre>
| 0debug |
From c# insert DateTime With Milliseconds : using System;
using System.Globalization;
public class Program
{
public static void Main()
{
DateTime time =
DateTime.ParseExact("18/03/201115:16:57.487","dd/MM/yyyyHH:mm:ss.fff",
CultureInfo.InvariantCulture);
Console.WriteLine("Other Output:" + time);
}
}
I want to insert DateTime with milliseconds from C# to Sql | 0debug |
What is the impact of warnings when compiling in gcc? What can be the consequences? : <p>I've had that doubt for several days. Does anyone have any experience to tell about it? Thanks in advance.</p>
| 0debug |
How can I suppress the "The tag <some-tag> is unrecognized in this browser" warning in React? : <p>I'm using elements with custom tag names in React and getting a wall of these errors. There's a GitHub issue on the subject (<a href="https://github.com/hyperfuse/react-anime/issues/33" rel="noreferrer">https://github.com/hyperfuse/react-anime/issues/33</a>) in which someone states:</p>
<blockquote>
<p>This is a new warning message in React 16. Has nothing to do with anime/react-anime and this warning can safely be ignored.</p>
</blockquote>
<p>It's nice that it can be safely ignored, but it's still not going to pass scrutiny when my code is filling the console with useless error messages.</p>
<p>How can I suppress these warnings?</p>
| 0debug |
static char* mpjpeg_get_boundary(AVIOContext* pb)
{
uint8_t *mime_type = NULL;
const char *start;
const char *end;
uint8_t *res = NULL;
int len;
av_opt_get(pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type);
start = mime_type;
while (start != NULL && *start != '\0') {
start = strchr(start, ';');
if (start)
start = start+1;
while (av_isspace(*start))
start++;
if (!av_stristart(start, "boundary=", &start)) {
end = strchr(start, ';');
if (end)
len = end - start - 1;
else
len = strlen(start);
res = av_strndup(start, len);
break;
}
}
av_freep(&mime_type);
return res;
}
| 1threat |
Django 1.10.1 'my_templatetag' is not a registered tag library. Must be one of: : <p>I want a menu thats custom depending which group you are member of.
Im using Django 1.10.1, allauth and so on.
When im trying to make my templatetag it fails and it says:¨</p>
<pre><code>TemplateSyntaxError at /
'my_templatetag' is not a registered tag library. Must be one of:
account
account_tags
admin_list
admin_modify
admin_static
admin_urls
cache
i18n
l10n
log
socialaccount
socialaccount_tags
static
staticfiles
tz
</code></pre>
<p>'my_templatetag.py' looks like this:</p>
<pre><code>from django import template
from django.contrib.auth.models import Group
register = template.Library()
@register.filter(name='has_group')
def has_group(user, group_name):
group = Group.objects.get(name=group_name)
return group in user.groups.all()
</code></pre>
<p>and tha error comes in my .html file which say,</p>
<pre><code>{% load my_templatetag %}
</code></pre>
<p>I have tried to restart the server like millions of times, also i tried to change all the names, and the app is a part of INSTALLED_APPS in settings.py.
What am I doing wrong?</p>
| 0debug |
Java tagged union / sum types : <p>Is there any way to define a sum type in Java? Java seems to naturally support product types directly, and I thought enums might allow it to support sum types, and inheritance looks like maybe it could do it, but there is at least one case I can't resolve.
To elaborate, a sum type is a type which can have exactly one of a set of different types, like a tagged union in C.
In my case, I'm trying to implement haskell's Either type in Java:</p>
<pre><code>data Either a b = Left a | Right b
</code></pre>
<p>but at the base level I'm having to implement it as a product type, and just ignore one of its fields:</p>
<pre><code>public class Either<L,R>
{
private L left = null;
private R right = null;
public static <L,R> Either<L,R> right(R right)
{
return new Either<>(null, right);
}
public static <L,R> Either<L,R> left(L left)
{
return new Either<>(left, null);
}
private Either(L left, R right) throws IllegalArgumentException
{
this.left = left;
this.right = right;
if (left != null && right != null)
{
throw new IllegalArgumentException("An Either cannot be created with two values");
}
if (left == right)
{
throw new IllegalArgumentException("An Either cannot be created without a value");
}
}
.
.
.
}
</code></pre>
<p>I tried implementing this with inheritance, but I have to use a wildcard type parameter, or equivalent, which Java generics won't allow:</p>
<pre><code>public class Left<L> extends Either<L,?>
</code></pre>
<p>I haven't used Java's Enums much, but while they seem the next best candidate, I'm not hopeful.<br>
At this point, I think this might only be possible by type-casting <code>Object</code> values, which I would hope to avoid entirely, unless there's a way to do it once, safely, and be able to use that for all sum types.</p>
| 0debug |
CTC Loss InvalidArgumentError: sequence_length(b) <= time : <p>I am running into this error while trying to use tf.nn.ctc_loss through keras (ctc_batch_cost):</p>
<blockquote>
<p>InvalidArgumentError (see above for traceback): sequence_length(4) <= 471</p>
</blockquote>
<p>According to the documentation for tf.nn.ctc_loss, Input requirements are:</p>
<blockquote>
<p>sequence_length(b) <= time for all b</p>
<p>max(labels.indices(labels.indices[:, 1] == b, 2)) <=
sequence_length(b) for all b.</p>
</blockquote>
<p>I am having a hard time understanding what this means-- what is <code>b</code> and what is <code>sequence_length(b)</code>? </p>
| 0debug |
Sql Server Sorting Date With Hours/Mins : I have a complex date column that I need to sort by. SQL Server 2008
**My Query:**
SELECT DivisionName as Division, StoreNum as Store, LeadName as Lead, Type, ChangeType,Changes,
UpdatedBy,
convert(varchar(10),UpdatedDate, 101) + right(convert(varchar(32), UpdatedDate,100),8) as UpdatedDate FROM m
WHERE DivID!=0
ORDER BY convert(varchar(10),UPDATEdDate, 101) desc, right(convert(varchar(32), UPDATEdDate,100),8) asc
**The format:** in the database: smalldatetime 2016-01-25 16:50:00
**And to the display value, I use:**
convert(varchar(10),UpdatedDate, 101) + right(convert(varchar(32), UpdatedDate,100),8) as UpdatedDate
**My issue:** (Hour/Minute Sorting), I need the 7:40PM row at top.
[![enter image description here][1]][1]
[1]: http://i.stack.imgur.com/lB6zb.jpg | 0debug |
static void lsi_command_complete(SCSIRequest *req, uint32_t status, size_t resid)
{
LSIState *s = DO_UPCAST(LSIState, dev.qdev, req->bus->qbus.parent);
int out;
out = (s->sstat1 & PHASE_MASK) == PHASE_DO;
DPRINTF("Command complete status=%d\n", (int)status);
s->status = status;
s->command_complete = 2;
if (s->waiting && s->dbc != 0) {
lsi_bad_phase(s, out, PHASE_ST);
} else {
lsi_set_phase(s, PHASE_ST);
}
if (s->current && req == s->current->req) {
req->hba_private = NULL;
lsi_request_free(s, s->current);
scsi_req_unref(req);
}
lsi_resume_script(s);
}
| 1threat |
Android support EditTextPreference input type : <p>Is there any way to specify the input method type for <code>android.support.v7.preference.EditTextPreference</code>?</p>
| 0debug |
Data not retreving when clicking on search button : please find the below scenario of mine and do the needful help.
the search button is in frames and I am connecting to the frames with the below code.
driver.switchTo().frame("autoCompleteDialogIF");
and I am able to go the frames section.
search button syntax:
<a href="javascript:findButtonAction();">Find</a>
Here in the frames section we have text box and when I enter the values in text box and perform search the data is not retrieving which matches with the text.
**Code used:**
WebElement elementclick = driver.findElement(By.xpath(".//*[@id='filterPanelFindButton']/a"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", elementclick); | 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.