problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Subset DF by Unique Data Values for Factors in R : I am trying to filter a dataframe in which I have three columns, the 1st one is the date in format: "day/month/year", the 2nd one is the client name, and the 3rd one is the client spending on an specific product, I want to filter this df so I could get only the newest data purchase by client
Is there any way I could do this?
| 0debug
|
my php username line is not checking if the username already exist in my db : i used this line of code to check if the username already exist in my database
if the user does not exist it creates it if it does echo 'username alrady exist'
if(!DB::query('SELECT username FROM users WHERE username=:username', array(':username'=>$username))){
//create user
DB::query('INSERT INTO users VALUES (null, :username, :password, :email)', array(':username'=>$username, ':password'=>password_hash($password, PASSWORD_BCRYPT), ':email'=>$email));
echo "SUCCESS!";
}ELSE{
echo 'USER ALREADY EXIST';
}
}
| 0debug
|
Jquery Filer adding header : <p>We have following problem, we really need to add header in object (uploadFile) : and we can't recive it..</p>
<pre><code>uploadFile: {
url: SERWER+"person/offer/photo/upload",
data: null,
type: 'POST',
enctype: 'multipart/form-data',
synchron: true,
headers : {
'X-Auth-Token' : localStorage.getItem('X-Auth-Token')
},
success: function(data, itemEl, listEl, boxEl, newInputEl, inputEl, id){
console.log(data);
</code></pre>
<p>It doesn't work :(</p>
| 0debug
|
Is this battery compatible with the Node MCU ESP8266? : <p>Is this <a href="https://rads.stackoverflow.com/amzn/click/com/B01N74S3LO" rel="nofollow noreferrer" rel="nofollow noreferrer">battery</a> compatible with this <a href="https://rads.stackoverflow.com/amzn/click/com/B010O1G1ES" rel="nofollow noreferrer" rel="nofollow noreferrer">NodeMCU ESP8266</a>
?</p>
<p>More details; it was recommended to use this <a href="https://www.amazon.com/s/ref=nb_sb_ss_i_2_7?tag=shrikant06-20&url=search-alias%3Daps&field-keywords=3.7v%20lipo%20battery&sprefix=3.7v%20li%2Caps%2C573&crid=3EZ5X0GQYE3Z0&rh=i%3Aaps%2Ck%3A3.7v%20lipo%20battery" rel="nofollow noreferrer">page</a> to get a battery to power the Node ESP8266 but I'm not sure which models are compatible. </p>
| 0debug
|
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
| 1threat
|
An in app tutorial or walkthrough for a game : <p>I am looking for a way to implement a walkthrough into my android app. I want it to take the player through the first steps in getting started, it's just impossible to search without getting how to make an app tutorials. Any help and tips are appreciated.</p>
| 0debug
|
static void icount_adjust_rt(void *opaque)
{
timer_mod(icount_rt_timer,
qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL_RT) + 1000);
icount_adjust();
}
| 1threat
|
why cannot extract spring boot executable jar : <p>spring boot project, build as a executable jar, but I found cannot extract the executable jar, e.g.</p>
<pre><code>jar xvf spring-boot-foo-0.0.1-SNAPSHOT.jar
</code></pre>
<p>nothing output.
But when extract a normal jar, it is successful</p>
<pre><code>jar xvf mysql-connector-java-5.1.38.jar
created: META-INF/
inflated: META-INF/MANIFEST.MF
created: META-INF/services/
...
</code></pre>
<p>why is this?</p>
| 0debug
|
adding columns with two data types in sql server : [i need to achieve the output like this can anyone please help me. thanks in advance][1]
[1]: https://i.stack.imgur.com/2atrZ.png
| 0debug
|
iOS & Android App Download : We have publish app in iOS & Android store last year. When I go to the google play store I can see 50,000 to 100,000 App downloads. But how can I know how much exact number of apps are downloaded. Kindly can somebody help me. How to check.
Please note I have username & password for both iOS & Android developer account.
| 0debug
|
Stop PHP from echoing specific tags (but still echo others) : <p>I've been wondering if it's possible to "blacklist" specific HTML tags from printing (but <em>still</em> allow other tags to echo, so not strip_tags).</p>
<p>So basically, if I wanted to block the <code>h1</code> tag, instead of:</p>
<h1>Hello World</h1>
<p>My code would echo out:</p>
<pre><code><h1>Hello World</h1>
</code></pre>
<p>Any of you guys know if it's possible, and if it is, what should I do to achieve this?</p>
| 0debug
|
static int find_pte32 (mmu_ctx_t *ctx, int h, int rw)
{
return _find_pte(ctx, 0, h, rw);
}
| 1threat
|
What are the platforms in the .NET Platform Standard? : <p>Currently trying to learn about the .NET Platform Standard I've found myself quite confused about the idea of "different platforms". </p>
<p>I'll try to make my point clear. What I currently now about the .NET Framework is that .NET is roughly speaking made up of the CLR, the BCL and supporting software to boot the CLR and provide the interface between the virtual machine and the underlying OS.</p>
<p>So when we code using the .NET Framework we indeed target some version of the framework because the types we are using from the BCL come with the framework and so depend on the specific version.</p>
<p>Now, .NET Core is quite different as I understood. It is not all packed together like that. We have the CoreCLR which is a lightweight VM to run the IL, the CoreFX which are the libraries properly organized as NuGet packages and we had up to now the DNX/DNVM/DNU which provided the supporting stuff like booting the CoreCLR and interfacing with the OS.</p>
<p>Anyway, despite if we install the framework on Windows 7, Windows 8 or Windows 10, we code <em>against the framework</em>.</p>
<p>Now, on the .NET Platform Standard spec we see the following definition:</p>
<blockquote>
<p>Platform - e.g. .NET Framework 4.5, .NET Framework 4.6, Windows Phone 8.1, MonoTouch, UWP, etc.</p>
</blockquote>
<p>Also we see after that a list of platforms, which includes </p>
<ul>
<li>.NET Framework 2.0 - 4.6</li>
<li>Windows 8</li>
<li>Windows Phone 8.1</li>
<li>Silverlight 4, 5</li>
<li>DNX on .NET Framework 4.5.1 - 4.6</li>
<li>DNX on .NET Core 5.0</li>
</ul>
<p>Now this confuses me completely. I always though: we code against the .NET Framework and the framework is the framework no matter what. </p>
<p>But here we have these platforms which includes the .NET framework as just <em>one of many platforms</em>. We have for example Windows 8, but wait a minute, running .NET on Windows 8 is not just the same thing as running .NET on any other OS? Why it is separate from the .NET Framework 2.0 - 4.6 platform?</p>
<p>We also have DNX as a specific platform. This makes me wonder: the platform is that "supporting stuff" related to booting the Virtual Machine and providing the interface with the OS? Or the platform includes the Virtual Machine?</p>
<p>Anyway, as can be seen I'm quite confused. What are those platforms indeed and how this relates to my current understanding of the .NET Framework? Also, why .NET Framework 2.0 - 4.6 is described separetely? Isn't <em>everything</em> described here some version of .NET Framework unless .NET Core?</p>
| 0debug
|
Python list ways to select objects : <p>I have three lists: <code>[A, B, C]</code>, <code>[1]</code>, <code>[x,y]</code>.</p>
<p>How to generate the following with python:</p>
<p><code>[A,1,x]</code>, <code>[A,1,y]</code>, <code>[B,1,x]</code>, <code>[B,1,y]</code>, <code>[C,1,x]</code>, <code>[C,1,y]</code></p>
| 0debug
|
Why it is showing false when i insert 3 or more than 3 characters after s? : import java.util.regex.*;
import java.util.*;
class RegexEx
{
public static void main(String[] args)
{
String name=new String();
Scanner s=new Scanner(System.in);
System.out.print("\n\nEnter Name : ");
name=s.next();
System.out.println(Pattern.matches("[s][a-zA-Z]",name));
if(Pattern.matches("[s][a-zA-Z]",name))
{
System.out.println("\nValid Name");
}
else
{
System.out.println("\nInValid Name");
}
}
}
cmd:
C:\Users\student\Desktop>javac RegexEx.java
C:\Users\student\Desktop>java RegexEx
Enter Name : s
false
InValid Name
C:\Users\student\Desktop>java RegexEx
Enter Name : sa
true
Valid Name
C:\Users\student\Desktop>java RegexEx
Enter Name : sam
false
InValid Name
C:\Users\student\Desktop>
| 0debug
|
void main_loop_wait(int timeout)
{
IOHandlerRecord *ioh;
fd_set rfds, wfds, xfds;
int ret, nfds;
#ifdef _WIN32
int ret2, i;
#endif
struct timeval tv;
PollingEntry *pe;
ret = 0;
for(pe = first_polling_entry; pe != NULL; pe = pe->next) {
ret |= pe->func(pe->opaque);
}
#ifdef _WIN32
if (ret == 0) {
int err;
WaitObjects *w = &wait_objects;
ret = WaitForMultipleObjects(w->num, w->events, FALSE, timeout);
if (WAIT_OBJECT_0 + 0 <= ret && ret <= WAIT_OBJECT_0 + w->num - 1) {
if (w->func[ret - WAIT_OBJECT_0])
w->func[ret - WAIT_OBJECT_0](w->opaque[ret - WAIT_OBJECT_0]);
for(i = (ret - WAIT_OBJECT_0 + 1); i < w->num; i++) {
ret2 = WaitForSingleObject(w->events[i], 0);
if(ret2 == WAIT_OBJECT_0) {
if (w->func[i])
w->func[i](w->opaque[i]);
} else if (ret2 == WAIT_TIMEOUT) {
} else {
err = GetLastError();
fprintf(stderr, "WaitForSingleObject error %d %d\n", i, err);
}
}
} else if (ret == WAIT_TIMEOUT) {
} else {
err = GetLastError();
fprintf(stderr, "WaitForMultipleObjects error %d %d\n", ret, err);
}
}
#endif
nfds = -1;
FD_ZERO(&rfds);
FD_ZERO(&wfds);
FD_ZERO(&xfds);
for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) {
if (ioh->deleted)
continue;
if (ioh->fd_read &&
(!ioh->fd_read_poll ||
ioh->fd_read_poll(ioh->opaque) != 0)) {
FD_SET(ioh->fd, &rfds);
if (ioh->fd > nfds)
nfds = ioh->fd;
}
if (ioh->fd_write) {
FD_SET(ioh->fd, &wfds);
if (ioh->fd > nfds)
nfds = ioh->fd;
}
}
tv.tv_sec = 0;
#ifdef _WIN32
tv.tv_usec = 0;
#else
tv.tv_usec = timeout * 1000;
#endif
#if defined(CONFIG_SLIRP)
if (slirp_inited) {
slirp_select_fill(&nfds, &rfds, &wfds, &xfds);
}
#endif
ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv);
if (ret > 0) {
IOHandlerRecord **pioh;
for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) {
if (!ioh->deleted && ioh->fd_read && FD_ISSET(ioh->fd, &rfds)) {
ioh->fd_read(ioh->opaque);
}
if (!ioh->deleted && ioh->fd_write && FD_ISSET(ioh->fd, &wfds)) {
ioh->fd_write(ioh->opaque);
}
}
pioh = &first_io_handler;
while (*pioh) {
ioh = *pioh;
if (ioh->deleted) {
*pioh = ioh->next;
qemu_free(ioh);
} else
pioh = &ioh->next;
}
}
#if defined(CONFIG_SLIRP)
if (slirp_inited) {
if (ret < 0) {
FD_ZERO(&rfds);
FD_ZERO(&wfds);
FD_ZERO(&xfds);
}
slirp_select_poll(&rfds, &wfds, &xfds);
}
#endif
qemu_aio_poll();
if (vm_running) {
if (likely(!(cur_cpu->singlestep_enabled & SSTEP_NOTIMER)))
qemu_run_timers(&active_timers[QEMU_TIMER_VIRTUAL],
qemu_get_clock(vm_clock));
DMA_run();
}
qemu_run_timers(&active_timers[QEMU_TIMER_REALTIME],
qemu_get_clock(rt_clock));
if (alarm_timer->flags & ALARM_FLAG_EXPIRED) {
alarm_timer->flags &= ~(ALARM_FLAG_EXPIRED);
qemu_rearm_alarm_timer(alarm_timer);
}
qemu_bh_poll();
}
| 1threat
|
Android Studio How to get Stings from Fragment to Activity : I have an app that works with Stings but I doesn*t know how to send String from a Fragment to an Activity.
Please help me
| 0debug
|
Linq: count by range : <p>Please help me to create a linq query. I have a class</p>
<pre><code>class Person
{
string name;
int age;
}
</code></pre>
<p>I need to group a list of Persons by age ranges (0 to 10, 10 to 20, ... 90 to 100) and count a number of persons for each range. Also I want to filter the list by name. For example, get a number of men called "John" for each age range.
Thanks. </p>
| 0debug
|
static int vnc_display_get_address(const char *addrstr,
bool websocket,
bool reverse,
int displaynum,
int to,
bool has_ipv4,
bool has_ipv6,
bool ipv4,
bool ipv6,
SocketAddressLegacy **retaddr,
Error **errp)
{
int ret = -1;
SocketAddressLegacy *addr = NULL;
addr = g_new0(SocketAddressLegacy, 1);
if (strncmp(addrstr, "unix:", 5) == 0) {
addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
addr->u.q_unix.data->path = g_strdup(addrstr + 5);
if (websocket) {
error_setg(errp, "UNIX sockets not supported with websock");
goto cleanup;
}
if (to) {
error_setg(errp, "Port range not support with UNIX socket");
goto cleanup;
}
ret = 0;
} else {
const char *port;
size_t hostlen;
unsigned long long baseport = 0;
InetSocketAddress *inet;
port = strrchr(addrstr, ':');
if (!port) {
if (websocket) {
hostlen = 0;
port = addrstr;
} else {
error_setg(errp, "no vnc port specified");
goto cleanup;
}
} else {
hostlen = port - addrstr;
port++;
if (*port == '\0') {
error_setg(errp, "vnc port cannot be empty");
goto cleanup;
}
}
addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
inet = addr->u.inet.data = g_new0(InetSocketAddress, 1);
if (addrstr[0] == '[' && addrstr[hostlen - 1] == ']') {
inet->host = g_strndup(addrstr + 1, hostlen - 2);
} else {
inet->host = g_strndup(addrstr, hostlen);
}
if (websocket) {
if (g_str_equal(addrstr, "") ||
g_str_equal(addrstr, "on")) {
if (displaynum == -1) {
error_setg(errp, "explicit websocket port is required");
goto cleanup;
}
inet->port = g_strdup_printf(
"%d", displaynum + 5700);
if (to) {
inet->has_to = true;
inet->to = to + 5700;
}
} else {
inet->port = g_strdup(port);
}
} else {
int offset = reverse ? 0 : 5900;
if (parse_uint_full(port, &baseport, 10) < 0) {
error_setg(errp, "can't convert to a number: %s", port);
goto cleanup;
}
if (baseport > 65535 ||
baseport + offset > 65535) {
error_setg(errp, "port %s out of range", port);
goto cleanup;
}
inet->port = g_strdup_printf(
"%d", (int)baseport + offset);
if (to) {
inet->has_to = true;
inet->to = to + offset;
}
}
inet->ipv4 = ipv4;
inet->has_ipv4 = has_ipv4;
inet->ipv6 = ipv6;
inet->has_ipv6 = has_ipv6;
ret = baseport;
}
*retaddr = addr;
cleanup:
if (ret < 0) {
qapi_free_SocketAddressLegacy(addr);
}
return ret;
}
| 1threat
|
int ff_h264_fill_default_ref_list(H264Context *h)
{
int i, len;
if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
Picture *sorted[32];
int cur_poc, list;
int lens[2];
if (FIELD_PICTURE(h))
cur_poc = h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD];
else
cur_poc = h->cur_pic_ptr->poc;
for (list = 0; list < 2; list++) {
len = add_sorted(sorted, h->short_ref, h->short_ref_count, cur_poc, 1 ^ list);
len += add_sorted(sorted + len, h->short_ref, h->short_ref_count, cur_poc, 0 ^ list);
assert(len <= 32);
len = build_def_list(h->default_ref_list[list], sorted, len, 0, h->picture_structure);
len += build_def_list(h->default_ref_list[list] + len, h->long_ref, 16, 1, h->picture_structure);
assert(len <= 32);
if (len < h->ref_count[list])
memset(&h->default_ref_list[list][len], 0, sizeof(Picture) * (h->ref_count[list] - len));
lens[list] = len;
}
if (lens[0] == lens[1] && lens[1] > 1) {
for (i = 0; h->default_ref_list[0][i].f.data[0] == h->default_ref_list[1][i].f.data[0] && i < lens[0]; i++);
if (i == lens[0]) {
Picture tmp;
COPY_PICTURE(&tmp, &h->default_ref_list[1][0]);
COPY_PICTURE(&h->default_ref_list[1][0], &h->default_ref_list[1][1]);
COPY_PICTURE(&h->default_ref_list[1][1], &tmp);
}
}
} else {
len = build_def_list(h->default_ref_list[0], h->short_ref, h->short_ref_count, 0, h->picture_structure);
len += build_def_list(h->default_ref_list[0] + len, h-> long_ref, 16, 1, h->picture_structure);
assert(len <= 32);
if (len < h->ref_count[0])
memset(&h->default_ref_list[0][len], 0, sizeof(Picture) * (h->ref_count[0] - len));
}
#ifdef TRACE
for (i = 0; i < h->ref_count[0]; i++) {
tprintf(h->avctx, "List0: %s fn:%d 0x%p\n",
(h->default_ref_list[0][i].long_ref ? "LT" : "ST"),
h->default_ref_list[0][i].pic_id,
h->default_ref_list[0][i].f.data[0]);
}
if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
for (i = 0; i < h->ref_count[1]; i++) {
tprintf(h->avctx, "List1: %s fn:%d 0x%p\n",
(h->default_ref_list[1][i].long_ref ? "LT" : "ST"),
h->default_ref_list[1][i].pic_id,
h->default_ref_list[1][i].f.data[0]);
}
}
#endif
return 0;
}
| 1threat
|
How to make an installable .Net console app : <p>How can I make my console app installable so that when I open CMD I can run it from anywhere with a keyword. Like when I type in <code>git</code> in cmd for example. Thanks.</p>
| 0debug
|
the using system and attribute don't appear in their right color instead they appear in light blue. what does that mean? : [class Book[\]\[1\]][1]
[class program][2]
[1]: https://i.stack.imgur.com/WeOOb.png
[2]: https://i.stack.imgur.com/nfGv8.png
this is the code, I've tried rewriting it in a new program but its the same problem as soon as I create a class the "using system" and the others appear in light blue as well as attributes
| 0debug
|
Having trouble understanding "/n" in python : I dunno whats the purpose of this `/n` in `python`
Here is an example shown below:
rangeNum = int(raw_input("Enter the max number you'd like to go up to: \n"))
| 0debug
|
Does require('foo') try to load a file named 'foo' first or 'foo.js' first? : Quoting from the article at <https://medium.freecodecamp.org/requiring-modules-in-node-js-everything-you-need-to-know-e7fbd119be8> below:
> We can natively require JSON files and C++ addon files with the require function. You don’t even need to specify a file extension to do so.
> If a file extension was not specified, the first thing Node will try to resolve is a `.js` file. If it can’t find a `.js` file, it will try a `.json` file and it will parse the `.json` file if found as a JSON text file. After that, it will try to find a binary `.node` file. However, to remove ambiguity, you should probably specify a file extension when requiring anything other than `.js` files.
Here is my little experiment that seems to contradict what is written above.
$ cat foo.js
console.log('I am foo.js!')
require('./bar')
$ cat bar.js
console.log('I am bar.js!')
$ cat bar
console.log('I am bar!')
$ node foo.js
I am foo.js!
I am bar!
$ node bar
I am bar!
The experiment shows that if I do not specify the `.js` extension name, i.e. I import only `bar` or try to run only `bar`, then the first thing Node tries to do is to find a file named exactly as `bar`. Therefore, it contradicts the following statement from the quoted article.
> If a file extension was not specified, the first thing Node will try to resolve is a `.js` file.
Is the quoted article incorrect or am I misunderstanding something?
| 0debug
|
React Navigation how to hide tabbar from inside stack navigation : <p>I have the following stack navigation and screens:</p>
<pre><code>export const HomeStack = createStackNavigator({
Home: HomeScreen,
Categories: CategoriesScreen,
Products: ProductsScreen,
ProductDetails: ProductDetailsScreen,
})
</code></pre>
<p>I want to hide tabs only in ProductDetailsScreen</p>
<pre><code>export const hideTabBarComponents = [
'ProductDetails',
]
export const MainTabs = createBottomTabNavigator(
{
Home: HomeStack,
Favorite: FavoriteScreen,
Account: AccountScreen,
Help: HelpScreen,
Events: EventsScreen
},
{
navigationOptions: ({ navigation }) => ({
tabBarIcon: ({ focused, tintColor }) => {
...
},
tabBarLabel: ({ focused, tintColor }) => {
...
},
tabBarVisible: ! hideTabBarComponents.includes(navigation.state.routeName)
}),
}
);
</code></pre>
<p>The problem that can't pass any options to Tab navigation from Stack Navigation</p>
<p><strong>Not all of the stack screens only one of them</strong> </p>
| 0debug
|
Double message on ios when get geolocation : <p>I have created an ios app (Xcode) with a single WebKit View component that loads an external website. This website tries to get the current geolocation with this Javascript: <code>navigator.geolocation</code>.</p>
<p>This all works fine, but the problem is, I get 2 messages:</p>
<ol>
<li>First a message for the app: 'Allow "NameApp" to access your location while you are using the app?'</li>
<li>Second a message for the webview: '<a href="https://mywebsite.com" rel="noreferrer">https://mywebsite.com</a> would like to use your current location'.</li>
</ol>
<p>I have seen similar questions about this issue, but they all went about a native/offline Cordova app. I have an online app in my Webview.</p>
<p>How can I prevent this double message? Or a workaround for this problem?</p>
| 0debug
|
Python/Flask web development : <p>I using flask web development to create a mini-web with python 2.7.</p>
<pre><code>import settings
from flask import Flask, render_template
app = Flask(__name__)
app.config.from_object(settings)
@app.route("/")
def hello():
return "Hello World!"
@app.route("/login")
def login_template():
return render_template("login.html")
if __name__=="__main__":
app.run()
</code></pre>
<p>The <code>@app.route("/")</code> is working perfectly fine but i got an error in <code>@app.route("/login")</code> because im tryng to <code>render_template("login.html")</code>.</p>
<p>The file is in a directory <code>/templates/login.html</code> in the same working directory</p>
<p>I got this error:</p>
<p><a href="https://i.gyazo.com/761c169e0d55de45e3dd6c7af346c48c.png" rel="nofollow">https://i.gyazo.com/761c169e0d55de45e3dd6c7af346c48c.png</a></p>
<p><a href="https://i.gyazo.com/571c079b44c6216612c16798d57d200a.png" rel="nofollow">https://i.gyazo.com/571c079b44c6216612c16798d57d200a.png</a></p>
| 0debug
|
How do I extract a javascript variable from a .js file with python? : <p>I'm trying to extract the JSON data in the variable chartData. This is stored in a .js file which generates a chart for my solar system. I want to extract this data so i can store it in a separate database.</p>
<p>However I cant seem to find a way how to extract the JSON data with python.</p>
<p>This is the .js file.</p>
<pre><code>var chartData =
{
"labels":
[
"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"],
"datasets":
[
{
"strokeColor":" rgba(64,178,83,1.0)",
"fillColor":" rgba(64,178,83,.5)",
"data": [
15.101000,9.819000,9.966000,19.634000,18.403000,17.015000,20.356000,20.645000,5.443000,14.542000,13.513000,9.774000,15.053000,16.870000,10.582000,
15.139000,7.230000,9.019000,18.687000,16.074000,17.183000,23.353000,22.248000,22.762000,22.458000,20.809000,18.034000,12.810000,15.627000,21.057000,
19.589000]
}
]
}
var max = 25;
var steps = 5;
var input = document.getElementById("inputId");
input.setAttribute("min", "2019-02");
input.setAttribute("max", "2020-01");
input.setAttribute("value", "2019-08");
document.getElementById("labelValueId").innerHTML = " 498.812kWh 08.2019";
document.getElementById("buttonPrevId").disabled = false;
document.getElementById("buttonNextId").disabled = false;
var myBar = new Chart(document.getElementById("canvasId")
.getContext("2d"))
.Bar(chartData,
{
"pointDot": false,
"datasetFill": false,
"scaleOverride": true,
"scaleLabel": "<%=value%> kWh",
"scaleSteps": steps,
"scaleStartValue": 0,
"scaleStepWidth": Math.ceil(max / steps),
"scaleLineColor":" rgba(170,170,170,1.0)",
"scaleFontColor":" rgba(170,170,170,1.0)",
"scaleGridLineColor":" rgba(68,68,68,1.0)"});
</code></pre>
| 0debug
|
document.write('<script src="evil.js"></script>');
| 1threat
|
static void v9fs_renameat(void *opaque)
{
ssize_t err = 0;
size_t offset = 7;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
int32_t olddirfid, newdirfid;
V9fsString old_name, new_name;
pdu_unmarshal(pdu, offset, "dsds", &olddirfid,
&old_name, &newdirfid, &new_name);
v9fs_path_write_lock(s);
err = v9fs_complete_renameat(pdu, olddirfid,
&old_name, newdirfid, &new_name);
v9fs_path_unlock(s);
if (!err) {
err = offset;
}
complete_pdu(s, pdu, err);
v9fs_string_free(&old_name);
v9fs_string_free(&new_name);
}
| 1threat
|
Want to Implement Chat Feature in my android app is there any library or sdk i can use ? or i have to code it all myself? : <p>i just don't know where to get started.<br>
i am making a college project in which students can discuss problems with other students or with teacher may be its like a post in Facebook and commenting below that post .</p>
| 0debug
|
static int thread_execute(AVCodecContext *avctx, action_func* func, void *arg, int *ret, int job_count, int job_size)
{
SliceThreadContext *c = avctx->internal->thread_ctx;
int dummy_ret;
if (!(avctx->active_thread_type&FF_THREAD_SLICE) || avctx->thread_count <= 1)
return avcodec_default_execute(avctx, func, arg, ret, job_count, job_size);
if (job_count <= 0)
return 0;
pthread_mutex_lock(&c->current_job_lock);
c->current_job = avctx->thread_count;
c->job_count = job_count;
c->job_size = job_size;
c->args = arg;
c->func = func;
if (ret) {
c->rets = ret;
c->rets_count = job_count;
} else {
c->rets = &dummy_ret;
c->rets_count = 1;
}
c->current_execute++;
pthread_cond_broadcast(&c->current_job_cond);
thread_park_workers(c, avctx->thread_count);
return 0;
}
| 1threat
|
Task.Factory.StartNew() return thread to thread pool : <p>In this implementation <code>Task.Factory.StartNew</code> will never return thread to thread pool because it contains while(true) with Thread.Sleep. Is it right? How to check <code>queue</code> that it has task that need to be done?</p>
<pre><code>namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Helper h = new Helper();
PlayWithQueue s = new PlayWithQueue();
s.AddToQueueForExecution(() => { h.Indicate(1); });
s.AddToQueueForExecution(() => { h.Indicate(2); });
s.AddToQueueForExecution(() => { h.Indicate(3); });
s.AddToQueueForExecution(() => { h.Indicate(4); });
s.AddToQueueForExecution(() => { h.Indicate(5); });
s.AddToQueueForExecution(() => { h.Indicate(6); });
Console.ReadKey();
}
}
public class PlayWithQueue
{
private readonly ConcurrentQueue<Action> queue = new ConcurrentQueue<Action>();
public PlayWithQueue()
{
var task = Task.Factory.StartNew(ThreadProc);
}
public void AddToQueueForExecution(Action action)
{
queue.Enqueue(action);
}
private void ThreadProc()
{
while (true)
{
Action item;
bool isSuccessfull = false;
isSuccessfull = queue.TryDequeue(out item);
if (isSuccessfull)
{
item();
}
System.Threading.Thread.Sleep(100);
}
}
}
public class Helper
{
public void Indicate(int number)
{
Random rnd = new Random();
int timeDelay = rnd.Next(1000, 5000);
Console.WriteLine("Start" + number.ToString());
System.Threading.Thread.Sleep(timeDelay);
Console.WriteLine("End" + number.ToString() + " " + timeDelay.ToString());
}
}
}
</code></pre>
| 0debug
|
static int nbd_negotiate_send_rep_len(QIOChannel *ioc, uint32_t type,
uint32_t opt, uint32_t len, Error **errp)
{
uint64_t magic;
trace_nbd_negotiate_send_rep_len(opt, type, len);
magic = cpu_to_be64(NBD_REP_MAGIC);
if (nbd_write(ioc, &magic, sizeof(magic), errp) < 0) {
error_prepend(errp, "write failed (rep magic): ");
return -EINVAL;
}
opt = cpu_to_be32(opt);
if (nbd_write(ioc, &opt, sizeof(opt), errp) < 0) {
error_prepend(errp, "write failed (rep opt): ");
return -EINVAL;
}
type = cpu_to_be32(type);
if (nbd_write(ioc, &type, sizeof(type), errp) < 0) {
error_prepend(errp, "write failed (rep type): ");
return -EINVAL;
}
len = cpu_to_be32(len);
if (nbd_write(ioc, &len, sizeof(len), errp) < 0) {
error_prepend(errp, "write failed (rep data length): ");
return -EINVAL;
}
return 0;
}
| 1threat
|
how to Import Excel sheet in datagridview in C# : while i am trying to import data from excel some data of my excel sheet is missing in datagridviewa
[excel sheet][1]
[Data GridView][2]
[1]: http://i.stack.imgur.com/ero7B.png
[2]: http://i.stack.imgur.com/99G1X.png
| 0debug
|
Xcode 8 Warning: no rule to process file of type net.daringfireball.markdown for architecture x86_64 : <p>I get the above warning in Xcode 8 for a CHANGELOG.md file in my cocoapod source. How do I clear it?</p>
| 0debug
|
Simplify the following method : <p>The following method needs simplification so that lines become relatively small.</p>
<pre><code> def rep(m):
if m.group(0) == " " or m.group(0) == "_":
return "[ _]"
elif m.group(0) == "(" or m.group(0) == ")" or m.group(0) == "*" or m.group(0) == "+" or m.group(0) == "=" or m.group(0) == "?" or m.group(0) == "!" or m.group(0) == "^" or m.group(0) == "-":
return "\\" + m.group(0)
return re.sub(r"[ _()*+=?!^-]", rep, s)
</code></pre>
| 0debug
|
void *cpu_register_map_client(void *opaque, void (*callback)(void *opaque))
{
MapClient *client = g_malloc(sizeof(*client));
qemu_mutex_lock(&map_client_list_lock);
client->opaque = opaque;
client->callback = callback;
QLIST_INSERT_HEAD(&map_client_list, client, link);
if (!atomic_read(&bounce.in_use)) {
cpu_notify_map_clients_locked();
}
qemu_mutex_unlock(&map_client_list_lock);
return client;
}
| 1threat
|
static void glib_select_poll(fd_set *rfds, fd_set *wfds, fd_set *xfds,
bool err)
{
GMainContext *context = g_main_context_default();
if (!err) {
int i;
for (i = 0; i < n_poll_fds; i++) {
GPollFD *p = &poll_fds[i];
if ((p->events & G_IO_IN) && FD_ISSET(p->fd, rfds)) {
p->revents |= G_IO_IN;
}
if ((p->events & G_IO_OUT) && FD_ISSET(p->fd, wfds)) {
p->revents |= G_IO_OUT;
}
if ((p->events & G_IO_ERR) && FD_ISSET(p->fd, xfds)) {
p->revents |= G_IO_ERR;
}
}
}
if (g_main_context_check(context, max_priority, poll_fds, n_poll_fds)) {
g_main_context_dispatch(context);
}
}
| 1threat
|
static void *circular_buffer_task( void *_URLContext)
{
URLContext *h = _URLContext;
UDPContext *s = h->priv_data;
int old_cancelstate;
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_cancelstate);
ff_socket_nonblock(s->udp_fd, 0);
while(1) {
int left;
int len;
left = av_fifo_space(s->fifo);
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old_cancelstate);
len = recv(s->udp_fd, s->tmp+4, sizeof(s->tmp)-4, 0);
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_cancelstate);
if (len < 0) {
if (ff_neterrno() != AVERROR(EAGAIN) && ff_neterrno() != AVERROR(EINTR)) {
s->circular_buffer_error = AVERROR(EIO);
goto end;
}
continue;
}
AV_WL32(s->tmp, len);
if(left < len + 4) {
if (s->overrun_nonfatal) {
av_log(h, AV_LOG_WARNING, "Circular buffer overrun. "
"Surviving due to overrun_nonfatal option\n");
continue;
} else {
av_log(h, AV_LOG_ERROR, "Circular buffer overrun. "
"To avoid, increase fifo_size URL option. "
"To survive in such case, use overrun_nonfatal option\n");
s->circular_buffer_error = AVERROR(EIO);
goto end;
}
}
pthread_mutex_lock(&s->mutex);
av_fifo_generic_write(s->fifo, s->tmp, len+4, NULL);
pthread_cond_signal(&s->cond);
pthread_mutex_unlock(&s->mutex);
}
end:
pthread_mutex_lock(&s->mutex);
pthread_cond_signal(&s->cond);
pthread_mutex_unlock(&s->mutex);
return NULL;
}
| 1threat
|
static void vmgenid_device_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->vmsd = &vmstate_vmgenid;
dc->realize = vmgenid_realize;
dc->hotpluggable = false;
dc->props = vmgenid_properties;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
object_class_property_add_str(klass, VMGENID_GUID, NULL,
vmgenid_set_guid, NULL);
object_class_property_set_description(klass, VMGENID_GUID,
"Set Global Unique Identifier "
"(big-endian) or auto for random value",
NULL);
}
| 1threat
|
int qsv_init(AVCodecContext *s)
{
InputStream *ist = s->opaque;
QSVContext *qsv = ist->hwaccel_ctx;
AVQSVContext *hwctx_dec;
int ret;
if (!qsv) {
av_log(NULL, AV_LOG_ERROR, "QSV transcoding is not initialized. "
"-hwaccel qsv should only be used for one-to-one QSV transcoding "
"with no filters.\n");
return AVERROR_BUG;
}
ret = init_opaque_surf(qsv);
if (ret < 0)
return ret;
hwctx_dec = av_qsv_alloc_context();
if (!hwctx_dec)
return AVERROR(ENOMEM);
hwctx_dec->session = qsv->session;
hwctx_dec->iopattern = MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
hwctx_dec->ext_buffers = qsv->ext_buffers;
hwctx_dec->nb_ext_buffers = FF_ARRAY_ELEMS(qsv->ext_buffers);
av_freep(&s->hwaccel_context);
s->hwaccel_context = hwctx_dec;
ist->hwaccel_get_buffer = qsv_get_buffer;
ist->hwaccel_uninit = qsv_uninit;
return 0;
}
| 1threat
|
Sql server Row To Columns Data : I have data in a SQL Table with the following structure:
Engine_No Date Process Bolt_No1 B1Value1 B1Value2 B1Value3 Bolt_No2 B2Value1 B2Value2 B2Value3 Bolt_No3 B3Value1 B3Value2 B3Value3 Bolt_No4 B4Value1 B4Value2 B4Value3
I want to display the following results of a query:
Engine_No Date Process Bolt_No1 B1Value1 B1Value2 B1Value3
Engine_No Date Process Bolt_No2 B2Value1 B2Value2 B2Value3
Engine_No Date Process Bolt_No3 B3Value1 B3Value2 B3Value3
Engine_No Date Process Bolt_No4 B4Value1 B4Value2 B4Value3
Can someone suggest a auery that achieves this?
| 0debug
|
PHPMyAdmin - How to Save Queries : <p>Is there a way to get PHPMyAdmin to save the queries that you enter manually through the SQL tab? I don't want it to save every single query it runs for obvious reasons, I just want to be able to save the ones I enter in there, cuz some of them are very useful, and sometimes I forget how I did it afterwards. </p>
| 0debug
|
static void boston_platreg_write(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
if (size != 4) {
qemu_log_mask(LOG_UNIMP, "%uB platform register write", size);
return;
}
switch (addr & 0xffff) {
case PLAT_FPGA_BUILD:
case PLAT_CORE_CL:
case PLAT_WRAPPER_CL:
case PLAT_DDR3_STATUS:
case PLAT_PCIE_STATUS:
case PLAT_MMCM_DIV:
case PLAT_BUILD_CFG:
case PLAT_DDR_CFG:
break;
case PLAT_SOFTRST_CTL:
if (val & PLAT_SOFTRST_CTL_SYSRESET) {
qemu_system_reset_request();
}
break;
default:
qemu_log_mask(LOG_UNIMP, "Write platform register 0x%" HWADDR_PRIx
" = 0x%" PRIx64, addr & 0xffff, val);
break;
}
}
| 1threat
|
Continuous Deployment of a NodeJS using GitLab : <p>I have an API developed in NodeJS and have successfully set up continuous integration via a <code>.gitlab-ci.yml</code> file. The next stage is to set up continuous deployment to Heroku if all tests pass on the master branch.</p>
<p>There are plenty of tutorials covering the deployment of Ruby and Python apps but nothing on NodeJS. Currently my <code>.gitlab-ci.yml</code> file looks like this:</p>
<pre><code>image: node:latest
job1:
script: "ls -l"
test:
script: "npm install;npm test"
production:
type: deploy
script:
- npm install
- npm start
- gem install dpl
- dpl --provider=heroku --app=my-first-nodejs --api-key=XXXXXXXXXX
only:
- master
</code></pre>
<p>The Ruby and Python tutorials use the <code>dpl</code> tool to deploy but how can I start the NodeJS script on the server once deployed?</p>
<p>After adding the production section and pushing it the tests run and pass but the deploy stage gets stuck on pending. The console is blank. Has anyone set up a successful CD script for NodeJS?</p>
| 0debug
|
static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma,
uint64_t offset, uint64_t len)
{
RDMALocalBlock *block;
uint8_t *host_addr;
uint8_t *chunk_end;
if (rdma->current_index < 0) {
return 0;
}
if (rdma->current_chunk < 0) {
return 0;
}
block = &(rdma->local_ram_blocks.block[rdma->current_index]);
host_addr = block->local_host_addr + (offset - block->offset);
chunk_end = ram_chunk_end(block, rdma->current_chunk);
if (rdma->current_length == 0) {
return 0;
}
if (offset != (rdma->current_addr + rdma->current_length)) {
return 0;
}
if (offset < block->offset) {
return 0;
}
if ((offset + len) > (block->offset + block->length)) {
return 0;
}
if ((host_addr + len) > chunk_end) {
return 0;
}
return 1;
}
| 1threat
|
Passing String Java Android : If I have this background worker file in my android application and it gets data from my database how can I pass the string 'result' to another class?
The background worker connects to my server and then using php it connects to a database.
public class BackgroundWorker extends AsyncTask<String,Void,String> {
Context context;
AlertDialog alertDialog;
BackgroundWorker (Context ctx) {
context = ctx;
}
@Override
public String doInBackground(String... params) {
String type = params[0];
String specials_url = "";
if(type.equals("venue click")) {
try {
//String user_name = params[1];
URL url = new URL(specials_url);
HttpURLConnection httpURLConnection =
(HttpURLConnection)url.openConnection();
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
OutputStream outputStream = httpURLConnection.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new
OutputStreamWriter(outputStream, "UTF-8"));
// String post_data = URLEncoder.encode("user_name","UTF-
8")+"="+URLEncoder.encode(user_name,"UTF-8");
// bufferedWriter.write(post_data);
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
InputStream inputStream = httpURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new
InputStreamReader(inputStream,"iso-8859-1"));
String result="";
String line="";
while((line = bufferedReader.readLine())!= null) {
result += line;
}
bufferedReader.close();
inputStream.close();
httpURLConnection.disconnect();
return result;
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
@Override
protected void onPreExecute() {
alertDialog = new AlertDialog.Builder(context).create();
alertDialog.setTitle("Info");
}
@Override
protected void onPostExecute(String result) {
alertDialog.setMessage(result);
alertDialog.show();
// String temp = "login success";
// if (result.equals(temp)) {
// Intent intent = new Intent(context, Register.class);
// context.startActivity(intent);
// }
}
@Override
protected void onProgressUpdate(Void... values) {
super.onProgressUpdate(values);
}
}
| 0debug
|
static int n8x0_atag_setup(void *p, int model)
{
uint8_t *b;
uint16_t *w;
uint32_t *l;
struct omap_gpiosw_info_s *gpiosw;
struct omap_partition_info_s *partition;
const char *tag;
w = p;
stw_p(w++, OMAP_TAG_UART);
stw_p(w++, 4);
stw_p(w++, (1 << 2) | (1 << 1) | (1 << 0));
w++;
#if 0
stw_p(w++, OMAP_TAG_SERIAL_CONSOLE);
stw_p(w++, 4);
stw_p(w++, XLDR_LL_UART + 1);
stw_p(w++, 115200);
#endif
stw_p(w++, OMAP_TAG_LCD);
stw_p(w++, 36);
strcpy((void *) w, "QEMU LCD panel");
w += 8;
strcpy((void *) w, "blizzard");
w += 8;
stw_p(w++, N810_BLIZZARD_RESET_GPIO);
stw_p(w++, 24);
stw_p(w++, OMAP_TAG_CBUS);
stw_p(w++, 8);
stw_p(w++, N8X0_CBUS_CLK_GPIO);
stw_p(w++, N8X0_CBUS_DAT_GPIO);
stw_p(w++, N8X0_CBUS_SEL_GPIO);
w++;
stw_p(w++, OMAP_TAG_EM_ASIC_BB5);
stw_p(w++, 4);
stw_p(w++, N8X0_RETU_GPIO);
stw_p(w++, N8X0_TAHVO_GPIO);
gpiosw = (model == 810) ? n810_gpiosw_info : n800_gpiosw_info;
for (; gpiosw->name; gpiosw++) {
stw_p(w++, OMAP_TAG_GPIO_SWITCH);
stw_p(w++, 20);
strcpy((void *) w, gpiosw->name);
w += 6;
stw_p(w++, gpiosw->line);
stw_p(w++, gpiosw->type);
stw_p(w++, 0);
stw_p(w++, 0);
}
stw_p(w++, OMAP_TAG_NOKIA_BT);
stw_p(w++, 12);
b = (void *) w;
stb_p(b++, 0x01);
stb_p(b++, N8X0_BT_WKUP_GPIO);
stb_p(b++, N8X0_BT_HOST_WKUP_GPIO);
stb_p(b++, N8X0_BT_RESET_GPIO);
stb_p(b++, BT_UART + 1);
memcpy(b, &n8x0_bd_addr, 6);
b += 6;
stb_p(b++, 0x02);
w = (void *) b;
stw_p(w++, OMAP_TAG_WLAN_CX3110X);
stw_p(w++, 8);
stw_p(w++, 0x25);
stw_p(w++, N8X0_WLAN_PWR_GPIO);
stw_p(w++, N8X0_WLAN_IRQ_GPIO);
stw_p(w++, -1);
stw_p(w++, OMAP_TAG_MMC);
stw_p(w++, 16);
if (model == 810) {
stw_p(w++, 0x23f);
stw_p(w++, -1);
stw_p(w++, -1);
stw_p(w++, -1);
stw_p(w++, 0x240);
stw_p(w++, 0xc000);
stw_p(w++, 0x0248);
stw_p(w++, 0xc000);
} else {
stw_p(w++, 0xf);
stw_p(w++, -1);
stw_p(w++, -1);
stw_p(w++, -1);
stw_p(w++, 0);
stw_p(w++, 0);
stw_p(w++, 0);
stw_p(w++, 0);
}
stw_p(w++, OMAP_TAG_TEA5761);
stw_p(w++, 4);
stw_p(w++, N8X0_TEA5761_CS_GPIO);
w++;
partition = (model == 810) ? n810_part_info : n800_part_info;
for (; partition->name; partition++) {
stw_p(w++, OMAP_TAG_PARTITION);
stw_p(w++, 28);
strcpy((void *) w, partition->name);
l = (void *) (w + 8);
stl_p(l++, partition->size);
stl_p(l++, partition->offset);
stl_p(l++, partition->mask);
w = (void *) l;
}
stw_p(w++, OMAP_TAG_BOOT_REASON);
stw_p(w++, 12);
#if 0
strcpy((void *) w, "por");
strcpy((void *) w, "charger");
strcpy((void *) w, "32wd_to");
strcpy((void *) w, "sw_rst");
strcpy((void *) w, "mbus");
strcpy((void *) w, "unknown");
strcpy((void *) w, "swdg_to");
strcpy((void *) w, "sec_vio");
strcpy((void *) w, "pwr_key");
strcpy((void *) w, "rtc_alarm");
#else
strcpy((void *) w, "pwr_key");
#endif
w += 6;
tag = (model == 810) ? "RX-44" : "RX-34";
stw_p(w++, OMAP_TAG_VERSION_STR);
stw_p(w++, 24);
strcpy((void *) w, "product");
w += 6;
strcpy((void *) w, tag);
w += 6;
stw_p(w++, OMAP_TAG_VERSION_STR);
stw_p(w++, 24);
strcpy((void *) w, "hw-build");
w += 6;
strcpy((void *) w, "QEMU ");
pstrcat((void *) w, 12, qemu_get_version());
w += 6;
tag = (model == 810) ? "1.1.10-qemu" : "1.1.6-qemu";
stw_p(w++, OMAP_TAG_VERSION_STR);
stw_p(w++, 24);
strcpy((void *) w, "nolo");
w += 6;
strcpy((void *) w, tag);
w += 6;
return (void *) w - p;
}
| 1threat
|
static uint64_t qemu_rdma_poll(RDMAContext *rdma, uint64_t *wr_id_out)
{
int ret;
struct ibv_wc wc;
uint64_t wr_id;
ret = ibv_poll_cq(rdma->cq, 1, &wc);
if (!ret) {
*wr_id_out = RDMA_WRID_NONE;
return 0;
}
if (ret < 0) {
fprintf(stderr, "ibv_poll_cq return %d!\n", ret);
return ret;
}
wr_id = wc.wr_id & RDMA_WRID_TYPE_MASK;
if (wc.status != IBV_WC_SUCCESS) {
fprintf(stderr, "ibv_poll_cq wc.status=%d %s!\n",
wc.status, ibv_wc_status_str(wc.status));
fprintf(stderr, "ibv_poll_cq wrid=%s!\n", wrid_desc[wr_id]);
return -1;
}
if (rdma->control_ready_expected &&
(wr_id >= RDMA_WRID_RECV_CONTROL)) {
DDDPRINTF("completion %s #%" PRId64 " received (%" PRId64 ")"
" left %d\n", wrid_desc[RDMA_WRID_RECV_CONTROL],
wr_id - RDMA_WRID_RECV_CONTROL, wr_id, rdma->nb_sent);
rdma->control_ready_expected = 0;
}
if (wr_id == RDMA_WRID_RDMA_WRITE) {
uint64_t chunk =
(wc.wr_id & RDMA_WRID_CHUNK_MASK) >> RDMA_WRID_CHUNK_SHIFT;
uint64_t index =
(wc.wr_id & RDMA_WRID_BLOCK_MASK) >> RDMA_WRID_BLOCK_SHIFT;
RDMALocalBlock *block = &(rdma->local_ram_blocks.block[index]);
DDDPRINTF("completions %s (%" PRId64 ") left %d, "
"block %" PRIu64 ", chunk: %" PRIu64 " %p %p\n",
print_wrid(wr_id), wr_id, rdma->nb_sent, index, chunk,
block->local_host_addr, (void *)block->remote_host_addr);
clear_bit(chunk, block->transit_bitmap);
if (rdma->nb_sent > 0) {
rdma->nb_sent--;
}
if (!rdma->pin_all) {
#ifdef RDMA_UNREGISTRATION_EXAMPLE
qemu_rdma_signal_unregister(rdma, index, chunk, wc.wr_id);
#endif
}
} else {
DDDPRINTF("other completion %s (%" PRId64 ") received left %d\n",
print_wrid(wr_id), wr_id, rdma->nb_sent);
}
*wr_id_out = wc.wr_id;
return 0;
}
| 1threat
|
static int vtd_remap_irq_get(IntelIOMMUState *iommu, uint16_t index, VTDIrq *irq)
{
VTD_IRTE irte = { 0 };
int ret = 0;
ret = vtd_irte_get(iommu, index, &irte);
if (ret) {
return ret;
}
irq->trigger_mode = irte.trigger_mode;
irq->vector = irte.vector;
irq->delivery_mode = irte.delivery_mode;
#define VTD_IR_APIC_DEST_MASK (0xff00ULL)
#define VTD_IR_APIC_DEST_SHIFT (8)
irq->dest = (le32_to_cpu(irte.dest_id) & VTD_IR_APIC_DEST_MASK) >> \
VTD_IR_APIC_DEST_SHIFT;
irq->dest_mode = irte.dest_mode;
irq->redir_hint = irte.redir_hint;
VTD_DPRINTF(IR, "remapping interrupt index %d: trig:%u,vec:%u,"
"deliver:%u,dest:%u,dest_mode:%u", index,
irq->trigger_mode, irq->vector, irq->delivery_mode,
irq->dest, irq->dest_mode);
return 0;
}
| 1threat
|
static inline int RENAME(yuv420_rgb15)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){
int y, h_size;
if(c->srcFormat == PIX_FMT_YUV422P){
srcStride[1] *= 2;
srcStride[2] *= 2;
}
h_size= (c->dstW+7)&~7;
if(h_size*2 > dstStride[0]) h_size-=8;
__asm__ __volatile__ ("pxor %mm4, %mm4;" );
for (y= 0; y<srcSliceH; y++ ) {
uint8_t *_image = dst[0] + (y+srcSliceY)*dstStride[0];
uint8_t *_py = src[0] + y*srcStride[0];
uint8_t *_pu = src[1] + (y>>1)*srcStride[1];
uint8_t *_pv = src[2] + (y>>1)*srcStride[2];
long index= -h_size/2;
b5Dither= dither8[y&1];
g6Dither= dither4[y&1];
g5Dither= dither8[y&1];
r5Dither= dither8[(y+1)&1];
__asm__ __volatile__ (
"movd (%2, %0), %%mm0;"
"movd (%3, %0), %%mm1;"
"movq (%5, %0, 2), %%mm6;"
"1: \n\t"
YUV2RGB
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm0 \n\t"
"paddusb "MANGLE(g5Dither)", %%mm2 \n\t"
"paddusb "MANGLE(r5Dither)", %%mm1 \n\t"
#endif
"pand "MANGLE(mmx_redmask)", %%mm0;"
"pand "MANGLE(mmx_redmask)", %%mm2;"
"pand "MANGLE(mmx_redmask)", %%mm1;"
"psrlw $3,%%mm0;"
"psrlw $1,%%mm1;"
"pxor %%mm4, %%mm4;"
"movq %%mm0, %%mm5;"
"movq %%mm2, %%mm7;"
"punpcklbw %%mm4, %%mm2;"
"punpcklbw %%mm1, %%mm0;"
"psllw $2, %%mm2;"
"por %%mm2, %%mm0;"
"movq 8 (%5, %0, 2), %%mm6;"
MOVNTQ " %%mm0, (%1);"
"punpckhbw %%mm4, %%mm7;"
"punpckhbw %%mm1, %%mm5;"
"psllw $2, %%mm7;"
"movd 4 (%2, %0), %%mm0;"
"por %%mm7, %%mm5;"
"movd 4 (%3, %0), %%mm1;"
MOVNTQ " %%mm5, 8 (%1);"
"add $16, %1 \n\t"
"add $4, %0 \n\t"
" js 1b \n\t"
: "+r" (index), "+r" (_image)
: "r" (_pu - index), "r" (_pv - index), "r"(&c->redDither), "r" (_py - 2*index)
);
}
__asm__ __volatile__ (EMMS);
return srcSliceH;
}
| 1threat
|
static void vnc_colordepth(VncState *vs)
{
if (vnc_has_feature(vs, VNC_FEATURE_WMVI)) {
vnc_lock_output(vs);
vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
vnc_write_u8(vs, 0);
vnc_write_u16(vs, 1);
vnc_framebuffer_update(vs, 0, 0,
surface_width(vs->vd->ds),
surface_height(vs->vd->ds),
VNC_ENCODING_WMVi);
pixel_format_message(vs);
vnc_unlock_output(vs);
vnc_flush(vs);
} else {
set_pixel_conversion(vs);
}
}
| 1threat
|
How to sum a value per day and then GROUP BY YEARWEEK : If i have a database with 2 columns, date and piece and i want to first count piece per day and then group by week. How wrong is my code and how to do it?
SELECT date, piece,
(SELECT date, COUNT(piece)
FROM t1
WHERE piece > 10
GROUP BY date
) AS sum
FROM t1
GROUP BY YEARWEEK(date)
| 0debug
|
Authorize.net arb : I am working on authorize.net integration in Laravel Framework(PHP).
I am working on automated recurring billing.
The scenario is I have a site, users sign up for our services and we charge them on monthly basis, and for that we have implemented automated recurring billing.
But I am unable to get the transaction id of successfully placed transactions.
Please help
Thanks
| 0debug
|
How to prevent an instance of a class from being created when the condition is true. C# : <p>I have the class Pos:</p>
<pre><code>public class Pos
{
int x;
int y;
public int X
{
get
{
return x;
}
set
{
try
{
if (value == 3)
{
x = value;
}
}
catch
{
throw new ArgumentException();
}
}
}
public int Y { get; set; }
public Pos(int x, int y)
{
X = x;
Y = y;
}
}
</code></pre>
<p>I have an instance created, with X = 0. That is, as far as I understand, in the case of value = 3 -> x = 0 and in the constructor X = 0, then create an instance of the class.
How do I prevent an instance of a class from being created when the x property setter fails?
I will create a List that should not contain "wrong" objects.</p>
| 0debug
|
How To use Model OOP in Java, Sorry i am newbie : I have a Model Active Admin, i have created String ID setter and getter.
when i use setID in Login Form, i use this :
`ActiveAdmin AA = new ActiveAdmin();`
AA.setId(txtIdAdmin.getText());
and i test getter from login form, it work.
but when i test in another form, in another java class, in diffrent file, i can't get my string ID in Active Admin.
i used `AA.getId();`
and the result is blank.
please help me. any suggestion or answer.
sorry if my english is bad.
| 0debug
|
I do not understand the error code CS0120 for this specific program in C# : I am new to C# and need a little help. I am having one error and have searched for answers in my book and watched tutorials for this particular subject. The error is in bold. Any help will be appreciated! The large gap is to indicate another class I added called Point
~Thank you
class Program
{
private static Point another;
static void Main(string[] args)
{
Point origin = new Point(1366, 768);
Point bottomRight = another;
double distance = origin.DistanceTo(bottomRight);
Console.WriteLine("Distance is: {0}", distance);
Console.WriteLine("Number of Point objects: {0}", Point.ObjectCount());
{
private int x, y;
private int objectCount = 0;
public Point()
{
this.x = -1;
this.y = -1;
objectCount++;
}
public Point(int x, int y)
{
this.x = x;
this.y = y;
objectCount++;
}
public double DistanceTo(Point other)
{
int xDiff = this.x - other.x;
int yDiff = this.y - other.y;
double distance= Math.Sqrt((xDiff * xDiff) + (yDiff * yDiff));
return distance;
}
public static int ObjectCount()
{
***return objectCount;***
}
}
}
| 0debug
|
def count_char(string,char):
count = 0
for i in range(len(string)):
if(string[i] == char):
count = count + 1
return count
| 0debug
|
Why are so many js libraries talking about command line installation : I have apparently missed a shift in javascript culture ... now I see js libraries (such as [modernizr][1]) that talk about installing them via command lines via *npm*. This is of course very different from the simple notion of `<script src ='...'></script>`
My question is *not* 'what is npm', but what is going on in the culture of js development ... the paradigm shift, itself ...
> command line? what are you talking about!? ... it javascript!
[1]: https://modernizr.com/docs/#prefixed
| 0debug
|
C# tertiary operator solve : <p>Can any one tell me the meaning of the below C# code</p>
<pre><code>true? para1:para2;
</code></pre>
<p>For example,</p>
<pre><code>char x = 'A';
Console.WriteLine(true? x : 0);
</code></pre>
<p>The console prints 65</p>
<p>I do not understand how it works.</p>
| 0debug
|
static int vscsi_srp_indirect_data(VSCSIState *s, vscsi_req *req,
uint8_t *buf, uint32_t len)
{
struct srp_direct_buf *td = &req->ind_desc->table_desc;
struct srp_direct_buf *md = req->cur_desc;
int rc = 0;
uint32_t llen, total = 0;
dprintf("VSCSI: indirect segment 0x%x bytes, td va=0x%llx len=0x%x\n",
len, (unsigned long long)td->va, td->len);
while (len) {
if (md && md->len == 0) {
if (req->local_desc) {
md = ++req->cur_desc;
--req->local_desc;
--req->total_desc;
td->va += sizeof(struct srp_direct_buf);
} else {
md = req->cur_desc = NULL;
}
}
if (!md) {
if (!req->total_desc) {
dprintf("VSCSI: Out of descriptors !\n");
break;
}
md = req->cur_desc = &req->ext_desc;
dprintf("VSCSI: Reading desc from 0x%llx\n",
(unsigned long long)td->va);
rc = spapr_tce_dma_read(&s->vdev, td->va, md,
sizeof(struct srp_direct_buf));
if (rc) {
dprintf("VSCSI: tce_dma_read -> %d reading ext_desc\n", rc);
break;
}
vscsi_swap_desc(md);
td->va += sizeof(struct srp_direct_buf);
--req->total_desc;
}
dprintf("VSCSI: [desc va=0x%llx,len=0x%x] remaining=0x%x\n",
(unsigned long long)md->va, md->len, len);
llen = MIN(len, md->len);
if (req->writing) {
rc = spapr_tce_dma_read(&s->vdev, md->va, buf, llen);
} else {
rc = spapr_tce_dma_write(&s->vdev, md->va, buf, llen);
}
if (rc) {
dprintf("VSCSI: tce_dma_r/w(%d) -> %d\n", req->writing, rc);
break;
}
dprintf("VSCSI: data: %02x %02x %02x %02x...\n",
buf[0], buf[1], buf[2], buf[3]);
len -= llen;
buf += llen;
total += llen;
md->va += llen;
md->len -= llen;
}
return rc ? -1 : total;
}
| 1threat
|
open link in new tab with github markdown using target="_blank" : <p>Is there a way to let a Link, written in githubs markdown, open in a new tab?
All posts I have found related to this suggests to use HTML and <code>target="_blank"</code>, which is fine with me, but that doesn't work.
For example this link:</p>
<pre><code><a href="http://stackoverflow.com" target="_blank">Go</a>
</code></pre>
<p>Does not open in a new tab.
I'm no interested in replies for all kind of different markdown syntaxes, but only in a solution that will work when I write my markdown on github. </p>
| 0debug
|
Java 2D arrayList - copy last element, update it and add the updated version at the end of the list : The problem is kinda weird. I have a 2D arrayList. Where each element has an int called x and other called y. What i am trying to do is get the last element of 2DarrayList and update the x and y values and add the updated element right at the end of 2d arrayList.
The problem is when i update the last element, it also updates the element from where it is retrieving info from. I don't want the info. of the element to change from where the info is being derived from.
| 0debug
|
static int iscsi_aio_discard_acb(IscsiAIOCB *acb) {
struct iscsi_context *iscsi = acb->iscsilun->iscsi;
struct unmap_list list[1];
acb->canceled = 0;
acb->bh = NULL;
acb->status = -EINPROGRESS;
acb->buf = NULL;
list[0].lba = sector_qemu2lun(acb->sector_num, acb->iscsilun);
list[0].num = acb->nb_sectors * BDRV_SECTOR_SIZE / acb->iscsilun->block_size;
acb->task = iscsi_unmap_task(iscsi, acb->iscsilun->lun,
0, 0, &list[0], 1,
iscsi_unmap_cb,
acb);
if (acb->task == NULL) {
error_report("iSCSI: Failed to send unmap command. %s",
iscsi_get_error(iscsi));
return -1;
}
return 0;
}
| 1threat
|
int ff_rv34_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
RV34DecContext *r = avctx->priv_data;
MpegEncContext *s = &r->s;
AVFrame *pict = data;
SliceInfo si;
int i;
int slice_count;
uint8_t *slices_hdr = NULL;
int last = 0;
if (buf_size == 0) {
if (s->low_delay==0 && s->next_picture_ptr) {
*pict= *(AVFrame*)s->next_picture_ptr;
s->next_picture_ptr= NULL;
*data_size = sizeof(AVFrame);
}
return 0;
}
if(!avctx->slice_count){
slice_count = (*buf++) + 1;
slices_hdr = buf + 4;
buf += 8 * slice_count;
}else
slice_count = avctx->slice_count;
for(i=0; i<slice_count; i++){
int offset= get_slice_offset(avctx, slices_hdr, i);
int size;
if(i+1 == slice_count)
size= buf_size - offset;
else
size= get_slice_offset(avctx, slices_hdr, i+1) - offset;
r->si.end = s->mb_width * s->mb_height;
if(i+1 < slice_count){
init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, i+1), (buf_size-get_slice_offset(avctx, slices_hdr, i+1))*8);
if(r->parse_slice_header(r, &r->s.gb, &si) < 0){
if(i+2 < slice_count)
size = get_slice_offset(avctx, slices_hdr, i+2) - offset;
else
size = buf_size - offset;
}else
r->si.end = si.start;
}
last = rv34_decode_slice(r, r->si.end, buf + offset, size);
s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start;
if(last)
break;
}
if(last){
if(r->loop_filter)
r->loop_filter(r);
ff_er_frame_end(s);
MPV_frame_end(s);
if (s->pict_type == FF_B_TYPE || s->low_delay) {
*pict= *(AVFrame*)s->current_picture_ptr;
} else if (s->last_picture_ptr != NULL) {
*pict= *(AVFrame*)s->last_picture_ptr;
}
if(s->last_picture_ptr || s->low_delay){
*data_size = sizeof(AVFrame);
ff_print_debug_info(s, pict);
}
s->current_picture_ptr= NULL;
}
return buf_size;
}
| 1threat
|
Can't figure out what's causing problems : <p>I recently asked a question on how I'd set up a cross server bot with per server commands. Someone said I'd be able to using quick.db, then put this code in his answer:</p>
<pre><code>client.on("message", message => {
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if(command == "setautorole"){
let roleName = args.slice(0).join(" ");
let role = message.guild.roles.find(role => role.name == roleName).catch(message.reply("Couldn't find that role"),
db.set(`autorole_${message.guild.id}`, role.id)
}
if(command == "unsetautorole"){
db.delete(`autorole_${message.guild.id})
}
if(command == "setwelcomechannel"){
let channelName = args.slice(0).join(" ");
let channel = message.guild.channels.find(channel => channel.name == channelName).catch(message.reply("Couldn't find that channel")
db.set(`welcomechannel_${message.guild.id}`, channel.id)
}
if(command == "unsetwelcomechannel"){
db.delete(`welcomechannel_${message.guild.id})
}
})
client.on("guildMemberAdd", member => {
let roleId = db.get(`autorole_${member.guild.id}`);
if(roleId) member.addRole(roleId).catch(console.error);
let channelId = db.get(`welcomechannel_${member.guild.id}`);
if(channelId) channel = member.guild.channels.get(channelId).catch(console.error);
if(channel) channel.send("x")
})
</code></pre>
<p>The problem is, is that I get a whole lot of errors. <a href="https://imgur.com/a/zUxx9TK" rel="nofollow noreferrer">https://imgur.com/a/zUxx9TK</a></p>
<p>Where and what would I need to put to fix said errors?</p>
| 0debug
|
static void sx1_init(MachineState *machine, const int version)
{
struct omap_mpu_state_s *mpu;
MemoryRegion *address_space = get_system_memory();
MemoryRegion *flash = g_new(MemoryRegion, 1);
MemoryRegion *flash_1 = g_new(MemoryRegion, 1);
MemoryRegion *cs = g_new(MemoryRegion, 4);
static uint32_t cs0val = 0x00213090;
static uint32_t cs1val = 0x00215070;
static uint32_t cs2val = 0x00001139;
static uint32_t cs3val = 0x00001139;
DriveInfo *dinfo;
int fl_idx;
uint32_t flash_size = flash0_size;
int be;
if (version == 2) {
flash_size = flash2_size;
}
mpu = omap310_mpu_init(address_space, sx1_binfo.ram_size,
machine->cpu_model);
memory_region_init_ram(flash, NULL, "omap_sx1.flash0-0", flash_size,
&error_abort);
vmstate_register_ram_global(flash);
memory_region_set_readonly(flash, true);
memory_region_add_subregion(address_space, OMAP_CS0_BASE, flash);
memory_region_init_io(&cs[0], NULL, &static_ops, &cs0val,
"sx1.cs0", OMAP_CS0_SIZE - flash_size);
memory_region_add_subregion(address_space,
OMAP_CS0_BASE + flash_size, &cs[0]);
memory_region_init_io(&cs[2], NULL, &static_ops, &cs2val,
"sx1.cs2", OMAP_CS2_SIZE);
memory_region_add_subregion(address_space,
OMAP_CS2_BASE, &cs[2]);
memory_region_init_io(&cs[3], NULL, &static_ops, &cs3val,
"sx1.cs3", OMAP_CS3_SIZE);
memory_region_add_subregion(address_space,
OMAP_CS2_BASE, &cs[3]);
fl_idx = 0;
#ifdef TARGET_WORDS_BIGENDIAN
be = 1;
#else
be = 0;
#endif
if ((dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
if (!pflash_cfi01_register(OMAP_CS0_BASE, NULL,
"omap_sx1.flash0-1", flash_size,
blk_by_legacy_dinfo(dinfo),
sector_size, flash_size / sector_size,
4, 0, 0, 0, 0, be)) {
fprintf(stderr, "qemu: Error registering flash memory %d.\n",
fl_idx);
}
fl_idx++;
}
if ((version == 1) &&
(dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
memory_region_init_ram(flash_1, NULL, "omap_sx1.flash1-0", flash1_size,
&error_abort);
vmstate_register_ram_global(flash_1);
memory_region_set_readonly(flash_1, true);
memory_region_add_subregion(address_space, OMAP_CS1_BASE, flash_1);
memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val,
"sx1.cs1", OMAP_CS1_SIZE - flash1_size);
memory_region_add_subregion(address_space,
OMAP_CS1_BASE + flash1_size, &cs[1]);
if (!pflash_cfi01_register(OMAP_CS1_BASE, NULL,
"omap_sx1.flash1-1", flash1_size,
blk_by_legacy_dinfo(dinfo),
sector_size, flash1_size / sector_size,
4, 0, 0, 0, 0, be)) {
fprintf(stderr, "qemu: Error registering flash memory %d.\n",
fl_idx);
}
fl_idx++;
} else {
memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val,
"sx1.cs1", OMAP_CS1_SIZE);
memory_region_add_subregion(address_space,
OMAP_CS1_BASE, &cs[1]);
}
if (!machine->kernel_filename && !fl_idx && !qtest_enabled()) {
fprintf(stderr, "Kernel or Flash image must be specified\n");
exit(1);
}
sx1_binfo.kernel_filename = machine->kernel_filename;
sx1_binfo.kernel_cmdline = machine->kernel_cmdline;
sx1_binfo.initrd_filename = machine->initrd_filename;
arm_load_kernel(mpu->cpu, &sx1_binfo);
}
| 1threat
|
Resize Bootstrap Modals window : <p>Looking for help with this bootstrap modal. </p>
<p>When you click on a package (the colored blocks), the modal opens full screen. I cant figure out how to make it open more in a window. </p>
<p>Not sure if this is a bootstrap or j query thing. </p>
<p>site: <a href="http://pegasusbus.com/ebrochure" rel="nofollow">http://pegasusbus.com/ebrochure</a></p>
| 0debug
|
Python regular expression: exact match only : <p>I have a very simple question, but I can't find an answer for this.</p>
<p>I have some string like:</p>
<pre><code>test-123
</code></pre>
<p>I want to have some <code>smart</code> regular expression for validation if this string exact match my condition.</p>
<p>I expect to have a strings like:</p>
<pre><code>test-<number>
</code></pre>
<p>Where number should contains from 1 to * elements on numbers.</p>
<p>I'm trying to do something like this:</p>
<pre><code>import re
correct_string = 'test-251'
wrong_string = 'test-123x'
regex = re.compile(r'test-\d+')
if regex.match(correct_string):
print 'Matching correct string.'
if regex.match(wrong_string):
print 'Matching wrong_string.'
</code></pre>
<p>So, I can see both messages (with matching correct and wrong string), but I really expect to match only correct string.</p>
<p>Also, I was trying to use <code>search</code> method instead of <code>match</code> but with no luck.</p>
<p>Ideas?</p>
| 0debug
|
static void nvenc_setup_rate_control(AVCodecContext *avctx)
{
NVENCContext *ctx = avctx->priv_data;
NV_ENC_RC_PARAMS *rc = &ctx->config.rcParams;
if (avctx->bit_rate > 0)
rc->averageBitRate = avctx->bit_rate;
if (avctx->rc_max_rate > 0)
rc->maxBitRate = avctx->rc_max_rate;
if (ctx->rc > 0) {
nvenc_override_rate_control(avctx, rc);
} else if (ctx->flags & NVENC_LOSSLESS) {
set_lossless(avctx, rc);
} else if (avctx->global_quality > 0) {
set_constqp(avctx, rc);
} else if (avctx->qmin >= 0 && avctx->qmax >= 0) {
rc->rateControlMode = NV_ENC_PARAMS_RC_VBR;
set_vbr(avctx, rc);
}
if (avctx->rc_buffer_size > 0)
rc->vbvBufferSize = avctx->rc_buffer_size;
if (rc->averageBitRate > 0)
avctx->bit_rate = rc->averageBitRate;
#if NVENCAPI_MAJOR_VERSION >= 7
if (ctx->aq) {
ctx->config.rcParams.enableAQ = 1;
ctx->config.rcParams.aqStrength = ctx->aq_strength;
av_log(avctx, AV_LOG_VERBOSE, "AQ enabled.\n");
}
if (ctx->temporal_aq) {
ctx->config.rcParams.enableTemporalAQ = 1;
av_log(avctx, AV_LOG_VERBOSE, "Temporal AQ enabled.\n");
}
if (ctx->rc_lookahead) {
int lkd_bound = FFMIN(ctx->nb_surfaces, ctx->async_depth) -
ctx->config.frameIntervalP - 4;
if (lkd_bound < 0) {
av_log(avctx, AV_LOG_WARNING,
"Lookahead not enabled. Increase buffer delay (-delay).\n");
} else {
ctx->config.rcParams.enableLookahead = 1;
ctx->config.rcParams.lookaheadDepth = av_clip(ctx->rc_lookahead, 0, lkd_bound);
ctx->config.rcParams.disableIadapt = ctx->no_scenecut;
ctx->config.rcParams.disableBadapt = !ctx->b_adapt;
av_log(avctx, AV_LOG_VERBOSE,
"Lookahead enabled: depth %d, scenecut %s, B-adapt %s.\n",
ctx->config.rcParams.lookaheadDepth,
ctx->config.rcParams.disableIadapt ? "disabled" : "enabled",
ctx->config.rcParams.disableBadapt ? "disabled" : "enabled");
}
}
if (ctx->strict_gop) {
ctx->config.rcParams.strictGOPTarget = 1;
av_log(avctx, AV_LOG_VERBOSE, "Strict GOP target enabled.\n");
}
if (ctx->nonref_p)
ctx->config.rcParams.enableNonRefP = 1;
if (ctx->zerolatency)
ctx->config.rcParams.zeroReorderDelay = 1;
if (ctx->quality)
ctx->config.rcParams.targetQuality = ctx->quality;
#endif
}
| 1threat
|
what is wrong with: select CONVERT(date,N'13/01/2016') : I used sql server 2028 R when I run the above a script I get this error anyone could help please
error message:
Msg 241, Level 16, State 1, Line 1
Conversion failed when converting date and/or time from character string.
| 0debug
|
void ioinst_handle_stcrw(S390CPU *cpu, uint32_t ipb)
{
CRW *crw;
uint64_t addr;
int cc;
hwaddr len = sizeof(*crw);
CPUS390XState *env = &cpu->env;
addr = decode_basedisp_s(env, ipb);
if (addr & 3) {
program_interrupt(env, PGM_SPECIFICATION, 2);
return;
}
crw = s390_cpu_physical_memory_map(env, addr, &len, 1);
if (!crw || len != sizeof(*crw)) {
program_interrupt(env, PGM_ADDRESSING, 2);
goto out;
}
cc = css_do_stcrw(crw);
setcc(cpu, cc);
out:
s390_cpu_physical_memory_unmap(env, crw, len, 1);
}
| 1threat
|
Update MySQL root password - Ubuntu : <p>I want to update my MySQL password from <code>I9O*Kez</code> ---> <code>SO123*</code></p>
<p>I perform these </p>
<pre><code>mysql -u root -pI9O*Kez
service mysql stop
mysqld_safe --skip-grant-tables &
mysql -uroot
use mysql;
delete from user where User='root';
CREATE USER 'root'@'%' IDENTIFIED BY 'SO123*';
GRANT ALL PRIVILEGES ON * . * TO 'root'@'%';
</code></pre>
<p>I kept getting </p>
<pre><code>ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
</code></pre>
<p>Am I doing these completely wrong ? </p>
<p>It shouldn't be this difficult just to update a root password - right ?</p>
| 0debug
|
What is proper name of controller's parameters? : <p>I divided value objects into three types from design point of view. First, Entity is representaton of domain data and map with table of database. Second, DTO (data transfer object) is a simple and compact object and it exist for trans data from service layer to front layer. And there is a question about type three object. Type three objects are parameters of controller. It has also simple data like DTO but it has various entities reference key properties like "departmentIdx in Employee". I want to proper naming on third type object.</p>
<p>VO? It's not only for values, i think. POJO? POJO is too much range concept.</p>
| 0debug
|
How can I locate people with a gyroscope and accelerometer? : <p>I want to build an app that locate and track people by iPhone using Gyro+Accelerometer. No need for GPS here.</p>
<p>How should I approach this problem?</p>
| 0debug
|
Using dplyr to conditionally replace values in a column : <p>I have an example data set with a column that reads somewhat like this:</p>
<pre><code>Candy
Sanitizer
Candy
Water
Cake
Candy
Ice Cream
Gum
Candy
Coffee
</code></pre>
<p>What I'd like to do is replace it into just two factors - "Candy" and "Non-Candy". I can do this with Python/Pandas, but can't seem to figure out a dplyr based solution. Thank you!</p>
| 0debug
|
static void adlib_realizefn (DeviceState *dev, Error **errp)
{
AdlibState *s = ADLIB(dev);
PortioList *port_list = g_new(PortioList, 1);
struct audsettings as;
if (glob_adlib) {
error_setg (errp, "Cannot create more than 1 adlib device");
return;
}
glob_adlib = s;
#ifdef HAS_YMF262
if (YMF262Init (1, 14318180, s->freq)) {
error_setg (errp, "YMF262Init %d failed", s->freq);
return;
}
else {
YMF262SetTimerHandler (0, timer_handler, 0);
s->enabled = 1;
}
#else
s->opl = OPLCreate (OPL_TYPE_YM3812, 3579545, s->freq);
if (!s->opl) {
error_setg (errp, "OPLCreate %d failed", s->freq);
return;
}
else {
OPLSetTimerHandler (s->opl, timer_handler, 0);
s->enabled = 1;
}
#endif
as.freq = s->freq;
as.nchannels = SHIFT;
as.fmt = AUD_FMT_S16;
as.endianness = AUDIO_HOST_ENDIANNESS;
AUD_register_card ("adlib", &s->card);
s->voice = AUD_open_out (
&s->card,
s->voice,
"adlib",
s,
adlib_callback,
&as
);
if (!s->voice) {
Adlib_fini (s);
error_setg (errp, "Initializing audio voice failed");
return;
}
s->samples = AUD_get_buffer_size_out (s->voice) >> SHIFT;
s->mixbuf = g_malloc0 (s->samples << SHIFT);
adlib_portio_list[0].offset = s->port;
adlib_portio_list[1].offset = s->port + 8;
portio_list_init (port_list, OBJECT(s), adlib_portio_list, s, "adlib");
portio_list_add (port_list, isa_address_space_io(&s->parent_obj), 0);
}
| 1threat
|
static int dynticks_start_timer(struct qemu_alarm_timer *t)
{
struct sigevent ev;
timer_t host_timer;
struct sigaction act;
sigfillset(&act.sa_mask);
act.sa_flags = 0;
act.sa_handler = host_alarm_handler;
sigaction(SIGALRM, &act, NULL);
memset(&ev, 0, sizeof(ev));
ev.sigev_value.sival_int = 0;
ev.sigev_notify = SIGEV_SIGNAL;
#ifdef SIGEV_THREAD_ID
if (qemu_signalfd_available()) {
ev.sigev_notify = SIGEV_THREAD_ID;
ev._sigev_un._tid = qemu_get_thread_id();
}
#endif
ev.sigev_signo = SIGALRM;
if (timer_create(CLOCK_REALTIME, &ev, &host_timer)) {
perror("timer_create");
return -1;
}
t->timer = host_timer;
return 0;
}
| 1threat
|
Assign letter to a variable for if statement : <p>in C++ is there a way to assign a letter to a variable I need to write a program that asks for a letter grade A,B,C,D,F and out puts a different message depending on what letter grade was given </p>
| 0debug
|
can't display java code on my html website page in a proper formatted way : <p>I am new to website development so what I am doing is using <br> tag after each line of code to break the line and giving space in starting to make it as presentable as it is in eclipse but while displaying the entire code it shifts to left. There is no proper formatting. Please provide a way to do this. </p>
| 0debug
|
how to use IComparable<T> in C# to compare 2 List : Eg:-
var ExistingGroup = new List<Person>
{
new Person(1,"Rahul","Sharma"),
new Person(2,"Deepak","Jha"),
new Person(3,"Raj","Mishra"),
}
var NewGroup = new List<Person>
{
new Person(4,"Jay","Mohan"),
new Person(2,"Dileep","Kumar"),
new Person(5,"Mohan","Lal"),
}
OutPut :-
1 Removed
4 Added
2 Changed
3 Removed
5 Added
How to get this output with IComparable<T> in C#.
| 0debug
|
Leaflet : tiles didn't load : <p>I try to use the leaflet-map with polymer.
I add the leaflet-map tag inside my template, but when loading (and waiting) there is only one tile which is displayed (in the top left) with the original configuration (no leaflet-tilelayer, only set the latitude, longitude and zoom)</p>
<p>I switch to non-polymer version of leaflet, and try invalidateSize function, and there is always the same problem? I think i've missed something, but I don't know why.</p>
<p>Does anyone have any idea?
Thanks a lot</p>
| 0debug
|
Volley requests not working with Django Sessions : <p>I have a Django script running on the server that creates session variables for every request sent to the server. The script returns a specific value based on the previous stored session variables.</p>
<p>When I tested the script on the browser, the session on Django worked as per the requirement. <br></p>
<p>However, while using Volley to send the same request, the script considers every request as a new request without taking previous session variables into consideration.
<br></p>
<pre><code> StringRequest stringRequest = new StringRequest(Request.Method.GET,Send_URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Response(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
requestQueue.add(stringRequest);
}
</code></pre>
<p><code>RequestQueue defined globally and context assigned in the onCreate() method</code></p>
<p>P.S I rechecked by requesting from the browser and it works. So there are no issues on the Django End. <br>
Thanks!</p>
| 0debug
|
How to sum the elements of an array list that stores objects : <p>I have a array list called Employees that stores Employee objects. Each employee has last name, first name, hour,pay pate, gross, tax, and net. I am trying to calculate the sum of each Employee's hour,pay pate, gross, tax, and net. Is there a way to extract specific element of an object from an array list?</p>
<p>I have tried to calculate the sum through user's input, however, it does not seem to work. </p>
<pre><code>//Employee class
public Employee getinfo(Employee info )
{
info.LastName();
info.FirstName();
info.fullname();
info.hours();//ask user to input hour
toth += info.gethours();
info.payrate();//ask user to input payrate
totpr+= info.getpayrate();
info.calcGross();
totg+= info.getgross();
info.calcTaxes();
tott+= info.gettax();
info.calcNet();
totn+= info.getnet();
return info;
}
//Employees class
Employee max=new Employee();
public void add()
{
for (int i=0;i<max.maxemps();i++)
{
Employee emp= new Employee();
emp.getinfo(emp);
list.add(emp);
}
}
</code></pre>
<pre><code>//Actual results
qwe, ewq 6.00 7.00 42.00 6.30 35.70
ttt, yyy 8.00 9.00 72.00 10.80 61.20
Total 0.00 0.00 0.00 0.00 0.00
Average 0.00 0.00 0.00 0.00 0.00
//Expecting
Total Total 14.00 16.00 114.00 17.1 96.9
Average 7.00 8.00 57.00 8.505 48.45
</code></pre>
| 0debug
|
Pseudocode Python Concepts : <p>I know that pseudocode by its very nature is based more on natural language syntax and principles than anything else, but it is supposed to represent coding concepts. I am still a beginner , so I don't understand all of the concepts.</p>
<pre><code> int string (char s[1..m], char t[1..n])
// d is a table with m+1 rows and n+1 columns
declare int d[0..m, 0..n]
</code></pre>
<p>I understand this except for the last line. Could somebody explain to this to me in python ? </p>
| 0debug
|
Please provide regex for the given multiple numbers in a sentence? : Here I have to return true or false if my 2 digits (can be anything) found in a number not seperated by white spaces
here 2 digits (1 and 3) are present in two different numbers(8913011, 12) and it is returning true . This is wrong scenario
**String styy = "**1**2 46499 891**3**011";
boolean contains = styy.matches("(.*\\b[0-9]*?(1[0-9]*?3|3[0-9]*?1)[0-9]*?\\b.*?)");
System.out.println(contains);**
I want to search these two digits (1 and 3) two be present in a single number like this 4153
String styy = "4**1**5**3** 245 345"
in the above string 2 digits are present in a single number. This is what I want
Can you help me on this?
| 0debug
|
static MemoryRegion *pc_dimm_get_memory_region(PCDIMMDevice *dimm)
{
return host_memory_backend_get_memory(dimm->hostmem, &error_abort);
}
| 1threat
|
powering to decimal number produce wrong answer : my calculation is simple but it provide wrong answer,
for example 3**0.1-0.3 should equal to 0.0,
but python interpreter give 0.8161
even on using Decimal system,i am using python 3.6.3,
here my code is
from decimal import Decimal as D
print(D('3')**D('0.1')-D('0.3'))
here is output
0.816123174033904434442614138
| 0debug
|
std::vector "magically" empties : I'm currently programming something needing vectors. I have two nested loops;
for (size_t i = 0; i < m_neurons.size(); i++) {
for (size_t j = 0; j < m_neurons[0].m_weights.size(); j++) {
}
}
This section is the one we are interested in:
d.out ("i == " + std::to_string (i));
d.out ("m_neurons.size() == " + std::to_string (m_neurons.size()));
d.out ("m_neurons[i].m_weights.size() == " + std::to_string (m_neurons.at(i).m_weights.size()));
d.out ("m_neurons[i].m_weights.size() == " + std::to_string (m_neurons.at(i).m_weights.size()));
for (size_t j = 0; j < m_neurons[0].m_weights.size(); j++) {
I print out some sizes and then, I want C++ to loop through the vector; easy enough, right?
Except this happens:
i == 0
m_neurons.size() == 1
m_neurons[i].m_weights.size() == 4
m_neurons[i].m_weights.size() == 4
terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
Aborted (Speicherabzug geschrieben)
[maximilian@new-host library]$
1) Somehow the vector gets emptied
2) Somehow, the collection of the data is treated like I used `.at (int index)`
I have:
-tried alternating between `vector.at()` and `vector[]`
-deleted the executable and recompiled (multiple times)
-rebooted my pc [dunno, might help]
-investigated with GDB (the vector changed value from one step to the other)
-Used my mediocre googling skills to search something similar.
-Played a bit with the content of those vectors
I know that:
-The vector is NOT changed in between
-It is exactly THIS line of code that bugs out [because I have a printing s tatement exactly after]
-I recall it working a bit earlier in the day
Now my Questions are:
1) Is this a known issue/feature?
2) What caused it?
3) How can I fix it?
| 0debug
|
I'de like to Transpose excel columns into a new list : I'm new at VBA and tried finding already existing solutions but none answered fully my requirements:
My initial list has holes (blanks)[enter image description here][1] and I need to list the results as transposed without these blank fields
column A has files # and then 5 columns with prices but some are having only one price others 2 others 3 etc but never more than 3 prices.
My first trials were no success as I couldn't find the totals expected.
Thanks for your help
[1]: https://i.stack.imgur.com/dgmDL.png
| 0debug
|
How do I simulate a websocket disconnect manually? (Firefox or Chrome dev tools) : <p>How do I simulate a websocket disconnect manually? I'm trying to test websocket reconnect logic, and I have no way of doing this other than waiting for the browser's 10 minute websocket timeout.</p>
| 0debug
|
check if two array have any value same : <p>Is there any way I could check if two arrays contain the same value?</p>
<pre><code>array (size=1)
0 => string '209' (length=3)
array (size=4)
0 => string '209' (length=3)
1 => string '208' (length=3)
2 => string '1' (length=1)
3 => string '2' (length=1)
</code></pre>
<p>I want to see if I can get 209 they match in both array</p>
| 0debug
|
Composer Fatal error: Declaration of Fxp... must be compatible with ...AbstractAssetsRepository.php on line 334 : <p>I updated composer</p>
<pre><code>composer self-update
</code></pre>
<p>I installed the newer version of the plugin</p>
<pre><code>composer global require "fxp/composer-asset-plugin:*"
</code></pre>
<p>I try to install Laravel</p>
<p><strong>composer global require "laravel/installer"</strong></p>
<pre><code>Changed current directory to C:/Users/Arthur/AppData/Roaming/Composer
Fatal error: Declaration of Fxp\Composer\AssetPlugin\Repository\AbstractAssetsRe
pository::search() must be compatible with Composer\Repository\RepositoryInterfa
ce::search($query, $mode = 0, $type = NULL) in C:\Users\Arthur\AppData\Roaming\C
omposer\vendor\fxp\composer-asset-plugin\Repository\AbstractAssetsRepository.php
on line 334
</code></pre>
<p>Now all commands in composer not working</p>
<pre><code>composer <any command>
</code></pre>
<p>Please help me to resolve it</p>
| 0debug
|
How to assign a variable in one method and change/use it in another method? : <p>What changes do I have to make for the x and z variables to retain the values they are assigned in the Assign method? I have only recently started learning C# for college after learning C++ for 2 years in school so this is very confusing to me.</p>
<pre><code>class Program
{
static void Assign(int x, int z)
{
x = 3;
z = 2;
}
static void Sum(int x, int z)
{
Console.WriteLine(x + z);
}
static void Main(string[] args)
{
int x = 0, z = 0;
Assign(x,z);
Sum(x,z);
}
}
</code></pre>
| 0debug
|
static void socket_outgoing_migration(Object *src,
Error *err,
gpointer opaque)
{
MigrationState *s = opaque;
QIOChannel *sioc = QIO_CHANNEL(src);
if (err) {
trace_migration_socket_outgoing_error(error_get_pretty(err));
s->to_dst_file = NULL;
migrate_fd_error(s, err);
} else {
trace_migration_socket_outgoing_connected();
migration_set_outgoing_channel(s, sioc);
}
object_unref(src);
}
| 1threat
|
document.location = 'http://evil.com?username=' + user_input;
| 1threat
|
static int rndis_query_response(USBNetState *s,
rndis_query_msg_type *buf, unsigned int length)
{
rndis_query_cmplt_type *resp;
uint8_t infobuf[sizeof(oid_supported_list)];
uint32_t bufoffs, buflen;
int infobuflen;
unsigned int resplen;
bufoffs = le32_to_cpu(buf->InformationBufferOffset) + 8;
buflen = le32_to_cpu(buf->InformationBufferLength);
if (bufoffs + buflen > length)
return USB_RET_STALL;
infobuflen = ndis_query(s, le32_to_cpu(buf->OID),
bufoffs + (uint8_t *) buf, buflen, infobuf,
sizeof(infobuf));
resplen = sizeof(rndis_query_cmplt_type) +
((infobuflen < 0) ? 0 : infobuflen);
resp = rndis_queue_response(s, resplen);
if (!resp)
return USB_RET_STALL;
resp->MessageType = cpu_to_le32(RNDIS_QUERY_CMPLT);
resp->RequestID = buf->RequestID;
resp->MessageLength = cpu_to_le32(resplen);
if (infobuflen < 0) {
resp->Status = cpu_to_le32(RNDIS_STATUS_NOT_SUPPORTED);
resp->InformationBufferLength = cpu_to_le32(0);
resp->InformationBufferOffset = cpu_to_le32(0);
return 0;
}
resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
resp->InformationBufferOffset =
cpu_to_le32(infobuflen ? sizeof(rndis_query_cmplt_type) - 8 : 0);
resp->InformationBufferLength = cpu_to_le32(infobuflen);
memcpy(resp + 1, infobuf, infobuflen);
return 0;
}
| 1threat
|
Compute matrix an data frame : Body mass index (BMI) is a biometric measure of the relationship between height and weight of an individual. The BMI data were compiled in the following vector: imc <- c (18, 19, 24, 25, 30, 35, 30, 20, 18, 15). The criterion of experts to classify the groups is the following: low (<18.55); Normal (18.55-25) and overweight (> 30). With this information create a vector of factors called imcRangos from imc that shows the values, low, normal and overweight.
I need some help with it.
I really I do not understand it.
Please.
Thanks
| 0debug
|
JSON access children in plain javascript : <p>I have the following, simple JSON structure:</p>
<pre><code>{
"a": {
"value1": "w",
"value2": "x"
},
"b": {
"value1": "w",
"value2": "x"
},
"c": {
"value1": "w",
"value2": "x"
}
</code></pre>
<p>}</p>
<p>...the desired output is as follows: </p>
<pre><code>{
{
"value1": "w",
"value2": "x"
},
{
"value1": "w",
"value2": "x"
},
{
"value1": "w",
"value2": "x"
}
</code></pre>
<p>}</p>
<p>It would have to be plain Javascript (no jQuery).
Thanks in advance. </p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.