problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Show loading indicator during CanActivate : <p>In my <strong>Angular</strong> application I'm using a <code>CanActivate</code> guard to protect the access in certain router state.</p>
<p>The <code>CanActivate</code> guard performs a check that can last 3-4 seconds and it is very annoyng to wait that time without a loading indicator (i.e. a spinner).</p>
<p>Is there a "standard" way to show a loading spinner during the CanActivate check?</p>
<p>Thanks a lot</p>
| 0debug
|
How do i add <br> automatically in textarea when a user press "enter" key? : <p>how would i approach on adding
<code><br></code>
tag automatically when a user types inside textarea ? Probably using javascript or php (because im developing my web app using laravel) ? Would i need wysiwyg editor for such simple task ?</p>
| 0debug
|
static void exynos4210_fimd_write(void *opaque, target_phys_addr_t offset,
uint64_t val, unsigned size)
{
Exynos4210fimdState *s = (Exynos4210fimdState *)opaque;
unsigned w, i;
uint32_t old_value;
DPRINT_L2("write offset 0x%08x, value=%llu(0x%08llx)\n", offset,
(long long unsigned int)val, (long long unsigned int)val);
switch (offset) {
case FIMD_VIDCON0:
if ((val & FIMD_VIDCON0_ENVID_MASK) == FIMD_VIDCON0_ENVID_MASK) {
exynos4210_fimd_enable(s, true);
} else {
if ((val & FIMD_VIDCON0_ENVID) == 0) {
exynos4210_fimd_enable(s, false);
}
}
s->vidcon[0] = val;
break;
case FIMD_VIDCON1:
val = (val & (~FIMD_VIDCON1_ROMASK)) |
(s->vidcon[1] & FIMD_VIDCON1_ROMASK);
s->vidcon[1] = val;
break;
case FIMD_VIDCON2 ... FIMD_VIDCON3:
s->vidcon[(offset) >> 2] = val;
break;
case FIMD_VIDTCON_START ... FIMD_VIDTCON_END:
s->vidtcon[(offset - FIMD_VIDTCON_START) >> 2] = val;
break;
case FIMD_WINCON_START ... FIMD_WINCON_END:
w = (offset - FIMD_WINCON_START) >> 2;
i = fimd_get_buffer_id(&s->window[w]);
old_value = s->window[w].wincon;
val = (val & ~FIMD_WINCON_ROMASK) |
(s->window[w].wincon & FIMD_WINCON_ROMASK);
if (w == 0) {
val &= ~FIMD_WINCON_ALPHA_MUL;
}
exynos4210_fimd_trace_bppmode(s, w, val);
switch (val & FIMD_WINCON_BUFSELECT) {
case FIMD_WINCON_BUF0_SEL:
val &= ~FIMD_WINCON_BUFSTATUS;
break;
case FIMD_WINCON_BUF1_SEL:
val = (val & ~FIMD_WINCON_BUFSTAT_H) | FIMD_WINCON_BUFSTAT_L;
break;
case FIMD_WINCON_BUF2_SEL:
if (val & FIMD_WINCON_BUFMODE) {
val = (val & ~FIMD_WINCON_BUFSTAT_L) | FIMD_WINCON_BUFSTAT_H;
}
break;
default:
break;
}
s->window[w].wincon = val;
exynos4210_fimd_update_win_bppmode(s, w);
fimd_update_get_alpha(s, w);
if ((i != fimd_get_buffer_id(&s->window[w])) ||
(!(old_value & FIMD_WINCON_ENWIN) && (s->window[w].wincon &
FIMD_WINCON_ENWIN))) {
fimd_update_memory_section(s, w);
}
break;
case FIMD_SHADOWCON:
old_value = s->shadowcon;
s->shadowcon = val;
for (w = 0; w < NUM_OF_WINDOWS; w++) {
if (FIMD_WINDOW_PROTECTED(old_value, w) &&
!FIMD_WINDOW_PROTECTED(s->shadowcon, w)) {
fimd_update_memory_section(s, w);
}
}
break;
case FIMD_WINCHMAP:
s->winchmap = val;
break;
case FIMD_VIDOSD_START ... FIMD_VIDOSD_END:
w = (offset - FIMD_VIDOSD_START) >> 4;
i = ((offset - FIMD_VIDOSD_START) & 0xF) >> 2;
switch (i) {
case 0:
old_value = s->window[w].lefttop_y;
s->window[w].lefttop_x = (val >> FIMD_VIDOSD_HOR_SHIFT) &
FIMD_VIDOSD_COORD_MASK;
s->window[w].lefttop_y = (val >> FIMD_VIDOSD_VER_SHIFT) &
FIMD_VIDOSD_COORD_MASK;
if (s->window[w].lefttop_y != old_value) {
fimd_update_memory_section(s, w);
}
break;
case 1:
old_value = s->window[w].rightbot_y;
s->window[w].rightbot_x = (val >> FIMD_VIDOSD_HOR_SHIFT) &
FIMD_VIDOSD_COORD_MASK;
s->window[w].rightbot_y = (val >> FIMD_VIDOSD_VER_SHIFT) &
FIMD_VIDOSD_COORD_MASK;
if (s->window[w].rightbot_y != old_value) {
fimd_update_memory_section(s, w);
}
break;
case 2:
if (w == 0) {
s->window[w].osdsize = val;
} else {
s->window[w].alpha_val[0] =
unpack_upper_4((val & FIMD_VIDOSD_ALPHA_AEN0) >>
FIMD_VIDOSD_AEN0_SHIFT) |
(s->window[w].alpha_val[0] & FIMD_VIDALPHA_ALPHA_LOWER);
s->window[w].alpha_val[1] =
unpack_upper_4(val & FIMD_VIDOSD_ALPHA_AEN1) |
(s->window[w].alpha_val[1] & FIMD_VIDALPHA_ALPHA_LOWER);
}
break;
case 3:
if (w != 1 && w != 2) {
DPRINT_ERROR("Bad write offset 0x%08x\n", offset);
return;
}
s->window[w].osdsize = val;
break;
}
break;
case FIMD_VIDWADD0_START ... FIMD_VIDWADD0_END:
w = (offset - FIMD_VIDWADD0_START) >> 3;
i = ((offset - FIMD_VIDWADD0_START) >> 2) & 1;
if (i == fimd_get_buffer_id(&s->window[w]) &&
s->window[w].buf_start[i] != val) {
s->window[w].buf_start[i] = val;
fimd_update_memory_section(s, w);
break;
}
s->window[w].buf_start[i] = val;
break;
case FIMD_VIDWADD1_START ... FIMD_VIDWADD1_END:
w = (offset - FIMD_VIDWADD1_START) >> 3;
i = ((offset - FIMD_VIDWADD1_START) >> 2) & 1;
s->window[w].buf_end[i] = val;
break;
case FIMD_VIDWADD2_START ... FIMD_VIDWADD2_END:
w = (offset - FIMD_VIDWADD2_START) >> 2;
if (((val & FIMD_VIDWADD2_PAGEWIDTH) != s->window[w].virtpage_width) ||
(((val >> FIMD_VIDWADD2_OFFSIZE_SHIFT) & FIMD_VIDWADD2_OFFSIZE) !=
s->window[w].virtpage_offsize)) {
s->window[w].virtpage_width = val & FIMD_VIDWADD2_PAGEWIDTH;
s->window[w].virtpage_offsize =
(val >> FIMD_VIDWADD2_OFFSIZE_SHIFT) & FIMD_VIDWADD2_OFFSIZE;
fimd_update_memory_section(s, w);
}
break;
case FIMD_VIDINTCON0:
s->vidintcon[0] = val;
break;
case FIMD_VIDINTCON1:
s->vidintcon[1] &= ~(val & 7);
exynos4210_fimd_update_irq(s);
break;
case FIMD_WKEYCON_START ... FIMD_WKEYCON_END:
w = ((offset - FIMD_WKEYCON_START) >> 3) + 1;
i = ((offset - FIMD_WKEYCON_START) >> 2) & 1;
s->window[w].keycon[i] = val;
break;
case FIMD_WKEYALPHA_START ... FIMD_WKEYALPHA_END:
w = ((offset - FIMD_WKEYALPHA_START) >> 2) + 1;
s->window[w].keyalpha = val;
break;
case FIMD_DITHMODE:
s->dithmode = val;
break;
case FIMD_WINMAP_START ... FIMD_WINMAP_END:
w = (offset - FIMD_WINMAP_START) >> 2;
old_value = s->window[w].winmap;
s->window[w].winmap = val;
if ((val & FIMD_WINMAP_EN) ^ (old_value & FIMD_WINMAP_EN)) {
exynos4210_fimd_invalidate(s);
exynos4210_fimd_update_win_bppmode(s, w);
exynos4210_fimd_trace_bppmode(s, w, 0xFFFFFFFF);
exynos4210_fimd_update(s);
}
break;
case FIMD_WPALCON_HIGH ... FIMD_WPALCON_LOW:
i = (offset - FIMD_WPALCON_HIGH) >> 2;
s->wpalcon[i] = val;
if (s->wpalcon[1] & FIMD_WPALCON_UPDATEEN) {
for (w = 0; w < NUM_OF_WINDOWS; w++) {
exynos4210_fimd_update_win_bppmode(s, w);
fimd_update_get_alpha(s, w);
}
}
break;
case FIMD_TRIGCON:
val = (val & ~FIMD_TRIGCON_ROMASK) | (s->trigcon & FIMD_TRIGCON_ROMASK);
s->trigcon = val;
break;
case FIMD_I80IFCON_START ... FIMD_I80IFCON_END:
s->i80ifcon[(offset - FIMD_I80IFCON_START) >> 2] = val;
break;
case FIMD_COLORGAINCON:
s->colorgaincon = val;
break;
case FIMD_LDI_CMDCON0 ... FIMD_LDI_CMDCON1:
s->ldi_cmdcon[(offset - FIMD_LDI_CMDCON0) >> 2] = val;
break;
case FIMD_SIFCCON0 ... FIMD_SIFCCON2:
i = (offset - FIMD_SIFCCON0) >> 2;
if (i != 2) {
s->sifccon[i] = val;
}
break;
case FIMD_HUECOEFCR_START ... FIMD_HUECOEFCR_END:
i = (offset - FIMD_HUECOEFCR_START) >> 2;
s->huecoef_cr[i] = val;
break;
case FIMD_HUECOEFCB_START ... FIMD_HUECOEFCB_END:
i = (offset - FIMD_HUECOEFCB_START) >> 2;
s->huecoef_cb[i] = val;
break;
case FIMD_HUEOFFSET:
s->hueoffset = val;
break;
case FIMD_VIDWALPHA_START ... FIMD_VIDWALPHA_END:
w = ((offset - FIMD_VIDWALPHA_START) >> 3);
i = ((offset - FIMD_VIDWALPHA_START) >> 2) & 1;
if (w == 0) {
s->window[w].alpha_val[i] = val;
} else {
s->window[w].alpha_val[i] = (val & FIMD_VIDALPHA_ALPHA_LOWER) |
(s->window[w].alpha_val[i] & FIMD_VIDALPHA_ALPHA_UPPER);
}
break;
case FIMD_BLENDEQ_START ... FIMD_BLENDEQ_END:
s->window[(offset - FIMD_BLENDEQ_START) >> 2].blendeq = val;
break;
case FIMD_BLENDCON:
old_value = s->blendcon;
s->blendcon = val;
if ((s->blendcon & FIMD_ALPHA_8BIT) != (old_value & FIMD_ALPHA_8BIT)) {
for (w = 0; w < NUM_OF_WINDOWS; w++) {
fimd_update_get_alpha(s, w);
}
}
break;
case FIMD_WRTQOSCON_START ... FIMD_WRTQOSCON_END:
s->window[(offset - FIMD_WRTQOSCON_START) >> 2].rtqoscon = val;
break;
case FIMD_I80IFCMD_START ... FIMD_I80IFCMD_END:
s->i80ifcmd[(offset - FIMD_I80IFCMD_START) >> 2] = val;
break;
case FIMD_VIDW0ADD0_B2 ... FIMD_VIDW4ADD0_B2:
if (offset & 0x0004) {
DPRINT_ERROR("bad write offset 0x%08x\n", offset);
break;
}
w = (offset - FIMD_VIDW0ADD0_B2) >> 3;
if (fimd_get_buffer_id(&s->window[w]) == 2 &&
s->window[w].buf_start[2] != val) {
s->window[w].buf_start[2] = val;
fimd_update_memory_section(s, w);
break;
}
s->window[w].buf_start[2] = val;
break;
case FIMD_SHD_ADD0_START ... FIMD_SHD_ADD0_END:
if (offset & 0x0004) {
DPRINT_ERROR("bad write offset 0x%08x\n", offset);
break;
}
s->window[(offset - FIMD_SHD_ADD0_START) >> 3].shadow_buf_start = val;
break;
case FIMD_SHD_ADD1_START ... FIMD_SHD_ADD1_END:
if (offset & 0x0004) {
DPRINT_ERROR("bad write offset 0x%08x\n", offset);
break;
}
s->window[(offset - FIMD_SHD_ADD1_START) >> 3].shadow_buf_end = val;
break;
case FIMD_SHD_ADD2_START ... FIMD_SHD_ADD2_END:
s->window[(offset - FIMD_SHD_ADD2_START) >> 2].shadow_buf_size = val;
break;
case FIMD_PAL_MEM_START ... FIMD_PAL_MEM_END:
w = (offset - FIMD_PAL_MEM_START) >> 10;
i = ((offset - FIMD_PAL_MEM_START) >> 2) & 0xFF;
s->window[w].palette[i] = val;
break;
case FIMD_PALMEM_AL_START ... FIMD_PALMEM_AL_END:
w = (offset - FIMD_PALMEM_AL_START) >> 10;
i = ((offset - FIMD_PALMEM_AL_START) >> 2) & 0xFF;
s->window[w].palette[i] = val;
break;
default:
DPRINT_ERROR("bad write offset 0x%08x\n", offset);
break;
}
}
| 1threat
|
Telegram does not escape some markdown characters : <p>Telegram does not escape some markdown characters, for example:</p>
<ul>
<li><p>This works fine</p>
<p>_test\_test_</p></li>
<li><p>But this return parse error</p>
<p>*test\*test*</p></li>
</ul>
<p>What I do wrong?</p>
| 0debug
|
every message i send from client to server ends with null (null pointer exception). how do i fix? : I doing a sort of test run for the networked portion of an application I am building and I am running into a problem where every message I send from the client to the server has null attached to the end of it. so for example "hello" would be printed by the server as "hellonull". the actual application needs to be able to send commands that the server will read. this test only prints the message. I have found that this is a problem with a null pointer exception and I understand that but what I don't understand is where null is coming from. is it the end of the stream? I thought that the end of stream would be indicated by -1. and if null does indicate the end of the stream how do I exist the stream without reaching null?
this is the main class for the server:
package servertester;
import java.io.*;
import java.net.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
public class ServerLaunch {
public static void main(String[] args) throws IOException{
final int PORT = 4444;
final int NUM_THREADS = 50;
ExecutorService pool = Executors.newFixedThreadPool(NUM_THREADS);
try(ServerSocket serv = new ServerSocket(PORT)){
while(true){
try{
Socket con = serv.accept();
Runnable r = new ServerRunnable(con);
Future<?> future = pool.submit(r);
String msg = (String) future.get();
System.out.println(msg);
}catch(Exception e){
System.out.println(e);
}
}
}
}
}
and this is the Runnable class
package servertester;
import java.net.*;
import java.io.*;
import java.util.*;
public class ServerRunnable implements Runnable{
private Socket con;
ServerRunnable(Socket con){
this.con = con;
}
@Override
public void run() {
InputStream in;
try {
StringBuilder str = new StringBuilder();
in = con.getInputStream();
BufferedInputStream bin = new BufferedInputStream(in);
Reader reader = new InputStreamReader(bin);
for(int c = reader.read(); c != -1; c = reader.read()){
str.append((char) c);
}
System.out.println(str);
}catch(NullPointerException n){
System.out.println("np");
}
catch (IOException e) {
System.out.println("io");
}finally{
if(con != null)
try {
con.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
thanks in advance for the help...
| 0debug
|
Modify a line by adding and deleting few coloumns using perl script inline : I am writing a perl script where i know which columns are to be removed and and where it needs to be added. e,g I have a array called `deleteColumn` which contains a which number column is to be deleted.Similarly i have array called `AddColumn` which contains information about at which location something needs to be inserted.
Things is i have a line where columns are separated by comma (,). An e.g of this would be
1,2,3,5,9,7,8,12
Now value in array deleteColumn is say [4,7] which means i have to
delete element 9 and 12 .And value in array AddColumn is say [3,5]
these addColoumn indicates an empty addition i.e ','. So after deletion
and addition finally the output should look like 1,2,3,,5,,7,8.
How can i achieve this inline as i would need to read around GB's of
files ( combined size ) and operate on them . Can this be done inline ?
I am reading file line by line.
| 0debug
|
What is the difference between find and firstOrNull? : <p>Given the following code extracted from <a href="https://github.com/Kotlin/kotlin-koans/blob/resolutions/src/ii_collections/n15AllAnyAndOtherPredicates.kt#L36-L39" rel="noreferrer">Kotlin Koans</a>:</p>
<pre><code>fun Shop.findAnyCustomerFrom(city: City): Customer? {
// Return a customer who lives in the given city, or null if there is none
return customers.firstOrNull { it.isFrom(city) }
}
</code></pre>
<p>My own solution used <code>customers.find</code>. Both work in the koan scenario.</p>
<p>The documentation for <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/first-or-null.html" rel="noreferrer"><code>firstOrNull</code></a> and <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/find.html" rel="noreferrer"><code>find</code></a> seem to be very similar.</p>
<p>What is the difference between these two functions?</p>
| 0debug
|
How to loop throung multiple JSON arrays in JavaScript? : I have this JSON array:
{"Los Angeles, CA":["East Los Angeles","Florence","Florence-Firestone","Los Feliz","West Los Angeles"]}
But my code prints only "Los Angeles, CA", without child array strings...
function search4Location(query = true) {
$.ajax({
url: '/work/ajax/regions.php' + (query ? '?q=' + $("#searchLocation").val() : ''),
dataType: 'json',
success: function(data) {
var datalen = data.length;
$("#region").html('');
if (query == true) {
for (var i = 0; i < datalen; i++) {alert(123);
$("#region").append('<option>' + data[i] + '</option>');
var datalen2 = data[i].length;
for (var ii = 0; ii < datalen2; ii++) {
$("#region").append('<option>—— ' + data[i][ii] + '</option>');
}
}
} else {
for (var i = 0; i < datalen; i++) {
$("#region").append('<option>' + data[i] + '</option>');
}
}
}
});
return false;
}
How to make display them?
| 0debug
|
im trying to do a music quiz and i keep getting this error :
def MusicGame():
score=0
tries = 0
with open("songs.txt") as file:
for line in file.readlines():
artist,name=line.split(" - ", 1)
question=(artist + "- " + " ".join([x[0].upper() for x in name.split()])+": ")
answer=input(question)
if tries != 2:
if answer in ["STOOPID","Funky Friday","dark knight dummo","natural disaster","gucci gang"]:
print("well done")
tries=0
score=score+3
elif answer not in ["STOOPID","Funky Friday","dark knight dummo","natural disaster","gucci gang"]:
answer2=input("it was wrong try again")
if answer in ["STOOPID","Funky Friday","dark knight dummo","natural disaster","gucci gang"]:
print("well done+1")
tries=tries+1
score=score+1
elif answer2 not in ["STOOPID","Funky Friday","dark knight dummo","natural disaster","gucci gang"]:
print("you suck you lost")
break
i keep getting this error artist,name=line.split(" - ", 1)
ValueError: need more than 1 value to unpack
| 0debug
|
<No main classes found> in java program : <p>Hello I am writing a java program that converts Celsius to Fahrenheit. A custom method will calculate the conversion and pass it to the main method which called it.. In the main method a loop will be invoked as long as 0-100 and increment by 10.. I have tried some of the other suggestions I have seen with this error but with no luck.. Here is my code and thanks in advance</p>
<pre><code>package sknight_project10_orig;
public class SKnight_Project10_ORIG
{
public static double main(String[] args)
{
double Celsius = 0.0;
double Fahrenheit = 0.0;
//For loop to increment by 10 from 0-100
for (int i = 0; i < 100; i++)
{
convertTemp(Celsius);
System.out.println(Celsius + " = " + Fahrenheit);
i = i + 10;
}
return Celsius;
}
public static Double convertTemp(Double Celsius)
{
double Fahrenheit = Celsius * 1.8 + 32;
return Fahrenheit;
}
}
</code></pre>
| 0debug
|
void helper_rdmsr(void)
{
uint64_t val;
helper_svm_check_intercept_param(SVM_EXIT_MSR, 0);
switch((uint32_t)ECX) {
case MSR_IA32_SYSENTER_CS:
val = env->sysenter_cs;
break;
case MSR_IA32_SYSENTER_ESP:
val = env->sysenter_esp;
break;
case MSR_IA32_SYSENTER_EIP:
val = env->sysenter_eip;
break;
case MSR_IA32_APICBASE:
val = cpu_get_apic_base(env);
break;
case MSR_EFER:
val = env->efer;
break;
case MSR_STAR:
val = env->star;
break;
case MSR_PAT:
val = env->pat;
break;
case MSR_VM_HSAVE_PA:
val = env->vm_hsave;
break;
case MSR_IA32_PERF_STATUS:
val = 1000ULL;
val |= (((uint64_t)4ULL) << 40);
break;
#ifdef TARGET_X86_64
case MSR_LSTAR:
val = env->lstar;
break;
case MSR_CSTAR:
val = env->cstar;
break;
case MSR_FMASK:
val = env->fmask;
break;
case MSR_FSBASE:
val = env->segs[R_FS].base;
break;
case MSR_GSBASE:
val = env->segs[R_GS].base;
break;
case MSR_KERNELGSBASE:
val = env->kernelgsbase;
break;
#endif
#ifdef CONFIG_KQEMU
case MSR_QPI_COMMBASE:
if (env->kqemu_enabled) {
val = kqemu_comm_base;
} else {
val = 0;
}
break;
#endif
case MSR_MTRRphysBase(0):
case MSR_MTRRphysBase(1):
case MSR_MTRRphysBase(2):
case MSR_MTRRphysBase(3):
case MSR_MTRRphysBase(4):
case MSR_MTRRphysBase(5):
case MSR_MTRRphysBase(6):
case MSR_MTRRphysBase(7):
val = env->mtrr_var[((uint32_t)ECX - MSR_MTRRphysBase(0)) / 2].base;
break;
case MSR_MTRRphysMask(0):
case MSR_MTRRphysMask(1):
case MSR_MTRRphysMask(2):
case MSR_MTRRphysMask(3):
case MSR_MTRRphysMask(4):
case MSR_MTRRphysMask(5):
case MSR_MTRRphysMask(6):
case MSR_MTRRphysMask(7):
val = env->mtrr_var[((uint32_t)ECX - MSR_MTRRphysMask(0)) / 2].mask;
break;
case MSR_MTRRfix64K_00000:
val = env->mtrr_fixed[0];
break;
case MSR_MTRRfix16K_80000:
case MSR_MTRRfix16K_A0000:
val = env->mtrr_fixed[(uint32_t)ECX - MSR_MTRRfix16K_80000 + 1];
break;
case MSR_MTRRfix4K_C0000:
case MSR_MTRRfix4K_C8000:
case MSR_MTRRfix4K_D0000:
case MSR_MTRRfix4K_D8000:
case MSR_MTRRfix4K_E0000:
case MSR_MTRRfix4K_E8000:
case MSR_MTRRfix4K_F0000:
case MSR_MTRRfix4K_F8000:
val = env->mtrr_fixed[(uint32_t)ECX - MSR_MTRRfix4K_C0000 + 3];
break;
case MSR_MTRRdefType:
val = env->mtrr_deftype;
break;
case MSR_MTRRcap:
if (env->cpuid_features & CPUID_MTRR)
val = MSR_MTRRcap_VCNT | MSR_MTRRcap_FIXRANGE_SUPPORT | MSR_MTRRcap_WC_SUPPORTED;
else
val = 0;
break;
case MSR_MCG_CAP:
val = env->mcg_cap;
break;
case MSR_MCG_CTL:
if (env->mcg_cap & MCG_CTL_P)
val = env->mcg_ctl;
else
val = 0;
break;
case MSR_MCG_STATUS:
val = env->mcg_status;
break;
default:
if ((uint32_t)ECX >= MSR_MC0_CTL
&& (uint32_t)ECX < MSR_MC0_CTL + (4 * env->mcg_cap & 0xff)) {
uint32_t offset = (uint32_t)ECX - MSR_MC0_CTL;
val = env->mce_banks[offset];
break;
}
val = 0;
break;
}
EAX = (uint32_t)(val);
EDX = (uint32_t)(val >> 32);
}
| 1threat
|
static uint32_t epic_decode_pixel_pred(ePICContext *dc, int x, int y,
const uint32_t *curr_row,
const uint32_t *above_row)
{
uint32_t N, W, NW, pred;
unsigned delta;
int GN, GW, GNW, R, G, B;
if (x && y) {
W = curr_row[x - 1];
N = above_row[x];
NW = above_row[x - 1];
GN = (N >> G_shift) & 0xFF;
GW = (W >> G_shift) & 0xFF;
GNW = (NW >> G_shift) & 0xFF;
G = epic_decode_component_pred(dc, GN, GW, GNW);
R = G + epic_decode_component_pred(dc,
((N >> R_shift) & 0xFF) - GN,
((W >> R_shift) & 0xFF) - GW,
((NW >> R_shift) & 0xFF) - GNW);
B = G + epic_decode_component_pred(dc,
((N >> B_shift) & 0xFF) - GN,
((W >> B_shift) & 0xFF) - GW,
((NW >> B_shift) & 0xFF) - GNW);
} else {
if (x)
pred = curr_row[x - 1];
else
pred = above_row[x];
delta = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung);
R = ((pred >> R_shift) & 0xFF) - TOSIGNED(delta);
delta = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung);
G = ((pred >> G_shift) & 0xFF) - TOSIGNED(delta);
delta = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung);
B = ((pred >> B_shift) & 0xFF) - TOSIGNED(delta);
return (R << R_shift) | (G << G_shift) | (B << B_shift);
| 1threat
|
50000 to .5 lakhs in postgres query : Select * from employee;
ID name salary
1 karthi 30000
2 Thushara 70000
3 Divya 150000
How to convert like this
ID name salary
1 karthi 0.3 lakhs
2 Thushara 0.7 lakhs
3 Divya 1.5 lakhs
| 0debug
|
int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen)
{
int i = 0, d = 0;
int ret;
uint32_t count = 0;
while (i < slen) {
if ((slen - i) < 2) {
return -1;
}
ret = uleb128_decode_small(src + i, &count);
if (ret < 0 || (i && !count)) {
return -1;
}
i += ret;
d += count;
if (d > dlen) {
return -1;
}
if ((slen - i) < 2) {
return -1;
}
ret = uleb128_decode_small(src + i, &count);
if (ret < 0 || !count) {
return -1;
}
i += ret;
if (d + count > dlen || i + count > slen) {
return -1;
}
memcpy(dst + d, src + i, count);
d += count;
i += count;
}
return d;
}
| 1threat
|
How can I access 'spring.application.name' when defined in bootstrap.properties? : <p>I have the following spring-boot 1.4.2.RELEASE sample app</p>
<pre><code>@SpringBootApplication
public class Application {
@Value("${spring.application.name}")
private String applicationName;
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
</code></pre>
<p>And I have the following configuration defined in bootstrap.properties:</p>
<pre><code>spring.application.name=sample-app
</code></pre>
<p>When run it I get the following error: </p>
<pre><code>java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.application.name' in string value "${spring.application.name}"
</code></pre>
<p>Any hint on why it fails to inject 'spring.application.name'?
Need to define it there to support other spring boot cloud. </p>
| 0debug
|
Where do logs go when running ASP.NET Core on IIS 7.5? : <p>I'm posting this and answering it, because this left me stumped for a very long time. I have the following line in my <code>web.config</code>:</p>
<pre><code><aspNetCore processPath="dotnet" arguments=".\XXX.Server.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
</code></pre>
<p>So apparently, this should be logging to <code>logs\stdout</code>, but when I look, there's nothing there. I went on a wild goose chase, searching the whole disk for anything named 'log' (that returned too much) or 'stdout' (that returned nothing), and still couldn't figure it out.</p>
| 0debug
|
why it gives me an output of 49 : #include <stdio.h>
int main(void)
{
char i=49;
printf("%d",i);
return 0;
}
why it shows the output of 49 to me instead I am using %d to print a character whereas my character declaration is also wrong
| 0debug
|
static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquant, int ttmb, int first_block,
uint8_t *dst, int linesize, int skip_block)
{
MpegEncContext *s = &v->s;
GetBitContext *gb = &s->gb;
int i, j;
int subblkpat = 0;
int scale, off, idx, last, skip, value;
int ttblk = ttmb & 7;
if(ttmb == -1) {
ttblk = ff_vc1_ttblk_to_tt[v->tt_index][get_vlc2(gb, ff_vc1_ttblk_vlc[v->tt_index].table, VC1_TTBLK_VLC_BITS, 1)];
}
if(ttblk == TT_4X4) {
subblkpat = ~(get_vlc2(gb, ff_vc1_subblkpat_vlc[v->tt_index].table, VC1_SUBBLKPAT_VLC_BITS, 1) + 1);
}
if((ttblk != TT_8X8 && ttblk != TT_4X4) && (v->ttmbf || (ttmb != -1 && (ttmb & 8) && !first_block))) {
subblkpat = decode012(gb);
if(subblkpat) subblkpat ^= 3;
if(ttblk == TT_8X4_TOP || ttblk == TT_8X4_BOTTOM) ttblk = TT_8X4;
if(ttblk == TT_4X8_RIGHT || ttblk == TT_4X8_LEFT) ttblk = TT_4X8;
}
scale = 2 * mquant + ((v->pq == mquant) ? v->halfpq : 0);
if(ttblk == TT_8X4_TOP || ttblk == TT_8X4_BOTTOM) {
subblkpat = 2 - (ttblk == TT_8X4_TOP);
ttblk = TT_8X4;
}
if(ttblk == TT_4X8_RIGHT || ttblk == TT_4X8_LEFT) {
subblkpat = 2 - (ttblk == TT_4X8_LEFT);
ttblk = TT_4X8;
}
switch(ttblk) {
case TT_8X8:
i = 0;
last = 0;
while (!last) {
vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2);
i += skip;
if(i > 63)
break;
idx = wmv1_scantable[0][i++];
block[idx] = value * scale;
if(!v->pquantizer)
block[idx] += (block[idx] < 0) ? -mquant : mquant;
}
if(!skip_block){
s->dsp.vc1_inv_trans_8x8(block);
s->dsp.add_pixels_clamped(block, dst, linesize);
}
break;
case TT_4X4:
for(j = 0; j < 4; j++) {
last = subblkpat & (1 << (3 - j));
i = 0;
off = (j & 1) * 4 + (j & 2) * 16;
while (!last) {
vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2);
i += skip;
if(i > 15)
break;
idx = ff_vc1_simple_progressive_4x4_zz[i++];
block[idx + off] = value * scale;
if(!v->pquantizer)
block[idx + off] += (block[idx + off] < 0) ? -mquant : mquant;
}
if(!(subblkpat & (1 << (3 - j))) && !skip_block)
s->dsp.vc1_inv_trans_4x4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, block + off);
}
break;
case TT_8X4:
for(j = 0; j < 2; j++) {
last = subblkpat & (1 << (1 - j));
i = 0;
off = j * 32;
while (!last) {
vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2);
i += skip;
if(i > 31)
break;
idx = v->zz_8x4[i++]+off;
block[idx] = value * scale;
if(!v->pquantizer)
block[idx] += (block[idx] < 0) ? -mquant : mquant;
}
if(!(subblkpat & (1 << (1 - j))) && !skip_block)
s->dsp.vc1_inv_trans_8x4(dst + j*4*linesize, linesize, block + off);
}
break;
case TT_4X8:
for(j = 0; j < 2; j++) {
last = subblkpat & (1 << (1 - j));
i = 0;
off = j * 4;
while (!last) {
vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2);
i += skip;
if(i > 31)
break;
idx = v->zz_4x8[i++]+off;
block[idx] = value * scale;
if(!v->pquantizer)
block[idx] += (block[idx] < 0) ? -mquant : mquant;
}
if(!(subblkpat & (1 << (1 - j))) && !skip_block)
s->dsp.vc1_inv_trans_4x8(dst + j*4, linesize, block + off);
}
break;
}
return 0;
}
| 1threat
|
Convert a column of str into a column of datetime : <p>I have a huge column named Date of str with this format: year-month-day
and I want to convert it into a DateTime type </p>
<p>Can someone help me, please :)</p>
| 0debug
|
How to move item from listbox to folder vb.net : I have a list box and in the list box has paths to files how to move the selected items that has the path move that file to another folder.
| 0debug
|
How to create and write to a txt document from a batch executable : <p>I am making a mock operating system using .bat files and I want to be able to create and write to .txt files so I can store data, but I can't find a command that lets me do this. Any suggestions?</p>
| 0debug
|
Want to use plurals correctly when using sizeof function in php : When the page display results I want it to say say "We found X products" or "We Found 1 Product" rather than we found 1 products.
<?php echo sizeof($ids); ?> Products</strong>
| 0debug
|
Multipurpose with python : <p>I need to improve a script that runs 3 python scripts in parallel at the same time, I have this script below ready, only it is jumping some scripts on the list, I don't know why this is happening.</p>
<p>Code:</p>
<pre><code>import sys
import asyncio
scriptspy = [
'/scipts/sp01.py',
'/scipts/sp02.py',
'/scipts/sp03.py',
'/scipts/sp04.py',
'/scipts/sp05.py',
'/scipts/sp06.py',
'/scipts/sp07.py',
'/scipts/sp08.py',
'/scipts/sp09.py',
'/scipts/sp10.py',
'/scipts/sp11.py',
'/scipts/sp12.py',
'/scipts/sp13.py',
'/scipts/sp14.py',
'/scipts/sp15.py',
'/scipts/sp16.py',
'/scipts/sp17.py',
'/scipts/sp18.py',
'/scipts/sp19.py',
'/scipts/sp20.py',
'/scipts/sp21.py',
'/scipts/sp22.py',
'/scipts/sp23.py',
'/scipts/sp24.py',
]
#linux
async def main():
task_run= set()
while scriptspy:
# start 3 scripts
while len(task_run) < 3 and scriptspy:
script = scriptspy.pop()
p = await asyncio.create_subprocess_exec(sys.executable, script)
task = asyncio.create_task(p.wait())
task_run.add(task)
# wait one and start
task_run, task_end = await asyncio.wait(task_run, return_when=asyncio.FIRST_COMPLETED)
await asyncio.wait(task_run, return_when=asyncio.ALL_COMPLETED)
asyncio.run(main())
</code></pre>
<p>Detail
S.O Execute: Linux (Ubuntu)
Python: 3.7</p>
| 0debug
|
Default value of function parameter initialized by list initialization : <p>Could anyone help me with the following problem?</p>
<p>There is a simple code:</p>
<pre><code>#include <vector>
struct A {
std::vector<int> vec;
};
void func (A &&a = {}) {}
int main()
{
func();
return 0;
}
</code></pre>
<p>When I try to compile it by gcc 5.4.0 I get the error:</p>
<pre><code>undefined reference to `std::vector<int, std::allocator<int> >::vector()'
</code></pre>
<p>Amazingly, but clang compiles it well.
Also if to modify the code a little bit it is compiled without any problems:</p>
<pre><code>#include <vector>
struct A {
std::vector<int> vec;
};
void func (A &&a) {}
int main()
{
func({});
return 0;
}
</code></pre>
<p>I really cann't understand what's wrong with the first code.</p>
| 0debug
|
static target_ulong h_resize_hpt_commit(PowerPCCPU *cpu,
sPAPRMachineState *spapr,
target_ulong opcode,
target_ulong *args)
{
target_ulong flags = args[0];
target_ulong shift = args[1];
sPAPRPendingHPT *pending = spapr->pending_hpt;
int rc;
size_t newsize;
if (spapr->resize_hpt == SPAPR_RESIZE_HPT_DISABLED) {
return H_AUTHORITY;
}
trace_spapr_h_resize_hpt_commit(flags, shift);
rc = kvmppc_resize_hpt_commit(cpu, flags, shift);
if (rc != -ENOSYS) {
return resize_hpt_convert_rc(rc);
}
if (flags != 0) {
return H_PARAMETER;
}
if (!pending || (pending->shift != shift)) {
return H_CLOSED;
}
if (!pending->complete) {
return H_BUSY;
}
g_assert(spapr->htab_shift);
newsize = 1ULL << pending->shift;
rc = rehash_hpt(cpu, spapr->htab, HTAB_SIZE(spapr),
pending->hpt, newsize);
if (rc == H_SUCCESS) {
qemu_vfree(spapr->htab);
spapr->htab = pending->hpt;
spapr->htab_shift = pending->shift;
if (kvm_enabled()) {
target_ulong sdr1 = (target_ulong)(uintptr_t)spapr->htab
| (spapr->htab_shift - 18);
kvmppc_update_sdr1(sdr1);
}
pending->hpt = NULL;
}
spapr->pending_hpt = NULL;
free_pending_hpt(pending);
return rc;
}
| 1threat
|
static int32_t scsi_disk_dma_command(SCSIRequest *req, uint8_t *buf)
{
SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req);
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);
uint32_t len;
uint8_t command;
command = buf[0];
if (s->tray_open || !bdrv_is_inserted(s->qdev.conf.bs)) {
scsi_check_condition(r, SENSE_CODE(NO_MEDIUM));
return 0;
}
len = scsi_data_cdb_length(r->req.cmd.buf);
switch (command) {
case READ_6:
case READ_10:
case READ_12:
case READ_16:
DPRINTF("Read (sector %" PRId64 ", count %u)\n", r->req.cmd.lba, len);
if (r->req.cmd.buf[1] & 0xe0) {
goto illegal_request;
}
if (!check_lba_range(s, r->req.cmd.lba, len)) {
goto illegal_lba;
}
r->sector = r->req.cmd.lba * (s->qdev.blocksize / 512);
r->sector_count = len * (s->qdev.blocksize / 512);
break;
case WRITE_6:
case WRITE_10:
case WRITE_12:
case WRITE_16:
case WRITE_VERIFY_10:
case WRITE_VERIFY_12:
case WRITE_VERIFY_16:
if (bdrv_is_read_only(s->qdev.conf.bs)) {
scsi_check_condition(r, SENSE_CODE(WRITE_PROTECTED));
return 0;
}
DPRINTF("Write %s(sector %" PRId64 ", count %u)\n",
(command & 0xe) == 0xe ? "And Verify " : "",
r->req.cmd.lba, len);
if (r->req.cmd.buf[1] & 0xe0) {
goto illegal_request;
}
if (!check_lba_range(s, r->req.cmd.lba, len)) {
goto illegal_lba;
}
r->sector = r->req.cmd.lba * (s->qdev.blocksize / 512);
r->sector_count = len * (s->qdev.blocksize / 512);
break;
default:
abort();
illegal_request:
scsi_check_condition(r, SENSE_CODE(INVALID_FIELD));
return 0;
illegal_lba:
scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE));
return 0;
}
if (r->sector_count == 0) {
scsi_req_complete(&r->req, GOOD);
}
assert(r->iov.iov_len == 0);
if (r->req.cmd.mode == SCSI_XFER_TO_DEV) {
return -r->sector_count * 512;
} else {
return r->sector_count * 512;
}
}
| 1threat
|
List append acting wierd : I'm new to Python 3, and when using 2d arrays, I can add these elements, but it won't let me call an element; it throws a 'list index out of range'
a = []
for i in range (0,10):
x = str(input("insert player x"))
blah.append([x,0])
for i in range(0,10):
bleh = blah[0,1]
this throws a 'list index out of range' error
any suggestions?
| 0debug
|
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
| 1threat
|
static int ccid_handle_data(USBDevice *dev, USBPacket *p)
{
USBCCIDState *s = DO_UPCAST(USBCCIDState, dev, dev);
int ret = 0;
uint8_t buf[2];
switch (p->pid) {
case USB_TOKEN_OUT:
ret = ccid_handle_bulk_out(s, p);
break;
case USB_TOKEN_IN:
switch (p->devep & 0xf) {
case CCID_BULK_IN_EP:
if (!p->iov.size) {
ret = USB_RET_NAK;
} else {
ret = ccid_bulk_in_copy_to_guest(s, p);
}
break;
case CCID_INT_IN_EP:
if (s->notify_slot_change) {
buf[0] = CCID_MESSAGE_TYPE_RDR_to_PC_NotifySlotChange;
buf[1] = s->bmSlotICCState;
usb_packet_copy(p, buf, 2);
ret = 2;
s->notify_slot_change = false;
s->bmSlotICCState &= ~SLOT_0_CHANGED_MASK;
DPRINTF(s, D_INFO,
"handle_data: int_in: notify_slot_change %X, "
"requested len %zd\n",
s->bmSlotICCState, p->iov.size);
}
break;
default:
DPRINTF(s, 1, "Bad endpoint\n");
ret = USB_RET_STALL;
break;
}
break;
default:
DPRINTF(s, 1, "Bad token\n");
ret = USB_RET_STALL;
break;
}
return ret;
}
| 1threat
|
static void gen_iccci(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
#endif
}
| 1threat
|
int bdrv_is_snapshot(BlockDriverState *bs)
{
return !!(bs->open_flags & BDRV_O_SNAPSHOT);
}
| 1threat
|
static int vp3_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
Vp3DecodeContext *s = avctx->priv_data;
GetBitContext gb;
static int counter = 0;
int i;
init_get_bits(&gb, buf, buf_size * 8);
if (s->theora && get_bits1(&gb))
{
#if 1
av_log(avctx, AV_LOG_ERROR, "Header packet passed to frame decoder, skipping\n");
#else
int ptype = get_bits(&gb, 7);
skip_bits(&gb, 6*8);
switch(ptype)
{
case 1:
theora_decode_comments(avctx, &gb);
break;
case 2:
theora_decode_tables(avctx, &gb);
init_dequantizer(s);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown Theora config packet: %d\n", ptype);
return buf_size;
#endif
s->keyframe = !get_bits1(&gb);
if (!s->theora)
skip_bits(&gb, 1);
s->last_quality_index = s->quality_index;
s->nqis=0;
do{
s->qis[s->nqis++]= get_bits(&gb, 6);
} while(s->theora >= 0x030200 && s->nqis<3 && get_bits1(&gb));
s->quality_index= s->qis[0];
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, " VP3 %sframe #%d: Q index = %d\n",
s->keyframe?"key":"", counter, s->quality_index);
counter++;
if (s->quality_index != s->last_quality_index) {
init_dequantizer(s);
init_loop_filter(s);
if (s->keyframe) {
if (!s->theora)
{
skip_bits(&gb, 4);
skip_bits(&gb, 4);
if (s->version)
{
s->version = get_bits(&gb, 5);
if (counter == 1)
av_log(s->avctx, AV_LOG_DEBUG, "VP version: %d\n", s->version);
if (s->version || s->theora)
{
if (get_bits1(&gb))
av_log(s->avctx, AV_LOG_ERROR, "Warning, unsupported keyframe coding type?!\n");
skip_bits(&gb, 2);
if (s->last_frame.data[0] == s->golden_frame.data[0]) {
if (s->golden_frame.data[0])
avctx->release_buffer(avctx, &s->golden_frame);
s->last_frame= s->golden_frame;
} else {
if (s->golden_frame.data[0])
avctx->release_buffer(avctx, &s->golden_frame);
if (s->last_frame.data[0])
avctx->release_buffer(avctx, &s->last_frame);
s->golden_frame.reference = 3;
if(avctx->get_buffer(avctx, &s->golden_frame) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "vp3: get_buffer() failed\n");
s->current_frame= s->golden_frame;
if (!s->pixel_addresses_inited)
{
if (!s->flipped_image)
vp3_calculate_pixel_addresses(s);
else
theora_calculate_pixel_addresses(s);
} else {
s->current_frame.reference = 3;
if(avctx->get_buffer(avctx, &s->current_frame) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "vp3: get_buffer() failed\n");
s->current_frame.qscale_table= s->qscale_table;
s->current_frame.qstride= 0;
{START_TIMER
init_frame(s, &gb);
STOP_TIMER("init_frame")}
#if KEYFRAMES_ONLY
if (!s->keyframe) {
memcpy(s->current_frame.data[0], s->golden_frame.data[0],
s->current_frame.linesize[0] * s->height);
memcpy(s->current_frame.data[1], s->golden_frame.data[1],
s->current_frame.linesize[1] * s->height / 2);
memcpy(s->current_frame.data[2], s->golden_frame.data[2],
s->current_frame.linesize[2] * s->height / 2);
} else {
#endif
{START_TIMER
if (unpack_superblocks(s, &gb)){
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_superblocks\n");
STOP_TIMER("unpack_superblocks")}
{START_TIMER
if (unpack_modes(s, &gb)){
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_modes\n");
STOP_TIMER("unpack_modes")}
{START_TIMER
if (unpack_vectors(s, &gb)){
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_vectors\n");
STOP_TIMER("unpack_vectors")}
{START_TIMER
if (unpack_dct_coeffs(s, &gb)){
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_dct_coeffs\n");
STOP_TIMER("unpack_dct_coeffs")}
{START_TIMER
reverse_dc_prediction(s, 0, s->fragment_width, s->fragment_height);
if ((avctx->flags & CODEC_FLAG_GRAY) == 0) {
reverse_dc_prediction(s, s->fragment_start[1],
s->fragment_width / 2, s->fragment_height / 2);
reverse_dc_prediction(s, s->fragment_start[2],
s->fragment_width / 2, s->fragment_height / 2);
STOP_TIMER("reverse_dc_prediction")}
{START_TIMER
for (i = 0; i < s->macroblock_height; i++)
render_slice(s, i);
STOP_TIMER("render_fragments")}
{START_TIMER
apply_loop_filter(s);
STOP_TIMER("apply_loop_filter")}
#if KEYFRAMES_ONLY
#endif
*data_size=sizeof(AVFrame);
*(AVFrame*)data= s->current_frame;
if ((s->last_frame.data[0]) &&
(s->last_frame.data[0] != s->golden_frame.data[0]))
avctx->release_buffer(avctx, &s->last_frame);
s->last_frame= s->current_frame;
s->current_frame.data[0]= NULL;
return buf_size;
| 1threat
|
C++ Remove all non-number charachters from std::string : <p>What is an efficient way to remove all chars within in a string which are not in the range from 0 to 9?</p>
<pre><code>string s = "h3ll0";
string numbers = removeNonNumbersFromString(s);
cout << numbers << endl;
</code></pre>
<p>output should be <code>30</code></p>
| 0debug
|
what is the matter my java script : Its not working
what is the problem
i am trying put return values but browser not display anything :(
please help me
i newbie so please help me
<html>
<head></head>
<body>
<script type="text/javascript">
function (){
document.write(100+50);
}
function 2(){
document.write(100-50);
}
function 3(){
document.write(100/50);
}
function show(){
1();
2();
2();
}
show();
</script>
</body>
</html>
| 0debug
|
static void dec_sextb(DisasContext *dc)
{
LOG_DIS("sextb r%d, r%d\n", dc->r2, dc->r0);
if (!(dc->env->features & LM32_FEATURE_SIGN_EXTEND)) {
cpu_abort(dc->env, "hardware sign extender is not available\n");
}
tcg_gen_ext8s_tl(cpu_R[dc->r2], cpu_R[dc->r0]);
}
| 1threat
|
Get array [id] with json curl php : i use cloudflare API to create dns, iam use php cUrl to use the api, i am get result this :
Array ( [result] => Array ( [id] => 58fba3ebf4 [type] => A [name] => ser.domain.com [content] => 192.168.100.1 [proxiable] => [proxied] => [ttl] => 1 [priority] => 10 [locked] => [zone_id] => eb0d86828e3ac837c [zone_name] => domain.com [modified_on] => 2018-07-06T06:37:14.069598Z [created_on] => 2018-07-06T06:37:14.069598Z [meta] => Array ( [auto_added] => [managed_by_apps] => [managed_by_argo_tunnel] => ) ) [success] => 1 [errors] => Array ( ) [messages] => Array ( ) )
Now, How I Get one array, example i just get 'id' ?
| 0debug
|
int qemu_strtoll(const char *nptr, const char **endptr, int base,
int64_t *result)
{
char *p;
int err = 0;
if (!nptr) {
if (endptr) {
*endptr = nptr;
}
err = -EINVAL;
} else {
errno = 0;
*result = strtoll(nptr, &p, base);
err = check_strtox_error(endptr, p, errno);
}
return err;
}
| 1threat
|
how to show bar-code scanning screen always in android. : How to show bar-code scanning screen always in android.
IntentIntegrator integrator = new IntentIntegrator(activity);
| 0debug
|
static int adpcm_encode_frame(AVCodecContext *avctx,
unsigned char *frame, int buf_size, void *data)
{
int n, i, st;
short *samples;
unsigned char *dst;
ADPCMContext *c = avctx->priv_data;
dst = frame;
samples = (short *)data;
st= avctx->channels == 2;
switch(avctx->codec->id) {
case CODEC_ID_ADPCM_IMA_QT:
break;
case CODEC_ID_ADPCM_IMA_WAV:
n = avctx->frame_size / 8;
c->status[0].prev_sample = (signed short)samples[0];
bytestream_put_le16(&dst, c->status[0].prev_sample);
*dst++ = (unsigned char)c->status[0].step_index;
*dst++ = 0;
samples++;
if (avctx->channels == 2) {
c->status[1].prev_sample = (signed short)samples[1];
bytestream_put_le16(&dst, c->status[1].prev_sample);
*dst++ = (unsigned char)c->status[1].step_index;
*dst++ = 0;
samples++;
}
if(avctx->trellis > 0) {
uint8_t buf[2][n*8];
adpcm_compress_trellis(avctx, samples, buf[0], &c->status[0], n*8);
if(avctx->channels == 2)
adpcm_compress_trellis(avctx, samples+1, buf[1], &c->status[1], n*8);
for(i=0; i<n; i++) {
*dst++ = buf[0][8*i+0] | (buf[0][8*i+1] << 4);
*dst++ = buf[0][8*i+2] | (buf[0][8*i+3] << 4);
*dst++ = buf[0][8*i+4] | (buf[0][8*i+5] << 4);
*dst++ = buf[0][8*i+6] | (buf[0][8*i+7] << 4);
if (avctx->channels == 2) {
*dst++ = buf[1][8*i+0] | (buf[1][8*i+1] << 4);
*dst++ = buf[1][8*i+2] | (buf[1][8*i+3] << 4);
*dst++ = buf[1][8*i+4] | (buf[1][8*i+5] << 4);
*dst++ = buf[1][8*i+6] | (buf[1][8*i+7] << 4);
}
}
} else
for (; n>0; n--) {
*dst = adpcm_ima_compress_sample(&c->status[0], samples[0]) & 0x0F;
*dst |= (adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels]) << 4) & 0xF0;
dst++;
*dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 2]) & 0x0F;
*dst |= (adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 3]) << 4) & 0xF0;
dst++;
*dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 4]) & 0x0F;
*dst |= (adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 5]) << 4) & 0xF0;
dst++;
*dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 6]) & 0x0F;
*dst |= (adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 7]) << 4) & 0xF0;
dst++;
if (avctx->channels == 2) {
*dst = adpcm_ima_compress_sample(&c->status[1], samples[1]);
*dst |= adpcm_ima_compress_sample(&c->status[1], samples[3]) << 4;
dst++;
*dst = adpcm_ima_compress_sample(&c->status[1], samples[5]);
*dst |= adpcm_ima_compress_sample(&c->status[1], samples[7]) << 4;
dst++;
*dst = adpcm_ima_compress_sample(&c->status[1], samples[9]);
*dst |= adpcm_ima_compress_sample(&c->status[1], samples[11]) << 4;
dst++;
*dst = adpcm_ima_compress_sample(&c->status[1], samples[13]);
*dst |= adpcm_ima_compress_sample(&c->status[1], samples[15]) << 4;
dst++;
}
samples += 8 * avctx->channels;
}
break;
case CODEC_ID_ADPCM_SWF:
{
int i;
PutBitContext pb;
init_put_bits(&pb, dst, buf_size*8);
n = avctx->frame_size-1;
put_bits(&pb, 2, 2);
for(i=0; i<avctx->channels; i++){
c->status[i].step_index = av_clip(c->status[i].step_index, 0, 63);
put_bits(&pb, 16, samples[i] & 0xFFFF);
put_bits(&pb, 6, c->status[i].step_index);
c->status[i].prev_sample = (signed short)samples[i];
}
if(avctx->trellis > 0) {
uint8_t buf[2][n];
adpcm_compress_trellis(avctx, samples+2, buf[0], &c->status[0], n);
if (avctx->channels == 2)
adpcm_compress_trellis(avctx, samples+3, buf[1], &c->status[1], n);
for(i=0; i<n; i++) {
put_bits(&pb, 4, buf[0][i]);
if (avctx->channels == 2)
put_bits(&pb, 4, buf[1][i]);
}
} else {
for (i=1; i<avctx->frame_size; i++) {
put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels*i]) & 0xF);
if (avctx->channels == 2)
put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[1], samples[2*i+1]) & 0xF);
}
}
flush_put_bits(&pb);
dst += put_bits_count(&pb)>>3;
break;
}
case CODEC_ID_ADPCM_MS:
for(i=0; i<avctx->channels; i++){
int predictor=0;
*dst++ = predictor;
c->status[i].coeff1 = AdaptCoeff1[predictor];
c->status[i].coeff2 = AdaptCoeff2[predictor];
}
for(i=0; i<avctx->channels; i++){
if (c->status[i].idelta < 16)
c->status[i].idelta = 16;
bytestream_put_le16(&dst, c->status[i].idelta);
}
for(i=0; i<avctx->channels; i++){
c->status[i].sample1= *samples++;
bytestream_put_le16(&dst, c->status[i].sample1);
}
for(i=0; i<avctx->channels; i++){
c->status[i].sample2= *samples++;
bytestream_put_le16(&dst, c->status[i].sample2);
}
if(avctx->trellis > 0) {
int n = avctx->block_align - 7*avctx->channels;
uint8_t buf[2][n];
if(avctx->channels == 1) {
n *= 2;
adpcm_compress_trellis(avctx, samples, buf[0], &c->status[0], n);
for(i=0; i<n; i+=2)
*dst++ = (buf[0][i] << 4) | buf[0][i+1];
} else {
adpcm_compress_trellis(avctx, samples, buf[0], &c->status[0], n);
adpcm_compress_trellis(avctx, samples+1, buf[1], &c->status[1], n);
for(i=0; i<n; i++)
*dst++ = (buf[0][i] << 4) | buf[1][i];
}
} else
for(i=7*avctx->channels; i<avctx->block_align; i++) {
int nibble;
nibble = adpcm_ms_compress_sample(&c->status[ 0], *samples++)<<4;
nibble|= adpcm_ms_compress_sample(&c->status[st], *samples++);
*dst++ = nibble;
}
break;
case CODEC_ID_ADPCM_YAMAHA:
n = avctx->frame_size / 2;
if(avctx->trellis > 0) {
uint8_t buf[2][n*2];
n *= 2;
if(avctx->channels == 1) {
adpcm_compress_trellis(avctx, samples, buf[0], &c->status[0], n);
for(i=0; i<n; i+=2)
*dst++ = buf[0][i] | (buf[0][i+1] << 4);
} else {
adpcm_compress_trellis(avctx, samples, buf[0], &c->status[0], n);
adpcm_compress_trellis(avctx, samples+1, buf[1], &c->status[1], n);
for(i=0; i<n; i++)
*dst++ = buf[0][i] | (buf[1][i] << 4);
}
} else
for (; n>0; n--) {
for(i = 0; i < avctx->channels; i++) {
int nibble;
nibble = adpcm_yamaha_compress_sample(&c->status[i], samples[i]);
nibble |= adpcm_yamaha_compress_sample(&c->status[i], samples[i+avctx->channels]) << 4;
*dst++ = nibble;
}
samples += 2 * avctx->channels;
}
break;
default:
return -1;
}
return dst - frame;
}
| 1threat
|
MongoDB - Error: document must have an _id before saving : <p>I've been struggling so much with this project. I am following a tutorial that is out of date in some areas, for instance their version of Jquery used a totally different format for some functions and I had to do a lot of changing around. But I think I am down to one last major problem that I can't seem to find a fix for. In my Schema variable I've got the _id, username, and password types</p>
<pre><code>var UserSchema = new mongoose.Schema({
_id: mongoose.Schema.ObjectId,
username: String,
password: String
});
</code></pre>
<p>but when I go to try to add a new user to my app, instead of getting the alert I am supposed to get, it pops up as [object Object] and nothing gets added to the database. Then this error pops up in the mongo cmd </p>
<blockquote>
<p>"Error: document must have an _id before saving".</p>
</blockquote>
<p>I've tried commenting out the _id line and I get the right message but still nothing shows up in my database.</p>
| 0debug
|
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
| 1threat
|
static int vaapi_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
{
struct MpegEncContext * const s = avctx->priv_data;
struct vaapi_context * const vactx = avctx->hwaccel_context;
VAPictureParameterBufferMPEG2 *pic_param;
VAIQMatrixBufferMPEG2 *iq_matrix;
int i;
av_dlog(avctx, "vaapi_mpeg2_start_frame()\n");
vactx->slice_param_size = sizeof(VASliceParameterBufferMPEG2);
pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferMPEG2));
if (!pic_param)
return -1;
pic_param->horizontal_size = s->width;
pic_param->vertical_size = s->height;
pic_param->forward_reference_picture = VA_INVALID_ID;
pic_param->backward_reference_picture = VA_INVALID_ID;
pic_param->picture_coding_type = s->pict_type;
pic_param->f_code = mpeg2_get_f_code(s);
pic_param->picture_coding_extension.value = 0;
pic_param->picture_coding_extension.bits.intra_dc_precision = s->intra_dc_precision;
pic_param->picture_coding_extension.bits.picture_structure = s->picture_structure;
pic_param->picture_coding_extension.bits.top_field_first = s->top_field_first;
pic_param->picture_coding_extension.bits.frame_pred_frame_dct = s->frame_pred_frame_dct;
pic_param->picture_coding_extension.bits.concealment_motion_vectors = s->concealment_motion_vectors;
pic_param->picture_coding_extension.bits.q_scale_type = s->q_scale_type;
pic_param->picture_coding_extension.bits.intra_vlc_format = s->intra_vlc_format;
pic_param->picture_coding_extension.bits.alternate_scan = s->alternate_scan;
pic_param->picture_coding_extension.bits.repeat_first_field = s->repeat_first_field;
pic_param->picture_coding_extension.bits.progressive_frame = s->progressive_frame;
pic_param->picture_coding_extension.bits.is_first_field = mpeg2_get_is_frame_start(s);
switch (s->pict_type) {
case AV_PICTURE_TYPE_B:
pic_param->backward_reference_picture = ff_vaapi_get_surface_id(&s->next_picture.f);
case AV_PICTURE_TYPE_P:
pic_param->forward_reference_picture = ff_vaapi_get_surface_id(&s->last_picture.f);
break;
}
iq_matrix = ff_vaapi_alloc_iq_matrix(vactx, sizeof(VAIQMatrixBufferMPEG2));
if (!iq_matrix)
return -1;
iq_matrix->load_intra_quantiser_matrix = 1;
iq_matrix->load_non_intra_quantiser_matrix = 1;
iq_matrix->load_chroma_intra_quantiser_matrix = 1;
iq_matrix->load_chroma_non_intra_quantiser_matrix = 1;
for (i = 0; i < 64; i++) {
int n = s->dsp.idct_permutation[ff_zigzag_direct[i]];
iq_matrix->intra_quantiser_matrix[i] = s->intra_matrix[n];
iq_matrix->non_intra_quantiser_matrix[i] = s->inter_matrix[n];
iq_matrix->chroma_intra_quantiser_matrix[i] = s->chroma_intra_matrix[n];
iq_matrix->chroma_non_intra_quantiser_matrix[i] = s->chroma_inter_matrix[n];
}
return 0;
}
| 1threat
|
CONCATENATION IN CASE WHEN STATEMENT : I WANTED TO CHECK IF ALL THE TABLE_NAMES TO BE CREATED ARE EXISTING. IF EXISTING, WE NEED TO DROP THEM FIRST. THIS IS THE LOGIC THAT I'VE CREATED, THIS IS MY FIRST TIME TO CONCAT USING CASE WHEN. THE ERROR HERE IS THAT CONCAT CANNOT BE READ IN CASE WHEN. IS THERE ANY OTHER WAY TO CHECK IF TABLE NAMES ARE EXISTING? OR IS THERE A WAY TO PROCEED WITH THIS LOGIC WITH SUGGESTIONS OF TO FIX THIS THANK YOU!
`enter code here SET SERVEROUTPUT ON;
DECLARE
v_bs_drop_table VARCHAR2(50);
v_ebi_drop_table VARCHAR2(50);
BEGIN
FOR rec IN (SELECT table_name FROM user_tables WHERE LOWER(table_name) LIKE 'mpiat_after_bs_%')
LOOP
CASE rec.table_name
WHEN 'mpiat_after_bs_' || SUBSTR(TO_CHAR(SYSDATE, 'ddmonyy'), 3, 5) || '_t'
THEN
v_bs_drop_table := 'DROP TABLE ' || 'mpiat_after_bs_' || SUBSTR(TO_CHAR(SYSDATE, 'ddmonyy'), 3, 5) || '_t';
DBMS_OUTPUT.PUT_LINE(v_bs_drop_table);
EXECUTE IMMEDIATE v_bs_drop_table;
WHEN 'mpiat_after_bs_ebi_' || SUBSTR(TO_CHAR(SYSDATE, 'ddmonyy'), 3, 5) || '_t'
THEN
v_ebi_drop_table := 'DROP TABLE ' || 'mpiat_after_bs_ebi_' || SUBSTR(TO_CHAR(SYSDATE, 'ddmonyy'), 3, 5) || '_t';
DBMS_OUTPUT.PUT_LINE(v_ebi_drop_table);
EXECUTE IMMEDIATE v_ebi_drop_table;
ELSE
DBMS_OUTPUT.PUT_LINE('NO EXISTING TABLE NAMES');
END CASE;
END LOOP;
END;`
| 0debug
|
Find usages of lombok generated constructor in Intellij : <p>I have a class with lombok annotation (either <code>@Value</code> or <code>@Data</code>) and I am looking for an easy way to find usages of the auto generated constructor.</p>
<p>What I can do now is to find a one use of the constructor, put the cursor there and run 'Find usages' command and I get the results I want.</p>
<p>However I would like to do this directly from the class declaration. Is there a way to do that?</p>
| 0debug
|
BeerAdviser application : <p>I am reading a book on android development and it has a following example</p>
<pre><code> for
(String brand:brandlist)
{
brandsFormatted.append(brand).append('\n');
}
</code></pre>
<p>This is the .java code for the application.
Can anyone please explain me what happens in the for loop?
I did not understand
I am a beginner and I tried searching on the internet but did not understand this particular part.
Can anyone help me please?
Thank you</p>
| 0debug
|
static int img_resize(int argc, char **argv)
{
int c, ret, relative;
const char *filename, *fmt, *size;
int64_t n, total_size;
BlockDriverState *bs = NULL;
QemuOpts *param;
static QemuOptsList resize_options = {
.name = "resize_options",
.head = QTAILQ_HEAD_INITIALIZER(resize_options.head),
.desc = {
{
.name = BLOCK_OPT_SIZE,
.type = QEMU_OPT_SIZE,
.help = "Virtual disk size"
}, {
}
},
};
if (argc < 3) {
help();
return 1;
}
size = argv[--argc];
fmt = NULL;
for(;;) {
c = getopt(argc, argv, "f:h");
if (c == -1) {
break;
}
switch(c) {
case '?':
case 'h':
help();
break;
case 'f':
fmt = optarg;
break;
}
}
if (optind >= argc) {
help();
}
filename = argv[optind++];
switch (size[0]) {
case '+':
relative = 1;
size++;
break;
case '-':
relative = -1;
size++;
break;
default:
relative = 0;
break;
}
param = qemu_opts_create(&resize_options, NULL, 0, NULL);
if (qemu_opt_set(param, BLOCK_OPT_SIZE, size)) {
ret = -1;
qemu_opts_del(param);
goto out;
}
n = qemu_opt_get_size(param, BLOCK_OPT_SIZE, 0);
qemu_opts_del(param);
bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR);
if (!bs) {
ret = -1;
goto out;
}
if (relative) {
total_size = bdrv_getlength(bs) + n * relative;
} else {
total_size = n;
}
if (total_size <= 0) {
error_report("New image size must be positive");
ret = -1;
goto out;
}
ret = bdrv_truncate(bs, total_size);
switch (ret) {
case 0:
printf("Image resized.\n");
break;
case -ENOTSUP:
error_report("This image does not support resize");
break;
case -EACCES:
error_report("Image is read-only");
break;
default:
error_report("Error resizing image (%d)", -ret);
break;
}
out:
if (bs) {
bdrv_delete(bs);
}
if (ret) {
return 1;
}
return 0;
}
| 1threat
|
Why it can work in windows but can't work in Linux? : <p>My code is as follows.</p>
<p>When I use Visual Studio to compile , debug and execute, it's right. And when I use 'gcc' to compile , it's also right, but it's wrong when execute in Linux. The memory is wrong when it run.</p>
<p>And when print 'szBuf', the wrong is can't access the memory.</p>
<p>I want to know why it can work when in Windows but can't work in Linux?</p>
<pre><code>#include <stdio.h>
void ItoA(int nNum, char *pStr);
void Print(const char *pFormat, ...);
int main()
{
char ch = 'a';
int nNum = 11;
char szBuf[255] = "";
Print("ch: %c\n", ch);
Print("n: %d\n", nNum);
Print("s: %s\n", szBuf);
return 0;
}
void ItoA(int nNum, char *pStr)
{
if (NULL != pStr)
{
char szNum[255] = "";
int i = 0;
for (i = 0; 0 != nNum; i++)
{
szNum[i] = nNum % 10 + '0';
nNum /= 10;
}
for (i = i - 1; i >= 0; i--, pStr++)
{
*pStr = szNum[i];
}
*pStr = '\0';
}
}
void Print(const char *pFormat, ...)
{
if (NULL != pFormat)
{
char *pTemp = (char *)&pFormat;
pTemp += 4;
while ('\0' != *pFormat)
{
if ('%' == *pFormat)
{
pFormat++;
switch (*pFormat)
{
case 'c':
{
putchar(*pTemp);
pTemp += 4;
}
break;
case 'd':
{
char szBuf[255] = "";
int nNum = 0;
ItoA(*(int *)pTemp, szBuf);
for (int i = 0; '\0' != szBuf[i]; i++)
{
putchar(szBuf[i]);
}
pTemp += 4;
}
break;
case 's':
{
for (int i = 0; '\0' != (*(char **)pTemp)[i]; i++)
{
putchar((*(char **)pTemp)[i]);
}
pTemp += 4;
}
break;
default:
{
pFormat--;
putchar(*pTemp);
}
break;
}
}
else
{
putchar(*pFormat);
}
pFormat++;
}
}
}
</code></pre>
| 0debug
|
Python - JavaScript Explanation : So if anyone is knowledgeable on Animal Shelter Manager, I'm looking for some help. I'm trying to figure out what each line of code means.. the first is
from animalcontrol.py
def get_animalcontrol_query(dbo):
return "SELECT ac.*, ac.ID AS ACID, s.SpeciesName, x.Sex AS SexName, " \
"co.OwnerName AS CallerName, co.HomeTelephone, co.WorkTelephone, co.MobileTelephone, " \
"o1.OwnerName AS OwnerName, o1.OwnerName AS OwnerName1, o2.OwnerName AS OwnerName2, o3.OwnerName AS OwnerName3, " \
"o1.OwnerName AS SuspectName, o1.OwnerAddress AS SuspectAddress, o1.OwnerTown AS SuspectTown, o1.OwnerCounty AS SuspectCounty, o1.OwnerPostcode AS SuspectPostcode, " \
"o1.HomeTelephone AS SuspectHomeTelephone, o1.WorkTelephone AS SuspectWorkTelephone, o1.MobileTelephone AS SuspectMobileTelephone, " \
"vo.OwnerName AS VictimName, vo.OwnerAddress AS VictimAddress, vo.OwnerTown AS VictimTown, vo.OwnerCounty AS VictimCounty, vo.OwnerPostcode AS VictimPostcode," \
"vo.HomeTelephone AS VictimHomeTelephone, vo.WorkTelephone AS VictimWorkTelephone, vo.MobileTelephone AS VictimMobileTelephone, " \
"ti.IncidentName, ci.CompletedName, pl.LocationName " \
"FROM animalcontrol ac " \
"LEFT OUTER JOIN species s ON s.ID = ac.SpeciesID " \
"LEFT OUTER JOIN lksex x ON x.ID = ac.Sex " \
"LEFT OUTER JOIN owner co ON co.ID = ac.CallerID " \
"LEFT OUTER JOIN owner o1 ON o1.ID = ac.OwnerID " \
"LEFT OUTER JOIN owner o2 ON o2.ID = ac.Owner2ID " \
"LEFT OUTER JOIN owner o3 ON o3.ID = ac.Owner3ID " \
"LEFT OUTER JOIN owner vo ON vo.ID = ac.VictimID " \
"LEFT OUTER JOIN pickuplocation pl ON pl.ID = ac.PickupLocationID " \
"LEFT OUTER JOIN incidenttype ti ON ti.ID = ac.IncidentTypeID " \
"LEFT OUTER JOIN incidentcompleted ci ON ci.ID = ac.IncidentCompletedID"
What does `return "SELECT ac.*, ac.ID AS ACID,` mean.
and if I wanted to differ this code from what it is currently what would I have to change. ei "ac." or "ACID"
I know I will have to change `def get_animalcontrol_query(dbo):`
| 0debug
|
Airflow Python Unit Test? : <p>I'd like to add some unit tests for our DAGs, but could not find any. Is there a framework for unit test for DAGs? There is an End-to-End testing framework that exists but I guess it's dead: <a href="https://issues.apache.org/jira/browse/AIRFLOW-79" rel="noreferrer">https://issues.apache.org/jira/browse/AIRFLOW-79</a>. Please suggest, Thanks!</p>
| 0debug
|
aws lambda execution after callback guaranteed? : <p>My node4 lambda function called via API GW makes a sequence of slow API calls.
In order to not let users wait until everything completes, I'm planning to have my code look like this:</p>
<pre><code>function(event, context, callback) {
...
// Return users API GW call now
callback(null, data);
// Do the heavy lifting afterwards.
longApiCall().then(otherLongApiCalls)
}
</code></pre>
<p>But now I read in the <a href="http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html" rel="noreferrer">AWS docs</a>:
"the callback will wait until the Node.js runtime event loop is empty before freezing the process and returning the results to the caller"</p>
<p>Does that mean the API GW returns the response data before or after the longApiCalls complete?</p>
<p>If after, is there a suggested way for how to "return early" before everything is finished?</p>
| 0debug
|
How to fix null object that appears all the time on my phone and sometimes on my emulator : got a probleme with Android studio. I'm trying to do a pretty simple app but on my phone (Galaxy S8) it always gives me the same error. And i use two computer it does the same at home and at school. When i use the emulator, i have the problem also on the emulator at home that is not the same from school but not in School.
So on the emulator at school, the one that works i had the same error as all the other place but juste once and ive tried it a lot of time. But later in the program i have the same kind of error that appears but in some other function. So far i havent been able to go past that.
The error is saying that im trying to do something on a null object (a layout or a text view). The error that happens always on my phone is as soon as i try to use a constraint layer it wont work. The other one that happens late in the program on the emulator seems really random. Its a game of card the 98 card game. And at some time when i try to drop a card on one of the pile it give me the null object error on the same textView. I have really tried but cant see any pattern on this one.
```
public Boolean checkEndOfGame(LinearLayout cartes, LinearLayout piles){
if(nbCartes == 0){
return true;
}
for (int i=0; i< piles.getChildCount(); i++){
LinearLayout sorte = (LinearLayout)piles.getChildAt(i);
for(int j=0; j< sorte.getChildCount(); j++){
if(sorte.getChildAt(j) instanceof ConstraintLayout){
ConstraintLayout pile = (ConstraintLayout)sorte.getChildAt(j);
TextView textePile = (TextView) pile.getChildAt(0);
Integer noPile = new Integer(textePile.getText().toString());
for(int k=0; k< cartes.getChildCount(); k++){
LinearLayout rangee = (LinearLayout)cartes.getChildAt(i);
for(int l=0; l< rangee.getChildCount(); l++){
ConstraintLayout carte = (ConstraintLayout)rangee.getChildAt(l);
TextView texteCarte = (TextView) carte.getChildAt(0);
Integer noCarte = new Integer(texteCarte.getText().toString());
if(i>0){ //UP
if(noCarte>noPile){
return false;
}
}else{ //DOWN
if(noCarte<noPile){
return false;
}
}
}
}
}
}
}
return true;
}
```
So this is the function that gives me the random error always on that last TextView.
I give it carte and piles that are layout that contains each two other linearlayout. And in those there constraintLayout and in each constraintLayout theres a textView wich i can drag and drop.
| 0debug
|
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
{
AVFrame *frame = data;
DxaDecContext * const c = avctx->priv_data;
uint8_t *outptr, *srcptr, *tmpptr;
unsigned long dsize;
int i, j, compr, ret;
int stride;
int pc = 0;
GetByteContext gb;
bytestream2_init(&gb, avpkt->data, avpkt->size);
if (bytestream2_peek_le32(&gb) == MKTAG('C','M','A','P')) {
bytestream2_skip(&gb, 4);
for(i = 0; i < 256; i++){
c->pal[i] = 0xFFU << 24 | bytestream2_get_be24(&gb);
}
pc = 1;
}
if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
return ret;
memcpy(frame->data[1], c->pal, AVPALETTE_SIZE);
frame->palette_has_changed = pc;
outptr = frame->data[0];
srcptr = c->decomp_buf;
tmpptr = c->prev->data[0];
stride = frame->linesize[0];
if (bytestream2_get_le32(&gb) == MKTAG('N','U','L','L'))
compr = -1;
else
compr = bytestream2_get_byte(&gb);
dsize = c->dsize;
if (compr != 4 && compr != -1) {
bytestream2_skip(&gb, 4);
if (uncompress(c->decomp_buf, &dsize, avpkt->data + bytestream2_tell(&gb),
bytestream2_get_bytes_left(&gb)) != Z_OK) {
av_log(avctx, AV_LOG_ERROR, "Uncompress failed!\n");
return AVERROR_UNKNOWN;
}
memset(c->decomp_buf + dsize, 0, DECOMP_BUF_PADDING);
}
if (avctx->debug & FF_DEBUG_PICT_INFO)
av_log(avctx, AV_LOG_DEBUG, "compr:%2d, dsize:%d\n", compr, (int)dsize);
switch(compr){
case -1:
frame->key_frame = 0;
frame->pict_type = AV_PICTURE_TYPE_P;
if (c->prev->data[0])
memcpy(frame->data[0], c->prev->data[0], frame->linesize[0] * avctx->height);
else{
memset(frame->data[0], 0, frame->linesize[0] * avctx->height);
frame->key_frame = 1;
frame->pict_type = AV_PICTURE_TYPE_I;
}
break;
case 2:
case 4:
frame->key_frame = 1;
frame->pict_type = AV_PICTURE_TYPE_I;
for (j = 0; j < avctx->height; j++) {
memcpy(outptr, srcptr, avctx->width);
outptr += stride;
srcptr += avctx->width;
}
break;
case 3:
case 5:
if (!tmpptr) {
av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n");
if (!(avctx->flags2 & CODEC_FLAG2_SHOW_ALL))
return AVERROR_INVALIDDATA;
}
frame->key_frame = 0;
frame->pict_type = AV_PICTURE_TYPE_P;
for (j = 0; j < avctx->height; j++) {
if(tmpptr){
for(i = 0; i < avctx->width; i++)
outptr[i] = srcptr[i] ^ tmpptr[i];
tmpptr += stride;
}else
memcpy(outptr, srcptr, avctx->width);
outptr += stride;
srcptr += avctx->width;
}
break;
case 12:
case 13:
frame->key_frame = 0;
frame->pict_type = AV_PICTURE_TYPE_P;
if (!c->prev->data[0]) {
av_log(avctx, AV_LOG_ERROR, "Missing reference frame\n");
return AVERROR_INVALIDDATA;
}
decode_13(avctx, c, frame->data[0], frame->linesize[0], srcptr, c->prev->data[0]);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown/unsupported compression type %d\n", compr);
return AVERROR_INVALIDDATA;
}
av_frame_unref(c->prev);
if ((ret = av_frame_ref(c->prev, frame)) < 0)
return ret;
*got_frame = 1;
return avpkt->size;
}
| 1threat
|
Need some help porting Java code Android Studio to C# Visual Studio : <p>I need some help porting a piece of Java code to C#. The code is about a post request to a web api, to make the connection I used Volley in Java and I've already installed the NuGet in Visual Studio. I have trouble converting a StringRequest function to C#.</p>
<p>This is the piece of code that I'm currently trying to port in C# but I get errors when declaring the params in C#. For example it doesn't recognize the Request.Method and the new Response.Listener.</p>
<pre><code>StringRequest stringRequest = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>()
{
@Override
public void onResponse(String response)
{
Log.i("Volley Response", response);
}
}, new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error)
{
Log.e("Volley Error", error.toString());
}
})
{
@Override
public String getBodyContentType()
{
return "application/json; charset=utf-8";
}
@Override
public byte[] getBody()
{
try
{
return requestBody.getBytes("utf-8");
}
catch (UnsupportedEncodingException uee)
{
return null;
}
}
};
requestQueue.add(stringRequest);
return stringRequest;
</code></pre>
<p>If someone could be so nice to help me porting it to C# I would be very happy.</p>
| 0debug
|
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
| 1threat
|
'react-scripts' is not recognized as an internal or external command : <p>I've got a maven project, within which is JavaScript project cloned as a git sub-module. So the directory structure looks something like</p>
<p><code>mavenapp/src/main/javascript/[npm project files]</code></p>
<p>inside my package.json, the test looks like this : <code>"test": "react-scripts test --env=jsdom",</code></p>
<p>but when I try to run npm test is says </p>
<blockquote>
<p>'react-scripts' is not recognized as an internal or external command,</p>
</blockquote>
<p>Interestingly when I clone the javascript project independently I don't get this error. I've tried re-running <code>npm install</code>. </p>
<p><code>npm version : 5.5.1</code></p>
<p><code>node version : 9.3.0</code></p>
| 0debug
|
static void ahci_hba_enable(AHCIQState *ahci)
{
uint32_t reg, ports_impl;
uint16_t i;
uint8_t num_cmd_slots;
g_assert(ahci != NULL);
ahci_set(ahci, AHCI_GHC, AHCI_GHC_AE);
reg = ahci_rreg(ahci, AHCI_GHC);
ASSERT_BIT_SET(reg, AHCI_GHC_AE);
ahci->cap = ahci_rreg(ahci, AHCI_CAP);
ahci->cap2 = ahci_rreg(ahci, AHCI_CAP2);
num_cmd_slots = ((ahci->cap & AHCI_CAP_NCS) >> ctzl(AHCI_CAP_NCS)) + 1;
g_test_message("Number of Command Slots: %u", num_cmd_slots);
ports_impl = ahci_rreg(ahci, AHCI_PI);
for (i = 0; ports_impl; ports_impl >>= 1, ++i) {
if (!(ports_impl & 0x01)) {
continue;
}
g_test_message("Initializing port %u", i);
reg = ahci_px_rreg(ahci, i, AHCI_PX_CMD);
if (BITCLR(reg, AHCI_PX_CMD_ST | AHCI_PX_CMD_CR |
AHCI_PX_CMD_FRE | AHCI_PX_CMD_FR)) {
g_test_message("port is idle");
} else {
g_test_message("port needs to be idled");
ahci_px_clr(ahci, i, AHCI_PX_CMD,
(AHCI_PX_CMD_ST | AHCI_PX_CMD_FRE));
usleep(500000);
reg = ahci_px_rreg(ahci, i, AHCI_PX_CMD);
ASSERT_BIT_CLEAR(reg, AHCI_PX_CMD_CR);
ASSERT_BIT_CLEAR(reg, AHCI_PX_CMD_FR);
g_test_message("port is now idle");
}
ahci->port[i].clb = ahci_alloc(ahci, num_cmd_slots * 0x20);
qmemset(ahci->port[i].clb, 0x00, 0x100);
g_test_message("CLB: 0x%08" PRIx64, ahci->port[i].clb);
ahci_px_wreg(ahci, i, AHCI_PX_CLB, ahci->port[i].clb);
g_assert_cmphex(ahci->port[i].clb, ==,
ahci_px_rreg(ahci, i, AHCI_PX_CLB));
ahci->port[i].fb = ahci_alloc(ahci, 0x100);
qmemset(ahci->port[i].fb, 0x00, 0x100);
g_test_message("FB: 0x%08" PRIx64, ahci->port[i].fb);
ahci_px_wreg(ahci, i, AHCI_PX_FB, ahci->port[i].fb);
g_assert_cmphex(ahci->port[i].fb, ==,
ahci_px_rreg(ahci, i, AHCI_PX_FB));
ahci_px_wreg(ahci, i, AHCI_PX_SERR, 0xFFFFFFFF);
ahci_px_wreg(ahci, i, AHCI_PX_IS, 0xFFFFFFFF);
ahci_wreg(ahci, AHCI_IS, (1 << i));
reg = ahci_px_rreg(ahci, i, AHCI_PX_SERR);
g_assert_cmphex(reg, ==, 0);
reg = ahci_px_rreg(ahci, i, AHCI_PX_IS);
g_assert_cmphex(reg, ==, 0);
reg = ahci_rreg(ahci, AHCI_IS);
ASSERT_BIT_CLEAR(reg, (1 << i));
ahci_px_wreg(ahci, i, AHCI_PX_IE, 0xFFFFFFFF);
reg = ahci_px_rreg(ahci, i, AHCI_PX_IE);
g_assert_cmphex(reg, ==, ~((uint32_t)AHCI_PX_IE_RESERVED));
ahci_px_set(ahci, i, AHCI_PX_CMD, AHCI_PX_CMD_FRE);
reg = ahci_px_rreg(ahci, i, AHCI_PX_CMD);
ASSERT_BIT_SET(reg, AHCI_PX_CMD_FR);
reg = ahci_px_rreg(ahci, i, AHCI_PX_SERR);
if (BITSET(reg, AHCI_PX_SERR_DIAG_X)) {
ahci_px_set(ahci, i, AHCI_PX_SERR, AHCI_PX_SERR_DIAG_X);
}
reg = ahci_px_rreg(ahci, i, AHCI_PX_TFD);
if (BITCLR(reg, AHCI_PX_TFD_STS_BSY | AHCI_PX_TFD_STS_DRQ)) {
reg = ahci_px_rreg(ahci, i, AHCI_PX_SSTS);
if ((reg & AHCI_PX_SSTS_DET) == SSTS_DET_ESTABLISHED) {
ahci_px_set(ahci, i, AHCI_PX_CMD, AHCI_PX_CMD_ST);
ASSERT_BIT_SET(ahci_px_rreg(ahci, i, AHCI_PX_CMD),
AHCI_PX_CMD_CR);
g_test_message("Started Device %u", i);
} else if ((reg & AHCI_PX_SSTS_DET)) {
g_assert_not_reached();
}
}
}
ahci_set(ahci, AHCI_GHC, AHCI_GHC_IE);
reg = ahci_rreg(ahci, AHCI_GHC);
ASSERT_BIT_SET(reg, AHCI_GHC_IE);
}
| 1threat
|
static void pci_bridge_region_init(PCIBridge *br)
{
PCIBus *parent = br->dev.bus;
uint16_t cmd = pci_get_word(br->dev.config + PCI_COMMAND);
pci_bridge_init_alias(br, &br->alias_pref_mem,
PCI_BASE_ADDRESS_MEM_PREFETCH,
"pci_bridge_pref_mem",
&br->address_space_mem,
parent->address_space_mem,
cmd & PCI_COMMAND_MEMORY);
pci_bridge_init_alias(br, &br->alias_mem,
PCI_BASE_ADDRESS_SPACE_MEMORY,
"pci_bridge_mem",
&br->address_space_mem,
parent->address_space_mem,
cmd & PCI_COMMAND_MEMORY);
pci_bridge_init_alias(br, &br->alias_io,
PCI_BASE_ADDRESS_SPACE_IO,
"pci_bridge_io",
&br->address_space_io,
parent->address_space_io,
cmd & PCI_COMMAND_IO);
}
| 1threat
|
VB - Structures and Split : I am having difficulty with my vb program as my structure array will not fill with data from a text file which has been split using the split command. Puzzled. Any suggestions would be great. Code is below.
Cheers
Ewan
Imports System.IO
Public Class Form1
Public Structure ScavRecord
Public latitude As String
Public longitude As String
Public message As String
Public encrypted As String
End Structure
Dim Scav(4) As ScavRecord
Dim nextScav As Integer
Private Sub btnView_Click(sender As Object, e As EventArgs) Handles btnView.Click
Dim read As New StreamReader("F:\Higher Computing Science\Assignment\files for candidates\messages.txt")
nextScav = 0
Do
Dim temp As String = read.ReadLine()
Dim seperated As String() = temp.Split(",")
Scav(nextScav).latitude = seperated(0)
Scav(nextScav).longitude = seperated(1)
Scav(nextScav).message = seperated(2)
nextScav = nextScav + 1
ListBox.Items.Add(Scav(nextScav).latitude)
ListBox.Items.Add(Scav(nextScav).longitude)
ListBox.Items.Add(Scav(nextScav).message)
Loop Until read.EndOfStream()
End Sub
End Class
| 0debug
|
void *kqemu_vmalloc(size_t size)
{
static int phys_ram_fd = -1;
static int phys_ram_size = 0;
const char *tmpdir;
char phys_ram_file[1024];
void *ptr;
struct statfs stfs;
if (phys_ram_fd < 0) {
tmpdir = getenv("QEMU_TMPDIR");
if (!tmpdir)
tmpdir = "/dev/shm";
if (statfs(tmpdir, &stfs) == 0) {
int64_t free_space;
int ram_mb;
extern int ram_size;
free_space = (int64_t)stfs.f_bavail * stfs.f_bsize;
if ((ram_size + 8192 * 1024) >= free_space) {
ram_mb = (ram_size / (1024 * 1024));
fprintf(stderr,
"You do not have enough space in '%s' for the %d MB of QEMU virtual RAM.\n",
tmpdir, ram_mb);
if (strcmp(tmpdir, "/dev/shm") == 0) {
fprintf(stderr, "To have more space available provided you have enough RAM and swap, do as root:\n"
"umount /dev/shm\n"
"mount -t tmpfs -o size=%dm none /dev/shm\n",
ram_mb + 16);
} else {
fprintf(stderr,
"Use the '-m' option of QEMU to diminish the amount of virtual RAM or use the\n"
"QEMU_TMPDIR environment variable to set another directory where the QEMU\n"
"temporary RAM file will be opened.\n");
}
fprintf(stderr, "Or disable the accelerator module with -no-kqemu\n");
exit(1);
}
}
snprintf(phys_ram_file, sizeof(phys_ram_file), "%s/qemuXXXXXX",
tmpdir);
if (mkstemp(phys_ram_file) < 0) {
fprintf(stderr,
"warning: could not create temporary file in '%s'.\n"
"Use QEMU_TMPDIR to select a directory in a tmpfs filesystem.\n"
"Using '/tmp' as fallback.\n",
tmpdir);
snprintf(phys_ram_file, sizeof(phys_ram_file), "%s/qemuXXXXXX",
"/tmp");
if (mkstemp(phys_ram_file) < 0) {
fprintf(stderr, "Could not create temporary memory file '%s'\n",
phys_ram_file);
exit(1);
}
}
phys_ram_fd = open(phys_ram_file, O_CREAT | O_TRUNC | O_RDWR, 0600);
if (phys_ram_fd < 0) {
fprintf(stderr, "Could not open temporary memory file '%s'\n",
phys_ram_file);
exit(1);
}
unlink(phys_ram_file);
}
size = (size + 4095) & ~4095;
ftruncate(phys_ram_fd, phys_ram_size + size);
ptr = mmap(NULL,
size,
PROT_WRITE | PROT_READ, MAP_SHARED,
phys_ram_fd, phys_ram_size);
if (ptr == MAP_FAILED) {
fprintf(stderr, "Could not map physical memory\n");
exit(1);
}
phys_ram_size += size;
return ptr;
}
| 1threat
|
Should I still set ConnectionRequestTimeout on Apache HttpClient if I don't use a custom connection manager? : <p>I am using <a href="https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/config/RequestConfig.html">Apache RequestConfig</a> to configure some timeouts on my <code>HttpClient</code>.</p>
<pre><code>RequestConfig config = RequestConfig.custom()
.setConnectTimeout(timeout)
.setSocketTimeout(timeout)
.setConnectionRequestTimeout(timeout) // Can I leave this out..
.build();
CloseableHttpClient httpClient = HttpClients.custom()
//.setConnectionManager(connectionManager) // ..if I don't use this
.setDefaultRequestConfig(config)
.build();
</code></pre>
<p>Does it make any sense to call <code>setConnectionRequestTimeout(timeout)</code> even I don't have a custom Connection Manager / Pool set up? </p>
<p>As far as I understand, <code>setConnectionRequestTimeout(timeout)</code> is used to set the time to wait for a connection from the connection manager/pool.</p>
<p>Note that I am not setting a Connection Manager on the <code>httpClient</code> (see commented line). </p>
| 0debug
|
static void q35_host_initfn(Object *obj)
{
Q35PCIHost *s = Q35_HOST_DEVICE(obj);
PCIHostState *phb = PCI_HOST_BRIDGE(obj);
memory_region_init_io(&phb->conf_mem, obj, &pci_host_conf_le_ops, phb,
"pci-conf-idx", 4);
memory_region_init_io(&phb->data_mem, obj, &pci_host_data_le_ops, phb,
"pci-conf-data", 4);
object_initialize(&s->mch, sizeof(s->mch), TYPE_MCH_PCI_DEVICE);
object_property_add_child(OBJECT(s), "mch", OBJECT(&s->mch), NULL);
qdev_prop_set_uint32(DEVICE(&s->mch), "addr", PCI_DEVFN(0, 0));
qdev_prop_set_bit(DEVICE(&s->mch), "multifunction", false);
object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_START, "int",
q35_host_get_pci_hole_start,
NULL, NULL, NULL, NULL);
object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_END, "int",
q35_host_get_pci_hole_end,
NULL, NULL, NULL, NULL);
object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_START, "int",
q35_host_get_pci_hole64_start,
NULL, NULL, NULL, NULL);
object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_END, "int",
q35_host_get_pci_hole64_end,
NULL, NULL, NULL, NULL);
object_property_add(obj, PCIE_HOST_MCFG_SIZE, "int",
q35_host_get_mmcfg_size,
NULL, NULL, NULL, NULL);
object_property_add_link(obj, MCH_HOST_PROP_RAM_MEM, TYPE_MEMORY_REGION,
(Object **) &s->mch.ram_memory,
qdev_prop_allow_set_link_before_realize, 0, NULL);
object_property_add_link(obj, MCH_HOST_PROP_PCI_MEM, TYPE_MEMORY_REGION,
(Object **) &s->mch.pci_address_space,
qdev_prop_allow_set_link_before_realize, 0, NULL);
object_property_add_link(obj, MCH_HOST_PROP_SYSTEM_MEM, TYPE_MEMORY_REGION,
(Object **) &s->mch.system_memory,
qdev_prop_allow_set_link_before_realize, 0, NULL);
object_property_add_link(obj, MCH_HOST_PROP_IO_MEM, TYPE_MEMORY_REGION,
(Object **) &s->mch.address_space_io,
qdev_prop_allow_set_link_before_realize, 0, NULL);
s->mch.pci_hole.begin = MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT +
MCH_HOST_BRIDGE_PCIEXBAR_MAX;
s->mch.pci_hole.end = IO_APIC_DEFAULT_ADDRESS;
}
| 1threat
|
Facebook and Twitter data scraping using perl : <p>I want to create a web dashboard where i can search any user by name from facebook, & twitter and then show all the details (public like educations about , likes ) on my dashboard.</p>
<p>How this can be done using perl?</p>
<p>I cant use graph API as it shows for only users allow my app (permission based.)</p>
<p>Please guide me .</p>
| 0debug
|
static uint64_t mv88w8618_pic_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
mv88w8618_pic_state *s = opaque;
switch (offset) {
case MP_PIC_STATUS:
return s->level & s->enabled;
default:
return 0;
}
}
| 1threat
|
qemu_irq qemu_irq_invert(qemu_irq irq)
{
qemu_irq_raise(irq);
return qemu_allocate_irqs(qemu_notirq, irq, 1)[0];
}
| 1threat
|
display data in sepcific format using php : <p>I have following output. I want to read it using php.
Please let me know how I can do that</p>
<pre><code> ?({"ip":"104.112.115.28","country_code":"US","country_name":"United States","region_code":"CA","region_name":"California","city":"Houston","zip_code":"90013","time_zone":"America/Los_Angeles","latitude":34.0453,"longitude":-118.2413,"metro_code":803});
</code></pre>
| 0debug
|
connection.query('SELECT * FROM users WHERE username = ' + input_string)
| 1threat
|
Having trouble with strings : <p>I AM ON WINDOWS</p>
<p>I am working on a project. I have downloaded android-7.jar and renamed it to android7.zip and extracted the files. That worked fine. Now I have the classes for android. My main focus is just the android.app.AlertDialog, but that had a lot of imports, so I am just using the entire android source. I have my own java file, com.tylerr147.dialog.showDialog</p>
<p>Here is that file:</p>
<pre><code>//javac com/tylerr147/dialog/showDialog.java
package com.tylerr147.dialog;
import android.app.*;
import android.os.*;
public class showDialog extends Activity {
AlertDialog.Builder adb = new AlertDialog.Builder(this);
adb.setTitle("hi");
public static void main(String[] args) {
}
}
</code></pre>
<p>The reason I have the AlertDialog stuff outside of the main() is because I cannot use the AlertDialog in a static method.</p>
<p>Everything has is fine except I am getting:</p>
<pre><code>com\tylerr147\dialog\showDialog.java:10: error: <identifier> expected
adb.setTitle("hi");
^
com\tylerr147\dialog\showDialog.java:10: error: illegal start of type
adb.setTitle("hi");
^
2 errors
</code></pre>
<p>I have no idea what is causing this problem. Any help is greatly appreciated.</p>
| 0debug
|
Can't create php register form : <p><a href="https://i.stack.imgur.com/5tNTV.png" rel="nofollow noreferrer">Image URL</a></p>
<p>Error:
Parse error: syntax error, unexpected end of file in D:\OSPanel\domains\register\signup.php on line 47</p>
| 0debug
|
Webpack 4 "size exceeds the recommended limit (244 KiB)" : <p>I have two files which are combined under 600 bytes (.6kb) as below.</p>
<p>So how is it that my app.bundle.js is so large (987kb) and more importantly how does one manage the size of it?</p>
<p>src file index.js</p>
<pre><code>import _ from 'lodash';
import printMe from './print.js';
function component() {
var element = document.createElement('div');
var btn = document.createElement('button');
// Lodash, now imported by this script
element.innerHTML = _.join(['Hello', 'webpack'], ' ');
btn.innerHTML = 'click and check console';
btn.onclick = printMe;
element.appendChild(btn);
return element;
}
document.body.appendChild(component());
</code></pre>
<p>src file print.js</p>
<pre><code>export default function printMe() {
consoe.log('Called from print.js');
}
</code></pre>
<p>webpack.config.js</p>
<pre><code>const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
entry: {
app: './src/index.js',
print:'./src/print.js'
},
devtool: 'inline-source-map',
plugins: [
new CleanWebpackPlugin(['dist']),
new HtmlWebpackPlugin({
title: 'Output Management'
})
],
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist')
}
};
</code></pre>
<p>package.json</p>
<pre><code>{
"name": "my-webpack-4-proj",
"version": "1.0.0",
"description": "",
"main": "index.js",
"mode": "development",
"scripts": {
"dev": "webpack --mode development",
"build": "webpack --mode production",
"watch": "webpack --watch",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"clean-webpack-plugin": "^0.1.19",
"css-loader": "^0.28.11",
"csv-loader": "^2.1.1",
"file-loader": "^1.1.11",
"html-webpack-plugin": "^3.0.6",
"style-loader": "^0.20.3",
"webpack": "^4.1.1",
"webpack-cli": "^2.0.12",
"xml-loader": "^1.2.1"
},
"dependencies": {
"express": "^4.16.3",
"lowdash": "^1.2.0"
}
}
</code></pre>
<p>Warning message:</p>
<blockquote>
<p>WARNING in asset size limit: The following asset(s) exceed the
recommended size limit (244 KiB). This can impact web performance.
Assets: app.bundle.js (964 KiB)</p>
</blockquote>
| 0debug
|
UISearchController filter using two strings : <p>I have been following the tutorial for creating a UISearchController using <a href="https://www.raywenderlich.com/113772/uisearchcontroller-tutorial" rel="nofollow noreferrer">https://www.raywenderlich.com/113772/uisearchcontroller-tutorial</a></p>
<p>Everything is set up and working perfectly. I have two categories in my dataArray: Borough and Neighborhood. I set up my searchBar to only look into the values for Neighborhood. I created buttons for the different boroughs and what i'm hoping to achieve is when the button is pressed it will show all the possible values for that borough, but I can't seem to find anything to do this</p>
| 0debug
|
TypeError: Cannot read property 'wanted' of undefined: : <p>I have been deploying functions with firebase successfully all day learning how to use it. I was trying to see what happened if I initialized another directory that deploys to the same project and had no problems until i updated my npm version and now I am getting "Unexpected error has occurred" whenever I try to deploy</p>
<p>I have tried updating npm permission by making my own user the owner of the node_modules, bin, and share directories. I have tried uninstalling and reinstalling firebase-tools. I have also tried deleting all my current function directories and initializing a fresh directory and reinstalling my dependencies in there fresh.</p>
<p>Here is the debug log</p>
<pre><code>Dylans-MacBook-Pro-3:functions dsenderling$ firebase deploy --debug
[2019-07-03T18:04:35.526Z] ----------------------------------------------------------------------
[2019-07-03T18:04:35.528Z] Command: /usr/local/bin/node /usr/local/bin/firebase deploy --debug
[2019-07-03T18:04:35.529Z] CLI Version: 7.0.2
[2019-07-03T18:04:35.529Z] Platform: darwin
[2019-07-03T18:04:35.529Z] Node Version: v10.16.0
[2019-07-03T18:04:35.529Z] Time: Wed Jul 03 2019 13:04:35 GMT-0500 (Central Daylight Time)
[2019-07-03T18:04:35.529Z] ----------------------------------------------------------------------
[2019-07-03T18:04:35.537Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2019-07-03T18:04:35.537Z] > authorizing via signed-in user
[2019-07-03T18:04:35.537Z] [iam] checking project my-awesome-project-5a4e9 for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]
[2019-07-03T18:04:35.539Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/my-awesome-project-5a4e9:testIamPermissions
permissions=[cloudfunctions.functions.create, cloudfunctions.functions.delete, cloudfunctions.functions.get, cloudfunctions.functions.list, cloudfunctions.functions.update, cloudfunctions.operations.get, firebase.projects.get]
[2019-07-03T18:04:35.769Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Wed, 03 Jul 2019 18:04:35 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, server-timing=gfet4t7; dur=83, alt-svc=quic=":443"; ma=2592000; v="46,43,39", accept-ranges=none, transfer-encoding=chunked
[2019-07-03T18:04:37.033Z] TypeError: Cannot read property 'wanted' of undefined
at /usr/local/lib/node_modules/firebase-tools/lib/checkFirebaseSDKVersion.js:37:51
at process._tickCallback (internal/process/next_tick.js:68:7)
Error: An unexpected error has occurred.
</code></pre>
<p>My gut tells me there is something wrong with firebase-tools or my firebase sdk but I can't figure out what. Thanks in advance</p>
| 0debug
|
static void monitor_find_completion(Monitor *mon,
const char *cmdline)
{
const char *cmdname;
char *args[MAX_ARGS];
int nb_args, i, len;
const char *ptype, *str;
const mon_cmd_t *cmd;
MonitorBlockComplete mbs;
parse_cmdline(cmdline, &nb_args, args);
#ifdef DEBUG_COMPLETION
for (i = 0; i < nb_args; i++) {
monitor_printf(mon, "arg%d = '%s'\n", i, args[i]);
}
#endif
len = strlen(cmdline);
if (len > 0 && qemu_isspace(cmdline[len - 1])) {
if (nb_args >= MAX_ARGS) {
goto cleanup;
}
args[nb_args++] = g_strdup("");
}
if (nb_args <= 1) {
if (nb_args == 0)
cmdname = "";
else
cmdname = args[0];
readline_set_completion_index(mon->rs, strlen(cmdname));
for (cmd = mon->cmd_table; cmd->name != NULL; cmd++) {
cmd_completion(mon, cmdname, cmd->name);
}
} else {
for (cmd = mon->cmd_table; cmd->name != NULL; cmd++) {
if (compare_cmd(args[0], cmd->name)) {
break;
}
}
if (!cmd->name) {
goto cleanup;
}
ptype = next_arg_type(cmd->args_type);
for(i = 0; i < nb_args - 2; i++) {
if (*ptype != '\0') {
ptype = next_arg_type(ptype);
while (*ptype == '?')
ptype = next_arg_type(ptype);
}
}
str = args[nb_args - 1];
if (*ptype == '-' && ptype[1] != '\0') {
ptype = next_arg_type(ptype);
}
switch(*ptype) {
case 'F':
readline_set_completion_index(mon->rs, strlen(str));
file_completion(mon, str);
break;
case 'B':
mbs.mon = mon;
mbs.input = str;
readline_set_completion_index(mon->rs, strlen(str));
bdrv_iterate(block_completion_it, &mbs);
break;
case 's':
if (!strcmp(cmd->name, "info")) {
readline_set_completion_index(mon->rs, strlen(str));
for(cmd = info_cmds; cmd->name != NULL; cmd++) {
cmd_completion(mon, str, cmd->name);
}
} else if (!strcmp(cmd->name, "sendkey")) {
char *sep = strrchr(str, '-');
if (sep)
str = sep + 1;
readline_set_completion_index(mon->rs, strlen(str));
for (i = 0; i < Q_KEY_CODE_MAX; i++) {
cmd_completion(mon, str, QKeyCode_lookup[i]);
}
} else if (!strcmp(cmd->name, "help|?")) {
readline_set_completion_index(mon->rs, strlen(str));
for (cmd = mon->cmd_table; cmd->name != NULL; cmd++) {
cmd_completion(mon, str, cmd->name);
}
}
break;
default:
break;
}
}
cleanup:
for (i = 0; i < nb_args; i++) {
g_free(args[i]);
}
}
| 1threat
|
Converting pandas.core.series.Series to dataframe with appropriate column values python : <p>i'm running a function in which a variable is of pandas.core.series.Series type.</p>
<pre><code>type of the series shown below.
<class 'pandas.core.series.Series'>
product_id_y 1159730
count 1
Name: 6159402, dtype: object
</code></pre>
<p>i want to convert this into a dataframe,such that, i get</p>
<pre><code>product_id_y count
1159730 1
</code></pre>
<p>i tried doing this:</p>
<pre><code>series1 = series1.to_frame()
</code></pre>
<p>but getting wrong result</p>
<p>after converting to dataframe</p>
<pre><code> 6159402
product_id_y 1159730
count 1
</code></pre>
<p>after doing reset index i'e <code>series1 = series1.reset_index()</code></p>
<pre><code> index 6159402
0 product_id_y 1159730
1 count 1
</code></pre>
<p>is there anny other way to do this??</p>
| 0debug
|
static void sys_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
LM32SysState *s = opaque;
char *testname;
trace_lm32_sys_memory_write(addr, value);
addr >>= 2;
switch (addr) {
case R_CTRL:
qemu_system_shutdown_request();
break;
case R_PASSFAIL:
s->regs[addr] = value;
testname = (char *)s->testname;
qemu_log("TC %-16s %s\n", testname, (value) ? "FAILED" : "OK");
break;
case R_TESTNAME:
s->regs[addr] = value;
copy_testname(s);
break;
default:
error_report("lm32_sys: write access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
}
| 1threat
|
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
| 1threat
|
static void test_qemu_strtosz_erange(void)
{
const char *str = "10E";
char *endptr = NULL;
int64_t res;
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, -ERANGE);
g_assert(endptr == str + 3);
}
| 1threat
|
static void gen_bxx(DisasContext *dc, uint32_t code, uint32_t flags)
{
I_TYPE(instr, code);
TCGLabel *l1 = gen_new_label();
tcg_gen_brcond_tl(flags, dc->cpu_R[instr.a], dc->cpu_R[instr.b], l1);
gen_goto_tb(dc, 0, dc->pc + 4);
gen_set_label(l1);
gen_goto_tb(dc, 1, dc->pc + 4 + (instr.imm16s & -4));
dc->is_jmp = DISAS_TB_JUMP;
}
| 1threat
|
int64_t bdrv_getlength(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
if (!drv)
return -ENOMEDIUM;
if (bs->growable || bs->removable) {
if (drv->bdrv_getlength) {
return drv->bdrv_getlength(bs);
}
}
return bs->total_sectors * BDRV_SECTOR_SIZE;
}
| 1threat
|
Show price instead of quantity in shopping cart wordpress : <p>On this website: <a href="https://www.stenenentegels.nl/" rel="nofollow noreferrer">https://www.stenenentegels.nl/</a></p>
<p>The shopping cart is in the top right corner of the website.
When it is not folded open it shows the quantity of the cart in the orange circle.
I want to show the price there instead of the quantity. Has someone a solution for this?</p>
<p>I used this plugin for the custom shopping cart: <a href="https://wordpress.org/plugins/woo-floating-cart-lite/" rel="nofollow noreferrer">https://wordpress.org/plugins/woo-floating-cart-lite/</a></p>
<p>I think the best way to achieve this is to write a function in the functions.php file.</p>
<p>Hope you guys can help me out!</p>
| 0debug
|
static int mxg_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret;
unsigned int size;
uint8_t *startmarker_ptr, *end, *search_end, marker;
MXGContext *mxg = s->priv_data;
while (!avio_feof(s->pb) && !s->pb->error){
if (mxg->cache_size <= OVERREAD_SIZE) {
ret = mxg_update_cache(s, DEFAULT_PACKET_SIZE + OVERREAD_SIZE);
if (ret < 0)
return ret;
}
end = mxg->buffer_ptr + mxg->cache_size;
if (mxg->cache_size > OVERREAD_SIZE) {
search_end = end - OVERREAD_SIZE;
startmarker_ptr = mxg_find_startmarker(mxg->buffer_ptr, search_end);
} else {
search_end = end;
startmarker_ptr = mxg_find_startmarker(mxg->buffer_ptr, search_end);
if (startmarker_ptr >= search_end - 1 ||
*(startmarker_ptr + 1) != EOI) break;
}
if (startmarker_ptr != search_end) {
marker = *(startmarker_ptr + 1);
mxg->buffer_ptr = startmarker_ptr + 2;
mxg->cache_size = end - mxg->buffer_ptr;
if (marker == SOI) {
mxg->soi_ptr = startmarker_ptr;
} else if (marker == EOI) {
if (!mxg->soi_ptr) {
av_log(s, AV_LOG_WARNING, "Found EOI before SOI, skipping\n");
continue;
}
pkt->pts = pkt->dts = mxg->dts;
pkt->stream_index = 0;
#if FF_API_DESTRUCT_PACKET
FF_DISABLE_DEPRECATION_WARNINGS
pkt->destruct = NULL;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
pkt->buf = NULL;
pkt->size = mxg->buffer_ptr - mxg->soi_ptr;
pkt->data = mxg->soi_ptr;
if (mxg->soi_ptr - mxg->buffer > mxg->cache_size) {
if (mxg->cache_size > 0) {
memcpy(mxg->buffer, mxg->buffer_ptr, mxg->cache_size);
}
mxg->buffer_ptr = mxg->buffer;
}
mxg->soi_ptr = 0;
return pkt->size;
} else if ( (SOF0 <= marker && marker <= SOF15) ||
(SOS <= marker && marker <= COM) ) {
size = AV_RB16(mxg->buffer_ptr);
if (size < 2)
return AVERROR(EINVAL);
if (mxg->cache_size < size) {
ret = mxg_update_cache(s, size);
if (ret < 0)
return ret;
startmarker_ptr = mxg->buffer_ptr - 2;
mxg->cache_size = 0;
} else {
mxg->cache_size -= size;
}
mxg->buffer_ptr += size;
if (marker == APP13 && size >= 16) {
pkt->pts = pkt->dts = AV_RL64(startmarker_ptr + 8);
pkt->stream_index = 1;
#if FF_API_DESTRUCT_PACKET
FF_DISABLE_DEPRECATION_WARNINGS
pkt->destruct = NULL;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
pkt->buf = NULL;
pkt->size = size - 14;
pkt->data = startmarker_ptr + 16;
if (startmarker_ptr - mxg->buffer > mxg->cache_size) {
if (mxg->cache_size > 0) {
memcpy(mxg->buffer, mxg->buffer_ptr, mxg->cache_size);
}
mxg->buffer_ptr = mxg->buffer;
}
return pkt->size;
} else if (marker == COM && size >= 18 &&
!strncmp(startmarker_ptr + 4, "MXF", 3)) {
mxg->dts = AV_RL64(startmarker_ptr + 12);
}
}
} else {
mxg->buffer_ptr = search_end;
mxg->cache_size = OVERREAD_SIZE;
}
}
return AVERROR_EOF;
}
| 1threat
|
void ff_rtp_send_h264(AVFormatContext *s1, const uint8_t *buf1, int size)
{
const uint8_t *r, *end = buf1 + size;
RTPMuxContext *s = s1->priv_data;
s->timestamp = s->cur_timestamp;
s->buf_ptr = s->buf;
if (s->nal_length_size)
r = ff_avc_mp4_find_startcode(buf1, end, s->nal_length_size) ? buf1 : end;
else
r = ff_avc_find_startcode(buf1, end);
while (r < end) {
const uint8_t *r1;
if (s->nal_length_size) {
r1 = ff_avc_mp4_find_startcode(r, end, s->nal_length_size);
if (!r1)
r1 = end;
r += s->nal_length_size;
} else {
while (!*(r++));
r1 = ff_avc_find_startcode(r, end);
}
nal_send(s1, r, r1 - r, r1 == end);
r = r1;
}
flush_buffered(s1, 1);
}
| 1threat
|
Heroku/python failed to detect set buildpack : <p>I'm a Django newbie, I created an app and want to deploy it using Heroku. However, when I do <code>git push heroku master</code> (I follow Heroku's getting started), this is what I got:</p>
<pre><code>Counting objects: 36, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (33/33), done.
Writing objects: 100% (36/36), 19.22 KiB | 0 bytes/s, done.
Total 36 (delta 3), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Failed to detect set buildpack https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote: ! Push failed
remote: Verifying deploy....
remote:
remote: ! Push rejected to dry-waters-63931.
remote:
To https://git.heroku.com/dry-waters-63931.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/dry-waters-63931.git'
</code></pre>
<p>My root directory:</p>
<pre><code>├── assignment
├── household_management (django app)
├── templates
|
├── db.sqlite3
|
├── manage.py
</code></pre>
<p>I will be very appreciated if you guys can help. I'm really depressed right now...</p>
| 0debug
|
python:The word in List can't be removed : [As you can see ,i'm trying to delete the word in a list whose length is 1 or 2 ,but "P" and "ye" can't be find and removed!][1]
[the result of mine][2]
[1]: http://i.stack.imgur.com/7kkKL.png
[2]: http://i.stack.imgur.com/0EEIe.png
| 0debug
|
R: Converting character text to date format : I have character text in the following format, **"Jan 10, 09:56"**, I need to convert it to date format like **01/10/2018 09:56**
| 0debug
|
Use existing Method instead of new Prameter : Im trying to finish this project and I cant figure how to use my existing method in my other method. i want to get rid of "VOWELS", which is defined right after the class, and I just want to use the method isVowel which returns a True or False after you type in a Char.
this is what I have
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
public class StringAndIO {
private static Scanner v;
static final String VOWELS = "AaEeIiOoUuÄäÖöÜü";
public static boolean isVowel(char c) {
if (c == 'a' || c == 'A' || c == 'e' || c == 'E' || c == 'i' || c == 'I' || c == 'o' || c == 'O' || c == 'u'
|| c == 'U' || c == 'ä' || c == 'Ä' || c == 'ö' || c == 'Ö' || c == 'ü' || c == 'Ü') {
return true;
} else {
return false;
}
}
public static String toPigLatin(String text) {
String ret = "";
String vowelbuf = "";
for (int i = 0; i < text.length(); ++i) {
char x = text.charAt(i);
if (VOWELS.indexOf(x) != -1) {
vowelbuf += x;
} else {
if (vowelbuf.length() > 0) {
ret += vowelbuf + "b" + vowelbuf + x;
vowelbuf = "";
} else {
ret += x;
}
}
}
if (vowelbuf.length() > 0) {
ret += vowelbuf + "b" + vowelbuf;
}
return ret;
}
/**
* only there for testing purpose
*/
public static void main(String[] args) {
v = new Scanner(System.in);
System.out.println("Enter a Char!");
char c = v.next().charAt(0);
System.out.println(isVowel(c));
String s = "Meine Mutter ißt gerne Fisch";
System.out.println(s);
System.out.println(toPigLatin(s));
System.out.println();
}
}
<!-- end snippet -->
| 0debug
|
Using @available with stored properties : <p>I have an app that uses local notifications and supports iOS 10. I am trying to add iOS 9 support which requires me to use the old location notification API. I am trying to use @available and #available on my iOS 10 code and I can't figure out how to get my center variable to only be for devices running iOS 10. </p>
<p>When I set my target from iOS 10 to 9 I get the error message for this variable: "UNUserNotificationCenter is only available on iOS 10.0 or newer." It suggests I add "@available(iOS 10.0, *)" to my entire class which I don't want to do since there is code in this class that will be used for iOS 9. I appreciate any suggestions on how to limit my center property to just iOS 10.</p>
<pre><code>class ViewController: UIViewController, UITextFieldDelegate {
let center = UNUserNotificationCenter.current()
...
</code></pre>
| 0debug
|
Typescript: React event types : <p>What is the correct type for React events. Initially I just used <code>any</code> for the sake of simplicity. Now, I am trying to clean things up and avoid use of <code>any</code> completely.</p>
<p>So in a simple form like this:</p>
<pre><code>export interface LoginProps {
login: {
[k: string]: string | Function
uname: string
passw: string
logIn: Function
}
}
@inject('login') @observer
export class Login extends Component<LoginProps, {}> {
update = (e: React.SyntheticEvent<EventTarget>): void => {
this.props.login[e.target.name] = e.target.value
}
submit = (e: any): void => {
this.props.login.logIn()
e.preventDefault()
}
render() {
const { uname, passw } = this.props.login
return (
<div id='login' >
<form>
<input
placeholder='Username'
type="text"
name='uname'
value={uname}
onChange={this.update}
/>
<input
placeholder='Password'
type="password"
name='passw'
value={passw}
onChange={this.update}
/>
<button type="submit" onClick={this.submit} >
Submit
</button>
</form>
</div>
)
}
}
</code></pre>
<p>What type do I use here as event type?</p>
<p><code>React.SyntheticEvent<EventTarget></code> does not seem to be working as I get an error that <code>name</code> and <code>value</code> do not exist on <code>target</code>.</p>
<p>More generalised answer for all events would be really appreciated.</p>
<p>Thanks</p>
| 0debug
|
I want to build a minimap for my HTML5 game, how do I start? : <p>Assume I have a big map which uses a background image as pattern. I want to place a minimap at the corner when I am moving the player around. All I need the minimap to do is to display where my player is in the big map and where are other sprites in the map, using a very coarse representation and keeping their relative location but shows everything in a much smaller map. So I think this is a very basic and simple minimap. My player will be in the middle of the screen (I have already done that) and the minimap will stay at the corner of the screen. If I want to build such a feature for my game, how do I start?</p>
| 0debug
|
FFAMediaCodec* ff_AMediaCodec_createDecoderByType(const char *mime)
{
JNIEnv *env = NULL;
FFAMediaCodec *codec = NULL;
jstring mime_type = NULL;
codec = av_mallocz(sizeof(FFAMediaCodec));
if (!codec) {
return NULL;
}
codec->class = &amediacodec_class;
env = ff_jni_get_env(codec);
if (!env) {
av_freep(&codec);
return NULL;
}
if (ff_jni_init_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec) < 0) {
goto fail;
}
mime_type = ff_jni_utf_chars_to_jstring(env, mime, codec);
if (!mime_type) {
goto fail;
}
codec->object = (*env)->CallStaticObjectMethod(env, codec->jfields.mediacodec_class, codec->jfields.create_decoder_by_type_id, mime_type);
if (ff_jni_exception_check(env, 1, codec) < 0) {
goto fail;
}
codec->object = (*env)->NewGlobalRef(env, codec->object);
if (!codec->object) {
goto fail;
}
if (codec_init_static_fields(codec) < 0) {
goto fail;
}
if (codec->jfields.get_input_buffer_id && codec->jfields.get_output_buffer_id) {
codec->has_get_i_o_buffer = 1;
}
return codec;
fail:
ff_jni_reset_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec);
if (mime_type) {
(*env)->DeleteLocalRef(env, mime_type);
}
av_freep(&codec);
return NULL;
}
| 1threat
|
static void vfio_probe_ati_bar2_quirk(VFIOPCIDevice *vdev, int nr)
{
VFIOQuirk *quirk;
VFIOConfigMirrorQuirk *mirror;
if (!vfio_pci_is(vdev, PCI_VENDOR_ID_ATI, PCI_ANY_ID) ||
!vdev->has_vga || nr != 2 || !vdev->bars[2].mem64) {
return;
}
quirk = g_malloc0(sizeof(*quirk));
mirror = quirk->data = g_malloc0(sizeof(*mirror));
mirror->mem = quirk->mem = g_malloc0(sizeof(MemoryRegion));
quirk->nr_mem = 1;
mirror->vdev = vdev;
mirror->offset = 0x4000;
mirror->bar = nr;
memory_region_init_io(mirror->mem, OBJECT(vdev),
&vfio_generic_mirror_quirk, mirror,
"vfio-ati-bar2-4000-quirk", PCI_CONFIG_SPACE_SIZE);
memory_region_add_subregion_overlap(&vdev->bars[nr].region.mem,
mirror->offset, mirror->mem, 1);
QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next);
trace_vfio_quirk_ati_bar2_probe(vdev->vbasedev.name);
}
| 1threat
|
How to replace between certain text : <p>Ok i have some text like below:</p>
<p>& leftsidetext sometext rightsidetext & %leftsidetext sometext rightsidetext%</p>
<p>Now i want to replace replacetext inside sometext just in:
& leftsidetext sometext rightsidetext &</p>
| 0debug
|
Oracle to PostGRESQL database reduces : Why does the database size reduce in PostgreSQL post migration from Oracle schema having lob, clob and blob datatypes
| 0debug
|
Database conneectivity in php and html : I have some doubts about connecting the data base
1.how do i connect the PHP file with database(php my admin)?
2.what code should i give to check the correct and incorrect passwords?
3.how do i connect the database with my html page?
actually i had tried a lot of programs to connect them,But in vain.
I have completed the layouts.Just the database connectivity is pending.
[this is the code i have done.Please see the image][1]
[1]: https://i.stack.imgur.com/NNnBO.jpg
| 0debug
|
Add text before select element : <p>So i sm working on a application, where i need to have a select element with this text: 'sort element by option' where option is the option selected inside the select element, the select element should have always the sort element by text, i tried to add a before element but it didn't work. I also tried to add it to options tag. It worked but i don't want the 'sort element by option' text inside the opened select. Inside i just want the value.</p>
<p>So i have this at the moment:</p>
<pre><code><select>
<option>option</option>
</select>
select::before {
content: 'Sort element by'
color: black
}
</code></pre>
<p>i am searching a html/css solution, any help would be appreciate :)</p>
| 0debug
|
static void vfio_probe_ati_bar4_quirk(VFIOPCIDevice *vdev, int nr)
{
VFIOQuirk *quirk;
VFIOConfigWindowQuirk *window;
if (!vfio_pci_is(vdev, PCI_VENDOR_ID_ATI, PCI_ANY_ID) ||
!vdev->has_vga || nr != 4) {
return;
}
quirk = g_malloc0(sizeof(*quirk));
quirk->mem = g_new0(MemoryRegion, 2);
quirk->nr_mem = 2;
window = quirk->data = g_malloc0(sizeof(*window) +
sizeof(VFIOConfigWindowMatch));
window->vdev = vdev;
window->address_offset = 0;
window->data_offset = 4;
window->nr_matches = 1;
window->matches[0].match = 0x4000;
window->matches[0].mask = PCIE_CONFIG_SPACE_SIZE - 1;
window->bar = nr;
window->addr_mem = &quirk->mem[0];
window->data_mem = &quirk->mem[1];
memory_region_init_io(window->addr_mem, OBJECT(vdev),
&vfio_generic_window_address_quirk, window,
"vfio-ati-bar4-window-address-quirk", 4);
memory_region_add_subregion_overlap(&vdev->bars[nr].region.mem,
window->address_offset,
window->addr_mem, 1);
memory_region_init_io(window->data_mem, OBJECT(vdev),
&vfio_generic_window_data_quirk, window,
"vfio-ati-bar4-window-data-quirk", 4);
memory_region_add_subregion_overlap(&vdev->bars[nr].region.mem,
window->data_offset,
window->data_mem, 1);
QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next);
trace_vfio_quirk_ati_bar4_probe(vdev->vbasedev.name);
}
| 1threat
|
How to do match exactly the content using PHP : I need one help.I need to match two string using PHP.I am explaining the scenario below.
<?php
$fistno="9937229853";
$secondno="+919937229853";
?>
Here I need the value in `$fistno` is present in `$secondno` or not. If the value in `$fistno` is present in `$secondno` it will return true. In this case `9937229853` is present in `$secondno` so it should return true. Please help.
| 0debug
|
Importing a module in haskell makes the code not compile : <p>I wrote the following haskell code for test. It compiles fine with <code>ghc</code> (version 8.0.2), and prints 20, as expected.</p>
<pre class="lang-hs prettyprint-override"><code>f x = x * 2
main = print $ f 10
</code></pre>
<p>But when I import <code>Char</code> module like this:</p>
<pre class="lang-hs prettyprint-override"><code>module Data.Char
f x = x * 2
main = print $ f 10
</code></pre>
<p>it gives me this error: <code>test.hs:3:1: error: parse error on input ‘f’</code>.</p>
<p>Does haskell change the environment when a module is imported? What is the difference and am I importing the module wrong?</p>
| 0debug
|
send notification alert when AWS Lambda function has an error : <p>I have a AWS Lambda function running some process in my infrastructure. The Lambda is triggered every 8 hours using a CloudWatch rule. I am trying to raise a notification if any error happens into the Lambda process. I tried to use SES but that service is not available in that Region. </p>
<p>I will like to know any suggestions for this problem:</p>
<p><strong><em>How to setup notifications when an error occurs in my Lambda functions ?</em></strong> </p>
<p>I am looking for suggestions. This questions never asked for doing my task. I will appreciate any official documentation but either way, any help is welcome.</p>
| 0debug
|
Changing Kubernetes' node-proxy tcp keepalive time : <p>How do I properly change the TCP keepalive time for node-proxy?</p>
<p>I am running Kubernetes in Google Container Engine and have set up an ingress backed by HTTP(S) Google Load Balancer. When I continuously make POST requests to the ingress, I get a 502 error exactly once every 80 seconds or so. <code>backend_connection_closed_before_data_sent_to_client</code> error in Cloud Logging, which is because GLB's tcp keepalive (600 seconds) is larger than node-proxy's keepalive (no clue what it is).</p>
<p>The logged error is detailed in <a href="https://cloud.google.com/compute/docs/load-balancing/http/" rel="noreferrer">https://cloud.google.com/compute/docs/load-balancing/http/</a>.</p>
<p>Thanks!</p>
| 0debug
|
Chrome developer tools blackbox option isn't there? : <p>I can't find the option to blackbox code anywhere on the chrome developer tools. It also doesn't give me the option when I right-click a file. I am using the latest version.</p>
<p>This link that was posted 3 days ago states the e is simply a "blackbox" tab in settings, but it isn't there for me. <a href="https://developers.google.com/web/tools/chrome-devtools/javascript/step-code" rel="noreferrer">https://developers.google.com/web/tools/chrome-devtools/javascript/step-code</a></p>
<p>There is also no "Manage framework blackboxing" option in general settings as stated in various guides.</p>
<p>Can anyone help? I can't see any posts online saying it has been removed.</p>
<p>Thanks!</p>
<p><a href="https://i.stack.imgur.com/91jm0.png" rel="noreferrer">Screenshot of my settings menu</a></p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.