problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
static int sysctl_oldcvt(void *holdp, size_t holdlen, uint32_t kind)
{
switch (kind & CTLTYPE) {
case CTLTYPE_INT:
case CTLTYPE_UINT:
*(uint32_t *)holdp = tswap32(*(uint32_t *)holdp);
break;
#ifdef TARGET_ABI32
case CTLTYPE_LONG:
case CTLTYPE_ULONG:
*(uint32_t *)holdp = tswap32(*(long *)holdp);
break;
#else
case CTLTYPE_LONG:
*(uint64_t *)holdp = tswap64(*(long *)holdp);
case CTLTYPE_ULONG:
*(uint64_t *)holdp = tswap64(*(unsigned long *)holdp);
break;
#endif
#if !defined(__FreeBSD_version) || __FreeBSD_version < 900031
case CTLTYPE_QUAD:
#else
case CTLTYPE_U64:
#endif
*(uint64_t *)holdp = tswap64(*(uint64_t *)holdp);
break;
case CTLTYPE_STRING:
break;
default:
return -1;
}
return 0;
}
| 1threat |
def check_Odd_Parity(x):
parity = 0
while (x != 0):
x = x & (x - 1)
parity += 1
if (parity % 2 == 1):
return True
else:
return False | 0debug |
How create app to app communication in c#? : <p>I have problem, because I can send data from program for example program1 to program2.
I see that can use events, observer but the problem is how. </p>
<p>Sorry but I not have any code.</p>
<p>Can anybody take here example or link for help to understand events and observers? </p>
| 0debug |
What is format of object JS? : <p>There is an array:</p>
<pre><code>var data = data.addRows([
['Nitrogen', 0.78],
['Oxygen', 0.21],
['Other', 0.01]
]);
</code></pre>
<p>What does it mean? Arrays in array? What is it <code>['Nitrogen', 0.78]</code> ? Why <code>[]</code> brackets?</p>
<p>I tried to reproduce this like:</p>
<pre><code>var arr = [];
arr.push({'Oxygen', 0.21});
</code></pre>
| 0debug |
how to pass varibale from HTML page to nodejs : I have a requirement where i want to pass variable from HTML to nodejs.Requirement is as below:
1) I have different hyperlink of different areas like Newcastle, Dudley, Belfast.
2) for now i'm calling my nodejs code by passing /Newcastle or /Dudley or /Belfast
3) Now Based on these hyperlink click i'm triggering code to perform process to retrieve data
4) As of now i have seperate processing code for all these
5) What I'm looking to make a single common code to process the above request dynamically.
6) For which I want to pass some variable or parameter from HTML page to node JS to indicate the respective region like Newcastle or Belfast
Please suggest how I can achieve it. | 0debug |
const char *get_feature_xml(CPUState *env, const char *p, const char **newp)
{
extern const char *const xml_builtin[][2];
size_t len;
int i;
const char *name;
static char target_xml[1024];
len = 0;
while (p[len] && p[len] != ':')
len++;
*newp = p + len;
name = NULL;
if (strncmp(p, "target.xml", len) == 0) {
if (!target_xml[0]) {
GDBRegisterState *r;
sprintf(target_xml,
"<?xml version=\"1.0\"?>"
"<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"
"<target>"
"<xi:include href=\"%s\"/>",
GDB_CORE_XML);
for (r = env->gdb_regs; r; r = r->next) {
strcat(target_xml, "<xi:include href=\"");
strcat(target_xml, r->xml);
strcat(target_xml, "\"/>");
}
strcat(target_xml, "</target>");
}
return target_xml;
}
for (i = 0; ; i++) {
name = xml_builtin[i][0];
if (!name || (strncmp(name, p, len) == 0 && strlen(name) == len))
break;
}
return name ? xml_builtin[i][1] : NULL;
}
| 1threat |
How to reference Boolean java class from kotlin? : <p>As far as I understand <code>Boolean::class.java</code> gives me <code>Boolean.TYPE</code>, but not <code>Boolean.class</code></p>
| 0debug |
returning a value from a column if row number equals to a given value : <p>I have a dataframe with two columns, let's call them "value" and "diff". The column diff contains random row numbers.
I would like to create a vector by selecting values from the column "value" satisfying one condition, namely finding the value where the number given in diff column equals to the rownumber of the dataframe.
Shall I try it with a for loop, or is there an easier solution?</p>
| 0debug |
Why does -u mean remember for git push [-u] : In the manual it states that `-u` will tell git to remember where to push to.
However, I think this is a strange abbreviation. `-r` would make more sense.
It works fine I'm just wondering where these abbreviations come from.
Any one? | 0debug |
void ppc40x_chip_reset (CPUState *env)
{
target_ulong dbsr;
printf("Reset PowerPC chip\n");
cpu_ppc_reset(env);
dbsr = env->spr[SPR_40x_DBSR];
dbsr &= ~0x00000300;
dbsr |= 0x00000200;
env->spr[SPR_40x_DBSR] = dbsr;
cpu_loop_exit();
}
| 1threat |
How to use the Jenkins MSBuild plug-in in a Jenkinsfile? : <p>I have Jenkins v2.60.3 with the <a href="http://wiki.jenkins-ci.org/display/JENKINS/MSBuild+Plugin" rel="noreferrer">MSBuild Plugin</a> v1.27 installed on Windows.</p>
<p>I have configured the path to my <code>msbuild.exe</code> in Jenkins' Global Tool Configuration. I have also setup a Multi Branch Pipeline in Jenkins that picks up a <code>Jenkinsfile</code> from git repo successfully.</p>
<p>My question is: How do I invoke the MSBuild Plugin as a step in my <code>Jenkinsfile</code>? </p>
<p>Please note I know I can invoke <code>msbuild.exe</code> directly as a Windows batch step but I prefer to go through the MSBuild Plugin if possible.
`</p>
| 0debug |
void do_tlbwi (void)
{
mips_tlb_flush_extra (env, MIPS_TLB_NB);
invalidate_tlb(env->CP0_index & (MIPS_TLB_NB - 1), 0);
fill_tlb(env->CP0_index & (MIPS_TLB_NB - 1));
}
| 1threat |
can this have a better solution than the naive O(n*log(n)) approach. if yes can you please suggest an approach : you are given a string consisting of only 1's. eg: "11111111"
you have an iterator that changes direction when it hits the extremes of the string. starting in the direction left to right.
the iterator replaces the next immediate '1' in its path with a zero and then skips to the '1' following that. This goes on until there is only one '1' remaining in the string.
you have to print the location of that '1'.
here is a python 3 code with the naive solution (it also prints the steps for understanding the problem, although steps are not required for the expected answer):
n=int(input("enter the number of people in the row : "))
assert(n>=1)
input_string="1"*n
print(input_string)
direction=1
iterator=0
count=0
while(count!=1):
count=0
next_to_delete=-1
while(iterator<len(input_string) and iterator>=0):
if(input_string[iterator]=='1'):
if(next_to_delete==-1):
next_to_delete=iterator
else:
input_string=input_string[:iterator]+"0"+input_string[iterator+1:]
#i.e. input_string[iterator]='0'
next_to_delete=-1
count+=1
iterator+=direction
print(input_string)
direction=1 if direction==-1 else -1
iterator+=direction
print("answer is : ",end='')
print(next_to_delete+1) | 0debug |
numpy array printing in desired manner : <p>I am using numpy array to fetch values from file and do calculations. The final output is like this <br>
<code>('I', 10031, 'GASAS.SW', 2024, 23067, -501, -6760.1, 1, 125 )</code> <br>
But i need it to be printed like this <br>
<code>I 10031 GASAS.SW 2024 23067 -501 -6760.1 1 125</code> <br></p>
| 0debug |
static void vnc_dpy_copy(DisplayChangeListener *dcl,
DisplayState *ds,
int src_x, int src_y,
int dst_x, int dst_y, int w, int h)
{
VncDisplay *vd = ds->opaque;
VncState *vs, *vn;
uint8_t *src_row;
uint8_t *dst_row;
int i, x, y, pitch, inc, w_lim, s;
int cmp_bytes;
vnc_refresh_server_surface(vd);
QTAILQ_FOREACH_SAFE(vs, &vd->clients, next, vn) {
if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {
vs->force_update = 1;
vnc_update_client_sync(vs, 1);
}
}
pitch = vnc_server_fb_stride(vd);
src_row = vnc_server_fb_ptr(vd, src_x, src_y);
dst_row = vnc_server_fb_ptr(vd, dst_x, dst_y);
y = dst_y;
inc = 1;
if (dst_y > src_y) {
src_row += pitch * (h-1);
dst_row += pitch * (h-1);
pitch = -pitch;
y = dst_y + h - 1;
inc = -1;
}
w_lim = w - (16 - (dst_x % 16));
if (w_lim < 0)
w_lim = w;
else
w_lim = w - (w_lim % 16);
for (i = 0; i < h; i++) {
for (x = 0; x <= w_lim;
x += s, src_row += cmp_bytes, dst_row += cmp_bytes) {
if (x == w_lim) {
if ((s = w - w_lim) == 0)
break;
} else if (!x) {
s = (16 - (dst_x % 16));
s = MIN(s, w_lim);
} else {
s = 16;
}
cmp_bytes = s * VNC_SERVER_FB_BYTES;
if (memcmp(src_row, dst_row, cmp_bytes) == 0)
continue;
memmove(dst_row, src_row, cmp_bytes);
QTAILQ_FOREACH(vs, &vd->clients, next) {
if (!vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {
set_bit(((x + dst_x) / 16), vs->dirty[y]);
}
}
}
src_row += pitch - w * VNC_SERVER_FB_BYTES;
dst_row += pitch - w * VNC_SERVER_FB_BYTES;
y += inc;
}
QTAILQ_FOREACH(vs, &vd->clients, next) {
if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {
vnc_copy(vs, src_x, src_y, dst_x, dst_y, w, h);
}
}
}
| 1threat |
Pylint badge in gitlab : <p>Gitlab has functionality to generade badges about build status and coverage percentage.<br>
Is it possible to create custom badge to display Pylint results?
Or just display this results in README.md?<br>
I already have CI job for Pylint</p>
| 0debug |
Spring Data Redis Expire Key : <p>I have a One Spring Hibernate Application. In my application, Recently i am implemented Spring data Redis.</p>
<pre><code>spring-servlet.xml
<!-- redis connection factory -->
<bean id="jedisConnFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" p:use-pool="true"/>
<!-- redis template definition -->
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"
p:connection-factory-ref="jedisConnFactory"/>
</code></pre>
<p>And this <code>redisTemplate</code> use in my ServiceImpl class.</p>
<pre><code>RedisServiceImpl
@Autowired
private RedisTemplate<String, T> redisTemplate;
public RedisTemplate<String, T> getRedisTemplate() {
return redisTemplate;
}
public void setRedisTemplate(RedisTemplate<String, T> redisTemplate) {
this.redisTemplate = redisTemplate;
}
</code></pre>
<p>Now I added data in redisServer like this</p>
<pre><code>public void putData(String uniqueKey, String key, Object results) {
redisTemplate.opsForHash().put(uniqueKey, key, results);
}
</code></pre>
<p>Now i want to remove Expire key.</p>
<p>I search in Google, But in google all are saying like this</p>
<pre><code>redisTemplate.expire(key, timeout, TimeUnit);
</code></pre>
<p>In this expire method, We need to provide <code>uniqueKey</code> instead of <code>key</code>.
But I need to Expire <code>key</code> instead of <code>uniqueKey</code>.</p>
<p>So Please help me what can i do for expire <code>Key</code>?</p>
| 0debug |
static int output_frame(H264Context *h, AVFrame *dst, Picture *srcp)
{
AVFrame *src = &srcp->f;
int i;
int ret = av_frame_ref(dst, src);
if (ret < 0)
return ret;
av_dict_set(&dst->metadata, "stereo_mode", ff_h264_sei_stereo_mode(h), 0);
if (!srcp->crop)
return 0;
for (i = 0; i < 3; i++) {
int hshift = (i > 0) ? h->chroma_x_shift : 0;
int vshift = (i > 0) ? h->chroma_y_shift : 0;
int off = ((srcp->crop_left >> hshift) << h->pixel_shift) +
(srcp->crop_top >> vshift) * dst->linesize[i];
dst->data[i] += off;
}
return 0;
}
| 1threat |
Singleton component cannot depend on scoped components : <p>While working on android application using dagger2 for dependency injects while defining dagger component I'm getting this error </p>
<pre><code>Error:(13, 1) error: This @Singleton component cannot depend on scoped components:
@Singleton com.eaxample.app.DaggerAndroid.networkhandler.WebserviceComponent
</code></pre>
<p>My code of component is here :</p>
<pre><code>@Singleton
@Component(modules = {WebserviceModule.class}, dependencies = {ApplicationComponent.class})
public interface WebserviceComponent {
WebserviceHelper providesWebserviceHelper();
}
</code></pre>
<p>Code of componeent in which I;m getting error is :</p>
<pre><code>@Singleton
@Component(modules = {RemoteDataModule.class}, dependencies = {WebserviceComponent.class})
public interface RemoteDataSourceComponent {
RemoteDataSource providesRemoteDataSource();
}
</code></pre>
<p>Why getting this error and how to resolve this.</p>
| 0debug |
Can i store words in file using python like this? : import random, sys
from urllib import urlopen
word_url = "http://scrapmaker.com/data/wordlists/dictionaries/rockyou.txt"
words = []
for word in urlopen(word_url).readlines():
print "Doing it now..."
wordlist = open('wordlist.txt', 'w')
wordlist.write(words)
wordlist.close()
print "File written successfully!" | 0debug |
tkinter interface need helf : i'm developing a graphical interface with tkinter , when i open file and send it , i want to see the scrolling instructions in label (Commande)
To be more precise i do not know how to link this instruction (print ('Sending: ' + l)) with this instruction ( Label(Frame1, text="Commande",background='NavajoWhite2').pack(padx=165, pady=10))
Thanks to all
from tkinter import *
from tkinter import filedialog
from tkinter import ttk,Text
#nom de la fenetre
moha = Tk()
moha.title('Emetteur G-code Universel')
moha.geometry("2500x2500")
moha['bg']= 'NavajoWhite2'
##################
##################
#le chemin de recherche #
def file(tk_event=None, *args, **kw):
fiile= filedialog.askopenfilename(filetypes=[('txt files','.txt'),('all files','.*')])
file_path.set(fiile)
fichier = open(fiile, "r")
print(fiile)
content_bis = fichier.readlines()
for line in content_bis:
T.insert(END, line)
fichier.close()
# Créer les différentes Frame
Outil = LabelFrame(moha, text="Outil")
Outil.place(x=500)
Outil['bg']= 'NavajoWhite2'
label = Label(Outil, text='Fichier : ', background='NavajoWhite2')
label.place(x=10, y=114)
file_path = StringVar()
entry = Entry(Outil, textvariable=file_path)
entry.place(x=60, y=114)
################
def moh():
# Open grbl serial port
s = serial.Serial('/dev/ttyS0',115200)
# Open g-code file
f = open(file_path.get(), "r");
# Wake up grbl
s.write("\r\n\r\n".encode('utf8'))
time.sleep(2) # Wait for grbl to initialize
s.flushInput() # Flush startup text in serial input
# Stream g-code to grbl
for line in f:
l = line.strip() # Strip all EOL characters for consistency
print ('Sending: ' + l)
s.write((l + '\n').encode("utf8")) # Send g-code block to grbl
grbl_out = s.readline().decode("utf8") # Wait for grbl response with carriage return
print (' : ' + grbl_out)
# Wait here until grbl is finished to close serial port and file.
raw_input(" Press <Enter> to exit and disable grbl.")
# Close file and serial port
f.close()
s.close()
#Créer la barre de recherche
#################
o = LabelFrame(moha, text="Fase des commandes")
o.place(y=400)
o['bg']= 'NavajoWhite2'
Label(o, background='NavajoWhite2').pack(padx=670,pady=120)
Frame1 = Frame(o, borderwidth=3, relief=GROOVE, background='NavajoWhite2')
Frame1.place(x=0, y=5)
Label(Frame1, text="Commande",background='NavajoWhite2').pack(padx=165, pady=10)
#################
b1= Button(Outil, text ="Commande", background='White').place(x=10, y=20)
b2= Button(Outil, text ="Fichier", background='White').place(x=110, y=20)
b3= Button(Outil, text ="Côntrole de la machine",
background='White').place(x=190, y=20)
b4= Button(Outil, text ="Selectionner un fichier",background='White',
command=file).place(x=235, y=112)
b5= Button(Outil, text ="Envoyer",background='White', command=moh).place(x=30, y=150)
b6= Button(Outil, text ="Pause",background='White').place(x=110, y=150)
b7= Button(Outil, text ="Annuler",background='White').place(x=180, y=150)
Label(Outil, text="", background='NavajoWhite2').pack(padx=300, pady=150)
################
################
S = Scrollbar(Outil, background='NavajoWhite2')
T = Text(Outil, height=19, width=28)
S.place(x=380, y=10)
T.place(x=400, y=0)
S.config(command=T.yview)
T.config(yscrollcommand=S.set)
| 0debug |
static void eepro100_cu_command(EEPRO100State * s, uint8_t val)
{
eepro100_tx_t tx;
uint32_t cb_address;
switch (val) {
case CU_NOP:
break;
case CU_START:
if (get_cu_state(s) != cu_idle) {
logout("CU state is %u, should be %u\n", get_cu_state(s), cu_idle);
}
set_cu_state(s, cu_active);
s->cu_offset = s->pointer;
next_command:
cb_address = s->cu_base + s->cu_offset;
cpu_physical_memory_read(cb_address, (uint8_t *) & tx, sizeof(tx));
uint16_t status = le16_to_cpu(tx.status);
uint16_t command = le16_to_cpu(tx.command);
logout
("val=0x%02x (cu start), status=0x%04x, command=0x%04x, link=0x%08x\n",
val, status, command, tx.link);
bool bit_el = ((command & 0x8000) != 0);
bool bit_s = ((command & 0x4000) != 0);
bool bit_i = ((command & 0x2000) != 0);
bool bit_nc = ((command & 0x0010) != 0);
bool success = true;
uint16_t cmd = command & 0x0007;
s->cu_offset = le32_to_cpu(tx.link);
switch (cmd) {
case CmdNOp:
break;
case CmdIASetup:
cpu_physical_memory_read(cb_address + 8, &s->macaddr[0], 6);
TRACE(OTHER, logout("macaddr: %s\n", nic_dump(&s->macaddr[0], 6)));
break;
case CmdConfigure:
cpu_physical_memory_read(cb_address + 8, &s->configuration[0],
sizeof(s->configuration));
TRACE(OTHER, logout("configuration: %s\n", nic_dump(&s->configuration[0], 16)));
break;
case CmdMulticastList:
break;
case CmdTx:
(void)0;
uint32_t tbd_array = le32_to_cpu(tx.tx_desc_addr);
uint16_t tcb_bytes = (le16_to_cpu(tx.tcb_bytes) & 0x3fff);
TRACE(RXTX, logout
("transmit, TBD array address 0x%08x, TCB byte count 0x%04x, TBD count %u\n",
tbd_array, tcb_bytes, tx.tbd_count));
if (bit_nc) {
missing("CmdTx: NC = 0");
success = false;
break;
}
if (tcb_bytes > 2600) {
logout("TCB byte count too large, using 2600\n");
tcb_bytes = 2600;
}
if (!((tcb_bytes > 0) || (tbd_array != 0xffffffff))) {
logout
("illegal values of TBD array address and TCB byte count!\n");
}
uint8_t buf[2600];
uint16_t size = 0;
uint32_t tbd_address = cb_address + 0x10;
assert(tcb_bytes <= sizeof(buf));
while (size < tcb_bytes) {
uint32_t tx_buffer_address = ldl_phys(tbd_address);
uint16_t tx_buffer_size = lduw_phys(tbd_address + 4);
tbd_address += 8;
TRACE(RXTX, logout
("TBD (simplified mode): buffer address 0x%08x, size 0x%04x\n",
tx_buffer_address, tx_buffer_size));
tx_buffer_size = MIN(tx_buffer_size, sizeof(buf) - size);
cpu_physical_memory_read(tx_buffer_address, &buf[size],
tx_buffer_size);
size += tx_buffer_size;
}
if (tbd_array == 0xffffffff) {
} else {
uint8_t tbd_count = 0;
if (device_supports_eTxCB(s) && !(s->configuration[6] & BIT(4))) {
for (; tbd_count < 2; tbd_count++) {
uint32_t tx_buffer_address = ldl_phys(tbd_address);
uint16_t tx_buffer_size = lduw_phys(tbd_address + 4);
uint16_t tx_buffer_el = lduw_phys(tbd_address + 6);
tbd_address += 8;
TRACE(RXTX, logout
("TBD (extended flexible mode): buffer address 0x%08x, size 0x%04x\n",
tx_buffer_address, tx_buffer_size));
tx_buffer_size = MIN(tx_buffer_size, sizeof(buf) - size);
cpu_physical_memory_read(tx_buffer_address, &buf[size],
tx_buffer_size);
size += tx_buffer_size;
if (tx_buffer_el & 1) {
break;
}
}
}
tbd_address = tbd_array;
for (; tbd_count < tx.tbd_count; tbd_count++) {
uint32_t tx_buffer_address = ldl_phys(tbd_address);
uint16_t tx_buffer_size = lduw_phys(tbd_address + 4);
uint16_t tx_buffer_el = lduw_phys(tbd_address + 6);
tbd_address += 8;
TRACE(RXTX, logout
("TBD (flexible mode): buffer address 0x%08x, size 0x%04x\n",
tx_buffer_address, tx_buffer_size));
tx_buffer_size = MIN(tx_buffer_size, sizeof(buf) - size);
cpu_physical_memory_read(tx_buffer_address, &buf[size],
tx_buffer_size);
size += tx_buffer_size;
if (tx_buffer_el & 1) {
break;
}
}
}
TRACE(RXTX, logout("%p sending frame, len=%d,%s\n", s, size, nic_dump(buf, size)));
qemu_send_packet(s->vc, buf, size);
s->statistics.tx_good_frames++;
break;
case CmdTDR:
TRACE(OTHER, logout("load microcode\n"));
break;
default:
missing("undefined command");
success = false;
break;
}
stw_phys(cb_address, status | 0x8000 | (success ? 0x2000 : 0));
if (bit_i) {
eepro100_cx_interrupt(s);
}
if (bit_el) {
set_cu_state(s, cu_idle);
eepro100_cna_interrupt(s);
} else if (bit_s) {
set_cu_state(s, cu_suspended);
eepro100_cna_interrupt(s);
} else {
TRACE(OTHER, logout("CU list with at least one more entry\n"));
goto next_command;
}
TRACE(OTHER, logout("CU list empty\n"));
break;
case CU_RESUME:
if (get_cu_state(s) != cu_suspended) {
logout("bad CU resume from CU state %u\n", get_cu_state(s));
set_cu_state(s, cu_suspended);
}
if (get_cu_state(s) == cu_suspended) {
TRACE(OTHER, logout("CU resuming\n"));
set_cu_state(s, cu_active);
goto next_command;
}
break;
case CU_STATSADDR:
s->statsaddr = s->pointer;
TRACE(OTHER, logout("val=0x%02x (status address)\n", val));
break;
case CU_SHOWSTATS:
TRACE(OTHER, logout("val=0x%02x (dump stats)\n", val));
dump_statistics(s);
break;
case CU_CMD_BASE:
TRACE(OTHER, logout("val=0x%02x (CU base address)\n", val));
s->cu_base = s->pointer;
break;
case CU_DUMPSTATS:
TRACE(OTHER, logout("val=0x%02x (dump stats and reset)\n", val));
dump_statistics(s);
memset(&s->statistics, 0, sizeof(s->statistics));
break;
case CU_SRESUME:
missing("CU static resume");
break;
default:
missing("Undefined CU command");
}
}
| 1threat |
Python requests and BeautifulSoup4 .get('href') returning absoulte address : I'm trying to scrape the contents of `<a>` tags from a web page. My code is:
from bs4 import BeautifulSoup
import requests
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
url = 'https://www.safaribooksonline.com/library/view/linux-performance-optimization/9780134985961'
req = requests.get(url)
soup = BeautifulSoup(req.text, 'html.parser')
lessons = soup.find_all('li', class_='toc-level-1')
lesson = lessons[0]
print(lesson)
My page has an element:
<li class="toc-level-1 t-toc-level-1 js-content-uri" data-content-uri="/api/v1/book/9780134985961/chapter/LPOC_00_00_00.html">
<a href="/library/view/linux-performance-optimization/9780134985961/LPOC_00_00_00.html" class="t-chapter" tabindex="39">Introduction</a>
<ol>
<li class="toc-level-2 t-toc-level-2 js-content-uri" data-content-uri="/api/v1/book/9780134985961/chapter/LPOC_00_00_00.html"><a href="/library/view/linux-performance-optimization/9780134985961/LPOC_00_00_00.html" class="t-chapter" tabindex="41">Linux Performance Optimization: Introduction</a></li>
</ol>
</li>
However, when I use requests and the bs4 modules to scrape the data, with the above code, the output I get is:
<li class="toc-level-1 t-toc-level-1">
<a class="t-chapter js-chapter" href="https://www.safaribooksonline.comhttps://www.safaribooksonline.com/library/view/linux-performance-optimization/9780134985961/LPOC_00_00_00.html">Introduction</a>
<ol>
<li class="toc-level-2 t-toc-level-2">
<a class="t-chapter js-chapter" href="https://www.safaribooksonline.com/library/view/linux-performance-optimization/9780134985961/LPOC_00_00_00.html">Linux Performance Optimization: Introduction</a>
</li>
</ol>
</li>
Notice the href values of the `<a>` tags? They're supposed to be relative URLs like: `/library/view/linux-performance-optimization/9780134985961/LPOC_00_00_00.html` but I get absolute ones - and that too wrong sometimes: `https://www.safaribooksonline.comhttps://www.safaribooksonline.com/library/view/linux-performance-optimization/9780134985961/LPOC_00_00_00.html`.
I have no clue how the domain name gets prefixed to the link url, since only the href value is given in the original HTML, unless requests or bs4 is doing this. All my previous scripts that used this same method are also producing a similar error. Did something change on the side of the modules, or am I doing something wrong? | 0debug |
static void coroutine_fn stream_run(void *opaque)
{
StreamBlockJob *s = opaque;
BlockDriverState *bs = s->common.bs;
BlockDriverState *base = s->base;
int64_t sector_num, end;
int error = 0;
int ret = 0;
int n = 0;
void *buf;
s->common.len = bdrv_getlength(bs);
if (s->common.len < 0) {
block_job_completed(&s->common, s->common.len);
return;
}
end = s->common.len >> BDRV_SECTOR_BITS;
buf = qemu_blockalign(bs, STREAM_BUFFER_SIZE);
if (!base) {
bdrv_enable_copy_on_read(bs);
}
for (sector_num = 0; sector_num < end; sector_num += n) {
uint64_t delay_ns = 0;
bool copy;
wait:
block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns);
if (block_job_is_cancelled(&s->common)) {
break;
}
ret = bdrv_is_allocated(bs, sector_num,
STREAM_BUFFER_SIZE / BDRV_SECTOR_SIZE, &n);
if (ret == 1) {
copy = false;
} else if (ret >= 0) {
ret = bdrv_is_allocated_above(bs->backing_hd, base,
sector_num, n, &n);
if (ret == 0 && n == 0) {
n = end - sector_num;
}
copy = (ret == 1);
}
trace_stream_one_iteration(s, sector_num, n, ret);
if (ret >= 0 && copy) {
if (s->common.speed) {
delay_ns = ratelimit_calculate_delay(&s->limit, n);
if (delay_ns > 0) {
goto wait;
}
}
ret = stream_populate(bs, sector_num, n, buf);
}
if (ret < 0) {
BlockErrorAction action =
block_job_error_action(&s->common, s->common.bs, s->on_error,
true, -ret);
if (action == BDRV_ACTION_STOP) {
n = 0;
continue;
}
if (error == 0) {
error = ret;
}
if (action == BDRV_ACTION_REPORT) {
break;
}
}
ret = 0;
s->common.offset += n * BDRV_SECTOR_SIZE;
}
if (!base) {
bdrv_disable_copy_on_read(bs);
}
ret = error;
if (!block_job_is_cancelled(&s->common) && sector_num == end && ret == 0) {
const char *base_id = NULL, *base_fmt = NULL;
if (base) {
base_id = s->backing_file_id;
if (base->drv) {
base_fmt = base->drv->format_name;
}
}
ret = bdrv_change_backing_file(bs, base_id, base_fmt);
close_unused_images(bs, base, base_id);
}
qemu_vfree(buf);
block_job_completed(&s->common, ret);
}
| 1threat |
Cannot load a reference assembly for execution from a Web-Site project : <p>Using .NET 4.6.2 and an older Web-Site (not Web-Application) project. If I clear the BIN directory and then build and run it works, but sometimes after multiple builds and runs, it fails with this error.</p>
<pre><code>Server Error in '/' Application.
Cannot load a reference assembly for execution.
....
[BadImageFormatException: Cannot load a reference assembly for execution.]
[BadImageFormatException: Could not load file or assembly 'netfx.force.conflicts' or
one of its dependencies. Reference assemblies should not be loaded for execution.
They can only be loaded in the Reflection-only loader context.
(Exception from HRESULT: 0x80131058)]
....
</code></pre>
<p>Is there any trick to getting Web-Site projects to work correctly when the libraries they use are beginning to pull in netstandard 2.0?</p>
<p>Also, it seems that this assembly binding redirect is necessary to get it to run but nuget adds a redirect to an older version 4.1.1.0. Any suggestions on how to fix that other than manually editing this line after most nuget updates?</p>
<pre><code> <dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a"
culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
</code></pre>
<p>Would all these issues go away if the project was migrated to a Web-Application project?</p>
| 0debug |
eclipse error cannot make a static reference to a non-static field : <p>import java.util.Scanner;</p>
<p>public class Account {
int number1,number2,sum;</p>
<pre><code>public static void main(String[] args) {
Scanner input = new Scanner (System.in);
System.out.println("Enter your first number");
number1 = input.nextInt();
System.out.println("Enter your Second number");
number2 = input.nextInt();
sum = number1 + number2;
System.out.println("Your Answer is" + sum);
input.close();
}
</code></pre>
<p>}</p>
| 0debug |
static void init_mbr(BDRVVVFATState* s)
{
mbr_t* real_mbr=(mbr_t*)s->first_sectors;
partition_t* partition = &(real_mbr->partition[0]);
int lba;
memset(s->first_sectors,0,512);
real_mbr->nt_id= cpu_to_le32(0xbe1afdfa);
partition->attributes=0x80;
lba = sector2CHS(s->bs, &partition->start_CHS, s->first_sectors_number-1);
lba|= sector2CHS(s->bs, &partition->end_CHS, s->sector_count);
partition->start_sector_long =cpu_to_le32(s->first_sectors_number-1);
partition->length_sector_long=cpu_to_le32(s->sector_count - s->first_sectors_number+1);
partition->fs_type= s->fat_type==12 ? 0x1:
s->fat_type==16 ? (lba?0xe:0x06):
(lba?0xc:0x0b);
real_mbr->magic[0]=0x55; real_mbr->magic[1]=0xaa;
}
| 1threat |
Plugin with id 'androidx.navigation.safeargs' not found : <p>When I try to add Safe Args (Android Navigation) to my app's as following</p>
<p>( using this guide : <a href="https://developer.android.com/topic/libraries/architecture/navigation/navigation-pass-data" rel="noreferrer">https://developer.android.com/topic/libraries/architecture/navigation/navigation-pass-data</a> ) :</p>
<pre><code>apply plugin: 'com.android.application'
apply plugin: 'androidx.navigation.safeargs'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
android {...
</code></pre>
<p>I receive this error :</p>
<blockquote>
<p><strong>Plugin with id 'androidx.navigation.safeargs' not found.</strong></p>
</blockquote>
| 0debug |
static bool gen_check_loop_end(DisasContext *dc, int slot)
{
if (option_enabled(dc, XTENSA_OPTION_LOOP) &&
!(dc->tb->flags & XTENSA_TBFLAG_EXCM) &&
dc->next_pc == dc->lend) {
int label = gen_new_label();
gen_advance_ccount(dc);
tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_SR[LCOUNT], 0, label);
tcg_gen_subi_i32(cpu_SR[LCOUNT], cpu_SR[LCOUNT], 1);
gen_jumpi(dc, dc->lbeg, slot);
gen_set_label(label);
gen_jumpi(dc, dc->next_pc, -1);
return true;
}
return false;
}
| 1threat |
Testing EditText errors with Espresso on Android : <p>I want to test if an EditText field has an error (set with editText.setError("Cannot be blank!")).</p>
<p><a href="https://i.stack.imgur.com/fipqA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fipqA.png" alt="EditText field with error"></a></p>
<p>I've created an Espresso test case with the new AndroidStudio 2.2 feature, to record Espresso tests. So the code is pretty much auto-generated. But for now it only checks if the editText is displayed.</p>
<pre><code>@RunWith(AndroidJUnit4.class)
public class CreateNoteActivityTitleCannotBeBlank {
@Rule
public ActivityTestRule<CreateNoteActivity> mActivityTestRule = new ActivityTestRule<>(CreateNoteActivity.class);
@Test
public void createNoteActivityTitleCannotBeBlank() {
ViewInteraction floatingActionButton = onView(
allOf(withId(R.id.fab_add_note),
withParent(allOf(withId(R.id.activity_create_note),
withParent(withId(android.R.id.content)))),
isDisplayed()));
floatingActionButton.perform(click());
ViewInteraction editText = onView(
allOf(withId(R.id.tiet_note_title),
childAtPosition(
childAtPosition(
withId(R.id.til_title),
0),
0),
isDisplayed()));
editText.check(matches(isDisplayed()));
}
private static Matcher<View> childAtPosition(
final Matcher<View> parentMatcher, final int position) {
return new TypeSafeMatcher<View>() {
@Override
public void describeTo(Description description) {
description.appendText("Child at position " + position + " in parent ");
parentMatcher.describeTo(description);
}
@Override
public boolean matchesSafely(View view) {
ViewParent parent = view.getParent();
return parent instanceof ViewGroup && parentMatcher.matches(parent)
&& view.equals(((ViewGroup) parent).getChildAt(position));
}
};
}
}
</code></pre>
<p>Is there a way to test if the error is displayed?</p>
| 0debug |
can't get a:hover function in css/php to work : for some reason my browser with xampp (PHP) isn't giving a response to the hover command in this piece of code. how can i solve this to get my font to get a little color while hovering over with my mouse?
.headermenu a{
font-size: 18px;
color: #ffffff;
display: inline-block 5px;
background-color: #7f2048;
box-shadow: 0px 0px 50px #888888;
border-radius: 5px;
vertical-align: middle;
padding-bottom: 5px;
padding-top: 5px;
padding-left: 24px;
padding-right: 24px;
margin-bottom: 10px;
text-decoration: none;
font-family:
.headermenu a: hover{
color: #5b5a64;
}
-------------------
im using `<div class"headermenu">` and a end-div to get it to work.
in sublime the text hover from headermenu a:hover{ is white so means not functioning or something i guess.
thnx for helping me out in advise!!! btw im new here.
| 0debug |
static void qemu_remap_bucket(MapCacheEntry *entry,
target_phys_addr_t size,
target_phys_addr_t address_index)
{
uint8_t *vaddr_base;
xen_pfn_t *pfns;
int *err;
unsigned int i, j;
target_phys_addr_t nb_pfn = size >> XC_PAGE_SHIFT;
trace_qemu_remap_bucket(address_index);
pfns = qemu_mallocz(nb_pfn * sizeof (xen_pfn_t));
err = qemu_mallocz(nb_pfn * sizeof (int));
if (entry->vaddr_base != NULL) {
if (munmap(entry->vaddr_base, size) != 0) {
perror("unmap fails");
exit(-1);
}
}
for (i = 0; i < nb_pfn; i++) {
pfns[i] = (address_index << (MCACHE_BUCKET_SHIFT-XC_PAGE_SHIFT)) + i;
}
vaddr_base = xc_map_foreign_bulk(xen_xc, xen_domid, PROT_READ|PROT_WRITE,
pfns, err, nb_pfn);
if (vaddr_base == NULL) {
perror("xc_map_foreign_bulk");
exit(-1);
}
entry->vaddr_base = vaddr_base;
entry->paddr_index = address_index;
for (i = 0; i < nb_pfn; i += BITS_PER_LONG) {
unsigned long word = 0;
if ((i + BITS_PER_LONG) > nb_pfn) {
j = nb_pfn % BITS_PER_LONG;
} else {
j = BITS_PER_LONG;
}
while (j > 0) {
word = (word << 1) | !err[i + --j];
}
entry->valid_mapping[i / BITS_PER_LONG] = word;
}
qemu_free(pfns);
qemu_free(err);
}
| 1threat |
Minimize function with parameters : <p>Currently I have the following code that defines the function <code>f</code>.</p>
<pre><code>a = #something
b = #something
c = #something
def f(x):
"""Evaluates some function that depends on parameters a, b, and c"""
someNumber = #some calculation
return someNumber
</code></pre>
<p>Ideally I would do <code>def f(x, a, b, c)</code>, BUT I am minimizing <code>f</code> with respect to <code>x</code> and SciPy's optimization toolbox doesn't allow for one to minimize functions with parameters in the arguments. That said I would like to run my minimization code for multiple values of <code>a, b</code> and <code>c</code>. Is there a way I can do this?</p>
| 0debug |
static int RENAME(epzs_motion_search2)(MpegEncContext * s,
int *mx_ptr, int *my_ptr,
int P[10][2], int pred_x, int pred_y,
uint8_t *src_data[3],
uint8_t *ref_data[3], int stride, int uvstride, int16_t (*last_mv)[2],
int ref_mv_scale, uint8_t * const mv_penalty)
{
int best[2]={0, 0};
int d, dmin;
const int shift= 1+s->quarter_sample;
uint32_t *map= s->me.map;
int map_generation;
const int penalty_factor= s->me.penalty_factor;
const int size=0;
const int h=8;
const int ref_mv_stride= s->mb_stride;
const int ref_mv_xy= s->mb_x + s->mb_y *ref_mv_stride;
me_cmp_func cmp, chroma_cmp;
LOAD_COMMON
cmp= s->dsp.me_cmp[size];
chroma_cmp= s->dsp.me_cmp[size+1];
map_generation= update_map_generation(s);
dmin = 1000000;
if (s->first_slice_line) {
CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift)
}else{
CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift)
if(dmin>64*2){
CHECK_MV(P_MEDIAN[0]>>shift, P_MEDIAN[1]>>shift)
CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
CHECK_MV(P_TOP[0]>>shift, P_TOP[1]>>shift)
CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift)
CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
}
}
if(dmin>64*4){
CHECK_CLIPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16)
if(s->end_mb_y == s->mb_height || s->mb_y+1<s->end_mb_y)
CHECK_CLIPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
}
if(s->me.dia_size==-1)
dmin= RENAME(funny_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride,
pred_x, pred_y, penalty_factor,
shift, map, map_generation, size, h, mv_penalty);
else if(s->me.dia_size<-1)
dmin= RENAME(sab_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride,
pred_x, pred_y, penalty_factor,
shift, map, map_generation, size, h, mv_penalty);
else if(s->me.dia_size<2)
dmin= RENAME(small_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride,
pred_x, pred_y, penalty_factor,
shift, map, map_generation, size, h, mv_penalty);
else
dmin= RENAME(var_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride,
pred_x, pred_y, penalty_factor,
shift, map, map_generation, size, h, mv_penalty);
*mx_ptr= best[0];
*my_ptr= best[1];
return dmin;
}
| 1threat |
Get current date and time from google in android : I have some experience in Android App development.Now we developed an Android Application where we need date and time from google or internet means exact time. Already I test some code from stack overflow and from some other sites but not work correctly. The App is crashed. And this thing waste my time about one day.
Anyone to help me.
Please. I will wait. | 0debug |
void msix_load(PCIDevice *dev, QEMUFile *f)
{
unsigned n = dev->msix_entries_nr;
unsigned int vector;
if (!(dev->cap_present & QEMU_PCI_CAP_MSIX)) {
return;
}
msix_free_irq_entries(dev);
qemu_get_buffer(f, dev->msix_table_page, n * PCI_MSIX_ENTRY_SIZE);
qemu_get_buffer(f, dev->msix_table_page + MSIX_PAGE_PENDING, (n + 7) / 8);
msix_update_function_masked(dev);
for (vector = 0; vector < n; vector++) {
msix_handle_mask_update(dev, vector, true);
}
}
| 1threat |
'await Unexpected identifier' on Node.js 7.5 : <p>I am experimenting with the <code>await</code> keyword in Node.js. I have this test script:</p>
<pre><code>"use strict";
function x() {
return new Promise(function(resolve, reject) {
setTimeout(function() {
resolve({a:42});
},100);
});
}
await x();
</code></pre>
<p>But when I run it in node I get</p>
<pre><code>await x();
^
SyntaxError: Unexpected identifier
</code></pre>
<p>whether I run it with <code>node</code> or <code>node --harmony-async-await</code> or in the Node.js 'repl' on my Mac with Node.js 7.5 or Node.js 8 (nightly build).</p>
<p>Oddly, the same code works in the Runkit JavaScript notebook environment: <a href="https://runkit.com/glynnbird/58a2eb23aad2bb0014ea614b" rel="noreferrer">https://runkit.com/glynnbird/58a2eb23aad2bb0014ea614b</a></p>
<p>What am I doing wrong?</p>
| 0debug |
Access Form checkbox updates date in another table : I'm trying to make a form checkbox update a the date in another table.
Private Sub Delivered_AfterUpdate()
If Delivered = -1 Then
[tool implentation].[date] = Now()
End Sub
This is code I have but it does not work. Does anyone have a suggestion?
Thanks
| 0debug |
How to create a table corresponding to enum in EF Core Code First? : <p>How would one turn the enums used in an EF Core database context into lookup tables and add the relevant foreign keys?</p>
<hr>
<ul>
<li>Same as <a href="https://stackoverflow.com/q/11167665/10245">EF5 Code First Enums and Lookup Tables</a> but for EF Core instead of EF 6</li>
<li>Related to <a href="https://stackoverflow.com/q/44262314/10245">How can I make EF Core database first use Enums?</a></li>
</ul>
| 0debug |
Making an element in reverse side using css : <p>I want to make an element inside html to be displayed in reverse side or direction including images and text. See the image <img src="https://i.ibb.co/VCZTb4j/Screen-Shot-2019-03-25-at-11-22-37-AM.png" alt="normal"></p>
<p>I expect to have as an example:
<img src="https://i.ibb.co/1qDGNKy/opposite.png" alt="after"></p>
| 0debug |
How to split string and map each character into dictionary : <p>Suppose i have a string like <code>'value=sahi'</code> and i want it like <code>{1:s,2:a,3:h,4:i}</code>
is there any function to do like this.</p>
| 0debug |
How can i make a carousel like this? : How can i make a carousel like this with UICollection view?
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/CY1qZ.png | 0debug |
int qed_check(BDRVQEDState *s, BdrvCheckResult *result, bool fix)
{
QEDCheck check = {
.s = s,
.result = result,
.nclusters = qed_bytes_to_clusters(s, s->file_size),
.request = { .l2_table = NULL },
.fix = fix,
};
int ret;
check.used_clusters = g_try_malloc0(((check.nclusters + 31) / 32) *
sizeof(check.used_clusters[0]));
if (check.nclusters && check.used_clusters == NULL) {
return -ENOMEM;
}
check.result->bfi.total_clusters =
(s->header.image_size + s->header.cluster_size - 1) /
s->header.cluster_size;
ret = qed_check_l1_table(&check, s->l1_table);
if (ret == 0) {
qed_check_for_leaks(&check);
if (fix) {
qed_check_mark_clean(s, result);
}
}
g_free(check.used_clusters);
return ret;
}
| 1threat |
Why is it reading from the file randomly? ( this is in C ) : #include <stdio.h>
void readMatrices(FILE*numbers, int array[4][4], int array2[4][4]) /*this puts the numbers fomr the file into two matrices*/
{
int i,j,num;
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
fscanf(numbers,"%d",&array[i][j]);
}
}
for(i=0;i<=4;i++)
{
for(j=0;j<4;j++)
{
fscanf(numbers,"%d",&array2[i][j]);
}
}
}
void printMatrices(int array[4][4],int array2[4][4]) /* prints out the matrices*/
{
int i,j,num;
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
printf("%d ",array[i][j]);
}
printf("\n");
}
printf("\n");
for(i=0;i<=4;i++)
{
for(j=0;j<4;j++)
{
printf("%d ",array2[i][j]);
}
printf("\n");
}
printf("\n");
}
void multiplyMatrices(int array[4][4],int array2[4][4],int result[4][4]) /*multiplies the matrices*/
{
int i,j;
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
result[i][j] = (array[i][0]*array2[0][j])+(array[i][1]*array2[1][j])+(array[i][2]*array2[2][j])+(array[i][3]*array2[3][j]);
printf("%d ",result[i][j]);
}
printf("\n");
}
printf("\n");
}
int main()
{
int array[4][4],array2[4][4],results[4][4];
FILE*numbers;
numbers = fopen("numbers.txt", "r");
readMatrices(numbers,array,array2);
while(array[0][0]!=0)
{
printMatrices(array,array2);
multiplyMatrices(array,array2,results);
readMatrices(numbers,array,array2);
}
fclose(numbers);
return 0;
}
https://www.dropbox.com/s/gcga78imj6139nz/numbers.txt?dl=0
this is the file^^^
its reading the file but in random groups of fours rather than in order like it should be, this is an issue because its wrong ( lol ) and it also wont read the 0 in the file which causes it to loop infinitely. | 0debug |
the display function in linked list is not working properly : When i call the display function, the first element of linked list is printed twice. I do not know what is wrong with the code. Please help me to figure it out. The code is as follows:
#include <iostream>
using namespace std;
class node{
public:
char data;
node *link;
};
class linklist{
private:
node *start, *temp, *cur;
public:
linklist(){
start = NULL;
}
void insert(char x){
if (start == NULL){
start = new node;
start->data = x;
start->link = NULL;
cur = start;
}
else
while (cur->link != NULL){
cur = cur->link;
}
temp = new node;
temp->data = x;
temp->link = NULL;
cur->link = temp;
}
void display(){
cur = start;
while (cur->link != NULL){
cout << "Value is: " << cur->data << endl;
cur = cur->link;
}
cout << "Value is: " << cur->data << endl;
}
};
int main(){
linklist obj;
obj.insert('e');
obj.insert('t');
obj.insert('r');
obj.insert('w');
obj.insert('l');
obj.display();
system("Pause");
}
the expected output is: etrwl.
Actual output: eetrwl | 0debug |
static void arm_cpu_do_interrupt_aarch32(CPUState *cs)
{
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
uint32_t addr;
uint32_t mask;
int new_mode;
uint32_t offset;
uint32_t moe;
switch (env->exception.syndrome >> ARM_EL_EC_SHIFT) {
case EC_BREAKPOINT:
case EC_BREAKPOINT_SAME_EL:
moe = 1;
break;
case EC_WATCHPOINT:
case EC_WATCHPOINT_SAME_EL:
moe = 10;
break;
case EC_AA32_BKPT:
moe = 3;
break;
case EC_VECTORCATCH:
moe = 5;
break;
default:
moe = 0;
break;
}
if (moe) {
env->cp15.mdscr_el1 = deposit64(env->cp15.mdscr_el1, 2, 4, moe);
}
switch (cs->exception_index) {
case EXCP_UDEF:
new_mode = ARM_CPU_MODE_UND;
addr = 0x04;
mask = CPSR_I;
if (env->thumb)
offset = 2;
else
offset = 4;
break;
case EXCP_SWI:
new_mode = ARM_CPU_MODE_SVC;
addr = 0x08;
mask = CPSR_I;
offset = 0;
break;
case EXCP_BKPT:
env->exception.fsr = 2;
case EXCP_PREFETCH_ABORT:
A32_BANKED_CURRENT_REG_SET(env, ifsr, env->exception.fsr);
A32_BANKED_CURRENT_REG_SET(env, ifar, env->exception.vaddress);
qemu_log_mask(CPU_LOG_INT, "...with IFSR 0x%x IFAR 0x%x\n",
env->exception.fsr, (uint32_t)env->exception.vaddress);
new_mode = ARM_CPU_MODE_ABT;
addr = 0x0c;
mask = CPSR_A | CPSR_I;
offset = 4;
break;
case EXCP_DATA_ABORT:
A32_BANKED_CURRENT_REG_SET(env, dfsr, env->exception.fsr);
A32_BANKED_CURRENT_REG_SET(env, dfar, env->exception.vaddress);
qemu_log_mask(CPU_LOG_INT, "...with DFSR 0x%x DFAR 0x%x\n",
env->exception.fsr,
(uint32_t)env->exception.vaddress);
new_mode = ARM_CPU_MODE_ABT;
addr = 0x10;
mask = CPSR_A | CPSR_I;
offset = 8;
break;
case EXCP_IRQ:
new_mode = ARM_CPU_MODE_IRQ;
addr = 0x18;
mask = CPSR_A | CPSR_I;
offset = 4;
if (env->cp15.scr_el3 & SCR_IRQ) {
new_mode = ARM_CPU_MODE_MON;
mask |= CPSR_F;
}
break;
case EXCP_FIQ:
new_mode = ARM_CPU_MODE_FIQ;
addr = 0x1c;
mask = CPSR_A | CPSR_I | CPSR_F;
if (env->cp15.scr_el3 & SCR_FIQ) {
new_mode = ARM_CPU_MODE_MON;
}
offset = 4;
break;
case EXCP_SMC:
new_mode = ARM_CPU_MODE_MON;
addr = 0x08;
mask = CPSR_A | CPSR_I | CPSR_F;
offset = 0;
break;
default:
cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
return;
}
if (new_mode == ARM_CPU_MODE_MON) {
addr += env->cp15.mvbar;
} else if (A32_BANKED_CURRENT_REG_GET(env, sctlr) & SCTLR_V) {
addr += 0xffff0000;
} else {
addr += A32_BANKED_CURRENT_REG_GET(env, vbar);
}
if ((env->uncached_cpsr & CPSR_M) == ARM_CPU_MODE_MON) {
env->cp15.scr_el3 &= ~SCR_NS;
}
switch_mode (env, new_mode);
env->uncached_cpsr &= ~PSTATE_SS;
env->spsr = cpsr_read(env);
env->condexec_bits = 0;
env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M) | new_mode;
env->uncached_cpsr &= ~CPSR_E;
if (env->cp15.sctlr_el[arm_current_el(env)] & SCTLR_EE) {
env->uncached_cpsr |= ~CPSR_E;
}
env->daif |= mask;
if (arm_feature(env, ARM_FEATURE_V4T)) {
env->thumb = (A32_BANKED_CURRENT_REG_GET(env, sctlr) & SCTLR_TE) != 0;
}
env->regs[14] = env->regs[15] + offset;
env->regs[15] = addr;
}
| 1threat |
how to login to instagram on dev computer : <p>I am trying to create a wordpress plugin that will display images from my company's instagram account. My dev computer is on my desktop computer behind the company's firewall. My understanding (which could be wrong) is that the page will have to go to the instagram site to get an access token, and then the token is returned to a specified redirect url. Is there any way I can get access to this while behind the firewall on my local desktop (that obviously has no direct connection to the outside)? </p>
| 0debug |
Why an application starts with FPU Control Word different than Default8087CW? : <p>Could you please help me to understand what is going on with FPU Control Word in my Delphi application, on Win32 platform.</p>
<p>When we create a new VCL application, the control word is set up to 1372h. This is the first thing I don't understand, why it is 1372h instead of 1332h which is the <code>Default8087CW</code> defined in <code>System</code> unit.</p>
<p>The difference between these two:</p>
<pre><code>1001101110010 //1372h
1001100110010 //1332h
</code></pre>
<p>is the 6th bit which according to documentation is reserved or not used.</p>
<p>The second question regards <code>CreateOleObject</code>.</p>
<pre><code>function CreateOleObject(const ClassName: string): IDispatch;
var
ClassID: TCLSID;
begin
try
ClassID := ProgIDToClassID(ClassName);
{$IFDEF CPUX86}
try
Set8087CW( Default8087CW or $08);
{$ENDIF CPUX86}
OleCheck(CoCreateInstance(ClassID, nil, CLSCTX_INPROC_SERVER or
CLSCTX_LOCAL_SERVER, IDispatch, Result));
{$IFDEF CPUX86}
finally
Reset8087CW;
end;
{$ENDIF CPUX86}
except
on E: EOleSysError do
raise EOleSysError.Create(Format('%s, ProgID: "%s"',[E.Message, ClassName]),E.ErrorCode,0) { Do not localize }
end;
end;
</code></pre>
<p>The above function is changing control word to <code>137Ah</code>, so it is turning on the 3rd bit (Overflow Mask). I don't understand why it is calling <code>Reset8087CW</code> after, instead of restoring the state of the word which was before entering into the function? </p>
| 0debug |
Javascript/java is changing my leading spaces to questiom marks : I am using this inside of a minecraft mod to read and write file and all the leading space are being converted to ? in the file.
**file input sample:**
{
"ReturnToStart": "1b",
**file out put sample:**
{
???"ReturnToStart": "1b",
<!-- begin snippet: js hide: false console: true -->
<!-- language: lang-js -->
//xxxxxxxxxxxxxxxxxxxxxxx
var ips = new java.io.FileInputStream("ABC.json");
var fileReader = new java.io.InputStreamReader(ips,"UTF-8");
var data1 = fileReader.read();
var data;
var start1 = "";
while(data1 != -1) {
data = String.fromCharCode(data1);
start1 = start1+data;
data1 = fileReader.read();
}
fileReader.close();
var fileWriter = new java.io.FileWriter("J_out2.txt");
fileWriter.write(start1);
fileWriter.close();
<!-- end snippet -->
| 0debug |
static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
{
int i, j, k, cbp, val, mb_type, motion_type;
const int mb_block_count = 4 + (1 << s->chroma_format);
int ret;
ff_tlog(s->avctx, "decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y);
av_assert2(s->mb_skipped == 0);
if (s->mb_skip_run-- != 0) {
if (s->pict_type == AV_PICTURE_TYPE_P) {
s->mb_skipped = 1;
s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride] =
MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
} else {
int mb_type;
if (s->mb_x)
mb_type = s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride - 1];
else
mb_type = s->current_picture.mb_type[s->mb_width + (s->mb_y - 1) * s->mb_stride - 1];
if (IS_INTRA(mb_type)) {
av_log(s->avctx, AV_LOG_ERROR, "skip with previntra\n");
return AVERROR_INVALIDDATA;
}
s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride] =
mb_type | MB_TYPE_SKIP;
if ((s->mv[0][0][0] | s->mv[0][0][1] | s->mv[1][0][0] | s->mv[1][0][1]) == 0)
s->mb_skipped = 1;
}
return 0;
}
switch (s->pict_type) {
default:
case AV_PICTURE_TYPE_I:
if (get_bits1(&s->gb) == 0) {
if (get_bits1(&s->gb) == 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid mb type in I-frame at %d %d\n",
s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
mb_type = MB_TYPE_QUANT | MB_TYPE_INTRA;
} else {
mb_type = MB_TYPE_INTRA;
}
break;
case AV_PICTURE_TYPE_P:
mb_type = get_vlc2(&s->gb, ff_mb_ptype_vlc.table, MB_PTYPE_VLC_BITS, 1);
if (mb_type < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid mb type in P-frame at %d %d\n", s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
mb_type = ptype2mb_type[mb_type];
break;
case AV_PICTURE_TYPE_B:
mb_type = get_vlc2(&s->gb, ff_mb_btype_vlc.table, MB_BTYPE_VLC_BITS, 1);
if (mb_type < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid mb type in B-frame at %d %d\n", s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
mb_type = btype2mb_type[mb_type];
break;
}
ff_tlog(s->avctx, "mb_type=%x\n", mb_type);
if (IS_INTRA(mb_type)) {
s->bdsp.clear_blocks(s->block[0]);
if (!s->chroma_y_shift)
s->bdsp.clear_blocks(s->block[6]);
if (s->picture_structure == PICT_FRAME &&
!s->frame_pred_frame_dct)
s->interlaced_dct = get_bits1(&s->gb);
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
if (s->concealment_motion_vectors) {
if (s->picture_structure != PICT_FRAME)
skip_bits1(&s->gb);
s->mv[0][0][0] =
s->last_mv[0][0][0] =
s->last_mv[0][1][0] = mpeg_decode_motion(s, s->mpeg_f_code[0][0],
s->last_mv[0][0][0]);
s->mv[0][0][1] =
s->last_mv[0][0][1] =
s->last_mv[0][1][1] = mpeg_decode_motion(s, s->mpeg_f_code[0][1],
s->last_mv[0][0][1]);
check_marker(s->avctx, &s->gb, "after concealment_motion_vectors");
} else {
memset(s->last_mv, 0, sizeof(s->last_mv));
}
s->mb_intra = 1;
if ((CONFIG_MPEG1_XVMC_HWACCEL || CONFIG_MPEG2_XVMC_HWACCEL) && s->pack_pblocks)
ff_xvmc_pack_pblocks(s, -1);
if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
if (s->avctx->flags2 & AV_CODEC_FLAG2_FAST) {
for (i = 0; i < 6; i++)
mpeg2_fast_decode_block_intra(s, *s->pblocks[i], i);
} else {
for (i = 0; i < mb_block_count; i++)
if ((ret = mpeg2_decode_block_intra(s, *s->pblocks[i], i)) < 0)
return ret;
}
} else {
for (i = 0; i < 6; i++) {
ret = ff_mpeg1_decode_block_intra(&s->gb,
s->intra_matrix,
s->intra_scantable.permutated,
s->last_dc, *s->pblocks[i],
i, s->qscale);
if (ret < 0) {
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n",
s->mb_x, s->mb_y);
return ret;
}
s->block_last_index[i] = ret;
}
}
} else {
if (mb_type & MB_TYPE_ZERO_MV) {
av_assert2(mb_type & MB_TYPE_CBP);
s->mv_dir = MV_DIR_FORWARD;
if (s->picture_structure == PICT_FRAME) {
if (s->picture_structure == PICT_FRAME
&& !s->frame_pred_frame_dct)
s->interlaced_dct = get_bits1(&s->gb);
s->mv_type = MV_TYPE_16X16;
} else {
s->mv_type = MV_TYPE_FIELD;
mb_type |= MB_TYPE_INTERLACED;
s->field_select[0][0] = s->picture_structure - 1;
}
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
s->last_mv[0][0][0] = 0;
s->last_mv[0][0][1] = 0;
s->last_mv[0][1][0] = 0;
s->last_mv[0][1][1] = 0;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
} else {
av_assert2(mb_type & MB_TYPE_L0L1);
if (s->picture_structure == PICT_FRAME && s->frame_pred_frame_dct) {
motion_type = MT_FRAME;
} else {
motion_type = get_bits(&s->gb, 2);
if (s->picture_structure == PICT_FRAME && HAS_CBP(mb_type))
s->interlaced_dct = get_bits1(&s->gb);
}
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
s->mv_dir = (mb_type >> 13) & 3;
ff_tlog(s->avctx, "motion_type=%d\n", motion_type);
switch (motion_type) {
case MT_FRAME:
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x16;
s->mv_type = MV_TYPE_16X16;
for (i = 0; i < 2; i++) {
if (USES_LIST(mb_type, i)) {
s->mv[i][0][0] =
s->last_mv[i][0][0] =
s->last_mv[i][1][0] =
mpeg_decode_motion(s, s->mpeg_f_code[i][0],
s->last_mv[i][0][0]);
s->mv[i][0][1] =
s->last_mv[i][0][1] =
s->last_mv[i][1][1] =
mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][0][1]);
if (s->full_pel[i]) {
s->mv[i][0][0] *= 2;
s->mv[i][0][1] *= 2;
}
}
}
} else {
mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
s->mv_type = MV_TYPE_16X8;
for (i = 0; i < 2; i++) {
if (USES_LIST(mb_type, i)) {
for (j = 0; j < 2; j++) {
s->field_select[i][j] = get_bits1(&s->gb);
for (k = 0; k < 2; k++) {
val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
s->last_mv[i][j][k]);
s->last_mv[i][j][k] = val;
s->mv[i][j][k] = val;
}
}
}
}
}
break;
case MT_FIELD:
s->mv_type = MV_TYPE_FIELD;
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
for (i = 0; i < 2; i++) {
if (USES_LIST(mb_type, i)) {
for (j = 0; j < 2; j++) {
s->field_select[i][j] = get_bits1(&s->gb);
val = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
s->last_mv[i][j][0]);
s->last_mv[i][j][0] = val;
s->mv[i][j][0] = val;
ff_tlog(s->avctx, "fmx=%d\n", val);
val = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][j][1] >> 1);
s->last_mv[i][j][1] = 2 * val;
s->mv[i][j][1] = val;
ff_tlog(s->avctx, "fmy=%d\n", val);
}
}
}
} else {
av_assert0(!s->progressive_sequence);
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
for (i = 0; i < 2; i++) {
if (USES_LIST(mb_type, i)) {
s->field_select[i][0] = get_bits1(&s->gb);
for (k = 0; k < 2; k++) {
val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
s->last_mv[i][0][k]);
s->last_mv[i][0][k] = val;
s->last_mv[i][1][k] = val;
s->mv[i][0][k] = val;
}
}
}
}
break;
case MT_DMV:
if (s->progressive_sequence){
av_log(s->avctx, AV_LOG_ERROR, "MT_DMV in progressive_sequence\n");
return AVERROR_INVALIDDATA;
}
s->mv_type = MV_TYPE_DMV;
for (i = 0; i < 2; i++) {
if (USES_LIST(mb_type, i)) {
int dmx, dmy, mx, my, m;
const int my_shift = s->picture_structure == PICT_FRAME;
mx = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
s->last_mv[i][0][0]);
s->last_mv[i][0][0] = mx;
s->last_mv[i][1][0] = mx;
dmx = get_dmv(s);
my = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][0][1] >> my_shift);
dmy = get_dmv(s);
s->last_mv[i][0][1] = my * (1 << my_shift);
s->last_mv[i][1][1] = my * (1 << my_shift);
s->mv[i][0][0] = mx;
s->mv[i][0][1] = my;
s->mv[i][1][0] = mx;
s->mv[i][1][1] = my;
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
m = s->top_field_first ? 1 : 3;
s->mv[i][2][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
s->mv[i][2][1] = ((my * m + (my > 0)) >> 1) + dmy - 1;
m = 4 - m;
s->mv[i][3][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
s->mv[i][3][1] = ((my * m + (my > 0)) >> 1) + dmy + 1;
} else {
mb_type |= MB_TYPE_16x16;
s->mv[i][2][0] = ((mx + (mx > 0)) >> 1) + dmx;
s->mv[i][2][1] = ((my + (my > 0)) >> 1) + dmy;
if (s->picture_structure == PICT_TOP_FIELD)
s->mv[i][2][1]--;
else
s->mv[i][2][1]++;
}
}
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR,
"00 motion_type at %d %d\n", s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
}
s->mb_intra = 0;
if (HAS_CBP(mb_type)) {
s->bdsp.clear_blocks(s->block[0]);
cbp = get_vlc2(&s->gb, ff_mb_pat_vlc.table, MB_PAT_VLC_BITS, 1);
if (mb_block_count > 6) {
cbp <<= mb_block_count - 6;
cbp |= get_bits(&s->gb, mb_block_count - 6);
s->bdsp.clear_blocks(s->block[6]);
}
if (cbp <= 0) {
av_log(s->avctx, AV_LOG_ERROR,
"invalid cbp %d at %d %d\n", cbp, s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
if ((CONFIG_MPEG1_XVMC_HWACCEL || CONFIG_MPEG2_XVMC_HWACCEL) && s->pack_pblocks)
ff_xvmc_pack_pblocks(s, cbp);
if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
if (s->avctx->flags2 & AV_CODEC_FLAG2_FAST) {
for (i = 0; i < 6; i++) {
if (cbp & 32)
mpeg2_fast_decode_block_non_intra(s, *s->pblocks[i], i);
else
s->block_last_index[i] = -1;
cbp += cbp;
}
} else {
cbp <<= 12 - mb_block_count;
for (i = 0; i < mb_block_count; i++) {
if (cbp & (1 << 11)) {
if ((ret = mpeg2_decode_block_non_intra(s, *s->pblocks[i], i)) < 0)
return ret;
} else {
s->block_last_index[i] = -1;
}
cbp += cbp;
}
}
} else {
if (s->avctx->flags2 & AV_CODEC_FLAG2_FAST) {
for (i = 0; i < 6; i++) {
if (cbp & 32)
mpeg1_fast_decode_block_inter(s, *s->pblocks[i], i);
else
s->block_last_index[i] = -1;
cbp += cbp;
}
} else {
for (i = 0; i < 6; i++) {
if (cbp & 32) {
if ((ret = mpeg1_decode_block_inter(s, *s->pblocks[i], i)) < 0)
return ret;
} else {
s->block_last_index[i] = -1;
}
cbp += cbp;
}
}
}
} else {
for (i = 0; i < 12; i++)
s->block_last_index[i] = -1;
}
}
s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride] = mb_type;
return 0;
}
| 1threat |
static void send_qmp_error_event(BlockDriverState *bs,
BlockErrorAction action,
bool is_read, int error)
{
IoOperationType optype;
optype = is_read ? IO_OPERATION_TYPE_READ : IO_OPERATION_TYPE_WRITE;
qapi_event_send_block_io_error(bdrv_get_device_name(bs), optype, action,
bdrv_iostatus_is_enabled(bs),
error == ENOSPC, strerror(error),
&error_abort);
}
| 1threat |
I am not able to click on filter on grid in selenium : I am giving the code below where i need to click on the filter icon. please help me out
<thead class="k-grid-header" role="rowgroup">
<tr role="row">
<th class="k-header k-filterable k-with-icon" scope="col" data-title="User Name" data-index="0" data-field="UserName" data-role="columnsorter">
<a class="k-grid-filter" href="javascript:void(0)" tabindex="-1">
<span class="k-icon k-filter"/>
</a>
<a class="k-link" href="/Admin/AdminRoleGrid/Read?adminGrid-sort=UserName-asc">User Name</a>
</th> | 0debug |
static void virtio_serial_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->init = virtio_serial_init_pci;
k->exit = virtio_serial_exit_pci;
k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
k->device_id = PCI_DEVICE_ID_VIRTIO_CONSOLE;
k->revision = VIRTIO_PCI_ABI_VERSION;
k->class_id = PCI_CLASS_COMMUNICATION_OTHER;
dc->alias = "virtio-serial";
dc->reset = virtio_pci_reset;
dc->props = virtio_serial_properties;
}
| 1threat |
int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
int ts_start, int duration, int raw)
{
AVBPrint buf;
int ret, dlen;
AVSubtitleRect **rects;
av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
if ((ret = ff_ass_bprint_dialog(&buf, dialog, ts_start, duration, raw)) < 0)
goto err;
dlen = ret;
if (!av_bprint_is_complete(&buf))
rects = av_realloc_array(sub->rects, (sub->num_rects+1), sizeof(*sub->rects));
if (!rects)
sub->rects = rects;
sub->end_display_time = FFMAX(sub->end_display_time, 10 * duration);
rects[sub->num_rects] = av_mallocz(sizeof(*rects[0]));
rects[sub->num_rects]->type = SUBTITLE_ASS;
ret = av_bprint_finalize(&buf, &rects[sub->num_rects]->ass);
if (ret < 0)
goto err;
sub->num_rects++;
return dlen;
errnomem:
ret = AVERROR(ENOMEM);
err:
av_bprint_finalize(&buf, NULL);
return ret;
} | 1threat |
Is i=++i; undefined behavior? : <p>This is undefined behavior, right? Double assignment in the same sequence point?</p>
<pre><code>int i = 0;
i = ++i;
</code></pre>
| 0debug |
static int get_codec_data(AVIOContext *pb, AVStream *vst,
AVStream *ast, int myth)
{
nuv_frametype frametype;
if (!vst && !myth)
return 1;
while (!avio_feof(pb)) {
int size, subtype;
frametype = avio_r8(pb);
switch (frametype) {
case NUV_EXTRADATA:
subtype = avio_r8(pb);
avio_skip(pb, 6);
size = PKTSIZE(avio_rl32(pb));
if (vst && subtype == 'R') {
if (vst->codecpar->extradata) {
av_freep(&vst->codecpar->extradata);
vst->codecpar->extradata_size = 0;
}
if (ff_get_extradata(NULL, vst->codecpar, pb, size) < 0)
return AVERROR(ENOMEM);
size = 0;
if (!myth)
return 0;
}
break;
case NUV_MYTHEXT:
avio_skip(pb, 7);
size = PKTSIZE(avio_rl32(pb));
if (size != 128 * 4)
break;
avio_rl32(pb);
if (vst) {
vst->codecpar->codec_tag = avio_rl32(pb);
vst->codecpar->codec_id =
ff_codec_get_id(ff_codec_bmp_tags, vst->codecpar->codec_tag);
if (vst->codecpar->codec_tag == MKTAG('R', 'J', 'P', 'G'))
vst->codecpar->codec_id = AV_CODEC_ID_NUV;
} else
avio_skip(pb, 4);
if (ast) {
int id;
ast->codecpar->codec_tag = avio_rl32(pb);
ast->codecpar->sample_rate = avio_rl32(pb);
ast->codecpar->bits_per_coded_sample = avio_rl32(pb);
ast->codecpar->channels = avio_rl32(pb);
ast->codecpar->channel_layout = 0;
id = ff_wav_codec_get_id(ast->codecpar->codec_tag,
ast->codecpar->bits_per_coded_sample);
if (id == AV_CODEC_ID_NONE) {
id = ff_codec_get_id(nuv_audio_tags, ast->codecpar->codec_tag);
if (id == AV_CODEC_ID_PCM_S16LE)
id = ff_get_pcm_codec_id(ast->codecpar->bits_per_coded_sample,
0, 0, ~1);
}
ast->codecpar->codec_id = id;
ast->need_parsing = AVSTREAM_PARSE_FULL;
} else
avio_skip(pb, 4 * 4);
size -= 6 * 4;
avio_skip(pb, size);
return 0;
case NUV_SEEKP:
size = 11;
break;
default:
avio_skip(pb, 7);
size = PKTSIZE(avio_rl32(pb));
break;
}
avio_skip(pb, size);
}
return 0;
}
| 1threat |
How to send push notifications to google firebase web application : Can anybody provide information on how to setup push notifications for a chrome web application?
How to setup topics, create new topics, delete topics and what the syntax would be.
I searched the internet using what tools we have and come up with nothing.
Thankyou. | 0debug |
void bdrv_io_unplugged_begin(BlockDriverState *bs)
{
BdrvChild *child;
if (bs->io_plug_disabled++ == 0 && bs->io_plugged > 0) {
BlockDriver *drv = bs->drv;
if (drv && drv->bdrv_io_unplug) {
drv->bdrv_io_unplug(bs);
}
}
QLIST_FOREACH(child, &bs->children, next) {
bdrv_io_unplugged_begin(child->bs);
}
}
| 1threat |
How to replace volumes_from in docker-composer v3 : <p>I want to know the equivalent of the configuration below to suit version 3 of docker-composer.yml! volumes_from is no longer valid so am I supposed to skip the data volume and replace it with top level volumes ?</p>
<pre><code>version: '2'
services:
php:
build: ./docker-files/php-fpm/.
volumes_from:
- data
working_dir: /code
links:
- mysql
nginx:
image: nginx:latest
ports:
- "80:80"
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
volumes_from:
- data
links:
- php
data:
image: tianon/true
volumes:
- .:/code
</code></pre>
| 0debug |
static void iscsi_close(BlockDriverState *bs)
{
IscsiLun *iscsilun = bs->opaque;
struct iscsi_context *iscsi = iscsilun->iscsi;
iscsi_detach_aio_context(bs);
if (iscsi_is_logged_in(iscsi)) {
iscsi_logout_sync(iscsi);
}
iscsi_destroy_context(iscsi);
g_free(iscsilun->zeroblock);
g_free(iscsilun->allocationmap);
memset(iscsilun, 0, sizeof(IscsiLun));
}
| 1threat |
static int vnc_update_client(VncState *vs, int has_dirty)
{
if (vs->need_update && vs->csock != -1) {
VncDisplay *vd = vs->vd;
int y;
int n_rectangles;
int saved_offset;
int n;
if (vs->output.offset && !vs->audio_cap && !vs->force_update)
return 0;
if (!has_dirty && !vs->audio_cap && !vs->force_update)
return 0;
n_rectangles = 0;
vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
vnc_write_u8(vs, 0);
saved_offset = vs->output.offset;
vnc_write_u16(vs, 0);
for (y = 0; y < vd->server->height; y++) {
int x;
int last_x = -1;
for (x = 0; x < vd->server->width / 16; x++) {
if (vnc_get_bit(vs->dirty[y], x)) {
if (last_x == -1) {
last_x = x;
}
vnc_clear_bit(vs->dirty[y], x);
} else {
if (last_x != -1) {
int h = find_and_clear_dirty_height(vs, y, last_x, x);
n = send_framebuffer_update(vs, last_x * 16, y,
(x - last_x) * 16, h);
n_rectangles += n;
}
last_x = -1;
}
}
if (last_x != -1) {
int h = find_and_clear_dirty_height(vs, y, last_x, x);
n = send_framebuffer_update(vs, last_x * 16, y,
(x - last_x) * 16, h);
n_rectangles += n;
}
}
vs->output.buffer[saved_offset] = (n_rectangles >> 8) & 0xFF;
vs->output.buffer[saved_offset + 1] = n_rectangles & 0xFF;
vnc_flush(vs);
vs->force_update = 0;
return n_rectangles;
}
if (vs->csock == -1)
vnc_disconnect_finish(vs);
return 0;
}
| 1threat |
void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top)
{
assert(!bdrv_requests_pending(bs_top));
assert(!bdrv_requests_pending(bs_new));
bdrv_ref(bs_top);
change_parent_backing_link(bs_top, bs_new);
bdrv_set_backing_hd(bs_new, bs_top);
bdrv_unref(bs_top);
bdrv_unref(bs_new);
}
| 1threat |
static int ogg_read_packet(AVFormatContext *s, AVPacket *pkt)
{
struct ogg *ogg;
struct ogg_stream *os;
int idx, ret;
int pstart, psize;
int64_t fpos, pts, dts;
if (s->io_repositioned) {
ogg_reset(s);
s->io_repositioned = 0;
retry:
do {
ret = ogg_packet(s, &idx, &pstart, &psize, &fpos);
if (ret < 0)
return ret;
} while (idx < 0 || !s->streams[idx]);
ogg = s->priv_data;
os = ogg->streams + idx;
pts = ogg_calc_pts(s, idx, &dts);
ogg_validate_keyframe(s, idx, pstart, psize);
if (os->keyframe_seek && !(os->pflags & AV_PKT_FLAG_KEY))
goto retry;
os->keyframe_seek = 0;
ret = av_new_packet(pkt, psize);
if (ret < 0)
return ret;
pkt->stream_index = idx;
memcpy(pkt->data, os->buf + pstart, psize);
pkt->pts = pts;
pkt->dts = dts;
pkt->flags = os->pflags;
pkt->duration = os->pduration;
pkt->pos = fpos;
if (os->end_trimming) {
uint8_t *side_data = av_packet_new_side_data(pkt,
AV_PKT_DATA_SKIP_SAMPLES,
10);
AV_WL32(side_data + 4, os->end_trimming);
os->end_trimming = 0;
if (os->new_metadata) {
uint8_t *side_data = av_packet_new_side_data(pkt,
AV_PKT_DATA_METADATA_UPDATE,
os->new_metadata_size);
memcpy(side_data, os->new_metadata, os->new_metadata_size);
av_freep(&os->new_metadata);
os->new_metadata_size = 0;
return psize;
| 1threat |
React Props is Not Defined : <p>I'm having trouble understanding why my props.updateBuilding is not working. </p>
<p>The following works when the prop is within the render method </p>
<pre><code>class Buildings extends Component {
constructor(props) {
super(props);
}
componentWillMount() {
this.props.fetchBuildings();
}
renderBuildings(building) {
return (
<div>
<p> {building.name}</p>
</div>
);
}
render() {
return (
<div>
{this.props.buildings.map(this.renderBuildings)}
<button type="button" className="btn btn-success" onClick={this.props.updateBuilding.bind(this, 1)}>Edit</button>
</div>
);
}
}
function mapStateToProps(state) {
return { buildings: state.buildings.all };
}
function mapDispatchToProps(dispatch){
return bindActionCreators({ fetchBuildings, updateBuilding}, dispatch);
}
</code></pre>
<p>But when I put <code>this.props.updateBuilding</code> to the renderBuildings method like below... </p>
<pre><code> renderBuildings(building) {
return (
<div>
<p> {building.name}</p>
<button type="button" className="btn btn-success" onClick={this.props.updateBuilding.bind(this, building.id)}>Edit</button>
</div>
);
}
</code></pre>
<p>I get the error: </p>
<pre><code>Cannot read property 'props' of undefined
</code></pre>
<p>It seems that the prop <code>updateBuildings</code> cannot be read when it is inside the renderBuildings method and I'm not sure what is causing this. </p>
| 0debug |
html select option display value with empty color div and display value : i need the html select option dispaly value with empty color div and display value.
how do we do that with html,js or jquery?
i attached png value i need like that.
Thanks.[this is what i need]
[1]: https://i.stack.imgur.com/OysaJ.png | 0debug |
Xpath: select div with grandchildren containing text : <p>How do you write the xpath to select the div with class tableRow that contains a nested div with the title <code>apple</code> as well as a nested span with the text <code>3.14</code>?</p>
<pre><code><div class='tableRow'>
<div class='tableCell'>
<div class='container' title='apple'></div>
</div>
<div class='tableCell'>
<span class='showSpan'>3.14</span>
</div>
</div>
</code></pre>
| 0debug |
Failure [INSTALL_CANCELED_BY_USER] on Xiaomi device : <p>I bought a Xiaomi Redmi 4x yesterday and I can't debug my apps in this device.</p>
<p>I already enabled the Developer Options in the device, switch on to USB Debugging, install the USB Drivers and accepted the RSA debugging fingerprint pop that appears when I plug it on USB port for the first time.</p>
<p>So, I select the "Xiaomi Redmi 4X (Android 6.0 - API 23)" in devices list of Visual Studio, click in Run (or deploy) and see this error:</p>
<pre><code>>Detecting installed packages...
>Removing old runtime: Mono.Android.DebugRuntime...
>Target device is arm64-v8a.
>Installing the Mono shared runtime (debug - 1505313604)...
>10% ... 3520kb of 35035kb copied
>20% ... 7040kb of 35035kb copied
>30% ... 10560kb of 35035kb copied
>40% ... 14016kb of 35035kb copied
>50% ... 17536kb of 35035kb copied
>60% ... 21056kb of 35035kb copied
>70% ... 24576kb of 35035kb copied
>80% ... 28032kb of 35035kb copied
>90% ... 31552kb of 35035kb copied
>100% ... 35035kb of 35035kb copied
> Deployment failed
>Mono.AndroidTools.InstallFailedException: Unexpected install output: pkg: /data/local/tmp/Mono.Android.DebugRuntime-debug.apk
>Failure [INSTALL_CANCELED_BY_USER]
>
> at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName)
> at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass94_0.<InstallPackage>b__0(Task`1 t)
> at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
> at System.Threading.Tasks.Task.Execute()
>Unexpected install output: pkg: /data/local/tmp/Mono.Android.DebugRuntime-debug.apk
>Failure [INSTALL_CANCELED_BY_USER]
>
>Creating "obj\Debug\upload.flag" because "AlwaysCreate" was specified.
>Creating directory "obj\.cache\".
>Done building project "MyTestApp.csproj".
>Build succeeded.
>An error occured. See full exception on logs for more details.
>Unexpected install output: pkg: /data/local/tmp/Mono.Android.DebugRuntime-debug.apk
>Failure [INSTALL_CANCELED_BY_USER]
>
>
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========
</code></pre>
<p>This occurs with all my apps and just in this Xiaomi device. In other brand devices and emulators, the debug works normally.</p>
<p>Just to complement, I have this problem <a href="http://en.miui.com/thread-544718-1-1.html" rel="noreferrer">http://en.miui.com/thread-544718-1-1.html</a> and even following the instructions, I can't make the "Install via USB" works.</p>
<p>There is any solution to debug in this device?</p>
| 0debug |
static int mace3_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
const uint8_t *buf, int buf_size)
{
int16_t *samples = data;
MACEContext *ctx = avctx->priv_data;
int i, j, k;
for(i = 0; i < avctx->channels; i++) {
int16_t *output = samples + i;
for (j=0; j < buf_size / 2 / avctx->channels; j++)
for (k=0; k < 2; k++) {
uint8_t pkt = buf[i*2 + j*2*avctx->channels + k];
chomp3(&ctx->chd[i], output, pkt &7, MACEtab1, MACEtab2,
8, avctx->channels);
output += avctx->channels;
chomp3(&ctx->chd[i], output,(pkt >> 3) &3, MACEtab3, MACEtab4,
4, avctx->channels);
output += avctx->channels;
chomp3(&ctx->chd[i], output, pkt >> 5 , MACEtab1, MACEtab2,
8, avctx->channels);
output += avctx->channels;
}
}
*data_size = 2 * 3 * buf_size;
return buf_size;
}
| 1threat |
static QOSState *pci_test_start(int socket)
{
const char *cmd = "-netdev socket,fd=%d,id=hs0 -device "
"virtio-net-pci,netdev=hs0";
return qtest_pc_boot(cmd, socket);
}
| 1threat |
static void gen_check_sr(DisasContext *dc, uint32_t sr)
{
if (!xtensa_option_bits_enabled(dc->config, sregnames[sr].opt_bits)) {
if (sregnames[sr].name) {
qemu_log("SR %s is not configured\n", sregnames[sr].name);
} else {
qemu_log("SR %d is not implemented\n", sr);
}
gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
}
}
| 1threat |
Click the button and it sends that info into another box on the page : <p>I want to be able to click on a button then that puts that information into another part on the page (in a box). However, I want the ability to remove this from that box too. </p>
<p>What is the best way to do this using html and javascript?</p>
<p>thanks</p>
| 0debug |
SQL Server where clause with two date : I use this query in my app
**"SELECT * FROM Vi_WebReport WHERE Legajo=? AND ent>=? AND ent>=?"**
So, legajo its a number thats identify one person. And ent its a date. The query works ok, but when i want to select only one day like:
**SELECT * FROM Vi_WebReport WHERE Legajo=1 AND ent>=02/02/2017 AND ent>=02/02/2017**
The query show empty table.
Thanks! | 0debug |
Appium IOS Get All Device ID that connrct to MAC : need help
How do i call in my framework (In java) to “instruments -s devices” to Get all
Device UDID that connect to the MAC and parse the result (UDID) to Array list ?
Thanks ! | 0debug |
For create this kind of product image functionality what i should use please : Here is aliexpress single product page. I want this kind of product page.
actually the question is how i can create this kind of image fature.
Like :
When i hover a small image it load big image in same div.
It only load when i hover or click otherwise it don't so it decrease page load time.
If you have any advise or any javascript plugin, or anything that can help me please help.
thanks to all :)
https://www.aliexpress.com/item/Justin-Bieber-Poster-Hip-Hop-Harajuku-Streetwear-Hoodie-Hooded-Man-Letters-Justin-Bieber-Purpose-Tour-Security/32749040850.html?spm=2114.01010108.3.19.DqjInY&ws_ab_test=searchweb0_0,searchweb201602_3_10065_10068_10000074_10502_10000032_10504_119_10000025_10000029_430_10000028_10060_10000067_10062_10056_10055_10000062_10054_10059_9871_10099_10000022_9875_10000013_10103_10102_10000016_10096_10000018_10000019_10000056_10000059_10052_10053_10107_10050_10106_10051_10000053_10000007_10000050_10084_10083_10000047_10080_10082_10081_10110_10111_10112_10113_10114_10115_10000041_10000044_10078_10079_10000038_429_10073_10000035_10121-9871_9875_10502_10504,searchweb201603_1,afswitch_3,single_sort_2_default&btsid=23a5ef88-7eca-4972-8153-6f8f5a192f7b
| 0debug |
Extract string values from mixed data types in list : I have a list of mixed data types and from that I want to access string into one single value. For instance,
['000000001', 'Aaron', 'Appindangoye', '26', '183', '84.8']
from here I want to get Aaron Appindangoye together. Need a help. Thank you in advance. | 0debug |
Is there an R functon for easily display text as in Question function : I need to present the user with some text as in the help function. The help function display the text in a convenient way (for example, in emacs it uses a new buffer, in terminal opens vim, etc). So, is there a function that receives the string and does this job?
Thanks
| 0debug |
Do I really need to learn xml for android development? : <p>I am a Python programmer and I want to learn android app development. My million dollar question is, <strong>do I really need to learn xml?</strong> Can't I just use the design tab in android studio and drag n drop elements to make the design?</p>
| 0debug |
static int64_t mkv_write_seekhead(AVIOContext *pb, MatroskaMuxContext *mkv)
{
AVIOContext *dyn_cp;
mkv_seekhead *seekhead = mkv->main_seekhead;
ebml_master metaseek, seekentry;
int64_t currentpos;
int i;
currentpos = avio_tell(pb);
if (seekhead->reserved_size > 0) {
if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0) {
currentpos = -1;
goto fail;
}
}
if (start_ebml_master_crc32(pb, &dyn_cp, &metaseek, MATROSKA_ID_SEEKHEAD,
seekhead->reserved_size) < 0) {
currentpos = -1;
goto fail;
}
for (i = 0; i < seekhead->num_entries; i++) {
mkv_seekhead_entry *entry = &seekhead->entries[i];
seekentry = start_ebml_master(dyn_cp, MATROSKA_ID_SEEKENTRY, MAX_SEEKENTRY_SIZE);
put_ebml_id(dyn_cp, MATROSKA_ID_SEEKID);
put_ebml_num(dyn_cp, ebml_id_size(entry->elementid), 0);
put_ebml_id(dyn_cp, entry->elementid);
put_ebml_uint(dyn_cp, MATROSKA_ID_SEEKPOSITION, entry->segmentpos);
end_ebml_master(dyn_cp, seekentry);
}
end_ebml_master_crc32(pb, &dyn_cp, mkv, metaseek);
if (seekhead->reserved_size > 0) {
uint64_t remaining = seekhead->filepos + seekhead->reserved_size - avio_tell(pb);
put_ebml_void(pb, remaining);
avio_seek(pb, currentpos, SEEK_SET);
currentpos = seekhead->filepos;
}
fail:
av_freep(&mkv->main_seekhead->entries);
av_freep(&mkv->main_seekhead);
return currentpos;
}
| 1threat |
bool cpu_physical_memory_is_io(hwaddr phys_addr)
{
MemoryRegionSection *section;
section = phys_page_find(address_space_memory.dispatch,
phys_addr >> TARGET_PAGE_BITS);
return !(memory_region_is_ram(section->mr) ||
memory_region_is_romd(section->mr));
}
| 1threat |
clicking on buttom using httprequest in vbs : I WANT TO SIMULATE 'ie.document.getElementbyId("buttom_id").(0).click' IN XMLHTTPREQUEST, PLEASE HELP :(
THEREFORE IN CLICKING THE BUTTOM :
1) RIGHT CLICK ON THE WEBPAGE AND SELECT 'INSPECT'
2) SELECT NETWORK TAB
3) COPY ALL AS HAR
THIS INTERACT IS IN below:
[HAR FILE][1]
[1]: http://textuploader.com/dr1bt
MY CODE IS BELOW:
Function SaveGraphImageFromURLs( fileUrl, filePath)
Dim FileNum As Long
Dim FileData() As Byte
Dim WHTTP As Object
fileUrl = "http://80.191.214.122/Orion/Charts/CustomChartData.ashx?Calculate95thPercentile=True&CalculateTrendLine=True&ChartDateSpan=1&ChartInitialZoom=yesterday&ChartName=MMAvgBps&ChartSubTitle=%24%7bZoomRange%7d&ChartTitle=%24%7bCaption%7d&Height=0&NetObject=I%3a21067&ResourceID=69&SampleSize=30&Width=640&DataFormat=ChartData&NetObjectIds=21067"
WHTTP.Open "post", fileUrl, False
WHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
WHTTP.send
FileData = WHTTP.responseBody
Set WHTTP = Nothing
'Save the file
FileNum = FreeFile
Open filePath For Binary Access Write As #FileNum
Put #FileNum, 1, FileData
Close #FileNum
Debug.Print "File has been saved!", vbInformation, "Success"
End Function | 0debug |
Clears all the fields in Android Studio :
I have 4 fields and 2 buttons, one of the buttons is reset, I want that when I click on the button it clears all the fields | 0debug |
void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip)
{
const ARMCPRegInfo *ri = rip;
switch (ri->accessfn(env, ri)) {
case CP_ACCESS_OK:
return;
case CP_ACCESS_TRAP:
case CP_ACCESS_TRAP_UNCATEGORIZED:
break;
default:
g_assert_not_reached();
}
raise_exception(env, EXCP_UDEF);
}
| 1threat |
static av_cold int iv_alloc_frames(Indeo3DecodeContext *s)
{
int luma_width = (s->width + 3) & ~3,
luma_height = (s->height + 3) & ~3,
chroma_width = ((luma_width >> 2) + 3) & ~3,
chroma_height = ((luma_height >> 2) + 3) & ~3,
luma_pixels = luma_width * luma_height,
chroma_pixels = chroma_width * chroma_height,
i;
unsigned int bufsize = luma_pixels * 2 + luma_width * 3 +
(chroma_pixels + chroma_width) * 4;
if(!(s->buf = av_malloc(bufsize)))
return AVERROR(ENOMEM);
s->iv_frame[0].y_w = s->iv_frame[1].y_w = luma_width;
s->iv_frame[0].y_h = s->iv_frame[1].y_h = luma_height;
s->iv_frame[0].uv_w = s->iv_frame[1].uv_w = chroma_width;
s->iv_frame[0].uv_h = s->iv_frame[1].uv_h = chroma_height;
s->iv_frame[0].Ybuf = s->buf + luma_width;
i = luma_pixels + luma_width * 2;
s->iv_frame[1].Ybuf = s->buf + i;
i += (luma_pixels + luma_width);
s->iv_frame[0].Ubuf = s->buf + i;
i += (chroma_pixels + chroma_width);
s->iv_frame[1].Ubuf = s->buf + i;
i += (chroma_pixels + chroma_width);
s->iv_frame[0].Vbuf = s->buf + i;
i += (chroma_pixels + chroma_width);
s->iv_frame[1].Vbuf = s->buf + i;
for(i = 1; i <= luma_width; i++)
s->iv_frame[0].Ybuf[-i] = s->iv_frame[1].Ybuf[-i] =
s->iv_frame[0].Ubuf[-i] = 0x80;
for(i = 1; i <= chroma_width; i++) {
s->iv_frame[1].Ubuf[-i] = 0x80;
s->iv_frame[0].Vbuf[-i] = 0x80;
s->iv_frame[1].Vbuf[-i] = 0x80;
s->iv_frame[1].Vbuf[chroma_pixels+i-1] = 0x80;
}
return 0;
} | 1threat |
ask sql for multiplication two coloms and then division with sum of some rows : i have tables
**scores**
id name score item_id
1 rikad 90 1
2 rikad 80 2
3 rikad 70 3
4 reza 80 1
5 reza 80 2
6 reza 100 3
----------
**items**
id weight
1 0.5
2 0.2
3 0.3
----------
i want the output with new column call last_score ( (score x weight ) / "0.5 + 0.2 + 0.3 (sum of all weight that have same name)" )
id name score item_id weight last_score
1 rikad 90 1 0.5 last_score
2 rikad 80 2 0.2 last_score
3 rikad 70 3 0.3 last_score
4 reza 80 1 0.5 last_score
5 reza 80 2 0.2 last_score
6 reza 100 3 0.3 last_score | 0debug |
JaveScript: how to put things in the end of the call stack? : I am working in angular(2) and more and more I get into situation where I need to wait for angular to do its magic and then execute my code.
all its actually means is just to put the action in the end of the call stack(which I achieve right now by setting a time-out for 0 ms and a comment explaining my actions).
But that seems like being a smart ass.
I heard people talking about ngOnChange, but that seems even worse, I mean on every change of every element I need to execute this code which happens in such rare cases?
recent example would be when user changes view, I want the video to start playing(same component).
whats the correct way to do it? | 0debug |
yuv2rgb48_2_c_template(SwsContext *c, const int32_t *buf[2],
const int32_t *ubuf[2], const int32_t *vbuf[2],
const int32_t *abuf[2], uint16_t *dest, int dstW,
int yalpha, int uvalpha, int y,
enum PixelFormat target)
{
const int32_t *buf0 = buf[0], *buf1 = buf[1],
*ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
*vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
int yalpha1 = 4095 - yalpha;
int uvalpha1 = 4095 - uvalpha;
int i;
for (i = 0; i < ((dstW + 1) >> 1); i++) {
int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14;
int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14;
int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha + (-128 << 23)) >> 14;
int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha + (-128 << 23)) >> 14;
int R, G, B;
Y1 -= c->yuv2rgb_y_offset;
Y2 -= c->yuv2rgb_y_offset;
Y1 *= c->yuv2rgb_y_coeff;
Y2 *= c->yuv2rgb_y_coeff;
Y1 += 1 << 13;
Y2 += 1 << 13;
R = V * c->yuv2rgb_v2r_coeff;
G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
B = U * c->yuv2rgb_u2b_coeff;
output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14);
output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14);
output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14);
output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14);
dest += 6;
}
}
| 1threat |
php how to get a random value between 2 users : i have selected two users with their id.
eg:
$user_one = 1034;
$user_two = 1098;
$new_id = "";
Now i want to select one user between these two users **Randomly**. Can someone please help me how to select random ids from given ids.
eg:
$new_id = $get_random_id //Must be 1034 or 1038 | 0debug |
static int mp3_write_audio_packet(AVFormatContext *s, AVPacket *pkt)
{
MP3Context *mp3 = s->priv_data;
if (pkt->data && pkt->size >= 4) {
MPADecodeHeader c;
int av_unused base;
avpriv_mpegaudio_decode_header(&c, AV_RB32(pkt->data));
if (!mp3->initial_bitrate)
mp3->initial_bitrate = c.bit_rate;
if ((c.bit_rate == 0) || (mp3->initial_bitrate != c.bit_rate))
mp3->has_variable_bitrate = 1;
#ifdef FILTER_VBR_HEADERS
base = 4 + xing_offtbl[c.lsf == 1][c.nb_channels == 1];
if (base + 4 <= pkt->size) {
uint32_t v = AV_RB32(pkt->data + base);
if (MKBETAG('X','i','n','g') == v || MKBETAG('I','n','f','o') == v)
return 0;
}
base = 4 + 32;
if (base + 4 <= pkt->size && MKBETAG('V','B','R','I') == AV_RB32(pkt->data + base))
return 0;
#endif
if (mp3->xing_offset)
mp3_xing_add_frame(mp3, pkt);
}
return ff_raw_write_packet(s, pkt);
}
| 1threat |
How to update object in React state : <p>I have an indexed list of <code>users</code> in the JS object (not array). It's part of the React state.</p>
<pre><code>{
1: { id: 1, name: "John" }
2: { id: 2, name: "Jim" }
3: { id: 3, name: "James" }
}
</code></pre>
<p>What's the best practice to:</p>
<ol>
<li>add a new user { id: 4, name: "Jane" } with id (4) as key</li>
<li>remove a user with id 2</li>
<li>change the name of user #2 to "Peter"</li>
</ol>
<p>Without any immutable helpers. I'm using Coffeescript and Underscore (so _.extend is ok...).</p>
<p>Thanks.</p>
| 0debug |
static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t size,
uint32_t node, bool dedicated_hp_event_source,
Error **errp)
{
sPAPRDRConnector *drc;
sPAPRDRConnectorClass *drck;
uint32_t nr_lmbs = size/SPAPR_MEMORY_BLOCK_SIZE;
int i, fdt_offset, fdt_size;
void *fdt;
uint64_t addr = addr_start;
for (i = 0; i < nr_lmbs; i++) {
drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB,
addr/SPAPR_MEMORY_BLOCK_SIZE);
g_assert(drc);
fdt = create_device_tree(&fdt_size);
fdt_offset = spapr_populate_memory_node(fdt, node, addr,
SPAPR_MEMORY_BLOCK_SIZE);
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
drck->attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, errp);
addr += SPAPR_MEMORY_BLOCK_SIZE;
if (dev->hotplugged) {
if (dedicated_hp_event_source) {
drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB,
addr_start / SPAPR_MEMORY_BLOCK_SIZE);
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
spapr_hotplug_req_add_by_count_indexed(SPAPR_DR_CONNECTOR_TYPE_LMB,
nr_lmbs,
drck->get_index(drc));
} else {
spapr_hotplug_req_add_by_count(SPAPR_DR_CONNECTOR_TYPE_LMB,
nr_lmbs);
| 1threat |
Unable to find current origin/master revision in submodule path : <p>In my project (which uses <code>git</code>), I need to use <a href="https://github.com/mb21/JSONedit" rel="noreferrer">a library</a>, which is still in progress. I decided to create a submodule for that library, because I want to update from time to time its latest version (I don't plan to make my own change there).</p>
<p>I did:</p>
<pre><code>git submodule add https://github.com/mb21/JSONedit.git
git commit -am 'added JSNedit submodule'
git push -u origin master
git pull origin master
</code></pre>
<p>Then, I did see the JSONedit folder in my local folder, and a link in my git folder online. But when I did <code>git submodule update --remote JSONedit/</code>, I got the following errors: </p>
<pre><code>fatal: Needed a single revision
Unable to find current origin/master revision in submodule path 'JSONedit'
</code></pre>
<p>Does anyone know what's wrong here?</p>
| 0debug |
Member function invocation through object : <p>I just to understand the logic behind this code. When member function is not part of the object then how does the compiler invokes the function. Somehow the compiler needs to know the address of the function to invoke. Where it gets the address of the right function.I know this is silly question but curious to understand the underlying truth behind this</p>
<pre><code>#include <iostream>
using namespace std;
class Base {
public:
Base() {
cout << "Base class constructor\n";
}
void Fun()
{
cout << sizeof(this) << endl;
cout << "This is member function" ;
}
void Fun1()
{
cout << "This is second member fun" << endl;
}
int Val;
};
int main(int argc, char* argv[])
{
Base Obj;
cout << sizeof(Obj) << endl;
Obj.Fun();
return 0;
}
</code></pre>
| 0debug |
Automatically check bounds in std::vector : <p>During active development of a class that uses <code>std::vector</code>, it often happens that an index is out of bounds. (See <a href="https://codereview.stackexchange.com/questions/183930">this code review question</a> for a practical example.) When using <code>operator[]</code>, this results in undefined behavior. Still, the <code>[]</code> syntax is easy to read an more convenient than writing <code>.at()</code>.</p>
<p>Therefore I'd like to write my code using the <code>[]</code> operator, but at the same time have bounds checks enabled. After testing the code, it should be very easy to remove the bounds checks.</p>
<p>I'm thinking of the following code:</p>
<pre><code>util::bound_checked<std::vector<int>> numbers;
numbers.push_back(1);
numbers.push_back(2);
numbers.push_back(3);
numbers.push_back(4);
std::cout << numbers[17] << "\n";
</code></pre>
<p>To me, this utility template seems to be so straight-forward that I'd expect it to exist. Does it? If so, under which name?</p>
| 0debug |
how to delete an element from a struct? : I Would like you to help me in a homework we got from our teacher.
My question is the following: Can you help me in correcting my ddelete method (function)? Oh and please don't mark it as a duplicate, because don't think that there's a solution out there to my problem. (I'm saying that because last night Insearched a lot for it)
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
typedef struct{
long long unsigned num;
char name[20];
}Telbook;
using namespace std;
int be(Telbook*);
void ki(Telbook[]);
void search (Telbook[]);
void ddelete(Telbook[]);
int count(Telbook[]);
int main(){
setlocale(LC_ALL,"");
printf("\t\t\t Struktura feladat 1. \n\n\n");
Telbook tomb[50];
int db;
db=be(tomb);
ki(tomb);
search(tomb);
ddelete(tomb);
ki(tomb);
system("pause");
}
int be(Telbook *n){
int i=0;
printf("Enter phone # and names until the phone # you entered is 0\n");
/*printf("Kérek egy nevet: ");
scanf("%s",n->name);*/
printf("Enter a Phone #: ");
scanf("%llu",&n->num);
while(n->num){
printf("Enter a name: ");
scanf("%s",n->name);
i++;
n++;
printf("Enter a phone #: ");
scanf("%llu",&n->num);
}
return i;
}
void ki(Telbook n[]){
int i=0;
while(n[i].num){
printf("Name: %s, Phone #: %llu\n",n[i].name,n[i].num);
i++;
//n++;
}
}
void search(Telbook n[]){
int i=0;
int dbb;
char nev[20];
dbb=count(n);
printf("Enter the name you're searching for: ");
scanf("%s",nev);
for(i=0;i<dbb;i++){
if(strcmp(n[i].name,nev)==0)break;
//n++;
}
if(i==dbb){
printf("The name doesn't exist.\n");
}
else{
printf("The name you have searhed for is: %s it's on the %d. index.\n",nev,i+1);
}
}
int count(Telbook n[]) {
int i = 0;
while (n[i].num) {
i++;
}
return i;
}
void ddelete(Telbook n[]){
int szam,db=count(n),i=0,adat;
printf("Enter a number you want to delete: ");scanf("%d",&szam);
for(i = 0; i < db; i++){
if( szam == n[i].num){
for (i = 0; i < db - 1; i++)
{
n[i] = n[i + 1];
}
}
}
}
Here's my code i written it as understandable as possible. | 0debug |
Confused about Directory.GetFiles : <p>I've read the docs about the <code>Directory.GetPath</code> search pattern and how it is used, because I noticed that <code>*.dll</code> finds both <code>test.dll</code> and <code>test.dll_20170206</code>. That behavior is documented</p>
<p>Now, I have a program that lists files in a folder based on a user-configured mask and processes them. I noticed that masks like <code>*.txt</code> lead to the above mentioned "problem" as expected. </p>
<p>However, the mask <code>fixedname.txt</code> also causes <code>fixedname.txt_20170206</code> or the like to appear in the list, even though the documentation states this only occurs</p>
<blockquote>
<p>When you use the asterisk wildcard character in a searchPattern such as "*.txt"</p>
</blockquote>
<p>Why is that? </p>
<p>PS: I just checked: Changing the file mask to <code>fixednam?.txt</code> does not help even though the docs say</p>
<blockquote>
<p>When you use the question mark wildcard character, this method returns only files that match the specified file extension. For example, given two files, "file1.txt" and "file1.txtother", in a directory, a search pattern of "file?.txt" returns just the first file, whereas a search pattern of "file*.txt" returns both files.</p>
</blockquote>
| 0debug |
My sql query is giving me a error can any one help me? : $query = " SELECT * FROM comments WHERE comment_post_id = {$The_post_id} AND comment_status= 'approved' ";
error is
errorYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND comment_status='approved'' at line 1 | 0debug |
static void do_fp_st(DisasContext *s, int srcidx, TCGv_i64 tcg_addr, int size)
{
TCGv_i64 tmp = tcg_temp_new_i64();
tcg_gen_ld_i64(tmp, cpu_env, fp_reg_offset(srcidx, MO_64));
if (size < 4) {
tcg_gen_qemu_st_i64(tmp, tcg_addr, get_mem_index(s), MO_TE + size);
} else {
TCGv_i64 tcg_hiaddr = tcg_temp_new_i64();
tcg_gen_qemu_st_i64(tmp, tcg_addr, get_mem_index(s), MO_TEQ);
tcg_gen_qemu_st64(tmp, tcg_addr, get_mem_index(s));
tcg_gen_ld_i64(tmp, cpu_env, fp_reg_hi_offset(srcidx));
tcg_gen_addi_i64(tcg_hiaddr, tcg_addr, 8);
tcg_gen_qemu_st_i64(tmp, tcg_hiaddr, get_mem_index(s), MO_TEQ);
tcg_temp_free_i64(tcg_hiaddr);
}
tcg_temp_free_i64(tmp);
}
| 1threat |
static int rdma_delete_block(RDMAContext *rdma, RDMALocalBlock *block)
{
RDMALocalBlocks *local = &rdma->local_ram_blocks;
RDMALocalBlock *old = local->block;
int x;
if (rdma->blockmap) {
g_hash_table_remove(rdma->blockmap, (void *)(uintptr_t)block->offset);
}
if (block->pmr) {
int j;
for (j = 0; j < block->nb_chunks; j++) {
if (!block->pmr[j]) {
continue;
}
ibv_dereg_mr(block->pmr[j]);
rdma->total_registrations--;
}
g_free(block->pmr);
block->pmr = NULL;
}
if (block->mr) {
ibv_dereg_mr(block->mr);
rdma->total_registrations--;
block->mr = NULL;
}
g_free(block->transit_bitmap);
block->transit_bitmap = NULL;
g_free(block->unregister_bitmap);
block->unregister_bitmap = NULL;
g_free(block->remote_keys);
block->remote_keys = NULL;
g_free(block->block_name);
block->block_name = NULL;
if (rdma->blockmap) {
for (x = 0; x < local->nb_blocks; x++) {
g_hash_table_remove(rdma->blockmap,
(void *)(uintptr_t)old[x].offset);
}
}
if (local->nb_blocks > 1) {
local->block = g_malloc0(sizeof(RDMALocalBlock) *
(local->nb_blocks - 1));
if (block->index) {
memcpy(local->block, old, sizeof(RDMALocalBlock) * block->index);
}
if (block->index < (local->nb_blocks - 1)) {
memcpy(local->block + block->index, old + (block->index + 1),
sizeof(RDMALocalBlock) *
(local->nb_blocks - (block->index + 1)));
}
} else {
assert(block == local->block);
local->block = NULL;
}
trace_rdma_delete_block(block, (uintptr_t)block->local_host_addr,
block->offset, block->length,
(uintptr_t)(block->local_host_addr + block->length),
BITS_TO_LONGS(block->nb_chunks) *
sizeof(unsigned long) * 8, block->nb_chunks);
g_free(old);
local->nb_blocks--;
if (local->nb_blocks && rdma->blockmap) {
for (x = 0; x < local->nb_blocks; x++) {
g_hash_table_insert(rdma->blockmap,
(void *)(uintptr_t)local->block[x].offset,
&local->block[x]);
}
}
return 0;
}
| 1threat |
Why does NumberFormatter's string(from:) return an optional? : <p><a href="https://developer.apple.com/documentation/foundation/numberformatter/1418046-string" rel="noreferrer">Documentation link</a></p>
<p>Why does the <code>NumberFormatter</code> function <code>func string(from number: NSNumber) -> String?</code> return a <code>String?</code> rather than a <code>String</code>? Are there particular inputs or states for a <code>NumberFormatter</code> where this function could return nil? Sometimes I hear these less-than-ideal return types are from Objective-C holdover files, is this one of those cases?</p>
| 0debug |
Cut line shortcut in Visual Studio Code (Ctrl+L in VS) (not delete line!) : <p>Visual Studio has by default the shortcut Ctrl+l (cut line). It copies the line where the cursor is to the clipboard and deletes it.</p>
<p>I cannot find it in Visual Studio Code. Is there a way to add it as end user?</p>
<p>(I know there is Ctrl+Shift+K for delete line, which is not the same)</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.