problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static void tcp_chr_tls_init(CharDriverState *chr)
{
TCPCharDriver *s = chr->opaque;
QIOChannelTLS *tioc;
Error *err = NULL;
if (s->is_listen) {
tioc = qio_channel_tls_new_server(
s->ioc, s->tls_creds,
NULL,
&err);
} else {
tioc = qio_channel_tls_new_client(
s->ioc, s->tls_creds,
s->addr->u.inet.data->host,
&err);
}
if (tioc == NULL) {
error_free(err);
tcp_chr_disconnect(chr);
}
object_unref(OBJECT(s->ioc));
s->ioc = QIO_CHANNEL(tioc);
qio_channel_tls_handshake(tioc,
tcp_chr_tls_handshake,
chr,
NULL);
}
| 1threat
|
System.Web.Mvc.HttpPostAttribute vs System.Web.Http.HttpPostAttribute? : <p>In my Web API project which is based on the ASP.NET MVC, I want to use the <code>HttpPost</code> attribute. When I've added that onto the action, The IntelliSense suggests me these two namespaces:</p>
<ul>
<li><strong>System.Web.Mvc.HttpPostAttribute</strong></li>
<li><strong>System.Web.Http.HttpPostAttribute</strong></li>
</ul>
<p>Which one should be used and why?</p>
| 0debug
|
static void gen_add_carry(TCGv dest, TCGv t0, TCGv t1)
{
TCGv tmp;
tcg_gen_add_i32(dest, t0, t1);
tmp = load_cpu_field(CF);
tcg_gen_add_i32(dest, dest, tmp);
dead_tmp(tmp);
}
| 1threat
|
Java Scanner Input , there are no compilation errors neither successfull input :
The Following code is a simple java program where i am just getting an input of a student details but the program doesnt do anything it just stays like this no compilation error or does not take any input
import java.util.Scanner;
public class Scannerexample {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int Rollno = scan.nextInt();
String firstname = scan.nextLine();
String lastname = scan.nextLine();
String Department = scan.nextLine();
Boolean Result = scan.hasNext();
char gender = scan.next().charAt(0);
System.out.println("Enter Rollno "+ Rollno);
System.out.println("Enter Firstname "+ firstname);
System.out.println("Enter Lastname "+ lastname);
System.out.println("Enter Department "+ Department);
System.out.println("Enter Result "+ Result);
System.out.println("Enter Gender "+ gender);
scan.close();
}
}
| 0debug
|
How to use boostrap scrollspy on angular 7 project? : I have transform basic html page with boostrap scrollspy component and my nav doesn't work (no change when page scroll).
I have install boostrap 4 with the command below :
npm install boostrap
There is no change on page scroll or when i clic on menu there is no "active" flag.
Can you help me ? Thanks :)
| 0debug
|
Fetch categories list from SQL Server 2008 : <p>I have below table structure in SQL Server 2008:</p>
<ol>
<li>Article (stores articles)</li>
<li>Category (stores category) </li>
<li>ArticleToCategory (stores article and category reference since one article can be tagged to multiple category). </li>
</ol>
<p>Now i want to fetch categories (with article count) whose articles are not tagged to any other category).</p>
| 0debug
|
The input line is too long when starting kafka : <p>I'm trying to run Kafka message queue on Windows.</p>
<p>I'm usin this tutorial - <a href="https://dzone.com/articles/running-apache-kafka-on-windows-os" rel="noreferrer">https://dzone.com/articles/running-apache-kafka-on-windows-os</a></p>
<p>When i try to run it with comand - .\bin\windows\kafka-server-start.bat .\config\server.properties</p>
<p>and i get an error:
<strong>The input line is too long.
The syntax of the command is incorrect.</strong></p>
<p>kafka location - C:\kafka_2.11-1.0.0</p>
| 0debug
|
I Want upload Zip file on Google Drive but using C Sharp Windows Application (Frame Work 4.0 VS 2010) :
[1]: https://i.stack.imgur.com/8r5i7.png
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
| 0debug
|
Is it possible to load and unload jdk and custom modules dynamically in Java 9? : <p>I am beginner in JPMS and can't understand its dynamism. For example, in current JVM instance <code>moduleA.jar</code> is running. <code>moduleA</code> requires only <code>java.base</code> module. Now, I want </p>
<ol>
<li>to load dynamically <code>moduleB.jar</code> that needs <code>java.sql</code> module and <code>moduleC.jar</code></li>
<li>execute some code from <code>moduleB</code></li>
<li>unload <code>moduleB</code>, <code>java.sql</code>, <code>moduleC</code> from JVM and release all resources.</li>
</ol>
<p>Can it be done in Java 9 module system?</p>
| 0debug
|
void do_icbi (void)
{
uint32_t tmp;
#if defined(TARGET_PPC64)
if (!msr_sf)
T0 &= 0xFFFFFFFFULL;
#endif
tmp = ldl_kernel(T0);
T0 &= ~(ICACHE_LINE_SIZE - 1);
tb_invalidate_page_range(T0, T0 + ICACHE_LINE_SIZE);
}
| 1threat
|
static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td,
uint32_t *int_mask, bool queuing)
{
UHCIAsync *async;
int len = 0, max_len;
uint8_t pid;
USBDevice *dev;
USBEndpoint *ep;
if (!(td->ctrl & TD_CTRL_ACTIVE))
return TD_RESULT_NEXT_QH;
async = uhci_async_find_td(s, addr, td);
if (async) {
async->queue->valid = 32;
if (!async->done)
return TD_RESULT_ASYNC_CONT;
if (queuing) {
return TD_RESULT_ASYNC_CONT;
}
uhci_async_unlink(async);
goto done;
}
async = uhci_async_alloc(uhci_queue_get(s, td), addr);
async->queue->valid = 32;
async->isoc = td->ctrl & TD_CTRL_IOS;
max_len = ((td->token >> 21) + 1) & 0x7ff;
pid = td->token & 0xff;
dev = uhci_find_device(s, (td->token >> 8) & 0x7f);
ep = usb_ep_get(dev, pid, (td->token >> 15) & 0xf);
usb_packet_setup(&async->packet, pid, ep, addr);
qemu_sglist_add(&async->sgl, td->buffer, max_len);
usb_packet_map(&async->packet, &async->sgl);
switch(pid) {
case USB_TOKEN_OUT:
case USB_TOKEN_SETUP:
len = usb_handle_packet(dev, &async->packet);
if (len >= 0)
len = max_len;
break;
case USB_TOKEN_IN:
len = usb_handle_packet(dev, &async->packet);
break;
default:
uhci_async_free(async);
s->status |= UHCI_STS_HCPERR;
uhci_update_irq(s);
return TD_RESULT_STOP_FRAME;
}
if (len == USB_RET_ASYNC) {
uhci_async_link(async);
return TD_RESULT_ASYNC_START;
}
async->packet.result = len;
done:
len = uhci_complete_td(s, td, async, int_mask);
usb_packet_unmap(&async->packet, &async->sgl);
uhci_async_free(async);
return len;
}
| 1threat
|
Angular Dialog: No component factory found for DialogModule. : <p>Trying to make a dialog using feature model in angular 6. But I'm getting this error:</p>
<blockquote>
<p>No component factory found for DialogModule. Did you add it to @NgModule.entryComponents?</p>
</blockquote>
<p>Everyone keeps saying to use </p>
<blockquote>
<p>entryComponents: [DialogComponent]</p>
</blockquote>
<p>which I am already doing. Also tried to use that in the feature module without success. Here are I think the necessary and simplified files:</p>
<p>app.module.ts</p>
<pre><code>import { DialogModule } from './components/dialog/dialog.module';
import { DialogComponent } from './components/dialog/dialog.component';
...
// AoT requires an exported function for factories
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http);
}
@NgModule({
declarations: [..., AppComponent],
imports: [DialogModule],
entryComponents: [DialogComponent],
providers: [..., MatDialogModule],
bootstrap: [AppComponent]
})
export class AppModule {}
</code></pre>
<p>dialog.module.ts</p>
<pre><code>import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { DialogComponent } from './dialog.component';
...
@NgModule({
imports: [
CommonModule
],
declarations: [..., DialogComponent],
exports: [DialogComponent]
})
export class DialogModule {
...
}
</code></pre>
<p>some-other.component.ts</p>
<pre><code>import { DialogModule } from '../../components/dialog/dialog.module';
...
@Component({
...
})
export class LanguageButtonComponent implements OnInit {
constructor(private languageService : LanguageService,
private dialog: MatDialog,) {
}
// activated from button
openDialog() {
this.dialog.open(DialogModule);
}
}
</code></pre>
<p>How to get rid of the error?</p>
| 0debug
|
Database connections : My program wont launch, I'm getting an error I don't know how to fix. Please advise
I've googled the error
Error 1:
Severity Code Description Project File Line Suppression State
Error Unable to copy file "obj\Debug\KarateStock.exe" to "bin\Debug\KarateStock.exe". The process cannot access the file 'bin\Debug\KarateStock.exe' because it is being used by another process. KarateStock
Error 2:
Severity Code Description Project File Line Suppression State
Error Could not copy "obj\Debug\KarateStock.exe" to "bin\Debug\KarateStock.exe". Exceeded retry count of 10. Failed. The file is locked by: "KarateStock (6744), KarateStock (5932), KarateStock (1196)" KarateStock
| 0debug
|
void blkconf_geometry(BlockConf *conf, int *ptrans,
unsigned cyls_max, unsigned heads_max, unsigned secs_max,
Error **errp)
{
DriveInfo *dinfo;
if (!conf->cyls && !conf->heads && !conf->secs) {
dinfo = drive_get_by_blockdev(conf->bs);
conf->cyls = dinfo->cyls;
conf->heads = dinfo->heads;
conf->secs = dinfo->secs;
if (ptrans) {
*ptrans = dinfo->trans;
}
}
if (!conf->cyls && !conf->heads && !conf->secs) {
hd_geometry_guess(conf->bs,
&conf->cyls, &conf->heads, &conf->secs,
ptrans);
} else if (ptrans && *ptrans == BIOS_ATA_TRANSLATION_AUTO) {
*ptrans = hd_bios_chs_auto_trans(conf->cyls, conf->heads, conf->secs);
}
if (conf->cyls || conf->heads || conf->secs) {
if (conf->cyls < 1 || conf->cyls > cyls_max) {
error_setg(errp, "cyls must be between 1 and %u", cyls_max);
return;
}
if (conf->heads < 1 || conf->heads > heads_max) {
error_setg(errp, "heads must be between 1 and %u", heads_max);
return;
}
if (conf->secs < 1 || conf->secs > secs_max) {
error_setg(errp, "secs must be between 1 and %u", secs_max);
return;
}
}
}
| 1threat
|
Install Android App Bundle on device : <p>I built my project using the new Android App Bundle format. With APK files, I can download the APK to my device, open it, and immediately install the app. I downloaded my app as a bundle (.aab format) and my Nexus 5X running Android 8.1 can't open the file. Is there any way to install AABs on devices in the same convenient manner as APKs? </p>
| 0debug
|
Scrap the stackflow user data : import requests
from bs4 import BeautifulSoup
import pandas as pd
import csv
url='https://stackoverflow.com/users'
response= requests.get(url)
html=response.content
soup= BeautifulSoup(html, 'html.parser')
all_table= soup.find("table")
l=len(soup.find_all('div', class_='container'))
print(l)
divs= soup.find_all("div", class_='container')
i=0
with open('stackdata.csv', 'a') as csv_file:
writer=csv.writer(csv_file)
for div in divs:
print(div.text)
name_box=soup.find('div', attrs={'class': 'user-details'})
name=name_box.text
print(name)
writer.writerow([name])
div.text print the all data but when I want to write in csv file it goes only one upper data.
| 0debug
|
How to delete an undesirable row from pandas dataframe : <p>I have pandas dataframe for exemple like :</p>
<pre><code>id column1 column2
1 aaa mmm
2 bbb nnn
3 ccc ooo
4 ddd ppp
5 eee qqq
</code></pre>
<p>I have a list that contain some values from column1 :</p>
<pre><code>[bbb],[ddd],[eee]
</code></pre>
<p>I need python code in order to delete from the pandas all elements existing in the list </p>
<p>Ps: my pandas contains 280 000 samples so I need a fast code</p>
<p>Thanks </p>
| 0debug
|
How to insert a sleep/pause before the next method is called in android? : <p>In an android app I have a layout, and when the user presses a button a different layout is shown (in the same activity). But instead to show the different layout right away, I want to put in a small delay (ca. 0.5 seconds). How to do that best in android?</p>
<p>In python you just do <code>time.sleep(0.5)</code> but I have seen already dozen of code lines to do the same. How to do this the <em>most simple way as possible</em>?</p>
| 0debug
|
script tag in PHP function - expecting statment : Im trying to use javascript code in PHP function,
but I get error - expecting statement
code:
function subscribe_request($phone ){
<script src="js/subscrie.js" type="text/javascript">
//something
</script>
}
| 0debug
|
How to work with xml and java (android) : <p>How do I make something in xml, and change the value of it in Java?</p>
<p>ex:</p>
<pre><code><TextView
android:text="Hello World!"
android:textSize="50dp"
android:layout_marginTop="27dp"
android:id="@+id/textView"
android:editable="true"
android:enabled="true" />
</code></pre>
<p>Now how do I edit the text from being "Hello World" to something else in Java?</p>
| 0debug
|
How to use auto layout so my app fits all screen sizes in swift : [I want it to look like this on all iphones][1]
[But when I switch to a larger size phone it does this, it also looks ugly on smaller phones as well.][2]
[1]: https://i.stack.imgur.com/LYwQm.png
[2]: https://i.stack.imgur.com/rPbbF.png
| 0debug
|
How can I re-write this strcpy() function using pointers only? : <p>this is strcpy code</p>
<pre><code>char *strcpy(char *dest, const char* src)
#endif
{
char *ret = dest;
while (*dest++ = *src++)
;
return ret;
}
</code></pre>
<p>I tried to implement it using swap method and pointers only</p>
<pre><code>char *strcpy(char *dest, char *src)
{
char *ret = dest;
dest = src;
src = ret;
return ret
}
</code></pre>
<p>but the swap method didn't work,can any one tell me if it's proper to use swap method to perform strcpy() function? if not, how can I write this code using ponters notation only?</p>
| 0debug
|
static void cmd_seek(IDEState *s, uint8_t* buf)
{
unsigned int lba;
uint64_t total_sectors = s->nb_sectors >> 2;
if (total_sectors == 0) {
ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
return;
}
lba = ube32_to_cpu(buf + 2);
if (lba >= total_sectors) {
ide_atapi_cmd_error(s, SENSE_ILLEGAL_REQUEST, ASC_LOGICAL_BLOCK_OOR);
return;
}
ide_atapi_cmd_ok(s);
}
| 1threat
|
grep: input dictionary file. Recursively search DIR for dictionary terms, output found filenames to a file named after dictionary_term : I have a dictionary file:
`dictionary.txt`
it contains the following example IP addresses:
`
1.1.1.1
2.2.2.2
3.3.3.3
`
There are many `IP_files.iplists` within this directory, each IP LIST containing many different IP addresses
I would like to search for: `1.1.1.1` and if this string is found within one of the IP LISTS, then output all found IP LIST filenames (e.g. `IP_files_list1.iplists`) to another file that is named after the dictionary search term (eg. `1.1.1.1.txt`)
Ideally then, `1.1.1.1.txt` containing a list of all of the filenames it was found in
`2.2.2.2.txt` would contain a list of all of the IP LIST filenames it was found in
> `grep -r "1.1.1.1" > 1.1.1.1`
>
> is about as far as I have come. This creates a file named 1.1.1.1 and
> lists all of the IPLISTS.iplists file names that "1.1.1.1" is found in
.
> So 1.1.1.1 looks something like this:
>
`IP_files_list1.iplists
IP_files_list2.iplists
IP_files_list_another_list.iplists`
| 0debug
|
Why flexible array member must be at end of struct but struct with flexible array not? : <p>Some struct with flexible array:</p>
<pre><code>struct SomeArray { unsigned length; int array[]; };
</code></pre>
<p>This code gcc (ver. 4.9.2) compiling with no errors:</p>
<pre><code>struct s1{ unsigned length; SomeArray some_array; const char * string; } ss1;
</code></pre>
<p>How this work?</p>
| 0debug
|
static void raw_refresh_limits(BlockDriverState *bs, Error **errp)
{
BDRVRawState *s = bs->opaque;
struct stat st;
if (!fstat(s->fd, &st)) {
if (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)) {
int ret = hdev_get_max_transfer_length(bs, s->fd);
if (ret > 0 && ret <= BDRV_REQUEST_MAX_BYTES) {
bs->bl.max_transfer = pow2floor(ret);
raw_probe_alignment(bs, s->fd, errp);
bs->bl.min_mem_alignment = s->buf_align;
bs->bl.opt_mem_alignment = MAX(s->buf_align, getpagesize());
| 1threat
|
how to print incorrect questions? : <p>I am making a quiz in python and i want to know how i can display the incorrect questions at the end of the quiz. For example i have a 10 question quiz and i get 3 wrong, so i want to those questions to be displayed in the program and give me the option to re take them.</p>
<p>Here is my code:</p>
<pre><code>correct=0
incorrect=0
def tryagain():
while True:
answer = input('Do you want to continue?: Press Y for yes and N for no ')
if answer.lower().startswith("y"):
print()
elif answer.lower().startswith("n"):
exit()
print('****** Welceome to the Online Maths Test ********')
print()
print()
print()
print()
print()
print()
print()
import os
os.system("PAUSE")
import os
os.system('cls')
print('Question 1: 123 - 39 = ? \n 1. 64 \n 2. 44 \n 3. 74 \n 4. 84')
print()
answer=int(input())
if answer == 4:
print ()
print ()
global correct
correct=correct+1
elif answer != 4:
print ()
global incorrect
incorrect=incorrect+1
import os
os.system('cls')
print('Question 2: 123+39 = ? \n \n 1. 162 \n 2. 166 \n 3. 62 \n 4. 66')
print()
answer=int(input())
if answer == 1:
print ()
print ()
global correct
correct=correct+1
elif answer != 1:
print ()
global incorrect
incorrect=incorrect+1
import os
os.system('cls')
print('Question 3: 123*9 = ? \n 1. 1007 \n 2. 1107 \n 3. 1106 \n 4. 1116')
print()
answer=int(input())
if answer == 2:
print ()
print ()
global correct
correct=correct+1
elif answer != 2:
print ()
global incorrect
incorrect=incorrect+1
import os
os.system('cls')
print('Question 4: 135 / 15 = ? \n 1. 8 \n 2. 8.5 \n 3. 9 \n 4. 9.5')
print()
answer=int(input())
if answer == 3:
print ()
print ()
global correct
correct=correct+1
elif answer != 3:
print ()
global incorrect
incorrect=incorrect+1
import os
os.system('cls')
print('Question 5: 12 * (12 / 2) = ? \n 1. 144 \n 2. 6 \n 3. 72 \n 4. 36')
print()
answer=int(input())
if answer == 3:
print ()
print ()
global correct
correct=correct+1
elif answer != 3:
print ()
global incorrect
incorrect=incorrect+1
import os
os.system('cls')
print('Question 6: 130 / 2 + 8 = ? \n 1. 13 \n 2. 14 \n 3. 61 \n 4. 84')
print()
answer=int(input())
if answer == 4:
print ()
print ()
correct=correct+1
elif answer != 4:
print ()
global incorrect
incorrect=incorrect+1
import os
os.system('cls')
print('Question 7: 10 + 12 + 13 * 6 / 2 = ? \n 1. 105 \n 2. 44 \n 3. 61 \n 4. 84')
print()
answer=int(input())
if answer == 3:
print ()
print ()
global correct
correct=correct+1
elif answer != 3:
print ()
global incorrect
incorrect=incorrect+1
import os
os.system('cls')
print('Question 8: (10 + 12 + 13 * 6) / 2 = ? \n 1. 50 \n 2. 44 \n 3. 61 \n 4. 84')
print()
answer=int(input())
if answer == 1:
print ()
print ()
global correct
correct=correct+1
elif answer != 1:
print ()
global incorrect
incorrect=incorrect+1
import os
os.system('cls')
print('Question 9: 8 (12 + 6 / 3 * 2) - 1 = ? \n 1. 127 \n 2. 109 \n 3. 95 \n 4. 135')
print()
answer=int(input())
if answer == 1:
print ()
print ()
global correct
correct=correct+1
elif answer != 1:
print ()
global incorrect
incorrect=incorrect+1
import os
os.system('cls')
print('Question 10: 1 / 1 * 1 - 1 + 1 = ? \n 1. 1 \n 2. -1 \n 3. 0 \n 4. -2')
print()
answer=int(input())
if answer == 1:
print ()
print ()
global correct
correct=correct+1
elif answer != 1:
global incorrect
incorrect=incorrect+1
print()
print()
print()
print()
import os
os.system('cls')
print('Your total score is: ',correct,' / 10')
print('Your presentage is: ',correct*100/10,'%')
print()
print()
print()
print()
tryagain()
tryagain()
</code></pre>
| 0debug
|
R make new columns from uniqe values in column dynamically : <p>I want to create new columns based on unique values in one column dynamically. Original:</p>
<pre><code>id, category
1, a
2, b
3, c
4, b
</code></pre>
<p>New:</p>
<pre><code>id, category, a, b, c
1, a, 1, 0, 0
2, b, 0, 1, 0
3, c, 0, 0, 1
4, b, 0, 1, 0
</code></pre>
<p>For now I do:</p>
<pre><code>data$categoryA = ifelse(data$category=="a", 1, 0)
data$categoryB = ifelse(data$category=="b", 1, 0)
...
</code></pre>
<p>But I want to do this dynamically something like this:</p>
<pre><code>for(CATEGORY in unique(data$category) {
data$CATEGORY = ifelse(data$CATEGORY =="a", 1, 0)
}
</code></pre>
| 0debug
|
How to check if used paginate in laravel : <p>I have a custom view and in some functions, I used <code>paginate</code> and other functions I don't use <code>paginate</code>. now how can I check if I used <code>paginate</code> or not ?</p>
<pre><code>@if($products->links())
{{$products->links()}}
@endif // not work
</code></pre>
<p>of course that I know I can use a variable as true false to will check it, But is there any native function to check it ?</p>
| 0debug
|
static int vhdx_create_bat(BlockDriverState *bs, BDRVVHDXState *s,
uint64_t image_size, VHDXImageType type,
bool use_zero_blocks, uint64_t file_offset,
uint32_t length)
{
int ret = 0;
uint64_t data_file_offset;
uint64_t total_sectors = 0;
uint64_t sector_num = 0;
uint64_t unused;
int block_state;
VHDXSectorInfo sinfo;
assert(s->bat == NULL);
data_file_offset = file_offset + length + 5 * MiB;
total_sectors = image_size >> s->logical_sector_size_bits;
if (type == VHDX_TYPE_DYNAMIC) {
ret = bdrv_truncate(bs, data_file_offset);
if (ret < 0) {
goto exit;
}
} else if (type == VHDX_TYPE_FIXED) {
ret = bdrv_truncate(bs, data_file_offset + image_size);
if (ret < 0) {
goto exit;
}
} else {
ret = -ENOTSUP;
goto exit;
}
if (type == VHDX_TYPE_FIXED ||
use_zero_blocks ||
bdrv_has_zero_init(bs) == 0) {
s->bat = g_try_malloc0(length);
if (length && s->bat != NULL) {
ret = -ENOMEM;
goto exit;
}
block_state = type == VHDX_TYPE_FIXED ? PAYLOAD_BLOCK_FULLY_PRESENT :
PAYLOAD_BLOCK_NOT_PRESENT;
block_state = use_zero_blocks ? PAYLOAD_BLOCK_ZERO : block_state;
while (sector_num < total_sectors) {
vhdx_block_translate(s, sector_num, s->sectors_per_block, &sinfo);
sinfo.file_offset = data_file_offset +
(sector_num << s->logical_sector_size_bits);
sinfo.file_offset = ROUND_UP(sinfo.file_offset, MiB);
vhdx_update_bat_table_entry(bs, s, &sinfo, &unused, &unused,
block_state);
cpu_to_le64s(&s->bat[sinfo.bat_idx]);
sector_num += s->sectors_per_block;
}
ret = bdrv_pwrite(bs, file_offset, s->bat, length);
if (ret < 0) {
goto exit;
}
}
exit:
g_free(s->bat);
return ret;
}
| 1threat
|
iOS ytplayer API not working properly : I have embedded youtube in my application using ytplayer helper library for iOS the main issue I am facing right now is that I have embedded the multiple instances of ytplayer within scrollview and its loosing its not calling the changestate playback properly. the problem occurs when two videos are loaded concurrently.
| 0debug
|
void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
void *opaque)
{
SaveStateEntry *se, *new_se;
QTAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) {
if (se->vmsd == vmsd && se->opaque == opaque) {
QTAILQ_REMOVE(&savevm_handlers, se, entry);
qemu_free(se);
| 1threat
|
int mips_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
{
MIPSCPU *cpu = MIPS_CPU(cs);
CPUMIPSState *env = &cpu->env;
target_ulong tmp;
tmp = ldtul_p(mem_buf);
if (n < 32) {
env->active_tc.gpr[n] = tmp;
return sizeof(target_ulong);
}
if (env->CP0_Config1 & (1 << CP0C1_FP)
&& n >= 38 && n < 73) {
if (n < 70) {
if (env->CP0_Status & (1 << CP0St_FR)) {
env->active_fpu.fpr[n - 38].d = tmp;
} else {
env->active_fpu.fpr[n - 38].w[FP_ENDIAN_IDX] = tmp;
}
}
switch (n) {
case 70:
env->active_fpu.fcr31 = tmp & 0xFF83FFFF;
RESTORE_ROUNDING_MODE;
break;
case 71:
env->active_fpu.fcr0 = tmp;
break;
}
return sizeof(target_ulong);
}
switch (n) {
case 32:
env->CP0_Status = tmp;
break;
case 33:
env->active_tc.LO[0] = tmp;
break;
case 34:
env->active_tc.HI[0] = tmp;
break;
case 35:
env->CP0_BadVAddr = tmp;
break;
case 36:
env->CP0_Cause = tmp;
break;
case 37:
env->active_tc.PC = tmp & ~(target_ulong)1;
if (tmp & 1) {
env->hflags |= MIPS_HFLAG_M16;
} else {
env->hflags &= ~(MIPS_HFLAG_M16);
}
break;
case 72:
break;
default:
if (n > 89) {
return 0;
}
break;
}
return sizeof(target_ulong);
}
| 1threat
|
static void bdrv_qed_invalidate_cache(BlockDriverState *bs)
{
BDRVQEDState *s = bs->opaque;
bdrv_qed_close(bs);
memset(s, 0, sizeof(BDRVQEDState));
bdrv_qed_open(bs, NULL, bs->open_flags, NULL);
}
| 1threat
|
postgres: how to create a table by loading a .sql file : In SQLite you can do
sqlite3 i.db < x.sql
where `x.sql` is a `create table` statement and `i.db` is the database
What is the equivalent in PostgresSQL ?
| 0debug
|
How to update XML file in java : <p>I am new to java and I would like to update the dates to existing xml file but not sure ho to do it lets say the file is File.xml
and I need to change the date in:
So I need to update the start and end date.
Thanks</p>
| 0debug
|
Passing data without ending a function C# (Creating a facebook's wall) : <p>Hey i am supposed to do a user activity log for a forum on each user profile (something similar to facebook's wall), i tried to make some huge database request but the efficiency is disappointing so i have to find another way to do this. So i've thought that maybe on each function (like voteup, votedown, write post, create topic etc) i'll be parsing a json to my logic and then from getting that json i'll be making some actions. But im not sure if its possible in C# and couldn't find any similar soultion on web. Maybe by making each function some kind of async i could get the goal? Or maybe some of you know a good tutorial or example with doing such a thing. </p>
| 0debug
|
Dispalying ads on browsers protected by Adblock : <p>I understand that people don't want to see ads but as a developer I would like to make money from ads on my site.
How to add an ads to my site so Adblock will not block my content ?</p>
| 0debug
|
Bit hack: Expanding bits : <p>I am trying to convert a <code>uint16_t</code> input to a <code>uint32_t</code> bit mask. One bit in the input toggles two bits in the output bit mask. Here is an example converting a 4-bit input to an 8-bit bit mask:</p>
<pre><code>Input Output
ABCDb -> AABB CCDDb
A,B,C,D are individual bits
Example outputs:
0000b -> 0000 0000b
0001b -> 0000 0011b
0010b -> 0000 1100b
0011b -> 0000 1111b
....
1100b -> 1111 0000b
1101b -> 1111 0011b
1110b -> 1111 1100b
1111b -> 1111 1111b
</code></pre>
<p>Is there a bithack-y way to achieve this behavior?</p>
| 0debug
|
static bool check_overwrapping_aiocb(BDRVSheepdogState *s, SheepdogAIOCB *aiocb)
{
SheepdogAIOCB *cb;
QLIST_FOREACH(cb, &s->inflight_aiocb_head, aiocb_siblings) {
if (AIOCBOverwrapping(aiocb, cb)) {
return true;
}
}
QLIST_INSERT_HEAD(&s->inflight_aiocb_head, aiocb, aiocb_siblings);
return false;
}
| 1threat
|
New Line in Gmail App for iOS using URL Scheme : <p>We are working on an iOS app and we happen to be using the Gmail app's URL Scheme to compose a new email for the user. We figured out most of it, however we are having some trouble adding new lines in the body of the email. So far our URL looks like this: </p>
<p><code>googlegmail://co?from=username@example.com&to=helpdesk@example.com&subject=TITLE&body=What%20ever%20they%20include%20for%20the%20body</code></p>
<p>We have already tried using <code>%0D%0A</code>, as well as a few other options, however none of those seem to work. Is there any way to add a new line through the URL or is that just not possible?</p>
| 0debug
|
static void xics_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
dc->realize = xics_realize;
dc->props = xics_properties;
dc->reset = xics_reset;
}
| 1threat
|
static uint64_t memory_region_dispatch_read1(MemoryRegion *mr,
hwaddr addr,
unsigned size)
{
uint64_t data = 0;
if (!memory_region_access_valid(mr, addr, size, false)) {
return -1U;
}
if (!mr->ops->read) {
return mr->ops->old_mmio.read[ctz32(size)](mr->opaque, addr);
}
access_with_adjusted_size(addr, &data, size,
mr->ops->impl.min_access_size,
mr->ops->impl.max_access_size,
memory_region_read_accessor, mr);
return data;
}
| 1threat
|
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
| 1threat
|
How to login with AWS CLI using credentials profiles : <p>I want to setup multiple AWS profiles so that I can easily change settings and credentials when jumping between projects.</p>
<p>I've read the AWS documentation but it's quite vague about how to select what profile you want to use when logging in.</p>
<p>When I'm trying to login it's just giving me this error which seems to indicate that it's not picking up any credentials.</p>
<p><code>An error occurred (UnrecognizedClientException) when calling the GetAuthorizationToken operation: The security token included in the request is invalid.</code></p>
| 0debug
|
How to convert numbers like 902.1 or 902 to 900 in php : <p>Anyone knows how i can convert How to convert numbers like 902.1 or 902 to 900 in php..i have tried both ceil and floor like below but still same issue</p>
<pre><code>$amount = 902.1
$amount2 = floor($amount);
return $amount2;
returns 902
</code></pre>
<p>but i want to return either 900 or 910..something like this</p>
| 0debug
|
How to configure Google Java Code Formatter in Intellij IDEA 17? : <p>In the latest versions of IntelliJ IDEA it seems that it isn't possible to import code style files like <a href="https://github.com/google/styleguide/blob/gh-pages/intellij-java-google-style.xml" rel="noreferrer">intellij-java-google-style.xml</a>.</p>
<p>I would like use the Google Java Code Style in this IDE but it seems there isn't a trivial solution.</p>
| 0debug
|
static void scsi_read_complete(void * opaque, int ret)
{
SCSIGenericReq *r = (SCSIGenericReq *)opaque;
int len;
if (ret) {
DPRINTF("IO error ret %d\n", ret);
scsi_command_complete(r, ret);
return;
}
len = r->io_header.dxfer_len - r->io_header.resid;
DPRINTF("Data ready tag=0x%x len=%d\n", r->req.tag, len);
r->len = -1;
r->req.bus->complete(r->req.bus, SCSI_REASON_DATA, r->req.tag, len);
if (len == 0)
scsi_command_complete(r, 0);
}
| 1threat
|
What is the git clone --filter option's syntax? : <p>The Git 2.17 <a href="https://github.com/git/git/blob/master/Documentation/RelNotes/2.17.0.txt" rel="noreferrer">changelog</a> describes this option:</p>
<blockquote>
<ul>
<li>The machinery to clone & fetch, which in turn involves packing and
unpacking objects, has been told how to omit certain objects using<br>
the filtering mechanism introduced by another topic. It now knows<br>
to mark the resulting pack as a promisor pack to tolerate missing<br>
objects, laying foundation for "narrow" clones.</li>
</ul>
</blockquote>
<p>Is this flag ready to be used, or is it most likely quite unstable? Does anyone know the right syntax to pass? Whatever flags I pass are rejected as being an invalid filter-spec. For example, these were my attempts to filter by directory:</p>
<pre><code>git clone file://path --depth=1 --filter '--subdirectory-filter Assets' TestRepo
git clone file://path --depth=1 --filter --subdirectory-filter Assets TestRepo
git clone file://path --depth=1 --filter Assets TestRepo
</code></pre>
| 0debug
|
static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child,
int64_t offset, unsigned int bytes, QEMUIOVector *qiov)
{
BlockDriverState *bs = child->bs;
void *bounce_buffer;
BlockDriver *drv = bs->drv;
struct iovec iov;
QEMUIOVector bounce_qiov;
int64_t cluster_offset;
unsigned int cluster_bytes;
size_t skip_bytes;
int ret;
assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE));
bdrv_round_to_clusters(bs, offset, bytes, &cluster_offset, &cluster_bytes);
trace_bdrv_co_do_copy_on_readv(bs, offset, bytes,
cluster_offset, cluster_bytes);
iov.iov_len = cluster_bytes;
iov.iov_base = bounce_buffer = qemu_try_blockalign(bs, iov.iov_len);
if (bounce_buffer == NULL) {
ret = -ENOMEM;
goto err;
}
qemu_iovec_init_external(&bounce_qiov, &iov, 1);
ret = bdrv_driver_preadv(bs, cluster_offset, cluster_bytes,
&bounce_qiov, 0);
if (ret < 0) {
goto err;
}
if (drv->bdrv_co_pwrite_zeroes &&
buffer_is_zero(bounce_buffer, iov.iov_len)) {
ret = bdrv_co_do_pwrite_zeroes(bs, cluster_offset, cluster_bytes, 0);
} else {
ret = bdrv_driver_pwritev(bs, cluster_offset, cluster_bytes,
&bounce_qiov, 0);
}
if (ret < 0) {
goto err;
}
skip_bytes = offset - cluster_offset;
qemu_iovec_from_buf(qiov, 0, bounce_buffer + skip_bytes, bytes);
err:
qemu_vfree(bounce_buffer);
return ret;
}
| 1threat
|
How to remove # from URL in Aurelia : <p>Can anybody please explain in step by step manner, how can we remove # from URL in Aurelia</p>
| 0debug
|
PyODBC : can't open the driver even if it exists : <p>I'm new to the linux world and I want to query a Microsoft SQL Server from Python. I used it on Windows and it was perfectly fine but in Linux it's quite painful.</p>
<p>After some hours, I finally succeed to install the Microsoft ODBC driver on Linux Mint with unixODBC.</p>
<p>Then, I set up an anaconda with python 3 environment. </p>
<p>I then do this :</p>
<pre><code>import pyodbc as odbc
sql_PIM = odbc.connect("Driver={ODBC Driver 13 for SQL Server};Server=XXX;Database=YYY;Trusted_Connection=Yes")
</code></pre>
<p>It returns :</p>
<pre><code>('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0' : file not found (0) (SQLDriverConnect)")
</code></pre>
<p>The thing I do not undertsand is that PyODBC seems to read the right filepath from odbcinst.ini and still does not work.</p>
<p>I went to "/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0" and the file actually exists !</p>
<p>So why does it tell me that it does not exist ?
Here are some possible clues :</p>
<ul>
<li>I'm on a virtual environment</li>
<li>I need to have "read" rights because it's a root filepath</li>
</ul>
<p>I do not know how to solve either of these problems.</p>
<p>Thanks !</p>
| 0debug
|
I want to write a macro to copy the full row from sheet1 to sheet 2 only if the column C is marked as Y? : I am new to macros and wanted to learn the same.
I want to write a macro to copy the full row from sheet1 to sheet 2 only if the column C is marked as Y.
I have three sheets in a workbook and I want to copy all the rows from all the first three sheets into sheet 4 which has the column 'C' marked as Y.
Please help.
Thanks in advance.
| 0debug
|
can someone explain me why we use parentheses around conditions in javaScript : **can someone explain me why we use parentheses around conditions in javaScript**
for an example if we take the below code Ex:
**if(5 > 4) {}**
----------------
in the above code i need to know why we use parentheses around the **'if'** statement's condition we can just use the below code like
**if 5 > 4 {}**
---------------
but why do we include parentheses around the **'if'** statement's condition for what purpose do we use it is it just to seperate the condition and the **{}** block of the if statement or what
| 0debug
|
Widget rebuild after TextField selection Flutter : <p>I'm developping a Flutter App that needed to have a form. So when the user open the app, a Splash Screen appear before the form that have the following code : </p>
<pre><code>import 'package:flutter/material.dart';
import '../model/User.dart';
import './FileManager.dart';
import './MyListPage.dart';
class UserLoader extends StatefulWidget {
@override
_UserLoaderState createState() => new _UserLoaderState();
}
class _UserLoaderState extends State<UserLoader> {
final userFileName = "user_infos.txt";
User _user;
@override
Widget build(BuildContext context) {
print("build UserLoader");
final _formKey = new GlobalKey<FormState>();
final _firstNameController = new TextEditingController();
final _lastNameController = new TextEditingController();
final _emailController = new TextEditingController();
final _phoneController = new TextEditingController();
return new Scaffold(
appBar: new AppBar(
title: new Text("Informations"),
actions: <Widget>[
new IconButton(
icon: const Icon(Icons.save),
onPressed: () {
_user = _onFormValidate(
_formKey.currentState,
_firstNameController.text,
_lastNameController.text,
_emailController.text,
_phoneController.text);
})
],
),
body: new Center(
child: new SingleChildScrollView(
child: new Form(
key: _formKey,
child: new Column(children: <Widget>[
new ListTile(
leading: const Icon(Icons.person),
title: new TextFormField(
decoration: new InputDecoration(
hintText: "Prénom",
),
keyboardType: TextInputType.text,
controller: _firstNameController,
validator: _validateName,
),
),
new ListTile(
leading: const Icon(Icons.person),
title: new TextFormField(
decoration: new InputDecoration(
hintText: "Nom",
),
keyboardType: TextInputType.text,
controller: _lastNameController,
validator: _validateName,
),
),
Etc, etc ...
</code></pre>
<p>However when i tap the TextField, the keyboard appear and close immediately and all the component is rebuild. So it is impossible for me to complete the form..</p>
<p>Can someone have a solution please? Thanks in advance !</p>
| 0debug
|
ff_rm_retrieve_cache (AVFormatContext *s, AVIOContext *pb,
AVStream *st, RMStream *ast, AVPacket *pkt)
{
RMDemuxContext *rm = s->priv_data;
assert (rm->audio_pkt_cnt > 0);
if (st->codec->codec_id == CODEC_ID_AAC)
av_get_packet(pb, pkt, ast->sub_packet_lengths[ast->sub_packet_cnt - rm->audio_pkt_cnt]);
else {
av_new_packet(pkt, st->codec->block_align);
memcpy(pkt->data, ast->pkt.data + st->codec->block_align *
(ast->sub_packet_h * ast->audio_framesize / st->codec->block_align - rm->audio_pkt_cnt),
st->codec->block_align);
}
rm->audio_pkt_cnt--;
if ((pkt->pts = ast->audiotimestamp) != AV_NOPTS_VALUE) {
ast->audiotimestamp = AV_NOPTS_VALUE;
pkt->flags = AV_PKT_FLAG_KEY;
} else
pkt->flags = 0;
pkt->stream_index = st->index;
return rm->audio_pkt_cnt;
}
| 1threat
|
React-native JS Debugger issues with CORS — iOS : <p>I am having an issue with the react-native JS debugger on the iOS. The error occurs when I try to debug my app using the JS Debugger tool. I tried different solutions around the web with no success. Has anyone come across this error and managed to fix it?</p>
<p>Replication:</p>
<p>1) Run development app on real iOS device, which loads the JS bundle from <a href="http://172.16.23.27.xip.io:8081/index.delta?platform=ios&dev=true&minify=false" rel="noreferrer">http://172.16.23.27.xip.io:8081/index.delta?platform=ios&dev=true&minify=false</a></p>
<p>2) Enable JS Remote debug tools, which opens <a href="http://localhost:8081/debugger-ui/" rel="noreferrer">http://localhost:8081/debugger-ui/</a> in Chrome.</p>
<p>3) Bundle reloads, and Chrome DevTools console displays the following error:</p>
<p><strong>Failed to load <a href="http://172.16.23.27.xip.io:8081/index.delta?platform=ios&dev=true&minify=false" rel="noreferrer">http://172.16.23.27.xip.io:8081/index.delta?platform=ios&dev=true&minify=false</a>: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<a href="http://localhost:8081" rel="noreferrer">http://localhost:8081</a>' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
(index):188 Uncaught (in promise) TypeError: Failed to fetch</strong></p>
<pre><code>"react": "16.2.0",
"react-native": "0.52.1"
</code></pre>
| 0debug
|
static uint32_t nvdimm_get_max_xfer_label_size(void)
{
uint32_t max_get_size, max_set_size, dsm_memory_size = 4096;
max_get_size = dsm_memory_size - sizeof(NvdimmFuncGetLabelDataOut);
max_set_size = dsm_memory_size - offsetof(NvdimmDsmIn, arg3) -
sizeof(NvdimmFuncSetLabelDataIn);
return MIN(max_get_size, max_set_size);
}
| 1threat
|
databricks scala: how to substring a variable string : suppose I have a variable
var variable="[123]"
how to substring only get
123 without the []
Thanks, in scala language
| 0debug
|
Anyone know why this href isn't firing the javascript in Internet Explorer? : Can anyone tell me why this href wouldn't be firing the javascript in IE11? Works in all other browsers.
<a href="<%# "javascript:checkSelection('UserSImageSelectionByCategory.aspx?PartialPath="
+ base64Encode((string)DataBinder.Eval(Container.DataItem,"PartialPath")) +
"&var=" + variableName + "', "
+DataBinder.Eval(Container.DataItem, "Height" )+ ", "
+DataBinder.Eval(Container.DataItem, "Width" )+")" %>"
>
| 0debug
|
static int mov_open_dref(AVIOContext **pb, const char *src, MOVDref *ref,
AVIOInterruptCB *int_cb, int use_absolute_path, AVFormatContext *fc)
{
if (ref->nlvl_to > 0 && ref->nlvl_from > 0) {
char filename[1024];
const char *src_path;
int i, l;
src_path = strrchr(src, '/');
if (src_path)
src_path++;
else
src_path = src;
for (i = 0, l = strlen(ref->path) - 1; l >= 0; l--)
if (ref->path[l] == '/') {
if (i == ref->nlvl_to - 1)
break;
else
i++;
}
if (i == ref->nlvl_to - 1 && src_path - src < sizeof(filename)) {
memcpy(filename, src, src_path - src);
filename[src_path - src] = 0;
for (i = 1; i < ref->nlvl_from; i++)
av_strlcat(filename, "../", sizeof(filename));
av_strlcat(filename, ref->path + l + 1, sizeof(filename));
if (!avio_open2(pb, filename, AVIO_FLAG_READ, int_cb, NULL))
return 0;
}
} else if (use_absolute_path) {
av_log(fc, AV_LOG_WARNING, "Using absolute path on user request, "
"this is a possible security issue\n");
if (!avio_open2(pb, ref->path, AVIO_FLAG_READ, int_cb, NULL))
return 0;
}
return AVERROR(ENOENT);
}
| 1threat
|
Seaborn boxplot + stripplot: duplicate legend : <p>One of the coolest things you can easily make in <code>seaborn</code> is <code>boxplot</code> + <code>stripplot</code> combination:</p>
<pre><code>import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
tips = sns.load_dataset("tips")
sns.stripplot(x="day", y="total_bill", hue="smoker",
data=tips, jitter=True,
palette="Set2", split=True,linewidth=1,edgecolor='gray')
sns.boxplot(x="day", y="total_bill", hue="smoker",
data=tips,palette="Set2",fliersize=0)
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.);
</code></pre>
<p><a href="https://i.stack.imgur.com/IxAVf.png"><img src="https://i.stack.imgur.com/IxAVf.png" alt="boxplot+stripplot"></a></p>
<p>Unfortunately, as you can see above, it produced double legend, one for boxplot, one for stripplot. Obviously, it looks ridiculous and redundant. But I cannot seem to find a way to get rid of <code>stripplot</code> legend and only leave <code>boxplot</code> legend. Probably, I can somehow delete items from <code>plt.legend</code>, but I cannot find it in the documentation.</p>
| 0debug
|
static int usb_xhci_initfn(struct PCIDevice *dev)
{
int i, ret;
XHCIState *xhci = DO_UPCAST(XHCIState, pci_dev, dev);
xhci->pci_dev.config[PCI_CLASS_PROG] = 0x30;
xhci->pci_dev.config[PCI_INTERRUPT_PIN] = 0x01;
xhci->pci_dev.config[PCI_CACHE_LINE_SIZE] = 0x10;
xhci->pci_dev.config[0x60] = 0x30;
usb_xhci_init(xhci, &dev->qdev);
if (xhci->numintrs > MAXINTRS) {
xhci->numintrs = MAXINTRS;
}
if (xhci->numintrs < 1) {
xhci->numintrs = 1;
}
if (xhci->numslots > MAXSLOTS) {
xhci->numslots = MAXSLOTS;
}
if (xhci->numslots < 1) {
xhci->numslots = 1;
}
xhci->mfwrap_timer = qemu_new_timer_ns(vm_clock, xhci_mfwrap_timer, xhci);
xhci->irq = xhci->pci_dev.irq[0];
memory_region_init(&xhci->mem, "xhci", LEN_REGS);
memory_region_init_io(&xhci->mem_cap, &xhci_cap_ops, xhci,
"capabilities", LEN_CAP);
memory_region_init_io(&xhci->mem_oper, &xhci_oper_ops, xhci,
"operational", 0x400);
memory_region_init_io(&xhci->mem_runtime, &xhci_runtime_ops, xhci,
"runtime", LEN_RUNTIME);
memory_region_init_io(&xhci->mem_doorbell, &xhci_doorbell_ops, xhci,
"doorbell", LEN_DOORBELL);
memory_region_add_subregion(&xhci->mem, 0, &xhci->mem_cap);
memory_region_add_subregion(&xhci->mem, OFF_OPER, &xhci->mem_oper);
memory_region_add_subregion(&xhci->mem, OFF_RUNTIME, &xhci->mem_runtime);
memory_region_add_subregion(&xhci->mem, OFF_DOORBELL, &xhci->mem_doorbell);
for (i = 0; i < xhci->numports; i++) {
XHCIPort *port = &xhci->ports[i];
uint32_t offset = OFF_OPER + 0x400 + 0x10 * i;
port->xhci = xhci;
memory_region_init_io(&port->mem, &xhci_port_ops, port,
port->name, 0x10);
memory_region_add_subregion(&xhci->mem, offset, &port->mem);
}
pci_register_bar(&xhci->pci_dev, 0,
PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_TYPE_64,
&xhci->mem);
ret = pcie_cap_init(&xhci->pci_dev, 0xa0, PCI_EXP_TYPE_ENDPOINT, 0);
assert(ret >= 0);
if (xhci->flags & (1 << XHCI_FLAG_USE_MSI)) {
msi_init(&xhci->pci_dev, 0x70, xhci->numintrs, true, false);
}
if (xhci->flags & (1 << XHCI_FLAG_USE_MSI_X)) {
msix_init(&xhci->pci_dev, xhci->numintrs,
&xhci->mem, 0, OFF_MSIX_TABLE,
&xhci->mem, 0, OFF_MSIX_PBA,
0x90);
}
return 0;
}
| 1threat
|
static void win_chr_readfile(CharDriverState *chr)
{
WinCharState *s = chr->opaque;
int ret, err;
uint8_t buf[1024];
DWORD size;
ZeroMemory(&s->orecv, sizeof(s->orecv));
s->orecv.hEvent = s->hrecv;
ret = ReadFile(s->hcom, buf, s->len, &size, &s->orecv);
if (!ret) {
err = GetLastError();
if (err == ERROR_IO_PENDING) {
ret = GetOverlappedResult(s->hcom, &s->orecv, &size, TRUE);
}
}
if (size > 0) {
qemu_chr_read(chr, buf, size);
}
}
| 1threat
|
static void do_video_out(AVFormatContext *s,
OutputStream *ost,
AVFrame *in_picture,
float quality)
{
int ret, format_video_sync;
AVPacket pkt;
AVCodecContext *enc = ost->st->codec;
int nb_frames;
double sync_ipts, delta;
double duration = 0;
int frame_size = 0;
InputStream *ist = NULL;
if (ost->source_index >= 0)
ist = input_streams[ost->source_index];
if(ist && ist->st->start_time != AV_NOPTS_VALUE && ist->st->first_dts != AV_NOPTS_VALUE && ost->frame_rate.num)
duration = 1/(av_q2d(ost->frame_rate) * av_q2d(enc->time_base));
sync_ipts = in_picture->pts;
delta = sync_ipts - ost->sync_opts + duration;
nb_frames = 1;
format_video_sync = video_sync_method;
if (format_video_sync == VSYNC_AUTO)
format_video_sync = (s->oformat->flags & AVFMT_VARIABLE_FPS) ? ((s->oformat->flags & AVFMT_NOTIMESTAMPS) ? VSYNC_PASSTHROUGH : VSYNC_VFR) : 1;
switch (format_video_sync) {
case VSYNC_CFR:
if (delta < -1.1)
nb_frames = 0;
else if (delta > 1.1)
nb_frames = lrintf(delta);
break;
case VSYNC_VFR:
if (delta <= -0.6)
nb_frames = 0;
else if (delta > 0.6)
ost->sync_opts = lrint(sync_ipts);
break;
case VSYNC_DROP:
case VSYNC_PASSTHROUGH:
ost->sync_opts = lrint(sync_ipts);
break;
default:
av_assert0(0);
}
nb_frames = FFMIN(nb_frames, ost->max_frames - ost->frame_number);
if (nb_frames == 0) {
nb_frames_drop++;
av_log(NULL, AV_LOG_VERBOSE, "*** drop!\n");
return;
} else if (nb_frames > 1) {
if (nb_frames > dts_error_threshold * 30) {
av_log(NULL, AV_LOG_ERROR, "%d frame duplication too large, skiping\n", nb_frames - 1);
nb_frames_drop++;
return;
}
nb_frames_dup += nb_frames - 1;
av_log(NULL, AV_LOG_VERBOSE, "*** %d dup!\n", nb_frames - 1);
}
duplicate_frame:
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
in_picture->pts = ost->sync_opts;
if (!check_recording_time(ost))
return;
if (s->oformat->flags & AVFMT_RAWPICTURE &&
enc->codec->id == CODEC_ID_RAWVIDEO) {
enc->coded_frame->interlaced_frame = in_picture->interlaced_frame;
enc->coded_frame->top_field_first = in_picture->top_field_first;
pkt.data = (uint8_t *)in_picture;
pkt.size = sizeof(AVPicture);
pkt.pts = av_rescale_q(in_picture->pts, enc->time_base, ost->st->time_base);
pkt.flags |= AV_PKT_FLAG_KEY;
write_frame(s, &pkt, ost);
video_size += pkt.size;
} else {
int got_packet;
AVFrame big_picture;
big_picture = *in_picture;
big_picture.interlaced_frame = in_picture->interlaced_frame;
if (ost->st->codec->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)) {
if (ost->top_field_first == -1)
big_picture.top_field_first = in_picture->top_field_first;
else
big_picture.top_field_first = !!ost->top_field_first;
}
big_picture.quality = quality;
if (!enc->me_threshold)
big_picture.pict_type = 0;
if (ost->forced_kf_index < ost->forced_kf_count &&
big_picture.pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
big_picture.pict_type = AV_PICTURE_TYPE_I;
ost->forced_kf_index++;
}
update_benchmark(NULL);
ret = avcodec_encode_video2(enc, &pkt, &big_picture, &got_packet);
update_benchmark("encode_video %d.%d", ost->file_index, ost->index);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Video encoding failed\n");
exit_program(1);
}
if (got_packet) {
if (pkt.pts == AV_NOPTS_VALUE && !(enc->codec->capabilities & CODEC_CAP_DELAY))
pkt.pts = ost->sync_opts;
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base);
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base);
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "encoder -> type:video "
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ost->st->time_base),
av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->st->time_base));
}
write_frame(s, &pkt, ost);
frame_size = pkt.size;
video_size += pkt.size;
av_free_packet(&pkt);
if (ost->logfile && enc->stats_out) {
fprintf(ost->logfile, "%s", enc->stats_out);
}
}
}
ost->sync_opts++;
ost->frame_number++;
if(--nb_frames)
goto duplicate_frame;
if (vstats_filename && frame_size)
do_video_stats(output_files[ost->file_index]->ctx, ost, frame_size);
}
| 1threat
|
Which of the following is not equivalent to others? : <p>Which of the following is not equivalent to the other two? Please tell me when it isn't output different from the other two.</p>
<pre><code> while (i<10) {...}
for (;i<10:) {...}
do {...} while (i<10);
</code></pre>
<p>I'll appreciate it for your answer.</p>
| 0debug
|
ports for openvpn and websockets : <p>this will sound a silly question....
but id like to know the following.
i was going to install a freeswitch voip server on small intel nuc and on another intel nuc (nucs are small low powered desktop like units ) i planned to install openvpn to be used as a very useful vpn for when im on a dodgy wifi connection.</p>
<p>since id like openvpn to be running on port 443 tcp and since freeswitch ideally runs on 443 tcp i figured id need two seperate computers - hence the two machines on 2 completely different remote internet connections .</p>
<p>however im rather inclined to install both openvpn port 443 tcp ( running all the time) and also freeswitch websocket server ( listening on 443 tcp) running on the same computer and behind one router on a friends broadband connection port forwarding anything coming in for 443 tcp to the same local ip add of the same server running both freeswitch websocket and openvpn - is this a good idea?</p>
<p>id sooner not change the listening port on openvpn - since the default 1194 may well be blocked from hotel wifi etc and web sockets will undoubtedly respond more reliably if its listening on 443 tcp.</p>
<p>can two services listening on the same port / protocol work ok (nat wise )behind the router ?</p>
| 0debug
|
Convert the data frame having month, year and count columns to time series [r] : I have a data frame with columns `month, year, count`.[dataset][1]
Now how can I convert this data frame to time series(from `data frame` class to `ts` class). So that final output should be like this [enter image description here][2].
I tried to use answer from [this][3] question. But I didn't get the proper answer. I also tried to use aggregate functions but I am stuck.
[1]: https://i.stack.imgur.com/uL1zK.png
[2]: https://i.stack.imgur.com/vaJak.png
[3]: https://stackoverflow.com/questions/44996756/convert-data-frame-to-time-series-in-r
| 0debug
|
void qemu_anon_ram_free(void *ptr, size_t size)
{
trace_qemu_anon_ram_free(ptr, size);
if (ptr) {
munmap(ptr, size);
}
}
| 1threat
|
How to do a tekken/street fighter like slider/bar Unity3D : Hi I am trying to create a health bar which transition from healthValueX to healthValueY over time. Curently I am decreasing the value like this:
void Update ()
{
myVar-= 100 * Time.deltaTime;
slider.value = myVar;
}
and there is 2 methods which I call on press to manage the slider in addition.
void addHealth()
{
myVar+=250; //Harcoded for the short question
}
void forceRemoveHealth()
{
myVar-=250; //Harcoded for the short question
}
I like the transition in the `Update` it looks good. But when I mage a huge change for example in `addHealth()` or `forceRemoveHealth()` I would to color the gap and then to transition instead of go from 300 health directly to 50 for example.
The tricky part is that I do both - decrease every frame and want to support a bigger decrease based on input. What's the best way to achive this.
| 0debug
|
Can't always set React Native breakpoints in Chrome : <p>While debugging my React Native app in Chrome, I'm often unable to set breakpoints in the Sources tab. When I click on a line of code to add the breakpoint, a breakpoint is added instead to the next function declaration line in my module.</p>
<p>This doesn't happen in all of my source modules, but often enough that it prevents me from debugging efficiently.</p>
<p>I'm currently using RN 0.22 but this has been happening on older versions of RN as well (e.g. RN 0.18).</p>
| 0debug
|
when I write findAll it says: findAll is not defined : <p>I am trying to write my first data scraping code. However, this happens whenever I try and find all the tr tags in the html:</p>
<p>I wrote: match = findAll("tr",{"class":"match"})
This comes up: NameError: name "findAll" is not defined.</p>
| 0debug
|
av_cold int ff_huffyuv_alloc_temp(HYuvContext *s)
{
int i;
if (s->bitstream_bpp<24 || s->version > 2) {
for (i=0; i<3; i++) {
s->temp[i]= av_malloc(2*s->width + 16);
if (!s->temp[i])
return AVERROR(ENOMEM);
s->temp16[i] = (uint16_t*)s->temp[i];
}
} else {
s->temp[0]= av_mallocz(4*s->width + 16);
if (!s->temp[0])
return AVERROR(ENOMEM);
}
return 0;
}
| 1threat
|
def remove_odd(str1):
str2 = ''
for i in range(1, len(str1) + 1):
if(i % 2 == 0):
str2 = str2 + str1[i - 1]
return str2
| 0debug
|
void cpu_loop(CPUS390XState *env)
{
CPUState *cs = CPU(s390_env_get_cpu(env));
int trapnr, n, sig;
target_siginfo_t info;
target_ulong addr;
while (1) {
cpu_exec_start(cs);
trapnr = cpu_s390x_exec(cs);
cpu_exec_end(cs);
switch (trapnr) {
case EXCP_INTERRUPT:
break;
case EXCP_SVC:
n = env->int_svc_code;
if (!n) {
n = env->regs[1];
}
env->psw.addr += env->int_svc_ilen;
env->regs[2] = do_syscall(env, n, env->regs[2], env->regs[3],
env->regs[4], env->regs[5],
env->regs[6], env->regs[7], 0, 0);
break;
case EXCP_DEBUG:
sig = gdb_handlesig(cs, TARGET_SIGTRAP);
if (sig) {
n = TARGET_TRAP_BRKPT;
goto do_signal_pc;
}
break;
case EXCP_PGM:
n = env->int_pgm_code;
switch (n) {
case PGM_OPERATION:
case PGM_PRIVILEGED:
sig = TARGET_SIGILL;
n = TARGET_ILL_ILLOPC;
goto do_signal_pc;
case PGM_PROTECTION:
case PGM_ADDRESSING:
sig = TARGET_SIGSEGV;
n = TARGET_SEGV_MAPERR;
addr = env->__excp_addr;
goto do_signal;
case PGM_EXECUTE:
case PGM_SPECIFICATION:
case PGM_SPECIAL_OP:
case PGM_OPERAND:
do_sigill_opn:
sig = TARGET_SIGILL;
n = TARGET_ILL_ILLOPN;
goto do_signal_pc;
case PGM_FIXPT_OVERFLOW:
sig = TARGET_SIGFPE;
n = TARGET_FPE_INTOVF;
goto do_signal_pc;
case PGM_FIXPT_DIVIDE:
sig = TARGET_SIGFPE;
n = TARGET_FPE_INTDIV;
goto do_signal_pc;
case PGM_DATA:
n = (env->fpc >> 8) & 0xff;
if (n == 0xff) {
goto do_sigill_opn;
} else {
if (n & 0x80) {
n = TARGET_FPE_FLTINV;
} else if (n & 0x40) {
n = TARGET_FPE_FLTDIV;
} else if (n & 0x20) {
n = TARGET_FPE_FLTOVF;
} else if (n & 0x10) {
n = TARGET_FPE_FLTUND;
} else if (n & 0x08) {
n = TARGET_FPE_FLTRES;
} else {
goto do_sigill_opn;
}
sig = TARGET_SIGFPE;
goto do_signal_pc;
}
default:
fprintf(stderr, "Unhandled program exception: %#x\n", n);
cpu_dump_state(cs, stderr, fprintf, 0);
exit(EXIT_FAILURE);
}
break;
do_signal_pc:
addr = env->psw.addr;
do_signal:
info.si_signo = sig;
info.si_errno = 0;
info.si_code = n;
info._sifields._sigfault._addr = addr;
queue_signal(env, info.si_signo, &info);
break;
default:
fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr);
cpu_dump_state(cs, stderr, fprintf, 0);
exit(EXIT_FAILURE);
}
process_pending_signals (env);
}
}
| 1threat
|
Java : If inside method is throwing error, shouldn't the outside method also throw error? : <p>Say,</p>
<pre><code>public String testing() {
caller.call();
}
Class Caller {
public void call() throws Exception1 {
}
}
</code></pre>
<p>that is, is say, call() can throw Exception1, do I have to add same throws in testing() method definition also? Or its not needed? I am not getting any compile time error in Intellij IDE when I don't throws in testing() method definition. Shouldn't I have the compile time error?</p>
| 0debug
|
C# how to catch Exeption : I am new in `C#` programming and I don't understand this problem.
using (WebClient wc = new WebClient())
{
try{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
HtmlResult = wc.UploadString(URI, myParameters);
}catch(AuthenticateExeption a){
throw new AuthenticateExeption("I can not connect to the server...");
}
}
I am trying `catch` exeption using my `AuthenticateExeption`, but code never go to `throw new AuthenticateExeption("I can not connect to the server...");` and program always down on `HtmlResult = wc.UploadString(URI, myParameters);` line.
Why?
| 0debug
|
How is Anaconda related to Python? : <p>I am a beginner and I want to learn computer programming. So, for now, I have started learning Python by myself with some knowledge about programming in C and Fortran.</p>
<p>Now, I have installed Python version 3.6.0 and I have struggled finding a suitable text for learning Python in this version. Even the online lecture series ask for versions 2.7 and 2.5 . </p>
<p>Now that I have got a book which, however, makes codes in version 2 and <em>tries</em> to make it <em>as close as possible</em> in version 3 (according to the author); the author recommends "downloading Anaconda for Windows" for installing Python.</p>
<p>So, my <strong>question</strong> is: What is this <strong>'Anaconda'</strong>? I saw that it was some open data science platform. What does it mean? Is it some editor or something like Pycharm, IDLE or something?</p>
<p>Also, I downloaded my Python (the one that I am using right now) for Windows from Python.org and I didn't need to install any "open data science platform".
So what is this happening? </p>
<p>Please explain in easy language. I don't have too much knowledge about these.</p>
| 0debug
|
Custom Package in main golang : <p>Package main no look my package.</p>
<p>Struct project: </p>
<p><img src="https://sun9-23.userapi.com/c853528/v853528063/d2aa5/OnQlmJvxd4s.jpg" alt="struct"></p>
<p>Sunrise.go have name package <code>sunrise</code></p>
<p>Sunrise.go have function;</p>
<pre><code>func getSunriseConst() [64]struct {
x float64
y float64
z float64
} {
return sunrise
}
</code></pre>
<p>I want call function in main.go, but main no view my package. Help guys</p>
| 0debug
|
PHP error " Undefined variable: mysql_fetch_assoc" : <p>I'm recieving the above error when I try to run this code, I have tried multiple solutions, using fetch_array too:
<pre><code>$conn = mysql_connect('localhost', '-----', '-----','-----')
or die('Error connecting to mysql');
$sql = "SELECT * FROM Subject";
$result = mysql_query($sql);
$row=null;
echo "<table>";
while( $row = $mysql_fetch_assoc[$result]){
echo "<tr><td>";
echo $data['SubjectNo'];
echo "</td><td>";
echo $data['SubjectName'];
echo"</td></tr>";
}
echo "</table";
echo"urnan";
?>
</code></pre>
| 0debug
|
Sort array of string values without converting it into integer in ruby : I have an array of string having integer values and I want to sort it but without converting it into integer, I want to do it in Ruby,
Please suggest how can I do that?
Ex- array = ["0934", "123", "934", "0123"]
and expected output is
array = ["0123", "123", "0934", "934"]
| 0debug
|
VBScript RegEx - Non capturing group getting captured in full match : **Sample string =** dadasd_37=12abc_dadasd_asdasdasd_asdas_asd
**My regex =** `(?:_37=)([^_]+)`
**What i am trying to get=** 12abc (anything that starts with 37= and the word ends with _).
However, the full match is still coming as _37=12abc
| 0debug
|
static void superh_cpu_initfn(Object *obj)
{
CPUState *cs = CPU(obj);
SuperHCPU *cpu = SUPERH_CPU(obj);
CPUSH4State *env = &cpu->env;
cs->env_ptr = env;
cpu_exec_init(cs, &error_abort);
env->movcal_backup_tail = &(env->movcal_backup);
if (tcg_enabled()) {
sh4_translate_init();
}
}
| 1threat
|
VBA excel programming : [![output sheet][1]][1]
[![The sheet from which data has to be dumped.][2]][2]
There is an excel sheet with ItemId and ItemName.For a single ItemID there are 4-5 ItemName.The data from this sheet needs to be dumped into another sheet using VBA Excel Programming.
The sheet in which the data is dumped shall list the ItemName in different columns for a single ItemId.
[1]: http://i.stack.imgur.com/Fx3da.png
[2]: http://i.stack.imgur.com/rJy9w.png
| 0debug
|
Docker-compose hangs on Attaching to : <p>I have an issue when running docker-compose up. It hangs on attaching to and I cannot access my web app on <code>localhost:4200</code>.</p>
<p><strong>docker-compose.yml:</strong></p>
<pre><code>version: '2' # specify docker-compose version
# Define the services/containers to be run
services:
angular: # name of the first service
build:
context: .
dockerfile: ./.docker/scs.dockerfile # specify the directory of the Dockerfile
container_name: secure-cloud-storage-build-dev
image: secure-cloud-storage
ports:
- "4200:4200" # specify port forwarding
</code></pre>
<p><strong>dockerfile:</strong></p>
<pre><code># Stage 0, based on Node.js, to build and compile Angular
FROM node:8.6 as node
WORKDIR /app
COPY package.json /app/
RUN npm install
COPY ./ /app/
ARG env=prod
RUN npm run build -- --prod --environment $env
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
FROM nginx:1.13
COPY --from=node /app/dist/ /usr/share/nginx/html
COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf
</code></pre>
<p><strong>nginx-custom.conf:</strong></p>
<pre><code>server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
</code></pre>
<p><strong>Here is verbose output:</strong></p>
<p><a href="https://i.stack.imgur.com/wLhJr.png" rel="noreferrer">docker-compose --verbose up output</a></p>
<p>Any clues what might be going wrong? I am quite fresh in Docker world, basically doing tutorials, so might be something obvious i missed.
My <code>localhost:4200</code> returns <code>ERR_EMPTY_RESPONSE</code>.</p>
| 0debug
|
static int qcow2_update_options(BlockDriverState *bs, QDict *options,
int flags, Error **errp)
{
BDRVQcow2State *s = bs->opaque;
QemuOpts *opts = NULL;
const char *opt_overlap_check, *opt_overlap_check_template;
int overlap_check_template = 0;
uint64_t l2_cache_size, refcount_cache_size;
Qcow2Cache *l2_table_cache;
Qcow2Cache *refcount_block_cache;
uint64_t cache_clean_interval;
bool use_lazy_refcounts;
int i;
Error *local_err = NULL;
int ret;
opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail;
}
read_cache_sizes(bs, opts, &l2_cache_size, &refcount_cache_size,
&local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail;
}
l2_cache_size /= s->cluster_size;
if (l2_cache_size < MIN_L2_CACHE_SIZE) {
l2_cache_size = MIN_L2_CACHE_SIZE;
}
if (l2_cache_size > INT_MAX) {
error_setg(errp, "L2 cache size too big");
ret = -EINVAL;
goto fail;
}
refcount_cache_size /= s->cluster_size;
if (refcount_cache_size < MIN_REFCOUNT_CACHE_SIZE) {
refcount_cache_size = MIN_REFCOUNT_CACHE_SIZE;
}
if (refcount_cache_size > INT_MAX) {
error_setg(errp, "Refcount cache size too big");
ret = -EINVAL;
goto fail;
}
l2_table_cache = qcow2_cache_create(bs, l2_cache_size);
refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size);
if (l2_table_cache == NULL || refcount_block_cache == NULL) {
error_setg(errp, "Could not allocate metadata caches");
ret = -ENOMEM;
goto fail;
}
cache_clean_interval =
qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL, 0);
if (cache_clean_interval > UINT_MAX) {
error_setg(errp, "Cache clean interval too big");
ret = -EINVAL;
goto fail;
}
use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS,
(s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS));
if (use_lazy_refcounts && s->qcow_version < 3) {
error_setg(errp, "Lazy refcounts require a qcow2 image with at least "
"qemu 1.1 compatibility level");
ret = -EINVAL;
goto fail;
}
opt_overlap_check = qemu_opt_get(opts, QCOW2_OPT_OVERLAP);
opt_overlap_check_template = qemu_opt_get(opts, QCOW2_OPT_OVERLAP_TEMPLATE);
if (opt_overlap_check_template && opt_overlap_check &&
strcmp(opt_overlap_check_template, opt_overlap_check))
{
error_setg(errp, "Conflicting values for qcow2 options '"
QCOW2_OPT_OVERLAP "' ('%s') and '" QCOW2_OPT_OVERLAP_TEMPLATE
"' ('%s')", opt_overlap_check, opt_overlap_check_template);
ret = -EINVAL;
goto fail;
}
if (!opt_overlap_check) {
opt_overlap_check = opt_overlap_check_template ?: "cached";
}
if (!strcmp(opt_overlap_check, "none")) {
overlap_check_template = 0;
} else if (!strcmp(opt_overlap_check, "constant")) {
overlap_check_template = QCOW2_OL_CONSTANT;
} else if (!strcmp(opt_overlap_check, "cached")) {
overlap_check_template = QCOW2_OL_CACHED;
} else if (!strcmp(opt_overlap_check, "all")) {
overlap_check_template = QCOW2_OL_ALL;
} else {
error_setg(errp, "Unsupported value '%s' for qcow2 option "
"'overlap-check'. Allowed are any of the following: "
"none, constant, cached, all", opt_overlap_check);
ret = -EINVAL;
goto fail;
}
s->overlap_check = 0;
for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) {
s->overlap_check |=
qemu_opt_get_bool(opts, overlap_bool_option_names[i],
overlap_check_template & (1 << i)) << i;
}
s->l2_table_cache = l2_table_cache;
s->refcount_block_cache = refcount_block_cache;
s->use_lazy_refcounts = use_lazy_refcounts;
s->discard_passthrough[QCOW2_DISCARD_NEVER] = false;
s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true;
s->discard_passthrough[QCOW2_DISCARD_REQUEST] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST,
flags & BDRV_O_UNMAP);
s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true);
s->discard_passthrough[QCOW2_DISCARD_OTHER] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false);
s->cache_clean_interval = cache_clean_interval;
cache_clean_timer_init(bs, bdrv_get_aio_context(bs));
ret = 0;
fail:
qemu_opts_del(opts);
opts = NULL;
return ret;
}
| 1threat
|
static void usb_mtp_handle_reset(USBDevice *dev)
{
MTPState *s = USB_MTP(dev);
trace_usb_mtp_reset(s->dev.addr);
#ifdef __linux__
usb_mtp_inotify_cleanup(s);
#endif
usb_mtp_object_free(s, QTAILQ_FIRST(&s->objects));
s->session = 0;
usb_mtp_data_free(s->data_in);
s->data_in = NULL;
usb_mtp_data_free(s->data_out);
s->data_out = NULL;
g_free(s->result);
s->result = NULL;
}
| 1threat
|
static void quorum_aio_finalize(QuorumAIOCB *acb)
{
BDRVQuorumState *s = acb->common.bs->opaque;
int i, ret = 0;
if (acb->vote_ret) {
ret = acb->vote_ret;
}
acb->common.cb(acb->common.opaque, ret);
if (acb->is_read) {
for (i = 0; i < s->num_children; i++) {
qemu_vfree(acb->qcrs[i].buf);
qemu_iovec_destroy(&acb->qcrs[i].qiov);
}
}
g_free(acb->qcrs);
qemu_aio_release(acb);
}
| 1threat
|
Modify second column of ls -l in a directory : I am trying to modify the number following the permissions, which appears in the second column of ls -l:
drwxrwxrwx 1 ddel-rio ddel-rio 512 nov 15 20:27 test0
I want the 1 to be a 2, I've researched the hard links but I still can't solve it.
| 0debug
|
window.location.href = 'http://attack.com?user=' + user_input;
| 1threat
|
Hangman Assignment: Need help revealing the secret word : <p>I have a school assignment and in hangman you reveal the word slowly as the user guesses and I am having trouble with that.</p>
<p><strong>For example, this is what I want (ex. applesauce):</strong></p>
<p>guess: 'a'</p>
<p>display: 'a*****a***'</p>
<p>guess: 'p'</p>
<p>display: 'app***a***'</p>
<p><strong>This is what I currently have:</strong></p>
<p>guess: 'a'</p>
<p>display: 'a*****a***'</p>
<p>guess: 'p'</p>
<p>display: '*pp*******'</p>
<p><strong>Here is my code if it helps:</strong></p>
<pre><code>import java.util.Scanner;
import java.util.Random;
public class HangmanAssignment
{
static Scanner numIn = new Scanner(System.in);
static Scanner strIn = new Scanner(System.in);
// Used to hold the user's previous guesses into a string.
static StringBuffer buffer = new StringBuffer();
public static void main(String[] args)
{
String category;
int wordLength;
int position;
int lettersRemaining;
int totalLives = 10;
boolean isGuessInWord;
StringBuffer prevGuessedLetters;
String word;
String displayWord = "";
char guess;
category = getCategory();
word = getWord(category);
// Gets the length of the word.
wordLength = word.length();
lettersRemaining = wordLength;
System.out.println("The length of your word is: " + wordLength + " characters.");
// Generates as many '*' as long as word's length and stores it in 'displayWord'.
for (int i = 0; i < wordLength; i++)
{
displayWord += "-";
// System.out.println(displayWord); /* Testing */
}
while (lettersRemaining > 0 && totalLives > 0)
{
// Prompts user to guess a letter.
System.out.println("Guess a letter (Note: there are " + wordLength + " letters)");
guess = strIn.findWithinHorizon(".", 0).charAt(0);
// Checks if the letter guessed in within 'word'.
isGuessInWord = (word.indexOf(guess)) != -1;
// Checks if the guess is in within 'word'.
if (isGuessInWord == false)
{
totalLives--;
System.out.println("Sorry, but '" + guess + "' was not in the word.");
if (totalLives < 1)
{
System.out.println("It seems like you have no lives left! :(");
}
else if (totalLives == 1)
{
System.out.println("Careful! You only have 1 life left!");
}
else
{
System.out.println("You still have " + (totalLives) + " lives left!");
}
}
else
{
System.out.println("Nice one! The letter '" + guess + "' was in the word!");
for (position = 0; position < wordLength; position++)
{
String newDisplayWord = "";
for (position = 0; position < wordLength; position++)
{
if (word.charAt(position) == guess)
{
/* displayWord.charAt(position).equals(word.charAt(position)); */
System.out.print(guess);
lettersRemaining--;
}
else
{
System.out.print("*");
}
}
}
}
// Holds the user's previously guessed letters and the number of letters in the word that are still unknown.
System.out.println();
prevGuessedLetters = buffer.append(guess);
System.out.println("Previously guessed letters: " + (prevGuessedLetters));
System.out.println("Letters remaining: " + (lettersRemaining));
System.out.println("");
// Checks win/lose conditions.
if (lettersRemaining == 0)
{
System.out.println("Congratulations, '" + word + "' was the correct answer!");
}
if (totalLives < 1)
{
System.out.println("Sorry, you lose!");
System.out.println("The correct answer was '" + word + "'.");
{
break;
}
}
}
}
public static String getCategory()
{
String category;
System.out.println("=====================================");
System.out.println("Welcome to the Hangman Game!");
System.out.println("=====================================");
while (true)
{
System.out.println("Choose from the following categories:");
System.out.println("1. Car Brands");
System.out.println("2. Countries");
System.out.println("3. Animals");
System.out.println("4. Fruit");
System.out.println("");
category = strIn.nextLine();
if (category.toLowerCase().equals("1") || (category.toLowerCase().equals("one")))
{
category = "car brands";
}
else if (category.toLowerCase().equals("2") || (category.toLowerCase().equals("two")))
{
category = "countries";
}
else if (category.toLowerCase().equals("3") || (category.toLowerCase().equals("three")))
{
category = "animals";
}
else if (category.toLowerCase().equals("4") || (category.toLowerCase().equals("four")))
{
category = "fruit";
}
if (category.toLowerCase().equals("car brands") || category.toLowerCase().equals("countries") || category.toLowerCase().equals("animals") || category.toLowerCase().equals("fruit"))
{
System.out.println("");
System.out.println("Nice Choice! You have chosen the '" + category + "' category!");
System.out.println("");
break;
}
else
{
System.out.println("Sorry, but '" + category + "' is not a valid input. Try Again!");
System.out.println("");
}
}
return category;
}
public static String getWord(String category)
{
String[] carBrandsWord = {"toyota", "ferrari", "honda", "hyundai", "lamborghini", "dodge", "ford", "chevrolet", "fiat", "lexus", "volkswagen", "acura", "audi", "bentley", "bugatti", "buick", "cadillac"};
String[] countriesWord = {"canada", "england", "france", "switzerland", "australia", "sweden", "greece", "italy", "mexico", "brazil", "india", "china", "russia", "japan", "spain", "ireland"};
String[] animalsWord = {"cat", "dog", "parrot", "bear", "tiger", "monkey", "zebra", "hippopotamus", "chicken", "horse", "cow", "starfish", "squid", "wolf", "hyena", "cheetah", "penguin"};
String[] fruitsWord = {"apple", "banana", "orange", "grapes", "grapefruit", "apricot", "cherry", "guava", "kiwi", "mango", "melon", "olive", "pineapple", "strawberry", "watermelon"};
String word = "";
if (category.toLowerCase().equals("car brands"))
{
Random random = new Random();
int index = random.nextInt(carBrandsWord.length);
word = (carBrandsWord[index]);
}
else if (category.toLowerCase().equals("countries"))
{
Random random = new Random();
int index = random.nextInt(countriesWord.length);
word = (countriesWord[index]);
}
else if (category.toLowerCase().equals("animals"))
{
Random random = new Random();
int index = random.nextInt(animalsWord.length);
word = (animalsWord[index]);
}
else
{
Random random = new Random();
int index = random.nextInt(fruitsWord.length);
word = (fruitsWord[index]);
}
return word;
}
}
</code></pre>
| 0debug
|
Int32.Parse vs Int32.TryParse : <p>People have been suggesting to use Int32.TryParse but I found out that in case of any string such as "4e",it would give me output 0(i would directly print my input),whereas Int32.Parse would give an Exception. Is there a side to using TryParse which I am not able to see? Any help would be much appreciated</p>
| 0debug
|
Cant export service from module 'it was neither declared nor imported' : <p><br/>
I am trying to export an Service from one of my modules but i only get the following error:</p>
<pre><code>ERROR Error: Uncaught (in promise):
Error: Can't export value ConfirmDialogService from SharedModule as it was neither declared nor imported!
</code></pre>
<p>My Module is the following:</p>
<pre><code>import { NgModule } from "@angular/core";
import { CommonModule } from "@angular/common";
import { FormsModule } from "@angular/forms";
import { RouterModule } from "@angular/router";
import { MaterialModule } from "@angular/material";
import { ConfirmDialogComponent } from './confirm-dialog/confirm-dialog.component';
import { ConfirmDialogService } from './confirm-dialog/confirm-dialog.service';
@NgModule({
imports: [
RouterModule,
CommonModule,
MaterialModule,
FormsModule
],
providers: [
ConfirmDialogService
],
declarations: [
ConfirmDialogComponent
],
exports: [
ConfirmDialogComponent
ConfirmDialogService
]
})
export class SharedModule {}
</code></pre>
<p>The files do exist and are referenced correctly in TS but when running the app the error appears.</p>
| 0debug
|
static void string_cleanup(void *datap)
{
StringSerializeData *d = datap;
visit_free(string_output_get_visitor(d->sov));
visit_free(d->siv);
g_free(d->string);
g_free(d);
}
| 1threat
|
static void coroutine_fn bdrv_discard_co_entry(void *opaque)
{
DiscardCo *rwco = opaque;
rwco->ret = bdrv_co_discard(rwco->bs, rwco->sector_num, rwco->nb_sectors);
}
| 1threat
|
print variable after closing the file in perl : Below code works fine but I want $ip to be printed after closing the file.
use strict;
use warnings;
use POSIX;
my $file = "/tmp/example";
open(FILE, "<$file") or die $!;
while (<FILE>) {
my $lines = $_;
if ($lines =~ m/address/){
my($string, $ip) = (split ' ', $lines);
print "IP address is:$ip\n";
}
}
close(FILE);
| 0debug
|
enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags)
{
if (bps > 64U)
return AV_CODEC_ID_NONE;
if (flt) {
switch (bps) {
case 32:
return be ? AV_CODEC_ID_PCM_F32BE : AV_CODEC_ID_PCM_F32LE;
case 64:
return be ? AV_CODEC_ID_PCM_F64BE : AV_CODEC_ID_PCM_F64LE;
default:
return AV_CODEC_ID_NONE;
}
} else {
bps += 7;
bps >>= 3;
if (sflags & (1 << (bps - 1))) {
switch (bps) {
case 1:
return AV_CODEC_ID_PCM_S8;
case 2:
return be ? AV_CODEC_ID_PCM_S16BE : AV_CODEC_ID_PCM_S16LE;
case 3:
return be ? AV_CODEC_ID_PCM_S24BE : AV_CODEC_ID_PCM_S24LE;
case 4:
return be ? AV_CODEC_ID_PCM_S32BE : AV_CODEC_ID_PCM_S32LE;
default:
return AV_CODEC_ID_NONE;
}
} else {
switch (bps) {
case 1:
return AV_CODEC_ID_PCM_U8;
case 2:
return be ? AV_CODEC_ID_PCM_U16BE : AV_CODEC_ID_PCM_U16LE;
case 3:
return be ? AV_CODEC_ID_PCM_U24BE : AV_CODEC_ID_PCM_U24LE;
case 4:
return be ? AV_CODEC_ID_PCM_U32BE : AV_CODEC_ID_PCM_U32LE;
default:
return AV_CODEC_ID_NONE;
}
}
}
}
| 1threat
|
int ff_eac3_parse_header(AC3DecodeContext *s)
{
int i, blk, ch;
int ac3_exponent_strategy, parse_aht_info, parse_spx_atten_data;
int parse_transient_proc_info;
int num_cpl_blocks;
GetBitContext *gbc = &s->gbc;
if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {
avpriv_request_sample(s->avctx, "Dependent substream decoding");
return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
} else if (s->frame_type == EAC3_FRAME_TYPE_RESERVED) {
av_log(s->avctx, AV_LOG_ERROR, "Reserved frame type\n");
return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
}
if (s->substreamid) {
avpriv_request_sample(s->avctx, "Additional substreams");
return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
}
if (s->bit_alloc_params.sr_code == EAC3_SR_CODE_REDUCED) {
avpriv_request_sample(s->avctx, "Reduced sampling rate");
return AVERROR_PATCHWELCOME;
}
skip_bits(gbc, 5);
for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
skip_bits(gbc, 5);
if (get_bits1(gbc)) {
skip_bits(gbc, 8);
}
}
if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {
if (get_bits1(gbc)) {
skip_bits(gbc, 16);
}
}
if (get_bits1(gbc)) {
if (s->channel_mode > AC3_CHMODE_STEREO) {
s->preferred_downmix = get_bits(gbc, 2);
if (s->channel_mode & 1) {
s->center_mix_level_ltrt = get_bits(gbc, 3);
s->center_mix_level = get_bits(gbc, 3);
}
if (s->channel_mode & 4) {
s->surround_mix_level_ltrt = av_clip(get_bits(gbc, 3), 3, 7);
s->surround_mix_level = av_clip(get_bits(gbc, 3), 3, 7);
}
}
if (s->lfe_on && (s->lfe_mix_level_exists = get_bits1(gbc))) {
s->lfe_mix_level = get_bits(gbc, 5);
}
if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT) {
for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
if (get_bits1(gbc)) {
skip_bits(gbc, 6);
}
}
if (get_bits1(gbc)) {
skip_bits(gbc, 6);
}
switch(get_bits(gbc, 2)) {
case 1: skip_bits(gbc, 5); break;
case 2: skip_bits(gbc, 12); break;
case 3: {
int mix_data_size = (get_bits(gbc, 5) + 2) << 3;
skip_bits_long(gbc, mix_data_size);
break;
}
}
if (s->channel_mode < AC3_CHMODE_STEREO) {
for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
if (get_bits1(gbc)) {
skip_bits(gbc, 8);
skip_bits(gbc, 6);
}
}
}
if (get_bits1(gbc)) {
for (blk = 0; blk < s->num_blocks; blk++) {
if (s->num_blocks == 1 || get_bits1(gbc)) {
skip_bits(gbc, 5);
}
}
}
}
}
if (get_bits1(gbc)) {
s->bitstream_mode = get_bits(gbc, 3);
skip_bits(gbc, 2);
if (s->channel_mode == AC3_CHMODE_STEREO) {
s->dolby_surround_mode = get_bits(gbc, 2);
s->dolby_headphone_mode = get_bits(gbc, 2);
}
if (s->channel_mode >= AC3_CHMODE_2F2R) {
s->dolby_surround_ex_mode = get_bits(gbc, 2);
}
for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
if (get_bits1(gbc)) {
skip_bits(gbc, 8);
}
}
if (s->bit_alloc_params.sr_code != EAC3_SR_CODE_REDUCED) {
skip_bits1(gbc);
}
}
if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT && s->num_blocks != 6) {
skip_bits1(gbc);
}
if (s->frame_type == EAC3_FRAME_TYPE_AC3_CONVERT &&
(s->num_blocks == 6 || get_bits1(gbc))) {
skip_bits(gbc, 6);
}
if (get_bits1(gbc)) {
int addbsil = get_bits(gbc, 6);
for (i = 0; i < addbsil + 1; i++) {
skip_bits(gbc, 8);
}
}
if (s->num_blocks == 6) {
ac3_exponent_strategy = get_bits1(gbc);
parse_aht_info = get_bits1(gbc);
} else {
ac3_exponent_strategy = 1;
parse_aht_info = 0;
}
s->snr_offset_strategy = get_bits(gbc, 2);
parse_transient_proc_info = get_bits1(gbc);
s->block_switch_syntax = get_bits1(gbc);
if (!s->block_switch_syntax)
memset(s->block_switch, 0, sizeof(s->block_switch));
s->dither_flag_syntax = get_bits1(gbc);
if (!s->dither_flag_syntax) {
for (ch = 1; ch <= s->fbw_channels; ch++)
s->dither_flag[ch] = 1;
}
s->dither_flag[CPL_CH] = s->dither_flag[s->lfe_ch] = 0;
s->bit_allocation_syntax = get_bits1(gbc);
if (!s->bit_allocation_syntax) {
s->bit_alloc_params.slow_decay = ff_ac3_slow_decay_tab[2];
s->bit_alloc_params.fast_decay = ff_ac3_fast_decay_tab[1];
s->bit_alloc_params.slow_gain = ff_ac3_slow_gain_tab [1];
s->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[2];
s->bit_alloc_params.floor = ff_ac3_floor_tab [7];
}
s->fast_gain_syntax = get_bits1(gbc);
s->dba_syntax = get_bits1(gbc);
s->skip_syntax = get_bits1(gbc);
parse_spx_atten_data = get_bits1(gbc);
num_cpl_blocks = 0;
if (s->channel_mode > 1) {
for (blk = 0; blk < s->num_blocks; blk++) {
s->cpl_strategy_exists[blk] = (!blk || get_bits1(gbc));
if (s->cpl_strategy_exists[blk]) {
s->cpl_in_use[blk] = get_bits1(gbc);
} else {
s->cpl_in_use[blk] = s->cpl_in_use[blk-1];
}
num_cpl_blocks += s->cpl_in_use[blk];
}
} else {
memset(s->cpl_in_use, 0, sizeof(s->cpl_in_use));
}
if (ac3_exponent_strategy) {
for (blk = 0; blk < s->num_blocks; blk++) {
for (ch = !s->cpl_in_use[blk]; ch <= s->fbw_channels; ch++) {
s->exp_strategy[blk][ch] = get_bits(gbc, 2);
}
}
} else {
for (ch = !((s->channel_mode > 1) && num_cpl_blocks); ch <= s->fbw_channels; ch++) {
int frmchexpstr = get_bits(gbc, 5);
for (blk = 0; blk < 6; blk++) {
s->exp_strategy[blk][ch] = ff_eac3_frm_expstr[frmchexpstr][blk];
}
}
}
if (s->lfe_on) {
for (blk = 0; blk < s->num_blocks; blk++) {
s->exp_strategy[blk][s->lfe_ch] = get_bits1(gbc);
}
}
if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT &&
(s->num_blocks == 6 || get_bits1(gbc))) {
skip_bits(gbc, 5 * s->fbw_channels);
}
if (parse_aht_info) {
s->channel_uses_aht[CPL_CH]=0;
for (ch = (num_cpl_blocks != 6); ch <= s->channels; ch++) {
int use_aht = 1;
for (blk = 1; blk < 6; blk++) {
if ((s->exp_strategy[blk][ch] != EXP_REUSE) ||
(!ch && s->cpl_strategy_exists[blk])) {
use_aht = 0;
break;
}
}
s->channel_uses_aht[ch] = use_aht && get_bits1(gbc);
}
} else {
memset(s->channel_uses_aht, 0, sizeof(s->channel_uses_aht));
}
if (!s->snr_offset_strategy) {
int csnroffst = (get_bits(gbc, 6) - 15) << 4;
int snroffst = (csnroffst + get_bits(gbc, 4)) << 2;
for (ch = 0; ch <= s->channels; ch++)
s->snr_offset[ch] = snroffst;
}
if (parse_transient_proc_info) {
for (ch = 1; ch <= s->fbw_channels; ch++) {
if (get_bits1(gbc)) {
skip_bits(gbc, 10);
skip_bits(gbc, 8);
}
}
}
for (ch = 1; ch <= s->fbw_channels; ch++) {
if (parse_spx_atten_data && get_bits1(gbc)) {
s->spx_atten_code[ch] = get_bits(gbc, 5);
} else {
s->spx_atten_code[ch] = -1;
}
}
if (s->num_blocks > 1 && get_bits1(gbc)) {
int block_start_bits = (s->num_blocks-1) * (4 + av_log2(s->frame_size-2));
skip_bits_long(gbc, block_start_bits);
avpriv_request_sample(s->avctx, "Block start info");
}
for (ch = 1; ch <= s->fbw_channels; ch++) {
s->first_spx_coords[ch] = 1;
s->first_cpl_coords[ch] = 1;
}
s->first_cpl_leak = 1;
return 0;
}
| 1threat
|
Coping a row from sheet to another based on whether the candidate is accepted or rejected : <p>Now, I'm trying to create a semi automated tool in google sheets for hiring (self-use). I need a code to copy the whole row based on whether the candidate is (Accepted or Rejected) if the candidate is accepted I want to copy the whole row and paste it in the (Accepted Candidates Sheet).</p>
<p>Can anyone support me?</p>
<p>Thanks in advance.</p>
| 0debug
|
Can i store a Map<String, Object> inside a Shared Preferences in dart? : <p>Is there a way that we could save a map object into shared preferences so that we can fetch the data from shared preferences rather than listening to the database all the time.
actually i want to reduce the amount of data downloaded from firebase. so i am thinking of a solution to have a listener for shared prefs and read the data from shared prefs.</p>
<p>But i dont see a way of achieving this in flutter or dart.</p>
<p>Please can someone help me to achieve this if there is a workaround.</p>
<p>Many Thanks,
Mahi </p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.