problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
How to speed up a .py script refering to millions of files? : <p>I have about 2.5M files to process with a .py script. </p>
<p>I'm using super calculator but I the problem is not the power, its the python process itself that open and close every time and loosing time.</p>
<p>I'm using a loop to get every files in a folder that I want to convert with the script. So the ${line} refers to a file where every line is referring to every files of the folder.</p>
<p>Is there a way to process all files after opening the .py script instead of looping the python script? </p>
<p>There is my loop code :</p>
<pre><code>### LOOP ###
while :
do
pythonsh ${RAMDISK}/script.py -l ${RAMDISK}/${line}.pdb -U '' -A hydrogens
done
exit
</code></pre>
<p>The python script is only a tool to convert .pdb to .pdbqt files that I've found from AutodockTools which comes with Autodock4.</p>
| 0debug |
Is this C# syntax correct? : Learning C#, found below code snippet.
What does below line means, which has the same name as a class? [see attached][1]
`public Item Parent;`
```
class Item
{
public string Name;
public Item Parent;
}
```
[1]: https://i.stack.imgur.com/cwFKG.png | 0debug |
i have set this funciton in one loop but issue is only work in first tiime : private static void SendMailTest()
{
var dto = qEmail.Dequeue();
if (dto.Attachment != null && dto.Attachment.Length > 0)
{
for (int i = 0; i < dto.Attachment.Length; i++)
{
if (dto.Attachment[i] != null)
{
MemoryStream ms = new MemoryStream();
dto.Attachment[i].ContentStream.CopyTo(ms);
byte[] byteArr = ms.ToArray();
ms.Flush();
ms.Dispose();
}
}
}
}
not working this second time not copy in dto.Attachment[i].ContentStream.CopyTo(ms); | 0debug |
mapping integers 1-max onto 100 integers from 1-1,000,000 : <p>I need to map a Java integer from the range 1-max to the range 1-1,000,000, but only using 100 particular (non-linear) values in the destination range. The 100 values are:<br>
1-10 (so the first 10 values map to themselves)<br>
then by 5's: 15, 20, 25 ... to 100<br>
then by 50's: 150, 200, 250 ... to 1,000<br>
and so on, the final values being 900,000 950,000 and 1,000,000<br>
I can't quite get my head around anything more elegant than a bag of nested if/else-if's.<br>
The solution is not time/cycle sensitive.</p>
| 0debug |
How to get row data in columns and column data in rows using pivot in sql 2008 r2 : [Current result which i am getting from my stored procedure][1]
[Expected result from current result][2]
[1]: http://i.stack.imgur.com/S8zxt.jpg
[2]: http://i.stack.imgur.com/L1OtK.jpg | 0debug |
void do_info_snapshots(Monitor *mon)
{
DriveInfo *dinfo;
BlockDriverState *bs, *bs1;
QEMUSnapshotInfo *sn_tab, *sn;
int nb_sns, i;
char buf[256];
bs = get_bs_snapshots();
if (!bs) {
monitor_printf(mon, "No available block device supports snapshots\n");
return;
}
monitor_printf(mon, "Snapshot devices:");
QTAILQ_FOREACH(dinfo, &drives, next) {
bs1 = dinfo->bdrv;
if (bdrv_has_snapshot(bs1)) {
if (bs == bs1)
monitor_printf(mon, " %s", bdrv_get_device_name(bs1));
}
}
monitor_printf(mon, "\n");
nb_sns = bdrv_snapshot_list(bs, &sn_tab);
if (nb_sns < 0) {
monitor_printf(mon, "bdrv_snapshot_list: error %d\n", nb_sns);
return;
}
monitor_printf(mon, "Snapshot list (from %s):\n",
bdrv_get_device_name(bs));
monitor_printf(mon, "%s\n", bdrv_snapshot_dump(buf, sizeof(buf), NULL));
for(i = 0; i < nb_sns; i++) {
sn = &sn_tab[i];
monitor_printf(mon, "%s\n", bdrv_snapshot_dump(buf, sizeof(buf), sn));
}
qemu_free(sn_tab);
}
| 1threat |
How to change port number of Appache server in ubuntu : I want to change my port number 80 to some other number of my Appache server . how it possible in ubuntu | 0debug |
Run python script from an android app : <p>i am creating an android app which basically asks a user to enter a product name and then returns the best deals available for that particular product.I wrote a python script to scrape various ecommerce websites and return various deals available. What will be the best way to run this script with the product name from the app?</p>
<p>I am planning on creating a REST aPI and integrate that with my app but how do i run a python script through a RESTApi?</p>
| 0debug |
What is the purpose of the "new" keyword in Java, PHP, etc.? : <p>In many languages, we use <code>new</code> to instantiate a new instance of a class. For example, in Java:</p>
<pre class="lang-java prettyprint-override"><code>class MyClass {
int number = 1;
MyClass(int n) {
self.number = n;
}
}
</code></pre>
<pre class="lang-java prettyprint-override"><code>MyClass obj1 = new MyClass(5);
</code></pre>
<p>However, as I've been using Python more and more, I've come to wonder why the <code>new</code> keyword is even necessary. In Python, we can simply do:</p>
<pre class="lang-py prettyprint-override"><code>class MyClass:
def __init__(self, n):
self.n = n
</code></pre>
<pre class="lang-py prettyprint-override"><code>obj1 = MyClass(5)
</code></pre>
<p>So, what's the purpose of the keyword? Is there some syntactic ambiguity that we resolve by using the keyword?</p>
| 0debug |
int64_t helper_fdtox(CPUSPARCState *env, float64 src)
{
int64_t ret;
clear_float_exceptions(env);
ret = float64_to_int64_round_to_zero(src, &env->fp_status);
check_ieee_exceptions(env);
return ret;
}
| 1threat |
image not displaying in ci : controller has index() method and display() method. Method index displays the image. and this method called display() doesn't display the images. Both methods are in same controller. Both methods are calling the same view file called $this->load->view('home/portfolio2');. index() method is displaying the image but display() method not displaying the image. Any advise, help will be more appreciated. | 0debug |
static void add_user_command(char *optarg)
{
cmdline = g_realloc(cmdline, ++ncmdline * sizeof(char *));
cmdline[ncmdline-1] = optarg;
}
| 1threat |
Create/append nested dictionary inside a dictionary in Python? : <p>How to append a dictionary?<br>
I tried <code>maindict[a] = m</code> and <code>maindict[a][x] = n</code>. It didnt work, I get <code>TypeError: list indices must be integers or slices, not str</code></p>
<pre><code>maindict =
{ 'a' : '',
'b' : '',
...
}
m =
{ 'x' : '',
'y' : ''}
n =
{ 'l' : '',
'm' : ''}
</code></pre>
<p>tobe</p>
<pre><code>maindict = { 'a' : { 'x' : { 'l' : '',
'm' : ''}, 'y' : ''},
'b' : '', ... }
</code></pre>
| 0debug |
Perl text::csv unknown variable : Here is an easy one.
I checked to documents, what is that in line 18 ? What kind of variable is @$row, is it the (default output) $_ of the TEXT::CSV getline function ?
1 #!/efs/dist/perl5/core/5.10/exec/bin/perl
2
3 use Text::CSV ;
4 use Time::Local ;
5
6 use strict ;
7 use warnings ;
8 my $file = "$ARGV[0]" ;
9
10 open my $fh, "<", $file or die "$file: $!" ;
11
12
13 my $csv = Text::CSV->new ({
14 binary => 1,
15 auto_diag => 1,
16 });
17 while (my $row = $csv->getline ($fh)) {
18 print "@$row\n" ;
19 } | 0debug |
static void check_guest_output(const testdef_t *test, int fd)
{
bool output_ok = false;
int i, nbr, pos = 0;
char ch;
for (i = 0; i < 6000; ++i) {
while ((nbr = read(fd, &ch, 1)) == 1) {
if (ch == test->expect[pos]) {
pos += 1;
if (test->expect[pos] == '\0') {
output_ok = true;
goto done;
}
} else {
pos = 0;
}
}
g_assert(nbr >= 0);
g_usleep(10000);
}
done:
g_assert(output_ok);
}
| 1threat |
static void qsv_uninit(AVCodecContext *s)
{
InputStream *ist = s->opaque;
QSVContext *qsv = ist->hwaccel_ctx;
av_freep(&qsv->ost->enc_ctx->hwaccel_context);
av_freep(&s->hwaccel_context);
av_buffer_unref(&qsv->opaque_surfaces_buf);
av_freep(&qsv->surface_used);
av_freep(&qsv->surface_ptrs);
av_freep(&qsv);
}
| 1threat |
Angular 2 Get current route : <p>So I need somehow check if I am on home page and do something and in other pages don't do that. Also that component imported on all of pages.</p>
<p>How can I detect on that component if I'm on home page???</p>
<p>Thanks</p>
| 0debug |
Determining the number of times a substring occurs in a string : <p>I have a string "ABChi hi" and I would like to write a program to determine the number of times the substring "hi" occurs in the main string. So far, my code looks like this:</p>
<pre><code> the_word = "ABChi hi"
new_word = the_word.split()
count = 0
for i in new_word:
if i == "hi":
count += 1
</code></pre>
<p>The problem is that when I split the string, I get </p>
<pre><code> ["ABChi", "hi"]
</code></pre>
<p>which will only help me count one of the two hi's that occur, although the correct answer is 2. Does anyone have any ideas on how to obtain the correct answer?</p>
| 0debug |
def substract_elements(test_tup1, test_tup2):
res = tuple(map(lambda i, j: i - j, test_tup1, test_tup2))
return (res) | 0debug |
static int build_filter(ResampleContext *c, void *filter, double factor, int tap_count, int alloc, int phase_count, int scale,
int filter_type, int kaiser_beta){
int ph, i;
double x, y, w;
double *tab = av_malloc_array(tap_count+1, sizeof(*tab));
const int center= (tap_count-1)/2;
if (!tab)
return AVERROR(ENOMEM);
if (factor > 1.0)
factor = 1.0;
av_assert0(phase_count == 1 || phase_count % 2 == 0);
for(ph = 0; ph <= phase_count / 2; ph++) {
double norm = 0;
for(i=0;i<=tap_count;i++) {
x = M_PI * ((double)(i - center) - (double)ph / phase_count) * factor;
if (x == 0) y = 1.0;
else y = sin(x) / x;
switch(filter_type){
case SWR_FILTER_TYPE_CUBIC:{
const float d= -0.5;
x = fabs(((double)(i - center) - (double)ph / phase_count) * factor);
if(x<1.0) y= 1 - 3*x*x + 2*x*x*x + d*( -x*x + x*x*x);
else y= d*(-4 + 8*x - 5*x*x + x*x*x);
break;}
case SWR_FILTER_TYPE_BLACKMAN_NUTTALL:
w = 2.0*x / (factor*tap_count) + M_PI;
y *= 0.3635819 - 0.4891775 * cos(w) + 0.1365995 * cos(2*w) - 0.0106411 * cos(3*w);
break;
case SWR_FILTER_TYPE_KAISER:
w = 2.0*x / (factor*tap_count*M_PI);
y *= bessel(kaiser_beta*sqrt(FFMAX(1-w*w, 0)));
break;
default:
av_assert0(0);
}
tab[i] = y;
if (i < tap_count)
norm += y;
}
switch(c->format){
case AV_SAMPLE_FMT_S16P:
for(i=0;i<tap_count;i++)
((int16_t*)filter)[ph * alloc + i] = av_clip(lrintf(tab[i] * scale / norm), INT16_MIN, INT16_MAX);
if (tap_count % 2 == 0) {
for (i = 0; i < tap_count; i++)
((int16_t*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((int16_t*)filter)[ph * alloc + i];
}
else {
for (i = 1; i <= tap_count; i++)
((int16_t*)filter)[(phase_count-ph) * alloc + tap_count-i] =
av_clip(lrintf(tab[i] * scale / (norm - tab[0] + tab[tap_count])), INT16_MIN, INT16_MAX);
}
break;
case AV_SAMPLE_FMT_S32P:
for(i=0;i<tap_count;i++)
((int32_t*)filter)[ph * alloc + i] = av_clipl_int32(llrint(tab[i] * scale / norm));
if (tap_count % 2 == 0) {
for (i = 0; i < tap_count; i++)
((int32_t*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((int32_t*)filter)[ph * alloc + i];
}
else {
for (i = 1; i <= tap_count; i++)
((int32_t*)filter)[(phase_count-ph) * alloc + tap_count-i] =
av_clipl_int32(llrint(tab[i] * scale / (norm - tab[0] + tab[tap_count])));
}
break;
case AV_SAMPLE_FMT_FLTP:
for(i=0;i<tap_count;i++)
((float*)filter)[ph * alloc + i] = tab[i] * scale / norm;
if (tap_count % 2 == 0) {
for (i = 0; i < tap_count; i++)
((float*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((float*)filter)[ph * alloc + i];
}
else {
for (i = 1; i <= tap_count; i++)
((float*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / (norm - tab[0] + tab[tap_count]);
}
break;
case AV_SAMPLE_FMT_DBLP:
for(i=0;i<tap_count;i++)
((double*)filter)[ph * alloc + i] = tab[i] * scale / norm;
if (tap_count % 2 == 0) {
for (i = 0; i < tap_count; i++)
((double*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((double*)filter)[ph * alloc + i];
}
else {
for (i = 1; i <= tap_count; i++)
((double*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / (norm - tab[0] + tab[tap_count]);
}
break;
}
}
#if 0
{
#define LEN 1024
int j,k;
double sine[LEN + tap_count];
double filtered[LEN];
double maxff=-2, minff=2, maxsf=-2, minsf=2;
for(i=0; i<LEN; i++){
double ss=0, sf=0, ff=0;
for(j=0; j<LEN+tap_count; j++)
sine[j]= cos(i*j*M_PI/LEN);
for(j=0; j<LEN; j++){
double sum=0;
ph=0;
for(k=0; k<tap_count; k++)
sum += filter[ph * tap_count + k] * sine[k+j];
filtered[j]= sum / (1<<FILTER_SHIFT);
ss+= sine[j + center] * sine[j + center];
ff+= filtered[j] * filtered[j];
sf+= sine[j + center] * filtered[j];
}
ss= sqrt(2*ss/LEN);
ff= sqrt(2*ff/LEN);
sf= 2*sf/LEN;
maxff= FFMAX(maxff, ff);
minff= FFMIN(minff, ff);
maxsf= FFMAX(maxsf, sf);
minsf= FFMIN(minsf, sf);
if(i%11==0){
av_log(NULL, AV_LOG_ERROR, "i:%4d ss:%f ff:%13.6e-%13.6e sf:%13.6e-%13.6e\n", i, ss, maxff, minff, maxsf, minsf);
minff=minsf= 2;
maxff=maxsf= -2;
}
}
}
#endif
av_free(tab);
return 0;
}
| 1threat |
What is faster in C#, an if statement, or a virtual function call to a function that does nothing? And why? : <p>Say you have a class called <code>MyClass</code> which has a certain behavior encapsulated using a reference (<code>myBehavior</code>) to another class called <code>Behavior</code>. By default <code>MyClass</code> should have no behavior.</p>
<p>For instances which hadn't set <code>myBehavior</code> to anything after it was initialized - Would it be more speed efficient if <code>myBehavior</code> was initialized to <code>null</code>, and each time it was needed checked with <code>if(myBehavior)</code> or would it be faster if it were initialized to an instance of a <code>NullBehavior</code>, derived from <code>Behavior</code>, which does nothing? and why?</p>
<pre><code>class MyClass
{
Behavior myBehavior = null;
void doSomething()
{
if(myBehavior)
{
myBehavior.performAction();
}
}
}
</code></pre>
<p>or:</p>
<pre><code>class NullBehavior : Behavior
{
override void performAction()
{
// don't do anything
}
}
class MyClass
{
Behavior myBehavior = new NullBehavior(); // or equals some static universal instance of NullBehavior
void doSomething()
{
myBehavior.performAction();
}
}
</code></pre>
| 0debug |
static void qxl_check_state(PCIQXLDevice *d)
{
QXLRam *ram = d->ram;
assert(SPICE_RING_IS_EMPTY(&ram->cmd_ring));
assert(SPICE_RING_IS_EMPTY(&ram->cursor_ring));
}
| 1threat |
Select top 5 records of each group in MYSQL : <p>I am trying to fetch a grouped result, with only top 5 rows for each group.. Confused how to do it..</p>
<p>Here's the query:</p>
<pre><code>SELECT O.rest_brId as BRID, O.`reason` as REASON , count(O.reason) as
OCCURENCES
FROM orders O
WHERE O.status = 4
GROUP BY BRID, REASON
HAVING count(O.reason)
</code></pre>
<p>There current result is :
<a href="https://i.stack.imgur.com/LVvZT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LVvZT.png" alt="result"></a></p>
<p>What I want is that every BRID to have <= 5 rows, with TOP 5 MAX no. of OCCURENCES</p>
<p>How to do? Googled, but got confused.</p>
| 0debug |
Java Swing - Localize Temperature : <p>Is there a way to localize Temperature in Java? Like temperature format will be based on the locale?</p>
<p>Because for example, for Norwegian language temperature format should be 14 °C. There should be a space before degrees symbol. But other languages should be 14°C.</p>
| 0debug |
How to control the printwriter from a separate method : Im working on building my own GUI program that talks to my pc from a tablet. I have the server side done in java but my problem is on the client side.
I want to send data out the PrintWriter to the server from a separate method.
I have accomplished sending in the code below (it sends 'a') but i cant figure out how to send it from a separate method. i believe its a basic java scope problem that im not understanding. i would really appreciate the help.
I have tried moving the variables into other scopes.
import java.io.*;
import java.net.*;
public class TestClient {
public static void main(String[] args) {
String hostName = "192.168.0.3";
int portNumber = 6666;
try ( //Connect to server on chosen port.
Socket connectedSocket = new Socket(hostName, portNumber);
//Create a printWriter so send data to server.
PrintWriter dataOut = new PrintWriter(connectedSocket.getOutputStream(), true);
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in))
)
{
//Send data to server.
dataOut.println("a");
}catch (UnknownHostException e) {
System.err.println("Don't know about host " + hostName);
System.exit(1);
} catch (IOException e) {
System.err.println("Couldn't get I/O for the connection to " +
hostName);
System.exit(1);
}
}
public static void sendToServer() {
//I want to control the print writer from this method.
//I have failed i all the ways i have tried.
}
}
| 0debug |
static int init_context_frame(MpegEncContext *s)
{
int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;
s->mb_width = (s->width + 15) / 16;
s->mb_stride = s->mb_width + 1;
s->b8_stride = s->mb_width * 2 + 1;
s->b4_stride = s->mb_width * 4 + 1;
mb_array_size = s->mb_height * s->mb_stride;
mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;
s->h_edge_pos = s->mb_width * 16;
s->v_edge_pos = s->mb_height * 16;
s->mb_num = s->mb_width * s->mb_height;
s->block_wrap[0] =
s->block_wrap[1] =
s->block_wrap[2] =
s->block_wrap[3] = s->b8_stride;
s->block_wrap[4] =
s->block_wrap[5] = s->mb_stride;
y_size = s->b8_stride * (2 * s->mb_height + 1);
c_size = s->mb_stride * (s->mb_height + 1);
yc_size = y_size + 2 * c_size;
if (s->mb_height & 1)
yc_size += 2*s->b8_stride + 2*s->mb_stride;
FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int), fail);
for (y = 0; y < s->mb_height; y++)
for (x = 0; x < s->mb_width; x++)
s->mb_index2xy[x + y * s->mb_width] = x + y * s->mb_stride;
s->mb_index2xy[s->mb_height * s->mb_width] = (s->mb_height - 1) * s->mb_stride + s->mb_width;
if (s->encoding) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail)
s->p_mv_table = s->p_mv_table_base + s->mb_stride + 1;
s->b_forw_mv_table = s->b_forw_mv_table_base + s->mb_stride + 1;
s->b_back_mv_table = s->b_back_mv_table_base + s->mb_stride + 1;
s->b_bidir_forw_mv_table = s->b_bidir_forw_mv_table_base + s->mb_stride + 1;
s->b_bidir_back_mv_table = s->b_bidir_back_mv_table_base + s->mb_stride + 1;
s->b_direct_mv_table = s->b_direct_mv_table_base + s->mb_stride + 1;
FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_type, mb_array_size * sizeof(uint16_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->lambda_table, mb_array_size * sizeof(int), fail)
FF_ALLOC_OR_GOTO(s->avctx, s->cplx_tab,
mb_array_size * sizeof(float), fail);
FF_ALLOC_OR_GOTO(s->avctx, s->bits_tab,
mb_array_size * sizeof(float), fail);
}
if (s->codec_id == AV_CODEC_ID_MPEG4 ||
(s->flags & CODEC_FLAG_INTERLACED_ME)) {
for (i = 0; i < 2; i++) {
int j, k;
for (j = 0; j < 2; j++) {
for (k = 0; k < 2; k++) {
FF_ALLOCZ_OR_GOTO(s->avctx,
s->b_field_mv_table_base[i][j][k],
mv_table_size * 2 * sizeof(int16_t),
fail);
s->b_field_mv_table[i][j][k] = s->b_field_mv_table_base[i][j][k] +
s->mb_stride + 1;
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->b_field_select_table [i][j], mb_array_size * 2 * sizeof(uint8_t), fail)
FF_ALLOCZ_OR_GOTO(s->avctx, s->p_field_mv_table_base[i][j], mv_table_size * 2 * sizeof(int16_t), fail)
s->p_field_mv_table[i][j] = s->p_field_mv_table_base[i][j] + s->mb_stride + 1;
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->p_field_select_table[i], mb_array_size * 2 * sizeof(uint8_t), fail)
}
}
if (s->out_format == FMT_H263) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->coded_block_base, y_size + (s->mb_height&1)*2*s->b8_stride, fail);
s->coded_block = s->coded_block_base + s->b8_stride + 1;
FF_ALLOCZ_OR_GOTO(s->avctx, s->cbp_table , mb_array_size * sizeof(uint8_t), fail);
FF_ALLOCZ_OR_GOTO(s->avctx, s->pred_dir_table, mb_array_size * sizeof(uint8_t), fail);
}
if (s->h263_pred || s->h263_plus || !s->encoding) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->dc_val_base, yc_size * sizeof(int16_t), fail);
s->dc_val[0] = s->dc_val_base + s->b8_stride + 1;
s->dc_val[1] = s->dc_val_base + y_size + s->mb_stride + 1;
s->dc_val[2] = s->dc_val[1] + c_size;
for (i = 0; i < yc_size; i++)
s->dc_val_base[i] = 1024;
}
FF_ALLOCZ_OR_GOTO(s->avctx, s->mbintra_table, mb_array_size, fail);
memset(s->mbintra_table, 1, mb_array_size);
FF_ALLOCZ_OR_GOTO(s->avctx, s->mbskip_table, mb_array_size + 2, fail);
return init_er(s);
fail:
return AVERROR(ENOMEM);
}
| 1threat |
Trying to get a simple php form to fire : <p>I shouldnt even be in HTML/CSS, but here I am trying to incorporate a php modal contact form into my site...</p>
<p>I'm trying to get all of a demo form's functionality into my footer page (and then I'll restyle everything.)</p>
<p><a href="http://danux.me/sections/footer_modal.html" rel="nofollow noreferrer">http://danux.me/sections/footer_modal.html</a></p>
<p>I'm trying to get "email me" to fire ideally, but am settling now for just the Demo button to fire the popup form.</p>
<p>I also uploaded the demo form I'm pulling code from, just to make sure it works on my site. (It does.)</p>
<p><a href="http://danux.me/contact/" rel="nofollow noreferrer">http://danux.me/contact/</a></p>
<p>Any guesses as to what I'm doing wrong?</p>
| 0debug |
static void cpu_exec_step(CPUState *cpu)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
TranslationBlock *tb;
target_ulong cs_base, pc;
uint32_t flags;
uint32_t cflags = 1 | CF_IGNORE_ICOUNT;
if (sigsetjmp(cpu->jmp_env, 0) == 0) {
tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags,
cflags & CF_HASH_MASK);
if (tb == NULL) {
mmap_lock();
tb_lock();
tb = tb_gen_code(cpu, pc, cs_base, flags, cflags);
tb_unlock();
mmap_unlock();
}
cc->cpu_exec_enter(cpu);
trace_exec_tb(tb, pc);
cpu_tb_exec(cpu, tb);
cc->cpu_exec_exit(cpu);
} else {
#ifndef CONFIG_SOFTMMU
tcg_debug_assert(!have_mmap_lock());
#endif
tb_lock_reset();
}
}
| 1threat |
replace sub string with conditions vba : hoping you can help me out with a bit of vba code i cant seem to make work. been using stackoverflow to help me create some simple macros but this one is a bit more complicated and i suck
the goal is to search thru a excel file with strings in column A and replace a part of a string if a couple of conditions exist.
logically: if NAME and CODE(A) or CODE(B) exist in string then replace NAME
example: NAME = child1in CODE(A) = csus CODE(B) = mfus
- note: there are several names that need to be replaced but the codes are the same
TIA!
here is my code:
________________________
`Sub replacement_TEST()
Dim rows As Integer
Dim cellvalue As String
Dim Newcellvalue As String
rows = ActiveSheet.UsedRange.rows.Count
For i = 1 To rows
cellvalue = ActiveSheet.Cells(i, 1).value
eqcode = "csus"
acct1 = "child1in"
If acct1 = "child1in" And (eqcode = "csus" Or eqcode = "mfus") Then
Newcellvalue = Replace(cellvalue, "child1in", "child1")
ElseIf acct1 = "wstre2in" And (eqcode = "csus" Or eqcode = "mfus") Then
Newcellvalue = Replace(Newcellvalue, "wstre2in", "wstre2lv")
ElseIf acct1 = "wstrebin" And (eqcode = "csus" Or eqcode = "mfus") Then
Newcellvalue = Replace(Newcellvalue, "wstrebin", "wstrebal")
ElseIf acct1 = "lrcfbag" And (eqcode = "csus" Or eqcode = "mfus") Then
Newcellvalue = Replace(Newcellvalue, "lrcfbag", "lrcfbal")
ElseIf acct1 = "wstpsbst" And (eqcode = "csus" Or eqcode = "mfus") Then
Newcellvalue = Replace(Newcellvalue, "wstpsbst", "wstpsbal"
End If
End If
End Sub` | 0debug |
Elasticsearch 6: Rejecting mapping update as the final mapping would have more than 1 type : <p>I'm trying to convert a project to use the latest Elasticsearch 6 and am having this problem. I don't know if the problem is "Product" vs "product". In my mappings and attributes I specify "products", so I am not sure why I get this error when I try to index a product.</p>
<p>Error:</p>
<blockquote>
<p>Invalid NEST response built from a unsuccessful low level call on PUT:
/products/products/1?pretty=true&error_trace=true</p>
<p>"Rejecting mapping update to [products] as the final mapping would
have more than 1 type: [Product, products]"</p>
</blockquote>
<p>Request:</p>
<pre><code>{
"id": 1,
"warehouseId": 0,
"productStatus": 1,
"sku": "102377",
"name": "Name",
"shortDescription": "Description",
"longDescription": "Description",
"price": 37.3200
}
</code></pre>
<p>My code:</p>
<pre><code> [ElasticsearchType(Name = "products")]
public class Product : BaseEntity
{
[Key]
public int Id { get; set; }
public int WarehouseId { get; set; }
[Display(Name = "Product Status")]
public Enums.ProductStatus ProductStatus { get; set; }
[Required, StringLength(10)]
public string Sku { get; set; }
[Required, StringLength(200)]
public string Name { get; set; }
[StringLength(500), Display(Name = "Short Description")]
public string ShortDescription { get; set; }
[DataType(DataType.MultilineText), Display(Name = "Long Description")]
public string LongDescription { get; set; }
[Column(TypeName ="Money")]
public Nullable<decimal> Price { get; set; }
}
connection.DefaultMappingFor<Product>(m => m.IndexName("products"));
</code></pre>
| 0debug |
static void onenand_reset(OneNANDState *s, int cold)
{
memset(&s->addr, 0, sizeof(s->addr));
s->command = 0;
s->count = 1;
s->bufaddr = 0;
s->config[0] = 0x40c0;
s->config[1] = 0x0000;
onenand_intr_update(s);
qemu_irq_raise(s->rdy);
s->status = 0x0000;
s->intstatus = cold ? 0x8080 : 0x8010;
s->unladdr[0] = 0;
s->unladdr[1] = 0;
s->wpstatus = 0x0002;
s->cycle = 0;
s->otpmode = 0;
s->blk_cur = s->blk;
s->current = s->image;
s->secs_cur = s->secs;
if (cold) {
memset(s->blockwp, ONEN_LOCK_LOCKED, s->blocks);
if (s->blk_cur && blk_read(s->blk_cur, 0, s->boot[0], 8) < 0) {
hw_error("%s: Loading the BootRAM failed.\n", __func__);
}
}
}
| 1threat |
Difference between pip3 and `python3 setup.py install` regarding cmdclass argument : <p>I tried to configure my package such that a script is executed on the installation process. Therefore, I inherited from setuptools.command install and created my custom class <code>ActionOnInstall</code> to do stuff when package is installed. This class is called via setuptools <code>setup()</code> argument <code>cmdclass</code> as described <a href="https://cbuelter.wordpress.com/2015/10/25/extend-the-setuptools-install-command/comment-page-1/" rel="noreferrer">here</a>.</p>
<p>A minimal example of such a setup.py file looks like</p>
<pre><code>from setuptools import find_packages, setup
from setuptools.command.install import install
class ActionOnInstall(install):
def run(self):
print("Call install.run(self) works!")
install.run(self)
setup(name='name',
cmdclass={
'install': ActionOnInstall})
</code></pre>
<p>Building the package by executing </p>
<pre><code>pip3 install <path-to-dir-with-setup.py>
</code></pre>
<p>runs successfully but does not execute commands specified in <code>ActionOnInstall.run()</code>. More directly calling this setup.py by </p>
<pre><code>python3 setup.py install
</code></pre>
<p>executes commands specified in <code>ActionOnInstall.run()</code>.</p>
<p>Then, I found myself asking: what is the actual difference of these both approaches to install a package. I know, like other posts tell us, pip makes life easier regarding package installation. But how these both approaches treat the <code>cmdclass</code> argument of <code>setup()</code> differently is not explained. Thus, I would highly appreciate to hear from you guys.</p>
| 0debug |
static void decode_bo_addrmode_post_pre_base(CPUTriCoreState *env,
DisasContext *ctx)
{
uint32_t op2;
uint32_t off10;
int32_t r1, r2;
TCGv temp;
r1 = MASK_OP_BO_S1D(ctx->opcode);
r2 = MASK_OP_BO_S2(ctx->opcode);
off10 = MASK_OP_BO_OFF10_SEXT(ctx->opcode);
op2 = MASK_OP_BO_OP2(ctx->opcode);
switch (op2) {
case OPC2_32_BO_CACHEA_WI_SHORTOFF:
case OPC2_32_BO_CACHEA_W_SHORTOFF:
case OPC2_32_BO_CACHEA_I_SHORTOFF:
break;
case OPC2_32_BO_CACHEA_WI_POSTINC:
case OPC2_32_BO_CACHEA_W_POSTINC:
case OPC2_32_BO_CACHEA_I_POSTINC:
tcg_gen_addi_tl(cpu_gpr_a[r2], cpu_gpr_a[r2], off10);
break;
case OPC2_32_BO_CACHEA_WI_PREINC:
case OPC2_32_BO_CACHEA_W_PREINC:
case OPC2_32_BO_CACHEA_I_PREINC:
tcg_gen_addi_tl(cpu_gpr_a[r2], cpu_gpr_a[r2], off10);
break;
case OPC2_32_BO_CACHEI_WI_SHORTOFF:
case OPC2_32_BO_CACHEI_W_SHORTOFF:
break;
case OPC2_32_BO_CACHEI_W_POSTINC:
case OPC2_32_BO_CACHEI_WI_POSTINC:
if (tricore_feature(env, TRICORE_FEATURE_131)) {
tcg_gen_addi_tl(cpu_gpr_a[r2], cpu_gpr_a[r2], off10);
}
break;
case OPC2_32_BO_CACHEI_W_PREINC:
case OPC2_32_BO_CACHEI_WI_PREINC:
if (tricore_feature(env, TRICORE_FEATURE_131)) {
tcg_gen_addi_tl(cpu_gpr_a[r2], cpu_gpr_a[r2], off10);
}
break;
case OPC2_32_BO_ST_A_SHORTOFF:
gen_offset_st(ctx, cpu_gpr_a[r1], cpu_gpr_a[r2], off10, MO_LESL);
break;
case OPC2_32_BO_ST_A_POSTINC:
tcg_gen_qemu_st_tl(cpu_gpr_a[r1], cpu_gpr_a[r2], ctx->mem_idx,
MO_LESL);
tcg_gen_addi_tl(cpu_gpr_a[r2], cpu_gpr_a[r2], off10);
break;
case OPC2_32_BO_ST_A_PREINC:
gen_st_preincr(ctx, cpu_gpr_a[r1], cpu_gpr_a[r2], off10, MO_LESL);
break;
case OPC2_32_BO_ST_B_SHORTOFF:
gen_offset_st(ctx, cpu_gpr_d[r1], cpu_gpr_a[r2], off10, MO_UB);
break;
case OPC2_32_BO_ST_B_POSTINC:
tcg_gen_qemu_st_tl(cpu_gpr_d[r1], cpu_gpr_a[r2], ctx->mem_idx,
MO_UB);
tcg_gen_addi_tl(cpu_gpr_a[r2], cpu_gpr_a[r2], off10);
break;
case OPC2_32_BO_ST_B_PREINC:
gen_st_preincr(ctx, cpu_gpr_d[r1], cpu_gpr_a[r2], off10, MO_UB);
break;
case OPC2_32_BO_ST_D_SHORTOFF:
gen_offset_st_2regs(cpu_gpr_d[r1+1], cpu_gpr_d[r1], cpu_gpr_a[r2],
off10, ctx);
break;
case OPC2_32_BO_ST_D_POSTINC:
gen_st_2regs_64(cpu_gpr_d[r1+1], cpu_gpr_d[r1], cpu_gpr_a[r2], ctx);
tcg_gen_addi_tl(cpu_gpr_a[r2], cpu_gpr_a[r2], off10);
break;
case OPC2_32_BO_ST_D_PREINC:
temp = tcg_temp_new();
tcg_gen_addi_tl(temp, cpu_gpr_a[r2], off10);
gen_st_2regs_64(cpu_gpr_d[r1+1], cpu_gpr_d[r1], temp, ctx);
tcg_gen_mov_tl(cpu_gpr_a[r2], temp);
tcg_temp_free(temp);
break;
case OPC2_32_BO_ST_DA_SHORTOFF:
gen_offset_st_2regs(cpu_gpr_a[r1+1], cpu_gpr_a[r1], cpu_gpr_a[r2],
off10, ctx);
break;
case OPC2_32_BO_ST_DA_POSTINC:
gen_st_2regs_64(cpu_gpr_a[r1+1], cpu_gpr_a[r1], cpu_gpr_a[r2], ctx);
tcg_gen_addi_tl(cpu_gpr_a[r2], cpu_gpr_a[r2], off10);
break;
case OPC2_32_BO_ST_DA_PREINC:
temp = tcg_temp_new();
tcg_gen_addi_tl(temp, cpu_gpr_a[r2], off10);
gen_st_2regs_64(cpu_gpr_a[r1+1], cpu_gpr_a[r1], temp, ctx);
tcg_gen_mov_tl(cpu_gpr_a[r2], temp);
tcg_temp_free(temp);
break;
case OPC2_32_BO_ST_H_SHORTOFF:
gen_offset_st(ctx, cpu_gpr_d[r1], cpu_gpr_a[r2], off10, MO_LEUW);
break;
case OPC2_32_BO_ST_H_POSTINC:
tcg_gen_qemu_st_tl(cpu_gpr_d[r1], cpu_gpr_a[r2], ctx->mem_idx,
MO_LEUW);
tcg_gen_addi_tl(cpu_gpr_a[r2], cpu_gpr_a[r2], off10);
break;
case OPC2_32_BO_ST_H_PREINC:
gen_st_preincr(ctx, cpu_gpr_d[r1], cpu_gpr_a[r2], off10, MO_LEUW);
break;
case OPC2_32_BO_ST_Q_SHORTOFF:
temp = tcg_temp_new();
tcg_gen_shri_tl(temp, cpu_gpr_d[r1], 16);
gen_offset_st(ctx, temp, cpu_gpr_a[r2], off10, MO_LEUW);
tcg_temp_free(temp);
break;
case OPC2_32_BO_ST_Q_POSTINC:
temp = tcg_temp_new();
tcg_gen_shri_tl(temp, cpu_gpr_d[r1], 16);
tcg_gen_qemu_st_tl(temp, cpu_gpr_a[r2], ctx->mem_idx,
MO_LEUW);
tcg_gen_addi_tl(cpu_gpr_a[r2], cpu_gpr_a[r2], off10);
tcg_temp_free(temp);
break;
case OPC2_32_BO_ST_Q_PREINC:
temp = tcg_temp_new();
tcg_gen_shri_tl(temp, cpu_gpr_d[r1], 16);
gen_st_preincr(ctx, temp, cpu_gpr_a[r2], off10, MO_LEUW);
tcg_temp_free(temp);
break;
case OPC2_32_BO_ST_W_SHORTOFF:
gen_offset_st(ctx, cpu_gpr_d[r1], cpu_gpr_a[r2], off10, MO_LEUL);
break;
case OPC2_32_BO_ST_W_POSTINC:
tcg_gen_qemu_st_tl(cpu_gpr_d[r1], cpu_gpr_a[r2], ctx->mem_idx,
MO_LEUL);
tcg_gen_addi_tl(cpu_gpr_a[r2], cpu_gpr_a[r2], off10);
break;
case OPC2_32_BO_ST_W_PREINC:
gen_st_preincr(ctx, cpu_gpr_d[r1], cpu_gpr_a[r2], off10, MO_LEUL);
break;
}
}
| 1threat |
How to create this layout using LinearLayout? : <p>I want to construct below layout using LinearLayout.
<a href="https://i.stack.imgur.com/AqBgH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AqBgH.png" alt="enter image description here"></a>
I created that using ConstraintLayout,but it was too long for me. And now I am wondering how this layout could be created via LinearLayout? Is it possible? And also pictures have to have their own size,because I suppose that if it is match_parent or wrap_content,quality of image will be bad. This is how I tried to construct via LinearLayout,but result is too different. So,what I have to do? </p>
<pre><code> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.abay.myeleven.MyTeamActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/attacks"
android:orientation="horizontal"
android:layout_marginTop="25dp"
android:layout_weight="1"
>
<ImageButton
android:layout_width="@dimen/player_width"
android:layout_height="@dimen/player_height"
android:src="@drawable/player_default"
android:layout_weight="1"
android:background="#FFF"
/>
<ImageButton
android:layout_width="@dimen/player_width"
android:layout_height="@dimen/player_height"
android:src="@drawable/player_default"
android:layout_weight="1"
android:background="#FFF"
/>
<ImageButton
android:layout_width="@dimen/player_width"
android:layout_height="@dimen/player_height"
android:src="@drawable/player_default"
android:layout_weight="1"
android:background="#FFF"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/midfields"
android:orientation="horizontal"
android:layout_marginTop="25dp"
android:layout_weight="1"
>
<ImageButton
android:layout_width="@dimen/player_width"
android:layout_height="@dimen/player_height"
android:src="@drawable/player_default"
android:layout_weight="1"
android:background="#FFF"
/>
<ImageButton
android:layout_width="@dimen/player_width"
android:layout_height="@dimen/player_height"
android:src="@drawable/player_default"
android:layout_weight="1"
android:background="#FFF"
/>
<ImageButton
android:layout_width="@dimen/player_width"
android:layout_height="@dimen/player_height"
android:src="@drawable/player_default"
android:layout_weight="1"
android:background="#FFF"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/defenders"
android:orientation="horizontal"
android:layout_marginTop="25dp"
android:layout_weight="1"
>
<ImageButton
android:layout_width="@dimen/player_width"
android:layout_height="@dimen/player_height"
android:src="@drawable/player_default"
android:layout_weight="1"
android:background="#FFF"
/>
<ImageButton
android:layout_width="@dimen/player_width"
android:layout_height="@dimen/player_height"
android:src="@drawable/player_default"
android:layout_weight="1"
android:background="#FFF"
/>
<ImageButton
android:layout_width="@dimen/player_width"
android:layout_height="@dimen/player_height"
android:src="@drawable/player_default"
android:layout_weight="1"
android:background="#FFF"
/>
<ImageButton
android:layout_width="@dimen/player_width"
android:layout_height="@dimen/player_height"
android:src="@drawable/player_default"
android:layout_weight="1"
android:background="#FFF"
/>
</LinearLayout>
<ImageButton
android:layout_width="@dimen/player_width"
android:layout_height="@dimen/player_height"
android:src="@drawable/player_default"
android:layout_weight="1"
android:background="#FFF"
android:layout_gravity="center"
/>
</LinearLayout>
</code></pre>
| 0debug |
Printing a char in C with printf wont print : <p>I have the following code: </p>
<pre><code>#include <stdio.h>
#include <string.h>
int main(void)
{
char buff[50];
int pass = 0;
printf("\n Enter the password : \n");
gets(buff);
char str[80];
strcat(str, "nw");
strcat(str, "ww");
strcat(str, "io");
strcat(str, "oi");
char str2[22];
strcat(str2, "jm");
strcat(str2, "qw");
strcat(str2, "ef");
strcat(str2, "io");
strcat(str2, "nw");
strcat(str2, "ce");
strcat(str2, "or");
strcat(str2, "ww");
strcat(str2, "qf");
strcat(str2, "ej");
strcat(str2, "oi");
if(strcmp(buff, str))
{
/* we sf as df er fd xc yyu er we nm hj ui ty as asd qwe er t yu as sd df rt ty qw sd password */
printf ("\n Wrong Password \n");
}
else
{
printf ("\n Correct Password \n");
pass = 1;
}
if(pass)
{
printf ("\n\n\n\n\n\n\n%s", str2);
}
return 0;
}
</code></pre>
<p>When I run it I get: </p>
<pre><code>root@images:~# ./root.flag
Enter the password :
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Wrong Password
Segmentation fault (core dumped)
</code></pre>
<p>It prints the newline characters but not the value store in str2. How do I get str2 to print to the screen? Im fairly new to C so I have no clue why this is not working. It is likely something simple that I am overlooking.</p>
| 0debug |
Keras conv1d layer parameters: filters and kernel_size : <p>I am very confused by these two parameters in the conv1d layer from keras:
<a href="https://keras.io/layers/convolutional/#conv1d" rel="noreferrer">https://keras.io/layers/convolutional/#conv1d</a></p>
<p>the documentation says:</p>
<pre><code>filters: Integer, the dimensionality of the output space (i.e. the number output of filters in the convolution).
kernel_size: An integer or tuple/list of a single integer, specifying the length of the 1D convolution window.
</code></pre>
<p>But that does not seem to relate to the standard terminologies I see on many tutorials such as <a href="https://adeshpande3.github.io/adeshpande3.github.io/A-Beginner" rel="noreferrer">https://adeshpande3.github.io/adeshpande3.github.io/A-Beginner</a>'s-Guide-To-Understanding-Convolutional-Neural-Networks/ and <a href="https://machinelearningmastery.com/sequence-classification-lstm-recurrent-neural-networks-python-keras/" rel="noreferrer">https://machinelearningmastery.com/sequence-classification-lstm-recurrent-neural-networks-python-keras/</a></p>
<p>Using the second tutorial link which uses Keras, I'd imagine that in fact 'kernel_size' is relevant to the conventional 'filter' concept which defines the sliding window on the input feature space. But what about the 'filter' parameter in conv1d? What does it do? </p>
<p>For example, in the following code snippet:</p>
<pre><code>model.add(embedding_layer)
model.add(Dropout(0.2))
model.add(Conv1D(filters=100, kernel_size=4, padding='same', activation='relu'))
</code></pre>
<p>suppose the embedding layer outputs a matrix of dimension 50 (rows, each row is a word in a sentence) x 300 (columns, the word vector dimension), how does the conv1d layer transforms that matrix?</p>
<p>Many thanks</p>
| 0debug |
static uint64_t qemu_next_deadline_dyntick(void)
{
int64_t delta;
int64_t rtdelta;
if (use_icount)
delta = INT32_MAX;
else
delta = (qemu_next_deadline() + 999) / 1000;
if (active_timers[QEMU_TIMER_REALTIME]) {
rtdelta = (active_timers[QEMU_TIMER_REALTIME]->expire_time -
qemu_get_clock(rt_clock))*1000;
if (rtdelta < delta)
delta = rtdelta;
}
if (delta < MIN_TIMER_REARM_US)
delta = MIN_TIMER_REARM_US;
return delta;
}
| 1threat |
Code for copy data using VbA code in excel : Can someone please help me to how to code for below snapshots :
[Input][1]
[Output][2]
[1]: https://i.stack.imgur.com/AgX6l.jpg
[2]: https://i.stack.imgur.com/spTJ2.jpg | 0debug |
how to convert string to array in ios? : I have get a response from server like following link.
http://paste.ofcode.org/NhBN7HVALRg9DjjucD9xmK
NSString *strdetails = [NSString stringWithFormat:@"%@",[[products objectAtIndex:i] valueForKey:@"details"]];
NSLog(@"%@",strdetails);
string display like following link...when i add on array but it's convert to previous data
http://paste.ofcode.org/35zHDmBWqAERKAJ47V6scJ9
but I want array not string.
please help me.
| 0debug |
static ssize_t test_block_read_func(QCryptoBlock *block,
size_t offset,
uint8_t *buf,
size_t buflen,
Error **errp,
void *opaque)
{
Buffer *header = opaque;
g_assert_cmpint(offset + buflen, <=, header->capacity);
memcpy(buf, header->buffer + offset, buflen);
return buflen;
}
| 1threat |
Vuejs, Difficulties to build with relative path : <p>I'm facing difficulties to make a proper build with a relative path when I run <code>npm run build</code>. Resolving assets is easy but I don't know how to configure 2 things:</p>
<p>1/ The <code>assetsPublicPath</code> in <code>config/index.js</code></p>
<pre><code>// see http://vuejs-templates.github.io/webpack for documentation.
var path = require('path')
module.exports = {
build: {
env: require('./prod.env'),
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/ONLY_ABSOLUTE_PATH_ARE_ALLOWED/',
productionSourceMap: true,
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css']
},
dev: {
env: require('./dev.env'),
port: 8080,
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {},
// CSS Sourcemaps off by default because relative paths are "buggy"
// with this option, according to the CSS-Loader README
// (https://github.com/webpack/css-loader#sourcemaps)
// In our experience, they generally work as expected,
// just be aware of this issue when enabling this option.
cssSourceMap: false
}
}
</code></pre>
<p>2/ The <code>base</code> option in the <code>vue-router</code> config seems to accept only absolute path too...</p>
<pre><code>const router = new VueRouter({
mode: 'history',
base: '/ABSOLUTE_PATH_ONLY/',
routes: [
{ path: '/', redirect: '/fr/poster/home' },
{ path: '/:lang', redirect: '/:lang/poster/home' },
{
path: '/:lang/poster',
component: PosterLayout,
children: [
{
// UserProfile will be rendered inside User's <router-view>
// when /user/:id/profile is matched
name: 'home',
path: 'home',
component: Home
},
{
// UserPosts will be rendered inside User's <router-view>
// when /user/:id/posts is matched
name: 'themeCover',
path: ':theme',
component: ThemeCover
}
]
},
{
name: 'themeDetails',
path: '/:lang/theme/:theme',
component: ThemeDetails
}
]
})
</code></pre>
<p>So, it works when I specified the correct future URL, but it's not "future proof" in case, the server is modified...</p>
<p>Any ideas to solve this if it's solvable?</p>
| 0debug |
static int ftp_connect_data_connection(URLContext *h)
{
int err;
char buf[CONTROL_BUFFER_SIZE], opts_format[20];
AVDictionary *opts = NULL;
FTPContext *s = h->priv_data;
if (!s->conn_data) {
if ((err = ftp_passive_mode(s)) < 0) {
av_dlog(h, "Set passive mode failed\n");
return err;
}
ff_url_join(buf, sizeof(buf), "tcp", NULL, s->hostname, s->server_data_port, NULL);
if (s->rw_timeout != -1) {
snprintf(opts_format, sizeof(opts_format), "%d", s->rw_timeout);
av_dict_set(&opts, "timeout", opts_format, 0);
}
err = ffurl_open(&s->conn_data, buf, AVIO_FLAG_READ_WRITE,
&h->interrupt_callback, &opts);
av_dict_free(&opts);
if (err < 0)
return err;
if (s->position)
if ((err = ftp_restart(s, s->position)) < 0)
return err;
}
s->state = READY;
return 0;
}
| 1threat |
Most efficient of using 'if' : <p>Code 1 :</p>
<pre><code>if( !(varOfsomeClass->isValid($imParams)) ){
//some function i need to run
}
</code></pre>
<ul>
<li>run function isValid</li>
<li>reverse value with not (!)</li>
<li>check value with if</li>
</ul>
<p>Code 2 :</p>
<pre><code>if( (varOfsomeClass->isValid($imParams)) ){
} else {
//some function i need to run
}
</code></pre>
<ul>
<li>run function isValid</li>
<li>check value with if</li>
<li>enter else part(maybe, or do nothing because isValid is true)</li>
</ul>
<p>which is more efficient? which is better to use?</p>
<p>nb: Code 1 is indeed more 'human'</p>
| 0debug |
How does Java handle vulnerable code coming as input arguments? : <p>How does jvm handle vulnerable code like 'System.exit()' when passed as user inputs?</p>
| 0debug |
Is it possible to prevent `useLazyQuery` queries from being re-fetched on component state change / re-render? : <p>Currently I have a <code>useLazyQuery</code> hook which is fired on a button press (part of a search form). </p>
<p>The hook behaves normally, and is only fired when the button is pressed. However, once I've fired it once, it's then fired every time the component re-renders (usually due to state changes).</p>
<p>So if I search once, then edit the search fields, the results appear immediately, and I don't have to click on the search button again. </p>
<p>Not the UI I want, and it causes an error if you delete the search text entirely (as it's trying to search with <code>null</code> as the variable), is there any way to prevent the <code>useLazyQuery</code> from being refetched on re-render?</p>
<p>This can be worked around using <code>useQuery</code> dependent on a 'searching' state which gets toggled on when I click on the button. However I'd rather see if I can avoid adding complexity to the component.</p>
<pre class="lang-js prettyprint-override"><code>const AddCardSidebar = props => {
const [searching, toggleSearching] = useState(false);
const [searchParams, setSearchParams] = useState({
name: ''
});
const [searchResults, setSearchResults] = useState([]);
const [selectedCard, setSelectedCard] = useState();
const [searchCardsQuery, searchCardsQueryResponse] = useLazyQuery(SEARCH_CARDS, {
variables: { searchParams },
onCompleted() {
setSearchResults(searchCardsQueryResponse.data.searchCards.cards);
}
});
...
return (
<div>
<h1>AddCardSidebar</h1>
<div>
{searchResults.length !== 0 &&
searchResults.map(result => {
return (
<img
key={result.scryfall_id}
src={result.image_uris.small}
alt={result.name}
onClick={() => setSelectedCard(result.scryfall_id)}
/>
);
})}
</div>
<form>
...
<button type='button' onClick={() => searchCardsQuery()}>
Search
</button>
</form>
...
</div>
);
};
</code></pre>
| 0debug |
What is the difference between a double and short type in C? : <p>I am writing a C code but am not sure when to use a double or a short type when defining a pointer. Can someone explain the difference between the two?</p>
| 0debug |
Why do we declare pointers : Why do we use pointers in c to store addresses of variables?? Why can't we simply use an unsigned int instead??
I mean we could simply declare an unsigned int to store the addresses | 0debug |
static int swri_resample(ResampleContext *c,
uint8_t *dst, const uint8_t *src, int *consumed,
int src_size, int dst_size, int update_ctx)
{
int fn_idx = c->format - AV_SAMPLE_FMT_S16P;
if (c->filter_length == 1 && c->phase_shift == 0) {
int index= c->index;
int frac= c->frac;
int64_t index2= (1LL<<32)*c->frac/c->src_incr + (1LL<<32)*index;
int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr;
int new_size = (src_size * (int64_t)c->src_incr - frac + c->dst_incr - 1) / c->dst_incr;
dst_size= FFMIN(dst_size, new_size);
c->dsp.resample_one[fn_idx](dst, src, dst_size, index2, incr);
index += dst_size * c->dst_incr_div;
index += (frac + dst_size * (int64_t)c->dst_incr_mod) / c->src_incr;
av_assert2(index >= 0);
*consumed= index;
if (update_ctx) {
c->frac = (frac + dst_size * (int64_t)c->dst_incr_mod) % c->src_incr;
c->index = 0;
}
} else {
int64_t end_index = (1LL + src_size - c->filter_length) << c->phase_shift;
int64_t delta_frac = (end_index - c->index) * c->src_incr - c->frac;
int delta_n = (delta_frac + c->dst_incr - 1) / c->dst_incr;
dst_size = FFMIN(dst_size, delta_n);
if (dst_size > 0) {
if (!c->linear) {
*consumed = c->dsp.resample_common[fn_idx](c, dst, src, dst_size, update_ctx);
} else {
*consumed = c->dsp.resample_linear[fn_idx](c, dst, src, dst_size, update_ctx);
}
} else {
*consumed = 0;
}
}
return dst_size;
}
| 1threat |
Elixir - how to deep merge maps? : <p>With <code>Map.merge</code> I have:</p>
<pre><code>Map.merge(%{ a: %{ b: 1 }}, %{ a: %{ c: 3 }}) # => %{ a: %{ c: 3 }}
</code></pre>
<p>but actually I want to:</p>
<pre><code>Map.merge(%{ a: %{ b: 1 }}, %{ a: %{ c: 3 }}) # => %{ a: %{ b: 1, c: 3 }}
</code></pre>
<p>Is there any native method without writing a recursive boilerplate function for this case?</p>
| 0debug |
static void exynos4210_i2c_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
Exynos4210I2CState *s = (Exynos4210I2CState *)opaque;
uint8_t v = value & 0xff;
DPRINT("write %s [0x%02x] <- 0x%02x\n", exynos4_i2c_get_regname(offset),
(unsigned int)offset, v);
switch (offset) {
case I2CCON_ADDR:
s->i2ccon = (v & ~I2CCON_INT_PEND) | (s->i2ccon & I2CCON_INT_PEND);
if ((s->i2ccon & I2CCON_INT_PEND) && !(v & I2CCON_INT_PEND)) {
s->i2ccon &= ~I2CCON_INT_PEND;
qemu_irq_lower(s->irq);
if (!(s->i2ccon & I2CCON_INTRS_EN)) {
s->i2cstat &= ~I2CSTAT_START_BUSY;
}
if (s->i2cstat & I2CSTAT_START_BUSY) {
if (s->scl_free) {
if (EXYNOS4_I2C_MODE(s->i2cstat) == I2CMODE_MASTER_Tx) {
exynos4210_i2c_data_send(s);
} else if (EXYNOS4_I2C_MODE(s->i2cstat) ==
I2CMODE_MASTER_Rx) {
exynos4210_i2c_data_receive(s);
}
} else {
s->i2ccon |= I2CCON_INT_PEND;
qemu_irq_raise(s->irq);
}
}
}
break;
case I2CSTAT_ADDR:
s->i2cstat =
(s->i2cstat & I2CSTAT_START_BUSY) | (v & ~I2CSTAT_START_BUSY);
if (!(s->i2cstat & I2CSTAT_OUTPUT_EN)) {
s->i2cstat &= ~I2CSTAT_START_BUSY;
s->scl_free = true;
qemu_irq_lower(s->irq);
break;
}
if (!I2C_IN_MASTER_MODE(s->i2cstat)) {
break;
}
if (v & I2CSTAT_START_BUSY) {
s->i2cstat &= ~I2CSTAT_LAST_BIT;
s->i2cstat |= I2CSTAT_START_BUSY;
s->scl_free = false;
if (i2c_start_transfer(s->bus, s->i2cds >> 1, s->i2cds & 0x1) &&
(s->i2ccon & I2CCON_ACK_GEN)) {
s->i2cstat |= I2CSTAT_LAST_BIT;
} else if (EXYNOS4_I2C_MODE(s->i2cstat) == I2CMODE_MASTER_Rx) {
exynos4210_i2c_data_receive(s);
}
exynos4210_i2c_raise_interrupt(s);
} else {
i2c_end_transfer(s->bus);
if (!(s->i2ccon & I2CCON_INT_PEND)) {
s->i2cstat &= ~I2CSTAT_START_BUSY;
}
s->scl_free = true;
}
break;
case I2CADD_ADDR:
if ((s->i2cstat & I2CSTAT_OUTPUT_EN) == 0) {
s->i2cadd = v;
}
break;
case I2CDS_ADDR:
if (s->i2cstat & I2CSTAT_OUTPUT_EN) {
s->i2cds = v;
s->scl_free = true;
if (EXYNOS4_I2C_MODE(s->i2cstat) == I2CMODE_MASTER_Tx &&
(s->i2cstat & I2CSTAT_START_BUSY) &&
!(s->i2ccon & I2CCON_INT_PEND)) {
exynos4210_i2c_data_send(s);
}
}
break;
case I2CLC_ADDR:
s->i2clc = v;
break;
default:
DPRINT("ERROR: Bad write offset 0x%x\n", (unsigned int)offset);
break;
}
}
| 1threat |
static int has_codec_parameters(AVCodecContext *enc)
{
int val;
switch(enc->codec_type) {
case CODEC_TYPE_AUDIO:
val = enc->sample_rate;
break;
case CODEC_TYPE_VIDEO:
val = enc->width && enc->pix_fmt != PIX_FMT_NONE;
break;
default:
val = 1;
break;
}
return (val != 0);
}
| 1threat |
(Java) For some reason this when I print this arraylist it prints the second part of it as same as the third part :
import java.util.*;
public class RoadTrip
{
ArrayList<GeoLocation> roadTrip = new ArrayList<GeoLocation>();
double cheat = 0;
// Create a GeoLocation and add it to the road trip
public void addStop(String name, double latitude, double longitude)
{
GeoLocation loc = new GeoLocation(name + " ", longitude);
roadTrip.add(loc);
}
// Get the total number of stops in the trip
public int getNumberOfStops()
{
return roadTrip.size();
}
// Get the total miles of the trip
public double getTripLength()
{
double totalDistance = 0;
for (int i = 1; i < roadTrip.size(); i++ )
{
GeoLocation here = roadTrip.get(i);
GeoLocation prev = roadTrip.get(i-1);
totalDistance = totalDistance + here.distanceFrom(prev);
}
return totalDistance;
}
// Return a formatted toString of the trip
public String toString()
{
int i = 0;
String retVal="";
for( Object test: roadTrip)
{
retVal = retVal + ( i + 1 ) + ". " + test + "\n";
i++;
}
return retVal;
}
}
When I return retVal, it returns the values
1. Powder Springs(-110.97168, -110.97168)
2. Argonne(-149.00134, -149.00134)
3. Zeba(-84.74096, -84.74096)
4. Hyampom(-53.2522, -53.2522)
5. North Fairfield(47.05816, 47.05816)
When it should return
1. Powder Springs (70.47312, -110.97168)
2. Argonne (-12.26804, -149.00134)
3. Zeba (-3.89922, -84.74096)
4. Hyampom (84.57072, -53.2522)
5. North Fairfield (73.14154, 47.05816)
The problem is that the latitude value is for some reason equal to the longitude value. | 0debug |
void cpu_state_reset(CPUMIPSState *env)
{
MIPSCPU *cpu = mips_env_get_cpu(env);
CPUState *cs = CPU(cpu);
env->CP0_PRid = env->cpu_model->CP0_PRid;
env->CP0_Config0 = env->cpu_model->CP0_Config0;
#ifdef TARGET_WORDS_BIGENDIAN
env->CP0_Config0 |= (1 << CP0C0_BE);
#endif
env->CP0_Config1 = env->cpu_model->CP0_Config1;
env->CP0_Config2 = env->cpu_model->CP0_Config2;
env->CP0_Config3 = env->cpu_model->CP0_Config3;
env->CP0_Config4 = env->cpu_model->CP0_Config4;
env->CP0_Config4_rw_bitmask = env->cpu_model->CP0_Config4_rw_bitmask;
env->CP0_Config5 = env->cpu_model->CP0_Config5;
env->CP0_Config5_rw_bitmask = env->cpu_model->CP0_Config5_rw_bitmask;
env->CP0_Config6 = env->cpu_model->CP0_Config6;
env->CP0_Config7 = env->cpu_model->CP0_Config7;
env->CP0_LLAddr_rw_bitmask = env->cpu_model->CP0_LLAddr_rw_bitmask
<< env->cpu_model->CP0_LLAddr_shift;
env->CP0_LLAddr_shift = env->cpu_model->CP0_LLAddr_shift;
env->SYNCI_Step = env->cpu_model->SYNCI_Step;
env->CCRes = env->cpu_model->CCRes;
env->CP0_Status_rw_bitmask = env->cpu_model->CP0_Status_rw_bitmask;
env->CP0_TCStatus_rw_bitmask = env->cpu_model->CP0_TCStatus_rw_bitmask;
env->CP0_SRSCtl = env->cpu_model->CP0_SRSCtl;
env->current_tc = 0;
env->SEGBITS = env->cpu_model->SEGBITS;
env->SEGMask = (target_ulong)((1ULL << env->cpu_model->SEGBITS) - 1);
#if defined(TARGET_MIPS64)
if (env->cpu_model->insn_flags & ISA_MIPS3) {
env->SEGMask |= 3ULL << 62;
}
#endif
env->PABITS = env->cpu_model->PABITS;
env->CP0_SRSConf0_rw_bitmask = env->cpu_model->CP0_SRSConf0_rw_bitmask;
env->CP0_SRSConf0 = env->cpu_model->CP0_SRSConf0;
env->CP0_SRSConf1_rw_bitmask = env->cpu_model->CP0_SRSConf1_rw_bitmask;
env->CP0_SRSConf1 = env->cpu_model->CP0_SRSConf1;
env->CP0_SRSConf2_rw_bitmask = env->cpu_model->CP0_SRSConf2_rw_bitmask;
env->CP0_SRSConf2 = env->cpu_model->CP0_SRSConf2;
env->CP0_SRSConf3_rw_bitmask = env->cpu_model->CP0_SRSConf3_rw_bitmask;
env->CP0_SRSConf3 = env->cpu_model->CP0_SRSConf3;
env->CP0_SRSConf4_rw_bitmask = env->cpu_model->CP0_SRSConf4_rw_bitmask;
env->CP0_SRSConf4 = env->cpu_model->CP0_SRSConf4;
env->CP0_PageGrain_rw_bitmask = env->cpu_model->CP0_PageGrain_rw_bitmask;
env->CP0_PageGrain = env->cpu_model->CP0_PageGrain;
env->CP0_EBaseWG_rw_bitmask = env->cpu_model->CP0_EBaseWG_rw_bitmask;
env->active_fpu.fcr0 = env->cpu_model->CP1_fcr0;
env->active_fpu.fcr31_rw_bitmask = env->cpu_model->CP1_fcr31_rw_bitmask;
env->active_fpu.fcr31 = env->cpu_model->CP1_fcr31;
env->msair = env->cpu_model->MSAIR;
env->insn_flags = env->cpu_model->insn_flags;
#if defined(CONFIG_USER_ONLY)
env->CP0_Status = (MIPS_HFLAG_UM << CP0St_KSU);
# ifdef TARGET_MIPS64
env->CP0_Status |= (1 << CP0St_PX);
# endif
# ifdef TARGET_ABI_MIPSN64
env->CP0_Status |= (1 << CP0St_UX);
# endif
env->CP0_HWREna |= 0x0000000F;
if (env->CP0_Config1 & (1 << CP0C1_FP)) {
env->CP0_Status |= (1 << CP0St_CU1);
}
if (env->CP0_Config3 & (1 << CP0C3_DSPP)) {
env->CP0_Status |= (1 << CP0St_MX);
}
# if defined(TARGET_MIPS64)
if ((env->CP0_Config1 & (1 << CP0C1_FP)) &&
(env->CP0_Status_rw_bitmask & (1 << CP0St_FR))) {
env->CP0_Status |= (1 << CP0St_FR);
}
# endif
#else
if (env->hflags & MIPS_HFLAG_BMASK) {
env->CP0_ErrorEPC = (env->active_tc.PC
- (env->hflags & MIPS_HFLAG_B16 ? 2 : 4));
} else {
env->CP0_ErrorEPC = env->active_tc.PC;
}
env->active_tc.PC = env->exception_base;
env->CP0_Random = env->tlb->nb_tlb - 1;
env->tlb->tlb_in_use = env->tlb->nb_tlb;
env->CP0_Wired = 0;
env->CP0_GlobalNumber = (cs->cpu_index & 0xFF) << CP0GN_VPId;
env->CP0_EBase = (cs->cpu_index & 0x3FF);
if (kvm_enabled()) {
env->CP0_EBase |= 0x40000000;
} else {
env->CP0_EBase |= (int32_t)0x80000000;
}
if (env->CP0_Config3 & (1 << CP0C3_CMGCR)) {
env->CP0_CMGCRBase = 0x1fbf8000 >> 4;
}
env->CP0_EntryHi_ASID_mask = (env->CP0_Config4 & (1 << CP0C4_AE)) ?
0x3ff : 0xff;
env->CP0_Status = (1 << CP0St_BEV) | (1 << CP0St_ERL);
env->CP0_IntCtl = 0xe0000000;
{
int i;
for (i = 0; i < 7; i++) {
env->CP0_WatchLo[i] = 0;
env->CP0_WatchHi[i] = 0x80000000;
}
env->CP0_WatchLo[7] = 0;
env->CP0_WatchHi[7] = 0;
}
env->CP0_Debug = (1 << CP0DB_CNT) | (0x1 << CP0DB_VER);
cpu_mips_store_count(env, 1);
if (env->CP0_Config3 & (1 << CP0C3_MT)) {
int i;
for (i = 0; i < ARRAY_SIZE(env->tcs); i++) {
env->tcs[i].CP0_TCBind = cs->cpu_index << CP0TCBd_CurVPE;
env->tcs[i].CP0_TCHalt = 1;
}
env->active_tc.CP0_TCHalt = 1;
cs->halted = 1;
if (cs->cpu_index == 0) {
env->mvp->CP0_MVPControl |= (1 << CP0MVPCo_EVP);
env->CP0_VPEConf0 |= (1 << CP0VPEC0_MVP) | (1 << CP0VPEC0_VPA);
cs->halted = 0;
env->active_tc.CP0_TCHalt = 0;
env->tcs[0].CP0_TCHalt = 0;
env->active_tc.CP0_TCStatus = (1 << CP0TCSt_A);
env->tcs[0].CP0_TCStatus = (1 << CP0TCSt_A);
}
}
#endif
if ((env->insn_flags & ISA_MIPS32R6) &&
(env->active_fpu.fcr0 & (1 << FCR0_F64))) {
env->CP0_Status |= (1 << CP0St_FR);
}
if (env->CP0_Config3 & (1 << CP0C3_MSAP)) {
msa_reset(env);
}
compute_hflags(env);
restore_fp_status(env);
restore_pamask(env);
cs->exception_index = EXCP_NONE;
if (semihosting_get_argc()) {
env->active_tc.gpr[4] = -1;
}
} | 1threat |
datagridview cellcontent checkbiox change event : I have a datagridview with 3 columns invoice id, price and a checkbox.
If checkbox is clicked price becomes 0 for that row. Now that is happening.
But when I uncheck the checkbox price should be as it was. But it is remaining zero. Below is my code for cellcontent click. How can i get previous price if checkbox in unchecked?
private void grvItems_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
var senderGrid = (DataGridView)sender;
DataGridViewRow row = this.grvItems.CurrentRow;
if (e.RowIndex >= 0)
{
if (senderGrid.Columns[e.ColumnIndex] is DataGridViewCheckBoxColumn &&
e.RowIndex >= 0)
{
if (e.ColumnIndex == grvItems.Columns["UnderWarranty"].Index)
{
string returnAmt = lblReturnAmountVal.Text;
bool isCheked = (bool)grvItems.Rows[e.RowIndex].Cells["UnderWarranty"].EditedFormattedValue;
if (isCheked)
{
grvItems.Rows[e.RowIndex].Cells["PRICE"].Value = "0.00";
lblReturnAmountVal.Text = "0.00";
}
else
{
}
grvItems.EndEdit();
}
}
}
} | 0debug |
void main_loop_wait(int nonblocking)
{
IOHandlerRecord *ioh;
fd_set rfds, wfds, xfds;
int ret, nfds;
struct timeval tv;
int timeout;
if (nonblocking)
timeout = 0;
else {
timeout = qemu_calculate_timeout();
qemu_bh_update_timeout(&timeout);
}
os_host_main_loop_wait(&timeout);
nfds = -1;
FD_ZERO(&rfds);
FD_ZERO(&wfds);
FD_ZERO(&xfds);
QLIST_FOREACH(ioh, &io_handlers, next) {
if (ioh->deleted)
continue;
if (ioh->fd_read &&
(!ioh->fd_read_poll ||
ioh->fd_read_poll(ioh->opaque) != 0)) {
FD_SET(ioh->fd, &rfds);
if (ioh->fd > nfds)
nfds = ioh->fd;
}
if (ioh->fd_write) {
FD_SET(ioh->fd, &wfds);
if (ioh->fd > nfds)
nfds = ioh->fd;
}
}
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
slirp_select_fill(&nfds, &rfds, &wfds, &xfds);
qemu_mutex_unlock_iothread();
ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv);
qemu_mutex_lock_iothread();
if (ret > 0) {
IOHandlerRecord *pioh;
QLIST_FOREACH_SAFE(ioh, &io_handlers, next, pioh) {
if (ioh->deleted) {
QLIST_REMOVE(ioh, next);
qemu_free(ioh);
continue;
}
if (ioh->fd_read && FD_ISSET(ioh->fd, &rfds)) {
ioh->fd_read(ioh->opaque);
}
if (ioh->fd_write && FD_ISSET(ioh->fd, &wfds)) {
ioh->fd_write(ioh->opaque);
}
}
}
slirp_select_poll(&rfds, &wfds, &xfds, (ret < 0));
qemu_run_all_timers();
qemu_bh_poll();
}
| 1threat |
static int do_subchannel_work(SubchDev *sch)
{
if (sch->do_subchannel_work) {
return sch->do_subchannel_work(sch);
} else {
return -EINVAL;
}
}
| 1threat |
what is the dataWithContentsOfURL equivalent in android? : Hi i am trying to get the video data from a url. my project is base in a swift project. there they use dataWithContentsOfURL someone know what is the equivalent for android
> data = [NSData dataWithContentsOfURL:videoUrl options:0 error:&error];
data = [NSData dataWithContentsOfURL:videoUrl options:0 error:&error]; | 0debug |
How to create a Navigation Drawer and Bottom Bar in the same app : <p>I am creating an app, and I want to have a Navigation Drawer and a Bottom Bar in the app.</p>
<p>I think that I am going for a good way, but I Can do that the Navigation Drawer when I display it, this is not above the Bottom Bar, it is behind, so How can I do it? I need the Navigation Drawer up of the Bottom Bar.</p>
<p>This is my code, I hope you can help me, thanks n.n</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/include_list_viewpager" />-
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_height="match_parent"
android:layout_width="300dp"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header"
app:menu="@menu/drawer_view" />
</android.support.v4.widget.DrawerLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:itemBackground="@color/colorPrimaryRed"
app:itemTextColor="@drawable/nav_item_color_state"
app:itemIconTint="@drawable/nav_item_color_state"
app:menu="@menu/navigation" />
</RelativeLayout>
</code></pre>
| 0debug |
Cannot read property 'style' of null - Google Sign-In Button : <p>I'm trying to implement Google sign in for my website. The Sign-In button shows up correctly and signs-people in well initially. My problem occurs when I log out after having used the website and try to move to the Sign-In page (I'm using React, so it's all one page). I use the exact same function to render the Sign-In page but it gives me a "cb=gapi.loaded_0:249 Uncaught TypeError: Cannot read property 'style' of null". The error in gapi occurs here (at least I think): </p>
<pre><code> a.El;window.document.getElementById((c?"not_signed_in":"connected"
</code></pre>
<p>This is how I initially add the Sign-In button to be rendered: </p>
<pre><code>elements.push(h('div.g-signin2',{'data-onsuccess': 'onSignIn'}))
return h('div.page_content',elements)
</code></pre>
<p>which I later render with a ReactDOM.render call. </p>
<p>Here's how I handle SignOut and SignIn: </p>
<pre><code>function signOut() {
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function () {
// console.log('User signed out.');
signedin = false;
auth2 = null;
renderPage()
});
}
var google_idtoken;
var signedin = false;
// set auth2 to null to indicate that google api hasn't been loaded yet
var auth2 = null;
function onSignIn(googleUser) {
auth2 = gapi.auth2.getAuthInstance({
client_id: 'ClientID.apps.googleusercontent.com'
});
google_idtoken = googleUser.getAuthResponse().id_token;
wrongemail = true;
// if(auth2 != null && auth2.isSignedIn.get() == true){
if ((((auth2.currentUser.get()).getBasicProfile()).getEmail()).split("@").pop() == 'domain.com'){
signedin = true
wrongemail = false
}
updateSources()
// renderPage()
}
</code></pre>
| 0debug |
static AVFilterContext *create_filter(AVFilterGraph *ctx, int index,
const char *name, const char *args,
AVClass *log_ctx)
{
AVFilterContext *filt;
AVFilter *filterdef;
char inst_name[30];
snprintf(inst_name, sizeof(inst_name), "Parsed filter %d", index);
filterdef = avfilter_get_by_name(name);
if(!filterdef) {
av_log(log_ctx, AV_LOG_ERROR,
"no such filter: '%s'\n", name);
return NULL;
}
filt = avfilter_open(filterdef, inst_name);
if(!filt) {
av_log(log_ctx, AV_LOG_ERROR,
"error creating filter '%s'\n", name);
return NULL;
}
if(avfilter_graph_add_filter(ctx, filt) < 0)
return NULL;
if(avfilter_init_filter(filt, args, NULL)) {
av_log(log_ctx, AV_LOG_ERROR,
"error initializing filter '%s' with args '%s'\n", name, args);
return NULL;
}
return filt;
}
| 1threat |
C# Writing to a excel file : <p>I have Data stored in DataTables and I'm trying to write that data into a .xlsx file, with multiple sheets. I don't how to go about it. Thanks</p>
| 0debug |
How to load a component from a variable name in Vue.js? : <p>I want to load a component from a dynamic variable name in my vue.js application.</p>
<p>I have the following component registered:</p>
<pre><code><template id="goal">
<h1>Goal:{{data.text}}</h1>
</template>
</code></pre>
<p>Instead of loading it like this</p>
<pre><code><goal></goal>
</code></pre>
<p>I want to load from a variable name, something like this:</p>
<pre><code><{{mytemplate.type}}></{{mytemplate.type}}>
</code></pre>
<p>Where, of course, mytemplate.type would be, in this case equal to "goal"</p>
| 0debug |
How do I convert a Python3 file i to .exe file? : <p>I've been coding on python for a while. Made quite a few games and applications. Now I want to share them but don't know how. I can't just ask my friends to download python on their computers. </p>
<p>Please Help!</p>
| 0debug |
Python How to prevent input same value in a empty list for several times : **Wrong** example
a = [ ]
while a [ 4 ] ! = None: #ensure in put 5 times
option = input()
if option in a: #prevent input same value
continue
else:
a.append(option)
Moreover, if i use dict is better?
And I am not native of English | 0debug |
Remove exact alphanumeric string from text in R/Python : <p>"The string? is made up a load of strings but the problem is the removal of question mark in the word string? without removing the other question marks. can anybody have a look?" </p>
<p>In the above text I have to alter "string?" to "string". But I dont want the statement to lose the rest of the ? in the text.</p>
<p>Resultant text should be:
"The string is made up a load of strings but the problem is the removal of question mark in the word string without removing the other question marks. can anybody have a look?" </p>
<p>I have tried gsub, string_replace and a number of other methods, they end up removing or replacing the word and still keeping the "?"</p>
| 0debug |
Connect new oulet from storyboard is always nil : I'm trying to connect new outlet from storyboard to UIViewController (by dragging), the outlet created as follow:
@IBOutle var button2: UIButton!
- without "weak" key,
in runtime the outlet is nil, even if i add the "weak" key by my self and reconnect it again.
Its append in all the viewControllers in my project, only in one project.
(there are old outlets that work, the issue is only in new outlets create)
I tried to delete the DrivedData..
The files exist in the Target, in Compile Resources
Im using Xcode 8 yet.
any answer?
| 0debug |
static int ffm2_read_header(AVFormatContext *s)
{
FFMContext *ffm = s->priv_data;
AVStream *st;
AVIOContext *pb = s->pb;
AVCodecContext *codec;
const AVCodecDescriptor *codec_desc;
int ret, i;
int f_main = 0, f_cprv = -1, f_stvi = -1, f_stau = -1;
AVCodec *enc;
char *buffer;
ffm->packet_size = avio_rb32(pb);
if (ffm->packet_size != FFM_PACKET_SIZE) {
av_log(s, AV_LOG_ERROR, "Invalid packet size %d, expected size was %d\n",
ffm->packet_size, FFM_PACKET_SIZE);
ret = AVERROR_INVALIDDATA;
ffm->write_index = avio_rb64(pb);
if (pb->seekable) {
ffm->file_size = avio_size(pb);
if (ffm->write_index && 0)
adjust_write_index(s);
} else {
ffm->file_size = (UINT64_C(1) << 63) - 1;
while(!avio_feof(pb)) {
unsigned id = avio_rb32(pb);
unsigned size = avio_rb32(pb);
int64_t next = avio_tell(pb) + size;
char rc_eq_buf[128];
if(!id)
break;
switch(id) {
case MKBETAG('M', 'A', 'I', 'N'):
if (f_main++) {
ret = AVERROR(EINVAL);
avio_rb32(pb);
avio_rb32(pb);
break;
case MKBETAG('C', 'O', 'M', 'M'):
f_cprv = f_stvi = f_stau = 0;
st = avformat_new_stream(s, NULL);
if (!st) {
ret = AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 1000000);
codec = st->codec;
codec->codec_id = avio_rb32(pb);
codec_desc = avcodec_descriptor_get(codec->codec_id);
if (!codec_desc) {
av_log(s, AV_LOG_ERROR, "Invalid codec id: %d\n", codec->codec_id);
codec->codec_id = AV_CODEC_ID_NONE;
codec->codec_type = avio_r8(pb);
if (codec->codec_type != codec_desc->type) {
av_log(s, AV_LOG_ERROR, "Codec type mismatch: expected %d, found %d\n",
codec_desc->type, codec->codec_type);
codec->codec_id = AV_CODEC_ID_NONE;
codec->codec_type = AVMEDIA_TYPE_UNKNOWN;
codec->bit_rate = avio_rb32(pb);
codec->flags = avio_rb32(pb);
codec->flags2 = avio_rb32(pb);
codec->debug = avio_rb32(pb);
if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
int size = avio_rb32(pb);
codec->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!codec->extradata)
return AVERROR(ENOMEM);
codec->extradata_size = size;
avio_read(pb, codec->extradata, size);
break;
case MKBETAG('S', 'T', 'V', 'I'):
if (f_stvi++) {
ret = AVERROR(EINVAL);
codec->time_base.num = avio_rb32(pb);
codec->time_base.den = avio_rb32(pb);
if (codec->time_base.num <= 0 || codec->time_base.den <= 0) {
av_log(s, AV_LOG_ERROR, "Invalid time base %d/%d\n",
codec->time_base.num, codec->time_base.den);
ret = AVERROR_INVALIDDATA;
codec->width = avio_rb16(pb);
codec->height = avio_rb16(pb);
codec->gop_size = avio_rb16(pb);
codec->pix_fmt = avio_rb32(pb);
codec->qmin = avio_r8(pb);
codec->qmax = avio_r8(pb);
codec->max_qdiff = avio_r8(pb);
codec->qcompress = avio_rb16(pb) / 10000.0;
codec->qblur = avio_rb16(pb) / 10000.0;
codec->bit_rate_tolerance = avio_rb32(pb);
avio_get_str(pb, INT_MAX, rc_eq_buf, sizeof(rc_eq_buf));
codec->rc_eq = av_strdup(rc_eq_buf);
codec->rc_max_rate = avio_rb32(pb);
codec->rc_min_rate = avio_rb32(pb);
codec->rc_buffer_size = avio_rb32(pb);
codec->i_quant_factor = av_int2double(avio_rb64(pb));
codec->b_quant_factor = av_int2double(avio_rb64(pb));
codec->i_quant_offset = av_int2double(avio_rb64(pb));
codec->b_quant_offset = av_int2double(avio_rb64(pb));
codec->dct_algo = avio_rb32(pb);
codec->strict_std_compliance = avio_rb32(pb);
codec->max_b_frames = avio_rb32(pb);
codec->mpeg_quant = avio_rb32(pb);
codec->intra_dc_precision = avio_rb32(pb);
codec->me_method = avio_rb32(pb);
codec->mb_decision = avio_rb32(pb);
codec->nsse_weight = avio_rb32(pb);
codec->frame_skip_cmp = avio_rb32(pb);
codec->rc_buffer_aggressivity = av_int2double(avio_rb64(pb));
codec->codec_tag = avio_rb32(pb);
codec->thread_count = avio_r8(pb);
codec->coder_type = avio_rb32(pb);
codec->me_cmp = avio_rb32(pb);
codec->me_subpel_quality = avio_rb32(pb);
codec->me_range = avio_rb32(pb);
codec->keyint_min = avio_rb32(pb);
codec->scenechange_threshold = avio_rb32(pb);
codec->b_frame_strategy = avio_rb32(pb);
codec->qcompress = av_int2double(avio_rb64(pb));
codec->qblur = av_int2double(avio_rb64(pb));
codec->max_qdiff = avio_rb32(pb);
codec->refs = avio_rb32(pb);
break;
case MKBETAG('S', 'T', 'A', 'U'):
if (f_stau++) {
ret = AVERROR(EINVAL);
codec->sample_rate = avio_rb32(pb);
codec->channels = avio_rl16(pb);
codec->frame_size = avio_rl16(pb);
break;
case MKBETAG('C', 'P', 'R', 'V'):
if (f_cprv++) {
ret = AVERROR(EINVAL);
enc = avcodec_find_encoder(codec->codec_id);
if (enc && enc->priv_data_size && enc->priv_class) {
buffer = av_malloc(size + 1);
if (!buffer) {
ret = AVERROR(ENOMEM);
avio_get_str(pb, size, buffer, size + 1);
if ((ret = ffm_append_recommended_configuration(st, &buffer)) < 0)
break;
case MKBETAG('S', '2', 'V', 'I'):
if (f_stvi++ || !size) {
ret = AVERROR(EINVAL);
buffer = av_malloc(size);
if (!buffer) {
ret = AVERROR(ENOMEM);
avio_get_str(pb, INT_MAX, buffer, size);
av_set_options_string(codec, buffer, "=", ",");
if ((ret = ffm_append_recommended_configuration(st, &buffer)) < 0)
break;
case MKBETAG('S', '2', 'A', 'U'):
if (f_stau++ || !size) {
ret = AVERROR(EINVAL);
buffer = av_malloc(size);
if (!buffer) {
ret = AVERROR(ENOMEM);
avio_get_str(pb, INT_MAX, buffer, size);
av_set_options_string(codec, buffer, "=", ",");
if ((ret = ffm_append_recommended_configuration(st, &buffer)) < 0)
break;
avio_seek(pb, next, SEEK_SET);
for (i = 0; i < s->nb_streams; i++)
avcodec_parameters_from_context(s->streams[i]->codecpar, s->streams[i]->codec);
while ((avio_tell(pb) % ffm->packet_size) != 0 && !pb->eof_reached)
avio_r8(pb);
ffm->packet_ptr = ffm->packet;
ffm->packet_end = ffm->packet;
ffm->frame_offset = 0;
ffm->dts = 0;
ffm->read_state = READ_HEADER;
ffm->first_packet = 1;
return 0;
fail:
ffm_close(s);
return ret;
| 1threat |
A way to subclass NamedTuple for purposes of typechecking : <p>I have several namedtuples that share some fields. I have a function that accepts these tuples and is guaranteed to only interact with the shared fields. I want to typecheck such code in mypy.</p>
<p>An example of the code would be:</p>
<pre><code>from typing import NamedTuple
class Base(NamedTuple):
x: int
y: int
class BaseExtended(NamedTuple):
x: int
y: int
z: str
def DoSomething(tuple: Base):
return tuple.x + tuple.y
base = Base(3, 4)
base_extended = BaseExtended(5, 6, 'foo')
DoSomething(base)
DoSomething(base_extended)
</code></pre>
<p>When I run mypy on this code I get a predictable error:</p>
<blockquote>
<p>mypy_example.py:20: error: Argument 1 to "DoSomething" has
incompatible type "BaseExtended"; expected "Base"</p>
</blockquote>
<p>Is there no way to structure my code and keep mypy typechecking? I cannot inherit BaseExtended from Base, since there's a bug in the NamedTuple inheritance implementation:</p>
<p><a href="https://github.com/python/typing/issues/427" rel="noreferrer">https://github.com/python/typing/issues/427</a></p>
<p>I don't want to use an ugly "Union[Base, BaseExtended]" either, since this breaks when I try to typecheck a List, since "List[Union[Base, BaseExtended]]" is not equal to "List[BaseExtended]" due to some mypy magic about variant/covariant types:</p>
<p><a href="https://github.com/python/mypy/issues/3351" rel="noreferrer">https://github.com/python/mypy/issues/3351</a></p>
<p>Should I just abandon the idea?</p>
| 0debug |
static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)
{
FFPsyBand *band;
int w, g, w2, i;
float *PNS = &s->scoefs[0*128], *PNS34 = &s->scoefs[1*128];
float *NOR34 = &s->scoefs[3*128];
const float lambda = s->lambda;
const float freq_mult = avctx->sample_rate/(1024.0f/sce->ics.num_windows)/2.0f;
const float thr_mult = NOISE_LAMBDA_REPLACE*(100.0f/lambda);
const float spread_threshold = NOISE_SPREAD_THRESHOLD*(lambda/100.f);
if (sce->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE)
return;
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
for (g = 0; g < sce->ics.num_swb; g++) {
int noise_sfi;
float dist1 = 0.0f, dist2 = 0.0f, noise_amp;
float pns_energy = 0.0f, energy_ratio, dist_thresh;
float sfb_energy = 0.0f, threshold = 0.0f, spread = 0.0f;
const int start = sce->ics.swb_offset[w*16+g];
const float freq = start*freq_mult;
const float freq_boost = FFMAX(0.88f*freq/NOISE_LOW_LIMIT, 1.0f);
if (freq < NOISE_LOW_LIMIT || avctx->cutoff && freq >= avctx->cutoff)
continue;
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g];
sfb_energy += band->energy;
spread += band->spread;
threshold += band->threshold;
}
dist_thresh = FFMIN(2.5f*NOISE_LOW_LIMIT/freq, 1.27f);
if (sce->zeroes[w*16+g] || spread < spread_threshold ||
sfb_energy > threshold*thr_mult*freq_boost) {
sce->pns_ener[w*16+g] = sfb_energy;
continue;
}
noise_sfi = av_clip(roundf(log2f(sfb_energy)*2), -100, 155);
noise_amp = -ff_aac_pow2sf_tab[noise_sfi + POW_SF2_ZERO];
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
float band_energy, scale;
const int start_c = sce->ics.swb_offset[(w+w2)*16+g];
band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g];
for (i = 0; i < sce->ics.swb_sizes[g]; i++)
PNS[i] = s->random_state = lcg_random(s->random_state);
band_energy = s->fdsp->scalarproduct_float(PNS, PNS, sce->ics.swb_sizes[g]);
scale = noise_amp/sqrtf(band_energy);
s->fdsp->vector_fmul_scalar(PNS, PNS, scale, sce->ics.swb_sizes[g]);
pns_energy += s->fdsp->scalarproduct_float(PNS, PNS, sce->ics.swb_sizes[g]);
abs_pow34_v(NOR34, &sce->coeffs[start_c], sce->ics.swb_sizes[g]);
abs_pow34_v(PNS34, PNS, sce->ics.swb_sizes[g]);
dist1 += quantize_band_cost(s, &sce->coeffs[start_c],
NOR34,
sce->ics.swb_sizes[g],
sce->sf_idx[(w+w2)*16+g],
sce->band_alt[(w+w2)*16+g],
lambda/band->threshold, INFINITY, NULL, 0);
dist2 += quantize_band_cost(s, PNS,
PNS34,
sce->ics.swb_sizes[g],
noise_sfi,
NOISE_BT,
lambda/band->threshold, INFINITY, NULL, 0);
}
energy_ratio = sfb_energy/pns_energy;
sce->pns_ener[w*16+g] = energy_ratio*sfb_energy;
if (energy_ratio > 0.85f && energy_ratio < 1.25f && dist1/dist2 > dist_thresh) {
sce->band_type[w*16+g] = NOISE_BT;
sce->zeroes[w*16+g] = 0;
if (sce->band_type[w*16+g-1] != NOISE_BT &&
sce->band_type[w*16+g-2] == NOISE_BT) {
sce->band_type[w*16+g-1] = NOISE_BT;
sce->zeroes[w*16+g-1] = 0;
}
}
}
}
}
| 1threat |
Perl tr usage of regexp : <p>i would like to ask about regex usage in Perl, extacly the tr///</p>
<p>So if i have an expression
tr/abcde/abc the result will be abcab?
How extacly the tr works?</p>
| 0debug |
How would I assign Configmap to a pod that is already running? : I can not get a configmap loaded into a pod that is currently running nginx.
I can not get a currently running pod (running nginx) to read a configmap.
I tried by creating a simple pod definition and added to it a simple read configmap shown below:
```
apiVersion: v1
kind: Pod
metadata:
name: testpod
spec:
containers:
- name: testcontainer
image: nginx
env:
- name: MY_VAR
configMapKeyRef:
name: configmap1
key: data1
valueFrom:
```
This ran successfully and its yaml file was saved and then deleted.
Heres what I got:
```
apiVersion: v1
kind: Pod
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"name":"testpod","namespace":"default"},"spec":{"containers":[{"env":[{"name":"MY_VAR","valueFrom":{"configMapKeyRef":{"key":"data1","name":"configmap1"}}}],"image":"nginx","name":"testcontainer"}]}}
creationTimestamp: null
name: testpod
selfLink: /api/v1/namespaces/default/pods/testpod
spec:
containers:
- env:
- name: MY_VAR
valueFrom:
configMapKeyRef:
key: data1
name: configmap1
image: nginx
imagePullPolicy: Always
name: testcontainer
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: default-token-27x4x
readOnly: true
dnsPolicy: ClusterFirst
enableServiceLinks: true
nodeName: ip-10-0-1-103
priority: 0
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: default
serviceAccountName: default
terminationGracePeriodSeconds: 30
tolerations:
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 300
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 300
volumes:
- name: default-token-27x4x
secret:
defaultMode: 420
secretName: default-token-27x4x
status:
phase: Pending
qosClass: BestEffort
```
I then tried copying its syntax into what was another pod which was running.
This is what I got using `kubectl edit pod po`?
```
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2019-08-17T18:15:22Z"
labels:
run: pod1
name: pod1
namespace: default
resourceVersion: "12167"
selfLink: /api/v1/namespaces/default/pods/pod1
uid: fa297c13-c11a-11e9-9a5f-02ca4f0dcea0
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: pod1
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: default-token-27x4x
readOnly: true
dnsPolicy: ClusterFirst
enableServiceLinks: true
nodeName: ip-10-0-1-102
priority: 0
restartPolicy: Never
schedulerName: default-scheduler
securityContext: {}
serviceAccount: default
serviceAccountName: default
terminationGracePeriodSeconds: 30
tolerations:
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 300
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 300
volumes:
- name: default-token-27x4x
secret:
defaultMode: 420
secretName: default-token-27x4x
status:
conditions:
- lastProbeTime: null
lastTransitionTime: "2019-08-17T18:15:22Z"
status: "True"
type: Initialized
- lastProbeTime: null
lastTransitionTime: "2019-08-17T18:15:27Z"
status: "True"
type: Ready
- lastProbeTime: null
lastTransitionTime: "2019-08-17T18:15:27Z"
status: "True"
type: ContainersReady
- lastProbeTime: null
lastTransitionTime: "2019-08-17T18:15:22Z"
status: "True"
type: PodScheduled
containerStatuses:
- containerID: docker://99bfded0d69f4ed5ed854e59b458acd8a9197f9bef6d662a03587fe2ff61b128
image: nginx:latest
imageID: docker-pullable://nginx@sha256:53ddb41e46de3d63376579acf46f9a41a8d7de33645db47a486de9769201fec9
lastState: {}
name: pod1
ready: true
restartCount: 0
state:
running:
startedAt: "2019-08-17T18:15:27Z"
hostIP: 10.0.1.102
phase: Running
podIP: 10.244.2.2
qosClass: BestEffort
startTime: "2019-08-17T18:15:22Z"
cloud_user@ip-10-0-1-101:~$ k get po pod1 -o yaml --export
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: pod1
name: pod1
selfLink: /api/v1/namespaces/default/pods/pod1
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: pod1
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: default-token-27x4x
readOnly: true
dnsPolicy: ClusterFirst
enableServiceLinks: true
nodeName: ip-10-0-1-102
priority: 0
restartPolicy: Never
schedulerName: default-scheduler
securityContext: {}
serviceAccount: default
serviceAccountName: default
terminationGracePeriodSeconds: 30
tolerations:
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 300
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 300
volumes:
- name: default-token-27x4x
secret:
defaultMode: 420
secretName: default-token-27x4x
status:
phase: Pending
qosClass: BestEffort
```
What am I doing wrong or have I missed something? | 0debug |
angular build size with sass is huge : <p>So, I'm working on big app and all components have their own sass file style (we use ViewEncapsulation.Native) but I build <code>npm run build --stats-json --prod --aot</code> and check the stats with <a href="https://chrisbateman.github.io/webpack-visualizer/" rel="noreferrer">https://chrisbateman.github.io/webpack-visualizer/</a> I get this</p>
<p><a href="https://i.stack.imgur.com/geutm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/geutm.png" alt="enter image description here"></a></p>
<p>All those big orange blocs on the right are sass.shim.ngstyle.ts files and each one is like 195k !</p>
| 0debug |
How to declare a variable that can not insert in function : <p>I wanna declare a function with 2 Input parameters.</p>
<pre><code>function myFunc( $first , $second )
{
return $first;
}
</code></pre>
<p>When it called I only need the first parameter and don't wanna use "NULL" for the second.</p>
<pre><code>echo myFunc("Hello");
</code></pre>
<p>Sorry because of my poor English</p>
<p>Thanks</p>
| 0debug |
Using a loop function or lapply funtion to have a plot : I have a very large data set including 200 variables (columns), I am looking for a way (Loop function, etc) to have multiple variables in the same plot. How can I modify the below code to have this kind of plot(instead of repeating each geom_line(aes(y=)) for each W?
A<-seq(0,9,1)
B<-seq(30,39,1)
W1<-seq(0.3,1.2,0.1)
r<-seq(32,41,1)
f<-seq(33,42,1)
W2<-seq(1.3,2.2,0.1)
g<-seq(34,43,1)
W3<-seq(4.3,5.2,0.1)
s<-data.frame(A,B,m1,r,f,m2,g,m3)
ggplot(s,aes(x=A,y=B))+geom_point()+geom_line(aes(y=W1))+
geom_line(aes(y=W2))+
geom_line(aes(y=W3))+theme_bw() | 0debug |
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int))
{
int total = size;
do {
int len = FFMIN(f->end - f->wptr, size);
if (func) {
if (func(src, f->wptr, len) <= 0)
break;
} else {
memcpy(f->wptr, src, len);
src = (uint8_t*)src + len;
}
f->wptr += len;
if (f->wptr >= f->end)
f->wptr = f->buffer;
f->wndx += len;
size -= len;
} while (size > 0);
return total - size;
}
| 1threat |
static inline int get_segment(CPUPPCState *env, mmu_ctx_t *ctx,
target_ulong eaddr, int rw, int type)
{
hwaddr hash;
target_ulong vsid;
int ds, pr, target_page_bits;
int ret, ret2;
pr = msr_pr;
ctx->eaddr = eaddr;
#if defined(TARGET_PPC64)
if (env->mmu_model & POWERPC_MMU_64) {
ppc_slb_t *slb;
target_ulong pageaddr;
int segment_bits;
LOG_MMU("Check SLBs\n");
slb = slb_lookup(env, eaddr);
if (!slb) {
return -5;
}
if (slb->vsid & SLB_VSID_B) {
vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT_1T;
segment_bits = 40;
} else {
vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT;
segment_bits = 28;
}
target_page_bits = (slb->vsid & SLB_VSID_L)
? TARGET_PAGE_BITS_16M : TARGET_PAGE_BITS;
ctx->key = !!(pr ? (slb->vsid & SLB_VSID_KP)
: (slb->vsid & SLB_VSID_KS));
ds = 0;
ctx->nx = !!(slb->vsid & SLB_VSID_N);
pageaddr = eaddr & ((1ULL << segment_bits)
- (1ULL << target_page_bits));
if (slb->vsid & SLB_VSID_B) {
hash = vsid ^ (vsid << 25) ^ (pageaddr >> target_page_bits);
} else {
hash = vsid ^ (pageaddr >> target_page_bits);
}
ctx->ptem = (slb->vsid & SLB_VSID_PTEM) |
((pageaddr >> 16) & ((1ULL << segment_bits) - 0x80));
} else
#endif
{
target_ulong sr, pgidx;
sr = env->sr[eaddr >> 28];
ctx->key = (((sr & 0x20000000) && (pr != 0)) ||
((sr & 0x40000000) && (pr == 0))) ? 1 : 0;
ds = sr & 0x80000000 ? 1 : 0;
ctx->nx = sr & 0x10000000 ? 1 : 0;
vsid = sr & 0x00FFFFFF;
target_page_bits = TARGET_PAGE_BITS;
LOG_MMU("Check segment v=" TARGET_FMT_lx " %d " TARGET_FMT_lx " nip="
TARGET_FMT_lx " lr=" TARGET_FMT_lx
" ir=%d dr=%d pr=%d %d t=%d\n",
eaddr, (int)(eaddr >> 28), sr, env->nip, env->lr, (int)msr_ir,
(int)msr_dr, pr != 0 ? 1 : 0, rw, type);
pgidx = (eaddr & ~SEGMENT_MASK_256M) >> target_page_bits;
hash = vsid ^ pgidx;
ctx->ptem = (vsid << 7) | (pgidx >> 10);
}
LOG_MMU("pte segment: key=%d ds %d nx %d vsid " TARGET_FMT_lx "\n",
ctx->key, ds, ctx->nx, vsid);
ret = -1;
if (!ds) {
if (type != ACCESS_CODE || ctx->nx == 0) {
LOG_MMU("htab_base " TARGET_FMT_plx " htab_mask " TARGET_FMT_plx
" hash " TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, hash);
ctx->hash[0] = hash;
ctx->hash[1] = ~hash;
ctx->raddr = (hwaddr)-1ULL;
if (unlikely(env->mmu_model == POWERPC_MMU_SOFT_6xx ||
env->mmu_model == POWERPC_MMU_SOFT_74xx)) {
ret = ppc6xx_tlb_check(env, ctx, eaddr, rw, type);
} else {
LOG_MMU("0 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=" TARGET_FMT_lx " ptem=" TARGET_FMT_lx
" hash=" TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, vsid, ctx->ptem,
ctx->hash[0]);
ret = find_pte(env, ctx, 0, rw, type, target_page_bits);
if (ret < 0) {
if (eaddr != 0xEFFFFFFF) {
LOG_MMU("1 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=" TARGET_FMT_lx " api=" TARGET_FMT_lx
" hash=" TARGET_FMT_plx "\n", env->htab_base,
env->htab_mask, vsid, ctx->ptem, ctx->hash[1]);
}
ret2 = find_pte(env, ctx, 1, rw, type,
target_page_bits);
if (ret2 != -1) {
ret = ret2;
}
}
}
#if defined(DUMP_PAGE_TABLES)
if (qemu_log_enabled()) {
hwaddr curaddr;
uint32_t a0, a1, a2, a3;
qemu_log("Page table: " TARGET_FMT_plx " len " TARGET_FMT_plx
"\n", sdr, mask + 0x80);
for (curaddr = sdr; curaddr < (sdr + mask + 0x80);
curaddr += 16) {
a0 = ldl_phys(curaddr);
a1 = ldl_phys(curaddr + 4);
a2 = ldl_phys(curaddr + 8);
a3 = ldl_phys(curaddr + 12);
if (a0 != 0 || a1 != 0 || a2 != 0 || a3 != 0) {
qemu_log(TARGET_FMT_plx ": %08x %08x %08x %08x\n",
curaddr, a0, a1, a2, a3);
}
}
}
#endif
} else {
LOG_MMU("No access allowed\n");
ret = -3;
}
} else {
target_ulong sr;
LOG_MMU("direct store...\n");
sr = env->sr[eaddr >> 28];
if ((sr & 0x1FF00000) >> 20 == 0x07f) {
ctx->raddr = ((sr & 0xF) << 28) | (eaddr & 0x0FFFFFFF);
ctx->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
return 0;
}
switch (type) {
case ACCESS_INT:
break;
case ACCESS_CODE:
return -4;
case ACCESS_FLOAT:
return -4;
case ACCESS_RES:
return -4;
case ACCESS_CACHE:
ctx->raddr = eaddr;
return 0;
case ACCESS_EXT:
return -4;
default:
qemu_log("ERROR: instruction should not need "
"address translation\n");
return -4;
}
if ((rw == 1 || ctx->key != 1) && (rw == 0 || ctx->key != 0)) {
ctx->raddr = eaddr;
ret = 2;
} else {
ret = -2;
}
}
return ret;
}
| 1threat |
C# - Dictionary.Count - not working as expected : The following line of code is not working as expected: If there are two dictionary entries it prints "2, 2" instead of "1, 2"
Console.WriteLine($"Student: {studentMap.Count} - Average Score: {average} - Letter Grade: {GetLetterGrade(average)}");
It is not listing the dictionary count like this line ↓↓↓ of code above it in the other for-loop.
Console.WriteLine($"Enter test {studentScores.Count + 1 } for student {studentMap.Count + 1 }");
I'm guessing it's an issue with the for-loop but I don't see the problem
for (int students = 0; students < studentCount; students++)
{
List<int> studentScores = new List<int>();
for (int scores = 0; scores < scoreCount; scores++)
{
string scoreInput = string.Empty;
Console.WriteLine(string.Empty);
Console.WriteLine($"Enter test {studentScores.Count + 1 } for student {studentMap.Count + 1 }");
scoreInput = Console.ReadLine();
Console.WriteLine(string.Empty);
Console.WriteLine("--------------------");
int intScore = Convert.ToInt32(scoreInput);
studentScores.Add(intScore);
}
studentMap.Add(students, studentScores);
}
Console.WriteLine("The test results are as follows:");
Console.WriteLine(string.Empty);
for (int i = 0; i < studentMap.Count; i++)
{
List<int> studentScores = studentMap[i];
double scoreSum = studentScores.Sum();
double scoreNum = studentScores.Count();
double average = scoreSum / scoreNum;
Console.WriteLine($"Student: {studentMap.Count} - Average Score: {average} - Letter Grade: {GetLetterGrade(average)}");
}
Console.WriteLine();
Console.ReadLine();
} | 0debug |
Clickonce App Doesn't start with Windows 1803 : <p>I have a Clickonce app from Visual Studio 2015 SP3 that is published to the network server and used in-house only. The program works just fine when launched from Visual Studio. It runs just fine on a Windows machine that <strong>does not</strong> have the 1803 update. But once a machine updates to 1803, the application no longer starts. I get the "Checking for updates..." window then nothing. On a fresh install, I usually get the Smartscreen telling me the program may be dangerous. It doesn't get that far.</p>
<p>I've created the Clickonce from a computer with the 1803 update and the problem still exists.</p>
<p>I've disconnected the machine from the network. The application starts but then has no database access and it needs the database. It's also written to hide buttons that would use the database to prevent users from trying to do things that require it.</p>
<p>I found a workaround (third paragraph) at <a href="https://social.technet.microsoft.com/Forums/en-US/7cbd16f5-526e-4b0b-a186-3ebf41b7b349/smartscreen-prompt-does-not-show-for-clickonce-app-since-windows-10-update-1803?forum=win10itprogeneral" rel="noreferrer">https://social.technet.microsoft.com/Forums/en-US/7cbd16f5-526e-4b0b-a186-3ebf41b7b349/smartscreen-prompt-does-not-show-for-clickonce-app-since-windows-10-update-1803?forum=win10itprogeneral</a>. When I start the application from the directory mentioned, I get the Smartscreen and can tell it to run anyway. Every time I click the desktop icon, it works just fine.</p>
<p>If a new release is published, the new release is downloaded and the program updated, but the Smartscreen no longer appears and the application never starts. </p>
<p>So somewhere between installing the latest update and the Smartscreen, this is failing. Anyone else experiencing this and have an idea as to why?</p>
| 0debug |
Python - How to make a list of permutations : I have a list of variables, let's call it X. Below are the contents of X
x = ['A, B', '2', '3', 'Jan, Feb']
I want to transform this list into a list of lists with all the permutations of each list item that is comma separated sot hat it looks like this.
x = [['A', '2', '3', 'Jan'], ['A', '2', '3', 'Feb']
['B', '2', '3', 'Jan'], ['B', '2', '3', 'Feb']]
I prefer a solution that uses built-in tools | 0debug |
i need to hide radio input doesn't work : This is my html code i want to hide the radio button on css but when i press f5 doesn't work
<div id="ud_tab">
<input type="radio" name="ud_tabs" id="tab1" checked="">
<label for="tab1">Headline 1</label>
<input type="radio" name="ud_tabs" id="tab2">
<label for="tab2">Headline 2</label>
<input type="radio" name="ud_tabs" id="tab3">
<label for="tab3">Headline 3</label>
</div>
my css code is this, im new xd
#ud_tab input[type=radio]{
display: none;}
| 0debug |
How i can fetch only date from timestamp column through PHP? : I wanna to fetch old date as well not only current date stored in Timestamp,i used date() function but it only return current date and time. | 0debug |
Color under status bar when using Drawer Layout : I'm having the hardest time changing the color beneath the transparent status bar color.The transparency is fine when the drawer is open but the color beneath is wrong. Different fragments are going to have different action bar colors.
fitsSystemWindow has no effect.
Changing the status bar color just makes it solid.
If I set a set a color with a lower alpha, it just mixes with the Green(Primary Color Dark).
Example below of what is happening and what I want.
What is happening: Color underneath is green.
[![enter image description here][1]][1]
**What I want is like what is happening in the play store:**
[![enter image description here][2]][2]
[![enter image description here][3]][3]
[1]: https://i.stack.imgur.com/JARSE.png
[2]: https://i.stack.imgur.com/56Qmi.jpg
[3]: https://i.stack.imgur.com/fOzkX.jpg | 0debug |
Turning a string that contains a equation into an integer : <p>I would like to be able to convert a string such as "(5+6)*6" and get the resulting integer from that equation. It is important that it starts out as a string. </p>
| 0debug |
Change path symbols \ to / [C++] : I have a string path to my file that I want to execute .
It is for example :
E:\folderA\folderB\myfile.exe
If I write this path and I try to execute file there it says that file doesn't exist.
When I write it like that. Then it works.
E:/folderA/folderB/myFile.exe
How do I change \ to / ?
| 0debug |
int check_hw_breakpoints(CPUX86State *env, int force_dr6_update)
{
target_ulong dr6;
int reg, type;
int hit_enabled = 0;
dr6 = env->dr[6] & ~0xf;
for (reg = 0; reg < DR7_MAX_BP; reg++) {
type = hw_breakpoint_type(env->dr[7], reg);
if ((type == 0 && env->dr[reg] == env->eip) ||
((type & 1) && env->cpu_watchpoint[reg] &&
(env->cpu_watchpoint[reg]->flags & BP_WATCHPOINT_HIT))) {
dr6 |= 1 << reg;
if (hw_breakpoint_enabled(env->dr[7], reg)) {
hit_enabled = 1;
}
}
}
if (hit_enabled || force_dr6_update)
env->dr[6] = dr6;
return hit_enabled;
}
| 1threat |
What server URL should be used for the `oc login` command when using OpenShift's PaaS? : <p>What do I provide for the server URL in the <code>oc login</code> tool, when using the OpenShift PaaS?</p>
<p>I'm trying to migrate my OpenShift Online v2 app to v3, following <a href="https://docs.openshift.com/online/dev_guide/migrating_applications/web_framework_applications.html#dev-guide-migrating-web-framework-applications-php" rel="noreferrer">the instructions for PHP apps linked to from OpenShift's Migration Center</a>. That page says to run something following the pattern <code>oc new-app https://github.com/<github-id>/<repo-name>.git --name=<app-name> -e <ENV_VAR_NAME>=<env_var_value></code>. After tracking down a download for oc (which wasn't easy), I tried running that command with my repo URL*; this results in:</p>
<pre><code>$ oc new-app https://USERNAME@bitbucket.org/USERNAME/PROJECTNAME.git --name=PROJECTNAME
error: Missing or incomplete configuration info. Please login or point to an existing, complete config file:
1. Via the command-line flag --config
2. Via the KUBECONFIG environment variable
3. In your home directory as ~/.kube/config
To view or setup config directly use the 'config' command.
</code></pre>
<p>Not knowing what subcommand of <code>oc config</code> to use, I searched and found <a href="https://docs.openshift.com/online/cli_reference/get_started_cli.html" rel="noreferrer">Get Started with the CLI</a>, which says to use <code>oc login</code> to start the configuration process. But when I run that, I get:</p>
<pre><code>Server [https://localhost:8443]:
</code></pre>
<p>What do I provide for the URL here, when using the OpenShift PaaS (i.e. not a local installation)? I've tried things like <code>https://openshift.com/</code> and the URL of my web app, but both of them result in</p>
<pre><code>error: The server was unable to respond - verify you have provided the correct host and port and that the server is currently running.
</code></pre>
<p>* I decided to use Bitbucket instead of GitHub; I'm not sure if this is unsupported, or (if it's supported) whether I should be providing <code>USERNAME@bitbucket.org</code>.</p>
| 0debug |
static void gen_spr_604 (CPUPPCState *env)
{
spr_register(env, SPR_PIR, "PIR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_pir,
0x00000000);
spr_register(env, SPR_IABR, "IABR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_DABR, "DABR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_MMCR0, "MMCR0",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_MMCR1, "MMCR1",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_PMC1, "PMC1",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_PMC2, "PMC2",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_PMC3, "PMC3",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_PMC4, "PMC4",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_SIAR, "SIAR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, SPR_NOACCESS,
0x00000000);
spr_register(env, SPR_SDA, "SDA",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, SPR_NOACCESS,
0x00000000);
spr_register(env, SPR_EAR, "EAR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
}
| 1threat |
How to insert column in sql server dynamically using stored procedures? : M trying this query bt its not working.
CREATE PROCEDURE USP_UPDATEUSERS_0 @COLUMNNAME NVARCHAR(30),@DATATYPE NVARCHAR(30) AS ALTER TABLE HC_USER_MAIN ADD COLUMNNAME=@COLUMNNAME DATATYPE=@DATATYPE
its showing error:
Msg 102, Level 15, State 1, Procedure USP_UPDATEUSERS_0, Line 1
Incorrect syntax near '='. | 0debug |
Store First & Second Character value in two different veritable : <p>I wish to store First & Second character of value in two different variable <code>id</code> with <code>ccMain</code>.Using jquery or Javascript.</p>
<p>Here is the html code I have to set up the environment:</p>
<pre><code><span id="ccMain">GM</span>
</code></pre>
| 0debug |
How to make this regex have proper syntax for python 3 : #!/usr/bin/env python
# -*- encoding: utf8 -*-
import re
sample = u'I am from 美国。We should be friends. 朋友。'
for n in re.findall(ur'[\u4e00-\u9fff]+',sample):
print n | 0debug |
Making Unix shell scripts POSIX compliant : <p>I have been working on a shell script to automate some tasks. What is the best way to make sure the shell script would run without any issues in most of the platforms. For ex., I have been using <code>echo -n</code> command to print some messages to the screen without a trailing new line and the <code>-n</code> switch doesn't work in some ksh shells. I was told the script must be POSIX compliant. How do I make sure that the script is POSIX compliant. Is there a tool? Or is there a shell that supports only bare minimum POSIX requirements?</p>
| 0debug |
static int applehttp_open(URLContext *h, const char *uri, int flags)
{
AppleHTTPContext *s;
int ret, i;
const char *nested_url;
if (flags & AVIO_FLAG_WRITE)
return AVERROR(ENOSYS);
s = av_mallocz(sizeof(AppleHTTPContext));
if (!s)
return AVERROR(ENOMEM);
h->priv_data = s;
h->is_streamed = 1;
if (av_strstart(uri, "applehttp+", &nested_url)) {
av_strlcpy(s->playlisturl, nested_url, sizeof(s->playlisturl));
} else if (av_strstart(uri, "applehttp:
av_strlcpy(s->playlisturl, "http:
av_strlcat(s->playlisturl, nested_url, sizeof(s->playlisturl));
} else {
av_log(h, AV_LOG_ERROR, "Unsupported url %s\n", uri);
ret = AVERROR(EINVAL);
goto fail;
}
if ((ret = parse_playlist(h, s->playlisturl)) < 0)
goto fail;
if (s->n_segments == 0 && s->n_variants > 0) {
int max_bandwidth = 0, maxvar = -1;
for (i = 0; i < s->n_variants; i++) {
if (s->variants[i]->bandwidth > max_bandwidth || i == 0) {
max_bandwidth = s->variants[i]->bandwidth;
maxvar = i;
}
}
av_strlcpy(s->playlisturl, s->variants[maxvar]->url,
sizeof(s->playlisturl));
if ((ret = parse_playlist(h, s->playlisturl)) < 0)
goto fail;
}
if (s->n_segments == 0) {
av_log(h, AV_LOG_WARNING, "Empty playlist\n");
ret = AVERROR(EIO);
goto fail;
}
s->cur_seq_no = s->start_seq_no;
if (!s->finished && s->n_segments >= 3)
s->cur_seq_no = s->start_seq_no + s->n_segments - 3;
return 0;
fail:
av_free(s);
return ret;
}
| 1threat |
What does it mean to initialize a string like "std::string mystring{""};". Is it new feature of C++ 11 or 14? : <p>I am new to <strong>C++ 11 & 14</strong>. In my new role I saw a code where <strong>string was initialized</strong> (below) and I do not know what is this new way called and where to read about it. Can some one tell what is it called and how does it work. Regards.</p>
<pre><code>std::string mystring{""};
</code></pre>
| 0debug |
How to serve static directory from "ng serve" : <p>Can I ask if there are any similar config for webpack dev server config like this:</p>
<pre><code>devServer : {
historyApiFallback : true,
stats : 'minimal',
contentBase: helpers.root('../src/static'),
}
</code></pre>
<p>I want to serve static files from static directory like how the webpack dev server is serving files.
Thanks</p>
| 0debug |
Create JSON Array and JSON Object Android Studio : I'm getting data from an XML file and this is my code on parsing the XML, which I have no problems with. I'm not familiar with ArrayList so I stick with JSON.
while (eventType != XmlPullParser.END_DOCUMENT)
{
if(eventType == XmlPullParser.START_DOCUMENT)
{
Log.e("XML READ","--- Start XML ---");
}
else if(eventType == XmlPullParser.START_TAG) {
if (xpp.getName().toString().equals("question")) {
} else if (xpp.getName().toString().equals("choice")) {
try {
choices = new JSONObject();
choices.put("value", xpp.getAttributeValue(null, "value"));
choices.put("iscorrect", xpp.getAttributeValue(null, "iscorrect"));
jsonArray.put(choices);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
try {
questions.put("questions", jsonArray);
} catch (JSONException e) {
e.printStackTrace();
}
try {
eventType = xpp.next();
} catch (XmlPullParserException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
I'm trying to create a JSON Object in this structure.
{
"question": [
{
"q": "what is 1 + 1?",
"choices": [
{
"ans":"1",
"iscorrect":"false"
},
{
"ans":"2",
"iscorrect":"true"
}
]
},
]
}
I have based my code from this link
https://stackoverflow.com/questions/17810044/android-create-json-array-and-json-object
PS: Sorry for bad english
PPS: New to android | 0debug |
git clone with different username/account : <p>This is a stupid question, but I've looked it up for ages, and I can't find anything, so I have to ask it.</p>
<p>How do you <code>clone</code> something on <code>git</code> with a different account?</p>
<p>e.g if I am logged in to <code>abcdef</code>, and I want to clone something on the account <code>12345</code>, how do I do so?</p>
<p>I remember doing this before like this: <code>git clone url -l username</code>.
Then it would ask me for a <code>password</code> and I would type it in.
But this either does not work anymore, or my brain is messing with me!</p>
<p>Thanks for the help.</p>
| 0debug |
static void cpu_notify_map_clients(void)
{
MapClient *client;
while (!LIST_EMPTY(&map_client_list)) {
client = LIST_FIRST(&map_client_list);
client->callback(client->opaque);
LIST_REMOVE(client, link);
}
}
| 1threat |
org.json.JSONException: Value <br><table of type java.lang.String cannot be converted to JSONObject? : I know there a lot of people with the same problem but any answers can help me. And all just confuse me.
I'm trying to do a Login/Register on Android Studio.
The problem display is the follow.
W/System.err: org.json.JSONException: Value <br><table of type java.lang.String cannot be converted to JSONObject
W/System.err: at org.json.JSON.typeMismatch(JSON.java:111)
W/System.err: at org.json.JSONObject.<init>(JSONObject.java:160)
W/System.err: at org.json.JSONObject.<init>(JSONObject.java:173)
...
This is my code.
final Button bRegister = (Button) findViewById(R.id.rButton);
bRegister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String name = etName.getText().toString();
final String username = etUsername.getText().toString();
final String password = etPassword.getText().toString();
Response.Listener<String> responseListener = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonResponse = new JSONObject(response);
boolean success = jsonResponse.getBoolean("success");
if (success) {
Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
RegisterActivity.this.startActivity(intent);
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(RegisterActivity.this);
builder.setMessage("Register Failed")
.setNegativeButton("Retry", null)
.create()
.show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
RegisterRequest registerRequest = new RegisterRequest(name, username, password, responseListener);
RequestQueue queue = Volley.newRequestQueue(RegisterActivity.this);
queue.add(registerRequest);
}
});
}
}
And of course the php one.
<?php
$con = mysqli_connect("host", "user", "password", "database");
$name = $_POST["name"];
$username = $_POST["username"];
$password = $_POST["password"];
$statement = mysqli_prepare($con, "INSERT INTO user (name, username, password) VALUES (?, ?, ?)");
mysqli_stmt_bind_param($statement, "sss", $name, $username, $password);
mysqli_stmt_execute($statement);
$response = array();
$response["success"] = true;
echo json_encode($response);
Thanks in advance for the help and sorry for the trouble.
| 0debug |
View being blocked by UITransitionView after being presented : <p>I have a side navigation controller and present it via a UIButton. When I make this NC the root view controller directly by <code>[self presentviewcontroller: NC animated: YES completion: nil]</code>, some reason the menu side of the NC is blocked by a <code>UITransitionView</code> that I cannot get to disappear.</p>
<p>I've attached an image of the <a href="https://i.stack.imgur.com/qnlng.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qnlng.png" alt="view hierarchy"></a>. <a href="https://i.stack.imgur.com/07Muy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/07Muy.png" alt="Here"></a> is another.</p>
<p>I have tried the following:</p>
<pre><code>UIWindow *window = [(AppDelegate *)[[UIApplication sharedApplication] delegate] window];
window.backgroundColor = kmain;
CATransition* transition = [CATransition animation];
transition.duration = .5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromTop;
[nc.view.layer addAnimation:transition forKey:kCATransition];
[UIView transitionWithView:window
duration:0.5
options:UIViewAnimationOptionTransitionNone
animations:^{ window.rootViewController = nc; }
completion:^(BOOL finished) {
for (UIView *subview in window.subviews) {
if ([subview isKindOfClass:NSClassFromString(@"UITransitionView")]) {
[subview removeFromSuperview];
}
}
}];
</code></pre>
<p>But it is very hacky, and as the rootviewcontroller of the window changes during the transition, it's a little choppy and part of the navigationcontroller and the top right corner turn black. It looks very bad.</p>
| 0debug |
uint64_t cpu_get_tsc(CPUX86State *env)
{
#ifdef CONFIG_KQEMU
if (env->kqemu_enabled) {
return cpu_get_real_ticks();
} else
#endif
{
return cpu_get_ticks();
}
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.