problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
ASP.NET Core 2.0 Could not load file or assembly System.ServiceModel : <p>I am working on porting an "ASP.NET Core Web Application" that was compiling under the .NET Framework 4.6.1 (i.e. full framework) over to compiling against .NET Core 2.0. I have some dependencies which still require the full framework but with .NET 2.0 my understanding is that I can now reference full framework assemblies from within a .NET Core 2.0 compiled application.</p>
<p>When I attempt to run the project, I get the following error:</p>
<p><em>Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.</em></p>
<p>I looked through all the NuGet packages and projects I'm referencing and none of them reference System.ServiceModel.Web but I'm not convinced that's the same as the System.ServiceModel. When I open the projectname.deps.json file located in the bin folder, I see a reference to System.ServiceModel.Web but no reference to System.ServiceModel under the "Microsoft.NETCore.App/2.0.0" section which contains the following line:
"ref/netcoreapp2.0/System.ServiceModel.Web.dll": {},</p>
<p>I also poked around in the "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.0" folder and I see a System.ServiceModel.Web.dll.</p>
<p>I'm not doing any WCF work and as I stated I've looked at all the dependencies of the libraries I'm using and none of them appear to be referencing System.ServiceModel.</p>
<p>Has anyone else run into this issue? I appreciate any and all insights anyone might have.</p>
| 0debug
|
What is the difference between C.UTF-8 and en_US.UTF-8 locales? : <p>I'm migrating a python application from an ubuntu server with locale en_US.UTF-8 to a new debian server which comes with C.UTF-8 already set by default. I'm trying to understand if there would be any impact but couldn't find good resources on the internet to understand the difference between both. </p>
| 0debug
|
What is the recommended way to update project.pbxproj file for the app while upgrading react-native version : <p>I am using <a href="https://github.com/ncuillery/rn-diff" rel="noreferrer">rn-diff</a> to upgrade <code>react-native</code> version for my app. Sometimes, the project.pbxproj is updated to contain some new dependencies or updates to the existing dependencies. What is the recommended way to update this file? I don't think that I can just copy and paste the changes shown in the diff because it may create some duplicates or create some conflicting entries in the file.</p>
<p>For example, below link contains changes made to the <code>project.pbxproj</code> file while changing from version 0.54.4 to 0.55.0. There are a lot changes to the project.pbxproj file and I am not sure if I am supposed to copy them over or I should rather be updating some dependencies myself in Xcode.</p>
<p><a href="https://github.com/ncuillery/rn-diff/compare/rn-0.54.4...rn-0.55.0" rel="noreferrer">https://github.com/ncuillery/rn-diff/compare/rn-0.54.4...rn-0.55.0</a></p>
| 0debug
|
static void dec10_reg_scc(DisasContext *dc)
{
int cond = dc->dst;
LOG_DIS("s%s $r%u\n", cc_name(cond), dc->src);
if (cond != CC_A)
{
int l1;
gen_tst_cc (dc, cpu_R[dc->src], cond);
l1 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_R[dc->src], 0, l1);
tcg_gen_movi_tl(cpu_R[dc->src], 1);
gen_set_label(l1);
} else {
tcg_gen_movi_tl(cpu_R[dc->src], 1);
}
cris_cc_mask(dc, 0);
}
| 1threat
|
static int get_riff(AVFormatContext *s, AVIOContext *pb)
{
AVIContext *avi = s->priv_data;
char header[8];
int i;
avio_read(pb, header, 4);
avi->riff_end = avio_rl32(pb);
avi->riff_end += avio_tell(pb);
avio_read(pb, header + 4, 4);
for (i = 0; avi_headers[i][0]; i++)
if (!memcmp(header, avi_headers[i], 8))
break;
if (!avi_headers[i][0])
return AVERROR_INVALIDDATA;
if (header[7] == 0x19)
av_log(s, AV_LOG_INFO,
"This file has been generated by a totally broken muxer.\n");
return 0;
}
| 1threat
|
Python min value in nested lists : <pre><code>a_list = [['2', 0.5],
['2', 0.5],
['2', 1.0],
['1', 2.0],
['1', 3.5],
['1', 2.5]]
b_list = {'1', '2'}
</code></pre>
<p>What is the most pythonic way of calculating the min value from a_list for each value in b_list?</p>
| 0debug
|
Uniqueness with a combination of numbers regardless of sequence : <p>I am working on a feature that requires me to arrive at a unique string. There are 2 attributes for every person in the data model - Company Id and Person Id. The combination of the Co and Person Id will always be unique. When 1 person initiates a conversation with another, I need to create a unique string to identify that conversation.</p>
<p>So, if a Person A (say Co:100, Id:100) starts a conversation with Person B (say Co:200, Id:200), the unique string should be the same as if Person B started a conversation with Person A.</p>
<p>I need to write this logic in JS and C#.</p>
| 0debug
|
How do I make a program know where it is? : <p>I want to add a picture to my program but you need the directory for the picture for that (by my understanding). How do I make the program know where it self is and find the picture that I want to add. Note I can't set the directory to where it is on my computer as I want the program to be usable on other computers.</p>
| 0debug
|
How do I call activity method from Adaptor class : I have three Class
mainActivity.java
public class mainactivity extends AppCompatActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.abc);
}
public void firstDialog()
{
//Do something
//call next method
secondDialog()
}
public void secondDialog()
{
//Do something
}
}
Next is another class which is calling the adaptor class
secondclass.java
public class secondclass extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.xyz);
//calling and set adaptor
adapter=new Myadaptopr(this,result);
recyclerlist.setAdapter(adapter);
}
//Now the Adaptor class
public class Myadaptopr extends RecyclerView.Adapter<Myadaptopr.ViewHolder> {
@Override
public void onBindViewHolder(final MedicineAdaptor.ViewHolder holder, int position) {
//In this function I need to call firstDialog() Method How Do I proceed.
}
}
**My Question is:**
How do I call the methods of mainactivity.java class file.
I have tried solution:
but didn't work because mainactivity class don't call and set the adaptor.
((mainactivity)context).firstDialog();
| 0debug
|
Do importable libraries exist for common mathematical operations (e.g. min, max and mean) in C or C++? : <p>I'm a Python programmer starting to learn C / C++. One issue I'm finding, however, is that the C languages seem to lack a lot of "basic" mathematical operations. For example, even finding the min, max or mean of an array.</p>
<p>Consider finding the maximum value of an array as an example. I appreciate this is an "easy" task and I can write a simple loop that goes through the whole array and compares each element to the current maximum-found value, replacing this maximum with the current element if it exceeds it. However, it's annoying in each project I'm working on to have to define such commonly used functions.</p>
<p>Therefore, I wonder if there are widely used / accepted C & C++ libraries for such mathematical operations (i.e. similar to numpy for Python), which would save time and limit the chance of me introducing bugs by re-writing commonly used algorithms?</p>
<p>More generally, would this be considered bad practice in C/C++ programs - do such programmers simply expect to see everything coded up from first principles?</p>
<p>Thanks</p>
| 0debug
|
START_TEST(qdict_iterapi_test)
{
int count;
const QDictEntry *ent;
fail_unless(qdict_first(tests_dict) == NULL);
qdict_put(tests_dict, "key1", qint_from_int(1));
qdict_put(tests_dict, "key2", qint_from_int(2));
qdict_put(tests_dict, "key3", qint_from_int(3));
count = 0;
for (ent = qdict_first(tests_dict); ent; ent = qdict_next(tests_dict, ent)){
fail_unless(qdict_haskey(tests_dict, qdict_entry_key(ent)) == 1);
count++;
}
fail_unless(count == qdict_size(tests_dict));
count = 0;
for (ent = qdict_first(tests_dict); ent; ent = qdict_next(tests_dict, ent)){
fail_unless(qdict_haskey(tests_dict, qdict_entry_key(ent)) == 1);
count++;
}
fail_unless(count == qdict_size(tests_dict));
}
| 1threat
|
static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx,
AVCodecContext *dec_ctx)
{
AVPacket enc_pkt;
AVFrame *in_frame, *out_frame;
uint8_t *raw_in = NULL, *raw_out = NULL;
int in_offset = 0, out_offset = 0;
int frame_data_size = 0;
int result = 0;
int got_output = 0;
int i = 0;
in_frame = av_frame_alloc();
if (!in_frame) {
av_log(NULL, AV_LOG_ERROR, "Can't allocate input frame\n");
return AVERROR(ENOMEM);
}
in_frame->nb_samples = enc_ctx->frame_size;
in_frame->format = enc_ctx->sample_fmt;
in_frame->channel_layout = enc_ctx->channel_layout;
if (av_frame_get_buffer(in_frame, 32) != 0) {
av_log(NULL, AV_LOG_ERROR, "Can't allocate a buffer for input frame\n");
return AVERROR(ENOMEM);
}
out_frame = av_frame_alloc();
if (!out_frame) {
av_log(NULL, AV_LOG_ERROR, "Can't allocate output frame\n");
return AVERROR(ENOMEM);
}
raw_in = av_malloc(in_frame->linesize[0] * NUMBER_OF_FRAMES);
if (!raw_in) {
av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for raw_in\n");
return AVERROR(ENOMEM);
}
raw_out = av_malloc(in_frame->linesize[0] * NUMBER_OF_FRAMES);
if (!raw_out) {
av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for raw_out\n");
return AVERROR(ENOMEM);
}
for (i = 0; i < NUMBER_OF_FRAMES; i++) {
av_init_packet(&enc_pkt);
enc_pkt.data = NULL;
enc_pkt.size = 0;
generate_raw_frame((uint16_t*)(in_frame->data[0]), i, enc_ctx->sample_rate,
enc_ctx->channels, enc_ctx->frame_size);
memcpy(raw_in + in_offset, in_frame->data[0], in_frame->linesize[0]);
in_offset += in_frame->linesize[0];
result = avcodec_encode_audio2(enc_ctx, &enc_pkt, in_frame, &got_output);
if (result < 0) {
av_log(NULL, AV_LOG_ERROR, "Error encoding audio frame\n");
return result;
}
if (got_output) {
result = avcodec_decode_audio4(dec_ctx, out_frame, &got_output, &enc_pkt);
if (result < 0) {
av_log(NULL, AV_LOG_ERROR, "Error decoding audio packet\n");
return result;
}
if (got_output) {
if (result != enc_pkt.size) {
av_log(NULL, AV_LOG_INFO, "Decoder consumed only part of a packet, it is allowed to do so -- need to update this test\n");
return AVERROR_UNKNOWN;
}
if (in_frame->nb_samples != out_frame->nb_samples) {
av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different number of samples\n");
return AVERROR_UNKNOWN;
}
if (in_frame->channel_layout != out_frame->channel_layout) {
av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different channel layout\n");
return AVERROR_UNKNOWN;
}
if (in_frame->format != out_frame->format) {
av_log(NULL, AV_LOG_ERROR, "Error frames before and after decoding has different sample format\n");
return AVERROR_UNKNOWN;
}
memcpy(raw_out + out_offset, out_frame->data[0], out_frame->linesize[0]);
out_offset += out_frame->linesize[0];
}
}
av_free_packet(&enc_pkt);
}
if (memcmp(raw_in, raw_out, frame_data_size * NUMBER_OF_FRAMES) != 0) {
av_log(NULL, AV_LOG_ERROR, "Output differs\n");
return 1;
}
av_log(NULL, AV_LOG_INFO, "OK\n");
av_freep(&raw_in);
av_freep(&raw_out);
av_frame_free(&in_frame);
av_frame_free(&out_frame);
return 0;
}
| 1threat
|
Recursion why is return necessary? : Recursion why is "return" necessary?
DO I NEED "RETURN X" STATEMENT HERE?? BECAUSE Result is the same thing whether with or without.
package RecursionTry1;
public class RecursionTry {
public int run(int x)
{
if(x<5)
{
System.out.println(x);
run(x+1);
}
System.out.println(x);
return x; //<---- DO I NEED "RETURN X" STATEMENT HERE?? BECAUSE Result is the same thing whether with or without.
}
public static void main(String args[])
{
RecursionTry A=new RecursionTry();
A.run(1);
}
}
| 0debug
|
my html form doesn't work with my php code : if i make insert_teacher('bla bla','bla bla','dqsd') in php file , but when i want to make it with html form it doesn't show me anything, and nothing inserted in my db
====
if i make insert_teacher('bla bla','bla bla','dqsd') in php file , but when i want to make it with html form it doesn't show me anything, and nothing inserted in my db
===
if i make insert_teacher('bla bla','bla bla','dqsd') in php file , but when i want to make it with html form it doesn't show me anything, and nothing inserted in my db
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<?php
include_once("resources/functions.php");
echo 1;
if(isset($_POST['submit']))
{
$name=$_POST['name'];
$exp=$_POST['exp'];
$sub=$_POST['sub'];
$insert=insert_teacher($name,$exp,'dqsd');// return 1 or 0
echo $insert;
}
?>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<header>
<h1>City Gallery</h1>
</header>
<ul class="sidenav">
<li><a href="index.php">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a class="active" href="setup_teachers.php">Teachers Section</a></li>
</ul>
<div class="content">
<h3 class="warning"><?php if(isset($b)) echo $b; ?></h3>
<h3>Adding teachers information</h3>
<div>
<form action="" method="POST" >
<label for="fname">FullName</label>
<input type="text" id="fname" name="name">
<label for="lname">Experience</label>
<input type="text" id="lname" name="exp">
<label for="subject">Subject</label>
<select id="country" name="sub">
<option value="physics">physique</option>
<option value="maths">mathematique</option>
<option value="english">Anglais</option>
</select>
<input type="submit">
</form>
</div>
</div>
</body>
</html>
<!-- end snippet -->
| 0debug
|
static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width)
{
#ifdef HAVE_MMX
asm volatile(
"mov %4, %%"REG_a" \n\t"
"movq "MANGLE(w1111)", %%mm5 \n\t"
"movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t"
"pxor %%mm7, %%mm7 \n\t"
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_b" \n\t"
"add %%"REG_b", %%"REG_b" \n\t"
ASMALIGN16
"1: \n\t"
PREFETCH" 64(%0, %%"REG_b") \n\t"
PREFETCH" 64(%1, %%"REG_b") \n\t"
#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
"movq (%0, %%"REG_b"), %%mm0 \n\t"
"movq (%1, %%"REG_b"), %%mm1 \n\t"
"movq 6(%0, %%"REG_b"), %%mm2 \n\t"
"movq 6(%1, %%"REG_b"), %%mm3 \n\t"
PAVGB(%%mm1, %%mm0)
PAVGB(%%mm3, %%mm2)
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $24, %%mm0 \n\t"
"psrlq $24, %%mm2 \n\t"
PAVGB(%%mm1, %%mm0)
PAVGB(%%mm3, %%mm2)
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
#else
"movd (%0, %%"REG_b"), %%mm0 \n\t"
"movd (%1, %%"REG_b"), %%mm1 \n\t"
"movd 3(%0, %%"REG_b"), %%mm2 \n\t"
"movd 3(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm0 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm2, %%mm0 \n\t"
"movd 6(%0, %%"REG_b"), %%mm4 \n\t"
"movd 6(%1, %%"REG_b"), %%mm1 \n\t"
"movd 9(%0, %%"REG_b"), %%mm2 \n\t"
"movd 9(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm4 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm4, %%mm2 \n\t"
"psrlw $2, %%mm0 \n\t"
"psrlw $2, %%mm2 \n\t"
#endif
"movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t"
"movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t"
"pmaddwd %%mm0, %%mm1 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm2, %%mm0 \n\t"
"packssdw %%mm3, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm0 \n\t"
"pmaddwd %%mm5, %%mm1 \n\t"
"packssdw %%mm1, %%mm0 \n\t"
"psraw $7, %%mm0 \n\t"
#if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
"movq 12(%0, %%"REG_b"), %%mm4 \n\t"
"movq 12(%1, %%"REG_b"), %%mm1 \n\t"
"movq 18(%0, %%"REG_b"), %%mm2 \n\t"
"movq 18(%1, %%"REG_b"), %%mm3 \n\t"
PAVGB(%%mm1, %%mm4)
PAVGB(%%mm3, %%mm2)
"movq %%mm4, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $24, %%mm4 \n\t"
"psrlq $24, %%mm2 \n\t"
PAVGB(%%mm1, %%mm4)
PAVGB(%%mm3, %%mm2)
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
#else
"movd 12(%0, %%"REG_b"), %%mm4 \n\t"
"movd 12(%1, %%"REG_b"), %%mm1 \n\t"
"movd 15(%0, %%"REG_b"), %%mm2 \n\t"
"movd 15(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm4 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm2, %%mm4 \n\t"
"movd 18(%0, %%"REG_b"), %%mm5 \n\t"
"movd 18(%1, %%"REG_b"), %%mm1 \n\t"
"movd 21(%0, %%"REG_b"), %%mm2 \n\t"
"movd 21(%1, %%"REG_b"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm5 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm5 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm5, %%mm2 \n\t"
"movq "MANGLE(w1111)", %%mm5 \n\t"
"psrlw $2, %%mm4 \n\t"
"psrlw $2, %%mm2 \n\t"
#endif
"movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t"
"movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t"
"pmaddwd %%mm4, %%mm1 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm4 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm4 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm2, %%mm4 \n\t"
"packssdw %%mm3, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm4 \n\t"
"pmaddwd %%mm5, %%mm1 \n\t"
"add $24, %%"REG_b" \n\t"
"packssdw %%mm1, %%mm4 \n\t"
"psraw $7, %%mm4 \n\t"
"movq %%mm0, %%mm1 \n\t"
"punpckldq %%mm4, %%mm0 \n\t"
"punpckhdq %%mm4, %%mm1 \n\t"
"packsswb %%mm1, %%mm0 \n\t"
"paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t"
"movd %%mm0, (%2, %%"REG_a") \n\t"
"punpckhdq %%mm0, %%mm0 \n\t"
"movd %%mm0, (%3, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: : "r" (src1+width*6), "r" (src2+width*6), "r" (dstU+width), "r" (dstV+width), "g" (-width)
: "%"REG_a, "%"REG_b
);
#else
int i;
for(i=0; i<width; i++)
{
int b= src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3];
int g= src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4];
int r= src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5];
dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128;
dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128;
}
#endif
}
| 1threat
|
Open file on IntelliJ from iTerm 2 : <p>I have output in my iTerm like:</p>
<pre><code> File project/path/path/file.py:56:54 extra text information
</code></pre>
<p>How I can open this file in IntelliJ with a single click?</p>
| 0debug
|
How can I read the Ids on of Div elemnt for LI tag : I want the Ids of all the li elemnt under div text.
<div id="editSortable">
<ul class="sortable-list ui-sortable">
<li id="id1">Test 1</li>
<li id="id2">Test 2</li>
<li id="id3">Test 3</li>
</ul>
</div>
I need output as id1, id2, id3 as a string.
Please suggest.
| 0debug
|
Pandas - find first non-null value in column : <p>If I have a series that has either NULL or some non-null value. How can I find the 1st row where the value is not NULL so I can report back the datatype to the user. If the value is non-null all values are the same datatype in that series.</p>
<p>Thanks</p>
| 0debug
|
static Visitor *validate_test_init_internal(TestInputVisitorData *data,
const char *json_string,
va_list *ap)
{
Visitor *v;
data->obj = qobject_from_jsonv(json_string, ap);
g_assert(data->obj);
data->qiv = qmp_input_visitor_new_strict(data->obj);
g_assert(data->qiv);
v = qmp_input_get_visitor(data->qiv);
g_assert(v);
return v;
}
| 1threat
|
WPF Programmatically Enable TextBox Scrolling/Panning for Tablets : <p>I am working with a WPF application that will be used on Windows tablets. The issue I am having is that I cannot scroll through a large multi-line TextBox on a tablet by pressing and dragging the content. However, it still scrolls on a desktop with a mouse wheel.</p>
<p>This question (<a href="https://stackoverflow.com/questions/26781833/enable-swipe-scrolling-on-textbox-control-in-wpf-scrollviewer">Enable swipe scrolling on Textbox control in WPF Scrollviewer</a>) seems to answer the same problem I am having, but I need to do it programmatically. This is what I am doing to set the panning mode of the TextBox:</p>
<pre><code>txtLongText.SetValue(ScrollViewer.PanningModeProperty, PanningMode.None);
</code></pre>
<p>Which I can tell is working because the click & drag text selection is now disabled, but the content still does not scroll. I am also setting the panning mode of the outer ScrollViewer as such:</p>
<pre><code>popupScrollView.PanningMode = PanningMode.Both;
</code></pre>
<p>The <code>popupScrollView</code> object is then being set as the content inside a Popup.</p>
<p>The only thing I can think of is if there is somewhere else higher up that I need to be setting the panning mode? Any help would be appreciated. Thanks.</p>
| 0debug
|
Flutter & Firebase: Compression before upload image : <p>I want to send photo selected by user in my app to Firebase Storage. I have a simple class with property <code>_imageFile</code> which is set like this:</p>
<pre><code>File _imageFile;
_getImage() async {
var fileName = await ImagePicker.pickImage();
setState(() {
_imageFile = fileName;
});
}
</code></pre>
<p>after that I send photo like with this code:</p>
<pre><code>final String rand1 = "${new Random().nextInt(10000)}";
final String rand2 = "${new Random().nextInt(10000)}";
final String rand3 = "${new Random().nextInt(10000)}";
final StorageReference ref = FirebaseStorage.instance.ref().child('${rand1}_${rand2}_${rand3}.jpg');
final StorageUploadTask uploadTask = ref.put(_imageFile);
final Uri downloadUrl = (await uploadTask.future).downloadUrl;
print(downloadUrl);
</code></pre>
<p>The problem is that the photos are often very large. Is there any method in Flutter/Dart to compress and resize photo before upload? I am ok with loss of quality.</p>
| 0debug
|
static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
int i;
int64_t creation_time;
int version = avio_r8(pb);
avio_rb24(pb);
if (version == 1) {
creation_time = avio_rb64(pb);
avio_rb64(pb);
} else {
creation_time = avio_rb32(pb);
avio_rb32(pb);
}
mov_metadata_creation_time(&c->fc->metadata, creation_time);
c->time_scale = avio_rb32(pb);
if (c->time_scale <= 0) {
av_log(c->fc, AV_LOG_ERROR, "Invalid mvhd time scale %d\n", c->time_scale);
return AVERROR_INVALIDDATA;
}
av_log(c->fc, AV_LOG_TRACE, "time scale = %i\n", c->time_scale);
c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb);
if (c->time_scale > 0 && !c->trex_data)
c->fc->duration = av_rescale(c->duration, AV_TIME_BASE, c->time_scale);
avio_rb32(pb);
avio_rb16(pb);
avio_skip(pb, 10);
for (i = 0; i < 3; i++) {
c->movie_display_matrix[i][0] = avio_rb32(pb);
c->movie_display_matrix[i][1] = avio_rb32(pb);
c->movie_display_matrix[i][2] = avio_rb32(pb);
}
avio_rb32(pb);
avio_rb32(pb);
avio_rb32(pb);
avio_rb32(pb);
avio_rb32(pb);
avio_rb32(pb);
avio_rb32(pb);
return 0;
}
| 1threat
|
How to set unselected Text Color for TabLayout.Tab - Android : <p>How do you set text-color for a tab that's not selected? I know you can set the text-color for the TabLayout by doing: <strong>setTabTextColors</strong></p>
| 0debug
|
Given a string of letters, how can I count the occurrences of every letter? : <p>Given a string of letters, I'm looking to create an object containing key value pairs with the letter as the key and the number of occurrences within the string as the value. </p>
<p>So given "aabccc", the function should return:
{ a: 2, b: 1, c: 3 }</p>
<p>What would be a good way to count the letters? Ideally adhering to functional programming paradigm and utilizing ES6 functionality if it's applicable. Until now I've only worked with C++ and OO so I'm working through exercises using tools and techniques outside of my comfort zone. I'm very new to all the new features of ES6 and functional programming so I'm hoping to develop the correct mindset for them. </p>
<p>Any insights would be greatly appreciated. Thank you.</p>
| 0debug
|
c# Login form with User Authentication with sql database : I am new to SQL and C#. I am working on a login form that checks if the user is an admin or a basic user. In my SQL I created a table that stores username, password, and role (admin or basic user). The saved data are the following:
For admin: username = admin, password = admin, role = admin
For basic user: username = user, password = user, role = user
If the user enters username and password "admin" it should be directed to the admin page else it would be user page. This is my code.
string query = "SELECT * from tbl_login WHERE Username = @username and password = @password";
con.Open();
SqlCommand sqlcmd = new SqlCommand(query, con);
sqlcmd.Parameters.AddWithValue("@username", tbusername.Text);
sqlcmd.Parameters.AddWithValue("@password", tbpswlog.Text);
DataTable dtbl = new DataTable();
SqlDataAdapter sqlsda = new SqlDataAdapter(sqlcmd);
sqlsda.Fill(dtbl);
con.Close();
if (dtbl.Rows.Count == 1)
{
this.Hide();
if (tbusername.Equals("admin"))
{
MessageBox.Show("You are logged in as an Admin");
AdminHome fr1 = new AdminHome();
fr1.Show();
this.Hide();
}
else
{
MessageBox.Show("You are logged in as a User");
UserHome fr2 = new UserHome();
fr2.Show();
this.Hide();
}
}
else
{
MessageBox.Show("Incorrect username or password");
}
}
I know this code lacks and wrong. Thank you
| 0debug
|
Function sum of square python : Im trying to code the sum of squares in python and i'm pretty new to this
this is what i have for now,
n=int(input("n="))
def sumsquare(n):
sum=0
i=0
while(n<=i):
sum= sum + i**2
Basically what i'm trying to do is to make the user choose a number, and based on that number I want to calculate the sum of squares , and return "The sum of square is ___"
Thanks in advance for your help !
| 0debug
|
static int decode_ext_header(Wmv2Context *w){
MpegEncContext * const s= &w->s;
GetBitContext gb;
int fps;
int code;
if(s->avctx->extradata_size<4) return -1;
init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8);
fps = get_bits(&gb, 5);
s->bit_rate = get_bits(&gb, 11)*1024;
w->mspel_bit = get_bits1(&gb);
w->flag3 = get_bits1(&gb);
w->abt_flag = get_bits1(&gb);
w->j_type_bit = get_bits1(&gb);
w->top_left_mv_flag= get_bits1(&gb);
w->per_mb_rl_bit = get_bits1(&gb);
code = get_bits(&gb, 3);
if(code==0) return -1;
s->slice_height = s->mb_height / code;
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
av_log(s->avctx, AV_LOG_DEBUG, "fps:%d, br:%d, qpbit:%d, abt_flag:%d, j_type_bit:%d, tl_mv_flag:%d, mbrl_bit:%d, code:%d, flag3:%d, slices:%d\n",
fps, s->bit_rate, w->mspel_bit, w->abt_flag, w->j_type_bit, w->top_left_mv_flag, w->per_mb_rl_bit, code, w->flag3,
code);
}
return 0;
}
| 1threat
|
static int skip_check(MpegEncContext *s, Picture *p, Picture *ref)
{
int x, y, plane;
int score = 0;
int64_t score64 = 0;
for (plane = 0; plane < 3; plane++) {
const int stride = p->f.linesize[plane];
const int bw = plane ? 1 : 2;
for (y = 0; y < s->mb_height * bw; y++) {
for (x = 0; x < s->mb_width * bw; x++) {
int off = p->shared ? 0 : 16;
uint8_t *dptr = p->f.data[plane] + 8 * (x + y * stride) + off;
uint8_t *rptr = ref->f.data[plane] + 8 * (x + y * stride);
int v = s->dsp.frame_skip_cmp[1](s, dptr, rptr, stride, 8);
switch (s->avctx->frame_skip_exp) {
case 0: score = FFMAX(score, v); break;
case 1: score += FFABS(v); break;
case 2: score += v * v; break;
case 3: score64 += FFABS(v * v * (int64_t)v); break;
case 4: score64 += v * v * (int64_t)(v * v); break;
}
}
}
}
if (score)
score64 = score;
if (score64 < s->avctx->frame_skip_threshold)
return 1;
if (score64 < ((s->avctx->frame_skip_factor * (int64_t)s->lambda) >> 8))
return 1;
return 0;
}
| 1threat
|
static void dec_sr(DisasContext *dc)
{
if (dc->format == OP_FMT_RI) {
LOG_DIS("sri r%d, r%d, %d\n", dc->r1, dc->r0, dc->imm5);
} else {
LOG_DIS("sr r%d, r%d, r%d\n", dc->r2, dc->r0, dc->r1);
}
if (dc->format == OP_FMT_RI) {
if (!(dc->features & LM32_FEATURE_SHIFT) && (dc->imm5 != 1)) {
qemu_log_mask(LOG_GUEST_ERROR,
"hardware shifter is not available\n");
t_gen_illegal_insn(dc);
return;
}
tcg_gen_sari_tl(cpu_R[dc->r1], cpu_R[dc->r0], dc->imm5);
} else {
int l1 = gen_new_label();
int l2 = gen_new_label();
TCGv t0 = tcg_temp_local_new();
tcg_gen_andi_tl(t0, cpu_R[dc->r1], 0x1f);
if (!(dc->features & LM32_FEATURE_SHIFT)) {
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 1, l1);
t_gen_illegal_insn(dc);
tcg_gen_br(l2);
}
gen_set_label(l1);
tcg_gen_sar_tl(cpu_R[dc->r2], cpu_R[dc->r0], t0);
gen_set_label(l2);
tcg_temp_free(t0);
}
}
| 1threat
|
Java DateFormat for UTC : <p>I have a DateFormat like</p>
<pre><code>DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
</code></pre>
<p>I have a date like this:</p>
<pre><code>2017-02-23T11:00:04.072625
</code></pre>
<p>This "date" is a UTC date (Z is null). This parses fine. However, it seems to be interpreted as the timezone of the machine. So, my machine is EST, this ends up as </p>
<pre><code>2017-02-23T11:00:04.072625-0500
</code></pre>
<p>Which is wrong. I can explicitly set the timezone with like</p>
<pre><code>format.setTimeZone(TimeZone.getTimeZone("UTC"));
</code></pre>
<p>But if the time came in a different zone in the future, that would not be right either.</p>
<p>If I add a "Z" or "z" to the SimpleDateFormat string, this fails to parse.</p>
<p>Any ideas on how to handle this correctly?</p>
| 0debug
|
static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
const char *language,
kbd_layout_t * k)
{
FILE *f;
char * filename;
char line[1024];
int len;
filename = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);
if (!k)
k = g_malloc0(sizeof(kbd_layout_t));
if (!(filename && (f = fopen(filename, "r")))) {
fprintf(stderr,
"Could not read keymap file: '%s'\n", language);
return NULL;
}
g_free(filename);
for(;;) {
if (fgets(line, 1024, f) == NULL)
break;
len = strlen(line);
if (len > 0 && line[len - 1] == '\n')
line[len - 1] = '\0';
if (line[0] == '#')
continue;
if (!strncmp(line, "map ", 4))
continue;
if (!strncmp(line, "include ", 8)) {
parse_keyboard_layout(table, line + 8, k);
} else {
char *end_of_keysym = line;
while (*end_of_keysym != 0 && *end_of_keysym != ' ')
end_of_keysym++;
if (*end_of_keysym) {
int keysym;
*end_of_keysym = 0;
keysym = get_keysym(table, line);
if (keysym == 0) {
} else {
const char *rest = end_of_keysym + 1;
char *rest2;
int keycode = strtol(rest, &rest2, 0);
if (rest && strstr(rest, "numlock")) {
add_to_key_range(&k->keypad_range, keycode);
add_to_key_range(&k->numlock_range, keysym);
}
if (rest && strstr(rest, "shift"))
keycode |= SCANCODE_SHIFT;
if (rest && strstr(rest, "altgr"))
keycode |= SCANCODE_ALTGR;
if (rest && strstr(rest, "ctrl"))
keycode |= SCANCODE_CTRL;
add_keysym(line, keysym, keycode, k);
if (rest && strstr(rest, "addupper")) {
char *c;
for (c = line; *c; c++)
*c = qemu_toupper(*c);
keysym = get_keysym(table, line);
if (keysym)
add_keysym(line, keysym, keycode | SCANCODE_SHIFT, k);
}
}
}
}
}
fclose(f);
return k;
}
| 1threat
|
static int vp3_decode_init(AVCodecContext *avctx)
{
Vp3DecodeContext *s = avctx->priv_data;
int i;
s->avctx = avctx;
s->width = avctx->width;
s->height = avctx->height;
avctx->pix_fmt = PIX_FMT_YUV420P;
avctx->has_b_frames = 0;
dsputil_init(&s->dsp, avctx);
s->quality_index = -1;
s->superblock_width = (s->width + 31) / 32;
s->superblock_height = (s->height + 31) / 32;
s->superblock_count = s->superblock_width * s->superblock_height * 3 / 2;
s->u_superblock_start = s->superblock_width * s->superblock_height;
s->v_superblock_start = s->superblock_width * s->superblock_height * 5 / 4;
s->superblock_coding = av_malloc(s->superblock_count);
s->macroblock_width = (s->width + 15) / 16;
s->macroblock_height = (s->height + 15) / 16;
s->macroblock_count = s->macroblock_width * s->macroblock_height;
s->fragment_width = s->width / FRAGMENT_PIXELS;
s->fragment_height = s->height / FRAGMENT_PIXELS;
s->fragment_count = s->fragment_width * s->fragment_height * 3 / 2;
s->u_fragment_start = s->fragment_width * s->fragment_height;
s->v_fragment_start = s->fragment_width * s->fragment_height * 5 / 4;
debug_init(" width: %d x %d\n", s->width, s->height);
debug_init(" superblocks: %d x %d, %d total\n",
s->superblock_width, s->superblock_height, s->superblock_count);
debug_init(" macroblocks: %d x %d, %d total\n",
s->macroblock_width, s->macroblock_height, s->macroblock_count);
debug_init(" %d fragments, %d x %d, u starts @ %d, v starts @ %d\n",
s->fragment_count,
s->fragment_width,
s->fragment_height,
s->u_fragment_start,
s->v_fragment_start);
s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment));
s->coded_fragment_list = av_malloc(s->fragment_count * sizeof(int));
s->pixel_addresses_inited = 0;
for (i = 0; i < 16; i++) {
init_vlc(&s->dc_vlc[i], 5, 32,
&dc_bias[i][0][1], 4, 2,
&dc_bias[i][0][0], 4, 2);
init_vlc(&s->ac_vlc_1[i], 5, 32,
&ac_bias_0[i][0][1], 4, 2,
&ac_bias_0[i][0][0], 4, 2);
init_vlc(&s->ac_vlc_2[i], 5, 32,
&ac_bias_1[i][0][1], 4, 2,
&ac_bias_1[i][0][0], 4, 2);
init_vlc(&s->ac_vlc_3[i], 5, 32,
&ac_bias_2[i][0][1], 4, 2,
&ac_bias_2[i][0][0], 4, 2);
init_vlc(&s->ac_vlc_4[i], 5, 32,
&ac_bias_3[i][0][1], 4, 2,
&ac_bias_3[i][0][0], 4, 2);
}
for (i = 0; i < 64; i++)
quant_index[dequant_index[i]] = i;
s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int));
s->superblock_macroblocks = av_malloc(s->superblock_count * 4 * sizeof(int));
s->macroblock_fragments = av_malloc(s->macroblock_count * 6 * sizeof(int));
s->macroblock_coded = av_malloc(s->macroblock_count + 1);
init_block_mapping(s);
for (i = 0; i < 3; i++) {
s->current_frame.data[i] = NULL;
s->last_frame.data[i] = NULL;
s->golden_frame.data[i] = NULL;
}
return 0;
}
| 1threat
|
static int url_alloc_for_protocol(URLContext **puc, struct URLProtocol *up,
const char *filename, int flags,
const AVIOInterruptCB *int_cb)
{
URLContext *uc;
int err;
#if CONFIG_NETWORK
if (up->flags & URL_PROTOCOL_FLAG_NETWORK && !ff_network_init())
return AVERROR(EIO);
#endif
if ((flags & AVIO_FLAG_READ) && !up->url_read) {
av_log(NULL, AV_LOG_ERROR,
"Impossible to open the '%s' protocol for reading\n", up->name);
return AVERROR(EIO);
}
if ((flags & AVIO_FLAG_WRITE) && !up->url_write) {
av_log(NULL, AV_LOG_ERROR,
"Impossible to open the '%s' protocol for writing\n", up->name);
return AVERROR(EIO);
}
uc = av_mallocz(sizeof(URLContext) + strlen(filename) + 1);
if (!uc) {
err = AVERROR(ENOMEM);
goto fail;
}
uc->av_class = &ffurl_context_class;
uc->filename = (char *)&uc[1];
strcpy(uc->filename, filename);
uc->prot = up;
uc->flags = flags;
uc->is_streamed = 0;
uc->max_packet_size = 0;
if (up->priv_data_size) {
uc->priv_data = av_mallocz(up->priv_data_size);
if (!uc->priv_data) {
err = AVERROR(ENOMEM);
goto fail;
}
if (up->priv_data_class) {
int proto_len= strlen(up->name);
char *start = strchr(uc->filename, ',');
*(const AVClass **)uc->priv_data = up->priv_data_class;
av_opt_set_defaults(uc->priv_data);
if(!strncmp(up->name, uc->filename, proto_len) && uc->filename + proto_len == start){
int ret= 0;
char *p= start;
char sep= *++p;
char *key, *val;
p++;
while(ret >= 0 && (key= strchr(p, sep)) && p<key && (val = strchr(key+1, sep))){
*val= *key= 0;
ret= av_opt_set(uc->priv_data, p, key+1, 0);
if (ret == AVERROR_OPTION_NOT_FOUND)
av_log(uc, AV_LOG_ERROR, "Key '%s' not found.\n", p);
*val= *key= sep;
p= val+1;
}
if(ret<0 || p!=key){
av_log(uc, AV_LOG_ERROR, "Error parsing options string %s\n", start);
av_freep(&uc->priv_data);
av_freep(&uc);
err = AVERROR(EINVAL);
goto fail;
}
memmove(start, key+1, strlen(key));
}
}
}
if (int_cb)
uc->interrupt_callback = *int_cb;
*puc = uc;
return 0;
fail:
*puc = NULL;
if (uc)
av_freep(&uc->priv_data);
av_freep(&uc);
#if CONFIG_NETWORK
if (up->flags & URL_PROTOCOL_FLAG_NETWORK)
ff_network_close();
#endif
return err;
}
| 1threat
|
int bdrv_open_backing_file(BlockDriverState *bs)
{
char backing_filename[PATH_MAX];
int back_flags, ret;
BlockDriver *back_drv = NULL;
if (bs->backing_hd != NULL) {
return 0;
}
bs->open_flags &= ~BDRV_O_NO_BACKING;
if (bs->backing_file[0] == '\0') {
return 0;
}
bs->backing_hd = bdrv_new("");
bdrv_get_full_backing_filename(bs, backing_filename,
sizeof(backing_filename));
if (bs->backing_format[0] != '\0') {
back_drv = bdrv_find_format(bs->backing_format);
}
back_flags = bs->open_flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT);
ret = bdrv_open(bs->backing_hd, backing_filename, NULL,
back_flags, back_drv);
if (ret < 0) {
bdrv_delete(bs->backing_hd);
bs->backing_hd = NULL;
bs->open_flags |= BDRV_O_NO_BACKING;
return ret;
}
return 0;
}
| 1threat
|
Get status bar height dynamically from XML : <p>I need to optimize my Android app to look good on phones with a notch, like the Essential Phone.</p>
<p>This phones have different status bar heights than the standard 25dp value, so you can't hardcode that value.</p>
<p>The Android P developer preview released yesterday includes support for the notch and some APIs to query its location and bounds, but for my app I only need to be able to get the status bar height from XML, and not use a fixed value.</p>
<p>Unfortunately, I couldn't find any way to get that value from XML.</p>
<p>Is there any way?</p>
<p>Thank you.</p>
| 0debug
|
Prepared statement does not match bind variables even tho it do? : As far as i can tell i select 6 columns from the table, and i bind 6 variables so why does it tell me that it does not match?
This is for a rating script where people can vote cars
This script works with the Insert/Select/Union but i noticed that everything was getting really slow when people voted the images from the folder structure so i would like to move the selected images to another folder where they can be accessed faster but i seem to get a problem when trying to bind the result, this is usually not a problem for me, could someone explain to me why this is happening in this particular case ?
$stmt = $dbCon->prepare(" INSERT INTO cars_daily ( cars_daily_identifier, cars_daily_source, cars_daily_views, cars_daily_votes, cars_daily_rating, cars_daily_category) "
. " (SELECT cars_car_id, cars_car_source, cars_car_views, cars_car_votes, cars_car_rating, cars_car_category "
. " FROM cars_bcar "
. " WHERE cars_car_category IN (?) ORDER BY RAND() LIMIT 5) "
. " UNION "
. " (SELECT cars_car_id, cars_car_source, cars_car_views, cars_car_votes, cars_car_rating, cars_car_category "
. " FROM cars_car "
. " WHERE cars_car_category IN (?) ORDER BY RAND() LIMIT 5) "
. " UNION "
. " (SELECT cars_car_id, cars_car_source, cars_car_views, cars_car_votes, cars_car_rating, cars_car_category "
. " FROM cars_car "
. " WHERE cars_car_category IN (?) ORDER BY RAND() LIMIT 5) ");
$stmt->bind_param('iii', $cat1, $cat2, $cat3);
if ($stmt->execute()) {
echo "<br><br>";
echo "Success SELECT/INSERT";
echo "<br><br>";
} else {
echo "<br><br>";
print_r($stmt->error);
echo "<br><br>";
echo "Fail SELECT/INSERT";
}
$stmt->bind_result($cars_car_id, $cars_cars_source, $cars_car_views, $cars_car_votes, $cars_car_rating, $cars_car_category);
while ($stmt->fetch()) {
copy("models/$cars_cars_source", "daily/$cars_cars_source");
}
| 0debug
|
How to get control info of Notepad write by python language : I have code bellow copy from website : https://pywinauto.github.io/ :
```
from pywinauto.application import Application
app = Application().start("notepad.exe")
app.UntitledNotepad.menu_select("Help->About Notepad")
app.AboutNotepad.OK.click()
app.UntitledNotepad.Edit.type_keys("pywinauto Works!", with_spaces = True)
```
I have a question are : how to know Notepad have UntitledNotepad control. I use Autoit to get control info but can't get info of some controls, can't get UntitledNotepad control, but why code above know UntitledNotepad in Notepad. Please show me way to know UntitledNotepad control exist in Notepad.
Thanks !!!
| 0debug
|
static inline void tcg_out_sety(TCGContext *s, tcg_target_long val)
{
if (val == 0 || val == -1)
tcg_out32(s, WRY | INSN_IMM13(val));
else
fprintf(stderr, "unimplemented sety %ld\n", (long)val);
}
| 1threat
|
write_f(int argc, char **argv)
{
struct timeval t1, t2;
int Cflag = 0, pflag = 0, qflag = 0, bflag = 0;
int c, cnt;
char *buf;
int64_t offset;
int count;
int total = 0;
int pattern = 0xcd;
while ((c = getopt(argc, argv, "bCpP:q")) != EOF) {
switch (c) {
case 'b':
bflag = 1;
break;
case 'C':
Cflag = 1;
break;
case 'p':
pflag = 1;
break;
case 'P':
pattern = atoi(optarg);
break;
case 'q':
qflag = 1;
break;
default:
return command_usage(&write_cmd);
}
}
if (optind != argc - 2)
return command_usage(&write_cmd);
if (bflag && pflag) {
printf("-b and -p cannot be specified at the same time\n");
return 0;
}
offset = cvtnum(argv[optind]);
if (offset < 0) {
printf("non-numeric length argument -- %s\n", argv[optind]);
return 0;
}
optind++;
count = cvtnum(argv[optind]);
if (count < 0) {
printf("non-numeric length argument -- %s\n", argv[optind]);
return 0;
}
if (!pflag) {
if (offset & 0x1ff) {
printf("offset %lld is not sector aligned\n",
(long long)offset);
return 0;
}
if (count & 0x1ff) {
printf("count %d is not sector aligned\n",
count);
return 0;
}
}
buf = qemu_io_alloc(count, pattern);
gettimeofday(&t1, NULL);
if (pflag)
cnt = do_pwrite(buf, offset, count, &total);
else if (bflag)
cnt = do_save_vmstate(buf, offset, count, &total);
else
cnt = do_write(buf, offset, count, &total);
gettimeofday(&t2, NULL);
if (cnt < 0) {
printf("write failed: %s\n", strerror(-cnt));
goto out;
}
if (qflag)
goto out;
t2 = tsub(t2, t1);
print_report("wrote", &t2, offset, count, total, cnt, Cflag);
out:
qemu_io_free(buf);
return 0;
}
| 1threat
|
Xamp is not start Apache, Mysql is working fine : I was working on my PHP project yesterday and it was working fine, but today morning after the restart xamp is not starting Apache for some reason. Can someone suggest how can I work around it:
Error: Apache shutdown unexpectedly.
1:17:04 PM [Apache] This may be due to a blocked port, missing dependencies,
1:17:04 PM [Apache] improper privileges, a crash, or a shutdown by another method.
1:17:04 PM [Apache] Press the Logs button to view error logs and check
1:17:04 PM [Apache] the Windows Event Viewer for more clues
1:17:04 PM [Apache] If you need more help, copy and post this
1:17:04 PM [Apache] entire log window on the forums
| 0debug
|
alert('Hello ' + user_input);
| 1threat
|
The project system has encountered an error When trying to load project : <p>In Visual Studio 2017 v15.7.1 I am getting the following error window when trying to load one of my projects:</p>
<p><a href="https://i.stack.imgur.com/jl3rY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jl3rY.png" alt="VS error window"></a></p>
<p>And when I go to the path specified, inside the test file I find a very long stack-trace which I could not copy all of it because it exceeds allowed characters count. </p>
<blockquote>
<p>===================== 5/31/2018 3:40:57 PM LimitedFunctionality System.AggregateException: Project system data flow
'ProjectBuildSnapshotService Outer 320459' closed because of an
exception: System.AggregateException: One or more errors occurred.
---> System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. --->
System.AggregateException: One or more errors occurred. --->
System.NullReferenceException: Object reference not set to an instance
of an object. at
Microsoft.VisualStudio.ProjectServices.DesignTimeBuilder.d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.ProjectSystem.Build.DesignTimeBuilderService.BuilderLifetimeHelper.d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.ProjectSystem.Build.DesignTimeBuilderService.d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
Microsoft.VisualStudio.ProjectSystem.Build.DesignTimeBuilderService.d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)<br>
at
Microsoft.VisualStudio.ProjectSystem.Build.DesignTimeBuildManagerService.d__55.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)<br>
at
Microsoft.VisualStudio.ProjectSystem.Build.DesignTimeBuildManagerService.d__53.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.ProjectSystem.Designers.ProjectBuildSnapshotService.d__74.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)<br>
at
Microsoft.VisualStudio.ProjectSystem.Designers.ProjectBuildSnapshotService.<>c__DisplayClass72_0.<b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.Threading.JoinableTask.d__78.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.Threading.JoinableTask<code>1.<JoinAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.ProjectSystem.Designers.ProjectBuildSnapshotService.<UpdateSnapshotCoreAsync>d__72.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)<br>
at
Microsoft.VisualStudio.ProjectSystem.Designers.CustomizableBlockSubscriberBase</code>3.d__34.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.ProjectSystem.Designers.CustomizableBlockSubscriberBase<code>3.<>c__DisplayClass32_0.<<Initialize>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.Threading.JoinableTask.<JoinAsync>d__78.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.ProjectSystem.Designers.CustomizableBlockSubscriberBase</code>3.<b__32_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.VisualStudio.ProjectSystem.DataflowExtensions.<>c__DisplayClass24_0`2.<b__0>d.MoveNext()</p>
</blockquote>
| 0debug
|
void aio_set_fd_handler(AioContext *ctx,
int fd,
IOHandler *io_read,
IOHandler *io_write,
AioFlushHandler *io_flush,
void *opaque)
{
AioHandler *node;
node = find_aio_handler(ctx, fd);
if (!io_read && !io_write) {
if (node) {
if (ctx->walking_handlers)
node->deleted = 1;
else {
QLIST_REMOVE(node, node);
g_free(node);
}
}
} else {
if (node == NULL) {
node = g_malloc0(sizeof(AioHandler));
node->fd = fd;
QLIST_INSERT_HEAD(&ctx->aio_handlers, node, node);
}
node->io_read = io_read;
node->io_write = io_write;
node->io_flush = io_flush;
node->opaque = opaque;
}
}
| 1threat
|
static BlockDriverAIOCB *curl_aio_readv(BlockDriverState *bs,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque)
{
CURLAIOCB *acb;
acb = qemu_aio_get(&curl_aiocb_info, bs, cb, opaque);
acb->qiov = qiov;
acb->sector_num = sector_num;
acb->nb_sectors = nb_sectors;
acb->bh = qemu_bh_new(curl_readv_bh_cb, acb);
qemu_bh_schedule(acb->bh);
return &acb->common;
}
| 1threat
|
Replace in angularJS : This is string:
1<div>2</div><div>3</div><div>4</div>
After replace
var descriptionVal = desc.replace('<div>', '-').replace('</div>', '-');
only replace first div!
1-2</div><div>3</div><div>4</div>
how replace all div?
| 0debug
|
R - here() function, what's a .here file? : <p>I'm struggling to find the answer to this very basic question and to make the here() function work (from the here package). I'd be glad if someone could help me with that.</p>
<p>What's a file .here mentionned in this <a href="https://github.com/jennybc/here_here" rel="nofollow noreferrer">github</a>? And how can I create one ?</p>
<p>I've tried adding a text file called '.here.txt' in my workflow (where I want the here() function to "start") but it doesn't work.</p>
| 0debug
|
Python- In nested function, I want to call inner function. PFB details : ** I have a class called IrisData. I have defined One function in that as description.
* description has multiple sub-function inside which I want to access.
* I want my function to be like
1. It should return every function defined within description, if description is called.
code line : print(I.description())
2. It should return only inner function when inner function is called.
code line : print(I.description.attribute())*
PFB code snippet :
class IrisData:
def urls(self):
self.url='https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data'
return self.url
def columns(self):
self.column_name=['sepal length','sepal width','petal length','petal width','class']
return self.column_name
def description(self):
def title():
self.titles ='Title: Iris Plants Database'
return self.titles
def source():
self.sources='''Sources:
\t(a) Creator: R.A. Fisher
\t(b) Donor: Michael Marshall (MARSHALL%PLU@io.arc.nasa.gov)
\t(c) Date: July, 1988'''
return self.sources
def info():
self.descri='''Relevant Information:
\t--- This is perhaps the best known database to be found in the pattern recognition literature. Fisher's paper is a classic in the field and is referenced frequently to this day. (See Duda & Hart, for
example.
\t--- The data set contains 3 classes of 50 instances each, where each class refers to a type of iris plant. One class is linearly separable from the other 2; the latter are NOT linearly
separable from each other.
\t--- Predicted attribute: class of iris plant.
\t--- This is an exceedingly simple domain.
\t--- This data differs from the data presented in Fishers article (identified by Steve Chadwick, spchadwick@espeedaz.net )
\tThe 35th sample should be: 4.9,3.1,1.5,0.2,"Iris-setosa"
\twhere the error is in the fourth feature.
\tThe 38th sample: 4.9,3.6,1.4,0.1,"Iris-setosa"
\twhere the errors are in the second and third features. '''
return self.descri
def attribute():
self.attri="""Attribute Information:
1. sepal length in cm
2. sepal width in cm
3. petal length in cm
4. petal width in cm
5. class:
-- Iris Setosa
-- Iris Versicolour
-- Iris Virginica"""
return self.attri
return attribute(),info(),source(),title()
I=IrisData()
print(I.urls())
print(I.columns())
print(I.description())
print(I.description.attribute())
| 0debug
|
static void scsi_dma_complete_noio(void *opaque, int ret)
{
SCSIDiskReq *r = (SCSIDiskReq *)opaque;
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
if (r->req.aiocb != NULL) {
r->req.aiocb = NULL;
block_acct_done(bdrv_get_stats(s->qdev.conf.bs), &r->acct);
}
if (r->req.io_canceled) {
goto done;
}
if (ret < 0) {
if (scsi_handle_rw_error(r, -ret)) {
goto done;
}
}
r->sector += r->sector_count;
r->sector_count = 0;
if (r->req.cmd.mode == SCSI_XFER_TO_DEV) {
scsi_write_do_fua(r);
return;
} else {
scsi_req_complete(&r->req, GOOD);
}
done:
if (!r->req.io_canceled) {
scsi_req_unref(&r->req);
}
}
| 1threat
|
static void test_tco_second_timeout_shutdown(void)
{
TestData td;
const uint16_t ticks = TCO_SECS_TO_TICKS(128);
QDict *ad;
td.args = "-watchdog-action shutdown";
td.noreboot = false;
test_init(&td);
stop_tco(&td);
clear_tco_status(&td);
reset_on_second_timeout(true);
set_tco_timeout(&td, ticks);
load_tco(&td);
start_tco(&td);
clock_step(ticks * TCO_TICK_NSEC * 2);
ad = get_watchdog_action();
g_assert(!strcmp(qdict_get_str(ad, "action"), "shutdown"));
QDECREF(ad);
stop_tco(&td);
qtest_end();
}
| 1threat
|
Max arc4random() value : For some reason I'm not able to find any sort of official doc telling me what the maximum range is for arc4random. I've seen in some non-authoritarian sources that it's 2^32 - 1, a little over 4 billion.
Can anyone confirm this? If so, can you link to an official doc showing this number somewhere? I'm trying to generate a random number on my iOS app and need to have a pretty official upper end for the algorithm to work correctly. Thanks in advance!
| 0debug
|
(php,mysqli,phpmyadmin) Can I enter my data this way? : Please, I cant find the mistake but it doesn't work.
Always shows "error de envio"(sending error)
...or die("error de envio");
[Myphpadmin data][1] <- Link img.
My php code:
$link =mysqli_connect("localhost","my_user","my_password","usuario")or die("
<h2>NO se encuentra el servidor </h2>");
$name=$_POST['name'];
$pass=$_POST['pass'];
$nick=$_POST['nick'];
$email=$_POST['correo'];
$raza=$_POST['raza'];
$req =(strlen($nick)*strlen($pass)*strlen($email))or die("<h2>no se llenaron los datos </h2>");
$contra=md5($pass);
mysqli_query($link,"SELECT * FROM usuario");
mysqli_query($link,"INSERT INTO `usuario`(`nombre`,`contrasena`,`usuario`,`email`,`raza`) VALUES('$name','$contra','$nick','$email','$raza')") or die("error de envio");
echo"gracias por registrarse"
mysqli_close($link);
Can I enter my data this way?
Thanks for your help.
[1]: https://i.stack.imgur.com/14KOF.png
| 0debug
|
static inline int bidir_refine(MpegEncContext * s, int mb_x, int mb_y)
{
MotionEstContext * const c= &s->me;
const int mot_stride = s->mb_stride;
const int xy = mb_y *mot_stride + mb_x;
int fbmin;
int pred_fx= s->b_bidir_forw_mv_table[xy-1][0];
int pred_fy= s->b_bidir_forw_mv_table[xy-1][1];
int pred_bx= s->b_bidir_back_mv_table[xy-1][0];
int pred_by= s->b_bidir_back_mv_table[xy-1][1];
int motion_fx= s->b_bidir_forw_mv_table[xy][0]= s->b_forw_mv_table[xy][0];
int motion_fy= s->b_bidir_forw_mv_table[xy][1]= s->b_forw_mv_table[xy][1];
int motion_bx= s->b_bidir_back_mv_table[xy][0]= s->b_back_mv_table[xy][0];
int motion_by= s->b_bidir_back_mv_table[xy][1]= s->b_back_mv_table[xy][1];
const int flags= c->sub_flags;
const int qpel= flags&FLAG_QPEL;
const int shift= 1+qpel;
const int xmin= c->xmin<<shift;
const int ymin= c->ymin<<shift;
const int xmax= c->xmax<<shift;
const int ymax= c->ymax<<shift;
uint8_t map[8][8][8][8];
memset(map,0,sizeof(map));
#define BIDIR_MAP(fx,fy,bx,by) \
map[(motion_fx+fx)&7][(motion_fy+fy)&7][(motion_bx+bx)&7][(motion_by+by)&7]
BIDIR_MAP(0,0,0,0) = 1;
fbmin= check_bidir_mv(s, motion_fx, motion_fy,
motion_bx, motion_by,
pred_fx, pred_fy,
pred_bx, pred_by,
0, 16);
if(s->avctx->bidir_refine){
int score, end;
#define CHECK_BIDIR(fx,fy,bx,by)\
if( !BIDIR_MAP(fx,fy,bx,by)\
&&(fx<=0 || motion_fx+fx<=xmax) && (fy<=0 || motion_fy+fy<=ymax) && (bx<=0 || motion_bx+bx<=xmax) && (by<=0 || motion_by+by<=ymax)\
&&(fx>=0 || motion_fx+fx>=xmin) && (fy>=0 || motion_fy+fy>=ymin) && (bx>=0 || motion_bx+bx>=xmin) && (by>=0 || motion_by+by>=ymin)){\
BIDIR_MAP(fx,fy,bx,by) = 1;\
score= check_bidir_mv(s, motion_fx+fx, motion_fy+fy, motion_bx+bx, motion_by+by, pred_fx, pred_fy, pred_bx, pred_by, 0, 16);\
if(score < fbmin){\
fbmin= score;\
motion_fx+=fx;\
motion_fy+=fy;\
motion_bx+=bx;\
motion_by+=by;\
end=0;\
}\
}
#define CHECK_BIDIR2(a,b,c,d)\
CHECK_BIDIR(a,b,c,d)\
CHECK_BIDIR(-a,-b,-c,-d)
#define CHECK_BIDIRR(a,b,c,d)\
CHECK_BIDIR2(a,b,c,d)\
CHECK_BIDIR2(b,c,d,a)\
CHECK_BIDIR2(c,d,a,b)\
CHECK_BIDIR2(d,a,b,c)
do{
end=1;
CHECK_BIDIRR( 0, 0, 0, 1)
if(s->avctx->bidir_refine > 1){
CHECK_BIDIRR( 0, 0, 1, 1)
CHECK_BIDIR2( 0, 1, 0, 1)
CHECK_BIDIR2( 1, 0, 1, 0)
CHECK_BIDIRR( 0, 0,-1, 1)
CHECK_BIDIR2( 0,-1, 0, 1)
CHECK_BIDIR2(-1, 0, 1, 0)
if(s->avctx->bidir_refine > 2){
CHECK_BIDIRR( 0, 1, 1, 1)
CHECK_BIDIRR( 0,-1, 1, 1)
CHECK_BIDIRR( 0, 1,-1, 1)
CHECK_BIDIRR( 0, 1, 1,-1)
if(s->avctx->bidir_refine > 3){
CHECK_BIDIR2( 1, 1, 1, 1)
CHECK_BIDIRR( 1, 1, 1,-1)
CHECK_BIDIR2( 1, 1,-1,-1)
CHECK_BIDIR2( 1,-1,-1, 1)
CHECK_BIDIR2( 1,-1, 1,-1)
}
}
}
}while(!end);
}
s->b_bidir_forw_mv_table[xy][0]= motion_fx;
s->b_bidir_forw_mv_table[xy][1]= motion_fy;
s->b_bidir_back_mv_table[xy][0]= motion_bx;
s->b_bidir_back_mv_table[xy][1]= motion_by;
return fbmin;
}
| 1threat
|
How do I use transaction with oracle SQL? : <p>I am trying to use transaction blocks on a SQL-Console with an Oracle DB. I'm used to use transaxction blocks in PostgreSQL like</p>
<pre><code>BEGIN;
<simple sql statement>
END;
</code></pre>
<p>but in oracle it seems that this is not possible. I'm always getting "ORA-00900" errors and I don't know how to fix that. If I just use SQL-Statements like</p>
<pre><code><simple sql statement>
COMMIT;
</code></pre>
<p>it works. But isn't there some tag to define the start of a transaction? I tried </p>
<pre><code>START TRANSACTION;
<simple sql statement>
COMMIT;
</code></pre>
<p>But it still throws an ORA-00900. My operating system is windows, I am using IntelliJ IDEA and a Oracle 11g DB.</p>
| 0debug
|
MySQL fails on: mysql "ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded" : <p>My local environment is:</p>
<ul>
<li>fresh Ubuntu 16.04</li>
<li>with PHP 7</li>
<li><p>with installed MySQL 5.7</p>
<pre><code>sudo apt-get install mysql-common mysql-server
</code></pre></li>
</ul>
<hr>
<p>When I tried to login to MySQL (via CLI):</p>
<pre><code>mysql -u root -p
</code></pre>
<p>I came across an cyclic issue with 3 steps.</p>
<h2>1) First was some socket issue</h2>
<pre><code>ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
</code></pre>
<p><strong>Solution: restarting PC.</strong></p>
<p>Which led to another error:</p>
<h2>2) With access denied</h2>
<pre><code>ERROR 1698 (28000): Access denied for user 'root'@'localhost'.
</code></pre>
<p>Possible issue? Wrong password for "root" user!</p>
<p><strong>Solution: <a href="https://support.rackspace.com/how-to/mysql-resetting-a-lost-mysql-root-password/">reset root password with this tutorial</a>.</strong></p>
<p>With correct password and working socket, there comes last error.</p>
<h2>3) Incorrect auth plugin</h2>
<pre><code>mysql "ERROR 1524 (HY000): Plugin 'unix_socket' is not loaded"
</code></pre>
<p>Here I stopped or somehow got to 1) again.</p>
| 0debug
|
How do I get my Eclipse-Maven project to automatically update its classpath when I change a dependency in my pom.xml file? : <p>I’m using Eclipse Mars with Maven (v 3.3). When I update a dependency in my pom (change the version), my Eclipse-Maven project doesn’t pick it up, even when I right click my project, and select “Maven” -> “Update Project.” I know this because I do not see compilation errors in the Eclipse Java editor that I see when I build the project on the command line using</p>
<pre><code>mvn clean install
</code></pre>
<p>When I remove the project from the workspace and re-import it, then things get back to normal. However this is a cumbersome process. How do I get my Maven-Eclipse project to automatically detect changes in my pom and update the project libraries appropriately?</p>
<p>And yes, in the “Project” menu, “Build Automatically” is checked.</p>
| 0debug
|
How do I save the output of this code into a file? (PHP) : <p>This code that loops through some mysql tables:</p>
<pre><code>foreach($tables as $table)
{
echo "<h2>" . $table[0] . "</h2>";
$query = "DESCRIBE " . $table[0];
$result = $mysqli->query($query);
$columns = $result->fetch_all();
foreach($columns as $column)
{
echo $column[0]. '<br />';
}
}
</code></pre>
<p>How do I make it output to a file? (Just the names of the tables and the column names)</p>
| 0debug
|
Heroku - No web process running : <p>I made a twitter bot using tweepy in Python and tried deploying it using Heroku. The Bot just tweets after certain intervals. After deploying it, the Python program just doesn't run and Heroku log shows the following error : </p>
<pre><code>at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=fathomless-island-25537.herokuapp.com request_id=0aa76d12-31e6-4940-85ec-a8476af4f82f fwd="182.64.210.145" dyno= connect= service= status=503 bytes=
</code></pre>
<p>After looking through some similar problems where a django app has to be deployed, I tried:</p>
<pre><code>heroku ps:scale web=1
</code></pre>
<p>and got:</p>
<pre><code>Scaling dynos... !
! Couldn't find that formation.
</code></pre>
<p>Does it mean that the program failed to establish a web process or is there something else related to dynos ? Or if I have to include some code related to dynos in my program ? I don't know which part of this whole process has a problem. Apologies if it's too basic.</p>
| 0debug
|
Can't reference system.drawing.dll plz help me :
When I create the code that continuously executes the function, it works normally for 4 minutes, but the error "Can not reference system.drawing.dll" appears and it can not be executed.
I've tried Googleing a couple of times to solve it, but I have not had the same experience with you.
Try writing a Google translation and ask a question.
Code Admins Please help me.
public static Bitmap GetScreenshot(IntPtr hwnd)
{
RECT rc;
GetWindowRect(new HandleRef(null, hwnd), out rc);
Bitmap bmp = new Bitmap(rc.Right - rc.Left, rc.Bottom - rc.Top,
PixelFormat.Format32bppArgb);
Graphics gfxBmp = Graphics.FromImage(bmp);
IntPtr hdcBitmap;
try
{
hdcBitmap = gfxBmp.GetHdc();
}
catch
{
return null;
}
bool succeeded = PrintWindow(hwnd, hdcBitmap, 0x3);
gfxBmp.ReleaseHdc(hdcBitmap);
if (!succeeded)
{
gfxBmp.FillRectangle(new SolidBrush(Color.Gray), new
Rectangle(Point.Empty, bmp.Size));
}
IntPtr hRgn = CreateRectRgn(0, 0, 0, 0);
GetWindowRgn(hwnd, hRgn);
Region region = Region.FromHrgn(hRgn);//err here once
if (!region.IsEmpty(gfxBmp))
{
gfxBmp.ExcludeClip(region);
gfxBmp.Clear(Color.Transparent);
}
gfxBmp.Dispose();
return bmp;
}
Timer timer3 = new System.Windows.Forms.Timer();
timer3.Interval = 1; // 1초
timer3.Tick += new EventHandler(timer_Tick2);
timer3.Start();
| 0debug
|
How to properly include a library from node_modules into your project? : <p>the question can maybe be stupid but did not find the answer till now.<br>
I'm trying to include a library from <strong>node_modules</strong>, from what I've learn since yesterday we should include like that with <strong>asset</strong>:</p>
<pre><code>{{-- bootstrap 4.1.3 --}}
<link href="{{asset('css/app.css')}}" rel="stylesheet" type="text/css">
</code></pre>
<p>I want to add <strong>selectize.js</strong> into my project so I used <strong>npm install selectize --save</strong> to be directly install and save into <strong>package.json(dependencies)</strong>.</p>
<p>My question is, how can I include that now? Just like default bootstrap is. How can I go from <strong>node_modules/</strong> to <strong>public/</strong>?<br>
Should I do it manually or there is a more professional/cleaner way to do it?<br>
Thank you for the help.</p>
| 0debug
|
SQLite Error 14: 'unable to open database file' with EF Core code first : <p>I am getting an</p>
<p>SQLite Error 14: 'unable to open database file'</p>
<p>with EF Core code first, no idea why. I worked fine the first time, the database file got created in c:\users\username\AppData\Local\Packages\PackageId\LocalState.</p>
<p>Then I deleted the database file and the code first migration and ModelSnapshot classes and created a new migration (I am calling DbContext.Database.Migrate() on app start to automatically execute them). Now the database cannot be created again.</p>
| 0debug
|
How to programming Xor calculator hex base 16 in java? : How to programming Xor calculator java for hexadecimal base 16 in java like in the screenshot shown below. The first input is the key and thee second input is the string, the third one is the output. Actually I tried a lot of scripts and I googled the issue but the result is not coming true like in this calculators. Please Help.
[online xor calculator][1]
[windows programmer calculator][2]
[1]: https://i.stack.imgur.com/cgZ0M.png
[2]: https://i.stack.imgur.com/fMUaP.png
| 0debug
|
AddfdInfo *qmp_add_fd(bool has_fdset_id, int64_t fdset_id, bool has_opaque,
const char *opaque, Error **errp)
{
int fd;
Monitor *mon = cur_mon;
MonFdset *mon_fdset = NULL;
MonFdsetFd *mon_fdset_fd;
AddfdInfo *fdinfo;
fd = qemu_chr_fe_get_msgfd(mon->chr);
if (fd == -1) {
error_set(errp, QERR_FD_NOT_SUPPLIED);
goto error;
}
if (has_fdset_id) {
QLIST_FOREACH(mon_fdset, &mon_fdsets, next) {
if (fdset_id <= mon_fdset->id) {
if (fdset_id < mon_fdset->id) {
mon_fdset = NULL;
}
break;
}
}
}
if (mon_fdset == NULL) {
int64_t fdset_id_prev = -1;
MonFdset *mon_fdset_cur = QLIST_FIRST(&mon_fdsets);
if (has_fdset_id) {
if (fdset_id < 0) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "fdset-id",
"a non-negative value");
goto error;
}
QLIST_FOREACH(mon_fdset, &mon_fdsets, next) {
mon_fdset_cur = mon_fdset;
if (fdset_id < mon_fdset_cur->id) {
break;
}
}
} else {
QLIST_FOREACH(mon_fdset, &mon_fdsets, next) {
mon_fdset_cur = mon_fdset;
if (fdset_id_prev == mon_fdset_cur->id - 1) {
fdset_id_prev = mon_fdset_cur->id;
continue;
}
break;
}
}
mon_fdset = g_malloc0(sizeof(*mon_fdset));
if (has_fdset_id) {
mon_fdset->id = fdset_id;
} else {
mon_fdset->id = fdset_id_prev + 1;
}
if (!mon_fdset_cur) {
QLIST_INSERT_HEAD(&mon_fdsets, mon_fdset, next);
} else if (mon_fdset->id < mon_fdset_cur->id) {
QLIST_INSERT_BEFORE(mon_fdset_cur, mon_fdset, next);
} else {
QLIST_INSERT_AFTER(mon_fdset_cur, mon_fdset, next);
}
}
mon_fdset_fd = g_malloc0(sizeof(*mon_fdset_fd));
mon_fdset_fd->fd = fd;
mon_fdset_fd->removed = false;
if (has_opaque) {
mon_fdset_fd->opaque = g_strdup(opaque);
}
QLIST_INSERT_HEAD(&mon_fdset->fds, mon_fdset_fd, next);
fdinfo = g_malloc0(sizeof(*fdinfo));
fdinfo->fdset_id = mon_fdset->id;
fdinfo->fd = mon_fdset_fd->fd;
return fdinfo;
error:
if (fd != -1) {
close(fd);
}
return NULL;
}
| 1threat
|
static void dca_init_vlcs(void)
{
static int vlcs_inited = 0;
int i, j;
if (vlcs_inited)
return;
dca_bitalloc_index.offset = 1;
dca_bitalloc_index.wrap = 2;
for (i = 0; i < 5; i++)
init_vlc(&dca_bitalloc_index.vlc[i], bitalloc_12_vlc_bits[i], 12,
bitalloc_12_bits[i], 1, 1,
bitalloc_12_codes[i], 2, 2, 1);
dca_scalefactor.offset = -64;
dca_scalefactor.wrap = 2;
for (i = 0; i < 5; i++)
init_vlc(&dca_scalefactor.vlc[i], SCALES_VLC_BITS, 129,
scales_bits[i], 1, 1,
scales_codes[i], 2, 2, 1);
dca_tmode.offset = 0;
dca_tmode.wrap = 1;
for (i = 0; i < 4; i++)
init_vlc(&dca_tmode.vlc[i], tmode_vlc_bits[i], 4,
tmode_bits[i], 1, 1,
tmode_codes[i], 2, 2, 1);
for(i = 0; i < 10; i++)
for(j = 0; j < 7; j++){
if(!bitalloc_codes[i][j]) break;
dca_smpl_bitalloc[i+1].offset = bitalloc_offsets[i];
dca_smpl_bitalloc[i+1].wrap = 1 + (j > 4);
init_vlc(&dca_smpl_bitalloc[i+1].vlc[j], bitalloc_maxbits[i][j],
bitalloc_sizes[i],
bitalloc_bits[i][j], 1, 1,
bitalloc_codes[i][j], 2, 2, 1);
}
vlcs_inited = 1;
}
| 1threat
|
how to read nextline of textfile in java : import java.io.*;
import java.util.*;
public class stringstore
{
public static void main(String[] args)
{
File file = new File("C:\\a.txt");
try
{
String strIP="";
Scanner sc = new Scanner(file);
while(sc.hasNext())
{
String line = sc.nextLine();
String str[] = line.split(", ");
strIP = str[0];
}
System.out.println(strIP);
}
catch(IOException e)
{
// work with the errors here
}
}
}
How do i read a nextline from a textfile and display it.Please help. Its urgent and i want to know this as early as possible. Thanking You'll in advance.
| 0debug
|
Logistic regression R-predict : No of rows error : <p>I am trying to use the predict function to predict the values of a logistic regression and I am getting the incorrect number of rows. This question has already been asked
<a href="https://stackoverflow.com/questions/40978688/r-warning-newdata-had-15-rows-but-variables-found-have-22-rows">R Warning: newdata' had 15 rows but variables found have 22 rows</a></p>
<p>and I have tried the approach but I still get the error. Here is the code</p>
<pre><code># Split as training and test sets
train_idx <- trainTestSplit(adult,trainPercent=75,seed=1111)
train <- adult[train_idx, ]
test <- adult[-train_idx, ]
xtrain <- train[,1:7]
ytrain <- train[,8]
xtrain1 <- dummy.data.frame(xtrain, sep = ".")
xtrain2 <- as.matrix(xtrain1)
xtest <- test[,1:7]
ytest <- test[,8]
xtest1 <- dummy.data.frame(xtest, sep = ".")
xtest2 <- as.matrix(xtest1)
fit=glm(ytrain~xtrain2,family=binomial)
a=predict(fit,newdata=xtrain1,type="response")
b=ifelse(a>0.5,1,0)
confusionMatrix(b,ytrain)
Confusion Matrix and Statistics
Reference
Prediction 0 1
0 16065 3157
1 968 2430
Accuracy : 0.8176
95% CI : (0.8125, 0.8227)
# Predict with test dataframe
a=predict(fit,xtest1,type="response")
: 'newdata' had 7541 rows but variables found have 22620 rows
2: In predict.lm(object, newdata, se.fit, scale = 1, type = ifelse(type == :
prediction from a rank-deficient fit may be misleading
>
</code></pre>
<p>I also tried</p>
<pre><code> names(xtest1)=names(xtrain1) and
a=predict(fit,xtest1,type="response")
</code></pre>
<p>They were the same anyway but I get the same error. This is an issue that is very counter intuitive. Please help...</p>
| 0debug
|
static int mxf_write_footer(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
AVIOContext *pb = s->pb;
int err = 0;
mxf->duration = mxf->last_indexed_edit_unit + mxf->edit_units_count;
mxf_write_klv_fill(s);
mxf->footer_partition_offset = avio_tell(pb);
if (mxf->edit_unit_byte_count && s->oformat != &ff_mxf_opatom_muxer) {
if ((err = mxf_write_partition(s, 0, 0, footer_partition_key, 0)) < 0)
} else {
if ((err = mxf_write_partition(s, 0, 2, footer_partition_key, 0)) < 0)
mxf_write_klv_fill(s);
mxf_write_index_table_segment(s);
mxf_write_klv_fill(s);
mxf_write_random_index_pack(s);
if (s->pb->seekable) {
if (s->oformat == &ff_mxf_opatom_muxer){
avio_seek(pb, mxf->body_partition_offset[0], SEEK_SET);
if ((err = mxf_write_opatom_body_partition(s)) < 0)
avio_seek(pb, 0, SEEK_SET);
if (mxf->edit_unit_byte_count && s->oformat != &ff_mxf_opatom_muxer) {
if ((err = mxf_write_partition(s, 1, 2, header_closed_partition_key, 1)) < 0)
mxf_write_klv_fill(s);
mxf_write_index_table_segment(s);
} else {
if ((err = mxf_write_partition(s, 0, 0, header_closed_partition_key, 1)) < 0)
end:
ff_audio_interleave_close(s);
av_freep(&mxf->index_entries);
av_freep(&mxf->body_partition_offset);
av_freep(&mxf->timecode_track->priv_data);
av_freep(&mxf->timecode_track);
mxf_free(s);
return err < 0 ? err : 0;
| 1threat
|
are sas procedures source code available : <p>I understand SAS is proprietary software. I am wondering if the procedures that ships with it also ship without source code. For example, I see a PROC ANOVA in the user guide; is there anyway to look at the source code to see exactly how this procedure computes anovas?</p>
<p>There are some <a href="https://communities.sas.com/t5/Base-SAS-Programming/How-to-retrieve-the-source-code-of-a-compiled-macro/td-p/320093" rel="nofollow noreferrer">threads</a> discussing viewing the source code compiled without a "secure" flag. Do the prepackaged procedures like ANOVA ship in this way (I don't have access to SAS to find out myself).</p>
| 0debug
|
TextBox Value Disappears VB6 : I my case I am having two form Form 1 and Form 2.
Form 1 having two Buttons and Form 2 is having one textbox.
On Button 1 Click event I am writing "My Text" in my Form 2 TextBox and on button 2 I am showing Form 2.
What is happening is When I close my Form 2 using close [X] button and reopen it value in my Form 2 Textbox Disappears.
Please Help how can I resolve this,
| 0debug
|
static void xhci_kick_ep(XHCIState *xhci, unsigned int slotid,
unsigned int epid, unsigned int streamid)
{
XHCIStreamContext *stctx;
XHCIEPContext *epctx;
XHCIRing *ring;
USBEndpoint *ep = NULL;
uint64_t mfindex;
int length;
int i;
trace_usb_xhci_ep_kick(slotid, epid, streamid);
assert(slotid >= 1 && slotid <= xhci->numslots);
assert(epid >= 1 && epid <= 31);
if (!xhci->slots[slotid-1].enabled) {
fprintf(stderr, "xhci: xhci_kick_ep for disabled slot %d\n", slotid);
return;
}
epctx = xhci->slots[slotid-1].eps[epid-1];
if (!epctx) {
fprintf(stderr, "xhci: xhci_kick_ep for disabled endpoint %d,%d\n",
epid, slotid);
return;
}
if (epctx->retry) {
XHCITransfer *xfer = epctx->retry;
trace_usb_xhci_xfer_retry(xfer);
assert(xfer->running_retry);
if (xfer->iso_xfer) {
mfindex = xhci_mfindex_get(xhci);
xhci_check_iso_kick(xhci, xfer, epctx, mfindex);
if (xfer->running_retry) {
return;
}
if (xhci_setup_packet(xfer) < 0) {
return;
}
usb_handle_packet(xfer->packet.ep->dev, &xfer->packet);
assert(xfer->packet.status != USB_RET_NAK);
xhci_complete_packet(xfer);
} else {
if (xhci_setup_packet(xfer) < 0) {
return;
}
usb_handle_packet(xfer->packet.ep->dev, &xfer->packet);
if (xfer->packet.status == USB_RET_NAK) {
return;
}
xhci_complete_packet(xfer);
}
assert(!xfer->running_retry);
epctx->retry = NULL;
}
if (epctx->state == EP_HALTED) {
DPRINTF("xhci: ep halted, not running schedule\n");
return;
}
if (epctx->nr_pstreams) {
uint32_t err;
stctx = xhci_find_stream(epctx, streamid, &err);
if (stctx == NULL) {
return;
}
ring = &stctx->ring;
xhci_set_ep_state(xhci, epctx, stctx, EP_RUNNING);
} else {
ring = &epctx->ring;
streamid = 0;
xhci_set_ep_state(xhci, epctx, NULL, EP_RUNNING);
}
assert(ring->dequeue != 0);
while (1) {
XHCITransfer *xfer = &epctx->transfers[epctx->next_xfer];
if (xfer->running_async || xfer->running_retry) {
break;
}
length = xhci_ring_chain_length(xhci, ring);
if (length < 0) {
break;
} else if (length == 0) {
break;
}
if (xfer->trbs && xfer->trb_alloced < length) {
xfer->trb_count = 0;
xfer->trb_alloced = 0;
g_free(xfer->trbs);
xfer->trbs = NULL;
}
if (!xfer->trbs) {
xfer->trbs = g_malloc(sizeof(XHCITRB) * length);
xfer->trb_alloced = length;
}
xfer->trb_count = length;
for (i = 0; i < length; i++) {
assert(xhci_ring_fetch(xhci, ring, &xfer->trbs[i], NULL));
}
xfer->xhci = xhci;
xfer->epid = epid;
xfer->slotid = slotid;
xfer->streamid = streamid;
if (epid == 1) {
if (xhci_fire_ctl_transfer(xhci, xfer) >= 0) {
epctx->next_xfer = (epctx->next_xfer + 1) % TD_QUEUE;
ep = xfer->packet.ep;
} else {
fprintf(stderr, "xhci: error firing CTL transfer\n");
}
} else {
if (xhci_fire_transfer(xhci, xfer, epctx) >= 0) {
epctx->next_xfer = (epctx->next_xfer + 1) % TD_QUEUE;
ep = xfer->packet.ep;
} else {
if (!xfer->iso_xfer) {
fprintf(stderr, "xhci: error firing data transfer\n");
}
}
}
if (epctx->state == EP_HALTED) {
break;
}
if (xfer->running_retry) {
DPRINTF("xhci: xfer nacked, stopping schedule\n");
epctx->retry = xfer;
break;
}
}
if (ep) {
usb_device_flush_ep_queue(ep->dev, ep);
}
}
| 1threat
|
What's Object Oriented Programming? : <p>I'm pretty new to programming with Object Oriented Programming Languages.
So please how do you explain the concept of object oriented programming to a kid?</p>
| 0debug
|
static int encode_picture(MpegEncContext *s, int picture_number)
{
int i;
int bits;
s->picture_number = picture_number;
s->me.mb_var_sum_temp =
s->me.mc_mb_var_sum_temp = 0;
if (s->codec_id == CODEC_ID_MPEG1VIDEO || s->codec_id == CODEC_ID_MPEG2VIDEO || (s->h263_pred && !s->h263_msmpeg4))
set_frame_distances(s);
if(ENABLE_MPEG4_ENCODER && s->codec_id == CODEC_ID_MPEG4)
ff_set_mpeg4_time(s);
s->me.scene_change_score=0;
if(s->pict_type==FF_I_TYPE){
if(s->msmpeg4_version >= 3) s->no_rounding=1;
else s->no_rounding=0;
}else if(s->pict_type!=FF_B_TYPE){
if(s->flipflop_rounding || s->codec_id == CODEC_ID_H263P || s->codec_id == CODEC_ID_MPEG4)
s->no_rounding ^= 1;
}
if(s->flags & CODEC_FLAG_PASS2){
if (estimate_qp(s,1) < 0)
return -1;
ff_get_2pass_fcode(s);
}else if(!(s->flags & CODEC_FLAG_QSCALE)){
if(s->pict_type==FF_B_TYPE)
s->lambda= s->last_lambda_for[s->pict_type];
else
s->lambda= s->last_lambda_for[s->last_non_b_pict_type];
update_qscale(s);
}
s->mb_intra=0;
for(i=1; i<s->avctx->thread_count; i++){
ff_update_duplicate_context(s->thread_context[i], s);
}
ff_init_me(s);
if(s->pict_type != FF_I_TYPE){
s->lambda = (s->lambda * s->avctx->me_penalty_compensation + 128)>>8;
s->lambda2= (s->lambda2* (int64_t)s->avctx->me_penalty_compensation + 128)>>8;
if(s->pict_type != FF_B_TYPE && s->avctx->me_threshold==0){
if((s->avctx->pre_me && s->last_non_b_pict_type==FF_I_TYPE) || s->avctx->pre_me==2){
s->avctx->execute(s->avctx, pre_estimate_motion_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count);
}
}
s->avctx->execute(s->avctx, estimate_motion_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count);
}else {
for(i=0; i<s->mb_stride*s->mb_height; i++)
s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
if(!s->fixed_qscale){
s->avctx->execute(s->avctx, mb_var_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count);
}
}
for(i=1; i<s->avctx->thread_count; i++){
merge_context_after_me(s, s->thread_context[i]);
}
s->current_picture.mc_mb_var_sum= s->current_picture_ptr->mc_mb_var_sum= s->me.mc_mb_var_sum_temp;
s->current_picture. mb_var_sum= s->current_picture_ptr-> mb_var_sum= s->me. mb_var_sum_temp;
emms_c();
if(s->me.scene_change_score > s->avctx->scenechange_threshold && s->pict_type == FF_P_TYPE){
s->pict_type= FF_I_TYPE;
for(i=0; i<s->mb_stride*s->mb_height; i++)
s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
}
if(!s->umvplus){
if(s->pict_type==FF_P_TYPE || s->pict_type==FF_S_TYPE) {
s->f_code= ff_get_best_fcode(s, s->p_mv_table, CANDIDATE_MB_TYPE_INTER);
if(s->flags & CODEC_FLAG_INTERLACED_ME){
int a,b;
a= ff_get_best_fcode(s, s->p_field_mv_table[0][0], CANDIDATE_MB_TYPE_INTER_I);
b= ff_get_best_fcode(s, s->p_field_mv_table[1][1], CANDIDATE_MB_TYPE_INTER_I);
s->f_code= FFMAX3(s->f_code, a, b);
}
ff_fix_long_p_mvs(s);
ff_fix_long_mvs(s, NULL, 0, s->p_mv_table, s->f_code, CANDIDATE_MB_TYPE_INTER, 0);
if(s->flags & CODEC_FLAG_INTERLACED_ME){
int j;
for(i=0; i<2; i++){
for(j=0; j<2; j++)
ff_fix_long_mvs(s, s->p_field_select_table[i], j,
s->p_field_mv_table[i][j], s->f_code, CANDIDATE_MB_TYPE_INTER_I, 0);
}
}
}
if(s->pict_type==FF_B_TYPE){
int a, b;
a = ff_get_best_fcode(s, s->b_forw_mv_table, CANDIDATE_MB_TYPE_FORWARD);
b = ff_get_best_fcode(s, s->b_bidir_forw_mv_table, CANDIDATE_MB_TYPE_BIDIR);
s->f_code = FFMAX(a, b);
a = ff_get_best_fcode(s, s->b_back_mv_table, CANDIDATE_MB_TYPE_BACKWARD);
b = ff_get_best_fcode(s, s->b_bidir_back_mv_table, CANDIDATE_MB_TYPE_BIDIR);
s->b_code = FFMAX(a, b);
ff_fix_long_mvs(s, NULL, 0, s->b_forw_mv_table, s->f_code, CANDIDATE_MB_TYPE_FORWARD, 1);
ff_fix_long_mvs(s, NULL, 0, s->b_back_mv_table, s->b_code, CANDIDATE_MB_TYPE_BACKWARD, 1);
ff_fix_long_mvs(s, NULL, 0, s->b_bidir_forw_mv_table, s->f_code, CANDIDATE_MB_TYPE_BIDIR, 1);
ff_fix_long_mvs(s, NULL, 0, s->b_bidir_back_mv_table, s->b_code, CANDIDATE_MB_TYPE_BIDIR, 1);
if(s->flags & CODEC_FLAG_INTERLACED_ME){
int dir, j;
for(dir=0; dir<2; dir++){
for(i=0; i<2; i++){
for(j=0; j<2; j++){
int type= dir ? (CANDIDATE_MB_TYPE_BACKWARD_I|CANDIDATE_MB_TYPE_BIDIR_I)
: (CANDIDATE_MB_TYPE_FORWARD_I |CANDIDATE_MB_TYPE_BIDIR_I);
ff_fix_long_mvs(s, s->b_field_select_table[dir][i], j,
s->b_field_mv_table[dir][i][j], dir ? s->b_code : s->f_code, type, 1);
}
}
}
}
}
}
if (estimate_qp(s, 0) < 0)
return -1;
if(s->qscale < 3 && s->max_qcoeff<=128 && s->pict_type==FF_I_TYPE && !(s->flags & CODEC_FLAG_QSCALE))
s->qscale= 3;
if (s->out_format == FMT_MJPEG) {
s->intra_matrix[0] = ff_mpeg1_default_intra_matrix[0];
for(i=1;i<64;i++){
int j= s->dsp.idct_permutation[i];
s->intra_matrix[j] = av_clip_uint8((ff_mpeg1_default_intra_matrix[i] * s->qscale) >> 3);
}
ff_convert_matrix(&s->dsp, s->q_intra_matrix, s->q_intra_matrix16,
s->intra_matrix, s->intra_quant_bias, 8, 8, 1);
s->qscale= 8;
}
s->current_picture_ptr->key_frame=
s->current_picture.key_frame= s->pict_type == FF_I_TYPE;
s->current_picture_ptr->pict_type=
s->current_picture.pict_type= s->pict_type;
if(s->current_picture.key_frame)
s->picture_in_gop_number=0;
s->last_bits= put_bits_count(&s->pb);
switch(s->out_format) {
case FMT_MJPEG:
if (ENABLE_MJPEG_ENCODER)
ff_mjpeg_encode_picture_header(s);
break;
case FMT_H261:
if (ENABLE_H261_ENCODER)
ff_h261_encode_picture_header(s, picture_number);
break;
case FMT_H263:
if (ENABLE_WMV2_ENCODER && s->codec_id == CODEC_ID_WMV2)
ff_wmv2_encode_picture_header(s, picture_number);
else if (ENABLE_MSMPEG4_ENCODER && s->h263_msmpeg4)
msmpeg4_encode_picture_header(s, picture_number);
else if (ENABLE_MPEG4_ENCODER && s->h263_pred)
mpeg4_encode_picture_header(s, picture_number);
else if (ENABLE_RV10_ENCODER && s->codec_id == CODEC_ID_RV10)
rv10_encode_picture_header(s, picture_number);
else if (ENABLE_RV20_ENCODER && s->codec_id == CODEC_ID_RV20)
rv20_encode_picture_header(s, picture_number);
else if (ENABLE_FLV_ENCODER && s->codec_id == CODEC_ID_FLV1)
ff_flv_encode_picture_header(s, picture_number);
else if (ENABLE_ANY_H263_ENCODER)
h263_encode_picture_header(s, picture_number);
break;
case FMT_MPEG1:
if (ENABLE_MPEG1VIDEO_ENCODER || ENABLE_MPEG2VIDEO_ENCODER)
mpeg1_encode_picture_header(s, picture_number);
break;
case FMT_H264:
break;
default:
assert(0);
}
bits= put_bits_count(&s->pb);
s->header_bits= bits - s->last_bits;
for(i=1; i<s->avctx->thread_count; i++){
update_duplicate_context_after_me(s->thread_context[i], s);
}
s->avctx->execute(s->avctx, encode_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count);
for(i=1; i<s->avctx->thread_count; i++){
merge_context_after_encode(s, s->thread_context[i]);
}
emms_c();
return 0;
}
| 1threat
|
how to use radio buttons in xamarin forms : <p>Creating a Registration page i need to get following data from user.
-First Name
-Last Name
-Username
-Email
-Password
-Date of Birth
-<strong>Gender</strong>
-<strong>User Role</strong></p>
<p>For Last to parameters I am unable to find how to use radio buttons in xamarin forms. Following is my code for Registration Page.</p>
<pre><code><StackLayout BackgroundColor="#30af91" Padding="60">
<Entry Text="{Binding FirstName}" Placeholder="First Name"/>
<Entry Text="{Binding LastName}" Placeholder="Last Name"/>
<Entry Text="{Binding UserName}" Placeholder="Last Name"/>
<Entry Text="{Binding Email}" Placeholder="Email" />
<Entry Text="{Binding Password}" Placeholder="Password" IsPassword="True"/>
<Entry Text="{Binding ConfirmPassword}" Placeholder="Confirm Password" IsPassword="True"/>
<DatePicker MinimumDate="1/1/1948" MaximumDate="12/31/2007"/>
<!--Radio buttons for Gender
1. Male 2.Female-->
<!--Radio Buttons for UserRole
1. Admin 2.Participant-->
<Button Command="{Binding RegisterCommand}" Text="Register"/>
<Label Text="{Binding Message}" />
</StackLayout>
</code></pre>
| 0debug
|
Suppress SQL Queries logging in Entity Framework core : <p>I have a console .net core app that uses entity framework core.
The app uses logging framework to write to file and console:</p>
<pre><code> serviceProvider = new ServiceCollection()
.AddLogging()
.AddDbContext<DataStoreContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")))
.BuildServiceProvider();
//configure console logging
serviceProvider.GetService<ILoggerFactory>()
.AddConsole(LogLevel.Debug)
.AddSerilog();
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information()
.WriteTo.RollingFile(Path.Combine(Directory.GetCurrentDirectory(), "logs/vcibot-{Date}.txt"))
.WriteTo.RollingFile(Path.Combine(Directory.GetCurrentDirectory(), "logs/vcibot-errors-{Date}.txt"), LogEventLevel.Error)
.CreateLogger();
logger = serviceProvider.GetService<ILoggerFactory>()
.CreateLogger<Program>();
</code></pre>
<p>Min Level for file output is set to Information. But with this setup output also contains SQL queries, here is the example:</p>
<blockquote>
<p>2017-02-06 10:31:38.282 -08:00 [Information] Executed DbCommand (0ms)
[Parameters=[], CommandType='Text', CommandTimeout='30'] SELECT
[f].[BuildIdentifier], [f].[Branch], [f].[BuildDate],
[f].[StaticAssetSizeInKb] FROM [FileSizesHistoryEntries] AS [f]</p>
</blockquote>
<p>Is there a way to disable the SQL queries logging (log them only in Debug log level)</p>
| 0debug
|
Vuex 2.0 Dispatch versus Commit : <p>Can someone explain when you would use a dispatch versus a commit?</p>
<p>I understand a commit triggers mutation, and a dispatch triggers an action.</p>
<p>However, isn't a dispatch also a type of action? </p>
| 0debug
|
Take right selected value from select options from multiple select tables generated thro for loop : I've tried to get solutions from Google and earlier asked questions but questions and answers relate to only one select having multiple options. To clarify more, when I generate code thro for loop to create multiple select on screen and then use JavaScript to get selectedIndex or value and use alert to check if correct value is taken , then only value from selected option from first select table generated through for loop is shown repeated. Kindly find the code
...
<body>
<script>
... JSON code getting g named array throgh JSON.parse method
for (g=0; g<m.length; g++) {
n += " <select id=\"mySelect\" onchange=\"myFunction()\">";
n += " <option> - Select Option - </option>";
n += "<option>A</option>";
n += " <option>B</option>";
n += " <option>C</option>";
n += " <option>D</option>";
n += " </select>";
}
} // end of for loop
document.getElementById("demo").innerHTML = n;
.. in between some code
function myFunction() {
var y = document.getElementById("mySelect");
var j = y.selectedIndex;
var b = y.options[j].text;
alert ("Your answer is: " + b);
} // end of myFunction
</script>
<p id="demo"></p>
</body>
</html>
when execute this code, e.g. if array g is of length 5, then select-option is shown on screen five times, is perfect, when we select option from first select-options loop alert shows perfect selected option. e.g. if we select C from first select then alert shows C, but when we select options from other four select elements it still shows C ie selected option from first select elements.
we want our code to show right selected options from different 5 select elements generated throgh above for loop.
request to kindly help, since we have mined a lot for the answer.
Regards,
Guruprasad
| 0debug
|
Return to readline version 6.x in Homebrew to fix Postgresql? : <p>I'm no Homebrew expert but I think it has "upgraded" me from readline version 6.x to 7.0 sometime after <a href="http://ftp.gnu.org/gnu/readline/">9/15/16</a>:</p>
<pre><code>eat@eric-macbook:Homebrew$ brew info readline
readline: stable 7.0 (bottled) [keg-only]
Library for command-line editing
https://tiswww.case.edu/php/chet/readline/rltop.html
/usr/local/Cellar/readline/7.0 (45 files, 2M)
</code></pre>
<p>This has caused headaches for my 9.4.5 Homebrew version of Postgresql (I need the older 9.4 for comparability reasons):</p>
<pre><code>eat@eric-macbook:~$ psql --version
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib
Referenced from: /usr/local/Cellar/postgresql/9.4.5/bin/psql
Reason: image not found
Trace/BPT trap: 5
</code></pre>
<p>Unfortunately I can't find a 6.x version of readline on Homebrew to revert to - only 7.0 seems to be available(?).</p>
<p>My question is twofold:</p>
<ul>
<li>Is the the readline version mismatch the cause of my postgres/psql problem?</li>
<li>If so, how do I return to 6.x with Homebrew to correct the problem?</li>
</ul>
<p>Thank you in advance!</p>
| 0debug
|
C++, Sort One Vector Based On Another One : <p>The best example I've got is that I want to sort Names based on their Score.</p>
<pre><code>vector <string> Names {"Karl", "Martin", "Paul", "Jennie"};
vector <int> Score{45, 5, 14, 24};
</code></pre>
<p>So if I sort the score to {5, 14, 24, 45}, the names should also be sorted based on their score.</p>
| 0debug
|
Haskell: app build troubleshooting : How am I supposed to go about troubleshooting if an imported library won't build?
$ stack new any-tool simple
$ cd any-tool/
$ stack build
The boilerplate builds.
Adding `import Turtle` to `Main.hs`:
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Turtle
main :: IO ()
main = do
putStrLn "hello world"
Adding `turtle` to `any-tool.cabal`:
....
executable any-tool
hs-source-dirs: src
main-is: Main.hs
default-language: Haskell2010
build-depends: base >= 4.7 && < 5
, turtle
Won't build:
$ stack build
clock-0.7.2: configure
clock-0.7.2: build
hashable-1.2.6.1: download
hashable-1.2.6.1: configure
hashable-1.2.6.1: build
hashable-1.2.6.1: copy/register
Progress: 2/30
-- While building custom Setup.hs for package clock-0.7.2 using:
/home/alexey/.stack/setup-exe-cache/x86_64-linux-tinfo6-nopie/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0 build --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to: /home/alexey/spaces/haskell/any-tool/.stack-work/logs/clock-0.7.2.log
...
Looks like no particular surprise: turtle has a couple of dozen dependencies, any incompatibility and there she goes. The question is, what is my next step?
| 0debug
|
static void get_slice_data(ProresContext *ctx, const uint16_t *src,
int linesize, int x, int y, int w, int h,
DCTELEM *blocks, uint16_t *emu_buf,
int mbs_per_slice, int blocks_per_mb, int is_chroma)
{
const uint16_t *esrc;
const int mb_width = 4 * blocks_per_mb;
int elinesize;
int i, j, k;
for (i = 0; i < mbs_per_slice; i++, src += mb_width) {
if (x >= w) {
memset(blocks, 0, 64 * (mbs_per_slice - i) * blocks_per_mb
* sizeof(*blocks));
return;
}
if (x + mb_width <= w && y + 16 <= h) {
esrc = src;
elinesize = linesize;
} else {
int bw, bh, pix;
esrc = emu_buf;
elinesize = 16 * sizeof(*emu_buf);
bw = FFMIN(w - x, mb_width);
bh = FFMIN(h - y, 16);
for (j = 0; j < bh; j++) {
memcpy(emu_buf + j * 16,
(const uint8_t*)src + j * linesize,
bw * sizeof(*src));
pix = emu_buf[j * 16 + bw - 1];
for (k = bw; k < mb_width; k++)
emu_buf[j * 16 + k] = pix;
}
for (; j < 16; j++)
memcpy(emu_buf + j * 16,
emu_buf + (bh - 1) * 16,
mb_width * sizeof(*emu_buf));
}
if (!is_chroma) {
ctx->dsp.fdct(esrc, elinesize, blocks);
blocks += 64;
if (blocks_per_mb > 2) {
ctx->dsp.fdct(src + 8, linesize, blocks);
blocks += 64;
}
ctx->dsp.fdct(src + linesize * 4, linesize, blocks);
blocks += 64;
if (blocks_per_mb > 2) {
ctx->dsp.fdct(src + linesize * 4 + 8, linesize, blocks);
blocks += 64;
}
} else {
ctx->dsp.fdct(esrc, elinesize, blocks);
blocks += 64;
ctx->dsp.fdct(src + linesize * 4, linesize, blocks);
blocks += 64;
if (blocks_per_mb > 2) {
ctx->dsp.fdct(src + 8, linesize, blocks);
blocks += 64;
ctx->dsp.fdct(src + linesize * 4 + 8, linesize, blocks);
blocks += 64;
}
}
x += mb_width;
}
}
| 1threat
|
Middle function on pthon : Write a function middle which takes a list L as its argument, and returns the item in the middle position of L, when L has an odd length. Otherwise, middle should return 999999. For example, calling middle([8, 0, 100, 12, 1]) should return 100.
| 0debug
|
sqlzoo:what's wrong with the answer for 'The award for the first time (Economics) who is the winner?' : here is my answer,but the result shows wrong,i want to know why and the correct answer!!
SELECT winner FROM nobel
WHERE subject='Economics' AND yr IN (SELECT min('yr') FROM nobel
WHERE subject='Economics');
| 0debug
|
Can anyone help me? It's always showing "-----WELCOME----- ENTER TOTAL PERSON COUNT: Exception in thread "main" java.util.InputMismatchException " : import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("-----WELCOME-----");
Scanner input = new Scanner(System.in);
System.out.println("ENTER TOTAL PERSON COUNT: ");
long c = input.nextLong();
}
}
| 0debug
|
static int block_save_setup(QEMUFile *f, void *opaque)
{
int ret;
DPRINTF("Enter save live setup submitted %d transferred %d\n",
block_mig_state.submitted, block_mig_state.transferred);
qemu_mutex_lock_iothread();
init_blk_migration(f);
set_dirty_tracking();
qemu_mutex_unlock_iothread();
ret = flush_blks(f);
blk_mig_reset_dirty_cursor();
qemu_put_be64(f, BLK_MIG_FLAG_EOS);
return ret;
}
| 1threat
|
Setting up stylesheet for mobile in wordpress : I use WP 4.9.2 and Leto theme from aThemes. The site that I built on it looks great on bigger screens, but is really screwed up in mobile. I checked the stylesheet - the problem is related to the @media queries. I just don't seem to be setting in the right way ( the css). So, I need to know how to style or what css to use to set the thing up. The theme I use is [Leto][1], and I use Woocommerce plugin. So the responsiveness of the site is perfect on all pages but [this one, which in my opinion, utilizes Woocommerce][2]. Anyone anywhere any help is welcome.
Here is the `you can look up the whole stylesheet -->`[stylesheet][3]. You can download the theme in the first link, which was to [Leto][1].
[1]: https://athemes.com/theme/leto/
[2]: https://davoodkhan.net/opt2/my-account/
[3]: https://pastebin.com/XUntBwDi
| 0debug
|
Branching solution : <p>I'm working with visual studio and TFS and currently exploring the idea of branching and merging. To give a general overview of how I'm organizing one solution:</p>
<pre><code>MySolution
- MyProject 1
MyProject1TestBranch
- MyProject 2
- MyProject 3
</code></pre>
<p>I have been playing around with this and created a test branch and have been testing merging changes between "MyProject 1" and "MyProject1TestBranch".</p>
<p>Is it a good idea to be merging individual projects in a solution like this? What if several projects share code from another project? OR should I be branching the entire solution to keep it simple? </p>
<p>If it's best to branch an entire solution, what are the advantages / disadvantages of doing so? Should I perhaps be looking at using a completely different strategy entirely?</p>
<p>Appreciate any feedback. I guess at this stage I'm just looking for some verification as to whether or not I'm heading in the right direction</p>
| 0debug
|
How to check for command line arguments in GO : <p>I am writing a program that makes a simple web server in GO. The program should check for a port passed in the command line. If no port is given, I want to panic and exit the program. I thought this should work:</p>
<pre><code>if len(os.Args < 1) {
panic("No port number given!")
}
</code></pre>
<p>But for some reason it is saying mismatched types []string and int. How can I change this simple if so it works correctly? I am new to GO, so I am sorry if this is a simple question.</p>
| 0debug
|
AES 256 from Java : I'm trying to reproduce an encryption/decryption done in `Java` to a `Ruby` one.
`Java` code comes from [here][1]
I have a problem with the decryption. Here is my ruby code:
key = Digest::SHA256.digest(key)
aes = OpenSSL::Cipher.new('AES-256-CBC')
aes.decrypt
aes.key = Digest::SHA256.digest(key)
aes.update(secretdata) + aes.final
# => OpenSSL::Cipher::CipherError: bad decrypt
[1]: https://stackoverflow.com/a/992119/2616474
| 0debug
|
How is it possible to have two variables with same names - one is global and another one is local? : <p>I understand that two variable can be declared of same name in two distinct function.
how can we declare a variable within a function which is already declared in the global scope?</p>
| 0debug
|
void cpu_dump_state (CPUState *env, FILE *f, fprintf_function cpu_fprintf,
int flags)
{
#define RGPL 4
#define RFPL 4
int i;
cpu_fprintf(f, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR "
TARGET_FMT_lx " XER " TARGET_FMT_lx "\n",
env->nip, env->lr, env->ctr, env->xer);
cpu_fprintf(f, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " HF "
TARGET_FMT_lx " idx %d\n", env->msr, env->spr[SPR_HID0],
env->hflags, env->mmu_idx);
#if !defined(NO_TIMER_DUMP)
cpu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64
#if !defined(CONFIG_USER_ONLY)
" DECR %08" PRIu32
#endif
"\n",
cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env)
#if !defined(CONFIG_USER_ONLY)
, cpu_ppc_load_decr(env)
#endif
);
#endif
for (i = 0; i < 32; i++) {
if ((i & (RGPL - 1)) == 0)
cpu_fprintf(f, "GPR%02d", i);
cpu_fprintf(f, " %016" PRIx64, ppc_dump_gpr(env, i));
if ((i & (RGPL - 1)) == (RGPL - 1))
cpu_fprintf(f, "\n");
}
cpu_fprintf(f, "CR ");
for (i = 0; i < 8; i++)
cpu_fprintf(f, "%01x", env->crf[i]);
cpu_fprintf(f, " [");
for (i = 0; i < 8; i++) {
char a = '-';
if (env->crf[i] & 0x08)
a = 'L';
else if (env->crf[i] & 0x04)
a = 'G';
else if (env->crf[i] & 0x02)
a = 'E';
cpu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' ');
}
cpu_fprintf(f, " ] RES " TARGET_FMT_lx "\n",
env->reserve_addr);
for (i = 0; i < 32; i++) {
if ((i & (RFPL - 1)) == 0)
cpu_fprintf(f, "FPR%02d", i);
cpu_fprintf(f, " %016" PRIx64, *((uint64_t *)&env->fpr[i]));
if ((i & (RFPL - 1)) == (RFPL - 1))
cpu_fprintf(f, "\n");
}
cpu_fprintf(f, "FPSCR %08x\n", env->fpscr);
#if !defined(CONFIG_USER_ONLY)
cpu_fprintf(f, "SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FMT_lx " SDR1 "
TARGET_FMT_lx "\n", env->spr[SPR_SRR0], env->spr[SPR_SRR1],
env->sdr1);
#endif
#undef RGPL
#undef RFPL
}
| 1threat
|
VS used to open browser in new tab, now opens new browser : <p>I've been updating to the latest version of Visual Studio Preview and I think a setting has been changed.</p>
<p>When I start debugging an ASP.NET web app in Visual Studio 2017 15.7.0 Preview 4, VS opens a new browser.</p>
<p>I've had a similar issue before and it was a setting. This time it's not that setting. As you can see below, my Chrome debugging is already unchecked.
<a href="https://i.stack.imgur.com/MFdJv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MFdJv.png" alt="enter image description here"></a></p>
<p>I'm also aware of the check box to "Launch Browser" under Project -> Properties.</p>
<p>If I uncheck that no browser is opened. The previous behavior which I really liked was to open a new tab in my default browser i.e. Chrome.</p>
<p>How do I restore that behavior? I'd like VS to automatically open a new tab in Chrome and if I have no browser open, only then it should open up a new browser.</p>
| 0debug
|
concat ' ands string : At mssql I want concat ' and 1 string
Example: Concat ('My name',''')
Ouput : My name'
pls me, Thanks
| 0debug
|
uint32_t HELPER(xc)(CPUS390XState *env, uint32_t l, uint64_t dest,
uint64_t src)
{
int i;
unsigned char x;
uint32_t cc = 0;
HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n",
__func__, l, dest, src);
#ifndef CONFIG_USER_ONLY
if ((l > 32) && (src == dest) &&
(src & TARGET_PAGE_MASK) == ((src + l) & TARGET_PAGE_MASK)) {
mvc_fast_memset(env, l + 1, dest, 0);
return 0;
}
#else
if (src == dest) {
memset(g2h(dest), 0, l + 1);
return 0;
}
#endif
for (i = 0; i <= l; i++) {
x = cpu_ldub_data(env, dest + i) ^ cpu_ldub_data(env, src + i);
if (x) {
cc = 1;
}
cpu_stb_data(env, dest + i, x);
}
return cc;
}
| 1threat
|
void bdrv_eject(BlockDriverState *bs, int eject_flag)
{
BlockDriver *drv = bs->drv;
int ret;
if (!drv || !drv->bdrv_eject) {
ret = -ENOTSUP;
} else {
ret = drv->bdrv_eject(bs, eject_flag);
}
if (ret == -ENOTSUP) {
if (eject_flag)
bdrv_close(bs);
}
}
| 1threat
|
static char *spapr_vio_get_dev_name(DeviceState *qdev)
{
VIOsPAPRDevice *dev = VIO_SPAPR_DEVICE(qdev);
VIOsPAPRDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev);
char *name;
name = g_strdup_printf("%s@%x", pc->dt_name, dev->reg);
return name;
}
| 1threat
|
static void store_slice_c(uint8_t *dst, const int16_t *src,
int dst_stride, int src_stride,
int width, int height, int log2_scale)
{
int y, x;
#define STORE(pos) do { \
temp = ((src[x + y * src_stride + pos] << log2_scale) + d[pos]) >> 8; \
if (temp & 0x100) temp = ~(temp >> 31); \
dst[x + y * dst_stride + pos] = temp; \
} while (0)
for (y = 0; y < height; y++) {
const uint8_t *d = dither[y&7];
for (x = 0; x < width; x += 8) {
int temp;
STORE(0);
STORE(1);
STORE(2);
STORE(3);
STORE(4);
STORE(5);
STORE(6);
STORE(7);
}
}
}
| 1threat
|
Swift sometimes calls wrong method : <p>I noticed strange behaviour during working with Swift projects. I can't explain it other than Swift sometimes calls wrong method. It is very rare and even adding blank lines to the code could lead that this error is gone.</p>
<p>Let me explain in screenshots what I mean, next I use CoreData example of SwiftDDP project that can be found on Github, but such issues I was able to see in my own projects.</p>
<p>Here we at <code>Todos.swift:74</code> where you can see breakpoint, I expect that next call should be <code>getId()</code> method of <code>MeteorClient</code> class because it was already instantiated:</p>
<p><a href="https://i.stack.imgur.com/7F4mM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7F4mM.png" alt="Screenshot 1"></a></p>
<p>After Step Into as you can see the <code>ping()</code> of the same instance is called:</p>
<p><a href="https://i.stack.imgur.com/mMsDg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mMsDg.png" alt="Screenshot 2"></a></p>
<p>The next two steps into lead to <code>EXC_BAD_ACCESS</code> exception:</p>
<p><a href="https://i.stack.imgur.com/SGdYE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SGdYE.png" alt="Screenshot 3"></a></p>
<p>In my project I saw this issue fairly often before I stopped using singletons, so it could be related to Swift static memory usage or I don't understand something that is not surprising as I have little experience with multithreading and memory management.</p>
<p>My environment is:</p>
<ul>
<li>AppCode OC-145.184.11</li>
<li>Xcode Version 7.2.1 (7C1002)</li>
<li>iOS 9.2 SDK</li>
<li>Apple Swift version 2.1.1 (swiftlang-700.1.101.15 clang-700.1.81)</li>
</ul>
<p><strong>NOTE</strong>: Here I use AppCode but the same behavior I was able see in Xcode, and even more if the same issue that reproduces in Xcode could not reproduce in AppCode and vice versa.</p>
<p>Would be thankful if someone can explain this strange behaviour to me.</p>
<p>Thanks!</p>
| 0debug
|
void ff_print_debug_info(MpegEncContext *s, AVFrame *pict)
{
if ( s->avctx->hwaccel || !pict || !pict->mb_type
|| (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU))
return;
if (s->avctx->debug & (FF_DEBUG_SKIP | FF_DEBUG_QP | FF_DEBUG_MB_TYPE)) {
int x,y;
av_log(s->avctx, AV_LOG_DEBUG, "New frame, type: %c\n",
av_get_picture_type_char(pict->pict_type));
for (y = 0; y < s->mb_height; y++) {
for (x = 0; x < s->mb_width; x++) {
if (s->avctx->debug & FF_DEBUG_SKIP) {
int count = s->mbskip_table[x + y * s->mb_stride];
if (count > 9)
count = 9;
av_log(s->avctx, AV_LOG_DEBUG, "%1d", count);
}
if (s->avctx->debug & FF_DEBUG_QP) {
av_log(s->avctx, AV_LOG_DEBUG, "%2d",
pict->qscale_table[x + y * s->mb_stride]);
}
if (s->avctx->debug & FF_DEBUG_MB_TYPE) {
int mb_type = pict->mb_type[x + y * s->mb_stride];
if (IS_PCM(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "P");
else if (IS_INTRA(mb_type) && IS_ACPRED(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "A");
else if (IS_INTRA4x4(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "i");
else if (IS_INTRA16x16(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "I");
else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "d");
else if (IS_DIRECT(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "D");
else if (IS_GMC(mb_type) && IS_SKIP(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "g");
else if (IS_GMC(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "G");
else if (IS_SKIP(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "S");
else if (!USES_LIST(mb_type, 1))
av_log(s->avctx, AV_LOG_DEBUG, ">");
else if (!USES_LIST(mb_type, 0))
av_log(s->avctx, AV_LOG_DEBUG, "<");
else {
av_assert2(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));
av_log(s->avctx, AV_LOG_DEBUG, "X");
}
if (IS_8X8(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "+");
else if (IS_16X8(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "-");
else if (IS_8X16(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "|");
else if (IS_INTRA(mb_type) || IS_16X16(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, " ");
else
av_log(s->avctx, AV_LOG_DEBUG, "?");
if (IS_INTERLACED(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "=");
else
av_log(s->avctx, AV_LOG_DEBUG, " ");
}
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
}
if ((s->avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) ||
(s->avctx->debug_mv)) {
const int shift = 1 + s->quarter_sample;
int mb_y;
uint8_t *ptr;
int i;
int h_chroma_shift, v_chroma_shift, block_height;
const int width = s->avctx->width;
const int height = s->avctx->height;
const int mv_sample_log2 = 4 - pict->motion_subsample_log2;
const int mv_stride = (s->mb_width << mv_sample_log2) +
(s->codec_id == AV_CODEC_ID_H264 ? 0 : 1);
s->low_delay = 0;
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt,
&h_chroma_shift, &v_chroma_shift);
for (i = 0; i < 3; i++) {
size_t size= (i == 0) ? pict->linesize[i] * FFALIGN(height, 16):
pict->linesize[i] * FFALIGN(height, 16) >> v_chroma_shift;
s->visualization_buffer[i]= av_realloc(s->visualization_buffer[i], size);
memcpy(s->visualization_buffer[i], pict->data[i], size);
pict->data[i] = s->visualization_buffer[i];
}
pict->type = FF_BUFFER_TYPE_COPY;
pict->opaque= NULL;
ptr = pict->data[0];
block_height = 16 >> v_chroma_shift;
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
int mb_x;
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
const int mb_index = mb_x + mb_y * s->mb_stride;
if ((s->avctx->debug_mv) && pict->motion_val) {
int type;
for (type = 0; type < 3; type++) {
int direction = 0;
switch (type) {
case 0:
if ((!(s->avctx->debug_mv & FF_DEBUG_VIS_MV_P_FOR)) ||
(pict->pict_type!= AV_PICTURE_TYPE_P))
continue;
direction = 0;
break;
case 1:
if ((!(s->avctx->debug_mv & FF_DEBUG_VIS_MV_B_FOR)) ||
(pict->pict_type!= AV_PICTURE_TYPE_B))
continue;
direction = 0;
break;
case 2:
if ((!(s->avctx->debug_mv & FF_DEBUG_VIS_MV_B_BACK)) ||
(pict->pict_type!= AV_PICTURE_TYPE_B))
continue;
direction = 1;
break;
}
if (!USES_LIST(pict->mb_type[mb_index], direction))
continue;
if (IS_8X8(pict->mb_type[mb_index])) {
int i;
for (i = 0; i < 4; i++) {
int sx = mb_x * 16 + 4 + 8 * (i & 1);
int sy = mb_y * 16 + 4 + 8 * (i >> 1);
int xy = (mb_x * 2 + (i & 1) +
(mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
int mx = (pict->motion_val[direction][xy][0] >> shift) + sx;
int my = (pict->motion_val[direction][xy][1] >> shift) + sy;
draw_arrow(ptr, sx, sy, mx, my, width,
height, s->linesize, 100);
}
} else if (IS_16X8(pict->mb_type[mb_index])) {
int i;
for (i = 0; i < 2; i++) {
int sx = mb_x * 16 + 8;
int sy = mb_y * 16 + 4 + 8 * i;
int xy = (mb_x * 2 + (mb_y * 2 + i) * mv_stride) << (mv_sample_log2 - 1);
int mx = (pict->motion_val[direction][xy][0] >> shift);
int my = (pict->motion_val[direction][xy][1] >> shift);
if (IS_INTERLACED(pict->mb_type[mb_index]))
my *= 2;
draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
height, s->linesize, 100);
}
} else if (IS_8X16(pict->mb_type[mb_index])) {
int i;
for (i = 0; i < 2; i++) {
int sx = mb_x * 16 + 4 + 8 * i;
int sy = mb_y * 16 + 8;
int xy = (mb_x * 2 + i + mb_y * 2 * mv_stride) << (mv_sample_log2 - 1);
int mx = pict->motion_val[direction][xy][0] >> shift;
int my = pict->motion_val[direction][xy][1] >> shift;
if (IS_INTERLACED(pict->mb_type[mb_index]))
my *= 2;
draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
height, s->linesize, 100);
}
} else {
int sx= mb_x * 16 + 8;
int sy= mb_y * 16 + 8;
int xy= (mb_x + mb_y * mv_stride) << mv_sample_log2;
int mx= (pict->motion_val[direction][xy][0]>>shift) + sx;
int my= (pict->motion_val[direction][xy][1]>>shift) + sy;
draw_arrow(ptr, sx, sy, mx, my, width, height, s->linesize, 100);
}
}
}
if ((s->avctx->debug & FF_DEBUG_VIS_QP) && pict->motion_val) {
uint64_t c = (pict->qscale_table[mb_index] * 128 / 31) *
0x0101010101010101ULL;
int y;
for (y = 0; y < block_height; y++) {
*(uint64_t *)(pict->data[1] + 8 * mb_x +
(block_height * mb_y + y) *
pict->linesize[1]) = c;
*(uint64_t *)(pict->data[2] + 8 * mb_x +
(block_height * mb_y + y) *
pict->linesize[2]) = c;
}
}
if ((s->avctx->debug & FF_DEBUG_VIS_MB_TYPE) &&
pict->motion_val) {
int mb_type = pict->mb_type[mb_index];
uint64_t u,v;
int y;
#define COLOR(theta, r) \
u = (int)(128 + r * cos(theta * 3.141592 / 180)); \
v = (int)(128 + r * sin(theta * 3.141592 / 180));
u = v = 128;
if (IS_PCM(mb_type)) {
COLOR(120, 48)
} else if ((IS_INTRA(mb_type) && IS_ACPRED(mb_type)) ||
IS_INTRA16x16(mb_type)) {
COLOR(30, 48)
} else if (IS_INTRA4x4(mb_type)) {
COLOR(90, 48)
} else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type)) {
} else if (IS_DIRECT(mb_type)) {
COLOR(150, 48)
} else if (IS_GMC(mb_type) && IS_SKIP(mb_type)) {
COLOR(170, 48)
} else if (IS_GMC(mb_type)) {
COLOR(190, 48)
} else if (IS_SKIP(mb_type)) {
} else if (!USES_LIST(mb_type, 1)) {
COLOR(240, 48)
} else if (!USES_LIST(mb_type, 0)) {
COLOR(0, 48)
} else {
av_assert2(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));
COLOR(300,48)
}
u *= 0x0101010101010101ULL;
v *= 0x0101010101010101ULL;
for (y = 0; y < block_height; y++) {
*(uint64_t *)(pict->data[1] + 8 * mb_x +
(block_height * mb_y + y) * pict->linesize[1]) = u;
*(uint64_t *)(pict->data[2] + 8 * mb_x +
(block_height * mb_y + y) * pict->linesize[2]) = v;
}
if (IS_8X8(mb_type) || IS_16X8(mb_type)) {
*(uint64_t *)(pict->data[0] + 16 * mb_x + 0 +
(16 * mb_y + 8) * pict->linesize[0]) ^= 0x8080808080808080ULL;
*(uint64_t *)(pict->data[0] + 16 * mb_x + 8 +
(16 * mb_y + 8) * pict->linesize[0]) ^= 0x8080808080808080ULL;
}
if (IS_8X8(mb_type) || IS_8X16(mb_type)) {
for (y = 0; y < 16; y++)
pict->data[0][16 * mb_x + 8 + (16 * mb_y + y) *
pict->linesize[0]] ^= 0x80;
}
if (IS_8X8(mb_type) && mv_sample_log2 >= 2) {
int dm = 1 << (mv_sample_log2 - 2);
for (i = 0; i < 4; i++) {
int sx = mb_x * 16 + 8 * (i & 1);
int sy = mb_y * 16 + 8 * (i >> 1);
int xy = (mb_x * 2 + (i & 1) +
(mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
int32_t *mv = (int32_t *) &pict->motion_val[0][xy];
if (mv[0] != mv[dm] ||
mv[dm * mv_stride] != mv[dm * (mv_stride + 1)])
for (y = 0; y < 8; y++)
pict->data[0][sx + 4 + (sy + y) * pict->linesize[0]] ^= 0x80;
if (mv[0] != mv[dm * mv_stride] || mv[dm] != mv[dm * (mv_stride + 1)])
*(uint64_t *)(pict->data[0] + sx + (sy + 4) *
pict->linesize[0]) ^= 0x8080808080808080ULL;
}
}
if (IS_INTERLACED(mb_type) &&
s->codec_id == AV_CODEC_ID_H264) {
}
}
s->mbskip_table[mb_index] = 0;
}
}
}
}
| 1threat
|
static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp)
{
VT686PMState *s = DO_UPCAST(VT686PMState, dev, dev);
uint8_t *pci_conf;
pci_conf = s->dev.config;
pci_set_word(pci_conf + PCI_COMMAND, 0);
pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_FAST_BACK |
PCI_STATUS_DEVSEL_MEDIUM);
pci_set_long(pci_conf + 0x48, 0x00000001);
s->smb_io_base =((s->smb_io_base & 0xfff0) + 0x0);
pci_conf[0x90] = s->smb_io_base | 1;
pci_conf[0x91] = s->smb_io_base >> 8;
pci_conf[0xd2] = 0x90;
pm_smbus_init(&s->dev.qdev, &s->smb);
memory_region_add_subregion(get_system_io(), s->smb_io_base, &s->smb.io);
apm_init(dev, &s->apm, NULL, s);
memory_region_init(&s->io, OBJECT(dev), "vt82c686-pm", 64);
memory_region_set_enabled(&s->io, false);
memory_region_add_subregion(get_system_io(), 0, &s->io);
acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_cnt_init(&s->ar, &s->io, 2);
}
| 1threat
|
static int get_port(const struct sockaddr_storage *ss)
{
sockaddr_union ssu = (sockaddr_union){.storage = *ss};
if (ss->ss_family == AF_INET)
return ntohs(ssu.in.sin_port);
#if HAVE_STRUCT_SOCKADDR_IN6
if (ss->ss_family == AF_INET6)
return ntohs(ssu.in6.sin6_port);
#endif
return 0;
}
| 1threat
|
SearchView hints not showing for single character typed : <p>I'm working on an Android application written in Scala that uses <code>android.support.v7.widget.SearchView</code> inside the action bar that's overridden by <code>android.support.v7.widget.Toolbar</code>.</p>
<p>In the app, I need to enable search suggestions for that <code>SearchView</code>. So, every time I detect a query change, I check to see if suggestions need to be updated (code below). If the suggestions need to be updated a call is made to the backend and an <code>android.database.MatrixCursor</code> is created that contains the search suggestions and is set on the <code>SearchView</code>s suggestions adapter (code below).</p>
<p>The problem that I'm having with this is that the search hints will not show up when typing a <strong>single</strong> character. Typing two or more characters in the search box works perfectly. </p>
<p>I've tried with <code>android:searchSuggestThreshold</code> set to <code>0</code> and <code>1</code> in my XML config and I get the same result (like that option being ignored): search hints showing for multiple input characters, but not showing for a single character. </p>
<p>Am I missing something in the config/initialisation of the <code>SearchView</code>? Like an option other than <code>android:searchSuggestThreshold</code> which I can set? I've spent the last few hours on looking for alternative options but couldn't find any.</p>
<p>A possible solution that I see would be getting the <code>AutoCompleteTextView</code> backing the <code>SearchView</code>'s input and setting the threshold for it to 1, but it's an ugly (hack-ish) solution as the <code>AutoCompleteTextView</code> is not exposed by the <code>SearchView</code>s API.</p>
<p>Does anyone know an elegant solution for this? </p>
<p>Thank you!</p>
<p><strong>Detecting search term changes:</strong></p>
<pre><code>//this gets called whenever something is changed in the search box. "s" contains the entire search term typed in the search box
def onQueryTextChange(s: String): Boolean = {
//this checks to see if a call should be made to the backend to update suggestions
SearchSuggestionController.query(s)
//return false as we're not consuming the event
false
}
</code></pre>
<p><strong>Updating search suggestions:</strong></p>
<pre><code>def updateSuggestions(suggestions: Array[String]): Unit = {
val cursor = new MatrixCursor(Array(BaseColumns._ID, SearchManager.SUGGEST_COLUMN_TEXT_1), suggestions.length)
for{
i <- suggestions.indices
s = suggestions(i)
} cursor.addRow(Array[AnyRef](i.toString, s))
getActivity.runOnUiThread(() => {
searchSuggestionAdapter.changeCursor(cursor)
searchSuggestionAdapter.notifyDataSetChanged()
})
}
</code></pre>
<p><strong>Menu SearchView initialization:</strong></p>
<pre><code>override def onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) = {
inflater.inflate(R.menu.menu_products, menu)
val searchManager = getActivity.getSystemService(Context.SEARCH_SERVICE).asInstanceOf[SearchManager]
val actionItem = menu.findItem(R.id.action_search)
searchView = MenuItemCompat.getActionView(actionItem).asInstanceOf[SearchView]
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity.getComponentName))
searchView.setSubmitButtonEnabled(false)
SearchSuggestionController.onSuggestionsProvided_=(updateSuggestions)
searchView setSuggestionsAdapter searchSuggestionAdapter
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
//...
//change listener for detecting search changes presented above
//...
}
//...
//initialise other components
//...
}
</code></pre>
<p><strong>Searchable config:</strong></p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_name"
android:hint="@string/actionbar_products_search_hint"
android:searchSuggestThreshold="0"
android:searchSuggestSelection=" ?"/>
</code></pre>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.