problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Where is `CV_HAAR_SCALE_IMAGE` in OpenCV 3.1.0 with Python 3.5? : <p>I get this error.</p>
<pre><code>AttributeError: module 'cv2' has no attribute 'CV_HAAR_SCALE_IMAGE'
</code></pre>
<p>After upgrading my OpenCV to 3.1.0.
I have tried these.</p>
<pre><code>cv2.cv.CV_HAAR_SCALE_IMAGE
</code></pre>
<p>And also this.</p>
<pre><code>cv2.CV_HAAR_SCALE_IMAGE
</code></pre>
<p>But still same error. I go here, <a href="http://docs.opencv.org/3.1.0/d9/d31/group__objdetect__c.html#ga812f46d031349fa2ee78a5e7240f5016" rel="noreferrer">http://docs.opencv.org/3.1.0/d9/d31/group__objdetect__c.html#ga812f46d031349fa2ee78a5e7240f5016</a> but I could not find any information of to which object the constants stored in.</p>
| 0debug
|
static void ppc_heathrow_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
const char *boot_device = machine->boot_order;
MemoryRegion *sysmem = get_system_memory();
PowerPCCPU *cpu = NULL;
CPUPPCState *env = NULL;
char *filename;
qemu_irq *pic, **heathrow_irqs;
int linux_boot, i;
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *bios = g_new(MemoryRegion, 1);
MemoryRegion *isa = g_new(MemoryRegion, 1);
uint32_t kernel_base, initrd_base, cmdline_base = 0;
int32_t kernel_size, initrd_size;
PCIBus *pci_bus;
PCIDevice *macio;
MACIOIDEState *macio_ide;
DeviceState *dev;
BusState *adb_bus;
int bios_size;
MemoryRegion *pic_mem;
MemoryRegion *escc_mem, *escc_bar = g_new(MemoryRegion, 1);
uint16_t ppc_boot_device;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
void *fw_cfg;
uint64_t tbfreq;
linux_boot = (kernel_filename != NULL);
if (cpu_model == NULL)
cpu_model = "G3";
for (i = 0; i < smp_cpus; i++) {
cpu = cpu_ppc_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
}
env = &cpu->env;
cpu_ppc_tb_init(env, TBFREQ);
qemu_register_reset(ppc_heathrow_reset, cpu);
}
if (ram_size > (2047 << 20)) {
fprintf(stderr,
"qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n",
((unsigned int)ram_size / (1 << 20)));
exit(1);
}
memory_region_allocate_system_memory(ram, NULL, "ppc_heathrow.ram",
ram_size);
memory_region_add_subregion(sysmem, 0, ram);
memory_region_init_ram(bios, NULL, "ppc_heathrow.bios", BIOS_SIZE);
vmstate_register_ram_global(bios);
if (bios_name == NULL)
bios_name = PROM_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
memory_region_set_readonly(bios, true);
memory_region_add_subregion(sysmem, PROM_ADDR, bios);
if (filename) {
bios_size = load_elf(filename, 0, NULL, NULL, NULL, NULL,
1, ELF_MACHINE, 0);
g_free(filename);
} else {
bios_size = -1;
}
if (bios_size < 0 || bios_size > BIOS_SIZE) {
hw_error("qemu: could not load PowerPC bios '%s'\n", bios_name);
exit(1);
}
if (linux_boot) {
uint64_t lowaddr = 0;
int bswap_needed;
#ifdef BSWAP_NEEDED
bswap_needed = 1;
#else
bswap_needed = 0;
#endif
kernel_base = KERNEL_LOAD_ADDR;
kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,
NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);
if (kernel_size < 0)
kernel_size = load_aout(kernel_filename, kernel_base,
ram_size - kernel_base, bswap_needed,
TARGET_PAGE_SIZE);
if (kernel_size < 0)
kernel_size = load_image_targphys(kernel_filename,
kernel_base,
ram_size - kernel_base);
if (kernel_size < 0) {
hw_error("qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
if (initrd_filename) {
initrd_base = round_page(kernel_base + kernel_size + KERNEL_GAP);
initrd_size = load_image_targphys(initrd_filename, initrd_base,
ram_size - initrd_base);
if (initrd_size < 0) {
hw_error("qemu: could not load initial ram disk '%s'\n",
initrd_filename);
exit(1);
}
cmdline_base = round_page(initrd_base + initrd_size);
} else {
initrd_base = 0;
initrd_size = 0;
cmdline_base = round_page(kernel_base + kernel_size + KERNEL_GAP);
}
ppc_boot_device = 'm';
} else {
kernel_base = 0;
kernel_size = 0;
initrd_base = 0;
initrd_size = 0;
ppc_boot_device = '\0';
for (i = 0; boot_device[i] != '\0'; i++) {
#if 0
if (boot_device[i] >= 'a' && boot_device[i] <= 'f') {
ppc_boot_device = boot_device[i];
break;
}
#else
if (boot_device[i] >= 'c' && boot_device[i] <= 'd') {
ppc_boot_device = boot_device[i];
break;
}
#endif
}
if (ppc_boot_device == '\0') {
fprintf(stderr, "No valid boot device for G3 Beige machine\n");
exit(1);
}
}
memory_region_init_alias(isa, NULL, "isa_mmio",
get_system_io(), 0, 0x00200000);
memory_region_add_subregion(sysmem, 0xfe000000, isa);
heathrow_irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *));
heathrow_irqs[0] =
g_malloc0(smp_cpus * sizeof(qemu_irq) * 1);
for (i = 0; i < smp_cpus; i++) {
switch (PPC_INPUT(env)) {
case PPC_FLAGS_INPUT_6xx:
heathrow_irqs[i] = heathrow_irqs[0] + (i * 1);
heathrow_irqs[i][0] =
((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT];
break;
default:
hw_error("Bus model not supported on OldWorld Mac machine\n");
}
}
if (kvm_enabled()) {
tbfreq = kvmppc_get_tbfreq();
} else {
tbfreq = TBFREQ;
}
if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
hw_error("Only 6xx bus is supported on heathrow machine\n");
}
pic = heathrow_pic_init(&pic_mem, 1, heathrow_irqs);
pci_bus = pci_grackle_init(0xfec00000, pic,
get_system_memory(),
get_system_io());
pci_vga_init(pci_bus);
escc_mem = escc_init(0, pic[0x0f], pic[0x10], serial_hds[0],
serial_hds[1], ESCC_CLOCK, 4);
memory_region_init_alias(escc_bar, NULL, "escc-bar",
escc_mem, 0, memory_region_size(escc_mem));
for(i = 0; i < nb_nics; i++)
pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL);
ide_drive_get(hd, MAX_IDE_BUS);
macio = pci_create(pci_bus, -1, TYPE_OLDWORLD_MACIO);
dev = DEVICE(macio);
qdev_connect_gpio_out(dev, 0, pic[0x12]);
qdev_connect_gpio_out(dev, 1, pic[0x0D]);
qdev_connect_gpio_out(dev, 2, pic[0x02]);
qdev_connect_gpio_out(dev, 3, pic[0x0E]);
qdev_connect_gpio_out(dev, 4, pic[0x03]);
macio_init(macio, pic_mem, escc_bar);
macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio),
"ide[0]"));
macio_ide_init_drives(macio_ide, hd);
macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio),
"ide[1]"));
macio_ide_init_drives(macio_ide, &hd[MAX_IDE_DEVS]);
dev = DEVICE(object_resolve_path_component(OBJECT(macio), "cuda"));
adb_bus = qdev_get_child_bus(dev, "adb.0");
dev = qdev_create(adb_bus, TYPE_ADB_KEYBOARD);
qdev_init_nofail(dev);
dev = qdev_create(adb_bus, TYPE_ADB_MOUSE);
qdev_init_nofail(dev);
if (usb_enabled(false)) {
pci_create_simple(pci_bus, -1, "pci-ohci");
}
if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
graphic_depth = 15;
fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_HEATHROW);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
if (kernel_cmdline) {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, cmdline_base);
pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE, kernel_cmdline);
} else {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
}
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base);
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
if (kvm_enabled()) {
#ifdef CONFIG_KVM
uint8_t *hypercall;
hypercall = g_malloc(16);
kvmppc_get_hypercall(env, hypercall, 16);
fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid());
#endif
}
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, tbfreq);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_CLOCKFREQ, CLOCKFREQ);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_BUSFREQ, BUSFREQ);
qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
}
| 1threat
|
static void *virtio_scsi_load_request(QEMUFile *f, SCSIRequest *sreq)
{
SCSIBus *bus = sreq->bus;
VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus);
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
VirtIOSCSIReq *req;
uint32_t n;
req = g_malloc(sizeof(*req));
qemu_get_be32s(f, &n);
assert(n < vs->conf.num_queues);
qemu_get_buffer(f, (unsigned char *)&req->elem, sizeof(req->elem));
#ifdef NDEBUG
#error building with NDEBUG is not supported
#endif
assert(req->elem.in_num <= ARRAY_SIZE(req->elem.in_sg));
assert(req->elem.out_num <= ARRAY_SIZE(req->elem.out_sg));
virtio_scsi_parse_req(s, vs->cmd_vqs[n], req);
scsi_req_ref(sreq);
req->sreq = sreq;
if (req->sreq->cmd.mode != SCSI_XFER_NONE) {
int req_mode =
(req->elem.in_num > 1 ? SCSI_XFER_FROM_DEV : SCSI_XFER_TO_DEV);
assert(req->sreq->cmd.mode == req_mode);
}
return req;
}
| 1threat
|
static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features,
uint32_t *ext_features,
uint32_t *ext2_features,
uint32_t *ext3_features,
uint32_t *kvm_features)
{
int i;
int found = 0;
for ( i = 0 ; i < 32 ; i++ )
if (feature_name[i] && !strcmp (flagname, feature_name[i])) {
*features |= 1 << i;
found = 1;
}
for ( i = 0 ; i < 32 ; i++ )
if (ext_feature_name[i] && !strcmp (flagname, ext_feature_name[i])) {
*ext_features |= 1 << i;
found = 1;
}
for ( i = 0 ; i < 32 ; i++ )
if (ext2_feature_name[i] && !strcmp (flagname, ext2_feature_name[i])) {
*ext2_features |= 1 << i;
found = 1;
}
for ( i = 0 ; i < 32 ; i++ )
if (ext3_feature_name[i] && !strcmp (flagname, ext3_feature_name[i])) {
*ext3_features |= 1 << i;
found = 1;
}
for ( i = 0 ; i < 32 ; i++ )
if (kvm_feature_name[i] && !strcmp (flagname, kvm_feature_name[i])) {
*kvm_features |= 1 << i;
found = 1;
}
if (!found) {
fprintf(stderr, "CPU feature %s not found\n", flagname);
}
}
| 1threat
|
why regex work well in java but not working in c++? : use c++
```
std::regex reg("[\\s\\S]*abc[\\s\\S]*:(\\S+)");
std::string src = " abc-def gg, :OK";
std::smatch match;
bool flag = std::regex_search(src, match, reg);
// flag is false
```
use java
```
Pattern p = Pattern.compile("[\\s\\S]*abc[\\s\\S]*:(\\S+)");
String src = " abc-def gg, :OK";
Matcher m = p.matcher(src);
int num = 0;
while (m.find()) {
for (int i = 1; i <= m.groupCount(); i++) {
num++;
}
}
System.out.println(num); num is 1 ,work well
```
The above two parts of the code, C + + operation does not output the correct result, but the java run can get the correct result, why is this happening, where is the problem?
| 0debug
|
How to use the Firebase refreshToken to reauthenticate? : <p>I use the JS library call <code>firebase.auth().signInWithEmailAndPassword(email, password)</code> and get back a <code>User</code> object. The <code>User</code> object contains a <a href="https://firebase.google.com/docs/reference/js/firebase.User#refreshToken" rel="noreferrer"><code>refreshToken</code></a>.</p>
<p>I use <code>curl 'https://docs-examples.firebaseio.com/rest/saving-data/auth-example.json?auth=TOKEN'</code> to make calls to Firebase. </p>
<p>The token will eventually expire. In order to make it look like the application (<code>iOS</code> and <code>macOS</code>) has persistent login, I want to refresh the token, how do I do that with using either the <code>REST</code> or <code>JS</code> library? I can't find any calls in the documentation that allow me to use the <code>refreshToken</code> to get a new <code>token</code>.</p>
| 0debug
|
static int sol_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
int ret;
if (s->pb->eof_reached)
return AVERROR(EIO);
ret= av_get_packet(s->pb, pkt, MAX_SIZE);
pkt->stream_index = 0;
pkt->size = ret;
return 0;
}
| 1threat
|
static int get_uint8(QEMUFile *f, void *pv, size_t size)
{
uint8_t *v = pv;
qemu_get_8s(f, v);
return 0;
}
| 1threat
|
Method overloading giving error with int & float : [A java programe code with showing method oveloading][1]
[1]: https://i.stack.imgur.com/DzTkQ.png`public class Main {
public static void main(String[] args) {
System.out.println(add(2,4));
System.out.println(add(2.3,3.4));
}
public static int add(int a, int b){
return (a + b);
}
public static float add(float a, float b){
return (a + b);
}
}
`
| 0debug
|
static void vnc_dpy_update(DisplayState *ds, int x, int y, int w, int h)
{
VncState *vs = ds->opaque;
int i;
h += y;
w += (x % 16);
x -= (x % 16);
x = MIN(x, vs->width);
y = MIN(y, vs->height);
w = MIN(x + w, vs->width) - x;
h = MIN(h, vs->height);
for (; y < h; y++)
for (i = 0; i < w; i += 16)
vnc_set_bit(vs->dirty_row[y], (x + i) / 16);
}
| 1threat
|
is there a way to insert a pause after a scan command? : <p>I am making a project in java and this is my first live Project. I am using the scanner class for the first time. I encountered this problem where the compiler skips my scan commands and goes on to the next output command. When i run the given code, it displays the following</p>
<blockquote>
<p>PS: my project is not even near completion so my code looks very rough and not even complete. so please do not remind me. Thank you :)</p>
</blockquote>
<pre><code>
import java.util.Scanner;
import java.io.*;
public class A{
public static void main(String ... args){
Scanner scan = new Scanner(System.in);
System.out.println("\n");
System.out.println(" Grand Theft Auto Online Profit Calulator");
System.out.println("Choose one of the following option:");
System.out.println("1.Existing User");
System.out.println("2.First time");
int user = scan.nextInt();
if(user == 2)
{
// ask for bunker
System.out.println("Do you own a bunker? Enter y or n");
String bunks = scan.nextLine();
//ask for nightclub
System.out.println("Do you own a Nightclub? Enter y or n");
String nclub = scan.nextLine();
// ask for crates warehouse
System.out.println("Do you own a Crates Warehouse? Enter y or n");
String cratesboi = scan.nextLine();
}
}
}
</code></pre>
<p>RESULT:</p>
<pre><code>Do you own a bunker? Enter y or n
Do you own a Nightclub? Enter y or n
y
Do you own a Crates Warehouse? Enter y or n
n
</code></pre>
<p>it shows the nightclub display straight after the bunker one without asking for an answer. whereas in crates the case is defference. i expected the compiler to ask me if i own a bunker or not but it did not</p>
| 0debug
|
How to Integrate the React-Native project to Android-Studio? : <p>I had tried to import the react-native project to android studio,
but the "index.android.js" file is not shown in android-studio IDE..
So what I will do ?</p>
| 0debug
|
Creating new bash var from value of json bash var : My environment created a variable that looks like this:
SM_TRAINING_ENV={"additional_framework_parameters":{},"channel_input_dirs":{"training":"/opt/ml/input/data/training"},"current_host":"algo-1","framework_module":"sagemaker_tensorflow_container.training:main","hosts":["algo-1"],"hyperparameters":{"bool_param":true,"float_param":1.25,"int_param":5,"model_dir":"s3://bucket/detection/prefix/testing-2019-04-06-02-24-20-194/model","str_param":"bla"},"input_config_dir":"/opt/ml/input/config","input_data_config":{"training":{"RecordWrapperType":"None","S3DistributionType":"FullyReplicated","TrainingInputMode":"File"}},"input_dir":"/opt/ml/input","is_master":true,"job_name":"testing-2019-04-06-02-24-20-194","log_level":20,"master_hostname":"algo-1","model_dir":"/opt/ml/model","module_dir":"s3://bucket/prefix/testing-2019-04-06-02-24-20-194/source/sourcedir.tar.gz","module_name":"launcher.sh","network_interface_name":"ethwe","num_cpus":8,"num_gpus":1,"output_data_dir":"/opt/ml/output/data","output_dir":"/opt/ml/output","output_intermediate_dir":"/opt/ml/output/intermediate","resource_config":{"current_host":"algo-1","hosts":["algo-1"],"network_interface_name":"ethwe"},"user_entry_point":"launcher.sh"}
How can I create a new bash variable that is equal to the value of `SM_TRAINING_ENV["hyperparameters"]["model_dir"]`?
| 0debug
|
Why elif statement instead of if statement? : <p>Why should I use an elif instead of using if statements over and over again.
I can't find any documentation on the matter. Thank you in advance.</p>
| 0debug
|
(C++) Not able to create objects different objects even when I give different constructor parameters : <p>I am making a basic card system in C++. It is object-oriented, of course. All I did was a class for the card stack, another for the card itself and the main class. But as I was trying to make this project, I noticed that all the cards that I made were the same! It seems to me that the problem lays on the creating of the object itself. Check it out, guys:</p>
<p>Main.cpp</p>
<pre><code>#include "Header.h"
using namespace std;
char cardTypes[4] = { CARD_TYPE_HEARTS,CARD_TYPE_SPADES,CARD_TYPE_CLUBS,CARD_TYPE_DIAMONDS };
int main(void) {
setlocale(LC_ALL, "Portuguese");
srand((unsigned)time(NULL));
CardStack stack;
for (int i = 0; i < 4; i++) {
char type = cardTypes[i];
for (int j = 0; j <= 13; j++) {
stack.add(&Card(j, type));
}
}
stack.shuffle();
cout << stack.getCard(0)->translateMe() << endl;
cout << stack.getCard(1)->translateMe() << endl;
cout << stack.getCard(2)->translateMe() << endl;
return 0;
}
</code></pre>
<p>Header.h</p>
<pre><code>#ifndef HEADER_H
#define HEADER_H
#include <iostream>
#include <vector>
#include <time.h>
#include <random>
#include <string>
using namespace std;
#define CARD_POS_STACK 0
#define CARD_TYPE_HEARTS 'H'
#define CARD_TYPE_SPADES 'S'
#define CARD_TYPE_CLUBS 'C'
#define CARD_TYPE_DIAMONDS 'D'
#define CARD_TYPE_NONE ' '
#define CARD_JOKER 0
#define CARD_ACE 1
#define CARD_2 2
#define CARD_3 3
#define CARD_4 4
#define CARD_5 5
#define CARD_6 6
#define CARD_7 7
#define CARD_8 8
#define CARD_9 9
#define CARD_10 10
#define CARD_JACK 11
#define CARD_QUEEN 12
#define CARD_KING 13
class Card {
private:
char type; /* type can be H (hearts), S (spades), C (clubs) or D (diamonds) */
short num; /* coringa = 0, J = 11, Q = 12 and K = 13*/
int pos; /* 0 = stack */
public:
/* > Creates a card */
Card(short num, char type);
/* > Recieves the card's type */
char getType();
/* > Recieves the card's number */
short getNum();
/* > Translates the number */
string translateMe();
/* > Recieves the card's position on the table */
int getPos();
/* > Checks if a card is equal to another */
bool isEqual(Card* another);
};
class CardStack {
private:
vector<Card*> cards;
int numOfCards;
public:
int getSize();
/* > Checks if there is any item in the stack */
bool isEmpty();
/* > Add a card to the top of the stack */
void add(Card* theCard);
/* > Remove a card from the stack */
void remove(Card* theCard);
/* > Shuffles randomly the card */
void shuffle();
/* > Get a certain card */
Card* getCard(int i);
/* > Gets the card at the top of the stack */
Card* getTopCard();
/* > Generates an empty stack */
CardStack();
};
#endif
</code></pre>
<p>Card.cpp</p>
<pre><code>#include "Header.h"
Card::Card(short cardNum, char cardType){
num = cardNum;
if (cardNum = CARD_JOKER)
type = CARD_TYPE_NONE;
else
type = cardType;
pos = CARD_POS_STACK;
}
string Card::translateMe() {
string message = "";
switch (num) {
case 0:
message.append("Coringa");
break;
case 11:
message.append("Valete de");
break;
case 12:
message.append("Rainha de ");
break;
case 13:
message.append("Rei de ");
break;
default:
message.append(to_string(num)+" de ");
}
switch (type) {
case CARD_TYPE_CLUBS:
message.append("Paus");
break;
case CARD_TYPE_DIAMONDS:
message.append("Ouros");
break;
case CARD_TYPE_HEARTS:
message.append("Copas");
break;
case CARD_TYPE_SPADES:
message.append("Espadas");
break;
}
return message;
}
char Card::getType() { return type; }
short Card::getNum() { return num; }
int Card::getPos() { return pos; }
bool Card::isEqual(Card* another) { return this == another; }
</code></pre>
<p>CardStack.cpp</p>
<pre><code>#include "Header.h"
#include <algorithm>
bool CardStack::isEmpty() {
return numOfCards == 0 ? true : false;
}
void CardStack::add(Card* theCard) {
cards.push_back(theCard);
}
void CardStack::remove(Card* theCard) {
for (int i = 0; i < cards.size(); i++)
if (theCard->isEqual(cards[i]))
cards.erase(cards.begin() + i);
}
CardStack::CardStack() {
numOfCards = 0;
}
void CardStack::shuffle() {
random_shuffle(cards.begin(), cards.end());
}
Card* CardStack::getCard(int i) {
return cards.at(i);
}
Card* CardStack::getTopCard() {
return cards.front();
}
int CardStack::getSize() {
numOfCards = cards.size();
return numOfCards;
}
</code></pre>
<p>And the output is the following:</p>
<pre><code>"Rei de Ouros"
"Rei de Ouros"
"Rei de Ouros"
</code></pre>
| 0debug
|
delete the item on search box if clicked. : I am trying to built a dropdown menu with a text box.When the text box is clicked the items appear and when the items are clicked they turn green(selected) and show up in the text box.
I was wondering if there was a way in which i could just click the item on the search box and the item gets unselected(ungreen). How can i capture the click on the element name in the text box.!.[enter image description here][1]
[1]: http://i.stack.imgur.com/YKEOQ.png
| 0debug
|
C memory pool storing : <p>I am writing small memory allocation system. Having: </p>
<pre><code>typedef struct _POOL
{
int size; /*size of memory pool*/
void* memory; /*pointer to pool location in memory*/
} Pool;
Pool* allocatePool(int n) {
Pool *myPool = malloc(sizeof(Pool) + n);
if (myPool){
myPool->size = n;
myPool->memory = myPool+1;
}
return myPool;
}
</code></pre>
<p>I am trying to write function that will store arbitrary object of n size at location offset within the pool.</p>
<pre><code>void store(Pool* pool, int offset, int size, void *object) {
char *ptrHelper;
ptrHelper = &(pool->memory); /*copy pool memory address*/
ptrHelper += offset; /*increment to match offset*/
memcpy(ptrHelper, &object, size); /*copy object in to the pool*/
}
</code></pre>
<p>Questions:</p>
<p>ptrHelper = &(pool->memory) is there another correct way of getting pool memory address?</p>
<p>What to do in case I want to store values grater than size of void *object (4 bytes in my case)?</p>
<p>How to correctly handle strings without changing functions parameter structure?
Thank you.</p>
| 0debug
|
how to get the last digit from format like ip address javascript? : <p>Does anyone know how can I get the last digits <code>192.168.1.180</code><br>
<b>Example :</b> 192.168.1.180 from this ip address i want to extract 180.<br>
Thanks in advance</p>
| 0debug
|
list comprehension even list elements instead of loop and how to refer only to the index : <p>I want to use list comp' instead of a loop.
Let's sat I have a list of lists and I want only the even index elements.
Eg: [[a,a], [b,b], [c,c],[g,g]] to..... [[a,a], [c,c]]</p>
<p>This doesn't work</p>
<pre><code>
a = [i for i in the_list if i % 2 == 0)]
</code></pre>
| 0debug
|
static void put_cabac(CABACContext *c, uint8_t * const state, int bit){
int RangeLPS= ff_h264_lps_range[2*(c->range&0xC0) + *state];
if(bit == ((*state)&1)){
c->range -= RangeLPS;
*state= ff_h264_mps_state[*state];
}else{
c->low += c->range - RangeLPS;
c->range = RangeLPS;
*state= ff_h264_lps_state[*state];
}
renorm_cabac_encoder(c);
}
| 1threat
|
Is it possible to overload operator of class A in a friend class B? : <p>I'm trying to solve the following problem from the lab where it says:</p>
<blockquote>
<p>Define a class called Repository that has 2 integer private variables. The >class contains an empty constructor and another one with 2 parameters. An >accesor method that displays the variables values is also included in the >class. Write another class called Mathematics which is friend to the first >one. This class contains the implementation of the elementary arithmetical >operations (+, -, *, /) applied to the values stored in the first class. Each >arithmetical method receives as parameter an object instantiated from the >first class.</p>
</blockquote>
<p>I have been searching all over the internet for a couple of hours already but I haven't found anything about overloading operators of a class in another one. I understand the overloading mechanism, I solved the problem using friend functions but I'm still asking myself if it is possible to do as above mentioned and if yes, I wish to know how to do it. Thanks in advance !</p>
<p>I have tried the solution mentioned <a href="https://stackoverflow.com/questions/3981911/operators-overloading-in-other-classes">here</a></p>
<pre><code>//friend Repository operator + (Repository &, Repository &);
friend Mathematics;
};
/*
Repository operator + (Repository &rep1, Repository &rep2)
{
Repository obToRet;
obToRet.val1 = rep1.val1 + rep2.val1;
obToRet.val2 = rep1.val2 + rep2.val2;
return obToRet;
}*/
class Mathematics
{
public:
friend Repository;
public static Repository operator+(Repository &rep1, Repository &rep2)
{
Repository objtoret;
objtoret.val1 = rep1.val1 + rep2.val1;
objtoret.val2 = rep1.val2 + rep2.val2;
return objtoret;
}
};
</code></pre>
| 0debug
|
iscsi_process_read(void *arg)
{
IscsiLun *iscsilun = arg;
struct iscsi_context *iscsi = iscsilun->iscsi;
aio_context_acquire(iscsilun->aio_context);
iscsi_service(iscsi, POLLIN);
iscsi_set_events(iscsilun);
aio_context_release(iscsilun->aio_context);
}
| 1threat
|
void ppc_set_irq (CPUState *env, int n_IRQ, int level)
{
if (level) {
env->pending_interrupts |= 1 << n_IRQ;
cpu_interrupt(env, CPU_INTERRUPT_HARD);
} else {
env->pending_interrupts &= ~(1 << n_IRQ);
if (env->pending_interrupts == 0)
cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
}
#if defined(PPC_DEBUG_IRQ)
if (loglevel & CPU_LOG_INT) {
fprintf(logfile, "%s: %p n_IRQ %d level %d => pending %08x req %08x\n",
__func__, env, n_IRQ, level,
env->pending_interrupts, env->interrupt_request);
}
#endif
}
| 1threat
|
How to explode php result : <p>I'm sorry for bad English.</p>
<p>First, this is my code:</p>
<pre><code>$cok = $get->signup("4110069061");
echo $cok;
</code></pre>
<p>And the result is:</p>
<pre><code>kKIR4cGstfwkl9obhc58gaozugo5k7yc9vmm77p3:4110069061.c6384ef.821b51c9fbe54980a7a4e45847767079:4110069061:13090485
</code></pre>
<p>My questions is:</p>
<p>How to explode this delim ":"</p>
<p>I want to make this result like this:</p>
<p>Session: </p>
<blockquote>
<p>kKIR4cGstfwkl9obhc58gaozugo5k7yc9vmm77p3</p>
</blockquote>
<p>Token:</p>
<blockquote>
<p>4110069061.c6384ef.821b51c9fbe54980a7a4e45847767079</p>
</blockquote>
<p>ID:</p>
<blockquote>
<p>4110069061</p>
</blockquote>
<p>MID:</p>
<blockquote>
<p>13090485</p>
</blockquote>
<p>Can you understand? Please help me</p>
<p>Thank you</p>
| 0debug
|
Java: incremental if loop function in the incremental loop of the main : I'm trying to put an incremental loop function in the main, that has an incremental loop too.
Problem is, the value of the function always return to 0, has it reset to zero everytime I call the function. How can I stop it to reset to 0 everytime I call it? Putting it in a global variable works, but I cannot do that for my assesment.
Here are the 2 parts of my code that i'm talking about:
public static int choix_case (int nbColonnes) {
int max = maximum(nbColonnes);
int valeur_aleatoire = ValeurAleatoire();
int compteur = 0;
do {
if ( valeur_aleatoire == 1) {
compteur++;
}
if (valeur_aleatoire == 2) {
compteur++;
}
if (valeur_aleatoire == 3) {
compteur++;
}
}
while(compteur <= max);
return compteur;
}
And then :
public static void obtenirNouvelleGrille(int[][] grille, int nbLignes, int nbColonnes) {
for(int i = 0; i < nbLignes; i++) {
// mettre le compteur de balles et de centres à 0
for(int j = 0; j < nbColonnes; j++){
int choix = choix_case(nbColonnes);
grille[i][j] = choix; // vide
// balle = une valeur de balle
// centre = une valeure de centre
}
}
}
Thanks!
| 0debug
|
Privacy policy link Google Play : <p>I am having trouble here, this is my first app and there is so much involved, I did not think it was this hard, currenctly I am stuck on adding a link to my app's <code>PRIVACY POLICY</code> my app is very simple, it does not share any data but I do use google's analytics, one more thing is that I do not have a website so supposedly I had the privacy policy link where would I put it apart from a site I own? </p>
| 0debug
|
memchr returns unexpected characters : <p>I'm trying my best to understand the memchr function but having some issues with some simple output. I'm getting extra characters at the end of *newchar.</p>
<pre><code>#include <stdio.h>
#include <string.h>
int main() {
char plus[6] = "12+123";
char *newchar = (char*) memchr(plus,43,3);
printf("%s",newchar);
}
</code></pre>
<p>output:</p>
<pre><code>+123( '
</code></pre>
<p>I expected to get "+123," why does it give me the extra characters? I noticed the output is consistent which confuses me earlier, it doesn't seem like these were grabbed from somewhere random in memory but were caused by the memchr function. </p>
| 0debug
|
static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
AVPacket *pkt)
{
unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
int chunk_type;
int chunk_size;
unsigned char opcode_preamble[OPCODE_PREAMBLE_SIZE];
unsigned char opcode_type;
unsigned char opcode_version;
int opcode_size;
unsigned char scratch[1024];
int i, j;
int first_color, last_color;
int audio_flags;
unsigned char r, g, b;
chunk_type = load_ipmovie_packet(s, pb, pkt);
if ((chunk_type == CHUNK_VIDEO) && (chunk_type != CHUNK_DONE))
return chunk_type;
if (url_feof(pb))
return CHUNK_EOF;
if (get_buffer(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
CHUNK_PREAMBLE_SIZE)
return CHUNK_BAD;
chunk_size = AV_RL16(&chunk_preamble[0]);
chunk_type = AV_RL16(&chunk_preamble[2]);
debug_ipmovie("chunk type 0x%04X, 0x%04X bytes: ", chunk_type, chunk_size);
switch (chunk_type) {
case CHUNK_INIT_AUDIO:
debug_ipmovie("initialize audio\n");
break;
case CHUNK_AUDIO_ONLY:
debug_ipmovie("audio only\n");
break;
case CHUNK_INIT_VIDEO:
debug_ipmovie("initialize video\n");
break;
case CHUNK_VIDEO:
debug_ipmovie("video (and audio)\n");
break;
case CHUNK_SHUTDOWN:
debug_ipmovie("shutdown\n");
break;
case CHUNK_END:
debug_ipmovie("end\n");
break;
default:
debug_ipmovie("invalid chunk\n");
chunk_type = CHUNK_BAD;
break;
}
while ((chunk_size > 0) && (chunk_type != CHUNK_BAD)) {
if (url_feof(pb)) {
chunk_type = CHUNK_EOF;
break;
}
if (get_buffer(pb, opcode_preamble, CHUNK_PREAMBLE_SIZE) !=
CHUNK_PREAMBLE_SIZE) {
chunk_type = CHUNK_BAD;
break;
}
opcode_size = AV_RL16(&opcode_preamble[0]);
opcode_type = opcode_preamble[2];
opcode_version = opcode_preamble[3];
chunk_size -= OPCODE_PREAMBLE_SIZE;
chunk_size -= opcode_size;
if (chunk_size < 0) {
debug_ipmovie("chunk_size countdown just went negative\n");
chunk_type = CHUNK_BAD;
break;
}
debug_ipmovie(" opcode type %02X, version %d, 0x%04X bytes: ",
opcode_type, opcode_version, opcode_size);
switch (opcode_type) {
case OPCODE_END_OF_STREAM:
debug_ipmovie("end of stream\n");
url_fseek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_END_OF_CHUNK:
debug_ipmovie("end of chunk\n");
url_fseek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_CREATE_TIMER:
debug_ipmovie("create timer\n");
if ((opcode_version > 0) || (opcode_size > 6)) {
debug_ipmovie("bad create_timer opcode\n");
chunk_type = CHUNK_BAD;
break;
}
if (get_buffer(pb, scratch, opcode_size) !=
opcode_size) {
chunk_type = CHUNK_BAD;
break;
}
s->fps = 1000000.0 / (AV_RL32(&scratch[0]) * AV_RL16(&scratch[4]));
s->frame_pts_inc = 90000 / s->fps;
debug_ipmovie(" %.2f frames/second (timer div = %d, subdiv = %d)\n",
s->fps, AV_RL32(&scratch[0]), AV_RL16(&scratch[4]));
break;
case OPCODE_INIT_AUDIO_BUFFERS:
debug_ipmovie("initialize audio buffers\n");
if ((opcode_version > 1) || (opcode_size > 10)) {
debug_ipmovie("bad init_audio_buffers opcode\n");
chunk_type = CHUNK_BAD;
break;
}
if (get_buffer(pb, scratch, opcode_size) !=
opcode_size) {
chunk_type = CHUNK_BAD;
break;
}
s->audio_sample_rate = AV_RL16(&scratch[4]);
audio_flags = AV_RL16(&scratch[2]);
s->audio_channels = (audio_flags & 1) + 1;
s->audio_bits = (((audio_flags >> 1) & 1) + 1) * 8;
if ((opcode_version == 1) && (audio_flags & 0x4))
s->audio_type = CODEC_ID_INTERPLAY_DPCM;
else if (s->audio_bits == 16)
s->audio_type = CODEC_ID_PCM_S16LE;
else
s->audio_type = CODEC_ID_PCM_U8;
debug_ipmovie("audio: %d bits, %d Hz, %s, %s format\n",
s->audio_bits,
s->audio_sample_rate,
(s->audio_channels == 2) ? "stereo" : "mono",
(s->audio_type == CODEC_ID_INTERPLAY_DPCM) ?
"Interplay audio" : "PCM");
break;
case OPCODE_START_STOP_AUDIO:
debug_ipmovie("start/stop audio\n");
url_fseek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_INIT_VIDEO_BUFFERS:
debug_ipmovie("initialize video buffers\n");
if ((opcode_version > 2) || (opcode_size > 8)) {
debug_ipmovie("bad init_video_buffers opcode\n");
chunk_type = CHUNK_BAD;
break;
}
if (get_buffer(pb, scratch, opcode_size) !=
opcode_size) {
chunk_type = CHUNK_BAD;
break;
}
s->video_width = AV_RL16(&scratch[0]) * 8;
s->video_height = AV_RL16(&scratch[2]) * 8;
debug_ipmovie("video resolution: %d x %d\n",
s->video_width, s->video_height);
break;
case OPCODE_UNKNOWN_06:
case OPCODE_UNKNOWN_0E:
case OPCODE_UNKNOWN_10:
case OPCODE_UNKNOWN_12:
case OPCODE_UNKNOWN_13:
case OPCODE_UNKNOWN_14:
case OPCODE_UNKNOWN_15:
debug_ipmovie("unknown (but documented) opcode %02X\n", opcode_type);
url_fseek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_SEND_BUFFER:
debug_ipmovie("send buffer\n");
url_fseek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_AUDIO_FRAME:
debug_ipmovie("audio frame\n");
s->audio_chunk_offset = url_ftell(pb);
s->audio_chunk_size = opcode_size;
url_fseek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_SILENCE_FRAME:
debug_ipmovie("silence frame\n");
url_fseek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_INIT_VIDEO_MODE:
debug_ipmovie("initialize video mode\n");
url_fseek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_CREATE_GRADIENT:
debug_ipmovie("create gradient\n");
url_fseek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_SET_PALETTE:
debug_ipmovie("set palette\n");
if (opcode_size > 0x304) {
debug_ipmovie("demux_ipmovie: set_palette opcode too large\n");
chunk_type = CHUNK_BAD;
break;
}
if (get_buffer(pb, scratch, opcode_size) != opcode_size) {
chunk_type = CHUNK_BAD;
break;
}
first_color = AV_RL16(&scratch[0]);
last_color = first_color + AV_RL16(&scratch[2]) - 1;
if ((first_color > 0xFF) || (last_color > 0xFF)) {
debug_ipmovie("demux_ipmovie: set_palette indices out of range (%d -> %d)\n",
first_color, last_color);
chunk_type = CHUNK_BAD;
break;
}
j = 4;
for (i = first_color; i <= last_color; i++) {
r = scratch[j++] * 4;
g = scratch[j++] * 4;
b = scratch[j++] * 4;
s->palette_control.palette[i] = (r << 16) | (g << 8) | (b);
}
s->palette_control.palette_changed = 1;
break;
case OPCODE_SET_PALETTE_COMPRESSED:
debug_ipmovie("set palette compressed\n");
url_fseek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_SET_DECODING_MAP:
debug_ipmovie("set decoding map\n");
s->decode_map_chunk_offset = url_ftell(pb);
s->decode_map_chunk_size = opcode_size;
url_fseek(pb, opcode_size, SEEK_CUR);
break;
case OPCODE_VIDEO_DATA:
debug_ipmovie("set video data\n");
s->video_chunk_offset = url_ftell(pb);
s->video_chunk_size = opcode_size;
url_fseek(pb, opcode_size, SEEK_CUR);
break;
default:
debug_ipmovie("*** unknown opcode type\n");
chunk_type = CHUNK_BAD;
break;
}
}
s->next_chunk_offset = url_ftell(pb);
if ((chunk_type == CHUNK_VIDEO) || (chunk_type == CHUNK_AUDIO_ONLY))
chunk_type = load_ipmovie_packet(s, pb, pkt);
return chunk_type;
}
| 1threat
|
static void check_exception(PowerPCCPU *cpu, sPAPREnvironment *spapr,
uint32_t token, uint32_t nargs,
target_ulong args,
uint32_t nret, target_ulong rets)
{
uint32_t mask, buf, len, event_len;
uint64_t xinfo;
sPAPREventLogEntry *event;
struct rtas_error_log *hdr;
if ((nargs < 6) || (nargs > 7) || nret != 1) {
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
return;
}
xinfo = rtas_ld(args, 1);
mask = rtas_ld(args, 2);
buf = rtas_ld(args, 4);
len = rtas_ld(args, 5);
if (nargs == 7) {
xinfo |= (uint64_t)rtas_ld(args, 6) << 32;
}
event = rtas_event_log_dequeue(mask);
if (!event) {
goto out_no_events;
}
hdr = event->data;
event_len = be32_to_cpu(hdr->extended_length) + sizeof(*hdr);
if (event_len < len) {
len = event_len;
}
cpu_physical_memory_write(buf, event->data, len);
rtas_st(rets, 0, RTAS_OUT_SUCCESS);
g_free(event->data);
g_free(event);
if (rtas_event_log_contains(mask)) {
qemu_irq_pulse(xics_get_qirq(spapr->icp, spapr->check_exception_irq));
}
return;
out_no_events:
rtas_st(rets, 0, RTAS_OUT_NO_ERRORS_FOUND);
}
| 1threat
|
How to get device set time in swift/ios? : <p><a href="https://i.stack.imgur.com/QiBX4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QiBX4.png" alt="enter image description here"></a></p>
<p>I want to get time, which user sees in their status bar if they change the time to 24-hour format, or manually select some other timezone with or some other time in Settings, it should be changed in my app as well.</p>
| 0debug
|
How to css all element not inside a class : html, body, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sup, sub, tt, var, u, i, center, ul, ol, li, dl, dt, dd, tfoot, caption, form, fieldset, legend, input, button, textarea, select, label, applet, object, iframe, audio, video, canvas, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary{font-family: inherit; line-height: inherit; vertical-align: baseline; border: 0; outline: 0; padding: 0; margin: 0;}
i don't want that effect into all element inside div.base .
may you have a solution?
| 0debug
|
c++ initializtion with interface : I am trying to implement a general `value` class in c++ that can contain integer, float, and fractions etc. So I wrote an interface `value_interface` and had `int` wrapped up in `int_wrapper` to inherit from the interface. However, `value(3)` will not initialize a `value` object, because even if `3` is convertable to `int_wrapper`, which is convertable to `value_interface`, `value_interface` is not directly convertable to `value`. Is there any way to make `value(3)` possible? Or is there a better way to do this?
#include <string>
class value_interface {
public:
virtual std::string to_string() const = 0;
virtual ~value_interface() {}
};
class value {
std::shared_ptr<value_interface> d_ptr_;
public:
value(value_interface* x) { d_ptr_ = std::unique_ptr<value_interface>(x); }
std::string to_string() const { return d_ptr_->to_string(); }
};
class int_wrapper : public value_interface {
int val_;
public:
int_wrapper(const int val) : val_(val) {}
operator int() const { return val_; }
std::string to_string() const override { return std::to_string(val_); }
friend value operator+(int_wrapper x, int_wrapper y);
};
int main() {
value a = 3; // compile error : cannot convert 3 to value
return 0;
}
| 0debug
|
How to remove a custom sign from a variable : <p>Let's say I have a variable called <code>$price</code> and contains <code>12,234,564</code>.</p>
<p>Now I want to remove this sign:</p>
<blockquote>
<p>,</p>
</blockquote>
<p>So it would be like this:</p>
<p><code>12234564</code></p>
<p>And here is the full code:</p>
<pre><code>if(isset($_GET['price']){
$add_price = $_GET['price'];
}
</code></pre>
<p>How to do this in PHP ?</p>
| 0debug
|
how can i solve this "Cannot subscript a value of type '[[String]]' with an index of type 'UInt32'" : [enter image description here][1]i'm having a problem about this UInt32 thingy
the "answer" in my button is having an error about this "Cannot subscript a value of type '[[String]]' with an index of type 'UInt32'"
let answers = [["1. After the exam, I felt too exhausted and famished to eat my foods.","2. I could eat a horse, I am a famish now.","3. I famished my stomach next time you treat me to a meal out.","4. I will bring lots of pizza, that's famish."],["Would","Has to","Must","Could"]]
var rightanswerplacement:UInt32 = 0
rightanswerplacement = arc4random_uniform(2)+1
var button:UIButton = UIButton()
var x = 1
for i in 1...3{
button = view.viewWithTag(i) as! UIButton
if (i == Int(rightanswerplacement)){
button.setTitle(answers[rightanswerplacement][0], for: UIControlState.normal)
}
else{
button.setTitle(answers[rightanswerplacement][x], for: UIControlState.normal)
x = 2
}
currentquestions += 1
}
[1]: https://i.stack.imgur.com/g554J.png
| 0debug
|
How to verify using Mockito : <pre><code>Class Sample{
int property1;
int property2;
protected method1(Object1 obj1)
{
.
.
obj1.process(new Object2(property1,property2));
.
.
}
}
</code></pre>
<p>I want to verify that obj1.process is called with certain value. Im happy to provide more clarification.</p>
| 0debug
|
PHP - PDO OOP MySQL database connection is being repeated, is that a normal behavior? : <p>I am using a class for db connection like this...</p>
<pre><code>class Dbh
{
private $host;
private $dbName;
private $password;
private $dbUser;
private $charset;
protected function connect ()
{
$this->host = 'localhost';
$this->dbName = 'test';
$this->password = '';
$this->dbUser = 'root';
$this->charset = 'utf8mb4';
try
{
$dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->dbName . ';charset=' . $this->charset;
$pdo = new PDO($dsn, $this->dbUser, $this->password);
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
return $pdo;
}
catch (PDOException $exception)
{
$message = 'Connection failed:' . $exception->getMessage();
return $message;
}
}
}
</code></pre>
<p>... Now what worries me if I echo in <code>try</code> for example <code>echo 'Connected';</code> and call for example...</p>
<pre><code>$user = new User();
$users = $user->getAllUsers();
$update = $user->updateUser();
$insert = $user->insertUsers();
</code></pre>
<p>It will output 3 times 'Connected' on a page, where it should do probably only once as 1 connection is enough. </p>
<p>How to fix this?</p>
| 0debug
|
i want to compute specific field in my db depends on ID_number : This is my model
```
public function total_late()
{
$query = "SELECT sum(late_deduction) as late_deduction FROM tbl_dtr";
$result = $this->db->query($query);
return $result->row()->late_deduction;
}
```
this the image of db
[enter image description here][1]
this is the image of my table
[enter image description here][2]
[1]: https://i.stack.imgur.com/ViMUi.png
[2]: https://i.stack.imgur.com/6zH1M.png
please help asap
thank you in advance
| 0debug
|
How can I use my getAge() methode : [enter image description here][1]
[1]: https://i.stack.imgur.com/sVvHm.png
I have to make this AgeDiscount class, which have a method that generates a Age Discount. So if I am 21 years, i will get a discount of 21%.
So i need use my getAge from my Customer class. But i dont know how to pick it up?
public class AgeDiscount implements Discount {
@Override
public double getDiscountedPrice(double originalPrice) {
return originalPrice;
}
}
| 0debug
|
apt-get update fails with 404 in a previously working build : <p>I am running a Travis build and it fails when building the mysql:5.7.27 docker image. The Dockerfile runs <code>apt-get update</code> and then I get an error <code>W: Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/main/binary-amd64/Packages 404 Not Found</code>.</p>
<p>Using curl I can see it is redirecting, but the redirect-to URL results in a 404. Has anyone seen this sort of behaviour and have a remedy? Is it basically unfixable until debian makes changes?</p>
<pre><code>➜ ms git:(develop) curl --head http://deb.debian.org/debian/dists/jessie-updates/main/binary-amd64/Packages
HTTP/1.1 302 Found
Date: Tue, 26 Mar 2019 16:03:04 GMT
Server: Apache
X-Content-Type-Options: nosniff
X-Frame-Options: sameorigin
Referrer-Policy: no-referrer
X-Xss-Protection: 1
Location: http://cdn-fastly.deb.debian.org/debian/dists/jessie-updates/main/binary-amd64/Packages
Content-Type: text/html; charset=iso-8859-1
➜ ms git:(develop) curl --head http://cdn-fastly.deb.debian.org/debian/dists/jessie-updates/main/binary-amd64/Packages
HTTP/1.1 404 Not Found
Server: Apache
X-Content-Type-Options: nosniff
X-Frame-Options: sameorigin
Referrer-Policy: no-referrer
X-Xss-Protection: 1
Content-Type: text/html; charset=iso-8859-1
Via: 1.1 varnish
Content-Length: 316
Accept-Ranges: bytes
Date: Tue, 26 Mar 2019 16:03:17 GMT
Via: 1.1 varnish
Age: 45
Connection: keep-alive
X-Served-By: cache-ams21028-AMS, cache-cdg20741-CDG
X-Cache: HIT, HIT
X-Cache-Hits: 6, 2
X-Timer: S1553616198.734091,VS0,VE0
</code></pre>
| 0debug
|
static void ERROR(const char *str)
{
fprintf(stderr, "%s\n", str);
exit(1);
}
| 1threat
|
need help Action script 3 keyboard input : <p>I want to make a game, and I just found a tutorial on making a rhythm game on this website <a href="http://www.flashgametuts.com/tutorials/as3/how-to-make-a-rhythm-game-in-as3-part-7/" rel="nofollow noreferrer">http://www.flashgametuts.com/tutorials/as3/how-to-make-a-rhythm-game-in-as3-part-7/</a>, and i need help for change this arrow input to a keyboard input, Lik "W" "A" "S" etc, Thank you</p>
| 0debug
|
Program wont move past delete : <p>So I can not figure out why my program halts at the delete statement inside my purge loop. It's not crashing it just won't execute or give my any sort of error.</p>
<p>I have double checked that I am deleting an array and need the brackets, and verified that it is valid new memory. It will not work if its called by the destructor or explicitly </p>
<pre><code>int main()
{
darray DA1;
DA1.Add("Hello");
DA1.Add("Good Morning");
return 0;
}
void Add(const char * string)
{
char ** temp = new char *[m_count + 1];
for (int i = 0; i < m_count; ++i)
temp[i] = m_array[i];
temp[m_count] = new char[strlen(string)];
strcpy(temp[m_count], string);
delete[] m_array;
m_array = temp;
m_count++;
}
void Purge()
{
for (int i = 0; i < m_count; ++i)
{
delete [] m_array[i];
m_array[i] = nullptr;
}
delete[] m_array;
m_array = nullptr;
m_count = 0;
}
</code></pre>
<p>I expect it to go through the 2d dynamic array deleting each array and then delete the final array.</p>
| 0debug
|
HikariPool-1 - jdbcUrl is required with driverClassName : <p>I went back to programming my old program <a href="https://github.com/JonkiPro/REST-Web-Services" rel="noreferrer">https://github.com/JonkiPro/REST-Web-Services</a>. I've updated Spring Boot from version 15.6 to version 2.0.0. I have encountered many problems with compilation, but I can not deal with one. Well, during compilation, he throws me in the console</p>
<pre><code>2018-03-18 21:54:53.339 ERROR 3220 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig : HikariPool-1 - jdbcUrl is required with driverClassName.
2018-03-18 21:54:55.392 INFO 3220 --- [ost-startStop-1] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'unit'
2018-03-18 21:54:56.698 INFO 3220 --- [ost-startStop-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'unit'
2018-03-18 21:54:56.778 ERROR 3220 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig : HikariPool-1 - jdbcUrl is required with driverClassName.
2018-03-18 21:54:56.782 ERROR 3220 --- [ost-startStop-1] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'webSecurityConfig': Unsatisfied dependency expressed through field 'userDetailsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDetailsService' defined in file [C:\Users\Jonatan\Documents\GitHub\REST-Web-Services\web\out\production\classes\com\web\web\security\service\impl\UserDetailsServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Cannot create inner bean '(inner bean)#65d6e77b' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#65d6e77b': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Post-processing of FactoryBean's singleton object failed; nested exception is java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName.
2018-03-18 21:54:56.821 WARN 3220 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
</code></pre>
<p>I've never had such a mistake. I do not know what it means completely. My properties for the base look like this</p>
<pre><code>spring:
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql:database
username: root
password: root
schema: classpath:/db/init/schema.sql
</code></pre>
<p>I do not know how to deal with this error. I've been programming quite a long time, but for the first time I'm meeting the concept of <code>hikari</code>. I'm using a Tomcat(in Spring Boot) server and a PostgreSQL database.</p>
| 0debug
|
C++ comparison of integers with float : <p>I have the following code.that demonstrates the problem I am having. How come the comparison is not evaluating to true? Is this a limitation of integer and floating point comparisons?</p>
<pre><code>#include <iostream>
int main(){
double m = -0.625;
if((-1)<=m<=0){
std::cout << "Enter here" <<std::endl;
}
return 0;
}
</code></pre>
| 0debug
|
Rewrite Javascript to Python : <p>I struggling to understand this javascript code and would like to rewrite it to python.</p>
<pre><code>function rotateRight(e, t) {
for (var n, i = 0; (t > i); i++)
n = (1 & e), e >>= 1, n <<= 31, e += n;
return e
}
</code></pre>
<p>My biggest struggle is to understand how is the <code>e</code> being influenced by <code>n</code>.</p>
<p>Thank you for help</p>
| 0debug
|
static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h ) {
const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
const int alpha = alpha_table[index_a];
const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
if (alpha ==0 || beta == 0) return;
if( bS[0] < 4 ) {
int8_t tc[4];
tc[0] = tc0_table[index_a][bS[0]]+1;
tc[1] = tc0_table[index_a][bS[1]]+1;
tc[2] = tc0_table[index_a][bS[2]]+1;
tc[3] = tc0_table[index_a][bS[3]]+1;
h->h264dsp.h264_h_loop_filter_chroma(pix, stride, alpha, beta, tc);
} else {
h->h264dsp.h264_h_loop_filter_chroma_intra(pix, stride, alpha, beta);
}
}
| 1threat
|
Hangfire DisableConcurrentExecution: What happens when the timeout expires? : <p>Per the <a href="http://hangfire.io/blog/2014/05/21/hangfire-0.8.2-released.html" rel="noreferrer">Hangfire 0.8.2 announcement post</a>, Hangfire has a <code>DisableConcurrentExecution</code> filter which, when applied to a method, prevents multiple instances of the method from executing concurrently.</p>
<p>The <code>DisableConcurrentExecution</code> filter takes a <code>timeoutInSeconds</code> int parameter. From the example in the linked article:</p>
<pre><code>[DisableConcurrentExecution(timeoutInSeconds: 10 * 60)]
public void SomeMethod()
{
// Operations performed inside a distributed lock
}
</code></pre>
<p>My question is: What happens when, given a job which is waiting on obtaining the lock for a <code>DisableConcurrentExecution</code>-filtered method, the time that the job has been waiting exceeds the <code>timeoutInSeconds</code> value?</p>
| 0debug
|
static VirtIOSCSIReq *virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq)
{
VirtIOSCSIReq *req;
req = g_malloc(sizeof(*req));
req->vq = vq;
req->dev = s;
req->sreq = NULL;
qemu_sglist_init(&req->qsgl, DEVICE(s), 8, &address_space_memory);
return req;
}
| 1threat
|
How to display graphics on a C++ program without third party libraries? : <p>I can't seem to find the answer I'm looking for, or I might miss understand this. Either way I am confused.</p>
<p>When I try to find out, there is always videos about C++ console programming, which annoys me because I wanna move away from console stuff by now. I know how to create a simple window, but not how to display real graphics on it. I have heard of stuff like OpenGL and DirectX, but it makes me wonder, what do those libraries have in their source whcih draws actual shapes and other things on the program? What C++ functions do they use in their code?</p>
| 0debug
|
static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val,
unsigned size)
{
SerialState *s = opaque;
addr &= 7;
DPRINTF("write addr=0x%" HWADDR_PRIx " val=0x%" PRIx64 "\n", addr, val);
switch(addr) {
default:
case 0:
if (s->lcr & UART_LCR_DLAB) {
s->divider = (s->divider & 0xff00) | val;
serial_update_parameters(s);
} else {
s->thr = (uint8_t) val;
if(s->fcr & UART_FCR_FE) {
if (fifo8_is_full(&s->xmit_fifo)) {
fifo8_pop(&s->xmit_fifo);
}
fifo8_push(&s->xmit_fifo, s->thr);
}
s->thr_ipending = 0;
s->lsr &= ~UART_LSR_THRE;
s->lsr &= ~UART_LSR_TEMT;
serial_update_irq(s);
if (s->tsr_retry <= 0) {
serial_xmit(NULL, G_IO_OUT, s);
}
}
break;
case 1:
if (s->lcr & UART_LCR_DLAB) {
s->divider = (s->divider & 0x00ff) | (val << 8);
serial_update_parameters(s);
} else {
uint8_t changed = (s->ier ^ val) & 0x0f;
s->ier = val & 0x0f;
if ((changed & UART_IER_MSI) && s->poll_msl >= 0) {
if (s->ier & UART_IER_MSI) {
s->poll_msl = 1;
serial_update_msl(s);
} else {
timer_del(s->modem_status_poll);
s->poll_msl = 0;
}
}
if (changed & UART_IER_THRI) {
if ((s->ier & UART_IER_THRI) && (s->lsr & UART_LSR_THRE)) {
s->thr_ipending = 1;
} else {
s->thr_ipending = 0;
}
}
if (changed) {
serial_update_irq(s);
}
}
break;
case 2:
if ((val ^ s->fcr) & UART_FCR_FE) {
val |= UART_FCR_XFR | UART_FCR_RFR;
}
if (val & UART_FCR_RFR) {
s->lsr &= ~(UART_LSR_DR | UART_LSR_BI);
timer_del(s->fifo_timeout_timer);
s->timeout_ipending = 0;
fifo8_reset(&s->recv_fifo);
}
if (val & UART_FCR_XFR) {
s->lsr |= UART_LSR_THRE;
s->thr_ipending = 1;
fifo8_reset(&s->xmit_fifo);
}
serial_write_fcr(s, val & 0xC9);
serial_update_irq(s);
break;
case 3:
{
int break_enable;
s->lcr = val;
serial_update_parameters(s);
break_enable = (val >> 6) & 1;
if (break_enable != s->last_break_enable) {
s->last_break_enable = break_enable;
qemu_chr_fe_ioctl(s->chr, CHR_IOCTL_SERIAL_SET_BREAK,
&break_enable);
}
}
break;
case 4:
{
int flags;
int old_mcr = s->mcr;
s->mcr = val & 0x1f;
if (val & UART_MCR_LOOP)
break;
if (s->poll_msl >= 0 && old_mcr != s->mcr) {
qemu_chr_fe_ioctl(s->chr,CHR_IOCTL_SERIAL_GET_TIOCM, &flags);
flags &= ~(CHR_TIOCM_RTS | CHR_TIOCM_DTR);
if (val & UART_MCR_RTS)
flags |= CHR_TIOCM_RTS;
if (val & UART_MCR_DTR)
flags |= CHR_TIOCM_DTR;
qemu_chr_fe_ioctl(s->chr,CHR_IOCTL_SERIAL_SET_TIOCM, &flags);
timer_mod(s->modem_status_poll, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + s->char_transmit_time);
}
}
break;
case 5:
break;
case 6:
break;
case 7:
s->scr = val;
break;
}
}
| 1threat
|
Tool for see wich symfony package is not compatible with another symfony version : I would like know if a tool for detect compatilitie of symfony package for symfony version ?
Example: if sonata/userbundle is compatible with symfony 3.4.
Thank's !
| 0debug
|
void do_addco (void)
{
T2 = T0;
T0 += T1;
if (likely(T0 >= T2)) {
xer_ca = 0;
} else {
xer_ca = 1;
}
if (likely(!((T2 ^ T1 ^ (-1)) & (T2 ^ T0) & (1 << 31)))) {
xer_ov = 0;
} else {
xer_so = 1;
xer_ov = 1;
}
}
| 1threat
|
cannot use setText() will crash the app everytime : <p>text view will crash every time i use .setText()
this is my activity
TextView tvAvgRank;
SharedPreferences pref;</p>
<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_stats);
pref = this.getSharedPreferences("ranks", Context.MODE_PRIVATE);
tvAvgRank = (TextView)findViewById(R.id.tvAvgRank);
tvAvgRank.setText(avgRank(loadRanks()));
}
</code></pre>
| 0debug
|
React Router v4 routes not working : <p>I am relatively new to reacts and I'm trying to figure out how to get React router to work. I've got a super simple test app that looks like this:</p>
<pre><code>import React from 'react';
import ReactDOM from 'react-dom';
import {BrowserRouter as Router, Route, Switch, IndexRoute, Link} from 'react-router-dom';
const Home = () => <h1><Link to= "/about">Click Me</Link></h1>
const About = () => <h1>About Us</h1>
const Test = () => (
<Router>
<Switch>
<Route path ="/" component = {Home} />
<Route path ="/about" component = {About} />
</Switch>
</Router>
)
ReactDOM.render(<Test />, document.getElementById('app'));
</code></pre>
<p>when I run the app the home component loads without any trouble, and when I click the "Click Me" link the url changes to localhost/about, however nothing happens. If I click refresh I get a "Cannot GET /about." Clearly I am doing something wrong but I haven't been able to figure out what. I am also using Webpack.</p>
| 0debug
|
static void address_space_update_topology(AddressSpace *as)
{
FlatView *old_view = as->current_map;
FlatView *new_view = generate_memory_topology(as->root);
address_space_update_topology_pass(as, old_view, new_view, false);
address_space_update_topology_pass(as, old_view, new_view, true);
as->current_map = new_view;
flatview_destroy(old_view);
address_space_update_ioeventfds(as);
}
| 1threat
|
WebSocket connection fails on Chrome without SSL : <p>I'm setting up a WebSocket between a standard web page and a Tomcat v7.0.62 server. The connection works fine with Tomcat SSL turned on/off on Firefox, Edge and IE11. However, in Chrome (v66.03), the websocket only connects when I've turned on SSL on the server and connect via https. In Chrome, when I turn SSL off on the server and try to connect via http, it throws an error.</p>
<p>Here's the error Chrome throws when trying to connect via http with SSL turned off on Tomcat...</p>
<pre><code>Error in connection establishment: net::ERR_PROXY_AUTH_REQUESTED_WITH_NO_CONNECTION
</code></pre>
<p>Here's my WebSocket connection code on the client...</p>
<pre><code>var wss = "wss://";
if (document.location.protocol === "http:") {
wss = "ws://";
}
var wsURL = wss + document.location.host + "/status?sessionId=<%=session.getId()%>";
</code></pre>
<p>Is this something Chrome specific that needs special code on non-https websocket connections?</p>
| 0debug
|
void helper_ldq_raw(uint64_t t0, uint64_t t1)
{
ldq_raw(t1, t0);
}
| 1threat
|
How to add randomness to the blink effect? : <p>JS</p>
<pre><code> <script>
(function blink() {
$('.demo').fadeOut(500).fadeIn(400, blink);
})();
</script>
</code></pre>
<p>CSS</p>
<pre><code>.demo {
background: url('../res/logo.png') no-repeat;
width: 200px;
height: 200px;
margin-top: 355px;
margin-left: 855px;
}
</code></pre>
<p>How do i add randomness to this blinking effect?</p>
| 0debug
|
Docker Repository Does Not Have a Release File on Running apt-get update on Ubuntu : <p>I am using Ubuntu 16.10 and recently installed Docker (v1.12.4) using the Xenial build by following the instructions found <a href="https://docs.docker.com/engine/installation/linux/ubuntulinux/" rel="noreferrer">here</a>. I haven't encountered any problems creating containers, ensuring they restart automatically, etc.</p>
<p>However, now every time I run <strong>apt-get update</strong> I receive the following error message:</p>
<pre><code>W: The repository 'https://apt.dockerproject.org/repo ubuntu-xenial Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch https://apt.dockerproject.org/repo/dists/ubuntu-xenial/main/binary-amd64/Packages
E: Some index files failed to download. They have been ignored, or old ones used instead.
</code></pre>
<p>I have tried to remedy the problem by following the advice found <a href="https://github.com/docker/docker/issues/22599" rel="noreferrer">here</a> and cannot seem to solve this problem.</p>
<p>Has anyone encountered this before and fixed it? If so, what is needed to resolve this?</p>
| 0debug
|
Does TensorFlow view all CPUs of one machine as ONE device? : <p>From the experiments I run, it seems like TensorFlow uses automatically all CPUs on one machine. Furthermore, it seems like TensorFlow refers to all CPUs as /cpu:0. </p>
<p>Am I right, that only the different GPUs of one machine get indexed and viewed as separate devices, but all the CPUs on one machine get viewed as a single device? </p>
<p>Is there any way that a machine can have multiple CPUs viewing it from TensorFlows perspective? </p>
| 0debug
|
Who leaked my source? : <p>Just imagine, having a company with 10 programmers. Each pulling and pushing to the git repository on github or bitbucket.</p>
<p>Then some day, the sourcecode is published on a public website. Is there any technical way to find out who pulled that source that got published?</p>
<p>Is there any way to bind an employee to a specific source, while there multiple employees working on the same source (different local repos)?</p>
| 0debug
|
Beautifuelsoup - Python : I was hoping to ask a pretty simple question. I have come across the below code and have not been able to find a decent explanation as to i) what exactly does the .attrs function do in this cose ii) what is the function of the ['href'] part at the end i.e. what exactly does that part of the code execute.
thanks very much for any help!
from urllib.request import urlopen
from bs4 import BeautifulSoup
html = urlopen("url")
bsObj = BeautifulSoup(html)
for link in bsObj.findAll("a"):
if 'href' in link.attrs:
print (link.attrs['href'])
| 0debug
|
Jqueru plugin mmenu : I have a problem with the mmenu I can not figure out how to install the plugin, the first time I work with it) help pls. What exactly is the problem I watch the tutorials where it is everywhere written to connect
Path / to / js / jquery.mmenu.all.min.js
But when downloading there is no such folder js, and even more so a minified file
| 0debug
|
static int v9fs_synth_fsync(FsContext *ctx, int fid_type,
V9fsFidOpenState *fs, int datasync)
{
errno = ENOSYS;
return 0;
}
| 1threat
|
currentTime() in video js : The following is my code which is not working. Any help would be appreciated.
var myPlayer;
videojs("example_video_1").ready(function(){
myPlayer = this;
if(myPlayer.currentTime()>3)
{
alert("STARTED");
});
});
| 0debug
|
Do cakephp 3.x auth only works with users table? : I have an admins table in my db with username and password.. I want to logged a user in using that.
When ever I try to login, it gives me an sql error.... unknown column Users.Username is not found
| 0debug
|
Add Kml file in google map with Local path and server path javascript : Below java script cod. server side path apply. plz local path throw open kml file in goolge map.
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 11,
center: {lat: 23.026261, lng: 72.566872}
});
var ctaLayer = new google.maps.KmlLayer({
url: 'http://exaple.com//aa.kml',
map: map
});
}
can i add local path in java script.
can i add dynamic change kml file in java script.
| 0debug
|
Assistance with inheritance issue in C++ : <p>I have a 2 C++ classes(A and B), let's say B inherits from A. </p>
<p>They both need to have a toString() function. They are being called from a function that returns the base class type. After returning, I want to call the tostring() function for the correct type of class. If the function returns a B type object, I want to call the toString() from the B class.</p>
<p>I think my problem is coming from the fact that the function returns a reference to the base class so it is calling the function from the base class.</p>
<p>Example classes:</p>
<pre><code>class A
{
std::string toString();
};
class B
: public A
{
int extraThingToPrint;
std::string toString(); //prints a different message than the A version
};
</code></pre>
<p>Example function:</p>
<pre><code>A otherClass::scan()
{
if(otherVar == 'a') return A();
else if(otherVar == 'bb') return B();
}
std::cout << scan().toString(); //if bb plz print B.toString() and not A.toString() (but if a, use A.toString())
</code></pre>
| 0debug
|
JSON DeserializeObject is very slow : <p>I created small recursive C# app to parse unknown JSON string to find particular Key/Value pair's using <code>Newtonsoft.Json.dll</code>. It works OK on small JSON strings, but takes really long time, if JSON is bigger: 3.5MB JSON file with 15K+ lines takes >3 min to parse. Parsing same file using RegExp takes <1 sec. Is that <code>JsonConvert.DeserializeObject()</code> takes that long ?!</p>
<pre><code> string json = @"{""origin-of_error"" : ""error_message"",""foo"" : ""bar""}";
static void GetJsonValue (string json, string findStr = "foo")
{
try
{
if (Regex.Match(json, @"^\[", RegexOptions.Multiline).Success)
{
// JSON string Array []
var jArr = JsonConvert.DeserializeObject<List<Object>>(json);
foreach (var jLine in jArr) GetJsonValue(jLine.ToString());
}
else
{
// JSON string KEY:VALUE
var jLog = JsonConvert.DeserializeObject<Dictionary<String, Object>>(json);
foreach (KeyValuePair<string, object> jEntry in jLog)
{
if (jEntry.Key.ToString() == findStr) Console.WriteLine("MATCH:" + jEntry.ToString());
GetJsonValue(jEntry.Value.ToString());
}
}
}
catch { }
}
</code></pre>
| 0debug
|
static gboolean ga_channel_open(GAChannel *c, const gchar *path, GAChannelMethod method)
{
int ret;
c->method = method;
switch (c->method) {
case GA_CHANNEL_VIRTIO_SERIAL: {
int fd = qemu_open(path, O_RDWR | O_NONBLOCK
#ifndef CONFIG_SOLARIS
| O_ASYNC
#endif
);
if (fd == -1) {
g_critical("error opening channel: %s", strerror(errno));
exit(EXIT_FAILURE);
}
#ifdef CONFIG_SOLARIS
ret = ioctl(fd, I_SETSIG, S_OUTPUT | S_INPUT | S_HIPRI);
if (ret == -1) {
g_critical("error setting event mask for channel: %s",
strerror(errno));
exit(EXIT_FAILURE);
}
#endif
ret = ga_channel_client_add(c, fd);
if (ret) {
g_critical("error adding channel to main loop");
return false;
}
break;
}
case GA_CHANNEL_ISA_SERIAL: {
struct termios tio;
int fd = qemu_open(path, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (fd == -1) {
g_critical("error opening channel: %s", strerror(errno));
exit(EXIT_FAILURE);
}
tcgetattr(fd, &tio);
tio.c_iflag &= ~(IGNBRK | BRKINT | IGNPAR | PARMRK | INPCK | ISTRIP |
INLCR | IGNCR | ICRNL | IXON | IXOFF | IXANY |
IMAXBEL);
tio.c_oflag = 0;
tio.c_lflag = 0;
tio.c_cflag |= GA_CHANNEL_BAUDRATE_DEFAULT;
tio.c_cc[VMIN] = 1;
tio.c_cc[VTIME] = 0;
tcflush(fd, TCIFLUSH);
tcsetattr(fd, TCSANOW, &tio);
ret = ga_channel_client_add(c, fd);
if (ret) {
g_error("error adding channel to main loop");
}
break;
}
case GA_CHANNEL_UNIX_LISTEN: {
Error *local_err = NULL;
int fd = unix_listen(path, NULL, strlen(path), &local_err);
if (local_err != NULL) {
g_critical("%s", error_get_pretty(local_err));
error_free(local_err);
return false;
}
ga_channel_listen_add(c, fd, true);
break;
}
default:
g_critical("error binding/listening to specified socket");
return false;
}
return true;
}
| 1threat
|
increase max_allowed_packet size in mysql docker : <p>We are using <strong>Docker</strong> for mysql, We are facing the below error while running</p>
<pre><code>Packet for query is too large (12884616 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable.; nested exception is com.mysql.jdbc.PacketTooBigException: Packet for query is too large (12884616 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable.
</code></pre>
<p>now we need to increase <code>max_allowed_packet</code> size in <strong>mysql</strong> configuration, Can anyone help me on docker command to increase <code>max_allowed_packet</code>.</p>
| 0debug
|
def profit_amount(actual_cost,sale_amount):
if(actual_cost > sale_amount):
amount = actual_cost - sale_amount
return amount
else:
return None
| 0debug
|
How to run a file in python and check its result : I'm totally new to python and sorry for the manner this question is asked. I have a file called helloworld.py. And I want to code a .py program in python which can run this file multiple times and automatically check its output is the desired one. How could I code this?
| 0debug
|
Django rest framework override page_size in ViewSet : <p>I am having problem with django rest framework pagination.
I have set pagination in settings like -</p>
<pre><code>'DEFAULT_PAGINATION_CLASS':'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 1
</code></pre>
<p>Below is my viewset. </p>
<pre><code>class HobbyCategoryViewSet(viewsets.ModelViewSet):
serializer_class = HobbyCategorySerializer
queryset = UserHobbyCategory.objects.all()
</code></pre>
<p>I want to set different page size for this viewset. I have tried setting page_size and Paginate_by class variables but list is paginated according to PAGE_SIZE defined in settings. Any idea where I am wrong ?</p>
| 0debug
|
Passing command line arguments to webpack.config.js : <p>I have a simple webpack.config.js </p>
<pre><code>module.exports = {
entry: "./app.js",
output: {
filename: "bundle.js"
},
}
</code></pre>
<p>And I want to pass the values for <code>entry</code>and <code>output</code> through command line arguments. Is that possible and how would I do that? </p>
| 0debug
|
How to trigger a jenkins build on specific node using pipeline plugin? : <p>I have a Jenkins pipeline job called "TestPipeline". I want to trigger a build on 2 different slaves which labeled "tester1' and "tester2". And the pipeline script is quite simple here:</p>
<pre><code>node('tester1') {
build 'test_job'
}
node('tester2') {
build 'test_job'
}
</code></pre>
<p>However when I run the TestPipeline job, the "test_job" won't run on the nodes which I assigned. But run on random node instead. </p>
<p>I'm wondering if I should set "Restrict where this project can be run" on my "test_job". So I set it to "tester" (The "tester" label contains both node "tester1" and "tester2"). But when I run the pipeline job again, the "test_job" runs on "tester2" twice. I should expect the job to run on "tester1" first and then run on "tester2".
Why is that? Is it because the "node" step doesn't matter when it comes to which node the build step should be built on?</p>
| 0debug
|
static int yuv4_write_header(AVFormatContext *s)
{
int *first_pkt = s->priv_data;
if (s->nb_streams != 1)
return AVERROR(EIO);
if (s->streams[0]->codecpar->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME) {
av_log(s, AV_LOG_ERROR, "ERROR: Codec not supported.\n");
return AVERROR_INVALIDDATA;
}
switch (s->streams[0]->codecpar->format) {
case AV_PIX_FMT_YUV411P:
av_log(s, AV_LOG_WARNING, "Warning: generating rarely used 4:1:1 YUV "
"stream, some mjpegtools might not work.\n");
break;
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_GRAY16:
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUV422P:
case AV_PIX_FMT_YUV444P:
break;
case AV_PIX_FMT_YUV420P9:
case AV_PIX_FMT_YUV422P9:
case AV_PIX_FMT_YUV444P9:
case AV_PIX_FMT_YUV420P10:
case AV_PIX_FMT_YUV422P10:
case AV_PIX_FMT_YUV444P10:
case AV_PIX_FMT_YUV420P12:
case AV_PIX_FMT_YUV422P12:
case AV_PIX_FMT_YUV444P12:
case AV_PIX_FMT_YUV420P14:
case AV_PIX_FMT_YUV422P14:
case AV_PIX_FMT_YUV444P14:
case AV_PIX_FMT_YUV420P16:
case AV_PIX_FMT_YUV422P16:
case AV_PIX_FMT_YUV444P16:
if (s->strict_std_compliance >= FF_COMPLIANCE_NORMAL) {
av_log(s, AV_LOG_ERROR, "'%s' is not an official yuv4mpegpipe pixel format. "
"Use '-strict -1' to encode to this pixel format.\n",
av_get_pix_fmt_name(s->streams[0]->codecpar->format));
return AVERROR(EINVAL);
}
av_log(s, AV_LOG_WARNING, "Warning: generating non standard YUV stream. "
"Mjpegtools will not work.\n");
break;
default:
av_log(s, AV_LOG_ERROR, "ERROR: yuv4mpeg can only handle "
"yuv444p, yuv422p, yuv420p, yuv411p and gray8 pixel formats. "
"And using 'strict -1' also yuv444p9, yuv422p9, yuv420p9, "
"yuv444p10, yuv422p10, yuv420p10, "
"yuv444p12, yuv422p12, yuv420p12, "
"yuv444p14, yuv422p14, yuv420p14, "
"yuv444p16, yuv422p16, yuv420p16 "
"and gray16 pixel formats. "
"Use -pix_fmt to select one.\n");
return AVERROR(EIO);
}
*first_pkt = 1;
return 0;
}
| 1threat
|
static void pci_spapr_set_irq(void *opaque, int irq_num, int level)
{
sPAPRPHBState *phb = opaque;
qemu_set_irq(phb->lsi_table[irq_num].qirq, level);
}
| 1threat
|
Linear search in a array using bool : I need to develop a linear search algorithm that tests whether the array contains testVal
this is what I wrote
bool Contains(int a[], int arraySize, int testVal)
{
bool contains = 0;
for (int i = 0; i < arraySize; ++i)
{
if (a[i] == testVal)
{
contains = true;
std::cout << "true" << std::endl;
}
else if (a[i] != testVal)
{
contains = false;
std::cout << "false" << std::endl;
}
}
return contains; }
When it debugs it prints correctly, but it also prints 19 "false". I guess it has something to do with the array size being 20. I don't how to fix it to only print once without the 19 "false". Can someone tell me what is wrong?
| 0debug
|
how to use directive @push in blade template laravel : <p>I need script only on one page. and it should load after jQuery.
I tried in index.blade </p>
<pre><code><script type="text/javascript" src="{{ URL::asset ('js/jquery.js') }}"></script>
@push('custom-scripts')
<script type="text/javascript" src="{{ URL::asset ('js/custom-scripts.js') }}"></script>
@endpush
</code></pre>
<p>and then I should use @stack('custom-scripts') in my view?</p>
| 0debug
|
Use .exe file in android application : <p>There is a way to put a computer program with .exe extensions in the Android program and then run them through the program.</p>
<p>I have read about ndk and win, but I do not know exactly how to use them</p>
<p>Please describe with an example or give full reference</p>
| 0debug
|
"assignment makes integer from pointer without a cast -wint-conversion" : <p>I am new to c language and I wanted to make a calculator so I wrote this code:</p>
<pre><code>#include<stdio.h>
void main()
{
int x,y,z;
char m;
printf("enter the first number");
scanf("%d",&x);
printf("enter the second number");
scanf("%d",&y);
printf("enter the math operator");
scanf("%c",&m);
if (m == '+')
{
z=x+y;
printf("the answer is %d",z);
}
else if(m == '-')
{
z=x-y;
printf("the answer is %d",z);
}
else
{
printf("wrong symbol");
}
}
</code></pre>
<p>when I run the program it will ignore</p>
<pre><code>scanf("%c",&m);
</code></pre>
<p>and </p>
<pre><code>if (m == '+')
{
z=x+y;
printf("the answer is %d",z);
}
else if(m == '-')
{
z=x-y;
printf("the answer is %d",z);
}
</code></pre>
<p>and it will go straight to</p>
<pre><code>else
{
printf("wrong symbol");
}
</code></pre>
<p>and it shows like this: <a href="https://i.imgur.com/QQF8ftg.jpg" rel="nofollow noreferrer">https://i.imgur.com/QQF8ftg.jpg</a>
please help.</p>
| 0debug
|
How can i create makefile for gcc on a server-client program? : <p>There are 3 files : "client.c" , "server.c" and "util.h"</p>
<p>I need to compile this with gcc on linux and have 2 executables, 1 for client and another for server .
But it can be possible to have more than 1 client running and ONLY 1 server.
Im not sure how to do this , create 1 makefile only for client and another for server or just 1 and it can work ? </p>
| 0debug
|
How can I get the same effect on my webpage? : <p>So I've seen a mouse-hover effect on 2 websites so far and I really like it.
<a href="https://i.stack.imgur.com/Ly0gP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ly0gP.png" alt="image1"></a></p>
<p><a href="https://i.stack.imgur.com/oDe1i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oDe1i.png" alt="image2"></a></p>
<p>This is the effect I'm talking about.
I'd be grateful if somebody can tell me how to get that effect on my webpage.
It only appears under your cursor when you hover over the page.</p>
| 0debug
|
Javascript Value To PHP variable : javascript code
<script type="text/javascript">
$("#test").click(function() {
getQuerystring(this);
return false;
});
function getQuerystring(el) {
console.log(el.href);
var getUrlParameter = function(sParam) {
var sPageURL = el.href.split('?')[1],
sURLVariables = sPageURL.split('&'),
sParameterName;
for (var i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
}
};
var blog = getUrlParameter('c');
//document.getElementById('detail').innerHTML = blog;
document.cookie = "blog = " + blog;
}
</script>
html code
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div style="border: dashed; size: auto;">
<a name="divtest" href="#detail?c=active" id="test">testing</a>
</div>
<div id="detail" style="border: 2px; size: auto;">
<?php
$chk = $_COOKIE['blog'];
echo $chk;
?>
</div>
the javascript code should set the cookie. and then php get the values saved in the cookie. i basically wants to send value from javascript to php on same page. but it seems to be an error" Notice: Undefined index: blog in C:\wamp64\www\test\ajax.php on line 40".i hae searched alot but didnt find proper solution.kindly help me correcting my code. i will be thankful to you.
| 0debug
|
static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
{
VideoData *s = s1->priv_data;
AVStream *st;
int video_fd;
int desired_palette, desired_depth;
struct video_tuner tuner;
struct video_audio audio;
struct video_picture pict;
int j;
int vformat_num = FF_ARRAY_ELEMS(video_formats);
av_log(s1, AV_LOG_WARNING, "V4L input device is deprecated and will be removed in the next release.");
if (ap->time_base.den <= 0) {
av_log(s1, AV_LOG_ERROR, "Wrong time base (%d)\n", ap->time_base.den);
return -1;
}
s->time_base = ap->time_base;
s->video_win.width = ap->width;
s->video_win.height = ap->height;
st = avformat_new_stream(s1, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 1000000);
video_fd = open(s1->filename, O_RDWR);
if (video_fd < 0) {
av_log(s1, AV_LOG_ERROR, "%s: %s\n", s1->filename, strerror(errno));
goto fail;
}
if (ioctl(video_fd, VIDIOCGCAP, &s->video_cap) < 0) {
av_log(s1, AV_LOG_ERROR, "VIDIOCGCAP: %s\n", strerror(errno));
goto fail;
}
if (!(s->video_cap.type & VID_TYPE_CAPTURE)) {
av_log(s1, AV_LOG_ERROR, "Fatal: grab device does not handle capture\n");
goto fail;
}
if (s->video_win.width <= 0 || s->video_win.height <= 0) {
if (ioctl(video_fd, VIDIOCGWIN, &s->video_win, sizeof(s->video_win)) < 0) {
av_log(s1, AV_LOG_ERROR, "VIDIOCGWIN: %s\n", strerror(errno));
goto fail;
}
}
if(av_image_check_size(s->video_win.width, s->video_win.height, 0, s1) < 0)
return -1;
desired_palette = -1;
desired_depth = -1;
for (j = 0; j < vformat_num; j++) {
if (ap->pix_fmt == video_formats[j].pix_fmt) {
desired_palette = video_formats[j].palette;
desired_depth = video_formats[j].depth;
break;
}
}
if (!ioctl(video_fd, VIDIOCGTUNER, &tuner)) {
tuner.mode = s->standard;
ioctl(video_fd, VIDIOCSTUNER, &tuner);
}
audio.audio = 0;
ioctl(video_fd, VIDIOCGAUDIO, &audio);
memcpy(&s->audio_saved, &audio, sizeof(audio));
audio.flags &= ~VIDEO_AUDIO_MUTE;
ioctl(video_fd, VIDIOCSAUDIO, &audio);
ioctl(video_fd, VIDIOCGPICT, &pict);
av_dlog(s1, "v4l: colour=%d hue=%d brightness=%d constrast=%d whiteness=%d\n",
pict.colour, pict.hue, pict.brightness, pict.contrast, pict.whiteness);
pict.palette = desired_palette;
pict.depth= desired_depth;
if (desired_palette == -1 || ioctl(video_fd, VIDIOCSPICT, &pict) < 0) {
for (j = 0; j < vformat_num; j++) {
pict.palette = video_formats[j].palette;
pict.depth = video_formats[j].depth;
if (-1 != ioctl(video_fd, VIDIOCSPICT, &pict))
break;
}
if (j >= vformat_num)
goto fail1;
}
if (ioctl(video_fd, VIDIOCGMBUF, &s->gb_buffers) < 0) {
int val;
s->video_win.x = 0;
s->video_win.y = 0;
s->video_win.chromakey = -1;
s->video_win.flags = 0;
if (ioctl(video_fd, VIDIOCSWIN, s->video_win) < 0) {
av_log(s1, AV_LOG_ERROR, "VIDIOCSWIN: %s\n", strerror(errno));
goto fail;
}
s->frame_format = pict.palette;
val = 1;
if (ioctl(video_fd, VIDIOCCAPTURE, &val) < 0) {
av_log(s1, AV_LOG_ERROR, "VIDIOCCAPTURE: %s\n", strerror(errno));
goto fail;
}
s->time_frame = av_gettime() * s->time_base.den / s->time_base.num;
s->use_mmap = 0;
} else {
s->video_buf = mmap(0, s->gb_buffers.size, PROT_READ|PROT_WRITE, MAP_SHARED, video_fd, 0);
if ((unsigned char*)-1 == s->video_buf) {
s->video_buf = mmap(0, s->gb_buffers.size, PROT_READ|PROT_WRITE, MAP_PRIVATE, video_fd, 0);
if ((unsigned char*)-1 == s->video_buf) {
av_log(s1, AV_LOG_ERROR, "mmap: %s\n", strerror(errno));
goto fail;
}
}
s->gb_frame = 0;
s->time_frame = av_gettime() * s->time_base.den / s->time_base.num;
s->gb_buf.frame = s->gb_frame % s->gb_buffers.frames;
s->gb_buf.height = s->video_win.height;
s->gb_buf.width = s->video_win.width;
s->gb_buf.format = pict.palette;
if (ioctl(video_fd, VIDIOCMCAPTURE, &s->gb_buf) < 0) {
if (errno != EAGAIN) {
fail1:
av_log(s1, AV_LOG_ERROR, "VIDIOCMCAPTURE: %s\n", strerror(errno));
} else {
av_log(s1, AV_LOG_ERROR, "Fatal: grab device does not receive any video signal\n");
}
goto fail;
}
for (j = 1; j < s->gb_buffers.frames; j++) {
s->gb_buf.frame = j;
ioctl(video_fd, VIDIOCMCAPTURE, &s->gb_buf);
}
s->frame_format = s->gb_buf.format;
s->use_mmap = 1;
}
for (j = 0; j < vformat_num; j++) {
if (s->frame_format == video_formats[j].palette) {
s->frame_size = s->video_win.width * s->video_win.height * video_formats[j].depth / 8;
st->codec->pix_fmt = video_formats[j].pix_fmt;
break;
}
}
if (j >= vformat_num)
goto fail;
s->fd = video_fd;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codec->width = s->video_win.width;
st->codec->height = s->video_win.height;
st->codec->time_base = s->time_base;
st->codec->bit_rate = s->frame_size * 1/av_q2d(st->codec->time_base) * 8;
return 0;
fail:
if (video_fd >= 0)
close(video_fd);
return AVERROR(EIO);
}
| 1threat
|
How to prevent a DynamoDB item being overwritten if an entry already exists : <p>Im trying to write a lambda function to add new data to a DynamoDB Table.
From reading the docs at: </p>
<p><a href="http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#put-property" rel="noreferrer">http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#put-property</a>
The PUT method: "Creates a new item, or replaces an old item with a new item by delegating to AWS.DynamoDB.putItem()."</p>
<p>Other than doing a check for an object before 'putting' is there a setting or flag to fail the object exists when the PUT is attempted?</p>
<p>I can see in </p>
<pre><code>params -> Expected -> Exists (Bool)
</code></pre>
<p>but can't see any documentation on what this does. </p>
<p>What would be the best architecture (or fasted) to prevent an item overwrite? </p>
<pre><code>Query the table first and if no item exists then add the item
</code></pre>
<p>or</p>
<pre><code>Attempt to insert the item and on failure because of duplicate entry report this back? (Is there a way to prevent item overwrite?)
</code></pre>
| 0debug
|
void hmp_change(Monitor *mon, const QDict *qdict)
{
const char *device = qdict_get_str(qdict, "device");
const char *target = qdict_get_str(qdict, "target");
const char *arg = qdict_get_try_str(qdict, "arg");
Error *err = NULL;
if (strcmp(device, "vnc") == 0 &&
(strcmp(target, "passwd") == 0 ||
strcmp(target, "password") == 0)) {
if (!arg) {
monitor_read_password(mon, hmp_change_read_arg, NULL);
return;
}
}
qmp_change(device, target, !!arg, arg, &err);
if (error_is_type(err, QERR_DEVICE_ENCRYPTED)) {
monitor_printf(mon, "%s (%s) is encrypted.\n",
error_get_field(err, "device"),
error_get_field(err, "filename"));
if (!monitor_get_rs(mon)) {
monitor_printf(mon,
"terminal does not support password prompting\n");
error_free(err);
return;
}
readline_start(monitor_get_rs(mon), "Password: ", 1,
cb_hmp_change_bdrv_pwd, err);
return;
}
hmp_handle_error(mon, &err);
}
| 1threat
|
static void test_visitor_in_null(TestInputVisitorData *data,
const void *unused)
{
Visitor *v;
Error *err = NULL;
char *tmp;
v = visitor_input_test_init(data, "{ 'a': null, 'b': '' }");
visit_start_struct(v, NULL, NULL, 0, &error_abort);
visit_type_null(v, "a", &error_abort);
visit_type_str(v, "a", &tmp, &err);
g_assert(!tmp);
error_free_or_abort(&err);
visit_type_null(v, "b", &err);
error_free_or_abort(&err);
visit_check_struct(v, &error_abort);
visit_end_struct(v, NULL);
}
| 1threat
|
Capture Downloads in the Network Tab of Google Chrome Developer Tools : <p>The Network tab in the Google Chrome Developer Tools window shows almost all http requests made, but does not seem to capture anything when the http request results in a file being downloaded.</p>
<p>How can I capture download requests in Google Chrome?</p>
| 0debug
|
int dyngen_code(TCGContext *s, uint8_t *gen_code_buf)
{
#ifdef CONFIG_PROFILER
{
extern int64_t dyngen_op_count;
extern int dyngen_op_count_max;
int n;
n = (gen_opc_ptr - gen_opc_buf);
dyngen_op_count += n;
if (n > dyngen_op_count_max)
dyngen_op_count_max = n;
}
#endif
tcg_gen_code_common(s, gen_code_buf, 0, NULL);
flush_icache_range((unsigned long)gen_code_buf,
(unsigned long)s->code_ptr);
return s->code_ptr - gen_code_buf;
}
| 1threat
|
How do I get the pointer to the first item in a vector for qsort's first argument? : <p>I know that to get the pointer to the first element of a vector, you can do:</p>
<pre><code>&myvector[0];
//or
&myvector.front();
</code></pre>
<p>I want to use the pointer above to insert it as the first argument for <a href="http://www.cplusplus.com/reference/cstdlib/qsort/" rel="nofollow noreferrer"><code>qsort</code></a>. The problem is, when I do this:</p>
<pre><code>qsort(graph->&edge[0], ..., ..., myComparatorFunction);
</code></pre>
<p>I get this error <code>expected unqualified-id before '&' token</code>. The <code>graph</code> refers to an instance of a self-made class below:</p>
<pre><code>class Graph {
public:
int V, E;
vector<Edge> edge;
};
</code></pre>
<p>The instance is created using:</p>
<pre><code>Graph* createGraph(vector<Edge> edge) {
Graph* graph = new Graph;
graph->edge = edge;
return graph;
}
</code></pre>
<p>How do I get rid of the error while achieving what I want?</p>
| 0debug
|
What type of casting is this? : <p>I'm new in OOP and I'm quite puzzled in casting. Please check the code and declaration below for your reference.</p>
<p><a href="https://i.stack.imgur.com/u4UJc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u4UJc.png" alt="enter image description here"></a></p>
<p>Then I declared this:</p>
<pre><code>Person[] people = new Person[10];
people[0] = new Learner("John"); // what type of casting is this?
</code></pre>
| 0debug
|
static void rc4030_dma_tt_update(rc4030State *s, uint32_t new_tl_base,
uint32_t new_tl_limit)
{
int entries, i;
dma_pagetable_entry *dma_tl_contents;
if (s->dma_tl_limit) {
memory_region_del_subregion(get_system_memory(), &s->dma_tt_alias);
cpu_physical_memory_write(s->dma_tl_limit & 0x7fffffff,
memory_region_get_ram_ptr(&s->dma_tt),
memory_region_size(&s->dma_tt_alias));
}
object_unparent(OBJECT(&s->dma_tt_alias));
s->dma_tl_base = new_tl_base;
s->dma_tl_limit = new_tl_limit;
new_tl_base &= 0x7fffffff;
if (s->dma_tl_limit) {
uint64_t dma_tt_size;
if (s->dma_tl_limit <= memory_region_size(&s->dma_tt)) {
dma_tt_size = s->dma_tl_limit;
} else {
dma_tt_size = memory_region_size(&s->dma_tt);
}
memory_region_init_alias(&s->dma_tt_alias, OBJECT(s),
"dma-table-alias",
&s->dma_tt, 0, dma_tt_size);
dma_tl_contents = memory_region_get_ram_ptr(&s->dma_tt);
cpu_physical_memory_read(new_tl_base, dma_tl_contents, dma_tt_size);
memory_region_transaction_begin();
entries = dma_tt_size / sizeof(dma_pagetable_entry);
for (i = 0; i < entries; i++) {
rc4030_dma_as_update_one(s, i, dma_tl_contents[i].frame);
}
memory_region_add_subregion(get_system_memory(), new_tl_base,
&s->dma_tt_alias);
memory_region_transaction_commit();
} else {
memory_region_init(&s->dma_tt_alias, OBJECT(s),
"dma-table-alias", 0);
}
}
| 1threat
|
static int aac_decode_er_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, GetBitContext *gb)
{
AACContext *ac = avctx->priv_data;
const MPEG4AudioConfig *const m4ac = &ac->oc[1].m4ac;
ChannelElement *che;
int err, i;
int samples = m4ac->frame_length_short ? 960 : 1024;
int chan_config = m4ac->chan_config;
int aot = m4ac->object_type;
if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD)
samples >>= 1;
ac->frame = data;
if ((err = frame_configure_elements(avctx)) < 0)
return err;
ac->avctx->profile = aot - 1;
ac->tags_mapped = 0;
if (chan_config < 0 || (chan_config >= 8 && chan_config < 11) || chan_config >= 13) {
avpriv_request_sample(avctx, "Unknown ER channel configuration %d",
chan_config);
return AVERROR_INVALIDDATA;
}
for (i = 0; i < tags_per_config[chan_config]; i++) {
const int elem_type = aac_channel_layout_map[chan_config-1][i][0];
const int elem_id = aac_channel_layout_map[chan_config-1][i][1];
if (!(che=get_che(ac, elem_type, elem_id))) {
av_log(ac->avctx, AV_LOG_ERROR,
"channel element %d.%d is not allocated\n",
elem_type, elem_id);
return AVERROR_INVALIDDATA;
}
che->present = 1;
if (aot != AOT_ER_AAC_ELD)
skip_bits(gb, 4);
switch (elem_type) {
case TYPE_SCE:
err = decode_ics(ac, &che->ch[0], gb, 0, 0);
break;
case TYPE_CPE:
err = decode_cpe(ac, gb, che);
break;
case TYPE_LFE:
err = decode_ics(ac, &che->ch[0], gb, 0, 0);
break;
}
if (err < 0)
return err;
}
spectral_to_sample(ac);
ac->frame->nb_samples = samples;
ac->frame->sample_rate = avctx->sample_rate;
*got_frame_ptr = 1;
skip_bits_long(gb, get_bits_left(gb));
return 0;
}
| 1threat
|
How do I fix this overflow problem without setting any height? : <p>I have been working on this interface for few days using bootstrap4 and I cant get this one div to get a scrollbar without setting height in px's. Also a guide toward managing one page design?
Following is the link to the HTML code.</p>
<p><a href="https://www.codeply.com/p/xm4bUOWFVh" rel="nofollow noreferrer">https://www.codeply.com/p/xm4bUOWFVh</a></p>
| 0debug
|
Difference between ArrayList<String>() and mutableListOf<String>() in Kotlin : <pre><code>private val repositories = mutableListOf<String>()
private val repositories = ArrayList<String>()
</code></pre>
<p>Both are mutable list, then what is the point of two keywords <code>mutableListOf</code> or <code>ArrayList</code>?</p>
<p>or is there any major difference? </p>
| 0debug
|
How to generate JaxB-Classes with java.util.Optional? : <p>I use the jaxb2-maven-plugin to generate JaxB-Classes from a given XSD.
It works fine.
But now I want to use java.util.Optional in the generated Classes. But JaxB generated the Classes without the Optionals. So I'm forced to make a Null-Check of every Variable.</p>
<p>Did anybody know how the jaxb2-maven-plugin has to be configured to use the java.util.Optional?</p>
<p>Thanks for you help!</p>
| 0debug
|
updating Dictonary code with ConcurrentDictonary : I'm trying to update the following code to use a ConcurrentDictionary. I appreciate any help.
<pre><code>
private Dictionary (string, SymbolOrderBook) books = new Dictionary(string, SymbolOrderBook)();
SymbolOrderBook book;
lock (books)
{
if (!books.TryGetValue(symbol, out book))
{
book = new SymbolOrderBook(symbol);
books.Add(symbol, book);
}
}
</code></pre>
Thank you!
| 0debug
|
See cron output via docker logs, without using an extra file : <p>I am running "cron" in a docker container. <br>
Every day a script is executed. <br>
The output of this script I would like to see via "docker logs " <br></p>
<p>The process with PID 0 is the cron daemon in my container. Entrypoint starts cron in foreground:</p>
<pre><code>/usr/sbin/crond -f
</code></pre>
<p>I understand, that I could redirect the script output to a file "path/to/logs"</p>
<pre><code>07 2 * * * /data/docker/backup_webserver/backupscript.sh >> path/to/logs
</code></pre>
<p>and start the container as following to see the logs</p>
<pre><code>"tail -f path/to/logs"
</code></pre>
<p>But then the file "path/to/logs" would grow during the runtime of the container. <br>
<strong>Is there a possibility to log from crontab, directly to "docker logs" ?</strong></p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.