problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
get the FragmentManager from within a Fragment (support.v4) : <p>Be aware, I am using the <code>android.support.v4.app.FragmentManager</code>. I have searched all over the internet, I have found many similar questions, but they are all referring to <code>android.app.FragmentManager</code> and none of the solutions work with support.v4 FragmentManager.</p>
<pre><code>import android.support.v4.app.FragmentManager;
</code></pre>
<p>I am using Fragments instead of Activities for navigation purposes. Inside my MainActivity I have a NavigationDrawer which is used to select a Fragment to be displayed using the following method:</p>
<pre><code>public boolean onNavigationSelected(MenuItem item) {
FragmentManager fragManager = getSupportFragmentManager();
if(item.getItemId() == R.id.fragment_one) {
fragManager.beginTransaction().replace(R.id.content, new FragmentOne()).commit()
}
if(item.getItemId() == R.id.fragment_two) {
fragManager.beginTransaction().replace(R.id.content, new FragmentTwo()).commit()
}
}
</code></pre>
<p>This works fine when a user navigates using the NavigationDrawer, but there are Buttons inside the Fragment which are used for navigation too, however the <code>getSupportFragmentManager()</code> method cannot be called from within a Fragment.</p>
<p>FragmentOne:</p>
<pre><code>public class FragmentOne extends Fragment {
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for the Fragment
fragment = inflater.inflate(R.layout.fragment_one_layout, container, false);
// Do some stuff to the fragment before returning it
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// This does not work
------------> FragmentManager fragManager = getSupportFragmentManager();
fragManager.beginTransaction().replace(R.id.content, new FragmentTwo()).commit();
}
});
return fragment;
}
}
</code></pre>
| 0debug |
static inline I2CBus *aux_bridge_get_i2c_bus(AUXTOI2CState *bridge)
{
return bridge->i2c_bus;
}
| 1threat |
static void omap_mcbsp_source_tick(void *opaque)
{
struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
static const int bps[8] = { 0, 1, 1, 2, 2, 2, -255, -255 };
if (!s->rx_rate)
return;
if (s->rx_req)
printf("%s: Rx FIFO overrun\n", __FUNCTION__);
s->rx_req = s->rx_rate << bps[(s->rcr[0] >> 5) & 7];
omap_mcbsp_rx_newdata(s);
timer_mod(s->source_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
NANOSECONDS_PER_SECOND);
}
| 1threat |
C# Script unable to find namespace in new IIS setup : So we have some scripts that utilize an API that is developed in-house by our parent company. Basically, we have utilized their API to create some ASP.NET code to retrieve check images, deposit images, statements, etc. through the customer's internet banking interface.
We recently started working with a brand new IIS on a new server.
The script we are trying to call is called Checks.aspx.cs.
The script it is trying to reference is called UnityC.cs.
The first file is located at C:\inetpub\wwwroot\TestIB\Checks.aspx.cs.
The second file is located at C:\inetpub\wwwroot\TestIB\App_Code\UnityC.cs
Basically, the Checks.aspx.cs script parses out the GET call and feeds the variables into the UnityC.cs script, where the check image is returned to the user in a browser.
At this site, I keep getting the following error:
"Error CS0246: The type or namespace name 'InternetBankingUnity' could not be found (are you missing a using directive or an assembly reference?)"
This is setup the same at this site as it is at our other sites, so I am very confused. The line that throws the error in the Checks.aspx.cs script is as follows:
InternetBankingUnity.OBUnityC OB_Unity = new InternetBankingUnity.OBUnityC();
Here is a little bit of code from the top of the Checks.aspx.cs file. I have tried doing using InternetBankingUnity to no avail. If I include the using statement, the error is on that line instead of the line mentioned above.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Text;
using InternetBankingUnity;
public partial class _default : System.Web.UI.Page
{
A little exerpt from the UnityC.cs file showing the using statements, namespace, and class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Hyland.Types;
using Hyland.Unity;
using System.IO;
using System.Configuration;
using System.Collections;
using System.Drawing;
namespace InternetBankingUnity
{
public class OBUnityC
{
I am at a loss as to why these scripts would be working fine at one site and be giving me compilation errors at another. We did just copy the scripts over from our TestIB setup to their site's TestIB setup...is there something I am missing here?
Thanks in advance for your advice. | 0debug |
Docker show current registry : <p>In docker, how can one display the current registry info you are currently logged in? I installed docker, if I now do docker push, where does it send my images?</p>
<p>I spend over 30min searching this info from Google and docker docs, and couldn't find it, so I think it deserves its own question.</p>
| 0debug |
Simplify the codes for some repeated actions by creating loops : <p>Here below are my codes performing data resetting for a series of ports of integer type. </p>
<pre><code> //note function: void resetData(int pin);
resetData(p00);
resetData(p01);
resetData(p02);
resetData(p03);
resetData(p04);
resetData(p05);
resetData(p06);
resetData(p07);
resetData(p10);
resetData(p11);
resetData(p12);
resetData(p13);
resetData(p14);
resetData(p15);
resetData(p16);
resetData(p17);
resetData(p50);
resetData(p51);
resetData(p80);
resetData(p81);
resetData(p82);
resetData(p83);
resetData(p84);
resetData(p85);
resetData(p86);
resetData(p87);
resetData(p110);
resetData(p111);
resetData(p112);
resetData(p113);
resetData(p114);
resetData(p115);
resetData(p116);
resetData(p117);
</code></pre>
<p>In the above codes, there are different types of ports (as grouped together), and they are processed by <code>resetData</code>. Is there way to simplify these long list of code by creating some loops, without changing the definition of <code>resetData</code>? Thanks!</p>
| 0debug |
def increasing_trend(nums):
if (sorted(nums)== nums):
return True
else:
return False | 0debug |
Loop until variable is isset then excute a code : <p>I try to do a while loop but something is missing I need to loop until variable is isset then execute a code something like dis :</p>
<pre><code>$counter=o;
while(null!==($var)){
$counter ++;
}
if (isset($var)){
excute code ....
}
</code></pre>
| 0debug |
static struct iovec *lock_iovec(int type, abi_ulong target_addr,
int count, int copy)
{
struct target_iovec *target_vec;
struct iovec *vec;
abi_ulong total_len, max_len;
int i;
int err = 0;
if (count == 0) {
errno = 0;
return NULL;
}
if (count < 0 || count > IOV_MAX) {
errno = EINVAL;
return NULL;
}
vec = calloc(count, sizeof(struct iovec));
if (vec == NULL) {
errno = ENOMEM;
return NULL;
}
target_vec = lock_user(VERIFY_READ, target_addr,
count * sizeof(struct target_iovec), 1);
if (target_vec == NULL) {
err = EFAULT;
goto fail2;
}
max_len = 0x7fffffff & TARGET_PAGE_MASK;
total_len = 0;
for (i = 0; i < count; i++) {
abi_ulong base = tswapal(target_vec[i].iov_base);
abi_long len = tswapal(target_vec[i].iov_len);
if (len < 0) {
err = EINVAL;
goto fail;
} else if (len == 0) {
vec[i].iov_base = 0;
} else {
vec[i].iov_base = lock_user(type, base, len, copy);
if (!vec[i].iov_base) {
err = EFAULT;
goto fail;
}
if (len > max_len - total_len) {
len = max_len - total_len;
}
}
vec[i].iov_len = len;
total_len += len;
}
unlock_user(target_vec, target_addr, 0);
return vec;
fail:
unlock_user(target_vec, target_addr, 0);
fail2:
free(vec);
errno = err;
return NULL;
}
| 1threat |
SQL Connection without log steal : <p>I'm making a game with a login system which connect to a database, but my source code is not crypted and I worried about if someone decompile my program, he can get the SQL logins and wanted to know how prevent from that?</p>
| 0debug |
How to add a Webview in Flutter? : <p>I know its possible to add a WebView as a full page but couldn't find any sample code to do it. I assume you could use a PageView as it's base but not sure how to call the native android WebView and add it to the PageView.</p>
<p>Can anyone point me in the right direction?</p>
| 0debug |
static int prepare_input_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret;
ret = check_packet(s, pkt);
if (ret < 0)
return ret;
#if !FF_API_COMPUTE_PKT_FIELDS2
if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {
AVStream *st = s->streams[pkt->stream_index];
if (!st->internal->reorder) {
if (pkt->pts == AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE)
pkt->pts = pkt->dts;
if (pkt->dts == AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE)
pkt->dts = pkt->pts;
}
if (pkt->pts == AV_NOPTS_VALUE || pkt->dts == AV_NOPTS_VALUE) {
av_log(s, AV_LOG_ERROR,
"Timestamps are unset in a packet for stream %d\n", st->index);
return AVERROR(EINVAL);
}
if (st->cur_dts != AV_NOPTS_VALUE &&
((!(s->oformat->flags & AVFMT_TS_NONSTRICT) && st->cur_dts >= pkt->dts) ||
st->cur_dts > pkt->dts)) {
av_log(s, AV_LOG_ERROR,
"Application provided invalid, non monotonically increasing "
"dts to muxer in stream %d: %" PRId64 " >= %" PRId64 "\n",
st->index, st->cur_dts, pkt->dts);
return AVERROR(EINVAL);
}
if (pkt->pts < pkt->dts) {
av_log(s, AV_LOG_ERROR, "pts %" PRId64 " < dts %" PRId64 " in stream %d\n",
pkt->pts, pkt->dts, st->index);
return AVERROR(EINVAL);
}
}
#endif
return 0;
}
| 1threat |
static void setup_frame(int sig, struct target_sigaction *ka,
target_sigset_t *set, CPUM68KState *env)
{
struct target_sigframe *frame;
abi_ulong frame_addr;
abi_ulong retcode_addr;
abi_ulong sc_addr;
int err = 0;
int i;
frame_addr = get_sigframe(ka, env, sizeof *frame);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
__put_user(sig, &frame->sig);
sc_addr = frame_addr + offsetof(struct target_sigframe, sc);
__put_user(sc_addr, &frame->psc);
setup_sigcontext(&frame->sc, env, set->sig[0]);
for(i = 1; i < TARGET_NSIG_WORDS; i++) {
if (__put_user(set->sig[i], &frame->extramask[i - 1]))
goto give_sigsegv;
}
retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode);
__put_user(retcode_addr, &frame->pretcode);
__put_user(0x70004e40 + (TARGET_NR_sigreturn << 16),
(long *)(frame->retcode));
if (err)
goto give_sigsegv;
env->aregs[7] = frame_addr;
env->pc = ka->_sa_handler;
unlock_user_struct(frame, frame_addr, 1);
return;
give_sigsegv:
unlock_user_struct(frame, frame_addr, 1);
force_sig(TARGET_SIGSEGV);
}
| 1threat |
Join columns of the same data.frame in rstudio : How to join 2 columns in rstudio from a single data.frame
For example:
Column A : a,b,c,d,e
Column B : b,c,a,b,e
The column i want
New Column : a,b,c,d,e,b,c,a,b,e
Basically i want to get all data under both columns into a single column using rstudio | 0debug |
Error when i execute my program . (C++) : I had some problems with my c++ program on my raspberry when i execute the program. The Program consist to take data from the arduino from the captor.
Thus I think that the problem cannot come from the arduino because the program of the arduino worked with a program python but for certain reasons I need to use C ++ I shall like to know how to solve my problem I am a little bit pressed for time because it is a university project.
so this is my program :
#include "SerialPort.h" //My library
SerialPort::SerialPort() //Constructor
{
this->numCon = open("/dev/ttyACM0", O_RDWR| O_NOCTTY ); //ttyACM0 arduino port
this->connected = false;
struct termios tty;
struct termios tty_old;
memset (&tty, 0, sizeof tty);
/* Error Handling */
if ( tcgetattr ( this->numCon, &tty ) != 0 ) {
std::cout << "Error " << errno << " from tcgetattr: " << strerror(errno) << std::endl;
return;
}
/* Save old tty parameters */
tty_old = tty;
/* Set Baud Rate */
cfsetospeed (&tty, (speed_t)B9600);
cfsetispeed (&tty, (speed_t)B9600);
/* Setting other Port Stuff */
tty.c_cflag &= ~PARENB; // Make 8n1
tty.c_cflag &= ~CSTOPB;
tty.c_cflag &= ~CSIZE;
tty.c_cflag |= CS8;
tty.c_cflag &= ~CRTSCTS; // no flow control
tty.c_cc[VMIN] = 1; // read doesn't block
tty.c_cc[VTIME] = 5; // 0.5 seconds read timeout
tty.c_cflag |= CREAD | CLOCAL; // turn on READ & ignore ctrl lines
/* Make raw */
cfmakeraw(&tty);
/* Flush Port, then applies attributes */
tcflush(this->numCon, TCIFLUSH );
if ( tcsetattr (this->numCon, TCSANOW, &tty ) != 0) {
std::cout << "Error " << errno << " from tcsetattr" << std::endl;
return;
}
this->connected = true;
}
SerialPort::~SerialPort() //Destructor
> the program consist to take and send data on Serial port(Arduino) with a constructor.
{
if (this->connected) {
this->connected = false;
}
}
char* SerialPort::readSerialPort()
{
int n = 0, spot = 0;
char buf = '\0';
/* Whole response*/
char response[1024];
memset(response, '\0', sizeof response);
do {
n = read(this->numCon, &buf, 1 );
sprintf( &response[spot], "%c", buf );
spot += n;
} while( buf != '\r' && n > 0);
if (n < 0) {
std::cout << "Error reading: " << strerror(errno) << std::endl;
}
else if (n == 0) {
std::cout << "Read nothing!" << std::endl;
}
else {
std::cout << "Response: " << response << std::endl;
}
return response;
}
void SerialPort::writeSerialPort(unsigned char cmd[])
{
int n_written = 0, spot = 0;
do {
n_written = write(this->numCon, &cmd[spot], 1 );
spot += n_written;
} while (cmd[spot-1] != '\r' && n_written > 0);
}
bool SerialPort::isConnected()
{
return this->connected;
}
And this is the library(SerialPort.h) :
#ifndef SERIALPORT_H
#define SERIALPORT_H
#include <stdio.h> // standard input / output functions
#include <stdlib.h>
#include <string.h> // string function definitions
#include <unistd.h> // UNIX standard function definitions
#include <fcntl.h> // File control definitions
#include <errno.h> // Error number definitions
#include <termios.h> // POSIX terminal control definitions
#include <iostream>
class SerialPort
{
private:
int numCon;
bool connected;
public:
SerialPort();
~SerialPort();
char* readSerialPort();
void writeSerialPort(unsigned char cmd[]);
bool isConnected();
};
#endif // SERIALPORT_H
thanks for taking time to read my post. | 0debug |
php session not working when redirecting in another page : <p>session is not working in my code. i have a login form, and when a user is on db the the page redirects him in main.php but it's not working</p>
<pre><code>//index.php
<?php
session_start();
include('connect.php');
if(isset($_POST['submit'])){
$username = mysqli_real_escape_string($dbCon, $_POST['username']);
$password = mysqli_real_escape_string($dbCon, $_POST['password']);
$sql = "select username, password from users where username='$username'";
$res = mysqli_query($dbCon, $sql);
if(!$res){
die(mysqli_errno);
}
while ($row = mysqli_fetch_assoc($res)){
$usr = $row['username'];
$pass = $row['password'];
}
if($username == $usr && $password == $pass){
$_SESSION["username"] = $username;
header("Location: main.php");
exit();
} else {
$error = "Invalid username or password";
}
}
?>
</code></pre>
<p>and here is my main.php</p>
<pre><code>//main.php
<?php
if(isset($_SESSION["username"])) {
$username = $_SESSION["username"];
} else {
header('Location: index.php');
die();
}
?>
</code></pre>
<p>thanks</p>
| 0debug |
int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,
const char *name, v9fs_synth_read read,
v9fs_synth_write write, void *arg)
{
int ret;
V9fsSynthNode *node, *tmp;
if (!v9fs_synth_fs) {
return EAGAIN;
}
if (!name || (strlen(name) >= NAME_MAX)) {
return EINVAL;
}
if (!parent) {
parent = &v9fs_synth_root;
}
qemu_mutex_lock(&v9fs_synth_mutex);
QLIST_FOREACH(tmp, &parent->child, sibling) {
if (!strcmp(tmp->name, name)) {
ret = EEXIST;
goto err_out;
}
}
mode = ((mode & 0777) | S_IFREG);
node = g_malloc0(sizeof(V9fsSynthNode));
node->attr = &node->actual_attr;
node->attr->inode = v9fs_synth_node_count++;
node->attr->nlink = 1;
node->attr->read = read;
node->attr->write = write;
node->attr->mode = mode;
node->private = arg;
strncpy(node->name, name, sizeof(node->name));
QLIST_INSERT_HEAD_RCU(&parent->child, node, sibling);
ret = 0;
err_out:
qemu_mutex_unlock(&v9fs_synth_mutex);
return ret;
}
| 1threat |
static void rv40_v_weak_loop_filter(uint8_t *src, const int stride,
const int filter_p1, const int filter_q1,
const int alpha, const int beta,
const int lim_p0q0, const int lim_q1,
const int lim_p1)
{
rv40_weak_loop_filter(src, 1, stride, filter_p1, filter_q1,
alpha, beta, lim_p0q0, lim_q1, lim_p1);
}
| 1threat |
What is `scanf` supposed to do with incomplete exponent-part? : <p>Take for example <code>rc = scanf("%f", &flt);</code> with the input <code>42ex</code>. An implementation of <code>scanf</code> would read <code>42e</code> thinking it would encounter a digit or sign after that and realize first when reading <code>x</code> that it didn't get that. Should it at this point push back both <code>x</code> and <code>e</code>? Or should it only push back the <code>x</code>.</p>
<p>The reason I ask is that GNU's libc will on a subsequent call to <code>gets</code> return <code>ex</code> indicating they've pushed back both <code>x</code> and <code>e</code>, but the standard says:</p>
<blockquote>
<p>An input item is read from the stream, unless the specification includes an n specifier. An input item is defined as the longest sequence of input characters which does not exceed any specified field width and which is, or is a prefix of, a matching input sequence[245] The first character, if any, after the input item remains unread. If the length of the input item is zero, the execution of the directive fails; this condition is a matching failure unless end-of-file, an encoding error, or a read error prevented input from the stream, in which case it is an input failure. </p>
</blockquote>
<p>I interpret this as since <code>42e</code> is a prefix of a matching input sequence (since for example <code>42e1</code> would be a matching input sequence), which should mean that it would consider <code>42e</code> as a input item that should be read leaving only <code>x</code> unread. That would also be more convenient to implement if the stream only supports single character push back.</p>
| 0debug |
Unable to install pip 3.0.2 : I have python3.7.2 on my computer.
This is where it is in my computer --> C:\Program Files\Python37
I have tried to open up cmd on my computer and tried to type in "cd Python37" but it doesnt find the python. If it opened up the next step for me would be to type in: pip install matplotlib==3.0.2
Please help, WHAT should I type in cmd in order to find the python from my computer and to finally install | 0debug |
printing a file in c : I am trying to print a file in my program but I am not sure where I am going wrong.
I could be using fscanf incorrectly which is very possible. T
I need to print the unsolved puzzle to see if I'm getting the file into my code correctly but like a said Im not sure if I'm even useing fscanf right.(the puzzle file is in my clion file to I know that not the problem.)
Here is what I have for my reading part of the program.
int read(const char *name, int **problem, int **z, int
*size) {
int n;
int *p;
int *c;
FILE* input;
input= fopen("name","r");
fscanf(input,"%d",&n);
*size=n;
p=(int *)malloc(n*n*sizeof(int)); /* nxn grid has n*n elements*/
c= (int*)malloc (n*n*sizeof(int));
*problem=p;
*z=c;
input=fopen(name,"r");
fprintf(input,"%d\n",n);
fclose(input);
return 0 ;
}
All I need to know is where I have gone wrong or if my problem isn't with this. | 0debug |
static void qemu_chr_parse_serial(QemuOpts *opts, ChardevBackend *backend,
Error **errp)
{
const char *device = qemu_opt_get(opts, "path");
if (device == NULL) {
error_setg(errp, "chardev: serial/tty: no device path given");
return;
}
backend->serial = g_new0(ChardevHostdev, 1);
backend->serial->device = g_strdup(device);
}
| 1threat |
When I try to run a java class in IntelliJ,nothing comes out even though it has been successfully compiled and run. : [enter image description here][1]
Did I mess up with the JV machine?
[1]: http://i.stack.imgur.com/GEXNF.png | 0debug |
Merge two JSON object based on common value in javascript? : I have the following situation with two object that I have to merge based on value1 and i know the property is key1= namekey1 :
obja = [{ key1: value1; a : 1 ; b : 2}]
objb = [ {namekey1: value1; d : 3 ; c : 4}]
Desired result
objc = [ key1: value1; a : 1 ; b : 2 ;d : 3 ; c : 4]
Is there a way I can do this?
Thanks | 0debug |
static void caps_to_network(RDMACapabilities *cap)
{
cap->version = htonl(cap->version);
cap->flags = htonl(cap->flags);
}
| 1threat |
google map not displaying clearly in android studio : 1.My app in android studio does not load the locations(map) clearly, it viewed parts of the world but shows the blue only
2. I can't view the textviews and buttons I dragged in the layout design view.
Please Help :)
[![My app in android studio does not load the locations(map) clearly, it viewed parts of the world but shows this, as well as the in the layout file, I can't view the textviews [![as well as the in the layout file, I can't view the textviews][1]][1] ][2]][2]
[1]: https://i.stack.imgur.com/AJZs1.png
[2]: https://i.stack.imgur.com/YSXzq.png | 0debug |
Why this is so(please refer to the entire question in description)? : P.S-I am a beginner in programming so my style of asking question may be a
little inappropriate, but please read through my problem and please provide
some help.
I have created an arrayList in android studio.
//creating an arrayList of string type named words
ArrayList<String> words = new ArrayList<String>();
words.add("one");
words.add("two");
words.add("three");
words.add("four");
words.add("five");
words.add("six");
words.add("seven");
words.add("eight");
words.add("nine");
words.add("ten");
Now the elements of this arrayList are to be displayed in TextView.
I have declared a Linear Layout named rootView-
LinearLayout rootView = (LinearLayout) findViewById(R.id.rootView);
This is the code to display the first element of the Arraylist in the textview -
TextView wordView = new TextView(this);
wordView.setText(words.get(i));
rootView.addView(wordView);
Now my question is to display all the elements of this ArrayList, we will create individual "textviews", (with all textviews with a different name).
If the name of any declared Textview matches with any another textview then error occurs.
But when we use loops to display the elements of this arraylist then we write something like this -
for (int i = 0;i<words.size();i++){
TextView wordView = new TextView(this);
wordView.setText(words.get(i));
rootView.addView(wordView);
}
This gives no error. So inside loops we have declared a single TextView named "wordView". Everytime the loop runs, a new Textview with same name wordView is created,then WHY IT DID'NT SHOWING ANY ERRORS??
and whenever we manually create textviews then there is a error whenever the name matches. WHy this is so??
Please Help!!
| 0debug |
functions calling functions python : def one_good_turn(n):
return n + 1
def deserves_another(n):
return n + 2
I don´t quite understand when it is asked me change the body of deserves_another, so that it always adds 2 to the output of one_good_turn? | 0debug |
static int mxf_read_material_package(MXFPackage *package, ByteIOContext *pb, int tag)
{
switch(tag) {
case 0x4403:
package->tracks_count = get_be32(pb);
if (package->tracks_count >= UINT_MAX / sizeof(UID))
return -1;
package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));
if (!package->tracks_refs)
return -1;
url_fskip(pb, 4);
get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
break;
}
return 0;
}
| 1threat |
in C++ what does the not operator '~' do when it is beside a method? and Pure virtual method : Example Code Below,
#include <string>
namespace vehicle
{
class Vehicle
{
public:
Vehicle(int a);
virtual ~Vehicle(); <------ not method?
protected:
int a;
};
}
Also, I don't fully get the concept of the 'Pure Virtual Method' where you declare a method as
virtual method() = 0;
Why do we need this?
Thanks alot,
| 0debug |
int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx)
{
MpegEncContext *s = &ctx->m;
int mb_num_bits = av_log2(s->mb_num - 1) + 1;
int header_extension = 0, mb_num, len;
if (get_bits_count(&s->gb) > s->gb.size_in_bits - 20)
return -1;
for (len = 0; len < 32; len++)
if (get_bits1(&s->gb))
break;
if (len != ff_mpeg4_get_video_packet_prefix_length(s)) {
av_log(s->avctx, AV_LOG_ERROR, "marker does not match f_code\n");
return -1;
}
if (ctx->shape != RECT_SHAPE) {
header_extension = get_bits1(&s->gb);
}
mb_num = get_bits(&s->gb, mb_num_bits);
if (mb_num >= s->mb_num) {
av_log(s->avctx, AV_LOG_ERROR,
"illegal mb_num in video packet (%d %d) \n", mb_num, s->mb_num);
return -1;
}
s->mb_x = mb_num % s->mb_width;
s->mb_y = mb_num / s->mb_width;
if (ctx->shape != BIN_ONLY_SHAPE) {
int qscale = get_bits(&s->gb, s->quant_precision);
if (qscale)
s->chroma_qscale = s->qscale = qscale;
}
if (ctx->shape == RECT_SHAPE)
header_extension = get_bits1(&s->gb);
if (header_extension) {
int time_incr = 0;
while (get_bits1(&s->gb) != 0)
time_incr++;
check_marker(s->avctx, &s->gb, "before time_increment in video packed header");
skip_bits(&s->gb, ctx->time_increment_bits);
check_marker(s->avctx, &s->gb, "before vop_coding_type in video packed header");
skip_bits(&s->gb, 2);
if (ctx->shape != BIN_ONLY_SHAPE) {
skip_bits(&s->gb, 3);
if (s->pict_type == AV_PICTURE_TYPE_S &&
ctx->vol_sprite_usage == GMC_SPRITE) {
if (mpeg4_decode_sprite_trajectory(ctx, &s->gb) < 0)
return AVERROR_INVALIDDATA;
av_log(s->avctx, AV_LOG_ERROR, "untested\n");
}
if (s->pict_type != AV_PICTURE_TYPE_I) {
int f_code = get_bits(&s->gb, 3);
if (f_code == 0)
av_log(s->avctx, AV_LOG_ERROR,
"Error, video packet header damaged (f_code=0)\n");
}
if (s->pict_type == AV_PICTURE_TYPE_B) {
int b_code = get_bits(&s->gb, 3);
if (b_code == 0)
av_log(s->avctx, AV_LOG_ERROR,
"Error, video packet header damaged (b_code=0)\n");
}
}
}
if (ctx->new_pred)
decode_new_pred(ctx, &s->gb);
return 0;
}
| 1threat |
Defaulting to last part of else if statement in java : <p>I am writhing a code to find the distance between 2 places where the user inputs different cities. i need to get the longitude and latitude of the two places, so i tried writing the code like this, but for some reason that i do not know, it always uses the coordinantes for orlando no matter what. Could anyone please help me?</p>
<p>(The latitudeStringOfQ is what the user entered)</p>
<pre><code>if (latitudeStringOfQ.equals(city1))
{
latitudeOfQ = latitudeOfBarrow;
longitudeOfQ = longitudeOfBarrow;
}
else if (latitudeStringOfQ.equals(city2))
{
latitudeOfQ = latitudeOfBrisbane;
longitudeOfQ = longitudeOfBrisbane;
}
else if (latitudeStringOfQ.equals(city3))
{
latitudeOfQ = latitudeOfDuluth;
longitudeOfQ = longitudeOfDuluth;
}
else if (latitudeStringOfQ.equals(city4))
{
latitudeOfQ = latitudeOfLondon;
longitudeOfQ = longitudeOfLondon;
}
else if(latitudeStringOfQ.equals(city5));
{
latitudeOfQ = latitudeOfOrlando;
longitudeOfQ = longitudeOfOrlando;
}
System.out.print(latitudeOfQ);
System.out.print(longitudeQ);
</code></pre>
| 0debug |
static void vfio_disable_interrupts(VFIOPCIDevice *vdev)
{
switch (vdev->interrupt) {
case VFIO_INT_INTx:
vfio_disable_intx(vdev);
break;
case VFIO_INT_MSI:
vfio_disable_msi(vdev);
break;
case VFIO_INT_MSIX:
vfio_disable_msix(vdev);
break;
}
}
| 1threat |
Need help starting a Parsing Code Generator for C++ : <p>So I'm working through my CS degree and currently taking a Programming Language concept class. The first assignment is to create a program that generates a random syntactically correct but does not have to be semantically correct. This assignment came after going over the BNF gramner. I have never even seen a program that creates a parse tree or uses one. I'm going from 0 to 4000 with this assignment and to be honest doubting my abilities a little. I'm not looking for a free ride but Just some help even starting the program. I'm not even sure what the Main program is suppose to look like or how it would work. Any guides or references for C++ parse programs would be great. Or some sample source code of a parser in c++.</p>
<p>This is the assignment...</p>
<p>The purpose of this exercise is to write a syntax generator for a subset of the C++ programming
language that will write “random” C++ programs to a file. By writing these random syntactically
correct programs, you will further develop your understanding of the difference between syntax
and semantics.</p>
<p>Consider the following set of productions that define a subset of the C++ programming
language:</p>
<p>(prog) ::= "int main() { (stat_list) return 0; }"</p>
<p>(stat_list) ::= (stat)
| (stat_list) (stat)</p>
<p>(stat) ::= (cmpd_stat)
| (if_stat)
| (iter_stat)
| (assgn_stat)
| (decl_stat)</p>
<p>The above in only a few of the 16 production rules for the assignment.</p>
<p>Problem 1. Write a program in C, C++, C#, Java, or Python (your choice) that starts with the
root non-terminal and generates a random syntactically correct C++ program using the
productions defined above. You should follow the examples we saw in class where we expand
non-terminals recursively until we obtain a sentence consisting of terminal tokens only. In the
case where a production contains more than one expansion (i.e., right-hand-side expressions),
your program should select one randomly (preferably with non-uniform weighting based on
which expansions are more likely to occur in C++). Your program should write the random C++
code to an output file.</p>
<p>I'm have to use C++ for the assignment because that is the only language that I how after taking the intro classes to CS classes.</p>
<p>Any help would be much appreciated.</p>
| 0debug |
static void buffer_reserve(Buffer *buffer, size_t len)
{
if ((buffer->capacity - buffer->offset) < len) {
buffer->capacity += (len + 1024);
buffer->buffer = qemu_realloc(buffer->buffer, buffer->capacity);
if (buffer->buffer == NULL) {
fprintf(stderr, "vnc: out of memory\n");
exit(1);
}
}
}
| 1threat |
How to change visitors location on page : <p>I want to have a button, and when you click on it, it will get you (the visitor) to the top of the page.
How can this be done?<br>
Thanks</p>
| 0debug |
how to add this small tips or message in my app, is this a Library ? or some thing please help me : I am new in android development. So I am trying to add the new thing in my app.then I am found the app on play store is look awesome I am searching how to add this but I am not found the answer
[enter image description here][1]
[1]: https://i.stack.imgur.com/byOvQ.jpg | 0debug |
static int event_qdev_init(DeviceState *qdev)
{
SCLPEvent *event = DO_UPCAST(SCLPEvent, qdev, qdev);
SCLPEventClass *child = SCLP_EVENT_GET_CLASS(event);
return child->init(event);
}
| 1threat |
void nbd_client_session_close(NbdClientSession *client)
{
struct nbd_request request = {
.type = NBD_CMD_DISC,
.from = 0,
.len = 0
};
if (!client->bs) {
return;
}
if (client->sock == -1) {
return;
}
nbd_send_request(client->sock, &request);
nbd_teardown_connection(client);
client->bs = NULL;
}
| 1threat |
Why does %timeit loop different number of times? : <p>On Jupter Notebook, i was trying to compare time taken between the two methods for finding the index with max value.</p>
<p><a href="https://i.stack.imgur.com/9QGzC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9QGzC.png" alt="enter image description here"></a></p>
<p>In the Image, the first function took, 1000 loops, and the second took 10000 loops, is this increase in loops due to the method itself OR Jupyter Just added more loops to get more accurate time per loop even though the second function maybe took 1000 only, is that the case?</p>
| 0debug |
Is it possible to install CNTK on a macbook? : <p>It is possible to install Microsoft CNTK on a macbook? I have OS X El Capitan. The official Microsoft documentation at <a href="https://github.com/Microsoft/CNTK/wiki/Setup-CNTK-on-your-machine" rel="noreferrer">https://github.com/Microsoft/CNTK/wiki/Setup-CNTK-on-your-machine</a> doesn't provide any information for mac users.</p>
<p>Thank you</p>
| 0debug |
vu_queue_empty(VuDev *dev, VuVirtq *vq)
{
if (vq->shadow_avail_idx != vq->last_avail_idx) {
return 0;
}
return vring_avail_idx(vq) == vq->last_avail_idx;
}
| 1threat |
Why do the following comparisons give different results? : <p>I'm trying to compare the following two quantities: an integer 'i' and the size of a vector v.</p>
<pre><code>#include <vector>
#include <iostream>
using namespace std;
int main()
{
vector <int> v(26,0);
int i = -1;
cout << i << " " << v.size() << endl;
if (i < v.size()) cout << "a1" << endl;
else cout << "b1" << endl;
if (-1 < 26) cout << "a2" << endl;
else cout << "b2" << endl;
return 0;
}
</code></pre>
<p>When I run the following code, the output that I get is:
-1 26
b1
a2</p>
<p>whereas I expect it to give:
-1 26
a1
a2</p>
<p>Why is this happening?</p>
| 0debug |
How to solve this TypeError? : Using TensorFlow backend.
Traceback (most recent call last):
File "/home/lwin/speech-emotion/Speech_emotion_recognition_BLSTM-master1/prediction.py", line 36, in <module>
f = functions.feature_extract((y, sr), nb_samples=1, dataset='prediction')
File "/home/lwin/speech-emotion/Speech_emotion_recognition_BLSTM-master1/utility/functions.py", line 17, in feature_extract
f = audioFeatureExtraction.stFeatureExtraction(x, Fs, globalvars.frame_size * Fs, globalvars.step * Fs)
File "/usr/local/lib/python3.5/dist-packages/pyAudioAnalysis/audioFeatureExtraction.py", line 544, in stFeatureExtraction
Win =Win.astype(int(Win))
TypeError: only length-1 arrays can be converted to Python scalars
| 0debug |
Powershell: backslash at end of string filepath in CSV stopping replacement : I have a CSV file with a list of full file paths. It looks something like this:
C:\Folder1\Subfolder1\file1.txt
C:\Folder1\Subfolder2\file2.txt
C:\Folder1\Subfolder3\file3.txt
What I'm trying to do is to remove the "C:\Folder1\" from the string so that I'm only left with:
Subfolder1\file1.txt
Subfolder2\file2.txt
Subfolder3\file3.txt
I came up with the following script:
(Get-Content c:\test.csv) |
% {$_.replace('C:\\Folder1\\','')}
When I run this, the replace does not work at all.
If I leave the "\\\\" off the end of the path, it works except it keeps a backslash in front of the Subfolder name:
\Subfolder1\file1.txt
\Subfolder2\file2.txt
\Subfolder3\file3.txt
I have tried a number of different methods to get this to work, including adding more backslashes to escape the backslash and changing the single quotes to double-quotes around the string I want to replace, but nothing is working.
Would someone point me in the right direction of what I am doing wrong?
Thanks!
| 0debug |
static void test_io_channel_setup_async(SocketAddressLegacy *listen_addr,
SocketAddressLegacy *connect_addr,
QIOChannel **src,
QIOChannel **dst)
{
QIOChannelSocket *lioc;
struct TestIOChannelData data;
data.loop = g_main_loop_new(g_main_context_default(),
TRUE);
lioc = qio_channel_socket_new();
qio_channel_socket_listen_async(
lioc, listen_addr,
test_io_channel_complete, &data, NULL);
g_main_loop_run(data.loop);
g_main_context_iteration(g_main_context_default(), FALSE);
g_assert(!data.err);
if (listen_addr->type == SOCKET_ADDRESS_LEGACY_KIND_INET) {
SocketAddressLegacy *laddr = qio_channel_socket_get_local_address(
lioc, &error_abort);
g_free(connect_addr->u.inet.data->port);
connect_addr->u.inet.data->port = g_strdup(laddr->u.inet.data->port);
qapi_free_SocketAddressLegacy(laddr);
}
*src = QIO_CHANNEL(qio_channel_socket_new());
qio_channel_socket_connect_async(
QIO_CHANNEL_SOCKET(*src), connect_addr,
test_io_channel_complete, &data, NULL);
g_main_loop_run(data.loop);
g_main_context_iteration(g_main_context_default(), FALSE);
g_assert(!data.err);
qio_channel_wait(QIO_CHANNEL(lioc), G_IO_IN);
*dst = QIO_CHANNEL(qio_channel_socket_accept(lioc, &error_abort));
g_assert(*dst);
qio_channel_set_delay(*src, false);
test_io_channel_set_socket_bufs(*src, *dst);
object_unref(OBJECT(lioc));
g_main_loop_unref(data.loop);
}
| 1threat |
static int vf_open(vf_instance_t *vf, char *args)
{
vf->config=config;
vf->query_format=query_format;
vf->put_image=put_image;
vf->uninit=uninit;
vf->priv = calloc(1, sizeof (struct vf_priv_s));
vf->priv->skipline = 0;
vf->priv->scalew = 1;
vf->priv->scaleh = 2;
if (args) sscanf(args, "%d:%d:%d", &vf->priv->skipline, &vf->priv->scalew, &vf->priv->scaleh);
return 1;
}
| 1threat |
What is the difference between Seq and IndexedSeq/LinearSeq in Scala? : <p>In <a href="http://www.scala-lang.org/docu/files/collections-api/collections_5.html" rel="noreferrer">Scala Collection documentation</a>, there is some clue to this question:</p>
<blockquote>
<p>Trait Seq has two subtraits LinearSeq, and IndexedSeq. These do not add any new operations, but each offers different performance characteristics: A linear sequence has efficient head and tail operations, whereas an indexed sequence has efficient apply, length, and (if mutable) update operations. </p>
</blockquote>
<p>But this does not address me when to use <code>IndexedSeq</code> instead of <code>Seq</code>?
I need some real example of <code>IndexedSeq</code> or <code>LinearSeq</code> where these collections do better than <code>Seq</code>.</p>
| 0debug |
c++ cross related singleton. how can i use function of each other without friends? : <p>I've got helped a lot in here.</p>
<p>this is my first time to ask a question.
ahead, sorry for my bad English.</p>
<p>I made two classes which is singleton for a project.
and its class needs to use other class's functions.</p>
<p>One is app class managing overall app's function
and the other one is menu class, which I am trying to add go back function by using stack.</p>
<p>app needs menu, and menu needs app to execute app function when you select a menu numbers.</p>
<p>but error shows up and I have no idea how should i correct it ;_;
thank you for your help</p>
<p>this is app.h & app.cpp file</p>
<pre><code> #include <iostream>
#include "Menu.h"
using namespace std;
class App
{
static App app;
App();
public:
static App* GetAppInstance();
Menu* getMenuInstance();
};
</code></pre>
<hr>
<pre><code> #include "App.h"
#include <iostream>
using namespace std;
App App::app;
App::App()
{
cout << "App" << endl;
}
App * App::GetAppInstance()
{
return &app;
}
Menu* App::getMenuInstance()
{
return Menu::getMenuInstance();
}
</code></pre>
<p>and this is Menu.cpp and Menu. h file</p>
<pre><code>#include <iostream>
using namespace std;
class App;
class Menu
{
static Menu menu;
Menu();
public:
static Menu* getMenuInstance();
App* getAppInstance();
};
</code></pre>
<hr>
<pre><code>#include "Menu.h"
#include <iostream>
using namespace std;
class App;
Menu::Menu()
{
cout << "메뉴" << endl;
}
Menu * Menu::getMenuInstance()
{
return &menu;
}
App* Menu::getAppInstance()
{
return App::GetAppInstance();
}
Menu Menu::menu
</code></pre>
| 0debug |
static int read_extra_header(FFV1Context *f)
{
RangeCoder *const c = &f->c;
uint8_t state[CONTEXT_SIZE];
int i, j, k, ret;
uint8_t state2[32][CONTEXT_SIZE];
memset(state2, 128, sizeof(state2));
memset(state, 128, sizeof(state));
ff_init_range_decoder(c, f->avctx->extradata, f->avctx->extradata_size);
ff_build_rac_states(c, 0.05 * (1LL << 32), 256 - 8);
f->version = get_symbol(c, state, 0);
if (f->version < 2) {
av_log(f->avctx, AV_LOG_ERROR, "Invalid version in global header\n");
return AVERROR_INVALIDDATA;
}
if (f->version > 2) {
c->bytestream_end -= 4;
f->micro_version = get_symbol(c, state, 0);
if (f->micro_version < 0)
return AVERROR_INVALIDDATA;
}
f->ac = f->avctx->coder_type = get_symbol(c, state, 0);
if (f->ac > 1) {
for (i = 1; i < 256; i++)
f->state_transition[i] = get_symbol(c, state, 1) + c->one_state[i];
}
f->colorspace = get_symbol(c, state, 0);
f->avctx->bits_per_raw_sample = get_symbol(c, state, 0);
f->chroma_planes = get_rac(c, state);
f->chroma_h_shift = get_symbol(c, state, 0);
f->chroma_v_shift = get_symbol(c, state, 0);
f->transparency = get_rac(c, state);
f->plane_count = 1 + (f->chroma_planes || f->version<4) + f->transparency;
f->num_h_slices = 1 + get_symbol(c, state, 0);
f->num_v_slices = 1 + get_symbol(c, state, 0);
if (f->chroma_h_shift > 4U || f->chroma_v_shift > 4U) {
av_log(f->avctx, AV_LOG_ERROR, "chroma shift parameters %d %d are invalid\n",
f->chroma_h_shift, f->chroma_v_shift);
return AVERROR_INVALIDDATA;
}
if (f->num_h_slices > (unsigned)f->width || !f->num_h_slices ||
f->num_v_slices > (unsigned)f->height || !f->num_v_slices
) {
av_log(f->avctx, AV_LOG_ERROR, "slice count invalid\n");
return AVERROR_INVALIDDATA;
}
f->quant_table_count = get_symbol(c, state, 0);
if (f->quant_table_count > (unsigned)MAX_QUANT_TABLES)
return AVERROR_INVALIDDATA;
for (i = 0; i < f->quant_table_count; i++) {
f->context_count[i] = read_quant_tables(c, f->quant_tables[i]);
if (f->context_count[i] < 0) {
av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n");
return AVERROR_INVALIDDATA;
}
}
if ((ret = ff_ffv1_allocate_initial_states(f)) < 0)
return ret;
for (i = 0; i < f->quant_table_count; i++)
if (get_rac(c, state)) {
for (j = 0; j < f->context_count[i]; j++)
for (k = 0; k < CONTEXT_SIZE; k++) {
int pred = j ? f->initial_states[i][j - 1][k] : 128;
f->initial_states[i][j][k] =
(pred + get_symbol(c, state2[k], 1)) & 0xFF;
}
}
if (f->version > 2) {
f->ec = get_symbol(c, state, 0);
if (f->micro_version > 2)
f->intra = get_symbol(c, state, 0);
}
if (f->version > 2) {
unsigned v;
v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0,
f->avctx->extradata, f->avctx->extradata_size);
if (v) {
av_log(f->avctx, AV_LOG_ERROR, "CRC mismatch %X!\n", v);
return AVERROR_INVALIDDATA;
}
}
if (f->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(f->avctx, AV_LOG_DEBUG,
"global: ver:%d.%d, coder:%d, colorspace: %d bpr:%d chroma:%d(%d:%d), alpha:%d slices:%dx%d qtabs:%d ec:%d intra:%d\n",
f->version, f->micro_version,
f->ac,
f->colorspace,
f->avctx->bits_per_raw_sample,
f->chroma_planes, f->chroma_h_shift, f->chroma_v_shift,
f->transparency,
f->num_h_slices, f->num_v_slices,
f->quant_table_count,
f->ec,
f->intra
);
return 0;
}
| 1threat |
How to get by Id from a repository Class dotnet core MVC : I have a repository.cs file like this:
private static List<AdminResponse> responses = new List<AdminResponse>();
public static IEnumerable<AdminResponse> Responses => responses;
public static void AddResponse(AdminResponse response)
{
responses.Add(response);
}
I am trying to retrieve an employee for editing from Employeescontroller.cs The employee model has int Id as key.
What should I write inside:
public ActionResult Details(int? id)
{
//What code goes here I cannot figure out :(
return View();
}
Thank you.
| 0debug |
How to convert a list with properties to a another list the java 8 way? : <p>There is a List A with property Developer. Developer schema likes that:</p>
<pre><code>@Getter
@Setter
public class Developer {
private String name;
private int age;
public Developer(String name, int age) {
this.name = name;
this.age = age;
}
public Developer name(String name) {
this.name = name;
return this;
}
public Developer name(int age) {
this.age = age;
return this;
}
}
</code></pre>
<p>List A with properties:</p>
<pre><code>List<Developer> A = ImmutableList.of(new Developer("Ivan", 25), new Developer("Curry", 28));
</code></pre>
<p>It is demanded to convert List A to List B which with property ProductManager and the properties is same as the ones of List A.</p>
<pre><code>@Getter
@Setter
public class ProductManager {
private String name;
private int age;
public ProductManager(String name, int age) {
this.name = name;
this.age = age;
}
public ProductManager name(String name) {
this.name = name;
return this;
}
public ProductManager name(int age) {
this.age = age;
return this;
}
}
</code></pre>
<p>In the old days, we would write codes like:</p>
<pre><code>public List<ProductManager> convert() {
List<ProductManager> pros = new ArrayList<>();
for (Developer dev: A) {
ProductManager manager = new ProductManager();
manager.setName(dev.getName());
manager.setAge(dev.getAge());
pros.add(manager);
}
return pros;
}
</code></pre>
<p>How could we write the above in a more elegant and brief manner with Java 8?</p>
| 0debug |
why python print " num += 1 " invalid syntax? : <pre><code>balance = 5000
monthlyPaymentRate = 0.02
annualInterestRate = 0.18
num = 0
remaining_balance = 0.00
while num <= 12:
remaining_balance = (annualInterestRate/12 * (balance-(balance * monthlyPaymentRate))+ tem_balance
num += 1
print(remaining_balance)
</code></pre>
<p>why python print " num += 1 " invalid syntax ?</p>
| 0debug |
How can I make all html tags close in the same line with php : <p>For example, if I have</p>
<pre><code><b>Line 1
Line 2</b>
</code></pre>
<p>I want to make it become </p>
<pre><code><b>Line 1</b>
<b>Line 2</b>
</code></pre>
<p>thanks.</p>
| 0debug |
static int net_slirp_init(VLANState *vlan, const char *model, const char *name,
int restricted, const char *ip)
{
if (slirp_in_use) {
return -1;
}
if (!slirp_inited) {
slirp_inited = 1;
slirp_init(restricted, ip);
while (slirp_redirs) {
struct slirp_config_str *config = slirp_redirs;
slirp_redirection(NULL, config->str);
slirp_redirs = config->next;
qemu_free(config);
}
#ifndef _WIN32
if (slirp_smb_export) {
slirp_smb(slirp_smb_export);
}
#endif
}
slirp_vc = qemu_new_vlan_client(vlan, model, name, NULL, slirp_receive,
NULL, net_slirp_cleanup, NULL);
slirp_vc->info_str[0] = '\0';
slirp_in_use = 1;
return 0;
}
| 1threat |
HTML/JS/CSS - Element won't get showed proplem : ***hey all, please do anyone know how to resolve my proplem (My element didn't get showed on Button click...) don't know the proplem***
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
var modal = document.getElementById('comments-main');
var btn = $("a#comments-btn");
var span = $("close");
btn.click = function() {
if(modal.style.display == 'block')
{
modal.style.display = "none";
}
else
{
modal.style.display = "block";
}
}
span.onclick = function() {
if(modal.style.display == 'block')
{
modal.style.display = "none";
}
}
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
<!-- language: lang-css -->
#comments-btn {
float: left;
margin-left: 50px;
}
.comments-modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
-webkit-animation-name: fadeIn; /* Fade in the background */
-webkit-animation-duration: 0.4s;
animation-name: fadeIn;
animation-duration: 0.4s;
}
.comments-content {
position: fixed;
bottom: 0;
background-color: #fefefe;
width: 100%;
}
.close {
color: white;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: red;
text-decoration: none;
cursor: pointer;
}
.comments-header {
padding: 2px 16px;
background-color: orange; /* #5cb85c */
color: white;
font-size: 15px;
border-left: 1.5px solid black;
border-right: 1.5px solid black;
border-top: 1.5px solid black;
border-bottom: 1.5px solid black;
border-radius:1px;
text-shadow: -1px 3px 3px white, 3px 4px 5px red, 6px 9px 12px black;
}
.comments-body {
padding: 2px 16px;
font-size: 15px;
font-style: italic;
border-left: 1.5px solid black;
border-right: 1.5px solid black;
border-radius: 1px;
}
.comments-modal-footer {
padding: 2px 16px;
background-color: orange;
border-left: 1.5px solid black;
border-right: 1.5px solid black;
border-bottom: 1.5px solid black;
border-radius:1px;
}
<!-- language: lang-html -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="comments-main" class="comments-modal">
<div class="comments-content">
<div class="comments-header">
<span class="close">×</span>
<h2> Shikor - FB Comments </h2>
</div>
<div class="comments-body">
<p>Facebook Comments Count: <span class="fb-comments-count" data-href="http://br-gaming.tk"></span></p><br />
<center><div class="fb-comments" data-href="http://br-gaming.tk" data-width="600" data-numposts="5" data-colorscheme="dark"></div></center>
</div>
<div class="comments-modal-footer"></div>
</div>
</div>
<a class="w3-button w3-xlarge w3-circle w3-orange w3-card-4" id="comments-btn" href="#" onclick="return false;"><i class="fa fa-comments-o" aria-hidden="true"></i></a>
<!-- end snippet -->
which i try to click on the button it show nothing... please some help ??? | 0debug |
Only allow form submit of pdf/images not ever blank : <p>Hi I have a website which the page logic should only accept submit under two conditions:</p>
<p>1) if the captcha is actively checked</p>
<p>and </p>
<p>2) if at least one file is attached (only pdf and image file types are allowed up to three total) are attached. </p>
<p>the issue is that we are receiving blank applications however, I am seeing a scenario where you can attach non pdfs/images with a pdf/image and still submit which strips all attachments.</p>
<p>proper behavior should be:
prevent submit if non pdf/image type attached show error message "Only image or pdf can be uploaded" and then a message stating this and preventing form submit at the bottom of the page in red just like the other errors.</p>
<p>Be polite. Thanks. :-)</p>
<p>Page URL: <a href="http://www.barona.com/about-barona/community-relations/community-giving-guidelines/" rel="nofollow">http://www.barona.com/about-barona/community-relations/community-giving-guidelines/</a></p>
<p>PHP (to test replace youremail with your email address, thanks!):</p>
<pre><code><?php
ini_set('display_errors', 'off');
$to = 'youremail@gmail.com';
$from = 'youremail@gmail.com';
$subject = 'New Application';
$allowed_extensions = array(
'.pdf',
'.jpeg',
'.jpg',
'.png',
'.gif',
'.bmp'
);
$file1 = '';
$file2 = '';
$file3 = '';
$filename1 = '';
$filename2 = '';
$filename3 = '';
//echo "1";
if (!empty($_FILES['file1']['name'])) {
//echo "File 1 exists";
$filename1 = $_FILES['file1']['name'];
$extension = '.' . strtolower(array_pop(explode('.', $filename1)));
$size1 = $_FILES['file1']['size'];
$mime1 = $_FILES['file1']['type'];
$tmp1 = $_FILES['file1']['tmp_name'];
if (in_array($extension, $allowed_extensions)) {
$file1 = fopen($tmp1, 'rb');
$data1 = fread($file1, filesize($tmp1));
// Now read the file content into a variable
fclose($file1);
// close the file
$data1 = chunk_split(base64_encode($data1));
// Now we need to encode it and split it into acceptable length lines
$file1 = $filename1;
} else {
$filename1 = '';
}
}
//file 2:
if (!empty($_FILES['file2']['name'])) {
//echo "File 2 exists";
$filename2 = $_FILES['file2']['name'];
$extension = '.' . strtolower(array_pop(explode('.', $filename2)));
$tmp2 = $_FILES['file2']['tmp_name'];
$size2 = $_FILES['file2']['size'];
$mime2 = $_FILES['file2']['type'];
if (in_array($extension, $allowed_extensions)) {
$file2 = fopen($tmp2, 'rb');
$data2 = fread($file2, filesize($tmp2));
// Now read the file content into a variable
fclose($file2);
// close the file
$data2 = chunk_split(base64_encode($data2));
// Now we need to encode it and split it into acceptable length lines
$file2 = $filename2;
} else {
$filename2 = '';
}
}
//File 3:
if (!empty($_FILES['file3']['name'])) {
//echo "File 3 exists";
$filename3 = $_FILES['file3']['name'];
$extension = '.' . strtolower(array_pop(explode('.', $filename3)));
$tmp3 = $_FILES['file3']['tmp_name'];
$size3 = $_FILES['file3']['size'];
$mime3 = $_FILES['file3']['type'];
if (in_array($extension, $allowed_extensions)) {
$file3 = fopen($tmp3, 'rb');
$data3 = fread($file3, filesize($tmp3));
// Now read the file content into a variable
fclose($file3);
// close the file
$data3 = chunk_split(base64_encode($data3));
// Now we need to encode it and split it into acceptable length lines
$file3 = $filename3;
} else {
$filename3 = '';
}
}
//echo "2";
//Only allow image or pdf.
$message = "<table border='1' style='width:80%'><tr><td>File 1: </td><td>$filename1</td></tr><tr><td>File 2: </td><td>$filename2<td></tr><tr><td>File 3: </td><td>$filename3</td></tr></table>";
// email fields: to, from, subject, and so on
$headers = "From: $from\n";
$headers .= "Reply-To: $to\n";
$headers .= "BCC: cpeterson@barona.com";
// boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// headers for attachment
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed, html;\n" . " boundary=\"{$mime_boundary}\"";
// multipart boundary
$message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=ISO-8859-1\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
$message .= "--{$mime_boundary}\n";
if (!empty($file1)) {
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name='$filename1'\n" . "Content-Disposition: attachment;\n" . " filename=$filename1\n" . "Content-Transfer-Encoding: base64\n\n" . $data1 . "\n\n";
$message .= "--{$mime_boundary}\n";
}
if (!empty($file2)) {
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name='$filename2'\n" . "Content-Disposition: attachment;\n" . " filename=$filename2\n" . "Content-Transfer-Encoding: base64\n\n" . $data2 . "\n\n";
$message .= "--{$mime_boundary}\n";
}
if (!empty($file3)) {
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name='$filename3'\n" . "Content-Disposition: attachment;\n" . " filename=$filename3\n" . "Content-Transfer-Encoding: base64\n\n" . $data3 . "\n\n";
$message .= "--{$mime_boundary}\n";
}
// send
$ok = @mail($to, $subject, $message, $headers, '-fnoreply@yourmailer.com');
if ($ok) {
//echo "<p>Thank you for submitting your application to: $to!</p>";
header("Location: ../../../about-barona/community-relations/community-giving-guidelines/thanks/"); /* Redirect browser */
exit();
} else {
//echo "<p>mail could not be sent!</p>";
header("Location: ../../../club-barona/email-signup/error/"); /* Redirect browser */
exit();
}
?>
</code></pre>
<p>Wordpress HTML:</p>
<pre><code><h2>COMMUNITY GIVING GUIDELINES & DONATION APPLICATION</h2><p>In an effort to better serve you, Barona will only review requests via an online donation application. To be considered for a donation or sponsorship, you must complete the online application. Requests submitted via email, mail, phone, or fax will not be accepted. All requests will be screened and reviewed for consideration by the Community Relations Committee. In making determinations on contribution requests, the Committee places emphasis on well-managed non-profit organizations and programs. Funding decisions are also based on the quality of the organizations programs and their support of Barona Resort & Casino’s key areas of focus. Additional consideration includes the scope of each program and the overall impact on the community. Barona maintains the flexibility to accommodate new and innovative approaches to meeting the needs of the community.</p><ul><li>Due to the volume of requests received, donation requests for auction and raffle items must be submitted at least 60 – 90 days prior to the date the donation is needed.</li><li>Sponsorship requests should be submitted by October for consideration in the following year, as planning is based on a calendar year.</li><li>Sponsorships exceeding $10,000 must include performance measurement criteria and the requestor must be prepared to submit a report of achievement.</li><li>We will respond to all requests with the decision of the committee, regardless of the outcome within 6 - 8 weeks of review.</li></ul>
<h3>We generally <b> exclude </b> requests that benefit:</h3>
<ul>
<li>Local sports organizations </li>
<li>An individual person or family </li>
<li>General operating expenses </li>
<li>Political candidates or organizations </li>
<li>Film or documentary productions </li>
<li>Memorials, endowments, or grants </li>
<li>Organizations outside of California </li>
<li>Travel expenses </li>
<li>Groups seeking educational or travel grants for contests, pageants, trips or conventions </li>
<li>Loan or loan guarantees </li>
<li>Capital improvement or building funds </li>
</ul>
<p><input id="chkTerms" name="chkTerms" onclick="validate();" required="required" type="checkbox" value="0"> I have read and understand the Community Giving Guidelines. Thank you for contacting Barona Resort &amp; Casino regarding a contribution towards your organization. Please note that this online application must be completed in its entirety and, if necessary, submitted with all appropriate supporting documents.</p><form action="../../../wp-content/themes/barona/form-to-email.php" enctype="multipart/form-data" method="post">
<div id="DonationApplicationFormContent" style="width: 700px; margin: 10px -150px !important; display: none;">
<hr />
<h2>Instructions </h2>
<p>Follow the directions below to submit your <strong><a href="/wp-content/uploads/2015/10/DonationApplicationForm.pdf" target="_blank">Donation Application Form</a></strong>.</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/G-SDuvlur8o" frameborder="0" allowfullscreen></iframe>
<h3 style="margin: 0;">Step 1</h3>
<p>Download the Donation Application Form PDF.<br /><small>Note: Safari users, right click the "Download Now" button and select "Download Linked File As".</small><br /><br />[easy_media_download url="/wp-content/uploads/2015/10/DonationApplicationForm.pdf" force_dl="1"]</p>
<h3 style="margin: 0;">Step 2</h3>
<strong>Print</strong> or <strong>complete</strong> the form using <strong><a href="https://get.adobe.com/reader" target="_blank">Adobe Acrobat Reader</a></strong>. You can download Adobe Acrobat for free at <a href="https://get.adobe.com/reader" target="_blank">https://get.adobe.com/reader</a>
</p>
<h3 style="margin: 0;">Step 3</h3>
Click <strong>Browse</strong> to upload the completed <strong>Donation Application Form</strong> along with any supporting documents (images or PDF).
</p>
<h3 style="margin: 0;">Step 4</h3>
<p>Click the <strong>Submit</strong> button below to complete your submission. <br />
<br />
OR
<br /><br />
Email your completed PDF document with any supporting documents to <a href="mailto: donationapplicationsbarona@gmail.com">donationapplicationsbarona@gmail.com</a>.
</p>
Upload event brochures, marketing materials or other documents. Upload images or PDF files only. (Limit: 5MB max per file):
<table>
<tr style="height: 30px;">
<td>File 1:<input type="file" id="file1" name="file1"></td>
</tr>
<tr style="height: 30px;">
<td>File 2:<input type="file" id="file2" name="file2"></td>
</tr>
<tr style="height: 30px;">
<td>File 3: <input type="file" id="file3" name="file3"></td>
</tr>
</table>
<table>
<tr >
<td>
<div class="g-recaptcha" id="rcaptcha" data-sitekey="6Let2wwTAAAAAJaUZQGTCRy6Pv4YYLoQjsLUH6hs"></div></td>
</tr>
<tr>
<td>
<div id="captcha" aria-live="assertive"></div></td>
</tr>
<tr style="height: 80px;">
<td><input tabindex="11" title="Submit" type="submit" value="Submit" onclick="return get_action(this);"><input tabindex="12" title="Reset" type="reset" value="Reset"></td>
</tr>
</table>
<label id="lblStatus">*Required.</label></div>
</form>
</code></pre>
<p>Page source:</p>
<p>see page. :-)</p>
<p>Please help fix it so no blank applications can be received. as well as only pdf/images allowed before submit. willing to install a js file. please be as thorough and I will select you as top vote/winner. be good my coder friends! Long live privacy!</p>
| 0debug |
I am trying to get some images to fade until the mouse is hovered over it : The images are here on this page - the top series of images - the last 3: http://ops-com.com/products-dup/ | 0debug |
What is unicode character of location? : <p>I want use character for the location (like in Google Maps) – <a href="http://i.stack.imgur.com/s0Nb6.png" rel="noreferrer">location symbol</a>.</p>
<p>I want to ask if there is such a unicode character?</p>
| 0debug |
How are classes loaded during user interaction in swift? : Very new to swift here. I am trying to make a simple to-do app.
When a user types in an task, i wanna try to add this task to a string array and increase a counter.
When I type in multiple tasks, my string array only holds the previously typed in task and my counter always is 1 (counter is based off number of items in the string array).
I'm assuming that every time i type in a new task, my class which deals with my string array and counter is reset to their initial values which is an empty string array and 0 respectively.
Any idea how to avoid this, or how classes are loaded when it comes to user interaction?
Sorry if im not being too clear, thanks. | 0debug |
Interacting with C++ classes from Swift : <p>I have a significant library of classes written in C++. I'm trying to make use of them through some type of bridge within Swift rather than rewrite them as Swift code. The primary motivation is that the C++ code represents a core library that is used on multiple platforms. Effectively, I'm just creating a Swift based UI to allow the core functionality to work under OS X.</p>
<p>There are other questions asking, "How do I call a C++ function from Swift." This is <em>not</em> my question. To bridge to a C++ function, the following works fine:</p>
<p><strong>Define a bridging header through "C"</strong></p>
<pre><code>#ifndef ImageReader_hpp
#define ImageReader_hpp
#ifdef __cplusplus
extern "C" {
#endif
const char *hexdump(char *filename);
const char *imageType(char *filename);
#ifdef __cplusplus
}
#endif
#endif /* ImageReader_hpp */
</code></pre>
<p><strong>Swift code can now call functions directly</strong></p>
<pre><code>let type = String.fromCString(imageType(filename))
let dump = String.fromCString(hexdump(filename))
</code></pre>
<p>My question is more specific. How can I instantiate and manipulate a <em>C++ Class</em> from within Swift? I can't seem to find anything published on this.</p>
| 0debug |
how to pass data from one fragment to previous fragment? : <p>I am going FragmentA->FragmentB. Now From FragmentB I want to pass data to FragmentA.So How can I do that??</p>
<p>Currently am going FragmentB->FragmentA with <code>getCustomFragmentManager().popBackStack();</code>
but not passing any value.</p>
| 0debug |
result from Ajax Call : <p>I have an ajax call and I want to use result of this ajax on another page.</p>
<p>//This is main.js file</p>
<pre><code>function myFun(){
var my_user = "Stas";
var itemsUrl = "myxmlwithusers";
var user_found = false;
$.ajax({
url: itemsUrl,
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
cache: false,
async: false,
dataType: "text",
success: function(data){
var jsonObject = JSON.parse(data);
results = jsonObject.d.results;
$(results).each(function(){
if($(this)[0].user == my_user){
user_found = true;
}
});
},
error:function () {
console.log("Error");
}
}
);
}
</code></pre>
<p>// This is execute.js file</p>
<pre><code>myFun();
if (user_found == true){cool}
</code></pre>
<p>I need true or false for // user_found. Let say I will put in the file execute.js my function myFun() and in main.js my user is fetch with "$(this)[0].user" and I need to receive "true" in execute.js</p>
<p>Thanks!</p>
| 0debug |
The service "fos_user.group_manager" has a dependency on a non-existent service "fos_user.entity_manager". : [i'm using symfony 2.8 i want to configure sonata user bundle and fosUserbundle][1]
[1]: https://i.stack.imgur.com/XQ4qZ.jpg | 0debug |
Validation travis.yml file locally : <p>Are there any tools (CLI or with GUI) for validation travis.yml file locally at my computer without the need of pushing it? Maybe there are some plugins for text editors or other approaches to solve this problem?</p>
| 0debug |
static void stream_pause(VideoState *is)
{
is->paused = !is->paused;
if (!is->paused) {
if(is->read_pause_return != AVERROR(ENOSYS)){
is->video_current_pts = get_video_clock(is);
}
is->frame_timer += (av_gettime() - is->video_current_pts_time) / 1000000.0;
is->video_current_pts_time= av_gettime();
}
}
| 1threat |
Is there a way to make clap override [ -h | --help ] flags help text in Rust Lang? : I'm following the sample code from Rust Clap Package's docs but just can't find any reference regarding help text for auto-generated flags [-h and --help].
extern crate clap;
use clap::{Arg, App, SubCommand};
fn main() {
let matches = App::new("Command One")
.version("1.0")
.author("Julio Talavera <codejutsu.dojo@gmail.com>")
.about("Descripción del comando.")
.arg(Arg::with_name("config")
.short("c")
.long("config")
.value_name("FILE")
.help("Sets a custom config file")
.takes_value(true))
.arg(Arg::with_name("INPUT")
.help("Sets the input file to use")
.required(true)
.index(1))
.arg(Arg::with_name("v")
.short("v")
.multiple(true)
.help("Sets the level of verbosity"))
// *** I'm trying this ***
.arg(Arg::with_name("help")
.short("h")
.long("help")
.help("A new help text."))
// ***********
.subcommand(SubCommand::with_name("test")
.about("controls testing features")
.version("1.3")
.author("Someone E. <someone_else@other.com>")
.arg(Arg::with_name("debug")
.short("d")
.help("print debug information verbosely")))
.get_matches();
let config = matches.value_of("config").unwrap_or("default.conf");
println!("Value for config: {}", config);
println!("Using input file: {}", matches.value_of("INPUT").unwrap());
match matches.occurrences_of("v") {
0 => println!("No verbose info"),
1 => println!("Some verbose info"),
2 => println!("Tons of verbose info"),
3 | _ => println!("Don't be crazy"),
}
if let Some(matches) = matches.subcommand_matches("test") {
if matches.is_present("debug") {
println!("Printing debug info...");
} else {
println!("Printing normally...");
}
}
} | 0debug |
How can I make rounded TextField in flutter? : <p>Material Design for iOS doesn't look good, especially the <strong>TextField</strong>. So is there any way to create your own ? Or Is ther any way to add some styling to TextField so it will look rounded ?</p>
| 0debug |
static void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq)
{
V9fsVirtioState *v = (V9fsVirtioState *)vdev;
V9fsState *s = &v->state;
V9fsPDU *pdu;
ssize_t len;
while ((pdu = pdu_alloc(s))) {
struct {
uint32_t size_le;
uint8_t id;
uint16_t tag_le;
} QEMU_PACKED out;
VirtQueueElement *elem = &v->elems[pdu->idx];
len = virtqueue_pop(vq, elem);
if (!len) {
pdu_free(pdu);
break;
}
BUG_ON(elem->out_num == 0 || elem->in_num == 0);
QEMU_BUILD_BUG_ON(sizeof out != 7);
len = iov_to_buf(elem->out_sg, elem->out_num, 0,
&out, sizeof out);
BUG_ON(len != sizeof out);
pdu->size = le32_to_cpu(out.size_le);
pdu->id = out.id;
pdu->tag = le16_to_cpu(out.tag_le);
qemu_co_queue_init(&pdu->complete);
pdu_submit(pdu);
}
}
| 1threat |
Entity LINQ Enumberable Async : I have query where I need to sum all daily work. Problem is - I need it not to lock `UI` and be `async`, but `Enumberable` does not support `Async`. I use `Enumberable` to parse date `String` into `DateTime` object.
Any tips for same result but async.
var result = (from w in db.Washes.AsEnumerable()
group w by new {Date = DateTime.ParseExact(w.WashTime, pattern, null).Date}
into g
orderby g.Key.Date descending
select new DailyAverageModel {
Date = g.Key.Date,
NoOfWashesPerDate = g.Count()
}).ToList(); | 0debug |
$(document).ready vs window.onload vs window.addEventListener : <p>I had been researching on the above 3 JS/jQuery commands and I want to execute the JavaScript after EVERYTHING is loaded, but seems all the above 3 scripts are fired before the DIV is loaded. Can anyone tell me how to execute a JS script after EVERYTHING is loaded. Please see the following html : If you carefully notice this, you will see the alert pop up window before the DIV is loaded. I am running it in Chrome. </p>
<pre><code> <script>
window.addEventListener( 'load', function( event ) {
alert("test");
});
$(document).ready(function(){
alert("test");
});
window.onload = function(e){
alert("test");
}
</script>
<body>
<div>
Hello There!!!
</div>
</body>
</code></pre>
| 0debug |
static void qpeg_decode_intra(uint8_t *src, uint8_t *dst, int size,
int stride, int width, int height)
{
int i;
int code;
int c0, c1;
int run, copy;
int filled = 0;
height--;
dst = dst + height * stride;
while(size > 0) {
code = *src++;
size--;
run = copy = 0;
if(code == 0xFC)
break;
if(code >= 0xF8) {
c0 = *src++;
c1 = *src++;
size -= 2;
run = ((code & 0x7) << 16) + (c0 << 8) + c1 + 2;
} else if (code >= 0xF0) {
c0 = *src++;
size--;
run = ((code & 0xF) << 8) + c0 + 2;
} else if (code >= 0xE0) {
run = (code & 0x1F) + 2;
} else if (code >= 0xC0) {
c0 = *src++;
c1 = *src++;
size -= 2;
copy = ((code & 0x3F) << 16) + (c0 << 8) + c1 + 1;
} else if (code >= 0x80) {
c0 = *src++;
size--;
copy = ((code & 0x7F) << 8) + c0 + 1;
} else {
copy = code + 1;
}
if(run) {
int p;
p = *src++;
size--;
for(i = 0; i < run; i++) {
dst[filled++] = p;
if (filled >= width) {
filled = 0;
dst -= stride;
}
}
} else {
for(i = 0; i < copy; i++) {
dst[filled++] = *src++;
if (filled >= width) {
filled = 0;
dst -= stride;
}
}
size -= copy;
}
}
}
| 1threat |
static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIORNG *vrng = VIRTIO_RNG(dev);
Error *local_err = NULL;
if (!vrng->conf.period_ms > 0) {
error_setg(errp, "'period' parameter expects a positive integer");
return;
}
if (vrng->conf.max_bytes > INT64_MAX) {
error_setg(errp, "'max-bytes' parameter must be non-negative, "
"and less than 2^63");
return;
}
if (vrng->conf.rng == NULL) {
vrng->conf.default_backend = RNG_RANDOM(object_new(TYPE_RNG_RANDOM));
user_creatable_complete(OBJECT(vrng->conf.default_backend),
&local_err);
if (local_err) {
error_propagate(errp, local_err);
object_unref(OBJECT(vrng->conf.default_backend));
return;
}
object_property_add_child(OBJECT(dev),
"default-backend",
OBJECT(vrng->conf.default_backend),
NULL);
object_unref(OBJECT(vrng->conf.default_backend));
object_property_set_link(OBJECT(dev),
OBJECT(vrng->conf.default_backend),
"rng", NULL);
}
vrng->rng = vrng->conf.rng;
if (vrng->rng == NULL) {
error_setg(errp, "'rng' parameter expects a valid object");
return;
}
virtio_init(vdev, "virtio-rng", VIRTIO_ID_RNG, 0);
vrng->vq = virtio_add_queue(vdev, 8, handle_input);
vrng->quota_remaining = vrng->conf.max_bytes;
vrng->rate_limit_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL,
check_rate_limit, vrng);
timer_mod(vrng->rate_limit_timer,
qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + vrng->conf.period_ms);
register_savevm(dev, "virtio-rng", -1, 1, virtio_rng_save,
virtio_rng_load, vrng);
}
| 1threat |
Excel - Cut certain range in a row and insert below of the row : Below are my Excel Raw data.
A B C D E F
1. A1 B1 C1 E1 F1
2. A2 B2 C2 E2 F2
3. A3 B3 C3 E3 F3
4. A4 B4 C4 E4 F4
I want to cut ranging E1 and F1 then Insert it below the line.
The output is as per below
A B C D E F
1. A1 B1 C1
2. E1 F1
3. A2 B2 C2
4. E2 F2
5. A3 B3 C3
6. E3 F3
7. A4 B4 C4
8. E4 F4
How am i going to do this with Excel VBA programming?
| 0debug |
Getting [Object HTMLInputElement] error : <p>looping through a json encoded output for a Month Year value, and trying to convert it a month number before passing it to next step in code ...</p>
<pre><code>... foreach loop
var month_number = null;
var dateOf = JSON.stringify(v.date);
if(dateOf.indexOf("January")>-1){month_number=1}else
if(dateOf.indexOf("February")>-1){month_number=2}else
if(dateOf.indexOf("March")>-1){month_number=3}
});
htmlStr += '<input type="hidden" id="month_number" value="' + month_number + '" />';
</code></pre>
<p>returning [Object HTMLInputElement] for month_number ... everything else is working ...</p>
| 0debug |
A PAGE with plugin of top posts (wordpress) : <p>I need a plugin for create "most visited posts" page.</p>
<p>NOT NEED ANY PLUGIN FOR A WIDGET, I WAN'T ANY WIDGET IN SIDEBAR.</p>
<p>I search a lot but I haven't found anythink.</p>
<p>Sorry for my english, thanks.</p>
| 0debug |
getTotal() takes exactly 2 arguments (1 given) : <p>So, here is my Shoping Cart code, im stuck with this code, i fix one error, another pop out. So now i get TypeError: getTotal() takes exactly 2 arguments (1 given)</p>
<pre><code>class Item():
"""Name and price of Item"""
def __init__(self, name, price):
self.name = name
self.price = price
def getName(self): #Returning item's name
return self.name
def getPrice(self): #Returning item's price.
return self.price
class User():
"""Getting name of user"""
def __init__(self, name,budget):
self.name = name
self.budget = budget
def userName(self): #Returning user's name
return self.name
def userBudget(self): #Returning user's budget
return self.budget
class Cart():
"""Creating a cart, you can add item in cart and remove it, also u can se your total bill."""
def __init__(self):
self.carta = [] #Carta is shopping cart.
def addItem(self,carta):
self.carta.append(1) #Adding item in cart.
def getTotal(self,carta): #Total bill.
total = 0
for item in carta:
item = getPrice, getName
total += item
return total
def numItems(self,carta): #Number of items in cart.
self.carta = carta.len()
return len.carta()
def kart():
item1 = Item ("Iphone", 500)
item2 = Item ("Samsung", 200)
item3 = Item("Huawei", 400)
uname = User("Marko", 2000)
kart = Cart()
kart.addItem(item1)
kart.addItem(item2)
kart.addItem(item3)
print ("Hi %i, your total bill is $%0.2f, and you have %i items in your cart.",uname.userName(), kart.getTotal(), kart.numItems())
final = kart()
print (final)
</code></pre>
<p>Output i get:</p>
<pre><code>Traceback (most recent call last):
File "C:\Users\Marko\Documents\Projects\Shopping.py", line 56, in <module>
final = kart()
File "C:\Users\Marko\Documents\Projects\Shopping.py", line 54, in kart
print ("Hi %i, your total bill is $%0.2f, and you have %i items in your cart.",uname.userName(), kart.getTotal(), kart.numItems())
TypeError: getTotal() takes exactly 2 arguments (1 given)
</code></pre>
<p>Every tip, every help is welcome, thanks,</p>
| 0debug |
void rtp_parse_close(RTPDemuxContext *s)
{
if (!strcmp(ff_rtp_enc_name(s->payload_type), "MP2T")) {
ff_mpegts_parse_close(s->ts);
}
av_free(s);
} | 1threat |
static void test_qemu_strtoul_empty(void)
{
const char *str = "";
char f = 'X';
const char *endptr = &f;
unsigned long res = 999;
int err;
err = qemu_strtoul(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, 0);
g_assert(endptr == str);
}
| 1threat |
How to check if Haptic Engine (UIFeedbackGenerator) is supported : <p>I am wondering how we could check if the new iOS 10 API <code>UIFeebackGenerator</code> is available on the current device. There are some more things we would need to check:</p>
<ol>
<li>The device needs to run iOS 10.0 or later</li>
<li>The device needs to be an iPhone 7 or later</li>
<li>The Haptic Engine needs to be turned on in the Settings </li>
</ol>
<p>The first two checks can be achieved using <code>#available(iOS 10, *)</code> statement and a (hacky) device-detection, but the latter one doesn't seem to be checkable.</p>
<p>Does someone know a solution for this? Or maybe we need to file an Apple Radar for this one. Thanks!</p>
| 0debug |
why "separate" and "union" function don´t not work in dplyr : I used the function "separate" and "union" to clean some data but they don´t seem to work
I´ve been trying to separate a column string into two columns using dplyr. The function is quite easy and don´t know why it does not work.
The variable (column) I want to separate is “season” which contains values of “MAD_S1, KGA_S1” etc. (thousands of records, but the categories are 6, all separated by the “_S1”; raw data has been inspected and all follow the same syntax). Therefore, I applied
separate(six_sites_spp, season, c("code_loc","season1"), sep = "_")
I have tried more explicit script such as:
separate(six_sites_spp,
col = "season",
into = c("code_loc", "season1"),
sep = "_")
but nothing either.
I have updated the dplyr versions, and try several things. If I use “union” instead to merge two columns it does not work either. I resolved this by using the classic “paste” function, but not for the splitting; I do however want to know why dplyr does not work (this is a great package and for some reason other commands are not working either).
Would anyone be able to provide feedback on this, please? Is it a possible “bug” or something within my system (windows10, HP envi), do I need another package simultaneously (I upload also tidyr in the same script)? any version mismatch (my R version 3.5.1 (2018-07-02). When I run the code it does something internally, as I see it runs the commands, but the output is the same dataframe (i.e. no new variables “code_loc”, “season1”
Many thanks in advance.
*there are no error messages | 0debug |
How to store dataset in xpt file using c# : I am strucked at a point
I am not able to find how to store the data which is retrieved from sql server to .xpt extension file.
Can any one please help me to resolve it. | 0debug |
Read file content from S3 bucket with boto3 : <p>I read the filenames in my S3 bucket by doing </p>
<pre><code>objs = boto3.client.list_objects(Bucket='my_bucket')
while 'Contents' in objs.keys():
objs_contents = objs['Contents']
for i in range(len(objs_contents)):
filename = objs_contents[i]['Key']
</code></pre>
<p>Now, I need to get the actual content of the file, similarly to a <code>open(filename).readlines()</code>. What is the best way?</p>
| 0debug |
static av_cold int common_end(AVCodecContext *avctx){
FFV1Context *s = avctx->priv_data;
int i, j;
for(j=0; j<s->slice_count; j++){
FFV1Context *fs= s->slice_context[j];
for(i=0; i<s->plane_count; i++){
PlaneContext *p= &fs->plane[i];
av_freep(&p->state);
av_freep(&p->vlc_state);
av_freep(&fs->sample_buffer);
av_freep(&avctx->stats_out);
for(j=0; j<s->quant_table_count; j++){
av_freep(&s->initial_states[j]);
FFV1Context *sf= s->slice_context[i];
av_freep(&sf->rc_stat2[j]);
av_freep(&s->rc_stat2[j]);
return 0; | 1threat |
What is the difference between AndroidJUnitRunner and AndroidJunit4? : <p>I am a newbie to the Android testing world and the samples for Unit tests mention the use of <code>AndroidJunit4</code> runner. I have stumbled upon another runner called <code>AndroidJUnitRunner</code>. Now, I saw the docs for both the classes and at one glance, it seems that the difference is that <code>AndroidJunit4</code> supports JUnit4 especially while <code>AndroidJUnitRunner</code> supports JUnit3 and JUnit4 but if you look into the class structure and the available methods, there actually is a huge difference between these two runners. </p>
<p>For ex, <code>AndroidJUnitRunner</code> extends from the following classes:</p>
<p><a href="https://i.stack.imgur.com/zrGS0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zrGS0.png" alt="enter image description here"></a></p>
<p>And, <code>AndroidJunit4</code> extends from,</p>
<p><a href="https://i.stack.imgur.com/RQbKD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RQbKD.png" alt="enter image description here"></a></p>
<p>So, what is the difference between the two runners and which runner am I supposed to be using finally?</p>
| 0debug |
document.getElementById('input').innerHTML = user_input; | 1threat |
static void amdvi_mmio_trace(hwaddr addr, unsigned size)
{
uint8_t index = (addr & ~0x2000) / 8;
if ((addr & 0x2000)) {
index = index >= AMDVI_MMIO_REGS_HIGH ? AMDVI_MMIO_REGS_HIGH : index;
trace_amdvi_mmio_read(amdvi_mmio_high[index], addr, size, addr & ~0x07);
} else {
index = index >= AMDVI_MMIO_REGS_LOW ? AMDVI_MMIO_REGS_LOW : index;
trace_amdvi_mmio_read(amdvi_mmio_high[index], addr, size, addr & ~0x07);
}
}
| 1threat |
Not able to execute (Unix)commands containing variables using JSch library : I have written a Java program which when executed would open an upload wizard through which a user can select a file. After doing this, the selected file would be transferred/uploaded to a Unix box to a directory which the user specifies and processed further. <br>
Here are the steps/actions: <br>
1. Browse the file through the upload wizard. <br>
2. After this the program would prompt for a new directory to be created, the name of which the user can give as an input. <br>
3. The program creates a new directory(source) and places the selected file in the created directory of the server. <br>
4. Show the contents of the transferred file in the source(using cat command). <br>
5. Prompt the user for a new directory to be created(target), copy the file from the source to target and subsequently show the contents of the file in the target(All Linux commands). <br><br>
I'm able to upload the file to the source(upto hte 1st 3 steps). However, the 4th and the 5th don't work. Here's the code which doesn't seem to work: <br><br>
String cmd1 = "cat" + " " + path + s1 + "/" + file;
System.out.println(cmd1);
((ChannelExec)channel).setCommand(cmd1);
Scanner in2 = new Scanner(System.in);
System.out.println("Enter d target directory");
String s = in2.nextLine();
String path2 = "/e/f/";
String d = path2 + s;
String cmd2 = "mkdir" + " " + path2 + s;
((ChannelExec)channel).setCommand(cmd2);
String src = p + "/" + file;
String cmd3 = "cp" + " " + path + s1 + "/" + file + " " + path2 + s;
((ChannelExec)channel).setCommand(cmd3);
String destpath = d + "/" + file;
String cmd4 = "cat" + " " + path2 + s + "/" + file;
| 0debug |
How can I find the version of .NET run-time programmatically? : <p>I need a solution to give me the <em>.NET</em> run-time version of both the full framework as well as the <em>.NET Core</em>.</p>
<p>On a machine with the following <em>.NET</em> versions:</p>
<pre><code>Full: 4.7.2
Core: 2.1.104
</code></pre>
<p>Running:</p>
<pre><code>RuntimeInformation.FrameworkDescription
</code></pre>
<p>Gives me:</p>
<pre><code>Full: .NET Framework 4.7.2558.0
Core: .NET Core 4.6.26212.01
</code></pre>
<p>Running:</p>
<pre><code>Environment.Version
</code></pre>
<p>Gives me: </p>
<pre><code>Full: 4.0.30319.42000
Core: 4.0.30319.42000
</code></pre>
<p>How can I accurately get the run-time versions across different platforms knowing that the registry option is not available outside <em>Windows</em>.</p>
| 0debug |
What are the benefits of only_full_group_by mode? : <p>I updated mysql and I went from MySQL Version 5.6.17 to version 5.7.14</p>
<p>Since I have errors on my sql queries</p>
<p>Indeed, many of my queries look like this:</p>
<pre><code>SELECT count (id) as nbr, lic from prep WHERE key = '18'
</code></pre>
<p>And I have this error:</p>
<blockquote>
<p>1140 - In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'operator.preparation.orig_lic';
this is incompatible with sql_mode=only_full_group_by</p>
</blockquote>
<p>After some research, I learn that Mysql 5.7.14 activates ONLY_FULL_GROUP_BY by default</p>
<p>Why is it enabled by default?</p>
<p>What is the best solution (for performance)? Disable ONLY_FULL_GROUP_BY or add a 'group by' on my query?</p>
<p>Thank you</p>
| 0debug |
document.write('<script src="evil.js"></script>'); | 1threat |
static void dp8393x_writew(void *opaque, target_phys_addr_t addr, uint32_t val)
{
dp8393xState *s = opaque;
int reg;
if ((addr & ((1 << s->it_shift) - 1)) != 0) {
return;
}
reg = addr >> s->it_shift;
write_register(s, reg, (uint16_t)val);
}
| 1threat |
void ioinst_handle_rchp(S390CPU *cpu, uint64_t reg1)
{
int cc;
uint8_t cssid;
uint8_t chpid;
int ret;
CPUS390XState *env = &cpu->env;
if (RCHP_REG1_RES(reg1)) {
program_interrupt(env, PGM_OPERAND, 2);
return;
}
cssid = RCHP_REG1_CSSID(reg1);
chpid = RCHP_REG1_CHPID(reg1);
trace_ioinst_chp_id("rchp", cssid, chpid);
ret = css_do_rchp(cssid, chpid);
switch (ret) {
case -ENODEV:
cc = 3;
break;
case -EBUSY:
cc = 2;
break;
case 0:
cc = 0;
break;
default:
program_interrupt(env, PGM_OPERAND, 2);
return;
}
setcc(cpu, cc);
}
| 1threat |
Contains dont Work as I expected : I'm wondering why I cannot compare this objects
public class myCustomClass
{
public string Value { get; set; }
public List<string> Keys { get; set; }
}
And i receve an List<myCustomClass>
I created an comparer and lookslike
var comparer = new MyQueryStringInfo {
Value = "somethingToCompare"
};
Ande When I do `attrOptions.Contains(comparer)` is false.
My question is can i only compare if my value exist inside my List, without compare my Keys? | 0debug |
how to create background service which constantly check GPS status? : For My Application GPS IS require constantly.
if GPS is turn off then i want to show prompt message to user to turn on GPS.
how should i use back ground service to perform this task. | 0debug |
How to change a html page from flask to Django : <p>I am working on an app that requires changing a flask template to that of Django.How to change the url_for('function') in the html page</p>
| 0debug |
I just want input as number in prompt box of js : is it possible?
and if yes how?
can we customize a prompt box in javascript.
and can we customize such tha it takes time as input.
`var r = prompt("ENTER THE NUMBER OF SECONDS AFTER WHICH YOU WANT TO BE REMINDED");` | 0debug |
Showing progress while waiting for all Tasks in List<Task> to complete : <p>I'm currently trying to continuously print dots at the end of a line as a form of indeterminate progress, while a large list of Tasks are running, with this code:</p>
<pre><code>start = DateTime.Now;
Console.Write("*Processing variables");
Task entireTask = Task.WhenAll(tasks);
Task progress = new Task(() => { while (!entireTask.IsCompleted) { Console.Write("."); System.Threading.Thread.Sleep(1000); } });
progress.Start();
entireTask.Wait();
timeDiff = DateTime.Now - start;
Console.WriteLine("\n*Operation completed in {0} seconds.", timeDiff.TotalSeconds);
</code></pre>
<p>Where <code>tasks</code> is from <code>List<Task> tasks = new List<Task>();</code>, <br>
and <code>tasks.Add(Task.Run(() => someMethodAsync()));</code> has occurred 10000's of times. <br>
This code currently works, however, is this the correct way of accomplishing this, and is this the most cost-effective way?</p>
| 0debug |
What is this time format? "2019-03-31T08:29:00" : <p>I am trying to determine what time format is this string "<strong>2019-03-31T08:29:00</strong>" so I can convert it to datetime object but I can't find the answer to this.</p>
<p>Can somebody help please?</p>
| 0debug |
static av_cold int hevc_decode_free(AVCodecContext *avctx)
{
HEVCContext *s = avctx->priv_data;
HEVCLocalContext *lc = s->HEVClc;
int i;
pic_arrays_free(s);
av_freep(&lc->edge_emu_buffer);
av_freep(&s->md5_ctx);
for(i=0; i < s->nals_allocated; i++) {
av_freep(&s->skipped_bytes_pos_nal[i]);
}
av_freep(&s->skipped_bytes_pos_size_nal);
av_freep(&s->skipped_bytes_nal);
av_freep(&s->skipped_bytes_pos_nal);
av_freep(&s->cabac_state);
av_frame_free(&s->tmp_frame);
av_frame_free(&s->output_frame);
for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
ff_hevc_unref_frame(s, &s->DPB[i], ~0);
av_frame_free(&s->DPB[i].frame);
}
for (i = 0; i < FF_ARRAY_ELEMS(s->vps_list); i++)
av_freep(&s->vps_list[i]);
for (i = 0; i < FF_ARRAY_ELEMS(s->sps_list); i++)
av_buffer_unref(&s->sps_list[i]);
for (i = 0; i < FF_ARRAY_ELEMS(s->pps_list); i++)
av_buffer_unref(&s->pps_list[i]);
av_freep(&s->sh.entry_point_offset);
av_freep(&s->sh.offset);
av_freep(&s->sh.size);
for (i = 1; i < s->threads_number; i++) {
lc = s->HEVClcList[i];
if (lc) {
av_freep(&lc->edge_emu_buffer);
av_freep(&s->HEVClcList[i]);
av_freep(&s->sList[i]);
}
}
av_freep(&s->HEVClcList[0]);
for (i = 0; i < s->nals_allocated; i++)
av_freep(&s->nals[i].rbsp_buffer);
av_freep(&s->nals);
s->nals_allocated = 0;
return 0;
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.