problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
PHP: Update variable when link is clicked : <p>I would like to update a variable when a html hyperlinked text is clicked.
Was wondering how I should approach this.</p>
<p>I have two seperate page options, a and b.</p>
<p>I would like to have "You are using A, CLICK HERE to change to B"
If they click, the global variable $option would update to == B.</p>
<p>Is this possible to do without the use of Javascript?</p>
| 0debug |
How to implement pagination for Ruby Hash? : I am working on a Ruby and Rails application and need to implement pagination for the below hash. Need to show the rooms floor wise with pagination.
Hash = { floor_1 : [101,102,103], floor_2: [201,203,204], floor_3: [301,302,303] }
is there any idea how can we do that?
I am using will pagination gem and its not working. | 0debug |
Why does finally() not work after catching on an Observable in Angular 2? : <p>I am trying to add a loading spinner to every request that ends in Angular 2, so I extended the Http service calling it HttpService. After every request I would like to call a finally() function after catching errors so that I can stop the loading spinner.</p>
<p>But typescript says: </p>
<blockquote>
<p>[ts] Property 'finally' does not exist on type 'Observable'.</p>
</blockquote>
<pre><code>import { AuthService } from './../../auth/auth.service';
import { Injectable } from '@angular/core';
import { Http, XHRBackend, RequestOptions, RequestOptionsArgs, Request, Response, Headers } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
import 'rxjs/add/observable/throw';
@Injectable()
export class HttpService extends Http {
constructor(
backend: XHRBackend,
options: RequestOptions,
private authservice: AuthService
) {
super(backend, options);
this.updateHeaders(options.headers);
}
request(url: string|Request, options?: RequestOptionsArgs): Observable<Response> {
return super.request(url, options)
.catch((response: Response) => this.authError(response))
.finally(() => {
// ...
/* Do something here when request is done. For example
finish a spinning loader. */
});
}
private authError(response: Response) {
if (response.status === 401 || response.status === 403) {
this.authservice.logout();
}
return Observable.throw(response);
}
private updateHeaders(headers: Headers) {
headers.set('Content-Type', 'application/json');
if (this.authservice.isloggedIn()) {
headers.set('Authorization', `Bearer ${this.authservice.getToken()}`);
}
}
}
</code></pre>
<p>How can I run some code after every http request like this? What is the best way of doing it?</p>
| 0debug |
Visual Studio Code - Java Classpath is incomplete. Only syntax errors will be reported : <p>I am making my first steps with java, after some extensive experiences with python. The script I am running is a simple Java Swing Gui, that compiles and runs fine from the command line and within VS Code. </p>
<p>To set up the java debug environment, I used the lauch.json settings suggested on the github site <a href="https://github.com/k--kato/vscode-javadebug" rel="noreferrer">https://github.com/k--kato/vscode-javadebug</a>. </p>
<p>Unfortunately, every time I open the folder that contains the script, I get the following error message: </p>
<pre><code>Warn: Classpath is incomplete. Only syntax errors will be reported.
</code></pre>
<p>I have no idea if the problem comes from within VS Code, of if it's some other configuration issue, such as the java set up....</p>
<p>My working platform is Linux Ubuntu, Gnome Shell. </p>
<p>Can anybody help? </p>
<p>This is the script: </p>
<pre><code>//file name = SimpleEx.java
import java.awt.EventQueue;
import javax.swing.JFrame;
public class SimpleEx extends JFrame {
public SimpleEx() {
initUI();
}
private void initUI() {
setTitle("Simple example");
setSize(300, 200);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[] args) {
EventQueue.invokeLater(() -> {
SimpleEx ex = new SimpleEx();
ex.setVisible(true);
});
}
}
</code></pre>
<p>and this is my launch.json: </p>
<pre><code>{
"version": "0.2.0",
"configurations": [
{
"name": "Java",
"type": "java",
"request": "launch",
"stopOnEntry": true,
"cwd": "${fileDirname}",
"startupClass": "${fileBasename}",
"options": [
"-classpath",
"${fileDirname}"
]
},
{
"name": "Java Console App",
"type": "java",
"request": "launch",
"stopOnEntry": true,
"cwd": "${fileDirname}",
"startupClass": "${fileBasename}",
"options": [
"-classpath",
"${fileDirname}"
],
"externalConsole": true
}
]
}
</code></pre>
| 0debug |
QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func,
void *opaque)
{
QEMUPutLEDEntry *s;
s = g_malloc0(sizeof(QEMUPutLEDEntry));
s->put_led = func;
s->opaque = opaque;
QTAILQ_INSERT_TAIL(&led_handlers, s, next);
return s;
}
| 1threat |
What is the standard way of creating browser extensions for gmail? : <p>I have come up with various solutions like using inboxSDK or using gmail.js plugin. But are these the standard way of creating gmail extensions? Is there any another way? Can we use these plugins for production usage?</p>
| 0debug |
void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
int flags)
{
#define RGPL 4
#define RFPL 4
PowerPCCPU *cpu = POWERPC_CPU(cs);
CPUPPCState *env = &cpu->env;
int i;
cpu_fprintf(f, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR "
TARGET_FMT_lx " XER " TARGET_FMT_lx " CPU#%d\n",
env->nip, env->lr, env->ctr, cpu_read_xer(env),
cs->cpu_index);
cpu_fprintf(f, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " HF "
TARGET_FMT_lx " iidx %d didx %d\n",
env->msr, env->spr[SPR_HID0],
env->hflags, env->immu_idx, env->dmmu_idx);
#if !defined(NO_TIMER_DUMP)
cpu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64
#if !defined(CONFIG_USER_ONLY)
" DECR %08" PRIu32
"\n",
cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env)
#if !defined(CONFIG_USER_ONLY)
, cpu_ppc_load_decr(env)
);
for (i = 0; i < 32; i++) {
if ((i & (RGPL - 1)) == 0)
cpu_fprintf(f, "GPR%02d", i);
cpu_fprintf(f, " %016" PRIx64, ppc_dump_gpr(env, i));
if ((i & (RGPL - 1)) == (RGPL - 1))
cpu_fprintf(f, "\n");
cpu_fprintf(f, "CR ");
for (i = 0; i < 8; i++)
cpu_fprintf(f, "%01x", env->crf[i]);
cpu_fprintf(f, " [");
for (i = 0; i < 8; i++) {
char a = '-';
if (env->crf[i] & 0x08)
a = 'L';
else if (env->crf[i] & 0x04)
a = 'G';
else if (env->crf[i] & 0x02)
a = 'E';
cpu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' ');
cpu_fprintf(f, " ] RES " TARGET_FMT_lx "\n",
env->reserve_addr);
for (i = 0; i < 32; i++) {
if ((i & (RFPL - 1)) == 0)
cpu_fprintf(f, "FPR%02d", i);
cpu_fprintf(f, " %016" PRIx64, *((uint64_t *)&env->fpr[i]));
if ((i & (RFPL - 1)) == (RFPL - 1))
cpu_fprintf(f, "\n");
cpu_fprintf(f, "FPSCR " TARGET_FMT_lx "\n", env->fpscr);
#if !defined(CONFIG_USER_ONLY)
cpu_fprintf(f, " SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FMT_lx
" PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_lx "\n",
env->spr[SPR_SRR0], env->spr[SPR_SRR1],
env->spr[SPR_PVR], env->spr[SPR_VRSAVE]);
cpu_fprintf(f, "SPRG0 " TARGET_FMT_lx " SPRG1 " TARGET_FMT_lx
" SPRG2 " TARGET_FMT_lx " SPRG3 " TARGET_FMT_lx "\n",
env->spr[SPR_SPRG0], env->spr[SPR_SPRG1],
env->spr[SPR_SPRG2], env->spr[SPR_SPRG3]);
cpu_fprintf(f, "SPRG4 " TARGET_FMT_lx " SPRG5 " TARGET_FMT_lx
" SPRG6 " TARGET_FMT_lx " SPRG7 " TARGET_FMT_lx "\n",
env->spr[SPR_SPRG4], env->spr[SPR_SPRG5],
env->spr[SPR_SPRG6], env->spr[SPR_SPRG7]);
if (env->excp_model == POWERPC_EXCP_BOOKE) {
cpu_fprintf(f, "CSRR0 " TARGET_FMT_lx " CSRR1 " TARGET_FMT_lx
" MCSRR0 " TARGET_FMT_lx " MCSRR1 " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1],
env->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1]);
cpu_fprintf(f, " TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx
" ESR " TARGET_FMT_lx " DEAR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_TCR], env->spr[SPR_BOOKE_TSR],
env->spr[SPR_BOOKE_ESR], env->spr[SPR_BOOKE_DEAR]);
cpu_fprintf(f, " PIR " TARGET_FMT_lx " DECAR " TARGET_FMT_lx
" IVPR " TARGET_FMT_lx " EPCR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_PIR], env->spr[SPR_BOOKE_DECAR],
env->spr[SPR_BOOKE_IVPR], env->spr[SPR_BOOKE_EPCR]);
cpu_fprintf(f, " MCSR " TARGET_FMT_lx " SPRG8 " TARGET_FMT_lx
" EPR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MCSR], env->spr[SPR_BOOKE_SPRG8],
env->spr[SPR_BOOKE_EPR]);
cpu_fprintf(f, " MCAR " TARGET_FMT_lx " PID1 " TARGET_FMT_lx
" PID2 " TARGET_FMT_lx " SVR " TARGET_FMT_lx "\n",
env->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1],
env->spr[SPR_BOOKE_PID2], env->spr[SPR_E500_SVR]);
if (env->flags & POWERPC_FLAG_CFAR) {
cpu_fprintf(f, " CFAR " TARGET_FMT_lx"\n", env->cfar);
switch (env->mmu_model) {
case POWERPC_MMU_32B:
case POWERPC_MMU_601:
case POWERPC_MMU_SOFT_6xx:
case POWERPC_MMU_SOFT_74xx:
case POWERPC_MMU_64B:
case POWERPC_MMU_2_03:
case POWERPC_MMU_2_06:
case POWERPC_MMU_2_06a:
case POWERPC_MMU_2_07:
case POWERPC_MMU_2_07a:
cpu_fprintf(f, " SDR1 " TARGET_FMT_lx " DAR " TARGET_FMT_lx
" DSISR " TARGET_FMT_lx "\n", env->spr[SPR_SDR1],
env->spr[SPR_DAR], env->spr[SPR_DSISR]);
break;
case POWERPC_MMU_BOOKE206:
cpu_fprintf(f, " MAS0 " TARGET_FMT_lx " MAS1 " TARGET_FMT_lx
" MAS2 " TARGET_FMT_lx " MAS3 " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MAS0], env->spr[SPR_BOOKE_MAS1],
env->spr[SPR_BOOKE_MAS2], env->spr[SPR_BOOKE_MAS3]);
cpu_fprintf(f, " MAS4 " TARGET_FMT_lx " MAS6 " TARGET_FMT_lx
" MAS7 " TARGET_FMT_lx " PID " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MAS4], env->spr[SPR_BOOKE_MAS6],
env->spr[SPR_BOOKE_MAS7], env->spr[SPR_BOOKE_PID]);
cpu_fprintf(f, "MMUCFG " TARGET_FMT_lx " TLB0CFG " TARGET_FMT_lx
" TLB1CFG " TARGET_FMT_lx "\n",
env->spr[SPR_MMUCFG], env->spr[SPR_BOOKE_TLB0CFG],
env->spr[SPR_BOOKE_TLB1CFG]);
break;
default:
break;
#undef RGPL
#undef RFPL
| 1threat |
def is_odd(n) :
if (n^1 == n-1) :
return True;
else :
return False; | 0debug |
static int http_open_cnx(URLContext *h)
{
const char *path, *proxy_path, *lower_proto = "tcp", *local_path;
char hostname[1024], hoststr[1024], proto[10];
char auth[1024], proxyauth[1024];
char path1[1024];
char buf[1024], urlbuf[1024];
int port, use_proxy, err, location_changed = 0, redirects = 0;
HTTPAuthType cur_auth_type, cur_proxy_auth_type;
HTTPContext *s = h->priv_data;
URLContext *hd = NULL;
proxy_path = getenv("http_proxy");
use_proxy = (proxy_path != NULL) && !getenv("no_proxy") &&
av_strstart(proxy_path, "http:
redo:
av_url_split(proto, sizeof(proto), auth, sizeof(auth),
hostname, sizeof(hostname), &port,
path1, sizeof(path1), s->location);
ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL);
if (!strcmp(proto, "https")) {
lower_proto = "tls";
use_proxy = 0;
if (port < 0)
port = 443;
}
if (port < 0)
port = 80;
if (path1[0] == '\0')
path = "/";
else
path = path1;
local_path = path;
if (use_proxy) {
ff_url_join(urlbuf, sizeof(urlbuf), proto, NULL, hostname, port, "%s",
path1);
path = urlbuf;
av_url_split(NULL, 0, proxyauth, sizeof(proxyauth),
hostname, sizeof(hostname), &port, NULL, 0, proxy_path);
}
ff_url_join(buf, sizeof(buf), lower_proto, NULL, hostname, port, NULL);
err = ffurl_open(&hd, buf, AVIO_FLAG_READ_WRITE,
&h->interrupt_callback, NULL);
if (err < 0)
goto fail;
s->hd = hd;
cur_auth_type = s->auth_state.auth_type;
cur_proxy_auth_type = s->auth_state.auth_type;
if (http_connect(h, path, local_path, hoststr, auth, proxyauth, &location_changed) < 0)
goto fail;
if (s->http_code == 401) {
if (cur_auth_type == HTTP_AUTH_NONE && s->auth_state.auth_type != HTTP_AUTH_NONE) {
ffurl_close(hd);
goto redo;
} else
goto fail;
}
if (s->http_code == 407) {
if (cur_proxy_auth_type == HTTP_AUTH_NONE &&
s->proxy_auth_state.auth_type != HTTP_AUTH_NONE) {
ffurl_close(hd);
goto redo;
} else
goto fail;
}
if ((s->http_code == 301 || s->http_code == 302 || s->http_code == 303 || s->http_code == 307)
&& location_changed == 1) {
ffurl_close(hd);
if (redirects++ >= MAX_REDIRECTS)
return AVERROR(EIO);
location_changed = 0;
goto redo;
}
return 0;
fail:
if (hd)
ffurl_close(hd);
s->hd = NULL;
return AVERROR(EIO);
}
| 1threat |
What's the difference between plugins and extends in eslint? : <p>I don't understand why we have plugins and extends. What is the difference between them and do I need one or the other? </p>
| 0debug |
Maximum number of thread Android : <p>I want to know if there is a maximum number of threads that it is possible to run on an Android device. It depends on the type of the device?</p>
| 0debug |
NVidia drivers not running on AWS after restarting the AMI : <p>everybody, I have the following problem:</p>
<p>I started a P2 instance with this <a href="https://aws.amazon.com/marketplace/pp/B00FYCDDTE" rel="noreferrer">AMI</a>. I installed some tools like screen, torch, etc. Then I successfully run some experiments using GPU and I created an image of the instance, so that I can terminate it and run it again later.</p>
<p>Later I started a new instance from the AMI I created before. Everything looked fine - screen, torch, my experiments were present on the system, but I couldn't run the same experiments as before:</p>
<blockquote>
<p>NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA
driver. Make sure that the latest NVIDIA driver is installed and
running.</p>
</blockquote>
<p>To me it looks like the drivers might be installed (because all other tools are installed from before), but they are not running. Is it a correct assumption? How can I start them?</p>
| 0debug |
Can't call datepicker in my laravel framework : I try to use jquery in my laravel framework but i can't call date picker in
label cus_birthday. What i miss ?
[Mycode][1]
[1]: https://i.stack.imgur.com/6UfcG.png | 0debug |
Welcome..i got an issue with OnClickListener : Welcome..
I got an issue with SetOnClickListener in mine mobile kotlin app on AndroidStudio.
I created menu with this tutorial https://www.youtube.com/watch?v=sZWMPYIkNd8
Its ok..works fine on HAXM emulator but i can't manage to make mine button interactive..Tutorial guide tells me to initialize Button with SetOnClickListener but android studio keeps asking me for more arguments and editors displays: "not-enough-information-to-infer-parameter-t-with-kotlin-and-android" which makes me stuck..
I'm learning this language but resolving this problem is kinda out of mine range...what i need to know to properly implement OnClickListener?
Guy on YT video doesnt put any extra phrase in brackets..so what i should do?
Thanks for any research effort
Peace | 0debug |
static void v9fs_lock(void *opaque)
{
int8_t status;
V9fsFlock *flock;
size_t offset = 7;
struct stat stbuf;
V9fsFidState *fidp;
int32_t fid, err = 0;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
flock = g_malloc(sizeof(*flock));
pdu_unmarshal(pdu, offset, "dbdqqds", &fid, &flock->type,
&flock->flags, &flock->start, &flock->length,
&flock->proc_id, &flock->client_id);
trace_v9fs_lock(pdu->tag, pdu->id, fid,
flock->type, flock->start, flock->length);
status = P9_LOCK_ERROR;
if (flock->flags & ~P9_LOCK_FLAGS_BLOCK) {
err = -EINVAL;
goto out_nofid;
}
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -ENOENT;
goto out_nofid;
}
err = v9fs_co_fstat(pdu, fidp, &stbuf);
if (err < 0) {
goto out;
}
status = P9_LOCK_SUCCESS;
out:
put_fid(pdu, fidp);
out_nofid:
err = offset;
err += pdu_marshal(pdu, offset, "b", status);
trace_v9fs_lock_return(pdu->tag, pdu->id, status);
complete_pdu(s, pdu, err);
v9fs_string_free(&flock->client_id);
g_free(flock);
}
| 1threat |
Coded UI Test cases code Generation : <p>I Have a desktop Application in which I have 200 Test cases with different input parameters</p>
<p>Now the issue is Every time I am recording the Each and every test case with different input parameters</p>
<p>Is there is any way so that I can copy the code and change the parameters so that my code remains same for all the test cases only input parameters change </p>
| 0debug |
static void device_finalize(Object *obj)
{
DeviceState *dev = DEVICE(obj);
BusState *bus;
DeviceClass *dc = DEVICE_GET_CLASS(dev);
if (dev->realized) {
while (dev->num_child_bus) {
bus = QLIST_FIRST(&dev->child_bus);
qbus_free(bus);
}
if (qdev_get_vmsd(dev)) {
vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
}
if (dc->exit) {
dc->exit(dev);
}
if (dev->opts) {
qemu_opts_del(dev->opts);
}
}
}
| 1threat |
Python transpose data set : <p>Looking for a python script to do this. The below only is only a sample and values are for CPU consumption in seconds.</p>
<pre><code>I have a CSV in the format:
col1 col2 col3 col4 Apr2018 May2018 June2018 July 2018
-----------------------------------------------------------------
Job1 ABD dt.com BU1 45087 67547 876465 987564
Job2 ACS pl.com BU2 94768 87658 987689 97678
Now I want to be able to get like this in a dataframe/ Table
col1 col2 col3 col4 Date Value
---------------------------------------------
Job1 ABD dt.com BU1 Apr2018 45087
Job1 ABD dt.com BU1 May2018 67547
Job1 ABD dt.com BU1 June2018 876465
Job1 ABD dt.com BU1 July2018 987564
Job2 ACS pl.com BU2 Apr2018 94768
Job2 ACS pl.com BU2 May2018 87658
Job2 ACS pl.com BU2 June2018 987689
Job2 ACS pl.com BU2 July2018 97678
</code></pre>
| 0debug |
START_TEST(qdict_haskey_not_test)
{
fail_unless(qdict_haskey(tests_dict, "test") == 0);
}
| 1threat |
Syntax Error in MySQL Script for user table : <p>Seems like every now and then I am having my troubles with MySQL. Can you help me with finding the error in this script? Thank you very much. I can't see it unfortunately.</p>
<pre><code>Create table `User` (
id int not null,
lastname VARCHAR(50) not null,
firstname VARCHAR (50) not null,
email VARCHAR(100) not null,
password VARCHAR not null,
registered TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
active bit not null
constraint pk_UserId Primary Key(`id`)
);
</code></pre>
| 0debug |
How to show Icon in Text widget in flutter? : <p>I want to show an icon in text widget. How do I do this ? </p>
<p>The following code only shows the <code>IconData</code></p>
<pre><code>Text("Click ${Icons.add} to add");
</code></pre>
| 0debug |
db.execute('SELECT * FROM employees WHERE id = ' + user_input) | 1threat |
Gitkraken Desktop App - Error login: "Please log in to continue" : <p>Who has been working with client GitKraken as GIT, you will know that authentication required?</p>
<p>For the application, log in with: <strong>firstemail@outlook.com</strong></p>
<p>The repository is with: <strong>businessemail@bussiness.com</strong></p>
<p>It requires credentials to make a pull, but I tried with both emails and usernames, and does not allow me.</p>
<p>Capture:
<a href="https://i.stack.imgur.com/4lWG5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4lWG5.png" alt="enter image description here"></a></p>
<p>In <strong><em>SourceTree</em></strong> it works perfectly, but here not!.
Thanked fully!.</p>
| 0debug |
How to change size of mat-icon on Angular Material? : <p>mat-icon tag of Angular Material always has default size is 24px. So how to change it ...???</p>
<pre><code>.mat-icon {
background-repeat: no-repeat;
display: inline-block;
fill: currentColor;
height: 24px;
width: 24px;
}
</code></pre>
| 0debug |
RegEx to replace a string inside a string in Visual Studio 2015 search : <p>I've got the following string all over my code:</p>
<pre><code>languageService.getString("string_from_key");
</code></pre>
<p>Now I want to replace <code>"string_from_key"</code> (with the quotation marks) with <code>KeyClass.string_from_key</code>.</p>
<p>I am struggling with the RegEx in Visual Studio 2015 to search and replace the mentioned strings all over the code. <code>string_from_key</code> is a changing value, thats why RegEx. Thanks in advance.</p>
| 0debug |
Revese loop for a date in PHP : <p>Having 2 dates (from, to) such as 10/1/2019 and 21/2/2019 how would it be possible to write a loop to print each and every date from the 21st Feb back to the 10th of Jan in reverse order?</p>
<p>Sorry for the dumb question but cannot figure it out!</p>
| 0debug |
I want to write a function that takes 2 strings and returns True if they are anagrams(any word that have the same letters in different order) : <p>I have tried this, i want the program to compare every letter in S1 with every letter in S2, any ideas?</p>
<pre><code>s1= "Army"
s2= "Mary"
def anagram(S1,S2):
q=0
w=0
S1.lower()
S2.lower()
for i in S1:
if S1[q]==S2[w]:
print S1[q]
else:
q+=1
w+=1
anagram(s1,s2)
</code></pre>
| 0debug |
How to generate offline Swagger API docs? : <p>I have a spring boot MVC java Web app. I've been able to integrate Springfox for API documentation. I can visually see all of the APIs when server is up and running. </p>
<p>How can I generate OFFLINE swagger API documentation? Note: I would not like to use asciidoc or markdown documentation, but I'd like the same swagger API user interface in html files. I'd like so that the links are relative to local directory instead of local host server links. Thanks</p>
| 0debug |
Errors in command-line for running java programs : Not sure how to really ask this question because there's a lot going on, hence why the tags are all over the place, but basically the situation is:
I have a java program completed, but the way that my professor is going to check to make sure that the program is working correctly is through CMD using the command "java Caesar input.txt output.txt" very simple, I know. But the issues that I am running into are that when I compile using "javac Caesar.java" it will compile and create a Caesar.class file in the folder, but when I try run it as "java caesar input.txt output.txt" it says Error: Could not find or load main class caesar. What am I doing wrong here? I can provide additional information as needed. | 0debug |
Wrong output from dictionary in C# : <p>Why do I get output of my namespace.object when printing from dictionary?</p>
<p>This is my data object.</p>
<pre><code>namespace MoleCalculator
{
public class elementDO
{
public int AtomicNumber { get; set; }
public string Symbol { get; set; }
public string Name { get; set; }
public decimal AtomicWeight { get; set; }
}
}
</code></pre>
<p>This is the class that has my dictionary</p>
<pre><code>namespace MoleCalculator
{
public class elementDictionary
{
public Dictionary<int, elementDO> periodic_Table = new Dictionary<int, elementDO>()
{
{1,new elementDO{AtomicNumber = 1,Symbol = "H",Name = "Hydrogen", AtomicWeight = 1.007825M}},
</code></pre>
<p>This is what drives it</p>
<pre><code>var elements = new elementDictionary().periodic_Table;
Console.WriteLine(elements[1]);
</code></pre>
| 0debug |
How can two similar mapView functions exist in a ViewController? : Within the ViewController class, I have two mapview functions:
The first mapView function handles overlays (like lines, shapes on a map, etc.)
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer
and the second mapView function handles annotations and pins on the map
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?
Coming from a C/Python background, I do not understand how you can have two functions that are named the same, and they do not overwrite one another. What's the idea behind this process? | 0debug |
static void FUNCC(pred8x16_vertical_add)(uint8_t *pix, const int *block_offset,
const int16_t *block, ptrdiff_t stride)
{
int i;
for(i=0; i<4; i++)
FUNCC(pred4x4_vertical_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
for(i=4; i<8; i++)
FUNCC(pred4x4_vertical_add)(pix + block_offset[i+4], block + i*16*sizeof(pixel), stride);
}
| 1threat |
void helper_float_check_status (void)
{
#ifdef CONFIG_SOFTFLOAT
if (env->exception_index == POWERPC_EXCP_PROGRAM &&
(env->error_code & POWERPC_EXCP_FP)) {
if (msr_fe0 != 0 || msr_fe1 != 0)
helper_raise_exception_err(env->exception_index, env->error_code);
} else {
int status = get_float_exception_flags(&env->fp_status);
if (status & float_flag_overflow) {
float_overflow_excp();
} else if (status & float_flag_underflow) {
float_underflow_excp();
} else if (status & float_flag_inexact) {
float_inexact_excp();
}
}
#else
if (env->exception_index == POWERPC_EXCP_PROGRAM &&
(env->error_code & POWERPC_EXCP_FP)) {
if (msr_fe0 != 0 || msr_fe1 != 0)
helper_raise_exception_err(env->exception_index, env->error_code);
}
#endif
}
| 1threat |
Java - IF condition not reading entered String variable value : <pre><code>import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
String play = "y";
System.out.print("Enter something: ");
play = scan.next();
System.out.println(play);
if (play == "Y" || play == "y")
{
System.out.println("If test works!!");
}
System.out.println("Did it work???");
}
}
</code></pre>
<p>I assume this has something to do with when I press enter, it's storing that as well. I tried changing String play to a char, but then I get errors from Scanner saying it can't change a String to a char.</p>
| 0debug |
static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
{
struct vmsvga_state_s *s = opaque;
if (s->index >= SVGA_SCRATCH_BASE) {
trace_vmware_scratch_write(s->index, value);
} else if (s->index >= SVGA_PALETTE_BASE) {
trace_vmware_palette_write(s->index, value);
} else {
trace_vmware_value_write(s->index, value);
}
switch (s->index) {
case SVGA_REG_ID:
if (value == SVGA_ID_2 || value == SVGA_ID_1 || value == SVGA_ID_0) {
s->svgaid = value;
}
break;
case SVGA_REG_ENABLE:
s->enable = !!value;
s->invalidated = 1;
s->vga.hw_ops->invalidate(&s->vga);
if (s->enable && s->config) {
vga_dirty_log_stop(&s->vga);
} else {
vga_dirty_log_start(&s->vga);
}
break;
case SVGA_REG_WIDTH:
if (value <= SVGA_MAX_WIDTH) {
s->new_width = value;
s->invalidated = 1;
} else {
printf("%s: Bad width: %i\n", __func__, value);
}
break;
case SVGA_REG_HEIGHT:
if (value <= SVGA_MAX_HEIGHT) {
s->new_height = value;
s->invalidated = 1;
} else {
printf("%s: Bad height: %i\n", __func__, value);
}
break;
case SVGA_REG_BITS_PER_PIXEL:
if (value != 32) {
printf("%s: Bad bits per pixel: %i bits\n", __func__, value);
s->config = 0;
s->invalidated = 1;
}
break;
case SVGA_REG_CONFIG_DONE:
if (value) {
s->fifo = (uint32_t *) s->fifo_ptr;
if ((CMD(min) | CMD(max) | CMD(next_cmd) | CMD(stop)) & 3) {
break;
}
if (CMD(min) < (uint8_t *) s->cmd->fifo - (uint8_t *) s->fifo) {
break;
}
if (CMD(max) > SVGA_FIFO_SIZE) {
break;
}
if (CMD(max) < CMD(min) + 10 * 1024) {
break;
}
vga_dirty_log_stop(&s->vga);
}
s->config = !!value;
break;
case SVGA_REG_SYNC:
s->syncing = 1;
vmsvga_fifo_run(s);
break;
case SVGA_REG_GUEST_ID:
s->guest = value;
#ifdef VERBOSE
if (value >= GUEST_OS_BASE && value < GUEST_OS_BASE +
ARRAY_SIZE(vmsvga_guest_id)) {
printf("%s: guest runs %s.\n", __func__,
vmsvga_guest_id[value - GUEST_OS_BASE]);
}
#endif
break;
case SVGA_REG_CURSOR_ID:
s->cursor.id = value;
break;
case SVGA_REG_CURSOR_X:
s->cursor.x = value;
break;
case SVGA_REG_CURSOR_Y:
s->cursor.y = value;
break;
case SVGA_REG_CURSOR_ON:
s->cursor.on |= (value == SVGA_CURSOR_ON_SHOW);
s->cursor.on &= (value != SVGA_CURSOR_ON_HIDE);
#ifdef HW_MOUSE_ACCEL
if (value <= SVGA_CURSOR_ON_SHOW) {
dpy_mouse_set(s->vga.con, s->cursor.x, s->cursor.y, s->cursor.on);
}
#endif
break;
case SVGA_REG_DEPTH:
case SVGA_REG_MEM_REGS:
case SVGA_REG_NUM_DISPLAYS:
case SVGA_REG_PITCHLOCK:
case SVGA_PALETTE_BASE ... SVGA_PALETTE_END:
break;
default:
if (s->index >= SVGA_SCRATCH_BASE &&
s->index < SVGA_SCRATCH_BASE + s->scratch_size) {
s->scratch[s->index - SVGA_SCRATCH_BASE] = value;
break;
}
printf("%s: Bad register %02x\n", __func__, s->index);
}
}
| 1threat |
Database Query failed error when creating page : I am getting a "Database query failed" error while trying to insert a new row into a table. This table (pages) has a column (subject_id) referencing another table (subjects). I am passing the value of the of the subject_id from the url and it is passed on the form correctly, all the values seem to be passed correctly on the form using php, but i get error while i try to insert the row. The form submits to itself.
select_all_pages_by_subject($sid) is a function that selects all rows (pages) from the current subject (passed from the url). It works fine for the position field.
> I suspect this error is probably a MySQL syntax error somewhere in my
> code, but i just cant seem to figure it out yet. I appreciate some
> help. Thank you.
here is my code:
<div class="body_content">
<?php
$sid = null;
if(isset($_GET["subject"])) {
$sid = $_GET["subject"];
}
?>
<form action="create_page.php" method="post">
Menu Name: <input type="text" name="menu" /> <br>
Position: <select name="position">
<?php
$new_page_query = select_all_pages_by_subject($sid);
$page_count = mysqli_num_rows($new_page_query);
for($count=1; $count<=($page_count + 1); $count++) {
echo "<option value=\"$count\">$count</option>";
}
?>
</select> <br>
Visible:<br>
No <input type="radio" name="visible" value="0" />
Yes <input type="radio" name="visible" value="1" /> <br>
Subject ID: <input type="text" name="subject_id" value="<?php echo $sid; ?>" /> <br>
Content: <br>
<textarea rows="5" cols="40" name="content"></textarea> <br>
<input type="submit" value="Create Page" name="submit" /> <br>
<a href="admin.php">Cancel</a> <br>
</form>
<?php
if(isset($_POST['submit'])) {
$menu_name = $_POST["menu"];
$position = (int) $_POST["position"];
$visible = (int) $_POST["visible"];
$content = $_POST["content"];
$subject_id = (int) $_POST["$sid"];
$insert_query = "INSERT INTO pages (subject_id, menu_name, position, visible, content) VALUES ({$subject_id},'{$menu_name}', {$position}, {$visible}, '{content}') WHERE subject_id = $sid";
$page_insert = mysqli_query($connection, $insert_query);
if($page_insert) {
$_SESSION["message"] = "Page created successfully";
redirect_to("admin.php");
} else {
$_SESSION["message"] = "Page creation failed";
redirect_to("create_page.php?subject=$sid");
}
}
?>
</div> | 0debug |
ffmpeg convert from H.264 (High 4:4:4 Profile) to H.264 (Main Profile) : <p>How can I convert a video from H.264 (High 4:4:4 Profile) to H.264 (Main Profile) using ffmpeg? </p>
<p>I can't do that with this command: <code>ffmpeg -i 1/25359.mp4 -profile:v main out.mp4</code>. </p>
<p>That'd return an error:</p>
<pre><code>...
That'd return an error:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1/25359.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:06.08, start: 0.000000, bitrate: 1059 kb/s
Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 351x297, 1057 kb/s, 12.50 fps, 12.50 tbr, 12800 tbn, 25 tbc (default)
Metadata:
handler_name : VideoHandler
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
x264 [error]: main profile doesn't support 4:4:4
[libx264 @ 0x8fa9640] Error setting profile main.
[libx264 @ 0x8fa9640] Possible profiles: baseline main high high10 high422 high444
Output #0, mp4, to '1/24545.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Stream #0:0(und): Video: h264, none, q=2-31, 128 kb/s, 12.50 fps (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc56.60.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
</code></pre>
| 0debug |
What is Jetifier? : <p>What is Jetifier? For example, to create a new project using the androidx-packaged dependencies, this new project needs to add the following line to the <em>gradle.properties</em> file:</p>
<pre><code>android.enableJetifier=true
</code></pre>
<p>So what does it mean - "enable jetifier"?</p>
| 0debug |
get multiple json object array in single object array in php : I have created json array of result array in php i got following result:
[{"05-10-2018":"Seeing dads differently"},{"05-10-2018":"Extraordinary ordinary Britain"},{"05-10-2018":" Roll up for the Social Science Market!"},{"05-10-2018":"Why do we use it?"},{"05-10-2018":"Extraordinary ordinary Britain"}]
but i want following format of result
{
'12-14-2018' : '<a href="http://google.com" target=_blank>Amet Temporibus ad quod enim dolor doloribus sequi!</a>',
'09-30-2018' : '<a href="http://google.com" target=_blank>Cupiditate blanditiis autem at obcaecati libero laborum.</a>',
'09-22-2018' : '<a href="http://google.com" target=_blank>Quo accusamus itaque esse aliquid error reprehenderit!</a>',
'09-16-2018' : '<a href="http://google.com" target=_blank>Quia magni aperiam nam asperiores animi enim?</a>',
'08-21-2018' : '<a href="http://google.com" target=_blank>Quia quibusdam nemo nobis rerum. Dolorem, ipsa?</a>',
'08-09-2018' : '<a href="http://google.com" target=_blank>At minima unde cum alias maiores corrupti quas.</a>',
'07-23-2018' : '<a href="http://google.com" target=_blank>Blanditiis maiores odio cumque eligendi facilis iure.</a>',
'07-16-2018' : '<a href="http://google.com" target=_blank>Dolorum, iusto quisquam distinctio dolore quo aperiam reiciendis.</a>',
'06-28-2018' : '<a href="http://google.com" target=_blank>Aperiam odio voluptatibus quae sunt unde itaque.</a>',
'06-15-2018' : '<a href="http://google.com" target=_blank>Tempore asperiores et possimus inventore vero ab.</a>',
'06-02-2018' : '<a href="http://google.com" target=_blank>Possimus asperiores perferendis recusandae debitis omnis consectetur aut!</a>',
'05-30-2018' : '<a href="http://google.com" target=_blank>Minus aliquid maxime atque praesentium rerum dolores sint?</a>',
'05-18-2018' : '<a href="http://google.com" target=_blank>Corporis accusantium assumenda facilis fugiat ut nostrum.</a>',
'05-09-2018' : '<a href="http://google.com" target=_blank>Sequi ad sint sunt quasi veniam cum.</a>',};
How i get it?
please help me as soon as possible.
| 0debug |
bool css_schid_final(int m, uint8_t cssid, uint8_t ssid, uint16_t schid)
{
SubchSet *set;
uint8_t real_cssid;
real_cssid = (!m && (cssid == 0)) ? channel_subsys.default_cssid : cssid;
if (real_cssid > MAX_CSSID || ssid > MAX_SSID ||
!channel_subsys.css[real_cssid] ||
!channel_subsys.css[real_cssid]->sch_set[ssid]) {
return true;
}
set = channel_subsys.css[real_cssid]->sch_set[ssid];
return schid > find_last_bit(set->schids_used,
(MAX_SCHID + 1) / sizeof(unsigned long));
}
| 1threat |
meaning less rspec uninitialized constant error : I have a rails app and running on a VPS, the installation steps of Ruby, Rails, and RSpec are identical on my laptop and VPS (followed by the [same instruction][1]).<br />But when I want to test the app using RSpec on the VPS it gives the `uninitialized constant` error (something like [this][2]). the exact clone of the project runs perfectly without any errors on my laptop!<br />
Although the tests are executing on my laptop without any problems, I tried the solutions exist on the web but didn't help me -- even I reinstalled Ruby, Rails, and RSpec on the server!
###Quesions:
1. What is wrong with RSpec?
2. How can I fix this?
[1]: https://gorails.com/setup/ubuntu/18.04
[2]: https://stackoverflow.com/questions/19692297/rspec-testing-throws-uninitialized-constant-rails-nameerror | 0debug |
document.write('<script src="evil.js"></script>'); | 1threat |
Fetch image from API : <p><strong>Q1)</strong> In my reactjs application, I am trying to fetch an API from my backend Nodejs server. The API responds with an image file on request.</p>
<p>I can access and see image file on <a href="http://192.168.22.124:3000/source/592018124023PM-pexels-photo.jpg" rel="noreferrer">http://192.168.22.124:3000/source/592018124023PM-pexels-photo.jpg</a></p>
<p>But in my reactjs client side I get this error on console log.</p>
<blockquote>
<p>Uncaught (in promise) SyntaxError: Unexpected token � in JSON at position 0</p>
</blockquote>
<p><strong>Reactjs:</strong></p>
<pre><code>let fetchURL = 'http://192.168.22.124:3000/source/';
let image = name.map((picName) => {
return picName
})
fetch(fetchURL + image)
.then(response => response.json())
.then(images => console.log(fetchURL + images));
</code></pre>
<p><strong>Nodejs:</strong> </p>
<pre><code>app.get('/source/:fileid', (req, res) => {
const { fileid } = req.params;
res.sendFile(__dirname + /data/ + fileid);
});
</code></pre>
<p><strong>Is there any better way to do than what I am doing above?</strong></p>
<p><strong>Q2)</strong> Also, how can I assign a value to an empty variable (which lives outside the fetch function)<br>
jpg = fetchURL + images;
So I can access it somewhere.</p>
| 0debug |
Angular detect If checkbox is checked from the .ts : <p>I am using Angular 4 and I have a checkbox on my component on the component's html template file:</p>
<pre><code><input type="checkbox" (change)="canBeEditable($event)">
</code></pre>
<p>On my component's .ts file I have this which set's the value to true.</p>
<pre><code>toggleEditable() {
this.contentEditable = true;
}
</code></pre>
<p>My problem is that I only want the value changed IF the checkbox IS checked.</p>
<p>So it would look something like:</p>
<pre><code>toggleEditable() {
if (checkbox is checked) {
this.contentEditable = true;
}
}
</code></pre>
<p>How can I do this?</p>
| 0debug |
static void openrisc_cpu_initfn(Object *obj)
{
CPUState *cs = CPU(obj);
OpenRISCCPU *cpu = OPENRISC_CPU(obj);
static int inited;
cs->env_ptr = &cpu->env;
cpu_exec_init(cs, &error_abort);
#ifndef CONFIG_USER_ONLY
cpu_openrisc_mmu_init(cpu);
#endif
if (tcg_enabled() && !inited) {
inited = 1;
openrisc_translate_init();
}
}
| 1threat |
sql in ms-access : <p>I have a table name customers with two columns, case id and owner. I need to write a query to select random 5 caseids for every name in owner column.please help </p>
| 0debug |
c++: can I use .find function to look for multiple elements in a string : <p>c++: can I use .find function to look for multiple characters in a string
ex: looking for + and - in an array of linear equations </p>
| 0debug |
C# WaitForExit() not working? : <p>I am starting an application with parameteres, and I want to close my C# application after "Startup.exe" closed. After startup.exe closed the C# application still running, so my question is why WaitForExit() not working for me? And how to solve this issue? </p>
<pre><code>private void button4_Click(object sender, EventArgs e)
{
string arg0 = "/connect";
string arg1 = txtUsername.Text;
string arg2 = txtPassword.Text;
string genArgs = arg0+" "+arg1 +" "+ arg2;
string pathToFile = System.IO.Directory.GetCurrentDirectory()+"/Startup.exe";
Process runProg = new Process();
runProg.StartInfo.FileName = pathToFile;
runProg.StartInfo.Arguments = genArgs;
runProg.Start();
runProg.WaitForExit();
}
</code></pre>
| 0debug |
IOS-Charts set maximum visible x axis values : <p>I'm using ios-charts (<a href="https://github.com/danielgindi/Charts" rel="noreferrer">https://github.com/danielgindi/Charts</a>). I have a LineChartView with 12 values in the x axis.
This however is far too many to see at the same time, so I want to display only 5 and then let the user drag to the right to see the next.</p>
<p><a href="https://i.stack.imgur.com/0GzqD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0GzqD.png" alt="enter image description here"></a></p>
<p>I've tried this:</p>
<pre><code> let chart = LineChartView()
chart.dragEnabled = true
chart.setVisibleXRangeMaximum(5)
let xAxis = chart.xAxis
xAxis.axisMinValue = 0
xAxis.axisMaxValue = 5.0
xAxis.setLabelsToSkip(0)
</code></pre>
<p>But still see all 11 values at the time. How can I only see 5?</p>
| 0debug |
Electron and typescript "Cannot find module 'electron'" : <p>Regarding <a href="https://electron.atom.io/blog/2017/06/01/typescript" rel="noreferrer">https://electron.atom.io/blog/2017/06/01/typescript</a>
electron support typescript but is not working on my setup:</p>
<p><a href="https://i.stack.imgur.com/Zhoev.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Zhoev.jpg" alt="[ts] cannot find module 'electron'"></a></p>
<p>I use vscode 1.16.1</p>
<p>Here is my package.json</p>
<pre><code>{
[...]
"devDependencies": {
"electron": "^1.6.13",
"ts-loader": "~2.3.7",
"typescript": "~2.5.0",
"webpack": "^3.6.0",
[...]
}
}
</code></pre>
<p>tsconfig.json</p>
<pre><code>{
"compilerOptions": {
"module": "es6",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true
},
"include": [
"src/**/*"
]
}
</code></pre>
<p>and my webpack</p>
<pre><code>const path = require('path');
module.exports = [{
entry: './src/main.ts',
devtool: 'inline-source-map',
target: 'electron',
module: {
rules: [
{ test: /\.ts$/, use: 'ts-loader', exclude: /node_modules/ }
]
},
node: {
__dirname: false,
__filename: false
},
resolve: {
extensions: [".ts", ".js"]
},
output: {
filename: 'electron_core.js',
path: path.resolve(__dirname, 'dist')
}
}
];
</code></pre>
<p>When I add at the top of my main.ts</p>
<pre><code>///<reference path="../node_modules/electron/electron.d.ts" />
</code></pre>
<p>then is ok I don't have the error anymore. However I would like to avoid referencing files like this as it seems it's useless with the latest version of typescript (see <a href="https://stackoverflow.com/questions/12930049/how-do-i-import-other-typescript-files?answertab=votes#tab-top">How do I import other TypeScript files?</a>) and moreover in the electron tutorial for typescript they don't need it ...)</p>
<p>Thanks</p>
| 0debug |
Increase timeout limit in Google Chrome : <p>Internet speed at work is very limited, and because of this I can't load several useful pages, like Trello, Bitbucket, Slack and so on.</p>
<p>Chrome console shows me a long list timeout errors like <code>GET https://..... net::ERR_TIMED_OUT</code>. </p>
<p>I was wondering if there is any way to change timeout settings in Chrome.</p>
| 0debug |
import re
def text_lowercase_underscore(text):
patterns = '^[a-z]+_[a-z]+$'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!') | 0debug |
Android can not understand how to make fragments in the UI : First of all, even tho i can somehow understand what are the differences between fragments and activities, i can not possibly say what is better to use.
I want to create a simple drawerview. User can select from the options in the drawer menu and the main page changes. AppBar should be present at all changes, as i want the title to be there.
The UI is written in .xml format and i cant figure out how to use that in java files to be called from the mainActivity. I want to use about 4-5 different pages that change on button clicks, inside the main UI format.
I have tried working with fragments form android studio developers section, but no luck. Unfortunatelly it is not the same as JavaFX or Qt which i have some experience on Ui. Also if anyone could explain the logic that i have to follow in order to understand android UI and how to solve these kinds of problems, i would appriciate it. | 0debug |
Deploy VueJS App in a subdirectory : <p>I'm experiencing problems deploying a Vue JS app built using the Webpack CLi to work.</p>
<p>If uploaded in a root directory everything renders fine, but inside a subfolder, all the links break.</p>
<p>I've added a base href:</p>
<pre><code> <base href="/dist/">
</code></pre>
<p>And the scripts load, but all the asset paths created by Webpack are broken, the images and fonts don't load as they are pointing to the root directory.</p>
<p>Can anyone please help?</p>
| 0debug |
static int net_rx_ok(void *opaque)
{
struct XenNetDev *netdev = opaque;
RING_IDX rc, rp;
if (netdev->xendev.be_state != XenbusStateConnected)
return 0;
rc = netdev->rx_ring.req_cons;
rp = netdev->rx_ring.sring->req_prod;
xen_rmb();
if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&netdev->rx_ring, rc)) {
xen_be_printf(&netdev->xendev, 2, "%s: no rx buffers (%d/%d)\n",
__FUNCTION__, rc, rp);
return 0;
}
return 1;
}
| 1threat |
Weird error in python regarding scoping : <pre><code>x = 5
def foobar():
print (x) #Prints global value of x, which is 5
x = 1 #assigns local variable x to 1
foobar()
</code></pre>
<p>Instead, it throws a </p>
<pre><code>UnboundLocalError: local variable 'x' referenced before assignment
</code></pre>
<p>What am I misunderstanding in the comments? Note, I understand if i do x=x+1, it'll throw error due to 'accessing value of local scope x beforei it's defined', but in this case I'm doing x=1, which does not require reading of existing value of x! This is NOT a duplicate question.</p>
| 0debug |
def is_majority(arr, n, x):
i = binary_search(arr, 0, n-1, x)
if i == -1:
return False
if ((i + n//2) <= (n -1)) and arr[i + n//2] == x:
return True
else:
return False
def binary_search(arr, low, high, x):
if high >= low:
mid = (low + high)//2
if (mid == 0 or x > arr[mid-1]) and (arr[mid] == x):
return mid
elif x > arr[mid]:
return binary_search(arr, (mid + 1), high, x)
else:
return binary_search(arr, low, (mid -1), x)
return -1 | 0debug |
Gradle build lintVitalRelease NullPointerException : <p>Updated Android Studio from 3.0 Canary 3 to Beta 2, and the Gradle plugin from Alpha 5 to Beta 2. Debug builds just fine, but when trying to generate a signed APK for a release build type, this error keeps coming up. Have tried deleting the .gradle folder, .idea folder, Invalidate caches & Restart and gradlew clean.</p>
<pre><code>14:16:32.483 [ERROR] [system.err] Note: Recompile with -Xlint:deprecation for details.
14:16:32.483 [ERROR] [system.err] Note: Some input files use unchecked or unsafe operations.
14:16:32.483 [ERROR] [system.err] Note: Recompile with -Xlint:unchecked for details.
14:16:37.434 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:16:37.434 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':app:lintVitalRelease'.
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > java.lang.NullPointerException (no error message)
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:lintVitalRelease'.
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
14:16:37.435 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.lang.NullPointerException
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.scope.BuildOutput.getOutputPath(BuildOutput.java:222)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.scope.BuildOutputs.lambda$load$2(BuildOutputs.java:243)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.scope.BuildOutputs.load(BuildOutputs.java:245)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.scope.BuildOutputs.load(BuildOutputs.java:184)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.scope.BuildOutputs.load(BuildOutputs.java:140)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.ide.BuildOutputsSupplier.lambda$get$1(BuildOutputsSupplier.java:55)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:397)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.ide.BuildOutputsSupplier.get(BuildOutputsSupplier.java:50)
14:16:37.436 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.ide.BuildOutputsSupplier.get(BuildOutputsSupplier.java:35)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.ide.AndroidArtifactImpl.getOutputs(AndroidArtifactImpl.java:135)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.LintGradleProject$AppGradleProject.<init>(LintGradleProject.java:206)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.LintGradleProject$AppGradleProject.<init>(LintGradleProject.java:192)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.LintGradleProject$ProjectSearch.getProject(LintGradleProject.java:949)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.LintGradleProject$ProjectSearch.getProject(LintGradleProject.java:785)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.LintGradleClient.createLintRequest(LintGradleClient.java:193)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.tools.lint.LintCliClient.run(LintCliClient.java:151)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.internal.LintGradleClient.run(LintGradleClient.java:209)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.tasks.Lint.runLint(Lint.java:359)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.tasks.Lint.lintSingleVariant(Lint.java:329)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.build.gradle.tasks.Lint.lint(Lint.java:134)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:141)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:731)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:705)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] ... 27 more
14:16:37.437 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:16:37.438 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:16:37.438 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
14:16:37.438 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger]
14:16:37.438 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 19s
</code></pre>
| 0debug |
static void decode_sigpass(Jpeg2000T1Context *t1, int width, int height,
int bpno, int bandno, int bpass_csty_symbol,
int vert_causal_ctx_csty_symbol)
{
int mask = 3 << (bpno - 1), y0, x, y;
for (y0 = 0; y0 < height; y0 += 4)
for (x = 0; x < width; x++)
for (y = y0; y < height && y < y0 + 4; y++) {
if ((t1->flags[y+1][x+1] & JPEG2000_T1_SIG_NB)
&& !(t1->flags[y+1][x+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS))) {
int flags_mask = -1;
if (vert_causal_ctx_csty_symbol && y == y0 + 3)
flags_mask &= ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE);
if (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ff_jpeg2000_getsigctxno(t1->flags[y+1][x+1] & flags_mask, bandno))) {
int xorbit, ctxno = ff_jpeg2000_getsgnctxno(t1->flags[y+1][x+1], &xorbit);
if (bpass_csty_symbol)
t1->data[y][x] = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ? -mask : mask;
else
t1->data[y][x] = (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ^ xorbit) ?
-mask : mask;
ff_jpeg2000_set_significance(t1, x, y,
t1->data[y][x] < 0);
}
t1->flags[y + 1][x + 1] |= JPEG2000_T1_VIS;
}
}
}
| 1threat |
static void spapr_machine_reset(void)
{
MachineState *machine = MACHINE(qdev_get_machine());
sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
PowerPCCPU *first_ppc_cpu;
uint32_t rtas_limit;
hwaddr rtas_addr, fdt_addr;
void *fdt;
int rc;
foreach_dynamic_sysbus_device(find_unknown_sysbus_device, NULL);
first_ppc_cpu = POWERPC_CPU(first_cpu);
if (kvm_enabled() && kvmppc_has_cap_mmu_radix() &&
ppc_check_compat(first_ppc_cpu, CPU_POWERPC_LOGICAL_3_00, 0,
spapr->max_compat_pvr)) {
spapr->patb_entry = PATBE1_GR;
} else {
spapr_setup_hpt_and_vrma(spapr);
}
qemu_devices_reset();
object_child_foreach_recursive(object_get_root(), spapr_reset_drcs, NULL);
spapr_clear_pending_events(spapr);
rtas_limit = MIN(spapr->rma_size, RTAS_MAX_ADDR);
rtas_addr = rtas_limit - RTAS_MAX_SIZE;
fdt_addr = rtas_addr - FDT_MAX_SIZE;
if (!spapr->cas_reboot) {
spapr_ovec_cleanup(spapr->ov5_cas);
spapr->ov5_cas = spapr_ovec_new();
ppc_set_compat(first_ppc_cpu, spapr->max_compat_pvr, &error_fatal);
}
fdt = spapr_build_fdt(spapr, rtas_addr, spapr->rtas_size);
spapr_load_rtas(spapr, fdt, rtas_addr);
rc = fdt_pack(fdt);
assert(rc == 0);
if (fdt_totalsize(fdt) > FDT_MAX_SIZE) {
error_report("FDT too big ! 0x%x bytes (max is 0x%x)",
fdt_totalsize(fdt), FDT_MAX_SIZE);
exit(1);
}
qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt));
cpu_physical_memory_write(fdt_addr, fdt, fdt_totalsize(fdt));
g_free(fdt);
first_ppc_cpu->env.gpr[3] = fdt_addr;
first_ppc_cpu->env.gpr[5] = 0;
first_cpu->halted = 0;
first_ppc_cpu->env.nip = SPAPR_ENTRY_POINT;
spapr->cas_reboot = false;
} | 1threat |
Why do I hot nan? : Simple python code
def m(x,y):
x=2
y=[3,5]
a=1
b=[0,26]
print m(a,b)
I want to change the arguments,if it is possible without return.When I run my code
python d1.py
None
Why?
| 0debug |
How to define as Save As Function in Python : <p>hello I have below code like this, I would like to do save as same name but add a Tag New to same file name so save it as new_TBM. Any help is appreciated.</p>
<pre><code>import sys
from tableaudocumentapi import Workbook
sourceWB = Workbook('C:\\Users\\rmakkena\\Music\\TBM.twb')
sourceWB.datasources[0].connections[0].server = "MY-NEW-SERVER"
sourceWB.datasources[0].connections[0].dbname = "NEW-DATABASE"
sourceWB.datasources[0].connections[0].username = "rithesh"
sourceWB.save_as()
</code></pre>
| 0debug |
static void hax_process_section(MemoryRegionSection *section, uint8_t flags)
{
MemoryRegion *mr = section->mr;
hwaddr start_pa = section->offset_within_address_space;
ram_addr_t size = int128_get64(section->size);
unsigned int delta;
uint64_t host_va;
if (!memory_region_is_ram(mr)) {
if (memory_region_is_romd(mr)) {
fprintf(stderr, "%s: Warning: Ignoring ROMD region 0x%016" PRIx64
"->0x%016" PRIx64 "\n", __func__, start_pa,
start_pa + size);
}
return;
}
delta = qemu_real_host_page_size - (start_pa & ~qemu_real_host_page_mask);
delta &= ~qemu_real_host_page_mask;
if (delta > size) {
return;
}
start_pa += delta;
size -= delta;
size &= qemu_real_host_page_mask;
if (!size || (start_pa & ~qemu_real_host_page_mask)) {
return;
}
host_va = (uintptr_t)memory_region_get_ram_ptr(mr)
+ section->offset_within_region + delta;
if (memory_region_is_rom(section->mr)) {
flags |= HAX_RAM_INFO_ROM;
}
g_assert(size <= UINT32_MAX);
hax_update_mapping(start_pa, size, host_va, flags);
}
| 1threat |
Mathematical notation or Pseudocode? : <p>At this moment I am concerned about which is the best way to explain an algorithm intuitively.</p>
<p>I have try to read some pseudocode an wow it may be complex for some cases (specially for math applications even more than the formulas itself or pure code like in PHP, C++ or Py). I have thought how about describe algorithms from mathematical notation in a way such that a mathematician could understand it and a web developer too.</p>
<p>Do you think it is a good idea ? (IF all the grammars and structure, symbols and modelings of it will be well explained and it is compact)</p>
<p>Example:
<a href="https://i.stack.imgur.com/IfkyK.png" rel="nofollow noreferrer">Binary Search</a></p>
<p>It even could help to simplify algorithm complexity if a mathematical analysis is done (I think)</p>
| 0debug |
Warning: addcslashes() expects exactly 2 parameters, 1 given in : i have this peace of codes which produce error Warning: addcslashes() expects exactly 2 parameters, 1 given in line 10
$searchtype=isset($_POST['searchtype']) ? $_POST['searchtype']:null;
$searchterm=isset($_POST['searchterm']) ? $_POST['searchtype'] : null;
$searchterm = trim($searchterm);
if(!$searchtype || !$searchterm)
{
echo 'You are not entered search detail. Please go back and try again';
}
if(!get_magic_quotes_gpc())
{
$searchtype = addcslashes($searchtype);//line 10 with error
$searchterm = addcslashes($searchterm);//line with error
}
@ $db = new msqli('localhost','root','','sales');
if(mysqli_connect_errno())
{
echo 'Error: Could not connect to database. Please try again leter.';
exit; | 0debug |
angular 2 this._Router.navigate(['/app/home']); navigates to home page but previous page is still on home page : i can navigate properly with "this._Router.navigate(['/app/home']);" syntax but it keep all the previous page data on home page. | 0debug |
static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
void *opaque, int state, int secstate,
int crm, int opc1, int opc2)
{
uint32_t *key = g_new(uint32_t, 1);
ARMCPRegInfo *r2 = g_memdup(r, sizeof(ARMCPRegInfo));
int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0;
int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0;
r2->secure = secstate;
if (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]) {
r2->fieldoffset = r->bank_fieldoffsets[ns];
}
if (state == ARM_CP_STATE_AA32) {
if (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]) {
if ((r->state == ARM_CP_STATE_BOTH && ns) ||
(arm_feature(&cpu->env, ARM_FEATURE_V8) && !ns)) {
r2->type |= ARM_CP_NO_MIGRATE;
r2->resetfn = arm_cp_reset_ignore;
}
} else if ((secstate != r->secure) && !ns) {
r2->type |= ARM_CP_NO_MIGRATE;
r2->resetfn = arm_cp_reset_ignore;
}
if (r->state == ARM_CP_STATE_BOTH) {
if (r2->cp == 0) {
r2->cp = 15;
}
#ifdef HOST_WORDS_BIGENDIAN
if (r2->fieldoffset) {
r2->fieldoffset += sizeof(uint32_t);
}
#endif
}
}
if (state == ARM_CP_STATE_AA64) {
if (r->cp == 0 || r->state == ARM_CP_STATE_BOTH) {
r2->cp = CP_REG_ARM64_SYSREG_CP;
}
*key = ENCODE_AA64_CP_REG(r2->cp, r2->crn, crm,
r2->opc0, opc1, opc2);
} else {
*key = ENCODE_CP_REG(r2->cp, is64, ns, r2->crn, crm, opc1, opc2);
}
if (opaque) {
r2->opaque = opaque;
}
r2->state = state;
r2->crm = crm;
r2->opc1 = opc1;
r2->opc2 = opc2;
if ((r->type & ARM_CP_SPECIAL) ||
((r->crm == CP_ANY) && crm != 0) ||
((r->opc1 == CP_ANY) && opc1 != 0) ||
((r->opc2 == CP_ANY) && opc2 != 0)) {
r2->type |= ARM_CP_NO_MIGRATE;
}
if (!(r->type & ARM_CP_OVERRIDE)) {
ARMCPRegInfo *oldreg;
oldreg = g_hash_table_lookup(cpu->cp_regs, key);
if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) {
fprintf(stderr, "Register redefined: cp=%d %d bit "
"crn=%d crm=%d opc1=%d opc2=%d, "
"was %s, now %s\n", r2->cp, 32 + 32 * is64,
r2->crn, r2->crm, r2->opc1, r2->opc2,
oldreg->name, r2->name);
g_assert_not_reached();
}
}
g_hash_table_insert(cpu->cp_regs, key, r2);
}
| 1threat |
Safe recursive delete in bash : <p>Is there a way to check if the supplied path either by user input or some self-detect-mechanism safe to be deleted in bash scripting?</p>
<p>For example:</p>
<pre><code>rm -rf $SOMELOCATION
</code></pre>
<p>Obviously I don't want SOMELOCATION to be any of / /var /etc /home /usr /opt /root or some important directories.</p>
<p>Is there a way to prevent such <strong>incident</strong> in bash without iterating all those directory above (and possibly more important directory)?</p>
<p>Is there something like isSystemDirectory function return true or false? :-)</p>
| 0debug |
Editing a String in a .class file : <p><strong>Issue</strong></p>
<p>Hey. I've been developing a game and in the game, I was showing the version "1.0.13", and I quickly realized that it was completely incorrect, and it should display "1.9". I edit my code in Eclipse, and I didn't make backups for my code each version, so I couldn't just edit the String from Eclipse. I tried decompiling the .jar file for the game using a <strong>.jar decompiler</strong>. I downloaded the source code (.java files) and put it into Eclipse Neon. Upon putting the .java files in I realized a few errors appeared. I fixed them and ran the program. Many of the game's mechanics were completely broken. I realized that wasn't going to work, so I extracted the .jar with <strong>WinRAR</strong> and then tried editing the .class file manually (which was a stupid idea) using <strong>Notepad++</strong>. After using their built-in tool I quickly replaced all the "1.0.13"s with "1.9". Upon saving the code and running the .jar file a window appeared with the title "Java Virtual Machine Launcher" and the text "Error": A JNI error has occurred, please check your installation and try again". I then ran across a program named <strong>JBE (Java Bytecode Editor)</strong>. When using the program I was unsure how to edit the constant variables, and I searched for tutorials using the program and found none.</p>
<p>I just want to edit a single String and I've spent hours of research, and I can't even find a solution. If you know how to solve this situation, please comment. Thanks in advance.</p>
<p><strong>Info</strong></p>
<p>Since I "need at least 10 reputation to post more thank 2 links." I'll just post a <a href="http://pastebin.com/A4Jtifcn" rel="nofollow noreferrer">single PasteBin link</a> that you can read that will link to all the websites and programs I have talked about in this post.</p>
| 0debug |
How do i print everything seperetly? what will be the loop? : Make two new dictionaries representing different people, and store all three
dictionaries in a list called people .Loop through your list of people .As you
loop through the list, print everything you know about each person .
person_1 = {'first_name':'shamol',
'last_name': 'kabir',
'age': '25',
'city': 'jessore'}
person_2 = {'first_name':'shorif',
'last_name':'jaman',
'age':'28',
'city':'khulna'}
person_3= {'first_name':'mizan',
'last_name':'rahman',
'age':'25',
'city':'jessore'}
people= [person_1,person_2,person_3]
what will be the next few lines?? | 0debug |
Simple Search System Not Working PHP SQL HTML : <p>So I'm new to SQL, PHP and HTML. I'm trying to create a search system for my database that contains a table for foods and their prices. I've searched everywhere for people who have the same problem as me but none of the solutions seem to help me. </p>
<p>I've searched far and wide over all the forums I could find, loads of tutorials on YouTube yet to no avail.</p>
<p>Main PHP code:</p>
<pre><code><!doctype html>
<html>
<head>
<meta charset = "utf-8">
<title>Lists of foods and prices! Input yours here!</title>
</head>
<body>
<h1>Insert your fav food!</h1>
<table>
<form action = "" method = "post">
<tr>
<td>Food: </td><td><input type="text" name="Food"></td></tr>
<tr>
<td>Price: </td><td><input type="integer" name="Price"></td></tr>
<tr>
<td>Supermarket: </td><td><input type="text" name="Supermarket"></td></tr>
</tr>
<tr>
<td><input type="submit" name = "submit"></td></tr>
</form>
</table>
<table>
<form action = "" method = "post">
<tr>
<td>Search: </td><td><input type="text" name="Search"></td></tr>
<tr>
<td><input type="submit" name = "Search"></td></tr>
</form>
</table>
<?php
if(isset($_POST["submit"])){
include 'dbconfig.php';
include 'New Text Document.js';
$Food = $_POST['Food'];
$Price = $_POST['Price'];
$Supermarket = $_POST['Supermarket'];
mysqli_query($conn,"INSERT INTO costsoffood VALUES('$Food', '$Price', '$Supermarket')");
}
if(isset($_POST["Search"])){
include 'dbconfig.php';
$search = $_POST["Search"];
$query="SELECT * FROM costsoffood WHERE Food LIKE %$search%";
$result=mysqli_query($conn,"SELECT * FROM costsoffood WHERE Food LIKE '%$search%'");
if(mysqli_num_rows($result)>0){
while($row = mysqli_fetch_array($result)){
echo "<tr><td>". $row['food']."</td><td>". $row['price']."</td><td>".$row['supermarket']."</td></tr>";
}
echo "</table>";
}
else{
echo "no results";
}
}
?>
</body>
</html>
</code></pre>
<p>dbconfig.php</p>
<pre><code><?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "dataone";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
</code></pre>
| 0debug |
How can I put image to top right side of image? : Here is my code. I want to put second image on historyIcon image to top right corner. Is it possible?
| 0debug |
static int init_poc(H264Context *h){
MpegEncContext * const s = &h->s;
const int max_frame_num= 1<<h->sps.log2_max_frame_num;
int field_poc[2];
h->frame_num_offset= h->prev_frame_num_offset;
if(h->frame_num < h->prev_frame_num)
h->frame_num_offset += max_frame_num;
if(h->sps.poc_type==0){
const int max_poc_lsb= 1<<h->sps.log2_max_poc_lsb;
if (h->poc_lsb < h->prev_poc_lsb && h->prev_poc_lsb - h->poc_lsb >= max_poc_lsb/2)
h->poc_msb = h->prev_poc_msb + max_poc_lsb;
else if(h->poc_lsb > h->prev_poc_lsb && h->prev_poc_lsb - h->poc_lsb < -max_poc_lsb/2)
h->poc_msb = h->prev_poc_msb - max_poc_lsb;
else
h->poc_msb = h->prev_poc_msb;
field_poc[0] =
field_poc[1] = h->poc_msb + h->poc_lsb;
if(s->picture_structure == PICT_FRAME)
field_poc[1] += h->delta_poc_bottom;
}else if(h->sps.poc_type==1){
int abs_frame_num, expected_delta_per_poc_cycle, expectedpoc;
int i;
if(h->sps.poc_cycle_length != 0)
abs_frame_num = h->frame_num_offset + h->frame_num;
else
abs_frame_num = 0;
if(h->nal_ref_idc==0 && abs_frame_num > 0)
abs_frame_num--;
expected_delta_per_poc_cycle = 0;
for(i=0; i < h->sps.poc_cycle_length; i++)
expected_delta_per_poc_cycle += h->sps.offset_for_ref_frame[ i ];
if(abs_frame_num > 0){
int poc_cycle_cnt = (abs_frame_num - 1) / h->sps.poc_cycle_length;
int frame_num_in_poc_cycle = (abs_frame_num - 1) % h->sps.poc_cycle_length;
expectedpoc = poc_cycle_cnt * expected_delta_per_poc_cycle;
for(i = 0; i <= frame_num_in_poc_cycle; i++)
expectedpoc = expectedpoc + h->sps.offset_for_ref_frame[ i ];
} else
expectedpoc = 0;
if(h->nal_ref_idc == 0)
expectedpoc = expectedpoc + h->sps.offset_for_non_ref_pic;
field_poc[0] = expectedpoc + h->delta_poc[0];
field_poc[1] = field_poc[0] + h->sps.offset_for_top_to_bottom_field;
if(s->picture_structure == PICT_FRAME)
field_poc[1] += h->delta_poc[1];
}else{
int poc= 2*(h->frame_num_offset + h->frame_num);
if(!h->nal_ref_idc)
poc--;
field_poc[0]= poc;
field_poc[1]= poc;
}
if(s->picture_structure != PICT_BOTTOM_FIELD) {
s->current_picture_ptr->field_poc[0]= field_poc[0];
s->current_picture_ptr->poc = field_poc[0];
}
if(s->picture_structure != PICT_TOP_FIELD) {
s->current_picture_ptr->field_poc[1]= field_poc[1];
s->current_picture_ptr->poc = field_poc[1];
}
if(!FIELD_PICTURE || !s->first_field) {
Picture *cur = s->current_picture_ptr;
cur->poc= FFMIN(cur->field_poc[0], cur->field_poc[1]);
}
return 0;
}
| 1threat |
What packages/functions are imported by default in Kotlin? : <p>In Java the <code>java.lang</code> package is imported by default.<br>
In kotlin a number of functions and classes are available without being imported, like <code>println</code> and kotlins <code>Array</code>, <code>Int</code>, etc types.<br>
What else is imported by default and where is it defined?</p>
| 0debug |
why new Date("Tue Apr 08 2008 00:00:00 GMT+0530").getMonth() is returning 3 : <pre><code>new Date("Tue Apr 08 2008 00:00:00 GMT+0530").getMonth() returns 3?
</code></pre>
<p>Why does this datetime format returns -1 month. Also can any one please tell me is this UTC timestamp or GMT or ISO. I am pretty confused. Any help is greatly appreciated.</p>
| 0debug |
i am stuck in very bad situation. help pls : <p>Last month i bought my new huawei g630-u20.. Everything was working cool until i thought to have my device rooted 😱😱. I googled and found this kingo root app to root my device . it rooted my device but after that everything went wrong.. I cannot access my android internal storage all folders are gone 😭😭 even i cannot start camera now it says unable to connect to camera.. I am now using sd card storage as primary but most of the apps are not working .. Please help me .. I google and found that bloody app has put my android internal storage to read-only without telling me.. What can i do now help me... 😭😭</p>
| 0debug |
Validating a field with jQuery : <p>I am trying to validate a form field so that the post won't proceed if the field is set with a value. So my field is:</p>
<pre><code> <input type="text" name="validator" id="validator" value="" title="validator" class="myClass" />
</code></pre>
<p>and then I'm using the following snippet to check if it has been filled:</p>
<pre><code> jQuery("form").submit(function(){
<?php if(isset($_POST['validator']) || !empty($_POST['validator'])){
die("Unable to write to database");
}
?>
});
</code></pre>
<p>but when I hit the submit button the form continues and registers the new user. What't wrong with my code please ? </p>
| 0debug |
Java Volleyball scoring program arrays and loops : <p>I am new to coding. Please be gentle with me.
I have been charged with creating a program that compares the scores of two competing volleyball. To win a match in volleyball, a team must get 25 points. But the team must also win by 2. These two teams are going to play five matches.</p>
<p>The program should accept from the user the scores for each team one match at a time. If at any time that user enters scores that violate the 25-point rule or the “win by 2” point rule, print an error on the screen and make the user enter both scores again.</p>
<p>When the user is finished entering the scores, print which team won the game, that is the team that won the most matches.</p>
<p>You have to use arrays and loops in this assignment. </p>
<p><strong>My program is only scoring the first set of scores in the array.</strong>
<strong>How do I make it store all five sets of scores?</strong> </p>
<pre><code>public static void main(String[] args) {
int team1[];
int team2[];
team1=new int[5];
team2=new int[5];
int counter1=0;
int counter2=0;
int k = 0;
for (int i=0;i<=4;i++){
Scanner scanint = new Scanner(System.in);
System.out.println("Enter the number of points Team 1 earned in Match " + (i+1));
team1[i] = scanint.nextInt();
System.out.println("Enter the number of points Team 2 earned in Match " + (i+1));
team2[i] = scanint.nextInt();
////////////////////////////////////////////
if (team1[i] < 25 & team2[i] < 25){
System.out.println("That cannot be. One team must get at least 25 points. Please re-enter the data.");
System.out.println("Enter the number of points Team 1 earned in Match " + (i+1));
team1[i] = scanint.nextInt();
System.out.println("Enter the number of points Team 2 earned in Match " + (i+1));
team2[i] = scanint.nextInt();
}
else if (team1[i] - team2[i] < 2 || team2[i] - team1[i] < 2){
System.out.println("That can't be. One team must win by at least two points. Please re-enter the data.");
System.out.println("Enter the number of points Team 1 earned in Match " + (i+1));
team1[i] = scanint.nextInt();
System.out.println("Enter the number of points Team 2 earned in Match " + (i+1));
team2[i] = scanint.nextInt();
}
else {
System.out.println("Enter the number of points Team 1 earned in Match " + (i+1));
team1[i] = scanint.nextInt();
System.out.println("Enter the number of points Team 2 earned in Match " + (i+1));
team2[i] = scanint.nextInt();
}
/////////////////////////////////////////////
if (team2[i] < team1[i]){
counter1++;}
else{ counter2++;}
}
if (counter1 > counter2) {
System.out.println("Team 1 has won the game.");}
else{
System.out.println("Team 2 has won the game.");
}
</code></pre>
| 0debug |
long do_sigreturn(CPUPPCState *env)
{
struct target_sigcontext *sc = NULL;
struct target_mcontext *sr = NULL;
target_ulong sr_addr = 0, sc_addr;
sigset_t blocked;
target_sigset_t set;
sc_addr = env->gpr[1] + SIGNAL_FRAMESIZE;
if (!lock_user_struct(VERIFY_READ, sc, sc_addr, 1))
goto sigsegv;
#if defined(TARGET_PPC64)
set.sig[0] = sc->oldmask + ((uint64_t)(sc->_unused[3]) << 32);
#else
__get_user(set.sig[0], &sc->oldmask);
__get_user(set.sig[1], &sc->_unused[3]);
#endif
target_to_host_sigset_internal(&blocked, &set);
set_sigmask(&blocked);
__get_user(sr_addr, &sc->regs);
if (!lock_user_struct(VERIFY_READ, sr, sr_addr, 1))
goto sigsegv;
restore_user_regs(env, sr, 1);
unlock_user_struct(sr, sr_addr, 1);
unlock_user_struct(sc, sc_addr, 1);
return -TARGET_QEMU_ESIGRETURN;
sigsegv:
unlock_user_struct(sr, sr_addr, 1);
unlock_user_struct(sc, sc_addr, 1);
force_sig(TARGET_SIGSEGV);
return 0;
}
| 1threat |
Trying to check if a certain position contains a certain character in C# : <p>I need to check the third and fourth last position of a string if it contains a dot. I'm unsure how to do this. Do I use string.Contains for this? Do I need to make an Array out of it? I'm thoroughly confused about this.</p>
| 0debug |
FirebaseRemoteConfig Error "No value of type 'String' exists for parameter key" : <p>I am using Firebase Core and some other Features, but not Remote Config. Multiple times a second the following Output is on Logcat. </p>
<p>Where can I disable the Remote Config functionality or even set those non-existing values?</p>
<p>Dependencies:</p>
<pre><code>// Project
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'com.google.firebase:firebase-plugins:1.2.0'
classpath 'io.fabric.tools:gradle:1.26.1'
// Module
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.android.support:preference-v7:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'org.jsoup:jsoup:1.11.3'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-messaging:17.5.0'
implementation 'com.google.firebase:firebase-perf:16.2.4'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.jsibbold:zoomage:1.2.0'
implementation 'com.android.support:exifinterface:28.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'
</code></pre>
<pre><code>W/FirebaseRemoteConfig: No value of type 'String' exists for parameter key 'sessions_max_length_minutes'.
W/FirebaseRemoteConfig: No value of type 'String' exists for parameter key 'sessions_max_length_minutes'.
W/FirebaseRemoteConfig: No value of type 'String' exists for parameter key 'sessions_feature_enabled'.
W/FirebaseRemoteConfig: No value of type 'String' exists for parameter key 'sessions_max_length_minutes'.
W/FirebaseRemoteConfig: No value of type 'String' exists for parameter key 'fpr_vc_trace_sampling_rate'.
W/FirebaseRemoteConfig: No value of type 'String' exists for parameter key 'sessions_feature_enabled'.
W/FirebaseRemoteConfig: No value of type 'String' exists for parameter key 'fpr_vc_trace_sampling_rate'.
</code></pre>
<p><em>It is not causing any problems I think, just annoying that it spams the Console.</em></p>
| 0debug |
Angular 2 get current route in guard : <p>I have an AccessGuard class in my project which its work is to determine if user can access to the route or not. I used the <code>router.url</code> to get the current route but the url returns the route before navigation to the new route like I'm in the users route and I click on the candidates route so the url returns users instead of candidates which I want that to validate access to the route
this is my route file:</p>
<pre><code>const routes:Routes = [
{
path:'',
component:PanelComponent,
canActivate:[AuthGuard,AccessGuard],
canActivateChild:[AuthGuard,AccessGuard],
children:[
{
path:'dashboard',
component:DashboardComponent
},
{
path:'users',
component:UsersComponent
},
{
path:'users/:id',
component:ShowUserComponent
},
{
path:'candidates',
component:CandidatesComponent
},
{
path:'permissions',
component:PermissionsComponent
},
{
path:'holidays',
component:HolidaysComponent
},
{
path:'candidate/:id',
component:CandidateComponent
},
{
path:'salary/create',
component:InsertSalaryComponent
},
{
path:'document/create',
component:InsertDocumentComponent
},
{
path:'leave/create',
component:InsertLeaveComponent
}
]
}
];
</code></pre>
<p>and this is my access guard:</p>
<pre><code>permissions;
currentRoute;
constructor(private authService:AuthService,private router:Router){
this.permissions = this.authService.getPermissions();
}
canActivate(){
return this.checkHavePermission();
}
canActivateChild(){
console.log(this.router.url);
return this.checkHavePermission();
}
private checkHavePermission(){
switch (this.router.url) {
case "/panel/users":
return this.getPermission('user.view');
case '/panel/dashboard':
return true;
case '/panel/candidates':
return this.getPermission('candidate.view');
default:
return true;
}
}
getPermission(perm){
for(var i=0;i<this.permissions.length;i++){
if(this.permissions[i].name == perm ){
return true;
}
}
return false;
}
</code></pre>
| 0debug |
Thread 1 Signal SIGABRT XCode : import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
I an getting an error at the "@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {" | 0debug |
db.execute('SELECT * FROM employees WHERE id = ' + user_input) | 1threat |
static av_cold int qtrle_decode_init(AVCodecContext *avctx)
{
QtrleContext *s = avctx->priv_data;
s->avctx = avctx;
switch (avctx->bits_per_coded_sample) {
case 1:
case 33:
avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
break;
case 2:
case 4:
case 8:
case 34:
case 36:
case 40:
avctx->pix_fmt = AV_PIX_FMT_PAL8;
break;
case 16:
avctx->pix_fmt = AV_PIX_FMT_RGB555;
break;
case 24:
avctx->pix_fmt = AV_PIX_FMT_RGB24;
break;
case 32:
avctx->pix_fmt = AV_PIX_FMT_RGB32;
break;
default:
av_log (avctx, AV_LOG_ERROR, "Unsupported colorspace: %d bits/sample?\n",
avctx->bits_per_coded_sample);
return AVERROR_INVALIDDATA;
}
s->frame.data[0] = NULL;
return 0;
}
| 1threat |
Angular preloading google map : <p>I am trying to create webpage with angular containing a google map. The map is taking a while to load. Is there is way to preload the map together with the app so the user see only the already loaded map?</p>
| 0debug |
HTML Validation for phone numbers : <p>I am new to HTML,can any one please help me to validate a phone number only with '+' and numeric values and phone number shud not exceed 13 numbers,and to validate email with a '@' and a '.',I dont want to use javascript </p>
| 0debug |
How primary memory is organised in a microcontroller? : <p>My query is :How the memory is organized and managed in the microcontroller?
(It doesn't have any OS i.e no presence of MMU).</p>
<p>I am working over zynq 7000 (ZC702) FPGA,It has seperate arm core and seperate DDR memory connected together with axi interconnects.</p>
<p>I wrote 11 1111 1111 in decimal to DDR(10 1's),it is giving me same after reading.
when i write 111 1111 1111 in decimal to DDR(11 1's),it gives me -1.</p>
<p>here the whole physical memory is consumed.This will not be the case when i use any microcontroller.
Who will manage the memory in microcontroller?</p>
| 0debug |
int ff_rv34_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
const uint8_t *buf, int buf_size)
{
RV34DecContext *r = avctx->priv_data;
MpegEncContext *s = &r->s;
AVFrame *pict = data;
SliceInfo si;
int i;
int slice_count;
const uint8_t *slices_hdr = NULL;
int last = 0;
if (buf_size == 0) {
if (s->low_delay==0 && s->next_picture_ptr) {
*pict= *(AVFrame*)s->next_picture_ptr;
s->next_picture_ptr= NULL;
*data_size = sizeof(AVFrame);
}
return 0;
}
if(!avctx->slice_count){
slice_count = (*buf++) + 1;
slices_hdr = buf + 4;
buf += 8 * slice_count;
}else
slice_count = avctx->slice_count;
for(i=0; i<slice_count; i++){
int offset= get_slice_offset(avctx, slices_hdr, i);
int size;
if(i+1 == slice_count)
size= buf_size - offset;
else
size= get_slice_offset(avctx, slices_hdr, i+1) - offset;
if(offset > buf_size){
av_log(avctx, AV_LOG_ERROR, "Slice offset is greater than frame size\n");
break;
}
r->si.end = s->mb_width * s->mb_height;
if(i+1 < slice_count){
init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, i+1), (buf_size-get_slice_offset(avctx, slices_hdr, i+1))*8);
if(r->parse_slice_header(r, &r->s.gb, &si) < 0){
if(i+2 < slice_count)
size = get_slice_offset(avctx, slices_hdr, i+2) - offset;
else
size = buf_size - offset;
}else
r->si.end = si.start;
}
if(!i && si.type == FF_B_TYPE && (!s->last_picture_ptr || !s->last_picture_ptr->data[0]))
return -1;
last = rv34_decode_slice(r, r->si.end, buf + offset, size);
s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start;
if(last)
break;
}
if(last){
if(r->loop_filter)
r->loop_filter(r, s->mb_height - 1);
ff_er_frame_end(s);
MPV_frame_end(s);
if (s->pict_type == FF_B_TYPE || s->low_delay) {
*pict= *(AVFrame*)s->current_picture_ptr;
} else if (s->last_picture_ptr != NULL) {
*pict= *(AVFrame*)s->last_picture_ptr;
}
if(s->last_picture_ptr || s->low_delay){
*data_size = sizeof(AVFrame);
ff_print_debug_info(s, pict);
}
s->current_picture_ptr= NULL;
}
return buf_size;
}
| 1threat |
static int slavio_misc_init1(SysBusDevice *sbd)
{
DeviceState *dev = DEVICE(sbd);
MiscState *s = SLAVIO_MISC(dev);
sysbus_init_irq(sbd, &s->irq);
sysbus_init_irq(sbd, &s->fdc_tc);
memory_region_init_io(&s->cfg_iomem, OBJECT(s), &slavio_cfg_mem_ops, s,
"configuration", MISC_SIZE);
sysbus_init_mmio(sbd, &s->cfg_iomem);
memory_region_init_io(&s->diag_iomem, OBJECT(s), &slavio_diag_mem_ops, s,
"diagnostic", MISC_SIZE);
sysbus_init_mmio(sbd, &s->diag_iomem);
memory_region_init_io(&s->mdm_iomem, OBJECT(s), &slavio_mdm_mem_ops, s,
"modem", MISC_SIZE);
sysbus_init_mmio(sbd, &s->mdm_iomem);
memory_region_init_io(&s->led_iomem, OBJECT(s), &slavio_led_mem_ops, s,
"leds", MISC_SIZE);
sysbus_init_mmio(sbd, &s->led_iomem);
memory_region_init_io(&s->sysctrl_iomem, OBJECT(s), &slavio_sysctrl_mem_ops, s,
"system-control", MISC_SIZE);
sysbus_init_mmio(sbd, &s->sysctrl_iomem);
memory_region_init_io(&s->aux1_iomem, OBJECT(s), &slavio_aux1_mem_ops, s,
"misc-system-functions", MISC_SIZE);
sysbus_init_mmio(sbd, &s->aux1_iomem);
memory_region_init_io(&s->aux2_iomem, OBJECT(s), &slavio_aux2_mem_ops, s,
"software-powerdown-control", MISC_SIZE);
sysbus_init_mmio(sbd, &s->aux2_iomem);
qdev_init_gpio_in(dev, slavio_set_power_fail, 1);
return 0;
}
| 1threat |
static void bdrv_throttle_read_timer_cb(void *opaque)
{
BlockDriverState *bs = opaque;
qemu_co_enter_next(&bs->throttled_reqs[0]);
}
| 1threat |
f.write fails to recored inputs : Suppose such a text
In [134]: !cat test1.md
The first test
I open it and write contents
In [156]: f1 = open("test1.md", "r+")
In [157]: f1.write("The second test")
Out[157]: 15
In [158]: !cat test1.md
The first test
test second method
It works correctly until now, if continue to input
In [159]: f1.write("The third test")
Out[159]: 14
In [160]: !cat test1.md
The first test
test second method
In [161]: f1.write("The fourth test")
Out[161]: 16
In [162]: !cat test1.md
The first test
test second method
What's the problem with `f.write`?
| 0debug |
Android BindingAdapter order of execution? : <p>I need to understand how the Data Binding Library determine the order of execution for its BindingAdapters. If I have two BindingAdapters for a View and if the View has both the attributes corresponding to those BindingAdapters, how will it determine which adapter will be executed first? I ask because the order of execution matters in my case.</p>
<p>I have the following BindingAdapter/s:</p>
<pre><code>public class SpinnerBindingAdapter {
@BindingAdapter(value = {"entries"})
public static void setEntries(Spinner spinner, List<? extends SpinnerItem> spinnerItems) {
for (int i = 0; i < spinnerItems.size(); i++) {
spinnerItems.get(i).setIndex(i);
}
ArrayAdapter<? extends SpinnerItem> adapter =
new ArrayAdapter<>(spinner.getContext(), R.layout.spinner_item, spinnerItems);
spinner.setAdapter(adapter);
}
@InverseBindingAdapter(attribute = "selectedItem", event = "selectedItemAttrChanged")
public static Object getSelectedItem(Spinner spinner) {
Object selectedItem = spinner.getSelectedItem();
return selectedItem;
}
@BindingAdapter(value = {"selectedItem"})
public static void setSelectedItem(Spinner spinner, SpinnerItem spinnerItem) {
if (spinner.getAdapter() == null) {
return;
}
// Other code omitted for simplicity
}
@BindingAdapter(value = {"selectedItemAttrChanged"}, requireAll = false)
public static void setOnItemSelectedListener(Spinner spinner, final InverseBindingListener selectedItemChange) {
if (selectedItemChange == null) {
spinner.setOnItemSelectedListener(null);
} else {
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
selectedItemChange.onChange();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
}
}
</code></pre>
<p>And here is how I populate the Spinner and set the selection:</p>
<pre><code><Spinner
android:id="@+id/spinner_system_activity_edit_tracker_unit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill_horizontal"
app:entries="@{DatabaseModel.queryForAll()}"
app:selectedItem="@={object.selectedItem}"/>
</code></pre>
<p>DatabaseModel.queryForAll is a static method that queries the database and returns a list of objects which is then given to the BindingAdapter. The BindingAdapter takes this list, update each of its item with an index and set it as an adapter for the spinner.</p>
<p>For whatever reason, the "setSelectedItem" BindingAdapter always gets called first. This is undesirable, because I need the entries to be initialised first. If its not initialised first then spinner.getAdapter() will be null when setSelectedItem is first called. Which means that previous saved selection will not be restored.</p>
| 0debug |
How show specific data on click of ListView from sqlite database? : Hello friend i am new in android i have one table in sqlite database which have two field one is b and another is "n" "b" represent book number and "n" represent book names i am successfully fetch all "n" field in my list view now i want when any user click particular listitem show book b number which in my databas for example i have book n=Genesis when any any one click on genesis it show book number like b=1;
here my code an database structure
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
});
return view;
}
private void setData() {
stringArrayList = new ArrayList<>();
mDBHelper = new DatabaseHelper(getContext());
mDb = mDBHelper.getReadableDatabase();
Cursor cursor = mDb.rawQuery("SELECT b, n FROM key_english;", new String[]{});
if (cursor.getCount() == 0) {
Toast.makeText(getContext(), "NO DATA FOUND", Toast.LENGTH_SHORT).show();
} else {
while (cursor.moveToNext()) {
stringArrayList.add(cursor.getString(1));
}
}
[Here my database my database structre][1]
[1]: https://i.stack.imgur.com/7aXut.png | 0debug |
lodash for "select by object path"? : <p>Let's say I have this object (or an array of these objects):</p>
<pre><code>var person = {
birth: {
place: {
country: 'USA'
}
}
};
</code></pre>
<p>I thought there was a lodash function where I could pass in <code>'birth.place.country'</code> and get back the value <code>USA</code>.</p>
<p>Is there such a function in lodasdh 3.x, or am I Imagining this?</p>
| 0debug |
Unknown cin properties : <p>Try as I might, I cannot find any information on what <code>cin.binary</code> is for. </p>
<p>similar ones, thinking bases, dec, hex, octal only seem to appear when used with cout - e.g.,</p>
<p><code>cout << std::hex << n;</code>.</p>
<p>However <code>cout << std::binary << n;</code> isn't valid</p>
<p>Entering <code>cin.</code> produces this intellisense popup</p>
<p><a href="https://i.stack.imgur.com/kURtK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kURtK.png" alt="intellisense popup for <code>cin.</code>"></a></p>
<p>I'm left assuming that these are some sort of flags. Sure would be nice to know for sure though.</p>
| 0debug |
BlockDriverAIOCB *dma_bdrv_io(
BlockDriverState *bs, QEMUSGList *sg, uint64_t sector_num,
DMAIOFunc *io_func, BlockDriverCompletionFunc *cb,
void *opaque, bool to_dev)
{
DMAAIOCB *dbs = qemu_aio_get(&dma_aio_pool, bs, cb, opaque);
dbs->acb = NULL;
dbs->bs = bs;
dbs->sg = sg;
dbs->sector_num = sector_num;
dbs->sg_cur_index = 0;
dbs->sg_cur_byte = 0;
dbs->to_dev = to_dev;
dbs->io_func = io_func;
dbs->bh = NULL;
qemu_iovec_init(&dbs->iov, sg->nsg);
dma_bdrv_cb(dbs, 0);
if (!dbs->acb) {
qemu_aio_release(dbs);
return NULL;
}
return &dbs->common;
}
| 1threat |
Remove some content from data php regx : <p>I want remove (deleted)345345 from the data file.
number can be anything.</p>
<pre><code>abc@gmail.com (deleted)395343
aab@gmail.com (deleted)2342322
</code></pre>
<p>i want data like
eg. abc@gmail.com</p>
| 0debug |
Add Xcode Developer Account from the Command Line : <p>I am trying to use <code>xcodebuild -allowProvisioningUpdates</code> on a machine that I only have access via the command line (Azure Devops macOS Hosted Machine).</p>
<p>Unfortunately, according to <code>man xcodebuild</code> in order to use <code>-allowProvisioningUpdates</code> it seems that "Requires a developer account to have been added in Xcode's Accounts preference pane."</p>
<p>Giving this, is there a way do add the account via the command line?</p>
<p>Thank you,
Cosmin</p>
| 0debug |
static inline void mpeg4_encode_dc(PutBitContext * s, int level, int n)
{
#if 1
level+=256;
if (n < 4) {
put_bits(s, uni_DCtab_lum_len[level], uni_DCtab_lum_bits[level]);
} else {
put_bits(s, uni_DCtab_chrom_len[level], uni_DCtab_chrom_bits[level]);
}
#else
int size, v;
size = 0;
v = abs(level);
while (v) {
v >>= 1;
size++;
}
if (n < 4) {
put_bits(&s->pb, DCtab_lum[size][1], DCtab_lum[size][0]);
} else {
put_bits(&s->pb, DCtab_chrom[size][1], DCtab_chrom[size][0]);
}
if (size > 0) {
if (level < 0)
level = (-level) ^ ((1 << size) - 1);
put_bits(&s->pb, size, level);
if (size > 8)
put_bits(&s->pb, 1, 1);
}
#endif
} | 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.