problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
static int get_physical_address_code(CPUState *env,
target_phys_addr_t *physical, int *prot,
target_ulong address, int is_user)
{
unsigned int i;
uint64_t context;
int is_nucleus;
if ((env->lsu & IMMU_E) == 0 || (env->pstate & PS_RED) != 0) {
*physical = ultrasparc_truncate_physical(address);
*prot = PAGE_EXEC;
return 0;
}
context = env->dmmu.mmu_primary_context & 0x1fff;
is_nucleus = env->tl > 0;
for (i = 0; i < 64; i++) {
if (ultrasparc_tag_match(&env->itlb[i],
address, context, physical,
is_nucleus)) {
if ((env->itlb[i].tte & 0x4) && is_user) {
if (env->immu.sfsr)
env->immu.sfsr = 2;
env->immu.sfsr |= (is_user << 3) | 1;
env->exception_index = TT_TFAULT;
#ifdef DEBUG_MMU
printf("TFAULT at 0x%" PRIx64 "\n", address);
#endif
return 1;
}
*prot = PAGE_EXEC;
TTE_SET_USED(env->itlb[i].tte);
return 0;
}
}
#ifdef DEBUG_MMU
printf("TMISS at 0x%" PRIx64 "\n", address);
#endif
env->immu.tag_access = (address & ~0x1fffULL) | context;
env->exception_index = TT_TMISS;
return 1;
}
| 1threat |
Create empty conda environment : <p>I can create a new conda environment, with program <code>biopython</code> with this:</p>
<pre><code>conda create --name snowflakes biopython
</code></pre>
<p>What if I do not want to install any program? It seems I can not do that:</p>
<pre><code>» conda create --name tryout
Error: too few arguments, must supply command line package specs or --file
You can specify one or more default packages to install when creating
an environment. Doing so allows you to call conda create without
explicitly providing any package names.
To set the provided packages, call conda config like this:
conda config --add create_default_packages PACKAGE_NAME
</code></pre>
| 0debug |
NoUiSlider - doesn't hide lines : <p>I have NoUiSlider 12.1.0 in my CSS theme (modern admin) and it works fine, but there is some problem with CSS. When I move by handle the slider lines behind them are not hiding / changing color. Do anyone know what can cause the problem, or what class/styles I should check?</p>
<p><a href="https://i.stack.imgur.com/VGnSd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VGnSd.png" alt="enter image description here"></a></p>
| 0debug |
C++ - Moving generated numbers into a string : <p>I have a code that generates some numbers, and now I need to count how frequent they are. For example, the code will generate 100000 numbers, and i need to know how many times does 0 appear, 1, 2... I know that this can be done with strings, but im having a problem turning those values into one big string.
You see, all the generated numbers will be the same variable G, so if a ask to turn G into a string, Im going to have a string of the very last number assigned to G, and not of all of them, that is beacuse the variable G changes value each time its printed, because it is inside a loop. is there any way for me to move ALL the printed values into one big string? (If 100000 is too much for a string, i can generate less numbers with little problem)</p>
<p>This is the code</p>
<pre><code>int a,b,c,d,e,f,g,h,i,k,A,B,C,D,E,F,G;
srand(time(NULL));
int seed = rand();
default_random_engine ran { static_cast <int>( chrono::high_resolution_clock::now().time_since_epoch().count())};
default_random_engine ran_2 { static_cast <int>( chrono::high_resolution_clock::now().time_since_epoch().count())};
uniform_int_distribution <int> range {1,50};
a=range (ran);
b = 2;
c = 107;
d = 109;
e = 113;
f = 167;
g = 173;
h = 587;
i = 13;
for ( k=0; k < 100000; k++) {
srand(time(NULL));
int seed = rand();
default_random_engine ran { static_cast <int>( chrono::high_resolution_clock::now().time_since_epoch().count())};
default_random_engine ran_2 { static_cast <int>( chrono::high_resolution_clock::now().time_since_epoch().count())};
uniform_int_distribution <int> range {1,50};
a=range (ran);
b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++; b++;
c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++; c++;
d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++; d++;
e++; e++; e++; e++; e++; e++; e++; e++; e++; e++; e++; e++; e++; e++; e++; e++; e++; e++;
f++; f++;
g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--; g--;
h--; h--; h--; h--; h--; h--; h--; h--; h--; h--; h--;
i--; i--; i--; i--; i--; i--; i--; i--; i--; i--; i--; i--; i--; i--; i--; i--; i--; i--; i--; i--; i--; i--; i--; i--;
A= (a*b*c*f);
B= ((A^13)/d*h-i^a);
C= (A*B^i-b*h*g*e*a);
D= (b+c+d+e+f+g+h+i)*a;
E= ((a*A*B*C*D)/100000000);
F= E % 10;
if ( F < 0 ) { G = F*(-1); } else { G = F; }
cout << G;
}
</code></pre>
<p>}</p>
<p>Thank you very much! :) Have a great day</p>
| 0debug |
aws lambda Unable to import module 'lambda_function': No module named 'requests' : <p>I have recently started to use AWS Lambda to use triggers against some python code I have written. I currently have 2 lambda functions, both of which have been created with ZIP files. The second one I created is supposed to test the trigger events.</p>
<p>This is for testing purposes so I'm using the best code of all: </p>
<pre><code>def lambda_handler(event, context):
print ("Hello World")
</code></pre>
<p>However, I get this error back:</p>
<pre><code>Response:
{
"errorMessage": "Unable to import module 'lambda_function'"
}
Request ID:
"65024f16-172c-11e8-ab26-27ff3322e597"
Function Logs:
START RequestId: 65024f16-172c-11e8-ab26-27ff3322e597 Version: $LATEST
Unable to import module 'lambda_function': No module named 'requests'
END RequestId: 65024f16-172c-11e8-ab26-27ff3322e597
REPORT RequestId: 65024f16-172c-11e8-ab26-27ff3322e597 Duration: 15.93 ms
Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 22 MB
</code></pre>
<p>Everywhere I have searched for this, the answer was solved by making sure the names for the functions were correct or making sure the .zip file was readable. I have satisfied both of these conditions (the name of the file is lambda_function.py and it is in the root). </p>
<p>Alternatively, it seems like it might be an issue with the logs. I double checked my permission and I have the ability to create logs with all resources. Any other ideas what the issue might be?</p>
| 0debug |
How to merge two branches(master and demo branch) code in Git : <p>I've 2 branches,like master and demo.
I want to merge demo code in to master so please help me to solve this issue.
Branches
1 Master
2 demo</p>
| 0debug |
How i can libere my application memoire in c#? : in my c# application load form i make load like 30 picture and this make my memory full and if i addd some more pic i get the message "that my memroy is full"
1/ how i can make my memory empty or make more bigger ?
2/ the are any another way to get all my pics to picture box without make my memory full ?
thank you for anyone wanna help or try help me
[this is my load form
1. List item
[\]\[1\][1]
[1]: https://i.stack.imgur.com/bFVjy.png | 0debug |
Pattern match list with exactly 2 elements in Haskell : <p>I just started learning Haskell and I'm trying to use pattern matching to match a list that has exactly 2 elements. As an exercise, I'm trying to write a function which returns the one but last element from a list. So far I found this:</p>
<pre><code>myButLast :: [a] -> a
myButLast [] = error "Cannot take one but last from empty list!"
myButLast [x] = error "Cannot take one but last from list with only one element!"
myButLast [x:y] = x
myButLast (x:xs) = myButLast xs
</code></pre>
<p>Now the line with myButLast [x:y] is clearly incorrect, but I don't know how to match a list that has exactly 2 elements, as that is what I'm trying to do there. I read this (<a href="http://learnyouahaskell.com/syntax-in-functions#pattern-matching" rel="noreferrer">http://learnyouahaskell.com/syntax-in-functions#pattern-matching</a>) page and it helped me a lot, but I'm not completely there yet...</p>
| 0debug |
How to input strings into stack until newline in C++? : i/p - hello world
I've to input the 2 strings word by word into the stack.
`stack<string> st;`
`string str;
``while(str!="\n")`
{
cin>>str;
st.push(str);
}
It's executing infinitely. | 0debug |
Is Java and Python both Pass-by-Object-reference? : So in Python you can do the following:
def append(list):
list.append(1)
list = [0]
append(list)
print(list)
This obviously allows me to append 1 to the list, however if I change the reference of list within the append function it doesn't change (which is as expected due to Pass-by-Object-reference). Java works similar however it's considered Pass-by-Value. Does this simply mean that Python is like C++ when it passes a pointer that points to an object by value and then dereferences? | 0debug |
How to use maketrans() and translate() methods on strings in python3? : How can I use the maketrans() and tranlate() method on a string to get the translated string in Python3?
eg.
In variable
s='The quick brown fox'
If I have to replace 'The' with '123' in variable 's' how can I do it with these two methods in Python3?
output: '123 quick brown fox' | 0debug |
Xcode 9.1 simulator stay in front button missing? : <p>There used to be a button called "stay in front" in older versions of ios simulater. I used this often, but in recent updates it seems to be removed. Is there a any way to activate this feature ? </p>
<p><a href="https://i.stack.imgur.com/6KaFN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6KaFN.png" alt="https://imgur.com/a/sYXDM"></a>
new window menu</p>
<p><a href="https://i.stack.imgur.com/RRxeh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RRxeh.png" alt="old window menu"></a> old window menu</p>
| 0debug |
How to destructur an array with this : <p>My linter is become crazy with this:</p>
<pre><code>this.views = data.data[226];
</code></pre>
<p>What is the proper way of writing this using array destructuring? </p>
| 0debug |
The use of Repository and unit of work patterns (revisited) ... in EF Core with ASP.NET Core : <p>I was following <a href="https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/advanced#repository-and-unit-of-work-patterns" rel="noreferrer">this tutorial</a> for EF Core with ASP.NET Core. The interesting thing is that this article states that 'the use of Repository and unit of work patterns is not always the best choice for applications that use EF', but in the tutorial of EF 5 the use of repository and unit of work patterns still is promoted even with a seperate tutorial part. </p>
<p>Reading <a href="https://stackoverflow.com/questions/8749153/why-use-repository-pattern-or-please-explain-it-to-me">old articles</a> on stackoverflow it is reported that the reasons one would apply it is mainly for testing (dependency injection). </p>
<p>Reading further in the turial it is mentioned that 'The Entity Framework Core implements an in-memory database provider that can be used for testing'. I presume this is a new feature that was not there at the time of EF5. Does this mean that there is hardly any reason anymore to apply the use of repository and unit of work patterns in EF Core with ASP.NET Core?</p>
| 0debug |
static int dxa_probe(AVProbeData *p)
{
if (p->buf_size <= 4)
return 0;
if (p->buf[0] == 'D' && p->buf[1] == 'E' &&
p->buf[2] == 'X' && p->buf[3] == 'A')
return AVPROBE_SCORE_MAX;
else
return 0;
}
| 1threat |
void ppc_slb_invalidate_one (CPUPPCState *env, uint64_t T0)
{
tlb_flush(env, 1);
}
| 1threat |
static void mptsas_fetch_request(MPTSASState *s)
{
PCIDevice *pci = (PCIDevice *) s;
char req[MPTSAS_MAX_REQUEST_SIZE];
MPIRequestHeader *hdr = (MPIRequestHeader *)req;
hwaddr addr;
int size;
if (s->state != MPI_IOC_STATE_OPERATIONAL) {
mptsas_set_fault(s, MPI_IOCSTATUS_INVALID_STATE);
return;
}
addr = s->host_mfa_high_addr | MPTSAS_FIFO_GET(s, request_post);
pci_dma_read(pci, addr, req, sizeof(hdr));
if (hdr->Function < ARRAY_SIZE(mpi_request_sizes) &&
mpi_request_sizes[hdr->Function]) {
size = mpi_request_sizes[hdr->Function];
assert(size <= MPTSAS_MAX_REQUEST_SIZE);
pci_dma_read(pci, addr + sizeof(hdr), &req[sizeof(hdr)],
size - sizeof(hdr));
}
if (hdr->Function == MPI_FUNCTION_SCSI_IO_REQUEST) {
mptsas_process_scsi_io_request(s, (MPIMsgSCSIIORequest *)req, addr);
} else {
mptsas_process_message(s, (MPIRequestHeader *)req);
}
}
| 1threat |
I am unable to raise exceptions correctly in my flask app : <p>In my flask app, I am unable to throw an error due to the following line of code.</p>
<p>Note that MyException is a class that is subclass of the Exception class, and it imports status from the flask_api.</p>
<pre><code>raise MyException(
status.HTTP_400_BAD_REQUEST, "File does not exist: " + file_path
)
</code></pre>
<p>However, this yields the following error in my terminal when I get to this error in my webpage:</p>
<pre><code>TypeError: 'tuple' object is not callable
The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a tuple.
</code></pre>
<p>Am I unable to raise exceptions in flask?</p>
| 0debug |
Xgboost-How to use "mae" as objective function? : <p>I know xgboost need first gradient and second gradient, but anybody else has used "mae" as obj function?</p>
| 0debug |
How I could create a theme selector for Django (ideas, advices, ...) : <p>I'm developping and improving my <code>Django</code> website and I would like to get advices about <code>graphic charts</code> and what I can do with Django.
When I'm developping my software, I adopted a graphic chart according to my compagny's colors (blue and white) in order to display a good trial version.</p>
<p>But, if I have to develope my project for another compagny, let suppose with "green and red" graphic chart, I have to modify all my CSS files and replace original white & blue colors by green & red.</p>
<p>My question is :</p>
<p><strong>How I could write a script which will be located in a tools menu in my Django website with a <code>theme selector</code> ?</strong></p>
<p>For example, I had to create some CSS file and choose the good one by checking a case ? Then, the website will adopt colors from this theme.</p>
<p>Something like this in <code>Dolibarr Software</code> :</p>
<p><a href="https://i.stack.imgur.com/k1uBf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k1uBf.png" alt="enter image description here"></a></p>
<p>For the moment, I'm just getting some ideas / processes and if someone had already made this kind of things ?</p>
<p>Thank you</p>
| 0debug |
I WANT TO USE CASE WHEN COMMAND WITH THREEN CONTIATION PLZ GIVE U R SUGGESTIONTHIS IS MY QUERY BUT SHOW ING ERROR :
SELECT DISTINCT A.PHONE, OTHER,STARTTIME,duration,imeinumber,imsinumber,CALL_TYPE,a.provider_key, A.CELLTOWERID, SITEADDRESS,
LAT, LONG, AZIMUTH FROM cdat A
LEFT JOIN CDATDUPL.DBO.CDATCELLTOWERAREANEW B ON case when a.provider_key!='9' then a.tower_key=b.TOWER_KEY else
A.celltowerid = B.CELLTOWERID
AND A.PROVIDER_key=B.PROVIDER_KEY and a.state_key end=b.state_key | 0debug |
const char *qdict_get_str(const QDict *qdict, const char *key)
{
QObject *obj = qdict_get_obj(qdict, key, QTYPE_QSTRING);
return qstring_get_str(qobject_to_qstring(obj));
}
| 1threat |
import math
def is_polite(n):
n = n + 1
return (int)(n+(math.log((n + math.log(n, 2)), 2))) | 0debug |
how to Save Words in Array, in C : I am making a school project which is about restaurant menu.
I have to save all of my items name separately in an array, and their price in different array.
**OUTPUT SHOULD BE SOMETHING LIKE THIS**
1. Burger 19.2
2. Fries 21.21
....
#include <stdio.h>
#include <stdlib.h>
#define TOTALITEM 3
int main()
{
const char *menu[TOTALITEM] = {"Burger", "fries", "wings"};
double menuPrice[TOTALITEM] = {15.2, 21.21, 51.2};
for (int i = 0; i < TOTALITEM; i++)
{
printf("\n%i. %c", i+1,menu[i]);
printf("\t\t %.2lf", menuPrice[i]);
}
}
| 0debug |
static int gd_vc_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
{
VirtualConsole *vc = chr->opaque;
return vc ? write(vc->fd, buf, len) : len;
}
| 1threat |
static uint64_t ivshmem_io_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
IVShmemState *s = opaque;
uint32_t ret;
switch (addr)
{
case INTRMASK:
ret = ivshmem_IntrMask_read(s);
break;
case INTRSTATUS:
ret = ivshmem_IntrStatus_read(s);
break;
case IVPOSITION:
if (s->shm_fd > 0) {
ret = s->vm_id;
} else {
ret = -1;
}
break;
default:
IVSHMEM_DPRINTF("why are we reading " TARGET_FMT_plx "\n", addr);
ret = 0;
}
return ret;
}
| 1threat |
RxJS 5, converting an observable to a BehaviorSubject(?) : <p>I have a parent observable that, once it has a subscriber, will do a lookup and emit a single value, then complete.</p>
<p>I'd like to convert that into an observable (or behavior subject or whatever works) that does the following: once it has at least one subscriber, it gets the result from the parent observable (once). Then it emits that value to all of its subscribers, and also emits that single value to all future subscribers, when they subscribe. It should continue with this behavior even if its subscriber count drops to zero.</p>
<p>It seems like this should be easy. Here is what didn't work:</p>
<pre><code>theValue$: Observable<boolean> = parent$
.take(1)
.share()
</code></pre>
<p>Other things that didn't work: <code>publishReplay()</code>, <code>publish()</code>. Something that worked better:</p>
<pre><code>theValue$ = new BehaviorSubject<boolean>(false);
parent$
.take(1)
.subscribe( value => theValue$.next(value));
</code></pre>
<p>There is a problem with this approach, though: <code>parent$</code> is subscribed to before <code>theValue$</code> gets its first subscriber.</p>
<p>Is there a better way to handle this?</p>
| 0debug |
Javscript [object Object] see content : I have maybe a real simple problem, but i need to know how to do this.
My ambitions:
<!-- begin snippet: js hide: false -->
<!-- language: lang-js -->
var test_obj = {
'test' : 't',
'test2' : 't2'
}
/*
when i log a object it often gives me somthing like this:
[object Object]
but if i want to take a look into the object, i want to see (for test_obj):
{ 'test' : 't', 'test2' : 't2' }
*/
<!-- end snippet -->
So how can I log an ibject that it shows me what is in it ?
| 0debug |
R - aggregating sum row wise : <p>I have a data frame mydf as <code> mydf <- data.frame(month = c('apr', 'may', 'june'),cost = c(100, 150, 200))</code></p>
<p>I wish to get a runningTotal that sums each record cumulatively</p>
<pre><code> month cost runningTotal
1 apr 100 100
2 may 150 250
3 june 200 450
</code></pre>
<p>I tried using dplyr sum but didn't work.
Can someone help me find the most efficient way of doing this
Thanks.</p>
| 0debug |
static av_cold int encode_close(AVCodecContext *avctx)
{
if (avctx->priv_data) {
DCAEncContext *c = avctx->priv_data;
subband_bufer_free(c);
ff_dcaadpcm_free(&c->adpcm_ctx);
}
return 0;
}
| 1threat |
using regex to account for any dollar amount entry in python 3, including just decimal values without grouping : I'm trying to account for the possibility of any USD denomination and I came up with this:
\$\d+\.?\,?\d+\.?\d+
This works for entries like **$10,500.23, $1,050.23, $105.23, $105, $10, $1**
But won't work for things like **$.23**
I tried using \d+? instead of just \d? but that doesn't seem to work either (maybe there is a special way of handling this that I'm unaware of?) | 0debug |
int[] from String or int[] from char[] : <p>what i want to do is take a String of numbers like "8675309" and then do some math based on different digits from the String. i'd be happy to get 8, 6, 7, 5, 3, 0, 9 and then using the indexes, but they seem to give weird numbers (like 51) so far. i simply want to wind up doing myArray[0] + myArray[3] = output (this example would be 8+5=13)</p>
<p>i own 6 books on Java and none of them cover this. 6+ hours on the web (google, stackoverflow, youtube, others) and nowhere can i find this. - no matter how i search i get results of everything but.</p>
<p>from arrays which are already populated, to strings already delimited, to discarding everything but numbers from a string, etc...</p>
<p>i tried using/modifying what i've found and the best i can come up with has eclipse yelling at me that it's not possible to convert a char to an int.</p>
<pre><code> String str = cn;
char[] charArray = str.toCharArray();
String number = String.valueOf(cn);
int[] digits1 = number.toCharArray();
int newInt = charArray[0];
System.out.println(newInt);
</code></pre>
<p><em>"Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Type mismatch: cannot convert from char[] to int[]"</em></p>
| 0debug |
error: Unable to resolve build file: XCBCore.BuildFile : <pre><code>error: Unable to resolve build file: XCBCore.BuildFile (missingTargetProductReference("3bf83096e50de72a94699e9afc1133ebe3512682230d04680075c283a974e273")) (in target 'MyTarget')
</code></pre>
<p>Xcode 10 is giving this error immediately when trying to build our project. It's not immediately clear what is causing it. </p>
<p>How can I resolve it?</p>
| 0debug |
Understanding React's Synthetic Event System : <p>This has been on my mind for a few days now.</p>
<p>As per the docs, React has <a href="https://facebook.github.io/react/docs/events.html" rel="noreferrer">synthetic event system</a>, which is a <code>a cross-browser wrapper around the browser's native event</code>. Going through the docs, is my understanding correct that the custom (synthetic) event system, isn't about efficiency but rather cross-browser compatibility.</p>
<p>In other words, React still appends the event to the element rather than the more efficient approach of event-delegation on the parent element? </p>
<p>I also noticed this in Firefox Inspector which raised the initial curiosity.</p>
<p>The reason for asking the question is that I am working on an app where a user maybe able to select a thousand elements & drag them around the screen, so eventually event delegation is going to come up.</p>
| 0debug |
uint64_t helper_load_fpcr (void)
{
uint64_t ret = 0;
#ifdef CONFIG_SOFTFLOAT
ret |= env->fp_status.float_exception_flags << 52;
if (env->fp_status.float_exception_flags)
ret |= 1ULL << 63;
env->ipr[IPR_EXC_SUM] &= ~0x3E:
env->ipr[IPR_EXC_SUM] |= env->fp_status.float_exception_flags << 1;
#endif
switch (env->fp_status.float_rounding_mode) {
case float_round_nearest_even:
ret |= 2ULL << 58;
break;
case float_round_down:
ret |= 1ULL << 58;
break;
case float_round_up:
ret |= 3ULL << 58;
break;
case float_round_to_zero:
break;
}
return ret;
}
| 1threat |
Javascript Boolean doesn't work, Larvel 5.6 : I want to redirect the user to the edit.blade page when they login for the first time. for this I made an if else statement, but it doesn't work and i have no idea what the problem is. Can someone help me.
this is the code that i have now:
// This section is the only change
if ($this->guard()->validate($this->credentials($request))) {
$user = $this->guard()->getLastAttempted();
dd($user);
// Make sure the user is active
if ($user->verified && $this->attemptLogin($request)) {
if ($user->first_time_login == true || $user->first_time_login == 1) {
$this->redirectTo = '/users/edit';
$user->first_time_login = false;
$user->save();
}
return $this->sendLoginResponse($request);
| 0debug |
R: as.POSIXct timezone and scale_x_datetime issues in my dataset : <p>I spent some time trying to figure out why the hour ticks were shifted when scale_x_datetime was applied. I've tried to give the timezone when the Date/Time column was created. I used ggplot and scale_x_datetime() from the package scales. The hour ticks were wrong, which datapoint did not match the time in their Date/Time column.</p>
<p>Here is some procedures to deal with my dataset. </p>
<pre><code> DF$DateTime<-as.POSIXct(DF$timestamp,format="%m/%d/%y %H:%M", tz="America/Toronto")
DF$Date<-as.Date(DF$DateTime)
lims <- as.POSIXct(strptime(c("2015-07-21 00:00","2015-07-23 00:00"), format = "%Y-%m-%d %H:%M"), tz="America/Toronto")
ggplot(DF) + geom_line(aes(x=DateTime, y=-Diff,group=Date)) + scale_x_datetime(limits =lims, breaks=date_breaks("2 hour"), labels=date_format("%m/%d %H:%M"))
</code></pre>
<p>Do I miss anything here?? Please help me to figure it out.
Many thanks!</p>
| 0debug |
void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr, Error **errp)
{
const CompatInfo *compat = compat_by_pvr(compat_pvr);
CPUPPCState *env = &cpu->env;
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
uint64_t pcr;
if (!compat_pvr) {
pcr = 0;
} else if (!compat) {
error_setg(errp, "Unknown compatibility PVR 0x%08"PRIx32, compat_pvr);
} else {
pcr = compat->pcr;
}
cpu->compat_pvr = compat_pvr;
env->spr[SPR_PCR] = pcr & pcc->pcr_mask;
if (kvm_enabled()) {
int ret = kvmppc_set_compat(cpu, cpu->compat_pvr);
if (ret < 0) {
error_setg_errno(errp, -ret,
"Unable to set CPU compatibility mode in KVM");
}
}
} | 1threat |
Vanilla JavaScript and the DOM changes : <p>I don't understand why I would use JS to alter HTML or CSS. I understand fully why we use it to enhance the interaction of the code. </p>
<p>For example, why would I use "getElementByTagName("p")" to change all of my paragraphs, when I can set my paragraphs initially while I'm writing my HTML? When /in what cases would I need to address these nodes outside of JS interaction? OR, would I address the nodes only for the purpose of enhancing the interaction?</p>
<p>I'm just looking for a clean and clear answer.</p>
<p>Thank you all.</p>
| 0debug |
static void do_fp_ld(DisasContext *s, int destidx, TCGv_i64 tcg_addr, int size)
{
TCGv_i64 tmplo = tcg_temp_new_i64();
TCGv_i64 tmphi;
if (size < 4) {
TCGMemOp memop = MO_TE + size;
tmphi = tcg_const_i64(0);
tcg_gen_qemu_ld_i64(tmplo, tcg_addr, get_mem_index(s), memop);
} else {
TCGv_i64 tcg_hiaddr;
tmphi = tcg_temp_new_i64();
tcg_hiaddr = tcg_temp_new_i64();
tcg_gen_qemu_ld_i64(tmplo, tcg_addr, get_mem_index(s), MO_TEQ);
tcg_gen_addi_i64(tcg_hiaddr, tcg_addr, 8);
tcg_gen_qemu_ld_i64(tmphi, tcg_hiaddr, get_mem_index(s), MO_TEQ);
tcg_temp_free_i64(tcg_hiaddr);
}
tcg_gen_st_i64(tmplo, cpu_env, fp_reg_offset(destidx, MO_64));
tcg_gen_st_i64(tmphi, cpu_env, fp_reg_hi_offset(destidx));
tcg_temp_free_i64(tmplo);
tcg_temp_free_i64(tmphi);
}
| 1threat |
static void timestamp_put(QDict *qdict)
{
int err;
QObject *obj;
qemu_timeval tv;
err = qemu_gettimeofday(&tv);
if (err < 0)
return;
obj = qobject_from_jsonf("{ 'seconds': %" PRId64 ", "
"'microseconds': %" PRId64 " }",
(int64_t) tv.tv_sec, (int64_t) tv.tv_usec);
assert(obj != NULL);
qdict_put_obj(qdict, "timestamp", obj);
}
| 1threat |
Docker Machine vs Docker run : <p>I'm confused between docker-machine vs docker run </p>
<p>docker images, shows me my images
and then I can run one of these images with docker run. </p>
<p>When do I need to use docker-machine? </p>
| 0debug |
PHP Cut URL from some variable query : <p>if I have some URL like these:</p>
<p><code>http://localhost/myfile.php?start=2018&end=2019&page=1&status=</code></p>
<p>Did anynone know how to replace any words from that link that contain <code>page=</code> ?</p>
<p>The result that I want is :</p>
<p><code>http://localhost/myfile.php?start=2018&end=2019&status=</code></p>
<p>Even if the link is like this:</p>
<p><code>http://localhost/myfile.php?start=2018&end=2019&status=&page=3</code></p>
<p>I still want the result will be without <code>page</code> variable and value, so it might be:
<code>http://localhost/myfile.php?start=2018&end=2019&status=</code></p>
<p>any idea how to do this? Especially without regex (regex is my last option)</p>
| 0debug |
static int decode_ref_pic_marking(H264Context *h, GetBitContext *gb){
MpegEncContext * const s = &h->s;
int i;
if(h->nal_unit_type == NAL_IDR_SLICE){
s->broken_link= get_bits1(gb) -1;
h->mmco[0].long_arg= get_bits1(gb) - 1;
if(h->mmco[0].long_arg == -1)
else{
h->mmco[0].opcode= MMCO_LONG;
h->mmco_index= 1;
}
}else{
if(get_bits1(gb)){
for(i= 0; i<MAX_MMCO_COUNT; i++) {
MMCOOpcode opcode= get_ue_golomb(gb);
h->mmco[i].opcode= opcode;
if(opcode==MMCO_SHORT2UNUSED || opcode==MMCO_SHORT2LONG){
h->mmco[i].short_pic_num= (h->curr_pic_num - get_ue_golomb(gb) - 1) & (h->max_pic_num - 1);
}
if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){
unsigned int long_arg= get_ue_golomb(gb);
if(long_arg >= 32 || (long_arg >= 16 && !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))){
av_log(h->s.avctx, AV_LOG_ERROR, "illegal long ref in memory management control operation %d\n", opcode);
return -1;
}
h->mmco[i].long_arg= long_arg;
}
if(opcode > (unsigned)MMCO_LONG){
av_log(h->s.avctx, AV_LOG_ERROR, "illegal memory management control operation %d\n", opcode);
return -1;
}
if(opcode == MMCO_END)
break;
}
h->mmco_index= i;
}else{
assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count);
if(h->short_ref_count && h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count &&
!(FIELD_PICTURE && !s->first_field && s->current_picture_ptr->reference)) {
h->mmco[0].opcode= MMCO_SHORT2UNUSED;
h->mmco[0].short_pic_num= h->short_ref[ h->short_ref_count - 1 ]->frame_num;
h->mmco_index= 1;
if (FIELD_PICTURE) {
h->mmco[0].short_pic_num *= 2;
h->mmco[1].opcode= MMCO_SHORT2UNUSED;
h->mmco[1].short_pic_num= h->mmco[0].short_pic_num + 1;
h->mmco_index= 2;
}
}else
}
}
return 0;
} | 1threat |
How to fix app crash caused due to attemt of reading field from a null reference? : I am creating a sample app that sends notification to the driver when a rider requests pickup (like the uber app) I have a button for that functionality in the app.The app works fine and gets the driver but when i click on the button to call the driver the app crashes showing a nullpointerexception at `if (response.body().success == 1) Toast.makeText(Home.this, "Request Failed!", Toast.LENGTH_SHORT).show();`
this is the code
private void sendRequestToDriver(String driverId) {
DatabaseReference tokens = FirebaseDatabase.getInstance().getReference(Common.token_tbl);
tokens.orderByKey().equalTo(driverId)
.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot postSnapshot:dataSnapshot.getChildren())
{
Token token = postSnapshot.getValue(Token.class);
String json_lat_lng = new Gson().toJson(new LatLng(mLastLocation.getLatitude(),mLastLocation.getLongitude()));
Notification data = new Notification("SKYLAKE",json_lat_lng);
Sender content = null;
if (token != null) {
content = new Sender(token.getToken(),data);
}
mService.sendMessage(content)
.enqueue(new Callback<FCMResponse>() {
@Override
public void onResponse(@NonNull Call<FCMResponse> call, Response<FCMResponse> response) {
if (response.body().success == 1)
Toast.makeText(Home.this, "Request Failed!", Toast.LENGTH_SHORT).show();
else {
Toast.makeText(Home.this, "Request Sent!", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Call<FCMResponse> call, Throwable t) {
Log.e("ERROR",t.getMessage());
}
});
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
the logcat shows `Attempt to read from field 'int com.joy.skylake.enlyftrider.Model.FCMResponse.success' on a null object reference` | 0debug |
Do not have permission to access app while deploying google service account : <p>After creating google service account with permission as shown below - deployment fails with message . I am failing to understand where this is going wrong.</p>
<p>====</p>
<pre><code>$ gcloud iam service-accounts get-iam-policy cdemail@appid.iam.gserviceaccount.com
bindings:
- members:
- serviceAccount:cdemail@appid.iam.gserviceaccount.com
role: roles/owner
etag: Bxxxxxxxxg=
</code></pre>
<p>====</p>
<pre><code>$ gcloud auth activate-service-account --key-file ../a.json
Activated service account credentials for: [cdemail@appid.iam.gserviceaccount.com]
$ gcloud app deploy
ERROR: (gcloud.app.deploy) You do not have permission to access app [appid].
</code></pre>
| 0debug |
JavaScript regular expression and java regular expression : Is javascript and java regular expression are same ??
Can we use same regular expression at both place to validate server side validation and client side validation ???? | 0debug |
static void opt_mb_qmin(const char *arg)
{
video_mb_qmin = atoi(arg);
if (video_mb_qmin < 0 ||
video_mb_qmin > 31) {
fprintf(stderr, "qmin must be >= 1 and <= 31\n");
exit(1);
}
}
| 1threat |
Why is control of flow not reaching to the file according to file path I am providing. : While automating the upload file feature in selenium using Java ,the control is not going to the file according to the file path I have provided. Why is the control not reaching to the file properly? | 0debug |
How to use multiple service accounts with gcloud? : <p>I have two Google Cloud service accounts; one for each of my two projects.</p>
<pre><code># ACCOUNTS
editor@someproj-1.iam.gserviceaccount.com
editor@someproj-2.iam.gserviceaccount.com
</code></pre>
<p>I can tell <code>gcloud</code> which account I need to use before executing a command:</p>
<pre><code>gcloud set account [ACCOUNT]
</code></pre>
<p><strong>Question:</strong> Is there any way I can configure <code>gcloud</code> and <code>gsutil</code> so that they'll be used for operations performed in their respective project without me having to switch between these accounts manually all the time?</p>
<hr>
<p>I'm managing instances in one project and I upload/download files from buckets in another project. It becomes quite tedious to have to perform <code>gcloud set_account [ACCOUNT]</code> all the time in-between commands.</p>
<p>I need to be running long-running commands in both projects at the same time which causes me to think I will fall into a pit if I activate/de-activate the accounts used for these commands.</p>
<p>Perhaps my only option is to run google-cloud-sdk from two different Docker containers?</p>
| 0debug |
av_cold void ff_cavsdsp_init_x86(CAVSDSPContext *c, AVCodecContext *avctx)
{
int cpu_flags = av_get_cpu_flags();
cavsdsp_init_mmx(c, avctx);
#if HAVE_AMD3DNOW_INLINE
if (INLINE_AMD3DNOW(cpu_flags))
cavsdsp_init_3dnow(c, avctx);
#endif
#if HAVE_MMXEXT_INLINE
if (INLINE_MMXEXT(cpu_flags)) {
DSPFUNC(put, 0, 16, mmxext);
DSPFUNC(put, 1, 8, mmxext);
DSPFUNC(avg, 0, 16, mmxext);
DSPFUNC(avg, 1, 8, mmxext);
}
#endif
#if HAVE_MMX_EXTERNAL
if (EXTERNAL_MMXEXT(cpu_flags)) {
c->avg_cavs_qpel_pixels_tab[0][0] = avg_cavs_qpel16_mc00_mmxext;
c->avg_cavs_qpel_pixels_tab[1][0] = avg_cavs_qpel8_mc00_mmxext;
}
#endif
#if HAVE_SSE2_EXTERNAL
if (EXTERNAL_SSE2(cpu_flags)) {
c->put_cavs_qpel_pixels_tab[0][0] = put_cavs_qpel16_mc00_sse2;
c->avg_cavs_qpel_pixels_tab[0][0] = avg_cavs_qpel16_mc00_sse2;
}
#endif
}
| 1threat |
Type hinting sqlalchemy query result : <p>I can't figure out what kind of object a sqlalchemy query returns.</p>
<pre><code>entries = session.query(Foo.id, Foo.date).all()
</code></pre>
<p>The type of each object in entries seems to be <code>sqlalchemy.util._collections.result</code>, but a quick <code>from sqlalchemy.util._collections import result</code> in a python interpreter raises an ImportError.</p>
<p>What I'm ultimately trying to do is to type hint this function:</p>
<pre><code>def my_super_function(session: Session) -> ???:
entries = session.query(Foo.id, Foo.date).all()
return entries
</code></pre>
<p>What should I put in place of <code>???</code>? mypy (in this case) seems to be fine with <code>List[Tuple[int, str]]</code> because yes indeed I can access my entries like if they were tuples, but i can also access them with <code>entry.date</code>, for example.</p>
| 0debug |
How to check for null int? : <p>Is this conditional check OK? It works fine but I'm wondering if there is a potential hidden issue. It sure is a lot simpler than having to check for null.</p>
<pre><code>public int? myInt;
if (myInt > 0)
{
Do something
}
</code></pre>
| 0debug |
Using SafeArea in Flutter : <p>I am trying to understand the <a href="https://docs.flutter.io/flutter/widgets/SafeArea-class.html" rel="noreferrer">SafeArea</a> widget in Flutter.</p>
<p>SafeArea code added to Flutter Gallery app <a href="https://github.com/flutter/flutter/pull/13593" rel="noreferrer">here</a> in github show <code>top:false</code> and <code>bottom:false</code> everywhere. Why do these need to be set false in these cases?
<a href="https://i.stack.imgur.com/tVOSv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tVOSv.png" alt="enter image description here"></a></p>
| 0debug |
static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
unsigned int op0, unsigned int op1, unsigned int op2,
unsigned int crn, unsigned int crm, unsigned int rt)
{
const ARMCPRegInfo *ri;
TCGv_i64 tcg_rt;
ri = get_arm_cp_reginfo(s->cp_regs,
ENCODE_AA64_CP_REG(CP_REG_ARM64_SYSREG_CP,
crn, crm, op0, op1, op2));
if (!ri) {
qemu_log_mask(LOG_UNIMP, "%s access to unsupported AArch64 "
"system register op0:%d op1:%d crn:%d crm:%d op2:%d\n",
isread ? "read" : "write", op0, op1, crn, crm, op2);
unallocated_encoding(s);
return;
}
if (!cp_access_ok(s->current_pl, ri, isread)) {
unallocated_encoding(s);
return;
}
if (ri->accessfn) {
TCGv_ptr tmpptr;
gen_a64_set_pc_im(s->pc - 4);
tmpptr = tcg_const_ptr(ri);
gen_helper_access_check_cp_reg(cpu_env, tmpptr);
tcg_temp_free_ptr(tmpptr);
}
switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) {
case ARM_CP_NOP:
return;
case ARM_CP_NZCV:
tcg_rt = cpu_reg(s, rt);
if (isread) {
gen_get_nzcv(tcg_rt);
} else {
gen_set_nzcv(tcg_rt);
}
return;
case ARM_CP_CURRENTEL:
tcg_rt = cpu_reg(s, rt);
tcg_gen_movi_i64(tcg_rt, s->current_pl << 2);
return;
default:
break;
}
if (use_icount && (ri->type & ARM_CP_IO)) {
gen_io_start();
}
tcg_rt = cpu_reg(s, rt);
if (isread) {
if (ri->type & ARM_CP_CONST) {
tcg_gen_movi_i64(tcg_rt, ri->resetvalue);
} else if (ri->readfn) {
TCGv_ptr tmpptr;
tmpptr = tcg_const_ptr(ri);
gen_helper_get_cp_reg64(tcg_rt, cpu_env, tmpptr);
tcg_temp_free_ptr(tmpptr);
} else {
tcg_gen_ld_i64(tcg_rt, cpu_env, ri->fieldoffset);
}
} else {
if (ri->type & ARM_CP_CONST) {
return;
} else if (ri->writefn) {
TCGv_ptr tmpptr;
tmpptr = tcg_const_ptr(ri);
gen_helper_set_cp_reg64(cpu_env, tmpptr, tcg_rt);
tcg_temp_free_ptr(tmpptr);
} else {
tcg_gen_st_i64(tcg_rt, cpu_env, ri->fieldoffset);
}
}
if (use_icount && (ri->type & ARM_CP_IO)) {
gen_io_end();
s->is_jmp = DISAS_UPDATE;
} else if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) {
s->is_jmp = DISAS_UPDATE;
}
}
| 1threat |
static void get_private_data(OutputStream *os)
{
AVCodecContext *codec = os->ctx->streams[0]->codec;
uint8_t *ptr = codec->extradata;
int size = codec->extradata_size;
int i;
if (codec->codec_id == AV_CODEC_ID_H264) {
ff_avc_write_annexb_extradata(ptr, &ptr, &size);
if (!ptr)
ptr = codec->extradata;
}
if (!ptr)
return;
os->private_str = av_mallocz(2*size + 1);
if (!os->private_str)
return;
for (i = 0; i < size; i++)
snprintf(&os->private_str[2*i], 3, "%02x", ptr[i]);
if (ptr != codec->extradata)
av_free(ptr);
}
| 1threat |
int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
enum AVSampleFormat sample_fmt, int align)
{
int line_size;
int sample_size = av_get_bytes_per_sample(sample_fmt);
int planar = av_sample_fmt_is_planar(sample_fmt);
if (!sample_size || nb_samples <= 0 || nb_channels <= 0)
if (!align) {
align = 1;
nb_samples = FFALIGN(nb_samples, 32);
}
if (nb_channels > INT_MAX / align ||
(int64_t)nb_channels * nb_samples > (INT_MAX - (align * nb_channels)) / sample_size)
line_size = planar ? FFALIGN(nb_samples * sample_size, align) :
FFALIGN(nb_samples * sample_size * nb_channels, align);
if (linesize)
*linesize = line_size;
return planar ? line_size * nb_channels : line_size;
} | 1threat |
SQL INSERT statement is not executing but I am not receiving an exception either : On my button click event I am just wanting to insert a row into a table. When i click the button i get no exception and i also don't get my messagebox to show either. I have the messagebox as a way to check to see if the query had been executed. When i step through it skips the MessageBox and doesn't throw an exception.
private void BtnSend_Click(object sender, EventArgs e)
{
string theDate = dateTimePicker1.Value.ToString("MM-dd-yyyy");
var select = "INSERT INTO Trinity3(Date, Device_S_N, Student_Last_Name, Student_First_Name, Student_Number, School, Grade, Damage)" +
"VALUES (@Date, @Serial, @LastName, @FirstName, @StudentNum, @School, @Grade, @Damage)" +
"COMMIT";
SqlConnection connection = new SqlConnection("Data Source=CPS1113020004; Initial Catalog=Coweta Public Schools; Integrated Security=True");
//Create a SqlCommand instance
SqlCommand command = new SqlCommand(select, connection);
//Add the parameter
command.CommandType = CommandType.Text;
command.CommandText = select;
command.Parameters.AddWithValue("@Date", theDate);
command.Parameters.AddWithValue("@Serial",txtSerial.Text);
command.Parameters.AddWithValue("@LastName",txtLastName.Text);
command.Parameters.AddWithValue("@FirstName",txtFirstName.Text);
command.Parameters.AddWithValue("@StudentNum", txtStudentNum.Text);
command.Parameters.AddWithValue("@School",txtSchool.Text);
command.Parameters.AddWithValue("@Grade", txtGrade.Text);
command.Parameters.AddWithValue("@Damage", txtDamage.Text);
//Execute the query
try
{
connection.Open();
command.ExecuteNonQuery();
MessageBox.Show("Records Inserted Successfully");
}
catch
{
//Handle exception, show message to user...
}
finally
{
connection.Close();
}
this.Visible = false;
var searchForm = new SearchForm();
searchForm.ShowDialog();
} | 0debug |
How to register on gcm to get the registration id from gcm : <p>I want to use GCM in my project I read about the GCM i understood the working of it but when i am not unable to understand how we do code to get the registration id form GCM can you give me full code to get the registration id from GCM please don't say that do google.
please give me code how can i register on GCM and how can I get registration id from GCM. </p>
| 0debug |
cursor.execute('SELECT * FROM users WHERE username = ' + user_input) | 1threat |
void usb_generic_async_ctrl_complete(USBDevice *s, USBPacket *p)
{
if (p->len < 0) {
s->setup_state = SETUP_STATE_IDLE;
}
switch (s->setup_state) {
case SETUP_STATE_SETUP:
if (p->len < s->setup_len) {
s->setup_len = p->len;
}
s->setup_state = SETUP_STATE_DATA;
p->len = 8;
break;
case SETUP_STATE_ACK:
s->setup_state = SETUP_STATE_IDLE;
p->len = 0;
break;
default:
break;
}
usb_packet_complete(s, p);
}
| 1threat |
What is the difference between Pipeline and Release Pipeline in azure devops? : <p>An yaml file is generated while you choose this option shown below: </p>
<p><a href="https://i.stack.imgur.com/srDc7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/srDc7.png" alt="enter image description here"></a></p>
<p>In this yaml file, you can define an entire deployment cycle starting from <code>restore -> build -> run tests -> publish and -> deploy to azure app service web app</code>. </p>
<p>then, why there is the releases option? If i can define an entire lifecycle via the <code>Pipelines -> Pipelines</code> option, what is the purpose of the <code>Pipelines -> Releases</code> option? </p>
<p><a href="https://i.stack.imgur.com/zb6ax.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zb6ax.png" alt="enter image description here"></a></p>
| 0debug |
c# getting word before special character including whitespace or no whitespace : i have a string eg: string text = "select * from value='value' and testvalue = ?test and status like ?status";
i have tried using regular expression
var m = Regex.Matches(str, @"(\S+)\s+=");//with whitespace
var m = Regex.Matches(str, @"(\S+)=");//without whitespace
i need to get my output in dynamic labels and textbox
output:
label textbox
testvalue
status
here in this string if already value present i dodnt want it as labels and textbox
only with question mark and like must give me output as mentioned above
if whitespaces present between '=', it must dicsard and give output | 0debug |
import re
def find_character(string):
uppercase_characters = re.findall(r"[A-Z]", string)
lowercase_characters = re.findall(r"[a-z]", string)
numerical_characters = re.findall(r"[0-9]", string)
special_characters = re.findall(r"[, .!?]", string)
return uppercase_characters, lowercase_characters, numerical_characters, special_characters | 0debug |
please help, c++ isnt changing variable value : i want the code to get out of the while loop when i input a number other than 66, i made it print the value of plz to see if th evalue was changing. it is not changing, it stays at 1 even though i typed plz=o;
please help
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
cout << "welcome to the random number generator, please enter a
number\n";
int plz=1, d;
d=1;
while (plz>0)
{
d=d+1;
int g;
cin >> g;
g= 666;
if (g==666)
int j;
else
plz=0;
cout << plz << "\n";
}
srand (d);
d= rand();
cout << d << "\n";
}
` | 0debug |
void usb_desc_create_serial(USBDevice *dev)
{
DeviceState *hcd = dev->qdev.parent_bus->parent;
const USBDesc *desc = usb_device_get_usb_desc(dev);
int index = desc->id.iSerialNumber;
char serial[64];
char *path;
int dst;
if (dev->serial) {
usb_desc_set_string(dev, index, dev->serial);
return;
}
assert(index != 0 && desc->str[index] != NULL);
dst = snprintf(serial, sizeof(serial), "%s", desc->str[index]);
path = qdev_get_dev_path(hcd);
if (path) {
dst += snprintf(serial+dst, sizeof(serial)-dst, "-%s", path);
}
dst += snprintf(serial+dst, sizeof(serial)-dst, "-%s", dev->port->path);
usb_desc_set_string(dev, index, serial);
} | 1threat |
C# selenium. pls help me : First of all, Im not good at English. I want u to understand it.
Im programing selenium of c#. but I dont understand howto useit;/
For example,I want to check the XPath that I want to click from HTML.
This is the HTML Iwant.
<span class="option_text">10</span>
Below is the original HTML
-----
<div class="report_options _options">
<a href="#" class="option" data-reportpolicy="R1">
<i class="ico as_radio"></i>
<span class="option_text">1</span>
</a>
<a href="#" class="option" data-reportpolicy="R2">
<i class="ico as_radio"></i>
<span class="option_text">2</span>
</a>
.
.(Omitted)
.
<a href="#" class="option" data-reportpolicy="R11">
<i class="ico as_radio"></i>
<span class="option_text">10</span>
</a>
</div>
I used
WebDriver.FindElement(By.XPath("//span[contains(@class,'option_text') and contains(text(), '10')]")).Click();
but I could not.
Someone give me advice pls. | 0debug |
regex matching parsing : <p>I have this patter <code>p</code> and want to use this pattern to find if it has any matching. This is in Python.</p>
<p><code>p = "keyword" + ".*?(\d+(\.\d+)?[\s%]?[\w/]*)"
found = re.findall(p, some_text)
</code></p>
<p>I have problem parsing this regex.</p>
<ol>
<li><p>What is the first "?". </p>
<p>I understand that ".*" matches any thing for 0 or more times. But not sure what the "?" does here.</p></li>
<li><p>It is weird to see nested capture group parenthesis. What does it do?</p></li>
<li><p>What is the "?" in <code>[\s%]?</code> regex? I assume this is matching white space followed by "%". But not sure what the "?" does here.</p></li>
<li><p>What is the asterisk in <code>[\w/]*</code> regex? I assume this is matching any word character followed by forward slash. But not sure what the "*" does.</p></li>
</ol>
| 0debug |
What is wrong with my java code, it won't compile? : <p>Okay so I typed a java code to do a simple function. Every time I enter it won't let me compile. Where is my error in this code?</p>
<pre><code>public int add(int a, int b) {
int sum;
sum = a + b;
}
public static void main(String[] args){
int x = 5;
double y = 7;
int total = add(x,y);
System.out.println(total);
}
</code></pre>
| 0debug |
while true, check if name in names : amount_of_names = int(input("Input amount of players: "))
names = []
for counter in range(amount_of_names):
name = str(input("Input players first name: "))
names.append(name)
#print (names)
selected_name = str(input("Input your name: "))
import random
names = random.choice(names)
while True:
name in names
import random
names = random.choice(names)
break
print (names)
I would like the "while true" statement to run until "name" and "names" do not match, if the name does not match, then print the non-matching name. Atm I only get a letter as an output or a syntax error whilst trying to get this working, effectively unable to be matched with their name if it is already in the list - if anyone can help it would be much appreciated
| 0debug |
static int ftp_get_line(FTPContext *s, char *line, int line_size)
{
int ch;
char *q = line;
int ori_block_flag = s->conn_control_block_flag;
for (;;) {
ch = ftp_getc(s);
if (ch < 0) {
s->conn_control_block_flag = ori_block_flag;
return ch;
}
if (ch == '\n') {
if (q > line && q[-1] == '\r')
q--;
*q = '\0';
s->conn_control_block_flag = ori_block_flag;
return 0;
} else {
s->conn_control_block_flag = 0;
if ((q - line) < line_size - 1)
*q++ = ch;
}
}
}
| 1threat |
QObject *qlist_peek(QList *qlist)
{
QListEntry *entry;
QObject *ret;
if (qlist == NULL || QTAILQ_EMPTY(&qlist->head)) {
return NULL;
}
entry = QTAILQ_FIRST(&qlist->head);
ret = entry->value;
return ret;
}
| 1threat |
static void fill_tone_level_array (QDM2Context *q, int flag)
{
int i, sb, ch, sb_used;
int tmp, tab;
if (q->nb_channels <= 0)
return;
for (ch = 0; ch < q->nb_channels; ch++)
for (sb = 0; sb < 30; sb++)
for (i = 0; i < 8; i++) {
if ((tab=coeff_per_sb_for_dequant[q->coeff_per_sb_select][sb]) < (last_coeff[q->coeff_per_sb_select] - 1))
tmp = q->quantized_coeffs[ch][tab + 1][i] * dequant_table[q->coeff_per_sb_select][tab + 1][sb]+
q->quantized_coeffs[ch][tab][i] * dequant_table[q->coeff_per_sb_select][tab][sb];
else
tmp = q->quantized_coeffs[ch][tab][i] * dequant_table[q->coeff_per_sb_select][tab][sb];
if(tmp < 0)
tmp += 0xff;
q->tone_level_idx_base[ch][sb][i] = (tmp / 256) & 0xff;
}
sb_used = QDM2_SB_USED(q->sub_sampling);
if ((q->superblocktype_2_3 != 0) && !flag) {
for (sb = 0; sb < sb_used; sb++)
for (ch = 0; ch < q->nb_channels; ch++)
for (i = 0; i < 64; i++) {
q->tone_level_idx[ch][sb][i] = q->tone_level_idx_base[ch][sb][i / 8];
if (q->tone_level_idx[ch][sb][i] < 0)
q->tone_level[ch][sb][i] = 0;
else
q->tone_level[ch][sb][i] = fft_tone_level_table[0][q->tone_level_idx[ch][sb][i] & 0x3f];
}
} else {
tab = q->superblocktype_2_3 ? 0 : 1;
for (sb = 0; sb < sb_used; sb++) {
if ((sb >= 4) && (sb <= 23)) {
for (ch = 0; ch < q->nb_channels; ch++)
for (i = 0; i < 64; i++) {
tmp = q->tone_level_idx_base[ch][sb][i / 8] -
q->tone_level_idx_hi1[ch][sb / 8][i / 8][i % 8] -
q->tone_level_idx_mid[ch][sb - 4][i / 8] -
q->tone_level_idx_hi2[ch][sb - 4];
q->tone_level_idx[ch][sb][i] = tmp & 0xff;
if ((tmp < 0) || (!q->superblocktype_2_3 && !tmp))
q->tone_level[ch][sb][i] = 0;
else
q->tone_level[ch][sb][i] = fft_tone_level_table[tab][tmp & 0x3f];
}
} else {
if (sb > 4) {
for (ch = 0; ch < q->nb_channels; ch++)
for (i = 0; i < 64; i++) {
tmp = q->tone_level_idx_base[ch][sb][i / 8] -
q->tone_level_idx_hi1[ch][2][i / 8][i % 8] -
q->tone_level_idx_hi2[ch][sb - 4];
q->tone_level_idx[ch][sb][i] = tmp & 0xff;
if ((tmp < 0) || (!q->superblocktype_2_3 && !tmp))
q->tone_level[ch][sb][i] = 0;
else
q->tone_level[ch][sb][i] = fft_tone_level_table[tab][tmp & 0x3f];
}
} else {
for (ch = 0; ch < q->nb_channels; ch++)
for (i = 0; i < 64; i++) {
tmp = q->tone_level_idx[ch][sb][i] = q->tone_level_idx_base[ch][sb][i / 8];
if ((tmp < 0) || (!q->superblocktype_2_3 && !tmp))
q->tone_level[ch][sb][i] = 0;
else
q->tone_level[ch][sb][i] = fft_tone_level_table[tab][tmp & 0x3f];
}
}
}
}
}
return;
}
| 1threat |
Error: Too many redirects occurred trying to open “https://www.facebook.com/dialog/oauth?client id =0000000000 : I am getting the error Too many redirects occurred trying to open “https://www.facebook.com/dialog/oauth?client id while trying to login with facebook.
Valid OAuth redirect URIs of my app is given as http://localhost:8000/
What can be the issue ? | 0debug |
Dynamic memory C, realloc exeption : i try write code with dynamic memory, and faced with the problem,
when called realloc() in genPointLinkArray() program throws exeptions: "ConsoleApplication1.exe has triggered a breakpoint.". i use Visual Studio 15 and run program in a Debug mode
struct graphPoint
{
point p;
int value;
};
struct graphLink
{
point start;
graphPoint end;
};
graphLink* genPointLink(char map[10][10], point start, graphPoint primaryPoint[22], int *linksNum)
{
graphLink *lin = (graphLink*)0;
(*linksNum) = 0;
for (int i = 0; i < 22; i++)
{
if (!ifWay(map, start, primaryPoint[i].p))
{
(*linksNum)++;
if(*linksNum == 1)
lin = (graphLink*)malloc(sizeof(graphLink));
else
{
lin = (graphLink*)realloc(lin, (*linksNum) * sizeof(graphLink));
}
(lin + (*linksNum - 1))->start = start;
(lin + (*linksNum - 1))->end = primaryPoint[i];
}
}
return lin;
}
graphLink* genPointLinkArray(char map[10][10], graphPoint primaryPoint[22], int *linksNum)
{
graphLink *links = (graphLink*)0, *l;
int currentNum = 0;
*linksNum = 0;
for (int i = 0; i < 22; i++)
{
l = genPointLink(map, primaryPoint[i].p, primaryPoint, ¤tNum);
if(currentNum != 0)
if (*linksNum == 0)
links = (graphLink*)calloc(currentNum, sizeof(graphLink));
else
links = (graphLink*)realloc(links, ((currentNum + *linksNum) * sizeof(graphLink)));
*linksNum = *linksNum + currentNum;
for (int i = 0; i < currentNum; i++)
{
links[*linksNum - 1 + i].end = l[i].end;
links[*linksNum - 1 + i].start = l[i].start;
}
}
for (int i = 0; i < *linksNum; i++)
{
printf("(%d ; %d) -> (%d ; %d) : %d\n", links[i].start.x, links[i].start.y, links[i].end.p.x, links[i].end.p.y, links[i].end.value);
}
return links;
} | 0debug |
static inline void RENAME(rgb32tobgr16)(const uint8_t *src, uint8_t *dst, unsigned int src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
mm_end = end - 15;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psllq $8, %%mm0\n\t"
"psllq $8, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $19, %%mm2\n\t"
"psrlq $19, %%mm5\n\t"
"pand %2, %%mm2\n\t"
"pand %2, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_16mask):"memory");
d += 4;
s += 16;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
const int src= *((uint32_t*)s)++;
*d++ = ((src&0xF8)<<8) + ((src&0xFC00)>>5) + ((src&0xF80000)>>19);
}
}
| 1threat |
Solving PDE with implicit euler in python - incorrect output : <p>I will try and explain exactly what's going on and my issue.</p>
<p>This is a bit mathy and SO doesn't support latex, so sadly I had to resort to images. I hope that's okay.</p>
<p><a href="https://i.stack.imgur.com/W2ytK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/W2ytK.png" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/7txtE.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/7txtE.jpg" alt="enter image description here"></a></p>
<p>I don't know why it's inverted, sorry about that.
At any rate, this is a linear system Ax = b where we know A and b, so we can find x, which is our approximation at the next time step. We continue doing this until time t_final.</p>
<p>This is the code</p>
<pre><code>import numpy as np
tau = 2 * np.pi
tau2 = tau * tau
i = complex(0,1)
def solution_f(t, x):
return 0.5 * (np.exp(-tau * i * x) * np.exp((2 - tau2) * i * t) + np.exp(tau * i * x) * np.exp((tau2 + 4) * i * t))
def solution_g(t, x):
return 0.5 * (np.exp(-tau * i * x) * np.exp((2 - tau2) * i * t) - np.exp(tau * i * x) * np.exp((tau2 + 4) * i * t))
for l in range(2, 12):
N = 2 ** l #number of grid points
dx = 1.0 / N #space between grid points
dx2 = dx * dx
dt = dx #time step
t_final = 1
approximate_f = np.zeros((N, 1), dtype = np.complex)
approximate_g = np.zeros((N, 1), dtype = np.complex)
#Insert initial conditions
for k in range(N):
approximate_f[k, 0] = np.cos(tau * k * dx)
approximate_g[k, 0] = -i * np.sin(tau * k * dx)
#Create coefficient matrix
A = np.zeros((2 * N, 2 * N), dtype = np.complex)
#First row is special
A[0, 0] = 1 -3*i*dt
A[0, N] = ((2 * dt / dx2) + dt) * i
A[0, N + 1] = (-dt / dx2) * i
A[0, -1] = (-dt / dx2) * i
#Last row is special
A[N - 1, N - 1] = 1 - (3 * dt) * i
A[N - 1, N] = (-dt / dx2) * i
A[N - 1, -2] = (-dt / dx2) * i
A[N - 1, -1] = ((2 * dt / dx2) + dt) * i
#middle
for k in range(1, N - 1):
A[k, k] = 1 - (3 * dt) * i
A[k, k + N - 1] = (-dt / dx2) * i
A[k, k + N] = ((2 * dt / dx2) + dt) * i
A[k, k + N + 1] = (-dt / dx2) * i
#Bottom half
A[N :, :N] = A[:N, N:]
A[N:, N:] = A[:N, :N]
Ainv = np.linalg.inv(A)
#Advance through time
time = 0
while time < t_final:
b = np.concatenate((approximate_f, approximate_g), axis = 0)
x = np.dot(Ainv, b) #Solve Ax = b
approximate_f = x[:N]
approximate_g = x[N:]
time += dt
approximate_solution = np.concatenate((approximate_f, approximate_g), axis=0)
#Calculate the actual solution
actual_f = np.zeros((N, 1), dtype = np.complex)
actual_g = np.zeros((N, 1), dtype = np.complex)
for k in range(N):
actual_f[k, 0] = solution_f(t_final, k * dx)
actual_g[k, 0] = solution_g(t_final, k * dx)
actual_solution = np.concatenate((actual_f, actual_g), axis = 0)
print(np.sqrt(dx) * np.linalg.norm(actual_solution - approximate_solution))
</code></pre>
<p>It doesn't work. At least not in the beginning, it shouldn't start this slow. I should be unconditionally stable and converge to the right answer.</p>
<p>What's going wrong here?</p>
| 0debug |
static void filter_mb_edgech( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int qp ) {
int i;
const int index_a = qp + h->slice_alpha_c0_offset;
const int alpha = (alpha_table+52)[index_a];
const int beta = (beta_table+52)[qp + h->slice_beta_offset];
if( bS[0] < 4 ) {
int8_t tc[4];
for(i=0; i<4; i++)
tc[i] = bS[i] ? (tc0_table+52)[index_a][bS[i] - 1] + 1 : 0;
h->s.dsp.h264_v_loop_filter_chroma(pix, stride, alpha, beta, tc);
} else {
h->s.dsp.h264_v_loop_filter_chroma_intra(pix, stride, alpha, beta);
}
}
| 1threat |
Circle appears as a square in IE : <p>I have the following css code for drawing a circle on a page. </p>
<pre><code>.full-circle {
background-color: rgba(204, 0, 102, 0);
border: 3px solid #333;
margin: auto;
height: 75px;
width: 75px;
-moz-border-radius:75px;
-webkit-border-radius: 75px;
}
</code></pre>
<p>It is called by:</p>
<pre><code> <div class="full-circle">
</code></pre>
<p>Works fine in Firefox but when I run it in IE it appears as a square and i'm not sure why.</p>
| 0debug |
static int xvid_ff_2pass_destroy(struct xvid_context *ref,
xvid_plg_destroy_t *param) {
if( ref->twopassbuffer != NULL )
ref->twopassbuffer[0] = 0;
return 0;
}
| 1threat |
static int write_note(struct memelfnote *men, int fd)
{
struct elf_note en;
en.n_namesz = men->namesz;
en.n_type = men->type;
en.n_descsz = men->datasz;
bswap_note(&en);
if (dump_write(fd, &en, sizeof(en)) != 0)
return (-1);
if (dump_write(fd, men->name, men->namesz_rounded) != 0)
return (-1);
if (dump_write(fd, men->data, men->datasz) != 0)
return (-1);
return (0);
}
| 1threat |
What's the meaning of "READY=2/2" output by command "kubectl get pod $yourpod" : <pre><code>kubectl get pod run-sh-1816639685-xejyk
NAME READY STATUS RESTARTS AGE
run-sh-1816639685-xejyk 2/2 Running 0 26m
</code></pre>
<p>What's the meaning of "READY=2/2"? The same with "1/1"?</p>
| 0debug |
import re
def text_match(text):
patterns = '^[a-z]+_[a-z]+$'
if re.search(patterns, text):
return ('Found a match!')
else:
return ('Not matched!') | 0debug |
static void raw_probe_alignment(BlockDriverState *bs, Error **errp)
{
BDRVRawState *s = bs->opaque;
DWORD sectorsPerCluster, freeClusters, totalClusters, count;
DISK_GEOMETRY_EX dg;
BOOL status;
if (s->type == FTYPE_CD) {
bs->request_alignment = 2048;
return;
}
if (s->type == FTYPE_HARDDISK) {
status = DeviceIoControl(s->hfile, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
NULL, 0, &dg, sizeof(dg), &count, NULL);
if (status != 0) {
bs->request_alignment = dg.Geometry.BytesPerSector;
return;
}
}
if (s->drive_path[0]) {
GetDiskFreeSpace(s->drive_path, §orsPerCluster,
&dg.Geometry.BytesPerSector,
&freeClusters, &totalClusters);
bs->request_alignment = dg.Geometry.BytesPerSector;
}
}
| 1threat |
static uint64_t sysbus_esp_mem_read(void *opaque, target_phys_addr_t addr,
unsigned int size)
{
SysBusESPState *sysbus = opaque;
uint32_t saddr;
saddr = addr >> sysbus->it_shift;
return esp_reg_read(&sysbus->esp, saddr);
}
| 1threat |
Importerror: No module named memcache (Django project) : <p>In a Django project of mine, I run this command to run the project on localhost:</p>
<p><code>python manage.py runserver</code></p>
<p>It results in the error:</p>
<p><code>Importerror: No module named memcache</code></p>
<p>However, I've already fulfilled the requirement via: <code>sudo apt-get install python-memcache</code></p>
<p>Peculiarly, if I go into the python shell outside my virtualevn and try <code>import memcache</code>, it works fine. However, inside my virtualenv, if I go into the python shell and try <code>import memcache</code>, I get the same import error listed above. What's going on? </p>
| 0debug |
Understanding class object : <p>I am trying to create object that will store inside vector using pointers</p>
<p>I can store object inside vector when I don t use pointers, but when I try to use pointers I can not do that</p>
<pre><code>// created class that combine some attributes for file "datum" = date, "vrijeme" = creation of file etc.
class datoteka{
public:
string datum;
string vrijeme;
string velicina;
string ime;
datoteka();
datoteka(string datum, string vrijeme, string velicina, string ime)
{
this -> datum = datum;
this -> vrijeme = vrijeme;
this -> velicina = velicina;
this -> ime = ime;
}
~datoteka();
};
int main()
{
vector <datoteka> fajlovi;
string linija;
string prva;
int i = 0;
datoteka * pokObjDatoteke;
pokObjDatoteke = new datoteka();
std::ifstream pisi("list.txt"); //file is open
while(getline(pisi,linija)) //get first line of file
{
string vrijednost;
stringstream red; //create stream from line
string datoteka[4]; // create array to store seperate information
red << linija;
while(!red.eof() && i != 4) // since line containt lot of tabs i
read just first for values
{
red >> vrijednost;
datoteka[i]= vrijednost;
i++;
cout << vrijednost << " ovo je vrijednost" << endl;
}
pokObjDatoteke->datum = datoteka[0];
pokObjDatoteke->vrijeme = datoteka[1];
pokObjDatoteke->velicina = datoteka[2];
pokObjDatoteke->ime = datoteka[3];
fajlovi.push_back(*pokObjDatoteke); /**** problem ****
}
return 0;
}
</code></pre>
<p>I want to store objects in vector, instead I get just some memory location, probably from pointer but how can I store object and not address</p>
| 0debug |
Why I am getting null exception when using an Interface : <pre><code>public class Blah
{
public bool Whatever { get; set; }
public string WhatYouJustSaid { get; set; }
}
public interface IBlah
{
Blah BlahValues { get; set; }
}
class Class1:IBlah
{
public Blah BlahValues { get; set; }
}
</code></pre>
<p>And then for example:</p>
<pre><code> Class1 c1 = new Class1();
c1.BlahValues.WhatYouJustSaid = "nothing";
c1.BlahValues.Whatever = false;
</code></pre>
<p>So how should I change my code that <code>BlahValues</code> doesn't get null? </p>
| 0debug |
collect all values from the variable in javascript : `var collectionsd` returns in console log like
[5.2140564, 52.3705452]
[5.2180339, 52.3363171]
[5.2424313, 52.3595914]
[5.2739435, 52.388464]
[5.2368864, 52.336711]
In frontend shows only `[5.2368864, 52.336711]` i need to like below in javascript
var collectionsd = [[5.2140564, 52.3705452],[5.2180339, 52.3363171],[5.2424313, 52.3595914],[5.2739435, 52.388464],[5.2368864, 52.336711]];
| 0debug |
python - input as parameter of function : I'm really sorry I'm really new to this. I'm wrote a script for a 'robot' that adds one to a user response, but my code does not run. I'm really new and wondered if anybody could help me understand what I'm doing wrong
> import time
> print("hello, I am the addition bot, I add one to any number you know")
time.sleep(0.7)
> print("Quick!")
time.sleep(0.2)
> print("My boss is coming, please give me a number!")
time.sleep(0.4)
> print("Quick!")
time.sleep(1)
> def addOneTo(number):
return number + 1
> oldNumber = input()
> print(addOneTo(oldNumber))
| 0debug |
int av_parse_cpu_caps(unsigned *flags, const char *s)
{
static const AVOption cpuflags_opts[] = {
{ "flags" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = "flags" },
#if ARCH_PPC
{ "altivec" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ALTIVEC }, .unit = "flags" },
#elif ARCH_X86
{ "mmx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMX }, .unit = "flags" },
{ "mmx2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMX2 }, .unit = "flags" },
{ "mmxext" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMX2 }, .unit = "flags" },
{ "sse" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE }, .unit = "flags" },
{ "sse2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE2 }, .unit = "flags" },
{ "sse2slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE2SLOW }, .unit = "flags" },
{ "sse3" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE3 }, .unit = "flags" },
{ "sse3slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE3SLOW }, .unit = "flags" },
{ "ssse3" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSSE3 }, .unit = "flags" },
{ "atom" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ATOM }, .unit = "flags" },
{ "sse4.1" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE4 }, .unit = "flags" },
{ "sse4.2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE42 }, .unit = "flags" },
{ "avx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_AVX }, .unit = "flags" },
{ "xop" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_XOP }, .unit = "flags" },
{ "fma3" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_FMA3 }, .unit = "flags" },
{ "fma4" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_FMA4 }, .unit = "flags" },
{ "avx2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_AVX2 }, .unit = "flags" },
{ "bmi1" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_BMI1 }, .unit = "flags" },
{ "bmi2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_BMI2 }, .unit = "flags" },
{ "3dnow" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_3DNOW }, .unit = "flags" },
{ "3dnowext", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_3DNOWEXT }, .unit = "flags" },
{ "cmov", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_CMOV }, .unit = "flags" },
#define CPU_FLAG_P2 AV_CPU_FLAG_CMOV | AV_CPU_FLAG_MMX
#define CPU_FLAG_P3 CPU_FLAG_P2 | AV_CPU_FLAG_MMX2 | AV_CPU_FLAG_SSE
#define CPU_FLAG_P4 CPU_FLAG_P3| AV_CPU_FLAG_SSE2
{ "pentium2", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_P2 }, .unit = "flags" },
{ "pentium3", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_P3 }, .unit = "flags" },
{ "pentium4", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_P4 }, .unit = "flags" },
#define CPU_FLAG_K62 AV_CPU_FLAG_MMX | AV_CPU_FLAG_3DNOW
#define CPU_FLAG_ATHLON CPU_FLAG_K62 | AV_CPU_FLAG_CMOV | AV_CPU_FLAG_3DNOWEXT | AV_CPU_FLAG_MMX2
#define CPU_FLAG_ATHLONXP CPU_FLAG_ATHLON | AV_CPU_FLAG_SSE
#define CPU_FLAG_K8 CPU_FLAG_ATHLONXP | AV_CPU_FLAG_SSE2
{ "k6", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMX }, .unit = "flags" },
{ "k62", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_K62 }, .unit = "flags" },
{ "athlon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_ATHLON }, .unit = "flags" },
{ "athlonxp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_ATHLONXP }, .unit = "flags" },
{ "k8", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_K8 }, .unit = "flags" },
#elif ARCH_ARM
{ "armv5te", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV5TE }, .unit = "flags" },
{ "armv6", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV6 }, .unit = "flags" },
{ "armv6t2", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV6T2 }, .unit = "flags" },
{ "vfp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP }, .unit = "flags" },
{ "vfpv3", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFPV3 }, .unit = "flags" },
{ "neon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON }, .unit = "flags" },
#elif ARCH_AARCH64
{ "armv8", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV8 }, .unit = "flags" },
{ "neon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON }, .unit = "flags" },
{ "vfp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP }, .unit = "flags" },
#endif
{ NULL },
};
static const AVClass class = {
.class_name = "cpuflags",
.item_name = av_default_item_name,
.option = cpuflags_opts,
.version = LIBAVUTIL_VERSION_INT,
};
const AVClass *pclass = &class;
return av_opt_eval_flags(&pclass, &cpuflags_opts[0], s, flags);
} | 1threat |
static void tcg_out_setcond(TCGContext *s, TCGType type, TCGCond cond,
TCGArg arg0, TCGArg arg1, TCGArg arg2,
int const_arg2)
{
int crop, sh;
assert(TCG_TARGET_REG_BITS == 64 || type == TCG_TYPE_I32);
if (type == TCG_TYPE_I32) {
arg2 = (uint32_t)arg2;
}
if (arg2 == 0) {
switch (cond) {
case TCG_COND_EQ:
tcg_out_setcond_eq0(s, type, arg0, arg1);
return;
case TCG_COND_NE:
if (TCG_TARGET_REG_BITS == 64 && type == TCG_TYPE_I32) {
tcg_out_ext32u(s, TCG_REG_R0, arg1);
arg1 = TCG_REG_R0;
}
tcg_out_setcond_ne0(s, arg0, arg1);
return;
case TCG_COND_GE:
tcg_out32(s, NOR | SAB(arg1, arg0, arg1));
arg1 = arg0;
case TCG_COND_LT:
if (type == TCG_TYPE_I32) {
tcg_out_shri32(s, arg0, arg1, 31);
} else {
tcg_out_shri64(s, arg0, arg1, 63);
}
return;
default:
break;
}
}
if (HAVE_ISEL) {
int isel, tab;
tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 7, type);
isel = tcg_to_isel[cond];
tcg_out_movi(s, type, arg0, 1);
if (isel & 1) {
tab = TAB(arg0, 0, arg0);
isel &= ~1;
} else {
tcg_out_movi(s, type, TCG_REG_R0, 0);
tab = TAB(arg0, arg0, TCG_REG_R0);
}
tcg_out32(s, isel | tab);
return;
}
switch (cond) {
case TCG_COND_EQ:
arg1 = tcg_gen_setcond_xor(s, arg1, arg2, const_arg2);
tcg_out_setcond_eq0(s, type, arg0, arg1);
return;
case TCG_COND_NE:
arg1 = tcg_gen_setcond_xor(s, arg1, arg2, const_arg2);
if (TCG_TARGET_REG_BITS == 64 && type == TCG_TYPE_I32) {
tcg_out_ext32u(s, TCG_REG_R0, arg1);
arg1 = TCG_REG_R0;
}
tcg_out_setcond_ne0(s, arg0, arg1);
return;
case TCG_COND_GT:
case TCG_COND_GTU:
sh = 30;
crop = 0;
goto crtest;
case TCG_COND_LT:
case TCG_COND_LTU:
sh = 29;
crop = 0;
goto crtest;
case TCG_COND_GE:
case TCG_COND_GEU:
sh = 31;
crop = CRNOR | BT(7, CR_EQ) | BA(7, CR_LT) | BB(7, CR_LT);
goto crtest;
case TCG_COND_LE:
case TCG_COND_LEU:
sh = 31;
crop = CRNOR | BT(7, CR_EQ) | BA(7, CR_GT) | BB(7, CR_GT);
crtest:
tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 7, type);
if (crop) {
tcg_out32(s, crop);
}
tcg_out32(s, MFOCRF | RT(TCG_REG_R0) | FXM(7));
tcg_out_rlw(s, RLWINM, arg0, TCG_REG_R0, sh, 31, 31);
break;
default:
tcg_abort();
}
}
| 1threat |
parse JSON without knowing the key value : <p>I know how to parse a JSON knowing the key value, but now I'd like to get the key values from a JSON that it's not mine, so I can know the key names, for instance I have this JSON</p>
<pre><code>[
{
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "Sincere@april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
"geo": {
"lat": "-37.3159",
"lng": "81.1496"
}
},
"phone": "1-770-736-8031 x56442",
"website": "hildegard.org",
"company": {
"name": "Romaguera-Crona",
"catchPhrase": "Multi-layered client-server neural-net",
"bs": "harness real-time e-markets"
}
},
{
"id": 2,
"name": "Ervin Howell",
"username": "Antonette",
"email": "Shanna@melissa.tv",
"address": {
"street": "Victor Plains",
"suite": "Suite 879",
"city": "Wisokyburgh",
"zipcode": "90566-7771",
"geo": {
"lat": "-43.9509",
"lng": "-34.4618"
}
},
"phone": "010-692-6593 x09125",
"website": "anastasia.net",
"company": {
"name": "Deckow-Crist",
"catchPhrase": "Proactive didactic contingency",
"bs": "synergize scalable supply-chains"
}
},
...
]
</code></pre>
<p>So from now I have this : </p>
<pre><code>with open('users.json') as f:
data = json.load(f)
</code></pre>
<p>Where I can see all the JSON loaded if I print <code>data</code>, so my question is, how do I print all of the keys and nested objects without knowing the name?</p>
<p>My goal is having something like
id
name
username
email
address that contains street, suite, city, zipcode, geo that contains lat, long, etc..</p>
| 0debug |
Add custom headers to 'request' : <p>I am proxying my api via following setup in my express config</p>
<pre><code> // Proxy api calls
app.use('/api', function (req, res) {
let url = config.API_HOST + req.url
req.pipe(request(url)).pipe(res)
})
</code></pre>
<p><code>config.API_HOST</code> in here resolves to my api url and <code>req.url</code> is some endpoint i.e. <code>/users</code> I tried following documentation on npm for <a href="https://www.npmjs.com/package/request#custom-http-headers" rel="noreferrer">request</a> and set up my headers like so</p>
<pre><code> // Proxy api calls
app.use('/api', function (req, res) {
let options = {
url: config.API_HOST + req.url,
options: { 'mycustomheader': 'test' }
}
req.pipe(request(options)).pipe(res)
})
</code></pre>
<p>But I am not able to see my custom headers in chrome dev tools under Network.</p>
| 0debug |
variable might not have been initialized used : <p>i have made a code that make a random fruit depending on is probability</p>
<pre><code>#include<iostream>
#include"stdafx.h"
#include <cstdlib>
int main()
{
int Blueberries;
int Grapefruit;
int Orange;
int Apple;
int Pineapple;
int random = rand() % 100;
if (random > Orange & random < Apple)
{
random = Pineapple;
}
else if (random > Pineapple & random < Grapefruit)
{
random = Apple;
}
else if (random > Apple & random < Blueberries)
{
random = Grapefruit;
}
else if (random > 46)
{
random = Blueberries;
}
else if (random < 10)
{
random = Orange;
}
std::cout << random << ".\n";
system("pause");
return(0);
}
</code></pre>
<p>but when i want to use it, this pop up "variable not initialized used" can somebody explain to me what does this mean ?</p>
| 0debug |
How to make use of string variables in a query in jsp : <p>I have 2 string variables name and password. Now I have to use these variables in a query in where condition. How should I do it.
Suppose I want to execute a query-
"SELECT * FROM students WHERE students.name=name and student.pass=password"</p>
<p>I'm not able to do it. What is the right syntax for this query statement?</p>
| 0debug |
How do I use Error handling in Java : <p>This code works if you put a number 0-100 and if you but something out of that range. How do i get it to accept things like letters or words and say please enter a grade between 0 and 100? My code is: </p>
<pre><code> import java.util.Scanner;
public class LetterGrade {
public static void main(String[] args) {
Scanner grades = new Scanner(System.in);
int grade = 0;
String LetterGrade = "";
System.out.print("Enter your test grades: ");
grade = grades.nextInt();
if (grade > 100 || grade < 0) {
System.out.println("Enter the percentage from 0 - 100");
}
while (grade > 100 || grade < 0) {
System.out.print("Enter your test grades: ");
grade = grades.nextInt();
if (grade > 100 || grade < 0) {
System.out.println("Enter the precentage from 0 - 100");
}
}
//Define the number Grade to equal a Letter
if (grade <= 100 && grade >= 97)
LetterGrade = "A+";
if (grade <= 96 && grade >= 93)
LetterGrade = "A";
if (grade <= 92 && grade >= 90)
LetterGrade = "A-";
if (grade <= 89 && grade >= 87)
LetterGrade = "B+";
if (grade <= 86 && grade >= 83)
LetterGrade = "B";
if (grade <= 82 && grade >= 80)
LetterGrade = "B-";
if (grade <= 77 && grade >= 74)
LetterGrade = "C+";
if (grade <= 73 && grade >= 73)
LetterGrade = "C";
if (grade <= 72 && grade >= 70)
LetterGrade = "C-";
if (grade <= 69 && grade >= 67)
LetterGrade = "D+";
if (grade <= 66 && grade >= 65)
LetterGrade = "D";
if (grade <= 64 && grade >= 60)
LetterGrade = "D-";
if (grade <= 59 && grade >= 0)
LetterGrade = "F";
System.out.println("Your test grade of " + grade + " is a letter grade of " + LetterGrade);
}
</code></pre>
<p>}</p>
| 0debug |
How to improve performance when having a huge list of bytes to be written to file in python? : In python, I have a huge list of floating point values(nearly 30 million values). I have to convert each of them as 4 byte values in little endian format and write all those to a binary file in order.
For a list with some thousands or even lakhs of data, my code is working fine. But if the data increases, it is taking time to process and write to file. What optimization techniques can I use to write to file more efficiently?
As suggested in this blog, http://dabeaz.blogspot.in/2010/01/few-useful-bytearray-tricks.html?m=1 , I am replacing all the small writes to a file by the use of bytearray. But still, the performance is not satisfiable.
Also I have tried multiprocessing (concurrent.futures.ProcessPoolExecutor()) to utilize all the cores in the system instead of using a single CPU core. But still it is taking more time to complete the execution.
Can anyone give me more suggestions on how to improve the performance(in terms of time and memory) for this problem. | 0debug |
Getting six and six.moves modules to autocomplete in pycharm : <p>Is it possible to get imports for the six module to work in pycharm? I realize the module does some playing with imports that confuses pycharm but was hoping there was some type of workaround.</p>
<p>For example, I'd like the following to work properly in pycharm or intellij::</p>
<pre><code>from six.moves import BaseHTTPServer
</code></pre>
| 0debug |
void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
{
Error *errp = NULL;
int paging = qdict_get_try_bool(qdict, "paging", 0);
const char *file = qdict_get_str(qdict, "filename");
bool has_begin = qdict_haskey(qdict, "begin");
bool has_length = qdict_haskey(qdict, "length");
int64_t begin = 0;
int64_t length = 0;
char *prot;
if (has_begin) {
begin = qdict_get_int(qdict, "begin");
}
if (has_length) {
length = qdict_get_int(qdict, "length");
}
prot = g_strconcat("file:", file, NULL);
qmp_dump_guest_memory(paging, prot, has_begin, begin, has_length, length,
&errp);
hmp_handle_error(mon, &errp);
g_free(prot);
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.