problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
How to include end date in pandas date_range method? : <p>From <code>pd.date_range('2016-01', '2016-05', freq='M', ).strftime('%Y-%m')</code>, the last month is <code>2016-04</code>, but I was expecting it to be <code>2016-05</code>. It seems to me this function is behaving like the <code>range</code> method, where the end parameter is not included in the returning array. </p>
<p>Is there a way to get the end month included in the returning array, without processing the string for the end month?</p>
| 0debug |
static void virtio_ccw_serial_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
DeviceState *proxy = DEVICE(ccw_dev);
Error *err = NULL;
char *bus_name;
if (proxy->id) {
bus_name = g_strdup_printf("%s.0", proxy->id);
virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev), bus_name);
g_free(bus_name);
}
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
if (err) {
error_propagate(errp, err);
}
}
| 1threat |
Difference between restrict_with_exception and restrict_with_error : <p>Can anyone tell me the difference between these two ways when dealing with object whose parent key is destroyed? What practical reason makes you choose one from the other?</p>
| 0debug |
How to remove unwanted string in sql server : I am making product inventory and showing data using below statement
SELECT _PRODNAME AS [Manufacture Product],
_BASEPRODNAME AS [Sub Product],
_PRDDEFQTY AS [Required Qty / Unit],
_PURQTY AS [Purchase Qty],
_PURRETQTY AS [Return Qty],
_ISSUEQTY AS [Issue Qty],
_DAMAGEQTY AS [Damage Qty],
_BALQTY AS [Balance Qty],
_MINESTIMATE AS [Estimate Qty],
_SALEQTY AS [Sale Qty],
_MANUDAMAGEQTY AS Damage,
_AVAILQTY AS [Avail Qty]
FROM dbo.VIEW_MANUFACTURING
this giving me result as
manu 2 GOOD 34.00 502.00 0.00 0.00 0.00 502.00 14.705882 0.00 0.00 14.71
manu CHOCO ALMOND 1\2 kg 34.00 500.00 0.00 0.00 0.00 500.00 14.705882 0.00 0.00 14.71
Vanila Cake Butter Cream 10.00 600.00 0.00 72.00 0.00 528.00 52.800000 0.00 0.00 52.80
Vanila Cake Eggs 2.00 1000.00 0.00 37.00 0.00 963.00 52.800000 0.00 0.00 52.80
Vanila Cake Flour 5.00 500.00 0.00 0.00 0.00 500.00 52.800000 0.00 0.00 52.80
but my expected result is
manu 14.705882 0.00 0.00 14.71
2 GOOD 34.00 502.00 0.00 0.00 0.00 502.00
CHOCO ALMOND 1\2 kg 34.00 500.00 0.00 0.00 0.00 500.00
Vanila Cake 52.800000 0.00 0.00 52.80
Butter Cream 10.00 600.00 0.00 72.00 0.00 528.00
Eggs 2.00 1000.00 0.00 37.00 0.00 963.00
Flour 5.00 500.00 0.00 0.00 0.00 500.00
in my sample data Vanila Cake is main product and Butter Cream, Eggs, Flour are sub product, Columns 3,4,5,6,7,8 are for sub product data and Columns 9,10,11,12 are for main product.
My question is how to show this data seprately, I dont have any idea to this. | 0debug |
If the number is 0594 the total number of digit should be 4,how to solve it? : 1. If the no taken is "06584" the output would be "4",excluding ZERO.
2. But,how to get "5" as output counting even ZERO as a digit?
Below is the code.
#include<stdio.h>
void main()
{
int n,c=0,d;
printf("Enter no\n");
scanf("%d",&n);
while(n!=0)
{
d=n%10;
c++;
n=n/10;
}
printf("No of digits=>%d\n",c);
}
| 0debug |
what is a mysql buffered cursor w.r.t python mysql connector : <p>Can someone please give an example to understand this?</p>
<blockquote>
<p>After executing a query, a MySQLCursorBuffered cursor fetches the entire result set from the server and buffers the rows.
For queries executed using a buffered cursor, row-fetching methods such as fetchone() return rows from the set of buffered rows. For nonbuffered cursors, rows are not fetched from the server until a row-fetching method is called. In this case, you must be sure to fetch all rows of the result set before executing any other statements on the same connection, or an InternalError (Unread result found) exception will be raised.</p>
</blockquote>
<p>Thanks</p>
| 0debug |
void spapr_drc_attach(sPAPRDRConnector *drc, DeviceState *d, void *fdt,
int fdt_start_offset, Error **errp)
{
trace_spapr_drc_attach(spapr_drc_index(drc));
if (drc->isolation_state != SPAPR_DR_ISOLATION_STATE_ISOLATED) {
error_setg(errp, "an attached device is still awaiting release");
return;
}
if (spapr_drc_type(drc) == SPAPR_DR_CONNECTOR_TYPE_PCI) {
g_assert(drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_USABLE);
}
g_assert(fdt);
drc->dev = d;
drc->fdt = fdt;
drc->fdt_start_offset = fdt_start_offset;
if (spapr_drc_type(drc) != SPAPR_DR_CONNECTOR_TYPE_PCI) {
drc->awaiting_allocation = true;
}
object_property_add_link(OBJECT(drc), "device",
object_get_typename(OBJECT(drc->dev)),
(Object **)(&drc->dev),
NULL, 0, NULL);
}
| 1threat |
Exclude words ('string') from array : I am having this array
`array = ["R.M", 20, "R.U-CS", 3, "R.M-TIC", 3, "R.J.CONF", 20]`
I want to remove string values from this array to like this :
> `[20, 3, 3, 20]`
Only numeric values | 0debug |
How do we set constant variables while building R packages? : <p>We are building a package in R for our service (a robo-advisor here in Brazil) and we send requests all the time to our external API inside our functions. </p>
<p>As it is the first time we build a package we have some questions. :(</p>
<p>When we will use our package to run some scripts we will need some information as <code>api_path, login, password</code>.</p>
<p>How do we place this information inside our package? </p>
<p>Here is a real example:</p>
<pre><code>get_asset_daily <- function(asset_id) {
api_path <- "https://api.verios.com.br"
url <- paste0(api_path, "/assets/", asset_id, "/dailies?asc=d")
data <- fromJSON(url)
data
}
</code></pre>
<p>Sometimes we use a <code>staging</code> version of the API and we have to constantly switch paths. How we should call it inside our function? </p>
<p>Should we set a global environment variable, a package environment variable, just define <code>api_path</code> in our scripts or a package config file?</p>
<p>How do we do that? </p>
<p>Thanks for your help in advance.</p>
<p>Ana</p>
| 0debug |
static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
unsigned int i, j, entries, ctts_count = 0;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
avio_r8(pb);
avio_rb24(pb);
entries = avio_rb32(pb);
av_log(c->fc, AV_LOG_TRACE, "track[%u].ctts.entries = %u\n", c->fc->nb_streams - 1, entries);
if (!entries)
return 0;
if (entries >= UINT_MAX / sizeof(*sc->ctts_data))
return AVERROR_INVALIDDATA;
av_freep(&sc->ctts_data);
sc->ctts_data = av_fast_realloc(NULL, &sc->ctts_allocated_size, entries * sizeof(*sc->ctts_data));
if (!sc->ctts_data)
return AVERROR(ENOMEM);
for (i = 0; i < entries && !pb->eof_reached; i++) {
int count =avio_rb32(pb);
int duration =avio_rb32(pb);
if (count <= 0) {
av_log(c->fc, AV_LOG_TRACE,
"ignoring CTTS entry with count=%d duration=%d\n",
count, duration);
continue;
}
for (j = 0; j < count; j++)
add_ctts_entry(&sc->ctts_data, &ctts_count, &sc->ctts_allocated_size, 1, duration);
av_log(c->fc, AV_LOG_TRACE, "count=%d, duration=%d\n",
count, duration);
if (FFNABS(duration) < -(1<<28) && i+2<entries) {
av_log(c->fc, AV_LOG_WARNING, "CTTS invalid\n");
av_freep(&sc->ctts_data);
sc->ctts_count = 0;
return 0;
}
if (i+2<entries)
mov_update_dts_shift(sc, duration);
}
sc->ctts_count = ctts_count;
if (pb->eof_reached)
return AVERROR_EOF;
av_log(c->fc, AV_LOG_TRACE, "dts shift %d\n", sc->dts_shift);
return 0;
}
| 1threat |
How to switch between PHP Classes? : <p>I am currently developing a web app which has following three classes. (One is parent and other two are child classes.)</p>
<pre><code>class Members {} /* Parent Class */
class Group1 extends Members {} /* Child class 1 */
class Group2 extends Members {} /* Child class 2 */
</code></pre>
<p>The requirement is quite simple. All persons in Group 1 or Group 2 <strong>Must be a Member.</strong> But my question is, what should I do if a person in Group 1 decided to move Group 2? Creating a new group 2 object will remove all the past data. But <strong>Everything he/she has done in Group 1 must be preserved.</strong> Any help how to do this in <strong>Proper Way</strong> is highly welcome..!</p>
| 0debug |
def find_Min_Swaps(arr,n) :
noOfZeroes = [0] * n
count = 0
noOfZeroes[n - 1] = 1 - arr[n - 1]
for i in range(n-2,-1,-1) :
noOfZeroes[i] = noOfZeroes[i + 1]
if (arr[i] == 0) :
noOfZeroes[i] = noOfZeroes[i] + 1
for i in range(0,n) :
if (arr[i] == 1) :
count = count + noOfZeroes[i]
return count | 0debug |
Creates a text on a site and retrieves it? c# : <p>I would like to know if there is a text editor or a file uploader/downloader (like pastebin or mega) but for C# program</p>
<p>I explain myself: I am making a program for my college, I would like that when everyone opens my program, that everyone is the same text file, that it can be modified and then saved and when the others load it, there will be the modifications on it</p>
<p>I don't know if it's very clear, but I'd like not to go through servers because I don't understand anything about them</p>
<p>Will there be a solution?</p>
<p>Thank you. </p>
| 0debug |
Can I convert numbers to amount of characters in python : Hi just wondering if I can convert a number like 3 into a string wich gives me the amount of characters in a input. Like: 3 = --- and 6 = ------
Thanks in advance, Thijs | 0debug |
static target_ulong h_enter(PowerPCCPU *cpu, sPAPRMachineState *spapr,
target_ulong opcode, target_ulong *args)
{
CPUPPCState *env = &cpu->env;
target_ulong flags = args[0];
target_ulong pte_index = args[1];
target_ulong pteh = args[2];
target_ulong ptel = args[3];
unsigned apshift, spshift;
target_ulong raddr;
target_ulong index;
uint64_t token;
apshift = ppc_hash64_hpte_page_shift_noslb(cpu, pteh, ptel, &spshift);
if (!apshift) {
return H_PARAMETER;
}
raddr = (ptel & HPTE64_R_RPN) & ~((1ULL << apshift) - 1);
if (is_ram_address(spapr, raddr)) {
if ((ptel & HPTE64_R_WIMG) != HPTE64_R_M) {
return H_PARAMETER;
}
} else {
if ((ptel & (HPTE64_R_W | HPTE64_R_I | HPTE64_R_M)) != HPTE64_R_I) {
return H_PARAMETER;
}
}
pteh &= ~0x60ULL;
if (!valid_pte_index(env, pte_index)) {
return H_PARAMETER;
}
index = 0;
if (likely((flags & H_EXACT) == 0)) {
pte_index &= ~7ULL;
token = ppc_hash64_start_access(cpu, pte_index);
for (; index < 8; index++) {
if (!(ppc_hash64_load_hpte0(cpu, token, index) & HPTE64_V_VALID)) {
break;
}
}
ppc_hash64_stop_access(cpu, token);
if (index == 8) {
return H_PTEG_FULL;
}
} else {
token = ppc_hash64_start_access(cpu, pte_index);
if (ppc_hash64_load_hpte0(cpu, token, 0) & HPTE64_V_VALID) {
ppc_hash64_stop_access(cpu, token);
return H_PTEG_FULL;
}
ppc_hash64_stop_access(cpu, token);
}
ppc_hash64_store_hpte(cpu, pte_index + index,
pteh | HPTE64_V_HPTE_DIRTY, ptel);
args[0] = pte_index + index;
return H_SUCCESS;
}
| 1threat |
How do I get the current time as a TimeStamp in Kotlin? : <p>This is the timestamp format I need: 2018-03-22 19:02:12.337909 </p>
| 0debug |
Making phone call from a flutter app : <p>I try to make a phone call from my Flutter app. With the following code:</p>
<pre><code>UrlLauncher.launch('tel: xxxxxxxx');
</code></pre>
<p>I found this Function on the github flutter repo: <a href="https://github.com/flutter/flutter/issues/4856" rel="noreferrer">https://github.com/flutter/flutter/issues/4856</a></p>
<p>But this don't work for me. Is this Function still in Flutter and in which package? Or is there an better option to do an phone call from my app? </p>
| 0debug |
static void gen_spr_thrm (CPUPPCState *env)
{
spr_register(env, SPR_THRM1, "THRM1",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_THRM2, "THRM2",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_THRM3, "THRM3",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
}
| 1threat |
static int alloc_f(BlockDriverState *bs, int argc, char **argv)
{
int64_t offset, sector_num;
int nb_sectors, remaining;
char s1[64];
int num, sum_alloc;
int ret;
offset = cvtnum(argv[1]);
if (offset < 0) {
printf("non-numeric offset argument -- %s\n", argv[1]);
} else if (offset & 0x1ff) {
printf("offset %" PRId64 " is not sector aligned\n",
offset);
if (argc == 3) {
nb_sectors = cvtnum(argv[2]);
if (nb_sectors < 0) {
printf("non-numeric length argument -- %s\n", argv[2]);
} else {
nb_sectors = 1;
remaining = nb_sectors;
sum_alloc = 0;
sector_num = offset >> 9;
while (remaining) {
ret = bdrv_is_allocated(bs, sector_num, remaining, &num);
sector_num += num;
remaining -= num;
if (ret) {
sum_alloc += num;
if (num == 0) {
nb_sectors -= remaining;
remaining = 0;
cvtstr(offset, s1, sizeof(s1));
printf("%d/%d sectors allocated at offset %s\n",
sum_alloc, nb_sectors, s1);
| 1threat |
Image read/write in Java without imageio between local file systems : <p>I'm very new to Java and I'm recently making a program which reads image files(jpg) from one directory, and write(copy) them to another directory.</p>
<p>I can't use imageio or move/copy methods and I also have to check the time consuming caused by the R/W operation.</p>
<p>The problem is I wrote some codes below and it runs, but all of my output image files in the destination have 0 byte and have no contents at all.
I can see only black screens which have no bytes when I open the result images.</p>
<pre><code>public class image_io {
public static void main(String[] args)
{
FileInputStream fis = null;
FileOutputStream fos = null;
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
// getting path
File directory = new File("C:\\src");
File[] fList = directory.listFiles();
String fileName, filePath, destPath;
// date for time check
Date d = new Date();
int byt = 0;
long start_t, end_t;
for (File file : fList)
{
// making paths of source and destination
fileName = file.getName();
filePath = "C:\\src\\" + fileName;
destPath = "C:\\dest\\" + fileName;
// read the images and check reading time consuming
try
{
fis = new FileInputStream(filePath);
bis = new BufferedInputStream(fis);
do
{
start_t = d.getTime();
}
while ((byt = bis.read()) != -1);
end_t = d.getTime();
System.out.println(end_t - start_t);
} catch (Exception e) {e.printStackTrace();}
// write the images and check writing time consuming
try
{
fos = new FileOutputStream(destPath);
bos = new BufferedOutputStream(fos);
int idx = byt;
start_t = d.getTime();
for (; idx == 0; idx--)
{
bos.write(byt);
}
end_t = d.getTime();
System.out.println(end_t - start_t);
} catch (Exception e) {e.printStackTrace();}
}
}
</code></pre>
<p>}</p>
<p>Is FileInput/OutputStream doesn't support image files?
Or is there some mistakes in my code?</p>
<p>Please, somebody help me..</p>
| 0debug |
static int vp3_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
Vp3DecodeContext *s = avctx->priv_data;
GetBitContext gb;
int i, ret;
if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0)
return ret;
#if CONFIG_THEORA_DECODER
if (s->theora && get_bits1(&gb)) {
int type = get_bits(&gb, 7);
skip_bits_long(&gb, 6*8);
if (s->avctx->active_thread_type&FF_THREAD_FRAME) {
av_log(avctx, AV_LOG_ERROR, "midstream reconfiguration with multithreading is unsupported, try -threads 1\n");
return AVERROR_PATCHWELCOME;
}
if (type == 0) {
vp3_decode_end(avctx);
ret = theora_decode_header(avctx, &gb);
if (ret < 0) {
vp3_decode_end(avctx);
} else
ret = vp3_decode_init(avctx);
return ret;
} else if (type == 2) {
ret = theora_decode_tables(avctx, &gb);
if (ret < 0) {
vp3_decode_end(avctx);
} else
ret = vp3_decode_init(avctx);
return ret;
}
av_log(avctx, AV_LOG_ERROR,
"Header packet passed to frame decoder, skipping\n");
return -1;
}
#endif
s->keyframe = !get_bits1(&gb);
if (!s->all_fragments) {
av_log(avctx, AV_LOG_ERROR, "Data packet without prior valid headers\n");
return -1;
}
if (!s->theora)
skip_bits(&gb, 1);
for (i = 0; i < 3; i++)
s->last_qps[i] = s->qps[i];
s->nqps = 0;
do {
s->qps[s->nqps++] = get_bits(&gb, 6);
} while (s->theora >= 0x030200 && s->nqps < 3 && get_bits1(&gb));
for (i = s->nqps; i < 3; i++)
s->qps[i] = -1;
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, " VP3 %sframe #%d: Q index = %d\n",
s->keyframe ? "key" : "", avctx->frame_number + 1, s->qps[0]);
s->skip_loop_filter = !s->filter_limit_values[s->qps[0]] ||
avctx->skip_loop_filter >= (s->keyframe ? AVDISCARD_ALL
: AVDISCARD_NONKEY);
if (s->qps[0] != s->last_qps[0])
init_loop_filter(s);
for (i = 0; i < s->nqps; i++)
if (s->qps[i] != s->last_qps[i] || s->qps[0] != s->last_qps[0])
init_dequantizer(s, i);
if (avctx->skip_frame >= AVDISCARD_NONKEY && !s->keyframe)
return buf_size;
s->current_frame.f->pict_type = s->keyframe ? AV_PICTURE_TYPE_I
: AV_PICTURE_TYPE_P;
s->current_frame.f->key_frame = s->keyframe;
if (ff_thread_get_buffer(avctx, &s->current_frame, AV_GET_BUFFER_FLAG_REF) < 0)
goto error;
if (!s->edge_emu_buffer)
s->edge_emu_buffer = av_malloc(9 * FFABS(s->current_frame.f->linesize[0]));
if (s->keyframe) {
if (!s->theora) {
skip_bits(&gb, 4);
skip_bits(&gb, 4);
if (s->version) {
s->version = get_bits(&gb, 5);
if (avctx->frame_number == 0)
av_log(s->avctx, AV_LOG_DEBUG,
"VP version: %d\n", s->version);
}
}
if (s->version || s->theora) {
if (get_bits1(&gb))
av_log(s->avctx, AV_LOG_ERROR,
"Warning, unsupported keyframe coding type?!\n");
skip_bits(&gb, 2);
}
} else {
if (!s->golden_frame.f->data[0]) {
av_log(s->avctx, AV_LOG_WARNING,
"vp3: first frame not a keyframe\n");
s->golden_frame.f->pict_type = AV_PICTURE_TYPE_I;
if (ff_thread_get_buffer(avctx, &s->golden_frame,
AV_GET_BUFFER_FLAG_REF) < 0)
goto error;
ff_thread_release_buffer(avctx, &s->last_frame);
if ((ret = ff_thread_ref_frame(&s->last_frame,
&s->golden_frame)) < 0)
goto error;
ff_thread_report_progress(&s->last_frame, INT_MAX, 0);
}
}
memset(s->all_fragments, 0, s->fragment_count * sizeof(Vp3Fragment));
ff_thread_finish_setup(avctx);
if (unpack_superblocks(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_superblocks\n");
goto error;
}
if (unpack_modes(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_modes\n");
goto error;
}
if (unpack_vectors(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_vectors\n");
goto error;
}
if (unpack_block_qpis(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_block_qpis\n");
goto error;
}
if (unpack_dct_coeffs(s, &gb)) {
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_dct_coeffs\n");
goto error;
}
for (i = 0; i < 3; i++) {
int height = s->height >> (i && s->chroma_y_shift);
if (s->flipped_image)
s->data_offset[i] = 0;
else
s->data_offset[i] = (height - 1) * s->current_frame.f->linesize[i];
}
s->last_slice_end = 0;
for (i = 0; i < s->c_superblock_height; i++)
render_slice(s, i);
for (i = 0; i < 3; i++) {
int row = (s->height >> (3 + (i && s->chroma_y_shift))) - 1;
apply_loop_filter(s, i, row, row + 1);
}
vp3_draw_horiz_band(s, s->height);
if ((ret = av_frame_ref(data, s->current_frame.f)) < 0)
return ret;
for (i = 0; i < 3; i++) {
AVFrame *dst = data;
int off = (s->offset_x >> (i && s->chroma_y_shift)) +
(s->offset_y >> (i && s->chroma_y_shift)) * dst->linesize[i];
dst->data[i] += off;
}
*got_frame = 1;
if (!HAVE_THREADS || !(s->avctx->active_thread_type & FF_THREAD_FRAME)) {
ret = update_frames(avctx);
if (ret < 0)
return ret;
}
return buf_size;
error:
ff_thread_report_progress(&s->current_frame, INT_MAX, 0);
if (!HAVE_THREADS || !(s->avctx->active_thread_type & FF_THREAD_FRAME))
av_frame_unref(s->current_frame.f);
return -1;
}
| 1threat |
Substring in c# to find second part in the string : <p>How to find the second part of the string using substring in c#</p>
<p>I have follwwing string:</p>
<pre><code>string str = "George Micahel R - 412352434";
</code></pre>
<p>I wanted the above string as two parts.Before "-" and after "-"</p>
<p>I have my first part using following code:</p>
<pre><code> string firstPart = str.Substring(0,str.IndexOf(" - "));
</code></pre>
<p>When I am trying for the second part using the following code it gives me an error.</p>
<pre><code> string secondPart = str.Substring(str.IndexOf(" - "), Len(str);
</code></pre>
<p>How to get the second part(only number)?</p>
<p>Thanks in advance.</p>
| 0debug |
Firefox automation with selenium : Hello I'm Chris and I try to make a py script but I need help to finish.
I would like to code how Firefox open a website and click button after wait 30 mins and close everything :) . I would like to loop this action :).
from selenium.webdriver import Firefox
YOUR_PAGE_URL = 'http://www.websyndic.com/wv3/?qs=OTcxNzAw'
NEXT_BUTTON_XPATH = '/html/body/div[3]/div[3]/div[1]/div/div/div[3]/div/div/a'
browser = Firefox()
browser.get(YOUR_PAGE_URL)
button = browser.find_element_by_xpath(NEXT_BUTTON_XPATH)
button.click()
Can I make .exe file from .py file? I would like to run this script with Windows 2012 Server or any suggestion?
Sorry for my bad english :) | 0debug |
static void roq_encode_video(RoqContext *enc)
{
RoqTempdata *tempData = enc->tmpData;
int i;
memset(tempData, 0, sizeof(*tempData));
create_cel_evals(enc, tempData);
generate_new_codebooks(enc, tempData);
if (enc->framesSinceKeyframe >= 1) {
motion_search(enc, 8);
motion_search(enc, 4);
}
retry_encode:
for (i=0; i<enc->width*enc->height/64; i++)
gather_data_for_cel(tempData->cel_evals + i, enc, tempData);
if (tempData->mainChunkSize/8 > 65536) {
enc->lambda *= .8;
goto retry_encode;
}
remap_codebooks(enc, tempData);
write_codebooks(enc, tempData);
reconstruct_and_encode_image(enc, tempData, enc->width, enc->height,
enc->width*enc->height/64);
enc->avctx->coded_frame = enc->current_frame;
FFSWAP(AVFrame *, enc->current_frame, enc->last_frame);
FFSWAP(motion_vect *, enc->last_motion4, enc->this_motion4);
FFSWAP(motion_vect *, enc->last_motion8, enc->this_motion8);
av_free(tempData->cel_evals);
av_free(tempData->closest_cb2);
enc->framesSinceKeyframe++;
}
| 1threat |
void pcnet_common_cleanup(PCNetState *d)
{
d->nic = NULL;
}
| 1threat |
Memory allocation problems with android application : <p>I have an android application that performs image analysis, which is managed with an <code>IntentService</code> - the process takes a couple of seconds each time and works accurately and quickly. </p>
<p>But when the process is repeated in the app around 50 times (as illustrated) it begins to get very slow until the point in which the app and device becomes unusable. When the device is restarted and app opens again it runs as usual.</p>
<p>Inspecting with Android Studio I can see that each time I run the analysis that the memory allocation for the app goes up and up every time by around <em>1MB</em>. So it is clearly running out of memory when it crashes.</p>
<p>I have used this flag on finishing the analysis and going to the result to try fix background activities;</p>
<pre><code>intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
</code></pre>
<p>which has had minimal effect, and I understand the IntentService manages itself shutting down. So not sure what else I can do to try and reduce the memory allocation or at least clear down allocation and stop adding to it?</p>
<p><a href="https://i.stack.imgur.com/S12aw.png"><img src="https://i.stack.imgur.com/S12aw.png" alt="Image Analysis Workflow"></a></p>
<p>Further details:</p>
<ul>
<li>The application is using the camera implementation based on <a href="https://github.com/googlesamples/android-Camera2Basic">Google Camera2</a></li>
<li>The analysis is done with a C++ library through the IntentService</li>
</ul>
| 0debug |
static int cuvid_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
{
CuvidContext *ctx = avctx->priv_data;
AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)ctx->hwdevice->data;
AVCUDADeviceContext *device_hwctx = device_ctx->hwctx;
CUcontext dummy, cuda_ctx = device_hwctx->cuda_ctx;
AVFrame *frame = data;
CUVIDSOURCEDATAPACKET cupkt;
AVPacket filter_packet = { 0 };
AVPacket filtered_packet = { 0 };
CUdeviceptr mapped_frame = 0;
int ret = 0, eret = 0;
if (ctx->bsf && avpkt->size) {
if ((ret = av_packet_ref(&filter_packet, avpkt)) < 0) {
av_log(avctx, AV_LOG_ERROR, "av_packet_ref failed\n");
return ret;
}
if ((ret = av_bsf_send_packet(ctx->bsf, &filter_packet)) < 0) {
av_log(avctx, AV_LOG_ERROR, "av_bsf_send_packet failed\n");
av_packet_unref(&filter_packet);
return ret;
}
if ((ret = av_bsf_receive_packet(ctx->bsf, &filtered_packet)) < 0) {
av_log(avctx, AV_LOG_ERROR, "av_bsf_receive_packet failed\n");
return ret;
}
avpkt = &filtered_packet;
}
ret = CHECK_CU(cuCtxPushCurrent(cuda_ctx));
if (ret < 0) {
av_packet_unref(&filtered_packet);
return ret;
}
memset(&cupkt, 0, sizeof(cupkt));
if (avpkt->size) {
cupkt.payload_size = avpkt->size;
cupkt.payload = avpkt->data;
if (avpkt->pts != AV_NOPTS_VALUE) {
cupkt.flags = CUVID_PKT_TIMESTAMP;
cupkt.timestamp = av_rescale_q(avpkt->pts, avctx->pkt_timebase, (AVRational){1, 10000000});
}
} else {
cupkt.flags = CUVID_PKT_ENDOFSTREAM;
}
ret = CHECK_CU(cuvidParseVideoData(ctx->cuparser, &cupkt));
av_packet_unref(&filtered_packet);
if (ret < 0) {
if (ctx->internal_error)
ret = ctx->internal_error;
goto error;
}
if (av_fifo_size(ctx->frame_queue)) {
CUVIDPARSERDISPINFO dispinfo;
CUVIDPROCPARAMS params;
unsigned int pitch = 0;
int offset = 0;
int i;
av_fifo_generic_read(ctx->frame_queue, &dispinfo, sizeof(CUVIDPARSERDISPINFO), NULL);
memset(¶ms, 0, sizeof(params));
params.progressive_frame = dispinfo.progressive_frame;
params.second_field = 0;
params.top_field_first = dispinfo.top_field_first;
ret = CHECK_CU(cuvidMapVideoFrame(ctx->cudecoder, dispinfo.picture_index, &mapped_frame, &pitch, ¶ms));
if (ret < 0)
goto error;
if (avctx->pix_fmt == AV_PIX_FMT_CUDA) {
ret = av_hwframe_get_buffer(ctx->hwframe, frame, 0);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "av_hwframe_get_buffer failed\n");
goto error;
}
ret = ff_decode_frame_props(avctx, frame);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "ff_decode_frame_props failed\n");
goto error;
}
for (i = 0; i < 2; i++) {
CUDA_MEMCPY2D cpy = {
.srcMemoryType = CU_MEMORYTYPE_DEVICE,
.dstMemoryType = CU_MEMORYTYPE_DEVICE,
.srcDevice = mapped_frame,
.dstDevice = (CUdeviceptr)frame->data[i],
.srcPitch = pitch,
.dstPitch = frame->linesize[i],
.srcY = offset,
.WidthInBytes = FFMIN(pitch, frame->linesize[i]),
.Height = avctx->coded_height >> (i ? 1 : 0),
};
ret = CHECK_CU(cuMemcpy2D(&cpy));
if (ret < 0)
goto error;
offset += avctx->coded_height;
}
} else if (avctx->pix_fmt == AV_PIX_FMT_NV12) {
AVFrame *tmp_frame = av_frame_alloc();
if (!tmp_frame) {
av_log(avctx, AV_LOG_ERROR, "av_frame_alloc failed\n");
ret = AVERROR(ENOMEM);
goto error;
}
tmp_frame->format = AV_PIX_FMT_CUDA;
tmp_frame->hw_frames_ctx = av_buffer_ref(ctx->hwframe);
tmp_frame->data[0] = (uint8_t*)mapped_frame;
tmp_frame->linesize[0] = pitch;
tmp_frame->data[1] = (uint8_t*)(mapped_frame + avctx->coded_height * pitch);
tmp_frame->linesize[1] = pitch;
tmp_frame->width = avctx->width;
tmp_frame->height = avctx->height;
ret = ff_get_buffer(avctx, frame, 0);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "ff_get_buffer failed\n");
av_frame_free(&tmp_frame);
goto error;
}
ret = av_hwframe_transfer_data(frame, tmp_frame, 0);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "av_hwframe_transfer_data failed\n");
av_frame_free(&tmp_frame);
goto error;
}
av_frame_free(&tmp_frame);
} else {
ret = AVERROR_BUG;
goto error;
}
frame->width = avctx->width;
frame->height = avctx->height;
frame->pts = av_rescale_q(dispinfo.timestamp, (AVRational){1, 10000000}, avctx->pkt_timebase);
frame->pkt_pts = frame->pts;
av_frame_set_pkt_pos(frame, -1);
av_frame_set_pkt_duration(frame, 0);
av_frame_set_pkt_size(frame, -1);
frame->interlaced_frame = !dispinfo.progressive_frame;
if (!dispinfo.progressive_frame)
frame->top_field_first = dispinfo.top_field_first;
*got_frame = 1;
} else {
*got_frame = 0;
}
error:
if (mapped_frame)
eret = CHECK_CU(cuvidUnmapVideoFrame(ctx->cudecoder, mapped_frame));
eret = CHECK_CU(cuCtxPopCurrent(&dummy));
if (eret < 0)
return eret;
else
return ret;
}
| 1threat |
SQLALCHEMY : How to rename an existing table? : class Movie(Base):
id = Column(Integer, primary_key=True)
title = Column(String)
release_date = Column(Date)
name=Column(String)
__tablename__ = 'titanic'
def __init__(self, newname,title, release_date):
self.title = title
self.release_date = release_date
What is the code to change table name from "titanic" to "wild" ?
In Postgresql it is
ALTER TABLE table_name
RENAME TO new_table_name;
I am not finding a solution in sqlalchemy. | 0debug |
C# - Launch Task periodically : I want to launch a method in a separated thread periodically (every minute). I was using `System.Timers.Timer` but I realize that Timers cause memory leaks.
I need to remove Timers and use task. The first idea is launch a Task in the following way:
_taskWork = Task.Factory.StartNew( DoWork );
And in the DoWork method:
private void DoWork()
{
While(true)
{
// Stuff here
Thread.Sleep(60000);
}
}
Is there any way to launch a task avoiding this approach?
Thanks | 0debug |
Multiply a float with a double : <p>I try to do a very simple thing, just multiply two numbers a float and a double.
I get the message can't convert a double to float... Thank you</p>
<pre><code>float tax = 0f;
tax = 0.14 * 26818;
</code></pre>
| 0debug |
static void vnc_update(VncState *vs, int x, int y, int w, int h)
{
int i;
h += y;
w += (x % 16);
x -= (x % 16);
x = MIN(x, vs->serverds.width);
y = MIN(y, vs->serverds.height);
w = MIN(x + w, vs->serverds.width) - x;
h = MIN(h, vs->serverds.height);
for (; y < h; y++)
for (i = 0; i < w; i += 16)
vnc_set_bit(vs->dirty_row[y], (x + i) / 16);
}
| 1threat |
Managing FCM device groups : <p>I'm trying to figure out how to manage FCM device groups from an app server by using the REST API.</p>
<p>AFAIK these are the updated docs: <a href="https://firebase.google.com/docs/cloud-messaging/android/device-group#managing_device_groups" rel="noreferrer">https://firebase.google.com/docs/cloud-messaging/android/device-group#managing_device_groups</a></p>
<p>Here's what I can already do:</p>
<ul>
<li>Create a new device group with some device tokens</li>
<li>Add device tokens to an existing device group</li>
</ul>
<p>And this is what I just can't figure out how to do since there's no mention of it in the docs:</p>
<ul>
<li><p>Query whether a device group already exists, based on its <code>notification_key_name</code>.</p>
<p>Workaround 1: if I try creating a group with a <code>notification_key_name</code>
that already exists then I get an error telling me so, but that seems
like a <em>very</em> hacky way to find out.</p>
<p>Workaround 2: Store that information by myself somewhere else.</p></li>
<li><p>Finding out which device tokens (<code>registration_id</code>) belong to a device group. </p>
<p>Workaround: as before, store that information by myself somewhere else.</p></li>
<li><p>Remove device tokens (<code>registration_id</code>) from a device group.</p>
<p>Workaround: none.</p></li>
<li><p>Remove a device group.</p>
<p>Workaround: none.</p></li>
</ul>
<p>Thanks!</p>
| 0debug |
static inline PageDesc *page_find(target_ulong index)
{
PageDesc *p;
p = l1_map[index >> L2_BITS];
if (!p)
return 0;
return p + (index & (L2_SIZE - 1));
}
| 1threat |
iOS: CollectionView like date picker scrolling effect : <p>I want a list in which 2nd item of list is a bit zoomed and highlighted and when i scroll that cell/item will get little smaller and next item becomes highlighted and zoomed. More like the date picker scrolling effect but with custom cells.</p>
| 0debug |
static void scsi_disk_emulate_mode_select(SCSIDiskReq *r, uint8_t *inbuf)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
uint8_t *p = inbuf;
int cmd = r->req.cmd.buf[0];
int len = r->req.cmd.xfer;
int hdr_len = (cmd == MODE_SELECT ? 4 : 8);
int bd_len;
int pass;
if ((r->req.cmd.buf[1] & 0x11) != 0x10) {
goto invalid_field;
}
if (len < hdr_len) {
goto invalid_param_len;
}
bd_len = (cmd == MODE_SELECT ? p[3] : lduw_be_p(&p[6]));
len -= hdr_len;
p += hdr_len;
if (len < bd_len) {
goto invalid_param_len;
}
if (bd_len != 0 && bd_len != 8) {
goto invalid_param;
}
len -= bd_len;
p += bd_len;
for (pass = 0; pass < 2; pass++) {
if (mode_select_pages(r, p, len, pass == 1) < 0) {
assert(pass == 0);
return;
}
}
if (!bdrv_enable_write_cache(s->qdev.conf.bs)) {
scsi_req_ref(&r->req);
block_acct_start(bdrv_get_stats(s->qdev.conf.bs), &r->acct, 0,
BLOCK_ACCT_FLUSH);
r->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_aio_complete, r);
return;
}
scsi_req_complete(&r->req, GOOD);
return;
invalid_param:
scsi_check_condition(r, SENSE_CODE(INVALID_PARAM));
return;
invalid_param_len:
scsi_check_condition(r, SENSE_CODE(INVALID_PARAM_LEN));
return;
invalid_field:
scsi_check_condition(r, SENSE_CODE(INVALID_FIELD));
}
| 1threat |
int bdrv_flush(BlockDriverState *bs)
{
Coroutine *co;
RwCo rwco = {
.bs = bs,
.ret = NOT_DONE,
};
if (qemu_in_coroutine()) {
bdrv_flush_co_entry(&rwco);
} else {
AioContext *aio_context = bdrv_get_aio_context(bs);
co = qemu_coroutine_create(bdrv_flush_co_entry);
qemu_coroutine_enter(co, &rwco);
while (rwco.ret == NOT_DONE) {
aio_poll(aio_context, true);
}
}
return rwco.ret;
}
| 1threat |
document.getElementById('input').innerHTML = user_input; | 1threat |
static int vhdx_log_read_desc(BlockDriverState *bs, BDRVVHDXState *s,
VHDXLogEntries *log, VHDXLogDescEntries **buffer,
bool convert_endian)
{
int ret = 0;
uint32_t desc_sectors;
uint32_t sectors_read;
VHDXLogEntryHeader hdr;
VHDXLogDescEntries *desc_entries = NULL;
VHDXLogDescriptor desc;
int i;
assert(*buffer == NULL);
ret = vhdx_log_peek_hdr(bs, log, &hdr);
if (ret < 0) {
goto exit;
}
if (vhdx_log_hdr_is_valid(log, &hdr, s) == false) {
ret = -EINVAL;
goto exit;
}
desc_sectors = vhdx_compute_desc_sectors(hdr.descriptor_count);
desc_entries = qemu_blockalign(bs, desc_sectors * VHDX_LOG_SECTOR_SIZE);
ret = vhdx_log_read_sectors(bs, log, §ors_read, desc_entries,
desc_sectors, false);
if (ret < 0) {
goto free_and_exit;
}
if (sectors_read != desc_sectors) {
ret = -EINVAL;
goto free_and_exit;
}
for (i = 0; i < hdr.descriptor_count; i++) {
desc = desc_entries->desc[i];
vhdx_log_desc_le_import(&desc);
if (convert_endian) {
desc_entries->desc[i] = desc;
}
if (vhdx_log_desc_is_valid(&desc, &hdr) == false) {
ret = -EINVAL;
goto free_and_exit;
}
}
if (convert_endian) {
desc_entries->hdr = hdr;
}
*buffer = desc_entries;
goto exit;
free_and_exit:
qemu_vfree(desc_entries);
exit:
return ret;
}
| 1threat |
How to solve 'libcurl' not found with Rails on Windows : <p>This is giving me a headache. I'm continuing a Rails project that started on Linux and I keep getting this when I run Puma on Ruby Mine:</p>
<pre><code>Error:[rake --tasks] DL is deprecated, please use Fiddle
rake aborted!
LoadError: Could not open library 'libcurl': The specified module could not be found.
Could not open library 'libcurl.dll': The specified module could not be found.
Could not open library 'libcurl.so.4': The specified module could not be found.
Could not open library 'libcurl.so.4.dll': The specified module could not be found.
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/ffi-1.9.14-x86-mingw32/lib/ffi/library.rb:147:in `block in ffi_lib'
[...]
</code></pre>
<p><strong>Now, what have I tried?</strong></p>
<ul>
<li>I installed Puma successfully on Windows following <a href="https://github.com/hicknhack-software/rails-disco/wiki/Installing-puma-on-windows" rel="noreferrer">this steps</a></li>
<li>I downloaded <code>curl-7.50.1-win32-mingw</code> and put it on "C:/curl"</li>
<li>I added C:/curl/bin and C:/curl/include to PATH</li>
<li>I installed successfully curb gem with <code>gem install curb --platform=ruby -- --with-curl-lib=C:/curl/bin --with-curl-include=C:/curl/include</code></li>
<li>I put the .dll files in Ruby bin folder, installed the certificate in curl/bin and even run the curl.exe just in case.</li>
</ul>
<p>I rebooted the machine but I keep seeing the same error.</p>
<p>I do not know what to do. <strong>How to successfully install libcurl on Windows for use with Rails</strong></p>
| 0debug |
C++ Variable names in function : I was wondering if this is possible to do in C++. I have a function that takes user input for x and y bounds and I need to verify it, and it would be easier to do with one function. Is this possible in C++? Here's some pseudocode.
void bounds(char i){
// if i is 'x'
std::cin >> [i]Lower // store to xLower
// verify
}
// then do
bounds('x');
bounds('y'); | 0debug |
Template literal inside of the RegEx : <p>I tried to place a template literal inside of a RegEx, and it didn't work. I then made a variable <code>regex</code> which holds my RegEx, but it still not giving me the desired result.</p>
<p>However if I <code>console.log(regex)</code> individually, I do receive the desired RegEx, such as <code>/.+?(?=location)/i</code>, <code>/.+?(?=date)/i</code> and so on, but once I place <code>regex</code> inside the <code>.replace</code> it appears not to be working</p>
<pre><code>function validate (data) {
let testArr = Object.keys(data);
errorMessages.forEach((elem, i) => {
const regex = `/.+?(?=${elem.value})/i`;
const a = testArr[i].replace(regex, '');
})
}
</code></pre>
| 0debug |
Can't find package on Anaconda Navigator. What to do next? : <p>I am trying to install "pulp" module in Anaconda Navigator's Environment tabs. But when I search in "All" packages I can't find it. It happened with other packages too. </p>
<p><a href="https://i.stack.imgur.com/JqYIF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JqYIF.png" alt="enter image description here"></a></p>
<p>Is there any way to install my package to the desired environment?</p>
<p>I tried to install it by opening a terminal in the environment, but I see that afterwards it won't show up in the list. </p>
<p>What am I missing here?</p>
| 0debug |
Laravel Collection keys modification : <p>I use <code>filter</code> method from <code>Collection</code> class to remove some objects from collection. But after that operation, sometimes objects with keys eg. 1, 4, 5 left. I would like to always have elements with order 0, 1, 2, 3 etc. after <code>filter</code> action.</p>
<p>Is there any elegant way to do it without rewriting table to a new one?</p>
<p>Thanks!</p>
| 0debug |
from collections import Counter
def add_dict(d1,d2):
add_dict = Counter(d1) + Counter(d2)
return add_dict | 0debug |
Month function in sql : Provided a date, say '2011-08-06' .
Is it `Month(Date)=08` or `Month(Date)='08'?` | 0debug |
static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
{
AVFilterContext *ctx = inlink->dst;
ShowInfoContext *showinfo = ctx->priv;
uint32_t plane_checksum[8] = {0}, checksum = 0;
char chlayout_str[128];
int plane;
for (plane = 0; samplesref->data[plane] && plane < 8; plane++) {
uint8_t *data = samplesref->data[plane];
int linesize = samplesref->linesize[plane];
plane_checksum[plane] = av_adler32_update(plane_checksum[plane],
data, linesize);
checksum = av_adler32_update(checksum, data, linesize);
}
av_get_channel_layout_string(chlayout_str, sizeof(chlayout_str), -1,
samplesref->audio->channel_layout);
av_log(ctx, AV_LOG_INFO,
"n:%d pts:%"PRId64" pts_time:%f pos:%"PRId64" "
"fmt:%s chlayout:%s nb_samples:%d rate:%d planar:%d "
"checksum:%u plane_checksum[%u %u %u %u %u %u %u %u]\n",
showinfo->frame,
samplesref->pts, samplesref->pts * av_q2d(inlink->time_base),
samplesref->pos,
av_get_sample_fmt_name(samplesref->format),
chlayout_str,
samplesref->audio->nb_samples,
samplesref->audio->sample_rate,
samplesref->audio->planar,
checksum,
plane_checksum[0], plane_checksum[1], plane_checksum[2], plane_checksum[3],
plane_checksum[4], plane_checksum[5], plane_checksum[6], plane_checksum[7]);
showinfo->frame++;
avfilter_filter_samples(inlink->dst->outputs[0], samplesref);
}
| 1threat |
Autofocus TextField programmatically in SwiftUI : <p>I'm using a modal to add names to a list. When the modal is shown, I want to focus the TextField automatically, like this:</p>
<p><a href="https://i.stack.imgur.com/gkmeA.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/gkmeA.gif" alt="Preview"></a></p>
<p>I've not found any suitable solutions yet.</p>
<p>Is there anything implemented into SwiftUI already in order to do this?</p>
<p>Thanks for your help.</p>
<pre><code>var modal: some View {
NavigationView{
VStack{
HStack{
Spacer()
TextField("Name", text: $inputText) // autofocus this!
.textFieldStyle(DefaultTextFieldStyle())
.padding()
.font(.system(size: 25))
// something like .focus() ??
Spacer()
}
Button(action: {
if self.inputText != ""{
self.players.append(Player(name: self.inputText))
self.inputText = ""
self.isModal = false
}
}, label: {
HStack{
Text("Add \(inputText)")
Image(systemName: "plus")
}
.font(.system(size: 20))
})
.padding()
.foregroundColor(.white)
.background(Color.blue)
.cornerRadius(10)
Spacer()
}
.navigationBarTitle("New Player")
.navigationBarItems(trailing: Button(action: {self.isModal=false}, label: {Text("Cancel").font(.system(size: 20))}))
.padding()
}
}
</code></pre>
| 0debug |
how to delete more than two Array Objects in tableview in ios? : i have taken three arrays one Array for saving image data and remaining two arrays image names and dates,
While deleting row i'm getting this error
NSInternalInconsistencyException', reason: '-[__NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object'
how to handle this? | 0debug |
y=[ x[i] for i in range(len(x)) if not x[i] in x[:i] ] : y=[ x[i] for i in range(len(x)) if not x[i] in x[:i] ]
Can anyone explain to me how this step by step approach to deleting duplicates and sorting in ascending order both works at the same time in this single line?Thanks. | 0debug |
Could not chdir to home directory after create a user : <p>I've created a user in Ubuntu 16.04 using the commands</p>
<pre><code>sudo useradd peris
sudo passwd peris
</code></pre>
<p>Then I log off, ans log in with the new user but I got this error:</p>
<pre><code>Could not chdir to home directory /home/peris: No such file or directory
</code></pre>
| 0debug |
static int planarRgb16ToRgb16Wrapper(SwsContext *c, const uint8_t *src[],
int srcStride[], int srcSliceY, int srcSliceH,
uint8_t *dst[], int dstStride[])
{
const uint16_t *src102[] = { (uint16_t *)src[1], (uint16_t *)src[0], (uint16_t *)src[2] };
const uint16_t *src201[] = { (uint16_t *)src[2], (uint16_t *)src[0], (uint16_t *)src[1] };
int stride102[] = { srcStride[1], srcStride[0], srcStride[2] };
int stride201[] = { srcStride[2], srcStride[0], srcStride[1] };
const AVPixFmtDescriptor *src_format = av_pix_fmt_desc_get(c->srcFormat);
const AVPixFmtDescriptor *dst_format = av_pix_fmt_desc_get(c->dstFormat);
int bits_per_sample = src_format->comp[0].depth_minus1 + 1;
int swap = 0;
if ( HAVE_BIGENDIAN && !(src_format->flags & AV_PIX_FMT_FLAG_BE) ||
!HAVE_BIGENDIAN && src_format->flags & AV_PIX_FMT_FLAG_BE)
swap++;
if ( HAVE_BIGENDIAN && !(dst_format->flags & AV_PIX_FMT_FLAG_BE) ||
!HAVE_BIGENDIAN && dst_format->flags & AV_PIX_FMT_FLAG_BE)
swap += 2;
if ((src_format->flags & (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB)) !=
(AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB)) {
av_log(c, AV_LOG_ERROR, "unsupported planar RGB conversion %s -> %s\n",
src_format->name, dst_format->name);
return srcSliceH;
}
switch (c->dstFormat) {
case AV_PIX_FMT_BGR48LE:
case AV_PIX_FMT_BGR48BE:
gbr16ptopacked16(src102, stride102,
dst[0] + srcSliceY * dstStride[0], dstStride[0],
srcSliceH, 0, swap, bits_per_sample, c->srcW);
break;
case AV_PIX_FMT_RGB48LE:
case AV_PIX_FMT_RGB48BE:
gbr16ptopacked16(src201, stride201,
dst[0] + srcSliceY * dstStride[0], dstStride[0],
srcSliceH, 0, swap, bits_per_sample, c->srcW);
break;
case AV_PIX_FMT_RGBA64LE:
case AV_PIX_FMT_RGBA64BE:
gbr16ptopacked16(src201, stride201,
dst[0] + srcSliceY * dstStride[0], dstStride[0],
srcSliceH, 1, swap, bits_per_sample, c->srcW);
break;
case AV_PIX_FMT_BGRA64LE:
case AV_PIX_FMT_BGRA64BE:
gbr16ptopacked16(src102, stride102,
dst[0] + srcSliceY * dstStride[0], dstStride[0],
srcSliceH, 1, swap, bits_per_sample, c->srcW);
break;
default:
av_log(c, AV_LOG_ERROR,
"unsupported planar RGB conversion %s -> %s\n",
src_format->name, dst_format->name);
}
return srcSliceH;
}
| 1threat |
void dsputil_init_alpha(void)
{
put_pixels_tab[0][0] = put_pixels16_axp_asm;
put_pixels_tab[0][1] = put_pixels16_x2_axp;
put_pixels_tab[0][2] = put_pixels16_y2_axp;
put_pixels_tab[0][3] = put_pixels16_xy2_axp;
put_no_rnd_pixels_tab[0][0] = put_pixels16_axp_asm;
put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_axp;
put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_axp;
put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_axp;
avg_pixels_tab[0][0] = avg_pixels16_axp;
avg_pixels_tab[0][1] = avg_pixels16_x2_axp;
avg_pixels_tab[0][2] = avg_pixels16_y2_axp;
avg_pixels_tab[0][3] = avg_pixels16_xy2_axp;
avg_no_rnd_pixels_tab[0][0] = avg_no_rnd_pixels16_axp;
avg_no_rnd_pixels_tab[0][1] = avg_no_rnd_pixels16_x2_axp;
avg_no_rnd_pixels_tab[0][2] = avg_no_rnd_pixels16_y2_axp;
avg_no_rnd_pixels_tab[0][3] = avg_no_rnd_pixels16_xy2_axp;
put_pixels_tab[1][0] = put_pixels_axp_asm;
put_pixels_tab[1][1] = put_pixels_x2_axp;
put_pixels_tab[1][2] = put_pixels_y2_axp;
put_pixels_tab[1][3] = put_pixels_xy2_axp;
put_no_rnd_pixels_tab[1][0] = put_pixels_axp_asm;
put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels_x2_axp;
put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels_y2_axp;
put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels_xy2_axp;
avg_pixels_tab[1][0] = avg_pixels_axp;
avg_pixels_tab[1][1] = avg_pixels_x2_axp;
avg_pixels_tab[1][2] = avg_pixels_y2_axp;
avg_pixels_tab[1][3] = avg_pixels_xy2_axp;
avg_no_rnd_pixels_tab[1][0] = avg_no_rnd_pixels_axp;
avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels_x2_axp;
avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels_y2_axp;
avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels_xy2_axp;
clear_blocks = clear_blocks_axp;
if (amask(AMASK_MVI) == 0) {
put_pixels_clamped = put_pixels_clamped_mvi_asm;
add_pixels_clamped = add_pixels_clamped_mvi_asm;
get_pixels = get_pixels_mvi;
diff_pixels = diff_pixels_mvi;
pix_abs8x8 = pix_abs8x8_mvi;
pix_abs16x16 = pix_abs16x16_mvi_asm;
pix_abs16x16_x2 = pix_abs16x16_x2_mvi;
pix_abs16x16_y2 = pix_abs16x16_y2_mvi;
pix_abs16x16_xy2 = pix_abs16x16_xy2_mvi;
}
}
| 1threat |
Angular 6 - ForkJoin has no exported member : <p>I have updated to Angular 6 and I'm trying to use ForkJoin, so on my service I have:</p>
<pre><code>import { forkJoin } from 'rxjs/observable/forkJoin';
</code></pre>
<p>But it's not recognising is and I'm getting:</p>
<pre><code>...ForkJoin has no exported member
</code></pre>
<p>How can I fix this?</p>
| 0debug |
How do we query on a secondary index of dynamodb using boto3? : <p>Is there a way at all to query on the <code>global secondary index</code> of dynamodb using <code>boto3</code>. I dont find any online tutorials or resources. </p>
| 0debug |
VBA Ms Excel Matching references with Zero amount total : [enter image description here][1]
[1]: https://i.stack.imgur.com/JrhCv.png
Dear Friends
I am trying to write a VBA code that could delete matched referenece in the row(ex A1 match A2 and B1 match B2) with sum amount of C1 & C2 = Zero.
in the below case system should check Row# 1 and should be match Row# 2 as A1 match A2 and B1 match with B2 and sum amount of C1 and C2 = nill.
then repeat this proccess to the end of the file.
Thanks
Salem H. | 0debug |
No "NOT NULL" and "UNIQUE" constraint on Room Persistence Library : <p>While playing with the <strong>Room Persistence Library</strong> I came to know that there is no methodology to set a data class field with NOT NULL and also UNIQUE constraints. whether SQLite supports those constraints. Isn't it a problem to migrate old database where those constraints are used? Can anyone give a suggestion for this issue?</p>
| 0debug |
static void spatial_compose53i_dy(dwt_compose_t *cs, DWTELEM *buffer, int width, int height, int stride){
int y= cs->y;
DWTELEM *b0= cs->b0;
DWTELEM *b1= cs->b1;
DWTELEM *b2= buffer + mirror(y+1, height-1)*stride;
DWTELEM *b3= buffer + mirror(y+2, height-1)*stride;
{START_TIMER
if(b1 <= b3) vertical_compose53iL0(b1, b2, b3, width);
if(b0 <= b2) vertical_compose53iH0(b0, b1, b2, width);
STOP_TIMER("vertical_compose53i*")}
{START_TIMER
if(y-1 >= 0) horizontal_compose53i(b0, width);
if(b0 <= b2) horizontal_compose53i(b1, width);
STOP_TIMER("horizontal_compose53i")}
cs->b0 = b2;
cs->b1 = b3;
cs->y += 2;
}
| 1threat |
document.getElementById('input').innerHTML = user_input; | 1threat |
React.js - Communicating between sibling components : <p>I'm new to React, and I'd like to ask a strategy question about how best to accomplish a task where data must be communicated between sibling components.</p>
<p>First, I'll describe the task:</p>
<p>Say I have multiple <code><select></code> components that are children of a single parent that passes down the select boxes dynamically, composed from an array. Each box has exactly the same available options in its initial state, but once a user selects a particular option in one box, it must be disabled as an option in all other boxes until it is released. </p>
<p>Here's an example of the same in (silly) code. (I'm using <code>react-select</code> as a shorthand for creating the select boxes.)</p>
<p>In this example, I need to disable (ie, set <code>disabled: true</code>) the options for "It's my favorite" and "It's my least favorite" when a user selects them in one select box (and release them if a user de-selects them).</p>
<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var React = require('react');
var Select = require('react-select');
var AnForm = React.createClass({
render: function(){
// this.props.fruits is an array passed in that looks like:
// ['apples', 'bananas', 'cherries','watermelon','oranges']
var selects = this.props.fruits.map(function(fruit, i) {
var options = [
{ value: 'first', label: 'It\'s my favorite', disabled: false },
{ value: 'second', label: 'I\'m OK with it', disabled: false },
{ value: 'third', label: 'It\'s my least favorite', disabled: false }
];
return (
<Child fruit={fruit} key={i} options={options} />
);
});
return (
<div id="myFormThingy">
{fruitSelects}
</div>
)
}
});
var AnChild = React.createClass({
getInitialState: function() {
return {
value:'',
options: this.props.options
};
},
render: function(){
function changeValue(value){
this.setState({value:value});
}
return (
<label for={this.props.fruit}>{this.props.fruit}</label>
<Select
name={this.props.fruit}
value={this.state.value}
options={this.state.options}
onChange={changeValue.bind(this)}
placeholder="Choose one"
/>
)
}
});</code></pre>
</div>
</div>
</p>
<p>Is updating the child options best accomplished by passing data back up to the parent through a callback? Should I use refs to access the child components in that callback? Does a redux reducer help?</p>
<p>I apologize for the general nature of the question, but I'm not finding a lot of direction on how to deal with these sibling-to-sibling component interactions in a unidirectional way.</p>
<p>Thanks for any help.</p>
| 0debug |
static int vfio_get_device(VFIOGroup *group, const char *name, VFIODevice *vdev)
{
struct vfio_device_info dev_info = { .argsz = sizeof(dev_info) };
struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };
struct vfio_irq_info irq_info = { .argsz = sizeof(irq_info) };
int ret, i;
ret = ioctl(group->fd, VFIO_GROUP_GET_DEVICE_FD, name);
if (ret < 0) {
error_report("vfio: error getting device %s from group %d: %m",
name, group->groupid);
error_printf("Verify all devices in group %d are bound to vfio-pci "
"or pci-stub and not already in use\n", group->groupid);
return ret;
}
vdev->fd = ret;
vdev->group = group;
QLIST_INSERT_HEAD(&group->device_list, vdev, next);
ret = ioctl(vdev->fd, VFIO_DEVICE_GET_INFO, &dev_info);
if (ret) {
error_report("vfio: error getting device info: %m");
goto error;
}
DPRINTF("Device %s flags: %u, regions: %u, irgs: %u\n", name,
dev_info.flags, dev_info.num_regions, dev_info.num_irqs);
if (!(dev_info.flags & VFIO_DEVICE_FLAGS_PCI)) {
error_report("vfio: Um, this isn't a PCI device");
goto error;
}
vdev->reset_works = !!(dev_info.flags & VFIO_DEVICE_FLAGS_RESET);
if (!vdev->reset_works) {
error_report("Warning, device %s does not support reset", name);
}
if (dev_info.num_regions < VFIO_PCI_CONFIG_REGION_INDEX + 1) {
error_report("vfio: unexpected number of io regions %u",
dev_info.num_regions);
goto error;
}
if (dev_info.num_irqs < VFIO_PCI_MSIX_IRQ_INDEX + 1) {
error_report("vfio: unexpected number of irqs %u", dev_info.num_irqs);
goto error;
}
for (i = VFIO_PCI_BAR0_REGION_INDEX; i < VFIO_PCI_ROM_REGION_INDEX; i++) {
reg_info.index = i;
ret = ioctl(vdev->fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
if (ret) {
error_report("vfio: Error getting region %d info: %m", i);
goto error;
}
DPRINTF("Device %s region %d:\n", name, i);
DPRINTF(" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\n",
(unsigned long)reg_info.size, (unsigned long)reg_info.offset,
(unsigned long)reg_info.flags);
vdev->bars[i].flags = reg_info.flags;
vdev->bars[i].size = reg_info.size;
vdev->bars[i].fd_offset = reg_info.offset;
vdev->bars[i].fd = vdev->fd;
vdev->bars[i].nr = i;
QLIST_INIT(&vdev->bars[i].quirks);
}
reg_info.index = VFIO_PCI_ROM_REGION_INDEX;
ret = ioctl(vdev->fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
if (ret) {
error_report("vfio: Error getting ROM info: %m");
goto error;
}
DPRINTF("Device %s ROM:\n", name);
DPRINTF(" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\n",
(unsigned long)reg_info.size, (unsigned long)reg_info.offset,
(unsigned long)reg_info.flags);
vdev->rom_size = reg_info.size;
vdev->rom_offset = reg_info.offset;
reg_info.index = VFIO_PCI_CONFIG_REGION_INDEX;
ret = ioctl(vdev->fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
if (ret) {
error_report("vfio: Error getting config info: %m");
goto error;
}
DPRINTF("Device %s config:\n", name);
DPRINTF(" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\n",
(unsigned long)reg_info.size, (unsigned long)reg_info.offset,
(unsigned long)reg_info.flags);
vdev->config_size = reg_info.size;
if (vdev->config_size == PCI_CONFIG_SPACE_SIZE) {
vdev->pdev.cap_present &= ~QEMU_PCI_CAP_EXPRESS;
}
vdev->config_offset = reg_info.offset;
if ((vdev->features & VFIO_FEATURE_ENABLE_VGA) &&
dev_info.num_regions > VFIO_PCI_VGA_REGION_INDEX) {
struct vfio_region_info vga_info = {
.argsz = sizeof(vga_info),
.index = VFIO_PCI_VGA_REGION_INDEX,
};
ret = ioctl(vdev->fd, VFIO_DEVICE_GET_REGION_INFO, &vga_info);
if (ret) {
error_report(
"vfio: Device does not support requested feature x-vga");
goto error;
}
if (!(vga_info.flags & VFIO_REGION_INFO_FLAG_READ) ||
!(vga_info.flags & VFIO_REGION_INFO_FLAG_WRITE) ||
vga_info.size < 0xbffff + 1) {
error_report("vfio: Unexpected VGA info, flags 0x%lx, size 0x%lx",
(unsigned long)vga_info.flags,
(unsigned long)vga_info.size);
goto error;
}
vdev->vga.fd_offset = vga_info.offset;
vdev->vga.fd = vdev->fd;
vdev->vga.region[QEMU_PCI_VGA_MEM].offset = QEMU_PCI_VGA_MEM_BASE;
vdev->vga.region[QEMU_PCI_VGA_MEM].nr = QEMU_PCI_VGA_MEM;
QLIST_INIT(&vdev->vga.region[QEMU_PCI_VGA_MEM].quirks);
vdev->vga.region[QEMU_PCI_VGA_IO_LO].offset = QEMU_PCI_VGA_IO_LO_BASE;
vdev->vga.region[QEMU_PCI_VGA_IO_LO].nr = QEMU_PCI_VGA_IO_LO;
QLIST_INIT(&vdev->vga.region[QEMU_PCI_VGA_IO_LO].quirks);
vdev->vga.region[QEMU_PCI_VGA_IO_HI].offset = QEMU_PCI_VGA_IO_HI_BASE;
vdev->vga.region[QEMU_PCI_VGA_IO_HI].nr = QEMU_PCI_VGA_IO_HI;
QLIST_INIT(&vdev->vga.region[QEMU_PCI_VGA_IO_HI].quirks);
vdev->has_vga = true;
}
irq_info.index = VFIO_PCI_ERR_IRQ_INDEX;
ret = ioctl(vdev->fd, VFIO_DEVICE_GET_IRQ_INFO, &irq_info);
if (ret) {
DPRINTF("VFIO_DEVICE_GET_IRQ_INFO failure ret=%d\n", ret);
ret = 0;
} else if (irq_info.count == 1) {
vdev->pci_aer = true;
} else {
error_report("vfio: Warning: "
"Could not enable error recovery for the device\n");
}
error:
if (ret) {
QLIST_REMOVE(vdev, next);
vdev->group = NULL;
close(vdev->fd);
}
return ret;
}
| 1threat |
Does a Catch all catch an aggregate exception? and prevent crashing? : <p>Would this cause an app to crash? Visual studio picks up the exception, but is that just because it's an IDE? Would this be ok in production? Or do I need to explicitly catch an AggregateException?</p>
<pre><code>try
{
throw new AggregateException;
}
catch
{
What will happen?
}
</code></pre>
| 0debug |
Sql server query to match the exact word : This query returns the following:
select * from dbo.persons where LastName like '%Dan%';
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/3KvuD.png
How can I select only the first row with LastName = "Dan" and not "Dant" or "Dan12" | 0debug |
What happen in background memory point of view when we move one branch to another branch of same project in git...? : <p>What happen in background memory point of view when we move one branch to another branch of same project in git, Where the commit store???</p>
| 0debug |
Send specific key ASCII code to Bash : I want to force on bash "Tab" clicking from my C# code.
I'm able to send any STRING value to the Bash and get the output, but how can I send the specific key to bash? I want to send "TAB". Can I type into bash console some specific string to have this kind of solution?
I've tried
`$'\t'`, some `echo` combinations etc, but I can't force bash to, for example, list the files in current directories.
Thanks for any advice. | 0debug |
static void iommu_config_write(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
IOMMUState *is = opaque;
IOMMU_DPRINTF("IOMMU config write: 0x%" HWADDR_PRIx " val: %" PRIx64
" size: %d\n", addr, val, size);
switch (addr) {
case IOMMU_CTRL:
if (size == 4) {
is->regs[IOMMU_CTRL >> 3] &= 0xffffffffULL;
is->regs[IOMMU_CTRL >> 3] |= val << 32;
} else {
is->regs[IOMMU_CTRL] = val;
}
break;
case IOMMU_CTRL + 0x4:
is->regs[IOMMU_CTRL >> 3] &= 0xffffffff00000000ULL;
is->regs[IOMMU_CTRL >> 3] |= val & 0xffffffffULL;
break;
case IOMMU_BASE:
if (size == 4) {
is->regs[IOMMU_BASE >> 3] &= 0xffffffffULL;
is->regs[IOMMU_BASE >> 3] |= val << 32;
} else {
is->regs[IOMMU_BASE] = val;
}
break;
case IOMMU_BASE + 0x4:
is->regs[IOMMU_BASE >> 3] &= 0xffffffff00000000ULL;
is->regs[IOMMU_BASE >> 3] |= val & 0xffffffffULL;
break;
default:
qemu_log_mask(LOG_UNIMP,
"apb iommu: Unimplemented register write "
"reg 0x%" HWADDR_PRIx " size 0x%x value 0x%" PRIx64 "\n",
addr, size, val);
break;
}
}
| 1threat |
How can mypy ignore a single line in a source file? : <p>I'm using <a href="http://mypy-lang.org/" rel="noreferrer">mypy</a> in my python project for type checking. I'm also using PyYAML for reading and writing the project configuration files. Unfortunately, when using the <a href="http://pyyaml.org/wiki/PyYAMLDocumentation" rel="noreferrer">recommended import mechanism from the PyYAML documentation</a> this generates a spurious error in a try/except clause that attempts to import native libraries:</p>
<pre><code>from yaml import load, dump
try:
from yaml import CLoader as Loader, CDumper as Dumper
except ImportError:
from yaml import Loader, Dumper
</code></pre>
<p>On my system <code>CLoader</code> and <code>CDumper</code> aren't present, which results in the errors <code>error: Module 'yaml' has no attribute 'CLoader'</code> and <code>error: Module 'yaml' has no attribute 'CDumper'</code>.</p>
<p>Is there a way to have mypy ignore errors on this line? I was hoping that I could do something like this to have mypy skip that line:</p>
<pre><code>from yaml import load, dump
try:
from yaml import CLoader as Loader, CDumper as Dumper # nomypy
except ImportError:
from yaml import Loader, Dumper
</code></pre>
| 0debug |
static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_count,
AudioData *in , int in_count){
AudioData *postin, *midbuf, *preout;
int ret;
AudioData preout_tmp, midbuf_tmp;
if(s->full_convert){
av_assert0(!s->resample);
swri_audio_convert(s->full_convert, out, in, in_count);
return out_count;
}
if((ret=swri_realloc_audio(&s->postin, in_count))<0)
return ret;
if(s->resample_first){
av_assert0(s->midbuf.ch_count == s->used_ch_count);
if((ret=swri_realloc_audio(&s->midbuf, out_count))<0)
return ret;
}else{
av_assert0(s->midbuf.ch_count == s->out.ch_count);
if((ret=swri_realloc_audio(&s->midbuf, in_count))<0)
return ret;
}
if((ret=swri_realloc_audio(&s->preout, out_count))<0)
return ret;
postin= &s->postin;
midbuf_tmp= s->midbuf;
midbuf= &midbuf_tmp;
preout_tmp= s->preout;
preout= &preout_tmp;
if(s->int_sample_fmt == s-> in_sample_fmt && s->in.planar && !s->channel_map)
postin= in;
if(s->resample_first ? !s->resample : !s->rematrix)
midbuf= postin;
if(s->resample_first ? !s->rematrix : !s->resample)
preout= midbuf;
if(s->int_sample_fmt == s->out_sample_fmt && s->out.planar
&& !(s->out_sample_fmt==AV_SAMPLE_FMT_S32P && (s->dither.output_sample_bits&31))){
if(preout==in){
out_count= FFMIN(out_count, in_count);
av_assert0(s->in.planar);
copy(out, in, out_count);
return out_count;
}
else if(preout==postin) preout= midbuf= postin= out;
else if(preout==midbuf) preout= midbuf= out;
else preout= out;
}
if(in != postin){
swri_audio_convert(s->in_convert, postin, in, in_count);
}
if(s->resample_first){
if(postin != midbuf)
out_count= resample(s, midbuf, out_count, postin, in_count);
if(midbuf != preout)
swri_rematrix(s, preout, midbuf, out_count, preout==out);
}else{
if(postin != midbuf)
swri_rematrix(s, midbuf, postin, in_count, midbuf==out);
if(midbuf != preout)
out_count= resample(s, preout, out_count, midbuf, in_count);
}
if(preout != out && out_count){
AudioData *conv_src = preout;
if(s->dither.method){
int ch;
int dither_count= FFMAX(out_count, 1<<16);
if (preout == in) {
conv_src = &s->dither.temp;
if((ret=swri_realloc_audio(&s->dither.temp, dither_count))<0)
return ret;
}
if((ret=swri_realloc_audio(&s->dither.noise, dither_count))<0)
return ret;
if(ret)
for(ch=0; ch<s->dither.noise.ch_count; ch++)
if((ret=swri_get_dither(s, s->dither.noise.ch[ch], s->dither.noise.count, 12345678913579<<ch, s->dither.noise.fmt))<0)
return ret;
av_assert0(s->dither.noise.ch_count == preout->ch_count);
if(s->dither.noise_pos + out_count > s->dither.noise.count)
s->dither.noise_pos = 0;
if (s->dither.method < SWR_DITHER_NS){
if (s->mix_2_1_simd) {
int len1= out_count&~15;
int off = len1 * preout->bps;
if(len1)
for(ch=0; ch<preout->ch_count; ch++)
s->mix_2_1_simd(conv_src->ch[ch], preout->ch[ch], s->dither.noise.ch[ch] + s->dither.noise.bps * s->dither.noise_pos, s->native_simd_one, 0, 0, len1);
if(out_count != len1)
for(ch=0; ch<preout->ch_count; ch++)
s->mix_2_1_f(conv_src->ch[ch] + off, preout->ch[ch] + off, s->dither.noise.ch[ch] + s->dither.noise.bps * s->dither.noise_pos + off + len1, s->native_one, 0, 0, out_count - len1);
} else {
for(ch=0; ch<preout->ch_count; ch++)
s->mix_2_1_f(conv_src->ch[ch], preout->ch[ch], s->dither.noise.ch[ch] + s->dither.noise.bps * s->dither.noise_pos, s->native_one, 0, 0, out_count);
}
} else {
switch(s->int_sample_fmt) {
case AV_SAMPLE_FMT_S16P :swri_noise_shaping_int16(s, conv_src, preout, &s->dither.noise, out_count); break;
case AV_SAMPLE_FMT_S32P :swri_noise_shaping_int32(s, conv_src, preout, &s->dither.noise, out_count); break;
case AV_SAMPLE_FMT_FLTP :swri_noise_shaping_float(s, conv_src, preout, &s->dither.noise, out_count); break;
case AV_SAMPLE_FMT_DBLP :swri_noise_shaping_double(s,conv_src, preout, &s->dither.noise, out_count); break;
}
}
s->dither.noise_pos += out_count;
}
swri_audio_convert(s->out_convert, out, conv_src, out_count);
}
return out_count;
}
| 1threat |
static av_cold int libssh_authentication(LIBSSHContext *libssh, const char *user, const char *password)
{
int authorized = 0;
int auth_methods;
if (user)
ssh_options_set(libssh->session, SSH_OPTIONS_USER, user);
if (ssh_userauth_none(libssh->session, NULL) == SSH_AUTH_SUCCESS)
return 0;
auth_methods = ssh_userauth_list(libssh->session, NULL);
if (auth_methods & SSH_AUTH_METHOD_PUBLICKEY) {
if (libssh->priv_key) {
ssh_string pub_key;
ssh_private_key priv_key;
int type;
if (!ssh_try_publickey_from_file(libssh->session, libssh->priv_key, &pub_key, &type)) {
priv_key = privatekey_from_file(libssh->session, libssh->priv_key, type, password);
if (ssh_userauth_pubkey(libssh->session, NULL, pub_key, priv_key) == SSH_AUTH_SUCCESS) {
av_log(libssh, AV_LOG_DEBUG, "Authentication successful with selected private key.\n");
authorized = 1;
}
} else {
av_log(libssh, AV_LOG_DEBUG, "Invalid key is provided.\n");
return AVERROR(EACCES);
}
} else if (ssh_userauth_autopubkey(libssh->session, password) == SSH_AUTH_SUCCESS) {
av_log(libssh, AV_LOG_DEBUG, "Authentication successful with auto selected key.\n");
authorized = 1;
}
}
if (!authorized && (auth_methods & SSH_AUTH_METHOD_PASSWORD)) {
if (ssh_userauth_password(libssh->session, NULL, password) == SSH_AUTH_SUCCESS) {
av_log(libssh, AV_LOG_DEBUG, "Authentication successful with password.\n");
authorized = 1;
}
}
if (!authorized) {
av_log(libssh, AV_LOG_ERROR, "Authentication failed.\n");
return AVERROR(EACCES);
}
return 0;
}
| 1threat |
Valid Regex Not so valid in PHP : <p>So i want to extract everything in between form tags (including the tags them selves). </p>
<p>The form is as below:</p>
<pre><code><body><br />
<!--
<form method="POST" action="#">
<table style="table-layout: fixed; border: 1px solid #ffffff; " border="1">
<!--
<col width="50"> --></p>
<tr style="width: 1154px; background-color: #0d56c2; vertical-align: middle; color: #ffffff; height: 70px; ">
<td style="width: 413px; text-align: center;">Calls</td>
<td style="background-color: #D6DCE5; width: 319px; padding-left: 20px; padding-top: 15px;"><input type="text" name="calls" value="150" style="width: 173px;"></td>
<td style="width: 412px; padding: 5px; vertical-align: middle;"> in a period of <input name="period" value="5" style="width: 173px; ">&nbsp;<br />
<select name="callUnit" style="width: 100px; height: 29px; position: absolute;"><option value="hour" selected>hours</option><option value="minute" >minutes</option></select>
</td>
</tr>
</table>
</form>
</body>
</code></pre>
<p>Regex i am using is: <code><form.*>[\s\S]*<\/form></code> and according to <a href="https://regex101.com/" rel="nofollow noreferrer">regex101</a> This is a valid regular expression that should extract form tags + everthing in between. </p>
<p>However using the above regular expression in preg_match i get the following error: <code>Warning: preg_match(): Unknown modifier '['</code></p>
| 0debug |
void virtio_net_exit(VirtIODevice *vdev)
{
VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);
qemu_del_vm_change_state_handler(n->vmstate);
if (n->vhost_started) {
vhost_net_stop(tap_get_vhost_net(n->nic->nc.peer), vdev);
}
qemu_purge_queued_packets(&n->nic->nc);
unregister_savevm(n->qdev, "virtio-net", n);
qemu_free(n->mac_table.macs);
qemu_free(n->vlans);
qemu_del_timer(n->tx_timer);
qemu_free_timer(n->tx_timer);
virtio_cleanup(&n->vdev);
qemu_del_vlan_client(&n->nic->nc);
}
| 1threat |
static void subband_transform(DCAEncContext *c, const int32_t *input)
{
int ch, subs, i, k, j;
for (ch = 0; ch < c->fullband_channels; ch++) {
int32_t hist[512];
int hist_start = 0;
const int chi = c->channel_order_tab[ch];
for (i = 0; i < 512; i++)
hist[i] = c->history[i][ch];
for (subs = 0; subs < SUBBAND_SAMPLES; subs++) {
int32_t accum[64];
int32_t resp;
int band;
for (i = 0; i < 64; i++)
accum[i] = 0;
for (k = 0, i = hist_start, j = 0;
i < 512; k = (k + 1) & 63, i++, j++)
accum[k] += mul32(hist[i], c->band_interpolation[j]);
for (i = 0; i < hist_start; k = (k + 1) & 63, i++, j++)
accum[k] += mul32(hist[i], c->band_interpolation[j]);
for (k = 16; k < 32; k++)
accum[k] = accum[k] - accum[31 - k];
for (k = 32; k < 48; k++)
accum[k] = accum[k] + accum[95 - k];
for (band = 0; band < 32; band++) {
resp = 0;
for (i = 16; i < 48; i++) {
int s = (2 * band + 1) * (2 * (i + 16) + 1);
resp += mul32(accum[i], cos_t(s << 3)) >> 3;
}
c->subband[subs][band][ch] = ((band + 1) & 2) ? -resp : resp;
}
for (i = 0; i < 32; i++)
hist[i + hist_start] = input[(subs * 32 + i) * c->channels + chi];
hist_start = (hist_start + 32) & 511;
}
}
}
| 1threat |
Python 3: Convert string from utf-8 to ascii : <p>I am using Python 3.x and have a string that contains utf-8 characters, like this:</p>
<pre><code>link='https%3A%2F%2Fwww.google.com'
</code></pre>
<p>I would now like to convert the string to ascii, so that it reads '<a href="https://www.google.com" rel="nofollow noreferrer">https://www.google.com</a>'. How can I achieve this? I have tried </p>
<pre><code>link.decode('utf-8')
</code></pre>
<p>which throws the exception:</p>
<pre><code>AttributeError: 'str' object has no attribute 'decode'
</code></pre>
<p>Is there not an easy way to simply decode a string containing utf-8 characters to plain ascii characters?</p>
| 0debug |
def count_list(input_list):
return len(input_list) | 0debug |
static void decode_clnpass(Jpeg2000DecoderContext *s, Jpeg2000T1Context *t1,
int width, int height, int bpno, int bandno,
int seg_symbols)
{
int mask = 3 << (bpno - 1), y0, x, y, runlen, dec;
for (y0 = 0; y0 < height; y0 += 4)
for (x = 0; x < width; x++) {
if (y0 + 3 < height &&
!((t1->flags[y0 + 1][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) ||
(t1->flags[y0 + 2][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) ||
(t1->flags[y0 + 3][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) ||
(t1->flags[y0 + 4][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)))) {
if (!ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_RL))
continue;
runlen = ff_mqc_decode(&t1->mqc,
t1->mqc.cx_states + MQC_CX_UNI);
runlen = (runlen << 1) | ff_mqc_decode(&t1->mqc,
t1->mqc.cx_states +
MQC_CX_UNI);
dec = 1;
} else {
runlen = 0;
dec = 0;
}
for (y = y0 + runlen; y < y0 + 4 && y < height; y++) {
if (!dec) {
if (!(t1->flags[y + 1][x + 1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS)))
dec = ff_mqc_decode(&t1->mqc,
t1->mqc.cx_states +
ff_jpeg2000_getsigctxno(t1->flags[y + 1][x + 1],
bandno));
}
if (dec) {
int xorbit;
int ctxno = ff_jpeg2000_getsgnctxno(t1->flags[y + 1][x + 1],
&xorbit);
t1->data[y][x] = (ff_mqc_decode(&t1->mqc,
t1->mqc.cx_states + ctxno) ^
xorbit)
? -mask : mask;
ff_jpeg2000_set_significance(t1, x, y, t1->data[y][x] < 0);
}
dec = 0;
t1->flags[y + 1][x + 1] &= ~JPEG2000_T1_VIS;
}
}
if (seg_symbols) {
int val;
val = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);
val = (val << 1) + ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);
val = (val << 1) + ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);
val = (val << 1) + ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);
if (val != 0xa)
av_log(s->avctx, AV_LOG_ERROR,
"Segmentation symbol value incorrect\n");
}
}
| 1threat |
I have written a code but it doesn't work as I would have liked : I have a file containing 5 columnes and a few 7 rows as follows
0,5,7,9,0
5,9,7,0,0
9,9,7,0,0
7,7,9,9,0
0,0,0,0,0
5,5,7,0,0
5,0,0,0,0
i want a validation check in python that should allow me to check that there is either a 5,7,9 but none of them is repeated i.e there must be only one occurrence of these numbers,5 and 7 are a must a 9 is optional, the remaining three can be 0. I have written this code but it doesn't work as I wan't . I also want to store the valid rows in a separate list.
My attempt of the program in python is as follows
def validation ():
numlist = open("scores.txt","r")
invalidnum=0
for line in numlist:
x = line.count("0")
inv1 = line.count("1")
inv2 = line.count("2")
inv3 = line.count("3")
if x > 2 or inv1 > 1 or inv2 > 1 or inv3 > 1 or line not in ("0","5","7","9"):
invalidnum=invalidnum+1
print(invalidnum,"Invalid numbers found"
else:
print("All numbers are valid in the list")
I will appreciate if someone can help me on this.
Thanks | 0debug |
Get rid of "Remote debugger is in a background tab" warning in React Native : <p>I've started a new React Native project and I keep getting the following warning:</p>
<blockquote>
<p>Remote debugger is in a background tab which may cause apps to perform slowly. Fix this by foregrounding the tab (or opening it in a separate window).</p>
</blockquote>
<p>It's a bit annoying so I wanna know how I can get rid of it? I'm running the debugger in Chrome and I moved it to a seperate window but it did not help.</p>
| 0debug |
static void cmv_process_header(CmvContext *s, const uint8_t *buf, const uint8_t *buf_end)
{
int pal_start, pal_count, i;
if(buf_end - buf < 16) {
av_log(s->avctx, AV_LOG_WARNING, "truncated header\n");
return;
}
s->width = AV_RL16(&buf[4]);
s->height = AV_RL16(&buf[6]);
if (s->avctx->width!=s->width || s->avctx->height!=s->height)
avcodec_set_dimensions(s->avctx, s->width, s->height);
s->avctx->time_base.num = 1;
s->avctx->time_base.den = AV_RL16(&buf[10]);
pal_start = AV_RL16(&buf[12]);
pal_count = AV_RL16(&buf[14]);
buf += 16;
for (i=pal_start; i<pal_start+pal_count && i<AVPALETTE_COUNT && buf_end - buf >= 3; i++) {
s->palette[i] = 0xFFU << 24 | AV_RB24(buf);
buf += 3;
}
}
| 1threat |
Why media library not shown in wordpress? also image are not u ploded into the meida library : Media library is not displayed neither i can upload nor i can see the uploaded media files. So kindly help me out to this situation | 0debug |
Facebook's setReadPermissions() on Login Button deprecated - what to use instead? : <p>Im following Facebook's login tutorial for Android SDK and it seems <code>login_button.setReadPermissions()</code> is now deprecated:</p>
<p><a href="https://i.stack.imgur.com/zvmPq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zvmPq.png" alt="enter image description here"></a></p>
<p>What do I use as a replacement?</p>
| 0debug |
Unable To Run Unit Tests in Xcode 11: The run destination * is not valid for tests you have chosen to perform : <p>Pretty sure my tests were running fine before I updated from Xcode 10.3 to Xcode 11. Now when I try to run a test I get the following error. </p>
<p><a href="https://i.stack.imgur.com/OWRDI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/OWRDI.png" alt="Xcode Error Alert"></a>
The run destination iPhone 5s is not valid for tests you have chosen to perform.
Please select a run destination which supports the tests that you wish to perform.</p>
<p>As an experiment, I tried creating a brand new test target and running the example tests that it gives you and the error is the same. I've also tried with different simulators. </p>
| 0debug |
static void gen_spr_power8_fscr(CPUPPCState *env)
{
spr_register_kvm(env, SPR_FSCR, "FSCR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
KVM_REG_PPC_FSCR, 0x00000000);
}
| 1threat |
What is the meaning of the dollar sign "$" in R function()? : <p>Through learning <code>R</code>, I just came across the following code explained <a href="https://cran.r-project.org/doc/manuals/R-intro.html#Scope" rel="noreferrer">here</a>. </p>
<pre><code>open.account <- function(total) {
list(
deposit = function(amount) {
if(amount <= 0)
stop("Deposits must be positive!\n")
total <<- total + amount
cat(amount, "deposited. Your balance is", total, "\n\n")
},
withdraw = function(amount) {
if(amount > total)
stop("You don't have that much money!\n")
total <<- total - amount
cat(amount, "withdrawn. Your balance is", total, "\n\n")
},
balance = function() {
cat("Your balance is", total, "\n\n")
}
)
}
ross <- open.account(100)
robert <- open.account(200)
ross$withdraw(30)
ross$balance()
robert$balance()
ross$deposit(50)
ross$balance()
ross$withdraw(500)
</code></pre>
<p>What is the most of my interest about this code, learning the use of <code>"$"</code> dollar sign which refer to an specific <code>internal function</code> in <code>open.account()</code> function. I mean this part :</p>
<pre><code> ross$withdraw(30)
ross$balance()
robert$balance()
ross$deposit(50)
ross$balance()
ross$withdraw(500)
</code></pre>
<p><strong>Questions:</strong> <br></p>
<p>1- What is the meaning of the dollar sign <code>"$"</code> in <code>R</code> <code>function()</code> ? <br>
2- How to <strong>identify</strong> its attributes in functions, specially for the functions that you adopting from other (<em>i.e.</em> you did not write it)?<br>
I used the following script </p>
<pre><code>> grep("$", open.account())
[1] 1 2 3
</code></pre>
<p>but it is not useful I want to find a way to extract the name(s) of internal functions that can be refer by "$" without just by calling and searching the written code as <code>> open.account()</code> . <br>
For instance in case of <code>open.account()</code> I'd like to see something like this:</p>
<pre><code>$deposit
$withdraw
$balance
</code></pre>
<p>3- Is there any reference that I can read more about it? <br>
tnx!</p>
| 0debug |
How can I fix the following error? : <p>Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.</p>
<blockquote>
<p>com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/widget/ViewDragHelper$Callback.class</p>
</blockquote>
| 0debug |
static int parse_metadata_ext(DBEContext *s)
{
if (s->mtd_ext_size)
skip_input(s, s->key_present + s->mtd_ext_size + 1);
return 0;
}
| 1threat |
To remove a line starting and ending with different strings from a file : **@ IN NS ns1.riodomain.com.**
**@ IN A 192.175.3.255**
**@ IN MX 10 root@ns1.riodomain.com.**
**mail IN A 192.164.2.228**
**ns1 IN A 192.164.2.333**
After executing i need to get as follows
**@ IN A 192.168.1.213**
**@ IN MX 10 root@ns1.onedomain.com.**
**mail IN A 192.168.1.213**
**ns1 IN A 192.168.1.213**
I need to remove the first line with specific pattern.
Can anyone help? | 0debug |
int nbd_init(int fd, QIOChannelSocket *ioc, uint32_t flags, off_t size)
{
return -ENOTSUP;
}
| 1threat |
def bell_Number(n):
bell = [[0 for i in range(n+1)] for j in range(n+1)]
bell[0][0] = 1
for i in range(1, n+1):
bell[i][0] = bell[i-1][i-1]
for j in range(1, i+1):
bell[i][j] = bell[i-1][j-1] + bell[i][j-1]
return bell[n][0] | 0debug |
int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)
{
AVCodecContext *const avctx = h->avctx;
int err = 0;
h->mb_y = 0;
if (!in_setup && !h->droppable)
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
h->picture_structure == PICT_BOTTOM_FIELD);
if (in_setup || !(avctx->active_thread_type & FF_THREAD_FRAME)) {
if (!h->droppable) {
err = ff_h264_execute_ref_pic_marking(h);
h->poc.prev_poc_msb = h->poc.poc_msb;
h->poc.prev_poc_lsb = h->poc.poc_lsb;
}
h->poc.prev_frame_num_offset = h->poc.frame_num_offset;
h->poc.prev_frame_num = h->poc.frame_num;
}
if (avctx->hwaccel) {
if (avctx->hwaccel->end_frame(avctx) < 0)
av_log(avctx, AV_LOG_ERROR,
"hardware accelerator failed to decode picture\n");
}
#if CONFIG_ERROR_RESILIENCE
if (!FIELD_PICTURE(h) && h->enable_er) {
h264_set_erpic(&sl->er.cur_pic, h->cur_pic_ptr);
h264_set_erpic(&sl->er.last_pic,
sl->ref_count[0] ? sl->ref_list[0][0].parent : NULL);
h264_set_erpic(&sl->er.next_pic,
sl->ref_count[1] ? sl->ref_list[1][0].parent : NULL);
ff_er_frame_end(&sl->er);
}
#endif
emms_c();
h->current_slice = 0;
return err;
} | 1threat |
static int alloc_table(VLC *vlc, int size)
{
int index;
index = vlc->table_size;
vlc->table_size += size;
if (vlc->table_size > vlc->table_allocated) {
vlc->table_allocated += (1 << vlc->bits);
vlc->table = av_realloc(vlc->table,
sizeof(VLC_TYPE) * 2 * vlc->table_allocated);
if (!vlc->table)
return -1;
}
return index;
}
| 1threat |
static int decode_frame_mp3on4(AVCodecContext * avctx,
void *data, int *data_size,
const uint8_t * buf, int buf_size)
{
MP3On4DecodeContext *s = avctx->priv_data;
MPADecodeContext *m;
int len, out_size = 0;
uint32_t header;
OUT_INT *out_samples = data;
OUT_INT decoded_buf[MPA_FRAME_SIZE * MPA_MAX_CHANNELS];
OUT_INT *outptr, *bp;
int fsize;
int fr, i, j, n;
len = buf_size;
*data_size = 0;
if (buf_size < HEADER_SIZE)
return -1;
outptr = s->frames == 1 ? out_samples : decoded_buf;
for (fr = 0; fr < s->frames; fr++) {
fsize = AV_RB16(buf) >> 4;
fsize = FFMIN3(fsize, len, MPA_MAX_CODED_FRAME_SIZE);
m = s->mp3decctx[fr];
assert (m != NULL);
header = (AV_RB32(buf) & 0x000fffff) | s->syncword;
if (ff_mpa_check_header(header) < 0) {
*data_size = 0;
return buf_size;
}
ff_mpegaudio_decode_header(m, header);
out_size += mp_decode_frame(m, outptr, buf, fsize);
buf += fsize;
len -= fsize;
if(s->frames > 1) {
n = m->avctx->frame_size*m->nb_channels;
bp = out_samples + s->coff[fr];
if(m->nb_channels == 1) {
for(j = 0; j < n; j++) {
*bp = decoded_buf[j];
bp += avctx->channels;
}
} else {
for(j = 0; j < n; j++) {
bp[0] = decoded_buf[j++];
bp[1] = decoded_buf[j];
bp += avctx->channels;
}
}
}
}
avctx->sample_rate = s->mp3decctx[0]->sample_rate;
avctx->bit_rate = 0;
for (i = 0; i < s->frames; i++)
avctx->bit_rate += s->mp3decctx[i]->bit_rate;
*data_size = out_size;
return buf_size;
}
| 1threat |
Prometheus - add target specific label in static_configs : <p>I have job definition as follows:</p>
<pre><code> - job_name: 'test-name'
static_configs:
- targets: [ '192.168.1.1:9100', '192.168.1.1:9101', '192.168.1.1:9102' ]
labels:
group: 'development'
</code></pre>
<p>Is there any way to annotate targets with labels? For instance, I would like to add 'service-1' label to '192.168.1.1:9100', 'service-2' to '192.168.1.1:9101' etc.</p>
| 0debug |
How to sum specific array elements in python : I have a simple question, that I hope python can do easily for me.
I would like to use the sum function on an array.
The array is a little complicated however it has the following structure:
[[x1,y1,z1],[x2,y2,z2],..]
I want to sum up all the z elements
sum([[x1,y1,z1],[x2,y2,z2],..]) = z1+z2+...
Can I do this? | 0debug |
how to use variable(value) anywhere in function in javascript :
Below there if part of my javascript function. In that function, i am trying to use mathematical formula:
if(m == 1){
var intAmt = amt * (Math.pow((1 + rate / (12*100)), 12*period)) - amt;
var notPaid = Math.round(parseInt(amt) + intAmt,2);
}else if(status === "Not Paid"){
//dueAmt is tobe taken from below
var intAmt = dueAmt * (Math.pow((1 + rate / (12*100)), 12*period)) -dueAmt;
var notPaid = parseInt(dueAmt) + parseInt(amt) + intAmt;
}
//dueAmt is passed to the formula again n again
var dueAmt = notPaid;
the above part of code is javascript function is in for loop
I need to use the dueAmt variable again in if loop.But in else part of the loop it gives me undefined. | 0debug |
Why my HTML page is so small? : <p>i cant see why this website registration page is so small.
Im newbie to HTML.. Just want to help with UX.</p>
<p><a href="http://weelytics.com/app#register" rel="nofollow">http://weelytics.com/app#register</a></p>
<p>Thank you!</p>
| 0debug |
static int usb_parse(const char *cmdline)
{
int r;
r = usb_device_add(cmdline);
if (r < 0) {
fprintf(stderr, "qemu: could not add USB device '%s'\n", cmdline);
}
return r;
}
| 1threat |
I'm really confused on how to simplify boolean statements : I'm told to condense this in python in a more simplified form. Is it possible to do so in an orderly manner?
(not ((b or not c) and (not a or not c))) or (not (c or not (b and c))) or (a and not c) and (not a or (a and b and c) or (a and ((b and not c) or (not b))))
(not (a and not b) or (not c and b)) and (not b) or (not a and b and not c) or (a and not b)) | 0debug |
how to add my facebok webpage to an href link in wordpress header : Working with a developer from india that got his money and stopped coding. I have the following code: and want to add www.facebook.com/"mypage"
href="<?php echo get_option('facebook');?>"><i class="fab fa-facebook-f
This is on wordpress. Does anyone know where in this code i can add the /mypage? currently the link goes to facebook so i know its coded somewhere but i cant find it.
Ive tried to plug and chug but that didn't really help.
Thanks | 0debug |
What's the most minimalistic way to render "OK" in Elixir/Phoenix? : <p>In Rails you can render text directly, e.g. <code>render :text => 'OK'</code></p>
<p>Is there a shortcut in Elixir/Phoenix to render text directly, without having to define a template or layout?</p>
<p>The shortest way I found was this:</p>
<pre><code> defmodule MyApp.PageController do
use MyApp.Web, :controller
def index(conn, _params) do
# the file ok.html.eex contains just the string OK
render conn, "ok.html", layout: false
end
end
</code></pre>
<p>Is there a shorter way to render "OK", without having to provide the template file "ok.html"? </p>
| 0debug |
static int qemu_rdma_exchange_get_response(RDMAContext *rdma,
RDMAControlHeader *head, int expecting, int idx)
{
uint32_t byte_len;
int ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RECV_CONTROL + idx,
&byte_len);
if (ret < 0) {
fprintf(stderr, "rdma migration: recv polling control error!\n");
return ret;
}
network_to_control((void *) rdma->wr_data[idx].control);
memcpy(head, rdma->wr_data[idx].control, sizeof(RDMAControlHeader));
DDDPRINTF("CONTROL: %s receiving...\n", control_desc[expecting]);
if (expecting == RDMA_CONTROL_NONE) {
DDDPRINTF("Surprise: got %s (%d)\n",
control_desc[head->type], head->type);
} else if (head->type != expecting || head->type == RDMA_CONTROL_ERROR) {
fprintf(stderr, "Was expecting a %s (%d) control message"
", but got: %s (%d), length: %d\n",
control_desc[expecting], expecting,
control_desc[head->type], head->type, head->len);
return -EIO;
}
if (head->len > RDMA_CONTROL_MAX_BUFFER - sizeof(*head)) {
fprintf(stderr, "too long length: %d\n", head->len);
return -EINVAL;
}
if (sizeof(*head) + head->len != byte_len) {
fprintf(stderr, "Malformed length: %d byte_len %d\n",
head->len, byte_len);
return -EINVAL;
}
return 0;
}
| 1threat |
Python is not running : <p>I just bought a new notebook and I installed on it Python 3.6 and after restarting it, I tried to open python in CMD using "python" as I used to do in my old laptop but it does not take any effect.
Also I tried with PyCharm console but nothing...
Somebody knows what to do?</p>
<p>Greetings!</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.