problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
void *address_space_map(AddressSpace *as,
target_phys_addr_t addr,
target_phys_addr_t *plen,
bool is_write)
{
AddressSpaceDispatch *d = as->dispatch;
target_phys_addr_t len = *plen;
target_phys_addr_t todo = 0;
int l;
target_phys_addr_t page;
MemoryRegionSection *section;
ram_addr_t raddr = RAM_ADDR_MAX;
ram_addr_t rlen;
void *ret;
while (len > 0) {
page = addr & TARGET_PAGE_MASK;
l = (page + TARGET_PAGE_SIZE) - addr;
if (l > len)
l = len;
section = phys_page_find(d, page >> TARGET_PAGE_BITS);
if (!(memory_region_is_ram(section->mr) && !section->readonly)) {
if (todo || bounce.buffer) {
break;
}
bounce.buffer = qemu_memalign(TARGET_PAGE_SIZE, TARGET_PAGE_SIZE);
bounce.addr = addr;
bounce.len = l;
if (!is_write) {
address_space_read(as, addr, bounce.buffer, l);
}
*plen = l;
return bounce.buffer;
}
if (!todo) {
raddr = memory_region_get_ram_addr(section->mr)
+ memory_region_section_addr(section, addr);
}
len -= l;
addr += l;
todo += l;
}
rlen = todo;
ret = qemu_ram_ptr_length(raddr, &rlen);
*plen = rlen;
return ret;
}
| 1threat |
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pic, int *got_packet)
{
ProresContext *ctx = avctx->priv_data;
uint8_t *orig_buf, *buf, *slice_hdr, *slice_sizes, *tmp;
uint8_t *picture_size_pos;
PutBitContext pb;
int x, y, i, mb, q = 0;
int sizes[4] = { 0 };
int slice_hdr_size = 2 + 2 * (ctx->num_planes - 1);
int frame_size, picture_size, slice_size;
int mbs_per_slice = ctx->mbs_per_slice;
int pkt_size, ret;
*avctx->coded_frame = *pic;
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
pkt_size = ctx->mb_width * ctx->mb_height * 64 * 3 * 12
+ ctx->num_slices * 2 + 200 + FF_MIN_BUFFER_SIZE;
if ((ret = ff_alloc_packet(pkt, pkt_size)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
return ret;
}
orig_buf = pkt->data;
orig_buf += 4;
bytestream_put_be32 (&orig_buf, FRAME_ID);
buf = orig_buf;
tmp = buf;
buf += 2; size will be stored here
bytestream_put_be16 (&buf, 0);
bytestream_put_buffer(&buf, "Lavc", 4);
bytestream_put_be16 (&buf, avctx->width);
bytestream_put_be16 (&buf, avctx->height);
bytestream_put_byte (&buf, ctx->chroma_factor << 6);
bytestream_put_byte (&buf, 0);
bytestream_put_byte (&buf, 0);
bytestream_put_byte (&buf, 0);
bytestream_put_byte (&buf, 6);
bytestream_put_byte (&buf, 0x40);
bytestream_put_byte (&buf, 0);
bytestream_put_byte (&buf, 0x03);
for (i = 0; i < 64; i++)
bytestream_put_byte(&buf, ctx->profile_info->quant[i]);
for (i = 0; i < 64; i++)
bytestream_put_byte(&buf, ctx->profile_info->quant[i]);
bytestream_put_be16 (&tmp, buf - orig_buf);
picture_size_pos = buf + 1;
bytestream_put_byte (&buf, 0x40); size (in bits)
buf += 4;
bytestream_put_be16 (&buf, ctx->num_slices);
bytestream_put_byte (&buf, av_log2(ctx->mbs_per_slice) << 4);
slice_sizes = buf;
buf += ctx->num_slices * 2;
for (y = 0; y < ctx->mb_height; y++) {
mbs_per_slice = ctx->mbs_per_slice;
for (x = mb = 0; x < ctx->mb_width; x += mbs_per_slice, mb++) {
while (ctx->mb_width - x < mbs_per_slice)
mbs_per_slice >>= 1;
q = find_slice_quant(avctx, pic, (mb + 1) * TRELLIS_WIDTH, x, y,
mbs_per_slice);
}
for (x = ctx->slices_width - 1; x >= 0; x--) {
ctx->slice_q[x] = ctx->nodes[q].quant;
q = ctx->nodes[q].prev_node;
}
mbs_per_slice = ctx->mbs_per_slice;
for (x = mb = 0; x < ctx->mb_width; x += mbs_per_slice, mb++) {
q = ctx->slice_q[mb];
while (ctx->mb_width - x < mbs_per_slice)
mbs_per_slice >>= 1;
bytestream_put_byte(&buf, slice_hdr_size << 3);
slice_hdr = buf;
buf += slice_hdr_size - 1;
init_put_bits(&pb, buf, (pkt_size - (buf - orig_buf)) * 8);
encode_slice(avctx, pic, &pb, sizes, x, y, q, mbs_per_slice);
bytestream_put_byte(&slice_hdr, q);
slice_size = slice_hdr_size + sizes[ctx->num_planes - 1];
for (i = 0; i < ctx->num_planes - 1; i++) {
bytestream_put_be16(&slice_hdr, sizes[i]);
slice_size += sizes[i];
}
bytestream_put_be16(&slice_sizes, slice_size);
buf += slice_size - slice_hdr_size;
}
}
orig_buf -= 8;
frame_size = buf - orig_buf;
picture_size = buf - picture_size_pos - 6;
bytestream_put_be32(&orig_buf, frame_size);
bytestream_put_be32(&picture_size_pos, picture_size);
pkt->size = frame_size;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
| 1threat |
static int write_elf64_load(DumpState *s, MemoryMapping *memory_mapping,
int phdr_index, target_phys_addr_t offset)
{
Elf64_Phdr phdr;
int ret;
int endian = s->dump_info.d_endian;
memset(&phdr, 0, sizeof(Elf64_Phdr));
phdr.p_type = cpu_convert_to_target32(PT_LOAD, endian);
phdr.p_offset = cpu_convert_to_target64(offset, endian);
phdr.p_paddr = cpu_convert_to_target64(memory_mapping->phys_addr, endian);
if (offset == -1) {
phdr.p_filesz = 0;
} else {
phdr.p_filesz = cpu_convert_to_target64(memory_mapping->length, endian);
}
phdr.p_memsz = cpu_convert_to_target64(memory_mapping->length, endian);
phdr.p_vaddr = cpu_convert_to_target64(memory_mapping->virt_addr, endian);
ret = fd_write_vmcore(&phdr, sizeof(Elf64_Phdr), s);
if (ret < 0) {
dump_error(s, "dump: failed to write program header table.\n");
return -1;
}
return 0;
}
| 1threat |
Pie Chart Legend - Chart.js : <p>I need help to put the number of the pie chart in the legend</p>
<p><a href="http://i.stack.imgur.com/grBpc.png" rel="noreferrer">Chart Image</a></p>
<p>If i hover the chart with mouse i can see the number relative to each item</p>
<p>i want to display it in the legend either </p>
<p>the important code so far:</p>
<pre><code>var tempData = {
labels: Status,
datasets: [
{
label: "Status",
data: Qtd,
backgroundColor: randColor
},
]
};
var ctx = $("#pieStatus").get(0).getContext("2d");
var chartInstance = new Chart(ctx, {
type: 'pie',
data: tempData,
options: {
title: {
display: true,
fontsize: 14,
text: 'Total de Pedidos por Situação'
},
legend: {
display: true,
position: 'bottom',
},
responsive: false
}
});
</code></pre>
<blockquote>
<p>"Qtd","randColor" are "var" already with values</p>
</blockquote>
| 0debug |
Angular 4/5 Form Group Validation : <p>I have a reactive form set up on my Angular app but I am trying to figure out if Angular 4/5 has a way to check if an input with a formControlName directive is valid or not.</p>
<p>I don't want to check if the whole form is valid - i know how to do this. I have a stepper process form and I want to disable the next button if it is invalid. </p>
<p>i.e. is there something like this for <strong>form controls</strong> and not just form groups?:</p>
<pre><code>[disabled]="!formGroup.valid"
</code></pre>
| 0debug |
Mount native ext4 partition in WSL2 : <p>I often work on Windows and Linux (on dual boot) and I'm using a ntfs partition to synchronize a data between systems which is something problematic (lots of docker containers have a problem to work with ntfs permissions). I've tried to mount an ext4 partition in wsl1 but it's impossible but I've read that with release of WSL2 it could be achieved. I've tried to do that but have no idea how it can be done. Is there really a way to mount native ext4 in wsl2 to share one partition between linux and wsl2? </p>
| 0debug |
static void spapr_add_lmbs(DeviceState *dev, uint64_t addr, uint64_t size,
uint32_t node, Error **errp)
{
sPAPRDRConnector *drc;
sPAPRDRConnectorClass *drck;
uint32_t nr_lmbs = size/SPAPR_MEMORY_BLOCK_SIZE;
int i, fdt_offset, fdt_size;
void *fdt;
for (i = 0; i < nr_lmbs; i++) {
drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB,
addr/SPAPR_MEMORY_BLOCK_SIZE);
g_assert(drc);
fdt = create_device_tree(&fdt_size);
fdt_offset = spapr_populate_memory_node(fdt, node, addr,
SPAPR_MEMORY_BLOCK_SIZE);
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
drck->attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, errp);
addr += SPAPR_MEMORY_BLOCK_SIZE;
}
if (dev->hotplugged) {
spapr_hotplug_req_add_by_count(SPAPR_DR_CONNECTOR_TYPE_LMB, nr_lmbs);
}
}
| 1threat |
static void qcow_close(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
qcrypto_cipher_free(s->cipher);
s->cipher = NULL;
g_free(s->l1_table);
qemu_vfree(s->l2_cache);
g_free(s->cluster_cache);
g_free(s->cluster_data);
migrate_del_blocker(s->migration_blocker);
error_free(s->migration_blocker);
}
| 1threat |
how can i retreive a row(given as search) from postgresql and display the result in html page? : my problem is that i have to search a term(take as id).if i give some number to search it should search the id in the table(take as result) of pgadmin3(postgresql).and display the result table of particular row what i have searched in the html page.my conditions are i can use only html5 ,ccs3, angularjs and with out using jsp and servelets how can i actually retreive data from postgres and display that in html page??please send me some link or something like step by step code to do that. | 0debug |
static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features,
uint32_t *ext_features,
uint32_t *ext2_features,
uint32_t *ext3_features,
uint32_t *kvm_features,
uint32_t *svm_features)
{
if (!lookup_feature(features, flagname, NULL, feature_name) &&
!lookup_feature(ext_features, flagname, NULL, ext_feature_name) &&
!lookup_feature(ext2_features, flagname, NULL, ext2_feature_name) &&
!lookup_feature(ext3_features, flagname, NULL, ext3_feature_name) &&
!lookup_feature(kvm_features, flagname, NULL, kvm_feature_name) &&
!lookup_feature(svm_features, flagname, NULL, svm_feature_name))
fprintf(stderr, "CPU feature %s not found\n", flagname);
}
| 1threat |
Scala merge array add more distinguished field : I am a new Scala programmer, i have a case that needs everyone help
Input:
a = Array("a", "b", "c")
b = Array("d", "e", "f")
c = Array("g", "h", "k")
I want output like this:
a+b+c=> Array({"1",array["a", "b", "c"]},
{"2",array["d", "e", "f"]},
{"3,array("g", "h", "k")]})
Regards,
Trinh | 0debug |
static int find_tag(ByteIOContext *pb, uint32_t tag1)
{
unsigned int tag;
int size;
for(;;) {
if (url_feof(pb))
return -1;
tag = get_le32(pb);
size = get_le32(pb);
if (tag == tag1)
break;
url_fseek(pb, size, SEEK_CUR);
}
if (size < 0)
size = 0x7fffffff;
return size;
}
| 1threat |
static void bdrv_io_limits_intercept(BlockDriverState *bs,
int nb_sectors,
bool is_write)
{
bool must_wait = throttle_schedule_timer(&bs->throttle_state, is_write);
if (must_wait ||
!qemu_co_queue_empty(&bs->throttled_reqs[is_write])) {
qemu_co_queue_wait(&bs->throttled_reqs[is_write]);
}
throttle_account(&bs->throttle_state,
is_write,
nb_sectors * BDRV_SECTOR_SIZE);
if (throttle_schedule_timer(&bs->throttle_state, is_write)) {
return;
}
qemu_co_queue_next(&bs->throttled_reqs[is_write]);
}
| 1threat |
Code does not work in Python with turtle module : <p>I was creating a game in python with turtle and came across an error. The game's objective is to move your tank around and shoot enemy tanks. I am not finished yet. I added a white border, but when I tried to program the tank so that it could not go out of the boundaries, it does not work. Here is my code:</p>
<pre><code>#Import modules
import turtle
import time
import random
#Create screen
map = turtle.Screen()
map.bgcolor("limegreen")
#Create player tank
tank = turtle.Turtle()
tank.shape("triangle")
tank.color("blue")
tank.speed(0)
tank.penup()
tank.setposition(0, 0)
tank.setheading(90)
#Create border
borderPen = turtle.Turtle()
borderPen.speed(0)
borderPen.hideturtle()
borderPen.penup()
borderPen.setposition(-300, -300)
borderPen.color("white")
borderPen.pendown()
for sides in range(4):
borderPen.fd(600)
borderPen.lt(90)
#Define update coords function
global playerX
global playerY
global playerHeading
global tankSpeed
tankSpeed = 5
def update_coords():
playerX = tank.xcor()
playerY = tank.ycor()
playerHeading = tank.heading()
#Define player movement functions
def move_forward():
tank.fd(5)
update_coords();
if playerX > 300 or playerX == 300:
tank.setx(playerX - 5)
update_coords();
elif playerX < -300 or playerX == -300:
tank.setx(playerX + 5)
update_coords();
elif playerY > 300 or playerY == 300:
tank.sety(playerY - 5)
update_coords();
elif playerY < -300 or playerY == -300:
tank.sety(playerY + 5)
update_coords();
def turn_left():
tank.lt(10)
def turn_right():
tank.rt(10)
#Allow player movement
map.listen()
map.onkey(move_forward, "Up")
map.onkey(turn_left, "Left")
map.onkey(turn_right, "Right")
#Create bullet
bullet = turtle.Turtle()
bullet.penup()
bullet.speed(0)
bullet.color("black")
bullet.hideturtle()
</code></pre>
<p>If you know why the code does not work, please respond. Thanks!</p>
| 0debug |
int qemu_strtoul(const char *nptr, const char **endptr, int base,
unsigned long *result)
{
char *ep;
int err = 0;
if (!nptr) {
if (endptr) {
*endptr = nptr;
}
err = -EINVAL;
} else {
errno = 0;
*result = strtoul(nptr, &ep, base);
if (errno == ERANGE) {
*result = -1;
}
err = check_strtox_error(nptr, ep, endptr, errno);
}
return err;
}
| 1threat |
Name or service not known [tcp://redis:6379] : <p>i am having a problem setting up redis cache with laravel.
i have a redis server runnig on my local machine:</p>
<p><a href="https://i.stack.imgur.com/PdbZC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PdbZC.png" alt="enter image description here"></a></p>
<p>my .env:</p>
<p><a href="https://i.stack.imgur.com/lO3hJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lO3hJ.png" alt="enter image description here"></a></p>
<p>i have the localhost on port 6379 ready and listened:</p>
<p><a href="https://i.stack.imgur.com/2h5Q0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2h5Q0.png" alt="enter image description here"></a></p>
<p>someone plz tell me what's happenig here?<a href="https://i.stack.imgur.com/Z35Tj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Z35Tj.png" alt="enter image description here"></a></p>
| 0debug |
parse a csv file in C# , any help appreciated : String[] values = File.ReadAllText(@"C:/Users/state.csv").Split(',');
Console.WriteLine(values);
Console.ReadLine();
it just prints out :
System.String[] onto console and the program is running for a long time | 0debug |
App crashes when trying to upload in firebase : App crashes when trying to upload in firebase. In the XML i have a upload button that is used to invoke camera. On clicking it doesn't get uploaded on to the firebase.
This is my code
private Button mUploadBtn;
private ImageView mImageView;
private static final int CAMERA_REQUEST_CODE = 1;
private StorageReference mStorage;
Uri photoURI;
private ProgressDialog mProgressDialog;
private static final int GALLERY_INTENT = 2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mStorage = FirebaseStorage.getInstance().getReference();
mUploadBtn = (Button) findViewById(R.id.upload);
mImageView = (ImageView) findViewById(R.id.imageView);
mProgressDialog = new ProgressDialog(this);
mUploadBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, CAMERA_REQUEST_CODE);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAMERA_REQUEST_CODE && resultCode == RESULT_OK) {
mProgressDialog.setMessage("Uplaoding");
mProgressDialog.show();
Uri uri = data.getData();
StorageReference filepath = mStorage.child("Photos").child("file");
filepath.putFile(uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
mProgressDialog.dismiss();
Toast.makeText(MainActivity.this,"Done",Toast.LENGTH_LONG).show();
}
});
}
}
}[This is the error i am getting and it is pointing to
filepath.putFile(uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
][1]
[1]: https://i.stack.imgur.com/WG36s.png | 0debug |
React native takes very long to load on device : <p>I've been developing a react-native app using the simulator for a while. On the simulator (iOS), the app loads very fast (on reload for eg). However, when I tried to load the app to the device, it spends between 1-3 minutes in the splash screen before loading into the app. </p>
<p>My project is fairly small, and has no extra resources other than the javascript. Looking at the documentation I couldn't find what might be the cause of the issue, though I suspect it has to do with the fact that it is not getting the JS from the packager local server.</p>
<p>What am I doing wrong? </p>
<p>(btw - react-native v0.31)</p>
| 0debug |
I want to change the positioning of my plates in css in flexbox : Allow me to begin by saying I'm not set on using flexbox so if a different method has to be used, I'm open to it. I am making a JavaScript website which displays plates with questions and answers. Question length varies and so does the amount of answers - therefore the plates are not the same height. They could be but I like the look of them not being so. The black image shows what it currently looks like and the white shows what I would like it to look like. I would like to be able to fully be able to customize the location of these plates to always be a fixed distance of 5px appart. Also if one plate is very long I'd like there to be the possibility of e.g. 3 small plates to be able to go on either side without them being changed in size but simply arranged in this messy clean look.[ desired look ][1][current look ][2][code ][3][code ][4][code ][5]please note I have tried using `right` `left` `top` and `bottom` but they have no effect.
[1]: https://i.stack.imgur.com/kioxU.png
[2]: https://i.stack.imgur.com/IhToG.png
[3]: https://i.stack.imgur.com/TZjSx.png
[4]: https://i.stack.imgur.com/AGP28.png
[5]: https://i.stack.imgur.com/aaCec.png | 0debug |
How can I make the client stays on until the server makes a connection..Java? : //Client
`enter code here` public class MyClient {
public static void main(String[] args) throws IOException, SocketException, ConnectException {
ServerSocket serverSocket = null;
Socket clientSocket = null;
BufferedReader in = null;
System.out.println("Welcome to the Daytime client.");
try{
clientSocket = new Socket("localhost", 4321);
while(true){
in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
String s = in.readLine();
System.out.println("Here is the timestamp received from the server: "+s);
System.out.println("The program terminated with no error and no exception");
in.close();
clientSocket.close();
clientSocket.close();
}
}catch (ConnectException e){
System.exit(0);
}catch (SocketException f){
System.exit(0);
}catch (IOException e) {
System.out.println("Error: " + e);
System.exit(0);
}
}
}
//SERVER
import java.io.*;
import java.net.*;
import java.util.*;
public class MyServer {
public static void main(String[] args) throws IOException {
ServerSocket serverSocket = null;
Socket clientSocket = null;
PrintWriter out = null;
System.out.println("Daytime server ready.");
try {
serverSocket = new ServerSocket(4321);
while(true){
clientSocket = serverSocket.accept();
System.out.println("Request received.");
out = new PrintWriter(clientSocket.getOutputStream(), true);
Date timestamp = new Date ();
out.println(timestamp.toString());
}
} catch (IOException e) {
System.out.println("Error: " + e);
System.exit(0);
}
out.close();
clientSocket.close();
serverSocket.close();
System.out.println("3");
}
}
| 0debug |
Importing multiple packages using brackets gives errors in go? : <p>So for some reason when I import on a single line like this it works fine:</p>
<pre><code>package main
import "fmt"
func main() {
fmt.Println("hi")
}
</code></pre>
<p>But when I do this:</p>
<pre><code>package main
import {
"fmt"
"bufio"
"os"
"errors"
"math"
}
func main() {
fmt.Println("hi")
}
</code></pre>
<p>I get this:</p>
<p>main.go:3:8: expected 'STRING', found '{'</p>
<p>main.go:4:3: expected ';', found "fmt"</p>
<p>Does anyone know what's the problem? Thanks!</p>
| 0debug |
Safari 11 / YouTube API bug. Rapid play/pause and failure to autoplay : <p>This just started getting reported to me by users. I spent a bunch of time exploring my own code for bugs, but it seems like it's related specifically to <strong>Safari 11</strong> <em>(newest)</em>.</p>
<p>When using a simple example of the YouTube IFrame Embed API, Safari will rapidly switch between states of play and pause until it ends up on pause.</p>
<p>This is not the most optimized version of the example because there was some exploration in here as to what might make it work. I wanted to skip ahead and autoplay, but it wouldn't work the way it's supposed to. I tried using <code>start</code> and <code>playVideo</code> which are documented YT API examples.</p>
<p>I've only recently confirmed this to be a bug which explains why there's some verbose parameters in the example.</p>
<p>Notes:</p>
<ul>
<li>Sometimes the video WILL play depending on how many times you refresh, but it's very infrequent.</li>
<li>Autoplay flags usually fail.</li>
<li>Using <code>start</code> flag in this example to skip forward because <code>startSeconds</code> was not working.</li>
<li>Code example works in other browsers: <code>Chrome</code>, <code>Opera</code>, <code>Firefox</code></li>
</ul>
<p>Here's an image of what you might see in Safari's console, which shows the Player State panic, eventually landing on 2 (<em>paused</em>). <a href="https://i.stack.imgur.com/2WmSO.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2WmSO.png" alt="Panic in the console"></a></p>
<p>Here's a copy/paste code sample that will replicate the bug. Drop it in any HTML file and you should see it fail in Safari 11. </p>
<pre><code><style>
body, html, iframe {
position: absolute; left: 0; right: 0; top: 0; bottom: 0; width: 100%; height: 100%;
margin: 0;
padding: 0;
pointer-events: none;
}
</style>
<script>
var videoId = "9nwQ1F7oX-8";
var playerVars = {
autohide: 1,
autopause: 0,
autoplay: 1,
cc_load_policy: "0",
disablekb: 1,
enablejsapi: 1,
iv_load_policy: 1,
modestbranding: 1,
origin: "*",
rel: 0,
showinfo: 0,
start: 122,
version: 3
};
</script>
<iframe id="ytplayer"
frameborder="0"
allowfullscreen="1"
title="YouTube video player"
width="100%"
height="100%"
x-src="https://www.youtube.com/embed/9nwQ1F7oX-8?enablejsapi=1&amp;origin=*&amp;rel=0&amp;version=3&amp;iv_load_policy=3&amp;modestbranding=1&amp;showinfo=0&amp;autohide=1&amp;disablekb=1&amp;autoplay=1&amp;autopause=0&amp;cc_load_policy=0&amp;startSeconds=30&amp;widgetid=1"
src="https://www.youtube.com/embed/9nwQ1F7oX-8?enablejsapi=1&amp;origin=*&amp;start=122">
</iframe>
<script>
window.onYouTubeIframeAPIReady = function() {
console.log("YouTube is ready!", videoId, playerVars);
var api = new YT.Player("ytplayer", {
width: "100%",
height: "100%",
videoId: videoId,
playerVars: playerVars,
events: {
onError: function(e) {
// 100 – The video requested was not found. This error occurs when a video has been removed (for any reason) or has been marked as private.
// 101 – The owner of the requested video does not allow it to be played in embedded players.
// 150 – This error is the same as 101. It"s just a 101 error in disguise!
console.warn("An error has occurred", arguments);
},
onReady: function() {
// log
console.log("YouTube player is ready to use");
//
api.playVideo();
},
onStateChange: function(e) {
// log
console.log("YouTube state change ", e);
// Finished
if (e.data == 0) {
console.log("Finished");
}
// Playing
else if (e.data === YT.PlayerState.PLAYING) {
console.log("Playing");
}
// Pausing
else if (e.data === 2) {
console.log("Pausing");
}
// Buffering
else if (e.data === 3) {
console.log("Buffering");
}
}
}
});
}
</script>
<script src="https://www.youtube.com/iframe_api"></script>
</code></pre>
| 0debug |
How does Google's reCAPTCHA v3 work? : <p>Google has rolled out <a href="https://developers.google.com/recaptcha/docs/v3" rel="noreferrer">reCAPTCHA v3</a>. It does away with all user the friction. I wish to use it to secure my site. However, I am unsure about how this is going to protect my site. What if a hacker spams the URLs on my site with an external tool without using the interface I provide? How is reCAPTCHA v3 going to stop that?</p>
| 0debug |
i want to send some command from my android app to android terminal emulator : public void onClick(View p1)
{
// TODO: Implement this method
Intent i=new Intent(Intent.ACTION_SEND);
i.setType("*/*");
i.setPackage("jackpal.androidterm");
i.putExtra(Intent.EXTRA_TEXT,"date");
startActivity(i);
} | 0debug |
Google Assistant SDK to integrate it in an app : <p>Is it possible to integrate the google assistant in an android app?</p>
<p>I couldn't find any information about it online.</p>
<p>I know today Google released the Assistant SDK but they don't mention any android support even in their <a href="https://developers.googleblog.com/2017/04/introducing-google-assistant-sdk.html" rel="noreferrer">Android Developers Blog post</a></p>
<p>It would be useful to ask for something your app can offer if installed.</p>
<p>For example:</p>
<p>"ok google, find a Star Wars blu ray on amazon"</p>
<p>and it would launch the amazon shopping app and look for it.</p>
<p>Is it possible to implement something like this within an app with this released SDK?</p>
| 0debug |
Vue-meta: metaInfo doesn't have an access to computed properties : <p>I'm using vue-meta to dynamically change my meta tags. I want to change it only on some particular pages. </p>
<p>I'm using metaInfo function and try to change, for example, a title. But data from my getter is undefined which is why I cannot change the title in meta tags. It seems like metaInfo function try to access data before the component actually has it.</p>
<p>Here is my code in the component:</p>
<pre><code><template>
...
</template>
<script>
export default {
metaInfo() {
return {
title: this.getViewPage.data.meta.title, // data is undefined
};
},
created() {
this.loadViewPage();
},
computed: {
...mapGetters(['getViewPage']),
},
methods: {
...mapActions(['loadViewPage']),
};
</script>
</code></pre>
| 0debug |
static av_always_inline void rv40_adaptive_loop_filter(uint8_t *src, const int step,
const int stride, const int dmode,
const int lim_q1, const int lim_p1,
const int alpha,
const int beta, const int beta2,
const int chroma, const int edge)
{
int diff_p1p0[4], diff_q1q0[4], diff_p1p2[4], diff_q1q2[4];
int sum_p1p0 = 0, sum_q1q0 = 0, sum_p1p2 = 0, sum_q1q2 = 0;
uint8_t *ptr;
int flag_strong0 = 1, flag_strong1 = 1;
int filter_p1, filter_q1;
int i;
int lims;
for(i = 0, ptr = src; i < 4; i++, ptr += stride){
diff_p1p0[i] = ptr[-2*step] - ptr[-1*step];
diff_q1q0[i] = ptr[ 1*step] - ptr[ 0*step];
sum_p1p0 += diff_p1p0[i];
sum_q1q0 += diff_q1q0[i];
}
filter_p1 = FFABS(sum_p1p0) < (beta<<2);
filter_q1 = FFABS(sum_q1q0) < (beta<<2);
if(!filter_p1 && !filter_q1)
return;
for(i = 0, ptr = src; i < 4; i++, ptr += stride){
diff_p1p2[i] = ptr[-2*step] - ptr[-3*step];
diff_q1q2[i] = ptr[ 1*step] - ptr[ 2*step];
sum_p1p2 += diff_p1p2[i];
sum_q1q2 += diff_q1q2[i];
}
if(edge){
flag_strong0 = filter_p1 && (FFABS(sum_p1p2) < beta2);
flag_strong1 = filter_q1 && (FFABS(sum_q1q2) < beta2);
}else{
flag_strong0 = flag_strong1 = 0;
}
lims = filter_p1 + filter_q1 + ((lim_q1 + lim_p1) >> 1) + 1;
if(flag_strong0 && flag_strong1){
for(i = 0; i < 4; i++, src += stride){
int sflag, p0, q0, p1, q1;
int t = src[0*step] - src[-1*step];
if(!t) continue;
sflag = (alpha * FFABS(t)) >> 7;
if(sflag > 1) continue;
p0 = (25*src[-3*step] + 26*src[-2*step]
+ 26*src[-1*step]
+ 26*src[ 0*step] + 25*src[ 1*step] + rv40_dither_l[dmode + i]) >> 7;
q0 = (25*src[-2*step] + 26*src[-1*step]
+ 26*src[ 0*step]
+ 26*src[ 1*step] + 25*src[ 2*step] + rv40_dither_r[dmode + i]) >> 7;
if(sflag){
p0 = av_clip(p0, src[-1*step] - lims, src[-1*step] + lims);
q0 = av_clip(q0, src[ 0*step] - lims, src[ 0*step] + lims);
}
p1 = (25*src[-4*step] + 26*src[-3*step]
+ 26*src[-2*step]
+ 26*p0 + 25*src[ 0*step] + rv40_dither_l[dmode + i]) >> 7;
q1 = (25*src[-1*step] + 26*q0
+ 26*src[ 1*step]
+ 26*src[ 2*step] + 25*src[ 3*step] + rv40_dither_r[dmode + i]) >> 7;
if(sflag){
p1 = av_clip(p1, src[-2*step] - lims, src[-2*step] + lims);
q1 = av_clip(q1, src[ 1*step] - lims, src[ 1*step] + lims);
}
src[-2*step] = p1;
src[-1*step] = p0;
src[ 0*step] = q0;
src[ 1*step] = q1;
if(!chroma){
src[-3*step] = (25*src[-1*step] + 26*src[-2*step] + 51*src[-3*step] + 26*src[-4*step] + 64) >> 7;
src[ 2*step] = (25*src[ 0*step] + 26*src[ 1*step] + 51*src[ 2*step] + 26*src[ 3*step] + 64) >> 7;
}
}
}else if(filter_p1 && filter_q1){
for(i = 0; i < 4; i++, src += stride)
rv40_weak_loop_filter(src, step, 1, 1, alpha, beta, lims, lim_q1, lim_p1,
diff_p1p0[i], diff_q1q0[i], diff_p1p2[i], diff_q1q2[i]);
}else{
for(i = 0; i < 4; i++, src += stride)
rv40_weak_loop_filter(src, step, filter_p1, filter_q1,
alpha, beta, lims>>1, lim_q1>>1, lim_p1>>1,
diff_p1p0[i], diff_q1q0[i], diff_p1p2[i], diff_q1q2[i]);
}
}
| 1threat |
static uint32_t slavio_serial_mem_readb(void *opaque, target_phys_addr_t addr)
{
SerialState *ser = opaque;
ChannelState *s;
uint32_t saddr;
uint32_t ret;
int channel;
saddr = (addr & 3) >> 1;
channel = (addr & SERIAL_MAXADDR) >> 2;
s = &ser->chn[channel];
switch (saddr) {
case 0:
SER_DPRINTF("Read channel %c, reg[%d] = %2.2x\n", CHN_C(s), s->reg, s->rregs[s->reg]);
ret = s->rregs[s->reg];
s->reg = 0;
return ret;
case 1:
s->rregs[0] &= ~1;
clr_rxint(s);
if (s->type == kbd || s->type == mouse)
ret = get_queue(s);
else
ret = s->rx;
SER_DPRINTF("Read channel %c, ch %d\n", CHN_C(s), ret);
return ret;
default:
break;
}
return 0;
}
| 1threat |
static int get_audio_flags(AVCodecContext *enc){
int flags = (enc->bits_per_coded_sample == 16) ? FLV_SAMPLESSIZE_16BIT : FLV_SAMPLESSIZE_8BIT;
if (enc->codec_id == CODEC_ID_AAC)
return FLV_CODECID_AAC | FLV_SAMPLERATE_44100HZ | FLV_SAMPLESSIZE_16BIT | FLV_STEREO;
else if (enc->codec_id == CODEC_ID_SPEEX) {
if (enc->sample_rate != 16000) {
av_log(enc, AV_LOG_ERROR, "flv only supports wideband (16kHz) Speex audio\n");
return -1;
}
if (enc->channels != 1) {
av_log(enc, AV_LOG_ERROR, "flv only supports mono Speex audio\n");
return -1;
}
if (enc->frame_size / 320 > 8) {
av_log(enc, AV_LOG_WARNING, "Warning: Speex stream has more than "
"8 frames per packet. Adobe Flash "
"Player cannot handle this!\n");
}
return FLV_CODECID_SPEEX | FLV_SAMPLERATE_11025HZ | FLV_SAMPLESSIZE_16BIT;
} else {
switch (enc->sample_rate) {
case 44100:
flags |= FLV_SAMPLERATE_44100HZ;
break;
case 22050:
flags |= FLV_SAMPLERATE_22050HZ;
break;
case 11025:
flags |= FLV_SAMPLERATE_11025HZ;
break;
case 8000:
case 5512:
if(enc->codec_id != CODEC_ID_MP3){
flags |= FLV_SAMPLERATE_SPECIAL;
break;
}
default:
av_log(enc, AV_LOG_ERROR, "flv does not support that sample rate, choose from (44100, 22050, 11025).\n");
return -1;
}
}
if (enc->channels > 1) {
flags |= FLV_STEREO;
}
switch(enc->codec_id){
case CODEC_ID_MP3:
flags |= FLV_CODECID_MP3 | FLV_SAMPLESSIZE_16BIT;
break;
case CODEC_ID_PCM_U8:
flags |= FLV_CODECID_PCM | FLV_SAMPLESSIZE_8BIT;
break;
case CODEC_ID_PCM_S16BE:
flags |= FLV_CODECID_PCM | FLV_SAMPLESSIZE_16BIT;
break;
case CODEC_ID_PCM_S16LE:
flags |= FLV_CODECID_PCM_LE | FLV_SAMPLESSIZE_16BIT;
break;
case CODEC_ID_ADPCM_SWF:
flags |= FLV_CODECID_ADPCM | FLV_SAMPLESSIZE_16BIT;
break;
case CODEC_ID_NELLYMOSER:
if (enc->sample_rate == 8000) {
flags |= FLV_CODECID_NELLYMOSER_8KHZ_MONO | FLV_SAMPLESSIZE_16BIT;
} else {
flags |= FLV_CODECID_NELLYMOSER | FLV_SAMPLESSIZE_16BIT;
}
break;
case 0:
flags |= enc->codec_tag<<4;
break;
default:
av_log(enc, AV_LOG_ERROR, "codec not compatible with flv\n");
return -1;
}
return flags;
}
| 1threat |
What does char '|' mean in Linux command : <p>In example:</p>
<p><code>lsof -i -P -n | grep LISTEN</code></p>
<p>How do I "read" that command? I have tried to search anywhere, and found nothing explained those.</p>
| 0debug |
static void v9fs_remove(void *opaque)
{
int32_t fid;
int err = 0;
size_t offset = 7;
V9fsFidState *fidp;
V9fsPDU *pdu = opaque;
pdu_unmarshal(pdu, offset, "d", &fid);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
if (!pdu->s->ctx.flags & PATHNAME_FSCONTEXT) {
err = -EOPNOTSUPP;
goto out_err;
}
err = v9fs_mark_fids_unreclaim(pdu, &fidp->path);
if (err < 0) {
goto out_err;
}
err = v9fs_co_remove(pdu, &fidp->path);
if (!err) {
err = offset;
}
out_err:
clunk_fid(pdu->s, fidp->fid);
put_fid(pdu, fidp);
out_nofid:
complete_pdu(pdu->s, pdu, err);
} | 1threat |
Where should I save an SQL Table on my computer? : I am currently creating a database for my project and was wondering where I should save the table. Should I just save it in documents (D:\Documents) or should I save it in the same folder where my project is saved (D:\Documents\Visual Studio 2015\Projects\ALevelCompUnit3)? I was hoping to develop it at school.
Also, the school only provides Visual Basic 2008; would I have to change the framework to do it at school? | 0debug |
How to kill an heroku build that is in progress? : <p>I accidentally pushed a build that does an npm install in the postinstall script. This has led to my heroku app being stuck in an infinite install loop. I searched the heroku documentation on how to kill builds but came up blank. The closest thing I found was <a href="https://help.heroku.com/Z44Q4WW4/how-do-i-stop-a-release-phase" rel="noreferrer">https://help.heroku.com/Z44Q4WW4/how-do-i-stop-a-release-phase</a> and I tried killing as per those instructions but my build won't die :(</p>
| 0debug |
whats the simplest way to write a palindrome string using a while loop in java. : Ive searched about everywhere but I just cant find any thing very concrete I've been working at this code for awhile but it keeps stumping me.
public static void main(String[] args)
{
System.out.println(palindrome("word"));
}
public static boolean palindrome(String myPString)
{
Scanner in = new Scanner(System.in);
System.out.println("Enter a word:");
String word = in.nextLine();
String reverse = "";
int startIndex = 0;
int str = word.length() -1;
while(str >=0)
{
reverse = reverse + word.charAt(i);
}
| 0debug |
static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
AVFormatContext *s)
{
AVIOContext *pb_buf;
int i, ret, size;
uint8_t *buf;
for (i = 0; i < s->nb_streams; i++)
if (s->flags & AVFMT_FLAG_BITEXACT) {
return 0;
}
ret = avio_open_dyn_buf(&pb_buf);
if (ret < 0)
return ret;
if (mov->mode & MODE_3GP) {
mov_write_3gp_udta_tag(pb_buf, s, "perf", "artist");
mov_write_3gp_udta_tag(pb_buf, s, "titl", "title");
mov_write_3gp_udta_tag(pb_buf, s, "auth", "author");
mov_write_3gp_udta_tag(pb_buf, s, "gnre", "genre");
mov_write_3gp_udta_tag(pb_buf, s, "dscp", "comment");
mov_write_3gp_udta_tag(pb_buf, s, "albm", "album");
mov_write_3gp_udta_tag(pb_buf, s, "cprt", "copyright");
mov_write_3gp_udta_tag(pb_buf, s, "yrrc", "date");
} else if (mov->mode == MODE_MOV) {
mov_write_string_metadata(s, pb_buf, "\251ART", "artist", 0);
mov_write_string_metadata(s, pb_buf, "\251nam", "title", 0);
mov_write_string_metadata(s, pb_buf, "\251aut", "author", 0);
mov_write_string_metadata(s, pb_buf, "\251alb", "album", 0);
mov_write_string_metadata(s, pb_buf, "\251day", "date", 0);
mov_write_string_metadata(s, pb_buf, "\251swr", "encoder", 0);
mov_write_string_metadata(s, pb_buf, "\251des", "comment", 0);
mov_write_string_metadata(s, pb_buf, "\251gen", "genre", 0);
mov_write_string_metadata(s, pb_buf, "\251cpy", "copyright", 0);
} else {
mov_write_meta_tag(pb_buf, mov, s);
}
if (s->nb_chapters && !(mov->flags & FF_MOV_FLAG_DISABLE_CHPL))
mov_write_chpl_tag(pb_buf, s);
if ((size = avio_close_dyn_buf(pb_buf, &buf)) > 0) {
avio_wb32(pb, size + 8);
ffio_wfourcc(pb, "udta");
avio_write(pb, buf, size);
}
av_free(buf);
return 0;
}
| 1threat |
static inline void downmix_2f_2r_to_mono(float *samples)
{
int i;
for (i = 0; i < 256; i++) {
samples[i] += (samples[i + 256] + samples[i + 512] + samples[i + 768]);
samples[i + 256] = samples[i + 512] = samples[i + 768] = 0;
}
}
| 1threat |
how to get Difference between Two Dates in Javascript Year/Month/Day : <p>I need the difference between two dates in javascript, this is my date format 24-05-2018, and I need no of year, no of months, no of days</p>
| 0debug |
Automatically hard wrap lines at column in VSCode : <p>How can I automatically hard wrap lines in VSCode? By that I mean if a line reaches a specified column, automatically insert a newline at the word boundary closest to that column without going over. Vim has a setting called <a href="http://vim.wikia.com/wiki/Automatic_word_wrapping" rel="noreferrer">textwidth</a> that does this that I like to use when editing Markdown. It doesn't seem like VSCode does, as far as I can tell. It just has ways to control softwrapping.</p>
| 0debug |
How to shorten list by grouping values that appear multiple times in Python 3.7? : <p>I have a list that's something like this:</p>
<pre><code>foo = ['bar', 'bar', 'bar', 'foo', 'foo','bar']
</code></pre>
<p>and I want it to be converted to something like this:</p>
<pre><code>'1-3 = bar'
'4-5 = foo'
'6 = bar'
</code></pre>
<p>The conversion needs to be done automatically, to accommodate list changes. How would I go about automating this?</p>
| 0debug |
GGPLOT2 in R code not working though I have installed the library : Hi can anyone tell me whats wrong with following R code?
ggplot(train, aes(x= Item_Visibility, y = Item_Outlet_Sales)) + geom_point(size = 2.5, color="navy") + xlab("Item Visibility") + ylab("Item Outlet Sales") + ggtitle("Item Visibility vs Item Outlet Sales") | 0debug |
Why haven't newer dependently typed languages adopted SSReflect's approach? : <p>There are two conventions I've found in Coq's SSReflect extension that seem particularly useful but which I haven't seen widely adopted in newer dependently-typed languages (Lean, Agda, Idris).</p>
<p>Firstly, where possible predicates are expressed as boolean-returning functions rather than inductively defined datatypes. This brings decidability by default, opens up more opportunities for proof by computation, and improves checking performance by avoiding the need for the proof engine to carry around large proof terms. The main disadvantage I see is the need to use reflection lemmas to manipulate these boolean predicates when proving.</p>
<p>Secondly, datatypes with invariants are defined as dependent records containing a simple datatype plus a proof of the invariant. For instance, fixed length sequences are defined in SSReflect like: </p>
<pre><code>Structure tuple_of : Type := Tuple {tval :> seq T; _ : size tval == n}.
</code></pre>
<p>A <code>seq</code> and a proof of that sequence's length being a certain value. This is opposed to how e.g. Idris defines this type:</p>
<pre><code>data Vect : (len : Nat) -> (elem : Type) -> Type
</code></pre>
<p>A dependently typed datastructure in which the invariant is part of its type. One advantage of SSReflect's approach is that it allows reuse, so that for instance many of the functions defined for <code>seq</code> and proofs about them can still be used with <code>tuple</code> (by operating on the underlying <code>seq</code>), whereas with Idris' approach functions like <code>reverse</code>, <code>append</code> and the like need to be rewritten for <code>Vect</code>. Lean actually has a SSReflect style equivalent in its standard library, <code>vector</code>, but it also has an Idris-style <code>array</code> which seems to have an optimised implementation in the runtime.</p>
<p>One <a href="http://ilyasergey.net/pnp/pnp.pdf" rel="noreferrer">SSReflect-oriented book</a> even claims the <code>Vect n A</code> style approach is an antipattern:</p>
<blockquote>
<p>A common anti-pattern in dependently-typed languages and Coq in particular is to encode such algebraic properties into the definitions of the datatypes and functions themselves (a canonical example
of such approach are length-indexed lists). While this approach looks appealing, as it demonstrates
the power of dependent types to capture certain properties of datatypes and functions on them, it
is inherently non-scalable, as there will be always another property of interest, which has not been
foreseen by a designer of the datatype/function, so it will have to be encoded as an external fact
anyway. This is why we advocate the approach, in which datatypes and functions are defined as close
to the way they would be defined by a programmer as possible, and all necessary properties of them
are proved separately.</p>
</blockquote>
<p>My question is hence, why haven't these approaches been more widely adopted. Are there disadvantages I'm missing, or maybe their advantages are less significant in languages with better support for dependent pattern matching than Coq?</p>
| 0debug |
static int get_audio_frame_size(AVCodecContext *enc, int size)
{
int frame_size;
if(enc->codec_id == CODEC_ID_VORBIS)
return -1;
if (enc->frame_size <= 1) {
int bits_per_sample = av_get_bits_per_sample(enc->codec_id);
if (bits_per_sample) {
if (enc->channels == 0)
return -1;
frame_size = (size << 3) / (bits_per_sample * enc->channels);
} else {
if (enc->bit_rate == 0)
return -1;
frame_size = (size * 8 * enc->sample_rate) / enc->bit_rate;
}
} else {
frame_size = enc->frame_size;
}
return frame_size;
}
| 1threat |
learning php login screen with username and password. but it doesnt work : <p>I have the following code in a html and suspect the line with "htmlspecialchars($_SERVER["PHP_SELF"])" is the error :
...
<pre><code>$check = 0;
if ($count == 1) {
if ($username == "johnny" && $password == "123123") {
echo "Hej $username. din kode er korrekt. Velkommen! <br>";
$check = 1;
}
else {
echo "hej, din kode eller brugernam " . "er forkert. <br>";
echo "forsøg venligst igen: <br><br>";
}
}
if (check == 0) {
echo "<h1>Indtast venligst brugernavn og din kode</h1>";
echo "<form action= \"htmlspecialchars($_SERVER["PHP_SELF"])\" method=\"post\">";
echo "<input type=\"hidden\" name=\"count\" value=\"1\">";
echo "username: <input type=\"text\" name=\"username\">";
echo "<br>";
echo "password: <input type=\"password\" name=\"password\">";
echo "<br><br>";
echo "<input type=\"submit\">";
echo "</form>";
}
?>
</code></pre>
<p>
...</p>
| 0debug |
static int parse_playlist(HLSContext *c, const char *url,
struct variant *var, AVIOContext *in)
{
int ret = 0, is_segment = 0, is_variant = 0, bandwidth = 0;
int64_t duration = 0;
enum KeyType key_type = KEY_NONE;
uint8_t iv[16] = "";
int has_iv = 0;
char key[MAX_URL_SIZE] = "";
char line[1024];
const char *ptr;
int close_in = 0;
uint8_t *new_url = NULL;
if (!in) {
close_in = 1;
if ((ret = avio_open2(&in, url, AVIO_FLAG_READ,
c->interrupt_callback, NULL)) < 0)
return ret;
}
if (av_opt_get(in, "location", AV_OPT_SEARCH_CHILDREN, &new_url) >= 0)
url = new_url;
read_chomp_line(in, line, sizeof(line));
if (strcmp(line, "#EXTM3U")) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
if (var) {
free_segment_list(var);
var->finished = 0;
}
while (!in->eof_reached) {
read_chomp_line(in, line, sizeof(line));
if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) {
struct variant_info info = {{0}};
is_variant = 1;
ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_variant_args,
&info);
bandwidth = atoi(info.bandwidth);
} else if (av_strstart(line, "#EXT-X-KEY:", &ptr)) {
struct key_info info = {{0}};
ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_key_args,
&info);
key_type = KEY_NONE;
has_iv = 0;
if (!strcmp(info.method, "AES-128"))
key_type = KEY_AES_128;
if (!strncmp(info.iv, "0x", 2) || !strncmp(info.iv, "0X", 2)) {
ff_hex_to_data(iv, info.iv + 2);
has_iv = 1;
}
av_strlcpy(key, info.uri, sizeof(key));
} else if (av_strstart(line, "#EXT-X-TARGETDURATION:", &ptr)) {
if (!var) {
var = new_variant(c, 0, url, NULL);
if (!var) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
var->target_duration = atoi(ptr) * AV_TIME_BASE;
} else if (av_strstart(line, "#EXT-X-MEDIA-SEQUENCE:", &ptr)) {
if (!var) {
var = new_variant(c, 0, url, NULL);
if (!var) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
var->start_seq_no = atoi(ptr);
} else if (av_strstart(line, "#EXT-X-ENDLIST", &ptr)) {
if (var)
var->finished = 1;
} else if (av_strstart(line, "#EXTINF:", &ptr)) {
is_segment = 1;
duration = atof(ptr) * AV_TIME_BASE;
} else if (av_strstart(line, "#", NULL)) {
continue;
} else if (line[0]) {
if (is_variant) {
if (!new_variant(c, bandwidth, line, url)) {
ret = AVERROR(ENOMEM);
goto fail;
}
is_variant = 0;
bandwidth = 0;
}
if (is_segment) {
struct segment *seg;
if (!var) {
var = new_variant(c, 0, url, NULL);
if (!var) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
seg = av_malloc(sizeof(struct segment));
if (!seg) {
ret = AVERROR(ENOMEM);
goto fail;
}
seg->duration = duration;
seg->key_type = key_type;
if (has_iv) {
memcpy(seg->iv, iv, sizeof(iv));
} else {
int seq = var->start_seq_no + var->n_segments;
memset(seg->iv, 0, sizeof(seg->iv));
AV_WB32(seg->iv + 12, seq);
}
ff_make_absolute_url(seg->key, sizeof(seg->key), url, key);
ff_make_absolute_url(seg->url, sizeof(seg->url), url, line);
dynarray_add(&var->segments, &var->n_segments, seg);
is_segment = 0;
}
}
}
if (var)
var->last_load_time = av_gettime_relative();
fail:
av_free(new_url);
if (close_in)
avio_close(in);
return ret;
}
| 1threat |
static void coroutine_fn wait_for_overlapping_requests(BlockDriverState *bs,
int64_t sector_num, int nb_sectors)
{
BdrvTrackedRequest *req;
int64_t cluster_sector_num;
int cluster_nb_sectors;
bool retry;
/* If we touch the same cluster it counts as an overlap. This guarantees
* that allocating writes will be serialized and not race with each other
* for the same cluster. For example, in copy-on-read it ensures that the
* CoR read and write operations are atomic and guest writes cannot
* interleave between them.
round_to_clusters(bs, sector_num, nb_sectors,
&cluster_sector_num, &cluster_nb_sectors);
do {
retry = false;
QLIST_FOREACH(req, &bs->tracked_requests, list) {
if (tracked_request_overlaps(req, cluster_sector_num,
cluster_nb_sectors)) {
qemu_co_queue_wait(&req->wait_queue);
retry = true;
break;
}
}
} while (retry);
} | 1threat |
void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)
{
FrameThreadContext *fctx = avctx->internal->thread_ctx;
const AVCodec *codec = avctx->codec;
int i;
park_frame_worker_threads(fctx, thread_count);
if (fctx->prev_thread && fctx->prev_thread != fctx->threads)
if (update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0) < 0) {
av_log(avctx, AV_LOG_ERROR, "Final thread update failed\n");
fctx->prev_thread->avctx->internal->is_copy = fctx->threads->avctx->internal->is_copy;
fctx->threads->avctx->internal->is_copy = 1;
}
fctx->die = 1;
for (i = 0; i < thread_count; i++) {
PerThreadContext *p = &fctx->threads[i];
pthread_mutex_lock(&p->mutex);
pthread_cond_signal(&p->input_cond);
pthread_mutex_unlock(&p->mutex);
if (p->thread_init)
pthread_join(p->thread, NULL);
p->thread_init=0;
if (codec->close)
codec->close(p->avctx);
release_delayed_buffers(p);
av_frame_free(&p->frame);
}
for (i = 0; i < thread_count; i++) {
PerThreadContext *p = &fctx->threads[i];
pthread_mutex_destroy(&p->mutex);
pthread_mutex_destroy(&p->progress_mutex);
pthread_cond_destroy(&p->input_cond);
pthread_cond_destroy(&p->progress_cond);
pthread_cond_destroy(&p->output_cond);
av_packet_unref(&p->avpkt);
av_freep(&p->released_buffers);
if (i) {
av_freep(&p->avctx->priv_data);
av_freep(&p->avctx->slice_offset);
}
av_freep(&p->avctx->internal);
av_freep(&p->avctx);
}
av_freep(&fctx->threads);
pthread_mutex_destroy(&fctx->buffer_mutex);
av_freep(&avctx->internal->thread_ctx);
if (avctx->priv_data && avctx->codec && avctx->codec->priv_class)
av_opt_free(avctx->priv_data);
avctx->codec = NULL;
}
| 1threat |
Imagemagick convert command: set delay time for the last frame : <p>I have some .png files named '_tmp*.png' and I want to convert them into a gif file by the convert command with imagemagick. So i could use</p>
<pre><code>convert -delay 20 _tmp*.png result.gif
</code></pre>
<p>However I want the last frame to hold for a while on screen so that one can see the ending of the animation more clearly. Say, I want the last frame to last for 3 seconds while keeping the delay time for the other frames not changed. I studied the document for the convert command but it seems it does not have such a choice. </p>
<p>So how can I do this with the convert command? </p>
| 0debug |
Select radio button from external URL : <p>How do you select a radio button using external link such as <strong>/page.html#item1</strong> or <strong>/page.html?item1</strong> so that when the page loads it's already selected</p>
<pre><code><input type="radio" name="price" id="item-1">
<input type="radio" name="price" id="item-2">
<input type="radio" name="price" id="item-3">
</code></pre>
<p>Any method will do, javascript or jquery</p>
| 0debug |
static const uint8_t *pcx_rle_decode(const uint8_t *src, uint8_t *dst,
unsigned int bytes_per_scanline,
int compressed)
{
unsigned int i = 0;
unsigned char run, value;
if (compressed) {
while (i < bytes_per_scanline) {
run = 1;
value = *src++;
if (value >= 0xc0) {
run = value & 0x3f;
value = *src++;
}
while (i < bytes_per_scanline && run--)
dst[i++] = value;
}
} else {
memcpy(dst, src, bytes_per_scanline);
src += bytes_per_scanline;
}
return src;
}
| 1threat |
What is the difference between NDK and SDK : <p>I want to know the difference between Software Development Kit (SDK) and Native Development Kit(NDK) in android.</p>
| 0debug |
static void pc_dimm_unplug_request(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
HotplugHandlerClass *hhc;
Error *local_err = NULL;
PCMachineState *pcms = PC_MACHINE(hotplug_dev);
if (!pcms->acpi_dev) {
error_setg(&local_err,
"memory hotplug is not enabled: missing acpi device");
goto out;
}
if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
error_setg(&local_err,
"nvdimm device hot unplug is not supported yet.");
goto out;
}
hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev);
hhc->unplug_request(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);
out:
error_propagate(errp, local_err);
}
| 1threat |
Store serialized arrays or individual columns? : <p>I'm in need of advice. I have a large table that a user will fill out (roughly 150+ fields), many of which are (bool) check boxes, and a few text inputs. I know that if I store the tables as serialized arrays, it would dramatically affect searching and exporting the database into another usable format (like a .csv).</p>
<p>Would I be better off storing each field individually and creating a massive table, store it serialized anyway, or is there some other way to achieve this with a happy middle?</p>
| 0debug |
jQuery add html content in hidden div : <p>When I use jQuery selectors for add dynamically generated html in hidden div, they don't work. How to add something in hidden div with jquery?
I need to make div hidden while adding content after ajax query, because I should generate many html blocks and add them on page, I want to add all blocks in hidden div and then show all content (make div visible).</p>
| 0debug |
static inline int get_phys_addr(CPUState *env, uint32_t address,
int access_type, int is_user,
uint32_t *phys_ptr, int *prot)
{
if (address < 0x02000000)
address += env->cp15.c13_fcse;
if ((env->cp15.c1_sys & 1) == 0) {
*phys_ptr = address;
*prot = PAGE_READ | PAGE_WRITE;
return 0;
} else if (arm_feature(env, ARM_FEATURE_MPU)) {
return get_phys_addr_mpu(env, address, access_type, is_user, phys_ptr,
prot);
} else if (env->cp15.c1_sys & (1 << 23)) {
return get_phys_addr_v6(env, address, access_type, is_user, phys_ptr,
prot);
} else {
return get_phys_addr_v5(env, address, access_type, is_user, phys_ptr,
prot);
}
}
| 1threat |
static void GCC_FMT_ATTR(3, 4) parse_error(JSONParserContext *ctxt,
QObject *token, const char *msg, ...)
{
va_list ap;
char message[1024];
va_start(ap, msg);
vsnprintf(message, sizeof(message), msg, ap);
va_end(ap);
if (ctxt->err) {
error_free(ctxt->err);
ctxt->err = NULL;
}
error_setg(&ctxt->err, "JSON parse error, %s", message);
}
| 1threat |
don't correct out put in C# : <p>example I enter 1357 and program out 106 instead of 10</p>
<pre><code> string num = Console.ReadLine();
Console.Write(Convert.ToInt32(num[1]) + Convert.ToInt32(num[3]));
Console.ReadKey();
</code></pre>
| 0debug |
Write char pointer to a file, read file and check size? : <p>I'm trying to read a char pointer to a file, then check the size of that file. The file SHOULD be 256 bytes if I'm doing this correctly. I want to create a file that has the char* array fwrite into it, then check that file to see it's size and print out it's size in bytes. My code is down below.</p>
<p>ALSO, i should be writing chars into the peep, NOT INTEGERS, but I'm not sure how to do that.</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
double price;
char title[60];
} game;
void main(){
FILE* fp = fopen("file.txt","w+"); //file.txt will be blockchain text file.
char* peep = malloc(256);
for(int i = 0; i<256;i++){ // Populate array with 256 2's.
peep[i] = 2; //THIS SHOULD BE CHARACTERS, ONE CHARACTER PER INDEX
}
for (int i = 0; i < 256 ;i++){ //Print array to verify if has 256 2 char.
printf("%d %d\n",peep[i],i);
}
int j = sizeof(peep)/sizeof(peep[0]); //amount of elements in array.
fwrite(peep,sizeof(peep[0]),sizeof(peep)/sizeof(peep[0]),fp); //Writes 256 chars to the array, all of the peep.
long fsize = 0; //Size of the file after writing
if (fp != NULL){
fseek(fp,0,SEEK_END);
fsize = ftell(fp);
}
if (fsize != 256){
printf("\nPEEP NOT FULL,size is %ld",fsize);
}
// fseek(fp,0,SEEK_SET); //Go back to start of file, since we were at the end.
}
</code></pre>
| 0debug |
How to list tables affected by cascading delete : <p>I'm trying to perform a cascading delete on 15+ tables but I'm not certain that all of the requisite foreign keys have been configured properly. I would like to check for missing constraints without manually reviewing each constraint.</p>
<p>Is there a way to obtain a list of tables that will be affected by a cascading delete query?</p>
| 0debug |
Big O for an algorithm for finding prime numbers : <p>I have a pseudo code from university:</p>
<pre><code>(0) initialize logic array prim[ n ]
(1) prim[ 1 ] = false
(2) for i = 2 to n do
(3) for k = 2 to i − 1 do
(4) if i % k == 0 then
(5) break
(6) prim[i] = (k == i) // Was loop (3) fully executed?
(7) return prim[]
</code></pre>
<p>Now I have to calculate the Big O for this pseudo code.</p>
<p>We learnt to make it step by step, by adding up the number of operations.</p>
<p>This is what I got so far:</p>
<p>Comparisons:</p>
<pre><code>(4): (n-1)(n-2) outer loop * inner loop
(6): (n-1) outer loop
(4) + (6): n^2 - 2 n + 1 operations for all comparisons
</code></pre>
<p>Assignments:</p>
<pre><code>(1): 1
(6): (n - 1)
(1) + (6): n operations for all assignments
</code></pre>
<p>Division:</p>
<pre><code>(4): (n-1)(n-2) outer loop * inner loop
n^2 - 3 n + 2 operations for the division.
</code></pre>
<p>So if you add up those numbers:</p>
<pre><code>(n^2 - 2 n + 1) + n + n^2 - 3 n + 2 = 2n^2 - 4 n + 3
</code></pre>
<p>I think there is somewhere a misconception from my side, because the Big O should be O(n^2) but here it is O(2n^2) from what I understand.</p>
<p>Can you guys please help me figuring out, what my misconception is. Thanks</p>
| 0debug |
static void qemu_rbd_complete_aio(RADOSCB *rcb)
{
RBDAIOCB *acb = rcb->acb;
int64_t r;
r = rcb->ret;
if (acb->cmd != RBD_AIO_READ) {
if (r < 0) {
acb->ret = r;
acb->error = 1;
} else if (!acb->error) {
acb->ret = rcb->size;
}
} else {
if (r < 0) {
memset(rcb->buf, 0, rcb->size);
acb->ret = r;
acb->error = 1;
} else if (r < rcb->size) {
memset(rcb->buf + r, 0, rcb->size - r);
if (!acb->error) {
acb->ret = rcb->size;
}
} else if (!acb->error) {
acb->ret = r;
}
}
acb->bh = qemu_bh_new(rbd_aio_bh_cb, acb);
qemu_bh_schedule(acb->bh);
g_free(rcb);
}
| 1threat |
static int rtp_parse_mp4_au(RTPDemuxContext *s, const uint8_t *buf)
{
int au_headers_length, au_header_size, i;
GetBitContext getbitcontext;
RTPPayloadData *infos;
infos = s->rtp_payload_data;
if (infos == NULL)
return -1;
au_headers_length = AV_RB16(buf);
if (au_headers_length > RTP_MAX_PACKET_LENGTH)
return -1;
infos->au_headers_length_bytes = (au_headers_length + 7) / 8;
buf += 2;
init_get_bits(&getbitcontext, buf, infos->au_headers_length_bytes * 8);
au_header_size = infos->sizelength + infos->indexlength;
if (au_header_size <= 0 || (au_headers_length % au_header_size != 0))
return -1;
infos->nb_au_headers = au_headers_length / au_header_size;
infos->au_headers = av_malloc(sizeof(struct AUHeaders) * infos->nb_au_headers);
infos->au_headers[0].size = 0;
infos->au_headers[0].index = 0;
for (i = 0; i < infos->nb_au_headers; ++i) {
infos->au_headers[0].size += get_bits_long(&getbitcontext, infos->sizelength);
infos->au_headers[0].index = get_bits_long(&getbitcontext, infos->indexlength);
infos->nb_au_headers = 1;
return 0;
| 1threat |
Victory Check in Swing Tic Tac Toe : <p>I am trying to create a game of tic tac toe using swing however I'm having trouble with making it check for a winner. I have it set up with three classes, one for the victory check, one for the game itself, and one for each button. I don't know how to make the victory check work if someone could help It'd be very much appreciated. </p>
<p>Tic Tac Toe Class:</p>
<pre><code>import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class TicTacToe extends JFrame {
JPanel panel = new JPanel();
public static boolean gameWon = false;
public static int o = 1;
public static int x = 0;
static JFrame frame = new JFrame();
//turn counter called in the button to switch between x and o
public static int turn = 0;
public static int[] totalTurns = new int[9];
static Victory vic = new Victory();
//the brackets are creating an array
//we need nine buttons so a total of 9 slots for buttons in the array
Button[] button = new Button[9];
public static void main(String[] args) {
new TicTacToe();
vic.checkWin();
}
public TicTacToe()
{
//making it so each square is 600x600
//can be resized, maybe change that?
//make the program stop when closed
setSize(800,800);
setResizable(false);
setDefaultCloseOperation(EXIT_ON_CLOSE);
//making a 3x3 grid within the panel in a grid layout
panel.setLayout(new GridLayout(3,3) );
//creating 9 buttons within the button array
for(int i = 0; i < 9; i++)
{
//creates button
System.out.println("creating button " + i);
button[i] = new Button();
button[i].setText("");
//adds button to the panel
panel.add(button[i]);
}
add(panel);
setVisible(true);
}
}
</code></pre>
<p>Button Class:</p>
<pre><code>import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.ImageIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Button extends JButton implements ActionListener{
//The two options aside from empty
ImageIcon X,O;
public String x = "X";
public String o = "O";
public Button()
{
X = new ImageIcon(this.getClass().getResource("x.jpg"));
O = new ImageIcon(this.getClass().getResource("o.jpg"));
this.addActionListener(this);
}
public void actionPerformed(ActionEvent event)
{
switch(TicTacToe.turn)
{
case 0: //turn is 0
setIcon(X);
setText(x);
System.out.println("printing X");
TicTacToe.turn++;
System.out.println("switching turn");
removeActionListener(this);
break;
case 1: //turn is 1 and then reduces back to case 0
setIcon(O);
setText(o);
System.out.println("printing O");
TicTacToe.turn--;
System.out.println("switching turn");
removeActionListener(this);
break;
}
}
}
</code></pre>
<p>Victory Class:</p>
<pre><code>import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class Victory extends TicTacToe {
JFrame frame = new JFrame();
public static boolean gameWon = false;
public void checkWin()
{
if (button[0].getText() == button[1].getText()
&& button[1] == button[2] && button[0].getText() != "") //top row
[x][x][x]
{
System.out.println("Victory condition met: top row");
gameWon = true;
Win();
}
else if (button[3].getText() == button[4].getText()
&& button[4].getText() == button[5].getText() && button[3].getText() != "") //mid row [x][x][x]
{
System.out.println("Victory condition met: mid row");
gameWon = true;
Win();
}
else if (button[6].getText() == button[7].getText()
&& button[7].getText() == button[8].getText() && button[6].getText() != "") //bot row [x][x][x]
{
System.out.println("Victory condition met: bot row");
gameWon = true;
Win();
}
else if (button[0].getText() == button[3].getText()
&& button[3].getText() == button[6].getText() && button[0].getText() != "") //first column [x][x][x]
{
System.out.println("Victory condition met: first col");
gameWon = true;
Win();
}
else if (button[1].getText() == button[4].getText()
&& button[4].getText() == button[7].getText() && button[1].getText() != "") //second column [x][x][x]
{
System.out.println("Victory condition met: second col");
gameWon = true;
Win();
}
else if (button[2].getText() == button[5].getText()
&& button[5].getText() == button[8].getText() && button[2].getText() != "") //last column [x][x][x]
{
System.out.println("Victory condition met: last col");
gameWon = true;
Win();
}
else if (button[0].getText() == button[4].getText()
&& button[4].getText() == button[8].getText() && button[0].getText() != "") //diag 1 [x][x][x]
{
System.out.println("Victory condition met: diag 1");
gameWon = true;
Win();
}
else if (button[2].getText() == button[4].getText()
&& button[4].getText() == button[6].getText() && button[2].getText() != "") //diag 2 [x][x][x]
{
System.out.println("Victory condition met: diag 2");
gameWon = true;
Win();
}
else if (turn == 9)
{
System.out.println("Victory conditions not met");
gameWon = false;
Win();
}
}
private void Win()
{
System.out.println("Win Called");
if(button[0].getText() == "O")
{
JOptionPane.showMessageDialog(frame, "O wins!");
System.out.println("O wins");
}
if(button[0].getText() == "X")
{
JOptionPane.showMessageDialog(frame, button[0].getText() + " wins!");
System.out.println("X wins");
}
else if (turn == 9 && gameWon == false)
{
JOptionPane.showMessageDialog(null, "Tie!");
System.out.println("Tie");
}
}
}
</code></pre>
<p>I think that I should be calling the victory after TicTacToe is created in main however this results in two TicTacToe boards being created. What do i do?</p>
| 0debug |
how to itirate over Postgresql rows in python script? : I'm writing a script which takes row from DB and iterate over the rows.
In MySQL I would do:
import MySQLdb
db_mysql=MySQLdb.Connect(user=...,passwd=...,db=..., host=...)
cur = db_mysql.cursor(MySQLdb.cursors.DictCursor)
cur.execute ("""SELECT X,Y,Z FROM tab_a""")
for row in crs.fetchall () :
do things...
But I don't know how to do it in PostgreSQL as PostgreSQL doesn't have `cursors`.
Basicly this question could be how to translate the above MySQL code to work with PostgreSQL.
This is what I have so far.
import pg
pos = pg.connect(dbname=...,user=...,passwd=...,host=..., port=...)
pos.query("""SELECT X,Y,Z FROM tab_a""")
How do I iterate over this query results? | 0debug |
combining if statement with conditional statement in Python 3.x : when "if" is combined with "or", which one Python prioritise first:
for example:
if a == b or c
is it (a == b) or c or is it a == (b or c)
I assume the correct logical form should be the former one but I accidentally used:
if gender == "m' or "M"
and to my surprise it did not generate any errors and did the purpose.
| 0debug |
How to publish artifacts separately for each project in solution from VSTS CI pipeline? : <p>In my solution, I have two projects (a Asp.net MVC and a Windows Service). I want to create CI/CD pipeline to deploy web application and windows service on different VMs. But to achieve this my CI pipeline should be able to publish artifacts separately for both project and then I can feed these artifacts in CD pipeline for deployment. How artifacts for all projects can be published separately in a CI pipeline ?</p>
<p>PS: If I create two solutions each with one project only and create CI/CD pipeline separately, all works fine. But I want to achieve it with solution having multiple project as mentioned above.</p>
| 0debug |
How do you read Tensorboard files programmatically? : <p>How can you write a python script to read Tensorboard log files, extracting the loss and accuracy and other numerical data, without launching the GUI <code>tensorboard --logdir=...</code>?</p>
| 0debug |
How to reorder columns gridview asp.net : <p>I create a dynamically gridview, but I want to insert the columns according to the alphabetical order of the headers. How do I do that? Help me.</p>
| 0debug |
PHP using $_GET['id'] to display database information : <p>I'm trying to build a forum with PHP and PDO at the moment and I have a link which takes you to the page for a category with the categories ID in the URL (eg. WEBSITE/category.php?id=1). When I get there, I want to display the name of the category you are looking at using this $_GET information, but it won't seem to do it for me.
Here is what I've got:</p>
<pre><code><?php
include 'dbconfig.php';
include 'header.php';
$sql = "SELECT cat_id, cat_name, cat_description FROM categories WHERE cat_id = " . $_GET['id'];
$query = $DB_con->prepare($sql);
$query->execute();
$numRows = $query->fetchColumn();
if (!$query) {
echo 'Something went wrong whilst getting the category from the database.';
} else {
if ($numRows == 0) {
echo 'Sorry, this category does not exist';
} else {
while($catRow = $query->fetch(PDO::FETCH_ASSOC)){
echo $catRow['cat_name'];
}
}
}
include 'footer.php';
?>
</code></pre>
<p>So as you can see, I have tried to make a while loop that creates an array using PDO::FETCH_ASSOC allowing me to print category details, but when I go to the page nothing shows up except the header.php and the footer.php. There also aren't any errors that come up. Can anybody see what I'm doing wrong? Or let me know if there's information that I have left out. Thanks.</p>
| 0debug |
Is there a way to "refresh" an imported repository with Lerna? : <p>I am involved in a project with two separate repositories that we will soon be combining into a monorepo. Lerna's <code>import</code> command will be very helpful in this regard, so we will keep the projects' histories.</p>
<p>However, there are currently some in-progress feature branches in the original repositories that likely won't be ready when we move to the monorepo. It's my understanding that <code>lerna import</code> will only pull in the currently checked out branch from the source repo - is that correct?</p>
<p>So I was wondering if there was a way to do the import again, but only pull in commits that have been made since the last import?</p>
<p>That way, the teams working on the feature branches can merge to the <code>develop</code> branch once they're ready and we can bring that over into the monorepo.</p>
<p>Alternatively, are there strategies out there for dealing with this scenario?</p>
<p>Or am I going to have to wait until everything is merged to <code>develop</code> before doing the <code>lerna import</code>?</p>
<p>Thanks!</p>
| 0debug |
push item to div from list of item div : <p>I have a question. I have for example list of div, i just want all these dives should be clickable. And after click on div, value from div should be pushed to on an other div. How I can do it in a best way?</p>
<pre><code> <?php
define('HOST','xxxx');
define('USER','xxx');
define('PASS','xxxx');
define('DB','xxxxx');
$con = mysqli_connect(HOST,USER,PASS,DB);
$sql = "select * from users";
$res = mysqli_query($con,$sql);
$result = array();
while($row = mysqli_fetch_array($res)){
array_push($result,
array(
'email'=>$row[3],
));
}
echo json_encode(array("result"=>$result));
mysqli_close($con);
?>
<html>
<head>
<style>
#usersOnLine {
font-family:tahoma;
font-size:12px;
color:black;
border: 3px teal solid;
height: 525px;
width: 250px;
float: right;
overflow-y:scroll;
}
.container{
width:970px;
height:auto;
margin:0 auto;
}
</style>
</head>
<body>
<div class="container">
<div id="reciver"><h3>reciver</h3></div>
<div id="sender"><h3>sender</h3></div>
<h2 align="right"> all contacts </h2>
<div id="usersOnLine">
<?php
foreach($result as $key => $val)
{
echo $val['email'];
echo "<br>";
}
?>
</div>
</div>
</body>
</html>
</code></pre>
<p>here is useronline div in which many name are i want when i click on any name name push to reciver div how to made it i am new in php</p>
| 0debug |
Sql manipulation : I have two columns LocationCity and LocationCountry. I need to concatenate into a single column.
what i have now is :
select LocationCity,LocationCountry from Location
output: Hitchin,England United Kingdom
expected out is :
Hitchin, England, UK
how to achieve? | 0debug |
static void *clone_func(void *arg)
{
new_thread_info *info = arg;
CPUArchState *env;
CPUState *cpu;
TaskState *ts;
rcu_register_thread();
env = info->env;
cpu = ENV_GET_CPU(env);
thread_cpu = cpu;
ts = (TaskState *)cpu->opaque;
info->tid = gettid();
cpu->host_tid = info->tid;
task_settid(ts);
if (info->child_tidptr)
put_user_u32(info->tid, info->child_tidptr);
if (info->parent_tidptr)
put_user_u32(info->tid, info->parent_tidptr);
sigprocmask(SIG_SETMASK, &info->sigmask, NULL);
pthread_mutex_lock(&info->mutex);
pthread_cond_broadcast(&info->cond);
pthread_mutex_unlock(&info->mutex);
pthread_mutex_lock(&clone_lock);
pthread_mutex_unlock(&clone_lock);
cpu_loop(env);
return NULL;
}
| 1threat |
check only direct childs when parent checkbox is checked : I want to check only child checkbox which does not have subchilds, when parent is checked.
I have created jsfiddle below, in which if we Check A1 only a2 should be checked. All other operation should be same.
$(function() {
$('li :checkbox').on('click', function() {
var $chk = $(this),
$li = $chk.closest('li'),
$ul, $parent;
if ($li.has('ul')) {
$li.find(':checkbox').not(this).prop('checked', this.checked)
}
do {
$ul = $li.parent();
console.log($ul)
$parent = $ul.siblings(':checkbox');
if ($chk.is(':checked')) {
$parent.prop('checked', $ul.has(':checkbox:not(:checked)').length == 0)
} else {
$parent.prop('checked', false)
}
if($ul.get(0))
if($ul.find(':checkbox:checked').length !== 0)
$parent.prop('checked', true)
$chk = $parent;
$li = $chk.closest('li');
} while ($ul.is(':not(.someclass)'));
});
});
[JsFiddle][1]
[1]: https://jsfiddle.net/nq4Ldr5c/ | 0debug |
static int remove_decoded_packets(AVFormatContext *ctx, int64_t scr){
int i;
for(i=0; i<ctx->nb_streams; i++){
AVStream *st = ctx->streams[i];
StreamInfo *stream = st->priv_data;
PacketDesc *pkt_desc;
while((pkt_desc= stream->predecode_packet)
&& scr > pkt_desc->dts){
if(stream->buffer_index < pkt_desc->size ||
stream->predecode_packet == stream->premux_packet){
av_log(ctx, AV_LOG_ERROR,
"buffer underflow i=%d bufi=%d size=%d\n",
i, stream->buffer_index, pkt_desc->size);
break;
}
stream->buffer_index -= pkt_desc->size;
stream->predecode_packet= pkt_desc->next;
av_freep(&pkt_desc);
}
}
return 0;
}
| 1threat |
void bdrv_dirty_bitmap_serialize_part(const BdrvDirtyBitmap *bitmap,
uint8_t *buf, uint64_t start,
uint64_t count)
{
hbitmap_serialize_part(bitmap->bitmap, buf, start, count);
}
| 1threat |
static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs)
{
BDRVSheepdogState *s = bs->opaque;
SheepdogAIOCB *acb;
AIOReq *aio_req;
if (s->cache_flags != SD_FLAG_CMD_CACHE) {
return 0;
}
acb = sd_aio_setup(bs, NULL, 0, 0);
acb->aiocb_type = AIOCB_FLUSH_CACHE;
acb->aio_done_func = sd_finish_aiocb;
aio_req = alloc_aio_req(s, acb, vid_to_vdi_oid(s->inode.vdi_id),
0, 0, 0, 0, 0);
QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings);
add_aio_request(s, aio_req, NULL, 0, false, acb->aiocb_type);
qemu_coroutine_yield();
return acb->ret;
}
| 1threat |
Importing image to python :cannot import name 'imread' : <p>I'm new to python and I want to import an image. </p>
<pre><code>import numpy as np
from scipy.misc import imread, imsave, imresize
# Read an JPEG image into a numpy array
img = imread('Cover.jpg')
print(img.dtype, img.shape)
</code></pre>
<p>but I face with following error: <code>cannot import name 'imread'</code>
I've already successfully installed numpy and scipy.</p>
| 0debug |
static int ivf_write_trailer(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
if (pb->seekable) {
IVFEncContext *ctx = s->priv_data;
size_t end = avio_tell(pb);
avio_seek(pb, 24, SEEK_SET);
avio_wl64(pb, ctx->frame_cnt * ctx->sum_delta_pts / (ctx->frame_cnt - 1));
avio_seek(pb, end, SEEK_SET);
}
return 0;
}
| 1threat |
static void do_stop_capture(Monitor *mon, const QDict *qdict)
{
int i;
int n = qdict_get_int(qdict, "n");
CaptureState *s;
for (s = capture_head.lh_first, i = 0; s; s = s->entries.le_next, ++i) {
if (i == n) {
s->ops.destroy (s->opaque);
LIST_REMOVE (s, entries);
qemu_free (s);
return;
}
}
}
| 1threat |
PHP search Using multiple Criteria submitted from a form. : $query = "SELECT * FROM student WHERE idStudent = ? AND Student_Fname = ? AND Student_Sname = ? AND Program_idProgram = ? AND Class_idClass = ?";
$stmt = mysqli_prepare($dbc, $query);
mysqli_stmt_bind_param($stmt, 'sssss', $idStudent,
$Student_Fname, $Student_Sname, $Program_idProgram, $Class_idClass);
mysqli_stmt_execute($stmt);
$result = @mysqli_query($dbc, $query);
if($result){ // display results here} | 0debug |
SocketAddressLegacy *socket_local_address(int fd, Error **errp)
{
struct sockaddr_storage ss;
socklen_t sslen = sizeof(ss);
if (getsockname(fd, (struct sockaddr *)&ss, &sslen) < 0) {
error_setg_errno(errp, errno, "%s",
"Unable to query local socket address");
return NULL;
}
return socket_sockaddr_to_address(&ss, sslen, errp);
}
| 1threat |
thread does not work, it's freezing my application : <p>I have a function with several loopings and database query, I want to call it asynchronously by passing a progress bar to show the user the progress.</p>
<p>When I call the thread the program hangs I can not even close</p>
<p>when I call synchContext.Post (state => etlBusiness.LoadData (progressBar), null); it freezes, it is not feasible to bring the logic of loadData to UI there are many methods being called the inside</p>
<pre><code> public partial class Home : Form
{
public Home()
{
InitializeComponent();
synchronizationContext = System.Threading.SynchronizationContext.Current;
}
private SynchronizationContext synchronizationContext;
public SynchronizationContext context = SynchronizationContext.Current;
public Thread _myThread = null;
private void btnSend_Click(object sender, EventArgs e)
{
_myThread = new Thread(() => LoadData(synchronizationContext, progressBar1));
_myThread.Start();
}
private void LoadData(System.Threading.SynchronizationContext synchContext, ProgressBar progressBar)
{
string filePath = tbPath.Text;
ETLBusiness etlBusiness = new ETLBusiness(filePath);
synchContext.Post(state => etlBusiness.LoadData(progressBar), null);
_myThread.Abort();
}
}
</code></pre>
| 0debug |
int ff_adts_write_frame_header(ADTSContext *ctx,
uint8_t *buf, int size, int pce_size)
{
PutBitContext pb;
init_put_bits(&pb, buf, ADTS_HEADER_SIZE);
put_bits(&pb, 12, 0xfff);
put_bits(&pb, 1, 0);
put_bits(&pb, 2, 0);
put_bits(&pb, 1, 1);
put_bits(&pb, 2, ctx->objecttype);
put_bits(&pb, 4, ctx->sample_rate_index);
put_bits(&pb, 1, 0);
put_bits(&pb, 3, ctx->channel_conf);
put_bits(&pb, 1, 0);
put_bits(&pb, 1, 0);
put_bits(&pb, 1, 0);
put_bits(&pb, 1, 0);
put_bits(&pb, 13, ADTS_HEADER_SIZE + size + pce_size);
put_bits(&pb, 11, 0x7ff);
put_bits(&pb, 2, 0);
flush_put_bits(&pb);
return 0;
}
| 1threat |
How to separate data in row . : I have a table in MY Sql DB, having two column PageId and Datavalue . In Datavalue column contain comma separated data. I want to data in row wise. Please help | 0debug |
converting string array to int array for sql statement c# : In my model i have:
public List<uint> Ids {get; set;}
I am executing sql in my get call and the format for the Ids are not in proper format for the sql statment to successfully execute.
db.tableName.FromSql("SELECT * FROM tableName where( id in ({0}) && itemId = {1}), x.Ids, x.ItemId);
currently my x.ids looks like this: [0]: 100 [1]: 101
i want for my x.ids to look like 100, 101 so that in my where clause they will look like...`id in (100, 101)`..
I have tried: `var temp = string.Join(', ', x.Ids); //result: "100, 101"` but this is a string array and i want int array for the sql to work.
x is being passed in my method.
Is there a simple way to make this conversion or do i have to loop through the string array and convert and push into int array?
| 0debug |
static int setup_common(char *argv[], int argv_sz)
{
memset(cur_ide, 0, sizeof(cur_ide));
return append_arg(0, argv, argv_sz,
g_strdup("-nodefaults -display none"));
}
| 1threat |
How to Format Date C# : <p>I have datetime value="11/03/2018 12:00:00 ص" I want to format this to be
"11-03-2018" how to make this, and i want this value to be datetime,
I tried using DateTime.Parse and ParseExact, but with errors</p>
<p>thanks</p>
| 0debug |
Java script and full-stack JavaScript difference? : <p>What is difference between JavaScript and full-stack JavaScript.</p>
<p>Both are same or not.</p>
| 0debug |
How to execute javascript functions in client-side in browsers with Node-JS? : <p>I'm trying to execute javascript code in <strong>client-side</strong> using node-JS, precisely I want to execute an <strong>alert</strong> when the user or the password is wrong to log to the website. Executing javascript in client code could even animate my website. How do I do that? </p>
<p>I tried to use npm alert-node, also npm js-alert, and npm popups, but those modules didn't work (no one mentioned). Really I think that those modules are not necessary if I just want to create an alert with a message "Error to log, try again". </p>
<p>If possible, can you give me a tutorial that explain <strong>how to execute javascript in client-side in node js?</strong> I use <strong>express</strong> with <strong>EJS</strong> and <strong>bootstrap</strong>. thanks. </p>
| 0debug |
can any one explain this example step by step its abot getting prime numbers :
> function to show primes
function showPrimes(n) {
for (let i = 2; i < n; i++) {
if (!isPrime(i)) continue;
alert(i); // a prime
}
}
> function to check prime
function isPrime(n) {
for (let i = 2; i < n; i++) {
if ( n % i == 0) return false;
}
return true;
}
> trigger to run the function and put the value of (n)
showPrimes(10);
| 0debug |
static void lm32_evr_init(QEMUMachineInitArgs *args)
{
const char *cpu_model = args->cpu_model;
const char *kernel_filename = args->kernel_filename;
LM32CPU *cpu;
CPULM32State *env;
DriveInfo *dinfo;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
qemu_irq *cpu_irq, irq[32];
ResetInfo *reset_info;
int i;
hwaddr flash_base = 0x04000000;
size_t flash_sector_size = 256 * 1024;
size_t flash_size = 32 * 1024 * 1024;
hwaddr ram_base = 0x08000000;
size_t ram_size = 64 * 1024 * 1024;
hwaddr timer0_base = 0x80002000;
hwaddr uart0_base = 0x80006000;
hwaddr timer1_base = 0x8000a000;
int uart0_irq = 0;
int timer0_irq = 1;
int timer1_irq = 3;
reset_info = g_malloc0(sizeof(ResetInfo));
if (cpu_model == NULL) {
cpu_model = "lm32-full";
cpu = cpu_lm32_init(cpu_model);
env = &cpu->env;
reset_info->cpu = cpu;
reset_info->flash_base = flash_base;
memory_region_init_ram(phys_ram, NULL, "lm32_evr.sdram", ram_size);
vmstate_register_ram_global(phys_ram);
memory_region_add_subregion(address_space_mem, ram_base, phys_ram);
dinfo = drive_get(IF_PFLASH, 0, 0);
pflash_cfi02_register(flash_base, NULL, "lm32_evr.flash", flash_size,
dinfo ? dinfo->bdrv : NULL, flash_sector_size,
flash_size / flash_sector_size, 1, 2,
0x01, 0x7e, 0x43, 0x00, 0x555, 0x2aa, 1);
cpu_irq = qemu_allocate_irqs(cpu_irq_handler, cpu, 1);
env->pic_state = lm32_pic_init(*cpu_irq);
for (i = 0; i < 32; i++) {
irq[i] = qdev_get_gpio_in(env->pic_state, i);
sysbus_create_simple("lm32-uart", uart0_base, irq[uart0_irq]);
sysbus_create_simple("lm32-timer", timer0_base, irq[timer0_irq]);
sysbus_create_simple("lm32-timer", timer1_base, irq[timer1_irq]);
env->juart_state = lm32_juart_init();
reset_info->bootstrap_pc = flash_base;
if (kernel_filename) {
uint64_t entry;
int kernel_size;
kernel_size = load_elf(kernel_filename, NULL, NULL, &entry, NULL, NULL,
1, ELF_MACHINE, 0);
reset_info->bootstrap_pc = entry;
if (kernel_size < 0) {
kernel_size = load_image_targphys(kernel_filename, ram_base,
ram_size);
reset_info->bootstrap_pc = ram_base;
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);
qemu_register_reset(main_cpu_reset, reset_info); | 1threat |
static void IRQ_local_pipe (openpic_t *opp, int n_CPU, int n_IRQ)
{
IRQ_dst_t *dst;
IRQ_src_t *src;
int priority;
dst = &opp->dst[n_CPU];
src = &opp->src[n_IRQ];
priority = IPVP_PRIORITY(src->ipvp);
if (priority <= dst->pctp) {
DPRINTF("%s: IRQ %d has too low priority on CPU %d\n",
__func__, n_IRQ, n_CPU);
return;
}
if (IRQ_testbit(&dst->raised, n_IRQ)) {
DPRINTF("%s: IRQ %d was missed on CPU %d\n",
__func__, n_IRQ, n_CPU);
return;
}
set_bit(&src->ipvp, IPVP_ACTIVITY);
IRQ_setbit(&dst->raised, n_IRQ);
if (priority < dst->raised.priority) {
DPRINTF("%s: IRQ %d is hidden by raised IRQ %d on CPU %d\n",
__func__, n_IRQ, dst->raised.next, n_CPU);
return;
}
IRQ_get_next(opp, &dst->raised);
if (IRQ_get_next(opp, &dst->servicing) != -1 &&
priority <= dst->servicing.priority) {
DPRINTF("%s: IRQ %d is hidden by servicing IRQ %d on CPU %d\n",
__func__, n_IRQ, dst->servicing.next, n_CPU);
return;
}
DPRINTF("Raise OpenPIC INT output cpu %d irq %d\n", n_CPU, n_IRQ);
opp->irq_raise(opp, n_CPU, src);
}
| 1threat |
CSS - how to target only one element with desired class in div? : <div class="menu">
<ul>
<li>
<ul class="sub-menu">
<li>
<ul class="sub-menu">
<li></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
Could You please tell me how to target just first ul element with "sub-menu" class as on an example above? Every pseudo-class I know targets both "sub-menu" ul-s at the same time. | 0debug |
Regex find the caracter ";" between quote : I'm trying to make a regex that find a ";" caracter between two quote ("). The corresponding regex that I found is the following :
;(?=[^"]*"[^"]*(?:"[^"]*"[^"]*)*$)
Here is an exemple : https://regexr.com/40lhm
The problem is that this corresponding regex is not working when a simple quote (") is found in the string. When such a case happend, it's actually returning the whole sequence of ";".
Exemple of the problem : https://regexr.com/40n3c
Any help would be much appreciated !
Thanks
| 0debug |
void ff_h264_free_tables(H264Context *h, int free_rbsp)
{
int i;
av_freep(&h->intra4x4_pred_mode);
av_freep(&h->chroma_pred_mode_table);
av_freep(&h->cbp_table);
av_freep(&h->mvd_table[0]);
av_freep(&h->mvd_table[1]);
av_freep(&h->direct_table);
av_freep(&h->non_zero_count);
av_freep(&h->slice_table_base);
h->slice_table = NULL;
av_freep(&h->list_counts);
av_freep(&h->mb2b_xy);
av_freep(&h->mb2br_xy);
av_buffer_pool_uninit(&h->qscale_table_pool);
av_buffer_pool_uninit(&h->mb_type_pool);
av_buffer_pool_uninit(&h->motion_val_pool);
av_buffer_pool_uninit(&h->ref_index_pool);
if (free_rbsp && h->DPB) {
for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
ff_h264_unref_picture(h, &h->DPB[i]);
av_freep(&h->DPB);
}
h->cur_pic_ptr = NULL;
for (i = 0; i < h->nb_slice_ctx; i++) {
H264SliceContext *sl = &h->slice_ctx[i];
av_freep(&sl->dc_val_base);
av_freep(&sl->er.mb_index2xy);
av_freep(&sl->er.error_status_table);
av_freep(&sl->er.er_temp_buffer);
av_freep(&sl->bipred_scratchpad);
av_freep(&sl->edge_emu_buffer);
av_freep(&sl->top_borders[0]);
av_freep(&sl->top_borders[1]);
sl->bipred_scratchpad_allocated = 0;
sl->edge_emu_buffer_allocated = 0;
sl->top_borders_allocated[0] = 0;
sl->top_borders_allocated[1] = 0;
if (free_rbsp) {
av_freep(&sl->rbsp_buffer);
sl->rbsp_buffer_size = 0;
}
}
}
| 1threat |
C++ large multidimensional-arrays on stack : <p>My simulation tries to predict the demand on a system for a long period of time ... the output results in a very large 4D array (I use the 4 dimensions to minimise the chance of an error when the data is written to the array i.e. I can understand it better this way!).</p>
<p>The array size will be 25x4x3x20000 and I need it to be at least an (unsigned int) but I know that the stack can't handle this amount of data. </p>
<pre><code>unsigned int ar[25][4][3][2000];
</code></pre>
<p>I have been looking around and found different solutions. However I am still undecided on which one to implement. So my question is: which one is better in term of performance and good practice:</p>
<ol>
<li><strong>Use a vector of arrays:</strong> as described in <a href="https://stackoverflow.com/questions/18991765/vector-of-vectors-reserve">stackoverflow.com/questions/18991765</a> ... But then any idea on how to convert for a 4D dimensions? </li>
</ol>
<blockquote>
<p><code>std::vector< std::array<int, 5> > vecs;
vecs.reserve(N);</code></p>
</blockquote>
<ol start="2">
<li><strong>Use a 4D vector and push_back()</strong>: I didn't use this because I know the final size of the array and I wanted to prevent many push_backs operations. </li>
<li><strong>Create the array on the heap</strong>: as described in
<a href="https://stackoverflow.com/questions/675817/how-do-i-create-an-array-in-c-which-is-on-the-heap-instead-of-the-stack">stackoverflow.com/questions/675817</a></li>
</ol>
<p>Any other suggestion is appreciated!</p>
| 0debug |
db.execute('SELECT * FROM products WHERE product_id = ' + product_input) | 1threat |
How to shutdown jshell at the end of the script? : <p>How to instruct <code>jshell</code> to terminate at the end of the script similarly to interpreters of other languages like for example <code>python3</code> or <code>node</code>?</p>
<p>Following command</p>
<pre><code>./jshell -q /tmp/shell.java
</code></pre>
<p>with script <code>/tmp/shell.java</code></p>
<pre class="lang-java prettyprint-override"><code>System.out.println("Hello world");
</code></pre>
<p>prints</p>
<pre class="lang-none prettyprint-override"><code>Hello world
jshell>
</code></pre>
<p>and waits for further commands. I'd like it to stop immediately at the end of the file.</p>
<p>I'm looking for something more elegant than <code>System.exit(0);</code> at the end of the script.</p>
| 0debug |
Using date pipe in a conditional expression - Angular 2 : <p>With the follow expression I'm expecting for Angular to interpolate a date (if not null) through the date pipe, but I get the proceeding error.</p>
<pre><code>{{charge.offenseDate ? charge.offenseDate | date : 'No date'}}
EXCEPTION: Error: Uncaught (in promise): Template parse errors:
Parser Error: Conditional expression {{charge.offenseDate ? charge.offenseDate | date : 'No Date' }} requires all 3 expressions at the end of the expression
</code></pre>
<p>Is what I'm expecting possible, or just a...<em>pipe dream</em> :)</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.