problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
source insight 4087 can not parse smart point in boost : followings are my code:
class test{public:void fun(){}};int main(){boost::scoped_ptr<test> a;a.fun();}
when I click fun() in main ,souceInsight tell me symbol not found;
what can I do to fix it? thanks for you answer.
| 0debug
|
static void do_order_test(void)
{
Coroutine *co;
co = qemu_coroutine_create(co_order_test);
record_push(1, 1);
qemu_coroutine_enter(co, NULL);
record_push(1, 2);
g_assert(!qemu_in_coroutine());
qemu_coroutine_enter(co, NULL);
record_push(1, 3);
g_assert(!qemu_in_coroutine());
}
| 1threat
|
how to Styling classes with the same name in a file css : <p>i have one problem .I can not give each one a particular style.help me<a href="https://i.stack.imgur.com/WwMe6.png" rel="nofollow noreferrer">enter image description here</a></p>
| 0debug
|
In Redux, is it necessary to do deep copy : <p>The below object is <code>action.data</code> has a nested object <code>address</code></p>
<pre><code>{
name: 'Ben',
address: {
country: 'Australia',
state: 'NSW'
}
}
</code></pre>
<p>How should I handle it in the reducer?</p>
<pre><code>const rootReducer = (state = initState, action) {
switch(action.type) {
switch RECEIVE_DATA:
return {...state, data: action.data}
}
}
</code></pre>
<p>Can I do it as above? that I just assign the whole object to <code>data</code> without copying?</p>
<p>or</p>
<pre><code>const rootReducer = (state = initState, action) {
switch(action.type) {
switch RECEIVE_DATA:
const address = {...action.data.address}
const data = {...action.data, address}
return {...state, data}
}
}
</code></pre>
<p>Or should I do a deep copy of the object and assign it to <code>data</code>?
thanks</p>
| 0debug
|
How to check whether openpyxl package exist and if it is not exist how to download and install it within the script in Python 3.5.1? : I started writing python codes two weeks ago and until now I have manipulate some excel data after converting it to txt file. I want to manipulate excel data directly, so I need to install openpyxl package. However, my script will be used in many different places and computers (note that: all of them either OS X or a Linux distrubution) which might (probably do not) contain openpyxl package installed. I want my script to check whether this package exist, and if it does not exit, then download and install it.
For that purpose, as I searched and found that I could check the existence of the package by first importing the pip module and then pip.get_installed_distributions() method. However, I am not sure whether I am in a wrong way or not. Beside, I have no idea how to download and install openpyxl package "without leaving the script".
Would you like to help me ?
| 0debug
|
alert('Hello ' + user_input);
| 1threat
|
Kotlin TextView.text += : [I want to keep the text in the text view and add 0 to it][1]
i have tried txtCalc.text = "The text" + "0" and it doesn't work
[1]: https://i.stack.imgur.com/lDAVD.png
| 0debug
|
Is there any merit about assembly language? : <p>I heard some of developers use assembly language in embedded system. </p>
<p>I wonder what merit they have from learning assembly language and what field use assembly language. </p>
<p>Do you have any experience? </p>
| 0debug
|
After running the above code why I am getting just one o\p for type() function ? Why not for all three ? : x = input("enter a name = ")
y = input("enter a integer = ")
z = input("enter a decimal number = ")
type(x)
type(y)
type(z)
After running the above code why I am getting just one o\p for type() function ? Why not for all three ?
| 0debug
|
How to stop Golang from replacing double-quotes with backslashes when executing a DOS command : I am writing a program in Golang that will use Mozilla's Thunderbird email client to send email. The DOS command that should be executed is:
```DOS
start "" "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe" -compose "to='CloudCoin@Protonmail.com',subject='Subject1',body='Hello'" -offline
```
My Go code looks like this (command is the DOS command listed above) :
```Go
cmd := exec.Command("cmd.exe", "/C", command)
```
But I get an error:
```
Windows cannot find '\\'. Make sure you typed the name correctly, and then try again.
```
It seems that instead of trying to start "" it is trying to start \\\\. How can I keep my double-quotes?
| 0debug
|
malformed query, expected END_OBJECT but found FIELD_NAME error in Kibana (Elastic Search) : <p>I am running the following GET query within my Kibana Console and for some reason I am getting a error in the response window as follows :</p>
<p>// error </p>
<pre><code>[match] malformed query, expected [END_OBJECT] but found [FIELD_NAME]
</code></pre>
<p>Can anyone suggest why I am not able to use multiple match blocks within the 'should' section?</p>
<p>// response - if i take out one of the match blocks it works?? </p>
<pre><code>{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "[match] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
"line": 9,
"col": 13
}
],
"type": "parsing_exception",
"reason": "[match] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
"line": 9,
"col": 13
},
"status": 400
}
</code></pre>
<p>// my query</p>
<pre><code>GET _search
{
"query": {
"bool": {
"should": [
{
"match": {
"text": "facebook advice"
},
"match": {
"profile": "facebook advice"
}
}
],
"minimum_number_should_match": 1,
"filter": {
"term": {
"accountid": "22"
}
}
}
}
</code></pre>
| 0debug
|
void Y8950UpdateOne(FM_OPL *OPL, INT16 *buffer, int length)
{
int i;
int data;
OPLSAMPLE *buf = buffer;
UINT32 amsCnt = OPL->amsCnt;
UINT32 vibCnt = OPL->vibCnt;
UINT8 rythm = OPL->rythm&0x20;
OPL_CH *CH,*R_CH;
YM_DELTAT *DELTAT = OPL->deltat;
YM_DELTAT_DECODE_PRESET(DELTAT);
if( (void *)OPL != cur_chip ){
cur_chip = (void *)OPL;
S_CH = OPL->P_CH;
E_CH = &S_CH[9];
SLOT7_1 = &S_CH[7].SLOT[SLOT1];
SLOT7_2 = &S_CH[7].SLOT[SLOT2];
SLOT8_1 = &S_CH[8].SLOT[SLOT1];
SLOT8_2 = &S_CH[8].SLOT[SLOT2];
amsIncr = OPL->amsIncr;
vibIncr = OPL->vibIncr;
ams_table = OPL->ams_table;
vib_table = OPL->vib_table;
}
R_CH = rythm ? &S_CH[6] : E_CH;
for( i=0; i < length ; i++ )
{
ams = ams_table[(amsCnt+=amsIncr)>>AMS_SHIFT];
vib = vib_table[(vibCnt+=vibIncr)>>VIB_SHIFT];
outd[0] = 0;
if( DELTAT->portstate )
YM_DELTAT_ADPCM_CALC(DELTAT);
for(CH=S_CH ; CH < R_CH ; CH++)
OPL_CALC_CH(CH);
if(rythm)
OPL_CALC_RH(S_CH);
data = Limit( outd[0] , OPL_MAXOUT, OPL_MINOUT );
buf[i] = data >> OPL_OUTSB;
}
OPL->amsCnt = amsCnt;
OPL->vibCnt = vibCnt;
if( !DELTAT->portstate )
OPL->status &= 0xfe;
}
| 1threat
|
how to count comparison selectionsort? : how to count comparison selectionsort?
terms :
when the statements you perform to find the maximum value is 'true'
then count comparison.
The value to get the maximum value is held at the first element in the array, not at random.
i try with c
variable count position change - no work
new variable 'first' , first=sort[MAX] insert first for loop, - no work
int main()
{
int sort[10000],i,n,MAX,temp,count,first;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&sort[i]);
}
for(MAX=0;MAX<n;MAX++)
for(i=MAX+1;i<n;i++)
{
if(sort[MAX]>first)
{
count++;
temp=sort[MAX];
sort[MAX]=sort[i];
sort[i]=temp;
}
}
printf("%d ",count);
return 0;
}
| 0debug
|
static int vmstate_n_elems(void *opaque, VMStateField *field)
{
int n_elems = 1;
if (field->flags & VMS_ARRAY) {
n_elems = field->num;
} else if (field->flags & VMS_VARRAY_INT32) {
n_elems = *(int32_t *)(opaque+field->num_offset);
} else if (field->flags & VMS_VARRAY_UINT32) {
n_elems = *(uint32_t *)(opaque+field->num_offset);
} else if (field->flags & VMS_VARRAY_UINT16) {
n_elems = *(uint16_t *)(opaque+field->num_offset);
} else if (field->flags & VMS_VARRAY_UINT8) {
n_elems = *(uint8_t *)(opaque+field->num_offset);
}
return n_elems;
}
| 1threat
|
static void qemu_paio_submit(struct qemu_paiocb *aiocb)
{
aiocb->ret = -EINPROGRESS;
aiocb->active = 0;
mutex_lock(&lock);
if (idle_threads == 0 && cur_threads < max_threads)
spawn_thread();
TAILQ_INSERT_TAIL(&request_list, aiocb, node);
mutex_unlock(&lock);
cond_signal(&cond);
}
| 1threat
|
static int mv_read_packet(AVFormatContext *avctx, AVPacket *pkt)
{
MvContext *mv = avctx->priv_data;
AVIOContext *pb = avctx->pb;
AVStream *st = avctx->streams[mv->stream_index];
const AVIndexEntry *index;
int frame = mv->frame[mv->stream_index];
int ret;
uint64_t pos;
if (frame < st->nb_frames) {
index = &st->index_entries[frame];
pos = avio_tell(pb);
if (index->pos > pos)
avio_skip(pb, index->pos - pos);
else if (index->pos < pos) {
if (!pb->seekable)
return AVERROR(EIO);
ret = avio_seek(pb, index->pos, SEEK_SET);
if (ret < 0)
return ret;
}
ret = av_get_packet(pb, pkt, index->size);
if (ret < 0)
return ret;
pkt->stream_index = mv->stream_index;
pkt->pts = index->timestamp;
pkt->flags |= AV_PKT_FLAG_KEY;
mv->frame[mv->stream_index]++;
mv->eof_count = 0;
} else {
mv->eof_count++;
if (mv->eof_count >= avctx->nb_streams)
return AVERROR_EOF;
}
mv->stream_index++;
if (mv->stream_index >= avctx->nb_streams)
mv->stream_index = 0;
return 0;
}
| 1threat
|
converting csv to Json without pandas (python) : <p>I am a student and I have an assignment where I have to convert a csv file to Json format without using Pandas. Is there a way to achieve this in python?</p>
<p>Thank you,</p>
| 0debug
|
Smooth vue collapse transition on v-if : <p>I'm struggling with vue transitions trying to show / hide content using v-if smoothly. Whilst I understand the css classes and transitions, I can make the content appear 'smoothly' using things like opacity or translation etc...but once the animation is complete (or rather as it starts), any html sections below seem to 'jump'.</p>
<p>I'm trying to achieve the same affect as the Bootstrap 4 'collapse' class - click one of the top buttons here: <a href="https://getbootstrap.com/docs/4.0/components/collapse/" rel="noreferrer">https://getbootstrap.com/docs/4.0/components/collapse/</a></p>
<p>As the hidden section appears / disappears, all the html content 'slides' nicely with it.</p>
<p>Is this possible using Vue transition for content being shown using v-if? All the samples on the vue transitions docs, whilst having great css transition effects, have the below html 'jump' once the transition has started or is complete.</p>
<p>I've seen some pure js solutions using max-height - <a href="https://jsfiddle.net/wideboy32/7ap15qq0/134/" rel="noreferrer">https://jsfiddle.net/wideboy32/7ap15qq0/134/</a></p>
<p>and tried with vue: <a href="https://jsfiddle.net/wideboy32/eywraw8t/303737/" rel="noreferrer">https://jsfiddle.net/wideboy32/eywraw8t/303737/</a></p>
<pre><code>.smooth-enter-active, .smooth-leave-active {
transition: max-height .5s;
}
.smooth-enter, .smooth-leave-to {
max-height: 0 .5s;
}
</code></pre>
<p>Thanks!</p>
| 0debug
|
av_cold void ff_fft_init_mmx(FFTContext *s)
{
#if HAVE_YASM
int has_vectors = av_get_cpu_flags();
#if ARCH_X86_32
if (has_vectors & AV_CPU_FLAG_3DNOW && HAVE_AMD3DNOW) {
s->imdct_calc = ff_imdct_calc_3dnow;
s->imdct_half = ff_imdct_half_3dnow;
s->fft_calc = ff_fft_calc_3dnow;
}
if (has_vectors & AV_CPU_FLAG_3DNOWEXT && HAVE_AMD3DNOWEXT) {
s->imdct_calc = ff_imdct_calc_3dnowext;
s->imdct_half = ff_imdct_half_3dnowext;
s->fft_calc = ff_fft_calc_3dnowext;
}
#endif
if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE) {
s->imdct_calc = ff_imdct_calc_sse;
s->imdct_half = ff_imdct_half_sse;
s->fft_permute = ff_fft_permute_sse;
s->fft_calc = ff_fft_calc_sse;
s->fft_permutation = FF_FFT_PERM_SWAP_LSBS;
}
if (has_vectors & AV_CPU_FLAG_AVX && HAVE_AVX && s->nbits >= 5) {
s->imdct_half = ff_imdct_half_avx;
s->fft_calc = ff_fft_calc_avx;
s->fft_permutation = FF_FFT_PERM_AVX;
}
#endif
}
| 1threat
|
SQL Query Select That User Don't Have The Products : <p>Im trying to make a feature called "Edit Profile User" this</p>
<p>so in this feature im as Admin that can Edit User's Profile such as Name, username , DOB, etc. </p>
<p>in this feature we also can edit/Assign Product to this user. Example </p>
<p>User A have product :
1. Shampoo
2. Soap
3. Toothpick</p>
<p>and in server we've more than 3 product which are : Shampoo, Soap, Toothpick, Sponge, and Towel (5 items)</p>
<p>so the problem is : how to show the items that User have and automatically selected in select option, and also show the product that user didnt have / still available in server ? </p>
<p>so the example is :
User A Product :
1. Shampoo (selected)
2. Soap (selected)
3. Toothpick (selected)
4. Sponge
5. Towel</p>
<p>im still confuse and no idea , already a week searching on google .
and i use Chosen from harvest with multiple select </p>
<p>here's the source : <a href="https://harvesthq.github.io/chosen/" rel="nofollow noreferrer">https://harvesthq.github.io/chosen/</a></p>
<p>can anybody help me figure it out this problem ? im so stressed</p>
<p>*and this project based in Laravel </p>
| 0debug
|
What does the Atomics object do in JavaScript? : <p>This is the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics" rel="noreferrer">MDN documentation on Atomics</a>.</p>
<p>I can't understand how an atomic object could be used in a real-life situation or if they are for internal use only (i.e. not meant to be called at all).</p>
<p><strong>What does the <code>Atomics</code> object do in JavaScript? How can I use them?</strong></p>
| 0debug
|
Python psycopg2 DELETE data in AWS, no result, no error : <p>I try to delete data in a table in AWS. The code below works well if I pull data from AWS.</p>
<pre><code>import psycopg2
import pandas as pd
con=psycopg2.connect(dbname= My_Credential.....)
cur = con.cursor()
sql = """
DELETE FROM my_table
"""
cur.execute(sql)
</code></pre>
<p>After runing the code, I don't have any error message, but if I go check the data in that table, the data is still there. I wonder if I need to add any code like to COMMIT the change?</p>
<p>please advise. thanks</p>
| 0debug
|
static inline struct rgbvec interp_trilinear(const LUT3DContext *lut3d,
const struct rgbvec *s)
{
const struct rgbvec d = {s->r - PREV(s->r), s->g - PREV(s->g), s->b - PREV(s->b)};
const struct rgbvec c000 = lut3d->lut[PREV(s->r)][PREV(s->g)][PREV(s->b)];
const struct rgbvec c001 = lut3d->lut[PREV(s->r)][PREV(s->g)][NEXT(s->b)];
const struct rgbvec c010 = lut3d->lut[PREV(s->r)][NEXT(s->g)][PREV(s->b)];
const struct rgbvec c011 = lut3d->lut[PREV(s->r)][NEXT(s->g)][NEXT(s->b)];
const struct rgbvec c100 = lut3d->lut[NEXT(s->r)][PREV(s->g)][PREV(s->b)];
const struct rgbvec c101 = lut3d->lut[NEXT(s->r)][PREV(s->g)][NEXT(s->b)];
const struct rgbvec c110 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][PREV(s->b)];
const struct rgbvec c111 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][NEXT(s->b)];
const struct rgbvec c00 = lerp(&c000, &c100, d.r);
const struct rgbvec c10 = lerp(&c010, &c110, d.r);
const struct rgbvec c01 = lerp(&c001, &c101, d.r);
const struct rgbvec c11 = lerp(&c011, &c111, d.r);
const struct rgbvec c0 = lerp(&c00, &c10, d.g);
const struct rgbvec c1 = lerp(&c01, &c11, d.g);
const struct rgbvec c = lerp(&c0, &c1, d.b);
return c;
}
| 1threat
|
delete all new lines '\n' between two intances of a pattern using sed or awk : I have this input file as input.txt as shown below
In the output
I am trying to delete all new lines between the all occurances of pattern '------'.
Then delete that pattern from the output file
print_me(0034 bla bla bla bla bla bla bla bla bla.)
and insert a new line with string containing the number, such as
printername('0034')
input.txt
print_me 0034 bla bla bla bla bl
a bla bla bla bla.
------ -------------------------
print_me 0035 bla bla bla bla bl
a bla bla bla bla.
------ -------------------------
print_me 0037 bla bla bla bla bl
a bla bla bla bla.
------ -------------------------
print_me 0038 bla bla bla bla bl
a bla bla bla bla.
------ -------------------------
desired output.txt
printername('0034')
print_me(0034 bla bla bla bla bla bla bla bla bla.)
printername('0035')
print_me(0035 bla bla bla bla bla bla bla bla bla.)
printername('0036')
print_me(0036 bla bla bla bla bla bla bla bla bla.)
printername('0037')
print_me(0037 bla bla bla bla bla bla bla bla bla.)
printername('0038')
print_me(0038 bla bla bla bla bla bla bla bla bla.)
| 0debug
|
Error: Nock: No match for request : <p>I am receiving following error</p>
<pre><code>{ error:
{ Error: Nock: No match for request {
"method": "GET",
"url": "http://localhost:3000/admin/orders/30075889/transactions.json",
"headers": {
"content-type": "application/json",
"host": "localhost:3000"
}
} Got instead {
"method": "GET",
"url": "http://localhost:3000/admin/orders/30075889/transactions.json",
"headers": {
"content-type": "application/json",
"host": "localhost:3000"
}
}
</code></pre>
<p>The url is as expected, not sure what's wrong, any pointer?</p>
| 0debug
|
void cpu_stop_current(void)
{
}
| 1threat
|
Adding Variables in Tkinter : <p>I have been working on a tkinter calculator which adds 2 numbers together. I am planning on making this more advanced by adding in set numbers that when you type a number in it multiplies the number by that set varible. However, even after extensive research I cannot find some help for my particular issue. Here is my code:</p>
<pre><code>from Tkinter import *
root = Tk()
e1 = Entry(root)
e2 = Entry(root)
l = Label(root)
def callback():
total = sum(int(e.get()) for e in (e1, e2))
l.config(text="answer = %s" % total)
b = Button(root, text="add them", command=callback)
for widget in (e1, e2, l, b):
widget.pack()
b.mainloop()
</code></pre>
<p>Thanks.</p>
| 0debug
|
C# How to open an application that is in the taskbar? : I have Bluestacks opened in my taskbar, and I wanted to put it at the top of my screen, how can i do it?
InitializeComponent();
bool bluestack = false;
Process[] processlist = Process.GetProcesses();//getting all the processes and then if bluestacks is up switch to it else start bluestacks
foreach (Process theprocess in processlist)
{
if (theprocess.ProcessName == "Bluestacks")
bluestack = true;
}
this.Hide();
if (!bluestack)
{
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "C:/ProgramData/BlueStacks/Client/Bluestacks.exe");
Process.Start(new ProcessStartInfo(path));
}
else
{
}
| 0debug
|
How to select 3 columns and get data from mysql table? : I want to select 3 columns and want to retrieve data from the mysql table. All the columns exist on a single table called "orderTable". Please check what I am doing:
SELECT * FROM `orderTable` WHERE shipped = 0, reject_order = 0 AND customer_id = '26898'
Kindly Suggest what I am doing wrong. Your suggestions would be highly welcome. Thank You.
| 0debug
|
establishing a virtually bigger display buffer via code : I don't know if this is a programming question but it is a issue that may be possible to solve via code.
Given my little knowledge about how the display processing pipeline in our computers really work, I had the idea that the pixels on the monitor are allocated space in a memory buffer somewhere and this buffer size depends on the size of our screen. So, can we fake the computer into thinking that we have a bigger monitor than we actually have and take the advantage for instance screencasting at a larger resolution than we already have?
| 0debug
|
How to replace the How to replace the <div> <br></div> with space using javascript? with space using javascript? : In the body search all the instances of <div> <br></div> and replace with space using javascript
| 0debug
|
Closing the main menu on mouse out : <p>we are using default nav-bar of bootstrap in our website <a href="https://mihanmag.com" rel="nofollow noreferrer">mihanmag</a> </p>
<p>I want to close the menu, when mouse go out of it. can anyone help me?</p>
| 0debug
|
Laravel 5.4 redirection to custom url after login : <p>I am using Laravel Framework 5.4.10, and I am using the regular authentication that </p>
<pre><code>php artisan make:auth
</code></pre>
<p>provides. I want to protect the entire app, and to redirect users to /themes after login.</p>
<p>I have 4 controllers: ForgotPasswordController.php, LoginController.php, RegisterController.php and ResetPasswordController.php. I have edited this line into the last three:</p>
<pre><code>protected $redirectTo = '/themes';
</code></pre>
<p>This is the first line in my routes/web.php:</p>
<pre><code>Auth::routes();
</code></pre>
<p>I have added this function in my Controller.php:</p>
<pre><code> public function __construct()
{
$this->middleware('auth');
}
</code></pre>
<p>I have edited app/Http/Middleware/RedirectIfAuthenticated.php, so that the handle function looks like this:</p>
<pre><code>public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/themes');
}
return $next($request);
}
</code></pre>
<p>It's all fine, except when I click the Login button, I get redirected to "/", not "/themes". If I don't require authentication in the controllers (no __contruct function in Controller.php file), I get redirected OK at login. What am I doing wrong? </p>
| 0debug
|
static void curl_multi_timeout_do(void *arg)
{
#ifdef NEED_CURL_TIMER_CALLBACK
BDRVCURLState *s = (BDRVCURLState *)arg;
int running;
if (!s->multi) {
return;
}
aio_context_acquire(s->aio_context);
curl_multi_socket_action(s->multi, CURL_SOCKET_TIMEOUT, 0, &running);
curl_multi_check_completion(s);
aio_context_release(s->aio_context);
#else
abort();
#endif
}
| 1threat
|
my image is leaving space left side even though background size is cover : Ques: My image is leaving space on the left side instead of covering 100% on both the left and right side.
background-image: url("https://images.unsplash.com/photo-1491336238524-c990bd671778?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60");
background-size: cover;
background-repeat: no-repeat;
width: 100%;
height:100%;
| 0debug
|
How to create T4 text templates(.tt) in ASP.NET core on Visual Studio 2015 : <p>I want to create T4 text templates to achieve code generation. All the tutorials I found on msdn suggest following to add a new text template: <code>Add > New Item > Text Template</code>, (eg <a href="https://msdn.microsoft.com/en-us/library/dd820620.aspx">https://msdn.microsoft.com/en-us/library/dd820620.aspx</a>) but I don't see that option(<code>Text Template</code>) there. I am using ASP.NET core 1.0.</p>
<p>Is this issue related to VS2015 or ASP.NET core? If T4 templating is not supported in any of them, what's the best solution/alternative to achieve this? </p>
<p>(I want to generate typescript code from C# code), similar to this tutorial <a href="http://dotnetspeak.com/2015/02/typescript-models-creation-via-t4-templates">http://dotnetspeak.com/2015/02/typescript-models-creation-via-t4-templates</a></p>
| 0debug
|
ValueError: Series lengths must match to compare when matching dates in Pandas : <p>I apologize in advance for asking such a basic question but I am stumped.</p>
<p>This is a very simple, dummy example. I'm having some issue matching dates in Pandas and I can't figure out why.</p>
<pre><code>df = pd.DataFrame([[1,'2016-01-01'],
[2,'2016-01-01'],
[3,'2016-01-02'],
[4,'2016-01-03']],
columns=['ID', 'Date'])
df['Date'] = df['Date'].astype('datetime64')
</code></pre>
<p>Say I want to match row 1 in the above df.<br>
I know beforehand that I want to match ID <code>1</code>.<br>
And I know the date I want as well, and as a matter of fact, I'll extract that date directly from row 1 of the df to make it bulletproof.</p>
<pre><code>some_id = 1
some_date = df.iloc[1:2]['Date'] # gives 2016-01-01
</code></pre>
<p>So why doesn't this line work to return me row 1??</p>
<pre><code>df[(df['ID']==some_id) & (df['Date'] == some_date)]
</code></pre>
<p>Instead I get
<code>ValueError: Series lengths must match to compare</code><br>
which I understand, and makes sense...but leaves me wondering...how else can I compare dates in pandas if I can't compare one to many?</p>
| 0debug
|
Powershell Import-CSV where date-column -lt/ -gt (dd.MM.YYYY) : I am working on a small Powershell script to process CSV files.
CSV-File-Example:
lastname;firstname;birthday
| 0debug
|
static av_cold int j2kenc_init(AVCodecContext *avctx)
{
int i, ret;
Jpeg2000EncoderContext *s = avctx->priv_data;
Jpeg2000CodingStyle *codsty = &s->codsty;
Jpeg2000QuantStyle *qntsty = &s->qntsty;
s->avctx = avctx;
av_log(s->avctx, AV_LOG_DEBUG, "init\n");
memset(codsty->log2_prec_widths , 15, sizeof(codsty->log2_prec_widths ));
memset(codsty->log2_prec_heights, 15, sizeof(codsty->log2_prec_heights));
codsty->nreslevels2decode=
codsty->nreslevels = 7;
codsty->log2_cblk_width = 4;
codsty->log2_cblk_height = 4;
codsty->transform = avctx->prediction_method ? FF_DWT53 : FF_DWT97_INT;
qntsty->nguardbits = 1;
s->tile_width = 256;
s->tile_height = 256;
if (codsty->transform == FF_DWT53)
qntsty->quantsty = JPEG2000_QSTY_NONE;
else
qntsty->quantsty = JPEG2000_QSTY_SE;
s->width = avctx->width;
s->height = avctx->height;
for (i = 0; i < 3; i++)
s->cbps[i] = 8;
if (avctx->pix_fmt == AV_PIX_FMT_RGB24){
s->ncomponents = 3;
} else if (avctx->pix_fmt == AV_PIX_FMT_GRAY8){
s->ncomponents = 1;
} else{
s->planar = 1;
s->ncomponents = 3;
avcodec_get_chroma_sub_sample(avctx->pix_fmt,
s->chroma_shift, s->chroma_shift + 1);
}
ff_jpeg2000_init_tier1_luts();
ff_mqc_init_context_tables();
init_luts();
init_quantization(s);
if (ret=init_tiles(s))
return ret;
av_log(s->avctx, AV_LOG_DEBUG, "after init\n");
return 0;
}
| 1threat
|
ld: library not found for -lstdc++.6 : <p>After updating Xcode Version to 10.0 beta start getting "ld: library not found for -lstdc++.6" error. same code working fine in Xcode 9.2</p>
<p>Also updated macOS to 10.13.5</p>
| 0debug
|
Visual studio code suppress pep8 warnings : <p>How can I suppress pep8 warnings, in Visual studio code? What I want to do is to suppress E501 warning I don't want to get warnings where my code length is more than 80 chars. I'm using <a href="https://marketplace.visualstudio.com/items?itemName=donjayamanne.python" rel="noreferrer">Don Jayamanne's Python extension</a> and here is my config file for vscode</p>
<pre><code>{
"python.linting.pylintEnabled": false,
"python.linting.pep8Enabled": true,
"python.pythonPath": "/workspace/virtualenvs/abr/bin/python3",
"python.linting.enabled": true
}
</code></pre>
<p>I know that there is one another option <b>"python.linting.pep8Args": []</b> but I couldn't to get it work. I've installed pep8 on virtualenv</p>
<p>What I've already tried.</p>
<ol>
<li>"python.linting.pep8Args": ['--ignore=E501']</li>
<li>"Searched all visual studio code settings"</li>
</ol>
| 0debug
|
static void test_qemu_strtoull_full_max(void)
{
const char *str = g_strdup_printf("%lld", ULLONG_MAX);
uint64_t res = 999;
int err;
err = qemu_strtoull(str, NULL, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, ULLONG_MAX);
}
| 1threat
|
How to create a loop that will make regression models in R? : <p>I have data that looks something like this, there is time series data for many species over multiple years.</p>
<pre><code>Species year x
species1 2000 56
species1 2001 12
species1 2002 40
species2 2000 30
species2 2001 40
species2 2002 50
</code></pre>
<p>For each species, I would like to create a regression model of x vs year, I would also like to plot each model and find the slope of every trendline. To do this, I suspect I should use some type of loop.</p>
| 0debug
|
static int img_create(int argc, char **argv)
{
int c, ret = 0;
uint64_t img_size = -1;
const char *fmt = "raw";
const char *base_fmt = NULL;
const char *filename;
const char *base_filename = NULL;
char *options = NULL;
for(;;) {
c = getopt(argc, argv, "F:b:f:he6o:");
if (c == -1) {
break;
}
switch(c) {
case '?':
case 'h':
help();
break;
case 'F':
base_fmt = optarg;
break;
case 'b':
base_filename = optarg;
break;
case 'f':
fmt = optarg;
break;
case 'e':
error_report("option -e is deprecated, please use \'-o "
"encryption\' instead!");
return 1;
case '6':
error_report("option -6 is deprecated, please use \'-o "
"compat6\' instead!");
return 1;
case 'o':
options = optarg;
break;
}
}
if (optind >= argc) {
help();
}
filename = argv[optind++];
if (optind < argc) {
int64_t sval;
char *end;
sval = strtosz_suffix(argv[optind++], &end, STRTOSZ_DEFSUFFIX_B);
if (sval < 0 || *end) {
error_report("Invalid image size specified! You may use k, M, G or "
"T suffixes for ");
error_report("kilobytes, megabytes, gigabytes and terabytes.");
ret = -1;
goto out;
}
img_size = (uint64_t)sval;
}
if (options && !strcmp(options, "?")) {
ret = print_block_option_help(filename, fmt);
goto out;
}
ret = bdrv_img_create(filename, fmt, base_filename, base_fmt,
options, img_size, BDRV_O_FLAGS);
out:
if (ret) {
return 1;
}
return 0;
}
| 1threat
|
static int count_cow_clusters(BDRVQcow2State *s, int nb_clusters,
uint64_t *l2_table, int l2_index)
{
int i;
for (i = 0; i < nb_clusters; i++) {
uint64_t l2_entry = be64_to_cpu(l2_table[l2_index + i]);
QCow2ClusterType cluster_type = qcow2_get_cluster_type(l2_entry);
switch(cluster_type) {
case QCOW2_CLUSTER_NORMAL:
if (l2_entry & QCOW_OFLAG_COPIED) {
goto out;
}
break;
case QCOW2_CLUSTER_UNALLOCATED:
case QCOW2_CLUSTER_COMPRESSED:
case QCOW2_CLUSTER_ZERO:
break;
default:
abort();
}
}
out:
assert(i <= nb_clusters);
return i;
}
| 1threat
|
Control key not working on embedded terminal (mac os) : <p>I probably changed some setting by mistake, how do I get the control key to work again??</p>
<p><strong>Given</strong> I open a terminal in IntelliJ (2016.2.3)<br>
<strong>And</strong> I run a command that takes some time to run<br>
<strong>When</strong> I press <code>control + c</code> <br>
<strong>Then</strong> I should see the command being aborted <br>
<strong>Instead</strong> I see the letter c is typed instead.</p>
<p>Basically the <code>control</code> key is not working at all in the embedded terminal.</p>
<p>The same scenario works on <strong>webstorm</strong> and <strong>iterm</strong>. So it's definitely <strong>IntelliJ</strong></p>
| 0debug
|
static int qpel_motion_search(MpegEncContext * s,
int *mx_ptr, int *my_ptr, int dmin,
int src_index, int ref_index,
int size, int h)
{
MotionEstContext * const c= &s->me;
const int mx = *mx_ptr;
const int my = *my_ptr;
const int penalty_factor= c->sub_penalty_factor;
const int map_generation= c->map_generation;
const int subpel_quality= c->avctx->me_subpel_quality;
uint32_t *map= c->map;
me_cmp_func cmpf, chroma_cmpf;
me_cmp_func cmp_sub, chroma_cmp_sub;
LOAD_COMMON
int flags= c->sub_flags;
cmpf= s->dsp.me_cmp[size];
chroma_cmpf= s->dsp.me_cmp[size+1];
cmp_sub= s->dsp.me_sub_cmp[size];
chroma_cmp_sub= s->dsp.me_sub_cmp[size+1];
if(c->skip){
*mx_ptr = 0;
*my_ptr = 0;
return dmin;
}
if(c->avctx->me_cmp != c->avctx->me_sub_cmp){
dmin= cmp(s, mx, my, 0, 0, size, h, ref_index, src_index, cmp_sub, chroma_cmp_sub, flags);
if(mx || my || size>0)
dmin += (mv_penalty[4*mx - pred_x] + mv_penalty[4*my - pred_y])*penalty_factor;
}
if (mx > xmin && mx < xmax &&
my > ymin && my < ymax) {
int bx=4*mx, by=4*my;
int d= dmin;
int i, nx, ny;
const int index= (my<<ME_MAP_SHIFT) + mx;
const int t= score_map[(index-(1<<ME_MAP_SHIFT) )&(ME_MAP_SIZE-1)];
const int l= score_map[(index- 1 )&(ME_MAP_SIZE-1)];
const int r= score_map[(index+ 1 )&(ME_MAP_SIZE-1)];
const int b= score_map[(index+(1<<ME_MAP_SHIFT) )&(ME_MAP_SIZE-1)];
const int c= score_map[(index )&(ME_MAP_SIZE-1)];
int best[8];
int best_pos[8][2];
memset(best, 64, sizeof(int)*8);
#if 1
if(s->me.dia_size>=2){
const int tl= score_map[(index-(1<<ME_MAP_SHIFT)-1)&(ME_MAP_SIZE-1)];
const int bl= score_map[(index+(1<<ME_MAP_SHIFT)-1)&(ME_MAP_SIZE-1)];
const int tr= score_map[(index-(1<<ME_MAP_SHIFT)+1)&(ME_MAP_SIZE-1)];
const int br= score_map[(index+(1<<ME_MAP_SHIFT)+1)&(ME_MAP_SIZE-1)];
for(ny= -3; ny <= 3; ny++){
for(nx= -3; nx <= 3; nx++){
const int t2= nx*nx*(tr + tl - 2*t) + 4*nx*(tr-tl) + 32*t;
const int c2= nx*nx*( r + l - 2*c) + 4*nx*( r- l) + 32*c;
const int b2= nx*nx*(br + bl - 2*b) + 4*nx*(br-bl) + 32*b;
int score= ny*ny*(b2 + t2 - 2*c2) + 4*ny*(b2 - t2) + 32*c2;
int i;
if((nx&3)==0 && (ny&3)==0) continue;
score += 1024*(mv_penalty[4*mx + nx - pred_x] + mv_penalty[4*my + ny - pred_y])*penalty_factor;
for(i=0; i<8; i++){
if(score < best[i]){
memmove(&best[i+1], &best[i], sizeof(int)*(7-i));
memmove(&best_pos[i+1][0], &best_pos[i][0], sizeof(int)*2*(7-i));
best[i]= score;
best_pos[i][0]= nx + 4*mx;
best_pos[i][1]= ny + 4*my;
break;
}
}
}
}
}else{
int tl;
const int cx = 4*(r - l);
const int cx2= r + l - 2*c;
const int cy = 4*(b - t);
const int cy2= b + t - 2*c;
int cxy;
if(map[(index-(1<<ME_MAP_SHIFT)-1)&(ME_MAP_SIZE-1)] == (my<<ME_MAP_MV_BITS) + mx + map_generation && 0){
tl= score_map[(index-(1<<ME_MAP_SHIFT)-1)&(ME_MAP_SIZE-1)];
}else{
tl= cmp(s, mx-1, my-1, 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags); wrong if chroma me is different
}
cxy= 2*tl + (cx + cy)/4 - (cx2 + cy2) - 2*c;
assert(16*cx2 + 4*cx + 32*c == 32*r);
assert(16*cx2 - 4*cx + 32*c == 32*l);
assert(16*cy2 + 4*cy + 32*c == 32*b);
assert(16*cy2 - 4*cy + 32*c == 32*t);
assert(16*cxy + 16*cy2 + 16*cx2 - 4*cy - 4*cx + 32*c == 32*tl);
for(ny= -3; ny <= 3; ny++){
for(nx= -3; nx <= 3; nx++){
int score= ny*nx*cxy + nx*nx*cx2 + ny*ny*cy2 + nx*cx + ny*cy + 32*c; factor
int i;
if((nx&3)==0 && (ny&3)==0) continue;
score += 32*(mv_penalty[4*mx + nx - pred_x] + mv_penalty[4*my + ny - pred_y])*penalty_factor;
for(i=0; i<8; i++){
if(score < best[i]){
memmove(&best[i+1], &best[i], sizeof(int)*(7-i));
memmove(&best_pos[i+1][0], &best_pos[i][0], sizeof(int)*2*(7-i));
best[i]= score;
best_pos[i][0]= nx + 4*mx;
best_pos[i][1]= ny + 4*my;
break;
}
}
}
}
}
for(i=0; i<subpel_quality; i++){
nx= best_pos[i][0];
ny= best_pos[i][1];
CHECK_QUARTER_MV(nx&3, ny&3, nx>>2, ny>>2)
}
#if 0
const int tl= score_map[(index-(1<<ME_MAP_SHIFT)-1)&(ME_MAP_SIZE-1)];
const int bl= score_map[(index+(1<<ME_MAP_SHIFT)-1)&(ME_MAP_SIZE-1)];
const int tr= score_map[(index-(1<<ME_MAP_SHIFT)+1)&(ME_MAP_SIZE-1)];
const int br= score_map[(index+(1<<ME_MAP_SHIFT)+1)&(ME_MAP_SIZE-1)];
if(tl<br){
static int stats[7][7], count;
count++;
stats[4*mx - bx + 3][4*my - by + 3]++;
if(256*256*256*64 % count ==0){
for(i=0; i<49; i++){
if((i%7)==0) printf("\n");
printf("%6d ", stats[0][i]);
}
printf("\n");
}
}
#endif
#else
CHECK_QUARTER_MV(2, 2, mx-1, my-1)
CHECK_QUARTER_MV(0, 2, mx , my-1)
CHECK_QUARTER_MV(2, 2, mx , my-1)
CHECK_QUARTER_MV(2, 0, mx , my )
CHECK_QUARTER_MV(2, 2, mx , my )
CHECK_QUARTER_MV(0, 2, mx , my )
CHECK_QUARTER_MV(2, 2, mx-1, my )
CHECK_QUARTER_MV(2, 0, mx-1, my )
nx= bx;
ny= by;
for(i=0; i<8; i++){
int ox[8]= {0, 1, 1, 1, 0,-1,-1,-1};
int oy[8]= {1, 1, 0,-1,-1,-1, 0, 1};
CHECK_QUARTER_MV((nx + ox[i])&3, (ny + oy[i])&3, (nx + ox[i])>>2, (ny + oy[i])>>2)
}
#endif
#if 0
CHECK_QUARTER_MV(1, 3, mx-1, my-1)
CHECK_QUARTER_MV(1, 2, mx-1, my-1)
CHECK_QUARTER_MV(1, 1, mx-1, my-1)
CHECK_QUARTER_MV(2, 1, mx-1, my-1)
CHECK_QUARTER_MV(3, 1, mx-1, my-1)
CHECK_QUARTER_MV(0, 1, mx , my-1)
CHECK_QUARTER_MV(1, 1, mx , my-1)
CHECK_QUARTER_MV(2, 1, mx , my-1)
CHECK_QUARTER_MV(3, 1, mx , my-1)
CHECK_QUARTER_MV(3, 2, mx , my-1)
CHECK_QUARTER_MV(3, 3, mx , my-1)
CHECK_QUARTER_MV(3, 0, mx , my )
CHECK_QUARTER_MV(3, 1, mx , my )
CHECK_QUARTER_MV(3, 2, mx , my )
CHECK_QUARTER_MV(3, 3, mx , my )
CHECK_QUARTER_MV(2, 3, mx , my )
CHECK_QUARTER_MV(1, 3, mx , my )
CHECK_QUARTER_MV(0, 3, mx , my )
CHECK_QUARTER_MV(3, 3, mx-1, my )
CHECK_QUARTER_MV(2, 3, mx-1, my )
CHECK_QUARTER_MV(1, 3, mx-1, my )
CHECK_QUARTER_MV(1, 2, mx-1, my )
CHECK_QUARTER_MV(1, 1, mx-1, my )
CHECK_QUARTER_MV(1, 0, mx-1, my )
#endif
assert(bx >= xmin*4 && bx <= xmax*4 && by >= ymin*4 && by <= ymax*4);
*mx_ptr = bx;
*my_ptr = by;
}else{
*mx_ptr =4*mx;
*my_ptr =4*my;
}
return dmin;
}
| 1threat
|
How to show/hide content on button click? : <p>I have some content in p tag</p>
<pre><code><p>Some Content</p>
</code></pre>
<p>I also have two button 'Hide' and 'Show'.</p>
<pre><code><button>Hide</button>
<button>Show</button>
</code></pre>
<p>I want to hide the content if i click on 'Hide' button and show it again if clicked on 'Show' button. How to do it? Using JS or JQuery?</p>
| 0debug
|
void mips_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
int is_write, int is_user, uintptr_t retaddr)
{
MIPSCPU *cpu = MIPS_CPU(cs);
CPUMIPSState *env = &cpu->env;
env->CP0_BadVAddr = addr;
do_raise_exception(env, (is_write == 1) ? EXCP_AdES : EXCP_AdEL, retaddr);
}
| 1threat
|
Unfortunately Stopped android app : Logcat code
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aj.admin.bcombooks/com.aj.admin.bcombooks.MainActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class android.support.design.widget.NavigationView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class android.support.design.widget.NavigationView
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.aj.admin.bcombooks.MainActivity.onCreate(MainActivity.java:39)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class android.support.design.widget.NavigationView
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.aj.admin.bcombooks.MainActivity.onCreate(MainActivity.java:39)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.aj.admin.bcombooks.MainActivity.onCreate(MainActivity.java:39)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f07006b
at android.content.res.Resources.getValue(Resources.java:1351)
at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:330)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:195)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:188)
at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100)
at android.support.v7.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:491)
at android.support.design.internal.NavigationMenuPresenter$NavigationMenuAdapter.prepareMenuItems(NavigationMenuPresenter.java:525)
at android.support.design.internal.NavigationMenuPresenter$NavigationMenuAdapter.update(NavigationMenuPresenter.java:460)
at android.support.design.internal.NavigationMenuPresenter.updateMenuView(NavigationMenuPresenter.java:117)
at android.support.design.widget.NavigationView.inflateMenu(NavigationView.java:250)
at android.support.design.widget.NavigationView.<init>(NavigationView.java:172)
at android.support.design.widget.NavigationView.<init>(NavigationView.java:98)
at java.lang.reflect.Constructor.newInstance(Native Method)
can any one help me how i can solve this error my app is fine working on android 7.0 but when i install in android 6.0 then app does not work its stopped . Where My minimum SDK is 15 and Target SDK is 26
MainActivty code
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
Toolbar toolbar ;
TabLayout tabLayout ;
ViewPager viewPager ;
Pager fragmentAdapter ;
NavigationView navigationView;
private DrawerLayout drawerLayout;
private ActionBarDrawerToggle actionBarDrawerToggle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main); // This line shows error
drawerLayout = (DrawerLayout) findViewById(R.id.drawer);
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout,
R.string.open, R.string.close);
drawerLayout.addDrawerListener(actionBarDrawerToggle);
actionBarDrawerToggle.syncState();
because of this line my app is stopped in android 6.0 but its fine working on android 7.0 please help me to solve this problem .
| 0debug
|
int rom_add_file(const char *file, const char *fw_dir,
hwaddr addr, int32_t bootindex,
bool option_rom, MemoryRegion *mr)
{
MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
Rom *rom;
int rc, fd = -1;
char devpath[100];
rom = g_malloc0(sizeof(*rom));
rom->name = g_strdup(file);
rom->path = qemu_find_file(QEMU_FILE_TYPE_BIOS, rom->name);
if (rom->path == NULL) {
rom->path = g_strdup(file);
fd = open(rom->path, O_RDONLY | O_BINARY);
if (fd == -1) {
fprintf(stderr, "Could not open option rom '%s': %s\n",
rom->path, strerror(errno));
goto err;
rom->fw_dir = g_strdup(fw_dir);
rom->fw_file = g_strdup(file);
rom->addr = addr;
rom->romsize = lseek(fd, 0, SEEK_END);
if (rom->romsize == -1) {
fprintf(stderr, "rom: file %-20s: get size error: %s\n",
rom->name, strerror(errno));
goto err;
rom->datasize = rom->romsize;
rom->data = g_malloc0(rom->datasize);
lseek(fd, 0, SEEK_SET);
rc = read(fd, rom->data, rom->datasize);
if (rc != rom->datasize) {
fprintf(stderr, "rom: file %-20s: read error: rc=%d (expected %zd)\n",
rom->name, rc, rom->datasize);
goto err;
close(fd);
rom_insert(rom);
if (rom->fw_file && fw_cfg) {
const char *basename;
char fw_file_name[FW_CFG_MAX_FILE_PATH];
void *data;
basename = strrchr(rom->fw_file, '/');
if (basename) {
basename++;
} else {
basename = rom->fw_file;
snprintf(fw_file_name, sizeof(fw_file_name), "%s/%s", rom->fw_dir,
basename);
snprintf(devpath, sizeof(devpath), "/rom@%s", fw_file_name);
if ((!option_rom || mc->option_rom_has_mr) && mc->rom_file_has_mr) {
data = rom_set_mr(rom, OBJECT(fw_cfg), devpath);
} else {
data = rom->data;
fw_cfg_add_file(fw_cfg, fw_file_name, data, rom->romsize);
} else {
if (mr) {
rom->mr = mr;
snprintf(devpath, sizeof(devpath), "/rom@%s", file);
} else {
snprintf(devpath, sizeof(devpath), "/rom@" TARGET_FMT_plx, addr);
add_boot_device_path(bootindex, NULL, devpath);
return 0;
err:
if (fd != -1)
close(fd);
g_free(rom->data);
g_free(rom->path);
g_free(rom->name);
g_free(rom);
return -1;
| 1threat
|
How to efficiently concatenate multiple arrays in Ruby? : <p>I just wanted to concatenate multiple arrays in Ruby and couldn't find a satisfying way to do so.</p>
<p><strong>Example input:</strong></p>
<pre><code>foo = [1, 2, 3]
bar = [4, 5, 6]
baz = [7, 8, 9]
</code></pre>
<p><strong>Expected result:</strong> (without modifying the existing arrays)</p>
<pre><code>[1, 2, 3, 4, 5, 6, 7, 8, 9]
</code></pre>
<p>My actual arrays are <em>much</em> larger, so I'm interested in an efficient solution. There may also be more than three arrays, so a short syntax is preferred.</p>
<h3>What I have tried so far</h3>
<ul>
<li><p><code>foo + bar + baz</code> is the obvious one, it's concise and clear. But it is evaluated as <code>(foo + bar) + baz</code>. In other words: it creates an intermediate array <code>[1, 2, 3, 4, 5, 6]</code> that is thrown away after the whole operation. As noted in the <a href="http://ruby-doc.org/core-2.3.1/Array.html#method-i-2B" rel="noreferrer">documentation</a>:</p>
<blockquote>
<p>repeated use of <code>+=</code> on arrays can be quite inefficient</p>
</blockquote></li>
<li><p><code>[*foo, *bar, *baz]</code> basically inlines the elements which is not very efficient for large arrays, either. It also looks more like a hack to me.</p></li>
<li><p><code>[foo, bar, baz].flatten(1)</code> seems to be even worse than the above, performance wise.</p></li>
<li><p><code>[].concat(foo).concat(bar).concat(baz)</code> is the fastest, but it looks cumbersome and it needs multiple method invocations.</p></li>
</ul>
<p>Shouldn't there be a simple class method for such a basic task? Something like:</p>
<pre><code>Array.concat(foo, bar, baz)
</code></pre>
<p>Am I missing something obvious?</p>
| 0debug
|
Do I have to unsubscribe from ActivatedRoute (e.g. params) observables? : <p>I find many examples where <code>ActivatedRoute</code> Observables like <code>params</code> or <code>url</code> are subscribed but not unsubscribed.</p>
<pre><code>constructor(private route: ActivatedRoute) {}
ngOnInit() {
this.route.params
// (+) converts string 'id' to a number
.switchMap((params: Params) => this.service.getHero(+params['id']))
.subscribe((hero: Hero) => this.hero = hero);
}
</code></pre>
<ul>
<li>Are the route objects and subscriptions destroyed automagically and newly created for every component creation?</li>
<li>Do I have to care about unsubscribing from those <code>Observable</code>s?</li>
<li>If not, can you explain what happens with the tree of ActivatedRoute objects in <code>Router</code>.<code>routerState</code>?</li>
</ul>
| 0debug
|
static void release_drive(Object *obj, const char *name, void *opaque)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
BlockDriverState **ptr = qdev_get_prop_ptr(dev, prop);
if (*ptr) {
bdrv_detach_dev(*ptr, dev);
blockdev_auto_del(*ptr);
}
}
| 1threat
|
I am trying to set attributes string to UITableViewCell's text label I am using following code : NSDictionary * dic = [arrayForTableView objectAtIndex:indexPath.row];
NSNumber* lostPets = [dic valueForKey:@"lostPets"];
NSNumber * foundPets = [dic valueForKey:@"foundPets"];
NSString * breed = [dic valueForKey:@"breed"];
NSMutableAttributedString* message = [[NSMutableAttributedString alloc] init];
//set text
[message appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ (",breed]]];
[message appendAttributedString:[[NSAttributedString alloc] initWithString:[foundPets stringValue] attributes:@{
NSFontAttributeName : [UIColor greenColor]
}]];
[message appendAttributedString:[[NSAttributedString alloc] initWithString:@"), ("]];
[message appendAttributedString:[[NSAttributedString alloc] initWithString:[lostPets stringValue] attributes:@{
NSFontAttributeName : [UIColor redColor]
}]];
[message appendAttributedString:[[NSAttributedString alloc] initWithString:@")"]];
cell.textLabel.attributedText = message;
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UICachedDeviceRGBColor ctFontRef]: unrecognized selector sent to instance
I tried to debug the code but unable to get the point of crash. Kindly help.
Thanks in advance.
| 0debug
|
Not possible to transfer the data back to the ViewController (Swift) : It is not possible to transfer the data back to the ViewController **(From BarCodeScannerViewController to TableViewController)**
**SecondVC-(BarCodeScannerViewController.swift)**
@objc func SendDataBack(_ button:UIBarButtonItem!) {
if let presenter = self.presentingViewController as? TableViewController {
presenter.BarCode = "Test"
}
self.dismiss(animated: true, completion: nil)
}
**FirstVC-(TableViewController.swift)**
***// The result is (BarCode - )***
var BarCode: String = ""
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
print("BarCode - \(BarCode)")
}
| 0debug
|
Why does .loc have inclusive behavior for slices? : <p>For some reason, the following 2 calls to <code>iloc</code> / <code>loc</code> produce different behavior:</p>
<pre><code>>>> import pandas as pd
>>> df = pd.DataFrame(dict(A=range(3), B=range(3)))
>>> df.iloc[:1]
A B
0 0 0
>>> df.loc[:1]
A B
0 0 0
1 1 1
</code></pre>
<p>I understand that <code>loc</code> considers the row labels, while <code>iloc</code> considers the integer-based indices of the rows. But why is the upper bound for the <code>loc</code> call considered inclusive, while the <code>iloc</code> bound is considered exclusive?</p>
| 0debug
|
TypeError: 'int' object is not callable and I don't know why : <p>I got the above error on this code and I do not know why:</p>
<pre><code>P=input('P=')
r=input('r=')
n=input('n=')
t=input('t=')
P=int (P)
r=float (r)
n=int (n)
t=int (t)
A=P(1+(r/n))^(n*t)
print("A=",A)
</code></pre>
| 0debug
|
def repeat_tuples(test_tup, N):
res = ((test_tup, ) * N)
return (res)
| 0debug
|
How to present data from a server into graph? : <p>I'm try to make a project by using php:</p>
<p>The user input their health data and upload to the server.
Assume the server is local host.</p>
<p>Now how will I present those data to the user in graph?
What is the logic behind that?</p>
| 0debug
|
static void mpeg_decode_sequence_extension(Mpeg1Context *s1)
{
MpegEncContext *s = &s1->mpeg_enc_ctx;
int horiz_size_ext, vert_size_ext;
int bit_rate_ext;
skip_bits(&s->gb, 1);
s->avctx->profile = get_bits(&s->gb, 3);
s->avctx->level = get_bits(&s->gb, 4);
s->progressive_sequence = get_bits1(&s->gb);
s->chroma_format = get_bits(&s->gb, 2);
if (!s->chroma_format) {
s->chroma_format = 1;
av_log(s->avctx, AV_LOG_WARNING, "Chroma format invalid\n");
}
horiz_size_ext = get_bits(&s->gb, 2);
vert_size_ext = get_bits(&s->gb, 2);
s->width |= (horiz_size_ext << 12);
s->height |= (vert_size_ext << 12);
bit_rate_ext = get_bits(&s->gb, 12);
s->bit_rate += (bit_rate_ext << 18) * 400;
check_marker(&s->gb, "after bit rate extension");
s->avctx->rc_buffer_size += get_bits(&s->gb, 8) * 1024 * 16 << 10;
s->low_delay = get_bits1(&s->gb);
if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY)
s->low_delay = 1;
s1->frame_rate_ext.num = get_bits(&s->gb, 2) + 1;
s1->frame_rate_ext.den = get_bits(&s->gb, 5) + 1;
ff_dlog(s->avctx, "sequence extension\n");
s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO;
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_DEBUG,
"profile: %d, level: %d ps: %d cf:%d vbv buffer: %d, bitrate:%"PRId64"\n",
s->avctx->profile, s->avctx->level, s->progressive_sequence, s->chroma_format,
s->avctx->rc_buffer_size, s->bit_rate);
}
| 1threat
|
Iam trying to write an SQL server Query using joins and having some difficulty : Tables are explained in detail as below:
I have 3 tables:
Table A
(It serves as a mastertable for information about the employees)
EmployeeId(Primary key)|Employee Designation|EmployeeName|(More columns of employee data which is not relevant to this particular query)
Table B
(It serves as table where all employees who are accounted for are stored.For eg an employee who has reported sick or is on leave or has pregnancy leave, etc.Bottom line an employee which is not available)
EmployeeID(Primary key)(Also referencing master table A as foreign key)|AccountedFor||AccountedFordurationFrom(datetime)|AccountedForDurationTo(datetime)
Table C
(It serves as a table where excused data of employees are present.For eg we have our organization's time table spread as events,1st event is morning time conference,then 2nd is silence working time,3rd is brainstorming sessions etc.Now if an employee is excused for a particular event ,it is entered here)
EmployeeID|EventCode|Excuse_DurationFrom|Excuse Duration To|Any specific Detailment
Here EmployeeID and ExcusedForEventCode are both composite primary keys as it is possible to have same employeeId for multiple excuses,but the combination is always unique.
We have built some custom attendance management system and would require the following details:
1.We need to find all those employees who are neither accounted for nor excused for a specific event(this will be provided through front end) for a time duration selected through the front end.
2.The result of the above query will subsequently be used to compare with a biometric attendance machine logs which gives
EmployeeId|LogDate(datetime)|EventCodes as a separate table input to our database.(Mastertable A employeeId references this EmployeeId as foreign key)
It will be compared to find out true absentees for a particular event.ie All those employees who are neither accounted for,nor excuses for any particular event and who does not figure out in the biometric scan machine logs are absented for those time duration selected.We need the output of absentee like this
EmployeeId|Employee Designation|Employee Name|EventName(Have a separate table linking with EventCode)|Date&time(This would be per day per event report of employee who are absent from the selected time duration).
We have tried queries like:
select employeemastertable.employeeid,employeemastertable.Designation,employeemastertable.Name,EventCodes.EventCodeName as Eventexcusedfrom from employeemastertable inner join employeeexcusedforevents on employeemastertable.employeeid=employeeexcusedforevents.employeeid inner join EventCodes on employeeexcusedforEvents.ExcusedForEventCode=EventCodes.Eventcode left join employeeaccountedFor on employeemastertable.employeeid=employeeaccountedFor.employeeid where employeeexcusedforevents.ExcusedForEventCode!=1(Morning conference) and employeeaccountedFor.employeeid is null;
Names have been changed
I do understand this will give those employees who does not figure out in event Morning conference but even if i do left join instead of inner join between employeemastertable and employeeexcusedForevents and put employeeexcusedforevents.excusedforeventcode is null and employeeexcusedforevents.employeeid is null,i do get all those employees not present in the other two table,but the criteria of event is not satisfied.That means what if the employee is excused for the 2nd event as well in the organization.How would i cater for that in the above code?(PS this is only the 1st part of the equation i understand that,after this i need help for the other part also,where time duration and comparing with logs is concerned)?
urgent help would be appreciated fully
| 0debug
|
k-means clustering performance benchmarking : I have a 157 dimensional data-set with 688 data-points on which I need to perform clustering. Since k-means is the simplest, I decided to begin with that.
Here is the sklearn function call:
`KMeans(init='k-means++', n_clusters=4, n_init=10),name="k-means++", data=sales)`
Here are some performance numbers. Can someone please help me interpret them:
init time inertia homo compl v-meas ARI AMI num_clusters
k-means++ 0.06s 38967 0.262 0.816 0.397 0.297 0.250 4
k-means++ 0.05s 29825 0.321 0.847 0.466 0.338 0.306 6
k-means++ 0.07s 23131 0.411 0.836 0.551 0.430 0.393 8
k-means++ 0.09s 20566 0.636 0.817 0.715 0.788 0.621 10
k-means++ 0.09s 18695 0.534 0.794 0.638 0.568 0.513 12
k-means++ 0.11s 16805 0.773 0.852 0.810 0.916 0.760 14
k-means++ 0.11s 15297 0.822 0.775 0.798 0.811 0.761 16
I know that it is good to have a low inertia and higher homogeneity score, but I don't know what is a good threshold for these. For example, 15297 is the lowest inertia I get, but that happens when the number of clusters is set to 16. Is this good or bad?
Abbreviations:
`homo = homogeneity score, compl = completeness score, v_meas = v measure score, ARI = adjusted Randomness, AMI = adjusted mutual info `
| 0debug
|
static void decode_block(BinkAudioContext *s, short *out, int use_dct)
{
int ch, i, j, k;
float q, quant[25];
int width, coeff;
GetBitContext *gb = &s->gb;
if (use_dct)
skip_bits(gb, 2);
for (ch = 0; ch < s->channels; ch++) {
FFTSample *coeffs = s->coeffs_ptr[ch];
q = 0.0f;
coeffs[0] = get_float(gb) * s->root;
coeffs[1] = get_float(gb) * s->root;
for (i = 0; i < s->num_bands; i++) {
int value = get_bits(gb, 8);
quant[i] = expf(FFMIN(value, 95) * 0.15289164787221953823f) * s->root;
}
for (k = 0; s->bands[k] < 1; k++) {
q = quant[k];
}
i = 2;
while (i < s->frame_len) {
if (get_bits1(gb)) {
j = i + rle_length_tab[get_bits(gb, 4)] * 8;
} else {
j = i + 8;
}
j = FFMIN(j, s->frame_len);
width = get_bits(gb, 4);
if (width == 0) {
memset(coeffs + i, 0, (j - i) * sizeof(*coeffs));
i = j;
while (s->bands[k] < i)
q = quant[k++];
} else {
while (i < j) {
if (s->bands[k] == i)
q = quant[k++];
coeff = get_bits(gb, width);
if (coeff) {
if (get_bits1(gb))
coeffs[i] = -q * coeff;
else
coeffs[i] = q * coeff;
} else {
coeffs[i] = 0.0f;
}
i++;
}
}
}
if (CONFIG_BINKAUDIO_DCT_DECODER && use_dct) {
coeffs[0] /= 0.5;
ff_dct_calc (&s->trans.dct, coeffs);
s->dsp.vector_fmul_scalar(coeffs, coeffs, s->frame_len / 2, s->frame_len);
}
else if (CONFIG_BINKAUDIO_RDFT_DECODER)
ff_rdft_calc(&s->trans.rdft, coeffs);
}
s->fmt_conv.float_to_int16_interleave(out, (const float **)s->coeffs_ptr,
s->frame_len, s->channels);
if (!s->first) {
int count = s->overlap_len * s->channels;
int shift = av_log2(count);
for (i = 0; i < count; i++) {
out[i] = (s->previous[i] * (count - i) + out[i] * i) >> shift;
}
}
memcpy(s->previous, out + s->block_size,
s->overlap_len * s->channels * sizeof(*out));
s->first = 0;
}
| 1threat
|
static void do_audio_out(AVFormatContext *s, OutputStream *ost,
AVFrame *frame)
{
AVCodecContext *enc = ost->st->codec;
AVPacket pkt;
int got_packet = 0;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
#if 0
if (!check_recording_time(ost))
return;
#endif
if (frame->pts == AV_NOPTS_VALUE || audio_sync_method < 0)
frame->pts = ost->sync_opts;
ost->sync_opts = frame->pts + frame->nb_samples;
av_assert0(pkt.size || !pkt.data);
update_benchmark(NULL);
if (avcodec_encode_audio2(enc, &pkt, frame, &got_packet) < 0) {
av_log(NULL, AV_LOG_FATAL, "Audio encoding failed (avcodec_encode_audio2)\n");
exit_program(1);
}
update_benchmark("encode_audio %d.%d", ost->file_index, ost->index);
if (got_packet) {
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base);
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base);
if (pkt.duration > 0)
pkt.duration = av_rescale_q(pkt.duration, enc->time_base, ost->st->time_base);
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "encoder -> type:audio "
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ost->st->time_base),
av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->st->time_base));
}
write_frame(s, &pkt, ost);
audio_size += pkt.size;
av_free_packet(&pkt);
}
}
| 1threat
|
Call function when input is changed on text box? : <p>I'm trying to create a button that changes color when username and password fields have both been entered with some sort of input (IE; neither username or password text boxes are empty)</p>
<p>Is there a way I can get a function to trigger when input of a text box is changed in NativeScript? I've asked at the NativeScript slack, among other sites but I don't seem to get a reply ever.</p>
<p>I thought this was a relatively simple request, especially when I'm using vanilla JS. Surely it must be simpler than using a framework such as Angular or Vue? </p>
<p>I do not want to use a framework, I am looking for a way to do this with plain JS. What have I tried? I've tried <code>onChange=""</code>, <code>textChange=""</code>, <code>change=""</code> but none seem to work.</p>
| 0debug
|
How are std::arrays of smart pointers initialized? : <p>I currently try to initialize the following array, Spot is a class that is defined elsewhere:</p>
<pre><code>static const int WIDTH = 7;
static const int HEIGHT = 6;
std::array<std::array<std::unique_ptr<Spot>, WIDTH>, HEIGHT> field;
</code></pre>
<p>When trying to initialize it:</p>
<pre><code> for (int i = 0; i < HEIGHT; i++) {
for (int j = 0; j < WIDTH; j++) {
field.at(i).at(j) = std::make_unique<Spot>(new Spot());
}
}
</code></pre>
<p>it states that Spot* cannot be converted to const Spot &, which makes pretty much sense.</p>
<p>Google is not really helpful here, as the questions either deal with </p>
<pre><code>std::unique_ptr<T> [] or
std::uniqe_ptr<std::array<T>> but not with
std::array<std::unique_ptr<T>>
</code></pre>
<p>So, how do you achieve that? Is that even a thing? Or are you not supposed to use std::arrays with smart pointers at all?</p>
| 0debug
|
Create a time object? : <p>I have a vast number of files that need to be deleted past a certain date.
I can't use the datestamp of the file because the files are created some time before they are used. A file called OCT21.txt needs to be deleted a few days after October 21st, but it could have been created in May.</p>
<p>My question is: is it possible to convert the "OCT21" string into a format that the time module can use?</p>
| 0debug
|
static void uart_rx_reset(UartState *s)
{
s->rx_wpos = 0;
s->rx_count = 0;
qemu_chr_accept_input(s->chr);
s->r[R_SR] |= UART_SR_INTR_REMPTY;
s->r[R_SR] &= ~UART_SR_INTR_RFUL;
}
| 1threat
|
capture but don't consume characters in string : <p>is it possible? for example the capture group in the pattern '(ab)' wouldn't consume characters in the string 'ab' somehow?</p>
| 0debug
|
Jetbrains Rider + Visual Studio WPF : <p>I'm about to have a project with C# again. As I love using Jetbrains IDE's I came along Rider. The main problem for me is that I need a Windows Forms or WPF Designer for the GUI.</p>
<p>Is there any external software available for it or does anybody knows a convenient work pipeline to use Visual Studio only for WPF/WinForms and Rider as Code IDE? </p>
| 0debug
|
static void bt_vhci_add(int vlan_id)
{
struct bt_scatternet_s *vlan = qemu_find_bt_vlan(vlan_id);
if (!vlan->slave)
fprintf(stderr, "qemu: warning: adding a VHCI to "
"an empty scatternet %i\n", vlan_id);
bt_vhci_init(bt_new_hci(vlan));
}
| 1threat
|
Is any way to generate a multiplataform exe/executable from a python file? : <p>I want to convert a .py file into a multiplataform (Windows, Linux,..) onefile (without librarys or other folders) executable file for using it without a Python installation.</p>
| 0debug
|
Is it necessary to use Class in Python every time You write a complex Program : <p>I have a like 50 lines code of python program converted into exe using pyinstaller</p>
<p>So is it necessary for me to use class in my python program ? because it works perfectly fine without class</p>
| 0debug
|
Multiply by transposing rows by date in R : I want to convert this table :
[![enter image description here][1]][1]
to that table with **R**
[![enter image description here][2]][2]
In brief : converting the time periods between start date and end date to months table vertically
Thanks!
[1]: https://i.stack.imgur.com/7s8SQ.png
[2]: https://i.stack.imgur.com/rXYbp.png
| 0debug
|
pp_context_t *pp_get_context(int width, int height, int cpuCaps){
PPContext *c= memalign(32, sizeof(PPContext));
int i;
int stride= (width+15)&(~15);
memset(c, 0, sizeof(PPContext));
c->cpuCaps= cpuCaps;
if(cpuCaps&PP_FORMAT){
c->hChromaSubSample= cpuCaps&0x3;
c->vChromaSubSample= (cpuCaps>>4)&0x3;
}else{
c->hChromaSubSample= 1;
c->vChromaSubSample= 1;
}
reallocBuffers(c, width, height, stride);
c->frameNum=-1;
return c;
}
| 1threat
|
how too summary values in specyfic range : $srv2 = 0;
foreach ($result as $value) {
for($i = 0; $i >= 11 && $i <= 20; $i++){
$srv2 += $value['words_count'];
}
if ($i > 20)
{
break;
}
}
Can sameone tell me what is wrong ? I want to summarry all values in range 11-20 included 11.
| 0debug
|
Python3 pass lists to function with functools.lru_cache : <p>I want to cache a function that takes a list as a parameter, but when I try to do so with the <a href="https://docs.python.org/3/library/functools.html#functools.lru_cache" rel="noreferrer"><code>functools.lru_cache</code></a> decorator, it fails with <code>TypeError: unhashable type: 'list'</code>.</p>
<pre><code>
import functools
@functools.lru_cache()
def example_func(lst):
return sum(lst) + max(lst) + min(lst)
print(example_func([1, 2]))
</code></pre>
| 0debug
|
int ff_jpeg2000_init_component(Jpeg2000Component *comp,
Jpeg2000CodingStyle *codsty,
Jpeg2000QuantStyle *qntsty,
int cbps, int dx, int dy,
AVCodecContext *avctx)
{
int reslevelno, bandno, gbandno = 0, ret, i, j;
uint32_t csize;
if (codsty->nreslevels2decode <= 0) {
av_log(avctx, AV_LOG_ERROR, "nreslevels2decode %d invalid or uninitialized\n", codsty->nreslevels2decode);
return AVERROR_INVALIDDATA;
}
if (ret = ff_jpeg2000_dwt_init(&comp->dwt, comp->coord,
codsty->nreslevels2decode - 1,
codsty->transform))
return ret;
if (av_image_check_size(comp->coord[0][1] - comp->coord[0][0],
comp->coord[1][1] - comp->coord[1][0], 0, avctx))
return AVERROR_INVALIDDATA;
csize = (comp->coord[0][1] - comp->coord[0][0]) *
(comp->coord[1][1] - comp->coord[1][0]);
if (comp->coord[0][1] - comp->coord[0][0] > 32768 ||
comp->coord[1][1] - comp->coord[1][0] > 32768) {
av_log(avctx, AV_LOG_ERROR, "component size too large\n");
return AVERROR_PATCHWELCOME;
}
if (codsty->transform == FF_DWT97) {
csize += AV_INPUT_BUFFER_PADDING_SIZE / sizeof(*comp->f_data);
comp->i_data = NULL;
comp->f_data = av_mallocz_array(csize, sizeof(*comp->f_data));
if (!comp->f_data)
} else {
csize += AV_INPUT_BUFFER_PADDING_SIZE / sizeof(*comp->i_data);
comp->f_data = NULL;
comp->i_data = av_mallocz_array(csize, sizeof(*comp->i_data));
if (!comp->i_data)
}
comp->reslevel = av_mallocz_array(codsty->nreslevels, sizeof(*comp->reslevel));
if (!comp->reslevel)
for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) {
int declvl = codsty->nreslevels - reslevelno;
Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno;
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
reslevel->coord[i][j] =
ff_jpeg2000_ceildivpow2(comp->coord_o[i][j], declvl - 1);
reslevel->log2_prec_width = codsty->log2_prec_widths[reslevelno];
reslevel->log2_prec_height = codsty->log2_prec_heights[reslevelno];
if (!reslevel->log2_prec_width || !reslevel->log2_prec_height) {
return AVERROR_INVALIDDATA;
}
if (reslevelno == 0)
reslevel->nbands = 1;
else
reslevel->nbands = 3;
if (reslevel->coord[0][1] == reslevel->coord[0][0])
reslevel->num_precincts_x = 0;
else
reslevel->num_precincts_x =
ff_jpeg2000_ceildivpow2(reslevel->coord[0][1],
reslevel->log2_prec_width) -
(reslevel->coord[0][0] >> reslevel->log2_prec_width);
if (reslevel->coord[1][1] == reslevel->coord[1][0])
reslevel->num_precincts_y = 0;
else
reslevel->num_precincts_y =
ff_jpeg2000_ceildivpow2(reslevel->coord[1][1],
reslevel->log2_prec_height) -
(reslevel->coord[1][0] >> reslevel->log2_prec_height);
reslevel->band = av_mallocz_array(reslevel->nbands, sizeof(*reslevel->band));
if (!reslevel->band)
for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++) {
ret = init_band(avctx, reslevel,
comp, codsty, qntsty,
bandno, gbandno, reslevelno,
cbps, dx, dy);
if (ret < 0)
return ret;
}
}
return 0;
}
| 1threat
|
How to plot a system of linear equations in python? : <p>I have a set of linear equations like: <code>2x+3y+4z = 3</code> and <code>3x+3y+2z = 0</code>. How to plot them and highlight the common are in Python?</p>
| 0debug
|
break circle into sections for heading : <p>I am attempting to break a circle into 3 sections given an angle, this angle determines where the sections will be, for more details on what the sections are search online for aircraft holding patterns.</p>
<p>I'm having trouble getting the logic to work correctly, in the situation where one of the sections spans both sides of 360 degrees. This is what I have so far. both radial and heading are known numbers, in my test case they're 310 and 70 respectively. The code is written in swift.</p>
<pre><code>func setEntryLimits(){
directHigh = abs((radial+110.0).truncatingRemainder(dividingBy: 360))
directLow = abs((radial-70.0).truncatingRemainder(dividingBy: 360))
parallelHigh = abs(radial.truncatingRemainder(dividingBy: 360))
parallelLow = abs((radial+110.0).truncatingRemainder(dividingBy: 360))
tearDropHigh = abs((radial-70.0).truncatingRemainder(dividingBy: 360))
tearDropLow = abs(radial.truncatingRemainder(dividingBy: 360))
turnHeadingDial()
}
func turnHeadingDial(){
var heading = value*360
inbound = radial + 180
if(tearDropHigh>360||parallelHigh>360||directHigh>360){
heading = heading+360
}
if(tearDropHigh<tearDropLow){
let tempT = tearDropLow
tearDropLow = tearDropHigh
tearDropHigh = tempT
}
if(parallelHigh<parallelLow){
let tempP = parallelLow
parallelLow = parallelHigh
parallelHigh = tempP
}
if(directHigh<directLow){
let tempD = directLow;
directLow = directHigh;
directHigh = tempD;
}
if(inbound>360){
inbound = inbound-360
}
if(heading<tearDropHigh&&heading>(tearDropLow)){
entryLabel.setText("Tear Drop")
test1.setText(String(tearDropHigh))
test2.setText(String(tearDropLow))
}
else if(heading<(parallelHigh)&&heading>parallelLow){
entryLabel.setText("Parallel")
test1.setText(String(parallelHigh))
test2.setText(String(parallelLow))
}
else if(heading<(directHigh)&&heading>directLow){
entryLabel.setText("Direct")
test1.setText(String(directHigh))
test2.setText(String(directLow))
}
else {
entryLabel.setText("calc error")
}
print(tearDropHigh," -tear- ",tearDropLow," ",parallelHigh," -parallel- ",parallelLow," ",directHigh," -direct- ",directLow)
headingLabel.setText(String(heading))
}
</code></pre>
| 0debug
|
How to add dynamic values to java new new Object[] with diffrent type of values : I am currently using like below, but i don't know how to add values dynamically to this array,
Object[] oParams = new Object[] {
Integer.valueOf(this.userId),
Date.valueOf(this.startDate),
Date.valueOf(this.endDate)
};
Thanks in advance.
| 0debug
|
How can I seperate data with typecasting in an array? : I want to add 2 different types in the same array of size 100x4.In the first column I want to add names of foods(with use of pointers) and in the second and third some numbers such as calories and hour of eating.(WITH TYPECASTING)
I've been trying for this many days but I cannot find any solution.Is there a way to fix this with typecasting?
#include <stdio.h>
int main(){
char *table[100][4];
int n=0;
int j;
for (j=0;j<4;j++){
if (j==0){
printf ("Add your food:\n");
scanf("%s",&table[n][j]);
}else if (j==1){
printf ("Add calories:\n");
(float) *table[n][j];
scanf("%d",&table[n][j]);
}else if (j==2){
(float) *table[n][j];
printf ("Add the time you ate:\n");
scanf("%.2f",&table[n][j]);
}else if (j==3){
printf ("Kati\n");
}
}
for (j=0;j<4;j++){
if (j==0){
printf ("food:%s",&table[n][j]);
}else if (j==1){
(float) *table[n][j];
printf ("calories:%f",*table[n][j]);
}else if (j==2){
(float) *table[n][j];
printf ("time you ate:%f",*table[n][j]);
}else if (j==3){
printf ("Kati\n");
}
}
}
| 0debug
|
iOS build size with Swift 3 and pods : <p>I just noticed cocoapods with Swift increases build size, however when I use same libraries manually then build size is normal.</p>
<p>I created a blank project with some pods and the build size goes to the 10MB and .app file is around 40MB.</p>
<p>I also notices that my .app file contains all my cocoapods frameworks
(around 37MB) by viewing "Package content".<a href="https://i.stack.imgur.com/KT9Zy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/KT9Zy.png" alt="enter image description here"></a></p>
<p>My podfile having these pods</p>
<blockquote>
<p>pod 'Alamofire', '~> 4.4'</p>
<p>pod 'SwiftyJSON'</p>
<p>pod 'IQKeyboardManagerSwift'</p>
<p>pod 'ActionSheetPicker-3.0'</p>
<p>pod 'Kingfisher'</p>
<p>pod 'JKNotificationPanel'</p>
</blockquote>
<p>My questions are</p>
<ol>
<li>why my .app file contains all framework, I guess it happens only with Swift and cocoapod (Correct me if I am wrong) ?</li>
<li>How can we reduce the size of build by using cocoapods with Swift</li>
</ol>
<p>Thanks in advance</p>
| 0debug
|
C++ opencv remove small areas : I managed to do what I need by finding a python code (I found it in stackexchange):
<code>gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
labelnum, labelimg, contours, GoCs = cv2.connectedComponentsWithStats(gray)
for label in xrange(1, labelnum):
x,y,w,h,size = contours[label]
if size <= N:
img_white[y:y+h, x:x+w] = 0
cv2.imwrite("img_filter.png", img_white)
</code>
It managed to remove small areas (small blobs and particles) by accessing contours elements.
I want to do it for C++. Is it possible? I found this function:
<code>
int connectedComponentsWithStats(InputArray image, OutputArray labels, OutputArray stats, OutputArray centroids, int connectivity=8, int ltype=CV_32S)</code>
But I don't see how to access the contours elements.
Any tip?
| 0debug
|
Number connect 2d array c : Number connect game,I am expecting the selected number to loop/move multiple times to connect another number.But I only manage to loop/move the number once,I am not sure why.I have attach an example below.I really need help.
Here's my code:
#include <stdio.h>
#include <stdlib.h>
char pname()
{
char name[20];
printf("\n Please key in your name : ");
scanf("%s",&name);
printf("***Good day %s, let's start the game...all the best!!!***\n\n", name);
printf("***Connect a pair of number[REMEMBER! Do not intersect the path]***\n\n");
}
/*gameboard function*/
int gameboard(char box[9][9])
{
int x,y;
/*Use for loop to Assign the inner element of the array*/
for(x = 0; x < 9; x++)
{
for(y = 0; y <9; y++)
{
box[x][y] ='_';
}
}
/*Use for loop to Assign the border of the array*/
for(x = 0; x < 9; x++)
{
box[0][x]='#';
box[x][8]='#';
box[x][0]='#';
box[8][x]='#';
}
}
/*Store the Random number in the game board*/
void rnum(char box[9][9])
{
/*Declare variables as int type*/
int r1,r2,r3,r4,x;
/*Declare variables as char type*/
char r='1';
srand( (unsigned) time(NULL));
/*generate random number between 1 and 7*/
for(x=0;x<7;x++)
{
r1 = 1 + rand()%7;
r2 = 1 + rand()%7;
r3 = 1 + rand()%7;
r4 = 1 + rand()%7;
box[r1][r2]= r + x;
box[r3][r4]= r + x;
}
}
void playgame(char box[9][9])
{
int x=0, y=0, choice2,a,b;
char input,num;
do{
printf("Please select a number (1-7) : ");
fflush(stdin);
scanf("%c",&num);
if(num=='0' ||num > '7')
{
printf("Invalid!\n");
printf("Please enter another number\n");
}
else
{
printf("\nNumer %i is currently selected!\n", num);
}
}while(num=='0' ||num > '7');
printf("\n[1]Move\n[2]Sign out\n");
printf("\nEnter choice: \n");
scanf("%d", &choice2);
for (a = 0; a < 9; a++)
{
for (b = 0; b < 9; b++)
{
if (box[a][b] == num)
{
x=a;
y=b;
}
}
}
switch(choice2)
{
case 1:
printf("Press 'e' to go up\n");
printf("Press 'd' to go right\n");
printf("Press 's' to go left\n");
printf("Press 'x' to go down\n");
printf("Press 'q' to give up\n");
fflush(stdin);
scanf("%c", &input);
if (input == 'e')
{
box[x-1][y] = num;
x--;
}
else if (input == 'd')
{
box[x][y+1] = num;
y++;
}
else if (input == 's')
{
box[x][y-1] = num;
y--;
}
else if (input == 'x')
{
box[x+1][y] = num;
x++;
}
else if(input == 'q'){
printf("Thank you!");
exit(0);
}
break;
case 2: printf("Bye!\n");
}
}
/*Main function*/
int main(void)
{
/*Declare variables as char type*/
char box[9][9];
/*Declare variables as char type*/
char name[20];
/*Declare variables as int type*/
int x,y,num,a;
system("COLOR E");
/*Display the Welcome greeting*/
printf("************* WELCOME TO NUMBER CONNECT ! ******************\n\n");
pname();
/*call the gameboard() function*/
gameboard(box);
/*call the rnum() function*/
rnum(box);
/*Display the gameboard*/
for(x = 0; x < 9; x++)
{
for(y = 0; y < 9; y++)
{
printf(" %c ",box[x][y]);
}
printf("\n\n");
}
/*Call the playgame() function*/
for(a=0;a<9;a++)
{
playgame(box);
for(x = 0; x < 9; x++)
{
for(y = 0; y < 9; y++)
{
printf(" %c ",box[x][y]);
}
printf("\n\n");
}
}
return 0;
}
[Number][1]
[1]: http://i.stack.imgur.com/Ng4Nt.jpg
| 0debug
|
Create an empty text file : <p>I've been reading and googling all over but I can't seem to find this simple answer. </p>
<p>I have a function that reads a file, but if the files doesn't exists it panics. What I want to do is a function that before reading, checks if the files exists, and if not, it creates an empty file. Here is what I have.</p>
<pre><code>func exists(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return true, err
}
</code></pre>
| 0debug
|
Regex for multi line search that should select text "abc" which comes before the text "xyz" and should not select anything except "abc" : <p>Regex for multi line search that should select text "abc" which comes before the text "xyz" and should not select anything except "abc"</p>
<p>suppose if the text is as below,</p>
<pre><code> aaaabbbb
abc
abc
lmn xyz
</code></pre>
<p>the regex should match only the text abc in 3rd line just above last line</p>
| 0debug
|
static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, int (*read_child)(), int ctx_size, enum MXFMetadataSetType type)
{
ByteIOContext *pb = mxf->fc->pb;
MXFMetadataSet *ctx = ctx_size ? av_mallocz(ctx_size) : mxf;
uint64_t klv_end = url_ftell(pb) + klv->length;
if (!ctx)
return -1;
while (url_ftell(pb) + 4 < klv_end) {
int tag = get_be16(pb);
int size = get_be16(pb);
uint64_t next = url_ftell(pb) + size;
UID uid = {0};
dprintf(mxf->fc, "local tag %#04x size %d\n", tag, size);
if (!size) {
av_log(mxf->fc, AV_LOG_ERROR, "local tag %#04x with 0 size\n", tag);
continue;
}
if (tag > 0x7FFF) {
int i;
for (i = 0; i < mxf->local_tags_count; i++) {
int local_tag = AV_RB16(mxf->local_tags+i*18);
if (local_tag == tag) {
memcpy(uid, mxf->local_tags+i*18+2, 16);
dprintf(mxf->fc, "local tag %#04x\n", local_tag);
PRINT_KEY(mxf->fc, "uid", uid);
}
}
}
if (ctx_size && tag == 0x3C0A)
get_buffer(pb, ctx->uid, 16);
else if (read_child(ctx, pb, tag, size, uid) < 0)
return -1;
url_fseek(pb, next, SEEK_SET);
}
if (ctx_size) ctx->type = type;
return ctx_size ? mxf_add_metadata_set(mxf, ctx) : 0;
}
| 1threat
|
static inline int copy_siginfo_to_user(target_siginfo_t *tinfo,
const target_siginfo_t *info)
{
tswap_siginfo(tinfo, info);
return 0;
}
| 1threat
|
static int do_token_setup(USBDevice *s, USBPacket *p)
{
int request, value, index;
int ret = 0;
if (p->len != 8)
memcpy(s->setup_buf, p->data, 8);
s->setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6];
s->setup_index = 0;
request = (s->setup_buf[0] << 8) | s->setup_buf[1];
value = (s->setup_buf[3] << 8) | s->setup_buf[2];
index = (s->setup_buf[5] << 8) | s->setup_buf[4];
if (s->setup_buf[0] & USB_DIR_IN) {
ret = s->info->handle_control(s, request, value, index,
s->setup_len, s->data_buf);
if (ret < 0)
return ret;
if (ret < s->setup_len)
s->setup_len = ret;
s->setup_state = SETUP_STATE_DATA;
} else {
if (s->setup_len == 0)
s->setup_state = SETUP_STATE_ACK;
else
s->setup_state = SETUP_STATE_DATA;
return ret;
| 1threat
|
How to set core profile context for OpenGL in glfw? : <p>I am looking for a way in c++ to do something like this <a href="https://stackoverflow.com/questions/25951198/opengl-glsl-3-30-in-ubuntu-14-10-mesa-10-1-3">OpenGL GLSL 3.30 in Ubuntu 14.10 mesa 10.1.3</a></p>
| 0debug
|
git commit hash in dockerfile as label : <p>How to add git commit hash or any other dynamically inferred value in Dockerfile.</p>
<pre><code>LABEL vcs-ref=$(git rev-parse --short HEAD)
</code></pre>
<p>Something like this?</p>
| 0debug
|
static int buf_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
{
QEMUBuffer *s = opaque;
ssize_t len = qsb_get_length(s->qsb) - pos;
if (len <= 0) {
return 0;
}
if (len > size) {
len = size;
}
return qsb_get_buffer(s->qsb, pos, len, buf);
}
| 1threat
|
A java program that generates 100 random numbers : <p>Can someone help me with this exercise? Write a program that generates 100 random numbers and stores each number into an integer array. For this program, you must meet the following technical requirements: 1) In main, generate the 100 random numbers and store each in an array 2) In main, ask the user to enter a number to see if it exists in the array 3) Write a function that takes the array and user number as input parameters and returns either true or false if the number does or does not exist in the array respectively 4) In main, call this function appropriately and use the result to print out to the user if the number they provided is in the array</p>
| 0debug
|
please help me out to understanding this array sorting (bubble sort) : how did it working when both the loop is starting from 0 and comparison between both indexes have the same value
public class BubbleSort {
public static void main(String[] args)
{
int arr[]={5,1,2,1,1,4,4,4,4,4,3};
for(int i=0;i<arr.length;i++)//i=0
{
for(int j=0;j<arr.length;j++)//j=0
{
if(arr[i]>arr[j])//i=5>j=5
{
int temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
for(int k=0;k<arr.length;k++)` `
System.out.println(arr[k]);
}
}
| 0debug
|
If block error handling in bash : <p>I have if statements with multiple lines of code in bash, sometimes while running the script any of lines of code thrown error message so could you please let me know how to handle errors. I just wanna catch the error and display some error message to identify, and also I do not want to stop the running scripts, since it has 7800 lines of code I wanna continue with the next steps. each test steps are inside if loop. I want to know how to handle errors inside the if loop which having series of lines of code.</p>
<p>Thank you so much for help.</p>
| 0debug
|
android studio imagebutton from internet : <p>i am programming an app with AndroidStudio and want to use an <strong>ImageButton</strong> to Display an Image. The Problem is, that this <strong>Image is from the Internet</strong> and I just found a method to use Pictures in the R.mipmap.*** for the ImageButton.</p>
<p>Does anyone have an idea how it may work</p>
<p>Thankyou</p>
<p>Prog Rammer</p>
| 0debug
|
static X86CPU *pc_new_cpu(const char *cpu_model, int64_t apic_id,
DeviceState *icc_bridge, Error **errp)
{
X86CPU *cpu = NULL;
Error *local_err = NULL;
if (icc_bridge == NULL) {
error_setg(&local_err, "Invalid icc-bridge value");
goto out;
}
cpu = cpu_x86_create(cpu_model, &local_err);
if (local_err != NULL) {
goto out;
}
qdev_set_parent_bus(DEVICE(cpu), qdev_get_child_bus(icc_bridge, "icc"));
object_property_set_int(OBJECT(cpu), apic_id, "apic-id", &local_err);
object_property_set_bool(OBJECT(cpu), true, "realized", &local_err);
out:
if (local_err) {
error_propagate(errp, local_err);
object_unref(OBJECT(cpu));
cpu = NULL;
}
return cpu;
}
| 1threat
|
SocketAddressLegacy *socket_parse(const char *str, Error **errp)
{
SocketAddressLegacy *addr;
addr = g_new0(SocketAddressLegacy, 1);
if (strstart(str, "unix:", NULL)) {
if (str[5] == '\0') {
error_setg(errp, "invalid Unix socket address");
goto fail;
} else {
addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
addr->u.q_unix.data = g_new(UnixSocketAddress, 1);
addr->u.q_unix.data->path = g_strdup(str + 5);
}
} else if (strstart(str, "fd:", NULL)) {
if (str[3] == '\0') {
error_setg(errp, "invalid file descriptor address");
goto fail;
} else {
addr->type = SOCKET_ADDRESS_LEGACY_KIND_FD;
addr->u.fd.data = g_new(String, 1);
addr->u.fd.data->str = g_strdup(str + 3);
}
} else if (strstart(str, "vsock:", NULL)) {
addr->type = SOCKET_ADDRESS_LEGACY_KIND_VSOCK;
addr->u.vsock.data = g_new(VsockSocketAddress, 1);
if (vsock_parse(addr->u.vsock.data, str + strlen("vsock:"), errp)) {
goto fail;
}
} else {
addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
addr->u.inet.data = g_new(InetSocketAddress, 1);
if (inet_parse(addr->u.inet.data, str, errp)) {
goto fail;
}
}
return addr;
fail:
qapi_free_SocketAddressLegacy(addr);
return NULL;
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.