problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Input/output operations per second of an application in Windows : <p>I need the Input/output operations per second information of an application. Is there a way to monitor Input/output operations per second of an application ?</p>
| 0debug
|
do_socket_read(GIOChannel *source,
GIOCondition condition,
gpointer data)
{
int rv;
int dwSendLength;
int dwRecvLength;
uint8_t pbRecvBuffer[APDUBufSize];
static uint8_t pbSendBuffer[APDUBufSize];
VReaderStatus reader_status;
VReader *reader = NULL;
static VSCMsgHeader mhHeader;
VSCMsgError *error_msg;
GError *err = NULL;
static gchar *buf;
static gsize br, to_read;
static int state = STATE_HEADER;
if (state == STATE_HEADER && to_read == 0) {
buf = (gchar *)&mhHeader;
to_read = sizeof(mhHeader);
}
if (to_read > 0) {
g_io_channel_read_chars(source, (gchar *)buf, to_read, &br, &err);
if (err != NULL) {
g_error("error while reading: %s", err->message);
}
buf += br;
to_read -= br;
if (to_read != 0) {
return TRUE;
}
}
if (state == STATE_HEADER) {
mhHeader.type = ntohl(mhHeader.type);
mhHeader.reader_id = ntohl(mhHeader.reader_id);
mhHeader.length = ntohl(mhHeader.length);
if (verbose) {
printf("Header: type=%d, reader_id=%u length=%d (0x%x)\n",
mhHeader.type, mhHeader.reader_id, mhHeader.length,
mhHeader.length);
}
switch (mhHeader.type) {
case VSC_APDU:
case VSC_Flush:
case VSC_Error:
case VSC_Init:
buf = (gchar *)pbSendBuffer;
to_read = mhHeader.length;
state = STATE_MESSAGE;
return TRUE;
default:
fprintf(stderr, "Unexpected message of type 0x%X\n", mhHeader.type);
return FALSE;
}
}
if (state == STATE_MESSAGE) {
switch (mhHeader.type) {
case VSC_APDU:
if (verbose) {
printf(" recv APDU: ");
print_byte_array(pbSendBuffer, mhHeader.length);
}
dwSendLength = mhHeader.length;
dwRecvLength = sizeof(pbRecvBuffer);
reader = vreader_get_reader_by_id(mhHeader.reader_id);
reader_status = vreader_xfr_bytes(reader,
pbSendBuffer, dwSendLength,
pbRecvBuffer, &dwRecvLength);
if (reader_status == VREADER_OK) {
mhHeader.length = dwRecvLength;
if (verbose) {
printf(" send response: ");
print_byte_array(pbRecvBuffer, mhHeader.length);
}
send_msg(VSC_APDU, mhHeader.reader_id,
pbRecvBuffer, dwRecvLength);
} else {
rv = reader_status;
send_msg(VSC_Error, mhHeader.reader_id, &rv, sizeof(uint32_t));
}
vreader_free(reader);
reader = NULL;
break;
case VSC_Flush:
send_msg(VSC_FlushComplete, mhHeader.reader_id, NULL, 0);
break;
case VSC_Error:
error_msg = (VSCMsgError *) pbSendBuffer;
if (error_msg->code == VSC_SUCCESS) {
qemu_mutex_lock(&pending_reader_lock);
if (pending_reader) {
vreader_set_id(pending_reader, mhHeader.reader_id);
vreader_free(pending_reader);
pending_reader = NULL;
qemu_cond_signal(&pending_reader_condition);
}
qemu_mutex_unlock(&pending_reader_lock);
break;
}
printf("warning: qemu refused to add reader\n");
if (error_msg->code == VSC_CANNOT_ADD_MORE_READERS) {
qemu_mutex_lock(&pending_reader_lock);
if (pending_reader) {
pending_reader = NULL;
qemu_cond_signal(&pending_reader_condition);
}
qemu_mutex_unlock(&pending_reader_lock);
}
break;
case VSC_Init:
if (on_host_init(&mhHeader, (VSCMsgInit *)pbSendBuffer) < 0) {
return FALSE;
}
break;
default:
g_assert_not_reached();
return FALSE;
}
state = STATE_HEADER;
}
return TRUE;
}
| 1threat
|
returning from method when spawned thread is ready in c++ : I am new to thread related concepts.I have program with main function where I call function a() that spawns a thread(NewThread) using boost.now as part of thread i do some initialization of some variable and then start a while(1) loop.
I want give the control to function b() when control reaches inside while(1),
currently it is reaching to b() without starting while loop.
Please guide me.
void NewThread()
{
//initialization of some modules
//infinite while loop
while(1)
{
}
}
void a()
{
this->libThread = new boost::thread(boost::bind(&NewThread));
}
void b()
{
cout<<"function b";
}
int main()
{
a();
b();
}
| 0debug
|
Starting Node.js Thread Pool for Parallelism : <p>Yes hello. I recently came to learn that Node.js is single-threaded. I would like to use my application faster (MongoDB/Express app) so I have written the following script (I want it to use 8 processors)</p>
<pre><code>#!/bin/bash
node app.js &
node app.js &
node app.js &
node app.js &
node app.js &
node app.js &
node app.js &
node app.js &
</code></pre>
<p>When I try to run the script, I get many errors about ports being used, but I know that TCP allows for 65536 ports and it should only try to use 8. Do I need to update my Node.js to a new version?</p>
<p>I am running on Amazon Linux.</p>
<p>Thank you.</p>
| 0debug
|
How to use AVCapturePhotoOutput : <p>I have been working on using a custom camera, and I recently upgraded to Xcode 8 beta along with Swift 3. I originally had this:</p>
<pre><code>var stillImageOutput: AVCaptureStillImageOutput?
</code></pre>
<p>However, I am now getting the warning:</p>
<blockquote>
<p>'AVCaptureStillImageOutput' was deprecated in iOS 10.0: Use AVCapturePhotoOutput instead</p>
</blockquote>
<p>As this is fairly new, I have not seen much information on this. Here is my current code:</p>
<pre><code>var captureSession: AVCaptureSession?
var stillImageOutput: AVCaptureStillImageOutput?
var previewLayer: AVCaptureVideoPreviewLayer?
func clickPicture() {
if let videoConnection = stillImageOutput?.connection(withMediaType: AVMediaTypeVideo) {
videoConnection.videoOrientation = .portrait
stillImageOutput?.captureStillImageAsynchronously(from: videoConnection, completionHandler: { (sampleBuffer, error) -> Void in
if sampleBuffer != nil {
let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sampleBuffer)
let dataProvider = CGDataProvider(data: imageData!)
let cgImageRef = CGImage(jpegDataProviderSource: dataProvider!, decode: nil, shouldInterpolate: true, intent: .defaultIntent)
let image = UIImage(cgImage: cgImageRef!, scale: 1, orientation: .right)
}
})
}
}
</code></pre>
<p>I have tried to look at <code>AVCapturePhotoCaptureDelegate</code>, but I am not quite sure how to use it. Does anybody know how to use this? Thanks.</p>
| 0debug
|
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
| 1threat
|
swift background image for all viewcontrollers : i would like to swift background image for all viewcontrollers,
please kind help to adv. how to do it. the below code is work for a single viewcontroller.
let backgroundImage = UIImageView(frame: UIScreen.main.bounds)
backgroundImage.image = UIImage(named: "bg_name.png")
backgroundImage.contentMode = UIViewContentMode.scaleAspectFill
self.view.insertSubview(backgroundImage, at: 0)
| 0debug
|
Design Patterns - Adapter pattern vs Decorator Pattern? : <p>I have been reading about design patterns and this got me curious:</p>
<p>Decorator Pattern says wrap an original object and add additional features in the wrapper object. So structurally speaking - Wrappers follow decorator pattern.</p>
<p>Adapter pattern says changing one object by creating an instance of it and adding functionalities to it. These functionalities do not match those of the original object so we have to modify them, but we may also add our own extra methods which are not a part of the original object.</p>
<p>In this regard, what is the difference between Adapter and Decorator design pattern?</p>
| 0debug
|
Need a SQL query to get data from sql database for a given period with certain condition : I have sql database namely sales.dbo with 7 columns. First column contains different sales person names, on column 2 to 6 other information, on column 7,sales average. What i need is a query to get all sales person details(all seven columns in excel) if their sales average is more than 60 % between a given date. For example:
In my database, i have data from 01/05/2016 to 31/05/2016, if i enter a period in my excel sheet between 25/05/2016 to 31/05/2016 and my required average for ex.60% (should be changed as per my need), then i need all the sales person details who continuously have sales average of more than 60% between 25 to 31st May 2016.
If a sales man average was dropped below 60 % on 28th May , then i don't want to see him on my report.In simple words, i need all sales person who continuously hitting 60 % or more on average sales within my search period.
Thanks in Advance.
| 0debug
|
Find max value from Array of Structs : The Array:
let a = [(x:5,y:9),(x:1,y:4),(x:4,y:3),(x:2,y:5),(x:6,y:8)]
I want to get the max of y from the array.
print : 9
| 0debug
|
struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem,
unsigned long sdram_size,
const char *core)
{
struct omap_mpu_state_s *s = g_new0(struct omap_mpu_state_s, 1);
qemu_irq dma_irqs[4];
DriveInfo *dinfo;
int i;
SysBusDevice *busdev;
struct omap_target_agent_s *ta;
s->mpu_model = omap2420;
s->cpu = cpu_arm_init(core ?: "arm1136-r2");
if (s->cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
s->sdram_size = sdram_size;
s->sram_size = OMAP242X_SRAM_SIZE;
s->wakeup = qemu_allocate_irq(omap_mpu_wakeup, s, 0);
omap_clk_init(s);
memory_region_allocate_system_memory(&s->sdram, NULL, "omap2.dram",
s->sdram_size);
memory_region_add_subregion(sysmem, OMAP2_Q2_BASE, &s->sdram);
memory_region_init_ram(&s->sram, NULL, "omap2.sram", s->sram_size,
&error_abort);
vmstate_register_ram_global(&s->sram);
memory_region_add_subregion(sysmem, OMAP2_SRAM_BASE, &s->sram);
s->l4 = omap_l4_init(sysmem, OMAP2_L4_BASE, 54);
s->ih[0] = qdev_create(NULL, "omap2-intc");
qdev_prop_set_uint8(s->ih[0], "revision", 0x21);
qdev_prop_set_ptr(s->ih[0], "fclk", omap_findclk(s, "mpu_intc_fclk"));
qdev_prop_set_ptr(s->ih[0], "iclk", omap_findclk(s, "mpu_intc_iclk"));
qdev_init_nofail(s->ih[0]);
busdev = SYS_BUS_DEVICE(s->ih[0]);
sysbus_connect_irq(busdev, 0,
qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ));
sysbus_connect_irq(busdev, 1,
qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_FIQ));
sysbus_mmio_map(busdev, 0, 0x480fe000);
s->prcm = omap_prcm_init(omap_l4tao(s->l4, 3),
qdev_get_gpio_in(s->ih[0],
OMAP_INT_24XX_PRCM_MPU_IRQ),
NULL, NULL, s);
s->sysc = omap_sysctl_init(omap_l4tao(s->l4, 1),
omap_findclk(s, "omapctrl_iclk"), s);
for (i = 0; i < 4; i++) {
dma_irqs[i] = qdev_get_gpio_in(s->ih[omap2_dma_irq_map[i].ih],
omap2_dma_irq_map[i].intr);
}
s->dma = omap_dma4_init(0x48056000, dma_irqs, sysmem, s, 256, 32,
omap_findclk(s, "sdma_iclk"),
omap_findclk(s, "sdma_fclk"));
s->port->addr_valid = omap2_validate_addr;
soc_dma_port_add_mem(s->dma, memory_region_get_ram_ptr(&s->sdram),
OMAP2_Q2_BASE, s->sdram_size);
soc_dma_port_add_mem(s->dma, memory_region_get_ram_ptr(&s->sram),
OMAP2_SRAM_BASE, s->sram_size);
s->uart[0] = omap2_uart_init(sysmem, omap_l4ta(s->l4, 19),
qdev_get_gpio_in(s->ih[0],
OMAP_INT_24XX_UART1_IRQ),
omap_findclk(s, "uart1_fclk"),
omap_findclk(s, "uart1_iclk"),
s->drq[OMAP24XX_DMA_UART1_TX],
s->drq[OMAP24XX_DMA_UART1_RX],
"uart1",
serial_hds[0]);
s->uart[1] = omap2_uart_init(sysmem, omap_l4ta(s->l4, 20),
qdev_get_gpio_in(s->ih[0],
OMAP_INT_24XX_UART2_IRQ),
omap_findclk(s, "uart2_fclk"),
omap_findclk(s, "uart2_iclk"),
s->drq[OMAP24XX_DMA_UART2_TX],
s->drq[OMAP24XX_DMA_UART2_RX],
"uart2",
serial_hds[0] ? serial_hds[1] : NULL);
s->uart[2] = omap2_uart_init(sysmem, omap_l4ta(s->l4, 21),
qdev_get_gpio_in(s->ih[0],
OMAP_INT_24XX_UART3_IRQ),
omap_findclk(s, "uart3_fclk"),
omap_findclk(s, "uart3_iclk"),
s->drq[OMAP24XX_DMA_UART3_TX],
s->drq[OMAP24XX_DMA_UART3_RX],
"uart3",
serial_hds[0] && serial_hds[1] ? serial_hds[2] : NULL);
s->gptimer[0] = omap_gp_timer_init(omap_l4ta(s->l4, 7),
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER1),
omap_findclk(s, "wu_gpt1_clk"),
omap_findclk(s, "wu_l4_iclk"));
s->gptimer[1] = omap_gp_timer_init(omap_l4ta(s->l4, 8),
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER2),
omap_findclk(s, "core_gpt2_clk"),
omap_findclk(s, "core_l4_iclk"));
s->gptimer[2] = omap_gp_timer_init(omap_l4ta(s->l4, 22),
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER3),
omap_findclk(s, "core_gpt3_clk"),
omap_findclk(s, "core_l4_iclk"));
s->gptimer[3] = omap_gp_timer_init(omap_l4ta(s->l4, 23),
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER4),
omap_findclk(s, "core_gpt4_clk"),
omap_findclk(s, "core_l4_iclk"));
s->gptimer[4] = omap_gp_timer_init(omap_l4ta(s->l4, 24),
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER5),
omap_findclk(s, "core_gpt5_clk"),
omap_findclk(s, "core_l4_iclk"));
s->gptimer[5] = omap_gp_timer_init(omap_l4ta(s->l4, 25),
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER6),
omap_findclk(s, "core_gpt6_clk"),
omap_findclk(s, "core_l4_iclk"));
s->gptimer[6] = omap_gp_timer_init(omap_l4ta(s->l4, 26),
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER7),
omap_findclk(s, "core_gpt7_clk"),
omap_findclk(s, "core_l4_iclk"));
s->gptimer[7] = omap_gp_timer_init(omap_l4ta(s->l4, 27),
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER8),
omap_findclk(s, "core_gpt8_clk"),
omap_findclk(s, "core_l4_iclk"));
s->gptimer[8] = omap_gp_timer_init(omap_l4ta(s->l4, 28),
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER9),
omap_findclk(s, "core_gpt9_clk"),
omap_findclk(s, "core_l4_iclk"));
s->gptimer[9] = omap_gp_timer_init(omap_l4ta(s->l4, 29),
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER10),
omap_findclk(s, "core_gpt10_clk"),
omap_findclk(s, "core_l4_iclk"));
s->gptimer[10] = omap_gp_timer_init(omap_l4ta(s->l4, 30),
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER11),
omap_findclk(s, "core_gpt11_clk"),
omap_findclk(s, "core_l4_iclk"));
s->gptimer[11] = omap_gp_timer_init(omap_l4ta(s->l4, 31),
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPTIMER12),
omap_findclk(s, "core_gpt12_clk"),
omap_findclk(s, "core_l4_iclk"));
omap_tap_init(omap_l4ta(s->l4, 2), s);
s->synctimer = omap_synctimer_init(omap_l4tao(s->l4, 2), s,
omap_findclk(s, "clk32-kHz"),
omap_findclk(s, "core_l4_iclk"));
s->i2c[0] = qdev_create(NULL, "omap_i2c");
qdev_prop_set_uint8(s->i2c[0], "revision", 0x34);
qdev_prop_set_ptr(s->i2c[0], "iclk", omap_findclk(s, "i2c1.iclk"));
qdev_prop_set_ptr(s->i2c[0], "fclk", omap_findclk(s, "i2c1.fclk"));
qdev_init_nofail(s->i2c[0]);
busdev = SYS_BUS_DEVICE(s->i2c[0]);
sysbus_connect_irq(busdev, 0,
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_I2C1_IRQ));
sysbus_connect_irq(busdev, 1, s->drq[OMAP24XX_DMA_I2C1_TX]);
sysbus_connect_irq(busdev, 2, s->drq[OMAP24XX_DMA_I2C1_RX]);
sysbus_mmio_map(busdev, 0, omap_l4_region_base(omap_l4tao(s->l4, 5), 0));
s->i2c[1] = qdev_create(NULL, "omap_i2c");
qdev_prop_set_uint8(s->i2c[1], "revision", 0x34);
qdev_prop_set_ptr(s->i2c[1], "iclk", omap_findclk(s, "i2c2.iclk"));
qdev_prop_set_ptr(s->i2c[1], "fclk", omap_findclk(s, "i2c2.fclk"));
qdev_init_nofail(s->i2c[1]);
busdev = SYS_BUS_DEVICE(s->i2c[1]);
sysbus_connect_irq(busdev, 0,
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_I2C2_IRQ));
sysbus_connect_irq(busdev, 1, s->drq[OMAP24XX_DMA_I2C2_TX]);
sysbus_connect_irq(busdev, 2, s->drq[OMAP24XX_DMA_I2C2_RX]);
sysbus_mmio_map(busdev, 0, omap_l4_region_base(omap_l4tao(s->l4, 6), 0));
s->gpio = qdev_create(NULL, "omap2-gpio");
qdev_prop_set_int32(s->gpio, "mpu_model", s->mpu_model);
qdev_prop_set_ptr(s->gpio, "iclk", omap_findclk(s, "gpio_iclk"));
qdev_prop_set_ptr(s->gpio, "fclk0", omap_findclk(s, "gpio1_dbclk"));
qdev_prop_set_ptr(s->gpio, "fclk1", omap_findclk(s, "gpio2_dbclk"));
qdev_prop_set_ptr(s->gpio, "fclk2", omap_findclk(s, "gpio3_dbclk"));
qdev_prop_set_ptr(s->gpio, "fclk3", omap_findclk(s, "gpio4_dbclk"));
if (s->mpu_model == omap2430) {
qdev_prop_set_ptr(s->gpio, "fclk4", omap_findclk(s, "gpio5_dbclk"));
}
qdev_init_nofail(s->gpio);
busdev = SYS_BUS_DEVICE(s->gpio);
sysbus_connect_irq(busdev, 0,
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPIO_BANK1));
sysbus_connect_irq(busdev, 3,
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPIO_BANK2));
sysbus_connect_irq(busdev, 6,
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPIO_BANK3));
sysbus_connect_irq(busdev, 9,
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPIO_BANK4));
if (s->mpu_model == omap2430) {
sysbus_connect_irq(busdev, 12,
qdev_get_gpio_in(s->ih[0],
OMAP_INT_243X_GPIO_BANK5));
}
ta = omap_l4ta(s->l4, 3);
sysbus_mmio_map(busdev, 0, omap_l4_region_base(ta, 1));
sysbus_mmio_map(busdev, 1, omap_l4_region_base(ta, 0));
sysbus_mmio_map(busdev, 2, omap_l4_region_base(ta, 2));
sysbus_mmio_map(busdev, 3, omap_l4_region_base(ta, 4));
sysbus_mmio_map(busdev, 4, omap_l4_region_base(ta, 5));
s->sdrc = omap_sdrc_init(sysmem, 0x68009000);
s->gpmc = omap_gpmc_init(s, 0x6800a000,
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_GPMC_IRQ),
s->drq[OMAP24XX_DMA_GPMC]);
dinfo = drive_get(IF_SD, 0, 0);
if (!dinfo) {
fprintf(stderr, "qemu: missing SecureDigital device\n");
exit(1);
}
s->mmc = omap2_mmc_init(omap_l4tao(s->l4, 9),
blk_by_legacy_dinfo(dinfo),
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_MMC_IRQ),
&s->drq[OMAP24XX_DMA_MMC1_TX],
omap_findclk(s, "mmc_fclk"), omap_findclk(s, "mmc_iclk"));
s->mcspi[0] = omap_mcspi_init(omap_l4ta(s->l4, 35), 4,
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_MCSPI1_IRQ),
&s->drq[OMAP24XX_DMA_SPI1_TX0],
omap_findclk(s, "spi1_fclk"),
omap_findclk(s, "spi1_iclk"));
s->mcspi[1] = omap_mcspi_init(omap_l4ta(s->l4, 36), 2,
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_MCSPI2_IRQ),
&s->drq[OMAP24XX_DMA_SPI2_TX0],
omap_findclk(s, "spi2_fclk"),
omap_findclk(s, "spi2_iclk"));
s->dss = omap_dss_init(omap_l4ta(s->l4, 10), sysmem, 0x68000800,
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_DSS_IRQ),
s->drq[OMAP24XX_DMA_DSS],
omap_findclk(s, "dss_clk1"), omap_findclk(s, "dss_clk2"),
omap_findclk(s, "dss_54m_clk"),
omap_findclk(s, "dss_l3_iclk"),
omap_findclk(s, "dss_l4_iclk"));
omap_sti_init(omap_l4ta(s->l4, 18), sysmem, 0x54000000,
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_STI),
omap_findclk(s, "emul_ck"),
serial_hds[0] && serial_hds[1] && serial_hds[2] ?
serial_hds[3] : NULL);
s->eac = omap_eac_init(omap_l4ta(s->l4, 32),
qdev_get_gpio_in(s->ih[0], OMAP_INT_24XX_EAC_IRQ),
&s->drq[OMAP24XX_DMA_EAC_AC_RD],
omap_findclk(s, "func_96m_clk"),
omap_findclk(s, "core_l4_iclk"));
qemu_register_reset(omap2_mpu_reset, s);
return s;
}
| 1threat
|
Wbsite refresh with php or JS : <p>how can I refresh my PHP website so that my time (time in seconds) will update constantly without a reloading animation/screen?
I tried a bit but with these codes I always had a reload animation!
(Reload animation = short white screen on reloading a page)</p>
| 0debug
|
void qdev_property_add_legacy(DeviceState *dev, Property *prop,
Error **errp)
{
gchar *type;
type = g_strdup_printf("legacy<%s>", prop->info->name);
qdev_property_add(dev, prop->name, type,
qdev_get_legacy_property,
qdev_set_legacy_property,
NULL,
prop, errp);
g_free(type);
}
| 1threat
|
static int usb_net_handle_data(USBDevice *dev, USBPacket *p)
{
USBNetState *s = (USBNetState *) dev;
int ret = 0;
switch(p->pid) {
case USB_TOKEN_IN:
switch (p->devep) {
case 1:
ret = usb_net_handle_statusin(s, p);
break;
case 2:
ret = usb_net_handle_datain(s, p);
break;
default:
goto fail;
}
break;
case USB_TOKEN_OUT:
switch (p->devep) {
case 2:
ret = usb_net_handle_dataout(s, p);
break;
default:
goto fail;
}
break;
default:
fail:
ret = USB_RET_STALL;
break;
}
if (ret == USB_RET_STALL)
fprintf(stderr, "usbnet: failed data transaction: "
"pid 0x%x ep 0x%x len 0x%x\n",
p->pid, p->devep, p->len);
return ret;
}
| 1threat
|
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
| 1threat
|
static int vhost_client_sync_dirty_bitmap(CPUPhysMemoryClient *client,
target_phys_addr_t start_addr,
target_phys_addr_t end_addr)
{
struct vhost_dev *dev = container_of(client, struct vhost_dev, client);
int i;
if (!dev->log_enabled || !dev->started) {
return 0;
}
for (i = 0; i < dev->mem->nregions; ++i) {
struct vhost_memory_region *reg = dev->mem->regions + i;
vhost_dev_sync_region(dev, start_addr, end_addr,
reg->guest_phys_addr,
range_get_last(reg->guest_phys_addr,
reg->memory_size));
}
for (i = 0; i < dev->nvqs; ++i) {
struct vhost_virtqueue *vq = dev->vqs + i;
vhost_dev_sync_region(dev, start_addr, end_addr, vq->used_phys,
range_get_last(vq->used_phys, vq->used_size));
}
return 0;
}
| 1threat
|
Allowed memory size of 134217728 bytes exhausted (tried to allocate 42 bytes) : <p>I am retrieving record from mysql table which return more than 0.2m number of rows per query, which obviously take lot of memory. in my case i have 8 GBs installed RAM on my system with SSD 256 GBs.
When i execute my page it returns the following error:</p>
<pre><code>Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 42 bytes) in D:\xampp\htdocs\classes\CRUD.php on line 84
</code></pre>
<p>I think i should need to use threading instead of php loops over table rows?
Maybe i am wrong. Any suggestion/help will be appreciated. </p>
| 0debug
|
static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **dst)
{
av_freep(dst);
*dst = av_strdup(val);
return 0;
}
| 1threat
|
conert R code into matlab : I would like to convert this code from R into matlab.
this aimed to perform a calculations of regression parameters a detrended cross correlation analysis.
there is a way to do it automatically, or we should do it line by line.
This analysis should be performed on tiem series.
x and y denotes two time series with same length.
require(tseries)
require(fracdiff)
require(matrixStats)
DCCA_beta_avg<-function(y,x,smin,smax,step){
XTX<-var(x)*(length(x)-1)
betas<-rep(0,(smax-smin)/step+1)
for(s in seq(smin,smax,by=step)){
betas[(s-smin)/step+1]<-DCCA_beta_sides(y,x,s)
}
DCCA_beta<-mean(betas)
DCCA_res<-(y-DCCA_beta*x)-mean(y-DCCA_beta*x)
DCCA_sigma2<-sum(DCCA_res^2)/(length(DCCA_res)-2)
DCCA_SE<-sqrt(DCCA_sigma2/XTX)
DCCA_R2<-1-var(DCCA_res)/var(y)
OLS_beta<-lm(y~x)$coefficients[2]
OLS_res<-(y-OLS_beta*x)-mean(y-OLS_beta*x)
OLS_sigma2<-sum(OLS_res^2)/(length(OLS_res)-2)
OLS_SE<-sqrt(OLS_sigma2/XTX)
OLS_R2<-1-var(OLS_res)/var(y)
return(c(OLS_beta,OLS_SE,OLS_R2,DCCA_beta,DCCA_SE,DCCA_R2))
}
DCCA_beta<-DCCdccafunction(y,x,s){
xx<-cumsum(x-mean(x))
yy<-cumsum(y-mean(y))
t<-1:length(xx)
F2sj_xy<-runif(floor(length(xx)/s))
F2sj_xx<-F2sj_xy
for(ss in seq(1,(floor(length(xx)/s)*s),by=s)){
F2sj_xy[(ss-1)/s+1]<-sum((summary(lm(xx[ss:(ss+s-1)]~t[ss:(ss+s-1)]))$residuals)*(summary(lm(yy[ss:(ss+s-1)]~t[ss:(ss+s-1)]))$residuals))/(s-1)
F2sj_xx[(ss-1)/s+1]<-sum((summary(lm(xx[ss:(ss+s-1)]~t[ss:(ss+s-1)]))$residuals)*(summary(lm(xx[ss:(ss+s-1)]~t[ss:(ss+s-1)]))$residuals))/(s-1)
}
beta<-mean(F2sj_xy)/mean(F2sj_xx)
return(beta)
}
DCCA_beta_F<-function(y,x,s){
xx<-cumsum(x-mean(x))
yy<-cumsum(y-mean(y))
t<-1:length(xx)
F2sj_xy<-runif(floor(length(xx)/s))
F2sj_xx<-F2sj_xy
F2sj_yy<-F2sj_xy
for(ss in seq(1,(floor(length(xx)/s)*s),by=s)){
F2sj_xy[(ss-1)/s+1]<-sum((summary(lm(xx[ss:(ss+s-1)]~t[ss:(ss+s-1)]))$residuals)*(summary(lm(yy[ss:(ss+s-1)]~t[ss:(ss+s-1)]))$residuals))/(s-1)
F2sj_xx[(ss-1)/s+1]<-sum((summary(lm(xx[ss:(ss+s-1)]~t[ss:(ss+s-1)]))$residuals)*(summary(lm(xx[ss:(ss+s-1)]~t[ss:(ss+s-1)]))$residuals))/(s-1)
F2sj_yy[(ss-1)/s+1]<-sum((summary(lm(yy[ss:(ss+s-1)]~t[ss:(ss+s-1)]))$residuals)*(summary(lm(yy[ss:(ss+s-1)]~t[ss:(ss+s-1)]))$residuals))/(s-1)
}
beta<-mean(F2sj_xy)/mean(F2sj_xx)
return(c(beta,mean(F2sj_xx),mean(F2sj_yy)))
#return(c(beta,sum(F2sj_xx),sum(F2sj_yy)))
}
DCCA_beta_SE<-function(y,x,s){
r<-DCCA_beta_F(y,x,s)
beta<-r[1]
yhat<-beta*x
alpha<-mean(y)-beta*mean(x)
res<-y-yhat
residuals<-res-mean(res)
resres<-cumsum(residuals-mean(residuals))
F2sj_res<-runif(floor(length(residuals)/s))
t<-1:length(resres)
for(ss in seq(1,(floor(length(residuals)/s)*s),by=s)){
F2sj_res[(ss-1)/s+1]<-sum((summary(lm(resres[ss:(ss+s-1)]~t[ss:(ss+s-1)]))$residuals)*(summary(lm(resres[ss:(ss+s-1)]~t[ss:(ss+s-1)]))$residuals))/(s-1)
}
#SE<-mean(residuals^2)/((length(residuals)-2)*r[2])
SE<-mean(F2sj_res)/((length(residuals)-2)*r[2])
SE_a<-(mean(F2sj_res)/r[2])*(sum(x^2)/(length(residuals)*(length(residuals)-2)))
R<-1-mean(F2sj_res)/(r[3])
return(c(alpha,sqrt(SE_a),beta,sqrt(SE),R))
}
DCCA_beta_SE_F<-function(y,x,s){
r<-DCCA_beta_F(y,x,s)
beta<-r[1]
yhat<-beta*x
alpha<-mean(y)-beta*mean(x)
res<-y-yhat
residuals<-res-mean(res)
res_R<-y-x
resres<-cumsum(residuals-mean(residuals))
resres_R<-cumsum(res_R)
F2sj_res<-runif(floor(length(residuals)/s))
F2sj_res_R<-runif(floor(length(res_R)/s))
t<-1:length(resres)
for(ss in seq(1,(floor(length(residuals)/s)*s),by=s)){
F2sj_res[(ss-1)/s+1]<-sum((summary(lm(resres[ss:(ss+s-1)]~t[ss:(ss+s-1)]))$residuals)*(summary(lm(resres[ss:(ss+s-1)]~t[ss:(ss+s-1)]))$residuals))/(s-1)
F2sj_res_R[(ss-1)/s+1]<-sum((summary(lm(resres_R[ss:(ss+s-1)]~t[ss:(ss+s-1)]))$residuals)*(summary(lm(resres_R[ss:(ss+s-1)]~t[ss:(ss+s-1)]))$residuals))/(s-1)
}
#SE<-mean(residuals^2)/((length(residuals)-2)*r[2])
#SE<-mean(F2sj_res)/((length(residuals)-2)*r[2])
#SE<-mean(F2sj_res)/((length(F2sj_res)-2)*r[2]) #controlling for uncertainty connected to scales (higher scales have higher uncertainty due to lower number of blocks)
SE<-mean(F2sj_res)/(ceiling(length(residuals)/s)*r[2]) #loosing d.f. due to fitting a and b in each box
#SE_a<-(mean(F2sj_res)/r[2])*(sum(x^2)/(length(residuals)*(length(residuals)-2)))
#SE_a<-(mean(F2sj_res)/r[2])*(sum(x^2)/(length(F2sj_res)*(length(F2sj_res)-2))) #controlling for uncertainty connected to scales (higher scales have higher uncertainty due to lower number of blocks)
SE_a<-(mean(F2sj_res)/r[2])*(sum(x^2)/(length(residuals)*ceiling(length(residuals)/s))) #loosing d.f. due to fitting a and b in each box
R<-1-mean(F2sj_res)/(r[3])
#SSR_U<-sum(residuals^2)
SSR_U<-sum(F2sj_res)
#SSR_R<-sum((y-x)^2) #specific null: alpha=0, beta=1
SSR_R<-sum(F2sj_res_R)
#F_stat<-((SSR_R-SSR_U)/(SSR_U))*((length(residuals)-2)/2)
#F_stat<-((SSR_R-SSR_U)/(SSR_U))*((length(F2sj_res)-2)/2) #controlling for uncertainty connected to scales (higher scales have higher uncertainty due to lower number of blocks)
F_stat<-((SSR_R-SSR_U)/(SSR_U))*(ceiling(length(residuals)/s)/2) #loosing d.f. due to fitting a and b in each box
F_p<-pf(F_stat,2,length(F2sj_res)-2,lower.tail=FALSE)
return(c(alpha,sqrt(SE_a),beta,sqrt(SE),R,F_stat,F_p))
}
DCCA_beta_s<-function(y,x,smin,smax,step){
results<-matrix(rep(0,6*((smax-smin)/step+1)),ncol=6)
for(s in seq(smin,smax,by=step)){
beta<-DCCA_beta_SE(y,x,s)
results[((s-smin)/step+1),1]<-s
results[((s-smin)/step+1),2]<-beta[1]
results[((s-smin)/step+1),3]<-beta[2]
results[((s-smin)/step+1),4]<-beta[3]
results[((s-smin)/step+1),5]<-beta[4]
results[((s-smin)/step+1),6]<-beta[5]
}
return(results)
}
DCCA_beta_s_F<-function(y,x,smin,smax,step){
results<-matrix(rep(0,10*((smax-smin)/step+2)),ncol=10)
for(s in seq(smin,smax,by=step)){
beta<-DCCA_beta_SE_F(y,x,s)
results[((s-smin)/step+1),1]<-s
results[((s-smin)/step+1),2]<-beta[1]
results[((s-smin)/step+1),3]<-beta[2]
results[((s-smin)/step+1),4]<-2*pnorm(abs(beta[1]/beta[2]),lower.tail=FALSE)#p-value for null=0
results[((s-smin)/step+1),5]<-beta[3]
results[((s-smin)/step+1),6]<-beta[4]
results[((s-smin)/step+1),7]<-2*pnorm(abs((beta[3]-1)/beta[4]),lower.tail=FALSE)#p-value for null=1
results[((s-smin)/step+1),8]<-beta[5]
results[((s-smin)/step+1),9]<-beta[6]
results[((s-smin)/step+1),10]<-beta[7]
}
#results[(smax-smin)/step+2,2]<-mean(results[1:(dim(results)[1]-1),2])#A
#results[(smax-smin)/step+2,5]<-mean(results[1:(dim(results)[1]-1),5])#B
results[(smax-smin)/step+2,2]<-sum(results[1:(dim(results)[1]-1),2]*results[1:(dim(results)[1]-1),8])/sum(results[1:(dim(results)[1]-1),8])#A as R2(s) weighted
results[(smax-smin)/step+2,5]<-sum(results[1:(dim(results)[1]-1),5]*results[1:(dim(results)[1]-1),8])/sum(results[1:(dim(results)[1]-1),8])#B as R2(s) weighted
results[(smax-smin)/step+2,3]<-sqrt((sum(x^2)/length(x))*sum((y-results[(smax-smin)/step+2,2]-results[(smax-smin)/step+2,5]*x)^2)/((length(y)-dim(results)[1]+1)*sum((x-mean(x))^2)))#SE_A
results[(smax-smin)/step+2,4]<-2*pnorm(abs(results[(smax-smin)/step+2,2]/results[(smax-smin)/step+2,3]),lower.tail=FALSE)#p-value for null=0
results[(smax-smin)/step+2,6]<-sqrt(sum((y-results[(smax-smin)/step+2,2]-results[(smax-smin)/step+2,5]*x)^2)/((length(y)-dim(results)[1]+1)*sum((x-mean(x))^2)))#SE_B
results[(smax-smin)/step+2,7]<-2*pnorm(abs((results[(smax-smin)/step+2,5]-1)/results[(smax-smin)/step+2,6]),lower.tail=FALSE)#p-value for null=1
results[(smax-smin)/step+2,8]<-1-sum((y-results[(smax-smin)/step+2,2]-results[(smax-smin)/step+2,5]*x)^2)/sum(y^2)#R2
results[(smax-smin)/step+2,9]<-((length(x)-2)/2)*((results[(smax-smin)/step+2,8]-(1-(sum((y-x)^2))/(sum((y-mean(y))^2))))/(1-results[(smax-smin)/step+2,8]))#F_test_R2_based
results[(smax-smin)/step+2,10]<-pf(results[(smax-smin)/step+2,9],2,length(y)-2,lower.tail=FALSE)#F_test p_val
return(results)
}
| 0debug
|
I am trying to install C compiler in RHEL6 without internet : <p>I have been trying to install basic softwares needed for making my linux machine into a development env. I got a machine with RHEL6, however it is not connected to the internet. I am able to connect to the lan and ssh to other machines. I tried to install using yum but failed with the following error.</p>
<pre><code>[root@******* pcre-8.38]#yum install gcc-c++
Loaded plugins: aliases, changelog, downloadonly, kabi, presto, product-id, refresh-packagekit, security, subscription-
: manager, tmprepo, verify, versionlock
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading support for Red Hat kernel ABI
https://www.softwarecollections.org/repos/rhscl/devtoolset-3/epel-6-x86_64/repodata/repomd.xml: [Errno 12] Timeout on https://www.softwarecollections.org/repos/rhscl/devtoolset-3/epel-6-x86_64/repodata/repomd.xml: (28, 'connect() timed out!')
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: rhscl-devtoolset-3-epel-6-x86_64. Please verify its path and try again.
</code></pre>
<p>Prior to this i installed an ngnix web server and tried to do a <em>make</em> but that failed with:</p>
<pre><code>...
checking windows.h presence... no
checking for windows.h... no
configure: error: You need a C++ compiler for C++ support.
make[1]: *** [/home/gunjaj/software/pcre-8.38/Makefile] Error 1
make[1]: Leaving directory `/home/gunjaj/software/nginx-1.8.1'
make: *** [build] Error 2
</code></pre>
<p>Any help is appreciated.</p>
<p>PS: This question is similar to another question <a href="https://stackoverflow.com/questions/13853507/how-to-install-c-compiler-for-gcc-without-internet-connection-rhel6">How to install C compiler for GCC without Internet connection? (RHEL6)</a></p>
<p>but i have absolutely no way of getting internet right now.</p>
| 0debug
|
Non-exhaustive patterns in function in Haskell : <p>Im trying to write a function that takes in list of Cards and gives me back all the rank values. Im getting the problem of Non-exhaustive patterns in function and I can't fix it</p>
<pre><code>data Card = Card Suit Rank
deriving (Show, Bounded, Read)
data Suit = Red
| Black
deriving (Show, Enum, Bounded, Read)
data Rank = Ace
| Two
| Three
| Four
| Five
| Six
| Seven
| Eight
| Nine
| Ten
deriving (Show, Enum, Bounded, Read)
handValue :: [Card] -> [Int]
handValue [Card s r]
| (length [Card s r]) < 0 = (fromEnum (r) + 1) : handValue (tail [Card s r])
| otherwise = []
</code></pre>
<p>What Can I do to counter this problem?</p>
| 0debug
|
how to get the weight quatity from list in python? : i'm new to python ,so i'm confuse to get the regex pattern to find the corresponding weight from the product.
this is my code.
import re
string1 = [' (Expiry Date: 30 May 2019) 4 x Organic Infant Goat Milk Follow-on Formula 3 400g',' (Expiry on 30 May 2019) 4 x Organic Infant Goat Milk Follow-on Formula 2 400g '," [ Bellamy's ] Bellamys Organic Step 3 Toddler Milk Drink 900g x 6 tins Made In Australia CARTON DEAL EXPIRE 06/2019 to 2020",' [[1+1]] FRISO (2) 1.8kg+900g'," [[Carton Sales]] Bellamy's Organic Follow-On Formula Step 2 900g x 6tins",' Dumex Mamil Gold Stage 4 Growing Up Kid Milk Formula (850g) x 6',' Wyeth S-26 Promise Gold Stage 4 1.6kg X 6 Tins']
m = [re.search('([0-9.]+[kgG]{1,2})', s).group(0) for s in string1]
print m
the output is like this
['400g', '400g', '900g', '1.8kg', '900g', '850g', '1.6kg']
but i need to get this output
['4x400g', '4x400g', '900gx6', '1.8kg+900g', '900gx6', '850gx6', '1.6kgX6']
is there any way to get this.
| 0debug
|
Alternative for __dirname in node when using the --experimental-modules flag : <p>I use the flag <code>--experimental-modules</code> when running my node application in order to use ES6 modules.</p>
<p>However when I use this flag the metavariable <code>__dirname</code> is not available. Is there an alternative way to get the same string that is stored in <code>__dirname</code> that is compatible with this mode?</p>
| 0debug
|
def count_Primes_nums(n):
ctr = 0
for num in range(n):
if num <= 1:
continue
for i in range(2,num):
if (num % i) == 0:
break
else:
ctr += 1
return ctr
| 0debug
|
static int ff_estimate_motion_b(MpegEncContext * s,
int mb_x, int mb_y, int16_t (*mv_table)[2], Picture *picture, int f_code)
{
int mx, my, range, dmin;
int xmin, ymin, xmax, ymax;
int rel_xmin, rel_ymin, rel_xmax, rel_ymax;
int pred_x=0, pred_y=0;
int P[10][2];
const int shift= 1+s->quarter_sample;
const int mot_stride = s->mb_width + 2;
const int mot_xy = (mb_y + 1)*mot_stride + mb_x + 1;
uint8_t * const ref_picture= picture->data[0];
uint16_t * const mv_penalty= s->me.mv_penalty[f_code] + MAX_MV;
int mv_scale;
s->me.penalty_factor = get_penalty_factor(s, s->avctx->me_cmp);
s->me.sub_penalty_factor= get_penalty_factor(s, s->avctx->me_sub_cmp);
s->me.mb_penalty_factor = get_penalty_factor(s, s->avctx->mb_cmp);
get_limits(s, &range, &xmin, &ymin, &xmax, &ymax, f_code);
rel_xmin= xmin - mb_x*16;
rel_xmax= xmax - mb_x*16;
rel_ymin= ymin - mb_y*16;
rel_ymax= ymax - mb_y*16;
switch(s->me_method) {
case ME_ZERO:
default:
no_motion_search(s, &mx, &my);
dmin = 0;
mx-= mb_x*16;
my-= mb_y*16;
break;
case ME_FULL:
dmin = full_motion_search(s, &mx, &my, range, xmin, ymin, xmax, ymax, ref_picture);
mx-= mb_x*16;
my-= mb_y*16;
break;
case ME_LOG:
dmin = log_motion_search(s, &mx, &my, range / 2, xmin, ymin, xmax, ymax, ref_picture);
mx-= mb_x*16;
my-= mb_y*16;
break;
case ME_PHODS:
dmin = phods_motion_search(s, &mx, &my, range / 2, xmin, ymin, xmax, ymax, ref_picture);
mx-= mb_x*16;
my-= mb_y*16;
break;
case ME_X1:
case ME_EPZS:
{
P_LEFT[0] = mv_table[mot_xy - 1][0];
P_LEFT[1] = mv_table[mot_xy - 1][1];
if(P_LEFT[0] > (rel_xmax<<shift)) P_LEFT[0] = (rel_xmax<<shift);
if (mb_y) {
P_TOP[0] = mv_table[mot_xy - mot_stride ][0];
P_TOP[1] = mv_table[mot_xy - mot_stride ][1];
P_TOPRIGHT[0] = mv_table[mot_xy - mot_stride + 1 ][0];
P_TOPRIGHT[1] = mv_table[mot_xy - mot_stride + 1 ][1];
if(P_TOP[1] > (rel_ymax<<shift)) P_TOP[1]= (rel_ymax<<shift);
if(P_TOPRIGHT[0] < (rel_xmin<<shift)) P_TOPRIGHT[0]= (rel_xmin<<shift);
if(P_TOPRIGHT[1] > (rel_ymax<<shift)) P_TOPRIGHT[1]= (rel_ymax<<shift);
P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
}
pred_x= P_LEFT[0];
pred_y= P_LEFT[1];
}
if(mv_table == s->b_forw_mv_table){
mv_scale= (s->pb_time<<16) / (s->pp_time<<shift);
}else{
mv_scale= ((s->pb_time - s->pp_time)<<16) / (s->pp_time<<shift);
}
dmin = s->me.motion_search[0](s, 0, &mx, &my, P, pred_x, pred_y, rel_xmin, rel_ymin, rel_xmax, rel_ymax,
picture, s->p_mv_table, mv_scale, mv_penalty);
break;
}
dmin= s->me.sub_motion_search(s, &mx, &my, dmin, rel_xmin, rel_ymin, rel_xmax, rel_ymax,
pred_x, pred_y, picture, 0, 0, mv_penalty);
if(s->avctx->me_sub_cmp != s->avctx->mb_cmp && !s->me.skip)
dmin= s->me.get_mb_score(s, mx, my, pred_x, pred_y, picture, mv_penalty);
mv_table[mot_xy][0]= mx;
mv_table[mot_xy][1]= my;
return dmin;
}
| 1threat
|
static void pxa2xx_mm_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
PXA2xxState *s = (PXA2xxState *) opaque;
switch (addr) {
case MDCNFG ... SA1110:
if ((addr & 3) == 0) {
s->mm_regs[addr >> 2] = value;
break;
}
default:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
break;
}
}
| 1threat
|
java runtimeExcpetion result :
public static void main(String[] args) {
System.out.print("a");
try {
System.out.print("b");
throw new IllegalArgumentException();
} catch (IllegalArgumentException e) {
System.out.print("c");
throw new RuntimeException("1");
} catch (RuntimeException e) {
System.out.print("d");
throw new RuntimeException("2");
} finally {
System.out.print("e");
throw new RuntimeException("3");
}}
I can not understand why the output is abce and runtimeException
| 0debug
|
Im Not Able to view page of my form in php : <p>I just done with coding of my recipe form where user will fill it and these data will go to database but i don't know what is mistake in my code ,</p>
<p>you guys can see in snapshot error plus my codes </p>
<p><a href="https://i.stack.imgur.com/M6nrA.jpg" rel="nofollow noreferrer">My Codes:</a></p>
<p><a href="https://i.stack.imgur.com/J9Pab.jpg" rel="nofollow noreferrer">Error on Browser:</a></p>
| 0debug
|
static void clear_tco_status(const TestData *d)
{
qpci_io_writew(d->dev, d->tco_io_base + TCO1_STS, 0x0008);
qpci_io_writew(d->dev, d->tco_io_base + TCO2_STS, 0x0002);
qpci_io_writew(d->dev, d->tco_io_base + TCO2_STS, 0x0004);
}
| 1threat
|
envlist_unsetenv(envlist_t *envlist, const char *env)
{
struct envlist_entry *entry;
size_t envname_len;
if ((envlist == NULL) || (env == NULL))
return (EINVAL);
if (strchr(env, '=') != NULL)
return (EINVAL);
envname_len = strlen(env);
for (entry = envlist->el_entries.lh_first; entry != NULL;
entry = entry->ev_link.le_next) {
if (strncmp(entry->ev_var, env, envname_len) == 0)
break;
}
if (entry != NULL) {
QLIST_REMOVE(entry, ev_link);
free((char *)entry->ev_var);
free(entry);
envlist->el_count--;
}
return (0);
}
| 1threat
|
What is the purpose of the file "drawables.xml" under the "values" directory? : <p>For an android studio project, I found a file named "drawables.xml" in the "values" folder</p>
<pre><code><resources xmlns:android="http://schemas.android.com/apk/res/android">
<item name="ic_menu_camera" type="drawable">@android:drawable/ic_menu_camera</item>
<item name="ic_menu_gallery" type="drawable">@android:drawable/ic_menu_gallery</item>
<item name="ic_menu_slideshow" type="drawable">@android:drawable/ic_menu_slideshow</item>
<item name="ic_menu_manage" type="drawable">@android:drawable/ic_menu_manage</item>
<item name="ic_menu_share" type="drawable">@android:drawable/ic_menu_share</item>
<item name="ic_menu_send" type="drawable">@android:drawable/ic_menu_send</item>
</resources>
</code></pre>
<p>What's the purpose of this file? Why does it create another reference to an existing drawable and why not just use "@android:drawable/ic_menu_camera"?</p>
| 0debug
|
Textbox entry giving errors in c# : **I have 4 text boxes. In first textbox just i am doubleclicking and opening child form.there i am displaying some names and values. I am selecting one name in that form and that name is coming to first form first text box and next text box value is coming. next I want to take input using third text box and do some caliculations, display result in fourth textbox(readonly one).but it is giving some error.what I made mistake.
here is my code
Below code I wrote to take values from child form**
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
//MessageBox.Show(dataGridView1.CurrentRow.Cells[3].Value.ToString());
Form8.code = dataGridView1.CurrentRow.Cells[0].Value.ToString();
Form8.name = dataGridView1.CurrentRow.Cells[1].Value.ToString();
Form8.fiel= dataGridView1.CurrentRow.Cells[6].Value.ToString();
Form8.measure= dataGridView1.CurrentRow.Cells[2].Value.ToString();
below Code of my main form to store that values
boxname.Text = name;
if (boxname.Text == "")
{
MessageBox.Show("Empty Name");
}
else
{
//boxname.Text = name;
boxbprice.Text = fiel;
double qty=Convert.ToDouble(boxqty.Text);//taking quanty input and storing that a double datatype variable.
}
> where I did mistake.it is giving some error
> "input String was not in a currect format"
| 0debug
|
How to assert the regular expression against my output using selenium java : This is my regex value
/(\u20AC|\u00A3)[\d,]*/?(week|wk|month|mth|year|yr)?/
Can I please know how to verify this regular expression against my output using selenium.
| 0debug
|
static void gen_msync(DisasContext *ctx)
{
}
| 1threat
|
F# type constructor doesn't act like a function : <p>If I define a type like this:</p>
<pre><code>type Foo = Items of seq<int>
</code></pre>
<p>I can create a <code>Foo</code> as follows:</p>
<pre><code>Items [1;2;3]
</code></pre>
<p>However, the following doesn't work:</p>
<pre><code>[1;2;3] |> Items
</code></pre>
<p>The error message is:</p>
<pre><code>Type mismatch. Expecting a
int list -> 'a
but given a
seq<int> -> Foo
</code></pre>
<p>Shouldn't the compiler be able to convert an <code>int list</code> into a <code>seq<int></code>? If the <code>Items</code> constructor was a normal function, I could invoke it either way:</p>
<pre><code>let length ints = Seq.length ints
printfn "%A" (length [1;2;3])
printfn "%A" ([1;2;3] |> length)
</code></pre>
| 0debug
|
How can I use v-for to display data from dailymotion api? : <p>I have making a video list viewer using dailymotion api with vue.js. but I faced a wall about "v-for" which I display video list data.</p>
<p>I requested from dailymotion api.</p>
<p>Sample data(jsonURL): <a href="https://api.dailymotion.com/user/olddog928/videos?fields=id,thumbnail_url,title&availability=1&page=1&limit=100" rel="nofollow noreferrer">https://api.dailymotion.com/user/olddog928/videos?fields=id,thumbnail_url,title&availability=1&page=1&limit=100</a></p>
<p>in this data, the "title" data located into "loaded data" -> list(Array) -> "title".</p>
<pre><code>HTML:
<div id="app">
<button v-on:click="getList">Load list</button>
<ul>
<li v-for="l in lists">{{ l.title }}</li>
</ul>
</div>
JavaScript:
var url = 'https://api.dailymotion.com/user/olddog928/videos';
new Vue({
el: '#app',
data: {
lists: null
},
methods: {
getList() {
axios({
method: 'get',
url: url,
params: {
fields: 'id,thumbnail_url,title',
availability: 1,
page: 1,
limit: 100
}
}).then(function (res) {
console.log(res.data.list);
this.lists = res.data.list;
});
}
}
});
</code></pre>
<p>The point is 1. get json with axios -> 2. save data list to "lists" -> 3. Using v-for to display list title in "li" tag</p>
| 0debug
|
C++ smart button input : <p>I recently learned basic C ++ and I wanted to know if there was any way to know if a specific button in the keyboard was pressed / released.I couldn't really think about a way to do it with my C++ knowledge.</p>
<p>Thanks! :) </p>
| 0debug
|
Python 3, if str is present replace with str : <p>I'm writing a fairly simple python program to find and download videos from a particular site. I would like to have my script name the file by using the page title except the page title contains various strings i would like remove for e.g.,</p>
<pre><code>The title is:
The Big Bang Theory S09E15 720p HDTV X264-DIMENSION
</code></pre>
<p>but the titles are not always consistent for e.g.,</p>
<pre><code>The title is:
Triple 9 2016 READNFO HDRip AC3-EVO
</code></pre>
<p>How can I replace strings if they are present?
Maybe create a list or dictionary of possible strings and if they are present then remove them (or replace with empty string)? I have tried and tried to find an answer but cannot find anything that helps my situation.</p>
<p>Basically if <code>"HDTV", "HDRip", "720p", "X264", etc</code> are present then replace them otherwise carry on?</p>
| 0debug
|
Changing numbers to fractions in ssrs report : I have tried this expression for ssrs ***=Format(Fields!width.Value, "#/###" )***.
I am new to ssrs and having trouble changing numbers to fractions. Do i input it in the query ? or is there any way to input fractions inside a report.
| 0debug
|
How to decompile iOS apps? : <p>I want to see the code of an iOS app.</p>
<p>The app I downloaded is .deb.</p>
<p><strong>First question</strong>: Is it possible to install .deb file on iOS or I downloaded a wrong file?</p>
<p>After unpacking the .deb file, I got some files, including .nib, .storyboard and some other files.</p>
<p>My <strong>main question</strong> is, How to decompile these .nib files?</p>
<p>I tried to decompile these files using NibToXibConverter, but I didn't succeed.</p>
| 0debug
|
How to implement pagination in nestjs with typeorm : <p>Anyway to get the total count and record with single query, instead of execute the query two times. Or how can i reuse the where condition in both query.</p>
<pre><code>async findAll(query): Promise<Paginate> {
const take = query.take || 10
const skip = query.skip || 0
const keyword = query.keyword || ''
const builder = this.userRepository.createQueryBuilder("user")
const total = await builder.where("user.name like :name", { name: '%' + keyword + '%' }).getCount()
const data = await builder.where("user.name like :name", { name: '%' + keyword + '%' }).orderBy('name', 'DESC').skip(skip).take(take).getMany();
return {
data: data,
count: total
}
}
</code></pre>
<p>{
count: 10,
data: [
{
id: 1,
name: 'David'
},
{
id: 2,
name: 'Alex'
}]
}</p>
| 0debug
|
Want to extract specific data in other cell in MS_Excel : 000008()-24/25 MELFORD COURT, HARDWICK GRANGE WOOLSTON WARRINGTON, WAI 4RZ ENGLAND
I want to extract all data .i.e. whole address after 000008()- in other cell in excel but don't know how to do it
| 0debug
|
Java - Why does int default to 0 when a value outside the range is attempted to be stored in it : <p>I have a simple program for calculating the x to the power of y.</p>
<pre><code> public static int calculatePower(int x, int y) {
int result = 1;
if (y == 0)
return result;
for (int i = 1; i <= y; i++) {
result = result * x;
}
return result;
}
</code></pre>
<p>When i pass the parameters as 4 and 15, i get the value back as 1073741824. But when the parameters are 4 and 16, the value returned is zero. </p>
<p>If the outer range value cannot be stored in int, shouldnt it be retaining the last value - 1073741824 ?</p>
| 0debug
|
How to return variable itself in PHP functions intead of values? : I have a lot of variables in a certain process and i want to store them all in a function. I want to know if there's a way to return the variables itself from a function instead of returning only the values.
| 0debug
|
Platform suggestions for android app without javascript : <p>Is there any cross platform tool apart from xamarin for developing an app,which is not functioning on javascript,</p>
| 0debug
|
def first_repeated_char(str1):
for index,c in enumerate(str1):
if str1[:index+1].count(c) > 1:
return c
return "None"
| 0debug
|
static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf)
{
SCSITargetReq *r = DO_UPCAST(SCSITargetReq, req, req);
switch (buf[0]) {
case REPORT_LUNS:
if (!scsi_target_emulate_report_luns(r)) {
goto illegal_request;
}
break;
case INQUIRY:
if (!scsi_target_emulate_inquiry(r)) {
goto illegal_request;
}
break;
case REQUEST_SENSE:
r->len = scsi_device_get_sense(r->req.dev, r->buf,
MIN(req->cmd.xfer, sizeof r->buf),
(req->cmd.buf[1] & 1) == 0);
if (r->req.dev->sense_is_ua) {
scsi_device_unit_attention_reported(req->dev);
r->req.dev->sense_len = 0;
r->req.dev->sense_is_ua = false;
}
break;
default:
scsi_req_build_sense(req, SENSE_CODE(LUN_NOT_SUPPORTED));
scsi_req_complete(req, CHECK_CONDITION);
return 0;
illegal_request:
scsi_req_build_sense(req, SENSE_CODE(INVALID_FIELD));
scsi_req_complete(req, CHECK_CONDITION);
return 0;
}
if (!r->len) {
scsi_req_complete(req, GOOD);
}
return r->len;
}
| 1threat
|
Aws S3 Filter by Tags. Search by tags : <p>We have our bucket with new Aws SDK API on AWS S3. We uploaded and tagged lots of files and folders with tags. </p>
<p>How can we filter on key-value tag, or only one of them? I'd like to find all the objects with key = "temp", or key = "temp" and value = "lol". </p>
<p>Thanks! </p>
| 0debug
|
Conversion of string into Datetime : <p>I have a column with dates in it in the string format as'08-MAY-17'. How can I convert this column into datetime format so that I can select a specific time window for my datafrme</p>
| 0debug
|
Azure ASP .net WebApp The request timed out : <p>I have deployed an ASP .net MVC web app to Azure App service. </p>
<p>I do a GET request from my site to some controller method which gets data from DB(DbContext). Sometimes the process of getting data from DB may take more than 4 minutes. That means that my request has no action more than 4 minutes. After that Azure kills the connection - I get message:</p>
<blockquote>
<p><h2>500 - The request timed out.</h2> The web server failed
to respond within the specified time.</p>
</blockquote>
<p>This is a method example: </p>
<pre><code> [HttpGet]
public async Task<JsonResult> LongGet(string testString)
{
var task = Task.Delay(360000);
await task;
return Json("Woke", JsonRequestBehavior.AllowGet);
}
</code></pre>
<p>I have seen a lot of questions like this, but I got no answer:</p>
<p><a href="https://social.msdn.microsoft.com/Forums/azure/en-US/560dc2a9-43e1-4c68-830c-6e1defe2f72d/azure-web-app-request-timeout-issue?forum=" rel="noreferrer">Not working 1</a>
Cant give other link - reputation is too low. </p>
<p>I have read this <a href="https://azure.microsoft.com/ru-ru/blog/new-configurable-idle-timeout-for-azure-load-balancer/" rel="noreferrer">article</a> - its about Azure Load Balancer which is not available for webapps, but its written that common way of handling my problem in Azure webapp is using TCP Keep-alive. So I changed my method: </p>
<pre><code>[HttpGet]
public async Task<JsonResult> LongPost(string testString)
{
ServicePointManager.SetTcpKeepAlive(true, 1000, 5000);
ServicePointManager.MaxServicePointIdleTime = 400000;
ServicePointManager.FindServicePoint(Request.Url).MaxIdleTime = 4000000;
var task = Task.Delay(360000);
await task;
return Json("Woke", JsonRequestBehavior.AllowGet);
}
</code></pre>
<p>But still get same error.
I am using simple GET request like </p>
<pre><code>GET /Home/LongPost?testString="abc" HTTP/1.1
Host: longgetrequest.azurewebsites.net
Cache-Control: no-cache
Postman-Token: bde0d996-8cf3-2b3f-20cd-d704016b29c6
</code></pre>
<p>So I am looking for the answer what am I doing wrong and how to increase request timeout time in Azure Web app. Any help is appreciated. </p>
<p>Azure setting on portal: </p>
<p>Web sockets - On</p>
<p>Always On - On</p>
<p>App settings: </p>
<p>SCM_COMMAND_IDLE_TIMEOUT = 3600</p>
<p>WEBSITE_NODE_DEFAULT_VERSION = 4.2.3</p>
| 0debug
|
How to manage service workers in chrome? : <p>In Mozila, we can view service workers by <code>about:serviceworkers</code>.
Is there any option in chrome to manage/delete service workers?</p>
<p>I have a worker in google chrome background displaying unwanted browser push notifications?</p>
| 0debug
|
How to access private Docker Hub repository from Kubernetes on Vagrant : <p>I am failing to pull from my private Docker Hub repository into my local Kubernetes setup running on Vagrant:</p>
<blockquote>
<p>Container "hellonode" in pod "hellonode-n1hox" is waiting to start: image can't be
pulled</p>
<p>Failed to pull image "username/hellonode": Error: image username/hellonode:latest not found</p>
</blockquote>
<p>I have set up Kubernetes locally via Vagrant as described <a href="http://kubernetes.io/docs/getting-started-guides/vagrant/" rel="noreferrer">here</a> and created a secret named "dockerhub" with <em>kubectl create secret docker-registry dockerhub --docker-server=<a href="https://registry.hub.docker.com/" rel="noreferrer">https://registry.hub.docker.com/</a> --docker-username=username --docker-password=... --docker-email=...</em> which I supplied as the image pull secret.</p>
<p>I am running Kubernetes 1.2.0.</p>
| 0debug
|
void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data,
GArray *linker)
{
GSList *device_list;
device_list = nvdimm_get_plugged_device_list();
if (!device_list) {
return;
}
nvdimm_build_nfit(device_list, table_offsets, table_data, linker);
nvdimm_build_ssdt(device_list, table_offsets, table_data, linker);
g_slist_free(device_list);
}
| 1threat
|
float64 HELPER(ucf64_negd)(float64 a)
{
return float64_chs(a);
}
| 1threat
|
Error undefined methode 'interger' when make migrate : <h2>I'm building a database with Ruby, but when I tried to make a model (database table) a couple errors showed up, and I don't understand what is " in block in change" and "change". Here's the error.</h2>
<pre><code>>C:\Users\MINH\Monika>rake db:migrate
>== 20161130153857 CreatePages: migrating ======================================
>-- create_table(:pages)
>rake aborted!
>StandardError: An error has occurred, this and all later migrations canceled:
>undefined method `interger' for #><ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition:0x58a4528>
>C:/Users/MINH/Monika/db/migrate/20161130153857_create_pages.rb:11:in `block in >change'
>C:/Users/MINH/Monika/db/migrate/20161130153857_create_pages.rb:3:in `change'
>NoMethodError: undefined method `interger' for #>>>..<ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition:0x58a4528>
>C:/Users/MINH/Monika/db/migrate/20161130153857_create_pages.rb:11:in `block in >change'
>C:/Users/MINH/Monika/db/migrate/20161130153857_create_pages.rb:3:in `change'
>Tasks: TOP => db:migrate
>(See full trace by running task with --trace)
</code></pre>
<hr>
<p>This is the migration</p>
<pre><code>>class CreatePages < ActiveRecord::Migration[5.0]
> def change
> create_table :pages do |t|
> t.string :name
> t.text :description
> t.text :address
> t.text :contact
> t.string :profile_image
> t.string :cover_image
> t.string :look_book
> t.interger :seller_id
>
> t.timestamps
> end
> end
>end
</code></pre>
| 0debug
|
void virtio_config_writel(VirtIODevice *vdev, uint32_t addr, uint32_t data)
{
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
uint32_t val = data;
if (addr > (vdev->config_len - sizeof(val)))
return;
stl_p(vdev->config + addr, val);
if (k->set_config) {
k->set_config(vdev, vdev->config);
}
}
| 1threat
|
Activating Anaconda Environment in VsCode : <p>I have Anaconda working on my system and VsCode working, but how do I get VsCode to activate a specific environment when running my python script?</p>
| 0debug
|
Get district name from latitude and longitude in php : <p>I have current latitude and longitude, with this how to get district name or code in php. Please help me.</p>
| 0debug
|
How to divide the web page in different segment.? : <p>Hi Currently i am working in web project. There it self i am designing a website for mobile device. Here i want to know behalf of what i can use pixel for footer,header.And what is default height and width for mobile device.
Here some sample code is there</p>
<pre><code> <body>
<div id="header">
<h1>Books Gallery</h1>
</div>
<div id="footer">
**Copyright © 2016*
</div>
</body>
</code></pre>
| 0debug
|
How to check localhost (im using asp sql server) website to android phone : I need to check my website on my android phone , i wonder how can i connect it through localhost. need help please. thank you.
| 0debug
|
Enable HTTPS on GCE/GKE : <p>I am running web site with Kubernetes on Google Cloud. At the moment, everything is working well - through http. But I need https. I have several services and one of them is exposed to the outside world, let's call it web. As far as I know, this is the only service that needs to be modified. I tried to creating a static IP and TCP/SSL loadbalancer ssl-LB in the Networking section of GCP and using that LB in web.yaml, which I create. Creating the service gets stuck with:</p>
<pre><code>Error creating load balancer (will retry): Failed to create load
balancer for service default/web: requested ip <IP> is
neither static nor assigned to LB
aff3a4e1f487f11e787cc42010a84016(default/web): <nil>
</code></pre>
<p>According to GCP my IP is static, however. The hashed LB I cannot find anywhere and it should be assigned to ssl-LB anyway. How do I assign this properly?</p>
<p><strong>More details:</strong></p>
<p>Here are the contents of web.yaml</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
name: web
labels:
...
spec:
type: LoadBalancer
loadBalancerIP: <RESERVED STATIC IP>
ports:
- port: 443
targetPort: 7770
selector:
...
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: web
spec:
replicas: 1
template:
metadata:
labels:
...
spec:
containers:
- name: web
image: gcr.io/<PROJECT>/<IMAGE NAME>
ports:
- containerPort: 7770
</code></pre>
| 0debug
|
av_cold void ff_dnxhdenc_init_x86(DNXHDEncContext *ctx)
{
#if HAVE_SSE2_INLINE
if (av_get_cpu_flags() & AV_CPU_FLAG_SSE2) {
if (ctx->cid_table->bit_depth == 8)
ctx->get_pixels_8x4_sym = get_pixels_8x4_sym_sse2;
}
#endif
}
| 1threat
|
Select children link with jquery : <p>How should select the link <code><a></code> in this structure with jquery</p>
<pre><code><span id="guiaAtencion:ot4">
<p>
<a href="http://www.apps.com">link</a>
</p>
</span>
</code></pre>
| 0debug
|
python- having issue with math : Having an issue with the math in the code. after the first person's payout is calculated the other 2 are done incorrectly,
1/2 to Stan.
2/3 of what remains to Kyle.
The rest is to be split equally to Butters and Wendy.
my first split to Stan is correct but after that can't seem to figure out the correct way to code it.
def main():
estate = int(input('Enter value of Kennys estate '))
stan = estate / 2
kyle = stan * .66
wendy_butters = kyle / 2
print('stan gets$ ',format (stan,' .2f'))
print('kyle gets$ ',format (kyle,' .2f'))
print('Butters and Wendy each get $ ',format (wendy_butters,' .2f'))
main ()
| 0debug
|
Apply a set of functions to an object : <p>I have a dataframe with a set of objects <code>df$data</code> and a set of rules to be applied on every object <code>df$rules</code>.</p>
<pre><code>df <- data.frame(
data = c(1,2,3),
rules = c("rule1", "rule1, rule2, rule3", "rule3, rule2"),
stringsAsFactors = FALSE
)
</code></pre>
<p>The rules are</p>
<pre><code>rule1 <- function(data) {
data * 2
}
rule2 <- function(data) {
data + 1
}
rule3 <- function(data) {
data ^ 3
}
</code></pre>
<p>For every row in the dataframe I want to apply all the rules specified in the <code>rules</code> column. The rules should be applied in series.</p>
<p>What I figured out:</p>
<pre><code>apply_rules <- function(data, rules) {
for (i in 1:length(data)) {
rules_now <- unlist(strsplit(rules[i], ", "))
for (j in 1:length(rules_now)) {
data[i] <- apply_rule(data[i], rules_now[j])
}
}
return(data)
}
apply_rule <- function(data, rule) {
return(sapply(data, rule))
}
apply_rules(df$data, df$rules)
# [1] 2 125 28
</code></pre>
<p>Although this works I'm pretty sure there must be more elegant solutions. On SO I could find lot's of stuff about the <code>apply</code>-functions and also one <a href="https://stackoverflow.com/questions/30979206/apply-many-functions-to-one-vector/30979677#30979677">post</a> about applying many functions to a vector and something about <a href="https://stackoverflow.com/questions/11330659/method-chaining-with-r/11331637#11331637">chaining functions</a>. The <code>Compose</code> idea looks promising but I couldn't figure out how to make a call to <code>Compose</code> with my rules as string. (<code>parse()</code> didn't work..)</p>
<p>Any hints?</p>
| 0debug
|
SocketException: Address already in use MONGODB : <p>i found this error when trying to run mongodb. I install it via homebrew. Please assist</p>
<pre><code>Agungs-MacBook-Pro:~ agungmahaputra$ mongod
2017-12-26T15:31:15.911+0700 I CONTROL [initandlisten] MongoDB starting : pid=5189 port=27017 dbpath=/data/db 64-bit host=Agungs-MacBook-Pro.local
2017-12-26T15:31:15.911+0700 I CONTROL [initandlisten] db version v3.6.0
2017-12-26T15:31:15.911+0700 I CONTROL [initandlisten] git version: a57d8e71e6998a2d0afde7edc11bd23e5661c915
2017-12-26T15:31:15.911+0700 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2n 7 Dec 2017
2017-12-26T15:31:15.911+0700 I CONTROL [initandlisten] allocator: system
2017-12-26T15:31:15.911+0700 I CONTROL [initandlisten] modules: none
2017-12-26T15:31:15.911+0700 I CONTROL [initandlisten] build environment:
2017-12-26T15:31:15.911+0700 I CONTROL [initandlisten] distarch: x86_64
2017-12-26T15:31:15.911+0700 I CONTROL [initandlisten] target_arch: x86_64
2017-12-26T15:31:15.911+0700 I CONTROL [initandlisten] options: {}
2017-12-26T15:31:15.911+0700 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address already in use
2017-12-26T15:31:15.911+0700 I CONTROL [initandlisten] now exiting
2017-12-26T15:31:15.911+0700 I CONTROL [initandlisten] shutting down with code:48
Agungs-MacBook-Pro:~ agungmahaputra$
</code></pre>
| 0debug
|
in UPDATE How to delete the old in ASP.Net MVC : - how To delete physically old image after updating
> > [HttpPost]
> > [ValidateAntiForgeryToken]
> > public ActionResult Edit(Job job, HttpPostedFileBase jobimage)
> > {
> > if (ModelState.IsValid)
> > {
> > System.IO.File.Delete(Path.Combine(Server.MapPath("~/Uploads"),job.JobImage));
> > string path = Path.Combine(Server.MapPath("~/Uploads"), jobimage.FileName);
> > jobimage.SaveAs(path);
> > job.JobImage = jobimage.FileName;
> > db.Entry(job).State = EntityState.Modified;
> > db.SaveChanges();
> > return RedirectToAction("Index");
> > }
> > ViewBag.CategoryId = new SelectList(db.Categories, "Id", "CategoryName", job.CategoryId);
> > return View(job);
> > }
- this line not working any help and thank u
> System.IO.File.Delete(Path.Combine(Server.MapPath("~/Uploads"),job.JobImage));
| 0debug
|
static int get_key(const char **ropts, const char *delim, char *key, unsigned key_size)
{
unsigned key_pos = 0;
const char *opts = *ropts;
opts += strspn(opts, WHITESPACES);
while (is_key_char(*opts)) {
key[key_pos++] = *opts;
if (key_pos == key_size)
key_pos--;
(opts)++;
}
opts += strspn(opts, WHITESPACES);
if (!*opts || !strchr(delim, *opts))
return AVERROR(EINVAL);
opts++;
key[key_pos++] = 0;
if (key_pos == key_size)
key[key_pos - 4] = key[key_pos - 3] = key[key_pos - 2] = '.';
*ropts = opts;
return 0;
}
| 1threat
|
Python file read line startswith to endswith and move to list : <p>i have file like below:</p>
<pre><code>=======
line1 contents
line2 contents
line3 contents
=======
=======
line4 contents
line5 contents
=======
=======
line6 contents
line7 contents
=======
</code></pre>
<p>Read file contents that startswith ======= to endswith =======. Send output to list.</p>
<p>Below is expected output for list of list </p>
<pre><code> [["line1 contents", "line2 contents", "line3 contents"],
["line4 contents", "line5 contents"],
["line6 contents", "line7 contents"]]
</code></pre>
| 0debug
|
int init_timer_alarm(void)
{
struct qemu_alarm_timer *t = NULL;
int i, err = -1;
for (i = 0; alarm_timers[i].name; i++) {
t = &alarm_timers[i];
err = t->start(t);
if (!err)
break;
}
if (err) {
err = -ENOENT;
goto fail;
}
atexit(quit_timers);
t->pending = true;
alarm_timer = t;
return 0;
fail:
return err;
}
| 1threat
|
Web scrapping using python for multiple pages : <p>I have a beautifulsoup parser to get all content of html. How do i scrap the web when it hs multiple pages. like,
myurl = "<a href="https://www.mybanktracker.com/ABC-Bank/Reviews" rel="nofollow noreferrer">https://www.mybanktracker.com/ABC-Bank/Reviews</a>"
the url has 20 off pages like
<a href="https://www.mybanktracker.com/ABC-Bank/Reviews/pages/1" rel="nofollow noreferrer">https://www.mybanktracker.com/ABC-Bank/Reviews/pages/1</a>
<a href="https://www.mybanktracker.com/ABC-Bank/Reviews/pages/2" rel="nofollow noreferrer">https://www.mybanktracker.com/ABC-Bank/Reviews/pages/2</a> and so on.
How do i extract all the pages infro into one? or any other easier way to do so?</p>
| 0debug
|
sql group by each row select : sql table name= phones
rows= id, mobileno, status, userid, createdon
each user can have multiple numbers, i want to find oldest active phonenumber for each users.
status=1 is active.
for example:
user1= id=1, mobileno=123, status=1,userid=1,createdon=2019/12/20
user1= id=1, mobileno=1234, status=1,userid=1,createdon=2019/12/19
user1= id=1, mobileno=12348, status=0,userid=1,createdon=2019/12/17
user2= id=2, mobileno=12345, status=1,userid=2,createdon=2019/12/15
user2= id=2, mobileno=123456, status=1,userid=2,createdon=2019/12/10
result must be
user1= id=1, mobileno=1234
user2= id=2, mobileno=123456
(id unqiue and mobileno= oldest active one)
thanks.
| 0debug
|
laravel collection to array : <p>I have two models, <code>Post</code> and <code>Comment</code>; many comments belong to a single post. I'm trying to access all comments associated with a post as an array.</p>
<p>I have the following, which gives a collection.</p>
<p><code>$comments_collection = $post->comments()->get()</code></p>
<p>How would I turn this <code>$comments_collection</code> into an array? Is there a more direct way of accessing this array through eloquent relationships?</p>
| 0debug
|
static const UID *mxf_get_mpeg2_codec_ul(AVCodecContext *avctx)
{
int long_gop = avctx->gop_size > 1 || avctx->has_b_frames;
if (avctx->profile == 4) {
if (avctx->level == 8)
return &mxf_mpeg2_codec_uls[0+long_gop];
else if (avctx->level == 4)
return &mxf_mpeg2_codec_uls[4+long_gop];
else if (avctx->level == 6) 14
return &mxf_mpeg2_codec_uls[8+long_gop];
} else if (avctx->profile == 0) {
if (avctx->level == 5)
return &mxf_mpeg2_codec_uls[2+long_gop];
else if (avctx->level == 2)
return &mxf_mpeg2_codec_uls[6+long_gop];
}
return NULL;
}
| 1threat
|
How to store multiple product under one shop? How to manage certain situation in Mysql : <p>I guys, i'm working on a e-commerce website where in, Mysql i got two tables. Products and Shops now i have condition where, i need to add Multiple product under one shop in my shop table. i'm confused how to figure out this thing. please give soltion or atleast Table structure so that, i can implement according to that.
i need table colum structure thank you.</p>
| 0debug
|
How to find the address of default gateway and the local address facing towards it? : <p>I'm implementing a port control protocol (PCP) client working in Linux, implemented in C. It needs to connect to the default gateway to open ports. PCP needs to embed the local IP address in the message itself, not just in the IP headers (presumably this is for detecting the presence of unwanted NAT in the path, but it's a mystery to me how there could be a NAT between the machine itself and its default gateway). PCP also needs to connect to the default gateway, needing its address.</p>
<p>This raises two questions:</p>
<ol>
<li>How to find the IP address of the default gateway?</li>
<li>How to find the IP address of the machine towards the default gateway even in the presence of multiple interfaces and IP addresses?</li>
</ol>
| 0debug
|
static void av_noinline filter_mb_edgecv( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) {
const unsigned int index_a = 52 + qp + h->slice_alpha_c0_offset;
const int alpha = alpha_table[index_a];
const int beta = (beta_table+52)[qp + 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->s.dsp.h264_h_loop_filter_chroma(pix, stride, alpha, beta, tc);
} else {
h->s.dsp.h264_h_loop_filter_chroma_intra(pix, stride, alpha, beta);
}
}
| 1threat
|
There is a polygon in 2D space. Find its area : <p>There is a polygon in 2D space. Find its area.
An array of numbers:</p>
<ol>
<li><p>Positive integer n, the quantity of the polygon vertices.</p></li>
<li><p>Sequence of reals with n subsequences of two numbers, each subsequence contains the 2D coordinates of a vertex of the polygon.
Output:</p></li>
</ol>
<p>A real, the area of the polygon</p>
<p>What is wrong with my code? </p>
<p>Example: </p>
<p>Input:
3 1.0 0.0 0.0 2.0 -1.0 0.0
Output:
2</p>
<p>class Program
{</p>
<pre><code> static void Main(string[] args)
{
var input = Console.ReadLine();
var numbers = input.Split(' ').Select(x => double.Parse(x)).ToArray();
var a = (int) numbers[0];
double[] arr = numbers.Skip(1).Take(a).ToArray();
double[,] coord = new double[2, a];
for(int i = 0; i <= arr.Length/2; i++)
{
coord[0, i] = arr[i];
coord[1, i] = arr[1+i];
}
double sum1 = 0;
double sum2 = 0;
for(int i = 0; i < a - 1; i++)
{
sum1 += coord[0, i] * coord[1, i + 1];
sum2 += coord[1, i] * coord[0, i + 1];
}
double area = Math.Abs((sum1 - sum2) / 2d);
Console.Write(coord[0,2]);
Console.ReadKey();
}
}
</code></pre>
| 0debug
|
static void test_unaligned_write_same(void)
{
QVirtIOSCSI *vs;
uint8_t buf[512] = { 0 };
const uint8_t write_same_cdb[CDB_SIZE] = { 0x41, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x02, 0x00 };
qvirtio_scsi_start("-drive file=blkdebug::null-co:
",format=raw,file.align=4k "
"-device scsi-disk,drive=dr1,lun=0,scsi-id=1");
vs = qvirtio_scsi_pci_init(PCI_SLOT);
g_assert_cmphex(0, ==,
virtio_scsi_do_command(vs, write_same_cdb, NULL, 0, buf, 512));
qvirtio_scsi_pci_free(vs);
qvirtio_scsi_stop();
}
| 1threat
|
how to get the full date list based on start and end date using moment js : get the date list based on start and end date using moment js
for example, I have two dates, One is a start date and end date. My start date is `2019-04-02` and my end date is `2019-05-16` i need all the date in between these two dates.
my output will be `["2019-04-02", "2019-04-03", "2019-04-04", ..., "2019-05-16"]` is it possible in moment js
| 0debug
|
def centered_hexagonal_number(n):
return 3 * n * (n - 1) + 1
| 0debug
|
def remove_elements(list1, list2):
result = [x for x in list1 if x not in list2]
return result
| 0debug
|
How to change Context value while using React Hook of useContext : <p>Using the <code>useContext</code> hook with React 16.8+ works well. You can create a component, use the hook, and utilize the context values without any issues.</p>
<p>What I'm not certain about is how to apply changes to the Context Provider values.</p>
<p>1) Is the useContext hook strictly a means of consuming the context values?</p>
<p>2) Is there a recommended way, using React hooks, to update values from the child component, which will then trigger component re-rendering for any components using the <code>useContext</code> hook with this context?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const ThemeContext = React.createContext({
style: 'light',
visible: true
});
function Content() {
const { style, visible } = React.useContext(ThemeContext);
const handleClick = () => {
// change the context values to
// style: 'dark'
// visible: false
}
return (
<div>
<p>
The theme is <em>{style}</em> and state of visibility is
<em> {visible.toString()}</em>
</p>
<button onClick={handleClick}>Change Theme</button>
</div>
)
};
function App() {
return <Content />
};
const rootElement = document.getElementById('root');
ReactDOM.render(<App />, rootElement);</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="root"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.8.2/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.8.2/umd/react-dom.production.min.js"></script></code></pre>
</div>
</div>
</p>
| 0debug
|
static int alloc_f(int argc, char **argv)
{
int64_t offset;
int nb_sectors, remaining;
char s1[64];
int num, sum_alloc;
int ret;
offset = cvtnum(argv[1]);
if (offset & 0x1ff) {
printf("offset %" PRId64 " is not sector aligned\n",
offset);
return 0;
}
if (argc == 3) {
nb_sectors = cvtnum(argv[2]);
} else {
nb_sectors = 1;
}
remaining = nb_sectors;
sum_alloc = 0;
while (remaining) {
ret = bdrv_is_allocated(bs, offset >> 9, nb_sectors, &num);
remaining -= num;
if (ret) {
sum_alloc += num;
}
}
cvtstr(offset, s1, sizeof(s1));
printf("%d/%d sectors allocated at offset %s\n",
sum_alloc, nb_sectors, s1);
return 0;
}
| 1threat
|
Include and compile cpp header file from c : I have a cpp file and its header file. I need to include this cpp header file in a c code and use the functions in it.
When the cpp.h file is compiled through main.c, compilation fails because of the cpp linkage.
On using the macro __cplusplus stream and string are not resolved, is there some way to compile the cpp.h file through and execute.
I have given a outline of my code only.
Kindly help me out in this. Thanks
**cpp header file cpp.h**
struct s1
{
string a;
string b;
};
typedef struct s1 s2;
class c1
{
public:
void fun1(s2 &s3);
private:
fun2(std::string &x,const char *y);
};
**cpp file cpp.cpp**
c1::fun1(s2 &s3)
{
fstream file;
}
c1::fun2(std::string &x,const char *y)
{
}
**c file main.c**
#include "cpp.h"
void main()
{
c1 c2;
s1 structobj;
c2.fun1(&structobj);
printf("\n value of a in struct %s",structobj.a);
}
| 0debug
|
How To Make Circle with Four Color In Java : Can you help me to find out how to make image like this with Java Applet.
[CIRCLE FILLED COLOR][1]
[1]: https://i.stack.imgur.com/YRHbR.png
I have no idea about this , my way stuck until this step.
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
public class CircleDraw extends Frame {
Shape circle = new Ellipse2D.Float(100.0f, 100.0f, 100.0f, 100.0f);
Shape square = new Rectangle2D.Double(100, 100,100, 100);
public void paint(Graphics g) {
Graphics2D ga = (Graphics2D)g;
ga.draw(circle);
ga.setPaint(Color.green);
ga.fill(circle);
ga.setPaint(Color.red);
ga.draw(square);
}
public static void main(String args[]) {
Frame frame = new CircleDraw();
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
}
});
frame.setSize(300, 250);
frame.setVisible(true);
}
}
if you have any solution I'll appreciated
Thanks
| 0debug
|
Maze game adding player issue : <blockquote>
<p>Giving me a Syntax error that "cannot find MyKeyListener". I am trying to add it so player class can be implemented into the grid.So far i have created both player and maze but cant seem able to add player to maze because of this syntax error. Can anyone point out what mistake i am making.</p>
</blockquote>
<pre><code>import java.awt.*;
import javax.swing.*;
import java.awt.event.*; // Needed for ActionListener
import javax.swing.event.*; // Needed for ActionListener
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.Timer;
public class www extends JFrame
{
static Maze maze = new Maze ();
static Timer t;
//======================================================== constructor
public www ()
{
// 1... Create/initialize components
// 2... Create content pane, set layout
JPanel content = new JPanel (); // Create a content pane
content.setLayout (new BorderLayout ()); // Use BorderLayout for panel
JPanel north = new JPanel ();
north.setLayout (new FlowLayout ()); // Use FlowLayout for input area
DrawArea board = new DrawArea (500, 500);
// 3... Add the components to the input area.
content.add (north, "North"); // Input area
content.add (board, "South"); // Output area
// 4... Set this window's attributes.
setContentPane (content);
pack ();
setTitle ("MAZE");
setSize (490, 500);
setKeyListener(new MyKeylistener());
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo (null); // Center window.
}
public static void main (String[] args)
{
www window = new www ();
window.setVisible (true);
//jf.setTitle("Tutorial");
//jf.setSize(600,400);
}
class DrawArea extends JPanel
{
public DrawArea (int width, int height)
{
this.setPreferredSize (new Dimension (width, height)); // size
}
public void paintComponent (Graphics g)
{
maze.show (g); // display current state of colony
}
}
}
class Maze
{
private int grid [][];
public Maze ()
{
int [][] maze =
{ {1,0,1,1,1,1,1,1,1,1,1,1,1},
{1,0,1,0,1,0,1,0,0,0,0,0,1},
{1,0,1,0,0,0,1,0,1,1,1,0,1},
{1,0,0,0,1,1,1,0,0,0,0,0,1},
{1,0,1,0,0,0,0,0,1,1,1,0,1},
{1,0,1,0,1,1,1,0,1,0,0,0,1},
{1,0,1,0,1,0,0,0,1,1,1,0,1},
{1,0,1,0,1,1,1,0,1,0,1,0,1},
{1,0,0,0,0,0,0,0,0,0,1,0,1},
{1,1,1,1,1,1,1,1,1,1,1,0,1}};
grid = maze;
}
public void show (Graphics g)
{
for (int row = 0 ; row < grid.length ; row++)
for (int col = 0 ; col < grid [0].length ; col++)
{
if (grid [row] [col] == 1) // life
g.setColor (Color.black);
else
g.setColor (Color.white);
g.fillRect (col * 30 + 30, row * 30 + 30, 30, 30); // draw life form
}
//g.setColor(Color.RED);
//g.fillRect(60,30,30,50);
}
class MyKeyListener extends KeyAdapter {
int x = 0, y = 0,velX = 0, velY = 0;
public void keyPressed(KeyEvent e)
{
int c = e.getKeyCode();
if(c == KeyEvent.VK_LEFT)
{
velX = -1;
velY = 0;
}
if (c == KeyEvent.VK_UP)
{
velX = 0;
velY = -1;
}
if( c==KeyEvent.VK_RIGHT)
{
velX = 1;
velY = 0;
}
if(c==KeyEvent.VK_DOWN)
{
velX = 0;
velY = 1;
}
}
public MyKeyListener ()
{
tm.start ();
addKeyListener(this);
setFocusable(true);
setFocusTraversalKeysEnabled(false);
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
g.setColor(Color.RED);
g.fillRect(x,y,50,30);
}
public void actionPerformed(ActionEvent e)
{
x = x+velX;
y = y +velY;
repaint();
}
}
// public void player ()
// {
//
// Timer tm = new Timer(5,this);
// int x = 0;
// int y = 0;
// int velX = 0 ;
// int velY = 0;tm.start();
// addKeyListener(this);
// setFocusable(true);
// setFocusTraversalKeysEnabled(false);
// }
// public void actionPerformed(ActionEvent e)
// {
// x = x+velX;
// y = y +velY;
// repaint();
// }
// public void keyPressed(KeyEvent e)
// {
// int c = e.getKeyCode();
// if(c == KeyEvent.VK_LEFT)
// {
// velX = -1;
// velY = 0;
// }
// if (c == KeyEvent.VK_UP)
// {
// velX = 0;
// velY = -1;
// }
// if( c==KeyEvent.VK_RIGHT)
// {
// velX = 1;
// velY = 0;
// }
// if(c==KeyEvent.VK_DOWN)
// {
// velX = 0;
// velY = 1;
// }
// }
//
// public void keyTyped(KeyEvent e){}
//
// public void keyReleased(KeyEvent e){}
}
</code></pre>
| 0debug
|
static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
{
MOVMuxContext *mov = s->priv_data;
int64_t pos = avio_tell(pb);
int has_h264 = 0, has_video = 0;
int minor = 0x200;
int i;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
has_video = 1;
if (st->codec->codec_id == AV_CODEC_ID_H264)
has_h264 = 1;
}
avio_wb32(pb, 0);
ffio_wfourcc(pb, "ftyp");
if (mov->mode == MODE_3GP) {
ffio_wfourcc(pb, has_h264 ? "3gp6" : "3gp4");
minor = has_h264 ? 0x100 : 0x200;
} else if (mov->mode & MODE_3G2) {
ffio_wfourcc(pb, has_h264 ? "3g2b" : "3g2a");
minor = has_h264 ? 0x20000 : 0x10000;
} else if (mov->mode == MODE_PSP)
ffio_wfourcc(pb, "MSNV");
else if (mov->mode == MODE_MP4)
ffio_wfourcc(pb, "isom");
else if (mov->mode == MODE_IPOD)
ffio_wfourcc(pb, has_video ? "M4V ":"M4A ");
else if (mov->mode == MODE_ISM)
ffio_wfourcc(pb, "isml");
else if (mov->mode == MODE_F4V)
ffio_wfourcc(pb, "f4v ");
else
ffio_wfourcc(pb, "qt ");
avio_wb32(pb, minor);
if (mov->mode == MODE_MOV)
ffio_wfourcc(pb, "qt ");
else if (mov->mode == MODE_ISM) {
ffio_wfourcc(pb, "piff");
ffio_wfourcc(pb, "iso2");
} else {
ffio_wfourcc(pb, "isom");
ffio_wfourcc(pb, "iso2");
if (has_h264)
ffio_wfourcc(pb, "avc1");
}
if (mov->mode == MODE_3GP)
ffio_wfourcc(pb, has_h264 ? "3gp6":"3gp4");
else if (mov->mode & MODE_3G2)
ffio_wfourcc(pb, has_h264 ? "3g2b":"3g2a");
else if (mov->mode == MODE_PSP)
ffio_wfourcc(pb, "MSNV");
else if (mov->mode == MODE_MP4)
ffio_wfourcc(pb, "mp41");
return update_size(pb, pos);
}
| 1threat
|
Neeed update code for my programme : controller code i have :
<?php
class Latest_ctrl extends Ci_controller{
public function insert(){
$name=$this->input->post('name');
$pass=$this->input->post('pass');
$email=$this->input->post('email');
$mobile=$this->input->post('mobile');
$address=$this->input->post('address');
$data=array(
'name'=>$name,
'pass'=>$pass,
'email'=>$email,
'mobile'=>$mobile,
'address'=>$address
);
$this->load->model('latest_model');
$query= $this->db->insert('form',$data);
if($query){
redirect('latest_ctrl/view');
}
}
public function view(){
$this->load->model('latest_model');
$val=$this->latest_model->get_data();
$data['value']=$val;
$this->load->view('latest',$data);
}
public function index(){
$this->load->view('new_login');
}
public function delete($id){
$id=$this->uri->segment(3);
$this->load->model('latest_model');
$this->latest_model->delete_id($id);
redirect(base_url('latest_ctrl/view'));
}
Public function update($id){
$upd=$this->uri->segment(3);
$data = array(
'name' => $this->input->post('name'),
'pass' => $this->input->post('pass'),
'email' => $this->input->post('email'),
'mobile' => $this->input->post('mobile'),
'address' => $this->input->post('address')
);
$this->load->model('latest_model');
}
}
?>
Model code i have :
<?php
class Latest_model extends CI_model{
public function insert($tableName,$data){
return $this->db->insert($tableName, $data);
}
public function get_data(){
$query = $this->db->get('form');
if ( $query->num_rows() > 0 )
{
$row=$query->result();
return $row;
}
}
public function delete_id($id){
$this->db->where('id', $id);
$this->db->delete('form');
}
public function update_data(){
}
}
?>
view i have :
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1>Welcome Page </h1>
<form action="<?php echo base_url();?>latest_ctrl/insert" method="post">
<table >
<tr>
<td colspan=2 align="center"><h3>User Details</h3></td>
</tr>
<tr>
<td>
<?php echo form_label('Name'); ?>
</td>
<td>
<?php echo form_input(array('id' => 'name', 'name' => 'name','value'=>'')); ?>
</td>
</tr>
<tr>
<td>
<?php echo form_label('Pass'); ?>
</td>
<td>
<?php echo form_password(array('id' => 'pass', 'name' => 'pass')); ?>
</td>
</tr>
<tr>
<td><?php echo form_label('Email'); ?>
</td>
<td><?php echo form_input(array('id' => 'email', 'name' => 'email')); ?></td>
</tr>
<tr>
<td><?php echo form_label('Mobile'); ?>
</td>
<td><?php echo form_input(array('id' => 'mobile', 'name' => 'mobile')); ?>
</td>
</tr>
<tr>
<td>
<?php echo form_label('Address'); ?>
</td>
<td>
<?php echo form_input(array('id' => 'address', 'name' => 'address')); ?>
</td>
</tr>
<tr>
<td colspan="2" align="center"><?php echo form_submit(array('id' => 'submit', 'value' => 'Submit')); ?>
</td>
</tr>
</form>
</table>
</body>
</html>
i want to edit a particular record for that purpose i need model and controller code to update the record i am newbie in codeigniter thanks in advance
also i have a page which redirect the page to the update controller but i want only update code for model and controller for update purpose
| 0debug
|
Implementing a custom Decoder in Swift 4 : <p>I'd like to decode an XML document using the new <code>Decodable</code> protocol introduced in Swift 4, however, there doesn't seem to be an existing implementation for an XML decoder that conforms to the <code>Decoder</code> protocol.</p>
<p>My plan was to use the SWXMLHash library to parse the XML, then possibly make the <code>XMLIndexer</code> class in that library extend the <code>Decoder</code> protocol so that my model can be initialized with an instance of <code>XMLIndexer</code> (<code>XMLIndexer</code> is returned by <code>SWXMLHash.parse(xmlString)</code>).</p>
<p><a href="https://i.stack.imgur.com/S6n3z.png" rel="noreferrer"><img src="https://i.stack.imgur.com/S6n3z.png" alt="XMLIndexer+Decoder.swift"></a></p>
<p>My issue is that I have no clue how to implement the <code>Decoder</code> protocol and I can't seem to find any resources online that explain how it's done. Every resource that I've found strictly mentions the <code>JSONDecoder</code> class which is included with the Swift standard library and no resource I've found addresses the issue of creating your own custom decoder.</p>
| 0debug
|
static void ide_dma_cb(void *opaque, int ret)
{
IDEState *s = opaque;
int n;
int64_t sector_num;
uint64_t offset;
bool stay_active = false;
if (ret == -ECANCELED) {
return;
}
if (ret < 0) {
if (ide_handle_rw_error(s, -ret, ide_dma_cmd_to_retry(s->dma_cmd))) {
s->bus->dma->aiocb = NULL;
dma_buf_commit(s, 0);
return;
}
}
n = s->io_buffer_size >> 9;
if (n > s->nsector) {
n = s->nsector;
stay_active = true;
}
sector_num = ide_get_sector(s);
if (n > 0) {
assert(n * 512 == s->sg.size);
dma_buf_commit(s, s->sg.size);
sector_num += n;
ide_set_sector(s, sector_num);
s->nsector -= n;
}
if (s->nsector == 0) {
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
goto eot;
}
n = s->nsector;
s->io_buffer_index = 0;
s->io_buffer_size = n * 512;
if (s->bus->dma->ops->prepare_buf(s->bus->dma, s->io_buffer_size) < 512) {
s->status = READY_STAT | SEEK_STAT;
dma_buf_commit(s, 0);
goto eot;
}
trace_ide_dma_cb(s, sector_num, n, IDE_DMA_CMD_str(s->dma_cmd));
if ((s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) &&
!ide_sect_range_ok(s, sector_num, n)) {
ide_dma_error(s);
block_acct_invalid(blk_get_stats(s->blk), s->acct.type);
return;
}
offset = sector_num << BDRV_SECTOR_BITS;
switch (s->dma_cmd) {
case IDE_DMA_READ:
s->bus->dma->aiocb = dma_blk_read(s->blk, &s->sg, offset,
BDRV_SECTOR_SIZE, ide_dma_cb, s);
break;
case IDE_DMA_WRITE:
s->bus->dma->aiocb = dma_blk_write(s->blk, &s->sg, offset,
BDRV_SECTOR_SIZE, ide_dma_cb, s);
break;
case IDE_DMA_TRIM:
s->bus->dma->aiocb = dma_blk_io(blk_get_aio_context(s->blk),
&s->sg, offset, BDRV_SECTOR_SIZE,
ide_issue_trim, s->blk, ide_dma_cb, s,
DMA_DIRECTION_TO_DEVICE);
break;
default:
abort();
}
return;
eot:
if (s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) {
block_acct_done(blk_get_stats(s->blk), &s->acct);
}
ide_set_inactive(s, stay_active);
}
| 1threat
|
void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time)
{
QEMUTimer **pt, *t;
qemu_del_timer(ts);
pt = &active_timers[ts->clock->type];
for(;;) {
t = *pt;
if (!t)
break;
if (t->expire_time > expire_time)
break;
pt = &t->next;
}
ts->expire_time = expire_time;
ts->next = *pt;
*pt = ts;
if (pt == &active_timers[ts->clock->type]) {
if ((alarm_timer->flags & ALARM_FLAG_EXPIRED) == 0) {
qemu_rearm_alarm_timer(alarm_timer);
}
if (use_icount)
qemu_notify_event();
}
}
| 1threat
|
Is terraform destroy needed before terraform apply? : <p>Is terraform <code>destroy</code> needed before terraform <code>apply</code>? If not, what is a workflow you follow when updating existing infrastructure and how do you decide if <code>destroy</code> is needed?</p>
| 0debug
|
AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
{
AVStream *st;
int i;
if (av_reallocp_array(&s->streams, s->nb_streams + 1,
sizeof(*s->streams)) < 0) {
s->nb_streams = 0;
return NULL;
}
st = av_mallocz(sizeof(AVStream));
if (!st)
return NULL;
if (!(st->info = av_mallocz(sizeof(*st->info)))) {
av_free(st);
return NULL;
}
st->codec = avcodec_alloc_context3(c);
if (!st->codec) {
av_free(st->info);
av_free(st);
return NULL;
}
if (s->iformat) {
st->codec->bit_rate = 0;
avpriv_set_pts_info(st, 33, 1, 90000);
}
st->index = s->nb_streams;
st->start_time = AV_NOPTS_VALUE;
st->duration = AV_NOPTS_VALUE;
st->cur_dts = 0;
st->first_dts = AV_NOPTS_VALUE;
st->probe_packets = MAX_PROBE_PACKETS;
st->last_IP_pts = AV_NOPTS_VALUE;
for (i = 0; i < MAX_REORDER_DELAY + 1; i++)
st->pts_buffer[i] = AV_NOPTS_VALUE;
st->sample_aspect_ratio = (AVRational) { 0, 1 };
st->info->fps_first_dts = AV_NOPTS_VALUE;
st->info->fps_last_dts = AV_NOPTS_VALUE;
s->streams[s->nb_streams++] = st;
return st;
}
| 1threat
|
server side script for AJAX call : <p>In writing my first program that uses jQuery's .ajax() function to ask a server side PHP script for data and then process it, I am struggling to come up with an appropriate file name for the PHP script. Is there a naming convention or a standard file name for a script whose purpose is to receive requests and send back data to AJAX calls? What file names are you using for your server side scripts that handle AJAX calls?</p>
| 0debug
|
document.write('<script src="evil.js"></script>');
| 1threat
|
Doest display php echo values from mysql : Tables: Users & UserGroup
Users contains: ID, Name, Image, UserGroupID
UserGroup contains: ID, Name, Menu
UserGroupID(column) is linked with UserGroup table's ID.
column Menu contains something like this:
`
<header id="header-navbar" class="content-mini content-mini-full"> <ul class="nav-header pull-right"> <li> <div class="btn-group"> <button class="btn btn-default btn-image dropdown-toggle" data-toggle="dropdown" type="button"> <img src="../images/employees/'.$row_UserDetails['Image'].'" alt=""> <span class="caret"></span> </button> <ul class="dropdown-menu dropdown-menu-right"> <li> <a tabindex="-1" href="my-profile.php"> <i class="si si-user pull-right"></i> My Profile </a> </li> <li> <a tabindex="-1" href="../logout.php"> <i class="si si-logout pull-right"></i>Log out </a> </li> </ul> </div> </li> </ul>
</header>
`
Now at img src its creating a problem.
'.$row_UserDetails['Image'].'
Doesnt display the value.
Why is that & how do we fix this?
Anyways i am trying to display the above results from php mysql in php page using this: `<?php echo $row_UserGroup['Menu'];?>`
but doesnt work.
All displays fine except img src which value is coming from existing recordset.
| 0debug
|
java.lang.StackOverflowError: stack size 8MB: Aftertextchanged : <p>I have multiple edit texts in activity and using textwatcher to take/observe user input. Using methods for each editexts for writing functionality. sometimes i had to use same method for multiple edittexts where it is causing the java.lang.StackOverflowError: stack size 8MB error.Kindly someone help me or anyone suggest me how to use same method for multiple edittext watchers. it will be helpful. </p>
| 0debug
|
WEB APPLICATION OR PAGE SPEED TESTER [OR TEST TOOL] : <p>Is there a browser add-on or application that can use to test the speed of web applications? </p>
<p>If there is an existing tools like this.
What do you use to check the speed ?</p>
<p>Thank you.</p>
| 0debug
|
int loader_exec(const char * filename, char ** argv, char ** envp,
struct target_pt_regs * regs, struct image_info *infop)
{
struct linux_binprm bprm;
int retval;
int i;
bprm.p = TARGET_PAGE_SIZE*MAX_ARG_PAGES-sizeof(unsigned int);
for (i=0 ; i<MAX_ARG_PAGES ; i++)
bprm.page[i] = NULL;
retval = open(filename, O_RDONLY);
if (retval < 0)
return retval;
bprm.fd = retval;
bprm.filename = (char *)filename;
bprm.argc = count(argv);
bprm.argv = argv;
bprm.envc = count(envp);
bprm.envp = envp;
retval = prepare_binprm(&bprm);
if(retval>=0) {
if (bprm.buf[0] == 0x7f
&& bprm.buf[1] == 'E'
&& bprm.buf[2] == 'L'
&& bprm.buf[3] == 'F') {
retval = load_elf_binary(&bprm,regs,infop);
} else {
fprintf(stderr, "Unknown binary format\n");
return -1;
}
}
if(retval>=0) {
do_init_thread(regs, infop);
return retval;
}
for (i=0 ; i<MAX_ARG_PAGES ; i++) {
free(bprm.page[i]);
}
return(retval);
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.