problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
beautifulsoup scrapping table, name of links missing : : Trying to scrap a table with beautifulSoup that looks like this :
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/EzX6i.png
I used the following code :
import requests
response=requests.get(url,headers=headers)
soup=BeautifulSoup(response.content, 'html.parser')
columns = ['Pname','MP','FG','FGA','FG%','3P','3PA',"3P%",
'FT','FTA','FT%','ORB','DRB','TRB','AST','STL','BLK','TOV','PF','PTS',"+/-"]
stat_table=soup.find_all('table',class_ = "sortable stats_table")
stat_table=stat_table[0]
body=[]
for row in stat_table.find_all("tr"):
for cell in row.find_all('td'):
body.append(cell.text.split(' '))
the output only starts at MP and all the names, I guess since they are links are lost. How can I fix this ?
| 0debug |
static void add_codec(FFStream *stream, AVCodecContext *av)
{
AVStream *st;
if(stream->nb_streams >= FF_ARRAY_ELEMS(stream->streams))
return;
switch(av->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if (av->bit_rate == 0)
av->bit_rate = 64000;
if (av->sample_rate == 0)
av->sample_rate = 22050;
if (av->channels == 0)
av->channels = 1;
break;
case AVMEDIA_TYPE_VIDEO:
if (av->bit_rate == 0)
av->bit_rate = 64000;
if (av->time_base.num == 0){
av->time_base.den = 5;
av->time_base.num = 1;
}
if (av->width == 0 || av->height == 0) {
av->width = 160;
av->height = 128;
}
if (av->bit_rate_tolerance == 0)
av->bit_rate_tolerance = FFMAX(av->bit_rate / 4,
(int64_t)av->bit_rate*av->time_base.num/av->time_base.den);
if (av->qmin == 0)
av->qmin = 3;
if (av->qmax == 0)
av->qmax = 31;
if (av->max_qdiff == 0)
av->max_qdiff = 3;
av->qcompress = 0.5;
av->qblur = 0.5;
if (!av->nsse_weight)
av->nsse_weight = 8;
av->frame_skip_cmp = FF_CMP_DCTMAX;
if (!av->me_method)
av->me_method = ME_EPZS;
av->rc_buffer_aggressivity = 1.0;
if (!av->rc_eq)
av->rc_eq = "tex^qComp";
if (!av->i_quant_factor)
av->i_quant_factor = -0.8;
if (!av->b_quant_factor)
av->b_quant_factor = 1.25;
if (!av->b_quant_offset)
av->b_quant_offset = 1.25;
if (!av->rc_max_rate)
av->rc_max_rate = av->bit_rate * 2;
if (av->rc_max_rate && !av->rc_buffer_size) {
av->rc_buffer_size = av->rc_max_rate;
}
break;
default:
abort();
}
st = av_mallocz(sizeof(AVStream));
if (!st)
return;
st->codec = avcodec_alloc_context3(NULL);
stream->streams[stream->nb_streams++] = st;
memcpy(st->codec, av, sizeof(AVCodecContext));
}
| 1threat |
Excel Column seperation : I have copy and pasted data in an Excel sheet that includes each columns value in the first cell only, How can i separate these into their own cells for later calculations without manually doing 1 at a time? Since there is 1,200+ cell values. I have an included a screenshot of my current issue, refer to attached image.[Excel screenshot][1]
[1]: https://i.stack.imgur.com/s5rvm.png | 0debug |
Python : How to replace the array of values in one dictionary with elements from another array of dictionaries : This is my dictionaries:
```
main_dict =
[
{'link_value':[123,111] , 'id' : 22}
{'link_value':[234] , 'id' : 14}
]
dict2 =
[
{'id':123 , value:['xx','yy'],name:'mg1'}
{'id':111 , value:['zz','yy'],name:'mg2'}
{'id':234 , value:['aa','yy'],name:'mg3'}
]
```
I want to replace the link_value with elements from the dict2 array
```
expected_result:
[
{'link_value':[{'id':123 , value:['xx','yy'],name:'mg1'} ,{'id':111 , value:['zz','yy'],name:'mg2'}] , 'id' : 22}
{'link_value':[{'id':234 , value:['aa','yy'],name:'mg3'}] , 'id' : 14}
]
``` | 0debug |
Catching & Handling Jackson Exceptions with a custom message : <p>I'm hoping to to catch some jackson exceptions that are occurring in a spring-boot API I am developing. For example, I have the following request class and I want to catch the error that occurs when the "questionnaireResponse" key in the JSON request object is null or blank i.e <code>" "</code> in the request object.</p>
<pre><code>@Validated
@JsonRootName("questionnaireResponse")
public class QuestionnaireResponse {
@JsonProperty("identifier")
@Valid
private Identifier identifier = null;
@JsonProperty("basedOn")
@Valid
private List<Identifier_WRAPPED> basedOn = null;
@JsonProperty("parent")
@Valid
private List<Identifier_WRAPPED> parent = null;
@JsonProperty("questionnaire")
@NotNull(message = "40000")
@Valid
private Identifier_WRAPPED questionnaire = null;
@JsonProperty("status")
@NotNull(message = "40000")
@NotEmptyString(message = "40005")
private String status = null;
@JsonProperty("subject")
@Valid
private Identifier_WRAPPED subject = null;
@JsonProperty("context")
@Valid
private Identifier_WRAPPED context = null;
@JsonProperty("authored")
@NotNull(message = "40000")
@NotEmptyString(message = "40005")
@Pattern(regexp = "\\d{4}-(?:0[1-9]|[1-2]\\d|3[0-1])-(?:0[1-9]|1[0-2])T(?:[0-1]\\d|2[0-3]):[0-5]\\d:[0-5]\\dZ", message = "40001")
private String authored;
@JsonProperty("author")
@NotNull(message = "40000")
@Valid
private QuestionnaireResponseAuthor author = null;
@JsonProperty("source")
@NotNull(message = "40000")
@Valid
private Identifier_WRAPPED source = null; // Reference(Patient | Practitioner | RelatedPerson) resources not implemented
@JsonProperty("item")
@NotNull(message = "40000")
@Valid
private List<QuestionnaireResponseItem> item = null;
public Identifier getIdentifier() {
return identifier;
}
public void setIdentifier(Identifier identifier) {
this.identifier = identifier;
}
public List<Identifier_WRAPPED> getBasedOn() {
return basedOn;
}
public void setBasedOn(List<Identifier_WRAPPED> basedOn) {
this.basedOn = basedOn;
}
public List<Identifier_WRAPPED> getParent() {
return parent;
}
public void setParent(List<Identifier_WRAPPED> parent) {
this.parent = parent;
}
public Identifier_WRAPPED getQuestionnaire() {
return questionnaire;
}
public void setQuestionnaire(Identifier_WRAPPED questionnaire) {
this.questionnaire = questionnaire;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Identifier_WRAPPED getSubject() {
return subject;
}
public void setSubject(Identifier_WRAPPED subject) {
this.subject = subject;
}
public Identifier_WRAPPED getContext() {
return context;
}
public void setContext(Identifier_WRAPPED context) {
this.context = context;
}
public String getAuthored() {
return authored;
}
public void setAuthored(String authored) {
this.authored = authored;
}
public QuestionnaireResponseAuthor getAuthor() {
return author;
}
public void setAuthor(QuestionnaireResponseAuthor author) {
this.author = author;
}
public Identifier_WRAPPED getSource() {
return source;
}
public void setSource(Identifier_WRAPPED source) {
this.source = source;
}
public List<QuestionnaireResponseItem> getItem() {
return item;
}
public void setItem(List<QuestionnaireResponseItem> item) {
this.item = item;
}
}
</code></pre>
<p>Resulting in this Jackson error:</p>
<pre><code>{
"Map": {
"timestamp": "2018-07-25T12:45:32.285Z",
"status": 400,
"error": "Bad Request",
"message": "JSON parse error: Root name '' does not match expected ('questionnaireResponse') for type [simple type, class com.optum.genomix.model.gel.QuestionnaireResponse]; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Root name '' does not match expected ('questionnaireResponse') for type [simple type, class com.optum.genomix.model.gel.QuestionnaireResponse]\n at [Source: (PushbackInputStream); line: 2, column: 3]",
"path": "/api/optumhealth/genomics/v1.0/questionnaireResponse/create"
}
}
</code></pre>
<p>Is there a way to catch and handle these exceptions (in the example JsonRootName is null/invalid), maybe similarly to @ControllerAdvice classes extending ResponseEntityExceptionHandler?</p>
| 0debug |
I am tring to output the string like as shown below : <?php $str = "PHP CODING TECH"; ?>
this is a string and want to echo out the output as below: PCT PHCT PHPCT PHPCOT PHPCODT PHPCODIT an so on...
| 0debug |
Why This Query Not Work Properly : why this query not show more than one data.even I have 10/12 data but this line only show 1.check I have limit it 3 but it show only 1
$getAds=mysql_query("SELECT * FROM advertises WHERE status='RUNNING' AND adult='0' AND (country LIKE '%$test%' OR country='ALL') AND (device LIKE '%$pabu%' OR device='ALL') ORDER BY rand() LIMIT 0,3"); | 0debug |
How to pass a function as an argument to a ReactJS component in TypeScript : <p>I am trying to make a reusable ReactJS button component and need help on how to
pass a function to a component and then use it as a click event. The click event on the button is not working.</p>
<p>Here is the code that will call the component:</p>
<pre><code>export var MyPublicFunction = function (inArg: number) {
alert(inArg);
}
ReactDOM.render(<MyButton name="My Button" clickFunction={MyPublicFunction(1)} >Button</MyButton>, document.getElementById('content'));
</code></pre>
<p>Here it the component I'm trying to write:</p>
<pre><code>interface myProps {
name: string;
clickFunction: any
}
class MyButton extends React.Component<myProps, {}> {
constructor(props: myProps) {
super(props);
}
render() {
return (<div>
<button ref="btn1" onClick={this.props.clickFunction} >
{this.props.name}
</button>
</div>);
} //end render.
} //end class.
</code></pre>
| 0debug |
Would this be a valid C I/O library? : <p>I have a question. I want to create a simple C I/O library, and I wish to check whether the method I am using is the correct one. The code is effectively pseudocode, so ignore the syntax.</p>
<pre><code>Simple I/O Library:
Output is 0x0000
Input is 0xFFFF
void writeChar (char* po) {
char* ph = 0x0000
char po;
*ph = po
}
char readChar () {
char* pi = 0xFFFF
char in
in = *pi
return in
}
</code></pre>
<p>**Update:**Sorry if I wasn't clear. This is for an memory-mapped I/O system. The values are simply examples. I just wanted to test if the idea is valid.</p>
<p><strong>One More Question:</strong> I would like to understand the difference between memory access and port access. What, if any, changes would be required to access a port instead of a memory location, assuming a port-mapped I/O system this time.</p>
| 0debug |
static int exynos4210_fimd_init(SysBusDevice *dev)
{
Exynos4210fimdState *s = FROM_SYSBUS(Exynos4210fimdState, dev);
s->ifb = NULL;
sysbus_init_irq(dev, &s->irq[0]);
sysbus_init_irq(dev, &s->irq[1]);
sysbus_init_irq(dev, &s->irq[2]);
memory_region_init_io(&s->iomem, &exynos4210_fimd_mmio_ops, s,
"exynos4210.fimd", FIMD_REGS_SIZE);
sysbus_init_mmio(dev, &s->iomem);
s->console = graphic_console_init(exynos4210_fimd_update,
exynos4210_fimd_invalidate, NULL, NULL, s);
return 0;
}
| 1threat |
static void disas_arm_insn(CPUARMState * env, DisasContext *s)
{
unsigned int cond, insn, val, op1, i, shift, rm, rs, rn, rd, sh;
TCGv tmp;
TCGv tmp2;
TCGv tmp3;
TCGv addr;
TCGv_i64 tmp64;
insn = arm_ldl_code(env, s->pc, s->bswap_code);
s->pc += 4;
if (IS_M(env))
goto illegal_op;
cond = insn >> 28;
if (cond == 0xf){
ARCH(5);
if (((insn >> 25) & 7) == 1) {
if (!arm_feature(env, ARM_FEATURE_NEON))
goto illegal_op;
if (disas_neon_data_insn(env, s, insn))
goto illegal_op;
}
if ((insn & 0x0f100000) == 0x04000000) {
if (!arm_feature(env, ARM_FEATURE_NEON))
goto illegal_op;
if (disas_neon_ls_insn(env, s, insn))
goto illegal_op;
}
if (((insn & 0x0f30f000) == 0x0510f000) ||
((insn & 0x0f30f010) == 0x0710f000)) {
if ((insn & (1 << 22)) == 0) {
if (!arm_feature(env, ARM_FEATURE_V7MP)) {
goto illegal_op;
}
}
ARCH(5TE);
}
if (((insn & 0x0f70f000) == 0x0450f000) ||
((insn & 0x0f70f010) == 0x0650f000)) {
ARCH(7);
return;
}
if (((insn & 0x0f700000) == 0x04100000) ||
((insn & 0x0f700010) == 0x06100000)) {
if (!arm_feature(env, ARM_FEATURE_V7MP)) {
goto illegal_op;
}
return;
}
if ((insn & 0x0ffffdff) == 0x01010000) {
ARCH(6);
if (((insn >> 9) & 1) != s->bswap_code) {
goto illegal_op;
}
} else if ((insn & 0x0fffff00) == 0x057ff000) {
switch ((insn >> 4) & 0xf) {
case 1:
ARCH(6K);
gen_clrex(s);
case 4:
case 5:
case 6:
ARCH(7);
default:
goto illegal_op;
}
} else if ((insn & 0x0e5fffe0) == 0x084d0500) {
if (IS_USER(s)) {
goto illegal_op;
}
ARCH(6);
gen_srs(s, (insn & 0x1f), (insn >> 23) & 3, insn & (1 << 21));
} else if ((insn & 0x0e50ffe0) == 0x08100a00) {
int32_t offset;
if (IS_USER(s))
goto illegal_op;
ARCH(6);
rn = (insn >> 16) & 0xf;
addr = load_reg(s, rn);
i = (insn >> 23) & 3;
switch (i) {
case 0: offset = -4; break;
case 1: offset = 0; break;
case 2: offset = -8; break;
case 3: offset = 4; break;
default: abort();
}
if (offset)
tcg_gen_addi_i32(addr, addr, offset);
tmp = gen_ld32(addr, 0);
tcg_gen_addi_i32(addr, addr, 4);
tmp2 = gen_ld32(addr, 0);
if (insn & (1 << 21)) {
switch (i) {
case 0: offset = -8; break;
case 1: offset = 4; break;
case 2: offset = -4; break;
case 3: offset = 0; break;
default: abort();
}
if (offset)
tcg_gen_addi_i32(addr, addr, offset);
store_reg(s, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
gen_rfe(s, tmp, tmp2);
} else if ((insn & 0x0e000000) == 0x0a000000) {
int32_t offset;
val = (uint32_t)s->pc;
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, val);
store_reg(s, 14, tmp);
offset = (((int32_t)insn) << 8) >> 8;
val += (offset << 2) | ((insn >> 23) & 2) | 1;
val += 4;
gen_bx_im(s, val);
} else if ((insn & 0x0e000f00) == 0x0c000100) {
if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
if (env->cp15.c15_cpar & (1 << 1))
if (!disas_iwmmxt_insn(env, s, insn))
}
} else if ((insn & 0x0fe00000) == 0x0c400000) {
ARCH(5TE);
} else if ((insn & 0x0f000010) == 0x0e000010) {
} else if ((insn & 0x0ff10020) == 0x01000000) {
uint32_t mask;
uint32_t val;
if (IS_USER(s))
mask = val = 0;
if (insn & (1 << 19)) {
if (insn & (1 << 8))
mask |= CPSR_A;
if (insn & (1 << 7))
mask |= CPSR_I;
if (insn & (1 << 6))
mask |= CPSR_F;
if (insn & (1 << 18))
val |= mask;
}
if (insn & (1 << 17)) {
mask |= CPSR_M;
val |= (insn & 0x1f);
}
if (mask) {
gen_set_psr_im(s, mask, 0, val);
}
}
goto illegal_op;
}
if (cond != 0xe) {
s->condlabel = gen_new_label();
gen_test_cc(cond ^ 1, s->condlabel);
s->condjmp = 1;
}
if ((insn & 0x0f900000) == 0x03000000) {
if ((insn & (1 << 21)) == 0) {
ARCH(6T2);
rd = (insn >> 12) & 0xf;
val = ((insn >> 4) & 0xf000) | (insn & 0xfff);
if ((insn & (1 << 22)) == 0) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, val);
} else {
tmp = load_reg(s, rd);
tcg_gen_ext16u_i32(tmp, tmp);
tcg_gen_ori_i32(tmp, tmp, val << 16);
}
store_reg(s, rd, tmp);
} else {
if (((insn >> 12) & 0xf) != 0xf)
goto illegal_op;
if (((insn >> 16) & 0xf) == 0) {
gen_nop_hint(s, insn & 0xff);
} else {
val = insn & 0xff;
shift = ((insn >> 8) & 0xf) * 2;
if (shift)
val = (val >> shift) | (val << (32 - shift));
i = ((insn & (1 << 22)) != 0);
if (gen_set_psr_im(s, msr_mask(env, s, (insn >> 16) & 0xf, i), i, val))
goto illegal_op;
}
}
} else if ((insn & 0x0f900000) == 0x01000000
&& (insn & 0x00000090) != 0x00000090) {
op1 = (insn >> 21) & 3;
sh = (insn >> 4) & 0xf;
rm = insn & 0xf;
switch (sh) {
case 0x0:
if (op1 & 1) {
tmp = load_reg(s, rm);
i = ((op1 & 2) != 0);
if (gen_set_psr(s, msr_mask(env, s, (insn >> 16) & 0xf, i), i, tmp))
goto illegal_op;
} else {
rd = (insn >> 12) & 0xf;
if (op1 & 2) {
if (IS_USER(s))
goto illegal_op;
tmp = load_cpu_field(spsr);
} else {
tmp = tcg_temp_new_i32();
gen_helper_cpsr_read(tmp, cpu_env);
}
store_reg(s, rd, tmp);
}
break;
case 0x1:
if (op1 == 1) {
ARCH(4T);
tmp = load_reg(s, rm);
gen_bx(s, tmp);
} else if (op1 == 3) {
ARCH(5);
rd = (insn >> 12) & 0xf;
tmp = load_reg(s, rm);
gen_helper_clz(tmp, tmp);
store_reg(s, rd, tmp);
} else {
goto illegal_op;
}
break;
case 0x2:
if (op1 == 1) {
ARCH(5J);
tmp = load_reg(s, rm);
gen_bx(s, tmp);
} else {
goto illegal_op;
}
break;
case 0x3:
if (op1 != 1)
goto illegal_op;
ARCH(5);
tmp = load_reg(s, rm);
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, s->pc);
store_reg(s, 14, tmp2);
gen_bx(s, tmp);
break;
case 0x5:
ARCH(5TE);
rd = (insn >> 12) & 0xf;
rn = (insn >> 16) & 0xf;
tmp = load_reg(s, rm);
tmp2 = load_reg(s, rn);
if (op1 & 2)
gen_helper_double_saturate(tmp2, cpu_env, tmp2);
if (op1 & 1)
gen_helper_sub_saturate(tmp, cpu_env, tmp, tmp2);
else
gen_helper_add_saturate(tmp, cpu_env, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
case 7:
if (op1 != 1) {
goto illegal_op;
}
ARCH(5);
gen_exception_insn(s, 4, EXCP_BKPT);
break;
case 0x8:
case 0xa:
case 0xc:
case 0xe:
ARCH(5TE);
rs = (insn >> 8) & 0xf;
rn = (insn >> 12) & 0xf;
rd = (insn >> 16) & 0xf;
if (op1 == 1) {
tmp = load_reg(s, rm);
tmp2 = load_reg(s, rs);
if (sh & 4)
tcg_gen_sari_i32(tmp2, tmp2, 16);
else
gen_sxth(tmp2);
tmp64 = gen_muls_i64_i32(tmp, tmp2);
tcg_gen_shri_i64(tmp64, tmp64, 16);
tmp = tcg_temp_new_i32();
tcg_gen_trunc_i64_i32(tmp, tmp64);
tcg_temp_free_i64(tmp64);
if ((sh & 2) == 0) {
tmp2 = load_reg(s, rn);
gen_helper_add_setq(tmp, cpu_env, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rm);
tmp2 = load_reg(s, rs);
gen_mulxy(tmp, tmp2, sh & 2, sh & 4);
tcg_temp_free_i32(tmp2);
if (op1 == 2) {
tmp64 = tcg_temp_new_i64();
tcg_gen_ext_i32_i64(tmp64, tmp);
tcg_temp_free_i32(tmp);
gen_addq(s, tmp64, rn, rd);
gen_storeq_reg(s, rn, rd, tmp64);
tcg_temp_free_i64(tmp64);
} else {
if (op1 == 0) {
tmp2 = load_reg(s, rn);
gen_helper_add_setq(tmp, cpu_env, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
store_reg(s, rd, tmp);
}
}
break;
default:
goto illegal_op;
}
} else if (((insn & 0x0e000000) == 0 &&
(insn & 0x00000090) != 0x90) ||
((insn & 0x0e000000) == (1 << 25))) {
int set_cc, logic_cc, shiftop;
op1 = (insn >> 21) & 0xf;
set_cc = (insn >> 20) & 1;
logic_cc = table_logic_cc[op1] & set_cc;
if (insn & (1 << 25)) {
val = insn & 0xff;
shift = ((insn >> 8) & 0xf) * 2;
if (shift) {
val = (val >> shift) | (val << (32 - shift));
}
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, val);
if (logic_cc && shift) {
gen_set_CF_bit31(tmp2);
}
} else {
rm = (insn) & 0xf;
tmp2 = load_reg(s, rm);
shiftop = (insn >> 5) & 3;
if (!(insn & (1 << 4))) {
shift = (insn >> 7) & 0x1f;
gen_arm_shift_im(tmp2, shiftop, shift, logic_cc);
} else {
rs = (insn >> 8) & 0xf;
tmp = load_reg(s, rs);
gen_arm_shift_reg(tmp2, shiftop, tmp, logic_cc);
}
}
if (op1 != 0x0f && op1 != 0x0d) {
rn = (insn >> 16) & 0xf;
tmp = load_reg(s, rn);
} else {
TCGV_UNUSED(tmp);
}
rd = (insn >> 12) & 0xf;
switch(op1) {
case 0x00:
tcg_gen_and_i32(tmp, tmp, tmp2);
if (logic_cc) {
gen_logic_CC(tmp);
}
store_reg_bx(env, s, rd, tmp);
break;
case 0x01:
tcg_gen_xor_i32(tmp, tmp, tmp2);
if (logic_cc) {
gen_logic_CC(tmp);
}
store_reg_bx(env, s, rd, tmp);
break;
case 0x02:
if (set_cc && rd == 15) {
if (IS_USER(s)) {
goto illegal_op;
}
gen_sub_CC(tmp, tmp, tmp2);
gen_exception_return(s, tmp);
} else {
if (set_cc) {
gen_sub_CC(tmp, tmp, tmp2);
} else {
tcg_gen_sub_i32(tmp, tmp, tmp2);
}
store_reg_bx(env, s, rd, tmp);
}
break;
case 0x03:
if (set_cc) {
gen_sub_CC(tmp, tmp2, tmp);
} else {
tcg_gen_sub_i32(tmp, tmp2, tmp);
}
store_reg_bx(env, s, rd, tmp);
break;
case 0x04:
if (set_cc) {
gen_add_CC(tmp, tmp, tmp2);
} else {
tcg_gen_add_i32(tmp, tmp, tmp2);
}
store_reg_bx(env, s, rd, tmp);
break;
case 0x05:
if (set_cc) {
gen_adc_CC(tmp, tmp, tmp2);
} else {
gen_add_carry(tmp, tmp, tmp2);
}
store_reg_bx(env, s, rd, tmp);
break;
case 0x06:
if (set_cc) {
gen_sbc_CC(tmp, tmp, tmp2);
} else {
gen_sub_carry(tmp, tmp, tmp2);
}
store_reg_bx(env, s, rd, tmp);
break;
case 0x07:
if (set_cc) {
gen_sbc_CC(tmp, tmp2, tmp);
} else {
gen_sub_carry(tmp, tmp2, tmp);
}
store_reg_bx(env, s, rd, tmp);
break;
case 0x08:
if (set_cc) {
tcg_gen_and_i32(tmp, tmp, tmp2);
gen_logic_CC(tmp);
}
tcg_temp_free_i32(tmp);
break;
case 0x09:
if (set_cc) {
tcg_gen_xor_i32(tmp, tmp, tmp2);
gen_logic_CC(tmp);
}
tcg_temp_free_i32(tmp);
break;
case 0x0a:
if (set_cc) {
gen_sub_CC(tmp, tmp, tmp2);
}
tcg_temp_free_i32(tmp);
break;
case 0x0b:
if (set_cc) {
gen_add_CC(tmp, tmp, tmp2);
}
tcg_temp_free_i32(tmp);
break;
case 0x0c:
tcg_gen_or_i32(tmp, tmp, tmp2);
if (logic_cc) {
gen_logic_CC(tmp);
}
store_reg_bx(env, s, rd, tmp);
break;
case 0x0d:
if (logic_cc && rd == 15) {
if (IS_USER(s)) {
goto illegal_op;
}
gen_exception_return(s, tmp2);
} else {
if (logic_cc) {
gen_logic_CC(tmp2);
}
store_reg_bx(env, s, rd, tmp2);
}
break;
case 0x0e:
tcg_gen_andc_i32(tmp, tmp, tmp2);
if (logic_cc) {
gen_logic_CC(tmp);
}
store_reg_bx(env, s, rd, tmp);
break;
default:
case 0x0f:
tcg_gen_not_i32(tmp2, tmp2);
if (logic_cc) {
gen_logic_CC(tmp2);
}
store_reg_bx(env, s, rd, tmp2);
break;
}
if (op1 != 0x0f && op1 != 0x0d) {
tcg_temp_free_i32(tmp2);
}
} else {
op1 = (insn >> 24) & 0xf;
switch(op1) {
case 0x0:
case 0x1:
sh = (insn >> 5) & 3;
if (sh == 0) {
if (op1 == 0x0) {
rd = (insn >> 16) & 0xf;
rn = (insn >> 12) & 0xf;
rs = (insn >> 8) & 0xf;
rm = (insn) & 0xf;
op1 = (insn >> 20) & 0xf;
switch (op1) {
case 0: case 1: case 2: case 3: case 6:
tmp = load_reg(s, rs);
tmp2 = load_reg(s, rm);
tcg_gen_mul_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
if (insn & (1 << 22)) {
ARCH(6T2);
tmp2 = load_reg(s, rn);
tcg_gen_sub_i32(tmp, tmp2, tmp);
tcg_temp_free_i32(tmp2);
} else if (insn & (1 << 21)) {
tmp2 = load_reg(s, rn);
tcg_gen_add_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
if (insn & (1 << 20))
gen_logic_CC(tmp);
store_reg(s, rd, tmp);
break;
case 4:
ARCH(6);
tmp = load_reg(s, rs);
tmp2 = load_reg(s, rm);
tmp64 = gen_mulu_i64_i32(tmp, tmp2);
gen_addq_lo(s, tmp64, rn);
gen_addq_lo(s, tmp64, rd);
gen_storeq_reg(s, rn, rd, tmp64);
tcg_temp_free_i64(tmp64);
break;
case 8: case 9: case 10: case 11:
case 12: case 13: case 14: case 15:
tmp = load_reg(s, rs);
tmp2 = load_reg(s, rm);
if (insn & (1 << 22)) {
tcg_gen_muls2_i32(tmp, tmp2, tmp, tmp2);
} else {
tcg_gen_mulu2_i32(tmp, tmp2, tmp, tmp2);
}
if (insn & (1 << 21)) {
TCGv al = load_reg(s, rn);
TCGv ah = load_reg(s, rd);
tcg_gen_add2_i32(tmp, tmp2, tmp, tmp2, al, ah);
tcg_temp_free(al);
tcg_temp_free(ah);
}
if (insn & (1 << 20)) {
gen_logicq_cc(tmp, tmp2);
}
store_reg(s, rn, tmp);
store_reg(s, rd, tmp2);
break;
default:
goto illegal_op;
}
} else {
rn = (insn >> 16) & 0xf;
rd = (insn >> 12) & 0xf;
if (insn & (1 << 23)) {
op1 = (insn >> 21) & 0x3;
if (op1)
ARCH(6K);
else
ARCH(6);
addr = tcg_temp_local_new_i32();
load_reg_var(s, addr, rn);
if (insn & (1 << 20)) {
switch (op1) {
case 0:
gen_load_exclusive(s, rd, 15, addr, 2);
break;
case 1:
gen_load_exclusive(s, rd, rd + 1, addr, 3);
break;
case 2:
gen_load_exclusive(s, rd, 15, addr, 0);
break;
case 3:
gen_load_exclusive(s, rd, 15, addr, 1);
break;
default:
abort();
}
} else {
rm = insn & 0xf;
switch (op1) {
case 0:
gen_store_exclusive(s, rd, rm, 15, addr, 2);
break;
case 1:
gen_store_exclusive(s, rd, rm, rm + 1, addr, 3);
break;
case 2:
gen_store_exclusive(s, rd, rm, 15, addr, 0);
break;
case 3:
gen_store_exclusive(s, rd, rm, 15, addr, 1);
break;
default:
abort();
}
}
tcg_temp_free(addr);
} else {
rm = (insn) & 0xf;
addr = load_reg(s, rn);
tmp = load_reg(s, rm);
if (insn & (1 << 22)) {
tmp2 = gen_ld8u(addr, IS_USER(s));
gen_st8(tmp, addr, IS_USER(s));
} else {
tmp2 = gen_ld32(addr, IS_USER(s));
gen_st32(tmp, addr, IS_USER(s));
}
tcg_temp_free_i32(addr);
store_reg(s, rd, tmp2);
}
}
} else {
int address_offset;
int load;
rn = (insn >> 16) & 0xf;
rd = (insn >> 12) & 0xf;
addr = load_reg(s, rn);
if (insn & (1 << 24))
gen_add_datah_offset(s, insn, 0, addr);
address_offset = 0;
if (insn & (1 << 20)) {
switch(sh) {
case 1:
tmp = gen_ld16u(addr, IS_USER(s));
break;
case 2:
tmp = gen_ld8s(addr, IS_USER(s));
break;
default:
case 3:
tmp = gen_ld16s(addr, IS_USER(s));
break;
}
load = 1;
} else if (sh & 2) {
ARCH(5TE);
if (sh & 1) {
tmp = load_reg(s, rd);
gen_st32(tmp, addr, IS_USER(s));
tcg_gen_addi_i32(addr, addr, 4);
tmp = load_reg(s, rd + 1);
gen_st32(tmp, addr, IS_USER(s));
load = 0;
} else {
tmp = gen_ld32(addr, IS_USER(s));
store_reg(s, rd, tmp);
tcg_gen_addi_i32(addr, addr, 4);
tmp = gen_ld32(addr, IS_USER(s));
rd++;
load = 1;
}
address_offset = -4;
} else {
tmp = load_reg(s, rd);
gen_st16(tmp, addr, IS_USER(s));
load = 0;
}
if (!(insn & (1 << 24))) {
gen_add_datah_offset(s, insn, address_offset, addr);
store_reg(s, rn, addr);
} else if (insn & (1 << 21)) {
if (address_offset)
tcg_gen_addi_i32(addr, addr, address_offset);
store_reg(s, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
if (load) {
store_reg(s, rd, tmp);
}
}
break;
case 0x4:
case 0x5:
goto do_ldst;
case 0x6:
case 0x7:
if (insn & (1 << 4)) {
ARCH(6);
rm = insn & 0xf;
rn = (insn >> 16) & 0xf;
rd = (insn >> 12) & 0xf;
rs = (insn >> 8) & 0xf;
switch ((insn >> 23) & 3) {
case 0:
op1 = (insn >> 20) & 7;
tmp = load_reg(s, rn);
tmp2 = load_reg(s, rm);
sh = (insn >> 5) & 7;
if ((op1 & 3) == 0 || sh == 5 || sh == 6)
goto illegal_op;
gen_arm_parallel_addsub(op1, sh, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
case 1:
if ((insn & 0x00700020) == 0) {
tmp = load_reg(s, rn);
tmp2 = load_reg(s, rm);
shift = (insn >> 7) & 0x1f;
if (insn & (1 << 6)) {
if (shift == 0)
shift = 31;
tcg_gen_sari_i32(tmp2, tmp2, shift);
tcg_gen_andi_i32(tmp, tmp, 0xffff0000);
tcg_gen_ext16u_i32(tmp2, tmp2);
} else {
if (shift)
tcg_gen_shli_i32(tmp2, tmp2, shift);
tcg_gen_ext16u_i32(tmp, tmp);
tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000);
}
tcg_gen_or_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
} else if ((insn & 0x00200020) == 0x00200000) {
tmp = load_reg(s, rm);
shift = (insn >> 7) & 0x1f;
if (insn & (1 << 6)) {
if (shift == 0)
shift = 31;
tcg_gen_sari_i32(tmp, tmp, shift);
} else {
tcg_gen_shli_i32(tmp, tmp, shift);
}
sh = (insn >> 16) & 0x1f;
tmp2 = tcg_const_i32(sh);
if (insn & (1 << 22))
gen_helper_usat(tmp, cpu_env, tmp, tmp2);
else
gen_helper_ssat(tmp, cpu_env, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
} else if ((insn & 0x00300fe0) == 0x00200f20) {
tmp = load_reg(s, rm);
sh = (insn >> 16) & 0x1f;
tmp2 = tcg_const_i32(sh);
if (insn & (1 << 22))
gen_helper_usat16(tmp, cpu_env, tmp, tmp2);
else
gen_helper_ssat16(tmp, cpu_env, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
} else if ((insn & 0x00700fe0) == 0x00000fa0) {
tmp = load_reg(s, rn);
tmp2 = load_reg(s, rm);
tmp3 = tcg_temp_new_i32();
tcg_gen_ld_i32(tmp3, cpu_env, offsetof(CPUARMState, GE));
gen_helper_sel_flags(tmp, tmp3, tmp, tmp2);
tcg_temp_free_i32(tmp3);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
} else if ((insn & 0x000003e0) == 0x00000060) {
tmp = load_reg(s, rm);
shift = (insn >> 10) & 3;
if (shift != 0)
tcg_gen_rotri_i32(tmp, tmp, shift * 8);
op1 = (insn >> 20) & 7;
switch (op1) {
case 0: gen_sxtb16(tmp); break;
case 2: gen_sxtb(tmp); break;
case 3: gen_sxth(tmp); break;
case 4: gen_uxtb16(tmp); break;
case 6: gen_uxtb(tmp); break;
case 7: gen_uxth(tmp); break;
default: goto illegal_op;
}
if (rn != 15) {
tmp2 = load_reg(s, rn);
if ((op1 & 3) == 0) {
gen_add16(tmp, tmp2);
} else {
tcg_gen_add_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
}
store_reg(s, rd, tmp);
} else if ((insn & 0x003f0f60) == 0x003f0f20) {
tmp = load_reg(s, rm);
if (insn & (1 << 22)) {
if (insn & (1 << 7)) {
gen_revsh(tmp);
} else {
ARCH(6T2);
gen_helper_rbit(tmp, tmp);
}
} else {
if (insn & (1 << 7))
gen_rev16(tmp);
else
tcg_gen_bswap32_i32(tmp, tmp);
}
store_reg(s, rd, tmp);
} else {
goto illegal_op;
}
break;
case 2:
switch ((insn >> 20) & 0x7) {
case 5:
if (((insn >> 6) ^ (insn >> 7)) & 1) {
goto illegal_op;
}
tmp = load_reg(s, rm);
tmp2 = load_reg(s, rs);
tmp64 = gen_muls_i64_i32(tmp, tmp2);
if (rd != 15) {
tmp = load_reg(s, rd);
if (insn & (1 << 6)) {
tmp64 = gen_subq_msw(tmp64, tmp);
} else {
tmp64 = gen_addq_msw(tmp64, tmp);
}
}
if (insn & (1 << 5)) {
tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u);
}
tcg_gen_shri_i64(tmp64, tmp64, 32);
tmp = tcg_temp_new_i32();
tcg_gen_trunc_i64_i32(tmp, tmp64);
tcg_temp_free_i64(tmp64);
store_reg(s, rn, tmp);
break;
case 0:
case 4:
if (insn & (1 << 7)) {
goto illegal_op;
}
tmp = load_reg(s, rm);
tmp2 = load_reg(s, rs);
if (insn & (1 << 5))
gen_swap_half(tmp2);
gen_smul_dual(tmp, tmp2);
if (insn & (1 << 6)) {
tcg_gen_sub_i32(tmp, tmp, tmp2);
} else {
gen_helper_add_setq(tmp, cpu_env, tmp, tmp2);
}
tcg_temp_free_i32(tmp2);
if (insn & (1 << 22)) {
tmp64 = tcg_temp_new_i64();
tcg_gen_ext_i32_i64(tmp64, tmp);
tcg_temp_free_i32(tmp);
gen_addq(s, tmp64, rd, rn);
gen_storeq_reg(s, rd, rn, tmp64);
tcg_temp_free_i64(tmp64);
} else {
if (rd != 15)
{
tmp2 = load_reg(s, rd);
gen_helper_add_setq(tmp, cpu_env, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
store_reg(s, rn, tmp);
}
break;
case 1:
case 3:
if (!arm_feature(env, ARM_FEATURE_ARM_DIV)) {
goto illegal_op;
}
if (((insn >> 5) & 7) || (rd != 15)) {
goto illegal_op;
}
tmp = load_reg(s, rm);
tmp2 = load_reg(s, rs);
if (insn & (1 << 21)) {
gen_helper_udiv(tmp, tmp, tmp2);
} else {
gen_helper_sdiv(tmp, tmp, tmp2);
}
tcg_temp_free_i32(tmp2);
store_reg(s, rn, tmp);
break;
default:
goto illegal_op;
}
break;
case 3:
op1 = ((insn >> 17) & 0x38) | ((insn >> 5) & 7);
switch (op1) {
case 0:
ARCH(6);
tmp = load_reg(s, rm);
tmp2 = load_reg(s, rs);
gen_helper_usad8(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
if (rd != 15) {
tmp2 = load_reg(s, rd);
tcg_gen_add_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
store_reg(s, rn, tmp);
break;
case 0x20: case 0x24: case 0x28: case 0x2c:
ARCH(6T2);
shift = (insn >> 7) & 0x1f;
i = (insn >> 16) & 0x1f;
i = i + 1 - shift;
if (rm == 15) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
} else {
tmp = load_reg(s, rm);
}
if (i != 32) {
tmp2 = load_reg(s, rd);
tcg_gen_deposit_i32(tmp, tmp2, tmp, shift, i);
tcg_temp_free_i32(tmp2);
}
store_reg(s, rd, tmp);
break;
case 0x12: case 0x16: case 0x1a: case 0x1e:
case 0x32: case 0x36: case 0x3a: case 0x3e:
ARCH(6T2);
tmp = load_reg(s, rm);
shift = (insn >> 7) & 0x1f;
i = ((insn >> 16) & 0x1f) + 1;
if (shift + i > 32)
goto illegal_op;
if (i < 32) {
if (op1 & 0x20) {
gen_ubfx(tmp, shift, (1u << i) - 1);
} else {
gen_sbfx(tmp, shift, i);
}
}
store_reg(s, rd, tmp);
break;
default:
goto illegal_op;
}
break;
}
break;
}
do_ldst:
sh = (0xf << 20) | (0xf << 4);
if (op1 == 0x7 && ((insn & sh) == sh))
{
goto illegal_op;
}
rn = (insn >> 16) & 0xf;
rd = (insn >> 12) & 0xf;
tmp2 = load_reg(s, rn);
i = (IS_USER(s) || (insn & 0x01200000) == 0x00200000);
if (insn & (1 << 24))
gen_add_data_offset(s, insn, tmp2);
if (insn & (1 << 20)) {
if (insn & (1 << 22)) {
tmp = gen_ld8u(tmp2, i);
} else {
tmp = gen_ld32(tmp2, i);
}
} else {
tmp = load_reg(s, rd);
if (insn & (1 << 22))
gen_st8(tmp, tmp2, i);
else
gen_st32(tmp, tmp2, i);
}
if (!(insn & (1 << 24))) {
gen_add_data_offset(s, insn, tmp2);
store_reg(s, rn, tmp2);
} else if (insn & (1 << 21)) {
store_reg(s, rn, tmp2);
} else {
tcg_temp_free_i32(tmp2);
}
if (insn & (1 << 20)) {
store_reg_from_load(env, s, rd, tmp);
}
break;
case 0x08:
case 0x09:
{
int j, n, user, loaded_base;
TCGv loaded_var;
user = 0;
if (insn & (1 << 22)) {
if (IS_USER(s))
goto illegal_op;
if ((insn & (1 << 15)) == 0)
user = 1;
}
rn = (insn >> 16) & 0xf;
addr = load_reg(s, rn);
loaded_base = 0;
TCGV_UNUSED(loaded_var);
n = 0;
for(i=0;i<16;i++) {
if (insn & (1 << i))
n++;
}
if (insn & (1 << 23)) {
if (insn & (1 << 24)) {
tcg_gen_addi_i32(addr, addr, 4);
} else {
}
} else {
if (insn & (1 << 24)) {
tcg_gen_addi_i32(addr, addr, -(n * 4));
} else {
if (n != 1)
tcg_gen_addi_i32(addr, addr, -((n - 1) * 4));
}
}
j = 0;
for(i=0;i<16;i++) {
if (insn & (1 << i)) {
if (insn & (1 << 20)) {
tmp = gen_ld32(addr, IS_USER(s));
if (user) {
tmp2 = tcg_const_i32(i);
gen_helper_set_user_reg(cpu_env, tmp2, tmp);
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp);
} else if (i == rn) {
loaded_var = tmp;
loaded_base = 1;
} else {
store_reg_from_load(env, s, i, tmp);
}
} else {
if (i == 15) {
val = (long)s->pc + 4;
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, val);
} else if (user) {
tmp = tcg_temp_new_i32();
tmp2 = tcg_const_i32(i);
gen_helper_get_user_reg(tmp, cpu_env, tmp2);
tcg_temp_free_i32(tmp2);
} else {
tmp = load_reg(s, i);
}
gen_st32(tmp, addr, IS_USER(s));
}
j++;
if (j != n)
tcg_gen_addi_i32(addr, addr, 4);
}
}
if (insn & (1 << 21)) {
if (insn & (1 << 23)) {
if (insn & (1 << 24)) {
} else {
tcg_gen_addi_i32(addr, addr, 4);
}
} else {
if (insn & (1 << 24)) {
if (n != 1)
tcg_gen_addi_i32(addr, addr, -((n - 1) * 4));
} else {
tcg_gen_addi_i32(addr, addr, -(n * 4));
}
}
store_reg(s, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
if (loaded_base) {
store_reg(s, rn, loaded_var);
}
if ((insn & (1 << 22)) && !user) {
tmp = load_cpu_field(spsr);
gen_set_cpsr(tmp, 0xffffffff);
tcg_temp_free_i32(tmp);
s->is_jmp = DISAS_UPDATE;
}
}
break;
case 0xa:
case 0xb:
{
int32_t offset;
val = (int32_t)s->pc;
if (insn & (1 << 24)) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, val);
store_reg(s, 14, tmp);
}
offset = (((int32_t)insn << 8) >> 8);
val += (offset << 2) + 4;
gen_jmp(s, val);
}
break;
case 0xc:
case 0xd:
case 0xe:
if (disas_coproc_insn(env, s, insn))
goto illegal_op;
break;
case 0xf:
gen_set_pc_im(s->pc);
s->is_jmp = DISAS_SWI;
break;
default:
illegal_op:
gen_exception_insn(s, 4, EXCP_UDEF);
break;
}
}
} | 1threat |
int kvm_vm_ioctl(KVMState *s, int type, ...)
{
int ret;
void *arg;
va_list ap;
va_start(ap, type);
arg = va_arg(ap, void *);
va_end(ap);
ret = ioctl(s->vmfd, type, arg);
if (ret == -1)
ret = -errno;
return ret;
}
| 1threat |
static int flv_read_header(AVFormatContext *s)
{
int flags;
FLVContext *flv = s->priv_data;
int offset;
avio_skip(s->pb, 4);
flags = avio_r8(s->pb);
flv->missing_streams = flags & (FLV_HEADER_FLAG_HASVIDEO | FLV_HEADER_FLAG_HASAUDIO);
s->ctx_flags |= AVFMTCTX_NOHEADER;
offset = avio_rb32(s->pb);
avio_seek(s->pb, offset, SEEK_SET);
avio_skip(s->pb, 4);
s->start_time = 0;
flv->sum_flv_tag_size = 0;
flv->last_keyframe_stream_index = -1;
return 0;
}
| 1threat |
Proper usage of AsyncTask? : <p>I'm trying to use AsyncTask in the main class of the app as exercise. I included the basic code that i'm trying to understand.The error is the <code>DownloadFilesTask must be declared abstract or implement abstract method doInBackground</code></p>
<p>Java code;</p>
<pre><code>import android.media.Image;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.os.AsyncTask;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
ImageView image = (ImageView)findViewById(R.id.BackGroundForAll);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
private class DownloadFilesTask extends AsyncTask<Void, Void, Void> {
protected Long doInBackground(Void....Void) {
}
protected void onProgressUpdate(Integer... progress) {
}
protected void onPostExecute(Long result) {
}
}
}
</code></pre>
| 0debug |
static void print_report(AVFormatContext **output_files,
AVOutputStream **ost_table, int nb_ostreams,
int is_last_report)
{
char buf[1024];
AVOutputStream *ost;
AVFormatContext *oc, *os;
int64_t total_size;
AVCodecContext *enc;
int frame_number, vid, i;
double bitrate, ti1, pts;
static int64_t last_time = -1;
static int qp_histogram[52];
if (!is_last_report) {
int64_t cur_time;
cur_time = av_gettime();
if (last_time == -1) {
last_time = cur_time;
return;
}
if ((cur_time - last_time) < 500000)
return;
last_time = cur_time;
}
oc = output_files[0];
total_size = url_fsize(oc->pb);
if(total_size<0)
total_size= url_ftell(oc->pb);
buf[0] = '\0';
ti1 = 1e10;
vid = 0;
for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i];
os = output_files[ost->file_index];
enc = ost->st->codec;
if (vid && enc->codec_type == CODEC_TYPE_VIDEO) {
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ",
enc->coded_frame->quality/(float)FF_QP2LAMBDA);
}
if (!vid && enc->codec_type == CODEC_TYPE_VIDEO) {
float t = (av_gettime()-timer_start) / 1000000.0;
frame_number = ost->frame_number;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d fps=%3d q=%3.1f ",
frame_number, (t>1)?(int)(frame_number/t+0.5) : 0,
enc->coded_frame ? enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);
if(is_last_report)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L");
if(qp_hist && enc->coded_frame){
int j;
int qp= lrintf(enc->coded_frame->quality/(float)FF_QP2LAMBDA);
if(qp>=0 && qp<sizeof(qp_histogram)/sizeof(int))
qp_histogram[qp]++;
for(j=0; j<32; j++)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", (int)lrintf(log(qp_histogram[j]+1)/log(2)));
}
if (enc->flags&CODEC_FLAG_PSNR){
int j;
double error, error_sum=0;
double scale, scale_sum=0;
char type[3]= {'Y','U','V'};
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "PSNR=");
for(j=0; j<3; j++){
if(is_last_report){
error= enc->error[j];
scale= enc->width*enc->height*255.0*255.0*frame_number;
}else{
error= enc->coded_frame->error[j];
scale= enc->width*enc->height*255.0*255.0;
}
if(j) scale/=4;
error_sum += error;
scale_sum += scale;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%c:%2.2f ", type[j], psnr(error/scale));
}
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "*:%2.2f ", psnr(error_sum/scale_sum));
}
vid = 1;
}
pts = (double)ost->st->pts.val * av_q2d(ost->st->time_base);
if ((pts < ti1) && (pts > 0))
ti1 = pts;
}
if (ti1 < 0.01)
ti1 = 0.01;
if (verbose || is_last_report) {
bitrate = (double)(total_size * 8) / ti1 / 1000.0;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
"size=%8.0fkB time=%0.1f bitrate=%6.1fkbits/s",
(double)total_size / 1024, ti1, bitrate);
if (verbose > 1)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " dup=%d drop=%d",
nb_frames_dup, nb_frames_drop);
if (verbose >= 0)
fprintf(stderr, "%s \r", buf);
fflush(stderr);
}
if (is_last_report && verbose >= 0){
int64_t raw= audio_size + video_size + extra_size;
fprintf(stderr, "\n");
fprintf(stderr, "video:%1.0fkB audio:%1.0fkB global headers:%1.0fkB muxing overhead %f%%\n",
video_size/1024.0,
audio_size/1024.0,
extra_size/1024.0,
100.0*(total_size - raw)/raw
);
}
}
| 1threat |
void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict)
{
struct in_addr host_addr = { .s_addr = INADDR_ANY };
int host_port;
char buf[256] = "";
const char *src_str, *p;
SlirpState *s;
int is_udp = 0;
int err;
const char *arg1 = qdict_get_str(qdict, "arg1");
const char *arg2 = qdict_get_try_str(qdict, "arg2");
const char *arg3 = qdict_get_try_str(qdict, "arg3");
if (arg2) {
s = slirp_lookup(mon, arg1, arg2);
src_str = arg3;
} else {
s = slirp_lookup(mon, NULL, NULL);
src_str = arg1;
}
if (!s) {
return;
}
if (!src_str || !src_str[0])
goto fail_syntax;
p = src_str;
get_str_sep(buf, sizeof(buf), &p, ':');
if (!strcmp(buf, "tcp") || buf[0] == '\0') {
is_udp = 0;
} else if (!strcmp(buf, "udp")) {
is_udp = 1;
} else {
goto fail_syntax;
}
if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) {
goto fail_syntax;
}
if (buf[0] != '\0' && !inet_aton(buf, &host_addr)) {
goto fail_syntax;
}
host_port = atoi(p);
err = slirp_remove_hostfwd(QTAILQ_FIRST(&slirp_stacks)->slirp, is_udp,
host_addr, host_port);
monitor_printf(mon, "host forwarding rule for %s %s\n", src_str,
err ? "removed" : "not found");
return;
fail_syntax:
monitor_printf(mon, "invalid format\n");
}
| 1threat |
static void compare_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
BdrvCheckMode fix, bool *rebuild,
int64_t *highest_cluster,
uint16_t *refcount_table, int64_t nb_clusters)
{
BDRVQcowState *s = bs->opaque;
int64_t i;
uint64_t refcount1, refcount2;
int ret;
for (i = 0, *highest_cluster = 0; i < nb_clusters; i++) {
ret = qcow2_get_refcount(bs, i, &refcount1);
if (ret < 0) {
fprintf(stderr, "Can't get refcount for cluster %" PRId64 ": %s\n",
i, strerror(-ret));
res->check_errors++;
continue;
}
refcount2 = refcount_table[i];
if (refcount1 > 0 || refcount2 > 0) {
*highest_cluster = i;
}
if (refcount1 != refcount2) {
int *num_fixed = NULL;
if (refcount1 == 0) {
*rebuild = true;
} else if (refcount1 > refcount2 && (fix & BDRV_FIX_LEAKS)) {
num_fixed = &res->leaks_fixed;
} else if (refcount1 < refcount2 && (fix & BDRV_FIX_ERRORS)) {
num_fixed = &res->corruptions_fixed;
}
fprintf(stderr, "%s cluster %" PRId64 " refcount=%" PRIu64
" reference=%" PRIu64 "\n",
num_fixed != NULL ? "Repairing" :
refcount1 < refcount2 ? "ERROR" :
"Leaked",
i, refcount1, refcount2);
if (num_fixed) {
ret = update_refcount(bs, i << s->cluster_bits, 1,
refcount_diff(refcount1, refcount2),
refcount1 > refcount2,
QCOW2_DISCARD_ALWAYS);
if (ret >= 0) {
(*num_fixed)++;
continue;
}
}
if (refcount1 < refcount2) {
res->corruptions++;
} else {
res->leaks++;
}
}
}
}
| 1threat |
static int net_dump_init(NetClientState *peer, const char *device,
const char *name, const char *filename, int len)
{
struct pcap_file_hdr hdr;
NetClientState *nc;
DumpState *s;
struct tm tm;
int fd;
fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0644);
if (fd < 0) {
error_report("-net dump: can't open %s", filename);
return -1;
}
hdr.magic = PCAP_MAGIC;
hdr.version_major = 2;
hdr.version_minor = 4;
hdr.thiszone = 0;
hdr.sigfigs = 0;
hdr.snaplen = len;
hdr.linktype = 1;
if (write(fd, &hdr, sizeof(hdr)) < sizeof(hdr)) {
error_report("-net dump write error: %s", strerror(errno));
close(fd);
return -1;
}
nc = qemu_new_net_client(&net_dump_info, peer, device, name);
snprintf(nc->info_str, sizeof(nc->info_str),
"dump to %s (len=%d)", filename, len);
s = DO_UPCAST(DumpState, nc, nc);
s->fd = fd;
s->pcap_caplen = len;
qemu_get_timedate(&tm, 0);
s->start_ts = mktime(&tm);
return 0;
}
| 1threat |
How do I cloudform an API gateway resource with a lambda proxy integration : <p>I've been trying to work out how to express (in cloudformation) an API Gateway Resource that has a Lambda function integration type using the Lambda Proxy integration.</p>
<p>This is easy to do in the AWS console as there is a check box that you can select:
<a href="https://i.stack.imgur.com/AkELO.png" rel="noreferrer"><img src="https://i.stack.imgur.com/AkELO.png" alt="API gateway console showing the Use Lambda Proxy Integration checkbox"></a></p>
<p>However there is no corresponding field in the AWS::ApiGateway::Method CloudFormation resource (it should be in the <a href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apitgateway-method-integration.html" rel="noreferrer">Integration property</a>).</p>
<p>How can I configure this in cloudformation?</p>
| 0debug |
How to change root path ~/ in Razor in asp.net core : <p>The simplest question for which I can't find an answer.</p>
<p>I have an asp.net core 2.1 MVC application with Razor.</p>
<p>Application widely uses <code>~/path</code> syntax.
Everything works great if application runs from domain root (for example, from <a href="http://localhost:5000/" rel="noreferrer">http://localhost:5000/</a>)</p>
<p>But when I run application at non-root (for example, <a href="http://localhost:5000/app" rel="noreferrer">http://localhost:5000/app</a>) the Razor still uses root (<code>/</code>) as base path.</p>
<p>Question: how to configure this? How to specify base path for Razor's <code>~/</code>? There must be an environment variable for it :)</p>
<p>PS: Application run in docker behind the reverse proxy.</p>
| 0debug |
How to access Kubernetes UI via browser? : <p>I have installed Kubernetes using <a href="https://github.com/kubernetes/contrib" rel="noreferrer">contrib/ansible</a> scripts.
When I run cluster-info:</p>
<pre><code>[osboxes@kube-master-def ~]$ kubectl cluster-info
Kubernetes master is running at http://localhost:8080
Elasticsearch is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/elasticsearch-logging
Heapster is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/heapster
Kibana is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/kibana-logging
KubeDNS is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/kube-dns
kubedash is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/kubedash
Grafana is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/monitoring-grafana
InfluxDB is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/monitoring-influxdb
</code></pre>
<p>The cluster is exposed on localhost with insecure port, and exposed on secure port 443 via ssl</p>
<p><code>kube 18103 1 0 12:20 ? 00:02:57 /usr/bin/kube-controller-manager --logtostderr=true --v=0 --master=https://10.57.50.161:443 -- kubeconfig=/etc/kubernetes/controller-manager.kubeconfig --service-account-private-key-file=/etc/kubernetes/certs/server.key --root-ca-file=/etc/kubernetes/certs/ca.crt
kube 18217 1 0 12:20 ? 00:00:15 /usr/bin/kube-scheduler --logtostderr=true --v=0 --master=https://10.57.50.161:443 --kubeconfig=/etc/kubernetes/scheduler.kubeconfig
root 27094 1 0 12:21 ? 00:00:00 /bin/bash /usr/libexec/kubernetes/kube-addons.sh
kube 27300 1 1 12:21 ? 00:05:36 /usr/bin/kube-apiserver --logtostderr=true --v=0 --etcd-servers=http://10.57.50.161:2379 --insecure-bind-address=127.0.0.1 --secure-port=443 --allow-privileged=true --service-cluster-ip-range=10.254.0.0/16 --admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota --tls-cert-file=/etc/kubernetes/certs/server.crt --tls-private-key-file=/etc/kubernetes/certs/server.key --client-ca-file=/etc/kubernetes/certs/ca.crt --token-auth-file=/etc/kubernetes/tokens/known_tokens.csv --service-account-key-file=/etc/kubernetes/certs/server.crt
</code></p>
<p>I have copied the certificates from kube-master machine to my local machine, I have installed the ca root certificate. The chrome/safari browsers are accepting the ca root certificate.
When I'm trying to access the <a href="https://10.57.50.161/ui" rel="noreferrer">https://10.57.50.161/ui</a>
I'm getting the 'Unauthorized'</p>
<p>How can I access the kubernetes ui?</p>
| 0debug |
Native PHP function that pairs elements from arbitrary number of input arrays : <p>Given two (or more) arrays as parameters,</p>
<pre><code>$a1 = [1, 2, 3];
$a2 = ['a', 'b', 'c'];
</code></pre>
<p>is there a native PHP array function that will produce the following:</p>
<pre><code>[[1, 'a'], [2, 'b'], [3, 'c']]
</code></pre>
<p>i.e. - pair each element from the input arrays?</p>
<p>I've looked through the PHP docs with no luck.</p>
| 0debug |
How to assign the correct typing to React.cloneElement when giving properties to children? : <p>I am using React and Typescript. I have a react component that acts as a wrapper, and I wish to copy its properties to its children. I am following React's guide to using clone element: <a href="https://facebook.github.io/react/blog/2015/03/03/react-v0.13-rc2.html#react.cloneelement" rel="noreferrer">https://facebook.github.io/react/blog/2015/03/03/react-v0.13-rc2.html#react.cloneelement</a>. But when using using <code>React.cloneElement</code> I get the following error from Typescript:</p>
<pre><code>Argument of type 'ReactChild' is not assignable to parameter of type 'ReactElement<any>'.at line 27 col 39
Type 'string' is not assignable to type 'ReactElement<any>'.
</code></pre>
<p><strong>How can I assign the correct typing's to react.cloneElement?</strong></p>
<p>Here is an example that replicates the error above:</p>
<pre><code>import * as React from 'react';
interface AnimationProperties {
width: number;
height: number;
}
/**
* the svg html element which serves as a wrapper for the entire animation
*/
export class Animation extends React.Component<AnimationProperties, undefined>{
/**
* render all children with properties from parent
*
* @return {React.ReactNode} react children
*/
renderChildren(): React.ReactNode {
return React.Children.map(this.props.children, (child) => {
return React.cloneElement(child, { // <-- line that is causing error
width: this.props.width,
height: this.props.height
});
});
}
/**
* render method for react component
*/
render() {
return React.createElement('svg', {
width: this.props.width,
height: this.props.height
}, this.renderChildren());
}
}
</code></pre>
| 0debug |
Wildcards generic in Kotlin for variable : <p>Is it possible to declare generic wildcards in Kotlin like this code in Java: </p>
<pre><code>List<Integer> a = new ArrayList<>();
List<? extends Number> b = a;
</code></pre>
| 0debug |
C# How to get last 5 variables from an Array? : <p>I'm creating mobile game in unity, all i need to know is how to get last 5 variables of an Array using <code>for</code> or <code>foreach</code>?</p>
| 0debug |
How to add date and time seperately in java : static final String DATE_FORMAT = "yyyy-MM-dd";
static final String TIME_FORMAT = "HH:mm:ss";
private static final int ADD_MINUTES = 2;
static final String FromDate = "2016-01-01 00:00:00";
public static void main(String[] args) throws Exception {
DateFormat df = new SimpleDateFormat(DATE_FORMAT);
DateFormat d_f = new SimpleDateFormat(DATE_FORMAT);
DateFormat tf = new SimpleDateFormat(TIME_FORMAT);
Calendar cal = Calendar.getInstance();
cal.setTime(df.parse(FromDate));
cal.add(Calendar.MINUTE, ADD_MINUTES);
record.append("\t");
record.append(d_f.format(cal.getTime()));
record.append("\t");
record.append(tf.format(cal.getTime()));
record.append("\t");
records.add(record.toString());
}
Here i want to add date and time seperately i mean in different tab, used \t still i am not getting the required output.
| 0debug |
static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h)
{
const int mb_x = h->mb_x;
const int mb_y = h->mb_y;
const int mb_xy = h->mb_xy;
const int mb_type = h->cur_pic.f.mb_type[mb_xy];
uint8_t *dest[3];
int linesize;
int i, j, p;
int *block_offset = &h->block_offset[0];
const int transform_bypass = !SIMPLE && (h->qscale == 0 && h->sps.transform_bypass);
const int plane_count = (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) ? 3 : 1;
for (p = 0; p < plane_count; p++) {
dest[p] = h->cur_pic.f.data[p] +
((mb_x << PIXEL_SHIFT) + mb_y * h->linesize) * 16;
h->vdsp.prefetch(dest[p] + (h->mb_x & 3) * 4 * h->linesize + (64 << PIXEL_SHIFT),
h->linesize, 4);
}
h->list_counts[mb_xy] = h->list_count;
if (!SIMPLE && MB_FIELD) {
linesize = h->mb_linesize = h->mb_uvlinesize = h->linesize * 2;
block_offset = &h->block_offset[48];
if (mb_y & 1)
for (p = 0; p < 3; p++)
dest[p] -= h->linesize * 15;
if (FRAME_MBAFF) {
int list;
for (list = 0; list < h->list_count; list++) {
if (!USES_LIST(mb_type, list))
continue;
if (IS_16X16(mb_type)) {
int8_t *ref = &h->ref_cache[list][scan8[0]];
fill_rectangle(ref, 4, 4, 8, (16 + *ref) ^ (h->mb_y & 1), 1);
} else {
for (i = 0; i < 16; i += 4) {
int ref = h->ref_cache[list][scan8[i]];
if (ref >= 0)
fill_rectangle(&h->ref_cache[list][scan8[i]], 2, 2,
8, (16 + ref) ^ (h->mb_y & 1), 1);
}
}
}
}
} else {
linesize = h->mb_linesize = h->mb_uvlinesize = h->linesize;
}
if (!SIMPLE && IS_INTRA_PCM(mb_type)) {
if (PIXEL_SHIFT) {
const int bit_depth = h->sps.bit_depth_luma;
GetBitContext gb;
init_get_bits(&gb, (uint8_t *)h->intra_pcm_ptr, 768 * bit_depth);
for (p = 0; p < plane_count; p++)
for (i = 0; i < 16; i++) {
uint16_t *tmp = (uint16_t *)(dest[p] + i * linesize);
for (j = 0; j < 16; j++)
tmp[j] = get_bits(&gb, bit_depth);
}
} else {
for (p = 0; p < plane_count; p++)
for (i = 0; i < 16; i++)
memcpy(dest[p] + i * linesize,
(uint8_t *)h->intra_pcm_ptr + p * 256 + i * 16, 16);
}
} else {
if (IS_INTRA(mb_type)) {
if (h->deblocking_filter)
xchg_mb_border(h, dest[0], dest[1], dest[2], linesize,
linesize, 1, 1, SIMPLE, PIXEL_SHIFT);
for (p = 0; p < plane_count; p++)
hl_decode_mb_predict_luma(h, mb_type, 1, SIMPLE,
transform_bypass, PIXEL_SHIFT,
block_offset, linesize, dest[p], p);
if (h->deblocking_filter)
xchg_mb_border(h, dest[0], dest[1], dest[2], linesize,
linesize, 0, 1, SIMPLE, PIXEL_SHIFT);
} else {
FUNC(hl_motion_444)(h, dest[0], dest[1], dest[2],
h->me.qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
h->me.qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,
h->h264dsp.weight_h264_pixels_tab,
h->h264dsp.biweight_h264_pixels_tab);
}
for (p = 0; p < plane_count; p++)
hl_decode_mb_idct_luma(h, mb_type, 1, SIMPLE, transform_bypass,
PIXEL_SHIFT, block_offset, linesize,
dest[p], p);
if (h->cbp || IS_INTRA(mb_type)) {
h->dsp.clear_blocks(h->mb);
h->dsp.clear_blocks(h->mb + (24 * 16 << PIXEL_SHIFT));
}
}
}
| 1threat |
av_cold void ff_vp56_init(AVCodecContext *avctx, int flip, int has_alpha)
{
VP56Context *s = avctx->priv_data;
int i;
s->avctx = avctx;
avctx->pix_fmt = has_alpha ? PIX_FMT_YUVA420P : PIX_FMT_YUV420P;
if (avctx->idct_algo == FF_IDCT_AUTO)
avctx->idct_algo = FF_IDCT_VP3;
ff_dsputil_init(&s->dsp, avctx);
ff_vp56dsp_init(&s->vp56dsp, avctx->codec->id);
ff_init_scantable(s->dsp.idct_permutation, &s->scantable,ff_zigzag_direct);
for (i=0; i<4; i++)
s->framep[i] = &s->frames[i];
s->framep[VP56_FRAME_UNUSED] = s->framep[VP56_FRAME_GOLDEN];
s->framep[VP56_FRAME_UNUSED2] = s->framep[VP56_FRAME_GOLDEN2];
s->edge_emu_buffer_alloc = NULL;
s->above_blocks = NULL;
s->macroblocks = NULL;
s->quantizer = -1;
s->deblock_filtering = 1;
s->filter = NULL;
s->has_alpha = has_alpha;
if (flip) {
s->flip = -1;
s->frbi = 2;
s->srbi = 0;
} else {
s->flip = 1;
s->frbi = 0;
s->srbi = 2;
}
}
| 1threat |
Javascript - How to find the most day of the week? : I have an array of date, how do I find the most popular / second / third etc day of the week?
The I have tried the following
moment(@date field).week()
but how about an array of json dates?
2018-04-19
2018-04-19
2018-04-19
2018-04-20
2018-04-24
2018-05-02
2018-05-02
2018-05-02 | 0debug |
Is there any code line which can only show installed Games in my android app? : I have heard about getInstalledApplication() but it shows all app.
I want only games .
Please help i have to complete my android app development project
| 0debug |
vscode keyboard shortcut for launch configuration : <p>In vscode, I have a launch.json with more than one configuration.</p>
<p>Is there a way to assign a keyboard shortcut to a specific configuration?, I've not been able to find any information, thanks!</p>
| 0debug |
Is there a way to find the length of a variable in Java? : <pre><code>long AccountNumber = 1234567890;
public void setAccNum(long Number)
try(the size of the account number is lesser than equal to 10){
this.Accountnumber = Number;
}
catch(Exception e){
System.out.println("Error: Invalid account number");
}
</code></pre>
<p>In the above code, to validate the length of the account number, is there any function to find the length of the value in AccountNumber variable in Java?</p>
| 0debug |
how to combine two select sql statement? : ---- SELECT b.subCusNo, c.companyName as [Subsidiary],b.equityInterest,b.relation from cusparentsub b ,customerdetails c where b.subcusNo=c.custNo
----SELECT b.parentCusNo,c.companyName as [Parent Company],b.equityInterest, b.relation FROM cusparentsub b ,customerdetails c where b.parentcusNo=c.custNo.
Above is two sql statement. is it possible to join the select statement and the output will be in a table with subcusno,companyname,parentcusno,companyname,equityinterest and relation data?
thank you | 0debug |
Is there any way of executing a Python script from a web browser? : <p>I have a python script which I want to execute when someone clicks on a button in an HTML/PHP web page in the browser. How can this be achieved and what is the best way of doing it?</p>
| 0debug |
Can't load workbook using openpyxl : I have problem to load excel using openpyxl. Can someone help out, thanks.
openpyxl.__version__
'2.5.12'
jupyter version
5.7.4
os.getcwd()
'/Users/barbara/Documents/17_BMO'
path = "Users/barbara/Documents/17_BMO/Region.xlsx"
wb1 = openpyxl.load_workbook(path)
I got error message:FileNotFoundError: [Errno 2] No such file or directory: 'Users/barbara/Documents/17_BMO/Region.xlsx' | 0debug |
JavaScript function does not work. Help a newbie :\ : <p>I'm working on a linear gradient generator.
I wanted to add a random gradient function, so it picks the background style and sets a gradient with two random colors. Everything worked until i added this random function. It looks like this:</p>
<pre><code>function getRandomInRange(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function setRandomGradient() {
body.style.background = "linear-gradient(to right, rgb("
+ (getRandomInRange(1, 255)
+ " ,"
+ (getRandomInRange(1, 255)
+ " ,"
+ (getRandomInRange(1, 255)
+ "), rgb("
+ (getRandomInRange(1, 255)
+ " ,"
+ (getRandomInRange(1, 255)
+ " ,"
+ (getRandomInRange(1, 255)
+ "))";
}
</code></pre>
<p>getRandomInRange works well, but setRandomGradient isn't working and console shows me an error like:</p>
<blockquote>
<p>Uncaught SyntaxError: Unexpected token ';'</p>
</blockquote>
<p>Poitning to the last semicolon before a function brakets close. But if i remove the semicolon, the error is starting to point to something else, like closing brakets or something else</p>
| 0debug |
static void qemu_fflush(QEMUFile *f)
{
int ret = 0;
if (!f->ops->put_buffer) {
return;
}
if (f->is_write && f->buf_index > 0) {
ret = f->ops->put_buffer(f->opaque, f->buf, f->buf_offset, f->buf_index);
if (ret >= 0) {
f->buf_offset += f->buf_index;
}
f->buf_index = 0;
}
if (ret < 0) {
qemu_file_set_error(f, ret);
}
}
| 1threat |
Problems with inheritance in the STL : <p>In <a href="http://www.stepanovpapers.com/notes.pdf">http://www.stepanovpapers.com/notes.pdf</a>, Alexander Stepanov mentions:</p>
<blockquote>
<p>It is interesting to note that the only examples of inheritance that
remained in STL inherit from empty classes. Originally, there were
many uses of inheritance inside the containers and even iterators, but
they had to be removed because of the problems they caused.</p>
</blockquote>
<p>What are the technical problems that precluded the use of inheritance in the STL?</p>
| 0debug |
Handling changes to files with --skip-worktree from another branch : <p>On my machine, I've set <code>--skip-worktree</code> to <code>config/database.yml</code>.</p>
<pre><code>git update-index --skip-worktree config/database.yml
</code></pre>
<p>Another developer has committed and merged into the develop branch changes to <code>config/database.yml</code> while working on the project.</p>
<p>Now, when I do <code>git pull origin develop</code>, I get</p>
<pre><code>Andrews-Air:[project] agrimm$ git pull origin develop
From bitbucket.org:[company]/[project]
* branch develop -> FETCH_HEAD
Updating [SHA]..[Another SHA]
error: Your local changes to the following files would be overwritten by merge:
config/database.yml
Please, commit your changes or stash them before you can merge.
Aborting
</code></pre>
<p>How should I handle such a change? Should I do</p>
<pre><code>git update-index --no-skip-worktree config/database.yml
git stash save "Save changes to config/database.yml"
git pull origin develop
git stash apply
# Fix any conflicts
git update-index --skip-worktree config/database.yml
</code></pre>
<p>Or is there a less hacky approach?</p>
| 0debug |
static void gen_pusha(DisasContext *s)
{
int i;
gen_op_movl_A0_reg(R_ESP);
gen_op_addl_A0_im(-8 << s->dflag);
if (!s->ss32)
tcg_gen_ext16u_tl(cpu_A0, cpu_A0);
tcg_gen_mov_tl(cpu_T[1], cpu_A0);
if (s->addseg)
gen_op_addl_A0_seg(s, R_SS);
for(i = 0;i < 8; i++) {
gen_op_mov_v_reg(MO_32, cpu_T[0], 7 - i);
gen_op_st_v(s, s->dflag, cpu_T[0], cpu_A0);
gen_op_addl_A0_im(1 << s->dflag);
}
gen_op_mov_reg_v(MO_16 + s->ss32, R_ESP, cpu_T[1]);
}
| 1threat |
How to add column with constant in Spark-java data frame : <p>I have imported </p>
<pre><code>import org.apache.spark.sql.Column;
import org.apache.spark.sql.functions;
</code></pre>
<p>in my Java-Spark driver</p>
<p>But</p>
<pre><code>DataFrame inputDFTwo = hiveContext.sql("select * from sourcing_src_tbl");
inputDFTwo.withColumn("asofdate", lit("2016-10-2"));
</code></pre>
<p>here "lit" is still showing error in eclipse(windows).Which library should I include to make it work.</p>
| 0debug |
Passing parameters from a rotating proxy service into a get request : <p>I'm reading urls from a text file:
using this service <a href="https://www.proxyrotator.com/app/rotating-proxy-api/" rel="nofollow noreferrer">https://www.proxyrotator.com/app/rotating-proxy-api/</a>
and it doesn't work obviously. Thank you.</p>
<pre><code>def checkUrl(url):
try:
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X
10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95
Safari/537.36'}
proxy = 'http://falcon.proxyrotator.com:51337/'
params = dict(
apiKey='WZV8jEX49JKz3TaBMHpyD6POOP'
)
resp = requests.get(url, proxy=proxy, params=params, headers=headers)
return str(resp.status_code)
</code></pre>
| 0debug |
static int recode_subtitle(AVCodecContext *avctx,
AVPacket *outpkt, const AVPacket *inpkt)
{
#if CONFIG_ICONV
iconv_t cd = (iconv_t)-1;
int ret = 0;
char *inb, *outb;
size_t inl, outl;
AVPacket tmp;
#endif
if (avctx->sub_charenc_mode != FF_SUB_CHARENC_MODE_PRE_DECODER)
return 0;
#if CONFIG_ICONV
cd = iconv_open("UTF-8", avctx->sub_charenc);
av_assert0(cd != (iconv_t)-1);
inb = inpkt->data;
inl = inpkt->size;
if (inl >= INT_MAX / UTF8_MAX_BYTES - FF_INPUT_BUFFER_PADDING_SIZE) {
av_log(avctx, AV_LOG_ERROR, "Subtitles packet is too big for recoding\n");
ret = AVERROR(ENOMEM);
goto end;
}
ret = av_new_packet(&tmp, inl * UTF8_MAX_BYTES);
if (ret < 0)
goto end;
outpkt->buf = tmp.buf;
outpkt->data = tmp.data;
outpkt->size = tmp.size;
outb = outpkt->data;
outl = outpkt->size;
if (iconv(cd, &inb, &inl, &outb, &outl) == (size_t)-1 ||
iconv(cd, NULL, NULL, &outb, &outl) == (size_t)-1 ||
outl >= outpkt->size || inl != 0) {
av_log(avctx, AV_LOG_ERROR, "Unable to recode subtitle event \"%s\" "
"from %s to UTF-8\n", inpkt->data, avctx->sub_charenc);
av_free_packet(&tmp);
ret = AVERROR(errno);
goto end;
}
outpkt->size -= outl;
outpkt->data[outpkt->size - 1] = '\0';
end:
if (cd != (iconv_t)-1)
iconv_close(cd);
return ret;
#else
av_assert0(!"requesting subtitles recoding without iconv");
#endif
}
| 1threat |
Overwrite parquet files from dynamic frame in AWS Glue : <p>I use dynamic frames to write a parquet file in S3 but if a file already exists my program append a new file instead of replace it. The sentence that I use is this:</p>
<pre><code>glueContext.write_dynamic_frame.from_options(frame = table,
connection_type = "s3",
connection_options = {"path": output_dir,
"partitionKeys": ["var1","var2"]},
format = "parquet")
</code></pre>
<p>Is there anything like <code>"mode":"overwrite"</code> that replace my parquet files?</p>
| 0debug |
static void calc_transform_coeffs_cpl(AC3DecodeContext *s)
{
int bin, band, ch, band_end;
bin = s->start_freq[CPL_CH];
for (band = 0; band < s->num_cpl_bands; band++) {
band_end = bin + s->cpl_band_sizes[band];
for (; bin < band_end; bin++) {
for (ch = 1; ch <= s->fbw_channels; ch++) {
if (s->channel_in_cpl[ch]) {
s->fixed_coeffs[ch][bin] = ((int64_t)s->fixed_coeffs[CPL_CH][bin] *
(int64_t)s->cpl_coords[ch][band]) >> 23;
if (ch == 2 && s->phase_flags[band])
s->fixed_coeffs[ch][bin] = -s->fixed_coeffs[ch][bin];
}
}
}
}
}
| 1threat |
Do Object.keys() and Object.values() methods return arrays that preserve the same order : <p>Do <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys" rel="noreferrer">Object.keys()</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values" rel="noreferrer">Object.values()</a> methods return arrays that preserve the same order?</p>
<p>I mean, suppose that we have the following object:</p>
<pre><code>var obj = {};
obj.prop1 = "Foo";
obj.prop2 = "Bar";
</code></pre>
<p>If I call <code>obj.keys()</code> and <code>obj.values()</code> will they return properties with the same order?</p>
<pre><code>prop1
prop2
Foo
Bar
</code></pre>
<p>or</p>
<pre><code>prop2
prop1
Bar
Foo
</code></pre>
<p>Right?</p>
<p>So the following option is not possible, right?</p>
<pre><code>prop1
prop2
Bar
Foo
</code></pre>
| 0debug |
how do i use an initializer list on a derived class? : I'm writing a `Qt` application where I have a derived class of `QDialog`. My derived class also uses a initializer list to for a couple of private members (that get set through the constructor). Now I am a bit confused even in terms of allowed syntax. I found this [post][1], tried to follow it in my little demo script and came up with the following:
#include <QString>
#include <QSettings>
#include <QtWidgets/QWidget>
#include <QtWidgets/QDialog>
class foo {
Q_OBJECT
public:
foo(QSettings* const set=nullptr, const QString s="", QWidget *parent=nullptr) : QDialog{
public:
foo(QSettings* const set=nullptr, const QString s="", QWidget *parent): QDialog(parent){}
};
QString nme_get() {return name;}
void qux(void);
private:
const QString name;
QSettings * const settings;
};
void foo::qux(void) {
QSettings *test = settings;
QString name = nme_get();
test->beginGroup(name);
/*
* ...
*/
test->endGroup();
}
int main (void) {
QWidget *parent = nullptr;
QSettings *sttngs = new QSettings(QSettings::NativeFormat,QSettings::UserScope,"GNU","scaper",nullptr
);
foo inst{sttngs, QString("quux"), parent};
inst.qux();
return 0;
}
which the compiler throws out with:
foo.cpp: In constructor ‘foo::foo(QSettings*, QString, QWidget*)’:
foo.cpp:10:91: error: type ‘QDialog’ is not a direct base of ‘foo’
foo(QSettings* const set=nullptr, const QString s="", QWidget *parent=nullptr) : QDialog{
^
foo.cpp:11:9: error: expected primary-expression before ‘public’
public:
^
foo.cpp:11:9: error: expected ‘}’ before ‘public’
foo.cpp:10:9: error: uninitialized const member in ‘class QSettings* const’ [-fpermissive]
foo(QSettings* const set=nullptr, const QString s="", QWidget *parent=nullptr) : QDialog{
^
foo.cpp:20:28: note: ‘QSettings* const foo::settings’ should be initialized
QSettings * const settings;
^
foo.cpp:11:9: error
[1]: https://stackoverflow.com/questions/33092076/initializer-list-for-derived-class#33092161
| 0debug |
static void a15_daughterboard_init(const VexpressMachineState *vms,
ram_addr_t ram_size,
const char *cpu_model,
qemu_irq *pic)
{
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *sram = g_new(MemoryRegion, 1);
if (!cpu_model) {
cpu_model = "cortex-a15";
}
{
uint64_t rsz = ram_size;
if (rsz > (30ULL * 1024 * 1024 * 1024)) {
fprintf(stderr, "vexpress-a15: cannot model more than 30GB RAM\n");
exit(1);
}
}
memory_region_allocate_system_memory(ram, NULL, "vexpress.highmem",
ram_size);
memory_region_add_subregion(sysmem, 0x80000000, ram);
init_cpus(cpu_model, "a15mpcore_priv", 0x2c000000, pic, vms->secure);
memory_region_init_ram(sram, NULL, "vexpress.a15sram", 0x10000,
&error_abort);
vmstate_register_ram_global(sram);
memory_region_add_subregion(sysmem, 0x2e000000, sram);
}
| 1threat |
This program is returning inf" as the output in c : #include <stdio.h>
void main()
{
int i, n,a;
float result=1;
float sum;
a=1;
sum=0;
printf("Enter a number:\n");
scanf("%d",&n);
for (i=0;i<=n-1;i++)
{
result=result*i;
sum = a + (i/result);`enter code here`
}
printf("%.2f is the answer\n",sum );
}
The code here is meant to find the sum of factorial.The output comes as "inf is the answer". I don't know how to solve this. New to programming.
| 0debug |
Which function tells me what kernel gave as the local socket? : As a client I do a socket(), it gives me a number I store in sktnum. I then do a connect() with sktnum and the remote address. Hey presto, it succeeds, and I am told the kernel has selected a local IP address and port number (so as the server will know where to send back to). What function (linux C/C++) do I call to find out what port and IP address the kernel selected. (And please don't be one of those people who say "why do you want to know") | 0debug |
how to convert to lower case in c++ using files : <p>I need to convert each word to lower case in file by looping on all file's sentences. I would like to use cout each word after I convert it. I assume I need to use c_str() some how.</p>
| 0debug |
WHEN I am tryng to insert an image in database it's not showing any error but image is not inserting in table : I am tryng to insert an image in database it's not showing any error but image is not inserting in table
result is printing "not"
<?php
if (isset($_POST['pic_upload']))
{
if(getimagesize($_FILES['image']['tmp_name'])==False)
{
echo "select img";
}
else{
$image=addslashes($_FILES['image']['tmp_name']);
$name=addslashes($_FILES['image']['name']);
$image = file_get_contents($image);
$image = base64_encode($image);
saveimage($name,$image);
}
}
function saveimage($name,$image)
{
require 'db.php';
$sql="insert into blob(name,image) values('$name','$image')";
$result=$conn->query($sql);
if($result){
echo "done";
}
else {
echo 'not';
}
}
?> | 0debug |
static av_always_inline av_flatten void h264_loop_filter_luma_intra_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta)
{
int d;
for( d = 0; d < 16; d++ ) {
const int p2 = pix[-3*xstride];
const int p1 = pix[-2*xstride];
const int p0 = pix[-1*xstride];
const int q0 = pix[ 0*xstride];
const int q1 = pix[ 1*xstride];
const int q2 = pix[ 2*xstride];
if( FFABS( p0 - q0 ) < alpha &&
FFABS( p1 - p0 ) < beta &&
FFABS( q1 - q0 ) < beta ) {
if(FFABS( p0 - q0 ) < (( alpha >> 2 ) + 2 )){
if( FFABS( p2 - p0 ) < beta)
{
const int p3 = pix[-4*xstride];
pix[-1*xstride] = ( p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4 ) >> 3;
pix[-2*xstride] = ( p2 + p1 + p0 + q0 + 2 ) >> 2;
pix[-3*xstride] = ( 2*p3 + 3*p2 + p1 + p0 + q0 + 4 ) >> 3;
} else {
pix[-1*xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
}
if( FFABS( q2 - q0 ) < beta)
{
const int q3 = pix[3*xstride];
pix[0*xstride] = ( p1 + 2*p0 + 2*q0 + 2*q1 + q2 + 4 ) >> 3;
pix[1*xstride] = ( p0 + q0 + q1 + q2 + 2 ) >> 2;
pix[2*xstride] = ( 2*q3 + 3*q2 + q1 + q0 + p0 + 4 ) >> 3;
} else {
pix[0*xstride] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
}
}else{
pix[-1*xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
pix[ 0*xstride] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
}
}
pix += ystride;
}
}
| 1threat |
Bootstrap row in col overflow rounded : Bootstrap row in col, overflow. Red area in focus. What is it problem. ?
[Click in show picture][1]
[1]: http://prntscr.com/dtrrai | 0debug |
Where is this image being generated on my webpage? : <p>I can't figure out where the chain link image is coming from on my blogger page (<a href="http://jareds94-wine.blogspot.com" rel="nofollow">http://jareds94-wine.blogspot.com</a>). Using Google Chrome's inspect feature I can see that it has something to do with hentry::before but it's not coming from the CSS so it must be coming form a javascript file right? Any help would be much appreciate as I'm trying to change it to another image.</p>
| 0debug |
static int ws_snd_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int in_size, out_size;
int sample = 128;
int i;
uint8_t *samples = data;
if (!buf_size)
return 0;
out_size = AV_RL16(&buf[0]);
in_size = AV_RL16(&buf[2]);
buf += 4;
if (out_size > *data_size) {
av_log(avctx, AV_LOG_ERROR, "Frame is too large to fit in buffer\n");
return -1;
}
if (in_size > buf_size) {
av_log(avctx, AV_LOG_ERROR, "Frame data is larger than input buffer\n");
return -1;
}
*data_size = out_size;
if (in_size == out_size) {
for (i = 0; i < out_size; i++)
*samples++ = *buf++;
return buf_size;
}
while (out_size > 0) {
int code;
uint8_t count;
code = (*buf) >> 6;
count = (*buf) & 0x3F;
buf++;
switch(code) {
case 0:
for (count++; count > 0; count--) {
code = *buf++;
sample += ws_adpcm_2bit[code & 0x3];
sample = av_clip_uint8(sample);
*samples++ = sample;
sample += ws_adpcm_2bit[(code >> 2) & 0x3];
sample = av_clip_uint8(sample);
*samples++ = sample;
sample += ws_adpcm_2bit[(code >> 4) & 0x3];
sample = av_clip_uint8(sample);
*samples++ = sample;
sample += ws_adpcm_2bit[(code >> 6) & 0x3];
sample = av_clip_uint8(sample);
*samples++ = sample;
out_size -= 4;
}
break;
case 1:
for (count++; count > 0; count--) {
code = *buf++;
sample += ws_adpcm_4bit[code & 0xF];
sample = av_clip_uint8(sample);
*samples++ = sample;
sample += ws_adpcm_4bit[code >> 4];
sample = av_clip_uint8(sample);
*samples++ = sample;
out_size -= 2;
}
break;
case 2:
if (count & 0x20) {
int8_t t;
t = count;
t <<= 3;
sample += t >> 3;
sample = av_clip_uint8(sample);
*samples++ = sample;
out_size--;
} else {
for (count++; count > 0; count--) {
*samples++ = *buf++;
out_size--;
}
sample = buf[-1];
}
break;
default:
for(count++; count > 0; count--) {
*samples++ = sample;
out_size--;
}
}
}
return buf_size;
}
| 1threat |
First part:- Given a sorted array and a target value, return the index : '''
class Solution(object):
def searchInsert(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: int
"""
print target
print nums
for i in nums:
print i
if i==target:
return nums.index(i)
else:
if i>=target:
nums.append('target')-----[1](How to append the target here
before the 'i' element to which
compared)
else:
nums.append('target')
print False
'''
Second Part:- If not, return the index where it would be if it were inserted in order ?
I think I solved the first part but I am struggling to make second part of appending work. Can anyone guide ? | 0debug |
void aux_init_mmio(AUXSlave *aux_slave, MemoryRegion *mmio)
{
assert(!aux_slave->mmio);
aux_slave->mmio = mmio;
}
| 1threat |
static size_t fd_getpagesize(int fd)
{
#ifdef CONFIG_LINUX
struct statfs fs;
int ret;
if (fd != -1) {
do {
ret = fstatfs(fd, &fs);
} while (ret != 0 && errno == EINTR);
if (ret == 0 && fs.f_type == HUGETLBFS_MAGIC) {
return fs.f_bsize;
}
}
#endif
return getpagesize();
}
| 1threat |
How to convert a float into int using round method in ms sql? : <p>I tried with </p>
<p><code> select ROUND(1235.53)<br>
--(It can contain "n" digit of scale)</code></p>
<p>But got error</p>
<p><strong>The round function requires 2 to 3 arguments.
</strong></p>
<p>I am not sure what is the use of other parameters. </p>
| 0debug |
static void virtio_pci_modern_regions_init(VirtIOPCIProxy *proxy)
{
static const MemoryRegionOps common_ops = {
.read = virtio_pci_common_read,
.write = virtio_pci_common_write,
.impl = {
.min_access_size = 1,
.max_access_size = 4,
},
.endianness = DEVICE_LITTLE_ENDIAN,
};
static const MemoryRegionOps isr_ops = {
.read = virtio_pci_isr_read,
.write = virtio_pci_isr_write,
.impl = {
.min_access_size = 1,
.max_access_size = 4,
},
.endianness = DEVICE_LITTLE_ENDIAN,
};
static const MemoryRegionOps device_ops = {
.read = virtio_pci_device_read,
.write = virtio_pci_device_write,
.impl = {
.min_access_size = 1,
.max_access_size = 4,
},
.endianness = DEVICE_LITTLE_ENDIAN,
};
static const MemoryRegionOps notify_ops = {
.read = virtio_pci_notify_read,
.write = virtio_pci_notify_write,
.impl = {
.min_access_size = 1,
.max_access_size = 4,
},
.endianness = DEVICE_LITTLE_ENDIAN,
};
memory_region_init_io(&proxy->common.mr, OBJECT(proxy),
&common_ops,
proxy,
"virtio-pci-common", 0x1000);
proxy->common.offset = 0x0;
proxy->common.type = VIRTIO_PCI_CAP_COMMON_CFG;
memory_region_init_io(&proxy->isr.mr, OBJECT(proxy),
&isr_ops,
proxy,
"virtio-pci-isr", 0x1000);
proxy->isr.offset = 0x1000;
proxy->isr.type = VIRTIO_PCI_CAP_ISR_CFG;
memory_region_init_io(&proxy->device.mr, OBJECT(proxy),
&device_ops,
virtio_bus_get_device(&proxy->bus),
"virtio-pci-device", 0x1000);
proxy->device.offset = 0x2000;
proxy->device.type = VIRTIO_PCI_CAP_DEVICE_CFG;
memory_region_init_io(&proxy->notify.mr, OBJECT(proxy),
¬ify_ops,
virtio_bus_get_device(&proxy->bus),
"virtio-pci-notify",
QEMU_VIRTIO_PCI_QUEUE_MEM_MULT *
VIRTIO_QUEUE_MAX);
proxy->notify.offset = 0x3000;
proxy->notify.type = VIRTIO_PCI_CAP_NOTIFY_CFG;
}
| 1threat |
static av_cold int Faac_encode_init(AVCodecContext *avctx)
{
FaacAudioContext *s = avctx->priv_data;
faacEncConfigurationPtr faac_cfg;
unsigned long samples_input, max_bytes_output;
if (avctx->channels < 1 || avctx->channels > 6)
return -1;
s->faac_handle = faacEncOpen(avctx->sample_rate,
avctx->channels,
&samples_input, &max_bytes_output);
faac_cfg = faacEncGetCurrentConfiguration(s->faac_handle);
if (faac_cfg->version != FAAC_CFG_VERSION) {
av_log(avctx, AV_LOG_ERROR, "wrong libfaac version (compiled for: %d, using %d)\n", FAAC_CFG_VERSION, faac_cfg->version);
faacEncClose(s->faac_handle);
return -1;
}
switch(avctx->profile) {
case FF_PROFILE_AAC_MAIN:
faac_cfg->aacObjectType = MAIN;
break;
case FF_PROFILE_UNKNOWN:
case FF_PROFILE_AAC_LOW:
faac_cfg->aacObjectType = LOW;
break;
case FF_PROFILE_AAC_SSR:
faac_cfg->aacObjectType = SSR;
break;
case FF_PROFILE_AAC_LTP:
faac_cfg->aacObjectType = LTP;
break;
default:
av_log(avctx, AV_LOG_ERROR, "invalid AAC profile\n");
faacEncClose(s->faac_handle);
return -1;
}
faac_cfg->mpegVersion = MPEG4;
faac_cfg->useTns = 0;
faac_cfg->allowMidside = 1;
faac_cfg->bitRate = avctx->bit_rate / avctx->channels;
faac_cfg->bandWidth = avctx->cutoff;
if(avctx->flags & CODEC_FLAG_QSCALE) {
faac_cfg->bitRate = 0;
faac_cfg->quantqual = avctx->global_quality / FF_QP2LAMBDA;
}
faac_cfg->outputFormat = 1;
faac_cfg->inputFormat = FAAC_INPUT_16BIT;
avctx->frame_size = samples_input / avctx->channels;
avctx->coded_frame= avcodec_alloc_frame();
avctx->coded_frame->key_frame= 1;
avctx->extradata_size = 0;
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {
unsigned char *buffer = NULL;
unsigned long decoder_specific_info_size;
if (!faacEncGetDecoderSpecificInfo(s->faac_handle, &buffer,
&decoder_specific_info_size)) {
avctx->extradata = av_malloc(decoder_specific_info_size + FF_INPUT_BUFFER_PADDING_SIZE);
avctx->extradata_size = decoder_specific_info_size;
memcpy(avctx->extradata, buffer, avctx->extradata_size);
faac_cfg->outputFormat = 0;
}
#undef free
free(buffer);
#define free please_use_av_free
}
if (!faacEncSetConfiguration(s->faac_handle, faac_cfg)) {
av_log(avctx, AV_LOG_ERROR, "libfaac doesn't support this output format!\n");
return -1;
}
return 0;
}
| 1threat |
float64 float64_sqrt( float64 a STATUS_PARAM )
{
flag aSign;
int16 aExp, zExp;
bits64 aSig, zSig, doubleZSig;
bits64 rem0, rem1, term0, term1;
aSig = extractFloat64Frac( a );
aExp = extractFloat64Exp( a );
aSign = extractFloat64Sign( a );
if ( aExp == 0x7FF ) {
if ( aSig ) return propagateFloat64NaN( a, a STATUS_VAR );
if ( ! aSign ) return a;
float_raise( float_flag_invalid STATUS_VAR);
return float64_default_nan;
}
if ( aSign ) {
if ( ( aExp | aSig ) == 0 ) return a;
float_raise( float_flag_invalid STATUS_VAR);
return float64_default_nan;
}
if ( aExp == 0 ) {
if ( aSig == 0 ) return 0;
normalizeFloat64Subnormal( aSig, &aExp, &aSig );
}
zExp = ( ( aExp - 0x3FF )>>1 ) + 0x3FE;
aSig |= LIT64( 0x0010000000000000 );
zSig = estimateSqrt32( aExp, aSig>>21 );
aSig <<= 9 - ( aExp & 1 );
zSig = estimateDiv128To64( aSig, 0, zSig<<32 ) + ( zSig<<30 );
if ( ( zSig & 0x1FF ) <= 5 ) {
doubleZSig = zSig<<1;
mul64To128( zSig, zSig, &term0, &term1 );
sub128( aSig, 0, term0, term1, &rem0, &rem1 );
while ( (sbits64) rem0 < 0 ) {
--zSig;
doubleZSig -= 2;
add128( rem0, rem1, zSig>>63, doubleZSig | 1, &rem0, &rem1 );
}
zSig |= ( ( rem0 | rem1 ) != 0 );
}
return roundAndPackFloat64( 0, zExp, zSig STATUS_VAR );
}
| 1threat |
struct GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
int64_t count, Error **errp)
{
GuestFileHandle *gfh = guest_file_handle_find(handle, errp);
GuestFileRead *read_data = NULL;
guchar *buf;
FILE *fh;
size_t read_count;
if (!gfh) {
if (!has_count) {
count = QGA_READ_COUNT_DEFAULT;
} else if (count < 0) {
error_setg(errp, "value '%" PRId64 "' is invalid for argument count",
count);
fh = gfh->fh;
buf = g_malloc0(count+1);
read_count = fread(buf, 1, count, fh);
if (ferror(fh)) {
error_setg_errno(errp, errno, "failed to read file");
slog("guest-file-read failed, handle: %" PRId64, handle);
} else {
buf[read_count] = 0;
read_data = g_new0(GuestFileRead, 1);
read_data->count = read_count;
read_data->eof = feof(fh);
if (read_count) {
read_data->buf_b64 = g_base64_encode(buf, read_count);
gfh->state = RW_STATE_READING;
g_free(buf);
clearerr(fh);
return read_data; | 1threat |
count same value on multiplecoulmns : i have hive table like, i need to count occurance of c
team_name opponent_team match_won
csk mm mm
csk dc csk
mm csk csk
dc csk dc
now i need data like,
team_name total_matches matches_won
csk 4 2
mm 2 1
dc 2 1
can anybody help me on the query part.
| 0debug |
I cant understand this code in Python, can you help me? : <p>I had a code assignment but i could'nt find the answer, so i check it on the net. the code is written in python. The code is absolutely right but i cannot understand it. I am pretty much new to python so plz help me.</p>
<p>Here is the question</p>
<p>Assume s is a string of lower case characters.</p>
<p>Write a program that prints the longest substring of s in which the letters occur in alphabetical order. For example, if s = 'azcbobobegghakl', then your program should print</p>
<p>Longest substring in alphabetical order is: beggh
In the case of ties, print the first substring. For example, if s = 'abcbcd', then your program should print</p>
<p>Longest substring in alphabetical order is: abc</p>
<p>The code is:</p>
<pre><code> # initialise tracker variables
maxLen=0
current=s[0]
longest=s[0]
# step through s indices
for i in range(len(s) - 1):
if s[i + 1] >= s[i]:
current += s[i + 1]
# if current length is bigger update
if len(current) > maxLen:
maxLen = len(current)
longest = current
else:
current=s[i + 1]
i += 1
print ('Longest substring in alphabetical order is: ' + longest)
</code></pre>
| 0debug |
How to print list items as if they're contents of print in python? : <p>words_list = ['who', 'got', '\n', 'inside', 'your', '\n', 'mind', 'baby']</p>
<p>I have this list of words stored as a list element. I wanted to use the elements as contents of the print function. Ex.</p>
<pre><code>print(words_list[0] + words_list[1] + words_list[2]...words_list[n])
</code></pre>
<p>My desired output would be: </p>
<blockquote>
<pre><code>who got
inside your
mind baby
</code></pre>
</blockquote>
| 0debug |
Designing room allocation I want to color box heading red if occupied and green if vacant based on value : Designing room allocation page which contains multiple panel boxes developed in bootstrap.boxes act as an beds.if bed occupied then highlight header as red else green as vacate if clicked on green panel it goes to room allocation page .if clicked on red panel it goes room vacate page so how should i do development any idea using bootstrap and JQuery [enter image description here][1]
[1]: https://i.stack.imgur.com/jBnIz.jpg | 0debug |
Parse error: syntax error, unexpected '[' google-api-php-client-2.0.1-PHP5_4/vendor/react/promise/src/functions.php on line 15 : <p>I am trying to add data on google calendar by PHP.
Parse error: syntax error, unexpected '[' google-api-php-client-2.0.1-PHP5_4/vendor/react/promise/src/functions.php on line 15</p>
| 0debug |
static void string_output_append_range(StringOutputVisitor *sov,
int64_t s, int64_t e)
{
Range *r = g_malloc0(sizeof(*r));
r->begin = s;
r->end = e + 1;
sov->ranges = g_list_insert_sorted_merged(sov->ranges, r, range_compare);
}
| 1threat |
How would I go about generating a number from a range, and making it so that each possibility in the range has a different probability? : <p>I want to figure out how to generate a number from a range, where each item in the range has a different probability of it being generated.</p>
<p>For instance, I want the chances to be:</p>
<pre><code>p=c(.1,.2,.3,.35, .02, .03)
</code></pre>
<p>For a range of 1-6.</p>
<p>I believe I need to use cumsum, but I'm not sure how to go about it.</p>
| 0debug |
tensorflow deeplearning colab : I'm(beginner)working on cat and dog classifier ....
how to rectify these errors
import tflearn
from tflearn.layers.conv import conv_2d,maxpool_2d
convnet=conv_2d(convent,32,5,activation='relu')
convent=max_pool_2d(convent,5)
ImportError
<ipython-input-8-dc6c9fb9359a> in <module>()
1
2 import tflearn
----> 3 from tflearn.layers.conv import conv_2d,maxpool_2d
ImportError: cannot import name 'maxpool_2d'
NameError
<ipython-input-64-4f4aec72da8c> in <module>()
----> 1 convnet=conv_2d(convent,32,5,activation='relu')
2 convent=max_pool_2d(convent,5)
NameError: name 'convent' is not defined
NameError
<ipython-input-4-be31c35783ac> in <module>()
----> 1 convnet = conv_2d(convnet, 64, 5, activation='relu')
2 convent=max_pool_2d(convent,5)
NameError: name 'conv_2d' is not defined | 0debug |
How to run Java Script : In Chrome, I right clicked and select "inspect", and then I went "Console" tab. I wanted to practice JavaScript, so I typed
<script type="text/javascript">
and hit enter, but I got error message
Uncaught Syntax error: Unexpected Token<
Why?
| 0debug |
How to get bundle id in flutter : <p>i was use below method to get app name and packageName but i need Bundle id for iphone users.
i want to share app link.
i done it in android but in iphone i needs bundle id.</p>
<pre><code> Future<Null> _initPackageInfo() async {
final PackageInfo info = await PackageInfo.fromPlatform();
setState(() {
_packageInfo = info;
packageName = info.packageName;
appName = info.appName;
buildNumber = info.buildNumber;
});
}
</code></pre>
| 0debug |
Recursion. Explain the code. Please : Find the number of ways that a given integer x can be expressed as the sum of the nth power of unique, natural numbers.
ex: If x=10, n=2
The only possible case is : 3^2 +1^2
Here is the solution i read some somewhere -
int solve(int x, const vector<int> &powers, int index) {
if(index == 0) {
return (x == 1) ? 1 : 0;
}
// else
if(x == powers[index])
return 1 + solve(x, powers, index - 1);
// else
int res = 0;
res += solve(x - powers[index], powers, index - 1);
res += solve(x, powers, index - 1);
return res;
}
int main() {
int x, n;
cin >> x >> n;
int pow = 1;
vector<int> powers;
for(int a = 2; pow <= x; a++) {
powers.push_back(pow);
pow = power(a, n);
}
cout << solve(x, powers, powers.size() - 1) << endl;
return 0;
}
Here I'm not able to actually visualise it. How to think recursively?
Help please. Please explain the solve function ? | 0debug |
Unexpected block statement surrounding arrow body : <p>I'm using <code>"eslint-config-airbnb": "^6.1.0",</code> to keep my JavaScript clean. </p>
<p>My linter is unhappy with what seems to be legitimate code:</p>
<p><a href="https://i.stack.imgur.com/4cTob.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4cTob.png" alt="enter image description here"></a></p>
<p>It seems like this might be an <a href="https://github.com/eslint/eslint/issues/4353" rel="noreferrer">ongoing issue</a>. Does anyone have any suggestions for an OCD developer on how to address this in the meantime? Perhaps disabling this rule or otherwise?</p>
| 0debug |
Compiling C++ in OSX terminal: Undefined symbols for architecture x86_64 : <p>I'm writing code for a class project and I did it all in Xcode, which worked fine. I was able to compile w/ arguments in Xcode and get output. However, when I try to compile it in terminal, I keep getting this error (I'm also not sure if I'm compiling it correctly):</p>
<pre><code>francis-mbp:CS280-Assignment1 fren$ gcc /Users/fren/Desktop/CS280-Assignment1/main.cpp -o main
/Users/fren/Desktop/CS280-Assignment1/main.cpp:31:32: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
list<string>::iterator iter=lineToPrint.begin();
^
/Users/fren/Desktop/CS280-Assignment1/main.cpp:32:19: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
int charLimit = 60;
^
2 warnings generated.
Undefined symbols for architecture x86_64:
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::compare(char const*) const", referenced from:
_main in main-b9d962.o
"std::__1::locale::has_facet(std::__1::locale::id&) const", referenced from:
std::__1::basic_filebuf<char, std::__1::char_traits<char> >::basic_filebuf() in main-b9d962.o
"std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in main-b9d962.o
std::__1::basic_filebuf<char, std::__1::char_traits<char> >::imbue(std::__1::locale const&) in main-b9d962.o
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in main-b9d962.o
std::__1::basic_filebuf<char, std::__1::char_traits<char> >::basic_filebuf() in main-b9d962.o
"std::__1::ios_base::getloc() const", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in main-b9d962.o
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in main-b9d962.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::erase(unsigned long, unsigned long)", referenced from:
Line::addWord(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in main-b9d962.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(char const*, unsigned long)", referenced from:
Line::addWord(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in main-b9d962.o
Line::printLine(int) in main-b9d962.o
_main in main-b9d962.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(char const*, unsigned long, unsigned long)", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > std::__1::operator+<char, std::__1::char_traits<char>, std::__1::allocator<char> >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const*) in main-b9d962.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(unsigned long, char)", referenced from:
std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) in main-b9d962.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::append(char const*, unsigned long)", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > std::__1::operator+<char, std::__1::char_traits<char>, std::__1::allocator<char> >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const*) in main-b9d962.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::assign(char const*)", referenced from:
Line::addWord(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in main-b9d962.o
_main in main-b9d962.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::push_back(char)", referenced from:
_main in main-b9d962.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
Line::addWord(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in main-b9d962.o
std::__1::list<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::push_back(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in main-b9d962.o
std::__1::list<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::insert(std::__1::__list_const_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void*>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in main-b9d962.o
Line::checkBack() in main-b9d962.o
_main in main-b9d962.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long, unsigned long, std::__1::allocator<char> const&)", referenced from:
Line::addWord(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in main-b9d962.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()", referenced from:
Line::addWord(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in main-b9d962.o
std::__1::list<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::pop_back() in main-b9d962.o
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > std::__1::operator+<char, std::__1::char_traits<char>, std::__1::allocator<char> >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const*) in main-b9d962.o
Line::printLine(int) in main-b9d962.o
std::__1::list<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::pop_front() in main-b9d962.o
std::__1::list<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::push_back(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in main-b9d962.o
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > std::__1::operator+<char, std::__1::char_traits<char>, std::__1::allocator<char> >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const*) in main-b9d962.o
std::__1::list<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::insert(std::__1::__list_const_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void*>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in main-b9d962.o
Line::printLine(int) in main-b9d962.o
Line::popBack(int) in main-b9d962.o
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
francis-mbp:CS280-Assignment1 fren$
</code></pre>
<p>Here's the code for my project (doesn't include main bc of character limit): </p>
<pre><code>#include <iostream>
#include<string>
#include<vector>
#include<sstream>
#include<fstream>
#include<algorithm>
#include<queue>
#include<list>
#include<iterator>
#include<ctype.h>
using namespace std;
/*
Class defining data structure that holds linked list containing words to be output
Contains words on a per-line basis (Empties after each line is printed)
Handles list operations
*/
class Line
{
public:
list<string> lineToPrint;
list<string>::iterator iter=lineToPrint.begin();
int charLimit = 60;
string spaceToInsert;
int totalChars;
int totalSpaces;
int numWords;
int placesForSpaces;
int spacePerPlace;
int extraSpaces;
void addWord (string word);
void reset (void);
void changeLimit (int newLimit);
void printLine (int endOfParagraph);
void calculateSpaces(void);
void newParagraph(void);
void popBack(int type);
string checkBack(void);
};
void Line::addWord(string word) {
cout << "adding word: " << word << endl;
string firstHalfWord;
string secondHalfWord;
int numToTruncate;
int splittingWord = 1;
lineToPrint.push_back(word);
totalChars += word.length();
numWords ++;
calculateSpaces();
if(((totalChars > charLimit) && (numWords >= 1)) || ((totalSpaces < placesForSpaces) && (spacePerPlace == 0))) {
splittingWord = 0;
lineToPrint.pop_back();
numToTruncate = totalChars - (charLimit - placesForSpaces - 1);
if(numToTruncate > word.length()) {
cout << numToTruncate << " " << word.length();
cout << "error" << endl;
} else {
secondHalfWord = word.substr(word.length() - numToTruncate);
firstHalfWord = word.erase(word.length() - numToTruncate) + "-";
}
lineToPrint.push_back(firstHalfWord);
totalChars -= (word.length() + secondHalfWord.length());
totalChars += firstHalfWord.length();
calculateSpaces();
}
if((spacePerPlace <= 2 && extraSpaces<= placesForSpaces)||(spacePerPlace == 3 && extraSpaces == 0)) {
if(spacePerPlace == 1){
spaceToInsert = " ";
} else if (spacePerPlace == 2) {
spaceToInsert = " ";
} else if (spacePerPlace == 3) {
spaceToInsert = " ";
}
iter++;
for(int j = placesForSpaces; j > 0; j--) {
//cout << "inserting " << spacePerPlace << " spaces!" << endl;
lineToPrint.insert(iter, spaceToInsert);
totalSpaces -= spacePerPlace;
if(extraSpaces != 0){
lineToPrint.insert(iter, " ");
totalSpaces --;
extraSpaces --;
}
iter++;
}
printLine(1);
}
if(splittingWord == 0 && secondHalfWord.length() > charLimit){
iter = lineToPrint.begin();
addWord(secondHalfWord);
} else if (splittingWord == 0 && secondHalfWord.length() <= charLimit) {
lineToPrint.push_back(secondHalfWord);
totalChars += secondHalfWord.length();
numWords ++;
}
iter = lineToPrint.begin();
splittingWord = 1;
}
//Resets the list and variables for calculating spaces to insert
void Line::reset(void) {
lineToPrint.clear();
totalChars = 0; totalSpaces = 0; numWords = 0; placesForSpaces = 0;
}
//Changes the variable limit used in space insert calculations
void Line::changeLimit(int newLimit) {
//cout << "Changing Limit to: " << newLimit << endl;
charLimit = newLimit;
}
//Makes calculations for variables used in space insertion calculations
void Line::calculateSpaces(void) {
//cout << "calculating spaces..." << endl;
totalSpaces = charLimit - totalChars;
if (numWords == 1 && totalChars >= charLimit) {
placesForSpaces = 0;
spacePerPlace = 0;
} else {
if(numWords == 1){
placesForSpaces = 1;
} else {
placesForSpaces = numWords - 1;
}
spacePerPlace = totalSpaces/placesForSpaces;
extraSpaces = totalSpaces%placesForSpaces;
}
//cout << "totalChars: "<< totalChars <<" totalSpaces: "<< totalSpaces << " numWOrds: " << numWords << " placesFOrSpaces: " << placesForSpaces << " spacePerPlace: " << spacePerPlace << " extraSpaces: " << extraSpaces << endl;
}
//Prints the list (with spaces included)
//Takes int argument; 0 = end of paragraph, 1 = not end of paragraph
void Line::printLine(int endOfParagraph) {
//p1cout << "character limit: " << charLimit << endl;
if(endOfParagraph == 1) {
cout << "printing line NOT end of paragraph" << endl;
for(list<string>::iterator it = lineToPrint.begin(); it != lineToPrint.end(); it++){
cout << *it;
lineToPrint.pop_front();
}
} else if (endOfParagraph == 0) {
iter++;
cout << "printing line end of paragraph" << endl;
if (numWords != 1) {
for(int i = placesForSpaces; i >0; i--) {
lineToPrint.insert(iter, " ");
iter++;
}
}
iter = lineToPrint.begin();
for(list<string>::iterator it = lineToPrint.begin(); it != lineToPrint.end(); it++){
cout << *it;
lineToPrint.pop_front();
}
}
cout << endl;
totalChars = 0; totalSpaces = 0; numWords = 0; placesForSpaces = 0;
}
//Prints a new line to separate paragraphs
void Line::newParagraph(void){
cout << endl;
}
//Returns the string held in the back of the list
string Line::checkBack(void) {
return lineToPrint.back();
}
//Removes a string off the back of the list
void Line::popBack(int type) {
if(type == 1){
string wordToPop = checkBack();
cout << "word to pop : " << wordToPop << endl;
int length = wordToPop.length();
cout << "length of w2pop : " << length <<endl;
totalChars -= length;
}
//cout << "popping from back: " << checkBack();
lineToPrint.pop_back();
numWords --;
}
</code></pre>
<p>Thanks to any help</p>
| 0debug |
static int h263p_decode_umotion(MpegEncContext * s, int pred)
{
int code = 0, sign;
if (get_bits1(&s->gb))
return pred;
code = 2 + get_bits1(&s->gb);
while (get_bits1(&s->gb))
{
code <<= 1;
code += get_bits1(&s->gb);
if (code >= 32768) {
avpriv_request_sample(s->avctx, "Huge DMV");
return AVERROR_INVALIDDATA;
}
}
sign = code & 1;
code >>= 1;
code = (sign) ? (pred - code) : (pred + code);
ff_tlog(s->avctx,"H.263+ UMV Motion = %d\n", code);
return code;
}
| 1threat |
An efficient algorithm to cluster a list of tuples : I would like to develop an efficient algorithm which will cluster a list of tuples, as presented below:
public class Tuple<T, R> {
private final T left;
private final R right;
public Tuple(T left, R right) {
this.left = left;
this.right = right;
}
public T getLeft() {
return left;
}
public R getRight() {
return right;
}
}
And return them grouped, based on equality of 'left' fields or 'right' fields. An output can be a list of groups as specified below:
public class Group<L, R> extends Tuple<List<L>, List<R>> {
public Group(List<L> left, List<R> right) {
super(left, right);
}
}
How can I do this efficiently? Is there a way to parallelise such algorithm using some intermediate concurrent data structures?
Example input: Tuple(4,C),Tuple(1,A),Tuple(2,B),Tuple(3,B),Tuple(3,A), Tuple(5,C), Tuple(6,D)
Expected output: Group((1,2,3),(A,B)), Group((4,5),(C)), Group((6),(D))
Many thanks for help in advance. Any pseudo code will be appreciated. | 0debug |
static av_always_inline int vmnc_get_pixel(const uint8_t *buf, int bpp, int be)
{
switch (bpp * 2 + be) {
case 2:
case 3:
return *buf;
case 4:
return AV_RL16(buf);
case 5:
return AV_RB16(buf);
case 8:
return AV_RL32(buf);
case 9:
return AV_RB32(buf);
default:
return 0;
}
}
| 1threat |
Take a list of numbers and return the average without sum() : I want to getting average of list without using sum()
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
sample_list = [2, 10, 3, 5]
sample_listSum =[sample_list[0]+ sample_list[1]+ sample_list[2]+ sample_list[3]]
sample_listLength = len(sample_list)
sample_listAvrage = sample_listSum / sample_listLength
print("This is result of list", sample_listAvrage)
<!-- end snippet -->
but it's not working, may I ask you help me about it?
| 0debug |
static int pmp_packet(AVFormatContext *s, AVPacket *pkt)
{
PMPContext *pmp = s->priv_data;
AVIOContext *pb = s->pb;
int ret = 0;
int i;
if (url_feof(pb))
return AVERROR_EOF;
if (pmp->cur_stream == 0) {
int num_packets;
pmp->audio_packets = avio_r8(pb);
num_packets = (pmp->num_streams - 1) * pmp->audio_packets + 1;
avio_skip(pb, 8);
pmp->current_packet = 0;
av_fast_malloc(&pmp->packet_sizes,
&pmp->packet_sizes_alloc,
num_packets * sizeof(*pmp->packet_sizes));
if (!pmp->packet_sizes_alloc) {
av_log(s, AV_LOG_ERROR, "Cannot (re)allocate packet buffer\n");
return AVERROR(ENOMEM);
for (i = 0; i < num_packets; i++)
pmp->packet_sizes[i] = avio_rl32(pb);
ret = av_get_packet(pb, pkt, pmp->packet_sizes[pmp->current_packet]);
if (ret >= 0) {
ret = 0;
if (pmp->cur_stream == 0)
pkt->dts = s->streams[0]->cur_dts++;
pkt->stream_index = pmp->cur_stream;
if (pmp->current_packet % pmp->audio_packets == 0)
pmp->cur_stream = (pmp->cur_stream + 1) % pmp->num_streams;
pmp->current_packet++;
return ret;
| 1threat |
run a C script at startup [Red Pitaya] : I have a #C script that needs to run when I turn on my machine (Red Pitaya). the script is executable with a run.sh file, both of them are located in a directory under /root. the script is working perfectly when run manually. I tried to follow the solution presented here :
https://askubuntu.com/questions/9853/how-can-i-make-rc-local-run-on-startup
without success.
any suggestions? Thank you.
| 0debug |
"The visual Studio component cache is out of date, please restart Visual Studio." : <p>I'm on windows 7, using Atmel studio 7.0. When I opened up my project in Atmel Studio, it failed to load and gave this error:</p>
<pre><code>The Visual Studio component cache is out of date please restart visual studio.
</code></pre>
<p>When I closed and reopened Atmel Studio, the same error continued. I also tried right clicking on my project, and selecting "Reload project" but then I got this error:</p>
<pre><code>Value cannot be null. Parameter name: url
</code></pre>
<p>How can I open up my project?</p>
| 0debug |
I can't fill into []map[string]interface{} : I want to prepare conditions data for gorm. But datas don't fill into variable.
email := c.Query("email")
count := c.Query("count")
filters := []map[string]interface{}{
{"email": email},
{"count": count},
}
I can take datas at c.Query() lines.
How can I do? | 0debug |
static ssize_t v9fs_synth_lgetxattr(FsContext *ctx, V9fsPath *path,
const char *name, void *value, size_t size)
{
errno = ENOTSUP;
return -1;
}
| 1threat |
How to download previous version of tensorflow? : <p>For some reason, I want to use some previous version of tensorflow('tensorflow-**-.whl', not source code on github) and where can I download the previous version and how can I know the corresponding <code>cuda version</code> that is compatible.</p>
| 0debug |
Gradle : DSL element 'useProguard' is obsolete and will be removed soon : <p>Since the 3.5 update of Android Studio, I have this warning when building my app :</p>
<blockquote>
<p>DSL element 'useProguard' is obsolete and will be removed soon. Use
'android.enableR8' in gradle.properties to switch between R8 and
Proguard..</p>
</blockquote>
| 0debug |
int spapr_vio_check_tces(VIOsPAPRDevice *dev, target_ulong ioba,
target_ulong len, enum VIOsPAPR_TCEAccess access)
{
int start, end, i;
start = ioba >> SPAPR_VIO_TCE_PAGE_SHIFT;
end = (ioba + len - 1) >> SPAPR_VIO_TCE_PAGE_SHIFT;
for (i = start; i <= end; i++) {
if ((dev->rtce_table[i].tce & access) != access) {
#ifdef DEBUG_TCE
fprintf(stderr, "FAIL on %d\n", i);
#endif
return -1;
}
}
return 0;
}
| 1threat |
static int alsa_init_in (HWVoiceIn *hw, struct audsettings *as)
{
ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw;
struct alsa_params_req req;
struct alsa_params_obt obt;
snd_pcm_t *handle;
struct audsettings obt_as;
req.fmt = aud_to_alsafmt (as->fmt, as->endianness);
req.freq = as->freq;
req.nchannels = as->nchannels;
req.period_size = conf.period_size_in;
req.buffer_size = conf.buffer_size_in;
req.size_in_usec = conf.size_in_usec_in;
req.override_mask =
(conf.period_size_in_overridden ? 1 : 0) |
(conf.buffer_size_in_overridden ? 2 : 0);
if (alsa_open (1, &req, &obt, &handle)) {
return -1;
}
obt_as.freq = obt.freq;
obt_as.nchannels = obt.nchannels;
obt_as.fmt = obt.fmt;
obt_as.endianness = obt.endianness;
audio_pcm_init_info (&hw->info, &obt_as);
hw->samples = obt.samples;
alsa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);
if (!alsa->pcm_buf) {
dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\n",
hw->samples, 1 << hw->info.shift);
alsa_anal_close1 (&handle);
return -1;
}
alsa->handle = handle;
return 0;
}
| 1threat |
Date.toISOString() but local time instead of UTC : <p>Let's say we have this datetime:</p>
<pre><code>var d = new Date("Sat Jul 21 2018 14:00:00 GMT+0200");
</code></pre>
<p>Exporting it as a string (<code>console.log(d)</code>) gives inconsistent results among browsers:</p>
<ul>
<li><p><code>Sat Jul 21 2018 14:00:00 GMT+0200 (Paris, Madrid (heure d’été))</code> with Chrome</p></li>
<li><p><code>Sat Jul 21 14:00:00 UTC+0200 2018</code> with Internet Explorer, etc.</p></li>
</ul>
<p>so we can't send datetime to a server with an <strong>unconsistent format</strong>.</p>
<p>The natural idea then would be to ask for an ISO8601 datetime, and use <code>d.toISOString();</code> but it gives the UTC datetime: <code>2018-07-21T12:00:00.000Z</code> whereas I would like the local-timezone time instead:</p>
<pre><code>2018-07-21T14:00:00+0200
or
2018-07-21T14:00:00
</code></pre>
<p><strong>How to get this (without relying on a third party dependency like momentjs)?</strong></p>
<p>I tried this, which <em>seems to work</em>, but <strong>isn't there a more natural way to do it?</strong></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var pad = function(i) { return (i < 10) ? '0' + i : i; };
var d = new Date("Sat Jul 21 2018 14:00:00 GMT+0200");
Y = d.getFullYear();
m = d.getMonth() + 1;
D = d.getDate();
H = d.getHours();
M = d.getMinutes();
S = d.getSeconds();
s = Y + '-' + pad(m) + '-' + pad(D) + 'T' + pad(H) + ':' + pad(M) + ':' + pad(S);
console.log(s);</code></pre>
</div>
</div>
</p>
| 0debug |
How to script Gradle in order to publish shadowjar into Artifactory : <p>I am using shadowJar in my java project.
I would like to push the outcome into artifactory.</p>
<p>My gradle script look like this, I am not sure how to connect the dots:</p>
<pre><code>shadowJar {
baseName = 'com.mycompany.myapp'
manifest {
attributes 'Main-Class': 'myapp.starter'
}
}
]
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'com.github.johnrengelman.shadow'
// rep for the project
repositories {
mavenCentral()
maven {
url 'http://repo.company:8081/artifactory/libs-release'
credentials {
username = "${repo_user}"
password = "${repo_password}"
}
}
maven {
url 'http://repo.company:8081/artifactory/libs-snapshot'
credentials {
username = "${repo_user}"
password = "${repo_password}"
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourceJar {
classifier "sources"
}
}
}
}
</code></pre>
<p>How do I code gradle to take the shadowjar file?</p>
<p>thanks,
ray.</p>
| 0debug |
SQL: generate N random positive integers adding up to a provided total M : This problem keeps popping up in different programming languages:
- [R](http://stackoverflow.com/questions/24845909/generate-n-random-integers-that-sum-to-m-in-r)
- [Java](http://stackoverflow.com/questions/10021796/how-to-generate-a-sequence-of-n-random-positive-integers-which-add-up-to-some-va)
- [Python](http://stackoverflow.com/questions/40231094/generate-n-positive-integers-within-a-range-adding-up-to-a-total-in-python)
This question is about a "vanilla" SQL solution restricted to a single SELECT statement with optional common table expressions [CTEs]. The input is a 1x2 table call `inputs`: a single row with columns `M` and `N` of `int` type. The result should be an Nx1 table with a single column `i` for the integers that add us to `M`. | 0debug |
static void *acpi_set_bsel(PCIBus *bus, void *opaque)
{
unsigned *bsel_alloc = opaque;
unsigned *bus_bsel;
if (qbus_is_hotpluggable(BUS(bus))) {
bus_bsel = g_malloc(sizeof *bus_bsel);
*bus_bsel = (*bsel_alloc)++;
object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
bus_bsel, NULL);
}
return bsel_alloc;
}
| 1threat |
What is the purpose of the c flag in the "conda install" command : <p>I'm learning to setup python environments using conda, and I noticed that on the anaconda cloud website they recommend installing packages using the sintax </p>
<pre><code>conda install -c package
</code></pre>
<p>However on the conda documentation they use the same command without the c flag.</p>
<p>Could anyone explain to me what is the purpose of the c flag and when should it be used?</p>
| 0debug |
Segmentation fault in list<Object*> iterator : <p>I'm learning C++, and now I have problems with iterators. This is my case: I have this code here.</p>
<pre><code>// std::list<Dragon*> dragons = cave.getDragons();
for (std::list<Dragon*>::iterator it = cave.getDragons().begin(); it != cave.getDragons().end(); it++){
os << std::endl << (*it)->getName();
}
</code></pre>
<p>It returns a Segmentation fault. This is my list and my getDragons() method:</p>
<pre><code>std::list<Dragon*> dragons;
std::list<Dragon*> getDragons() const {return dragons;}
</code></pre>
<p>And my question is... Why do I have a Segmentation fault doing that like this, but if I use dragons variable, which is commented, don't? Thanks! </p>
| 0debug |
static int vc1_decode_p_mb(VC1Context *v, DCTELEM block[6][64])
{
MpegEncContext *s = &v->s;
GetBitContext *gb = &s->gb;
int i, j;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
int cbp;
int mqdiff, mquant;
int ttmb = v->ttfrm;
int status;
static const int size_table[6] = { 0, 2, 3, 4, 5, 8 },
offset_table[6] = { 0, 1, 3, 7, 15, 31 };
int mb_has_coeffs = 1;
int dmv_x, dmv_y;
int index, index1;
int val, sign;
int first_block = 1;
int dst_idx, off;
int skipped, fourmv;
mquant = v->pq;
if (v->mv_type_is_raw)
fourmv = get_bits1(gb);
else
fourmv = v->mv_type_mb_plane[mb_pos];
if (v->skip_is_raw)
skipped = get_bits1(gb);
else
skipped = v->s.mbskip_table[mb_pos];
s->dsp.clear_blocks(s->block[0]);
if (!fourmv)
{
if (!skipped)
{
GET_MVDATA(dmv_x, dmv_y);
s->current_picture.mb_type[mb_pos] = s->mb_intra ? MB_TYPE_INTRA : MB_TYPE_16x16;
vc1_pred_mv(s, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0]);
if (s->mb_intra && !mb_has_coeffs)
{
GET_MQUANT();
s->ac_pred = get_bits(gb, 1);
cbp = 0;
}
else if (mb_has_coeffs)
{
if (s->mb_intra) s->ac_pred = get_bits(gb, 1);
cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
GET_MQUANT();
}
else
{
mquant = v->pq;
cbp = 0;
}
s->current_picture.qscale_table[mb_pos] = mquant;
if (!v->ttmbf && !s->mb_intra && mb_has_coeffs)
ttmb = get_vlc2(gb, vc1_ttmb_vlc[v->tt_index].table,
VC1_TTMB_VLC_BITS, 2);
if(!s->mb_intra) vc1_mc_1mv(v);
dst_idx = 0;
for (i=0; i<6; i++)
{
s->dc_val[0][s->block_index[i]] = 0;
dst_idx += i >> 2;
val = ((cbp >> (5 - i)) & 1);
off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
v->mb_type[0][s->block_index[i]] = s->mb_intra;
if(s->mb_intra) {
v->a_avail = v->c_avail = 0;
if(i == 2 || i == 3 || s->mb_y)
v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
if(i == 1 || i == 3 || s->mb_x)
v->c_avail = v->mb_type[0][s->block_index[i] - 1];
vc1_decode_intra_block(v, block[i], i, val, mquant, (i&4)?v->codingset2:v->codingset);
vc1_inv_trans(block[i], 8, 8);
for(j = 0; j < 64; j++) block[i][j] += 128;
s->dsp.put_pixels_clamped(block[i], s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2));
if(v->pq >= 9 && v->overlap) {
if(v->a_avail)
s->dsp.h263_v_loop_filter(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2), s->y_dc_scale);
if(v->c_avail)
s->dsp.h263_h_loop_filter(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2), s->y_dc_scale);
}
} else if(val) {
vc1_decode_p_block(v, block[i], i, mquant, ttmb, first_block);
if(!v->ttmbf && ttmb < 8) ttmb = -1;
first_block = 0;
s->dsp.add_pixels_clamped(block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize);
}
}
}
else
{
s->mb_intra = 0;
for(i = 0; i < 6; i++) v->mb_type[0][s->block_index[i]] = 0;
s->current_picture.mb_type[mb_pos] = MB_TYPE_SKIP;
s->current_picture.qscale_table[mb_pos] = 0;
vc1_pred_mv(s, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0]);
vc1_mc_1mv(v);
return 0;
}
}
else
{
if (!skipped )
{
int intra_count = 0, coded_inter = 0;
int is_intra[6], is_coded[6];
cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
for (i=0; i<6; i++)
{
val = ((cbp >> (5 - i)) & 1);
s->dc_val[0][s->block_index[i]] = 0;
s->mb_intra = 0;
if(i < 4) {
dmv_x = dmv_y = 0;
s->mb_intra = 0;
mb_has_coeffs = 0;
if(val) {
GET_MVDATA(dmv_x, dmv_y);
}
vc1_pred_mv(s, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0]);
if(!s->mb_intra) vc1_mc_4mv_luma(v, i);
intra_count += s->mb_intra;
is_intra[i] = s->mb_intra;
is_coded[i] = mb_has_coeffs;
}
if(i&4){
is_intra[i] = (intra_count >= 3);
is_coded[i] = val;
}
if(i == 4) vc1_mc_4mv_chroma(v);
v->mb_type[0][s->block_index[i]] = is_intra[i];
if(!coded_inter) coded_inter = !is_intra[i] & is_coded[i];
}
dst_idx = 0;
GET_MQUANT();
s->current_picture.qscale_table[mb_pos] = mquant;
{
int intrapred = 0;
for(i=0; i<6; i++)
if(is_intra[i]) {
if(v->mb_type[0][s->block_index[i] - s->block_wrap[i]] || v->mb_type[0][s->block_index[i] - 1]) {
intrapred = 1;
break;
}
}
if(intrapred)s->ac_pred = get_bits(gb, 1);
else s->ac_pred = 0;
}
if (!v->ttmbf && coded_inter)
ttmb = get_vlc2(gb, vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 12);
for (i=0; i<6; i++)
{
dst_idx += i >> 2;
off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
s->mb_intra = is_intra[i];
if (is_intra[i]) {
v->a_avail = v->c_avail = 0;
if(i == 2 || i == 3 || s->mb_y)
v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
if(i == 1 || i == 3 || s->mb_x)
v->c_avail = v->mb_type[0][s->block_index[i] - 1];
vc1_decode_intra_block(v, s->block[i], i, is_coded[i], mquant, (i&4)?v->codingset2:v->codingset);
vc1_inv_trans(block[i], 8, 8);
for(j = 0; j < 64; j++) block[i][j] += 128;
s->dsp.put_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize);
if(v->pq >= 9 && v->overlap) {
if(v->a_avail)
s->dsp.h263_v_loop_filter(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2), s->y_dc_scale);
if(v->c_avail)
s->dsp.h263_h_loop_filter(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2), s->y_dc_scale);
}
} else if(is_coded[i]) {
status = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block);
if(!v->ttmbf && ttmb < 8) ttmb = -1;
first_block = 0;
s->dsp.add_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize);
}
}
return status;
}
else MB
{
s->mb_intra = 0;
for (i=0; i<6; i++) v->mb_type[0][s->block_index[i]] = 0;
for (i=0; i<4; i++)
{
vc1_pred_mv(s, i, 0, 0, 0, v->range_x, v->range_y, v->mb_type[0]);
vc1_mc_4mv_luma(v, i);
}
vc1_mc_4mv_chroma(v);
s->current_picture.qscale_table[mb_pos] = 0;
return 0;
}
}
return -1;
}
| 1threat |
void esp_init(target_phys_addr_t espaddr, int it_shift,
espdma_memory_read_write dma_memory_read,
espdma_memory_read_write dma_memory_write,
void *dma_opaque, qemu_irq irq, qemu_irq *reset)
{
DeviceState *dev;
SysBusDevice *s;
ESPState *esp;
dev = qdev_create(NULL, "esp");
esp = DO_UPCAST(ESPState, busdev.qdev, dev);
esp->dma_memory_read = dma_memory_read;
esp->dma_memory_write = dma_memory_write;
esp->dma_opaque = dma_opaque;
esp->it_shift = it_shift;
qdev_init(dev);
s = sysbus_from_qdev(dev);
sysbus_connect_irq(s, 0, irq);
sysbus_mmio_map(s, 0, espaddr);
*reset = qdev_get_gpio_in(dev, 0);
}
| 1threat |
How to resolve invalid syntax issue? : <p>I have this issue and can't seem to find a resolution to it. It keeps showing me on line 15 invalid syntax. What's wrong with it?</p>
<pre><code>print("Shirt Order")
print()
colour = input("What colour of the shirt? Blue or White: ")
if colour.lower() == "blue":
size = input("What size of the shirt? (S/M/L): ")
if size.lower() == "l":
print("Sorry, we do not have that size available.")
elif size.lower() == "m":
print("You have selected a blue shirt in size medium, that will be $9 please.")
elif size.lower() == "s":
print("You have selected a blue shirt in size small, that will be $5.50 please.")
else:
print("Sorry, your order was not recognized, please try again.")
elif colour.lower() == "white":
size = input("What size of the shirt? (S/M/L): ")
if size.lower() == "l":
print("You have selected a white shirt in size large, that will be $10 please.")
elif size.lower() == "m":
print("You have selected a white shirt in size medium, that will be $9 please.")
elif size.lower() == "s":
print("Sorry, we do not have that size available.")
else:
print("Sorry, your order was not recognized, please try again.")
</code></pre>
| 0debug |
Bootstrao Carousel not working : the bootstrap carousel in bootstrap 4.0 is not working, i have checked everything and written the code 100% the same:
<div id="carouselExampleControls" class="carousel slide" data-
ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="images/pic03.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="images/pic01.jpg" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="images/pic02.jpg" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls"
role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls"
role="button"
data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div> | 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.