problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static inline int ucf64_exceptbits_to_host(int target_bits)
{
int host_bits = 0;
if (target_bits & UCF64_FPSCR_FLAG_INVALID) {
host_bits |= float_flag_invalid;
}
if (target_bits & UCF64_FPSCR_FLAG_DIVZERO) {
host_bits |= float_flag_divbyzero;
}
if (target_bits & UCF64_FPSCR_FLAG_OVERFLOW) {
host_bits |= float_flag_overflow;
}
if (target_bits & UCF64_FPSCR_FLAG_UNDERFLOW) {
host_bits |= float_flag_underflow;
}
if (target_bits & UCF64_FPSCR_FLAG_INEXACT) {
host_bits |= float_flag_inexact;
}
return host_bits;
}
| 1threat
|
How to convert number 1 to a Boolean in python : <p>I have seen similar questions asked, but none have answered my question. I am relatively new to python, and have no idea what i'm doing. </p>
| 0debug
|
How do I memorize algorithms? : <p>I am an AP Computer Science student and I need help memorizing the algorithms.The algorithms are in a revision sheet and they are about abstract classes, interfaces, and polymorphism, so what would be the easiest way to memorize this.Thanks! </p>
| 0debug
|
range based for loop with existing variable : <p>Using a range based for loop in C++11 with an existing variable, I would expect that variable to be filled with the value of the last iteration after the loop. However, I've gotten different results when I tested it.</p>
<p>Example:</p>
<pre><code>#include <iostream>
#include <vector>
using namespace std;
int main() {
std::vector<int> v;
v.push_back(2);
v.push_back(43);
v.push_back(99);
int last = -50;
for (last : v)
std::cout << ":" << last << "\n";
std::cout << last;
return 0;
}
</code></pre>
<ol>
<li>MSVC 2013 doesn't seem to support range based for loops without type declaration</li>
<li><p>GCC-5.1 either automatically introduces a new variable or sets it back to the initial value, giving</p>
<blockquote>
<p>:2<br>
:43<br>
:99<br>
-50</p>
</blockquote></li>
</ol>
<p>I guess MSVC is just being MSVC again, but what about GCC here? Why is <code>last</code> not <code>99</code> in the last line?</p>
<hr>
<p>Given the <a href="http://en.cppreference.com/w/cpp/language/range-for">definition by the standard</a>, I would expect the behaviour I described in the first sentence.</p>
<pre><code>{
auto && __range = range_expression ;
for (auto __begin = begin_expr, __end = end_expr;
__begin != __end; ++__begin) {
range_declaration = *__begin;
loop_statement
}
}
</code></pre>
<p><code>range_declaration</code> being <code>last</code> and not <code>int last</code>, this should modify the existing variable.</p>
| 0debug
|
How to update some part of text using SQL UPDATE statment : I have a query saved in column of a table named sqlcode which is maintaining the metadata. For instance following is a query:
select
id,name,address,phone,
.......
......
,upddate
from bank a
join bankreg b
on
a.id = b.id
where (condition)
I'm trying to update the text of query saved in metadata but i want to only update column names part of the query without making any change to select,from,joins or any other conditions. Any way of only updating column names would be helpful. I've tried using `replace` function but couldn't got desired output.
| 0debug
|
static void test_qemu_strtol_empty(void)
{
const char *str = "";
char f = 'X';
const char *endptr = &f;
long res = 999;
int err;
err = qemu_strtol(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, 0);
g_assert(endptr == str);
}
| 1threat
|
This application's bundle identifier does not match its code signing identifier : <p>When I try to build and run the app on the device I get following error <code>App installation failed: This application's bundle identifier does not match its code signing identifier.</code></p>
<p>I checked the signing certificates, bundle ids, provision profile, entitlements and everything is correct. </p>
<p><a href="https://i.stack.imgur.com/ZnQ6P.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZnQ6P.png" alt="Error message"></a></p>
<p>Any Ideas ?</p>
| 0debug
|
Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
{
Visitor *v;
QDict *pdict;
Object *obj;
const char *id = qemu_opts_id(opts);
const char *type = qemu_opt_get(opts, "qom-type");
if (!type) {
error_setg(errp, QERR_MISSING_PARAMETER, "qom-type");
return NULL;
}
if (!id) {
error_setg(errp, QERR_MISSING_PARAMETER, "id");
return NULL;
}
pdict = qemu_opts_to_qdict(opts, NULL);
qdict_del(pdict, "qom-type");
qdict_del(pdict, "id");
v = opts_visitor_new(opts);
obj = user_creatable_add_type(type, id, pdict, v, errp);
visit_free(v);
QDECREF(pdict);
return obj;
}
| 1threat
|
query = 'SELECT * FROM customers WHERE email = ' + email_input
| 1threat
|
static void lcd_refresh(void *opaque)
{
musicpal_lcd_state *s = opaque;
int x, y;
for (x = 0; x < 128; x++)
for (y = 0; y < 64; y++)
if (s->video_ram[x + (y/8)*128] & (1 << (y % 8)))
set_lcd_pixel(s, x, y, MP_LCD_TEXTCOLOR);
else
set_lcd_pixel(s, x, y, 0);
dpy_update(s->ds, 0, 0, 128*3, 64*3);
}
| 1threat
|
How to avoid flake8's "F821 undefined name '_'" when _ has been installed by gettext? : <h2>Problem overview:</h2>
<p>In my project's main script, <code>gettext</code> installs the function <code>_()</code> that is used in other modules for translations (like in <code>print(_('Something to translate'))</code>).</p>
<p>As stated by <a href="https://docs.python.org/3/library/gettext.html#gettext.install" rel="noreferrer">the doc</a>:</p>
<blockquote>
<p>the _() function [is] installed in Python’s builtins namespace, so it is easily accessible in all modules of your application.</p>
</blockquote>
<p>So, everything runs fine.</p>
<p><em>Only problem</em>: <code>flake8</code> shows errors (actually returned by PyFlakes):</p>
<pre><code>$ flake8 *.py
lib.py:2:12: F821 undefined name '_'
main_script.py:8:7: F821 undefined name '_'
</code></pre>
<p>This is normal, as <code>_</code> is indeed not defined in main_script.py nor lib.py.</p>
<h2>Simple structure that reproduces the problem:</h2>
<pre><code>.
├── lib.py
├── locale
│ └── de
│ └── LC_MESSAGES
│ ├── myapp.mo
│ └── myapp.po
└── main_script.py
</code></pre>
<p>Where lib.py contains this:</p>
<pre><code>def fct(sentence):
return _(sentence)
</code></pre>
<p>and main_script.py this:</p>
<pre><code>#!/usr/bin/env python3
import gettext
import lib
gettext.translation('myapp', 'locale', ['de']).install()
print(_('A sentence'))
print(lib.fct('A sentence'))
</code></pre>
<p>and myapp.po contains:</p>
<pre><code>msgid ""
msgstr ""
"Project-Id-Version: myapp\n"
msgid "A sentence"
msgstr "Ein Satz"
</code></pre>
<p>(was compiled by poedit to produce the mo file).</p>
<p>As stated above, the main script does work:</p>
<pre><code>$ ./main_script.py
Ein Satz
Ein Satz
</code></pre>
<p><strong>Important note: I'm looking for a solution working both for the script where <code>gettext.install()</code> is called <em>and</em> all other modules that <em>do not need to call</em> <code>gettext.install()</code>.</strong> Otherwise, the structure could be even more simple, because calling <code>_()</code> from main_script.py is enough to trigger F821.</p>
<h2>Solutions to solve the situation that look bad (or worse):</h2>
<ul>
<li>add a <code># noqa</code> comment at the end of each line using <code>_()</code></li>
<li><code>--ignore</code> F821 (don't want to do that because this is useful in other situations)</li>
</ul>
| 0debug
|
Android flashlight app using camera api 2 : <p>How can blink my flashlight app using 1 image button and using camera api 2 ?? Please someone help me.</p>
| 0debug
|
How to create tray shaped bottom border like andriod input? : In one of the custom input I created in js file for an application using phonegap, we need to have exact border as it was resulting in normal input in android devices.
[![enter image description here][1]][1]
So the question is how to create shaped boarder using css exact looking app for custom inputs which are not getting this by default.
[1]: https://i.stack.imgur.com/PmSmI.png
| 0debug
|
static int srt_encode_frame(AVCodecContext *avctx,
unsigned char *buf, int bufsize, const AVSubtitle *sub)
{
SRTContext *s = avctx->priv_data;
ASSDialog *dialog;
int i, len, num;
s->ptr = s->buffer;
s->end = s->ptr + sizeof(s->buffer);
for (i=0; i<sub->num_rects; i++) {
if (sub->rects[i]->type != SUBTITLE_ASS) {
av_log(avctx, AV_LOG_ERROR, "Only SUBTITLE_ASS type supported.\n");
return AVERROR(ENOSYS);
}
dialog = ff_ass_split_dialog(s->ass_ctx, sub->rects[i]->ass, 0, &num);
for (; dialog && num--; dialog++) {
if (avctx->codec->id == CODEC_ID_SRT) {
int sh, sm, ss, sc = 10 * dialog->start;
int eh, em, es, ec = 10 * dialog->end;
sh = sc/3600000; sc -= 3600000*sh;
sm = sc/ 60000; sc -= 60000*sm;
ss = sc/ 1000; sc -= 1000*ss;
eh = ec/3600000; ec -= 3600000*eh;
em = ec/ 60000; ec -= 60000*em;
es = ec/ 1000; ec -= 1000*es;
srt_print(s,"%d\r\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\r\n",
++s->count, sh, sm, ss, sc, eh, em, es, ec);
}
s->alignment_applied = 0;
s->dialog_start = s->ptr - 2;
srt_style_apply(s, dialog->style);
ff_ass_split_override_codes(&srt_callbacks, s, dialog->text);
}
}
if (s->ptr == s->buffer)
return 0;
len = av_strlcpy(buf, s->buffer, bufsize);
if (len > bufsize-1) {
av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n");
return -1;
}
return len;
}
| 1threat
|
When to use --hostname in docker? : <p>Is <code>--hostname</code> like a domain name system in docker container environment that can replace <code>--ip</code> when referring to other container? </p>
| 0debug
|
static int decode_subframe_lpc(ShortenContext *s, int command, int channel,
int residual_size, int32_t coffset)
{
int pred_order, sum, qshift, init_sum, i, j;
const int *coeffs;
if (command == FN_QLPC) {
pred_order = get_ur_golomb_shorten(&s->gb, LPCQSIZE);
if (pred_order > s->nwrap) {
av_log(s->avctx, AV_LOG_ERROR, "invalid pred_order %d\n",
pred_order);
return AVERROR(EINVAL);
}
for (i = 0; i < pred_order; i++)
s->coeffs[i] = get_sr_golomb_shorten(&s->gb, LPCQUANT);
coeffs = s->coeffs;
qshift = LPCQUANT;
} else {
pred_order = command;
if (pred_order >= FF_ARRAY_ELEMS(fixed_coeffs)) {
av_log(s->avctx, AV_LOG_ERROR, "invalid pred_order %d\n",
pred_order);
return AVERROR_INVALIDDATA;
}
coeffs = fixed_coeffs[pred_order];
qshift = 0;
}
if (command == FN_QLPC && coffset)
for (i = -pred_order; i < 0; i++)
s->decoded[channel][i] -= coffset;
init_sum = pred_order ? (command == FN_QLPC ? s->lpcqoffset : 0) : coffset;
for (i = 0; i < s->blocksize; i++) {
sum = init_sum;
for (j = 0; j < pred_order; j++)
sum += coeffs[j] * s->decoded[channel][i - j - 1];
s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) +
(sum >> qshift);
}
if (command == FN_QLPC && coffset)
for (i = 0; i < s->blocksize; i++)
s->decoded[channel][i] += coffset;
return 0;
}
| 1threat
|
static USBDevice *usb_serial_init(USBBus *bus, const char *filename)
{
USBDevice *dev;
CharDriverState *cdrv;
uint32_t vendorid = 0, productid = 0;
char label[32];
static int index;
while (*filename && *filename != ':') {
const char *p;
char *e;
if (strstart(filename, "vendorid=", &p)) {
vendorid = strtol(p, &e, 16);
if (e == p || (*e && *e != ',' && *e != ':')) {
error_report("bogus vendor ID %s", p);
return NULL;
}
filename = e;
} else if (strstart(filename, "productid=", &p)) {
productid = strtol(p, &e, 16);
if (e == p || (*e && *e != ',' && *e != ':')) {
error_report("bogus product ID %s", p);
return NULL;
}
filename = e;
} else {
error_report("unrecognized serial USB option %s", filename);
return NULL;
}
while(*filename == ',')
filename++;
}
if (!*filename) {
error_report("character device specification needed");
return NULL;
}
filename++;
snprintf(label, sizeof(label), "usbserial%d", index++);
cdrv = qemu_chr_new(label, filename, NULL);
if (!cdrv)
return NULL;
dev = usb_create(bus, "usb-serial");
qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
if (vendorid)
qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid);
if (productid)
qdev_prop_set_uint16(&dev->qdev, "productid", productid);
qdev_init_nofail(&dev->qdev);
return dev;
}
| 1threat
|
static inline void RENAME(shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, long src_size)
{
x86_reg idx = 15 - src_size;
const uint8_t *s = src-idx;
uint8_t *d = dst-idx;
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
"test %0, %0 \n\t"
"jns 2f \n\t"
PREFETCH" (%1, %0) \n\t"
"movq %3, %%mm7 \n\t"
"pxor %4, %%mm7 \n\t"
"movq %%mm7, %%mm6 \n\t"
"pxor %5, %%mm7 \n\t"
".p2align 4 \n\t"
"1: \n\t"
PREFETCH" 32(%1, %0) \n\t"
"movq (%1, %0), %%mm0 \n\t"
"movq 8(%1, %0), %%mm1 \n\t"
# if COMPILE_TEMPLATE_MMX2
"pshufw $177, %%mm0, %%mm3 \n\t"
"pshufw $177, %%mm1, %%mm5 \n\t"
"pand %%mm7, %%mm0 \n\t"
"pand %%mm6, %%mm3 \n\t"
"pand %%mm7, %%mm1 \n\t"
"pand %%mm6, %%mm5 \n\t"
"por %%mm3, %%mm0 \n\t"
"por %%mm5, %%mm1 \n\t"
# else
"movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm4 \n\t"
"pand %%mm7, %%mm0 \n\t"
"pand %%mm6, %%mm2 \n\t"
"pand %%mm7, %%mm1 \n\t"
"pand %%mm6, %%mm4 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq %%mm4, %%mm5 \n\t"
"pslld $16, %%mm2 \n\t"
"psrld $16, %%mm3 \n\t"
"pslld $16, %%mm4 \n\t"
"psrld $16, %%mm5 \n\t"
"por %%mm2, %%mm0 \n\t"
"por %%mm4, %%mm1 \n\t"
"por %%mm3, %%mm0 \n\t"
"por %%mm5, %%mm1 \n\t"
# endif
MOVNTQ" %%mm0, (%2, %0) \n\t"
MOVNTQ" %%mm1, 8(%2, %0) \n\t"
"add $16, %0 \n\t"
"js 1b \n\t"
SFENCE" \n\t"
EMMS" \n\t"
"2: \n\t"
: "+&r"(idx)
: "r" (s), "r" (d), "m" (mask32b), "m" (mask32r), "m" (mmx_one)
: "memory");
#endif
for (; idx<15; idx+=4) {
register int v = *(const uint32_t *)&s[idx], g = v & 0xff00ff00;
v &= 0xff00ff;
*(uint32_t *)&d[idx] = (v>>16) + g + (v<<16);
}
}
| 1threat
|
how to read this king of json o/p in adnroid : [<br>
{<br>
"hit": "1"<br>
},<br>
{<br>
"SUM(hit)": "196290"<br>
},<br>
{<br>
"COUNT(id)": "4010"<br>
}<br>
]<br>
<br><br>
how to read this king of json o/p in adnroid
| 0debug
|
Turtle Graphics- Process terminated due to stackOberflowException : I am trying to prepare a Turtle graphics solution in C#. Everything is working fine but it ends in Process Terminated due to StackOverflowException. I checked [this][1]
and
[this][2]
where the issue is of getter setter or infinite loop. But I dont have any of this condition in my code. I am a newbie in C#.
Below is my code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TurtleGraphics
{
class Program
{/**
* Directions: 0 right, 1 down, 2 left, 3 up
*/
private static short direction = 0;
private static bool penDown;
private static int turtleX = 0, turtleY = 0;
private static int[,] floor = new int[20, 20];
public static void Main(String[] args)
{
initFloor(floor);
//Scanner in = new Scanner(System.in);
printMenu();
int nextCommand = int.Parse(Console.ReadLine());
while (nextCommand != 9)
{
switch (nextCommand)
{
case 1:
penDown = false;
break;
case 2:
penDown = true;
break;
case 3:
direction++;
break;
case 4:
direction--;
break;
case 5:
Console.WriteLine("How many steps do you want to move?");
int move = int.Parse(Console.ReadLine());
if (move <= 10)
while (--move != 0)
Moves();
break;
case 6:
printArray();
break;
default:
Console.WriteLine("Unknow command, please try again:\n");
break;
}
Moves();
Console.WriteLine("What's next?");
nextCommand = int.Parse(Console.ReadLine());
}
}
private static void initFloor(int[,] floor)
{
for (int i = 0; i < floor.GetLength(0); i++)
{
for (int j = 0; j < floor.GetLength(1); j++)
{
floor[i,j] = 0;
}
}
}
private static void printMenu()
{
Console.WriteLine("Commands List:\n\n\t1 Pen up\n"
+ "\t2 Pen down\n"
+ "\t3 Turn right\n"
+ "\t4 Turn left\n"
+ "\t5 to 10 Move forward 10 spaces (replace 10 for a different number of spaces)\n"
+ "\t6 Display the 20-by-20 array\n"
+ "\t9 End of data (sentinel)Please enter a command number:\n");
}
private static void printArray()
{
for (int i = 0; i < floor.GetLength(0); i++)
{
for (int j = 0; j < floor.GetLength(1); j++)
{
// Console.WriteLine(floor[i, j]);
// Console.WriteLine(" ");
if (floor[i, j] == 0)
Console.Write(".");
else if (floor[i, j] == 1)
Console.Write("*");
else if (floor[i, j] == 2)
Console.Write("T");
}
Console.WriteLine();
}
}
private static void Moves()
{
switch (direction)
{
case 0:
turtleX++;
break;
case 1:
turtleY++;
break;
case 2:
turtleX--;
break;
case 3:
turtleY--;
break;
default:
if (direction < 0)
direction = 3;
else
direction = 4;
Moves();
break;
}
if (penDown)
{
if (turtleX < 20 && turtleY < 20)
floor[turtleX, turtleY] = 1;
else
{
direction -= 2;
Moves();
}
}
}
}
}
Any quick help is appreciated. Thanks
[1]: https://stackoverflow.com/questions/26016613/getting-infinite-loop-issue-process-terminated-due-to-stackoverflowexception
[2]: https://stackoverflow.com/questions/46520739/c-sharp-process-is-terminated-due-to-stackoverflowexception
| 0debug
|
How to skip the zero value in an array of objects? : <p>I'm trying to handle an array of object. Where, I wanna ignore the object which has the value of '0' and print the values which is greater than zero by looping through 'storyIds', any ideas.</p>
<pre><code>var dataArr = [
{number: 1, workId: [0], storyIds: [0]},
{number: 2, workId: [0], storyIds: [0]},
{number: 3, workId: [1], storyIds: [10]},
{number: 4, workId: [2], storyIds: [10]},
{number: 5, workId: [3], storyIds: [20]}
];
</code></pre>
<p><strong>Expected Output</strong></p>
<pre><code>3, 4, 5 //Output
</code></pre>
| 0debug
|
docker run throw error `No such file or directory` when use 2 commands : <p>I found that if I use two commands, the second command cann't read the file in volume, (while the first can read it.) like that:</p>
<pre><code>[root@iZu51 test]# echo 'hello world' >> /data/test/a.txt
[root@iZu51 test]# docker run --rm -v /data/test:/data debian:stretch-slim cat /data/a.txt
hello world
[root@iZu51 test]# docker run --rm -v /data/test:/data debian:stretch-slim cat /data/a.txt && cat /data/a.txt
hello world
cat: /data/a.txt: No such file or directory
[root@iZu51 test]# docker run --rm -v /data/test:/data debian:stretch-slim cat /data/a.txt; cat /data/a.txt
hello world
cat: /data/a.txt: No such file or directory
</code></pre>
<p>How to fixed it? or it's a bug</p>
| 0debug
|
static void fdctrl_write_data(FDCtrl *fdctrl, uint32_t value)
{
FDrive *cur_drv;
int pos;
if (!(fdctrl->dor & FD_DOR_nRESET)) {
FLOPPY_DPRINTF("Floppy controller in RESET state !\n");
return;
}
if (!(fdctrl->msr & FD_MSR_RQM) || (fdctrl->msr & FD_MSR_DIO)) {
FLOPPY_DPRINTF("error: controller not ready for writing\n");
return;
}
fdctrl->dsr &= ~FD_DSR_PWRDOWN;
if (fdctrl->msr & FD_MSR_NONDMA) {
pos = fdctrl->data_pos++;
pos %= FD_SECTOR_LEN;
fdctrl->fifo[pos] = value;
if (pos == FD_SECTOR_LEN - 1 ||
fdctrl->data_pos == fdctrl->data_len) {
cur_drv = get_cur_drv(fdctrl);
if (blk_write(cur_drv->blk, fd_sector(cur_drv), fdctrl->fifo, 1)
< 0) {
FLOPPY_DPRINTF("error writing sector %d\n",
fd_sector(cur_drv));
return;
}
if (!fdctrl_seek_to_next_sect(fdctrl, cur_drv)) {
FLOPPY_DPRINTF("error seeking to next sector %d\n",
fd_sector(cur_drv));
return;
}
}
if (fdctrl->data_pos == fdctrl->data_len)
fdctrl_stop_transfer(fdctrl, 0x00, 0x00, 0x00);
return;
}
if (fdctrl->data_pos == 0) {
pos = command_to_handler[value & 0xff];
FLOPPY_DPRINTF("%s command\n", handlers[pos].name);
fdctrl->data_len = handlers[pos].parameters + 1;
fdctrl->msr |= FD_MSR_CMDBUSY;
}
FLOPPY_DPRINTF("%s: %02x\n", __func__, value);
fdctrl->fifo[fdctrl->data_pos++] = value;
if (fdctrl->data_pos == fdctrl->data_len) {
if (fdctrl->data_state & FD_STATE_FORMAT) {
fdctrl_format_sector(fdctrl);
return;
}
pos = command_to_handler[fdctrl->fifo[0] & 0xff];
FLOPPY_DPRINTF("treat %s command\n", handlers[pos].name);
(*handlers[pos].handler)(fdctrl, handlers[pos].direction);
}
}
| 1threat
|
Sorting a multiple list using position of data from first list : I have a dynamically populated list that when its built, the data is passed into creating a stacked bar chart. With the data in the list sorted so also the chart.
`list: [['Completion Date', 'New', 'NW-New', 'NW-Info', 'NW-Dec', 'NS-Modify', 'SN-Mod', 'VW-NwClter', 'NW-Del', 'VW-ModClter'], ['10/15/2017', 1, 0, 0, 0, 0, 0, 0, 0, 0], ['10/16/2017', 5, 8, 3, 2, 1, 0, 0, 0, 0], ['10/17/2017', 1, 9, 0, 29, 3, 3, 0, 0, 0], ['10/18/2017', 4, 44, 0, 11, 1, 0, 2, 0, 0], ['10/19/2017', 4, 39, 0, 0, 1, 0, 0, 1, 0], ['10/20/2017', 3, 2, 0, 0, 0, 1, 0, 0, 6], ['10/21/2017', 0, 0, 0, 0, 0, 0, 2, 0, 0], ['10/22/2017', 0, 0, 0, 0, 0, 0, 0, 0, 0], ['10/23/2017', 1, 67, 0, 85, 3, 2, 0, 1, 0], ['10/24/2017', 2, 25, 1, 4, 5, 0, 0, 1, 1], ['10/25/2017', 4, 65, 0, 11, 5, 0, 0, 11, 1], ['10/26/2017', 7, 40, 0, 0, 6, 0, 0, 2, 0], ['10/27/2017', 2, 37, 0, 115, 2, 0, 0, 0, 0], ['10/28/2017', 2, 0, 0, 0, 0, 0, 0, 0, 0], ['10/29/2017', 0, 0, 0, 0, 0, 0, 0, 0, 0], ['10/30/2017', 5, 53, 0, 0, 3, 0, 0, 1, 0], ['10/31/2017', 1, 30, 0, 19, 3, 0, 0, 0, 0], ['11/01/2017', 6, 106, 0, 2, 1, 0, 0, 1, 1], ['11/02/2017', 5, 74, 0, 10, 0, 0, 0, 9, 0]]`
The data in the first list matches that in the other list, completion data goes with the date and the strings in the first list goes with the other data respectively. I wanted a situation where if the string on the first list is sorted alphabetically, then the data matching its index position on the other list changes to the new position of the sorted string. Note the first data string completion date and the respective dates remain same.
I did some research and saw some examples but they where relative to two list. Like an example of sorting using zip. Any ideas will be welcomed.
| 0debug
|
Docker missing layer IDs in output : <p>I just did a fresh install of Docker on Ubuntu using the official guidelines: <a href="https://docs.docker.com/engine/installation/linux/ubuntulinux/" rel="noreferrer">https://docs.docker.com/engine/installation/linux/ubuntulinux/</a></p>
<p>When I pull an image using "sudo docker pull ubuntu" and then "sudo docker history ubuntu" it returns missing layer IDs in the columns. Using the documentation example ( <a href="https://docs.docker.com/engine/reference/commandline/history/" rel="noreferrer">https://docs.docker.com/engine/reference/commandline/history/</a> ) my output is:</p>
<pre><code>IMAGE CREATED CREATED BY SIZE COMMENT
3e23a5875458 8 days ago /bin/sh -c #(nop) ENV LC_ALL=C.UTF-8 0 B
"missing" 8 days ago /bin/sh -c dpkg-reconfigure locales && loc 1.245 MB
"missing" 8 days ago /bin/sh -c apt-get update && apt-get install 338.3 MB
</code></pre>
<p>and so on. Only the base layer ID shows, the rest is "missing". I tried installing on another Ubuntu machine connected to a different network and it has the same problem for any image that I download.</p>
<p>Does someone know what's causing this or able to help me fix it? I rely on this layer ID since I'm gathering some statistics on the reusability of layers so I need this ID to show correctly.</p>
<p>Thank you</p>
| 0debug
|
How to bind data in checkbox list in Gridview with same datatable : I want to gives checkbox list in gridview .How I bind data to checkboxlist from same datatatable?
| 0debug
|
how to show traffic route in listview in android map? : I'm create map use google APi's know im intersted to show the routes in he listview in android map how im implement this please kindly tell us every one??
| 0debug
|
Upload a CSV file and read it in Bokeh Web app : <p>I have a Bokeh plotting app, and I need to allow the user to upload a CSV file and modify the plots according to the data in it.
Is it possible to do this with the available widgets of Bokeh?
Thank you very much. </p>
| 0debug
|
Can somebody help me link my external style sheet? : <head>
<link rel="stylesheet" type="text/css" href="css.css"> - external stylesheet
<div class = "idiot" href = "css.css">Purchase!</div>
<title></title>
</head>
<body>
</body>
<style type="text/css">
.idiot{cursor:pointer; }
.idiot:link {
color: gray;
}
.idiot:visited {
color: red;
}
.idiot:hover {
color: black;
}
.idiot:active {
color: blue;}
</style>
</html>
-Under here is what is written in the external stylesheet-
body {background-color:black; }
-So, I click on the link, but nothing pops up, and nothing even happens at all. Can somebody please help?
| 0debug
|
int page_unprotect(target_ulong address, unsigned long pc, void *puc)
{
unsigned int page_index, prot, pindex;
PageDesc *p, *p1;
target_ulong host_start, host_end, addr;
mmap_lock();
host_start = address & qemu_host_page_mask;
page_index = host_start >> TARGET_PAGE_BITS;
p1 = page_find(page_index);
if (!p1) {
mmap_unlock();
return 0;
}
host_end = host_start + qemu_host_page_size;
p = p1;
prot = 0;
for(addr = host_start;addr < host_end; addr += TARGET_PAGE_SIZE) {
prot |= p->flags;
p++;
}
if (prot & PAGE_WRITE_ORG) {
pindex = (address - host_start) >> TARGET_PAGE_BITS;
if (!(p1[pindex].flags & PAGE_WRITE)) {
mprotect((void *)g2h(host_start), qemu_host_page_size,
(prot & PAGE_BITS) | PAGE_WRITE);
p1[pindex].flags |= PAGE_WRITE;
tb_invalidate_phys_page(address, pc, puc);
#ifdef DEBUG_TB_CHECK
tb_invalidate_check(address);
#endif
mmap_unlock();
return 1;
}
}
mmap_unlock();
return 0;
}
| 1threat
|
static int mkv_write_tracks(AVFormatContext *s)
{
MatroskaMuxContext *mkv = s->priv_data;
AVIOContext *dyn_cp, *pb = s->pb;
ebml_master tracks;
int i, ret, default_stream_exists = 0;
ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_TRACKS, avio_tell(pb));
if (ret < 0)
return ret;
ret = start_ebml_master_crc32(pb, &dyn_cp, &tracks, MATROSKA_ID_TRACKS, 0);
if (ret < 0)
return ret;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
default_stream_exists |= st->disposition & AV_DISPOSITION_DEFAULT;
}
for (i = 0; i < s->nb_streams; i++) {
ret = mkv_write_track(s, mkv, i, dyn_cp, default_stream_exists);
if (ret < 0)
return ret;
}
end_ebml_master_crc32(pb, &dyn_cp, mkv, tracks);
return 0;
}
| 1threat
|
static qemu_irq *ppce500_init_mpic(MachineState *machine, PPCE500Params *params,
MemoryRegion *ccsr, qemu_irq **irqs)
{
qemu_irq *mpic;
DeviceState *dev = NULL;
SysBusDevice *s;
int i;
mpic = g_new0(qemu_irq, 256);
if (kvm_enabled()) {
Error *err = NULL;
if (machine_kernel_irqchip_allowed(machine)) {
dev = ppce500_init_mpic_kvm(params, irqs, &err);
}
if (machine_kernel_irqchip_required(machine) && !dev) {
error_reportf_err(err,
"kernel_irqchip requested but unavailable: ");
exit(1);
}
}
if (!dev) {
dev = ppce500_init_mpic_qemu(params, irqs);
}
for (i = 0; i < 256; i++) {
mpic[i] = qdev_get_gpio_in(dev, i);
}
s = SYS_BUS_DEVICE(dev);
memory_region_add_subregion(ccsr, MPC8544_MPIC_REGS_OFFSET,
s->mmio[0].memory);
return mpic;
}
| 1threat
|
static int gif_read_image(GifState *s, AVFrame *frame)
{
int left, top, width, height, bits_per_pixel, code_size, flags;
int is_interleaved, has_local_palette, y, pass, y1, linesize, n, i;
uint8_t *ptr, *spal, *palette, *ptr1;
left = bytestream_get_le16(&s->bytestream);
top = bytestream_get_le16(&s->bytestream);
width = bytestream_get_le16(&s->bytestream);
height = bytestream_get_le16(&s->bytestream);
flags = bytestream_get_byte(&s->bytestream);
is_interleaved = flags & 0x40;
has_local_palette = flags & 0x80;
bits_per_pixel = (flags & 0x07) + 1;
av_dlog(s->avctx, "gif: image x=%d y=%d w=%d h=%d\n", left, top, width, height);
if (has_local_palette) {
bytestream_get_buffer(&s->bytestream, s->local_palette, 3 * (1 << bits_per_pixel));
palette = s->local_palette;
} else {
palette = s->global_palette;
bits_per_pixel = s->bits_per_pixel;
}
if (left + width > s->screen_width ||
top + height > s->screen_height)
return AVERROR(EINVAL);
n = (1 << bits_per_pixel);
spal = palette;
for(i = 0; i < n; i++) {
s->image_palette[i] = (0xffu << 24) | AV_RB24(spal);
spal += 3;
}
for(; i < 256; i++)
s->image_palette[i] = (0xffu << 24);
if (s->transparent_color_index >= 0)
s->image_palette[s->transparent_color_index] = 0;
code_size = bytestream_get_byte(&s->bytestream);
ff_lzw_decode_init(s->lzw, code_size, s->bytestream,
s->bytestream_end - s->bytestream, FF_LZW_GIF);
linesize = frame->linesize[0];
ptr1 = frame->data[0] + top * linesize + left;
ptr = ptr1;
pass = 0;
y1 = 0;
for (y = 0; y < height; y++) {
ff_lzw_decode(s->lzw, ptr, width);
if (is_interleaved) {
switch(pass) {
default:
case 0:
case 1:
y1 += 8;
ptr += linesize * 8;
if (y1 >= height) {
y1 = pass ? 2 : 4;
ptr = ptr1 + linesize * y1;
pass++;
}
break;
case 2:
y1 += 4;
ptr += linesize * 4;
if (y1 >= height) {
y1 = 1;
ptr = ptr1 + linesize;
pass++;
}
break;
case 3:
y1 += 2;
ptr += linesize * 2;
break;
}
} else {
ptr += linesize;
}
}
ff_lzw_decode_tail(s->lzw);
s->bytestream = ff_lzw_cur_ptr(s->lzw);
return 0;
}
| 1threat
|
Getting undefined values from JavaScript array : <p>I am getting response something like this in the form JavaScript Object </p>
<pre><code>{
"result": [
{
"invoice_prefix": "INV",
"maximum_invoice_no": "0009"
}
]
}
</code></pre>
<p>I am trying to fetch the value of invoice_prefix and maximum_invoice_no
I have written result[0].maximum_invoice_no but I am getting undefined .
I have tried a lot of other ways also but still getting undefined . Please help me and give me some hint </p>
| 0debug
|
Calculate the estimated travel time Google Maps : <p>How can I calculate the estimated travel time on a route with react and google-maps?</p>
| 0debug
|
character in string between other strings : how to find character or a word in string between other strings? for example I want to find
"<"
character between <tag> and </tag> tags in string below:
"<tag>some text some text < text</tag>"
| 0debug
|
Error c2064 when passing an object vector by reference : <p>I was making coding for fun with vectors, but then I bumped into this error:
Error c2064 'This term doesn't give back a function that accepts 1 arguments';
The error is given in line 33, when I call the function 'ins' passing my vector 'Vett' as an argument, as said in the function declaration.</p>
<p>Code:</p>
<pre><code>struct Num_and_Car {
int n;
char c;
`};`
bool pari (Num_and_Car Acces) {
if (Acces.n % 2 == 0)
return true;
else return false;`
}
void ins (std::vector <Num_and_Car>Vettore) {
int ins;
for (int i = 0; Vettore[i].n != 0; i++) {
std::cin >> ins;
std::cout << "Succesfull\n";
if (ins == 0)
break;
else
Vettore.push_back({ ins });
std::cout << "Succesfull\n";
}
}
int main () {
int ins = 0;
std::vector <Num_and_Car> Vett;
std::cout <<"Succesfull\n";
Vett.push_back({1 });
ins (Vett);
std::cout <<"Succesfull\n";
int n = std::count_if(Vett.begin(), Vett.end(), pari);
std::cout << n <<"pari\n";
std::cin >> n;
}
</code></pre>
<p>Thanks in advice for any help.</p>
| 0debug
|
How to exit bash function if error? : <p>I am making a presubmit script. It looks like this:</p>
<pre><code>function presubmit() {
gradle test android
gradle test ios
gradle test server
git push origin master
}
</code></pre>
<p>I want the function to exit, if any of the tests fail so it won't push a bug to git. How?</p>
| 0debug
|
How to fix NumberFormatException for input string "0.40" : <p>i am trying to convert string value to long for further processing but this error occurs everytime </p>
<pre><code>13-Feb-2019 13:15:35.593 SEVERE [http-nio-8084-exec-570] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service()
java.lang.NumberFormatException: For input string: "0.40"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:589)
at java.lang.Long.parseLong(Long.java:631)
</code></pre>
| 0debug
|
int qemu_poll_ns(GPollFD *fds, guint nfds, int64_t timeout)
{
#ifdef CONFIG_PPOLL
if (timeout < 0) {
return ppoll((struct pollfd *)fds, nfds, NULL, NULL);
} else {
struct timespec ts;
int64_t tvsec = timeout / 1000000000LL;
if (tvsec > (int64_t)INT32_MAX) {
tvsec = INT32_MAX;
}
ts.tv_sec = tvsec;
ts.tv_nsec = timeout % 1000000000LL;
return ppoll((struct pollfd *)fds, nfds, &ts, NULL);
}
#else
return g_poll(fds, nfds, qemu_timeout_ns_to_ms(timeout));
#endif
}
| 1threat
|
int ff_get_line(AVIOContext *s, char *buf, int maxlen)
{
int i = 0;
char c;
do {
c = avio_r8(s);
if (c && i < maxlen-1)
buf[i++] = c;
} while (c != '\n' && c != '\r' && c);
if (c == '\r' && avio_r8(s) != '\n')
avio_skip(s, -1);
buf[i] = 0;
return i;
}
| 1threat
|
Opening a download file and coping it : I am tryiing to openn a file I demand from mmy user to download so i can use it so i am tryin to copy it to my internal storage
i tried using this code:
Intent myIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
myIntent.setType("text/*");
myIntent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(myIntent, 100);
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 100) {
if(resultCode == Activity.RESULT_OK){
Uri result= data.getData();
Log.e("fag", result.getPath());
copyFile(result);
}
if (resultCode == Activity.RESULT_CANCELED) {
Log.e("", "canceled");
}
}
Intent a = new Intent(getApplicationContext(), MainActivity.class);
startActivity(a);
}
private void copyFile(Uri inputFile) {
FileInputStream in = null;
FileOutputStream out = null;
try {
in = new FileInputStream(inputFile.getPath());
out = openFileOutput(NAME , MODE_PRIVATE);
byte[] buffer = new byte[1024];
while ( in.read(buffer) != -1) {
out.write(buffer);
}
in.close();
in = null;
out.close();
out = null;
} catch (FileNotFoundException fnfe1) {
Log.e("tag", fnfe1.getMessage());
fnfe1.printStackTrace();
}
catch (Exception e) {
Log.e("tag", e.getMessage());
}
}
but when i run this cod i get a file not found exception. so i checked what uri i get drom the intent and it isn't the path to the file but this path
/document/primary:Download/5643_05072018-13-48.csv
and i dont know how to use this uri.
I got a simmmilar resualt using the ACTION_GET_CONTENT intent.
can someone show me how to use it?
| 0debug
|
Intellij Java 2016 & Maven : how to embed dependencies in JAR? : <p>I'm using Intellij Java 2016.2.2 and Maven to create a very simple Java console application.</p>
<p>I want to add an external library, so I add my dependency in Maven like this:</p>
<pre><code><dependency>
<groupId>jline</groupId>
<artifactId>jline</artifactId>
<version>2.12</version>
</dependency>
</code></pre>
<p>It works fine when I run it in the IDE, but not in an external console (I have the following error: <em>java.lang.NoClassDefFoundError</em>).</p>
<p>I checked and for some reason, the external JAR is not added in the JAR I just generated. I also tried many things in "File -> Project Structure", but still not working...</p>
<p>I just want to build my JAR with my dependencies in it, so I can simply run my application in a console using:</p>
<pre><code>java -jar myproject.jar
</code></pre>
<p>How can I do that? Thanks for your help!</p>
| 0debug
|
Too many if statements in JAVA : <p>Hello I'm trying to make a java program where a user can enter different commands and this class can identify all the commands and based on that it calls methods from 3-4 different classes. currently for each command I have different if statements as such:</p>
<pre><code>if (input.equals("change category FOOD"){...}
if (input.equals("Sort by price FOOD"){...}
if (input.equals("logout"){...}
</code></pre>
<p>There are so many commands, and I wanted to know if there is a way to shorten this up.</p>
| 0debug
|
static void write_section_data(MpegTSContext *ts, MpegTSFilter *tss1,
const uint8_t *buf, int buf_size, int is_start)
{
MpegTSSectionFilter *tss = &tss1->u.section_filter;
int len;
if (is_start) {
memcpy(tss->section_buf, buf, buf_size);
tss->section_index = buf_size;
tss->section_h_size = -1;
tss->end_of_section_reached = 0;
} else {
if (tss->end_of_section_reached)
return;
len = 4096 - tss->section_index;
if (buf_size < len)
len = buf_size;
memcpy(tss->section_buf + tss->section_index, buf, len);
tss->section_index += len;
}
if (tss->section_h_size == -1 && tss->section_index >= 3) {
len = (AV_RB16(tss->section_buf + 1) & 0xfff) + 3;
if (len > 4096)
return;
tss->section_h_size = len;
}
if (tss->section_h_size != -1 &&
tss->section_index >= tss->section_h_size) {
int crc_valid = 1;
tss->end_of_section_reached = 1;
if (tss->check_crc) {
crc_valid = !av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1, tss->section_buf, tss->section_h_size);
if (crc_valid) {
ts->crc_validity[ tss1->pid ] = 100;
}else if (ts->crc_validity[ tss1->pid ] > -10) {
ts->crc_validity[ tss1->pid ]--;
}else
crc_valid = 2;
}
if (crc_valid)
tss->section_cb(tss1, tss->section_buf, tss->section_h_size);
}
}
| 1threat
|
how to run python script to send data to google pubsub : From google console i am creating a topic and publish it which is working fine now i want to do it from python script which i have done but i don't know where to put those files in google pub/sub. Can some one please teach me how can i accomplish it by using script. I am new and i am student. i have never used google pub/sub. I just want to make some random data and send it to pub/sub that's all i want. Some one told i need web hosting to run those scripts, is it true? kindly please guide me briefly for 3 days i am reading docs and now everything is now messed up in my mind. In advance thank you.
| 0debug
|
static av_cold int tqi_decode_init(AVCodecContext *avctx)
{
TqiContext *t = avctx->priv_data;
ff_blockdsp_init(&t->bdsp, avctx);
ff_bswapdsp_init(&t->bsdsp);
ff_idctdsp_init(&t->idsp, avctx);
ff_init_scantable_permutation(t->idsp.idct_permutation, FF_IDCT_PERM_NONE);
ff_init_scantable(t->idsp.idct_permutation, &t->intra_scantable, ff_zigzag_direct);
avctx->framerate = (AVRational){ 15, 1 };
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
ff_mpeg12_init_vlcs();
return 0;
}
| 1threat
|
Is there a callback for window.scrollTo? : <p>I want to call <code>focus()</code> on an input after the widow scrolled. I'm using the smooth behavior for the <code>scrollTo()</code> method. The problem is the <code>focus</code> method cut the smooth behavior. The solution is to call the <code>focus</code> function just after the scroll end. </p>
<p>But I can't find any doc or threads speaking about how to detect the end of <code>scrollTo</code> method.</p>
<pre><code>let el = document.getElementById('input')
let elScrollOffset = el.getBoundingClientRect().top
let scrollOffset = window.pageYOffset || document.documentElement.scrollTop
let padding = 12
window.scrollTo({
top: elScrollOffset + scrollOffset - padding,
behavior: 'smooth'
})
// wait for the end of scrolling and then
el.focus()
</code></pre>
<p>Any ideas?</p>
| 0debug
|
Hwo to design this site menu style in WPF : I do not speak English well. So, I used Google translator. Sorry...
I am trying to implement www.devexpress.com menu.
But I do not know what to do to implement the unfolding details below.
this is my source file.
[enter link description here][1]
[1]: https://drive.google.com/open?id=0B2twYdJfAGHHYXUtU0I4YVdRak0
thank you.
| 0debug
|
static void free_test_data(test_data *data)
{
AcpiSdtTable *temp;
int i;
if (data->rsdt_tables_addr) {
g_free(data->rsdt_tables_addr);
}
for (i = 0; i < data->tables->len; ++i) {
temp = &g_array_index(data->tables, AcpiSdtTable, i);
if (temp->aml) {
g_free(temp->aml);
}
if (temp->aml_file) {
if (!temp->tmp_files_retain &&
g_strstr_len(temp->aml_file, -1, "aml-")) {
unlink(temp->aml_file);
}
g_free(temp->aml_file);
}
if (temp->asl) {
g_free(temp->asl);
}
if (temp->asl_file) {
if (!temp->tmp_files_retain) {
unlink(temp->asl_file);
}
g_free(temp->asl_file);
}
}
g_array_free(data->tables, false);
}
| 1threat
|
How to use array_slice in this type $_POST['MetaData']['video_title'][$index] : <p>How to use array_slice in this type of array
$_POST['MetaData']['video_title'][$index]</p>
| 0debug
|
How to play videos using Unity VideoPlayer and VideoClip API on Android in 5.6.0b1 : <p>Unity introduced new functionality in 5.6.0b1 release and now it is possilbe to play videos on iPhone and Android. </p>
<p>I managed to make it work on iphone and Windows, but on Android it is stuck on "Preparing" the video.</p>
<p>This is the code I used</p>
<pre><code>public VideoClip videoToPlay;
private VideoPlayer videoPlayer;
private VideoSource videoSource;
//Audio
private AudioSource audioSource;
// Use this for initialization
void Start()
{
Application.runInBackground = true;
StartCoroutine(playVideo());
}
IEnumerator playVideo()
{
//Add VideoPlayer to the GameObject
videoPlayer = gameObject.AddComponent<VideoPlayer>();
//Add AudioSource
audioSource = gameObject.AddComponent<AudioSource>();
//Disable Play on Awake for both Video and Audio
videoPlayer.playOnAwake = false;
audioSource.playOnAwake = false;
//We want to play from video clip not from url
videoPlayer.source = VideoSource.VideoClip;
//Set video To Play then prepare Audio to prevent Buffering
// videoPlayer.clip = videoToPlay;
videoPlayer.url = Application.streamingAssetsPath + "/TestVideo.MP4";
videoPlayer.source = VideoSource.Url;
VideoClip clip = new VideoClip();
//Set Audio Output to AudioSource
videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
//Assign the Audio from Video to AudioSource to be played
videoPlayer.EnableAudioTrack(0, true);
videoPlayer.SetTargetAudioSource(0, audioSource);
videoPlayer.Prepare();
//Wait until video is prepared
while (!videoPlayer.isPrepared)
{
Debug.Log("Preparing Video");
yield return null;
}
Debug.Log("Done Preparing Video");
//Play Video
videoPlayer.Play();
//Play Sound
audioSource.Play();
Debug.Log("Playing Video");
while (videoPlayer.isPlaying)
{
yield return null;
}
Debug.Log("Done Playing Video");
}
</code></pre>
<p>P.S.</p>
<p>In Unity documentation I found that when using android, I need to use WWW class to retrieve the files. The problem is that only MovieTexture is available and no VideoClip from WWW object. Is there a way to convert it?</p>
| 0debug
|
static void gen_load_fp(DisasContext *s, int opsize, TCGv addr, TCGv_ptr fp)
{
TCGv tmp;
TCGv_i64 t64;
int index = IS_USER(s);
t64 = tcg_temp_new_i64();
tmp = tcg_temp_new();
switch (opsize) {
case OS_BYTE:
tcg_gen_qemu_ld8s(tmp, addr, index);
gen_helper_exts32(cpu_env, fp, tmp);
break;
case OS_WORD:
tcg_gen_qemu_ld16s(tmp, addr, index);
gen_helper_exts32(cpu_env, fp, tmp);
break;
case OS_LONG:
tcg_gen_qemu_ld32u(tmp, addr, index);
gen_helper_exts32(cpu_env, fp, tmp);
break;
case OS_SINGLE:
tcg_gen_qemu_ld32u(tmp, addr, index);
gen_helper_extf32(cpu_env, fp, tmp);
break;
case OS_DOUBLE:
tcg_gen_qemu_ld64(t64, addr, index);
gen_helper_extf64(cpu_env, fp, t64);
tcg_temp_free_i64(t64);
break;
case OS_EXTENDED:
if (m68k_feature(s->env, M68K_FEATURE_CF_FPU)) {
gen_exception(s, s->insn_pc, EXCP_FP_UNIMP);
break;
}
tcg_gen_qemu_ld32u(tmp, addr, index);
tcg_gen_shri_i32(tmp, tmp, 16);
tcg_gen_st16_i32(tmp, fp, offsetof(FPReg, l.upper));
tcg_gen_addi_i32(tmp, addr, 4);
tcg_gen_qemu_ld64(t64, tmp, index);
tcg_gen_st_i64(t64, fp, offsetof(FPReg, l.lower));
break;
case OS_PACKED:
gen_exception(s, s->insn_pc, EXCP_FP_UNIMP);
break;
default:
g_assert_not_reached();
}
tcg_temp_free(tmp);
tcg_temp_free_i64(t64);
}
| 1threat
|
Typescript: is not assignable to type error : <p>I am new to using typescript with angular 2. I am using version 1 of angular 2-cli. When compiling, I get this error saying "is not assignable to type Assignment[]". I looked at the data types and it looks okay so far, but I am not sure what the error is exactly. Thanks for your help. </p>
<p><strong>Here is a photo of the error from the console.</strong>
<a href="https://i.stack.imgur.com/O37l4.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/O37l4.jpg" alt="enter image description here"></a></p>
<p><strong>data.ts file - these are two of the items that appear in the array</strong></p>
<pre><code>export const Assignments: Assignment[] = [
{
"a_type": "one",
"a_title": "Assignment 1",
"symbol": 1,
"show": false,
"tooltip": {
"left": 82
},
"buttonPos":{
"left": 130
},
"printTop": 0,
"instructions": "Instructions here",
"due_date": "sept-15.png",
"percentage": "10.png",
"taskA": {
"name": "Option A",
"a_title": "Task A",
"information": "Instructions for task A",
"selectA": true
}
}, {
"a_type": "two",
"a_title": "Assignment 2",
"symbol": 2,
"show": false,
"sub_a_title": "Assignment Information",
"tooltip": {
"left": 200
},
"buttonPos":{
"left": 250
},
"printTop": 250,
"instructions": "Instructions here",
"due_date": "29.png",
"percentage": "10.png",
"taskA": {
"a_title": "Assignment 2 info",
"name": "Option A",
"information": "Instructions for task A",
"selectA": false
},
"taskB": {
"a_title": "Assignment 2 info",
"name": "Option B",
"information": "Instructions for task B",
"selectB": false
}
}
]
</code></pre>
<p><strong>assignment.ts - here's the data types</strong></p>
<pre><code>export class Assignment {
a_type: string;
a_title: string;
symbol: any;
show: boolean;
tooltip: any;
left: number;
buttonPos:any;
printTop: number;
instructions: string;
due_date: string;
percentage: string;
taskA: any;
name: string;
information: string;
selectA: boolean;
taskB: any;
selectB: boolean;
}
</code></pre>
| 0debug
|
Having 4 words, need randomly generate with button to Label1. Delphi XE3 : <p>How to do it?
I have Label1, Button1 and 4 different words on a,b,c,d. I need randomly place one of these words to Label1. How to do it?</p>
| 0debug
|
For loop in javascript (using .then, .catch and return) only goes trough once : I am creating a discord bot, but i am still very new. I am using the `jimp` image cropper to get an image from an url and then crop it into 5 pieces of same sizes. This is my code:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
var Discord = require('discord.js');
var auth = require('./author.json');
var https = require('https');
var fs = require('fs');
var Jimp = require('jimp');
var bot = new Discord.Client({
});
bot.login(auth.token);
bot.on('message', function(message, channelID, userID, user, evt) {
if (message.content.toString().includes(bot.user.toString())) {
message.channel.send("Use / instead")
}
if(message.content.toString()=="/ping"){
message.channel.send("pong")
}
if(message.attachments && message.content.toString().includes("/split")){
Jimp.read(message.attachments.array()[0].url)
.then (image =>{
for(var i=0;i<5;i++)
{
return image
.clone().crop(0,image.bitmap.height/5*i,image.bitmap.width,image.bitmap.height/5)
.write('./files/cropped'+i+'.png')
console.log(i);
}
})
.catch(err => {
console.error(err);
});
}
});
<!-- end snippet -->
The `for` loop only executes once here. If i try to remove `return` and keep only image then it properly creates 5 crops, but it gives me and error:`UnhandledPromiseRejectionWarning`.
Thank you for your help!
| 0debug
|
Android - Cannot resolve symbol Toast : <p>This happens alot to me... I often find code on SO but users do not add the necessary imports.</p>
<p>I get <code>Cannot resolve symbol Toast</code></p>
<p>I searched the documentation of toast, but I am unable to find the necessary import line. I tried <code>import ui.notifiers.toasts</code> because it is in the URL, but does not work.</p>
<p><a href="https://developer.android.com/guide/topics/ui/notifiers/toasts" rel="nofollow noreferrer">https://developer.android.com/guide/topics/ui/notifiers/toasts</a></p>
| 0debug
|
void ff_h264_write_back_intra_pred_mode(H264Context *h){
int8_t *mode= h->intra4x4_pred_mode + h->mb2br_xy[h->mb_xy];
AV_COPY32(mode, h->intra4x4_pred_mode_cache + 4 + 8*4);
mode[4]= h->intra4x4_pred_mode_cache[7+8*3];
mode[5]= h->intra4x4_pred_mode_cache[7+8*2];
mode[6]= h->intra4x4_pred_mode_cache[7+8*1];
}
| 1threat
|
How do I use openpyxl to express a spreadsheets' columns as values? : In Python, calling a column from the spreadsheet and printing it just returns <Cell 'File Name' .A000> but what I want is the singular number that is in the cell. I can't figure out from openpyxl's documentation how to do this for the whole column the same way you can a singular cell.
| 0debug
|
MySql Database Error Issue : I need help for fixing database error. I am getting an error like this:
I am new to mysql.
*****************************************************************************
Database error: Invalid SQL: CREATE TABLE gl2preethyd1495077842 AS SELECT chart_id, sum(a.amount) as dr, sum(a.amount) as cr FROM acc_trans a join gl b left outer join ar c ON a.trans_id=c.id WHERE if ( c.service_completion is null, ( a.transdate <='' and a.transdate >= '' ), ( c.service_completion <='' and c.service_completion >= '' ) ) and a.trans_id=b.id GROUP BY chart_id ORDER BY chart_id
MySQL Error: 1054 (Unknown column 'c.service_completion' in 'where clause')
Session halted.
******************************************************************************
CODE:
$sql = "CREATE TABLE $temp2 AS " ;
$sql.= "SELECT chart_id, sum(a.amount) as dr, sum(a.amount) as cr FROM acc_trans a join gl b left outer join ar c ON a.trans_id=c.id " ;
$sql .="WHERE if ( c.service_completion is null, ( a.transdate <='$TB_ToDate' and a.transdate >= '$TB_FromDate' ), ( c.service_completion <='$TB_ToDate' and c.service_completion >= '$TB_FromDate' ) ) and a.trans_id=b.id ";
if ($attrib1<>'') $sql .= " and attrib1=$attrib1 " ;
if ($attrib2<>'') $sql .= " and attrib2=$attrib2 " ;
if ($attrib3<>'') $sql .= " and attrib3=$attrib3 " ;
$sql.= "GROUP BY chart_id ORDER BY chart_id" ;
Can you guys help me to fix the issue ASAP? I am unable to find where the issue is.
| 0debug
|
static float get_band_cost_UQUAD_mips(struct AACEncContext *s,
PutBitContext *pb, const float *in,
const float *scaled, int size, int scale_idx,
int cb, const float lambda, const float uplim,
int *bits)
{
const float Q34 = ff_aac_pow34sf_tab[POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512];
const float IQ = ff_aac_pow2sf_tab [POW_SF2_ZERO + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
int i;
float cost = 0;
int curbits = 0;
int qc1, qc2, qc3, qc4;
uint8_t *p_bits = (uint8_t*)ff_aac_spectral_bits[cb-1];
float *p_codes = (float *)ff_aac_codebook_vectors[cb-1];
for (i = 0; i < size; i += 4) {
const float *vec;
int curidx;
float *in_pos = (float *)&in[i];
float di0, di1, di2, di3;
int t0, t1, t2, t3, t4;
qc1 = scaled[i ] * Q34 + ROUND_STANDARD;
qc2 = scaled[i+1] * Q34 + ROUND_STANDARD;
qc3 = scaled[i+2] * Q34 + ROUND_STANDARD;
qc4 = scaled[i+3] * Q34 + ROUND_STANDARD;
__asm__ volatile (
".set push \n\t"
".set noreorder \n\t"
"ori %[t4], $zero, 2 \n\t"
"slt %[t0], %[t4], %[qc1] \n\t"
"slt %[t1], %[t4], %[qc2] \n\t"
"slt %[t2], %[t4], %[qc3] \n\t"
"slt %[t3], %[t4], %[qc4] \n\t"
"movn %[qc1], %[t4], %[t0] \n\t"
"movn %[qc2], %[t4], %[t1] \n\t"
"movn %[qc3], %[t4], %[t2] \n\t"
"movn %[qc4], %[t4], %[t3] \n\t"
".set pop \n\t"
: [qc1]"+r"(qc1), [qc2]"+r"(qc2),
[qc3]"+r"(qc3), [qc4]"+r"(qc4),
[t0]"=&r"(t0), [t1]"=&r"(t1), [t2]"=&r"(t2), [t3]"=&r"(t3),
[t4]"=&r"(t4)
);
curidx = qc1;
curidx *= 3;
curidx += qc2;
curidx *= 3;
curidx += qc3;
curidx *= 3;
curidx += qc4;
curbits += p_bits[curidx];
curbits += uquad_sign_bits[curidx];
vec = &p_codes[curidx*4];
__asm__ volatile (
".set push \n\t"
".set noreorder \n\t"
"lwc1 %[di0], 0(%[in_pos]) \n\t"
"lwc1 %[di1], 4(%[in_pos]) \n\t"
"lwc1 %[di2], 8(%[in_pos]) \n\t"
"lwc1 %[di3], 12(%[in_pos]) \n\t"
"abs.s %[di0], %[di0] \n\t"
"abs.s %[di1], %[di1] \n\t"
"abs.s %[di2], %[di2] \n\t"
"abs.s %[di3], %[di3] \n\t"
"lwc1 $f0, 0(%[vec]) \n\t"
"lwc1 $f1, 4(%[vec]) \n\t"
"lwc1 $f2, 8(%[vec]) \n\t"
"lwc1 $f3, 12(%[vec]) \n\t"
"nmsub.s %[di0], %[di0], $f0, %[IQ] \n\t"
"nmsub.s %[di1], %[di1], $f1, %[IQ] \n\t"
"nmsub.s %[di2], %[di2], $f2, %[IQ] \n\t"
"nmsub.s %[di3], %[di3], $f3, %[IQ] \n\t"
".set pop \n\t"
: [di0]"=&f"(di0), [di1]"=&f"(di1),
[di2]"=&f"(di2), [di3]"=&f"(di3)
: [in_pos]"r"(in_pos), [vec]"r"(vec),
[IQ]"f"(IQ)
: "$f0", "$f1", "$f2", "$f3",
"memory"
);
cost += di0 * di0 + di1 * di1
+ di2 * di2 + di3 * di3;
}
if (bits)
*bits = curbits;
return cost * lambda + curbits;
}
| 1threat
|
Add checkbox button : <p>I'm creating list view with checkboxes, and I need in this a button that adds next checkbox in my form app. I know how to add single box, but idk how to make a loop that will helps me to add next checkboxes. Here, I give u a piece of code. At the start I have 24 checkboxes, next must be on 612 px position. </p>
<pre><code>private void btnAdd_Click(object sender, EventArgs e)
{
CheckBox box;
box = new CheckBox();
box.AutoSize = true;
box.Location = new Point(30, 612);
this.Controls.Add(box);
}
</code></pre>
| 0debug
|
How to initialize biases in a Keras model? : <p>I am trying to build a synthetic model in Keras, and I need to assign values for the weights and biases. Assigning the weights is easy, I am using the instructions provided here: <a href="https://keras.io/initializations/" rel="noreferrer">https://keras.io/initializations/</a>.
However, I could not find any instructions on how to assign the biases. Any ideas?</p>
| 0debug
|
atal error: Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\hotelmenuentry\process.php:8 : <p>"Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\hotelmenuentry\process.php:8 Stack trace: #0 {main} thrown in C:\xampp\htdocs\hotelmenuentry\process.php on line 8"</p>
<p>Please give me solution.</p>
| 0debug
|
How to show json value in php page : someone please tell me how we can show this value on php file viea {echo json_encode($array);} ?
var formData=new FormData();
formData.append("fieldname","value");
formData.append("image",$('[name="filename"]')[0].files[0]);
$.ajax({
url:"page.php",
data:formData,
type: 'POST',
dataType:"JSON",
cache: false,
contentType: false,
processData: false,
success:function(data){ }
});
| 0debug
|
How to define swagger property that is an unknown name? : <p>I need to define a swagger property that doesn't have a known name.</p>
<pre><code>{
"type": "object",
"properties": {
"?????": {
"type": "array",
"items": { "$ref": "#/definitions/ModelRelease" }
}
}
</code></pre>
<p>The ????? portion of my definition is an integer of an unknown value. Any ideas?</p>
| 0debug
|
run batch code in vba to open a specific access file in runtime : How would I run the following in a shell statement in ms access?
"C:\Program Files (x86)\Microsoft Office\Office14\msaccess.exe" "http://stoneplastics/Departments/Quality/Databases/LabelsNewRelease.accdb" /runtime
It works fine in a batch file.
I have tried for 3 hours to get this to work and I am having trouble
| 0debug
|
static void mirror_do_zero_or_discard(MirrorBlockJob *s,
int64_t sector_num,
int nb_sectors,
bool is_discard)
{
MirrorOp *op;
op = g_new0(MirrorOp, 1);
op->s = s;
op->sector_num = sector_num;
op->nb_sectors = nb_sectors;
s->in_flight++;
s->sectors_in_flight += nb_sectors;
if (is_discard) {
blk_aio_pdiscard(s->target, sector_num << BDRV_SECTOR_BITS,
op->nb_sectors << BDRV_SECTOR_BITS,
mirror_write_complete, op);
} else {
blk_aio_pwrite_zeroes(s->target, sector_num * BDRV_SECTOR_SIZE,
op->nb_sectors * BDRV_SECTOR_SIZE,
s->unmap ? BDRV_REQ_MAY_UNMAP : 0,
mirror_write_complete, op);
}
}
| 1threat
|
Chat App using Firebase: Get notification when new message received - Android : <p>I am developing a chat app using Firebase Realtime Database. I have been able to send and receive messages properly. Now, I want to implement notification whenever new message is received. For that, I have created a <code>Service</code> which listens to database changes using <code>ChildEventListener</code> and creates notification. The problem is that I am creating notification in <code>onChildAdded</code> method and this method fires both for existing node in database and new one. This is causing notification to be created multiple times for same message whenever user navigate back and forth from app. </p>
<p>Here is how I am implementing it:</p>
<pre><code>chatMsgsRef.orderByChild(FirebaseDBKeys.LOCATION_LAST_UPDATED).addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
ChatMessage message = dataSnapshot.getValue(ChatMessage.class);
if (!message.getSenderId().equals(currentUserId)) {
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(NotificationsService.this)
.setSmallIcon(R.drawable.message)
.setContentTitle("New Message from " + message.getReceipientName())
.setContentText(message.getMessage())
.setOnlyAlertOnce(true)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
mBuilder.setAutoCancel(true);
mBuilder.setLocalOnly(false);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
</code></pre>
<p>How can I implement notifications in the way it works in other chat applications like whatsapp, etc.??</p>
| 0debug
|
static av_cold int msrle_decode_init(AVCodecContext *avctx)
{
MsrleContext *s = avctx->priv_data;
s->avctx = avctx;
switch (avctx->bits_per_coded_sample) {
case 4:
case 8:
avctx->pix_fmt = AV_PIX_FMT_PAL8;
break;
case 24:
avctx->pix_fmt = AV_PIX_FMT_BGR24;
break;
default:
av_log(avctx, AV_LOG_ERROR, "unsupported bits per sample\n");
return AVERROR_INVALIDDATA;
}
s->frame.data[0] = NULL;
return 0;
}
| 1threat
|
How to return an Int from one method to another in java : <pre><code>public static void main(){
getNumber();
printNumber();
int x;
}
public static int getNumber(){
int x = 5;
return(x);
}
public static void printNumber(){
System.out.println(x);
}
</code></pre>
<p>I am a total beginner, sorry for such a simple question. The above fragment of code is what I tried.</p>
| 0debug
|
def decimal_to_binary(n):
return bin(n).replace("0b","")
| 0debug
|
OpenTracing doesn't send logs with Serilog : <p>I'm trying to use <a href="https://github.com/opentracing-contrib/csharp-netcore" rel="noreferrer">OpenTracing.Contrib.NetCore</a> with Serilog. I need to send to Jaeger my custom logs. Now, it works only when I use default logger factory <code>Microsoft.Extensions.Logging.ILoggerFactory</code></p>
<p>My Startup:</p>
<pre><code>public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddSingleton<ITracer>(sp =>
{
var loggerFactory = sp.GetRequiredService<ILoggerFactory>();
string serviceName = sp.GetRequiredService<IHostingEnvironment>().ApplicationName;
var samplerConfiguration = new Configuration.SamplerConfiguration(loggerFactory)
.WithType(ConstSampler.Type)
.WithParam(1);
var senderConfiguration = new Configuration.SenderConfiguration(loggerFactory)
.WithAgentHost("localhost")
.WithAgentPort(6831);
var reporterConfiguration = new Configuration.ReporterConfiguration(loggerFactory)
.WithLogSpans(true)
.WithSender(senderConfiguration);
var tracer = (Tracer)new Configuration(serviceName, loggerFactory)
.WithSampler(samplerConfiguration)
.WithReporter(reporterConfiguration)
.GetTracer();
//GlobalTracer.Register(tracer);
return tracer;
});
services.AddOpenTracing();
}
</code></pre>
<p>and somewhere in controller:</p>
<pre><code>[Route("api/[controller]")]
public class ValuesController : ControllerBase
{
private readonly ILogger<ValuesController> _logger;
public ValuesController(ILogger<ValuesController> logger)
{
_logger = logger;
}
[HttpGet("{id}")]
public ActionResult<string> Get(int id)
{
_logger.LogWarning("Get values by id: {valueId}", id);
return "value";
}
}
</code></pre>
<p>in a result I will able to see that log in Jaeger UI
<a href="https://i.stack.imgur.com/5at1L.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5at1L.png" alt="enter image description here"></a></p>
<p>But when I use Serilog, there are no any custom logs. I've added <code>UseSerilog()</code> to <code>WebHostBuilder</code>, and all custom logs I can see in console but not in Jaeger.
There is open issue in <a href="https://github.com/jaegertracing/jaeger-client-csharp/issues/146" rel="noreferrer">github</a>. Could you please suggest how I can use Serilog with OpenTracing?</p>
| 0debug
|
signtool.exe set proxy for timestamp in a batch : I want reach the timestamp server for sign a file with signtool.exe behind a firewall, this is my batch file:
signtool.exe timestamp /t http://timestamp-server foo.exe
has sign tool some feature for set the proxy?
| 0debug
|
static int motion_inter_block (bit_buffer_t *bitbuf,
uint8_t *current, uint8_t *previous, int pitch,
svq1_pmv_t *motion, int x, int y) {
uint8_t *src;
uint8_t *dst;
svq1_pmv_t mv;
svq1_pmv_t *pmv[3];
int result;
pmv[0] = &motion[0];
pmv[1] = &motion[(x / 8) + 2];
pmv[2] = &motion[(x / 8) + 4];
if (y == 0) {
pmv[1] = pmv[0];
pmv[2] = pmv[0];
}
result = decode_motion_vector (bitbuf, &mv, pmv);
if (result != 0)
return result;
motion[0].x = mv.x;
motion[0].y = mv.y;
motion[(x / 8) + 2].x = mv.x;
motion[(x / 8) + 2].y = mv.y;
motion[(x / 8) + 3].x = mv.x;
motion[(x / 8) + 3].y = mv.y;
src = &previous[(x + (mv.x >> 1)) + (y + (mv.y >> 1))*pitch];
dst = current;
put_pixels_tab[((mv.y & 1) << 1) | (mv.x & 1)](dst,src,pitch,16);
put_pixels_tab[((mv.y & 1) << 1) | (mv.x & 1)](dst+8,src+8,pitch,16);
return 0;
}
| 1threat
|
Recommended way to install pip(3) on centos7 : <p>I am interrested in knowing the recommended way to install pip3 for python3.6 (as of today, may 2018) on current version of centos7 (7.5.1804) and the accepted answer of <a href="https://stackoverflow.com/questions/32618686/how-to-install-pip-in-centos-7">How to install pip in CentOS 7?</a> seems to be outdated because:</p>
<pre><code>yum search -v pip
</code></pre>
<p>outputs (among other things):</p>
<pre><code>python2-pip.noarch : A tool for installing and managing Python 2 packages
Repo : epel
python34-pip.noarch : A tool for installing and managing Python3 packages
Repo : epel
</code></pre>
<p>and <code>python34-pip</code> seems to be a (newer?) simpler way than the accepted answer of <a href="https://stackoverflow.com/questions/32618686/how-to-install-pip-in-centos-7">How to install pip in CentOS 7?</a> :</p>
<blockquote>
<p>sudo yum install python34-setuptools</p>
<p>sudo easy_install-3.4 pip</p>
</blockquote>
<p>But since the versions of python installed on my machine are 2.7.5 and 3.6.3 why is it python34-pip and not python36-pip ? Is pip the same for 3.4+ (up to current 3.6.3) ?</p>
| 0debug
|
static void qmp_output_complete(Visitor *v, void *opaque)
{
QmpOutputVisitor *qov = to_qov(v);
assert(qov->root && QSLIST_EMPTY(&qov->stack));
assert(opaque == qov->result);
qobject_incref(qov->root);
*qov->result = qov->root;
qov->result = NULL;
}
| 1threat
|
def max_sub_array_sum_repeated(a, n, k):
max_so_far = -2147483648
max_ending_here = 0
for i in range(n*k):
max_ending_here = max_ending_here + a[i%n]
if (max_so_far < max_ending_here):
max_so_far = max_ending_here
if (max_ending_here < 0):
max_ending_here = 0
return max_so_far
| 0debug
|
Check if a date is 24 hours old : <p>I have a created date. I want to run an if/switch statement to know whether the date and time right now is more than 24 hours from the created date.</p>
<p>If the created date is more than 24 hours ago, do something, if it's less than 24 hours ago do something else.</p>
<pre><code>let now = +new Date();
// This is returned as: July 18, 2018 at 3:48:00 AM UTC+1
let createdAt = +doc.data().created_at;
const oneDay = 60 * 60 * 24;
var compareDatesBoolean = (now - createdAt) > oneDay;
</code></pre>
<p>Any guidance here would be great thank you! :)</p>
| 0debug
|
static void cin_decode_rle(const unsigned char *src, int src_size, unsigned char *dst, int dst_size)
{
int len, code;
unsigned char *dst_end = dst + dst_size;
const unsigned char *src_end = src + src_size;
while (src < src_end && dst < dst_end) {
code = *src++;
if (code & 0x80) {
len = code - 0x7F;
memset(dst, *src++, FFMIN(len, dst_end - dst));
} else {
len = code + 1;
memcpy(dst, src, FFMIN(len, dst_end - dst));
src += len;
}
dst += len;
}
}
| 1threat
|
Is it possible to have two or more active exceptions at the same time? : <p>C++17 introduces a new function <a href="https://www.cs.helsinki.fi/group/boi2016/doc/cppreference/reference/en.cppreference.com/w/cpp/error/uncaught_exception.html" rel="noreferrer"><code>std::uncaught_exceptions</code></a>:</p>
<blockquote>
<p>Detects how many exceptions have been thrown or rethrown and not yet
entered their matching catch clauses.</p>
</blockquote>
<p>The following code:</p>
<pre><code>#include <iostream>
using namespace std;
struct A
{
~A()
{
cout << std::uncaught_exceptions() << endl;
}
};
int main()
{
try
{
try
{
A a1;
throw 1;
}
catch (...)
{
A a2;
throw;
}
}
catch (...)
{
A a3;
}
}
</code></pre>
<p>outputs:</p>
<blockquote>
<p>1</p>
<p>1</p>
<p>0</p>
</blockquote>
<p>Is it possible to have two or more active exceptions at the same time?</p>
<p>Is there any example?</p>
| 0debug
|
Nodejs on Azure where is output of the console log : <p>I deployed a nodejs web app on azure as an
App Service</p>
<p>How do i see the console.log from my application?</p>
| 0debug
|
How Do I calcualte a for loop to display in a listbox where the first loop is user input but the remaining iterations are calculated? : I am trying to create a loop that will calculate inside a listbox but run the actual calculation after the first statement and compound the remaining...
Here is my code:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
// Count Loop
int numdays;
numdays = 1;
// Declare and Assign Variables
double organism, daysmultiply, dailyincrease;
organism = double.Parse(OrganismTextBox.Text);
dailyincrease = double.Parse(DailyIncreaseTextBox.Text);
daysmultiply = double.Parse(DaysMultiplyTextBox.Text);
ResultsListBox.Items.Clear();
// Need to have daily increase texbox formatted as a percentage - unsure how
for (numdays = 0; numdays <= daysmultiply; numdays++)
{
ResultsListBox.Items.Add(" Day " + numdays + " Popualtion is " + (organism * dailyincrease));
numdays = numdays++;
<!-- end snippet -->
The result of the calculation is a loop that calculates .6 each time it iterates. I am trying to figure out how to compound the loop each time.
Can someone please help?
| 0debug
|
Why use '$' instead of '.'? : <p>In my AndroidManifest.xml i have a warning in the line code below.</p>
<pre><code><service android:name=".Helper.LocationService"/>
</code></pre>
<p>The warning is: </p>
<blockquote>
<p>Inner classes should use $ rather than . When you reference an inner
class in a manifest file, you must use '$' instead of '.' as the
separator character, i.e. Outer$Inner instead of Outer.Inner.</p>
</blockquote>
<p>So, Why use '$' instead of '.', if when I use '.' still works?</p>
| 0debug
|
How to interact with a REST service in C# : <p>I'm developing a small application that has to interact with a JSON/REST service.
What is the easiest option to interact with it in my c# application.</p>
<p>I don't need to have the best performances, since it's just a tools that will do some synchronization once a day, I'm more oriented toward the ease of use and the time of development.</p>
<p>(the service in question will be our local JIRA instance).</p>
| 0debug
|
Javascript ES6 import without a name : <p>I am running Webpack, Babel and Vue.js and I want to split up my entry file. Currently I have an app.js file which is the starting point to my application.</p>
<p>I have some bits and pieces of Code I want to put into a <code>bootstrap.js</code> file which I want to include in my main <code>app.js</code> file can I can have a clean file to start out with Vue and add components in it as I go.</p>
<p>Some examples of what I would want to put in my <code>bootstrap.js</code> file:</p>
<pre><code>import messagesNL from './translations/nl';
Vue.use(VeeValidate, {
locale: 'nl',
dictionary: {
nl: {
messages: messagesNL
}
}
});
window.Vue = Vue;
</code></pre>
<p>So pretty much setup for plugins, global configuration, etc. I feel like this is not your typical module and I find it hard to create a module like structure for this file so I basically use this in my <code>app.js</code> file:</p>
<pre><code>import bootstrap from './bootstrap';
</code></pre>
<p>Having no idea if this would work, it seems to just import everything neatly without me having done a <code>module exports {}</code> like syntax.</p>
<p>Now the bootstrap variable that I assigned to that file is unused in <code>app.js</code> since it's only used to require the file and my IDE kind of 'greys` it out to let me know it is unused.</p>
<p>Is there another syntax for this so that I don't have to assign a name to it? Is this approach ok to split up my file, or should I be doing something else?</p>
<p>I haven't put it into a proper module yet because then it would have it's own local scope and I would be unsure how to set up Vue with all the plugins, etc. If anybody has a better suggestion I am open to it.</p>
<p>Cheers.</p>
| 0debug
|
static void bonito_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
{
PCIBonitoState *s = opaque;
uint32_t saddr;
int reset = 0;
saddr = (addr - BONITO_REGBASE) >> 2;
DPRINTF("bonito_writel "TARGET_FMT_plx" val %x saddr %x \n", addr, val, saddr);
switch (saddr) {
case BONITO_BONPONCFG:
case BONITO_IODEVCFG:
case BONITO_SDCFG:
case BONITO_PCIMAP:
case BONITO_PCIMEMBASECFG:
case BONITO_PCIMAP_CFG:
case BONITO_GPIODATA:
case BONITO_GPIOIE:
case BONITO_INTEDGE:
case BONITO_INTSTEER:
case BONITO_INTPOL:
case BONITO_PCIMAIL0:
case BONITO_PCIMAIL1:
case BONITO_PCIMAIL2:
case BONITO_PCIMAIL3:
case BONITO_PCICACHECTRL:
case BONITO_PCICACHETAG:
case BONITO_PCIBADADDR:
case BONITO_PCIMSTAT:
case BONITO_TIMECFG:
case BONITO_CPUCFG:
case BONITO_DQCFG:
case BONITO_MEMSIZE:
s->regs[saddr] = val;
break;
case BONITO_BONGENCFG:
if (!(s->regs[saddr] & 0x04) && (val & 0x04)) {
reset = 1;
}
s->regs[saddr] = val;
if (reset) {
qemu_system_reset_request();
}
break;
case BONITO_INTENSET:
s->regs[BONITO_INTENSET] = val;
s->regs[BONITO_INTEN] |= val;
break;
case BONITO_INTENCLR:
s->regs[BONITO_INTENCLR] = val;
s->regs[BONITO_INTEN] &= ~val;
break;
case BONITO_INTEN:
case BONITO_INTISR:
DPRINTF("write to readonly bonito register %x \n", saddr);
break;
default:
DPRINTF("write to unknown bonito register %x \n", saddr);
break;
}
}
| 1threat
|
Is it possible to write javascript in a php heredoc syntax? : I'm trying to put javascript coding in a heredoc syntax and I want it to be printed out with the php print_r method. Is it possible to do that?
PHP
<?php
function printR($val){
echo "<pre>";
print_r($val);
echo "</pre>";
}
$str = <<<EOT
var msg = "Hello my name is ";
var name = "Jermaine Forbes";
function writeIt(m,n){
console.log(m+n);
}
writeIt(msg,name);
EOT;
printR($str);
?>
| 0debug
|
static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
PCIBus *bus, PIIX4PMState *s)
{
memory_region_init_io(&s->io_gpe, OBJECT(s), &piix4_gpe_ops, s,
"acpi-gpe0", GPE_LEN);
memory_region_add_subregion(parent, GPE_BASE, &s->io_gpe);
acpi_pcihp_init(OBJECT(s), &s->acpi_pci_hotplug, bus, parent,
s->use_acpi_pci_hotplug);
s->cpu_hotplug_legacy = true;
object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy",
piix4_get_cpu_hotplug_legacy,
piix4_set_cpu_hotplug_legacy,
NULL);
legacy_acpi_cpu_hotplug_init(parent, OBJECT(s), &s->gpe_cpu,
PIIX4_CPU_HOTPLUG_IO_BASE);
if (s->acpi_memory_hotplug.is_enabled) {
acpi_memory_hotplug_init(parent, OBJECT(s), &s->acpi_memory_hotplug);
}
}
| 1threat
|
static void xan_unpack(unsigned char *dest, unsigned char *src)
{
unsigned char opcode;
int size;
int offset;
int byte1, byte2, byte3;
for (;;) {
opcode = *src++;
if ( (opcode & 0x80) == 0 ) {
offset = *src++;
size = opcode & 3;
bytecopy(dest, src, size); dest += size; src += size;
size = ((opcode & 0x1c) >> 2) + 3;
bytecopy (dest, dest - (((opcode & 0x60) << 3) + offset + 1), size);
dest += size;
} else if ( (opcode & 0x40) == 0 ) {
byte1 = *src++;
byte2 = *src++;
size = byte1 >> 6;
bytecopy (dest, src, size); dest += size; src += size;
size = (opcode & 0x3f) + 4;
bytecopy (dest, dest - (((byte1 & 0x3f) << 8) + byte2 + 1), size);
dest += size;
} else if ( (opcode & 0x20) == 0 ) {
byte1 = *src++;
byte2 = *src++;
byte3 = *src++;
size = opcode & 3;
bytecopy (dest, src, size); dest += size; src += size;
size = byte3 + 5 + ((opcode & 0xc) << 6);
bytecopy (dest,
dest - ((((opcode & 0x10) >> 4) << 0x10) + 1 + (byte1 << 8) + byte2),
size);
dest += size;
} else {
size = ((opcode & 0x1f) << 2) + 4;
if (size > 0x70)
break;
bytecopy (dest, src, size); dest += size; src += size;
}
}
size = opcode & 3;
bytecopy(dest, src, size); dest += size; src += size;
}
| 1threat
|
Checking for empty string in C++ alternatives : <p>There are (at least :) two ways of checking if an string is empty in C++, in particular:</p>
<pre><code>if (s.length() == 0) {
// string is empty
}
</code></pre>
<p>and</p>
<pre><code>if (s == "") {
// string is empty
}
</code></pre>
<p>Which one is the best from a performance point of view? Maybe the library implementation is clever enough so there isn't any different between them (in which case other criteria should decide, i.e. readibility) but I tend to think that the first alternative (using <code>length()</code>) is better.</p>
<p>Any feedback on this, please? (Or even a 3rd method better than the ones I have proposed).</p>
| 0debug
|
ASP.NET Core MVC scheduled task : <p>I need to run a scheduled task on every new day in asp.net mvc core application.
Can I do it, and how?!</p>
<p>thnx</p>
| 0debug
|
How to route CodeIgniter with Angular.js? : <p>I'm trying to use Angular.js and CodeIgniter together. </p>
<p>With <code>ngRoute</code> in my app, I'm setting in my <code>main.js</code>:</p>
<pre><code>$locationProvider.html5Mode(true);
$routeProvider.when('/test', {
templateUrl: 'partials/test.html'
});
$routeProvider.otherwise({
templateUrl: 'partials/home.html'
});
</code></pre>
<p>In my <code>routes.php</code>, I'm setting:</p>
<pre><code>$route['default_controller'] = 'home';
$route['(:any)'] = "home";
</code></pre>
<p>And in my <code>home/index.php</code>, I have the <code><ng-view></ng-view></code>.</p>
<p>The thing is, <strong>without</strong> the <code>html5Mode(true)</code> (with /#/ on the URL) everything works fine. But otherwise, the partials file works, but the page reloads anyway.</p>
<p>In Inspector Elements, things look like this:</p>
<p><a href="https://i.stack.imgur.com/lSwQ3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lSwQ3.png" alt="partials/test.html loaded, but the page realoded, and the error "ngView: undefined" showed up"></a></p>
<p>partials/test.html loaded, but the page realoded, and the error "ngView: undefined" showed up.</p>
<p>I'm still learning Angularjs. Anyone can help?</p>
| 0debug
|
React-Virtualized Autosizer calculates height as 0 for VirtualScroll : <p>Where AutoSizer's width gives me an appropriate value, I'm consistently getting an Autosizer height of 0, which causes the VirtualScroll component not to display. However, if i use the disableHeight prop and provide VirtualScroll with a fixed value for height (i.e. 200px), VirtualScroll displays rows as expected. Can anyone see whats wrong?</p>
<p>Ultimately, the Autosizer is meant to live inside a Material-ui Dialog component, but I have also tried simply rendering the autosizer into a div. Same issue.</p>
<pre><code>render() {
return (
<Dialog
modal={false}
open={this.state.open}
onRequestClose={this.handleClose}
contentStyle={pageOptionsDialog.body}
>
<div>
<AutoSizer>
{({ width, height }) => (
<VirtualScroll
id="virtualScroll"
onRowsRendered={this.props.loadNextPage}
rowRenderer={this.rowRenderer}
height={height}
rowCount={this.props.rowCount}
rowHeight={30}
width={width}
/>
)}
</AutoSizer>
</div>
</dialog>
)}
</code></pre>
| 0debug
|
Project Euler #5 - Why won't this while loop finish? : <p>If I change the code line "num++" to "num+=2520", the code runs fine and returns the correct answer, but I'd like to know why it doesn't run as is, primarily because I didn't think of the fact that the number must be a multiple at 2520 before looking the answer up, and I don't see why my own code isn't correctly giving the answer without that change. To me, it seems correct. Unfortunately, the while loop never ends. </p>
<p>My guess is it has something to do with how long the correct number is (232792560), because if I lower the requirements even a little bit (from 9 to 8, per se), the while loop manages to finish.</p>
<pre><code> long long int num = 1;
int div_counter = 1;
bool check = false;
while(!check)
{
for(int i = 2; i < 21; i++)
{
if(num % i == 0)
{
div_counter++;
}
}
if(div_counter == 20)
{
check = true;
}
else
{
num++;
div_counter = 0;
}
}
return num;
</code></pre>
| 0debug
|
Tensorboard not found as magic function in jupyter : <p>I want to run tensorboard in jupyter using the latest tensorflow 2.0.0a0.
With the tensorboard version 1.13.1, and python 3.6. </p>
<p>using </p>
<p><code>...
%tensorboard --logdir {logs_base_dir}</code></p>
<p>I get the error :</p>
<p><code>UsageError: Line magic function %tensorboard not found</code></p>
<p>Do you have an idea what the problem could be? It seems that all versions are up to date and the command seems correct too. </p>
<p>Thanks</p>
| 0debug
|
static void get_offset_range(hwaddr phys_addr,
ram_addr_t mapping_length,
DumpState *s,
hwaddr *p_offset,
hwaddr *p_filesz)
{
RAMBlock *block;
hwaddr offset = s->memory_offset;
int64_t size_in_block, start;
*p_offset = -1;
*p_filesz = 0;
if (s->has_filter) {
if (phys_addr < s->begin || phys_addr >= s->begin + s->length) {
return;
}
}
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
if (s->has_filter) {
if (block->offset >= s->begin + s->length ||
block->offset + block->length <= s->begin) {
continue;
}
if (s->begin <= block->offset) {
start = block->offset;
} else {
start = s->begin;
}
size_in_block = block->length - (start - block->offset);
if (s->begin + s->length < block->offset + block->length) {
size_in_block -= block->offset + block->length -
(s->begin + s->length);
}
} else {
start = block->offset;
size_in_block = block->length;
}
if (phys_addr >= start && phys_addr < start + size_in_block) {
*p_offset = phys_addr - start + offset;
*p_filesz = phys_addr + mapping_length <= start + size_in_block ?
mapping_length :
size_in_block - (phys_addr - start);
return;
}
offset += size_in_block;
}
}
| 1threat
|
static int net_slirp_init(NetClientState *peer, const char *model,
const char *name, int restricted,
bool ipv4, const char *vnetwork, const char *vhost,
bool ipv6, const char *vprefix6, int vprefix6_len,
const char *vhost6,
const char *vhostname, const char *tftp_export,
const char *bootfile, const char *vdhcp_start,
const char *vnameserver, const char *vnameserver6,
const char *smb_export, const char *vsmbserver,
const char **dnssearch)
{
struct in_addr net = { .s_addr = htonl(0x0a000200) };
struct in_addr mask = { .s_addr = htonl(0xffffff00) };
struct in_addr host = { .s_addr = htonl(0x0a000202) };
struct in_addr dhcp = { .s_addr = htonl(0x0a00020f) };
struct in_addr dns = { .s_addr = htonl(0x0a000203) };
struct in6_addr ip6_prefix;
struct in6_addr ip6_host;
struct in6_addr ip6_dns;
#ifndef _WIN32
struct in_addr smbsrv = { .s_addr = 0 };
#endif
NetClientState *nc;
SlirpState *s;
char buf[20];
uint32_t addr;
int shift;
char *end;
struct slirp_config_str *config;
if (!ipv4 && (vnetwork || vhost || vnameserver)) {
return -1;
}
if (!ipv6 && (vprefix6 || vhost6 || vnameserver6)) {
return -1;
}
if (!ipv4 && !ipv6) {
return -1;
}
if (!tftp_export) {
tftp_export = legacy_tftp_prefix;
}
if (!bootfile) {
bootfile = legacy_bootp_filename;
}
if (vnetwork) {
if (get_str_sep(buf, sizeof(buf), &vnetwork, '/') < 0) {
if (!inet_aton(vnetwork, &net)) {
return -1;
}
addr = ntohl(net.s_addr);
if (!(addr & 0x80000000)) {
mask.s_addr = htonl(0xff000000);
} else if ((addr & 0xfff00000) == 0xac100000) {
mask.s_addr = htonl(0xfff00000);
} else if ((addr & 0xc0000000) == 0x80000000) {
mask.s_addr = htonl(0xffff0000);
} else if ((addr & 0xffff0000) == 0xc0a80000) {
mask.s_addr = htonl(0xffff0000);
} else if ((addr & 0xffff0000) == 0xc6120000) {
mask.s_addr = htonl(0xfffe0000);
} else if ((addr & 0xe0000000) == 0xe0000000) {
mask.s_addr = htonl(0xffffff00);
} else {
mask.s_addr = htonl(0xfffffff0);
}
} else {
if (!inet_aton(buf, &net)) {
return -1;
}
shift = strtol(vnetwork, &end, 10);
if (*end != '\0') {
if (!inet_aton(vnetwork, &mask)) {
return -1;
}
} else if (shift < 4 || shift > 32) {
return -1;
} else {
mask.s_addr = htonl(0xffffffff << (32 - shift));
}
}
net.s_addr &= mask.s_addr;
host.s_addr = net.s_addr | (htonl(0x0202) & ~mask.s_addr);
dhcp.s_addr = net.s_addr | (htonl(0x020f) & ~mask.s_addr);
dns.s_addr = net.s_addr | (htonl(0x0203) & ~mask.s_addr);
}
if (vhost && !inet_aton(vhost, &host)) {
return -1;
}
if ((host.s_addr & mask.s_addr) != net.s_addr) {
return -1;
}
if (vnameserver && !inet_aton(vnameserver, &dns)) {
return -1;
}
if ((dns.s_addr & mask.s_addr) != net.s_addr ||
dns.s_addr == host.s_addr) {
return -1;
}
if (vdhcp_start && !inet_aton(vdhcp_start, &dhcp)) {
return -1;
}
if ((dhcp.s_addr & mask.s_addr) != net.s_addr ||
dhcp.s_addr == host.s_addr || dhcp.s_addr == dns.s_addr) {
return -1;
}
#ifndef _WIN32
if (vsmbserver && !inet_aton(vsmbserver, &smbsrv)) {
return -1;
}
#endif
#if defined(_WIN32) && (_WIN32_WINNT < 0x0600)
if (vprefix6) {
return -1;
}
memset(&ip6_prefix, 0, sizeof(ip6_prefix));
ip6_prefix.s6_addr[0] = 0xfe;
ip6_prefix.s6_addr[1] = 0xc0;
#else
if (!vprefix6) {
vprefix6 = "fec0::";
}
if (!inet_pton(AF_INET6, vprefix6, &ip6_prefix)) {
return -1;
}
#endif
if (!vprefix6_len) {
vprefix6_len = 64;
}
if (vprefix6_len < 0 || vprefix6_len > 126) {
return -1;
}
if (vhost6) {
#if defined(_WIN32) && (_WIN32_WINNT < 0x0600)
return -1;
#else
if (!inet_pton(AF_INET6, vhost6, &ip6_host)) {
return -1;
}
if (!in6_equal_net(&ip6_prefix, &ip6_host, vprefix6_len)) {
return -1;
}
#endif
} else {
ip6_host = ip6_prefix;
ip6_host.s6_addr[15] |= 2;
}
if (vnameserver6) {
#if defined(_WIN32) && (_WIN32_WINNT < 0x0600)
return -1;
#else
if (!inet_pton(AF_INET6, vnameserver6, &ip6_dns)) {
return -1;
}
if (!in6_equal_net(&ip6_prefix, &ip6_dns, vprefix6_len)) {
return -1;
}
#endif
} else {
ip6_dns = ip6_prefix;
ip6_dns.s6_addr[15] |= 3;
}
nc = qemu_new_net_client(&net_slirp_info, peer, model, name);
snprintf(nc->info_str, sizeof(nc->info_str),
"net=%s,restrict=%s", inet_ntoa(net),
restricted ? "on" : "off");
s = DO_UPCAST(SlirpState, nc, nc);
s->slirp = slirp_init(restricted, ipv4, net, mask, host,
ipv6, ip6_prefix, vprefix6_len, ip6_host,
vhostname, tftp_export, bootfile, dhcp,
dns, ip6_dns, dnssearch, s);
QTAILQ_INSERT_TAIL(&slirp_stacks, s, entry);
for (config = slirp_configs; config; config = config->next) {
if (config->flags & SLIRP_CFG_HOSTFWD) {
if (slirp_hostfwd(s, config->str,
config->flags & SLIRP_CFG_LEGACY) < 0)
goto error;
} else {
if (slirp_guestfwd(s, config->str,
config->flags & SLIRP_CFG_LEGACY) < 0)
goto error;
}
}
#ifndef _WIN32
if (!smb_export) {
smb_export = legacy_smb_export;
}
if (smb_export) {
if (slirp_smb(s, smb_export, smbsrv) < 0)
goto error;
}
#endif
s->exit_notifier.notify = slirp_smb_exit;
qemu_add_exit_notifier(&s->exit_notifier);
return 0;
error:
qemu_del_net_client(nc);
return -1;
}
| 1threat
|
I need to split a string after a number with dot in nodejs : var str = "1.one 2. two 3.three"
output should be
["one", "two", "three"]
| 0debug
|
JavaScript doesn't work properly on elements added by .html() : <p>I got a little issue with my JavaScript and jQuery fadeIn(), html() and fadeOut() methods.</p>
<p>This is my code below.</p>
<p>My HTML </p>
<pre><code><div class="fluid-container">
<div class="row">
<div class="col text-center">
<ul class="list-inline pb-6 border-bottom d-inline-block w-75">
<button class="list-inline-item circle-button mr-3" type="button" name="button">1</button>
<li class="list-inline-item mr-5">Password</li>
<button class="list-inline-item circle-button mr-3 grey-btn" type="button" name="button">2</button>
<li class="list-inline-item half-opacity">Industries</li>
</ul>
<br>
<div id="ReplCont">
<span class="h5 d-inline-block mt-4 mb-5">Hey there Maxx, welcome to Flairr!<br>To get started, create a password for yourself.</span>
<br>
<input class="mb-6 ml-5 mr-3 rounded w-20" type="text" name="password" value="" placeholder="Password" id="pass-input">
<img class="flairr-tick-resize vis-hidden" src="./img/flairr_tick.svg" alt="Tick images">
<br>
<input class="mb-5 ml-5 mr-3 rounded w-20" type="text" name="confirm password" value="" placeholder="Confirm Password" id="conf-pass-input">
<img class="flairr-tick-resize vis-hidden" src="./img/flairr_tick.svg" alt="Tick images">
<br>
<button class="mb-2 half-opacity" type="button" name="button" id="cont-btn">Continue</button>
</div>
<div id="empty-bg">
<!-- Must be empty -->
</div>
</div>
</div>
</div>
</code></pre>
<p>JAVASCRIPT</p>
<pre><code>$(document).ready(function(){
// INDUSTIES BUTTONS
// Toggle active
$('.industry-btn-new').click(function(){
if ($('.industry-btn-chsen').length >= 3) {
if ($(this).hasClass('industry-btn-chsen')) {
$(this).toggleClass('industry-btn-chsen');
}
}else {
$(this).toggleClass('industry-btn-chsen');
}
})
// Get started button
$('.industry-btn-new').click(function(){
if ($('.industry-btn-chsen').length >= 3) {
$('#get-started').removeClass('half-opacity');
}else if ($('.industry-btn-chsen').length <= 3) {
$('#get-started').addClass('half-opacity');
}
})
// INPUTS COMPARISON
$('#conf-pass-input, #pass-input').keyup(function(){
if ($('#pass-input').val() === $('#conf-pass-input').val() && $('.w-20').val().length >= 1) {
$('.flairr-tick-resize').removeClass('vis-hidden');
$('#cont-btn').removeClass('half-opacity');
$('.w-20').removeClass('red-input');
}else if ($('#pass-input').val() !== $('#conf-pass-input').val() || $('.w-20').val().length <= 1) {
$('.flairr-tick-resize').addClass('vis-hidden');
$('#cont-btn').addClass('half-opacity');
$('.w-20').removeClass('red-input');
}
});
// CONTINUE BUTTON ACTIONS
$('#cont-btn').click(function(){
if ($('#pass-input').val() !== $('#conf-pass-input').val() || $('.w-20').val().length <= 0) {
$('.w-20').addClass('red-input');
}else {
$('#ReplCont').fadeOut('slow', function() {
$('#ReplCont').html(`<span class="h5 d-inline-block mt-4 mb-5">Alright Maxx,<br>choose up to 3 industries you're interested in.</span>
<br>
<button class="m-2 industry-btn-new" type="button" name="button">Marketing</button>
<button class="m-2 industry-btn-new" type="button" name="button">Finance</button>
<button class="m-2 industry-btn-new" type="button" name="button">Business Development</button>
<button class="m-2 industry-btn-new" type="button" name="button">Engineering</button>
<br>
<div class="pb-5 mb-4 border-bottom w-75 text=center mx-auto">
<button class="m-2 industry-btn-new" type="button" name="button">Design</button>
<button class="m-2 industry-btn-new" type="button" name="button">Computer Science</button>
<button class="m-2 industry-btn-new" type="button" name="button">Data Science</button>
</div>
<br>
<button class="mb-2 half-opacity" type="button" name="button" id="get-started">Get started</button>`);
$('#ReplCont').fadeIn('slow');
});
}
})
})
</code></pre>
<p>I'm replacing content inside DIV with ID ReplCont when click on continue button. The problem is after I replace content inside ReplCont DIV my JS for new content doesn't work.
But if I put it manually then and refresh the page then JS works fine.</p>
<p>I have some thoughts. Maybe JS loads on page load and after setting new HTML with jQuery I have to reload JS somehow. But I'm no sure. Please help friends!</p>
<p>Thank you in advance!</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.