problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
void ff_simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block)
{
int i;
DCTELEM *ptr;
ptr = block;
for(i=0;i<4;i++) {
BF(0);
BF(1);
BF(2);
BF(3);
BF(4);
BF(5);
BF(6);
BF(7);
ptr += 2 * 8;
}
for(i=0; i<8; i++) {
idctRowCondDC_8(block + i*8);
}
for(i=0;i<8;i++) {
idct4col_put(dest + i, 2 * line_size, block + i);
idct4col_put(dest + line_size + i, 2 * line_size, block + 8 + i);
}
}
| 1threat |
RegEx not match if matched in previous group : I have some HTML pages and I want to match some pattern but not in comment.
So let's say i have for example following part of page:
<div>
<div>Hello $world$</div>
<div>Another text <!-- $example$--></div>
</div>
<div>
How are $you$?
</div>
<!--
<div>
Lorem ipsum $dolor$ sit
</div>
-->
And I need to match $world$ and $you$ but not match $example$ and $dolor$.
I tried do it on my own but i was able to match only all of them or none of them.
Do you have any ideas?
Unfortunately I cannot first delete all comments and then match what is needed, because finally I have to save my results and comments should still be there. | 0debug |
static int ebml_parse_elem(MatroskaDemuxContext *matroska,
EbmlSyntax *syntax, void *data)
{
static const uint64_t max_lengths[EBML_TYPE_COUNT] = {
[EBML_UINT] = 8,
[EBML_FLOAT] = 8,
[EBML_STR] = 0x1000000,
[EBML_UTF8] = 0x1000000,
[EBML_BIN] = 0x10000000,
};
AVIOContext *pb = matroska->ctx->pb;
uint32_t id = syntax->id;
uint64_t length;
int res;
data = (char *)data + syntax->data_offset;
if (syntax->list_elem_size) {
EbmlList *list = data;
list->elem = av_realloc(list->elem, (list->nb_elem+1)*syntax->list_elem_size);
data = (char*)list->elem + list->nb_elem*syntax->list_elem_size;
memset(data, 0, syntax->list_elem_size);
list->nb_elem++;
}
if (syntax->type != EBML_PASS && syntax->type != EBML_STOP) {
matroska->current_id = 0;
if ((res = ebml_read_length(matroska, pb, &length)) < 0)
return res;
if (max_lengths[syntax->type] && length > max_lengths[syntax->type]) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Invalid length 0x%"PRIx64" > 0x%"PRIx64" for syntax element %i\n",
length, max_lengths[syntax->type], syntax->type);
return AVERROR_INVALIDDATA;
}
}
switch (syntax->type) {
case EBML_UINT: res = ebml_read_uint (pb, length, data); break;
case EBML_FLOAT: res = ebml_read_float (pb, length, data); break;
case EBML_STR:
case EBML_UTF8: res = ebml_read_ascii (pb, length, data); break;
case EBML_BIN: res = ebml_read_binary(pb, length, data); break;
case EBML_NEST: if ((res=ebml_read_master(matroska, length)) < 0)
return res;
if (id == MATROSKA_ID_SEGMENT)
matroska->segment_start = avio_tell(matroska->ctx->pb);
return ebml_parse_nest(matroska, syntax->def.n, data);
case EBML_PASS: return ebml_parse_id(matroska, syntax->def.n, id, data);
case EBML_STOP: return 1;
default: return avio_skip(pb,length)<0 ? AVERROR(EIO) : 0;
}
if (res == AVERROR_INVALIDDATA)
av_log(matroska->ctx, AV_LOG_ERROR, "Invalid element\n");
else if (res == AVERROR(EIO))
av_log(matroska->ctx, AV_LOG_ERROR, "Read error\n");
return res;
}
| 1threat |
static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt)
{
struct tcphdr *ptcp, *stcp;
int res;
trace_colo_compare_main("compare tcp");
ptcp = (struct tcphdr *)ppkt->transport_header;
stcp = (struct tcphdr *)spkt->transport_header;
if (ntohs(ppkt->ip->ip_off) & IP_DF) {
spkt->ip->ip_id = ppkt->ip->ip_id;
spkt->ip->ip_sum = ppkt->ip->ip_sum;
}
if (ptcp->th_sum == stcp->th_sum) {
res = colo_packet_compare_common(ppkt, spkt, ETH_HLEN);
} else {
res = -1;
}
if (res != 0 && trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {
trace_colo_compare_pkt_info_src(inet_ntoa(ppkt->ip->ip_src),
ntohl(stcp->th_seq),
ntohl(stcp->th_ack),
res, stcp->th_flags,
spkt->size);
trace_colo_compare_pkt_info_dst(inet_ntoa(ppkt->ip->ip_dst),
ntohl(ptcp->th_seq),
ntohl(ptcp->th_ack),
res, ptcp->th_flags,
ppkt->size);
qemu_hexdump((char *)ppkt->data, stderr,
"colo-compare ppkt", ppkt->size);
qemu_hexdump((char *)spkt->data, stderr,
"colo-compare spkt", spkt->size);
}
return res;
}
| 1threat |
How to print data from database? : <p>I am supposed to create webpage with a list of literature, where admin will maintain the list and users will be able to choose the books and print a list. I already have the web app done, but I have no idea, how to print it. Definetly some button, which will print just the data in a list. Any ideas ?</p>
| 0debug |
Mounting Volume as part of a multi-stage build : <p>How can I mount a volume to store my .m2 repo so I don't have to download the internet on every build?</p>
<p>My build is a Multi stage build:</p>
<pre><code>FROM maven:3.5-jdk-8 as BUILD
COPY . /usr/src/app
RUN mvn --batch-mode -f /usr/src/app/pom.xml clean package
FROM openjdk:8-jdk
COPY --from=BUILD /usr/src/app/target /opt/target
WORKDIR /opt/target
CMD ["/bin/bash", "-c", "find -type f -name '*.jar' | xargs java -jar"]
</code></pre>
| 0debug |
import re
def replace_specialchar(text):
return (re.sub("[ ,.]", ":", text))
| 0debug |
Simulate display: inline in React Native : <p>React Native doesn't support the CSS <code>display</code> property, and by default all elements use the behavior of <code>display: flex</code> (no <code>inline-flex</code> either). Most non-flex layouts can be simulated with flex properties, but I'm flustered with inline text.</p>
<p>My app has a container that contains several words in text, some of which need formatting. This means I need to use spans to accomplish the formatting. In order to achieve wrapping of the spans, I can set the container to use <code>flex-wrap: wrap</code>, but this will only allow wrapping at the end of a span rather than the traditional inline behavior of wrapping at word breaks.</p>
<p>The problem visualized (spans in yellow):</p>
<p><a href="https://i.stack.imgur.com/CgR94.png" rel="noreferrer"><img src="https://i.stack.imgur.com/CgR94.png" alt="enter image description here"></a></p>
<p>(via <a href="http://codepen.io/anon/pen/GoWmdm?editors=110" rel="noreferrer">http://codepen.io/anon/pen/GoWmdm?editors=110</a>)</p>
<p>Is there a way to get proper wrapping and true inline simulation using flex properties?</p>
| 0debug |
Why Does code.runnable.com Allow Me to Change a Variable's Value in Java? : <p>I heard that Java integers are <strong>pass by value</strong>, so why does the following code work in code.runnable.com? </p>
<pre><code>public class HelloWorld {
public static void main(String[] args) {
int number = 0;
number = 2;
System.out.println(number);
}
}
</code></pre>
<p>The code will print out <strong>2</strong>.</p>
| 0debug |
how to write standard deviation? : do i calculate my standard deviation in the loop. also i know the formula for standard deviation just not how to get it to accept the numbers from the users. im new to programming so explain everything. also dont mind my sorry attempt at trying to write out Standard deviation formula it wasnt meant to work just to understand SD more
import java.util.Scanner;
public class readFromKeyboard {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String inStr = input.next();
int n;
int i;
int count=0;
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
double average=0;
int sum;
double deviation = 0;
while (!inStr.equals("EOL")) {
count++;
n = Integer.parseInt(inStr);
min = Math.min(min, n);
max = Math.max(max, n);
System.out.printf("%d ", n);
inStr = input.next();
average += n;
// really bad attempt here
deviation = math.pow(n / average,2) ++ / mean sqrt();
}
average = average/count;
System.out.println("\n The average of these numbers is " + average);
System.out.printf("The list has %d numbers\n", count);
System.out.printf("The minimum of the list is %d\n", min);
System.out.printf("The maximum of the list is %d\n", max);
input.close();
}
}
| 0debug |
static int xenfb_map_fb(struct XenFB *xenfb)
{
struct xenfb_page *page = xenfb->c.page;
char *protocol = xenfb->c.xendev.protocol;
int n_fbdirs;
xen_pfn_t *pgmfns = NULL;
xen_pfn_t *fbmfns = NULL;
void *map, *pd;
int mode, ret = -1;
pd = page->pd;
mode = sizeof(unsigned long) * 8;
if (!protocol) {
uint32_t *ptr32 = NULL;
uint32_t *ptr64 = NULL;
#if defined(__i386__)
ptr32 = (void*)page->pd;
ptr64 = ((void*)page->pd) + 4;
#elif defined(__x86_64__)
ptr32 = ((void*)page->pd) - 4;
ptr64 = (void*)page->pd;
#endif
if (ptr32) {
if (ptr32[1] == 0) {
mode = 32;
pd = ptr32;
} else {
mode = 64;
pd = ptr64;
}
}
#if defined(__x86_64__)
} else if (strcmp(protocol, XEN_IO_PROTO_ABI_X86_32) == 0) {
mode = 32;
pd = ((void*)page->pd) - 4;
#elif defined(__i386__)
} else if (strcmp(protocol, XEN_IO_PROTO_ABI_X86_64) == 0) {
mode = 64;
pd = ((void*)page->pd) + 4;
#endif
}
if (xenfb->pixels) {
munmap(xenfb->pixels, xenfb->fbpages * XC_PAGE_SIZE);
xenfb->pixels = NULL;
}
xenfb->fbpages = (xenfb->fb_len + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE;
n_fbdirs = xenfb->fbpages * mode / 8;
n_fbdirs = (n_fbdirs + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE;
pgmfns = g_malloc0(sizeof(xen_pfn_t) * n_fbdirs);
fbmfns = g_malloc0(sizeof(xen_pfn_t) * xenfb->fbpages);
xenfb_copy_mfns(mode, n_fbdirs, pgmfns, pd);
map = xc_map_foreign_pages(xen_xc, xenfb->c.xendev.dom,
PROT_READ, pgmfns, n_fbdirs);
if (map == NULL)
goto out;
xenfb_copy_mfns(mode, xenfb->fbpages, fbmfns, map);
munmap(map, n_fbdirs * XC_PAGE_SIZE);
xenfb->pixels = xc_map_foreign_pages(xen_xc, xenfb->c.xendev.dom,
PROT_READ, fbmfns, xenfb->fbpages);
if (xenfb->pixels == NULL)
goto out;
ret = 0;
out:
g_free(pgmfns);
g_free(fbmfns);
return ret;
}
| 1threat |
static int cris_mmu_enabled(uint32_t rw_gc_cfg)
{
return (rw_gc_cfg & 12) != 0;
}
| 1threat |
Regular expresion : I'm trying to understand regex, and I want to prevent entering numbers starting with 550, if length is 8, or starting with 393 if length is 5.
Tried it here (https://regex101.com/) and the correct expression is shown below
^((?!550)\d{8}|(?!393)\d{5})$
but the mask in my code works in «online» mode, and for some reason allows only numbers starting with 550 or 393, the rest of the input is forbidden (can't even enter 10000). How to remake this expression?
| 0debug |
static void vp9_superframe_close(AVBSFContext *ctx)
{
VP9BSFContext *s = ctx->priv_data;
int n;
for (n = 0; n < s->n_cache; n++)
av_packet_free(&s->cache[n]);
}
| 1threat |
I am trying to write a haskell function that takes a list of dates and a month and returns how many dates in the list match the given month : this is what I have so far and it doesn't seem to be working
numInMonth :: [(Int,Int,Int)] -> Int -> Int
numInMonth x [] = x
numInMonth x (y:ys)
minList1 (x:xs) = currentMin x xs
currentMax :: Int -> [Int] -> Int
currentMax x [] = x
currentMax x (y:ys)
| x >= y = currentMax x ys
| otherwise = currentMax y ys
maxList1 :: [Int] -> Int
maxList1 (x:xs) = currentMax x xs | 0debug |
document.write('<script src="evil.js"></script>'); | 1threat |
RxJava 2.0 - How to convert Observable to Publisher : <p>How to convert Observable to Publisher in RxJava version 2?</p>
<p>In the first version we have the <a href="https://github.com/ReactiveX/RxJavaReactiveStreams" rel="noreferrer">https://github.com/ReactiveX/RxJavaReactiveStreams</a> project that do exactly what I need.
But How can I do it in RxJava 2?</p>
| 0debug |
How to configure exim4 to send & receive email on a VPS using my own domain name? : <p>I just bought a new "public cloud" to put my new website on it.</p>
<p>This public cloud is in "advanced zone", which means that every instance I deploy is in a NAT network with private IP (10.1.1.x), and there is a firewall in front of the global network to control IN and OUT ports.</p>
<p>I have deployed two instances with Debian 8, one for webserver & the other one for the database.
I have my own domain name (let's say "mydomain.com"), and I want my website to be able to send email using this domain name (FROM would be "no-reply@mydomain.com") and I would like to receive emails sent by users of the website (TO contact@mydomain.com) using a Thunderbird or Outlook for example.</p>
<p>Exim4 was already installed on the webserver (installed by default in Debian 8), I used <code>dpkg-reconfigure exim4-config</code> to reconfigure it. Here is the content of my different files.</p>
<p>/etc/exim4/update-exim4.conf.conf</p>
<pre><code>dc_eximconfig_configtype='internet'
dc_other_hostnames='contact.mydomain.com'
dc_local_interfaces='127.0.0.1'
dc_readhost=''
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost=''
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname=''
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'
</code></pre>
<p>/etc/hosts :</p>
<pre><code>ROUTER_IP mydomain.com contact
</code></pre>
<p>/etc/hostname :</p>
<pre><code>contact
</code></pre>
<p>/etc/email-addresses :</p>
<pre><code>contact@mydomain.com
</code></pre>
<p>When I type <code>hostname</code> : contact<br>
When I type <code>hostname -d</code> : com<br>
When I type <code>hostname -f</code> : mydomain.com</p>
<p>In my DNS I created a zone with SPF type to avoid spam. Here it is :</p>
<pre><code>TTL = 600 / Target = "v=spf1 a mx ptr ~all"
</code></pre>
<p>I tried to send an email using this command :</p>
<pre><code>echo "This is a test." | mail -s Testing myownaddress@gmail.com
</code></pre>
<p>When I'm sending an email to gmail, I receive an email from <code>root (root@mydomain.com)</code> and not <code>contact@mydomain.com</code></p>
<p>When I'm sending an email to my own personnal address, I have an error in exim4 mainlog <code>/var/log/exim4/mainlog</code> :</p>
<pre><code>SMTP error from remote mail server after RCPT TO:<johnny@myserver.com>: host mail.myserver.com [37.xx.xx.Xx]: 504 5.5.2 <contact>: Helo command rejected: need fully-qualified hostname
</code></pre>
<p>I don't understand what I'm doing wrong. Do you have any idea on this please ?</p>
<p>Thanks in advance !<br>
Regards,<br>
Julien Q.</p>
| 0debug |
Amazon Redhisft: Re-occurring date for public holiday table : I am trying to create a table for the public holiday for the countries we deal with. However, I want the dates to be re-occurring so that I can apply a date key for each.
For example, if I have 2018-06-16 and 2018-12-25 as a public holiday, then I want the table to auto-generate 2019-06-16 and 2018-12-25 and so on without me adding it manually each time.
Anyone knows how this can be done in amazon redshift? | 0debug |
static int decode_chunks(AVCodecContext *avctx,
AVFrame *picture, int *got_output,
const uint8_t *buf, int buf_size)
{
Mpeg1Context *s = avctx->priv_data;
MpegEncContext *s2 = &s->mpeg_enc_ctx;
const uint8_t *buf_ptr = buf;
const uint8_t *buf_end = buf + buf_size;
int ret, input_size;
int last_code = 0;
for (;;) {
uint32_t start_code = -1;
buf_ptr = avpriv_mpv_find_start_code(buf_ptr, buf_end, &start_code);
if (start_code > 0x1ff) {
if (s2->pict_type != AV_PICTURE_TYPE_B || avctx->skip_frame <= AVDISCARD_DEFAULT) {
if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE)) {
int i;
avctx->execute(avctx, slice_decode_thread, &s2->thread_context[0], NULL, s->slice_count, sizeof(void*));
for (i = 0; i < s->slice_count; i++)
s2->error_count += s2->thread_context[i]->error_count;
}
if (CONFIG_MPEG_VDPAU_DECODER && avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_mpeg_picture_complete(s2, buf, buf_size, s->slice_count);
if (slice_end(avctx, picture)) {
if (s2->last_picture_ptr || s2->low_delay)
*got_output = 1;
}
}
s2->pict_type = 0;
return FFMAX(0, buf_ptr - buf - s2->parse_context.last_index);
}
input_size = buf_end - buf_ptr;
if (avctx->debug & FF_DEBUG_STARTCODE) {
av_log(avctx, AV_LOG_DEBUG, "%3X at %td left %d\n", start_code, buf_ptr-buf, input_size);
}
switch (start_code) {
case SEQ_START_CODE:
if (last_code == 0) {
mpeg1_decode_sequence(avctx, buf_ptr, input_size);
s->sync=1;
} else {
av_log(avctx, AV_LOG_ERROR, "ignoring SEQ_START_CODE after %X\n", last_code);
if (avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
break;
case PICTURE_START_CODE:
if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE) && s->slice_count) {
int i;
avctx->execute(avctx, slice_decode_thread,
s2->thread_context, NULL,
s->slice_count, sizeof(void*));
for (i = 0; i < s->slice_count; i++)
s2->error_count += s2->thread_context[i]->error_count;
s->slice_count = 0;
}
if (last_code == 0 || last_code == SLICE_MIN_START_CODE) {
ret = mpeg_decode_postinit(avctx);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "mpeg_decode_postinit() failure\n");
return ret;
}
if (mpeg1_decode_picture(avctx, buf_ptr, input_size) < 0)
s2->pict_type = 0;
s2->first_slice = 1;
last_code = PICTURE_START_CODE;
} else {
av_log(avctx, AV_LOG_ERROR, "ignoring pic after %X\n", last_code);
if (avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
break;
case EXT_START_CODE:
init_get_bits(&s2->gb, buf_ptr, input_size*8);
switch (get_bits(&s2->gb, 4)) {
case 0x1:
if (last_code == 0) {
mpeg_decode_sequence_extension(s);
} else {
av_log(avctx, AV_LOG_ERROR, "ignoring seq ext after %X\n", last_code);
if (avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
break;
case 0x2:
mpeg_decode_sequence_display_extension(s);
break;
case 0x3:
mpeg_decode_quant_matrix_extension(s2);
break;
case 0x7:
mpeg_decode_picture_display_extension(s);
break;
case 0x8:
if (last_code == PICTURE_START_CODE) {
mpeg_decode_picture_coding_extension(s);
} else {
av_log(avctx, AV_LOG_ERROR, "ignoring pic cod ext after %X\n", last_code);
if (avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
break;
}
break;
case USER_START_CODE:
mpeg_decode_user_data(avctx, buf_ptr, input_size);
break;
case GOP_START_CODE:
if (last_code == 0) {
s2->first_field=0;
mpeg_decode_gop(avctx, buf_ptr, input_size);
s->sync=1;
} else {
av_log(avctx, AV_LOG_ERROR, "ignoring GOP_START_CODE after %X\n", last_code);
if (avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
break;
default:
if (start_code >= SLICE_MIN_START_CODE &&
start_code <= SLICE_MAX_START_CODE && last_code != 0) {
const int field_pic = s2->picture_structure != PICT_FRAME;
int mb_y = (start_code - SLICE_MIN_START_CODE) << field_pic;
last_code = SLICE_MIN_START_CODE;
if (s2->picture_structure == PICT_BOTTOM_FIELD)
mb_y++;
if (mb_y >= s2->mb_height) {
av_log(s2->avctx, AV_LOG_ERROR, "slice below image (%d >= %d)\n", mb_y, s2->mb_height);
return -1;
}
if (s2->last_picture_ptr == NULL) {
if (s2->pict_type == AV_PICTURE_TYPE_B) {
if (!s->closed_gop)
break;
}
}
if (s2->pict_type == AV_PICTURE_TYPE_I)
s->sync=1;
if (s2->next_picture_ptr == NULL) {
if (s2->pict_type == AV_PICTURE_TYPE_P && !s->sync) break;
}
if ((avctx->skip_frame >= AVDISCARD_NONREF && s2->pict_type == AV_PICTURE_TYPE_B) ||
(avctx->skip_frame >= AVDISCARD_NONKEY && s2->pict_type != AV_PICTURE_TYPE_I) ||
avctx->skip_frame >= AVDISCARD_ALL)
break;
if (!s->mpeg_enc_ctx_allocated)
break;
if (s2->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
if (mb_y < avctx->skip_top || mb_y >= s2->mb_height - avctx->skip_bottom)
break;
}
if (!s2->pict_type) {
av_log(avctx, AV_LOG_ERROR, "Missing picture start code\n");
if (avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
break;
}
if (s2->first_slice) {
s2->first_slice = 0;
if (mpeg_field_start(s2, buf, buf_size) < 0)
return -1;
}
if (!s2->current_picture_ptr) {
av_log(avctx, AV_LOG_ERROR, "current_picture not initialized\n");
return AVERROR_INVALIDDATA;
}
if (avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) {
s->slice_count++;
break;
}
if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE)) {
int threshold = (s2->mb_height * s->slice_count +
s2->slice_context_count / 2) /
s2->slice_context_count;
if (threshold <= mb_y) {
MpegEncContext *thread_context = s2->thread_context[s->slice_count];
thread_context->start_mb_y = mb_y;
thread_context->end_mb_y = s2->mb_height;
if (s->slice_count) {
s2->thread_context[s->slice_count-1]->end_mb_y = mb_y;
ff_update_duplicate_context(thread_context, s2);
}
init_get_bits(&thread_context->gb, buf_ptr, input_size*8);
s->slice_count++;
}
buf_ptr += 2;
} else {
ret = mpeg_decode_slice(s2, mb_y, &buf_ptr, input_size);
emms_c();
if (ret < 0) {
if (avctx->err_recognition & AV_EF_EXPLODE)
return ret;
if (s2->resync_mb_x >= 0 && s2->resync_mb_y >= 0)
ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, ER_AC_ERROR | ER_DC_ERROR | ER_MV_ERROR);
} else {
ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x-1, s2->mb_y, ER_AC_END | ER_DC_END | ER_MV_END);
}
}
}
break;
}
}
}
| 1threat |
static av_cold int mss2_decode_init(AVCodecContext *avctx)
{
MSS2Context * const ctx = avctx->priv_data;
MSS12Context *c = &ctx->c;
int ret;
c->avctx = avctx;
avctx->coded_frame = &ctx->pic;
if (ret = ff_mss12_decode_init(c, 1, &ctx->sc[0], &ctx->sc[1]))
return ret;
c->pal_stride = c->mask_stride;
c->pal_pic = av_malloc(c->pal_stride * avctx->height);
c->last_pal_pic = av_malloc(c->pal_stride * avctx->height);
if (!c->pal_pic || !c->last_pal_pic) {
mss2_decode_end(avctx);
return AVERROR(ENOMEM);
}
if (ret = wmv9_init(avctx)) {
mss2_decode_end(avctx);
return ret;
}
ff_mss2dsp_init(&ctx->dsp);
avctx->pix_fmt = c->free_colours == 127 ? AV_PIX_FMT_RGB555
: AV_PIX_FMT_RGB24;
return 0;
}
| 1threat |
cant define a variable in html : guys i cant define variable in html .. here is my code
sb.appendHtmlConstant("<div id='Button +"i"' class=\"" + getClass(c.getIndex()) + "\">");
here i cant define "i" to be a variable .. any help please ??
thanks a lot
| 0debug |
Manipulating css on iframe : i have `iframe` embed external website to my website, but text, button and content very large.
how to manipulate the content?
content like
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/XfO5l.png
my code:
<div class="row-container">
<div class="poker_content" [ngClass]="{'not-opened': iframeUrl === null}">
<iframe [src]="iframeUrl | safe" *ngIf="showIframe"></iframe>
</div>
</div>
| 0debug |
How to get the duration of video using cv2 : <p>I can only get the number of frames <code>CAP_PROP_FRAME_COUNT</code> using CV2.</p>
<p>However, I cannot find the parameter to get the duration of the video using cv2. </p>
<p>How to do that? </p>
<p>Thank you very much.</p>
| 0debug |
How to check for an intermediate page while Automating in Selenium : <p>There is an option to turn the intermediate page ON/OFF.
How to navigate to the page if the page is present. If not present how to continue the code.</p>
| 0debug |
can i reference a random function's values with a list? : i have a list of different characters, three of which are randomly chosen each time i run the program. if my functions look like this (with each string in the list referencing to these functions)
`public void Character1()
{ agility = UnityEngine.Random.Range(1, 3); }
public void Character2()
{ agility = UnityEngine.Random.Range(1, 3); }
public void Character3()
{ agility = UnityEngine.Random.Range(1, 3); }`
and i need to add together each character's agility value, how would i go about doing that?
| 0debug |
JQuery: How to find an input with a value that is defined in a variable : <p>I have a list of HTML radio buttons each with their own value (say 1 - 10)</p>
<p>I also have a hidden field with a set value (say 5)</p>
<p>I want to find the input that has the value of the hiddenfield</p>
<pre><code>$('.block').each(function (index) {
var hiddenVal = $('.myHiddenField').val();
var inputWithHiddenVal = $(this).find('li input[value="5"]')
});
</code></pre>
<p>I want the input[value="5"] to use the hiddenVal variable</p>
<p>e.g.</p>
<pre><code>$(this).find('li input[value="hiddenVal"]')
</code></pre>
| 0debug |
Is it possible to create an object with a space in python? : <p>Is it possible to create an object named 'Stack Overflow' and is valued 5.</p>
<p>For example:</p>
<pre><code>stack overflow = 5
</code></pre>
| 0debug |
static void realview_init(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
CPUState *env;
ram_addr_t ram_offset;
DeviceState *dev;
qemu_irq *irqp;
qemu_irq pic[64];
PCIBus *pci_bus;
NICInfo *nd;
int n;
int done_smc = 0;
qemu_irq cpu_irq[4];
int ncpu;
if (!cpu_model)
cpu_model = "arm926";
if (strcmp(cpu_model, "arm11mpcore") == 0) {
ncpu = 4;
} else {
ncpu = 1;
}
for (n = 0; n < ncpu; n++) {
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
irqp = arm_pic_init_cpu(env);
cpu_irq[n] = irqp[ARM_PIC_CPU_IRQ];
if (n > 0) {
env->regs[15] = 0x80000000;
}
}
ram_offset = qemu_ram_alloc(ram_size);
cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM);
arm_sysctl_init(0x10000000, 0xc1400400);
if (ncpu == 1) {
dev = sysbus_create_simple("realview_gic", 0x10040000, cpu_irq[0]);
} else {
dev = sysbus_create_varargs("realview_mpcore", -1,
cpu_irq[0], cpu_irq[1], cpu_irq[2],
cpu_irq[3], NULL);
}
for (n = 0; n < 64; n++) {
pic[n] = qdev_get_gpio_in(dev, n);
}
sysbus_create_simple("pl050_keyboard", 0x10006000, pic[20]);
sysbus_create_simple("pl050_mouse", 0x10007000, pic[21]);
sysbus_create_simple("pl011", 0x10009000, pic[12]);
sysbus_create_simple("pl011", 0x1000a000, pic[13]);
sysbus_create_simple("pl011", 0x1000b000, pic[14]);
sysbus_create_simple("pl011", 0x1000c000, pic[15]);
sysbus_create_simple("pl081", 0x10030000, pic[24]);
sysbus_create_simple("sp804", 0x10011000, pic[4]);
sysbus_create_simple("sp804", 0x10012000, pic[5]);
sysbus_create_simple("pl110_versatile", 0x10020000, pic[23]);
sysbus_create_varargs("pl181", 0x10005000, pic[17], pic[18], NULL);
sysbus_create_simple("pl031", 0x10017000, pic[10]);
dev = sysbus_create_varargs("realview_pci", 0x60000000,
pic[48], pic[49], pic[50], pic[51], NULL);
pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci");
if (usb_enabled) {
usb_ohci_init_pci(pci_bus, -1);
}
n = drive_get_max_bus(IF_SCSI);
while (n >= 0) {
pci_create_simple(pci_bus, -1, "lsi53c895a");
n--;
}
for(n = 0; n < nb_nics; n++) {
nd = &nd_table[n];
if ((!nd->model && !done_smc) || strcmp(nd->model, "smc91c111") == 0) {
smc91c111_init(nd, 0x4e000000, pic[28]);
done_smc = 1;
} else {
pci_nic_init(nd, "rtl8139", NULL);
}
}
ram_offset = qemu_ram_alloc(0x1000);
cpu_register_physical_memory(0x80000000, 0x1000, ram_offset | IO_MEM_RAM);
realview_binfo.ram_size = ram_size;
realview_binfo.kernel_filename = kernel_filename;
realview_binfo.kernel_cmdline = kernel_cmdline;
realview_binfo.initrd_filename = initrd_filename;
realview_binfo.nb_cpus = ncpu;
arm_load_kernel(first_cpu, &realview_binfo);
}
| 1threat |
adb touchscreen swipe fail in a call : <p>I'm trying to simulate a auto video call with adb using touches and swipes.
The scenario: </p>
<p>Device1 audio calls Device2, Device2 answers, Device1 asks for video call(bidirectional), Device2 tries to answer and fails.
The wired thing is that sometimes it works but most of the it fails on that point when the device2 trying to answer via adb swipe.</p>
<p>here is the code:</p>
<pre><code>@Test(timeout = 60000000)
/**
*
*/
@TestProperties(name = "Video call / Normal video call")
public void VT111_0011() throws InterruptedException, IOException, AWTException {
initTestVariable("Normal_Video_Call_Test_VT111_0011");
sleep(idleBeforeTest);
System.out.println("Starting normal video test");
Android.adbCommand(secondDevice.getDevice1(), "adb -s " + secondDevice.getDeviceID() + " shell input touchscreen swipe 355 858 590 858");
for(int i=0; i<Iteration; i++) {
moveMouse();
Jsystem.broadCastMessage("\nIteration " + i, globalVar.nameForLogFile);
cleanLogs();
firstDevice.call(secondDevice);
Thread.sleep(2000);
if(secondDevice.isRinging())
secondDevice.answerCall(1000);
else{
ringingFail();
}
// Start video by gui
Android.adbCommand(firstDevice.getDevice1(),"adb -s " + firstDevice.getDeviceID() + " shell input tap 650 380");
Android.adbCommand(firstDevice.getDevice1(),"adb -s " + firstDevice.getDeviceID() + " shell input tap 420 470");
Thread.sleep(1000);
Android.adbCommand(firstDevice.getDevice1(),"adb -s " + firstDevice.getDeviceID() + " shell input tap 197 780"); // 197 920 Video bidirectional
Thread.sleep(5500);
// Device2 answers video
Android.adbCommand(firstDevice.getDevice1(),"adb -s " + firstDevice.getDeviceID() + " shell input tap 355 858"); // 197 920 Video bidirectional
Android.adbCommand(secondDevice.getDevice1(), "adb -s " + secondDevice.getDeviceID() + " shell input touchscreen swipe 355 858 590 858");
Thread.sleep(200);
Android.adbCommand(firstDevice.getDevice1(),"adb -s " + firstDevice.getDeviceID() + " shell input tap 60 372");
Android.adbCommand(secondDevice.getDevice1(),"adb -s " + secondDevice.getDeviceID() + " shell input tap 60 372");
/* Thread.sleep(5000);
if((!firstDevice.isInCall()) || (!secondDevice.isInCall())){
inCallFail();
continue;
} */
int failsCounter = 0;
VerifyVideo verifyVideo = new VerifyVideo();
for(int j = 8; j<10; j++){
if(verifyVideo.verrfiyVideo(firstDevice, secondDevice) == false)
failsCounter++;
}
if(failsCounter>2) {
Jsystem.broadCastMessage("****** TEST FAILED, VIDEO DOSENT WORK GOOD ENOUGH ****** " , globalVar.nameForLogFile);
System.out.println("Number of fails: " + failsCounter);
comparePhototsFail();
}
firstDevice.endCall();
secondDevice.endCall();
sleep(TimeBetweenIteration);
}
}
</code></pre>
<p>Any ideas?
Thanks.</p>
| 0debug |
Self-update / shadow-copy with Asp.Net Core : <p>I'm writing a Asp.Net Core application which should be able to update itself (replace its own binaries while running).</p>
<p><a href="https://msdn.microsoft.com/en-us/library/ms404279.aspx" rel="noreferrer">This MSDN article</a> describes shadow copying with the classical .Net framework, which would be exactly what I need. But the whole AppDomain thing is missing in .Net Core.</p>
<p>So my questions are:</p>
<ul>
<li>Is there an alternative way in .Net Core to enable shadow copying the assemblies?</li>
<li>Are there other mechanisms in .Net Core that allow to build a self-updating application?</li>
</ul>
| 0debug |
join mysql with null value : I have sample data in the following table on MySQL:
Id value Source
===== === ====
1 24 F
2 20 M
3 10 F
And I want to join with this table
Id value Source
===== === ====
1 2 T
2 5 T
and the result I want be like this:
Id value value Source Source
===== === ==== ==== ====
1 24 2 F T
2 20 5 M T
3 10 null F null
anyone can help please?
| 0debug |
static void av_estimate_timings_from_bit_rate(AVFormatContext *ic)
{
int64_t filesize, duration;
int bit_rate, i;
AVStream *st;
if (ic->bit_rate == 0) {
bit_rate = 0;
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
bit_rate += st->codec->bit_rate;
}
ic->bit_rate = bit_rate;
}
if (ic->duration == AV_NOPTS_VALUE &&
ic->bit_rate != 0 &&
ic->file_size != 0) {
filesize = ic->file_size;
if (filesize > 0) {
for(i = 0; i < ic->nb_streams; i++) {
st = ic->streams[i];
duration= av_rescale(8*filesize, st->time_base.den, ic->bit_rate*(int64_t)st->time_base.num);
if (st->duration == AV_NOPTS_VALUE)
st->duration = duration;
}
}
}
}
| 1threat |
Laravel find all data from child_category table using Eloquent ORM with related category & subcategory name? : I have three table:
category
subcategory
child_category
need all data from child_category table using Eloquent ORM with related category & subcategory name.
| 0debug |
static inline void idct4col_put(uint8_t *dest, int line_size, const int16_t *col)
{
int c0, c1, c2, c3, a0, a1, a2, a3;
a0 = col[8*0];
a1 = col[8*2];
a2 = col[8*4];
a3 = col[8*6];
c0 = ((a0 + a2) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1));
c2 = ((a0 - a2) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1));
c1 = a1 * C1 + a3 * C2;
c3 = a1 * C2 - a3 * C1;
dest[0] = av_clip_uint8((c0 + c1) >> C_SHIFT);
dest += line_size;
dest[0] = av_clip_uint8((c2 + c3) >> C_SHIFT);
dest += line_size;
dest[0] = av_clip_uint8((c2 - c3) >> C_SHIFT);
dest += line_size;
dest[0] = av_clip_uint8((c0 - c1) >> C_SHIFT);
}
| 1threat |
Coversion of the regular expression of VBA code to C# code : sFileText = Replace(sFileText, vbCrLf & " ", "|").
Can anyone tell me how to convert this regular expression of VBA Code to C# code? | 0debug |
C passing pointet to pointer in function : I am very confused... I am reading about pointer to pointer and now I think I know less than previous.
Passing double pointer is needed to change value of that pointer but if we have let's say pointer to some structure and we want to change value of some its member we use passing simple pointer. Am I right or it's incorrect? | 0debug |
Python regex wont match or escape backslashes : <p>So I'm trying to run through a file and match to a line in python, I understand regex but for some reason I can't get this one to work. </p>
<pre><code> p1 = re.compile("\s*(service_description)\s*([A-Z]:\\\s*Drive\s*Space)")
for x in cfg: #cfg is an array of everyline in the file
if p1.match(x):
print(p1.match(x).group(2))
</code></pre>
<p>it works fine in pythex, but when I run my script I cannot get it to match. it I've tried different combos, but the second I add the \ in (trying to get a literal '\' it stops matching.</p>
<p>for reference the line I'm trying to match to is </p>
<pre><code> service_description M:\ Drive Space
</code></pre>
<p>where M could also be any letter caps A-Z </p>
| 0debug |
Iterating over object values in JavaScript : <p>What is the most efficient / elegant way to iterate object values in JavaScript? </p>
<p>As an example, assume the following object: <code>let myObj = {p1: "v1", p2: "v2"}</code></p>
| 0debug |
sql query with TextBox1.Text Id value in where condition in Appsettings of C# asp.net : I want to use sql query in appsettings C# with TextBox.Text value(which from .cs code)in condition.
For example:
<add key="test" value="Select * from table where id=Textbox1.Text" />
Is it possible ?
| 0debug |
static int pc_rec_cmp(const void *p1, const void *p2)
{
PCRecord *r1 = *(PCRecord **)p1;
PCRecord *r2 = *(PCRecord **)p2;
if (r1->count < r2->count)
return 1;
else if (r1->count == r2->count)
return 0;
else
return -1;
}
| 1threat |
React native - connection has no connection handler error meaning? : <p>I created a new react project and when I run it on iOS from xcode, the console gives me this:</p>
<pre><code>2017-05-19 23:25:34.119 [info][tid:main][RCTBatchedBridge.m:77] Initializing <RCTBatchedBridge: 0x6100001a6c80> (parent: <RCTBridge: 0x6100000c46e0>, executor: RCTJSCExecutor)
2017-05-19 23:25:51.287 [info][tid:main][RCTRootView.m:295] Running application test ({
initialProps = {
};
rootTag = 1;
})
2017-05-19 23:25:51.289 [info][tid:com.facebook.react.JavaScript] Running application "test" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
2017-05-19 23:25:51.299771-0400 test[21948:1121429] [] nw_connection_get_connected_socket_block_invoke 3 Connection has no connected handler
2017-05-19 23:25:53.335282-0400 test[21948:1121426] [] nw_connection_get_connected_socket_block_invoke 4 Connection has no connected handler
2017-05-19 23:25:55.349190-0400 test[21948:1120112] [] nw_connection_get_connected_socket_block_invoke 5 Connection has no connected handler
</code></pre>
<p>What do <code>2017-05-19 23:25:51.299771-0400 test[21948:1121429] [] nw_connection_get_connected_socket_block_invoke 3 Connection has no connected handler</code> these lines mean and how to I resolve the issue?</p>
<p>I first noticed this when I tried to use fetch in my application and found it did not work. I found these messages in the console and later discovered these messages are happening with all my applications so I assume that means it is a config issue on my part? </p>
<p>I created a new test program to test what was causing this and found it happens on a brand new project. Below is my code is that generated the log output above:</p>
<pre><code>/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
export default class test extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.ios.js
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+D or shake for dev menu
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('test', () => test);
</code></pre>
| 0debug |
How to keep scroll position using flatlist when navigating back in react native ? : <p>I am new to react native. I am facing problem in maintaining the position of flatlist when navigating forward and then come back to that screen. </p>
<p>Current behavior<br>
When navigating forward and then back, the scroll position is lost. </p>
<p>Expected behavior<br>
When navigating on an extensive list of items, the user scrolls down the list and click on some item. The app goes to the next page which shows the product details. If the user decides do navigate back, the page does not scroll to the previous point. </p>
| 0debug |
static int decode_mb_cabac(H264Context *h) {
MpegEncContext * const s = &h->s;
const int mb_xy= s->mb_x + s->mb_y*s->mb_stride;
int mb_type, partition_count, cbp = 0;
int dct8x8_allowed= h->pps.transform_8x8_mode;
s->dsp.clear_blocks(h->mb);
tprintf("pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y);
if( h->slice_type != I_TYPE && h->slice_type != SI_TYPE ) {
int skip;
if( FRAME_MBAFF && s->mb_x==0 && (s->mb_y&1)==0 )
predict_field_decoding_flag(h);
if( FRAME_MBAFF && (s->mb_y&1)==1 && h->prev_mb_skipped )
skip = h->next_mb_skipped;
else
skip = decode_cabac_mb_skip( h, s->mb_x, s->mb_y );
if( skip ) {
if( FRAME_MBAFF && (s->mb_y&1)==0 ){
s->current_picture.mb_type[mb_xy] = MB_TYPE_SKIP;
h->next_mb_skipped = decode_cabac_mb_skip( h, s->mb_x, s->mb_y+1 );
if(h->next_mb_skipped)
predict_field_decoding_flag(h);
else
h->mb_mbaff = h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h);
}
decode_mb_skip(h);
h->cbp_table[mb_xy] = 0;
h->chroma_pred_mode_table[mb_xy] = 0;
h->last_qscale_diff = 0;
return 0;
}
}
if(FRAME_MBAFF){
if( (s->mb_y&1) == 0 )
h->mb_mbaff =
h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h);
}else
h->mb_field_decoding_flag= (s->picture_structure!=PICT_FRAME);
h->prev_mb_skipped = 0;
compute_mb_neighbors(h);
if( ( mb_type = decode_cabac_mb_type( h ) ) < 0 ) {
av_log( h->s.avctx, AV_LOG_ERROR, "decode_cabac_mb_type failed\n" );
return -1;
}
if( h->slice_type == B_TYPE ) {
if( mb_type < 23 ){
partition_count= b_mb_type_info[mb_type].partition_count;
mb_type= b_mb_type_info[mb_type].type;
}else{
mb_type -= 23;
goto decode_intra_mb;
}
} else if( h->slice_type == P_TYPE ) {
if( mb_type < 5) {
partition_count= p_mb_type_info[mb_type].partition_count;
mb_type= p_mb_type_info[mb_type].type;
} else {
mb_type -= 5;
goto decode_intra_mb;
}
} else {
assert(h->slice_type == I_TYPE);
decode_intra_mb:
partition_count = 0;
cbp= i_mb_type_info[mb_type].cbp;
h->intra16x16_pred_mode= i_mb_type_info[mb_type].pred_mode;
mb_type= i_mb_type_info[mb_type].type;
}
if(MB_FIELD)
mb_type |= MB_TYPE_INTERLACED;
h->slice_table[ mb_xy ]= h->slice_num;
if(IS_INTRA_PCM(mb_type)) {
const uint8_t *ptr;
unsigned int x, y;
ptr= h->cabac.bytestream;
if(h->cabac.low&0x1) ptr--;
if(CABAC_BITS==16){
if(h->cabac.low&0x1FF) ptr--;
}
for(y=0; y<16; y++){
const int index= 4*(y&3) + 32*((y>>2)&1) + 128*(y>>3);
for(x=0; x<16; x++){
tprintf("LUMA ICPM LEVEL (%3d)\n", *ptr);
h->mb[index + (x&3) + 16*((x>>2)&1) + 64*(x>>3)]= *ptr++;
}
}
for(y=0; y<8; y++){
const int index= 256 + 4*(y&3) + 32*(y>>2);
for(x=0; x<8; x++){
tprintf("CHROMA U ICPM LEVEL (%3d)\n", *ptr);
h->mb[index + (x&3) + 16*(x>>2)]= *ptr++;
}
}
for(y=0; y<8; y++){
const int index= 256 + 64 + 4*(y&3) + 32*(y>>2);
for(x=0; x<8; x++){
tprintf("CHROMA V ICPM LEVEL (%3d)\n", *ptr);
h->mb[index + (x&3) + 16*(x>>2)]= *ptr++;
}
}
ff_init_cabac_decoder(&h->cabac, ptr, h->cabac.bytestream_end - ptr);
h->cbp_table[mb_xy] = 0x1ef;
h->chroma_pred_mode_table[mb_xy] = 0;
s->current_picture.qscale_table[mb_xy]= 0;
h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, 0);
memset(h->non_zero_count[mb_xy], 16, 16);
s->current_picture.mb_type[mb_xy]= mb_type;
return 0;
}
if(MB_MBAFF){
h->ref_count[0] <<= 1;
h->ref_count[1] <<= 1;
}
fill_caches(h, mb_type, 0);
if( IS_INTRA( mb_type ) ) {
int i, pred_mode;
if( IS_INTRA4x4( mb_type ) ) {
if( dct8x8_allowed && decode_cabac_mb_transform_size( h ) ) {
mb_type |= MB_TYPE_8x8DCT;
for( i = 0; i < 16; i+=4 ) {
int pred = pred_intra_mode( h, i );
int mode = decode_cabac_mb_intra4x4_pred_mode( h, pred );
fill_rectangle( &h->intra4x4_pred_mode_cache[ scan8[i] ], 2, 2, 8, mode, 1 );
}
} else {
for( i = 0; i < 16; i++ ) {
int pred = pred_intra_mode( h, i );
h->intra4x4_pred_mode_cache[ scan8[i] ] = decode_cabac_mb_intra4x4_pred_mode( h, pred );
}
}
write_back_intra_pred_mode(h);
if( check_intra4x4_pred_mode(h) < 0 ) return -1;
} else {
h->intra16x16_pred_mode= check_intra_pred_mode( h, h->intra16x16_pred_mode );
if( h->intra16x16_pred_mode < 0 ) return -1;
}
h->chroma_pred_mode_table[mb_xy] =
pred_mode = decode_cabac_mb_chroma_pre_mode( h );
pred_mode= check_intra_pred_mode( h, pred_mode );
if( pred_mode < 0 ) return -1;
h->chroma_pred_mode= pred_mode;
} else if( partition_count == 4 ) {
int i, j, sub_partition_count[4], list, ref[2][4];
if( h->slice_type == B_TYPE ) {
for( i = 0; i < 4; i++ ) {
h->sub_mb_type[i] = decode_cabac_b_mb_sub_type( h );
sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
h->sub_mb_type[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].type;
}
if( IS_DIRECT(h->sub_mb_type[0] | h->sub_mb_type[1] |
h->sub_mb_type[2] | h->sub_mb_type[3]) ) {
pred_direct_motion(h, &mb_type);
if( h->ref_count[0] > 1 || h->ref_count[1] > 1 ) {
for( i = 0; i < 4; i++ )
if( IS_DIRECT(h->sub_mb_type[i]) )
fill_rectangle( &h->direct_cache[scan8[4*i]], 2, 2, 8, 1, 1 );
}
}
} else {
for( i = 0; i < 4; i++ ) {
h->sub_mb_type[i] = decode_cabac_p_mb_sub_type( h );
sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
h->sub_mb_type[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].type;
}
}
for( list = 0; list < h->list_count; list++ ) {
for( i = 0; i < 4; i++ ) {
if(IS_DIRECT(h->sub_mb_type[i])) continue;
if(IS_DIR(h->sub_mb_type[i], 0, list)){
if( h->ref_count[list] > 1 )
ref[list][i] = decode_cabac_mb_ref( h, list, 4*i );
else
ref[list][i] = 0;
} else {
ref[list][i] = -1;
}
h->ref_cache[list][ scan8[4*i]+1 ]=
h->ref_cache[list][ scan8[4*i]+8 ]=h->ref_cache[list][ scan8[4*i]+9 ]= ref[list][i];
}
}
if(dct8x8_allowed)
dct8x8_allowed = get_dct8x8_allowed(h);
for(list=0; list<h->list_count; list++){
for(i=0; i<4; i++){
if(IS_DIRECT(h->sub_mb_type[i])){
fill_rectangle(h->mvd_cache[list][scan8[4*i]], 2, 2, 8, 0, 4);
continue;
}
h->ref_cache[list][ scan8[4*i] ]=h->ref_cache[list][ scan8[4*i]+1 ];
if(IS_DIR(h->sub_mb_type[i], 0, list) && !IS_DIRECT(h->sub_mb_type[i])){
const int sub_mb_type= h->sub_mb_type[i];
const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE_16x8)) ? 2 : 1;
for(j=0; j<sub_partition_count[i]; j++){
int mpx, mpy;
int mx, my;
const int index= 4*i + block_width*j;
int16_t (* mv_cache)[2]= &h->mv_cache[list][ scan8[index] ];
int16_t (* mvd_cache)[2]= &h->mvd_cache[list][ scan8[index] ];
pred_motion(h, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, index, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, index, 1 );
tprintf("final mv:%d %d\n", mx, my);
if(IS_SUB_8X8(sub_mb_type)){
mv_cache[ 1 ][0]=
mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= mx;
mv_cache[ 1 ][1]=
mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= my;
mvd_cache[ 1 ][0]=
mvd_cache[ 8 ][0]= mvd_cache[ 9 ][0]= mx - mpx;
mvd_cache[ 1 ][1]=
mvd_cache[ 8 ][1]= mvd_cache[ 9 ][1]= my - mpy;
}else if(IS_SUB_8X4(sub_mb_type)){
mv_cache[ 1 ][0]= mx;
mv_cache[ 1 ][1]= my;
mvd_cache[ 1 ][0]= mx - mpx;
mvd_cache[ 1 ][1]= my - mpy;
}else if(IS_SUB_4X8(sub_mb_type)){
mv_cache[ 8 ][0]= mx;
mv_cache[ 8 ][1]= my;
mvd_cache[ 8 ][0]= mx - mpx;
mvd_cache[ 8 ][1]= my - mpy;
}
mv_cache[ 0 ][0]= mx;
mv_cache[ 0 ][1]= my;
mvd_cache[ 0 ][0]= mx - mpx;
mvd_cache[ 0 ][1]= my - mpy;
}
}else{
uint32_t *p= (uint32_t *)&h->mv_cache[list][ scan8[4*i] ][0];
uint32_t *pd= (uint32_t *)&h->mvd_cache[list][ scan8[4*i] ][0];
p[0] = p[1] = p[8] = p[9] = 0;
pd[0]= pd[1]= pd[8]= pd[9]= 0;
}
}
}
} else if( IS_DIRECT(mb_type) ) {
pred_direct_motion(h, &mb_type);
fill_rectangle(h->mvd_cache[0][scan8[0]], 4, 4, 8, 0, 4);
fill_rectangle(h->mvd_cache[1][scan8[0]], 4, 4, 8, 0, 4);
dct8x8_allowed &= h->sps.direct_8x8_inference_flag;
} else {
int list, mx, my, i, mpx, mpy;
if(IS_16X16(mb_type)){
for(list=0; list<2; list++){
if(IS_DIR(mb_type, 0, list)){
if(h->ref_count[list] > 0 ){
const int ref = h->ref_count[list] > 1 ? decode_cabac_mb_ref( h, list, 0 ) : 0;
fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, ref, 1);
}
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, (uint8_t)LIST_NOT_USED, 1);
}
for(list=0; list<2; list++){
if(IS_DIR(mb_type, 0, list)){
pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, 0, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, 0, 1 );
tprintf("final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx-mpx,my-mpy), 4);
fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4);
}else
fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, 0, 4);
}
}
else if(IS_16X8(mb_type)){
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
const int ref= h->ref_count[list] > 1 ? decode_cabac_mb_ref( h, list, 8*i ) : 0;
fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, ref, 1);
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, (LIST_NOT_USED&0xFF), 1);
}
}
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, 8*i, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, 8*i, 1 );
tprintf("final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx-mpx,my-mpy), 4);
fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx,my), 4);
}else{
fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, 0, 4);
fill_rectangle(h-> mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, 0, 4);
}
}
}
}else{
assert(IS_8X16(mb_type));
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
const int ref= h->ref_count[list] > 1 ? decode_cabac_mb_ref( h, list, 4*i ) : 0;
fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, ref, 1);
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, (LIST_NOT_USED&0xFF), 1);
}
}
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, 4*i, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, 4*i, 1 );
tprintf("final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx-mpx,my-mpy), 4);
fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx,my), 4);
}else{
fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, 0, 4);
fill_rectangle(h-> mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, 0, 4);
}
}
}
}
}
if( IS_INTER( mb_type ) ) {
h->chroma_pred_mode_table[mb_xy] = 0;
write_back_motion( h, mb_type );
}
if( !IS_INTRA16x16( mb_type ) ) {
cbp = decode_cabac_mb_cbp_luma( h );
cbp |= decode_cabac_mb_cbp_chroma( h ) << 4;
}
h->cbp_table[mb_xy] = h->cbp = cbp;
if( dct8x8_allowed && (cbp&15) && !IS_INTRA( mb_type ) ) {
if( decode_cabac_mb_transform_size( h ) )
mb_type |= MB_TYPE_8x8DCT;
}
s->current_picture.mb_type[mb_xy]= mb_type;
if( cbp || IS_INTRA16x16( mb_type ) ) {
const uint8_t *scan, *scan8x8, *dc_scan;
int dqp;
if(IS_INTERLACED(mb_type)){
scan8x8= s->qscale ? h->field_scan8x8 : h->field_scan8x8_q0;
scan= s->qscale ? h->field_scan : h->field_scan_q0;
dc_scan= luma_dc_field_scan;
}else{
scan8x8= s->qscale ? h->zigzag_scan8x8 : h->zigzag_scan8x8_q0;
scan= s->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
dc_scan= luma_dc_zigzag_scan;
}
h->last_qscale_diff = dqp = decode_cabac_mb_dqp( h );
if( dqp == INT_MIN ){
av_log(h->s.avctx, AV_LOG_ERROR, "cabac decode of qscale diff failed at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
s->qscale += dqp;
if(((unsigned)s->qscale) > 51){
if(s->qscale<0) s->qscale+= 52;
else s->qscale-= 52;
}
h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, s->qscale);
if( IS_INTRA16x16( mb_type ) ) {
int i;
if( decode_cabac_residual( h, h->mb, 0, 0, dc_scan, NULL, 16) < 0)
return -1;
if( cbp&15 ) {
for( i = 0; i < 16; i++ ) {
if( decode_cabac_residual(h, h->mb + 16*i, 1, i, scan + 1, h->dequant4_coeff[0][s->qscale], 15) < 0 )
return -1;
}
} else {
fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1);
}
} else {
int i8x8, i4x4;
for( i8x8 = 0; i8x8 < 4; i8x8++ ) {
if( cbp & (1<<i8x8) ) {
if( IS_8x8DCT(mb_type) ) {
if( decode_cabac_residual(h, h->mb + 64*i8x8, 5, 4*i8x8,
scan8x8, h->dequant8_coeff[IS_INTRA( mb_type ) ? 0:1][s->qscale], 64) < 0 )
return -1;
} else
for( i4x4 = 0; i4x4 < 4; i4x4++ ) {
const int index = 4*i8x8 + i4x4;
if( decode_cabac_residual(h, h->mb + 16*index, 2, index, scan, h->dequant4_coeff[IS_INTRA( mb_type ) ? 0:3][s->qscale], 16) < 0 )
return -1;
}
} else {
uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ];
nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0;
}
}
}
if( cbp&0x30 ){
int c;
for( c = 0; c < 2; c++ ) {
if( decode_cabac_residual(h, h->mb + 256 + 16*4*c, 3, c, chroma_dc_scan, NULL, 4) < 0)
return -1;
}
}
if( cbp&0x20 ) {
int c, i;
for( c = 0; c < 2; c++ ) {
for( i = 0; i < 4; i++ ) {
const int index = 16 + 4 * c + i;
if( decode_cabac_residual(h, h->mb + 16*index, 4, index - 16, scan + 1, h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp], 15) < 0)
return -1;
}
}
} else {
uint8_t * const nnz= &h->non_zero_count_cache[0];
nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] =
nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0;
}
} else {
uint8_t * const nnz= &h->non_zero_count_cache[0];
fill_rectangle(&nnz[scan8[0]], 4, 4, 8, 0, 1);
nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] =
nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0;
h->last_qscale_diff = 0;
}
s->current_picture.qscale_table[mb_xy]= s->qscale;
write_back_non_zero_count(h);
if(MB_MBAFF){
h->ref_count[0] >>= 1;
h->ref_count[1] >>= 1;
}
return 0;
}
| 1threat |
int main_loop_init(void)
{
int ret;
qemu_mutex_lock_iothread();
ret = qemu_signal_init();
if (ret) {
return ret;
}
ret = qemu_event_init();
if (ret) {
return ret;
}
return 0;
}
| 1threat |
GZIP in .net core not working : <p>I'm attempting to add Gzip middleware to my ASP.net core app. </p>
<p>I have added the following package : </p>
<blockquote>
<p>"Microsoft.AspNetCore.ResponseCompression": "1.0.0"</p>
</blockquote>
<p>In my startup.cs for the Configure Services method I have the following : </p>
<pre><code>public void ConfigureServices(IServiceCollection services)
{
services.Configure<GzipCompressionProviderOptions>(options => options.Level = CompressionLevel.Fastest);
services.AddResponseCompression(options =>
{
options.Providers.Add<GzipCompressionProvider>();
});
services.AddMvc();
}
</code></pre>
<p>In my Configure method I have the following : </p>
<pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseResponseCompression();
app.UseMvc();
}
</code></pre>
<p>However when I try and load a page, it doesn't come through as Gzip compressed. I have used both a string response and outputting a view. The response headers in chrome look like : </p>
<p><a href="https://i.stack.imgur.com/5Vh4T.png"><img src="https://i.stack.imgur.com/5Vh4T.png" alt="enter image description here"></a></p>
<p>I am on a windows machine developing in visual studio. When running the app I have tried just running from Visual Studio (Via F5), and also using the "dotnet run" command from command line. Neither output GZip compression. </p>
| 0debug |
Html script doesn't work anymore after moving into source file - why so? how to fix? : <p>I got an html file that looks somewhat like this:
</p>
<pre class="lang-html prettyprint-override"><code><html>
<head>
<script type="text/javascript" src="lang-parser.js"></script>
<script id="code" type="text/some-scripting-language">
//some code here in some language that is not js
</script>
<script type="text/javascript" src="sketch.js"></script>
</head>
<body>
<div id="canvas"></div>
</body>
</html>
</code></pre>
<p>Everything works and seems fine. Now I take the code in the middle script and move it into another file, and change the html code for that to:</p>
<pre class="lang-html prettyprint-override"><code> <script id="code" src="code.cdy" type="text/some-scripting-language"></script>
</code></pre>
<p>and it stops working, without any explicit errors, as if the script didn't load in time or something.</p>
<p>My question is: what can be the reason for this behavior and how can I change it?</p>
<p>Notes:</p>
<ol>
<li>Even if I write a wrong name of the file the console doesn't inform me about non-existent file. </li>
<li>If I additionally write that the file is of type <code>text/javascript</code> (which it is not), when the console finally informs me the file doesn't exist.</li>
<li>IMHO: It looks like the language parser gets downloaded asynchronously, and while it is in the process the parser reads the next tag, sees unknown type of language there and just ignores the entire thing... But that doesn't explain why without the source the code works. </li>
</ol>
| 0debug |
got error while download gattlib via pip3 : <p>I use Ubuntu 16.04 64bit OS<br>
when I run </p>
<pre><code>$ sudo pip3 install gattlib
</code></pre>
<p>I got this error message</p>
<blockquote>
<p>/usr/bin/ld: cannot find -lboost_python-py34<br>
collect2: error: ld returned 1 exit status<br>
error: command 'x86_64-linux-gnu-g++' failed with exit status 1 </p>
</blockquote>
<p>I tried googling how to solve this but nothing works for me<br>
I want to use gatttool at python, so I need to install this<br>
How can I solve this? </p>
<p>PS. I already downloaded libboost-dev</p>
| 0debug |
ReactJS, Calling setState with same parameter : <p>I have been reading the React docs and came across <code>shouldComponentUpdate()</code>. My understanding is that everytime <code>setState()</code> is called, a re-render of that component will be updated. </p>
<p>My question is that If the value to be updated is the <strong>SAME</strong> as the current state value, would this trigger a re-render event? or I would have to manually checks for the current value and value to be updated in <code>shouldComponentUpdate()</code></p>
| 0debug |
int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in)
{
char *param, buffer[128], tmp[128];
int len, tag_close, sptr = 1, line_start = 1, an = 0, end = 0;
SrtStack stack[16];
int closing_brace_missing = 0;
stack[0].tag[0] = 0;
strcpy(stack[0].param[PARAM_SIZE], "{\\fs}");
strcpy(stack[0].param[PARAM_COLOR], "{\\c}");
strcpy(stack[0].param[PARAM_FACE], "{\\fn}");
for (; !end && *in; in++) {
switch (*in) {
case '\r':
break;
case '\n':
if (line_start) {
end = 1;
break;
}
rstrip_spaces_buf(dst);
av_bprintf(dst, "\\N");
line_start = 1;
break;
case ' ':
if (!line_start)
av_bprint_chars(dst, *in, 1);
break;
case '{':
handle_open_brace(dst, &in, &an, &closing_brace_missing);
break;
case '<':
tag_close = in[1] == '/';
len = 0;
if (sscanf(in+tag_close+1, "%127[^>]>%n", buffer, &len) >= 1 && len > 0) {
const char *tagname = buffer;
while (*tagname == ' ')
tagname++;
if ((param = strchr(tagname, ' ')))
*param++ = 0;
if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) ||
( tag_close && sptr > 0 && !av_strcasecmp(stack[sptr-1].tag, tagname))) {
int i, j, unknown = 0;
in += len + tag_close;
if (!tag_close)
memset(stack+sptr, 0, sizeof(*stack));
if (!av_strcasecmp(tagname, "font")) {
if (tag_close) {
for (i=PARAM_NUMBER-1; i>=0; i--)
if (stack[sptr-1].param[i][0])
for (j=sptr-2; j>=0; j--)
if (stack[j].param[i][0]) {
av_bprintf(dst, "%s", stack[j].param[i]);
break;
}
} else {
while (param) {
if (!av_strncasecmp(param, "size=", 5)) {
unsigned font_size;
param += 5 + (param[5] == '"');
if (sscanf(param, "%u", &font_size) == 1) {
snprintf(stack[sptr].param[PARAM_SIZE],
sizeof(stack[0].param[PARAM_SIZE]),
"{\\fs%u}", font_size);
}
} else if (!av_strncasecmp(param, "color=", 6)) {
param += 6 + (param[6] == '"');
snprintf(stack[sptr].param[PARAM_COLOR],
sizeof(stack[0].param[PARAM_COLOR]),
"{\\c&H%X&}",
html_color_parse(log_ctx, param));
} else if (!av_strncasecmp(param, "face=", 5)) {
param += 5 + (param[5] == '"');
len = strcspn(param,
param[-1] == '"' ? "\"" :" ");
av_strlcpy(tmp, param,
FFMIN(sizeof(tmp), len+1));
param += len;
snprintf(stack[sptr].param[PARAM_FACE],
sizeof(stack[0].param[PARAM_FACE]),
"{\\fn%s}", tmp);
}
if ((param = strchr(param, ' ')))
param++;
}
for (i=0; i<PARAM_NUMBER; i++)
if (stack[sptr].param[i][0])
av_bprintf(dst, "%s", stack[sptr].param[i]);
}
} else if (tagname[0] && !tagname[1] && av_stristr("bisu", tagname)) {
av_bprintf(dst, "{\\%c%d}", (char)av_tolower(tagname[0]), !tag_close);
} else if (!av_strcasecmp(tagname, "br")) {
av_bprintf(dst, "\\N");
} else {
unknown = 1;
snprintf(tmp, sizeof(tmp), "</%s>", tagname);
}
if (tag_close) {
sptr--;
} else if (unknown && !strstr(in, tmp)) {
in -= len + tag_close;
av_bprint_chars(dst, *in, 1);
} else
av_strlcpy(stack[sptr++].tag, tagname,
sizeof(stack[0].tag));
break;
}
}
default:
av_bprint_chars(dst, *in, 1);
break;
}
if (*in != ' ' && *in != '\r' && *in != '\n')
line_start = 0;
}
if (!av_bprint_is_complete(dst))
return AVERROR(ENOMEM);
while (dst->len >= 2 && !strncmp(&dst->str[dst->len - 2], "\\N", 2))
dst->len -= 2;
dst->str[dst->len] = 0;
rstrip_spaces_buf(dst);
return 0;
}
| 1threat |
static int decode_frame(AVCodecContext * avctx,
void *data, int *data_size,
UINT8 * buf, int buf_size)
{
MPADecodeContext *s = avctx->priv_data;
UINT32 header;
UINT8 *buf_ptr;
int len, out_size;
short *out_samples = data;
*data_size = 0;
buf_ptr = buf;
while (buf_size > 0) {
len = s->inbuf_ptr - s->inbuf;
if (s->frame_size == 0) {
if (s->free_format_next_header != 0) {
s->inbuf[0] = s->free_format_next_header >> 24;
s->inbuf[1] = s->free_format_next_header >> 16;
s->inbuf[2] = s->free_format_next_header >> 8;
s->inbuf[3] = s->free_format_next_header;
s->inbuf_ptr = s->inbuf + 4;
s->free_format_next_header = 0;
goto got_header;
}
len = HEADER_SIZE - len;
if (len > buf_size)
len = buf_size;
else if (len > 0) {
memcpy(s->inbuf_ptr, buf_ptr, len);
buf_ptr += len;
buf_size -= len;
s->inbuf_ptr += len;
}
if ((s->inbuf_ptr - s->inbuf) >= HEADER_SIZE) {
got_header:
header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
(s->inbuf[2] << 8) | s->inbuf[3];
if (check_header(header) < 0) {
memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf);
s->inbuf_ptr--;
dprintf("skip %x\n", header);
s->free_format_frame_size = 0;
} else {
if (decode_header(s, header) == 1) {
s->frame_size = -1;
memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf);
s->inbuf_ptr--;
} else {
avctx->sample_rate = s->sample_rate;
avctx->channels = s->nb_channels;
avctx->bit_rate = s->bit_rate;
}
}
}
} else if (s->frame_size == -1) {
len = MPA_MAX_CODED_FRAME_SIZE - len;
if (len > buf_size)
len = buf_size;
if (len == 0) {
s->frame_size = 0;
} else {
UINT8 *p, *pend;
UINT32 header1;
int padding;
memcpy(s->inbuf_ptr, buf_ptr, len);
p = s->inbuf_ptr - 3;
pend = s->inbuf_ptr + len - 4;
while (p <= pend) {
header = (p[0] << 24) | (p[1] << 16) |
(p[2] << 8) | p[3];
header1 = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
(s->inbuf[2] << 8) | s->inbuf[3];
if ((header & SAME_HEADER_MASK) ==
(header1 & SAME_HEADER_MASK)) {
len = (p + 4) - s->inbuf_ptr;
buf_ptr += len;
buf_size -= len;
s->inbuf_ptr = p;
s->free_format_next_header = header;
s->free_format_frame_size = s->inbuf_ptr - s->inbuf;
padding = (header1 >> 9) & 1;
if (s->layer == 1)
s->free_format_frame_size -= padding * 4;
else
s->free_format_frame_size -= padding;
dprintf("free frame size=%d padding=%d\n",
s->free_format_frame_size, padding);
decode_header(s, header1);
goto next_data;
}
p++;
}
buf_ptr += len;
s->inbuf_ptr += len;
buf_size -= len;
}
} else if (len < s->frame_size) {
if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE)
s->frame_size = MPA_MAX_CODED_FRAME_SIZE;
len = s->frame_size - len;
if (len > buf_size)
len = buf_size;
else if (len > 0)
{
memcpy(s->inbuf_ptr, buf_ptr, len);
buf_ptr += len;
s->inbuf_ptr += len;
buf_size -= len;
}
} else {
out_size = mp_decode_frame(s, out_samples);
s->inbuf_ptr = s->inbuf;
s->frame_size = 0;
*data_size = out_size;
break;
}
next_data:
}
return buf_ptr - buf;
}
| 1threat |
void ff_svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp,
int dc)
{
const int qmul = svq3_dequant_coeff[qp];
int i;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
if (dc) {
dc = 13*13*((dc == 1) ? 1538*block[0] : ((qmul*(block[0] >> 3)) / 2));
block[0] = 0;
}
for (i = 0; i < 4; i++) {
const int z0 = 13*(block[0 + 4*i] + block[2 + 4*i]);
const int z1 = 13*(block[0 + 4*i] - block[2 + 4*i]);
const int z2 = 7* block[1 + 4*i] - 17*block[3 + 4*i];
const int z3 = 17* block[1 + 4*i] + 7*block[3 + 4*i];
block[0 + 4*i] = z0 + z3;
block[1 + 4*i] = z1 + z2;
block[2 + 4*i] = z1 - z2;
block[3 + 4*i] = z0 - z3;
}
for (i = 0; i < 4; i++) {
const int z0 = 13*(block[i + 4*0] + block[i + 4*2]);
const int z1 = 13*(block[i + 4*0] - block[i + 4*2]);
const int z2 = 7* block[i + 4*1] - 17*block[i + 4*3];
const int z3 = 17* block[i + 4*1] + 7*block[i + 4*3];
const int rr = (dc + 0x80000);
dst[i + stride*0] = cm[ dst[i + stride*0] + (((z0 + z3)*qmul + rr) >> 20) ];
dst[i + stride*1] = cm[ dst[i + stride*1] + (((z1 + z2)*qmul + rr) >> 20) ];
dst[i + stride*2] = cm[ dst[i + stride*2] + (((z1 - z2)*qmul + rr) >> 20) ];
dst[i + stride*3] = cm[ dst[i + stride*3] + (((z0 - z3)*qmul + rr) >> 20) ];
}
}
| 1threat |
I'm trying to sum up the top 80% by value of sales $ and give a count on how many customers make up that 80% : I'm trying to build a sales query for a rolling 12 months. I know my sales by customer, and my total sales. I'm trying to sum up the top 80% of sales $ and give a count on how many customers make up that 80%. Any ideas? I have a result set that looks like the below. Thanks in advance!
Customer Sales TotalSales PercentOfSales
8585 19788.81 769658.68 0.03
8429 19598.26 769658.68 0.03
2837 19431.29 769658.68 0.03
6071 19398.11 769658.68 0.03
5027 19223.13 769658.68 0.02
6677 19204.90 769658.68 0.02 | 0debug |
size_t mptsas_config_ioc_0(MPTSASState *s, uint8_t **data, int address)
{
PCIDeviceClass *pcic = PCI_DEVICE_GET_CLASS(s);
return MPTSAS_CONFIG_PACK(0, MPI_CONFIG_PAGETYPE_IOC, 0x01,
"*l*lwwb*b*b*blww",
pcic->vendor_id, pcic->device_id, pcic->revision,
pcic->subsystem_vendor_id,
pcic->subsystem_id);
}
| 1threat |
Can anybody help me with this output , because i dont understand it , its 30 . and im a beginner in Java : <p>When I compile the output is 30 . I thought it would be 2 beacause z is smaller than 0 so z = z + 3 , (-1 + 3 = 2):(. I dont get it </p>
<pre><code> int z = -1;
if(z < 0)
z += 3;
else if(z == 2)
z += 5;
if(z < 5)
z *= 15;
System.out.println("z is = " + z);
</code></pre>
| 0debug |
C# Select the Header as the range to search in microsoft word : I have some text in the header of a word document. I have a find and replace method that searches for text and then replaces it if it is found. My question is, how do I only select the header to be the range to search and replace for key words? | 0debug |
static int mpc8_probe(AVProbeData *p)
{
const uint8_t *bs = p->buf + 4;
const uint8_t *bs_end = bs + p->buf_size;
int64_t size;
if (p->buf_size < 16)
return 0;
if (AV_RL32(p->buf) != TAG_MPCK)
return 0;
while (bs < bs_end + 3) {
int header_found = (bs[0] == 'S' && bs[1] == 'H');
if (bs[0] < 'A' || bs[0] > 'Z' || bs[1] < 'A' || bs[1] > 'Z')
return 0;
bs += 2;
size = bs_get_v(&bs);
if (size < 2)
return 0;
if (bs + size - 2 >= bs_end)
return AVPROBE_SCORE_EXTENSION - 1;
if (header_found) {
if (size < 11 || size > 28)
return 0;
if (!AV_RL32(bs))
return 0;
return AVPROBE_SCORE_MAX;
} else {
bs += size - 2;
}
}
return 0;
}
| 1threat |
Is Haskell's type system isomorphic to an inconsistent logic system? If so, what are the consequences? : <p>In Haskell there is a term <code>undefined :: a</code>, which is said to be a term
representation of a bad computation or endless loop. Since <code>undefined</code> has
type <code>a</code>, them it's possible to create any syntactic correct type by
applying type substitutions. So <code>undefined</code> has any type and the o inverse is also true: any type has <code>undefined</code>, which is the bottom value living inside of any type (including the <code>Void</code> type, right?).</p>
<p>Curry-Howard isomorphism gives more than proposition as types, it also gives habited types as theorems.</p>
<p>A logic system with all propositions as theorems is said to be inconsistent.</p>
<p>So, Haskell's type system isomorphic to an inconsistent logic system?</p>
<p>If so, what are the consequences?</p>
<p>If Haskell's type system is a inconsistent proof system, them we can't trust it?</p>
<p>Would be possible to represent endless loop with no <code>undefined</code>?</p>
| 0debug |
Convert to base 2 then split in an array : <p>I want to convert my base 10 number to base 2 and then store parts in an array. </p>
<p>Here are two examples:</p>
<p>my value is 5 so it will be converted to 101 then I have an array like this: {1,0,1}</p>
<p>or my value is 26 so it will be converted to 11010 then I will have an array like this: {0,1,0,1,1}</p>
<p>Thank you in advance for your time and consideration.</p>
| 0debug |
static int spapr_tce_table_realize(DeviceState *dev)
{
sPAPRTCETable *tcet = SPAPR_TCE_TABLE(dev);
if (kvm_enabled()) {
tcet->table = kvmppc_create_spapr_tce(tcet->liobn,
tcet->window_size,
&tcet->fd);
}
if (!tcet->table) {
size_t table_size = (tcet->window_size >> SPAPR_TCE_PAGE_SHIFT)
* sizeof(uint64_t);
tcet->table = g_malloc0(table_size);
}
tcet->nb_table = tcet->window_size >> SPAPR_TCE_PAGE_SHIFT;
trace_spapr_iommu_new_table(tcet->liobn, tcet, tcet->table, tcet->fd);
memory_region_init_iommu(&tcet->iommu, OBJECT(dev), &spapr_iommu_ops,
"iommu-spapr", UINT64_MAX);
QLIST_INSERT_HEAD(&spapr_tce_tables, tcet, list);
vmstate_register(DEVICE(tcet), tcet->liobn, &vmstate_spapr_tce_table,
tcet);
return 0;
}
| 1threat |
How can i publish app with different names in play store? : <p>I already published one app in play store.After that i made some changes in the code, now i want to publish that app with different name in play store.How can i release it with out affecting the previous app,so that previous app and present app are showing in play store. </p>
| 0debug |
void cpu_ppc_set_papr(PowerPCCPU *cpu)
{
CPUPPCState *env = &cpu->env;
env->msr_mask &= ~((1ull << MSR_EP) | MSR_HVB);
env->spr[SPR_AMOR] = amor->default_value = 0xffffffffffffffffull;
if (kvm_enabled()) {
kvmppc_set_papr(cpu);
}
} | 1threat |
-bash: gcloud: command not found on Mac : <p>I'm following the <a href="https://cloud.google.com/sdk/docs/quickstart-mac-os-x" rel="noreferrer">Quickstart for Mac OS X</a> to install the cloud SDK. Following the steps exactly,</p>
<p>1) <code>python -V</code> returns "Python 2.7.10"</p>
<p>2) Download and extract using <code>./install.sh</code> the 64bit version of the SDK in google-cloud-sdk returns...</p>
<pre><code>Welcome to the Google Cloud SDK!
To help improve the quality of this product, we collect anonymized usage data
and anonymized stacktraces when crashes are encountered; additional information
is available at <https://cloud.google.com/sdk/usage-statistics>. You may choose
to opt out of this collection now (by choosing 'N' at the below prompt), or at
any time in the future by running the following command:
gcloud config set disable_usage_reporting true
Do you want to help improve the Google Cloud SDK (Y/n)? Y
Your current Cloud SDK version is: 170.0.1
The latest available version is: 170.0.1
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Components │
├───────────────┬──────────────────────────────────────────────────────┬──────────────────────────┬───────────┤
│ Status │ Name │ ID │ Size │
├───────────────┼──────────────────────────────────────────────────────┼──────────────────────────┼───────────┤
│ Not Installed │ App Engine Go Extensions │ app-engine-go │ 97.7 MiB │
│ Not Installed │ Cloud Bigtable Command Line Tool │ cbt │ 4.0 MiB │
│ Not Installed │ Cloud Bigtable Emulator │ bigtable │ 3.5 MiB │
│ Not Installed │ Cloud Datalab Command Line Tool │ datalab │ < 1 MiB │
│ Not Installed │ Cloud Datastore Emulator │ cloud-datastore-emulator │ 15.4 MiB │
│ Not Installed │ Cloud Datastore Emulator (Legacy) │ gcd-emulator │ 38.1 MiB │
│ Not Installed │ Cloud Pub/Sub Emulator │ pubsub-emulator │ 33.2 MiB │
│ Not Installed │ Emulator Reverse Proxy │ emulator-reverse-proxy │ 14.5 MiB │
│ Not Installed │ Google Container Local Builder │ container-builder-local │ 3.7 MiB │
│ Not Installed │ Google Container Registry's Docker credential helper │ docker-credential-gcr │ 2.2 MiB │
│ Not Installed │ gcloud Alpha Commands │ alpha │ < 1 MiB │
│ Not Installed │ gcloud Beta Commands │ beta │ < 1 MiB │
│ Not Installed │ gcloud app Java Extensions │ app-engine-java │ 128.1 MiB │
│ Not Installed │ gcloud app PHP Extensions (Mac OS X) │ app-engine-php-darwin │ 21.9 MiB │
│ Not Installed │ gcloud app Python Extensions │ app-engine-python │ 6.5 MiB │
│ Not Installed │ kubectl │ kubectl │ 15.9 MiB │
│ Installed │ BigQuery Command Line Tool │ bq │ < 1 MiB │
│ Installed │ Cloud SDK Core Libraries │ core │ 6.7 MiB │
│ Installed │ Cloud Storage Command Line Tool │ gsutil │ 3.0 MiB │
└───────────────┴──────────────────────────────────────────────────────┴──────────────────────────┴───────────┘
To install or remove components at your current SDK version [170.0.1], run:
$ gcloud components install COMPONENT_ID
$ gcloud components remove COMPONENT_ID
To update your SDK installation to the latest version [170.0.1], run:
$ gcloud components update
==> Source [/Users/shaneoseasnain/Desktop/google-cloud-sdk/completion.bash.inc] in your profile to enable shell command completion for gcloud.
==> Source [/Users/shaneoseasnain/Desktop/google-cloud-sdk/path.bash.inc] in your profile to add the Google Cloud SDK command line tools to your $PATH.
For more information on how to get started, please visit:
https://cloud.google.com/sdk/docs/quickstarts
</code></pre>
<p>3) I've restarted the terminal and run <code>gcloud init</code> from inside google-cloud-sdk. This returns "<code>command not found</code>." If I run <code>ls</code>, I see the following directory structure:</p>
<pre><code>LICENSE completion.zsh.inc path.fish.inc
README deb path.zsh.inc
RELEASE_NOTES install.bat platform
VERSION install.sh properties
bin lib rpm
completion.bash.inc path.bash.inc
</code></pre>
<p>4) I've tried to run <code>gcloud init</code> inside <code>bin</code> as well, but get the same problem, <code>command not found</code>.</p>
<p>The only other suggestions I can see from the install guide are "enable command-completion in your bash shell, and/or enable usage reporting." I'm not sure how to do this but command completion and reporting don't look like they should be related to this problem. There is a lot written about <code>command not found</code> but they relate to other problems where, for example, gcloud has stopped working after a while or problems in older versions. Has anyone a tip how to get the cloud sdk working?</p>
<p>Thanks</p>
| 0debug |
static void floor_fit(venc_context_t * venc, floor_t * fc, float * coeffs, int * posts, int samples) {
int range = 255 / fc->multiplier + 1;
int i;
for (i = 0; i < fc->values; i++) {
int position = fc->list[fc->list[i].sort].x;
int begin = fc->list[fc->list[FFMAX(i-1, 0)].sort].x;
int end = fc->list[fc->list[FFMIN(i+1, fc->values - 1)].sort].x;
int j;
float average = 0;
begin = (position + begin) / 2;
end = (position + end ) / 2;
assert(end <= samples);
for (j = begin; j < end; j++) average += fabs(coeffs[j]);
average /= end - begin;
average /= 32;
for (j = 0; j < range; j++) if (floor1_inverse_db_table[j * fc->multiplier] > average) break;
posts[fc->list[i].sort] = j;
}
}
| 1threat |
Macro and function with same name in header file : <p><code>tool.c</code></p>
<pre><code>#include <stdlib.h>
#include "tool.h"
void safeFree(void** pp) {
if (pp != NULL & *pp != NULL) {
free(*pp);
*pp = NULL;
}
}
</code></pre>
<p><code>tool.h</code></p>
<pre><code>#ifndef tool_h
#define tool_h
void safeFree(void** pp);
#define safeFree(p) safeFree((void**)&(p))
#endif /* tool_h */
</code></pre>
<p>I want to use the macro after I import <code>tool.h</code> in <code>main.c</code>, but the programme can't be compiled. Is there any way I could define macro and function with same name?</p>
| 0debug |
Javascript ArrayBuffer to Hex : <p>I've got a Javascript ArrayBuffer that I would like to be converted into a hex string.</p>
<p>Anyone knows of a function that I can call or a pre written function already out there?</p>
<p>I have only been able to find arraybuffer to string functions, but I want the hexdump of the array buffer instead.</p>
| 0debug |
Search and replace a particular string having special characters in a file using Perl : Search and replace a particular string in a file using Perl.
I have a .txt file. where i need to search and replace a string.
i code i have is working fine for string not having special characters.but for the string containing special characters like (?,=,:: ) is not working with this code. Can anyone please urgently help??
Thanks in advance.
a.txt file content:
------------------
<tbody>
<tr><td> App URL </td><td> <xmp class="no-margin" style="white-space:pre-wrap">https://example.com/abc/f?p=CDE:HOME/</xmp> </td></tr><tr><td> App control </td><td> <xmp class="no-margin" style="white-space:pre-wrap">SSO</xmp> </td></tr><tr><td> App Owner </td><td> <xmp class="no-margin" style="white-space:pre-wrap">CCS</xmp> </td></tr>
</tbody>
-----------------------------
Need to replace in a.txt file:
<xmp class="no-margin" style="white-space:pre-wrap">https://example.com/abc/f?p=CDE:HOME/</xmp>
----------------------------
Replacement String:
<a href="https://example.com/abc/f?p=CDE:HOME/" target="_blank">https://example.com/abc/f?p=CDE:HOME/</a>
---------------------------
#!/usr/bin/perl
use strict;
use warnings;
$^I = '.bak'; # create a backup copy
my $string2 = '<xmp class="no-margin" style="white-space:pre-wrap">https://example.com/abc/f?p=CDE:HOME/</xmp>' ; #old string
my $string3 = '<a href="https://example.com/abc/f?p=CDE:HOME/" target="_blank">https://example.com/abc/f?p=CDE:HOME/</a>'; #new string
while (<>) {
s/$string2/$string3/g;
print; # print to the modified file
expected result in a.txt file after replacement:
----------------------------------------------
<tbody>
<tr><td> App URL </td><td> <a href="https://example.com/abc/f?p=CDE:HOME/" target="_blank">https://example.com/abc/f?p=CDE:HOME/</a> </td></tr><tr><td> App control </td><td> <xmp class="no-margin" style="white-space:pre-wrap">SSO</xmp> </td></tr><tr><td> App Owner </td><td> <xmp class="no-margin" style="white-space:pre-wrap">CCS</xmp> </td></tr>
</tbody> | 0debug |
Remove all Jbuttons and passing the setText value to other variables : <p>I want to be able to remove all the JButton that is tied to b by just clicking on whichever of them and also to pass the value from the button that the user clicked to outside the loop. The code below only removes the button the user clicked on only.</p>
<pre><code>for (File file : listOfFiles) {
int fileCount = 0;
if (file.isFile()) {
JButton b = new JButton(String.valueOf(fileCount));
fileCount++;
b.setText(file.getName());
b.setPreferredSize(new Dimension(300, 40));
Panel.add(b);
frame.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
b.setVisible(false);
}
});
}
}
</code></pre>
| 0debug |
void spapr_tce_table_enable(sPAPRTCETable *tcet,
uint32_t page_shift, uint64_t bus_offset,
uint32_t nb_table)
{
if (tcet->nb_table) {
error_report("Warning: trying to enable already enabled TCE table");
return;
}
tcet->bus_offset = bus_offset;
tcet->page_shift = page_shift;
tcet->nb_table = nb_table;
tcet->table = spapr_tce_alloc_table(tcet->liobn,
tcet->page_shift,
tcet->bus_offset,
tcet->nb_table,
&tcet->fd,
tcet->need_vfio);
memory_region_set_size(&tcet->iommu,
(uint64_t)tcet->nb_table << tcet->page_shift);
memory_region_add_subregion(&tcet->root, tcet->bus_offset, &tcet->iommu);
}
| 1threat |
static int proxy_rename(FsContext *ctx, const char *oldpath,
const char *newpath)
{
int retval;
V9fsString oldname, newname;
v9fs_string_init(&oldname);
v9fs_string_init(&newname);
v9fs_string_sprintf(&oldname, "%s", oldpath);
v9fs_string_sprintf(&newname, "%s", newpath);
retval = v9fs_request(ctx->private, T_RENAME, NULL, "ss",
&oldname, &newname);
v9fs_string_free(&oldname);
v9fs_string_free(&newname);
if (retval < 0) {
errno = -retval;
}
return retval;
}
| 1threat |
How to round of 0.5 in sql server : How to round of 0.5 in sql server | 0debug |
Keras - NN prediction of error in metrological measurement. : <p>I have example data which contain coordinates of points on the x-y plane (for
example 2.0000 , 4.0000), next using monte carlo method, a small random error
is added to those coordinates to simulate a set of points measured by a
metrological machine.</p>
<p>This may sound trivial, but Im not really sure what to do next with this data, Im trying to build a model which predicts the error in measurement, but I have problem in visualizing the whole concept, ie. should the input layer of the network have neurons which receive real coordinates of the points and
simulated coordinates, or simulated ones only? Or maybe I should estimate
measurement error for each simulated point and and use it with coordinates of
those points in the input layer? Also, how many neurons the network should
have on the output layer and how should I interpret that data? I know this
probably isnt the best description of the problem, but I am a complete
begginner in this field, so any theoretical help or practical examples will be greatly appreciated. </p>
| 0debug |
let promise wait a couple of seconds before return : <p>I'm having a function returning a promise. In this function, we call a third party vender to send some push notification through their server. </p>
<p>it looks like </p>
<pre><code>apiGetLoggedInUser.then(
user => {
return sendMessage(user.name);
}
)
</code></pre>
<p>However the thing is we decided to wait for 3 seconds before we really call this sendMessage function. However we'd prefer not to change sendMessage since it's provided. </p>
<p>I'm wondering how to really do the "wait" part in this scenario since promise is used to remove "sync" operations. </p>
<p>Am I understanding correctly? What shall I do?</p>
| 0debug |
static void test_parse_invalid_path_subprocess(void)
{
qemu_set_log_filename("/tmp/qemu-%d%d.log");
}
| 1threat |
How to use string C data type in PIC C Compiler : How to use `string` in [CCS](https://ccsinfo.com/forum/viewtopic.php?p=205898)?
I tried:
```
#include<string.h>
```
>But I still have error with it:
```
string myString = "My String"; // Error
``` | 0debug |
static void dss_sp_shift_sq_sub(const int32_t *filter_buf,
int32_t *error_buf, int32_t *dst)
{
int a;
for (a = 0; a < 72; a++) {
int i, tmp;
tmp = dst[a] * filter_buf[0];
for (i = 14; i > 0; i--)
tmp -= error_buf[i] * (unsigned)filter_buf[i];
for (i = 14; i > 0; i--)
error_buf[i] = error_buf[i - 1];
tmp = (tmp + 4096) >> 13;
error_buf[1] = tmp;
dst[a] = av_clip_int16(tmp);
}
}
| 1threat |
recursion and binary trees. how do i write the commented parts : how do i write the code to find a certain node. specifically how do i say a node was visited after i check it
public Iterator<T> pathToRoot(T targetElement, BinaryTreeNode<T> current)
throws ElementNotFoundException
{
Stack<BinaryTreeNode<T>> myStack = new Stack<>();
if (current == null)
return null;
if (current.element.equals(targetElement)) //found it
{
myStack.push(current); //adds the current element to the stack
}
// mark as visited
//mark node also as found
// return the found element
if (current.hasLeftChild() || current.hasRightChild()) //if the current node has a left or right child
{
// mark node as visited
}
if (current.hasLeftChild())//if the current node has a left child node
pathToRoot(targetElement, current.getLeft()); // check the left child node
if (current.hasRightChild())//same thing as above but for the right
pathToRoot(targetElement, current.getRight());
if(current != targetElement && /*node has been visited*/)
myStack.pop(); // pop node from the stack
return myStack.toString(); //return string of path to root
}
/*using a dfs search to find a node*/ | 0debug |
Ruby how to test thread : How to check the result of some method inside thread.
For example:
we have thread:
module Task
def self.execute
"result"
end
end
threads = []
threads << Thread.new do
Task.execute
end
Now we need to specify the test which check the result:
expect(Task.execute).to eq("result")
Ok. Let's try to add thread inside thread:
threads << Thread.new do
deep_thread = Thread.new { Task.execute }
deep_thread.join
end
So, how to check that the fact of two finished threads, and also check the result of `deep_thread` ? | 0debug |
Missing array data in codeignitor php : i have menu which get data from database
here is my code
<nav id="mysidebarmenu" class="amazonmenu">
<ul>
<?php
//Get Category array
$categories = json_decode($this->db->get_where('ui_settings',array('type' => 'home_category'))->row()->value);
foreach($categories as $row){
?>
<li>
<a href="javascript:void(0);">
<?php
echo $this->crud_model->get_type_name_by_id('category',$row,'category_name');
?>
</a>
<div>
<div class="col-md-12">
<?php
//Get Sub Category array
$subs = $this->db->get_where('sub_category',array('category'=>$row['category_id']))->result_array();
foreach($subs as $row1){
$this->db->limit(4);
$this->db->order_by('product_id','desc');
$products = $this->db->get_where('product',array('sub_category'=>$row1['sub_category_id'],'status' =>'ok'))->result_array();
?>
<div class="col-md-12"><h3 class="text-center" style="background:#EAEAEA;"><?php echo $row1['sub_category_name']; ?></h3></div>
<?php
foreach($products as $row2){
if($this->crud_model->is_publishable($row2['product_id'])){
?>
<div class="col-md-3">
<div class="menu_box">
<div class="img_menu_box" style="background:url('<?php echo $this->crud_model->file_view('product',$row2['product_id'],'','','no','src','multi','one') ?>') no-repeat center center; background-size: 100% auto;">
</div>
<a href="<?php echo $this->crud_model->product_link($row2['product_id']); ?>">
<?php echo $row2['title']; ?>
</a>
</div>
</div>
<?php
}
}
?>
<?php
}
?>
</div>
</div>
</li>
<?php
}
?>
</ul>
</nav>
**here are results i am getting**<br>
> print_r($categories);<br>
> result = Array ( [0] => 5 [1] => 31 )<br>
> print_r($subs);<br>
> 1- result for Array [0] => 5 = ( [0] => Array ( [sub_category_id] => 18 [sub_category_name] => A [category] => 5 ) [1]
> => Array ( [sub_category_id] => 19 [sub_category_name] => B [category] => 5 ))<br>
>2- result for Array [1] => 31 = Array ( )
the problem is in second array result coming empty
| 0debug |
static uint64_t cirrus_vga_mem_read(void *opaque,
target_phys_addr_t addr,
uint32_t size)
{
CirrusVGAState *s = opaque;
unsigned bank_index;
unsigned bank_offset;
uint32_t val;
if ((s->vga.sr[0x07] & 0x01) == 0) {
return vga_mem_readb(&s->vga, addr);
}
if (addr < 0x10000) {
bank_index = addr >> 15;
bank_offset = addr & 0x7fff;
if (bank_offset < s->cirrus_bank_limit[bank_index]) {
bank_offset += s->cirrus_bank_base[bank_index];
if ((s->vga.gr[0x0B] & 0x14) == 0x14) {
bank_offset <<= 4;
} else if (s->vga.gr[0x0B] & 0x02) {
bank_offset <<= 3;
}
bank_offset &= s->cirrus_addr_mask;
val = *(s->vga.vram_ptr + bank_offset);
} else
val = 0xff;
} else if (addr >= 0x18000 && addr < 0x18100) {
val = 0xff;
if ((s->vga.sr[0x17] & 0x44) == 0x04) {
val = cirrus_mmio_blt_read(s, addr & 0xff);
}
} else {
val = 0xff;
#ifdef DEBUG_CIRRUS
printf("cirrus: mem_readb " TARGET_FMT_plx "\n", addr);
#endif
}
return val;
}
| 1threat |
Jenkins Pipeline: is it possible to avoid multiple checkout? : <p>I've moved a few old Jenkins jobs to new ones using the <a href="https://jenkins.io/doc/pipeline/">pipeline feature</a> in order to be able to integrate the Jenkins configuration within the git repositories.
It's working fine but I'm asking myself if there is a way to reduce the number of checkout that happens while building.</p>
<p><strong>Setup</strong></p>
<ul>
<li>I have a Jenkins multibranch job which is related to my git repository</li>
<li><p>I have a Jenkinsfile in my git repository</p>
<pre><code>#!groovy
node {
stage 'Checkout'
checkout scm
// build project
stage 'Build'
...
}
</code></pre></li>
</ul>
<p><strong>Problem</strong></p>
<p>When I push to my remote branche <em>BRANCH_1</em>, the multibranch jenkins job is triggered and my understanding is that the following steps happen:</p>
<ul>
<li>the multibranch job makes a <code>git fetch</code> for the branch indexing and triggers the job corresponding to my remote branch: <em>BRANCH_1_job</em></li>
<li><em>BRANCH_1_job</em> makes a <code>git checkout</code> to retrieve the Jenkinsfile of the triggered branch</li>
<li>the Jenkinsfile is executed and makes a <code>checkout scm</code> itself. If I don't do it, I can not build my project because no source are available.</li>
</ul>
<p>So for building my branch, I end up with one <code>git fetch</code> and two <code>git checkout</code>.</p>
<p><strong>Questions</strong></p>
<ul>
<li>Do I understand the process correctly? Or did I miss something?</li>
<li>Is there a way to reduce the number of <code>git checkout</code>? When I check the <a href="https://github.com/jenkinsci/pipeline-examples/tree/master/jenkinsfile-examples">official examples</a>, they all make a checkout scm as first step. I would personally think that I don't have to do it because the jenkins job already had to make a checkout to retrieve the Jenkinsfile (so my sources have to be here somehow).</li>
<li>Don't you think these multiple checkouts can cause bad performance as soon as the git repo contains a big number of refs?</li>
</ul>
<p>Thanks you all</p>
| 0debug |
Running NodeJS project in Visual Studio Code with yarn : <p>I have a NodeJS project which I can start from command line with <code>yarn start</code> command. My <code>package.json</code> looks similar to this:</p>
<pre><code>{
"name": "projectname",
"version": "0.0.1",
"description": "",
"author": "My Name",
"license": "",
"scripts": {
"start": "yarn dev",
"dev": "yarn stop && pm2 start pm2-dev.yaml && webpack-dev-server --progress",
"prod": "yarn stop && yarn build && pm2 start pm2-prod.yaml",
"build": "rimraf dist lib && babel src -d lib --ignore test.js && cross-env NODE_ENV=production webpack -p --progress",
"stop": "rimraf logs/* && pm2 delete all || true"
},
"dependencies": {
"body-parser": "~1.16.0",
"ejs": "2.5.5",
"express": "^4.14.1",
"pg": "^6.1.2",
"react": "^15.4.2",
"redux": "^3.6.0",
},
"devDependencies": {
"babel-cli": "^6.22.2",
"cross-env": "^3.1.4",
"eslint": "^3.13.0",
"pm2": "^2.3.0",
"redux-mock-store": "^1.2.2",
"rimraf": "^2.5.4",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.2.1"
}
}
</code></pre>
<p>I am trying to start this project in debugging mode with Visual Studio Code but with almost no luck. I have defined my launch configuration in VS Code <code>launch.json</code> file like this:</p>
<pre><code>{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "yarn",
"runtimeExecutable": "yarn",
"runtimeArgs": [
"start"
],
"port": 5858,
"cwd": "${workspaceRoot}",
"timeout": 10000
}
]
}
</code></pre>
<p>The problem with this configuration is that it usually times-out because <code>webpack-dev-server</code> build is longer than 10 seconds. I can increase the <code>timeout</code> in my configuration, but I have noticed that VS Code results with a message <code>Cannot connect to runtime process (timeout after 30000 ms).</code> eventually, so I assume that this is not a good solution. Also, my breakpoints are ignored with this kind of config which tells me that I am definitely doing something wrong here.</p>
<p>This is the first time I am trying out Visual Studio Code and I usually don't use NodeJS, but I got this project with all these scripts in <code>package.json</code> already defined so I'm trying to adopt to it and therefore all the confusion about how to run it properly.</p>
<p>Can Visual Studio Code run a project like this with full debugging functionality at all, and if so, how should I configure my launch script?</p>
| 0debug |
c strcmp() with array of strings : <p>I am trying to count the amount of times which any word is repeated in the words[] array. I already have i, j, num_words and the words array initialized. The words array is type char *words[n]. The frequency[] array runs parallel to the words[] array and keeps track of the number of times each word appears. The program compiles but when it runs i get a segmentation fault. The problem is coming from the following section of code: </p>
<pre><code> int frequency[1000] = {0};
for(i = 0; i < num_words; i++){
for(j = i+1; j < num_words; j++){
if(strcmp(words[i], words[j]) == 0){
freq[i]++;
}
}
}
</code></pre>
<p>I've been playing around with this for a while but i have no idea what is wrong with this bit of code. </p>
| 0debug |
Trying to make the answer randomly generated after retry in C# : <pre><code>using System;
namespace Test
{
class Program
{
static void Main(string[] args)
{
int num1 = int.Parse(args[0]);
int num2 = int.Parse(args[1]);
bool GameOver = false;
int turn = 3;
Random random = new Random();
int answer = random.Next(num1, num2);
// string input = "";
Console.WriteLine("Hello, welcome to the guess a number challenge");
while (!GameOver)
{
if (turn != 0)
{
turn--;
Console.WriteLine($"Please Select number between {num1} to {num2}:");
int SelectedNumber = int.Parse(Console.ReadLine());
if (SelectedNumber < answer && SelectedNumber >= num1)
{
System.Console.WriteLine("Almost there, just the number is too small\n");
} else if (SelectedNumber > answer && SelectedNumber <= num2)
{
System.Console.WriteLine("Your number is too big\n");
} else if(SelectedNumber == answer)
{
System.Console.WriteLine("CONGRATULATIONS!!!! You guess it right\n");
GameOver = true;
retry();
} else
{
System.Console.WriteLine("Your number is out of range\n");
}
} else
{
System.Console.WriteLine($"GAME OVER!!!! The answer is {answer}");
GameOver = true;
retry();
}
void retry() {
System.Console.WriteLine("Would you like to retry? Y/N");
string input = Console.ReadLine();
string ConsoleInput = input.ToLower();
if(ConsoleInput == "y")
{
GameOver = false;
turn = 3;
} else if(ConsoleInput == "n")
{
GameOver = true;
} else
{
Console.WriteLine("Invalid input");
retry();
}
}
}
}
}
}
</code></pre>
<p>Hello all, just want to ask a question.
I tried to build "guess a number" game in terminal, where player has to guess a number based on the number range given.
I tried to make the <em>answer</em> randomly generated, thus the Random class.
and the answer will be randomized after retry.
The problem is, after each retry, the <em>answer</em> is still the same.
I am not sure where did I did wrong.
Thanks for the help, and sorry for the noob question.</p>
| 0debug |
static void qobject_input_check_struct(Visitor *v, Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
StackObject *tos = QSLIST_FIRST(&qiv->stack);
assert(tos && !tos->entry);
if (qiv->strict) {
GHashTable *const top_ht = tos->h;
if (top_ht) {
GHashTableIter iter;
const char *key;
g_hash_table_iter_init(&iter, top_ht);
if (g_hash_table_iter_next(&iter, (void **)&key, NULL)) {
error_setg(errp, "Parameter '%s' is unexpected", key);
}
}
}
}
| 1threat |
int ff_nvenc_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
NVENCSTATUS nv_status;
CUresult cu_res;
CUcontext dummy;
NvencSurface *tmpoutsurf, *inSurf;
int res;
NvencContext *ctx = avctx->priv_data;
NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs;
NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs;
NV_ENC_PIC_PARAMS pic_params = { 0 };
pic_params.version = NV_ENC_PIC_PARAMS_VER;
if (frame) {
inSurf = get_free_frame(ctx);
if (!inSurf) {
av_log(avctx, AV_LOG_ERROR, "No free surfaces\n");
return AVERROR_BUG;
}
cu_res = dl_fn->cuda_dl->cuCtxPushCurrent(ctx->cu_context);
if (cu_res != CUDA_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "cuCtxPushCurrent failed\n");
return AVERROR_EXTERNAL;
}
res = nvenc_upload_frame(avctx, frame, inSurf);
cu_res = dl_fn->cuda_dl->cuCtxPopCurrent(&dummy);
if (cu_res != CUDA_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "cuCtxPopCurrent failed\n");
return AVERROR_EXTERNAL;
}
if (res) {
inSurf->lockCount = 0;
return res;
}
pic_params.inputBuffer = inSurf->input_surface;
pic_params.bufferFmt = inSurf->format;
pic_params.inputWidth = avctx->width;
pic_params.inputHeight = avctx->height;
pic_params.inputPitch = inSurf->pitch;
pic_params.outputBitstream = inSurf->output_surface;
if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
if (frame->top_field_first)
pic_params.pictureStruct = NV_ENC_PIC_STRUCT_FIELD_TOP_BOTTOM;
else
pic_params.pictureStruct = NV_ENC_PIC_STRUCT_FIELD_BOTTOM_TOP;
} else {
pic_params.pictureStruct = NV_ENC_PIC_STRUCT_FRAME;
}
if (ctx->forced_idr >= 0 && frame->pict_type == AV_PICTURE_TYPE_I) {
pic_params.encodePicFlags =
ctx->forced_idr ? NV_ENC_PIC_FLAG_FORCEIDR : NV_ENC_PIC_FLAG_FORCEINTRA;
} else {
pic_params.encodePicFlags = 0;
}
pic_params.inputTimeStamp = frame->pts;
nvenc_codec_specific_pic_params(avctx, &pic_params);
} else {
pic_params.encodePicFlags = NV_ENC_PIC_FLAG_EOS;
}
cu_res = dl_fn->cuda_dl->cuCtxPushCurrent(ctx->cu_context);
if (cu_res != CUDA_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "cuCtxPushCurrent failed\n");
return AVERROR_EXTERNAL;
}
nv_status = p_nvenc->nvEncEncodePicture(ctx->nvencoder, &pic_params);
cu_res = dl_fn->cuda_dl->cuCtxPopCurrent(&dummy);
if (cu_res != CUDA_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "cuCtxPopCurrent failed\n");
return AVERROR_EXTERNAL;
}
if (nv_status != NV_ENC_SUCCESS &&
nv_status != NV_ENC_ERR_NEED_MORE_INPUT)
return nvenc_print_error(avctx, nv_status, "EncodePicture failed!");
if (frame) {
av_fifo_generic_write(ctx->output_surface_queue, &inSurf, sizeof(inSurf), NULL);
timestamp_queue_enqueue(ctx->timestamp_list, frame->pts);
if (ctx->initial_pts[0] == AV_NOPTS_VALUE)
ctx->initial_pts[0] = frame->pts;
else if (ctx->initial_pts[1] == AV_NOPTS_VALUE)
ctx->initial_pts[1] = frame->pts;
}
if (nv_status == NV_ENC_SUCCESS) {
while (av_fifo_size(ctx->output_surface_queue) > 0) {
av_fifo_generic_read(ctx->output_surface_queue, &tmpoutsurf, sizeof(tmpoutsurf), NULL);
av_fifo_generic_write(ctx->output_surface_ready_queue, &tmpoutsurf, sizeof(tmpoutsurf), NULL);
}
}
if (output_ready(avctx, !frame)) {
av_fifo_generic_read(ctx->output_surface_ready_queue, &tmpoutsurf, sizeof(tmpoutsurf), NULL);
res = process_output_surface(avctx, pkt, tmpoutsurf);
if (res)
return res;
av_assert0(tmpoutsurf->lockCount);
tmpoutsurf->lockCount--;
*got_packet = 1;
} else {
*got_packet = 0;
}
return 0;
}
| 1threat |
Get selected feature names TFIDF Vectorizer : <p>I'm using python and I want to get the TFIDF representation for a large corpus of data, I'm using the following code to convert the docs into their TFIDF form.</p>
<pre><code>from sklearn.feature_extraction.text import TfidfVectorizer
tfidf_vectorizer = TfidfVectorizer(
min_df=1, # min count for relevant vocabulary
max_features=4000, # maximum number of features
strip_accents='unicode', # replace all accented unicode char
# by their corresponding ASCII char
analyzer='word', # features made of words
token_pattern=r'\w{1,}', # tokenize only words of 4+ chars
ngram_range=(1, 1), # features made of a single tokens
use_idf=True, # enable inverse-document-frequency reweighting
smooth_idf=True, # prevents zero division for unseen words
sublinear_tf=False)
tfidf_df = tfidf_vectorizer.fit_transform(df['text'])
</code></pre>
<p>Here I pass a parameter <code>max_features</code>. The vectorizer will select the best features and return a scipy sparse matrix. Problem is I dont know which features are getting selected and how do I map those feature names back to the scipy matrix I get? Basically for the <code>n</code> selected features from the <code>m</code> number of documents, I want a <code>m x n</code> matrix with the selected features as the column names instead of their integer ids. How do I accomplish this?</p>
| 0debug |
How to declare a property of NSArray of NSObjects in Objective C : <p>I have a custom User class where I am storing user data. For now I have Group class where I want to add Users as an array. Somewhere I seen once something like, but I lost it and can't find.</p>
<pre><code> @property (strong, nonatomic) User<NSArray> *groupUsers;
</code></pre>
<p>Do you know how to make it right syntax?</p>
<p>Thanks!</p>
| 0debug |
How to remove the Xcode warning Apple Mach-O Linker Warning 'Pointer not aligned at address : <p>I have a slight issue when build my Xcode project, get tones of warning after update pod. It looks like this</p>
<p><a href="https://i.stack.imgur.com/kDrX2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kDrX2.png" alt="enter image description here"></a></p>
<p>Already search the whole site here but still no luck. it doesn't affect the project but it is quite annoying. Anyone could help? </p>
| 0debug |
static int tcg_target_const_match(tcg_target_long val, TCGType type,
const TCGArgConstraint *arg_ct)
{
int ct = arg_ct->ct;
if (ct & TCG_CT_CONST) {
return 1;
}
if (type == TCG_TYPE_I32) {
val = (int32_t)val;
}
if (ct & TCG_CT_CONST_S16) {
return val == (int16_t)val;
} else if (ct & TCG_CT_CONST_S32) {
return val == (int32_t)val;
} else if (ct & TCG_CT_CONST_ADLI) {
return tcg_match_add2i(type, val);
} else if (ct & TCG_CT_CONST_ORI) {
return tcg_match_ori(type, val);
} else if (ct & TCG_CT_CONST_XORI) {
return tcg_match_xori(type, val);
} else if (ct & TCG_CT_CONST_U31) {
return val >= 0 && val <= 0x7fffffff;
} else if (ct & TCG_CT_CONST_ZERO) {
return val == 0;
}
return 0;
}
| 1threat |
static gboolean fd_trampoline(GIOChannel *chan, GIOCondition cond, gpointer opaque)
{
IOTrampoline *tramp = opaque;
if ((cond & G_IO_IN) && tramp->fd_read) {
tramp->fd_read(tramp->opaque);
}
if ((cond & G_IO_OUT) && tramp->fd_write) {
tramp->fd_write(tramp->opaque);
}
return TRUE;
}
| 1threat |
C++ replacing character in strings : <p>Im currently trying to capitalize the character 'i' but only if it's by itself </p>
<p>this is the code i have </p>
<pre><code>int main()
{
string textMessage = "Yesterday’s Doctor Who broadcast made me
laugh and cry in the same episode! i can only wonder what the
Doctor will get into next. My family and i are huge fans.";
replace(textMessage.begin(), textMessage.end(), 'i', 'I');
cout << textMessage;
}
</code></pre>
<p>my output is </p>
<p><code>Yesterday’s Doctor Who broadcast made me laugh and cry In the same epIsode! I can only wonder what the Doctor wIll get Into next. My famIly and I are huge fans.</code></p>
<p>this is the output i want</p>
<p><code>Yesterday’s Doctor Who broadcast made me laugh and cry in the same episode! I can only wonder what the Doctor will get into next. My family and I are huge fans.</code></p>
| 0debug |
difference between button button = (button) v and button button = (button)findviewbyid(r.id.button1) : could somebody tell me what is the difference between Button button = (Button)v and Button button = (Button)findviewbyid(R.id.button) | 0debug |
why recursion is returning undefined in javascript? : <p>I'm using recursion to reverse the number. in the terminating condition i am returning the result. but it's returning "undefined". the console inside the if is showing the correct output. </p>
<p>// reverse the number</p>
<pre><code>var result= "";
var reverse = function(x) {
if(x == 0){
console.log("result",result);
return result;
}else{
var lastDigit = x % 10;
result += lastDigit;
x = Math.floor(x/10);
reverse(x);
}
};
console.log(reverse(73254));
</code></pre>
| 0debug |
I have been trying a program in python for mapreduce and need some help in it : To get more hands-on experience I wanted to try a project word count. Here is the sample data which I have.
> The United Nations (UN) is an intergovernmental organisation
> established on 24 October 1945 to promote international cooperation. A
> replacement for the ineffective League of Nations, the organisation
> was created following World War II to prevent another such conflict.
> At its founding, the UN had 51 member states; there are now 193. The
> UN Headquarters resides in international territory in New York City,
> with further main offices in Geneva, Nairobi, and Vienna. The
> organisation is financed by assessed and voluntary contributions from
> its member states. Its objectives include maintaining international
> peace and security, promoting human rights, fostering social and
> economic development, protecting the environment, and providing
> humanitarian aid in cases of famine, natural disaster, and armed
> conflict.
>
> During World War II, US President Franklin D. Roosevelt initiated talks on a successor agency to the League of Nations, and the United
> Nations Charter was drafted at a conference in AprilJune 1945; this
> charter took effect on 24 October 1945, and the UN began operation.
> The UN's mission to preserve world peace was complicated in its early
> decades by the Cold War between the US and USSR and their respective
> allies, though the organization participated in major actions in Korea
> and the Congo, as well as approving the creation of the state Israel
> in 1947. The organisation's membership grew significantly following
> widespread decolonization in the 1960s, and by the 1970s, its budget
> for economic and social development programmes far outstripped its
> spending on peacekeeping. After the end of the Cold War, the UN took
> on major military and peacekeeping missions in Kuwait, Namibia,
> Cambodia, Bosnia, Rwanda, Somalia, Sudan, and the Democratic Republic
> of Congo with varying degrees of success.
> The UN has six principal organs: the General Assembly (the main deliberative assembly); the Security Council (for deciding certain
> resolutions for peace and security); the Economic and Social Council
> (ECOSOC) (for promoting international economic and social co-operation
> and development); the Secretariat (for providing studies, information,
> and facilities needed by the UN); the International Court of Justice
> (the primary judicial organ); and the United Nations Trusteeship
> Council (inactive since 1994). UN System agencies include the World
> Bank Group, the World Health Organization, the World Food Programme,
> UNESCO, and UNICEF. The UN's most prominent officer is the
> Secretary-General, an office held by Ban Ki-moon of South Korea since
> 2007. Non-governmental organisations may be granted consultative status with ECOSOC and other agencies to participate in the UN's work.The organisation won the 2001 Nobel Peace Prize, and a number of its officers and agencies have also been awarded the prize. Other evaluations of the UN's effectiveness have been mixed. Some commentators believe the organisation to be an important force for peace and human development, while others have called the organisation ineffective, corrupt, or biased.
and i used the following python code to get my result
from mrjob.job import MRJob
from mrjob.step import MRStep
class MovieRatings(MRJob):
def steps(self):
return [
MRStep(mapper=self.mapper_get_ratings,
reducer=self.reducer_count_ratings),
]
def mapper_get_ratings(self, _, line):
(word) = line.split(' ')
yield word, 1
def reducer_count_ratings(self, key, values):
yield Key, sum(values)
if __name__ == '__main__':
MovieRatings.run()
i am getting the following error
[root@localhost Desktop]# python RatingsBreakdown.py UN.txt
Traceback (most recent call last):
File "RatingsBreakdown.py", line 1, in <module>
from mrjob.job import MRJob
File "/usr/lib/python2.6/site-packages/mrjob/job.py", line 1106
for k, v in unfiltered_jobconf.items() if v is not None
^
SyntaxError: invalid syntax
[root@localhost Desktop]# python3 RatingsBreakdown.py UN.txt
No configs found; falling back on auto-configuration
No configs specified for inline runner
Running step 1 of 2...
Creating temp directory /tmp/RatingsBreakdown.training.20171128.083536.602598
Error while reading from /tmp/RatingsBreakdown.training.20171128.083536.602598/step/000/mapper/00000/input:
Traceback (most recent call last):
File "RatingsBreakdown.py", line 25, in <module>
RatingsBreakdown.run()
File "/usr/lib/python3.4/site-packages/mrjob/job.py", line 424, in run
mr_job.execute()
File "/usr/lib/python3.4/site-packages/mrjob/job.py", line 445, in execute
super(MRJob, self).execute()
File "/usr/lib/python3.4/site-packages/mrjob/launch.py", line 185, in execute
self.run_job()
File "/usr/lib/python3.4/site-packages/mrjob/launch.py", line 233, in run_job
runner.run()
File "/usr/lib/python3.4/site-packages/mrjob/runner.py", line 511, in run
self._run()
File "/usr/lib/python3.4/site-packages/mrjob/sim.py", line 144, in _run
self._run_mappers_and_combiners(step_num, map_splits)
File "/usr/lib/python3.4/site-packages/mrjob/sim.py", line 185, in _run_mappers_and_combiners
for task_num, map_split in enumerate(map_splits)
File "/usr/lib/python3.4/site-packages/mrjob/sim.py", line 120, in _run_multiple
func()
File "/usr/lib/python3.4/site-packages/mrjob/sim.py", line 662, in _run_mapper_and_combiner
run_mapper()
File "/usr/lib/python3.4/site-packages/mrjob/sim.py", line 685, in _run_task
stdin, stdout, stderr, wd, env)
File "/usr/lib/python3.4/site-packages/mrjob/inline.py", line 92, in invoke_task
task.execute()
File "/usr/lib/python3.4/site-packages/mrjob/job.py", line 433, in execute
self.run_mapper(self.options.step_num)
File "/usr/lib/python3.4/site-packages/mrjob/job.py", line 517, in run_mapper
for out_key, out_value in mapper(key, value) or ():
File "RatingsBreakdown.py", line 13, in mapper_get_ratings
(userID, movieID, rating, timestamp) = line.split('\t')
ValueError: need more than 1 value to unpack
[root@localhost Desktop]# python3 MovieRatings.py UN.txt
No configs found; falling back on auto-configuration
No configs specified for inline runner
Running step 1 of 1...
Creating temp directory /tmp/MovieRatings.training.20171128.083635.368889
Error while reading from /tmp/MovieRatings.training.20171128.083635.368889/step/000/reducer/00000/input:
Traceback (most recent call last):
File "MovieRatings.py", line 20, in <module>
MovieRatings.run()
File "/usr/lib/python3.4/site-packages/mrjob/job.py", line 424, in run
mr_job.execute()
File "/usr/lib/python3.4/site-packages/mrjob/job.py", line 445, in execute
super(MRJob, self).execute()
File "/usr/lib/python3.4/site-packages/mrjob/launch.py", line 185, in execute
self.run_job()
File "/usr/lib/python3.4/site-packages/mrjob/launch.py", line 233, in run_job
runner.run()
File "/usr/lib/python3.4/site-packages/mrjob/runner.py", line 511, in run
self._run()
File "/usr/lib/python3.4/site-packages/mrjob/sim.py", line 150, in _run
self._run_reducers(step_num, num_reducer_tasks)
File "/usr/lib/python3.4/site-packages/mrjob/sim.py", line 246, in _run_reducers
for task_num in range(num_reducer_tasks)
File "/usr/lib/python3.4/site-packages/mrjob/sim.py", line 120, in _run_multiple
func()
File "/usr/lib/python3.4/site-packages/mrjob/sim.py", line 685, in _run_task
stdin, stdout, stderr, wd, env)
File "/usr/lib/python3.4/site-packages/mrjob/inline.py", line 92, in invoke_task
task.execute()
File "/usr/lib/python3.4/site-packages/mrjob/job.py", line 439, in execute
self.run_reducer(self.options.step_num)
File "/usr/lib/python3.4/site-packages/mrjob/job.py", line 560, in run_reducer
for out_key, out_value in reducer(key, values) or ():
File "MovieRatings.py", line 17, in reducer_count_ratings
yield Key, sum(values)
NameError: name 'Key' is not defined
Would like to solve the error and understand what mistake i have done.
Thanks | 0debug |
static void e100_pci_reset(EEPRO100State * s, E100PCIDeviceInfo *e100_device)
{
uint32_t device = s->device;
uint8_t *pci_conf = s->dev.config;
TRACE(OTHER, logout("%p\n", s));
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);
pci_config_set_device_id(pci_conf, e100_device->device_id);
pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM |
PCI_STATUS_FAST_BACK);
pci_config_set_revision(pci_conf, e100_device->revision);
pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET);
pci_set_byte(pci_conf + PCI_LATENCY_TIMER, 0x20);
pci_set_byte(pci_conf + PCI_INTERRUPT_PIN, 1);
pci_set_byte(pci_conf + PCI_MIN_GNT, 0x08);
pci_set_byte(pci_conf + PCI_MAX_LAT, 0x18);
s->stats_size = e100_device->stats_size;
s->has_extended_tcb_support = e100_device->has_extended_tcb_support;
switch (device) {
case i82550:
case i82551:
case i82557A:
case i82557B:
case i82557C:
case i82558A:
case i82558B:
case i82559A:
case i82559B:
case i82559ER:
case i82562:
case i82801:
break;
case i82559C:
#if EEPROM_SIZE > 0
pci_set_word(pci_conf + PCI_SUBSYSTEM_VENDOR_ID, PCI_VENDOR_ID_INTEL);
pci_set_word(pci_conf + PCI_SUBSYSTEM_ID, 0x0040);
#endif
break;
default:
logout("Device %X is undefined!\n", device);
}
s->configuration[6] |= BIT(4);
s->configuration[6] |= BIT(5);
if (s->stats_size == 80) {
if (s->configuration[6] & BIT(2)) {
assert(s->configuration[6] & BIT(5));
} else {
if (s->configuration[6] & BIT(5)) {
s->stats_size = 64;
} else {
s->stats_size = 76;
}
}
} else {
if (s->configuration[6] & BIT(5)) {
s->stats_size = 64;
}
}
assert(s->stats_size > 0 && s->stats_size <= sizeof(s->statistics));
if (e100_device->power_management) {
int cfg_offset = 0xdc;
int r = pci_add_capability(&s->dev, PCI_CAP_ID_PM,
cfg_offset, PCI_PM_SIZEOF);
assert(r >= 0);
pci_set_word(pci_conf + cfg_offset + PCI_PM_PMC, 0x7e21);
#if 0
pci_set_word(pci_conf + cfg_offset + PCI_PM_CTRL, 0x0000);
pci_set_byte(pci_conf + cfg_offset + PCI_PM_PPB_EXTENSIONS, 0x0000);
#endif
}
#if EEPROM_SIZE > 0
if (device == i82557C || device == i82558B || device == i82559C) {
logout("Get device id and revision from EEPROM!!!\n");
}
#endif
}
| 1threat |
static inline void vring_used_idx_set(VirtQueue *vq, uint16_t val)
{
VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches);
hwaddr pa = offsetof(VRingUsed, idx);
virtio_stw_phys_cached(vq->vdev, &caches->used, pa, val);
address_space_cache_invalidate(&caches->used, pa, sizeof(val));
vq->used_idx = val;
}
| 1threat |
CSS3 - Use part of an image for background : <p>I want to use some images as backgrounds but I have no control over the images. If the images are 500px x 500px , is it possible with just CSS3 to scale the image down to 200px x 200px and then only use 100px x 100px from the center?</p>
| 0debug |
Cannot add click events to dynamic generated list items by jquery : <h1>Jquery Code</h1>
<p>this is my jquery function for retrieving list or categories from database which is dynamically genrated by jquery function, I have added click event on each of the generated list items. But its not giving any alert on click.</p>
<pre><code> <script type="text/javascript" src="<?= base_url('assets/js/jquery.js'); ?>"></script>
<script type="text/javascript" src="<?= base_url('assets/js/jquery.min.js'); ?>"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
getlevel1category();
$('#cat').click(function () {
alert();
});
function getlevel1category () {
$.ajax({
type:'POST',
url: "<?php echo base_url(); ?>" + "HomeController/getLevel1Categories",
async: true,
dataType: 'json',
success: function (data) {
var html='';
var i;
for(i=0;i<data.length;i++)
{
html +='<li id="cat">'+data[i].Name+'</li>';
}
$('#level1').html(html);
},
error: function () {
alert('Could not get data');
}
});
}
}
</script>
</code></pre>
<h1>Controller</h1>
<pre><code><?php
class HomeController extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('HomeModel');
}
public function getLevel1Categories()
{
$result = $this->HomeModel->getLevel1Categories();
echo json_encode($result);
}
}
?>
</code></pre>
<h1>Model function</h1>
<pre><code>public function getLevel1Categories()
{
$this->db->select()
->from('category_level1_tbl');
$query = $this->db->get()->result();
return $query;
}
</code></pre>
<h1>html</h1>
<pre><code><div>
<div>
<h3>Level 1 Categories</h3>
</div>
<div >
<ul id="level1">
</ul>
</div>
</div>
</code></pre>
| 0debug |
Vectors must be the same lengths : <p>I want to plot angles against time. Here the code:</p>
<pre><code>clear all
close all
params.t0 = 0; % start time of simulation
params.tend = 10; % end time
params.m=2^8; %number of steps in each Brownian path
params.deltat=params.tend/params.m; % time increment for each Brownian path
params.R=4; % integer number to obtain EM stepsize from Brownian path stepsize
params.dt = params.R*params.deltat; %0.01; % time increment for both EM and ode45
params.D=0.001; % diffusion constant
deltat= params.tend/params.m; % time increment for each Brownian path
params.D=0.1; %diffsuion
params.R=4;
params.dt = params.R*params.deltat;
theta0=pi*rand(1);
phi0=2*pi*rand(1);
P_initial=[theta0;phi0];
[theta,phi]=difusion_SDE(params);
plot([0:params.dt:params.tend],[theta0,theta],'--*')
hold on
plot([0:params.dt:params.tend],[phi0,phi],'--*')
</code></pre>
<p>and the function file:</p>
<pre><code>function [theta,phi]=difusion_SDE(params)
dW=sqrt(params.deltat)*randn(2,params.m);
theta0=pi*rand(1);
phi0=2*pi*rand(1);
P_initial=[ theta0; phi0];
L = params.m/ params.R;
pem=zeros(2,L);
Ang_rescale=zeros(2,L);
Ptemp=P_initial;
for j=1:L
Winc = sum(dW(:,[ params.R*(j-1)+1: params.R*j]),2);
theta=Ptemp(1);
phi=Ptemp(2);
A=[ params.D.*cot(theta);...
0];
B=[sqrt(params.D) 0 ;...
0 sqrt(params.D)./sin(theta) ];
Ptemp=Ptemp+ params.dt*A+B*Winc;
pem(1,j)=Ptemp(1);
pem(2,j)=Ptemp(2);
Ang_rescale(1,j)=mod(pem(1,j),pi);
Ang_rescale(2,j)=mod(pem(2,j),2*pi);
theta= Ang_rescale(1,j);
phi=Ang_rescale(2,j);
end
</code></pre>
<p>When I run the code, I got this message error
Error using plot
Vectors must be the same lengths.
I appreciate any help to solve this error</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.