problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static int avs_read_packet(AVFormatContext * s, AVPacket * pkt)
{
AvsFormat *avs = s->priv_data;
int sub_type = 0, size = 0;
AvsBlockType type = AVS_NONE;
int palette_size = 0;
uint8_t palette[4 + 3 * 256];
int ret;
if (avs->remaining_audio_size > 0)
if (avs_read_audio_packet(s, pkt) > 0)
return 0;
while (1) {
if (avs->remaining_frame_size <= 0) {
if (!avio_rl16(s->pb))
return AVERROR(EIO);
avs->remaining_frame_size = avio_rl16(s->pb) - 4;
}
while (avs->remaining_frame_size > 0) {
sub_type = avio_r8(s->pb);
type = avio_r8(s->pb);
size = avio_rl16(s->pb);
if (size < 4)
avs->remaining_frame_size -= size;
switch (type) {
case AVS_PALETTE:
ret = avio_read(s->pb, palette, size - 4);
if (ret < size - 4)
return AVERROR(EIO);
palette_size = size;
break;
case AVS_VIDEO:
if (!avs->st_video) {
avs->st_video = av_new_stream(s, AVS_VIDEO);
if (avs->st_video == NULL)
return AVERROR(ENOMEM);
avs->st_video->codec->codec_type = AVMEDIA_TYPE_VIDEO;
avs->st_video->codec->codec_id = CODEC_ID_AVS;
avs->st_video->codec->width = avs->width;
avs->st_video->codec->height = avs->height;
avs->st_video->codec->bits_per_coded_sample=avs->bits_per_sample;
avs->st_video->nb_frames = avs->nb_frames;
avs->st_video->codec->time_base = (AVRational) {
1, avs->fps};
}
return avs_read_video_packet(s, pkt, type, sub_type, size,
palette, palette_size);
case AVS_AUDIO:
if (!avs->st_audio) {
avs->st_audio = av_new_stream(s, AVS_AUDIO);
if (avs->st_audio == NULL)
return AVERROR(ENOMEM);
avs->st_audio->codec->codec_type = AVMEDIA_TYPE_AUDIO;
}
avs->remaining_audio_size = size - 4;
size = avs_read_audio_packet(s, pkt);
if (size != 0)
return size;
break;
default:
avio_skip(s->pb, size - 4);
}
}
}
}
| 1threat
|
This is a question about reversing a string : <p>Write a function that reverses a string. The input string is given as an array of characters char[].</p>
<p>Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.</p>
<p>You may assume all the characters consist of printable ascii characters.</p>
<p>Example 1:</p>
<p>Input: ["h","e","l","l","o"]
Output: ["o","l","l","e","h"]</p>
<pre><code>class Solution {
public void reverseString(char[] s) {
for(int i=0; i<s.length/2; i++){
for(int j=s.length-1; j>i; j--){
char temp = s[j];
s[j] = s[i];
s[i] = temp;
}
}
}
}
</code></pre>
<p>Input: ["h","e","l","l","o"]</p>
<p>My output["e","l","o","h","l"]</p>
<p>expected: ["o","l","l","e","h"]</p>
<p>Can anyone tell where am I wrong.</p>
| 0debug
|
crashing the program on a specific date C# : i use this code to get date
String.Format("{0:yyyy/MM/dd}", Convert.ToDateTime(calender.Text))
it work correct .
but cant get 3 Special data so my program crashing.
in the day "31" and Month "2" , "4" , "6" for example `"1397/06/31"`or `"1397/04/31"`
how to fix it?
| 0debug
|
int pcilg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2)
{
CPUS390XState *env = &cpu->env;
S390PCIBusDevice *pbdev;
uint64_t offset;
uint64_t data;
uint8_t len;
uint32_t fh;
uint8_t pcias;
cpu_synchronize_state(CPU(cpu));
if (env->psw.mask & PSW_MASK_PSTATE) {
program_interrupt(env, PGM_PRIVILEGED, 4);
return 0;
}
if (r2 & 0x1) {
program_interrupt(env, PGM_SPECIFICATION, 4);
return 0;
}
fh = env->regs[r2] >> 32;
pcias = (env->regs[r2] >> 16) & 0xf;
len = env->regs[r2] & 0xf;
offset = env->regs[r2 + 1];
pbdev = s390_pci_find_dev_by_fh(fh);
if (!pbdev || !(pbdev->fh & FH_MASK_ENABLE)) {
DPRINTF("pcilg no pci dev\n");
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
}
if (pbdev->lgstg_blocked) {
setcc(cpu, ZPCI_PCI_LS_ERR);
s390_set_status_code(env, r2, ZPCI_PCI_ST_BLOCKED);
return 0;
}
if (pcias < 6) {
if ((8 - (offset & 0x7)) < len) {
program_interrupt(env, PGM_OPERAND, 4);
return 0;
}
MemoryRegion *mr = pbdev->pdev->io_regions[pcias].memory;
memory_region_dispatch_read(mr, offset, &data, len,
MEMTXATTRS_UNSPECIFIED);
} else if (pcias == 15) {
if ((4 - (offset & 0x3)) < len) {
program_interrupt(env, PGM_OPERAND, 4);
return 0;
}
data = pci_host_config_read_common(
pbdev->pdev, offset, pci_config_size(pbdev->pdev), len);
switch (len) {
case 1:
break;
case 2:
data = bswap16(data);
break;
case 4:
data = bswap32(data);
break;
case 8:
data = bswap64(data);
break;
default:
program_interrupt(env, PGM_OPERAND, 4);
return 0;
}
} else {
DPRINTF("invalid space\n");
setcc(cpu, ZPCI_PCI_LS_ERR);
s390_set_status_code(env, r2, ZPCI_PCI_ST_INVAL_AS);
return 0;
}
env->regs[r1] = data;
setcc(cpu, ZPCI_PCI_LS_OK);
return 0;
}
| 1threat
|
Can I move a DOM element to an arbitrary position without mutating the DOM? : Is it possible to move an element to a position in a variable without changing a value in the DOM?
| 0debug
|
static inline void RENAME(planar2x)(const uint8_t *src, uint8_t *dst, int srcWidth, int srcHeight, int srcStride, int dstStride)
{
int x,y;
dst[0]= src[0];
for(x=0; x<srcWidth-1; x++){
dst[2*x+1]= (3*src[x] + src[x+1])>>2;
dst[2*x+2]= ( src[x] + 3*src[x+1])>>2;
}
dst[2*srcWidth-1]= src[srcWidth-1];
dst+= dstStride;
for(y=1; y<srcHeight; y++){
#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
const long mmxSize= srcWidth&~15;
asm volatile(
"mov %4, %%"REG_a" \n\t"
"1: \n\t"
"movq (%0, %%"REG_a"), %%mm0 \n\t"
"movq (%1, %%"REG_a"), %%mm1 \n\t"
"movq 1(%0, %%"REG_a"), %%mm2 \n\t"
"movq 1(%1, %%"REG_a"), %%mm3 \n\t"
"movq -1(%0, %%"REG_a"), %%mm4 \n\t"
"movq -1(%1, %%"REG_a"), %%mm5 \n\t"
PAVGB" %%mm0, %%mm5 \n\t"
PAVGB" %%mm0, %%mm3 \n\t"
PAVGB" %%mm0, %%mm5 \n\t"
PAVGB" %%mm0, %%mm3 \n\t"
PAVGB" %%mm1, %%mm4 \n\t"
PAVGB" %%mm1, %%mm2 \n\t"
PAVGB" %%mm1, %%mm4 \n\t"
PAVGB" %%mm1, %%mm2 \n\t"
"movq %%mm5, %%mm7 \n\t"
"movq %%mm4, %%mm6 \n\t"
"punpcklbw %%mm3, %%mm5 \n\t"
"punpckhbw %%mm3, %%mm7 \n\t"
"punpcklbw %%mm2, %%mm4 \n\t"
"punpckhbw %%mm2, %%mm6 \n\t"
#if 1
MOVNTQ" %%mm5, (%2, %%"REG_a", 2)\n\t"
MOVNTQ" %%mm7, 8(%2, %%"REG_a", 2)\n\t"
MOVNTQ" %%mm4, (%3, %%"REG_a", 2)\n\t"
MOVNTQ" %%mm6, 8(%3, %%"REG_a", 2)\n\t"
#else
"movq %%mm5, (%2, %%"REG_a", 2) \n\t"
"movq %%mm7, 8(%2, %%"REG_a", 2)\n\t"
"movq %%mm4, (%3, %%"REG_a", 2) \n\t"
"movq %%mm6, 8(%3, %%"REG_a", 2)\n\t"
#endif
"add $8, %%"REG_a" \n\t"
" js 1b \n\t"
:: "r" (src + mmxSize ), "r" (src + srcStride + mmxSize ),
"r" (dst + mmxSize*2), "r" (dst + dstStride + mmxSize*2),
"g" (-mmxSize)
: "%"REG_a
);
#else
const int mmxSize=1;
#endif
dst[0 ]= (3*src[0] + src[srcStride])>>2;
dst[dstStride]= ( src[0] + 3*src[srcStride])>>2;
for(x=mmxSize-1; x<srcWidth-1; x++){
dst[2*x +1]= (3*src[x+0] + src[x+srcStride+1])>>2;
dst[2*x+dstStride+2]= ( src[x+0] + 3*src[x+srcStride+1])>>2;
dst[2*x+dstStride+1]= ( src[x+1] + 3*src[x+srcStride ])>>2;
dst[2*x +2]= (3*src[x+1] + src[x+srcStride ])>>2;
}
dst[srcWidth*2 -1 ]= (3*src[srcWidth-1] + src[srcWidth-1 + srcStride])>>2;
dst[srcWidth*2 -1 + dstStride]= ( src[srcWidth-1] + 3*src[srcWidth-1 + srcStride])>>2;
dst+=dstStride*2;
src+=srcStride;
}
#if 1
dst[0]= src[0];
for(x=0; x<srcWidth-1; x++){
dst[2*x+1]= (3*src[x] + src[x+1])>>2;
dst[2*x+2]= ( src[x] + 3*src[x+1])>>2;
}
dst[2*srcWidth-1]= src[srcWidth-1];
#else
for(x=0; x<srcWidth; x++){
dst[2*x+0]=
dst[2*x+1]= src[x];
}
#endif
#ifdef HAVE_MMX
asm volatile( EMMS" \n\t"
SFENCE" \n\t"
:::"memory");
#endif
}
| 1threat
|
C# .net code error message in calculator code :
**I am coding for calculator in c#.net. I am having an error message on txtDisplay in txtDisplay.Text. the error says "The name 'txtDisplay' does not exists in the current context".My code so far is:**
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Calc
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnOne_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnOne.Text;
}
| 0debug
|
static int build_huff(const uint8_t *src, VLC *vlc, int *fsym)
{
int i;
HuffEntry he[256];
int last;
uint32_t codes[256];
uint8_t bits[256];
uint8_t syms[256];
uint32_t code;
*fsym = -1;
for (i = 0; i < 256; i++) {
he[i].sym = i;
he[i].len = *src++;
}
qsort(he, 256, sizeof(*he), ff_ut_huff_cmp_len);
if (!he[0].len) {
*fsym = he[0].sym;
return 0;
}
if (he[0].len > 32)
return -1;
last = 255;
while (he[last].len == 255 && last)
last--;
code = 1;
for (i = last; i >= 0; i--) {
codes[i] = code >> (32 - he[i].len);
bits[i] = he[i].len;
syms[i] = he[i].sym;
code += 0x80000000u >> (he[i].len - 1);
}
return ff_init_vlc_sparse(vlc, FFMIN(he[last].len, 11), last + 1,
bits, sizeof(*bits), sizeof(*bits),
codes, sizeof(*codes), sizeof(*codes),
syms, sizeof(*syms), sizeof(*syms), 0);
}
| 1threat
|
static void bastardized_rice_decompress(ALACContext *alac,
int32_t *output_buffer,
int output_size,
int readsamplesize,
int rice_initialhistory,
int rice_kmodifier,
int rice_historymult,
int rice_kmodifier_mask
)
{
int output_count;
unsigned int history = rice_initialhistory;
int sign_modifier = 0;
for (output_count = 0; output_count < output_size; output_count++) {
int32_t x;
int32_t x_modified;
int32_t final_val;
int k;
k = av_log2((history >> 9) + 3);
x= decode_scalar(&alac->gb, k, rice_kmodifier, readsamplesize);
x_modified = sign_modifier + x;
final_val = (x_modified + 1) / 2;
if (x_modified & 1) final_val *= -1;
output_buffer[output_count] = final_val;
sign_modifier = 0;
history += x_modified * rice_historymult
- ((history * rice_historymult) >> 9);
if (x_modified > 0xffff)
history = 0xffff;
if ((history < 128) && (output_count+1 < output_size)) {
int k;
unsigned int block_size;
sign_modifier = 1;
k = 7 - av_log2(history) + ((history + 16) >> 6 );
block_size= decode_scalar(&alac->gb, k, rice_kmodifier, 16);
if (block_size > 0) {
if(block_size >= output_size - output_count){
av_log(alac->avctx, AV_LOG_ERROR, "invalid zero block size of %d %d %d\n", block_size, output_size, output_count);
block_size= output_size - output_count - 1;
}
memset(&output_buffer[output_count+1], 0, block_size * 4);
output_count += block_size;
}
if (block_size > 0xffff)
sign_modifier = 0;
history = 0;
}
}
}
| 1threat
|
spring-jdbc vs spring-data-jdbc and what are they supporting : <p>I'm curious what is the difference between the spring-jdbc (what I missing in the newest spring release) and spring-data-jdbc.<br>
Is there a difference or just a renaming (in the repositories I don't see this)? </p>
<p>And is there somewhere described what are the supported targets(DB/JDBC specs/JDK) of the versions? </p>
<p>e.g. for the plain JDBC from oracle I can see that information here:
<a href="http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#01_03_1" rel="noreferrer">http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#01_03_1</a><br>
(e.g.: JDBC Spec 4.1 in ojdbc7.jar on Java7/Java8 on Oracle DB 12.1/12cR1) </p>
<p>But I miss that for spring-jdbc - where do I find that information?</p>
| 0debug
|
Why is JavaScript bind() necessary? : <p>The problem in example 1 is 'this' referring to the global name instead of the myName object.</p>
<p>I understand the use of bind() in setting the value of this to a specific object, so it solves the problem in example 1, but why does this problem occur in the first place? Is it just the way Javascript was created? </p>
<p>I'm also wondering why example 3 solves the issue and the difference between example 2 and 3. </p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>this.name = "John"
var myName = {
name: "Tom",
getName: function() {
return this.name
}
}
var storeMyName = myName.getName; // example 1
var storeMyName2 = myName.getName.bind(myName); // example 2
var storeMyName3 = myName.getName(); // example 3
console.log("example 1: " + storeMyName()); // doesn't work
console.log("example 2: " + storeMyName2()); // works
console.log("example 3: " + storeMyName3); // works</code></pre>
</div>
</div>
</p>
| 0debug
|
void av_parser_close(AVCodecParserContext *s)
{
if(s){
if (s->parser->parser_close) {
ff_lock_avcodec(NULL);
s->parser->parser_close(s);
ff_unlock_avcodec();
}
av_free(s->priv_data);
av_free(s);
}
}
| 1threat
|
How do I convert a Firestore date/Timestamp to a JS Date()? : <p>I am trying to convert the below date to a javascript Date() object. When I get it back from the server, it is a Timestamp object, </p>
<p><strong>Screenshot from Firebase Firestore console:</strong></p>
<p><a href="https://i.stack.imgur.com/Dz7gE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Dz7gE.png" alt="enter image description here"></a></p>
<p>When I try the following on a list of objects returned from firestore:</p>
<pre><code> list.forEach(a => {
var d = a.record.dateCreated;
console.log(d, new Date(d), Date(d))
})
</code></pre>
<p><strong>I get this output:</strong>
<a href="https://i.stack.imgur.com/H5NEW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/H5NEW.png" alt="enter image description here"></a></p>
<p>Clearly the Timestamps are all different, and are not all the same date of Sept 09, 2018 (which happens to be today). I'm also not sure why <code>new Date(Timestamp)</code> results in an <code>invalid date</code>. I'm a bit of a JS newbie, am I doing something wrong with the dates or timestamps?</p>
| 0debug
|
regex in javascript to check value in range : <p>What should be the regex for checking a value is in range of (1000 to 20000)</p>
| 0debug
|
Show Tutorial View on first time only : <p>I'm trying to create an tutorial screen that displays only during the first opening of an app. i know i should use user defaults but how and where ? in method viewDidLoad or on app delegate class ? </p>
| 0debug
|
static void n8x0_init(QEMUMachineInitArgs *args,
struct arm_boot_info *binfo, int model)
{
MemoryRegion *sysmem = get_system_memory();
struct n800_s *s = (struct n800_s *) g_malloc0(sizeof(*s));
int sdram_size = binfo->ram_size;
s->mpu = omap2420_mpu_init(sysmem, sdram_size, args->cpu_model);
n8x0_gpio_setup(s);
n8x0_nand_setup(s);
n8x0_i2c_setup(s);
if (model == 800)
n800_tsc_kbd_setup(s);
else if (model == 810) {
n810_tsc_setup(s);
n810_kbd_setup(s);
}
n8x0_spi_setup(s);
n8x0_dss_setup(s);
n8x0_cbus_setup(s);
n8x0_uart_setup(s);
if (usb_enabled(false)) {
n8x0_usb_setup(s);
}
if (args->kernel_filename) {
binfo->kernel_filename = args->kernel_filename;
binfo->kernel_cmdline = args->kernel_cmdline;
binfo->initrd_filename = args->initrd_filename;
arm_load_kernel(s->mpu->cpu, binfo);
qemu_register_reset(n8x0_boot_init, s);
}
if (option_rom[0].name &&
(args->boot_device[0] == 'n' || !args->kernel_filename)) {
uint8_t nolo_tags[0x10000];
s->mpu->cpu->env.regs[15] = OMAP2_Q2_BASE + 0x400000;
load_image_targphys(option_rom[0].name,
OMAP2_Q2_BASE + 0x400000,
sdram_size - 0x400000);
n800_setup_nolo_tags(nolo_tags);
cpu_physical_memory_write(OMAP2_SRAM_BASE, nolo_tags, 0x10000);
}
}
| 1threat
|
static target_ulong helper_udiv_common(CPUSPARCState *env, target_ulong a,
target_ulong b, int cc)
{
SPARCCPU *cpu = sparc_env_get_cpu(env);
int overflow = 0;
uint64_t x0;
uint32_t x1;
x0 = (a & 0xffffffff) | ((int64_t) (env->y) << 32);
x1 = (b & 0xffffffff);
if (x1 == 0) {
cpu_restore_state(CPU(cpu), GETPC());
helper_raise_exception(env, TT_DIV_ZERO);
}
x0 = x0 / x1;
if (x0 > 0xffffffff) {
x0 = 0xffffffff;
overflow = 1;
}
if (cc) {
env->cc_dst = x0;
env->cc_src2 = overflow;
env->cc_op = CC_OP_DIV;
}
return x0;
}
| 1threat
|
static void disas_ldst_pair(DisasContext *s, uint32_t insn)
{
int rt = extract32(insn, 0, 5);
int rn = extract32(insn, 5, 5);
int rt2 = extract32(insn, 10, 5);
int64_t offset = sextract32(insn, 15, 7);
int index = extract32(insn, 23, 2);
bool is_vector = extract32(insn, 26, 1);
bool is_load = extract32(insn, 22, 1);
int opc = extract32(insn, 30, 2);
bool is_signed = false;
bool postindex = false;
bool wback = false;
TCGv_i64 tcg_addr;
int size;
if (opc == 3) {
unallocated_encoding(s);
return;
}
if (is_vector) {
size = 2 + opc;
} else {
size = 2 + extract32(opc, 1, 1);
is_signed = extract32(opc, 0, 1);
if (!is_load && is_signed) {
unallocated_encoding(s);
return;
}
}
switch (index) {
case 1:
postindex = true;
wback = true;
break;
case 0:
if (is_signed) {
unallocated_encoding(s);
return;
}
postindex = false;
break;
case 2:
postindex = false;
break;
case 3:
postindex = false;
wback = true;
break;
}
if (is_vector && !fp_access_check(s)) {
return;
}
offset <<= size;
if (rn == 31) {
gen_check_sp_alignment(s);
}
tcg_addr = read_cpu_reg_sp(s, rn, 1);
if (!postindex) {
tcg_gen_addi_i64(tcg_addr, tcg_addr, offset);
}
if (is_vector) {
if (is_load) {
do_fp_ld(s, rt, tcg_addr, size);
} else {
do_fp_st(s, rt, tcg_addr, size);
}
} else {
TCGv_i64 tcg_rt = cpu_reg(s, rt);
if (is_load) {
do_gpr_ld(s, tcg_rt, tcg_addr, size, is_signed, false);
} else {
do_gpr_st(s, tcg_rt, tcg_addr, size);
}
}
tcg_gen_addi_i64(tcg_addr, tcg_addr, 1 << size);
if (is_vector) {
if (is_load) {
do_fp_ld(s, rt2, tcg_addr, size);
} else {
do_fp_st(s, rt2, tcg_addr, size);
}
} else {
TCGv_i64 tcg_rt2 = cpu_reg(s, rt2);
if (is_load) {
do_gpr_ld(s, tcg_rt2, tcg_addr, size, is_signed, false);
} else {
do_gpr_st(s, tcg_rt2, tcg_addr, size);
}
}
if (wback) {
if (postindex) {
tcg_gen_addi_i64(tcg_addr, tcg_addr, offset - (1 << size));
} else {
tcg_gen_subi_i64(tcg_addr, tcg_addr, 1 << size);
}
tcg_gen_mov_i64(cpu_reg_sp(s, rn), tcg_addr);
}
}
| 1threat
|
req.handle.writev is not a function : <p>I'm using React, React-Redux with Webpack for my project in a Docker container and keep running into this error</p>
<blockquote>
<p>internal/stream_base_commons.js:59 var err = req.handle.writev(req,
chunks, allBuffers);
^</p>
<p>TypeError: req.handle.writev is not a function
at writevGeneric (internal/stream_base_commons.js:59:24)
at Socket._writeGeneric (net.js:758:5)
at Socket._writev (net.js:767:8)
at doWrite (_stream_writable.js:408:12)
at clearBuffer (_stream_writable.js:517:5)
at Socket.Writable.uncork (_stream_writable.js:314:7)
at connectionCorkNT (_http_outgoing.js:646:8)
at process._tickCallback (internal/process/next_tick.js:63:19)</p>
</blockquote>
<p>The following is my versions</p>
<ol>
<li>NODE_VERSION 8.9</li>
<li>YARN_VERSION 1.7.0</li>
<li>OS Docker Linux/ Raspbian Lite</li>
<li>Webpack/ Webpack-Ddv-Server (latest)</li>
<li>React/ Redux (latest)</li>
</ol>
<p>My package.json</p>
<pre><code>{
....
"dependencies": {
"object-assign": "*",
"raf": "*",
"react": "*",
"react-dev-utils": "*",
"react-dom": "*",
"react-facebook-login": "*",
"react-helmet": "*",
"react-loadable": "*",
"react-slick": "*",
"react-router": "*",
"react-router-dom": "*",
"react-redux":"*",
"redux":"*",
"redux-thunk":"*",
"slick-carousel":"*",
"font-awesome":"*"
},
"devDependencies": {
"postcss-flexbugs-fixes": "3.2.0",
"postcss-loader": "2.0.8",
"promise": "8.0.1",
"autoprefixer": "7.1.6",
"babel-core": "6.26.0",
"babel-eslint": "7.2.3",
"babel-jest": "20.0.3",
"babel-loader": "7.1.2",
"babel-preset-react-app": "^3.1.1",
"babel-runtime": "6.26.0",
"case-sensitive-paths-webpack-plugin": "2.1.1",
"node-sass-chokidar": "*",
"npm-run-all": "*",
"sass-loader": "*",
"sw-precache-webpack-plugin": "0.11.4",
"resolve": "1.6.0",
"style-loader": "0.19.0",
"url-loader": "0.6.2",
"webpack": "*",
"webpack-dev-server": "*",
"webpack-manifest-plugin": "*",
"whatwg-fetch": "2.0.3",
"chalk": "1.1.3",
"css-loader": "0.28.7",
"dotenv": "4.0.0",
"dotenv-expand": "4.2.0",
"eslint": "4.10.0",
"eslint-config-react-app": "^2.1.0",
"eslint-loader": "1.9.0",
"eslint-plugin-flowtype": "2.39.1",
"eslint-plugin-import": "2.8.0",
"eslint-plugin-jsx-a11y": "5.1.1",
"eslint-plugin-react": "7.4.0",
"extract-text-webpack-plugin": "3.0.2",
"file-loader": "*",
"fs-extra": "*",
"html-webpack-plugin": "*",
"jest": "20.0.4"
},
"scripts": {
"start-js": "node scripts/start.js",
"start": "npm-run-all -p watch-css start-js",
"build-js": "node scripts/build.js",
"build": "npm-run-all build-css build-js",
"build-css": "node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/",
"watch-css": "npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive",
"test": "node scripts/test.js --env=jsdom",
"postinstall": "npm run start"
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx,mjs}"
],
"setupFiles": [
"<rootDir>/config/polyfills.js"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}",
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}"
],
"testEnvironment": "node",
"testURL": "http://localhost",
"transform": {
"^.+\\.(js|jsx|mjs)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|mjs|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$"
],
"moduleNameMapper": {
"^react-native$": "react-native-web"
},
"moduleFileExtensions": [
"web.js",
"js",
"json",
"web.jsx",
"jsx",
"node",
"mjs"
]
},
"babel": {
"presets": [
"react-app"
]
},
"eslintConfig": {
"extends": "react-app"
}
}
</code></pre>
<p>Anyone else with this issue? Does not happen often but does frustrate the development process</p>
| 0debug
|
Cannot use 'dotnet ef...' - The specified framework version '2.0' could not be parsed : <p>My project builds without any issues and can run without issues, but I cannot use <code>dotnet ef migrations</code> because of this strange error:</p>
<pre><code>The specified framework version '2.0' could not be parsed
The specified framework 'Microsoft.NETCore.App', version '2.0' was not found.
- Check application dependencies and target a framework version installed at:
/
- Alternatively, install the framework version '2.0'.
</code></pre>
<p>I have latest dotnet tooling installed - SDK 2.1.4 and runtime 2.0.5.</p>
<p>Can anyone help with that?
I was trying to find any solutions on web but didn't find anything working...</p>
| 0debug
|
Uncaught Invariant Violation: Rendered more hooks than during the previous render : <p>I have a component that looks like this (very simplified version):</p>
<pre><code>const component = (props: PropTypes) => {
const [allResultsVisible, setAllResultsVisible] = useState(false);
const renderResults = () => {
return (
<section>
<p onClick={ setAllResultsVisible(!allResultsVisible) }>
More results v
</p>
{
allResultsVisible &&
<section className="entity-block--hidden-results">
...
</section>
}
</section>
);
};
return <div>{ renderResults() }</div>;
}
</code></pre>
<p>When I load the page this component is used on, I get this error: <code>Uncaught Invariant Violation: Rendered more hooks than during the previous render.</code> I tried to find an explanation of this error, but my searching returned no results. </p>
<p>When I modify the component slightly:</p>
<pre><code>const component = (props: PropTypes) => {
const [allResultsVisible, setAllResultsVisible] = useState(false);
const handleToggle = () => {
setAllResultsVisible(!allResultsVisible);
}
const renderResults = () => {
return (
<section>
<p onClick={ handleToggle }>
More results v
</p>
{
allResultsVisible &&
<section className="entity-block--hidden-results">
...
</section>
}
</section>
);
};
return <div>{ renderResults() }</div>;
}
</code></pre>
<p>I no longer get that error. Is it because I included the <code>setState</code> function within the jsx that is returned by <code>renderResults</code>? It would be great to have an explanation of why the fix works.</p>
| 0debug
|
Separating multiple if conditions with commas in Swift : <p>We already know <a href="https://stackoverflow.com/questions/35434939/swift-if-statement-multiple-conditions-separated-by-commas">multiple optional bindings can be used in a single if/guard statement by separating them with commas</a>, but not with <code>&&</code> e.g.</p>
<pre><code>// Works as expected
if let a = someOpt, b = someOtherOpt {
}
// Crashes
if let a = someOpt && b = someOtherOpt {
}
</code></pre>
<p>Playing around with playgrounds, the comma-style format also seems to work for boolean conditions though I can't find this mentioned anywhere. e.g.</p>
<pre><code>if 1 == 1, 2 == 2 {
}
// Seems to be the same as
if 1 == 1 && 2 == 2 {
}
</code></pre>
<p>Is this an accepted method for evaluating multiple boolean conditions, and is the behaviour of <code>,</code> identical to that of <code>&&</code> or are they technically different?</p>
| 0debug
|
How can I stop EF Core from creating a filtered index on a nullable column : <p>I have this model:</p>
<pre><code>public class Subject
{
public int Id { get; set; }
[Required]
[StringLength(50)]
public string Name { get; set; }
public int LevelId { get; set; }
[ForeignKey("LevelId")]
public Level Level { get; set; }
[Column(TypeName = "datetime2")]
public DateTime? DeletedAt { get; set; }
}
</code></pre>
<p>And index configured via Fluent API:</p>
<pre><code>entityBuilder.HasIndex(e => new { e.LevelId, e.Name, e.DeletedAt })
.IsUnique();
</code></pre>
<p>It's creating a table with a unique filtered index. How can I prevent EF from adding the filter? I just want the index and don't want it filtered.</p>
| 0debug
|
void s390_sclp_extint(uint32_t parm)
{
if (kvm_enabled()) {
kvm_s390_service_interrupt(parm);
} else {
S390CPU *dummy_cpu = s390_cpu_addr2state(0);
cpu_inject_ext(dummy_cpu, EXT_SERVICE, parm, 0);
}
}
| 1threat
|
Mapped Types: removing optional modifier : <p>Given this code:</p>
<pre><code>interface Foo{
one?: string;
two?: string;
}
type Foo2 = {
[P in keyof Foo]: number;
}
</code></pre>
<p>I would expect the type of <code>Foo2</code> to be <code>{ one: number; two: number; }</code> However, instead it seems to keep the optional modifier <code>{ one?: number; two?: number; }</code></p>
<p>Is it possible to remove the optional modifier when using mapped types?</p>
| 0debug
|
static void test_tco_second_timeout_none(void)
{
TestData td;
const uint16_t ticks = TCO_SECS_TO_TICKS(256);
QDict *ad;
td.args = "-watchdog-action none";
td.noreboot = false;
test_init(&td);
stop_tco(&td);
clear_tco_status(&td);
reset_on_second_timeout(true);
set_tco_timeout(&td, ticks);
load_tco(&td);
start_tco(&td);
clock_step(ticks * TCO_TICK_NSEC * 2);
ad = get_watchdog_action();
g_assert(!strcmp(qdict_get_str(ad, "action"), "none"));
QDECREF(ad);
stop_tco(&td);
qtest_end();
}
| 1threat
|
Continuous WebJob with timer trigger : <p>I have written following functions in continuous web job :</p>
<pre><code>public static void fun1([TimerTrigger("24:00:00", RunOnStartup = true, UseMonitor = true)] TimerInfo timerInfo, TextWriter log)
{//Code}
public static void fun2([TimerTrigger("00:01:00", RunOnStartup = true, UseMonitor = true)] TimerInfo timerInfo, TextWriter log)
{//code}
</code></pre>
<p>where, fun1 is not getting called again (only once, after starting web job)
and fun2 is getting called with 1 min trigger after every process gets completed.</p>
<p>can anyone please explain why?
Am I doing anything wrong?</p>
| 0debug
|
create an array from elements in a string, elemets start with certain key/sign : <p>I want to abstract an array with text strings that reside in a text, each text element starts with a certain sign or key e.g. $ or &. how can I achieve this?</p>
<p>so "$Huey, $Dewey, and $Louie all live in Duckcity. $Goofy and $Mickey live there too." should result in </p>
<pre><code>string characters = {"Heuy","Dewey", "Louie", "Goofy","Mickey"};
</code></pre>
| 0debug
|
how to identify if checkbox is checked ajax? : <p>When I'm getting E-mail message I can not identify which checkbox is checked.</p>
<p>My JS code looks like this: </p>
<pre><code>$(document).ready(function(){
$('#submit').click(function(){
$.post("submit.php",
{service1: $('#service1').val(),
service2: $('#service2').val(),
function(data){
$('#response').html(data);
}
);
});
</code></pre>
<p>What should I add to my code to identify which is checked?
Thanks</p>
| 0debug
|
static void gen_tlbld_74xx(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
gen_helper_74xx_tlbd(cpu_env, cpu_gpr[rB(ctx->opcode)]);
#endif
}
| 1threat
|
how to change the (image color) of buttons? : <p>I have 4 bottons and I set a image as a background on each button.
What I want to do is that the button should turn into gray when not selected
and turn into its original image color when selected.
how can I do this??</p>
<pre><code> <Button
android:id="@+id/btn_settingTab"
android:layout_width="35dp"
android:layout_height="35dp"
android:background="@drawable/setting_icon"
android:layout_centerHorizontal="true"/>
</code></pre>
| 0debug
|
Hello, i have coded this simple application, what i want now is for my app when reopened to display the last image i had clicked last : <blockquote>
<p>This is the MainActivity code</p>
</blockquote>
<pre><code>public class MainActivity extends AppCompatActivity {
ImageView imageView;
private static final int START_CAMERA_APP = 1;
private String imageFileLocation = "";
private static final int REQUEST_CODE = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = (ImageView)findViewById(R.id.img_cam);
}
</code></pre>
<blockquote>
<p>Method to open the camera</p>
</blockquote>
<pre><code> public void takePhoto (View view)
{
Intent openCamera = new Intent();
openCamera.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
File photoFile = null;
try {
photoFile = createImageFile();
}
catch (IOException e)
{
e.printStackTrace();
}
openCamera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
startActivityForResult(openCamera,START_CAMERA_APP);
}
</code></pre>
<blockquote>
<p>onActivity method to return the captured image</p>
</blockquote>
<pre><code>@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == START_CAMERA_APP && resultCode == RESULT_OK)
{
Bitmap photoCapturedBitmap = BitmapFactory.decodeFile(imageFileLocation);
imageView.setImageBitmap(photoCapturedBitmap);
}
if(requestCode == REQUEST_CODE && resultCode == RESULT_OK)
{
Uri uri = null;
if (data != null)
{
uri = data.getData();
Bitmap bitmap = null;
try {
bitmap = getBitmapFromUri(uri);
imageView.setImageBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
</code></pre>
<blockquote>
<p>Method to create the image</p>
</blockquote>
<pre><code> File createImageFile() throws IOException
{
String timeStamp = new SimpleDateFormat("yyyyMMdd+HHmmss").format(new Date());
String imageFileName = "IMAGE" + timeStamp+ "_";
File storageDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File image = File.createTempFile(imageFileName, ".jpg",storageDirectory);
imageFileLocation = image.getAbsolutePath();
return image;
}
</code></pre>
<blockquote>
<p>And finally methods related to the gallery
public void gallery(View view)
{</p>
</blockquote>
<pre><code> Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("image/*");
startActivityForResult(intent,REQUEST_CODE);
}
private Bitmap getBitmapFromUri (Uri uri) throws IOException
{
ParcelFileDescriptor parcelFileDescriptor = getContentResolver().openFileDescriptor(uri,"r");
FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
Bitmap bitmap = BitmapFactory.decodeFileDescriptor(fileDescriptor);
parcelFileDescriptor.close();
return bitmap;
}
</code></pre>
<p>}</p>
| 0debug
|
static target_long monitor_get_pc (const struct MonitorDef *md, int val)
{
CPUState *env = mon_get_cpu();
if (!env)
return 0;
return env->eip + env->segs[R_CS].base;
}
| 1threat
|
static void spr_write_ibatl_h (void *opaque, int sprn)
{
DisasContext *ctx = opaque;
gen_op_store_ibatl((sprn - SPR_IBAT4L) / 2);
RET_STOP(ctx);
}
| 1threat
|
static int dxv_decompress_raw(AVCodecContext *avctx)
{
DXVContext *ctx = avctx->priv_data;
GetByteContext *gbc = &ctx->gbc;
bytestream2_get_buffer(gbc, ctx->tex_data, ctx->tex_size);
return 0;
}
| 1threat
|
MS SQL query if table exist : Hey all I have the following query:
SELECT
COUNT(*) over () as countNum
,[F1] AS STANDARDandOBJ
,[F2] AS CLUSTER
,[F3] AS OBJECTIVE
,[F4] AS EXTRA0
IF COL_LENGTH([tmpExcelDB].[dbo].['Blahsing$'], [F5]) IS NOT NULL
BEGIN
print 'exists'
END
ELSE
BEGIN
print 'Nope'
END
,CONCAT([F1], [F2]) AS combined
FROM [tmpExcelDB].[dbo].['0812 Orientation to Nursing$']
WHERE
LOWER(F3) NOT LIKE 'course tools-%'
But it seems that I have an error of:
Incorrect syntax near ','.
Which is pointing to row:
> ,CONCAT([F1], [F2]) AS combined
How does this need to be formatted in order to work?
| 0debug
|
What is the meaning of == $0 that is shown in inspect element of google chrome for the selected element : <p>When I used inspect elements in Google Chrome there is always <code>== $0</code> at the end of the selected element. This is something new and I hadn't see it in the older versions of the Google Chrome:</p>
<p><a href="https://i.stack.imgur.com/lMYiw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lMYiw.png" alt="enter image description here"></a></p>
| 0debug
|
static void vga_update_display(void *opaque)
{
VGACommonState *s = opaque;
int full_update, graphic_mode;
qemu_flush_coalesced_mmio_buffer();
if (ds_get_bits_per_pixel(s->ds) == 0) {
} else {
full_update = 0;
if (!(s->ar_index & 0x20) &&
(!(vga_cga_hacks & VGA_CGA_HACK_PALETTE_BLANKING) ||
(s->ar_index != 0 && s->ar_flip_flop))) {
graphic_mode = GMODE_BLANK;
} else {
graphic_mode = s->gr[VGA_GFX_MISC] & VGA_GR06_GRAPHICS_MODE;
}
if (graphic_mode != s->graphic_mode) {
s->graphic_mode = graphic_mode;
s->cursor_blink_time = qemu_get_clock_ms(vm_clock);
full_update = 1;
}
switch(graphic_mode) {
case GMODE_TEXT:
vga_draw_text(s, full_update);
break;
case GMODE_GRAPH:
vga_draw_graphic(s, full_update);
break;
case GMODE_BLANK:
default:
vga_draw_blank(s, full_update);
break;
}
}
}
| 1threat
|
desktop application on Chrome : <p>I have a basic knowledge of html, css and javascript, enough to build some simple web sites. </p>
<p>What I need now is to create a simple desktop application (bookmarks manager), running on Chrome, win7 64bit. </p>
<p>Is it possible without learning a new language and please for some short steps?</p>
| 0debug
|
static void raw_close_fd_pool(BDRVRawState *s)
{
int i;
for (i = 0; i < RAW_FD_POOL_SIZE; i++) {
if (s->fd_pool[i] != -1) {
close(s->fd_pool[i]);
s->fd_pool[i] = -1;
}
}
}
| 1threat
|
org.json.JSONException: No value for answers : https://a.top4top.net/p_480p8eho1.png
in this image my json from webservice
when reguest this webservice all of things done but in answers array give me this exception org.json.JSONException: No value for answers
StringRequest req = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
@Override
public void onResponse(String s) {
try {
questionsList = new ArrayList<QuestionsBean>();
JSONObject jsonObject = new JSONObject(s);
JSONArray question = jsonObject.getJSONArray("questions");
//Log.d("arrayaaaaaaaa: ", question.length() + "");
for (int i = 0; i < question.length(); i++) {
JSONObject x = question.getJSONObject(i);
QuestionsBean u = new QuestionsBean();
u.setDate(x.getString("date"));
u.setQuestion(x.getString("question_text"));
JSONObject bject = new JSONObject();
JSONArray answers = bject.getJSONArray("answers");
for (int j = 0; j < answers.length(); j++) {
JSONObject xx = answers.getJSONObject(i);
u.setAnswer_body(xx.getString("Answer_body"));
}
questionsList.add(u);`enter code here`
| 0debug
|
formControlName in a children component : <p>I would like to create a custom input component and reuse it in my forms, but I am hitting an issue with formGroup and formControlName.</p>
<pre><code>// Form
<form [formGroup]='loginForm'>
<custom-input [myFormControlName]='email'></custom-input>
</form>
// CustomInput Component's Template
<input formControlName='myFormControlName'>
</code></pre>
<p>The problem appears to be that formControlName is expecting to be used with a FormGroup directive and since I am using formControlName in a sub-component it doesn't find the formControlName.. Anyone knows how to work around that?</p>
| 0debug
|
how to adjust table to view content left and right : So i have this code :
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Mizona</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<style type="text/css">
#logo img {
outline: none;
text-decoration: none;
-ms-interpolation-mode: bicubic;
width: auto;
float: none !important;
clear: both;
display: block;
}
td {
word-break:break-word; -webkit-hyphens:auto; -moz-hyphens:auto; hyphens:auto; border-collapse:collapse !important; font-family:'Verdana', 'Arial', sans-serif; font-weight:normal; line-height:19px; font-size:12px; margin:0; padding:0;
}
.desktop-only {
display: block;
}
.mobile-only {
display: none;
}
.no-spacing {
margin: 0px;
padding: 0px;
}
#cover-content a {
color: #0EABD6;
}
img {
max-width: 100%;
}
#cover-content ul {
padding-left: 15px;
}
#socialicons img {
outline: none;
text-decoration: none;
-ms-interpolation-mode: bicubic;
width: auto;
float: none !important;
clear: both;
display: inline-block !important;
border: none;
}
#graphic img {
outline: none;
text-decoration: none;
-ms-interpolation-mode: bicubic;
width: auto;
max-width: 100%;
float: none !important;
clear: both;
display: inline-block !important;
}
.pad-right-5 {
padding-right: 5px;
}
.pad-right-10 {
padding-right: 10px;
}
.pad-right-20 {
padding-right: 20px;
}
.pad-top-10 {
padding-top: 10px;
}
.mobile-center {
text-align: left !important;
}
@media only screen and (max-width: 600px) {
.pad-right-10 {
padding-right: 0px;
}
.desktop-only {
display: none !important;
}
.mobile-center {
text-align: center !important;
}
.mobile-only {
display: block;
}
#logo img {
width: 100% !important;
}
#logo-mobile img {
width: 80% !important;
}
#cover-img img {
max-width: 100%;
}
#graphic img {
width: 100% !important;
height: auto !important;
}
*[class].center {
text-align:center !important;
margin:0 auto !important;
}
*[class].bottom-pad{ padding-bottom:35px !important;}
table[class="body"] table.columns td {
width: auto !important;
}
table[class="body"] table.column td .list {
width: auto !important;
}
table[class="body"] img {
width: auto !important;
height: auto !important;
max-width: 100% !important;
}
table[class="body"] center {
min-width: 0 !important;
}
table[class="body"] .container {
width: 100% !important;
}
table[class="body"] .row {
width: 100% !important;
display: block !important;
}
table[class="body"] .wrapper {
display: block !important;
padding-right: 0 !important;
}
table[class="body"] .columns {
table-layout: fixed !important;
float: none !important;
width: 100% !important;
padding-right: 0px !important;
padding-left: 0px !important;
display: block !important;
}
table[class="body"] .column {
table-layout: fixed !important;
float: none !important;
width: 100% !important;
padding-right: 0px !important;
padding-left: 0px !important;
display: block !important;
}
table[class="body"] .wrapper.first .columns {
display: table !important;
}
table[class="body"] .wrapper.first .column {
display: table !important;
}
table[class="body"] table.columns td {
width: 100% !important;
}
table[class="body"] table.column td {
width: 100% !important;
}
table[class="body"] .columns td {
width: 100% !important;
display: block;
}
table[class="body"] .column td {
width: 100% !important;
display: block;
}
table[class="body"] td.offset-by-one {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-two {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-three {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-four {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-five {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-six {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-seven {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-eight {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-nine {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-ten {
padding-left: 0 !important;
}
table[class="body"] td.offset-by-eleven {
padding-left: 0 !important;
}
table[class="body"] table.columns td.expander {
width: 1px !important;
}
table[class="body"] .right-text-pad {
padding-left: 10px !important;
}
table[class="body"] .text-pad-right {
padding-left: 10px !important;
}
table[class="body"] .left-text-pad {
padding-right: 10px !important;
}
table[class="body"] .text-pad-left {
padding-right: 10px !important;
}
table[class="body"] .hide-for-small {
display: none !important;
}
table[class="body"] .show-for-desktop {
display: none !important;
}
table[class="body"] .show-for-small {
display: inherit !important;
}
table[class="body"] .hide-for-desktop {
display: inherit !important;
}
.social-icon td img {
width: 40px !important;
height: 40px !important;
}
}
</style>
</head>
<body style="width:100% !important; min-width:100%; -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%; text-align:left; line-height:19px; font-size:12px; margin:0; padding:0; background:#eeeeee; ">
<table class="body" style="border-spacing:0; border-collapse:collapse; vertical-align:top; text-align:left; height:100%; width:100%; line-height:19px; font-size:12px; background:#eeeeee; margin:0; padding:0; " bgcolor="#EEEEEE">
<tbody>
<tr style="vertical-align:top; text-align:left; padding:0; " align="left">
<td class="center" align="center" valign="top" style="word-break:break-word; -webkit-hyphens:auto; -moz-hyphens:auto; hyphens:auto; border-collapse:collapse !important; vertical-align:top; text-align:center; font-weight:normal; line-height:19px; font-size:12px; margin:0; padding:0; ">
<center style="width:100%; min-width:580px; ">
<table class="container mktoContainer" id="template-wrapper" style="border-spacing:0; border-collapse:collapse; vertical-align:top; text-align:inherit; width:580px; background:#ffffff; margin:0 auto; padding:0; " bgcolor="#FFFFFF">
<tbody>
<tr class="mktoModule" id="main-header" mktoname="main-header" style="vertical-align:top; text-align:left; padding:0; " align="left">
<td class="center" style="word-break:break-word; -webkit-hyphens:auto; -moz-hyphens:auto; hyphens:auto; vertical-align:top; text-align:left; margin:0; padding:0;" align="left" valign="top">
<table class="row" style="border-spacing:0; border-collapse:collapse; vertical-align:top; text-align:left; width:100%; position:relative; display:block; padding:0px; ">
<tbody>
<tr style="vertical-align:top; text-align:left; padding:0; " align="left">
<td class="wrapper last center" style="word-break:break-word; -webkit-hyphens:auto; -moz-hyphens:auto; hyphens:auto; border-collapse:collapse !important; vertical-align:top; text-align:left; position:relative; color:#555555; line-height:19px; -webkit-transition:font-size 1s ease-in-out !important; font-size:12px; margin:0; padding:0px; " align="left" valign="top">
<table class="twelve columns center desktop-only" style="border-spacing:0; border-collapse:collapse; vertical-align:top; text-align:left; width:580px; padding:0; display:table !important; ">
<tbody>
<tr style="vertical-align:top; text-align:left; padding:0; " align="left">
<td class="center" style="word-break:break-word; -webkit-hyphens:auto; -moz-hyphens:auto; hyphens:auto; border-collapse:collapse !important; vertical-align:top; text-align:left; color:#555555; line-height:19px; -webkit-transition:font-size 1s ease-in-out !important; font-size:12px; margin:0; padding:0px; " align="left" valign="top">
<div class="mktEditable" id="logo" style="" mktoname="logo">
<img src="http://info.eoriginal.com/rs/907-BBE-942/images/nl-header-demand-gen-promo-v2.jpg" alt="eO Logo White.png" constrain="true" imagepreview="false" style="max-width: 600px;" />
</div> </td>
</tr>
</tbody>
</table> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr class="mktoModule" id="mod-padding-10" mktoname="mod-padding-10" style="vertical-align:top; text-align:left; padding:0; color: #555555;" align="left">
<td style="padding: 10px 40px"> </td>
</tr>
<tr class="mktoModule" id="mod-cover" mktoname="mod-cover" style="text-align:left; padding:0; color: #555555;" align="left">
<td style="padding: 10px 40px">
<table class="columns" width="100%">
<tbody>
<tr valign="top">
<td align="left">
<div class="mktEditable" id="cover-img" mktoname="cover-img">
<h4 style="font-family: Verdana; color: #2ea049;"><span style="font-size: 14px;">{{My.Campaign-Headline}}</span></h4>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td bgcolor="#0EABD6" style="padding: 12px 18px 12px 18px; border-radius:0px" align="center">
<div id="cta2" class="mktEditable" style="" mktoname="cta2">
<p class="no-spacing"><a href="{{my.Fulfillment-CTA-URL}}" target="_blank" style="font-size: 14px; font-weight: normal; color: #ffffff; text-decoration: none; display: inline-block;">Request a Meeting</a></p>
</div>
</td>
</tr>
</tbody>
</table>
</div> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr class="mktoModule" id="mod-cover" mktoname="mod-cover" style="vertical-align:top; text-align:left; padding:0; color: #555555;" align="right">
<td style="padding: 10px 40px">
<table class="columns" width="100%">
<tbody>
<tr valign="top">
<td align="right">
<div class="mktEditable" id="cover-img" mktoname="cover-img">
<p class="no-spacing"><img src="{{my.Image-Thumb}}" width="250" /></p>
</div> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr class="mktoModule" id="mod-content" mktoname="mod-content" style="vertical-align:top; text-align:left; padding:0; color: #555555;">
<td style="padding: 0px 40px">
<table class="columns" width="100%">
<tbody>
<tr valign="top">
<td align="left">
<div class="mktEditable" id="cover-content" mktoname="cover-content">
<p style="font-family: Verdana;"><span style="font-size: 14px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</span></p>
</div> <br />
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr class="mktoModule" id="mod-cta" mktoname="mod-cta" style="vertical-align:top; padding:0;">
<td style="padding: 0px 40px;" align="center">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="center">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td bgcolor="#0EABD6" style="padding: 12px 18px 12px 18px; border-radius:0px" align="center">
<div id="cta2" class="mktEditable" style="" mktoname="cta2">
<p class="no-spacing"><a href="{{my.Fulfillment-CTA-URL}}" target="_blank" style="font-size: 14px; font-weight: normal; color: #ffffff; text-decoration: none; display: inline-block;">Request a Meeting</a></p>
</div>
</td>
</tr>
</tbody>
</table> <br />
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr class="mktoModule" id="social" mktoname="social" bgcolor="#2EA049">
<td class="two-column" style="font-size: 0; text-align: center;">
<div class="rcolumn" style="width: 100%; max-width: 295px; display: inline-block; vertical-align: top;">
<table width="100%">
<tbody>
<tr>
<td class="inner mobile-center" style="font-size: 10px; color: #FFFFFF; padding: 20px 40px;"> <a href="http://go.eoriginal.com/JB3eB005bE0cHk00O000000" target="_blank" style="text-decoration:none; color:#ffffff">eOriginal.com</a> </td>
</tr>
</tbody>
</table>
</div>
<div class="rcolumn" style="width: 100%; max-width: 295px; display: inline-block; vertical-align: top;">
<table width="100%">
<tbody>
<tr>
<td class="inner" style="font-size: 10px; color: #FFFFFF; padding: 10px 40px;">
<table align="center" border="0" cellpadding="0" cellspacing="0" style="width: 100%">
<tbody>
<tr>
<td align="left" valign="middle" width="50"><a href="https://twitter.com/eOriginal/" style="text-decoration:none;" target="_blank"><img alt="Twitter" src="https://eoriginal.wise-portal.com/newsletter/public/social-twitter-icon.png" style="color: #FFFFFF; font-size: 12px; " width="40" height="40" /></a></td>
<td align="left" valign="middle" width="50"><a href="https://www.linkedin.com/company/57606" style="text-decoration:none;" target="_blank"><img alt="LinkedIn" src="https://eoriginal.wise-portal.com/newsletter/public/social-linkedin-icon.png" style="color: #FFFFFF; font-size: 12px; " width="40" height="40" /></a></td>
<td align="left" valign="middle" width="50"><a href="http://www.facebook.com/pages/eOriginal/58932553996/" style="text-decoration:none;" target="_blank"><img alt="Facebook" src="https://eoriginal.wise-portal.com/newsletter/public/social-facebook-icon.png" style="color: #FFFFFF; font-size: 12px;" width="40" height="40" /></a></td>
<td align="left" valign="middle" width="50"><a href="https://www.eoriginal.com/eo-insights/" style="text-decoration:none;" target="_blank"><img alt="Blog" src="https://eoriginal.wise-portal.com/newsletter/public/social-blog-icon.png" style="color: #FFFFFF; font-size: 12px; " width="40" height="40" /></a></td>
</tr>
</tbody>
</table> </td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
<tr class="mktoModule" id="footer" mktoname="footer" bgcolor="#353937">
<td class="two-column" style="font-size: 0; text-align: center;">
<div class="rcolumn" style="width: 100%; max-width: 295px; display: inline-block; vertical-align: top;">
<table width="100%">
<tbody>
<tr>
<td class="inner mobile-center" style="font-size: 10px; color: #FFFFFF; padding: 10px 40px;"> <img src="http://info.eoriginal.com/rs/907-BBE-942/images/nl-footer-logo-v2.2.png" width="200" /><br /><br /> <span>© 2018 eOriginal, Inc. All rights reserved.</span> </td>
</tr>
</tbody>
</table>
</div>
<!--[if (gte mso 9)|(IE)]>
</td><td width="50%" valign="top">
<![endif]-->
<div class="rcolumn" style="width: 100%; max-width: 295px; display: inline-block; vertical-align: top;">
<table width="100%">
<tbody>
<tr>
<td class="inner mobile-center" style="font-size: 10px; color: #FFFFFF; padding: 10px 40px;"> The Warehouse at Camden Yards<br /> 351 W. Camden St., Suite 800<br /> Baltimore, MD 21201<br /><br /> SALES <span style="color: #2EA049">1-866-935-1776</span><br />SUPPORT <span style="color: #2EA049">1-866-364-3578</span> </td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
</center> </td>
</tr>
</tbody>
</table>
</body>
</html>
<!-- end snippet -->
based on this code above what i get is like this:
[![enter image description here][1]][1]
so as you can see the topic and button will view above the picture. But what im trying to achieve is to make the topic/button and image to view beside each other like this:
[![enter image description here][2]][2]
How can i achieve this ? If possible i'd like a 60 to 40 ratio. 40 being the image.
[1]: https://i.stack.imgur.com/xqjq8.png
[2]: https://i.stack.imgur.com/YcRle.png
| 0debug
|
If a user inputs a 4 digit int, how do I use an array to extract each digit? : <p>I'm creating a very basic encryption program, and I'm stuck. Essentially the user inputs a 4 digit int using a scanner and my goal is to, encrypt each digit, using a set formula. But i can't figure out how to, extract each digit and insert it into the formula. if anyone knows the simplest way of doing so, id really appreciate it. </p>
| 0debug
|
availability set azure fault domain & update domain : Q.I have 2 servers.so i ll have 2 FD(FD0, FD1) & 2 UD(UD0, UD1). what if UD0 is down & at the same time the FD1 goes down due some reason. so what will happen ?
| 0debug
|
Call from TableView Swift2 : I have anything like that
http://i.imgur.com/Hmjidup.png
I want when I push on the right number call. I try with **tel//:** but don't work. Is possible?
Thanks!
| 0debug
|
c# Linq List<T>.Where().ToList() create new instances of <T> : <p>I have a class, Solution.
I use this class as a List which I don't want to grow unnecessarily.</p>
<p>I search the list to get a preexisting entry and return that -or- create a new entry if need be:</p>
<pre><code>var s0 = _solutions.Where(x => x.strtId == strtNodeId && x.endId == endNodeId).ToList();
</code></pre>
<p>However, Linq will actually create new instances when where is true.
But, as you might already see, that is not what I want.</p>
<p>The combination of <code>x.startNode && x.endNode</code> is unique in all instances of <code>_solution</code></p>
<p>At the end what I need is the reference to the one instance of _solution being searched for, if it already exists.</p>
<p>But what can I do aside from creating my own for loop/s?</p>
<p>Thanks.</p>
| 0debug
|
Displaying iReport from jFrame by jButton click event : I am using NetBeans 8.0.2. I have already created iReport using iReport5.6.0. After designing I moved it into my existing Java Application project in NetBeans into new folder called **reports**. My jFrame file **reportform.java** is in same project under **appfolder**. I wish to display/preview my already created report by click of a Button on jFrame **reportform.java**. My report is working/displaying fine otherwise in the same project.
| 0debug
|
Is CppCoreGuidelines C.21 correct? : <p>While reading the Bjarne Stroustrup's CoreCppGuidelines, I have found a guideline which contradicts my experience.</p>
<p>The <a href="https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rc-five">C.21</a> requires the following:</p>
<blockquote>
<p>If you define or <code>=delete</code> any default operation, define or <code>=delete</code> them all</p>
</blockquote>
<p>With the following reason:</p>
<blockquote>
<p>The semantics of the special functions are closely related, so if one needs to be non-default, the odds are that others need modification too.</p>
</blockquote>
<p>From my experience, the two most common situations of redefinition of default operations are the following:</p>
<p>#1: Definition of virtual destructor with default body to allow inheritance:</p>
<pre><code>class C1
{
...
virtual ~C1() = default;
}
</code></pre>
<p>#2: Definition of default constructor making some initialization of RAII-typed members:</p>
<pre><code>class C2
{
public:
int a; float b; std::string c; std::unique_ptr<int> x;
C2() : a(0), b(1), c("2"), x(std::make_unique<int>(5))
{}
}
</code></pre>
<p>All other situations were rare in my experience.</p>
<p>What do you think of these examples? Are they exceptions of the C.21 rule or it's better to define all default operations here? Are there any other frequent exceptions?</p>
| 0debug
|
static void add_pc_test_case(const char *mname)
{
char *path;
PlugTestData *data;
if (!g_str_has_prefix(mname, "pc-")) {
return;
}
data = g_new(PlugTestData, 1);
data->machine = g_strdup(mname);
data->cpu_model = "Haswell";
data->sockets = 1;
data->cores = 3;
data->threads = 2;
data->maxcpus = data->sockets * data->cores * data->threads * 2;
if (g_str_has_suffix(mname, "-1.4") ||
(strcmp(mname, "pc-1.3") == 0) ||
(strcmp(mname, "pc-1.2") == 0) ||
(strcmp(mname, "pc-1.1") == 0) ||
(strcmp(mname, "pc-1.0") == 0) ||
(strcmp(mname, "pc-0.15") == 0) ||
(strcmp(mname, "pc-0.14") == 0) ||
(strcmp(mname, "pc-0.13") == 0) ||
(strcmp(mname, "pc-0.12") == 0) ||
(strcmp(mname, "pc-0.11") == 0) ||
(strcmp(mname, "pc-0.10") == 0)) {
path = g_strdup_printf("cpu/%s/init/%ux%ux%u&maxcpus=%u",
mname, data->sockets, data->cores,
data->threads, data->maxcpus);
qtest_add_data_func_full(path, data, test_plug_without_cpu_add,
test_data_free);
g_free(path);
} else {
path = g_strdup_printf("cpu/%s/add/%ux%ux%u&maxcpus=%u",
mname, data->sockets, data->cores,
data->threads, data->maxcpus);
qtest_add_data_func_full(path, data, test_plug_with_cpu_add,
test_data_free);
g_free(path);
}
}
| 1threat
|
How to generate two colors randomly in JS with slight difference : How to generate two colors with rgb format in js which are similar but slight difference in shade. See the image for clearance. Ignore the rest coding just provide the random JS functions to show these.
[enter image description here][1]
[1]: https://i.stack.imgur.com/CIRdx.jpg
| 0debug
|
How does JavaScript deals with value which is unknown? : <p>I am new to JavaScript and reading a <a href="http://eloquentjavascript.net/03_functions.html" rel="nofollow noreferrer">book</a> and in recursive chapter, there is an example as follow</p>
<pre><code>function findSolution(target) {
function find(current, history) {
if (current == target)
return history;
else if (current > target)
return null;
else
return find(current + 5, "(" + history + " + 5)") ||
find(current * 3, "(" + history + " * 3)");
}
*return find(1, "1"); // when will this run?
}
console.log(findSolution(24));
// → (((1 * 3) + 5) * 3)
</code></pre>
<p>I am unable to understand how does JavaScript will run these causes as it expects a value of <code>current</code> in all three <code>if</code> cases? But the author is just running the outside of function which takes <code>target</code> as an argument, not the <code>current</code>. Does it take value of current and history from </p>
<pre><code>return find(1,"1")
</code></pre>
<p>like in hoisting?</p>
| 0debug
|
URL Blocked: This redirect failed because the redirect URI is not whitelisted....(Localhost web application) : <p>URL Blocked: This redirect failed because the redirect URI is not whitelisted in the app’s Client OAuth Settings. Make sure Client and Web OAuth Login are on and add all your app domains as Valid OAuth Redirect URIs.</p>
<p>I've installed the laravel/socialite and I'm trying to link my application with facebook ! after installing the package ,creating my facebook application , I try to acces to the login page with facebook on my application but it keeps telling me that ther's some kind of URL errors ... ??? any ideas.?</p>
| 0debug
|
int qcow2_refcount_init(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
unsigned int refcount_table_size2, i;
int ret;
assert(s->refcount_table_size <= INT_MAX / sizeof(uint64_t));
refcount_table_size2 = s->refcount_table_size * sizeof(uint64_t);
s->refcount_table = g_try_malloc(refcount_table_size2);
if (s->refcount_table_size > 0) {
if (s->refcount_table == NULL) {
goto fail;
}
BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_LOAD);
ret = bdrv_pread(bs->file, s->refcount_table_offset,
s->refcount_table, refcount_table_size2);
if (ret != refcount_table_size2)
goto fail;
for(i = 0; i < s->refcount_table_size; i++)
be64_to_cpus(&s->refcount_table[i]);
}
return 0;
fail:
return -ENOMEM;
}
| 1threat
|
How to use Laravel Passport with Password Grant Tokens? : <p>I just read the <a href="https://laravel.com/docs/5.6/passport" rel="noreferrer">https://laravel.com/docs/5.6/passport</a> documentation and I have some doubts that hopefully someone could help me with:</p>
<p>First, some context, I want to use Passport as a way to provide Oauth authentication for my mobile app (first-party app).</p>
<ol>
<li><p>When I use <code>php artisan passport:client --password</code> I get back a Client ID and a Client Secret. Does this value have to be fixed on my app? for example storing them hardcoded or as a "settings" file? If the values shouldn't be stored then how should it work?</p></li>
<li><p>To register a user to my app I use: <code>$user->createToken('The-App')->accessToken;</code> I get that the accessToken will be the one used for sending on all my requests as a Header (Authorization => Bearer $accessToken) but what exactly is "The-App" value for?</p></li>
<li><p>For login the user I'm using the URL: <a href="http://example.com/oauth/token" rel="noreferrer">http://example.com/oauth/token</a> and sending as parameters: </p>
<p>{
"username": "user@email.com",
"password": "userpassword",
"grant_type": "password",
"client_id": 1, // The Client ID that I got from the command (question 1)
"client_secret": "Shhh" // The Client Secret that I got from the command (question 1)
}</p></li>
<li><p>When I login the user using the previous endpoint I get back a refresh_token, I read that I could refresh the token through <a href="http://example.com/oauth/token/refresh" rel="noreferrer">http://example.com/oauth/token/refresh</a> but I try to request the refresh I got Error 419, I removed the url oauth/token/refresh from the csrf verification and now I get back <code>"message": "Unauthenticated."</code>, I'm making the following request:</p>
<p>Content-Type: x-www-form-urlencoded
grant_type: refresh_token
refresh_token: the-refresh-token // The Refresh Token that I got from the command (question 3)
client_id: 1 // The Client ID that I got from the command (question 1)
client_secret: Shhh // The Client Secret that I got from the command (question 1)
scope: ''</p></li>
</ol>
<p>Should I use this endpoint? or is not necessary given the app I'm trying to develop.</p>
<ol start="5">
<li>Finally, there are a lot of endpoints that I get from passport that I don't think I will use for example: <code>oauth/clients*</code>, <code>oauth/personal-access-tokens*</code> is there a way to remove them from the endpoints published by passport?</li>
</ol>
<p>Thanks a lot for your help!</p>
| 0debug
|
int kvm_arch_init_vcpu(CPUState *env)
{
struct {
struct kvm_cpuid2 cpuid;
struct kvm_cpuid_entry2 entries[100];
} __attribute__((packed)) cpuid_data;
uint32_t limit, i, j, cpuid_i;
uint32_t eax, ebx, ecx, edx;
cpuid_i = 0;
cpu_x86_cpuid(env, 0, 0, &eax, &ebx, &ecx, &edx);
limit = eax;
for (i = 0; i <= limit; i++) {
struct kvm_cpuid_entry2 *c = &cpuid_data.entries[cpuid_i++];
switch (i) {
case 2: {
int times;
cpu_x86_cpuid(env, i, 0, &eax, &ebx, &ecx, &edx);
times = eax & 0xff;
c->function = i;
c->flags |= KVM_CPUID_FLAG_STATEFUL_FUNC;
c->flags |= KVM_CPUID_FLAG_STATE_READ_NEXT;
c->eax = eax;
c->ebx = ebx;
c->ecx = ecx;
c->edx = edx;
for (j = 1; j < times; ++j) {
cpu_x86_cpuid(env, i, 0, &eax, &ebx, &ecx, &edx);
c->function = i;
c->flags |= KVM_CPUID_FLAG_STATEFUL_FUNC;
c->eax = eax;
c->ebx = ebx;
c->ecx = ecx;
c->edx = edx;
c = &cpuid_data.entries[++cpuid_i];
}
break;
}
case 4:
case 0xb:
case 0xd:
for (j = 0; ; j++) {
cpu_x86_cpuid(env, i, j, &eax, &ebx, &ecx, &edx);
c->function = i;
c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
c->index = j;
c->eax = eax;
c->ebx = ebx;
c->ecx = ecx;
c->edx = edx;
c = &cpuid_data.entries[++cpuid_i];
if (i == 4 && eax == 0)
break;
if (i == 0xb && !(ecx & 0xff00))
break;
if (i == 0xd && eax == 0)
break;
}
break;
default:
cpu_x86_cpuid(env, i, 0, &eax, &ebx, &ecx, &edx);
c->function = i;
c->eax = eax;
c->ebx = ebx;
c->ecx = ecx;
c->edx = edx;
break;
}
}
cpu_x86_cpuid(env, 0x80000000, 0, &eax, &ebx, &ecx, &edx);
limit = eax;
for (i = 0x80000000; i <= limit; i++) {
struct kvm_cpuid_entry2 *c = &cpuid_data.entries[cpuid_i++];
cpu_x86_cpuid(env, i, 0, &eax, &ebx, &ecx, &edx);
c->function = i;
c->eax = eax;
c->ebx = ebx;
c->ecx = ecx;
c->edx = edx;
}
cpuid_data.cpuid.nent = cpuid_i;
return kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
}
| 1threat
|
pandas.factorize on an entire data frame : <p><a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.factorize.html" rel="noreferrer"><code>pandas.factorize</code></a> encodes input values as an enumerated type or categorical variable. </p>
<p>But how can I easily and efficiently convert many columns of a data frame? What about the reverse mapping step?</p>
<p>Example: This data frame contains columns with string values such as "type 2" which I would like to convert to numerical values - and possibly translate them back later.</p>
<p><a href="https://i.stack.imgur.com/MLATh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MLATh.png" alt="enter image description here"></a></p>
| 0debug
|
Is it possible to wget / curl protected files from GCS? : <p>Is it possible to wget / curl protected files from Google Cloud Storage without making them public? I don't mind a fixed predefined token. I just want to avoid the case where my public file gets leeched, costing me good dollars.</p>
| 0debug
|
in C# i wanna compare two Lists : I have two lists
List1 < Labels > lbl and List2 < Strings > value
and I wanna compare both using `foreach` like
if (label1.text == value ) { // value is the 2nd list name
// do something here
}
| 0debug
|
void cpu_dump_state (CPUState *env, FILE *f,
int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
int flags)
{
#define RGPL 4
#define RFPL 4
int i;
cpu_fprintf(f, "NIP " ADDRX " LR " ADDRX " CTR " ADDRX " XER %08x\n",
env->nip, env->lr, env->ctr, env->xer);
cpu_fprintf(f, "MSR " ADDRX " HID0 " ADDRX " HF " ADDRX " idx %d\n",
env->msr, env->spr[SPR_HID0], env->hflags, env->mmu_idx);
#if !defined(NO_TIMER_DUMP)
cpu_fprintf(f, "TB %08x %08x "
#if !defined(CONFIG_USER_ONLY)
"DECR %08x"
#endif
"\n",
cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env)
#if !defined(CONFIG_USER_ONLY)
, cpu_ppc_load_decr(env)
#endif
);
#endif
for (i = 0; i < 32; i++) {
if ((i & (RGPL - 1)) == 0)
cpu_fprintf(f, "GPR%02d", i);
cpu_fprintf(f, " " REGX, ppc_dump_gpr(env, i));
if ((i & (RGPL - 1)) == (RGPL - 1))
cpu_fprintf(f, "\n");
}
cpu_fprintf(f, "CR ");
for (i = 0; i < 8; i++)
cpu_fprintf(f, "%01x", env->crf[i]);
cpu_fprintf(f, " [");
for (i = 0; i < 8; i++) {
char a = '-';
if (env->crf[i] & 0x08)
a = 'L';
else if (env->crf[i] & 0x04)
a = 'G';
else if (env->crf[i] & 0x02)
a = 'E';
cpu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' ');
}
cpu_fprintf(f, " ] RES " ADDRX "\n", env->reserve);
for (i = 0; i < 32; i++) {
if ((i & (RFPL - 1)) == 0)
cpu_fprintf(f, "FPR%02d", i);
cpu_fprintf(f, " %016" PRIx64, *((uint64_t *)&env->fpr[i]));
if ((i & (RFPL - 1)) == (RFPL - 1))
cpu_fprintf(f, "\n");
}
cpu_fprintf(f, "FPSCR %08x\n", env->fpscr);
#if !defined(CONFIG_USER_ONLY)
cpu_fprintf(f, "SRR0 " ADDRX " SRR1 " ADDRX " SDR1 " ADDRX "\n",
env->spr[SPR_SRR0], env->spr[SPR_SRR1], env->sdr1);
#endif
#undef RGPL
#undef RFPL
}
| 1threat
|
int rom_load_all(void)
{
target_phys_addr_t addr = 0;
MemoryRegionSection section;
Rom *rom;
QTAILQ_FOREACH(rom, &roms, next) {
if (rom->fw_file) {
continue;
}
if (addr > rom->addr) {
fprintf(stderr, "rom: requested regions overlap "
"(rom %s. free=0x" TARGET_FMT_plx
", addr=0x" TARGET_FMT_plx ")\n",
rom->name, addr, rom->addr);
return -1;
}
addr = rom->addr;
addr += rom->romsize;
section = memory_region_find(get_system_memory(), rom->addr, 1);
rom->isrom = section.size && memory_region_is_rom(section.mr);
}
qemu_register_reset(rom_reset, NULL);
roms_loaded = 1;
return 0;
}
| 1threat
|
TopShelf: how to integrate topshelf to an existing windows service project? : Bare with me, I am new to TopShelf and Windows Service programming in general.
A lot of the [examples][1] and [documentation][2] out there refer to creating a Windows Console project in Visual Studio **first**, and **then** adding TopShelf.
However, in my case I already have a perfectly good and working Windows Service project called QShipsService.sln, etc... and it uses a simple Connected Service (admittedly to old SOAP legacy services).
Can someone please direct me or provide an example of how to use TopShelf, with an existing non-ConsoleApp project?
Thank you
[1]: https://www.c-sharpcorner.com/article/creating-windows-service-in-net-with-topshelf/
[2]: https://www.youtube.com/watch?v=FUa8RzWpJI0
| 0debug
|
Spring Security blocks POST requests despite SecurityConfig : <p>I'm developing a REST API based on Spring Boot (<code>spring-boot-starter-web</code>) where I use Spring Security (<code>spring-security-core</code> e <code>spring-security-config</code>) to protect the different endpoints.</p>
<p>The authentication is done by using a local database that contains users with two different sets of roles: <code>ADMIN</code> and<code>USER</code>. <code>USER</code> should be able to<code>GET</code> all API endpoints and <code>POST</code> to endpoints based on<code>routeA</code>. <code>ADMIN</code> should be able to do the same as<code>USER</code> plus <code>POST</code> and<code>DELETE</code> to endpoints based on `routeB</p>
<p>However the behavior I'm getting is that I can do <code>GET</code> requests to any endpoint but <code>POST</code> requests always return <code>HTTP 403 Forbidden</code> for either type of user - <code>ADMIN</code> and <code>USER</code> - which is not expected what I'm expecting based on my <code>SecurityConfiguration</code>.</p>
<p>Any ideas of what am I missing?</p>
<hr>
<p><strong>SecurityConfiguration.java</strong>
</p>
<pre><code>@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
private static final Logger logger = LoggerFactory.getLogger(SecurityConfiguration.class);
@Autowired
private RESTAuthenticationEntryPoint authenticationEntryPoint;
@Autowired
private DataSource dataSource;
@Override
public void configure(AuthenticationManagerBuilder builder) throws Exception {
logger.info("Using database as the authentication provider.");
builder.jdbcAuthentication().dataSource(dataSource).passwordEncoder(new BCryptPasswordEncoder());
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().
authorizeRequests().antMatchers(HttpMethod.GET, "/**").hasAnyRole("ADMIN", "USER")
.antMatchers(HttpMethod.POST, "/routeA/*").hasAnyRole("ADMIN", "USER")
.antMatchers(HttpMethod.POST, "/routeB/*").hasRole("ADMIN")
.antMatchers(HttpMethod.DELETE, "/routeB/*").hasRole("ADMIN").and().
requestCache().requestCache(new NullRequestCache()).and().
httpBasic().authenticationEntryPoint(authenticationEntryPoint).and().
cors();
}
@Bean
public CorsConfigurationSource corsConfigurationSource() {
final CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(Arrays.asList("*"));
configuration.setAllowedMethods(Arrays.asList("HEAD", "GET", "POST", "PUT", "DELETE", "PATCH"));
configuration.setAllowCredentials(true);
configuration.setAllowedHeaders(Arrays.asList("Authorization", "Cache-Control", "Content-Type"));
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}
</code></pre>
<p><strong>RouteBController .java</strong>
</p>
<pre><code>@RestController
public class RouteBController {
static final Logger logger = LoggerFactory.getLogger(RouteBController.class);
public RouteBController() { }
@RequestMapping(value = "routeB", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, method = RequestMethod.GET)
public String getStuff() {
return "Got a hello world!";
}
@RequestMapping(value = "routeB", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, method = RequestMethod.POST)
public String postStuff() {
return "Posted a hello world!";
}
}
</code></pre>
<p><strong>RESTAuthenticationEntryPoint.java</strong>
</p>
<pre><code>@Component
public class RESTAuthenticationEntryPoint extends BasicAuthenticationEntryPoint {
@Override
public void afterPropertiesSet() throws Exception {
setRealmName("AppNameHere");
super.afterPropertiesSet();
}
}
</code></pre>
| 0debug
|
static ssize_t qsb_get_iovec(const QEMUSizedBuffer *qsb,
off_t pos, off_t *d_off)
{
ssize_t i;
off_t curr = 0;
if (pos > qsb->used) {
return -1;
}
for (i = 0; i < qsb->n_iov; i++) {
if (curr + qsb->iov[i].iov_len > pos) {
*d_off = pos - curr;
return i;
}
curr += qsb->iov[i].iov_len;
}
return -1;
}
| 1threat
|
Any good tutorial on Bot Framework? : I have started developing project in Bot Framework C#, however, I am just a beginner (like creating hello world, dialog exchange with simple if else condition ). I have some basic knowledge on FormFlow and Dialog. But I am unable to go beyond this. I have gone through several tutorial sites including StackOverflow (others include https://dev.botframework.com, http://aihelpwebsite.com etc) and even downloaded some sample codes in C#. But many are way above my head. Just need a good Book/website which I can refer to always and gain my knowledge bit by bit. Not in a hurry to learn , but just need something systematic.
| 0debug
|
How to Build lora network : <p>I want to make Lora network in india that helps to receive node(sensor) data within 2km to 3km range in urban area.</p>
<p>I had read some tutorial but I have some doubts...</p>
<p>1)can we use single channel gateway without license? (because in india 868mhz is not free)</p>
<p>2)is it required to use TTN server or can we even use our own server to send data from gateway.</p>
<p>3)is lora protocol free to implement?</p>
| 0debug
|
Rolify Table Error (user.add_role :admin Unknown Key Error) : <p>I'm attempting to setup the rolify gem and I'm running into an issue assigning a role to a user in the console.</p>
<p>Here's my error: </p>
<pre><code>2.2.1 :007 > user.add_role :admin
ArgumentError: Unknown key: :optional.
</code></pre>
<p>I'm running devise with cancancan and rolify. I'm also running the Koudoku gem for subscription payment support. I'm suspecting this error might be caused by the fact that my "subscriptions" table also has a "user_id" column. Is there anything I can do to correct this issue?</p>
<p>Here's my schema.</p>
<pre><code>create_table "subscriptions", force: :cascade do |t|
t.string "stripe_id"
t.integer "plan_id"
t.string "last_four"
t.integer "coupon_id"
t.string "card_type"
t.float "current_price"
t.integer "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "first_name"
t.string "string"
t.string "last_name"
end
add_index "users", ["email"], name: "index_users_on_email", unique: true
add_index "users", ["reset_password_token"], name:
"index_users_on_reset_password_token", unique: true
create_table "users_roles", id: false, force: :cascade do |t|
t.integer "user_id"
t.integer "role_id"
end
add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id"
end
</code></pre>
<p>Thanks.</p>
| 0debug
|
Find case insensitive word or sentence in a body of text - PHP : <p>I am a complete newbie in PHP and programming generally. I am looking for an example or function of searching a sentence or a word in a body of text.</p>
<p>Thanks,</p>
<p>Matt</p>
| 0debug
|
static void scsi_command_complete(SCSIDiskReq *r, int status, int sense)
{
DPRINTF("Command complete tag=0x%x status=%d sense=%d\n",
r->req.tag, status, sense);
scsi_req_set_status(r, status, sense);
scsi_req_complete(&r->req);
scsi_remove_request(r);
}
| 1threat
|
What does "^=" in c++ mean? : <p>I read mutation of genetic algorithm in this post:
<a href="https://stackoverflow.com/questions/4725515/c-genetic-algorithm-mutation-error">c++ Genetic Algorithm Mutation error</a></p>
<p>What does <code>^=</code> mean in <code>Child1.binary_code[z] ^= 1</code>?
Thank you in advance.</p>
| 0debug
|
Array of json into json object : <p>I am trying to convert array of json into json object is this the correct syntax in java script file</p>
<pre><code>var request = {"data":[{
"contractorName": param.contractorName,
"hoursWorked": param.hoursWorked,
"hourlyRate": param.hourlyRate,
"paymentAmount": param.paymentAmount,
"workerUserId": param.workerUserId
}]
}
</code></pre>
| 0debug
|
What is the fastest way to empty s3 bucket using boto3? : <p>I was thinking about deleting and then re-creating bucket (bad option which I realised later).</p>
<p>Then how can delete all objects from the bucket?</p>
<p>I tried this : <a href="http://boto3.readthedocs.io/en/latest/reference/services/s3.html#S3.Bucket.delete_objects" rel="noreferrer">http://boto3.readthedocs.io/en/latest/reference/services/s3.html#S3.Bucket.delete_objects</a></p>
<p>But it deletes multiple objects not all.</p>
<p>can you suggest what is the best way to empty bucket ?</p>
| 0debug
|
Do all UWP apps leak memory when navigating pages? : <p>So I've been getting my teeth into UWP and developing a simple app in C# using VS2017 v15.6.4, on the latest release of Windows 10.</p>
<p>When running the app I notice its memory usage continues to increase over time.</p>
<p>After a lot of pairing back of the code, I've come to the conclusion that this is being caused by page navigation calls, such as:</p>
<pre><code>Frame.Navigate(typeof SomePage);
Frame.GoBack();
Frame.GoForward();
</code></pre>
<p>It is very easy to create and observe this process...</p>
<p>1) In VS2017, create a new Blank App (Universal Windows) project, call it PageTest.</p>
<p>2) Add a new Blank Page to the project, naming it 'NewPage'.</p>
<p>3) Add the following code to the MainPage.xaml.cs:</p>
<pre><code>using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace PageTest
{
public sealed partial class MainPage : Page
{
DispatcherTimer timer = new DispatcherTimer();
public MainPage()
{
InitializeComponent();
timer.Interval = TimeSpan.FromSeconds(.01);
timer.Tick += Timer_Tick;
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
timer.Start();
}
private void Timer_Tick(object sender, object e)
{
timer.Stop();
Frame.Navigate(typeof(NewPage));
}
}
}
</code></pre>
<p>4) Add the following (almost identical) code to NewPage.xaml.cs:</p>
<pre><code>using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace PageTest
{
public sealed partial class NewPage : Page
{
DispatcherTimer timer = new DispatcherTimer();
public NewPage()
{
InitializeComponent();
timer.Interval = TimeSpan.FromSeconds(.01);
timer.Tick += Timer_Tick;
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
timer.Start();
}
private void Timer_Tick(object sender, object e)
{
timer.Stop();
Frame.Navigate(typeof(MainPage));
}
}
}
</code></pre>
<p>You can see that this simple test app contains 2 pages, and when it runs, the app will automatically navigate between the two pages at the rate of 100 times per second (via the timers) until you close the app.</p>
<p>5) Build and run the app. Also run Task Manager and note the app's initial memory footprint.</p>
<p>6) Go and make a cup of coffee. When you come back you'll see the memory usage has grown. And it will continue to grow.</p>
<p>Now I know this example is unrealistic, but it is here purely to demonstrate what I suspect is a fundamental problem affecting most (if not all) UWP apps.</p>
<p>Try this...</p>
<p>Run the Windows 10 Settings app (a UWP app developed by Microsoft). Again, note it's initial memory footprint in Task Manager. (On my kit this starts at about 12.1 MB).</p>
<p>Then repeatedly click on the System Settings icon... then the Back button... then the System Settings icon... then the Back button... You get the idea. And watch the memory footprint also increase.</p>
<p>After a few minutes of doing this, my MS Settings app memory consumption went up to over 90 MB.</p>
<p>This memory consumption seems to be related to UWP page complexity and it goes up rapidly if you start adding a lot of XAML controls to your pages, especially Image controls. And it doesn't take long before my feature rich UWP app is consuming 1-2GB memory.</p>
<p>So this 'problem' seems to affect all frame based UWP apps. I've tried it with other UWP apps on 3 different PC's and I see the same problem on them all.</p>
<p>With my feature rich app, memory consumption has got so bad that I'm now considering scrapping Page navigation altogether and putting everything on the MainPage. Which is not a pleasant thought.</p>
<p><strong>Potential Solutions That Don't Work...</strong></p>
<p>I've come across other articles describing a similar issue and there are proposed solutions that I've tried, which don't make any difference...</p>
<p>1) Adding either of the following lines to the .xaml page definitions does not help...</p>
<pre><code>NavigationCacheMode="Required"
NavigationCacheMode="Enabled"
</code></pre>
<p>2) Manually forcing garbage collection when switching pages does not help. So doing something like this makes no difference...</p>
<pre><code>protected override void OnNavigatedFrom(NavigationEventArgs e)
{
GC.Collect();
}
</code></pre>
<p><strong>Does anyone know if there a solution to this, or is it a fundamental issue with UWP apps?</strong></p>
| 0debug
|
Rust - need vector slices to live longer : 13 fn populate_chain(file_path: &str) -> HashMap<String, HashSet<& String>>{
14 println!("loading...");
15 let time = util::StopWatch::new();
16 let mut words = HashMap::new();
17 {
18 let f = |mut x:Vec<String>|{
19 let word = x.pop().unwrap();
20 words.insert(word, HashSet::new());
21 };
22 Csv::process_rows(f, file_path, "\t");
23 }
24
25 let col: Vec<(String, HashSet<& String>)> = words.clone().into_iter().collect();
26 let m: usize = col.len()-1;
27 for i in 0..m{
28 ¦ let ref k: String = col[i].0;
29 ¦ for j in i..m{
30 ¦ ¦ let ref nk: String = col[j].0;
31 ¦ ¦ if check_link(k, nk){
32 ¦ ¦ ¦ words.get_mut(k).unwrap().insert(nk);
33 ¦ ¦ ¦ words.get_mut(nk).unwrap().insert(k);
34 ¦ ¦ }
35 ¦ }
36 }
37
38 time.print_time();
39 words
40 }
Is there any way to get the slices of this vector to last long enough so that I can use them in this kind of circular structure?
I'm basically just using the double four loops to chain words together which are related so that they can be quickly looked up later.
Here are the compiler errors...
error: `col` does not live long enough
--> src/main.rs:28:29
|
28 | let ref k: String = col[i].0;
| ^^^ does not live long enough
...
40 | }
| - borrowed value only lives until here
|
note: borrowed value must be valid for the anonymous lifetime #1 defined on the block at 13:72...
--> src/main.rs:13:73
|
13 | fn populate_chain(file_path: &str) -> HashMap<String, HashSet<& String>>{
| ^
error: `col` does not live long enough
--> src/main.rs:30:34
|
30 | let ref nk: String = col[j].0;
| ^^^ does not live long enough
...
40 | }
| - borrowed value only lives until here
|
note: borrowed value must be valid for the anonymous lifetime #1 defined on the block at 13:72...
--> src/main.rs:13:73
|
13 | fn populate_chain(file_path: &str) -> HashMap<String, HashSet<& String>>{
|
| 0debug
|
static int decode_cabac_mb_cbp_chroma( H264Context *h) {
int ctx;
int cbp_a, cbp_b;
cbp_a = (h->left_cbp>>4)&0x03;
cbp_b = (h-> top_cbp>>4)&0x03;
ctx = 0;
if( cbp_a > 0 ) ctx++;
if( cbp_b > 0 ) ctx += 2;
if( get_cabac( &h->cabac, &h->cabac_state[77 + ctx] ) == 0 )
return 0;
ctx = 4;
if( cbp_a == 2 ) ctx++;
if( cbp_b == 2 ) ctx += 2;
return 1 + get_cabac( &h->cabac, &h->cabac_state[77 + ctx] );
}
| 1threat
|
Creating Hyper-V Administrators group in Windows 10 : <p>I am receiving the error "Unable to add user to the Hyper-V Administrators group. Exit code 2220" while attempting to deploy to an MS Android emulator. I am able to deploy windows mobile emulators as well as Linux VMs in Hyper-V.</p>
<ul>
<li>Windows 10 Pro</li>
<li>Visual Studio 2015 Professional Update 1</li>
<li>MS VS Emulator for Android 1.0.60106.1</li>
<li>Xamarin 4.0.0.1717</li>
</ul>
<p>I do not have a Hyper-V Administrators group. Numerous questions and blogs have suggested that I uninstall Hyper-V and reinstall. I tried this, it didn't create the Hyper-V Administrators group.</p>
<p>I've read several articles from Ben Armstrong (aka twitter @virtualpcguy) a Hyper-V Program Manager on how to manually create/add users to the group, as well as some powershell scripts to automate this. Unfortunately these are based on Server 2008 R2, Windows 7, and Windows 8. In my reading it looks like windows 10 does not use <strong>InitialStore.xml</strong> </p>
<ul>
<li><a href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2008/01/17/allowing-non-administrators-to-control-hyper-v.aspx">Allowing non-Administrators to control Hyper-V</a></li>
<li><a href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2014/06/11/allowing-non-administrators-to-control-hyper-v-updated.aspx">Allowing non-Administrators to control Hyper-V–Updated</a></li>
<li><a href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2010/09/28/creating-a-hyper-v-administrators-local-group-through-powershell.aspx">Creating a “Hyper-V Administrators” local group through PowerShell</a></li>
<li><a href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2010/09/27/setting-up-non-administrative-control-of-hyper-v-through-powershell.aspx">Setting up non-administrative control of Hyper-V through PowerShell</a></li>
</ul>
<p>Although I can manually add a group, Hyper-V Administrators, using lusrmgr.msc and add myself as a user I don't know how to apply the permissions for Hyper-V.</p>
<p>Note: This Windows 10 was installed with a non pro version, then upgraded to Pro. Might this be a factor in the missing Hyper-V Supervisors group? </p>
| 0debug
|
void helper_memalign(uint32_t addr, uint32_t dr, uint32_t wr, uint32_t size)
{
uint32_t mask;
switch (size) {
case 4: mask = 3; break;
case 2: mask = 1; break;
default:
case 1: mask = 0; break;
}
if (addr & mask) {
qemu_log("unaligned access addr=%x size=%d, wr=%d\n",
addr, size, wr);
if (!(env->sregs[SR_MSR] & MSR_EE)) {
return;
}
env->sregs[SR_ESR] = ESR_EC_UNALIGNED_DATA | (wr << 10) \
| (dr & 31) << 5;
if (size == 4) {
env->sregs[SR_ESR] |= 1 << 11;
}
helper_raise_exception(EXCP_HW_EXCP);
}
}
| 1threat
|
Nesting MYSQLi commands code : This question refers to nesting mysqli commands, i'm not sure the term "nesting" is the correct one here so i'll explain.
Look at this code for example:
$query = 'SELECT id FROM users WHERE id="' . $_POST['uid'] . '"';
$result = $mysqli->query($query);
$user_id = mysqli_fetch_row($result);
The code above can be turned into a *shorthand* version as follows:
$user_id = mysqli_fetch_row($mysqli->query('SELECT id FROM users WHERE id="' . $_POST['uid'] . '"'));
I know this works because i've tried it. I see that PHP is taking care of the code from "inside-out", is it basically a recursive method to write this code or am I completely off with the terms?
My question is this, does this work for all MYSQL commands or PHP functions? are there exceptions for this functionality? what are the drawbacks to using such form? (besides it being less *readable* by a programmer)
| 0debug
|
PhP/MySQL - how to add parameters like ?q=blabla to url : <p>I know this question must be very, very basic since even beginners are asking more advanced questions, but I can't find the answer.. I have searched for hours on this, so please condone my ignorance.</p>
<p><strong>What I have</strong>: localhost:8888/site/document.php</p>
<p>It loads some data from my MySQL database on this page, such as q = office.</p>
<p><strong>What I want</strong>: localhost:8888/site/document.php?q=office</p>
<p>Thanks in advance!</p>
| 0debug
|
IllegalStateException: reasonPhrase can't be empty with Android WebView : <p>I've recently been noticing that a number of users are receiving this <code>IllegalStateException</code>, which causes a crash of the app. It happens when a <code>WebView</code> is shown to the user:</p>
<pre><code>Fatal Exception: java.lang.IllegalArgumentException: reasonPhrase can't be empty.
at android.webkit.WebResourceResponse.setStatusCodeAndReasonPhrase + 129(WebResourceResponse.java:129)
at android.webkit.WebResourceResponse.(WebResourceResponse.java:70)
at jY.a + 308(jY.java:308)
at zn.handleMessage + 67(zn.java:67)
at android.os.Handler.dispatchMessage + 102(Handler.java:102)
at android.os.Looper.loop + 211(Looper.java:211)
at android.app.ActivityThread.main + 5373(ActivityThread.java:5373)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke + 372(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 1020(ZygoteInit.java:1020)
at com.android.internal.os.ZygoteInit.main + 815(ZygoteInit.java:815)
</code></pre>
<p>This crash is not happening for every user. I have tried asking users to update Chrome in the hope that it updates Chromium and also asking them to install the latest version of the Android System WebView but neither gave me any success. Has anyone come across this and know how to fix this? I can't even replicate it myself personally.</p>
<p>I also found this bug log here:
<a href="https://bugs.chromium.org/p/chromium/issues/detail?id=925887" rel="noreferrer">https://bugs.chromium.org/p/chromium/issues/detail?id=925887</a></p>
<p>I've also looked at the source code and can see that the relevant crash is being caused by <code>line 154</code>:
<a href="https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/webkit/WebResourceResponse.java" rel="noreferrer">https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/webkit/WebResourceResponse.java</a></p>
<p>The weird thing is that this supposedly should only happen when an error happens, but I can see that the <code>WebView</code> correctly loads for the user from screenshots and then the app crashes shortly after. Any help would be greatly appreciated!</p>
| 0debug
|
static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
uint32_t type;
uint32_t av_unused ctype;
int64_t title_size;
char *title_str;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
avio_r8(pb);
avio_rb24(pb);
ctype = avio_rl32(pb);
type = avio_rl32(pb);
av_log(c->fc, AV_LOG_TRACE, "ctype= %.4s (0x%08x)\n", (char*)&ctype, ctype);
av_log(c->fc, AV_LOG_TRACE, "stype= %.4s\n", (char*)&type);
if (type == MKTAG('v','i','d','e'))
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
else if (type == MKTAG('s','o','u','n'))
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
else if (type == MKTAG('m','1','a',' '))
st->codec->codec_id = AV_CODEC_ID_MP2;
else if ((type == MKTAG('s','u','b','p')) || (type == MKTAG('c','l','c','p')))
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
avio_rb32(pb);
avio_rb32(pb);
avio_rb32(pb);
title_size = atom.size - 24;
if (title_size > 0) {
title_str = av_malloc(title_size + 1);
if (!title_str)
return AVERROR(ENOMEM);
avio_read(pb, title_str, title_size);
title_str[title_size] = 0;
if (title_str[0]) {
int off = (!c->isom && title_str[0] == title_size - 1);
av_dict_set(&st->metadata, "handler_name", title_str + off, 0);
}
av_freep(&title_str);
}
return 0;
}
| 1threat
|
Install packages in Alpine docker : <p>How do I write Dockerfile commands to install the following in alpine docker image:</p>
<ol>
<li>software-properties-common</li>
<li>openjdk-8-jdk</li>
<li>python3</li>
<li>nltk </li>
<li>Flask</li>
</ol>
| 0debug
|
alert('Hello ' + user_input);
| 1threat
|
Contentful Javascript API - looking up an entry by slug : <p>I see how to query an Entry by the ID.</p>
<p>Is there a way to lookup by slug? That is what I really want to do.</p>
<p>Thanks!</p>
| 0debug
|
How to change to a stringbuilder in java : I am trying to change the following code to stringbuilder so i can format the output of an arraylist how can i do this.
private static String createFormattedList(List<List<String>> failureList) {
String lineBreak = "</br>";
String result = "";
for (List<String> failure : failureList) {
for (String item : failure) {
result += item + lineBreak;
}
result += lineBreak;
}
return result;
}
}
| 0debug
|
can't set a value in another class : <p>This is a method from a class, courses is an array from another class, I set the value of cn in main, but it skips all the codes after it. Why is that?</p>
<pre><code>public class GradeBook {
Scanner r=new Scanner(System.in);
private int cn;
private Course courses[]=new Course[cn];
void entercourse(){
for(int i = 0;i<courses.length;i++){
System.out.println("c name");
courses[i].setName(r.nextLine());
System.out.println("mark");
courses[i].setMark(r.nextInt());
courses[i].setpass();
}
}
</code></pre>
| 0debug
|
static void test_bmdma_short_prdt(void)
{
QPCIDevice *dev;
QPCIBar bmdma_bar, ide_bar;
uint8_t status;
PrdtEntry prdt[] = {
{
.addr = 0,
.size = cpu_to_le32(0x10 | PRDT_EOT),
},
};
dev = get_pci_device(&bmdma_bar, &ide_bar);
status = send_dma_request(CMD_READ_DMA, 0, 1,
prdt, ARRAY_SIZE(prdt), NULL);
g_assert_cmphex(status, ==, 0);
assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR);
status = send_dma_request(CMD_READ_DMA | CMDF_ABORT, 0, 1,
prdt, ARRAY_SIZE(prdt), NULL);
g_assert_cmphex(status, ==, 0);
assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR);
}
| 1threat
|
React and Redux: redirect after action : <p>I develop a website with React/Redux and I use a thunk middleware to call my API. My problem concerns redirections after actions.</p>
<p>I really do not know how and where I can do the redirection: in my action, in the reducer, in my component, … ?</p>
<p>My action looks like this:</p>
<pre><code>export function deleteItem(id) {
return {
[CALL_API]: {
endpoint: `item/${id}`,
method: 'DELETE',
types: [DELETE_ITEM_REQUEST, DELETE_ITEM_SUCCESS, DELETE_ITEM_FAILURE]
},
id
};
}
</code></pre>
<p><code>react-redux</code> is already implemented on my website and I know that I can do as below, but I do not want to redirect the use if the request failed:</p>
<pre><code>router.push('/items');
</code></pre>
<p>Thanks!</p>
| 0debug
|
load multiple models in Tensorflow : <p>I have written the following convolutional neural network (CNN) class in Tensorflow [<em>I have tried to omit some lines of code for clarity.</em>]</p>
<pre><code>class CNN:
def __init__(self,
num_filters=16, # initial number of convolution filters
num_layers=5, # number of convolution layers
num_input=2, # number of channels in input
num_output=5, # number of channels in output
learning_rate=1e-4, # learning rate for the optimizer
display_step = 5000, # displays training results every display_step epochs
num_epoch = 10000, # number of epochs for training
batch_size= 64, # batch size for mini-batch processing
restore_file=None, # restore file (default: None)
):
# define placeholders
self.image = tf.placeholder(tf.float32, shape = (None, None, None,self.num_input))
self.groundtruth = tf.placeholder(tf.float32, shape = (None, None, None,self.num_output))
# builds CNN and compute prediction
self.pred = self._build()
# I have already created a tensorflow session and saver objects
self.sess = tf.Session()
self.saver = tf.train.Saver()
# also, I have defined the loss function and optimizer as
self.loss = self._loss_function()
self.optimizer = tf.train.AdamOptimizer(learning_rate).minimize(self.loss)
if restore_file is not None:
print("model exists...loading from the model")
self.saver.restore(self.sess,restore_file)
else:
print("model does not exist...initializing")
self.sess.run(tf.initialize_all_variables())
def _build(self):
#builds CNN
def _loss_function(self):
# computes loss
#
def train(self, train_x, train_y, val_x, val_y):
# uses mini batch to minimize the loss
self.sess.run(self.optimizer, feed_dict = {self.image:sample, self.groundtruth:gt})
# I save the session after n=10 epochs as:
if epoch%n==0:
self.saver.save(sess,'snapshot',global_step = epoch)
# finally my predict function is
def predict(self, X):
return self.sess.run(self.pred, feed_dict={self.image:X})
</code></pre>
<p>I have trained two CNNs for two separate tasks independently. Each took around 1 day. Say, model1 and model2 are saved as '<code>snapshot-model1-10000</code>' and '<code>snapshot-model2-10000</code>' (with their corresponding meta files) respectively. I can test each model and compute its performance separately.</p>
<p>Now, I want to load these two models in a single script. I would naturally try to do as below:</p>
<pre><code>cnn1 = CNN(..., restore_file='snapshot-model1-10000',..........)
cnn2 = CNN(..., restore_file='snapshot-model2-10000',..........)
</code></pre>
<p>I encounter the error [<em>The error message is long. I just copied/pasted a snippet of it.</em>]</p>
<pre><code>NotFoundError: Tensor name "Variable_26/Adam_1" not found in checkpoint files /home/amitkrkc/codes/A549_models/snapshot-hela-95000
[[Node: save_1/restore_slice_85 = RestoreSlice[dt=DT_FLOAT, preferred_shard=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save_1/Const_0, save_1/restore_slice_85/tensor_name, save_1/restore_slice_85/shape_and_slice)]]
</code></pre>
<p>Is there a way to load from these two files two separate CNNs? Any suggestion/comment/feedback is welcome.</p>
<p>Thank you,</p>
| 0debug
|
static int qxl_post_load(void *opaque, int version)
{
PCIQXLDevice* d = opaque;
uint8_t *ram_start = d->vga.vram_ptr;
QXLCommandExt *cmds;
int in, out, newmode;
assert(d->last_release_offset < d->vga.vram_size);
if (d->last_release_offset == 0) {
d->last_release = NULL;
} else {
d->last_release = (QXLReleaseInfo *)(ram_start + d->last_release_offset);
}
d->modes = (QXLModes*)((uint8_t*)d->rom + d->rom->modes_offset);
trace_qxl_post_load(d->id, qxl_mode_to_string(d->mode));
newmode = d->mode;
d->mode = QXL_MODE_UNDEFINED;
switch (newmode) {
case QXL_MODE_UNDEFINED:
qxl_create_memslots(d);
break;
case QXL_MODE_VGA:
qxl_create_memslots(d);
qxl_enter_vga_mode(d);
break;
case QXL_MODE_NATIVE:
qxl_create_memslots(d);
qxl_create_guest_primary(d, 1, QXL_SYNC);
cmds = g_malloc0(sizeof(QXLCommandExt) * (d->ssd.num_surfaces + 1));
for (in = 0, out = 0; in < d->ssd.num_surfaces; in++) {
if (d->guest_surfaces.cmds[in] == 0) {
continue;
}
cmds[out].cmd.data = d->guest_surfaces.cmds[in];
cmds[out].cmd.type = QXL_CMD_SURFACE;
cmds[out].group_id = MEMSLOT_GROUP_GUEST;
out++;
}
if (d->guest_cursor) {
cmds[out].cmd.data = d->guest_cursor;
cmds[out].cmd.type = QXL_CMD_CURSOR;
cmds[out].group_id = MEMSLOT_GROUP_GUEST;
out++;
}
qxl_spice_loadvm_commands(d, cmds, out);
g_free(cmds);
if (d->guest_monitors_config) {
qxl_spice_monitors_config_async(d, 1);
}
break;
case QXL_MODE_COMPAT:
qxl_set_mode(d, d->shadow_rom.mode, 1);
break;
}
return 0;
}
| 1threat
|
static void usb_ohci_init(OHCIState *ohci, DeviceState *dev,
int num_ports, int devfn,
qemu_irq irq, enum ohci_type type,
const char *name, uint32_t localmem_base)
{
int i;
if (usb_frame_time == 0) {
#ifdef OHCI_TIME_WARP
usb_frame_time = get_ticks_per_sec();
usb_bit_time = muldiv64(1, get_ticks_per_sec(), USB_HZ/1000);
#else
usb_frame_time = muldiv64(1, get_ticks_per_sec(), 1000);
if (get_ticks_per_sec() >= USB_HZ) {
usb_bit_time = muldiv64(1, get_ticks_per_sec(), USB_HZ);
} else {
usb_bit_time = 1;
}
#endif
dprintf("usb-ohci: usb_bit_time=%" PRId64 " usb_frame_time=%" PRId64 "\n",
usb_frame_time, usb_bit_time);
}
ohci->mem = cpu_register_io_memory(ohci_readfn, ohci_writefn, ohci);
ohci->localmem_base = localmem_base;
ohci->name = name;
ohci->irq = irq;
ohci->type = type;
usb_bus_new(&ohci->bus, dev);
ohci->num_ports = num_ports;
for (i = 0; i < num_ports; i++) {
usb_register_port(&ohci->bus, &ohci->rhport[i].port, ohci, i, ohci_attach);
}
ohci->async_td = 0;
qemu_register_reset(ohci_reset, ohci);
ohci_reset(ohci);
}
| 1threat
|
Python assert(False) vs assert(false) : A recent coding error of mine has made me think...
I have been using `assert(false)` instead of `assert(False)` in one of my functions.
This function is invoked only inside `try/except` clauses.
So I never noticed this "compilation error", until I actually printed the details of the exception.
Then it made me wonder if there were any runtime differences between the two.
Of course, the "`false`" here can be replaced with any other undefined symbol.
Obviously, the printouts themselves would be different.
Here's a simple test that I conducted:
try:
assert false
except Exception,e:
print "false: class name = {:15}, message = {}".format(e.__class__.__name__,e.message)
try:
assert False
except Exception,e:
print "False: class name = {:15}, message = {}".format(e.__class__.__name__,e.message)
The printout of this test is:
false: class name = NameError , message = name 'false' is not defined
False: class name = AssertionError , message =
So my question is, are there any other runtime differences here? In particularly, I am interested to know if using `assert(false)` over `assert(False)` could somehow hinder the performance of my program.
Thank you very much!
| 0debug
|
int ff_h264_set_parameter_from_sps(H264Context *h)
{
if (h->flags & CODEC_FLAG_LOW_DELAY ||
(h->sps.bitstream_restriction_flag &&
!h->sps.num_reorder_frames)) {
if (h->avctx->has_b_frames > 1 || h->delayed_pic[0])
av_log(h->avctx, AV_LOG_WARNING, "Delayed frames seen. "
"Reenabling low delay requires a codec flush.\n");
else
h->low_delay = 1;
}
if (h->avctx->has_b_frames < 2)
h->avctx->has_b_frames = !h->low_delay;
if (h->avctx->bits_per_raw_sample != h->sps.bit_depth_luma ||
h->cur_chroma_format_idc != h->sps.chroma_format_idc) {
if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
h->cur_chroma_format_idc = h->sps.chroma_format_idc;
h->pixel_shift = h->sps.bit_depth_luma > 8;
ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma,
h->sps.chroma_format_idc);
ff_h264chroma_init(&h->h264chroma, h->sps.bit_depth_chroma);
ff_h264qpel_init(&h->h264qpel, h->sps.bit_depth_luma);
ff_h264_pred_init(&h->hpc, h->avctx->codec_id, h->sps.bit_depth_luma,
h->sps.chroma_format_idc);
if (CONFIG_ERROR_RESILIENCE)
ff_me_cmp_init(&h->mecc, h->avctx);
ff_videodsp_init(&h->vdsp, h->sps.bit_depth_luma);
} else {
av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth %d\n",
h->sps.bit_depth_luma);
return AVERROR_INVALIDDATA;
}
}
return 0;
}
| 1threat
|
Attribute Value Read? : <p>Currently im trying to read a XML attribute with no sucess, so far what i got is :</p>
<pre><code> XmlDocument _doc = new XmlDocument();
_doc.LoadXml(@"<DATA jsonclass=""array"">
<ROW id=""1"">
<D n=""697""/>
<D n=""2601"">10815</D>
<D n=""3242""/>
<D n=""3243"">2017-03-15 00:00:00.0</D>
<D n=""3245"">+</D>
<D n=""3274""/>
<D n=""4895"">USD</D>
</ROW>
<ROW id=""1"">
<D n=""697""/>
<D n=""2601"">10816</D>
<D n=""3242""/>
<D n=""3243"">2017-03-15 00:00:00.0</D>
<D n=""3245"">+</D>
<D n=""3274""/>
<D n=""4895"">USD</D>
</ROW>
</DATA>");
XmlNodeList elemLista = _doc.GetElementsByTagName("D");
for (int i = 0; i < elemLista.Count; i++)
{
string attrVal = elemLista[i].Attributes["n"].Value;
//this is returnig 2601 and Im looking for **10816**
Console.WriteLine(attrVal);
// Req.RequestAllPOAvailable();`
}
}
</code></pre>
<p>I'm expecting to get 10815 and 10816, but the results is the same.... the output still 2601, what im doing wrong? thanks for your help</p>
| 0debug
|
Randomly select multiple items from an array : <p>I want to have an array with different words and phrases and randomly generate around five of these on page refresh. How would I go about doing this in javascript?</p>
| 0debug
|
connect_to_qemu(
const char *host,
const char *port
) {
struct addrinfo hints;
struct addrinfo *server;
int ret, sock;
sock = qemu_socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
fprintf(stderr, "Error opening socket!\n");
return -1;
}
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = 0;
hints.ai_protocol = 0;
ret = getaddrinfo(host, port, &hints, &server);
if (ret != 0) {
fprintf(stderr, "getaddrinfo failed\n");
return -1;
}
if (connect(sock, server->ai_addr, server->ai_addrlen) < 0) {
fprintf(stderr, "Could not connect\n");
return -1;
}
if (verbose) {
printf("Connected (sizeof Header=%zd)!\n", sizeof(VSCMsgHeader));
}
return sock;
}
| 1threat
|
In Spark, is it possible to share data between two executors? : <p>I have a really big read only data that I want all the executors on the same node to use. Is that possible in Spark. I know, you can broadcast variables, but can you broadcast really big arrays. Does, under the hood, it shares data between executors on the same node? How is this able to share data between the JVMs of the executors running on the same node?</p>
| 0debug
|
How to understand following single and double quotes terminology in C/C++? : Help me understand the following:
cout<<'a' prints a and it's okay but
cout<<'ab' prints 24930 but I was expecting an error due to term 'ab' having two character in single quote
cout<<'a'+1 prints 98
cout<<"ab" prints ab and it's okay but
cout<<"ab"+1 prints b, why?
cout<<"a"+1 prints nothing ?
cout<<'a'+'b' prints 195 ?
cout<<"a"+"b" gives error ?
Please help me to understand all these things in details. I am very confused. I would be very thankful.
| 0debug
|
Angular2: How to find out what was previous page url when using angular2 routing : <p>I am developing an angular2 app and I use router.
I am in a page /myapp/signup. after signup I navigate the use to /myapp/login. /myapp/login can also be navigated from my home page which is /myapp. So now, when the user users /myapp/login I go back. This can be done by using location.back(). But I dont want to go back when the user is coming from /myapp/signup. So I should check if the user is coming from /myapp/signup and if so, I want to direct it to somewhere else.
How can I know the previous url so that I direct the user to a specific state based on that ?</p>
| 0debug
|
Is it good practice to return available Options for the entity : <p>I'm working on a new api and i'm trying to decide if it would be a good practice to include the list of available options as well as the selected option when returning an entity back from the database. </p>
<p>Take for example </p>
<pre><code>class car
{
int Id;
Type Type;
List<Type> Types;
}
class Type
{
int Id;
string Name;
}
</code></pre>
<p>I've seen this done both ways, so I was wondering if there was a preference.</p>
<p>Thanks</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.