problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static void blend_image(AVFilterContext *ctx,
AVFilterBufferRef *dst, AVFilterBufferRef *src,
int x, int y)
{
OverlayContext *over = ctx->priv;
int i, j, k;
int width = src->video->w;
int height = src->video->h;
if (over->main_is_packed_rgb) {
uint8_t *dp = dst->data[0] + x * over->main_pix_step[0] +
y * dst->linesize[0];
uint8_t *sp = src->data[0];
uint8_t alpha;
const int dr = over->main_rgba_map[R];
const int dg = over->main_rgba_map[G];
const int db = over->main_rgba_map[B];
const int da = over->main_rgba_map[A];
const int dstep = over->main_pix_step[0];
const int sr = over->overlay_rgba_map[R];
const int sg = over->overlay_rgba_map[G];
const int sb = over->overlay_rgba_map[B];
const int sa = over->overlay_rgba_map[A];
const int sstep = over->overlay_pix_step[0];
const int main_has_alpha = over->main_has_alpha;
for (i = 0; i < height; i++) {
uint8_t *d = dp, *s = sp;
for (j = 0; j < width; j++) {
alpha = s[sa];
if (main_has_alpha && alpha != 0 && alpha != 255) {
uint8_t alpha_d = d[da];
alpha = UNPREMULTIPLY_ALPHA(alpha, alpha_d);
}
switch (alpha) {
case 0:
break;
case 255:
d[dr] = s[sr];
d[dg] = s[sg];
d[db] = s[sb];
break;
default:
d[dr] = FAST_DIV255(d[dr] * (255 - alpha) + s[sr] * alpha);
d[dg] = FAST_DIV255(d[dg] * (255 - alpha) + s[sg] * alpha);
d[db] = FAST_DIV255(d[db] * (255 - alpha) + s[sb] * alpha);
}
if (main_has_alpha) {
switch (alpha) {
case 0:
break;
case 255:
d[da] = s[sa];
break;
default:
d[da] += FAST_DIV255((255 - d[da]) * s[sa]);
}
}
d += dstep;
s += sstep;
}
dp += dst->linesize[0];
sp += src->linesize[0];
}
} else {
const int main_has_alpha = over->main_has_alpha;
if (main_has_alpha) {
uint8_t *da = dst->data[3] + x * over->main_pix_step[3] +
y * dst->linesize[3];
uint8_t *sa = src->data[3];
uint8_t alpha;
for (i = 0; i < height; i++) {
uint8_t *d = da, *s = sa;
for (j = 0; j < width; j++) {
alpha = *s;
if (alpha != 0 && alpha != 255) {
uint8_t alpha_d = *d;
alpha = UNPREMULTIPLY_ALPHA(alpha, alpha_d);
}
switch (alpha) {
case 0:
break;
case 255:
*d = *s;
break;
default:
*d += FAST_DIV255((255 - *d) * *s);
}
d += 1;
s += 1;
}
da += dst->linesize[3];
sa += src->linesize[3];
}
}
for (i = 0; i < 3; i++) {
int hsub = i ? over->hsub : 0;
int vsub = i ? over->vsub : 0;
uint8_t *dp = dst->data[i] + (x >> hsub) +
(y >> vsub) * dst->linesize[i];
uint8_t *sp = src->data[i];
uint8_t *ap = src->data[3];
int wp = FFALIGN(width, 1<<hsub) >> hsub;
int hp = FFALIGN(height, 1<<vsub) >> vsub;
for (j = 0; j < hp; j++) {
uint8_t *d = dp, *s = sp, *a = ap;
for (k = 0; k < wp; k++) {
int alpha_v, alpha_h, alpha;
if (hsub && vsub && j+1 < hp && k+1 < wp) {
alpha = (a[0] + a[src->linesize[3]] +
a[1] + a[src->linesize[3]+1]) >> 2;
} else if (hsub || vsub) {
alpha_h = hsub && k+1 < wp ?
(a[0] + a[1]) >> 1 : a[0];
alpha_v = vsub && j+1 < hp ?
(a[0] + a[src->linesize[3]]) >> 1 : a[0];
alpha = (alpha_v + alpha_h) >> 1;
} else
alpha = a[0];
if (main_has_alpha && alpha != 0 && alpha != 255) {
uint8_t alpha_d;
if (hsub && vsub && j+1 < hp && k+1 < wp) {
alpha_d = (d[0] + d[src->linesize[3]] +
d[1] + d[src->linesize[3]+1]) >> 2;
} else if (hsub || vsub) {
alpha_h = hsub && k+1 < wp ?
(d[0] + d[1]) >> 1 : d[0];
alpha_v = vsub && j+1 < hp ?
(d[0] + d[src->linesize[3]]) >> 1 : d[0];
alpha_d = (alpha_v + alpha_h) >> 1;
} else
alpha_d = d[0];
alpha = UNPREMULTIPLY_ALPHA(alpha, alpha_d);
}
*d = FAST_DIV255(*d * (255 - alpha) + *s * alpha);
s++;
d++;
a += 1 << hsub;
}
dp += dst->linesize[i];
sp += src->linesize[i];
ap += (1 << vsub) * src->linesize[3];
}
}
}
}
| 1threat
|
qcrypto_tls_session_check_credentials(QCryptoTLSSession *session,
Error **errp)
{
if (object_dynamic_cast(OBJECT(session->creds),
TYPE_QCRYPTO_TLS_CREDS_ANON)) {
return 0;
} else if (object_dynamic_cast(OBJECT(session->creds),
TYPE_QCRYPTO_TLS_CREDS_X509)) {
if (session->creds->verifyPeer) {
return qcrypto_tls_session_check_certificate(session,
errp);
} else {
return 0;
}
} else {
error_setg(errp, "Unexpected credential type %s",
object_get_typename(OBJECT(session->creds)));
return -1;
}
}
| 1threat
|
Endianess using %d specifier for float : <pre><code>void main()
{
float a=2;
printf("%d",a);
}
</code></pre>
<p>In my machine, float is 4 bytes, int is 2 bytes and bytes are stored in little-endian format.</p>
<p>a is 0x 00 00 00 02</p>
<p>Now as my machine is little endian, the bytes should be stored as 0x 02 00 00 00</p>
<p>Now when I use %d specifer, first 2 bytes should be fetched and output should be 512, but I am not getting that output.</p>
<p>Can someone tell me why is it happening?</p>
| 0debug
|
static void memory_dump(Monitor *mon, int count, int format, int wsize,
target_phys_addr_t addr, int is_physical)
{
CPUState *env;
int l, line_size, i, max_digits, len;
uint8_t buf[16];
uint64_t v;
if (format == 'i') {
int flags;
flags = 0;
env = mon_get_cpu();
if (!env && !is_physical)
return;
#ifdef TARGET_I386
if (wsize == 2) {
flags = 1;
} else if (wsize == 4) {
flags = 0;
} else {
flags = 0;
if (env) {
#ifdef TARGET_X86_64
if ((env->efer & MSR_EFER_LMA) &&
(env->segs[R_CS].flags & DESC_L_MASK))
flags = 2;
else
#endif
if (!(env->segs[R_CS].flags & DESC_B_MASK))
flags = 1;
}
}
#endif
monitor_disas(mon, env, addr, count, is_physical, flags);
return;
}
len = wsize * count;
if (wsize == 1)
line_size = 8;
else
line_size = 16;
max_digits = 0;
switch(format) {
case 'o':
max_digits = (wsize * 8 + 2) / 3;
break;
default:
case 'x':
max_digits = (wsize * 8) / 4;
break;
case 'u':
case 'd':
max_digits = (wsize * 8 * 10 + 32) / 33;
break;
case 'c':
wsize = 1;
break;
}
while (len > 0) {
if (is_physical)
monitor_printf(mon, TARGET_FMT_plx ":", addr);
else
monitor_printf(mon, TARGET_FMT_lx ":", (target_ulong)addr);
l = len;
if (l > line_size)
l = line_size;
if (is_physical) {
cpu_physical_memory_rw(addr, buf, l, 0);
} else {
env = mon_get_cpu();
if (!env)
break;
if (cpu_memory_rw_debug(env, addr, buf, l, 0) < 0) {
monitor_printf(mon, " Cannot access memory\n");
break;
}
}
i = 0;
while (i < l) {
switch(wsize) {
default:
case 1:
v = ldub_raw(buf + i);
break;
case 2:
v = lduw_raw(buf + i);
break;
case 4:
v = (uint32_t)ldl_raw(buf + i);
break;
case 8:
v = ldq_raw(buf + i);
break;
}
monitor_printf(mon, " ");
switch(format) {
case 'o':
monitor_printf(mon, "%#*" PRIo64, max_digits, v);
break;
case 'x':
monitor_printf(mon, "0x%0*" PRIx64, max_digits, v);
break;
case 'u':
monitor_printf(mon, "%*" PRIu64, max_digits, v);
break;
case 'd':
monitor_printf(mon, "%*" PRId64, max_digits, v);
break;
case 'c':
monitor_printc(mon, v);
break;
}
i += wsize;
}
monitor_printf(mon, "\n");
addr += l;
len -= l;
}
}
| 1threat
|
How to force Laravel Project to use HTTPS for all routes? : <p>I am working on a project that requires a secure connection.</p>
<p>I can set the route, uri, asset to use 'https' via:</p>
<pre><code>Route::get('order/details/{id}', ['uses' => 'OrderController@details', 'as' => 'order.details', 'https']);
url($language.'/index', [], true)
asset('css/bootstrap.min.css', true)
</code></pre>
<p>But setting the parameters all the time seems tiring.</p>
<p>Is there a way to force all routes to generate HTTPS links?</p>
| 0debug
|
document.write('<script src="evil.js"></script>');
| 1threat
|
static void memory_region_finalize(Object *obj)
{
MemoryRegion *mr = MEMORY_REGION(obj);
assert(QTAILQ_EMPTY(&mr->subregions));
assert(memory_region_transaction_depth == 0);
mr->destructor(mr);
memory_region_clear_coalescing(mr);
g_free((char *)mr->name);
g_free(mr->ioeventfds);
}
| 1threat
|
How do I re-write/modify my current python interpreter's grammar structure, not too good with python : This is my current python interpreter that use parsing rule to take input and then print out the expression. The interpreter works fine, but I want make and add certain changes of my current grammar rules to new grammar rules. So far I can only get some grammar changes that I want.
This is the changes I want to make from my current grammar:
# <stmt-list> ::= empty | <stmt> <stmt-list>
to
# <stmt_list> ::= <stmt> | <stmt> <stmt_list>
# <factor> ::= id | intnum | ( <expr> )
to
# <base> ::= (<expr>) | id | number
<stmt> ::= id = <expr> ; | print <expr>;
to
<stmt> ::= id = <expr> ; | iprint <expr> ; | rprint <expr> ;
Also I'm sure not sure how implement the new grammar rules below into my interpreter, I think I might already have them?
<prog> ::= <decl_list> <stmt_list>
<decl-list> ::= <decl> | <decl> <decl_list>
<decl> ::= <type> <id_list> ;
<type> ::= int | real
<id_list> ::= id | id {, <id_list>}
This is my current code for my current grammar:
import sys
global varTable
varTable = {}
def main():
global itProgram, nextToken, nextChar, nextLex, flagEof, strStmt
nextToken = ""
nextChar = ""
flagEof = False
strStmt = ""
try:
fileProgram = open(sys.argv[1], "rt")
except IndexError:
print "Missing input file!"
return
except IOError:
print "Could not open \'" + sys.argv[1] + "\'!"
return
strProgram = fileProgram.read()
itProgram = iter(strProgram)
if strProgram == "":
nextChar = ""
else:
nextChar = itProgram.next()
#while not flagEof:
funcLex()
stmtList()
def funcLex():
global itProgram, nextToken, nextLex, nextChar, flagEof, strStmt
nextToken = ""
nextLex = ""
isFloat = False
try:
while nextChar.isspace():
nextChar = itProgram.next()
except StopIteration:
nextChar = ""
funcLex()
return
try:
if nextChar == "(":
nextToken = "LPARA"
nextLex = nextChar
nextChar = itProgram.next()
elif nextChar == ")":
nextToken = "RPARA"
nextLex = nextChar
nextChar = itProgram.next()
elif nextChar == "+":
nextToken = "ADD"
nextLex = nextChar
nextChar = itProgram.next()
elif nextChar == "-":
nextToken = "SUB"
nextLex = nextChar
nextChar = itProgram.next()
elif nextChar == "*":
nextToken = "MULT"
nextLex = nextChar
nextChar = itProgram.next()
elif nextChar == "/":
nextToken = "DIV"
nextLex = nextChar
nextChar = itProgram.next()
elif nextChar == "=":
nextToken = "ASSIGN"
nextLex = nextChar
nextChar = itProgram.next()
elif nextChar == ";":
nextToken = "SEMI"
nextLex = nextChar
nextChar = itProgram.next()
elif nextChar.isalpha():
nextLex = nextChar
nextChar = itProgram.next()
while nextChar.isalnum():
nextLex += nextChar
nextChar = itProgram.next()
if nextLex == "print":
nextToken = "PRINT"
else:
nextToken = "ID"
elif nextChar.isalnum():
nextLex = nextChar
nextChar = itProgram.next()
while nextChar.isalnum() or nextChar == ".":
if nextChar == ".":
isFloat = True
nextLex += nextChar
nextChar = itProgram.next()
if isFloat:
nextToken = "FLOAT"
else:
nextToken = "INT"
elif nextChar == "":
nextLex = nextChar
nextToken = "EMPTY"
flagEof = True
else:
nextToken = "UNKNOWN"
#print "Syntax error!"
except StopIteration:
nextChar = ""
strStmt = strStmt + nextLex + " "
if nextToken == "SEMI":
print strStmt
strStmt = ""
# <stmt-list> ::= empty | <stmt> <stmt-list>
def stmtList():
global nextToken
if nextToken == "EMPTY":
print ">>> Empty .tiny file."
else:
while nextToken != "EMPTY":
stmt()
# <stmt> ::= id = <expr> ; |
# print <expr> ;
def stmt():
global nextToken, nextLex
if nextToken == "ID":
varName = nextLex
funcLex()
if nextToken == "ASSIGN":
funcLex()
result = expr()
if result[1] != "UNKNOWN":
lookupVarTable(varName, result[0], result[1])
else:
printError("undefined variable.")
elif nextToken == "PRINT":
funcLex()
result = expr()
if result[1] != "UNKNOWN" and nextToken == "SEMI":
print ">>> " + str(result[0])
elif result[1] == "UNKNOWN":
printError("undefined variable.")
else:
printError("<stmt> syntax error.")
return
if nextToken == "SEMI":
funcLex()
else:
printError("<stmt> missing ';'")
# <expr> ::= <term> { + <term> | - <term> }
def expr():
global nextToken, nextLex
lResult = term()
while nextToken == "ADD" or nextToken == "SUB":
operator = nextToken
funcLex()
rResult = term()
#Variable is not defined
if lResult[1] == "UNKNOWN" or rResult[1] == "UNKNOWN":
printError("Undefined variable!")
if lResult[1] != rResult[1]: #type mismatch
printError("Type mismatch!")
elif operator == "ADD":
lResult = (lResult[0]+rResult[0], lResult[1])
else:
lResult = (lResult[0]-rResult[0], lResult[1])
return lResult
# <term> ::= <factor> { * <factor> | / <factor> }
def term():
global nextToken, nextLex
lResult = factor()
while nextToken == "MULT" or nextToken == "DIV":
operator = nextToken
funcLex()
rResult = factor()
#Variable is not defined
if lResult[1] == "UNKNOWN" or rResult[1] == "UNKNOWN":
printError("Undefined variable!")
if lResult[1] != rResult[1]: #type mismatch
printError("Type mismatch!")
elif operator == "MULT":
lResult = (lResult[0]*rResult[0], lResult[1])
else:
lResult = (lResult[0]/rResult[0], lResult[1])
return lResult
# <factor> ::= id | intnum | ( <expr> )
def factor():
global nextToken, nextLex
if nextToken == "ID":
result = lookupVarTable(nextLex, 0, "UNKNOWN")
funcLex()
elif nextToken == "INT":
result = (int(nextLex), "INT")
funcLex()
elif nextToken == "FLOAT":
result = (float(nextLex), "FLOAT")
funcLex()
elif nextToken == "LPARA":
funcLex()
result = expr()
if nextToken == "RPARA":
funcLex()
else:
printError("<factor>")
return result
def printError(strMessage):
global strStmt
if strStmt != "":
print strStmt
print ">>> Error: " + strMessage
exit()
def lookupVarTable(varName, varValue, varType):
#if varName not in varTable:
# varValue == "UNKNOWN"
if varType != "UNKNOWN":
varTable[varName] = (varValue, varType)
return varTable[varName]
elif varName in varTable:
return varTable[varName]
else:
return (varValue, varType)
if __name__ == "__main__":
main()
| 0debug
|
static int send_sub_rect_jpeg(VncState *vs, int x, int y, int w, int h,
int bg, int fg, int colors,
VncPalette *palette)
{
int ret;
if (colors == 0) {
if (tight_detect_smooth_image(vs, w, h)) {
int quality = tight_conf[vs->tight.quality].jpeg_quality;
ret = send_jpeg_rect(vs, x, y, w, h, quality);
ret = send_full_color_rect(vs, x, y, w, h);
}
} else if (colors == 1) {
ret = send_solid_rect(vs);
} else if (colors == 2) {
ret = send_mono_rect(vs, x, y, w, h, bg, fg);
} else if (colors <= 256) {
if (colors > 96 &&
tight_detect_smooth_image(vs, w, h)) {
int quality = tight_conf[vs->tight.quality].jpeg_quality;
ret = send_jpeg_rect(vs, x, y, w, h, quality);
ret = send_palette_rect(vs, x, y, w, h, palette);
}
}
return ret;
}
| 1threat
|
How do you right align a horizontal UIStackView? : <p>I've yet to find an answer for this anywhere and I'm not sure if it's possible, but I'm trying to right align a horizontal <code>UIStackView</code>, so that if subviews are hidden they move towards the right side not the left. Either programmatically (in Swift) or using the Interface Builder</p>
| 0debug
|
How do I replace the words in a list with the position of that word? It should be pretty basic please, like GCSE level : Sentence = input("type in sentence:"). split()
#The above stores the individual words in Sentence, into a list
# But now how do I replace each word in Sentence with the position of that word
| 0debug
|
Replace a string and duplicate all rows containing it in R : I have a data.table in R, where I would like to duplicate rows m times and replace a 'string' to 'string'_(m times).
Example table:
Input Table:
[![enter image description here][1]][1]
If number of repetitions is m ( say, m=2) then I would need the output table to look like this:
[![enter image description here][2]][2]
So for every row with OrderId, the output table should have m rows, where the OrderId is changed to OrderId_(1 to m) , like OrderId_1, OrderId_2 etc. The change should also happen to the ProdId field where there is OrdId prefix.
And the quantity needs to be incremented by 1 for every new row
[1]: https://i.stack.imgur.com/w2EP7.png
[2]: https://i.stack.imgur.com/dvNfU.png
Please guide me how to approach this in R. Any pointers would be of great help. Thank you.
| 0debug
|
Call function in itself in callback : <p>i am not quite sure that Title related to my problem, so sorry.</p>
<p>I have asynchronous function that call callback function. So the main idea is I want to call function "dodo" each time after "asyncFunc" is done.</p>
<p>Are there some patterns for that? Are there issues releated to memory leak ?</p>
<pre><code>var can = true;
function dodo() {
if(can)
{
can = false;
asyncFunc(function(data) {
doSmth();
can = true;
});
}
}
setInterval(dodo, 0);
</code></pre>
| 0debug
|
how to make py.test --cov skip virtualenv directory : <p>Should I care how my tests cover the external libraries I'm using in my project ? </p>
<p>The py.test --cov displays how all files are covered, including ones in my virtualenv directory. How can I make the output show only the coverage of the modules I've written ?</p>
| 0debug
|
'ansible_date_time' is undefined : <p>Trying to register an ec2 instance in AWS with Ansible's ec2_ami module, and using current date/time as version (we'll end up making a lot of AMIs in the future).</p>
<p>This is what I have:</p>
<pre><code>- name: Create new AMI
hosts: localhost
connection: local
gather_facts: false
vars:
tasks:
- include_vars: ami_vars.yml
- debug: var=ansible_date_time
- name: Register ec2 instance as AMI
ec2_ami: aws_access_key={{ ec2_access_key }}
aws_secret_key={{ ec2_secret_key }}
instance_id={{ temp_instance.instance_ids[0] }}
region={{ region }}
wait=yes
name={{ ami_name }}
with_items: temp_instance
register: new_ami
</code></pre>
<p>From ami_vars.yml:</p>
<pre><code>ami_version: "{{ ansible_date_time.iso8601 }}"
ami_name: ami_test_{{ ami_version }}
</code></pre>
<p>When I run the full playbook, I get this error message:</p>
<pre><code>fatal: [localhost]: FAILED! => {"failed": true, "msg": "ERROR! ERROR! ERROR! 'ansible_date_time' is undefined"}
</code></pre>
<p>However, when run the debug command separately, from a separate playbook, it works fine:</p>
<pre><code>- name: Test date-time lookup
hosts: localhost
connection: local
tasks:
- include_vars: ami_vars.yml
- debug: msg="ami version is {{ ami_version }}"
- debug: msg="ami name is {{ ami_name }}"
</code></pre>
<p>Result:</p>
<pre><code>TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": "ami version is 2016-02-05T19:32:24Z"
}
TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": "ami name is ami_test_2016-02-05T19:32:24Z"
}
</code></pre>
<p>Any idea what's going on?</p>
| 0debug
|
static int kvm_virtio_pci_vq_vector_unmask(VirtIOPCIProxy *proxy,
unsigned int queue_no,
unsigned int vector,
MSIMessage msg)
{
VirtQueue *vq = virtio_get_queue(proxy->vdev, queue_no);
EventNotifier *n = virtio_queue_get_guest_notifier(vq);
VirtIOIRQFD *irqfd = &proxy->vector_irqfd[vector];
int ret;
if (irqfd->msg.data != msg.data || irqfd->msg.address != msg.address) {
ret = kvm_irqchip_update_msi_route(kvm_state, irqfd->virq, msg);
if (ret < 0) {
return ret;
}
}
if (proxy->vdev->guest_notifier_mask) {
proxy->vdev->guest_notifier_mask(proxy->vdev, queue_no, false);
if (proxy->vdev->guest_notifier_pending &&
proxy->vdev->guest_notifier_pending(proxy->vdev, queue_no)) {
event_notifier_set(n);
}
} else {
ret = kvm_virtio_pci_irqfd_use(proxy, queue_no, vector);
}
return ret;
}
| 1threat
|
How to install DrRacket in Kali Linux : <p>I want to Install DrRacket in Kali Linux. I send the next command</p>
<blockquote>
<p>sudo add-apt-repository ppa:plt/racket</p>
</blockquote>
<p>But, I receive the next message:</p>
<blockquote>
<p>aptsources.distro.NoDistroTemplateException: Error: could not find a
distribution template for Kali/kali-rolling</p>
</blockquote>
<p>Somebody know how to install it?</p>
| 0debug
|
how to make single sql query without using union for more than 2 sql statements ? : SELECT 'INITIALIZE' AS PROCESS_DESC,floor((Max(EXEC_DATE)-min(EXEC_DATE))*24) || ' HOURS ' || mod(floor((Max(EXEC_DATE)-min(EXEC_DATE))*24*60),60) || ' MINUTES ' || mod(floor((Max(EXEC_DATE)-min(EXEC_DATE))*24*60*60),60) || ' SECS ' time_difference FROM spool_table WHERE process_desc='INITIALIZE' AND to_date(EXEC_DATE, 'DD-MON-YYYY')= (select to_date(EXEC_DATE, 'DD-MON-YYYY')= from spool_table WHERE process_desc='INITIALIZE') UNION ALL SELECT 'PRELIM' AS PROCESS_DESC, floor((Max(EXEC_DATE)-min(EXEC_DATE))*24) || ' HOURS ' || mod(floor((Max(EXEC_DATE)-min(EXEC_DATE))*24*60),60) || ' MINUTES ' || mod(floor((Max(EXEC_DATE)-min(EXEC_DATE))*24*60*60),60) || ' SECS ' time_difference FROM spool_table WHERE process_desc='PRELIM' AND to_date(EXEC_DATE, 'DD-MON-YYYY')= (select to_date(Max(EXEC_DATE), 'DD-MON-YYYY') from spool_table WHERE process_desc='PRELIM')
| 0debug
|
int kvm_arch_insert_hw_breakpoint(target_ulong addr, target_ulong len, int type)
{
return -EINVAL;
}
| 1threat
|
Azure Pipeline Nuget Package Versioning Scheme, How to Get "1.0.$(Rev:r)" : <p>I'm setting up an Azure Pipelines build that needs to package a C# .NET class library into a NuGet package.</p>
<p>In <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/artifacts/nuget?view=azure-devops&tabs=yaml#package-versioning" rel="noreferrer">this documentation</a>, it lists a couple different ways to automatically generate SemVer strings. In particular, I want to implement this one:</p>
<blockquote>
<p><code>$(Major).$(Minor).$(rev:.r)</code>, where <code>Major</code> and <code>Minor</code> are two variables
defined in the build pipeline. This format will automatically
increment the build number and the package version with a new patch
number. It will keep the major and minor versions constant, until you
change them manually in the build pipeline.</p>
</blockquote>
<p>But that's all they say about it, no example is provided. A link to learn more takes you to <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/package/nuget?view=azure-devops" rel="noreferrer">this documentation</a>, where it says this:</p>
<blockquote>
<p>For <code>byBuildNumber</code>, the version will be set to the build number, ensure
that your build number is a proper SemVer e.g. <code>1.0.$(Rev:r)</code>. If you
select byBuildNumber, the task will extract a dotted version, <code>1.2.3.4</code>
and use only that, dropping any label. To use the build number as is,
you should use byEnvVar as described above, and set the environment
variable to <code>BUILD_BUILDNUMBER</code>.</p>
</blockquote>
<p>Again, no example is provided. It looks like I want to use <code>versioningScheme: byBuildNumber</code>, but I'm not quite sure how to set the build number, I think it pulls it from the <code>BUILD_BUILDNUMBER</code> environment variable, but I can't find a way to set environment variables, only script variables. Furthermore, am I suppose to just set that to <code>1.0.$(Rev:r)</code>, or to <code>$(Major).$(Minor).$(rev:.r)</code>? I'm afraid that would just interpret it literally.</p>
<p>Googling for the literal string "versioningScheme: byBuildNumber" returns a single result... Does anyone have a working <code>azure-pipelines.yml</code> with this versioning scheme?</p>
| 0debug
|
static inline void int8x8_fmul_int32(DCADSPContext *dsp, float *dst,
const int8_t *src, int scale)
{
dsp->int8x8_fmul_int32(dst, src, scale);
}
| 1threat
|
static int set_sps(HEVCContext *s, const HEVCSPS *sps)
{
#define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + CONFIG_HEVC_D3D11VA_HWACCEL)
enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts;
int ret;
export_stream_params(s->avctx, &s->ps, sps);
pic_arrays_free(s);
ret = pic_arrays_init(s, sps);
if (ret < 0)
goto fail;
if (sps->pix_fmt == AV_PIX_FMT_YUV420P || sps->pix_fmt == AV_PIX_FMT_YUVJ420P) {
#if CONFIG_HEVC_DXVA2_HWACCEL
*fmt++ = AV_PIX_FMT_DXVA2_VLD;
#endif
#if CONFIG_HEVC_D3D11VA_HWACCEL
*fmt++ = AV_PIX_FMT_D3D11VA_VLD;
#endif
}
*fmt++ = sps->pix_fmt;
*fmt = AV_PIX_FMT_NONE;
ret = ff_get_format(s->avctx, pix_fmts);
if (ret < 0)
goto fail;
s->avctx->pix_fmt = ret;
ff_hevc_pred_init(&s->hpc, sps->bit_depth);
ff_hevc_dsp_init (&s->hevcdsp, sps->bit_depth);
ff_videodsp_init (&s->vdsp, sps->bit_depth);
if (sps->sao_enabled && !s->avctx->hwaccel) {
av_frame_unref(s->tmp_frame);
ret = ff_get_buffer(s->avctx, s->tmp_frame, AV_GET_BUFFER_FLAG_REF);
if (ret < 0)
goto fail;
s->frame = s->tmp_frame;
}
s->ps.sps = sps;
s->ps.vps = (HEVCVPS*) s->ps.vps_list[s->ps.sps->vps_id]->data;
return 0;
fail:
pic_arrays_free(s);
s->ps.sps = NULL;
return ret;
}
| 1threat
|
How to add existing django project onto git hub : <p>I have created Django python web app .How to add it to github am new to both of these and have searched web for somedays without any luck.</p>
| 0debug
|
static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) {
MpegEncContext * const s = &h->s;
int mba_xy, mbb_xy;
int ctx = 0;
if(FRAME_MBAFF){
int mb_xy = mb_x + (mb_y&~1)*s->mb_stride;
mba_xy = mb_xy - 1;
if( (mb_y&1)
&& h->slice_table[mba_xy] == h->slice_num
&& MB_FIELD == !!IS_INTERLACED( s->current_picture.mb_type[mba_xy] ) )
mba_xy += s->mb_stride;
if( MB_FIELD ){
mbb_xy = mb_xy - s->mb_stride;
if( !(mb_y&1)
&& h->slice_table[mbb_xy] == h->slice_num
&& IS_INTERLACED( s->current_picture.mb_type[mbb_xy] ) )
mbb_xy -= s->mb_stride;
}else
mbb_xy = mb_x + (mb_y-1)*s->mb_stride;
}else{
int mb_xy = mb_x + mb_y*s->mb_stride;
mba_xy = mb_xy - 1;
mbb_xy = mb_xy - s->mb_stride;
}
if( h->slice_table[mba_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mba_xy] ))
ctx++;
if( h->slice_table[mbb_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mbb_xy] ))
ctx++;
if( h->slice_type == B_TYPE )
ctx += 13;
return get_cabac( &h->cabac, &h->cabac_state[11+ctx] );
}
| 1threat
|
How To Declare Input-Output Parameters In SQL Server Stored Procedure/Function? : <p>In Oracle, </p>
<p>We can declare an input-output parameters (not just input <strong>or</strong> output) like the following:</p>
<pre><code>Create Or Replace Procedure USERTEST.SimpleInOutProcedure(
p_InputInt Int,
p_OutputInt out Int,
p_InputOutputInt in out Int
) AS
BEGIN
p_OutputInt := p_InputInt + 1;
p_InputOutputInt := p_InputOutputInt + p_InputOutputInt;
END;
</code></pre>
<p>However, as I try to declare such in SQL Server, the script would not compile:</p>
<pre><code>create procedure SimpleInOutProcedure
@p_InputInt int, @p_OutputInt int input output
As
Begin
Select * from TestTableCommonA;
End
</code></pre>
<p>The word "input" is not expected, thus not blue-colored in the SQL Server Management Studio:</p>
<p><a href="https://i.stack.imgur.com/Pa4X6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Pa4X6.png" alt="enter image description here"></a></p>
<p>What's wrong with my script, how to declare input-output parameters in SQL Server Stored Procedure/Function?</p>
<p>I want to do this because I need to create "equivalent" reader for SQL Server DB which previously was created for Oracle DB and has the reader for in/out parameters.</p>
| 0debug
|
Android how can i make uploading large images fast like OLX : i am developing an app which seems like OLX , alowing the user to ad ads and of course select images from gallery to upload to my server but uploading large image take long time.How can i treat this issue (i am using Volley library for uploading the images) but i think there is a better libraries
| 0debug
|
AddDbContext or AddDbContextPool : <p>For Asp.net Core apps, which one do we have to use? <code>AddDbContext</code> or <code>AddDbContextPool</code>? According to EF Core documentation, <code>AddDbContextPool</code> provides high performance but the default Asp.net Core project templates use <code>AddDbContext</code>. </p>
| 0debug
|
How can I delay an event in c# : I would like to delay the execution of an instruction without executing any other one meanwhile.
Here's the program.[enter image description here][1]
[1]: http://i.stack.imgur.com/iP1rm.png
Thank You
| 0debug
|
static bool blit_is_unsafe(struct CirrusVGAState *s)
{
assert(s->cirrus_blt_width > 0);
assert(s->cirrus_blt_height > 0);
if (blit_region_is_unsafe(s, s->cirrus_blt_dstpitch,
s->cirrus_blt_dstaddr & s->cirrus_addr_mask)) {
if (blit_region_is_unsafe(s, s->cirrus_blt_srcpitch,
s->cirrus_blt_srcaddr & s->cirrus_addr_mask)) {
return false;
| 1threat
|
python3.7.4 pip install mysqlclient on windows i cant install : <p>pip install mysqlclient
Collecting mysqlclient
Using cached <a href="https://files.pythonhosted.org/packages/4d/38/c5f8bac9c50f3042c8f05615f84206f77f03db79781db841898fde1bb284/mysqlclient-1.4.4.tar.gz" rel="nofollow noreferrer">https://files.pythonhosted.org/packages/4d/38/c5f8bac9c50f3042c8f05615f84206f77f03db79781db841898fde1bb284/mysqlclient-1.4.4.tar.gz</a>
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\amirhossein\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] =
'"'"'C:\Users\AMIRHO~1\AppData\Local\Temp\pip-install-0khbcyo4\mysqlclient\setup.py'"'"'; <strong>file</strong>='"'"'C:\Users\AMIRHO~1\AppData\Local\Temp\pip-install-0khbcyo4\mysqlclient\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(<strong>file</strong>);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, <strong>file</strong>, '"'"'exec'"'"'))' install --record 'C:\Users\AMIRHO~1\AppData\Local\Temp\pip-record-0w16kjrt\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\AMIRHO~1\AppData\Local\Temp\pip-install-0khbcyo4\mysqlclient\
Complete output (24 lines):
running install
running build
running build_py
creating build
creating build\lib.win32-3.7
creating build\lib.win32-3.7\MySQLdb
copying MySQLdb__init__.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb_exceptions.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\compat.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-3.7\MySQLdb
creating build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants__init__.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLdb\constants
running build_ext
building 'MySQLdb._mysql' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": <a href="https://visualstudio.microsoft.com/downloads/" rel="nofollow noreferrer">https://visualstudio.microsoft.com/downloads/</a><br>
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\amirhossein\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\AMIRHO~1\AppData\Local\Temp\pip-install-0khbcyo4\mysqlclient\setup.py'"'"'; <strong>file</strong>='"'"'C:\Users\AMIRHO~1\AppData\Local\Temp\pip-install-0khbcyo4\mysqlclient\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(<strong>file</strong>);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, <strong>file</strong>, '"'"'exec'"'"'))' install --record 'C:\Users\AMIRHO~1\AppData\Local\Temp\pip-record-0w16kjrt\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.</p>
| 0debug
|
void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment)
{
size_t align = QEMU_VMALLOC_ALIGN;
size_t total = size + align - getpagesize();
void *ptr = mmap(0, total, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
size_t offset = QEMU_ALIGN_UP((uintptr_t)ptr, align) - (uintptr_t)ptr;
void *ptr1;
if (ptr == MAP_FAILED) {
return NULL;
}
if (alignment) {
*alignment = align;
}
ptr1 = mmap(ptr + offset, size, PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
if (ptr1 == MAP_FAILED) {
munmap(ptr, total);
return NULL;
}
ptr += offset;
total -= offset;
if (offset > 0) {
munmap(ptr - offset, offset);
}
if (total > size) {
munmap(ptr + size, total - size);
}
trace_qemu_anon_ram_alloc(size, ptr);
return ptr;
}
| 1threat
|
static void test_qemu_strtoull_whitespace(void)
{
const char *str = " \t ";
char f = 'X';
const char *endptr = &f;
uint64_t res = 999;
int err;
err = qemu_strtoull(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, 0);
g_assert(endptr == str);
}
| 1threat
|
C++ ifstream error: can't read data : <p>I am trying to read a dataset file(space delimited numbers such as 0.5678) with fstream, but it can't read the dataset and return the same strange value for all data entries</p>
<pre><code>ifstream input_file('Data_file');
for (int j = 1; j <= dimension; j++){
for (int i = 1; i <= no_of_data_points; i++){
double x;
input_file >> x;
cout << x << endl;
}
}
</code></pre>
<p>The above code returns ,</p>
<pre><code>-9.25596e+61
-9.25596e+61
-9.25596e+61
-9.25596e+61
-9.25596e+61
-9.25596e+61
-9.25596e+61
-9.25596e+61
-9.25596e+61
-9.25596e+61
-9.25596e+61
-9.25596e+61
-9.25596e+61
-9.25596e+61
.........
</code></pre>
<p>I have no idea how to debug it. Can anyone help me?
Thank you!</p>
| 0debug
|
Bootstrep forms to HeidiSQL : Can you give me some tips whit this. I made a form with bootstrep and i don't know how to make this: when i complete all steps (firstname, secondname, email, password, gender, status(student/profesor)) and press submit to save this information into my database (i use HeidiSQL).
<div class="container">
<h2> Completati formularul</h2>
<form role="form">
<div class="col-md-4">
<div class="form-group">
<label for="prenume">Prenume</label>
<input type="prenume" class="form-control" id="prenume" placeholder="Enter prenume"></input>
</div>
<div class="form-group">
<label for="name">Name</label>
<input type="name" class="form-control" id="name" placeholder="Enter name"></input>
</div>
<div class="form-group">
<label for="cnp">CNP</label>
<input type="cnp" class="form-control" id="cnp" placeholder="Enter the cnp"></input>
</div>
<div class="form-group">
<label for="email">E-mail</label>
<input type="email" class="form-control" id="email" placeholder="Enter E-mail"></input>
</div>
<div class="form-group">
<label for="password">Parola</label>
<input type="password" class="form-control" id="password" placeholder="Enter password"></input>
</div>
<p>Sex</p>
<div class="radio">
<label><input type="radio" name="m">Masculin</label>
</div>
<div class="radio">
<label><input type="radio" name="f">Feminin</label>
</div>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">Statut
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li> </li>
<li><a href="#">Student</a></li>
<li><a href="#">Profesor</a></li>
<li><a href="#">Suport tehnic</a></li>
</ul>
</div>
<br/>
<p>Necesar</p>
<div class="checkbox">
<label><input type="checkbox" value="">Videoproiector</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">Flipchart</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">Marker</label>
</div>
<p>Observatii</p>
<div class="form-group">
<textarea class="form-control" placeholder="Message"></textarea>
</div>
<div>
<button type="submit" class="btn btn-default">Submit</button>
</div>
| 0debug
|
Shell Script ...!! TRAP COMMAND explaination : Can anyone explain how "TRAP" command works in a script with a simple example
Thanks in advance
| 0debug
|
Singleton with parameter in Kotlin : <p>I am trying to convert an Android app from Java to Kotlin. There are a few singletons in the app. I used a companion object for the singletons without constructor parameters. There is another singleton that takes a constructor parameter.</p>
<p>Java code:</p>
<pre><code>public class TasksLocalDataSource implements TasksDataSource {
private static TasksLocalDataSource INSTANCE;
private TasksDbHelper mDbHelper;
// Prevent direct instantiation.
private TasksLocalDataSource(@NonNull Context context) {
checkNotNull(context);
mDbHelper = new TasksDbHelper(context);
}
public static TasksLocalDataSource getInstance(@NonNull Context context) {
if (INSTANCE == null) {
INSTANCE = new TasksLocalDataSource(context);
}
return INSTANCE;
}
}
</code></pre>
<p>My solution in kotlin:</p>
<pre><code>class TasksLocalDataSource private constructor(context: Context) : TasksDataSource {
private val mDbHelper: TasksDbHelper
init {
checkNotNull(context)
mDbHelper = TasksDbHelper(context)
}
companion object {
lateinit var INSTANCE: TasksLocalDataSource
private val initialized = AtomicBoolean()
fun getInstance(context: Context) : TasksLocalDataSource {
if(initialized.getAndSet(true)) {
INSTANCE = TasksLocalDataSource(context)
}
return INSTANCE
}
}
}
</code></pre>
<p>Am I missing anything? Thread safety? Laziness ? </p>
<p>There were a few similar questions but I don't like the answers :)</p>
| 0debug
|
static void test_ivshmem_server(void)
{
IVState state1, state2, *s1, *s2;
ServerThread thread;
IvshmemServer server;
int ret, vm1, vm2;
int nvectors = 2;
guint64 end_time = g_get_monotonic_time() + 5 * G_TIME_SPAN_SECOND;
memset(tmpshmem, 0x42, TMPSHMSIZE);
ret = ivshmem_server_init(&server, tmpserver, tmpshm,
TMPSHMSIZE, nvectors,
g_test_verbose());
g_assert_cmpint(ret, ==, 0);
ret = ivshmem_server_start(&server);
g_assert_cmpint(ret, ==, 0);
setup_vm_with_server(&state1, nvectors);
s1 = &state1;
setup_vm_with_server(&state2, nvectors);
s2 = &state2;
g_assert_cmpuint(in_reg(s1, IVPOSITION), ==, 0xffffffff);
g_assert_cmpuint(in_reg(s2, IVPOSITION), ==, 0xffffffff);
g_assert_cmpuint(qtest_readb(s1->qtest, (uintptr_t)s1->mem_base), ==, 0x00);
thread.server = &server;
ret = pipe(thread.pipe);
g_assert_cmpint(ret, ==, 0);
thread.thread = g_thread_new("ivshmem-server", server_thread, &thread);
g_assert(thread.thread != NULL);
while (g_get_monotonic_time() < end_time) {
g_usleep(1000);
if (qtest_readb(s1->qtest, (uintptr_t)s1->mem_base) == 0x42 &&
qtest_readb(s2->qtest, (uintptr_t)s2->mem_base) == 0x42) {
break;
}
}
vm1 = in_reg(s1, IVPOSITION);
vm2 = in_reg(s2, IVPOSITION);
g_assert_cmpuint(vm1, !=, vm2);
global_qtest = s1->qtest;
ret = qpci_msix_table_size(s1->dev);
g_assert_cmpuint(ret, ==, nvectors);
ret = qpci_msix_pending(s1->dev, 0);
g_assert_cmpuint(ret, ==, 0);
out_reg(s2, DOORBELL, vm1 << 16);
do {
g_usleep(10000);
ret = qpci_msix_pending(s1->dev, 0);
} while (ret == 0 && g_get_monotonic_time() < end_time);
g_assert_cmpuint(ret, !=, 0);
global_qtest = s2->qtest;
ret = qpci_msix_pending(s2->dev, 0);
g_assert_cmpuint(ret, ==, 0);
out_reg(s1, DOORBELL, vm2 << 16);
do {
g_usleep(10000);
ret = qpci_msix_pending(s2->dev, 0);
} while (ret == 0 && g_get_monotonic_time() < end_time);
g_assert_cmpuint(ret, !=, 0);
qtest_quit(s2->qtest);
qtest_quit(s1->qtest);
if (qemu_write_full(thread.pipe[1], "q", 1) != 1) {
g_error("qemu_write_full: %s", g_strerror(errno));
}
g_thread_join(thread.thread);
ivshmem_server_close(&server);
close(thread.pipe[1]);
close(thread.pipe[0]);
}
| 1threat
|
How can i receive sms from india to Us twilio number : <p>I am Sending sms to twilio usa number from india but it is not delivered.Can you please tell me why my messages are not delivered.</p>
| 0debug
|
Iterating over array of chars in C : <p>If I iterate over an array of chars using a pointer and declared this way:</p>
<pre><code>char my_ary[3] = { 'A', 'B', 'C' };
char *my_p = my_ary;
while(*my_p){
printf("value of pointer is %c\n", *my_p);
my_p++;
}
</code></pre>
<p>I get the values along with some garbage:</p>
<pre><code>value of pointer is A
value of pointer is B
value of pointer is C
value of pointer is �
value of pointer is �
value of pointer is u
value of pointer is �
value of pointer is �
value of pointer is
</code></pre>
<p>If on the other hand I declare the array as static, I don't get the garbage:</p>
<pre><code>static char my_ary[3] = { 'A', 'B', 'C' };
char *my_p = my_ary;
while(*my_p){
printf("value of pointer is %c\n", *my_p);
my_p++;
}
value of pointer is A
value of pointer is B
value of pointer is C
</code></pre>
<p>Why is the static keyword affecting this particular case?</p>
| 0debug
|
static int gdv_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
GDVContext *gdv = avctx->priv_data;
GetByteContext *gb = &gdv->gb;
PutByteContext *pb = &gdv->pb;
AVFrame *frame = data;
int ret, i, pal_size;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size);
int compression;
unsigned flags;
uint8_t *dst;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
if (pal && pal_size == AVPALETTE_SIZE)
memcpy(gdv->pal, pal, AVPALETTE_SIZE);
bytestream2_init(gb, avpkt->data, avpkt->size);
bytestream2_init_writer(pb, gdv->frame, gdv->frame_size);
flags = bytestream2_get_le32(gb);
compression = flags & 0xF;
rescale(gdv, gdv->frame, avctx->width, avctx->height,
!!(flags & 0x10), !!(flags & 0x20));
switch (compression) {
case 1:
memset(gdv->frame + PREAMBLE_SIZE, 0, gdv->frame_size - PREAMBLE_SIZE);
case 0:
if (bytestream2_get_bytes_left(gb) < 256*3)
return AVERROR_INVALIDDATA;
for (i = 0; i < 256; i++) {
unsigned r = bytestream2_get_byte(gb);
unsigned g = bytestream2_get_byte(gb);
unsigned b = bytestream2_get_byte(gb);
gdv->pal[i] = 0xFFU << 24 | r << 18 | g << 10 | b << 2;
}
break;
case 2:
ret = decompress_2(avctx);
break;
case 3:
break;
case 5:
ret = decompress_5(avctx, flags >> 8);
break;
case 6:
ret = decompress_68(avctx, flags >> 8, 0);
break;
case 8:
ret = decompress_68(avctx, flags >> 8, 1);
break;
default:
return AVERROR_INVALIDDATA;
}
memcpy(frame->data[1], gdv->pal, AVPALETTE_SIZE);
dst = frame->data[0];
if (!gdv->scale_v && !gdv->scale_h) {
int sidx = PREAMBLE_SIZE, didx = 0;
int y, x;
for (y = 0; y < avctx->height; y++) {
for (x = 0; x < avctx->width; x++) {
dst[x+didx] = gdv->frame[x+sidx];
}
sidx += avctx->width;
didx += frame->linesize[0];
}
} else {
int sidx = PREAMBLE_SIZE, didx = 0;
int y, x;
for (y = 0; y < avctx->height; y++) {
if (!gdv->scale_v) {
for (x = 0; x < avctx->width; x++) {
dst[didx + x] = gdv->frame[sidx + x];
}
} else {
for (x = 0; x < avctx->width; x++) {
dst[didx + x] = gdv->frame[sidx + x/2];
}
}
if (!gdv->scale_h || ((y & 1) == 1)) {
sidx += !gdv->scale_v ? avctx->width : avctx->width/2;
}
didx += frame->linesize[0];
}
}
*got_frame = 1;
return ret < 0 ? ret : avpkt->size;
}
| 1threat
|
static AddressParts gen_lea_modrm_0(CPUX86State *env, DisasContext *s,
int modrm)
{
int def_seg, base, index, scale, mod, rm;
target_long disp;
bool havesib;
def_seg = R_DS;
index = -1;
scale = 0;
disp = 0;
mod = (modrm >> 6) & 3;
rm = modrm & 7;
base = rm | REX_B(s);
if (mod == 3) {
goto done;
}
switch (s->aflag) {
case MO_64:
case MO_32:
havesib = 0;
if (rm == 4) {
int code = cpu_ldub_code(env, s->pc++);
scale = (code >> 6) & 3;
index = ((code >> 3) & 7) | REX_X(s);
if (index == 4) {
index = -1;
}
base = (code & 7) | REX_B(s);
havesib = 1;
}
switch (mod) {
case 0:
if ((base & 7) == 5) {
base = -1;
disp = (int32_t)cpu_ldl_code(env, s->pc);
s->pc += 4;
if (CODE64(s) && !havesib) {
base = -2;
disp += s->pc + s->rip_offset;
}
}
break;
case 1:
disp = (int8_t)cpu_ldub_code(env, s->pc++);
break;
default:
case 2:
disp = (int32_t)cpu_ldl_code(env, s->pc);
s->pc += 4;
break;
}
if (base == R_ESP && s->popl_esp_hack) {
disp += s->popl_esp_hack;
}
if (base == R_EBP || base == R_ESP) {
def_seg = R_SS;
}
break;
case MO_16:
if (mod == 0) {
if (rm == 6) {
base = -1;
disp = cpu_lduw_code(env, s->pc);
s->pc += 2;
break;
}
} else if (mod == 1) {
disp = (int8_t)cpu_ldub_code(env, s->pc++);
} else {
disp = (int16_t)cpu_lduw_code(env, s->pc);
s->pc += 2;
}
switch (rm) {
case 0:
base = R_EBX;
index = R_ESI;
break;
case 1:
base = R_EBX;
index = R_EDI;
break;
case 2:
base = R_EBP;
index = R_ESI;
def_seg = R_SS;
break;
case 3:
base = R_EBP;
index = R_EDI;
def_seg = R_SS;
break;
case 4:
base = R_ESI;
break;
case 5:
base = R_EDI;
break;
case 6:
base = R_EBP;
def_seg = R_SS;
break;
default:
case 7:
base = R_EBX;
break;
}
break;
default:
tcg_abort();
}
done:
return (AddressParts){ def_seg, base, index, scale, disp };
}
| 1threat
|
Html : how to get value of input from form? : <p>I have got the following code:</p>
<pre><code><form method='POST' onsubmit='javascript:searchAndUpdateGrid(GET_THE_VALUE_OF_INPUT);return false;'
<input type="text" id="inputField" class="form-control" placeholder="Type something...">
</form>
</code></pre>
<p>I want to launch the function searchAndUpdateGrid with the value entered by the user in the input field. How can I do that ? (I would like to avoid to get it from Javascript)</p>
<p>Thanks !</p>
| 0debug
|
Unexpected Results When Using Pointers to Access Array Elements : <p>I have two classes. <code>class1</code> and <code>class2</code>. <code>class2</code> creates an array with elements that are of type <code>class1</code>. <code>class2</code> has a member that points to that array. I can access the pointer with <code>class 2's</code> <code>getpointer</code> method, but I get unexpected results when I try to use the pointer to access members of the array's elements.</p>
<p>Here's the code:</p>
<pre><code>#include <iostream>
using namespace std;
class class1{
int a;
int b;
public:
class1(){}
class1(int x, int y){a = x; b = y;}
int geta(){return a;}
int getb(){return b;}
};
class class2{
int c;
int d;
class1 *e;
public:
class2(int x, int y){c = x; d = y;}
void setE(){
class1 arr[3];
class1 arrTemp (0,0);
arr[0] = arrTemp;
class1 arrTemp1 (1,1);
arr[1] = arrTemp1;
class1 arrTemp2 (2,2);
arr[2] = arrTemp2;
cout << "Element 1, A = ";
cout << arr[0].geta() << endl;
cout << "Element 1, B = ";
cout << arr[0].getb() << endl;
cout << "Element 2, A = ";
cout << arr[1].geta() << endl;
cout << "Element 2, B = ";
cout << arr[1].getb() << endl;
cout << "Element 3, A = ";
cout << arr[2].geta() << endl;
cout << "Element 3, B = ";
cout << arr[2].getb() << endl;
class1 *pt;
pt = &arr[0];
e = pt;
}
class1* getpointer(){return e;}
};
int main(){
class2 testObj (1,2);
testObj.setE();
class1 *objPointer = testObj.getpointer();
class1 tempclass1;
tempclass1 = *(objPointer + 0);
cout << "Element 1, A = ";
cout << tempclass1.geta() << endl;
cout << "Element 1, B = ";
cout << tempclass1.getb() << endl;
tempclass1 = *(objPointer + 1);
cout << "Element 2, A = ";
cout << tempclass1.geta() << endl;
cout << "Element 2, B = ";
cout << tempclass1.getb() << endl;
tempclass1 = *(objPointer + 1);
cout << "Element 3, A = ";
cout << tempclass1.geta() << endl;
cout << "Element 3, B = ";
cout << tempclass1.getb() << endl;
};
</code></pre>
<p>This is the output:</p>
<pre><code>Element 1, A = 0
Element 1, B = 0
Element 2, A = 1
Element 2, B = 1
Element 3, A = 2
Element 3, B = 2
Element 1, A = 0
Element 1, B = 0
Element 2, A = -360531408
Element 2, B = 29391
Element 3, A = -360531408
Element 3, B = 29391
</code></pre>
<p>With the first set of <code>cout</code> statements I verify that the data is going into the array correctly. </p>
<p>It looks like I get the correct data for the first element, but after that what I get with the pointer is completely different from the actual array. I'm very new to C++, but I thought that <code>*(Pointer + i)</code> was equal to <code>arr[i]</code>.</p>
| 0debug
|
Python - Printing Integer variable inside double quote : <p>I have an integer variable in Python::</p>
<blockquote>
<p>var = 10</p>
</blockquote>
<p>I want to print it like this :</p>
<blockquote>
<p>"10"</p>
</blockquote>
<p>Tried many things like </p>
<blockquote>
<p>' "var" '</p>
</blockquote>
<p>but did not really work.</p>
<p>Any help would really be appreciated.
Thanks in advance.</p>
| 0debug
|
Is there a function for generating settings.SECRET_KEY in django? : <p>I wrote an <a href="https://github.com/nemesisdesign/ansible-openwisp2/" rel="noreferrer">ansible-role for openwisp2</a> to ease its deployment, it's a series of django apps. To ease the deployment as much as possible, I wrote a simple (probably trivial) <a href="https://github.com/nemesisdesign/ansible-openwisp2/blob/master/files/generate_django_secret_key.py" rel="noreferrer">SECRET_KEY generator script</a> which is called by ansible to generate the secret key the first time the ansible playbook is run.</p>
<p>Now, that works fine BUT I think it defeats the built-in security measures Django has in generating a strong key which is also very hard to guess.</p>
<p>At the time I looked at other ways of doing it but didn't find much, now I wonder: <strong>is there a function for generating settings.SECRET_KEY in django?</strong></p>
<p>That would avoid this kind of home baked solutions that even though they work they are not effective when it comes to security.</p>
| 0debug
|
Scala goupBy and merge Java : I have the following spark dataframe that I am manipulating on a databricks notebook
let's call the dataframe df.
src tgt
1 2
1 3
1 4
2 1
2 3
2 5
3 4
4 2
4 5
4 6
5 2
I need to take the data and count the number of outgoing edges from src to
target and from target to src. As follows.
node out_deg in-deg total_deg
1 3 1 4
2 3 3 6
3 1 2 3
4 3 2 5
5 1 2 3
6 0 1 1
For example: node 4 has 3 edges going out (to 2, 5, and 6) and 2 edges coming in (from 1 and 3).
It's total edges = in + out = 3 + 2 = 5.
How do I do this?
| 0debug
|
static int check_empty_sectors(BlockBackend *blk, int64_t sect_num,
int sect_count, const char *filename,
uint8_t *buffer, bool quiet)
{
int pnum, ret = 0;
ret = blk_pread(blk, sect_num << BDRV_SECTOR_BITS, buffer,
sect_count << BDRV_SECTOR_BITS);
if (ret < 0) {
error_report("Error while reading offset %" PRId64 " of %s: %s",
sectors_to_bytes(sect_num), filename, strerror(-ret));
return ret;
}
ret = is_allocated_sectors(buffer, sect_count, &pnum);
if (ret || pnum != sect_count) {
qprintf(quiet, "Content mismatch at offset %" PRId64 "!\n",
sectors_to_bytes(ret ? sect_num : sect_num + pnum));
return 1;
}
return 0;
}
| 1threat
|
Activity Not starting ; another activity is starting instead : I am facing a very weird issue. I am trying to launch one activity but instead of that, another activity is opening. I am trying to open RegActivity, I do have specified it in mainfiest and also made it Launcher activity but instead of that when I run the app "MainActivity" is calling. MainActivity is not even a Launcher or Default activity. I cleaned up the project, Rebuilt it. But still, Nothing works. I am stuck. I have wasted my entire day and nothing helped me. Please help Guys!!!
MainFiest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abc.ecommerce" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="Frizzy"
android:theme="@style/AppTheme2" >
<activity
android:name="com.solodroid.ecommerce.RegActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.solodroid.ecommerce.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.solodroid.ecommerce.ActivityCategoryList"
android:screenOrientation="portrait" />
<activity
android:name="com.solodroid.ecommerce.ActivityMenuList"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name="com.solodroid.ecommerce.ActivityMenuDetail"
android:screenOrientation="portrait" />
<activity
android:name="com.solodroid.ecommerce.ActivityCart"
android:screenOrientation="portrait" />
<activity
android:name="com.solodroid.ecommerce.ActivityCheckout"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name="com.solodroid.ecommerce.ActivityConfirmMessage"
android:screenOrientation="portrait" />
<activity
android:name="com.solodroid.ecommerce.ActivityContactUs"
android:screenOrientation="portrait" />
<activity
android:name="com.solodroid.ecommerce.ActivityProfile"
android:screenOrientation="portrait" />
<activity
android:name="com.solodroid.ecommerce.ActivityInformation"
android:screenOrientation="portrait" />
<activity
android:name="com.solodroid.ecommerce.ActivityAbout"
android:screenOrientation="portrait" />
<activity
android:name="com.solodroid.ecommerce.LoginActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"/>
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"
/>
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
</application>
</manifest>
RegActivity.java
package com.abc.ecommerce;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import org.json.JSONException;
import java.io.IOException;
import java.util.HashMap;
public class RegActivity extends AppCompatActivity {
private EditText etid, etname, etstorename, etemail, etphone, etdoj;
Button btnregister;
TextView tvlogin;
private ParseContent parseContent;
PreferenceHelper preferenceHelper;
private final int RegTask = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_reg);
preferenceHelper = new PreferenceHelper(this);
parseContent = new ParseContent(this);
if(preferenceHelper.getIsLogin()){
Intent intent = new Intent(RegActivity.this,MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
this.finish();
}
//etid = (EditText) findViewById(R.id.etmi_id);
etname = (EditText) findViewById(R.id.etname);
//etstorename = (EditText) findViewById(R.id.etstore_name);
etemail = (EditText) findViewById(R.id.etemail);
etphone = (EditText) findViewById(R.id.etphone);
// etdoj = (EditText) findViewById(R.id.etdoj);
btnregister = (Button) findViewById(R.id.btn);
tvlogin = (TextView) findViewById(R.id.tvlogin);
tvlogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(RegActivity.this,LoginActivity.class);
startActivity(intent);
}
});
btnregister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
register();
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}
private void register() throws IOException, JSONException {
if (!AndyUtils.isNetworkAvailable(RegActivity.this)) {
Toast.makeText(RegActivity.this, "Internet is required!", Toast.LENGTH_SHORT).show();
return;
}
AndyUtils.showSimpleProgressDialog(RegActivity.this);
final HashMap<String, String> map = new HashMap<>();
// map.put(AndyConstants.Params.MI_ID, etid.getText().toString());
map.put(AndyConstants.Params.NAME, etname.getText().toString());
// map.put(AndyConstants.Params.STORE_NAME, etstorename.getText().toString());
map.put(AndyConstants.Params.EMAIL, etemail.getText().toString());
map.put(AndyConstants.Params.PHONE, etphone.getText().toString());
//map.put(AndyConstants.Params.DOJ, etdoj.getText().toString());
new AsyncTask<Void, Void, String>(){
protected String doInBackground(Void[] params) {
String response="";
try {
HttpRequest req = new HttpRequest(AndyConstants.ServiceType.REGISTER);
response = req.prepare(HttpRequest.Method.POST).withData(map).sendAndReadString();
} catch (Exception e) {
response=e.getMessage();
}
return response;
}
protected void onPostExecute(String result) {
//do something with response
Log.d("newwwss", result);
onTaskCompleted(result, RegTask);
}
}.execute();
}
private void onTaskCompleted(String response,int task) {
Log.d("responsejson", response.toString());
AndyUtils.removeSimpleProgressDialog(); //will remove progress dialog
switch (task) {
case RegTask:
if (parseContent.isSuccess(response)) {
parseContent.saveInfo(response);
Toast.makeText(RegActivity.this, "Registered Successfully!", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(RegActivity.this,MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
this.finish();
}else {
Toast.makeText(RegActivity.this, parseContent.getErrorMessage(response), Toast.LENGTH_SHORT).show();
}
}
}
}
Please tell me what is wrong here? i don't find anything.
| 0debug
|
Attempted to compile "zone.js" as an external module, but it looks like a global module : <p>I have the "AngularClass" angular2-webpack-starter project
I have install all npm dependencies
Now I'm trying to install typings</p>
<p>typings.json</p>
<pre><code>{
"dependencies": {
"zone.js": "github:gdi2290/typed-zone.js#66ea8a3451542bb7798369306840e46be1d6ec89"
},
"devDependencies": {},
"ambientDependencies": {
"angular-protractor": "github:DefinitelyTyped/DefinitelyTyped/angular-protractor/angular-protractor.d.ts#64b25f63f0ec821040a5d3e049a976865062ed9d",
"core-js": "registry:dt/core-js#0.0.0+20160317120654",
"hammerjs": "github:DefinitelyTyped/DefinitelyTyped/hammerjs/hammerjs.d.ts#74a4dfc1bc2dfadec47b8aae953b28546cb9c6b7",
"jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#4b36b94d5910aa8a4d20bdcd5bd1f9ae6ad18d3c",
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#8cf8164641be73e8f1e652c2a5b967c7210b6729",
"selenium-webdriver": "github:DefinitelyTyped/DefinitelyTyped/selenium-webdriver/selenium-webdriver.d.ts#a83677ed13add14c2ab06c7325d182d0ba2784ea",
"webpack": "github:DefinitelyTyped/DefinitelyTyped/webpack/webpack.d.ts#95c02169ba8fa58ac1092422efbd2e3174a206f4"
}
}
</code></pre>
<p>when I typed </p>
<pre><code>sudo typings install
</code></pre>
<p>I got</p>
<pre><code>derzunov:angular2-webpack-starter derzunov$ sudo typings install
typings ERR! message Attempted to compile "zone.js" as an external module, but it looks like a global module.
typings ERR! cwd /Users/derzunov/projects/Angular2/angular2-webpack-starter
typings ERR! system Darwin 15.4.0
typings ERR! command "/usr/local/bin/node" "/usr/local/bin/typings" "install"
typings ERR! node -v v4.4.4
typings ERR! typings -v 1.0.2
typings ERR! If you need help, you may report this error at:
typings ERR! <https://github.com/typings/typings/issues>
</code></pre>
<p>What does it mean?
Help! =))</p>
| 0debug
|
Different pages under different tabs in WPF : <p>I have a tabcontrol in my mainwindow and I have tabs like users, transactions, etc. I created a page individually to show under each tab. But I'm not sure how to plugin each page under each tab. Can somebody help me?</p>
| 0debug
|
Recommend manual SugarCRM for developer, please : Everyone.
I'm intern developer in the bank. Now I develop custom things in the SugarCRM. But I can't find good manual about customisation in the SugarCRM ver.6.5+.
Pleeeease, help me!!!
| 0debug
|
static inline void gen_efdnabs(DisasContext *ctx)
{
if (unlikely(!ctx->spe_enabled)) {
gen_exception(ctx, POWERPC_EXCP_APU);
return;
}
#if defined(TARGET_PPC64)
tcg_gen_ori_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], 0x8000000000000000LL);
#else
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
tcg_gen_ori_tl(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)], 0x80000000);
#endif
}
| 1threat
|
static void check_watchpoint(int offset, int len, int flags)
{
CPUState *cpu = current_cpu;
CPUArchState *env = cpu->env_ptr;
target_ulong pc, cs_base;
target_ulong vaddr;
CPUWatchpoint *wp;
int cpu_flags;
if (cpu->watchpoint_hit) {
cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG);
return;
}
vaddr = (cpu->mem_io_vaddr & TARGET_PAGE_MASK) + offset;
QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) {
if (cpu_watchpoint_address_matches(wp, vaddr, len)
&& (wp->flags & flags)) {
wp->flags |= BP_WATCHPOINT_HIT;
if (!cpu->watchpoint_hit) {
cpu->watchpoint_hit = wp;
tb_check_watchpoint(cpu);
if (wp->flags & BP_STOP_BEFORE_ACCESS) {
cpu->exception_index = EXCP_DEBUG;
cpu_loop_exit(cpu);
} else {
cpu_get_tb_cpu_state(env, &pc, &cs_base, &cpu_flags);
tb_gen_code(cpu, pc, cs_base, cpu_flags, 1);
cpu_resume_from_signal(cpu, NULL);
}
}
} else {
wp->flags &= ~BP_WATCHPOINT_HIT;
}
}
}
| 1threat
|
static int htab_save_complete(QEMUFile *f, void *opaque)
{
sPAPRMachineState *spapr = opaque;
int fd;
qemu_put_be32(f, 0);
if (!spapr->htab) {
int rc;
assert(kvm_enabled());
fd = get_htab_fd(spapr);
if (fd < 0) {
return fd;
}
rc = kvmppc_save_htab(f, fd, MAX_KVM_BUF_SIZE, -1);
if (rc < 0) {
return rc;
}
close_htab_fd(spapr);
} else {
if (spapr->htab_first_pass) {
htab_save_first_pass(f, spapr, -1);
}
htab_save_later_pass(f, spapr, -1);
}
qemu_put_be32(f, 0);
qemu_put_be16(f, 0);
qemu_put_be16(f, 0);
return 0;
}
| 1threat
|
R: What do reshigh and reslow mean? : I'm wondering what reshigh and reslow mean in the portfolio.optim function in the package tseries.
| 0debug
|
how Android soong/android.bp build works? : <p>Google introduced Soong build system the replacement of old makefile system.
Have any idea about how it works?
please tell me about Android.bp </p>
| 0debug
|
android.app.RemoteServiceException: at android.app.ActivityThread$H.handleMessage when sending notifications : <p>I use a service to display notifications. On some rare devices (3 users among 50 000 every day), I have the the following crash (which can be seen in the Google Play developer console ; only on Android 4.x devices) :</p>
<pre><code>android.app.RemoteServiceException:
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1509)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5327)
at java.lang.reflect.Method.invokeNative(Native Method:0)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method:0)
</code></pre>
<p>My notifications are made with a code like this (old style notifs, deprecated in Android 6+ but works anyway ; the bug is on Android 4.x where the code is not deprecated):</p>
<pre><code>Notification notification = new Notification(icon, "Custom Notification", when);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification);
contentView.setImageViewResource(R.id.notifWeatherImageView, WeatherRowTools.getImageForWeatherCode(weatherCodeString));
....some stuff here...
notification.contentView = contentView;
notification.contentIntent = contentIntent;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults = 0;
mNotificationManager.notify(1, notification);
</code></pre>
<p>Any idea on how to solve this issue?</p>
<p>Thanks a lot !!!</p>
| 0debug
|
Pointers give seg fault : <p>here's the program</p>
<pre><code> #include <iostream>
#include <time.h>
#include <conio.h>
#include <cstdlib>
#include <windows.h>
using namespace std;
const int widht = 117,height = 26;
class Paddle
{
private:
int y;
int originalY;
public:
Paddle()
{
y=height/2-2;
originalY=y;
}
inline int getY()
{
return y;
}
inline void moveUp()
{
y--;
}
inline void moveDown()
{
y++;
}
void checkWall()
{
if (y<0)
{
while (y<0)
{
y++;
}
}
else if (y>height)
{
while (y>height)
{
y--;
}
}
}
void Reset()
{
y=originalY;
}
};
class Ball
{
private:
int x,y;
int originalX,originalY;
public:
Ball()
{
x=widht/2;
y=height/2;
originalX=x;
originalY=y;
}
inline int getX()
{
return x;
}
inline int getY()
{
return y;
}
inline void moveRight()
{
x++;
}
inline void moveUpRight()
{
x++;
y--;
}
inline void moveDownRight()
{
x++;
y++;
}
inline void moveLeft()
{
x--;
}
inline void moveUpLeft()
{
y--;
x--;
}
inline void moveDownLeft()
{
y++;
x--;
}
inline void Reset()
{
x=originalX;
y=originalY;
}
};
class Manager
{
private:
int score1,score2;
int columns, rows;
public:
int p1y;
int p2y;
int ballX,ballY;
bool gameOver;
Manager()
{
gameOver = false;
}
void Draw(Paddle *p1,Paddle *p2,Ball *b)
{
system("cls");
p1y=p1->getY();
p2y=p1->getY();
ballX=b->getX();
ballY=b->getY();
for (int i=0;i<height;i++)
{
for (int j=0;j<widht;j++)
{
if (i==p1y && j==2)
{
cout << "\xDB";
}
else if (i==p1y+1 && j==2)
{
cout << "\xDB";
}
else if (i==p1y+2 && j==2)
{
cout << "\xDB";
}
else if (i==p1y+3 && j==2)
{
cout << "\xDB";
}
else if (i==p1y+4 && j==2)
{
cout << "\xDB";
}
else if (i==p2y && j==widht-1)
{
cout << "\xDB";
}
else if (i==p2y+1 && j==widht-1)
{
cout << "\xDB";
}
else if (i==p2y+2 && j==widht-1)
{
cout << "\xDB";
}
else if (i==p2y+3 && j==widht-1)
{
cout << "\xDB";
}
else if (i==p2y+4 && j==widht-1)
{
cout << "\xDB";
}
else if (i==ballX && j==ballY)
{
cout << "O";
}
cout << " ";
}
cout << endl;
}
cout << p1 -> getY();
}
void Input(Paddle *p1,Paddle *p2)
{
if (_kbhit())
{
switch(_getch())
{
case 'w':
p1->moveUp();
break;
case 's':
p1->moveDown();
break;
case 'i':
p2->moveUp();
break;
case 'k':
p2->moveDown();
break;
}
}
}
void Run(Paddle *p1,Paddle *p2, Ball *b)
{
while(!gameOver)
{
Draw(p1,p2,b);
Input(p1,p2);
Sleep(10);
}
}
};
int main()
{
Paddle *p1;
Paddle *p2;
Ball *b;
Manager *m;
m->Run(p1,p2,b);
return 0;
}
</code></pre>
<p>I can't understand why when i launch the program it give (with the debugger) segmentation fault.
I think cause are pointers, because before it worked perfectly(but without modifiyng values);
Hae any tips?</p>
| 0debug
|
static int sdp_parse_rtpmap(AVFormatContext *s,
AVStream *st, RTSPStream *rtsp_st,
int payload_type, const char *p)
{
AVCodecContext *codec = st->codec;
char buf[256];
int i;
AVCodec *c;
const char *c_name;
get_word_sep(buf, sizeof(buf), "/ ", &p);
if (payload_type < RTP_PT_PRIVATE) {
codec->codec_id = ff_rtp_codec_id(buf, codec->codec_type);
}
if (codec->codec_id == AV_CODEC_ID_NONE) {
RTPDynamicProtocolHandler *handler =
ff_rtp_handler_find_by_name(buf, codec->codec_type);
init_rtp_handler(handler, rtsp_st, st);
if (!rtsp_st->dynamic_handler)
codec->codec_id = ff_rtp_codec_id(buf, codec->codec_type);
}
c = avcodec_find_decoder(codec->codec_id);
if (c && c->name)
c_name = c->name;
else
c_name = "(null)";
get_word_sep(buf, sizeof(buf), "/", &p);
i = atoi(buf);
switch (codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
av_log(s, AV_LOG_DEBUG, "audio codec set to: %s\n", c_name);
codec->sample_rate = RTSP_DEFAULT_AUDIO_SAMPLERATE;
codec->channels = RTSP_DEFAULT_NB_AUDIO_CHANNELS;
if (i > 0) {
codec->sample_rate = i;
avpriv_set_pts_info(st, 32, 1, codec->sample_rate);
get_word_sep(buf, sizeof(buf), "/", &p);
i = atoi(buf);
if (i > 0)
codec->channels = i;
}
av_log(s, AV_LOG_DEBUG, "audio samplerate set to: %i\n",
codec->sample_rate);
av_log(s, AV_LOG_DEBUG, "audio channels set to: %i\n",
codec->channels);
break;
case AVMEDIA_TYPE_VIDEO:
av_log(s, AV_LOG_DEBUG, "video codec set to: %s\n", c_name);
if (i > 0)
avpriv_set_pts_info(st, 32, 1, i);
break;
default:
break;
}
if (rtsp_st->dynamic_handler && rtsp_st->dynamic_handler->init)
rtsp_st->dynamic_handler->init(s, st->index,
rtsp_st->dynamic_protocol_context);
return 0;
}
| 1threat
|
static int usb_msd_handle_data(USBDevice *dev, USBPacket *p)
{
MSDState *s = (MSDState *)dev;
int ret = 0;
struct usb_msd_cbw cbw;
uint8_t devep = p->devep;
switch (p->pid) {
case USB_TOKEN_OUT:
if (devep != 2)
goto fail;
switch (s->mode) {
case USB_MSDM_CBW:
if (p->iov.size != 31) {
fprintf(stderr, "usb-msd: Bad CBW size");
goto fail;
}
usb_packet_copy(p, &cbw, 31);
if (le32_to_cpu(cbw.sig) != 0x43425355) {
fprintf(stderr, "usb-msd: Bad signature %08x\n",
le32_to_cpu(cbw.sig));
goto fail;
}
DPRINTF("Command on LUN %d\n", cbw.lun);
if (cbw.lun != 0) {
fprintf(stderr, "usb-msd: Bad LUN %d\n", cbw.lun);
goto fail;
}
s->tag = le32_to_cpu(cbw.tag);
s->data_len = le32_to_cpu(cbw.data_len);
if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
} else if (cbw.flags & 0x80) {
s->mode = USB_MSDM_DATAIN;
} else {
s->mode = USB_MSDM_DATAOUT;
}
DPRINTF("Command tag 0x%x flags %08x len %d data %d\n",
s->tag, cbw.flags, cbw.cmd_len, s->data_len);
s->residue = 0;
s->scsi_len = 0;
s->req = scsi_req_new(s->scsi_dev, s->tag, 0, NULL);
scsi_req_enqueue(s->req, cbw.cmd);
if (s->mode != USB_MSDM_CSW && s->residue == 0) {
scsi_req_continue(s->req);
}
ret = p->result;
break;
case USB_MSDM_DATAOUT:
DPRINTF("Data out %zd/%d\n", p->iov.size, s->data_len);
if (p->iov.size > s->data_len) {
goto fail;
}
if (s->scsi_len) {
usb_msd_copy_data(s, p);
}
if (s->residue) {
int len = p->iov.size - p->result;
if (len) {
usb_packet_skip(p, len);
s->data_len -= len;
if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
}
}
}
if (p->result < p->iov.size) {
DPRINTF("Deferring packet %p\n", p);
s->packet = p;
ret = USB_RET_ASYNC;
} else {
ret = p->result;
}
break;
default:
DPRINTF("Unexpected write (len %zd)\n", p->iov.size);
goto fail;
}
break;
case USB_TOKEN_IN:
if (devep != 1)
goto fail;
switch (s->mode) {
case USB_MSDM_DATAOUT:
if (s->data_len != 0 || p->iov.size < 13) {
goto fail;
}
s->packet = p;
ret = USB_RET_ASYNC;
break;
case USB_MSDM_CSW:
DPRINTF("Command status %d tag 0x%x, len %zd\n",
s->result, s->tag, p->iov.size);
if (p->iov.size < 13) {
goto fail;
}
usb_msd_send_status(s, p);
s->mode = USB_MSDM_CBW;
ret = 13;
break;
case USB_MSDM_DATAIN:
DPRINTF("Data in %zd/%d, scsi_len %d\n",
p->iov.size, s->data_len, s->scsi_len);
if (s->scsi_len) {
usb_msd_copy_data(s, p);
}
if (s->residue) {
int len = p->iov.size - p->result;
if (len) {
usb_packet_skip(p, len);
s->data_len -= len;
if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
}
}
}
if (p->result < p->iov.size) {
DPRINTF("Deferring packet %p\n", p);
s->packet = p;
ret = USB_RET_ASYNC;
} else {
ret = p->result;
}
break;
default:
DPRINTF("Unexpected read (len %zd)\n", p->iov.size);
goto fail;
}
break;
default:
DPRINTF("Bad token\n");
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| 1threat
|
static void bdrv_io_limits_intercept(BlockDriverState *bs,
unsigned int bytes,
bool is_write)
{
bool must_wait = throttle_schedule_timer(&bs->throttle_state, is_write);
if (must_wait ||
!qemu_co_queue_empty(&bs->throttled_reqs[is_write])) {
qemu_co_queue_wait(&bs->throttled_reqs[is_write]);
}
throttle_account(&bs->throttle_state, is_write, bytes);
if (throttle_schedule_timer(&bs->throttle_state, is_write)) {
return;
}
qemu_co_queue_next(&bs->throttled_reqs[is_write]);
}
| 1threat
|
the right way to limit text? PHP : <p>There is a way to count blank space with <code>substr</code>?</p>
<pre><code>$testo = $news['testo'];
$testo = strip_tags($testo);
echo "<p>".substr($testo,0,200)."</p>";
</code></pre>
<p>I did several tests and i see that <code>substr</code> does NOT count whitespace. How can I tell him to count them?</p>
<p>This is a problem because it gives me a different number of characters each time for article.</p>
| 0debug
|
Prime Number in clisp : Well I'm just completely new to CLISP programming language and I have started learning this language by my own from yesterday and that too out of interest.Now when i came across functions and loop,after learning about them I started developing the Prime Number problem in CLISP.
My code is as follows:
(defun prime (num)
(setq c 1)
(setq a 2)
(loop
(setq a (+ 1 a))
(if (= (mod num a) 0)
(setq c (+ c 1))
)
(when (> (+ a 1) 17) (return a))
)
)
(if (= c 1)
(return-from prime num)
)
)
(loop for x from 1 to 20
do (prime x)
)
Now the problem which I am facing with this code is that whenever I am trying to execute this code the error which I am getting is as follows:
***IF: variable C has no value
but I've declared a value to c already still it's appearing. So all i want to know is that why this error is appearing even though i have declared it.
| 0debug
|
static void do_unassigned_access(target_ulong addr, int is_write, int is_exec,
int is_asi, int size)
#else
void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,
int is_asi, int size)
#endif
{
CPUState *saved_env;
saved_env = env;
env = cpu_single_env;
#ifdef DEBUG_UNASSIGNED
printf("Unassigned mem access to " TARGET_FMT_plx " from " TARGET_FMT_lx
"\n", addr, env->pc);
#endif
if (is_exec)
raise_exception(TT_CODE_ACCESS);
else
raise_exception(TT_DATA_ACCESS);
env = saved_env;
}
| 1threat
|
How to create Multiple Pills/Tabs Selection Boxes in Html, Css, Twitter Bootstrap? : <p><strong>Can anyone have idea, how to create this type of pills/tabs in Html/CSS/Twitter Bootstrap and what they called?</strong></p>
<p><a href="https://i.stack.imgur.com/tpIlj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tpIlj.png" alt="enter image description here"></a></p>
| 0debug
|
Returning address of local variable and program still work : <p>Lets say this is the snapshot I want to talk about. In this code, main function calls 'foo' which returns address of locally declared variable 'a'. I was under the impression that locally declared variables de-allocates the memory when they go out of scope. Variable 'a' should be de-allocated after call to foo is done and there should not be anything left related to 'a'. But in this case, it seems to be breaking that basic assumption. What is going on underneath?</p>
<pre><code>int* foo() {
int a = 5;
return &a;
}
int main() {
int* p = foo();
// Prints 5
std::cout << "Coming from foo = " << *p << std::endl;
*p = 8;
// Prints 8
std::cout << "Setting explicitly = " << *p << std::endl;
}
</code></pre>
| 0debug
|
static void qpci_spapr_io_writeb(QPCIBus *bus, void *addr, uint8_t value)
{
QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
uint64_t port = (uintptr_t)addr;
if (port < s->pio.size) {
writeb(s->pio_cpu_base + port, value);
} else {
writeb(s->mmio_cpu_base + port, value);
}
}
| 1threat
|
void coroutine_fn qemu_co_mutex_unlock(CoMutex *mutex)
{
Coroutine *self = qemu_coroutine_self();
trace_qemu_co_mutex_unlock_entry(mutex, self);
assert(mutex->locked);
assert(mutex->holder == self);
assert(qemu_in_coroutine());
mutex->holder = NULL;
self->locks_held--;
if (atomic_fetch_dec(&mutex->locked) == 1) {
return;
}
for (;;) {
CoWaitRecord *to_wake = pop_waiter(mutex);
unsigned our_handoff;
if (to_wake) {
Coroutine *co = to_wake->co;
aio_co_wake(co);
break;
}
if (++mutex->sequence == 0) {
mutex->sequence = 1;
}
our_handoff = mutex->sequence;
atomic_mb_set(&mutex->handoff, our_handoff);
if (!has_waiters(mutex)) {
break;
}
if (atomic_cmpxchg(&mutex->handoff, our_handoff, 0) != our_handoff) {
break;
}
}
trace_qemu_co_mutex_unlock_return(mutex, self);
}
| 1threat
|
mongoose.connect(), first argument should be String, received undefined : <p>I am trying to set the test database for the testing purpose, but its not working.</p>
<p>I am trying to connect to mongodb using mongoose, but finding problem in connection error shows:</p>
<pre><code>throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
^
MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()`is a string.
at new MongooseError (/media/abhigyan/ABHI/programming/node js/Practice/On my Own/Todo/node_modules/mongoose/lib/error/mongooseError.js:11:11)
at NativeConnection.Connection.openUri (/media/abhigyan/ABHI/programming/node js/Practice/On my Own/Todo/node_modules/mongoose/lib/connection.js:424:11)
at Mongoose.connect (/media/abhigyan/ABHI/programming/node js/Practice/On my Own/Todo/node_modules/mongoose/lib/index.js:230:15)
at Object.<anonymous> (/media/abhigyan/ABHI/programming/node js/Practice/On my Own/Todo/server/db/mongoose.js:5:10)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/media/abhigyan/ABHI/programming/node js/Practice/On my Own/Todo/server/models/Todo.js:1:82)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/media/abhigyan/ABHI/programming/node js/Practice/On my Own/Todo/server/tests/server.test.js:4:16)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at /media/abhigyan/ABHI/programming/node js/Practice/On my Own/Todo/node_modules/mocha/lib/mocha.js:250:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/media/abhigyan/ABHI/programming/node js/Practice/On my Own/Todo/node_modules/mocha/lib/mocha.js:247:14)
at Mocha.run (/media/abhigyan/ABHI/programming/node js/Practice/On my Own/Todo/node_modules/mocha/lib/mocha.js:576:10)
at Object.<anonymous> (/media/abhigyan/ABHI/programming/node js/Practice/On my Own/Todo/node_modules/mocha/bin/_mocha:637:18)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
error Command failed with exit code 1.
</code></pre>
<p>I am passing a valid String, but Its not working!</p>
<pre><code>const mongoose = require('mongoose');
mongoose.Promise = global.Promise;
mongoose.connect(process.env.MONGODB_URI, err => {
if(err)
console.log(err);
}
);
module.exports = {
mongoose
};
</code></pre>
<p>Here is the Script to run mocha:</p>
<pre><code>export NODE_ENV='test' && mocha server/**/*.test.js
</code></pre>
<p>Here is the configuration code:</p>
<pre><code>const config = require('./config.json');
const env = process.env.NODE_ENV.toString() || 'development';
if(env === 'test' || env === 'development') {
const envConfig = config[env];
Object.keys(envConfig).forEach(key => {
process.env[key] = envConfig[key];
});
};
console.log(env);
</code></pre>
<p>Here is the config.json file: </p>
<pre><code>{
"test": {
"PORT": 3000,
"MONGODB_URI": "mongodb://localhost:27017/TodoTest"
},
"development": {
"PORT": 3000,
"MONGODB_URI": "mongodb://localhost:27017/Todo"
}
}
</code></pre>
<p>Thanks for help!</p>
| 0debug
|
Opening Custom WebView with "Powered By Chrome" With action menus : <p>I've recently noticed that when a link is opened in some of few Android apps, they have this similar look and feel and the custom action menus with the "Powered by Chrome" below the custom menu. What component is used in this or is it still the Chromium <code>WebView</code>? Hopefully I'm looking to add them to my next projects which involve opening link inside an app.</p>
<p><a href="https://i.stack.imgur.com/RXitcm.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/RXitcm.jpg" alt="LinkedIn App"></a>
<strong>LinkedIn App</strong></p>
<p><a href="https://i.stack.imgur.com/8NCyem.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8NCyem.png" alt="Twitter App"></a>
<strong>Twitter App</strong></p>
<p><a href="https://i.stack.imgur.com/S7ZLgm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/S7ZLgm.png" alt="GMail App"></a>
<strong>GMail App</strong></p>
| 0debug
|
Create Macro using VBE in Excel to high and unhide rows based on a value : I am trying to create a survey in excel and want to hide and unhide rows based on their answers. For example, If D3 = "no" hide rows D4:D10, and I want to repeat this multiple times throughout, but the number of rows to hide changes. So if D3 = "yes" leave unhidden. Then move to answer D5, if D:5 = "no" hide rows D6:D7. And this continues on and on throughout. I am fine writing a macro for each one, but I have not found one that works out there like this. I would appreciate any help I can get. I am not overly familiar with using VBE.
| 0debug
|
Axios Delete request with body and headers? : <p>I'm using Axios while programing in ReactJS and I pretend to send a DELETE request to my server.</p>
<p>To do so I need the headers:</p>
<pre><code>headers: {
'Authorization': ...
}
</code></pre>
<p>and the body is composed of</p>
<pre><code>var payload = {
"username": ..
}
</code></pre>
<p>I've been searching in the inter webs and only found that the DELETE method requires a "param" and accepts no "data".</p>
<p>I've been trying to send it like so:</p>
<pre><code>axios.delete(URL, payload, header);
</code></pre>
<p>or even</p>
<pre><code>axios.delete(URL, {params: payload}, header);
</code></pre>
<p>But nothing seems to work...</p>
<p>Can someone tell me if its possible (I presume it is) to send a DELETE request with both headers and body and how to do so ?</p>
<p>Thank you in advance!</p>
| 0debug
|
static inline void gen_op_mov_reg_v(int ot, int reg, TCGv t0)
{
switch(ot) {
case OT_BYTE:
if (reg < 4 X86_64_DEF( || reg >= 8 || x86_64_hregs)) {
tcg_gen_deposit_tl(cpu_regs[reg], cpu_regs[reg], t0, 0, 8);
} else {
tcg_gen_deposit_tl(cpu_regs[reg - 4], cpu_regs[reg - 4], t0, 8, 8);
}
break;
case OT_WORD:
tcg_gen_deposit_tl(cpu_regs[reg], cpu_regs[reg], t0, 0, 16);
break;
default:
case OT_LONG:
tcg_gen_ext32u_tl(cpu_regs[reg], t0);
break;
#ifdef TARGET_X86_64
case OT_QUAD:
tcg_gen_mov_tl(cpu_regs[reg], t0);
break;
#endif
}
}
| 1threat
|
C# Sql commands are not working : i have problem that the code isnt work, im trying to populate the database that saved in local host on Sql-Server but the code is doing nothing :(
private void button2_Click(object sender, EventArgs e)
{
try
{
conn.Open();
if (dataGridView1.SelectedRows.Count != 0 && listBox1.SelectedIndex != -1)
{
string id = "select studentID from student where studentName like '%" + listBox1.SelectedItem.ToString() + "%'";
SqlCommand a = new SqlCommand(id, conn);
a.ExecuteNonQuery();
SqlDataReader reader = a.ExecuteReader();
string s = reader.GetString(0);
string q = "insert into Borrow values (" + dataGridView1.CurrentRow.Cells[0].Value.ToString()
+ ", " + s + " , '" + DateTime.Now + "' , Null)";
SqlCommand cmd = new SqlCommand(q, conn);
cmd.ExecuteNonQuery();
MessageBox.Show("Book is now Borrowed");
string tmp = "update Book set quantity=quantity-1 where bookID " + dataGridView1.CurrentRow.Cells[0].Value.ToString();
SqlCommand tm = new SqlCommand(tmp, conn);
}
}
catch
{
}
finally
{
conn.Close();
}
}
| 0debug
|
Store members of date in diferent variables : I want to store the date in different integer variables, such as month, date, hour, min, sec in C++ in Ubuntu.
| 0debug
|
Is it possible to define a non empty array type in Typescript? : <p>I have a list of numbers that I know is never empty. Is it possible to define an array in Typescript that is never empty?</p>
<p>I know that it is possible with tuples like <code>[ number, number ]</code> but this will not work as my array can be any size.</p>
<p>I guess what I am looking for is a <code>NonEmptyArray<number></code> type.</p>
<p>Does it exist? :)</p>
| 0debug
|
static int do_load_save_vmstate(BDRVSheepdogState *s, uint8_t *data,
int64_t pos, int size, int load)
{
bool create;
int fd, ret = 0, remaining = size;
unsigned int data_len;
uint64_t vmstate_oid;
uint32_t vdi_index;
uint64_t offset;
fd = connect_to_sdog(s->addr, s->port);
if (fd < 0) {
return fd;
}
while (remaining) {
vdi_index = pos / SD_DATA_OBJ_SIZE;
offset = pos % SD_DATA_OBJ_SIZE;
data_len = MIN(remaining, SD_DATA_OBJ_SIZE - offset);
vmstate_oid = vid_to_vmstate_oid(s->inode.vdi_id, vdi_index);
create = (offset == 0);
if (load) {
ret = read_object(fd, (char *)data, vmstate_oid,
s->inode.nr_copies, data_len, offset,
s->cache_enabled);
} else {
ret = write_object(fd, (char *)data, vmstate_oid,
s->inode.nr_copies, data_len, offset, create,
s->cache_enabled);
}
if (ret < 0) {
error_report("failed to save vmstate %s", strerror(errno));
goto cleanup;
}
pos += data_len;
data += data_len;
remaining -= data_len;
}
ret = size;
cleanup:
closesocket(fd);
return ret;
}
| 1threat
|
JvmOverloads annotation for class primary constructor : <p>Why is it prohibited to autogenerate many constructors visible to Java from class primary constructor with default params likes this?</p>
<pre><code>@JvmOverloads
class Video(private val id: Long, val ownerId: Long, var title: String? = null, var imgLink: String? = null, var videoLink: String? = null,
var description: String? = null, var created: Date? = null, var accessKey: String? = null, var duration: Long? = null,
var views: Long? = null, var comments: Long? = null) : Entity
</code></pre>
<blockquote>
<p>This annotation is not applicable to target 'class'</p>
</blockquote>
| 0debug
|
Remove a big list of of special characters : <p>I want to remove each of the following special characters from my documents: </p>
<pre><code>symbols = {`,~,!,@,#,$,%,^,&,*,(,),_,-,+,=,{,[,],},|,\,:,;,",<,,,>,.,?,/}
</code></pre>
<p>The reason why I am not simply doing something like this:</p>
<pre><code>document = re.sub(r'([^\s\w]|_)+', '', document)
</code></pre>
<p>is that in this way I remove also many (accented/special) letters in the case of documents written in languages such as Polish etc.</p>
<p>How can I remove each of the special characters above in one expression?</p>
| 0debug
|
Loop on all lines of very large file C# : <p>I want to loop on all the lines of a very large file (10GB for example) using <code>foreach</code></p>
<p>I am currently using <code>File.ReadLines</code> like that:</p>
<pre><code>var lines = File.ReadLines(fileName);
foreach (var line in lines) {
// Process line
}
</code></pre>
<p>But this is very slow if the file is larger than 2MB and it will do the loop very slowly.</p>
<p>How can I loop on very large files?</p>
<p>Any help would be appreciated.</p>
<p>Thanks!</p>
| 0debug
|
what i have to do with this error in android studio : Cannot launch AVD in emulator.
Output:
Hax is enabled
Hax ram_size 0x60000000
HAX is working and emulator runs in fast virt mode.
emulator: WARNING: UpdateCheck: Failure: No error
none.xml:1: parser error : Extra content at the end of the document
s=Windowsversion=25.2.2.0&coreVersion=C%3A\Users\zigorat\.android">Found</a>
^
emulator: Listening for console connections on port: 5554
emulator: Serial number of this emulator (for ADB): emulator-5554
[8652]:WARNING:./android/base/files/IniFile.cpp:158:Failed to process .ini file C:\Users\zigorat\.android\emu-update-last-check.ini for reading.
none.xml:1: parser error : Extra content at the end of the document
90f9e0a9&os=Windowsversion=25.2.2.0&coreVersion=qemu2%202.2.0">Found</a>
^
emulator: WARNING: UpdateCheck: Failure: No error
emulator: WARNING: UpdateCheck: failed to get the latest version, skipping check (current version '25.2.
| 0debug
|
Assemebly Help cmp dont work properly : Hello everyone i am new in asm x86 problem is i am trying to code simple number comparison script but cmp doesnt work properly here is my code THANKs!
---------------------------------------------------------------------
`global _start
section .bss
number1:resb 3
number2:resb 3
section .data
da db "hello"
ll equ $-da
label1 db "enter the first number >>>"
len equ $-label1
label2 db "enter the second number >>>"
len2 equ $-label2
mess1 db "number 1 less than number 2",0ah
l1 equ $-mess1
mess2 db "number2 less than number 1",0ah
l2 equ $-mess2
section .text
_start:
mov eax,4
mov ebx,1
mov ecx,label1
mov edx,len
int 80h
mov eax,3
mov ebx,2
mov ecx,number1
mov edx,3
int 80h
mov eax,4
mov ebx,1
mov ecx,label2
mov edx,len2
int 80h
mov eax,3
mov ebx,2
mov ecx,number2
mov edx,3
int 80h
mov eax,4
mov ebx,1
mov ecx,number1
mov edx,3
int 80h
mov ax,number1
mov bx,number2
cmp ax,bx
jl _ss1
_ss1:
int 80h
mov eax,4
mov ebx,1
mov ecx,da
mov edx,ll
int 80h
mov eax,1
mov ebx,0
int 80h`
| 0debug
|
Try-With Resource when AutoCloseable is null : <p>How does the try-with feature work for <code>AutoCloseable</code> variables that have been declared <code>null</code>? </p>
<p>I assumed this would lead to a null pointer exception when it attempts to invoke <code>close</code> on the variable, but it runs no problem:</p>
<pre><code>try (BufferedReader br = null){
System.out.println("Test");
}
catch (IOException e){
e.printStackTrace();
}
</code></pre>
| 0debug
|
Spring Boot 1.4 testing with Security enabled? : <p>I'm wondering how I should go about authenticating a user for my tests? As it stands now all tests I will write will fail because the endpoints require authorization.</p>
<p>Test code:</p>
<pre><code>@RunWith(SpringRunner.class)
@WebMvcTest(value = PostController.class)
public class PostControllerTest {
@Autowired
private MockMvc mvc;
@MockBean
private PostService postService;
@Test
public void testHome() throws Exception {
this.mvc.perform(get("/")).andExpect(status().isOk()).andExpect(view().name("posts"));
}
}
</code></pre>
<p>One solution I found is to disable it by setting secure to false in @WebMvcTest. But that's not what I'm trying to do.</p>
<p>Any ideas?</p>
| 0debug
|
static const HWAccel *get_hwaccel(enum AVPixelFormat pix_fmt)
{
int i;
for (i = 0; hwaccels[i].name; i++)
if (hwaccels[i].pix_fmt == pix_fmt)
return &hwaccels[i];
return NULL;
}
| 1threat
|
static void elcr_ioport_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
PICCommonState *s = opaque;
s->elcr = val & s->elcr_mask;
}
| 1threat
|
FirstOrDefaultAsync() & SingleOrDefaultAsync() vs FindAsync() EFCore : <p>We have 3 different approaches to get single items from EFCore they are <code>FirstOrDefaultAsync()</code>, <code>SingleOrDefaultAsync()</code> (including its versions with not default value returned, also we have <code>FindAsync()</code> and maybe more with the same purpose like <code>LastOrDefaultAsync()</code>. </p>
<pre><code> var findItem = await dbContext.TodoItems
.FindAsync(request.Id)
.ConfigureAwait(false);
var firstItem = await dbContext.TodoItems
.FirstOrDefaultAsync(i => i.Id == request.Id)
.ConfigureAwait(false);
var singleItem = await dbContext.TodoItems
.SingleOrDefaultAsync(i => i.Id == request.Id)
.ConfigureAwait(false);
</code></pre>
<p>I would like to know the differences between each one of them. So far what I know is that we <code>FirstOrDefaultAsync()</code> to get the first given a condition, (usually using this because we know that more than one item can satisfy the condition), on the other hand we use <code>SingleOrDefaultAsync()</code> because we know that there is only one possible match to find, and <code>FindAsync()</code> to get an item given its primary key.</p>
<p>I think <code>FirstOrDefaultAsync()</code> & <code>SingleOrDefaultAsync()</code> always hit the database (not sure about this), and <code>FindAsync()</code> this is what Microsoft docs says:</p>
<blockquote>
<p>Asynchronously finds an entity with the given primary key values. If
an entity with the given primary key values exists in the context,
then it is returned immediately without making a request to the store.
Otherwise, a request is made to the store for an entity with the given
primary key values and this entity, if found, is attached to the
context and returned. If no entity is found in the context or the
store, then null is returned.</p>
</blockquote>
<p>So my question is, if our given condition used for <code>FirstOrDefault()</code>, <code>SingleOrDefault()</code> and <code>FindAsync()</code> is the primary key, <strong>do we have any actual difference?</strong></p>
<p>What I think is that the first time they are used always hit the db, <strong>but what about the next calls?</strong>. And probably EFCore could use the same context to get the values for <code>FirstOrDefault()</code> and <code>SingleOrDefault()</code> as it does for <code>FindAsync()</code>, <strong>maybe?</strong>.</p>
| 0debug
|
call a javascript function inside ajax success function : <p>I Have an ajax success function that I wich to call inside it another javascript function, but i don't know the command or the JQuery function to do that.</p>
<p>Here is my function:</p>
<pre><code> function save(id_matiere,id_grp,id_niv)
{
$.ajax({
url : "<?php echo site_url('index.php/programme/ajouter_ens_mat')?>",
type: "POST",
data: $('#form').serialize()+ '&m='+ id_matiere+ '&g='+ id_grp,
dataType: "JSON",
success: function(data)
{
afficher(id_grp,id_niv);
}
});
}
</code></pre>
<p>The function name that I wich to call is called "afficher".</p>
<p>Tell me please how to do this.
thank you!</p>
| 0debug
|
static int vhost_set_vring_file(struct vhost_dev *dev,
VhostUserRequest request,
struct vhost_vring_file *file)
{
int fds[VHOST_MEMORY_MAX_NREGIONS];
size_t fd_num = 0;
VhostUserMsg msg = {
.request = request,
.flags = VHOST_USER_VERSION,
.payload.u64 = file->index & VHOST_USER_VRING_IDX_MASK,
.size = sizeof(msg.payload.u64),
};
if (ioeventfd_enabled() && file->fd > 0) {
fds[fd_num++] = file->fd;
} else {
msg.payload.u64 |= VHOST_USER_VRING_NOFD_MASK;
}
vhost_user_write(dev, &msg, fds, fd_num);
return 0;
}
| 1threat
|
What does the getenv() function in the code below do? : <pre><code>emailpassword: getenv('EMAIL_PASSWORD',''),
</code></pre>
<p>So what exactly does this code do? And what is the 'getenv' function.
A quick google search told me that it is something to do with environment variables. Could someone explain what they are?</p>
| 0debug
|
const char *bdrv_get_encrypted_filename(BlockDriverState *bs)
{
if (bs->backing_hd && bs->backing_hd->encrypted)
return bs->backing_file;
else if (bs->encrypted)
return bs->filename;
else
return NULL;
}
| 1threat
|
how can i arrange array like this : <p>I have array like below:</p>
<p>$matrix = array(1, 2, 1,1, 2, 1,1, 1, 1);</p>
<p>how can I get array like below?</p>
<pre><code>//OUTPUT:
minesweeper(matrix) = [[1, 2, 1],
[2, 1, 1],
[1, 1, 1]]
</code></pre>
| 0debug
|
Dynamica alocation of an unknown matrix in C : I'm new to stack overflow, I've searched for the info available and I can't really find an answer to my question unless I'm just overlooking it.
I need to take a file that is inputted by the user and multiply it by another file. That much I know how to do.
the problem is one file is an array and the other is a matrix.
I need to scan in the first line of the matrix to find the size of the matrix and I then need to dynamically allocate the matrix and array from the files.
This is what I have so far
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main()
{
int row1, col1;
//These values need to be pulled from the first file//
char filename1[100];
//Seting the file name for entery and seting the limit to 100//
FILE* fp1;
//FILE must be set as a pointer (FILE must also be capitalized)//
printf("Enter file name including file extention: \n");
//This will pull in the name entered by the user//
scanf("%s", filename1);
//Scans in the name of the first file//
fp1 = fopen(filename1, "r");
//This will open the file as entered by the user//
if (fp1 == NULL)
{
printf("\nError, file not found\n");
exit(0);
}
//This is for the first file//
char filename2[100];
//Seting the file name for entery and seting the limit to 100//
FILE* fp2;
//FILE must be set as a pointer (FILE must also be capitalized)//
printf("Enter file name including file extention: \n");
//This will pull in the name entered by the user//
scanf("%s", filename2);
//Scans in the name of the first file//
fp2 = fopen(filename2, "r");
//This will open the file as entered by the user//
if (fp2 == NULL)
{
printf("\nError, file not found\n");
exit(0);
}
//This is for the second file//
//**I need to now dynamicaly allocate the input files**//
return 0;
}
| 0debug
|
static int mmu_translate_region(CPUS390XState *env, target_ulong vaddr,
uint64_t asc, uint64_t entry, int level,
target_ulong *raddr, int *flags, int rw,
bool exc)
{
CPUState *cs = CPU(s390_env_get_cpu(env));
uint64_t origin, offs, new_entry;
const int pchks[4] = {
PGM_SEGMENT_TRANS, PGM_REG_THIRD_TRANS,
PGM_REG_SEC_TRANS, PGM_REG_FIRST_TRANS
};
PTE_DPRINTF("%s: 0x%" PRIx64 "\n", __func__, entry);
origin = entry & _REGION_ENTRY_ORIGIN;
offs = (vaddr >> (17 + 11 * level / 4)) & 0x3ff8;
new_entry = ldq_phys(cs->as, origin + offs);
PTE_DPRINTF("%s: 0x%" PRIx64 " + 0x%" PRIx64 " => 0x%016" PRIx64 "\n",
__func__, origin, offs, new_entry);
if ((new_entry & _REGION_ENTRY_INV) != 0) {
DPRINTF("%s: invalid region\n", __func__);
trigger_page_fault(env, vaddr, pchks[level / 4], asc, rw, exc);
return -1;
}
if ((new_entry & _REGION_ENTRY_TYPE_MASK) != level) {
trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw, exc);
return -1;
}
if (level == _ASCE_TYPE_SEGMENT) {
return mmu_translate_segment(env, vaddr, asc, new_entry, raddr, flags,
rw, exc);
}
offs = (vaddr >> (28 + 11 * (level - 4) / 4)) & 3;
if (offs < ((new_entry & _REGION_ENTRY_TF) >> 6)
|| offs > (new_entry & _REGION_ENTRY_LENGTH)) {
DPRINTF("%s: invalid offset or len (%lx)\n", __func__, new_entry);
trigger_page_fault(env, vaddr, pchks[level / 4 - 1], asc, rw, exc);
return -1;
}
return mmu_translate_region(env, vaddr, asc, new_entry, level - 4,
raddr, flags, rw, exc);
}
| 1threat
|
static void write_streaminfo(FlacEncodeContext *s, uint8_t *header)
{
PutBitContext pb;
memset(header, 0, FLAC_STREAMINFO_SIZE);
init_put_bits(&pb, header, FLAC_STREAMINFO_SIZE);
put_bits(&pb, 16, s->avctx->frame_size);
put_bits(&pb, 16, s->avctx->frame_size);
put_bits(&pb, 24, 0);
put_bits(&pb, 24, s->max_framesize);
put_bits(&pb, 20, s->samplerate);
put_bits(&pb, 3, s->channels-1);
put_bits(&pb, 5, 15);
put_bits(&pb, 24, (s->sample_count & 0xFFFFFF000LL) >> 12);
put_bits(&pb, 12, s->sample_count & 0x000000FFFLL);
flush_put_bits(&pb);
}
| 1threat
|
static void monitor_event(void *opaque, int event)
{
Monitor *mon = opaque;
switch (event) {
case CHR_EVENT_MUX_IN:
qemu_mutex_lock(&mon->out_lock);
mon->mux_out = 0;
qemu_mutex_unlock(&mon->out_lock);
if (mon->reset_seen) {
monitor_resume(mon);
monitor_flush(mon);
} else {
mon->suspend_cnt = 0;
}
break;
case CHR_EVENT_MUX_OUT:
if (mon->reset_seen) {
if (mon->suspend_cnt == 0) {
monitor_printf(mon, "\n");
}
monitor_flush(mon);
monitor_suspend(mon);
} else {
mon->suspend_cnt++;
}
qemu_mutex_lock(&mon->out_lock);
mon->mux_out = 1;
qemu_mutex_unlock(&mon->out_lock);
break;
case CHR_EVENT_OPENED:
monitor_printf(mon, "QEMU %s monitor - type 'help' for more "
"information\n", QEMU_VERSION);
if (!mon->mux_out) {
readline_show_prompt(mon->rs);
}
mon->reset_seen = 1;
mon_refcount++;
break;
case CHR_EVENT_CLOSED:
mon_refcount--;
monitor_fdsets_cleanup();
break;
}
}
| 1threat
|
static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr,
GetBitContext *gb, SBRData *ch_data)
{
int i;
ch_data->bs_freq_res[0] = ch_data->bs_freq_res[ch_data->bs_num_env[1]];
ch_data->bs_num_env[0] = ch_data->bs_num_env[1];
ch_data->bs_amp_res = sbr->bs_amp_res_header;
switch (ch_data->bs_frame_class = get_bits(gb, 2)) {
case FIXFIX:
ch_data->bs_num_env[1] = 1 << get_bits(gb, 2);
if (ch_data->bs_num_env[1] == 1)
ch_data->bs_amp_res = 0;
ch_data->bs_freq_res[1] = get_bits1(gb);
for (i = 1; i < ch_data->bs_num_env[1]; i++)
ch_data->bs_freq_res[i + 1] = ch_data->bs_freq_res[1];
break;
case FIXVAR:
ch_data->bs_var_bord[1] = get_bits(gb, 2);
ch_data->bs_num_rel[1] = get_bits(gb, 2);
ch_data->bs_num_env[1] = ch_data->bs_num_rel[1] + 1;
for (i = 0; i < ch_data->bs_num_rel[1]; i++)
ch_data->bs_rel_bord[1][i] = 2 * get_bits(gb, 2) + 2;
ch_data->bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env[1]]);
for (i = 0; i < ch_data->bs_num_env[1]; i++)
ch_data->bs_freq_res[ch_data->bs_num_env[1] - i] = get_bits1(gb);
break;
case VARFIX:
ch_data->bs_var_bord[0] = get_bits(gb, 2);
ch_data->bs_num_rel[0] = get_bits(gb, 2);
ch_data->bs_num_env[1] = ch_data->bs_num_rel[0] + 1;
for (i = 0; i < ch_data->bs_num_rel[0]; i++)
ch_data->bs_rel_bord[0][i] = 2 * get_bits(gb, 2) + 2;
ch_data->bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env[1]]);
get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env[1]);
break;
case VARVAR:
ch_data->bs_var_bord[0] = get_bits(gb, 2);
ch_data->bs_var_bord[1] = get_bits(gb, 2);
ch_data->bs_num_rel[0] = get_bits(gb, 2);
ch_data->bs_num_rel[1] = get_bits(gb, 2);
ch_data->bs_num_env[1] = ch_data->bs_num_rel[0] + ch_data->bs_num_rel[1] + 1;
for (i = 0; i < ch_data->bs_num_rel[0]; i++)
ch_data->bs_rel_bord[0][i] = 2 * get_bits(gb, 2) + 2;
for (i = 0; i < ch_data->bs_num_rel[1]; i++)
ch_data->bs_rel_bord[1][i] = 2 * get_bits(gb, 2) + 2;
ch_data->bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env[1]]);
get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env[1]);
break;
}
if (ch_data->bs_pointer > ch_data->bs_num_env[1] + 1) {
av_log(ac->avccontext, AV_LOG_ERROR,
"Invalid bitstream, bs_pointer points to a middle noise border outside the time borders table: %d\n",
ch_data->bs_pointer);
return -1;
}
if (ch_data->bs_frame_class == FIXFIX && ch_data->bs_num_env[1] > 4) {
av_log(ac->avccontext, AV_LOG_ERROR,
"Invalid bitstream, too many SBR envelopes in FIXFIX type SBR frame: %d\n",
ch_data->bs_num_env[1]);
return -1;
}
if (ch_data->bs_frame_class == VARVAR && ch_data->bs_num_env[1] > 5) {
av_log(ac->avccontext, AV_LOG_ERROR,
"Invalid bitstream, too many SBR envelopes in VARVAR type SBR frame: %d\n",
ch_data->bs_num_env[1]);
return -1;
}
ch_data->bs_num_noise = (ch_data->bs_num_env[1] > 1) + 1;
return 0;
}
| 1threat
|
vmxnet3_io_bar0_write(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
VMXNET3State *s = opaque;
if (VMW_IS_MULTIREG_ADDR(addr, VMXNET3_REG_TXPROD,
VMXNET3_DEVICE_MAX_TX_QUEUES, VMXNET3_REG_ALIGN)) {
int tx_queue_idx =
VMW_MULTIREG_IDX_BY_ADDR(addr, VMXNET3_REG_TXPROD,
VMXNET3_REG_ALIGN);
assert(tx_queue_idx <= s->txq_num);
vmxnet3_process_tx_queue(s, tx_queue_idx);
if (VMW_IS_MULTIREG_ADDR(addr, VMXNET3_REG_IMR,
VMXNET3_MAX_INTRS, VMXNET3_REG_ALIGN)) {
int l = VMW_MULTIREG_IDX_BY_ADDR(addr, VMXNET3_REG_IMR,
VMXNET3_REG_ALIGN);
VMW_CBPRN("Interrupt mask for line %d written: 0x%" PRIx64, l, val);
vmxnet3_on_interrupt_mask_changed(s, l, val);
if (VMW_IS_MULTIREG_ADDR(addr, VMXNET3_REG_RXPROD,
VMXNET3_DEVICE_MAX_RX_QUEUES, VMXNET3_REG_ALIGN) ||
VMW_IS_MULTIREG_ADDR(addr, VMXNET3_REG_RXPROD2,
VMXNET3_DEVICE_MAX_RX_QUEUES, VMXNET3_REG_ALIGN)) {
VMW_WRPRN("BAR0 unknown write [%" PRIx64 "] = %" PRIx64 ", size %d",
(uint64_t) addr, val, size);
| 1threat
|
static int aiff_read_header(AVFormatContext *s)
{
int size, filesize;
int64_t offset = 0;
uint32_t tag;
unsigned version = AIFF_C_VERSION1;
AVIOContext *pb = s->pb;
AVStream * st;
AIFFInputContext *aiff = s->priv_data;
filesize = get_tag(pb, &tag);
if (filesize < 0 || tag != MKTAG('F', 'O', 'R', 'M'))
return AVERROR_INVALIDDATA;
tag = avio_rl32(pb);
if (tag == MKTAG('A', 'I', 'F', 'F'))
version = AIFF;
else if (tag != MKTAG('A', 'I', 'F', 'C'))
return AVERROR_INVALIDDATA;
filesize -= 4;
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
while (filesize > 0) {
size = get_tag(pb, &tag);
if (size < 0)
return size;
filesize -= size + 8;
switch (tag) {
case MKTAG('C', 'O', 'M', 'M'):
st->nb_frames = get_aiff_header(s, size, version);
if (st->nb_frames < 0)
return st->nb_frames;
if (offset > 0)
goto got_sound;
break;
case MKTAG('F', 'V', 'E', 'R'):
version = avio_rb32(pb);
break;
case MKTAG('N', 'A', 'M', 'E'):
get_meta(s, "title" , size);
break;
case MKTAG('A', 'U', 'T', 'H'):
get_meta(s, "author" , size);
break;
case MKTAG('(', 'c', ')', ' '):
get_meta(s, "copyright", size);
break;
case MKTAG('A', 'N', 'N', 'O'):
get_meta(s, "comment" , size);
break;
case MKTAG('S', 'S', 'N', 'D'):
aiff->data_end = avio_tell(pb) + size;
offset = avio_rb32(pb);
avio_rb32(pb);
offset += avio_tell(pb);
if (st->codecpar->block_align)
goto got_sound;
if (!pb->seekable) {
av_log(s, AV_LOG_ERROR, "file is not seekable\n");
return -1;
}
avio_skip(pb, size - 8);
break;
case MKTAG('w', 'a', 'v', 'e'):
if ((uint64_t)size > (1<<30))
return -1;
st->codecpar->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
st->codecpar->extradata_size = size;
avio_read(pb, st->codecpar->extradata, size);
break;
default:
avio_skip(pb, size);
}
if (size & 1) {
filesize--;
avio_skip(pb, 1);
}
}
got_sound:
if (!st->codecpar->block_align) {
av_log(s, AV_LOG_ERROR, "could not find COMM tag or invalid block_align value\n");
return -1;
}
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
st->start_time = 0;
st->duration = st->nb_frames * aiff->block_duration;
avio_seek(pb, offset, SEEK_SET);
return 0;
}
| 1threat
|
I want to find Ip address and Domain name of server whichever we connect by using Ruby.? : <p>Means I want to create method which will find Ip address and Domain name of server by using Ruby.</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.