problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Rails 4 and ActionCable : <p>I am building a real time chat into a rails 4 application. It seems <code>ActionCable</code> is the tool for this kind of job. </p>
<p>Is it possible to use <code>ActionCable</code> in rails 4 or do I have update to rails 5?</p>
<p>I cannot find any introduction for <code>ActionCable</code> with rails 4. </p>
| 0debug
|
static int ehci_state_fetchitd(EHCIState *ehci, int async)
{
uint32_t entry;
EHCIitd itd;
assert(!async);
entry = ehci_get_fetch_addr(ehci, async);
get_dwords(NLPTR_GET(entry),(uint32_t *) &itd,
sizeof(EHCIitd) >> 2);
ehci_trace_itd(ehci, entry, &itd);
if (ehci_process_itd(ehci, &itd) != 0) {
return -1;
}
put_dwords(NLPTR_GET(entry), (uint32_t *) &itd,
sizeof(EHCIitd) >> 2);
ehci_set_fetch_addr(ehci, async, itd.next);
ehci_set_state(ehci, async, EST_FETCHENTRY);
return 1;
}
| 1threat
|
static inline void RENAME(yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
long width, long height,
long lumStride, long chromStride, long dstStride)
{
RENAME(yuvPlanartouyvy)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 2);
}
| 1threat
|
How to use NPM and install packages inside Visual Studio 2017? : <p>I have a simple Visual Studio solution, running ASP.NET Core v2 and building a React app.</p>
<p>Now, I want to install a simple component using the NPM. In this particular example, it could be:</p>
<pre><code>npm install --save react-bootstrap-typeahead
</code></pre>
<p>I want this package to work just in my solution and nowhere else.</p>
<p><strong>My result:</strong></p>
<p>When I run this, I get the following nice error which obviously makes some sense. If NPM believes it can find my project file at <code>'C:\Users\LarsHoldgaard\package.json'</code>, it's out of luck. The correct path would be <code>C:\Users\LarsHoldgaard\Documents\Github\Likvido.CreditRisk\Likvido.CreditRisk\Likvido.CreditRisk</code> .</p>
<pre><code>npm : npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\LarsHoldgaard\package.json'
At line:1 char:1
+ npm install --save react-bootstrap-typeahead
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (npm WARN saveEr...d\package.json':String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
npm
WARN
enoent
ENOENT: no such file or directory, open 'C:\Users\LarsHoldgaard\package.json'
npm
WARN
grunt-sass@2.0.0 requires a peer of grunt@>=0.4.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
react-rating@1.0.6 requires a peer of react@>=0.13.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
react-bootstrap-typeahead@2.5.1 requires a peer of react@^0.14.0 || ^15.2.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
react-bootstrap-typeahead@2.5.1 requires a peer of react-dom@^0.14.0 || ^15.2.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
prop-types-extra@1.0.1 requires a peer of react@>=0.14.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
react-overlays@0.8.3 requires a peer of react@^0.14.9 || >=15.3.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
react-overlays@0.8.3 requires a peer of react-dom@^0.14.9 || >=15.3.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
react-onclickoutside@6.7.1 requires a peer of react@^15.5.x || ^16.x but none is installed. You must install peer dependencies yourself.
npm
WARN
react-onclickoutside@6.7.1 requires a peer of react-dom@^15.5.x || ^16.x but none is installed. You must install peer dependencies yourself.
npm
WARN
react-transition-group@2.2.1 requires a peer of react@>=15.0.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
react-transition-group@2.2.1 requires a peer of react-dom@>=15.0.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
LarsHoldgaard No description
npm
WARN
LarsHoldgaard No repository field.
npm
WARN
LarsHoldgaard No README data
npm
WARN
LarsHoldgaard No license field.
</code></pre>
<p><strong>My thinking:</strong></p>
<p>Being a <strong>console noob</strong>, I would guess I just needed to change my current folder. But if I run <code>dir</code>, I am in the right folder, and I can see my <code>package.json</code> along with other files.</p>
<p>What is the right way to install components?</p>
| 0debug
|
What is mean by return 1, -1 and 0 ? What values does this method returns? : <p>/*
What values are return when I mention return 1, -1 and 0 in the method</p>
<p>I was writing thing this code to sort String based on there size
*/</p>
<pre><code>public int compare(String s1, String s2)
{
int len1 = s1.length();
int len2 = s2.length();
if(len1 > len2)
{
return 1;
}
else if (len1 < len2)
{
return -1;
}
return 0;
}
</code></pre>
| 0debug
|
push object in objects javascript : i dont understand why i can not push into my object, here is my code :
credentialsDom = { //my object
'en': {'template':'html/en_credentials_email.html',
'mailSubject':'Your solution test credentials'},
'fr':{'template':'html/fr_credentials_email.html',
'mailSubject':'Vos accès à la plateforme de test'}
}
credentialsDom['fr'].push({"data": "data"})
and i get : credentialsDom.fr.push is not a function
can explain why please, i dont understad how objects working
| 0debug
|
Java code not working properly-- working on odd summation. : I am very new to Computer Science. I am trying to learn Java on my own for fun. I found some practice problems online and have gotten stuck. I am trying to write a simple loop to determine odd numbers. I want the loop to add one odd number at a time and then to sum the total. For example I want the program to display the numbers like A1 = {1}, A2 = {1, 3}, A3 = {1, 3, 5}, A4 = {1, 3, 5, 7}... where each A# adds on an additional odd number each time through the loop and then I also want to determine the total sum of all the list from A1 to A20. The sum should be as such. {1)+{1,3},+{1,3,5}=14
public class MyClass {
public static void main(String args[]) {
int limit = 20;
int sum = 0;
for(int i=1; i <= limit; i++){
//if the number is not divisible by 2 then it is odd
if( i % 2 != 0){
System.out.print(i + " ");
}
}}
}
The code above displays odd numbers all together not the way I am hoping for. It also does not sum up the odd numbers.
Any help would be appreciated, thank you.
| 0debug
|
how to copy only 7(n values) cells from the list of cells and loop till end of cell with VBA : how to copy only 7(n values) cells from the list of cells and loop till end of cell and to be pasted in the next sheet(target sheet) with vba. Please help on this, its urgent.
Ex: values in vertical
1113456
1311456
1509456
1707456
1905456
2103456
2301456
2499456
2697456
2895456
3093456
| 0debug
|
static int qemu_rdma_exchange_get_response(RDMAContext *rdma,
RDMAControlHeader *head, int expecting, int idx)
{
int ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RECV_CONTROL + idx);
if (ret < 0) {
fprintf(stderr, "rdma migration: recv polling control error!\n");
return ret;
}
network_to_control((void *) rdma->wr_data[idx].control);
memcpy(head, rdma->wr_data[idx].control, sizeof(RDMAControlHeader));
DDDPRINTF("CONTROL: %s receiving...\n", control_desc[expecting]);
if (expecting == RDMA_CONTROL_NONE) {
DDDPRINTF("Surprise: got %s (%d)\n",
control_desc[head->type], head->type);
} else if (head->type != expecting || head->type == RDMA_CONTROL_ERROR) {
fprintf(stderr, "Was expecting a %s (%d) control message"
", but got: %s (%d), length: %d\n",
control_desc[expecting], expecting,
control_desc[head->type], head->type, head->len);
return -EIO;
}
if (head->len > RDMA_CONTROL_MAX_BUFFER - sizeof(*head)) {
fprintf(stderr, "too long length: %d\n", head->len);
return -EINVAL;
}
return 0;
}
| 1threat
|
Sikuli or AutoIT - which one is better? : <p>AutoIT and Sikuli both supports windows based automation. But I dont have much experience on both. I would like to know the major differences between each other and which one is efficient. Kindly share your thoughts.</p>
| 0debug
|
How to calculate with SCSS variables from function : <p>I have a function which converts px to rem. For example:</p>
<pre><code>height: rem-calc(14px); // makes height: 1rem;
</code></pre>
<p>Now I would like to calculate with it from variables. For example:</p>
<pre><code>$switch-track-width: rem-calc(50px);
$switch-thumb-size: $switch-track-width / 2; // making it 25px or 1.7857rem in this case
</code></pre>
<p>That doesn't work so I tried something else:</p>
<pre><code>$switch-thumb-size: ($switch-track-width / 2) + 0rem;
$switch-thumb-size: (#{$switch-track-width} / 2) + 0rem;
</code></pre>
<p>Both <code>$switch-thumb-size</code> examples aren't working either. Now this is dividing but I'm also unable to get <code>times (*)</code>, <code>plus (+)</code> and <code>minus (-)</code> working.</p>
<p>I'm also having a problem when calculating with 2 variables. For example:</p>
<pre><code>$switch-track-height: rem-calc(14px);
$switch-track-width: rem-calc(50px);
$switch-thumb-right: $switch-track-height - $switch-track-width;
</code></pre>
<p>I prever to keep the function inside the variable instead of in the property like: <code>height: rem-calc($switch-track-height);</code>.</p>
<p>If someone could tell me how to calculate with SCSS variables on both examples that would be very helpful. </p>
<p>Thanks in advance</p>
| 0debug
|
ReactNative Eject Explained : <p>I literally started reading about ReactNative an hour ago and am reading this git readme <a href="https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/README.md" rel="noreferrer">https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/README.md</a></p>
<p>Next I googled about it and found this link which seem to be explaining it but not to me novice in web, react, or react-native
<a href="https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md" rel="noreferrer">https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md</a></p>
<p>Can someone explain to me as if I am 2 years old what is the meaning of eject? I keep hearing term "ejected project" but I cannot wrap my head around it.</p>
| 0debug
|
static int metadata_parse(FLACContext *s)
{
int i, metadata_last, metadata_type, metadata_size;
int initial_pos= get_bits_count(&s->gb);
if (show_bits_long(&s->gb, 32) == MKBETAG('f','L','a','C')) {
skip_bits_long(&s->gb, 32);
do {
metadata_last = get_bits1(&s->gb);
metadata_type = get_bits(&s->gb, 7);
metadata_size = get_bits_long(&s->gb, 24);
if (get_bits_count(&s->gb) + 8*metadata_size > s->gb.size_in_bits) {
skip_bits_long(&s->gb, initial_pos - get_bits_count(&s->gb));
break;
}
if (metadata_size) {
switch (metadata_type) {
case FLAC_METADATA_TYPE_STREAMINFO:
if (!s->got_streaminfo) {
ff_flac_parse_streaminfo(s->avctx, (FLACStreaminfo *)s,
s->gb.buffer+get_bits_count(&s->gb)/8);
allocate_buffers(s);
s->got_streaminfo = 1;
}
default:
for (i = 0; i < metadata_size; i++)
skip_bits(&s->gb, 8);
}
}
} while (!metadata_last);
return 1;
}
return 0;
}
| 1threat
|
static void ics_base_realize(DeviceState *dev, Error **errp)
{
ICSStateClass *icsc = ICS_BASE_GET_CLASS(dev);
ICSState *ics = ICS_BASE(dev);
Object *obj;
Error *err = NULL;
obj = object_property_get_link(OBJECT(dev), ICS_PROP_XICS, &err);
if (!obj) {
error_setg(errp, "%s: required link '" ICS_PROP_XICS "' not found: %s",
__func__, error_get_pretty(err));
return;
}
ics->xics = XICS_FABRIC(obj);
if (icsc->realize) {
icsc->realize(ics, errp);
}
}
| 1threat
|
Why this is so(see the below two code samples)? : <p>Code 1:</p>
<pre><code>public void displayQuantity(int number) {
TextView quantityTV = (TextView) findViewById(R.id.quantity_tv);
quantityTV.setText( " "+ number);
}
</code></pre>
<p>Code 2:</p>
<pre><code> public void displayQuantity(int number) {
TextView quantityTV = (TextView) findViewById(R.id.quantity_tv);
quantityTV.setText(number);
}
</code></pre>
<p>Why Code 2 gives error while code 1 doesn't??
There is a difference of - " __ " in b/w code 1 & 2</p>
| 0debug
|
python enumerate tqdm bar when reading a file? : <p>I can't see the tqdm progress bar when I use this code to iterate my opened file:</p>
<pre><code> with open(file_path, 'r') as f:
for i, line in enumerate(tqdm(f)):
if i >= start and i <= end:
print("line #: %s" % i)
for i in tqdm(range(0, line_size, batch_size)):
# pause if find a file naed pause at the currend dir
re_batch = {}
for j in range(batch_size):
re_batch[j] = re.search(line, last_span)
</code></pre>
<p>what's the right way to use tqdm here?</p>
| 0debug
|
i need help getting around this code i keep getting , missing right parenthesis error and i'm currently stock as a result :
CREATE TABLE STUDENT
( Student# NUMBER(9),
FirstName VARCHAR2(52),
LastName VARCHAR2(50),
DeptID NUMBER(9) NOT NULL,
ProjectID NUMBER(5,2) NOT NULL,
PCID NUMBER(10) NOT NULL,
PR# NUMBER(10) NOT NULL,
Email VARCHAR(50)
CONSTRAINT student_student#_pk PRIMARY KEY (student#),
CONSTRAINT student_deptid_fk FOREIGN KEY (deptid)
REFERENCES department (deptid),
CONSTRAINT student_pcid_fk FOREIGN KEY (pcid)
REFERENCES projectcourse (pcid) ,
CONSTRAINT student_project#_fk FOREIGN KEY (project#)
REFERENCES project (project#),
CONSTRAINT student_pr#_fk FOREIGN KEY (pr#)
REFRENCES projectregisteration (pr#));
| 0debug
|
AutoFocus an input element in react JS : <p>I am unable to autofocus the input tag rendered in this component. What am I missing here?</p>
<pre><code>class TaskBox extends Component {
constructor() {
super();
this.focus = this.focus.bind(this);
}
focus() {
this.textInput.focus();
}
componentWillUpdate(){
this.focus();
}
render() {
let props = this.props;
return (
<div style={{display: props.visible ? 'block' : 'none'}}>
<input
ref={(input) => { this.textInput = input; }}
onBlur={props.blurFN} />
<div>
<div>Imp.</div>
<div>Urg.</div>
<div>Role</div>
</div>
<div>
<button>Add goal</button>
</div>
</div>
)
}
}
</code></pre>
<p>Any help is appreciated.</p>
| 0debug
|
Angular 2 setinterval() keep running on other component : <p>I have the following method in one component:</p>
<pre><code>ngOnInit()
{
this.battleInit();
setInterval(() => {
this.battleInit();
}, 5000);
}
</code></pre>
<p>Now, I need to run this interval only if the user is in this specific component, that means that when the user navigate away from this component the interval will stop.</p>
<p>Currently, <code>this.battleInit()</code> is executed every 5 seconds, even after the user navigates away from this page.</p>
<p>Short question: How do I stop <code>setInterval()</code> when user navigate away (by routing) to another component?</p>
| 0debug
|
uint64_t helper_mullv(CPUAlphaState *env, uint64_t op1, uint64_t op2)
{
int64_t res = (int64_t)op1 * (int64_t)op2;
if (unlikely((int32_t)res != res)) {
arith_excp(env, GETPC(), EXC_M_IOV, 0);
}
return (int64_t)((int32_t)res);
}
| 1threat
|
C - i++ not working inside a while loop : So, I'm helping a friend with her programing class, and we've come across something funny. I have the next code:
void ingresardatos(struct alumno *lista){
int i=0;
char continuar='s';
while(continuar=='s' && i<20){
printf("Valor de i al iniciar: %d \n", i);
printf("Introduzca el nombre del alumno:\n");
scanf("%s",&(lista[i].nombre));
printf("Introduzca la matricula:\n");
scanf("%s",&lista[i].matricula);
printf("Introduzca la primera calificacion:\n");
scanf("%f",&lista[i].calf1);
printf("Introduzca la segunda calificacion:\n");
scanf("%f",&lista[i].calf2);
printf("Introduzca la tercera caificacion:\n");
scanf("%f",&lista[i].calf3);
lista[i].prom=(lista[i].calf1+lista[i].calf2+lista[i].calf3)/3;
if(lista[i].prom<=5.9){
strcpy(lista[i].nota,"NA");
}
else if(lista[i].prom>=6 && lista[i].prom<=7.3){
strcpy(lista[i].nota,"S");
}
else if(lista[i].prom>=7.4 && lista[i].prom<=8.6){
strcpy(lista[i].nota,"B");
}
else if(lista[i].prom>=8.7 && lista[i].prom<=10){
strcpy(lista[i].nota,"MB");
}
printf("Valor de i antes: %d \n", i);
i++;
printf("Valor de i después: %d \n", i);
printf("¿Desea continuar? (S/N)");
scanf("%s",&continuar);
}
}
It's supposed to be a grade list for a class of 20; you introduce the student's data until you press "n", and it saves them on a list. Now, I figured out the pointer part (I just really know Java, so it's kinda weird working on C), but what I can't figure out is how to make the i++ part work. If you run it like it is, it'll start with i=0 on the first pass, then go through all the code, and finally do i++ before asking if you want to continue (it prints it on the screen). But then, when you press "s" to indicate you want to continue, it'll start with i=0 again, and for the life of me I can't figure out why. I tried i++, ++i, i=i+1, and so on, but nothing seems to work. I even tried making i a pointer, but Windows didn't like it and crashed my program everytime I ran it.
If someone could explain just why it isn't working, I'd be eternaly greatful. I've been at it for days now, and I can't figure it out.
| 0debug
|
void ff_snow_vertical_compose97i_mmx(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, int width){
long i = width;
while(i & 15)
{
i--;
b4[i] -= (W_DM*(b3[i] + b5[i])+W_DO)>>W_DS;
b3[i] -= (W_CM*(b2[i] + b4[i])+W_CO)>>W_CS;
b2[i] += (W_BM*(b1[i] + b3[i])+4*b2[i]+W_BO)>>W_BS;
b1[i] += (W_AM*(b0[i] + b2[i])+W_AO)>>W_AS;
}
i+=i;
asm volatile(
"jmp 2f \n\t"
"1: \n\t"
snow_vertical_compose_mmx_load("%4","mm0","mm2","mm4","mm6")
snow_vertical_compose_mmx_add("%6","mm0","mm2","mm4","mm6")
snow_vertical_compose_mmx_move("mm0","mm2","mm4","mm6","mm1","mm3","mm5","mm7")
snow_vertical_compose_sra("1","mm0","mm2","mm4","mm6")
snow_vertical_compose_r2r_add("mm1","mm3","mm5","mm7","mm0","mm2","mm4","mm6")
"pcmpeqw %%mm1, %%mm1 \n\t"
"psllw $15, %%mm1 \n\t"
"psrlw $14, %%mm1 \n\t"
snow_vertical_compose_r2r_add("mm1","mm1","mm1","mm1","mm0","mm2","mm4","mm6")
snow_vertical_compose_sra("2","mm0","mm2","mm4","mm6")
snow_vertical_compose_mmx_load("%5","mm1","mm3","mm5","mm7")
snow_vertical_compose_r2r_sub("mm0","mm2","mm4","mm6","mm1","mm3","mm5","mm7")
snow_vertical_compose_mmx_store("%5","mm1","mm3","mm5","mm7")
snow_vertical_compose_mmx_load("%4","mm0","mm2","mm4","mm6")
snow_vertical_compose_mmx_add("%3","mm1","mm3","mm5","mm7")
snow_vertical_compose_r2r_sub("mm1","mm3","mm5","mm7","mm0","mm2","mm4","mm6")
snow_vertical_compose_mmx_store("%4","mm0","mm2","mm4","mm6")
"pcmpeqw %%mm7, %%mm7 \n\t"
"pcmpeqw %%mm5, %%mm5 \n\t"
"psllw $15, %%mm7 \n\t"
"psrlw $13, %%mm5 \n\t"
"paddw %%mm7, %%mm5 \n\t"
snow_vertical_compose_r2r_add("mm5","mm5","mm5","mm5","mm0","mm2","mm4","mm6")
"movq (%2,%%"REG_d"), %%mm1 \n\t"
"movq 8(%2,%%"REG_d"), %%mm3 \n\t"
"paddw %%mm7, %%mm1 \n\t"
"paddw %%mm7, %%mm3 \n\t"
"pavgw %%mm1, %%mm0 \n\t"
"pavgw %%mm3, %%mm2 \n\t"
"movq 16(%2,%%"REG_d"), %%mm1 \n\t"
"movq 24(%2,%%"REG_d"), %%mm3 \n\t"
"paddw %%mm7, %%mm1 \n\t"
"paddw %%mm7, %%mm3 \n\t"
"pavgw %%mm1, %%mm4 \n\t"
"pavgw %%mm3, %%mm6 \n\t"
snow_vertical_compose_r2r_sub("mm7","mm7","mm7","mm7","mm0","mm2","mm4","mm6")
snow_vertical_compose_sra("1","mm0","mm2","mm4","mm6")
snow_vertical_compose_mmx_add("%3","mm0","mm2","mm4","mm6")
snow_vertical_compose_sra("2","mm0","mm2","mm4","mm6")
snow_vertical_compose_mmx_add("%3","mm0","mm2","mm4","mm6")
snow_vertical_compose_mmx_store("%3","mm0","mm2","mm4","mm6")
snow_vertical_compose_mmx_add("%1","mm0","mm2","mm4","mm6")
snow_vertical_compose_mmx_move("mm0","mm2","mm4","mm6","mm1","mm3","mm5","mm7")
snow_vertical_compose_sra("1","mm0","mm2","mm4","mm6")
snow_vertical_compose_r2r_add("mm1","mm3","mm5","mm7","mm0","mm2","mm4","mm6")
snow_vertical_compose_mmx_add("%2","mm0","mm2","mm4","mm6")
snow_vertical_compose_mmx_store("%2","mm0","mm2","mm4","mm6")
"2: \n\t"
"sub $32, %%"REG_d" \n\t"
"jge 1b \n\t"
:"+d"(i)
:"r"(b0),"r"(b1),"r"(b2),"r"(b3),"r"(b4),"r"(b5));
}
| 1threat
|
Firebase Permission denied Error : <p>I am Very beginner to firebase and trying to get value from my database.</p>
<p>but it showing me same error every time.</p>
<pre><code> W/SyncTree: Listen at /child failed: FirebaseError: Permission denied
</code></pre>
<p>My firebase rules</p>
<pre><code> {
"Condition" : "sunny",
"child" : 5
}
</code></pre>
<p>my Androidmanifest.xml</p>
<pre><code> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mohit.firebase" >
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
>
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
</code></pre>
<p>My mainactivity.java
package com.mohit.firebase;</p>
<pre><code>import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.firebase.client.DataSnapshot;
import com.firebase.client.Firebase;
import com.firebase.client.FirebaseError;
import com.firebase.client.ValueEventListener;
public class MainActivity extends AppCompatActivity {
TextView tv;
Button bt1;
Button bt2;
Firebase mRootRef;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv = (TextView) findViewById(R.id.button);
bt1 = (Button) findViewById(R.id.button);
bt2 = (Button) findViewById(R.id.button2);
Firebase.setAndroidContext(this);
mRootRef = new Firebase("https://superb-flag-126719.firebaseio.com/");
Log.d("fb","Firebase Object: " + String.valueOf(mRootRef));
}
@Override
protected void onStart() {
super.onStart();
Firebase mchild = mRootRef.child("child");
mchild.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String condition = (String) dataSnapshot.getValue();
Log.d("fb","String get: " + condition);
tv.setText(condition);
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
}
}
</code></pre>
<p>my BuildGraddle</p>
<pre><code> apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.mohit.firebase"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.firebase:firebase-client-android:2.5.2+'
}
</code></pre>
<p>i checked my firebase url. It's Perfectly Correct.</p>
| 0debug
|
How to rename file with sequential numbering? : I have a number of files with the following naming:
name1.name2.s01.ep01.RANDOMWORD.mp4
name1.name2.s01.ep02.RANDOMWORD.mp4
name1.name2.s01.ep03.RANDOMWORD.mp4
I need to remove everything between last . and ep# from the file names and only have `name1.name2.s01.ep01.mp4` (sometimes extension can be different)
name1.name2.s01.ep01.mp4
name1.name2.s01.ep02.mp4
| 0debug
|
I want to build a web application offline which run on Android, read .PDF files with some security option. Is that possible? : <p>Aim is an application that can run on mobile smart device (android, ios, …) to read a book in pdf format. We want to add security option that will en-descrypt pdf after download.Problem that we are encounter is that browser on android, ios device cannot view pdf file directly.</p>
| 0debug
|
Find the name of the database I'm connected to in php : <p>Is there a way to find out the name of the database I am connected to?</p>
<p>I have several includes to I don't know what is the db selected </p>
| 0debug
|
static void test_parse_path_subprocess(void)
{
qemu_set_log_filename("/tmp/qemu.log");
qemu_set_log_filename("/tmp/qemu-%d.log");
qemu_set_log_filename("/tmp/qemu.log.%d");
}
| 1threat
|
Regular expression C# : check file name contening date and underscores : I need to check the syntax of a file name in order to treat it and excludes files that don't match the expression.
The file names must be like that :
(2 caracters letter or number)_(some caracters letters and numbers)__(YYYY-MM-dd-HH-SS-MM).csv
=> the last part is a date
=> in the middle we have two underscores
Can you help me for this request ? I'm not familiar at all with the regex and the few tests I made were not good.
Thanks a lot :)
| 0debug
|
void host_cpuid(uint32_t function, uint32_t count,
uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
{
#if defined(CONFIG_KVM)
uint32_t vec[4];
#ifdef __x86_64__
asm volatile("cpuid"
: "=a"(vec[0]), "=b"(vec[1]),
"=c"(vec[2]), "=d"(vec[3])
: "0"(function), "c"(count) : "cc");
#else
asm volatile("pusha \n\t"
"cpuid \n\t"
"mov %%eax, 0(%2) \n\t"
"mov %%ebx, 4(%2) \n\t"
"mov %%ecx, 8(%2) \n\t"
"mov %%edx, 12(%2) \n\t"
"popa"
: : "a"(function), "c"(count), "S"(vec)
: "memory", "cc");
#endif
if (eax)
*eax = vec[0];
if (ebx)
*ebx = vec[1];
if (ecx)
*ecx = vec[2];
if (edx)
*edx = vec[3];
#endif
}
| 1threat
|
cpu_x86_dump_seg_cache(CPUState *env, FILE *f,
int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
const char *name, struct SegmentCache *sc)
{
#ifdef TARGET_X86_64
if (env->hflags & HF_CS64_MASK) {
cpu_fprintf(f, "%-3s=%04x %016" PRIx64 " %08x %08x", name,
sc->selector, sc->base, sc->limit, sc->flags);
} else
#endif
{
cpu_fprintf(f, "%-3s=%04x %08x %08x %08x", name, sc->selector,
(uint32_t)sc->base, sc->limit, sc->flags);
}
if (!(env->hflags & HF_PE_MASK) || !(sc->flags & DESC_P_MASK))
goto done;
cpu_fprintf(f, " DPL=%d ", (sc->flags & DESC_DPL_MASK) >> DESC_DPL_SHIFT);
if (sc->flags & DESC_S_MASK) {
if (sc->flags & DESC_CS_MASK) {
cpu_fprintf(f, (sc->flags & DESC_L_MASK) ? "CS64" :
((sc->flags & DESC_B_MASK) ? "CS32" : "CS16"));
cpu_fprintf(f, " [%c%c", (sc->flags & DESC_C_MASK) ? 'C' : '-',
(sc->flags & DESC_R_MASK) ? 'R' : '-');
} else {
cpu_fprintf(f, (sc->flags & DESC_B_MASK) ? "DS " : "DS16");
cpu_fprintf(f, " [%c%c", (sc->flags & DESC_E_MASK) ? 'E' : '-',
(sc->flags & DESC_W_MASK) ? 'W' : '-');
}
cpu_fprintf(f, "%c]", (sc->flags & DESC_A_MASK) ? 'A' : '-');
} else {
static const char *sys_type_name[2][16] = {
{
"Reserved", "TSS16-avl", "LDT", "TSS16-busy",
"CallGate16", "TaskGate", "IntGate16", "TrapGate16",
"Reserved", "TSS32-avl", "Reserved", "TSS32-busy",
"CallGate32", "Reserved", "IntGate32", "TrapGate32"
},
{
"<hiword>", "Reserved", "LDT", "Reserved", "Reserved",
"Reserved", "Reserved", "Reserved", "Reserved",
"TSS64-avl", "Reserved", "TSS64-busy", "CallGate64",
"Reserved", "IntGate64", "TrapGate64"
}
};
cpu_fprintf(f, "%s",
sys_type_name[(env->hflags & HF_LMA_MASK) ? 1 : 0]
[(sc->flags & DESC_TYPE_MASK)
>> DESC_TYPE_SHIFT]);
}
done:
cpu_fprintf(f, "\n");
}
| 1threat
|
Android app works fine when it installs from android studio but crashes when share it to any other device? Anyone please help me : [Android] app works fine when it installs from android studio but crashes when share it to any other device? Anyone please help me..
| 0debug
|
static void vscsi_command_complete(SCSIRequest *sreq, uint32_t status)
{
VSCSIState *s = DO_UPCAST(VSCSIState, vdev.qdev, sreq->bus->qbus.parent);
vscsi_req *req = sreq->hba_private;
int32_t res_in = 0, res_out = 0;
dprintf("VSCSI: SCSI cmd complete, r=0x%x tag=0x%x status=0x%x, req=%p\n",
reason, sreq->tag, status, req);
if (req == NULL) {
fprintf(stderr, "VSCSI: Can't find request for tag 0x%x\n", sreq->tag);
return;
}
if (status == CHECK_CONDITION) {
req->senselen = scsi_req_get_sense(req->sreq, req->sense,
sizeof(req->sense));
status = 0;
dprintf("VSCSI: Sense data, %d bytes:\n", len);
dprintf(" %02x %02x %02x %02x %02x %02x %02x %02x\n",
req->sense[0], req->sense[1], req->sense[2], req->sense[3],
req->sense[4], req->sense[5], req->sense[6], req->sense[7]);
dprintf(" %02x %02x %02x %02x %02x %02x %02x %02x\n",
req->sense[8], req->sense[9], req->sense[10], req->sense[11],
req->sense[12], req->sense[13], req->sense[14], req->sense[15]);
}
dprintf("VSCSI: Command complete err=%d\n", status);
if (status == 0) {
if (req->writing) {
res_out = req->data_len;
} else {
res_in = req->data_len;
}
}
vscsi_send_rsp(s, req, status, res_in, res_out);
vscsi_put_req(req);
}
| 1threat
|
static inline void read_mem(IVState *s, uint64_t off, void *buf, size_t len)
{
QTestState *qtest = global_qtest;
global_qtest = s->qtest;
qpci_memread(s->dev, s->mem_base + off, buf, len);
global_qtest = qtest;
}
| 1threat
|
two separate select options should not conflict using javascript : <td> <select style="font-size:18px" id="sg" name="sg" onchange="SetText(sg,word1)">
<option value="all" selected="selected">Select</option>
<option value="icpa_2039">icpa_2039</option>
<option value="icpl_131">icpl_131</option>
<option value="icpl_96061">icpl_96061</option> </select> </td>
<td> between </td> <td> <select style="font-size:18px" id="sg2" name="sg2" onchange="SetText(sg2,word2)">
<option value="all" selected="selected">Select</option>
<option value="icpa_2039">icpa_2039</option>
<option value="icpl_131">icpl_131</option>
<option value="icpl_96061">icpl_96061</option> </select></td>
<script src="js/jquery-1.9.0.min.js"></script>
<script type="text/javascript" >
var $j = jQuery.noConflict();
$j(function(){
$j("select[id^='sg']").change(function(){
var geno1 =$j('#sg').val();
var geno2 =$j('#sg2').val();
if(geno1==geno2) {
$j('#warning').show();
$j('#warning').html("Please choose two differnet genotypes names!!!");
}
else {
$j('#warning').hide();
}
});
});
</script>
can anyone help me to figure out what is fault going on the code i wrote,
i had two separate select options where i want search values between the two select options
| 0debug
|
void object_property_add_alias(Object *obj, const char *name,
Object *target_obj, const char *target_name,
Error **errp)
{
AliasProperty *prop;
ObjectProperty *target_prop;
target_prop = object_property_find(target_obj, target_name, errp);
if (!target_prop) {
return;
}
prop = g_malloc(sizeof(*prop));
prop->target_obj = target_obj;
prop->target_name = target_name;
object_property_add(obj, name, target_prop->type,
property_get_alias,
property_set_alias,
property_release_alias,
prop, errp);
}
| 1threat
|
void qemu_co_queue_run_restart(Coroutine *co)
{
Coroutine *next;
trace_qemu_co_queue_run_restart(co);
while ((next = QSIMPLEQ_FIRST(&co->co_queue_wakeup))) {
QSIMPLEQ_REMOVE_HEAD(&co->co_queue_wakeup, co_queue_next);
qemu_coroutine_enter(next, NULL);
}
}
| 1threat
|
What problems might I run into in a program with multiple threads? : <p>Let's say I have two threads that both have access to the same gameWorld instance. The gameWorld has a List and the threads can change affect the entities with the method doAction(Action action, Map values). Each entity has a Map of values. Depending on the action and values put into the doAction method, the entities will be changed in different ways. </p>
<p>Assuming the doAction method is the only way the list of entities can be changed, are there any problems I might run into? What would happen if the same entity is being changed at the same time by both threads? Can multiple methods be running at the same time on one instance? If so, could the same method be running twice at the same time? </p>
| 0debug
|
void os_daemonize(void)
{
if (daemonize) {
pid_t pid;
int fds[2];
if (pipe(fds) == -1) {
exit(1);
}
pid = fork();
if (pid > 0) {
uint8_t status;
ssize_t len;
close(fds[1]);
again:
len = read(fds[0], &status, 1);
if (len == -1 && (errno == EINTR)) {
goto again;
}
if (len != 1) {
exit(1);
}
else if (status == 1) {
fprintf(stderr, "Could not acquire pidfile\n");
exit(1);
} else {
exit(0);
}
} else if (pid < 0) {
exit(1);
}
close(fds[0]);
daemon_pipe = fds[1];
qemu_set_cloexec(daemon_pipe);
setsid();
pid = fork();
if (pid > 0) {
exit(0);
} else if (pid < 0) {
exit(1);
}
umask(027);
signal(SIGTSTP, SIG_IGN);
signal(SIGTTOU, SIG_IGN);
signal(SIGTTIN, SIG_IGN);
}
}
| 1threat
|
How to remove "My Wish List" and "Compare Products" blocks from Magento 2.0 Luma template? : <p>I have spent a lot of hours trying to remove "My Wish List" and "Compare Products" blocks from Luma template. Besides, I need to change and remove some of the bottom links.</p>
<p>I cannot find where to modify. Can you help me, please?</p>
<p>Thanks</p>
| 0debug
|
can we check the device to be smartphone or tablet in flutter? : <p>I am actually trying to figure out if the app is running on a smartphone or tablet in my flutter app but the package <code>device_info</code> can only tell about the device but not whether the device is smartphone or tablet. Is there a way we can do this by checking the size of the device.</p>
<p>Many thanks
Mahi</p>
| 0debug
|
Attach an object to another object : <p>Where can i find the script on c# (unity3d) to attach an object to another object when you press the mouse button?</p>
<p>I tried to use a lot of different scripts, but one does not work.</p>
| 0debug
|
Error while finding the max element position in the list in python language?(value error) : <p><strong><em>ValueError: max() arg is an empty sequence</em></strong>
why am i getting the above error by this code
n=l.index(max(l))
need to find the position of the max element in the list.
l is the list of the elements</p>
| 0debug
|
Nested Touchable with absolute position : <p>I need to implement an interface where an object is clickable, but an area of this object does another action, like this:</p>
<pre><code>|-----------|
| | | -> clicking on this small area does an action
| ---|
| |
| |
| | -> clicking on this area does another action
| |
|-----------|
</code></pre>
<p>I did an implementation similar this structure:</p>
<pre><code><View> // Container
<Touchable onPress={do X}> // Large area
<Touchable onPress={do Y} style={{position: absolute, top: 0, right: 0}}> // Small area
</View>
</code></pre>
<p>The problem is that the small area never activate the onPress props. The event is always triggered on the large area.</p>
<p>Can someone help me with this?</p>
<p>Thanks!</p>
| 0debug
|
numpy difference between flat and ravel() : <p>What is the difference between the following?</p>
<pre><code>>>> import numpy as np
>>> arr = np.array([[[ 0, 1, 2],
... [ 10, 12, 13]],
... [[100, 101, 102],
... [110, 112, 113]]])
>>> arr
array([[[ 0, 1, 2],
[ 10, 12, 13]],
[[100, 101, 102],
[110, 112, 113]]])
>>> arr.ravel()
array([ 0, 1, 2, 10, 12, 13, 100, 101, 102, 110, 112, 113])
>>> arr.ravel()[0] = -1
>>> arr
array([[[ -1, 1, 2],
[ 10, 12, 13]],
[[100, 101, 102],
[110, 112, 113]]])
>>> list(arr.flat)
[-1, 1, 2, 10, 12, 13, 100, 101, 102, 110, 112, 113]
>>> arr.flat[0] = 99
>>> arr
array([[[ 99, 1, 2],
[ 10, 12, 13]],
[[100, 101, 102],
[110, 112, 113]]])
</code></pre>
<p>Other than the fact that <code>flat</code> returns an iterator instead of a list, they appear to be the same, since they both alter the original array in place (this is in contrast to <code>flatten()</code>, which returns a copy of the array). So, is there any other significant difference between <code>flat</code> and <code>ravel()</code>? If not, when would it be useful to use one instead of the other?</p>
| 0debug
|
CSS Layout: Footer at bottom OR end of page (if further down) : <p>I know, this kind of questions has been asked a lot, but somehow the correct answer is always eluding me...</p>
<p>Ok, I've got two things I want:</p>
<ul>
<li>A footer that's always on the bottom of the page, no matter if the content has less height than the available screen or more.</li>
<li>The content above the footer should fill the rest of the screen - or use more space, if needed</li>
</ul>
<p>The first part is quite easy, for example, <a href="https://codepen.io/cbracco/pen/zekgx" rel="nofollow noreferrer">here</a>, with something like this...</p>
<pre><code>.footer {
position: absolute;
bottom: 0;
left: 0;
}
</code></pre>
<p>No problem there. But how can I get the content above the <code>.footer</code> element to fill the remaining space? <code>height=100%;</code> obviously doesn't work;</p>
<p>Anyone got an idea how to realize a layout with...</p>
<ul>
<li>A fixed header</li>
<li>A footer at the bottom of the screen (or below, if the content needs more height than that)</li>
<li>A content that fills the available screen or uses more, if needed</li>
</ul>
<p>(The reason is that in the end, I want a grid with flexible height that fills the screen in the content)</p>
| 0debug
|
Changing String to Integer in Dictionary (Python) : I am trying to convert a list made up of strings in a dictionary to float variables.
Here is the code I was given:
```
data = {'year':[1990, 2000, 2010], 'gdp':['8.95', '12.56', '14.78']}
```
The end result is supposed to look like this:
```
data = {'year':[1990, 2000, 2010], 'gdp':[8.95, 12.56, 14.78]}
```
Thank you in advance for any hints or help!
| 0debug
|
Need to put dynamically generated (PHP) data into javascript : <p>I have a simple jQuery function, like this:</p>
<pre><code>$(foo).bar({
data:{
//HERE GOES SOME PREFORMATTED DATA FROM DATABASE ACCESSIBLE BY PHP FUNCTION
},
});
</code></pre>
<p>How do I do this? Thanks, cheers!</p>
| 0debug
|
Xmpp in Android with php server : <p>I am developing an app in which there is a chatting functionality also , except chat my rest app is done now i want to integrate chat in my app for which i am trying xmpp , i have tried a sample for xmpp with my own jabbered server and its working.
Following are my question are
1.How to integrate my app php data with jabbered server to show list of user chatting with there image , name , time and last message like the whats app chat list etc. like the image below<a href="https://i.stack.imgur.com/JDlde.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JDlde.png" alt="enter image description here"></a></p>
<p>2.Flow of xmpp , like how its works example first the message is sent to FCM then to jabbered server and then to Device or it works differentely.</p>
<ol start="3">
<li>How to manage chat history , do i need local database to maintain it or jabbered help for history also.</li>
</ol>
<p>Any suggestion , link , example will be appreciated Thanks.</p>
| 0debug
|
static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h, int intra ) {
const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
const int alpha = alpha_table[index_a];
const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
if (alpha ==0 || beta == 0) return;
if( bS[0] < 4 || !intra ) {
int8_t tc[4];
tc[0] = tc0_table[index_a][bS[0]]+1;
tc[1] = tc0_table[index_a][bS[1]]+1;
tc[2] = tc0_table[index_a][bS[2]]+1;
tc[3] = tc0_table[index_a][bS[3]]+1;
h->h264dsp.h264_h_loop_filter_chroma(pix, stride, alpha, beta, tc);
} else {
h->h264dsp.h264_h_loop_filter_chroma_intra(pix, stride, alpha, beta);
}
}
| 1threat
|
static void scsi_hd_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(klass);
sc->init = scsi_hd_initfn;
sc->destroy = scsi_destroy;
sc->alloc_req = scsi_new_request;
sc->unit_attention_reported = scsi_disk_unit_attention_reported;
dc->fw_name = "disk";
dc->desc = "virtual SCSI disk";
dc->reset = scsi_disk_reset;
dc->props = scsi_hd_properties;
dc->vmsd = &vmstate_scsi_disk_state;
}
| 1threat
|
Color parsing in Swift : I have a data from server in a format like "rgb(0,0,0)", which should be used on some UI elements.
Is there a way to parse it in something like UIColor(red: 0, green: 0, blue: 0, alpha: 1)?
| 0debug
|
'package' must be of length 1 : I have created an object of class shiny tag list and it is browsable as an animation in the viewer pane of Rstudio. However the file cannot be saved locally as an HTML file due to an error
Expected : HTML output file similar to what was seen on the viewer pane
Actual : Error message : Error in system.file(config, package = package) :
'package' must be of length 1
| 0debug
|
static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op)
{
static const TCGTargetOpDef r = { .args_ct_str = { "r" } };
static const TCGTargetOpDef r_r = { .args_ct_str = { "r", "r" } };
static const TCGTargetOpDef r_L = { .args_ct_str = { "r", "L" } };
static const TCGTargetOpDef L_L = { .args_ct_str = { "L", "L" } };
static const TCGTargetOpDef r_ri = { .args_ct_str = { "r", "ri" } };
static const TCGTargetOpDef r_rC = { .args_ct_str = { "r", "rC" } };
static const TCGTargetOpDef r_rZ = { .args_ct_str = { "r", "rZ" } };
static const TCGTargetOpDef r_r_ri = { .args_ct_str = { "r", "r", "ri" } };
static const TCGTargetOpDef r_0_ri = { .args_ct_str = { "r", "0", "ri" } };
static const TCGTargetOpDef r_0_rI = { .args_ct_str = { "r", "0", "rI" } };
static const TCGTargetOpDef r_0_rJ = { .args_ct_str = { "r", "0", "rJ" } };
static const TCGTargetOpDef r_0_rO = { .args_ct_str = { "r", "0", "rO" } };
static const TCGTargetOpDef r_0_rX = { .args_ct_str = { "r", "0", "rX" } };
switch (op) {
case INDEX_op_goto_ptr:
return &r;
case INDEX_op_ld8u_i32:
case INDEX_op_ld8u_i64:
case INDEX_op_ld8s_i32:
case INDEX_op_ld8s_i64:
case INDEX_op_ld16u_i32:
case INDEX_op_ld16u_i64:
case INDEX_op_ld16s_i32:
case INDEX_op_ld16s_i64:
case INDEX_op_ld_i32:
case INDEX_op_ld32u_i64:
case INDEX_op_ld32s_i64:
case INDEX_op_ld_i64:
case INDEX_op_st8_i32:
case INDEX_op_st8_i64:
case INDEX_op_st16_i32:
case INDEX_op_st16_i64:
case INDEX_op_st_i32:
case INDEX_op_st32_i64:
case INDEX_op_st_i64:
return &r_r;
case INDEX_op_add_i32:
case INDEX_op_add_i64:
return &r_r_ri;
case INDEX_op_sub_i32:
case INDEX_op_sub_i64:
return &r_0_ri;
case INDEX_op_mul_i32:
return (s390_facilities & FACILITY_GEN_INST_EXT ? &r_0_ri : &r_0_rI);
case INDEX_op_mul_i64:
return (s390_facilities & FACILITY_GEN_INST_EXT ? &r_0_rJ : &r_0_rI);
case INDEX_op_or_i32:
case INDEX_op_or_i64:
return &r_0_rO;
case INDEX_op_xor_i32:
case INDEX_op_xor_i64:
return &r_0_rX;
case INDEX_op_and_i32:
case INDEX_op_and_i64:
return &r_0_ri;
case INDEX_op_shl_i32:
case INDEX_op_shr_i32:
case INDEX_op_sar_i32:
return &r_0_ri;
case INDEX_op_shl_i64:
case INDEX_op_shr_i64:
case INDEX_op_sar_i64:
return &r_r_ri;
case INDEX_op_rotl_i32:
case INDEX_op_rotl_i64:
case INDEX_op_rotr_i32:
case INDEX_op_rotr_i64:
return &r_r_ri;
case INDEX_op_brcond_i32:
return (s390_facilities & FACILITY_EXT_IMM ? &r_ri : &r_rZ);
case INDEX_op_brcond_i64:
return (s390_facilities & FACILITY_EXT_IMM ? &r_rC : &r_rZ);
case INDEX_op_bswap16_i32:
case INDEX_op_bswap16_i64:
case INDEX_op_bswap32_i32:
case INDEX_op_bswap32_i64:
case INDEX_op_bswap64_i64:
case INDEX_op_neg_i32:
case INDEX_op_neg_i64:
case INDEX_op_ext8s_i32:
case INDEX_op_ext8s_i64:
case INDEX_op_ext8u_i32:
case INDEX_op_ext8u_i64:
case INDEX_op_ext16s_i32:
case INDEX_op_ext16s_i64:
case INDEX_op_ext16u_i32:
case INDEX_op_ext16u_i64:
case INDEX_op_ext32s_i64:
case INDEX_op_ext32u_i64:
case INDEX_op_ext_i32_i64:
case INDEX_op_extu_i32_i64:
case INDEX_op_extract_i32:
case INDEX_op_extract_i64:
return &r_r;
case INDEX_op_clz_i64:
return &r_r_ri;
case INDEX_op_qemu_ld_i32:
case INDEX_op_qemu_ld_i64:
return &r_L;
case INDEX_op_qemu_st_i64:
case INDEX_op_qemu_st_i32:
return &L_L;
case INDEX_op_deposit_i32:
case INDEX_op_deposit_i64:
{
static const TCGTargetOpDef dep
= { .args_ct_str = { "r", "rZ", "r" } };
return &dep;
}
case INDEX_op_setcond_i32:
case INDEX_op_setcond_i64:
{
static const TCGTargetOpDef setc_z
= { .args_ct_str = { "r", "r", "rZ" } };
static const TCGTargetOpDef setc_c
= { .args_ct_str = { "r", "r", "rC" } };
return (s390_facilities & FACILITY_EXT_IMM ? &setc_c : &setc_z);
}
case INDEX_op_movcond_i32:
case INDEX_op_movcond_i64:
{
static const TCGTargetOpDef movc_z
= { .args_ct_str = { "r", "r", "rZ", "r", "0" } };
static const TCGTargetOpDef movc_c
= { .args_ct_str = { "r", "r", "rC", "r", "0" } };
return (s390_facilities & FACILITY_EXT_IMM ? &movc_c : &movc_z);
}
case INDEX_op_div2_i32:
case INDEX_op_div2_i64:
case INDEX_op_divu2_i32:
case INDEX_op_divu2_i64:
{
static const TCGTargetOpDef div2
= { .args_ct_str = { "b", "a", "0", "1", "r" } };
return &div2;
}
case INDEX_op_mulu2_i64:
{
static const TCGTargetOpDef mul2
= { .args_ct_str = { "b", "a", "0", "r" } };
return &mul2;
}
case INDEX_op_add2_i32:
case INDEX_op_add2_i64:
case INDEX_op_sub2_i32:
case INDEX_op_sub2_i64:
{
static const TCGTargetOpDef arith2
= { .args_ct_str = { "r", "r", "0", "1", "rA", "r" } };
return &arith2;
}
default:
break;
}
return NULL;
}
| 1threat
|
Regex for remove domain in hostname : <p>I am trying to capture only the hostname within this date, but my regex is broken when inside the hostname, there are <code>.</code> because I remove the <strong>hostname domain</strong></p>
<p><strong>REGEX</strong></p>
<pre><code>^([^;@#.\s]+)
</code></pre>
<p><strong>DATA</strong></p>
<pre><code>srvdata;172.24.154.210
srvnet;10.16.0.1
srvdata2 300
#srvdata3
srvdata3 #srvdata3
srvdata4.domain.com
srvdata.4.domain.com
</code></pre>
<p><strong>OUTPUT</strong></p>
<pre><code>srvdata
srvnet
srvdata2
srvdata3
srvdata4
srvdata
</code></pre>
<p><strong>DESIRED OUTPUT</strong></p>
<pre><code>srvdata
srvnet
srvdata2
srvdata3
srvdata4
srvdata.4
</code></pre>
<p><a href="https://regex101.com/r/KQNbSr/3/" rel="nofollow noreferrer"><strong>REGEX101</strong></a></p>
| 0debug
|
Displaying customUIView in a ViewController : I am creating a uiView which I want to display in my viewcontroller . I have created the UIView and it shows but the problem I have now are
1. When I call the uiview in my viewcontroller, I can no longer interact with the elements of the viewcontroller. The CostomView I created has completely prevented the interaction with my viewcontroller and I want to be able to interact with the UIViewcontroller
2. I want to hide the status bar which includes the battery percentage and networkbar and other things so the view completely covers them. I implemeted a code to cover them but it returns an error.
below is my code
class SliderView: CustomView {
@IBOutlet weak var containerView: UIView!
@IBOutlet weak var sliderImage: UIImageView!
@IBOutlet weak var sliderText: UILabel!
override func initialize() {
super.initialize()
let name = String(describing: type(of: self))
let nib = UINib(nibName: name, bundle: .main)
nib.instantiate(withOwner: self, options: nil)
self.addSubview(self.containerView)
self.containerView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
self.containerView.topAnchor.constraint(equalTo: self.topAnchor),
self.containerView.leadingAnchor.constraint(equalTo: self.leadingAnchor),
self.containerView.trailingAnchor.constraint(equalTo: self.trailingAnchor),
])
}
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
return sliderImage.frame.contains(point)
}
override var prefersStatusBarHidden: Bool {
return true
}
// THIS THROWS an error 'Property does not override any property from its superclass'
}
my UIView is called in my Viewcontroller like
weak var sliderView: SliderView!
override func loadView() {
super.loadView()
let sliderView = SliderView()
self.view.addSubview(sliderView)
NSLayoutConstraint.activate([
sliderView.topAnchor.constraint(equalTo: self.view.topAnchor),
sliderView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
sliderView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
sliderView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
])
self.sliderView = sliderView
}
override func viewDidLoad() {
super.viewDidLoad()
sliderView.sliderText.text = "HOOOOO WORKS"
}
| 0debug
|
Generate random matrix with specific values : <p>I am new to MATLAB and I want to create a random n*n matrix containing just -1 OR 1 as values.
any help ?</p>
| 0debug
|
static void prstatfs_to_statfs(struct statfs *stfs, ProxyStatFS *prstfs)
{
memset(stfs, 0, sizeof(*stfs));
stfs->f_type = prstfs->f_type;
stfs->f_bsize = prstfs->f_bsize;
stfs->f_blocks = prstfs->f_blocks;
stfs->f_bfree = prstfs->f_bfree;
stfs->f_bavail = prstfs->f_bavail;
stfs->f_files = prstfs->f_files;
stfs->f_ffree = prstfs->f_ffree;
stfs->f_fsid.__val[0] = prstfs->f_fsid[0] & 0xFFFFFFFFU;
stfs->f_fsid.__val[1] = prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU;
stfs->f_namelen = prstfs->f_namelen;
stfs->f_frsize = prstfs->f_frsize;
}
| 1threat
|
static int proxy_chown(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp)
{
int retval;
retval = v9fs_request(fs_ctx->private, T_CHOWN, NULL, "sdd",
fs_path, credp->fc_uid, credp->fc_gid);
if (retval < 0) {
errno = -retval;
}
return retval;
}
| 1threat
|
Python decorators in classes Eoor : class A(object):
def wrapped(self, func):
func.string = self.get_something()
return func
def get_something(self):
return "something"
@wrapped
def main(self):
print self.main.string
a = A()
a.main()
| 0debug
|
Meaning of Lazy Evaluation in Javascript : <p>in the Boilerplate I am using for a React Redux project I came across this comment in the code:</p>
<blockquote>
<p>This is a thunk, meaning it is a function that immediately returns a
function for lazy evaluation. It is incredibly useful for creating
async actions, especially when combined with redux-thunk!</p>
</blockquote>
<p>Now, if I understand this correctly, lazy evaluation is the process of returning a function. What is the purpose of returning a function though, and how is this great for creating async actions?</p>
<p><em>Oh also</em>, is a thunk just a function?</p>
| 0debug
|
How to get div id, if i have link href? : How can i get `div#id` by link href?
>I think to use `XPATH` and get parents elements by ..//.
But no. Help please!
| 0debug
|
TypeScript conditional types - filter out readonly properties / pick only required properties : <p>Using the new conditional types in TypeScript (or maybe another technique), is there a way to pick only certain properties from an interface based on their modifiers? For example, having...</p>
<pre><code>interface I1 {
readonly n: number
s: string
}
</code></pre>
<p>I would like to create a new type based on the previous one which looks like this:</p>
<pre><code>interface I2 {
s: string
}
</code></pre>
| 0debug
|
Order of Programming/Engineering : I am currently working on a new software and I am not sure how to go on.
I already started coding before having a good plan.
My opinion was to start with:
1. Create User Stories
2. Create BMSC & Hsmc
3. Code the required features
4. Test
5. Refactor & solve bugs
Now I want to know where do i put the UML Diagram, before coding or after coding?
| 0debug
|
C# - Field values of an array picking up values of a loop : <p>I'm training C# on a simple card game. I have methods that shuffle and deals the cards. I have a random deck that is well generated.
Is it possible to set an array for the player1 cards, picking up the first ten values of the array.
Here is a part of my code : </p>
<pre><code>currentCard = 0;
public Card DealCard()
{
if (currentCard < deck.Length)
return deck[currentCard++];
else
return null;
}
</code></pre>
<p>I want to pick up for example ten first values of </p>
<pre><code>deck[currentCard++]
</code></pre>
<p>Any suggestions will be appreciated, thanks for your help !</p>
| 0debug
|
void init_rl(RLTable *rl)
{
int8_t max_level[MAX_RUN+1], max_run[MAX_LEVEL+1];
uint8_t index_run[MAX_RUN+1];
int last, run, level, start, end, i;
for(last=0;last<2;last++) {
if (last == 0) {
start = 0;
end = rl->last;
} else {
start = rl->last;
end = rl->n;
}
memset(max_level, 0, MAX_RUN + 1);
memset(max_run, 0, MAX_LEVEL + 1);
memset(index_run, rl->n, MAX_RUN + 1);
for(i=start;i<end;i++) {
run = rl->table_run[i];
level = rl->table_level[i];
if (index_run[run] == rl->n)
index_run[run] = i;
if (level > max_level[run])
max_level[run] = level;
if (run > max_run[level])
max_run[level] = run;
}
rl->max_level[last] = av_malloc(MAX_RUN + 1);
memcpy(rl->max_level[last], max_level, MAX_RUN + 1);
rl->max_run[last] = av_malloc(MAX_LEVEL + 1);
memcpy(rl->max_run[last], max_run, MAX_LEVEL + 1);
rl->index_run[last] = av_malloc(MAX_RUN + 1);
memcpy(rl->index_run[last], index_run, MAX_RUN + 1);
}
}
| 1threat
|
';' expected while i follow tutorial : <pre><code>package com.company;
import java.io.*;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
throw IOException{
}
}
}
</code></pre>
<p>Can some body help me please i follow tutorial but it show up ';' expected error</p>
| 0debug
|
How to monitor a jar file and rerun jar on it is changed ? : I deployed app.jar file on server by command:
`java -jar app.jar`
Then I hope app.jar can be replaced and restarted automatically,
It there any solution to do this ?
| 0debug
|
I have a scenario when i need to insert into table from same table after changing some column. Issue is Identity Column : let say,
insert into A select * from A where col1 = "ABC", leads to an error as there would be a same identity column, I want to increment automatically from the max id the table have
| 0debug
|
import re
def text_match_word(text):
patterns = '\w+\S*$'
if re.search(patterns, text):
return 'Found a match!'
else:
return 'Not matched!'
| 0debug
|
How to sort Hashset<MyBean> : I have a `Set<MultiAdminComponent> rootItems = new HashSet<>();`HashSet.
In this I have all my[ Screen.][1]
In my `HashSet` I am going to have all my rows. I want to sort the `MultiAdminComponent` based on `rowId`.
**This is MultiAdminComponent**
public class MultiAdminComponent {
private String componentName;
private String componentIdentification;
private String componentType;
private String componentState;
private String componentUrl;
private String componentId;
private String rowId;
private List<MultiAdminComponent> items;
private int componentStateId;
private int ctastatus;
private String actionId;
private String actionToPerform;
private int orderNumber;
private int ctarevision;
[1]: https://plnkr.co/edit/XgfuZho0E8Gi5d1CbOrH?p=preview
How can I sort based on RowId in `MultiAdminComponent` bean
| 0debug
|
int xics_alloc(XICSState *icp, int src, int irq_hint, bool lsi)
{
ICSState *ics = &icp->ics[src];
int irq;
if (irq_hint) {
assert(src == xics_find_source(icp, irq_hint));
if (!ICS_IRQ_FREE(ics, irq_hint - ics->offset)) {
trace_xics_alloc_failed_hint(src, irq_hint);
return -1;
}
irq = irq_hint;
} else {
irq = ics_find_free_block(ics, 1, 1);
if (irq < 0) {
trace_xics_alloc_failed_no_left(src);
return -1;
}
irq += ics->offset;
}
ics_set_irq_type(ics, irq - ics->offset, lsi);
trace_xics_alloc(src, irq);
return irq;
}
| 1threat
|
How to get Linux autocompletion with numbered menu? : <p>I've been trying to find this for a couple of days now and while I am aware that I can write a bash function to get it the way I want, I am sure that this option comes out of the box.</p>
<p>I have recently upgraded to RHEL 7.11 and in previous RHEL versions when using double tab it would display a numbered menu when I had ambiguous options.</p>
<p>Consider this, I have a directory with the following files:</p>
<pre><code>abc abcd abcde abcdef abcdefg abcdefgh abcdefghi
</code></pre>
<p>So when I type:</p>
<pre><code>cat abc [tab][tab]
</code></pre>
<p>And there were multiple matches, I would get:</p>
<pre><code>1) abc
2) abcd
3) abcde
4) abcdef
5) abcdefg
6) abcdefgh
7) abcdefghi
</code></pre>
<p>Subsequently I could type <strong>'7'</strong> and <strong>[tab]</strong> and it would concatenate the file at the option <strong>7)</strong>.</p>
<p>This is super useful when there are a lot of similar options with many files starting with the same characters (as is the case on my server where file names are preceded with system names for clarity).</p>
<p>Any ideas?</p>
| 0debug
|
Pylint: Disable specific warnings for specific folder : <p>We have a Python project laid out like this:</p>
<pre><code>project/
├── .pylintrc
├── module1.py
├── module2.py
└── tests/
├── test_module1.py
└── test_module2.py
</code></pre>
<p>Our unit and function tests reside in the folder called <code>tests/</code>. When it comes to tests the pylint warnings <code>missing-docstring</code>, <code>invalid-name</code> and <code>protected-access</code> are not relevant. On the other hand, these warnings are very useful for the actual code in the project.</p>
<p>My question is whether it is possible to add ignores for <code>missing-docstring</code>, <code>invalid-name</code> and <code>protected-access</code> in the <code>.pylintrc</code>-file that apply to modules in the <code>tests/</code>-folder <em>only</em>?</p>
<p>If possible, we do not want to add <code>#</code>-disables for these warnings to every test-module inside the folder.</p>
| 0debug
|
sql server import and export wizard error when trying to import access database into sql server : My access database is password protected and i work as it
https://stackoverflow.com/a/22500754/8736671
but it have an error that the work group file information file is missing or opened exclusively an other user.
| 0debug
|
How can i ignore error to continue project in c# code? : <p>I am working on a windows form application. when i run the project in one of my class error occurs. (see below image)</p>
<p><a href="https://i.stack.imgur.com/ho7ra.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ho7ra.jpg" alt="enter image description here"></a></p>
<p>But when i press continue button The project runs well. Also, I can not delete this line of code. How can I ignore this error to continue project?</p>
| 0debug
|
Status Bar light content doesn't work : this is not duplicated question I couldn't found answer in this website i have tried all this methods below
override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent }
this is my first time to face this kind of this code works in my Previous apps
[i even change this in my target ][1]
[1]: https://i.stack.imgur.com/Pyj8p.png
| 0debug
|
static always_inline void gen_intermediate_code_internal (CPUState *env,
TranslationBlock *tb,
int search_pc)
{
DisasContext ctx, *ctxp = &ctx;
opc_handler_t **table, *handler;
target_ulong pc_start;
uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int j, lj = -1;
int num_insns;
int max_insns;
pc_start = tb->pc;
gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
ctx.nip = pc_start;
ctx.tb = tb;
ctx.exception = POWERPC_EXCP_NONE;
ctx.spr_cb = env->spr_cb;
ctx.mem_idx = env->mmu_idx;
ctx.access_type = -1;
ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0;
#if defined(TARGET_PPC64)
ctx.sf_mode = msr_sf;
#endif
ctx.fpu_enabled = msr_fp;
if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)
ctx.spe_enabled = msr_spe;
else
ctx.spe_enabled = 0;
if ((env->flags & POWERPC_FLAG_VRE) && msr_vr)
ctx.altivec_enabled = msr_vr;
else
ctx.altivec_enabled = 0;
if ((env->flags & POWERPC_FLAG_SE) && msr_se)
ctx.singlestep_enabled = CPU_SINGLE_STEP;
else
ctx.singlestep_enabled = 0;
if ((env->flags & POWERPC_FLAG_BE) && msr_be)
ctx.singlestep_enabled |= CPU_BRANCH_STEP;
if (unlikely(env->singlestep_enabled))
ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP;
#if defined (DO_SINGLE_STEP) && 0
msr_se = 1;
#endif
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0)
max_insns = CF_COUNT_MASK;
gen_icount_start();
while (ctx.exception == POWERPC_EXCP_NONE && gen_opc_ptr < gen_opc_end) {
if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) {
TAILQ_FOREACH(bp, &env->breakpoints, entry) {
if (bp->pc == ctx.nip) {
gen_debug_exception(ctxp);
break;
}
}
}
if (unlikely(search_pc)) {
j = gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
gen_opc_instr_start[lj++] = 0;
gen_opc_pc[lj] = ctx.nip;
gen_opc_instr_start[lj] = 1;
gen_opc_icount[lj] = num_insns;
}
}
LOG_DISAS("----------------\n");
LOG_DISAS("nip=" ADDRX " super=%d ir=%d\n",
ctx.nip, ctx.mem_idx, (int)msr_ir);
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
gen_io_start();
if (unlikely(ctx.le_mode)) {
ctx.opcode = bswap32(ldl_code(ctx.nip));
} else {
ctx.opcode = ldl_code(ctx.nip);
}
LOG_DISAS("translate opcode %08x (%02x %02x %02x) (%s)\n",
ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), little_endian ? "little" : "big");
ctx.nip += 4;
table = env->opcodes;
num_insns++;
handler = table[opc1(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc2(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc3(ctx.opcode)];
}
}
if (unlikely(handler->handler == &gen_invalid)) {
if (qemu_log_enabled()) {
qemu_log("invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) " ADDRX " %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);
} else {
printf("invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) " ADDRX " %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);
}
} else {
if (unlikely((ctx.opcode & handler->inval) != 0)) {
if (qemu_log_enabled()) {
qemu_log("invalid bits: %08x for opcode: "
"%02x - %02x - %02x (%08x) " ADDRX "\n",
ctx.opcode & handler->inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
} else {
printf("invalid bits: %08x for opcode: "
"%02x - %02x - %02x (%08x) " ADDRX "\n",
ctx.opcode & handler->inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
}
gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL);
break;
}
}
(*(handler->handler))(&ctx);
#if defined(DO_PPC_STATISTICS)
handler->count++;
#endif
if (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP &&
(ctx.nip <= 0x100 || ctx.nip > 0xF00) &&
ctx.exception != POWERPC_SYSCALL &&
ctx.exception != POWERPC_EXCP_TRAP &&
ctx.exception != POWERPC_EXCP_BRANCH)) {
gen_exception(ctxp, POWERPC_EXCP_TRACE);
} else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) ||
(env->singlestep_enabled) ||
num_insns >= max_insns)) {
break;
}
#if defined (DO_SINGLE_STEP)
break;
#endif
}
if (tb->cflags & CF_LAST_IO)
gen_io_end();
if (ctx.exception == POWERPC_EXCP_NONE) {
gen_goto_tb(&ctx, 0, ctx.nip);
} else if (ctx.exception != POWERPC_EXCP_BRANCH) {
if (unlikely(env->singlestep_enabled)) {
gen_debug_exception(ctxp);
}
tcg_gen_exit_tb(0);
}
gen_icount_end(tb, num_insns);
*gen_opc_ptr = INDEX_op_end;
if (unlikely(search_pc)) {
j = gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j)
gen_opc_instr_start[lj++] = 0;
} else {
tb->size = ctx.nip - pc_start;
tb->icount = num_insns;
}
#if defined(DEBUG_DISAS)
qemu_log_mask(CPU_LOG_TB_CPU, "---------------- excp: %04x\n", ctx.exception);
log_cpu_state_mask(CPU_LOG_TB_CPU, env, 0);
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
int flags;
flags = env->bfd_mach;
flags |= ctx.le_mode << 16;
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(pc_start, ctx.nip - pc_start, flags);
qemu_log("\n");
}
#endif
}
| 1threat
|
Html isn't recognizing the tags that Angularjs spitting out : <p>Angular</p>
<pre><code> $scope.name = "<h1>John Doe</h1>"
</code></pre>
<p>HTML</p>
<pre><code> <div>{{name}}</div>
</code></pre>
<p>Outputs:</p>
<pre><code> <h1>John Doe</h1>
</code></pre>
<p>How do I make it so Html recognize the tags that I'm spitting on the page.</p>
| 0debug
|
StackExchange redis client very slow compared to benchmark tests : <p>I'm implementing a Redis caching layer using the Stackexchange Redis client and the performance right now is bordering on unusable.</p>
<p>I have a local environment where the web application and the redis server are running on the same machine. I ran the Redis benchmark test against my Redis server and the results were actually really good (I'm just including set and get operations in my write up):</p>
<pre><code>C:\Program Files\Redis>redis-benchmark -n 100000
====== PING_INLINE ======
100000 requests completed in 0.88 seconds
50 parallel clients
3 bytes payload
keep alive: 1
====== SET ======
100000 requests completed in 0.89 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.70% <= 1 milliseconds
99.90% <= 2 milliseconds
100.00% <= 3 milliseconds
111982.08 requests per second
====== GET ======
100000 requests completed in 0.81 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.87% <= 1 milliseconds
99.98% <= 2 milliseconds
100.00% <= 2 milliseconds
124069.48 requests per second
</code></pre>
<p>So according to the benchmarks I am looking at over 100,000 sets and 100,000 gets, per second. I wrote a unit test to do 300,000 set/gets:</p>
<pre><code>private string redisCacheConn = "localhost:6379,allowAdmin=true,abortConnect=false,ssl=false";
[Fact]
public void PerfTestWriteShortString()
{
CacheManager cm = new CacheManager(redisCacheConn);
string svalue = "t";
string skey = "testtesttest";
for (int i = 0; i < 300000; i++)
{
cm.SaveCache(skey + i, svalue);
string valRead = cm.ObtainItemFromCacheString(skey + i);
}
}
</code></pre>
<p>This uses the following class to perform the Redis operations via the Stackexchange client:</p>
<pre><code>using StackExchange.Redis;
namespace Caching
{
public class CacheManager:ICacheManager, ICacheManagerReports
{
private static string cs;
private static ConfigurationOptions options;
private int pageSize = 5000;
public ICacheSerializer serializer { get; set; }
public CacheManager(string connectionString)
{
serializer = new SerializeJSON();
cs = connectionString;
options = ConfigurationOptions.Parse(connectionString);
options.SyncTimeout = 60000;
}
private static readonly Lazy<ConnectionMultiplexer> lazyConnection = new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect(options));
private static ConnectionMultiplexer Connection => lazyConnection.Value;
private static IDatabase cache => Connection.GetDatabase();
public string ObtainItemFromCacheString(string cacheId)
{
return cache.StringGet(cacheId);
}
public void SaveCache<T>(string cacheId, T cacheEntry, TimeSpan? expiry = null)
{
if (IsValueType<T>())
{
cache.StringSet(cacheId, cacheEntry.ToString(), expiry);
}
else
{
cache.StringSet(cacheId, serializer.SerializeObject(cacheEntry), expiry);
}
}
public bool IsValueType<T>()
{
return typeof(T).IsValueType || typeof(T) == typeof(string);
}
}
}
</code></pre>
<p>My JSON serializer is just using Newtonsoft.JSON:</p>
<pre><code>using System.Collections.Generic;
using Newtonsoft.Json;
namespace Caching
{
public class SerializeJSON:ICacheSerializer
{
public string SerializeObject<T>(T cacheEntry)
{
return JsonConvert.SerializeObject(cacheEntry, Formatting.None,
new JsonSerializerSettings()
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
}
public T DeserializeObject<T>(string data)
{
return JsonConvert.DeserializeObject<T>(data, new JsonSerializerSettings()
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
}
}
}
</code></pre>
<p>My test times are around 21 seconds (for 300,000 sets and 300,000 gets). This gives me around 28,500 operations per second (at least 3 times slower than I would expect using the benchmarks). The application I am converting to use Redis is pretty chatty and certain heavy requests can approximate 200,000 total operations against Redis. Obviously I wasn't expecting anything like the same times I was getting when using the system runtime cache, but the delays after this change are significant. Am I doing something wrong with my implementation and does anyone know why my benchmarked figures are so much faster than my Stackechange test figures?</p>
<p>Thanks,
Paul</p>
| 0debug
|
How to find dates between two dates in SqlServer 2005 : I need to find the dates between two dates in sql server.
2015-12-04 00:00:00.000 and 2015-12-10 00:00:00.000
| 0debug
|
how to call a bootstarp class into javascript using (document.get element by class) : how to call a bootstrap class into java script using HTML DOM getElementsByClassName() Method
for eg:-
document.getElementByClass=("has-error");
I need a the text box to turn into green if the data is valid and to red if the data is in valid using boot strap class
**has-success and has-error**
| 0debug
|
static inline void omap_gp_timer_trigger(struct omap_gp_timer_s *timer)
{
if (timer->pt)
omap_gp_timer_out(timer, !timer->out_val);
else
qemu_irq_pulse(timer->out);
}
| 1threat
|
Remove text between two parenthesis, if two more parenthesis : <p>I have this string:</p>
<p><code>"This thing (123, 12) (2005.03 - 2011.12)"</code></p>
<p>I want to convert it to:</p>
<p><code>"This thing (2005.03 - 2011.12)"</code></p>
<p>Meaning remove text between two first parenthesis: <code>(123, 12)</code>. But only if there are two or more parenthesis following in same string. So a string like </p>
<p><code>"Another thing (2005.05 - 2011.08)"</code> </p>
<p>should be left as it is.
How can I do it with javascript?</p>
| 0debug
|
Java ActionListener (actionPerfomed) not working for me : <p>The below is a simple code to learn ActionListener, but I don't really understand what is wrong with the code. The program is not printing anything when any of the component is selected. Any suggestion? Thanks.</p>
<pre><code>public class ComboBoxDemo extends JFrame implements ActionListener{
private String[] str = {"One", "Two", "Three", "Four"};
private String[] d = {"1", "2", "3", "4"};
private JPanel panel;
private JButton button;
private JComboBox cb, cb1;
private int count = 0;
public ComboBoxDemo() {
panel = new JPanel();
button = new JButton("Click");
setTitle("Demo");
panel.setLayout(new FlowLayout());
cb = new JComboBox<String>(str);
cb1 = new JComboBox<String>(d);
panel.add(cb);
panel.add(cb1);
panel.add(button);
getContentPane().add(panel);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(200,200);
setVisible(true);
}
public static void main(String[] args) {
new ComboBoxDemo();
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == button) {
count = count*2;
System.out.println(count);
}
if(e.getSource() == cb) {
count++;
System.out.println(count);
}
if(e.getSource() == cb1) {
count--;
System.out.println(count);
}
}
}
</code></pre>
| 0debug
|
static int aiff_write_trailer(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
AIFFOutputContext *aiff = s->priv_data;
AVCodecParameters *par = s->streams[0]->codecpar;
int64_t file_size, end_size;
end_size = file_size = avio_tell(pb);
if (file_size & 1) {
avio_w8(pb, 0);
end_size++;
}
if (s->pb->seekable) {
avio_seek(pb, aiff->form, SEEK_SET);
avio_wb32(pb, file_size - aiff->form - 4);
avio_seek(pb, aiff->frames, SEEK_SET);
avio_wb32(pb, (file_size - aiff->ssnd - 12) / par->block_align);
avio_seek(pb, aiff->ssnd, SEEK_SET);
avio_wb32(pb, file_size - aiff->ssnd - 4);
avio_seek(pb, end_size, SEEK_SET);
avio_flush(pb);
}
return 0;
}
| 1threat
|
Visual Studio C++ difference between Managed Test Project and Native Unit Test Project : <p>I'm new to visual studio, what are some of the differences between Managed Test Project and Native Unit Test Project. Most of the unit test information available on the internet just says to make a native unit test, but what's the actual difference?</p>
| 0debug
|
static void bswap_phdr(struct elf_phdr *phdr)
{
bswap32s(&phdr->p_type);
bswaptls(&phdr->p_offset);
bswaptls(&phdr->p_vaddr);
bswaptls(&phdr->p_paddr);
bswaptls(&phdr->p_filesz);
bswaptls(&phdr->p_memsz);
bswap32s(&phdr->p_flags);
bswaptls(&phdr->p_align);
}
| 1threat
|
Copy current directory in to docker image : <p>When building my Docker image I need to copy all of the files in the same directory in to the Docker image.</p>
<p>I attempted to do this </p>
<pre><code>ADD ./* $HOME/src
RUN ls $HOME/src
</code></pre>
<p>but it doesn't seem to work </p>
<pre><code>ls: cannot access /root/src: No such file or directory
</code></pre>
<p>How would I go about copying all of the current directory and subdirectories in to my docker image while building?</p>
| 0debug
|
connection.query('SELECT * FROM users WHERE username = ' + input_string)
| 1threat
|
static void musicpal_misc_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
}
| 1threat
|
HTML, Javascript Help, CSS : i am working on a restaurant website. i created a form with select option and i want it that if someone selects any of the options, a price for that option will appear. i know javascript should be used but i am not that good in javascript and i hope someone can help me out.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<div class="col-md-7 col-md-offset-1">
<div class="col-md-3">
<label for="menu">Food: </label>
</div>
<div class="col-md-5">
<select name="menu" id="menu" required>
<option value="jollof" selected>Jollof w/ chicken</option>
<option value="jollof" >Plain Rice w/ chicken</option>
<option value="jollof" >Salad w/ chicken</option>
<option value="jollof" >Jollof w/ Fish</option>
<option value="jollof" >Plain Rice w/ chicken</option>
<option value="jollof" >Fufu w/ chicken</option>
<option value="jollof" >Fufu w/ Goat Meat</option>
<option value="jollof" >Fufu w/ Fish</option>
<option value="jollof" >Chips w/ Chicken</option>
<option value="jollof" >Chips w/ Fish</option>
</select>
</div>
</div>
<!-- end snippet -->
| 0debug
|
CONVERT (3 Days 18 Hours 39 Minutes) into seconds in SQL : CONVERT (3 Days 18 Hours 39 Minutes) into seconds in SQL
| 0debug
|
static int parse_playlist(URLContext *h, const char *url)
{
HLSContext *s = h->priv_data;
AVIOContext *in;
int ret = 0, is_segment = 0, is_variant = 0, bandwidth = 0;
int64_t duration = 0;
char line[1024];
const char *ptr;
if ((ret = avio_open2(&in, url, AVIO_FLAG_READ,
&h->interrupt_callback, NULL)) < 0)
return ret;
read_chomp_line(in, line, sizeof(line));
if (strcmp(line, "#EXTM3U"))
return AVERROR_INVALIDDATA;
free_segment_list(s);
s->finished = 0;
while (!in->eof_reached) {
read_chomp_line(in, line, sizeof(line));
if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) {
struct variant_info info = {{0}};
is_variant = 1;
ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_variant_args,
&info);
bandwidth = atoi(info.bandwidth);
} else if (av_strstart(line, "#EXT-X-TARGETDURATION:", &ptr)) {
s->target_duration = atoi(ptr) * AV_TIME_BASE;
} else if (av_strstart(line, "#EXT-X-MEDIA-SEQUENCE:", &ptr)) {
s->start_seq_no = atoi(ptr);
} else if (av_strstart(line, "#EXT-X-ENDLIST", &ptr)) {
s->finished = 1;
} else if (av_strstart(line, "#EXTINF:", &ptr)) {
is_segment = 1;
duration = atof(ptr) * AV_TIME_BASE;
} else if (av_strstart(line, "#", NULL)) {
continue;
} else if (line[0]) {
if (is_segment) {
struct segment *seg = av_malloc(sizeof(struct segment));
if (!seg) {
ret = AVERROR(ENOMEM);
goto fail;
}
seg->duration = duration;
ff_make_absolute_url(seg->url, sizeof(seg->url), url, line);
dynarray_add(&s->segments, &s->n_segments, seg);
is_segment = 0;
} else if (is_variant) {
struct variant *var = av_malloc(sizeof(struct variant));
if (!var) {
ret = AVERROR(ENOMEM);
goto fail;
}
var->bandwidth = bandwidth;
ff_make_absolute_url(var->url, sizeof(var->url), url, line);
dynarray_add(&s->variants, &s->n_variants, var);
is_variant = 0;
}
}
}
s->last_load_time = av_gettime_relative();
fail:
avio_close(in);
return ret;
}
| 1threat
|
static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)
{
VirtIOBlock *s = to_virtio_blk(vdev);
struct virtio_blk_config blkcfg;
uint64_t capacity;
int cylinders, heads, secs;
bdrv_get_geometry(s->bs, &capacity);
bdrv_get_geometry_hint(s->bs, &cylinders, &heads, &secs);
stq_raw(&blkcfg.capacity, capacity);
stl_raw(&blkcfg.seg_max, 128 - 2);
stw_raw(&blkcfg.cylinders, cylinders);
blkcfg.heads = heads;
blkcfg.sectors = secs;
memcpy(config, &blkcfg, sizeof(blkcfg));
}
| 1threat
|
React-Leaflet marker files not found : <p>I've got very simple code to display a map using react-leaflet and place a marker on it. However, i get the following two errors in my browser console</p>
<blockquote>
<p>GET <a href="http://localhost:8080/marker-icon-2x.png" rel="noreferrer">http://localhost:8080/marker-icon-2x.png</a> 404 (Not Found)</p>
<p>GET <a href="http://localhost:8080/marker-shadow.png" rel="noreferrer">http://localhost:8080/marker-shadow.png</a> 404 (Not Found)</p>
</blockquote>
<p>I tried to fix this issue by downloading those two images and placing them at the root. It works. However, how can i change the URL the react-leaflet marker element looks for the marker images? I'd like to store them in "./images" rather than at the root.</p>
| 0debug
|
how to calculate support of a itemset : ask: Implement function support to calculate the support of a given rule on a set of transactions. The funciton has signiture
def support(rule, transactions):
pass
where
rule is a list of two sets, represneting the X→YX→Y rule
transactions is a list of transactions
| 0debug
|
sas loigc operators not evaluating correctly : I have a condition which follows this logic Av(B^C) which is equivalent to (AvB) ^ (BvC).
Where:
A = NAF> 2
B= (COUNT_INT + COUNT_NOINT < 25)
C= (NAF> 1)
This is the condition given in the specs: NAF> 2 OR
(( COUNT_INT + COUNT_NOINT < 25) AND (NAF> 1))
This is how I coded it in sas, but its not producing the correct results. I appreciate any suggestions. Thanks.
if (((naf gt 2 or sum(count_int,count_nonint) lt 25)) and (naf gt 2 or naf gt 1)) then check_naf = "bad";
| 0debug
|
static inline void RENAME(yuvPlanartouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
unsigned int width, unsigned int height,
int lumStride, int chromStride, int dstStride, int vertLumPerChroma)
{
unsigned y;
const unsigned chromWidth= width>>1;
for(y=0; y<height; y++)
{
#ifdef HAVE_MMX
asm volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
".balign 16 \n\t"
"1: \n\t"
PREFETCH" 32(%1, %%"REG_a", 2) \n\t"
PREFETCH" 32(%2, %%"REG_a") \n\t"
PREFETCH" 32(%3, %%"REG_a") \n\t"
"movq (%2, %%"REG_a"), %%mm0 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq (%3, %%"REG_a"), %%mm1 \n\t"
"punpcklbw %%mm1, %%mm0 \n\t"
"punpckhbw %%mm1, %%mm2 \n\t"
"movq (%1, %%"REG_a",2), %%mm3 \n\t"
"movq 8(%1, %%"REG_a",2), %%mm5 \n\t"
"movq %%mm0, %%mm4 \n\t"
"movq %%mm2, %%mm6 \n\t"
"punpcklbw %%mm3, %%mm0 \n\t"
"punpckhbw %%mm3, %%mm4 \n\t"
"punpcklbw %%mm5, %%mm2 \n\t"
"punpckhbw %%mm5, %%mm6 \n\t"
MOVNTQ" %%mm0, (%0, %%"REG_a", 4)\n\t"
MOVNTQ" %%mm4, 8(%0, %%"REG_a", 4)\n\t"
MOVNTQ" %%mm2, 16(%0, %%"REG_a", 4)\n\t"
MOVNTQ" %%mm6, 24(%0, %%"REG_a", 4)\n\t"
"add $8, %%"REG_a" \n\t"
"cmp %4, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dst), "r"(ysrc), "r"(usrc), "r"(vsrc), "g" ((long)chromWidth)
: "%"REG_a
);
#else
#if __WORDSIZE >= 64
int i;
uint64_t *ldst = (uint64_t *) dst;
const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
for(i = 0; i < chromWidth; i += 2){
uint64_t k, l;
k = uc[0] + (yc[0] << 8) +
(vc[0] << 16) + (yc[1] << 24);
l = uc[1] + (yc[2] << 8) +
(vc[1] << 16) + (yc[3] << 24);
*ldst++ = k + (l << 32);
yc += 4;
uc += 2;
vc += 2;
}
#else
int i, *idst = (int32_t *) dst;
const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
for(i = 0; i < chromWidth; i++){
#ifdef WORDS_BIGENDIAN
*idst++ = (uc[0] << 24)+ (yc[0] << 16) +
(vc[0] << 8) + (yc[1] << 0);
#else
*idst++ = uc[0] + (yc[0] << 8) +
(vc[0] << 16) + (yc[1] << 24);
#endif
yc += 2;
uc++;
vc++;
}
#endif
#endif
if((y&(vertLumPerChroma-1))==(vertLumPerChroma-1) )
{
usrc += chromStride;
vsrc += chromStride;
}
ysrc += lumStride;
dst += dstStride;
}
#ifdef HAVE_MMX
asm( EMMS" \n\t"
SFENCE" \n\t"
:::"memory");
#endif
}
| 1threat
|
static void smc91c111_cleanup(NetClientState *nc)
{
smc91c111_state *s = qemu_get_nic_opaque(nc);
s->nic = NULL;
}
| 1threat
|
def division_elements(test_tup1, test_tup2):
res = tuple(ele1 // ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
return (res)
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.