problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
I want to access key value of "Store_name" from multiple dictionary , how do i access that? : {
"category": "string",
"top_bottom": {
"count": 0,
"data": [
{
"store_name": "string",
"store_id": "string",
"value": 0
}
],
"end_name": "string"
}
} | 0debug |
Move a variable and operate on it : <p>Is the following code safe?</p>
<pre><code>struct Foo {
Foo bar() { return *this; }
} foo;
foo = std::move(foo).bar(); // is this safe?
</code></pre>
<p>I'm wondering if calling methods on an rvalue is safe.</p>
| 0debug |
static int get_free_io_mem_idx(void)
{
int i;
for (i = 0; i<IO_MEM_NB_ENTRIES; i++)
if (!io_mem_used[i]) {
io_mem_used[i] = 1;
return i;
}
return -1;
}
| 1threat |
Dicrease the number of if : Hello I have this code using Python :
a = ["Porsche", "Google", "Facebook", "Mercedes", "Audi", "Twitter"]
if "Porsche" in a:
pass
if "Google" in a:
pass
if "Facebook" in a:
pass
if "Mercedes" in a:
pass
if "Audi" in a:
pass
if "Twitter" in a:
pass
But with this code I have no ideas how can I discrease the number of if. Is there a better way using Python to do ?
Thank you very much ! | 0debug |
static void qlist_destroy_obj(QObject *obj)
{
QList *qlist;
QListEntry *entry, *next_entry;
assert(obj != NULL);
qlist = qobject_to_qlist(obj);
QTAILQ_FOREACH_SAFE(entry, &qlist->head, next, next_entry) {
QTAILQ_REMOVE(&qlist->head, entry, next);
qobject_decref(entry->value);
g_free(entry);
}
g_free(qlist);
}
| 1threat |
Taking input from a text file line by line : <p>I have a text file in which the data is mentioned as below. </p>
<p>3<br>
4<br>
5<br>
6</p>
<p>Now i want to make a function in which i first take the value <strong>3</strong> and then make another function in which i need the value <strong>4</strong>. </p>
<p>I have this code which reads the file line by line. But my question is how should access the integers in each line and then store it in any variable so that i can use it in my function? </p>
<pre><code> try {
File f = new File("src/txt.txt");
BufferedReader b = new BufferedReader(new FileReader(f));
String readLine = "";
System.out.println("Reading file using Buffered Reader");
while ((readLine = b.readLine()) != null) {
System.out.println(readLine);
}
} catch (IOException e) {
e.printStackTrace();
}
</code></pre>
| 0debug |
How to make UILabel resize to fit text : <p>I have a UILabel that I have layed out in a storyboard centred in the view. It has some initial text "tap to login".</p>
<p>I am changing the value of the label to be the user's name once they have logged in. Once I do this, the label is no longer centered as the UILabel has not changed size.</p>
<p>How can I do this with autolayout in interface builder?</p>
| 0debug |
R:Hoe to arrange a data frame in order to display columns : i have the following code and data frames
CONSUMO<-data.frame( 9914282, 10375040, 10618441, 10547759)
INVERSION<-data.frame( 2860302
, 3017084, 29452363, 2917028)
IMPORTACIONES<-data.frame(3966992, 4183838,4244597,4274534)
EXPORTACIONES<-data.frame( 9914282, 4168771,4217287, 4427378)
PIB<-(CONSUMO+INVERSION+EXPORTACIONES-IMPORTACIONES)
PIB
## X9914282 X10375040 X10618441 X10547759
## 1 18721874 13377057 40043494 13617631
PERIODO<-data.frame(2011,2012,2013,2014)
I use this code to put all the data together
Tabla7<-data.frame(c(PERIODO,CONSUMO,INVERSION, EXPORTACIONES,
IMPORTACIONES, PIB))
it is displayed like this:
Tabla7
## X2011 X2012 X2013 X2014 X9914282 X10375040 X10618441 X10547759 X2860302
## 1 2011 2012 2013 2014 9914282 10375040 10618441 10547759 2860302
## X3017084 X29452363 X2917028 X9914282.1 X4168771 X4217287 X4427378
## 1 3017084 29452363 2917028 9914282 4168771 4217287 4427378
## X3966992 X4183838 X4244597 X4274534 X9914282.2 X10375040.1 X10618441.1
## 1 3966992 4183838 4244597 4274534 18721874 13377057 40043494
## X10547759.1
## 1 13617631
and my question is how to display the new data frame that looks like a table, so PERIODO CONSUMO INVERSION EXPORTACIONES IMPORTACIONES PIB quantities are displayed in different columns and its values shown vertically.
many thanks in advance.
Elle. | 0debug |
File manipulation using Python : <p>I recently started working in a lab that generate a lot of data. I need to manipulate files very often for various needs. I have learnt awk programming but it seems not enough for my work. I know python but not to that extent where I can comfortably work on files. Could anyone please suggest to me any book or online tutorial where I can find exclusively the use of Python on files. most of the python books do not dwell intensively on this subject.
thanks</p>
| 0debug |
how to resize a range to a specific column : I have data in a range from B2:P10.
If i select a cell (for example c3), what is the vba code to select right to column p (so c3:p3).
There is text in column q so i cant select right to the 'end'.
i've tried using offset and resize functions but everything i try is relative and doesnt stop at the absolute of column P | 0debug |
File.exists giving a null reference exception instead of returning false. c# : <pre><code>if(File.Exists(Application.persistentDataPath + "/users/" + Input.GetComponent<Text>().text + ".dat"))
</code></pre>
<p>This line always causes a null reference exception instead of returning false when it cannot find the file.</p>
| 0debug |
static void save_display_set(DVBSubContext *ctx)
{
DVBSubRegion *region;
DVBSubRegionDisplay *display;
DVBSubCLUT *clut;
uint32_t *clut_table;
int x_pos, y_pos, width, height;
int x, y, y_off, x_off;
uint32_t *pbuf;
char filename[32];
static int fileno_index = 0;
x_pos = -1;
y_pos = -1;
width = 0;
height = 0;
for (display = ctx->display_list; display != NULL; display = display->next) {
region = get_region(ctx, display->region_id);
if (x_pos == -1) {
x_pos = display->x_pos;
y_pos = display->y_pos;
width = region->width;
height = region->height;
} else {
if (display->x_pos < x_pos) {
width += (x_pos - display->x_pos);
x_pos = display->x_pos;
}
if (display->y_pos < y_pos) {
height += (y_pos - display->y_pos);
y_pos = display->y_pos;
}
if (display->x_pos + region->width > x_pos + width) {
width = display->x_pos + region->width - x_pos;
}
if (display->y_pos + region->height > y_pos + height) {
height = display->y_pos + region->height - y_pos;
}
}
}
if (x_pos >= 0) {
pbuf = av_malloc(width * height * 4);
for (display = ctx->display_list; display != NULL; display = display->next) {
region = get_region(ctx, display->region_id);
x_off = display->x_pos - x_pos;
y_off = display->y_pos - y_pos;
clut = get_clut(ctx, region->clut);
if (clut == 0)
clut = &default_clut;
switch (region->depth) {
case 2:
clut_table = clut->clut4;
break;
case 8:
clut_table = clut->clut256;
break;
case 4:
default:
clut_table = clut->clut16;
break;
}
for (y = 0; y < region->height; y++) {
for (x = 0; x < region->width; x++) {
pbuf[((y + y_off) * width) + x_off + x] =
clut_table[region->pbuf[y * region->width + x]];
}
}
}
snprintf(filename, 32, "dvbs.%d", fileno_index);
png_save2(filename, pbuf, width, height);
av_free(pbuf);
}
fileno_index++;
}
| 1threat |
static int expand(AVFilterContext *ctx, double *pz, int nb, double *coeffs)
{
int i;
coeffs[0] = 1.0;
coeffs[1] = 0.0;
for (i = 0; i < nb; i++) {
coeffs[2 * (i + 1) ] = 0.0;
coeffs[2 * (i + 1) + 1] = 0.0;
}
for (i = 0; i < nb; i++)
multiply(pz[2 * i], pz[2 * i + 1], nb, coeffs);
for (i = 0; i < nb + 1; i++) {
if (fabs(coeffs[2 * i + 1]) > DBL_EPSILON) {
av_log(ctx, AV_LOG_ERROR, "coeff: %lf of z^%d is not real; poles/zeros are not complex conjugates.\n",
coeffs[2 * i + i], i);
return AVERROR(EINVAL);
}
}
return 0;
}
| 1threat |
static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap)
{
struct video_data *s = s1->priv_data;
struct v4l2_input input;
struct v4l2_standard standard;
struct v4l2_streamparm streamparm = { 0 };
struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe;
int i;
streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
#if FF_API_FORMAT_PARAMETERS
if (ap->channel > 0)
s->channel = ap->channel;
#endif
memset (&input, 0, sizeof (input));
input.index = s->channel;
if (ioctl(s->fd, VIDIOC_ENUMINPUT, &input) < 0) {
av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl enum input failed:\n");
return AVERROR(EIO);
}
av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set input_id: %d, input: %s\n",
s->channel, input.name);
if (ioctl(s->fd, VIDIOC_S_INPUT, &input.index) < 0) {
av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl set input(%d) failed\n",
s->channel);
return AVERROR(EIO);
}
#if FF_API_FORMAT_PARAMETERS
if (ap->standard) {
av_freep(&s->standard);
s->standard = av_strdup(ap->standard);
}
#endif
if (s->standard) {
av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s\n",
s->standard);
memset (&standard, 0, sizeof (standard));
for(i=0;;i++) {
standard.index = i;
if (ioctl(s->fd, VIDIOC_ENUMSTD, &standard) < 0) {
av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl set standard(%s) failed\n",
s->standard);
return AVERROR(EIO);
}
if (!strcasecmp(standard.name, s->standard)) {
break;
}
}
av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s, id: %"PRIu64"\n",
s->standard, (uint64_t)standard.id);
if (ioctl(s->fd, VIDIOC_S_STD, &standard.id) < 0) {
av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl set standard(%s) failed\n",
s->standard);
return AVERROR(EIO);
}
}
av_freep(&s->standard);
if (ap->time_base.num && ap->time_base.den) {
av_log(s1, AV_LOG_DEBUG, "Setting time per frame to %d/%d\n",
ap->time_base.num, ap->time_base.den);
tpf->numerator = ap->time_base.num;
tpf->denominator = ap->time_base.den;
if (ioctl(s->fd, VIDIOC_S_PARM, &streamparm) != 0) {
av_log(s1, AV_LOG_ERROR,
"ioctl set time per frame(%d/%d) failed\n",
ap->time_base.num, ap->time_base.den);
return AVERROR(EIO);
}
if (ap->time_base.den != tpf->denominator ||
ap->time_base.num != tpf->numerator) {
av_log(s1, AV_LOG_INFO,
"The driver changed the time per frame from %d/%d to %d/%d\n",
ap->time_base.num, ap->time_base.den,
tpf->numerator, tpf->denominator);
}
} else {
if (ioctl(s->fd, VIDIOC_G_PARM, &streamparm) != 0) {
av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_PARM): %s\n", strerror(errno));
return AVERROR(errno);
}
}
ap->time_base.num = tpf->numerator;
ap->time_base.den = tpf->denominator;
return 0;
}
| 1threat |
How to get a folder's name with PHP? : <p>I want to get a folder's name with PHP and store it in a variable. But I don't know how to do that ! So my site directory is like this: </p>
<pre><code>---daygostar.com
---css
---js
---scss
---index.php
</code></pre>
<p>So here ,I would like to get <strong>daygostar.com</strong>'s name and store it at <strong>index.php</strong>. So how to do that ? </p>
| 0debug |
static void readline_completion(ReadLineState *rs)
{
int len, i, j, max_width, nb_cols, max_prefix;
char *cmdline;
rs->nb_completions = 0;
cmdline = g_malloc(rs->cmd_buf_index + 1);
memcpy(cmdline, rs->cmd_buf, rs->cmd_buf_index);
cmdline[rs->cmd_buf_index] = '\0';
rs->completion_finder(rs->mon, cmdline);
g_free(cmdline);
if (rs->nb_completions <= 0)
return;
if (rs->nb_completions == 1) {
len = strlen(rs->completions[0]);
for(i = rs->completion_index; i < len; i++) {
readline_insert_char(rs, rs->completions[0][i]);
}
if (len > 0 && rs->completions[0][len - 1] != '/')
readline_insert_char(rs, ' ');
} else {
monitor_printf(rs->mon, "\n");
max_width = 0;
max_prefix = 0;
for(i = 0; i < rs->nb_completions; i++) {
len = strlen(rs->completions[i]);
if (i==0) {
max_prefix = len;
} else {
if (len < max_prefix)
max_prefix = len;
for(j=0; j<max_prefix; j++) {
if (rs->completions[i][j] != rs->completions[0][j])
max_prefix = j;
}
}
if (len > max_width)
max_width = len;
}
if (max_prefix > 0)
for(i = rs->completion_index; i < max_prefix; i++) {
readline_insert_char(rs, rs->completions[0][i]);
}
max_width += 2;
if (max_width < 10)
max_width = 10;
else if (max_width > 80)
max_width = 80;
nb_cols = 80 / max_width;
j = 0;
for(i = 0; i < rs->nb_completions; i++) {
monitor_printf(rs->mon, "%-*s", max_width, rs->completions[i]);
if (++j == nb_cols || i == (rs->nb_completions - 1)) {
monitor_printf(rs->mon, "\n");
j = 0;
}
}
readline_show_prompt(rs);
}
for (i = 0; i < rs->nb_completions; i++) {
g_free(rs->completions[i]);
}
}
| 1threat |
static void qmp_output_type_uint64(Visitor *v, const char *name, uint64_t *obj,
Error **errp)
{
QmpOutputVisitor *qov = to_qov(v);
qmp_output_add(qov, name, qint_from_int(*obj));
}
| 1threat |
How can I print the name of variables in Python? : <p>I am trying to define the function which returns the name of variables.</p>
<pre><code>>>> def function(x):
... return(str(x))
...
>>> a = 1
>>> function(a)
'1'
</code></pre>
<p>I want to define the following function. How can I define it?</p>
<pre><code>>>> a = 1
>>> function(a)
a = 1
</code></pre>
| 0debug |
"Gradle Version 2.10 is required." Error : <p>As I've been using </p>
<pre><code>classpath 'com.android.tools.build:gradle:+'
</code></pre>
<p>In the <strong>build.gradle</strong> file, I got the following error since <strong>gradle version 2.10</strong> has been released.
The error is :</p>
<blockquote>
<p>Warning:Gradle version 2.10 is required. Current version is 2.8. If
using the gradle wrapper, try editing the distributionUrl in
C:\Users\blahblah\myproject\gradle\wrapper\gradle-wrapper.properties
to gradle-2.10-all.zip</p>
</blockquote>
<p>at first it looks easy to solve by the guide, but when I'd done the change, I got the error again. </p>
<p>I'm using <strong>Android Studio 2.0</strong> with the latest <strong>Android SDK Tools 24.4.1</strong> and <strong>Android SDK Build Tools 23.0.2</strong></p>
<p>I've even tried to download <strong>Gradle 2.10</strong> and put it manually on android-studio\gradle\ folder, but no luck.</p>
<p>Any help would be appreciated.</p>
| 0debug |
Exception in thread "main" java.lang.Error: Unresolved compilation : <pre><code>public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
String str = "https:\/\/www.facebook.com\/GaladariHotel";
str=str.replaceAll("\", "");
System.out.println(str);
}
}
</code></pre>
<p>I am using java as my programming language.
I want to print </p>
<pre><code>"https:\/\/www.facebook.com\/GaladariHotel"
</code></pre>
<p>as follows:</p>
<pre><code>"https://www.facebook.com/GaladariHotel"
</code></pre>
<p>Can somebody help me to correct my code?</p>
<p>Thanks in advance </p>
<p>my application requirement is actually to extract the data from the following link
<a href="http://www.mocky.io/v2/5700dbc8120000ad1f7709ca" rel="nofollow">http://www.mocky.io/v2/5700dbc8120000ad1f7709ca</a></p>
| 0debug |
"expected ')' before textIn" and "expected constructor, destructor or type conversion before '(' token" : <p>I've looked through multiple threads, but they are either completely different problems or people not knowing how to create constructors. I get the titles first error in my header, and the second error in the cpp file itself.</p>
<p>MenuItem.h</p>
<pre><code>#include "SFML/Graphics.hpp"
#include <string>
#ifndef MENUITEM_H
#define MENUITEM_H
class MenuItem
{
public:
//Below constructor creates the first error
MenuItem(string textIn="", float x, float y, bool highlightedDefault=false);
bool highlighted;
sf::Text text;
};
#endif // MENUITEM_H
</code></pre>
<p>MenuItem.cpp</p>
<pre><code>#include "MenuItem.h"
MenuItem::MenuItem(string textIn, float x, float y, bool highlightedDefault)
{
...
}
</code></pre>
| 0debug |
static int curl_open(BlockDriverState *bs, const char *filename, int flags)
{
BDRVCURLState *s = bs->opaque;
CURLState *state = NULL;
double d;
#define RA_OPTSTR ":readahead="
char *file;
char *ra;
const char *ra_val;
int parse_state = 0;
static int inited = 0;
file = strdup(filename);
s->readahead_size = READ_AHEAD_SIZE;
ra = file + strlen(file) - 1;
while (ra >= file) {
if (parse_state == 0) {
if (*ra == ':')
parse_state++;
else
break;
} else if (parse_state == 1) {
if (*ra > '9' || *ra < '0') {
char *opt_start = ra - strlen(RA_OPTSTR) + 1;
if (opt_start > file &&
strncmp(opt_start, RA_OPTSTR, strlen(RA_OPTSTR)) == 0) {
ra_val = ra + 1;
ra -= strlen(RA_OPTSTR) - 1;
*ra = '\0';
s->readahead_size = atoi(ra_val);
break;
} else {
break;
}
}
}
ra--;
}
if ((s->readahead_size & 0x1ff) != 0) {
fprintf(stderr, "HTTP_READAHEAD_SIZE %Zd is not a multiple of 512\n",
s->readahead_size);
goto out_noclean;
}
if (!inited) {
curl_global_init(CURL_GLOBAL_ALL);
inited = 1;
}
DPRINTF("CURL: Opening %s\n", file);
s->url = file;
state = curl_init_state(s);
if (!state)
goto out_noclean;
curl_easy_setopt(state->curl, CURLOPT_NOBODY, 1);
curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION, (void *)curl_size_cb);
if (curl_easy_perform(state->curl))
goto out;
curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d);
curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION, (void *)curl_read_cb);
curl_easy_setopt(state->curl, CURLOPT_NOBODY, 0);
if (d)
s->len = (size_t)d;
else if(!s->len)
goto out;
DPRINTF("CURL: Size = %lld\n", (long long)s->len);
curl_clean_state(state);
curl_easy_cleanup(state->curl);
state->curl = NULL;
s->multi = curl_multi_init();
curl_multi_setopt( s->multi, CURLMOPT_SOCKETDATA, s);
curl_multi_setopt( s->multi, CURLMOPT_SOCKETFUNCTION, curl_sock_cb );
curl_multi_do(s);
return 0;
out:
fprintf(stderr, "CURL: Error opening file: %s\n", state->errmsg);
curl_easy_cleanup(state->curl);
state->curl = NULL;
out_noclean:
qemu_free(file);
return -EINVAL;
}
| 1threat |
php link doesn't work correctly : I'm having an imagehover on a php page and that image should link to a certain url.
if(file_exists($actionsloaded))
echo '<a href=\"index.php\"><img src="/wp-content/uploads/2017/07/'.$image_on.'" onmouseover="this.src=\'/wp-content/uploads/2017/07/'.$image_off.'\';" onmouseout="this.src=\'/wp-content/uploads/2017/07/'.$image_on.'\';"/></a>';
else
Problem is, when I click the link it goes to url.com/"index.php/"
any ideas what might be wrong with it?
| 0debug |
Rails 5.1 run system tests and normal tests with one command : <p>In Rails 5.1, you can do <code>bin/rails test</code> to run normal tests, and <code>bin/rails test:system</code>. What is the Rails sanctioned way of running both at the same time?</p>
| 0debug |
static void vscsi_inquiry_no_target(VSCSIState *s, vscsi_req *req)
{
uint8_t *cdb = req->iu.srp.cmd.cdb;
uint8_t resp_data[36];
int rc, len, alen;
if ((cdb[1] & 0x01) || (cdb[1] & 0x01) || cdb[2] != 0) {
vscsi_makeup_sense(s, req, ILLEGAL_REQUEST, 0x24, 0);
vscsi_send_rsp(s, req, CHECK_CONDITION, 0, 0);
return;
}
alen = cdb[3];
alen = (alen << 8) | cdb[4];
len = MIN(alen, 36);
memset(resp_data, 0, 36);
resp_data[0] = 0x7f;
resp_data[2] = 0x06;
resp_data[3] = 0x02;
resp_data[4] = 36 - 5;
resp_data[7] = 0x10;
memcpy(&resp_data[16], "QEMU EMPTY ", 16);
memcpy(&resp_data[8], "QEMU ", 8);
req->writing = 0;
vscsi_preprocess_desc(req);
rc = vscsi_srp_transfer_data(s, req, 0, resp_data, len);
if (rc < 0) {
vscsi_makeup_sense(s, req, HARDWARE_ERROR, 0, 0);
vscsi_send_rsp(s, req, CHECK_CONDITION, 0, 0);
} else {
vscsi_send_rsp(s, req, 0, 36 - rc, 0);
}
}
| 1threat |
static int ftp_retrieve(FTPContext *s)
{
char command[CONTROL_BUFFER_SIZE];
const int retr_codes[] = {150, 550, 0};
snprintf(command, sizeof(command), "RETR %s\r\n", s->path);
if (ftp_send_command(s, command, retr_codes, NULL) != 150)
return AVERROR(EIO);
s->state = DOWNLOADING;
return 0;
}
| 1threat |
Python Selenium losses login details : I'm trying to extract past one year prices from (https://www.deribit.com/prinx_chart).
I've tried several ways to do that, however I always end up losing login details and unable to download the file.
Here's my recent code:
```from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
options = webdriver.ChromeOptions()
preferences = {"download.default_directory" : "D:\scrapping",
"safebrowsing.enabled": False}
options.add_experimental_option("prefs", preferences)
driver = webdriver.Chrome(options = options,
executable_path = 'D:\\chromedriver.exe')
driver.maximize_window()
driver.get('https://www.deribit.com/')
driver.find_element_by_xpath("""//input[@type = "email"]""").send_keys(************).click()
driver.find_element_by_xpath("""//input[@type = "password"]""").send_keys(*********).click()
driver.find_element_by_name("go").click()
driver.get('https://www.deribit.com/prinx_chart')
driver.implicitly_wait(20)
element1 = driver.find_element_by_xpath("""//button[@title="1 year"]""")
element2 = driver.find_element_by_xpath("""//div[@class="pull-right context-menu btn-group"]""")
element3 = driver.find_element_by_xpath("""//*[@id="chartmenu"]/li/a""")
hoverover = ActionChains(driver).move_to_element(element1).move_to_element(
element2).move_to_element(element3).click().perform()
```
As I said, unable to download the file and get an error which says not signed in. Where am I wrong here? Please help! | 0debug |
How to test load on Set of difrent api : i am doing load testing in Soap ui and working on cab booking application so set api like this for example Usersingin ,GetlocationDetails,bookcab,getDriverDetails,acceptRide and completeRide so on. it will become on loop(on completing of one ride successfully ) so this seniors may happened like 1000 or 10000 times.
the question is how to interlink api do it a single entity and perform load test using soap ui, jmeter or any load testing tools,or by coding please help me sort out problem with simple demo
thanks | 0debug |
AspNetCore:2.1 not found : <p>Created a new .NET CORE 2.1 (preview) web app. Running it in local docker with Linux container
I am getting compiler error:</p>
<p>Error Building blobtest<br>
Service 'blobtest' failed to build: manifest for microsoft/aspnetcore:2.1 not found. </p>
<p>My dotnetversion<br>
C:\WINDOWS\system32>dotnet --version
2.1.300-preview2-008530</p>
| 0debug |
SQL Database - Finding the previous value in a table : I have table `queue` with values.
`id name
1 apple
2 mango
3 banana`(I assumed this name,dont remember it exactly)
But I accidentally changed it to be
`id name
1 apple
2 mango
3 John`
So I reverted it back to <br>
`id name
1 apple
2 mango
3 banana`
But now came to know that name is not banana for id =3. How can I know what used to be there before I changed it? | 0debug |
Getting country name from country code : <p>I have found the answer for this for objective-c but Im having a hard time doing this in swift. </p>
<p>I have used this to get the country code for the current location:</p>
<pre><code> let countryCode = NSLocale.currentLocale().objectForKey(NSLocaleCountryCode) as! String
print(countryCode)
// printing for example US
</code></pre>
<p>But how do I convert this country code to a country name, like in this example converting "US" to "United States"?</p>
| 0debug |
When can I use explicit operator bool without a cast? : <p>My class has an explicit conversion to bool:</p>
<pre><code>struct T {
explicit operator bool() const { return true; }
};
</code></pre>
<p>and I have an instance of it:</p>
<pre><code>T t;
</code></pre>
<p>To assign it to a variable of type <code>bool</code>, I need to write a cast:</p>
<pre><code>bool b = static_cast<bool>(t);
bool b = bool(t);
bool b(t); // converting initialiser
bool b{static_cast<bool>(t)};
</code></pre>
<p>I know that I can use my type directly in a conditional without a cast, despite the <code>explicit</code> qualifier:</p>
<pre><code>if (t)
/* statement */;
</code></pre>
<p>Where else can I use <code>t</code> as a <code>bool</code> without a cast?</p>
| 0debug |
How to get the file name having more then one extension in c# : <p>I am having file name as below.
i need only sample.xml as result.
sample.xml.jued.783737377365474.da</p>
<p>Please help me on this. thanks in Advance</p>
| 0debug |
How do i return return a value even if there's a mismatch in case? : How do i return return a value even if there's a mismatch in case?
For example i have an array with the string "alex". A user searches through the array and types "AlEx" by accident. How do i return the original value "alex"? I am currently using C#. | 0debug |
create an array till any particular number in reactjs : <p>I am a beginner in React js and trying to do some operations.</p>
<p>I want to create an array till the length of any array (particular number)
suppose my array length is 10 , then the array should be</p>
<p>my state variables-</p>
<pre><code> this.state{
length = 10,
length_array= []
}
handleClick = () =>{
this.setState{
length_array:[1,2,3,4,5,6,7,8,9,10]
}}
</code></pre>
<p>I want to display this array in my table header</p>
<pre><code><Table>
<tr>
<th>
this.state.length_array.map((item, key) =>
<th>{item.name}</th>
);
</th>
</tr>
</Table>
</code></pre>
<p>Thanks.</p>
| 0debug |
What's the difference between tsc (TypeScript compiler) and ts-node? : <p>I'm very confused about the difference between <code>tsc</code> and <code>ts-node</code>. I'm learning TypeScript and I usually transpile server <code>.ts</code> files with <code>tsc</code> command.</p>
<p>Now, I'm approaching <a href="https://nestjs.com/" rel="noreferrer">nestjs</a> framework, and I see that it uses <code>ts-node</code>.</p>
<p>So what's the difference between the two? Which one should I use?</p>
| 0debug |
Update TextBox wile in Background Worker : **Unable to update textbox value while in background worker,
value to be updated is sum of column("TaxableValue") of a datatable created inside background worker.**
On Button Click following event is raised
Private Sub btnCalcTax_Click(sender As Object, e As EventArgs) Handles btnCalcTax.Click
BackgroundWorker1.RunWorkerAsync()
End Sub
I have created a function to calculate TAX.
Public Function TAXCALC
Dim taxcalcdt As New DataTable
'Code For Calculating Tax Begins.
......
'Code For Calculating Tax End.
TextBox1.Text = taxcalcdt.Compute("Sum(TaxableValue)", String.Empty).ToString
End Sub
I am unable to update sum of column("TaxableValue") to Textbox1.text
Code For BackgroundWorker_DoWork is
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
TAXCALC()
End Sub
| 0debug |
When can a base class have a different layout than the corresponding complete object type? : <p>GCC and Clang do not perform C++17’s guaranteed copy elision when a base class constructor is called; see <a href="https://stackoverflow.com/questions/46065704/why-isnt-rvo-applied-to-base-class-subobject-initialization">this question</a> and the corresponding <a href="https://bugs.llvm.org/show_bug.cgi?id=34516" rel="noreferrer">Clang bug report</a> for details.</p>
<p>In response to the bug report, <a href="https://bugs.llvm.org/show_bug.cgi?id=34516#c1" rel="noreferrer">Richard Smith states</a>:</p>
<blockquote>
<p>This is a defect in the standard wording. Copy elision cannot be guaranteed when initializing a base class subobject, because base classes can have different layout than the corresponding complete object type.</p>
</blockquote>
<p>Under what circumstances can a base class have a “different layout than the corresponding complete object type” in a way that makes guaranteed copy elision impossible? Is there a concrete example that illustrates this?</p>
| 0debug |
static inline int ultrasparc_tag_match(SparcTLBEntry *tlb,
uint64_t address, uint64_t context,
target_phys_addr_t *physical,
int is_nucleus)
{
uint64_t mask;
switch ((tlb->tte >> 61) & 3) {
default:
case 0x0:
mask = 0xffffffffffffe000ULL;
break;
case 0x1:
mask = 0xffffffffffff0000ULL;
break;
case 0x2:
mask = 0xfffffffffff80000ULL;
break;
case 0x3:
mask = 0xffffffffffc00000ULL;
break;
}
if (TTE_IS_VALID(tlb->tte) &&
((is_nucleus && compare_masked(0, tlb->tag, 0x1fff))
|| TTE_IS_GLOBAL(tlb->tte) || compare_masked(context, tlb->tag, 0x1fff))
&& compare_masked(address, tlb->tag, mask))
{
*physical = ((tlb->tte & mask) | (address & ~mask)) & 0x1ffffffe000ULL;
return 1;
}
return 0;
}
| 1threat |
scala - convert tuplen of long datatype to Array[Long] : <p>I get the counts of dataframe columns from spark to scala variable as below</p>
<pre><code>scala> col_counts
res38: (Long, Long, Long) = (3,3,0)
scala>
</code></pre>
<p>Now, I want to convert this to Array(3,3,0). I'm doing a roundabout way like</p>
<pre><code>scala> col_counts.toString.replaceAll("""\)|\(""","").split(",")
res47: Array[String] = Array(3, 3, 0)
scala>
</code></pre>
<p>But it looks ugly. Is there an elegant way of getting it? I'm looking for a generic solution to convert any n - Long tuple to Array. </p>
| 0debug |
asp.net login on line : Hello at the end of this i get an syntax error, but i cant figure out what causes the error
SqlDataAdapter sda = new SqlDataAdapter("Select * From bruker Where Brukernavn='" + Textbox1.Text + "' and Passord='" + TextBox2.Text"");
| 0debug |
document.getElementById('input').innerHTML = user_input; | 1threat |
My code seems to stop executing beyond a particular line with no errors. : I haven't used any break statement but my code isn't executing beyond a line. I am using the same loop in a different way 5 times in the same code with each loop running more than 1000 times. Could this be a reason?
` ActiveCell.FormulaR1C1 = "1 Month"
'The above line executes but beyond this things are working
i = x
j = x
Dim t3 As Date, t4 As Date, temp As Integer
Dim r As Single
temp = 0
Do Until temp = 1
t1 = "=DAY(dt(j))"
t2 = "=DAY(dt(i))"
t3 = "=MONTH(dt(j))"
t4 = "=MONTH(dt(i))"
If (t2 < t1) Then ' condition 1
If (t3 <> t4) Then ' condition 2
upf(0) = "=COUNTIF(chp(i-1):chp(j),"">0"")" 'counting +ve numbers
dwf(0) = "=COUNTIF(chp(i-1):chp(j),""<0"")" 'counting -ve numbers
upb(0) = "=COUNTIF(chb(i-1):chb(j),"">0"")"
dwb(0) = "=COUNTIF(chb(i-1):chb(j),""<0"")"
std(0) = "=STDEV(price(i-1):price(j))" 'standard deviation
sdb(0) = "=STDEV(bch(i-1):bch(j))"
mx = "=MAX(price(i-1):price(j))"
mn = "=MIN(price(i-1):price(j))"
ActiveCell.FormulaR1C1 = mn / mx - 1 'calculating maximum drawdown
ActiveCell.Offset(0, 1).Select
mx = "=MAX(bch(i-1):bch(j))"
mn = "=MIN(bch(i-1):bch(j))"
ActiveCell.FormulaR1C1 = mn / mx - 1
temp = 1
End If
End If
Loop` 'end loop | 0debug |
static void test_tco_ticks_counter(void)
{
TestData d;
uint16_t ticks = TCO_SECS_TO_TICKS(8);
uint16_t rld;
d.args = NULL;
d.noreboot = true;
test_init(&d);
stop_tco(&d);
clear_tco_status(&d);
reset_on_second_timeout(false);
set_tco_timeout(&d, ticks);
load_tco(&d);
start_tco(&d);
do {
rld = qpci_io_readw(d.dev, d.tco_io_bar, TCO_RLD) & TCO_RLD_MASK;
g_assert_cmpint(rld, ==, ticks);
clock_step(TCO_TICK_NSEC);
ticks--;
} while (!(qpci_io_readw(d.dev, d.tco_io_bar, TCO1_STS) & TCO_TIMEOUT));
stop_tco(&d);
qtest_end();
}
| 1threat |
static inline void RET_STOP (DisasContext *ctx)
{
gen_update_nip(ctx, ctx->nip);
ctx->exception = EXCP_MTMSR;
}
| 1threat |
How this result is 2? csharp : Int x = 1
While(x++<5)
{if (x % 2 == 0)
x += 2
}
Question is, how many times the following loop will executed?
As I can see the 1st x equals to 1 ,2nd x equals to 2 ,3rd x equals to 4 , I thought it will execute 3 times,but why the answer is 2 times?
Can someone explain to me pls,sorry for my bad English. | 0debug |
React-Redux - No reducer provided for key "coins" : <p>Not sure why I'm getting the following errors.</p>
<p>I'm just setting up my store, actions and reducers, I haven't called dispatch on anything yet.</p>
<h3>Expected</h3>
<p>App runs fine, Redux state is not updated</p>
<h3>Results</h3>
<p><a href="https://i.stack.imgur.com/iGupu.png" rel="noreferrer"><img src="https://i.stack.imgur.com/iGupu.png" alt="enter image description here"></a></p>
src/index.js
<pre><code>import React from 'react'
import ReactDOM from 'react-dom'
import { createStore, applyMiddleware, compose } from 'redux'
import { Provider } from 'react-redux'
import thunk from 'redux-thunk'
import reducer from './reducer'
import App from './App'
import css from './coinhover.scss'
const element = document.getElementById('coinhover');
const store = createStore(reducer, compose(
applyMiddleware(thunk),
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
));
ReactDOM.render(
<Provider store={ store }>
<App />
</Provider>, element);
</code></pre>
src/reducer/index.js
<pre><code>import { combineReducers } from 'redux'
import { coins } from './coins'
export default combineReducers({
coins
});
</code></pre>
src/reducer/actions/coins.js
<pre><code>import * as api from '../../services/api'
import { storage, addToPortfolio } from '../../services/coinFactory'
export const ADD_COIN = 'ADD_COIN'
export function getCoin(coin) {
return dispatch => {
api.getCoin(coin)
.then((res_coin) => addToPortfolio(res_coin))
.then((portfolio) => dispatch(updatePortfolio(portfolio)));
}
}
export function updatePortfolio(portfolio) {
return {
type: ADD_COIN,
portfolio
}
}
</code></pre>
finally src/reducer/coins/index.js
<pre><code>import { ADD_COIN } from './actions'
const initialState = [];
export default (state = initialState, action) => {
switch(action.type) {
case ADD_COIN:
return action.portfolio;
default:
return state;
}
}
</code></pre>
| 0debug |
how can I pass the array data coming from api to one ViewController to another ViewController? : I'm new in iOS
I'm trying to pass my array data to another view controller through prepare segue to the another viewcontroller.
```Swift
class FirstVc {
var location = [Any]()
self.clientrequest.request(url: "http://api.details.in/api/users/alllocation", method: .GET, completion: {
res , err in
let decode = try! JSONDecoder().decode(SelectLocation.self, from:json)
self.location = decode.states
//I'm getting all locations here
print(self.location)
})
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.destination is SecondVc
{
let vc = segue.destination as? SecondVc
//here I'm assigning the variable
vc?.mineSpillere2 = self.location
}
}
class SecondVc{
@IBOutlet weak var selectState: UILabel!
var mineSpillere2 = [Any]()
override func viewDidLoad() {
selectState.text = mineSpillere2 as? String
}
}
``` | 0debug |
VBA EXCEL: Can I copy Userform's code to a txt file? : <p>I would like to copy the code from a userform using a macro, but I couldn't find any way to do so, help, please.</p>
| 0debug |
sizeof operator gives varied results for float : <pre><code>float f=124.50;
cout<<sizeof(f);
cout<<sizeof(124.50);
</code></pre>
<p>Both the statements give different results.But works for int and char. why does it differ for float? </p>
| 0debug |
How do I generate the first 12 numbers in the sequence 1, 1, 1, 2, 2, 3, 4, 5, 7, 9 using a while loop? : <p>I have figured out the formula to work the sequence out which is the use the each number in the sequence uses the previous previous previous number + the previous previous number for example to get the number 4 you use the previous x3 number which is the first 2 in the sequence plus the previous x2 number which is the second 2 in the sequence. I understand that I have to use 4 variables and then swap the number accordingly in the loop but i cant quite figure out how to do so.
Here is what I have so far.</p>
<pre><code> System.out.print("Loop for the first 12 terms of sequence 1, 1, 1, 2, 2, 3, 4, 5, 7, 9\n");
int p0, p1, p2, p3, c;// c in control p is num is sequence.
c=0;
p0=1;
p1=1;
p2=1;
p3=p0+p1;
while(c<=12){
System.out.print(p0+","+p1+","+p2+","+p3+",");
c++;
}
</code></pre>
<p>which just gives me the first 4 numbers of the sequence 12 times. Do I have to use an entirely different while loop for the next numbers or can I do it in the same loop?
any help appreciated. Thank you.</p>
| 0debug |
webpack: Cannot read property 'match' of undefined : <p>I have installed webpack (Symfony encore) using npm as follows:</p>
<p><code>sudo npm install -g @symfony/webpack-encore --save-dev</code></p>
<p>I ran this from <code>/var/www/project</code> </p>
<p>I was required to install globally due to issues with package managers and shared folders when dealing with Windows host / Linux guest.</p>
<p>I cannot install webpack (node_modules) in the same directory (or under it) as the <code>/var/www/project</code> </p>
<p>So my package.json file looks like this:</p>
<pre><code>{
"name": "test",
"version": "1.0.0",
"description": "This is a test",
"main": "index.js",
"dependencies": {},
"devDependencies": {
"@symfony/webpack-encore": "^0.15.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Alex",
"license": "MIT"
}
</code></pre>
<p>I run encore from <code>/var/www/project</code> using this</p>
<p><code>/usr/local/bin/encore dev</code></p>
<p>I get this lovely output in return:</p>
<pre><code>Running webpack ...
TypeError: Cannot read property 'match' of undefined
- index.js:125 parse
[lib]/[webpack-encore]/[yargs-parser]/index.js:125:12
- index.js:761 Function.Parser.detailed
[lib]/[webpack-encore]/[yargs-parser]/index.js:761:10
- yargs.js:938 Object.Yargs.self._parseArgs
[lib]/[webpack-encore]/[yargs]/yargs.js:938:27
- yargs.js:927 Object.get [as argv]
[lib]/[webpack-encore]/[yargs]/yargs.js:927:19
- index.js:725 Object.configureRuntimeEnvironment
[lib]/[@symfony]/webpack-encore/index.js:725:54
- index.js:770 Proxy.parameters
[lib]/[@symfony]/webpack-encore/index.js:770:45
- webpack.config.js:3 Object.<anonymous>
/var/www/project/webpack.config.js:3:8
- module.js:573 Module._compile
module.js:573:30
- module.js:584 Object.Module._extensions..js
module.js:584:10
- module.js:507 Module.load
module.js:507:32
</code></pre>
<p>What am I missing?</p>
| 0debug |
DVDemuxContext* avpriv_dv_init_demux(AVFormatContext *s)
{
DVDemuxContext *c;
c = av_mallocz(sizeof(DVDemuxContext));
if (!c)
return NULL;
c->vst = avformat_new_stream(s, NULL);
if (!c->vst) {
av_free(c);
return NULL;
}
c->sys = NULL;
c->fctx = s;
memset(c->ast, 0, sizeof(c->ast));
c->ach = 0;
c->frames = 0;
c->abytes = 0;
c->vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
c->vst->codec->codec_id = CODEC_ID_DVVIDEO;
c->vst->codec->bit_rate = 25000000;
c->vst->start_time = 0;
return c;
}
| 1threat |
static int usb_hid_initfn(USBDevice *dev, int kind)
{
USBHIDState *us = DO_UPCAST(USBHIDState, dev, dev);
usb_desc_init(dev);
hid_init(&us->hid, kind, usb_hid_changed);
us->changed = 1;
return 0;
}
| 1threat |
Como utilizar nominatim.openstreetmap.org/search para limitar os resultados a 1KM ao meu redor? : Ao usar https://nominatim.openstreetmap.org/search?format=xml&q=bahamas%20ponte%20nova&addressdetails=1&limit=3
eu tenho exatamente o resultado que eu quero.
Mas se eu excluir o nome da minha cidade Ponte Nova, no resultado vem até referências da Espanha, mas não vem nenhum resultado da minha cidade.
Como faço para que os resultados se concentrem em um raio determinado? | 0debug |
uint16_t virtio_get_cylinders(void)
{
return blk_cfg.geometry.cylinders;
}
| 1threat |
static int opt_output_file(const char *opt, const char *filename)
{
AVFormatContext *oc;
int i, err;
AVOutputFormat *file_oformat;
OutputStream *ost;
InputStream *ist;
if (!strcmp(filename, "-"))
filename = "pipe:";
err = avformat_alloc_output_context2(&oc, NULL, last_asked_format, filename);
last_asked_format = NULL;
if (!oc) {
print_error(filename, err);
exit_program(1);
}
file_oformat= oc->oformat;
if (!strcmp(file_oformat->name, "ffm") &&
av_strstart(filename, "http:", NULL)) {
int err = read_ffserver_streams(oc, filename);
if (err < 0) {
print_error(filename, err);
exit_program(1);
}
} else if (!nb_stream_maps) {
#define NEW_STREAM(type, index)\
if (index >= 0) {\
ost = new_ ## type ## _stream(oc);\
ost->source_index = index;\
ost->sync_ist = &input_streams[index];\
input_streams[index].discard = 0;\
}
if (!video_disable && oc->oformat->video_codec != CODEC_ID_NONE) {
int area = 0, idx = -1;
for (i = 0; i < nb_input_streams; i++) {
ist = &input_streams[i];
if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
ist->st->codec->width * ist->st->codec->height > area) {
area = ist->st->codec->width * ist->st->codec->height;
idx = i;
}
}
NEW_STREAM(video, idx);
}
if (!audio_disable && oc->oformat->audio_codec != CODEC_ID_NONE) {
int channels = 0, idx = -1;
for (i = 0; i < nb_input_streams; i++) {
ist = &input_streams[i];
if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
ist->st->codec->channels > channels) {
channels = ist->st->codec->channels;
idx = i;
}
}
NEW_STREAM(audio, idx);
}
if (!subtitle_disable && oc->oformat->subtitle_codec != CODEC_ID_NONE) {
for (i = 0; i < nb_input_streams; i++)
if (input_streams[i].st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
NEW_STREAM(subtitle, i);
break;
}
}
} else {
for (i = 0; i < nb_stream_maps; i++) {
StreamMap *map = &stream_maps[i];
if (map->disabled)
continue;
ist = &input_streams[input_files[map->file_index].ist_index + map->stream_index];
switch (ist->st->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO: ost = new_video_stream(oc); break;
case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream(oc); break;
case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream(oc); break;
case AVMEDIA_TYPE_DATA: ost = new_data_stream(oc); break;
default:
av_log(NULL, AV_LOG_ERROR, "Cannot map stream #%d.%d - unsupported type.\n",
map->file_index, map->stream_index);
exit_program(1);
}
ost->source_index = input_files[map->file_index].ist_index + map->stream_index;
ost->sync_ist = &input_streams[input_files[map->sync_file_index].ist_index +
map->sync_stream_index];
ist->discard = 0;
}
}
av_dict_copy(&oc->metadata, metadata, 0);
av_dict_free(&metadata);
if (nb_output_files == MAX_FILES)
exit_program(1);
output_files = grow_array(output_files, sizeof(*output_files), &nb_output_files, nb_output_files + 1);
output_files[nb_output_files - 1].ctx = oc;
output_files[nb_output_files - 1].ost_index = nb_output_streams - oc->nb_streams;
av_dict_copy(&output_files[nb_output_files - 1].opts, format_opts, 0);
if (oc->oformat->flags & AVFMT_NEEDNUMBER) {
if (!av_filename_number_test(oc->filename)) {
print_error(oc->filename, AVERROR(EINVAL));
exit_program(1);
}
}
if (!(oc->oformat->flags & AVFMT_NOFILE)) {
if (!file_overwrite &&
(strchr(filename, ':') == NULL ||
filename[1] == ':' ||
av_strstart(filename, "file:", NULL))) {
if (avio_check(filename, 0) == 0) {
if (!using_stdin) {
fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename);
fflush(stderr);
if (!read_yesno()) {
fprintf(stderr, "Not overwriting - exiting\n");
exit_program(1);
}
}
else {
fprintf(stderr,"File '%s' already exists. Exiting.\n", filename);
exit_program(1);
}
}
}
if ((err = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE)) < 0) {
print_error(filename, err);
exit_program(1);
}
}
oc->preload= (int)(mux_preload*AV_TIME_BASE);
oc->max_delay= (int)(mux_max_delay*AV_TIME_BASE);
if (loop_output >= 0) {
av_log(NULL, AV_LOG_WARNING, "-loop_output is deprecated, use -loop\n");
oc->loop_output = loop_output;
}
if (chapters_input_file >= nb_input_files) {
if (chapters_input_file == INT_MAX) {
chapters_input_file = -1;
for (i = 0; i < nb_input_files; i++)
if (input_files[i].ctx->nb_chapters) {
chapters_input_file = i;
break;
}
} else {
av_log(NULL, AV_LOG_ERROR, "Invalid input file index %d in chapter mapping.\n",
chapters_input_file);
exit_program(1);
}
}
if (chapters_input_file >= 0)
copy_chapters(chapters_input_file, nb_output_files - 1);
for (i = 0; i < nb_meta_data_maps; i++) {
AVFormatContext *files[2];
AVDictionary **meta[2];
int j;
#define METADATA_CHECK_INDEX(index, nb_elems, desc)\
if ((index) < 0 || (index) >= (nb_elems)) {\
av_log(NULL, AV_LOG_ERROR, "Invalid %s index %d while processing metadata maps\n",\
(desc), (index));\
exit_program(1);\
}
int in_file_index = meta_data_maps[i][1].file;
if (in_file_index < 0)
continue;
METADATA_CHECK_INDEX(in_file_index, nb_input_files, "input file")
files[0] = oc;
files[1] = input_files[in_file_index].ctx;
for (j = 0; j < 2; j++) {
MetadataMap *map = &meta_data_maps[i][j];
switch (map->type) {
case 'g':
meta[j] = &files[j]->metadata;
break;
case 's':
METADATA_CHECK_INDEX(map->index, files[j]->nb_streams, "stream")
meta[j] = &files[j]->streams[map->index]->metadata;
break;
case 'c':
METADATA_CHECK_INDEX(map->index, files[j]->nb_chapters, "chapter")
meta[j] = &files[j]->chapters[map->index]->metadata;
break;
case 'p':
METADATA_CHECK_INDEX(map->index, files[j]->nb_programs, "program")
meta[j] = &files[j]->programs[map->index]->metadata;
break;
}
}
av_dict_copy(meta[0], *meta[1], AV_DICT_DONT_OVERWRITE);
}
if (metadata_global_autocopy && nb_input_files)
av_dict_copy(&oc->metadata, input_files[0].ctx->metadata,
AV_DICT_DONT_OVERWRITE);
if (metadata_streams_autocopy)
for (i = output_files[nb_output_files - 1].ost_index; i < nb_output_streams; i++) {
InputStream *ist = &input_streams[output_streams[i].source_index];
av_dict_copy(&output_streams[i].st->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE);
}
frame_rate = (AVRational){0, 0};
frame_width = 0;
frame_height = 0;
audio_sample_rate = 0;
audio_channels = 0;
audio_sample_fmt = AV_SAMPLE_FMT_NONE;
chapters_input_file = INT_MAX;
av_freep(&meta_data_maps);
nb_meta_data_maps = 0;
metadata_global_autocopy = 1;
metadata_streams_autocopy = 1;
metadata_chapters_autocopy = 1;
av_freep(&stream_maps);
nb_stream_maps = 0;
av_dict_free(&codec_names);
av_freep(&forced_key_frames);
uninit_opts();
init_opts();
return 0;
}
| 1threat |
modify xslt according to the output xml : I am trying to modify my xslt to get the required output.
Listing the required input xml, output xml and XSLT file
Here is my input xml
<NewDataSet>
<Header>
<BankName>SAMA</BankName>
<CashCenterName>SAMA Riyadh</CashCenterName>
</Header>
<DepositorList>
<ReferenceNumber>1</ReferenceNumber>
<DepositList_Id>0</DepositList_Id>
<PreparedBy>FZE</PreparedBy>
<TotalContainerCount>2</TotalContainerCount>
<ExpectedDate>2018-04-19T09:13:10-05:00</ExpectedDate>
<DeclaredAmount>150000</DeclaredAmount>
<ContainerList>
<ContainerNumber>903000033102</ContainerNumber>
<ContainerList_Id>0</ContainerList_Id>
<DeclaredAmount>50000</DeclaredAmount>
<DepositList_Id>0</DepositList_Id>
</ContainerList>
<ContainerList>
<ContainerNumber>903000033103</ContainerNumber>
<ContainerList_Id>1</ContainerList_Id>
<DeclaredAmount>100000</DeclaredAmount>
<DepositList_Id>0</DepositList_Id>
</ContainerList>
<ContainerContentList>
<ContainerContentList_Id>0</ContainerContentList_Id>
<TotalRecordCount>1</TotalRecordCount>
<ContainerList_Id>0</ContainerList_Id>
</ContainerContentList>
</DepositorList>
The output I am looking for is
<NewDataSet>
<Header>
<BankName>SAMA</BankName>
<CashCenterName>SAMA Riyadh</CashCenterName>
</Header>
<DepositorList>
<ReferenceNumber>1</ReferenceNumber>
<DepositList_Id>0</DepositList_Id>
<PreparedBy>FZE</PreparedBy>
<TotalContainerCount>2</TotalContainerCount>
<ExpectedDate>2018-04-19T09:13:10-05:00</ExpectedDate>
<DeclaredAmount>150000</DeclaredAmount>
<ContainerList>
<ContainerNumber>903000033102</ContainerNumber>
<DeclaredAmount>50000</DeclaredAmount>
<ContainerContentList>
<ContainerContentList_Id>0</ContainerContentList_Id>
<TotalRecordCount>1</TotalRecordCount>
<ContainerList_Id>0</ContainerList_Id>
</ContainerContentList>
</ContainerList>
<ContainerList>
<ContainerNumber>903000033103</ContainerNumber>
<ContainerList_Id>1</ContainerList_Id>
<DeclaredAmount>100000</DeclaredAmount>
<DepositList_Id>0</DepositList_Id>
</ContainerList>
</DepositorList>
Please suggest the right xslt to get the correct results.
Adding xslt in comment as it was giving error of mostly code
My current XSLT so far
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/NewDataSet">
<NewDataSet>
<xsl:copy-of select="Header"/>
<xsl:for-each select="DepositorList">
<DepositorList>
<xsl:variable name="DepositList_Id">
<xsl:value-of select="DepositList_Id"/>
</xsl:variable>
<xsl:variable name="ContainerList_Id">
<xsl:value-of select="../ContainerList[DepositList_Id=$DepositList_Id]/ContainerList_Id"/>
</xsl:variable>
<xsl:variable name="ContainerContentList_Id">
<xsl:value-of select="../ContainerContentList[ContainerList_Id=$DepositList_Id]/ContainerList_Id/ontainerContentList_Id"/>
</xsl:variable>
<xsl:copy-of select="*"/>
<xsl:copy-of select="../ContainerList[DepositList_Id=$DepositList_Id]"/>
<xsl:copy-of select="../ContainerContentList[ContainerList_Id=$ContainerList_Id]"/>
</DepositorList>
</xsl:for-each>
</NewDataSet>
</xsl:template>
</xsl:stylesheet>
| 0debug |
change text inside a span in based on id and text : I have two tags a div
`<div id="en">..</div>`and a span of same id `<span id="en">..</span>`
i want to change text only on span ` $('#en').text("sometext");` but not in div is there any way to specify it uniquely? like this $('span#en').text(obj.en); | 0debug |
static int decode_slice_luma(AVCodecContext *avctx, SliceContext *slice,
uint16_t *dst, int dst_stride,
const uint8_t *buf, unsigned buf_size,
const int16_t *qmat)
{
ProresContext *ctx = avctx->priv_data;
LOCAL_ALIGNED_16(int16_t, blocks, [8*4*64]);
int16_t *block;
GetBitContext gb;
int i, blocks_per_slice = slice->mb_count<<2;
int ret;
for (i = 0; i < blocks_per_slice; i++)
ctx->bdsp.clear_block(blocks+(i<<6));
init_get_bits(&gb, buf, buf_size << 3);
decode_dc_coeffs(&gb, blocks, blocks_per_slice);
if ((ret = decode_ac_coeffs(avctx, &gb, blocks, blocks_per_slice)) < 0)
return ret;
block = blocks;
for (i = 0; i < slice->mb_count; i++) {
ctx->prodsp.idct_put(dst, dst_stride, block+(0<<6), qmat);
ctx->prodsp.idct_put(dst +8, dst_stride, block+(1<<6), qmat);
ctx->prodsp.idct_put(dst+4*dst_stride , dst_stride, block+(2<<6), qmat);
ctx->prodsp.idct_put(dst+4*dst_stride+8, dst_stride, block+(3<<6), qmat);
block += 4*64;
dst += 16;
}
return 0;
}
| 1threat |
static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, i, type, size, pts, flags, is_audio, next, pos;
AVStream *st = NULL;
for(;;){
pos = url_ftell(s->pb);
url_fskip(s->pb, 4);
type = get_byte(s->pb);
size = get_be24(s->pb);
pts = get_be24(s->pb);
pts |= get_byte(s->pb) << 24;
if (url_feof(s->pb))
return AVERROR(EIO);
url_fskip(s->pb, 3);
flags = 0;
if(size == 0)
continue;
next= size + url_ftell(s->pb);
if (type == FLV_TAG_TYPE_AUDIO) {
is_audio=1;
flags = get_byte(s->pb);
} else if (type == FLV_TAG_TYPE_VIDEO) {
is_audio=0;
flags = get_byte(s->pb);
} else {
if (type == FLV_TAG_TYPE_META && size > 13+1+4)
flv_read_metabody(s, next);
else
av_log(s, AV_LOG_ERROR, "skipping flv packet: type %d, size %d, flags %d\n", type, size, flags);
url_fseek(s->pb, next, SEEK_SET);
continue;
}
for(i=0;i<s->nb_streams;i++) {
st = s->streams[i];
if (st->id == is_audio)
break;
}
if(i == s->nb_streams){
av_log(NULL, AV_LOG_ERROR, "invalid stream\n");
st= create_stream(s, is_audio);
s->ctx_flags &= ~AVFMTCTX_NOHEADER;
}
if( (st->discard >= AVDISCARD_NONKEY && !((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY || is_audio))
||(st->discard >= AVDISCARD_BIDIR && ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_DISP_INTER && !is_audio))
|| st->discard >= AVDISCARD_ALL
){
url_fseek(s->pb, next, SEEK_SET);
continue;
}
if ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY)
av_add_index_entry(st, pos, pts, size, 0, AVINDEX_KEYFRAME);
break;
}
if(!url_is_streamed(s->pb) && s->duration==AV_NOPTS_VALUE){
int size;
const int pos= url_ftell(s->pb);
const int fsize= url_fsize(s->pb);
url_fseek(s->pb, fsize-4, SEEK_SET);
size= get_be32(s->pb);
url_fseek(s->pb, fsize-3-size, SEEK_SET);
if(size == get_be24(s->pb) + 11){
s->duration= get_be24(s->pb) * (int64_t)AV_TIME_BASE / 1000;
}
url_fseek(s->pb, pos, SEEK_SET);
}
if(is_audio){
if(!st->codec->sample_rate || !st->codec->bits_per_sample || (!st->codec->codec_id && !st->codec->codec_tag)) {
st->codec->channels = (flags & FLV_AUDIO_CHANNEL_MASK) == FLV_STEREO ? 2 : 1;
if((flags & FLV_AUDIO_CODECID_MASK) == FLV_CODECID_NELLYMOSER_8HZ_MONO)
st->codec->sample_rate= 8000;
else
st->codec->sample_rate = (44100 << ((flags & FLV_AUDIO_SAMPLERATE_MASK) >> FLV_AUDIO_SAMPLERATE_OFFSET) >> 3);
st->codec->bits_per_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;
flv_set_audio_codec(s, st, flags & FLV_AUDIO_CODECID_MASK);
}
}else{
size -= flv_set_video_codec(s, st, flags & FLV_VIDEO_CODECID_MASK);
}
ret= av_get_packet(s->pb, pkt, size - 1);
if (ret <= 0) {
return AVERROR(EIO);
}
pkt->size = ret;
pkt->pts = pts;
pkt->stream_index = st->index;
if (is_audio || ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY))
pkt->flags |= PKT_FLAG_KEY;
return ret;
}
| 1threat |
What is Docker.qcow2? : <p>I was looking at my disk with DaisyDisk and I have a 30GB something called Docker.qcow2. More specifically, DaisyDisk puts it under <code>~/Library/Containers/com.docker.docker/Data/vms/0/Docker.qcow2</code>. Is it some kind of cache? Can I delete it? I have a lot of images from old projects that I won't ever use and I'm trying to clear up my disk.</p>
| 0debug |
How to add Angular2 Materials to project? : I use AngularJS 2 installed following instructions on the official tutorial. How to add easy Angular Materials in project? And how start to use these materials, for example, add button to HTML template?
I use Windows command prompt.
npm -v // 3.10/10 | 0debug |
static CharDriverState *qmp_chardev_open_socket(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
Error **errp)
{
CharDriverState *chr;
TCPCharDriver *s;
ChardevSocket *sock = backend->u.socket;
SocketAddress *addr = sock->addr;
bool do_nodelay = sock->has_nodelay ? sock->nodelay : false;
bool is_listen = sock->has_server ? sock->server : true;
bool is_telnet = sock->has_telnet ? sock->telnet : false;
bool is_waitconnect = sock->has_wait ? sock->wait : false;
int64_t reconnect = sock->has_reconnect ? sock->reconnect : 0;
ChardevCommon *common = qapi_ChardevSocket_base(sock);
QIOChannelSocket *sioc = NULL;
chr = qemu_chr_alloc(common, errp);
if (!chr) {
return NULL;
}
s = g_new0(TCPCharDriver, 1);
s->is_unix = addr->type == SOCKET_ADDRESS_KIND_UNIX;
s->is_listen = is_listen;
s->is_telnet = is_telnet;
s->do_nodelay = do_nodelay;
if (sock->tls_creds) {
Object *creds;
creds = object_resolve_path_component(
object_get_objects_root(), sock->tls_creds);
if (!creds) {
error_setg(errp, "No TLS credentials with id '%s'",
sock->tls_creds);
goto error;
}
s->tls_creds = (QCryptoTLSCreds *)
object_dynamic_cast(creds,
TYPE_QCRYPTO_TLS_CREDS);
if (!s->tls_creds) {
error_setg(errp, "Object with id '%s' is not TLS credentials",
sock->tls_creds);
goto error;
}
object_ref(OBJECT(s->tls_creds));
if (is_listen) {
if (s->tls_creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) {
error_setg(errp, "%s",
"Expected TLS credentials for server endpoint");
goto error;
}
} else {
if (s->tls_creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT) {
error_setg(errp, "%s",
"Expected TLS credentials for client endpoint");
goto error;
}
}
}
qapi_copy_SocketAddress(&s->addr, sock->addr);
chr->opaque = s;
chr->chr_write = tcp_chr_write;
chr->chr_sync_read = tcp_chr_sync_read;
chr->chr_close = tcp_chr_close;
chr->get_msgfds = tcp_get_msgfds;
chr->set_msgfds = tcp_set_msgfds;
chr->chr_add_client = tcp_chr_add_client;
chr->chr_add_watch = tcp_chr_add_watch;
chr->chr_update_read_handler = tcp_chr_update_read_handler;
chr->explicit_be_open = true;
chr->filename = SocketAddress_to_str("disconnected:",
addr, is_listen, is_telnet);
if (is_listen) {
if (is_telnet) {
s->do_telnetopt = 1;
}
} else if (reconnect > 0) {
s->reconnect_time = reconnect;
}
sioc = qio_channel_socket_new();
if (s->reconnect_time) {
qio_channel_socket_connect_async(sioc, s->addr,
qemu_chr_socket_connected,
chr, NULL);
} else if (s->is_listen) {
if (qio_channel_socket_listen_sync(sioc, s->addr, errp) < 0) {
goto error;
}
s->listen_ioc = sioc;
if (is_waitconnect) {
fprintf(stderr, "QEMU waiting for connection on: %s\n",
chr->filename);
tcp_chr_accept(QIO_CHANNEL(s->listen_ioc), G_IO_IN, chr);
}
qio_channel_set_blocking(QIO_CHANNEL(s->listen_ioc), false, NULL);
if (!s->ioc) {
s->listen_tag = qio_channel_add_watch(
QIO_CHANNEL(s->listen_ioc), G_IO_IN, tcp_chr_accept, chr, NULL);
}
} else {
if (qio_channel_socket_connect_sync(sioc, s->addr, errp) < 0) {
goto error;
}
tcp_chr_new_client(chr, sioc);
object_unref(OBJECT(sioc));
}
return chr;
error:
if (sioc) {
object_unref(OBJECT(sioc));
}
if (s->tls_creds) {
object_unref(OBJECT(s->tls_creds));
}
g_free(s);
qemu_chr_free_common(chr);
return NULL;
}
| 1threat |
Accesing variables and methods between classes using reference and singleton : <p>I'm struggling with using variables and methods between classes. For example, let's focus on variable only. I have two classes, <code>Foo</code> and <code>Bar</code>. I have constantly changing variable in <code>Foo</code> named <code>number</code>. How do I access this variable from class <code>Bar</code>? There will be always only one instance of <code>Bar</code> class.</p>
<pre><code>class Foo {
private Bar bclass;
public int number = 0;
Foo() {
bclass = new Bar();
}
}
class Bar {
Bar() {
// code
// Access Foo's number from here
}
}
</code></pre>
<p>There are a few options that I can think of. First - Singleton pattern. I can make all methods and variables static, make constructor private and make only one instance. Second solution would be passing <code>number</code> as reference via constructor. But that doesn't solve my problem with accessing methods in <code>Foo</code>. Or i could pass whole instance of <code>Foo</code> to <code>Bar</code> via constructor like this:</p>
<pre><code> Bar(Foo firstClass) {}
// Then in Foo
bclass = new Bar(this);
</code></pre>
<p>My program is using 4 different classes, all of them will have always only one instance and all of them need to communicate with main class or between each other in some way (using it's variables or methods). Which approach would you recommend me? Making all 4 classes as Singletons?</p>
<p>Sorry if the title or text is confusing, if I missed something it something isn't clear I will gladly respond or edit my question.</p>
| 0debug |
how to write query in mongodb for fetching data? :
This is my Json Data
"tangoRewardList": [
{
"_id": ObjectId("58107ee67a6e3f0504a2a14c"),
"brands": [{
"description": "Tango Card",
"image_url": "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/tango-card-gift-card.png",
"rewards": [{
"description": "Tango Card E-Custom",
"sku": "TNGO-E-V-STD",
"currency_code": "USD",
"available": true,
"type": "reward",
"countries": [
"US"
],
"is_variable": true,
"min_price": "1",
"max_price": "500000"
}]
}]
}
]
in this Data i want to fetch **min_price** or **max_price** using query in mongodb (*i need query for that*) help me
Thanks in advance for your support | 0debug |
Putting strings in Python lists : <p>I am trying to make a dynamic map for a text-based RPG that I am coding, so I tried this array:</p>
<pre><code>landscape = [['-,-,-,-,-,-,-,-,-,-,-,-,-,-,X']
['-,-,-,-,-,-,-,-,-,-,-,-,-,-,-']
['-,-,-,-,-,-,-,-,-,-,-,-,-,-,-']
['-,-,-,-,-,-,-,-,-,-,-,-,-,-,-']
['-,-,-,-,-,-,-,-,-,-,-,-,-,-,-']
['-,-,-,-,-,-,-,-,-,-,-,-,-,-,-']
['-,-,-,-,-,-,-,-,-,-,-,-,-,-,-']
['-,-,-,-,-,-,-,-,-,-,-,-,-,-,-']
['-,-,-,-,-,-,-,-,-,-,-,-,-,-,-']
['-,-,-,-,-,-,-,-,-,-,-,-,-,-,-']
['-,-,-,-,-,-,-,-,-,-,-,-,-,-,-']
['-,-,-,-,-,-,-,-,-,-,-,-,-,-,-']
['-,-,-,-,-,-,-,-,-,-,-,-,-,-,-']
['-,-,-,-,-,-,-,-,-,-,-,-,-,-,-']
['O,-,-,-,-,-,-,-,-,-,-,-,-,-,-']]
</code></pre>
<p>However, it gave an error message saying that str objects cannot be placed in arrays. Is there a way to fix this?</p>
| 0debug |
void timer_init_tl(QEMUTimer *ts,
QEMUTimerList *timer_list, int scale,
QEMUTimerCB *cb, void *opaque)
{
ts->timer_list = timer_list;
ts->cb = cb;
ts->opaque = opaque;
ts->scale = scale;
ts->expire_time = -1;
}
| 1threat |
static uint64_t mmio_ide_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
MMIOState *s = opaque;
addr >>= s->shift;
if (addr & 7)
return ide_ioport_read(&s->bus, addr);
else
return ide_data_readw(&s->bus, 0);
}
| 1threat |
static void vnc_write_u32(VncState *vs, uint32_t value)
{
uint8_t buf[4];
buf[0] = (value >> 24) & 0xFF;
buf[1] = (value >> 16) & 0xFF;
buf[2] = (value >> 8) & 0xFF;
buf[3] = value & 0xFF;
vnc_write(vs, buf, 4);
}
| 1threat |
static void ide_init1(IDEBus *bus, int unit)
{
static int drive_serial = 1;
IDEState *s = &bus->ifs[unit];
s->bus = bus;
s->unit = unit;
s->drive_serial = drive_serial++;
s->io_buffer_total_len = IDE_DMA_BUF_SECTORS*512 + 4;
s->io_buffer = qemu_memalign(2048, s->io_buffer_total_len);
memset(s->io_buffer, 0, s->io_buffer_total_len);
s->smart_selftest_data = qemu_blockalign(s->bs, 512);
memset(s->smart_selftest_data, 0, 512);
s->sector_write_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
ide_sector_write_timer_cb, s);
}
| 1threat |
java, best API jar : <p>I'm building one API using javax.ws.rs-api(2.1.1) and com.sun.jersey (1.18.1) but it causes one Exception. Reading some threads it seems like one of both includes one class that is part of the other and this raises this Exception.
After some tries I'm still stucked on find how to fix it but then another question came to my brain, Is this the best API class for building servlets? So my question is if somebody can provide his experience and can say that continue using those libraries is the best option (and then fight for fixing this Exception) or can suggest better options.</p>
<p>I'm not using Spring neither Hibernate and those are not the option, I build my own Servlet from scratch ... yes ... I have my reasons ....</p>
<p>Thanks in advance
Regards</p>
| 0debug |
static av_cold int vc2_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet)
{
int ret = 0;
int sig_size = 256;
VC2EncContext *s = avctx->priv_data;
const char aux_data[] = LIBAVCODEC_IDENT;
const int aux_data_size = sizeof(aux_data);
const int header_size = 100 + aux_data_size;
int64_t max_frame_bytes, r_bitrate = avctx->bit_rate >> (s->interlaced);
s->avctx = avctx;
s->size_scaler = 1;
s->prefix_bytes = 0;
s->last_parse_code = 0;
s->next_parse_offset = 0;
max_frame_bytes = (av_rescale(r_bitrate, s->avctx->time_base.num,
s->avctx->time_base.den) >> 3) - header_size;
while (sig_size > 255) {
s->slice_max_bytes = FFALIGN(av_rescale(max_frame_bytes, 1,
s->num_x*s->num_y), s->size_scaler);
s->slice_max_bytes += 4 + s->prefix_bytes;
sig_size = s->slice_max_bytes/s->size_scaler;
s->size_scaler <<= 1;
}
s->slice_min_bytes = s->slice_max_bytes - s->slice_max_bytes*(s->tolerance/100.0f);
ret = encode_frame(s, avpkt, frame, aux_data, header_size, s->interlaced);
if (ret)
return ret;
if (s->interlaced) {
ret = encode_frame(s, avpkt, frame, aux_data, header_size, 2);
if (ret)
return ret;
}
flush_put_bits(&s->pb);
avpkt->size = put_bits_count(&s->pb) >> 3;
*got_packet = 1;
return 0;
}
| 1threat |
Turning a simple python "program" in a C "program"! : <p>So i have this "program" in python3 which adds 3 strings but the middle part x times. But i decided to choose C as my first language after doing some simple stuff on Python 3.
NOW this is how it looks in Python:</p>
<pre><code>def printWord(begin, mid, end, r):
print(begin, end="")
for i in range(r+1):
print(mid, end="")
print(end)
begin = input("Enter your beginning.\t")
mid =input("Enter your middle.\t")
end = input("Enter your ending.\t")
r = int(input("How many times?\t"))
printWord(begin, mid, end, r)
</code></pre>
<p>So this works and every thing is cool!</p>
<p>Now C:</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
int makeWord(char begin[], char mid[], char end[], int r)
{
int i;
printf("%s", begin);
for(i=0;i<=r;i++){
printf("%s", mid);
}
printf("%s", end);
return 0;
}
int main()
{
int r;
char begin[3], mid[2], end[3];
printf("Enter the beginning!\t");
scanf("%s", begin);
printf("Enter the middle!\t");
scanf("%s", mid);
printf("Enter the ending!\t");
scanf("%s", end);
printf("How many times?\t");
scanf("%d", r);
makeWord(begin, mid, end, r);
return 0;
}
</code></pre>
<p>But this one stops </p>
<p>Now my question WHY?
Thanks for answering</p>
| 0debug |
complex API vs simple API endpoint : <p>I have a backend Rails application that is mainly API endpoints and a front-end application that is mainly being built in React.</p>
<p>Consider the following models:</p>
<ol>
<li><strong>Panel</strong>: is an container element inside a dashboard. It defines dimensions/positions inside the dashboard. It also defines its content using a content_type and a content_id (polymorphic associations).</li>
<li><strong>Chart / SingleValue / Section</strong>: these are all models that can be used as content for the panel. </li>
</ol>
<p>What I would like to do now is letting the user create a "chart panel" in one step.</p>
<p>I've been wondering for a while now if it is better to:</p>
<ol>
<li>Have all the basic CRUD API end-points and manage the panel+chart creation 100% on the front-end. This would mean more complexity on the front-end but fewer API end-points.</li>
<li>Have an extra API endpoint on the Rails side to create panel+chart/panel+single_value/panel+section (atomic operation). This would mean much less complexity on the front-end but more API end-points.</li>
</ol>
<p>What would be the ideal approach?</p>
| 0debug |
int net_init_tap(const NetClientOptions *opts, const char *name,
NetClientState *peer)
{
const NetdevTapOptions *tap;
int fd, vnet_hdr = 0, i = 0, queues;
const char *script = NULL;
const char *downscript = NULL;
const char *vhostfdname;
char ifname[128];
assert(opts->kind == NET_CLIENT_OPTIONS_KIND_TAP);
tap = opts->tap;
queues = tap->has_queues ? tap->queues : 1;
vhostfdname = tap->has_vhostfd ? tap->vhostfd : NULL;
if (tap->has_fd) {
if (tap->has_ifname || tap->has_script || tap->has_downscript ||
tap->has_vnet_hdr || tap->has_helper || tap->has_queues ||
tap->has_fds) {
error_report("ifname=, script=, downscript=, vnet_hdr=, "
"helper=, queues=, and fds= are invalid with fd=");
fd = monitor_handle_fd_param(cur_mon, tap->fd);
if (fd == -1) {
fcntl(fd, F_SETFL, O_NONBLOCK);
vnet_hdr = tap_probe_vnet_hdr(fd);
if (net_init_tap_one(tap, peer, "tap", name, NULL,
script, downscript,
vhostfdname, vnet_hdr, fd)) {
} else if (tap->has_fds) {
char *fds[MAX_TAP_QUEUES];
char *vhost_fds[MAX_TAP_QUEUES];
int nfds, nvhosts;
if (tap->has_ifname || tap->has_script || tap->has_downscript ||
tap->has_vnet_hdr || tap->has_helper || tap->has_queues ||
tap->has_fd) {
error_report("ifname=, script=, downscript=, vnet_hdr=, "
"helper=, queues=, and fd= are invalid with fds=");
nfds = get_fds(tap->fds, fds, MAX_TAP_QUEUES);
if (tap->has_vhostfds) {
nvhosts = get_fds(tap->vhostfds, vhost_fds, MAX_TAP_QUEUES);
if (nfds != nvhosts) {
error_report("The number of fds passed does not match the "
"number of vhostfds passed");
for (i = 0; i < nfds; i++) {
fd = monitor_handle_fd_param(cur_mon, fds[i]);
if (fd == -1) {
fcntl(fd, F_SETFL, O_NONBLOCK);
if (i == 0) {
vnet_hdr = tap_probe_vnet_hdr(fd);
} else if (vnet_hdr != tap_probe_vnet_hdr(fd)) {
error_report("vnet_hdr not consistent across given tap fds");
if (net_init_tap_one(tap, peer, "tap", name, ifname,
script, downscript,
tap->has_vhostfds ? vhost_fds[i] : NULL,
vnet_hdr, fd)) {
} else if (tap->has_helper) {
if (tap->has_ifname || tap->has_script || tap->has_downscript ||
tap->has_vnet_hdr || tap->has_queues || tap->has_fds) {
error_report("ifname=, script=, downscript=, and vnet_hdr= "
"queues=, and fds= are invalid with helper=");
fd = net_bridge_run_helper(tap->helper, DEFAULT_BRIDGE_INTERFACE);
if (fd == -1) {
fcntl(fd, F_SETFL, O_NONBLOCK);
vnet_hdr = tap_probe_vnet_hdr(fd);
if (net_init_tap_one(tap, peer, "bridge", name, ifname,
script, downscript, vhostfdname,
vnet_hdr, fd)) {
} else {
script = tap->has_script ? tap->script : DEFAULT_NETWORK_SCRIPT;
downscript = tap->has_downscript ? tap->downscript :
DEFAULT_NETWORK_DOWN_SCRIPT;
if (tap->has_ifname) {
pstrcpy(ifname, sizeof ifname, tap->ifname);
} else {
ifname[0] = '\0';
for (i = 0; i < queues; i++) {
fd = net_tap_init(tap, &vnet_hdr, i >= 1 ? "no" : script,
ifname, sizeof ifname, queues > 1);
if (fd == -1) {
if (queues > 1 && i == 0 && !tap->has_ifname) {
if (tap_fd_get_ifname(fd, ifname)) {
error_report("Fail to get ifname");
if (net_init_tap_one(tap, peer, "tap", name, ifname,
i >= 1 ? "no" : script,
i >= 1 ? "no" : downscript,
vhostfdname, vnet_hdr, fd)) {
return 0; | 1threat |
Python 3.x - input() - Security : Does **input()** (in python) has security issue?
For your information, I am using python 3.x currently. | 0debug |
def count_Fac(n):
m = n
count = 0
i = 2
while((i * i) <= m):
total = 0
while (n % i == 0):
n /= i
total += 1
temp = 0
j = 1
while((temp + j) <= total):
temp += j
count += 1
j += 1
i += 1
if (n != 1):
count += 1
return count | 0debug |
static int mpeg4_decode_header(AVCodecParserContext *s1, AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
struct Mp4vParseContext *pc = s1->priv_data;
Mpeg4DecContext *dec_ctx = &pc->dec_ctx;
MpegEncContext *s = &dec_ctx->m;
GetBitContext gb1, *gb = &gb1;
int ret;
s->avctx = avctx;
s->current_picture_ptr = &s->current_picture;
if (avctx->extradata_size && pc->first_picture) {
init_get_bits(gb, avctx->extradata, avctx->extradata_size * 8);
ret = ff_mpeg4_decode_picture_header(dec_ctx, gb);
}
init_get_bits(gb, buf, 8 * buf_size);
ret = ff_mpeg4_decode_picture_header(dec_ctx, gb);
if (s->width && (!avctx->width || !avctx->height ||
!avctx->coded_width || !avctx->coded_height)) {
ret = ff_set_dimensions(avctx, s->width, s->height);
return ret;
}
if((s1->flags & PARSER_FLAG_USE_CODEC_TS) && s->avctx->time_base.den>0 && ret>=0){
av_assert1(s1->pts == AV_NOPTS_VALUE);
av_assert1(s1->dts == AV_NOPTS_VALUE);
s1->pts = av_rescale_q(s->time, (AVRational){1, s->avctx->time_base.den}, (AVRational){1, 1200000});
}
s1->pict_type = s->pict_type;
pc->first_picture = 0;
return ret;
} | 1threat |
What is the ideal target time for rendering a page of a PHP forum? : <p>I am creating this question because I am currently working on my free time (for fun) on a PHP forum, using MySQL for my database. And for a little while now (most of the essential features being implemented), I have been questioning the performance of my scripts.</p>
<p>I already did some profiling of my scripts and improved some of them, but I eventually always end up with the same question: <strong>what is a good target time to render the typical page of a forum ?</strong> In my case, such a page consists in displaying 20 to 50 messages of a given topic (users can decide how many messages per page they want to display) with roughly half of them using features like uploads displayed as a gallery below a message (which involves string parsing and checking the existence of a file with file_exists()).</p>
<p>After reading some topics on performance with PHP on this website, I learned, among others, that Youtube had a target render time of 100ms (= 0,1s). I managed to have load times below this target time for my heaviest pages, but only after a while due to PHP caching with file_exists() (I run my project locally, with a WAMP Server). But I doubt I can really compare my project to a website as heavy in features as Youtube. So,</p>
<ul>
<li><p>When rendering (in HTML/CSS) my "typical" page, what time should I target ? Is it acceptable to stick to the 100ms limit, or should I go way below (for example, below 50ms) ? Are there any known statistics about current state-of-the-art forums I could use for reference ?</p></li>
<li><p>Since I am currently working with WAMP Server, does it introduce bias while profiling my scripts ? Is it equivalent to your average PHP-enabled HTTP server, or does it run slower/faster on average ?</p></li>
</ul>
<p>This question interests me a lot, as some features I designed add some overhead to my scripts (which scales with the amount of messages being displayed). For example, my format code to embed videos is not parsed at the creation of a message, but at its display, as I want to be able to easily change the embed code as well as allowing users to choose how videos are embedded (directly, or with small/HQ thumbnail which is replaced with the embed code upon clicking) for their comfort. Of course, I could as well parse the code at the submission of a new message to reduce the overhead, but I want to be sure this is necessary.</p>
<p>I hope this is not too vague... thank you in advance for your answers.</p>
| 0debug |
Is 500 lines too big for a React component? : <p>I am building a Table component that has filters on it and therefore there is a lot of logic involved and also I am using material ui which uses a lot of lines. However I am finding the component to be too extense. Is having a component with this size ok?</p>
| 0debug |
Missing required module Firebase - Jenkins build error : <p>I have configured jenkins for building my ios-swift application. i have used
xcode version 8.1 and swift version 3. I am new to Jenkins and continues integration process. Based on my console output, i think build is successful. bacause console output print like this</p>
<pre><code> Touch build/testinng.app
cd /Users/Shared/Jenkins/Home/workspace/testinng_Bit_Test
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/usr/bin/touch -c /Users/Shared/Jenkins/Home/workspace/testinng_Bit_Test/build/testinng.app
CodeSign build/testinng.app
cd /Users/Shared/Jenkins/Home/workspace/testinng_Bit_Test
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
Signing Identity: "-"
/usr/bin/codesign --force --sign - --timestamp=none /Users/Shared/Jenkins/Home/workspace/testinng_Bit_Test/build/testinng.app
** BUILD SUCCEEDED **
2016-11-09 19:51:39.300 xcodebuild[2659:26623] [MT] IDETestOperationsObserverDebug: (E99CCCC3-8EED-4FBA-8A00-2CD3C0D7273F) Beginning test session testinngUITests-E99CCCC3-8EED-4FBA-8A00-2CD3C0D7273F at 2016-11-09 19:51:39.299 with Xcode 8B62 on target <DVTiPhoneSimulator: 0x7f9dce6bc690> {
SimDevice: SimDevice : iPhone 7 (223F7310-19DF-4FA7-B147-73AB8B48454F) : state={ Booted } deviceType={ SimDeviceType : com.apple.CoreSimulator.SimDeviceType.iPhone-7 } runtime={ SimRuntime : 10.1 (14B72) - com.apple.CoreSimulator.SimRuntime.iOS-10-1 }
} (10.1 (14B72))
</code></pre>
<p>But after this console output print failure message. </p>
<pre><code>failed to import required module: 'Firebase'.
</code></pre>
<p>I gofinal console output like this.</p>
<pre><code> Touch build/testinng.app
cd /Users/Shared/Jenkins/Home/workspace/testinng_Bit_Test
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/usr/bin/touch -c /Users/Shared/Jenkins/Home/workspace/testinng_Bit_Test/build/testinng.app
CodeSign build/testinng.app
cd /Users/Shared/Jenkins/Home/workspace/testinng_Bit_Test
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
Signing Identity: "-"
/usr/bin/codesign --force --sign - --timestamp=none /Users/Shared/Jenkins/Home/workspace/testinng_Bit_Test/build/testinng.app
** BUILD SUCCEEDED **
2016-11-09 19:51:39.300 xcodebuild[2659:26623] [MT] IDETestOperationsObserverDebug: (E99CCCC3-8EED-4FBA-8A00-2CD3C0D7273F) Beginning test session testinngUITests-E99CCCC3-8EED-4FBA-8A00-2CD3C0D7273F at 2016-11-09 19:51:39.299 with Xcode 8B62 on target <DVTiPhoneSimulator: 0x7f9dce6bc690> {
SimDevice: SimDevice : iPhone 7 (223F7310-19DF-4FA7-B147-73AB8B48454F) : state={ Booted } deviceType={ SimDeviceType : com.apple.CoreSimulator.SimDeviceType.iPhone-7 } runtime={ SimRuntime : 10.1 (14B72) - com.apple.CoreSimulator.SimRuntime.iOS-10-1 }
} (10.1 (14B72))
=== BUILD TARGET testinngTests OF PROJECT testinng WITH CONFIGURATION Debug ===
Check dependencies
Create product structure
/bin/mkdir -p /Users/Shared/Jenkins/Home/workspace/testinng_Bit_Test/build/testinng.app/PlugIns/testinngTests.xctest
ProcessInfoPlistFile build/testinng.app/PlugIns/testinngTests.xctest/Info.plist testinngTests/Info.plist
cd /Users/Shared/Jenkins/Home/workspace/testinng_Bit_Test
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
builtin-infoPlistUtility /Users/Shared/Jenkins/Home/workspace/testinng_Bit_Test/testinngTests/Info.plist -expandbuildsettings -format binary -platform iphonesimulator -o /Users/Shared/Jenkins/Home/workspace/testinng_Bit_Test/build/testinng.app/PlugIns/testinngTests.xctest/Info.plist
CompileSwift normal x86_64 /Users/Shared/Jenkins/Home/workspace/testinng_Bit_Test/testinngTests/testinngTests.swift
cd /Users/Shared/Jenkins/Home/workspace/testinng_Bit_Test
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/Shared/Jenkins/Home/workspace/testinng_Bit_Test/testinngTests/testinngTests.swift -target x86_64-apple-ios10.0 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk -I /Users/Shared/Jenkins/Home/workspace/testinng_Bit_Test/build -F /--akyiibisusqoudfyyfxubyhwzzgz/Build/Intermediates/testinng.build/Debug-iphonesimulator/testinngTests.build/Objects-normal/x86_64/testinngTests.swiftdeps -o /Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/testinng-akyiibisusqoudfyyfxubyhwzzgz/Build/Intermediates/testinng.build/Debug-iphonesimulator/testinngTests.build/Objects-normal/x86_64/testinngTests.o
/Users/Shared/Jenkins/Home/workspace/testinng_Bit_Test/testinngTests/testinngTests.swift:10:18: error: missing required module 'Firebase'
@testable import testinng
^
2016-11-09 19:51:48.418 xcodebuild[2659:26623] Error Domain=IDETestOperationsObserverErrorDomain Code=3 "Test operation was canceled. If you believe this error represents a bug, please attach the log file at /Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/testinng-akyiibisusqoudfyyfxubyhwzzgz/Logs/Test/B554B7BB-8F73-4B3F-8B9B-B07918ED46AB/Session-testinngUITests-2016-11-09_195139-CXzaIj.log" UserInfo={NSLocalizedDescription=Test operation was canceled. If you believe this error represents a bug, please attach the log file at /Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/testinng-akyiibisusqoudfyyfxubyhwzzgz/Logs/Test/B554B7BB-8F73-4B3F-8B9B-B07918ED46AB/Session-testinngUITests-2016-11-09_195139-CXzaIj.log}
2016-11-09 19:51:48.418 xcodebuild[2659:26623] Error Domain=IDETestOperationsObserverErrorDomain Code=3 "Test operation was canceled. If you believe this error represents a bug, please attach the log file at /Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/testinng-akyiibisusqoudfyyfxubyhwzzgz/Logs/Test/B554B7BB-8F73-4B3F-8B9B-B07918ED46AB/Session-testinngTests-2016-11-09_195139-NdHjC1.log" UserInfo={NSLocalizedDescription=Test operation was canceled. If you believe this error represents a bug, please attach the log file at /Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/testinng-akyiibisusqoudfyyfxubyhwzzgz/Logs/Test/B554B7BB-8F73-4B3F-8B9B-B07918ED46AB/Session-testinngTests-2016-11-09_195139-NdHjC1.log}
2016-11-09 19:51:48.419 xcodebuild[2659:27966] Connection peer refused channel request for "dtxproxy:XCTestManager_IDEInterface:XCTestManager_DaemonConnectionInterface"; channel canceled <DTXChannel: 0x7f9dceef3b20>
2016-11-09 19:51:48.419 xcodebuild[2659:26664] Connection peer refused channel request for "dtxproxy:XCTestManager_IDEInterface:XCTestManager_DaemonConnectionInterface"; channel canceled <DTXChannel: 0x7f9dcee7ded0>
Testing failed:
Missing required module 'Firebase'
** TEST FAILED **
The following build commands failed:
CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
CompileSwift normal x86_64 /Users/Shared/Jenkins/Home/workspace/testinng_Bit_Test/testinngTests/testinngTests.swift
(2 failures)
Build step 'Xcode' marked build as failure
</code></pre>
<p>What is the issue related with this?</p>
| 0debug |
Garbage value being sent to the function instead of the actual parameter. What could be the problem/error in the code? : #PF-Assgn-22
def find_leap_years(given_year):
i=0
count=0
while(count<15):
print(given_year)
if(given_year%4==0)and(given_year%400==0):
if(given_year%100!=0):
list_of_leap_years[i]=given_year
i+=1
count+=1
given_year+=1
return list_of_leap_years
list_of_leap_years=find_leap_years(2000)
print(list_of_leap_years) | 0debug |
$_POST not retrieving data from Javascript's Fetch() : <p>I'm posting data using javascript's <code>fetch()</code> .</p>
<pre><code> fetch('/string.php', {
method: 'post',
body: JSON.stringify({
name: 'helloe world',
})
})
.then(function(response) {
if (response.status >= 200 && response.status < 300) {
return response.text()
}
throw new Error(response.statusText)
})
.then(function(response) {
console.log(response);
})
</code></pre>
<p>string.php file contains:</p>
<pre><code>print_r($_POST);
</code></pre>
<p>Now my problem is the <code>$_POST</code> returns an empty array. I can fix this by appending the file with:</p>
<pre><code>$_POST = json_decode(file_get_contents('php://input'), true);
</code></pre>
<p>But that feels very hackish and isn't ideal. Is this the intended behaviour for PHP when retrieving post data from a JS <code>fetch()</code>?</p>
<p>Is there anyway I may automatically put the contents within the <code>$_POST</code>?</p>
| 0debug |
Choosing between Google Cloud Flexible or Standard Environment : <p>I'm starting to build a web/mobile app that is going to be offered as SaaS.
I have seen many cloud options for hosting (Heroku, AWS) but finally decided to go with Google Cloud App Engine.</p>
<p>My back-end will be Java based, and I'm confused about going with the Standard or Flexible Env.
I have read several docs online but still undecided.</p>
<p><em>Considerations to tackle:</em></p>
<ol>
<li>I am not very experienced with Docker and this is my first Saas App.</li>
<li><p>My app should run perfectly with the offering of the Standard Env.</p></li>
<li><p>Migrating from the Standard to the Flex environment seems to bring
some headache.</p></li>
</ol>
<p>Would you please help me decide on the way to?</p>
| 0debug |
Which equation represents quadratic time : <p><a href="https://i.stack.imgur.com/9ioTI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9ioTI.png" alt="enter image description here"></a></p>
<p>I believe it is 3n+5n^2+1 but I am not 100 percent sure. If I am wrong can someone explain to me why?</p>
| 0debug |
Python OS module os.listdir() : when I am executed above command in python console gives below error
Note: I am working **windows 10 environment**
>>> os.listdir()
Traceback (most recent call last):
File "<stdin>, line 1, in <module>
TypeError: listdir() takes exactly 1 argument (0 given) | 0debug |
Why is LEA 0x89AB(%A0),%A0 an Illegal Instruction in 86k assembly : [Click here to view the question][1]
[1]: https://i.stack.imgur.com/9MDHU.png
here is the programming card :
https://files.fm/u/7pfmqca9
Why is LEA 0x89AB(%A0),%A0 an Illegal Instruction in 86k assembly?
| 0debug |
npm publish Failed PUT 402 : <p>Working on a course that is having me go through a Bash tutorial.
I am stuck on the part where the code is asking me to publish my code so far. My instructions are as follows:</p>
<blockquote>
<pre><code> What good is a package manager without packages?
Not very good.
Luckily, that is not a problem for npm, because it's very easy for all
npm users to publish their modules and share them with the world.
Packages get into the registry by using the `npm publish` command.
Try it now. There's not much to it.
(Make sure you're still in the right project directory, though. If you
publish something by mistake, you can remove it, but there's no guarantee
that no one saw it in the meantime.)
Then run `how-to-npm verify` when you're done.
</code></pre>
</blockquote>
<p>My code was:</p>
<pre><code>jsf2008:~/workspace/dev (master) $ npm publish
npm ERR! publish Failed PUT 402
npm ERR! code E402
npm ERR! You must sign up for private packages : @jsf2008/quit
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2017-08-22T14_44_29_746Z-debug.log
jsf2008:~/workspace/dev (master) $
</code></pre>
<p>I am quite lost here. I can't even find Error PUT 402 anywhere. Any help would be greatly appreciated.</p>
| 0debug |
How to load web view in to view when a specific button is on clicked? : <p>I am new to android .I am trying to develop an android application which has web view opening when clicked on a specific button.I need to show the website which has java script.How can I create it?</p>
| 0debug |
Access a list in another project c# : <p>I am new to C# and am trying to create a list in one project and access the same in another project. Could you tell me what would be the best way to do this?</p>
<p>Thanks</p>
| 0debug |
iTextSharp - how to have space padding at the top & bottom of a columnText : I am writing text into a ColumnText using
columnText.AddElement(paragraph);
I would like to have some padding (blank space) at the top and bottom of the column, bearing in mind that I am writing many paragraphs before reaching the bottom of the column.
I would appreciate it if you give me an idea how to achieve this.
Thanks
| 0debug |
static abi_long do_sendto(int fd, abi_ulong msg, size_t len, int flags,
abi_ulong target_addr, socklen_t addrlen)
{
void *addr;
void *host_msg;
abi_long ret;
if ((int)addrlen < 0) {
return -TARGET_EINVAL;
}
host_msg = lock_user(VERIFY_READ, msg, len, 1);
if (!host_msg)
return -TARGET_EFAULT;
if (fd_trans_target_to_host_data(fd)) {
ret = fd_trans_target_to_host_data(fd)(host_msg, len);
if (ret < 0) {
unlock_user(host_msg, msg, 0);
return ret;
}
}
if (target_addr) {
addr = alloca(addrlen+1);
ret = target_to_host_sockaddr(fd, addr, target_addr, addrlen);
if (ret) {
unlock_user(host_msg, msg, 0);
return ret;
}
ret = get_errno(safe_sendto(fd, host_msg, len, flags, addr, addrlen));
} else {
ret = get_errno(safe_sendto(fd, host_msg, len, flags, NULL, 0));
}
unlock_user(host_msg, msg, 0);
return ret;
}
| 1threat |
static void cirrus_mem_writeb_mode4and5_8bpp(CirrusVGAState * s,
unsigned mode,
unsigned offset,
uint32_t mem_value)
{
int x;
unsigned val = mem_value;
uint8_t *dst;
dst = s->vram_ptr + offset;
for (x = 0; x < 8; x++) {
if (val & 0x80) {
*dst = s->cirrus_shadow_gr1;
} else if (mode == 5) {
*dst = s->cirrus_shadow_gr0;
}
val <<= 1;
dst++;
}
cpu_physical_memory_set_dirty(s->vram_offset + offset);
cpu_physical_memory_set_dirty(s->vram_offset + offset + 7);
}
| 1threat |
C++ Segmentation Fault. Any pro's here on this who can help? GDB and Valgrind outputs in link : Compiled on Ubuntu Bionic 10/2018 ARM 64bit with clang.
Error: Segmentation fault.
Any ideas?
Pastebin link for gdb and valgrind outputs - https://pastebin.com/S2Snf13J
400
401 for (t = ta_args(ta); t; t = (tagi_t )t_next(t)) {
402 tag_type_t tt = t->t_tag;
403
404 if (!tt)
405 continue;
406
407 if (tt->tt_class == ref_tag_class) {
408 assert(((tag_type_t)tt->tt_magic)->tt_class->tc_ref_set);
409 n += tl_get(tt, (void )t->t_value, lst);
410 }
411 #if !defined(NDEBUG)
412 else if (tt->tt_class && tt->tt_class->tc_ref_set) {
413 fprintf(stderr, "WARNING: tag %s::%s directly used by tl_gets()\n",
414 tt->tt_ns ? tt->tt_ns : "", tt->tt_name ? tt->tt_name : "");
415 assert(tt->tt_class == ref_tag_class);
416 }
417 #endif
418 }
419
420 ta_end(ta); | 0debug |
Split a string and loop through values in MySql Procedure : <p>I got a situation where I have to pass a comma separated string to MySQL procedure and split that string and insert those values as rows in to a table.</p>
<p>As show below</p>
<p>For example if I passed 'jhon,swetha,sitha' string to mysql procedure then it have to split that string by comma and insert those values as 3 records into a table.</p>
<pre><code> CREATE PROCEDURE new_routine (IN str varchar(30))
BEGIN
DECLARE tmp varchar(10);
DECLARE inc INT DEFAULT 0;
WHILE INSTR(str, ',') DO
SET tmp = SUBSTRING(SUBSTRING_INDEX(str,',',inc),LENGTH(SUBSTRING_INDEX(str,',',inc-1))+1),',','');
SET str = REPLACE(str, tmp, '');
//insert tmp into a table.
END WHILE;
END
</code></pre>
<p>But this does not worked any solution please.</p>
| 0debug |
C Installed Library - What is this? : <p>I'm currently trying to install a library in c (specifically libsndfile). It's telling me that I need to 'install' and library. I'm confused, what exactly am I doing by 'installing' the library? </p>
<p>Why is it that I'm not just including header and source code files? </p>
<p>I've tried googling this but have not gotten too much success. Does anyone care to explain or recommend an article that discusses this?</p>
<p>Thank you,</p>
| 0debug |
static av_cold int svq3_decode_init(AVCodecContext *avctx)
{
SVQ3Context *svq3 = avctx->priv_data;
H264Context *h = &svq3->h;
MpegEncContext *s = &h->s;
int m;
unsigned char *extradata;
unsigned char *extradata_end;
unsigned int size;
int marker_found = 0;
if (ff_h264_decode_init(avctx) < 0)
return -1;
s->flags = avctx->flags;
s->flags2 = avctx->flags2;
s->unrestricted_mv = 1;
h->is_complex=1;
h->sps.chroma_format_idc = 1;
avctx->pix_fmt = avctx->codec->pix_fmts[0];
if (!s->context_initialized) {
h->chroma_qp[0] = h->chroma_qp[1] = 4;
svq3->halfpel_flag = 1;
svq3->thirdpel_flag = 1;
svq3->unknown_flag = 0;
extradata = (unsigned char *)avctx->extradata;
extradata_end = avctx->extradata + avctx->extradata_size;
if (extradata) {
for (m = 0; m + 8 < avctx->extradata_size; m++) {
if (!memcmp(extradata, "SEQH", 4)) {
marker_found = 1;
break;
}
extradata++;
}
}
if (marker_found) {
GetBitContext gb;
int frame_size_code;
size = AV_RB32(&extradata[4]);
if (size > extradata_end - extradata - 8)
return AVERROR_INVALIDDATA;
init_get_bits(&gb, extradata + 8, size*8);
frame_size_code = get_bits(&gb, 3);
switch (frame_size_code) {
case 0: avctx->width = 160; avctx->height = 120; break;
case 1: avctx->width = 128; avctx->height = 96; break;
case 2: avctx->width = 176; avctx->height = 144; break;
case 3: avctx->width = 352; avctx->height = 288; break;
case 4: avctx->width = 704; avctx->height = 576; break;
case 5: avctx->width = 240; avctx->height = 180; break;
case 6: avctx->width = 320; avctx->height = 240; break;
case 7:
avctx->width = get_bits(&gb, 12);
avctx->height = get_bits(&gb, 12);
break;
}
svq3->halfpel_flag = get_bits1(&gb);
svq3->thirdpel_flag = get_bits1(&gb);
skip_bits1(&gb);
skip_bits1(&gb);
skip_bits1(&gb);
skip_bits1(&gb);
s->low_delay = get_bits1(&gb);
skip_bits1(&gb);
while (get_bits1(&gb)) {
skip_bits(&gb, 8);
}
svq3->unknown_flag = get_bits1(&gb);
avctx->has_b_frames = !s->low_delay;
if (svq3->unknown_flag) {
#if CONFIG_ZLIB
unsigned watermark_width = svq3_get_ue_golomb(&gb);
unsigned watermark_height = svq3_get_ue_golomb(&gb);
int u1 = svq3_get_ue_golomb(&gb);
int u2 = get_bits(&gb, 8);
int u3 = get_bits(&gb, 2);
int u4 = svq3_get_ue_golomb(&gb);
unsigned long buf_len = watermark_width*watermark_height*4;
int offset = (get_bits_count(&gb)+7)>>3;
uint8_t *buf;
if ((uint64_t)watermark_width*4 > UINT_MAX/watermark_height)
return -1;
buf = av_malloc(buf_len);
av_log(avctx, AV_LOG_DEBUG, "watermark size: %dx%d\n", watermark_width, watermark_height);
av_log(avctx, AV_LOG_DEBUG, "u1: %x u2: %x u3: %x compressed data size: %d offset: %d\n", u1, u2, u3, u4, offset);
if (uncompress(buf, &buf_len, extradata + 8 + offset, size - offset) != Z_OK) {
av_log(avctx, AV_LOG_ERROR, "could not uncompress watermark logo\n");
av_free(buf);
return -1;
}
svq3->watermark_key = ff_svq1_packet_checksum(buf, buf_len, 0);
svq3->watermark_key = svq3->watermark_key << 16 | svq3->watermark_key;
av_log(avctx, AV_LOG_DEBUG, "watermark key %#x\n", svq3->watermark_key);
av_free(buf);
#else
av_log(avctx, AV_LOG_ERROR, "this svq3 file contains watermark which need zlib support compiled in\n");
return -1;
#endif
}
}
s->width = avctx->width;
s->height = avctx->height;
if (ff_MPV_common_init(s) < 0)
return -1;
h->b_stride = 4*s->mb_width;
if (ff_h264_alloc_tables(h) < 0) {
av_log(avctx, AV_LOG_ERROR, "svq3 memory allocation failed\n");
return AVERROR(ENOMEM);
}
}
return 0;
}
| 1threat |
static int ogg_read_close(AVFormatContext *s)
{
struct ogg *ogg = s->priv_data;
int i;
for (i = 0; i < ogg->nstreams; i++) {
av_free(ogg->streams[i].buf);
av_free(ogg->streams[i].private);
}
av_free(ogg->streams);
return 0;
}
| 1threat |
How to do multiple word and value replacement in a multiple line at one time :
Lets say I have multiples like this
my input lines:
"stack overflow version {5} my new version"
"stack exchnage version {10} my new version"
"perl scripting version 5.14 my new version"
"segmentaion falult happen {5} if the memory is not freed"
" my college 30 new xxxx"
I want to replace value inside parenthesis and the value is not
constant it will be vary by file by file.
`My Approaches`:
use strict;
use warnings;
my $old_parameter='stack overfolw version';
my $new_parameter;
my $old_value={5};
my $new_value=' ';
my $filename ='input.txt'
open my $fh, "<", $filename or die "Couldn't open input file: $!";my file
while<FH>
{
if ($old_parameter) and ($old_value)
{
s/($old_value)/(new_value);
}
the above code will replace the value if the value is constant but if the
value is vary lets say (1--100) and also I want to do
replacement at one time all the line.
then what would be the best approach ?
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.