problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
How to run code after constructor in a Lombok builder : <p>I have a class that I want to use Lombok.Builder and I need pre-process of some parameters. Something like this:</p>
<pre><code>@Builder
public class Foo {
public String val1;
public int val2;
public List<String> listValues;
public void init(){
// do some checks with the values.
}
}
</code></pre>
<p>normally I would just call <code>init()</code> on a NoArg constructor, but with the generated builder I'm unable to do so. Is there a way for this <code>init</code> be called by the generated builder? For example <code>build()</code> would generate a code like:</p>
<pre><code>public Foo build() {
Foo foo = Foo(params....)
foo.init();
return foo;
}
</code></pre>
<p>I'm aware that I can manually code the <code>all args</code> constructor, that the Builder will call through it and I can call <code>init</code> inside there.</p>
<p>But that is a sub-optimal solution as my class will likely have new fields added every once in a while which would mean changing the constructor too.</p>
| 0debug
|
How I can view rows and columns of 'Adult' Dataset in R : <p>How I can view rows and columns of 'Adult' Dataset in R? I just started learning R.
Any help is appreciated.Pls refer to the screenhot<a href="https://i.stack.imgur.com/RbeQx.jpg" rel="nofollow noreferrer">enter image description here</a></p>
| 0debug
|
Base vs default branch in bitbucket version of git : <p>Why there exists two different types of branches, base and default in Bitbucket? In my mind I understand that the master branch most of the times should be the default branch, i.e. the branch that everyone in the team should use as a reference and as also the branch that "guidelines" the development. But what different functionality a base branch may introduce? Thank you for your patience.</p>
| 0debug
|
static void bonito_writel(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
PCIBonitoState *s = opaque;
uint32_t saddr;
int reset = 0;
saddr = (addr - BONITO_REGBASE) >> 2;
DPRINTF("bonito_writel "TARGET_FMT_plx" val %x saddr %x\n", addr, val, saddr);
switch (saddr) {
case BONITO_BONPONCFG:
case BONITO_IODEVCFG:
case BONITO_SDCFG:
case BONITO_PCIMAP:
case BONITO_PCIMEMBASECFG:
case BONITO_PCIMAP_CFG:
case BONITO_GPIODATA:
case BONITO_GPIOIE:
case BONITO_INTEDGE:
case BONITO_INTSTEER:
case BONITO_INTPOL:
case BONITO_PCIMAIL0:
case BONITO_PCIMAIL1:
case BONITO_PCIMAIL2:
case BONITO_PCIMAIL3:
case BONITO_PCICACHECTRL:
case BONITO_PCICACHETAG:
case BONITO_PCIBADADDR:
case BONITO_PCIMSTAT:
case BONITO_TIMECFG:
case BONITO_CPUCFG:
case BONITO_DQCFG:
case BONITO_MEMSIZE:
s->regs[saddr] = val;
break;
case BONITO_BONGENCFG:
if (!(s->regs[saddr] & 0x04) && (val & 0x04)) {
reset = 1;
}
s->regs[saddr] = val;
if (reset) {
qemu_system_reset_request();
}
break;
case BONITO_INTENSET:
s->regs[BONITO_INTENSET] = val;
s->regs[BONITO_INTEN] |= val;
break;
case BONITO_INTENCLR:
s->regs[BONITO_INTENCLR] = val;
s->regs[BONITO_INTEN] &= ~val;
break;
case BONITO_INTEN:
case BONITO_INTISR:
DPRINTF("write to readonly bonito register %x\n", saddr);
break;
default:
DPRINTF("write to unknown bonito register %x\n", saddr);
break;
}
}
| 1threat
|
static int get_whole_cluster(BlockDriverState *bs, uint64_t cluster_offset,
uint64_t offset, int allocate)
{
uint64_t parent_cluster_offset;
BDRVVmdkState *s = bs->opaque;
uint8_t whole_grain[s->cluster_sectors*512];
if (s->hd->backing_hd) {
BDRVVmdkState *ps = s->hd->backing_hd->opaque;
if (!vmdk_is_cid_valid(bs))
return -1;
parent_cluster_offset = get_cluster_offset(s->hd->backing_hd, offset, allocate);
if (bdrv_pread(ps->hd, parent_cluster_offset, whole_grain, ps->cluster_sectors*512) !=
ps->cluster_sectors*512)
return -1;
if (bdrv_pwrite(s->hd, cluster_offset << 9, whole_grain, sizeof(whole_grain)) !=
sizeof(whole_grain))
return -1;
}
return 0;
}
| 1threat
|
Golang lib/pq: Runtime error when querying a database : I'm setting up a PostgreSQL database for my golang backend, but I'm getting this error when trying to read a table:
```
runtime error: invalid memory address or nil pointer dereference
/FwzFiles/go/src/runtime/panic.go:82 (0x4423b0)
panicmem: panic(memoryError)
/FwzFiles/go/src/runtime/signal_unix.go:390 (0x4421df)
sigpanic: panicmem()
/FwzFiles/go/src/database/sql/sql.go:1080 (0x4e59d9)
(*DB).conn: db.mu.Lock()
/FwzFiles/go/src/database/sql/sql.go:1379 (0x4e7197)
(*DB).prepare: dc, err := db.conn(ctx, strategy)
/FwzFiles/go/src/database/sql/sql.go:1352 (0x4e6f58)
(*DB).PrepareContext: stmt, err = db.prepare(ctx, query, cachedOrNewConn)
/FwzFiles/go/src/database/sql/sql.go:1369 (0x9c8020)
(*DB).Prepare: return db.PrepareContext(context.Background(), query)
/FwzFiles/go-projects/first-postgresql/main.go:62 (0x9c7fe2)
AllEmployees: queryStmt, err := db.Prepare("SELECT * FROM employees ORDER BY id")
/home/f4ww4z/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/context.go:124 (0x991109)
(*Context).Next: c.handlers[c.index](c)
/home/f4ww4z/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/recovery.go:83 (0x9a43d9)
RecoveryWithWriter.func1: c.Next()
/home/f4ww4z/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/context.go:124 (0x991109)
(*Context).Next: c.handlers[c.index](c)
/home/f4ww4z/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/logger.go:240 (0x9a3480)
LoggerWithConfig.func1: c.Next()
/home/f4ww4z/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/context.go:124 (0x991109)
(*Context).Next: c.handlers[c.index](c)
/home/f4ww4z/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/gin.go:389 (0x99a921)
(*Engine).handleHTTPRequest: c.Next()
/home/f4ww4z/go/pkg/mod/github.com/gin-gonic/gin@v1.4.0/gin.go:351 (0x99a153)
(*Engine).ServeHTTP: engine.handleHTTPRequest(c)
/FwzFiles/go/src/net/http/server.go:2774 (0x6ccd87)
serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/FwzFiles/go/src/net/http/server.go:1878 (0x6c8970)
(*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/FwzFiles/go/src/runtime/asm_amd64.s:1337 (0x459c50)
goexit: BYTE $0x90 // NOP
[GIN] 2019/08/17 - 16:25:18 | 500 | 23.812025ms | ::1 | GET /employees
```
Here's where the error is pointing at (`main.go:63`):
```
func AllEmployees(c *gin.Context) {
// Query the Postgres employees table
queryStmt, err := db.Prepare("SELECT * FROM employees ORDER BY id")
rows, err := queryStmt.Query() // line 63
if err != nil {
panic(err)
}
defer rows.Close()
// Extract the employees data from the query
result := Employees{}
for rows.Next() {
employee := Employee{}
err := rows.Scan(&employee.ID, &employee.Name, &employee.Salary, &employee.Age)
if err != nil {
panic(err)
}
result.Employees = append(result.Employees, employee)
}
c.JSON(http.StatusOK, gin.H{
"employees": result,
})
}
```
It should return 2 rows that I manually created on the `employees` table.
Note I'm successfully connected to the db, just that it errored when querying.
Can anyone help with this?
| 0debug
|
static int find_pte64(CPUPPCState *env, mmu_ctx_t *ctx, int h,
int rw, int type, int target_page_bits)
{
hwaddr pteg_off;
target_ulong pte0, pte1;
int i, good = -1;
int ret, r;
ret = -1;
pteg_off = get_pteg_offset(env, ctx->hash[h], HASH_PTE_SIZE_64);
for (i = 0; i < 8; i++) {
if (env->external_htab) {
pte0 = ldq_p(env->external_htab + pteg_off + (i * 16));
pte1 = ldq_p(env->external_htab + pteg_off + (i * 16) + 8);
} else {
pte0 = ldq_phys(env->htab_base + pteg_off + (i * 16));
pte1 = ldq_phys(env->htab_base + pteg_off + (i * 16) + 8);
}
r = pte64_check(ctx, pte0, pte1, h, rw, type);
LOG_MMU("Load pte from %016" HWADDR_PRIx " => " TARGET_FMT_lx " "
TARGET_FMT_lx " %d %d %d " TARGET_FMT_lx "\n",
pteg_off + (i * 16), pte0, pte1, (int)(pte0 & 1), h,
(int)((pte0 >> 1) & 1), ctx->ptem);
switch (r) {
case -3:
return -1;
case -2:
ret = -2;
good = i;
break;
case -1:
default:
break;
case 0:
ret = 0;
good = i;
goto done;
}
}
if (good != -1) {
done:
LOG_MMU("found PTE at addr %08" HWADDR_PRIx " prot=%01x ret=%d\n",
ctx->raddr, ctx->prot, ret);
pte1 = ctx->raddr;
if (pte_update_flags(ctx, &pte1, ret, rw) == 1) {
if (env->external_htab) {
stq_p(env->external_htab + pteg_off + (good * 16) + 8,
pte1);
} else {
stq_phys_notdirty(env->htab_base + pteg_off +
(good * 16) + 8, pte1);
}
}
}
if (target_page_bits != TARGET_PAGE_BITS) {
ctx->raddr |= (ctx->eaddr & ((1 << target_page_bits) - 1))
& TARGET_PAGE_MASK;
}
return ret;
}
| 1threat
|
static ssize_t test_block_read_func(QCryptoBlock *block,
void *opaque,
size_t offset,
uint8_t *buf,
size_t buflen,
Error **errp)
{
Buffer *header = opaque;
g_assert_cmpint(offset + buflen, <=, header->capacity);
memcpy(buf, header->buffer + offset, buflen);
return buflen;
}
| 1threat
|
.submit method dosent work when trying to login : im trying to login to a web page to get some tables but my code dosent work to login.
Sub GetTable()
Dim ieApp As InternetExplorer
Dim ieDoc As Object
Dim ieTable As Object
Dim clip As DataObject
Set ieApp = New InternetExplorer
ieApp.Visible = True
ieApp.Navigate "https://www.teambinder.com/TeamBinder184/Logon/default.aspx"
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
Set ieDoc = ieApp.Document
With ieDoc.forms(0)
.txtUserId.Value = "8888"
.txtCompanyId.Value = "8888"
.txtPassword.Value = "88888"
'IN HERE WHERE IT DOSE NOTHING WHILE SUPPOSE TO LOGIN TO THE PAGE'
`.submit`
End Sub
| 0debug
|
How do you reduce a list of tuplies in Python 3? : Input
```in = [(1, 2), (1, 4), (1, 6)]```
Expected Output
```(3, 12)```
I've tried
```print(reduce(lambda a, b: (a[0] + b[0], a[1] + b[1]), in))```
and
```print(reduce(lambda (a, b), (c, d): (a + c, b + d), in))```
both of which fail due to invalid syntax.
| 0debug
|
query = 'SELECT * FROM customers WHERE email = ' + email_input
| 1threat
|
SUPER URGENT FIX - Wordpress Header Fatal Error : im getting this error on my page "Fatal error: Can't use function return value in write context in /home/shamsavh/public_html/wp-content/themes/bleute/header.php on line 35"
the code at line 35 is "$header_setting = '';" below is detailed code, can someone please help
<!DOCTYPE html>
<!--[if lt IE 7 ]><html class="ie ie6" <?php language_attributes(); ?>> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" <?php language_attributes(); ?>> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" <?php language_attributes(); ?>> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!-->
<html <?php language_attributes(); ?>> <!--<![endif]-->
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<!--[if lt IE 9]>
<script src="<?php echo esc_url( get_template_directory_uri() ); ?>/asset/js/html5.js"></script>
<![endif]-->
<!-- Mobile Specific Metas
================================================== -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="profile" href="http://gmpg.org/xfn/11" />
<?php wp_head();?>
</head>
<body <?php body_class(); ?>>
<div id="bleute-mobile-menu">
<button>
<i></i>
<i></i>
<i></i>
</button>
<?php wp_nav_menu( array( // show menu mobile
'theme_location' => 'mobile-menu',
'container' => 'nav',
'container_class' => 'mobile-menu'
) ); ?>
</div>
<?php
if (!is_404()) {
***$header_setting = '';***
$header_page_setting = get_post_meta( get_the_ID(), '_beautheme_custom_header', TRUE );
if (!empty(bleute_GetOption('header-type'))) {
$header_setting = bleute_GetOption('header-type');
}
if ($header_page_setting) {
$header_setting = $header_page_setting;
}
if (empty($header_setting)) {
$header_setting = 'none-slide';
}
if(is_search() == 'true'){
$header_setting = 'none-slide';
}
get_template_part('templates/header', $header_setting);
if (bleute_GetOption('enable-fixed') == '2') {
get_template_part('templates/header-stick', $header_setting);
}
?>
<?php }?>
| 0debug
|
static av_cold int aac_decode_init(AVCodecContext * avccontext) {
AACContext * ac = avccontext->priv_data;
int i;
ac->avccontext = avccontext;
if (avccontext->extradata_size <= 0 ||
decode_audio_specific_config(ac, avccontext->extradata, avccontext->extradata_size))
return -1;
avccontext->sample_fmt = SAMPLE_FMT_S16;
avccontext->sample_rate = ac->m4ac.sample_rate;
avccontext->frame_size = 1024;
AAC_INIT_VLC_STATIC( 0, 144);
AAC_INIT_VLC_STATIC( 1, 114);
AAC_INIT_VLC_STATIC( 2, 188);
AAC_INIT_VLC_STATIC( 3, 180);
AAC_INIT_VLC_STATIC( 4, 172);
AAC_INIT_VLC_STATIC( 5, 140);
AAC_INIT_VLC_STATIC( 6, 168);
AAC_INIT_VLC_STATIC( 7, 114);
AAC_INIT_VLC_STATIC( 8, 262);
AAC_INIT_VLC_STATIC( 9, 248);
AAC_INIT_VLC_STATIC(10, 384);
dsputil_init(&ac->dsp, avccontext);
ac->random_state = 0x1f2e3d4c;
if(ac->dsp.float_to_int16 == ff_float_to_int16_c) {
ac->add_bias = 385.0f;
ac->sf_scale = 1. / (-1024. * 32768.);
ac->sf_offset = 0;
} else {
ac->add_bias = 0.0f;
ac->sf_scale = 1. / -1024.;
ac->sf_offset = 60;
}
#ifndef CONFIG_HARDCODED_TABLES
for (i = 0; i < 428; i++)
ff_aac_pow2sf_tab[i] = pow(2, (i - 200)/4.);
#endif
INIT_VLC_STATIC(&vlc_scalefactors,7,FF_ARRAY_ELEMS(ff_aac_scalefactor_code),
ff_aac_scalefactor_bits, sizeof(ff_aac_scalefactor_bits[0]), sizeof(ff_aac_scalefactor_bits[0]),
ff_aac_scalefactor_code, sizeof(ff_aac_scalefactor_code[0]), sizeof(ff_aac_scalefactor_code[0]),
352);
ff_mdct_init(&ac->mdct, 11, 1);
ff_mdct_init(&ac->mdct_small, 8, 1);
ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
ff_sine_window_init(ff_sine_1024, 1024);
ff_sine_window_init(ff_sine_128, 128);
return 0;
}
| 1threat
|
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
| 1threat
|
Type ‘Any’ has no subscript members : <p>I'm working through a tutorial and have run into a roadblock with the type any error. I was able to get the others resolved but this one is kicking my tail.</p>
<p>Here is the viewcontroller code:</p>
<pre><code>import UIKit
class ViewController: UIViewController {
//Our web service url
let URL_GET_TEAMS:String = "http://192.168.43.207/MyWebService/api/getteams.php"
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//created NSURL
let requestURL = NSURL(string: URL_GET_TEAMS)
//creating NSMutableURLRequest
let request = NSMutableURLRequest(URL: requestURL!)
//setting the method to post
request.HTTPMethod = "GET"
//creating a task to send the post request
let task = NSURLSession.sharedSession().dataTaskWithRequest(request){
data, response, error in
//exiting if there is some error
if error != nil{
print("error is \(error)")
return;
}
//parsing the response
do {
//converting resonse to NSDictionary
var teamJSON: NSDictionary!
teamJSON = try NSJSONSerialization.JSONObjectWithData(data!, options: .MutableContainers) as? NSDictionary
//getting the JSON array teams from the response
let teams: NSArray = teamJSON["teams"] as! NSArray
//looping through all the json objects in the array teams
for i in 0 ..< teams.count{
//getting the data at each index
let teamId:Int = teams[i]["id"] as! Int!
let teamName:String = teams[i]["name"] as! String!
let teamMember:Int = teams[i]["member"] as! Int!
//displaying the data
print("id -> ", teamId)
print("name -> ", teamName)
print("member -> ", teamMember)
print("===================")
print("")
}
} catch {
print(error)
}
}
//executing the task
task.resume()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
</code></pre>
<p>The error is thrown on the following lines:
//getting the data at each index
let teamId:Int = teams[i]["id"] as! Int!
let teamName:String = teams[i]["name"] as! String!
let teamMember:Int = teams[i]["member"] as! Int!</p>
<p>Any help would be appreciative.</p>
| 0debug
|
Calling X resolution of screen from another class : I have a class of game named below
public class BrickBreaker extends Activity {
// there is lot of other code but i am only pointing to the issue
class BreakoutView extends SurfaceView implements Runnable {
// The size of the screen in pixels
int screenX;
int screenY;
// Get a Display object to access screen details
Display display = getWindowManager().getDefaultDisplay();
// Load the resolution into a Point object
Point size = new Point();
display.getSize(size);
screenX = size.x;
screenY = size.y;
}}
and from another class i want to access screenX other class is below.
public class Paddle {
public void update(long fps){
rect.left = x;
rect.right = x + length;
if (x<0){
x=0;
}
else if (x+length > screenX){
x = screenX-length;
}
}
screenX is not accessible from here please help me how to do that?
| 0debug
|
Keep ratio of DIV or img : <p>I want to keep the ratio of DIV
For example
I use google map</p>
<p><code><div id="map" style="background-color: grey;width:100%;"> Map here </div></code></p>
<p>It adjust the width to window or <code>col-*</code> for <code>bootstrap</code>.</p>
<p>it changes according to window size. </p>
<p>But now I want to keep the width:height ratio = 1 : 1</p>
<p>How should I do??</p>
<p>Same situation happens to <code>img</code> </p>
<p>I want to keep this img square</p>
<p><code><img class="img-fluid" style="width:100%;"></code></p>
| 0debug
|
Angular JS 1 : multiple-date-picker date formating is not working : I am using multiple-date-picker
[multiple-date-picker ][1]
but there is no option to format the date.
right now when I am trying to iterate the array I am getting
[![enter image description here][2]][2]
["2017-11-06T18:30:00.000Z","2017-11-08T18:30:00.000Z","2017-11-16T18:30:00.000Z"]
below is the code
<div style="width:80%">
<multiple-date-picker ng-model="myArrayOfDates"></multiple-date-picker>
</div>
<div ng-repeat="m in myArrayOfDates">
<div class="col-sm-3 text-right">
<label>Time {{m}}</label>
</div>
**javascript:**
$scope.myArrayOfDates = [];
I tried using filters but that did not work.
Please advice.
[1]: https://github.com/arca-computing/MultipleDatePicker
[2]: https://i.stack.imgur.com/QbO9S.png
| 0debug
|
def check_element(test_tup, check_list):
res = False
for ele in check_list:
if ele in test_tup:
res = True
break
return (res)
| 0debug
|
gen_intermediate_code_internal(M68kCPU *cpu, TranslationBlock *tb,
bool search_pc)
{
CPUState *cs = CPU(cpu);
CPUM68KState *env = &cpu->env;
DisasContext dc1, *dc = &dc1;
uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int j, lj;
target_ulong pc_start;
int pc_offset;
int num_insns;
int max_insns;
pc_start = tb->pc;
dc->tb = tb;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
dc->env = env;
dc->is_jmp = DISAS_NEXT;
dc->pc = pc_start;
dc->cc_op = CC_OP_DYNAMIC;
dc->singlestep_enabled = cs->singlestep_enabled;
dc->fpcr = env->fpcr;
dc->user = (env->sr & SR_S) == 0;
dc->is_mem = 0;
dc->done_mac = 0;
lj = -1;
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0)
max_insns = CF_COUNT_MASK;
gen_tb_start();
do {
pc_offset = dc->pc - pc_start;
gen_throws_exception = NULL;
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (bp->pc == dc->pc) {
gen_exception(dc, dc->pc, EXCP_DEBUG);
dc->is_jmp = DISAS_JUMP;
break;
}
}
if (dc->is_jmp)
break;
}
if (search_pc) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
tcg_ctx.gen_opc_pc[lj] = dc->pc;
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
gen_io_start();
dc->insn_pc = dc->pc;
disas_m68k_insn(env, dc);
num_insns++;
} while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end &&
!cs->singlestep_enabled &&
!singlestep &&
(pc_offset) < (TARGET_PAGE_SIZE - 32) &&
num_insns < max_insns);
if (tb->cflags & CF_LAST_IO)
gen_io_end();
if (unlikely(cs->singlestep_enabled)) {
if (!dc->is_jmp) {
gen_flush_cc_op(dc);
tcg_gen_movi_i32(QREG_PC, dc->pc);
}
gen_helper_raise_exception(cpu_env, tcg_const_i32(EXCP_DEBUG));
} else {
switch(dc->is_jmp) {
case DISAS_NEXT:
gen_flush_cc_op(dc);
gen_jmp_tb(dc, 0, dc->pc);
break;
default:
case DISAS_JUMP:
case DISAS_UPDATE:
gen_flush_cc_op(dc);
tcg_gen_exit_tb(0);
break;
case DISAS_TB_JUMP:
break;
}
}
gen_tb_end(tb, num_insns);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(env, pc_start, dc->pc - pc_start, 0);
qemu_log("\n");
}
#endif
if (search_pc) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
lj++;
while (lj <= j)
tcg_ctx.gen_opc_instr_start[lj++] = 0;
} else {
tb->size = dc->pc - pc_start;
tb->icount = num_insns;
}
}
| 1threat
|
static void gen_eob_inhibit_irq(DisasContext *s, bool inhibit)
{
gen_update_cc_op(s);
if (inhibit && !(s->flags & HF_INHIBIT_IRQ_MASK)) {
gen_set_hflag(s, HF_INHIBIT_IRQ_MASK);
} else {
gen_reset_hflag(s, HF_INHIBIT_IRQ_MASK);
}
if (s->tb->flags & HF_RF_MASK) {
gen_helper_reset_rf(cpu_env);
}
if (s->singlestep_enabled) {
gen_helper_debug(cpu_env);
} else if (s->tf) {
gen_helper_single_step(cpu_env);
} else {
tcg_gen_exit_tb(0);
}
s->is_jmp = DISAS_TB_JUMP;
}
| 1threat
|
static int get_cod(J2kDecoderContext *s, J2kCodingStyle *c, uint8_t *properties)
{
J2kCodingStyle tmp;
int compno;
if (s->buf_end - s->buf < 5)
return AVERROR(EINVAL);
tmp.log2_prec_width =
tmp.log2_prec_height = 15;
tmp.csty = bytestream_get_byte(&s->buf);
if (bytestream_get_byte(&s->buf)){
av_log(s->avctx, AV_LOG_ERROR, "only LRCP progression supported\n");
return -1;
}
tmp.nlayers = bytestream_get_be16(&s->buf);
tmp.mct = bytestream_get_byte(&s->buf);
get_cox(s, &tmp);
for (compno = 0; compno < s->ncomponents; compno++){
if (!(properties[compno] & HAD_COC))
memcpy(c + compno, &tmp, sizeof(J2kCodingStyle));
}
return 0;
}
| 1threat
|
How do you install multiple, separate instances of Ubuntu in WSL? : <p>In Windows 10, how do you install multiple, separate instances of Ubuntu in WSL? I'd like separate instances for different work spaces. For instance one for Python development, one for Ruby development, one for .Net Core development, etc. I know I could jam all of these into the same Ubuntu on WSL instance, but I'd rather have a separate one for each of these scenarios. Is this possible?</p>
| 0debug
|
having trouble installing awslogs agent : <p>I'm having issues trying to instal awslogs agent on my ec2 node. When I run this command:</p>
<pre><code>sudo python ./awslogs-agent-setup.py --region us-east-1
</code></pre>
<p>it seems to fail at step 2 like this:</p>
<pre><code>Launching interactive setup of CloudWatch Logs agent ...
Step 1 of 5: Installing pip ...DONE
Step 2 of 5: Downloading the latest CloudWatch Logs agent bits ...
Traceback (most recent call last):
File "./awslogs-agent-setup.py", line 1144, in <module>
main()
File "./awslogs-agent-setup.py", line 1140, in main
setup.setup_artifacts()
File "./awslogs-agent-setup.py", line 696, in setup_artifacts
self.install_awslogs_cli()
File "./awslogs-agent-setup.py", line 523, in install_awslogs_cli
subprocess.call([AWSCLI_CMD, 'configure', 'set', 'plugins.cwlogs', 'cwlogs'], env=DEFAULT_ENV)
File "/usr/lib64/python2.7/subprocess.py", line 524, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
</code></pre>
<p>what directory or file is it missing?</p>
| 0debug
|
Need assistance creating a specific regular expression python : <p>I am not so familiar with regular expressions and need some help creating one.
I need to create a regular expression that would filter any combination of '+'s and '-'s from a string.</p>
<p>For example :
if given "95--45++12-+45+-+7" it would output : ['--', '++', '-+', '+-+']</p>
<p>Help would be very much appreciated :)</p>
| 0debug
|
Why does this C code magically print "a[2] = 98"? : <pre><code>#include <stdio.h>
int main(void){
int n;
int a[5];
int *p;
a[2] = 1024;
p = &n;
/* adding any of these lines makes code to print "a[2] = 98" at output */
p[5] = 98; //OR *(p + 5) = 98;
printf("a[2] = %d\n", a[2]); //Prints a[2] = 98
return (0);
}
</code></pre>
<p>I don't understand why this C code magically prints "a[2] = 98". Though, this is what I want but I want to understand it.</p>
| 0debug
|
How to upgrade/refresh the ag-grid after row delete? : <p>I have an ag grid where i am trying to delete a row...I am able to remove the row from data source using "splice" technique,after that i want to refresh the table.But it is showing error.This is the code which i am using to delete a row</p>
<pre><code>selectedvalue={} //this holds the selected row value
rowData=[]; //this holds all the row data
onRowSelected(event) {
this.selectedvalue = event;
}
deletebtn() {
for (let i = 0; i < this.rowData.length; i++) {
if (this.selectedvalue.node.data.make === this.rowData[i].make) {
this.rowData.splice(i, 1);
this.gridOptions.api.refreshView();
}
}
}
</code></pre>
<p>It is showing erroe something like this--> Cannot read property 'refreshView' of undefined...How can watch the changes made in table after row delete.</p>
| 0debug
|
static int get_siz(J2kDecoderContext *s)
{
int i, ret;
if (s->buf_end - s->buf < 36)
bytestream_get_be16(&s->buf);
s->width = bytestream_get_be32(&s->buf);
s->height = bytestream_get_be32(&s->buf);
s->image_offset_x = bytestream_get_be32(&s->buf);
s->image_offset_y = bytestream_get_be32(&s->buf);
s->tile_width = bytestream_get_be32(&s->buf);
s->tile_height = bytestream_get_be32(&s->buf);
s->tile_offset_x = bytestream_get_be32(&s->buf);
s->tile_offset_y = bytestream_get_be32(&s->buf);
s->ncomponents = bytestream_get_be16(&s->buf);
if (s->buf_end - s->buf < 2 * s->ncomponents)
for (i = 0; i < s->ncomponents; i++){
uint8_t x = bytestream_get_byte(&s->buf);
s->cbps[i] = (x & 0x7f) + 1;
s->precision = FFMAX(s->cbps[i], s->precision);
s->sgnd[i] = !!(x & 0x80);
s->cdx[i] = bytestream_get_byte(&s->buf);
s->cdy[i] = bytestream_get_byte(&s->buf);
}
s->numXtiles = ff_j2k_ceildiv(s->width - s->tile_offset_x, s->tile_width);
s->numYtiles = ff_j2k_ceildiv(s->height - s->tile_offset_y, s->tile_height);
s->tile = av_mallocz(s->numXtiles * s->numYtiles * sizeof(J2kTile));
if (!s->tile)
return AVERROR(ENOMEM);
for (i = 0; i < s->numXtiles * s->numYtiles; i++){
J2kTile *tile = s->tile + i;
tile->comp = av_mallocz(s->ncomponents * sizeof(J2kComponent));
if (!tile->comp)
return AVERROR(ENOMEM);
}
s->avctx->width = s->width - s->image_offset_x;
s->avctx->height = s->height - s->image_offset_y;
switch(s->ncomponents){
case 1: if (s->precision > 8) {
s->avctx->pix_fmt = PIX_FMT_GRAY16;
} else s->avctx->pix_fmt = PIX_FMT_GRAY8;
break;
case 3: if (s->precision > 8) {
s->avctx->pix_fmt = PIX_FMT_RGB48;
} else s->avctx->pix_fmt = PIX_FMT_RGB24;
break;
case 4: s->avctx->pix_fmt = PIX_FMT_BGRA; break;
}
if (s->picture.data[0])
s->avctx->release_buffer(s->avctx, &s->picture);
if ((ret = s->avctx->get_buffer(s->avctx, &s->picture)) < 0)
return ret;
s->picture.pict_type = FF_I_TYPE;
s->picture.key_frame = 1;
return 0;
}
| 1threat
|
Change total value of a stacked progress bar : I want to change stacked progress bar maximum value,By default it will
take 100
<div class="progress">
<div class="progress-bar progress-bar-info" role="progressbar"
style="width:20%">
Abc
</div>
<div class="progress-bar progress-bar-warning" role="progressbar"
style="width:30%">
dfgdf
</div>
</div>
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/P9eYm.png
In this image i want to give maximum value 60 but it will take 100.
| 0debug
|
int xen_be_bind_evtchn(struct XenDevice *xendev)
{
if (xendev->local_port != -1) {
return 0;
}
xendev->local_port = xc_evtchn_bind_interdomain
(xendev->evtchndev, xendev->dom, xendev->remote_port);
if (xendev->local_port == -1) {
xen_be_printf(xendev, 0, "xc_evtchn_bind_interdomain failed\n");
return -1;
}
xen_be_printf(xendev, 2, "bind evtchn port %d\n", xendev->local_port);
qemu_set_fd_handler(xc_evtchn_fd(xendev->evtchndev),
xen_be_evtchn_event, NULL, xendev);
return 0;
}
| 1threat
|
C homework with pipes and forks : <p><strong>Hello everyone,</strong> </p>
<p>I'm quite lost in my school homework since they haven't told us much about it and I haven't done anything like that before.</p>
<p><strong>The task is:</strong></p>
<p><em>In the C language create a program that creates two processes (fork function) and connects them via pipe (the pipe function).
The first descendant redirects its' stdout into the pipe and writes (space separated) pairs of random numbers into it (function rand).
Delay the output of the numbers (i.e. by 1 second).</em></p>
<p><em>The first descendant has
to treat the SIGUSR1 signal (sigaction function) and in case of receiving such signal it prints a string “TERMINATED” to it's stderr and terminates.</em></p>
<p><em>The second descendant redirects the pipe output to it's stdin, redirects it's stdout into a file called out.txt in
the current directory and executes a binary file (execl function) for finding the greatest common divisor (the output of our previous tasks where we had to write a makefile that runs a small C program that detects if a number is prime).</em></p>
<p><em>The parent process waits 5 seconds and then sends SIGUSR1 to the first process (number generator). This should perform a correct termination of both processes. It waits for the sub-processes to terminate (wait function) and terminates itself.</em></p>
<p><em>In fact you are implementing something like this: while : ; do echo $RANDOM $RANDOM ; sleep 1; done | ./c1_task > out.txt</em></p>
<p>I'm absolutely lost in this and I have nothing so far unfortunatelly.
I don't know where to start.</p>
<p>Could somebody advise me something, please?</p>
<p>Thanks in advance!</p>
| 0debug
|
How can I delete the last occurrence of a pattern in a file using a grep/awk/bash/etc? : <p>What is the easiest way to delete the last occurrence of a pattern in a file using a grep/awk/bash/etc? For example, I have a file in which the expression "hello world" appears multiple times and I would like to delete the entire line or just the last time "hello world" occurs. Thanks! </p>
| 0debug
|
void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex,
int lastInLumBuf, int lastInChrBuf)
{
const int dstH= c->dstH;
const int flags= c->flags;
int16_t **lumPixBuf= c->lumPixBuf;
int16_t **chrUPixBuf= c->chrUPixBuf;
int16_t **alpPixBuf= c->alpPixBuf;
const int vLumBufSize= c->vLumBufSize;
const int vChrBufSize= c->vChrBufSize;
int32_t *vLumFilterPos= c->vLumFilterPos;
int32_t *vChrFilterPos= c->vChrFilterPos;
int16_t *vLumFilter= c->vLumFilter;
int16_t *vChrFilter= c->vChrFilter;
int32_t *lumMmxFilter= c->lumMmxFilter;
int32_t *chrMmxFilter= c->chrMmxFilter;
int32_t av_unused *alpMmxFilter= c->alpMmxFilter;
const int vLumFilterSize= c->vLumFilterSize;
const int vChrFilterSize= c->vChrFilterSize;
const int chrDstY= dstY>>c->chrDstVSubSample;
const int firstLumSrcY= vLumFilterPos[dstY];
const int firstChrSrcY= vChrFilterPos[chrDstY];
c->blueDither= ff_dither8[dstY&1];
if (c->dstFormat == PIX_FMT_RGB555 || c->dstFormat == PIX_FMT_BGR555)
c->greenDither= ff_dither8[dstY&1];
else
c->greenDither= ff_dither4[dstY&1];
c->redDither= ff_dither8[(dstY+1)&1];
if (dstY < dstH - 2) {
const int16_t **lumSrcPtr= (const int16_t **)(void*) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
const int16_t **chrUSrcPtr= (const int16_t **)(void*) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **)(void*) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
int i;
if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->srcH) {
const int16_t **tmpY = (const int16_t **) lumPixBuf + 2 * vLumBufSize;
int neg = -firstLumSrcY, i, end = FFMIN(c->srcH - firstLumSrcY, vLumFilterSize);
for (i = 0; i < neg; i++)
tmpY[i] = lumSrcPtr[neg];
for ( ; i < end; i++)
tmpY[i] = lumSrcPtr[i];
for ( ; i < vLumFilterSize; i++)
tmpY[i] = tmpY[i-1];
lumSrcPtr = tmpY;
if (alpSrcPtr) {
const int16_t **tmpA = (const int16_t **) alpPixBuf + 2 * vLumBufSize;
for (i = 0; i < neg; i++)
tmpA[i] = alpSrcPtr[neg];
for ( ; i < end; i++)
tmpA[i] = alpSrcPtr[i];
for ( ; i < vLumFilterSize; i++)
tmpA[i] = tmpA[i - 1];
alpSrcPtr = tmpA;
}
}
if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize > c->chrSrcH) {
const int16_t **tmpU = (const int16_t **) chrUPixBuf + 2 * vChrBufSize;
int neg = -firstChrSrcY, i, end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize);
for (i = 0; i < neg; i++) {
tmpU[i] = chrUSrcPtr[neg];
}
for ( ; i < end; i++) {
tmpU[i] = chrUSrcPtr[i];
}
for ( ; i < vChrFilterSize; i++) {
tmpU[i] = tmpU[i - 1];
}
chrUSrcPtr = tmpU;
}
if (flags & SWS_ACCURATE_RND) {
int s= APCK_SIZE / 8;
for (i=0; i<vLumFilterSize; i+=2) {
*(const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ];
*(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)];
lumMmxFilter[s*i+APCK_COEF/4 ]=
lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ]
+ (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0);
if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
*(const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ];
*(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)];
alpMmxFilter[s*i+APCK_COEF/4 ]=
alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ];
}
}
for (i=0; i<vChrFilterSize; i+=2) {
*(const void**)&chrMmxFilter[s*i ]= chrUSrcPtr[i ];
*(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrUSrcPtr[i+(vChrFilterSize>1)];
chrMmxFilter[s*i+APCK_COEF/4 ]=
chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ]
+ (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0);
}
} else {
for (i=0; i<vLumFilterSize; i++) {
*(const void**)&lumMmxFilter[4*i+0]= lumSrcPtr[i];
lumMmxFilter[4*i+2]=
lumMmxFilter[4*i+3]=
((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001;
if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
*(const void**)&alpMmxFilter[4*i+0]= alpSrcPtr[i];
alpMmxFilter[4*i+2]=
alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2];
}
}
for (i=0; i<vChrFilterSize; i++) {
*(const void**)&chrMmxFilter[4*i+0]= chrUSrcPtr[i];
chrMmxFilter[4*i+2]=
chrMmxFilter[4*i+3]=
((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001;
}
}
}
}
| 1threat
|
error while running expect in unix : Getting error while running expect script in bash script
Input:
{
/usr/bin/expect << EOF
spawn ssh execsped@10.150.10.194 "cd /home/execsped/ram_test_72;./testecho.sh \"$evenno\" \"$eisinno\" \"$efilename\""
expect "Password"
send "abc@123\r"
expect "*#*"
EOF
}
Output:-
extra characters after close-quote
while executing
"spawn ssh execsped@10.150.10.72 "cd /home/execsped/evoting_test_72;./testecho.sh "10575" "_eVoting.pdf" "abc.pdf"
"
| 0debug
|
Delting object from array in vue props : I am getting a very strange behaviour while splicing the object from array.
I have a js array with objects. I am passing it via props and populating a navigation based on it. Now when I try to delete it inside `created hood` it deleted half and keep half.
Here is the code. Very simple
props: {
navItems: {
type: Array,
},
},
In created hook I have
let nav = this.navItems
for(let j in nav){
nav.splice(j,1)
}
console.log(nav) // print half item from the array. Shouldn't remove all?
this.nav = nav
Thank you.
| 0debug
|
How to get a depth image from velodyne data_points? : I am currently working on a problem where I have created an uint16 image of type CV_16UC1 based on velodyne data where lets say 98% of the pixels are black(value 0) and the remaining pixels have the metric depth information(distance to that point). These pixels correspond to the velodyne points from the cloud.<br>
<br>
`cv::Mat depthMat = cv::Mat::zeros(frame.size(), CV_16UC1);
depthMat = ... //here the matrice is filled`
If I try to display this image I get this:
[![enter image description here][1]][1]
From this image I need to get a denser depth image or smth that would resemble a proper depth image like in the example shown on this video: <br>
https://www.youtube.com/watch?v=4yZ4JGgLE0I
<br>
This would require proper interpolation and extrapolation of those points and it is here where is where I am stuck for days. I am a dummy when it comes to interpolation techniques. Does anyone know how this can be done or at least can point me to a working solution or example algorithm for creating a depth map from sparse data? <br>
I tried the following from the [kinect][2] examples but it did not change the output:
depthMat.convertTo(depthf, CV_8UC1, 255.0/65535);
const unsigned char noDepth = 255;
cv::Mat small_depthf, temp, temp2;
cv::resize(depthf, small_depthf, cv::Size(), 0.01, 0.01);
cv::inpaint(small_depthf, (small_depthf == noDepth), temp, 5.0, cv::INPAINT_TELEA);
cv::resize(temp, temp2, depthf.size());
temp2.copyTo(depthf, (depthf == noDepth));
cv::imshow("window",depthf);
cv::waitKey(3);
[1]: https://i.stack.imgur.com/3uhBa.png
[2]: https://www.youtube.com/watch?v=u0A4OVZxzKQ
| 0debug
|
Get position of the set bit in C : <p>I have a 4 byte data.Each bit will be acting as a switch.I need to enable/disable the switch based on the bits value in the 4 byte data.What will be the optimized way to get the positions of bit that are set out of 32 bits..?</p>
| 0debug
|
Basic Shape class and Circle Class : I have this homework assignment to do and I did most of the code, but I have an error in int main(). Here's what the assignment saids: 1. Define an abstract base class called BasicShape. The BasicShape class should have the following members:
a) Protected Member Variable: area (a double used to hold the shape’s area).
b) Private Member Variable: name (a string to indicate the shape’s type)
c) Constructor and Public Member Functions:
• BasicShape(double a, string n): A constructor that sets value of member area with a and member name with n.
• calcArea(): This public function should be a pure virtual function.
• print(): A public virtual function that only prints the value of data member area
• getName():A public function that returns the value of data member name
2. Define a class named Circle. It should be derived from the BasicShape class.
It should have the following members:
a) Private Member Variable: radius (a double used to hold the circle’s radius)
b) Constructor and Public Member Functions:
• Circle(double a, string n, double r): constructor that should call the base class constructor to initialize the member area with a and name with n. The constructor will also set the value of member radius with r
• calcArea(): Overridden function that calculates the area of the circle (area = 3.14159 * radius * radius) and stores the result in the inherited member area.
• print(): Overridden function that will print the radius, inherited member area and inherited member name. This function should use the base class’s print function to print the area.
3. After you have created these classes, create a test program
• Write a function named poly whose only parameter is a BasicShape pointer.
• Function poly should use the BasicShape pointer to invoke calcArea function and print function.
• In main(): define a Circle object with initial area 0, name Round and radius 10.
• From main(), call the function poly such that it will polymorphically invoke calcArea function and print function of the Circle object.
And here's my code:
Basic Shape.h
#ifndef BASICSHAPE_H
#define BASICSHAPE_H
#include <string>
class basicShape
{
public:
basicShape(const std::string &, double &);
double getArea() const;
virtual double calcArea() const = 0;
virtual void print()const;
std::string getname()const;
protected:
const double area;
private:
const std::string name;
};
#endif
Basic Shape.cpp
#include <iostream>
#include"Basic Shape.h"
#include <string>
using namespace std;
basicShape::basicShape(const string &n, double &a)
: area(a), name(n)
{
}
void basicShape::print() const
{
cout << "The area is: " << area;
}
string basicShape::getname() const
{
return name;
}
Circle.h
#ifndef CIRCLE_H
#define CIRCLE_H
#include <string>
#include "Basic Shape.h"
using namespace std;
class Circle : public basicShape
{
public:
Circle(const string & n, double & a, double & r);
virtual double calcArea() const override;
virtual void print() const override;
private:
double radius;
};
#endif
Circle.cpp
#include <iostream>
#include "Circle.h"
#include<string>
using namespace std;
Circle::Circle(const string &n, double &a, double &r)
:basicShape(n,a)
{
radius = r;
calcArea();
}
double Circle::calcArea() const
{
double area;
area = 3.14159*radius*radius;
return area;
}
double basicShape::getArea() const
{
return area;
}
void Circle::print() const
{
cout << "radius:" << radius;
basicShape::print();
basicShape::getname();
}
Test.cpp
#include <iostream>
#include "Basic Shape.h"
#include "Circle.h"
#include <string>
#include<vector>
using namespace std;
void poly(const basicShape * const);
int main()
{
Circle circle("Round",0.0,10.0);
vector< basicShape * > shapes(1);
for (const basicShape *basicshapePtr : shapes)
poly(basicshapePtr);
}
void poly(const basicShape * const baseClassPtr)
{
baseClassPtr->calcArea();
baseClassPtr->print();
}
| 0debug
|
what search mechanism does 're' uses in python? : <p>I mean what algorithm does it use to search? (behind)
if it's hash? then its always better to compile the string first and use it for search in later point of time, rather than calling re.match every time against whole string</p>
<p>Please share your thoughts.!</p>
| 0debug
|
How to play gif in android from url? : <p>I want to play animated gif from url in android app like imgur app. Imagur is superb and very fast. I am loading gif with webview but its not up to the mark.</p>
| 0debug
|
static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
const int *const_args)
{
int c;
switch (opc) {
case INDEX_op_exit_tb:
tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_I0, args[0]);
tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I7) |
INSN_IMM13(8));
tcg_out32(s, RESTORE | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_G0) |
INSN_RS2(TCG_REG_G0));
break;
case INDEX_op_goto_tb:
if (s->tb_jmp_offset) {
tcg_out_sethi(s, TCG_REG_I5, args[0] & 0xffffe000);
tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I5) |
INSN_IMM13((args[0] & 0x1fff)));
s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf;
} else {
tcg_out_ld_ptr(s, TCG_REG_I5, (tcg_target_long)(s->tb_next + args[0]));
tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I5) |
INSN_RS2(TCG_REG_G0));
}
tcg_out_nop(s);
s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf;
break;
case INDEX_op_call:
if (const_args[0])
tcg_out32(s, CALL | ((((tcg_target_ulong)args[0]
- (tcg_target_ulong)s->code_ptr) >> 2)
& 0x3fffffff));
else {
tcg_out_ld_ptr(s, TCG_REG_I5,
(tcg_target_long)(s->tb_next + args[0]));
tcg_out32(s, JMPL | INSN_RD(TCG_REG_O7) | INSN_RS1(TCG_REG_I5) |
INSN_RS2(TCG_REG_G0));
}
tcg_out_nop(s);
break;
case INDEX_op_jmp:
case INDEX_op_br:
tcg_out_branch_i32(s, COND_A, args[0]);
tcg_out_nop(s);
break;
case INDEX_op_movi_i32:
tcg_out_movi(s, TCG_TYPE_I32, args[0], (uint32_t)args[1]);
break;
#if TCG_TARGET_REG_BITS == 64
#define OP_32_64(x) \
glue(glue(case INDEX_op_, x), _i32): \
glue(glue(case INDEX_op_, x), _i64)
#else
#define OP_32_64(x) \
glue(glue(case INDEX_op_, x), _i32)
#endif
OP_32_64(ld8u):
tcg_out_ldst(s, args[0], args[1], args[2], LDUB);
break;
OP_32_64(ld8s):
tcg_out_ldst(s, args[0], args[1], args[2], LDSB);
break;
OP_32_64(ld16u):
tcg_out_ldst(s, args[0], args[1], args[2], LDUH);
break;
OP_32_64(ld16s):
tcg_out_ldst(s, args[0], args[1], args[2], LDSH);
break;
case INDEX_op_ld_i32:
#if TCG_TARGET_REG_BITS == 64
case INDEX_op_ld32u_i64:
#endif
tcg_out_ldst(s, args[0], args[1], args[2], LDUW);
break;
OP_32_64(st8):
tcg_out_ldst(s, args[0], args[1], args[2], STB);
break;
OP_32_64(st16):
tcg_out_ldst(s, args[0], args[1], args[2], STH);
break;
case INDEX_op_st_i32:
#if TCG_TARGET_REG_BITS == 64
case INDEX_op_st32_i64:
#endif
tcg_out_ldst(s, args[0], args[1], args[2], STW);
break;
OP_32_64(add):
c = ARITH_ADD;
goto gen_arith;
OP_32_64(sub):
c = ARITH_SUB;
goto gen_arith;
OP_32_64(and):
c = ARITH_AND;
goto gen_arith;
OP_32_64(andc):
c = ARITH_ANDN;
goto gen_arith;
OP_32_64(or):
c = ARITH_OR;
goto gen_arith;
OP_32_64(orc):
c = ARITH_ORN;
goto gen_arith;
OP_32_64(xor):
c = ARITH_XOR;
goto gen_arith;
case INDEX_op_shl_i32:
c = SHIFT_SLL;
goto gen_arith;
case INDEX_op_shr_i32:
c = SHIFT_SRL;
goto gen_arith;
case INDEX_op_sar_i32:
c = SHIFT_SRA;
goto gen_arith;
case INDEX_op_mul_i32:
c = ARITH_UMUL;
goto gen_arith;
OP_32_64(neg):
c = ARITH_SUB;
goto gen_arith1;
OP_32_64(not):
c = ARITH_ORN;
goto gen_arith1;
case INDEX_op_div_i32:
tcg_out_div32(s, args[0], args[1], args[2], const_args[2], 0);
break;
case INDEX_op_divu_i32:
tcg_out_div32(s, args[0], args[1], args[2], const_args[2], 1);
break;
case INDEX_op_rem_i32:
case INDEX_op_remu_i32:
tcg_out_div32(s, TCG_REG_I5, args[1], args[2], const_args[2],
opc == INDEX_op_remu_i32);
tcg_out_arithc(s, TCG_REG_I5, TCG_REG_I5, args[2], const_args[2],
ARITH_UMUL);
tcg_out_arith(s, args[0], args[1], TCG_REG_I5, ARITH_SUB);
break;
case INDEX_op_brcond_i32:
tcg_out_brcond_i32(s, args[2], args[0], args[1], const_args[1],
args[3]);
break;
case INDEX_op_setcond_i32:
tcg_out_setcond_i32(s, args[3], args[0], args[1],
args[2], const_args[2]);
break;
#if TCG_TARGET_REG_BITS == 32
case INDEX_op_brcond2_i32:
tcg_out_brcond2_i32(s, args[4], args[0], args[1],
args[2], const_args[2],
args[3], const_args[3], args[5]);
break;
case INDEX_op_setcond2_i32:
tcg_out_setcond2_i32(s, args[5], args[0], args[1], args[2],
args[3], const_args[3],
args[4], const_args[4]);
break;
case INDEX_op_add2_i32:
tcg_out_arithc(s, args[0], args[2], args[4], const_args[4],
ARITH_ADDCC);
tcg_out_arithc(s, args[1], args[3], args[5], const_args[5],
ARITH_ADDX);
break;
case INDEX_op_sub2_i32:
tcg_out_arithc(s, args[0], args[2], args[4], const_args[4],
ARITH_SUBCC);
tcg_out_arithc(s, args[1], args[3], args[5], const_args[5],
ARITH_SUBX);
break;
case INDEX_op_mulu2_i32:
tcg_out_arithc(s, args[0], args[2], args[3], const_args[3],
ARITH_UMUL);
tcg_out_rdy(s, args[1]);
break;
#endif
case INDEX_op_qemu_ld8u:
tcg_out_qemu_ld(s, args, 0);
break;
case INDEX_op_qemu_ld8s:
tcg_out_qemu_ld(s, args, 0 | 4);
break;
case INDEX_op_qemu_ld16u:
tcg_out_qemu_ld(s, args, 1);
break;
case INDEX_op_qemu_ld16s:
tcg_out_qemu_ld(s, args, 1 | 4);
break;
case INDEX_op_qemu_ld32:
#if TCG_TARGET_REG_BITS == 64
case INDEX_op_qemu_ld32u:
#endif
tcg_out_qemu_ld(s, args, 2);
break;
#if TCG_TARGET_REG_BITS == 64
case INDEX_op_qemu_ld32s:
tcg_out_qemu_ld(s, args, 2 | 4);
break;
#endif
case INDEX_op_qemu_ld64:
tcg_out_qemu_ld(s, args, 3);
break;
case INDEX_op_qemu_st8:
tcg_out_qemu_st(s, args, 0);
break;
case INDEX_op_qemu_st16:
tcg_out_qemu_st(s, args, 1);
break;
case INDEX_op_qemu_st32:
tcg_out_qemu_st(s, args, 2);
break;
case INDEX_op_qemu_st64:
tcg_out_qemu_st(s, args, 3);
break;
#if TCG_TARGET_REG_BITS == 64
case INDEX_op_movi_i64:
tcg_out_movi(s, TCG_TYPE_I64, args[0], args[1]);
break;
case INDEX_op_ld32s_i64:
tcg_out_ldst(s, args[0], args[1], args[2], LDSW);
break;
case INDEX_op_ld_i64:
tcg_out_ldst(s, args[0], args[1], args[2], LDX);
break;
case INDEX_op_st_i64:
tcg_out_ldst(s, args[0], args[1], args[2], STX);
break;
case INDEX_op_shl_i64:
c = SHIFT_SLLX;
goto gen_arith;
case INDEX_op_shr_i64:
c = SHIFT_SRLX;
goto gen_arith;
case INDEX_op_sar_i64:
c = SHIFT_SRAX;
goto gen_arith;
case INDEX_op_mul_i64:
c = ARITH_MULX;
goto gen_arith;
case INDEX_op_div_i64:
c = ARITH_SDIVX;
goto gen_arith;
case INDEX_op_divu_i64:
c = ARITH_UDIVX;
goto gen_arith;
case INDEX_op_rem_i64:
case INDEX_op_remu_i64:
tcg_out_arithc(s, TCG_REG_I5, args[1], args[2], const_args[2],
opc == INDEX_op_rem_i64 ? ARITH_SDIVX : ARITH_UDIVX);
tcg_out_arithc(s, TCG_REG_I5, TCG_REG_I5, args[2], const_args[2],
ARITH_MULX);
tcg_out_arith(s, args[0], args[1], TCG_REG_I5, ARITH_SUB);
break;
case INDEX_op_ext32s_i64:
if (const_args[1]) {
tcg_out_movi(s, TCG_TYPE_I64, args[0], (int32_t)args[1]);
} else {
tcg_out_arithi(s, args[0], args[1], 0, SHIFT_SRA);
}
break;
case INDEX_op_ext32u_i64:
if (const_args[1]) {
tcg_out_movi_imm32(s, args[0], args[1]);
} else {
tcg_out_arithi(s, args[0], args[1], 0, SHIFT_SRL);
}
break;
case INDEX_op_brcond_i64:
tcg_out_brcond_i64(s, args[2], args[0], args[1], const_args[1],
args[3]);
break;
case INDEX_op_setcond_i64:
tcg_out_setcond_i64(s, args[3], args[0], args[1],
args[2], const_args[2]);
break;
#endif
gen_arith:
tcg_out_arithc(s, args[0], args[1], args[2], const_args[2], c);
break;
gen_arith1:
tcg_out_arithc(s, args[0], TCG_REG_G0, args[1], const_args[1], c);
break;
default:
fprintf(stderr, "unknown opcode 0x%x\n", opc);
tcg_abort();
}
}
| 1threat
|
void qdev_prop_set_globals_for_type(DeviceState *dev, const char *typename,
Error **errp)
{
GlobalProperty *prop;
QTAILQ_FOREACH(prop, &global_props, next) {
Error *err = NULL;
if (strcmp(typename, prop->driver) != 0) {
continue;
}
prop->not_used = false;
object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
}
}
| 1threat
|
Pipenv stuck "⠋ Locking..." : <p>Why is my pipenv stuck in the "Locking..." stage when installing [numpy|opencv|pandas]? </p>
<p>When running <code>pipenv install pandas</code> or <code>pipenv update</code> it hangs for a really long time with a message and loading screen that says it's still locking. Why? What do I need to do?</p>
| 0debug
|
static void RENAME(yuv2rgb555_2)(SwsContext *c, const uint16_t *buf0,
const uint16_t *buf1, const uint16_t *ubuf0,
const uint16_t *ubuf1, const uint16_t *vbuf0,
const uint16_t *vbuf1, const uint16_t *abuf0,
const uint16_t *abuf1, uint8_t *dest,
int dstW, int yalpha, int uvalpha, int y)
{
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
"pxor %%mm7, %%mm7 \n\t"
#ifdef DITHER1XBPP
"paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
"paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
"paddusb "RED_DITHER"(%5), %%mm5 \n\t"
#endif
WRITERGB15(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
}
| 1threat
|
static int connect_to_ssh(BDRVSSHState *s, QDict *options,
int ssh_flags, int creat_mode)
{
int r, ret;
Error *err = NULL;
const char *host, *user, *path, *host_key_check;
int port;
host = qdict_get_str(options, "host");
if (qdict_haskey(options, "port")) {
port = qdict_get_int(options, "port");
} else {
port = 22;
}
path = qdict_get_str(options, "path");
if (qdict_haskey(options, "user")) {
user = qdict_get_str(options, "user");
} else {
user = g_get_user_name();
if (!user) {
ret = -errno;
goto err;
}
}
if (qdict_haskey(options, "host_key_check")) {
host_key_check = qdict_get_str(options, "host_key_check");
} else {
host_key_check = "yes";
}
g_free(s->hostport);
s->hostport = g_strdup_printf("%s:%d", host, port);
s->sock = inet_connect(s->hostport, &err);
if (err != NULL) {
ret = -errno;
qerror_report_err(err);
error_free(err);
goto err;
}
s->session = libssh2_session_init();
if (!s->session) {
ret = -EINVAL;
session_error_report(s, "failed to initialize libssh2 session");
goto err;
}
#if TRACE_LIBSSH2 != 0
libssh2_trace(s->session, TRACE_LIBSSH2);
#endif
r = libssh2_session_handshake(s->session, s->sock);
if (r != 0) {
ret = -EINVAL;
session_error_report(s, "failed to establish SSH session");
goto err;
}
ret = check_host_key(s, host, port, host_key_check, &err);
if (ret < 0) {
qerror_report_err(err);
error_free(err);
goto err;
}
ret = authenticate(s, user);
if (ret < 0) {
goto err;
}
s->sftp = libssh2_sftp_init(s->session);
if (!s->sftp) {
session_error_report(s, "failed to initialize sftp handle");
ret = -EINVAL;
goto err;
}
DPRINTF("opening file %s flags=0x%x creat_mode=0%o",
path, ssh_flags, creat_mode);
s->sftp_handle = libssh2_sftp_open(s->sftp, path, ssh_flags, creat_mode);
if (!s->sftp_handle) {
session_error_report(s, "failed to open remote file '%s'", path);
ret = -EINVAL;
goto err;
}
r = libssh2_sftp_fstat(s->sftp_handle, &s->attrs);
if (r < 0) {
sftp_error_report(s, "failed to read file attributes");
return -EINVAL;
}
qdict_del(options, "host");
qdict_del(options, "port");
qdict_del(options, "user");
qdict_del(options, "path");
qdict_del(options, "host_key_check");
return 0;
err:
if (s->sftp_handle) {
libssh2_sftp_close(s->sftp_handle);
}
s->sftp_handle = NULL;
if (s->sftp) {
libssh2_sftp_shutdown(s->sftp);
}
s->sftp = NULL;
if (s->session) {
libssh2_session_disconnect(s->session,
"from qemu ssh client: "
"error opening connection");
libssh2_session_free(s->session);
}
s->session = NULL;
return ret;
}
| 1threat
|
Does React keep the order for state updates? : <p>I know that React may perform state updates asynchronously and in batch for performance optimization. Therefore you can never trust the state to be updated after having called <code>setState</code>. But can you trust React to <strong>update the state in the same order as <code>setState</code> is called</strong> for</p>
<ol>
<li>the same component?</li>
<li>different components?</li>
</ol>
<p>Consider clicking the button in the following examples:</p>
<p><strong>1.</strong> Is there ever a possibility that <strong>a is false and b is true</strong> for:</p>
<pre><code>class Container extends React.Component {
constructor(props) {
super(props);
this.state = { a: false, b: false };
}
render() {
return <Button onClick={this.handleClick}/>
}
handleClick = () => {
this.setState({ a: true });
this.setState({ b: true });
}
}
</code></pre>
<p><strong>2.</strong> Is there ever a possibility that <strong>a is false and b is true</strong> for:</p>
<pre><code>class SuperContainer extends React.Component {
constructor(props) {
super(props);
this.state = { a: false };
}
render() {
return <Container setParentState={this.setState.bind(this)}/>
}
}
class Container extends React.Component {
constructor(props) {
super(props);
this.state = { b: false };
}
render() {
return <Button onClick={this.handleClick}/>
}
handleClick = () => {
this.props.setParentState({ a: true });
this.setState({ b: true });
}
}
</code></pre>
<p>Keep in mind that these are extreme simplifications of my use case. I realize that I can do this differently, e.g. updating both state params at the same time in example 1, as well as performing the second state update in a callback to the first state update in example 2. However, this is not my question, and I am only interested in if there is a well defined way that React performs these state updates, nothing else.</p>
<p>Any answer backed up by documentation is greatly appreciated.</p>
| 0debug
|
Angular 6 - Passing messages via service to from component to message component : <p>I am trying out how to pass a message from <code>app.component.ts</code> to be displayed in <code>messageComponent.ts</code></p>
<p>on <code>app.component.html</code> I have added <code><app-messagecomponent></app-messagecomponent></code></p>
<p>Add the moment it's just showing nothing.</p>
<p>I also have a method in a service:</p>
<p>message.service.ts</p>
<pre><code>message(message) {
return message;
}
</code></pre>
<p>So what I want to do to pass a message from other components via the message service so it's displaying in the app-messagecomponent.html</p>
<p>For example from app.component.ts:</p>
<pre><code>sendMessageToService() {
this.myservice.message('my Message to be displayed in the messageComponent');
}
</code></pre>
<p>How can I do this?</p>
| 0debug
|
'string' does not contain a constructor that takes 0 arguments -- why? :/ : <p>I try serialize my list to string and error "'string' does not contain a constructor that takes 0 arguments"</p>
<pre><code>[Serializable]
class ComponentSerialization
{
public string komponent;
/**
* Konstruktor
*/
public ComponentSerialization(string v) {
ustawKomponent(v);
}
public void ustawKomponent(string v) {
this.komponent = v;
}
public string pobierzKomponent() {
string kom = new string();
kom = this.komponent;
return kom;
}
}
</code></pre>
<p>why not working? :/</p>
| 0debug
|
Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies : <p>I have a WinJS project that is previously built on Windows 8.1 using VS 2013. </p>
<p>Recently I upgraded this project to Universal Windows 10 by creating a blank Javascript Universal windows 10 project and then added all my files from old project. </p>
<p>I have Windows Runtime Components and also Class Library for SQLite. </p>
<p>I added Universal Windows Runtime Component and Universal Class Library and copied all my files from old project to respective places.</p>
<p>Somehow I managed to remove all the build errors. </p>
<p>I installed all the required SQLite-net, SQLite for Universal Windows Platform, Newtonsoft, etc.</p>
<p>But when I run the application and call a Native method in Windows Runtime Component it gives some kind of strange errors as:</p>
<p><code>An exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll but was not handled in user code.</code></p>
<p><code>Additional information: Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.</code></p>
<p><a href="https://i.stack.imgur.com/inIpi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/inIpi.png" alt="enter image description here"></a></p>
<p>Newtonsoft version is: 9.0.1</p>
<p>My <strong>project.json</strong> file of Windows Runtime Component has following:</p>
<pre><code> {
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0",
"Newtonsoft.Json": "9.0.1"
},
"frameworks": {
"uap10.0": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}
</code></pre>
<p>My Visual Studio version is:</p>
<p><a href="https://i.stack.imgur.com/YldNd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YldNd.png" alt="enter image description here"></a></p>
<p>I tried removing all the Newtonsoft json and re-installing it but no luck.</p>
| 0debug
|
Confuse about error and reject in Promise : <p>All:</p>
<p>I am pretty new to JS Promise, there is one confuse when it comes to Promise chaining, say I have a promise chaining like:</p>
<pre><code>var p = new Promise(function(res, rej){
})
.then(
function(data){
},
function(err){
})
.then(
function(data){
},
function(err){
})
.catch(
function(err){
})
</code></pre>
<p>What confuse me:</p>
<ol>
<li>When the function(err) get called and when the catch get called?</li>
<li>How to resolve and reject in <code>then</code>?</li>
</ol>
<p>Thanks</p>
| 0debug
|
Overriding Bootstrap's CSS : <p>I can't seem to override Bootstrap's CSS despite following instructions found in other questions. </p>
<pre><code><!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<!-- Custom CSS -->
<link rel="stylesheet" href="css/styles.css">
...
<!-- GRID SECTION -->
<div class="container">
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-8">
<h1 id="title">TITLE</h1>
</div>
<div class="col-md-2">
</div>
</div>
</div>
</code></pre>
<p>The CSS it this:</p>
<pre><code>@font-face {
font-family: hnl;
src: url('fonts/hnl.otf');
}
body {
font-family: hnl;
}
#title {
font-family: hnl;
text-align: center;
}
</code></pre>
<p>However, the font doesn't change, and the text does not align.
How can override Bootstrap's CSS?</p>
| 0debug
|
Merge an array of hashes in Ruby depending upon a key-value pair : I have an array of hashes with fixed key-value pair as follows:
[
{'abc_id'=>'1234', 'def_id'=>[]},
{'abc_id'=>'5678', 'def_id'=>['11', '22']},
{'abc_id'=>'1234', 'def_id'=>['33', '44']},
{'abc_id'=>'5678', 'def_id'=>['55', '66']}
]
Here, I'm trying to identify multiple matches of a single key-value pair and combine multiple hashes into one hash.
As per above example, we have two matching pairs with same value for 'abc_id' key as follows:
{'abc_id'=>'1234', 'def_id'=>[]} & {'abc_id'=>'1234', 'def_id'=>['33', '44']}
and
{'abc_id'=>'5678', 'def_id'=>['11', '22']} & {'abc_id'=>'5678', 'def_id'=>['55', '66']}
I'm expecting multiple hashes with same key-value pairs to be merged into one individual hash as follows:
For first pair it should be:
{'abc_id'=>'1234', 'def_id'=>['33', '44']}
and
for second pair it should be:
{'abc_id'=>'5678', 'def_id'=>['11', '22', '55', '66']}
| 0debug
|
How to create new database in neo4j? : <p>I'm using Linux 16.04 OS. I have installed fresh neo4j. I get referenced <a href="http://www.exegetic.biz/blog/2016/09/installing-neo4j-ubuntu-16-04/" rel="noreferrer">exegetic</a> and <a href="https://www.digitalocean.com/community/tutorials/how-to-install-neo4j-on-an-ubuntu-vps" rel="noreferrer">digitalocean</a> sites.</p>
<p>By default there's <strong>graph.db</strong> database.</p>
<blockquote>
<p>My question is how to create a new database and create nodes and
relation ship between nodes?</p>
</blockquote>
<p>As I show in picture default DB name is <strong>graph.db</strong>.</p>
<p><a href="https://i.stack.imgur.com/C0MmA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/C0MmA.png" alt="enter image description here"></a></p>
| 0debug
|
Can I use a Tag Helper in a custom Tag Helper that returns html? : <p>I recently ran into a situation where I would like to use a tag helper within a tag helper. I looked around and couldn't find anyone else trying to do this, am I using a poor convention or am I missing documentation?</p>
<p>Ex. <em>Tag Helper A</em> outputs HTML that contains another tag helper. </p>
<p>Ex. </p>
<pre><code>[HtmlTargetElement("tag-name")]
public class RazorTagHelper : TagHelper
{
public override void Process(TagHelperContext context, TagHelperOutput output)
{
StringBuilder sb = new StringBuilder();
sb.Append("<a asp-action=\"Home\" ");
output.Content.SetHtmlContent(sb.ToString());
}
}
</code></pre>
<p>Is there a way for me to process the <code><a asp-action> </a></code> tag helper from C#? Or to reprocess the output HTML with tag helpers?</p>
| 0debug
|
Why would it be illegal to inform about “abort”? : <p>The <a href="https://www.gnu.org/software/libc/manual/html_node/Aborting-a-Program.html#Aborting-a-Program" rel="noreferrer">GNU libc documentation of the <code>abort</code> function</a> contains the following notice:</p>
<blockquote>
<p><strong>Future Change Warning:</strong> Proposed Federal censorship regulations may prohibit us from giving you information about the possibility of calling this function. We would be required to say that this is not an acceptable way of terminating a program.</p>
</blockquote>
<p>Uh, what?</p>
<p>I found a seven-year-old <a href="https://www.reddit.com/r/linux/comments/d4783/federal_censorship_regulations_may_restrict/" rel="noreferrer">Reddit thread</a> discussing this. It appears that the notice was put in by Richard Stallman in 1995 — so it’s been in there for a while. However, except for <a href="https://sourceware.org/ml/glibc-linux/1999-q3/msg00013.html" rel="noreferrer">a 1999 mailing list thread</a> claiming it’s a joke, I couldn’t find any further information.</p>
<p>So: is this just an Easter egg put in by rms? Or is it serious (though probably no longer relevant)? If so, what does/did it refer to?</p>
<p>The <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/abort.html" rel="noreferrer">Open Group POSIX documentation</a> of the same function doesn’t include anything similar, nor do any of the man pages I consulted.</p>
| 0debug
|
static void coroutine_fn v9fs_link(void *opaque)
{
V9fsPDU *pdu = opaque;
int32_t dfid, oldfid;
V9fsFidState *dfidp, *oldfidp;
V9fsString name;
size_t offset = 7;
int err = 0;
v9fs_string_init(&name);
err = pdu_unmarshal(pdu, offset, "dds", &dfid, &oldfid, &name);
if (err < 0) {
goto out_nofid;
}
trace_v9fs_link(pdu->tag, pdu->id, dfid, oldfid, name.data);
if (name_is_illegal(name.data)) {
err = -ENOENT;
goto out_nofid;
}
if (!strcmp(".", name.data) || !strcmp("..", name.data)) {
err = -EEXIST;
goto out_nofid;
}
dfidp = get_fid(pdu, dfid);
if (dfidp == NULL) {
err = -ENOENT;
goto out_nofid;
}
oldfidp = get_fid(pdu, oldfid);
if (oldfidp == NULL) {
err = -ENOENT;
goto out;
}
err = v9fs_co_link(pdu, oldfidp, dfidp, &name);
if (!err) {
err = offset;
}
out:
put_fid(pdu, dfidp);
out_nofid:
v9fs_string_free(&name);
pdu_complete(pdu, err);
}
| 1threat
|
Creating repeating set from another column in R : <p>Using these dataset:</p>
<pre><code>[A]
100
200
300
[B]
A
B
C
</code></pre>
<p>I would like to make this column:</p>
<pre><code>[A] [B]
100 A
100 B
100 C
200 A
200 B
200 C
300 A
300 B
300 C
</code></pre>
<p>I would like to use rep function in R, but it does not work.
How do I create this column? </p>
| 0debug
|
How to open a device in Rust such as "/dev/something"? : In C I can use the function "open" to open a file or anything else such "/dev/something". How can I open "/dev/something" in Rust?
| 0debug
|
int net_init_tap(QemuOpts *opts, const char *name, VLANState *vlan)
{
const char *ifname;
ifname = qemu_opt_get(opts, "ifname");
if (!ifname) {
error_report("tap: no interface name");
return -1;
}
if (tap_win32_init(vlan, "tap", name, ifname) == -1) {
return -1;
}
return 0;
}
| 1threat
|
static void grlib_gptimer_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
GPTimerUnit *unit = opaque;
target_phys_addr_t timer_addr;
int id;
addr &= 0xff;
switch (addr) {
case SCALER_OFFSET:
value &= 0xFFFF;
unit->scaler = value;
trace_grlib_gptimer_writel(-1, addr, unit->scaler);
return;
case SCALER_RELOAD_OFFSET:
value &= 0xFFFF;
unit->reload = value;
trace_grlib_gptimer_writel(-1, addr, unit->reload);
grlib_gptimer_set_scaler(unit, value);
return;
case CONFIG_OFFSET:
trace_grlib_gptimer_writel(-1, addr, 0);
return;
default:
break;
}
timer_addr = (addr % TIMER_BASE);
id = (addr - TIMER_BASE) / TIMER_BASE;
if (id >= 0 && id < unit->nr_timers) {
switch (timer_addr) {
case COUNTER_OFFSET:
trace_grlib_gptimer_writel(id, addr, value);
unit->timers[id].counter = value;
grlib_gptimer_enable(&unit->timers[id]);
return;
case COUNTER_RELOAD_OFFSET:
trace_grlib_gptimer_writel(id, addr, value);
unit->timers[id].reload = value;
return;
case CONFIG_OFFSET:
trace_grlib_gptimer_writel(id, addr, value);
if (value & GPTIMER_INT_PENDING) {
value &= ~GPTIMER_INT_PENDING;
} else {
value |= unit->timers[id].config & GPTIMER_INT_PENDING;
}
unit->timers[id].config = value;
if (value & GPTIMER_LOAD) {
grlib_gptimer_restart(&unit->timers[id]);
} else if (value & GPTIMER_ENABLE) {
grlib_gptimer_enable(&unit->timers[id]);
}
value &= ~(GPTIMER_LOAD & GPTIMER_DEBUG_HALT);
unit->timers[id].config = value;
return;
default:
break;
}
}
trace_grlib_gptimer_writel(-1, addr, value);
}
| 1threat
|
why "lambda x: x ()()()()" works in Python? : I put several '()' after a lambda, seems Python ignores them rather than throwing error. Why? Thanks.
my code as
>>> lambda x: x ()()()()
<function <lambda> at 0x105ca7ed8>
>>> lambda x: x (1)(2)(dfdf)()
<function <lambda> at 0x105cae578>
| 0debug
|
static av_cold int nvenc_recalc_surfaces(AVCodecContext *avctx)
{
NvencContext *ctx = avctx->priv_data;
int nb_surfaces = 0;
if (ctx->rc_lookahead > 0) {
nb_surfaces = ctx->rc_lookahead + ((ctx->encode_config.frameIntervalP > 0) ? ctx->encode_config.frameIntervalP : 0) + 1 + 4;
if (ctx->nb_surfaces < nb_surfaces) {
av_log(avctx, AV_LOG_WARNING,
"Defined rc_lookahead requires more surfaces, "
"increasing used surfaces %d -> %d\n", ctx->nb_surfaces, nb_surfaces);
ctx->nb_surfaces = nb_surfaces;
}
}
ctx->nb_surfaces = FFMAX(1, FFMIN(MAX_REGISTERED_FRAMES, ctx->nb_surfaces));
ctx->async_depth = FFMIN(ctx->async_depth, ctx->nb_surfaces - 1);
return 0;
}
| 1threat
|
static int RENAME(resample_common)(ResampleContext *c,
DELEM *dst, const DELEM *src,
int n, int update_ctx)
{
int dst_index;
int index= c->index;
int frac= c->frac;
int sample_index = index >> c->phase_shift;
index &= c->phase_mask;
for (dst_index = 0; dst_index < n; dst_index++) {
FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index;
FELEM2 val=0;
int i;
for (i = 0; i < c->filter_length; i++) {
val += src[sample_index + i] * (FELEM2)filter[i];
}
OUT(dst[dst_index], val);
frac += c->dst_incr_mod;
index += c->dst_incr_div;
if (frac >= c->src_incr) {
frac -= c->src_incr;
index++;
}
sample_index += index >> c->phase_shift;
index &= c->phase_mask;
}
if(update_ctx){
c->frac= frac;
c->index= index;
}
return sample_index;
}
| 1threat
|
static void default_show_tags(WriterContext *wctx, AVDictionary *dict)
{
AVDictionaryEntry *tag = NULL;
while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) {
printf("TAG:");
writer_print_string(wctx, tag->key, tag->value);
}
}
| 1threat
|
Android - setAdapter View Pager in a fragment :
I want using image slide with ViewPager in **"extends Fragment {"**, but is error and **Red Line** in Activity **"Beranda"**
Can you help me? please :')
----------
## Beranda [this Activity] ##
package com.dolog.om.radarfutsalbooking;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
import me.relex.circleindicator.CircleIndicator;
public class Beranda extends Fragment {
private static ViewPager mPager;
private static int currentPage = 0;
private static final Integer[] XMEN = {R.drawable.beast, R.drawable.charles, R.drawable.magneto, R.drawable.mystique, R.drawable.wolverine};
private ArrayList<Integer> XMENArray = new ArrayList<Integer>();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.activity_beranda, container, false);
for (int i = 0; i < XMEN.length; i++)
XMENArray.add(XMEN[i]);
mPager = (ViewPager) rootView.findViewById(R.id.pager);
mPager.setAdapter(new MyAdapter(Beranda.this, XMENArray));
CircleIndicator indicator = (CircleIndicator) rootView.findViewById(R.id.indicator);
indicator.setViewPager(mPager);
// Auto start of viewpager
final Handler handler = new Handler();
final Runnable Update = new Runnable() {
public void run() {
if (currentPage == XMEN.length) {
currentPage = 0;
}
mPager.setCurrentItem(currentPage++, true);
}
};
Timer swipeTimer = new Timer();
swipeTimer.schedule(new TimerTask() {
@Override
public void run() {
handler.post(Update);
}
}, 5000, 5000);
FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fabberanda);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
return rootView;
}
}
## MyAdapter [this Activity] ##
package com.dolog.om.radarfutsalbooking;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import java.util.ArrayList;
public class MyAdapter extends PagerAdapter {
private ArrayList<Integer> images;
private LayoutInflater inflater;
private Context context;
public MyAdapter(Context context, ArrayList<Integer> images) {
this.context = context;
this.images=images;
inflater = LayoutInflater.from(context);
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
@Override
public int getCount() {
return images.size();
}
@Override
public Object instantiateItem(ViewGroup view, int position) {
View myImageLayout = inflater.inflate(R.layout.slide, view, false);
ImageView myImage = (ImageView) myImageLayout.findViewById(R.id.image);
myImage.setImageResource(images.get(position));
view.addView(myImageLayout, 0);
return myImageLayout;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view.equals(object);
}
And this problem [enter image description here][1]
[1]: https://i.stack.imgur.com/Lhv1n.png
| 0debug
|
Concatenating strings in a table row from the db : <p>How do I display the fullname on a table from the firstname and secondname in my database using php or js?</p>
| 0debug
|
X code fill an asset with colour : I have a variable `var image = SKSpriteNode(imageNamed: "image")` and it is an outline. I want to fill the image with colour but do not know the code necessary. Would someone be able to provide a solution.
Thanks,
A struggling programmer
| 0debug
|
New Flutter Project wizard not showing on Android Studio 3.0.1 : <p>I installed Flutter following official document and also installed Flutter and Dart plugin on Android Studio.</p>
<p>But, I can't see File>New Flutter Project wizard on Android Studio 3.0.1</p>
<p>I run "flutter doctor" command. See the below output. </p>
<pre><code>Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.1.5, on Mac OS X 10.13.3 17D102, locale en-TR)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.2)
[✓] Android Studio (version 3.0)
[✓] IntelliJ IDEA Community Edition (version 2017.3.3)
[!] Connected devices
! No devices available
! Doctor found issues in 1 category.
</code></pre>
| 0debug
|
Time Series Data - How to : <p>I'm thinking about doing a study over one month where the subject records how much he drinks and how often he urinates.</p>
<p>I want to get the subject to record these activities on a daily basis so that I have a month of data (times of urination each day, volume and times of drink taken each day). Once I have a month of this data for one subject, I want to be able to compare it to similar data from other subjects. The differences between the subjects would be weight, age, sex, underlying illness etc ...</p>
<p>I assume this will be done using time series software? If this is appropriate could someone point me in the right direction so that I can crib the appropriate code?</p>
<p>So far I've found <a href="https://stackoverflow.com/questions/4908057/time-series-data-manipulation">Time-Series Data manipulation</a> am I heading in the right direction? I am only at the planning stage.</p>
| 0debug
|
How to resize Image with SwiftUI? : <p>I have a large image in Assets.xcassets. How to resize this image with SwiftUI to make it small?</p>
<p>I tried to set frame but it doesn't work:</p>
<pre><code>Image(room.thumbnailImage)
.frame(width: 32.0, height: 32.0)
</code></pre>
| 0debug
|
In SQL, Whether sysjobs will tell which jobs are failed? : In SQL, Whether sysjobs will tell which jobs are failed?
We have around 100 jobs running on SQL Agent. We have set up an email alert notification for any job failed.
Is there a way for us to run a query to identify list of Jobs are failed.
Below query will provide, list of jobs enabled.
select * from MSDB.dbo.sysjobs where enabled = 1
| 0debug
|
How to add another IF condition into Formula? : I have the following formula and trying to add another IF Condition. I need to add IF B3>B2 Then Return 1. Thanks!
=IF($A$1>3,I1,$B$1)
| 0debug
|
av_cold int ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_height)
{
int p, b, x, y, x_tiles, y_tiles, t_width, t_height;
IVIBandDesc *band;
IVITile *tile, *ref_tile;
for (p = 0; p < 3; p++) {
t_width = !p ? tile_width : (tile_width + 3) >> 2;
t_height = !p ? tile_height : (tile_height + 3) >> 2;
if (!p && planes[0].num_bands == 4) {
t_width >>= 1;
t_height >>= 1;
}
if(t_width<=0 || t_height<=0)
return AVERROR(EINVAL);
for (b = 0; b < planes[p].num_bands; b++) {
band = &planes[p].bands[b];
x_tiles = IVI_NUM_TILES(band->width, t_width);
y_tiles = IVI_NUM_TILES(band->height, t_height);
band->num_tiles = x_tiles * y_tiles;
av_freep(&band->tiles);
band->tiles = av_mallocz(band->num_tiles * sizeof(IVITile));
if (!band->tiles)
return AVERROR(ENOMEM);
tile = band->tiles;
ref_tile = planes[0].bands[0].tiles;
for (y = 0; y < band->height; y += t_height) {
for (x = 0; x < band->width; x += t_width) {
tile->xpos = x;
tile->ypos = y;
tile->mb_size = band->mb_size;
tile->width = FFMIN(band->width - x, t_width);
tile->height = FFMIN(band->height - y, t_height);
tile->is_empty = tile->data_size = 0;
tile->num_MBs = IVI_MBs_PER_TILE(tile->width, tile->height,
band->mb_size);
av_freep(&tile->mbs);
tile->mbs = av_malloc(tile->num_MBs * sizeof(IVIMbInfo));
if (!tile->mbs)
return AVERROR(ENOMEM);
tile->ref_mbs = 0;
if (p || b) {
tile->ref_mbs = ref_tile->mbs;
ref_tile++;
}
tile++;
}
}
}
}
return 0;
}
| 1threat
|
How to solve this problem realted to nested lists in PYTHON : Given the names and grades for each student in a Physics class of students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade. Note: If there are multiple students with the same grade, order their names alphabetically and print each name on a new line.
SAMPLE INPUT
5
Harry
37.21
Berry
37.21
Tina
37.2
Akriti
41
Harsh
39
SAMPLE OUTPUT
Berry
Harry
| 0debug
|
How to 'insert if not exists' in php MySQL : <p>I started by googling, and found this article which talks about mutex tables.</p>
<p>I have a table with ~14 million records. If I want to add more data in the same format, is there a way to ensure the record I want to insert does not already exist without using a pair of queries (ie, one query to check and one to insert is the result set is empty)?</p>
<p>Does a unique constraint on a field guarantee the insert will fail if it's already there?</p>
<p>It seems that with merely a constraint, when I issue the insert via php, the script croaks.</p>
| 0debug
|
Is there a way to 'buffer' a background-image in css? : <p>I want my bacgkround-image, which is fairly large, to slowly buffer (not sure if this is the correct use of the word), like first being bad quality then better and then best. IMHO the 'normal' loading mode of displaying a few lines until it has loaded looks ugly. Is there a way to do this?</p>
| 0debug
|
void av_destruct_packet(AVPacket *pkt)
{
int i;
av_free(pkt->data);
pkt->data = NULL; pkt->size = 0;
for (i = 0; i < pkt->side_data_elems; i++)
av_free(pkt->side_data[i].data);
av_freep(&pkt->side_data);
pkt->side_data_elems = 0;
}
| 1threat
|
BlockDriverState *bdrv_new(void)
{
BlockDriverState *bs;
int i;
bs = g_new0(BlockDriverState, 1);
QLIST_INIT(&bs->dirty_bitmaps);
for (i = 0; i < BLOCK_OP_TYPE_MAX; i++) {
QLIST_INIT(&bs->op_blockers[i]);
}
notifier_with_return_list_init(&bs->before_write_notifiers);
bs->refcnt = 1;
bs->aio_context = qemu_get_aio_context();
QTAILQ_INSERT_TAIL(&all_bdrv_states, bs, bs_list);
return bs;
}
| 1threat
|
Javascript array value as HTML src value : I'm a complete beginner to HTML and Javascript and I've encountered this problem. I have a button and under `onclick`, I have :
onclick="document.getElementById('slideCurrent').src=images[1]"
and in the Javascript portion, I have :
var images = [
"PATH BLABLABLA_1",
"PATH BLABLABLA_2",
"PATH BLABLABLA_3"
];
and for some reason, it won't display the image. However, if I put the path directly there, it will work normally.
What can I do to fix this?
Thanks.
| 0debug
|
document.write('<script src="evil.js"></script>');
| 1threat
|
static void fw_cfg_mem_realize(DeviceState *dev, Error **errp)
{
FWCfgMemState *s = FW_CFG_MEM(dev);
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
memory_region_init_io(&s->ctl_iomem, OBJECT(s), &fw_cfg_ctl_mem_ops,
FW_CFG(s), "fwcfg.ctl", FW_CFG_SIZE);
sysbus_init_mmio(sbd, &s->ctl_iomem);
memory_region_init_io(&s->data_iomem, OBJECT(s), &fw_cfg_data_mem_ops,
FW_CFG(s), "fwcfg.data",
fw_cfg_data_mem_ops.valid.max_access_size);
sysbus_init_mmio(sbd, &s->data_iomem);
}
| 1threat
|
jquery catch event from a generated element : <p>I am getting data from AJAX to build a table. This table will have a link to delete a row from the database. I'm having trouble getting a listener to respond to a click on the generated content's "remove" link.</p>
<pre><code><!-- contribId is populated initially from PHP -->
<input id="hidden-contrib-id" value="<?= $contribId ?>" />
<div id="checksEnteredContainer">
</div>
<script>
$(document).ready(function(){
// get data via ajax and build table
buildCheckEnteredTable($('#hidden-contrib-id').val());
// various listeners here...
$('.remove_check').on('click', function() {
alert($(this).data('contribution-id'));
});
});
/**
* Get checks from database
*/
function buildCheckEnteredTable(contribId) {
var url = "/path/to/script";
var response = $.post(url, {action: 'getChecks', contribId: contribId});
response.done(function(result) {
// build html table from the data
$('#checksEnteredContainer').html(buildTable(result));
}
function buildTable(data) {
var numberOfRows = data.length;
var rows='';
for(i=0; i<numberOfRows; ++i) {
rows += '<tr>' +
'<td>' + data[i].checkNumber + '</td>' +
'<td>' + data[i].amount + '</td>' +
'<td><a href="#" class="remove_check" data-contribution-id="' + data[i].checkId + '">remove</a></td>'
'</tr>';
}
var table = '<table class="table"><tr><th>Check Number</th><th>Amount</th><th></th></tr>' +
rows +
'</table>';
return table;
}
</code></pre>
<p>The table creation is working fine and displaying in the browser; what's not working is the listener for <code>remove_check</code> class.</p>
<p>My guess is that the newly-created table is not actually in the DOM and the listener is unaware that the table exists? At any rate, how do I get the listener to respond to a click on the generated link?</p>
| 0debug
|
ResampleContext *ff_audio_resample_init(AVAudioResampleContext *avr)
{
ResampleContext *c;
int out_rate = avr->out_sample_rate;
int in_rate = avr->in_sample_rate;
double factor = FFMIN(out_rate * avr->cutoff / in_rate, 1.0);
int phase_count = 1 << avr->phase_shift;
int felem_size;
if (avr->internal_sample_fmt != AV_SAMPLE_FMT_S16P &&
avr->internal_sample_fmt != AV_SAMPLE_FMT_S32P &&
avr->internal_sample_fmt != AV_SAMPLE_FMT_FLTP &&
avr->internal_sample_fmt != AV_SAMPLE_FMT_DBLP) {
av_log(avr, AV_LOG_ERROR, "Unsupported internal format for "
"resampling: %s\n",
av_get_sample_fmt_name(avr->internal_sample_fmt));
return NULL;
}
c = av_mallocz(sizeof(*c));
if (!c)
return NULL;
c->avr = avr;
c->phase_shift = avr->phase_shift;
c->phase_mask = phase_count - 1;
c->linear = avr->linear_interp;
c->factor = factor;
c->filter_length = FFMAX((int)ceil(avr->filter_size / factor), 1);
c->filter_type = avr->filter_type;
c->kaiser_beta = avr->kaiser_beta;
switch (avr->internal_sample_fmt) {
case AV_SAMPLE_FMT_DBLP:
c->resample_one = resample_one_dbl;
c->resample_nearest = resample_nearest_dbl;
c->set_filter = set_filter_dbl;
break;
case AV_SAMPLE_FMT_FLTP:
c->resample_one = resample_one_flt;
c->resample_nearest = resample_nearest_flt;
c->set_filter = set_filter_flt;
break;
case AV_SAMPLE_FMT_S32P:
c->resample_one = resample_one_s32;
c->resample_nearest = resample_nearest_s32;
c->set_filter = set_filter_s32;
break;
case AV_SAMPLE_FMT_S16P:
c->resample_one = resample_one_s16;
c->resample_nearest = resample_nearest_s16;
c->set_filter = set_filter_s16;
break;
}
felem_size = av_get_bytes_per_sample(avr->internal_sample_fmt);
c->filter_bank = av_mallocz(c->filter_length * (phase_count + 1) * felem_size);
if (!c->filter_bank)
goto error;
if (build_filter(c) < 0)
goto error;
memcpy(&c->filter_bank[(c->filter_length * phase_count + 1) * felem_size],
c->filter_bank, (c->filter_length - 1) * felem_size);
memcpy(&c->filter_bank[c->filter_length * phase_count * felem_size],
&c->filter_bank[(c->filter_length - 1) * felem_size], felem_size);
c->compensation_distance = 0;
if (!av_reduce(&c->src_incr, &c->dst_incr, out_rate,
in_rate * (int64_t)phase_count, INT32_MAX / 2))
goto error;
c->ideal_dst_incr = c->dst_incr;
c->padding_size = (c->filter_length - 1) / 2;
c->index = -phase_count * ((c->filter_length - 1) / 2);
c->frac = 0;
c->buffer = ff_audio_data_alloc(avr->resample_channels, 0,
avr->internal_sample_fmt,
"resample buffer");
if (!c->buffer)
goto error;
av_log(avr, AV_LOG_DEBUG, "resample: %s from %d Hz to %d Hz\n",
av_get_sample_fmt_name(avr->internal_sample_fmt),
avr->in_sample_rate, avr->out_sample_rate);
return c;
error:
ff_audio_data_free(&c->buffer);
av_free(c->filter_bank);
av_free(c);
return NULL;
}
| 1threat
|
void acpi_memory_unplug_request_cb(HotplugHandler *hotplug_dev,
MemHotplugState *mem_st,
DeviceState *dev, Error **errp)
{
MemStatus *mdev;
mdev = acpi_memory_slot_status(mem_st, dev, errp);
if (!mdev) {
return;
}
assert(!object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM));
mdev->is_removing = true;
acpi_send_event(DEVICE(hotplug_dev), ACPI_MEMORY_HOTPLUG_STATUS);
}
| 1threat
|
I want to print the string between two strings which has special characters using python regular expressions : <p>Below is the complete text from which i want to retrieve the text between "
General Comment text : " and "Setup done by :"</p>
<p>Text:</p>
<p>DONE
The C-Arm Test cell humidity in % RH is:
Observed value : 25</p>
<p>General Comment text : </p>
<p>{\rtf1\fbidis\ansi\ansicpg936\deff0{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}</p>
<p>{*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\ltrpar\lang1033\f0\fs20 No measurements were taken\par</p>
<p>}</p>
<p>Setup done by : 502184520
Setup done on : 03/24/16 </p>
| 0debug
|
incomplete datetime conversion : <p>I'm trying to write a function to get the month, hour and day of the week from dictionaries depends on cities information (NYC, Chicago, Washington), the problem I'm facing is that only Washington city date shows and when I try to display other cities it keeps displaying Washington city date</p>
<p>Here is the function:</p>
<pre><code>from datetime import datetime
def time_of_trip(datum, city):
for x in datum:
if city == "NYC":
timeformatted = datetime.strptime(str(datum[x]), "(%m, %H, '%A')")
elif city == "Chicago":
timeformatted = datetime.strptime(str(datum[x]), "(%m, %H, '%A')")
elif city == "Washington":
timeformatted = datetime.strptime(str(datum[x]), "(%m, %H, '%A')")
month = datetime.strftime(timeformatted, "%m")
hour = datetime.strftime(timeformatted, "%H")
day_of_week = datetime.strftime(timeformatted, "%A")
return (month, hour, day_of_week)
tests = {'NYC': (1, 0, 'Friday'),
'Chicago': (3, 21, 'Thursday'),
'Washington': (3, 22, 'Thursday')}
time_of_trip(tests, "NYC")
</code></pre>
| 0debug
|
How to not show warnings in Create React App : <p>I'm using create-react-app from Facebook, when it starts via 'npm start' it shows me a list of warnings, such as:</p>
<p>'Bla' is defined but never used<br>
Expected '===' and instead saw '==' </p>
<p>I don't want to see any of these warnings, is there a way to supress them? </p>
| 0debug
|
Insertion sort using recursive function in python : <p>I was trying to implement insertion sort using a recursive function.</p>
<pre><code>def insertion_sort(arr):
found=False
#Base case when list has only one element
if len(arr)==1:
return arr
else:
'''
insert nth element in appropriate postion in a sorted list of n-1 elements
'''
partial_list=insertion_sort(arr[:len(arr)-1]
element=arr[-1]
for i in range(len(partial_list)):
if partial_list[i]>element:
index=i
found=True
break
if found:
return partial_list.insert(index,element)
else:
return partial_list.append(element)
</code></pre>
<p>But its showing an error: for i in range(len(partial_list)):
TypeError: object of type 'NoneType' has no len().
Can anyone please explain why partial_list is a 'None' type object; even though function insertion_sort is returning a list?</p>
| 0debug
|
int qemu_fclose(QEMUFile *f)
{
int ret = 0;
qemu_fflush(f);
if (f->close)
ret = f->close(f->opaque);
g_free(f);
return ret;
}
| 1threat
|
Productivity Power Tools not working in VS 2017 : <p>I just installed Productivity Power Tools for VS 2017 and the installer said everything was successful, I do see the location for it in Tools > Options. However when I click on it it doesn't have the option to enable/disable certain features (Custom Document Well for example).</p>
<p>I've tried uninstalling and re-installing with no success. The old behavior used to show the ability to enable/disable features on when you click on it. Now it just shows the output of the HTML copy tab</p>
| 0debug
|
swift 4 autolayout, did i do something wrong? : Please check what i wrong, i just try to add a subview fullscreen parent view but it not show up full parent view, if i not init or set it frame, it even not show up
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/NfXoA.png
| 0debug
|
target_compile_options() for only C++ files? : <p>Is it possible to use <code>target_compile_options()</code> for only C++ files? I'd like to use it for a target that is uses as a dependency for other applications so that the library can propagate its compiler flags to those apps. However, there are certain flags, such as <code>-std=c++14</code>, that cause the build to fail if they are used with C or ObjC files.</p>
<p>I've read that I should <code>CXX_FLAGS</code> instead to only add those flags to C++ files, however this won't (automatically) propagate through cmake's packages system.</p>
| 0debug
|
unable to fetch data from sql : <p>i am trying to make web app for mobile repair management so far i have made it submit data to MySQL but whenever i try to retrieve data either displays blank page or it gives MySQL_num_rows() expects parameter 1 to be resource error</p>
<p>here is my code</p>
<pre><code><?php
$connect = mysqli_connect('localhost','root','password','shopdata');
if(mysqli_connect_errno($connect)){
echo 'FAILED';
}
?>
<?php
$result = mysqli_query($connect,"SELECT * FROM `jobsheets` ");
?>
<table width="1350" cellpadding=5 cellspacing=5 border=1>
<tr>
<th>JOBSHEET NO.</th>
<th>CUSTOMER NAME</th>
<th>CUSTOMERS PH.</th>
<th>MOBILE BRAND</th>
<th>MODEL NAME</th>
<th>IMEI NO.</th>
<th>FAULT</th>
<th>BATEERY</th>
<th>BACKPANEL</th>
<th>CONDITION</th
</tr>
<?php
If (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_array($result)) {
?>
<tr>
<td><?php echo $row['job_number']; ?></td>
<td><?php echo $row['cust_name']; ?></td>
<td><?php echo $row['cust_mob']; ?></td>
<td><?php echo $row['mob_brand']; ?></td>
<td><?php echo $row['mob_name']; ?></td>
<td><?php echo $row['imei_number']; ?></td>
<td><?php echo $row['fault_name']; ?></td>
<td><?php echo $row['bat_status']; ?></td>
<td><?php echo $row['panel_status']; ?></td>
<td><?php echo $row['misc_note']; ?></td>
</tr>
</table>
<?php
}
}
?>**strong text**
</code></pre>
| 0debug
|
react native console.debug does not show log using log-ios : <p>After upgrading existing project to react native v 0.48.3, console.debug is not listing logs when I run the application on simulator.
It used to work till I upgraded using <code>react-native upgrade</code> option.</p>
<p>Any suggestion to view the logs using <code>react-native log-ios</code>. I am able to view logs on chrome console though, if I run remote debugger.</p>
<pre><code>React native version: 0.48.3
iOS = macOS Sierra 10.12.6.
</code></pre>
<p>react-native log-ios shows</p>
<pre>
Scanning 597 folders for symlinks in /Users/James/workspace/ReactNative/my_app/node_modules (4ms)
NOTE: Most system logs have moved to a new logging system. See log(1) for more information.
Sep 25 21:36:29 DSSB1234 com.apple.CoreSimulator.SimDevice.57E26096-292C-4C40-9A7A-D0E1092F482C[1625] (com.apple.videosubscriptionsd[2757]) : Service exited with abnormal code: 1
Sep 25 21:36:29 DSSB1234 com.apple.CoreSimulator.SimDevice.57E26096-292C-4C40-9A7A-D0E1092F482C[1625] (com.apple.imfoundation.IMRemoteURLConnectionAgent) : Unknown key for Boolean: EnableTransactions
Sep 25 21:36:29 DSSB1234 com.apple.CoreSimulator.SimDevice.57E26096-292C-4C40-9A7A-D0E1092F482C[1625] (com.apple.imfoundation.IMRemoteURLConnectionAgent) : Unknown key for integer: _DirtyJetsamMemoryLimit
Sep 25 21:36:29 DSSB1234 com.apple.CoreSimulator.SimDevice.57E26096-292C-4C40-9A7A-D0E1092F482C[1625] (com.apple.imfoundation.IMRemoteURLConnectionAgent) : Unknown key for Boolean: EnablePressuredExit
Sep 25 21:36:29 DSSB1234 com.apple.CoreSimulator.SimDevice.57E26096-292C-4C40-9A7A-D0E1092F482C[1625] (com.apple.AssetCacheLocatorService) : Unknown key for Boolean: EnableTransactions
Sep 25 21:36:29 DSSB1234 com.apple.CoreSimulator.SimDevice.57E26096-292C-4C40-9A7A-D0E1092F482C[1625] (com.apple.AssetCacheLocatorService) : Unknown key for Boolean: EnablePressuredExit
Sep 25 21:36:29 DSSB1234 com.apple.CoreSimulator.SimDevice.57E26096-292C-4C40-9A7A-D0E1092F482C[1625] (com.apple.StreamingUnzipService) : Unknown key for Boolean: EnableTransactions
Sep 25 21:36:29 DSSB1234 com.apple.CoreSimulator.SimDevice.57E26096-292C-4C40-9A7A-D0E1092F482C[1625] (com.apple.StreamingUnzipService) : Unknown key for Boolean: EnablePressuredExit
Sep 25 21:36:33 DSSB1234 my_app[2763] : assertion failed: 16G29 15A372: libxpc.dylib + 69578 [D870A237-D3A7-31F5-AAD4-CE880C0C8E7B]: 0x7d
Sep 25 21:36:33 DSSB1234 Unknown[2763] :
</pre>
| 0debug
|
static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_codecid) {
FLVContext *flv = s->priv_data;
AVCodecContext *vcodec = vstream->codec;
switch(flv_codecid) {
case FLV_CODECID_H263 : vcodec->codec_id = CODEC_ID_FLV1 ; break;
case FLV_CODECID_SCREEN: vcodec->codec_id = CODEC_ID_FLASHSV; break;
case FLV_CODECID_VP6A :
if (!flv->alpha_stream) {
AVCodecContext *alpha_codec;
flv->alpha_stream = av_new_stream(s, 2);
if (flv->alpha_stream) {
av_set_pts_info(flv->alpha_stream, 24, 1, 1000);
alpha_codec = flv->alpha_stream->codec;
alpha_codec->codec_type = CODEC_TYPE_VIDEO;
alpha_codec->codec_id = CODEC_ID_VP6F;
alpha_codec->extradata_size = 1;
alpha_codec->extradata = av_malloc(1);
}
}
case FLV_CODECID_VP6 : vcodec->codec_id = CODEC_ID_VP6F ;
if(vcodec->extradata_size != 1) {
vcodec->extradata_size = 1;
vcodec->extradata = av_malloc(1);
}
vcodec->extradata[0] = get_byte(&s->pb);
if (flv->alpha_stream)
flv->alpha_stream->codec->extradata[0] = vcodec->extradata[0];
return 1;
default:
av_log(s, AV_LOG_INFO, "Unsupported video codec (%x)\n", flv_codecid);
vcodec->codec_tag = flv_codecid;
}
return 0;
}
| 1threat
|
static int usb_device_post_load(void *opaque, int version_id)
{
USBDevice *dev = opaque;
if (dev->state == USB_STATE_NOTATTACHED) {
dev->attached = 0;
} else {
dev->attached = 1;
return 0;
| 1threat
|
Webpack and Express - Critical Dependencies Warning : <p>I have the following <code>webpack.config.ts</code>:</p>
<pre><code>var webpack = require( 'webpack' );
var path = require( 'path' );
module.exports = {
entry: [
'./api/bin/www.ts'
],
output: {
path: path.resolve( __dirname, './dist/api' ),
filename: 'index.js'
},
module: {
loaders: [
{ test: /\.ts$/, loader: 'awesome-typescript-loader' },
{ test: /\.json$/, loader: 'json-loader' }
]
},
resolve: {
extensions: [ '', '.js', '.ts' ]
},
target: 'node',
node: {
console: true,
fs: 'empty',
net: 'empty',
tls: 'empty'
}
};
</code></pre>
<p>When I run webpack I get a warning about a dependency:</p>
<pre><code>WARNING in ./~/express/lib/view.js
Critical dependencies:
78:29-56 the request of a dependency is an expression
@ ./~/express/lib/view.js 78:29-56
</code></pre>
<p>The express server I start with this is no more than a <code>Hello World</code> example and <strong>functions as should</strong> but I am concerned about this warning.</p>
<p>My googlefu hasn't revealed any passable solutions. I have seen one particular instance of this problem but the solutions were to bypass the warning by not showing it.</p>
| 0debug
|
static void ivshmem_read(void *opaque, const uint8_t *buf, int size)
{
IVShmemState *s = opaque;
int incoming_fd, tmp_fd;
int guest_max_eventfd;
long incoming_posn;
if (fifo8_is_empty(&s->incoming_fifo) && size == sizeof(incoming_posn)) {
memcpy(&incoming_posn, buf, size);
} else {
const uint8_t *p;
uint32_t num;
IVSHMEM_DPRINTF("short read of %d bytes\n", size);
num = MAX(size, sizeof(long) - fifo8_num_used(&s->incoming_fifo));
fifo8_push_all(&s->incoming_fifo, buf, num);
if (fifo8_num_used(&s->incoming_fifo) < sizeof(incoming_posn)) {
return;
}
size -= num;
buf += num;
p = fifo8_pop_buf(&s->incoming_fifo, sizeof(incoming_posn), &num);
g_assert(num == sizeof(incoming_posn));
memcpy(&incoming_posn, p, sizeof(incoming_posn));
if (size > 0) {
fifo8_push_all(&s->incoming_fifo, buf, size);
}
}
if (incoming_posn < -1) {
IVSHMEM_DPRINTF("invalid incoming_posn %ld\n", incoming_posn);
return;
}
tmp_fd = qemu_chr_fe_get_msgfd(s->server_chr);
IVSHMEM_DPRINTF("posn is %ld, fd is %d\n", incoming_posn, tmp_fd);
if (incoming_posn >= s->nb_peers) {
if (increase_dynamic_storage(s, incoming_posn) < 0) {
error_report("increase_dynamic_storage() failed");
if (tmp_fd != -1) {
}
return;
}
}
if (tmp_fd == -1) {
if ((incoming_posn >= 0) &&
(s->peers[incoming_posn].eventfds == NULL)) {
s->vm_id = incoming_posn;
return;
} else {
IVSHMEM_DPRINTF("posn %ld has gone away\n", incoming_posn);
close_guest_eventfds(s, incoming_posn);
return;
}
}
incoming_fd = dup(tmp_fd);
if (incoming_fd == -1) {
fprintf(stderr, "could not allocate file descriptor %s\n",
strerror(errno));
return;
}
if (incoming_posn == -1) {
void * map_ptr;
s->max_peer = 0;
if (check_shm_size(s, incoming_fd) == -1) {
exit(-1);
}
map_ptr = mmap(0, s->ivshmem_size, PROT_READ|PROT_WRITE, MAP_SHARED,
incoming_fd, 0);
memory_region_init_ram_ptr(&s->ivshmem, OBJECT(s),
"ivshmem.bar2", s->ivshmem_size, map_ptr);
vmstate_register_ram(&s->ivshmem, DEVICE(s));
IVSHMEM_DPRINTF("guest h/w addr = %p, size = %" PRIu64 "\n",
map_ptr, s->ivshmem_size);
memory_region_add_subregion(&s->bar, 0, &s->ivshmem);
s->shm_fd = incoming_fd;
return;
}
guest_max_eventfd = s->peers[incoming_posn].nb_eventfds;
if (guest_max_eventfd == 0) {
s->peers[incoming_posn].eventfds = g_new(EventNotifier, s->vectors);
}
IVSHMEM_DPRINTF("eventfds[%ld][%d] = %d\n", incoming_posn,
guest_max_eventfd, incoming_fd);
event_notifier_init_fd(&s->peers[incoming_posn].eventfds[guest_max_eventfd],
incoming_fd);
s->peers[incoming_posn].nb_eventfds++;
if (incoming_posn > s->max_peer) {
s->max_peer = incoming_posn;
}
if (incoming_posn == s->vm_id) {
s->eventfd_chr[guest_max_eventfd] = create_eventfd_chr_device(s,
&s->peers[s->vm_id].eventfds[guest_max_eventfd],
guest_max_eventfd);
}
if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) {
ivshmem_add_eventfd(s, incoming_posn, guest_max_eventfd);
}
}
| 1threat
|
how to access a single object from a json array : Okay so I have this json file
{ "Concepts":[ {"Concept":"1","Description":"siopao"},{"Concept":"4","Description":"gulaman"},{"Concept":"9","Description":"sisig"},{"Concept":"12","Description":"noodle"},{"Concept":"15","Description":"sisigan"},{"Concept":"16","Description":"buko shake"},{"Concept":"17","Description":"mango shake"},{"Concept":"19","Description":"burger"},{"Concept":"20","Description":"sample"},{"Concept":"21","Description":"shit"} ]}
how do I get only "Description":"siopao"? I'm using angularjs.
| 0debug
|
I want to assign a json string to a scope variable without list name in json?How can Indo : {[{“1”:”a”,”2”:”b”},{“3”:”c”}]}
Please provide the syntax how to assign the above to scope variable in angular js?
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.