problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
How to create a banner in wordpress without help of plugin : <p>I am very new to WordPress, and i want to create my own custom banner in WordPress without plugin help. I tried to search many times but can't able to resolve my problem, please anyone help me..
Thanks in advance</p>
| 0debug |
MemoryRegionSection memory_region_find(MemoryRegion *mr,
hwaddr addr, uint64_t size)
{
MemoryRegionSection ret = { .mr = NULL };
MemoryRegion *root;
AddressSpace *as;
AddrRange range;
FlatView *view;
FlatRange *fr;
addr += mr->addr;
for (root = mr; root->container; ) {
root = root->container;
addr += root->addr;
}
as = memory_region_to_address_space(root);
if (!as) {
return ret;
}
range = addrrange_make(int128_make64(addr), int128_make64(size));
rcu_read_lock();
view = atomic_rcu_read(&as->current_map);
fr = flatview_lookup(view, range);
if (!fr) {
goto out;
}
while (fr > view->ranges && addrrange_intersects(fr[-1].addr, range)) {
--fr;
}
ret.mr = fr->mr;
ret.address_space = as;
range = addrrange_intersection(range, fr->addr);
ret.offset_within_region = fr->offset_in_region;
ret.offset_within_region += int128_get64(int128_sub(range.start,
fr->addr.start));
ret.size = range.size;
ret.offset_within_address_space = int128_get64(range.start);
ret.readonly = fr->readonly;
memory_region_ref(ret.mr);
out:
rcu_read_unlock();
return ret;
}
| 1threat |
Regular expression to allow space between two string? : <p>I have following pattern to validate the String</p>
<pre><code>pattern ="^[a-zA-Z0-9_{}#$\/\-\+@!?()^%$`~|:,.=\[\]]*$"
</code></pre>
<p>But here it is not accepting space between two string as well.Can someone please tell me what changes i have to do in above pattern so it will allow space between two string? But Space should not be allowed at the beginning and end of string.</p>
| 0debug |
Shortest way to find the biggest integer in a row in a list[JAVA] : I want to print the numbers so that the output is: [12,9,8,7,5,4,3,1]
The problem is, i only know how to print the biggest.
I hope you guys can help me :)
int[] array = new int[]{8,5,3,7,9,12,4,1};
int biggest = 0;
for (int i =0; i<array.length;i++){
if(array[i]>biggest){
biggest = array[i];
}
}
System.out.println(biggest); //Outputs 12 | 0debug |
Group according to its parent and children : This is the output of my List. I need help in grouping the children with their parent. Thanks for your help.
0).
nodeID id_0 |
nodeName Test 3 |
parentID id_0
********************************************
1).
nodeID id_72864 |
nodeName Element A |
parentID id_0
********************************************
2).
nodeID id_72865 |
nodeName Element B |
parentID id_0
********************************************
3).
nodeID id_72866 |
nodeName Element C |
parentID id_0
********************************************
4).
nodeID id_72867 |
nodeName Element D |
parentID id_0
********************************************
5).
nodeID id_72868 |
nodeName Element E |
parentID id_0
********************************************
6).
nodeID id_72869 |
nodeName Element 1 |
parentID id_72864
********************************************
7).
nodeID id_72870 |
nodeName Element 2 |
parentID id_72865
********************************************
8).
nodeID id_108185 |
nodeName Element |
parentID id_72865
********************************************
9).
nodeID id_72871 |
nodeName Element 3 |
parentID id_72866
********************************************
10).
nodeID id_72872 |
nodeName Element 4 |
parentID id_72867
********************************************
11).
nodeID id_73527 |
nodeName Element 5 |
parentID id_72868
********************************************* | 0debug |
I don't what this function is doing in MATLAB : I was writing a code on MATLAB where by mistake, I wrote this line:
x = rand(1:3)
And I got the following output:[![enter image description here][1]][1]
[1]: http://i.stack.imgur.com/cStB2.png
Can someone explain me what is going on here? Is it a 3D matrix? Or something else? | 0debug |
How to convert large numbers in a text file (strings) into ints and add them. : 3123123123123 759345 903470283
1839282039485028304849404 3839282039485028304849404
22 32
9888 9233
93373849503817264 38394058293045859 38394932293045859 93373849503817264
38394058293045859
90349329492349 0
94840
10000000000000000000 600000
32453 325235 32
100 0
34
0
0 0 0
This is the text file I am working with. I need to convert these into ints and add them. I haven't learned parseInt yet, so unless there's any way around it, i'd like to know how to convert these into ints and sum them in each line.
| 0debug |
How to change Browser button name? : <p>As I am new in UI development ,Kindly help to provide solution. How to change the Browser button name by using jquery.</p>
| 0debug |
Overloaded string methods with string interpolation : <p>Why does string interpolation prefer overload of method with <code>string</code> instead of <code>IFormattable</code>?</p>
<p>Imagine following:</p>
<pre><code>static class Log {
static void Debug(string message);
static void Debug(IFormattable message);
static bool IsDebugEnabled { get; }
}
</code></pre>
<p>I have objects with very expensive <code>ToString()</code>. Previously, I did following:</p>
<pre><code>if (Log.IsDebugEnabled) Log.Debug(string.Format("Message {0}", expensiveObject));
</code></pre>
<p>Now, I wanted to have the IsDebugEnabled logic inside <code>Debug(IFormattable)</code>, and call ToString() on objects in message only when necessary.</p>
<pre><code>Log.Debug($"Message {expensiveObject}");
</code></pre>
<p>This, however, calls the <code>Debug(string)</code> overload.</p>
| 0debug |
How do I link two or more files? : <p>I got a question for ya'll. how do I link these two files?<br>
I want the class in EmptyClass.cs to be usable in Program.cs.<br>
Hope that makes sense I don't know how I could explain that differently. </p>
<p><a href="https://i.stack.imgur.com/jU9i5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jU9i5.png" alt="enter image description here"></a></p>
| 0debug |
static uint64_t fw_cfg_data_mem_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
return fw_cfg_read(opaque);
}
| 1threat |
alert('Hello ' + user_input); | 1threat |
static int put_uint64_as_uint32(QEMUFile *f, void *pv, size_t size,
VMStateField *field, QJSON *vmdesc)
{
uint64_t *v = pv;
qemu_put_be32(f, *v);
return 0;
}
| 1threat |
void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
{
GtkDisplayState *s = g_malloc0(sizeof(*s));
char *filename;
gtk_init(NULL, NULL);
s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
#if GTK_CHECK_VERSION(3, 2, 0)
s->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
s->vbox = gtk_vbox_new(FALSE, 0);
#endif
s->notebook = gtk_notebook_new();
s->menu_bar = gtk_menu_bar_new();
s->free_scale = FALSE;
setlocale(LC_ALL, "");
bindtextdomain("qemu", CONFIG_QEMU_LOCALEDIR);
textdomain("qemu");
s->null_cursor = gdk_cursor_new(GDK_BLANK_CURSOR);
s->mouse_mode_notifier.notify = gd_mouse_mode_change;
qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier);
qemu_add_vm_change_state_handler(gd_change_runstate, s);
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu_logo_no_text.svg");
if (filename) {
GError *error = NULL;
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename, &error);
if (pixbuf) {
gtk_window_set_icon(GTK_WINDOW(s->window), pixbuf);
} else {
g_error_free(error);
}
g_free(filename);
}
gd_create_menus(s);
gd_connect_signals(s);
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(s->notebook), FALSE);
gtk_notebook_set_show_border(GTK_NOTEBOOK(s->notebook), FALSE);
gd_update_caption(s);
gtk_box_pack_start(GTK_BOX(s->vbox), s->menu_bar, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(s->vbox), s->notebook, TRUE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(s->window), s->vbox);
gtk_widget_show_all(s->window);
#ifdef VTE_RESIZE_HACK
{
VirtualConsole *cur = gd_vc_find_current(s);
int i;
for (i = 0; i < s->nb_vcs; i++) {
VirtualConsole *vc = &s->vc[i];
if (vc && vc->type == GD_VC_VTE && vc != cur) {
gtk_widget_hide(vc->vte.terminal);
}
}
gd_update_windowsize(cur);
}
#endif
if (full_screen) {
gtk_menu_item_activate(GTK_MENU_ITEM(s->full_screen_item));
}
if (grab_on_hover) {
gtk_menu_item_activate(GTK_MENU_ITEM(s->grab_on_hover_item));
}
gd_set_keycode_type(s);
}
| 1threat |
How to create a color with an alpha value using SwiftUI? : <p>In <code>UIKit</code> to create a color with an alpha value there are different ways, for example:</p>
<pre><code>UIColor(red: 0, green: 0, blue: 0, alpha: 0.8)
</code></pre>
<p>but this method is not available on the corresponding class <code>Color</code> of <code>SwiftUI</code>.</p>
<p>What can I use?</p>
| 0debug |
Minify HTML, but don't touch PHP with Gulp : <h2>The problem</h2>
<p>I have a lot of <em>.php</em> files, mostly containing HTML, but also some PHP lines on top (e.g. form trigger code or similar). So they look like</p>
<pre><code><?php
if($someValue){
//doSth
}
//more content
?>
<!DOCTYPE html>
<html lang="de">
<head>
<title>My Website</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<!-- Content and scripts here -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
</body>
</html>
</code></pre>
<hr>
<h2>The goal</h2>
<p>My goal is to <strong>minify</strong> the HTML (and maybe even the inline javascript, but that's just a little extra), without touching the PHP on top.
I'm using Gulp as automated build tool and would like to see a solution using this tool and any extra packages as they are needed.</p>
| 0debug |
static int print_device_sinks(AVOutputFormat *fmt, AVDictionary *opts)
{
int ret, i;
AVFormatContext *dev = NULL;
AVDeviceInfoList *device_list = NULL;
AVDictionary *tmp_opts = NULL;
if (!fmt || !fmt->priv_class || !AV_IS_OUTPUT_DEVICE(fmt->priv_class->category))
return AVERROR(EINVAL);
printf("Audo-detected sinks for %s:\n", fmt->name);
if (!fmt->get_device_list) {
ret = AVERROR(ENOSYS);
printf("Cannot list sinks. Not implemented.\n");
goto fail;
}
if ((ret = avformat_alloc_output_context2(&dev, fmt, NULL, NULL)) < 0) {
printf("Cannot open device: %s.\n", fmt->name);
goto fail;
}
av_dict_copy(&tmp_opts, opts, 0);
av_opt_set_dict2(dev, &tmp_opts, AV_OPT_SEARCH_CHILDREN);
if ((ret = avdevice_list_devices(dev, &device_list)) < 0) {
printf("Cannot list sinks.\n");
goto fail;
}
for (i = 0; i < device_list->nb_devices; i++) {
printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ",
device_list->devices[i]->device_name, device_list->devices[i]->device_description);
}
fail:
av_dict_free(&tmp_opts);
avdevice_free_list_devices(&device_list);
avformat_free_context(dev);
return ret;
}
| 1threat |
int usb_handle_packet(USBDevice *dev, USBPacket *p)
{
int ret;
if (dev == NULL) {
return USB_RET_NODEV;
}
assert(dev->addr == p->devaddr);
assert(dev->state == USB_STATE_DEFAULT);
assert(p->owner == NULL);
if (p->devep == 0) {
switch (p->pid) {
case USB_TOKEN_SETUP:
ret = do_token_setup(dev, p);
break;
case USB_TOKEN_IN:
ret = do_token_in(dev, p);
break;
case USB_TOKEN_OUT:
ret = do_token_out(dev, p);
break;
default:
ret = USB_RET_STALL;
break;
}
} else {
ret = usb_device_handle_data(dev, p);
}
if (ret == USB_RET_ASYNC) {
p->owner = usb_ep_get(dev, p->pid, p->devep);
}
return ret;
}
| 1threat |
Catch all uncaughtException for Node js app : <p>I have a question: how do I can handle all uncaught Exception (operations/developer error will take all service down) for my node app. Then I can send an email alert to me whenever catch an error.</p>
| 0debug |
static void release_unused_pictures(H264Context *h, int remove_current)
{
int i;
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
if (h->DPB[i].f.data[0] && !h->DPB[i].reference &&
(remove_current || &h->DPB[i] != h->cur_pic_ptr)) {
unref_picture(h, &h->DPB[i]);
}
}
}
| 1threat |
void acpi_pm_tmr_init(ACPIREGS *ar, acpi_update_sci_fn update_sci,
MemoryRegion *parent)
{
ar->tmr.update_sci = update_sci;
ar->tmr.timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, acpi_pm_tmr_timer, ar);
memory_region_init_io(&ar->tmr.io, memory_region_owner(parent),
&acpi_pm_tmr_ops, ar, "acpi-tmr", 4);
memory_region_clear_global_locking(&ar->tmr.io);
memory_region_add_subregion(parent, 8, &ar->tmr.io);
}
| 1threat |
Code Deploy fails without any error message : <p>so I have been trying to setup code deploy for my application, but it keeps on failing. Initially, I didn't have an appspec.yml file in repository, so I got the error message that the appspec.yml file doesn't exist.</p>
<p>I have now included an appspec.yml file, but it still doesn't work and it doesn't give any error message. There are no events mentioned, like it used to before adding the appspec file.</p>
<p>I have less than a beginner's knowledge when it comes to creating a appspec.yml file, but I took hint from a youtube tutorial, and here is the file.</p>
<pre><code>version: 0.0
os: linux
files:
- source: /
destination: /var/www/cms
</code></pre>
<p>If it helps, the ec2 instance is running an ubuntu server, /var/www/cms is that directory out of which the nginx is supposed to serve files.</p>
| 0debug |
void ide_dma_cb(void *opaque, int ret)
{
IDEState *s = opaque;
int n;
int64_t sector_num;
bool stay_active = false;
if (ret == -ECANCELED) {
return;
}
if (ret < 0) {
int op = IDE_RETRY_DMA;
if (s->dma_cmd == IDE_DMA_READ)
op |= IDE_RETRY_READ;
else if (s->dma_cmd == IDE_DMA_TRIM)
op |= IDE_RETRY_TRIM;
if (ide_handle_rw_error(s, -ret, op)) {
return;
}
}
n = s->io_buffer_size >> 9;
if (n > s->nsector) {
n = s->nsector;
stay_active = true;
}
sector_num = ide_get_sector(s);
if (n > 0) {
dma_buf_commit(s);
sector_num += n;
ide_set_sector(s, sector_num);
s->nsector -= n;
}
if (s->nsector == 0) {
s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s->bus);
goto eot;
}
n = s->nsector;
s->io_buffer_index = 0;
s->io_buffer_size = n * 512;
if (s->bus->dma->ops->prepare_buf(s->bus->dma, ide_cmd_is_read(s)) == 0) {
s->status = READY_STAT | SEEK_STAT;
goto eot;
}
#ifdef DEBUG_AIO
printf("ide_dma_cb: sector_num=%" PRId64 " n=%d, cmd_cmd=%d\n",
sector_num, n, s->dma_cmd);
#endif
if ((s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) &&
!ide_sect_range_ok(s, sector_num, n)) {
dma_buf_commit(s);
ide_dma_error(s);
return;
}
switch (s->dma_cmd) {
case IDE_DMA_READ:
s->bus->dma->aiocb = dma_bdrv_read(s->bs, &s->sg, sector_num,
ide_dma_cb, s);
break;
case IDE_DMA_WRITE:
s->bus->dma->aiocb = dma_bdrv_write(s->bs, &s->sg, sector_num,
ide_dma_cb, s);
break;
case IDE_DMA_TRIM:
s->bus->dma->aiocb = dma_bdrv_io(s->bs, &s->sg, sector_num,
ide_issue_trim, ide_dma_cb, s,
DMA_DIRECTION_TO_DEVICE);
break;
}
return;
eot:
if (s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) {
block_acct_done(bdrv_get_stats(s->bs), &s->acct);
}
ide_set_inactive(s, stay_active);
}
| 1threat |
Is this a proper way to insert a node after the first for a doubly linked list? : <pre><code>NodePtr p = new Node(id, age, email)
p->prev = top;
p->next = top->next;
top->next = p;
top->next->prev = p;
</code></pre>
<p>I am trying to insert node p after the first node. </p>
<p>I am trying to teach myself how to use doubly linked lists. When I draw it out, it looks like it would work. I just wanted confirmation if this is correct. If this is not correct, how should I fix it?</p>
| 0debug |
static uint64_t htonll(uint64_t v)
{
union { uint32_t lv[2]; uint64_t llv; } u;
u.lv[0] = htonl(v >> 32);
u.lv[1] = htonl(v & 0xFFFFFFFFULL);
return u.llv;
}
| 1threat |
void virtio_setup_block(struct subchannel_id schid)
{
struct vq_info_block info;
struct vq_config_block config = {};
virtio_reset(schid);
config.index = 0;
if (run_ccw(schid, CCW_CMD_READ_VQ_CONF, &config, sizeof(config))) {
virtio_panic("Could not get block device configuration\n");
}
vring_init(&block, config.num, (void*)(100 * 1024 * 1024),
KVM_S390_VIRTIO_RING_ALIGN);
info.queue = (100ULL * 1024ULL* 1024ULL);
info.align = KVM_S390_VIRTIO_RING_ALIGN;
info.index = 0;
info.num = config.num;
block.schid = schid;
if (!run_ccw(schid, CCW_CMD_SET_VQ, &info, sizeof(info))) {
virtio_set_status(schid, VIRTIO_CONFIG_S_DRIVER_OK);
}
}
| 1threat |
Why does Boolean.getBoolean never seem to return true : <p>Based upon the java doc I have no logical explanation for this. Any ideas?</p>
<pre><code>Boolean.getBoolean(Boolean.TRUE.toString()) == false
</code></pre>
<p>See it for yourself:
<a href="https://ideone.com/rKa2dS" rel="nofollow">https://ideone.com/rKa2dS</a></p>
<p>Nothing clear to me why in the Java Doc
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Boolean.html#getBoolean-java.lang.String-" rel="nofollow">https://docs.oracle.com/javase/8/docs/api/java/lang/Boolean.html#getBoolean-java.lang.String-</a></p>
| 0debug |
Analysis of the output from tf.nn.dynamic_rnn tensorflow function : <p>I am not able to understand the output from <code>tf.nn.dynamic_rnn</code> tensorflow function. The document just tells about the size of the output, but it doesn't tell what does each row/column means. From the documentation:</p>
<blockquote>
<p><strong>outputs</strong>: The RNN output <code>Tensor</code>.</p>
<p>If time_major == False (default), this will be a <code>Tensor</code> shaped:
<code>[batch_size, max_time, cell.output_size]</code>.</p>
<p>If time_major == True, this will be a <code>Tensor</code> shaped:
<code>[max_time, batch_size, cell.output_size]</code>.</p>
<p>Note, if <code>cell.output_size</code> is a (possibly nested) tuple of integers
or <code>TensorShape</code> objects, then <code>outputs</code> will be a tuple having the<br>
same structure as <code>cell.output_size</code>, containing Tensors having shapes
corresponding to the shape data in <code>cell.output_size</code>.</p>
<p><strong>state</strong>: The final state. If <code>cell.state_size</code> is an int, this will
be shaped <code>[batch_size, cell.state_size]</code>. If it is a<br>
<code>TensorShape</code>, this will be shaped <code>[batch_size] + cell.state_size</code>.<br>
If it is a (possibly nested) tuple of ints or <code>TensorShape</code>, this will
be a tuple having the corresponding shapes.</p>
</blockquote>
<p>The <code>outputs</code> tensor is a 3-D matrix but what does each row/column represent?</p>
| 0debug |
static void gen_lea_v_seg(DisasContext *s, TCGMemOp aflag, TCGv a0,
int def_seg, int ovr_seg)
{
switch (aflag) {
#ifdef TARGET_X86_64
case MO_64:
if (ovr_seg < 0) {
tcg_gen_mov_tl(cpu_A0, a0);
return;
}
break;
#endif
case MO_32:
if (ovr_seg < 0) {
if (s->addseg) {
ovr_seg = def_seg;
} else {
tcg_gen_ext32u_tl(cpu_A0, a0);
return;
}
}
break;
case MO_16:
if (ovr_seg < 0) {
ovr_seg = def_seg;
}
tcg_gen_ext16u_tl(cpu_A0, a0);
if (!s->addseg) {
return;
}
a0 = cpu_A0;
break;
default:
tcg_abort();
}
if (ovr_seg >= 0) {
TCGv seg = tcg_temp_new();
tcg_gen_ld_tl(seg, cpu_env, offsetof(CPUX86State, segs[ovr_seg].base));
if (aflag == MO_64) {
tcg_gen_add_tl(cpu_A0, a0, seg);
} else if (CODE64(s)) {
tcg_gen_ext32u_tl(cpu_A0, a0);
tcg_gen_add_tl(cpu_A0, cpu_A0, seg);
} else {
tcg_gen_add_tl(cpu_A0, a0, seg);
tcg_gen_ext32u_tl(cpu_A0, cpu_A0);
}
tcg_temp_free(seg);
}
}
| 1threat |
"Use of a signed integer operand with a binary bitwise operator" - when using unsigned short : <p>In the following C snippet that checks if the first two bits of a 16-bit sequence are set:</p>
<pre><code>bool is_pointer(unsigned short int sequence) {
return (sequence >> 14) == 3;
}
</code></pre>
<p>CLion's Clang-Tidy is giving me a "Use of a signed integer operand with a binary bitwise operator" warning, and I can't understand why. Is <code>unsigned short</code> not unsigned enough?</p>
| 0debug |
Need to check an attribute value format for decimal value : I need to validate an attribute value for the decimal format check.
If the value is having 4 numbers before the decimal value (like 1234.12) print fail and if (123.23) it will pass.
Please help me. | 0debug |
Which contemporary computer languages are LL(1)? : <p>(I am spending the holiday time on some language theory. Excuse me if this is a naive question.)</p>
<p>According to <a href="https://en.wikipedia.org/wiki/LL_parser">here</a>:</p>
<blockquote>
<p>LL grammars, particularly LL(1) grammars, are of great practical
interest, as parsers for these grammars are easy to construct, and
many computer languages are designed to be LL(1) for this reason.</p>
</blockquote>
<p>So, out of curiosity, which contemporary computer langauges are LL(1) ? Does C, Java ,C# or Python fall into this category?</p>
| 0debug |
int chsc_sei_nt2_have_event(void)
{
S390pciState *s = S390_PCI_HOST_BRIDGE(
object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));
if (!s) {
return 0;
}
return !QTAILQ_EMPTY(&s->pending_sei);
}
| 1threat |
static void vc1_inv_trans_4x4_c(uint8_t *dest, int linesize, DCTELEM *block)
{
int i;
register int t1,t2,t3,t4;
DCTELEM *src, *dst;
const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
src = block;
dst = block;
for(i = 0; i < 4; i++){
t1 = 17 * (src[0] + src[2]) + 4;
t2 = 17 * (src[0] - src[2]) + 4;
t3 = 22 * src[1] + 10 * src[3];
t4 = 22 * src[3] - 10 * src[1];
dst[0] = (t1 + t3) >> 3;
dst[1] = (t2 - t4) >> 3;
dst[2] = (t2 + t4) >> 3;
dst[3] = (t1 - t3) >> 3;
src += 8;
dst += 8;
}
src = block;
for(i = 0; i < 4; i++){
t1 = 17 * (src[ 0] + src[16]) + 64;
t2 = 17 * (src[ 0] - src[16]) + 64;
t3 = 22 * src[ 8] + 10 * src[24];
t4 = 22 * src[24] - 10 * src[ 8];
dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)];
dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)];
dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)];
dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)];
src ++;
dest++;
}
}
| 1threat |
int ff_scale_image(uint8_t *dst_data[4], int dst_linesize[4],
int dst_w, int dst_h, enum AVPixelFormat dst_pix_fmt,
uint8_t * const src_data[4], int src_linesize[4],
int src_w, int src_h, enum AVPixelFormat src_pix_fmt,
void *log_ctx)
{
int ret;
struct SwsContext *sws_ctx = sws_getContext(src_w, src_h, src_pix_fmt,
dst_w, dst_h, dst_pix_fmt,
SWS_BILINEAR, NULL, NULL, NULL);
if (!sws_ctx) {
av_log(log_ctx, AV_LOG_ERROR,
"Impossible to create scale context for the conversion "
"fmt:%s s:%dx%d -> fmt:%s s:%dx%d\n",
av_get_pix_fmt_name(src_pix_fmt), src_w, src_h,
av_get_pix_fmt_name(dst_pix_fmt), dst_w, dst_h);
ret = AVERROR(EINVAL);
goto end;
}
if ((ret = av_image_alloc(dst_data, dst_linesize, dst_w, dst_h, dst_pix_fmt, 16)) < 0)
goto end;
ret = 0;
sws_scale(sws_ctx, (const uint8_t * const*)src_data, src_linesize, 0, src_h, dst_data, dst_linesize);
end:
sws_freeContext(sws_ctx);
return ret;
}
| 1threat |
Kind of a font disorder : Hey guys ı have a question about my code. I think I maked everythig correct. But ı have a font disorder. Here is my code can u help me pls? How can I fix it?[This is first photo][1], [This is second photo][2]
[1]: https://i.stack.imgur.com/lxvGn.png
[2]: https://i.stack.imgur.com/J4K2k.png | 0debug |
CSV module - how to open a file that everyday has a different name due to date change? : this is my very first post here and I am on the beggining of my adventure with Python, sorry for any mistakes I have made.
I am working on an automation of reporting to my collaborators.
I am pulling the report though API with the following code :
***code***
import requests
from datetime import date, timedelta
today = date.today()
yesterday = today - timedelta(days = 1)
app_id = 'myappid'
report_type = 'daily_report'
params = {
'api_token': 'api_token',
'from': yesterday,
'to': yesterday
}
request_url = 'https://domainxyz.com/export/{}/{}/v5'.format(app_id, report_type)
res = requests.request('GET', request_url, params=params)
if res.status_code != 200:
if res.status_code == 404:
print('There is a problem with the request URL. Make sure that it is correct')
else:
print('There was a problem retrieving data: ', res.text)
else:
f = open('{}-{}-{}-to-{}.csv'.format(app_id, report_type, params['from'], params['to']), 'w', newline='', encoding="utf-8")
f.write(res.text)
f.close()
and the code saves the file as 'myappid-daily_report-yesterdayDate-to-yesterdayDate.csv
and this is working just great.
Once I do have the data for yesterday, I would like to open the csv file and do some modifications with Pandas but before this, I need to open the CSV file which has kind of a dynamic name on daily basis.
I would open the file with the following
import csv
from datetime import date, timedelta
today = date.today()
yesterday = today - timedelta(days = 1)
app_id = 'myappid'
report_type = 'daily_report'
params = {
'from': yesterday,
'to': yesterday
}
csv_file = ('{}-{}-{}-to-{}'.format(app_id, report_type, params['from'], params['to']))
print (csv_file)
with open('csv_file' +'.csv', 'r') as csvfile:
***code***
print function returns proper name but I am getting an error which says :
Traceback (most recent call last):
File "C:/Users/Iwan/PycharmProjects/Learning/csv_mods.py", line 20, in <module>
with open('csv_file' +'.csv', 'r') as csvfile:
FileNotFoundError: [Errno 2] No such file or directory: 'csv_file.csv'
So I wonder how can I inject the *.csv on daily basis instead of manualy typing csv file name.
If I have made any mistake in this post or question please point it out and I will do my best to avoid this in the future.
Cheers,
Iwan
| 0debug |
The reference assemblies for framework ".NETFramework,Version=v4.6.2" were not found : <p>When trying to compile a solution, I get the following build error:</p>
<blockquote>
<p>Error MSB3644 The reference assemblies for framework
".NETFramework,Version=v4.6.2" were not found. To resolve this,
install the SDK or Targeting Pack for this framework version or
retarget your application to a version of the framework for which you
have the SDK or Targeting Pack installed. Note that assemblies will be
resolved from the Global Assembly Cache (GAC) and will be used in
place of reference assemblies. Therefore your assembly may not be
correctly targeted for the framework you intend.
C:\RPR\Dev\Libraries\Common\Common.csproj C:\Program Files
(x86)\Microsoft Visual
Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets 1111</p>
</blockquote>
<p>I've tried installing the .NET Framework 4.6.2 SDK, as well as the 4.6 Targeting Pack, however both error that I already have it installed. I also tried installing Visual Studio 2017 but it still gives the same error.</p>
<p>Any ideas?</p>
| 0debug |
qcrypto_tls_creds_x509_sanity_check(QCryptoTLSCredsX509 *creds,
bool isServer,
const char *cacertFile,
const char *certFile,
Error **errp)
{
gnutls_x509_crt_t cert = NULL;
gnutls_x509_crt_t cacerts[MAX_CERTS];
size_t ncacerts = 0;
size_t i;
int ret = -1;
memset(cacerts, 0, sizeof(cacerts));
if (access(certFile, R_OK) == 0) {
cert = qcrypto_tls_creds_load_cert(creds,
certFile, isServer,
errp);
if (!cert) {
goto cleanup;
}
}
if (access(cacertFile, R_OK) == 0) {
if (qcrypto_tls_creds_load_ca_cert_list(creds,
cacertFile, cacerts,
MAX_CERTS, &ncacerts,
errp) < 0) {
goto cleanup;
}
}
if (cert &&
qcrypto_tls_creds_check_cert(creds,
cert, certFile, isServer,
false, errp) < 0) {
goto cleanup;
}
for (i = 0; i < ncacerts; i++) {
if (qcrypto_tls_creds_check_cert(creds,
cacerts[i], cacertFile,
isServer, true, errp) < 0) {
goto cleanup;
}
}
if (cert && ncacerts &&
qcrypto_tls_creds_check_cert_pair(cert, certFile, cacerts,
ncacerts, cacertFile,
isServer, errp) < 0) {
goto cleanup;
}
ret = 0;
cleanup:
if (cert) {
gnutls_x509_crt_deinit(cert);
}
for (i = 0; i < ncacerts; i++) {
gnutls_x509_crt_deinit(cacerts[i]);
}
return ret;
}
| 1threat |
static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
{
ALSSpecificConfig *sconf = &ctx->sconf;
AVCodecContext *avctx = ctx->avctx;
GetBitContext *gb = &ctx->gb;
unsigned int div_blocks[32];
unsigned int c;
unsigned int js_blocks[2];
uint32_t bs_info = 0;
if (sconf->ra_flag == RA_FLAG_FRAMES && ra_frame)
skip_bits_long(gb, 32);
if (sconf->mc_coding && sconf->joint_stereo) {
ctx->js_switch = get_bits1(gb);
align_get_bits(gb);
}
if (!sconf->mc_coding || ctx->js_switch) {
int independent_bs = !sconf->joint_stereo;
for (c = 0; c < avctx->channels; c++) {
js_blocks[0] = 0;
js_blocks[1] = 0;
get_block_sizes(ctx, div_blocks, &bs_info);
if (sconf->joint_stereo && sconf->block_switching)
if (bs_info >> 31)
independent_bs = 2;
if (c == avctx->channels - 1)
independent_bs = 1;
if (independent_bs) {
if (decode_blocks_ind(ctx, ra_frame, c, div_blocks, js_blocks))
return -1;
independent_bs--;
} else {
if (decode_blocks(ctx, ra_frame, c, div_blocks, js_blocks))
return -1;
c++;
}
memmove(ctx->raw_samples[c] - sconf->max_order,
ctx->raw_samples[c] - sconf->max_order + sconf->frame_length,
sizeof(*ctx->raw_samples[c]) * sconf->max_order);
}
} else {
ALSBlockData bd;
int b;
int *reverted_channels = ctx->reverted_channels;
unsigned int offset = 0;
for (c = 0; c < avctx->channels; c++)
if (ctx->chan_data[c] < ctx->chan_data_buffer) {
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid channel data!\n");
return -1;
}
memset(&bd, 0, sizeof(ALSBlockData));
memset(reverted_channels, 0, sizeof(*reverted_channels) * avctx->channels);
bd.ra_block = ra_frame;
bd.prev_raw_samples = ctx->prev_raw_samples;
get_block_sizes(ctx, div_blocks, &bs_info);
for (b = 0; b < ctx->num_blocks; b++) {
bd.block_length = div_blocks[b];
for (c = 0; c < avctx->channels; c++) {
bd.const_block = ctx->const_block + c;
bd.shift_lsbs = ctx->shift_lsbs + c;
bd.opt_order = ctx->opt_order + c;
bd.store_prev_samples = ctx->store_prev_samples + c;
bd.use_ltp = ctx->use_ltp + c;
bd.ltp_lag = ctx->ltp_lag + c;
bd.ltp_gain = ctx->ltp_gain[c];
bd.lpc_cof = ctx->lpc_cof[c];
bd.quant_cof = ctx->quant_cof[c];
bd.raw_samples = ctx->raw_samples[c] + offset;
bd.raw_other = NULL;
read_block(ctx, &bd);
if (read_channel_data(ctx, ctx->chan_data[c], c))
return -1;
}
for (c = 0; c < avctx->channels; c++)
if (revert_channel_correlation(ctx, &bd, ctx->chan_data,
reverted_channels, offset, c))
return -1;
for (c = 0; c < avctx->channels; c++) {
bd.const_block = ctx->const_block + c;
bd.shift_lsbs = ctx->shift_lsbs + c;
bd.opt_order = ctx->opt_order + c;
bd.store_prev_samples = ctx->store_prev_samples + c;
bd.use_ltp = ctx->use_ltp + c;
bd.ltp_lag = ctx->ltp_lag + c;
bd.ltp_gain = ctx->ltp_gain[c];
bd.lpc_cof = ctx->lpc_cof[c];
bd.quant_cof = ctx->quant_cof[c];
bd.raw_samples = ctx->raw_samples[c] + offset;
decode_block(ctx, &bd);
}
memset(reverted_channels, 0, avctx->channels * sizeof(*reverted_channels));
offset += div_blocks[b];
bd.ra_block = 0;
}
for (c = 0; c < avctx->channels; c++)
memmove(ctx->raw_samples[c] - sconf->max_order,
ctx->raw_samples[c] - sconf->max_order + sconf->frame_length,
sizeof(*ctx->raw_samples[c]) * sconf->max_order);
}
return 0;
}
| 1threat |
static int ogg_read_page(AVFormatContext *s, int *str)
{
AVIOContext *bc = s->pb;
struct ogg *ogg = s->priv_data;
struct ogg_stream *os;
int ret, i = 0;
int flags, nsegs;
uint64_t gp;
uint32_t serial;
int size, idx;
uint8_t sync[4];
int sp = 0;
ret = avio_read(bc, sync, 4);
if (ret < 4)
return ret < 0 ? ret : AVERROR_EOF;
do{
int c;
if (sync[sp & 3] == 'O' &&
sync[(sp + 1) & 3] == 'g' &&
sync[(sp + 2) & 3] == 'g' && sync[(sp + 3) & 3] == 'S')
break;
c = avio_r8(bc);
if (bc->eof_reached)
return AVERROR_EOF;
sync[sp++ & 3] = c;
}while (i++ < MAX_PAGE_SIZE);
if (i >= MAX_PAGE_SIZE){
av_log (s, AV_LOG_INFO, "ogg, can't find sync word\n");
return AVERROR_INVALIDDATA;
}
if (avio_r8(bc) != 0)
return AVERROR_INVALIDDATA;
flags = avio_r8(bc);
gp = avio_rl64 (bc);
serial = avio_rl32 (bc);
avio_skip(bc, 8);
nsegs = avio_r8(bc);
idx = ogg_find_stream (ogg, serial);
if (idx < 0){
if (ogg->headers) {
int n;
for (n = 0; n < ogg->nstreams; n++) {
av_freep(&ogg->streams[n].buf);
if (!ogg->state || ogg->state->streams[n].private != ogg->streams[n].private)
av_freep(&ogg->streams[n].private);
}
ogg->curidx = -1;
ogg->nstreams = 0;
idx = ogg_new_stream(s, serial, 0);
} else {
idx = ogg_new_stream(s, serial, 1);
}
if (idx < 0)
return idx;
}
os = ogg->streams + idx;
os->page_pos = avio_tell(bc) - 27;
if(os->psize > 0)
ogg_new_buf(ogg, idx);
ret = avio_read(bc, os->segments, nsegs);
if (ret < nsegs)
return ret < 0 ? ret : AVERROR_EOF;
os->nsegs = nsegs;
os->segp = 0;
size = 0;
for (i = 0; i < nsegs; i++)
size += os->segments[i];
if (flags & OGG_FLAG_CONT || os->incomplete){
if (!os->psize){
while (os->segp < os->nsegs){
int seg = os->segments[os->segp++];
os->pstart += seg;
if (seg < 255)
break;
}
os->sync_pos = os->page_pos;
}
}else{
os->psize = 0;
os->sync_pos = os->page_pos;
}
if (os->bufsize - os->bufpos < size){
uint8_t *nb = av_malloc (os->bufsize *= 2);
memcpy (nb, os->buf, os->bufpos);
av_free (os->buf);
os->buf = nb;
}
ret = avio_read(bc, os->buf + os->bufpos, size);
if (ret < size)
return ret < 0 ? ret : AVERROR_EOF;
os->bufpos += size;
os->granule = gp;
os->flags = flags;
if (str)
*str = idx;
return 0;
}
| 1threat |
What are some resources I can follow to create a program that writes an XML file using STREAM? : <p>This is for my schoolwork. I need to write from my data to an XML file, invoiceData.xml using the STREAM method. I have done a program that reads from an XML file using the DOM method if telling you about it helps. :)</p>
<p>So please help me, it will be very much appreciated.</p>
| 0debug |
Mutation Observer Not Detecting Text Change : <p>I'm scratching my head as to why MutationObserver doesn't detect text changes done using textContent.</p>
<h2>HTML</h2>
<pre><code><div id="mainContainer">
<h1>Heading</h1>
<p>Paragraph.</p>
</div>
</code></pre>
<h2>JavaScript</h2>
<pre><code>function mutate(mutations) {
mutations.forEach(function(mutation) {
alert(mutation.type);
});
}
jQuery(document).ready(function() {
setTimeout(function() {
document.querySelector('div#mainContainer > p').textContent = 'Some other text.';
}, 2000);
var target = document.querySelector('div#mainContainer > p')
var observer = new MutationObserver( mutate );
var config = { characterData: true, attributes: false, childList: false, subtree: true };
observer.observe(target, config);
});
</code></pre>
<p>In the above script, the paragraph element's text content clearly changes but MutationObserver doesn't detect it.</p>
<p>However, if you change textContent to innerHTML, you will be alerted that the "characterData" has changed.</p>
<p>Why does MutationObserver detect innerHTML but not textContent?</p>
<p>Here is the JS Fiddle:</p>
<p><a href="https://jsfiddle.net/0vp8t8x7/" rel="noreferrer">https://jsfiddle.net/0vp8t8x7/</a></p>
<p>Notice that you'll only get alerted if you change textContent to innerHTML.</p>
| 0debug |
Even, Odd with min and max for the Odd only : <p>Prompt the user to enter the size of an array and allow the user to
input integer values to your array. Check each element if it is even
or odd. If even, print solved elemets (ascending order), If odd, get
the max and min using conditional statement. Output the result.</p>
<pre><code>public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number: ");
int n = sc.nextInt();
int s[] = new int[n];
for (int i = 0; i < n; i++) {
int e = sc.nextInt();
s[i] = e;
}
Arrays.sort(s);
System.out.println("\nEven numbers in ascending order:");
for (int j = 0; j < n; j++) {
if (s[j] % 2 == 0) {
System.out.print(s[j] + " ");
}
}
System.out.println("\nOdd numbers in descending order:");
for(int j = (n -1); j >= 0; j--) {
if (s[j] % 2 == 1) {
System.out.print(s[j] + " ");
}
}
}
</code></pre>
<p>I don't know how to add min/max for the Odd</p>
| 0debug |
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
{
PerThreadContext *p = avctx->internal->thread_ctx;
FrameThreadContext *fctx;
AVFrame *dst, *tmp;
FF_DISABLE_DEPRECATION_WARNINGS
int can_direct_free = !(avctx->active_thread_type & FF_THREAD_FRAME) ||
avctx->thread_safe_callbacks ||
(
#if FF_API_GET_BUFFER
!avctx->get_buffer &&
#endif
avctx->get_buffer2 == avcodec_default_get_buffer2);
FF_ENABLE_DEPRECATION_WARNINGS
if (!f->f->data[0])
return;
if (avctx->debug & FF_DEBUG_BUFFERS)
av_log(avctx, AV_LOG_DEBUG, "thread_release_buffer called on pic %p\n", f);
av_buffer_unref(&f->progress);
f->owner = NULL;
if (can_direct_free) {
av_frame_unref(f->f);
return;
}
fctx = p->parent;
pthread_mutex_lock(&fctx->buffer_mutex);
if (p->num_released_buffers + 1 >= INT_MAX / sizeof(*p->released_buffers))
goto fail;
tmp = av_fast_realloc(p->released_buffers, &p->released_buffers_allocated,
(p->num_released_buffers + 1) *
sizeof(*p->released_buffers));
if (!tmp)
goto fail;
p->released_buffers = tmp;
dst = &p->released_buffers[p->num_released_buffers];
av_frame_move_ref(dst, f->f);
p->num_released_buffers++;
fail:
pthread_mutex_unlock(&fctx->buffer_mutex);
}
| 1threat |
static void set_blocksize(Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
uint16_t value, *ptr = qdev_get_prop_ptr(dev, prop);
Error *local_err = NULL;
const int64_t min = 512;
const int64_t max = 32768;
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
return;
}
visit_type_uint16(v, &value, name, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
if (value < min || value > max) {
error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
dev->id?:"", name, (int64_t)value, min, max);
return;
}
if ((value & (value - 1)) != 0) {
error_setg(errp,
"Property %s.%s doesn't take value '%" PRId64 "', it's not a power of 2",
dev->id ?: "", name, (int64_t)value);
return;
}
*ptr = value;
}
| 1threat |
what is TypeError: 'dict' object is not callable : I was working on web scraping but the code is showing error. help me out how i can solve this?
I have installed all required things related to this.
import request
from bs4 import BeautifulSoup
page = request.GET('https://en.wikipedia.org//wiki//Beautiful_Soup_(HTML_parser)')
soup = BeautifulSoup(page.content,'html.parser')
print(soup)
i expect the html codes of the website. but it is showing:-
page = request.GET('https://en.wikipedia.org//wiki//Beautiful_Soup_(HTML_parser)')
TypeError: 'dict' object is not callable | 0debug |
Spacemacs hybrid line numbers : <p>How do I get hybrid line numbering (relative line numbers, but the current line shows the absolute line number instead of 0) in spacemacs for all files?</p>
<p>I tried setting relative line numbers in user-config but that doesn't seem to be working, and can't figure out how to replace the 0 in relative mode either:</p>
<pre><code>(global-linum-mode)
(setq-default dotspacemacs-line-numbers 'relative)
</code></pre>
| 0debug |
errors in my java program y=mx+b with method : this is the program:
i tried to make a program that get from the user the m and the b from a user (y =mx+b) and prints is to a from of function "y=mx+b" with a method " liner".
import java.io.*;
public class line
{
double m, b;
public void liner(double m,double b);
{
System.out.print("y = " + m + "x + " + b);
}
public static void main(String args[])
{
Scanner reader = new Scanner(System.in);
System.out.print("What is the Slope");
m = reader.nextInt();
reader.close();
System.out.print("What is the Y Intercept");
b = reader.nextInt();
reader.close();
liner (m , b);
}
}
this is the errors
/line.java:6: error: missing method body, or declare abstract
public void liner(double m,double b);
^
/line.java:14: error: cannot find symbol
Scanner reader = new Scanner(System.in);
^
symbol: class Scanner
location: class line
/line.java:14: error: cannot find symbol
Scanner reader = new Scanner(System.in);
^
symbol: class Scanner
location: class line
3 errors
| 0debug |
How to clone multiple children with React.cloneElement? : <p>I try to clone React elements like this, to pass the parent props to them (the props are not assigned in this example):</p>
<pre><code>React.createElement('div',
{
style: this.props.style
},
React.cloneElement(this.props.children, null)
)
</code></pre>
<p>This however returns following error:</p>
<blockquote>
<p>Uncaught Invariant Violation: Element type is invalid: expected a
string (for built-in components) or a class/function (for composite
components) but got: undefined.</p>
</blockquote>
<p>If there is only one child or if I pass React.cloneElement(this.props.children[0], null), there is no error and the desired element is rendered.</p>
<p>How can I clone multiple elements?</p>
| 0debug |
Why is the addresses same? : void test(int k);
int main()
{
int i = 0;
printf("The address of i is %x\n", &i);
test(i);
printf("The address of i is %x\n", &i);
test(i);
return 0;
}
void test(int k)
{
print("The address of k is %x\n", &k);
}
Here, &i and &k addresses are different although k holds the value of i...Is this because after function declaration k takes separate memory allocation? Please Explain to me! | 0debug |
static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
{
int i;
for (i = 0; i < ic->nb_streams; i++) {
AVStream *st = ic->streams[i];
AVCodecContext *dec = st->codec;
InputStream *ist = av_mallocz(sizeof(*ist));
char *framerate = NULL, *hwaccel = NULL, *hwaccel_device = NULL;
if (!ist)
exit_program(1);
GROW_ARRAY(input_streams, nb_input_streams);
input_streams[nb_input_streams - 1] = ist;
ist->st = st;
ist->file_index = nb_input_files;
ist->discard = 1;
st->discard = AVDISCARD_ALL;
ist->ts_scale = 1.0;
MATCH_PER_STREAM_OPT(ts_scale, dbl, ist->ts_scale, ic, st);
ist->dec = choose_decoder(o, ic, st);
ist->opts = filter_codec_opts(o->g->codec_opts, ist->st->codec->codec_id, ic, st, ist->dec);
switch (dec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
ist->resample_height = dec->height;
ist->resample_width = dec->width;
ist->resample_pix_fmt = dec->pix_fmt;
MATCH_PER_STREAM_OPT(frame_rates, str, framerate, ic, st);
if (framerate && av_parse_video_rate(&ist->framerate,
framerate) < 0) {
av_log(NULL, AV_LOG_ERROR, "Error parsing framerate %s.\n",
framerate);
exit_program(1);
}
MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st);
if (hwaccel) {
if (!strcmp(hwaccel, "none"))
ist->hwaccel_id = HWACCEL_NONE;
else if (!strcmp(hwaccel, "auto"))
ist->hwaccel_id = HWACCEL_AUTO;
else {
int i;
for (i = 0; hwaccels[i].name; i++) {
if (!strcmp(hwaccels[i].name, hwaccel)) {
ist->hwaccel_id = hwaccels[i].id;
break;
}
}
if (!ist->hwaccel_id) {
av_log(NULL, AV_LOG_FATAL, "Unrecognized hwaccel: %s.\n",
hwaccel);
av_log(NULL, AV_LOG_FATAL, "Supported hwaccels: ");
for (i = 0; hwaccels[i].name; i++)
av_log(NULL, AV_LOG_FATAL, "%s ", hwaccels[i].name);
av_log(NULL, AV_LOG_FATAL, "\n");
exit_program(1);
}
}
}
MATCH_PER_STREAM_OPT(hwaccel_devices, str, hwaccel_device, ic, st);
if (hwaccel_device) {
ist->hwaccel_device = av_strdup(hwaccel_device);
if (!ist->hwaccel_device)
exit_program(1);
}
break;
case AVMEDIA_TYPE_AUDIO:
guess_input_channel_layout(ist);
ist->resample_sample_fmt = dec->sample_fmt;
ist->resample_sample_rate = dec->sample_rate;
ist->resample_channels = dec->channels;
ist->resample_channel_layout = dec->channel_layout;
break;
case AVMEDIA_TYPE_DATA:
case AVMEDIA_TYPE_SUBTITLE:
case AVMEDIA_TYPE_ATTACHMENT:
case AVMEDIA_TYPE_UNKNOWN:
break;
default:
abort();
}
}
} | 1threat |
static int rv40_v_loop_filter_strength(uint8_t *src, int stride,
int beta, int beta2, int edge,
int *p1, int *q1)
{
return rv40_loop_filter_strength(src, 1, stride, beta, beta2, edge, p1, q1);
}
| 1threat |
What does this mean in a java code? Is the first time I've seen it: : <p>I would like to know what does this return statement mean since I have never seen it:</p>
<pre><code> static int max(int a, int b) {
return (a > b)? a : b;
}
</code></pre>
<p>Thank you for your help!</p>
| 0debug |
Keras - How are batches and epochs used in fit_generator()? : <p>I have a video of 8000 frames, and I'd like to train a Keras model on batches of 200 frames each. I have a frame generator that loops through the video frame-by-frame and accumulates the (3 x 480 x 640) frames into a numpy matrix <code>X</code> of shape <code>(200, 3, 480, 640)</code> -- (batch size, rgb, frame height, frame width) -- and yields <code>X</code> and <code>Y</code> every 200th frame:</p>
<pre><code>import cv2
...
def _frameGenerator(videoPath, dataPath, batchSize):
"""
Yield X and Y data when the batch is filled.
"""
camera = cv2.VideoCapture(videoPath)
width = camera.get(3)
height = camera.get(4)
frameCount = int(camera.get(7)) # Number of frames in the video file.
truthData = _prepData(dataPath, frameCount)
X = np.zeros((batchSize, 3, height, width))
Y = np.zeros((batchSize, 1))
batch = 0
for frameIdx, truth in enumerate(truthData):
ret, frame = camera.read()
if ret is False: continue
batchIndex = frameIdx%batchSize
X[batchIndex] = frame
Y[batchIndex] = truth
if batchIndex == 0 and frameIdx != 0:
batch += 1
print "now yielding batch", batch
yield X, Y
</code></pre>
<p>Here's how run <a href="https://keras.io/models/model/" rel="noreferrer"><code>fit_generator()</code></a>:</p>
<pre><code> batchSize = 200
print "Starting training..."
model.fit_generator(
_frameGenerator(videoPath, dataPath, batchSize),
samples_per_epoch=8000,
nb_epoch=10,
verbose=args.verbosity
)
</code></pre>
<p>My understanding is an epoch finishes when <code>samples_per_epoch</code> samples have been seen by the model, and <code>samples_per_epoch</code> = batch size * number of batches = 200 * 40. So after training for an epoch on frames 0-7999, the next epoch will start training again from frame 0. Is this correct?</p>
<p>With this setup <strong>I expect 40 batches (of 200 frames each) to be passed from the generator to <code>fit_generator</code>, per epoch; this would be 8000 total frames per epoch</strong> -- i.e., <code>samples_per_epoch=8000</code>. Then for subsequent epochs, <code>fit_generator</code> would reinitialize the generator such that we begin training again from the start of the video. Yet this is not the case. <strong>After the first epoch is complete (after the model logs batches 0-24), the generator picks up where it left off. Shouldn't the new epoch start again from the beginning of the training dataset?</strong></p>
<p>If there is something incorrect in my understanding of <code>fit_generator</code> please explain. I've gone through the documentation, this <a href="https://github.com/fchollet/keras/blob/master/examples/cifar10_cnn.py" rel="noreferrer">example</a>, and these <a href="https://github.com/fchollet/keras/issues/1627" rel="noreferrer">related</a> <a href="https://github.com/fchollet/keras/issues/107" rel="noreferrer">issues</a>. I'm using Keras v1.0.7 with the TensorFlow backend. This issue is also posted in the <a href="https://github.com/fchollet/keras/issues/3461" rel="noreferrer">Keras repo</a>.</p>
| 0debug |
How to migrate existing SQLite application to Room Persistance Library? : <p>It might be a bit early to ask, but is it possible and how to migrate/upgrade an existing SQLite database application to a new Android Room Persistance Library?</p>
| 0debug |
How to get data of a select option tag into a php variable befor submiting pure php? : I have a table that shows students list the data is shown using a foreach loop.
now inside the table, I have a column to take the attendance a student is whether present or absent. I put the present and absent inside a select tag in HTML.
as looks below:
<table>
<tr>
<td>ID</td>
<td>
<select name="att">
<option value="1">Present</option>
<option value="0">Absent</option>
</select>
</td>
</tr>
</table>
Now want to take the attendence and update related rows inside the table.
How to get values of IDs and atts to pass through php to the database?
I thought to get the values inside php array and send it but how to get the value from the select tag inside and array I had no idea.
If possible please provide the code.
| 0debug |
Why was the software for Apollo missions written in assembly and not in a high level programming language? : <p>According to <a href="https://www.hq.nasa.gov/alsj/a11/a11.1201-fm.html" rel="nofollow noreferrer">this article</a> and answers to <a href="https://stackoverflow.com/q/739561/1097451">this question</a>, the software that was used for the Apollo 11 mission, that landed the first man on the Moon, was <strong>written in assembly</strong>.</p>
<p>I find this quite shocking, since the project started in 1960 and the mission took place in 1969. By this time already several high level programming languages were available. For example Lisp, which is a fairly high level language, even with <strong>garbage collecting</strong> and that is still in use today.</p>
<p>Given the assumption that garbage-collected high level languages reduce the potential for human error in programming and the high risk aversion of the authorities, <em>why did the managers allow for such a tremendous hazard?</em></p>
| 0debug |
static inline int ape_decode_value_3860(APEContext *ctx, GetBitContext *gb,
APERice *rice)
{
unsigned int x, overflow;
overflow = get_unary(gb, 1, get_bits_left(gb));
if (ctx->fileversion > 3880) {
while (overflow >= 16) {
overflow -= 16;
rice->k += 4;
}
}
if (!rice->k)
x = overflow;
else
x = (overflow << rice->k) + get_bits(gb, rice->k);
rice->ksum += x - (rice->ksum + 8 >> 4);
if (rice->ksum < (rice->k ? 1 << (rice->k + 4) : 0))
rice->k--;
else if (rice->ksum >= (1 << (rice->k + 5)) && rice->k < 24)
rice->k++;
if (x & 1)
return (x >> 1) + 1;
else
return -(x >> 1);
}
| 1threat |
int ff_mov_iso639_to_lang(const char *lang, int mp4)
{
int i, code = 0;
for (i = 0; !mp4 && i < FF_ARRAY_ELEMS(mov_mdhd_language_map); i++) {
if (mov_mdhd_language_map[i] && !strcmp(lang, mov_mdhd_language_map[i]))
return i;
}
if (!mp4)
return 0;
if (lang[0] == '\0')
lang = "und";
for (i = 0; i < 3; i++) {
unsigned char c = (unsigned char)lang[i];
if (c < 0x60)
return 0;
if (c > 0x60 + 0x1f)
return 0;
code <<= 5;
code |= (c - 0x60);
}
return code;
}
| 1threat |
static int openfile(char *name, int flags, int growable, QDict *opts)
{
Error *local_err = NULL;
if (qemuio_bs) {
fprintf(stderr, "file open already, try 'help close'\n");
return 1;
}
if (growable) {
if (bdrv_open(&qemuio_bs, name, NULL, opts, flags | BDRV_O_PROTOCOL,
NULL, &local_err))
{
fprintf(stderr, "%s: can't open device %s: %s\n", progname, name,
error_get_pretty(local_err));
error_free(local_err);
return 1;
}
} else {
qemuio_bs = bdrv_new("hda");
if (bdrv_open(&qemuio_bs, name, NULL, opts, flags, NULL, &local_err)
< 0)
{
fprintf(stderr, "%s: can't open device %s: %s\n", progname, name,
error_get_pretty(local_err));
error_free(local_err);
bdrv_unref(qemuio_bs);
qemuio_bs = NULL;
return 1;
}
}
return 0;
}
| 1threat |
how to extract features,such as color, of an image using k means algorithm in MATLAB? : <p>I have a data set consisting of animals . I want to identify the color of each animal using k means algorithm in MATLAB.</p>
| 0debug |
int av_parse_color(uint8_t *rgba_color, const char *color_string, void *log_ctx)
{
if (!strcasecmp(color_string, "random") || !strcasecmp(color_string, "bikeshed")) {
int rgba = av_get_random_seed();
rgba_color[0] = rgba >> 24;
rgba_color[1] = rgba >> 16;
rgba_color[2] = rgba >> 8;
rgba_color[3] = rgba;
} else
if (!strncmp(color_string, "0x", 2)) {
char *tail;
int len = strlen(color_string);
unsigned int rgba = strtoul(color_string, &tail, 16);
if (*tail || (len != 8 && len != 10)) {
av_log(log_ctx, AV_LOG_ERROR, "Invalid 0xRRGGBB[AA] color string: '%s'\n", color_string);
return AVERROR(EINVAL);
}
if (len == 10) {
rgba_color[3] = rgba;
rgba >>= 8;
}
rgba_color[0] = rgba >> 16;
rgba_color[1] = rgba >> 8;
rgba_color[2] = rgba;
} else {
const ColorEntry *entry = bsearch(color_string,
color_table,
FF_ARRAY_ELEMS(color_table),
sizeof(ColorEntry),
color_table_compare);
if (!entry) {
av_log(log_ctx, AV_LOG_ERROR, "Cannot find color '%s'\n", color_string);
return AVERROR(EINVAL);
}
memcpy(rgba_color, entry->rgba_color, 4);
}
return 0;
}
| 1threat |
document.write('<script src="evil.js"></script>'); | 1threat |
Could not import PILLOW_VERSION from PIL : <p>While importing, Python(anaconda) gives the following error:</p>
<pre><code>ImportError: cannot import name 'PILLOW_VERSION' from 'PIL'
</code></pre>
<p>I tried removing <code>pillow</code> and then <code>conda install</code> but the error persists. Please help</p>
| 0debug |
Write out file with google colab : <p>Was there a way to write out files with google colab?
For example, if I use</p>
<pre><code>import requests
r = requests.get(url)
</code></pre>
<p>Where will those files be stored? Can they be found?
And similarly, can I get the file I outputted via say tensorflow save function</p>
<pre><code>saver=tf.Saver(....)
...
path = saver.save(sess, "./my_model.ckpt")
</code></pre>
<p>Thanks!</p>
| 0debug |
How to add VAT in Stripe Checkout? : <p>I'm using Stripe Checkout to create a subscription in Stripe Billing. Checkout also auto creates the Stripe customer object.</p>
<p>How can I add right right VAT rate based on where the customer is based? The customer should be able to see the price both including and excluding VAT/GST both in the checkout session itself and on the invoice.</p>
<p>The "create subscription" API call allows you to set the field "default_tax_rates" which sounds like what I need, but the problem is that with Stripe Checkout the subscription (and the customer object) are created automatically by Stripe Checkout so I cannot explicitly pass parameters to these creation calls.</p>
<p>I know how to calculate the VAT rate and I don't want to integrate with another third party vendor just for tax, so I'm not looking for something like Quaderno or Taxamo.</p>
<p>How do people solve this problem? I'm starting to think that maybe I should have integrated with Chargebee instead of Stripe :-(</p>
| 0debug |
how to write global router-function in nuxt.js : <p>I am using Vue.js with Nuxt.js, but I got a problem in router's functions.</p>
<p>In the pure Vue, i can write in <code>main.js</code> like this:</p>
<pre><code>val route = new Router({
routes:{
[...]
}
})
route.beforeEach(to,from,next){
//do something to validate
}
</code></pre>
<p>And how to do the same in nuxt.js ? I can not find any file like <code>main.js</code>.</p>
<p>Also, all i know is to deal with the <code>pages</code> folder to achieve router, I can not set the redirect path</p>
<p>please help, thx :)</p>
| 0debug |
static void smptebars_fill_picture(AVFilterContext *ctx, AVFrame *picref)
{
TestSourceContext *test = ctx->priv;
FFDrawColor color;
int r_w, r_h, w_h, p_w, p_h, i, tmp, x = 0;
const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(picref->format);
r_w = FFALIGN((test->w + 6) / 7, 1 << pixdesc->log2_chroma_w);
r_h = FFALIGN(test->h * 2 / 3, 1 << pixdesc->log2_chroma_h);
w_h = FFALIGN(test->h * 3 / 4 - r_h, 1 << pixdesc->log2_chroma_h);
p_w = FFALIGN(r_w * 5 / 4, 1 << pixdesc->log2_chroma_w);
p_h = test->h - w_h - r_h;
#define DRAW_COLOR(rgba, x, y, w, h) \
ff_draw_color(&test->draw, &color, rgba); \
ff_fill_rectangle(&test->draw, &color, \
picref->data, picref->linesize, x, y, w, h) \
for (i = 0; i < 7; i++) {
DRAW_COLOR(rainbow[i], x, 0, FFMIN(r_w, test->w - x), r_h);
DRAW_COLOR(wobnair[i], x, r_h, FFMIN(r_w, test->w - x), w_h);
x += r_w;
}
x = 0;
DRAW_COLOR(i_pixel, x, r_h + w_h, p_w, p_h);
x += p_w;
DRAW_COLOR(white, x, r_h + w_h, p_w, p_h);
x += p_w;
DRAW_COLOR(q_pixel, x, r_h + w_h, p_w, p_h);
x += p_w;
tmp = FFALIGN(5 * r_w - x, 1 << pixdesc->log2_chroma_w);
DRAW_COLOR(black, x, r_h + w_h, tmp, p_h);
x += tmp;
tmp = FFALIGN(r_w / 3, 1 << pixdesc->log2_chroma_w);
DRAW_COLOR(neg4ire, x, r_h + w_h, tmp, p_h);
x += tmp;
DRAW_COLOR(black, x, r_h + w_h, tmp, p_h);
x += tmp;
DRAW_COLOR(pos4ire, x, r_h + w_h, tmp, p_h);
x += tmp;
DRAW_COLOR(black, x, r_h + w_h, test->w - x, p_h);
}
| 1threat |
static void opt_frame_pad_left(const char *arg)
{
frame_padleft = atoi(arg);
if (frame_padleft < 0) {
fprintf(stderr, "Incorrect left pad size\n");
av_exit(1);
}
}
| 1threat |
how do create a reference to a menber of an array : how can i make a reference of a member of an array in a class.
something like:
class ASD{
int bb[4];
int& up = bb[0] // <- error need to const
int& down= bb[1] // <- samething
int& right= bb[2] // <- samething
int& left= bb[3] // <- samething
};
this is so i can do this:
int main(){
ASD asd();
asd.bb[1] = 5;
// or
for(int i = 0; i < 4 ; i++){
asd.bb[i] =i;
}
// and still be able to do this :
asd.left = 50;
//witch will be equal to asd.bb[3] = 50
return 0;
}
the firt person to debug this will be my hero :D!!!
can u?
thanks in advance
| 0debug |
why is logged_out.html not overriding in django registration? : <p>I am using built-in django login and logout. In my Project/urls.py i have added url's for both login and logout.</p>
<pre><code>from django.conf.urls import include, url
from account import views
from django.contrib.auth import views as auth_views
from django.contrib import admin
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^$',views.index,name='Index'),
url(r'^accounts/login/$',auth_views.login,name='login'),
url(r'^accounts/logout/$',auth_views.logout,name='logout'),
url(r'^accounts/register/$',views.register,name='register'),
url(r'^accounts/profile/$',views.profile,name='profile'),
]
</code></pre>
<p>and i've templates folder inside my account app folder. i have directory structure like this</p>
<pre><code>account
-templates
-registration
-login.html
-logged_out.html
-register.html
-rest_html_files
-rest files
</code></pre>
<p>i've read django docs which say that for login() default template is registration/login.html which is working fine in my project and logout() default template is registration/logged_out.html if no arguments is supplied but whenever it Logout button ( which has a href={% url 'logout' %} ) is clicked it redirects to the admin logout page rather than my custom logout page.
what could possibly be wrong??</p>
| 0debug |
Selecting values fromt he same df but for different years : I have a data frame of some features and corresponding years. Each value of the feature is listed for different years. I need to compare the values of a specific year with that 7 years earlier. So basically I need to define a function that will generate two columns one will give me the value of the feature from the table for a specific year and the other one for the same feature but 7 years earlier. How can I do that?
feature year
value1 2001
value1 2008
vlaue2 1996 etc
e.g. I want to compare value1(2008) with value1(2008 - 7) etc.
there should also be some conditional statements as year 2000 can't be compared with (2000-7 =1993) because there is no value for the feature for year (1993) for example.
Thanks a lot. | 0debug |
Serverless Framework: Request must be smaller than 69905067 bytes for the UpdateFunctionCode operation : <p>I am using package uploading zipped file like</p>
<pre><code>frameworkVersion: "=1.27.3"
service: recipes
provider:
name: aws
endpointType: REGIONAL
runtime: python3.6
stage: dev
region: eu-central-1
memorySize: 512
deploymentBucket:
name: dfki-meta
versionFunctions: false
stackTags:
Project: DFKIAPP
# Allows updates to all resources except deleting/replacing EC2 instances
stackPolicy:
- Effect: Allow
Principal: "*"
Action: "Update:*"
Resource: "*"
- Effect: Deny
Principal: "*"
Action:
- Update: Replace
- Update: Delete
Resource: "*"
Condition:
StringEquals:
ResourceType:
- AWS::EC2::Instance
# Access to RDS and S3 Bucket
iamRoleStatements:
- Effect: "Allow"
Action: "s3:ListBucket"
Resource: "*"
package:
individually: true
functions:
# get_recipes:
# handler: handler.get_recipes
# module: recipes_crud
# package:
# individually: true
# timeout: 30
# events:
# - http:
# path: recipes
# method: get
# request:
# parameters:
# querystring:
# persona: true
get_recommendation:
handler: handler.get_recommendation
module: recipes_ml
package:
artifact: zipped_dir.zip
timeout: 30
events:
- http:
path: recipes/{id}
method: get
request:
parameters:
paths:
id: true
querystring:
schaerfe_def: true
saettig_def: true
erfahrung_def: true
schaerfe_wunsch: true
saettig_wunsch: true
erfahrung_wunsch: true
gericht_wunsch: true
stimmung_wunsch: true
</code></pre>
<p>Can not understand this error, isn't 52.18 under 69905067 bytes ?</p>
<pre><code>(node:50928) ExperimentalWarning: The fs.promises API is experimental
Serverless: Packaging function: get_recommendation...
Serverless: Uploading function: get_recommendation (52.18 MB)...
Serverless Error ---------------------------------------
Request must be smaller than 69905067 bytes for the UpdateFunctionCode operation
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information -----------------------------
OS: darwin
Node Version: 10.1.0
Serverless Version: 1.27.3
</code></pre>
| 0debug |
RemoveAt method removing dont remove at index : I have a little problem and im not sure where is it.Im still learing to coding and my exercise are to sum equal numbers in List<>,but when im using RemoveAt(int index), he dont remove at index,he removing last index from the whole list and everything gone wrong? Could u help me :) Thats my method :)
private static int GetNumberFromInput(List<int> input)
{
int sum = 0;
for (int i = 0; i < input.Count; i++)
{
if (i == input.Count - 1)
{
break;
}
if (input[i] == input[i + 1])
{
sum = input[i] + input[i + 1];
input.RemoveAt(i);
input[i] = sum;
i--;
}
if (input[i] != input[i + 1])
{
if(input[i+1] == input[i + 2])
{
sum = input[i + 1] + input[i + 2];
input.RemoveAt(input[i + 1]);
input[i + 1] = sum;
}
i--;
}
}
return sum;
}
| 0debug |
Combine a JS to conditional : <p>JS newbie here. I have a landing page with two options - once and regular (two buttons). we have to include a script to the page, but can't have both firing and rather need it to be conditional. </p>
<p>The scripts are like this:</p>
<pre><code> <!-- Regular Donation -->
<script type="text/javascript">
window.adalyserTracker("trackEvent", "lce3", {value: 0.00, a4:"Regular"}, true);
</script>
<!-- One-off Donation -->
<script type="text/javascript">
window.adalyserTracker("trackEvent", "lce3", {value: 0.00, a4:"Once"}, true);
</script>
</code></pre>
<p>Any ninjas out there who can help combine those quickly to one (e.g. if id on the button = once, use 'Once', if Id on the button = regular, use 'Regular') </p>
<p>Thanks in advance :) </p>
| 0debug |
static void omap_mcbsp_writew(void *opaque, target_phys_addr_t addr,
uint32_t value)
{
struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
int offset = addr & OMAP_MPUI_REG_MASK;
if (offset == 0x04) {
if (((s->xcr[0] >> 5) & 7) < 3)
return;
if (s->tx_req > 3) {
s->tx_req -= 4;
if (s->codec && s->codec->cts) {
s->codec->out.fifo[s->codec->out.len ++] =
(value >> 24) & 0xff;
s->codec->out.fifo[s->codec->out.len ++] =
(value >> 16) & 0xff;
s->codec->out.fifo[s->codec->out.len ++] =
(value >> 8) & 0xff;
s->codec->out.fifo[s->codec->out.len ++] =
(value >> 0) & 0xff;
}
if (s->tx_req < 4)
omap_mcbsp_tx_done(s);
} else
printf("%s: Tx FIFO overrun\n", __FUNCTION__);
return;
}
omap_badwidth_write16(opaque, addr, value);
}
| 1threat |
static int v4l2_receive_frame(AVCodecContext *avctx, AVFrame *frame)
{
V4L2m2mContext *s = avctx->priv_data;
V4L2Context *const capture = &s->capture;
V4L2Context *const output = &s->output;
AVPacket avpkt = {0};
int ret;
ret = ff_decode_get_packet(avctx, &avpkt);
if (ret < 0 && ret != AVERROR_EOF)
return ret;
if (s->draining)
goto dequeue;
ret = ff_v4l2_context_enqueue_packet(output, &avpkt);
if (ret < 0) {
if (ret != AVERROR(ENOMEM))
return ret;
}
if (avpkt.size) {
ret = v4l2_try_start(avctx);
if (ret)
return 0;
}
dequeue:
return ff_v4l2_context_dequeue_frame(capture, frame);
}
| 1threat |
To open a new window with navigation arrows(like both front and back arrows) using javascript : I am using a javascript function to launch a new window with the navigation bar but here its loading without navigation bar or arrow.My code is given below.
window.open("https://www.google.com", "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400");
Please if anyone can answer to load the new window with the navigation arrow
| 0debug |
What's The Best Practices To Store Large Data Into MYSQL Database : What's your best practice to store large data into MYSQL?
E.g I want to create a site showing second hand car details with following items:
1. List item
2. Car Name
3. Car Model
4. Car Brand Name
5. Car Info 4
6. Car Info 5
7. Car Info 6
8. Car Info 7
9. Car Description........
These are some of the (text) related information which I want to store and it might be more than 30 items.
Now, there are some Images and Videos related to the car, owner information and many other details.
Now, what's the best practice of storing large data into the database?
| 0debug |
import re
def check_literals(text, patterns):
for pattern in patterns:
if re.search(pattern, text):
return ('Matched!')
else:
return ('Not Matched!') | 0debug |
static void socket_sendf(int fd, const char *fmt, va_list ap)
{
gchar *str;
size_t size, offset;
str = g_strdup_vprintf(fmt, ap);
size = strlen(str);
offset = 0;
while (offset < size) {
ssize_t len;
len = write(fd, str + offset, size - offset);
if (len == -1 && errno == EINTR) {
continue;
}
g_assert_no_errno(len);
g_assert_cmpint(len, >, 0);
offset += len;
}
}
| 1threat |
cout will not display object in array (c++) : So I have an array with currently two objects. When ran, the display is "0".
#include "stdafx.h"
#include <process.h>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
using namespace std;
int lBlock = rand() % 99 + 10;
int rBlock = lBlock + 1;
string randBlock[15] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"};
string blocks[2] = {("0x", lBlock, randBlock[rand() % 14], "0"), ("0x", lBlock, randBlock[rand() % 14], "0")};
cout << blocks[1];
Any help will be greatly apreciated!
| 0debug |
reading a json file in R: lexical error: invalid char in json text : <p>Here is an example of the code I'm using: </p>
<pre><code>library(jsonlite)
library(curl)
#url
url = "http://www.zillow.com/search/GetResults.htm?spt=homes&status=001000&lt=000000&ht=010000&pr=999999,10000001&mp=3779,37788&bd=0%2C&ba=0%2C&sf=,&lot=0%2C&yr=,1800&singlestory=0&hoa=0%2C&pho=0&pets=0&parking=0&laundry=0&income-restricted=0&pnd=0&red=0&zso=0&days=36m&ds=all&pmf=0&pf=0&sch=100111&zoom=6&rect=-91307373,29367814,-84759521,35554574&p=1&sort=globalrelevanceex&search=maplist&rid=4&rt=2&listright=true&isMapSearch=true&zoom=6"
#json
results_data_json = fromJSON(txt = url)
</code></pre>
<p>I used to be able to run similar code to this with no issue. Now I'm getting the following error:</p>
<pre><code>Error in feed_push_parser(buf) :
lexical error: invalid char in json text.
<html><head><title>Zillow: Real
(right here) ------^
</code></pre>
<p>Any ideas around this?</p>
| 0debug |
How do I assign a value when rows header and column headers are matched in MS SQL 2012? : I have 400 columns and rows on my table. They are exactly same string value, you can imagine this as a matrix. However, the index values are blank and need to assign a value where the column and row names are same.
Example,
RIGHT NOW
## Column A ##, ## Column B ##
## Column A ##
## Column B ##
OUTPUT SHOULD LIKE THIS
## Column A ##, ## Column B ##
## Column A ## 6 10
## Column B ## 10 6
Can anybody help me get this output?
SQL answers greatly appreciated if not Excel functions will also work.
Thanks in advance!
| 0debug |
static void to_meta_with_crop(AVCodecContext *avctx, AVFrame *p, int *dest)
{
int blockx, blocky, x, y;
int luma = 0;
int height = FFMIN(avctx->height, C64YRES);
int width = FFMIN(avctx->width , C64XRES);
uint8_t *src = p->data[0];
for (blocky = 0; blocky < C64YRES; blocky += 8) {
for (blockx = 0; blockx < C64XRES; blockx += 8) {
for (y = blocky; y < blocky + 8 && y < C64YRES; y++) {
for (x = blockx; x < blockx + 8 && x < C64XRES; x += 2) {
if(x < width && y < height) {
luma = (src[(x + 0 + y * p->linesize[0])] +
src[(x + 1 + y * p->linesize[0])]) / 2;
dest[0] = luma;
}
dest++;
}
}
}
}
}
| 1threat |
How can I generate a 100% random number between 1 and the max of a 32 bit int in C# : <p>I would like to generate a random number that populates an int in C#. </p>
<p>I have heard that sometimes random numbers are not reliable. Would this be a problem for me to generate a random number?</p>
<p>Can someone comment on this and suggest a very reliable way to generate a random number between 1 and the max of a 32 bit int?</p>
| 0debug |
int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp)
{
int fd;
switch (remote->type) {
case SOCKET_ADDRESS_KIND_INET:
fd = inet_dgram_saddr(remote->u.inet, local ? local->u.inet : NULL, errp);
break;
default:
error_setg(errp, "socket type unsupported for datagram");
fd = -1;
}
return fd;
}
| 1threat |
static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx,
int is_chroma)
{
int blk;
int i, j, bx, by;
uint8_t *dst, *prev, *ref, *ref_start, *ref_end;
int v, col[2];
const uint8_t *scan;
int xoff, yoff;
LOCAL_ALIGNED_16(DCTELEM, block, [64]);
LOCAL_ALIGNED_16(uint8_t, ublock, [64]);
LOCAL_ALIGNED_16(int32_t, dctblock, [64]);
int coordmap[64];
const int stride = c->pic.linesize[plane_idx];
int bw = is_chroma ? (c->avctx->width + 15) >> 4 : (c->avctx->width + 7) >> 3;
int bh = is_chroma ? (c->avctx->height + 15) >> 4 : (c->avctx->height + 7) >> 3;
int width = c->avctx->width >> is_chroma;
init_lengths(c, FFMAX(width, 8), bw);
for (i = 0; i < BINK_NB_SRC; i++)
read_bundle(gb, c, i);
ref_start = c->last.data[plane_idx];
ref_end = c->last.data[plane_idx]
+ (bw - 1 + c->last.linesize[plane_idx] * (bh - 1)) * 8;
for (i = 0; i < 64; i++)
coordmap[i] = (i & 7) + (i >> 3) * stride;
for (by = 0; by < bh; by++) {
if (read_block_types(c->avctx, gb, &c->bundle[BINK_SRC_BLOCK_TYPES]) < 0)
return -1;
if (read_block_types(c->avctx, gb, &c->bundle[BINK_SRC_SUB_BLOCK_TYPES]) < 0)
return -1;
if (read_colors(gb, &c->bundle[BINK_SRC_COLORS], c) < 0)
return -1;
if (read_patterns(c->avctx, gb, &c->bundle[BINK_SRC_PATTERN]) < 0)
return -1;
if (read_motion_values(c->avctx, gb, &c->bundle[BINK_SRC_X_OFF]) < 0)
return -1;
if (read_motion_values(c->avctx, gb, &c->bundle[BINK_SRC_Y_OFF]) < 0)
return -1;
if (read_dcs(c->avctx, gb, &c->bundle[BINK_SRC_INTRA_DC], DC_START_BITS, 0) < 0)
return -1;
if (read_dcs(c->avctx, gb, &c->bundle[BINK_SRC_INTER_DC], DC_START_BITS, 1) < 0)
return -1;
if (read_runs(c->avctx, gb, &c->bundle[BINK_SRC_RUN]) < 0)
return -1;
if (by == bh)
break;
dst = c->pic.data[plane_idx] + 8*by*stride;
prev = c->last.data[plane_idx] + 8*by*stride;
for (bx = 0; bx < bw; bx++, dst += 8, prev += 8) {
blk = get_value(c, BINK_SRC_BLOCK_TYPES);
if ((by & 1) && blk == SCALED_BLOCK) {
bx++;
dst += 8;
prev += 8;
continue;
}
switch (blk) {
case SKIP_BLOCK:
c->dsp.put_pixels_tab[1][0](dst, prev, stride, 8);
break;
case SCALED_BLOCK:
blk = get_value(c, BINK_SRC_SUB_BLOCK_TYPES);
switch (blk) {
case RUN_BLOCK:
scan = bink_patterns[get_bits(gb, 4)];
i = 0;
do {
int run = get_value(c, BINK_SRC_RUN) + 1;
i += run;
if (i > 64) {
av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return -1;
}
if (get_bits1(gb)) {
v = get_value(c, BINK_SRC_COLORS);
for (j = 0; j < run; j++)
ublock[*scan++] = v;
} else {
for (j = 0; j < run; j++)
ublock[*scan++] = get_value(c, BINK_SRC_COLORS);
}
} while (i < 63);
if (i == 63)
ublock[*scan++] = get_value(c, BINK_SRC_COLORS);
break;
case INTRA_BLOCK:
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTRA_DC);
read_dct_coeffs(gb, dctblock, bink_scan, bink_intra_quant, -1);
c->bdsp.idct_put(ublock, 8, dctblock);
break;
case FILL_BLOCK:
v = get_value(c, BINK_SRC_COLORS);
c->dsp.fill_block_tab[0](dst, v, stride, 16);
break;
case PATTERN_BLOCK:
for (i = 0; i < 2; i++)
col[i] = get_value(c, BINK_SRC_COLORS);
for (j = 0; j < 8; j++) {
v = get_value(c, BINK_SRC_PATTERN);
for (i = 0; i < 8; i++, v >>= 1)
ublock[i + j*8] = col[v & 1];
}
break;
case RAW_BLOCK:
for (j = 0; j < 8; j++)
for (i = 0; i < 8; i++)
ublock[i + j*8] = get_value(c, BINK_SRC_COLORS);
break;
default:
av_log(c->avctx, AV_LOG_ERROR, "Incorrect 16x16 block type %d\n", blk);
return -1;
}
if (blk != FILL_BLOCK)
c->bdsp.scale_block(ublock, dst, stride);
bx++;
dst += 8;
prev += 8;
break;
case MOTION_BLOCK:
xoff = get_value(c, BINK_SRC_X_OFF);
yoff = get_value(c, BINK_SRC_Y_OFF);
ref = prev + xoff + yoff * stride;
if (ref < ref_start || ref > ref_end) {
av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n",
bx*8 + xoff, by*8 + yoff);
return -1;
}
c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
break;
case RUN_BLOCK:
scan = bink_patterns[get_bits(gb, 4)];
i = 0;
do {
int run = get_value(c, BINK_SRC_RUN) + 1;
i += run;
if (i > 64) {
av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return -1;
}
if (get_bits1(gb)) {
v = get_value(c, BINK_SRC_COLORS);
for (j = 0; j < run; j++)
dst[coordmap[*scan++]] = v;
} else {
for (j = 0; j < run; j++)
dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS);
}
} while (i < 63);
if (i == 63)
dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS);
break;
case RESIDUE_BLOCK:
xoff = get_value(c, BINK_SRC_X_OFF);
yoff = get_value(c, BINK_SRC_Y_OFF);
ref = prev + xoff + yoff * stride;
if (ref < ref_start || ref > ref_end) {
av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n",
bx*8 + xoff, by*8 + yoff);
return -1;
}
c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
c->dsp.clear_block(block);
v = get_bits(gb, 7);
read_residue(gb, block, v);
c->dsp.add_pixels8(dst, block, stride);
break;
case INTRA_BLOCK:
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTRA_DC);
read_dct_coeffs(gb, dctblock, bink_scan, bink_intra_quant, -1);
c->bdsp.idct_put(dst, stride, dctblock);
break;
case FILL_BLOCK:
v = get_value(c, BINK_SRC_COLORS);
c->dsp.fill_block_tab[1](dst, v, stride, 8);
break;
case INTER_BLOCK:
xoff = get_value(c, BINK_SRC_X_OFF);
yoff = get_value(c, BINK_SRC_Y_OFF);
ref = prev + xoff + yoff * stride;
c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTER_DC);
read_dct_coeffs(gb, dctblock, bink_scan, bink_inter_quant, -1);
c->bdsp.idct_add(dst, stride, dctblock);
break;
case PATTERN_BLOCK:
for (i = 0; i < 2; i++)
col[i] = get_value(c, BINK_SRC_COLORS);
for (i = 0; i < 8; i++) {
v = get_value(c, BINK_SRC_PATTERN);
for (j = 0; j < 8; j++, v >>= 1)
dst[i*stride + j] = col[v & 1];
}
break;
case RAW_BLOCK:
for (i = 0; i < 8; i++)
memcpy(dst + i*stride, c->bundle[BINK_SRC_COLORS].cur_ptr + i*8, 8);
c->bundle[BINK_SRC_COLORS].cur_ptr += 64;
break;
default:
av_log(c->avctx, AV_LOG_ERROR, "Unknown block type %d\n", blk);
return -1;
}
}
}
if (get_bits_count(gb) & 0x1F)
skip_bits_long(gb, 32 - (get_bits_count(gb) & 0x1F));
return 0;
}
| 1threat |
reading a single chr from a string? : hello i am doing an exercise in C which takes a string like (a8$£de95") from the user and searches for letters (the smallest and largest) and then types the smallest and the largest letter and whatever letters in-between in this example it should show "abcde" and after this it types 2 letters which are already in order in which case they are "de" .
now i wrote a basic program to help get an understanding of characters as i have not solved any char/sting exercise before (all the previous exercises where with numbers only) . i wrote
char y;
printf("enter your string:- ");
scanf("%s",&y);
printf("%c",&y[2]);
return 0;
but it shows me nothing so my question is How do i read 1 character from a string and how do the computer knows what is the smallest and largest letter and how to i make him type the letters in between ?
thanks | 0debug |
React-native unable to run-android : <p>Following this: <a href="https://facebook.github.io/react-native/docs/getting-started.html" rel="noreferrer">https://facebook.github.io/react-native/docs/getting-started.html</a> ,
I've created an empty project and am trying to run it by doing:
sudo react-native run-android
This is what is produced:</p>
<pre><code>Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug...
Downloading https://services.gradle.org/distributions/gradle-2.4-all.zip
Exception in thread "main" javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
</code></pre>
<p>(I can post the rest of the error if that would be useful). Does anyone have any advice?</p>
| 0debug |
C# Use 'this' Keyword in a class : <p>i have a code for creating a LineShape from two points .</p>
<pre><code>class MyMenu
{
public static void AddLine()
{
ShapeContainer canvas = new ShapeContainer();
LineShape theLine = new LineShape();
canvas.Parent = this;
theLine.Parent = canvas;
theLine.BorderColor = SystemColors.ControlDarkDark;
theLine.StartPoint = new System.Drawing.Point(-3, 154);
theLine.EndPoint = new System.Drawing.Point(212, 154);
}
}
</code></pre>
<p>. i want to create a class and use from there but i end up having an error .</p>
<pre><code>Keyword 'this' is not valid in a static property, static method, or static field initializer
</code></pre>
<p>i tried to fix it like this but nothing !</p>
<pre><code> Form1 MyForm = new Form1();
canvas.Parent = MyForm;
</code></pre>
<p>Thanks you !</p>
| 0debug |
void qemu_get_timer(QEMUFile *f, QEMUTimer *ts)
{
uint64_t expire_time;
expire_time = qemu_get_be64(f);
if (expire_time != -1) {
qemu_mod_timer(ts, expire_time);
} else {
qemu_del_timer(ts);
}
}
| 1threat |
Given a singly linked list, group all odd nodes together followed by the even nodes. : Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.
You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity.
Example:
Given 1->2->3->4->5->NULL,
return 1->3->5->2->4->NULL.
I have seen the solution but I can't understand it, I need someone to visually explain the solution to the problem. | 0debug |
How can I solve this problem without using lists? : <p>Problem: You're a swimmer, and you want to compare all of your race times to find the fastest one. Write a program that continuously takes race times as doubles from standard input, until the input is "no more races," at which point it should print out the time of your fastest race.</p>
<p>The answer I found on another thread was using lists like:</p>
<pre><code>list1 = []
race_time = input("Enter a race time or type no more races to quit: ")
while race_time != "no more races":
list1.append(float(race_time))
race_time = input("Enter a race time or type no more races to quit ")
print(min(list1))
</code></pre>
<p>The problem is from if-else, and loops chapter and lists aren't introduced to us yet. How would I store the race times and compare them?</p>
| 0debug |
Scala object call with a brackets. What is going on? : In a Scala codebase I see this:
override def borrow(implicit doLater: DoLater): Borrow = {
...
doLater({
store.shutdown(10.seconds)
close()
})
...
The above code gets called like this:
val d = new DoLater
try {
f(d)
and `f` is a function that looks like this:
implicit doLater =>
val borrows = borrow
What is going on in above `doLater({...` call? Is it going to call the apply method and pass in this bracketed thing? `doLater` in the `borrow` method is an instance of the `DoLater` class right? What is the bracketed thing? Is it an anonymous class?
the `doLater` is an instance of this class:
class DoLater {
var thingsToDo: Seq[() => Unit] = Seq.empty
override def apply(d: => Unit) = {
thingsToDo = d _ +: thingsToDo
}
...
I'm jsut trying to figure our, Scala-Wise... what is going on in the `doLater({...` call.
| 0debug |
How reliable is double-slash comment in CSS : <p>As the headline says, how reliable is double-slash for single-line comment in CSS. Whats your experience of using sinlge comments like this?</p>
| 0debug |
void ff_vp3_idct_put_altivec(uint8_t *dst, int stride, DCTELEM block[64])
{
vec_u8 t;
IDCT_START
vec_s16 v2048 = vec_sl(vec_splat_s16(1), vec_splat_u16(11));
eight = vec_add(eight, v2048);
IDCT_1D(NOP, NOP)
TRANSPOSE8(b0, b1, b2, b3, b4, b5, b6, b7);
IDCT_1D(ADD8, SHIFT4)
#define PUT(a)\
t = vec_packsu(a, a);\
vec_ste((vec_u32)t, 0, (unsigned int *)dst);\
vec_ste((vec_u32)t, 4, (unsigned int *)dst);
PUT(b0) dst += stride;
PUT(b1) dst += stride;
PUT(b2) dst += stride;
PUT(b3) dst += stride;
PUT(b4) dst += stride;
PUT(b5) dst += stride;
PUT(b6) dst += stride;
PUT(b7)
}
| 1threat |
static void gen_sraq(DisasContext *ctx)
{
int l1 = gen_new_label();
int l2 = gen_new_label();
TCGv t0 = tcg_temp_new();
TCGv t1 = tcg_temp_local_new();
TCGv t2 = tcg_temp_local_new();
tcg_gen_andi_tl(t2, cpu_gpr[rB(ctx->opcode)], 0x1F);
tcg_gen_shr_tl(t0, cpu_gpr[rS(ctx->opcode)], t2);
tcg_gen_sar_tl(t1, cpu_gpr[rS(ctx->opcode)], t2);
tcg_gen_subfi_tl(t2, 32, t2);
tcg_gen_shl_tl(t2, cpu_gpr[rS(ctx->opcode)], t2);
tcg_gen_or_tl(t0, t0, t2);
gen_store_spr(SPR_MQ, t0);
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x20);
tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 0, l1);
tcg_gen_mov_tl(t2, cpu_gpr[rS(ctx->opcode)]);
tcg_gen_sari_tl(t1, cpu_gpr[rS(ctx->opcode)], 31);
gen_set_label(l1);
tcg_temp_free(t0);
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t1);
tcg_gen_movi_tl(cpu_ca, 0);
tcg_gen_brcondi_tl(TCG_COND_GE, t1, 0, l2);
tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 0, l2);
tcg_gen_movi_tl(cpu_ca, 1);
gen_set_label(l2);
tcg_temp_free(t1);
tcg_temp_free(t2);
if (unlikely(Rc(ctx->opcode) != 0))
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
}
| 1threat |
int use_gdb_syscalls(void)
{
if (gdb_syscall_mode == GDB_SYS_UNKNOWN) {
gdb_syscall_mode = (gdb_syscall_state ? GDB_SYS_ENABLED
: GDB_SYS_DISABLED);
}
return gdb_syscall_mode == GDB_SYS_ENABLED;
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.