problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static void virtio_balloon_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->init = virtio_balloon_init_pci;
k->exit = virtio_balloon_exit_pci;
k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
k->device_id = PCI_DEVICE_ID_VIRTIO_BALLOON;
k->revision = VIRTIO_PCI_ABI_VERSION;
k->class_id = PCI_CLASS_MEMORY_RAM;
dc->alias = "virtio-balloon";
dc->reset = virtio_pci_reset;
dc->props = virtio_balloon_properties;
}
| 1threat
|
export GATSBY_CONTENTFUL_OFFLINE=true : I am new to gatsby, Last 1 week i'm facing this problem when run the dev server
Try running setting GATSBY_CONTENTFUL_OFFLINE=true to see if we can serve from cache.
I am searching in after i got this line, Where to add this line in Gatsby
*****export GATSBY_CONTENTFUL_OFFLINE=true*****
| 0debug
|
Root access for Jupyter/iPython Notebook : <p>I'm trying to use the bash kernel in iPython/Jupyter notebook, but I need sudo access within the notebook itself.</p>
<p>I've tried <code>$ sudo jupyter notebook</code> to run the notebook as root, but that only returns:</p>
<pre><code>$ jupyter: 'notebook' is not a Jupyter command
</code></pre>
<p>So, I'm left with running <code>$ jupyter notebook</code> (unless there's a way to run Jupyter notebook as root).</p>
<p>I also can't do <code>su root</code> in the notebook itself because that requires an input and the notebook won't let me give an input.</p>
<p>Finally, there is allegedly an <code>--allow-root</code> option for Jupyter notebook:
<a href="http://jupyter-notebook.readthedocs.io/en/latest/config.html" rel="noreferrer">http://jupyter-notebook.readthedocs.io/en/latest/config.html</a></p>
<p>However, it looks like <code>--allow_root</code> is no longer an option. (I've tried modifying the config file by adding <code>NotebookApp.allow_root=True</code>, but that doesn't work.)</p>
<p>Any ideas guys? Maybe I'm doing something wrong?</p>
| 0debug
|
"plot.new has not been called yet" error in rmarkdown (Rstudio 1.0.44) : <p>I am using a recent version of Rstudio with an iMac</p>
<blockquote>
<p>Version 1.0.44 – © 2009-2016 RStudio, Inc. Mozilla/5.0 (Macintosh;
Intel Mac OS X 10_12_1) AppleWebKit/602.2.14 (KHTML, like Gecko)</p>
</blockquote>
<p>And I noticed the notebook function for rmarkdown files. When generating plots, the usual "Plots window" is not used any more, and the plots are generated just below the code chunk.</p>
<p>And I have an error for the following code: </p>
<pre><code>plot(seq(1,10,1))
abline(a=0,b=1)
</code></pre>
<p>The error is showed below the code chunk : </p>
<pre><code>Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) : plot.new has not been called yet
</code></pre>
<p>However, when knitting the whole rmarkdown file, there is no error.</p>
<p>So I would like to know how to avoid the error:</p>
<ul>
<li>by using another code</li>
<li>by using the "Plots window"</li>
<li>or another way.</li>
</ul>
| 0debug
|
static int get_video_buffer(AVFrame *frame, int align)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
int ret, i;
if (!desc)
return AVERROR(EINVAL);
if ((ret = av_image_check_size(frame->width, frame->height, 0, NULL)) < 0)
return ret;
if (!frame->linesize[0]) {
ret = av_image_fill_linesizes(frame->linesize, frame->format,
frame->width);
if (ret < 0)
return ret;
for (i = 0; i < 4 && frame->linesize[i]; i++)
frame->linesize[i] = FFALIGN(frame->linesize[i], align);
}
for (i = 0; i < 4 && frame->linesize[i]; i++) {
int h = frame->height;
if (i == 1 || i == 2)
h = -((-h) >> desc->log2_chroma_h);
frame->buf[i] = av_buffer_alloc(frame->linesize[i] * h);
if (!frame->buf[i])
goto fail;
frame->data[i] = frame->buf[i]->data;
}
if (desc->flags & PIX_FMT_PAL || desc->flags & PIX_FMT_PSEUDOPAL) {
av_buffer_unref(&frame->buf[1]);
frame->buf[1] = av_buffer_alloc(1024);
if (!frame->buf[1])
goto fail;
frame->data[1] = frame->buf[1]->data;
}
frame->extended_data = frame->data;
return 0;
fail:
av_frame_unref(frame);
return AVERROR(ENOMEM);
}
| 1threat
|
Python change pitch of wav file : <p>I need any python library to change pitch of my wav file without any raw audio data processing.
I spent couple hours to find it, but only found some strange raw data processing code snippets and video, that shows real-time pitch shift, but without source code.</p>
| 0debug
|
RegEx to extract english text in between html content string using javascript : I had a sample string like this.
<br> My first word, sentence
<div class='test'><span class='abc'></span>
</div> <br>between 1185–1667 <div> my second sentence, 1223 </div>
<span> my third word, asdf 1234 and fourth word</span>
I need a regular expression to extract English text in javascript, the result to be like this
var result=[
"My first word, sentence",
"between",
"my second sentence",
"my third word, asdf",
"and fourth word"
]
Appreciate someones help on how to achieve this result
| 0debug
|
How do i use while loop with variables : I want to loop between the choices that user has given as input and the choices are stored as variables,
A = "A"
S = "S"
D = "D"
F = "F"
action_input = input("\n ")
action_input1 = action_input.title()
while (action_input1 not in [A, S, D, F]) :
if action_input1 == A :
print("\n Required Result is : " + str(Ac))
elif action_input1 == S :
print("\n Required Result is : " + str(Sc))
elif action_input1 == D :
print("\n Required Result is : " + str(Dc))
elif action_input1 == F :
print("\n Required Result is : " + str(Fc))
else :
print("\n Please enter from the choices given above")
| 0debug
|
android RecyclerView crashing : <p>I am trying to learn. I am following this video <a href="https://www.youtube.com/watch?v=YL1VpGBj3R0" rel="nofollow noreferrer">https://www.youtube.com/watch?v=YL1VpGBj3R0</a></p>
<p>My adapter.java is:</p>
<pre><code> package com.example.rfr.listcards;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.List;
public class Adapter extends RecyclerView.Adapter<Adapter.myViewHolder> {
Context mContext;
List<item> mData;
public Adapter(Context mContext, List<item> mData) {
this.mContext = mContext;
this.mData = mData;
}
@Override
public myViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(mContext);
View v = inflater.inflate(R.layout.card_item, parent, false);
return new myViewHolder(v);
}
@Override
public void onBindViewHolder(myViewHolder holder, int position) {
holder.background_img.setImageResource(mData.get(position).getBackground());
holder.profile_photo.setImageResource(mData.get(position).getProfilePhoto());
holder.tv_title.setText(mData.get(position).getProfileName());
holder.tv_nbFollowers.setText(mData.get(position).getNbFollowers());
}
@Override
public int getItemCount() {
return mData.size();
}
public class myViewHolder extends RecyclerView.ViewHolder {
ImageView profile_photo, background_img;
TextView tv_title, tv_nbFollowers;
public myViewHolder(View itemView) {
super(itemView);
profile_photo = itemView.findViewById(R.id.profile_img);
background_img = itemView.findViewById(R.id.card_background);
tv_title = itemView.findViewById(R.id.card_title);
tv_nbFollowers = itemView.findViewById(R.id.card_nb_follower);
}
}
}
</code></pre>
<p>and the MainActivity.java is:</p>
<pre><code> package com.example.rfr.listcards;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Window;
import android.view.WindowManager;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// set the status bar background to transparetne
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
// setup recyclerView with the adapter
RecyclerView recyclerView = findViewById(R.id.rv_list);
List<item> mlist = new ArrayList<>();
mlist.add(new item(R.drawable.japon1, "Cities", R.drawable.a1, 2500));
mlist.add(new item(R.drawable.b2, "Cities", R.drawable.a2, 2500));
mlist.add(new item(R.drawable.b3, "Cities", R.drawable.a3, 2500));
mlist.add(new item(R.drawable.b4, "Cities", R.drawable.a4, 2500));
mlist.add(new item(R.drawable.b5, "Cities", R.drawable.a2, 2500));
mlist.add(new item(R.drawable.b6, "Cities", R.drawable.a1, 2500));
mlist.add(new item(R.drawable.b7, "Cities", R.drawable.a1, 2500));
mlist.add(new item(R.drawable.b7, "Cities", R.drawable.a1, 2500));
mlist.add(new item(R.drawable.b7, "Cities", R.drawable.a1, 2500));
Adapter adapter = new Adapter( this,mlist);
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager( this));
}
}
</code></pre>
<p>If a try the debbug mode, the app only crash if I place the brake point at the very last } of the MainActivity.java</p>
<p>Can you spot what is wrong?
My eyes already hurt just looking at this issue XD</p>
| 0debug
|
static void vc1_loop_filter(uint8_t* src, int step, int stride, int len, int pq)
{
int i;
int filt3;
for(i = 0; i < len; i += 4){
filt3 = vc1_filter_line(src + 2*step, stride, pq);
if(filt3){
vc1_filter_line(src + 0*step, stride, pq);
vc1_filter_line(src + 1*step, stride, pq);
vc1_filter_line(src + 3*step, stride, pq);
}
src += step * 4;
}
}
| 1threat
|
Flutter align button to bottom of Drawer : <p>I'm trying to have a Widget align to the bottom of my NavDrawer while still keeping a DrawerHeader and a list at the top of the Drawer. Here's what I'm trying:</p>
<pre><code>drawer: new Drawer(
child: new Column(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
new Text('Top'),
new Align(
alignment: FractionalOffset.bottomCenter,
child: new Text('Bottom'),
),
],
),
),
</code></pre>
<p>The bottom text should be aligned to the bottom of the drawer, but It isn't!</p>
| 0debug
|
How to make RxJava interval to perform action instantly : <p>Hello I am making observable to ask my server about its online/offline status every 15 seconds:</p>
<pre><code>public Observable<Response> repeatCheckServerStatus(int intervalSec, final String path) {
return Observable.interval(intervalSec, TimeUnit.SECONDS)
.flatMap(new Func1<Long, Observable<Response>>() {
@Override
public Observable<Response> call(Long aLong) {
return Observable.create(new Observable.OnSubscribe<Response>() {
@Override
public void call(Subscriber<? super Response> subscriber) {
try {
Response response = client.newCall(new Request.Builder()
.url(path + API_ACTION_CHECK_ONLINE_STATUS)
.header("Content-Type", "application/x-www-form-urlencoded")
.get()
.build()).execute();
subscriber.onNext(response);
subscriber.onCompleted();
if (!response.isSuccessful())
subscriber.onError(new Exception());
} catch (Exception e) {
subscriber.onError(e);
}
}
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
});
}
</code></pre>
<p>After I call this method, first execution of code will be after intervalSec time (15sec in my case). Looking at rxJava docummentation of interval method:</p>
<p><a href="http://reactivex.io/documentation/operators/interval.html" rel="noreferrer">http://reactivex.io/documentation/operators/interval.html</a></p>
<p>This is how it should be. </p>
<p>Question: is there any way to execute code instantly and then repeat in intervals?</p>
| 0debug
|
Haskell. Why is :info (:) returns the definition twice? : <p>I'm new to haskell.</p>
<p>If I type in GHCi (7.10.3):</p>
<pre><code>:info (:)
</code></pre>
<p>I get result:</p>
<pre><code>*** Parser:
data [] a = ... | a : [a] -- Defined in ‘GHC.Types’
infixr 5 :
data [] a = ... | a : [a] -- Defined in ‘GHC.Types’
infixr 5 :
</code></pre>
<p>Does it means that operator is defined twice?
I didn't find any suspicious things in the source =/</p>
| 0debug
|
Java using else if to assign a value : <p>I'm very new to programming and Java. I'm trying to use else if to assign a value to a variable if they selected the correct input. But whenever I try to compile it, it says it cannot find the variable.</p>
<pre><code>import java.util.Scanner;
public class TDEE
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
double tdee = 0.0;
System.out.print("Please enter your name: ");
String name = in.next();
System.out.print("Please enter your BMR: ");
double bmr = in.nextDouble();
System.out.print("Please enter your Gender (M/F): ");
String gender = in.next();
System.out.println();
// providing menu items
System.out.println("Select your activity level: ");
System.out.println("[0] Resting (Sleeping. Reclining)");
System.out.println("[1] Sedentary (Minimal Movement)");
System.out.println("[2] Light (Sitting, Standing)");
System.out.println("[3] Moderate (Light Manual Labor, Dancing, Riding Bike)");
System.out.println("[4] Very Active (Team Sports, Hard Manual Labor)");
System.out.println("[5] Extremely Active (Full-time Athlete, Heavy Manual Labor)");
System.out.println();
// accept user choice with a Scanner class method
System.out.print("Enter the number corresponding to your activty level(0,1,2,3,4, or 5): ");
String choice = in.next();
System.out.println();
if(choice.equalsIgnoreCase("0"))
{
double activityFactor = 1.0;
}
else if(choice.equalsIgnoreCase("1"))
{
double activityFactor = 1.3;
}
else if(choice.equalsIgnoreCase("2") && "M".equals(gender))
{
double activityFactor = 1.6;
}
else if(choice.equalsIgnoreCase("2") && "F".equals(gender))
{
double activityFactor = 1.5;
}
else if(choice.equalsIgnoreCase("3") && "M".equals(gender))
{
double activityFactor = 1.7;
}
else if(choice.equalsIgnoreCase("3") && "F".equals(gender))
{
double activityFactor = 1.6;
}
else if(choice.equalsIgnoreCase("4") && "M".equals(gender))
{
double activityFactor = 2.1;
}
else if(choice.equalsIgnoreCase("4") && "F".equals(gender))
{
double activityFactor = 1.9;
}
else if(choice.equalsIgnoreCase("5") && "M".equals(gender))
{
double activityFactor = 2.4;
}
else if(choice.equalsIgnoreCase("5") && "F".equals(gender))
{
double activityFactor = 2.2;
}
else
{
System.out.println("You did not choose a valid manu option.");
}
tdee = bmr * activityFactor;
System.out.println();
System.out.println("Name: " + name + " Gender: " + gender);
System.out.println("BMR: " + bmr + " Activity Factor: " + activityFactor);
System.out.println("TDEE: " + tdee);
}
}
</code></pre>
| 0debug
|
How to sort data in between two date using Angular.js : I need one help.I need to sort table data selecting two date using Angular.js.I am explaining my code below.
<div class="col-md-3">
<div class="input-group datepicker" date-format="yyyy-MM-dd" button-prev='<i class="fa fa-arrow-circle-left"></i>' button-next='<i class="fa fa-arrow-circle-right"></i>'>
<input type="text" name="birthdate" class="form-control" id="date" ng-model="date" placeholder="From date" />
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
<div class="col-md-3">
<div class=" input-group datepicker" date-format="yyyy-MM-dd" button-prev='<i class="fa fa-arrow-circle-left"></i>' button-next='<i class="fa fa-arrow-circle-right"></i>'>
<input type="text" name="birthdate" class="form-control" id="date" ng-model="date1" placeholder="To date" />
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
<tbody id="detailsstockid">
<tr ng-repeat="d in clickDetail">
<td>{{$index+1}}</td>
<td>{{d.rest_name}}</td>
<td>{{d.Android}}</td>
<td>{{d.IOS}}</td>
<td>{{d.resultant_counter}}</td>
<td>{{d.date}}</td>
</tr>
</tbody>
Here i have two datepicker field .When user will select `From date` and `To date` the record will fetch in between these two date including these dates also.Here i have also `d.date` which contains value like this `2016-05-21 15:15:44` from DB.as per this value i need to sort the table data.Please help me.
| 0debug
|
query = 'SELECT * FROM customers WHERE email = ' + email_input
| 1threat
|
Remove label section from paper-textarea : <p>I'd like to remove the extra space that the label takes up in a polymer text-area. Is this possible? Thank you.</p>
| 0debug
|
How to Rename a Unity Project? : <p>I want to change the name of a Unity project to something else such that Unity Editor shows the new name at the top or when I open a script using Visual Studio, it shows the new name at the top of VS. How to do that?</p>
<p>Does changing the project name change the game's name (the name that appears on top left corner of the game window)?</p>
<p>Does changing project name change the name of the game's executable file?</p>
| 0debug
|
static void cmd_read_cd(IDEState *s, uint8_t* buf)
{
int nb_sectors, lba, transfer_request;
nb_sectors = (buf[6] << 16) | (buf[7] << 8) | buf[8];
lba = ube32_to_cpu(buf + 2);
if (nb_sectors == 0) {
ide_atapi_cmd_ok(s);
return;
}
transfer_request = buf[9];
switch(transfer_request & 0xf8) {
case 0x00:
ide_atapi_cmd_ok(s);
break;
case 0x10:
ide_atapi_cmd_read(s, lba, nb_sectors, 2048);
break;
case 0xf8:
ide_atapi_cmd_read(s, lba, nb_sectors, 2352);
break;
default:
ide_atapi_cmd_error(s, ILLEGAL_REQUEST,
ASC_INV_FIELD_IN_CMD_PACKET);
break;
}
}
| 1threat
|
static inline void show_tags(WriterContext *wctx, AVDictionary *tags, int section_id)
{
AVDictionaryEntry *tag = NULL;
if (!tags)
return;
writer_print_section_header(wctx, section_id);
while ((tag = av_dict_get(tags, "", tag, AV_DICT_IGNORE_SUFFIX)))
writer_print_string(wctx, tag->key, tag->value, 0);
writer_print_section_footer(wctx);
}
| 1threat
|
Rename deployment in Kubernetes : <p>If I do <code>kubectl get deployments</code>, I get:</p>
<pre><code>$ kubectl get deployments
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
analytics-rethinkdb 1 1 1 1 18h
frontend 1 1 1 1 6h
queue 1 1 1 1 6h
</code></pre>
<p>Is it possible to rename the deployment to <code>rethinkdb</code>? I have tried googling <code>kubectl edit analytics-rethinkdb</code> and changing the name in the yaml, but that results in an error:</p>
<pre><code>$ kubectl edit deployments/analytics-rethinkdb
error: metadata.name should not be changed
</code></pre>
<p>I realize I can just <code>kubectl delete deployments/analytics-rethinkdb</code> and then do <code>kubectl run analytics --image=rethinkdb --command -- rethinkdb etc etc</code> but I feel like it should be possible to simply rename it, no?</p>
| 0debug
|
LiveData remove Observer after first callback : <p>How do I remove the observer after I receive the first result? Below are two code ways I've tried, but they both keep receiving updates even though I have removed the observer.</p>
<pre><code>Observer observer = new Observer<DownloadItem>() {
@Override
public void onChanged(@Nullable DownloadItem downloadItem) {
if(downloadItem!= null) {
DownloadManager.this.downloadManagerListener.onDownloadManagerFailed(null, "this item already exists");
return;
}
startDownload();
model.getDownloadByContentId(contentId).removeObservers((AppCompatActivity)context);
}
};
model.getDownloadByContentId(contentId).observeForever(observer);
</code></pre>
<hr>
<pre><code> model.getDownloadByContentId(contentId).observe((AppCompatActivity)context, downloadItem-> {
if(downloadItem!= null) {
this.downloadManagerListener.onDownloadManagerFailed(null, "this item already exists");
return;
}
startDownload();
model.getDownloadByContentId(contentId).removeObserver(downloadItem-> {});
} );
</code></pre>
| 0debug
|
Change TextView with EditText on Button Click in Fragment : i'm using textview to show my data in a form and then on button click i want the feilds becoming editable. Am doing this bcz i dont want edit field lines below my text whn it on view state and also hw to apply this in a fragment.
| 0debug
|
dump() missing 1 required positional argument: 'fp' in python json : <p>I am trying to prettify the json format but i am getting this error:</p>
<pre><code>import requests as tt
from bs4 import BeautifulSoup
import json
get_url=tt.get("https://in.pinterest.com/search/pins/?rs=ac&len=2&q=batman%20motivation&eq=batman%20moti&etslf=5839&term_meta[]=batman%7Cautocomplete%7Cundefined&term_meta[]=motivation%7Cautocomplete%7Cundefined")
soup=BeautifulSoup(get_url.text,"html.parser")
select_css=soup.select("script#jsInit1")[0]
for i in select_css:
print(json.dump(json.loads(i),indent=4,sort_keys=True))
</code></pre>
<p>Basically i want to extract this type of element :</p>
<pre><code>'orig': {'width': 1080, 'url': '', 'height': 1349},
</code></pre>
<p>I know i can do this with </p>
<pre><code>select_css.get('orig').get('url')
</code></pre>
<p>But i am not sure is this json element is nested element under any element ? That's why i am trying to prettify to get idea.</p>
| 0debug
|
static void coroutine_fn qed_need_check_timer_entry(void *opaque)
{
BDRVQEDState *s = opaque;
int ret;
assert(!s->allocating_acb);
trace_qed_need_check_timer_cb(s);
qed_acquire(s);
qed_plug_allocating_write_reqs(s);
ret = bdrv_co_flush(s->bs->file->bs);
qed_release(s);
if (ret < 0) {
qed_unplug_allocating_write_reqs(s);
return;
}
s->header.features &= ~QED_F_NEED_CHECK;
ret = qed_write_header(s);
(void) ret;
qed_unplug_allocating_write_reqs(s);
ret = bdrv_co_flush(s->bs);
(void) ret;
}
| 1threat
|
bash: the difference between "<" and "<<<" redirect : <p>This code in bash read and process lines in a variable </p>
<pre><code>while read -r line; do
echo "... $line ..."
done <<< "$list"
</code></pre>
<p>If i replace <<< with <, it does not work. Wonder why is that</p>
| 0debug
|
How do I convert a list to a string in Python? : <p>I would like to convert the result of the following:</p>
<pre><code>def main():
list = open('friends.txt').readlines()
list.sort()
f = open('friends_sorted.txt', 'w+')
f.write(str(list))
f.close()
if __name__ == '__main__':
main()
</code></pre>
<p>from</p>
<p>['David\n', 'Geri\n', 'Jessica\n', 'Joe\n', 'John\n', 'Rose\n']</p>
<p>to</p>
<p>David
<br>Geri
<br>Jessica
<br>Joe
<br>John
<br>Rose</p>
<p>--</p>
<p>How would I do this?</p>
| 0debug
|
static void setup_frame(int sig, struct target_sigaction *ka,
target_sigset_t *set, CPUCRISState *env)
{
struct target_signal_frame *frame;
abi_ulong frame_addr;
int err = 0;
int i;
frame_addr = get_sigframe(env, sizeof *frame);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto badframe;
__put_user(0x9c5f, frame->retcode+0);
__put_user(TARGET_NR_sigreturn,
frame->retcode + 1);
__put_user(0xe93d, frame->retcode + 2);
__put_user(set->sig[0], &frame->sc.oldmask);
if (err)
goto badframe;
for(i = 1; i < TARGET_NSIG_WORDS; i++) {
if (__put_user(set->sig[i], &frame->extramask[i - 1]))
goto badframe;
}
setup_sigcontext(&frame->sc, env);
env->regs[R_SP] = frame_addr;
env->regs[10] = sig;
env->pc = (unsigned long) ka->_sa_handler;
env->pregs[PR_SRP] = frame_addr + offsetof(typeof(*frame), retcode);
unlock_user_struct(frame, frame_addr, 1);
return;
badframe:
unlock_user_struct(frame, frame_addr, 1);
force_sig(TARGET_SIGSEGV);
}
| 1threat
|
Python returns MagicMock object instead of return_value : <p>I have a python file <code>a.py</code> which contains two classes <code>A</code> and <code>B</code>.</p>
<pre><code>class A(object):
def method_a(self):
return "Class A method a"
class B(object):
def method_b(self):
a = A()
print a.method_a()
</code></pre>
<p>I would like to unittest <code>method_b</code> in class <code>B</code> by mocking <code>A</code>. Here is the content of the file <code>testa.py</code> for this purpose:</p>
<pre><code>import unittest
import mock
import a
class TestB(unittest.TestCase):
@mock.patch('a.A')
def test_method_b(self, mock_a):
mock_a.method_a.return_value = 'Mocked A'
b = a.B()
b.method_b()
if __name__ == '__main__':
unittest.main()
</code></pre>
<p>I expect to get <code>Mocked A</code> in the output. But what I get is:</p>
<pre><code><MagicMock name='A().method_a()' id='4326621392'>
</code></pre>
<p>Where am I doing wrong?</p>
| 0debug
|
static av_cold int ljpeg_encode_init(AVCodecContext *avctx)
{
LJpegEncContext *s = avctx->priv_data;
int chroma_v_shift, chroma_h_shift;
if ((avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
avctx->pix_fmt == AV_PIX_FMT_YUV422P ||
avctx->pix_fmt == AV_PIX_FMT_YUV444P) &&
avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
av_log(avctx, AV_LOG_ERROR,
"Limited range YUV is non-standard, set strict_std_compliance to "
"at least unofficial to use it.\n");
return AVERROR(EINVAL);
}
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
s->scratch = av_malloc_array(avctx->width + 1, sizeof(*s->scratch));
ff_dsputil_init(&s->dsp, avctx);
ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);
av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift,
&chroma_v_shift);
if (avctx->pix_fmt == AV_PIX_FMT_BGR24) {
s->vsample[0] = s->hsample[0] =
s->vsample[1] = s->hsample[1] =
s->vsample[2] = s->hsample[2] = 1;
} else {
s->vsample[0] = 2;
s->vsample[1] = 2 >> chroma_v_shift;
s->vsample[2] = 2 >> chroma_v_shift;
s->hsample[0] = 2;
s->hsample[1] = 2 >> chroma_h_shift;
s->hsample[2] = 2 >> chroma_h_shift;
}
ff_mjpeg_build_huffman_codes(s->huff_size_dc_luminance,
s->huff_code_dc_luminance,
avpriv_mjpeg_bits_dc_luminance,
avpriv_mjpeg_val_dc);
ff_mjpeg_build_huffman_codes(s->huff_size_dc_chrominance,
s->huff_code_dc_chrominance,
avpriv_mjpeg_bits_dc_chrominance,
avpriv_mjpeg_val_dc);
return 0;
}
| 1threat
|
int ff_replaygain_export_raw(AVStream *st, int32_t tg, uint32_t tp,
int32_t ag, uint32_t ap)
{
AVReplayGain *replaygain;
if (tg == INT32_MIN && ag == INT32_MIN)
return 0;
replaygain = (AVReplayGain*)ff_stream_new_side_data(st, AV_PKT_DATA_REPLAYGAIN,
sizeof(*replaygain));
if (!replaygain)
return AVERROR(ENOMEM);
replaygain->track_gain = tg;
replaygain->track_peak = tp;
replaygain->album_gain = ag;
replaygain->album_peak = ap;
return 0;
}
| 1threat
|
set expandtab in .vimrc not taking effect : <p>For some reason the <code>set expandtab</code> command in my <code>.vimrc</code> file is not having any effect.</p>
<p>Here is my <code>.vimrc</code>:</p>
<pre><code>" tab settings
set expandtab
set smarttab
set softtabstop=2
set tabstop=2
set shiftwidth=2
set paste
</code></pre>
<p>However, when I run <code>vi</code> (no file name) the <code>:set</code> command emits:</p>
<pre><code>:set
--- Options ---
helplang=en shiftwidth=2 ttyfast
paste tabstop=2 ttymouse=xterm2
fileencodings=ucs-bom,utf-8,default,latin1
</code></pre>
<p>which indicates that the <code>expandtab</code> option is not set. This is further confirmed by executing <code>:set expandtab?</code> which returns with <code>noexpandtab</code>.</p>
<p>I'm on OSX 10.10, and <code>vi --help</code> returns:</p>
<pre><code>$ vi --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 20 2016 11:11:25)
MacOS X (unix) version
Included patches: 1-1847
Compiled by Homebrew
</code></pre>
<p>How come some settings in my .vimrc are being honored, but not <code>set expandtab</code>?</p>
| 0debug
|
void scsi_device_purge_requests(SCSIDevice *sdev, SCSISense sense)
{
SCSIRequest *req;
while (!QTAILQ_EMPTY(&sdev->requests)) {
req = QTAILQ_FIRST(&sdev->requests);
scsi_req_cancel(req);
}
sdev->unit_attention = sense;
}
| 1threat
|
How can I create an event on another users google calendar without reminders/notifications : <p>I try to create events for the users in my organization with a service account for which it is not needed that there is a reminder. Things like public holidays etc...</p>
<p>I add to the event a reminders object to override the default:</p>
<pre><code>EventReminder[] reminderOverrides = new EventReminder[] {};
Event.Reminders reminders = new Event.Reminders()
.setUseDefault(false)
.setOverrides(Arrays.asList(reminderOverrides));
event.setReminders(reminders)
</code></pre>
<p>Unit test and functional tests show there are no reminders attached when I check from a service account.</p>
<p>However when I login with user credentials, the default reminders are still visible. </p>
<p>What do I need to do differently so that people are not disturbed early in the morning on a public holiday?</p>
| 0debug
|
How to solve this error PHP Parse error: syntax error, unexpected ';'? : <p>I think the insert query should ends with semicolon as the similar code is working for another form. But it shows this error:</p>
<pre><code>PHP Parse error: syntax error, unexpected ';'
</code></pre>
<p>Here is my piece of PHP script for insert data into database from a form.</p>
<pre><code>if((!empty($name) && !empty($location) && !empty($fulladdress) && !empty($ownername) && !empty($ownercontact) && !empty(category) &&
($invalidphflag==true) && ($phoneflag==true) && !empty($size) && !empty($price) )
{
$insertquery= "INSERT INTO properties (name, location, address, owner_name, owner_no, size, price, category)
VALUES ('$name', '$location', '$fulladdress', '$ownername', '$ownercontact', '$size', '$price', '$category')";
$query = mysqli_query($db, $insertquery);
if($query)
{
$success= "Details submitted successfully.";
}
}
</code></pre>
| 0debug
|
Is there any way to check that uploaded file is mp3 or not in server side? : <p>Is there any way to do that? And also how to extract metadata from it (idv3 tag and etc).</p>
| 0debug
|
Laravel 5.5 change unauthenticated login redirect url : <p>In <code>Laravel < 5.5</code> I could change this file <code>app/Exceptions/Handler</code> to change the unauthenticated user redirect url:</p>
<pre><code>protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
}
return redirect()->guest(route('login'));
}
</code></pre>
<p>But in <code>Laravel 5.5</code> this has been moved to this location <code>vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php</code> so how can I change it now? I don't want to change stuff in the vendor directory encase it gets overridden by composer updates.</p>
<pre><code>protected function unauthenticated($request, AuthenticationException $exception)
{
return $request->expectsJson()
? response()->json(['message' => 'Unauthenticated.'], 401)
: redirect()->guest(route('login'));
}
</code></pre>
| 0debug
|
use lodash to find substring from array of strings : <p>I'm learning lodash. Is it possible to use lodash to find a substring in an array of strings?</p>
<pre><code> var myArray = [
'I like oranges and apples',
'I hate banana and grapes',
'I find mango ok',
'another array item about fruit'
]
</code></pre>
<p>is it possible to confirm if the word 'oranges' is in my array?
I've tried _.includes, _.some, _.indexOf but they all failed as they look at the full string, not a substring</p>
| 0debug
|
static void coroutine_fn v9fs_create(void *opaque)
{
int32_t fid;
int err = 0;
size_t offset = 7;
V9fsFidState *fidp;
V9fsQID qid;
int32_t perm;
int8_t mode;
V9fsPath path;
struct stat stbuf;
V9fsString name;
V9fsString extension;
int iounit;
V9fsPDU *pdu = opaque;
v9fs_path_init(&path);
v9fs_string_init(&name);
v9fs_string_init(&extension);
err = pdu_unmarshal(pdu, offset, "dsdbs", &fid, &name,
&perm, &mode, &extension);
if (err < 0) {
goto out_nofid;
trace_v9fs_create(pdu->tag, pdu->id, fid, name.data, perm, mode);
if (name_is_illegal(name.data)) {
err = -ENOENT;
goto out_nofid;
if (!strcmp(".", name.data) || !strcmp("..", name.data)) {
err = -EEXIST;
goto out_nofid;
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
goto out_nofid;
if (perm & P9_STAT_MODE_DIR) {
err = v9fs_co_mkdir(pdu, fidp, &name, perm & 0777,
fidp->uid, -1, &stbuf);
if (err < 0) {
err = v9fs_co_name_to_path(pdu, &fidp->path, name.data, &path);
if (err < 0) {
v9fs_path_copy(&fidp->path, &path);
err = v9fs_co_opendir(pdu, fidp);
if (err < 0) {
fidp->fid_type = P9_FID_DIR;
} else if (perm & P9_STAT_MODE_SYMLINK) {
err = v9fs_co_symlink(pdu, fidp, &name,
extension.data, -1 , &stbuf);
if (err < 0) {
err = v9fs_co_name_to_path(pdu, &fidp->path, name.data, &path);
if (err < 0) {
v9fs_path_copy(&fidp->path, &path);
} else if (perm & P9_STAT_MODE_LINK) {
int32_t ofid = atoi(extension.data);
V9fsFidState *ofidp = get_fid(pdu, ofid);
if (ofidp == NULL) {
err = v9fs_co_link(pdu, ofidp, fidp, &name);
put_fid(pdu, ofidp);
if (err < 0) {
err = v9fs_co_name_to_path(pdu, &fidp->path, name.data, &path);
if (err < 0) {
fidp->fid_type = P9_FID_NONE;
v9fs_path_copy(&fidp->path, &path);
err = v9fs_co_lstat(pdu, &fidp->path, &stbuf);
if (err < 0) {
fidp->fid_type = P9_FID_NONE;
} else if (perm & P9_STAT_MODE_DEVICE) {
char ctype;
uint32_t major, minor;
mode_t nmode = 0;
if (sscanf(extension.data, "%c %u %u", &ctype, &major, &minor) != 3) {
err = -errno;
switch (ctype) {
case 'c':
nmode = S_IFCHR;
break;
case 'b':
nmode = S_IFBLK;
break;
default:
err = -EIO;
nmode |= perm & 0777;
err = v9fs_co_mknod(pdu, fidp, &name, fidp->uid, -1,
makedev(major, minor), nmode, &stbuf);
if (err < 0) {
err = v9fs_co_name_to_path(pdu, &fidp->path, name.data, &path);
if (err < 0) {
v9fs_path_copy(&fidp->path, &path);
} else if (perm & P9_STAT_MODE_NAMED_PIPE) {
err = v9fs_co_mknod(pdu, fidp, &name, fidp->uid, -1,
0, S_IFIFO | (perm & 0777), &stbuf);
if (err < 0) {
err = v9fs_co_name_to_path(pdu, &fidp->path, name.data, &path);
if (err < 0) {
v9fs_path_copy(&fidp->path, &path);
} else if (perm & P9_STAT_MODE_SOCKET) {
err = v9fs_co_mknod(pdu, fidp, &name, fidp->uid, -1,
0, S_IFSOCK | (perm & 0777), &stbuf);
if (err < 0) {
err = v9fs_co_name_to_path(pdu, &fidp->path, name.data, &path);
if (err < 0) {
v9fs_path_copy(&fidp->path, &path);
} else {
err = v9fs_co_open2(pdu, fidp, &name, -1,
omode_to_uflags(mode)|O_CREAT, perm, &stbuf);
if (err < 0) {
fidp->fid_type = P9_FID_FILE;
fidp->open_flags = omode_to_uflags(mode);
if (fidp->open_flags & O_EXCL) {
fidp->flags |= FID_NON_RECLAIMABLE;
iounit = get_iounit(pdu, &fidp->path);
stat_to_qid(&stbuf, &qid);
err = pdu_marshal(pdu, offset, "Qd", &qid, iounit);
if (err < 0) {
err += offset;
trace_v9fs_create_return(pdu->tag, pdu->id,
qid.type, qid.version, qid.path, iounit);
out:
put_fid(pdu, fidp);
out_nofid:
pdu_complete(pdu, err);
v9fs_string_free(&name);
v9fs_string_free(&extension);
v9fs_path_free(&path);
| 1threat
|
Why does it not make a new list each time? : <pre><code>>>> def foo(bar=[]):
... bar.append("apple")
... return bar
>>> foo()
["apple"]
>>> foo()
["apple", "apple"]
>>> foo()
["apple", "apple", "apple"]
</code></pre>
<p>Why did it add in "apple" instead of making a new list?</p>
| 0debug
|
i want to copy a zip file from temp folder to a browsed location (say Destinydirectory) using .net. please provide me the code to do that : i want to copy a zip file from temp folder to a browsed location (say Destinydirectory) using .net. please provide me the code to do this.
i tried many ways but it gives error every time.
| 0debug
|
Can you move your animations to an external file in Angular2? : <p>The <code>@Component</code> annotation provides us with an <code>animations</code> property. This can be used to define a list of <code>triggers</code> each with a lot of <code>state</code> and <code>transition</code> properties.</p>
<p>When you add multiple animations to a component, this list can become pretty long. Also some animations would be really nice to use in other components as well. Having to put them directly in each component seems tedious and is repetitive - plus it violates the DRY principle.</p>
<p>You can define the template and styles properties on your component as well, but here you have the option of providing a <code>templateUrl</code> and <code>styleUrls</code> instead. I can't seem to find an <code>animationUrls</code> property - am i missing something - is there a way to do this?</p>
| 0debug
|
static int dshow_read_packet(AVFormatContext *s, AVPacket *pkt)
{
struct dshow_ctx *ctx = s->priv_data;
AVPacketList *pktl = NULL;
while (!pktl) {
WaitForSingleObject(ctx->mutex, INFINITE);
pktl = ctx->pktl;
if (pktl) {
*pkt = pktl->pkt;
ctx->pktl = ctx->pktl->next;
av_free(pktl);
ctx->curbufsize -= pkt->size;
}
ResetEvent(ctx->event);
ReleaseMutex(ctx->mutex);
if (!pktl) {
if (s->flags & AVFMT_FLAG_NONBLOCK) {
return AVERROR(EAGAIN);
} else {
WaitForSingleObject(ctx->event, INFINITE);
}
}
}
return pkt->size;
}
| 1threat
|
C scaning input strings saves to wrong variable : I'm trying to scan 3 strings on the console in C with scanf, but every time the second string is scanned it will also be added at the end of the first one.
I already tried to change the scanf format parameter (%8s, %[^\n]s, %8[^\n]s) but nothing worked that well. It seems that %8s ignores the second scanf and jumps directly to the third one.
char matrikelnumber[S_MATRIKELNUMBER]; //S_MATRIKELNUMBER is 8
char first_name[S_FIRST_NAME]; //S_FIRST_NAME is 30
char last_name[S_LAST_NAME]; //S_LAST_NAME is 30
printf("Matrikelnummer: ");
scanf("%s", matrikelnumber);
printf("%s\n", matrikelnumber); //Prints the correct input
printf("Vorname: ");
scanf("%s", first_name);
printf("%s\n", matrikelnumber); //Prints matrikelnumber + first_name added at the end
printf("Nachname: ");
scanf("%s", last_name);
How can I save all 3 strings correctly in the corresponding variable?
| 0debug
|
uint64_t helper_fadd(CPUPPCState *env, uint64_t arg1, uint64_t arg2)
{
CPU_DoubleU farg1, farg2;
farg1.ll = arg1;
farg2.ll = arg2;
if (unlikely(float64_is_infinity(farg1.d) && float64_is_infinity(farg2.d) &&
float64_is_neg(farg1.d) != float64_is_neg(farg2.d))) {
farg1.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXISI);
} else {
if (unlikely(float64_is_signaling_nan(farg1.d) ||
float64_is_signaling_nan(farg2.d))) {
fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN);
}
farg1.d = float64_add(farg1.d, farg2.d, &env->fp_status);
}
return farg1.ll;
}
| 1threat
|
What should ellipsis in attribute-list in C++ be used for? : <p>In <a href="http://en.cppreference.com/w/cpp/language/attributes" rel="noreferrer">C++ reference</a> I found information about allowed syntax of attributes in C++, it is:</p>
<pre><code>[[attribute-list]]
[[ using attribute-namespace : attribute-list ]]
</code></pre>
<p>"where attribute-list is a comma-separated sequence of zero or more attributes (possibly ending with an ellipsis ... indicating a pack expansion)" </p>
<p>I've tried to use its, but I see no difference between:</p>
<pre><code>[[deprecated]] void f()
{
}
</code></pre>
<p>and</p>
<pre><code>[[deprecated...]] void f()
{
}
</code></pre>
<p>In both cases output is the same.</p>
| 0debug
|
AWS Server Size for Hosting : <p>I am looking into purchasing server space with AWS to host what will eventually be over 50 websites. They will have many different ranges of traffic coming in. I would like to know if anyone has a recommendation on what size of server that would be able to handle this many sites.</p>
<p>Also, I was wondering if it's more cost effective/efficient to host an separate EC-2 instance for each site or too purchase a large umbrella server and host all sites on a single instance?</p>
<p>Thanks,</p>
| 0debug
|
static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4],
const DVprofile *sys)
{
int size, chan, i, j, d, of, smpls, freq, quant, half_ch;
uint16_t lc, rc;
const uint8_t* as_pack;
uint8_t *pcm, ipcm;
as_pack = dv_extract_pack(frame, dv_audio_source);
if (!as_pack)
return 0;
smpls = as_pack[1] & 0x3f;
freq = (as_pack[4] >> 3) & 0x07;
quant = as_pack[4] & 0x07;
if (quant > 1)
return -1;
if (freq >= FF_ARRAY_ELEMS(dv_audio_frequency))
size = (sys->audio_min_samples[freq] + smpls) * 4;
half_ch = sys->difseg_size / 2;
ipcm = (sys->height == 720 && !(frame[1] & 0x0C)) ? 2 : 0;
for (chan = 0; chan < sys->n_difchan; chan++) {
av_assert0(ipcm<4);
pcm = ppcm[ipcm++];
if (!pcm)
break;
for (i = 0; i < sys->difseg_size; i++) {
frame += 6 * 80;
if (quant == 1 && i == half_ch) {
av_assert0(ipcm<4);
pcm = ppcm[ipcm++];
if (!pcm)
break;
for (j = 0; j < 9; j++) {
for (d = 8; d < 80; d += 2) {
if (quant == 0) {
of = sys->audio_shuffle[i][j] + (d - 8) / 2 * sys->audio_stride;
if (of*2 >= size)
continue;
pcm[of*2] = frame[d+1];
pcm[of*2+1] = frame[d];
if (pcm[of*2+1] == 0x80 && pcm[of*2] == 0x00)
pcm[of*2+1] = 0;
} else {
lc = ((uint16_t)frame[d] << 4) |
((uint16_t)frame[d+2] >> 4);
rc = ((uint16_t)frame[d+1] << 4) |
((uint16_t)frame[d+2] & 0x0f);
lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc));
rc = (rc == 0x800 ? 0 : dv_audio_12to16(rc));
of = sys->audio_shuffle[i%half_ch][j] + (d - 8) / 3 * sys->audio_stride;
if (of*2 >= size)
continue;
pcm[of*2] = lc & 0xff;
pcm[of*2+1] = lc >> 8;
of = sys->audio_shuffle[i%half_ch+half_ch][j] +
(d - 8) / 3 * sys->audio_stride;
pcm[of*2] = rc & 0xff;
pcm[of*2+1] = rc >> 8;
++d;
frame += 16 * 80;
return size;
| 1threat
|
MutableLiveData with initial value : <p>How I can initialize <strong>MutableLiveData</strong> with initial value?
I'm looking for something like:</p>
<p><code>val text = MutableLiveData<String>("initial value")</code></p>
| 0debug
|
How to enable preprocessing evaluation when compiling code using GreenHills? : I am trying to do the following evaluation:
#if ( X != 0 )
do something
#endif
When I compile the code it throws the following errors:
#57: this operator is not allowed in a constant expression
#58: this operator is not allowed in a preprocessing expression
Am I missing any flag or something I need to set in order to be able to make this work? I am using Green Hills compiler.
| 0debug
|
static int parse_playlist(HLSContext *c, const char *url,
struct playlist *pls, AVIOContext *in)
{
int ret = 0, is_segment = 0, is_variant = 0;
int64_t duration = 0;
enum KeyType key_type = KEY_NONE;
uint8_t iv[16] = "";
int has_iv = 0;
char key[MAX_URL_SIZE] = "";
char line[MAX_URL_SIZE];
const char *ptr;
int close_in = 0;
int64_t seg_offset = 0;
int64_t seg_size = -1;
uint8_t *new_url = NULL;
struct variant_info variant_info;
char tmp_str[MAX_URL_SIZE];
struct segment *cur_init_section = NULL;
if (!in && c->http_persistent && c->playlist_pb) {
in = c->playlist_pb;
ret = open_url_keepalive(c->ctx, &c->playlist_pb, url);
if (ret == AVERROR_EXIT) {
return ret;
} else if (ret < 0) {
av_log(c->ctx, AV_LOG_WARNING,
"keepalive request failed for '%s', retrying with new connection: %s\n",
url, av_err2str(ret));
in = NULL;
}
}
if (!in) {
#if 1
AVDictionary *opts = NULL;
av_dict_set(&opts, "seekable", "0", 0);
av_dict_set(&opts, "user_agent", c->user_agent, 0);
av_dict_set(&opts, "cookies", c->cookies, 0);
av_dict_set(&opts, "headers", c->headers, 0);
av_dict_set(&opts, "http_proxy", c->http_proxy, 0);
if (c->http_persistent)
av_dict_set(&opts, "multiple_requests", "1", 0);
ret = c->ctx->io_open(c->ctx, &in, url, AVIO_FLAG_READ, &opts);
av_dict_free(&opts);
if (ret < 0)
return ret;
if (c->http_persistent)
c->playlist_pb = in;
else
close_in = 1;
#else
ret = open_in(c, &in, url);
if (ret < 0)
return ret;
close_in = 1;
#endif
}
if (av_opt_get(in, "location", AV_OPT_SEARCH_CHILDREN, &new_url) >= 0)
url = new_url;
read_chomp_line(in, line, sizeof(line));
if (strcmp(line, "#EXTM3U")) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
if (pls) {
free_segment_list(pls);
pls->finished = 0;
pls->type = PLS_TYPE_UNSPECIFIED;
}
while (!avio_feof(in)) {
read_chomp_line(in, line, sizeof(line));
if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) {
is_variant = 1;
memset(&variant_info, 0, sizeof(variant_info));
ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_variant_args,
&variant_info);
} else if (av_strstart(line, "#EXT-X-KEY:", &ptr)) {
struct key_info info = {{0}};
ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_key_args,
&info);
key_type = KEY_NONE;
has_iv = 0;
if (!strcmp(info.method, "AES-128"))
key_type = KEY_AES_128;
if (!strcmp(info.method, "SAMPLE-AES"))
key_type = KEY_SAMPLE_AES;
if (!strncmp(info.iv, "0x", 2) || !strncmp(info.iv, "0X", 2)) {
ff_hex_to_data(iv, info.iv + 2);
has_iv = 1;
}
av_strlcpy(key, info.uri, sizeof(key));
} else if (av_strstart(line, "#EXT-X-MEDIA:", &ptr)) {
struct rendition_info info = {{0}};
ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_rendition_args,
&info);
new_rendition(c, &info, url);
} else if (av_strstart(line, "#EXT-X-TARGETDURATION:", &ptr)) {
ret = ensure_playlist(c, &pls, url);
if (ret < 0)
goto fail;
pls->target_duration = strtoll(ptr, NULL, 10) * AV_TIME_BASE;
} else if (av_strstart(line, "#EXT-X-MEDIA-SEQUENCE:", &ptr)) {
ret = ensure_playlist(c, &pls, url);
if (ret < 0)
goto fail;
pls->start_seq_no = atoi(ptr);
} else if (av_strstart(line, "#EXT-X-PLAYLIST-TYPE:", &ptr)) {
ret = ensure_playlist(c, &pls, url);
if (ret < 0)
goto fail;
if (!strcmp(ptr, "EVENT"))
pls->type = PLS_TYPE_EVENT;
else if (!strcmp(ptr, "VOD"))
pls->type = PLS_TYPE_VOD;
} else if (av_strstart(line, "#EXT-X-MAP:", &ptr)) {
struct init_section_info info = {{0}};
ret = ensure_playlist(c, &pls, url);
if (ret < 0)
goto fail;
ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_init_section_args,
&info);
cur_init_section = new_init_section(pls, &info, url);
} else if (av_strstart(line, "#EXT-X-ENDLIST", &ptr)) {
if (pls)
pls->finished = 1;
} else if (av_strstart(line, "#EXTINF:", &ptr)) {
is_segment = 1;
duration = atof(ptr) * AV_TIME_BASE;
} else if (av_strstart(line, "#EXT-X-BYTERANGE:", &ptr)) {
seg_size = strtoll(ptr, NULL, 10);
ptr = strchr(ptr, '@');
if (ptr)
seg_offset = strtoll(ptr+1, NULL, 10);
} else if (av_strstart(line, "#", NULL)) {
continue;
} else if (line[0]) {
if (is_variant) {
if (!new_variant(c, &variant_info, line, url)) {
ret = AVERROR(ENOMEM);
goto fail;
}
is_variant = 0;
}
if (is_segment) {
struct segment *seg;
if (!pls) {
if (!new_variant(c, 0, url, NULL)) {
ret = AVERROR(ENOMEM);
goto fail;
}
pls = c->playlists[c->n_playlists - 1];
}
seg = av_malloc(sizeof(struct segment));
if (!seg) {
ret = AVERROR(ENOMEM);
goto fail;
}
seg->duration = duration;
seg->key_type = key_type;
if (has_iv) {
memcpy(seg->iv, iv, sizeof(iv));
} else {
int seq = pls->start_seq_no + pls->n_segments;
memset(seg->iv, 0, sizeof(seg->iv));
AV_WB32(seg->iv + 12, seq);
}
if (key_type != KEY_NONE) {
ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, key);
seg->key = av_strdup(tmp_str);
if (!seg->key) {
av_free(seg);
ret = AVERROR(ENOMEM);
goto fail;
}
} else {
seg->key = NULL;
}
ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, line);
seg->url = av_strdup(tmp_str);
if (!seg->url) {
av_free(seg->key);
av_free(seg);
ret = AVERROR(ENOMEM);
goto fail;
}
dynarray_add(&pls->segments, &pls->n_segments, seg);
is_segment = 0;
seg->size = seg_size;
if (seg_size >= 0) {
seg->url_offset = seg_offset;
seg_offset += seg_size;
seg_size = -1;
} else {
seg->url_offset = 0;
seg_offset = 0;
}
seg->init_section = cur_init_section;
}
}
}
if (pls)
pls->last_load_time = av_gettime_relative();
fail:
av_free(new_url);
if (close_in)
ff_format_io_close(c->ctx, &in);
return ret;
}
| 1threat
|
static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
int access_type, ARMMMUIdx mmu_idx,
hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot,
target_ulong *page_size_ptr, uint32_t *fsr,
ARMMMUFaultInfo *fi)
{
ARMCPU *cpu = arm_env_get_cpu(env);
CPUState *cs = CPU(cpu);
MMUFaultType fault_type = translation_fault;
uint32_t level;
uint32_t epd = 0;
int32_t t0sz, t1sz;
uint32_t tg;
uint64_t ttbr;
int ttbr_select;
hwaddr descaddr, indexmask, indexmask_grainsize;
uint32_t tableattrs;
target_ulong page_size;
uint32_t attrs;
int32_t stride = 9;
int32_t va_size;
int inputsize;
int32_t tbi = 0;
TCR *tcr = regime_tcr(env, mmu_idx);
int ap, ns, xn, pxn;
uint32_t el = regime_el(env, mmu_idx);
bool ttbr1_valid = true;
uint64_t descaddrmask;
if (arm_el_is_aa64(env, el)) {
level = 0;
va_size = 64;
if (el > 1) {
if (mmu_idx != ARMMMUIdx_S2NS) {
tbi = extract64(tcr->raw_tcr, 20, 1);
}
} else {
if (extract64(address, 55, 1)) {
tbi = extract64(tcr->raw_tcr, 38, 1);
} else {
tbi = extract64(tcr->raw_tcr, 37, 1);
}
}
tbi *= 8;
if (el > 1) {
ttbr1_valid = false;
}
} else {
level = 1;
va_size = 32;
if (el == 2) {
ttbr1_valid = false;
}
}
if (va_size == 64) {
t0sz = extract32(tcr->raw_tcr, 0, 6);
t0sz = MIN(t0sz, 39);
t0sz = MAX(t0sz, 16);
} else if (mmu_idx != ARMMMUIdx_S2NS) {
t0sz = extract32(tcr->raw_tcr, 0, 3);
} else {
bool sext = extract32(tcr->raw_tcr, 4, 1);
bool sign = extract32(tcr->raw_tcr, 3, 1);
t0sz = sextract32(tcr->raw_tcr, 0, 4);
if (sign != sext) {
qemu_log_mask(LOG_GUEST_ERROR,
"AArch32: VTCR.S / VTCR.T0SZ[3] missmatch\n");
}
}
t1sz = extract32(tcr->raw_tcr, 16, 6);
if (va_size == 64) {
t1sz = MIN(t1sz, 39);
t1sz = MAX(t1sz, 16);
}
if (t0sz && !extract64(address, va_size - t0sz, t0sz - tbi)) {
ttbr_select = 0;
} else if (ttbr1_valid && t1sz &&
!extract64(~address, va_size - t1sz, t1sz - tbi)) {
ttbr_select = 1;
} else if (!t0sz) {
ttbr_select = 0;
} else if (!t1sz && ttbr1_valid) {
ttbr_select = 1;
} else {
fault_type = translation_fault;
goto do_fault;
}
if (ttbr_select == 0) {
ttbr = regime_ttbr(env, mmu_idx, 0);
if (el < 2) {
epd = extract32(tcr->raw_tcr, 7, 1);
}
inputsize = va_size - t0sz;
tg = extract32(tcr->raw_tcr, 14, 2);
if (tg == 1) {
stride = 13;
}
if (tg == 2) {
stride = 11;
}
} else {
assert(ttbr1_valid);
ttbr = regime_ttbr(env, mmu_idx, 1);
epd = extract32(tcr->raw_tcr, 23, 1);
inputsize = va_size - t1sz;
tg = extract32(tcr->raw_tcr, 30, 2);
if (tg == 3) {
stride = 13;
}
if (tg == 1) {
stride = 11;
}
}
if (epd) {
goto do_fault;
}
if (mmu_idx != ARMMMUIdx_S2NS) {
level = 4 - (inputsize - 4) / stride;
} else {
uint32_t sl0 = extract32(tcr->raw_tcr, 6, 2);
uint32_t startlevel;
bool ok;
if (va_size == 32 || stride == 9) {
startlevel = 2 - sl0;
} else {
startlevel = 3 - sl0;
}
ok = check_s2_mmu_setup(cpu, va_size == 64, startlevel,
inputsize, stride);
if (!ok) {
fault_type = translation_fault;
goto do_fault;
}
level = startlevel;
}
indexmask_grainsize = (1ULL << (stride + 3)) - 1;
indexmask = (1ULL << (inputsize - (stride * (4 - level)))) - 1;
descaddr = extract64(ttbr, 0, 48);
descaddr &= ~indexmask;
descaddrmask = ((1ull << (va_size == 64 ? 48 : 40)) - 1) &
~indexmask_grainsize;
tableattrs = regime_is_secure(env, mmu_idx) ? 0 : (1 << 4);
for (;;) {
uint64_t descriptor;
bool nstable;
descaddr |= (address >> (stride * (4 - level))) & indexmask;
descaddr &= ~7ULL;
nstable = extract32(tableattrs, 4, 1);
descriptor = arm_ldq_ptw(cs, descaddr, !nstable, mmu_idx, fsr, fi);
if (fi->s1ptw) {
goto do_fault;
}
if (!(descriptor & 1) ||
(!(descriptor & 2) && (level == 3))) {
goto do_fault;
}
descaddr = descriptor & descaddrmask;
if ((descriptor & 2) && (level < 3)) {
tableattrs |= extract64(descriptor, 59, 5);
level++;
indexmask = indexmask_grainsize;
continue;
}
page_size = (1ULL << ((stride * (4 - level)) + 3));
descaddr |= (address & (page_size - 1));
attrs = extract64(descriptor, 2, 10)
| (extract64(descriptor, 52, 12) << 10);
if (mmu_idx == ARMMMUIdx_S2NS) {
break;
}
attrs |= extract32(tableattrs, 0, 2) << 11;
attrs |= extract32(tableattrs, 3, 1) << 5;
if (extract32(tableattrs, 2, 1)) {
attrs &= ~(1 << 4);
}
attrs |= nstable << 3;
break;
}
fault_type = access_fault;
if ((attrs & (1 << 8)) == 0) {
goto do_fault;
}
ap = extract32(attrs, 4, 2);
xn = extract32(attrs, 12, 1);
if (mmu_idx == ARMMMUIdx_S2NS) {
ns = true;
*prot = get_S2prot(env, ap, xn);
} else {
ns = extract32(attrs, 3, 1);
pxn = extract32(attrs, 11, 1);
*prot = get_S1prot(env, mmu_idx, va_size == 64, ap, ns, xn, pxn);
}
fault_type = permission_fault;
if (!(*prot & (1 << access_type))) {
goto do_fault;
}
if (ns) {
txattrs->secure = false;
}
*phys_ptr = descaddr;
*page_size_ptr = page_size;
return false;
do_fault:
*fsr = (1 << 9) | (fault_type << 2) | level;
fi->stage2 = fi->s1ptw || (mmu_idx == ARMMMUIdx_S2NS);
return true;
}
| 1threat
|
Active_Shipping Negotiated Rates for UPS - Ruby on Rails : <p>I've integrated the Shopify active_shipping gem into my site and I am trying to get negotiated rates from my UPS account (I can get regular rates). I can't find any documentation on the negotiated rates. Can anyone help me out here? I think this line of code should work but it doesn't produce any errors or any different shipping rates.</p>
<pre><code>response = carrier.find_rates(origin, destination, packages, {negotiated_rates: true})
</code></pre>
<p>I ran across this link here but still no luck:</p>
<p><a href="https://github.com/Shopify/active_shipping/blob/master/lib/active_shipping/carriers/ups.rb" rel="noreferrer">https://github.com/Shopify/active_shipping/blob/master/lib/active_shipping/carriers/ups.rb</a></p>
| 0debug
|
static void check_decode_result(int *got_output, int ret)
{
if (*got_output || ret<0)
decode_error_stat[ret<0] ++;
if (ret < 0 && exit_on_error)
exit_program(1);
}
| 1threat
|
Why does this function have a different value for the same variable but the same address? : <pre><code>def func(t):
t = 5
print('inside function', t)
print('inside function address = ', id(hex(t)))
x = 3
func(x)
print('outside function',x)
print('outside function address = ', id(hex(x)))
</code></pre>
<p>This Prints</p>
<pre><code>inside function 5
inside function address = 31255648
outside function 3
outside function address = 31255648
</code></pre>
<p>My understanding was a variable referenced in a function without assignment will use a variable outside of its scope. But if the function has an assignment, then it will create a new variable in a new space in memory and assign it there.</p>
<p>Why does the function id find the original address of the argument instead of the address of the newly created variable? </p>
| 0debug
|
Electron - How to know when renderer window is ready : <p>In my main process I create a renderer window:</p>
<pre><code>var mainWindow = new BrowserWindow({
height: 600,
width: 800,
x: 0,
y: 0,
frame: false,
resizable: true
});
mainWindow.openDevTools();
mainWindow.loadURL('file://' + __dirname + '/renderer/index.html');
</code></pre>
<p>Then I want to communicate with it in some way:</p>
<pre><code>mainWindow.webContents.send('message', 'hello world');
</code></pre>
<p>However the main window doesn't receive this message because it isn't fully done being created at the time I attempt to send it.</p>
<p>I have temporarily solved this by wrapping the latter code in a setTimeout() but that is most definitely not the right way to resolve a race condition.</p>
<p>Is there a callback for when the main window is ready? I tried the 'ready-to-show' event mentioned in the docs but it did not work.</p>
| 0debug
|
static int sbr_hf_calc_npatches(AACContext *ac, SpectralBandReplication *sbr)
{
int i, k, sb = 0;
int msb = sbr->k[0];
int usb = sbr->kx[1];
int goal_sb = ((1000 << 11) + (sbr->sample_rate >> 1)) / sbr->sample_rate;
sbr->num_patches = 0;
if (goal_sb < sbr->kx[1] + sbr->m[1]) {
for (k = 0; sbr->f_master[k] < goal_sb; k++) ;
} else
k = sbr->n_master;
do {
int odd = 0;
for (i = k; i == k || sb > (sbr->k[0] - 1 + msb - odd); i--) {
sb = sbr->f_master[i];
odd = (sb + sbr->k[0]) & 1;
}
if (sbr->num_patches > 5) {
av_log(ac->avctx, AV_LOG_ERROR, "Too many patches: %d\n", sbr->num_patches);
return -1;
}
sbr->patch_num_subbands[sbr->num_patches] = FFMAX(sb - usb, 0);
sbr->patch_start_subband[sbr->num_patches] = sbr->k[0] - odd - sbr->patch_num_subbands[sbr->num_patches];
if (sbr->patch_num_subbands[sbr->num_patches] > 0) {
usb = sb;
msb = sb;
sbr->num_patches++;
} else
msb = sbr->kx[1];
if (sbr->f_master[k] - sb < 3)
k = sbr->n_master;
} while (sb != sbr->kx[1] + sbr->m[1]);
if (sbr->patch_num_subbands[sbr->num_patches-1] < 3 && sbr->num_patches > 1)
sbr->num_patches--;
return 0;
}
| 1threat
|
how does 'length' work to return the length of a String type array object in Java? : <p>we have length()- <strong>a method</strong> that returns the length of a String object,</p>
<p>for example:</p>
<pre><code> String s, sarr[] = {"a","b"};
System.out.println(s.length());
System.out.println(sarr.length);
</code></pre>
<p>in Java. But what does happen, in background, in case of String type array object that we have to use <strong>length</strong> , probably a parameter, that returns the length of that said array object?</p>
| 0debug
|
how to manipulate the array in javascript? : I have a json response from the mongodb in this format;
[{
"_id" : 4,
"status" : [
{
"status" : "Closed",
"count" : 2
},
{
"status" : "Open",
"count" : 17
}
],
"count" : 19
},
{
"_id" : 3,
"status" : [
{
"status" : "Closed",
"count" : 6
},
{
"status" : "Open",
"count" : 22
}
],
"count" : 28
}]
I want to manipulate this into an array of object so it becomes easy for me to pass them onto the highcharts.
categories: ['3', '4']
series: [{
name: 'Open',
data: [20,24]
}, {
name: 'Closed',
data: [40,55]
}]
Basically i want to group all the "open" and "closed" with respect to the categories, so it becomes easy for me to include them in the highcharts.
Thanks !
| 0debug
|
Function which takes function/lambda/class with overloaded() as argument : <p>I need write a function which can take another function/lambda/class with () operator overloaded as a parametr and correctly work with them (like 3th arg of std::sort.
What it looks like in terms of C++ syntax?</p>
| 0debug
|
static void test_notify(void)
{
g_assert(!aio_poll(ctx, false));
aio_notify(ctx);
g_assert(!aio_poll(ctx, true));
g_assert(!aio_poll(ctx, false));
}
| 1threat
|
static inline int16_t logadd(int16_t a, int16_t b)
{
int16_t c = a - b;
uint8_t address = FFMIN((ABS(c) >> 1), 255);
return ((c >= 0) ? (a + latab[address]) : (b + latab[address]));
}
| 1threat
|
MemoryRegion *iotlb_to_region(target_phys_addr_t index)
{
return phys_sections[index & ~TARGET_PAGE_MASK].mr;
}
| 1threat
|
How can I add a click event to the v-data-table? : <p>I want to call the editItem function when the table row is clicked. Current what happens is I click on the table row and it doesn't display the details page. Yet when I put this click event on a particular table data the editItem function gets called. How can I make this same function to be called on the table row itself? </p>
<p>Here in my code I have tried using the the v-data-table template and slot and included the click event on the row but it is not working either</p>
<pre><code><template slot="items" slot-scope="props">
<tr @click="editItem(item), selected = item.id">
<td>{{ props.item.member }}</td>
<td>{{ props.item[1] }}</td>
<td>{{ props.item[2] }}</td>
<td>{{ props.item[3] }}</td>
<td>{{ props.item[4] }}</td>
<td>{{ props.item[5] }}</td>
<td>{{ props.item[6] }}</td>
<td>{{ props.item[7] }}</td>
<td>{{ props.item[8] }}</td>
<td>{{ props.item[9] }}</td>
<td>{{ props.item[10] }}</td>
<td>{{ props.item[11] }}</td>
<td>{{ props.item[12] }}</td>
<td>{{ props.item[13] }}</td>
</tr>
</template>
</code></pre>
<p>I expect that when the row is clicked, the editItem function is called</p>
| 0debug
|
How to cancel current request in interceptor - Angular 4 : <p>As you know it's possible to use <strong>Interceptors</strong> in new versions of Angular 4.</p>
<p>In mine, I want to cancel a request in interceptor in some conditions.
So is it possible? or maybe what should I ask is, Which way I should do that?</p>
<p>Also It will be Ok! if I found a way to rewrite some response to the request instead of canceling it.</p>
| 0debug
|
I don't know why don't work this code : I am using angular 1.x in my project and I want to create a filter, I Know how do it but don't work, not throws any console error, simply that not work.
This is my js code:
var myAPP = angular.module("myAPP",[]);
myAPP.filter("miFilter",function(){
return function(input){
return input.replace("normal","400x400");
};
});
and in my html file use this:
<img src="{{url | miFilter}}" />
| 0debug
|
static void mux_chr_update_read_handler(CharDriverState *chr,
GMainContext *context)
{
MuxDriver *d = chr->opaque;
int idx;
if (d->mux_cnt >= MAX_MUX) {
fprintf(stderr, "Cannot add I/O handlers, MUX array is full\n");
return;
}
if (chr->mux_idx == -1) {
chr->mux_idx = d->mux_cnt++;
}
idx = chr->mux_idx;
d->ext_opaque[idx] = chr->handler_opaque;
d->chr_can_read[idx] = chr->chr_can_read;
d->chr_read[idx] = chr->chr_read;
d->chr_event[idx] = chr->chr_event;
if (d->mux_cnt == 1) {
qemu_chr_add_handlers_full(d->drv, mux_chr_can_read,
mux_chr_read,
mux_chr_event,
chr, context);
}
if (d->focus != -1) {
mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_OUT);
}
d->focus = idx;
mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_IN);
}
| 1threat
|
static void test_cancel(void)
{
WorkerTestData data[100];
int num_canceled;
int i;
test_submit_many();
for (i = 0; i < 100; i++) {
data[i].n = 0;
data[i].ret = -EINPROGRESS;
data[i].aiocb = thread_pool_submit_aio(long_cb, &data[i],
done_cb, &data[i]);
}
active = 100;
qemu_aio_wait_nonblocking();
g_assert_cmpint(active, ==, 100);
g_usleep(1000000);
g_assert_cmpint(active, >, 50);
num_canceled = 0;
for (i = 0; i < 100; i++) {
if (__sync_val_compare_and_swap(&data[i].n, 0, 3) == 0) {
data[i].ret = -ECANCELED;
bdrv_aio_cancel(data[i].aiocb);
active--;
num_canceled++;
}
}
g_assert_cmpint(active, >, 0);
g_assert_cmpint(num_canceled, <, 100);
for (i = 0; i < 100; i++) {
if (data[i].n != 3) {
bdrv_aio_cancel(data[i].aiocb);
}
}
qemu_aio_wait_all();
g_assert_cmpint(active, ==, 0);
for (i = 0; i < 100; i++) {
if (data[i].n == 3) {
g_assert_cmpint(data[i].ret, ==, -ECANCELED);
g_assert(data[i].aiocb != NULL);
} else {
g_assert_cmpint(data[i].n, ==, 2);
g_assert_cmpint(data[i].ret, ==, 0);
g_assert(data[i].aiocb == NULL);
}
}
}
| 1threat
|
What does the %# flag in a printf statement in C? : <p>I am doing the chapter 3 of the book learning C the hard way by Zed Shaw. I am exploring the different string formatting options for printf. I encountered the following flag to put after the '%#' symbol:</p>
<p>The value should be converted to an "alternate form". For o conversions, the first character of the output string is made zero (by prefixing a 0 if it was not zero already). For x and X conversions, a nonzero result has the string "0x" (or "0X" for X conversions) prepended to it. For a, A, e, E, f, F, g, and G conversions, the result will always contain a decimal point, even if no digits follow it (normally, a decimal point appears in the results of those conversions only if a digit follows). For g and G conversions, trailing zeros are not removed from the result as they would otherwise be. For other conversions, the result is undefined. </p>
<p>It seems that '%#' flag is for a kind of type conversion for the printf statement. But I am not sure. Does anyone knows what kind of conversion of actual usage this %# flag has in the printf function in C? I can see any change or conversion for the character "A", which is the one I am using for the flag %# in the last print statement.</p>
<p>This is my code: </p>
<pre><code>#include <math.h>
int main(int argc, char *argv[])
{
int age = 32; // age and height not initialized
int height = 182;
printf("I am %d cm tall.\n", age);
printf("I am %d years old.\n", height);
printf("I wanna go to \"Panama\"\n"); // scaping double quotes
printf("I am %2$d tall and %1$d years old\n", age, height); // how to use positional arguments in printf statement
// how to use positional arguments in printf statement
printf("I am using the number pi: %'.2f\n", 3.1415939);
// Testing the %# formatting
printf("Testing for A: %# \n", 'A');
return 0;
}
</code></pre>
<p>The output I receive: </p>
<pre><code>I am 32 cm tall.
I am 182 years old.
I wanna go to "Panama"
I am 182 tall and 32 years old
I am using the number pi: 3.14
Testing for A: %#
</code></pre>
| 0debug
|
def count_tuplex(tuplex,value):
count = tuplex.count(value)
return count
| 0debug
|
static void test_visitor_in_errors(TestInputVisitorData *data,
const void *unused)
{
TestStruct *p = NULL;
Error *err = NULL;
Visitor *v;
v = visitor_input_test_init(data, "{ 'integer': false, 'boolean': 'foo', 'string': -42 }");
visit_type_TestStruct(v, &p, NULL, &err);
error_free_or_abort(&err);
g_assert(p->string == NULL);
g_free(p->string);
g_free(p);
}
| 1threat
|
Java Difference between current date and past date in Years, Months, Days, Hours, Minutes, Seconds : <p>I know this has been asked on here many times previously, but I'm haven't been able to find anything specific to my case. I'm trying to find the difference between the current datetime and a previous datetime, each with the format <code>yyyy-MM-dd HH:mm:ss.s</code>. Based on the answer given <a href="https://stackoverflow.com/questions/5351483/calculate-date-time-difference-in-java">here</a>, I've come up with the following code:</p>
<pre><code>SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.s");
String earliestRunTime = "2017-12-16 01:30:08.0";
Date currentDate = new Date();
log.info("Current Date: {}", format.format(currentDate));
try {
Date earliestDate = format.parse(earliestRunTime);
long diff = currentDate.getTime() - earliestDate.getTime();
long diffSeconds = diff / 1000 % 60;
long diffMinutes = diff / (60 * 1000) % 60;
long diffHours = diff / (60 * 60 * 1000) % 24;
long diffDays = diff / (24 * 60 * 60 * 1000) % 30;
long diffMonths = diff / (30 * 24 * 60 * 60 * 1000) % 12;
long diffYears = diff / (12 * 30 * 24 * 60 * 60 * 1000);
return String.format("%s years, %s months, %s days, %s hours, %s minutes, %s seconds",
diffYears, diffMonths, diffDays, diffHours, diffMinutes, diffSeconds);
}
catch (Exception e) {
e.printStackTrace();
return e.getMessage();
}
</code></pre>
<p>When I run the code, the JSON returns the following result:</p>
<pre><code>lifetime: "41 years, -1 months, 14 days, 9 hours, 42 minutes, 37 seconds"
</code></pre>
<p>I have two questions here:</p>
<ol>
<li>Where am I going wrong in my calculations 41 years and a negative number? </li>
<li>Is there a better way for me to do this? My current setup does not consider leap years or a 365 day year, and I need to take these into account.</li>
</ol>
| 0debug
|
Yii2 | requires bower-asset/jquery : <p>I'm trying to install Yii2 via composer:</p>
<pre><code>composer global require "fxp/composer-asset-plugin:~1.1.1"
composer create-project --prefer-dist yiisoft/yii2-app-basic basic
</code></pre>
<p>~/.composer/composer.json</p>
<pre><code>{
"require": {
"fxp/composer-asset-plugin": "~1.1.1"
}
}
</code></pre>
<p>result: </p>
<pre><code>Problem 1
- yiisoft/yii2 2.0.x-dev requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.
- yiisoft/yii2 dev-master requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.
- yiisoft/yii2 2.0.6 requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.
- yiisoft/yii2 2.0.5 requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.
- Installation request for yiisoft/yii2 >=2.0.5 -> satisfiable by yiisoft/yii2[2.0.5, 2.0.6, dev-master, 2.0.x-dev].
</code></pre>
<p>What do I do wrong?</p>
| 0debug
|
Combine Same Item Number into one cell Like concatinate function. : Hy Experts, I have an excel sheet with four columns. Column 1 is Part_No, Column 2 is Type, Column 3 is Col2 as Year and column 4 is Item Name.
Actually the column 1 as C column contains many Part_No with same number like 08256 is in sheet 2 times as row one and two. But in some cases the rows are very far from the same number. I used simple this function.
=concatenate(E,F)
It can combine only one row but I want to combine all the rows in one cell that have same Part_No. How it could be. Thanks
The structure of excel is as under.
[enter image description here][1]
[1]: https://i.stack.imgur.com/JL8YH.png
| 0debug
|
static void test_visitor_out_number(TestOutputVisitorData *data,
const void *unused)
{
double value = 3.14;
QObject *obj;
visit_type_number(data->ov, NULL, &value, &error_abort);
obj = visitor_get(data);
g_assert(qobject_type(obj) == QTYPE_QFLOAT);
g_assert(qfloat_get_double(qobject_to_qfloat(obj)) == value);
}
| 1threat
|
How to add a variable amount of variables in a list : <p>Is there a way to append a variable amount of variables in a list in python? I want the number of variables in my list to be equal to y
(y = 5)</p>
| 0debug
|
connection.query('SELECT * FROM users WHERE username = ' + input_string)
| 1threat
|
void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f,
ImageInfoSpecific *info_spec)
{
QObject *obj, *data;
Visitor *v = qobject_output_visitor_new(&obj);
visit_type_ImageInfoSpecific(v, NULL, &info_spec, &error_abort);
visit_complete(v, &obj);
assert(qobject_type(obj) == QTYPE_QDICT);
data = qdict_get(qobject_to_qdict(obj), "data");
dump_qobject(func_fprintf, f, 1, data);
qobject_decref(obj);
visit_free(v);
}
| 1threat
|
Laravel: find if a pivot table record exists : <p>I have two models which are joined by a pivot table, <code>User</code> and <code>Task</code>.</p>
<p>I have a <code>user_id</code> and a <code>task_id</code>.</p>
<p>What is the neatest way to check whether a record exists for this combination of user and task?</p>
| 0debug
|
Can't vertical center h1 inside div : <p>I'm having some troubles when trying to vertical center a header inside a div.
CSS is the following:</p>
<pre class="lang-html prettyprint-override"><code>.container {
background: #a3f;
padding-left: 3% !important;
}
.container h4 {
vertical-align: middle;
text-align: center;
background: #f02;
}
</code></pre>
<p>I have tried some <a href="https://stackoverflow.com/questions/396145/how-to-vertically-center-a-div-for-all-browsers">solutions</a> (also <a href="https://stackoverflow.com/questions/16629561/why-is-vertical-align-middle-not-working-on-my-span-or-div">this</a>), but the text continues at the top of the div.</p>
| 0debug
|
I am developing an Android app in which i want to create a sqlite database but i am facing this issue. Please help me solve this error : 10-02 01:31:57.697 22242-22242/com.example.android.mynotes E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.mynotes, PID: 22242
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
at android.view.View.performClick(View.java:5697)
at android.widget.TextView.performClick(TextView.java:10826)
at android.view.View$PerformClick.run(View.java:22526)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java:5697)
at android.widget.TextView.performClick(TextView.java:10826)
at android.view.View$PerformClick.run(View.java:22526)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.database.sqlite.SQLiteException: near "EXISTName": syntax error (code 1): , while compiling: CREATE TABLE IF NOT EXISTName(ID INTEGER PRIMARY KEY,TitleTEXT,DescriptionTEXT);
#################################################################
Error Code : 1 (SQLITE_ERROR)
Caused By : SQL(query) error or missing database.
(near "EXISTName": syntax error (code 1): , while compiling: CREATE TABLE IF NOT EXISTName(ID INTEGER PRIMARY KEY,TitleTEXT,DescriptionTEXT);)
#################################################################
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1058)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:623)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1812)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1743)
at com.example.android.mynotes.DbManager$DatabaseHelperNotes.onCreate(DbManager.kt:32)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:251)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at com.example.android.mynotes.DbManager.<init>(DbManager.kt:22)
at com.example.android.mynotes.AddNotes.BtnAdd(AddNotes.kt:19)
... 12 more
| 0debug
|
static void q35_host_get_pci_hole_end(Object *obj, Visitor *v,
const char *name, void *opaque,
Error **errp)
{
Q35PCIHost *s = Q35_HOST_DEVICE(obj);
uint32_t value = s->mch.pci_hole.end;
visit_type_uint32(v, name, &value, errp);
}
| 1threat
|
const char *avutil_configuration(void)
{
return FFMPEG_CONFIGURATION;
}
| 1threat
|
Sources to Teach .net Developing : <p>My IT Director asked that I get together (For Next Week!!!!) a lesson plan to teach him and our other developer .Net programming pretty much from the ground up in 6 two hour courses. Up until I was hired 5 years ago, all of our software solutions were in an older technology, namely VBA in MS Access, and the plan is to convert to .Net Web Applications. They are very intelligent, just have not had the time to dive into .Net.</p>
<p>So I'm asking for advice or ideas on how to structure these 6 courses and any sources you think I can turn to. I need to fit in Css Styling, C#, Jquery/Javascript/Ajax, Browser Debugging, Unit tests, etc...</p>
<p>Thank you!!!</p>
| 0debug
|
React & Draft.js - convertFromRaw not working : <p>I'm using Draft.js to implement a text editor. I want to save the content of the editor to a DB and later retrieve it and inject it in an editor again, e.g. when revisiting the editor page.</p>
<p><strong>First, these are the relevant imports</strong></p>
<pre><code>import { ContentState, EditorState, convertToRaw, convertFromRaw } from 'draft-js';
</code></pre>
<p><strong>How I Save the Data to the DB (located in a parent Component)</strong></p>
<pre><code>saveBlogPostToStore(blogPost) {
const JSBlogPost = { ...blogPost, content: convertToRaw(blogPost.content.getCurrentContent())};
this.props.dispatch(blogActions.saveBlogPostToStore(JSBlogPost));
}
</code></pre>
<p>Now when I check the DB, I get the following Object:</p>
<pre><code>[{"_id":null,"url":"2016-8-17-sample-title","title":"Sample Title","date":"2016-09-17T14:57:54.649Z","content":{"blocks":[{"key":"4ads4","text":"Sample Text Block","type":"unstyled","depth":0,"inlineStyleRanges":[],"entityRanges":[]}]},"author":"Lukas Gisder-Dubé","__v":0,"tags":[]}]
</code></pre>
<p>So far so good I guess, I tried some other stuff and the Object in the Database is definitely converted. For example, when I save the content without calling the convertToRaw()-method, there are a lot more fields.</p>
<p><strong>Setting the Data as new EditorState</strong></p>
<p>To retrieve the Data from the DB and set it as EditorState, I also tried a lot. The following is my best guess:</p>
<pre><code>constructor(props) {
super(props);
const DBEditorState = this.props.blogPost.content;
console.log(DBEditorState); // logs the same Object as above
this.state = { ...this.props.blogPost, content: EditorState.createWithContent(
convertFromRaw(DBEditorState)
)};
}
</code></pre>
<p>When rendering the component i get the following error:</p>
<pre><code>convertFromRawToDraftState.js:38 Uncaught TypeError: Cannot convert undefined or null to object
</code></pre>
<p>Any help is greatly appreciated!</p>
| 0debug
|
Can anyone help to draw rectangle in wxwidgets because i have written a code but it doesn't work it only displays a window frame : #include "wx/wx.h"
class MyFrame : public wxFrame{
public:
MyFrame();
~MyFrame();
private:
//DECLARE_EVENT_TABLE()
};
class MyWindow : public wxWindow{
public:
void OnPaint(wxPaintEvent& event);
private:
DECLARE_EVENT_TABLE()
};
class MyApp : public wxApp
{
public:
MyApp();
~MyApp();
virtual bool OnInit();
void DrawSimpleShapes(wxDC& dc);
private:
MyFrame* m_frame = NULL;
//MyWindow* w = NULL;
};
MyFrame::MyFrame() : wxFrame(nullptr,wxID_ANY,"Rectangle",wxPoint(30,30),wxSize(800,600))
{
}
bool MyApp :: OnInit()
{
m_frame = new MyFrame();
m_frame->Show();
//w = new MyWindow();
//w->Show();
return true;
}
wxIMPLEMENT_APP(MyApp);
wxBEGIN_EVENT_TABLE(MyWindow,wxWindow)
EVT_PAINT(MyWindow::OnPaint)
wxEND_EVENT_TABLE()
MyFrame::~MyFrame()
{
}
MyApp::MyApp()
{
}
MyApp::~MyApp()
{
}
void MyWindow :: OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);
dc.SetPen(*wxBLACK_PEN);
dc.SetBrush(*wxRED_BRUSH);
wxSize sz = GetClientSize();
wxCoord w = 100, h = 50;
int x = wxMax(0,(sz.x-w)/2);
int y = wxMax(0,(sz.y - h)/2);
wxRect recToDraw(x,y,w,h);
dc.DrawRectangle(recToDraw);
}
1. List item
how to draw a rectangle
some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem
some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem
some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem
some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem
some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem
some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem
some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem
some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem
| 0debug
|
static int vfio_container_do_ioctl(AddressSpace *as, int32_t groupid,
int req, void *param)
{
VFIOGroup *group;
VFIOContainer *container;
int ret = -1;
group = vfio_get_group(groupid, as);
if (!group) {
error_report("vfio: group %d not registered", groupid);
return ret;
}
container = group->container;
if (group->container) {
ret = ioctl(container->fd, req, param);
if (ret < 0) {
error_report("vfio: failed to ioctl %d to container: ret=%d, %s",
_IOC_NR(req) - VFIO_BASE, ret, strerror(errno));
}
}
vfio_put_group(group);
return ret;
}
| 1threat
|
Duplicate file is getting created in linux : <p>I created a file called <code>file2.txt</code> in Linux, opened it in text editor and saved it. When I closed the text editor I see two files <code>file2.txt</code> and <code>file2.txt~</code></p>
<p>I guess <code>file2.txt~</code> is temporary file created when I am editing the <code>file2.txt</code> but it should get removed when I finished saving and closed text editor.</p>
| 0debug
|
void qmp_blockdev_snapshot(const char *node, const char *overlay,
Error **errp)
{
BlockdevSnapshot snapshot_data = {
.node = (char *) node,
.overlay = (char *) overlay
};
TransactionAction action = {
.type = TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT,
.u.blockdev_snapshot = &snapshot_data,
};
blockdev_do_action(&action, errp);
}
| 1threat
|
Simple HTTP/TCP health check for MongoDB : <p>I need to create a Health Check for a MongoDB instance inside a Docker container.</p>
<p>Although I can make a workaround and use the Mongo Ping using the CLI, the best option is to create a simple HTTP or TCP testing. There is no response in the default 27017 port in standard ping testings.</p>
<p>Is there any trustworthy way to do it?</p>
| 0debug
|
After updating to OS 10 Swift 3 I am getting the following Web Filtering output message : <p>The App is working but wanted to know what this actually means?</p>
<pre><code>WF: _userSettingsForUser mobile: {
filterBlacklist = (
);
filterWhitelist = (
);
restrictWeb = 1;
useContentFilter = 0;
useContentFilterOverrides = 0;
whitelistEnabled = 0;
}
2016-09-26 14:27:14.161509 Aviation USA & Canada[412:49541]
WF: _WebFilterIsActive returning: NO
</code></pre>
| 0debug
|
jquery - change input text to hidden field using button click event : <p>I want to change the current input text field to hidden when i click on the submit button, but I don't know how to do this in jquery. If anyone know how to do it, please answer below. Thank you so much.</p>
| 0debug
|
Multi-homed SQL Server with High Availability Groups : <p>We have two servers (SQL-ATL01, SQL-ATL02) that make up a Failover Cluster, each running as part of a SQL Server High Availability Group (HAG). Each server has two network cards. One is a 10Gbit card that is directly connected to the other server and is used for Synchronizing the HAG on a 192.168.99.x subnet. The other is a 1Gbit card that is used to connect the DB servers to a switch to communicate with the application servers on a 10.0.0.x subnet. The Listener is pointed to the 192.168.99.x subnet.</p>
<p>We want to add a third server (SQL-NYC01) in another physical location to the cluster and run it as an Async replica part of the HAG, but the VPN only routes traffic on the subnet on the 1Gbit network.</p>
<p>Is there any way to set up the Failover Cluster and High Availability Group to tell it:</p>
<ul>
<li>Send synchronous replica traffic for SQL-ATL01 <--> SQL-ATL02 over 192.168.99.x</li>
<li>Send asynchronous replica traffic for (SQL-ATL01, SQL-ATL02) <--> SQL-NYC01 over 10.0.0.x</li>
</ul>
<p>Or do we <em>have</em> to have <em>all</em> replica traffic going in and out on the same IP address/subnet? </p>
| 0debug
|
Scaling flexdashboard gauge in R : <p>I'm trying to use <code>flexdashboard::gauge</code>, but it is always the same size(doesn't scale) and I don't know how to change it's size. I know there is a way to do this for normal plots using <code>renderPlot</code> and setting for example <code>height</code>. Is there a way to do something similar with <code>renderGauge</code> ? </p>
<p>It's my code:</p>
<pre><code>---
title: "Test"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
library(googleVis)
```
Column {.sidebar}
-----------------------------------------------------------------------
```{r}
selectInput("n", label = "Number of bins:",
choices = c(10, 20, 35, 50), selected = 20)
```
Column {data-width=500}
-----------------------------------------------------------------------
### Gauge
```{r}
renderGauge({
invalidateLater(1000, session)
dane <- round(runif(1,0,100))
df <- data.frame(Label = "IRR", Value = as.numeric(dane))
gauge(dane, min = 0, max = 100, symbol = '%', gaugeSectors(
success = c(80, 100), warning = c(40, 79), danger = c(0, 39)
))
})
```
### Chart A
```{r }
renderPlot({
plot(1:10,1:10)
})
```
Column {data-width=500}
-----------------------------------------------------------------------
### Chart B
```{r}
renderPlot({
plot(1:10,1:10)
})
```
### Chart C
```{r}
renderPlot({
plot(1:10,1:10)
})
```
</code></pre>
<p>The rest of charts are to fill the place.
Do you know how to make this gauge bigger?
Thanks!</p>
| 0debug
|
What does ^= do in python : <p>I have seen the operator ^= in code now once and I dont know what it does. This was used to find a single occurrence of a number in an array. So A = [1,1,2,3,3] it should return 2. This is how it was used</p>
<pre><code>def solution(A):
lone_num = 0
for number in A:
lone_num ^= number
return lone_num
</code></pre>
<p>Not particularly sure what it does. </p>
| 0debug
|
Get match string from string statement c# :
string l_path = "C:\\Winodws\\System32\calc.exe"
string findString = "C:\\Windows";
if (l_path.Contains(findString ))//C:\\Winodws\\System32\calc.exe
{
string l_EnvironmentVariable = l_path.Replace(findString , "WinDir");
}
i want to get exact match from string statement.But when i check contains method its checking for any character match..
| 0debug
|
static inline target_phys_addr_t get_pgaddr(target_phys_addr_t sdr1,
int sdr_sh,
target_phys_addr_t hash,
target_phys_addr_t mask)
{
return (sdr1 & ((target_phys_addr_t)(-1ULL) << sdr_sh)) | (hash & mask);
}
| 1threat
|
static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8,
AVStream *st, AVPacket *pkt, uint32_t *timestamp,
const uint8_t *buf, int len, uint16_t seq,
int flags)
{
int start_partition, end_packet;
int extended_bits, part_id;
int pictureid_present = 0, tl0picidx_present = 0, tid_present = 0,
keyidx_present = 0;
int pictureid = -1, pictureid_mask = 0;
int returned_old_frame = 0;
uint32_t old_timestamp;
if (!buf) {
if (vp8->data) {
int ret = ff_rtp_finalize_packet(pkt, &vp8->data, st->index);
if (ret < 0)
return ret;
*timestamp = vp8->timestamp;
if (vp8->sequence_dirty)
pkt->flags |= AV_PKT_FLAG_CORRUPT;
return 0;
}
return AVERROR(EAGAIN);
}
if (len < 1)
return AVERROR_INVALIDDATA;
extended_bits = buf[0] & 0x80;
start_partition = buf[0] & 0x10;
part_id = buf[0] & 0x0f;
end_packet = flags & RTP_FLAG_MARKER;
buf++;
len--;
if (extended_bits) {
if (len < 1)
return AVERROR_INVALIDDATA;
pictureid_present = buf[0] & 0x80;
tl0picidx_present = buf[0] & 0x40;
tid_present = buf[0] & 0x20;
keyidx_present = buf[0] & 0x10;
buf++;
len--;
}
if (pictureid_present) {
if (len < 1)
return AVERROR_INVALIDDATA;
if (buf[0] & 0x80) {
if (len < 2)
return AVERROR_INVALIDDATA;
pictureid = AV_RB16(buf) & 0x7fff;
pictureid_mask = 0x7fff;
buf += 2;
len -= 2;
} else {
pictureid = buf[0] & 0x7f;
pictureid_mask = 0x7f;
buf++;
len--;
}
}
if (tl0picidx_present) {
buf++;
len--;
}
if (tid_present || keyidx_present) {
buf++;
len--;
}
if (len < 1)
return AVERROR_INVALIDDATA;
if (start_partition && part_id == 0 && len >= 3) {
int res;
int non_key = buf[0] & 0x01;
if (!non_key) {
vp8_free_buffer(vp8);
vp8->sequence_ok = 1;
vp8->sequence_dirty = 0;
vp8->got_keyframe = 1;
} else {
int can_continue = vp8->data && !vp8->is_keyframe &&
avio_tell(vp8->data) >= vp8->first_part_size;
if (!vp8->sequence_ok)
return AVERROR(EAGAIN);
if (!vp8->got_keyframe)
return vp8_broken_sequence(ctx, vp8, "Keyframe missing\n");
if (pictureid >= 0) {
if (pictureid != ((vp8->prev_pictureid + 1) & pictureid_mask)) {
return vp8_broken_sequence(ctx, vp8,
"Missed a picture, sequence broken\n");
} else {
if (vp8->data && !can_continue)
return vp8_broken_sequence(ctx, vp8,
"Missed a picture, sequence broken\n");
}
} else {
uint16_t expected_seq = vp8->prev_seq + 1;
int16_t diff = seq - expected_seq;
if (vp8->data) {
if ((diff == 0 || diff == 1) && can_continue) {
} else {
return vp8_broken_sequence(ctx, vp8,
"Missed too much, sequence broken\n");
}
} else {
if (diff != 0)
return vp8_broken_sequence(ctx, vp8,
"Missed unknown data, sequence broken\n");
}
}
if (vp8->data) {
vp8->sequence_dirty = 1;
if (avio_tell(vp8->data) >= vp8->first_part_size) {
int ret = ff_rtp_finalize_packet(pkt, &vp8->data, st->index);
if (ret < 0)
return ret;
pkt->flags |= AV_PKT_FLAG_CORRUPT;
returned_old_frame = 1;
old_timestamp = vp8->timestamp;
} else {
vp8_free_buffer(vp8);
}
}
}
vp8->first_part_size = (AV_RL16(&buf[1]) << 3 | buf[0] >> 5) + 3;
if ((res = avio_open_dyn_buf(&vp8->data)) < 0)
return res;
vp8->timestamp = *timestamp;
vp8->broken_frame = 0;
vp8->prev_pictureid = pictureid;
vp8->is_keyframe = !non_key;
} else {
uint16_t expected_seq = vp8->prev_seq + 1;
if (!vp8->sequence_ok)
return AVERROR(EAGAIN);
if (vp8->timestamp != *timestamp) {
return vp8_broken_sequence(ctx, vp8,
"Received no start marker; dropping frame\n");
}
if (seq != expected_seq) {
if (vp8->is_keyframe) {
return vp8_broken_sequence(ctx, vp8,
"Missed part of a keyframe, sequence broken\n");
} else if (vp8->data && avio_tell(vp8->data) >= vp8->first_part_size) {
vp8->broken_frame = 1;
vp8->sequence_dirty = 1;
} else {
return vp8_broken_sequence(ctx, vp8,
"Missed part of the first partition, sequence broken\n");
}
}
}
if (!vp8->data)
return vp8_broken_sequence(ctx, vp8, "Received no start marker\n");
vp8->prev_seq = seq;
if (!vp8->broken_frame)
avio_write(vp8->data, buf, len);
if (returned_old_frame) {
*timestamp = old_timestamp;
return end_packet ? 1 : 0;
}
if (end_packet) {
int ret;
ret = ff_rtp_finalize_packet(pkt, &vp8->data, st->index);
if (ret < 0)
return ret;
if (vp8->sequence_dirty)
pkt->flags |= AV_PKT_FLAG_CORRUPT;
return 0;
}
return AVERROR(EAGAIN);
}
| 1threat
|
realloc error reding file : I have problem with this code.
Some times it runs perfectly but another times it stops before the last print with the error message: "Error in './ga': realloc(): invalid pointer: 0x00007f97d1304ac6".
I'm go crazy because I'm not use realloc()!
I suspect that there is somethink wrong in the file reding part, because this problem comes out when I add this part to the code (previously I set the data with other two arrays).
#include <limits> // std::numeric_limits<double>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <utility>
//#include <math.h>
#include <algorithm> // std::lower_bound, std::find
#include <random>
#include <cmath>
#include <cstring>
#include <iomanip> // std::setprecision
#include <vector> // std::vector
#define NUM_CITIES 14
long size_pop;
long tot_elem;
int main(int argc, char *argv[]) {
size_pop = atol(argv[1]);
std::cout << size_pop << "\n";
std::cout << "double: " << sizeof(double) << "\n";
std::cout << "float: " << sizeof(float) << "\n";
std::cout << "int: " << sizeof(int) << "\n";
std::cout << "long: " << sizeof(long) << "\n";
tot_elem = NUM_CITIES * size_pop;
std::cout << "tot_elem: " << tot_elem << "\n";
// std::cin.get() != '\n';
struct timeval start, end, setup_start, setup_end, fitness_start, fitness_end, next_gen_start, next_gen_end, sort_start, sort_end;
struct timeval fitness_total_start, fitness_total_end, probability_start, probability_end, selection_start, selection_end;
struct timeval crossover_start, crossover_end, mutation_start, mutation_end;
gettimeofday(&start, NULL);
std::vector<double> v_set;
std::vector<double> v_fit;
std::vector<double> v_sor;
std::vector<double> v_sel;
std::vector<double> v_cros;
std::vector<double> v_mut;
// coordinate delle città
// int x[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
// int y[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
// città
//city city_set[NUM_CITIES];
int city_set_x[NUM_CITIES];
int city_set_y[NUM_CITIES];
int city_set_id[NUM_CITIES];
// popolazione composta da path (possibii soluzioni al problema)
int *city_x = (int *)malloc(tot_elem * sizeof(int));
// memset(city_x, -1, tot_elem * sizeof(int));
int *city_y = (int *)malloc(tot_elem * sizeof(int));
// memset(city_y, -1, tot_elem * sizeof(int));
int *city_id = (int *)malloc(tot_elem * sizeof(int));
// memset(city_id, -1, tot_elem * sizeof(int));
fit *fitness_element = (fit *)malloc(size_pop * sizeof(fit));
// mating_pool, i migliori elementi della popolazione
int *mating_x = (int *)malloc(NUM_CITIES * SIZE_MATING * sizeof(int));
int *mating_y = (int *)malloc(NUM_CITIES * SIZE_MATING * sizeof(int));
int *mating_id = (int *)malloc(NUM_CITIES * SIZE_MATING * sizeof(int));
srand(time(NULL));
// std::cin.get() != '\n';
std::cout << "read from file\n";
// leggo le coordinate delle città
const char *filename = "/home/davide/Documenti/GA/BURMA14.txt";
char *line;
size_t n = 5;
FILE *coordFile = fopen(filename, "r");
//FILE *f = fopen("/home/davide/Documenti/GA/result.txt", "w");
int i; // indice dell'array
int x, y; // coordinate delle città
while(getline(&line, &n, coordFile) != -1 && i <= NUM_CITIES)
{
int items = sscanf(line, "%d %d %d", &i, &x, &y);
if(items != 3)
exit(EXIT_FAILURE);
--i;
//std::cout << x << "\n";
//std::cout << y << "\n";
//std::cout << i << "\n";
city_set_x[i] = x;
city_set_y[i] = y;
city_set_id[i] = i;
}
fclose(coordFile);
// std::cin.get() != '\n';
// stampa
std::cout << "[CITTA.X]\n";
for(int i = 0; i < NUM_CITIES; ++i) {
// city_set_x[i] = x[i];
// city_set[i].x = i + 1;
std::cout << city_set_x[i] << " ";
}
std::cout << "\n";
std::cout << "[CITTA.Y]\n";
for(int i = 0; i < NUM_CITIES; ++i) {
// city_set_y[i] = y[i];
// city_set[i].y = i + 1;
std::cout << city_set_y[i] << " ";
}
std::cout << "\n";
std::cout << "[CITTA.ID]\n";
for(int i = 0; i < NUM_CITIES; ++i) {
// city_set_id[i] = i;
std::cout << city_set_id[i] << " ";
}
std::cout << "\n";
}
The file from I read is this.
1 16 96
2 16 94
3 20 92
4 22 93
5 25 97
6 22 96
7 20 97
8 17 96
9 16 97
10 14 98
11 16 97
12 21 95
13 19 97
14 20 94
| 0debug
|
match multiple str in list python : <p>all</p>
<pre><code>a = ['T01--X','T02--X','T03--X','T04--XX','T01--X','T01--Y','T05--X','T02-YY','T01-T02','T02-T03']
</code></pre>
<p>how to match str including T01 or T02 or T03 in this list?</p>
<p>thanks in advance</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.