problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Are there any examples of serious websites using riot.js? : <p>I have scoured the internet (clicked next page on google a couple of times) and the riot.js docs, and can't find a single high traffic website that uses riot.js. </p>
<p>Are there any large scale websites/webapps using riot.js?</p>
| 0debug
|
I want to find the percentage : <p>i want to find the 25% value of any int or double like</p>
<p>int 100 - 25% should = 75 or
int 200 - 25% should = 150 etc</p>
<p>how can i do something like that in JAVA</p>
| 0debug
|
Do mutexes guarantee ordering of acquisition? : <p>A coworker had an issue recently that boiled down to what we believe was the following sequence of events in a C++ application with two threads:</p>
<ul>
<li><p>Thread A holds a mutex.</p></li>
<li><p>While thread A is holding the mutex, thread B attempts to lock it. Since it is held, thread B is suspended.</p></li>
<li><p>Thread A finishes the work that it was holding the mutex for, thus releasing the mutex.</p></li>
<li><p>Very shortly thereafter, thread A needs to touch a resource that is protected by the mutex, so it locks it again.</p></li>
<li><p>It appears that thread A is given the mutex again; thread B is still waiting, even though it "asked" for the lock first.</p></li>
</ul>
<p>Does this sequence of events fit with the semantics of, say, C++11's <code>std::mutex</code> and/or pthreads? I can honestly say I've never thought about this aspect of mutexes before.</p>
| 0debug
|
int64_t qemu_strtosz_metric(const char *nptr, char **end)
{
return do_strtosz(nptr, end, 'B', 1000);
}
| 1threat
|
void avpriv_do_elbg(int *points, int dim, int numpoints, int *codebook,
int numCB, int max_steps, int *closest_cb,
AVLFG *rand_state)
{
int dist;
elbg_data elbg_d;
elbg_data *elbg = &elbg_d;
int i, j, k, last_error, steps=0;
int *dist_cb = av_malloc(numpoints*sizeof(int));
int *size_part = av_malloc(numCB*sizeof(int));
cell *list_buffer = av_malloc(numpoints*sizeof(cell));
cell *free_cells;
int best_dist, best_idx = 0;
elbg->error = INT_MAX;
elbg->dim = dim;
elbg->numCB = numCB;
elbg->codebook = codebook;
elbg->cells = av_malloc(numCB*sizeof(cell *));
elbg->utility = av_malloc(numCB*sizeof(int));
elbg->nearest_cb = closest_cb;
elbg->points = points;
elbg->utility_inc = av_malloc(numCB*sizeof(int));
elbg->scratchbuf = av_malloc(5*dim*sizeof(int));
elbg->rand_state = rand_state;
do {
free_cells = list_buffer;
last_error = elbg->error;
steps++;
memset(elbg->utility, 0, numCB*sizeof(int));
memset(elbg->cells, 0, numCB*sizeof(cell *));
elbg->error = 0;
for (i=0; i < numpoints; i++) {
best_dist = distance_limited(elbg->points + i*elbg->dim, elbg->codebook + best_idx*elbg->dim, dim, INT_MAX);
for (k=0; k < elbg->numCB; k++) {
dist = distance_limited(elbg->points + i*elbg->dim, elbg->codebook + k*elbg->dim, dim, best_dist);
if (dist < best_dist) {
best_dist = dist;
best_idx = k;
}
}
elbg->nearest_cb[i] = best_idx;
dist_cb[i] = best_dist;
elbg->error += dist_cb[i];
elbg->utility[elbg->nearest_cb[i]] += dist_cb[i];
free_cells->index = i;
free_cells->next = elbg->cells[elbg->nearest_cb[i]];
elbg->cells[elbg->nearest_cb[i]] = free_cells;
free_cells++;
}
do_shiftings(elbg);
memset(size_part, 0, numCB*sizeof(int));
memset(elbg->codebook, 0, elbg->numCB*dim*sizeof(int));
for (i=0; i < numpoints; i++) {
size_part[elbg->nearest_cb[i]]++;
for (j=0; j < elbg->dim; j++)
elbg->codebook[elbg->nearest_cb[i]*elbg->dim + j] +=
elbg->points[i*elbg->dim + j];
}
for (i=0; i < elbg->numCB; i++)
vect_division(elbg->codebook + i*elbg->dim,
elbg->codebook + i*elbg->dim, size_part[i], elbg->dim);
} while(((last_error - elbg->error) > DELTA_ERR_MAX*elbg->error) &&
(steps < max_steps));
av_free(dist_cb);
av_free(size_part);
av_free(elbg->utility);
av_free(list_buffer);
av_free(elbg->cells);
av_free(elbg->utility_inc);
av_free(elbg->scratchbuf);
}
| 1threat
|
How to use React Router with Laravel? : <p>I needing use <code>React Router</code> with a <code>Laravel</code> project.</p>
<p>But when I create router on the <code>React Router</code> and try access, <code>Laravel</code> accuse Route not exist error.</p>
<p>How to can I use <code>React Router</code> to manager Laravel project routes?</p>
<pre><code>render((
<Router history={browserHistory}>
<Route path="/" component={App}/>
<Route path="/profile" component={Profile}/> // this route I trying access
</Router>
), document.getElementById('root'));
</code></pre>
| 0debug
|
void do_td (int flags)
{
if (!likely(!(((int64_t)T0 < (int64_t)T1 && (flags & 0x10)) ||
((int64_t)T0 > (int64_t)T1 && (flags & 0x08)) ||
((int64_t)T0 == (int64_t)T1 && (flags & 0x04)) ||
((uint64_t)T0 < (uint64_t)T1 && (flags & 0x02)) ||
((uint64_t)T0 > (uint64_t)T1 && (flags & 0x01)))))
do_raise_exception_err(EXCP_PROGRAM, EXCP_TRAP);
}
| 1threat
|
static void decode_delta_j(uint8_t *dst,
const uint8_t *buf, const uint8_t *buf_end,
int w, int h, int bpp, int dst_size)
{
int32_t pitch;
uint8_t *ptr;
uint32_t type, flag, cols, groups, rows, bytes;
uint32_t offset;
int planepitch_byte = (w + 7) / 8;
int planepitch = ((w + 15) / 16) * 2;
int kludge_j, b, g, r, d;
GetByteContext gb;
pitch = planepitch * bpp;
kludge_j = w < 320 ? (320 - w) / 8 / 2 : 0;
bytestream2_init(&gb, buf, buf_end - buf);
while (bytestream2_get_bytes_left(&gb) >= 2) {
type = bytestream2_get_be16(&gb);
switch (type) {
case 0:
return;
case 1:
flag = bytestream2_get_be16(&gb);
cols = bytestream2_get_be16(&gb);
groups = bytestream2_get_be16(&gb);
for (g = 0; g < groups; g++) {
offset = bytestream2_get_be16(&gb);
if (bytestream2_get_bytes_left(&gb) < 1)
return;
if (kludge_j)
offset = ((offset / (320 / 8)) * pitch) + (offset % (320 / 8)) - kludge_j;
else
offset = ((offset / planepitch_byte) * pitch) + (offset % planepitch_byte);
for (b = 0; b < cols; b++) {
for (d = 0; d < bpp; d++) {
uint8_t value = bytestream2_get_byte(&gb);
if (offset >= dst_size)
return;
ptr = dst + offset;
if (flag)
ptr[0] ^= value;
else
ptr[0] = value;
offset += planepitch;
}
}
if ((cols * bpp) & 1)
bytestream2_skip(&gb, 1);
}
break;
case 2:
flag = bytestream2_get_be16(&gb);
rows = bytestream2_get_be16(&gb);
bytes = bytestream2_get_be16(&gb);
groups = bytestream2_get_be16(&gb);
for (g = 0; g < groups; g++) {
offset = bytestream2_get_be16(&gb);
if (kludge_j)
offset = ((offset / (320 / 8)) * pitch) + (offset % (320/ 8)) - kludge_j;
else
offset = ((offset / planepitch_byte) * pitch) + (offset % planepitch_byte);
for (r = 0; r < rows; r++) {
for (d = 0; d < bpp; d++) {
unsigned noffset = offset + (r * pitch) + d * planepitch;
if (bytestream2_get_bytes_left(&gb) < 1)
return;
for (b = 0; b < bytes; b++) {
uint8_t value = bytestream2_get_byte(&gb);
if (noffset >= dst_size)
return;
ptr = dst + noffset;
if (flag)
ptr[0] ^= value;
else
ptr[0] = value;
noffset++;
}
}
}
if ((rows * bytes * bpp) & 1)
bytestream2_skip(&gb, 1);
}
break;
default:
return;
}
}
}
| 1threat
|
Write query for this example : <p>I have a table with below data,I want to write a query that give me id and the number of days that have connection. </p>
<p>For example for id 1 give me 2 times (2016-09-20 , 2016-09-22)</p>
<p><a href="https://i.stack.imgur.com/vs3t8.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vs3t8.jpg" alt="enter image description here"></a></p>
| 0debug
|
static int local_mknod(FsContext *ctx, const char *path, mode_t mode, dev_t dev)
{
return mknod(rpath(ctx, path), mode, dev);
}
| 1threat
|
How to make 2 varible add side by side?(Java) 2+2=22 : <p>int x= 2;</p>
<p>int y= 2;</p>
<p>int z= (?);</p>
<p>System.out.println(z);</p>
<p>I want it to print 22 instead of 4</p>
| 0debug
|
A program that replaces all s1's with s2 in a string : <p>I found this program that replaces all s1's with s2 in a string and i don't understant the sequence<br>
int i = strstr(s, s1) - s ?</p>
<pre><code>enter code here
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char *my_replace(char *s, char *s1, char *s2)
{
char *aux = (char *) malloc((sizeof(s) - sizeof(s1)) + sizeof(s2) + 1);
int i = strstr(s, s1) - s, j = strlen(s1);
strncpy(aux, s, i);
strcat(aux, s2);
strncat(aux, (s + i + j), (strlen(s) - i - j));
return aux;
}
int main()
{
char *s, *s1, *s2;
s = (char*)malloc(10);
s1 = (char*)malloc(10);
s2 = (char*)malloc(10);
char *aux;
scanf("%s%s%s", s, s1, s2);
aux = my_replace(s, s1, s2);
printf("%s\n", aux);
return 0;
}
</code></pre>
| 0debug
|
static int slirp_state_load(QEMUFile *f, void *opaque, int version_id)
{
Slirp *slirp = opaque;
struct ex_list *ex_ptr;
while (qemu_get_byte(f)) {
int ret;
struct socket *so = socreate(slirp);
if (!so)
return -ENOMEM;
ret = vmstate_load_state(f, &vmstate_slirp_socket, so, version_id);
if (ret < 0)
return ret;
if ((so->so_faddr.s_addr & slirp->vnetwork_mask.s_addr) !=
slirp->vnetwork_addr.s_addr) {
return -EINVAL;
}
for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
if (ex_ptr->ex_pty == 3 &&
so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr &&
so->so_fport == ex_ptr->ex_fport) {
break;
}
}
if (!ex_ptr)
return -EINVAL;
so->extra = (void *)ex_ptr->ex_exec;
}
if (version_id >= 2) {
slirp->ip_id = qemu_get_be16(f);
}
if (version_id >= 3) {
slirp_bootp_load(f, slirp);
}
return 0;
}
| 1threat
|
bool migration_in_setup(MigrationState *s)
{
return s->state == MIG_STATE_SETUP;
}
| 1threat
|
How to create a text input box with pygame? : <p>I want to get some text input from the user in python and display what they are typing in a text box, and when they press enter, it gets stored in a string. I've looked everywhere but i just can't find anything.(I'm using pygame)</p>
| 0debug
|
clear the contents of dynamic arrays inside the structure from a function in C : This is the sample version of my project and it throws run-time error because I could not clear the contents and already allocated dynamic memory of data array in the bipartition_fn() function.
Can someone please help me with clearing the contents of data array in bipartition data structure after every recursion of bipartition_fn() in the loop inside kdtree_fn()
#include <stdio.h>
#include <stdlib.h>
typedef struct{
int **data;
}kdtree;
typedef struct{
int *data;
}bipartition;
void kdtree_fn(int *data, bipartition bp);
bipartition bipartition_fn(int *data);
int main(){
int i;
int *data;
data = malloc(4*sizeof(int));
for(i=0; i<4;i++)
data[i] = i;
bipartition bp;
kdtree kd;
kdtree_fn(data,bp);
}
void kdtree_fn(int *data, bipartition bp){
kdtree k1;
k1.data = malloc(5*4*sizeof(int));
int i,j;
for(j=0; j<5; j++){
bp = bipartition_fn(data);
for( i=0; i<4; i++){
k1.data[j][i] = bp.data[i];
printf("%d ",k1.data[j][i]);
}
printf("\n");
}
return k1;
}
bipartition bipartition_fn(int *data){
bipartition bp1;
int i;
bp1.data = malloc(4*sizeof(int));
for(i=0; i<4; i++){
bp1.data[i] = data[i] +1;
}
return bp1;
}
| 0debug
|
generate ms excle with insert table having merge cells and formulas : **by using Apache poi i can insert table but i have to apply formulas, merge cells on table columns.
[enter image description here][1]
this the requirement of to generate excel file
[1]: https://i.stack.imgur.com/JgOlj.jpg
| 0debug
|
Import Data from .text file using Multithread in Java : <p>I need to load big size data from a .text file using Java. But because the file is very big, I would like to use multithread for this operation.
Could you help me about it?</p>
<p>Thanks</p>
| 0debug
|
Creating dynamic Tuple : <p>Are there a good way to create dynamic number of arguments like:</p>
<pre><code>public ??? Tuple<string,?????> returnProperTuple(int NumberOfArgs)
{// if/case
if(NumberOfArgs == 2)
return new Tuple<string, string>();
...
if(NumberOfArgs == 4)
return new Tuple<string, string, string, string>();
...
}
</code></pre>
| 0debug
|
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
| 1threat
|
How do i remove JSON Data? : I have the following JSON structure:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
[{"type":0,"id":1,"children":[{"type":0,"id":14},{"type":0,"id":1}]},{"type":0,"id":16,"children":[{"type":0,"id":15,"children":[{"type":0,"id":13},{"type":0,"id":17},{"type":0,"id":18}]}]}]
<!-- end snippet -->
How do i remove data "type":0,"id":15 from my json?
thanks
| 0debug
|
static int find_unused_picture(MpegEncContext *s, int shared)
{
int i;
if (shared) {
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
if (s->picture[i].f.data[0] == NULL)
return i;
}
} else {
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
if (pic_is_unused(s, &s->picture[i]))
return i;
}
}
return AVERROR_INVALIDDATA;
}
| 1threat
|
WARN [middleware:karma]: Invalid file type, defaulting to js. ts : <p>When I run unit testing via karma, I got those warning:</p>
<pre><code>12 02 2019 14:01:05.740:WARN [middleware:karma]: Invalid file type, defaulting to js. ts
12 02 2019 14:01:05.741:WARN [middleware:karma]: Invalid file type, defaulting to js. ts
</code></pre>
<p>I assumed that the type of the <code>karma.conf.js</code> file caused the issue, so I changed it to <code>karma.conf.ts</code>.</p>
<p>However the issue still happened, so it would be great if someone can tell me how to disable this warning.</p>
<p>Below is my karma.conf.ts file</p>
<pre><code>module.exports = function karmaConfig(config) {
config.set({
singleRun: true,
frameworks: [
'jasmine'
],
files: [
'sdk/**/*.spec.ts'
],
preprocessors: {
'sdk/**/*.spec.ts': ['webpack', 'sourcemap'],
'sdk/**/!(*.spec).ts': ['coverage']
},
browsers: [
'PhantomJS'
],
reporters: [
'progress',
'coverage',
'junit'
],
coverageReporter: {
dir: 'coverage/',
reporters: [
{ type: 'text-summary' },
{ type: 'html' },
{
type: 'lcov',
dir: 'reports',
subdir: 'coverage'
}
]
},
junitReporter: {
outputFile: 'reports/junit/TEST-karma.xml',
useBrowserName: false
},
transports: ['polling'],
webpack: require('./webpack.config'),
webpackMiddleware: {
stats: 'errors-only'
},
logLevel: config.LOG_INFO,
});
};
</code></pre>
<p>I use webpack <code>4.16.5</code> and karma <code>4.0.0</code></p>
| 0debug
|
static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
int buf_size, AVCodecContext *avctx)
{
HEVCParserContext *ctx = s->priv_data;
HEVCContext *h = &ctx->h;
GetBitContext *gb;
SliceHeader *sh = &h->sh;
HEVCParamSets *ps = &h->ps;
H2645Packet *pkt = &ctx->pkt;
const uint8_t *buf_end = buf + buf_size;
int state = -1, i;
H2645NAL *nal;
int is_global = buf == avctx->extradata;
if (!h->HEVClc)
h->HEVClc = av_mallocz(sizeof(HEVCLocalContext));
if (!h->HEVClc)
return AVERROR(ENOMEM);
gb = &h->HEVClc->gb;
s->pict_type = AV_PICTURE_TYPE_I;
s->key_frame = 0;
s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
h->avctx = avctx;
if (!buf_size)
return 0;
if (pkt->nals_allocated < 1) {
H2645NAL *tmp = av_realloc_array(pkt->nals, 1, sizeof(*tmp));
if (!tmp)
return AVERROR(ENOMEM);
pkt->nals = tmp;
memset(pkt->nals, 0, sizeof(*tmp));
pkt->nals_allocated = 1;
}
nal = &pkt->nals[0];
for (;;) {
int src_length, consumed;
int ret;
buf = avpriv_find_start_code(buf, buf_end, &state);
if (--buf + 2 >= buf_end)
break;
src_length = buf_end - buf;
h->nal_unit_type = (*buf >> 1) & 0x3f;
h->temporal_id = (*(buf + 1) & 0x07) - 1;
if (h->nal_unit_type <= NAL_CRA_NUT) {
if (src_length > 20)
src_length = 20;
}
consumed = ff_h2645_extract_rbsp(buf, src_length, nal);
if (consumed < 0)
return consumed;
ret = init_get_bits8(gb, nal->data + 2, nal->size);
if (ret < 0)
return ret;
switch (h->nal_unit_type) {
case NAL_VPS:
ff_hevc_decode_nal_vps(gb, avctx, ps);
break;
case NAL_SPS:
ff_hevc_decode_nal_sps(gb, avctx, ps, 1);
break;
case NAL_PPS:
ff_hevc_decode_nal_pps(gb, avctx, ps);
break;
case NAL_SEI_PREFIX:
case NAL_SEI_SUFFIX:
ff_hevc_decode_nal_sei(h);
break;
case NAL_TRAIL_N:
case NAL_TRAIL_R:
case NAL_TSA_N:
case NAL_TSA_R:
case NAL_STSA_N:
case NAL_STSA_R:
case NAL_RADL_N:
case NAL_RADL_R:
case NAL_RASL_N:
case NAL_RASL_R:
case NAL_BLA_W_LP:
case NAL_BLA_W_RADL:
case NAL_BLA_N_LP:
case NAL_IDR_W_RADL:
case NAL_IDR_N_LP:
case NAL_CRA_NUT:
if (is_global) {
av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", h->nal_unit_type);
return AVERROR_INVALIDDATA;
}
sh->first_slice_in_pic_flag = get_bits1(gb);
s->picture_structure = h->picture_struct;
s->field_order = h->picture_struct;
if (IS_IRAP(h)) {
s->key_frame = 1;
sh->no_output_of_prior_pics_flag = get_bits1(gb);
}
sh->pps_id = get_ue_golomb(gb);
if (sh->pps_id >= MAX_PPS_COUNT || !ps->pps_list[sh->pps_id]) {
av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id);
return AVERROR_INVALIDDATA;
}
ps->pps = (HEVCPPS*)ps->pps_list[sh->pps_id]->data;
if (ps->pps->sps_id >= MAX_SPS_COUNT || !ps->sps_list[ps->pps->sps_id]) {
av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", ps->pps->sps_id);
return AVERROR_INVALIDDATA;
}
if (ps->sps != (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data) {
ps->sps = (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data;
ps->vps = (HEVCVPS*)ps->vps_list[ps->sps->vps_id]->data;
}
if (!sh->first_slice_in_pic_flag) {
int slice_address_length;
if (ps->pps->dependent_slice_segments_enabled_flag)
sh->dependent_slice_segment_flag = get_bits1(gb);
else
sh->dependent_slice_segment_flag = 0;
slice_address_length = av_ceil_log2_c(ps->sps->ctb_width *
ps->sps->ctb_height);
sh->slice_segment_addr = get_bitsz(gb, slice_address_length);
if (sh->slice_segment_addr >= ps->sps->ctb_width * ps->sps->ctb_height) {
av_log(avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n",
sh->slice_segment_addr);
return AVERROR_INVALIDDATA;
}
} else
sh->dependent_slice_segment_flag = 0;
if (sh->dependent_slice_segment_flag)
break;
for (i = 0; i < ps->pps->num_extra_slice_header_bits; i++)
skip_bits(gb, 1);
sh->slice_type = get_ue_golomb(gb);
if (!(sh->slice_type == I_SLICE || sh->slice_type == P_SLICE ||
sh->slice_type == B_SLICE)) {
av_log(avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n",
sh->slice_type);
return AVERROR_INVALIDDATA;
}
s->pict_type = sh->slice_type == B_SLICE ? AV_PICTURE_TYPE_B :
sh->slice_type == P_SLICE ? AV_PICTURE_TYPE_P :
AV_PICTURE_TYPE_I;
if (ps->pps->output_flag_present_flag)
sh->pic_output_flag = get_bits1(gb);
if (ps->sps->separate_colour_plane_flag)
sh->colour_plane_id = get_bits(gb, 2);
if (!IS_IDR(h)) {
sh->pic_order_cnt_lsb = get_bits(gb, ps->sps->log2_max_poc_lsb);
s->output_picture_number = h->poc = ff_hevc_compute_poc(h, sh->pic_order_cnt_lsb);
} else
s->output_picture_number = h->poc = 0;
if (h->temporal_id == 0 &&
h->nal_unit_type != NAL_TRAIL_N &&
h->nal_unit_type != NAL_TSA_N &&
h->nal_unit_type != NAL_STSA_N &&
h->nal_unit_type != NAL_RADL_N &&
h->nal_unit_type != NAL_RASL_N &&
h->nal_unit_type != NAL_RADL_R &&
h->nal_unit_type != NAL_RASL_R)
h->pocTid0 = h->poc;
return 0;
}
buf += consumed;
}
if (!is_global)
av_log(h->avctx, AV_LOG_ERROR, "missing picture in access unit\n");
return -1;
}
| 1threat
|
AssetManager to parse local JSON file returns NullPointer : <p>I have red many topics and questions about it, but can't find any solution. I am also very new to Android and Java.</p>
<p>What I was trying to do is to parse my local JSON file and to set an adapter to view my Strings in a ListView. Shouldn't be too complicated, but I got this error:</p>
<pre><code>01-10 10:04:38.109 29962-29962/com.thkoeln.stucked E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.thkoeln.stucked, PID: 29962
java.lang.RuntimeException: Unable to start activity ComponentInfo{com../com...MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.AssetManager android.content.Context.getAssets()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.AssetManager android.content.Context.getAssets()' on a null object reference
at android.content.ContextWrapper.getAssets(ContextWrapper.java:81)
at com.thkoeln.stucked.JSONParser.loadJSONFromAsset(JSONParser.java:28)
at com.thkoeln.stucked.JSONParser.parseJson(JSONParser.java:52)
at com.thkoeln.stucked.MainActivity.onCreate(MainActivity.java:24)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
</code></pre>
<p>And here is my MainActivity.java :</p>
<pre><code>package com.thkoeln.stucked;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ListView;
import android.widget.ListAdapter;
import android.widget.SimpleAdapter;
public class MainActivity extends AppCompatActivity {
ListView activityList;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
activityList = (ListView) findViewById(R.id.activityList);
String fromArray[] = {"uid", "uname", "ustart"};
int to[] = {R.id.uid, R.id.uname, R.id.ustart};
JSONParser jp = new JSONParser();
jp.parseJson();
/*ListAdapter adapter = new SimpleAdapter(this, jp.userList, R.layout.user_item, fromArray, to);
activityList.setAdapter(adapter);*/
}
}
</code></pre>
<p>And this is my JSONParser.java :</p>
<pre><code>package com.thkoeln.stucked;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.ListView;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
public class JSONParser extends AppCompatActivity {
ArrayList<HashMap<String, String>> userList;
public String loadJSONFromAsset() {
String json = null;
try {
InputStream is = getAssets().open("users.json");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
json = new String(buffer, "UTF-8");
} catch (IOException ex) {
ex.printStackTrace();
}
return json;
}
public JSONObject parseJson() {
//ArrayList<HashMap<String, String>> userList
try {
JSONObject reader = new
JSONObject(String.valueOf(loadJSONFromAsset()));
JSONArray users = reader.getJSONArray("users");
Log.d("AnzahlUser", String.valueOf(users.length()));
for (int i = 0; i < users.length(); i++) {
JSONObject u = users.getJSONObject(i);
Log.d("Details-->", u.toString());
String uid = u.getString("uid");
String uname = u.getString("uname");
String ustart = u.getString("ustart");
//String uend = u.getString("u.end");
HashMap<String, String> user = new HashMap<>();
user.put("uid", uid);
user.put("uname", uname);
user.put("ustart", ustart);
//user.put("u.end", uend);
userList.add(user);
}
} catch (final JSONException e) {
e.printStackTrace();
}
return null;
}
}
</code></pre>
<p>I would be so thankful, if someone could help me with these ...</p>
| 0debug
|
How to get a approximate equation for reverse look up : Is there any method or way to get the approximate equation(x = g(y)) for doing a reverse lookup from Y to X. Following is the simple y = f(x) and it's plot.
```
import numpy as np
import matplotlib.pyplot as plt
formula = "2*x**6 + x**5 -3*x**4 + 7*x**3 + 9*x**2 + x + 6"
x = np.arange(1, 10)
y = eval(formula)
plt.plot(x, y)
plt.xlabel('X')
plt.ylabel('Y')
plt.show()
```
[Attaching the simple graph here][1]
[1]: https://i.stack.imgur.com/xIXXx.png
Can you please suggest me any possible way in R or Python to get reverse lookup function(From Y to X) with a minimal margin of error.
| 0debug
|
I'm trying to create a BlackJack game in java.(Ready to Program IDE) How do I turn an 11 into a 1 like I'm trying to do below? : <p>This is my entire code. I can't seem to find a way to pick out the aces and turn them into 1s if the total goes over 21.
/*********************************************************************************************************************************************************************</p>
<pre><code>Name:
BlackJack_Mason_Haddock
Description:
The famous known game "BlackJack" created in Java.
History:
Nov 16 2016 / M. Haddock / Created: Code skeleton
Nov 17 2016 / M. Haddock / Created: Random number generator from 1 to 10
*********************************************************************************************************************************************************************/
import java.awt.*; // Used in graphics
import java.awt.event.*; // For mouse stuff
import java.applet.*; // For mouse/music stuff
import java.io.*; // For input and output
import java.util.*; // For date and time stuff
import java.lang.*; // For point stuff
import hsa.Console; // Special console input output commands
class BlackJack_Mason_Haddock
{
public static void Title (Console c)
{
}
public static void Game (Console c)
{
int givenNumber[] = new int [52]; // Makes an empty array of integers of 52. Used for 52 cards in the deck
int i; // Used for any for loops of drawing cards
int total = 0; // Sets a base number for the total number of card scores
char next; // Used to catch the first letter of the string "string"
String string; // Used for a string given by the user
int ace = 11; // Setting aces to 11
int ace2 = 1; // Setting aces to 1 if 11 is over 21
for (i = 0 ; i < 1 ; i++) // Runs through the code below twice, once at a time.
{
givenNumber [i] = (int) (Math.random () * (11 - 1)) + 1; // Picks a random number from 1 to 10
c.print (givenNumber [i] + " "); // Outputs the random number picked above, adds a space for the second number
total = total + givenNumber [i];
if ((total < 22) && (givenNumber [i] == 1))
{
givenNumber [i] = ace;
total = total + 10;
}
if ((total > 21) && (givenNumber [i] == ace))
{
givenNumber [i] = ace2;
}
givenNumber [i] = (int) (Math.random () * (11 - 1)) + 1; // Picks a random number from 1 to 10
c.print (givenNumber [i] + " "); // Outputs the random number picked above, adds a space for the second number
total = total + givenNumber [i];
for (i = 0 ; i < 51 ; i++)
{
if ((total < 22) && (givenNumber [i] == 1))
{
givenNumber [i] = ace;
total = total + 10;
}
}
for (i = 0 ; i < 51 ; i++)
{
if ((total > 21) && (givenNumber [i] == ace))
{
givenNumber [i] = ace2;
}
}
if (total == 21)
{
c.print ("BlackJack! You Win!");
return;
}
do
{
c.println ("");
c.print ("Will you hit or stand?");
c.println ("");
string = c.readString ();
next = string.charAt (0);
c.println ("");
if ((total < 21) && (next == 'S') || (next == 's'))
{
c.print ("You stand at " + total);
return;
}
else if ((total < 21) && (next == 'H') || (next == 'h'))
{
givenNumber [i] = (int) (Math.random () * (11 - 1)) + 1;
c.print (givenNumber [i] + " ");
for (i = 0 ; i < 51 ; i++)
{
if ((total > 22) && (givenNumber [i] == 11))
{
total = total - 10;
}
}
total = total + givenNumber [i];
c.println ("");
c.print ("Total " + total + " ");
if (total == 21)
{
c.print ("You Win!");
return;
}
if (total > 21)
{
c.println ("");
c.print ("You bust!");
return;
}
} //End of the if statement
} //End of the for statement
while (true);
}
}
public static void main (String[] args)
{
Console c = new Console (32, 167, "BlackJack");
Title (c);
Game (c);
}
}
</code></pre>
| 0debug
|
Cant search my project database, various warnings : can i just start off by saying im doing a computing course where one of the units is intro to PHP and that im JUST starting to get into PHP so im very basic at this point, I have been tasked with making a site with a search page that you can search different movies etc.
**My production page (Search Page)**
<!DOCTYPE html>
<html>
<head>
<title>Royal Theatre</title>
<link rel="stylesheet" href="css/main.css">
<meta name="viewport" content="width=device-width">
<meta charset="UTF-8">
</head>
<body>
<header>
<img src="image/logo2.png">
</header>
<div class="nav">
<ul>
<li class="home"><a href="index.php">Home</a></li>
<li class="Production"><a class="active" href="production.php">Production</a></li>
<li class="Contact"><a href="contact.php">Contact</a></li>
</ul>
</div>
<h1>Search For Shows</h1>
<form action="presults.php" method="GET">
<br>
<label for="name" class="pd">Production Name:</label>
<br>
<input type="text" name="name">
<br>
<label for="genre" class="gnr">Genre:</label>
<br>
<input type="text" name="genre">
<br>
<label for="date" class="dte">Date:</label>
<br>
<input type="date" name="date">
<br>
<label for="time" class="tme">Starting Time:</label>
<br>
<input type="date_list" name="time">
<datalist id="production">
<option value="Little Stars: Dance">
<option value="RSNO Community Orchestra">
<option value="Nicki Minaj">
<option value="Harlem Globetrotters">
<option value="Alan Davies">
<option value="WWE">
<option value="Amazon Echo and the singing AI">
<option value="Spirited Away The Play">
<option value="A Generic Stand Up Comedy Act">
<option value="My Life Is A Joke">
<option value="Rangers Football Club">
<option value="NEDs">
<option value="NZXT & The CAM Software">
<option value="Franky Boil Tribute Act">
<option value="Wee Archie & The Akitas">
</datalist>
<input type="submit" name="submit" value="Search" />
</form>
<table>
<?php
echo "<TR><th>Production Reference</th> <th>Production Name</th> <th>Genre</th> <th>Date</th> <th>Starting Time</th> <th>Price Band</th>";
while ($row = mysqli_fetch_array($result)){
$reference=$row['reference'];
$name=$row['name'];
$genre=$row['genre'];
$date=$row['date'];
$time=$row['time'];
$pband=$row['pband'];
?>
<tr>
<td>
<?php echo "$reference";?>
</td>
<td>
<?php echo "$name";?>
</td>
<td>
<?php echo "$genre";?>
</td>
<td>
<?php echo "$date";?>
</td>
<td>
<?php echo "$time";?>
</td>
<td>
<?php echo "$pband";?>
</td>
</tr>
<?php }?>
</table>
<footer>
© Scott
</footer>
</body>
</html>
**My results php**
<?php
if(!isset($_GET['submit'])){
header('Location: production.php');
}else{
$name = $_GET['name'];
$genre = $_GET['genre'];
$time = $_GET['time'];
$date = $_GET['date'];
include'connection.php';
$query = "SELECT name, genre, date, time, adult, child, concession, price.pband FROM production, price WHERE name = '$name' AND genre = '$genre' AND date = '$date' AND time = '$time' AND production.pband = price.pband";
$result = mysqli_query($connection, $query);
?>
<!Doctype HTML>
<html>
<head>
<meta charset="utf-8">
<title>Production Results</title>
<link rel="stylesheet" type="text/css" href="main.css"> </head>
<body>
<h1>Search Result</h1>
<table>
<th class="TH">Production Reference</th>
<th class="TH">Production Name</th>
<th class="TH">Genre</th>
<th class="TH">Date</th>
<th class="TH">Starting Time</th>
<th class="TH">Price Band</th>
<?php
if(mysqli_num_rows($result) == 0){echo"<tr> <td class='TD'>" . 'No Results Found' . "</td></tr>";}
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
$date = $row['date'];
$date = strtotime($date);
$date = date('d-M-Y', $date);
echo"<td class='TD'><a href='production.php'>Back to the main
search page</a></td>";
echo "</table>";
echo "<tr>
<td class='TD'>" . $row['reference'] . "</td>
<td class='TD'>" . $row['name'] . "</td>
<td class='TD'>" . $row['genre'] . "</td>
<td class='TD'>" . $row['date'] . "</td>
<td class='TD'>" . $row['time'] . "</td>
<td class='TD'>" . $row['pband'] . '" /> '. "</td>
</tr>";
}
echo"</table>";
}
?>
**My connection.php**
<?php
$host = 'localhost';
$user = 'root';
$pass = '';
$db = 'theatre';
$con = mysqli_connect("$host", "$user", "",$db);
if(!$con){
die("Connection Failed " . mysqli_connect_error());
}else{
echo "";
}
?>
Any help at all is really greatly appreciated, i have been at this for hours on end and just cant see what the problem is
Thanks a lot!
| 0debug
|
static void pc_cmos_init_late(void *opaque)
{
pc_cmos_init_late_arg *arg = opaque;
ISADevice *s = arg->rtc_state;
int16_t cylinders;
int8_t heads, sectors;
int val;
int i, trans;
Object *container;
CheckFdcState state = { 0 };
val = 0;
if (ide_get_geometry(arg->idebus[0], 0,
&cylinders, &heads, §ors) >= 0) {
cmos_init_hd(s, 0x19, 0x1b, cylinders, heads, sectors);
val |= 0xf0;
}
if (ide_get_geometry(arg->idebus[0], 1,
&cylinders, &heads, §ors) >= 0) {
cmos_init_hd(s, 0x1a, 0x24, cylinders, heads, sectors);
val |= 0x0f;
}
rtc_set_memory(s, 0x12, val);
val = 0;
for (i = 0; i < 4; i++) {
if (ide_get_geometry(arg->idebus[i / 2], i % 2,
&cylinders, &heads, §ors) >= 0) {
trans = ide_get_bios_chs_trans(arg->idebus[i / 2], i % 2) - 1;
assert((trans & ~3) == 0);
val |= trans << (i * 2);
}
}
rtc_set_memory(s, 0x39, val);
for (i = 0; i < ARRAY_SIZE(fdc_container_path); i++) {
container = container_get(qdev_get_machine(), fdc_container_path[i]);
object_child_foreach(container, check_fdc, &state);
}
if (state.multiple) {
error_report("warning: multiple floppy disk controllers with "
"iobase=0x3f0 have been found;\n"
"the one being picked for CMOS setup might not reflect "
"your intent");
}
pc_cmos_init_floppy(s, state.floppy);
qemu_unregister_reset(pc_cmos_init_late, opaque);
}
| 1threat
|
Automatically create card on another HTML page including form information : <p>I'm currently creating a website with a list of members on a page.
Members will register via a form, and once the form is filled in, I would like a card component to be created on another page (which will be password protected and only usable by an admin) with the choice to either accept the members request (of which their name will be automatically added to the members page) or decline the request, in which case the card will be deleted.</p>
<p>Can anyone suggest how I might go about automatically creating a card including information via the form?</p>
<p>Thanks in advance.</p>
| 0debug
|
void empty_slot_init(target_phys_addr_t addr, uint64_t slot_size)
{
if (slot_size > 0) {
DeviceState *dev;
SysBusDevice *s;
EmptySlot *e;
dev = qdev_create(NULL, "empty_slot");
s = sysbus_from_qdev(dev);
e = FROM_SYSBUS(EmptySlot, s);
e->size = slot_size;
qdev_init_nofail(dev);
sysbus_mmio_map(s, 0, addr);
}
}
| 1threat
|
How to switch the capitals characters transform in DBeaver? : <p>The SQL editor in DBeaver has this unsupportable feature of transforming all capital characters into lower case. This happens as you type, the most schizophrenic thing.</p>
<p>I have searched in the menus and the Preferences dialogue, but I can not find the setting to this feature. How can I switch it off? </p>
| 0debug
|
How to launch Chrome Advanced REST Client : <p>There's <a href="https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo?hl=en-US" rel="noreferrer">this great REST client "extension" for Chrome</a>, but the only way I can find to launch it is to go to the Chrome webstore!</p>
<p>It's listed as Enabled in my Chrome extensions. Is there any local way to launch it?</p>
<p><a href="https://i.stack.imgur.com/dUjGs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dUjGs.png" alt="Advanced REST client Chrome extenstion"></a></p>
| 0debug
|
void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,
int64_t bps_wr,
int64_t iops,
int64_t iops_rd,
int64_t iops_wr,
bool has_bps_max,
int64_t bps_max,
bool has_bps_rd_max,
int64_t bps_rd_max,
bool has_bps_wr_max,
int64_t bps_wr_max,
bool has_iops_max,
int64_t iops_max,
bool has_iops_rd_max,
int64_t iops_rd_max,
bool has_iops_wr_max,
int64_t iops_wr_max,
bool has_iops_size,
int64_t iops_size, Error **errp)
{
ThrottleConfig cfg;
BlockDriverState *bs;
bs = bdrv_find(device);
if (!bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
memset(&cfg, 0, sizeof(cfg));
cfg.buckets[THROTTLE_BPS_TOTAL].avg = bps;
cfg.buckets[THROTTLE_BPS_READ].avg = bps_rd;
cfg.buckets[THROTTLE_BPS_WRITE].avg = bps_wr;
cfg.buckets[THROTTLE_OPS_TOTAL].avg = iops;
cfg.buckets[THROTTLE_OPS_READ].avg = iops_rd;
cfg.buckets[THROTTLE_OPS_WRITE].avg = iops_wr;
if (has_bps_max) {
cfg.buckets[THROTTLE_BPS_TOTAL].max = bps_max;
}
if (has_bps_rd_max) {
cfg.buckets[THROTTLE_BPS_READ].max = bps_rd_max;
}
if (has_bps_wr_max) {
cfg.buckets[THROTTLE_BPS_WRITE].max = bps_wr_max;
}
if (has_iops_max) {
cfg.buckets[THROTTLE_OPS_TOTAL].max = iops_max;
}
if (has_iops_rd_max) {
cfg.buckets[THROTTLE_OPS_READ].max = iops_rd_max;
}
if (has_iops_wr_max) {
cfg.buckets[THROTTLE_OPS_WRITE].max = iops_wr_max;
}
if (has_iops_size) {
cfg.op_size = iops_size;
}
if (!check_throttle_config(&cfg, errp)) {
return;
}
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
if (!bs->io_limits_enabled && throttle_enabled(&cfg)) {
bdrv_io_limits_enable(bs);
} else if (bs->io_limits_enabled && !throttle_enabled(&cfg)) {
bdrv_io_limits_disable(bs);
}
if (bs->io_limits_enabled) {
bdrv_set_io_limits(bs, &cfg);
}
aio_context_release(aio_context);
}
| 1threat
|
Can anyone help we with these xCode errors? : [enter image description here][1]im trying to make an app for my church and am watching a bunch of YT tutorials but im getting a lot of errors
http://imgur.com/a/qgals
[1]: https://i.stack.imgur.com/IaSxP.png
| 0debug
|
*ngIf and *ngFor on <td></td> element : <p>I have a situation where I need *ngIf and *ngFor directive on the same element. I found lot of answers on the stackoverlow but none for the this type of situation.</p>
<p>I have a table in which I'm looping through the array of objects and dynamically write cells in header:</p>
<pre><code> <table border="1" width="100%">
<thead>
<tr>
<td *ngFor="let item of headerItems" *ngIf="item.visible">{{ item?.name }}</td>
</tr>
</thead>
<tbody>
...
</tbody>
</table>
</code></pre>
<p>I want to show/hide if object contains visible set to true. How can I achieve this?</p>
| 0debug
|
void qemu_unregister_clock_reset_notifier(QEMUClock *clock,
Notifier *notifier)
{
qemu_clock_unregister_reset_notifier(clock->type, notifier);
}
| 1threat
|
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
| 1threat
|
Flutter - SWIFT_VERSION must be set to a supported value : <p>Trying out the library simple_permission, fixed the pod error and this came up, no idea how to proceed. There's no setting for the swift version in Build Settings, I tried adding it, but it didn't work.</p>
<pre><code>Launching lib/main.dart on iPhone X in debug mode...
Skipping compilation. Fingerprint match.
Running Xcode clean...
Starting Xcode build...
Xcode build done.
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
=== BUILD TARGET simple_permissions OF PROJECT Pods WITH CONFIGURATION Debug ===
The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.
Could not build the application for the simulator.
Error launching application on iPhone X.
</code></pre>
| 0debug
|
Return filtered JSON variable in Jquery : I have this function to return `iconurl` value, according to `compname` value:
function icons(x){
var comand = x.toLowerCase();
var icon= { "ico":[
{
"iconname": "X",
"iconurl": "resources/img/x.jpg"
},
{
"iconname": "Y",
"iconurl": "resources/img/y.png"
},
{
"iconname": "Z",
"iconurl": "resources/img/z.jpg"
}]
};
var returnedData = $.grep(icon.ico, function (element, index) {
return element.iconname.toLowerCase() == comand;
});
return returnedData[0].iconurl;
}
This works when I call this function only.
When I try to call this function for my variable, I get "Uncaught TypeError: Cannot read property 'iconurl' of undefined".
var compname = cp/X/;
var regExp = /[^/cp]+/;
var regcomp = regExp.exec(compname);
var icourl = icons(regcomp.toString());
Anyone here where is the problem?
Thanks!
| 0debug
|
def count_char_position(str1):
count_chars = 0
for i in range(len(str1)):
if ((i == ord(str1[i]) - ord('A')) or
(i == ord(str1[i]) - ord('a'))):
count_chars += 1
return count_chars
| 0debug
|
static inline void pxa2xx_rtc_int_update(PXA2xxState *s)
{
qemu_set_irq(s->pic[PXA2XX_PIC_RTCALARM], !!(s->rtsr & 0x2553));
}
| 1threat
|
Package for listing version of packages used in a Jupyter notebook : <p>I seem to remember there is a package that printed the versions and relevant information about Python packages used in a Jupyter notebook so the results in it were reproducible. But I cannot remember the name of the package. Can any of you point me in the right direction?</p>
<p>Thanks in advance!</p>
| 0debug
|
Installing a specific version of angular with angular cli : <p>I searched through google and angular cli doc but couldn't find any way to install a specific version of angular using angular cli. is it even possible?</p>
| 0debug
|
Asp.net foreach loop : <p>Is foreach loop check empty index of array or it terminates on that index where elements are ended? for example at index 0 of array the element exists and index 1 is empty and then at index 2 the element exist, is foreach loop check the element at index 2 or terminates at index 1?</p>
| 0debug
|
Null Data from onResponse() of volley in Fragment' onCreateView() : <p>I am trying to get some country data from a URL using volley.
In <strong>onResponse()</strong> data is successfully added to <em>countryList</em> and <em>countryList.size()</em> shows it has 5 countries.
But in <strong>onCreateView()</strong>, when I try to use <em>countryList</em>, it is null and throws <strong>NullPointerException</strong> because of <em>countryList.size()</em> as <em>countryList</em> has null value.
Thanks in advance, here's the code:</p>
<pre><code>public class MyAddress extends Fragment {
ArrayList<Countries> countryList;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.shipping_address, container, false);
RequestCountries();
Toast.makeText(getContext(), countryList.size(), Toast.LENGTH_SHORT).show();
//Some code to use countryList
return rootView;
}
private void RequestCountries() {
final String urlLink = ConstantValues.BASE_URL + "getCountries";
StringRequest countryRequest = new StringRequest
(
Request.Method.GET,
urlLink,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
JSONObject jsonResponse = new JSONObject(response);
JSONArray countries = jsonResponse.getJSONArray("countries");
for (int i=0; i< countries.length(); i++) {
JSONObject countryInfo = countries.getJSONObject(i);
String country_id = countryInfo.getString("country_id");
String country_name = countryInfo.getString("country_name");
Countries country = new Countries();
country.setCountry_id(country_id);
country.setCountry_name(country_name);
countryList.add(country);
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
Toast.makeText(getContext(), error.toString(), Toast.LENGTH_SHORT).show();
}
}
);
RequestQueue requestQueue = Volley.newRequestQueue(getContext());
requestQueue.add(countryRequest);
}
}
</code></pre>
| 0debug
|
sending post request to REST over SSL in json from C# : i looked up every single page on google there was no clear answer
right now this is my code:` try
{
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.hesabit.com/oauth2/token");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
httpWebRequest.Credentials = CredentialCache.DefaultCredentials;
ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
string result_st;
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = "{\"code\":\"{atho code}\"," +
"\"grant_type\":\"authorization_code\"," +
"\"client_id\":\"{client_id}\"," +
"\"client_secret\":\"{client_secret}\"," +
"\"redirect_uri\":\"{redirect_uri}\"}";
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
result_st = result;
}
return result_st;
}
catch (Exception ex)
{
return ex.ToString();
}
i really need to finish this today thank's
[1]: https://www.hesabit.com/docs/api/
| 0debug
|
trying to use bulksms,com api using guzzle in laravel but returning erros : i have been trying to use guzzle for sending bulk sms from bulksms.com and it is returning this error,guzzlehttp\exception\clientexception client error: post https://api.bulksms.com/v1/messages resulted in a 401 full authentication is required to access this resource response: : "type" "https://developer.bulksms.com/json/v1/errors#authentication-failed
my code
```
$client = new Client([
'base_uri'=>'https://www.bulksms.com/',
'timeout'=>'900.0'
]); //GuzzleHttp\Client
// $result = $client->post('', [
// 'form_params' => [
// 'sample-form-data' => 'value'
// ]
// ]);
$result = $client->request('POST','https://api.bulksms.com/v1/messages', [
'form_params' => [
'username' => 'username',
'password' => '****',
'sender' => 'my appname',
'recipients' => '+5555555555',
'message' => 'Testing message',
]
]);
| 0debug
|
In excel i want to compare particular cells and take the highest value and place in parent cell when particular cells update : [enter image description here][1]
[1]: http://i.stack.imgur.com/Bfv6L.png
1) Hi in the above image A column is having sum values help me with any formula so that in A13 i need an updated highest value.
2) Guys please help me i am running automated sequences so first it will update A12 with 90 then 90 should updated in A13 next again may A9 updates with 101 value so that A9 value should update in A13 so it should lookup in the latest cell and updated the value and should reflects in A13 cell help me even if it is macro but also be noticed i am running automated sequences i can't run macro manually so help me with code that runs automatically based on an cell input
thanks in advance.
| 0debug
|
git checkout my_branch vs. git checkout origin/my_branch : <p>I was on <code>branch1</code> when I checkout <code>branch2</code> like this (both branches are existing).</p>
<p><code>git checkout origin/branch2</code></p>
<p>then I got a detached head error:</p>
<pre><code>You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
</code></pre>
<p>But then I just checkout <code>branch2</code> (without <code>origin</code>) then it works ok:</p>
<p><code>git checkout branch2</code></p>
<p>So what's the difference between <code>git checkout</code> with and without <code>origin/</code>; and why there was the <code>detached HEAD</code> error when using <code>origin/</code>?</p>
| 0debug
|
Ruglare expermetion in python is not match : I'm doing regular expression on python. I spend much time to fix and to know why the regular expression doesn't work or match. I post the text and my code here. May I know what is wrong with my code:
The text is :
[pid 30101] 04:15:46 writev(25, [{"\0\225ub'\375[\340\244\6/", 11}, {"\4", 1},
{"Id before\0", 17}, {"Id\0", 10}], 4) = 39
[pid 30101] 04:15:46 getuid() = 10168
[pid 30101] 04:15:46 getuid() = 10168
[pid 30101] 04:15:46 ioctl(8, BINDER_WRITE_READ, 0x7fc0656648) = 0
[pid 30101] 04:15:46 ioctl(8, BINDER_WRITE_READ, 0x7fc0656648) = 0
[pid 30101] 04:15:46 fstat(33, {st_mode=S_IFCHR|0666, st_rdev=makedev(10, 62),
...}) = 0
[pid 30101] 04:15:46 fstat(33, {st_mode=S_IFCHR|0666, st_rdev=makedev(10, 62),
...}) = 0
[pid 30101] 04:15:46 ioctl(33, ASHMEM_GET_SIZE, 0) = 84
[pid 30101] 04:15:46 dup(33) = 34
[pid 30101] 04:15:46 close(33) = 0
[pid 30101] 04:15:46 dup(34) = 33
[pid 30101] 04:15:46 fstat(33, {st_mode=S_IFCHR|0666, st_rdev=makedev(10, 62),
...}) = 0
[pid 30101] 04:15:46 ioctl(33, ASHMEM_GET_SIZE, 0) = 84
[pid 30101] 04:15:46 mmap(NULL, 84, PROT_READ, MAP_SHARED, 33, 0) =
0x7d517db000
[pid 30101] 04:15:46 fstat(33, {st_mode=S_IFCHR|0666, st_rdev=makedev(10, 62),...}) = 0
[pid 30101] 04:15:46 ioctl(33, ASHMEM_GET_SIZE, 0) = 84
[pid 30101] 04:15:46 fstat(34, {st_mode=S_IFCHR|0666, st_rdev=makedev(10, 62),
...}) = 0
[pid 30101] 04:15:46 fstat(34, {st_mode=S_IFCHR|0666, st_rdev=makedev(10, 62),...}) = 0
[pid 30101] 04:15:46 ioctl(34, ASHMEM_GET_SIZE, 0) = 84
[pid 30101] 04:15:46 close(34) = 0
[pid 30101] 04:15:46 getuid() = 10168
[pid 30101] 04:15:46 writev(25, [{"\0\225ub'\375[\260y\3274", 11}, {"\4", 1},
{"After\0", 16}, {"eb41e1a15da0b8ee\0", 17}], 4) = 45
[pid 30101] 04:15:46 ioctl(8, BINDER_WRITE_READ, 0x7fc0656ee8) = 0
[pid 30101] 04:15:46 ioctl(8, BINDER_WRITE_READ, 0x7fc0656ee8) = 0
and here is my code:
import re
text = open('textfile.txt').read()
pid= str(30101)
if re.findall(r"^.* " + pid +"] \d\d:\d\d:\d\d getuid()^.*" + pid +"]\d\d:\d\d:\d\d ioctl\(8\, BINDER_WRITE_READ\, 0x7fc0656648\)^.*" + pid +"] \d\d:\d\d:\d\d fstat\(33\, \{st_mode=S_IFCHR\|0666\, st_rdev=makedev\(10\, 62\)\,
...\}\).*", text, re.M):
print 'found a match!'
else:
print 'no match'
| 0debug
|
What is ConstraintLayout Optimizer? : <p>Google published <strong>ConstraintLayout 1.1.0 beta 6</strong> on March 22, 2018. It has a new constraint known as <strong><em>Optimizer</em></strong>. The documentation of Optimizer at <a href="https://developer.android.com/reference/android/support/constraint/ConstraintLayout.html#Optimizer" rel="noreferrer">https://developer.android.com/reference/android/support/constraint/ConstraintLayout.html#Optimizer</a> does not mention when to use and why to use it. Can someone shed some light about it usage.</p>
| 0debug
|
target_ulong helper_rdhwr_xnp(CPUMIPSState *env)
{
check_hwrena(env, 5);
return (env->CP0_Config5 >> CP0C5_XNP) & 1;
}
| 1threat
|
Generics in .net 2.0 : Using a Where class on a class defination : During the preparation for "Programing in C#" Certification from [this][1] book at objective 2.1 where the following code is given for Generic Types.
class MyClass<T> where T:class,new()
{
public MyClass()
{
MyProperty = new T();
}
T MyProperty { get; set; }
}
I know what generic type is and why we need it, but can any one explain this confusing code and how we can use this with any example.
[1]: https://www.microsoftpressstore.com/store/exam-ref-70-483-programming-in-c-sharp-9780735676824
| 0debug
|
static void draw_slice(AVFilterLink *link, int y, int h)
{
ScaleContext *scale = link->dst->priv;
int out_h;
AVFilterPicRef *cur_pic = link->cur_pic;
uint8_t *data[4];
if (!scale->slice_dir) {
if (y != 0 && y + h != link->h) {
av_log(scale, AV_LOG_ERROR, "Slices start in the middle!\n");
return;
}
scale->slice_dir = y ? -1 : 1;
scale->slice_y = y ? link->dst->outputs[0]->h : y;
}
data[0] = cur_pic->data[0] + y * cur_pic->linesize[0];
data[1] = scale->input_is_pal ?
cur_pic->data[1] :
cur_pic->data[1] + (y>>scale->vsub) * cur_pic->linesize[1];
data[2] = cur_pic->data[2] + (y>>scale->vsub) * cur_pic->linesize[2];
data[3] = cur_pic->data[3] + y * cur_pic->linesize[3];
out_h = sws_scale(scale->sws, data, cur_pic->linesize, y, h,
link->dst->outputs[0]->outpic->data,
link->dst->outputs[0]->outpic->linesize);
if (scale->slice_dir == -1)
scale->slice_y -= out_h;
avfilter_draw_slice(link->dst->outputs[0], scale->slice_y, out_h);
if (scale->slice_dir == 1)
scale->slice_y += out_h;
}
| 1threat
|
static av_cold void sws_init_swscale(SwsContext *c)
{
enum AVPixelFormat srcFormat = c->srcFormat;
ff_sws_init_output_funcs(c, &c->yuv2plane1, &c->yuv2planeX,
&c->yuv2nv12cX, &c->yuv2packed1,
&c->yuv2packed2, &c->yuv2packedX, &c->yuv2anyX);
ff_sws_init_input_funcs(c);
if (c->srcBpc == 8) {
if (c->dstBpc <= 10) {
c->hyScale = c->hcScale = hScale8To15_c;
if (c->flags & SWS_FAST_BILINEAR) {
c->hyscale_fast = hyscale_fast_c;
c->hcscale_fast = hcscale_fast_c;
}
} else {
c->hyScale = c->hcScale = hScale8To19_c;
}
} else {
c->hyScale = c->hcScale = c->dstBpc > 10 ? hScale16To19_c
: hScale16To15_c;
}
if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) {
if (c->dstBpc <= 10) {
if (c->srcRange) {
c->lumConvertRange = lumRangeFromJpeg_c;
c->chrConvertRange = chrRangeFromJpeg_c;
} else {
c->lumConvertRange = lumRangeToJpeg_c;
c->chrConvertRange = chrRangeToJpeg_c;
}
} else {
if (c->srcRange) {
c->lumConvertRange = lumRangeFromJpeg16_c;
c->chrConvertRange = chrRangeFromJpeg16_c;
} else {
c->lumConvertRange = lumRangeToJpeg16_c;
c->chrConvertRange = chrRangeToJpeg16_c;
}
}
}
if (!(isGray(srcFormat) || isGray(c->dstFormat) ||
srcFormat == AV_PIX_FMT_MONOBLACK || srcFormat == AV_PIX_FMT_MONOWHITE))
c->needs_hcscale = 1;
}
| 1threat
|
static av_cold int oggvorbis_encode_close(AVCodecContext *avccontext)
{
OggVorbisContext *context = avccontext->priv_data;
vorbis_analysis_wrote(&context->vd, 0);
vorbis_block_clear(&context->vb);
vorbis_dsp_clear(&context->vd);
vorbis_info_clear(&context->vi);
av_freep(&avccontext->coded_frame);
av_freep(&avccontext->extradata);
return 0;
}
| 1threat
|
if $a = 3 and $b = 100 so i can get how many has been minused from $b=100 in $c variable (eg.$c = 3) in php.? : <p>if $a = 3 and $b = 100 so i can get how many has been minused from $b=100 in $c variable (eg.$c = 3) in php.?
I just need minused number from the addition of two variable 3 and 100
answer should be 3 in my third variable. </p>
| 0debug
|
Regex - extracting numbers from string in Oracle SQL : <p>how to extract using SQL or PL/SQL all numbers from below strings? </p>
<p>[ 6d (1.5h; 31h)] x (5 to 7)</p>
<p>[ 1d (8h; 24h; 48.5h; 72h; 96h)] x (1 to 5)</p>
| 0debug
|
static ExitStatus gen_fbcond(DisasContext *ctx, TCGCond cond, int ra,
int32_t disp)
{
TCGv cmp_tmp = tcg_temp_new();
gen_fold_mzero(cond, cmp_tmp, load_fpr(ctx, ra));
return gen_bcond_internal(ctx, cond, cmp_tmp, disp);
}
| 1threat
|
PHP - Regex to split string into alpha and numeric : I need to use `preg_split()` function to split string into alpha and numeric.
Ex: ABC10000 into, ABC and 10000
GSQ39800 into GSQ and 39800
WERTYI67888 into WERTYI and 67888
Alpha characters will be the first characters(any number of) of the string always and then the numeric(any number of).
| 0debug
|
Postgre returns wrong values for varchar-timestamp conversion : I have been encountering a very strange error while working on a postgre server. I have a column which contains times as varchar in the format HH24MMSS and I have to convert it to a timestamp using to_timestamp(varchar, 'HH24MMSS'). However, it returns me wrong values and I cannot understand why. Here are a few examples:
Select to_timestamp('111111', 'HH24MMSS')
-> 11:00:11
Select to_timestamp('000000', 'HH24MMSS')
-> 00:00:00
Select to_timestamp('122317', 'HH24MMSS')
-> 12:06:49
Here A Short Overview:
[enter image description here][1]
[1]: https://i.stack.imgur.com/5H3q1.png
Unfortunately, I cannot offer more detailed information about the server since I am not the admin nor the one maintaning it. I only know that it is Postgre 9.2. I really do not understand, what is wrong here. I would appreciate any hint or help.
| 0debug
|
package.config update does not update the references : <p>I have multiple projects referencing the same NuGet Package. When I got latest code, I realized that one of the projects had an updated package.config and also updated reference to the Dll that is provided by that package.</p>
<p>Now, I also updated package.config on other prjects hoping the as soon as I do an upgrade on that NuGet engine will see that and fetch me new DLLs. Well, it did not happen. After that I tried following things and none of them worked:</p>
<ol>
<li>Deleting the old version of DLL and then doing Restore package</li>
<li>Deleting the packages folder, restarting my VS 2015 and restoring the package</li>
</ol>
<p>Also, funny thing is that when I go to Manage Nuget Packages and look at the package for which I need new DLL, it shows that it is already at new version and I do not need to upgrade it.</p>
<p>Is there any ways I can get NuGet engine to upgrade these packages?</p>
| 0debug
|
static void xbr2x(AVFrame * input, AVFrame * output, const uint32_t * r2y)
{
int x,y;
int next_line = output->linesize[0]>>2;
for (y = 0; y < input->height; y++) {
uint32_t pprev;
uint32_t pprev2;
uint32_t * E = (uint32_t *)(output->data[0] + y * output->linesize[0] * 2);
uint32_t * sa2 = (uint32_t *)(input->data[0] + y * input->linesize[0] - 8);
uint32_t * sa1 = sa2 - (input->linesize[0]>>2);
uint32_t * sa0 = sa1 - (input->linesize[0]>>2);
uint32_t * sa3 = sa2 + (input->linesize[0]>>2);
uint32_t * sa4 = sa3 + (input->linesize[0]>>2);
if (y <= 1) {
sa0 = sa1;
if (y == 0) {
sa0 = sa1 = sa2;
}
}
if (y >= input->height - 2) {
sa4 = sa3;
if (y == input->height - 1) {
sa4 = sa3 = sa2;
}
}
pprev = pprev2 = 2;
for (x = 0; x < input->width; x++) {
uint32_t B1 = sa0[2];
uint32_t PB = sa1[2];
uint32_t PE = sa2[2];
uint32_t PH = sa3[2];
uint32_t H5 = sa4[2];
uint32_t A1 = sa0[pprev];
uint32_t PA = sa1[pprev];
uint32_t PD = sa2[pprev];
uint32_t PG = sa3[pprev];
uint32_t G5 = sa4[pprev];
uint32_t A0 = sa1[pprev2];
uint32_t D0 = sa2[pprev2];
uint32_t G0 = sa3[pprev2];
uint32_t C1 = 0;
uint32_t PC = 0;
uint32_t PF = 0;
uint32_t PI = 0;
uint32_t I5 = 0;
uint32_t C4 = 0;
uint32_t F4 = 0;
uint32_t I4 = 0;
if (x >= input->width - 2) {
if (x == input->width - 1) {
C1 = sa0[2];
PC = sa1[2];
PF = sa2[2];
PI = sa3[2];
I5 = sa4[2];
C4 = sa1[2];
F4 = sa2[2];
I4 = sa3[2];
} else {
C1 = sa0[3];
PC = sa1[3];
PF = sa2[3];
PI = sa3[3];
I5 = sa4[3];
C4 = sa1[3];
F4 = sa2[3];
I4 = sa3[3];
}
} else {
C1 = sa0[3];
PC = sa1[3];
PF = sa2[3];
PI = sa3[3];
I5 = sa4[3];
C4 = sa1[4];
F4 = sa2[4];
I4 = sa3[4];
}
E[0] = E[1] = E[next_line] = E[next_line + 1] = PE;
FILT2(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, 0, 1, next_line, next_line+1);
FILT2(PE, PC, PF, PB, PI, PA, PH, PD, PG, I4, A1, I5, H5, A0, D0, B1, C1, F4, C4, G5, G0, next_line, 0, next_line+1, 1);
FILT2(PE, PA, PB, PD, PC, PG, PF, PH, PI, C1, G0, C4, F4, G5, H5, D0, A0, B1, A1, I4, I5, next_line+1, next_line, 1, 0);
FILT2(PE, PG, PD, PH, PA, PI, PB, PF, PC, A0, I5, A1, B1, I4, F4, H5, G5, D0, G0, C1, C4, 1, next_line+1, 0, next_line);
sa0 += 1;
sa1 += 1;
sa2 += 1;
sa3 += 1;
sa4 += 1;
E += 2;
if (pprev2){
pprev2--;
pprev = 1;
}
}
}
}
| 1threat
|
void console_select(unsigned int index)
{
TextConsole *s;
if (index >= MAX_CONSOLES)
return;
s = consoles[index];
if (s) {
active_console = s;
if (s->g_width && s->g_height
&& (s->g_width != s->ds->width || s->g_height != s->ds->height))
dpy_resize(s->ds, s->g_width, s->g_height);
vga_hw_invalidate();
}
}
| 1threat
|
Assigning users to tasks in Visual Studio Team Services : <p>I've just joined my friend's Team Services account (free for the first 5 users account). If I visit the home page (<a href="https://XXXXXXX.visualstudio.com/Development/Development%20Team" rel="noreferrer">https://XXXXXXX.visualstudio.com/Development/Development%20Team</a>), I can see us both listed as Team Members. I can create backlog items/tasks and assign them to myself. My friend can create backlog items/tasks and assign them to himself. However, we can't assign each other.</p>
<p>Why could this be and any suggestions on how to resolve this?</p>
| 0debug
|
Regex match after semicolon and separated comma : <p>I have a string like</p>
<pre><code>Menu: apple, orange-juice, bananas
</code></pre>
<p>I want to use REGEX to match only <strong>apple</strong> <strong>orange-juice</strong> <strong>bananas</strong>
I have tried to search Google and regex101.com for help but still no any idea.</p>
<p>I would appreciate any help! Thank you</p>
| 0debug
|
int net_init_socket(QemuOpts *opts,
Monitor *mon,
const char *name,
VLANState *vlan)
{
if (qemu_opt_get(opts, "fd")) {
int fd;
if (qemu_opt_get(opts, "listen") ||
qemu_opt_get(opts, "connect") ||
qemu_opt_get(opts, "mcast")) {
qemu_error("listen=, connect= and mcast= is invalid with fd=\n");
return -1;
}
fd = net_handle_fd_param(mon, qemu_opt_get(opts, "fd"));
if (fd == -1) {
return -1;
}
if (!net_socket_fd_init(vlan, "socket", name, fd, 1)) {
close(fd);
return -1;
}
} else if (qemu_opt_get(opts, "listen")) {
const char *listen;
if (qemu_opt_get(opts, "fd") ||
qemu_opt_get(opts, "connect") ||
qemu_opt_get(opts, "mcast")) {
qemu_error("fd=, connect= and mcast= is invalid with listen=\n");
return -1;
}
listen = qemu_opt_get(opts, "listen");
if (net_socket_listen_init(vlan, "socket", name, listen) == -1) {
return -1;
}
} else if (qemu_opt_get(opts, "connect")) {
const char *connect;
if (qemu_opt_get(opts, "fd") ||
qemu_opt_get(opts, "listen") ||
qemu_opt_get(opts, "mcast")) {
qemu_error("fd=, listen= and mcast= is invalid with connect=\n");
return -1;
}
connect = qemu_opt_get(opts, "connect");
if (net_socket_connect_init(vlan, "socket", name, connect) == -1) {
return -1;
}
} else if (qemu_opt_get(opts, "mcast")) {
const char *mcast;
if (qemu_opt_get(opts, "fd") ||
qemu_opt_get(opts, "connect") ||
qemu_opt_get(opts, "listen")) {
qemu_error("fd=, connect= and listen= is invalid with mcast=\n");
return -1;
}
mcast = qemu_opt_get(opts, "mcast");
if (net_socket_mcast_init(vlan, "socket", name, mcast) == -1) {
return -1;
}
} else {
qemu_error("-socket requires fd=, listen=, connect= or mcast=\n");
return -1;
}
if (vlan) {
vlan->nb_host_devs++;
}
return 0;
}
| 1threat
|
typescript type of class that has tobe initialized : let circle: Circle;
This line says that circle is an instance of Circle. There is a case when I have a list of factories, they have not been initialized(list of classes). I have to process their static properties. What type should I use for?
I receive such error:
error TS2576: Property 'version' is a static member of type 'MigrationContainerBase'
| 0debug
|
How to use empty view with pagination using paging library android? : <ul>
<li>How to determine size of data returned before setting adapter? </li>
<li>How to use emptyview with paging library?</li>
<li>How to set emptyview if pagedlist returns null or no data?</li>
</ul>
| 0debug
|
static void do_help(int argc, const char **argv)
{
help_cmd(argv[1]);
}
| 1threat
|
static uint64_t icp_control_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
switch (offset >> 2) {
case 0:
return 0x41034003;
case 1:
return 0;
case 2:
return 0;
case 3:
return 0x11;
default:
hw_error("icp_control_read: Bad offset %x\n", (int)offset);
return 0;
}
}
| 1threat
|
Npm not found when running docker container from node image : <pre><code># Dockerfile
FROM node:7-alpine
RUN mkdir -p /src/app
WORKDIR /src/app
COPY package.json /src/app/package.json
RUN npm install
COPY . /src/app
EXPOSE 3000
CMD ['npm', 'start']
</code></pre>
<p>I'm trying to complete a <a href="https://katacoda.com" rel="noreferrer">katacoda.com</a> exercise for <a href="https://katacoda.com/courses/docker/3" rel="noreferrer">Dockerizing nodejs</a> applications with the Dockerfile above. The build completes but running the image quits immediately and in the docker logs I see:</p>
<pre><code>/bin/sh: [npm,: not found
</code></pre>
<p>I tried running the container in interactive mode with <code>docker -it nodeapp /bin/bash</code> which raised the error <code>docker: Error response from daemon: oci runtime error: container_linux.go:262: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory".</code> So I'm not sure what is going on here.</p>
| 0debug
|
static inline bool bdrv_req_is_aligned(BlockDriverState *bs,
int64_t offset, size_t bytes)
{
int64_t align = bdrv_get_align(bs);
return !(offset & (align - 1) || (bytes & (align - 1)));
}
| 1threat
|
Create Dynamic Table in Android : I am learning android development ,I want to create dynamic table rows .I don't know how to create .I want to create two table .One should static and Another should be dynamic .I referred in internet and i saw table layout , recycler view and I don't know which is best way to do it.Please someone guid me.
I want to create a tables like this[enter image description here][1]
I have tried like this only
[enter image description here][2]
Thanks in advance !!!.
[1]: https://i.stack.imgur.com/MLeu6.png
[2]: https://i.stack.imgur.com/50yks.png
| 0debug
|
static int amr_wb_decode_frame(AVCodecContext *avctx, void *data,
int *data_size, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AMRWBContext *s = avctx->priv_data;
int mode;
int packet_size;
static const uint8_t block_size[16] = {18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1};
mode = (buf[0] >> 3) & 0x000F;
packet_size = block_size[mode];
if (packet_size > buf_size) {
av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n",
buf_size, packet_size + 1);
return AVERROR_INVALIDDATA;
}
D_IF_decode(s->state, buf, data, _good_frame);
*data_size = 320 * 2;
return packet_size;
}
| 1threat
|
Junit in springboot not working with autowired annotation : I have a springboot application in which i m creating rest web services using mvc pattern. I have controller ,service and dao class and using autowired annotation for callung methods of service and dao layer.
When i creating junit using mockito,the values are going into controller but from controller it is not going to service class. Olease help in this
| 0debug
|
static void kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int w, int h)
{
BitBuf bb;
int res, val;
int i, j;
int bx, by;
int l0x, l1x, l0y, l1y;
int mx, my;
kmvc_init_getbits(bb, src);
for (by = 0; by < h; by += 8)
for (bx = 0; bx < w; bx += 8) {
kmvc_getbit(bb, src, res);
if (!res) {
kmvc_getbit(bb, src, res);
if (!res) {
val = *src++;
for (i = 0; i < 64; i++)
BLK(ctx->cur, bx + (i & 0x7), by + (i >> 3)) = val;
} else {
for (i = 0; i < 64; i++)
BLK(ctx->cur, bx + (i & 0x7), by + (i >> 3)) =
BLK(ctx->prev, bx + (i & 0x7), by + (i >> 3));
}
} else {
for (i = 0; i < 4; i++) {
l0x = bx + (i & 1) * 4;
l0y = by + (i & 2) * 2;
kmvc_getbit(bb, src, res);
if (!res) {
kmvc_getbit(bb, src, res);
if (!res) {
val = *src++;
for (j = 0; j < 16; j++)
BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) = val;
} else {
val = *src++;
mx = (val & 0xF) - 8;
my = (val >> 4) - 8;
for (j = 0; j < 16; j++)
BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) =
BLK(ctx->prev, l0x + (j & 3) + mx, l0y + (j >> 2) + my);
}
} else {
for (j = 0; j < 4; j++) {
l1x = l0x + (j & 1) * 2;
l1y = l0y + (j & 2);
kmvc_getbit(bb, src, res);
if (!res) {
kmvc_getbit(bb, src, res);
if (!res) {
val = *src++;
BLK(ctx->cur, l1x, l1y) = val;
BLK(ctx->cur, l1x + 1, l1y) = val;
BLK(ctx->cur, l1x, l1y + 1) = val;
BLK(ctx->cur, l1x + 1, l1y + 1) = val;
} else {
val = *src++;
mx = (val & 0xF) - 8;
my = (val >> 4) - 8;
BLK(ctx->cur, l1x, l1y) = BLK(ctx->prev, l1x + mx, l1y + my);
BLK(ctx->cur, l1x + 1, l1y) =
BLK(ctx->prev, l1x + 1 + mx, l1y + my);
BLK(ctx->cur, l1x, l1y + 1) =
BLK(ctx->prev, l1x + mx, l1y + 1 + my);
BLK(ctx->cur, l1x + 1, l1y + 1) =
BLK(ctx->prev, l1x + 1 + mx, l1y + 1 + my);
}
} else {
BLK(ctx->cur, l1x, l1y) = *src++;
BLK(ctx->cur, l1x + 1, l1y) = *src++;
BLK(ctx->cur, l1x, l1y + 1) = *src++;
BLK(ctx->cur, l1x + 1, l1y + 1) = *src++;
}
}
}
}
}
}
}
| 1threat
|
static void write_frame(AVFormatContext *s, AVPacket *pkt, AVCodecContext *avctx, AVBitStreamFilterContext *bsfc){
while(bsfc){
AVPacket new_pkt= *pkt;
int a= av_bitstream_filter_filter(bsfc, avctx, NULL,
&new_pkt.data, &new_pkt.size,
pkt->data, pkt->size,
pkt->flags & PKT_FLAG_KEY);
if(a){
av_free_packet(pkt);
new_pkt.destruct= av_destruct_packet;
}
*pkt= new_pkt;
bsfc= bsfc->next;
}
av_interleaved_write_frame(s, pkt);
}
| 1threat
|
int qemu_init_main_loop(Error **errp)
{
int ret;
GSource *src;
Error *local_error = NULL;
init_clocks();
ret = qemu_signal_init();
if (ret) {
return ret;
}
qemu_aio_context = aio_context_new(&local_error);
if (!qemu_aio_context) {
error_propagate(errp, local_error);
return -EMFILE;
}
qemu_notify_bh = qemu_bh_new(notify_event_cb, NULL);
gpollfds = g_array_new(FALSE, FALSE, sizeof(GPollFD));
src = aio_get_g_source(qemu_aio_context);
g_source_set_name(src, "aio-context");
g_source_attach(src, NULL);
g_source_unref(src);
src = iohandler_get_g_source();
g_source_set_name(src, "io-handler");
g_source_attach(src, NULL);
g_source_unref(src);
return 0;
}
| 1threat
|
Hi.. How to pull a Dockerfile from github (after edited) via Jenkins and run it on a remote server : Let's say I have a public repo (Github), my file looks like that:
docker build -t abrakadabra40404 . I changed it to:
docker build -t abrakadabra40404111111111 .
Now I want Jenkins to pull this file and run it on my server where docker was installed.
what should I write in the execute shell ????
*All other configurations have been made
| 0debug
|
c# How to check which line is selected listbox : <p>I need suggestions how to see which line is selected in a Listbox (winforms).
So when I click a line in the listbox a messagebox will popup with the text: <code>You clicked line X</code> or <code>You selected line is X</code></p>
<p>Hope you guys can help me!</p>
| 0debug
|
ruby on rails identifier error 1 : <p>Everytime i run this code i get an error can't find what i had did wrong it said something about synatic error tidentifier, expecting keyword_do or '{' or '('. Anyone has any suggestion on what it could be?</p>
<hr>
<p>_form.html.haml</p>
<pre><code> = simple_form_for @pin, html: { multipart: true } do |f|
= if @pin.errors.any?
#errors
%h2
= pluralize(@pin.errors.count, "error")
prevented this pin from saving
%ul
- @pin.errors.full_messages.each do |msg|
%li = msg
.form-group
= f.input :title, input_html: { class: 'form-control' }
.form-group
= f.input :description, input_html: { class: 'form-control' }
= f.button :submit, class: "btn btn-primary"
</code></pre>
| 0debug
|
Compare two IEnumerable : <p>I have two Ienumerables. First consist volleyball,basketboll, soccer events.
Second - full history of games. Its all string, because I parse its</p>
<pre><code>public class Events
{
public string Date { get; set; }
public string FirstTeam { get; set; }
public string SecondTeam { get; set; }
}
public class History
{
public string Date { get; set; }
public string FirstTeam { get; set; }
public string FirstTeamGoals { get; set; }
public string SecondTeam { get; set; }
public string SecondteamGoals { get; set; }
}
</code></pre>
<p>I need to show previous games of team, which takes part in event. Team can be First or Second team in previous games.</p>
<p>I try this:</p>
<pre><code>foreach (var teamInEvent in ListEvents)
{
var firstor = from p in History
where p.FirstTeam == teamInEvent.FirstTeam || p.SecondTeam == teamInEvent.FirstTeam
where p.SecondTeam == teamInEvent.SecondTeam || p.FirstTeam == teamInEvent.SecondTeam
select p;
}
</code></pre>
<p>as a result I need to show Date,FirstTeam,FirstTeamGoals,SecondTeam,SectGoals. Compare goals and show: Team won last 3 games(for example).</p>
| 0debug
|
Converting factor YYYY/MM to date class in R : I have dataframe with a column of dates of the form YYYY/MM, factor class, and I wish to convert it to date class. E.g. 2000/01 -> Jan 2000
I note that as.Date() is unable to handle date formats without the day component. I have tried using the as.yearmon() function from the zoo package.
> library(zoo)
> as.yearmon(factor("2000-01"))
[1] "Jan 2000" # It works with YYYY-MM format
> as.yearmon(factor("2000/01"))
[1] NA
> as.yearmon(factor("2000/01"),"%y/%m")
[1] NA
I'm looking for a function that will turn factor("2000/01") to "Jan 2000". Any help would be kindly appreciated.
| 0debug
|
static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
const uint8_t *buf, unsigned int substr)
{
SubStream *s = &m->substream[substr];
unsigned int ch;
int sync_word, tmp;
uint8_t checksum;
uint8_t lossless_check;
int start_count = get_bits_count(gbp);
const int max_matrix_channel = m->avctx->codec_id == CODEC_ID_MLP
? MAX_MATRIX_CHANNEL_MLP
: MAX_MATRIX_CHANNEL_TRUEHD;
sync_word = get_bits(gbp, 13);
if (sync_word != 0x31ea >> 1) {
av_log(m->avctx, AV_LOG_ERROR,
"restart header sync incorrect (got 0x%04x)\n", sync_word);
return AVERROR_INVALIDDATA;
}
s->noise_type = get_bits1(gbp);
if (m->avctx->codec_id == CODEC_ID_MLP && s->noise_type) {
av_log(m->avctx, AV_LOG_ERROR, "MLP must have 0x31ea sync word.\n");
return AVERROR_INVALIDDATA;
}
skip_bits(gbp, 16);
s->min_channel = get_bits(gbp, 4);
s->max_channel = get_bits(gbp, 4);
s->max_matrix_channel = get_bits(gbp, 4);
if (s->max_matrix_channel > max_matrix_channel) {
av_log(m->avctx, AV_LOG_ERROR,
"Max matrix channel cannot be greater than %d.\n",
max_matrix_channel);
return AVERROR_INVALIDDATA;
}
if (s->max_channel != s->max_matrix_channel) {
av_log(m->avctx, AV_LOG_ERROR,
"Max channel must be equal max matrix channel.\n");
return AVERROR_INVALIDDATA;
}
if (s->max_channel > MAX_MATRIX_CHANNEL_MLP && !s->noise_type) {
av_log_ask_for_sample(m->avctx,
"Number of channels %d is larger than the maximum supported "
"by the decoder.\n", s->max_channel + 2);
return AVERROR_PATCHWELCOME;
}
if (s->min_channel > s->max_channel) {
av_log(m->avctx, AV_LOG_ERROR,
"Substream min channel cannot be greater than max channel.\n");
return AVERROR_INVALIDDATA;
}
if (m->avctx->request_channels > 0
&& s->max_channel + 1 >= m->avctx->request_channels
&& substr < m->max_decoded_substream) {
av_log(m->avctx, AV_LOG_DEBUG,
"Extracting %d channel downmix from substream %d. "
"Further substreams will be skipped.\n",
s->max_channel + 1, substr);
m->max_decoded_substream = substr;
}
s->noise_shift = get_bits(gbp, 4);
s->noisegen_seed = get_bits(gbp, 23);
skip_bits(gbp, 19);
s->data_check_present = get_bits1(gbp);
lossless_check = get_bits(gbp, 8);
if (substr == m->max_decoded_substream
&& s->lossless_check_data != 0xffffffff) {
tmp = xor_32_to_8(s->lossless_check_data);
if (tmp != lossless_check)
av_log(m->avctx, AV_LOG_WARNING,
"Lossless check failed - expected %02x, calculated %02x.\n",
lossless_check, tmp);
}
skip_bits(gbp, 16);
memset(s->ch_assign, 0, sizeof(s->ch_assign));
for (ch = 0; ch <= s->max_matrix_channel; ch++) {
int ch_assign = get_bits(gbp, 6);
if (ch_assign > s->max_matrix_channel) {
av_log_ask_for_sample(m->avctx,
"Assignment of matrix channel %d to invalid output channel %d.\n",
ch, ch_assign);
return AVERROR_PATCHWELCOME;
}
s->ch_assign[ch_assign] = ch;
}
if (m->avctx->codec_id == CODEC_ID_MLP && m->needs_reordering) {
if (m->avctx->channel_layout == (AV_CH_LAYOUT_QUAD|AV_CH_LOW_FREQUENCY) ||
m->avctx->channel_layout == AV_CH_LAYOUT_5POINT0_BACK) {
int i = s->ch_assign[4];
s->ch_assign[4] = s->ch_assign[3];
s->ch_assign[3] = s->ch_assign[2];
s->ch_assign[2] = i;
} else if (m->avctx->channel_layout == AV_CH_LAYOUT_5POINT1_BACK) {
FFSWAP(int, s->ch_assign[2], s->ch_assign[4]);
FFSWAP(int, s->ch_assign[3], s->ch_assign[5]);
}
}
if (m->avctx->codec_id == CODEC_ID_TRUEHD &&
(m->avctx->channel_layout == AV_CH_LAYOUT_7POINT1 ||
m->avctx->channel_layout == AV_CH_LAYOUT_7POINT1_WIDE)) {
FFSWAP(int, s->ch_assign[4], s->ch_assign[6]);
FFSWAP(int, s->ch_assign[5], s->ch_assign[7]);
} else if (m->avctx->codec_id == CODEC_ID_TRUEHD &&
(m->avctx->channel_layout == AV_CH_LAYOUT_6POINT1 ||
m->avctx->channel_layout == (AV_CH_LAYOUT_6POINT1 | AV_CH_TOP_CENTER) ||
m->avctx->channel_layout == (AV_CH_LAYOUT_6POINT1 | AV_CH_TOP_FRONT_CENTER))) {
int i = s->ch_assign[6];
s->ch_assign[6] = s->ch_assign[5];
s->ch_assign[5] = s->ch_assign[4];
s->ch_assign[4] = i;
}
checksum = ff_mlp_restart_checksum(buf, get_bits_count(gbp) - start_count);
if (checksum != get_bits(gbp, 8))
av_log(m->avctx, AV_LOG_ERROR, "restart header checksum error\n");
s->param_presence_flags = 0xff;
s->num_primitive_matrices = 0;
s->blocksize = 8;
s->lossless_check_data = 0;
memset(s->output_shift , 0, sizeof(s->output_shift ));
memset(s->quant_step_size, 0, sizeof(s->quant_step_size));
for (ch = s->min_channel; ch <= s->max_channel; ch++) {
ChannelParams *cp = &s->channel_params[ch];
cp->filter_params[FIR].order = 0;
cp->filter_params[IIR].order = 0;
cp->filter_params[FIR].shift = 0;
cp->filter_params[IIR].shift = 0;
cp->huff_offset = 0;
cp->sign_huff_offset = (-1) << 23;
cp->codebook = 0;
cp->huff_lsbs = 24;
}
if (substr == m->max_decoded_substream)
m->avctx->channels = s->max_matrix_channel + 1;
return 0;
}
| 1threat
|
SQL Filter Orders by Customers Role : <p>I have two tables and i want display in my output list only orders who have customer role 0. <br>this is my db :</p>
<h3>table1</h3>
<p>Table name : <strong>customers</strong> <br><br>
<strong>id | role | name <br><br></strong>
1 | 0 | david<br>
2 | 0 | Opera<br>
3 | 1 | Jacob<br>
<br><br></p>
<h3>table2</h3>
<p>Table name : <strong>orders</strong> <br><br>
<strong>id | customerid | title | price <br><br></strong>
1 | 1 | hello world | 100 <br>
2 | 2 | hello world | 100<br>
3 | 3 | hello world | 100<br></p>
| 0debug
|
js , jquery, JSP. How to display a generic text inside a text box : I have a textarea/textbox which dynamically gets url from the database.Right now the textbox is showing full url address and does not look good. What I was trying to get is use some generic text like "click here for more info". i tried place holder but does not work. I need to use generic text and when lick go to the link it gets from database. Any help will be highly appreciated.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
//just for test
//this text area is getting values from db(url)
<a id="aurl" target="_blank" > <textarea id="evnt"
type="text" name="event" cols="40" disabled></textarea></a>
<!-- end snippet -->
| 0debug
|
Multiple Values in sql : I have two tables, Table A & Table B
Table A:
G.R.N ITEM QUANTITY
1 ABC001 150
1 CBD001 150
1 SDB001 100
Table B:
DELIVERY ITEM QUANTITY
34 ABC001 50
35 ABC001 40
36 ABC001 60
37 CBD001 50
38 CBD001 40
39 CBD001 10
Is it possible to get desired output like this:
G.R.N ITEM QUANTITY DELIVERY ITEM QUANTITY DIFFERENCE
1 ABC001 150 34,35,36 ABC001 150 0
1 CBD001 150 37,38,39 CBD001 100 50
1 SDB001 100 100
| 0debug
|
Do I have to store return values from methods C# : <p>I just started working with C# and I have noticed that my code works even if I
don't store a return value from a method. Example: Lets say I have a method</p>
<pre><code>public class Hello(){
public bool GoodMorning(){
return true;
}
}
</code></pre>
<p>Then this works:</p>
<pre><code>Hello.GoodMorning();
</code></pre>
<ul>
<li>What happens to the return value that I never store?</li>
<li>Is is bad practice to not store the return value?</li>
<li>If so, why?</li>
</ul>
| 0debug
|
static int vscsi_queue_cmd(VSCSIState *s, vscsi_req *req)
{
union srp_iu *srp = &req->iu.srp;
SCSIDevice *sdev;
int n, id, lun;
vscsi_decode_id_lun(be64_to_cpu(srp->cmd.lun), &id, &lun);
sdev = (id < 8 && lun < 16) ? s->bus.devs[id] : NULL;
if (!sdev) {
dprintf("VSCSI: Command for id %d with no drive\n", id);
if (srp->cmd.cdb[0] == INQUIRY) {
vscsi_inquiry_no_target(s, req);
} else {
vscsi_makeup_sense(s, req, ILLEGAL_REQUEST, 0x24, 0x00);
vscsi_send_rsp(s, req, CHECK_CONDITION, 0, 0);
} return 1;
}
req->lun = lun;
req->sreq = scsi_req_new(sdev, req->qtag, lun, req);
n = scsi_req_enqueue(req->sreq, srp->cmd.cdb);
dprintf("VSCSI: Queued command tag 0x%x CMD 0x%x ID %d LUN %d ret: %d\n",
req->qtag, srp->cmd.cdb[0], id, lun, n);
if (n) {
req->writing = (n < 1);
vscsi_preprocess_desc(req);
if (n > 0) {
req->data_len = n;
} else if (n < 0) {
req->data_len = -n;
}
scsi_req_continue(req->sreq);
}
return 0;
}
| 1threat
|
build_fadt(GArray *table_data, BIOSLinker *linker, AcpiPmInfo *pm,
unsigned facs, unsigned dsdt,
const char *oem_id, const char *oem_table_id)
{
AcpiFadtDescriptorRev1 *fadt = acpi_data_push(table_data, sizeof(*fadt));
fadt->firmware_ctrl = cpu_to_le32(facs);
bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_FILE,
&fadt->firmware_ctrl,
sizeof fadt->firmware_ctrl);
fadt->dsdt = cpu_to_le32(dsdt);
bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_FILE,
&fadt->dsdt,
sizeof fadt->dsdt);
fadt_setup(fadt, pm);
build_header(linker, table_data,
(void *)fadt, "FACP", sizeof(*fadt), 1, oem_id, oem_table_id);
}
| 1threat
|
target_ulong helper_lwr(CPUMIPSState *env, target_ulong arg1,
target_ulong arg2, int mem_idx)
{
target_ulong tmp;
tmp = do_lbu(env, arg2, mem_idx);
arg1 = (arg1 & 0xFFFFFF00) | tmp;
if (GET_LMASK(arg2) >= 1) {
tmp = do_lbu(env, GET_OFFSET(arg2, -1), mem_idx);
arg1 = (arg1 & 0xFFFF00FF) | (tmp << 8);
}
if (GET_LMASK(arg2) >= 2) {
tmp = do_lbu(env, GET_OFFSET(arg2, -2), mem_idx);
arg1 = (arg1 & 0xFF00FFFF) | (tmp << 16);
}
if (GET_LMASK(arg2) == 3) {
tmp = do_lbu(env, GET_OFFSET(arg2, -3), mem_idx);
arg1 = (arg1 & 0x00FFFFFF) | (tmp << 24);
}
return (int32_t)arg1;
}
| 1threat
|
how apt-get knows where to look for packages : <p>If I just run <code>apt-get update</code> (without any package name) on a new installation, the OS download/updates the packages. How does it know which packages to download and from where? Is the list of <code>sources</code> pre-configured in the <code>OS</code> eg. in Debian?</p>
| 0debug
|
How to build a TypeScript class constructor with object defining class fields? : <p>In TypeScript it's possible to create a class with a constructor that takes parameter with access modifiers and it automatically convert those parameters in class fields.</p>
<pre><code>class Item {
constructor(
public id: number,
public updatedAt: number,
public createdAt: number,
) {}
}
const item = new Item(1, 1, 1);
item.id // 1
</code></pre>
<p>I'm wondering if there is a way to pass all those parameters in an object instead</p>
<pre><code>class Item {
constructor({
public id: number,
public updatedAt: number,
public createdAt: number,
}) {}
}
const item = new Item({ id: 1, updatedAt: 1, createdAt: 1 });
item.id // 1
</code></pre>
<p>Is this possible? Ever gonna be possible?</p>
<p>Are there workarounds to do something similar?</p>
| 0debug
|
void memory_region_init_ram(MemoryRegion *mr,
Object *owner,
const char *name,
uint64_t size)
{
memory_region_init(mr, owner, name, size);
mr->ram = true;
mr->terminates = true;
mr->destructor = memory_region_destructor_ram;
mr->ram_addr = qemu_ram_alloc(size, mr);
}
| 1threat
|
static int decode_frame(AVCodecContext *avctx,
void *data, int *got_frame, AVPacket *avpkt)
{
TiffContext *const s = avctx->priv_data;
AVFrame *const p = data;
ThreadFrame frame = { .f = data };
unsigned off;
int le, ret, plane, planes;
int i, j, entries, stride;
unsigned soff, ssize;
uint8_t *dst;
GetByteContext stripsizes;
GetByteContext stripdata;
bytestream2_init(&s->gb, avpkt->data, avpkt->size);
if ((ret = ff_tdecode_header(&s->gb, &le, &off))) {
av_log(avctx, AV_LOG_ERROR, "Invalid TIFF header\n");
return ret;
} else if (off >= UINT_MAX - 14 || avpkt->size < off + 14) {
av_log(avctx, AV_LOG_ERROR, "IFD offset is greater than image size\n");
return AVERROR_INVALIDDATA;
}
s->le = le;
s->bppcount = s->bpp = 1;
s->photometric = TIFF_PHOTOMETRIC_NONE;
s->compr = TIFF_RAW;
s->fill_order = 0;
free_geotags(s);
s->stripsizesoff = s->strippos = 0;
bytestream2_seek(&s->gb, off, SEEK_SET);
entries = ff_tget_short(&s->gb, le);
if (bytestream2_get_bytes_left(&s->gb) < entries * 12)
return AVERROR_INVALIDDATA;
for (i = 0; i < entries; i++) {
if ((ret = tiff_decode_tag(s, p)) < 0)
return ret;
}
for (i = 0; i<s->geotag_count; i++) {
const char *keyname = get_geokey_name(s->geotags[i].key);
if (!keyname) {
av_log(avctx, AV_LOG_WARNING, "Unknown or unsupported GeoTIFF key %d\n", s->geotags[i].key);
continue;
}
if (get_geokey_type(s->geotags[i].key) != s->geotags[i].type) {
av_log(avctx, AV_LOG_WARNING, "Type of GeoTIFF key %d is wrong\n", s->geotags[i].key);
continue;
}
ret = av_dict_set(&p->metadata, keyname, s->geotags[i].val, 0);
if (ret<0) {
av_log(avctx, AV_LOG_ERROR, "Writing metadata with key '%s' failed\n", keyname);
return ret;
}
}
if (!s->strippos && !s->stripoff) {
av_log(avctx, AV_LOG_ERROR, "Image data is missing\n");
return AVERROR_INVALIDDATA;
}
if ((ret = init_image(s, &frame)) < 0)
return ret;
if (s->strips == 1 && !s->stripsize) {
av_log(avctx, AV_LOG_WARNING, "Image data size missing\n");
s->stripsize = avpkt->size - s->stripoff;
}
if (s->stripsizesoff) {
if (s->stripsizesoff >= (unsigned)avpkt->size)
return AVERROR_INVALIDDATA;
bytestream2_init(&stripsizes, avpkt->data + s->stripsizesoff,
avpkt->size - s->stripsizesoff);
}
if (s->strippos) {
if (s->strippos >= (unsigned)avpkt->size)
return AVERROR_INVALIDDATA;
bytestream2_init(&stripdata, avpkt->data + s->strippos,
avpkt->size - s->strippos);
}
if (s->rps <= 0 || s->rps % s->subsampling[1]) {
av_log(avctx, AV_LOG_ERROR, "rps %d invalid\n", s->rps);
return AVERROR_INVALIDDATA;
}
planes = s->planar ? s->bppcount : 1;
for (plane = 0; plane < planes; plane++) {
stride = p->linesize[plane];
dst = p->data[plane];
for (i = 0; i < s->height; i += s->rps) {
if (s->stripsizesoff)
ssize = ff_tget(&stripsizes, s->sstype, le);
else
ssize = s->stripsize;
if (s->strippos)
soff = ff_tget(&stripdata, s->sot, le);
else
soff = s->stripoff;
if (soff > avpkt->size || ssize > avpkt->size - soff) {
av_log(avctx, AV_LOG_ERROR, "Invalid strip size/offset\n");
return AVERROR_INVALIDDATA;
}
if ((ret = tiff_unpack_strip(s, p, dst, stride, avpkt->data + soff, ssize, i,
FFMIN(s->rps, s->height - i))) < 0) {
if (avctx->err_recognition & AV_EF_EXPLODE)
return ret;
break;
}
dst += s->rps * stride;
}
if (s->predictor == 2) {
if (s->photometric == TIFF_PHOTOMETRIC_YCBCR) {
av_log(s->avctx, AV_LOG_ERROR, "predictor == 2 with YUV is unsupported");
return AVERROR_PATCHWELCOME;
}
dst = p->data[plane];
soff = s->bpp >> 3;
if (s->planar)
soff = FFMAX(soff / s->bppcount, 1);
ssize = s->width * soff;
if (s->avctx->pix_fmt == AV_PIX_FMT_RGB48LE ||
s->avctx->pix_fmt == AV_PIX_FMT_RGBA64LE ||
s->avctx->pix_fmt == AV_PIX_FMT_GRAY16LE ||
s->avctx->pix_fmt == AV_PIX_FMT_YA16LE ||
s->avctx->pix_fmt == AV_PIX_FMT_GBRP16LE ||
s->avctx->pix_fmt == AV_PIX_FMT_GBRAP16LE) {
for (i = 0; i < s->height; i++) {
for (j = soff; j < ssize; j += 2)
AV_WL16(dst + j, AV_RL16(dst + j) + AV_RL16(dst + j - soff));
dst += stride;
}
} else if (s->avctx->pix_fmt == AV_PIX_FMT_RGB48BE ||
s->avctx->pix_fmt == AV_PIX_FMT_RGBA64BE ||
s->avctx->pix_fmt == AV_PIX_FMT_GRAY16BE ||
s->avctx->pix_fmt == AV_PIX_FMT_YA16BE ||
s->avctx->pix_fmt == AV_PIX_FMT_GBRP16BE ||
s->avctx->pix_fmt == AV_PIX_FMT_GBRAP16BE) {
for (i = 0; i < s->height; i++) {
for (j = soff; j < ssize; j += 2)
AV_WB16(dst + j, AV_RB16(dst + j) + AV_RB16(dst + j - soff));
dst += stride;
}
} else {
for (i = 0; i < s->height; i++) {
for (j = soff; j < ssize; j++)
dst[j] += dst[j - soff];
dst += stride;
}
}
}
if (s->photometric == TIFF_PHOTOMETRIC_WHITE_IS_ZERO) {
int c = (s->avctx->pix_fmt == AV_PIX_FMT_PAL8 ? (1<<s->bpp) - 1 : 255);
dst = p->data[plane];
for (i = 0; i < s->height; i++) {
for (j = 0; j < stride; j++)
dst[j] = c - dst[j];
dst += stride;
}
}
}
if (s->planar && s->bppcount > 2) {
FFSWAP(uint8_t*, p->data[0], p->data[2]);
FFSWAP(int, p->linesize[0], p->linesize[2]);
FFSWAP(uint8_t*, p->data[0], p->data[1]);
FFSWAP(int, p->linesize[0], p->linesize[1]);
}
*got_frame = 1;
return avpkt->size;
}
| 1threat
|
Spring @Scheduler parallel running : <p>I have the following 3 classes:</p>
<p><em>ComponantA</em></p>
<pre><code>package mytest.spring.test.spring;
import org.apache.log4j.Logger;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class ComponentA {
Logger log = Logger.getLogger(ComponentB.class);
@Scheduled(fixedRate=2000)
public void sayHello() {
for(int i=1 ; i<=5 ; i++) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
log.info("Hello from ComponentA " + i);
}
}
}
</code></pre>
<p><em>ComponentB</em></p>
<pre><code>package mytest.spring.test.spring;
import org.apache.log4j.Logger;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class ComponentB {
Logger log = Logger.getLogger(ComponentB.class);
@Scheduled(fixedRate=2000)
public void sayHello() {
for(int i=1 ; i<=3 ; i++) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
log.info("Hello from ComponentB " + i);
}
}
}
</code></pre>
<p><em>MyApplication</em></p>
<pre><code>package mytest.spring.test.spring;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}
</code></pre>
<p>When I execute it, I'm getting the following output:</p>
<pre><code>Hello from ComponentA 1
Hello from ComponentA 2
Hello from ComponentA 3
Hello from ComponentA 4
Hello from ComponentA 5
Hello from ComponentB 1
Hello from ComponentB 2
Hello from ComponentB 3
Hello from ComponentA 1
Hello from ComponentA 2
Hello from ComponentA 3
Hello from ComponentA 4
Hello from ComponentA 5
Hello from ComponentB 1
Hello from ComponentB 2
Hello from ComponentB 3
...
</code></pre>
<p>I need the 2 Scheduled methods to run in parallel, which is clearly not the cae according to the output I'm getting. I read that it should be possible to provide the @Schedule annotation with a custom TaskExecutor, with which it should be possible to define how many thread we want ...</p>
<p>Am I right ? I can't find how to provide this information.</p>
| 0debug
|
static coroutine_fn int qcow_co_writev(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, QEMUIOVector *qiov)
{
BDRVQcowState *s = bs->opaque;
int index_in_cluster;
uint64_t cluster_offset;
int ret = 0, n;
struct iovec hd_iov;
QEMUIOVector hd_qiov;
uint8_t *buf;
void *orig_buf;
s->cluster_cache_offset = -1;
if (bs->encrypted || qiov->niov > 1) {
buf = orig_buf = qemu_try_blockalign(bs, qiov->size);
if (buf == NULL) {
return -ENOMEM;
}
qemu_iovec_to_buf(qiov, 0, buf, qiov->size);
} else {
orig_buf = NULL;
buf = (uint8_t *)qiov->iov->iov_base;
}
qemu_co_mutex_lock(&s->lock);
while (nb_sectors != 0) {
index_in_cluster = sector_num & (s->cluster_sectors - 1);
n = s->cluster_sectors - index_in_cluster;
if (n > nb_sectors) {
n = nb_sectors;
}
cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0,
index_in_cluster,
index_in_cluster + n);
if (!cluster_offset || (cluster_offset & 511) != 0) {
ret = -EIO;
break;
}
if (bs->encrypted) {
Error *err = NULL;
assert(s->cipher);
if (encrypt_sectors(s, sector_num, buf, n, true, &err) < 0) {
error_free(err);
ret = -EIO;
break;
}
}
hd_iov.iov_base = (void *)buf;
hd_iov.iov_len = n * 512;
qemu_iovec_init_external(&hd_qiov, &hd_iov, 1);
qemu_co_mutex_unlock(&s->lock);
ret = bdrv_co_writev(bs->file,
(cluster_offset >> 9) + index_in_cluster,
n, &hd_qiov);
qemu_co_mutex_lock(&s->lock);
if (ret < 0) {
break;
}
ret = 0;
nb_sectors -= n;
sector_num += n;
buf += n * 512;
}
qemu_co_mutex_unlock(&s->lock);
qemu_vfree(orig_buf);
return ret;
}
| 1threat
|
static void test_wait_event_notifier(void)
{
EventNotifierTestData data = { .n = 0, .active = 1 };
event_notifier_init(&data.e, false);
aio_set_event_notifier(ctx, &data.e, event_ready_cb);
g_assert(!aio_poll(ctx, false));
g_assert_cmpint(data.n, ==, 0);
g_assert_cmpint(data.active, ==, 1);
event_notifier_set(&data.e);
g_assert(aio_poll(ctx, false));
g_assert_cmpint(data.n, ==, 1);
g_assert_cmpint(data.active, ==, 0);
g_assert(!aio_poll(ctx, false));
g_assert_cmpint(data.n, ==, 1);
g_assert_cmpint(data.active, ==, 0);
aio_set_event_notifier(ctx, &data.e, NULL);
g_assert(!aio_poll(ctx, false));
g_assert_cmpint(data.n, ==, 1);
event_notifier_cleanup(&data.e);
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.