problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static int tftp_send_oack(struct tftp_session *spt,
const char *keys[], uint32_t values[], int nb,
struct tftp_t *recv_tp)
{
struct sockaddr_in saddr, daddr;
struct mbuf *m;
struct tftp_t *tp;
int i, n = 0;
m = m_get(spt->slirp);
if (!m)
return -1;
memset(m->m_data, 0, m->m_size);
m->m_data += IF_MAXLINKHDR;
tp = (void *)m->m_data;
m->m_data += sizeof(struct udpiphdr);
tp->tp_op = htons(TFTP_OACK);
for (i = 0; i < nb; i++) {
n += snprintf(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%s",
keys[i]) + 1;
n += snprintf(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%u",
values[i]) + 1;
}
saddr.sin_addr = recv_tp->ip.ip_dst;
saddr.sin_port = recv_tp->udp.uh_dport;
daddr.sin_addr = spt->client_ip;
daddr.sin_port = spt->client_port;
m->m_len = sizeof(struct tftp_t) - 514 + n -
sizeof(struct ip) - sizeof(struct udphdr);
udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
return 0;
}
| 1threat
|
void mjpeg_picture_header(MpegEncContext *s)
{
put_marker(&s->pb, SOI);
jpeg_table_header(s);
put_marker(&s->pb, SOF0);
put_bits(&s->pb, 16, 17);
put_bits(&s->pb, 8, 8);
put_bits(&s->pb, 16, s->height);
put_bits(&s->pb, 16, s->width);
put_bits(&s->pb, 8, 3);
put_bits(&s->pb, 8, 1);
put_bits(&s->pb, 4, 2);
put_bits(&s->pb, 4, 2);
put_bits(&s->pb, 8, 0);
put_bits(&s->pb, 8, 2);
put_bits(&s->pb, 4, 1);
put_bits(&s->pb, 4, 1);
put_bits(&s->pb, 8, 0);
put_bits(&s->pb, 8, 3);
put_bits(&s->pb, 4, 1);
put_bits(&s->pb, 4, 1);
put_bits(&s->pb, 8, 0);
put_marker(&s->pb, SOS);
put_bits(&s->pb, 16, 12);
put_bits(&s->pb, 8, 3);
put_bits(&s->pb, 8, 1);
put_bits(&s->pb, 4, 0);
put_bits(&s->pb, 4, 0);
put_bits(&s->pb, 8, 2);
put_bits(&s->pb, 4, 1);
put_bits(&s->pb, 4, 1);
put_bits(&s->pb, 8, 3);
put_bits(&s->pb, 4, 1);
put_bits(&s->pb, 4, 1);
put_bits(&s->pb, 8, 0);
put_bits(&s->pb, 8, 63);
put_bits(&s->pb, 8, 0);
}
| 1threat
|
Load a local image after loading a remote image failed : <p>Is it possible to load a local image if the remote image failed?</p>
<p>For example, I have the following code:</p>
<pre><code><Image style={ styles.userImage }
source={ { uri: http://example.com/my_image.jpg } }
onError={(error) => ...}
/>
</code></pre>
<p>In case for example I don't have the rights to access <code>http://example.com/my_image.jpg</code>, I'll get an error in <code>onError</code>. Is there a way then to load a local image instead?</p>
| 0debug
|
C#(Unity) - How to stop the function execution? : <p>I have code like this one:</p>
<pre><code> public void Interacted(){
if (GameObject.Find ("Sara").GetComponent<controls> ().isIntered) {
if (Interer.name == "sinkTop" && !sinked) {
Interer.GetComponent<SpriteRenderer> ().sprite = sinkON;
sinked = true;
}
if (Interer.name == "sinkTop" && sinked) {
Interer.GetComponent<SpriteRenderer> ().sprite = sinkOFF;
sinked = false;
}
}
}
</code></pre>
<p>How do I stop <code>Interacted()</code> execution inside <code>if (Interer.name == "sinkTop" && !sinked)</code>?</p>
| 0debug
|
generates progress bars bysubmitbutton.want to generate a progressbar for time(Assume 1 min).means user should see 0 to 100% feature for 1 min : isc.DynamicForm.create({
ID:"DynamicForm51",
autoDraw:false,
})
var importSection = isc.DynamicForm.create({
ID:"DynamicForm42",
autoDraw:false,
numCols:2,
width:950,
items:[
{
name:"ImportSection",
titleAlign:"center",
textAlign:"center",
align:"center",
redrawOnChange:true,
hoverAlign:"left",
_constructor:"SelectItem"
},
{
editorType: "button",
//name:"SubmitItem",
title:"Submit",
align:"right",
shouldSaveValue: true,
_constructor:"SubmitItem",
click : function() {
//progressBar.hide();
move();
importSection.addItem(progressBar);
}
},
{
name:"Browse",
textAlign:"right",
align:"right",
_constructor:"ButtonItem",
},
{
colSpan:"*",
endRow:true,
//name:"CanvasItem0",
showTitle:true,
startRow:true,
width:"*",
canvas:DynamicForm51,
_constructor:"CanvasItem"
}
],
cellPadding:2,
minColWidth:20,
fixedColWidths:false,
saveOnEnter:true,
titleOrientation:"left",
titleWidth:500,
layoutAlign:"right",
visibility:"visible"
})
var progressBar = isc.Progressbar.create ({
title: "Current Status Indicator",
ID: "progressBar",
showTitle:true,
//ID: "progressBar",
name: "progressBar",
shouldSaveValue: true,
//width:25,
//height:10,
length:250,
titleAlign: "center",
titleOrientation: "left",
animateMoveTime: 10,
})
progressBar.hide();
function move() {
//progressBar.show();
progressBar.setPercentDone(50);
}
console.log(5):
| 0debug
|
How to toggle setContextMenu content in google map : I am working on google-map api.
I have problem with google map setcontextmenu.
When the user right-clicks the map, the context menu will appear. I tried to change the content of context menu option from "measure distance" to "stop measure distance".
Below is the code when the user right-clicks, it displays two menus : "measure distance" and "stop measuring". I want it to be toggle.
How can i do this?
Any help would be appreciated so much.
I tried to put flag variable inside the contextmenu but it just didn't work.
map_2.setContextMenu({
control: 'map',
options: [
{
title: 'Measure Distance',
name: 'measure_distance',
action: function(e) {
// some codes here
}
},
{
title: 'Stop Measuring',
name: 'stop_measure_distance',
action: function(e) {
// some codes here
}
}
]
});
When the user clicks "measure distance" menu, i want the "measure distance" menu disappear and "stop measuring" menu appears.
| 0debug
|
Multiple assignment in Python : <p>In python, a=b=1 assigns 1 to the two variables at the same memory location. Then why does changing the value of one variable(variable a) does not affect the value of other(variable b)?</p>
| 0debug
|
php finding an existing data from mysql : <p>I am trying to create a registration page and throw an error when the username or the email exists but it doesn't catch the error.
The table name in the database is 'users', username is 'uname' and email is 'email'.
It inserts the data without a problem.
I am using the same array to catch if any field is empty, also they are working perfectly fine.</p>
<pre><code> $query_usr = mysql_query("SELECT * FROM users WHERE uname='$uname' OR email='$email'");
if ($query_usr["uname"] === $uname) {
array_push($errors, "Username already exists");
}
if ($query_usr["email"] === $email) {
array_push($errors, "email already exists");
}
if (count($err) == 0) {
$pass = md5($pass1);
$query = "INSERT INTO users (uname, email, password) VALUES('$uname', '$email', '$pass')";
mysqli_query($connection, $query);
$_SESSION["uname"] = $uname;
$_SESSION["success"] = "You are now logged in";
//header('location: index.php');
}
else{
foreach ($err as $er){
echo $er;
echo "<p> </p>";
}
}
</code></pre>
| 0debug
|
how to turn stack in to an array? : <p>I am working on a stack, where i have to create it from scratch without using JAVA collections. I have coded the push, pop, peek and all other required methods. What I am confused about is the method of converting this stack to an array, with the top of the stack being element 0, how can this be done without using the toArray() method?</p>
| 0debug
|
int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t size_increase)
{
if ( s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < threshold
&& s->slice_context_count == 1
&& s->pb.buf == s->avctx->internal->byte_buffer) {
int lastgob_pos = s->ptr_lastgob - s->pb.buf;
int vbv_pos = s->vbv_delay_ptr - s->pb.buf;
uint8_t *new_buffer = NULL;
int new_buffer_size = 0;
av_fast_padded_malloc(&new_buffer, &new_buffer_size,
s->avctx->internal->byte_buffer_size + size_increase);
if (!new_buffer)
memcpy(new_buffer, s->avctx->internal->byte_buffer, s->avctx->internal->byte_buffer_size);
av_free(s->avctx->internal->byte_buffer);
s->avctx->internal->byte_buffer = new_buffer;
s->avctx->internal->byte_buffer_size = new_buffer_size;
rebase_put_bits(&s->pb, new_buffer, new_buffer_size);
s->ptr_lastgob = s->pb.buf + lastgob_pos;
s->vbv_delay_ptr = s->pb.buf + vbv_pos;
if (s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < threshold)
return AVERROR(EINVAL);
return 0;
| 1threat
|
How to proxy http requests with plain javascript? : <p>I'm writing a bot with plain javascript that sends requests to a certain website without node.js or dependencies like jquery. I want to send every requests through a proxy, but I can't figure out how to do that with vanilla js.</p>
<p>I don't know where to even start. I've read the xhr documentation and found nothing about proxies. Google yielded nothing too.</p>
<p>Thanks!</p>
| 0debug
|
How do I check for reference equality in F#? : <p>F# uses structural equality for the <code>=</code> operator, which is almost always what you want:</p>
<pre><code>let a = [1; 2; 3]
let b = [1; 2; 3]
printfn "%A" (a = b) // Prints "true"
</code></pre>
<p>But in some algorithms, it can be important to be able to ask "Are these two things <em>the same object</em>?" This can help with detecting cycles in a graph, for example. So how do I ask for reference equality in F#? I.e., how do I write the <code>isSameObject</code> function below?</p>
<pre><code>let isSameObject x y = ???
let a = [1; 2; 3]
let b = [1; 2; 3]
let a' = a
printfn "%A" (isSameObject a b) // Prints "false"
printfn "%A" (isSameObject a a') // Prints "true"
</code></pre>
| 0debug
|
create a new table every time though sp : i want create a new table every time though stored proc.
declare @datetime datetime
declare @date varchar(20)
select @datetime=(GETDATE()-1)
select @date=convert(varchar(10),@datetime,112)
print @datetime
print @date
create table #businessmster+'_'+@date
(
contentid int
)
tbale name which i want= #businessmaster_20171103
| 0debug
|
static void do_subtitle_out(AVFormatContext *s,
AVOutputStream *ost,
AVInputStream *ist,
AVSubtitle *sub,
int64_t pts)
{
static uint8_t *subtitle_out = NULL;
int subtitle_out_max_size = 65536;
int subtitle_out_size, nb, i;
AVCodecContext *enc;
AVPacket pkt;
if (pts == AV_NOPTS_VALUE) {
fprintf(stderr, "Subtitle packets must have a pts\n");
if (exit_on_error)
return;
enc = ost->st->codec;
if (!subtitle_out) {
subtitle_out = av_malloc(subtitle_out_max_size);
if (enc->codec_id == CODEC_ID_DVB_SUBTITLE)
nb = 2;
else
nb = 1;
for(i = 0; i < nb; i++) {
sub->pts = av_rescale_q(pts, ist->st->time_base, AV_TIME_BASE_Q);
subtitle_out_size = avcodec_encode_subtitle(enc, subtitle_out,
subtitle_out_max_size, sub);
av_init_packet(&pkt);
pkt.stream_index = ost->index;
pkt.data = subtitle_out;
pkt.size = subtitle_out_size;
pkt.pts = av_rescale_q(pts, ist->st->time_base, ost->st->time_base);
if (enc->codec_id == CODEC_ID_DVB_SUBTITLE) {
if (i == 0)
pkt.pts += 90 * sub->start_display_time;
else
pkt.pts += 90 * sub->end_display_time;
write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]);
| 1threat
|
static uint32_t get_features(VirtIODevice *vdev, uint32_t features)
{
VirtIOSerial *vser;
vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
if (vser->bus->max_nr_ports > 1) {
features |= (1 << VIRTIO_CONSOLE_F_MULTIPORT);
}
return features;
}
| 1threat
|
void ff_vc1_pred_mv_intfr(VC1Context *v, int n, int dmv_x, int dmv_y,
int mvn, int r_x, int r_y, uint8_t* is_intra, int dir)
{
MpegEncContext *s = &v->s;
int xy, wrap, off = 0;
int A[2], B[2], C[2];
int px, py;
int a_valid = 0, b_valid = 0, c_valid = 0;
int field_a, field_b, field_c;
int total_valid, num_samefield, num_oppfield;
int pos_c, pos_b, n_adj;
wrap = s->b8_stride;
xy = s->block_index[n];
if (s->mb_intra) {
s->mv[0][n][0] = s->current_picture.motion_val[0][xy][0] = 0;
s->mv[0][n][1] = s->current_picture.motion_val[0][xy][1] = 0;
s->current_picture.motion_val[1][xy][0] = 0;
s->current_picture.motion_val[1][xy][1] = 0;
if (mvn == 1) {
s->current_picture.motion_val[0][xy + 1][0] = 0;
s->current_picture.motion_val[0][xy + 1][1] = 0;
s->current_picture.motion_val[0][xy + wrap][0] = 0;
s->current_picture.motion_val[0][xy + wrap][1] = 0;
s->current_picture.motion_val[0][xy + wrap + 1][0] = 0;
s->current_picture.motion_val[0][xy + wrap + 1][1] = 0;
v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0;
s->current_picture.motion_val[1][xy + 1][0] = 0;
s->current_picture.motion_val[1][xy + 1][1] = 0;
s->current_picture.motion_val[1][xy + wrap][0] = 0;
s->current_picture.motion_val[1][xy + wrap][1] = 0;
s->current_picture.motion_val[1][xy + wrap + 1][0] = 0;
s->current_picture.motion_val[1][xy + wrap + 1][1] = 0;
}
return;
}
off = ((n == 0) || (n == 1)) ? 1 : -1;
if (s->mb_x || (n == 1) || (n == 3)) {
if ((v->blk_mv_type[xy])
|| (!v->blk_mv_type[xy] && !v->blk_mv_type[xy - 1])) {
A[0] = s->current_picture.motion_val[dir][xy - 1][0];
A[1] = s->current_picture.motion_val[dir][xy - 1][1];
a_valid = 1;
} else {
A[0] = (s->current_picture.motion_val[dir][xy - 1][0]
+ s->current_picture.motion_val[dir][xy - 1 + off * wrap][0] + 1) >> 1;
A[1] = (s->current_picture.motion_val[dir][xy - 1][1]
+ s->current_picture.motion_val[dir][xy - 1 + off * wrap][1] + 1) >> 1;
a_valid = 1;
}
if (!(n & 1) && v->is_intra[s->mb_x - 1]) {
a_valid = 0;
A[0] = A[1] = 0;
}
} else
A[0] = A[1] = 0;
B[0] = B[1] = C[0] = C[1] = 0;
if (n == 0 || n == 1 || v->blk_mv_type[xy]) {
if (!s->first_slice_line) {
if (!v->is_intra[s->mb_x - s->mb_stride]) {
b_valid = 1;
n_adj = n | 2;
pos_b = s->block_index[n_adj] - 2 * wrap;
if (v->blk_mv_type[pos_b] && v->blk_mv_type[xy]) {
n_adj = (n & 2) | (n & 1);
}
B[0] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap][0];
B[1] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap][1];
if (v->blk_mv_type[pos_b] && !v->blk_mv_type[xy]) {
B[0] = (B[0] + s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap][0] + 1) >> 1;
B[1] = (B[1] + s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap][1] + 1) >> 1;
}
}
if (s->mb_width > 1) {
if (!v->is_intra[s->mb_x - s->mb_stride + 1]) {
c_valid = 1;
n_adj = 2;
pos_c = s->block_index[2] - 2 * wrap + 2;
if (v->blk_mv_type[pos_c] && v->blk_mv_type[xy]) {
n_adj = n & 2;
}
C[0] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap + 2][0];
C[1] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap + 2][1];
if (v->blk_mv_type[pos_c] && !v->blk_mv_type[xy]) {
C[0] = (1 + C[0] + (s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap + 2][0])) >> 1;
C[1] = (1 + C[1] + (s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap + 2][1])) >> 1;
}
if (s->mb_x == s->mb_width - 1) {
if (!v->is_intra[s->mb_x - s->mb_stride - 1]) {
c_valid = 1;
n_adj = 3;
pos_c = s->block_index[3] - 2 * wrap - 2;
if (v->blk_mv_type[pos_c] && v->blk_mv_type[xy]) {
n_adj = n | 1;
}
C[0] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap - 2][0];
C[1] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap - 2][1];
if (v->blk_mv_type[pos_c] && !v->blk_mv_type[xy]) {
C[0] = (1 + C[0] + s->current_picture.motion_val[dir][s->block_index[1] - 2 * wrap - 2][0]) >> 1;
C[1] = (1 + C[1] + s->current_picture.motion_val[dir][s->block_index[1] - 2 * wrap - 2][1]) >> 1;
}
} else
c_valid = 0;
}
}
}
}
} else {
pos_b = s->block_index[1];
b_valid = 1;
B[0] = s->current_picture.motion_val[dir][pos_b][0];
B[1] = s->current_picture.motion_val[dir][pos_b][1];
pos_c = s->block_index[0];
c_valid = 1;
C[0] = s->current_picture.motion_val[dir][pos_c][0];
C[1] = s->current_picture.motion_val[dir][pos_c][1];
}
total_valid = a_valid + b_valid + c_valid;
if (!s->mb_x && !(n == 1 || n == 3)) {
A[0] = A[1] = 0;
}
if ((s->first_slice_line && v->blk_mv_type[xy]) || (s->first_slice_line && !(n & 2))) {
B[0] = B[1] = C[0] = C[1] = 0;
}
if (!v->blk_mv_type[xy]) {
if (s->mb_width == 1) {
px = B[0];
py = B[1];
} else {
if (total_valid >= 2) {
px = mid_pred(A[0], B[0], C[0]);
py = mid_pred(A[1], B[1], C[1]);
} else if (total_valid) {
if (a_valid) { px = A[0]; py = A[1]; }
if (b_valid) { px = B[0]; py = B[1]; }
if (c_valid) { px = C[0]; py = C[1]; }
} else
px = py = 0;
}
} else {
if (a_valid)
field_a = (A[1] & 4) ? 1 : 0;
else
field_a = 0;
if (b_valid)
field_b = (B[1] & 4) ? 1 : 0;
else
field_b = 0;
if (c_valid)
field_c = (C[1] & 4) ? 1 : 0;
else
field_c = 0;
num_oppfield = field_a + field_b + field_c;
num_samefield = total_valid - num_oppfield;
if (total_valid == 3) {
if ((num_samefield == 3) || (num_oppfield == 3)) {
px = mid_pred(A[0], B[0], C[0]);
py = mid_pred(A[1], B[1], C[1]);
} else if (num_samefield >= num_oppfield) {
px = !field_a ? A[0] : B[0];
py = !field_a ? A[1] : B[1];
} else {
px = field_a ? A[0] : B[0];
py = field_a ? A[1] : B[1];
}
} else if (total_valid == 2) {
if (num_samefield >= num_oppfield) {
if (!field_a && a_valid) {
px = A[0];
py = A[1];
} else if (!field_b && b_valid) {
px = B[0];
py = B[1];
} else if (c_valid) {
px = C[0];
py = C[1];
}
} else {
if (field_a && a_valid) {
px = A[0];
py = A[1];
} else if (field_b && b_valid) {
px = B[0];
py = B[1];
}
}
} else if (total_valid == 1) {
px = (a_valid) ? A[0] : ((b_valid) ? B[0] : C[0]);
py = (a_valid) ? A[1] : ((b_valid) ? B[1] : C[1]);
} else
px = py = 0;
}
s->mv[dir][n][0] = s->current_picture.motion_val[dir][xy][0] = ((px + dmv_x + r_x) & ((r_x << 1) - 1)) - r_x;
s->mv[dir][n][1] = s->current_picture.motion_val[dir][xy][1] = ((py + dmv_y + r_y) & ((r_y << 1) - 1)) - r_y;
if (mvn == 1) {
s->current_picture.motion_val[dir][xy + 1 ][0] = s->current_picture.motion_val[dir][xy][0];
s->current_picture.motion_val[dir][xy + 1 ][1] = s->current_picture.motion_val[dir][xy][1];
s->current_picture.motion_val[dir][xy + wrap ][0] = s->current_picture.motion_val[dir][xy][0];
s->current_picture.motion_val[dir][xy + wrap ][1] = s->current_picture.motion_val[dir][xy][1];
s->current_picture.motion_val[dir][xy + wrap + 1][0] = s->current_picture.motion_val[dir][xy][0];
s->current_picture.motion_val[dir][xy + wrap + 1][1] = s->current_picture.motion_val[dir][xy][1];
} else if (mvn == 2) {
s->current_picture.motion_val[dir][xy + 1][0] = s->current_picture.motion_val[dir][xy][0];
s->current_picture.motion_val[dir][xy + 1][1] = s->current_picture.motion_val[dir][xy][1];
s->mv[dir][n + 1][0] = s->mv[dir][n][0];
s->mv[dir][n + 1][1] = s->mv[dir][n][1];
}
}
| 1threat
|
C - recursion printing array in reverse order[help] : So I have the following source code which you will find below. I'm having a hard time understanding how interchanging the two last line in the printarrayfunction with reverse the order of the array.
lines inquestion:
printf("%d", arr[n-1]);
printArray(n-1, arr);
Would it be possible for somebody to dumb this down for me?? Thank you!
#include <stdio.h>
void printArray(int n, int arr[]);
int main(void){
int array[7]= {1,2,3,4,5,6,7}, n=7;
printArray(n, x);
return 0;
}
void printArray(int n, int arr[]){
if( n==1){
printf("%d", arr[0])
}
else {
printf("%d", arr[n-1]);
printArray(n-1, arr);
}
}
| 0debug
|
How do we authenticate against a secured NuGet server with Cake build? : <p>We are working on automating our builds using Cake Build and we use NuGet packages from nuget.org but we also have our own NuGet Feed server which has a username/password authentication to access. How do we utilize Cake Build with a custom NuGet feed server with authentication?</p>
| 0debug
|
static void multiwrite_cb(void *opaque, int ret)
{
MultiwriteCB *mcb = opaque;
trace_multiwrite_cb(mcb, ret);
if (ret < 0 && !mcb->error) {
mcb->error = ret;
}
mcb->num_requests--;
if (mcb->num_requests == 0) {
multiwrite_user_cb(mcb);
g_free(mcb);
}
}
| 1threat
|
How to determine if string cotain one group o digits on the end of it : currently I am struggling with an address normalization problem. At the beggining, ul = street. In my country in most scenario occurs streets with format like "ul. Marii Skłodowskiej-Curie" without number on the end of street but in specific situation occurs streets like "ul. Dywizjonu 303" where 303 is not a house number.
I have an address dictionary whereby I need to check if street exists. First example is pretty easy to validate because i will remove all digits from the end of string and compare result string with dictionary but on the other hand in second example if I will remove all digits from the end of string i will get "ul. Dywizjonu" without 303 which is integrated with street in normal way.
My question is, is it possible to rid off redundant digits and characters from the end of string and get last pair or single digit from string:
For instance:
"ul. Warszawska 150 12/45" -> separated result 150 and ul. Warszawska
"ul. Warszawska 17/19" -> separated result 17 and ul. Warszawska
"ul. Lipca 80r. 90" -> separated result 90 and ul. Lipca 80r.
"ul. Warszawska 14 10/120/2b" -> separated result 14 and ul. Warszawska
Currently I removed all redundant multi whitespaces from string and splitted by whitespace but i completely don't know what I suppose to do next to get a desirable result like above.
Thank you in advance for all your help.
| 0debug
|
void timer_mod_anticipate_ns(QEMUTimer *ts, int64_t expire_time)
{
QEMUTimerList *timer_list = ts->timer_list;
bool rearm;
qemu_mutex_lock(&timer_list->active_timers_lock);
if (ts->expire_time == -1 || ts->expire_time > expire_time) {
if (ts->expire_time != -1) {
timer_del_locked(timer_list, ts);
}
rearm = timer_mod_ns_locked(timer_list, ts, expire_time);
} else {
rearm = false;
}
qemu_mutex_unlock(&timer_list->active_timers_lock);
if (rearm) {
timerlist_rearm(timer_list);
}
}
| 1threat
|
Adding pandas columns to a sparse matrix : <p>I have additional derived values for X variables that I want to use in my model. </p>
<pre><code>XAll = pd_data[['title','wordcount','sumscores','length']]
y = pd_data['sentiment']
X_train, X_test, y_train, y_test = train_test_split(XAll, y, random_state=1)
</code></pre>
<p>As I am working with text data in title, I first convert it to a dtm separately:</p>
<pre><code>vect = CountVectorizer(max_df=0.5)
vect.fit(X_train['title'])
X_train_dtm = vect.transform(X_train['title'])
column_index = X_train_dtm.indices
print(type(X_train_dtm)) # This is <class 'scipy.sparse.csr.csr_matrix'>
print("X_train_dtm shape",X_train_dtm.get_shape()) # This is (856, 2016)
print("column index:",column_index) # This is column index: [ 533 754 859 ..., 633 950 1339]
</code></pre>
<p>Now that I have the text as a document term matrix, I would like to add the other features like 'wordcount','sumscores','length' to X_train_dtm which are numeric. This I shall create the model using the new dtm and thus would be more accurate as I would have inserted additinal features.</p>
<p>How do I add additional numeric columns of the pandas dataframe to a sparse csr matrix?</p>
| 0debug
|
Calculating age in Javascript with YYYY-mm-dd format : <p>I have birthday in following format: </p>
<pre><code>1982-09-20
</code></pre>
<p>I need to get the exact age of the person from that birthdate ( compared with the current date). </p>
<p>What's the easiest way to do this in JS? Can someone help me out please?</p>
<p>Thanks!</p>
| 0debug
|
static always_inline void fload_invalid_op_excp (int op)
{
int ve;
ve = fpscr_ve;
if (op & POWERPC_EXCP_FP_VXSNAN) {
env->fpscr |= 1 << FPSCR_VXSNAN;
}
if (op & POWERPC_EXCP_FP_VXSOFT) {
env->fpscr |= 1 << FPSCR_VXSOFT;
}
switch (op & ~(POWERPC_EXCP_FP_VXSOFT | POWERPC_EXCP_FP_VXSNAN)) {
case POWERPC_EXCP_FP_VXISI:
env->fpscr |= 1 << FPSCR_VXISI;
goto update_arith;
case POWERPC_EXCP_FP_VXIDI:
env->fpscr |= 1 << FPSCR_VXIDI;
goto update_arith;
case POWERPC_EXCP_FP_VXZDZ:
env->fpscr |= 1 << FPSCR_VXZDZ;
goto update_arith;
case POWERPC_EXCP_FP_VXIMZ:
env->fpscr |= 1 << FPSCR_VXIMZ;
goto update_arith;
case POWERPC_EXCP_FP_VXVC:
env->fpscr |= 1 << FPSCR_VXVC;
env->fpscr &= ~(0xF << FPSCR_FPCC);
env->fpscr |= 0x11 << FPSCR_FPCC;
if (ve != 0) {
env->exception_index = POWERPC_EXCP_PROGRAM;
env->error_code = POWERPC_EXCP_FP | POWERPC_EXCP_FP_VXVC;
env->fpscr |= 1 << FPSCR_FEX;
ve = 0;
}
break;
case POWERPC_EXCP_FP_VXSQRT:
env->fpscr |= 1 << FPSCR_VXSQRT;
update_arith:
env->fpscr &= ~((1 << FPSCR_FR) | (1 << FPSCR_FI));
if (ve == 0) {
FT0 = (uint64_t)-1;
env->fpscr &= ~(0xF << FPSCR_FPCC);
env->fpscr |= 0x11 << FPSCR_FPCC;
}
break;
case POWERPC_EXCP_FP_VXCVI:
env->fpscr |= 1 << FPSCR_VXCVI;
env->fpscr &= ~((1 << FPSCR_FR) | (1 << FPSCR_FI));
if (ve == 0) {
FT0 = (uint64_t)-1;
env->fpscr &= ~(0xF << FPSCR_FPCC);
env->fpscr |= 0x11 << FPSCR_FPCC;
}
break;
}
env->fpscr |= 1 << FPSCR_VX;
env->fpscr |= 1 << FPSCR_FX;
if (ve != 0) {
env->fpscr |= 1 << FPSCR_FEX;
if (msr_fe0 != 0 || msr_fe1 != 0)
do_raise_exception_err(POWERPC_EXCP_PROGRAM, POWERPC_EXCP_FP | op);
}
}
| 1threat
|
When should we define fields as "volatile"? When is it unnecessary? : <p>I understand <code>volatile</code> should be used on a class field to prevent the JVM from caching the value so when it will always be the latest value when it's read.</p>
<p>If my understanding is correct, doesn't it mean we should define all fields with <code>volatile</code> when working in a multithread thread-safe environment? When is it unnecessary to define a field as <code>volatile</code>? </p>
| 0debug
|
(Python) Stock_Market prediction using Linear regression : I'm trying to improve a stock_market prediction model using LinearRegression() on sklearn, first of all I'm new to machine learning and I am kind of struggling on how the code works here it is : [The Code][1]
Then it seems that we are using the same data two times one is scaled and called X and the other not called y. So I don't get how it can predict anything if it's just a line between two same data ???
Thanks for your help !!!!
[1]: https://www.kaggle.com/dkmostafa/predicting-stock-market-using-linear-regression
| 0debug
|
TypeError while running argv python code : from sys import argv
script, user_name = argv
prompt = '> '
print ("Hi %s, I'm the %s script.") % (user_name, script)
print ("I'd like to ask you a few questions.")
print ("Do you like me %s?") % user_name
likes = raw_input(prompt)
print ("Where do you live %s?") % (user_name)
lives = raw_input(prompt)
print ("What kind of computer do you have?")
computer = raw_input(prompt)
print """
Alright, so you said %r about liking me.
You live in %r. Not sure where that is.
And you have a %r computer. Nice.
""" % (likes, lives, computer)
While running this(python 3) code in powershell I am getting Type error 'unsupported operand type(s) for %:'Nonetype' and 'str''
What is the error here?
| 0debug
|
How to use vector<vector<string>> arr(n)? : vector<vector<string>> arr(n);
It was used in some code and i was unable to understand how to use so please help! me
| 0debug
|
Babel-node doesn't transform spread operator on preset env : <p>I'm trying to use babel-node with nodemon for the hot-reloading.
I've basically followed this <a href="https://github.com/babel/example-node-server" rel="noreferrer">repo</a>.</p>
<p>My <code>dev</code> script in <code>package.json</code> looks like that:</p>
<pre><code>"dev": "nodemon app.js --exec babel-node --presets env"
</code></pre>
<p>My <code>.babelrc</code>:</p>
<pre><code>{
"presets": ["env"]
}
</code></pre>
<p>Even though the spread operator is listed as supported by the env preset, when using it with this setup I get a </p>
<blockquote>
<p>SyntaxError: Unexpected token</p>
</blockquote>
| 0debug
|
Is cross-platform development worth learning : <p>I have been an Android developer for 1,5 years now and I thought about building an app for both <code>IOS</code> and <code>Android</code>. I have read multiple posts and questions about cross-platform developing. </p>
<p>Most of them are rather negative saying that <code>cross-platform</code> developing results in slow applications and also that an application should be approached differently since both <code>Android</code> and <code>IOS</code> are different.</p>
<p>The reason I am asking this is because most of the posts and questions I have seen so far are pretty old and I am asking if <code>cross-platform</code> developing is something I should pick up or just learn <code>IOS</code> development seperately. </p>
<p>If <code>cross-platform</code> is worth it nowadays then which language or tool should I use for it?</p>
| 0debug
|
How do I use numba on a member function of a class? : <p>I'm using the stable version of Numba 0.30.1.</p>
<p>I can do this:</p>
<pre><code>import numba as nb
@nb.jit("void(f8[:])",nopython=True)
def complicated(x):
for a in x:
b = a**2.+a**3.
</code></pre>
<p>as a test case, and the speedup is enormous. But I don't know how to proceed if I need to speed up a function inside a class. </p>
<pre><code>import numba as nb
def myClass(object):
def __init__(self):
self.k = 1
#@nb.jit(???,nopython=True)
def complicated(self,x):
for a in x:
b = a**2.+a**3.+self.k
</code></pre>
<p>What numba type do I use for the <code>self</code> object? I need to have this function inside a class since it needs to access a member variable.</p>
| 0debug
|
void qemu_purge_queued_packets(VLANClientState *vc)
{
VLANPacket *packet, *next;
TAILQ_FOREACH_SAFE(packet, &vc->vlan->send_queue, entry, next) {
if (packet->sender == vc) {
TAILQ_REMOVE(&vc->vlan->send_queue, packet, entry);
qemu_free(packet);
}
}
}
| 1threat
|
void configure_icount(const char *option)
{
vmstate_register(NULL, 0, &vmstate_timers, &timers_state);
if (!option)
return;
if (strcmp(option, "auto") != 0) {
icount_time_shift = strtol(option, NULL, 0);
use_icount = 1;
return;
}
use_icount = 2;
icount_time_shift = 3;
icount_rt_timer = qemu_new_timer(rt_clock, icount_adjust_rt, NULL);
qemu_mod_timer(icount_rt_timer,
qemu_get_clock(rt_clock) + 1000);
icount_vm_timer = qemu_new_timer(vm_clock, icount_adjust_vm, NULL);
qemu_mod_timer(icount_vm_timer,
qemu_get_clock(vm_clock) + get_ticks_per_sec() / 10);
}
| 1threat
|
static void evaluate_flags_writeback(uint32_t flags)
{
int x;
x = env->cc_x;
if ((x || env->cc_op == CC_OP_ADDC)
&& flags & Z_FLAG)
env->cc_mask &= ~Z_FLAG;
env->pregs[PR_CCS] &= ~(env->cc_mask | X_FLAG);
flags &= env->cc_mask;
env->pregs[PR_CCS] |= flags;
}
| 1threat
|
Boolean function always returning true : <p>I am taking a course on Udemy to learn C++, and I am following along with the professor. </p>
<p>This is the exact code that is being used in the class.
You pass in a letter, and it tells you whether or not it is a vowel. However, it is saying every letter is a vowel. For example, when I pass in 'b', it says it is a vowel.</p>
<p>Any clue?</p>
<hr>
<pre><code>#include <iostream>
#include <cmath>
using namespace std;
bool isVowel(char letter) {
if ((letter == 'a') || (letter == 'e') || (letter = 'i') ||
(letter = 'o') || (letter = 'u'))
return true;
else
return false;
}
int main() {
char let;
cout << "Enter a letter: ";
cin >> let;
if (isVowel(let))
cout << let << " is a vowel." << endl;
else
cout << let << " is a consonant." << endl;
return 0;
}
</code></pre>
<hr>
<p>I get the same problem using both codeblocks and xcode.</p>
<p>Thanks</p>
| 0debug
|
'goto *foo' where foo is not a pointer. What is this? : <p>I was playing around with <a href="https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html">labels as values</a> and ended up with this code. </p>
<pre><code>int foo = 0;
goto *foo;
</code></pre>
<p>My C/C++ experience tells me <code>*foo</code> means <code>dereference foo</code> and that this won't compile because <code>foo</code> isn't a pointer. But it does compile. What does this actually do?</p>
<p><code>gcc (Ubuntu 4.9.2-0ubuntu1~12.04) 4.9.2</code>, if important.</p>
| 0debug
|
Php alert doesn't work : I am trying to pop up an alert in html with php if the user hasn't upload a file in input element.
The source code in index.php :
<input type='file' name="imgInp" id="imgInp" accept=".jpg, .png, .jpeg|images/*"/>
<img style="max-height: 400px; max-width: 400px;" id="blah" src="#" alt="your image" />
In submitted php file:
if($_FILES["imgInp"]["name"]!='')
{
$first_file=rand().$_FILES["imgInp"]["name"];
$path="images/template/usersupload/";
$tot_dir=$path.$first_file;
if(file_exists($path))
{
move_uploaded_file($_FILES["imgInp"]["tmp_name"],$tot_dir);
}
}
else
{
echo '<script>alert("You forgot to upload a file!!!");
</script>';
echo'<script type="text/javascript">';
?>
window.location="index.php";
<?php
echo '</script>';
}
Please for your help.
| 0debug
|
static USBDevice *usb_bt_init(USBBus *bus, const char *cmdline)
{
USBDevice *dev;
struct USBBtState *s;
HCIInfo *hci;
const char *name = "usb-bt-dongle";
if (*cmdline) {
hci = hci_init(cmdline);
} else {
hci = bt_new_hci(qemu_find_bt_vlan(0));
}
if (!hci)
return NULL;
dev = usb_create(bus, name);
s = DO_UPCAST(struct USBBtState, dev, dev);
s->hci = hci;
if (qdev_init(&dev->qdev) < 0) {
error_report("Failed to initialize USB device '%s'", name);
return NULL;
}
return dev;
}
| 1threat
|
I want to create a simple login portal but there are som issues : i create a simple login portal but there are some issues and i try all solution
please help me
this is my login.php file.
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<link rel="short icon" href="sopraicon.ico">
<link rel="stylesheet" href="login.css">
<body>
<form method="POST" action="process.php" >
<img src="soprasteria.png" alt="sopra steria" width="20%" align="center">
<img src="share.png" alt="share" id="img1" align="right">
<a href=""> <img src="search.png" id="img1" align="right"></a>
<input type="text" class="search" name="search" placeholder="Search.."><br>
<br> <div class="sidediv"></div>
<p class="data">Sign in to Sopra Steria</p><br>
<h3 class="h3">User Login</h3>
<br><img src="Login.jpg" alt="login iamge" height="150px" width="170px"
align="left" style="padding-left:160px"><br>  <b>Username:</b>
<br>  <input type="text" placeholder="User Name" name="username"
required id="text">
<br>  <b>Password:</b><br>  <input type="password"
placeholder="Enter Password" name="password" required id="text" min="8">
<br>  <button type="submit" id="logbtn"
name="submit">Login</button><br>
<div class="bottomdiv"></div>
</form>
</body>
</head>
</html>
this is my process.php file
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$username = stripcslashes($username);
$password = stripcslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
mysql_connect("localhost","root","");
mysql_select_db("login");
$result = mysql_query("select * from users where username='$username'
and password='$password'") or die("failed to query
database".mysql_error());
$row = mysql_fetch_array(result);
if($row['username']==$username && $row['password']== $password){
echo"login success";
}
else{
echo"failed";
}
?>
but i get error on wamp server as you see in image
please help me...
thank you.
[1]: https://i.stack.imgur.com/JsCHY.jpg
help me out....
thank you
| 0debug
|
static int seg_write_trailer(struct AVFormatContext *s)
{
SegmentContext *seg = s->priv_data;
AVFormatContext *oc = seg->avf;
int ret = 0;
if (!oc)
goto fail;
if (!seg->write_header_trailer) {
if ((ret = segment_end(oc, 0)) < 0)
goto fail;
open_null_ctx(&oc->pb);
ret = av_write_trailer(oc);
close_null_ctx(oc->pb);
} else {
ret = segment_end(oc, 1);
}
if (ret < 0)
goto fail;
if (seg->list && seg->list_type == LIST_HLS) {
if ((ret = segment_hls_window(s, 1) < 0))
goto fail;
}
fail:
avio_close(seg->pb);
avformat_free_context(oc);
return ret;
}
| 1threat
|
static int avi_read_header(AVFormatContext *s)
{
AVIContext *avi = s->priv_data;
AVIOContext *pb = s->pb;
unsigned int tag, tag1, handler;
int codec_type, stream_index, frame_period;
unsigned int size;
int i;
AVStream *st;
AVIStream *ast = NULL;
int avih_width = 0, avih_height = 0;
int amv_file_format = 0;
uint64_t list_end = 0;
int64_t pos;
int ret;
AVDictionaryEntry *dict_entry;
avi->stream_index = -1;
ret = get_riff(s, pb);
if (ret < 0)
return ret;
av_log(avi, AV_LOG_DEBUG, "use odml:%d\n", avi->use_odml);
avi->io_fsize = avi->fsize = avio_size(pb);
if (avi->fsize <= 0 || avi->fsize < avi->riff_end)
avi->fsize = avi->riff_end == 8 ? INT64_MAX : avi->riff_end;
stream_index = -1;
codec_type = -1;
frame_period = 0;
for (;;) {
if (avio_feof(pb))
goto fail;
tag = avio_rl32(pb);
size = avio_rl32(pb);
print_tag("tag", tag, size);
switch (tag) {
case MKTAG('L', 'I', 'S', 'T'):
list_end = avio_tell(pb) + size;
tag1 = avio_rl32(pb);
print_tag("list", tag1, 0);
if (tag1 == MKTAG('m', 'o', 'v', 'i')) {
avi->movi_list = avio_tell(pb) - 4;
if (size)
avi->movi_end = avi->movi_list + size + (size & 1);
else
avi->movi_end = avi->fsize;
av_log(NULL, AV_LOG_TRACE, "movi end=%"PRIx64"\n", avi->movi_end);
goto end_of_header;
} else if (tag1 == MKTAG('I', 'N', 'F', 'O'))
ff_read_riff_info(s, size - 4);
else if (tag1 == MKTAG('n', 'c', 'd', 't'))
avi_read_nikon(s, list_end);
break;
case MKTAG('I', 'D', 'I', 'T'):
{
unsigned char date[64] = { 0 };
size += (size & 1);
size -= avio_read(pb, date, FFMIN(size, sizeof(date) - 1));
avio_skip(pb, size);
avi_metadata_creation_time(&s->metadata, date);
break;
case MKTAG('d', 'm', 'l', 'h'):
avi->is_odml = 1;
avio_skip(pb, size + (size & 1));
break;
case MKTAG('a', 'm', 'v', 'h'):
amv_file_format = 1;
case MKTAG('a', 'v', 'i', 'h'):
frame_period = avio_rl32(pb);
avio_rl32(pb);
avio_rl32(pb);
avi->non_interleaved |= avio_rl32(pb) & AVIF_MUSTUSEINDEX;
avio_skip(pb, 2 * 4);
avio_rl32(pb);
avio_rl32(pb);
avih_width = avio_rl32(pb);
avih_height = avio_rl32(pb);
avio_skip(pb, size - 10 * 4);
break;
case MKTAG('s', 't', 'r', 'h'):
tag1 = avio_rl32(pb);
handler = avio_rl32(pb);
if (tag1 == MKTAG('p', 'a', 'd', 's')) {
avio_skip(pb, size - 8);
break;
} else {
stream_index++;
st = avformat_new_stream(s, NULL);
if (!st)
goto fail;
st->id = stream_index;
ast = av_mallocz(sizeof(AVIStream));
if (!ast)
goto fail;
st->priv_data = ast;
if (amv_file_format)
tag1 = stream_index ? MKTAG('a', 'u', 'd', 's')
: MKTAG('v', 'i', 'd', 's');
print_tag("strh", tag1, -1);
if (tag1 == MKTAG('i', 'a', 'v', 's') ||
tag1 == MKTAG('i', 'v', 'a', 's')) {
int64_t dv_dur;
if (s->nb_streams != 1)
goto fail;
if (handler != MKTAG('d', 'v', 's', 'd') &&
handler != MKTAG('d', 'v', 'h', 'd') &&
handler != MKTAG('d', 'v', 's', 'l'))
goto fail;
ast = s->streams[0]->priv_data;
av_freep(&s->streams[0]->codecpar->extradata);
av_freep(&s->streams[0]->codecpar);
#if FF_API_LAVF_AVCTX
FF_DISABLE_DEPRECATION_WARNINGS
av_freep(&s->streams[0]->codec);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (s->streams[0]->info)
av_freep(&s->streams[0]->info->duration_error);
av_freep(&s->streams[0]->info);
if (s->streams[0]->internal)
av_freep(&s->streams[0]->internal->avctx);
av_freep(&s->streams[0]->internal);
av_freep(&s->streams[0]);
s->nb_streams = 0;
if (CONFIG_DV_DEMUXER) {
avi->dv_demux = avpriv_dv_init_demux(s);
if (!avi->dv_demux)
goto fail;
} else
goto fail;
s->streams[0]->priv_data = ast;
avio_skip(pb, 3 * 4);
ast->scale = avio_rl32(pb);
ast->rate = avio_rl32(pb);
avio_skip(pb, 4);
dv_dur = avio_rl32(pb);
if (ast->scale > 0 && ast->rate > 0 && dv_dur > 0) {
dv_dur *= AV_TIME_BASE;
s->duration = av_rescale(dv_dur, ast->scale, ast->rate);
stream_index = s->nb_streams - 1;
avio_skip(pb, size - 9 * 4);
break;
av_assert0(stream_index < s->nb_streams);
ast->handler = handler;
avio_rl32(pb);
avio_rl16(pb);
avio_rl16(pb);
avio_rl32(pb);
ast->scale = avio_rl32(pb);
ast->rate = avio_rl32(pb);
if (!(ast->scale && ast->rate)) {
av_log(s, AV_LOG_WARNING,
"scale/rate is %"PRIu32"/%"PRIu32" which is invalid. "
"(This file has been generated by broken software.)\n",
ast->scale,
ast->rate);
if (frame_period) {
ast->rate = 1000000;
ast->scale = frame_period;
} else {
ast->rate = 25;
ast->scale = 1;
avpriv_set_pts_info(st, 64, ast->scale, ast->rate);
ast->cum_len = avio_rl32(pb);
st->nb_frames = avio_rl32(pb);
st->start_time = 0;
avio_rl32(pb);
avio_rl32(pb);
if (ast->cum_len*ast->scale/ast->rate > 3600) {
av_log(s, AV_LOG_ERROR, "crazy start time, iam scared, giving up\n");
ast->cum_len = 0;
ast->sample_size = avio_rl32(pb);
ast->cum_len *= FFMAX(1, ast->sample_size);
av_log(s, AV_LOG_TRACE, "%"PRIu32" %"PRIu32" %d\n",
ast->rate, ast->scale, ast->sample_size);
switch (tag1) {
case MKTAG('v', 'i', 'd', 's'):
codec_type = AVMEDIA_TYPE_VIDEO;
ast->sample_size = 0;
st->avg_frame_rate = av_inv_q(st->time_base);
break;
case MKTAG('a', 'u', 'd', 's'):
codec_type = AVMEDIA_TYPE_AUDIO;
break;
case MKTAG('t', 'x', 't', 's'):
codec_type = AVMEDIA_TYPE_SUBTITLE;
break;
case MKTAG('d', 'a', 't', 's'):
codec_type = AVMEDIA_TYPE_DATA;
break;
default:
av_log(s, AV_LOG_INFO, "unknown stream type %X\n", tag1);
if (ast->sample_size < 0) {
if (s->error_recognition & AV_EF_EXPLODE) {
av_log(s, AV_LOG_ERROR,
"Invalid sample_size %d at stream %d\n",
ast->sample_size,
stream_index);
goto fail;
av_log(s, AV_LOG_WARNING,
"Invalid sample_size %d at stream %d "
"setting it to 0\n",
ast->sample_size,
stream_index);
ast->sample_size = 0;
if (ast->sample_size == 0) {
st->duration = st->nb_frames;
if (st->duration > 0 && avi->io_fsize > 0 && avi->riff_end > avi->io_fsize) {
av_log(s, AV_LOG_DEBUG, "File is truncated adjusting duration\n");
st->duration = av_rescale(st->duration, avi->io_fsize, avi->riff_end);
ast->frame_offset = ast->cum_len;
avio_skip(pb, size - 12 * 4);
break;
case MKTAG('s', 't', 'r', 'f'):
if (!size)
break;
if (stream_index >= (unsigned)s->nb_streams || avi->dv_demux) {
avio_skip(pb, size);
} else {
uint64_t cur_pos = avio_tell(pb);
unsigned esize;
if (cur_pos < list_end)
size = FFMIN(size, list_end - cur_pos);
st = s->streams[stream_index];
if (st->codecpar->codec_type != AVMEDIA_TYPE_UNKNOWN) {
avio_skip(pb, size);
break;
switch (codec_type) {
case AVMEDIA_TYPE_VIDEO:
if (amv_file_format) {
st->codecpar->width = avih_width;
st->codecpar->height = avih_height;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_AMV;
avio_skip(pb, size);
break;
tag1 = ff_get_bmp_header(pb, st, &esize);
if (tag1 == MKTAG('D', 'X', 'S', 'B') ||
tag1 == MKTAG('D', 'X', 'S', 'A')) {
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codecpar->codec_tag = tag1;
st->codecpar->codec_id = AV_CODEC_ID_XSUB;
break;
if (size > 10 * 4 && size < (1 << 30) && size < avi->fsize) {
if (esize == size-1 && (esize&1)) {
st->codecpar->extradata_size = esize - 10 * 4;
} else
st->codecpar->extradata_size = size - 10 * 4;
if (ff_get_extradata(s, st->codecpar, pb, st->codecpar->extradata_size) < 0)
return AVERROR(ENOMEM);
if (st->codecpar->extradata_size & 1)
avio_r8(pb);
if (st->codecpar->extradata_size &&
(st->codecpar->bits_per_coded_sample <= 8)) {
int pal_size = (1 << st->codecpar->bits_per_coded_sample) << 2;
const uint8_t *pal_src;
pal_size = FFMIN(pal_size, st->codecpar->extradata_size);
pal_src = st->codecpar->extradata +
st->codecpar->extradata_size - pal_size;
if (pal_src - st->codecpar->extradata >= 9 &&
!memcmp(st->codecpar->extradata + st->codecpar->extradata_size - 9, "BottomUp", 9))
pal_src -= 9;
for (i = 0; i < pal_size / 4; i++)
ast->pal[i] = 0xFFU<<24 | AV_RL32(pal_src+4*i);
ast->has_pal = 1;
print_tag("video", tag1, 0);
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_tag = tag1;
st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags,
tag1);
if (!st->codecpar->codec_id) {
char tag_buf[32];
av_get_codec_tag_string(tag_buf, sizeof(tag_buf), tag1);
st->codecpar->codec_id =
ff_codec_get_id(ff_codec_movvideo_tags, tag1);
if (st->codecpar->codec_id)
av_log(s, AV_LOG_WARNING,
"mov tag found in avi (fourcc %s)\n",
tag_buf);
st->need_parsing = AVSTREAM_PARSE_HEADERS;
if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4 &&
ast->handler == MKTAG('X', 'V', 'I', 'D'))
st->codecpar->codec_tag = MKTAG('X', 'V', 'I', 'D');
if (st->codecpar->codec_tag == MKTAG('V', 'S', 'S', 'H'))
st->need_parsing = AVSTREAM_PARSE_FULL;
if (st->codecpar->codec_id == AV_CODEC_ID_RV40)
st->need_parsing = AVSTREAM_PARSE_NONE;
if (st->codecpar->codec_tag == 0 && st->codecpar->height > 0 &&
st->codecpar->extradata_size < 1U << 30) {
st->codecpar->extradata_size += 9;
if ((ret = av_reallocp(&st->codecpar->extradata,
st->codecpar->extradata_size +
AV_INPUT_BUFFER_PADDING_SIZE)) < 0) {
st->codecpar->extradata_size = 0;
return ret;
} else
memcpy(st->codecpar->extradata + st->codecpar->extradata_size - 9,
"BottomUp", 9);
st->codecpar->height = FFABS(st->codecpar->height);
break;
case AVMEDIA_TYPE_AUDIO:
ret = ff_get_wav_header(s, pb, st->codecpar, size, 0);
if (ret < 0)
return ret;
ast->dshow_block_align = st->codecpar->block_align;
if (ast->sample_size && st->codecpar->block_align &&
ast->sample_size != st->codecpar->block_align) {
av_log(s,
AV_LOG_WARNING,
"sample size (%d) != block align (%d)\n",
ast->sample_size,
st->codecpar->block_align);
ast->sample_size = st->codecpar->block_align;
if (size & 1)
avio_skip(pb, 1);
st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
st->codecpar->extradata_size)
st->need_parsing = AVSTREAM_PARSE_NONE;
if (st->codecpar->codec_id == AV_CODEC_ID_FLAC)
st->need_parsing = AVSTREAM_PARSE_NONE;
if (ast->handler == AV_RL32("Axan")) {
st->codecpar->codec_id = AV_CODEC_ID_XAN_DPCM;
st->codecpar->codec_tag = 0;
ast->dshow_block_align = 0;
if (amv_file_format) {
st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_AMV;
ast->dshow_block_align = 0;
if ((st->codecpar->codec_id == AV_CODEC_ID_AAC ||
st->codecpar->codec_id == AV_CODEC_ID_FLAC ||
st->codecpar->codec_id == AV_CODEC_ID_MP2 ) && ast->dshow_block_align <= 4 && ast->dshow_block_align) {
av_log(s, AV_LOG_DEBUG, "overriding invalid dshow_block_align of %d\n", ast->dshow_block_align);
ast->dshow_block_align = 0;
if (st->codecpar->codec_id == AV_CODEC_ID_AAC && ast->dshow_block_align == 1024 && ast->sample_size == 1024 ||
st->codecpar->codec_id == AV_CODEC_ID_AAC && ast->dshow_block_align == 4096 && ast->sample_size == 4096 ||
st->codecpar->codec_id == AV_CODEC_ID_MP3 && ast->dshow_block_align == 1152 && ast->sample_size == 1152) {
av_log(s, AV_LOG_DEBUG, "overriding sample_size\n");
ast->sample_size = 0;
break;
case AVMEDIA_TYPE_SUBTITLE:
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->request_probe= 1;
avio_skip(pb, size);
break;
default:
st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
st->codecpar->codec_id = AV_CODEC_ID_NONE;
st->codecpar->codec_tag = 0;
avio_skip(pb, size);
break;
break;
case MKTAG('s', 't', 'r', 'd'):
if (stream_index >= (unsigned)s->nb_streams
|| s->streams[stream_index]->codecpar->extradata_size
|| s->streams[stream_index]->codecpar->codec_tag == MKTAG('H','2','6','4')) {
avio_skip(pb, size);
} else {
uint64_t cur_pos = avio_tell(pb);
if (cur_pos < list_end)
size = FFMIN(size, list_end - cur_pos);
st = s->streams[stream_index];
if (size<(1<<30)) {
av_log(s, AV_LOG_WARNING, "New extradata in strd chunk, freeing previous one.\n");
if (ff_get_extradata(s, st->codecpar, pb, size) < 0)
return AVERROR(ENOMEM);
if (st->codecpar->extradata_size & 1)
avio_r8(pb);
ret = avi_extract_stream_metadata(s, st);
if (ret < 0) {
av_log(s, AV_LOG_WARNING, "could not decoding EXIF data in stream header.\n");
break;
case MKTAG('i', 'n', 'd', 'x'):
pos = avio_tell(pb);
if (pb->seekable && !(s->flags & AVFMT_FLAG_IGNIDX) &&
avi->use_odml &&
read_braindead_odml_indx(s, 0) < 0 &&
(s->error_recognition & AV_EF_EXPLODE))
goto fail;
avio_seek(pb, pos + size, SEEK_SET);
break;
case MKTAG('v', 'p', 'r', 'p'):
if (stream_index < (unsigned)s->nb_streams && size > 9 * 4) {
AVRational active, active_aspect;
st = s->streams[stream_index];
avio_rl32(pb);
avio_rl32(pb);
avio_rl32(pb);
avio_rl32(pb);
avio_rl32(pb);
active_aspect.den = avio_rl16(pb);
active_aspect.num = avio_rl16(pb);
active.num = avio_rl32(pb);
active.den = avio_rl32(pb);
avio_rl32(pb);
if (active_aspect.num && active_aspect.den &&
active.num && active.den) {
st->sample_aspect_ratio = av_div_q(active_aspect, active);
av_log(s, AV_LOG_TRACE, "vprp %d/%d %d/%d\n",
active_aspect.num, active_aspect.den,
active.num, active.den);
size -= 9 * 4;
avio_skip(pb, size);
break;
case MKTAG('s', 't', 'r', 'n'):
if (s->nb_streams) {
ret = avi_read_tag(s, s->streams[s->nb_streams - 1], tag, size);
if (ret < 0)
return ret;
break;
default:
if (size > 1000000) {
char tag_buf[32];
av_get_codec_tag_string(tag_buf, sizeof(tag_buf), tag);
av_log(s, AV_LOG_ERROR,
"Something went wrong during header parsing, "
"tag %s has size %u, "
"I will ignore it and try to continue anyway.\n",
tag_buf, size);
if (s->error_recognition & AV_EF_EXPLODE)
goto fail;
avi->movi_list = avio_tell(pb) - 4;
avi->movi_end = avi->fsize;
goto end_of_header;
case MKTAG('i', 'd', 'x', '1'):
size += (size & 1);
avio_skip(pb, size);
break;
end_of_header:
if (stream_index != s->nb_streams - 1) {
fail:
return AVERROR_INVALIDDATA;
if (!avi->index_loaded && pb->seekable)
avi_load_index(s);
calculate_bitrate(s);
avi->index_loaded |= 1;
if ((ret = guess_ni_flag(s)) < 0)
return ret;
avi->non_interleaved |= ret | (s->flags & AVFMT_FLAG_SORT_DTS);
dict_entry = av_dict_get(s->metadata, "ISFT", NULL, 0);
if (dict_entry && !strcmp(dict_entry->value, "PotEncoder"))
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if ( st->codecpar->codec_id == AV_CODEC_ID_MPEG1VIDEO
|| st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO)
st->need_parsing = AVSTREAM_PARSE_FULL;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->nb_index_entries)
break;
if (avi->dv_demux)
avi->non_interleaved = 0;
if (i == s->nb_streams && avi->non_interleaved) {
av_log(s, AV_LOG_WARNING,
"Non-interleaved AVI without index, switching to interleaved\n");
avi->non_interleaved = 0;
if (avi->non_interleaved) {
av_log(s, AV_LOG_INFO, "non-interleaved AVI\n");
clean_index(s);
ff_metadata_conv_ctx(s, NULL, avi_metadata_conv);
ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv);
return 0;
| 1threat
|
Python - Quiz Help (: : I am a beginner to Python and having difficulties with a short quiz I am creating.
I have created a short video, to show exactly what is happening:
https://www.youtube.com/watch?v=aHRAr0T-i-Q&feature=youtu.be
How can I have it so it comes up with the question, "Who is Conor Mcgregor?" and then print the answers and how can I stop it from repeating the question again underneath the answers?
I presume this has something to do with my len(question): ?
Thanks you in advance!
| 0debug
|
Set component's props dynamically : <p>I need to set component's props after it is stored in a variable, here is pseudo code:</p>
<pre><code>render(){
let items = [{title:'hello'}, {title:'world'}];
let component = false;
switch (id) {
case 1:
component = <A />
break;
case 2:
component = <B />
break;
}
return(
items.map((item, index)=>{
return(
<span>
{/* SOMETHING LIKE THIS WOULD BE COOL - IS THAT EVEN POSSIBLE*/}
{component.props.set('title', item.title)}
</span>11
)
})
)
}
</code></pre>
<p>Inside <code>return</code> I run a loop where I need to set props for the component that is stored inside a variable.... How to set props for this component which I stored earlier in a variable? </p>
| 0debug
|
void do_tw (int flags)
{
if (!likely(!((Ts0 < Ts1 && (flags & 0x10)) ||
(Ts0 > Ts1 && (flags & 0x08)) ||
(Ts0 == Ts1 && (flags & 0x04)) ||
(T0 < T1 && (flags & 0x02)) ||
(T0 > T1 && (flags & 0x01)))))
do_raise_exception_err(EXCP_PROGRAM, EXCP_TRAP);
}
| 1threat
|
static av_cold int encode_close(AVCodecContext* avc_context)
{
TheoraContext *h = avc_context->priv_data;
th_encode_free(h->t_state);
av_freep(&h->stats);
av_freep(&avc_context->coded_frame);
av_freep(&avc_context->stats_out);
av_freep(&avc_context->extradata);
avc_context->extradata_size = 0;
return 0;
}
| 1threat
|
struct SwsContext *sws_getContext(int srcW, int srcH, int srcFormat,
int dstW, int dstH, int dstFormat,
int flags, SwsFilter *srcFilter,
SwsFilter *dstFilter, double *param)
{
struct SwsContext *ctx;
ctx = av_malloc(sizeof(struct SwsContext));
if (ctx)
ctx->av_class = av_mallocz(sizeof(AVClass));
if (!ctx || !ctx->av_class) {
av_log(NULL, AV_LOG_ERROR, "Cannot allocate a resampling context!\n");
return NULL;
}
if ((srcH != dstH) || (srcW != dstW)) {
if ((srcFormat != PIX_FMT_YUV420P) || (dstFormat != PIX_FMT_YUV420P)) {
av_log(NULL, AV_LOG_INFO, "PIX_FMT_YUV420P will be used as an intermediate format for rescaling\n");
}
ctx->resampling_ctx = img_resample_init(dstW, dstH, srcW, srcH);
} else {
ctx->resampling_ctx = av_malloc(sizeof(ImgReSampleContext));
ctx->resampling_ctx->iheight = srcH;
ctx->resampling_ctx->iwidth = srcW;
ctx->resampling_ctx->oheight = dstH;
ctx->resampling_ctx->owidth = dstW;
}
ctx->src_pix_fmt = srcFormat;
ctx->dst_pix_fmt = dstFormat;
return ctx;
}
| 1threat
|
MS SQL Query. VERY IMPORTANT : I have to write a query regarding the statement below:
List all directors who directed 50 movies or more, in descending order of the number of movies they directed. Return the directors' names and the number of movies each of them directed.
I have written multiple variations but I keep getting errors.
It involves joins. The tables involved are: Directors (directorID, firstname, lastname), Movie_Directors (directorID, movieID).
What I have so far is:
SELECT DISTINCT firstname,lastname,COUNT(movie_directors.directorID)
FROM dbo.movie_directors
INNER JOIN directors
ON directors.directorID=movie_directors.directorID
HAVING COUNT(movie_directors.directorID)>=50
The Error is:
Msg 8120, Level 16, State 1.
Column 'directors.firstname' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. (Line 1)
| 0debug
|
Next.js: Router.push with state : <p>I'm using next.js for rebuilding an app for server side rendering.
I have a button that handles a search request.</p>
<p>In the old app, the handler was this one:</p>
<pre><code>search = (event) => {
event.preventDefault();
history.push({
pathname: '/results',
state: {
pattern: this.state.searchText,
}
});
}
</code></pre>
<p>In the results class, I could get the state date with this.props.location.state.pattern.</p>
<p>So now I'm using next.js:</p>
<pre><code>import Router, { withRouter } from 'next/router'
performSearch = (event) => {
event.preventDefault();
Router.push({ pathname: '/results', state: { pattern: this.state.searchText } });
};
</code></pre>
<p>In the results class, I use </p>
<pre><code>static async getInitialProps({req}) {
return req.params;
}
</code></pre>
<p>I'm not sure if I have to add this to my server.js:</p>
<pre><code>server.get('/results', (req, res) => {
return app.render(req, res, '/results', req.params)
})
</code></pre>
<p>However, the function getInitialProps throws an error because req is undefined. Long text, short question: how to pass state or params to another page without using GET parameters?</p>
| 0debug
|
how to implement this function : now have `fmapT` and `traverse` :
fmapT ::
Traversable t =>
(a -> b)
-> t a
-> t b
traverse ::
Applicative f =>
(a -> f b)
-> t a
-> f (t b)
how can i implement the function `over` with `traverse` as an argument to `fmapT`:
over ::
((a -> Identity b) -> s -> Identity t)
-> (a -> b)
-> s
-> t
over = error "undefined"
| 0debug
|
Properties in C# advantage : <p>Although I understand the basic concept of properties like providing read, read-write access to private data members, I am still having a hard time understanding how it would be useful over just declaring the member as public. In what scenarios is it useful? and if it is a way to change values of private fields, how is the encapsulation still being enforced?</p>
<p>Kindly explain with an example or link if you can</p>
| 0debug
|
How to prevent client from changing critical HTML inputs? : <p>As you probably know, you can use <code>Inspect element</code> in Chrome to modify the web page you're viewing and possibly mess up with <code>radio</code> values (or similar), which you're NOT meant to change, <code>required</code> inputs and much more.</p>
<p>For instance:</p>
<pre><code><input type='radio' name='example' id='abcd' value='abcd'>
<input type='radio' name='example' id='efgh' value='efgh'>
<input type='text' name='username' id='username' required>
</code></pre>
<p>can be changed to</p>
<pre><code><input type='radio' name='example' id='OTHER_ID' value='OTHER_VALUE'>
<input type='radio' name='example' id='OTHER_ID2' value='OTHER_VALUE2'>
<input type='text' name='username' id='username'>
</code></pre>
<p>How can I prevent this?</p>
| 0debug
|
void armv7m_nvic_acknowledge_irq(void *opaque)
{
NVICState *s = (NVICState *)opaque;
CPUARMState *env = &s->cpu->env;
const int pending = s->vectpending;
const int running = nvic_exec_prio(s);
int pendgroupprio;
VecInfo *vec;
assert(pending > ARMV7M_EXCP_RESET && pending < s->num_irq);
vec = &s->vectors[pending];
assert(vec->enabled);
assert(vec->pending);
pendgroupprio = vec->prio;
if (pendgroupprio > 0) {
pendgroupprio &= nvic_gprio_mask(s);
}
assert(pendgroupprio < running);
trace_nvic_acknowledge_irq(pending, vec->prio);
vec->active = 1;
vec->pending = 0;
env->v7m.exception = s->vectpending;
nvic_irq_update(s);
}
| 1threat
|
int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
{
int i, av_uninit(j);
int current_ref_assigned = 0, err = 0;
Picture *av_uninit(pic);
if ((h->avctx->debug & FF_DEBUG_MMCO) && mmco_count == 0)
av_log(h->avctx, AV_LOG_DEBUG, "no mmco here\n");
for (i = 0; i < mmco_count; i++) {
int av_uninit(structure), av_uninit(frame_num);
if (h->avctx->debug & FF_DEBUG_MMCO)
av_log(h->avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode,
h->mmco[i].short_pic_num, h->mmco[i].long_arg);
if (mmco[i].opcode == MMCO_SHORT2UNUSED ||
mmco[i].opcode == MMCO_SHORT2LONG) {
frame_num = pic_num_extract(h, mmco[i].short_pic_num, &structure);
pic = find_short(h, frame_num, &j);
if (!pic) {
if (mmco[i].opcode != MMCO_SHORT2LONG ||
!h->long_ref[mmco[i].long_arg] ||
h->long_ref[mmco[i].long_arg]->frame_num != frame_num) {
av_log(h->avctx, AV_LOG_ERROR, "mmco: unref short failure\n");
err = AVERROR_INVALIDDATA;
continue;
switch (mmco[i].opcode) {
case MMCO_SHORT2UNUSED:
if (h->avctx->debug & FF_DEBUG_MMCO)
av_log(h->avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n",
h->mmco[i].short_pic_num, h->short_ref_count);
remove_short(h, frame_num, structure ^ PICT_FRAME);
break;
case MMCO_SHORT2LONG:
if (h->long_ref[mmco[i].long_arg] != pic)
remove_long(h, mmco[i].long_arg, 0);
remove_short_at_index(h, j);
h->long_ref[ mmco[i].long_arg ] = pic;
if (h->long_ref[mmco[i].long_arg]) {
h->long_ref[mmco[i].long_arg]->long_ref = 1;
h->long_ref_count++;
break;
case MMCO_LONG2UNUSED:
j = pic_num_extract(h, mmco[i].long_arg, &structure);
pic = h->long_ref[j];
if (pic) {
remove_long(h, j, structure ^ PICT_FRAME);
} else if (h->avctx->debug & FF_DEBUG_MMCO)
av_log(h->avctx, AV_LOG_DEBUG, "mmco: unref long failure\n");
break;
case MMCO_LONG:
if (h->long_ref[mmco[i].long_arg] != h->cur_pic_ptr) {
remove_long(h, mmco[i].long_arg, 0);
h->long_ref[mmco[i].long_arg] = h->cur_pic_ptr;
h->long_ref[mmco[i].long_arg]->long_ref = 1;
h->long_ref_count++;
h->cur_pic_ptr->reference |= h->picture_structure;
current_ref_assigned = 1;
break;
case MMCO_SET_MAX_LONG:
assert(mmco[i].long_arg <= 16);
for (j = mmco[i].long_arg; j < 16; j++) {
remove_long(h, j, 0);
break;
case MMCO_RESET:
while (h->short_ref_count) {
remove_short(h, h->short_ref[0]->frame_num, 0);
for (j = 0; j < 16; j++) {
remove_long(h, j, 0);
h->frame_num = h->cur_pic_ptr->frame_num = 0;
h->mmco_reset = 1;
h->cur_pic_ptr->mmco_reset = 1;
for (j = 0; j < MAX_DELAYED_PIC_COUNT; j++)
h->last_pocs[j] = INT_MIN;
break;
default: assert(0);
if (!current_ref_assigned) {
if (h->short_ref_count && h->short_ref[0] == h->cur_pic_ptr) {
h->cur_pic_ptr->reference = PICT_FRAME;
} else if (h->cur_pic_ptr->long_ref) {
av_log(h->avctx, AV_LOG_ERROR, "illegal short term reference "
"assignment for second field "
"in complementary field pair "
"(first field is long term)\n");
err = AVERROR_INVALIDDATA;
} else {
pic = remove_short(h, h->cur_pic_ptr->frame_num, 0);
if (pic) {
av_log(h->avctx, AV_LOG_ERROR, "illegal short term buffer state detected\n");
err = AVERROR_INVALIDDATA;
if (h->short_ref_count)
memmove(&h->short_ref[1], &h->short_ref[0],
h->short_ref_count * sizeof(Picture*));
h->short_ref[0] = h->cur_pic_ptr;
h->short_ref_count++;
h->cur_pic_ptr->reference |= h->picture_structure;
if (h->long_ref_count + h->short_ref_count > FFMAX(h->sps.ref_frame_count, 1)) {
av_log(h->avctx, AV_LOG_ERROR,
"number of reference frames (%d+%d) exceeds max (%d; probably "
"corrupt input), discarding one\n",
h->long_ref_count, h->short_ref_count, h->sps.ref_frame_count);
err = AVERROR_INVALIDDATA;
if (h->long_ref_count && !h->short_ref_count) {
for (i = 0; i < 16; ++i)
if (h->long_ref[i])
break;
assert(i < 16);
remove_long(h, i, 0);
} else {
pic = h->short_ref[h->short_ref_count - 1];
remove_short(h, pic->frame_num, 0);
print_short_term(h);
print_long_term(h);
if(err >= 0 && h->long_ref_count==0 && h->short_ref_count<=2 && h->pps.ref_count[0]<=1 + (h->picture_structure != PICT_FRAME) && h->cur_pic_ptr->f.pict_type == AV_PICTURE_TYPE_I){
h->cur_pic_ptr->sync |= 1;
if(!h->avctx->has_b_frames)
h->sync = 2;
return (h->avctx->err_recognition & AV_EF_EXPLODE) ? err : 0;
| 1threat
|
when i call the Startactivity(i) the error is shown (see below) my code is Intent i=new Intent(getApplicationContext(),NewRecipe.class); : FATAL EXCEPTION: main
Process: com.example.bullet.recipesearch, PID: 15986
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.bullet.recipesearch/com.example.bullet.recipesearch.MainRecipe$NewRecipe}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1805)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1523)
at android.app.Activity.startActivityForResult(Activity.java:4225)
at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79)
at android.app.Activity.startActivityForResult(Activity.java:4183)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859)
at android.app.Activity.startActivity(Activity.java:4522)
at android.app.Activity.startActivity(Activity.java:4490)
at com.example.bullet.recipesearch.MainRecipe.fetchingfromlist(MainRecipe.java:182)
at com.example.bullet.recipesearch.MainRecipe.access$000(MainRecipe.java:57)
at com.example.bullet.recipesearch.MainRecipe$NewRecipe$1.onResponse(MainRecipe.java:117)
at com.example.bullet.recipesearch.MainRecipe$NewRecipe$1.onResponse(MainRecipe.java:88)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
| 0debug
|
TypeError: first argument must be an iterable of pandas objects, you passed an object of type "DataFrame" : <p>I have a big dataframe and I try to split that and after <code>concat</code> that.
I use</p>
<pre><code>df2 = pd.read_csv('et_users.csv', header=None, names=names2, chunksize=100000)
for chunk in df2:
chunk['ID'] = chunk.ID.map(rep.set_index('member_id')['panel_mm_id'])
df2 = pd.concat(chunk, ignore_index=True)
</code></pre>
<p>But it return an error</p>
<pre><code>TypeError: first argument must be an iterable of pandas objects, you passed an object of type "DataFrame"
</code></pre>
<p>How can I fix that?</p>
| 0debug
|
How to write a while loop into a CSV file : <p>My code looks like:</p>
<pre><code>x=0
while (x<3):
print('purple'),
print('yellow'),
print({x})
x=x+1
</code></pre>
<p>I want it to log this data into a csv file named 'daffodils.csv'.
How do I do this so that the iterations won't write over eachother?</p>
<p>For example, if I ran the program two times, my csv file will look like:</p>
<pre><code>purple yellow 0
purple yellow 1
purple yellow 2
purple yellow 0
purple yellow 1
purple yellow 2
</code></pre>
<p>Thanks</p>
| 0debug
|
static void pxb_pcie_dev_realize(PCIDevice *dev, Error **errp)
{
if (!pci_bus_is_express(dev->bus)) {
error_setg(errp, "pxb-pcie devices cannot reside on a PCI bus");
return;
}
pxb_dev_realize_common(dev, true, errp);
}
| 1threat
|
Why using checkout and reset naming for the file-level operations in git? : <p>After reading <a href="https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting/summary" rel="nofollow noreferrer">this</a> nice article on git Reset, Checkout, and Revert I still don't quite understand the connection between some commands naming and their behaviour. Let's take a look at the table below:</p>
<p><a href="https://i.stack.imgur.com/2r8AX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2r8AX.png" alt="enter image description here"></a></p>
<p>On the commit-level the naming-behaviour correspondences seem fine to me, but on the file-level instead of typing <code>git checkout <some_file></code> I would rather go with <code>git reset <some_file></code> because what we are essentially doing here is resetting.</p>
<p>And in for the unstaging procedure I would expect to have something like <code>git unstage <some_file></code>. Much more understandable and nice.</p>
<p>So, is this weird naming for the file-level <code>checkout</code> and <code>unstage</code> is just a historical legacy or there is some logical reasons behind it?</p>
| 0debug
|
Count two collums from 1 table : [database view][1]
[1]: https://i.stack.imgur.com/CkMM1.png
I got this table (date, indoor_km, outdoor_km,...)
I have found the Sql count to count indoor_km or outdoor_km
But i'm looking for a sql count for the 2 colums from 1 table
| 0debug
|
static int decode_user_data(Mpeg4DecContext *ctx, GetBitContext *gb)
{
MpegEncContext *s = &ctx->m;
char buf[256];
int i;
int e;
int ver = 0, build = 0, ver2 = 0, ver3 = 0;
char last;
for (i = 0; i < 255 && get_bits_count(gb) < gb->size_in_bits; i++) {
if (show_bits(gb, 23) == 0)
break;
buf[i] = get_bits(gb, 8);
}
buf[i] = 0;
e = sscanf(buf, "DivX%dBuild%d%c", &ver, &build, &last);
if (e < 2)
e = sscanf(buf, "DivX%db%d%c", &ver, &build, &last);
if (e >= 2) {
ctx->divx_version = ver;
ctx->divx_build = build;
s->divx_packed = e == 3 && last == 'p';
}
e = sscanf(buf, "FFmpe%*[^b]b%d", &build) + 3;
if (e != 4)
e = sscanf(buf, "FFmpeg v%d.%d.%d / libavcodec build: %d", &ver, &ver2, &ver3, &build);
if (e != 4) {
e = sscanf(buf, "Lavc%d.%d.%d", &ver, &ver2, &ver3) + 1;
if (e > 1) {
if (ver > 0xFF || ver2 > 0xFF || ver3 > 0xFF) {
av_log(s->avctx, AV_LOG_WARNING,
"Unknown Lavc version string encountered, %d.%d.%d; "
"clamping sub-version values to 8-bits.\n",
ver, ver2, ver3);
}
build = ((ver & 0xFF) << 16) + ((ver2 & 0xFF) << 8) + (ver3 & 0xFF);
}
}
if (e != 4) {
if (strcmp(buf, "ffmpeg") == 0)
ctx->lavc_build = 4600;
}
if (e == 4)
ctx->lavc_build = build;
e = sscanf(buf, "XviD%d", &build);
if (e == 1)
ctx->xvid_build = build;
return 0;
}
| 1threat
|
Angular 2 filter/search list : <p>I'm looking for the angular 2 way to do <a href="http://www.w3schools.com/howto/howto_js_filter_lists.asp" rel="noreferrer">this</a>.</p>
<p>I simply have a list of items, and I want to make an input whos job is to filter the list.</p>
<pre><code><md-input placeholder="Item name..." [(ngModel)]="name"></md-input>
<div *ngFor="let item of items">
{{item.name}}
</div>
</code></pre>
<p>What's the actual way of doing this in Angular 2? Does that requires a pipe?</p>
| 0debug
|
C++ Outputting a text file in reverse order : <p>For this program I am writing, I am suppose to be taking in a text file from the command line, reversing the order of everything in the file and then outputting the text into a new text file with "-reverse" attached on to it. The problem I am having is reversing the order of the lines. I've been able to reverse the text but I need help reversing the lines. I've seen suggestions about using vectors but I'm still new to c++ and I believe i'm not suppose to be using vectors just high-level io
For example, filename.txt contains:</p>
<p>abc</p>
<p>edf</p>
<p>dfg</p>
<p>filename-reverse.txt should contain:</p>
<p>gfd</p>
<p>fde</p>
<p>cba</p>
<p>Mine only contains:</p>
<p>cba</p>
<p>fde</p>
<p>gfd</p>
<pre><code>#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
/**
* Reverses the line
*/
void reverseStr(string& x)
{
reverse(x.begin(), x.end());
}
int main(int argc, char *argv[])
{
string filename = argv[1];
string filenameCopy = filename;
string reverse = "-reverse";
string reverseFileName;
string reverseLine;
if(filename.rfind(".txt"))//inserts -reverse into existing file name
{
reverseFileName = filenameCopy.insert(filenameCopy.length() - 4,reverse);
}
string line;
ifstream myfile (filename);
ofstream out(reverseFileName);
if (myfile.is_open())
{
/*
vector<string> lines_in_reverse;
while(getline(myfile,line))
{
lines_in_reverse.insert(lines_in_reverse.begin(), line);
}
*/
while(getline(myfile,line))
{
cout << line << endl;
reverseStr(line);
cout << line << endl;
out << line << endl;
}
myfile.close();
}
else
{
cout << "Unable to open file";
}
return EXIT_SUCCESS;
}//main
</code></pre>
| 0debug
|
document.write('<script src="evil.js"></script>');
| 1threat
|
Is there any Data Compression Algorithms which is not based on Pattern? : <p>Most of the Data Compression Algorithms are based on 'Pattern'. But I'm looking for a Data Compression Algorithm which is not based on 'Pattern'</p>
| 0debug
|
Replace all vowels with 1,2,3... java : <p>Given a String str, return a string with all vowels replaced with numbers using the following rules.</p>
<p>Upper cased vowels should be replaced with increasing odd numbers starting at 1. For example, the first upper case vowel would be replaced with a 1, the second with a 3, the third with a 5, and so on.</p>
<p>Lower cased vowels should be replaced with increasing even numbers starting at 2. For example, the first lower case vowel would be replaced with a 2, the second with a 4, the third with a 6, an so on.</p>
<p>There may be case where the number to use as a replacement is more than one digit. In that case the vowel should be replaced with both digits.</p>
<p>Examples:</p>
<p>replaceAllVowels( "Hello" ) => "H2ll4"</p>
<p>replaceAllVowels( "HELLo" ) => "H1ll2"</p>
<p>replaceAllVowles( "hello there this is a really long string") => "h2ll4 th6r8 th10s 12s 14 r1618lly l20ng str22ng"</p>
<p>I'm lost with this one. Help would be greatly appreciated.</p>
| 0debug
|
get data from datalist to another page using session showing error input string is not in correct format : if(Session["proid"].ToString()!=null && Session["name"].ToString()!=null && Session["desc"].ToString()!=null && Session["price"].ToString()!=null)
{
int id = Convert.ToInt32(Session["proid"].ToString());
string proname = Session["name"].ToString();
string prodesc = Session["desc"].ToString();
string proprice=Session["price"].ToString();
}
| 0debug
|
Get second td of tr using jquery : <p>I'm trying to get td values of tr.. but unfortunately it's not working.. may be there is something wrong</p>
<p>My html looks like </p>
<pre><code><tr class="dname">
<td>abc</td>
<td>value here</td>
</tr>
</code></pre>
<p>My jquery code is</p>
<pre><code> jQuery(".dname").find("tr td:eq(1)").val();
</code></pre>
<p>What's wrong in this ?</p>
| 0debug
|
Count by ID if value is lower than and set the value 1 : <p>I have a problem.
My table is <strong>tableXYZ</strong>
I have a row <strong>a</strong> where i set the year.
I have a row <strong>b</strong> where i need to set value 1 if the year from row <strong>a</strong> is lower than 2019 and 0 if is > 2019.</p>
<p>After all i need to make a count from row <strong>b</strong> only the 1 values as total.</p>
<p>How can i do that, because i tried a lot of examples but doesn't work.</p>
| 0debug
|
static int exif_decode_tag(void *logctx, GetByteContext *gbytes, int le,
int depth, AVDictionary **metadata)
{
int ret, cur_pos;
unsigned id, count;
enum TiffTypes type;
if (depth > 2) {
return 0;
}
ff_tread_tag(gbytes, le, &id, &type, &count, &cur_pos);
if (!bytestream2_tell(gbytes)) {
bytestream2_seek(gbytes, cur_pos, SEEK_SET);
return 0;
}
ret = ff_tis_ifd(id);
if (ret) {
ret = avpriv_exif_decode_ifd(logctx, gbytes, le, depth + 1, metadata);
} else {
const char *name = exif_get_tag_name(id);
char *use_name = (char*) name;
if (!use_name) {
use_name = av_malloc(7);
if (!use_name) {
return AVERROR(ENOMEM);
}
snprintf(use_name, 7, "0x%04X", id);
}
ret = exif_add_metadata(logctx, count, type, use_name, NULL,
gbytes, le, metadata);
if (!name) {
av_freep(&use_name);
}
}
bytestream2_seek(gbytes, cur_pos, SEEK_SET);
return ret;
}
| 1threat
|
static void qmp_tmp105_set_temperature(const char *id, int value)
{
QDict *response;
response = qmp("{ 'execute': 'qom-set', 'arguments': { 'path': '%s', "
"'property': 'temperature', 'value': %d } }", id, value);
g_assert(qdict_haskey(response, "return"));
QDECREF(response);
}
| 1threat
|
I am passing a vector to a function. Program is compiling but when I am running it, it is showing segmentation fault(core dump). : <p>I want to sort a text file using merge sort. I am using vector to process the text file. This program is compiling correctly but when I am running it, it is showing segmentation fault(core dumped) error. I tried many thing but all in vain. Can anyone help me in this. Thanks in advance.</p>
<pre><code>vector<string> sV;
void merge(vector<string> & sV, int l, int m, int r)
{
int i, j, k;
int n1 = m - l + 1;
int n2 = r - m;
vector<string> sV1;
vector<string> sV2;
for (i = 0; i < n1; i++)
sV1[i] = sV[l+1];
for (j = 0; j < n2; j++)
sV2[j] = sV[m + 1 + j];
i = 0;
j = 0;
k = l;
while (i < n1 && j < n2)
{
if (sV1[i] <= sV2[j])
{
sV[k] = sV1[i];
i++;
}
else
{
sV[k] = sV2[j];
j++;
}
k++;
}
while (i < n1)
{
sV[k] = sV1[i];
i++;
k++;
}
while (j < n2)
{
sV[k] = sV2[j];
j++;
k++;
}
}
void mergeSort(vector<string> & sV, int l, int r)
{
if (l < r)
{
int m = l+(r-l)/2;
mergeSort(sV, l, m);
mergeSort(sV, m+1, r);
merge(sV, l, m, r);
}
}
int main()
{
string word;
char ch, ch1;
ifstream tin("a1.txt");
ofstream outp("out.txt");
if(!tin.is_open())
cout << "Unable to open file :) \n";
while(tin >> word)
sV.push_back(word);
mergeSort(sV, 0, sV.size() - 1);
for (size_t i = 0; i < sV.size(); i++) {
outp<< sV[i] << " ";
}
return 0;
}
</code></pre>
| 0debug
|
static const OptionDef *find_option(const OptionDef *po, const char *name)
{
const char *p = strchr(name, ':');
int len = p ? p - name : strlen(name);
while (po->name != NULL) {
if (!strncmp(name, po->name, len) && strlen(po->name) == len)
break;
po++;
}
return po;
}
| 1threat
|
how it not working add class using ng-repeat? : it may be click photo and not add class inside the ng-repeat using angularjs
<div class="resultitem" ng-repeat="a in vm.gettrustalbum">
<div class="result">
</div>
</div>
add class "demo" inside the ng-repeat?
output
<div class="resultitem" ng-repeat="a in vm.gettrustalbum">
<div class="result demo">
</div>
</div>
| 0debug
|
What does "this" refer to for each constructors? : <p>Please, explain what " : this()" refer to.Cant I use "base" instead of it.
When I move cursor on "this" it displays another Constructor .
Or when I replace it with "base" it gives this error: "object doesnt contain a constructor that takes 1 argument". </p>
<blockquote>
<pre><code>class Employee
{
private string name;
private string surname;
private DateTime birthday;
private double height;
private double salary;
public string Name { get { return name; } set { if (name != value) { name = value; } } }
public string Surname { get { return surname; } set { if (surname != value) { surname = value; } } }
public DateTime Birthday { get { return birthday; } set { if (birthday != value) { birthday = value; } } }
public double Height { get { return height; } set { if (height != value) { height = value; } } }
public double Salary { get { return salary; } set { if (salary != value) { salary = value; } } }
public string Full { get { return name + " " + surname; } }
public Employee() {
name = "Mina";
surname = "Babayeva";
birthday = DateTime.Now.AddYears(-19);
height=175;
salary = 3500;
}
public Employee(string name, string surname, DateTime birthday, double height, double salary) : this( name, surname)
{
this.birthday = birthday;
this.height = height;
this.salary = salary;
}
public Employee(string name) : this()
{
this.name = name;
}
public Employee(string name, string surname) : this(name)
{
this.surname = surname;
}
public void Print()
{
Console.WriteLine("Name is {0}\nSurname is {1}\nHeight is {2}\nBirthday is {3}\nSalary is {4}",
this.Name, this.Surname, this.Height, this.Birthday.ToString("dd/MM/yyyy"), this.Salary);
}
////////////////////////////////
Employee a = new Employee();
Employee b = new Employee("Adil", "Babayev");
Employee c = new Employee("Zumrud","Babayeva",DateTime.Now.AddYears(-52),167,1000000);
Employee e = new Employee("Hanna");
a.Print();
Console.WriteLine();
b.Print();
Console.WriteLine();
c.Print();
Console.WriteLine();
e.Print();
Console.WriteLine();
</code></pre>
</blockquote>
| 0debug
|
Ruby: I've seached for ways to remove trailing commas, but have found that : So i'm pretty new to Ruby and programming in general. I'm trying to send data (a list of passwords in a hashlist and how often they appear in the list) in an array to a .txt file in JSON format, which i will then use to make charts.
Here's the problem: the charts require that the JSON data be in a specific format, like so:
`[["patches90",35],
["Champions17",32],
["scotty1977",29],
["Kiddos08",25],
["holidays2016",21],
["scott26me",17],
["People1123@",13],
["Software0)",9],
["Artistic104",5],
["bank123",2]]`
with the way i'm currently printing the data, it comes out with an extra trailing comma that i'd like to get rid of. here's what it looks like:
`[["patches90",35],
["Champions17",32],
["scotty1977",29],
["Kiddos08",25],
["holidays2016",21],
["scott26me",17],
["People1123@",13],
["Software0)",9],
["Artistic104",5],
["bank123",2],`
As you can see, i have an extra comma and a missing closing bracket at the end. I've tried multiple loops and conditions and googled around to find answers with no luck. here's the code i'm using, any help would be appreciated:
f = open('/var/www/html/hashtopussy/top10.txt', 'w')
f.print "["
@words.sort{|a,b| (a[1]<=>b[1]) * -1}[0, @cap_at].each { |elem|
percentage = (elem[1].to_f / @total_words_processed) * 100
ret_str << "#{elem[0]} = #{elem[1].to_s} (#{percentage.round(2).to_s}%)\n"
#my code goes here
f.print "[#{elem[0].to_json},#{elem[1].to_json}]"
if (elem != elem.last)
f.print ",\n"
else f.print "]"
end
#and ends here
}
#f.print "]\n"
f.close
| 0debug
|
Using React within a dynamically loaded es module : <p>I have been loading a native ES Module which can be simplified to <code>src/test.tsx</code>:</p>
<pre><code>export default class Test {
constructor() {
console.log('loaded');
}
}
</code></pre>
<p>I can load this in my browser and initialize it great, a la:</p>
<pre><code>import('http://127.0.0.1:8085/').then(m => {
const instance = new m.default();
});
</code></pre>
<p>However.. if I want to add any external dependency, in this case React, I can't seem to figure out how to target es6 and also bundle React, with tsc. So my dist file contains <code>import React from 'react';</code> for which the browser has no idea how to resolve, and produces:</p>
<p><code>
(index):1 Uncaught (in promise) TypeError: Failed to resolve module specifier "react". Relative references must start with either "/", "./", or "../".
</code></p>
<p>My tsconfig looks like:</p>
<pre><code>{
"compilerOptions": {
"baseUrl": ".",
"rootDir": "src",
"module": "es6",
"target": "es2015",
"lib": ["es6", "dom"],
"declaration": true,
"jsx": "react",
"outDir": "dist",
"strict": true,
"noImplicitAny": false,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"skipLibCheck": true
},
"include": ["./src/**/*"]
}
</code></pre>
<p>Running node v9.5.0, typescript v2.9.2</p>
<p>I have also attempted to use webpack to bundle everything but cannot figure out how to produce a dynamically importable module that way</p>
| 0debug
|
Lopp trough key value duplicates in sub array : I'm trying to loop trough a simple array of arrays, then if I find duplicates of `'id'` value in a sub array, loop trough them.
This can be obvious for you but I can't find a simple way to do this. Any ideas?
$records = array(
array(
'id' => 2135,
),
array(
'id' => 2135,
),
array(
'id' => 5342,
),
array(
'id' => 5623,
),
array(
'id' => 5342,
)
);
| 0debug
|
static void handler_audit(Monitor *mon, const mon_cmd_t *cmd, int ret)
{
if (ret && !monitor_has_error(mon)) {
if (monitor_ctrl_mode(mon)) {
qerror_report(QERR_UNDEFINED_ERROR);
}
MON_DEBUG("command '%s' returned failure but did not pass an error\n",
cmd->name);
}
#ifdef CONFIG_DEBUG_MONITOR
if (!ret && monitor_has_error(mon)) {
MON_DEBUG("command '%s' returned success but passed an error\n",
cmd->name);
}
if (mon_print_count_get(mon) > 0 && strcmp(cmd->name, "info") != 0) {
MON_DEBUG("command '%s' called print functions %d time(s)\n",
cmd->name, mon_print_count_get(mon));
}
#endif
}
| 1threat
|
import re
text = 'Python Exercises'
def replace_spaces(text):
text =text.replace (" ", "_")
return (text)
text =text.replace ("_", " ")
return (text)
| 0debug
|
Sorting an array of objects in javascript by key value does not work : <p>I am trying to sort and array of objects in javascript that represent interfaces of devices. I have found some code here that seems to work for some cases and does not for others.</p>
<p>So here is my code:</p>
<pre><code>compareByName = function(a, b) {
console.log("sort by name");
const nameA = a.name.toUpperCase();
const nameB = b.name.toUpperCase();
let comparison = 0;
if (nameA > nameB) {
comparison = 0;
} else if (nameA < nameB) {
comparison = -1;
}
return comparison;
}
vm.interfaceData.sort(compareByName);
</code></pre>
<p>It works when i have objects like this:</p>
<pre><code>[
{
"name": "eth4",
},
{
"name": "eth3",
},
{
"name": "eth2",
},
{
"name": "eth2",
}
]
eth0
eth1
eth2
eth3
</code></pre>
<p>But when i have names like this it seems not to work anymore:</p>
<pre><code>[
{
"name": "GigabitEthernet0/8",
},
{
"name": "SBB",
},
{
"name": "SR-2",
},
{
"name": "GigabitEthernet0/7",
},
{
"name": "SR-1",
},
{
"name": "GigabitEthernet0/5",
},
{
"name": "GigabitEthernet0/4",
}
]
GigabitEthernet0/8
SBB
SR-2
GigabitEthernet0/7
SR-1
GigabitEthernet0/5
GigabitEthernet0/4
</code></pre>
| 0debug
|
def frequency_Of_Largest(n,arr):
mn = arr[0]
freq = 1
for i in range(1,n):
if (arr[i] >mn):
mn = arr[i]
freq = 1
elif (arr[i] == mn):
freq += 1
return freq
| 0debug
|
i have try this code but it it not working.though all the field are null but it still take action.code is given below : if(((f_NameText.getText())!=null)&&((l_NameText.getText())!=null)&&((u_NameText.getText())!=null)&&((newMembersPassword.getPassword())!=null))
{newMembersButton.addActionListener(new NewJoinButtonHandler());}
| 0debug
|
react, differences between component create with extend class and simple const = function : <p>In react tutorial:</p>
<p><a href="https://egghead.io/lessons/javascript-redux-react-todo-list-example-filtering-todos" rel="noreferrer">https://egghead.io/lessons/javascript-redux-react-todo-list-example-filtering-todos</a></p>
<p>there is main component create with extends:</p>
<pre><code>class TodoApp extends Component {
render() {
const visibleTodos = getVisibleTodos(
this.props.todos,
this.props.visibilityFilter
);
.
. // Input and Button stuff
.
</code></pre>
<p>and another components just create like a const that hold a function:</p>
<pre><code>const FilterLink = ({
filter,
children
}) => {
return (
<a href='#'
onClick={e => {
e.preventDefault();
store.dispatch({
type: 'SET_VISIBILITY_FILTER',
filter
});
}}
>
{children}
</a>
)
}
</code></pre>
<p>the difference i see, first created with class use a render function, and the another a return function to send back the template.</p>
<p>What are the differences? I've heard components in the future only will be allowed with extend Component ?</p>
| 0debug
|
Pass object as prop on Vue : <p>How do you go on passing objects as props on vue? I would imagine this would be a simple task but apparently not.</p>
<p>I have the following code on a .vue file: </p>
<p>`</p>
<pre><code><template>
<div id="scatter"></div>
</template>
<script>
export default {
props: {
data: {
type: Object,
default: () => ({})
}
},
mounted () {
console.log(this.data)
}
}
</script>
</code></pre>
<p>`</p>
<p>On html I try to pass the <code>data</code> props as follows : </p>
<p><code><component :data="{x:1}"></component></code></p>
<p>When I try lo log it into the console the result is only an empty observer object.</p>
| 0debug
|
Concise way of updating a nested value inside a record in Elm (0.18) : <p>I am looking for a concise way of updating a nested value inside a record in Elm (0.18).</p>
<p>Given the following example:</p>
<pre><code>person = { name = "Steven", address = { country = "Spain", city = "Barcelona" } }
</code></pre>
<p>I can update person.name to "Steve" using the following expression:</p>
<pre><code>{ person | name = "Steve" }
</code></pre>
<p>However, I am looking for a way to update a nested value. For instance, I would like to update person.address.city to "Madrid". I tried the following:</p>
<pre><code>{ person | address.city = "Madrid" }
{ person | address = { address | city = "Madrid" } }
{ person | address = { person.address | city = "Madrid" } }
</code></pre>
<p>The compiler rejects all these variations. The shortest valid option I see is:</p>
<pre><code>let personAddress = person.address in { person | address = { personAddress | city = "Madrid" } }
</code></pre>
<p>This seems to be a bit too much code just to update a nested value, Do you know if there is a better/shorter way of achieving that?</p>
| 0debug
|
static int set_dirty_tracking(void)
{
BlkMigDevState *bmds;
int ret;
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
bmds->dirty_bitmap = bdrv_create_dirty_bitmap(bmds->bs, BLOCK_SIZE,
NULL);
if (!bmds->dirty_bitmap) {
ret = -errno;
goto fail;
}
}
return 0;
fail:
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
if (bmds->dirty_bitmap) {
bdrv_release_dirty_bitmap(bmds->bs, bmds->dirty_bitmap);
}
}
return ret;
}
| 1threat
|
av_cold void ff_vp8dsp_init(VP8DSPContext *dsp)
{
dsp->vp8_luma_dc_wht = vp8_luma_dc_wht_c;
dsp->vp8_luma_dc_wht_dc = vp8_luma_dc_wht_dc_c;
dsp->vp8_idct_add = vp8_idct_add_c;
dsp->vp8_idct_dc_add = vp8_idct_dc_add_c;
dsp->vp8_idct_dc_add4y = vp8_idct_dc_add4y_c;
dsp->vp8_idct_dc_add4uv = vp8_idct_dc_add4uv_c;
dsp->vp8_v_loop_filter16y = vp8_v_loop_filter16_c;
dsp->vp8_h_loop_filter16y = vp8_h_loop_filter16_c;
dsp->vp8_v_loop_filter8uv = vp8_v_loop_filter8uv_c;
dsp->vp8_h_loop_filter8uv = vp8_h_loop_filter8uv_c;
dsp->vp8_v_loop_filter16y_inner = vp8_v_loop_filter16_inner_c;
dsp->vp8_h_loop_filter16y_inner = vp8_h_loop_filter16_inner_c;
dsp->vp8_v_loop_filter8uv_inner = vp8_v_loop_filter8uv_inner_c;
dsp->vp8_h_loop_filter8uv_inner = vp8_h_loop_filter8uv_inner_c;
dsp->vp8_v_loop_filter_simple = vp8_v_loop_filter_simple_c;
dsp->vp8_h_loop_filter_simple = vp8_h_loop_filter_simple_c;
VP8_MC_FUNC(0, 16);
VP8_MC_FUNC(1, 8);
VP8_MC_FUNC(2, 4);
VP8_BILINEAR_MC_FUNC(0, 16);
VP8_BILINEAR_MC_FUNC(1, 8);
VP8_BILINEAR_MC_FUNC(2, 4);
if (ARCH_ARM)
ff_vp8dsp_init_arm(dsp);
if (ARCH_PPC)
ff_vp8dsp_init_ppc(dsp);
if (ARCH_X86)
ff_vp8dsp_init_x86(dsp);
}
| 1threat
|
adding unsigned int to unsigned int* : <p>My development environment consists of the g++ cross compiler for ARM OMAP Sitata. I discovered an unusual nuance of simple pointer arithmetic, when adding an unsigned int to an unsigned int*, as follows:</p>
<pre><code>unsigned int* dst_base_addr;
unsigned int* dst_addr;
unsigned int dst_offset;
</code></pre>
<p>Simply attempting to add an (unsigned int) to an (unsigned int*)</p>
<pre><code>dst_addr = dst_base_addr + dst_offset;
</code></pre>
<p>The above is not interpreted as one might naively think but actually produces the following equivalent result </p>
<pre><code>dst_addr = (unsigned int*)((unsigned int)dst_base_addr + (dst_offset << 2));
</code></pre>
<p>The remedy is of course to do proper type conversion as follows</p>
<pre><code>dst_addr = (unsigned int*)((unsigned int)dst_base_addr + dst_offset);
</code></pre>
<p>Question: Why is proper type conversion even necessary in this situation?</p>
| 0debug
|
static void qxl_init_ramsize(PCIQXLDevice *qxl)
{
if (qxl->vgamem_size_mb < 8) {
qxl->vgamem_size_mb = 8;
qxl->vgamem_size = qxl->vgamem_size_mb * 1024 * 1024;
if (qxl->ram_size_mb != -1) {
qxl->vga.vram_size = qxl->ram_size_mb * 1024 * 1024;
if (qxl->vga.vram_size < qxl->vgamem_size * 2) {
qxl->vga.vram_size = qxl->vgamem_size * 2;
if (qxl->vram32_size_mb != -1) {
qxl->vram32_size = qxl->vram32_size_mb * 1024 * 1024;
if (qxl->vram32_size < 4096) {
qxl->vram32_size = 4096;
if (qxl->vram_size_mb != -1) {
qxl->vram_size = qxl->vram_size_mb * 1024 * 1024;
if (qxl->vram_size < qxl->vram32_size) {
qxl->vram_size = qxl->vram32_size;
if (qxl->revision == 1) {
qxl->vram32_size = 4096;
qxl->vram_size = 4096;
qxl->vgamem_size = msb_mask(qxl->vgamem_size * 2 - 1);
qxl->vga.vram_size = msb_mask(qxl->vga.vram_size * 2 - 1);
qxl->vram32_size = msb_mask(qxl->vram32_size * 2 - 1);
qxl->vram_size = msb_mask(qxl->vram_size * 2 - 1);
| 1threat
|
static int decode_stream_header(NUTContext *nut){
AVFormatContext *s= nut->avf;
ByteIOContext *bc = &s->pb;
StreamContext *stc;
int class, nom, denom, stream_id;
uint64_t tmp, end;
AVStream *st;
end= get_packetheader(nut, bc, 1);
end += url_ftell(bc) - 4;
GET_V(stream_id, tmp < s->nb_streams && !nut->stream[tmp].time_base.num);
stc= &nut->stream[stream_id];
st = s->streams[stream_id];
if (!st)
return AVERROR_NOMEM;
class = get_v(bc);
tmp = get_fourcc(bc);
st->codec->codec_tag= tmp;
switch(class)
{
case 0:
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_id = codec_get_bmp_id(tmp);
if (st->codec->codec_id == CODEC_ID_NONE)
av_log(s, AV_LOG_ERROR, "Unknown codec?!\n");
break;
case 1:
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->codec_id = codec_get_wav_id(tmp);
if (st->codec->codec_id == CODEC_ID_NONE)
av_log(s, AV_LOG_ERROR, "Unknown codec?!\n");
break;
case 2:
case 3:
st->codec->codec_type = CODEC_TYPE_DATA;
break;
default:
av_log(s, AV_LOG_ERROR, "Unknown stream class (%d)\n", class);
return -1;
}
GET_V(stc->time_base_id , tmp < nut->time_base_count);
GET_V(stc->msb_pts_shift , tmp < 16);
stc->max_pts_distance= get_v(bc);
GET_V(stc->decode_delay , tmp < 1000);
st->codec->has_b_frames= stc->decode_delay;
get_v(bc);
GET_V(st->codec->extradata_size, tmp < (1<<30));
if(st->codec->extradata_size){
st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
get_buffer(bc, st->codec->extradata, st->codec->extradata_size);
}
if (st->codec->codec_type == CODEC_TYPE_VIDEO){
GET_V(st->codec->width , tmp > 0)
GET_V(st->codec->height, tmp > 0)
st->codec->sample_aspect_ratio.num= get_v(bc);
st->codec->sample_aspect_ratio.den= get_v(bc);
if((!st->codec->sample_aspect_ratio.num) != (!st->codec->sample_aspect_ratio.den)){
av_log(s, AV_LOG_ERROR, "invalid aspect ratio\n");
return -1;
}
get_v(bc);
}else if (st->codec->codec_type == CODEC_TYPE_AUDIO){
GET_V(st->codec->sample_rate , tmp > 0)
tmp= get_v(bc);
if(tmp > st->codec->sample_rate){
av_log(s, AV_LOG_ERROR, "bleh, libnut muxed this ;)\n");
st->codec->sample_rate= tmp;
}
GET_V(st->codec->channels, tmp > 0)
}
if(skip_reserved(bc, end) || check_checksum(bc)){
av_log(s, AV_LOG_ERROR, "Stream header %d checksum mismatch\n", stream_id);
return -1;
}
stc->time_base= nut->time_base[stc->time_base_id];
av_set_pts_info(s->streams[stream_id], 63, stc->time_base.num, stc->time_base.den);
return 0;
}
| 1threat
|
perl search and replace with Tie : my search and replace is not working neither it is throwing any error,
i tried to modify the code and provide the i/p where it is working, not sure where the error occurs
while compling the code does't provide an error
> #!/usr/bin/perl -w
> use strict;
> use warnings;
> use diagnostics;
> use Tie::File;
> use v5.10;
> use File::Compare;
> my $VAR; $VAR=$ARGV[0];chomp $VAR;
> my $nam=qq~file_name~;/*FILENAME
> my @lines;
> our $s1="var1";/*STINGS
> our $s2="var2";/*STRINGS
> if ('$s1' ne '$s2')/*comparing the 2 stings
> {
> replace();
> }
> sub replace {/* for replacing the stings in file
> chomp $s1;chomp $s2;
> tie @lines, 'Tie::File', "$nam" or die " can't open the file\n";
> foreach (@lines)
> {
> s/$s2/$s1/g;/*replacing the strings
> }
> untie @lines;
> };
| 0debug
|
Pybind11 or Boost.Python or neither- : <p>I'm curious what the most flexible, most efficient, and most seamless method is for getting C++ and Python to talk to each other.
The contenders seem to be Pybind11, Boost.Python, and neither (simply writing functions and wrappers as below).</p>
<pre><code>using namespace boost::algorithm;
static PyObject* strtest(PyObject* self, PyObject* args)
{
std::string s = "Boost C++ Libraries";
to_upper(s);
PyObject * python_val = Py_BuildValue("s", s.c_str());
return python_val;
}
PyMODINIT_FUNC initmath_demo(void)
{
static PyMethodDef methods[] = {
"Test boost libraries" },
{ NULL, NULL, 0, NULL }
};
PyObject *m = Py_InitModule("math_demo", methods);
}
</code></pre>
| 0debug
|
Add class to HTML attribute using jQuery : <p>I'd like to add the class <code>btn</code> to my hyperlink after the page loads.</p>
<p>Here is my current script:</p>
<p><strong>HTML</strong></p>
<pre><code><span id="callnow" class="mhMobile callnow"><a href="tel:01234567890">01234567890</a></span>
</code></pre>
<p><strong>JS</strong> </p>
<pre><code>(function(text){
setTimeout(function(){
document.querySelector(".callnow a").addClass("btn");
}, 1000);
})()
</code></pre>
<p><strong>DEMO:</strong> <a href="https://jsfiddle.net/wnfmqsLf/" rel="nofollow noreferrer">https://jsfiddle.net/wnfmqsLf/</a></p>
| 0debug
|
static void d3d11va_frames_uninit(AVHWFramesContext *ctx)
{
AVD3D11VAFramesContext *frames_hwctx = ctx->hwctx;
D3D11VAFramesContext *s = ctx->internal->priv;
if (frames_hwctx->texture)
ID3D11Texture2D_Release(frames_hwctx->texture);
if (s->staging_texture)
ID3D11Texture2D_Release(s->staging_texture);
}
| 1threat
|
Object reference is required for non-static field. List<> : <p>I'm a little confused about this fairly typical error. My code is as below. I am trying to add items to a list.</p>
<p>The compiler is saying I need an object reference for non-static field, but I can't make the class static because I am not returning a value...?</p>
<pre><code> public class ApplicantData
{
public string Salutation { set; get; }
public string FirstName { set; get; }
public string LastName { set; get; }
}
public class ApplicantList : List<ApplicantData>
{
public void Add(string salutation, string firstName, string lastName)
{
var data = new ApplicantData
{
Salutation = salutation,
FirstName = firstName,
LastName = lastName
};
this.Add(data);
}
}
</code></pre>
<p>The above is called via:</p>
<pre><code>List ApplicantsDetailsData = ApplicantList.Add(salutation, firstname, lastname);
</code></pre>
<p>I'm sure the answer must be obvious... (!)</p>
| 0debug
|
static void spapr_cpu_core_register_types(void)
{
const SPAPRCoreInfo *info = spapr_cores;
type_register_static(&spapr_cpu_core_type_info);
while (info->name) {
spapr_cpu_core_register(info);
info++;
}
}
| 1threat
|
What wrong with BST : <p>I want to print all the key in BST. Why it printing only "the tree is empty" It just printing the tree is empty 2 times.
my coding first method is about creating a node to be a leaf and second is creating the leaf into the tree and thrid is printing the tree by inorder.
If my coding is too bad can you fix it? </p>
<pre class="lang-cpp prettyprint-override"><code>#include <iostream>
class BST
{
private:
struct Node
{
int key;
Node *left;
Node *right;
};
Node* root;
Node* createLeafPrivate(int key,Node* ptr);
void addLeafPrivate(int key,Node* ptr);
void printInoderPrivate(Node* ptr);
public:
BST():root(nullptr){}
Node* createLeaf(int key);
void addLeaf(int key);
void printInorder();
};
BST::Node* BST::createLeaf(int key)
{
Node* newNode=new Node();
newNode->key=key;
newNode->left=nullptr;
newNode->right=nullptr;
return newNode;
}
void BST::addLeaf(int key)
{
addLeafPrivate(key,root);
}
void BST::addLeafPrivate(int key,Node* Ptr)
{
if(root == nullptr)
root=createLeaf(key);
else if (key < Ptr->key)
{
if(Ptr->left != nullptr)
addLeafPrivate(key,Ptr->left);
else
Ptr->left=createLeaf(key);
}
else if (key > Ptr->key)
{
if(Ptr->right != nullptr)
addLeafPrivate(key,Ptr->right);
else
Ptr->right=createLeaf(key);
}
else
{
std::cout<<"The key "<<key<<"has already been added to the tree\n";
}
}
void BST::printInorder()
{
printInoderPrivate(root);
}
void BST::printInoderPrivate(Node* Ptr)
{
if(root != nullptr)
{
if(Ptr->left != nullptr)
printInoderPrivate(Ptr->left);
std::cout<<Ptr->key<<" ";
if(Ptr->right != nullptr)
printInoderPrivate(Ptr->right);
}
else
{
std::cout<<"The tree is empty\n";
}
}
int main()
{
BST myTree;
std::cout<<"----Printing the empty tree----\n";
myTree.printInorder();
for(int i=16;i<=0;i--)
myTree.addLeaf(i);
std::cout<<"----Printing the data tree-----\n";
myTree.printInorder();
std::cout<<std::endl;
return 0;
}
</code></pre>
| 0debug
|
Pascal help plss (:() : This is the code:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
program pi18;
var a,b,c,P:real;
begin
read(a,b,c);
if(a+b<c) or (b+c<a) or (a+c<b) then
writeln('Nu exista asa triunghi')
else
begin
P:=a+b+c;
if(a=b) and (a=c) then write('Triunghiul este echil')
else
if(sqr(a) = sqr(b) + sqr(c)) or (sqr(b) = sqr(a) + sqr(c)) or (sqr(c) = sqr(a) + sqr(b)) then
write('Triunghiul este dreptunghic'); readln();
else
write('Triunghiul este arbitrar'); readln();
end;
writeln('Perimetrul este: ', P);
end.
<!-- end snippet -->
And I have this error: Syntax error, ";" expected but "ELSE" found
This code is for:
- says the perimeter of a triangle.
- compare if the a,b,c are numbers for some types of triangles.
| 0debug
|
a tag without line-decoration in Bootstrap 4 : <p>I would like to have a link that looks just like plain text except for the cursor by using as few css as possible.</p>
<p>The problem: <code><a></code> has a blue color (that darkens when hovered) and also has underline on hover. I want it to look like plain text (black without underline).</p>
<p>By using the Bootstrap class "text-dark" I managed to get rid of the blue color.
But how do I get rid of the underline (text-decoration) <strong>without writing css</strong>?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.no-underline:hover {
text-decoration: none;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<span>Standard text</sapn>
<hr>
<a href="#">Standard a tag. Different colors and underline on hover</a>
<hr>
<a href="#" class="text-dark">a tag with text-dark class. Note underline on hover</a>
<hr>
<a href="#" class="text-dark no-underline">a tag with text-dark class and css to disable underline on hover</a></code></pre>
</div>
</div>
</p>
| 0debug
|
void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove){
int i;
s->dts= s->pts= AV_NOPTS_VALUE;
s->offset= 0;
for(i = 0; i < AV_PARSER_PTS_NB; i++) {
if ( s->next_frame_offset + off >= s->cur_frame_offset[i]
&&(s-> frame_offset < s->cur_frame_offset[i] || !s->frame_offset)
&& s->cur_frame_end[i]){
s->dts= s->cur_frame_dts[i];
s->pts= s->cur_frame_pts[i];
s->offset = s->next_frame_offset - s->cur_frame_offset[i];
if(remove)
s->cur_frame_offset[i]= INT64_MAX;
}
}
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.