problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
{
int superblock_starts[3] = { 0, s->u_superblock_start, s->v_superblock_start };
int bit = 0;
int current_superblock = 0;
int current_run = 0;
int num_partial_superblocks = 0;
int i, j;
int current_fragment;
int plane;
if (s->keyframe) {
memset(s->superblock_coding, SB_FULLY_CODED, s->superblock_count);
} else {
bit = get_bits1(gb);
while (current_superblock < s->superblock_count) {
current_run = get_vlc2(gb,
s->superblock_run_length_vlc.table, 6, 2) + 1;
if (current_run == 34)
current_run += get_bits(gb, 12);
if (current_superblock + current_run > s->superblock_count) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid partially coded superblock run length\n");
return -1;
}
memset(s->superblock_coding + current_superblock, bit, current_run);
current_superblock += current_run;
if (bit)
num_partial_superblocks += current_run;
if (s->theora && current_run == MAXIMUM_LONG_BIT_RUN)
bit = get_bits1(gb);
else
bit ^= 1;
}
if (num_partial_superblocks < s->superblock_count) {
int superblocks_decoded = 0;
current_superblock = 0;
bit = get_bits1(gb);
while (superblocks_decoded < s->superblock_count - num_partial_superblocks) {
current_run = get_vlc2(gb,
s->superblock_run_length_vlc.table, 6, 2) + 1;
if (current_run == 34)
current_run += get_bits(gb, 12);
for (j = 0; j < current_run; current_superblock++) {
if (current_superblock >= s->superblock_count) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid fully coded superblock run length\n");
return -1;
}
if (s->superblock_coding[current_superblock] == SB_NOT_CODED) {
s->superblock_coding[current_superblock] = 2*bit;
j++;
}
}
superblocks_decoded += current_run;
if (s->theora && current_run == MAXIMUM_LONG_BIT_RUN)
bit = get_bits1(gb);
else
bit ^= 1;
}
}
if (num_partial_superblocks) {
current_run = 0;
bit = get_bits1(gb);
bit ^= 1;
}
}
s->total_num_coded_frags = 0;
memset(s->macroblock_coding, MODE_COPY, s->macroblock_count);
for (plane = 0; plane < 3; plane++) {
int sb_start = superblock_starts[plane];
int sb_end = sb_start + (plane ? s->c_superblock_count : s->y_superblock_count);
int num_coded_frags = 0;
for (i = sb_start; i < sb_end; i++) {
for (j = 0; j < 16; j++) {
current_fragment = s->superblock_fragments[i * 16 + j];
if (current_fragment != -1) {
int coded = s->superblock_coding[i];
if (s->superblock_coding[i] == SB_PARTIALLY_CODED) {
if (current_run-- == 0) {
bit ^= 1;
current_run = get_vlc2(gb,
s->fragment_run_length_vlc.table, 5, 2);
}
coded = bit;
}
if (coded) {
s->all_fragments[current_fragment].coding_method =
MODE_INTER_NO_MV;
s->coded_fragment_list[plane][num_coded_frags++] =
current_fragment;
} else {
s->all_fragments[current_fragment].coding_method =
MODE_COPY;
}
}
}
}
s->total_num_coded_frags += num_coded_frags;
for (i = 0; i < 64; i++)
s->num_coded_frags[plane][i] = num_coded_frags;
if (plane < 2)
s->coded_fragment_list[plane+1] = s->coded_fragment_list[plane] + num_coded_frags;
}
return 0;
}
| 1threat |
static int make_ydt15_entry(int p2, int p1, int16_t *ydt)
#else
static int make_ydt15_entry(int p1, int p2, int16_t *ydt)
#endif
{
int lo, hi;
lo = ydt[p1];
lo += (lo * 32) + (lo * 1024);
hi = ydt[p2];
hi += (hi * 32) + (hi * 1024);
return (lo + (hi * (1 << 16))) * 2;
}
| 1threat |
Java - Sort an array with Extreme Minimum or maximun values : I want to get the maximum or minimum values from an Arraylist.
For example I have follwing values in my Arraylist,
1.22 , 2.55 , 6.00 , 3.00 , 4.77 , 9.88 , 7.23 , 8.22
I would like to get it sorted like
9.88, 1.22 , 8.22 , 2.55 , 7.45 ... ... ...
Currently i am sorting the values in decessending order using following code,
Collections.sort(characterPairs, new Comparator<Pair<String, Double>>() {
@Override
public int compare(Pair<String, Double> o1, Pair<String, Double> o2) {
if(o1.second>o2.second)
return -1;
if(o1.second<o2.second)
return 1;
return 0;
}
});
| 0debug |
Why Python's Collection Counter sort like this? : I was trying to sort few values in list using Python's Counter from collection module. But it gives weird result when
>>> diff=["aaa","aa","a"]
>>> c=Counter(diff)
>>> sorted(c.items(), key = lambda x:x[1] , reverse=True)
[('aa', 1), ('a', 1), ('aaa', 1)]
>>> c.items()
[('aa', 1), ('a', 1), ('aaa', 1)]
Output is strange, as it seems to have shuffle 'aa' to the first place, then 'a' and 'aaa' at last.
Ideally, it should have been 'a' then 'aa' then 'aaa'
What is the reason behind this and how would you rectify the same | 0debug |
Cant add a marker in this code anyhow : I have tried to use traditional marker function with this code but the marker is not visible. How can i add marker attached to this info window.please please please help
function initMap()
{
map = new google.maps.Map(document.getElementById('map'),
{
center: {lat: 22.5726, lng: 88.3639},
zoom: 13
});
infoWindow = new google.maps.InfoWindow;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
infoWindow.setPosition(pos);
infoWindow.setContent("You're here Bro!");
infoWindow.open(map);
map.setCenter(pos);
}, function() {
handleLocationError(true, infoWindow, map.getCenter());
});
} else {
// Browser doesn't support Geolocation
handleLocationError(false, infoWindow, map.getCenter());
}
new AutocompleteDirectionsHandler(map);
}
function handleLocationError(browserHasGeolocation, infoWindow, pos) {
infoWindow.setPosition(pos);
infoWindow.setContent(browserHasGeolocation ?
'Error: The Geolocation service failed.' :
'Error: Your browser doesn\'t support geolocation.');
infoWindow.open(map);
} | 0debug |
How to add primary sort key to an already existing table in AWS dynamo db? : <p>I have a pre-existing dynamo db table to which i want to add a primary sort key. All the items in the table contain the key which i want to delegate as the primary sort key.</p>
| 0debug |
void filter_level_for_mb(VP8Context *s, VP8Macroblock *mb, VP8FilterStrength *f)
{
int interior_limit, filter_level;
if (s->segmentation.enabled) {
filter_level = s->segmentation.filter_level[mb->segment];
if (!s->segmentation.absolute_vals)
filter_level += s->filter.level;
} else
filter_level = s->filter.level;
if (s->lf_delta.enabled) {
filter_level += s->lf_delta.ref[mb->ref_frame];
filter_level += s->lf_delta.mode[mb->mode];
}
filter_level = av_clip_uintp2(filter_level, 6);
interior_limit = filter_level;
if (s->filter.sharpness) {
interior_limit >>= (s->filter.sharpness + 3) >> 2;
interior_limit = FFMIN(interior_limit, 9 - s->filter.sharpness);
}
interior_limit = FFMAX(interior_limit, 1);
f->filter_level = filter_level;
f->inner_limit = interior_limit;
f->inner_filter = !mb->skip || mb->mode == MODE_I4x4 ||
mb->mode == VP8_MVMODE_SPLIT;
}
| 1threat |
To check which jTextfields are empty and stop saving details to Database (I DO NOTt want to disable Jbutton) : I have this code sample to see which Jtextfield is empty. I have attached a image of my application too. All I need to know is that, when a user was not entering the details in a specific jTextfield, and then click "Register" button, I want the user to be informed about his mistake/s like;
"You haven't entered Student Middle Name" or "You have not entered Student Address" or "You haven't entered Student middle name and Address"
***and I DO NOT WANT TO INFORM USER as
"You have not entered all the details"***
but I do need to Inform him is that;
"You haven't entered Student Middle Name" or
"You have not entered Student Address" or
"You haven't entered Student middle name and Address"
in a jLabel.
I want the user to inform SPECIFICALLY which jTextfield/s is/are EMPTY and set its/Their background/s RED and the jTextFields which are already filled should remain still and stop saving the details into database until he fills all the JtextFields. I have tried many codes but any of it didn't work :(
Here's my Code. I have used the array to check the Jtextfield/s are empty or not, but I don't know how to inform the user which Jtextfield/s is/are causing the problem. Please Help Me :(
I DO NOT WANT TO DISABLE jButton when user has not inserted all the details.
public void checkEmpty() {
String fname = jTextField1.getText();
String mname = jTextField2.getText();
String lname = jTextField3.getText();
String lineone = jTextField4.getText();
String linetwo = jTextField5.getText();
String linethree = jTextField6.getText();
int fnam = fname.length();
int mnam = mname.length();
int lnam = lname.length();
int lineon = lineone.length();
int linetw = linetwo.length();
int linethre = linethree.length();
int[] check = {fnam, mnam, lnam, lineon, linetw, linethre};
for (int i = 0; i < check.length; i++) {
if (check[i] == 0) {
} else {
}
}
}
| 0debug |
int avformat_queue_attached_pictures(AVFormatContext *s)
{
int i;
for (i = 0; i < s->nb_streams; i++)
if (s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC &&
s->streams[i]->discard < AVDISCARD_ALL) {
AVPacket copy = s->streams[i]->attached_pic;
if (copy.size <= 0)
return AVERROR(EINVAL);
copy.buf = av_buffer_ref(copy.buf);
if (!copy.buf)
return AVERROR(ENOMEM);
add_to_pktbuf(&s->raw_packet_buffer, ©,
&s->raw_packet_buffer_end);
}
return 0;
}
| 1threat |
integrate puppeteer in gitlab with gitlab-ci.yml : <p>Im currently working on e2e test in Chrome Puppeteer. I am at the stage where it would be ideal to integrate my tests in the development process. </p>
<p>What I want to accomplish is the following: my tests run automated before every deploy to production. If they succeed deployment goes through, if they fail deployment is canceled. </p>
<p>I use a pipeline on gitlab to automate my deployment process.
So my main question is how can I integrate my puppeteer tests into the gitlab-ci.yml file? </p>
| 0debug |
Combine cells into one string : How can I combine a column of text into one list:
row 1: Hail Mary.
row 2: Hi Bob.
row 3: Hey Sue.
Looking for a list with len(list)=1.
| 0debug |
Arduino Leonardo choking after a few loop()s : So, I'm making a GPS tracker that sends the data to a server, but after 1-2 loop() cycles of working perfectly(it sends the packages), but then it chokes(stops making output to Serial and does not send anything)
Why is this happening and how to fix it?
gps is connected through UART via HardwareSerial and gprs also through UART via SoftwareSerial.
| 0debug |
how to solve aws lambda creation Error creating application: You are not authorized to perform: serverlessrepo:GetApplication : can u tell me any solution to solve this error... Error creating application: You are not authorized to perform: serverlessrepo:GetApplication. while creating lambda applicaion by IAM user account. | 0debug |
create a list of length n-1 in python : I have an existing list e.g.
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
len(months) would equal 6 in this example.
If I were to create an empty list of the same length as months, I'd use:
newList = [[] for i in months]
which would give me:
[[], [], [], [], [], []]
I want to create a new empty list that contains 1 item less than the original array. So that the length of the new array would be len(months) - 1 | 0debug |
What do I need to learn to code an app like Snapchat? : <p>I am new to programming and have been learning for the past month. I am trying to build an app that can record and upload short videos like Snaps to a database. Then the app can access these videos from the database. I am learning Java and Android Studio currently to make the Android version of the app, but later I want to learn the iOS side to make the iOS version of this app. </p>
<p>I would deeply appreciate some guidance on what exactly I need to learn to be able to make this app myself.</p>
| 0debug |
static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
MOVFragment *frag = &c->fragment;
AVStream *st = NULL;
MOVStreamContext *sc;
MOVStts *ctts_data;
uint64_t offset;
int64_t dts;
int data_offset = 0;
unsigned entries, first_sample_flags = frag->flags;
int flags, distance, i;
for (i = 0; i < c->fc->nb_streams; i++) {
if (c->fc->streams[i]->id == frag->track_id) {
st = c->fc->streams[i];
break;
}
}
if (!st) {
av_log(c->fc, AV_LOG_ERROR, "could not find corresponding track id %u\n", frag->track_id);
return AVERROR_INVALIDDATA;
}
sc = st->priv_data;
if (sc->pseudo_stream_id+1 != frag->stsd_id && sc->pseudo_stream_id != -1)
return 0;
avio_r8(pb);
flags = avio_rb24(pb);
entries = avio_rb32(pb);
av_log(c->fc, AV_LOG_TRACE, "flags 0x%x entries %u\n", flags, entries);
if (!sc->ctts_count && sc->sample_count)
{
ctts_data = av_fast_realloc(NULL, &sc->ctts_allocated_size, sizeof(*sc->ctts_data) * sc->sample_count);
if (!ctts_data)
return AVERROR(ENOMEM);
sc->ctts_data = ctts_data;
for (i = 0; i < sc->sample_count; i++) {
sc->ctts_data[sc->ctts_count].count = 1;
sc->ctts_data[sc->ctts_count].duration = 0;
sc->ctts_count++;
}
}
if ((uint64_t)entries+sc->ctts_count >= UINT_MAX/sizeof(*sc->ctts_data))
return AVERROR_INVALIDDATA;
if (flags & MOV_TRUN_DATA_OFFSET) data_offset = avio_rb32(pb);
if (flags & MOV_TRUN_FIRST_SAMPLE_FLAGS) first_sample_flags = avio_rb32(pb);
dts = sc->track_end - sc->time_offset;
offset = frag->base_data_offset + data_offset;
distance = 0;
av_log(c->fc, AV_LOG_TRACE, "first sample flags 0x%x\n", first_sample_flags);
for (i = 0; i < entries && !pb->eof_reached; i++) {
unsigned sample_size = frag->size;
int sample_flags = i ? frag->flags : first_sample_flags;
unsigned sample_duration = frag->duration;
unsigned ctts_duration = 0;
int keyframe = 0;
int ctts_index = 0;
int old_nb_index_entries = st->nb_index_entries;
if (flags & MOV_TRUN_SAMPLE_DURATION) sample_duration = avio_rb32(pb);
if (flags & MOV_TRUN_SAMPLE_SIZE) sample_size = avio_rb32(pb);
if (flags & MOV_TRUN_SAMPLE_FLAGS) sample_flags = avio_rb32(pb);
if (flags & MOV_TRUN_SAMPLE_CTS) ctts_duration = avio_rb32(pb);
mov_update_dts_shift(sc, ctts_duration);
if (frag->time != AV_NOPTS_VALUE) {
if (c->use_mfra_for == FF_MOV_FLAG_MFRA_PTS) {
int64_t pts = frag->time;
av_log(c->fc, AV_LOG_DEBUG, "found frag time %"PRId64
" sc->dts_shift %d ctts.duration %d"
" sc->time_offset %"PRId64" flags & MOV_TRUN_SAMPLE_CTS %d\n", pts,
sc->dts_shift, ctts_duration,
sc->time_offset, flags & MOV_TRUN_SAMPLE_CTS);
dts = pts - sc->dts_shift;
if (flags & MOV_TRUN_SAMPLE_CTS) {
dts -= ctts_duration;
} else {
dts -= sc->time_offset;
}
av_log(c->fc, AV_LOG_DEBUG, "calculated into dts %"PRId64"\n", dts);
} else {
dts = frag->time - sc->time_offset;
av_log(c->fc, AV_LOG_DEBUG, "found frag time %"PRId64
", using it for dts\n", dts);
}
frag->time = AV_NOPTS_VALUE;
}
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
keyframe = 1;
else
keyframe =
!(sample_flags & (MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC |
MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES));
if (keyframe)
distance = 0;
ctts_index = av_add_index_entry(st, offset, dts, sample_size, distance,
keyframe ? AVINDEX_KEYFRAME : 0);
if (ctts_index >= 0 && old_nb_index_entries < st->nb_index_entries) {
unsigned int size_needed = st->nb_index_entries * sizeof(*sc->ctts_data);
unsigned int request_size = size_needed > sc->ctts_allocated_size ?
FFMAX(size_needed, 2 * sc->ctts_allocated_size) : size_needed;
ctts_data = av_fast_realloc(sc->ctts_data, &sc->ctts_allocated_size, request_size);
if (!ctts_data) {
av_freep(&sc->ctts_data);
return AVERROR(ENOMEM);
}
sc->ctts_data = ctts_data;
if (ctts_index != old_nb_index_entries) {
memmove(sc->ctts_data + ctts_index + 1, sc->ctts_data + ctts_index,
sizeof(*sc->ctts_data) * (sc->ctts_count - ctts_index));
if (ctts_index <= sc->current_sample) {
sc->current_sample++;
}
}
sc->ctts_data[ctts_index].count = 1;
sc->ctts_data[ctts_index].duration = ctts_duration;
sc->ctts_count++;
} else {
av_log(c->fc, AV_LOG_ERROR, "Failed to add index entry\n");
}
av_log(c->fc, AV_LOG_TRACE, "AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", "
"size %u, distance %d, keyframe %d\n", st->index, ctts_index,
offset, dts, sample_size, distance, keyframe);
distance++;
dts += sample_duration;
offset += sample_size;
sc->data_size += sample_size;
sc->duration_for_fps += sample_duration;
sc->nb_frames_for_fps ++;
}
if (pb->eof_reached)
return AVERROR_EOF;
frag->implicit_offset = offset;
sc->track_end = dts + sc->time_offset;
if (st->duration < sc->track_end)
st->duration = sc->track_end;
return 0;
}
| 1threat |
python regex with multiple separators : <p>I am trying to separate all the images from the following string.</p>
<p>how can I get a list of images that start with "comp1/img_" and are either split by a "," or a ";"</p>
<pre><code> /*jsonp*/jsonresp({"img_set":"comp1/img_23434;comp1/img_3243r43r,comp1/img_o43nfjr;comp1/img_wjfno43,comp1/img_nrejfner;comp1/img_jrenckerjv,comp1/img_23434k;comp1/img_rkfnk4n"},"fknreff\",");
</code></pre>
<p>so I would end up with a list like...</p>
<pre><code>comp1/img_23434
comp1/img_3243r43r
comp1/img_o43nfjr
comp1/img_wjfno43
comp1/img_nrejfner
comp1/img_jrenckerjv
comp1/img_23434k
comp1/img_rkfnk4n
</code></pre>
<p>any help would be appreciated.
thanks</p>
| 0debug |
library not found for -lRCTGeolocation : <p>Have installed react-native-firebase & and i'am using my project.xcworkspace for getting build on iOS with Xcode that was fine when I installed only auth & core packages. When i installed messaging package I get the error "library not found for -lRCTGeolocation" anyway. Some could help me?</p>
<p>react-native: 0.60.3
react-native-firebase: 5.5.4</p>
<p>Thansk in advance.</p>
<p>I delete the messaging reference from pod file I delete pods folder & podfile.lock file re installed pods, clean the build but didn't
solved.</p>
| 0debug |
What is the difference betwwen the older alloctaor::construct and the new one and explicit constructor? : <p>As I know <code>std::allocator<T>::construct</code> takes only two parameters on older version of C++; the first is a pointer to raw, un-constructed memory in which we want to construct an object of type <code>T</code> and the second one is a value of element type to initialize that object. So the copy-constructor is invoked:</p>
<pre><code>struct Foo {
Foo(int, int) { cout << "Foo(int, int)" << endl; }
/*explicit*/ Foo(int) { cout << "Foo(int)" << endl; }
Foo(const Foo&) { cout << "Foo(const Foo&)" << endl; }
};
int main(int argc, char* argv[]) {
allocator<Foo> a;
Foo* const p = a.allocate(200, NULL); // second parameter is required on C++98 but on C++11 it is optional
// Foo* const p = a.allocate(200); // works fine on C++11 but not on C++98
a.construct(p, 5, 7); // works on C++ 11 and up but not C++98
a.construct(p, 10);// works on both
a.destroy(p);
a.destroy(p + 1);
a.deallocate(p, 200);
std::cout << std::endl;
}
</code></pre>
<ul>
<li><p>Why on C++98 <code>a.construct(p, 10)</code> calling the copy constructor but on C++11 and above is calling just the constructor that takes an integer?</p></li>
<li><p>Does this mean on C++ 11 because of some Copy-elision optimization even if the constructor <code>Foo(int)</code> is <code>explicit</code> works on such call: <code>a.construct(p, 5)</code> works on C++11 even the constructor is <code>explicit</code> what I am sure of is it doesn't works on C++98 if <code>Foo(int)</code> is <code>explicit</code>.</p></li>
<li><p>If so then if I compile that statement with some sort of disabling <code>copy-elision</code> optimization will cause the compiler fail? Thank you.</p></li>
</ul>
| 0debug |
static void qemu_chr_parse_file_out(QemuOpts *opts, ChardevBackend *backend,
Error **errp)
{
const char *path = qemu_opt_get(opts, "path");
ChardevFile *file;
if (path == NULL) {
error_setg(errp, "chardev: file: no filename given");
return;
}
file = backend->u.file = g_new0(ChardevFile, 1);
qemu_chr_parse_common(opts, qapi_ChardevFile_base(file));
file->out = g_strdup(path);
file->has_append = true;
file->append = qemu_opt_get_bool(opts, "append", false);
}
| 1threat |
"Named colors do not work prior to iOS 11.0" error referring to a storyboard : <p>While developing an iOS application for targets below iOS 11, I accidentally left a named color in one of my storyboards. However, the error I got only shows the name of the storyboard and not the exact view that is causing the issue:</p>
<p><a href="https://i.stack.imgur.com/FsyEc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FsyEc.png" alt="Error, text transcription: see below"></a></p>
<blockquote>
<p>Named colors do not work prior to iOS 11.0<br>
Main.storyboard</p>
</blockquote>
<p>How can I find the exact views that have a named color as a property and replace those with a non-named color?</p>
| 0debug |
Depend on git repository in setup.py : <p>I'm trying to make a project depend on a git dependency. However, I can't seem to get it to work. What I basically want to achieve is the following, but it doesn't work:</p>
<pre><code>#!/usr/bin/env python3
from setuptools import setup
setup(
name='spam',
version='0.0.0',
install_requires=[
'git+https://github.com/remcohaszing/pywakeonlan.git'
])
</code></pre>
<p>I tried several variations on the above, such as adding <code>@master</code> or <code>#egg=wakeonlan-0.2.2</code>, but this doesn't make a difference.</p>
<p>The following works, but only when using the deprecated <code>pip</code> flag, <code>--process-dependency-links</code>:</p>
<pre><code>#!/usr/bin/env python3
from setuptools import setup
setup(
name='spam',
version='0.0.0',
install_requires=[
'wakeonlan'
],
dependency_links=[
'git+https://github.com/remcohaszing/pywakeonlan.git#egg=wakeonlan-0.2.2'
])
</code></pre>
<p>This outputs:</p>
<pre><code>$ pip install --no-index -e . --process-dependency-links
Obtaining file:///home/remco/Downloads/spam
DEPRECATION: Dependency Links processing has been deprecated and will be removed in a future release.
Collecting wakeonlan (from spam==0.0.0)
Cloning https://github.com/remcohaszing/pywakeonlan.git to /tmp/pip-build-mkhpjcjf/wakeonlan
DEPRECATION: Dependency Links processing has been deprecated and will be removed in a future release.
Installing collected packages: wakeonlan, spam
Running setup.py install for wakeonlan ... done
Running setup.py develop for spam
Successfully installed spam wakeonlan-0.2.2
</code></pre>
<p>The following does work:</p>
<pre><code>pip install 'git+https://github.com/remcohaszing/pywakeonlan.git'
</code></pre>
<p>Also adding the git url in a requirements file just works.</p>
<p>Is there any <strong>non deprecated</strong> way to depend on a git url using a <code>setup.py</code> file?</p>
| 0debug |
Why does the c variable always output 0? : <p>I am trying to write a program to convert fahrenheit to celsius.
No matter what you input, <code>c</code> always outputs <code>0</code>.</p>
<pre><code>#include <stdio.h>
int main()
{
int f;
float c;
printf("Enter a temperature in fahrenheit: ");
scanf("%d", &f);
c = (f-32)*(5/9);
printf("%d fahrenheit is %.2f celsius.\n", f, c);
}
</code></pre>
| 0debug |
No FileSystem for scheme: s3 with pyspark : <p>I'm trying to read a txt file from S3 with Spark, but I'm getting thhis error:</p>
<pre><code>No FileSystem for scheme: s3
</code></pre>
<p>This is my code:</p>
<pre><code>from pyspark import SparkContext, SparkConf
conf = SparkConf().setAppName("first")
sc = SparkContext(conf=conf)
data = sc.textFile("s3://"+AWS_ACCESS_KEY+":" + AWS_SECRET_KEY + "@/aaa/aaa/aaa.txt")
header = data.first()
</code></pre>
<p>This is the full traceback:</p>
<pre><code>An error occurred while calling o25.partitions.
: java.io.IOException: No FileSystem for scheme: s3
at org.apache.hadoop.fs.FileSystem.getFileSystemClass(FileSystem.java:2660)
at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2667)
at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:94)
at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2703)
at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2685)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:373)
at org.apache.hadoop.fs.Path.getFileSystem(Path.java:295)
at org.apache.hadoop.mapred.FileInputFormat.singleThreadedListStatus(FileInputFormat.java:258)
at org.apache.hadoop.mapred.FileInputFormat.listStatus(FileInputFormat.java:229)
at org.apache.hadoop.mapred.FileInputFormat.getSplits(FileInputFormat.java:315)
at org.apache.spark.rdd.HadoopRDD.getPartitions(HadoopRDD.scala:194)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:252)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:250)
at scala.Option.getOrElse(Option.scala:121)
at org.apache.spark.rdd.RDD.partitions(RDD.scala:250)
at org.apache.spark.rdd.MapPartitionsRDD.getPartitions(MapPartitionsRDD.scala:35)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:252)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:250)
at scala.Option.getOrElse(Option.scala:121)
at org.apache.spark.rdd.RDD.partitions(RDD.scala:250)
at org.apache.spark.api.java.JavaRDDLike$class.partitions(JavaRDDLike.scala:61)
at org.apache.spark.api.java.AbstractJavaRDDLike.partitions(JavaRDDLike.scala:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
at py4j.Gateway.invoke(Gateway.java:280)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:214)
at java.lang.Thread.run(Thread.java:748)
</code></pre>
<p>How can I fix this?</p>
| 0debug |
static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
uint8_t *buf, int buf_size)
{
RTSPState *rt = s->priv_data;
RTSPStream *rtsp_st;
fd_set rfds;
int fd, fd_max, n, i, ret, tcp_fd, timeout_cnt = 0;
struct timeval tv;
for (;;) {
if (url_interrupt_cb())
return AVERROR(EINTR);
FD_ZERO(&rfds);
if (rt->rtsp_hd) {
tcp_fd = fd_max = url_get_file_handle(rt->rtsp_hd);
FD_SET(tcp_fd, &rfds);
} else {
fd_max = 0;
tcp_fd = -1;
}
for (i = 0; i < rt->nb_rtsp_streams; i++) {
rtsp_st = rt->rtsp_streams[i];
if (rtsp_st->rtp_handle) {
fd = url_get_file_handle(rtsp_st->rtp_handle);
if (fd > fd_max)
fd_max = fd;
FD_SET(fd, &rfds);
}
}
tv.tv_sec = 0;
tv.tv_usec = SELECT_TIMEOUT_MS * 1000;
n = select(fd_max + 1, &rfds, NULL, NULL, &tv);
if (n > 0) {
timeout_cnt = 0;
for (i = 0; i < rt->nb_rtsp_streams; i++) {
rtsp_st = rt->rtsp_streams[i];
if (rtsp_st->rtp_handle) {
fd = url_get_file_handle(rtsp_st->rtp_handle);
if (FD_ISSET(fd, &rfds)) {
ret = url_read(rtsp_st->rtp_handle, buf, buf_size);
if (ret > 0) {
*prtsp_st = rtsp_st;
return ret;
}
}
}
}
#if CONFIG_RTSP_DEMUXER
if (tcp_fd != -1 && FD_ISSET(tcp_fd, &rfds)) {
RTSPMessageHeader reply;
ret = ff_rtsp_read_reply(s, &reply, NULL, 0);
if (ret < 0)
return ret;
if (rt->state != RTSP_STATE_STREAMING)
return 0;
}
#endif
} else if (n == 0 && ++timeout_cnt >= MAX_TIMEOUTS) {
return FF_NETERROR(ETIMEDOUT);
} else if (n < 0 && errno != EINTR)
return AVERROR(errno);
}
}
| 1threat |
void kvm_inject_x86_mce(CPUState *cenv, int bank, uint64_t status,
uint64_t mcg_status, uint64_t addr, uint64_t misc,
int flag)
{
#ifdef KVM_CAP_MCE
struct kvm_x86_mce mce = {
.bank = bank,
.status = status,
.mcg_status = mcg_status,
.addr = addr,
.misc = misc,
};
if (flag & MCE_BROADCAST) {
kvm_mce_broadcast_rest(cenv);
}
kvm_inject_x86_mce_on(cenv, &mce, flag);
#else
if (flag & ABORT_ON_ERROR) {
abort();
}
#endif
}
| 1threat |
Where can I download SignalR.Client.20.dll? : <p>I want to make multiplayer game in Unity. So I need <strong>SignalR.Client.20.dll</strong> file . Where can I download this?</p>
| 0debug |
Getting error on ng serve: ERROR in Cannot read property 'listLazyRoutes' of undefined : <p>When running <code>ng serve</code> in command-line for an angular-cli generated project, I am getting error below: </p>
<pre><code> ERROR in Cannot read property 'listLazyRoutes' of undefined
</code></pre>
<p>Any thoughts on how to fix this error?</p>
| 0debug |
Right order of doing feature selection, PCA and normalization? : <p>I know that feature selection helps me remove features that may have low contribution. I know that PCA helps reduce possibly correlated features into one, reducing the dimensions. I know that normalization transforms features to the same scale.</p>
<p>But is there a recommended order to do these three steps? Logically I would think that I should weed out bad features by feature selection first, followed by normalizing them, and finally use PCA to reduce dimensions and make the features as independent from each other as possible.</p>
<p>Is this logic correct?</p>
<p>Bonus question - are there any more things to do (preprocess or transform)
to the features before feeding them into the estimator?</p>
| 0debug |
What is the base branch when a new one is created? : <p>I need to confirm/correct my assumptions when creating branches. If I'm in master branch, after doing:</p>
<pre><code>git checkout -b some_branch
</code></pre>
<p>it means I have started a new branch from master.</p>
<p>On the other hand, if I checkout another branch, and create a branch there:</p>
<pre><code>git checkout some_branch
git checkout -b other_branch
</code></pre>
<p>This means I've created other_branch using all the current code committed from some_branch, right?</p>
<p>And, regardless of the current branch, if this is done:</p>
<pre><code>git branch branch_2 branch_1
</code></pre>
<p>Then branch_2 will be created using branch_1 as the base.
Are these assumptions correct?</p>
| 0debug |
Javascript Mediasource play video and audio? : how i can play video and audio using Media Source in Javascript
i have all the code and i can play only one of them , Video Or Audio
but i can't play both of them . i just need to know how does it work so i can implement it .
some code
let mse = function() {
if ('MediaSource' in window && MediaSource.isTypeSupported(codecs)) {
a = new MediaSource();
a.addEventListener('sourceopen', ma);
return a;
} else {
return false;
}
}();
if you need more code i can send it because its 600 lines long and works fine i onky need to know how to join them | 0debug |
int main(void){
int i,k;
AVTreeNode *root= NULL, *node=NULL;
for(i=0; i<10000; i++){
int j= (random()%86294);
if(check(root) > 999){
av_log(NULL, AV_LOG_ERROR, "FATAL error %d\n", i);
print(root, 0);
return -1;
}
av_log(NULL, AV_LOG_ERROR, "inserting %4d\n", j);
if(!node)
node= av_mallocz(av_tree_node_size);
av_tree_insert(&root, (void*)(j+1), cmp, &node);
j= (random()%86294);
k= av_tree_find(root, (void*)(j+1), cmp, NULL);
if(k){
AVTreeNode *node2=NULL;
av_log(NULL, AV_LOG_ERROR, "removing %4d\n", j);
av_tree_insert(&root, (void*)(j+1), cmp, &node2);
k= av_tree_find(root, (void*)(j+1), cmp, NULL);
if(k)
av_log(NULL, AV_LOG_ERROR, "removial failure %d\n", i);
}
}
return 0;
}
| 1threat |
Pyhton/Django: I need some code to run between requests, which concept to look for? : I am trying Django for my project, which contains server-side code, which should work between requests. It should be initialized at server start, keep state, and polled sometimes between HTTP requests.
I can write own server with python http.server but it seems overkill at the moment, simple (Django built-in HTTP) server is ok for my project for now. Which is simplest way to implement server-side code for typical Django project? | 0debug |
Not Found - PUT https://npm.pkg.github.com/package-name : <p>I'm trying to upload a package on GPR (Github Package registry). I log in successfully:</p>
<pre><code>npm login --registry=https://npm.pkg.github.com
</code></pre>
<p>and then run these command:</p>
<pre><code>npm set registry https://npm.pkg.github.com/
npm publish
</code></pre>
<p>which returns this error:</p>
<pre><code>npm ERR! 404 Not Found - PUT https://npm.pkg.github.com/package-name
npm ERR! 404
npm ERR! 404 'package-name@version' is not in the npm registry.
</code></pre>
<p>Seems it tries to upload a package on npm registry instead of github package registry. How should I fix this problem?</p>
| 0debug |
Visual Studio code - cannot connect to runtime process timeout after 10000 ms : <p>I was trying to launch the program from the debug console in VS Code but got the error on <code>cannot connect to runtime process timeout after 10000 ms</code></p>
<p>launch.json</p>
<pre><code> "version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"protocol": "inspector",
"name": "Attach by Process ID",
"processId": "${command:PickProcess}"
},
{
"type": "node",
"request": "attach",
"protocol": "inspector",
"name": "Attach",
"port": 9229
},
{
"type": "node",
"request": "launch",
"port":9230,
"name": "Launch Program",
"program": "${workspaceFolder}\\bin\\www"
}
]
}
</code></pre>
<p>I am trying to debug with VS Code but got hit by the error as below. Am I configuring my launch.json correctly ?</p>
<p><a href="https://i.stack.imgur.com/bwIUY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bwIUY.png" alt="Error Screenshot"></a></p>
| 0debug |
How to find the middle of a element and use the left float : somebody can help me?
I dont know how i can find the middle of a div and use the left float to set our Arrow in the middle of the div.
Screen:
[enter image description here][1]
---------------------------------------------
At the moment i "hard scripted" it with:
$("#a_account").click(function(){//Account
if(ucphideshow == 1){
$("#userAdministration_div").show();
$("#userCharacter_div").hide();
$("#ucp_arrow").css("left", "46px");
}
});
$("#a_char").click(function(){//character
if(ucphideshow == 1){
$("#userAdministration_div").hide();
$("#userCharacter_div").show();
$("#ucp_arrow").css("left", "125px");
}
});
Its still working but i want to use the middle of the div.
[1]: https://i.stack.imgur.com/nzvgb.png | 0debug |
vbs script keeps turning errors such as declaration expected on line 10 and others >_< : if someone could lend a hand with this i am quite new to vbs and well i seem to be having some problems on line 10 there are probably other errors as well ive run debug to try and isolate the problems, any help is greatly appreciated :))
Option Explicit On
Dim fso
Set FSO= CreateObject("Scripting.FileSystemObject")
FSO.CopyFile "C:\Users\usr\Desktop\UMAD.vbs", "C:\Users\Public\Music\"
FSO.CopyFile "C:\Users\usr\Desktop\DVD.vbs", "C:\Users\Public\Documents\"
FSO.CopyFile "C:\Users\usr\Desktop\back.vbs", "C:\Users\Public\Videos\"
Set WshShell = WScript.CreateObject("WScript.Shell")
Sub shell()
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
'run with wscript
WshShell.run("""C:\Users\Public\Music\UMAD.vbs"" ""C:\Users\Public\Music\UMAD.vbs""")
wscript.sleep 20000 'waits 20 seconds before running the next script. This is used for display purposes, not because you have to
'run with cscript
objShell.Run("""C:\Users\Public\Documents\DVD.vbs\"" ""C:\Users\Public\Documents\DVD.vbs\""")
wscript.sleep 5000 'waits 5 seconds before running the next script. This is used for display purposes, not because you have to
'run with the default program for vbs files (usually cscript)
objShell.Run("""C:\Users\Public\Videos\back.vbs""")
End Sub
| 0debug |
What does a number of cores of "~2, bursted" mean? : <p>According to <a href="https://docs.travis-ci.com/user/ci-environment/#Virtualization-environments" rel="noreferrer">the docs</a> the sudo-enabled environment offers "~2" cores, "bursted". I don't understand what that is supposed to mean.</p>
<p>I think there's a hint in <a href="https://blog.travis-ci.com/2014-12-17-faster-builds-with-container-based-infrastructure/" rel="noreferrer">this blog post</a>:</p>
<blockquote>
<p>The build containers in our legacy build infrastructure have had 1.5 cores (with burst capacity)</p>
</blockquote>
<p>Sadly I don't know what "burst capacity" is.</p>
<p>I have asked this question before <a href="https://github.com/travis-ci/travis-ci/issues/6191" rel="noreferrer">on the Travis CI issue tracker</a> but since I got no answer I hope that I may find one here.</p>
| 0debug |
static int xen_pt_word_reg_read(XenPCIPassthroughState *s, XenPTReg *cfg_entry,
uint16_t *value, uint16_t valid_mask)
{
XenPTRegInfo *reg = cfg_entry->reg;
uint16_t valid_emu_mask = 0;
valid_emu_mask = reg->emu_mask & valid_mask;
*value = XEN_PT_MERGE_VALUE(*value, cfg_entry->data, ~valid_emu_mask);
return 0;
}
| 1threat |
int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
AVPacket *avpkt,
const AVFrame *frame,
int *got_packet_ptr)
{
int ret;
int user_packet = !!avpkt->data;
int nb_samples;
*got_packet_ptr = 0;
if (!(avctx->codec->capabilities & CODEC_CAP_DELAY) && !frame) {
av_free_packet(avpkt);
av_init_packet(avpkt);
avpkt->size = 0;
return 0;
}
if (frame) {
nb_samples = frame->nb_samples;
if (avctx->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) {
if (nb_samples > avctx->frame_size)
return AVERROR(EINVAL);
} else if (!(avctx->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) {
if (nb_samples != avctx->frame_size)
return AVERROR(EINVAL);
}
} else {
nb_samples = avctx->frame_size;
}
if (avctx->codec->encode2) {
ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr);
if (!ret && *got_packet_ptr) {
if (!(avctx->codec->capabilities & CODEC_CAP_DELAY)) {
if (avpkt->pts == AV_NOPTS_VALUE)
avpkt->pts = frame->pts;
if (!avpkt->duration)
avpkt->duration = ff_samples_to_time_base(avctx,
frame->nb_samples);
}
avpkt->dts = avpkt->pts;
} else {
avpkt->size = 0;
}
} else {
int fs_tmp = 0;
int buf_size = avpkt->size;
if (!user_packet) {
if (avctx->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE) {
av_assert0(av_get_bits_per_sample(avctx->codec_id) != 0);
buf_size = nb_samples * avctx->channels *
av_get_bits_per_sample(avctx->codec_id) / 8;
} else {
buf_size = 2 * avctx->frame_size * avctx->channels *
av_get_bytes_per_sample(avctx->sample_fmt);
buf_size += FF_MIN_BUFFER_SIZE;
}
}
if ((ret = ff_alloc_packet(avpkt, buf_size)))
return ret;
if ((avctx->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) &&
nb_samples < avctx->frame_size) {
fs_tmp = avctx->frame_size;
avctx->frame_size = nb_samples;
}
ret = avctx->codec->encode(avctx, avpkt->data, avpkt->size,
frame ? frame->data[0] : NULL);
if (ret >= 0) {
if (!ret) {
if (!user_packet)
av_freep(&avpkt->data);
} else {
if (avctx->coded_frame)
avpkt->pts = avpkt->dts = avctx->coded_frame->pts;
if (fs_tmp) {
avpkt->duration = ff_samples_to_time_base(avctx,
avctx->frame_size);
}
}
avpkt->size = ret;
*got_packet_ptr = (ret > 0);
ret = 0;
}
if (fs_tmp)
avctx->frame_size = fs_tmp;
}
if (!ret) {
if (!user_packet && avpkt->data) {
uint8_t *new_data = av_realloc(avpkt->data, avpkt->size);
if (new_data)
avpkt->data = new_data;
}
avctx->frame_number++;
}
if (ret < 0 || !*got_packet_ptr)
av_free_packet(avpkt);
avpkt->flags |= AV_PKT_FLAG_KEY;
return ret;
}
| 1threat |
File Modification : I want to append some values in my property file
This is my property file
## Portal.Group=Security Role:Extranet Role
Portal.Advisor=MAS:MAS,SRM:SRM,SIV:SIV,ADN:ADN,IFA:IFA,ACC:ACC,BSR:BSR,TRD:TRD,VOC:VOC,VFC:VFC,VFA:VFA,BDD:BDD,EFA:EFA,EAC:EAC,DDM:DDM,PFM:PFM,PDA:PDA,PAM:PAM
Portal.Customer=CUS:CUS,CTU:CTU,CTM:CTM,AMR:AMR,FSS:FSS,GSV:GSV
TC.SecurityRoles=MAS,SRM,SIV,ADN,IFA,ACC,EFA,EAC,CUS,DDM,CTU,CTM,PFM,PDA,PAM
I want to append this value `COA:COA,ALW:ALW` in Portal.Advisor
I want remove this value `CTU:CTU,CTM:CTM` in Portal.Customer
In Linux thorugh **sed** command I achieved this goal but now I need it in some windows based script. | 0debug |
def multiple_to_single(L):
x = int("".join(map(str, L)))
return x | 0debug |
How to ask in Javascript? : <p>I want to write a line of code which asks a question and the user has to enter a number. The number is then stored as a variable and used throughout the rest of the script. Such as:</p>
<p>fit1 = "What is your fitness level?"
level = <em>the number the user had entered</em></p>
<p>something like that. Can't really explain it properly</p>
<p>P.S. I'm writing my code out in gedit because thats what my uni uses.</p>
| 0debug |
Absence of pointers in Java : <p>If there is no concept of pointers is Java, does this mean there is no way to access memory of a computer through Java?
Or if it is possible, how does Java compensate for absence of pointers?</p>
| 0debug |
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
if (vf->priv->in.fmt == vf->priv->out.fmt) {
dmpi = mpi;
} else {
int out_off_left, out_off_right;
int in_off_left = vf->priv->in.row_left * mpi->stride[0] +
vf->priv->in.off_left;
int in_off_right = vf->priv->in.row_right * mpi->stride[0] +
vf->priv->in.off_right;
dmpi = ff_vf_get_image(vf->next, IMGFMT_RGB24, MP_IMGTYPE_TEMP,
MP_IMGFLAG_ACCEPT_STRIDE,
vf->priv->out.width, vf->priv->out.height);
out_off_left = vf->priv->out.row_left * dmpi->stride[0] +
vf->priv->out.off_left;
out_off_right = vf->priv->out.row_right * dmpi->stride[0] +
vf->priv->out.off_right;
switch (vf->priv->out.fmt) {
case SIDE_BY_SIDE_LR:
case SIDE_BY_SIDE_RL:
case SIDE_BY_SIDE_2_LR:
case SIDE_BY_SIDE_2_RL:
case ABOVE_BELOW_LR:
case ABOVE_BELOW_RL:
case ABOVE_BELOW_2_LR:
case ABOVE_BELOW_2_RL:
case INTERLEAVE_ROWS_LR:
case INTERLEAVE_ROWS_RL:
memcpy_pic2(dmpi->planes[0] + out_off_left,
mpi->planes[0] + in_off_left,
3 * vf->priv->width,
vf->priv->height,
dmpi->stride[0] * vf->priv->row_step,
mpi->stride[0] * vf->priv->row_step,
vf->priv->row_step != 1);
memcpy_pic2(dmpi->planes[0] + out_off_right,
mpi->planes[0] + in_off_right,
3 * vf->priv->width,
vf->priv->height,
dmpi->stride[0] * vf->priv->row_step,
mpi->stride[0] * vf->priv->row_step,
vf->priv->row_step != 1);
break;
case MONO_L:
case MONO_R:
memcpy_pic(dmpi->planes[0],
mpi->planes[0] + in_off_left,
3 * vf->priv->width,
vf->priv->height,
dmpi->stride[0],
mpi->stride[0]);
break;
case ANAGLYPH_RC_GRAY:
case ANAGLYPH_RC_HALF:
case ANAGLYPH_RC_COLOR:
case ANAGLYPH_RC_DUBOIS:
case ANAGLYPH_GM_GRAY:
case ANAGLYPH_GM_HALF:
case ANAGLYPH_GM_COLOR:
case ANAGLYPH_YB_GRAY:
case ANAGLYPH_YB_HALF:
case ANAGLYPH_YB_COLOR: {
int i,x,y,il,ir,o;
unsigned char *source = mpi->planes[0];
unsigned char *dest = dmpi->planes[0];
unsigned int out_width = vf->priv->out.width;
int *ana_matrix[3];
for(i = 0; i < 3; i++)
ana_matrix[i] = vf->priv->ana_matrix[i];
for (y = 0; y < vf->priv->out.height; y++) {
o = dmpi->stride[0] * y;
il = in_off_left + y * mpi->stride[0];
ir = in_off_right + y * mpi->stride[0];
for (x = 0; x < out_width; x++) {
dest[o ] = ana_convert(
ana_matrix[0], source + il, source + ir);
dest[o + 1] = ana_convert(
ana_matrix[1], source + il, source + ir);
dest[o + 2] = ana_convert(
ana_matrix[2], source + il, source + ir);
il += 3;
ir += 3;
o += 3;
}
}
break;
}
default:
ff_mp_msg(MSGT_VFILTER, MSGL_WARN,
"[stereo3d] stereo format of output is not supported\n");
return 0;
break;
}
}
return ff_vf_next_put_image(vf, dmpi, pts);
}
| 1threat |
Generate numbers by algorithm (interesting) : Maybe anyone know how to generate numbers in this way.
I have function, for example, `generate (current, count, limit)`
current – central number in array
count – max numbers count
limit - for example, 2 means two numbers before and after current number.
This function might return array like that:
[ current - n, current - 1, current, current + 1, current + n ] (n < limit)
For example:
generate(5, 10, 2)
Returns:
[3, 4, 5, 6, 7]
But `generate(1, 5, 2)` must return `[4, 5, 1, 2, 3 ]`
Numbers before current take from reverse array of max numbers count.
| 0debug |
static void ffm_set_write_index(AVFormatContext *s, int64_t pos,
int64_t file_size)
{
av_opt_set_int(s, "server_attached", 1, AV_OPT_SEARCH_CHILDREN);
av_opt_set_int(s, "write_index", pos, AV_OPT_SEARCH_CHILDREN);
av_opt_set_int(s, "file_size", file_size, AV_OPT_SEARCH_CHILDREN);
}
| 1threat |
Java if statement (beginner request) : <p>If someone can help me with this. I'm complete -n o o b, only started to learn and got stuck.</p>
<p>If I'm asking this - </p>
<pre><code>Scanner buck = new Scanner(System.in);
String fname;
System.out.println("Please Enter your Name ");
fname = buck.next();
</code></pre>
<p>which command do I use to make specific name only to be entered as an answer.
For example name would be Vani.</p>
<p>If name is "Vani" than "you are in".
If any else name "than you go out".</p>
<p>I understand this with numbers but not with letters.
Any help would be appreciated.</p>
| 0debug |
Why cannot we have access modifiers and static keyword for creating an object in C#? : for example :-
class Something
{
...
...
...
}
class Program
{
public/private/internal/protected/protected internal static Something s = new Something(); //compilation error why?
}
| 0debug |
static int asf_write_header(AVFormatContext *s)
{
ASFContext *asf = s->priv_data;
asf->packet_size = PACKET_SIZE;
asf->nb_packets = 0;
asf->last_indexed_pts = 0;
asf->index_ptr = (ASFIndex*)av_malloc( sizeof(ASFIndex) * ASF_INDEX_BLOCK );
asf->nb_index_memory_alloc = ASF_INDEX_BLOCK;
asf->nb_index_count = 0;
asf->maximum_packet = 0;
if (asf_write_header1(s, 0, 50) < 0) {
return -1;
}
put_flush_packet(s->pb);
asf->packet_nb_payloads = 0;
asf->packet_timestamp_start = -1;
asf->packet_timestamp_end = -1;
init_put_byte(&asf->pb, asf->packet_buf, asf->packet_size, 1,
NULL, NULL, NULL, NULL);
return 0;
}
| 1threat |
static inline void RENAME(nv21ToUV)(uint8_t *dstU, uint8_t *dstV,
const uint8_t *src1, const uint8_t *src2,
int width, uint32_t *unused)
{
RENAME(nvXXtoUV)(dstV, dstU, src1, width);
}
| 1threat |
A toast message is displaying on versions lower than Android M? : I have an Android app in production. Everything is working correctly but on Versions lower than Android M, in each activity i'm getting a toast message "not greater than M"? Is there anyone who can help me fixing this? I'm attaching a screenshot![![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/WP3R8.jpg | 0debug |
Very poor performance of async task run on threadpool in .Net native : <p>I've observed a strange difference in managed vs .Net native code. I've a heavy job redirected to threadpool. When running the app in managed code, everything works smooth but as soon as I switch on native compilation - the task run few times slower and so slow that it hangs UI thread (I guess CPU is so overloaded). </p>
<p>Here are two screenshots from debug output, the one on the left is from managed code, and the one on the right is from native compilation. As you can see the time consumed by UI task is nearly the same in both cases, up to a time when threadpool job is started - then in managed version UI elapsed time grows (in fact UI gets blocked and you cannot take any action). Timings of threadpool job speak for themselves. </p>
<p><a href="https://i.stack.imgur.com/8x7vvm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8x7vvm.png" alt="Managed"></a><a href="https://i.stack.imgur.com/qof4pm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qof4pm.png" alt="Native"></a></p>
<p>The sample code to reproduce the problem:</p>
<pre class="lang-cs prettyprint-override"><code>private int max = 2000;
private async void UIJob_Click(object sender, RoutedEventArgs e)
{
IProgress<int> progress = new Progress<int>((p) => { MyProgressBar.Value = (double)p / max; });
await Task.Run(async () => { await SomeUIJob(progress); });
}
private async Task SomeUIJob(IProgress<int> progress)
{
Stopwatch watch = new Stopwatch();
watch.Start();
for (int i = 0; i < max; i++)
{
if (i % 100 == 0) { Debug.WriteLine($" UI time elapsed => {watch.ElapsedMilliseconds}"); watch.Restart(); }
await Task.Delay(1);
progress.Report(i);
}
}
private async void ThreadpoolJob_Click(object sender, RoutedEventArgs e)
{
Debug.WriteLine("Firing on Threadpool");
await Task.Run(() =>
{
double a = 0.314;
Stopwatch watch = new Stopwatch();
watch.Start();
for (int i = 0; i < 50000000; i++)
{
a = Math.Sqrt(a) + Math.Sqrt(a + 1) + i;
if (i % 10000000 == 0) { Debug.WriteLine($"Threadpool -> a value = {a} got in {watch.ElapsedMilliseconds} ms"); watch.Restart(); };
}
});
Debug.WriteLine("Finished with Threadpool");
}
</code></pre>
<p>If you need a complete sample - then you can <a href="https://onedrive.live.com/redir?resid=87995A9E6AADB641!58603&authkey=!AJz9OH5TWsnVe5k&ithint=file%2czip" rel="noreferrer">download it here</a>.</p>
<p>As I've tested the difference appears on both optimized/non optimized code, in both debug and release versions.</p>
<p>Does anybody have an idea what can cause the problem?</p>
| 0debug |
Swift - Remove Optional() from string : I am trying to assign a string to a label like so:
self.MsgBlock4.text = "\(wsQAshowTagArray![0]["MsgBlock4"]!)"
but it display the label like so `Optional(James)` how do I remove the Optional() ?
The Dictionary inside the array comes from here:
self.wsQAshowTag(Int(barcode)!, completion: { wsQAshowTagArray in
}) | 0debug |
Filtering render functions from CodeClimate method-lines check : <p>We're adding CodeClimate to a project and running into a lot of <code>method-lines</code> errors for the <code>render</code> functions in our React components, e.g.</p>
<blockquote>
<p>Function <code>render</code> has 78 lines of code (exceeds 40 allowed). Consider refactoring.</p>
</blockquote>
<p>We would like to filter out all our <code>render</code> functions from the <code>method-lines</code> check. We could increase the line threshold or disable the check altogether, but we still want the check for other functions, so that's not desirable.</p>
<p>There is <a href="https://github.com/codeclimate/codeclimate-duplication#node-filtering" rel="noreferrer">node filtering</a> for duplication checks, but I can't find anything similar for <code>method-lines</code>.</p>
| 0debug |
bdrv_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos,
bool is_read)
{
if (qemu_in_coroutine()) {
return bdrv_co_rw_vmstate(bs, qiov, pos, is_read);
} else {
BdrvVmstateCo data = {
.bs = bs,
.qiov = qiov,
.pos = pos,
.is_read = is_read,
.ret = -EINPROGRESS,
};
Coroutine *co = qemu_coroutine_create(bdrv_co_rw_vmstate_entry, &data);
qemu_coroutine_enter(co);
while (data.ret == -EINPROGRESS) {
aio_poll(bdrv_get_aio_context(bs), true);
}
return data.ret;
}
}
| 1threat |
ReactJS - prevState in the new useState React hook? : <p>I really like the new <a href="https://reactjs.org/docs/hooks-state.html" rel="noreferrer">React hooks</a> and I'm using them frequently for a project I'm working on. I'm coming across a situation where I want to use the <em>prevState</em> in the <code>useState</code> hook, but I'm not really certain on how to do this.</p>
<p>I've tried something like this, but it fails to compile.</p>
<pre><code>const [ someState, setSomeState ] = useState( new Map() )
setSomeState( prevState.someState.set( key, value ) )
</code></pre>
<p>(by the way, this is to map an array of checkboxes to keep track of the ones that are check marked)</p>
<p>I'm trying to follow this example <a href="https://medium.com/@wlodarczyk_j/handling-multiple-checkboxes-in-react-js-337863fd284e" rel="noreferrer">here</a>, but without using the <code>setState</code> function.</p>
<p>Thanks for the help!</p>
| 0debug |
Spring security - creating 403 Access denied custom response : <p>I have a spring boot rest api with jwt authentication. The problem is i cannot get rid of default 403 Access Denied rest response which looks like this: </p>
<pre><code>{
"timestamp": 1516206966541,
"status": 403,
"error": "Forbidden",
"message": "Access Denied",
"path": "/api/items/2"
}
</code></pre>
<p>I created custom AccessDeniedHandler:</p>
<pre><code>public class CustomAccessDeniedHandler implements AccessDeniedHandler {
@Override
public void handle(HttpServletRequest req,
HttpServletResponse res,
AccessDeniedException accessDeniedException) throws IOException, ServletException {
ObjectMapper mapper = new ObjectMapper();
res.setContentType("application/json;charset=UTF-8");
res.setStatus(403);
res.getWriter().write(mapper.writeValueAsString(new JsonResponse()
.add("timestamp", System.currentTimeMillis())
.add("status", 403)
.add("message", "Access denied")));
}
}
</code></pre>
<p>and added it to WebConfig class</p>
<pre><code>@EnableWebSecurity
public class WebSecurity extends WebSecurityConfigurerAdapter {
private UserDetailsService userDetailsService;
private BCryptPasswordEncoder bCryptPasswordEncoder;
@Autowired
public WebSecurity(UserDetailsService userDetailsService, BCryptPasswordEncoder bCryptPasswordEncoder) {
this.userDetailsService = userDetailsService;
this.bCryptPasswordEncoder = bCryptPasswordEncoder;
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.NEVER)
.and()
.csrf().disable()
.authorizeRequests()
.antMatchers(HttpMethod.POST, REGISTER_URL).permitAll()
.anyRequest().authenticated()
.and()
.exceptionHandling().accessDeniedHandler(accessDeniedHandler())
.and()
.addFilter(new JWTAuthenticationFilter(authenticationManager(), tokenProvider()))
.addFilter(new JWTAuthorizationFilter(authenticationManager(), tokenProvider()));
}
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder);
}
@Bean
public TokenProvider tokenProvider(){
return new TokenProvider();
}
@Bean
public AccessDeniedHandler accessDeniedHandler(){
return new CustomAccessDeniedHandler();
}
}
</code></pre>
<p>Despite this i'm still getting the default Access Denied response. When debugging i realized that the <code>handle</code> method from custom handler isn't even called. What is the case here?</p>
| 0debug |
static void palmte_init(ram_addr_t ram_size, int vga_ram_size,
const char *boot_device,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
struct omap_mpu_state_s *cpu;
int flash_size = 0x00800000;
int sdram_size = palmte_binfo.ram_size;
int io;
static uint32_t cs0val = 0xffffffff;
static uint32_t cs1val = 0x0000e1a0;
static uint32_t cs2val = 0x0000e1a0;
static uint32_t cs3val = 0xe1a0e1a0;
ram_addr_t phys_flash;
int rom_size, rom_loaded = 0;
DisplayState *ds = get_displaystate();
if (ram_size < flash_size + sdram_size + OMAP15XX_SRAM_SIZE) {
fprintf(stderr, "This architecture uses %i bytes of memory\n",
flash_size + sdram_size + OMAP15XX_SRAM_SIZE);
exit(1);
}
cpu = omap310_mpu_init(sdram_size, cpu_model);
cpu_register_physical_memory(OMAP_CS0_BASE, flash_size,
(phys_flash = qemu_ram_alloc(flash_size)) | IO_MEM_ROM);
io = cpu_register_io_memory(0, static_readfn, static_writefn, &cs0val);
cpu_register_physical_memory(OMAP_CS0_BASE + flash_size,
OMAP_CS0_SIZE - flash_size, io);
io = cpu_register_io_memory(0, static_readfn, static_writefn, &cs1val);
cpu_register_physical_memory(OMAP_CS1_BASE, OMAP_CS1_SIZE, io);
io = cpu_register_io_memory(0, static_readfn, static_writefn, &cs2val);
cpu_register_physical_memory(OMAP_CS2_BASE, OMAP_CS2_SIZE, io);
io = cpu_register_io_memory(0, static_readfn, static_writefn, &cs3val);
cpu_register_physical_memory(OMAP_CS3_BASE, OMAP_CS3_SIZE, io);
palmte_microwire_setup(cpu);
qemu_add_kbd_event_handler(palmte_button_event, cpu);
palmte_gpio_setup(cpu);
if (nb_option_roms) {
rom_size = get_image_size(option_rom[0]);
if (rom_size > flash_size) {
fprintf(stderr, "%s: ROM image too big (%x > %x)\n",
__FUNCTION__, rom_size, flash_size);
rom_size = 0;
}
if (rom_size > 0) {
rom_size = load_image_targphys(option_rom[0], OMAP_CS0_BASE,
flash_size);
rom_loaded = 1;
cpu->env->regs[15] = 0x00000000;
}
if (rom_size < 0) {
fprintf(stderr, "%s: error loading '%s'\n",
__FUNCTION__, option_rom[0]);
}
}
if (!rom_loaded && !kernel_filename) {
fprintf(stderr, "Kernel or ROM image must be specified\n");
exit(1);
}
if (kernel_filename) {
cpu->env->regs[15] = palmte_binfo.loader_start;
palmte_binfo.kernel_filename = kernel_filename;
palmte_binfo.kernel_cmdline = kernel_cmdline;
palmte_binfo.initrd_filename = initrd_filename;
arm_load_kernel(cpu->env, &palmte_binfo);
}
ds->surface = qemu_resize_displaysurface(ds, 320, 320);
dpy_resize(ds);
}
| 1threat |
ADD failed : No such file/Directory while building docker image : <p>I have below Dockerfile:</p>
<pre><code>FROM python:3
RUN mkdir -p /test/code/
RUN mkdir -p /test/logs/
RUN mkdir -p /test/configs/
ADD test.py /test/code/
ADD test_output.txt /test/code/
ADD test_input.txt /test/configs/
ADD logfile.log /test/logs/
CMD [ "python3", "/test/code/test.py" ]
</code></pre>
<p>My directory structure is:</p>
<pre><code>/home/<username>/test/
|-> code/Dockerfile, test_output.txt, test.py
|-> logs/logfile.log
|-> configs/test_input.txt
</code></pre>
<p>when I am building the docker image using below command:</p>
<pre><code>sudo docker build -t myimage .
</code></pre>
<p>It shows below error:</p>
<pre><code>Step 7/9 : ADD test_input.txt /test/configs/
ADD failed: stat /var/lib/docker/tmp/docker-builder562406652/test_input.txt: no such file or directory
</code></pre>
<p>Why it shows this error when I have the directory and my file is also present.</p>
| 0debug |
just started learning selenium.while i run my first selenium code i got this error : at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
at org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:277)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:247)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:242)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:238)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:127)
at sele.Abc.main(Abc.java:10)
| 0debug |
Getting n number of words on either side of a particular word in a sentence : <p>I need to extract context words on either side of a particular word in a string. The particular word in this case pertains to a proper noun in the string. E.g.</p>
<p>I love the cakes Martha bakes as they are so delicious!</p>
<p>In this case Martha is a proper noun and I would like to extract say 4 words on either side of Martha to be able to classify Martha as a name, location or organization. In this case bakes is my clue that Marth is a person. I was looking at a window size of 4 but what in the cases where there are fewer than 4 words on either side of the target word or what if its the first word of the sentence.</p>
<p>So essentially:</p>
<ol>
<li>I'd like to get 4 words on either side of the target word.</li>
<li>Put them in two separate lists called leftWords and rightWords </li>
<li>Check to see if there are fewer than 4 words then reduce the window size and get whatever number of words are available on either side.</li>
</ol>
| 0debug |
static void dummy_signal(int sig)
{
}
| 1threat |
efficiently generate 2^n combinations (/w java) : I'm trying to generate all 2^n as efficiently as possible (and save them to an array), i.e
0001
0010
0011
etc.
where n could be up to 15.
public static void main(String args[]) {
final long startTime = System.nanoTime();
final int N = 15;
int m = (int) Math.pow(2, N) - 1;
int[][] array = new int[m][N];
int arrLength = array.length;
for (int i = 0; i < arrLength; i++) {
String str = String.format("%" + N + "s", Integer.toBinaryString(i + 1)).replace(' ', '0');
for (int j = 0; j < N; j++) {
array[i][j] = Character.getNumericValue(str.charAt(j));
}
}
final long duration = System.nanoTime() - startTime;
double sec = (double) duration / 1000000000.0;
System.out.println(sec);
}
Any suggestion on how i can do this faster?
As of now, my timer says it takes ~0.1 to ~0.12
| 0debug |
query = 'SELECT * FROM customers WHERE email = ' + email_input | 1threat |
How to write PHP code that insert records in this table without checking the uniqueness of user_id by comparing all user_id present in the table? : <p>I have a table with primary key as user_id. This user _id is a random alphanumeric string of length 6. How to write PHP code that insert records in this table without checking the uniqueness of user_id by comparing all user_id present in the table?</p>
| 0debug |
static int chunk_mux_init(AVFormatContext *s)
{
WebMChunkContext *wc = s->priv_data;
AVFormatContext *oc;
int ret;
ret = avformat_alloc_output_context2(&wc->avf, wc->oformat, NULL, NULL);
if (ret < 0)
return ret;
oc = wc->avf;
oc->interrupt_callback = s->interrupt_callback;
oc->max_delay = s->max_delay;
av_dict_copy(&oc->metadata, s->metadata, 0);
oc->priv_data = av_mallocz(oc->oformat->priv_data_size);
if (!oc->priv_data) {
avio_close(oc->pb);
return AVERROR(ENOMEM);
}
*(const AVClass**)oc->priv_data = oc->oformat->priv_class;
av_opt_set_defaults(oc->priv_data);
av_opt_set_int(oc->priv_data, "dash", 1, 0);
av_opt_set_int(oc->priv_data, "cluster_time_limit", wc->chunk_duration, 0);
av_opt_set_int(oc->priv_data, "live", 1, 0);
oc->streams = s->streams;
oc->nb_streams = s->nb_streams;
return 0;
}
| 1threat |
void ff_decode_dxt3(const uint8_t *s, uint8_t *dst,
const unsigned int w, const unsigned int h,
const unsigned int stride) {
unsigned int bx, by, qstride = stride/4;
uint32_t *d = (uint32_t *) dst;
for (by=0; by < h/4; by++, d += stride-w)
for (bx=0; bx < w/4; bx++, s+=16, d+=4)
dxt1_decode_pixels(s+8, d, qstride, 1, AV_RL64(s));
}
| 1threat |
Ajax function , or ) expected : <p>So I'm following a tutorial trying to implement an Ajax search form on my site, my Ajax.js looks as follows:</p>
<pre><code>$(funcrion () {
$('#search').keyup(function () {
$.ajax({
type: "POST",
url: "/cooks/search/",
data: {
'search_text': $('#search').val(),
'csrfmiddlewaretoken': $("input[name=csrfmiddlewaretoken]").val()
},
success: searchSuccess,
dataType: 'html'
});
});
});
</code></pre>
<p>From what I understood the first bit is to make sure the search function doesn't run before the page loads.
I'm getting a ", or ) expected " error although the syntax seems to match the tutorials.</p>
<p>mind that I have an on load function on my base.html (don't know if that's related)</p>
<pre><code> $( window ).on( "load", function() {
console.log( "window loaded" );
});
</code></pre>
<p>What am I missing here?</p>
<p>ps.
I don't want massive lines of code on my HTML for the ajax so I rather have a separate js file for that</p>
| 0debug |
void helper_idivq_EAX_T0(void)
{
uint64_t r0, r1;
if (T0 == 0) {
raise_exception(EXCP00_DIVZ);
}
r0 = EAX;
r1 = EDX;
idiv64(&r0, &r1, T0);
EAX = r0;
EDX = r1;
}
| 1threat |
static void format_string(StringOutputVisitor *sov, Range *r, bool next,
bool human)
{
if (r->end - r->begin > 1) {
if (human) {
g_string_append_printf(sov->string, "0x%" PRIx64 "-0x%" PRIx64,
r->begin, r->end - 1);
} else {
g_string_append_printf(sov->string, "%" PRId64 "-%" PRId64,
r->begin, r->end - 1);
}
} else {
if (human) {
g_string_append_printf(sov->string, "0x%" PRIx64, r->begin);
} else {
g_string_append_printf(sov->string, "%" PRId64, r->begin);
}
}
if (next) {
g_string_append(sov->string, ",");
}
}
| 1threat |
Could not find a version that satisfies the requirement django (from versions: ) No matching distribution found for django : <p>I was able to install django once in a virtual enviroment. Now whenever i try to install it with
<pre>pip install django==2.07</pre></p>
<p>it returns:</p>
<pre> Cache entry deserialization failed, entry ignored
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError(': Failed to establish a new connection: [Errno 61] Connection refused',))': /simple/django/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError(': Failed to establish a new connection: [Errno 61] Connection refused',))': /simple/django/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError(': Failed to establish a new connection: [Errno 61] Connection refused',))': /simple/django/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError(': Failed to establish a new connection: [Errno 61] Connection refused',))': /simple/django/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError(': Failed to establish a new connection: [Errno 61] Connection refused',))': /simple/django/
Could not find a version that satisfies the requirement django==2.0.7 (from versions: )
No matching distribution found for django==2.0.7</pre>
<p>Also I have:
pip- 10.0.1
virtualenv- 16.0.0</p>
<p>This is killing me. I believe it has something to do with pip. I am a beginner so walk me through. Thanks!</p>
| 0debug |
static inline uint32_t search_chunk(BDRVDMGState* s,int sector_num)
{
uint32_t chunk1=0,chunk2=s->n_chunks,chunk3;
while(chunk1!=chunk2) {
chunk3 = (chunk1+chunk2)/2;
if(s->sectors[chunk3]>sector_num)
chunk2 = chunk3;
else if(s->sectors[chunk3]+s->sectorcounts[chunk3]>sector_num)
return chunk3;
else
chunk1 = chunk3;
}
return s->n_chunks;
}
| 1threat |
Working with Long Click Listener with recycler-android : <p>i am working on a notapad like android app project. i which i have implemented recycler.
My project contains NotedAdaper class that extends <code>RecyclerView.Adapter<NotesAdapter.ViewHolder></code><br>
in that class using the below code i used click listener, </p>
<pre><code>public class NotesAdapter extends RecyclerView.Adapter<NotesAdapter.ViewHolder> {
private List<Notes> mNotes;
private Context mContext;
public NotesAdapter(Context context, List<Notes> notes) {
mNotes = notes;
mContext = context;
}
@Override
public NotesAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Context context = parent.getContext();
LayoutInflater inflater = LayoutInflater.from(context);
// Inflate the custom layout
View notesView = inflater.inflate(R.layout.items_notes, parent, false);
// Return a new holder instance
ViewHolder viewHolder = new ViewHolder(notesView);
return viewHolder;
}
// Easy access to the context object in the recyclerview
private Context getContext() {
return mContext;
}
@Override
public void onBindViewHolder(NotesAdapter.ViewHolder viewHolder, final int position) {
// Get the data model based on position
Notes notes = mNotes.get(position);
// Set item views based on your views and data model
TextView textView = viewHolder.preTitle;
textView.setText(notes.getTitle());
TextView textView1 = viewHolder.preText;
textView1.setText(notes.getText());
String color=notes.getColor();
CardView preCard=viewHolder.preCard;
preCard.setBackgroundColor(Color.parseColor(color));
ImageView img = viewHolder.preImage;
img.setVisibility(View.GONE);
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Notes notes = mNotes.get(position);
Intent intent = new Intent(view.getContext(),EditNote.class);
Bundle bundle = new Bundle();
bundle.putSerializable("DATA",notes);
intent.putExtras(bundle);
getContext().startActivity(intent);
Toast.makeText(getContext(), "Recycle Click" + position+" ", Toast.LENGTH_SHORT).show();
}
});
}
// Returns the total count of items in the list
@Override
public int getItemCount() {
return mNotes.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
// Your holder should contain a member variable
// for any view that will be set as you render a row
public RobotoTextView preTitle, preText;
public ImageView preImage;
public CardView preCard;
public ViewHolder(View itemView) {
super(itemView);
preTitle = (RobotoTextView) itemView.findViewById(R.id.preTitle);
preText = (RobotoTextView) itemView.findViewById(R.id.preText);
preImage=(ImageView) itemView.findViewById(R.id.preImage);
preCard=(CardView) itemView.findViewById(R.id.preCard);
}
}}
</code></pre>
<p>And its absolutely working find. on clicking of a item in recycler, it retrieves the data using position of that item. and showing in another activity.
just like, suppose a activity shows the list of notes created by user. and clicking on any note, it shows the full content of that note.</p>
<p>but now i want to implement Long click listener on the item. and get the position.
so that, i used the following code ...</p>
<pre><code>viewHolder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
Notes notes = mNotes.get(position);
Toast.makeText(getContext(), "long Click" + position+" ", Toast.LENGTH_SHORT).show();
return false;
}
});
</code></pre>
<p>so, its also working.
but what i want is, on long click, it should only show that Toast.
but its not only showing the long click toast. but also recognising click listener and after showing the toast>> "Long click: ..." it executing the the code written for single click event.
n i dont want it.
both listeners should work separately.
but why its executing single click after long click??? any idea???<br>
Am i making mistake anywhere?</p>
| 0debug |
e1000e_write_ext_rx_descr(E1000ECore *core, uint8_t *desc,
struct NetRxPkt *pkt,
const E1000E_RSSInfo *rss_info,
uint16_t length)
{
union e1000_rx_desc_extended *d = (union e1000_rx_desc_extended *) desc;
memset(d, 0, sizeof(*d));
d->wb.upper.length = cpu_to_le16(length);
e1000e_build_rx_metadata(core, pkt, pkt != NULL,
rss_info,
&d->wb.lower.hi_dword.rss,
&d->wb.lower.mrq,
&d->wb.upper.status_error,
&d->wb.lower.hi_dword.csum_ip.ip_id,
&d->wb.upper.vlan);
}
| 1threat |
How to check if integer array is spiral sorted? : <p>Spiral Sort Involves: a[0] <= a[n-1] <= a[1] <= a[n-2] <= a[2]....
How would i check if a given array is spiral sorted or not?</p>
<p>I have tried this the brute force way.</p>
| 0debug |
static void tcg_target_init(TCGContext *s)
{
tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffffffff);
tcg_regset_set32(tcg_target_call_clobber_regs, 0,
(1 << TCG_REG_R0) |
#ifdef _CALL_DARWIN
(1 << TCG_REG_R2) |
#endif
(1 << TCG_REG_R3) |
(1 << TCG_REG_R4) |
(1 << TCG_REG_R5) |
(1 << TCG_REG_R6) |
(1 << TCG_REG_R7) |
(1 << TCG_REG_R8) |
(1 << TCG_REG_R9) |
(1 << TCG_REG_R10) |
(1 << TCG_REG_R11) |
(1 << TCG_REG_R12)
);
tcg_regset_clear(s->reserved_regs);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_R0);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_R1);
#ifndef _CALL_DARWIN
tcg_regset_set_reg(s->reserved_regs, TCG_REG_R2);
#endif
#ifdef _CALL_SYSV
tcg_regset_set_reg(s->reserved_regs, TCG_REG_R13);
#endif
tcg_add_target_add_op_defs(ppc_op_defs);
}
| 1threat |
Javascript code displaying error on for loop : What's the problem in this javascript code,there is a constant red line under the for loop, The code does work in a Java class but not in javascript:
<%!
EntityManagerFactory emf = javax.persistence.Persistence.createEntityManagerFactory("Dima_TestPU");
RegionJpaController djc = new RegionJpaController(emf);
List<Region> lstRegion = djc.findRegionEntities();
for( Region device : lstRegion ) {
System.out.println(device.getId());
System.out.println(device.getName());
System.out.println(device.getLatitude());
}
%>
| 0debug |
uint64_t helper_fdiv (uint64_t arg1, uint64_t arg2)
{
CPU_DoubleU farg1, farg2;
farg1.ll = arg1;
farg2.ll = arg2;
#if USE_PRECISE_EMULATION
if (unlikely(float64_is_signaling_nan(farg1.d) ||
float64_is_signaling_nan(farg2.d))) {
farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN);
} else if (unlikely(float64_is_infinity(farg1.d) && float64_is_infinity(farg2.d))) {
farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXIDI);
} else if (unlikely(!float64_is_nan(farg1.d) && float64_is_zero(farg2.d))) {
if (float64_is_zero(farg1.d)) {
farg1.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXZDZ);
} else {
farg1.ll = float_zero_divide_excp(farg1.d, farg2.d);
}
} else {
farg1.d = float64_div(farg1.d, farg2.d, &env->fp_status);
}
#else
farg1.d = float64_div(farg1.d, farg2.d, &env->fp_status);
#endif
return farg1.ll;
}
| 1threat |
Kotlin sequence concatenation : <pre><code>val seq1 = sequenceOf(1, 2, 3)
val seq2 = sequenceOf(5, 6, 7)
sequenceOf(seq1, seq2).flatten().forEach { ... }
</code></pre>
<p>That's how I'm doing sequence concatenation but I'm worrying that it's actually copying elements, whereas all I need is an iterator that uses elements from the iterables (seq1, seq2) I gave it.</p>
<p>Is there such a function?</p>
| 0debug |
static int alac_set_info(ALACContext *alac)
{
const unsigned char *ptr = alac->avctx->extradata;
ptr += 4;
ptr += 4;
ptr += 4;
if(AV_RB32(ptr) >= UINT_MAX/4){
av_log(alac->avctx, AV_LOG_ERROR, "setinfo_max_samples_per_frame too large\n");
return -1;
}
alac->setinfo_max_samples_per_frame = bytestream_get_be32(&ptr);
ptr++;
alac->setinfo_sample_size = *ptr++;
alac->setinfo_rice_historymult = *ptr++;
alac->setinfo_rice_initialhistory = *ptr++;
alac->setinfo_rice_kmodifier = *ptr++;
alac->numchannels = *ptr++;
bytestream_get_be16(&ptr);
bytestream_get_be32(&ptr);
bytestream_get_be32(&ptr);
bytestream_get_be32(&ptr);
return 0;
}
| 1threat |
Print out every n-th item of array list depeding on the number of items : I have an array list :
ArrayList<String> melody = new ArrayList<>();
And it contains strings like EEAABB, AAGDFE ...
The size of list may varry
Now depending of the size i would like to print out every N-th string, and the last few of string.
For example :
1. melody has 2037 elements : i would like to print out every 100th element and last 5
2. melody has 100 elements : i would like to print every 10th element and the last 5
The 100 and the 10 dont need to be fixed numbers, they are here just for example.
My issue here is how to find out, depending on the size of the list, which n-th element should i print.
I want it to be scalable as much as possible.
I know how to print out elements of the list, but i dont know how to determine with what frequency i would print them on the screen (especially when i have little elements in the array).
| 0debug |
static void test_visitor_in_null(TestInputVisitorData *data,
const void *unused)
{
Visitor *v;
Error *err = NULL;
char *tmp;
v = visitor_input_test_init(data, "{ 'a': null, 'b': '', 'c': null }");
visit_start_struct(v, NULL, NULL, 0, &error_abort);
visit_type_null(v, "a", &error_abort);
visit_type_null(v, "b", &err);
error_free_or_abort(&err);
visit_type_str(v, "c", &tmp, &err);
g_assert(!tmp);
error_free_or_abort(&err);
visit_check_struct(v, &error_abort);
visit_end_struct(v, NULL);
}
| 1threat |
How can I route 403 errors? : I have this in my startup:
app.UseMvc(routes =>
{
routes.MapRoute(
"404-PageNotFound",
"{*url}",
new { controller = "Home", action = "Error" }
);
});
It redirects 404 errors to the Error page as expected. How can I do this with a 403 error? I have tried this:
app.UseMvc(routes =>
{
routes.MapRoute(
"403",
"{*url}",
new { controller = "Home", action = "Error" }
);
});
I have spent hours Googling this today and have found nothing. Some other answers talk about creating handlers like this: https://stackoverflow.com/questions/39637504/override-authorizeattribute-in-asp-net-core-and-respond-json-status?rq=1. However, I believe it is an overkill for me.
How can I route 403 errors?
If it makes any difference; it is a Web API .NET Core 2.1 returning the 403 error and an MVC Core MVC 2.1 app handling the error. | 0debug |
How to convert 1000000 to 1M and 1000 to 1K on javascript : <p>I want to convert 1000000 to 1M also for 1000 To 1K</p>
<p>Any ideas?</p>
<p>I need it for my special project</p>
| 0debug |
How to use import with absolute paths with Expo and React Native? : <p>I'm trying to use absolute import paths instead of relative paths with <a href="https://github.com/expo/expo-sdk" rel="noreferrer">Expo</a> and React Native.</p>
<p>I looked on the expo docs and couldn't find an answer... Searching for the subject in react community I found <a href="https://github.com/tleunen/babel-plugin-module-resolver.git" rel="noreferrer">babel-plugin-module-resolver</a> but it seems that Expo is already using it so I've changed my .babelrc to create some aliases:</p>
<pre><code>{
"presets": ["babel-preset-expo"],
"env": {
"development": {
"plugins": [
"transform-react-jsx-source",
["module-resolver", {
"root": ["./app"],
"alias": {
"Components": "./app/components",
}
}]
]
}
}
}
</code></pre>
<p>But I got the following error:</p>
<pre><code>Unable to resolve module '@expo/vector-icons/glyphmaps/Entypo.json'
from '/Users/eduardoleal/Code/lua/rook/node_modules/@expo/vector-icons/Entypo.js':
Module does not exist in the module map or in these directories: /Users/eduardoleal/Code/lua/rook/node_modules/@expo/vector-icons/node_modules/@expo/vector-icons/glyphmaps , /Users/eduardoleal/Code/lua/rook/node_modules/@expo/vector-icons/glyphmaps This might be related to https://github.com/facebook/react-native/issues/4968 To resolve try the following:
1. Clear watchman watches: 'watchman watch-del-all'.
2. Delete the 'node_modules' folder: 'rm -rf node_modules && npm install'.
3. Reset packager cache: 'rm -fr $TMPDIR/react-*' or 'npm start --reset-cache'.
ABI16_0_0RCTFatal -[ABI16_0_0RCTBatchedBridge stopLoadingWithError:] __34-[ABI16_0_0RCTBatchedBridge start]_block_invoke_2 _dispatch_call_block_and_release _dispatch_client_callout _dispatch_main_queue_callback_4CF __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ __CFRunLoopRun CFRunLoopRunSpecific GSEventRunModal UIApplicationMain main start 0x0
</code></pre>
<p>Is there any easy way to import absolute paths?</p>
| 0debug |
Replace space with %20 in r : <p>I have following string: </p>
<pre><code>url <- https://www.google.mu/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=green carot
</code></pre>
<p>I want to replace the space between green and carot with %20</p>
<pre><code>>url
https://www.google.mu/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=green%20carot
</code></pre>
| 0debug |
react evironment variables .env return undefined : <p>I am building a react app and i need to fetch data from my api, now i want to store the api url as an environment variable. I have my .env file, i have dotenv installed, here is my code process.env.API_URL is returning undefined.</p>
<pre><code>import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import Home from '../src/components/Home'
import dotenv from 'dotenv'
import path from 'path'
class App extends Component {
render() {
console.log(process.env.API_URL)
return (
<div>
<Home/>
</div>
);
}
}
export default App;
</code></pre>
| 0debug |
did you specify the right host or port? error on Kubernetes : <p>I have followed the helloword tutorial on <a href="http://kubernetes.io/docs/hellonode/" rel="noreferrer">http://kubernetes.io/docs/hellonode/</a>. </p>
<p>When I run:</p>
<pre><code>kubectl run hello-node --image=gcr.io/PROJECT_ID/hello-node:v1 --port=8080
</code></pre>
<p>I get:
The connection to the server localhost:8080 was refused - did you specify the right host or port?</p>
<p>Why do the command line tries to connect to localhost? </p>
| 0debug |
static void scsi_read_data(SCSIDevice *d, uint32_t tag)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, d);
SCSIDiskReq *r;
r = scsi_find_request(s, tag);
if (!r) {
BADF("Bad read tag 0x%x\n", tag);
scsi_command_complete(r, CHECK_CONDITION, HARDWARE_ERROR);
return;
}
scsi_read_request(r);
}
| 1threat |
PHP session notice:undefined index : I am trying to pass a value using session from one page to another but it says
> Notice: Undefined index: user_id in path\file.php on line 61
The file where i am creating session is as follows
if(!isset($_SESSION))
{
session_start();
}
then
$_session['user_id']=$row['user_id'];
The file i am receiving session is as follows
if(!isset($_SESSION))
{
session_start();
}
then
$user_id=$_session['user_id'];
Where i am making mistake. Kindly guide me please | 0debug |
Using a C# 7 tuple in an ASP.NET Core Web API Controller : <p>Do you know why this works:</p>
<pre><code> public struct UserNameAndPassword
{
public string username;
public string password;
}
[HttpPost]
public IActionResult Create([FromBody]UserNameAndPassword usernameAndPassword)
{
Console.WriteLine(usernameAndPassword);
if (this.AuthenticationService.IsValidUserAndPasswordCombination(usernameAndPassword.username, usernameAndPassword.password))
return new ObjectResult(GenerateToken(usernameAndPassword.username));
return BadRequest();
}
</code></pre>
<p>But when I replace it with a tuple, this doesn’t work?</p>
<pre><code> [HttpPost]
public IActionResult Create([FromBody](string username, string password) usernameAndPassword) //encrypt password?
{
Console.WriteLine(usernameAndPassword);
if (this.AuthenticationService.IsValidUserAndPasswordCombination(usernameAndPassword.username, usernameAndPassword.password))
return new ObjectResult(GenerateToken(usernameAndPassword.username));
return BadRequest();
}
</code></pre>
<p>usernameAndPassword.username and .password are both null.</p>
<p>Are you not allowed to use tuples in a controller?</p>
| 0debug |
static int _do_bit_allocation(AC3DecodeContext *ctx, int chnl)
{
ac3_audio_block *ab = &ctx->audio_block;
int16_t sdecay, fdecay, sgain, dbknee, floor;
int16_t lowcomp, fgain, snroffset, fastleak, slowleak;
int16_t psd[256], bndpsd[50], excite[50], mask[50], delta;
uint8_t start, end, bin, i, j, k, lastbin, bndstrt, bndend, begin, deltnseg, band, seg, address;
uint8_t fscod = ctx->sync_info.fscod;
uint8_t *exps, *deltoffst, *deltlen, *deltba;
uint8_t *baps;
int do_delta = 0;
sdecay = sdecaytab[ab->sdcycod];
fdecay = fdecaytab[ab->fdcycod];
sgain = sgaintab[ab->sgaincod];
dbknee = dbkneetab[ab->dbpbcod];
floor = floortab[ab->floorcod];
if (chnl == 5) {
start = ab->cplstrtmant;
end = ab->cplendmant;
fgain = fgaintab[ab->cplfgaincod];
snroffset = (((ab->csnroffst - 15) << 4) + ab->cplfsnroffst) << 2;
fastleak = (ab->cplfleak << 8) + 768;
slowleak = (ab->cplsleak << 8) + 768;
exps = ab->dcplexps;
baps = ab->cplbap;
if (ab->cpldeltbae == 0 || ab->cpldeltbae == 1) {
do_delta = 1;
deltnseg = ab->cpldeltnseg;
deltoffst = ab->cpldeltoffst;
deltlen = ab->cpldeltlen;
deltba = ab->cpldeltba;
}
}
else if (chnl == 6) {
start = 0;
end = 7;
lowcomp = 0;
fgain = fgaintab[ab->lfefgaincod];
snroffset = (((ab->csnroffst - 15) << 4) + ab->lfefsnroffst) << 2;
exps = ab->dlfeexps;
baps = ab->lfebap;
}
else {
start = 0;
end = ab->endmant[chnl];
lowcomp = 0;
fgain = fgaintab[ab->fgaincod[chnl]];
snroffset = (((ab->csnroffst - 15) << 4) + ab->fsnroffst[chnl]) << 2;
exps = ab->dexps[chnl];
baps = ab->bap[chnl];
if (ab->deltbae[chnl] == 0 || ab->deltbae[chnl] == 1) {
do_delta = 1;
deltnseg = ab->deltnseg[chnl];
deltoffst = ab->deltoffst[chnl];
deltlen = ab->deltlen[chnl];
deltba = ab->deltba[chnl];
}
}
for (bin = start; bin < end; bin++)
psd[bin] = (3072 - ((int16_t) (exps[bin] << 7)));
j = start;
k = masktab[start];
do {
lastbin = FFMIN(bndtab[k] + bndsz[k], end);
bndpsd[k] = psd[j];
j++;
for (i = j; i < lastbin; i++) {
bndpsd[k] = logadd(bndpsd[k], psd[j]);
j++;
}
k++;
} while (end > lastbin);
bndstrt = masktab[start];
bndend = masktab[end - 1] + 1;
if (bndstrt == 0) {
lowcomp = calc_lowcomp(lowcomp, bndpsd[0], bndpsd[1], 0);
excite[0] = bndpsd[0] - fgain - lowcomp;
lowcomp = calc_lowcomp(lowcomp, bndpsd[1], bndpsd[2], 1);
excite[1] = bndpsd[1] - fgain - lowcomp;
begin = 7;
for (bin = 2; bin < 7; bin++) {
if (bndend != 7 || bin != 6)
lowcomp = calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin + 1], bin);
fastleak = bndpsd[bin] - fgain;
slowleak = bndpsd[bin] - sgain;
excite[bin] = fastleak - lowcomp;
if (bndend != 7 || bin != 6)
if (bndpsd[bin] <= bndpsd[bin + 1]) {
begin = bin + 1;
break;
}
}
for (bin = begin; bin < (FFMIN(bndend, 22)); bin++) {
if (bndend != 7 || bin != 6)
lowcomp = calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin + 1], bin);
fastleak -= fdecay;
fastleak = FFMAX(fastleak, bndpsd[bin] - fgain);
slowleak -= sdecay;
slowleak = FFMAX(slowleak, bndpsd[bin] - sgain);
excite[bin] = FFMAX(fastleak - lowcomp, slowleak);
}
begin = 22;
}
else {
begin = bndstrt;
}
for (bin = begin; bin < bndend; bin++) {
fastleak -= fdecay;
fastleak = FFMAX(fastleak, bndpsd[bin] - fgain);
slowleak -= sdecay;
slowleak = FFMAX(slowleak, bndpsd[bin] - sgain);
excite[bin] = FFMAX(fastleak, slowleak);
}
for (bin = bndstrt; bin < bndend; bin++) {
if (bndpsd[bin] < dbknee)
excite[bin] += ((dbknee - bndpsd[bin]) >> 2);
mask[bin] = FFMAX(excite[bin], hth[bin][fscod]);
}
if (do_delta) {
band = 0;
for (seg = 0; seg < deltnseg + 1; seg++) {
band += deltoffst[seg];
if (deltba[seg] >= 4)
delta = (deltba[seg] - 3) << 7;
else
delta = (deltba[seg] - 4) << 7;
for (k = 0; k < deltlen[seg]; k++) {
mask[band] += delta;
band++;
}
}
}
i = start;
j = masktab[start];
do {
lastbin = FFMIN(bndtab[j] + bndsz[j], end);
mask[j] -= snroffset;
mask[j] -= floor;
if (mask[j] < 0)
mask[j] = 0;
mask[j] &= 0x1fe0;
mask[j] += floor;
for (k = i; k < lastbin; k++) {
address = (psd[i] - mask[j]) >> 5;
address = FFMIN(63, (FFMAX(0, address)));
baps[i] = baptab[address];
i++;
}
j++;
} while (end > lastbin);
return 0;
}
| 1threat |
Limit Kafka batches size when using Spark Streaming : <p>Is it possible to limit the size of the batches returned by the Kafka consumer for Spark Streaming?</p>
<p>I am asking because the first batch I get has hundred of millions of records and it takes ages to process and checkpoint them.</p>
| 0debug |
get the % of my dataframe with NA : <p>here is my dataframe</p>
<p>I would like to fid the % of each row</p>
<pre><code> a b c
1 NA 10 10
2 NA 11 13
3 NA 20 12
4 NA 20 20
5 NA 3 15
6 10 2 8
</code></pre>
<p>first I sum the first row 10+10=20 so the % of the first row is 50% for b and 50% for c
It should looks like this</p>
<pre><code> a b c
1 NA 0.5 0.5
2 NA 0.458 0.542
3 NA 0.625 0.372
4 NA 0.5 0.5
5 NA 0.166 0.834
6 0.5 0.1 0.4
</code></pre>
<p>Thanks</p>
| 0debug |
jQuery removeClass() not working but hasClass() works : I am using some CSS classes and jQuery to make a custom selectbox. But I keep having problems with the removeClass() function.
I know there are alternatives to this problem. But could somebody explain me WHY it is not working?
$(".filterselect").on("click",function(){
$(this).find("ul").addClass("open");
});
$(".filterselect ul li").on("click",function(){
$(this).parent().find("li").removeClass("active"); // THIS WORKS
$(this).addClass("active"); // THIS WORKS
if ($(this).parent().hasClass("open"))
{
console.log("test"); // THIS WORKS
}
$(this).parent().removeClass("open"); // THIS DOESN'T WORK :(
});
Thanks for the help! | 0debug |
PHP Debug in Visual Studio Code breaks on every exception : <p>I am just starting to use the PHP Debug extension in Visual Studio Code (Ubuntu 14.04). It mostly works fine for me, but I have a problem that every time an exception is thrown, the debugger automatically breaks. We have lots of exceptions which are internally caught and handled in our code, so I don't want to have to step through each of these.</p>
<p>I've been trying to find something like the <a href="https://msdn.microsoft.com/en-us/library/x85tt0dd.aspx" rel="noreferrer" title="Exception Settings">Exception Settings</a> in Visual Studio 2015, but can't find any equivalent options within Visual Studio <em>Code</em>.</p>
<p>php.ini settings:</p>
<pre><code>[debug]
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
</code></pre>
<p>Visual Studio Code launch.json:</p>
<pre><code>{
"version": "0.2.0",
"configurations": [
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000,
"args": ["some arguments"]
}
]
}
</code></pre>
<p>Note that when I use Netbeans for debugging with the same xdebug settings and the same codebase, there is no break-on-exception behaviour, so I think this must be something in Visual Studio Code and/or the PHP Debug extension.</p>
<p>Can anyone suggest how to pass through exceptions without breaking?</p>
| 0debug |
static void gen_tlbli_74xx(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
gen_helper_74xx_tlbi(cpu_env, cpu_gpr[rB(ctx->opcode)]);
#endif
}
| 1threat |
static av_cold int twolame_encode_init(AVCodecContext *avctx)
{
TWOLAMEContext *s = avctx->priv_data;
int ret;
avctx->frame_size = TWOLAME_SAMPLES_PER_FRAME;
avctx->delay = 512 - 32 + 1;
s->glopts = twolame_init();
if (!s->glopts)
return AVERROR(ENOMEM);
twolame_set_verbosity(s->glopts, s->verbosity);
twolame_set_mode(s->glopts, s->mode);
twolame_set_psymodel(s->glopts, s->psymodel);
twolame_set_energy_levels(s->glopts, s->energy);
twolame_set_error_protection(s->glopts, s->error_protection);
twolame_set_copyright(s->glopts, s->copyright);
twolame_set_original(s->glopts, s->original);
twolame_set_num_channels(s->glopts, avctx->channels);
twolame_set_in_samplerate(s->glopts, avctx->sample_rate);
twolame_set_out_samplerate(s->glopts, avctx->sample_rate);
if (avctx->flags & CODEC_FLAG_QSCALE || !avctx->bit_rate) {
twolame_set_VBR(s->glopts, TRUE);
twolame_set_VBR_level(s->glopts,
avctx->global_quality / (float) FF_QP2LAMBDA);
av_log(avctx, AV_LOG_WARNING,
"VBR in MP2 is a hack, use another codec that supports it.\n");
} else {
twolame_set_bitrate(s->glopts, avctx->bit_rate / 1000);
}
ret = twolame_init_params(s->glopts);
if (ret) {
twolame_encode_close(avctx);
return AVERROR_UNKNOWN;
}
return 0;
}
| 1threat |
Set default image if img src= null : <pre><code> <img src="<%# ReturnEncodedBase64UTF8(Eval("Data")) %>" style="width:100%; height:30%;"/>
</code></pre>
<p>Hi, I'm new to C# and ASP.NET, I would like to know how do I set the img src to a default img for example ~\images\myimage.png if the img src above return null?</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.