problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Tomcat with compression enabled causes error on OS X High Sierra : <p>We have been using Tomcat (v7) on OS X for quite some time now and never experienced any problems. However, after updating the OS to High Sierra, the web applications do not work anymore when compression is enabled in the server.xml.</p>
<p>Chrome constantly shows an ERR_CONTENT_DECODING_FAILED (obviously without any content displaying). When compression is switched off, everything works fine. I assume the root of the problem is Apple's upgrade of zlib in High Sierra. Everything was working fine on Sierra. The Tomcat log files look flawless -- there is no mention of any error occurring there.</p>
<p>Does anyone experience the same issue and managed to fix it or knows of a viable workaround <em>without disabling compression</em>? </p>
<p>Also, it would also be helpful if someone can confirm that newer versions of Tomcat do not experience this issue on High Sierra.</p>
<p>Thanks for your help.</p>
| 0debug
|
Typescript runtime error: cannot read property of undefined (enum) : <p>I have the following interface and enum in a file <em>RESTConfig.ts</em>:</p>
<pre><code>export const enum RESTMethod {
POST = "POST",
GET = "GET"
}
export interface RESTConfig {
url: string;
method: RESTMethod;
data: any;
}
</code></pre>
<p>I want to import and use the enum in another class as such:</p>
<pre><code>import { RESTConfig, RESTMethod } from './RESTConfig';
class Pipelines {
...
private someMethod() {
let rest: RESTConfig = {
url: "",
method: RESTMethod.POST,
data: {}
}
...
}
...
}
</code></pre>
<p>Linting and transpiling works fine, but at runtime I get the following error:</p>
<blockquote>
<p>TypeError: Cannot read property 'POST' of undefined</p>
</blockquote>
<p>on the line "method: RESTMethod.POST".</p>
<p>Can someone tell me what I'm doing wrong?</p>
| 0debug
|
static void unix_accept_incoming_migration(void *opaque)
{
struct sockaddr_un addr;
socklen_t addrlen = sizeof(addr);
int s = (unsigned long)opaque;
QEMUFile *f;
int c, ret;
do {
c = qemu_accept(s, (struct sockaddr *)&addr, &addrlen);
} while (c == -1 && socket_error() == EINTR);
DPRINTF("accepted migration\n");
if (c == -1) {
fprintf(stderr, "could not accept migration connection\n");
return;
}
f = qemu_fopen_socket(c);
if (f == NULL) {
fprintf(stderr, "could not qemu_fopen socket\n");
goto out;
}
ret = qemu_loadvm_state(f);
if (ret < 0) {
fprintf(stderr, "load of migration failed\n");
goto out_fopen;
}
qemu_announce_self();
DPRINTF("successfully loaded vm state\n");
qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
close(s);
out_fopen:
qemu_fclose(f);
out:
close(c);
}
| 1threat
|
Android App - Result from math calculation is not showing up on screen : I am attempting to make a simple android app that calculates the diameter of a sonar signal. The user inputs the depth(in meters) and angle(in degrees) and the app inputs the information into the formula:
2.0 * depth * Math.tan(angle / 2.0)
So I have created the UI and the java code and when I go to run the app in a VM it loads, I enter numbers in to test it, and when I hit the calculate button it does nothing. I am new to java and android development in general so if anyone could shed some light that would be great.
Here is the MainActivity.java: https://gist.github.com/enporter/5c6238d0d81afaa13de9f473cd327c87
XML file for the UI widgets activity_main.xml:
https://gist.github.com/enporter/80bef3f89c2240838aab4a0472f42ba9
I suspect the problem is something to do with this code that includes the formula but I am not sure so any help would be greatly appreciated:
```double depth1 = Integer.parseInt(depth.getText().toString());
double angle1 = Integer.parseInt(angle.getText().toString());
double result1 = 2.0 * depth1 * Math.tan(angle1 / 2.0);
result.setText(valueOf(result1));```
| 0debug
|
What does "let _self = this" mean in Javascript/Typescript? : <p>In this <a href="https://github.com/MurhafSousli/ng2-disqus/blob/master/src/disqus/disqus.component.ts" rel="noreferrer">code snippet</a>, why is it that <code>this.identifier</code> doesn't work but <code>_self.url</code> works?</p>
<pre><code> getConfig() {
let _self = this;
return function () {
this.page.url = this.url || window.location.href;
this.page.identifier = _self.identifier;
this.page.category_id = this.categoryId;
this.language = this.lang;
};
}
</code></pre>
<p>So does <code>let _self = this</code> actually do?</p>
| 0debug
|
Is it possible to initialize a List on one line in Dart? (it's called a collection initializer in c#) : <p>Is it possible to initialize a list on one line in Dart? Something like the following...</p>
<pre><code>List<int> options = new List<int>{ 1,2,5,9 };
</code></pre>
<p><em>(this is possible in c# and is called a collection initializer)</em></p>
| 0debug
|
Stratify a variable in R : <p>An example</p>
<pre><code>mtcars$qsec
[1] 16.46 17.02 18.61 19.44 17.02 20.22 15.84 20.00 22.90 18.30 18.90 17.40
[13] 17.60 18.00 17.98 17.82 17.42 19.47 18.52 19.90 20.01 16.87 17.30 15.41
[25] 17.05 18.90 16.70 16.90 14.50 15.50 14.60 18.60
</code></pre>
<p>I want to stratify or group that variable. The point is I want to do it in the same steps (e.g. <code>5</code>).</p>
<p>Currently I would do it like that</p>
<pre><code>mtcars$qsec_group[mtcars$qsec < 10] <- '10 or less'
mtcars$qsec_group[mtcars$qsec >= 10 & mtcars$qsec < 15] <- '10-15'
mtcars$qsec_group[mtcars$qsec >= 15 & mtcars$qsec < 20] <- '15-20'
</code></pre>
<p>It is quite unflexible. Is there an <strong>R-way</strong> to say <em>Stratify that variable in steps of 5.</em>?</p>
| 0debug
|
How to use '?' in java? : <p>I've seen this character being used several times in tutorials and other people's projects, so I would like to know what I would use it for? It's use with 'return' specifically</p>
| 0debug
|
How can I get a QR code from an encrypted image? : <p><a href="https://drive.google.com/open?id=1gvYe9mkGFWloSTE4VWpWuehzdzNJ4P6v" rel="nofollow noreferrer">This is png image:</a></p>
<p>When I open it with Notepad++ I found that this is a QR code
How to recover it, if python have any lib for this problem?</p>
| 0debug
|
void OPPROTO op_mov_T0_cc(void)
{
T0 = cc_table[CC_OP].compute_all();
}
| 1threat
|
static inline void reloc_pc19(tcg_insn_unit *code_ptr, tcg_insn_unit *target)
{
ptrdiff_t offset = target - code_ptr;
assert(offset == sextract64(offset, 0, 19));
*code_ptr = deposit32(*code_ptr, 5, 19, offset);
}
| 1threat
|
void ff_riff_write_info_tag(AVIOContext *pb, const char *tag, const char *str)
{
int len = strlen(str);
if (len > 0) {
len++;
ffio_wfourcc(pb, tag);
avio_wl32(pb, len);
avio_put_str(pb, str);
if (len & 1)
avio_w8(pb, 0);
}
}
| 1threat
|
static void *rcu_q_updater(void *arg)
{
int j, target_el;
long long n_updates_local = 0;
long long n_removed_local = 0;
struct list_element *el, *prev_el;
*(struct rcu_reader_data **)arg = &rcu_reader;
atomic_inc(&nthreadsrunning);
while (goflag == GOFLAG_INIT) {
g_usleep(1000);
}
while (goflag == GOFLAG_RUN) {
target_el = select_random_el(RCU_Q_LEN);
j = 0;
QLIST_FOREACH_SAFE_RCU(prev_el, &Q_list_head, entry, el) {
j++;
if (target_el == j) {
QLIST_REMOVE_RCU(prev_el, entry);
call_rcu1(&prev_el->rcu, reclaim_list_el);
n_removed_local++;
break;
}
}
if (goflag == GOFLAG_STOP) {
break;
}
target_el = select_random_el(RCU_Q_LEN);
j = 0;
QLIST_FOREACH_RCU(el, &Q_list_head, entry) {
j++;
if (target_el == j) {
prev_el = g_new(struct list_element, 1);
atomic_add(&n_nodes, 1);
prev_el->val = atomic_read(&n_nodes);
QLIST_INSERT_BEFORE_RCU(el, prev_el, entry);
break;
}
}
n_updates_local += 2;
synchronize_rcu();
}
synchronize_rcu();
atomic_add(&n_updates, n_updates_local);
atomic_add(&n_nodes_removed, n_removed_local);
return NULL;
}
| 1threat
|
static int vmdk_parent_open(BlockDriverState *bs, const char * filename)
{
BDRVVmdkState *s = bs->opaque;
char *p_name;
char desc[DESC_SIZE];
char parent_img_name[1024];
if (bdrv_pread(s->hd, 0x200, desc, DESC_SIZE) != DESC_SIZE)
return -1;
if ((p_name = strstr(desc,"parentFileNameHint")) != 0) {
char *end_name;
struct stat file_buf;
p_name += sizeof("parentFileNameHint") + 1;
if ((end_name = strchr(p_name,'\"')) == 0)
return -1;
strncpy(s->hd->backing_file, p_name, end_name - p_name);
if (stat(s->hd->backing_file, &file_buf) != 0) {
path_combine(parent_img_name, sizeof(parent_img_name),
filename, s->hd->backing_file);
} else {
strcpy(parent_img_name, s->hd->backing_file);
}
s->hd->backing_hd = bdrv_new("");
if (!s->hd->backing_hd) {
failure:
bdrv_close(s->hd);
return -1;
}
if (bdrv_open(s->hd->backing_hd, parent_img_name, 0) < 0)
goto failure;
}
return 0;
}
| 1threat
|
static void usage(void)
{
printf("qemu-" TARGET_ARCH " version " QEMU_VERSION QEMU_PKGVERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n"
"usage: qemu-" TARGET_ARCH " [options] program [arguments...]\n"
"Linux CPU emulator (compiled for %s emulation)\n"
"\n"
"Standard options:\n"
"-h print this help\n"
"-g port wait gdb connection to port\n"
"-L path set the elf interpreter prefix (default=%s)\n"
"-s size set the stack size in bytes (default=%ld)\n"
"-cpu model select CPU (-cpu ? for list)\n"
"-drop-ld-preload drop LD_PRELOAD for target process\n"
"-E var=value sets/modifies targets environment variable(s)\n"
"-U var unsets targets environment variable(s)\n"
"-0 argv0 forces target process argv[0] to be argv0\n"
#if defined(CONFIG_USE_GUEST_BASE)
"-B address set guest_base address to address\n"
#endif
"\n"
"Debug options:\n"
"-d options activate log (logfile=%s)\n"
"-p pagesize set the host page size to 'pagesize'\n"
"-singlestep always run in singlestep mode\n"
"-strace log system calls\n"
"\n"
"Environment variables:\n"
"QEMU_STRACE Print system calls and arguments similar to the\n"
" 'strace' program. Enable by setting to any value.\n"
"You can use -E and -U options to set/unset environment variables\n"
"for target process. It is possible to provide several variables\n"
"by repeating the option. For example:\n"
" -E var1=val2 -E var2=val2 -U LD_PRELOAD -U LD_DEBUG\n"
"Note that if you provide several changes to single variable\n"
"last change will stay in effect.\n"
,
TARGET_ARCH,
interp_prefix,
x86_stack_size,
DEBUG_LOGFILE);
exit(1);
}
| 1threat
|
Casting results from Observable.forkJoin to their respective types in Angular 2 : <p>Let say I have a component in Angular 2 that needs to load 2 different things from the server before the page is displayed. I'd like all of those things to fire off and call one event handler when they come back telling the page isLoaded = true. Let's say I have a service class that looks like this.</p>
<pre><code>export class MyService {
getStronglyTypedData1(): Observable<StrongData1[]>{
return this.http.get('http://...').map((response:Response) => <StrongData1[]>response.json());
}
getStronglyTypedData2(): Observable<StrongData2[]>{
return this.http.get('http://...').map((response:Response) => <StrongData2[]>response.json());
}
}
</code></pre>
<p>Then I have a component that uses that service class like this.</p>
<pre><code>export class MyComponent implements OnInit {
isLoaded = false;
stronglyTypedData1: StrongData1[];
stronglyTypedData2: StrongData2[];
constructor(private myService:MyService){ }
ngOnInit(){
var requests [
this.myService.getStronglyTypedData1(),
this.myService.getStronglyTypedData2()
];
Observable.forkJoin(requests).subscribe(
results => {
this.stronglyTypedData1 = results[0];
this.stronglyTypedData2 = results[1];
this.isLoaded = true;
});
}
}
</code></pre>
<p>The TypeScript compiler is complaining that it cant convert type object to type StrongData1[]. If I change StrongData1 and StrongData2 to "any", everything works fine. I'd rather not do that though because I'm losing the benefit of TypeScript's strong typings. </p>
<p>How do I cast the results from forkJoin to their respective types?</p>
| 0debug
|
Program to repeatedly get the contents of a webpage : <p>I wish to get the contents of a web page that requires me to be logged in (and one that I do not have control over: e.g. Twitter or Facebook), for example I can have Chrome running and I can see Ajax updating the page updating, but I want to periodically get the contents of this page and somehow save it. I don't mind leaving a computer running to achieve this...</p>
| 0debug
|
I created a weather robot on Facebook, but it showed below error message : 404 Not Found: Requested route ('circle-weather-bot.mybluemix.net') does not exist.
| 0debug
|
Android Room persistence library @Update not working : <p>I am trying to update my database via new android room library, but it is not working. Here it is my approach</p>
<pre><code>@IgnoreExtraProperties
@Entity(tableName = CarModel.TABLE_NAME,
indices = {@Index(value = "car_name", unique = true)})
public class CarModel {
public static final String TABLE_NAME = "cars";
@PrimaryKey(autoGenerate = true)
private int id;
@ColumnInfo(name = "car_name")
private String name;
@ColumnInfo(name = "car_price")
private String price;
private String type;
private String position;
}
</code></pre>
<p>MainActivity.java</p>
<pre><code>viewModel.isCarsEmpty().observe(MainActivity.this, new Observer<Integer>() {
@Override
public void onChanged(@Nullable Integer rowCount) {
if (rowCount == 0) {
viewModel.insertItems(list);
} else {
viewModel.updateItems(list);
}
}
});
</code></pre>
<p>CarViewModel.java</p>
<pre><code>public LiveData<Integer> isCarsEmpty() {
return appDatabase.carDao().isDbEmpty();
}
public void insertItems(List<CarModel> carModels) {
new insertCarsAsyncTask(appDatabase).execute(carModels);
}
private class insertCarsAsyncTask extends AsyncTask<List<CarModel>, Void, Void> {
private AppDatabase db;
public insertCarsAsyncTask(AppDatabase appDatabase) {
db = appDatabase;
}
@Override
protected Void doInBackground(List<CarModel>... params) {
db.carDao().insertCars(params[0]);
return null;
}
}
public void updateItems(List<CarModel> list) {
new updateCarsTask(appDatabase).execute(list);
}
private class updateCarsTask extends AsyncTask<List<CarModel>, Void, Void> {
private AppDatabase db;
public updateCarsTask(AppDatabase appDatabase) {
db = appDatabase;
}
@Override
protected Void doInBackground(List<CarModel>... params) {
db.carDao().updateCars(params[0]);
return null;
}
}
</code></pre>
<p>CarDao.java</p>
<pre><code>@Insert(onConflict = REPLACE)
void insertCars(List<CarModel> cars);
@Update
void updateCars(List<CarModel> param);
@Query("SELECT count(*) FROM " + CarModel.TABLE_NAME)
LiveData<Integer> isDbEmpty();
</code></pre>
<p>I did debugging, new data comes and calling viewModel.updateItems(list) method.Thanks in advance!</p>
| 0debug
|
static CCW1 copy_ccw_from_guest(hwaddr addr, bool fmt1)
{
CCW0 tmp0;
CCW1 tmp1;
CCW1 ret;
if (fmt1) {
cpu_physical_memory_read(addr, &tmp1, sizeof(tmp1));
ret.cmd_code = tmp1.cmd_code;
ret.flags = tmp1.flags;
ret.count = be16_to_cpu(tmp1.count);
ret.cda = be32_to_cpu(tmp1.cda);
} else {
cpu_physical_memory_read(addr, &tmp0, sizeof(tmp0));
ret.cmd_code = tmp0.cmd_code;
ret.flags = tmp0.flags;
ret.count = be16_to_cpu(tmp0.count);
ret.cda = be16_to_cpu(tmp0.cda1) | (tmp0.cda0 << 16);
if ((ret.cmd_code & 0x0f) == CCW_CMD_TIC) {
ret.cmd_code &= 0x0f;
}
}
return ret;
}
| 1threat
|
Had a confusion with dropdownlist : <p>Hi everyone one making an work hours. Which my boss wants me to create two dropdownlist one is hours of the day(1,2,3) and one is "00/15/30/45" . and radio button for AM PM. My problem is what is "00/15/30/45" means? What datetime format it is? O.o</p>
<p>-newbie junior programmer</p>
| 0debug
|
JavaScript, how to create an array that sequentially counts till N? : <p>Not sure how exactly to word this, but essentially, I'm trying to write a function that if you input 5, it will return [1, 2, 3, 4, 5], if you input 7, it will return [1, 2, 3, 4, 5, 6, 7] etc etc.</p>
<p>It seems simple but for some reason it's just not clicking for me.</p>
| 0debug
|
Update NSFetchedResultsController using performBackgroundTask : <p>I have an <code>NSFetchedResultsController</code> and I am trying to update my data on a background context. For example, here I am trying to delete an object:</p>
<pre><code>persistentContainer.performBackgroundTask { context in
let object = context.object(with: restaurant.objectID)
context.delete(object)
try? context.save()
}
</code></pre>
<p>There are 2 things I don't understand:</p>
<ol>
<li>I would have expected this to modify, <strong>but not save</strong> the parent context. However, the parent context is definitely being saved (as verified by manually opening the SQLite file).</li>
<li>I would have expected the <code>NSFetchedResultsController</code> to update when the background content saves back up to its parent, but this is not happening. Do I need to manually trigger something on the main thread?</li>
</ol>
<p>Obviously there is something I am not getting. Can anybody explain this?</p>
<p>I know that I have implemented the fetched results controller delegate methods correctly, because if I change my code to directly update the <code>viewContext</code>, everything works as expected.</p>
| 0debug
|
Empty output while trying to convert a yaml data into a struct : <p>Im trying to convert a yaml data into a struct and print it. The output I get for this program is empty. </p>
<pre><code>package main
import (
"fmt"
"gopkg.in/yaml.v2"
)
type example struct {
variable1 string
variable2 string
}
func main() {
var a example
yaml.Unmarshal([]byte("variable1: asd\nvariable2: sdcs"), &a)
fmt.Println(a.variable1)
}
</code></pre>
| 0debug
|
dplyr chain filter based on frequency : <pre><code>table(mtcars$cyl)
4 6 8
11 7 14
</code></pre>
<p>Suppose I wanted to filter low frequency terms, in this case less than 10. Is there an elegant dplyr esque way to do this?</p>
<pre><code>mtcars %>% group_by(cyl) %>% filter([???])
</code></pre>
<p>The result would be a data frame with 4 and 8 cyl only, since they both occur 10 or more times.</p>
| 0debug
|
static test_speed(int step)
{
const struct pix_func* pix = pix_func;
const int linesize = 720;
char empty[32768];
char* bu =(char*)(((long)empty + 32) & ~0xf);
int sum = 0;
while (pix->name)
{
int i;
uint64_t te, ts;
op_pixels_func func = pix->func;
char* im = bu;
if (!(pix->mm_flags & mm_flags))
continue;
printf("%30s... ", pix->name);
fflush(stdout);
ts = rdtsc();
for(i=0; i<100000; i++){
func(im, im + 1000, linesize, 16);
im += step;
if (im > bu + 20000)
im = bu;
}
te = rdtsc();
emms();
printf("% 9d\n", (int)(te - ts));
sum += (te - ts) / 100000;
if (pix->mm_flags & PAD)
puts("");
pix++;
}
printf("Total sum: %d\n", sum);
}
| 1threat
|
static void disas_extract(DisasContext *s, uint32_t insn)
{
unsupported_encoding(s, insn);
}
| 1threat
|
Excel Formula is not working please : Please help. What is wrong with this equation in excel?
=IFERROR(IF(SEARCH(B$1,'Project Spread Sheet 4-14'!$H2)>0,'Sheet1 (2)'!indirect("C"&((column(ROW())))),""),"")
OR
=IFERROR(IF(SEARCH(B$1,'Project Spread Sheet 4-14'!$H2)>0,'Sheet1 (2)'!$C((column(ROW())))),""),"")
meant to do the same thing.
Thanks
| 0debug
|
deviding single column into two columns : how can i devide the payment column into refund and trasnfer fee on the bases of comments column
<!-- begin snippet: js hide: false -->
<!-- language: lang-html -->
<table>
<thead>
<th>Payment</th>
<th>comments</th>
</thead>
<tbody>
<tr>
<td>3000</td>
<td>refund</td>
</tr>
<tr>
<td>3000</td>
<td>refund</td>
</tr>
<tr>
<td>3000</td>
<td>transfer fee</td>
</tr>
</tbody>
</table>
<!-- end snippet -->
| 0debug
|
how to get the index of ith item in pandas.Series : <p>I'm trying to get the index of 6th item in the Series I have.</p>
<p>This is how the head looks like</p>
<pre><code>United States 1.536434e+13
China 6.348609e+12
Japan 5.542208e+12
Germany 3.493025e+12
France 2.681725e+12
</code></pre>
<p>For getting the 6th index name ( 6th Country after being sorted ), I usually use s.head(6) and get the 6th index from there</p>
<p>s.head(6) gives me</p>
<pre><code>United States 1.536434e+13
China 6.348609e+12
Japan 5.542208e+12
Germany 3.493025e+12
France 2.681725e+12
United Kingdom 2.487907e+12
</code></pre>
<p>and looking at this, I'm getting the index as United Kingdom.</p>
<p>So, is there any better way for getting the index other than this. And also, for a data frame, is there any function to get the 6th index on basis of a respective column after sorting. </p>
<p>If it's data frame, I usually, sort, create a new column named index, and use reset_index and then use iloc attribute to get the 6th ( Since, it will be using an range in the index after reset ). </p>
<p>Is there any better way in doing this with pd.Series and pd.DataFrame.</p>
<p>Thank you. </p>
| 0debug
|
why there is two interface comparable and comparator in java for sorting the collections? : <p>why there is two interface comparable and comparator in java for sorting the collections? </p>
<p>both are doing the same task it seems... confusion on this sorting technique? Please advise</p>
| 0debug
|
How can a Slack bot detect a direct message vs a message in a channel? : <p>TL;DR: Via the Slack APIs, how can I differentiate between a message in a channel vs a direct message?</p>
<p>I have a working Slack bot using the RTM API, let's call it Edi. And it works great as long as all commands start with "@edi"; e.g. "@edi help". It currently responses to any channel it's a member of and direct messages. However, I'd like to update the bot so that when it's a direct message, there won't be a need to start a command with "@edi"; e.g. "@edi help" in a channel, but "help" in a direct message. I don't see anything specific to differentiate between the two, but I did try using the channel.info endpoint and counting the number of people in "members"; however, this method only works on public channel. For private channels and direct messages, the endpoint returns an "channel_not_found" error.</p>
<p>Thanks in advance.</p>
| 0debug
|
static int eval_refl(const int16_t *coefs, int *refl, RA144Context *ractx)
{
int retval = 0;
int b, c, i;
unsigned int u;
int buffer1[10];
int buffer2[10];
int *bp1 = buffer1;
int *bp2 = buffer2;
for (i=0; i < 10; i++)
buffer2[i] = coefs[i];
u = refl[9] = bp2[9];
if (u + 0x1000 > 0x1fff) {
av_log(ractx, AV_LOG_ERROR, "Overflow. Broken sample?\n");
return 0;
}
for (c=8; c >= 0; c--) {
if (u == 0x1000)
u++;
if (u == 0xfffff000)
u--;
b = 0x1000-((u * u) >> 12);
if (b == 0)
b++;
for (u=0; u<=c; u++)
bp1[u] = ((bp2[u] - ((refl[c+1] * bp2[c-u]) >> 12)) * (0x1000000 / b)) >> 12;
refl[c] = u = bp1[c];
if ((u + 0x1000) > 0x1fff)
retval = 1;
FFSWAP(int *, bp1, bp2);
}
return retval;
}
| 1threat
|
JSHint does not recognise Async/Await syntax in Visual Studio Code (VSCode) : <p>I've been struggling with VSCode and JSHint to find out a way to get rid of this syntax highlighting. It seems like JSHint is not able to recognise Async/Await syntax.</p>
<p>Here you can find a screenshot of what I'm talking about. </p>
<p><a href="https://i.stack.imgur.com/IIt10.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IIt10.png" alt="enter image description here"></a></p>
<p>My JSHint version: <code>jshint-esnext v2.7.0-3</code></p>
| 0debug
|
static SaveStateEntry *find_se(const char *idstr, int instance_id)
{
SaveStateEntry *se;
QTAILQ_FOREACH(se, &savevm_handlers, entry) {
if (!strcmp(se->idstr, idstr) &&
instance_id == se->instance_id)
return se;
}
return NULL;
}
| 1threat
|
How to reduce 50 If functions by For ... Next loop using over 50 textboxes? : <p>I use vb.net 2008 to build an application. I have a form with 50 textboxes containing the ip address of the remote device, if the ping device is good then the background color of the textbox is green, otherwise red. I use the If function as follows:</p>
<pre><code>Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If My.Computer.Network.Ping(TextBox1.Text) Then
TextBox1.BackColor = Color.Green
Else
TextBox1.BackColor = Color.Red
End If
If My.Computer.Network.Ping(TextBox2.Text) Then
TextBox2.BackColor = Color.Green
Else
TextBox2.BackColor = Color.Red
End If
.
.’ The if functions of the Textbox3 to the Textbox49
.
If My.Computer.Network.Ping(TextBox50.Text) Then
TextBox50.BackColor = Color.Green
Else
TextBox50.BackColor = Color.Red
End If
End Sub
End Class
</code></pre>
<p>For 50 textboxes, I have to use 50 If functions as this makes the code very long, can you help me to shorten code with For ... Next loop.
Thank you for your help.</p>
| 0debug
|
ModuleNotFoundError in VS Code and Visual Studio despite installing : Am a newbie to Python and is trying to use eyed3 module. Here is my code.
import eyeD3
def GetAlbumName(filename):
tag = eyeD3.tag()
I installed eyeD3 using both Visual Studio Code ("python -m pip install eyeD3") and Visual Studio (it now says "Requirement already satisfied:"), but I am still running into "ModuleNotFoundError" exception.
Within Visual Studio Code, I tried changing the interpeter (Ctrl+Shift+P), but the exception remains.
| 0debug
|
Preload CSS file not supported on Firefox and Safari Mac : <p>I added the attribute rel="preload" to all css links like this : </p>
<pre><code> <link rel='preload' onload='this.rel="stylesheet"' as='style'
id='reworldmedia-style-css' href='style.css' type='text/css' media='all'
/>
</code></pre>
<p>It works fine in Chrome but not in Safari or Firefox </p>
| 0debug
|
static BlockDriverState *get_bs_snapshots(void)
{
BlockDriverState *bs;
DriveInfo *dinfo;
if (bs_snapshots)
return bs_snapshots;
QTAILQ_FOREACH(dinfo, &drives, next) {
bs = dinfo->bdrv;
if (bdrv_can_snapshot(bs))
goto ok;
}
return NULL;
ok:
bs_snapshots = bs;
return bs;
}
| 1threat
|
Warning: “Variables with usage in documentation object ‘FANG’ but not in code:” : <p>On R-devel (>3.6.1 at the time), a new warning has popped up in my package when running R CMD Check that looks like:</p>
<pre><code>“Variables with usage in documentation object ‘FANG’ but not in code:”
'FANG'
</code></pre>
<p>FANG is a data set that I include in my package.</p>
<p>You can see the exact error at:
<a href="https://travis-ci.org/business-science/tibbletime/jobs/568639099#L3163" rel="noreferrer">https://travis-ci.org/business-science/tibbletime/jobs/568639099#L3163</a></p>
<p>You can see the frozen state of this package at:
<a href="https://github.com/business-science/tibbletime/blob/305e80ee3f6eecd728eb06937650dae03c94320c/R/data.R#L18" rel="noreferrer">https://github.com/business-science/tibbletime/blob/305e80ee3f6eecd728eb06937650dae03c94320c/R/data.R#L18</a></p>
<p>Below, I answer my own question about what this error means, and why it occurred.</p>
| 0debug
|
static void mpeg_decode_sequence_extension(MpegEncContext *s)
{
int horiz_size_ext, vert_size_ext;
int bit_rate_ext, vbv_buf_ext, low_delay;
int frame_rate_ext_n, frame_rate_ext_d;
skip_bits(&s->gb, 8);
skip_bits(&s->gb, 1);
skip_bits(&s->gb, 2);
horiz_size_ext = get_bits(&s->gb, 2);
vert_size_ext = get_bits(&s->gb, 2);
s->width |= (horiz_size_ext << 12);
s->height |= (vert_size_ext << 12);
bit_rate_ext = get_bits(&s->gb, 12);
s->bit_rate = ((s->bit_rate / 400) | (bit_rate_ext << 12)) * 400;
skip_bits1(&s->gb);
vbv_buf_ext = get_bits(&s->gb, 8);
low_delay = get_bits1(&s->gb);
frame_rate_ext_n = get_bits(&s->gb, 2);
frame_rate_ext_d = get_bits(&s->gb, 5);
if (frame_rate_ext_d >= 1)
s->frame_rate = (s->frame_rate * frame_rate_ext_n) / frame_rate_ext_d;
dprintf("sequence extension\n");
s->mpeg2 = 1;
}
| 1threat
|
Full width button, how to align text : <p>Trying to figure out if I can align the text in a full width button, i.e a button that has <code>width: double.infinity</code></p>
<p>for example this:</p>
<pre><code>ButtonTheme(
minWidth: double.infinity,
child: FlatButton(
onPressed: () {},
child: Text('Sign Out', textAlign: TextAlign.left),
),
)
</code></pre>
<p>produces a centered text button and the alignment cannot be changed.</p>
<p>I have tried a few things but can't figure it out, unless I try to create a custom button.</p>
<p>I'm trying to get a full width button with text:left so the user can click anywhere in the row, and still get the material tap effect.</p>
<p><a href="https://i.stack.imgur.com/ld2Am.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ld2Am.png" alt="enter image description here"></a></p>
| 0debug
|
size_t qemu_fd_getpagesize(int fd)
{
#ifdef CONFIG_LINUX
struct statfs fs;
int ret;
if (fd != -1) {
do {
ret = fstatfs(fd, &fs);
} while (ret != 0 && errno == EINTR);
if (ret == 0 && fs.f_type == HUGETLBFS_MAGIC) {
return fs.f_bsize;
}
}
return getpagesize();
}
| 1threat
|
Build .NET solution using GitLab CI Pipeline : <p>I have a solution with several .NET projects in it. I use GitLab, not self-hosted, for version control and would like to start using their CI tools as well. I have added the following <code>.gitlab-ci.yml</code> file to my root:</p>
<pre><code>stages:
- build
- test
build_job:
stage: build
script:
- 'echo building...'
- 'msbuild.exe Bizio.sln'
except:
- tags
test_job:
stage: test
script:
- 'echo: testing...'
- 'msbuild.exe Bizio.sln'
- 'dir /s /b *.Tests.dll | findstr /r Tests\\bin\\ > tests_list.txt'
- 'for /f %%f in (tests_list.txt) do mstest.exe /testcontainer: "%%f"'
except:
- tags
</code></pre>
<p>The <code>build</code> stage always fails because it doesn't know what <code>msbuild</code> is. The exact error is:</p>
<blockquote>
<p>/bin/bash: line 61: msbuild.exe: command not found</p>
</blockquote>
<p>After some investigating, I've figured out that I'm using a shared runner. Here is the entire output from the job run:</p>
<pre><code>Running with gitlab-runner 10.6.0-rc1 (0a9d5de9)
on docker-auto-scale 72989761
Using Docker executor with image ruby:2.5 ...
Pulling docker image ruby:2.5 ...
Using docker image sha256:bae0455cb2b9010f134a2da3a1fba9d217506beec2d41950d151e12a3112c418 for ruby:2.5 ...
Running on runner-72989761-project-1239128-concurrent-0 via runner-72989761-srm-1520985217-1a689f37...
Cloning repository...
Cloning into '/builds/hyjynx-studios/bizio'...
Checking out bc8085a4 as master...
Skipping Git submodules setup
$ echo building...
building...
$ C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe Bizio.sln
/bin/bash: line 61: msbuild.exe: command not found
ERROR: Job failed: exit code 1
</code></pre>
<p>It looks like the shared runner I have is using a Docker image for Ruby, which seems wrong. I don't know how I can change that or select a different one that can be used for .NET. After some further investigating I'm getting worried that I'll have to jump through a lot of hoops to get what I want, like using an Azure VM to host a GitLab Runner that can build .NET apps.</p>
<p><strong>What do I need to do to use GitLab's CI pipelines to build my .NET solution using a non-self-hosted GitLab instance?</strong></p>
| 0debug
|
How do you comment a line in .sbt file : <p>This may sound like a stupid question, but I've been searching all over the internet on how to comment a line in an sbt file. Does anyone know how to?</p>
| 0debug
|
static unsigned tget(const uint8_t **p, int type, int le)
{
switch (type) {
case TIFF_BYTE : return *(*p)++;
case TIFF_SHORT: return tget_short(p, le);
case TIFF_LONG : return tget_long(p, le);
default : return UINT_MAX;
}
}
| 1threat
|
Make columns in data frame equal to median, mean, etc.? (R) : <p>I have several rows of numerical data, each representing a different quantity or measurement. I'm supposed to make the columns equal to the means of the the different quantities, the IQRS of the different quantities, and the medians of the different quantities, but there doesn't seem to be any way to do that?</p>
| 0debug
|
how to map column names to row minimum value : <p>I have the following data:</p>
<pre><code>df
dc1 dc2 dc3 min_colname
[1,] 12.9 13.4 13.4
[2,] 6.1 6.5 6.5
[3,] 6.3 6.7 6.7
[4,] 21.0 21.4 21.4
[5,] 1.6 1.8 1.8
[6,] 3.3 3.7 3.7
[7,] 7.0 7.4 7.4
[8,] 3.2 3.6 3.6
[9,] 14.8 15.2 15.2
[10,] 7.9 8.3 8.3
</code></pre>
<p>I am trying to add one more column say <code>min_colname</code> which will have the min values of each row but mapped to column name....for example for row 1 min value is <code>12.9</code>..so the first item in min_colname should be <code>dc1</code> and not the actual obs value.....</p>
| 0debug
|
MVC model not saving the value : <pre><code> var ticketnumber = TempData["ticketId"] as Ticket;
ticketnumber.TicketId = model.TicketId;
db.SaveChanges();
HttpPostedFileBase file = Request.Files["ImageData"];
UploadRepository service = new UploadRepository();
int i = service.UploadImageInDataBase(file, model);
</code></pre>
<p>I have the value inside my tempdata but when i try to assign the value of it to the model value it doesnt save and even in debug it tells me the value hasnt changed so i just dont get what i am doing wrong.</p>
| 0debug
|
Ensuring session strict mode in custom SessionHandlerInterface implementation : <h1>Intro</h1>
<p>Since PHP 5.5.2 there is a runtime configuration option (<a href="http://php.net/manual/en/session.configuration.php#ini.session.use-strict-mode" rel="noreferrer">session.use_strict_mode</a>) that is meant to prevent session fixation by malicious clients. When this option is enabled and the <a href="http://php.net/manual/en/session.configuration.php#ini.session.save-handler" rel="noreferrer">native session handler</a> is used (files), PHP will not accept any incoming session ID that did not previously exist in the session storage area, like so:</p>
<pre><code>$ curl -I -H "Cookie:PHPSESSID=madeupkey;" localhost
HTTP/1.1 200 OK
Cache-Control: no-store, no-cache, must-revalidate
Connection: close
Content-type: text/html; charset=UTF-8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Host: localhost
Pragma: no-cache
Set-Cookie: PHPSESSID=4v3lkha0emji0kk6lgl1lefsi1; path=/ <--- looky
</code></pre>
<p>(with <code>session.use_strict_mode</code> disabled, the response would have <strong>not</strong> included a <code>Set-Cookie</code> header and a <code>sess_madeupkey</code> file would have been created in the sessions directory)</p>
<h1>Problem</h1>
<p>I am in the process of implementing a <a href="http://php.net/manual/en/session.customhandler.php" rel="noreferrer">custom session handler</a> and I'd pretty much like it to adhere to the strict mode, however the interface makes it difficult.</p>
<p>When <code>session_start()</code> is called, <code>MyHandler::read($session_id)</code> is invoked down the line, but <code>$session_id</code> can be <strong>either</strong> the value fetched from the session cookie <strong>or</strong> a new session ID. The handler needs to know the difference, because in the former case an error must be raised if the session ID cannot be found. Moreover, according to spec <code>read($session_id)</code> must return either the session contents or an empty string (for new sessions), but there seems to be no way to raise an error up the chain.</p>
<p>So to sum up, the questions I need to answer in order to match the native behavior are:</p>
<ol>
<li><p>From the context of <code>read($session_id)</code>, how can I tell the difference between a newly minted session ID or a session ID that came from the HTTP request?</p></li>
<li><p>Given a session ID that came from the HTTP request and supposing that it was not found in the storage area, how would I signal an error to the PHP engine so that it would call <code>read($session_id)</code> again with a new session ID?</p></li>
</ol>
| 0debug
|
bool desc_ring_set_size(DescRing *ring, uint32_t size)
{
int i;
if (size < 2 || size > 0x10000 || (size & (size - 1))) {
DPRINTF("ERROR: ring[%d] size (%d) not a power of 2 "
"or in range [2, 64K]\n", ring->index, size);
return false;
}
for (i = 0; i < ring->size; i++) {
g_free(ring->info[i].buf);
}
ring->size = size;
ring->head = ring->tail = 0;
ring->info = g_realloc(ring->info, size * sizeof(DescInfo));
if (!ring->info) {
return false;
}
memset(ring->info, 0, size * sizeof(DescInfo));
for (i = 0; i < size; i++) {
ring->info[i].ring = ring;
}
return true;
}
| 1threat
|
Getting different results when dereferencing a pointer to an integer : <pre><code>#include<stdlib.h>
#include<iostream>
using namespace std;
void fun(int* a){
int b=*a++;
cout<<b<<endl;
}
void fun1(int *a){
int b=*a+1;
cout<<b<<endl;
}
int main(){
int n=5;
fun(&n);//output remains 5
fun1(&n);//output incremented by 1
}
</code></pre>
<p>In the function fun the value of n does not get incremented when done as shown in the above code, on the other hand in function fun1 the value of n gets incremented by 1.What is the problem with the first approach to increment n?</p>
| 0debug
|
duplicate ID in sql select : the select in mysql is this:
SELECT v.product_id,nome AS Produto,presentation AS Descricao, presentation
AS Descricao2, name1 AS categoria, description_two AS descricao, price AS
preco, quantity AS estoque, width, height, depth, weight, NAME,
referenceCode, datapostagem FROM Variant v INNER JOIN ProductCategory p ON
v.product_id = p.product_id INNER JOIN Product ON Product.id = p.product_id
INNER JOIN Category ON Category.id = category_id INNER JOIN Image i ON
i.product_id = p.product_id INNER JOIN DescriptionGroup D ON D.product_id =
p.product_id INNER JOIN Stock S ON S.variant_id = v.id INNER JOIN
DimensionGroup G ON G.variant_id = v.id LIMIT 10
The result return lot of duplicate product_id, how can i separate the product_id in another columm ? like product2, product3, product4 ?
the image of result bellow:
[enter image description here][1]
[1]: https://i.stack.imgur.com/XaQQK.png
| 0debug
|
static void slavio_timer_get_out(SLAVIO_TIMERState *s)
{
uint64_t count;
count = s->limit - PERIODS_TO_LIMIT(ptimer_get_count(s->timer));
DPRINTF("get_out: limit %" PRIx64 " count %x%08x\n", s->limit,
s->counthigh, s->count);
s->count = count & TIMER_COUNT_MASK32;
s->counthigh = count >> 32;
}
| 1threat
|
Sub-string splitting with php : <p>I have a string 33#math#indonesia#Primary 2, and want to be separated into like this 33,math,indonesia,primary 2 into four parts
<a href="https://i.stack.imgur.com/p3WrU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p3WrU.png" alt="enter image description here"></a></p>
| 0debug
|
Realm Exception 'value' is not a valid managed object : <p>I'm setting a property on a realm object with another realm object which is a different class, however I'm getting the error: 'value' is not avalid managed object.</p>
<pre><code>realmObject.setAnotherRealmObject(classInstance.returnAnotherRealmObjectWithValues())
</code></pre>
<p>The class instance receives anotherRealmObject constructor and returns it through the method with values from widgets:</p>
<pre><code>public ClassInstance(AnotherRealmObject anotherRealmObject){
mAnotherRealmObject = anotherRealmObject;
}
public AnotherRealmObject returnAnotherRealmObjectWithValues(){
mAnotherRealmObject.setId(RandomUtil.randomNumbersAndLetters(5));
mAnotherRealmObject.setName(etName.getText().toString());
return mAnotherRealmObject;
}
</code></pre>
<p>I'm creating the new Another Realm Object the right way (I think):</p>
<pre><code>mAnotherRealmObject = mRealmInstance.createObject(AnotherRealmObject.class);
</code></pre>
<p>Is it because I'm returning anotherRealmObject wherein it is already modified because of the passing reference?</p>
| 0debug
|
static void vaapi_encode_h264_write_sei(PutBitContext *pbc,
VAAPIEncodeContext *ctx,
VAAPIEncodePicture *pic)
{
VAAPIEncodeH264Context *priv = ctx->priv_data;
PutBitContext payload_bits;
char payload[256];
int payload_type, payload_size, i;
void (*write_payload)(PutBitContext *pbc,
VAAPIEncodeContext *ctx,
VAAPIEncodePicture *pic) = NULL;
vaapi_encode_h264_write_nal_header(pbc, NAL_SEI, 0);
for (payload_type = 0; payload_type < 64; payload_type++) {
switch (payload_type) {
case SEI_TYPE_BUFFERING_PERIOD:
if (!priv->send_timing_sei ||
pic->type != PICTURE_TYPE_IDR)
continue;
write_payload = &vaapi_encode_h264_write_buffering_period;
break;
case SEI_TYPE_PIC_TIMING:
if (!priv->send_timing_sei)
continue;
write_payload = &vaapi_encode_h264_write_pic_timing;
break;
case SEI_TYPE_USER_DATA_UNREGISTERED:
if (pic->encode_order != 0)
continue;
write_payload = &vaapi_encode_h264_write_identifier;
break;
default:
continue;
}
init_put_bits(&payload_bits, payload, sizeof(payload));
write_payload(&payload_bits, ctx, pic);
if (put_bits_count(&payload_bits) & 7) {
write_u(&payload_bits, 1, 1, bit_equal_to_one);
while (put_bits_count(&payload_bits) & 7)
write_u(&payload_bits, 1, 0, bit_equal_to_zero);
}
payload_size = put_bits_count(&payload_bits) / 8;
flush_put_bits(&payload_bits);
u(8, payload_type, last_payload_type_byte);
u(8, payload_size, last_payload_size_byte);
for (i = 0; i < payload_size; i++)
u(8, payload[i] & 0xff, sei_payload);
}
vaapi_encode_h264_write_trailing_rbsp(pbc);
}
| 1threat
|
static void nvdimm_dsm_label_size(NVDIMMDevice *nvdimm, hwaddr dsm_mem_addr)
{
NvdimmFuncGetLabelSizeOut label_size_out = {
.len = cpu_to_le32(sizeof(label_size_out)),
};
uint32_t label_size, mxfer;
label_size = nvdimm->label_size;
mxfer = nvdimm_get_max_xfer_label_size();
nvdimm_debug("label_size %#x, max_xfer %#x.\n", label_size, mxfer);
label_size_out.func_ret_status = cpu_to_le32(0 );
label_size_out.label_size = cpu_to_le32(label_size);
label_size_out.max_xfer = cpu_to_le32(mxfer);
cpu_physical_memory_write(dsm_mem_addr, &label_size_out,
sizeof(label_size_out));
}
| 1threat
|
static always_inline void gen_load_mem (DisasContext *ctx,
void (*tcg_gen_qemu_load)(TCGv t0, TCGv t1, int flags),
int ra, int rb, int32_t disp16,
int fp, int clear)
{
TCGv addr;
if (unlikely(ra == 31))
return;
addr = tcg_temp_new(TCG_TYPE_I64);
if (rb != 31) {
tcg_gen_addi_i64(addr, cpu_ir[rb], disp16);
if (clear)
tcg_gen_andi_i64(addr, addr, ~0x7);
} else {
if (clear)
disp16 &= ~0x7;
tcg_gen_movi_i64(addr, disp16);
}
if (fp)
tcg_gen_qemu_load(cpu_fir[ra], addr, ctx->mem_idx);
else
tcg_gen_qemu_load(cpu_ir[ra], addr, ctx->mem_idx);
tcg_temp_free(addr);
}
| 1threat
|
callback(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time)
{
AVFormatContext *s = priv_data;
struct dshow_ctx *ctx = s->priv_data;
AVPacketList **ppktl, *pktl_next;
WaitForSingleObject(ctx->mutex, INFINITE);
if(shall_we_drop(s, index))
goto fail;
pktl_next = av_mallocz(sizeof(AVPacketList));
if(!pktl_next)
goto fail;
if(av_new_packet(&pktl_next->pkt, buf_size) < 0) {
av_free(pktl_next);
goto fail;
}
pktl_next->pkt.stream_index = index;
pktl_next->pkt.pts = time;
memcpy(pktl_next->pkt.data, buf, buf_size);
for(ppktl = &ctx->pktl ; *ppktl ; ppktl = &(*ppktl)->next);
*ppktl = pktl_next;
ctx->curbufsize[index] += buf_size;
SetEvent(ctx->event[1]);
ReleaseMutex(ctx->mutex);
return;
fail:
ReleaseMutex(ctx->mutex);
return;
}
| 1threat
|
document.write('<script src="evil.js"></script>');
| 1threat
|
How to define an opaque type in TypeScript? : <p>If I recall correctly, in C++ you can define an an opaque type like this ...</p>
<pre><code>class Foo;
</code></pre>
<p>... and use it like a handle e.g. when declaring function signatures ...</p>
<pre><code>void printFoo(const Foo& foo);
</code></pre>
<p>Application code might then work with references-to-Foo or pointers-to-Foo without seeing the actual definition of Foo.</p>
<p>Is there anything similar in TypeScript -- how would you define an opaque type?</p>
<p>My problem is that if I define this ...</p>
<pre><code>interface Foo {};
</code></pre>
<p>... then that's freely interchangeable with other similar types. Is there an idiom?</p>
| 0debug
|
ag-grid auto height for entire grid : <p>I can't find a good way to size the grid to fit all rows perfectly.</p>
<p><a href="https://www.ag-grid.com/javascript-grid-width-and-height/#gsc.tab=0" rel="noreferrer">documentation</a> only points to sizing by % or px. </p>
<p>Since I want it to size based on rows, I came up with the following function. Seem like im re-inventing the wheel, so maybe there is a better way? </p>
<pre><code>getHeight(type:EntityType) {
var c = this.Apis[type] && this.Apis[type].api && this.Apis[type].api.rowModel // get api for current grid
? this.Apis[type].api.rowModel.rowsToDisplay.length
: -1;
return c > 0
? (40+(c*21))+'px' // not perfect but close formula for grid height
: '86%';
}
</code></pre>
<p>there has to be a less messy way..</p>
| 0debug
|
Labeling boxplot in seaborn with median value : <p>How can I label each boxplot in a seaborn plot with the median value?</p>
<p>E.g.</p>
<pre><code>import seaborn as sns
sns.set_style("whitegrid")
tips = sns.load_dataset("tips")
ax = sns.boxplot(x="day", y="total_bill", data=tips)
</code></pre>
<p>How do I label each boxplot with the median or average value?</p>
| 0debug
|
static int vnc_display_listen_addr(VncDisplay *vd,
SocketAddress *addr,
const char *name,
QIOChannelSocket ***lsock,
guint **lsock_tag,
size_t *nlsock,
Error **errp)
{
QIODNSResolver *resolver = qio_dns_resolver_get_instance();
SocketAddress **rawaddrs = NULL;
size_t nrawaddrs = 0;
Error *listenerr = NULL;
bool listening = false;
size_t i;
if (qio_dns_resolver_lookup_sync(resolver, addr, &nrawaddrs,
&rawaddrs, errp) < 0) {
return -1;
}
for (i = 0; i < nrawaddrs; i++) {
QIOChannelSocket *sioc = qio_channel_socket_new();
qio_channel_set_name(QIO_CHANNEL(sioc), name);
if (qio_channel_socket_listen_sync(
sioc, rawaddrs[i], listenerr == NULL ? &listenerr : NULL) < 0) {
continue;
}
listening = true;
(*nlsock)++;
*lsock = g_renew(QIOChannelSocket *, *lsock, *nlsock);
*lsock_tag = g_renew(guint, *lsock_tag, *nlsock);
(*lsock)[*nlsock - 1] = sioc;
(*lsock_tag)[*nlsock - 1] = 0;
}
for (i = 0; i < nrawaddrs; i++) {
qapi_free_SocketAddress(rawaddrs[i]);
}
g_free(rawaddrs);
if (listenerr) {
if (!listening) {
error_propagate(errp, listenerr);
return -1;
} else {
error_free(listenerr);
}
}
for (i = 0; i < *nlsock; i++) {
(*lsock_tag)[i] = qio_channel_add_watch(
QIO_CHANNEL((*lsock)[i]),
G_IO_IN, vnc_listen_io, vd, NULL);
}
return 0;
}
| 1threat
|
document.write('<script src="evil.js"></script>');
| 1threat
|
MySQL/PHP: How to do Subscriptions/Joining : <p>In my app a user can create an event and with those events a specified number of people can join.</p>
<p>The best way I can think of is to have columns named something like joined1, joined2, joined3 .. and so on and input the ID number of the user that joined in that column.</p>
<p>My question is how can I input the user ID into a joined spot that is not taken? The number of the joined spot isn't important but having access to the User IDs are. </p>
<p>Thanks for the help!</p>
| 0debug
|
static int xwma_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
int64_t size, av_uninit(data_size);
uint32_t dpds_table_size = 0;
uint32_t *dpds_table = 0;
unsigned int tag;
AVIOContext *pb = s->pb;
AVStream *st;
XWMAContext *xwma = s->priv_data;
int i;
tag = avio_rl32(pb);
if (tag != MKTAG('R', 'I', 'F', 'F'))
return -1;
avio_rl32(pb);
tag = avio_rl32(pb);
if (tag != MKTAG('X', 'W', 'M', 'A'))
return -1;
tag = avio_rl32(pb);
if (tag != MKTAG('f', 'm', 't', ' '))
return -1;
size = avio_rl32(pb);
st = av_new_stream(s, 0);
if (!st)
return AVERROR(ENOMEM);
ff_get_wav_header(pb, st->codec, size);
st->need_parsing = AVSTREAM_PARSE_NONE;
if (st->codec->codec_id != CODEC_ID_WMAV2) {
av_log(s, AV_LOG_WARNING, "unexpected codec (tag 0x04%x; id %d)\n",
st->codec->codec_tag, st->codec->codec_id);
av_log_ask_for_sample(s, NULL);
} else {
if (st->codec->extradata_size != 0) {
av_log(s, AV_LOG_WARNING, "unexpected extradata (%d bytes)\n",
st->codec->extradata_size);
av_log_ask_for_sample(s, NULL);
} else {
st->codec->extradata_size = 6;
st->codec->extradata = av_mallocz(6 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata[4] = 31;
}
}
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
for (;;) {
if (pb->eof_reached)
return -1;
tag = avio_rl32(pb);
size = avio_rl32(pb);
if (tag == MKTAG('d', 'a', 't', 'a')) {
break;
} else if (tag == MKTAG('d','p','d','s')) {
if (dpds_table) {
av_log(s, AV_LOG_ERROR, "two dpds chunks present\n");
return -1;
}
if (size & 3) {
av_log(s, AV_LOG_WARNING, "dpds chunk size "PRId64" not divisible by 4\n", size);
}
dpds_table_size = size / 4;
if (dpds_table_size == 0 || dpds_table_size >= INT_MAX / 4) {
av_log(s, AV_LOG_ERROR, "dpds chunk size "PRId64" invalid\n", size);
return -1;
}
dpds_table = av_malloc(dpds_table_size * sizeof(uint32_t));
if (!dpds_table) {
return AVERROR(ENOMEM);
}
for (i = 0; i < dpds_table_size; ++i) {
dpds_table[i] = avio_rl32(pb);
size -= 4;
}
}
avio_skip(pb, size);
}
if (size < 0)
return -1;
if (!size) {
xwma->data_end = INT64_MAX;
} else
xwma->data_end = avio_tell(pb) + size;
if (dpds_table && dpds_table_size) {
int64_t cur_pos;
const uint32_t bytes_per_sample
= (st->codec->channels * st->codec->bits_per_coded_sample) >> 3;
const uint64_t total_decoded_bytes = dpds_table[dpds_table_size - 1];
st->duration = total_decoded_bytes / bytes_per_sample;
cur_pos = avio_tell(pb);
for (i = 0; i < dpds_table_size; ++i) {
av_add_index_entry(st,
cur_pos + (i+1) * st->codec->block_align,
dpds_table[i] / bytes_per_sample,
st->codec->block_align,
0,
AVINDEX_KEYFRAME);
}
} else if (st->codec->bit_rate) {
st->duration = (size<<3) * st->codec->sample_rate / st->codec->bit_rate;
}
av_free(dpds_table);
return 0;
}
| 1threat
|
Django contrib admin default admin and password : <p>This may be a silly question. I start a new Django project as Document says, which only included an admin page. I start the server and use a web browser accessing the page. What can I enter in the username and password? Is their any place for me to config the default admin account?</p>
| 0debug
|
static void coroutine_fn bdrv_flush_co_entry(void *opaque)
{
RwCo *rwco = opaque;
rwco->ret = bdrv_co_flush(rwco->bs);
}
| 1threat
|
i want to sort this list in python from a file :
def insertionSort(a):
for i in range(1, len(a)): #outloop covering the range
value = a[i] #value = to list, which will compare items to the left
i = i - 1 #i goes lower than index to comapre futher to the left
while i >= 0 : #keep comparing till its at the begining of the list
if value < a[i]: #if value is less than i
a[i+1] = a[i] # shift number in right i to slot i + 1
a[i] = value # shift value that was left into slot i
i = i - 1
else:
break
infile = open("file1.txt", "r")
a=[]
for aline in infile:
a = aline.split()
insertionSort(a)
print(a)
this is what it is in the file
7686850495948548545
how do i get the insertionSort function to work on file?
| 0debug
|
How Can I Rewrite Without Stod() : <p>How can I rewrite my <strong>readDetails</strong> function without using <strong>stod()</strong> or <strong>strtod()</strong> in <strong>C++</strong>?
The compiler I will be using doesn't have c++11 enabled and I get</p>
<p>'stod' was not declared in this scope error</p>
<pre><code>int readDetails(SmallRestaurant sr[])
{
//Declaration
ifstream inf;
//Open file
inf.open("pop_density.txt");
//Check condition
if (!inf)
{
//Display
cout << "Input file is not found!" << endl;
//Pause
system("pause");
//Exit on failure
exit(EXIT_FAILURE);
}
//Declarations and initializations
string fLine;
int counter = 0;
int loc = -1;
//Read
getline(inf, fLine);
//Loop
while (inf)
{
//File read
loc = fLine.find('|');
sr[counter].nameInFile = fLine.substr(0, loc);
fLine = fLine.substr(loc + 1);
loc = fLine.find('|');
sr[counter].areaInFile = stod(fLine.substr(0, loc)); //line using stod
fLine = fLine.substr(loc + 1);
loc = fLine.find('|');
sr[counter].popInFile = stoi(fLine.substr(0, loc));
fLine = fLine.substr(loc + 1);
sr[counter].densityInFile = stod(fLine); //line using stod
counter++;
getline(inf, fLine);
}
//Return
return counter;
}
</code></pre>
<p>Below is the text I am trying to read:</p>
<p>Census Tract 201, Autauga County, Alabama|9.84473419420788|1808|183.651479494869
Census Tract 202, Autauga County, Alabama|3.34583234555866|2355|703.860730836106
Census Tract 203, Autauga County, Alabama|5.35750339330735|3057|570.60159846447</p>
| 0debug
|
void nbd_export_close(NBDExport *exp)
{
NBDClient *client, *next;
nbd_export_get(exp);
QTAILQ_FOREACH_SAFE(client, &exp->clients, next, next) {
client_close(client);
}
nbd_export_set_name(exp, NULL);
nbd_export_put(exp);
if (exp->blk) {
blk_remove_aio_context_notifier(exp->blk, blk_aio_attached,
blk_aio_detach, exp);
blk_unref(exp->blk);
exp->blk = NULL;
}
}
| 1threat
|
How to plot two pandas time series on same plot with legends and secondary y-axis? : <p>I want to plot two time series on the same plot with same x-axis and secondary y-axis. I have somehow achieved this, but two legends are overlapping and is unable to give label to x-axis and secondary y-axis.I tried putting two legend at upper-left and upper-right, but it is still not working. </p>
<p>Code:</p>
<pre><code>plt.figure(figsize=(12,5))
# Number of request every 10 minutes
log_10minutely_count_Series = log_df['IP'].resample('10min').count()
log_10minutely_count_Series.name="Count"
log_10minutely_count_Series.plot(color='blue', grid=True)
plt.legend(loc='upper left')
plt.xlabel('Number of request ever 10 minute')
# Sum of response size over each 10 minute
log_10minutely_sum_Series = log_df['Bytes'].resample('10min').sum()
log_10minutely_sum_Series.name = 'Sum'
log_10minutely_sum_Series.plot(color='red',grid=True, secondary_y=True)
plt.legend(loc='upper right')
plt.show()
</code></pre>
<p><a href="https://i.stack.imgur.com/BCJEz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BCJEz.png" alt="enter image description here"></a></p>
<p>Thanks in advance</p>
| 0debug
|
static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
int buf_size, void *data)
{
const AVFrame *pic = data;
int aligned_width = ((avctx->width + 47) / 48) * 48;
int stride = aligned_width * 8 / 3;
int h, w;
const uint16_t *y = (const uint16_t*)pic->data[0];
const uint16_t *u = (const uint16_t*)pic->data[1];
const uint16_t *v = (const uint16_t*)pic->data[2];
uint8_t *p = buf;
uint8_t *pdst = buf;
if (buf_size < aligned_width * avctx->height * 8 / 3) {
av_log(avctx, AV_LOG_ERROR, "output buffer too small\n");
return -1;
}
#define CLIP(v) av_clip(v, 4, 1019)
#define WRITE_PIXELS(a, b, c) \
do { \
val = CLIP(*a++); \
val |= (CLIP(*b++) << 10) | \
(CLIP(*c++) << 20); \
bytestream_put_le32(&p, val); \
} while (0)
for (h = 0; h < avctx->height; h++) {
uint32_t val;
for (w = 0; w < avctx->width - 5; w += 6) {
WRITE_PIXELS(u, y, v);
WRITE_PIXELS(y, u, y);
WRITE_PIXELS(v, y, u);
WRITE_PIXELS(y, v, y);
}
if (w < avctx->width - 1) {
WRITE_PIXELS(u, y, v);
val = CLIP(*y++);
if (w == avctx->width - 2)
bytestream_put_le32(&p, val);
}
if (w < avctx->width - 3) {
val |= (CLIP(*u++) << 10) | (CLIP(*y++) << 20);
bytestream_put_le32(&p, val);
val = CLIP(*v++) | (CLIP(*y++) << 10);
bytestream_put_le32(&p, val);
}
pdst += stride;
memset(p, 0, pdst - p);
p = pdst;
y += pic->linesize[0] / 2 - avctx->width;
u += pic->linesize[1] / 2 - avctx->width / 2;
v += pic->linesize[2] / 2 - avctx->width / 2;
}
return p - buf;
}
| 1threat
|
ESLint - Component should be written as a pure function (react prefer/stateless function) : <p>ESLint is giving me this error on a react project. </p>
<p><em>ESLint - Component should be written as a pure function (react prefer/stateless function)</em></p>
<p>It points to the first line of the component.</p>
<pre><code>export class myComponent extends React.Component {
render() {
return (
//stuff here
);
}
}
</code></pre>
<p>How do I get rid of this error?</p>
| 0debug
|
why saying $exception {"Incorrect syntax near ','."} System.Exception {System.Data.SqlClient.SqlException} :
Incorrect syntax near ',' exception arises when application is set to
run.
in sql server management studio qury is running fine. but it gives an
exception while application is set to run.
here is my code:
USE [PBSM]
GO
/****** Object: StoredProcedure [dbo].[month_wise_pending_details] Script Date: 09-05-2017 11:26:10 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[month_wise_pending_details]
@month int = 4, @year int =2017
as
begin
set nocount on;
SELECT P.PbsName
,pc.CauseName
,dbo.F_CONVERT_ENG_NUMBER_TO_BNG(PCI.DayFrom)+N'/'+dbo.F_CONVERT_ENG_NUMBER_TO_BNG(PCI.MonthFrom)+N'/'+dbo.F_CONVERT_ENG_NUMBER_TO_BNG(PCI.YearFrom)+N'থেকে'+dbo.F_CONVERT_ENG_NUMBER_TO_BNG(PCI.DayTo)+N'/'+dbo.F_CONVERT_ENG_NUMBER_TO_BNG(PCI.MonthTo)+N'/'+dbo.F_CONVERT_ENG_NUMBER_TO_BNG(PCI.YearTo) 'Date'
,PCI.Remarks
FROM Pbs P
INNER JOIN ProbableConnectionInfo PCI ON PCI.PbsId=P.PbsId
inner join ConnectionPendingCause cpc on pci.Id=cpc.ProbableConnectionId
inner join PendingCause pc on cpc.PendingCauseId=pc.Id
WHERE pci.Month=@month and Year=@year and cpc.PendingNumber>0
select dbo.F_CONVERT_ENG_NUMBER_TO_BNG(sum(ic.Pending)) 'PendingApplication'
, dbo.F_CONVERT_ENG_NUMBER_TO_BNG(sum(ic.loadNeed)) 'AppliedLoadAmount'
from IndustrialConnection ic
inner join ProbableConnectionInfo pci on ic.ProbableConnectionId=pci.Id
where pci.Month=@month and year=@year
group by pci.PbsId
set nocount off;
end
and here where the problem is showing:
namespace PBSM.DBGateway
{
public class SPService
{
private static string connectionString = ConfigurationManager.ConnectionStrings["Connection"].ConnectionString;
private static SqlConnection sqlConnection = new SqlConnection(connectionString);
public static DataTable GetDataByStoredProcedure(string spName)
{
sqlConnection.Open();
var sqlCommand = new SqlCommand(spName, sqlConnection);
var dataReader = sqlCommand.ExecuteReader();
var dt = new DataTable("Command");
dt.Load(dataReader);
sqlConnection.Close();
return dt;
}
}
}
| 0debug
|
Conversion of doubles to int : <p>A project I have requires the movement of a player at a coordinate using getX and getY, however, I am confused on how to convert getX and getY from a double to an int so i can play them in the drawing panel. </p>
| 0debug
|
static unsigned tget_long(const uint8_t **p, int le)
{
unsigned v = le ? AV_RL32(*p) : AV_RB32(*p);
*p += 4;
return v;
}
| 1threat
|
how to creat download and install link for ipa file? : How can I put my ipa file on my personal server, as a php link to other users, by clicking the download link and installing the program on Safari?
i whant creat download ipa link in php code.
plz help me.
tank you.
| 0debug
|
Does jQuery's html() method auto-join the argument if it's an array? : <p>While experimenting, I came across this.</p>
<pre><code><div id="result"></div>
<script type="text/javascript">
$('#result').html(['<p>This is inside an array</p>', '<em>This is second item in array</em>']);
</script>
</code></pre>
<p>When the page was reneded, I could see the following markup in the browser console:</p>
<pre><code><div id="result">
<p>This is inside an array</p>
<em>This is second item in array</em>
</div>
</code></pre>
<p>Does this mean that jQuery is running <code>array.join("")</code> in the background if the argument/parameter supplied to the .<code>html()</code> method is an array?</p>
<p>I couldn't find this mentioned in the documentation and hence was curious to know more on this.</p>
| 0debug
|
Social Media Icons disappeared on my Online Website while they appeared on my offline website : <p>Social Media Icons disappeared on my Online Website while they appeared on my offline website:</p>
<p><a href="https://i.stack.imgur.com/PU3l7.png" rel="nofollow noreferrer">Icons appear in yellow circles in my Offline Website</a></p>
<p><a href="https://i.stack.imgur.com/SbSRk.png" rel="nofollow noreferrer">Icons disappear in yellow circles in my Online Website</a></p>
| 0debug
|
static inline void gen_cmps(DisasContext *s, int ot)
{
gen_string_movl_A0_ESI(s);
gen_op_ld_T0_A0(ot + s->mem_index);
gen_string_movl_A0_EDI(s);
gen_op_ld_T1_A0(ot + s->mem_index);
gen_op_cmpl_T0_T1_cc();
gen_op_movl_T0_Dshift[ot]();
#ifdef TARGET_X86_64
if (s->aflag == 2) {
gen_op_addq_ESI_T0();
gen_op_addq_EDI_T0();
} else
#endif
if (s->aflag) {
gen_op_addl_ESI_T0();
gen_op_addl_EDI_T0();
} else {
gen_op_addw_ESI_T0();
gen_op_addw_EDI_T0();
}
}
| 1threat
|
regex in body of api test : Im testing api with https://cloud.google.com/datastore/docs/reference/data/rest/v1/projects/lookup
The following brings a found result with data. I would like to use a regex expression with bring back all records with name having the number 100867. All my attempts result wit a missing result set.
i.e. change to "name": "/1000867.*/"
` {
"keys": [
{
"path": [
{
"kind": "Job",
"name": "1000867:100071805:1"
}
]
}
]
}`
| 0debug
|
static void memory_region_write_accessor(MemoryRegion *mr,
hwaddr addr,
uint64_t *value,
unsigned size,
unsigned shift,
uint64_t mask)
{
uint64_t tmp;
if (mr->flush_coalesced_mmio) {
qemu_flush_coalesced_mmio_buffer();
}
tmp = (*value >> shift) & mask;
trace_memory_region_ops_write(mr, addr, tmp, size);
mr->ops->write(mr->opaque, addr, tmp, size);
}
| 1threat
|
Get Byte Array From Image in ImageView Android : <p>I have uploaded an image from my app to server and displayed that image in imageview. An error occurs when I want to re-upload the existing image in imageview to server. Shows this error:</p>
<pre><code>ava.lang.NullPointerException: Attempt to get length of null array
at com.billionusers.tingting.activities.MyPictureActivity$3.onClick(MyPictureActivity.java:145)
at android.view.View.performClick(View.java:5690)
at android.view.View$PerformClick.run(View.java:22693)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6269)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
</code></pre>
<p>My code so far:</p>
<pre><code>uploadTV.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Drawable avatar_drawable = new BitmapDrawable(getResources(), decBitmap);
if (userImage.getDrawable() != null){ //I'm trying to check if imageview has image or not
Intent editProfileIntent = null;
if (userImage.getDrawable() == avatar_drawable || imgBytes.length == 0) { // error occurs here. I'm trying to check if imageview's image is same as retrieved image
Bitmap imageViewBitmap = ((BitmapDrawable) userImage.getDrawable()).getBitmap();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
imageViewBitmap.compress(Bitmap.CompressFormat.PNG, 10, baos);
imgBytes = baos.toByteArray();
upLoadImageBytes(imgBytes);
editProfileIntent = new Intent(MyPictureActivity.this, EditProfileActivity.class);
startActivity(editProfileIntent);
}
} else {
Snackbar.make(findViewById(android.R.id.content), "Select an Image From Camera or Gallery", Snackbar.LENGTH_LONG).show();
}
}
});
</code></pre>
<p>Method to upload image via retrofit, works well:</p>
<pre><code>private void upLoadImageBytes(byte[] imgBytes) {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.addInterceptor(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request originalReq = chain.request();
Request request = originalReq.newBuilder()
.addHeader("x-access-token", key_token)
.method(originalReq.method(), originalReq.body())
.build();
return chain.proceed(request);
}
});
OkHttpClient client = builder.build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Constants.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.client(client)
.build();
ImageService anInterface = retrofit.create(ImageService.class);
RequestBody imageFileBody = RequestBody.create(MediaType.parse("image/*"), imgBytes);
MultipartBody.Part partBody = MultipartBody.Part.createFormData("avatar", "avatar.jpg", imageFileBody);
Call<ImageResponse> imageCall = anInterface.upLoadImage(partBody);
imageCall.enqueue(new Callback<ImageResponse>() {
@Override
public void onResponse(Call<ImageResponse> call, retrofit2.Response<ImageResponse> response) {
Log.d(TAG, "Response body is:\t" + response.body().toString());
}
@Override
public void onFailure(Call<ImageResponse> call, Throwable t) {
Log.d(TAG, "Response error message is:\t" + t.getMessage().toString());
}
});
}
</code></pre>
<p>PS: What I'm trying to do is to re-upload the image contained in my imageview when the button is clicked. Can someone say what's wrong pls? Thanks</p>
| 0debug
|
C++ and Angular 6 proper 2 way communication : I'm having some troubles finding a good way to stablish a communication between my frontend and my backend.
I have a C++ app that deals with the communication with some device, I'd like that my webpage gets the request from the user, then send that request to my always running C++ app, process that request, and then send a response back to my webpage, is there any way to make this happen?
| 0debug
|
PHP Header = Location in a different folder in directory : <p>If I had a page inside of an includes folder but wanted a <code>header("location: dashboard.php");</code> to redirect out of the folder into the main directory, how would I do this?</p>
<p>I want to come out of two folders to the main directory.</p>
| 0debug
|
XMLHttpRequest cannot load and Response for preflight has invalid HTTP status code 405 : <p>I am using ionic framework and angularjs I use chrome for viewing my logs but here i am doing a login page I am trying to post the user entered data to serve but i am getting this error like .</p>
<pre><code> OPTIONS http://aflaree.com/qrcodeservice/Service1.svc/login
</code></pre>
<p>and this one is next error <code>XMLHttpRequest cannot load http://aflaree.com/qrcodeservice/Service1.svc/login Response for preflight has invalid HTTP status code 405</code>
after reading some blog i figure there is a CORS extention from from which allows ajax request i tried that also but i am not able to find why this two error is appearing. here is my code</p>
<p><a href="https://plnkr.co/edit/Dz0aFsLqoQcnCxht00z3?p=preview">https://plnkr.co/edit/Dz0aFsLqoQcnCxht00z3?p=preview</a></p>
<p>my code work fine in device but I am getting error in chrome if any one knows why please help me</p>
| 0debug
|
Bioperl - how can i print first result of search sequence per iteration? : use Bio::DB::GenBank;
use Bio::DB::Query::GenBank;
$query = "LEGK";
$query_obj = Bio::DB::Query::GenBank->new(-db => 'protein',
-query => $query );
$gb_obj = Bio::DB::GenBank->new;
$stream_obj = $gb_obj->get_Stream_by_query($query_obj);
while ($seq_obj = $stream_obj->next_seq) {
# do something with the sequence object
print ">$query",' ', $seq_obj->display_id, ' ', $seq_obj->desc,"\n", $seq_obj->seq[,'\n';
hey. How can i print first occurrence of protein sequence?
| 0debug
|
.NET WebSockets forcibly closed despite keep-alive and activity on the connection : <p>We have written a simple WebSocket client using System.Net.WebSockets. The KeepAliveInterval on the ClientWebSocket is set to 30 seconds.</p>
<p>The connection is opened successfully and traffic flows as expected in both directions, or if the connection is idle, the client sends Pong requests every 30 seconds to the server (visible in Wireshark).</p>
<p>But after 100 seconds the connection is abruptly terminated due to the TCP socket being closed at the client end (watching in Wireshark we see the client send a FIN). The server responds with a 1001 Going Away before closing the socket.</p>
<p>After a lot of digging we have tracked down the cause and found a rather heavy-handed workaround. Despite a lot of Google and Stack Overflow searching we have only seen a couple of other examples of people posting about the problem and nobody with an answer, so I'm posting this to save others the pain and in the hope that someone may be able to suggest a better workaround.</p>
<p>The source of the 100 second timeout is that the WebSocket uses a System.Net.ServicePoint, which has a MaxIdleTime property to allow idle sockets to be closed. On opening the WebSocket if there is an existing ServicePoint for the Uri it will use that, with whatever the MaxIdleTime property was set to on creation. If not, a new ServicePoint instance will be created, with MaxIdleTime set from the current value of the System.Net.ServicePointManager MaxServicePointIdleTime property (which defaults to 100,000 milliseconds).</p>
<p>The issue is that neither WebSocket traffic nor WebSocket keep-alives (Ping/Pong) appear to register as traffic as far as the ServicePoint idle timer is concerned. So exactly 100 seconds after opening the WebSocket it just gets torn down, despite traffic or keep-alives.</p>
<p>Our hunch is that this may be because the WebSocket starts life as an HTTP request which is then upgraded to a websocket. It appears that the idle timer is only looking for HTTP traffic. If that is indeed what is happening that seems like a major bug in the System.Net.WebSockets implementation.</p>
<p>The workaround we are using is to set the MaxIdleTime on the ServicePoint to int.MaxValue. This allows the WebSocket to stay open indefinitely. But the downside is that this value applies to any other connections for that ServicePoint. In our context (which is a Load test using Visual Studio Web and Load testing) we have other (HTTP) connections open for the same ServicePoint, and in fact there is already an active ServicePoint instance by the time that we open our WebSocket. This means that after we update the MaxIdleTime, all HTTP connections for the Load test will have no idle timeout. This doesn't feel quite comfortable, although in practice the web server should be closing idle connections anyway.</p>
<p>We also briefly explore whether we could create a new ServicePoint instance reserved just for our WebSocket connection, but couldn't see a clean way of doing that.</p>
<p>One other little twist which made this harder to track down is that although the System.Net.ServicePointManager MaxServicePointIdleTime property defaults to 100 seconds, Visual Studio is overriding this value and setting it to 120 seconds - which made it harder to search for.</p>
| 0debug
|
static void nvdimm_dsm_root(NvdimmDsmIn *in, hwaddr dsm_mem_addr)
{
if (!in->function) {
nvdimm_dsm_function0(0
, dsm_mem_addr);
return;
}
nvdimm_dsm_no_payload(1 , dsm_mem_addr);
}
| 1threat
|
static void host_memory_backend_init(Object *obj)
{
HostMemoryBackend *backend = MEMORY_BACKEND(obj);
backend->merge = qemu_opt_get_bool(qemu_get_machine_opts(),
"mem-merge", true);
backend->dump = qemu_opt_get_bool(qemu_get_machine_opts(),
"dump-guest-core", true);
backend->prealloc = mem_prealloc;
object_property_add_bool(obj, "merge",
host_memory_backend_get_merge,
host_memory_backend_set_merge, NULL);
object_property_add_bool(obj, "dump",
host_memory_backend_get_dump,
host_memory_backend_set_dump, NULL);
object_property_add_bool(obj, "prealloc",
host_memory_backend_get_prealloc,
host_memory_backend_set_prealloc, NULL);
object_property_add(obj, "size", "int",
host_memory_backend_get_size,
host_memory_backend_set_size, NULL, NULL, NULL);
object_property_add(obj, "host-nodes", "int",
host_memory_backend_get_host_nodes,
host_memory_backend_set_host_nodes, NULL, NULL, NULL);
object_property_add_enum(obj, "policy", "HostMemPolicy",
HostMemPolicy_lookup,
host_memory_backend_get_policy,
host_memory_backend_set_policy, NULL);
}
| 1threat
|
Why my image is not displayed? : <p></p>
<pre><code><div class "nuhoLogo">
<a class "nuhoLogo" href="http://www.nuho.com">
</code></pre>
<p>//should't this path always work?</p>
<pre><code> <img src="C:/Users/Chibas/Desktop/html/MyWebSite/Logo/logo.gif" border="0" width="100" height="80" alt ="nuho-logo"/>
</a>
</div>
</code></pre>
| 0debug
|
What is the difference between Socket and RPC? : <p>What is the actual difference between Socket and RPC (Remote Procedure Call)?</p>
<p>As per my understanding both's working is based on <a href="https://en.wikipedia.org/wiki/Client%E2%80%93server_model" rel="noreferrer">Client–server model</a>. Also which one should be used in which conditions?</p>
<p>PS: Confusion arise while reading <a href="https://www.amazon.in/dp/8126520515/ref=pd_lpo_sbs_dp_ss_2?pf_rd_p=733112647&pf_rd_s=lpo-top-stripe&pf_rd_t=201&pf_rd_i=0470233990&pf_rd_m=A1VBAL9TL5WCBF&pf_rd_r=8JW67WP6F3CD4HHV4WWE" rel="noreferrer">Operating System Concepts by Galvin </a></p>
| 0debug
|
Does Pandas calculate ewm wrong? : <p>When trying to calculate the exponential moving average (EMA) from financial data in a dataframe it seems that Pandas' ewm approach is incorrect.</p>
<p>The basics are well explained in the following link:
<a href="http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:moving_averages" rel="noreferrer">http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:moving_averages</a></p>
<p>When going to Pandas explanation, the approach taken is as follows (using the "adjust" parameter as False):</p>
<pre><code> weighted_average[0] = arg[0];
weighted_average[i] = (1-alpha) * weighted_average[i-1] + alpha * arg[i]
</code></pre>
<p>This in my view is incorrect. The "arg" should be (for example) the closing values, however, arg[0] is the first average (i.e. the simple average of the first series of data of the length of the period selected), but NOT the first closing value. arg[0] and arg[i] can therefore never be from the same data. Using the "min_periods" parameter does not seem to resolve this.</p>
<p>Can anyone explain me how (or if) Pandas can be used to properly calculate the EMA of data?</p>
| 0debug
|
docker-compose creating multiple instances for the same image : <p>I need to start multiple containers for the same image. If i create my compose file as shown below, it works fine. </p>
<pre><code>version: '2'
services:
app01:
image: app
app02:
image: app
app03:
image: app
app04:
image: app
app05:
image: app
</code></pre>
<p>Is there any easy way for me to mention the number of instances for the compose instead of copy and pasting multiple times?</p>
| 0debug
|
how to add NixOS unstable channel declaratively in configuration.nix : <p>The NixOS cheatsheet describes how to install packages from <code>unstable</code> in <code>configuration.nix</code>.</p>
<p>It starts off by saying to add the unstable channel like so:</p>
<pre><code>$ sudo nix-channel --add https://nixos.org/channels/nixpkgs-unstable
$ sudo nix-channel --update
</code></pre>
<p>Then, it is easy to use this channel in <code>configuration.nix</code> (since it should now be on <code>NIX_PATH</code>):</p>
<pre><code>nixpkgs.config = {
allowUnfree = true;
packageOverrides = pkgs: {
unstable = import <nixos-unstable> {
config = config.nixpkgs.config;
};
};
};
environment = {
systemPackages = with pkgs; [
unstable.google-chrome
];
};
</code></pre>
<hr>
<p>I would like to not have to do the manual <code>nix-channel --add</code> and <code>nix-channel --update</code> steps. </p>
<p>I would like to be able to install my system from <code>configuration.nix</code> without first having to run the <code>nix-channel --add</code> and <code>nix-channel --update</code> steps.</p>
<p>Is there a way to automate this from <code>configuration.nix</code>?</p>
| 0debug
|
code signature in (/xxxxx) not valid for use in process using Library Validation : <p>I'm trying to build proxychains with xcode 8. When I run a program I got:</p>
<pre><code>/usr/local/homebrew/Cellar/proxychains-ng/4.11/lib/libproxychains4.dylib: code signing blocked mmap() of '/usr/local/homebrew/Cellar/proxychains-ng/4.11/lib/libproxychains4.dylib'
</code></pre>
<p>When I signed the program and library:</p>
<pre><code>codesign -s "Mac Developer: xxxx" `which proxychains`
codesign -s "Mac Developer: xxxx" /usr/local/homebrew/Cellar/proxychains-ng/4.11/lib/libproxychains4.dylib
</code></pre>
<p>No errors, but when I run it again, it says</p>
<pre><code>/usr/local/homebrew/Cellar/proxychains-ng/4.11/lib/libproxychains4.dylib: code signature in (/usr/local/homebrew/Cellar/proxychains-ng/4.11/lib/libproxychains4.dylib) not valid for use in process using Library Validation: mapping process is a platform binary, but mapped file is not
</code></pre>
<p>What should I do now? Do I need some sort of entitlements?</p>
| 0debug
|
Unable to telnet to localhost : <p>While trying to telnet to localhost I get the below error</p>
<pre><code>telnet localhost 32768
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
Trying ::1...
telnet: connect to address ::1: Network is unreachable
</code></pre>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.