problem stringlengths 26 131k | labels class label 2
classes |
|---|---|
static int buffered_get_fd(void *opaque)
{
QEMUFileBuffered *s = opaque;
return qemu_get_fd(s->file);
}
| 1threat |
int net_init_bridge(const NetClientOptions *opts, const char *name,
NetClientState *peer, Error **errp)
{
const NetdevBridgeOptions *bridge;
const char *helper, *br;
TAPState *s;
int fd, vnet_hdr;
assert(opts->type == NET_CLIENT_OPTIONS_KIND_BRIDGE);
bridge = opts->u.bridge;
helper = bridge->has_helper ? bridge->helper : DEFAULT_BRIDGE_HELPER;
br = bridge->has_br ? bridge->br : DEFAULT_BRIDGE_INTERFACE;
fd = net_bridge_run_helper(helper, br, errp);
if (fd == -1) {
return -1;
}
fcntl(fd, F_SETFL, O_NONBLOCK);
vnet_hdr = tap_probe_vnet_hdr(fd);
s = net_tap_fd_init(peer, "bridge", name, fd, vnet_hdr);
snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=%s,br=%s", helper,
br);
return 0;
}
| 1threat |
Can't remove .I. AND ..I. files : <p>could you suggest any idea how to remove two files from filesystem:<br>
<strong>..I.</strong><br>
and<br>
<strong>.I.</strong><br>
?? <br>
While experimenting I created them with command<br>
<strong>$ git touch .I.</strong><br>
I tried to use these commands:<br>
<strong>$ git rm .I.</strong><br>
<strong>$ git rm ./.I.</strong><br>
<strong>$ git rm ..I.</strong><br>
<strong>$ git rm ./..I.</strong><br>
but it didn't help.
Thank you in advance!</p>
| 0debug |
static int decode_ref_pic_marking(H264Context *h){
MpegEncContext * const s = &h->s;
int i;
if(h->nal_unit_type == NAL_IDR_SLICE){
s->broken_link= get_bits1(&s->gb) -1;
h->mmco[0].long_index= get_bits1(&s->gb) - 1;
if(h->mmco[0].long_index == -1)
h->mmco_index= 0;
else{
h->mmco[0].opcode= MMCO_LONG;
h->mmco_index= 1;
}
}else{
if(get_bits1(&s->gb)){
for(i= 0; i<MAX_MMCO_COUNT; i++) {
MMCOOpcode opcode= get_ue_golomb(&s->gb);;
h->mmco[i].opcode= opcode;
if(opcode==MMCO_SHORT2UNUSED || opcode==MMCO_SHORT2LONG){
h->mmco[i].short_frame_num= (h->frame_num - get_ue_golomb(&s->gb) - 1) & ((1<<h->sps.log2_max_frame_num)-1);
}
if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){
h->mmco[i].long_index= get_ue_golomb(&s->gb);
if( h->mmco[i].long_index >= 16){
av_log(h->s.avctx, AV_LOG_ERROR, "illegal long ref in memory management control operation %d\n", opcode);
return -1;
}
}
if(opcode > MMCO_LONG){
av_log(h->s.avctx, AV_LOG_ERROR, "illegal memory management control operation %d\n", opcode);
return -1;
}
if(opcode == MMCO_END)
break;
}
h->mmco_index= i;
}else{
assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count);
if(h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count){
h->mmco[0].opcode= MMCO_SHORT2UNUSED;
h->mmco[0].short_frame_num= h->short_ref[ h->short_ref_count - 1 ]->frame_num;
h->mmco_index= 1;
}else
h->mmco_index= 0;
}
}
return 0;
}
| 1threat |
How do I Intentionally cause a database validation error on insert : <p>I am trying to cause a database validation error when inserting into (or editing) the database to test the try/catch</p>
<p>C# is too smart and catches my type casting errors.</p>
| 0debug |
static void net_socket_send(void *opaque)
{
NetSocketState *s = opaque;
int size, err;
unsigned l;
uint8_t buf1[NET_BUFSIZE];
const uint8_t *buf;
size = qemu_recv(s->fd, buf1, sizeof(buf1), 0);
if (size < 0) {
err = socket_error();
if (err != EWOULDBLOCK)
goto eoc;
} else if (size == 0) {
eoc:
net_socket_read_poll(s, false);
net_socket_write_poll(s, false);
if (s->listen_fd != -1) {
qemu_set_fd_handler(s->listen_fd, net_socket_accept, NULL, s);
}
closesocket(s->fd);
s->fd = -1;
s->state = 0;
s->index = 0;
s->packet_len = 0;
s->nc.link_down = true;
memset(s->buf, 0, sizeof(s->buf));
memset(s->nc.info_str, 0, sizeof(s->nc.info_str));
return;
}
buf = buf1;
while (size > 0) {
switch(s->state) {
case 0:
l = 4 - s->index;
if (l > size)
l = size;
memcpy(s->buf + s->index, buf, l);
buf += l;
size -= l;
s->index += l;
if (s->index == 4) {
s->packet_len = ntohl(*(uint32_t *)s->buf);
s->index = 0;
s->state = 1;
}
break;
case 1:
l = s->packet_len - s->index;
if (l > size)
l = size;
if (s->index + l <= sizeof(s->buf)) {
memcpy(s->buf + s->index, buf, l);
} else {
fprintf(stderr, "serious error: oversized packet received,"
"connection terminated.\n");
s->state = 0;
goto eoc;
}
s->index += l;
buf += l;
size -= l;
if (s->index >= s->packet_len) {
qemu_send_packet(&s->nc, s->buf, s->packet_len);
s->index = 0;
s->state = 0;
}
break;
}
}
}
| 1threat |
Apple File System (APFS) Check if file is a clone on Terminal (shell) : <p>With macOS High Sierra a new file system is available: APFS.</p>
<p>This file system supports clone operations for files: No data duplication on storage.</p>
<p><code>cp</code> command has a flag (-c) that enables cloning in Terminal (shell).</p>
<p>But I didn't find a way to identify theses cloned files after.</p>
<p>Somebody knows how to identify cloned files with a shell command, or a flag in a existent command, like <code>ls</code>?</p>
| 0debug |
Converting each individual letter of a string to ASCII equivalent - Python : <p>How would one write a code to display the conversion of individual letters in a string to it's ASCII equivalent? One example of the output in shell would look like this:</p>
<pre><code>Enter a 3-letter word: Hey
H = 72
e = 101
y = 121
</code></pre>
| 0debug |
Extracting data from a web page to excel sheet : Is there anyone who knows how I can extract information from a web page into an excel sheet. The website is https://www.proudlysa.co.za/members.php and I would like to extract all the companies listed there and all their respective information and put it into an excel file. I have been copying each and every company but it seems cumbersome and I thought there may be a very simple way to do so. | 0debug |
What is the difference between retq and ret? : <p>Let's consider the following program, which computes an unsigned square of the argument:</p>
<pre><code>.global foo
.text
foo:
mov %rdi, %rax
mul %rdi
ret
</code></pre>
<p>This is properly compiled by <code>as</code>, but disassembles to </p>
<pre><code>0000000000000000 <foo>:
0: 48 89 f8 mov %rdi,%rax
3: 48 f7 e7 mul %rdi
6: c3 retq
</code></pre>
<p>Is there any difference between <code>ret</code> and <code>retq</code>?</p>
| 0debug |
what are python closures good for? : <p>I understand the technical definition of python closures: let's make it concrete.</p>
<pre><code>def foo(x):
def bar(y):
print(x+y)
return bar
</code></pre>
<p>In this example <code>x</code> will get bound with <code>bar</code>. But what are these things actually good for? ie in the toy example above one could have just as easily written</p>
<pre><code>def bar(x,y):
print(x+y)
</code></pre>
<p>I would like to know the best use cases for using closures instead of, for example, adding extra arguments to a function.</p>
| 0debug |
Java - make class required for other class : <p>i have 2 class, planet and moon, my plan is to make moon class require planet class, so first i create planet and then create moon, how to do it?
my planet class :</p>
<pre><code>public class planet {
//planet name
private String namaPlanet;
//total moon per planet
private int jmlBulan;
//revolution and rotation
private double jmlRotasi, jmlRevolusi;
public planet(String namaPlanet, int jmlBulan, double jmlJamPhari, double jmlHariPtahun) {
this.namaPlanet = namaPlanet;
this.jmlBulan = jmlBulan;
this.jmlRotasi = jmlJamPhari;
this.jmlRevolusi = jmlHariPtahun;
}
public planet(String namaPlanet, double jmlRotasi, double jmlRevolusi) {
this.namaPlanet = namaPlanet;
this.jmlRotasi = jmlRotasi;
this.jmlRevolusi = jmlRevolusi;
}
}
</code></pre>
<p>moon class :</p>
<pre><code>public class bulan extends planet {
private String namaBulan;
public bulan(String namaBulan, String namaPlanet,double jmlJamPhari, double jmlHariPtahun) {
super(namaPlanet, jmlJamPhari, jmlHariPtahun);
this.namaBulan = namaBulan;
}
}
</code></pre>
| 0debug |
nil slices vs non-nil slices vs empty slices in Go language : <p>I am a newbee to Go programming. I have read in go programming book that slice consists of three things: a pointer to an array, length and capacity.</p>
<p>I am getting confused between nil slices(slice has no underlying array to point to, len = 0,cap=0), non-nil slices where only len = 0,cap = 0 and empty slices.</p>
<p>Can anyone please tell whether nil and empty slices are same things?
If they both are different, then please tell what is the difference between those two?</p>
<p>How to test whether a slice is empty or not?</p>
<p>Also, what value does the pointer holds in non-nil slices, whose length and capacity are zero?</p>
| 0debug |
how to use array_push() : <p>I want to push new data in array which each value of them.</p>
<pre><code>$array = array("menu1" => "101", "menu2" => "201");
array_push($array, "menu3" => "301");
</code></pre>
<p>But I got an error syntax.</p>
<p>And if I use like this :</p>
<pre><code>$array = array("menu1" => "101", "menu2" => "201");
array_push($array, "menu3", "301");
result is : Array ( [menu1]=>101 [menu2]=>201 [0]=>menu3 [1]=>301 )
My hope the result is : Array ( [menu1]=>101 [menu2]=>201 [menu3]=>301 )
</code></pre>
<p>I want push new [menu3]=>'301' but I dont know how. Please help me, the answer will be appreciate</p>
| 0debug |
gitlab-ci SSH key invalid format : <p>I would like run deploy script with gitlab-ci, but step ssh-add <code>$SSH_PRIVATE_KEY</code> return an error :</p>
<pre><code>echo "$SSH_PRIVATE_KEY" | ssh-add -
Error loading key "(stdin)": invalid format
</code></pre>
<p>You can see my <code>.gitlab-ci.yml</code> :</p>
<pre><code>deploy:
image: node:9.11.1-alpine
stage: deploy
before_script:
# Install ssh-agent if not already installed, it is required by Docker.
# (change apt-get to yum if you use a CentOS-based image)
- 'which ssh-agent || ( apk add --update openssh )'
# Add bash
- apk add --update bash
# Add git
- apk add --update git
# Run ssh-agent (inside the build environment)
- eval $(ssh-agent -s)
# Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
- echo "$SSH_PRIVATE_KEY"
- echo "$SSH_PRIVATE_KEY" | ssh-add -
# For Docker builds disable host key checking. Be aware that by adding that
# you are suspectible to man-in-the-middle attacks.
# WARNING: Use this only with the Docker executor, if you use it with shell
# you will overwrite your user's SSH config.
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
# In order to properly check the server's host key, assuming you created the
# SSH_SERVER_HOSTKEYS variable previously, uncomment the following two lines
# instead.
# - mkdir -p ~/.ssh
# - '[[ -f /.dockerenv ]] && echo "$SSH_SERVER_HOSTKEYS" > ~/.ssh/known_hosts'
script:
- npm i -g pm2
- pm2 deploy ecosystem.config.js production
# only:
# - master
</code></pre>
<p>On my project setting, i've been add SSH_PRIVATE_KEY variable, with the id_rsa from my production server <code>cat ~/.ssh/id_rsa.pub</code>.</p>
<p>Anyone can help me ?</p>
| 0debug |
What is the downside of using one-line if statements? : <p>I see most code-bases using bracketed if-statements in all cases including cases in which only one statement needs to be executed after the if.</p>
<p>Are there any clear benefits to always using bracketed if-statements or has it just become a standard over time?</p>
<p>What is the general consensus on this, would it be a big mistake to allow one-line ifs through our linter?</p>
| 0debug |
2 simple "unresolved identitier" errors that I can't fix in Swift : <p>I am a Swift beginner currently following an Apple Intro to Developing iOS Apps in Swift tutorial. I have the follow error codes " Use of unresolved identifier 'UIImagePickerController' " and "Use of unresolved identifier 'imagePickController' " on lines 3 and 4 respectively. Thanks in advance! </p>
<pre><code>@IBAction func selectionImageFromPhotoLibrary(sender: UITapGestureRecognizer) {
nameTextField.resignFirstResponder()
let imagePickerController = UIIMagePickerController()
imagePickController.sourceType = .PhotoLibrary
imagePickerController.delegate=self
presentViewController(imagePickerController, animated: true, completion: nil)
}
</code></pre>
| 0debug |
How to put a simple passsword on SQLIte database like other database? : I am asking about just put password not encryption using [SQLClipher][1] or SEE or AES but when I want to access file I need come password like 'VISHAL' or Nothing else
[1]: https://www.zetetic.net/sqlcipher/ | 0debug |
Change image color dynamically : <p>I have a .png or .jpeg image. I want to change the color of the image ( previously may be it was white I want to change it to red ) according to the theme selected. How can I do this. </p>
| 0debug |
I want to get all the group(key) in my spinner then after that school no(key) into another spinner from firebase database : I'm a beginner & currently in a learning phase, please help me with this problem
This post might look like a duplicate to you but it's none of the previous questions had this much keys.
I want to get all the `group no 1` in my spinner then after that all the `school no` of group no 1 into another spinner from firebase database
Here's my database
[![enter image description here][1]][1]
here's my code
>java
public class Collection extends AppCompatActivity {
TextView ttl, tgat, tsch;
Button btnshw, btngt;
Spinner sping;
DatabaseReference d2ref;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_collection);
tgat = (TextView) findViewById(R.id.texigat);
tsch = (TextView) findViewById(R.id.texisch);
//tcls = (TextView) findViewById(R.id.texiclass);
ttl = (TextView) findViewById(R.id.texirs);
btnshw = (Button) findViewById(R.id.bshow);
btngt = (Button) findViewById(R.id.bgat);
sping = (Spinner) findViewById(R.id.spingat);
btnshw.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
d2ref = FirebaseDatabase.getInstance().getReference().child("2018-19").child("Gat No 14")
.child("School no 109").child("Standard 2nd");
d2ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String rs = dataSnapshot.child("Rupees").getValue().toString();
ttl.setText(rs);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
});
btngt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
d2ref = FirebaseDatabase.getInstance().getReference().child("2018-19");
ValueEventListener eventListener = new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
final List<String> gatno = new ArrayList<String>();
for (DataSnapshot dsnap : dataSnapshot.child("Gat No 14").getChildren()) {
String gat = dsnap.getKey();
gatno.add(gat);
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(Collection.this, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sping.setAdapter(adapter);
/*I wasn't able to get the value in 1st spinner so I didn't
wrote program for second spinner*/
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
};
d2ref.addListenerForSingleValueEvent(eventListener);
}
});
}
}
Please help me with this.
[1]: https://i.stack.imgur.com/kFb7u.png | 0debug |
static int bitpacked_decode_yuv422p10(AVCodecContext *avctx, AVFrame *frame,
AVPacket *avpkt)
{
uint64_t frame_size = (uint64_t)avctx->width * (uint64_t)avctx->height * 20;
uint64_t packet_size = avpkt->size * 8;
GetBitContext bc;
uint16_t *y, *u, *v;
int ret, i;
ret = ff_get_buffer(avctx, frame, 0);
if (ret < 0)
return ret;
y = (uint16_t*)frame->data[0];
u = (uint16_t*)frame->data[1];
v = (uint16_t*)frame->data[2];
if (frame_size > packet_size)
return AVERROR_INVALIDDATA;
if (avctx->width % 2)
return AVERROR_PATCHWELCOME;
ret = init_get_bits(&bc, avpkt->data, avctx->width * avctx->height * 20);
if (ret)
return ret;
for (i = 0; i < avctx->height; i++) {
y = (uint16_t*)(frame->data[0] + i * frame->linesize[0]);
u = (uint16_t*)(frame->data[1] + i * frame->linesize[1]);
v = (uint16_t*)(frame->data[2] + i * frame->linesize[2]);
for (int j = 0; j < avctx->width; j += 2) {
*u++ = get_bits(&bc, 10);
*y++ = get_bits(&bc, 10);
*v++ = get_bits(&bc, 10);
*y++ = get_bits(&bc, 10);
}
}
return 0;
}
| 1threat |
How to get Coursera API Docs ? : <p>Hi I want to use Coursera API for a tech blog purpose, like retrieving list of courses (course details, course duration , etc...) I try in coursera website to enroll for their developer program :
<a href="https://building.coursera.org/developer-program/" rel="noreferrer">https://building.coursera.org/developer-program/</a></p>
<p>but so far I didn't get any response from them (apply sent 2 weeks ago).
I found some http request like categories :
<a href="https://api.coursera.org/api/catalog.v1/categories" rel="noreferrer">https://api.coursera.org/api/catalog.v1/categories</a></p>
<p>or courses :
<a href="https://api.coursera.org/api/catalog.v1/courses" rel="noreferrer">https://api.coursera.org/api/catalog.v1/courses</a></p>
<p>Where Can I find some docs with all the API Functions?
Thanks for your help!</p>
| 0debug |
How to disable input text while the radio button is checked in javascript? : <label for="position"><b>Position:</b></label><br/><br/>
<input type="radio" name="position" id="r1" value="Dean" />Dean
<input type="radio" name="position" id="r2" value="Instructor"/>Instructor
<input type="radio" name="position" id="r3" value="Student"/>Student<br/><br/>
<input type="radio" name="position" id ="r4" value="<?php echo $_POST['otherPosition']?>"/>
Others:
<input type="text" value = "<?php if($error==TRUE){echo $_POST['otherPosition'];}?>" id="otherPosition" placeholder="Specify" name="position"/> | 0debug |
static av_cold int atrac3_decode_init(AVCodecContext *avctx)
{
int i, ret;
int version, delay, samples_per_frame, frame_factor;
const uint8_t *edata_ptr = avctx->extradata;
ATRAC3Context *q = avctx->priv_data;
if (avctx->channels <= 0 || avctx->channels > 2) {
av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n");
return AVERROR(EINVAL);
}
if (avctx->extradata_size == 14) {
av_log(avctx, AV_LOG_DEBUG, "[0-1] %d\n",
bytestream_get_le16(&edata_ptr));
edata_ptr += 4;
q->coding_mode = bytestream_get_le16(&edata_ptr);
av_log(avctx, AV_LOG_DEBUG,"[8-9] %d\n",
bytestream_get_le16(&edata_ptr));
frame_factor = bytestream_get_le16(&edata_ptr);
av_log(avctx, AV_LOG_DEBUG,"[12-13] %d\n",
bytestream_get_le16(&edata_ptr));
samples_per_frame = SAMPLES_PER_FRAME * avctx->channels;
version = 4;
delay = 0x88E;
q->coding_mode = q->coding_mode ? JOINT_STEREO : STEREO;
q->scrambled_stream = 0;
if (avctx->block_align != 96 * avctx->channels * frame_factor &&
avctx->block_align != 152 * avctx->channels * frame_factor &&
avctx->block_align != 192 * avctx->channels * frame_factor) {
av_log(avctx, AV_LOG_ERROR, "Unknown frame/channel/frame_factor "
"configuration %d/%d/%d\n", avctx->block_align,
avctx->channels, frame_factor);
return AVERROR_INVALIDDATA;
}
} else if (avctx->extradata_size == 10) {
version = bytestream_get_be32(&edata_ptr);
samples_per_frame = bytestream_get_be16(&edata_ptr);
delay = bytestream_get_be16(&edata_ptr);
q->coding_mode = bytestream_get_be16(&edata_ptr);
q->scrambled_stream = 1;
} else {
av_log(NULL, AV_LOG_ERROR, "Unknown extradata size %d.\n",
avctx->extradata_size);
return AVERROR(EINVAL);
}
if (version != 4) {
av_log(avctx, AV_LOG_ERROR, "Version %d != 4.\n", version);
return AVERROR_INVALIDDATA;
}
if (samples_per_frame != SAMPLES_PER_FRAME &&
samples_per_frame != SAMPLES_PER_FRAME * 2) {
av_log(avctx, AV_LOG_ERROR, "Unknown amount of samples per frame %d.\n",
samples_per_frame);
return AVERROR_INVALIDDATA;
}
if (delay != 0x88E) {
av_log(avctx, AV_LOG_ERROR, "Unknown amount of delay %x != 0x88E.\n",
delay);
return AVERROR_INVALIDDATA;
}
if (q->coding_mode == STEREO)
av_log(avctx, AV_LOG_DEBUG, "Normal stereo detected.\n");
else if (q->coding_mode == JOINT_STEREO) {
if (avctx->channels != 2)
return AVERROR_INVALIDDATA;
av_log(avctx, AV_LOG_DEBUG, "Joint stereo detected.\n");
} else {
av_log(avctx, AV_LOG_ERROR, "Unknown channel coding mode %x!\n",
q->coding_mode);
return AVERROR_INVALIDDATA;
}
if (avctx->block_align >= UINT_MAX / 2)
return AVERROR(EINVAL);
q->decoded_bytes_buffer = av_mallocz(FFALIGN(avctx->block_align, 4) +
FF_INPUT_BUFFER_PADDING_SIZE);
if (q->decoded_bytes_buffer == NULL)
return AVERROR(ENOMEM);
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
if ((ret = ff_mdct_init(&q->mdct_ctx, 9, 1, 1.0 / 32768)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n");
av_freep(&q->decoded_bytes_buffer);
return ret;
}
q->weighting_delay[0] = 0;
q->weighting_delay[1] = 7;
q->weighting_delay[2] = 0;
q->weighting_delay[3] = 7;
q->weighting_delay[4] = 0;
q->weighting_delay[5] = 7;
for (i = 0; i < 4; i++) {
q->matrix_coeff_index_prev[i] = 3;
q->matrix_coeff_index_now[i] = 3;
q->matrix_coeff_index_next[i] = 3;
}
ff_atrac_init_gain_compensation(&q->gainc_ctx, 4, 3);
avpriv_float_dsp_init(&q->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
ff_fmt_convert_init(&q->fmt_conv, avctx);
q->units = av_mallocz(sizeof(*q->units) * avctx->channels);
if (!q->units) {
atrac3_decode_close(avctx);
return AVERROR(ENOMEM);
}
return 0;
}
| 1threat |
jquery not sending date in query string : i have this html code.
<form class="" role="form">
<div class="col-lg-2">
<div class="form-group">
<label for="streams">Select Stream</label>
<select name="streams" id="streams" class="form-control">
<option value="">-- Select --</option>
<?php
while($streamRow = mysql_fetch_array($streamResult)) {
echo
"<option value=".$streamRow[0].">".$streamRow[1]."</option>";
}
?>
</select>
</div>
</div>
<div class="col-lg-2">
<div class="form-group">
<label for="branches">Select Branch</label>
<select name="branches" id="branches" class="form-control">
<option value="">-- Select --</option>
</select>
</div>
</div>
<div class="col-lg-2">
<div class="form-group">
<label for="batches">Select Batch</label>
<select name="batches" id="batches" class="form-control">
<option value="">-- Select --</option>
</select>
</div>
</div>
<div class="col-lg-2">
<div class="form-group divBefore">
<label for="divisionBefore">Div</label>
<select name="divisionBefore" id="divisionBefore" class="form-control">
<option value="">Sel</option>
</select>
</div>
<div class="form-group divAfter hide">
<label for="division">Div</label>
<select name="division" id="division" class="form-control">
<option value="">Sel</option>
<?php
$divisionResult = mysql_query("SELECT * FROM division");
while($divisionRow = mysql_fetch_array($divisionResult)) {
echo
"<option value=".$divisionRow[0].">".$divisionRow[1]."</option>";
}
?>
</select>
</div>
</div>
<div class="col-lg-2">
<div class="form-group semesterBefore">
<label for="semBefore">Sem</label>
<select name="semBefore" id="semBefore" class="form-control">
<option value="">Sel</option>
</select>
</div>
<div class="form-group semesterAfter hide">
<label for="sem">Sem</label>
<select name="sem" id="sem" class="form-control">
<option value="">Sel</option>
</select>
</div>
</div>
<div class="col-lg-2">
<div class="form-group subject">
<label for="subject">Select Subject</label>
<select name="subject" id="subject" class="form-control">
<option value="">-- Select --</option>
</select>
</div>
</div>
<!--<div class="col-lg-2" id="lecBefore">
<div class="form-group">
<label for="subject">Select Lecture</label>
<select name="lect" id="lect" class="form-control">
<option value="">-- Select --</option>
</select>
</div>
</div>
<div class="col-lg-2 hide" id="lecAfter">
<div class="form-group">
<label for="subject">Select Lecture</label>
<select name="lecture" id="lecture" class="form-control">
<option value="">-- Select --</option>
<option value="1">Lecture 1</option>
<option value="2">Lecture 2</option>
<option value="3">Lecture 3</option>
<option value="4">Lecture 4</option>
<option value="5">Lecture 5</option>
<option value="6">Lecture 6</option>
<option value="7">Lecture 7</option>
<option value="8">Lecture 8</option>
</select>
</div>
</div>-->
<div class="col-lg-2 hide" id="date">
<div class="form-group">
<label for="dateNow">Start Date</label> <br>
<div class="input-group date" id="avsDate">
<input type="text" class="form-control" name="avsDateTxt" id="avsDateTxt" readonly value="<?php echo date('d-m-Y');?>"><span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
</div>
</div>
</div>
<div class="col-lg-2 hide" id="date1">
<div class="form-group">
<label for="dateNow">End Date</label> <br>
<div class="input-group date" id="endDate">
<input type="text" class="form-control" name="endDateTxt" id="endDateTxt" readonly value="<?php echo date('d-m-Y');?>"><span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
</div>
</div>
</div>
</form>
and my jquery is.
$(document).ready(function() {
$('.sidebar-menu .attnd').addClass('active');
$('.sidebar-menu .attnd .genExcel').addClass('active');
$(".sidebar-menu .attnd").tree();
$('#streams').change(function() {
$('#branches').html("<option value=''>-- Select --</option>");
$('#batches').html("<option value=''>-- Select --</option>");
$('.divAfter').hide();
$('.divBefore').show();
$('.semesterAfter').hide();
$('.semesterBefore').show();
$('#date').hide();
$('#date1').hide();
$('#lecAfter').hide();
$('#lecBefore').show();
$('#studManip').html('');
if($(this).val() != '')
$.streamSelection($(this).val());
});
$('#branches').change(function() {
$('#batches').html("<option value=''>-- Select --</option>");
$('.divAfter').hide();
$('.divBefore').show();
$('.semesterAfter').hide();
$('.semesterBefore').show();
$('#date').hide();
$('#date1').hide();
$('#lecAfter').hide();
$('#lecBefore').show();
$('#studManip').html('');
if($(this).val() != '')
$.branchSelection($(this).val());
});
$('#batches').change(function() {
$('.divAfter').hide();
$('.divBefore').show();
$('.semesterAfter').hide();
$('.semesterBefore').show();
$('#date').hide();
$('#date1').hide();
$('#lecAfter').hide();
$('#lecBefore').show();
$('#studManip').html('');
if($(this).val() != '') {
$.listSemester($(this).val());
$('.divBefore').hide();
$('#division').val('');
$('.divAfter').show();
}
});
$('#division').change(function() {
$('.studList').hide();
$('.semesterAfter').hide();
$('.semesterBefore').show();
$('#date').hide();
$('#date1').hide();
$('#lecAfter').hide();
$('#lecBefore').show();
$('#studManip').html('');
if($(this).val() != '') {
$('.semesterBefore').hide();
$('#sem').val('');
$('.semesterAfter').show();
}
});
$('#sem').change(function() {
$('#date').hide();
$('#date1').hide();
$('#lecAfter').hide();
$('#lecBefore').show();
$('#studManip').html('');
if($(this).val() != '')
$.searchSubject();
});
$('#subject').change(function() {
if($(this).val() != '') {
$.when($('#date').show())
.then($('#date1').show())
.then($('.btnExcel').show());
}
});
/*$('#lecture').change(function() {
$.when($('#date').hide())
.then($('#studManip').html(''));
if($(this).val() != '') {
$('#date').show();
$.when($.searchStudent())
.then($('#studManip').show());
}
});*/
$('#avsDate').datepicker({
format: "dd-mm-yyyy",
startDate: "01-01-2012",
endDate: '<?php echo date('d-m-Y')?>',
todayBtn: "linked",
autoclose: true,
todayHighlight: true,
});
$('#endDate').datepicker({
format: "dd-mm-yyyy",
startDate: "01-01-2012",
endDate: '<?php echo date('d-m-Y')?>',
todayBtn: "linked",
autoclose: true,
todayHighlight: true,
});
$('#avsDate').datepicker().on('changeDate', function(e) {
$.when($('.btnExcel').attr('href', 'studExcel.php?streamId='+$('#streams').val()+'&branchId='+$('#branches').val()+'&batchId='+$('#batches').val()+'&divisionId='+$('#division').val()+'&semId='+$('#sem').val()+'&sDate='+$('#advDatetxt').val()+'&eDate='+$('#endDatetxt').val()))
.then($('.btnExcel').show());
});
$('#endDate').change(function() {
$.when($('.btnExcel').attr('href', 'studExcel.php?streamId='+$('#streams').val()+'&branchId='+$('#branches').val()+'&batchId='+$('#batches').val()+'&divisionId='+$('#division').val()+'&semId='+$('#sem').val()+'&sDate='+$('#advDatetxt').val()+'&eDate='+$('#endDatetxt').val()))
.then($('.btnExcel').show());
});
/*var date = new Date();
$('#avsDate').datepicker().on('changeDate', function(e) {
$('#studManip').html('');
if(weekday[$(this).datepicker('getDate').getUTCDay()] != 'Sunday'){
$.when($.searchStudent())
.then($('#studManip').show());
} else
alert('Today is Sunday');
});*/
});
$.streamSelection = function(selStreamId) {
$.ajax({
url:"../student/searchBranch.php",
data:{
streamId:selStreamId,
},
success: function(data) {
$('#branches').html(data);
},
error: function(error) {
alert(error);
}
});
}
$.branchSelection = function(selBranchId) {
$.ajax({
url:"../student/searchBatch.php",
data:{
branchId:selBranchId,
},
success: function(data) {
$('#batches').html(data);
},
error: function(error) {
alert(error);
}
});
}
$.listSemester = function(selStreamId) {
$.ajax({
url:"../student/searchStream.php",
data:{
streamId:selStreamId,
},
success: function(data) {
$('#sem').html(data);
},
error: function(error) {
alert(error);
}
});
}
$.searchSubject = function() {
$.ajax({
url:"searchSubject.php",
data:{
streamId : $('#streams').val(),
branchId : $('#branches').val(),
semId : $('#sem').val(),
},
success: function(data) {
$('#subject').html(data);
},
error: function(error) {
alert(error);
}
});
}
every thing is working fine but when i change **advDatetxt** or **endDatetxt** jquery won't sending value with query string and describe as indefined. when i put cursor on excel button it will display left bottom corner as.
[![undefine variable][1]][1]
[1]: http://i.stack.imgur.com/f0uwB.png | 0debug |
convert TextField to Var Int (swift) : <p>Hi Im new to swift programming. I would like to get the input of a textfield, convert it to an int and then work with that int (decreasing it). Here is my code:</p>
<pre><code> @IBOutlet weak var minutes: UITextField!
@IBOutlet weak var seconds: UITextField!
@IBOutlet weak var label_Timer: UILabel!
@IBAction func btn_Timer(_ sender: UITextField) {
var min:Int = Int(minutes.text!)
var sec:Int = Int(seconds.text!)
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(ViewController.timerRunning), userInfo: nil, repeats: true)
}
func timerRunning(){
sec -= 1
//operate on min and sec here
}
</code></pre>
| 0debug |
JAVA - How do I generate a random number that is weighted towards certain numbers? : <p>How do I generate a random number in Java, (using Eclipse) that is weighted towards certain numbers?</p>
<p>Example, I have 100 numbers, each can be equally chosen 1% of the time. However, if a certain number, lets say 5, is displayed 8 times in that 100, it now has an 8% chance to be randomly selected, while the other numbers are still at 1%. </p>
<p>How can I write a random generator that gives me 10 numbers and gives the number 5 that 8% advantage to show up?</p>
<p>Thanks and sorry if I did not explain that well.</p>
| 0debug |
Why comparing strings inside a method doesn't work? : <p>I've got 2 classes, object of the second class is created inside the first class. I'm using next() method to increase the value of seconds, then I want to check if its value is 0 and cannot get through by using .equals("0") method. </p>
<p>I'm writing in Eclipse, java 11</p>
<pre><code>public void tick(){
seconds.next(); //var "seconds" is of type second class(calling
// seconds means toString() from 2nd class)
if(seconds.equals("0")) {
System.out.println("CANNOT ACCESS THIS ????");
}
</code></pre>
<p>Method next() from second class: </p>
<pre><code>public void next() {
if(value==upperLimit) value=0;
else ++value;
}
public String toString() {
return value+"";
}
</code></pre>
<p>I expect to run first if statement inside tick() method, but it doesn't.</p>
| 0debug |
static int dvdsub_decode(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
DVDSubContext *ctx = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AVSubtitle *sub = data;
int is_menu;
if (ctx->buf_size) {
int ret = append_to_cached_buf(avctx, buf, buf_size);
if (ret < 0) {
*data_size = 0;
return ret;
}
buf = ctx->buf;
buf_size = ctx->buf_size;
}
is_menu = decode_dvd_subtitles(ctx, sub, buf, buf_size);
if (is_menu == AVERROR(EAGAIN)) {
*data_size = 0;
return append_to_cached_buf(avctx, buf, buf_size);
}
if (is_menu < 0) {
no_subtitle:
reset_rects(sub);
*data_size = 0;
return buf_size;
}
if (!is_menu && find_smallest_bounding_rectangle(sub) == 0)
goto no_subtitle;
if (ctx->forced_subs_only && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED))
goto no_subtitle;
#if defined(DEBUG)
{
char ppm_name[32];
snprintf(ppm_name, sizeof(ppm_name), "/tmp/%05d.ppm", ctx->sub_id++);
ff_dlog(NULL, "start=%d ms end =%d ms\n",
sub->start_display_time,
sub->end_display_time);
ppm_save(ppm_name, sub->rects[0]->pict.data[0],
sub->rects[0]->w, sub->rects[0]->h, (uint32_t*) sub->rects[0]->pict.data[1]);
}
#endif
ctx->buf_size = 0;
*data_size = 1;
return buf_size;
}
| 1threat |
Ruby Alphabet Upcase : So i can print the alphabet in Ruby.
alphabet = (a..z)
I can convert strings into Uppercase
string.upcase
However I can't figure out the right syntax to print the alphabet in uppercase.
I have the below code, which maps a frequency count to the displayed alphabet, I just want to be able to have each letter on a separate line and in uppercase.
mappedfreq = alphabet.upcase.collect do | s1 |frq = @lt[s1]
s1 + (frq> 0 ? ": #{'x ' x frq}" : '')
But placing the above ".upcase" throws an error.
| 0debug |
hqo can i make a correct regex in dajngo? : I need to make regex to make a button witch put me on other website
this is my re_path:
re_path (r'^detaletournament(?P<turnament_id>[0-9]+)/$',detaletournament)
Using the URLconf defined in projekt.urls, Django tried these URL patterns, in this order:
admin/
tir
login
register
usertournaments
turnament
addturnament
takepart
deletetournament
quittournament
mytournaments
webturnament
profile
^detaletournament(?P<turnament_id>[0-9]+)/$
The current path, detaletournament, didn't match any of these. | 0debug |
def overlapping(list1,list2):
c=0
d=0
for i in list1:
c+=1
for i in list2:
d+=1
for i in range(0,c):
for j in range(0,d):
if(list1[i]==list2[j]):
return 1
return 0 | 0debug |
Deploy a specific directory to npm with Travis-CI : <p>I want to deploy the <code>dist</code> folder after success. But instead, it keeps deploying the whole repository.</p>
<p>What I want to achieve is the same effect with:</p>
<pre><code>npm publish dist
</code></pre>
<p>Here is the related part from my <code>.travis.yml</code>:</p>
<pre><code>deploy:
provider: npm
email: sa.alemdar@hotmail.com
api_key:
secure: MyApiKey
skip_cleanup: true
file_glob: true
file: "dist/**/*"
on:
tags: true
repo: salemdar/angular2-cookie
</code></pre>
| 0debug |
How To Compile An Electron Application To A .exe : <p>I've been learning how to create applications in <a href="http://electron.atom.io/" rel="noreferrer">Electron</a> and I need help compiling a simple project to a Windows executable. The program is a clone from this Github repo: <a href="https://github.com/electron/electron-quick-start" rel="noreferrer">https://github.com/electron/electron-quick-start</a>. On the repo readme it shows how to run the program:</p>
<pre><code># Clone this repository
git clone https://github.com/electron/electron-quick-start
# Go into the repository
cd electron-quick-start
# Install dependencies
npm install
# Run the app
npm start
</code></pre>
<p>This works fine, but I can't figure out how to simply compile it. I've looked all over google, you would think that something as simple as deploying an application would be well known information. </p>
| 0debug |
Simulate Lens flare and chromatic aberration using python : <p>I have a set of images. I have to use them for training a network. I want to simulate a lens flare effect and chromatic aberration on the images. I have tried to find some function in OpenCV, scikit and other python image library but no help from there. How can i simulate these effect on my image? Rough idea or code will be useful. Images are in jpg format.</p>
| 0debug |
target_ulong helper_dvpe(CPUMIPSState *env)
{
CPUMIPSState *other_cpu = first_cpu;
target_ulong prev = env->mvp->CP0_MVPControl;
do {
if (other_cpu != env) {
other_cpu->mvp->CP0_MVPControl &= ~(1 << CP0MVPCo_EVP);
mips_vpe_sleep(other_cpu);
}
other_cpu = other_cpu->next_cpu;
} while (other_cpu);
return prev;
}
| 1threat |
Illegal instruction(core dumped) tensorflow : <p>I am importing tensorflow in my ubuntu python
using following commands-</p>
<pre><code>$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Illegal instruction (core dumped)
</code></pre>
<p>And the program exits.
Please specify the solution.</p>
| 0debug |
Piping not working with echo command : <p>When I run the following <code>Bash</code> script, I would expect it to print <code>Hello</code>. Instead, it prints a blank line and exits.</p>
<pre><code>echo 'Hello' | echo
</code></pre>
<p>Why doesn't <code>piping</code> output from <code>echo</code> to <code>echo</code> work?</p>
| 0debug |
DECL_IMDCT_BLOCKS(sse,sse)
#endif
DECL_IMDCT_BLOCKS(sse2,sse)
DECL_IMDCT_BLOCKS(sse3,sse)
DECL_IMDCT_BLOCKS(ssse3,sse)
#endif
#if HAVE_AVX_EXTERNAL
DECL_IMDCT_BLOCKS(avx,avx)
#endif
#endif
av_cold void ff_mpadsp_init_x86(MPADSPContext *s)
{
int cpu_flags = av_get_cpu_flags();
int i, j;
for (j = 0; j < 4; j++) {
for (i = 0; i < 40; i ++) {
mdct_win_sse[0][j][4*i ] = ff_mdct_win_float[j ][i];
mdct_win_sse[0][j][4*i + 1] = ff_mdct_win_float[j + 4][i];
mdct_win_sse[0][j][4*i + 2] = ff_mdct_win_float[j ][i];
mdct_win_sse[0][j][4*i + 3] = ff_mdct_win_float[j + 4][i];
mdct_win_sse[1][j][4*i ] = ff_mdct_win_float[0 ][i];
mdct_win_sse[1][j][4*i + 1] = ff_mdct_win_float[4 ][i];
mdct_win_sse[1][j][4*i + 2] = ff_mdct_win_float[j ][i];
mdct_win_sse[1][j][4*i + 3] = ff_mdct_win_float[j + 4][i];
}
}
#if HAVE_6REGS && HAVE_SSE_INLINE
if (INLINE_SSE(cpu_flags)) {
s->apply_window_float = apply_window_mp3;
}
#endif
#if HAVE_YASM
#if HAVE_SSE
#if ARCH_X86_32
if (EXTERNAL_SSE(cpu_flags)) {
s->imdct36_blocks_float = imdct36_blocks_sse;
}
#endif
if (EXTERNAL_SSE2(cpu_flags)) {
s->imdct36_blocks_float = imdct36_blocks_sse2;
}
if (EXTERNAL_SSE3(cpu_flags)) {
s->imdct36_blocks_float = imdct36_blocks_sse3;
}
if (EXTERNAL_SSSE3(cpu_flags)) {
s->imdct36_blocks_float = imdct36_blocks_ssse3;
}
#endif
#if HAVE_AVX_EXTERNAL
if (EXTERNAL_AVX(cpu_flags)) {
s->imdct36_blocks_float = imdct36_blocks_avx;
}
#endif
#endif
}
| 1threat |
int MPA_encode_init(AVCodecContext *avctx)
{
MpegAudioContext *s = avctx->priv_data;
int freq = avctx->sample_rate;
int bitrate = avctx->bit_rate;
int channels = avctx->channels;
int i, v, table;
float a;
if (channels > 2)
return -1;
bitrate = bitrate / 1000;
s->nb_channels = channels;
s->freq = freq;
s->bit_rate = bitrate * 1000;
avctx->frame_size = MPA_FRAME_SIZE;
avctx->key_frame = 1;
s->lsf = 0;
for(i=0;i<3;i++) {
if (mpa_freq_tab[i] == freq)
break;
if ((mpa_freq_tab[i] / 2) == freq) {
s->lsf = 1;
break;
}
}
if (i == 3)
return -1;
s->freq_index = i;
for(i=0;i<15;i++) {
if (mpa_bitrate_tab[s->lsf][1][i] == bitrate)
break;
}
if (i == 15)
return -1;
s->bitrate_index = i;
a = (float)(bitrate * 1000 * MPA_FRAME_SIZE) / (freq * 8.0);
s->frame_size = ((int)a) * 8;
s->frame_frac = 0;
s->frame_frac_incr = (int)((a - floor(a)) * 65536.0);
table = l2_select_table(bitrate, s->nb_channels, freq, s->lsf);
s->sblimit = sblimit_table[table];
s->alloc_table = alloc_tables[table];
#ifdef DEBUG
printf("%d kb/s, %d Hz, frame_size=%d bits, table=%d, padincr=%x\n",
bitrate, freq, s->frame_size, table, s->frame_frac_incr);
#endif
for(i=0;i<s->nb_channels;i++)
s->samples_offset[i] = 0;
for(i=0;i<257;i++) {
int v;
v = (mpa_enwindow[i] + 2) >> 2;
filter_bank[i] = v;
if ((i & 63) != 0)
v = -v;
if (i != 0)
filter_bank[512 - i] = v;
}
for(i=0;i<64;i++) {
v = (int)(pow(2.0, (3 - i) / 3.0) * (1 << 20));
if (v <= 0)
v = 1;
scale_factor_table[i] = v;
#ifdef USE_FLOATS
scale_factor_inv_table[i] = pow(2.0, -(3 - i) / 3.0) / (float)(1 << 20);
#else
#define P 15
scale_factor_shift[i] = 21 - P - (i / 3);
scale_factor_mult[i] = (1 << P) * pow(2.0, (i % 3) / 3.0);
#endif
}
for(i=0;i<128;i++) {
v = i - 64;
if (v <= -3)
v = 0;
else if (v < 0)
v = 1;
else if (v == 0)
v = 2;
else if (v < 3)
v = 3;
else
v = 4;
scale_diff_table[i] = v;
}
for(i=0;i<17;i++) {
v = quant_bits[i];
if (v < 0)
v = -v;
else
v = v * 3;
total_quant_bits[i] = 12 * v;
}
return 0;
}
| 1threat |
It always returns the none value but I want to print the bool in result : [It always returns the none value but I want to print the bool in result][1]
[1]: https://i.stack.imgur.com/iRJum.png | 0debug |
destructor c++ make leak memory : <p>I'm having a hard time figuring out how this destructor call</p>
<p>So I have class A with virtual destructor and inline virtual clone function</p>
<pre><code>class A{
public:
A(){ }
virtual ~A(){
qDebug() << "Class A destructor";
}
inline virtual A *clone(){
return NULL;
}
};
</code></pre>
<p>Then I have sub-class B also have destructor and clone function return pointer to class A</p>
<pre><code>class B : public A{
public:
B() { }
~B(){
qDebug() << "Class B destructor";
}
A *clone(){
B *temp = new B();
return static_cast<A *>(temp);
}
};
</code></pre>
<p>And I have main function and test function and i start do some crazy thing about pointer</p>
<pre><code>A *test(A *input){
return input->clone();
}
int main(){
B temp2;
A *temp = test(&temp2);
delete temp;
return 0;
}
</code></pre>
<p>Finally if I have the output is </p>
<pre><code>Class B destructor
Class A destructor
Class B destructor
Class A destructor
</code></pre>
<p>and if I'm not using virtual before destructor class A, I have ouput is</p>
<pre><code>Class A destructor
Class B destructor
Class A destructor
</code></pre>
<p>So can anyone explain me why virtual make so much different</p>
| 0debug |
How to print data from a block of data? : I am trying to read a file as a block of data and then get certain values from that data and store them in a struct, and I don't understand the professor's example.
I have a header file that contains a struct:
#ifndef _STRUC_H
#define _STRUC_H
#define NAMELEN 51
#define ADDLEN 125
struct record
{
int id;
char name[NAMELEN];
char address[ADDLEN];
};
#endif
And i have my main function that looks like this:
int main() {
string fileName;
ifstream inFile;
cout << "Please enter a filename: ";
getline(cin,fileName);
inFile.open(fileName);
if(!inFile)
{
cerr << "Could not open: " << fileName << endl;
return 1;
}
cout << endl;
record rec;
inFile.read(reinterpret_cast<char *>(&rec),sizeof(rec));
while(!inFile.eof())
{
cout << "Id : " << rec.id << endl;
cout << "Name: " << rec.name << endl;
cout << "Addr: " << rec.address << "\n" << endl;
inFile.read(reinterpret_cast<char *>(&rec),sizeof(rec));
}
inFile.close();
return 0;
}
What do the values for NAMELEN and ADDLEN do and How did my professor get them? | 0debug |
How to remove all git origin and local tags? : <p>How do you remove a git tag that has already been pushed?
Delete all git remote (origin) tags and Delete all git local tags.</p>
| 0debug |
uint32_t HELPER(ucf64_get_fpscr)(CPUUniCore32State *env)
{
int i;
uint32_t fpscr;
fpscr = (env->ucf64.xregs[UC32_UCF64_FPSCR] & UCF64_FPSCR_MASK);
i = get_float_exception_flags(&env->ucf64.fp_status);
fpscr |= ucf64_exceptbits_from_host(i);
return fpscr;
}
| 1threat |
Python: ImportError: No module named 'HTMLParser' : <p>I am new to Python. I have tried to ran this code but I am getting an error message for ImportError: No module named 'HTMLParser'. I am using Python 3.x. Any reason why this is not working ?</p>
<pre><code>#Import the HTMLParser model
from HTMLParser import HTMLParser
#Create a subclass and override the handler methods
class MyHTMLParser(HTMLParser):
#Function to handle the processing of HTML comments
def handle_comment(self,data):
print ("Encountered comment: ", data)
pos = self.getpos()
print ("At line: ", pos[0], "position ", pos[1])
def main():
#Instantiate the parser and feed it some html
parser= MyHTMLParser()
#Open the sample file and read it
f = open("myhtml.html")
if f.mode== "r":
contents= f.read() #read the entire FileExistsError
parser.feed()
if __name__== "__main__":
main()
</code></pre>
<p>I am getting the following error:</p>
<pre><code>Traceback (most recent call last):
File "C:\Users\bm250199\workspace\test\htmlparsing.py", line 3, in <module>
from HTMLParser import HTMLParser
ImportError: No module named 'HTMLParser'
</code></pre>
| 0debug |
Eclipse progra does not run with no errors : So i need to create a program for the user to input match scores and exit by inputting "exit" when prompted. However this code does not run even though there is no errors
package Main;
import java.util.Scanner;
public class Assignment {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
String[] names = new String[10];
int index = 0;
while (index<10);
{
index++;
System.out.print("Home team name: ");
names[index] = keyboard.nextLine();
System.out.print("Away team name: ");
names[index] = keyboard.nextLine();
System.out.print("Enter home score: ");
names[index] = keyboard.nextLine();
System.out.print("Enter away score: ");
names[index] = keyboard.nextLine();
System.out.print("If you would liketo quit type exit: ");
if ("exit".equalsIgnoreCase(keyboard.nextLine()));
keyboard.close();
}
}
}
I have very little knowledge of java and coding at this point, only very basic commands so i have no clue what is wrong.
| 0debug |
static MemoryRegionSection phys_page_find(target_phys_addr_t index)
{
uint16_t *p = phys_page_find_alloc(index, 0);
uint16_t s_index = phys_section_unassigned;
MemoryRegionSection section;
target_phys_addr_t delta;
if (p) {
s_index = *p;
}
section = phys_sections[s_index];
index <<= TARGET_PAGE_BITS;
assert(section.offset_within_address_space <= index
&& index <= section.offset_within_address_space + section.size-1);
delta = index - section.offset_within_address_space;
section.offset_within_address_space += delta;
section.offset_within_region += delta;
section.size -= delta;
return section;
}
| 1threat |
this code for loop and set-interval not work : i try to make a count that count from 10 to 0 by JavaScript with loop function and set interval but not work for me
this is a html file
<div id="countDown">10</div>
this is the JavaScript code
var numbers = document.getElementById('countDown');
function count() {
var i;
for(i=numbers.textContent; 0<=i; i--){
numbers.textContent= i;
}
}
setInterval(count, 1000); | 0debug |
Need to optimize a webpage for a course and the timeline shows this function as causing a forced sunchronous : Need to fix this piece of code in Javascript which is causing a forced synchronous layout. Any ideas or help as to how?
function updatePositions() {
frame++;
window.performance.mark("mark_start_frame");
var items = document.querySelectorAll('.mover');
for (var i = 0; i < items.length; i++) {
var phase = Math.sin((document.body.scrollTop / 1250) + (i % 5));
items[i].style.left = items[i].basicLeft + 100 * phase + 'px';
} | 0debug |
Persistent profile error in Google Chrome : <p>When I open Google Chrome I constantly get the error "A PROFILE ERROR OCCURRED: Something went wrong when opening your profile. Some features may be unavailable". Further, when I close Chrome, it will then refuse to open again unless I log out and log back in. This problem has survived logging out and back in to Chrome, uninstalling and reinstalling, and persists even if I am signed out of my Google account. This is occurring on my desktop PC but does not occur on my work PC, and so appears to be a problem with chrome on my PC.
Please help!</p>
| 0debug |
static void virtio_net_add_queue(VirtIONet *n, int index)
{
VirtIODevice *vdev = VIRTIO_DEVICE(n);
n->vqs[index].rx_vq = virtio_add_queue(vdev, n->net_conf.rx_queue_size,
virtio_net_handle_rx);
if (n->net_conf.tx && !strcmp(n->net_conf.tx, "timer")) {
n->vqs[index].tx_vq =
virtio_add_queue(vdev, 256, virtio_net_handle_tx_timer);
n->vqs[index].tx_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
virtio_net_tx_timer,
&n->vqs[index]);
} else {
n->vqs[index].tx_vq =
virtio_add_queue(vdev, 256, virtio_net_handle_tx_bh);
n->vqs[index].tx_bh = qemu_bh_new(virtio_net_tx_bh, &n->vqs[index]);
}
n->vqs[index].tx_waiting = 0;
n->vqs[index].n = n;
}
| 1threat |
static void tci_out_label(TCGContext *s, TCGArg arg)
{
TCGLabel *label = &s->labels[arg];
if (label->has_value) {
tcg_out_i(s, label->u.value);
assert(label->u.value);
} else {
tcg_out_reloc(s, s->code_ptr, sizeof(tcg_target_ulong), arg, 0);
tcg_out_i(s, 0);
}
}
| 1threat |
def count_X(tup, x):
count = 0
for ele in tup:
if (ele == x):
count = count + 1
return count | 0debug |
def remove_negs(num_list):
for item in num_list:
if item < 0:
num_list.remove(item)
return num_list | 0debug |
app.get - is there any difference between res.send vs return res.send : <p>I am new to node and express. I have seen app.get and app.post examples using both "res.send" and "return res.send". Are these the same? </p>
<pre><code>var express = require('express');
var app = express();
app.get('/', function(req, res) {
res.type('text/plain');
res.send('i am a beautiful butterfly');
});
</code></pre>
<p>or</p>
<pre><code>var express = require('express');
var app = express();
app.get('/', function(req, res) {
res.type('text/plain');
return res.send('i am a beautiful butterfly');
});
</code></pre>
| 0debug |
How to bubble up angular2 custom event : <p>Parent template:</p>
<pre><code><ul>
<tree-item [model]="tree" (addChild)="addChild($event)"></tree-item>
</ul>
</code></pre>
<p>Tree item template:</p>
<pre><code><li>
<div>{{model.name}}
<span [hidden]="!isFolder" (click)="addChild.emit(model)">Add Child</span>
</div>
<ul *ngFor="let m of model.children">
<tree-item [model]="m"></tree-item>
</ul>
</li>
</code></pre>
<p>For above example, parent receives addChild event only from the root tree-item (immediate child). Is it possible to bubble up addChild event from any tree-item?
I am using angular 2.0.0-rc.0.</p>
| 0debug |
What is wrong in this code php? : <p>What is wrong in this code php ?
netbeans 8.1 program have been tried and when I write $ _GET problem that occurs</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code> <html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
if ($_GET['button']) {
if ($_GET['name']) {
echo "Your Name Is".$_GET['name'];
}else {
echo "Plz Enter your Name";
}
}
?>
<div>
<label for="name">Name :</label>
<input type="text" name="name"/>
<input type="submit" name="button" value="Submit" for="name" />
</div>
</body>
</html></code></pre>
</div>
</div>
</p>
| 0debug |
Updating Column Values using DateLine : <p>Here is my sql table</p>
<pre><code>create table Poll_Question_Table (
PollQuestionId int primary key,
PollQuestionTex varchar(max),
PollStatus int ,
PollStartDate date,
PollEndDate date
)
</code></pre>
<p>i Want to change th status value from 1 to 0 if the current date pass the end date (dateline ) using function or trigger ..... tnx for ur help</p>
| 0debug |
Is there any process of running application after terminate in ios? : I was developing application which trigger some function every time after application is terminate but in iOS I havent found any solution for this process.
Can anyone suggest me the process to run application after terminate application in iOS. | 0debug |
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
{
int ret;
if ((ret = graph_check_validity(graphctx, log_ctx)))
if ((ret = graph_insert_fifos(graphctx, log_ctx)) < 0)
if ((ret = graph_config_formats(graphctx, log_ctx)))
if ((ret = graph_config_links(graphctx, log_ctx)))
if ((ret = graph_config_pointers(graphctx, log_ctx)))
return 0;
} | 1threat |
static int decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
H264Context *h = avctx->priv_data;
MpegEncContext *s = &h->s;
AVFrame *pict = data;
int buf_index;
s->flags= avctx->flags;
s->flags2= avctx->flags2;
if (buf_size == 0) {
Picture *out;
int i, out_idx;
out = h->delayed_pic[0];
out_idx = 0;
for(i=1; h->delayed_pic[i] && (h->delayed_pic[i]->poc && !h->delayed_pic[i]->key_frame); i++)
if(h->delayed_pic[i]->poc < out->poc){
out = h->delayed_pic[i];
out_idx = i;
}
for(i=out_idx; h->delayed_pic[i]; i++)
h->delayed_pic[i] = h->delayed_pic[i+1];
if(out){
*data_size = sizeof(AVFrame);
*pict= *(AVFrame*)out;
}
return 0;
}
if(h->is_avc && !h->got_avcC) {
int i, cnt, nalsize;
unsigned char *p = avctx->extradata;
if(avctx->extradata_size < 7) {
av_log(avctx, AV_LOG_ERROR, "avcC too short\n");
return -1;
}
if(*p != 1) {
av_log(avctx, AV_LOG_ERROR, "Unknown avcC version %d\n", *p);
return -1;
}
h->nal_length_size = 2;
cnt = *(p+5) & 0x1f;
p += 6;
for (i = 0; i < cnt; i++) {
nalsize = AV_RB16(p) + 2;
if(decode_nal_units(h, p, nalsize) < 0) {
av_log(avctx, AV_LOG_ERROR, "Decoding sps %d from avcC failed\n", i);
return -1;
}
p += nalsize;
}
cnt = *(p++);
for (i = 0; i < cnt; i++) {
nalsize = AV_RB16(p) + 2;
if(decode_nal_units(h, p, nalsize) != nalsize) {
av_log(avctx, AV_LOG_ERROR, "Decoding pps %d from avcC failed\n", i);
return -1;
}
p += nalsize;
}
h->nal_length_size = ((*(((char*)(avctx->extradata))+4))&0x03)+1;
h->got_avcC = 1;
}
if(!h->got_avcC && !h->is_avc && s->avctx->extradata_size){
if(decode_nal_units(h, s->avctx->extradata, s->avctx->extradata_size) < 0)
return -1;
h->got_avcC = 1;
}
buf_index=decode_nal_units(h, buf, buf_size);
if(buf_index < 0)
return -1;
if(!(s->flags2 & CODEC_FLAG2_CHUNKS) && !s->current_picture_ptr){
if (avctx->skip_frame >= AVDISCARD_NONREF || s->hurry_up) return 0;
av_log(avctx, AV_LOG_ERROR, "no frame!\n");
return -1;
}
if(!(s->flags2 & CODEC_FLAG2_CHUNKS) || (s->mb_y >= s->mb_height && s->mb_height)){
Picture *out = s->current_picture_ptr;
Picture *cur = s->current_picture_ptr;
int i, pics, cross_idr, out_of_order, out_idx;
field_end(h);
if (cur->field_poc[0]==INT_MAX || cur->field_poc[1]==INT_MAX) {
*data_size = 0;
} else {
cur->repeat_pict = 0;
if (h->sei_ct_type)
cur->interlaced_frame = (h->sei_ct_type & (1<<1)) != 0;
else
cur->interlaced_frame = FIELD_OR_MBAFF_PICTURE;
if(h->sps.pic_struct_present_flag){
switch (h->sei_pic_struct)
{
case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
cur->repeat_pict = 1;
break;
case SEI_PIC_STRUCT_FRAME_DOUBLING:
cur->interlaced_frame = 0;
cur->repeat_pict = 2;
break;
case SEI_PIC_STRUCT_FRAME_TRIPLING:
cur->interlaced_frame = 0;
cur->repeat_pict = 4;
break;
}
}else{
cur->interlaced_frame = FIELD_OR_MBAFF_PICTURE;
}
if (cur->field_poc[0] != cur->field_poc[1]){
cur->top_field_first = cur->field_poc[0] < cur->field_poc[1];
}else{
if(cur->interlaced_frame || h->sps.pic_struct_present_flag){
if(h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM
|| h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)
cur->top_field_first = 1;
else
cur->top_field_first = 0;
}else{
cur->top_field_first = 0;
}
}
if(h->sps.bitstream_restriction_flag
&& s->avctx->has_b_frames < h->sps.num_reorder_frames){
s->avctx->has_b_frames = h->sps.num_reorder_frames;
s->low_delay = 0;
}
if( s->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT
&& !h->sps.bitstream_restriction_flag){
s->avctx->has_b_frames= MAX_DELAYED_PIC_COUNT;
s->low_delay= 0;
}
pics = 0;
while(h->delayed_pic[pics]) pics++;
assert(pics <= MAX_DELAYED_PIC_COUNT);
h->delayed_pic[pics++] = cur;
if(cur->reference == 0)
cur->reference = DELAYED_PIC_REF;
out = h->delayed_pic[0];
out_idx = 0;
for(i=1; h->delayed_pic[i] && (h->delayed_pic[i]->poc && !h->delayed_pic[i]->key_frame); i++)
if(h->delayed_pic[i]->poc < out->poc){
out = h->delayed_pic[i];
out_idx = i;
}
cross_idr = !h->delayed_pic[0]->poc || !!h->delayed_pic[i] || h->delayed_pic[0]->key_frame;
out_of_order = !cross_idr && out->poc < h->outputed_poc;
if(h->sps.bitstream_restriction_flag && s->avctx->has_b_frames >= h->sps.num_reorder_frames)
{ }
else if((out_of_order && pics-1 == s->avctx->has_b_frames && s->avctx->has_b_frames < MAX_DELAYED_PIC_COUNT)
|| (s->low_delay &&
((!cross_idr && out->poc > h->outputed_poc + 2)
|| cur->pict_type == FF_B_TYPE)))
{
s->low_delay = 0;
s->avctx->has_b_frames++;
}
if(out_of_order || pics > s->avctx->has_b_frames){
out->reference &= ~DELAYED_PIC_REF;
for(i=out_idx; h->delayed_pic[i]; i++)
h->delayed_pic[i] = h->delayed_pic[i+1];
}
if(!out_of_order && pics > s->avctx->has_b_frames){
*data_size = sizeof(AVFrame);
h->outputed_poc = out->poc;
*pict= *(AVFrame*)out;
}else{
av_log(avctx, AV_LOG_DEBUG, "no picture\n");
}
}
}
assert(pict->data[0] || !*data_size);
ff_print_debug_info(s, pict);
#if 0
avctx->frame_number = s->picture_number - 1;
#endif
return get_consumed_bytes(s, buf_index, buf_size);
}
| 1threat |
Convert String containing bytes to Noramal String in java : I am having String containing bytes and i want to convert it to normal String but getting exception
String a ="[B@45466625</";
byte[] btDataFile = new sun.misc.BASE64Decoder().decodeBuffer(a);
String b = new String(btDataFile);
System.out.println(b); | 0debug |
Concatenate string and int : <p>I want to concatenate integer and string value, where integer is in a 2D list and string is in a 1D list.</p>
<pre><code>['VDM', 'MDM', 'OM']
</code></pre>
<p>The above mentions list is my string list.</p>
<pre><code>[[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]
</code></pre>
<p>The above mentioned list is my integer list.</p>
<p>I have tried this code:</p>
<pre><code>for i in range(numAttr):
for j in range(5):
abc=[[attr[i]+counts[i][j]]]
print(abc)
</code></pre>
<p>Here numAttr is the number of element in the first 1D list. and second 2D list is a static list i.e. for any dataset the 2D list will not change.</p>
<p>The above code showing the error:</p>
<pre><code>TypeError: can only concatenate str (not "int") to str
</code></pre>
<p>I want a list output which looks like this:</p>
<pre><code>[['VDM:1','VDM:2','VDM:3','VDM:4','VDM:5'],['MDM:1','MDM:2','MDM:3','MDM:4','MDM:5'],['OM:1','OM:2','OM:3','OM:4','OM:5']]
</code></pre>
| 0debug |
What does '->' mean in python? : <p>All,</p>
<p>Can you please tell me what this line means in Python? I don't know if I'm using it properly. </p>
<p>def read_places_file(filename) -> List[PlaceInformation]: </p>
<p>We are defining a method that takes a parameter called, 'filename'. And then what does the rest of the line mean? What does the '->' operator mean? </p>
<p>Thank you very much in advance. </p>
| 0debug |
Get the Text of a specific Textbox (not all) inside a Panel control : <p>How can I get the text from a Textbox and only this Textbox inside a Panel control in a visual studio Form. Panel is Panel1 and Textbox is txtbox. Thank you.</p>
| 0debug |
Significance of trivial destruction : <p>In C++17, the new <code>std::optional</code> mandates that it be trivially destructible if <code>T</code> is trivially destructible in [optional.object.dtor]:</p>
<blockquote>
<p><code>~optional();</code><br>
1 <em>Effects</em>: If <code>is_trivially_destructible_v<T> != true</code> and <code>*this</code> contains a value, calls <code>val->T::~T()</code>.<br>
2 <em>Remarks</em>: If <code>is_trivially_destructible_v<T> == true</code> then this destructor shall be a trivial destructor.</p>
</blockquote>
<p>So this potential implementation fragment would be non-conforming to the standard:</p>
<pre><code>template <class T>
struct wrong_optional {
union { T value; };
bool on;
~wrong_optional() { if (on) { value.~T(); } }
};
</code></pre>
<p>My question is: what is the advantage of this mandate? Presumably, for trivially destructible types, the compiler can figure out that <code>value.~T()</code> is a no-op and emit no code for <code>wrong_optional<T>::~wrong_optional()</code>. </p>
| 0debug |
C++ primer array? : It might be a boring question! thanks!
Here's the code:
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int a[5] = {0};
int b[5];
cout << a << endl;
cout << b << endl;
for (int i = 0; i < 5; i++)
{
cout << a[i] << " ";
}
cout << endl;
for (int i = 0; i < 5; i++)
{
cout << b[i] << " ";
}
cout << endl;
return 0;
}
in Ubuntu: g++ a.cpp
[![enter image description here][1]][1]
In windows with DEV C++ ,MinGW GCC 4.7.2:
[![enter image description here][2]][2]
So the question is focused on the array b:
I know I haven't initialized the array b.
Array b is full of garbage values, but why there is always having '0' with the fixed position like "X 0 X 0 X"??
What happens inside??
Just a protection mechanism?
[1]: http://i.stack.imgur.com/YjAwY.png
[2]: http://i.stack.imgur.com/QoNZw.png | 0debug |
Intellij gradle - using explicit module groups VS using qualified names : <p>I am trying to create a Gradle Java application.</p>
<p>In the New Project wizard, two options are available: </p>
<ul>
<li>using explicit module groups</li>
<li>using qualified names</li>
</ul>
<p>What do those two options mean? What are the differences?</p>
| 0debug |
Why did this guy use '\\n' : Ok so i was watching a python 3 tutorial about how to download a file
and this is what it kinda looks like
from urllib import request
import requests
goog="http://realchart.finance.yahoo.com/table.csvs=GOOG&d=8&e=7&f=2016&g=d&a=7&b=19&c=2004&ignore=.csv"
rp=request.urlopen(goog)
s=rp.read()
cp=str(s)
m=cp.split('\\n')
dest='goog.csv'
fw=open(dest,'w')
for c in m:
fw.write(c+ '\n')
fw.close()
fr=open('goog.csv','r')
k=fr.read()
print(k)
Why was split(\\\n) used ??? its true that the code only works properly when you use the double black slashes but why | 0debug |
static void vfio_vga_probe_ati_3c3_quirk(VFIOPCIDevice *vdev)
{
VFIOQuirk *quirk;
if (!vfio_pci_is(vdev, PCI_VENDOR_ID_ATI, PCI_ANY_ID) ||
!vdev->bars[4].ioport || vdev->bars[4].region.size < 256) {
return;
}
quirk = g_malloc0(sizeof(*quirk));
quirk->mem = g_malloc0(sizeof(MemoryRegion));
quirk->nr_mem = 1;
memory_region_init_io(quirk->mem, OBJECT(vdev), &vfio_ati_3c3_quirk, vdev,
"vfio-ati-3c3-quirk", 1);
memory_region_add_subregion(&vdev->vga.region[QEMU_PCI_VGA_IO_HI].mem,
3 , quirk->mem);
QLIST_INSERT_HEAD(&vdev->vga.region[QEMU_PCI_VGA_IO_HI].quirks,
quirk, next);
trace_vfio_quirk_ati_3c3_probe(vdev->vbasedev.name);
}
| 1threat |
What is Default value of array on heap in c++? : <p>When I print the default value of array on heap memory I'm getting random big numbers in code block. I know that the default value of array is 0 but I am getting random number . </p>
| 0debug |
Can I Have Redux-Saga and Redux-Thunk Working Together? : <p>I was working with redux-saga but I'm with a problem: the redux-auth-wrapper needs the redux-thunk to do the redirects, so I simply added the thunk in my store:</p>
<pre><code> import {createStore, compose, applyMiddleware} from 'redux';
import createLogger from 'redux-logger';
import {routerMiddleware} from 'react-router-redux';
import {browserHistory} from 'react-router';
import thunk from 'redux-thunk';
import createSagaMiddleware, {END} from 'redux-saga';
import sagas from '../sagas';
import reduxImmutableStateInvariant from 'redux-immutable-state-invariant';
import rootReducer from '../reducers';
import _ from 'lodash';
import {loadState, saveState} from '../connectivity/localStorage';
const persistedState = loadState();
const routerMw = routerMiddleware(browserHistory);
const loggerMiddleware = createLogger();
const sagaMiddleware = createSagaMiddleware();
function configureStoreProd() {
const middlewares = [
// Add other middleware on this line...
routerMw,
sagaMiddleware,
thunk
];
const store = createStore(rootReducer, persistedState, compose(
applyMiddleware(...middlewares)
)
);
store.subscribe(_.throttle(() => {
saveState({
auth: store.getState().auth
});
}, 1000));
sagaMiddleware.run(sagas);
store.close = () => store.dispatch(END);
return store;
}
function configureStoreDev() {
const middlewares = [
// Add other middleware on this line...
// Redux middleware that spits an error on you when you try to mutate your state either inside a dispatch or between dispatches.
reduxImmutableStateInvariant(),
routerMw,
sagaMiddleware,
loggerMiddleware,
thunk
];
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; // add support for Redux dev tools
const store = createStore(rootReducer, persistedState, composeEnhancers(
applyMiddleware(...middlewares)
)
);
store.subscribe(_.throttle(() => {
saveState({
auth: store.getState().auth
});
}, 1000));
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('../reducers', () => {
const nextReducer = require('../reducers').default; // eslint-disable-line global-require
store.replaceReducer(nextReducer);
});
}
sagaMiddleware.run(sagas);
store.close = () => store.dispatch(END);
return store;
}
const configureStore = process.env.NODE_ENV === 'production' ? configureStoreProd : configureStoreDev;
export default configureStore;
</code></pre>
<p>This way works nice without errors, but I'm new in react and I don't know if have problem with redux-saga and redux-thunk working together....</p>
<p>Someone can help me?</p>
| 0debug |
How to change screen on rotation : <p>I would like to change the View(to new xml with activity) when I rotate the screen on android studio. </p>
<p>Is there anyway I can do this?</p>
| 0debug |
What perl web framework to use for the old CGI based perl code? : <p>Yes, while i'm working on node.js, i still love perl, :)</p>
<p>The old web product is based on old perl CGI, i'm looking to the simplest way to fix XSS/Sql injection/etc. web security holes, within a week including testing, :(</p>
<p>So for
Catalyst
Dancer
Mason
Maypole
Mojolicious</p>
<p>which one should i use in the ARM platform ?
Thank you !</p>
| 0debug |
static void process_incoming_migration_bh(void *opaque)
{
Error *local_err = NULL;
MigrationIncomingState *mis = opaque;
bdrv_invalidate_cache_all(&local_err);
if (!local_err) {
blk_resume_after_migration(&local_err);
}
if (local_err) {
error_report_err(local_err);
local_err = NULL;
autostart = false;
}
qemu_announce_self();
if (!global_state_received() ||
global_state_get_runstate() == RUN_STATE_RUNNING) {
if (autostart) {
vm_start();
} else {
runstate_set(RUN_STATE_PAUSED);
}
} else {
runstate_set(global_state_get_runstate());
}
migrate_decompress_threads_join();
migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
MIGRATION_STATUS_COMPLETED);
qemu_bh_delete(mis->bh);
migration_incoming_state_destroy();
}
| 1threat |
How to set Azure SQL to rebuild indexes automatically? : <p>In on premise SQL databases, it is normal to have a maintenance plan for rebuilding the indexes once in a while, when it is not being used that much.</p>
<p>How can I set it up in Azure SQL DB?</p>
<p>P.S: I tried it before, but since I couldn't find any options for that, I thought maybe they are doing it automatically until I've read <a href="https://blogs.msdn.microsoft.com/dilkushp/2013/07/27/fragmentation-in-sql-azure/" rel="noreferrer">this post</a> and tried:</p>
<pre><code>SELECT
DB_NAME() AS DBName
,OBJECT_NAME(ps.object_id) AS TableName
,i.name AS IndexName
,ips.index_type_desc
,ips.avg_fragmentation_in_percent
FROM sys.dm_db_partition_stats ps
INNER JOIN sys.indexes i
ON ps.object_id = i.object_id
AND ps.index_id = i.index_id
CROSS APPLY sys.dm_db_index_physical_stats(DB_ID(), ps.object_id, ps.index_id, null, 'LIMITED') ips
ORDER BY ps.object_id, ps.index_id
</code></pre>
<p>And found out that I have indexes that need maintaining
<a href="https://i.stack.imgur.com/S2SIq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/S2SIq.png" alt="enter image description here"></a></p>
| 0debug |
Golang struct inheritance not working as intended? : <p>Check out <a href="https://play.golang.org/p/elIHgHAZjT" rel="noreferrer" title="this sandbox">this sandbox</a></p>
<p>When declaring a struct that inherits from a different struct:</p>
<pre><code>type Base struct {
a string
b string
}
type Something struct {
Base
c string
}
</code></pre>
<p>Then calling functions specifying values for the inherited values gives a compilation error:</p>
<pre><code>f(Something{
a: "letter a",
c: "letter c",
})
</code></pre>
<p>The error message is: <code>unknown Something field 'a' in struct literal</code>.</p>
<p>This seems highly weird to me. Is this really the intended functionality?</p>
<p>Thanks for the help!</p>
| 0debug |
What do unit tests not test? : <p>I was asked this in an interview, I have always read about what unit tests do, but what do they not do?</p>
<p><a href="https://stackoverflow.com/questions/67299/is-unit-testing-worth-the-effort">Is Unit Testing worth the effort?</a></p>
<p>Any insights? Thanks!</p>
| 0debug |
Python : save dictionaries through numpy.save : <p>I have a large data set (millions of rows) in memory, in the form of <strong>numpy arrays</strong> and <strong>dictionaries</strong>. </p>
<p>Once this data is constructed I want to store them into files;
so, later I can load these files into memory quickly, without reconstructing this data from the scratch once again.</p>
<p><strong>np.save</strong> and <strong>np.load</strong> functions does the job smoothly for numpy arrays.<br>
But I am facing problems with dict objects. </p>
<p>See below sample. d2 is the dictionary which was loaded from the file. <strong>See #out[28] it has been loaded into d2 as a numpy array, not as a dict.</strong> So further dict operations such as get are not working.</p>
<p>Is there a way to load the data from the file as dict (instead of numpy array) ?</p>
<pre><code>In [25]: d1={'key1':[5,10], 'key2':[50,100]}
In [26]: np.save("d1.npy", d1)
In [27]: d2=np.load("d1.npy")
In [28]: d2
Out[28]: array({'key2': [50, 100], 'key1': [5, 10]}, dtype=object)
In [30]: d1.get('key1') #original dict before saving into file
Out[30]: [5, 10]
In [31]: d2.get('key2') #dictionary loaded from the file
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-31-23e02e45bf22> in <module>()
----> 1 d2.get('key2')
AttributeError: 'numpy.ndarray' object has no attribute 'get'
</code></pre>
| 0debug |
static void xics_reset(void *opaque)
{
struct icp_state *icp = (struct icp_state *)opaque;
struct ics_state *ics = icp->ics;
int i;
for (i = 0; i < icp->nr_servers; i++) {
icp->ss[i].xirr = 0;
icp->ss[i].pending_priority = 0;
icp->ss[i].mfrr = 0xff;
qemu_set_irq(icp->ss[i].output, 0);
}
for (i = 0; i < ics->nr_irqs; i++) {
ics->irqs[i].server = 0;
ics->irqs[i].status = 0;
ics->irqs[i].priority = 0xff;
ics->irqs[i].saved_priority = 0xff;
}
}
| 1threat |
Please, help: Can't create xcarchive to ipa with xcode 9? : I am trying to convert my xcarchive to ipa. I tried using these advise with no success: https://stackoverflow.com/questions/14934808/how-to-convert-xcarchive-to-ipa-for-client-to-submit-app-to-app-store-using-ap
I am an absolute beginner to Mac and Apple Profiles and certificates.
All I know is:
I have iOS distribution certificate
I have Production Provision profile
I just hired a Mac in Cloud to convert it to ipa and upload to the appstore.
I am using this type of command:
xcodebuild
-exportArchive
-exportOptionsPlist {PATH_TO_PROJECT_ROOT}/ios/build/info.plist
-archivePath {PATH_TO_ARCHIVE_MADE_USING_XCODE}/MyApp.xcarchive
-exportPath {PATH_TO_EXPORT_THE_APP}/MyApp.ipa
with this info.plist code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>provisioningProfiles</key>
<dict>
<key>UUID</key>
<string>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</string>
</dict>
<key>signingCertificate</key>
<string>iPhone Distribution</string>
<key>signingStyle</key>
<string>manual</string>
<key>teamID</key>
<string>XXXXXXXX</string>
</dict>
</plist>
And I am getting an error: no matching certificate "iPhone Distribution: ..." for teamID: ....
What am I doing wrong?
What is the exact value I must input in "<key>signingCertificate</key>
<string>iPhone Distribution</string>" ?
Also, am I supposed to install any certificates or something like that on the Mac? I have never ever used Mac or Xcode before, I am just following the tips for generating ipa with command line code. | 0debug |
How to access :cause, :via and :trace keys of an exception in Clojure? : <p>I could not find a way to access <code>:cause, :via and :trace</code> keys of an exception.</p>
<p>Here is the code:</p>
<pre><code>(try
(throw (IllegalArgumentException. "1"))
(catch Exception e
e))
</code></pre>
<p>Output:</p>
<pre><code>#error{:cause "1",
:via [{:type java.lang.IllegalArgumentException, :message "1", :at [user$eval4073 invokeStatic "form-init5592296091748814678.clj" 1]}],
:trace [[user$eval4073 invokeStatic "form-init5592296091748814678.clj" 1]
[user$eval4073 invoke "form-init5592296091748814678.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 6927]
[clojure.lang.Compiler eval "Compiler.java" 6890]
[clojure.core$eval invokeStatic "core.clj" 3105]
[clojure.core$eval invoke "core.clj" 3101]
[clojure.main$repl$read_eval_print__7408$fn__7411 invoke "main.clj" 240]
....]}
</code></pre>
<p><em>P.S: (:via e) does not work.</em></p>
| 0debug |
VBA With SQl Quereis : I work in a FMCG company, I work in data department almost with reports
so i on daily basis have to refresh a SQL query to get the updated data of yesterday's sales and transactions on excel environment
So now i have an idea, Why do not i design a report that can be automatically updated from sql ?
I mean what i do now is that i run the SQL query to get data and then from this row data i get useful info. by inserting data into pivot tables then linking my reports to this data via Vlookup for example
So is there a VBA Code that i can put in the report workbook that goes to the sql server or even the sql file and run the query then refreshs pivots and updates finally my report data,all this also i need it to be done on the background ?!
Example:
Now i have an excel workbook report wich is a table..that table is linked to another excel workbook by Vlookup which is the SQL query powerpivot
now i need code that can autorefresh the sql query pivot automatically in the background once i open the report's workbook and then gets the updated data into the the report table and refresh any pivot in the same report workbook
can anyone help?
Thanks
Regards
A.Sabry
| 0debug |
Bitset membership function : <p>I'm writing a bitset membership predicate which should handle all values of x:</p>
<pre><code>int Contains(unsigned int A, int x)
{
return (x >= 0) && (x < 8 * sizeof A) && (((1u << x) & A) != 0);
}
</code></pre>
<p>Is there a more efficient implementation?</p>
| 0debug |
static void raw_aio_flush_io_queue(BlockDriverState *bs)
{
#ifdef CONFIG_LINUX_AIO
BDRVRawState *s = bs->opaque;
if (s->use_aio) {
laio_io_unplug(bs, s->aio_ctx, false);
}
#endif
}
| 1threat |
How to get the local ip address using php? : <p>I 'm creating a web app in which i need to save the sessions in the database including the Ip address of the user and the date and time of the session , for that i want to know how to do that ,knowing that the app will be used in LAN .
i 'm using codeIgniter framework.</p>
| 0debug |
Using MS SQL how to use select criteria based on sum : Given the below table and using SQL (sql-server preferred), how can I do a select so that only the ProductID's that sum to the first 200 orders or less is returned. In other works, I'd like ID's for 'Corn Flakes', 'Wheeties' returned since this is close to the sum of 200 orders but returning anything more would be over the limit.
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/x88aZ.png | 0debug |
void op_dmfc0_ebase (void)
{
T0 = env->CP0_EBase;
RETURN();
}
| 1threat |
CondaValueError: The target prefix is the base prefix. Aborting : <p>I have the following conda environment file <code>environment.yml</code>:</p>
<pre><code>name: testproject
channels:
- defaults
dependencies:
- python=3.7
prefix: /opt/projects/testproject
</code></pre>
<p>Before creating the environment, only the base environment exists:</p>
<pre><code>(base) me@mymachine:/opt/projects/testproject$ conda env list
# conda environments:
#
base * /opt/anaconda/anaconda3
</code></pre>
<p>When trying to create the environment, I get the following error:</p>
<pre><code>(base) me@mymachine:/opt/projects/testproject$ conda create -f environment.yml
CondaValueError: The target prefix is the base prefix. Aborting.
</code></pre>
<p>What does this error mean?</p>
| 0debug |
i am android studio beginner...see this guys please clear that : In android studio...,
I have two java files
First one is extends AppCompactActivity
And second one extends SQLiteDataBaseHelper
So this is the question..,
Can i access an EditText variable from first one to second one | 0debug |
Check any new Latitude and Longitude is within 100 meter range or not? from my current location : <p>I have data set with shops Latitude and Longitude, how do i find shops in 100 meter range from my current location(latitude,longitude)?</p>
| 0debug |
PostgreSQL Why where does not work with age function : I use age function in where but i don't know why it dose not work
```
select t1.id,date_part('year',age(t1.tdate,t2.birthday)) as age
FROM table t1
LEFT JOIN table2 t2 ON t1.id = t1.id
WHERE date_part('year',age(t1.tdate,t2.birthday)) >= 10
```
the result is incorrect
-----------------
![the result][1]
[1]: https://i.imgur.com/WeRPAqa.jpg "result"
<br/>
the result should be <br/>
-----------------
![the result][2]
[2]: https://i.imgur.com/pPvzcvA.jpg "result" | 0debug |
Insert record into two Sql table : [This is First table of database and it is in relation with second table ][1]
[This is the Second Table][2]
[1]: http://i.stack.imgur.com/yqQHq.png
[2]: http://i.stack.imgur.com/gG59m.png
but i want to do that when user get logged in he/she will give answers of question and that answer are also added to database but in second table but with first table of user id. Because of each user has to give this answers and answers were saved for each user. | 0debug |
Deprecation: Doctrine\ORM\Mapping\UnderscoreNamingStrategy without making it number aware is deprecated : <p>I'm using Symfony 4.3.8 and I can't find any information about thoses deprecations :</p>
<blockquote>
<p>User Deprecated: Creating Doctrine\ORM\Mapping\UnderscoreNamingStrategy without making it number aware is deprecated and will be removed in Doctrine ORM 3.0.</p>
<p>Creating Doctrine\ORM\Mapping\UnderscoreNamingStrategy without making it number aware is deprecated and will be removed in Doctrine ORM 3.0.</p>
</blockquote>
<p>I searched in stacktrace and found this :</p>
<pre><code>class UnderscoreNamingStrategy implements NamingStrategy
{
private const DEFAULT_PATTERN = '/(?<=[a-z])([A-Z])/';
private const NUMBER_AWARE_PATTERN = '/(?<=[a-z0-9])([A-Z])/';
/**
* Underscore naming strategy construct.
*
* @param int $case CASE_LOWER | CASE_UPPER
*/
public function __construct($case = CASE_LOWER, bool $numberAware = false)
{
if (! $numberAware) {
@trigger_error(
'Creating ' . self::class . ' without making it number aware is deprecated and will be removed in Doctrine ORM 3.0.',
E_USER_DEPRECATED
);
}
$this->case = $case;
$this->pattern = $numberAware ? self::NUMBER_AWARE_PATTERN : self::DEFAULT_PATTERN;
}
</code></pre>
<p>In this class, the constructor is always called without params, so $numberAware is always false.</p>
<p>This class is called in file which has been auto generated by the Symfony Dependency Injection, so I can't "edit" it ...</p>
<p>I thought maybe it was in doctrine.yaml :</p>
<pre><code>doctrine:
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
</code></pre>
<p>But I have not found any option to allow the number aware :(</p>
| 0debug |
Formatting LocalDate in Java : <p>I defined the following format in Java :</p>
<pre><code>//define format of YYYYMMDD
private final DateTimeFormatter dtf = DateTimeFormatter.BASIC_ISO_DATE;
</code></pre>
<p>My application fetches a certain date from the calendar:</p>
<pre><code>LocalDate localDate = fetchDate(); // fetch date in format "yyyy-mm-dd"
</code></pre>
<p>I want to store an additional two dates in format of <code>dtf</code>. The <code>startOfMonth</code> and <code>endOfMonth</code> of the given <code>localDate</code>.</p>
<p>E.g. if <code>localDate</code> is <code>"2019-12-12"</code> I want to create the following two variables - </p>
<pre><code>String startOfMonth = "20191201";
String endOfMonth = "20191231";
</code></pre>
<p>How can I do that?</p>
| 0debug |
Showing step by step solving of sudoku : <p>Is there any way to show the steps of solving a sudoku? My code just solve it within 0.5 second and I wish to modify it to show the changes on the sudoku grid step by step on processing. (I am using python)</p>
| 0debug |
save switch state even if the app gets restarted : I am trying to save the switch statement in objective-c but it will go back to the default state (which is off) whenever I reopen the app or go to another page and come back to the page that has switch
@property (strong, nonatomic) IBOutlet UISwitch *switch1;
@property (strong, nonatomic) IBOutlet UISwitch *switch2;
@property (strong, nonatomic) IBOutlet UISwitch *switch3;
I have 3 switches and I have 3 IBOutlets for them. I have tried some codes to save the state but it did not work. How can I get them to work?
| 0debug |
How to use regexp to extract the digit within { customer:490 } bought a car { car:6441 } : <p>I have a json object with value in this pattern:
{ customer:1501 } bought a car { car:6333 }
How to use regexp to extract the digit of customer and car.
I am very new to regex, I can only extract the string between the curly braces. I am not sure should I do it separately, i.e. extract the string between the curly braces than extract the digits after "customer:" or "car:". Please help</p>
| 0debug |
onmouseover not working with React.js : <p>The click event works fine, but the onmouseover event does not work. </p>
<pre><code>ProfImage = React.createClass({
getInitialState: function() {
return { showIcons: false };
},
onClick: function() {
if(this.state.showIcons == true) {
this.setState({ showIcons: false });
}
else {
this.setState({ showIcons: true });
}
},
onHover: function() {
this.setState({ showIcons: true });
},
render: function() {
return (
<div>
<span className="major">
<img src="/images/profile-pic.png" height="100" onClick={this.onClick} onmouseover={this.onHover} />
</span>
{ this.state.showIcons ? <SocialIcons /> : null }
</div>
);
}
});
</code></pre>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.