problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
How does python pass keyword changes values in list : I have one small code in python. I have created list and I am passing it as function parameter. According to me it should give output as 1 2 3 4 5. But it is giving me 5 2 3 4 5 as output. If I am just writing 'pass' keyword inside for loop then it should not do anything.Then why is that changing my output? Please help me out.
Here is my code:
def fun1(list1):
for list1[0] in list1:
pass
list2=[1,2,3,4,5]
fun1(list2)
print(list2)
| 0debug
|
static CCIDBus *ccid_bus_new(DeviceState *dev)
{
CCIDBus *bus;
bus = FROM_QBUS(CCIDBus, qbus_create(&ccid_bus_info, dev, NULL));
bus->qbus.allow_hotplug = 1;
return bus;
}
| 1threat
|
How to configure react-script so that it doesn't override tsconfig.json on 'start' : <p>I'm currently using <code>create-react-app</code> to bootstrap one of my projects. Basically, I'm trying to set up paths in tsconfig.json by adding these to the default tsconfig.json generated by create-react-app:</p>
<pre><code>"baseUrl": "./src",
"paths": {
"interfaces/*": [
"common/interfaces/*",
],
"components/*": [
"common/components/*",
],
},
</code></pre>
<p>However, every time I run <code>yarn start</code> which basically runs <code>react-scripts start</code>, it deletes my changes and generates the default configurations again. </p>
<p>How can I tell create-react-app to use my custom configs?</p>
| 0debug
|
static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx, InputStream *ist, int in_program)
{
AVStream *stream = ist->st;
AVCodecParameters *par;
AVCodecContext *dec_ctx;
char val_str[128];
const char *s;
AVRational sar, dar;
AVBPrint pbuf;
const AVCodecDescriptor *cd;
int ret = 0;
const char *profile = NULL;
av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
writer_print_section_header(w, in_program ? SECTION_ID_PROGRAM_STREAM : SECTION_ID_STREAM);
print_int("index", stream->index);
par = stream->codecpar;
dec_ctx = ist->dec_ctx;
if (cd = avcodec_descriptor_get(par->codec_id)) {
print_str("codec_name", cd->name);
if (!do_bitexact) {
print_str("codec_long_name",
cd->long_name ? cd->long_name : "unknown");
}
} else {
print_str_opt("codec_name", "unknown");
if (!do_bitexact) {
print_str_opt("codec_long_name", "unknown");
}
}
if (!do_bitexact && (profile = avcodec_profile_name(par->codec_id, par->profile)))
print_str("profile", profile);
else {
if (par->profile != FF_PROFILE_UNKNOWN) {
char profile_num[12];
snprintf(profile_num, sizeof(profile_num), "%d", par->profile);
print_str("profile", profile_num);
} else
print_str_opt("profile", "unknown");
}
s = av_get_media_type_string(par->codec_type);
if (s) print_str ("codec_type", s);
else print_str_opt("codec_type", "unknown");
#if FF_API_LAVF_AVCTX
print_q("codec_time_base", dec_ctx->time_base, '/');
#endif
av_get_codec_tag_string(val_str, sizeof(val_str), par->codec_tag);
print_str("codec_tag_string", val_str);
print_fmt("codec_tag", "0x%04x", par->codec_tag);
switch (par->codec_type) {
case AVMEDIA_TYPE_VIDEO:
print_int("width", par->width);
print_int("height", par->height);
if (dec_ctx) {
print_int("coded_width", dec_ctx->coded_width);
print_int("coded_height", dec_ctx->coded_height);
}
print_int("has_b_frames", par->video_delay);
sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
if (sar.den) {
print_q("sample_aspect_ratio", sar, ':');
av_reduce(&dar.num, &dar.den,
par->width * sar.num,
par->height * sar.den,
1024*1024);
print_q("display_aspect_ratio", dar, ':');
} else {
print_str_opt("sample_aspect_ratio", "N/A");
print_str_opt("display_aspect_ratio", "N/A");
}
s = av_get_pix_fmt_name(par->format);
if (s) print_str ("pix_fmt", s);
else print_str_opt("pix_fmt", "unknown");
print_int("level", par->level);
if (par->color_range != AVCOL_RANGE_UNSPECIFIED)
print_str ("color_range", av_color_range_name(par->color_range));
else
print_str_opt("color_range", "N/A");
s = av_get_colorspace_name(par->color_space);
if (s) print_str ("color_space", s);
else print_str_opt("color_space", "unknown");
if (par->color_trc != AVCOL_TRC_UNSPECIFIED)
print_str("color_transfer", av_color_transfer_name(par->color_trc));
else
print_str_opt("color_transfer", av_color_transfer_name(par->color_trc));
if (par->color_primaries != AVCOL_PRI_UNSPECIFIED)
print_str("color_primaries", av_color_primaries_name(par->color_primaries));
else
print_str_opt("color_primaries", av_color_primaries_name(par->color_primaries));
if (par->chroma_location != AVCHROMA_LOC_UNSPECIFIED)
print_str("chroma_location", av_chroma_location_name(par->chroma_location));
else
print_str_opt("chroma_location", av_chroma_location_name(par->chroma_location));
#if FF_API_PRIVATE_OPT
if (dec_ctx && dec_ctx->timecode_frame_start >= 0) {
char tcbuf[AV_TIMECODE_STR_SIZE];
av_timecode_make_mpeg_tc_string(tcbuf, dec_ctx->timecode_frame_start);
print_str("timecode", tcbuf);
} else {
print_str_opt("timecode", "N/A");
}
#endif
if (dec_ctx)
print_int("refs", dec_ctx->refs);
break;
case AVMEDIA_TYPE_AUDIO:
s = av_get_sample_fmt_name(par->format);
if (s) print_str ("sample_fmt", s);
else print_str_opt("sample_fmt", "unknown");
print_val("sample_rate", par->sample_rate, unit_hertz_str);
print_int("channels", par->channels);
if (par->channel_layout) {
av_bprint_clear(&pbuf);
av_bprint_channel_layout(&pbuf, par->channels, par->channel_layout);
print_str ("channel_layout", pbuf.str);
} else {
print_str_opt("channel_layout", "unknown");
}
print_int("bits_per_sample", av_get_bits_per_sample(par->codec_id));
break;
case AVMEDIA_TYPE_SUBTITLE:
if (par->width)
print_int("width", par->width);
else
print_str_opt("width", "N/A");
if (par->height)
print_int("height", par->height);
else
print_str_opt("height", "N/A");
break;
}
if (dec_ctx && dec_ctx->codec && dec_ctx->codec->priv_class && show_private_data) {
const AVOption *opt = NULL;
while (opt = av_opt_next(dec_ctx->priv_data,opt)) {
uint8_t *str;
if (opt->flags) continue;
if (av_opt_get(dec_ctx->priv_data, opt->name, 0, &str) >= 0) {
print_str(opt->name, str);
av_free(str);
}
}
}
if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS) print_fmt ("id", "0x%x", stream->id);
else print_str_opt("id", "N/A");
print_q("r_frame_rate", stream->r_frame_rate, '/');
print_q("avg_frame_rate", stream->avg_frame_rate, '/');
print_q("time_base", stream->time_base, '/');
print_ts ("start_pts", stream->start_time);
print_time("start_time", stream->start_time, &stream->time_base);
print_ts ("duration_ts", stream->duration);
print_time("duration", stream->duration, &stream->time_base);
if (par->bit_rate > 0) print_val ("bit_rate", par->bit_rate, unit_bit_per_second_str);
else print_str_opt("bit_rate", "N/A");
#if FF_API_LAVF_AVCTX
if (stream->codec->rc_max_rate > 0) print_val ("max_bit_rate", stream->codec->rc_max_rate, unit_bit_per_second_str);
else print_str_opt("max_bit_rate", "N/A");
#endif
if (dec_ctx && dec_ctx->bits_per_raw_sample > 0) print_fmt("bits_per_raw_sample", "%d", dec_ctx->bits_per_raw_sample);
else print_str_opt("bits_per_raw_sample", "N/A");
if (stream->nb_frames) print_fmt ("nb_frames", "%"PRId64, stream->nb_frames);
else print_str_opt("nb_frames", "N/A");
if (nb_streams_frames[stream_idx]) print_fmt ("nb_read_frames", "%"PRIu64, nb_streams_frames[stream_idx]);
else print_str_opt("nb_read_frames", "N/A");
if (nb_streams_packets[stream_idx]) print_fmt ("nb_read_packets", "%"PRIu64, nb_streams_packets[stream_idx]);
else print_str_opt("nb_read_packets", "N/A");
if (do_show_data)
writer_print_data(w, "extradata", par->extradata,
par->extradata_size);
writer_print_data_hash(w, "extradata_hash", par->extradata,
par->extradata_size);
#define PRINT_DISPOSITION(flagname, name) do { \
print_int(name, !!(stream->disposition & AV_DISPOSITION_##flagname)); \
} while (0)
if (do_show_stream_disposition) {
writer_print_section_header(w, in_program ? SECTION_ID_PROGRAM_STREAM_DISPOSITION : SECTION_ID_STREAM_DISPOSITION);
PRINT_DISPOSITION(DEFAULT, "default");
PRINT_DISPOSITION(DUB, "dub");
PRINT_DISPOSITION(ORIGINAL, "original");
PRINT_DISPOSITION(COMMENT, "comment");
PRINT_DISPOSITION(LYRICS, "lyrics");
PRINT_DISPOSITION(KARAOKE, "karaoke");
PRINT_DISPOSITION(FORCED, "forced");
PRINT_DISPOSITION(HEARING_IMPAIRED, "hearing_impaired");
PRINT_DISPOSITION(VISUAL_IMPAIRED, "visual_impaired");
PRINT_DISPOSITION(CLEAN_EFFECTS, "clean_effects");
PRINT_DISPOSITION(ATTACHED_PIC, "attached_pic");
writer_print_section_footer(w);
}
if (do_show_stream_tags)
ret = show_tags(w, stream->metadata, in_program ? SECTION_ID_PROGRAM_STREAM_TAGS : SECTION_ID_STREAM_TAGS);
if (stream->nb_side_data) {
int i;
writer_print_section_header(w, SECTION_ID_STREAM_SIDE_DATA_LIST);
for (i = 0; i < stream->nb_side_data; i++) {
AVPacketSideData *sd = &stream->side_data[i];
const char *name = av_packet_side_data_name(sd->type);
writer_print_section_header(w, SECTION_ID_STREAM_SIDE_DATA);
print_str("side_data_type", name ? name : "unknown");
print_int("side_data_size", sd->size);
if (sd->type == AV_PKT_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
writer_print_integers(w, "displaymatrix", sd->data, 9, " %11d", 3, 4, 1);
print_int("rotation", av_display_rotation_get((int32_t *)sd->data));
}
writer_print_section_footer(w);
}
writer_print_section_footer(w);
}
writer_print_section_footer(w);
av_bprint_finalize(&pbuf, NULL);
fflush(stdout);
return ret;
}
| 1threat
|
static int gif_parse_next_image(GifState *s)
{
ByteIOContext *f = s->f;
int ret, code;
for (;;) {
code = url_fgetc(f);
#ifdef DEBUG
printf("gif: code=%02x '%c'\n", code, code);
#endif
switch (code) {
case ',':
if (gif_read_image(s) < 0)
return AVERROR(EIO);
ret = 0;
goto the_end;
case ';':
ret = AVERROR(EIO);
goto the_end;
case '!':
if (gif_read_extension(s) < 0)
return AVERROR(EIO);
break;
case EOF:
default:
ret = AVERROR(EIO);
goto the_end;
}
}
the_end:
return ret;
}
| 1threat
|
How can i to make anagram program using who char with dynamic array? : this is the Code i have, what should i do ? it's not event a String. it use dynamic Array. i dont event know what i should to do. thanks
import java.util.ArrayList;
import java.util.Collections;
public class ArrayCheck {
public boolean isAnagram(ArrayList<Character> arr1, ArrayList<Character> arr2) {
}
}
| 0debug
|
Angular 4 setting selected option in Dropdown : <p>several questions about this and diffrent answeres. But none of them realy answeres the question. So again:</p>
<p>Setting default of a Dropdown select by value isnt working in my case. why?
This is from the dynamic Form tutorial of Angular 4:</p>
<pre><code><select [id]="question.key" [formControlName]="question.key">
<option *ngFor="let opt of question.options" [value]="opt.key" [selected]="opt.selected">{{opt.selected+opt.value}}</option>
</select>
</code></pre>
<p>It doesnt select anything. Available options are:</p>
<ul>
<li>trueaaa</li>
<li>falsebbb</li>
<li>falseccc</li>
</ul>
<p>But static true:</p>
<pre><code><option ... [selected]="true">...</option>
</code></pre>
<p>selects the last value (all true).
It also works with a private variable <code>boolvar = true</code> and using it in <code>[selected]="boolvar"</code></p>
<p>I dont understand the difference between the "opt" object and the class variable??</p>
| 0debug
|
static void virtio_vga_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
{
VirtIOVGA *vvga = VIRTIO_VGA(vpci_dev);
VirtIOGPU *g = &vvga->vdev;
VGACommonState *vga = &vvga->vga;
Error *err = NULL;
uint32_t offset;
int i;
vga->vram_size_mb = 8;
vga_common_init(vga, OBJECT(vpci_dev), false);
vga_init(vga, OBJECT(vpci_dev), pci_address_space(&vpci_dev->pci_dev),
pci_address_space_io(&vpci_dev->pci_dev), true);
pci_register_bar(&vpci_dev->pci_dev, 0,
PCI_BASE_ADDRESS_MEM_PREFETCH, &vga->vram);
vpci_dev->modern_mem_bar = 2;
vpci_dev->msix_bar = 4;
offset = memory_region_size(&vpci_dev->modern_bar);
offset -= vpci_dev->notify.size;
vpci_dev->notify.offset = offset;
offset -= vpci_dev->device.size;
vpci_dev->device.offset = offset;
offset -= vpci_dev->isr.size;
vpci_dev->isr.offset = offset;
offset -= vpci_dev->common.size;
vpci_dev->common.offset = offset;
qdev_set_parent_bus(DEVICE(g), BUS(&vpci_dev->bus));
vpci_dev->flags &= ~VIRTIO_PCI_FLAG_DISABLE_MODERN;
vpci_dev->flags |= VIRTIO_PCI_FLAG_DISABLE_LEGACY;
object_property_set_bool(OBJECT(g), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
pci_std_vga_mmio_region_init(vga, &vpci_dev->modern_bar,
vvga->vga_mrs, true);
vga->con = g->scanout[0].con;
graphic_console_set_hwops(vga->con, &virtio_vga_ops, vvga);
for (i = 0; i < g->conf.max_outputs; i++) {
object_property_set_link(OBJECT(g->scanout[i].con),
OBJECT(vpci_dev),
"device", errp);
}
}
| 1threat
|
unable to implement OnClickListener into seperate java class (android studio) : OnClickListener works fine when i implement on MainActivity class of java .But its a messy practice to use on same class of main interference.
So i add a separate java class "ButtonListener.java" and wrote the following code
package com.example.gowat.onclicklistner.ListenerPKG;
import android.graphics.Color;
import android.view.View;
import com.example.gowat.onclicklistner.MainActivity;
import com.example.gowat.onclicklistner.R;
public class ButtonListener extends MainActivity implements View.OnClickListener {
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.button2:
CL.setBackgroundColor(Color.parseColor("#00ff00"));
break;
case R.id.button:
CL.setBackgroundColor(Color.BLUE);
break; }}}
and following is code of "MainActivity.java"
package com.example.gowat.onclicklistner;
import android.content.Context;
import android.graphics.Color;
import android.support.constraint.ConstraintLayout;
import android.support.constraint.Constraints;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import com.example.gowat.onclicklistner.ListenerPKG.ButtonListener;
public class MainActivity extends AppCompatActivity {
public ConstraintLayout CL;
public Button blue,green;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
blue= (Button)findViewById(R.id.button);
green=findViewById(R.id.button2);
CL= findViewById(R.id.CL) ;
ButtonListener B= new ButtonListener();
blue.setOnClickListener(B);
green.setOnClickListener(B);
}}
I am trying this code but when ever i open my app and click on button it got crash.. any idea how to make it work?? i am trying it for 5 hours now :(
| 0debug
|
void x86_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
const char *optarg)
{
unsigned char model = !strcmp("?model", optarg);
unsigned char dump = !strcmp("?dump", optarg);
unsigned char cpuid = !strcmp("?cpuid", optarg);
x86_def_t *def;
char buf[256];
if (cpuid) {
(*cpu_fprintf)(f, "Recognized CPUID flags:\n");
listflags(buf, sizeof (buf), (uint32_t)~0, feature_name, 1);
(*cpu_fprintf)(f, " f_edx: %s\n", buf);
listflags(buf, sizeof (buf), (uint32_t)~0, ext_feature_name, 1);
(*cpu_fprintf)(f, " f_ecx: %s\n", buf);
listflags(buf, sizeof (buf), (uint32_t)~0, ext2_feature_name, 1);
(*cpu_fprintf)(f, " extf_edx: %s\n", buf);
listflags(buf, sizeof (buf), (uint32_t)~0, ext3_feature_name, 1);
(*cpu_fprintf)(f, " extf_ecx: %s\n", buf);
return;
}
for (def = x86_defs; def; def = def->next) {
snprintf(buf, sizeof (buf), def->flags ? "[%s]": "%s", def->name);
if (model || dump) {
(*cpu_fprintf)(f, "x86 %16s %-48s\n", buf, def->model_id);
} else {
(*cpu_fprintf)(f, "x86 %16s\n", buf);
}
if (dump) {
memcpy(buf, &def->vendor1, sizeof (def->vendor1));
memcpy(buf + 4, &def->vendor2, sizeof (def->vendor2));
memcpy(buf + 8, &def->vendor3, sizeof (def->vendor3));
buf[12] = '\0';
(*cpu_fprintf)(f,
" family %d model %d stepping %d level %d xlevel 0x%x"
" vendor \"%s\"\n",
def->family, def->model, def->stepping, def->level,
def->xlevel, buf);
listflags(buf, sizeof (buf), def->features, feature_name, 0);
(*cpu_fprintf)(f, " feature_edx %08x (%s)\n", def->features,
buf);
listflags(buf, sizeof (buf), def->ext_features, ext_feature_name,
0);
(*cpu_fprintf)(f, " feature_ecx %08x (%s)\n", def->ext_features,
buf);
listflags(buf, sizeof (buf), def->ext2_features, ext2_feature_name,
0);
(*cpu_fprintf)(f, " extfeature_edx %08x (%s)\n",
def->ext2_features, buf);
listflags(buf, sizeof (buf), def->ext3_features, ext3_feature_name,
0);
(*cpu_fprintf)(f, " extfeature_ecx %08x (%s)\n",
def->ext3_features, buf);
(*cpu_fprintf)(f, "\n");
}
}
if (kvm_enabled()) {
(*cpu_fprintf)(f, "x86 %16s\n", "[host]");
}
}
| 1threat
|
How can i sum two or more numbers(possibility for client to enter two or more numbers) same for Subtraction, Multiplication and Division c# : using System;
using System.Linq;
namespace Kalkulator
{
internal class Program
{
private static void Main(string[] args)
{
switch (ChooseOperation())
{
case "1":
Addition();
break;
case "2":
Subtraction();
break;
case "3":
Multiplication();
break;
case "4":
Division();
break;
default:
break;
}
}//I'm trying to make
private static string ChooseOperation()
{
string choose = "Choose from 1 to 4 for operation: \n 1.Addition\n 2.Subtraction\n 3.Multiplication\n 4.Division";
string[] option = { "1", "2", "3", "4" };
Console.WriteLine(choose);
string operation = Console.ReadLine();
while (!option.Contains(operation))
{
Console.WriteLine("You have to enter right option!");
Console.WriteLine(choose);
operation = Console.ReadLine();
}
return operation;
}
private static int[] ChooseOperands()
{
int[] operands = new int[2];
Console.Write("Enter first operand: ");
operands[0] = int.Parse(Console.ReadLine());
Console.Write("Enter second operand: ");
operands[1] = int.Parse(Console.ReadLine());
return operands;
}
private static void Addition()
{
Console.WriteLine("You selected Addition (+)");
int[] operands = ChooseOperands();
int result = 0;
for (int index = 1; index < operands.Length; index++)
result += operands[index];
Console.WriteLine();
Console.WriteLine("Addition result: {0}", result);
Console.ReadKey();
}
private static void Subtraction()
{
Console.WriteLine("You selected Subtraction (-)");
int[] operands = ChooseOperands();
int result = operands[0];
for (int index = 1; index < operands.Length; index++)
result -= operands[index];
Console.WriteLine();
Console.WriteLine("Subtraction result: {0}", result);
Console.ReadKey();
}
private static void Multiplication()
{
Console.WriteLine("You selected Multiplication (*)");
int[] operands = ChooseOperands();
int result = operands[0];
for (int index = 1; index < operands.Length; index++)
result *= operands[index];
Console.WriteLine();
Console.WriteLine("Multiplication result: {0}", result);
Console.ReadKey();
}
private static void Division()
{
Console.WriteLine("You selected Division (/)");
int[] operands = ChooseOperands();
int result = operands[0];
for (int index = 1; index < operands.Length; index++)
result /= operands[index];
Console.WriteLine();
Console.WriteLine("Division result: {0}", result);
Console.ReadKey();
}
}
}//i' m working on simplified calculator where user have to put 2 or more numbers for four operations: 1.Addition 2.Subtraction 3.Multiplication 4.Division
,but every time when I put more then two numbers its not working?//
| 0debug
|
Replace items in a list by for in statement ( Python) : <p>I am a new Python user and I am wondering how to replace every integer in a list with str variables? </p>
<p>I used the for-in statement, but it is not working. Please let me know how I can make the code work? Thank you so much! </p>
<p><a href="https://i.stack.imgur.com/3m7PX.png" rel="nofollow noreferrer">my code (what is wrong here?</a></p>
| 0debug
|
How can I see the current version of packages installed by pipenv? : <p>I'm managing my Python dependencies with <a href="https://pipenv.readthedocs.io/en/latest/" rel="noreferrer">pipenv</a>. How can see the currently installed versions of packages?</p>
<p>I could examine <code>Pipfile.lock</code>, but is there a simpler way from the command line?</p>
| 0debug
|
Is there Multimap in Kotlin? : <p>I need to store values in map likie this:</p>
<pre><code> val map = HashMap<String, Set<String>>()
</code></pre>
<p>But it is hard to interact with Set inside the map.</p>
<p>Is there any multimap implementations in Kotlin like <a href="https://google.github.io/guava/releases/19.0/api/docs/com/google/common/collect/Multimap.html" rel="noreferrer"> Multimap in Google Guava</a>?</p>
| 0debug
|
what's the difference between the two function? : def PartitionDemo(a,p,r):
x=a[p]
start=p
end=r
while start<end :
while start<end and a[end]>=x :
end-=1
while start<end and a[start]<x :
a[start]=a[end]
start+=1
a[end]=a[start]
a[start]=x
return start
def Partition2(a,low,high):
key = a[low]
while low < high:
while low < high and a[high] >= key:
high -= 1
while low < high and a[high] < key:
a[low] = a[high]
low += 1
a[high] = a[low]
a[low] = key
return low
PartitionDemo i write it myself,Partition2 i copy it from the net.but PartitionDemo can't run normally.it can not jump out the loop.they are the same logic i think.Partition2 works well.i try the quicksort in C++,Java,python.i don't understand what's going wrong in python.
| 0debug
|
JAVA class hierarchy: Which of the following lines will not compile? : <p>Having the following class hierarchy:</p>
<pre><code>Interface Animal {…}
class Dog implements Animal{…}
class Poodle extends Dog {…}
class Labrador extends Dog {…}
</code></pre>
<p>Which of the following lines will not compile? </p>
<pre><code>Poodle poodle = new Poodle(); //1
Animal animal = (Animal) poodle; //2
Dog dog = new Labrador(); //3
animal = dog; //4
poodle = dog; //5
Animal labrador = new Labrador(); //6
Dog dog2 = new Labrador(); //7
dog 2=labrador;//8
</code></pre>
<p>I think line 5: because of poodle's and dog's static binding.</p>
<p>Line 8 : only static binding is relevant for an assignment .</p>
<p>Am I right? May you give an explanation? </p>
| 0debug
|
Need explaining on what code does : <p>So I have this code because I need to add photos to my JTable and so I need to make an abstract table model. However, after seeing this code I seriously have no idea what It does, but I really want to understand it. If you could please explain it to me that would be awesome! (I also have no idea what Icon.class does inside of the code). The code is the following:</p>
<pre><code>public class TheModel extends AbstractTableModel {
private String[] columns;
private Object[][] rows;
public TheModel(){}
public TheModel(Object[][] data, String[] columnName){
this.rows = data;
this.columns = columnName;
}
public Class getColumnClass(int column){
// 4 is the index of the column image
if(column == 4){
return Icon.class;
}
else{
return getValueAt(0,column).getClass();
}
}
public int getRowCount() {
return this.rows.length;
}
public int getColumnCount() {
return this.columns.length;
}
public Object getValueAt(int rowIndex, int columnIndex) {
return this.rows[rowIndex][columnIndex];
}
public String getColumnName(int col){
return this.columns[col];
}
}
</code></pre>
<p>Every explanation is greatly appreciated! I know this website is mostly for help with coding problems not with explaining but I really hope you guys could make an exception .</p>
| 0debug
|
Use a generator for Keras model.fit_generator : <p>I originally tried to use <code>generator</code> syntax when writing a custom generator for training a Keras model. So I <code>yield</code>ed from <code>__next__</code>. However, when I would try to train my mode with <code>model.fit_generator</code> I would get an error that my generator was not an iterator. The fix was to change <code>yield</code> to <code>return</code> which also necessitated rejiggering the logic of <code>__next__</code> to track state. It's quite cumbersome compared to letting <code>yield</code> do the work for me.</p>
<p>Is there a way I can make this work with <code>yield</code>? I will need to write several more iterators that will have to have very clunky logic if I have to use a <code>return</code> statement.</p>
| 0debug
|
static inline void gen_op_eval_bge(TCGv dst, TCGv_i32 src)
{
gen_mov_reg_V(cpu_tmp0, src);
gen_mov_reg_N(dst, src);
tcg_gen_xor_tl(dst, dst, cpu_tmp0);
tcg_gen_xori_tl(dst, dst, 0x1);
}
| 1threat
|
using an enviroment variable for local sequelize configuration : <p>I'm looking to use an environment variable inside of the config.json file of my project using sequelize. I'm using dotenv to set environment variables locally. My config.json file looks like this</p>
<pre><code>{
"development": {
"username": process.env.DB_USER,
"password": process.env.DB_PASS,
"database": process.env.DB_DATABASE,
"host": process.env.DB_HOST,
"dialect": "mysql"
},
"test": {
"username": "root",
"password": null,
"database": "database_test",
"host": "127.0.0.1",
"dialect": "mysql"
},
"production": {
"use_env_variable": "JAWSDB_URL",
"dialect": "mysql"
}
}
</code></pre>
<p>The issue I'm having is that I can't use variables inside the config.json file. It looks like for production I can use the "use_env_varable" key and use the env variable for my connection string. So I guess I either need a way to figure out the combined connection string for my local mysql db or a way to use variables inside the config.json. Any solutions?</p>
| 0debug
|
How to send button value to datagridview? : How to send a button value to data grid view ,if the data grid view cell is last focus then the button value goes to last focus cell.
| 0debug
|
static uint64_t get_cluster_offset(BlockDriverState *bs,
uint64_t offset, int *num)
{
BDRVQcowState *s = bs->opaque;
int l1_index, l2_index;
uint64_t l2_offset, *l2_table, cluster_offset;
int l1_bits, c;
int index_in_cluster, nb_available, nb_needed, nb_clusters;
index_in_cluster = (offset >> 9) & (s->cluster_sectors - 1);
nb_needed = *num + index_in_cluster;
l1_bits = s->l2_bits + s->cluster_bits;
nb_available = (1 << l1_bits) - (offset & ((1 << l1_bits) - 1));
nb_available = (nb_available >> 9) + index_in_cluster;
cluster_offset = 0;
l1_index = offset >> l1_bits;
if (l1_index >= s->l1_size)
goto out;
l2_offset = s->l1_table[l1_index];
if (!l2_offset)
goto out;
l2_offset &= ~QCOW_OFLAG_COPIED;
l2_table = l2_load(bs, l2_offset);
if (l2_table == NULL)
return 0;
l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
cluster_offset = be64_to_cpu(l2_table[l2_index]);
nb_clusters = size_to_clusters(s, nb_needed << 9);
if (!cluster_offset) {
c = count_contiguous_free_clusters(nb_clusters, &l2_table[l2_index]);
} else {
c = count_contiguous_clusters(nb_clusters, s->cluster_size,
&l2_table[l2_index], 0, QCOW_OFLAG_COPIED);
nb_available = (c * s->cluster_sectors);
out:
if (nb_available > nb_needed)
nb_available = nb_needed;
*num = nb_available - index_in_cluster;
return cluster_offset & ~QCOW_OFLAG_COPIED;
| 1threat
|
disabling navlink react router : <p>I am using react router in and I want to disable the to attribute in a certain state. I passed empty string, but that doesn't disable the link instead it takes to the base route of the page. I even tried to pass null but that breaks the code. Is it even possible to do so?</p>
<pre><code><NavLink className="nav-link" to={this.state.role == 4 ? "/pages" : ""}></NavLink>
</code></pre>
| 0debug
|
static int handle_utimensat(FsContext *ctx, V9fsPath *fs_path,
const struct timespec *buf)
{
int ret;
#ifdef CONFIG_UTIMENSAT
int fd;
struct handle_data *data = (struct handle_data *)ctx->private;
fd = open_by_handle(data->mountfd, fs_path->data, O_NONBLOCK);
if (fd < 0) {
return fd;
}
ret = futimens(fd, buf);
close(fd);
#else
ret = -1;
errno = ENOSYS;
#endif
return ret;
}
| 1threat
|
def min_of_three(a,b,c):
if (a <= b) and (a <= c):
smallest = a
elif (b <= a) and (b <= c):
smallest = b
else:
smallest = c
return smallest
| 0debug
|
Is there any tool for monitoring Memory Management? : <p>I know we can check in android studio itself, but i want separate tool for
testing.please can any one suggest what are the tools are available for test for android app performance....</p>
| 0debug
|
unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, CPUARMState* qregs)
{
unsigned int nRc = 0;
FPA11 *fpa11;
qemufpa=qfpa;
user_registers=qregs;
#if 0
fprintf(stderr,"emulating FP insn 0x%08x, PC=0x%08x\n",
opcode, qregs[REG_PC]);
#endif
fpa11 = GET_FPA11();
if (fpa11->initflag == 0)
{
resetFPA11();
SetRoundingMode(ROUND_TO_NEAREST);
SetRoundingPrecision(ROUND_EXTENDED);
fpa11->initflag = 1;
}
set_float_exception_flags(0, &fpa11->fp_status);
if (TEST_OPCODE(opcode,MASK_CPRT))
{
nRc = EmulateCPRT(opcode);
}
else if (TEST_OPCODE(opcode,MASK_CPDO))
{
nRc = EmulateCPDO(opcode);
}
else if (TEST_OPCODE(opcode,MASK_CPDT))
{
nRc = EmulateCPDT(opcode);
}
else
{
nRc = 0;
}
if(nRc == 1 && get_float_exception_flags(&fpa11->fp_status))
{
nRc -= get_float_exception_flags(&fpa11->fp_status);
}
return(nRc);
}
| 1threat
|
How to debug this debugger error? : I am using `SQLite` Database to get the product name, quantity, price but when ever i press add_to_cart button, it force closes.
[This is what my debugger says, how to debug this ][1]
public void addToCart(Order order){
SQLiteDatabase db = getReadableDatabase();
String query = String.format("INSERT INTO OrderDetail(Productid,ProductName,Quantity,Price) VALUES('%s','%s','%s','%s');",
order.getProductid(),
order.getProductName(),
order.getQuantity(),
order.getPrice());
db.execSQL(query);
}
btncart = (FloatingActionButton)findViewById(R.id.btncart);
btncart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//line 49//
new Database(FoodDetails.this).addToCart(new Order(
foodId,
currentFood.getName(),
numberButton.getNumber(),
currentFood.getPrice()
));
Toast.makeText(FoodDetails.this,"Added to cart",Toast.LENGTH_SHORT).show();
}
});
This is the given `StackTrace`:
> at com.k.menu.Database.Database.addToCart(Database.java:54)
> at com.k.menu.FoodDetails$1.onClick(FoodDetails.java:49) These two are
> the errors i got from logcat
>
1-19 19:43:14.767 9304-9304/com.k.menu E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.k.menu, PID: 9304
com.readystatesoftware.sqliteasset.SQLiteAssetHelper$SQLiteAssetException: Missing databases/eatitDb.db file (or .zip, .gz archive) in assets, or target folder not writable
at android.content.res.AssetManager.openAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:347)
at android.content.res.AssetManager.open(AssetManager.java:321)
at com.readystatesoftware.sqliteasset.SQLiteAssetHelper.copyDatabaseFromAssets(SQLiteAssetHelper.java:436)
at com.readystatesoftware.sqliteasset.SQLiteAssetHelper.createOrOpenDatabase(SQLiteAssetHelper.java:400)
at com.readystatesoftware.sqliteasset.SQLiteAssetHelper.getWritableDatabase(SQLiteAssetHelper.java:176)
at com.k.menu.Database.Database.addToCart(Database.java:54)
at com.k.menu.FoodDetails$1.onClick(FoodDetails.java:49)
at android.view.View.performClick(View.java:5637)
at android.view.View$PerformClick.run(View.java:22429)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
The below link has my application database and food details https://www.dropbox.com/sh/j2j4umz5wv2o7t4/AACIExIYT24SjiYlxbZ0Ut24a?dl=0
[1]: https://i.stack.imgur.com/Sy1Zx.png
| 0debug
|
How to create optional RewriteCond in Apache : <p>i have touble for my .htaccess config., this is part of config:</p>
<pre><code>RewriteCond %{QUERY_STRING} ^token=(.*)
RewriteRule ^aplikasi/(.*).asp aplikasi.php?halaman=$1&token=%1
</code></pre>
<p>and result that config is:</p>
<pre><code>http://{domain}/aplikasi/{$1}.asp?token={%1}
</code></pre>
<p>if i using this link:</p>
<pre><code>http://{domain}/aplikasi/{$1}.asp
</code></pre>
<p>i have 404 error, i my question is : how to create like that with optional token prameter (i want to "?token={%1}" is optional)</p>
| 0debug
|
query = 'SELECT * FROM customers WHERE email = ' + email_input
| 1threat
|
Javscript object with shared name : So, I'm trying to create an object like:
var a = {
b:"object_id",
b:function(){ return c(this.b); }
}
var c = {
"object_id": {
foo: "bar"
}
}
But it only registers the last value for the key 'b'. But I think I've seen something like this used before and it would really help me if I could call a.b().foo or if I just want ID a.b
Is there any way to make this happen or will I have to rename value and/or method?
| 0debug
|
Chrome extension page action appearing outside of address bar : <p>I wrote a Chrome Extension page action, with the following implementation:</p>
<p>In manifest.json:</p>
<pre><code> "permissions" : [
"declarativeContent"
],
</code></pre>
<p>In background.js:</p>
<pre><code>chrome.runtime.onInstalled.addListener(function() {
// Replace all rules ...
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
// With a new rule ...
chrome.declarativeContent.onPageChanged.addRules([
{
conditions: [
new chrome.declarativeContent.PageStateMatcher({
pageUrl: { urlMatches: 'www\.somewebsite\.com/(translate|revise)/' },
})
],
// And shows the extension's page action.
actions: [ new chrome.declarativeContent.ShowPageAction() ]
}
]);
});
});
</code></pre>
<p>I noticed that in most Chrome browsers, the page action icon appears correctly inside the address and only appears when the matching page is met:</p>
<p><a href="https://i.stack.imgur.com/jQZI9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jQZI9.png" alt="Page action appearing as expected"></a></p>
<p>However, in some browsers recently page actions started appearing as enabled/disabled browser actions, i.e. outside the address bar, which is a lot clumsier because the whole idea around page actions icons is that they appear if and only if the page is relevant to them. There is no point showing a disabled page action for most of the time. Actually, it happened to browsers where it used to work well days ago, like if a Chrome update had some side effects.</p>
<p><a href="https://i.stack.imgur.com/BbnP3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BbnP3.png" alt="Page action appearing like a Browser action"></a></p>
<p>I presume this is related to some Chrome setting that now shows all extensions there, but is there any way I can force the page action to appear consistently in the address bar and only appear when it can be really useful?</p>
| 0debug
|
IoT speed sensor : <p>Do you know any IoT sensor for speed detection of a human and sending it to a mobile application?</p>
<p>In other words, I am looking for a very small IoT sensor that sends the speed data of players of a sports team to a mobile application.</p>
| 0debug
|
static CharDriverState *qemu_chr_open_stdio(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
Error **errp)
{
ChardevStdio *opts = backend->u.stdio;
CharDriverState *chr;
struct sigaction act;
if (is_daemonized()) {
error_setg(errp, "cannot use stdio with -daemonize");
return NULL;
}
if (stdio_in_use) {
error_setg(errp, "cannot use stdio by multiple character devices");
return NULL;
}
stdio_in_use = true;
old_fd0_flags = fcntl(0, F_GETFL);
tcgetattr(0, &oldtty);
qemu_set_nonblock(0);
atexit(term_exit);
memset(&act, 0, sizeof(act));
act.sa_handler = term_stdio_handler;
sigaction(SIGCONT, &act, NULL);
chr = qemu_chr_open_fd(0, 1);
chr->chr_close = qemu_chr_close_stdio;
chr->chr_set_echo = qemu_chr_set_echo_stdio;
if (opts->has_signal) {
stdio_allow_signal = opts->signal;
}
qemu_chr_fe_set_echo(chr, false);
return chr;
}
| 1threat
|
How can I make Elixir mix test output more verbose? : <p>In my Elixir/Phoenix app, when I run</p>
<pre><code>mix test
</code></pre>
<p>I get output like:</p>
<pre><code>$ mix test
....
Finished in 0.09 seconds
4 tests, 0 failures
</code></pre>
<p>with dots for each test that succeeded. </p>
<p>How do I output the names of the tests that succeed instead? </p>
<p>In Rails with rspec I used to do this with a .rspec file in the directory that looked like:</p>
<pre><code>$ cat .rspec
--color
-fd
--tty
</code></pre>
<p>Is there an equivalent in Elixir?</p>
| 0debug
|
static uint32_t sdhci_read_dataport(SDHCIState *s, unsigned size)
{
uint32_t value = 0;
int i;
if ((s->prnsts & SDHC_DATA_AVAILABLE) == 0) {
ERRPRINT("Trying to read from empty buffer\n");
return 0;
}
for (i = 0; i < size; i++) {
value |= s->fifo_buffer[s->data_count] << i * 8;
s->data_count++;
if ((s->data_count) >= (s->blksize & 0x0fff)) {
DPRINT_L2("All %u bytes of data have been read from input buffer\n",
s->data_count);
s->prnsts &= ~SDHC_DATA_AVAILABLE;
s->data_count = 0;
if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) {
s->blkcnt--;
}
if ((s->trnmod & SDHC_TRNS_MULTI) == 0 ||
((s->trnmod & SDHC_TRNS_BLK_CNT_EN) && (s->blkcnt == 0)) ||
(s->stopped_state == sdhc_gap_read &&
!(s->prnsts & SDHC_DAT_LINE_ACTIVE))) {
sdhci_end_transfer(s);
} else {
sdhci_read_block_from_card(s);
}
break;
}
}
return value;
}
| 1threat
|
Thumbnail Metadata Disappeared When Importing File with Copy to App : <p>I have been using the URL Resources to embed the thumbnail metadata into my custom document-based file. When I export my custom document file, the thumbnail shows up nicely when glanced in iOS Files app.</p>
<pre><code>override func fileAttributesToWrite(to url: URL, for saveOperation: UIDocumentSaveOperation) throws -> [AnyHashable : Any] {
var attr: [AnyHashable : Any] = [URLResourceKey.hasHiddenExtensionKey: true]
// Ignore the proper resizing for now.
...
attr[URLResourceKey.thumbnailDictionaryKey] = [
URLThumbnailDictionaryItem.NSThumbnail1024x1024SizeKey: #imageLiteral(resourceName: "Star")
]
return attr
}
</code></pre>
<p><a href="https://i.stack.imgur.com/FBWoW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FBWoW.png" alt="enter image description here"></a>
(Icon Credit: <a href="https://useyourloaf.com" rel="noreferrer">Use Your Loaf</a>)</p>
<p>However, when I import the file back into my app with Share action, <code>Copy to <MyApp></code>, all the metadata seems to survive <strong>except the thumbnail</strong>.</p>
<p><a href="https://i.stack.imgur.com/TUmlM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TUmlM.png" alt="enter image description here"></a></p>
<pre><code>func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
// Other non-image metadata survives, like creationDate.
if let creationDateOpt = try? url.resourceValues(forKeys: [.creationDateKey]).creationDate,
let creationDate = creationDateOpt {
print("creationDate: \(creationDate)")
}
if let thumbnailDictOpt = try? url.resourceValues(forKeys: [.thumbnailDictionaryKey]).thumbnailDictionary,
let thumbnailDict = thumbnailDictOpt,
let thumbnail = thumbnailDict[URLThumbnailDictionaryItem.NSThumbnail1024x1024SizeKey] {
print ("Thumbnail survived. Size: \(thumbnail.size)")
return true
}
print ("Thumbnail disappeard!")
return false
}
</code></pre>
<p>Considering that the thumbnail persists when I manual copy the file in Files app, the lost must happen during the system copying my file from Files to my app's container. Why does this happen? I can manually embed thumbnail as part of my file's data too, but I feel there should be a way to solve this, since other text-based metadata persists.</p>
<p>I tried using <code>promisedResourceValue</code> method instead, suspecting that the file might not be fully copied when it's opened, but the result is the same.</p>
<p><a href="https://i.stack.imgur.com/f2x07.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/f2x07.jpg" alt="enter image description here"></a></p>
<p>I have my full project available <a href="https://github.com/pt2277/TestUIDocumentSave" rel="noreferrer">here on GitHub</a>.</p>
| 0debug
|
How can I replace ~60 print entries in 5 different files using vim or sed? : <p>Fabfile (directory) containing Python files:</p>
<pre><code>print "DEBUG fab_helper DRYRUN: True"+var
print "DEBUG fab_helper DRYRUN: True"
#print "DEBUG cfn_stackname: "+cfn_stackname
</code></pre>
<p>To:</p>
<pre><code>LOGGER.DEBUG("DEBUG fab_helper DRYRUN: True"+var)
LOGGER.DEBUG("DEBUG fab_helper DRYRUN: True"
LOGGER.DEBUG(""DEBUG cfn_stackname: "+cfn_stackname)
</code></pre>
<p>How can I replace all these entries with my Logger module?
Should I use vim or sed?</p>
| 0debug
|
getting Invalid json error when I am decoding below data using json_decode in PHP : <p>[{\\"field_display_txt\\":\\"New custom field phone\\",\\"field_value\\":0},{\\"field_display_txt\\":\\"New custom field\\",\\"field_value\\":\\"test_zapier\\"},{\\"field_display_txt\\":\\"New custom field select\\",\\"field_value\\":\\"1\\"}]</p>
| 0debug
|
How do c++ compilers find an extern variable? : <p>I compile this program by g++ and clang++. There has a difference:<br>
g++ prints 1, but clang++ prints 2.<br>
It seems that<br>
g++: the extern varible is defined in the shortest scope.<br>
clang++: the extern varible is defined in the shortest global scope.</p>
<p>Does C++ spec has any specification about that?</p>
<p>main.cpp</p>
<pre><code>#include <iostream>
static int i;
static int *p = &i;
int main() {
int i;
{
extern int i;
i = 1;
*p = 2;
std::cout << i << std::endl;
}
}
</code></pre>
<p>other.cpp</p>
<pre><code>int i;
</code></pre>
<p>version: g++: 7.4.0/ clang++:10.0.0<br>
compilation: $(CXX) main.cpp other.cpp -o extern.exe</p>
| 0debug
|
void memory_region_set_address(MemoryRegion *mr, hwaddr addr)
{
MemoryRegion *parent = mr->parent;
int priority = mr->priority;
bool may_overlap = mr->may_overlap;
if (addr == mr->addr || !parent) {
mr->addr = addr;
return;
}
memory_region_transaction_begin();
memory_region_ref(mr);
memory_region_del_subregion(parent, mr);
if (may_overlap) {
memory_region_add_subregion_overlap(parent, addr, mr, priority);
} else {
memory_region_add_subregion(parent, addr, mr);
}
memory_region_unref(mr);
memory_region_transaction_commit();
}
| 1threat
|
How to highlight table tennis plates in Openlayers? : I want to highlight all table tennis plates in ol. The tag ist leisure=table_tennis_table and i know there is a possibility to do it with ol.style.
Pls help
| 0debug
|
void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
{
int i;
for (i = 0; ; i++) {
(*cpu_fprintf)(f, "PowerPC %-16s PVR %08x\n",
ppc_defs[i].name, ppc_defs[i].pvr);
if (strcmp(ppc_defs[i].name, "default") == 0)
break;
}
}
| 1threat
|
static int thread_init(AVCodecContext *avctx)
{
int i;
ThreadContext *c;
int thread_count = avctx->thread_count;
if (!thread_count) {
int nb_cpus = get_logical_cpus(avctx);
if (nb_cpus > 1)
thread_count = avctx->thread_count = nb_cpus + 1;
}
if (thread_count <= 1) {
avctx->active_thread_type = 0;
return 0;
}
c = av_mallocz(sizeof(ThreadContext));
if (!c)
return -1;
c->workers = av_mallocz(sizeof(pthread_t)*thread_count);
if (!c->workers) {
av_free(c);
return -1;
}
avctx->thread_opaque = c;
c->current_job = 0;
c->job_count = 0;
c->job_size = 0;
c->done = 0;
pthread_cond_init(&c->current_job_cond, NULL);
pthread_cond_init(&c->last_job_cond, NULL);
pthread_mutex_init(&c->current_job_lock, NULL);
pthread_mutex_lock(&c->current_job_lock);
for (i=0; i<thread_count; i++) {
if(pthread_create(&c->workers[i], NULL, worker, avctx)) {
avctx->thread_count = i;
pthread_mutex_unlock(&c->current_job_lock);
ff_thread_free(avctx);
return -1;
}
}
avcodec_thread_park_workers(c, thread_count);
avctx->execute = avcodec_thread_execute;
avctx->execute2 = avcodec_thread_execute2;
return 0;
}
| 1threat
|
bash: What are the purposes of the two semicolons in echo? : Can someone explain the meaning of the following bash script? I am mainly confused about the echo usage. What are the purposes of the two semicolons?
for addr in $@; do
for i in $(seq 8 -2 2); do echo -ne "\x${addr:$i:2}"; done
done
| 0debug
|
Keep only numbers between spesific letters : I want to keep a value in several seperated long text strings with one part in common. One of the text strings:
N-05-0040(119) f 2005 svart hp Ml:153 - 160 - 20 - 75 Tot 31- 3- 3- 6- 13 (4)29,7M - (4)28,2aK Kr 204.500, 2pr 2010, Trener: Ole Olesen
The common part is "Kr 204.500," and i only need the numbers, so i can use them for calculation,
| 0debug
|
Databricks error when trying to load a module using apache spark : <p>I'm using a notebook within Databricks. The notebook is set up with python 3 if that helps. Everything is working fine and I can extract data from Azure Storage. However when I run:</p>
<p><code>import org.apache.spark.sql.types.StructType</code></p>
<p>I get the error message </p>
<p><code>ImportError: No module named 'org'</code></p>
<p>Does anyone know how I would go about fixing this? Is this something to do with the notebook being in python? </p>
<p>I've only just started using Databricks today so apologies if this is a silly question - I couldn't find anything online that helped. </p>
<p>I did try to run <code>import org.py.spark.sql.types.StructType</code> but that didn't work either. </p>
<p>Thanks</p>
| 0debug
|
how to store vector in a vector c++ : <p>I want to store some int vectors into a vector, so firstly I initialize a vector type vector, then iterate for begin to end, and store int numbers into each subvectoer from 0 to 4 like below code: </p>
<pre><code>std::vector<std::vector<int> > v(12);
void fun_1(std::vector<int> a )
{
for (int i = 0; i < 5; ++i)
{
a.push_back(i);
}
}
int main()
{
for (int i = 0; i < 12; ++i)
{
fun_1(v[i]);
}
cout<<v[0].at(2);
}
</code></pre>
<p>So after I done that, there is always a segmentation fault which I think is because subvector is still empty, they are not assigned, so I am wondering how can I modify this to reach my goal? Thank for any idea.</p>
| 0debug
|
How to dynamically add/remove show fields in Sonata Admin : <p>I wanted to remove some show fields that are only relevant if some other fields have a certain value, but the entity cannot be accessed from the admin class.</p>
| 0debug
|
C# out parameter and dictionary : <p>I've a dictionary object in my C# code:dictEmployees;---></p>
<p>It has a list of all Employees.Employee class has two properties...Id and Salary.Lets say, Initially, this collection has a salary of 50K for employee Id 1.</p>
<pre><code>Employee employee = new Employee();
dictEmployees.TryGetValue(1, out employee);
</code></pre>
<p>Now,if I modify employee' salary in other some method, I see that the salary is also being reflected in the employee object in the dictionary.
Is this expected please?</p>
<p>Thanks.</p>
| 0debug
|
linux fio write the disk , how to recover .very urgent. help me,please, : I`m use os is CentOS release 6.6 . today , i want to test the disk write speed.
i have a 500g disk is /dev/sdc.
i use the cmd :
fio -filename=/dev/sdc -direct=1 -iodepth 1 -thread -rw=randwrite -ioengine=psync -bs=16k -size=1G -numjobs=5 -runtime=15 -group_reporting -name=mytest
when i use the cmd df -h look the disk:
Filesystem Size Used Avail Use% Mounted on
9.0Z 9.0Z 0 100% /data
and in /data ,i use ls ,but i can`t see any data
disk is ext4 !
how can i recover it !!! i`m very worry 。please help me !! thanks very much !!
| 0debug
|
why static variable intialised in each calling of function but we have to declare it everytime in C : I read that : static variable is initialised only once (unlike auto variable) and further defination of static variable would be bypassed during runtime. [from the link][1].
then why I am getting error that "i was not declare " in the code given below.
I wrote program such that the static variable "i" intiallised only first time when c is equal to 0 after that c increases.
#include<stdio.h>
int c=0;
int test()
{
if(c==0)
static int i=0;
c++;
i++;
if(i==5)
printf("%d\n",i);
else
test();
}
int main()
{
test();
return 0;
}
[1]: http://stackoverflow.com/questions/5033627/static-variable-inside-of-a-function-in-c
| 0debug
|
Java script get an object array filtered only with certain properties : I have an array of objects(object is `<Employee>` type) as shown below,
[{i: "MCA001", j: 4, n: "KEITH G MCALLISTER", m: null, a: 1, …}
, {...}]
i want this <Employee> object array filtered with certain properties,
for an instance, filtered array should have few properties,
[{i:.., j:.., a:..}]
i'm trying to use filter and map functions and still no success.
Appreciate if anyone can help me to figure this out.
Thank you very much.
| 0debug
|
Converting Time how can I improve my code? : <p>Just started programming so any suggestion or constructive criticism would be much appreciated. I'm pretty sure there are ways to shorten this I just don't know how, especially the use of functions.</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
int input, check = 1, ans;
int menu ();
int convert24(int hour, int min, int sec, int meridiem);
int convert12(int hour, int min, int sec, int meridiem);
int result(int hour, int min, int sec, int meridiem);
void processAnother();
int main()
{
do
{
menu();
processAnother();
system("cls");
}while (ans = 'y');
}
int menu ()
{
int hour, min, sec, meridiem;
printf("[1] Convert to 24-hour notation\n");
printf("[2] Convert to 12-hour notation\n");
printf("[3] Quit\n");
scanf("%d", &input);
switch(input)
{
case 1 :
{
printf("Enter hours (1-12):minute(1-59):seconds(1-59): ");
scanf("%d %d %d", &hour, &min, &sec);
printf("[1] AM or [2] PM: ");
scanf(" %d", &meridiem);
return convert24(hour, min, sec, meridiem);
break;
}
case 2 :
{
printf("Enter hours(1-24):minute(1-59):seconds(1-59): ");
scanf("%d %d %d", &hour, &min, &sec);
printf("[1]AM or [2]PM: ");
scanf(" %d", &meridiem);
return convert12(hour, min, sec, meridiem);
break;
}
default :
{
printf("Goodbye :)");
exit(0);
}
}
}
int convert24(int hour, int min, int sec, int meridiem)
{
if ((hour > 12 || hour < 0))
{
printf("\nError! Invalid Hour\n");
check = 0;
}
if ((min >= 60 || min <0))
{
printf("\nError! Invalid Minute\n");
check = 0;
}
if ((sec >= 60 || sec <0))
{
printf("\nError! Invalid Second\n");
check = 0;
}
if (meridiem > 2 || meridiem < 0)
{
printf("\nError! Invalid Meridiem\n");
check = 0;
}
if (check == 1)
{
if (meridiem == 1)
{
if (hour == 12)
{
hour = 0;
result(hour, min, sec, meridiem);
}
else
{
result(hour, min, sec, meridiem);
}
}
else if (meridiem == 2)
{
if (hour == 12)
{
hour = 12;
result(hour, min, sec, meridiem);
}
else
{
hour+=12;
result(hour, min, sec, meridiem);
}
}
}
processAnother();
}
int convert12(int hour, int min, int sec, int meridiem)
{
if ((hour > 24 || hour < 0))
{
printf("\nError! Invalid Hour\n");
check = 0;
}
if ((min >= 60 || min <0))
{
printf("\nError! Invalid Minute\n");
check = 0;
}
if ((sec >= 60 || sec <0))
{
printf("\nError! Invalid Second\n");
check = 0;
}
if (meridiem > 2 || meridiem < 0)
{
printf("\nError! Invalid Meridiem\n");
check = 0;
}
if (check == 1)
{
if (meridiem == 1)
{
if (hour <= 12)
{
result(hour, min, sec, meridiem);
}
else
{
hour -= 12;
result(hour, min, sec, meridiem);
}
}
else if (meridiem == 2)
{
if (hour <= 12)
{
result(hour, min, sec, meridiem);
}
else
{
hour -= 12;
result(hour, min, sec, meridiem);
}
}
}
processAnother();
}
int result(int hour, int min, int sec, int meridiem)
{
char *x;
int y;
if(meridiem == 1)
{
x = "AM";
}
else if (meridiem == 2)
{
x = "PM";
}
if (input == 1)
{
y = 24;
}
else if (input == 2)
{
y = 12;
}
printf("The %d-hr Notation is : %d:%d:%d %s\n",y, hour, min, sec, x);
return;
}
void processAnother()
{
printf("Process another [y/n]");
scanf("%c", &ans);
return;
}
</code></pre>
<p>Thank you very much.</p>
| 0debug
|
How to run a cronjob every 50 minutes? : <p>I want to run cron job in following manner</p>
<p>00:00
00:50
01:40
02:30
and so on</p>
<p>how can i setup cron tab so it works like this</p>
| 0debug
|
int ga_install_service(const char *path, const char *logfile,
const char *state_dir)
{
int ret = EXIT_FAILURE;
SC_HANDLE manager;
SC_HANDLE service;
TCHAR module_fname[MAX_PATH];
GString *cmdline;
SERVICE_DESCRIPTION desc = { (char *)QGA_SERVICE_DESCRIPTION };
if (GetModuleFileName(NULL, module_fname, MAX_PATH) == 0) {
printf_win_error("No full path to service's executable");
return EXIT_FAILURE;
}
cmdline = g_string_new(module_fname);
g_string_append(cmdline, " -d");
if (path) {
g_string_append_printf(cmdline, " -p %s", path);
}
if (logfile) {
g_string_append_printf(cmdline, " -l %s -v", logfile);
}
if (state_dir) {
g_string_append_printf(cmdline, " -t %s", state_dir);
}
g_debug("service's cmdline: %s", cmdline->str);
manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (manager == NULL) {
printf_win_error("No handle to service control manager");
goto out_strings;
}
service = CreateService(manager, QGA_SERVICE_NAME, QGA_SERVICE_DISPLAY_NAME,
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL, cmdline->str, NULL, NULL, NULL, NULL, NULL);
if (service == NULL) {
printf_win_error("Failed to install service");
goto out_manager;
}
ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &desc);
fprintf(stderr, "Service was installed successfully.\n");
ret = EXIT_SUCCESS;
CloseServiceHandle(service);
out_manager:
CloseServiceHandle(manager);
out_strings:
g_string_free(cmdline, TRUE);
return ret;
}
| 1threat
|
How to prevent Browser cache on Angular 2 site? : <p>We're currently working on a new project with regular updates that's being used daily by one of our clients. This project is being developed using angular 2 and we're facing cache issues, that is our clients are not seeing the latest changes on their machines.</p>
<p>Mainly the html/css files for the js files seem to get updated properly without giving much trouble.</p>
| 0debug
|
How to pass multiple parameters to middleware with OR condition in Laravel 5.2 : <p>I am trying to set permission to access an action to two different user roles Admin, Normal_User as shown below.</p>
<pre><code>Route::group(['middleware' => ['role_check:Normal_User','role_check:Admin']], function() {
Route::get('/user/{user_id}', array('uses' => 'UserController@showUserDashboard', 'as' => 'showUserDashboard'));
});
</code></pre>
<p>This route can be accessed by either Admin or Normal_user. But in this middleware configuration, user is required to be both Admin and Normal_User. How can I add OR condition in middleware parameter passing? Or is there any other method to give permission?</p>
<p>The following is my middleware</p>
<pre><code>public function handle($request, Closure $next, $role)
{
if ($role != Auth::user()->user_role->role ) {
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', 401);
} else {
return response('Unauthorized.', 401);
}
}
return $next($request);
}
</code></pre>
<p>Can anyone please reply?</p>
| 0debug
|
How to monitor websocket frames in firefox : <p>I know there was an extension called 'websocket-monitor', but it's no longer available.</p>
<p>It seems that nobody can view websocket frames by firefox. </p>
| 0debug
|
$ {I} and ${colours[i]} is not printing the values in console? : <pre><code>const colors = ['Red', 'Green', 'Blue']
for(let i=0, max = colors.length; i< max; i++)
{
console.log('Color at position ${i} is ${colors[i]}');
}
</code></pre>
<p>output: Color at position ${i} is ${colors[i]}</p>
| 0debug
|
what the problem with my code is bien repeating 5 time : import React, { Component } from "react";
class App extends Component {
state = {value: [{title: "my title",category: "action",replies: "62",views: "26k",activity: "18h"}]};
render() {return (
<div>{this.state.value ? this.state.value.map(valu => Object.keys(valu).map((tr, index) => (
<div key={index}>{valu.title}  {valu.category}  {valu.replies}  {valu.views}  {valu.activity}</div>))): null}</div>);}}export default App;
| 0debug
|
return cur == NULL ? -1 : cur->val; (I am confused for this c++ sentence) : <pre><code> /** Helper function to return the index-th node in the linked list. */
SinglyListNode* getNode(int index) {
SinglyListNode *cur = head;
for (int i = 0; i < index && cur; ++i) {
cur = cur->next;
}
return cur;
}
/** Helper function to return the last node in the linked list. */
SinglyListNode* getTail() {
SinglyListNode *cur = head;
while (cur && cur->next) {
cur = cur->next;
}
return cur;
}
/** Get the value of the index-th node in the linked list. If the index is invalid, return -1. */
int get(int index) {
SinglyListNode *cur = getNode(index);
return cur == NULL ? -1 : cur->val;
}
</code></pre>
<hr>
<p>This “ return cur == NULL ? -1 : cur->val; ”</p>
<p>I confused this syntax, can someone separate this sentence?</p>
| 0debug
|
int32 float128_to_int32_round_to_zero( float128 a STATUS_PARAM )
{
flag aSign;
int32 aExp, shiftCount;
uint64_t aSig0, aSig1, savedASig;
int32 z;
aSig1 = extractFloat128Frac1( a );
aSig0 = extractFloat128Frac0( a );
aExp = extractFloat128Exp( a );
aSign = extractFloat128Sign( a );
aSig0 |= ( aSig1 != 0 );
if ( 0x401E < aExp ) {
if ( ( aExp == 0x7FFF ) && aSig0 ) aSign = 0;
goto invalid;
}
else if ( aExp < 0x3FFF ) {
if ( aExp || aSig0 ) STATUS(float_exception_flags) |= float_flag_inexact;
return 0;
}
aSig0 |= LIT64( 0x0001000000000000 );
shiftCount = 0x402F - aExp;
savedASig = aSig0;
aSig0 >>= shiftCount;
z = aSig0;
if ( aSign ) z = - z;
if ( ( z < 0 ) ^ aSign ) {
invalid:
float_raise( float_flag_invalid STATUS_VAR);
return aSign ? (int32_t) 0x80000000 : 0x7FFFFFFF;
}
if ( ( aSig0<<shiftCount ) != savedASig ) {
STATUS(float_exception_flags) |= float_flag_inexact;
}
return z;
}
| 1threat
|
static void float_number(void)
{
int i;
struct {
const char *encoded;
double decoded;
int skip;
} test_cases[] = {
{ "32.43", 32.43 },
{ "0.222", 0.222 },
{ "-32.12313", -32.12313 },
{ "-32.20e-10", -32.20e-10, .skip = 1 },
{ },
};
for (i = 0; test_cases[i].encoded; i++) {
QObject *obj;
QFloat *qfloat;
obj = qobject_from_json(test_cases[i].encoded, NULL);
qfloat = qobject_to_qfloat(obj);
g_assert(qfloat);
g_assert(qfloat_get_double(qfloat) == test_cases[i].decoded);
if (test_cases[i].skip == 0) {
QString *str;
str = qobject_to_json(obj);
g_assert(strcmp(qstring_get_str(str), test_cases[i].encoded) == 0);
QDECREF(str);
}
QDECREF(qfloat);
}
}
| 1threat
|
static void cortex_a15_initfn(Object *obj)
{
ARMCPU *cpu = ARM_CPU(obj);
set_feature(&cpu->env, ARM_FEATURE_V7);
set_feature(&cpu->env, ARM_FEATURE_VFP4);
set_feature(&cpu->env, ARM_FEATURE_VFP_FP16);
set_feature(&cpu->env, ARM_FEATURE_NEON);
set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
set_feature(&cpu->env, ARM_FEATURE_ARM_DIV);
set_feature(&cpu->env, ARM_FEATURE_V7MP);
set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
cpu->midr = 0x412fc0f1;
cpu->reset_fpsid = 0x410430f0;
cpu->mvfr0 = 0x10110222;
cpu->mvfr1 = 0x11111111;
cpu->ctr = 0x8444c004;
cpu->reset_sctlr = 0x00c50078;
cpu->id_pfr0 = 0x00001131;
cpu->id_pfr1 = 0x00011011;
cpu->id_dfr0 = 0x02010555;
cpu->id_afr0 = 0x00000000;
cpu->id_mmfr0 = 0x10201105;
cpu->id_mmfr1 = 0x20000000;
cpu->id_mmfr2 = 0x01240000;
cpu->id_mmfr3 = 0x02102211;
cpu->id_isar0 = 0x02101110;
cpu->id_isar1 = 0x13112111;
cpu->id_isar2 = 0x21232041;
cpu->id_isar3 = 0x11112131;
cpu->id_isar4 = 0x10011142;
cpu->clidr = 0x0a200023;
cpu->ccsidr[0] = 0x701fe00a;
cpu->ccsidr[1] = 0x201fe00a;
cpu->ccsidr[2] = 0x711fe07a;
define_arm_cp_regs(cpu, cortexa15_cp_reginfo);
}
| 1threat
|
Maven on Windows Subsystem For Linux : <p>I'm trying to run maven on Windows Subsystem for Linux, and getting "cannot allocate memory" errors. However, <em>free -m</em> shows that I have plenty of memory available, and the same build on Cygwin succeeds.</p>
<p>Anyone have any tips for dealing with this? I'd prefer to change my settings.xml over my pom.xml's, but I'm open to almost anything.</p>
| 0debug
|
static int dvbsub_parse_region_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
DVBSubContext *ctx = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
int region_id, object_id;
int av_unused version;
DVBSubRegion *region;
DVBSubObject *object;
DVBSubObjectDisplay *display;
int fill;
int ret;
if (buf_size < 10)
return AVERROR_INVALIDDATA;
region_id = *buf++;
region = get_region(ctx, region_id);
if (!region) {
region = av_mallocz(sizeof(DVBSubRegion));
if (!region)
return AVERROR(ENOMEM);
region->id = region_id;
region->version = -1;
region->next = ctx->region_list;
ctx->region_list = region;
version = ((*buf)>>4) & 15;
fill = ((*buf++) >> 3) & 1;
region->width = AV_RB16(buf);
buf += 2;
region->height = AV_RB16(buf);
buf += 2;
ret = av_image_check_size2(region->width, region->height, avctx->max_pixels, AV_PIX_FMT_PAL8, 0, avctx);
if (ret < 0) {
region->width= region->height= 0;
return ret;
if (region->width * region->height != region->buf_size) {
av_free(region->pbuf);
region->buf_size = region->width * region->height;
region->pbuf = av_malloc(region->buf_size);
if (!region->pbuf) {
region->buf_size =
region->width =
region->height = 0;
return AVERROR(ENOMEM);
fill = 1;
region->dirty = 0;
region->depth = 1 << (((*buf++) >> 2) & 7);
if(region->depth<2 || region->depth>8){
av_log(avctx, AV_LOG_ERROR, "region depth %d is invalid\n", region->depth);
region->depth= 4;
region->clut = *buf++;
if (region->depth == 8) {
region->bgcolor = *buf++;
buf += 1;
} else {
buf += 1;
if (region->depth == 4)
region->bgcolor = (((*buf++) >> 4) & 15);
else
region->bgcolor = (((*buf++) >> 2) & 3);
ff_dlog(avctx, "Region %d, (%dx%d)\n", region_id, region->width, region->height);
if (fill) {
memset(region->pbuf, region->bgcolor, region->buf_size);
ff_dlog(avctx, "Fill region (%d)\n", region->bgcolor);
delete_region_display_list(ctx, region);
while (buf + 5 < buf_end) {
object_id = AV_RB16(buf);
buf += 2;
object = get_object(ctx, object_id);
if (!object) {
object = av_mallocz(sizeof(DVBSubObject));
if (!object)
return AVERROR(ENOMEM);
object->id = object_id;
object->next = ctx->object_list;
ctx->object_list = object;
object->type = (*buf) >> 6;
display = av_mallocz(sizeof(DVBSubObjectDisplay));
if (!display)
return AVERROR(ENOMEM);
display->object_id = object_id;
display->region_id = region_id;
display->x_pos = AV_RB16(buf) & 0xfff;
buf += 2;
display->y_pos = AV_RB16(buf) & 0xfff;
buf += 2;
if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) {
display->fgcolor = *buf++;
display->bgcolor = *buf++;
display->region_list_next = region->display_list;
region->display_list = display;
display->object_list_next = object->display_list;
object->display_list = display;
return 0;
| 1threat
|
When I float the div to the right the screen messes up...I've tried clear and some other options... : I'm having an issue in general when it comes to floats. I'll be doing fine with the layout but once I start floating the whole page does weird stuff. I think I need a better understanding of the concept of what goes on. Here is my code for html and css.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<!DOCTYPE html>
<html>
<head>
<title>This is it</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="wrapper">
<div id="heading">Heading</div>
<div id="navigation">Navigation</div>
<div id="leftSide">Left Side</div>
<div id="rightSide">Right Side</div>
<div id="footer">Footer</div>
<div style="clear: right;"></div>
</div>
</body>
</html>
<!-- end snippet -->
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
* {
margin: 0;
}
#heading {
background-color: black;
height: 150px;
}
#navigation {
background-color: green;
height: 30px;
}
#leftSide {
background-color: blue;
width: 400px;
height: 700px;
}
#rightSide {
background-color: red;
width: 400px;
height: 700px;
float: right;
}
#footer {
background-color: black;
}
<!-- end snippet -->
| 0debug
|
What is difference between echo and return in shortcode function with wordpress? : <p>I found both 'echo' and 'return' are working fine to display in shortcode function.</p>
<pre><code>function display_shortcode_content($atts) {
echo "COMES";
}
function display_shortcode_content($atts) {
return "COMES";
}
</code></pre>
<p>My doubt is what is difference between echo and retutn in the function? </p>
| 0debug
|
IE11 - does a polyfill / script exist for CSS variables? : <p>I'm developing a webpage in a mixed web browser environment (Chrome/IE11).
IE11 doesn't support CSS variables, is there a polyfill or script that exists that would allow me to use CSS variables in IE11?</p>
| 0debug
|
static int mjpeg_decode_sof0(MJpegDecodeContext *s,
UINT8 *buf, int buf_size)
{
int len, nb_components, i, width, height;
init_get_bits(&s->gb, buf, buf_size);
len = get_bits(&s->gb, 16);
if (get_bits(&s->gb, 8) != 8)
return -1;
height = get_bits(&s->gb, 16);
width = get_bits(&s->gb, 16);
nb_components = get_bits(&s->gb, 8);
if (nb_components <= 0 ||
nb_components > MAX_COMPONENTS)
return -1;
s->nb_components = nb_components;
s->h_max = 1;
s->v_max = 1;
for(i=0;i<nb_components;i++) {
s->component_id[i] = get_bits(&s->gb, 8) - 1;
s->h_count[i] = get_bits(&s->gb, 4);
s->v_count[i] = get_bits(&s->gb, 4);
if (s->h_count[i] > s->h_max)
s->h_max = s->h_count[i];
if (s->v_count[i] > s->v_max)
s->v_max = s->v_count[i];
s->quant_index[i] = get_bits(&s->gb, 8);
if (s->quant_index[i] >= 4)
return -1;
dprintf("component %d %d:%d\n", i, s->h_count[i], s->v_count[i]);
}
if (width != s->width || height != s->height) {
for(i=0;i<MAX_COMPONENTS;i++) {
free(s->current_picture[i]);
s->current_picture[i] = NULL;
}
s->width = width;
s->height = height;
if (s->first_picture &&
s->org_height != 0 &&
s->height < ((s->org_height * 3) / 4)) {
s->interlaced = 1;
s->bottom_field = 0;
}
for(i=0;i<nb_components;i++) {
int w, h;
w = (s->width + 8 * s->h_max - 1) / (8 * s->h_max);
h = (s->height + 8 * s->v_max - 1) / (8 * s->v_max);
w = w * 8 * s->h_count[i];
h = h * 8 * s->v_count[i];
if (s->interlaced)
w *= 2;
s->linesize[i] = w;
s->current_picture[i] = av_mallocz(w * h);
}
s->first_picture = 0;
}
if (len != 8+(3*nb_components))
dprintf("decode_sof0: error, len(%d) mismatch\n", len);
return 0;
}
| 1threat
|
Instagram. Given a User_id, how do i find the username? : <p>I have a list of thousands of instagram user-ids. How do i get their Instagram usernames/handles? </p>
<p>Thanks</p>
| 0debug
|
Error when checking model input: expected lstm_1_input to have 3 dimensions, but got array with shape (339732, 29) : <p>My input is simply a csv file with 339732 rows and two columns :</p>
<ul>
<li>the first being 29 feature values, i.e. X</li>
<li>the second being a binary label value, i.e. Y</li>
</ul>
<p>I am trying to train my data on a stacked LSTM model:</p>
<pre><code>data_dim = 29
timesteps = 8
num_classes = 2
model = Sequential()
model.add(LSTM(30, return_sequences=True,
input_shape=(timesteps, data_dim))) # returns a sequence of vectors of dimension 30
model.add(LSTM(30, return_sequences=True)) # returns a sequence of vectors of dimension 30
model.add(LSTM(30)) # return a single vector of dimension 30
model.add(Dense(1, activation='softmax'))
model.compile(loss='binary_crossentropy',
optimizer='rmsprop',
metrics=['accuracy'])
model.summary()
model.fit(X_train, y_train, batch_size = 400, epochs = 20, verbose = 1)
</code></pre>
<p>This throws the error:</p>
<blockquote>
<p>Traceback (most recent call last):
File "first_approach.py", line 80, in
model.fit(X_train, y_train, batch_size = 400, epochs = 20, verbose = 1)</p>
<p>ValueError: Error when checking model input: expected lstm_1_input to
have 3 dimensions, but got array with shape (339732, 29)</p>
</blockquote>
<p>I tried reshaping my input using <code>X_train.reshape((1,339732, 29))</code> but it did not work showing error:</p>
<blockquote>
<p>ValueError: Error when checking model input: expected lstm_1_input to
have shape (None, 8, 29) but got array with shape (1, 339732, 29)</p>
</blockquote>
<p>How can I feed in my input to the LSTM ?</p>
| 0debug
|
Verify container running state : <p>I have a <code>bash</code> script, which I use to run several <code>Docker</code> containers. Initialization time differs on system specifications, so sometimes these cannot be started in specified order. How can I detect with use of <code>bash</code>, that a container is running, so following container can be started. Containers requires previously started containers.</p>
| 0debug
|
AngularJS and UI-Router: 'Error: transition superseded' during angularjs unit tests : <p>I'm attempting to create an authorization package for a project of mine. I'm getting the error 'transition superseded' during my unit tests, and I can't find out where that would actually be.</p>
<p>Unit test:</p>
<pre><code>import angular from 'angular';
import 'angular-mocks';
import worldManagerApp from '../../src/world-manager-app';
import security from '../../src/security/security';
const {inject, module} = angular.mock;
describe('LoginService', ()=> {
let $httpBackend;
let $rootScope;
let successHandler;
let errorHandler;
let LoginService;
const USER = {username: "TEST", password: "PASSWORD"};
beforeEach(function() {
module(worldManagerApp);
module(security);
});
beforeEach(inject((_$httpBackend_, _LoginService_, _$rootScope_) => {
$httpBackend = _$httpBackend_;
$rootScope = _$rootScope_;
LoginService = _LoginService_;
successHandler = jasmine.createSpy('successHandler');
errorHandler = jasmine.createSpy('errorHandler');
}));
it('should exist', () => {
expect(LoginService).toBeDefined();
});
describe('.login()', () => {
describe('when given a proper username and password', () => {
it('should return the username and success', () => {
$httpBackend.expectPOST('/login').respond(200, {user: USER});
LoginService.login("TEST", "PASSWORD");
$rootScope.$digest();
$httpBackend.flush();
expect($rootScope.currentUser).toEqual("TEST");
});
});
});
});
</code></pre>
<p>Service:</p>
<pre><code>export default function LoginService($http){
'ngInject';
let service = {};
service.login = login;
function login(username, password){
$http({
url:'/login',
method: 'POST',
data: {
username: username,
password: password,
},
}).then (function(response) {
response.username;
}).catch(function(response){
});
}
return service;
}
</code></pre>
<p>Error:</p>
<pre><code>PhantomJS 1.9.8 (Windows 8 0.0.0) LoginService .login() when given a proper username and password should return the username and success FAILED
Error: transition superseded
at C:/Users/Manifest/AppData/Local/Temp/353229d8bf0abe298e7003bab30c0528.browserify:9387 <- node_modules/angular-mocks/angular-mocks.js:261:0
at processChecks (C:/Users/Manifest/AppData/Local/Temp/353229d8bf0abe298e7003bab30c0528.browserify:33750 <- node_modules/angular/angular.js:16674:0)
at C:/Users/Manifest/AppData/Local/Temp/353229d8bf0abe298e7003bab30c0528.browserify:35048 <- node_modules/angular/angular.js:17972:0
at C:/Users/Manifest/AppData/Local/Temp/353229d8bf0abe298e7003bab30c0528.browserify:34862 <- node_modules/angular/angular.js:17786:0
at C:/Users/Manifest/AppData/Local/Temp/353229d8bf0abe298e7003bab30c0528.browserify:521 <- frontend\test\security\loginService.spec.js:42:15
</code></pre>
<p>I assume it's a ui-Router problem, but I can't figure out how it should work if I am doing it wrong.</p>
| 0debug
|
Kotlin: How can I create a "static" inheritable function? : <p>For example, I want to have a function <code>example()</code> on a type <code>Child</code> that extends <code>Parent</code> so that I can use the function on both.</p>
<pre><code>Child.example()
Parent.example()
</code></pre>
<p>The first "obvious" way to do this is through the companion object of <code>Parent</code>, but this doesn't allow <code>example()</code> for <code>Child</code>.</p>
<p>The second way I tried was defining an extension function on <code>Parent.Companion</code>, which is inconvenient because you are forced to define a companion object. It also doesn't allow <code>example()</code> for <code>Child</code>.</p>
<p>Does anybody know how I can do this?</p>
| 0debug
|
$.post function does not work, gives out no errors : <p>I want to retrieve data from a mySQL server by using jQuery, which triggers a PHP script to receive the data. However, the <code>$.post</code> function from jQuery does not work at all and corrupts all the code, and I don't understand why.</p>
<p>Here is my JS code: </p>
<pre><code>$('button#btnSubmit').on('click', function() {
//Compare button pressed
var sel1 = $('select#country1').val(); //country iso codes
var sel2 = $('select#country2').val();
if(sel1 === "placeholder1" || sel2 === "placeholder2" || sel1 === sel2) {
alert("Please select at least two different countries")
}
else {
//post this to php file to retrieve data
try {
$.post('ajax/retrieve_data.php', { sel1: sel1, sel2: sel2 }, function(data) {
$('div#test-data').text(data);
}
catch(err) {
alert(err.message);
}
}
});
</code></pre>
<p>I included the jQuery library in my main HTML page with this: </p>
<pre><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
</code></pre>
<p>The <code>$.post</code> message corrupts the entire code, nothing works. When I remove it, the first part of the code works as it should. I have the feeling this is extremly easy to fix but I can't wrap my head around why it does not work.
Thank you!</p>
| 0debug
|
Insert Comma Separated String in SQLLITE : I need to insert coordinates in SQLLIte Table in Android
My Query is as below .
Its gives a Syntax error due to cordinates which contain string by comma separated information .
INSERT INTO "tableNonOilFarmer" ("farmerId","FirstName","MiddleName","LastName","FatherName","DOB","CategoryId","MobileNo","LandlineNo","StateId","DistrictId","TalukaMandalId","ClusterId","VillageId","Pincode","RsNumber","Area","LocationId","BorewellAvailable","BorewellDepth","SoilType","Flood","CurrentCropId","CurrentCropStatusId","CurrentCropAge","CurrentCropRating","Awareness","Interested","ContactDate","NextCrop","OverallRating","CreatedOn","Latitude","Longitude","Coordinates","Converted","Status","StatusBy","StatusDate","Comments","UserId","Sync") VALUES (3,test,test,test,test,2017-12-27,6,64,58,1,01,02,01,04,96559,1,1,1,false,353,kdf,1,1,1,5555,3,true,true,2017-12-27,,5,2017-12-27,16.868542,81.306554,81.30682,16.8682,0 81.306309,16.86842,0 81.306607,16.869098,0 81.307039,16.868813,0 81.30682,16.8682,0,false,0,null,1,null,167,S)
| 0debug
|
Is there any Tool available to validate sabre production credentials : <p>Is there any tool available to check sabre production credentials - (PCC) and can check the fares which we get in response like travelport provide us demo site where we can add our custom credentials and check.</p>
| 0debug
|
How to boot an NTFS Partition in Archlinux : <p>I just did a dual boot Win10/arch, i'm currently meeting an issue where I successfully auto-mount a NTFS partition but only on Read-Only and I need to "write" permission on it, I followed this method in order to boot at the start.</p>
<p><a href="https://www.youtube.com/watch?v=8hrm51ufjJc" rel="nofollow noreferrer">https://www.youtube.com/watch?v=8hrm51ufjJc</a></p>
<p>Can someone help me please?</p>
<p>Thanks in advance</p>
| 0debug
|
static void wait_for_aio(void)
{
while (aio_poll(ctx, true)) {
}
}
| 1threat
|
int bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp)
{
char *tmp_filename = g_malloc0(PATH_MAX + 1);
int64_t total_size;
QemuOpts *opts = NULL;
QDict *snapshot_options;
BlockDriverState *bs_snapshot;
Error *local_err;
int ret;
total_size = bdrv_getlength(bs);
if (total_size < 0) {
ret = total_size;
error_setg_errno(errp, -total_size, "Could not get image size");
goto out;
}
ret = get_tmp_filename(tmp_filename, PATH_MAX + 1);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not get temporary filename");
goto out;
}
opts = qemu_opts_create(bdrv_qcow2.create_opts, NULL, 0,
&error_abort);
qemu_opt_set_number(opts, BLOCK_OPT_SIZE, total_size, &error_abort);
ret = bdrv_create(&bdrv_qcow2, tmp_filename, opts, &local_err);
qemu_opts_del(opts);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not create temporary overlay "
"'%s': %s", tmp_filename,
error_get_pretty(local_err));
error_free(local_err);
goto out;
}
snapshot_options = qdict_new();
qdict_put(snapshot_options, "file.driver",
qstring_from_str("file"));
qdict_put(snapshot_options, "file.filename",
qstring_from_str(tmp_filename));
bs_snapshot = bdrv_new();
ret = bdrv_open(&bs_snapshot, NULL, NULL, snapshot_options,
flags, &bdrv_qcow2, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto out;
}
bdrv_append(bs_snapshot, bs);
out:
g_free(tmp_filename);
return ret;
}
| 1threat
|
I cannot pass a (String-)value to another class's setter method : <p>I know that i have not written a catch block yet.(reason?, but i think it's actually not the problem; the attributes of the "Game" class are perfectly changeable)</p>
<p>I always get an IOException when i try to call the setName method in Player (even if I set "name" in Player to public and change it directly).</p>
<pre><code> public class game{
protected static int amountPlayers;
protected static Player[] playerList = new Player[amountPlayers];
public static void main (String[] args) throws IOException{
//Scanner reader = new Scanner(System.in);
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String input;
System.out.println("new round? (1 for yes; enter for no):");
int boo = Integer.parseInt(br.readLine());
if (boo == 1) {
Rounds.setNew(true);
} // end of if
if (Rounds.getNew() == true) {
//SavingManagement.createFile();
System.out.println("# of players:");
int amount = Integer.parseInt(br.readLine());
setAmountPlayers(amount);
} // end of if
for (int i = 0; i < amountPlayers; i++) {
System.out.println("Name player No. " + (i + 1) + ":");
input = br.readLine();
playerList[i].setName(input);
} // end of for
}
public class Player {
protected static int score;
protected static String name = "";
public static void setName(String input) {
name = input;
}
}
</code></pre>
| 0debug
|
void qemu_get_guest_memory_mapping(MemoryMappingList *list, Error **errp)
{
CPUState *cpu, *first_paging_enabled_cpu;
RAMBlock *block;
ram_addr_t offset, length;
first_paging_enabled_cpu = find_paging_enabled_cpu(first_cpu);
if (first_paging_enabled_cpu) {
for (cpu = first_paging_enabled_cpu; cpu != NULL; cpu = cpu->next_cpu) {
Error *err = NULL;
cpu_get_memory_mapping(cpu, list, &err);
if (err) {
error_propagate(errp, err);
return;
}
}
return;
}
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
offset = block->offset;
length = block->length;
create_new_memory_mapping(list, offset, offset, length);
}
}
| 1threat
|
static void m48t59_isa_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->realize = m48t59_isa_realize;
dc->no_user = 1;
dc->reset = m48t59_reset_isa;
dc->props = m48t59_isa_properties;
}
| 1threat
|
Capture UIKeyCommand for Function Keys on iOS : <p>I am trying to capture the F5 key on an external bluetooth keyboard in an iOS application. I have set up the UIKeyCommands, yet I cannot figure out how to create a UIKeyCommand that would capture the function keys. There is no option for UIKeyModifierFunction.</p>
| 0debug
|
turn warning off in a cell jupyter notebook : <p>I get some useless warnings in python 3 jupyter notebook. I want to turn off these warnings in a particular cell only, so not in the rest of the ipynb-file.
Does someone know how to do this?</p>
| 0debug
|
Query decryption data SQL : It would like me know if, exists a native tool of the SQL for encryption some fields, put when making and execute a query, the SQL decrypt automatically.
| 0debug
|
static void RENAME(yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
long width, long height,
long lumStride, long chromStride, long srcStride)
{
long y;
const long chromWidth= -((-width)>>1);
for (y=0; y<height; y++) {
RENAME(extract_even)(src, ydst, width);
if(y&1) {
RENAME(extract_odd2avg)(src-srcStride, src, udst, vdst, chromWidth);
udst+= chromStride;
vdst+= chromStride;
}
src += srcStride;
ydst+= lumStride;
}
#if COMPILE_TEMPLATE_MMX
__asm__(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
#endif
}
| 1threat
|
connection.query('SELECT * FROM users WHERE username = ' + input_string)
| 1threat
|
int coroutine_fn bdrv_co_pwritev(BdrvChild *child,
int64_t offset, unsigned int bytes, QEMUIOVector *qiov,
BdrvRequestFlags flags)
{
BlockDriverState *bs = child->bs;
BdrvTrackedRequest req;
uint64_t align = bs->bl.request_alignment;
uint8_t *head_buf = NULL;
uint8_t *tail_buf = NULL;
QEMUIOVector local_qiov;
bool use_local_qiov = false;
int ret;
if (!bs->drv) {
return -ENOMEDIUM;
}
if (bs->read_only) {
return -EPERM;
}
assert(!(bs->open_flags & BDRV_O_INACTIVE));
ret = bdrv_check_byte_request(bs, offset, bytes);
if (ret < 0) {
return ret;
}
bdrv_inc_in_flight(bs);
tracked_request_begin(&req, bs, offset, bytes, BDRV_TRACKED_WRITE);
if (!qiov) {
ret = bdrv_co_do_zero_pwritev(bs, offset, bytes, flags, &req);
goto out;
}
if (offset & (align - 1)) {
QEMUIOVector head_qiov;
struct iovec head_iov;
mark_request_serialising(&req, align);
wait_serialising_requests(&req);
head_buf = qemu_blockalign(bs, align);
head_iov = (struct iovec) {
.iov_base = head_buf,
.iov_len = align,
};
qemu_iovec_init_external(&head_qiov, &head_iov, 1);
bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_HEAD);
ret = bdrv_aligned_preadv(bs, &req, offset & ~(align - 1), align,
align, &head_qiov, 0);
if (ret < 0) {
goto fail;
}
bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_HEAD);
qemu_iovec_init(&local_qiov, qiov->niov + 2);
qemu_iovec_add(&local_qiov, head_buf, offset & (align - 1));
qemu_iovec_concat(&local_qiov, qiov, 0, qiov->size);
use_local_qiov = true;
bytes += offset & (align - 1);
offset = offset & ~(align - 1);
if (bytes < align) {
qemu_iovec_add(&local_qiov, head_buf + bytes, align - bytes);
bytes = align;
}
}
if ((offset + bytes) & (align - 1)) {
QEMUIOVector tail_qiov;
struct iovec tail_iov;
size_t tail_bytes;
bool waited;
mark_request_serialising(&req, align);
waited = wait_serialising_requests(&req);
assert(!waited || !use_local_qiov);
tail_buf = qemu_blockalign(bs, align);
tail_iov = (struct iovec) {
.iov_base = tail_buf,
.iov_len = align,
};
qemu_iovec_init_external(&tail_qiov, &tail_iov, 1);
bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_TAIL);
ret = bdrv_aligned_preadv(bs, &req, (offset + bytes) & ~(align - 1), align,
align, &tail_qiov, 0);
if (ret < 0) {
goto fail;
}
bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_TAIL);
if (!use_local_qiov) {
qemu_iovec_init(&local_qiov, qiov->niov + 1);
qemu_iovec_concat(&local_qiov, qiov, 0, qiov->size);
use_local_qiov = true;
}
tail_bytes = (offset + bytes) & (align - 1);
qemu_iovec_add(&local_qiov, tail_buf + tail_bytes, align - tail_bytes);
bytes = ROUND_UP(bytes, align);
}
ret = bdrv_aligned_pwritev(bs, &req, offset, bytes, align,
use_local_qiov ? &local_qiov : qiov,
flags);
fail:
if (use_local_qiov) {
qemu_iovec_destroy(&local_qiov);
}
qemu_vfree(head_buf);
qemu_vfree(tail_buf);
out:
tracked_request_end(&req);
bdrv_dec_in_flight(bs);
return ret;
}
| 1threat
|
static int os_host_main_loop_wait(uint32_t timeout)
{
GMainContext *context = g_main_context_default();
int select_ret, g_poll_ret, ret, i;
PollingEntry *pe;
WaitObjects *w = &wait_objects;
gint poll_timeout;
static struct timeval tv0;
ret = 0;
for (pe = first_polling_entry; pe != NULL; pe = pe->next) {
ret |= pe->func(pe->opaque);
}
if (ret != 0) {
return ret;
}
g_main_context_prepare(context, &max_priority);
n_poll_fds = g_main_context_query(context, max_priority, &poll_timeout,
poll_fds, ARRAY_SIZE(poll_fds));
g_assert(n_poll_fds <= ARRAY_SIZE(poll_fds));
for (i = 0; i < w->num; i++) {
poll_fds[n_poll_fds + i].fd = (DWORD_PTR)w->events[i];
poll_fds[n_poll_fds + i].events = G_IO_IN;
}
if (poll_timeout < 0 || timeout < poll_timeout) {
poll_timeout = timeout;
}
qemu_mutex_unlock_iothread();
g_poll_ret = g_poll(poll_fds, n_poll_fds + w->num, poll_timeout);
qemu_mutex_lock_iothread();
if (g_poll_ret > 0) {
for (i = 0; i < w->num; i++) {
w->revents[i] = poll_fds[n_poll_fds + i].revents;
}
for (i = 0; i < w->num; i++) {
if (w->revents[i] && w->func[i]) {
w->func[i](w->opaque[i]);
}
}
}
if (g_main_context_check(context, max_priority, poll_fds, n_poll_fds)) {
g_main_context_dispatch(context);
}
if (nfds >= 0) {
select_ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv0);
if (select_ret != 0) {
timeout = 0;
}
}
return select_ret || g_poll_ret;
}
| 1threat
|
static void vfio_msi_enable(VFIOPCIDevice *vdev)
{
int ret, i;
vfio_disable_interrupts(vdev);
vdev->nr_vectors = msi_nr_vectors_allocated(&vdev->pdev);
retry:
vdev->msi_vectors = g_malloc0(vdev->nr_vectors * sizeof(VFIOMSIVector));
for (i = 0; i < vdev->nr_vectors; i++) {
VFIOMSIVector *vector = &vdev->msi_vectors[i];
MSIMessage msg = msi_get_message(&vdev->pdev, i);
vector->vdev = vdev;
vector->virq = -1;
vector->use = true;
if (event_notifier_init(&vector->interrupt, 0)) {
error_report("vfio: Error: event_notifier_init failed");
}
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
vfio_msi_interrupt, NULL, vector);
vfio_add_kvm_msi_virq(vector, &msg, false);
}
vdev->interrupt = VFIO_INT_MSI;
ret = vfio_enable_vectors(vdev, false);
if (ret) {
if (ret < 0) {
error_report("vfio: Error: Failed to setup MSI fds: %m");
} else if (ret != vdev->nr_vectors) {
error_report("vfio: Error: Failed to enable %d "
"MSI vectors, retry with %d", vdev->nr_vectors, ret);
}
for (i = 0; i < vdev->nr_vectors; i++) {
VFIOMSIVector *vector = &vdev->msi_vectors[i];
if (vector->virq >= 0) {
vfio_remove_kvm_msi_virq(vector);
}
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
NULL, NULL, NULL);
event_notifier_cleanup(&vector->interrupt);
}
g_free(vdev->msi_vectors);
if (ret > 0 && ret != vdev->nr_vectors) {
vdev->nr_vectors = ret;
goto retry;
}
vdev->nr_vectors = 0;
error_report("vfio: Error: Failed to enable MSI");
vdev->interrupt = VFIO_INT_NONE;
return;
}
trace_vfio_msi_enable(vdev->vbasedev.name, vdev->nr_vectors);
}
| 1threat
|
my sql query is not working i had many try : this is my sql query i wanted to store date and time whenever a user come and
post comments over my website. but showing me this context "Parse error: syntax..
code'error, unexpected 'now' (T_STRING) in"
$qry1='insert into life(title,quotation,photos,datetime) values('.$title.','.$quotation.','.$vphoto.''now())';'
| 0debug
|
What is the correct way to import and use d3 and its submodules in ES6? : <p>I'm trying to use a number of d3 packages in a Vue.js project with NPM for package management. I was trying to make a fiddle of a problem I'm having but am unable to replicate the issue there - the code works exactly as it should do.</p>
<p>I'm trying to identify differences between the code running in JSFiddle and the code running in my app and (aside from obvious fact that I'm not running Vue.js in the fiddle) the big one is how I'm importing my extra libraries. In the fiddle I'm adding links to the relevant libraries from CDNJS while in my app I'm using NPM and <code>import</code>. This is all to run charts using <code>dc</code>, which builds on a lot of <code>d3</code> features. My complete imports for the chart component is:</p>
<pre><code>import dc from 'dc'
import crossfilter from 'crossfilter2'
import * as time from 'd3-time'
import * as scale from 'd3-scale'
</code></pre>
<p>I'm not using any features from the base <code>d3</code> module.</p>
<p>The fiddle in question is here: <a href="https://jsfiddle.net/y1qby1xc/10/" rel="noreferrer">https://jsfiddle.net/y1qby1xc/10/</a></p>
| 0debug
|
what does the statement means in Java? : <p>I find a strange statement while reading the openjdk resources.
<a href="https://i.stack.imgur.com/ElYbv.png" rel="nofollow noreferrer">enter image description here</a></p>
<p>what does the "found:{}" means?</p>
| 0debug
|
static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size)
{
AcpiPciHpState *s = opaque;
uint32_t val = 0;
int bsel = s->hotplug_select;
if (bsel < 0 || bsel > ACPI_PCIHP_MAX_HOTPLUG_BUS) {
return 0;
}
switch (addr) {
case PCI_UP_BASE - PCI_HOTPLUG_ADDR:
val = s->acpi_pcihp_pci_status[bsel].device_present &
s->acpi_pcihp_pci_status[bsel].hotplug_enable;
ACPI_PCIHP_DPRINTF("pci_up_read %" PRIu32 "\n", val);
break;
case PCI_DOWN_BASE - PCI_HOTPLUG_ADDR:
val = s->acpi_pcihp_pci_status[bsel].down;
ACPI_PCIHP_DPRINTF("pci_down_read %" PRIu32 "\n", val);
break;
case PCI_EJ_BASE - PCI_HOTPLUG_ADDR:
ACPI_PCIHP_DPRINTF("pci_features_read %" PRIu32 "\n", val);
break;
case PCI_RMV_BASE - PCI_HOTPLUG_ADDR:
val = s->acpi_pcihp_pci_status[bsel].hotplug_enable;
ACPI_PCIHP_DPRINTF("pci_rmv_read %" PRIu32 "\n", val);
break;
case PCI_SEL_BASE - PCI_HOTPLUG_ADDR:
val = s->hotplug_select;
ACPI_PCIHP_DPRINTF("pci_sel_read %" PRIu32 "\n", val);
default:
break;
}
return val;
}
| 1threat
|
Google AdMob error after update to Xcode 11 Swift 5.1 : <p>Since I have updated to Xcode 11 the interstitial ads in my app won't load anymore.
(Before that everything worked fine. The app was even released on the App Store. We are now creating an updated version of the app)</p>
<p>I installed the Google AdMobs SDK via Cocoapods and updated this to the latest version. Still no success. (I followed all the steps of Google's tutorial, how to implement interstitial ads)
These are the error messages I get from the console:</p>
<pre><code> 2019-10-10 21:42:35.543249+0100 BuszZer[76592:876619] <Google> To get test ads on this device, set: request.testDevices = @[ kGADSimulatorID ];
2019-10-10 21:42:35.599222+0100 BuszZer[76592:876796] [Client] Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-10-10 21:42:35.599426+0100 BuszZer[76592:876796] [Client] Updating selectors after delegate addition failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-10-10 21:42:35.599610+0100 BuszZer[76592:876787] [Client] Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-10-10 21:42:35.600170+0100 BuszZer[76592:876787] [Client] Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-10-10 21:42:35.600215+0100 BuszZer[76592:876796] [Client] Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-10-10 21:42:35.601185+0100 BuszZer[76592:876787] [Client] Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-10-10 21:42:35.601435+0100 BuszZer[76592:876796] [Client] Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-10-10 21:42:35.608414+0100 BuszZer[76592:876619] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x60000360a1a0> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2019-10-10 21:42:35.610662+0100 BuszZer[76592:876789] - <Google>[I-ACS025031] AdMob App ID changed. Original, new: (nil), ca-app-pub-9056820091768756~5451481231
2019-10-10 21:42:35.611337+0100 BuszZer[76592:876789] - <Google>[I-ACS023007] Analytics v.60102000 started
2019-10-10 21:42:35.611517+0100 BuszZer[76592:876789] - <Google>[I-ACS023008] To enable debug logging set the following application argument: -APMAnalyticsDebugEnabled (see https://help.apple.com/xcode/mac/8.0/#/dev3ec8a1cb4)
</code></pre>
<p>Does anybody have similar problems or experiences and knows how to solve them? Any help is appreciated.
Thanks a lot!</p>
| 0debug
|
static void intel_hda_update_int_sts(IntelHDAState *d)
{
uint32_t sts = 0;
uint32_t i;
if (d->rirb_sts & ICH6_RBSTS_IRQ) {
sts |= (1 << 30);
}
if (d->rirb_sts & ICH6_RBSTS_OVERRUN) {
sts |= (1 << 30);
}
if (d->state_sts & d->wake_en) {
sts |= (1 << 30);
}
for (i = 0; i < 8; i++) {
if (d->st[i].ctl & (1 << 26)) {
sts |= (1 << i);
}
}
if (sts & d->int_ctl) {
sts |= (1 << 31);
}
d->int_sts = sts;
}
| 1threat
|
static int ioreq_parse(struct ioreq *ioreq)
{
struct XenBlkDev *blkdev = ioreq->blkdev;
uintptr_t mem;
size_t len;
int i;
xen_be_printf(&blkdev->xendev, 3,
"op %d, nr %d, handle %d, id %" PRId64 ", sector %" PRId64 "\n",
ioreq->req.operation, ioreq->req.nr_segments,
ioreq->req.handle, ioreq->req.id, ioreq->req.sector_number);
switch (ioreq->req.operation) {
case BLKIF_OP_READ:
ioreq->prot = PROT_WRITE;
if (ioreq->req.operation != BLKIF_OP_READ && blkdev->mode[0] != 'w') {
xen_be_printf(&blkdev->xendev, 0, "error: write req for ro device\n");
goto err;
}
break;
case BLKIF_OP_WRITE_BARRIER:
if (!syncwrite)
ioreq->presync = ioreq->postsync = 1;
case BLKIF_OP_WRITE:
ioreq->prot = PROT_READ;
if (syncwrite)
ioreq->postsync = 1;
break;
default:
xen_be_printf(&blkdev->xendev, 0, "error: unknown operation (%d)\n",
ioreq->req.operation);
goto err;
};
ioreq->start = ioreq->req.sector_number * blkdev->file_blk;
for (i = 0; i < ioreq->req.nr_segments; i++) {
if (i == BLKIF_MAX_SEGMENTS_PER_REQUEST) {
xen_be_printf(&blkdev->xendev, 0, "error: nr_segments too big\n");
goto err;
}
if (ioreq->req.seg[i].first_sect > ioreq->req.seg[i].last_sect) {
xen_be_printf(&blkdev->xendev, 0, "error: first > last sector\n");
goto err;
}
if (ioreq->req.seg[i].last_sect * BLOCK_SIZE >= XC_PAGE_SIZE) {
xen_be_printf(&blkdev->xendev, 0, "error: page crossing\n");
goto err;
}
ioreq->domids[i] = blkdev->xendev.dom;
ioreq->refs[i] = ioreq->req.seg[i].gref;
mem = ioreq->req.seg[i].first_sect * blkdev->file_blk;
len = (ioreq->req.seg[i].last_sect - ioreq->req.seg[i].first_sect + 1) * blkdev->file_blk;
qemu_iovec_add(&ioreq->v, (void*)mem, len);
}
if (ioreq->start + ioreq->v.size > blkdev->file_size) {
xen_be_printf(&blkdev->xendev, 0, "error: access beyond end of file\n");
goto err;
}
return 0;
err:
ioreq->status = BLKIF_RSP_ERROR;
return -1;
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.