problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Why do I get "Error: Could not find or load main class" for any java code? : <p>Any java code I compile and try to execute from CMD line results in the error: <br>
<strong>Error: Could not find or load main class</strong></p>
<p>I have tried setting environment variables:<br>
PATH=C:\Program Files\Java\jdk1.8.0_202\bin<br>
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_202</p>
<p>and with and with out:<br>
CLASSPATH=C:\Program Files\Java\jdk1.8.0_202\jre\lib or<br>
CLASSPATH=C:\Program Files\Java\jdk1.8.0_202\jre\lib\rt.jar or<br>
CLASSPATH=(directory of code)</p>
<p>The following is an example of a simple test prog that will not run:</p>
<pre><code>/**
* Experiment with println() and print()
*/
public class HelloGoodbye
{
public static void main(String[] args)
{
System.out.println("My First Hello!");
System.out.println("Hello again!");
System.out.print("Hello finally!");
System.out.print("Goodbye!");
}
}
</code></pre>
<p>This produces:
Error: Could not find or load main class</p>
| 0debug
|
how to convert non breaking space to in php : <p>here is my string</p>
<pre><code>hello
world
hello world
</code></pre>
<p>how can I convert this string to </p>
<pre><code>hello
&nbsp;
world
&nbsp;
&nbsp;
hello world
</code></pre>
<p>in php. Any one help please... </p>
| 0debug
|
static int h261_decode_mb(H261Context *h,
DCTELEM block[6][64])
{
MpegEncContext * const s = &h->s;
int i, cbp, xy, old_mtype;
cbp = 63;
do{
h->mba_diff = get_vlc2(&s->gb, h261_mba_vlc.table, H261_MBA_VLC_BITS, 2)+1;
}
while( h->mba_diff == MAX_MBA + 1 );
if ( h->mba_diff < 0 )
return -1;
h->current_mba += h->mba_diff;
if ( h->current_mba > MAX_MBA )
return -1;
s->mb_x= ((h->gob_number-1) % 2) * 11 + ((h->current_mba-1) % 11);
s->mb_y= ((h->gob_number-1) / 2) * 3 + ((h->current_mba-1) / 11);
xy = s->mb_x + s->mb_y * s->mb_stride;
ff_init_block_index(s);
ff_update_block_index(s);
s->dsp.clear_blocks(s->block[0]);
old_mtype = h->mtype;
h->mtype = get_vlc2(&s->gb, h261_mtype_vlc.table, H261_MTYPE_VLC_BITS, 2);
h->mtype = h261_mtype_map[h->mtype];
if (IS_FIL (h->mtype))
h->loop_filter = 1;
if ( IS_QUANT ( h->mtype ) ){
ff_set_qscale(s, get_bits(&s->gb, 5));
}
s->mb_intra = IS_INTRA4x4(h->mtype);
if ( IS_16X16 ( h->mtype ) ){
if ( ( h->current_mba == 1 ) || ( h->current_mba == 12 ) || ( h->current_mba == 23 ) ||
( h->mba_diff != 1) || ( !IS_16X16 ( old_mtype ) ))
{
h->current_mv_x = 0;
h->current_mv_y = 0;
}
h->current_mv_x= decode_mv_component(&s->gb, h->current_mv_x);
h->current_mv_y= decode_mv_component(&s->gb, h->current_mv_y);
}
if ( HAS_CBP( h->mtype ) ){
cbp = get_vlc2(&s->gb, h261_cbp_vlc.table, H261_CBP_VLC_BITS, 2) + 1;
}
if(s->mb_intra){
s->current_picture.mb_type[xy]= MB_TYPE_INTRA;
goto intra;
}
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0;
if(IS_16X16 ( h->mtype )){
s->mv[0][0][0] = h->current_mv_x * 2;
s->mv[0][0][1] = h->current_mv_y * 2;
}
else{
h->current_mv_x = s->mv[0][0][0] = 0;
h->current_mv_x = s->mv[0][0][1] = 0;
}
intra:
if(s->mb_intra || HAS_CBP(h->mtype)){
for (i = 0; i < 6; i++) {
if (h261_decode_block(h, block[i], i, cbp&32) < 0){
return -1;
}
cbp+=cbp;
}
}
{
int v= show_bits(&s->gb, 15);
if(get_bits_count(&s->gb) + 15 > s->gb.size_in_bits){
v>>= get_bits_count(&s->gb) + 15 - s->gb.size_in_bits;
}
if(v==0){
return SLICE_END;
}
}
return SLICE_OK;
}
| 1threat
|
static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
int64_t pos)
{
BDRVQcow2State *s = bs->opaque;
int64_t total_sectors = bs->total_sectors;
bool zero_beyond_eof = bs->zero_beyond_eof;
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_SAVE);
bs->zero_beyond_eof = false;
ret = bdrv_pwritev(bs, qcow2_vm_state_offset(s) + pos, qiov);
bs->zero_beyond_eof = zero_beyond_eof;
bs->total_sectors = total_sectors;
return ret;
}
| 1threat
|
How i get the value of "ReferenceNumber" from data jason object? following are my object : Following are my code how i can accesses my reference no key
ho to get it
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
{
"errors": [],
"data": [
[
{
"$": {
"Type": "Shipment Confirmation Advice",
"xmlns": "urn:microsoft-dynamics-nav/xmlports/x50065"
},
"ReceiptAuthorization": [
{
"DepositorCode": "A400",
"ReferenceNumber": "00-001",
"ShipmentDate": "12/07/18",
"ExpArrivalDate": null,
"ShipFrom": {
"ShipFromCode": null,
"ShipFromName": "AAWS",
"ShipFromName2": null,
"ShipFromAddr1": null,
"ShipFromAddr2": null,
"ShipFromCity": null,
"ShipFromState": null,
"ShipFromZip": null,
"ShipFromCountry": null
},
"Carrier": {
"CarrierCode": "FDXE",
"CarrierName": "Federal Express Corporation"
},
"Container": null,
"ProNumber": null,
"Warehouse": "MAIN",
"HdrUser1": null,
"HdrUser2": null,
"HdrUser3": null,
"HdrUser4": null,
"HdrUser5": "PURCHASE ORDER",
"ShipFromRef": null,
"TotalQtyDeclared": "2,000",
"Temperature": "0",
"MasterDocumentNumber": null,
"RectLine": [
{
"ItemNumber": "AFRIB-30",
"DeclaredQty": "1,000",
"UOM": "EACH",
"ItemDesc1": "AFRICAN BIG BOOK SOFT COVER",
"ItemDesc2": null,
"SubPart1Number": null,
"SubPart2Number": null,
"LineReference": null,
"LineUser1": null,
"LineUser2": null,
"LineUser3": null,
"LineUser4": null,
"LineUser5": null,
"Pack1": "20",
"Pack2": null,
"UnitWeight": "0.85",
"TareWeight": null,
"Length": null,
"Width": null,
"Height": null,
"Volume": null,
"Category": "PRINTED MATERIALS",
"Lot": null,
"CodeDate": null,
"GrsWeight": "850",
"NetWeight": null,
"DetailRef": null,
"SubLot": null,
"TagID": null,
"Attribute1": null,
"Attribute2": null,
"Attribute3": null,
"Attribute4": null,
"Attribute5": null,
"Attribute6": null
},
{
"ItemNumber": "ARMEB-30",
"DeclaredQty": "1,000",
"UOM": "EACH",
"ItemDesc1": "ARMENIAN BIG BOOK",
"ItemDesc2": null,
"SubPart1Number": null,
"SubPart2Number": null,
"LineReference": null,
"LineUser1": null,
"LineUser2": null,
"LineUser3": null,
"LineUser4": null,
"LineUser5": null,
"Pack1": "20",
"Pack2": null,
"UnitWeight": "0.85",
"TareWeight": null,
"Length": null,
"Width": null,
"Height": null,
"Volume": null,
"Category": "PRINTED MATERIALS",
"Lot": null,
"CodeDate": null,
"GrsWeight": "850",
"NetWeight": null,
"DetailRef": null,
"SubLot": null,
"TagID": null,
"Attribute1": null,
"Attribute2": null,
"Attribute3": null,
"Attribute4": null,
"Attribute5": null,
"Attribute6": null
}
]
},
{
"DepositorCode": "A400",
"ReferenceNumber": "PO000258",
"ShipmentDate": "07/12/18",
"ExpArrivalDate": null,
"ShipFrom": {
"ShipFromCode": null,
"ShipFromName": "Pending RFQ",
"ShipFromName2": null,
"ShipFromAddr1": null,
"ShipFromAddr2": null,
"ShipFromCity": null,
"ShipFromState": null,
"ShipFromZip": null,
"ShipFromCountry": null
},
"Carrier": {
"CarrierCode": null,
"CarrierName": null
},
"Container": null,
"ProNumber": null,
"Warehouse": "MAIN",
"HdrUser1": null,
"HdrUser2": null,
"HdrUser3": null,
"HdrUser4": null,
"HdrUser5": "PURCHASE ORDER",
"ShipFromRef": null,
"TotalQtyDeclared": "1",
"Temperature": "0",
"MasterDocumentNumber": null,
"RectLine": {
"ItemNumber": "B-1",
"DeclaredQty": "1",
"UOM": "EACH",
"ItemDesc1": "Big Book Hardcover 4th Edition",
"ItemDesc2": null,
"SubPart1Number": null,
"SubPart2Number": null,
"LineReference": "1",
"LineUser1": null,
"LineUser2": null,
"LineUser3": null,
"LineUser4": null,
"LineUser5": null,
"Pack1": "20",
"Pack2": null,
"UnitWeight": "1.6",
"TareWeight": null,
"Length": null,
"Width": null,
"Height": null,
"Volume": null,
"Category": "PRINTED MATERIALS",
"Lot": null,
"CodeDate": null,
"GrsWeight": "1.6",
"NetWeight": null,
"DetailRef": null,
"SubLot": null,
"TagID": null,
"Attribute1": null,
"Attribute2": null,
"Attribute3": null,
"Attribute4": null,
"Attribute5": null,
"Attribute6": null
}
},
{
"DepositorCode": "A400",
"ReferenceNumber": "PO000254",
"ShipmentDate": "07/12/18",
"ExpArrivalDate": null,
"ShipFrom": {
"ShipFromCode": null,
"ShipFromName": "Pending RFQ",
"ShipFromName2": null,
"ShipFromAddr1": null,
"ShipFromAddr2": null,
"ShipFromCity": null,
"ShipFromState": null,
"ShipFromZip": null,
"ShipFromCountry": null
},
"Carrier": {
"CarrierCode": null,
"CarrierName": null
},
"Container": null,
"ProNumber": null,
"Warehouse": "MAIN",
"HdrUser1": null,
"HdrUser2": null,
"HdrUser3": null,
"HdrUser4": null,
"HdrUser5": "PURCHASE ORDER",
"ShipFromRef": null,
"TotalQtyDeclared": "1",
"Temperature": "0",
"MasterDocumentNumber": null,
"RectLine": {
"ItemNumber": "B-1",
"DeclaredQty": "1",
"UOM": "EACH",
"ItemDesc1": "Big Book Hardcover 4th Edition",
"ItemDesc2": null,
"SubPart1Number": null,
"SubPart2Number": null,
"LineReference": "1",
"LineUser1": null,
"LineUser2": null,
"LineUser3": null,
"LineUser4": null,
"LineUser5": null,
"Pack1": "20",
"Pack2": null,
"UnitWeight": "1.6",
"TareWeight": null,
"Length": null,
"Width": null,
"Height": null,
"Volume": null,
"Category": "PRINTED MATERIALS",
"Lot": null,
"CodeDate": null,
"GrsWeight": "1.6",
"NetWeight": null,
"DetailRef": null,
"SubLot": null,
"TagID": null,
"Attribute1": null,
"Attribute2": null,
"Attribute3": null,
"Attribute4": null,
"Attribute5": null,
"Attribute6": null
}
},
{
"DepositorCode": "A400",
"ReferenceNumber": "PO000253",
"ShipmentDate": "07/12/18",
"ExpArrivalDate": null,
"ShipFrom": {
"ShipFromCode": null,
"ShipFromName": "Pending RFQ",
"ShipFromName2": null,
"ShipFromAddr1": null,
"ShipFromAddr2": null,
"ShipFromCity": null,
"ShipFromState": null,
"ShipFromZip": null,
"ShipFromCountry": null
},
"Carrier": {
"CarrierCode": null,
"CarrierName": null
},
"Container": null,
"ProNumber": null,
"Warehouse": "MAIN",
"HdrUser1": null,
"HdrUser2": null,
"HdrUser3": null,
"HdrUser4": null,
"HdrUser5": "PURCHASE ORDER",
"ShipFromRef": null,
"TotalQtyDeclared": "5",
"Temperature": "0",
"MasterDocumentNumber": null,
"RectLine": {
"ItemNumber": "AMHAP-2",
"DeclaredQty": "5",
"UOM": "EACH",
"ItemDesc1": "Amharic - 44 Questions",
"ItemDesc2": null,
"SubPart1Number": null,
"SubPart2Number": null,
"LineReference": "1",
"LineUser1": null,
"LineUser2": null,
"LineUser3": null,
"LineUser4": null,
"LineUser5": null,
"Pack1": "250",
"Pack2": null,
"UnitWeight": "0.076",
"TareWeight": null,
"Length": null,
"Width": null,
"Height": null,
"Volume": null,
"Category": "PRINTED MATERIALS",
"Lot": null,
"CodeDate": null,
"GrsWeight": "0.38",
"NetWeight": null,
"DetailRef": null,
"SubLot": null,
"TagID": null,
"Attribute1": null,
"Attribute2": null,
"Attribute3": null,
"Attribute4": null,
"Attribute5": null,
"Attribute6": null
}
},
{
"DepositorCode": "A400",
"ReferenceNumber": "PO000260",
"ShipmentDate": "07/12/18",
"ExpArrivalDate": null,
"ShipFrom": {
"ShipFromCode": null,
"ShipFromName": "Pending RFQ",
"ShipFromName2": null,
"ShipFromAddr1": null,
"ShipFromAddr2": null,
"ShipFromCity": null,
"ShipFromState": null,
"ShipFromZip": null,
"ShipFromCountry": null
},
"Carrier": {
"CarrierCode": null,
"CarrierName": null
},
"Container": null,
"ProNumber": null,
"Warehouse": "MAIN",
"HdrUser1": null,
"HdrUser2": null,
"HdrUser3": null,
"HdrUser4": null,
"HdrUser5": "PURCHASE ORDER",
"ShipFromRef": null,
"TotalQtyDeclared": "1",
"Temperature": "0",
"MasterDocumentNumber": null,
"RectLine": {
"ItemNumber": "B-1",
"DeclaredQty": "1",
"UOM": "EACH",
"ItemDesc1": "Big Book Hardcover 4th Edition",
"ItemDesc2": null,
"SubPart1Number": null,
"SubPart2Number": null,
"LineReference": "1",
"LineUser1": null,
"LineUser2": null,
"LineUser3": null,
"LineUser4": null,
"LineUser5": null,
"Pack1": "20",
"Pack2": null,
"UnitWeight": "1.6",
"TareWeight": null,
"Length": null,
"Width": null,
"Height": null,
"Volume": null,
"Category": "PRINTED MATERIALS",
"Lot": null,
"CodeDate": null,
"GrsWeight": "1.6",
"NetWeight": null,
"DetailRef": null,
"SubLot": null,
"TagID": null,
"Attribute1": null,
"Attribute2": null,
"Attribute3": null,
"Attribute4": null,
"Attribute5": null,
"Attribute6": null
}
}
]
}
]
]
}
<!-- end snippet -->
| 0debug
|
static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed,
int completion)
{
int dir;
size_t len = 0;
#ifdef DEBUG_ISOCH
const char *str = NULL;
#endif
int pid;
int ret;
int i;
USBDevice *dev;
struct ohci_iso_td iso_td;
uint32_t addr;
uint16_t starting_frame;
int16_t relative_frame_number;
int frame_count;
uint32_t start_offset, next_offset, end_offset = 0;
uint32_t start_addr, end_addr;
addr = ed->head & OHCI_DPTR_MASK;
if (!ohci_read_iso_td(ohci, addr, &iso_td)) {
printf("usb-ohci: ISO_TD read error at %x\n", addr);
return 0;
}
starting_frame = OHCI_BM(iso_td.flags, TD_SF);
frame_count = OHCI_BM(iso_td.flags, TD_FC);
relative_frame_number = USUB(ohci->frame_number, starting_frame);
#ifdef DEBUG_ISOCH
printf("--- ISO_TD ED head 0x%.8x tailp 0x%.8x\n"
"0x%.8x 0x%.8x 0x%.8x 0x%.8x\n"
"0x%.8x 0x%.8x 0x%.8x 0x%.8x\n"
"0x%.8x 0x%.8x 0x%.8x 0x%.8x\n"
"frame_number 0x%.8x starting_frame 0x%.8x\n"
"frame_count 0x%.8x relative %d\n"
"di 0x%.8x cc 0x%.8x\n",
ed->head & OHCI_DPTR_MASK, ed->tail & OHCI_DPTR_MASK,
iso_td.flags, iso_td.bp, iso_td.next, iso_td.be,
iso_td.offset[0], iso_td.offset[1], iso_td.offset[2], iso_td.offset[3],
iso_td.offset[4], iso_td.offset[5], iso_td.offset[6], iso_td.offset[7],
ohci->frame_number, starting_frame,
frame_count, relative_frame_number,
OHCI_BM(iso_td.flags, TD_DI), OHCI_BM(iso_td.flags, TD_CC));
#endif
if (relative_frame_number < 0) {
DPRINTF("usb-ohci: ISO_TD R=%d < 0\n", relative_frame_number);
return 1;
} else if (relative_frame_number > frame_count) {
DPRINTF("usb-ohci: ISO_TD R=%d > FC=%d\n", relative_frame_number,
frame_count);
OHCI_SET_BM(iso_td.flags, TD_CC, OHCI_CC_DATAOVERRUN);
ed->head &= ~OHCI_DPTR_MASK;
ed->head |= (iso_td.next & OHCI_DPTR_MASK);
iso_td.next = ohci->done;
ohci->done = addr;
i = OHCI_BM(iso_td.flags, TD_DI);
if (i < ohci->done_count)
ohci->done_count = i;
ohci_put_iso_td(ohci, addr, &iso_td);
return 0;
}
dir = OHCI_BM(ed->flags, ED_D);
switch (dir) {
case OHCI_TD_DIR_IN:
#ifdef DEBUG_ISOCH
str = "in";
#endif
pid = USB_TOKEN_IN;
break;
case OHCI_TD_DIR_OUT:
#ifdef DEBUG_ISOCH
str = "out";
#endif
pid = USB_TOKEN_OUT;
break;
case OHCI_TD_DIR_SETUP:
#ifdef DEBUG_ISOCH
str = "setup";
#endif
pid = USB_TOKEN_SETUP;
break;
default:
printf("usb-ohci: Bad direction %d\n", dir);
return 1;
}
if (!iso_td.bp || !iso_td.be) {
printf("usb-ohci: ISO_TD bp 0x%.8x be 0x%.8x\n", iso_td.bp, iso_td.be);
return 1;
}
start_offset = iso_td.offset[relative_frame_number];
next_offset = iso_td.offset[relative_frame_number + 1];
if (!(OHCI_BM(start_offset, TD_PSW_CC) & 0xe) ||
((relative_frame_number < frame_count) &&
!(OHCI_BM(next_offset, TD_PSW_CC) & 0xe))) {
printf("usb-ohci: ISO_TD cc != not accessed 0x%.8x 0x%.8x\n",
start_offset, next_offset);
return 1;
}
if ((relative_frame_number < frame_count) && (start_offset > next_offset)) {
printf("usb-ohci: ISO_TD start_offset=0x%.8x > next_offset=0x%.8x\n",
start_offset, next_offset);
return 1;
}
if ((start_offset & 0x1000) == 0) {
start_addr = (iso_td.bp & OHCI_PAGE_MASK) |
(start_offset & OHCI_OFFSET_MASK);
} else {
start_addr = (iso_td.be & OHCI_PAGE_MASK) |
(start_offset & OHCI_OFFSET_MASK);
}
if (relative_frame_number < frame_count) {
end_offset = next_offset - 1;
if ((end_offset & 0x1000) == 0) {
end_addr = (iso_td.bp & OHCI_PAGE_MASK) |
(end_offset & OHCI_OFFSET_MASK);
} else {
end_addr = (iso_td.be & OHCI_PAGE_MASK) |
(end_offset & OHCI_OFFSET_MASK);
}
} else {
end_addr = iso_td.be;
}
if ((start_addr & OHCI_PAGE_MASK) != (end_addr & OHCI_PAGE_MASK)) {
len = (end_addr & OHCI_OFFSET_MASK) + 0x1001
- (start_addr & OHCI_OFFSET_MASK);
} else {
len = end_addr - start_addr + 1;
}
if (len && dir != OHCI_TD_DIR_IN) {
ohci_copy_iso_td(ohci, start_addr, end_addr, ohci->usb_buf, len, 0);
}
if (completion) {
ret = ohci->usb_packet.result;
} else {
usb_packet_setup(&ohci->usb_packet, pid,
OHCI_BM(ed->flags, ED_FA),
OHCI_BM(ed->flags, ED_EN));
usb_packet_addbuf(&ohci->usb_packet, ohci->usb_buf, len);
dev = ohci_find_device(ohci, ohci->usb_packet.devaddr);
ret = usb_handle_packet(dev, &ohci->usb_packet);
if (ret == USB_RET_ASYNC) {
return 1;
}
}
#ifdef DEBUG_ISOCH
printf("so 0x%.8x eo 0x%.8x\nsa 0x%.8x ea 0x%.8x\ndir %s len %zu ret %d\n",
start_offset, end_offset, start_addr, end_addr, str, len, ret);
#endif
if (dir == OHCI_TD_DIR_IN && ret >= 0 && ret <= len) {
ohci_copy_iso_td(ohci, start_addr, end_addr, ohci->usb_buf, ret, 1);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_NOERROR);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_SIZE, ret);
} else if (dir == OHCI_TD_DIR_OUT && ret == len) {
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_NOERROR);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_SIZE, 0);
} else {
if (ret > (ssize_t) len) {
printf("usb-ohci: DataOverrun %d > %zu\n", ret, len);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_DATAOVERRUN);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_SIZE,
len);
} else if (ret >= 0) {
printf("usb-ohci: DataUnderrun %d\n", ret);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_DATAUNDERRUN);
} else {
switch (ret) {
case USB_RET_NODEV:
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_DEVICENOTRESPONDING);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_SIZE,
0);
break;
case USB_RET_NAK:
case USB_RET_STALL:
printf("usb-ohci: got NAK/STALL %d\n", ret);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_STALL);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_SIZE,
0);
break;
default:
printf("usb-ohci: Bad device response %d\n", ret);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_UNDEXPETEDPID);
break;
}
}
}
if (relative_frame_number == frame_count) {
OHCI_SET_BM(iso_td.flags, TD_CC, OHCI_CC_NOERROR);
ed->head &= ~OHCI_DPTR_MASK;
ed->head |= (iso_td.next & OHCI_DPTR_MASK);
iso_td.next = ohci->done;
ohci->done = addr;
i = OHCI_BM(iso_td.flags, TD_DI);
if (i < ohci->done_count)
ohci->done_count = i;
}
ohci_put_iso_td(ohci, addr, &iso_td);
return 1;
}
| 1threat
|
What are the disadvantages to Indexes in database tables? : <p>Is there any reason I shouldn't create an index for every one of my database tables, as a means of increasing performance? It would seem there must be some reason(s) else all tables would automatically have one by default.</p>
<p>I use MS SQL Server 2016.</p>
| 0debug
|
void memory_region_del_eventfd(MemoryRegion *mr,
hwaddr addr,
unsigned size,
bool match_data,
uint64_t data,
EventNotifier *e)
{
MemoryRegionIoeventfd mrfd = {
.addr.start = int128_make64(addr),
.addr.size = int128_make64(size),
.match_data = match_data,
.data = data,
.e = e,
};
unsigned i;
adjust_endianness(mr, &mrfd.data, size);
memory_region_transaction_begin();
for (i = 0; i < mr->ioeventfd_nb; ++i) {
if (memory_region_ioeventfd_equal(mrfd, mr->ioeventfds[i])) {
break;
}
}
assert(i != mr->ioeventfd_nb);
memmove(&mr->ioeventfds[i], &mr->ioeventfds[i+1],
sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb - (i+1)));
--mr->ioeventfd_nb;
mr->ioeventfds = g_realloc(mr->ioeventfds,
sizeof(*mr->ioeventfds)*mr->ioeventfd_nb + 1);
ioeventfd_update_pending |= mr->enabled;
memory_region_transaction_commit();
}
| 1threat
|
static void tcg_cpu_exec(void)
{
int ret = 0;
if (next_cpu == NULL)
next_cpu = first_cpu;
for (; next_cpu != NULL; next_cpu = next_cpu->next_cpu) {
CPUState *env = cur_cpu = next_cpu;
if (timer_alarm_pending) {
timer_alarm_pending = 0;
break;
}
if (cpu_can_run(env))
ret = qemu_cpu_exec(env);
else if (env->stop)
break;
if (ret == EXCP_DEBUG) {
gdb_set_stop_cpu(env);
debug_requested = 1;
break;
}
}
}
| 1threat
|
C++ operator overloading for embedded DSL language in C++ : <p>Is it possible to use C++ operator overloading and create a DSL-like syntax for embedded DsL code in c++.</p>
<pre><code>"a": auto = call("add2Numbers", "b", "c");
</code></pre>
<p>This is what I would like ideally. But anything close to this as valid C++ would be acceptable.</p>
| 0debug
|
want to select my my from java gui program not from web : this is my php code checker code for java application but i want to scan a new file in my java GUI program...
enter code here:
public class test {
public static void main(String[] args) throws MalformedURLException, IOException {
URL u = new URL("http://www.example.com/my/php/doc.php");
URLConnection c = u.openConnection();
InputStream r = c.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(r));
for (String line;
(
line = reader.
`enter code here`
readLine()) != null;
)
System.out.println(line);
| 0debug
|
Relative module was not found in Vue.js when build project : <p>I have a project on Vue.js with Typescript and when I run dev server (prod build too) it returns error in console:</p>
<blockquote>
<p>ERROR Failed to compile with 1 errors<br>
This relative module was not found:</p>
<p>*./app.vue in ./src/main.ts</p>
</blockquote>
<p>I alredy tried to checkout previous project commits, update global and local packages, clone and build project on other machines, delete and reinstall packages, delete package-lock.json, create new project via vue cli and add project files on new configuration - and nothing was changed. Same error. Very strange for me.</p>
<p>Here is my main.ts</p>
<pre><code>import Vue from 'vue';
import App from './app.vue';
import router from './router';
import store from './store';
Vue.config.productionTip = false;
new Vue({
router,
store,
render: (h) => h(App)
}).$mount('#app');
</code></pre>
<p>And here App.vue</p>
<pre><code><template>
<div id="app" class="container-fluid">
<header-component></header-component>
<main id="content" class="content row">
<transition name="fade">
<router-view/>
</transition>
</main>
<footer-component></footer-component>
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import HeaderComponent from './components/header/header.component';
import FooterComponent from './components/footer/footer.component';
@Component({
components: {
HeaderComponent,
FooterComponent
}
})
export default class App extends Vue {}
</script>
<style lang="scss">
@import "../node_modules/bootstrap/dist/css/bootstrap.min.css";
@import "../node_modules/font-awesome/css/font-awesome.min.css";
@import "../node_modules/vue2-animate/dist/vue2-animate.min.css";
@import "./styles/main.scss";
</style>
</code></pre>
<p>Thanks in advance for help.</p>
| 0debug
|
Advice on how to design a component : <p>I'm new to react (in the sense that I haven't ever completed a project I've started), and trying to get a more solid idea of the workflow of building components.</p>
<p>I've cloned this project:
<a href="https://github.com/bjones256/facebook-clone" rel="nofollow noreferrer">https://github.com/bjones256/facebook-clone</a></p>
<p>The component I'm trying to make is a "score" component that will be listed on a user's profile. The score will be calculated by a combination of the amount of views and likes on the users posts.</p>
<p>I don't expect it to be done for me, but moreso I would like advice on the thought process behind how this component could be designed.</p>
<p>Currently I'm not seeing which functions count the amount of likes/comments on a post so that set them in the constructor for the score component. Any advice? I would use codementor, but I'm broke right now :P</p>
| 0debug
|
Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[String]: Angular 7 : Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[String]: StaticInjectorError(Platform: core)[String]: NullInjectorError: No provider for String!
I faced the above issue when compiling my angular 7 project. below solution worked for me.
| 0debug
|
static int vp8_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
{
VP56RangeCoder *c = &s->c;
int header_size, hscale, vscale, ret;
int width = s->avctx->width;
int height = s->avctx->height;
s->keyframe = !(buf[0] & 1);
s->profile = (buf[0]>>1) & 7;
s->invisible = !(buf[0] & 0x10);
header_size = AV_RL24(buf) >> 5;
buf += 3;
buf_size -= 3;
if (s->profile > 3)
av_log(s->avctx, AV_LOG_WARNING, "Unknown profile %d\n", s->profile);
if (!s->profile)
memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab,
sizeof(s->put_pixels_tab));
else
memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_bilinear_pixels_tab,
sizeof(s->put_pixels_tab));
if (header_size > buf_size - 7 * s->keyframe) {
av_log(s->avctx, AV_LOG_ERROR, "Header size larger than data provided\n");
return AVERROR_INVALIDDATA;
}
if (s->keyframe) {
if (AV_RL24(buf) != 0x2a019d) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid start code 0x%x\n", AV_RL24(buf));
return AVERROR_INVALIDDATA;
}
width = AV_RL16(buf + 3) & 0x3fff;
height = AV_RL16(buf + 5) & 0x3fff;
hscale = buf[4] >> 6;
vscale = buf[6] >> 6;
buf += 7;
buf_size -= 7;
if (hscale || vscale)
avpriv_request_sample(s->avctx, "Upscaling");
s->update_golden = s->update_altref = VP56_FRAME_CURRENT;
vp78_reset_probability_tables(s);
memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter,
sizeof(s->prob->pred16x16));
memcpy(s->prob->pred8x8c, vp8_pred8x8c_prob_inter,
sizeof(s->prob->pred8x8c));
memcpy(s->prob->mvc, vp8_mv_default_prob,
sizeof(s->prob->mvc));
memset(&s->segmentation, 0, sizeof(s->segmentation));
memset(&s->lf_delta, 0, sizeof(s->lf_delta));
}
ff_vp56_init_range_decoder(c, buf, header_size);
buf += header_size;
buf_size -= header_size;
if (s->keyframe) {
if (vp8_rac_get(c))
av_log(s->avctx, AV_LOG_WARNING, "Unspecified colorspace\n");
vp8_rac_get(c);
}
if ((s->segmentation.enabled = vp8_rac_get(c)))
parse_segment_info(s);
else
s->segmentation.update_map = 0;
s->filter.simple = vp8_rac_get(c);
s->filter.level = vp8_rac_get_uint(c, 6);
s->filter.sharpness = vp8_rac_get_uint(c, 3);
if ((s->lf_delta.enabled = vp8_rac_get(c)))
if (vp8_rac_get(c))
update_lf_deltas(s);
if (setup_partitions(s, buf, buf_size)) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid partitions\n");
return AVERROR_INVALIDDATA;
}
if (!s->macroblocks_base ||
width != s->avctx->width || height != s->avctx->height)
if ((ret = vp8_update_dimensions(s, width, height)) < 0)
return ret;
get_quants(s);
if (!s->keyframe) {
update_refs(s);
s->sign_bias[VP56_FRAME_GOLDEN] = vp8_rac_get(c);
s->sign_bias[VP56_FRAME_GOLDEN2 ] = vp8_rac_get(c);
}
if (!(s->update_probabilities = vp8_rac_get(c)))
s->prob[1] = s->prob[0];
s->update_last = s->keyframe || vp8_rac_get(c);
vp78_update_probability_tables(s);
if ((s->mbskip_enabled = vp8_rac_get(c)))
s->prob->mbskip = vp8_rac_get_uint(c, 8);
if (!s->keyframe) {
s->prob->intra = vp8_rac_get_uint(c, 8);
s->prob->last = vp8_rac_get_uint(c, 8);
s->prob->golden = vp8_rac_get_uint(c, 8);
vp78_update_pred16x16_pred8x8_mvc_probabilities(s, VP8_MVC_SIZE);
}
return 0;
}
| 1threat
|
void qdev_property_add_static(DeviceState *dev, Property *prop,
Error **errp)
{
Error *local_err = NULL;
Object *obj = OBJECT(dev);
if (!prop->info->get && !prop->info->set) {
return;
}
object_property_add(obj, prop->name, prop->info->name,
prop->info->get, prop->info->set,
prop->info->release,
prop, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
object_property_set_description(obj, prop->name,
prop->info->description,
&error_abort);
if (prop->info->set_default_value) {
prop->info->set_default_value(obj, prop);
}
}
| 1threat
|
How do you map the payload in angular2 v5 using the HttpClient and redux : How would I do the equivalent of this call in my service using HttpClient instead of Http? HttpClient doesn't the map() call.
loadObservations() {
this.http.get(`${BASE_URL}${1000}`)
.map(res => res.json())
.map(payload => ({ type: 'ADD_OBSERVATIONS', payload }))
.subscribe(action => this.store.dispatch(action));
}
| 0debug
|
which website required to install Angular CLI : <p>which website required to install Angular CLI, please tell me because in office all sites are not accessible.</p>
| 0debug
|
Google-sheets parser for the cell : I got a string in the cell "D1-D4, D8-D11"
Need it calc summ of elenents "D1, D2, D3, D4, D8, D9, D10, D11"
Output - "8"
ps
I can calc summ of "D1, D2,...D11"
but i need the parser for range "D1-D4"
| 0debug
|
unrecognized selector sent to instance siwft : I'm getting server time using Alamofire,
And with NSTimer I refresh this time every second.
But I get error
> unrecognized selector sent to instance 0x7ff4636126a0'
and also if I change selector to
> selector: "getTime:"
, it gives me an error like this.
[![enter image description here][1]][1]
How should I fix it?
This is my code.
import UIKit
import Alamofire
typealias DownloadComplete = () -> ()
class ViewController: UIViewController {
@IBOutlet var currentTime: UILabel!
var stringDateFromServer = String()
let dateFormatter = NSDateFormatter()
override func viewDidLoad() {
super.viewDidLoad()
getTime { () -> () in
self.dateFormatter.dateFormat = "EEE, dd MMM yyyy HH:mm:ss zzz"
self.dateFormatter.locale = NSLocale(localeIdentifier: "en_US")
let date2 = self.dateFormatter.dateFromString(self.stringDateFromServer)!
self.dateFormatter.locale = NSLocale.currentLocale()
let date3 = self.dateFormatter.stringFromDate(date2)
self.currentTime.text = date3
}
NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "getTime", userInfo: nil, repeats: true)
}
func getTime(completed: DownloadComplete) {
let url = NSURL(string: "http://google.com")!
Alamofire.request(.HEAD, url).responseJSON { (Response) -> Void in
let result = Response.response
if let headers = result?.allHeaderFields {
if let date = headers["Date"] as? String {
self.stringDateFromServer = date
}
}
completed()
}
}
}
[1]: http://i.stack.imgur.com/dCItg.png
| 0debug
|
Mean Euclidean distance in Tensorflow : <p>I have two tensors of sequences of size [batch_size, seq_length, 2]. I want to compute mean Euclidean distance between tensors. What is the elegant way to do this?</p>
| 0debug
|
Gimbal Lock Problem while rotating around 3 axes. [UNITY3D] : I'm trying to do rotation on all of the 3 axes. I have three buttons for each axis, say user pressed X. Then the object should return 90 degrees around X axis. But looks like I cannot get rid of the gimbal lock situation whatever I do. Now I have
private void rotateMe(){
if (x)
transform.rotation *= Quaternion.AngleAxis(90, new Vector3(1, 0, 0));
else if (y)
transform.rotation *= Quaternion.AngleAxis(90, new Vector3(0, 1, 0));
else if (z)
transform.rotation *= Quaternion.AngleAxis(90, new Vector3(0, 0, 1));
}
This too still gives me gimbal lock problem. How do I get rid of the gimbal lock problem?
| 0debug
|
static inline void RENAME(LEToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
{
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(
"mov %0, %%"REG_a" \n\t"
"1: \n\t"
"movq (%1, %%"REG_a",2), %%mm0 \n\t"
"movq 8(%1, %%"REG_a",2), %%mm1 \n\t"
"movq (%2, %%"REG_a",2), %%mm2 \n\t"
"movq 8(%2, %%"REG_a",2), %%mm3 \n\t"
"psrlw $8, %%mm0 \n\t"
"psrlw $8, %%mm1 \n\t"
"psrlw $8, %%mm2 \n\t"
"psrlw $8, %%mm3 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"packuswb %%mm3, %%mm2 \n\t"
"movq %%mm0, (%3, %%"REG_a") \n\t"
"movq %%mm2, (%4, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
" js 1b \n\t"
: : "g" ((x86_reg)-width), "r" (src1+width*2), "r" (src2+width*2), "r" (dstU+width), "r" (dstV+width)
: "%"REG_a
);
#else
int i;
for (i=0; i<width; i++) {
dstU[i]= src1[2*i + 1];
dstV[i]= src2[2*i + 1];
}
#endif
}
| 1threat
|
Best practices for draining or clearing a Google Cloud pubsub topic : <p>For pubsub topics with number of messages in the range of ~100k, what is the best practice for draining/dropping/clearing/deleting all messages using gcloud-java SDK? </p>
<p>Possible solutions:</p>
<ul>
<li><p>Deleting and recreating the subscribers and then the publishers</p></li>
<li><p>High concurrency pull+ack (easy to hit the quota this way) </p></li>
<li>Something else</li>
</ul>
<p>My hope is that this process can be fast (not more than ~60 seconds, say), robust, and uses supported SDK methods with minimal other code.</p>
| 0debug
|
static int blk_mig_save_dirty_block(Monitor *mon, QEMUFile *f, int is_async)
{
BlkMigDevState *bmds;
int ret = 0;
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
if (mig_save_device_dirty(mon, f, bmds, is_async) == 0) {
ret = 1;
break;
}
}
return ret;
}
| 1threat
|
IllegalStateException when trying to add method to button click in Android Studio : <p>I'm creating a simple app that will generate workout routines every time i go to the gym. </p>
<p>Each time I call the method to generate a String of workouts I get an IllegalStateException </p>
<p>Here is my second display xml (where I want the generated String valued workouts to display)</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="1">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="0dp">
<Button
android:id="@+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="createRandomBicepWorkOut"
android:text="Generate"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toTopOf="@+id/textView3"
app:layout_constraintRight_toRightOf="parent"
tools:layout_constraintLeft_creator="1"
android:layout_marginBottom="146dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintHorizontal_bias="0.0" />
<TextView
android:id="@+id/textView3"
android:layout_width="420dp"
android:layout_height="291dp"
android:text="TextView"
tools:layout_constraintTop_creator="1"
tools:layout_constraintRight_creator="1"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="254dp"
tools:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintHorizontal_bias="0.0"
tools:layout_editor_absoluteY="255dp" />
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</code></pre>
<p>Here is my second display java file in which i have the algorithm to generate the workouts.</p>
<pre><code>public class SecondDisplay extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.seconddisplay); //xml file name
}
private TextView bicepResults;
public String createRandomBicepWorkOut(){
Random ran = new Random();
String[] bicepArray = new String[3];
String one = "curls";
String two = "preacher curls";
String three = "hammer curls";
String four = "barbell curls";
String five = "decline curls";
String six = "elliptical curls";
for(int i = 0; i < bicepArray.length;i++){
int index = ran.nextInt(5)+1;
if(index == 1)
bicepArray[i] = one;
else if(index == 2)
bicepArray[i] = two;
else if(index == 3)
bicepArray[i] = three;
else if(index == 4)
bicepArray[i] = four;
else if(index == 5)
bicepArray[i] = five;
else if(index == 6)
bicepArray[i] = six;
}
bicepResults = (TextView) findViewById(R.id.textView3);
for(int i = 0; i < bicepArray.length; i++){
bicepResults.setText(bicepArray[i]);
}
return "gains";
}
}
</code></pre>
<p>Here is my logcat</p>
<pre><code> 05-23 23:03:00.328 2686-2686/com.example.ghost.newapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ghost.newapp, PID: 2686
java.lang.IllegalStateException: Could not find method createRandomBicepWorkOut(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.widget.Button with id 'button6'
at android.view.View$DeclaredOnClickListener.resolveMethod(View.java:4730)
at android.view.View$DeclaredOnClickListener.onClick(View.java:4689)
at android.view.View.performClick(View.java:5610)
at android.view.View$PerformClick.run(View.java:22265)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
</code></pre>
| 0debug
|
static char *getstr8(const uint8_t **pp, const uint8_t *p_end)
{
int len;
const uint8_t *p;
char *str;
p = *pp;
len = get8(&p, p_end);
if (len < 0)
return NULL;
if ((p + len) > p_end)
return NULL;
str = av_malloc(len + 1);
if (!str)
return NULL;
memcpy(str, p, len);
str[len] = '\0';
p += len;
*pp = p;
return str;
}
| 1threat
|
static FlatView generate_memory_topology(MemoryRegion *mr)
{
FlatView view;
flatview_init(&view);
render_memory_region(&view, mr, 0, addrrange_make(0, UINT64_MAX));
flatview_simplify(&view);
return view;
}
| 1threat
|
Sort an array Javascript from string : I have a variable string
> mymvariable
who contain :
864827,,,34200,Sète ,,,445958,,,30220,AIGUES MORTES,,,169807,,,34570,PIGNAN,,,546049,,,13006,MARSEILLE,,
I would like to cast this string to an array like this:
1 864827,,,34200,Sète ,,,
2 445958,,,30220,AIGUES MORTES,,,
3 169807,,,34570,PIGNAN,,,
4 546049,,,13006,MARSEILLE,,
I have try to use:
var array = myvariable.split(",");
But when I do a array[0] that give me the first field here :
> 864827
I would like to have the first line when I do array[0] like this:
> 1 864827,,,34200,Sète ,,,
Is it possible to format the string like this ?
Thanks you
| 0debug
|
Conflict Protobuf version when using Opencv and Tensorflow c++ : <p>I am currently trying to use Tensorflow's shared library in a non-bazel project, so I creat a .so file from tensorflow using bazel.</p>
<p>but when I launch a c++ program that uses both Opencv and Tensorflow, it makes me the following error :</p>
<blockquote>
<p>[libprotobuf FATAL external/protobuf/src/google/protobuf/stubs/common.cc:78] This program was compiled against version 2.6.1 of the Protocol Buffer runtime library, which is not compatible with the installed version (3.1.0). Contact the program author for an update. If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library. (Version verification failed in "/build/mir-pkdHET/mir-0.21.0+16.04.20160330/obj-x86_64-linux-gnu/src/protobuf/mir_protobuf.pb.cc".)
terminate called after throwing an instance of 'google::protobuf::FatalException'</p>
<p>what(): This program was compiled against version 2.6.1 of the Protocol Buffer runtime library, which is not compatible with the installed version (3.1.0). Contact the program author for an update. If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library. (Version verification failed in "/build/mir-pkdHET/mir-0.21.0+16.04.20160330/obj-x86_64-linux-gnu/src/protobuf/mir_protobuf.pb.cc".)
Abandon (core dumped)</p>
</blockquote>
<p>Can you help me?</p>
<p>Thank you</p>
| 0debug
|
static int local_fstat(FsContext *fs_ctx, int fd, struct stat *stbuf)
{
int err;
err = fstat(fd, stbuf);
if (err) {
return err;
}
if (fs_ctx->fs_sm == SM_MAPPED) {
uid_t tmp_uid;
gid_t tmp_gid;
mode_t tmp_mode;
dev_t tmp_dev;
if (fgetxattr(fd, "user.virtfs.uid", &tmp_uid, sizeof(uid_t)) > 0) {
stbuf->st_uid = tmp_uid;
}
if (fgetxattr(fd, "user.virtfs.gid", &tmp_gid, sizeof(gid_t)) > 0) {
stbuf->st_gid = tmp_gid;
}
if (fgetxattr(fd, "user.virtfs.mode", &tmp_mode, sizeof(mode_t)) > 0) {
stbuf->st_mode = tmp_mode;
}
if (fgetxattr(fd, "user.virtfs.rdev", &tmp_dev, sizeof(dev_t)) > 0) {
stbuf->st_rdev = tmp_dev;
}
}
return err;
}
| 1threat
|
void helper_lcall_protected(int new_cs, target_ulong new_eip,
int shift, int next_eip_addend)
{
int new_stack, i;
uint32_t e1, e2, cpl, dpl, rpl, selector, offset, param_count;
uint32_t ss = 0, ss_e1 = 0, ss_e2 = 0, sp, type, ss_dpl, sp_mask;
uint32_t val, limit, old_sp_mask;
target_ulong ssp, old_ssp, next_eip;
next_eip = env->eip + next_eip_addend;
LOG_PCALL("lcall %04x:%08x s=%d\n", new_cs, (uint32_t)new_eip, shift);
LOG_PCALL_STATE(env);
if ((new_cs & 0xfffc) == 0)
raise_exception_err(EXCP0D_GPF, 0);
if (load_segment(&e1, &e2, new_cs) != 0)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
cpl = env->hflags & HF_CPL_MASK;
LOG_PCALL("desc=%08x:%08x\n", e1, e2);
if (e2 & DESC_S_MASK) {
if (!(e2 & DESC_CS_MASK))
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
if (e2 & DESC_C_MASK) {
if (dpl > cpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
} else {
rpl = new_cs & 3;
if (rpl > cpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
if (dpl != cpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
}
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, new_cs & 0xfffc);
#ifdef TARGET_X86_64
if (shift == 2) {
target_ulong rsp;
rsp = ESP;
PUSHQ(rsp, env->segs[R_CS].selector);
PUSHQ(rsp, next_eip);
ESP = rsp;
cpu_x86_load_seg_cache(env, R_CS, (new_cs & 0xfffc) | cpl,
get_seg_base(e1, e2),
get_seg_limit(e1, e2), e2);
EIP = new_eip;
} else
#endif
{
sp = ESP;
sp_mask = get_sp_mask(env->segs[R_SS].flags);
ssp = env->segs[R_SS].base;
if (shift) {
PUSHL(ssp, sp, sp_mask, env->segs[R_CS].selector);
PUSHL(ssp, sp, sp_mask, next_eip);
} else {
PUSHW(ssp, sp, sp_mask, env->segs[R_CS].selector);
PUSHW(ssp, sp, sp_mask, next_eip);
}
limit = get_seg_limit(e1, e2);
if (new_eip > limit)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
SET_ESP(sp, sp_mask);
cpu_x86_load_seg_cache(env, R_CS, (new_cs & 0xfffc) | cpl,
get_seg_base(e1, e2), limit, e2);
EIP = new_eip;
}
} else {
type = (e2 >> DESC_TYPE_SHIFT) & 0x1f;
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
rpl = new_cs & 3;
switch(type) {
case 1:
case 9:
case 5:
if (dpl < cpl || dpl < rpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
switch_tss(new_cs, e1, e2, SWITCH_TSS_CALL, next_eip);
CC_OP = CC_OP_EFLAGS;
return;
case 4:
case 12:
break;
default:
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
break;
}
shift = type >> 3;
if (dpl < cpl || dpl < rpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, new_cs & 0xfffc);
selector = e1 >> 16;
offset = (e2 & 0xffff0000) | (e1 & 0x0000ffff);
param_count = e2 & 0x1f;
if ((selector & 0xfffc) == 0)
raise_exception_err(EXCP0D_GPF, 0);
if (load_segment(&e1, &e2, selector) != 0)
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
if (!(e2 & DESC_S_MASK) || !(e2 & (DESC_CS_MASK)))
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
if (dpl > cpl)
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, selector & 0xfffc);
if (!(e2 & DESC_C_MASK) && dpl < cpl) {
get_ss_esp_from_tss(&ss, &sp, dpl);
LOG_PCALL("new ss:esp=%04x:%08x param_count=%d ESP=" TARGET_FMT_lx "\n",
ss, sp, param_count, ESP);
if ((ss & 0xfffc) == 0)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if ((ss & 3) != dpl)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if (load_segment(&ss_e1, &ss_e2, ss) != 0)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
ss_dpl = (ss_e2 >> DESC_DPL_SHIFT) & 3;
if (ss_dpl != dpl)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if (!(ss_e2 & DESC_S_MASK) ||
(ss_e2 & DESC_CS_MASK) ||
!(ss_e2 & DESC_W_MASK))
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if (!(ss_e2 & DESC_P_MASK))
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
old_sp_mask = get_sp_mask(env->segs[R_SS].flags);
old_ssp = env->segs[R_SS].base;
sp_mask = get_sp_mask(ss_e2);
ssp = get_seg_base(ss_e1, ss_e2);
if (shift) {
PUSHL(ssp, sp, sp_mask, env->segs[R_SS].selector);
PUSHL(ssp, sp, sp_mask, ESP);
for(i = param_count - 1; i >= 0; i--) {
val = ldl_kernel(old_ssp + ((ESP + i * 4) & old_sp_mask));
PUSHL(ssp, sp, sp_mask, val);
}
} else {
PUSHW(ssp, sp, sp_mask, env->segs[R_SS].selector);
PUSHW(ssp, sp, sp_mask, ESP);
for(i = param_count - 1; i >= 0; i--) {
val = lduw_kernel(old_ssp + ((ESP + i * 2) & old_sp_mask));
PUSHW(ssp, sp, sp_mask, val);
}
}
new_stack = 1;
} else {
sp = ESP;
sp_mask = get_sp_mask(env->segs[R_SS].flags);
ssp = env->segs[R_SS].base;
new_stack = 0;
}
if (shift) {
PUSHL(ssp, sp, sp_mask, env->segs[R_CS].selector);
PUSHL(ssp, sp, sp_mask, next_eip);
} else {
PUSHW(ssp, sp, sp_mask, env->segs[R_CS].selector);
PUSHW(ssp, sp, sp_mask, next_eip);
}
if (new_stack) {
ss = (ss & ~3) | dpl;
cpu_x86_load_seg_cache(env, R_SS, ss,
ssp,
get_seg_limit(ss_e1, ss_e2),
ss_e2);
}
selector = (selector & ~3) | dpl;
cpu_x86_load_seg_cache(env, R_CS, selector,
get_seg_base(e1, e2),
get_seg_limit(e1, e2),
e2);
cpu_x86_set_cpl(env, dpl);
SET_ESP(sp, sp_mask);
EIP = offset;
}
#ifdef CONFIG_KQEMU
if (kqemu_is_ok(env)) {
env->exception_index = -1;
cpu_loop_exit();
}
#endif
}
| 1threat
|
How can I disambiguate a type and a module with the same name? : <p>I'm trying to use Károly Lőrentey's <a href="https://github.com/lorentey/BTree">B-tree based <code>OrderedSet</code></a> in a project. However, I'm running into an issue where I can't declare an unqualified <code>OrderedSet<T></code> because the name conflicts between Foundation's <code>NSOrderedSet</code> (imported as <code>OrderedSet</code> in Swift 3) and <code>BTree</code>'s <code>OrderedSet</code>.</p>
<pre><code>let set = OrderedSet<Int>()
// error: 'OrderedSet' is ambiguous for type lookup in this context
// Found this candidate: Foundation.OrderedSet:3:14
// Found this candidate: BTree.OrderedSet:12:15
</code></pre>
<p>To resolve this conflict, you would normally qualify the name, and that would give you <code>BTree.OrderedSet<T></code>. However, the <code>BTree</code> module also contains a class named <code>BTree</code>. If I write <code>BTree.OrderedSet</code>, Swift thinks that I'm referring to a type named <code>OrderedSet</code> that is nested in the <code>BTree.BTree</code> type.</p>
<pre><code>let set = BTree.OrderedSet<Int>()
// error: reference to generic type 'BTree' requires arguments in <...>
</code></pre>
<p>If I don't <code>import BTree</code>, I can't use the <code>BTree</code> name at all.</p>
<pre><code>// no import BTree
let set = BTree.OrderedSet<Int>()
// error: use of undeclared type 'BTree'
</code></pre>
<p>How can I resolve this ambiguity between the <code>BTree</code> type and the <code>BTree</code> module?</p>
| 0debug
|
static void tcg_out_op (TCGContext *s, int opc, const TCGArg *args,
const int *const_args)
{
int c;
switch (opc) {
case INDEX_op_exit_tb:
tcg_out_movi (s, TCG_TYPE_I64, TCG_REG_R3, args[0]);
tcg_out_b (s, 0, (tcg_target_long) tb_ret_addr);
break;
case INDEX_op_goto_tb:
if (s->tb_jmp_offset) {
s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf;
s->code_ptr += 28;
}
else {
tcg_abort ();
}
s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf;
break;
case INDEX_op_br:
{
TCGLabel *l = &s->labels[args[0]];
if (l->has_value) {
tcg_out_b (s, 0, l->u.value);
}
else {
uint32_t val = *(uint32_t *) s->code_ptr;
tcg_out32 (s, B | (val & 0x3fffffc));
tcg_out_reloc (s, s->code_ptr - 4, R_PPC_REL24, args[0], 0);
}
}
break;
case INDEX_op_call:
tcg_out_call (s, args[0], const_args[0]);
break;
case INDEX_op_jmp:
if (const_args[0]) {
tcg_out_b (s, 0, args[0]);
}
else {
tcg_out32 (s, MTSPR | RS (args[0]) | CTR);
tcg_out32 (s, BCCTR | BO_ALWAYS);
}
break;
case INDEX_op_movi_i32:
tcg_out_movi (s, TCG_TYPE_I32, args[0], args[1]);
break;
case INDEX_op_movi_i64:
tcg_out_movi (s, TCG_TYPE_I64, args[0], args[1]);
break;
case INDEX_op_ld8u_i32:
case INDEX_op_ld8u_i64:
tcg_out_ldst (s, args[0], args[1], args[2], LBZ, LBZX);
break;
case INDEX_op_ld8s_i32:
case INDEX_op_ld8s_i64:
tcg_out_ldst (s, args[0], args[1], args[2], LBZ, LBZX);
tcg_out32 (s, EXTSB | RS (args[0]) | RA (args[0]));
break;
case INDEX_op_ld16u_i32:
case INDEX_op_ld16u_i64:
tcg_out_ldst (s, args[0], args[1], args[2], LHZ, LHZX);
break;
case INDEX_op_ld16s_i32:
case INDEX_op_ld16s_i64:
tcg_out_ldst (s, args[0], args[1], args[2], LHA, LHAX);
break;
case INDEX_op_ld_i32:
case INDEX_op_ld32u_i64:
tcg_out_ldst (s, args[0], args[1], args[2], LWZ, LWZX);
break;
case INDEX_op_ld32s_i64:
tcg_out_ldst (s, args[0], args[1], args[2], LWA, LWAX);
break;
case INDEX_op_ld_i64:
tcg_out_ldst (s, args[0], args[1], args[2], LD, LDX);
break;
case INDEX_op_st8_i32:
case INDEX_op_st8_i64:
tcg_out_ldst (s, args[0], args[1], args[2], STB, STBX);
break;
case INDEX_op_st16_i32:
case INDEX_op_st16_i64:
tcg_out_ldst (s, args[0], args[1], args[2], STH, STHX);
break;
case INDEX_op_st_i32:
case INDEX_op_st32_i64:
tcg_out_ldst (s, args[0], args[1], args[2], STW, STWX);
break;
case INDEX_op_st_i64:
tcg_out_ldst (s, args[0], args[1], args[2], STD, STDX);
break;
case INDEX_op_add_i32:
if (const_args[2])
ppc_addi32 (s, args[0], args[1], args[2]);
else
tcg_out32 (s, ADD | TAB (args[0], args[1], args[2]));
break;
case INDEX_op_sub_i32:
if (const_args[2])
ppc_addi32 (s, args[0], args[1], -args[2]);
else
tcg_out32 (s, SUBF | TAB (args[0], args[2], args[1]));
break;
case INDEX_op_and_i64:
case INDEX_op_and_i32:
if (const_args[2]) {
if ((args[2] & 0xffff) == args[2])
tcg_out32 (s, ANDI | RS (args[1]) | RA (args[0]) | args[2]);
else if ((args[2] & 0xffff0000) == args[2])
tcg_out32 (s, ANDIS | RS (args[1]) | RA (args[0])
| ((args[2] >> 16) & 0xffff));
else {
tcg_out_movi (s, (opc == INDEX_op_and_i32
? TCG_TYPE_I32
: TCG_TYPE_I64),
0, args[2]);
tcg_out32 (s, AND | SAB (args[1], args[0], 0));
}
}
else
tcg_out32 (s, AND | SAB (args[1], args[0], args[2]));
break;
case INDEX_op_or_i64:
case INDEX_op_or_i32:
if (const_args[2]) {
if (args[2] & 0xffff) {
tcg_out32 (s, ORI | RS (args[1]) | RA (args[0])
| (args[2] & 0xffff));
if (args[2] >> 16)
tcg_out32 (s, ORIS | RS (args[0]) | RA (args[0])
| ((args[2] >> 16) & 0xffff));
}
else {
tcg_out32 (s, ORIS | RS (args[1]) | RA (args[0])
| ((args[2] >> 16) & 0xffff));
}
}
else
tcg_out32 (s, OR | SAB (args[1], args[0], args[2]));
break;
case INDEX_op_xor_i64:
case INDEX_op_xor_i32:
if (const_args[2]) {
if ((args[2] & 0xffff) == args[2])
tcg_out32 (s, XORI | RS (args[1]) | RA (args[0])
| (args[2] & 0xffff));
else if ((args[2] & 0xffff0000) == args[2])
tcg_out32 (s, XORIS | RS (args[1]) | RA (args[0])
| ((args[2] >> 16) & 0xffff));
else {
tcg_out_movi (s, (opc == INDEX_op_and_i32
? TCG_TYPE_I32
: TCG_TYPE_I64),
0, args[2]);
tcg_out32 (s, XOR | SAB (args[1], args[0], 0));
}
}
else
tcg_out32 (s, XOR | SAB (args[1], args[0], args[2]));
break;
case INDEX_op_mul_i32:
if (const_args[2]) {
if (args[2] == (int16_t) args[2])
tcg_out32 (s, MULLI | RT (args[0]) | RA (args[1])
| (args[2] & 0xffff));
else {
tcg_out_movi (s, TCG_TYPE_I32, 0, args[2]);
tcg_out32 (s, MULLW | TAB (args[0], args[1], 0));
}
}
else
tcg_out32 (s, MULLW | TAB (args[0], args[1], args[2]));
break;
case INDEX_op_div_i32:
tcg_out32 (s, DIVW | TAB (args[0], args[1], args[2]));
break;
case INDEX_op_divu_i32:
tcg_out32 (s, DIVWU | TAB (args[0], args[1], args[2]));
break;
case INDEX_op_rem_i32:
tcg_out32 (s, DIVW | TAB (0, args[1], args[2]));
tcg_out32 (s, MULLW | TAB (0, 0, args[2]));
tcg_out32 (s, SUBF | TAB (args[0], 0, args[1]));
break;
case INDEX_op_remu_i32:
tcg_out32 (s, DIVWU | TAB (0, args[1], args[2]));
tcg_out32 (s, MULLW | TAB (0, 0, args[2]));
tcg_out32 (s, SUBF | TAB (args[0], 0, args[1]));
break;
case INDEX_op_shl_i32:
if (const_args[2]) {
tcg_out32 (s, (RLWINM
| RA (args[0])
| RS (args[1])
| SH (args[2])
| MB (0)
| ME (31 - args[2])
)
);
}
else
tcg_out32 (s, SLW | SAB (args[1], args[0], args[2]));
break;
case INDEX_op_shr_i32:
if (const_args[2]) {
tcg_out32 (s, (RLWINM
| RA (args[0])
| RS (args[1])
| SH (32 - args[2])
| MB (args[2])
| ME (31)
)
);
}
else
tcg_out32 (s, SRW | SAB (args[1], args[0], args[2]));
break;
case INDEX_op_sar_i32:
if (const_args[2])
tcg_out32 (s, SRAWI | RS (args[1]) | RA (args[0]) | SH (args[2]));
else
tcg_out32 (s, SRAW | SAB (args[1], args[0], args[2]));
break;
case INDEX_op_brcond_i32:
tcg_out_brcond (s, args[2], args[0], args[1], const_args[1], args[3], 0);
break;
case INDEX_op_brcond_i64:
tcg_out_brcond (s, args[2], args[0], args[1], const_args[1], args[3], 1);
break;
case INDEX_op_neg_i32:
case INDEX_op_neg_i64:
tcg_out32 (s, NEG | RT (args[0]) | RA (args[1]));
break;
case INDEX_op_add_i64:
if (const_args[2])
ppc_addi64 (s, args[0], args[1], args[2]);
else
tcg_out32 (s, ADD | TAB (args[0], args[1], args[2]));
break;
case INDEX_op_sub_i64:
if (const_args[2])
ppc_addi64 (s, args[0], args[1], -args[2]);
else
tcg_out32 (s, SUBF | TAB (args[0], args[2], args[1]));
break;
case INDEX_op_shl_i64:
if (const_args[2])
tcg_out_rld (s, RLDICR, args[0], args[1], args[2], 63 - args[2]);
else
tcg_out32 (s, SLD | SAB (args[1], args[0], args[2]));
break;
case INDEX_op_shr_i64:
if (const_args[2])
tcg_out_rld (s, RLDICL, args[0], args[1], 64 - args[2], args[2]);
else
tcg_out32 (s, SRD | SAB (args[1], args[0], args[2]));
break;
case INDEX_op_sar_i64:
if (const_args[2]) {
int sh = SH (args[2] & 0x1f) | (((args[2] >> 5) & 1) << 1);
tcg_out32 (s, SRADI | RA (args[0]) | RS (args[1]) | sh);
}
else
tcg_out32 (s, SRAD | SAB (args[1], args[0], args[2]));
break;
case INDEX_op_mul_i64:
tcg_out32 (s, MULLD | TAB (args[0], args[1], args[2]));
break;
case INDEX_op_div_i64:
tcg_out32 (s, DIVD | TAB (args[0], args[1], args[2]));
break;
case INDEX_op_divu_i64:
tcg_out32 (s, DIVDU | TAB (args[0], args[1], args[2]));
break;
case INDEX_op_rem_i64:
tcg_out32 (s, DIVD | TAB (0, args[1], args[2]));
tcg_out32 (s, MULLD | TAB (0, 0, args[2]));
tcg_out32 (s, SUBF | TAB (args[0], 0, args[1]));
break;
case INDEX_op_remu_i64:
tcg_out32 (s, DIVDU | TAB (0, args[1], args[2]));
tcg_out32 (s, MULLD | TAB (0, 0, args[2]));
tcg_out32 (s, SUBF | TAB (args[0], 0, args[1]));
break;
case INDEX_op_qemu_ld8u:
tcg_out_qemu_ld (s, args, 0);
break;
case INDEX_op_qemu_ld8s:
tcg_out_qemu_ld (s, args, 0 | 4);
break;
case INDEX_op_qemu_ld16u:
tcg_out_qemu_ld (s, args, 1);
break;
case INDEX_op_qemu_ld16s:
tcg_out_qemu_ld (s, args, 1 | 4);
break;
case INDEX_op_qemu_ld32u:
tcg_out_qemu_ld (s, args, 2);
break;
case INDEX_op_qemu_ld32s:
tcg_out_qemu_ld (s, args, 2 | 4);
break;
case INDEX_op_qemu_ld64:
tcg_out_qemu_ld (s, args, 3);
break;
case INDEX_op_qemu_st8:
tcg_out_qemu_st (s, args, 0);
break;
case INDEX_op_qemu_st16:
tcg_out_qemu_st (s, args, 1);
break;
case INDEX_op_qemu_st32:
tcg_out_qemu_st (s, args, 2);
break;
case INDEX_op_qemu_st64:
tcg_out_qemu_st (s, args, 3);
break;
case INDEX_op_ext8s_i32:
case INDEX_op_ext8s_i64:
c = EXTSB;
goto gen_ext;
case INDEX_op_ext16s_i32:
case INDEX_op_ext16s_i64:
c = EXTSH;
goto gen_ext;
case INDEX_op_ext32s_i64:
c = EXTSW;
goto gen_ext;
gen_ext:
tcg_out32 (s, c | RS (args[1]) | RA (args[0]));
break;
default:
tcg_dump_ops (s, stderr);
tcg_abort ();
}
}
| 1threat
|
int ff_init_poc(H264Context *h, int pic_field_poc[2], int *pic_poc)
{
const SPS *sps = h->ps.sps;
const int max_frame_num = 1 << sps->log2_max_frame_num;
int field_poc[2];
h->frame_num_offset = h->prev_frame_num_offset;
if (h->frame_num < h->prev_frame_num)
h->frame_num_offset += max_frame_num;
if (sps->poc_type == 0) {
const int max_poc_lsb = 1 << sps->log2_max_poc_lsb;
if (h->poc_lsb < h->prev_poc_lsb &&
h->prev_poc_lsb - h->poc_lsb >= max_poc_lsb / 2)
h->poc_msb = h->prev_poc_msb + max_poc_lsb;
else if (h->poc_lsb > h->prev_poc_lsb &&
h->prev_poc_lsb - h->poc_lsb < -max_poc_lsb / 2)
h->poc_msb = h->prev_poc_msb - max_poc_lsb;
else
h->poc_msb = h->prev_poc_msb;
field_poc[0] =
field_poc[1] = h->poc_msb + h->poc_lsb;
if (h->picture_structure == PICT_FRAME)
field_poc[1] += h->delta_poc_bottom;
} else if (sps->poc_type == 1) {
int abs_frame_num, expected_delta_per_poc_cycle, expectedpoc;
int i;
if (sps->poc_cycle_length != 0)
abs_frame_num = h->frame_num_offset + h->frame_num;
else
abs_frame_num = 0;
if (h->nal_ref_idc == 0 && abs_frame_num > 0)
abs_frame_num--;
expected_delta_per_poc_cycle = 0;
for (i = 0; i < sps->poc_cycle_length; i++)
expected_delta_per_poc_cycle += sps->offset_for_ref_frame[i];
if (abs_frame_num > 0) {
int poc_cycle_cnt = (abs_frame_num - 1) / sps->poc_cycle_length;
int frame_num_in_poc_cycle = (abs_frame_num - 1) % sps->poc_cycle_length;
expectedpoc = poc_cycle_cnt * expected_delta_per_poc_cycle;
for (i = 0; i <= frame_num_in_poc_cycle; i++)
expectedpoc = expectedpoc + sps->offset_for_ref_frame[i];
} else
expectedpoc = 0;
if (h->nal_ref_idc == 0)
expectedpoc = expectedpoc + sps->offset_for_non_ref_pic;
field_poc[0] = expectedpoc + h->delta_poc[0];
field_poc[1] = field_poc[0] + sps->offset_for_top_to_bottom_field;
if (h->picture_structure == PICT_FRAME)
field_poc[1] += h->delta_poc[1];
} else {
int poc = 2 * (h->frame_num_offset + h->frame_num);
if (!h->nal_ref_idc)
poc--;
field_poc[0] = poc;
field_poc[1] = poc;
}
if (h->picture_structure != PICT_BOTTOM_FIELD)
pic_field_poc[0] = field_poc[0];
if (h->picture_structure != PICT_TOP_FIELD)
pic_field_poc[1] = field_poc[1];
*pic_poc = FFMIN(pic_field_poc[0], pic_field_poc[1]);
return 0;
}
| 1threat
|
How to get the SPRING Boot HOST and PORT address during run time? : <p>How could I get the host and port where my application is deployed during run-time so that I can use it in my java method?</p>
| 0debug
|
static void chs_assemble_msbs_lsbs(DCAXllDecoder *s, DCAXllChSet *c, int band)
{
DCAXllBand *b = &c->bands[band];
int n, ch, nsamples = s->nframesamples;
for (ch = 0; ch < c->nchannels; ch++) {
int shift = chs_get_lsb_width(s, c, band, ch);
if (shift) {
int32_t *msb = b->msb_sample_buffer[ch];
if (b->nscalablelsbs[ch]) {
int32_t *lsb = b->lsb_sample_buffer[ch];
int adj = b->bit_width_adjust[ch];
for (n = 0; n < nsamples; n++)
msb[n] = msb[n] * (1 << shift) + (lsb[n] << adj);
} else {
for (n = 0; n < nsamples; n++)
msb[n] = msb[n] * (1 << shift);
}
}
}
}
| 1threat
|
How do you add an initial selection for Angular Material Table SelectionModel? : <p>The Angular Material documentation gives a nice example for how to add selection to a table (<a href="https://material.angular.io/components/table/overview#selection" rel="noreferrer">Table Selection docs</a>). They even provide a <a href="https://stackblitz.com/angular/aypedlrjldj?file=app%2Ftable-selection-example.ts" rel="noreferrer">Stackblitz</a> to try it out.</p>
<p>I found in the <a href="https://github.com/angular/material2/blob/master/src/cdk/collections/selection.ts" rel="noreferrer">code for the SelectionModel constructor</a> that the first argument is whether there can be multiple selections made (true) or not (false). The second argument is an array of initially selected values.</p>
<p>In the demo, they don't have any initially selected values, so the second argument in their constructor (line 36) is an empty array (<code>[]</code>).</p>
<p>I want to change it so that there is an initially selected value, so I changed line 36 to:</p>
<pre><code>selection = new SelectionModel<PeriodicElement>(true, [{position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}]);
</code></pre>
<p>This changes the checkbox in the header to an indeterminate state (as expected), but does not cause the row in the table to be selected. Am I setting the initial value incorrectly, or what am I missing here? How can I set an initially selected value?</p>
| 0debug
|
how does java treat octal and decimal number : <p>I am not able to understand how java stores the value specified as octal and hexadecimal value.i need an explanation for the output of the following code snippet.</p>
<pre><code>public class Test {
public static void main ( String args[] )
{
int a = 10 , b = 017 , c = 0X3A ;
System.out.println( a + " " + b + " " + c) ;
}
}
</code></pre>
<p>The output produced by this code is </p>
<pre><code>10 15 58
</code></pre>
<p>a detailed explanation on the output would be of great help.Thanks in advance</p>
| 0debug
|
c# dao recordset findfirst operation not supported : Please refrain from the "Nobody uses DAO" tropes. I am a new hobbyist to C# but have a whole library of VBA DAO code/logic I am hoping to utilize (i.e. translate) in C#. I can get a table open in a recordset. But trying to check for an existing record with FindFirst throws "Operation is not supported for this type of object." And I can't find a way to refine a Recordset via SELECT or SQL.
When working in the IDE, FindFirst is offered when working with DAO.Recordset variables so it must be part of the object.
I recognize by how hard it is to find information that this is not a popular area. But it is supported and I assume that is because at least some are still utilizing it. For the near term, simply being able to check for existing records in a DB will go a long ways for me. So any help resolving this error would be GREATLY APPRECIATED.
But I would further appreciate any help cracking open the door to C# DAO documentation, references or any other knowledge. (MS site only references VB.) I'm having no luck finding the right search terms.
Thx
| 0debug
|
How to fix AssertTrue error when running junit test : Setting up a Junit test but run into an test fail. Issue seems to be around my assertrue
import static org.junit.Assert.*;
import org.junit.Test;
import com.neueda.cap.spark.model.NeuFixMessage;
import quickfix.Message;
public class CalculateFillValue {
@Test
public void test() throws Exception {
CalculateFillValuesMapper test = new CalculateFillValuesMapper();
NeuFixMessage msg= new NeuFixMessage();
msg.setMsgType("8");
msg.setExecType("1");
msg.setLastPx("10.10");
msg.setLastShares("100");
msg = test.call(msg);
assertTrue("The file value should be 1010", msg.getFillValue() == 1010);
}
}
| 0debug
|
Using webpack, threejs examples, and typescript? : <p>I'm having a lot of trouble getting stuff in threejs's examples (like EffectComposer or Detector) to work with webpack and typescript.</p>
<p>First off the relevant <code>*.d.ts</code> files are all present and installed via <code>tsd</code>. My problem is getting webpack to actually include files outside of the default threejs build (namely things in <code>examples/js/</code>).</p>
<p>With <code>three</code> installed from npm I can do something like</p>
<pre><code>import THREE = require('three');
</code></pre>
<p>Which works fine but lacks any of the aforementioned goodies. There are a few other threejs packages on npm that bundle plugins but I don't think they work with typescript (since <code>require('three-js')(['EffectComposer'])</code> is rejected by the typescript compiler.</p>
<p>Has anyone gotten something in this package (like postprocessing) to work with typescript?</p>
| 0debug
|
Responsive Inline SVG using Bootstrap : <p>How to make an inline svg icon responsive using Bootstrap? Here is a sample code:</p>
<pre><code><svg id="mute-audio" xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewbox="-10 -10 68 68">
<circle cx="24" cy="24" r="34">
<title>Mute Audio</title>
</circle>
<path class="on" transform="scale(0.6), translate(17,18)" d="M38 22h-3.4c0 1.49-.31 2.87-.87 4.1l2.46 2.46C37.33 26.61 38 24.38 38 22zm-8.03.33c0-.11.03-.22.03-.33V10c0-3.32-2.69-6-6-6s-6 2.68-6 6v.37l11.97 11.96zM8.55 6L6 8.55l12.02 12.02v1.44c0 3.31 2.67 6 5.98 6 .45 0 .88-.06 1.3-.15l3.32 3.32c-1.43.66-3 1.03-4.62 1.03-5.52 0-10.6-4.2-10.6-10.2H10c0 6.83 5.44 12.47 12 13.44V42h4v-6.56c1.81-.27 3.53-.9 5.08-1.81L39.45 42 42 39.46 8.55 6z" fill="white"/>
<path class="off" transform="scale(0.6), translate(17,18)" d="M24 28c3.31 0 5.98-2.69 5.98-6L30 10c0-3.32-2.68-6-6-6-3.31 0-6 2.68-6 6v12c0 3.31 2.69 6 6 6zm10.6-6c0 6-5.07 10.2-10.6 10.2-5.52 0-10.6-4.2-10.6-10.2H10c0 6.83 5.44 12.47 12 13.44V42h4v-6.56c6.56-.97 12-6.61 12-13.44h-3.4z" fill="white"/>
</svg>
</code></pre>
<p>I tried different:</p>
<ol>
<li><p>class="img-responsive" in svg </p></li>
<li><p>class="embed-responsive-item" in
the container div</p></li>
</ol>
<p>No luck so far. How to accomplish this?</p>
| 0debug
|
static FlatView *address_space_get_flatview(AddressSpace *as)
{
FlatView *view;
rcu_read_lock();
view = atomic_rcu_read(&as->current_map);
flatview_ref(view);
rcu_read_unlock();
return view;
}
| 1threat
|
The "GenerateJavaStubs" task failed : <p>Currently banging my head against a wall with this issue, the error is preventing me from building and running my application. It is a PCL project.</p>
<pre><code> Error The "GenerateJavaStubs" task failed unexpectedly.
System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
at System.IO.PathHelper.GetFullPathName()
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.Path.GetFullPath(String path)
at Xamarin.Android.Tasks.GenerateJavaStubs.Run()
at Xamarin.Android.Tasks.GenerateJavaStubs.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() ConstructionMobileApp.Droid C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 1574
</code></pre>
<p>My assembly info in the PCL:</p>
<pre><code>using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("ConstructionMobileApp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConstructionMobileApp")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
</code></pre>
<p>Android Assembly Info:</p>
<pre><code>using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Android.App;
[assembly: AssemblyTitle("ConstructionMobileApp.Droid")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConstructionMobileApp.Droid")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: UsesPermission(Android.Manifest.Permission.Internet)]
[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
</code></pre>
| 0debug
|
void helper_lcall_protected_T0_T1(int shift, int next_eip)
{
int new_cs, new_eip;
uint32_t e1, e2, cpl, dpl, rpl, selector, offset, param_count;
uint32_t ss, ss_e1, ss_e2, push_size, sp, type, ss_dpl;
uint32_t old_ss, old_esp, val, i, limit;
uint8_t *ssp, *old_ssp;
new_cs = T0;
new_eip = T1;
if ((new_cs & 0xfffc) == 0)
raise_exception_err(EXCP0D_GPF, 0);
if (load_segment(&e1, &e2, new_cs) != 0)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
cpl = env->hflags & HF_CPL_MASK;
if (e2 & DESC_S_MASK) {
if (!(e2 & DESC_CS_MASK))
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
if (e2 & DESC_CS_MASK) {
if (dpl > cpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
} else {
rpl = new_cs & 3;
if (rpl > cpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
if (dpl != cpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
}
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, new_cs & 0xfffc);
sp = ESP;
if (!(env->segs[R_SS].flags & DESC_B_MASK))
sp &= 0xffff;
ssp = env->segs[R_SS].base + sp;
if (shift) {
ssp -= 4;
stl_kernel(ssp, env->segs[R_CS].selector);
ssp -= 4;
stl_kernel(ssp, next_eip);
} else {
ssp -= 2;
stw_kernel(ssp, env->segs[R_CS].selector);
ssp -= 2;
stw_kernel(ssp, next_eip);
}
sp -= (4 << shift);
limit = get_seg_limit(e1, e2);
if (new_eip > limit)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
if (!(env->segs[R_SS].flags & DESC_B_MASK))
ESP = (ESP & 0xffff0000) | (sp & 0xffff);
else
ESP = sp;
cpu_x86_load_seg_cache(env, R_CS, (new_cs & 0xfffc) | cpl,
get_seg_base(e1, e2), limit, e2);
EIP = new_eip;
} else {
type = (e2 >> DESC_TYPE_SHIFT) & 0x1f;
switch(type) {
case 1:
case 9:
case 5:
cpu_abort(env, "task gate not supported");
break;
case 4:
case 12:
break;
default:
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
break;
}
shift = type >> 3;
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
rpl = new_cs & 3;
if (dpl < cpl || dpl < rpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, new_cs & 0xfffc);
selector = e1 >> 16;
offset = (e2 & 0xffff0000) | (e1 & 0x0000ffff);
if ((selector & 0xfffc) == 0)
raise_exception_err(EXCP0D_GPF, 0);
if (load_segment(&e1, &e2, selector) != 0)
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
if (!(e2 & DESC_S_MASK) || !(e2 & (DESC_CS_MASK)))
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
if (dpl > cpl)
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, selector & 0xfffc);
if (!(e2 & DESC_C_MASK) && dpl < cpl) {
get_ss_esp_from_tss(&ss, &sp, dpl);
if ((ss & 0xfffc) == 0)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if ((ss & 3) != dpl)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if (load_segment(&ss_e1, &ss_e2, ss) != 0)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
ss_dpl = (ss_e2 >> DESC_DPL_SHIFT) & 3;
if (ss_dpl != dpl)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if (!(ss_e2 & DESC_S_MASK) ||
(ss_e2 & DESC_CS_MASK) ||
!(ss_e2 & DESC_W_MASK))
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if (!(ss_e2 & DESC_P_MASK))
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
param_count = e2 & 0x1f;
push_size = ((param_count * 2) + 8) << shift;
old_esp = ESP;
old_ss = env->segs[R_SS].selector;
if (!(env->segs[R_SS].flags & DESC_B_MASK))
old_esp &= 0xffff;
old_ssp = env->segs[R_SS].base + old_esp;
ss = (ss & ~3) | dpl;
cpu_x86_load_seg_cache(env, R_SS, ss,
get_seg_base(ss_e1, ss_e2),
get_seg_limit(ss_e1, ss_e2),
ss_e2);
if (!(env->segs[R_SS].flags & DESC_B_MASK))
sp &= 0xffff;
ssp = env->segs[R_SS].base + sp;
if (shift) {
ssp -= 4;
stl_kernel(ssp, old_ss);
ssp -= 4;
stl_kernel(ssp, old_esp);
ssp -= 4 * param_count;
for(i = 0; i < param_count; i++) {
val = ldl_kernel(old_ssp + i * 4);
stl_kernel(ssp + i * 4, val);
}
} else {
ssp -= 2;
stw_kernel(ssp, old_ss);
ssp -= 2;
stw_kernel(ssp, old_esp);
ssp -= 2 * param_count;
for(i = 0; i < param_count; i++) {
val = lduw_kernel(old_ssp + i * 2);
stw_kernel(ssp + i * 2, val);
}
}
} else {
if (!(env->segs[R_SS].flags & DESC_B_MASK))
sp &= 0xffff;
ssp = env->segs[R_SS].base + sp;
push_size = (4 << shift);
}
if (shift) {
ssp -= 4;
stl_kernel(ssp, env->segs[R_CS].selector);
ssp -= 4;
stl_kernel(ssp, next_eip);
} else {
ssp -= 2;
stw_kernel(ssp, env->segs[R_CS].selector);
ssp -= 2;
stw_kernel(ssp, next_eip);
}
sp -= push_size;
selector = (selector & ~3) | dpl;
cpu_x86_load_seg_cache(env, R_CS, selector,
get_seg_base(e1, e2),
get_seg_limit(e1, e2),
e2);
cpu_x86_set_cpl(env, dpl);
if (!(env->segs[R_SS].flags & DESC_B_MASK))
ESP = (ESP & 0xffff0000) | (sp & 0xffff);
else
ESP = sp;
EIP = offset;
}
}
| 1threat
|
Cookies vs. Web storage : <p>I am creating a project where I want to save the last level that the user reached so they can continue where they leave off the next time. I am wondering whether I should use cookies or web storage, and the reasons for using each one. For example, does one affect performance, is one commonly enabled/disabled, is one not supported by modern browsers, etc.</p>
<p>I am also interested in knowing whether there are other options besides these two that I could use instead, and what the advantages and disadvantages to those are.</p>
<p>Thank you!</p>
| 0debug
|
def decimal_To_Binary(N):
B_Number = 0
cnt = 0
while (N != 0):
rem = N % 2
c = pow(10,cnt)
B_Number += rem*c
N //= 2
cnt += 1
return B_Number
| 0debug
|
TextArea in Tabs component antd text not rendering : I am using antd with React and have the following code:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
<Tabs type="card">
<TabPane tab="Summary" key="1">
<TextArea name="Name"
rows={4}
style={{marginBottom: '10px'}}
defaultValue={"DefaultValue"}/>
</TabPane>
<TabPane tab="Description" key="2">
<TextArea name="Name"
rows={4}
style={{marginBottom: '10px'}}
defaultValue={"DefaultValue"}/>
</TabPane>
</Tabs>
<!-- language: lang-html -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<!-- end snippet -->
In the defaultValue props I am rendering values from props. But only the second text area renders the value I send from props and the first TextArea remains blank. If I set value instead of defaultValue it works but I can't edit the text inside it. What is the problem?
| 0debug
|
static int parse_vtrk(AVFormatContext *s,
FourxmDemuxContext *fourxm, uint8_t *buf, int size)
{
AVStream *st;
if (size != vtrk_SIZE) {
return AVERROR_INVALIDDATA;
}
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 60, 1, fourxm->fps);
fourxm->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_4XM;
st->codec->extradata_size = 4;
st->codec->extradata = av_malloc(4);
AV_WL32(st->codec->extradata, AV_RL32(buf + 16));
st->codec->width = AV_RL32(buf + 36);
st->codec->height = AV_RL32(buf + 40);
return 0;
}
| 1threat
|
Validation for digit only at EditText Android - Java : I am trying to make a simple functionality which the user insert 2 numbers and a toast present the sum...
First, in order to do so, I would like to verify the user insert only digits. If not, i would like to set toast massage (error) explains that only digits allows here. I use a boolean isdigit (EditText input) method.
However I get an error -maybe because the for loop can not accept null?
public class MainActivity extends AppCompatActivity {
private EditText firstIntCB, secundIntCB;
private Button getProductCB;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
addDataToDisplay();
}
public void addDataToDisplay() {
if (isdigit(firstIntCB)==true && isdigit(secundIntCB)==true){
firstIntCB = (EditText)findViewById(R.id.firstNumber);
secundIntCB = (EditText)findViewById(R.id.secundNumber);
getProductCB =(Button)findViewById(R.id.GetProduct);
getProductCB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Integer intFirst = Integer.parseInt(firstIntCB.getText().toString());
Integer intSec = Integer.parseInt(secundIntCB.getText().toString());
String product = Integer.toString((int)Math.pow(intFirst,intSec));
Toast.makeText
(getApplicationContext(),String.valueOf(product), Toast.LENGTH_LONG).show();
}
});
}
}
public boolean isdigit(EditText input) {
String data=input.getText().toString().trim();
for(int i=0;i<data.length();i++)
{
if (!Character.isDigit(data.charAt(i)))
return false;
}
return true;
}
| 0debug
|
Pass parameter to Partial View in ASP.NET Core : <p>On an ASP.NET Core 2.0 application I need to render a partial view and pass a few parameters:</p>
<pre><code>@Html.Partial("Form", new { File = "file.pdf" })
</code></pre>
<p>On the partial view I tried to access it using:</p>
<pre><code>@Model.File
</code></pre>
<p>And I get the error:</p>
<pre><code>RuntimeBinderException: 'object' does not contain a definition for 'File'
</code></pre>
<p>If I simply use on my partial:</p>
<pre><code>@Model
</code></pre>
<p>I get the following printed on the page:</p>
<pre><code>{ File = file.pdf }
</code></pre>
<p>So there the model is being passed and there is a property File in it.</p>
<p>So what am I missing?</p>
| 0debug
|
Will a NULL string get malloced? : I have a function that accepts a char pointer. In the function the pointer gets malloced. I sent in NULL as the argument in one instance and it didnt create any compiler warnings. I am confused as to why this is? I expected it to do so. I also did not free anything.
| 0debug
|
I can not figure out how to let my classes use Information from each other : <p>Within my code I am trying to get the Customer class to use the Address I have created as well as the Company class to use the Address I created I cannot Figure it out.</p>
<pre><code>class Program
{
public static void Main()
{
var address = new Address("56 Main St", "Mesa", "AZ", "38574");
}
}
public class Address
{
public string Street { get; set; }
public string City { get; set; }
public string State { get; set; }
public string ZipCode { get; set; }
public Address(string Street, string City, string State, string ZipCode)
{
}
}
public class Customer
{
public long Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public Customer(string FirstName, string LastName)
{
}
}
public class Company
{
public string CompanyName { get; set; }
}
}
</code></pre>
| 0debug
|
Which one is the fastest beween Set and Maps in Java? : <p>Which structure should I use if I need to have several operations of add and remove items into my collection? I need to have the quickest result, and obviously the most efficent one</p>
| 0debug
|
unfortunately android application is stoped : I want to make a login program in android. I write a code for login program. In this program username and password is send to server for authentication. But when i open the app and enter username and password and click on LoiIn button my application unfortunately stopped. But username and password will sent to server.Than means my application will stopped when i click on Login button.Here is my code.
public class LogIn extends Activity implements View.OnClickListener{
private Socket socket;
private DataOutputStream out;
private DataInputStream in;
private String username,password,s;
EditText eT_username,eT_password;
Button b_login,b_signup,b_connect;
TextView t;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_log_in);
eT_username = (EditText)findViewById(R.id.eT_username);
eT_password = (EditText)findViewById(R.id.eT_password);
b_login = (Button)findViewById(R.id.b_login);
b_signup = (Button)findViewById(R.id.b_signup);
b_connect = (Button)findViewById(R.id.b_connect);
t = (TextView)findViewById(R.id.tV);
b_login.setOnClickListener(this);
}
@Override
public void onClick(View v) {
String toast_msg;
try {
out = new DataOutputStream(socket.getOutputStream());
in = new DataInputStream(socket.getInputStream());
out.writeUTF("1");
username = eT_username.getText().toString();
password = eT_password.getText().toString();
out.writeUTF(username);
// out.flush();
out.writeUTF(password);
// out.flush();
t.setText("hi");
s = in.readUTF();
if (s.equals("ok")) {
toast_msg = "Login is successfull";
t.setText(toast_msg);
} else {
toast_msg = "username or password is incorrect";
t.setText(toast_msg);
}
} catch (IOException e) {
t.setText(e.toString());
}
}
public void connect(View v)
{
new Thread(new Runnable() {
@Override
public void run() {
try
{
socket = new Socket("192.168.0.101",5000);
}
catch(Exception e)
{
TextView t = (TextView)findViewById(R.id.textView);
t.setText(e.toString());
// Toast.makeText(LogIn.this,"Make sure that you are connected to Internet",Toast.LENGTH_LONG).show();
}
}
}).start();
}
public void openSignUp(View v)
{
if (v.getId()== R.id.b_signup)
{
Intent i = new Intent(LogIn.this,SignUp.class);
startActivity(i);
}
new SignUp(socket);
}
}
| 0debug
|
How can i have good quality when i get pics with glide? : hello i wan't to create profil user, i use firebase to make authentification and get profil picture but when i get profil picture to create the profil user the picture is very bad quality
I use Glide for get profil picture
Glide.with(this)
.load(this.getCurrentUser().getPhotoUrl())
.apply(RequestOptions.circleCropTransform())
.into(imageViewProfile);
My Image view :
<ImageView
android:id="@+id/imageView"
android:layout_width="113dp"
android:layout_height="102dp"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="8dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
How can i fix it ? i already try to use Picasso but that Don't work
Thanks
| 0debug
|
Flutter: Trying to bottom-center an item in a Column, but it keeps left-aligning : <p>I'm trying to bottom-center a widget at the bottom of a Column, but it keeps aligning to the left.</p>
<pre><code>return new Column(
new Stack(
new Positioned(
bottom: 0.0,
new Center(
new Container(),
),
),
),
);
</code></pre>
<p>The existence of the Positioned forces the Container to the left, instead of centering. Removing the Positioned, however, puts the Container in the middle-center.</p>
| 0debug
|
Testing progress bar on Android with Espresso : <p>The workflow should be the following:</p>
<ol>
<li>Activity starts</li>
<li>Progress bar is visible</li>
<li>Network request fires (idling resource is already registered so espresso knows how to wait for it).</li>
<li>Progress bar is hidden</li>
<li>Text from network is shown.</li>
</ol>
<p>Up to this point, I have written assertions for steps <strong>1, 3, 5</strong> and it works perfectly:</p>
<pre><code>onView(withText("foo 1"))
.check(matches(isDisplayed()));
</code></pre>
<p>Problem is, I have no idea how to let espresso know to verify the visibility of progress bar <strong>before</strong> the request is made and <strong>after</strong> the request is made.</p>
<p>Consider the <code>onCreate()</code> method is the following:</p>
<pre><code>super.onCreate(...);
setContentView(...);
showProgressBar(true);
apiClient.getStuff(new Callback() {
public void onSuccess() {
showProgressBar(false);
}
});
</code></pre>
<p>I have tried the following but it doesn't work:</p>
<pre><code>// Activity is launched at this point.
activityRule.launchActivity(new Intent());
// Up to this point, the request has been fired and response was
// returned, so the progress bar is now GONE.
onView(withId(R.id.progress_bar))
.check(matches(isDisplayed()));
onView(withId(R.id.progress_bar))
.check(matches(not(isDisplayed())));
</code></pre>
<p>The reason this is happening is because, since the client is registered as an idling resource, espresso will wait until it is <strong>idle</strong> again before running the first <code>onView(...progressbar...)...</code> so I need a way to let espresso know to run that <em>BEFORE</em> going to idle.</p>
<p><strong>EDIT:</strong> this doesn't work either:</p>
<pre><code>idlingResource.registerIdleTransitionCallback(new IdlingResource.ResourceCallback() {
@Override
public void onTransitionToIdle() {
onView(withId(R.id.progress_bar))
.check(matches(isDisplayed()));
}
});
</code></pre>
| 0debug
|
Find and return the sum of all elements of array which are either divisible by 2 or 3 : <p>I am new to programming and whenever I run this code I am getting a runtime error[NZEC].I dont know how to fix the error </p>
<pre><code>import java.util.Scanner;
public class divi2or3 {
public static int findSum(int arr[])
{
Scanner s = new Scanner(System.in);
int n = s.nextInt();
for(int i=0;i<n;i++){
arr[i] = s.nextInt();
}
int sum=0;
for(int j=0;j<n;j++)
{
if(arr[j]%2==0 || arr[j]%3==0){
sum = sum + arr[j];
}
}
s.close();
return sum;
}
}
</code></pre>
| 0debug
|
Sort a matrix by the sum of the rows C++ : Heyy, I am new to programming, so can you help me finish my program? I have to sort the matrix by the sum of the rows, the smallets sum has to be first and the the bigger and at the end has to be the biggest sum.
I have done this but I cant finish it:
#include <iostream>
using namespace std;
int main ()
{
int **matrix;
int i, j, count, row, col, sum, temp;
cout << "\n Enter the number of rows and columns";
cin >> row >> col;
matrix = new int *[row];
for (count = 0; count < row; count++)
matrix[count] = new int[col];
cout << "\nNow enter the element for the matrix.";
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
cout << "\nRow " << (i + 1) << " Col " << (j + 1) << " :";
cin >> *(*(matrix + i) + j);
}
}
for (i = 0; i < row; i++)
{
sum = 0;
for (j = 0; j < col; j++)
sum = sum + matrix[i][j];
cout << sum << endl;
}
for (int count = 0; count < row; count++)
delete[]matrix[count];
delete[]matrix;
matrix = 0;
return 0;
}
| 0debug
|
static XICSState *xics_system_init(int nr_servers, int nr_irqs)
{
XICSState *icp = NULL;
if (kvm_enabled()) {
QemuOpts *machine_opts = qemu_get_machine_opts();
bool irqchip_allowed = qemu_opt_get_bool(machine_opts,
"kernel_irqchip", true);
bool irqchip_required = qemu_opt_get_bool(machine_opts,
"kernel_irqchip", false);
Error *err = NULL;
if (irqchip_allowed) {
icp = try_create_xics(TYPE_KVM_XICS, nr_servers, nr_irqs, &err);
}
if (irqchip_required && !icp) {
error_report("kernel_irqchip requested but unavailable: %s",
error_get_pretty(err));
}
}
if (!icp) {
icp = try_create_xics(TYPE_XICS, nr_servers, nr_irqs, &error_abort);
}
return icp;
}
| 1threat
|
Difference between IAM role and IAM user in AWS : <p>What is the difference between an IAM role and an IAM user? The <a href="https://aws.amazon.com/iam/faqs/" rel="noreferrer">IAM FAQ</a> has an entry explaining it, but it was vague and not very clear:</p>
<blockquote>
<p>An IAM user has permanent long-term credentials and is used to directly interact with AWS services. An IAM role does not have any credentials and cannot make direct requests to AWS services. IAM roles are meant to be assumed by authorized entities, such as IAM users, applications, or an AWS service such as EC2.</p>
</blockquote>
<p>I think an IAM role is used for federated logins (using an IdP with SAML tokens for example), and they don't have permanent access keys that you can download like regular IAM users have (the "an IAM role doesn't have any credentials" part).</p>
<p>What do they mean when they say an IAM role can't make direct requests to AWS services? I can login to AWS Console (the web console) and create stacks etc, so it can't be that.</p>
| 0debug
|
JavaScript fetch API - Why does response.json() return a promise object (instead of JSON)? : <p>I've just started to learn the Fetch API: <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch" rel="noreferrer">https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch</a></p>
<p>Here's a code snippet which I wrote to tinker around with it:</p>
<pre><code>fetch('http://swapi.co/api/people/1')
.then(function(response) {
var json = response.json();
console.log(json);
// Expected : { "name": "Luke Skywalker","height": "1.72 m", ... }
// Get : Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
});
</code></pre>
<p>I would have expected to get an JSON object out of response.json().</p>
<p>Similar to what you get when using JSON.parse(). </p>
<p>Instead I get a promise object. </p>
<p>If I enlarge the promise chain like shown here ... </p>
<pre><code>return response.json().then(function(json) {
// process your JSON further
});
</code></pre>
<p>... then it works: Within the then method of the following promise it appears as json.</p>
<p><strong>Why can't I retrieve the JSON data within the then() of the first promise?</strong></p>
<p>Can anyone please explain what is going on here?</p>
<p>I would really much appreciate it.</p>
| 0debug
|
Starting up Project : Should you start to develop first in Android or iOS? : <p>When making Mobile Projects that support iOS and Android Platform Native and your a solo developer.</p>
<p>Is it good to start in iOS version first before making an Android version? </p>
<p>or</p>
<p>Is it good to start on Android version first before making iOS?</p>
<p>Any comment or good strategy on this?? It will help me to create a Timeline when making an apps. </p>
<p>Thanks in advance.. </p>
| 0debug
|
PHP: array declaration causes Error 500 : <p>I encountered a strange problem today: this simple code it's causing error 500.</p>
<pre><code>$ret = array();
$ret["lat"] = array():
</code></pre>
<p>it looks like doing anything wit <code>$ret</code> after is has been declared causes the error. I also tried:</p>
<pre><code>$ret = array("lat" => array(), "lon" => array());
$ret["lat"][0] = 3:
$ret = array();
$ret["lat"][0] = 3:
$ret = array();
$ret[] = 3:
</code></pre>
<p>and other stuff I could think of. I've alway did such things, can't understand why it's not working here. Any idea?</p>
| 0debug
|
static void dec_barrel(DisasContext *dc)
{
TCGv t0;
unsigned int s, t;
if ((dc->tb_flags & MSR_EE_FLAG)
&& !(dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)
&& !(dc->env->pvr.regs[0] & PVR0_USE_BARREL_MASK)) {
tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP);
t_gen_raise_exception(dc, EXCP_HW_EXCP);
return;
}
s = dc->imm & (1 << 10);
t = dc->imm & (1 << 9);
LOG_DIS("bs%s%s r%d r%d r%d\n",
s ? "l" : "r", t ? "a" : "l", dc->rd, dc->ra, dc->rb);
t0 = tcg_temp_new();
tcg_gen_mov_tl(t0, *(dec_alu_op_b(dc)));
tcg_gen_andi_tl(t0, t0, 31);
if (s)
tcg_gen_shl_tl(cpu_R[dc->rd], cpu_R[dc->ra], t0);
else {
if (t)
tcg_gen_sar_tl(cpu_R[dc->rd], cpu_R[dc->ra], t0);
else
tcg_gen_shr_tl(cpu_R[dc->rd], cpu_R[dc->ra], t0);
}
}
| 1threat
|
how to create a view using two tables in different schemas in ibm db2 : I have got two tables T1 and T2 . T1 is present in schema S1 and T2 is present in schema S2. I am using DB2 database. I also have two queries for fetching data from T1 and T2 respectively.
Now, I have a requirement where I need to create a view and get the combined data of two queries in that view.
I have searched a lot on internet for creating a view on different schemas in DB2, but couldn't get a right solution.
Please help.
| 0debug
|
def extract_singly(test_list):
res = []
temp = set()
for inner in test_list:
for ele in inner:
if not ele in temp:
temp.add(ele)
res.append(ele)
return (res)
| 0debug
|
String Values is geting the values from the other string : I'm having problem on string values, im generating on the funcion "gerarconta" that make random numbers for the following variables:
"cb->cocom[numcontas].senha" with 4 numbers as caracters, "cb->cocom[numcontas].agencia" and "cb->cocom[numcontas].numconta" with 3 caracters.
The problem is that the value of the first is saving on the other variables for exemplo :
cb->cocom[numcontas].senha = 1213
cb->cocom[numcontas].agencia = 545
cb->cocom[numcontas].numconta = 187545
an this happens everytime i use printf.
```
//AEP 30/04/2019
//Algoritmo para um sistema bancário
//Created by Jordão Qualho da silva
//.
//Last Update 16/04/2019 21:37
//------------------------------------------------------------------------------
//Bibliotecas
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <windows.h>
#include <locale.h>
#include <math.h>
#include <conio.h>
//------------------------------------------------------------------------------
int num=0; //numero de pessoas inseridas
int numcontas=0; //numero de contas inseridas
int tipoconta=-1; //-1=inicio 0=comum 1=especial 2=poupanca
//------------------------------------------------------------------------------
void gotoxy(int x, int y){
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),(COORD){x-1,y-1});
//muda o cursor para a posição x,y
}
//------------------------------------------------------------------------------
void fazerjanela (int ci,int li,int lf,int cf){
//faz uma janela c=coluna l=linha i=incial f=final
int i,y;
for ( i = ci+1; i < cf; i++) {
gotoxy(i,ci);printf("%c",196 );
}
for ( i = ci+1; i < cf; i++) {
gotoxy(i,lf);printf("%c",196 );
}
for ( i = li; i < lf; i++) {
gotoxy(ci,i);printf("%c",179 );
}
for ( i = li; i < lf; i++) {
gotoxy(cf,i);printf("%c",179 );
}
gotoxy(ci,li);printf("%c",218 );
gotoxy(cf,lf);printf("%c",217 );
gotoxy(cf,li);printf("%c", 191);
gotoxy(ci,lf);printf("%c", 192);
gotoxy(cf,lf+1);printf("\n");
}
//------------------------------------------------------------------------------
typedef struct Pessoa{
char nome [100];
char endereco [100];
char telefone [12];
float renda;
int tipopessoa; //1=fisica e 2=Juridica
char cpf [20],cnpj [20];
}pe;
typedef struct Historico{
char numconta [10];//verificar depois
char data [8];
char tipodoc [20];
float valor;
}hist;
typedef struct Contacomum{
char senha [4];
char numconta [3];
char agencia [3];
float saldo;
hist historicos [100];
pe pessoas [100];
int pessoa;
}cc;
typedef struct Contaespecial{
char senha [50];
char numconta [10];
char agencia [10];
float saldo;
hist historicos [100];
pe pessoas [100];
int pessoa;
float limite;
}ce;
typedef struct contapoupanca{
char senha [50];
char numconta [10];
char agencia [10];
float saldo;
hist historicos [100];
pe pessoas [100];
int pessoa;
}cp;
typedef struct contabancaria{
cp copou [20];
ce coesp [20];
cc cocom [20];
}cb;
//------------------------------------------------------------------------------
void gerarconta (cb *cb){
int i=0;
//semente para o numero randomico com o tempo do sistema atual
srand((unsigned)time(NULL));
FILE *arq;
arq = fopen("Contas.txt","w");
if (tipoconta==0) {
//gerando senha de 4 digitos aleatoria
for ( i = 0; i < 4; i++) {
cb->cocom[numcontas].senha[i]=48+(rand()%10);
}gotoxy (5,5); printf("%s",cb->cocom[numcontas].senha);
for ( i = 0; i < 3; i++) {
cb->cocom[numcontas].agencia[i]=48+(rand()%10);
}gotoxy (5,6); printf("%s",cb->cocom[numcontas].agencia);
for ( i = 0; i < 3; i++) {
cb->cocom[numcontas].numconta[i]=48+(rand()%10);
}gotoxy (5,7); printf("%s",cb->cocom[numcontas].numconta);
gotoxy (20,5); printf("%s",cb->cocom[numcontas].senha);
gotoxy (20,6); printf("%s",cb->cocom[numcontas].agencia);
gotoxy (20,7); printf("%s",cb->cocom[numcontas].numconta);
getch();
/*fprintf(arq,"%s %s %s",
cb->cocom[numcontas].senha,
cb->cocom[numcontas].agencia,
cb->cocom[numcontas].numconta);fclose (arq);*/
}
if (tipoconta==1) {
for ( i = 0; i < 4; i++) {
cb->coesp[numcontas].senha[i]=rand()%10;
}
for ( i = 0; i < 3; i++) {
cb->coesp[numcontas].agencia[i]=rand()%10;
}
for ( i = 0; i < 3; i++) {
cb->coesp[numcontas].numconta[i]=rand()%10;
}
}
if (tipoconta==2) {
for ( i = 0; i < 4; i++) {
cb->copou[numcontas].senha[i]=rand()%10;
}
for ( i = 0; i < 3; i++) {
cb->copou[numcontas].agencia[i]=rand()%10;
}
for ( i = 0; i < 3; i++) {
cb->copou[numcontas].numconta[i]=rand()%10;
}
}
}
//------------------------------------------------------------------------------
void transformarnome (char *nome){
int i,tam;
tam = strlen (nome);
for (i = 0; i < tam; i++) {
if (nome [i] == '.') {
nome[i]=' ';
}
}
}
//------------------------------------------------------------------------------
void transformarnomevolta (char *nome){
int i,tam;
tam = strlen (nome);
for (i = 0; i < tam; i++) {
if (nome [i] == ' ') {
nome[i]='.';
}
}
}
//------------------------------------------------------------------------------
void transformarCPF (char *cpf){
int i,tam;
cpf[13]=cpf[10];cpf[12]=cpf[9];cpf[11]='-';
cpf[10]=cpf[8]; cpf[9]=cpf[7]; cpf[8]=cpf[6];cpf[7]='.';
cpf[6]=cpf[5]; cpf[5]=cpf[4]; cpf[4]=cpf[3];cpf[3]='.';
}
//------------------------------------------------------------------------------
void criarpessoafisica (cb *cb){
int tam, flag=0;
FILE *arq; int i=0;
arq = fopen("Pessoas.txt","a");
cb->cocom[numcontas].pessoas[num].tipopessoa = 1;
system("cls"); fazerjanela(1,1,15,50);
gotoxy (15,2); printf("Cadastro de Pessoa Fisica");
gotoxy (3,4); printf("Pesssoa N00%i ", num+1);
gotoxy (3,6); printf("Nome: ");fflush (stdin);
scanf("%[^\n]s", &cb->cocom[numcontas].pessoas[num].nome);
gotoxy (3,7); printf("Endereco: ");fflush (stdin);
scanf("%[^\n]s", &cb->cocom[numcontas].pessoas[num].endereco );
gotoxy (3,8); printf("Telefone: ");fflush (stdin);
scanf("%[^\n]s", &cb->cocom[numcontas].pessoas[num].telefone );
gotoxy (3,9); printf("Renda Mensal: ");fflush (stdin);
scanf("%f", &cb->cocom[numcontas].pessoas[num].renda );
do {
gotoxy (3,12); printf(" ");
gotoxy (3,14); printf(" ");
gotoxy (3,10); printf(" ");
gotoxy (3,10); printf("CPF: ");fflush (stdin);
scanf("%[^\n]s", &cb->cocom[numcontas].pessoas[num].cpf );
tam = strlen (cb->cocom[numcontas].pessoas[num].cpf);
if (tam != 11) {
gotoxy (3,12); printf("Error 404: CPF Invalido !");
gotoxy (3,14); system ("PAUSE");
flag=1;
}else{
flag=0;
}
} while(flag);
gotoxy (3,12); printf("Pessoa cadastrada com sucesso !");
gotoxy (3,14); system("PAUSE"); system ("cls");
transformarnomevolta (&cb->cocom[numcontas].pessoas[num].nome);
transformarnomevolta (&cb->cocom[numcontas].pessoas[num].endereco);
transformarCPF(&cb->cocom[numcontas].pessoas[num].cpf );
fprintf(arq,"\n%s %s %s %.1f %s %i",
cb->cocom[numcontas].pessoas[num].nome,
cb->cocom[numcontas].pessoas[num].endereco,
cb->cocom[numcontas].pessoas[num].telefone,
cb->cocom[numcontas].pessoas[num].renda,
cb->cocom[numcontas].pessoas[num].cpf,
cb->cocom[numcontas].pessoas[num].tipopessoa);
fclose (arq);
}
//------------------------------------------------------------------------------
void criarpessoajuridica (cb *cb) {
int tam, flag=0;
FILE *arq; int i=0;
arq = fopen("Pessoas.txt","a");
cb->cocom[numcontas].pessoas[num].tipopessoa = 2;
system("cls"); fazerjanela(1,1,15,50);
gotoxy (15,2); printf("Cadastro de Pessoa Juridica");
gotoxy (3,4); printf("Pesssoa N000%i ", num+1);
gotoxy (3,6); printf("Nome: ");fflush (stdin);
scanf("%[^\n]s", &cb->cocom[numcontas].pessoas[num].nome);
gotoxy (3,7); printf("Endereco: ");fflush (stdin);
scanf("%[^\n]s", &cb->cocom[numcontas].pessoas[num].endereco );
gotoxy (3,8); printf("Telefone: ");fflush (stdin);
scanf("%[^\n]s", &cb->cocom[numcontas].pessoas[num].telefone );
gotoxy (3,9); printf("Renda Mensal: ");fflush (stdin);
scanf("%f", &cb->cocom[numcontas].pessoas[num].renda );
gotoxy (3,10); printf("CNPJ: ");fflush (stdin);
scanf("%%[^\n]s", &cb->cocom[numcontas].pessoas[num].cnpj );
gotoxy (3,12); printf("Pessoa cadastrada com sucesso !");
gotoxy (3,14); system("PAUSE"); system ("cls");
fprintf(arq,"%s %s %s %f %s",
cb->cocom[numcontas].pessoas[num].nome,
cb->cocom[numcontas].pessoas[num].endereco,
cb->cocom[numcontas].pessoas[num].telefone,
cb->cocom[numcontas].pessoas[num].renda,
cb->cocom[numcontas].pessoas[num].cnpj,
cb->cocom[numcontas].pessoas[num].tipopessoa);
num++;
}
//------------------------------------------------------------------------------
void cadastrarpessoa (cb *cb){
int pos1=1;
char opc;
do{
system("cls"); fazerjanela (1,1,15,50);
gotoxy (6,5); printf("Que tipo de pessoa deseja cadastrar ?");
gotoxy (6,8); printf(" Pessoa Fisica");
gotoxy (25,8); printf(" Pessoa Juridica");
gotoxy (40,14);printf(" Voltar");
switch (pos1){
case 1: gotoxy(6,8); printf("-> Pessoa Fisica");break;
case 2: gotoxy(25,8); printf("-> Pessoa Juridica");break;
case 3: gotoxy(40,14); printf("-> Voltar");break;
}
opc=getch();
if (opc==-32){ //tecla especial necessita pegar segundo valor
opc=getch();
switch (opc) {
case 75:pos1--; break; //SETA PRA CIMA
case 77:pos1++; break; //SETA PRA BAIXO
}
}
if (pos1==0) pos1=3;
if (pos1==4) pos1=1;
if (opc == 13) //ENTER
switch (pos1){
case 1:
criarpessoafisica (&cb);
opc=27;
break;
case 2:
criarpessoajuridica (&cb);
opc=27;
break;
case 3:
opc=27;
break;
}
}
while (opc!=27);
}
//------------------------------------------------------------------------------
void criarcontacomum(cb *cb){
int pos1=1;
char opc;
tipoconta = 0;
do{
system ("cls"); fazerjanela(1,1,15,50);
gotoxy (2,4); printf("-----------------(Conta Comum)------------------");
gotoxy (5,7); printf(" Cadastrar Nova Pessoa ");
gotoxy (5,9); printf(" Usar Pessoa Existente ");
gotoxy (2,12); printf("------------------------------------------------");
gotoxy (42,14); printf(" Sair");
switch (pos1){
case 1: gotoxy(5,7); printf("-> Cadastrar Nova Pessoa "); break;
case 2: gotoxy(5,9); printf("-> Usar Pessoa Existente "); break;
case 3: gotoxy(42,14);printf("-> Sair"); break;
}
opc=getch();
if (opc==-32){ //tecla especial necessita pegar segundo valor
opc=getch();
switch (opc) {
case 72:pos1--; break; //SETA PRA CIMA
case 80:pos1++; break; //SETA PRA BAIXO
}
}
if (pos1==0) pos1=3;
if (pos1==4) pos1=1;
if (opc == 13) //ENTER
switch (pos1){
case 1:
cadastrarpessoa (&cb);
gerarconta (&cb);
num++; numcontas ++;
break;
case 2:
break;
case 3:
opc=27;
break;
}
}
while (opc!=27);
}
//------------------------------------------------------------------------------
void criarcontaespecial(cb *cb){
}
//------------------------------------------------------------------------------
void criarcontapoupanca(cb *cb){
}
//------------------------------------------------------------------------------
void criarconta(cb *cb) {
int pos1=1;
char opc ;
do{
system ("cls"); fazerjanela(1,1,15,50);
gotoxy (2,4); printf("--------------------(Conta)---------------------");
gotoxy (5,6); printf(" Conta Comum ");
gotoxy (5,8); printf(" Conta Especial ");
gotoxy (5,10); printf(" Conta Poupanca ");
gotoxy (2,12); printf("------------------------------------------------");
gotoxy (42,14); printf(" Sair");
switch (pos1){
case 1: gotoxy(5,6); printf("-> Conta Comum"); break;
case 2: gotoxy(5,8); printf("-> Conta Especial"); break;
case 3: gotoxy(5,10); printf("-> Conta Poupanca" ); break;
case 4: gotoxy(42,14);printf("-> Sair"); break;
}
opc=getch();
if (opc==-32){ //tecla especial necessita pegar segundo valor
opc=getch();
switch (opc) {
case 72:pos1--; break; //SETA PRA CIMA
case 80:pos1++; break; //SETA PRA BAIXO
}
}
if (pos1==0) pos1=4;
if (pos1==5) pos1=1;
if (opc == 13) //ENTER
switch (pos1){
case 1:
criarcontacomum (&cb);
break;
case 2:
criarcontaespecial (&cb);
break;
case 3:
criarcontapoupanca (&cb);
case 4:
opc=27;
break;
}
}
while (opc!=27);
}
//------------------------------------------------------------------------------
void acessarconta(cb *cb){
}
//------------------------------------------------------------------------------
/*void lerarquivo (cb *cb){
FILE *arq; int i=0;
arq = fopen("Pessoas.txt","r");
system ("cls");
while ( !feof(arq)) {
fscanf(arq,"%s" "%s" "%f" "%s",&cb->contacomum[0]->pessoas[i].nome,&cb->contacomum[0]->pessoas[i].endereco,&cb->contacomum[0]->pessoas[i].renda,&cb->contacomum[0]->pessoas[i].cpf);
transformarnome (&cb->contacomum[0]->pessoas[i].nome);
transformarnome (&cb->contacomum[0]->pessoas[i].endereco);
i++;num++;
}
}*/
//------------------------------------------------------------------------------
/*void procurarpessoa (cb *cb){
int opcao,i,col=5;
if (num > 0) {
system ("cls");
fazerjanela(1,1,15,50);
gotoxy (13,2); printf("Pessoas Inseridas: %i", num-1);
for ( i = 0; i < num; i++) {
gotoxy (3,(i+4)); printf("%i. %s",(i+1),cb->pessoas[i].nome);
}
gotoxy (3,(i+5)); printf("Insira o numero da pessoa que desja editar: " );
fflush (stdin);scanf("%i", &opcao);
system ("cls");
fazerjanela(1,1,12,50);
opcao=opcao-1;
gotoxy (16,3); printf("Pesssoa Fisica N00%i ", opcao+1);
gotoxy (3,6); printf(" Nome: %s", cb->pessoas[opcao].nome);
gotoxy (3,7); printf("Endereco: %s", cb->pessoas[opcao].endereco );
gotoxy (3,8); printf(" Renda: %.1f", cb->pessoas[opcao].renda );
gotoxy (3,9); printf(" CPF: %s", cb->pessoas[opcao].cpf );
gotoxy (3,11); system ("PAUSE");
}
}*/
//------------------------------------------------------------------------------
int main() {
system("mode con:cols=50 lines=17");
cb contabancaria;
int pos1=1;
char opc;
//lerarquivo (&contabancaria); //arumar <<<<<<<<<<<<<<<<<<<<<<<<<<<<<------
do{
system("cls"); fazerjanela (1,1,15,50);
gotoxy (2,4); printf("--------------------(Conta)---------------------");
gotoxy (5,8); printf(" Criar ");
gotoxy (31,8); printf(" Acessar ");
gotoxy (2,12); printf("------------------------------------------------");
gotoxy (42,14); printf(" Sair");
switch (pos1){
case 1: gotoxy(5,8); printf("-> Criar"); break;
case 2: gotoxy(31,8); printf("-> Acessar"); break;
case 3: gotoxy(42,14);printf("-> Sair"); break;
}
opc=getch();
if (opc==-32){ //tecla especial necessita pegar segundo valor
opc=getch();
switch (opc) {
case 75:pos1--; break; //SETA PRA ESQUERDA
case 77:pos1++; break; //SETA PRA DIREITA
}
}
if (pos1==0) pos1=3;
if (pos1==4) pos1=1;
if (opc == 13) //ENTER
switch (pos1){
case 1:
criarconta(&contabancaria);
break;
case 2:
acessarconta(&contabancaria);
break;
case 3:
opc=27;
break;
}
}
while (opc!=27);
system("cls");
printf("\nPrograma Finalizado com suscesso !\n");
}
```
| 0debug
|
Change Text in IFrame without JQuery : <p>Weave: <a href="http://kodeweave.sourceforge.net/editor/#f6d9a54288f17fb68a8b234ec364dc41" rel="nofollow">http://kodeweave.sourceforge.net/editor/#f6d9a54288f17fb68a8b234ec364dc41</a></p>
<p>I love JQuery, I do, but just for fun I'd like to learn how to write the following in pure/vanilla JS.</p>
<pre><code>$("iframe").contents().find("<style>").html(cssEditor.value))
</code></pre>
| 0debug
|
static void colored_fputs(int level, int tint, const char *str)
{
if (!*str)
return;
if (use_color < 0)
check_color_terminal();
#if defined(_WIN32) && !defined(__MINGW32CE__) && HAVE_SETCONSOLETEXTATTRIBUTE
if (use_color && level != AV_LOG_INFO/8)
SetConsoleTextAttribute(con, background | color[level]);
fputs(str, stderr);
if (use_color && level != AV_LOG_INFO/8)
SetConsoleTextAttribute(con, attr_orig);
#else
if (use_color == 1 && level != AV_LOG_INFO/8) {
fprintf(stderr,
"\033[%d;3%dm%s\033[0m",
(color[level] >> 4) & 15,
color[level] & 15,
str);
} else if (tint && use_color == 256) {
fprintf(stderr,
"\033[48;5;%dm\033[38;5;%dm%s\033[0m",
(color[level] >> 16) & 0xff,
tint,
str);
} else if (use_color == 256 && level != AV_LOG_INFO/8) {
fprintf(stderr,
"\033[48;5;%dm\033[38;5;%dm%s\033[0m",
(color[level] >> 16) & 0xff,
(color[level] >> 8) & 0xff,
str);
} else
fputs(str, stderr);
#endif
}
| 1threat
|
Is there a way for python to check multiple values? : <p>Is there a way for python to check multiple values for "not equals to"? Like:</p>
<pre><code>if len(dict) != 2 or 4 or 8 or 16 or 32:
do_something()
</code></pre>
| 0debug
|
void SwScale_Init(){
int i;
for(i=0; i<768; i++){
int c= MIN(MAX(i-256, 0), 255);
clip_table[i]=c;
yuvtab_2568[c]= clip_yuvtab_2568[i]=(0x2568*(c-16))+(256<<13);
yuvtab_3343[c]= clip_yuvtab_3343[i]=0x3343*(c-128);
yuvtab_0c92[c]= clip_yuvtab_0c92[i]=-0x0c92*(c-128);
yuvtab_1a1e[c]= clip_yuvtab_1a1e[i]=-0x1a1e*(c-128);
yuvtab_40cf[c]= clip_yuvtab_40cf[i]=0x40cf*(c-128);
}
for(i=0; i<768; i++)
{
int v= clip_table[i];
clip_table16b[i]= v>>3;
clip_table16g[i]= (v<<3)&0x07E0;
clip_table16r[i]= (v<<8)&0xF800;
clip_table15b[i]= v>>3;
clip_table15g[i]= (v<<2)&0x03E0;
clip_table15r[i]= (v<<7)&0x7C00;
}
}
| 1threat
|
Importing Large Data Files into pandas : <p>I have a 1.5 GB .dat file that I need to import as a pandas dataframe, I'm running into memory issues (8GB RAM). How to I break the dat file into chunks to perform analysis?</p>
| 0debug
|
What happened to python's ~ when working with boolean? : <p>In a pandas DataFrame, I have a series of boolean values. In order to filter to rows where the boolean is True, I can use: <code>df[df.column_x]</code></p>
<p>I thought in order to filter to only rows where the column is False, I could use: <code>df[~df.column_x]</code>. I feel like I have done this before, and have seen it as the accepted answer. </p>
<p>However, this fails because <code>~df.column_x</code> converts the values to integers. See below. </p>
<pre><code>import pandas as pd . # version 0.24.2
a = pd.Series(['a', 'a', 'a', 'a', 'b', 'a', 'b', 'b', 'b', 'b'])
b = pd.Series([True, True, True, True, True, False, False, False, False, False], dtype=bool)
c = pd.DataFrame(data=[a, b]).T
c.columns = ['Classification', 'Boolean']```
print(~c.Boolean)
0 -2
1 -2
2 -2
3 -2
4 -2
5 -1
6 -1
7 -1
8 -1
9 -1
Name: Boolean, dtype: object
print(~b)
0 False
1 False
2 False
3 False
4 False
5 True
6 True
7 True
8 True
9 True
dtype: bool
</code></pre>
<p>Basically, I can use <code>c[~b]</code>, but not <code>c[~c.Boolean]</code></p>
<p>Am I just dreaming that this use to work?</p>
| 0debug
|
static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
LibOpenJPEGContext *ctx = avctx->priv_data;
opj_cinfo_t *compress = ctx->compress;
opj_image_t *image = ctx->image;
opj_cio_t *stream = ctx->stream;
int cpyresult = 0;
int ret, len;
AVFrame *gbrframe;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_RGB24:
case AV_PIX_FMT_RGBA:
case AV_PIX_FMT_GRAY8A:
cpyresult = libopenjpeg_copy_packed8(avctx, frame, image);
break;
case AV_PIX_FMT_XYZ12:
cpyresult = libopenjpeg_copy_packed12(avctx, frame, image);
break;
case AV_PIX_FMT_RGB48:
case AV_PIX_FMT_RGBA64:
cpyresult = libopenjpeg_copy_packed16(avctx, frame, image);
break;
case AV_PIX_FMT_GBR24P:
case AV_PIX_FMT_GBRP9:
case AV_PIX_FMT_GBRP10:
case AV_PIX_FMT_GBRP12:
case AV_PIX_FMT_GBRP14:
case AV_PIX_FMT_GBRP16:
gbrframe = av_frame_alloc();
av_frame_ref(gbrframe, frame);
gbrframe->data[0] = frame->data[2];
gbrframe->data[1] = frame->data[0];
gbrframe->data[2] = frame->data[1];
gbrframe->linesize[0] = frame->linesize[2];
gbrframe->linesize[1] = frame->linesize[0];
gbrframe->linesize[2] = frame->linesize[1];
if (avctx->pix_fmt == AV_PIX_FMT_GBR24P) {
cpyresult = libopenjpeg_copy_unpacked8(avctx, gbrframe, image);
} else {
cpyresult = libopenjpeg_copy_unpacked16(avctx, gbrframe, image);
}
av_frame_free(&gbrframe);
break;
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_YUV410P:
case AV_PIX_FMT_YUV411P:
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUV422P:
case AV_PIX_FMT_YUV440P:
case AV_PIX_FMT_YUV444P:
case AV_PIX_FMT_YUVA420P:
case AV_PIX_FMT_YUVA422P:
case AV_PIX_FMT_YUVA444P:
cpyresult = libopenjpeg_copy_unpacked8(avctx, frame, image);
break;
case AV_PIX_FMT_GRAY16:
case AV_PIX_FMT_YUV420P9:
case AV_PIX_FMT_YUV422P9:
case AV_PIX_FMT_YUV444P9:
case AV_PIX_FMT_YUVA420P9:
case AV_PIX_FMT_YUVA422P9:
case AV_PIX_FMT_YUVA444P9:
case AV_PIX_FMT_YUV444P10:
case AV_PIX_FMT_YUV422P10:
case AV_PIX_FMT_YUV420P10:
case AV_PIX_FMT_YUVA444P10:
case AV_PIX_FMT_YUVA422P10:
case AV_PIX_FMT_YUVA420P10:
case AV_PIX_FMT_YUV420P12:
case AV_PIX_FMT_YUV422P12:
case AV_PIX_FMT_YUV444P12:
case AV_PIX_FMT_YUV420P14:
case AV_PIX_FMT_YUV422P14:
case AV_PIX_FMT_YUV444P14:
case AV_PIX_FMT_YUV444P16:
case AV_PIX_FMT_YUV422P16:
case AV_PIX_FMT_YUV420P16:
case AV_PIX_FMT_YUVA444P16:
case AV_PIX_FMT_YUVA422P16:
case AV_PIX_FMT_YUVA420P16:
cpyresult = libopenjpeg_copy_unpacked16(avctx, frame, image);
break;
default:
av_log(avctx, AV_LOG_ERROR,
"The frame's pixel format '%s' is not supported\n",
av_get_pix_fmt_name(avctx->pix_fmt));
return AVERROR(EINVAL);
break;
}
if (!cpyresult) {
av_log(avctx, AV_LOG_ERROR,
"Could not copy the frame data to the internal image buffer\n");
return -1;
}
cio_seek(stream, 0);
if (!opj_encode(compress, stream, image, NULL)) {
av_log(avctx, AV_LOG_ERROR, "Error during the opj encode\n");
return -1;
}
len = cio_tell(stream);
if ((ret = ff_alloc_packet2(avctx, pkt, len)) < 0) {
return ret;
}
memcpy(pkt->data, stream->buffer, len);
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
| 1threat
|
void xtensa_breakpoint_handler(CPUState *cs)
{
XtensaCPU *cpu = XTENSA_CPU(cs);
CPUXtensaState *env = &cpu->env;
if (cs->watchpoint_hit) {
if (cs->watchpoint_hit->flags & BP_CPU) {
uint32_t cause;
cs->watchpoint_hit = NULL;
cause = check_hw_breakpoints(env);
if (cause) {
debug_exception_env(env, cause);
}
cpu_resume_from_signal(cs, NULL);
}
}
}
| 1threat
|
static void test_redirector_rx(void)
{
#ifndef _WIN32
int backend_sock[2], send_sock;
char *cmdline;
uint32_t ret = 0, len = 0;
char send_buf[] = "Hello!!";
char sock_path0[] = "filter-redirector0.XXXXXX";
char sock_path1[] = "filter-redirector1.XXXXXX";
char *recv_buf;
uint32_t size = sizeof(send_buf);
size = htonl(size);
ret = socketpair(PF_UNIX, SOCK_STREAM, 0, backend_sock);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(sock_path0);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(sock_path1);
g_assert_cmpint(ret, !=, -1);
cmdline = g_strdup_printf("-netdev socket,id=qtest-bn0,fd=%d "
"-device rtl8139,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=redirector0,path=%s,server,nowait "
"-chardev socket,id=redirector1,path=%s,server,nowait "
"-chardev socket,id=redirector2,path=%s,nowait "
"-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,"
"queue=rx,indev=redirector0 "
"-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
"queue=rx,outdev=redirector2 "
"-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,"
"queue=rx,indev=redirector1 "
, backend_sock[1], sock_path0, sock_path1, sock_path0);
qtest_start(cmdline);
g_free(cmdline);
struct iovec iov[] = {
{
.iov_base = &size,
.iov_len = sizeof(size),
}, {
.iov_base = send_buf,
.iov_len = sizeof(send_buf),
},
};
send_sock = unix_connect(sock_path1, NULL);
g_assert_cmpint(send_sock, !=, -1);
qmp("{ 'execute' : 'query-status'}");
ret = iov_send(send_sock, iov, 2, 0, sizeof(size) + sizeof(send_buf));
g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));
close(send_sock);
ret = qemu_recv(backend_sock[0], &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
g_assert_cmpint(len, ==, sizeof(send_buf));
recv_buf = g_malloc(len);
ret = qemu_recv(backend_sock[0], recv_buf, len, 0);
g_assert_cmpstr(recv_buf, ==, send_buf);
g_free(recv_buf);
unlink(sock_path0);
unlink(sock_path1);
qtest_end();
#endif
}
| 1threat
|
Genarating time in 5 seconds interval : Hello am kindly asking on how to generate time with a 5 seconds interval where the user selects a date then a specific time interval maybe from 11:00:00 to 12:00:00 then the program generates a record like this
1. date time random number
2. 23/01/2016 11:01:02 030
3. 23/01/2016 11:02:07 035
4. 23/01/2016 11:02:12 054
5. 23/01/2016 11:02:17 062
6. 23/01/2016 11:02:22 058
7. 23/01/2016 11:02:27 056
8. 23/01/2016 12:00:01 059
After it has generated it saves generated values in a plain text file.
| 0debug
|
static void rtc_periodic_timer(void *opaque)
{
RTCState *s = opaque;
rtc_timer_update(s, s->next_periodic_time);
#ifdef TARGET_I386
if ((s->cmos_data[RTC_REG_C] & 0xc0) && rtc_td_hack) {
s->irq_coalesced++;
return;
}
#endif
if (s->cmos_data[RTC_REG_B] & REG_B_PIE) {
s->cmos_data[RTC_REG_C] |= 0xc0;
rtc_irq_raise(s->irq);
}
if (s->cmos_data[RTC_REG_B] & REG_B_SQWE) {
qemu_irq_raise(s->sqw_irq);
}
}
| 1threat
|
static void vga_update_text(void *opaque, console_ch_t *chardata)
{
VGACommonState *s = opaque;
int graphic_mode, i, cursor_offset, cursor_visible;
int cw, cheight, width, height, size, c_min, c_max;
uint32_t *src;
console_ch_t *dst, val;
char msg_buffer[80];
int full_update = 0;
qemu_flush_coalesced_mmio_buffer();
if (!(s->ar_index & 0x20)) {
graphic_mode = GMODE_BLANK;
} else {
graphic_mode = s->gr[VGA_GFX_MISC] & VGA_GR06_GRAPHICS_MODE;
}
if (graphic_mode != s->graphic_mode) {
s->graphic_mode = graphic_mode;
full_update = 1;
}
if (s->last_width == -1) {
s->last_width = 0;
full_update = 1;
}
switch (graphic_mode) {
case GMODE_TEXT:
full_update |= update_basic_params(s);
cheight = (s->cr[VGA_CRTC_MAX_SCAN] & 0x1f) + 1;
cw = 8;
if (!(s->sr[VGA_SEQ_CLOCK_MODE] & VGA_SR01_CHAR_CLK_8DOTS)) {
cw = 9;
}
if (s->sr[VGA_SEQ_CLOCK_MODE] & 0x08) {
cw = 16;
}
width = (s->cr[VGA_CRTC_H_DISP] + 1);
if (s->cr[VGA_CRTC_V_TOTAL] == 100) {
height = 100;
} else {
height = s->cr[VGA_CRTC_V_DISP_END] |
((s->cr[VGA_CRTC_OVERFLOW] & 0x02) << 7) |
((s->cr[VGA_CRTC_OVERFLOW] & 0x40) << 3);
height = (height + 1) / cheight;
}
size = (height * width);
if (size > CH_ATTR_SIZE) {
if (!full_update)
return;
snprintf(msg_buffer, sizeof(msg_buffer), "%i x %i Text mode",
width, height);
break;
}
if (width != s->last_width || height != s->last_height ||
cw != s->last_cw || cheight != s->last_ch) {
s->last_scr_width = width * cw;
s->last_scr_height = height * cheight;
qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height);
dpy_text_resize(s->con, width, height);
s->last_depth = 0;
s->last_width = width;
s->last_height = height;
s->last_ch = cheight;
s->last_cw = cw;
full_update = 1;
}
if (full_update) {
s->full_update_gfx = 1;
}
if (s->full_update_text) {
s->full_update_text = 0;
full_update |= 1;
}
cursor_offset = ((s->cr[VGA_CRTC_CURSOR_HI] << 8) |
s->cr[VGA_CRTC_CURSOR_LO]) - s->start_addr;
if (cursor_offset != s->cursor_offset ||
s->cr[VGA_CRTC_CURSOR_START] != s->cursor_start ||
s->cr[VGA_CRTC_CURSOR_END] != s->cursor_end || full_update) {
cursor_visible = !(s->cr[VGA_CRTC_CURSOR_START] & 0x20);
if (cursor_visible && cursor_offset < size && cursor_offset >= 0)
dpy_text_cursor(s->con,
TEXTMODE_X(cursor_offset),
TEXTMODE_Y(cursor_offset));
else
dpy_text_cursor(s->con, -1, -1);
s->cursor_offset = cursor_offset;
s->cursor_start = s->cr[VGA_CRTC_CURSOR_START];
s->cursor_end = s->cr[VGA_CRTC_CURSOR_END];
}
src = (uint32_t *) s->vram_ptr + s->start_addr;
dst = chardata;
if (full_update) {
for (i = 0; i < size; src ++, dst ++, i ++)
console_write_ch(dst, VMEM2CHTYPE(le32_to_cpu(*src)));
dpy_text_update(s->con, 0, 0, width, height);
} else {
c_max = 0;
for (i = 0; i < size; src ++, dst ++, i ++) {
console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src)));
if (*dst != val) {
*dst = val;
c_max = i;
break;
}
}
c_min = i;
for (; i < size; src ++, dst ++, i ++) {
console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src)));
if (*dst != val) {
*dst = val;
c_max = i;
}
}
if (c_min <= c_max) {
i = TEXTMODE_Y(c_min);
dpy_text_update(s->con, 0, i, width, TEXTMODE_Y(c_max) - i + 1);
}
}
return;
case GMODE_GRAPH:
if (!full_update)
return;
s->get_resolution(s, &width, &height);
snprintf(msg_buffer, sizeof(msg_buffer), "%i x %i Graphic mode",
width, height);
break;
case GMODE_BLANK:
default:
if (!full_update)
return;
snprintf(msg_buffer, sizeof(msg_buffer), "VGA Blank mode");
break;
}
s->last_width = 60;
s->last_height = height = 3;
dpy_text_cursor(s->con, -1, -1);
dpy_text_resize(s->con, s->last_width, height);
for (dst = chardata, i = 0; i < s->last_width * height; i ++)
console_write_ch(dst ++, ' ');
size = strlen(msg_buffer);
width = (s->last_width - size) / 2;
dst = chardata + s->last_width + width;
for (i = 0; i < size; i ++)
console_write_ch(dst ++, 0x00200100 | msg_buffer[i]);
dpy_text_update(s->con, 0, 0, s->last_width, height);
}
| 1threat
|
Unbundle a webpack bundle.js with the SourceMap : <p>I want to reverse or unbundle a bundle.js.
Currently I am loading the bundle.js in my browser (Chrome)
Chrome detects the sourcemap and shows me a nice structure of the
full application based on the bundle. The application is bundled
using webpack and is a flux react application.</p>
<p>Is there a way to generate all these files out of the bundle so I can
easily browse the bundle based on the application structure?</p>
<p>This is for a reverse engineering project to get the application source from
an existing bundle. </p>
<p>So in chrome I can nicely browse the whole application using devtools sources.
and see all the individual files. But I would like to create that exact
same structure on my local drive. </p>
<p>I was trying a tool like <a href="https://www.npmjs.com/package/debundle" rel="noreferrer">debundle</a> But I cannot find a way to add the sourcemap to this conversion?</p>
<p>So can I easily unbundle an existing bundle.js if:</p>
<ul>
<li>Sourcemap is available</li>
<li>Chrome can easily show me the structure and individual files</li>
<li>Bundle is not minified or scrambled.</li>
<li>Bundle is created using webpack</li>
</ul>
| 0debug
|
how to sum up values of single dimentional array having same key in php : <p>For example: if strArr is ["B:-1", "A:1", "B:3", "A:5"] then your program should return the string A:6,B:2.</p>
<p>Your final output string should return the keys in alphabetical order. Exclude keys that have a value of 0 after being summed up.
Examples
Input: array("X:-1", "Y:1", "X:-4", "B:3", "X:5")
Output: B:3,Y:1</p>
| 0debug
|
int ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl)
{
ERContext *er = &sl->er;
int mb_array_size = h->mb_height * h->mb_stride;
int y_size = (2 * h->mb_width + 1) * (2 * h->mb_height + 1);
int c_size = h->mb_stride * (h->mb_height + 1);
int yc_size = y_size + 2 * c_size;
int x, y, i;
sl->ref_cache[0][scan8[5] + 1] =
sl->ref_cache[0][scan8[7] + 1] =
sl->ref_cache[0][scan8[13] + 1] =
sl->ref_cache[1][scan8[5] + 1] =
sl->ref_cache[1][scan8[7] + 1] =
sl->ref_cache[1][scan8[13] + 1] = PART_NOT_AVAILABLE;
if (sl != h->slice_ctx) {
memset(er, 0, sizeof(*er));
} else
if (CONFIG_ERROR_RESILIENCE) {
er->avctx = h->avctx;
er->decode_mb = h264_er_decode_mb;
er->opaque = h;
er->quarter_sample = 1;
er->mb_num = h->mb_num;
er->mb_width = h->mb_width;
er->mb_height = h->mb_height;
er->mb_stride = h->mb_stride;
er->b8_stride = h->mb_width * 2 + 1;
FF_ALLOCZ_OR_GOTO(h->avctx, er->mb_index2xy,
(h->mb_num + 1) * sizeof(int), fail);
for (y = 0; y < h->mb_height; y++)
for (x = 0; x < h->mb_width; x++)
er->mb_index2xy[x + y * h->mb_width] = x + y * h->mb_stride;
er->mb_index2xy[h->mb_height * h->mb_width] = (h->mb_height - 1) *
h->mb_stride + h->mb_width;
FF_ALLOCZ_OR_GOTO(h->avctx, er->error_status_table,
mb_array_size * sizeof(uint8_t), fail);
FF_ALLOC_OR_GOTO(h->avctx, er->er_temp_buffer,
h->mb_height * h->mb_stride, fail);
FF_ALLOCZ_OR_GOTO(h->avctx, sl->dc_val_base,
yc_size * sizeof(int16_t), fail);
er->dc_val[0] = sl->dc_val_base + h->mb_width * 2 + 2;
er->dc_val[1] = sl->dc_val_base + y_size + h->mb_stride + 1;
er->dc_val[2] = er->dc_val[1] + c_size;
for (i = 0; i < yc_size; i++)
sl->dc_val_base[i] = 1024;
}
return 0;
fail:
return AVERROR(ENOMEM);
}
| 1threat
|
C++, return array from function : <p>Im building this subnet calculator but now im stuck, with array. I want to create new int function that will return array, but I don't know how I tried many things but still don't have idea, think it will have to do something with pointers. I want to create new function starting at "while(octet4>0)". so octet4 gets passed into function and function should return fully functional array which I can use then in main. Hope somebody will know answer for what im looking for, hope solution would not be too complicated because Im just learning programming and thought this would be fun project to take on.</p>
<pre><code>int main() {
int i=0,j,q,s,size=8,temp;
int binary_ip[8];
int netmask;
int mask;
int octet1, octet2, octet3, octet4;
string ip;
cout<<"Vnesite IP naslov, npr. 192.168.32.55:"<<endl;
cin>>ip;
cout<<"Vnesite netmasko, npr. /27:"<<endl;
cin>>netmask;
stringstream stream(ip);
char ch;
stream >> octet1 >> ch >> octet2 >> ch >> octet3 >> ch >> octet4;
while(octet4>0){
binary_ip[i]=octet4%2;
i++;
octet4=octet4/2;
}
switch(i){
case 7:binary_ip[7]=0;
break;
case 6:for(s=6;s<=7;s++)binary_ip[s]=0;
break;
case 5:for(s=5;s<=7;s++)binary_ip[s]=0;
break;
case 4:for(s=4;s<=7;s++)binary_ip[s]=0;
break;
case 3:for(s=3;s<=7;s++)binary_ip[s]=0;
break;
case 2:for(s=2;s<=7;s++)binary_ip[s]=0;
break;
case 1:for(s=1;s<=7;s++)binary_ip[s]=0;
break;
}
for(q=0;q<size/2;q++){
temp=binary_ip[size-1-q];
binary_ip[size-1-q]=binary_ip[q];
binary_ip[q]=temp;}
return 0;
}
</code></pre>
| 0debug
|
What am I doing wrong? Select first_name, last_name, phone FROM Student WHERE registration_date LIKE '%13/02/2007%' ORDER by last_name, first_name; : I have no idea what I am doing wrong. I'm in a SQL class right and I'm meant to do this: List the first name, last name and phone number for all students that registered on 2/13/2007. Arrange the list in order of last name and first name.
alright and this is what I have right now. I get a "no rows selected" notification when I run this:
Select first_name, last_name, phone
FROM Student
WHERE registration_date LIKE '%13/02/2007%'
ORDER by last_name, first_name;
What am I doing wrong? I've been on this for about a half hour now.
| 0debug
|
import re
def text_match(text):
patterns = 'a.*?b$'
if re.search(patterns, text):
return ('Found a match!')
else:
return ('Not matched!')
| 0debug
|
Firebase notifications not working in iOS 11 : <p>I'm developing an app that uses Firebase push notifications. It worked well until I tried in iOS 11. Using an iphone with ios 11 the notifications don't arrive. Here's my code:</p>
<pre><code>- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)
(UIBackgroundFetchResult))completionHandler {
//Manage notification
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler{
//Manage notification
}
</code></pre>
<p>Neither of the methods are called.</p>
<p>Thanks for the help!</p>
| 0debug
|
how to remove empty objects from json iOS : how to remove empty objects from json iOS
**{"customer_latitude":"","customer_longtitude":""}**
i get an empty lat and long value from json,but this lat and long point show into sea in map view.i want to remove that empty value
| 0debug
|
static int ssi_slave_init(DeviceState *dev, DeviceInfo *base_info)
{
SSISlaveInfo *info = container_of(base_info, SSISlaveInfo, qdev);
SSISlave *s = SSI_SLAVE_FROM_QDEV(dev);
SSIBus *bus;
bus = FROM_QBUS(SSIBus, qdev_get_parent_bus(dev));
if (LIST_FIRST(&bus->qbus.children) != dev
|| LIST_NEXT(dev, sibling) != NULL) {
hw_error("Too many devices on SSI bus");
}
s->info = info;
return info->init(s);
}
| 1threat
|
Null object reference on database cursor : <p>Been trying to retrieve data from database, my database has values and I don't know which causes this error. </p>
<pre><code>public void popList(String date, String time, String type, String game, String place){
Cursor data = databaseHelper.getReports(date, time, type, game, place);
while (data.moveToNext()) {
HashMap<String, String> datax = new HashMap<>();
datax.put("id", (data.getString(data.getColumnIndex("betid"))));
datax.put("betnumber", (data.getString(data.getColumnIndex("betnum"))));
datax.put("betamount", (data.getString(data.getColumnIndex("betamt"))));
mData3.add(datax);
}
bettorAdapter = new MyAdapter(mData3);
listViewx.setAdapter(bettorAdapter);
bettorAdapter.notifyDataSetChanged();
}
public Cursor getReports(String date, String time, String type, String game, String place){
Cursor data=null;
try {
SQLiteDatabase db = this.getReadableDatabase();
String query = "SELECT * FROM reports WHERE date='"+date+"' AND time ='"+time+"' AND game='"+game+"' AND type='"+type+"' AND lugar='"+place+"'";
data = db.rawQuery(query,null);
}catch (Exception e){
System.out.println(e);
}
return data;
}
</code></pre>
| 0debug
|
ssize_t read_targphys(const char *name,
int fd, target_phys_addr_t dst_addr, size_t nbytes)
{
uint8_t *buf;
ssize_t did;
buf = g_malloc(nbytes);
did = read(fd, buf, nbytes);
if (did > 0)
rom_add_blob_fixed("read", buf, did, dst_addr);
g_free(buf);
return did;
}
| 1threat
|
static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
AVIContext *avi = s->priv_data;
AVIOContext *pb = s->pb;
int longs_pre_entry= avio_rl16(pb);
int index_sub_type = avio_r8(pb);
int index_type = avio_r8(pb);
int entries_in_use = avio_rl32(pb);
int chunk_id = avio_rl32(pb);
int64_t base = avio_rl64(pb);
int stream_id= 10*((chunk_id&0xFF) - '0') + (((chunk_id>>8)&0xFF) - '0');
AVStream *st;
AVIStream *ast;
int i;
int64_t last_pos= -1;
int64_t filesize= avi->fsize;
av_dlog(s, "longs_pre_entry:%d index_type:%d entries_in_use:%d chunk_id:%X base:%16"PRIX64"\n",
longs_pre_entry,index_type, entries_in_use, chunk_id, base);
if(stream_id >= s->nb_streams || stream_id < 0)
return -1;
st= s->streams[stream_id];
ast = st->priv_data;
if(index_sub_type)
return -1;
avio_rl32(pb);
if(index_type && longs_pre_entry != 2)
return -1;
if(index_type>1)
return -1;
if(filesize > 0 && base >= filesize){
av_log(s, AV_LOG_ERROR, "ODML index invalid\n");
if(base>>32 == (base & 0xFFFFFFFF) && (base & 0xFFFFFFFF) < filesize && filesize <= 0xFFFFFFFF)
base &= 0xFFFFFFFF;
else
return -1;
}
for(i=0; i<entries_in_use; i++){
if(index_type){
int64_t pos= avio_rl32(pb) + base - 8;
int len = avio_rl32(pb);
int key= len >= 0;
len &= 0x7FFFFFFF;
#ifdef DEBUG_SEEK
av_log(s, AV_LOG_ERROR, "pos:%"PRId64", len:%X\n", pos, len);
#endif
if(url_feof(pb))
return -1;
if(last_pos == pos || pos == base - 8)
avi->non_interleaved= 1;
if(last_pos != pos && (len || !ast->sample_size))
av_add_index_entry(st, pos, ast->cum_len, len, 0, key ? AVINDEX_KEYFRAME : 0);
ast->cum_len += get_duration(ast, len);
last_pos= pos;
}else{
int64_t offset, pos;
int duration;
offset = avio_rl64(pb);
avio_rl32(pb);
duration = avio_rl32(pb);
if(url_feof(pb))
return -1;
pos = avio_tell(pb);
if(avi->odml_depth > MAX_ODML_DEPTH){
av_log(s, AV_LOG_ERROR, "Too deeply nested ODML indexes\n");
return -1;
}
avio_seek(pb, offset+8, SEEK_SET);
avi->odml_depth++;
read_braindead_odml_indx(s, frame_num);
avi->odml_depth--;
frame_num += duration;
avio_seek(pb, pos, SEEK_SET);
}
}
avi->index_loaded=1;
return 0;
}
| 1threat
|
static int parse_audio(DBEContext *s, int start, int end, int seg_id)
{
int ch, ret, key = parse_key(s);
for (ch = start; ch < end; ch++) {
if (!s->ch_size[ch]) {
s->channels[seg_id][ch].nb_groups = 0;
continue;
}
if ((ret = convert_input(s, s->ch_size[ch], key)) < 0)
return ret;
if ((ret = parse_channel(s, ch, seg_id)) < 0) {
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return ret;
s->channels[seg_id][ch].nb_groups = 0;
}
skip_input(s, s->ch_size[ch]);
}
skip_input(s, 1);
return 0;
}
| 1threat
|
Lint found fatal errors while assembling a release target : <p>383/5000
I have an app that gives me compilation errors when I change it to release mode to upload it to the play store</p>
<p>I've tried analyzing-inspecting code
and I do not have any error.</p>
<p>I have also tried the compilation sugestion in the build build gradle and it does not give an error, but when I try to install the apk it gives me an error: "the APK failed to install. Error: Could not stop error string"</p>
<pre><code>org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:lintVitalRelease'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.gradle.api.GradleException: Lint found fatal errors while assembling a release target.
To proceed, either fix the issues identified by lint, or modify your build script as follows:
...
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
...
at com.android.tools.lint.gradle.LintGradleExecution.abort(LintGradleExecution.java:199)
at com.android.tools.lint.gradle.LintGradleExecution.runLint(LintGradleExecution.java:263)
at com.android.tools.lint.gradle.LintGradleExecution.lintSingleVariant(LintGradleExecution.java:359)
at com.android.tools.lint.gradle.LintGradleExecution.analyze(LintGradleExecution.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.android.tools.lint.gradle.api.ReflectiveLintRunner.runLint(ReflectiveLintRunner.kt:38)
at com.android.build.gradle.tasks.LintBaseTask.runLint(LintBaseTask.java:87)
at com.android.build.gradle.tasks.LintPerVariantTask.lint(LintPerVariantTask.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:780)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:747)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 32 more
</code></pre>
| 0debug
|
static void thread_pool_cancel(BlockDriverAIOCB *acb)
{
ThreadPoolElement *elem = (ThreadPoolElement *)acb;
ThreadPool *pool = elem->pool;
trace_thread_pool_cancel(elem, elem->common.opaque);
qemu_mutex_lock(&pool->lock);
if (elem->state == THREAD_QUEUED &&
qemu_sem_timedwait(&pool->sem, 0) == 0) {
QTAILQ_REMOVE(&pool->request_list, elem, reqs);
elem->state = THREAD_CANCELED;
event_notifier_set(&pool->notifier);
} else {
pool->pending_cancellations++;
while (elem->state != THREAD_CANCELED && elem->state != THREAD_DONE) {
qemu_cond_wait(&pool->check_cancel, &pool->lock);
}
pool->pending_cancellations--;
}
qemu_mutex_unlock(&pool->lock);
}
| 1threat
|
int dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
uint8_t* buf, int buf_size)
{
int size, i;
uint8_t *ppcm[4] = {0};
if (buf_size < DV_PROFILE_BYTES ||
!(c->sys = dv_frame_profile(buf)) ||
buf_size < c->sys->frame_size) {
return -1;
}
size = dv_extract_audio_info(c, buf);
for (i = 0; i < c->ach; i++) {
c->audio_pkt[i].size = size;
c->audio_pkt[i].pts = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate;
ppcm[i] = c->audio_buf[i];
}
dv_extract_audio(buf, ppcm, c->sys);
c->abytes += size;
if (c->sys->height == 720) {
if (buf[1] & 0x0C)
c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
else
c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
}
size = dv_extract_video_info(c, buf);
av_init_packet(pkt);
pkt->data = buf;
pkt->size = size;
pkt->flags |= PKT_FLAG_KEY;
pkt->stream_index = c->vst->id;
pkt->pts = c->frames;
c->frames++;
return size;
}
| 1threat
|
static int nbd_errno_to_system_errno(int err)
{
switch (err) {
case NBD_SUCCESS:
return 0;
case NBD_EPERM:
return EPERM;
case NBD_EIO:
return EIO;
case NBD_ENOMEM:
return ENOMEM;
case NBD_ENOSPC:
return ENOSPC;
case NBD_EINVAL:
default:
return EINVAL;
}
}
| 1threat
|
lodash _.contains one of multiple values in string : <p>Is there a way in lodash to check if a strings contains one of the values from an array?</p>
<p>For example:</p>
<pre><code>var text = 'this is some sample text';
var values = ['sample', 'anything'];
_.contains(text, values); // should be true
var values = ['nope', 'no'];
_.contains(text, values); // should be false
</code></pre>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.