problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
static void migration_instance_init(Object *obj)
{
MigrationState *ms = MIGRATION_OBJ(obj);
ms->state = MIGRATION_STATUS_NONE;
ms->xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE;
ms->mbps = -1;
ms->parameters.tls_creds = g_strdup("");
ms->parameters.tls_hostname = g_strdup("");
}
| 1threat |
Firebase RecyclerView in Fragment : <p>Can anyone help with this situation? I want to show history in a recycleview in a fragment from firebase database. But doesn't show. What went wrong i can not figure out. The app works fine but showing nothing in recyclerview.</p>
<p>My history class</p>
<pre><code>public class History {
public String Date;
public String Amount;
public String Via;
public String Mobile_Number;
public History() {
}
public History(String date, String amount, String via, String mobile_Number)
{
Date = date;
Amount = amount;
Via = via;
Mobile_Number = mobile_Number;
}
public String getDate() {
return Date;
}
public void setDate(String date) {
Date = date;
}
public String getAmount() {
return Amount;
}
public void setAmount(String amount) {
Amount = amount;
}
public String getVia() {
return Via;
}
public void setVia(String via) {
Via = via;
}
public String getMobile_Number() {
return Mobile_Number;
}
public void setMobile_Number(String mobile_Number) {
Mobile_Number = mobile_Number;
}
}
</code></pre>
<p>I am using this viewholder class.</p>
<pre><code>public class History {
public String Date;
public String Amount;
public String Via;
public String Mobile_Number;
public History() {
}
public History(String date, String amount, String via, String mobile_Number)
{
Date = date;
Amount = amount;
Via = via;
Mobile_Number = mobile_Number;
}
public String getDate() {
return Date;
}
public void setDate(String date) {
Date = date;
}
public String getAmount() {
return Amount;
}
public void setAmount(String amount) {
Amount = amount;
}
public String getVia() {
return Via;
}
public void setVia(String via) {
Via = via;
}
public String getMobile_Number() {
return Mobile_Number;
}
public void setMobile_Number(String mobile_Number) {
Mobile_Number = mobile_Number;
}
}
</code></pre>
<p>This fragment is used on pager.</p>
<pre><code> @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mMainView = inflater.inflate(R.layout.fragment_profile, container,
false);
recyclerView = (RecyclerView)
mMainView.findViewById(R.id.profile_recycler);
String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
String email = FirebaseAuth.getInstance().getCurrentUser().getEmail();
mDatabase =
FirebaseDatabase.getInstance().getReference().child("Users").child(uid);
mDatabase.keepSynced(true);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
Query query = FirebaseDatabase.getInstance()
.getReference()
.child("Users").child(uid).child("History").orderByKey();
FirebaseRecyclerOptions<History> options = new
FirebaseRecyclerOptions.Builder<History>()
.setQuery(query, History.class).build();
FirebaseRecyclerAdapter adapter = new
FirebaseRecyclerAdapter<History,HistoryViewHolder>(options) {
@Override
protected void onBindViewHolder(@NonNull HistoryViewHolder holder,
int position, @NonNull History model) {
holder.setAmountText("100");
holder.setDateText("dd-mm-yyyy");
holder.setMobileText("model.getMobile_Number()");
holder.setViaText("model.getVia()");
}
@Override
public HistoryViewHolder onCreateViewHolder(ViewGroup parent, int
viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.history_layout,parent,false);
return new HistoryViewHolder(view);
}
};
recyclerView.setAdapter(adapter);
return mMainView;
}
</code></pre>
<p>History layout to populate every data</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/history_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="0dp"
android:layout_marginTop="4dp"
android:fontFamily="serif"
android:text="Date"
android:textColor="@color/colorPrimary"
android:textStyle="bold" />
<TextView
android:id="@+id/history_mobile_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/history_date"
android:layout_marginStart="16dp"
android:layout_toEndOf="@+id/history_date"
android:text="Mobile Number" />
<TextView
android:id="@+id/history_via"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/history_mobile_number"
android:layout_below="@id/history_mobile_number"
android:text="Via"
android:textStyle="bold" />
<TextView
android:id="@+id/history_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/history_via"
android:layout_below="@+id/history_via"
android:layout_marginBottom="4dp"
android:text="Taka" />
</RelativeLayout>
</code></pre>
| 0debug |
mysql query PHP: I want to a specific items to be first and can modify the query how many items to be displayed : <p>I have the table below.</p>
<pre><code>id | car_name | owner
-------------------------
1 | Toyota | Jan
2 | Ford | Mike
3 | Isuzu | Andrew
4 | BMW | Jan
5 | Ferrari | Steve
6 | Audi | Jan
7 | Benz | Kin
8 | Hyundai | Jan
9 | Kia | Jan
</code></pre>
<p>I want to get all the car owners, but if Jan has 5 or more cars I can modify the query and get the first four item of Jan to be in the list. I don't care about the order that I receive the rest of the items. My priority is Jan should be the first. </p>
<pre><code>id | car_name | owner
-------------------------
1 | Toyota | Jan
4 | BMW | Jan
7 | Benz | Jan
8 | Hyundai | Jan
2 | Ford | Mike
3 | Isuzu | Andrew
5 | Ferrari | Steve
6 | Audi | Bob
</code></pre>
| 0debug |
Retrofit callbacks are not getting trigerred : Retrofit callbacks are not getting called.My code is-:
Call<OpShiftModel[]> tabCall = opShiftService.getTabData(getAuthHeader());
tabCall.enqueue(new Callback<OpShiftModel[]>() {
@Override
public void onResponse(Call<OpShiftModel[]> call, Response<OpShiftModel[]> response) {
try {
listener.onSuccess(response.body());
} catch (NullPointerException e) {
onFailure(call, e);
}
}
@Override
public void onFailure(Call<OpShiftModel[]> call, Throwable throwable) {
}
});}
Http response is coming successfull although. | 0debug |
mysql_error() not displaying an error in php : <p>I am trying to save error message but its not showing errors </p>
<pre><code>$selectquery=mysql_query("select * from employee where eid='$eid' and name='$name' and ssn='$ssn'");
if(mysql_num_rows($selectquery)>0)
{
$state="success";
$sql="insert into pfupload(eid1,name,ssn,state) values('$eid','$name','$ssn','$state')";
$sqlquery=mysql_query($sql);
}
else
{
$state1= mysql_error();
$sql1="insert into pfupload(eid1,name,ssn,state) values('$eid','$name','$ssn','$state1')";
mysql_query($sql1);
}
</code></pre>
| 0debug |
static void openpic_cpu_write_internal(void *opaque, hwaddr addr,
uint32_t val, int idx)
{
openpic_t *opp = opaque;
IRQ_src_t *src;
IRQ_dst_t *dst;
int s_IRQ, n_IRQ;
DPRINTF("%s: cpu %d addr " TARGET_FMT_plx " <= %08x\n", __func__, idx,
addr, val);
if (addr & 0xF)
return;
dst = &opp->dst[idx];
addr &= 0xFF0;
switch (addr) {
case 0x40:
case 0x50:
case 0x60:
case 0x70:
idx = (addr - 0x40) >> 4;
write_IRQreg_ide(opp, opp->irq_ipi0 + idx,
opp->src[opp->irq_ipi0 + idx].ide | val);
openpic_set_irq(opp, opp->irq_ipi0 + idx, 1);
openpic_set_irq(opp, opp->irq_ipi0 + idx, 0);
break;
case 0x80:
dst->pctp = val & 0x0000000F;
break;
case 0x90:
break;
case 0xA0:
break;
case 0xB0:
DPRINTF("PEOI\n");
s_IRQ = IRQ_get_next(opp, &dst->servicing);
IRQ_resetbit(&dst->servicing, s_IRQ);
dst->servicing.next = -1;
s_IRQ = IRQ_get_next(opp, &dst->servicing);
n_IRQ = IRQ_get_next(opp, &dst->raised);
src = &opp->src[n_IRQ];
if (n_IRQ != -1 &&
(s_IRQ == -1 ||
IPVP_PRIORITY(src->ipvp) > dst->servicing.priority)) {
DPRINTF("Raise OpenPIC INT output cpu %d irq %d\n",
idx, n_IRQ);
opp->irq_raise(opp, idx, src);
}
break;
default:
break;
}
}
| 1threat |
State not updating when receiving new props (ReactJS) : <p>I'm new to React. I'm stuck on this, would really appreciate some help! </p>
<p>A parent component will pass an array into this child component. When I console.log(this.props.repairs) it shows me an array of 4. I am trying to update this.state.sortedDataList whenever the array of repairs is passed in. The console.log(this.state) is still showing sortedDataList as an empty array. </p>
<p>What am I doing wrong? Thanks so much, appreciate any help. </p>
<pre><code>class Repairs extends React.Component {
constructor(props) {
super(props);
this.state = {
sortedDataList: []
};
}
componentWillReceiveProps(nextProps) {
if(this.props != nextProps) {
this.setState({
sortedDataList: this.props.repairs
});
}
}
render() {
console.log(this.props);
console.log(this.state);
return (
<div></div>
);
}
}
</code></pre>
| 0debug |
void address_space_rw(AddressSpace *as, target_phys_addr_t addr, uint8_t *buf,
int len, bool is_write)
{
AddressSpaceDispatch *d = as->dispatch;
int l;
uint8_t *ptr;
uint32_t val;
target_phys_addr_t page;
MemoryRegionSection *section;
while (len > 0) {
page = addr & TARGET_PAGE_MASK;
l = (page + TARGET_PAGE_SIZE) - addr;
if (l > len)
l = len;
section = phys_page_find(d, page >> TARGET_PAGE_BITS);
if (is_write) {
if (!memory_region_is_ram(section->mr)) {
target_phys_addr_t addr1;
addr1 = memory_region_section_addr(section, addr);
if (l >= 4 && ((addr1 & 3) == 0)) {
val = ldl_p(buf);
io_mem_write(section->mr, addr1, val, 4);
l = 4;
} else if (l >= 2 && ((addr1 & 1) == 0)) {
val = lduw_p(buf);
io_mem_write(section->mr, addr1, val, 2);
l = 2;
} else {
val = ldub_p(buf);
io_mem_write(section->mr, addr1, val, 1);
l = 1;
}
} else if (!section->readonly) {
ram_addr_t addr1;
addr1 = memory_region_get_ram_addr(section->mr)
+ memory_region_section_addr(section, addr);
ptr = qemu_get_ram_ptr(addr1);
memcpy(ptr, buf, l);
invalidate_and_set_dirty(addr1, l);
qemu_put_ram_ptr(ptr);
}
} else {
if (!(memory_region_is_ram(section->mr) ||
memory_region_is_romd(section->mr))) {
target_phys_addr_t addr1;
addr1 = memory_region_section_addr(section, addr);
if (l >= 4 && ((addr1 & 3) == 0)) {
val = io_mem_read(section->mr, addr1, 4);
stl_p(buf, val);
l = 4;
} else if (l >= 2 && ((addr1 & 1) == 0)) {
val = io_mem_read(section->mr, addr1, 2);
stw_p(buf, val);
l = 2;
} else {
val = io_mem_read(section->mr, addr1, 1);
stb_p(buf, val);
l = 1;
}
} else {
ptr = qemu_get_ram_ptr(section->mr->ram_addr
+ memory_region_section_addr(section,
addr));
memcpy(buf, ptr, l);
qemu_put_ram_ptr(ptr);
}
}
len -= l;
buf += l;
addr += l;
}
}
| 1threat |
How do I get my function definitions to work in Swift 3.1 if they worked in Swift 1.1? : <p>I was using Swift 1.1 and I just upgraded to Swift 3.1, and this extension below no longer works. I am getting the compiler errors marked with notes below. Is there an easy way to fix my syntax? I tried converting the code using xcode's built-feature but that only seemed to apply to the classes, and not this extension.</p>
<pre><code>import Foundation
import UIKit
extension UIView {
/**
Set x Position
:param: x CGFloat
by DaRk-_-D0G
*/
func setX(#x:CGFloat) { //Expected parameter name followed by ':'
var frame:CGRect = self.frame
frame.origin.x = x //Use of unresolved identifier 'x'
self.frame = frame
}
/**
Set y Position
:param: y CGFloat
by DaRk-_-D0G
*/
func setY(#y:CGFloat) { //Expected ',' separator
var frame:CGRect = self.frame
frame.origin.y = y //Use of unresolved identifier 'y'
self.frame = frame
}
/**
Set Width
:param: width CGFloat
by DaRk-_-D0G
*/
func setWidth(#width:CGFloat) { //Expected ',' separator
var frame:CGRect = self.frame
frame.size.width = width //Use of unresolved identifier 'width'
self.frame = frame
}
/**
Set Height
:param: height CGFloat
by DaRk-_-D0G
*/
func setHeight(#height:CGFloat) { //Expected ',' separator
var frame:CGRect = self.frame
frame.size.height = height //Use of unresolved identifier 'width'
self.frame = frame
}
}
</code></pre>
| 0debug |
What does it mean when there is a -- before an in value in java? Also what is a StringBuilder : <p>I am trying to finish an assignment in my intro to Java course, and I have some questions. First off, what does it mean when there is a -- in FRONT of an int value? Also what is a String Builder? I had some help but want to understand what it is I'm using in the code. Thanks.</p>
| 0debug |
Extract text between slashes which contain '=' : <p>I want a regex to extract the text between slashes which contain an equals '='</p>
<p><code>data/xx/yy/zz/date=20190506/xxx.json</code></p>
<p>-> <code>date=20190506</code></p>
| 0debug |
How to write pyspark dataframe to HDFS and then how to read it back into dataframe? : <p>I have a very big pyspark dataframe. So I want to perform pre processing on subsets of it and then store them to hdfs. Later I want to read all of them and merge together. Thanks. </p>
| 0debug |
void sigaction_invoke(struct sigaction *action,
struct qemu_signalfd_siginfo *info)
{
siginfo_t si = { 0 };
si.si_signo = info->ssi_signo;
si.si_errno = info->ssi_errno;
si.si_code = info->ssi_code;
if (info->ssi_code == SI_USER || info->ssi_code == SI_QUEUE ||
info->ssi_code <= 0) {
si.si_pid = info->ssi_pid;
si.si_uid = info->ssi_uid;
} else if (info->ssi_signo == SIGILL || info->ssi_signo == SIGFPE ||
info->ssi_signo == SIGSEGV || info->ssi_signo == SIGBUS) {
si.si_addr = (void *)(uintptr_t)info->ssi_addr;
} else if (info->ssi_signo == SIGCHLD) {
si.si_pid = info->ssi_pid;
si.si_status = info->ssi_status;
si.si_uid = info->ssi_uid;
}
action->sa_sigaction(info->ssi_signo, &si, NULL);
}
| 1threat |
sort objects in alphabetical order with function javascript no button : <pre><code> **Bu şekilde bir dizi nesnesi oluşturdum.Bunlara erişmek için function kullanmak istiyorum.Fakat for ve button kullanmadan erişemedim.İki tane fonksiyon kullandım birincisinde normal bir şekilde çıktı aldım.Fakat ikinci fonksiyonda sort ile sıralamasını istedim fakat olmadı.Nasıl bir yol izleyebilirim?**
</code></pre>
<p>this is code </p>
<blockquote>
<p>var list;
list=[
{name:"Elma",gram:700},
{name:"Armut",gram:780},
{name:"Kiraz",gram:750}
];</p>
</blockquote>
| 0debug |
static int nbd_handle_list(NBDClient *client, uint32_t length)
{
int csock;
NBDExport *exp;
csock = client->sock;
if (length) {
if (drop_sync(csock, length) != length) {
return -EIO;
}
return nbd_send_rep(csock, NBD_REP_ERR_INVALID, NBD_OPT_LIST);
}
QTAILQ_FOREACH(exp, &exports, next) {
if (nbd_send_rep_list(csock, exp)) {
return -EINVAL;
}
}
return nbd_send_rep(csock, NBD_REP_ACK, NBD_OPT_LIST);
}
| 1threat |
static uint32_t pci_reg_read4(void *opaque, target_phys_addr_t addr)
{
PPCE500PCIState *pci = opaque;
unsigned long win;
uint32_t value = 0;
win = addr & 0xfe0;
switch (win) {
case PPCE500_PCI_OW1:
case PPCE500_PCI_OW2:
case PPCE500_PCI_OW3:
case PPCE500_PCI_OW4:
switch (addr & 0xC) {
case PCI_POTAR:
value = pci->pob[(addr >> 5) & 0x7].potar;
break;
case PCI_POTEAR:
value = pci->pob[(addr >> 5) & 0x7].potear;
break;
case PCI_POWBAR:
value = pci->pob[(addr >> 5) & 0x7].powbar;
break;
case PCI_POWAR:
value = pci->pob[(addr >> 5) & 0x7].powar;
break;
default:
break;
}
break;
case PPCE500_PCI_IW3:
case PPCE500_PCI_IW2:
case PPCE500_PCI_IW1:
switch (addr & 0xC) {
case PCI_PITAR:
value = pci->pib[(addr >> 5) & 0x3].pitar;
break;
case PCI_PIWBAR:
value = pci->pib[(addr >> 5) & 0x3].piwbar;
break;
case PCI_PIWBEAR:
value = pci->pib[(addr >> 5) & 0x3].piwbear;
break;
case PCI_PIWAR:
value = pci->pib[(addr >> 5) & 0x3].piwar;
break;
default:
break;
};
break;
case PPCE500_PCI_GASKET_TIMR:
value = pci->gasket_time;
break;
default:
break;
}
pci_debug("%s: win:%lx(addr:" TARGET_FMT_plx ") -> value:%x\n", __func__,
win, addr, value);
return value;
}
| 1threat |
static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
int *got_packet)
{
X264Context *x4 = ctx->priv_data;
x264_nal_t *nal;
int nnal, i, ret;
x264_picture_t pic_out = {0};
int pict_type;
x264_picture_init( &x4->pic );
x4->pic.img.i_csp = x4->params.i_csp;
if (x264_bit_depth > 8)
x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt);
if (frame) {
for (i = 0; i < x4->pic.img.i_plane; i++) {
x4->pic.img.plane[i] = frame->data[i];
x4->pic.img.i_stride[i] = frame->linesize[i];
}
x4->pic.i_pts = frame->pts;
switch (frame->pict_type) {
case AV_PICTURE_TYPE_I:
x4->pic.i_type = x4->forced_idr > 0 ? X264_TYPE_IDR
: X264_TYPE_KEYFRAME;
break;
case AV_PICTURE_TYPE_P:
x4->pic.i_type = X264_TYPE_P;
break;
case AV_PICTURE_TYPE_B:
x4->pic.i_type = X264_TYPE_B;
break;
default:
x4->pic.i_type = X264_TYPE_AUTO;
break;
}
reconfig_encoder(ctx, frame);
if (x4->a53_cc) {
void *sei_data;
size_t sei_size;
ret = ff_alloc_a53_sei(frame, 0, &sei_data, &sei_size);
if (ret < 0) {
av_log(ctx, AV_LOG_ERROR, "Not enough memory for closed captions, skipping\n");
} else if (sei_data) {
x4->pic.extra_sei.payloads = av_mallocz(sizeof(x4->pic.extra_sei.payloads[0]));
if (x4->pic.extra_sei.payloads == NULL) {
av_log(ctx, AV_LOG_ERROR, "Not enough memory for closed captions, skipping\n");
av_free(sei_data);
} else {
x4->pic.extra_sei.sei_free = av_free;
x4->pic.extra_sei.payloads[0].payload_size = sei_size;
x4->pic.extra_sei.payloads[0].payload = sei_data;
x4->pic.extra_sei.num_payloads = 1;
x4->pic.extra_sei.payloads[0].payload_type = 4;
}
}
}
}
do {
if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0)
return AVERROR_EXTERNAL;
ret = encode_nals(ctx, pkt, nal, nnal);
if (ret < 0)
return ret;
} while (!ret && !frame && x264_encoder_delayed_frames(x4->enc));
pkt->pts = pic_out.i_pts;
pkt->dts = pic_out.i_dts;
switch (pic_out.i_type) {
case X264_TYPE_IDR:
case X264_TYPE_I:
pict_type = AV_PICTURE_TYPE_I;
break;
case X264_TYPE_P:
pict_type = AV_PICTURE_TYPE_P;
break;
case X264_TYPE_B:
case X264_TYPE_BREF:
pict_type = AV_PICTURE_TYPE_B;
break;
default:
pict_type = AV_PICTURE_TYPE_NONE;
}
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
ctx->coded_frame->pict_type = pict_type;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
pkt->flags |= AV_PKT_FLAG_KEY*pic_out.b_keyframe;
if (ret) {
ff_side_data_set_encoder_stats(pkt, (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA, NULL, 0, pict_type);
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
ctx->coded_frame->quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
*got_packet = ret;
return 0;
}
| 1threat |
void tcg_target_init(TCGContext *s)
{
tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffffffff);
#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I64], 0, 0xffffffff);
#endif
tcg_regset_set32(tcg_target_call_clobber_regs, 0,
(1 << TCG_REG_G1) |
(1 << TCG_REG_G2) |
(1 << TCG_REG_G3) |
(1 << TCG_REG_G4) |
(1 << TCG_REG_G5) |
(1 << TCG_REG_G6) |
(1 << TCG_REG_G7) |
(1 << TCG_REG_O0) |
(1 << TCG_REG_O1) |
(1 << TCG_REG_O2) |
(1 << TCG_REG_O3) |
(1 << TCG_REG_O4) |
(1 << TCG_REG_O5) |
(1 << TCG_REG_O7));
tcg_regset_clear(s->reserved_regs);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_G0);
#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
tcg_regset_set_reg(s->reserved_regs, TCG_REG_I4);
#endif
tcg_regset_set_reg(s->reserved_regs, TCG_REG_I5);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_I6);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_I7);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_O6);
tcg_regset_set_reg(s->reserved_regs, TCG_REG_O7);
tcg_add_target_add_op_defs(sparc_op_defs);
}
| 1threat |
void qmp_memsave(int64_t addr, int64_t size, const char *filename,
bool has_cpu, int64_t cpu_index, Error **errp)
{
FILE *f;
uint32_t l;
CPUState *cpu;
uint8_t buf[1024];
if (!has_cpu) {
cpu_index = 0;
}
cpu = qemu_get_cpu(cpu_index);
if (cpu == NULL) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
"a CPU number");
return;
}
f = fopen(filename, "wb");
if (!f) {
error_setg_file_open(errp, errno, filename);
return;
}
while (size != 0) {
l = sizeof(buf);
if (l > size)
l = size;
cpu_memory_rw_debug(cpu, addr, buf, l, 0);
if (fwrite(buf, 1, l, f) != l) {
error_set(errp, QERR_IO_ERROR);
goto exit;
}
addr += l;
size -= l;
}
exit:
fclose(f);
}
| 1threat |
static uint64_t dbdma_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
uint32_t value;
int channel = addr >> DBDMA_CHANNEL_SHIFT;
DBDMAState *s = opaque;
DBDMA_channel *ch = &s->channels[channel];
int reg = (addr - (channel << DBDMA_CHANNEL_SHIFT)) >> 2;
value = ch->regs[reg];
DBDMA_DPRINTF("readl 0x" TARGET_FMT_plx " => 0x%08x\n", addr, value);
DBDMA_DPRINTF("channel 0x%x reg 0x%x\n",
(uint32_t)addr >> DBDMA_CHANNEL_SHIFT, reg);
switch(reg) {
case DBDMA_CONTROL:
value = 0;
break;
case DBDMA_STATUS:
case DBDMA_CMDPTR_LO:
case DBDMA_INTR_SEL:
case DBDMA_BRANCH_SEL:
case DBDMA_WAIT_SEL:
break;
case DBDMA_XFER_MODE:
case DBDMA_CMDPTR_HI:
case DBDMA_DATA2PTR_HI:
case DBDMA_DATA2PTR_LO:
case DBDMA_ADDRESS_HI:
case DBDMA_BRANCH_ADDR_HI:
value = 0;
break;
case DBDMA_RES1:
case DBDMA_RES2:
case DBDMA_RES3:
case DBDMA_RES4:
break;
}
return value;
}
| 1threat |
return out of function : <p>Hi im working on a code but it is not working because i get the error: 'return' out of function</p>
<p>here is my code</p>
<pre><code>def get_information():
names_list=[]
coursework_marks_list=[]
prelim_marks_list=[]
file=open("details.txt","r")
for line in file:
item=line.split()
if len(item)>1:
names_list.append(item[0])
coursework_marks_list.append(item[1])
prelim_marks_list.append(item[2])
return names_list,coursework_marks_list,prelim_marks_list
</code></pre>
| 0debug |
While downloading the excel file i want the excel cell value will be displaying as currency format which one has currency format. : While downloading the excel file i want the excel cell value will be displaying as currency format which has currency value as $140.00.
| 0debug |
window.location.href = 'http://attack.com?user=' + user_input; | 1threat |
static void kvm_set_phys_mem(target_phys_addr_t start_addr, ram_addr_t size,
ram_addr_t phys_offset, bool log_dirty)
{
KVMState *s = kvm_state;
ram_addr_t flags = phys_offset & ~TARGET_PAGE_MASK;
KVMSlot *mem, old;
int err;
void *ram = NULL;
size = TARGET_PAGE_ALIGN(size);
start_addr = TARGET_PAGE_ALIGN(start_addr);
phys_offset &= ~IO_MEM_ROM;
if ((phys_offset & ~TARGET_PAGE_MASK) == IO_MEM_RAM) {
ram = qemu_safe_ram_ptr(phys_offset);
}
while (1) {
mem = kvm_lookup_overlapping_slot(s, start_addr, start_addr + size);
if (!mem) {
break;
}
if (flags < IO_MEM_UNASSIGNED && start_addr >= mem->start_addr &&
(start_addr + size <= mem->start_addr + mem->memory_size) &&
(ram - start_addr == mem->ram - mem->start_addr)) {
kvm_slot_dirty_pages_log_change(mem, log_dirty);
return;
}
old = *mem;
mem->memory_size = 0;
err = kvm_set_user_memory_region(s, mem);
if (err) {
fprintf(stderr, "%s: error unregistering overlapping slot: %s\n",
__func__, strerror(-err));
abort();
}
if (s->broken_set_mem_region &&
old.start_addr == start_addr && old.memory_size < size &&
flags < IO_MEM_UNASSIGNED) {
mem = kvm_alloc_slot(s);
mem->memory_size = old.memory_size;
mem->start_addr = old.start_addr;
mem->ram = old.ram;
mem->flags = kvm_mem_flags(s, log_dirty);
err = kvm_set_user_memory_region(s, mem);
if (err) {
fprintf(stderr, "%s: error updating slot: %s\n", __func__,
strerror(-err));
abort();
}
start_addr += old.memory_size;
phys_offset += old.memory_size;
ram += old.memory_size;
size -= old.memory_size;
continue;
}
if (old.start_addr < start_addr) {
mem = kvm_alloc_slot(s);
mem->memory_size = start_addr - old.start_addr;
mem->start_addr = old.start_addr;
mem->ram = old.ram;
mem->flags = kvm_mem_flags(s, log_dirty);
err = kvm_set_user_memory_region(s, mem);
if (err) {
fprintf(stderr, "%s: error registering prefix slot: %s\n",
__func__, strerror(-err));
#ifdef TARGET_PPC
fprintf(stderr, "%s: This is probably because your kernel's " \
"PAGE_SIZE is too big. Please try to use 4k " \
"PAGE_SIZE!\n", __func__);
#endif
abort();
}
}
if (old.start_addr + old.memory_size > start_addr + size) {
ram_addr_t size_delta;
mem = kvm_alloc_slot(s);
mem->start_addr = start_addr + size;
size_delta = mem->start_addr - old.start_addr;
mem->memory_size = old.memory_size - size_delta;
mem->ram = old.ram + size_delta;
mem->flags = kvm_mem_flags(s, log_dirty);
err = kvm_set_user_memory_region(s, mem);
if (err) {
fprintf(stderr, "%s: error registering suffix slot: %s\n",
__func__, strerror(-err));
abort();
}
}
}
if (!size) {
return;
}
if (flags >= IO_MEM_UNASSIGNED) {
return;
}
mem = kvm_alloc_slot(s);
mem->memory_size = size;
mem->start_addr = start_addr;
mem->ram = ram;
mem->flags = kvm_mem_flags(s, log_dirty);
err = kvm_set_user_memory_region(s, mem);
if (err) {
fprintf(stderr, "%s: error registering slot: %s\n", __func__,
strerror(-err));
abort();
}
}
| 1threat |
Spring Security 5 Replacement for OAuth2RestTemplate : <p>In <code>spring-security-oauth2:2.4.0.RELEASE</code> classes such as <code>OAuth2RestTemplate</code>, <code>OAuth2ProtectedResourceDetails</code> and <code>ClientCredentialsAccessTokenProvider</code> have all been marked as deprecated.</p>
<p>From the javadoc on these classes it points to a <a href="https://github.com/spring-projects/spring-security/wiki/OAuth-2.0-Migration-Guide" rel="noreferrer">spring security migration guide</a> that insinuates that people should migrate to the core spring-security 5 project. However I'm having trouble finding how I would implement my use case in this project.</p>
<p>All of the documentation and examples talk about integrating with a 3rd part OAuth provider if you want incoming requests to your application to be authenticated and you want to use the 3rd party OAuth provider to verify the identity. </p>
<p>In my use case all I want to do is make a request with a <code>RestTemplate</code> to an external service that is protected by OAuth. Currently I create an <code>OAuth2ProtectedResourceDetails</code> with my client id and secret which I pass into an <code>OAuth2RestTemplate</code>. I also have a custom <code>ClientCredentialsAccessTokenProvider</code> added to the <code>OAuth2ResTemplate</code> that just adds some extra headers to the token request that are required by the OAuth provider I'm using.</p>
<p>In the spring-security 5 documentation I've found a section that mentions <a href="https://docs.spring.io/spring-security/site/docs/current/reference/html5/#customizing-the-access-token-request-3" rel="noreferrer">customising the token request</a>, but again that looks to be in the context of authenticating an incoming request with a 3rd party OAuth provider. It is not clear how you would use this in combination with something like a <code>ClientHttpRequestInterceptor</code> to ensure that each outgoing request to an external service first gets a token and then gets that added to the request. </p>
<p>Also in the migration guide linked above there is reference to a <code>OAuth2AuthorizedClientService</code> which it says is useful for using in interceptors, but again this looks like it relies on things like the <code>ClientRegistrationRepository</code> which seems to be where it maintains registrations for third party providers if you want to use that provide to ensure an incoming request is authenticated.</p>
<p>Is there any way I can make use of the new functionality in spring-security 5 for registering OAuth providers in order to get a token to add to outgoing requests from my application?</p>
| 0debug |
How to turn off NavigationLink overlay color in SwiftUI? : <p>I've designed a "CardView" using ZStack in which the background layer is a gradient and the foreground layer is a PNG(or PDF) image(the image is a yellow path(like a circle) drawn in Adobe Illustrator).</p>
<p>When I put the ZStack inside a NavigationLink the gradient remains unchanged and fine, but the image get a bluish overlay color (like default color of a button) therefore there is no more yellow path(the path is bluish).</p>
<p>How can get the original color of foreground PNG(or PDF) image?</p>
<pre class="lang-swift prettyprint-override"><code>
import SwiftUI
struct MyCardView : View {
let cRadius : CGFloat = 35
let cHeight : CGFloat = 220
var body: some View {
NavigationView {
NavigationLink(destination: Text("Hello")) {
ZStack {
RoundedRectangle(cornerRadius: cRadius)
.foregroundColor(.white)
.opacity(0)
.background(LinearGradient(gradient: Gradient(colors: [Color(red: 109/255, green: 58/255, blue: 242/255),Color(red: 57/255, green: 23/255, blue: 189/255)]), startPoint: .leading, endPoint: .trailing), cornerRadius: 0)
.cornerRadius(cRadius)
.frame(height: cHeight)
.padding()
Image("someColoredPathPNGimage")
}
}
}
}
}
</code></pre>
| 0debug |
Unique function doesn't work in angular js : <p>(<a href="http://angularjs/angular.min.js:109:313" rel="nofollow noreferrer">http://angularjs/angular.min.js:109:313</a>) ngRepeat: mapImg in imgCat | unique:'select' </p>
<p>unique function doesn't work in server. but function work in localhost</p>
| 0debug |
Getting No loop matching the specified signature and casting error : <p>I'm a beginner to python and machine learning . I get below error when i try to fit data into statsmodels.formula.api OLS.fit()</p>
<p>Traceback (most recent call last):</p>
<blockquote>
<p>File "", line 47, in
regressor_OLS = sm.OLS(y , X_opt).fit()</p>
<p>File
"E:\Anaconda\lib\site-packages\statsmodels\regression\linear_model.py",
line 190, in fit
self.pinv_wexog, singular_values = pinv_extended(self.wexog)</p>
<p>File "E:\Anaconda\lib\site-packages\statsmodels\tools\tools.py",
line 342, in pinv_extended
u, s, vt = np.linalg.svd(X, 0)</p>
<p>File "E:\Anaconda\lib\site-packages\numpy\linalg\linalg.py", line
1404, in svd
u, s, vt = gufunc(a, signature=signature, extobj=extobj)</p>
<p>TypeError: No loop matching the specified signature and casting was
found for ufunc svd_n_s</p>
</blockquote>
<p>code</p>
<pre><code>#Importing Libraries
import numpy as np # linear algebra
import pandas as pd # data processing
import matplotlib.pyplot as plt #Visualization
#Importing the dataset
dataset = pd.read_csv('Video_Games_Sales_as_at_22_Dec_2016.csv')
#dataset.head(10)
#Encoding categorical data using panda get_dummies function . Easier and straight forward than OneHotEncoder in sklearn
#dataset = pd.get_dummies(data = dataset , columns=['Platform' , 'Genre' , 'Rating' ] , drop_first = True ) #drop_first use to fix dummy varible trap
dataset=dataset.replace('tbd',np.nan)
#Separating Independent & Dependant Varibles
#X = pd.concat([dataset.iloc[:,[11,13]], dataset.iloc[:,13: ]] , axis=1).values #Getting important variables
X = dataset.iloc[:,[10,12]].values
y = dataset.iloc[:,9].values #Dependant Varible (Global sales)
#Taking care of missing data
from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values = 'NaN' , strategy = 'mean' , axis = 0)
imputer = imputer.fit(X[:,0:2])
X[:,0:2] = imputer.transform(X[:,0:2])
#Splitting the dataset into the Training set and Test set
from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X,y,test_size = 0.2 , random_state = 0)
#Fitting Mutiple Linear Regression to the Training Set
from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(X_train,y_train)
#Predicting the Test set Result
y_pred = regressor.predict(X_test)
#Building the optimal model using Backward Elimination (p=0.050)
import statsmodels.formula.api as sm
X = np.append(arr = np.ones((16719,1)).astype(float) , values = X , axis = 1)
X_opt = X[:, [0,1,2]]
regressor_OLS = sm.OLS(y , X_opt).fit()
regressor_OLS.summary()
</code></pre>
<p>Dataset</p>
<p><a href="https://www.dropbox.com/s/w2hq4t0utbvk7bu/Video_Games_Sales_as_at_22_Dec_2016.csv?dl=0" rel="noreferrer">dataset link</a></p>
<p>Couldn't find anything helpful to solve this issue on stack-overflow or google . </p>
| 0debug |
static int read_key(void)
{
#if HAVE_TERMIOS_H
int n = 1;
unsigned char ch;
struct timeval tv;
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(0, &rfds);
tv.tv_sec = 0;
tv.tv_usec = 0;
n = select(1, &rfds, NULL, NULL, &tv);
if (n > 0) {
n = read(0, &ch, 1);
if (n == 1)
return ch;
return n;
}
#elif HAVE_CONIO_H
if(kbhit())
return(getch());
#endif
return -1;
}
| 1threat |
static void translate_priority(GICState *s, int irq, int cpu,
uint32_t *field, bool to_kernel)
{
if (to_kernel) {
*field = GIC_GET_PRIORITY(irq, cpu) & 0xff;
} else {
gic_set_priority(s, cpu, irq, *field & 0xff);
}
}
| 1threat |
Visual C++ application deployment that involves openCV: Proper Guideine needed : <p>I have written large amount code using Visual C++ on Visual Studio IDE(VS 2015 Enterprise).My application depends heavily on openCV(x64-vc14). It runs perfectly on my computer. But when I tried to deploy using install shield limited(in debug build mode) to another computer, it shows the .exe file depends many .dll files. I had gone through google, found about dependency walker but when I run dependency walker it gives a dependency list with thousands of .dll files. It's time consuming manual process to copy each of the dll files from my computer and add it in the directory of the application. Is there any other better way to do this automatically? Is there anything I am missing during the building process or in the project property set up? I need a guideline because, in future my application will be even bigger and might also depend on more dll files.</p>
| 0debug |
static int del_existing_snapshots(Monitor *mon, const char *name)
{
BlockDriverState *bs;
QEMUSnapshotInfo sn1, *snapshot = &sn1;
int ret;
bs = NULL;
while ((bs = bdrv_next(bs))) {
if (bdrv_can_snapshot(bs) &&
bdrv_snapshot_find(bs, snapshot, name) >= 0)
{
ret = bdrv_snapshot_delete(bs, name);
if (ret < 0) {
monitor_printf(mon,
"Error while deleting snapshot on '%s'\n",
bdrv_get_device_name(bs));
return -1;
}
}
}
return 0;
}
| 1threat |
powershell: split strings : Can you please suggest me on how to get the output using split or any other commands using powershell
*string = "version(2.3.4)_stack_over_flow.zip"
required output : "stack_over_flow"* | 0debug |
complex custom List View in Android : I have 4 button in The main Activity, and I want them to transfer the user to the 2nd Activity which is a LIST VIEW, but I want to code every button to transfer different elements to that list view. The question is That to code this list view should I use Custom List View Adapter or what ???? | 0debug |
C++ How do I fill in two-dimensional array : <p>I just want to fill in two-dimensional array string values. e.g: array[5][6] </p>
<pre><code>.X....
X.....
XX....
.....X
...X..
</code></pre>
<p>I tried to use <code>getline(cin, array)</code> but it makes cells:</p>
<pre><code>.
X
.
.
.
. etc
</code></pre>
<p>Also, I tried to use <code>_getch();</code> but it doesn't output values I just entered. So, is there a way that makes input clearner?</p>
| 0debug |
static void lsi_transfer_data(SCSIRequest *req, uint32_t len)
{
LSIState *s = DO_UPCAST(LSIState, dev.qdev, req->bus->qbus.parent);
int out;
if (s->waiting == 1 || !s->current || req->hba_private != s->current ||
(lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON))) {
if (lsi_queue_req(s, req, len)) {
return;
}
}
out = (s->sstat1 & PHASE_MASK) == PHASE_DO;
DPRINTF("Data ready tag=0x%x len=%d\n", req->tag, len);
s->current->dma_len = len;
s->command_complete = 1;
if (s->waiting) {
if (s->waiting == 1 || s->dbc == 0) {
lsi_resume_script(s);
} else {
lsi_do_dma(s, out);
}
}
}
| 1threat |
How to write my wen functions for comparison? : I wrote a function for vector comparison.
bool mycomp(const vector<int>& vi_a, const vector<int>& vi_b){
for(auto x:vi_a) cout << x;
cout << '\n';
return true;
}
int main(){
vector<int> vi1{2,9,8};
vector<int> vi2{3,5,6};
vector<int> vi = min(vi1, vi2, mycomp);
for(auto x:vi) cout << x;
cout << '\n';
return 0;
}
What's weird is that the output is `356`, instead of `298`. It seems that the two vectors are switched when calling `mycomp`.
p.s. I'd rather not use lambda here, because `mycomp` contains more than one line of code, which is more readable this way. | 0debug |
How to create folder on server pc in C# : <p>How can I create folder on the server-pc on a button click</p>
<pre><code>protected void BtnCreateFolder_Click(object sender, EventArgs e)
{
Directory.CreateDirectory("C:\\NewFolder1");
}
</code></pre>
<p>This code create folder on my local-pc, how can i create folder on server-pc with server-pc ip</p>
| 0debug |
static inline void RENAME(rgb32tobgr32)(const uint8_t *src, uint8_t *dst, long src_size)
{
#ifdef HAVE_MMX
asm volatile (
"xor %%"REG_a", %%"REG_a" \n\t"
ASMALIGN16
"1: \n\t"
PREFETCH" 32(%0, %%"REG_a") \n\t"
"movq (%0, %%"REG_a"), %%mm0 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"pslld $16, %%mm0 \n\t"
"psrld $16, %%mm1 \n\t"
"pand "MANGLE(mask32r)", %%mm0 \n\t"
"pand "MANGLE(mask32g)", %%mm2 \n\t"
"pand "MANGLE(mask32b)", %%mm1 \n\t"
"por %%mm0, %%mm2 \n\t"
"por %%mm1, %%mm2 \n\t"
MOVNTQ" %%mm2, (%1, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (src), "r"(dst), "r" (src_size-7)
: "%"REG_a
);
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#else
unsigned i;
unsigned num_pixels = src_size >> 2;
for(i=0; i<num_pixels; i++)
{
#ifdef WORDS_BIGENDIAN
dst[4*i + 1] = src[4*i + 3];
dst[4*i + 2] = src[4*i + 2];
dst[4*i + 3] = src[4*i + 1];
#else
dst[4*i + 0] = src[4*i + 2];
dst[4*i + 1] = src[4*i + 1];
dst[4*i + 2] = src[4*i + 0];
#endif
}
#endif
}
| 1threat |
void scsi_req_complete(SCSIRequest *req)
{
assert(req->status != -1);
scsi_req_ref(req);
scsi_req_dequeue(req);
req->bus->ops->complete(req->bus, SCSI_REASON_DONE,
req->tag,
req->status);
scsi_req_unref(req);
}
| 1threat |
What kind of encrypting is this? : <p>so I've been trying to figure out what this is for a while:</p>
<p>MzggMTAgMTA= </p>
<p>is it base64? Or a hash? </p>
<p>It looks so familiar to me but I can't find what it is...</p>
<p>Thanks and sorry if my question is silly, I am a beginner, thank you!</p>
| 0debug |
static int usb_linux_update_endp_table(USBHostDevice *s)
{
uint8_t *descriptors;
uint8_t devep, type, alt_interface;
int interface, length, i, ep, pid;
struct endp_data *epd;
for (i = 0; i < MAX_ENDPOINTS; i++) {
s->ep_in[i].type = INVALID_EP_TYPE;
s->ep_out[i].type = INVALID_EP_TYPE;
}
if (s->configuration == 0) {
return 0;
}
descriptors = &s->descr[18];
length = s->descr_len - 18;
i = 0;
if (descriptors[i + 1] != USB_DT_CONFIG ||
descriptors[i + 5] != s->configuration) {
fprintf(stderr, "invalid descriptor data - configuration %d\n",
s->configuration);
return 1;
}
i += descriptors[i];
while (i < length) {
if (descriptors[i + 1] != USB_DT_INTERFACE ||
(descriptors[i + 1] == USB_DT_INTERFACE &&
descriptors[i + 4] == 0)) {
i += descriptors[i];
continue;
}
interface = descriptors[i + 2];
alt_interface = usb_linux_get_alt_setting(s, s->configuration,
interface);
if (descriptors[i + 3] != alt_interface) {
i += descriptors[i];
continue;
}
while (i < length && descriptors[i +1] != USB_DT_ENDPOINT) {
i += descriptors[i];
}
if (i >= length)
break;
while (i < length) {
if (descriptors[i + 1] != USB_DT_ENDPOINT) {
break;
}
devep = descriptors[i + 2];
pid = (devep & USB_DIR_IN) ? USB_TOKEN_IN : USB_TOKEN_OUT;
ep = devep & 0xf;
if (ep == 0) {
fprintf(stderr, "usb-linux: invalid ep descriptor, ep == 0\n");
return 1;
}
switch (descriptors[i + 3] & 0x3) {
case 0x00:
type = USBDEVFS_URB_TYPE_CONTROL;
break;
case 0x01:
type = USBDEVFS_URB_TYPE_ISO;
set_max_packet_size(s, pid, ep, descriptors + i);
break;
case 0x02:
type = USBDEVFS_URB_TYPE_BULK;
break;
case 0x03:
type = USBDEVFS_URB_TYPE_INTERRUPT;
break;
default:
DPRINTF("usb_host: malformed endpoint type\n");
type = USBDEVFS_URB_TYPE_BULK;
}
epd = get_endp(s, pid, ep);
assert(epd->type == INVALID_EP_TYPE);
epd->type = type;
epd->halted = 0;
i += descriptors[i];
}
}
return 0;
}
| 1threat |
how can i Determining if one list has items contained in another list then print index n python : I Want to Determining if one list has items contained in another list then print index python
List1= [10,20,30]
List2=[10,50,80,90,20,30,40,50]
i want to find List 1 10 is present in List 2 or not if present then i need index of list 2. is there any solution or direct function? | 0debug |
static inline int decode_seq_parameter_set(H264Context *h){
MpegEncContext * const s = &h->s;
int profile_idc, level_idc;
int sps_id, i;
SPS *sps;
profile_idc= get_bits(&s->gb, 8);
get_bits1(&s->gb);
get_bits1(&s->gb);
get_bits1(&s->gb);
get_bits1(&s->gb);
get_bits(&s->gb, 4);
level_idc= get_bits(&s->gb, 8);
sps_id= get_ue_golomb(&s->gb);
sps= &h->sps_buffer[ sps_id ];
sps->profile_idc= profile_idc;
sps->level_idc= level_idc;
if(sps->profile_idc >= 100){
if(get_ue_golomb(&s->gb) == 3)
get_bits1(&s->gb);
get_ue_golomb(&s->gb);
get_ue_golomb(&s->gb);
sps->transform_bypass = get_bits1(&s->gb);
decode_scaling_matrices(h, sps, NULL, 1, sps->scaling_matrix4, sps->scaling_matrix8);
}else
sps->scaling_matrix_present = 0;
sps->log2_max_frame_num= get_ue_golomb(&s->gb) + 4;
sps->poc_type= get_ue_golomb(&s->gb);
if(sps->poc_type == 0){
sps->log2_max_poc_lsb= get_ue_golomb(&s->gb) + 4;
} else if(sps->poc_type == 1){
sps->delta_pic_order_always_zero_flag= get_bits1(&s->gb);
sps->offset_for_non_ref_pic= get_se_golomb(&s->gb);
sps->offset_for_top_to_bottom_field= get_se_golomb(&s->gb);
sps->poc_cycle_length= get_ue_golomb(&s->gb);
for(i=0; i<sps->poc_cycle_length; i++)
sps->offset_for_ref_frame[i]= get_se_golomb(&s->gb);
}
if(sps->poc_type > 2){
av_log(h->s.avctx, AV_LOG_ERROR, "illegal POC type %d\n", sps->poc_type);
return -1;
}
sps->ref_frame_count= get_ue_golomb(&s->gb);
if(sps->ref_frame_count > MAX_PICTURE_COUNT-2){
av_log(h->s.avctx, AV_LOG_ERROR, "too many reference frames\n");
}
sps->gaps_in_frame_num_allowed_flag= get_bits1(&s->gb);
sps->mb_width= get_ue_golomb(&s->gb) + 1;
sps->mb_height= get_ue_golomb(&s->gb) + 1;
if((unsigned)sps->mb_width >= INT_MAX/16 || (unsigned)sps->mb_height >= INT_MAX/16 ||
avcodec_check_dimensions(NULL, 16*sps->mb_width, 16*sps->mb_height))
return -1;
sps->frame_mbs_only_flag= get_bits1(&s->gb);
if(!sps->frame_mbs_only_flag)
sps->mb_aff= get_bits1(&s->gb);
else
sps->mb_aff= 0;
sps->direct_8x8_inference_flag= get_bits1(&s->gb);
#ifndef ALLOW_INTERLACE
if(sps->mb_aff)
av_log(h->s.avctx, AV_LOG_ERROR, "MBAFF support not included; enable it at compile-time.\n");
#endif
if(!sps->direct_8x8_inference_flag && sps->mb_aff)
av_log(h->s.avctx, AV_LOG_ERROR, "MBAFF + !direct_8x8_inference is not implemented\n");
sps->crop= get_bits1(&s->gb);
if(sps->crop){
sps->crop_left = get_ue_golomb(&s->gb);
sps->crop_right = get_ue_golomb(&s->gb);
sps->crop_top = get_ue_golomb(&s->gb);
sps->crop_bottom= get_ue_golomb(&s->gb);
if(sps->crop_left || sps->crop_top){
av_log(h->s.avctx, AV_LOG_ERROR, "insane cropping not completely supported, this could look slightly wrong ...\n");
}
}else{
sps->crop_left =
sps->crop_right =
sps->crop_top =
sps->crop_bottom= 0;
}
sps->vui_parameters_present_flag= get_bits1(&s->gb);
if( sps->vui_parameters_present_flag )
decode_vui_parameters(h, sps);
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%d profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s\n",
sps_id, sps->profile_idc, sps->level_idc,
sps->poc_type,
sps->ref_frame_count,
sps->mb_width, sps->mb_height,
sps->frame_mbs_only_flag ? "FRM" : (sps->mb_aff ? "MB-AFF" : "PIC-AFF"),
sps->direct_8x8_inference_flag ? "8B8" : "",
sps->crop_left, sps->crop_right,
sps->crop_top, sps->crop_bottom,
sps->vui_parameters_present_flag ? "VUI" : ""
);
}
return 0;
}
| 1threat |
void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds)
{
struct socket *so, *so_next;
int ret;
global_readfds = readfds;
global_writefds = writefds;
global_xfds = xfds;
updtime();
if (link_up) {
if (time_fasttimo && ((curtime - time_fasttimo) >= 2)) {
tcp_fasttimo();
time_fasttimo = 0;
}
if (do_slowtimo && ((curtime - last_slowtimo) >= 499)) {
ip_slowtimo();
tcp_slowtimo();
last_slowtimo = curtime;
}
}
if (link_up) {
for (so = tcb.so_next; so != &tcb; so = so_next) {
so_next = so->so_next;
if (so->so_state & SS_NOFDREF || so->s == -1)
continue;
if (FD_ISSET(so->s, xfds))
sorecvoob(so);
else if (FD_ISSET(so->s, readfds)) {
if (so->so_state & SS_FACCEPTCONN) {
tcp_connect(so);
continue;
}
ret = soread(so);
if (ret > 0)
tcp_output(sototcpcb(so));
}
if (FD_ISSET(so->s, writefds)) {
if (so->so_state & SS_ISFCONNECTING) {
so->so_state &= ~SS_ISFCONNECTING;
ret = send(so->s, (const void *) &ret, 0, 0);
if (ret < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK ||
errno == EINPROGRESS || errno == ENOTCONN)
continue;
so->so_state &= SS_PERSISTENT_MASK;
so->so_state |= SS_NOFDREF;
}
tcp_input((struct mbuf *)NULL, sizeof(struct ip), so);
} else
ret = sowrite(so);
}
#ifdef PROBE_CONN
if (so->so_state & SS_ISFCONNECTING) {
ret = recv(so->s, (char *)&ret, 0,0);
if (ret < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK ||
errno == EINPROGRESS || errno == ENOTCONN)
continue;
so->so_state &= SS_PERSISTENT_MASK;
so->so_state |= SS_NOFDREF;
} else {
ret = send(so->s, &ret, 0,0);
if (ret < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK ||
errno == EINPROGRESS || errno == ENOTCONN)
continue;
so->so_state &= SS_PERSISTENT_MASK;
so->so_state |= SS_NOFDREF;
} else
so->so_state &= ~SS_ISFCONNECTING;
}
tcp_input((struct mbuf *)NULL, sizeof(struct ip),so);
}
#endif
}
for (so = udb.so_next; so != &udb; so = so_next) {
so_next = so->so_next;
if (so->s != -1 && FD_ISSET(so->s, readfds)) {
sorecvfrom(so);
}
}
}
if (if_queued && link_up)
if_start();
global_readfds = NULL;
global_writefds = NULL;
global_xfds = NULL;
}
| 1threat |
rdt_parse_packet (PayloadContext *rdt, AVStream *st,
AVPacket *pkt, uint32_t *timestamp,
const uint8_t *buf, int len, int flags)
{
int seq = 1, res;
ByteIOContext pb;
if (rdt->audio_pkt_cnt == 0) {
int pos;
init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
flags = (flags & PKT_FLAG_KEY) ? 2 : 0;
res = ff_rm_parse_packet (rdt->rmctx, &pb, st, rdt->rmst[0], len, pkt,
&seq, &flags, timestamp);
pos = url_ftell(&pb);
if (res < 0)
return res;
rdt->audio_pkt_cnt[st->id] = res;
if (rdt->audio_pkt_cnt[st->id] > 0 &&
st->codec->codec_id == CODEC_ID_AAC) {
memcpy (rdt->buffer, buf + pos, len - pos);
rdt->rmctx->pb = av_alloc_put_byte (rdt->buffer, len - pos, 0,
NULL, NULL, NULL, NULL);
}
} else {
ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb, st, rdt->rmst[0], pkt);
if (rdt->audio_pkt_cnt[st->id] == 0 &&
st->codec->codec_id == CODEC_ID_AAC)
av_freep(&rdt->rmctx->pb);
}
pkt->stream_index = st->index;
pkt->pts = *timestamp;
return rdt->audio_pkt_cnt[st->id] > 0;
}
| 1threat |
static ssize_t qio_channel_socket_readv(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
int **fds,
size_t *nfds,
Error **errp)
{
QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc);
ssize_t ret;
struct msghdr msg = { NULL, };
char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)];
int sflags = 0;
memset(control, 0, CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS));
#ifdef MSG_CMSG_CLOEXEC
sflags |= MSG_CMSG_CLOEXEC;
#endif
msg.msg_iov = (struct iovec *)iov;
msg.msg_iovlen = niov;
if (fds && nfds) {
msg.msg_control = control;
msg.msg_controllen = sizeof(control);
}
retry:
ret = recvmsg(sioc->fd, &msg, sflags);
if (ret < 0) {
if (socket_error() == EAGAIN ||
socket_error() == EWOULDBLOCK) {
return QIO_CHANNEL_ERR_BLOCK;
}
if (socket_error() == EINTR) {
goto retry;
}
error_setg_errno(errp, socket_error(),
"Unable to read from socket");
return -1;
}
if (fds && nfds) {
qio_channel_socket_copy_fds(&msg, fds, nfds);
}
return ret;
}
| 1threat |
How to create a editable data-table (with pagination) without using Angular material? : <p>I want to create an editable table in Angular but without using Angular material. The table should also have pagination.</p>
| 0debug |
static void test_visitor_in_uint(TestInputVisitorData *data,
const void *unused)
{
Error *err = NULL;
uint64_t res = 0;
int64_t i64;
double dbl;
int value = 42;
Visitor *v;
v = visitor_input_test_init(data, "%d", value);
visit_type_uint64(v, NULL, &res, &error_abort);
g_assert_cmpuint(res, ==, (uint64_t)value);
visit_type_int(v, NULL, &i64, &error_abort);
g_assert_cmpint(i64, ==, value);
visit_type_number(v, NULL, &dbl, &error_abort);
g_assert_cmpfloat(dbl, ==, value);
v = visitor_input_test_init(data, "%d", -value);
visit_type_uint64(v, NULL, &res, &error_abort);
g_assert_cmpuint(res, ==, (uint64_t)-value);
v = visitor_input_test_init(data, "18446744073709551574");
visit_type_uint64(v, NULL, &res, &err);
error_free_or_abort(&err);
visit_type_number(v, NULL, &dbl, &error_abort);
g_assert_cmpfloat(dbl, ==, 18446744073709552000.0);
}
| 1threat |
How do I correctly use libsodium so that it is compatible between versions? : <p>I'm planning on storing a bunch of records in a file, where each record is then signed with <a href="https://libsodium.org/">libsodium</a>. However, I would like future versions of my program to be able to check signatures the current version has made, and ideally vice-versa.</p>
<p>For the current version of Sodium, signatures are made using the Ed25519 algorithm. I imagine that the default primitive can change in new versions of Sodium (otherwise libsodium wouldn't expose a way to choose a particular one, I think).</p>
<p>Should I...</p>
<ol>
<li>Always use the default primitive (i.e. <code>crypto_sign</code>)</li>
<li>Use a specific primitive (i.e. <code>crypto_sign_ed25519</code>)</li>
<li>Do (1), but store the value of <code>sodium_library_version_major()</code> in the file (either in a dedicated 'sodium version' field or a general 'file format revision' field) and quit if the currently running version is lower</li>
<li>Do (3), but also store <code>crypto_sign_primitive()</code></li>
<li>Do (4), but also store <code>crypto_sign_bytes()</code> and friends</li>
</ol>
<p>...or should I do something else entirely?</p>
<p>My program will be written in C.</p>
| 0debug |
Facebook : You are not logged in: You are not logged in. Please log in and try again : <p>code throws error</p>
<pre><code> $helper = $fb->getRedirectLoginHelper();
$loginUrl = $helper->getLoginUrl("https://apps.facebook.com/{$appname}/", $permissions);
echo "<script>window.top.location.href='".$loginUrl."'</script>";
</code></pre>
<p>Error </p>
<blockquote>
<p>You are not logged in: You are not logged in. Please log in and try again.</p>
</blockquote>
<p>the url which throws the error is (replaced my appname with appname) :</p>
<blockquote>
<p><a href="https://www.facebook.com/v2.7/dialog/oauth?client_id=8651003434372244&state=f2ad3183f9f04355435434534776ae19688ac&response_type=code&sdk=php-sdk-5.3.1&redirect_uri=https%3A%2F%2Fapps.facebook.com%2Fappname%2F&scope=email" rel="noreferrer">https://www.facebook.com/v2.7/dialog/oauth?client_id=8651003434372244&state=f2ad3183f9f04355435434534776ae19688ac&response_type=code&sdk=php-sdk-5.3.1&redirect_uri=https%3A%2F%2Fapps.facebook.com%2Fappname%2F&scope=email</a></p>
</blockquote>
<p>full script</p>
<pre><code> <?php
require_once '../../Facebook/autoload.php';
$fb = new Facebook\Facebook([
'app_id' => "$appid",
'app_secret' => "$appsecret",
'default_graph_version' => 'v2.7',
]);
$helper = $fb->getCanvasHelper();
$permissions = ['email']; // optionnal
try {
$accessToken = $helper->getAccessToken();
} catch(Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
if (isset($accessToken)) {
$accessToken = (string) $accessToken;
$fb->setDefaultAccessToken($accessToken);
if (isset($_GET['code'])) {
header('Location: ./');
}
// validating the access token
try {
$request = $fb->get('/me');
} catch(Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
if ($e->getCode() == 190) {
$helper = $fb->getRedirectLoginHelper();
$loginUrl = $helper->getLoginUrl("https://apps.facebook.com/{$appname}/", $permissions);
echo "<script>window.top.location.href='".$loginUrl."'</script>";
exit;
}
} catch(Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
// getting basic info about user
try {
$profile_request = $fb->get('/me?fields=name,first_name,last_name,email');
$user_profile = $profile_request->getGraphNode()->asArray();
} catch(Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
echo 'Graph returned an error: ' . $e->getMessage();
$url = "https://apps.facebook.com/{$appname}/";
echo '<script>window.top.location.href='.$url.'</script>';
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
// priting basic info about user on the screen
//print_r($user_profile);
// Now you can redirect to another page and use the access token from $_SESSION['facebook_access_token']
} else {
$helper = $fb->getRedirectLoginHelper();
$loginUrl = $helper->getLoginUrl("https://apps.facebook.com/{$appname}/", $permissions);
echo "<script>window.top.location.href='".$loginUrl."'</script>";
}
</code></pre>
| 0debug |
How to convert int eg.99 to char? : <p>How to achieve the same result as this below. I want to add values to char[] using int values.</p>
<pre><code>int i;
char c;
i = 99; /* ASCII DEC 'c' */
c = i; /* 'c'*/
</code></pre>
| 0debug |
- configuration.output.path: The provided value "public" is not an absolute path! with Webpack : <p>I'm using Laravel Mix, that is based on WebPack.</p>
<p>I had it working, and now, it fails with:</p>
<pre><code>Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.output.path: The provided value "public" is not an absolute path!
</code></pre>
<p>If I delete my webpack.mix.js content, it still fails the same way.</p>
<p>Can you help me debug this error, I have no clue how to go forward.</p>
<p>I have already deleted the node_modules folder, and ran <code>npm install</code>, it is still failing. </p>
<p>Any idea how should I solve this?</p>
| 0debug |
Return std::tuple and move semantics / copy elision : <p>I have the following factory function:</p>
<pre><code>auto factory() -> std::tuple<bool, std::vector<int>>
{
std::vector<int> vec;
vec.push_back(1);
vec.push_back(2);
return { true, vec };
}
auto [b, vec] = factory();
</code></pre>
<p>In the return statement is <code>vec</code> considered an <code>xvalue</code> or <code>prvalue</code> and therefore moved or copy elided?</p>
<p>My guess is no, because the compiler, when list-initializing the <code>std::tuple</code> in the return statement, still doesn't know that vec is going to be destroyed. So maybe an explicit std::move is required:</p>
<pre><code>auto factory() -> std::tuple<bool, std::vector<int>>
{
...
return { true, std::move(vec) };
}
auto [b, vec] = factory();
</code></pre>
<p>Is it that really required?</p>
| 0debug |
tube in c read and write in my program : good evening everyone
I have a problem with my program
I would like my program to display the result like this
child: 2 4 6 8 10
parent: 3 6 9 12 15
child 12 14 16 18 20
parent 18 21 24 27 30
etc
#include<stdio.h>
#include<stdlib.h>
#include <unistd.h>
main(int argc,char *argv[]){
int i=0,tube1[2],tube2[2],pid,tube3[2];
if(pipe(tube1)||pipe(tube2)==-1){
perror("pipe");
exit(0);
}
pid=fork();
while(i<100){
if(pid==0){
printf("fils ");
do{
i=i+2;
printf("%d ",i);
}while(i%5!=0);
write(tube1[1],&i,sizeof(int));
read(tube2[0],&i,sizeof(int));
}
else{
printf("pere ");
read(tube1[0],&i,sizeof(int));
do{
i=i+3;
printf("%d ",i);
}while(i%5!=0);
write(tube2[1],&i,sizeof(int));
}
printf("\n");
}
close(tube1[1]);
close(tube1[0]);
close(tube2[1]);
close(tube2[0]);
}
but i have probleme in my program I do not understand why.
and thank you for your help.
| 0debug |
av_cold void ff_hpeldsp_init_x86(HpelDSPContext *c, int flags)
{
int cpu_flags = av_get_cpu_flags();
if (INLINE_MMX(cpu_flags))
hpeldsp_init_mmx(c, flags);
if (EXTERNAL_AMD3DNOW(cpu_flags))
hpeldsp_init_3dnow(c, flags);
if (EXTERNAL_MMXEXT(cpu_flags))
hpeldsp_init_mmxext(c, flags);
if (EXTERNAL_SSE2_FAST(cpu_flags))
hpeldsp_init_sse2_fast(c, flags);
if (CONFIG_VP3_DECODER)
ff_hpeldsp_vp3_init_x86(c, cpu_flags, flags);
}
| 1threat |
Why is this returning a 0 when it should return a 10? : <pre><code>System.out.println((double)(20/200)*100);
</code></pre>
<p>I thought it was a rounding issue initially but the issue still persists when it's a double.</p>
| 0debug |
What is different of Config and ContainerConfig of docker inspect? : <p>I use <code>docker inspect</code> to get the image information. I find there are <code>Config</code> and <code>ContainerConfig</code> in the output, and most value are the same, except the <code>CMD</code>. </p>
<p>In practice, the <code>Config</code> take effect. For I must add cmd in the run command.
<code>
$ docker run -it debian bash
</code></p>
<p>I wonder what is the difference of the two items?</p>
<pre><code>$ docker inspect debian
[
{
"Id": "7abab0fd74f97b6b398a1aca68735c5be153d49922952f67e8696a2225e1d8e1",
......
"ContainerConfig": {
"Hostname": "e5c68db50333",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"/bin/sh",
"-c",
"#(nop) CMD [\"/bin/bash\"]"
],
"Image": "d8bd0657b25f17eef81a3d52b53da5bda4de0cf5cca3dcafec277634ae4b38fb",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"Config": {
"Hostname": "e5c68db50333",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"/bin/bash"
],
"Image": "d8bd0657b25f17eef81a3d52b53da5bda4de0cf5cca3dcafec277634ae4b38fb",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
......
}
]
</code></pre>
| 0debug |
static void inner_add_yblock_bw_16_obmc_32_sse2(const uint8_t *obmc, const long obmc_stride, uint8_t * * block, int b_w, long b_h,
int src_x, int src_y, long src_stride, slice_buffer * sb, int add, uint8_t * dst8){
snow_inner_add_yblock_sse2_header
snow_inner_add_yblock_sse2_start_16("xmm1", "xmm5", "3", "0")
snow_inner_add_yblock_sse2_accum_16("2", "16")
snow_inner_add_yblock_sse2_accum_16("1", "512")
snow_inner_add_yblock_sse2_accum_16("0", "528")
"mov %0, %%"REG_d" \n\t"
"movdqa %%xmm1, %%xmm0 \n\t"
"movdqa %%xmm5, %%xmm4 \n\t"
"punpcklwd %%xmm7, %%xmm0 \n\t"
"paddd (%%"REG_D"), %%xmm0 \n\t"
"punpckhwd %%xmm7, %%xmm1 \n\t"
"paddd 16(%%"REG_D"), %%xmm1 \n\t"
"punpcklwd %%xmm7, %%xmm4 \n\t"
"paddd 32(%%"REG_D"), %%xmm4 \n\t"
"punpckhwd %%xmm7, %%xmm5 \n\t"
"paddd 48(%%"REG_D"), %%xmm5 \n\t"
"paddd %%xmm3, %%xmm0 \n\t"
"paddd %%xmm3, %%xmm1 \n\t"
"paddd %%xmm3, %%xmm4 \n\t"
"paddd %%xmm3, %%xmm5 \n\t"
"psrad $8, %%xmm0 \n\t"
"psrad $8, %%xmm1 \n\t"
"psrad $8, %%xmm4 \n\t"
"psrad $8, %%xmm5 \n\t"
"packssdw %%xmm1, %%xmm0 \n\t"
"packssdw %%xmm5, %%xmm4 \n\t"
"packuswb %%xmm4, %%xmm0 \n\t"
"movdqu %%xmm0, (%%"REG_d") \n\t"
snow_inner_add_yblock_sse2_end_16
}
| 1threat |
I'm pressing the keys, but nothing is happening : Basically, i'm trying to get the camera to move, but it's not having any effect when i click q w e a s or d. I tried asking the original dude who wrote the code, but he's calling me a liar, so idk what to do.
Code: [Pastebin][1]
[1]: http://pastebin.com/8Gm0EuCG | 0debug |
How to nake a Discussion forum or Q&A forum? : <p>"Iam creating website for youngsters, but i want to add a discussion and Q&A forum at site. how can attach those facilities in my website?"</p>
| 0debug |
Lambda statement for finding sub-string in a string from list of strings : <p>I have a list of strings:</p>
<ol>
<li>This</li>
<li>Is</li>
<li>String</li>
<li>Find</li>
</ol>
<p>and a string <strong>"Find my String"</strong> what I need now is a lambda statement to search that my string contains any of the string from the list. </p>
| 0debug |
Could not connect to sql server from windows app : I am trying to connect windows form app with sql server remotely.
But I am getting following exception:
The underlying provider failed on open.
InnerException:
The network path was not found.
Following is my connection string:
<add name="dbEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="Data Source=serverip;Database=dbname;User ID=myuser;Password=mypass;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
It is connecting with my local db but not db on server.
I have checked on server all sql services are running and TCP/IP is enabled and there is also a rule for sql port in firewall.
Is there something that I am missing?
Please guide me.
Thank you. | 0debug |
void register_module_init(void (*fn)(void), module_init_type type)
{
ModuleEntry *e;
ModuleTypeList *l;
e = qemu_mallocz(sizeof(*e));
e->init = fn;
l = find_type(type);
TAILQ_INSERT_TAIL(l, e, node);
}
| 1threat |
android JSONOBJECT with index parsing : is it possible convert Json containing **JSONOBJECT** with **index** to java Model using GsonUtils ? or please mention any other converters.
please check
**json sample**
{ "1": {
"id": 1,
"name": "Bitcoin",
"quotes": {
"USD": {
"price": 6619.87,
},
"BTC": {
"price": 1.0,
}
},
"last_updated": 1529054674
},
"1027": {
"id": 1027,
"name": "Ethereum",
"quotes": {
"USD": {
"price": 495.449,
},
"BTC": {
"price": 0.0748427084,
}
},
"last_updated": 1529054660
}
} | 0debug |
Number of rows changes even after `pandas.merge` with `left` option : <p>I am merging two data frames using <code>pandas.merge</code>. Even after specifying <code>how = left</code> option, I found the number of rows of merged data frame is larger than the original. Why does this happen?</p>
<pre><code>panel = pd.read_csv(file1, encoding ='cp932')
before_len = len(panel)
prof_2000 = pd.read_csv(file2, encoding ='cp932').drop_duplicates()
temp_2000 = pd.merge(panel, prof_2000, left_on='Candidate_u', right_on="name2", how="left")
after_len = len(temp_2000)
print(before_len, after_len)
> 12661 13915
</code></pre>
| 0debug |
Ag-Grid Link with link in the cell : <p>I am building angular 4 app with ag-grid and I am having an issue with trying to figure out how to put a link in the cell. Can anybody help me with that issue?
Thanks</p>
| 0debug |
Ordering and Renaming files by a certain criteria ? : So I have a lot of files (hundreds of them) in a folder, and I like to order them and rename them with an automated process.
the names of those files are in a form similar to this : " Learning Java 46578.avi " and " learning python 46579.avi" and so on, the numbers on the end of each file name are successive.
So my problem is I cant order the files alphabetically because each one starts with a different letter. What I want is to write a script that checks automatically the number at the end of the file name and order the files accordingly and/or place those number in the beginning of all file names so they can be ordered Alphabetically
I hope that my question is good
Thank you | 0debug |
static int wav_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, size;
int64_t left;
AVStream *st;
WAVDemuxContext *wav = s->priv_data;
if (CONFIG_SPDIF_DEMUXER && wav->spdif == 0 &&
s->streams[0]->codec->codec_tag == 1) {
enum AVCodecID codec;
ret = ff_spdif_probe(s->pb->buffer, s->pb->buf_end - s->pb->buffer,
&codec);
if (ret > AVPROBE_SCORE_EXTENSION) {
s->streams[0]->codec->codec_id = codec;
wav->spdif = 1;
} else {
wav->spdif = -1;
}
}
if (CONFIG_SPDIF_DEMUXER && wav->spdif == 1)
return ff_spdif_read_packet(s, pkt);
if (wav->smv_data_ofs > 0) {
int64_t audio_dts, video_dts;
smv_retry:
audio_dts = s->streams[0]->cur_dts;
video_dts = s->streams[1]->cur_dts;
if (audio_dts != AV_NOPTS_VALUE && video_dts != AV_NOPTS_VALUE) {
audio_dts = av_rescale_q(audio_dts, s->streams[0]->time_base, AV_TIME_BASE_Q);
video_dts = av_rescale_q(video_dts, s->streams[1]->time_base, AV_TIME_BASE_Q);
wav->smv_last_stream = wav->smv_given_first ? video_dts > audio_dts : 0;
wav->smv_given_first = 1;
}
wav->smv_last_stream = !wav->smv_last_stream;
wav->smv_last_stream |= wav->audio_eof;
wav->smv_last_stream &= !wav->smv_eof;
if (wav->smv_last_stream) {
uint64_t old_pos = avio_tell(s->pb);
uint64_t new_pos = wav->smv_data_ofs +
wav->smv_block * wav->smv_block_size;
if (avio_seek(s->pb, new_pos, SEEK_SET) < 0) {
ret = AVERROR_EOF;
goto smv_out;
}
size = avio_rl24(s->pb);
ret = av_get_packet(s->pb, pkt, size);
if (ret < 0)
goto smv_out;
pkt->pos -= 3;
pkt->pts = wav->smv_block * wav->smv_frames_per_jpeg + wav->smv_cur_pt;
wav->smv_cur_pt++;
if (wav->smv_frames_per_jpeg > 0)
wav->smv_cur_pt %= wav->smv_frames_per_jpeg;
if (!wav->smv_cur_pt)
wav->smv_block++;
pkt->stream_index = 1;
smv_out:
avio_seek(s->pb, old_pos, SEEK_SET);
if (ret == AVERROR_EOF) {
wav->smv_eof = 1;
goto smv_retry;
}
return ret;
}
}
st = s->streams[0];
left = wav->data_end - avio_tell(s->pb);
if (wav->ignore_length)
left = INT_MAX;
if (left <= 0) {
if (CONFIG_W64_DEMUXER && wav->w64)
left = find_guid(s->pb, ff_w64_guid_data) - 24;
else
left = find_tag(s->pb, MKTAG('d', 'a', 't', 'a'));
if (left < 0) {
wav->audio_eof = 1;
if (wav->smv_data_ofs > 0 && !wav->smv_eof)
goto smv_retry;
return AVERROR_EOF;
}
wav->data_end = avio_tell(s->pb) + left;
}
size = MAX_SIZE;
if (st->codec->block_align > 1) {
if (size < st->codec->block_align)
size = st->codec->block_align;
size = (size / st->codec->block_align) * st->codec->block_align;
}
size = FFMIN(size, left);
ret = av_get_packet(s->pb, pkt, size);
if (ret < 0)
return ret;
pkt->stream_index = 0;
return ret;
}
| 1threat |
uint32_t omap_badwidth_read32(void *opaque, target_phys_addr_t addr)
{
OMAP_32B_REG(addr);
return 0;
}
| 1threat |
My Swift / Xcode app does not perform a simple calculation : [Xcode screenshot ][1]
[1]: https://i.stack.imgur.com/2Gzdj.png
I have a simple app called BillSplitter that calculates a bill to display: input text fields for number of diners, bill total, and tip...
when I run the app the grandTotal output does not calculate properly... the total and the tip do not calculate. Thanks for any help. | 0debug |
Does use of vue.js make use of jQuery obsolete? : <p>Can any experienced vue js developer tell me, will use of vue js make use of jQuery library obsolete ???</p>
| 0debug |
Conversion failed when converting mvarchar : Can someone assist with the error I have below on this statement
Select sh.INTERNAL_SHIPMENT_NUM,sh.shipment_id, sh.carrier, sh.carrier_service,sh.carrier_type,sh.route,sh.customer_name,sh.total_lines,
sh.total_weight,sh.total_volume,sh.SCHEDULED_SHIP_DATE AS SCHEDULED_SHIP_DATE,sh.total_qty,sh.trailing_sts,
CASE when sh.CUSTOMER IN (46003204,30321) then 'CHUB' else '' end CUSTOMER,
(select top 1 sd.customer_po from shipment_detail sd where sd.internal_shipment_num = sh.internal_shipment_num
order by sd.CUSTOMER_PO desc) as CUSTOMER_PO, SH.REJECTION_NOTE
from
shipment_detail sd
inner join shipment_header_view sh
on sd.INTERNAL_SHIPMENT_NUM = sh.INTERNAL_SHIPMENT_NUM
LEFT OUTER JOIN RYDI_orders RO ON SH.SHIPMENT_ID = RO.DELIVERY_id
where sh.leading_sts = 100 and sh.trailing_sts = 100
group by
sh.INTERNAL_SHIPMENT_NUM,sh.shipment_id, sh.carrier, sh.carrier_service,sh.carrier_type,sh.customer,sh.route,sh.customer_name,sh.total_lines,
sh.total_weight,sh.total_volume,sh.SCHEDULED_SHIP_DATE,sh.total_qty,sh.trailing_sts, SH.REJECTION_NOTE
error: Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the nvarchar value '50310H' to data type int. | 0debug |
React Native Android Negative Margins : <p>I'm working on a React Native app that has a user avatar component with an overlap effect:</p>
<p><a href="https://i.stack.imgur.com/3O08i.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/3O08i.jpg" alt="enter image description here"></a></p>
<p>I was able to get it working on iOS since it allows negative margins, but when you use negative margins on Android, it clips the last image like this: </p>
<p><a href="https://i.stack.imgur.com/8OPDj.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/8OPDj.jpg" alt="enter image description here"></a></p>
<p>Here are the styles I'm using:</p>
<pre><code>avatarContainer: {
borderRadius: 20,
width: 40,
height: 40,
marginRight: -11
},
avatar: {
borderRadius: 20,
width: 40,
height: 40
},
</code></pre>
<p>avatarContainer is the white circle behind the image and avatar is the image itself.</p>
<p>What is the best approach that works on both platforms to accomplish the desired styling?</p>
| 0debug |
static int msix_add_config(struct PCIDevice *pdev, unsigned short nentries,
unsigned bar_nr, unsigned bar_size)
{
int config_offset;
uint8_t *config;
uint32_t new_size;
if (nentries < 1 || nentries > PCI_MSIX_FLAGS_QSIZE + 1)
return -EINVAL;
if (bar_size > 0x80000000)
return -ENOSPC;
if (!bar_size) {
new_size = MSIX_PAGE_SIZE;
} else if (bar_size < MSIX_PAGE_SIZE) {
bar_size = MSIX_PAGE_SIZE;
new_size = MSIX_PAGE_SIZE * 2;
} else {
new_size = bar_size * 2;
}
pdev->msix_bar_size = new_size;
config_offset = pci_add_capability(pdev, PCI_CAP_ID_MSIX,
0, MSIX_CAP_LENGTH);
if (config_offset < 0)
return config_offset;
config = pdev->config + config_offset;
pci_set_word(config + PCI_MSIX_FLAGS, nentries - 1);
pci_set_long(config + PCI_MSIX_TABLE, bar_size | bar_nr);
pci_set_long(config + PCI_MSIX_PBA, (bar_size + MSIX_PAGE_PENDING) |
bar_nr);
pdev->msix_cap = config_offset;
pdev->wmask[config_offset + MSIX_CONTROL_OFFSET] |= MSIX_ENABLE_MASK |
MSIX_MASKALL_MASK;
pdev->msix_function_masked = true;
return 0;
}
| 1threat |
Efficiently generate all combinations (at all depths) whose sum is within a specified range : <p>I have a set of 80 numbers and I would like to find the list of combinations which totals up to a given number. The below code works fine but its takes too long could someone please help me with an enhanced version which would process it faster ?</p>
<pre><code>public void sum_up(List<int> numbers, int target)
{
sum_up_recursive(numbers, target, new List<int>());
}
public void sum_up_recursive(List<int> numbers, int target, List<int> partial)
{
int s = 0;
foreach (int x in partial) s += x;
if (s == target)
val +=" sum(" + string.Join(",", partial.ToArray()) + ")=" + target + Environment.NewLine;
if (s == target && string.Join(",", partial.ToArray()).Contains("130") &&
string.Join(",", partial.ToArray()).Contains("104"))
{
string gg = " sum(" + string.Join(",", partial.ToArray()) + ")=" + target;
val += " || || sum(" + string.Join(",", partial.ToArray()) + ")=" + target + Environment.NewLine;
}
if (s >= target)
return;
for (int i = 0; i < numbers.Count; i++)
{
List<int> remaining = new List<int>();
int n = numbers[i];
for (int j = i + 1; j < numbers.Count; j++) remaining.Add(numbers[j]);
List<int> partial_rec = new List<int>(partial);
partial_rec.Add(n);
sum_up_recursive(remaining, target, partial_rec);
}
lblResult.Text = val;
}
private void btnCheck_Click(object sender, EventArgs e)
{
string[] vendorVal = txtvendor.Text.Split(',');
int[] myInts = Array.ConvertAll(vendorVal, s => int.Parse(s));
List<int> numbers = myInts.ToList();
int target = Convert.ToInt32(txtDifference.Text);
sum_up(numbers, target);
}
</code></pre>
<p>Any help is appreciated...</p>
| 0debug |
I need to Merge Two mysql columns to one jtable column : <p>I need to Merge Two mysql columns to one jtable column. Here is the code I used to do that.</p>
<pre><code> ResultSet search = Main.DB.search("select * from users");
DefaultTableModel dtm= (DefaultTableModel)users.getModel();
while (search.next()) {
Vector v = new Vector();
v.add(search.getString(1));
v.add(search.getString(2));
v.add(search.getString(5+""+6)); // need to merge column 6 and 6
v.add(search.getString(7));
dtm.addRow(v);
</code></pre>
<p>Please Help me to do that.</p>
<p>Thank you</p>
| 0debug |
How is the usage of constructors an implementation of data-hiding? : <p>I know what constructors are used for, and kinda know what data hiding means.... found <strong>absolutely no link</strong> among the two (im a dimwit, sedd).... please help?</p>
| 0debug |
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
{
AVFilterContext *ctx = inlink->dst;
VolumeContext *vol = inlink->dst->priv;
AVFilterLink *outlink = inlink->dst->outputs[0];
int nb_samples = buf->nb_samples;
AVFrame *out_buf;
int64_t pos;
AVFrameSideData *sd = av_frame_get_side_data(buf, AV_FRAME_DATA_REPLAYGAIN);
int ret;
if (sd && vol->replaygain != REPLAYGAIN_IGNORE) {
if (vol->replaygain != REPLAYGAIN_DROP) {
AVReplayGain *replaygain = (AVReplayGain*)sd->data;
int32_t gain = 100000;
uint32_t peak = 100000;
float g, p;
if (vol->replaygain == REPLAYGAIN_TRACK &&
replaygain->track_gain != INT32_MIN) {
gain = replaygain->track_gain;
if (replaygain->track_peak != 0)
peak = replaygain->track_peak;
} else if (replaygain->album_gain != INT32_MIN) {
gain = replaygain->album_gain;
if (replaygain->album_peak != 0)
peak = replaygain->album_peak;
} else {
av_log(inlink->dst, AV_LOG_WARNING, "Both ReplayGain gain "
"values are unknown.\n");
}
g = gain / 100000.0f;
p = peak / 100000.0f;
av_log(inlink->dst, AV_LOG_VERBOSE,
"Using gain %f dB from replaygain side data.\n", g);
vol->volume = ff_exp10((g + vol->replaygain_preamp) / 20);
if (vol->replaygain_noclip)
vol->volume = FFMIN(vol->volume, 1.0 / p);
vol->volume_i = (int)(vol->volume * 256 + 0.5);
volume_init(vol);
}
av_frame_remove_side_data(buf, AV_FRAME_DATA_REPLAYGAIN);
}
if (isnan(vol->var_values[VAR_STARTPTS])) {
vol->var_values[VAR_STARTPTS] = TS2D(buf->pts);
vol->var_values[VAR_STARTT ] = TS2T(buf->pts, inlink->time_base);
}
vol->var_values[VAR_PTS] = TS2D(buf->pts);
vol->var_values[VAR_T ] = TS2T(buf->pts, inlink->time_base);
vol->var_values[VAR_N ] = inlink->frame_count_out;
pos = buf->pkt_pos;
vol->var_values[VAR_POS] = pos == -1 ? NAN : pos;
if (vol->eval_mode == EVAL_MODE_FRAME)
set_volume(ctx);
if (vol->volume == 1.0 || vol->volume_i == 256) {
out_buf = buf;
goto end;
}
if (av_frame_is_writable(buf)
&& (vol->precision != PRECISION_FIXED || vol->volume_i > 0)) {
out_buf = buf;
} else {
out_buf = ff_get_audio_buffer(inlink, nb_samples);
if (!out_buf)
return AVERROR(ENOMEM);
ret = av_frame_copy_props(out_buf, buf);
if (ret < 0) {
av_frame_free(&out_buf);
av_frame_free(&buf);
return ret;
}
}
if (vol->precision != PRECISION_FIXED || vol->volume_i > 0) {
int p, plane_samples;
if (av_sample_fmt_is_planar(buf->format))
plane_samples = FFALIGN(nb_samples, vol->samples_align);
else
plane_samples = FFALIGN(nb_samples * vol->channels, vol->samples_align);
if (vol->precision == PRECISION_FIXED) {
for (p = 0; p < vol->planes; p++) {
vol->scale_samples(out_buf->extended_data[p],
buf->extended_data[p], plane_samples,
vol->volume_i);
}
} else if (av_get_packed_sample_fmt(vol->sample_fmt) == AV_SAMPLE_FMT_FLT) {
for (p = 0; p < vol->planes; p++) {
vol->fdsp->vector_fmul_scalar((float *)out_buf->extended_data[p],
(const float *)buf->extended_data[p],
vol->volume, plane_samples);
}
} else {
for (p = 0; p < vol->planes; p++) {
vol->fdsp->vector_dmul_scalar((double *)out_buf->extended_data[p],
(const double *)buf->extended_data[p],
vol->volume, plane_samples);
}
}
}
emms_c();
if (buf != out_buf)
av_frame_free(&buf);
end:
vol->var_values[VAR_NB_CONSUMED_SAMPLES] += out_buf->nb_samples;
return ff_filter_frame(outlink, out_buf);
}
| 1threat |
In Fragment, On listView Click open new activity and pass value to other activity in android studio : list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
sowing sowing=new sowing();
FragmentManager fragmentManager=getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.FragmentContainer,sowing,sowing.getTag())
.addToBackStack("fragBack").commit();
String selectedFromList =(list.getItemAtPosition(position).toString());
}
}); | 0debug |
I have question about diagonal matrix that I have to generate without using any matrix function? : [enter image description here][1]
I have to generate the matrix above but I have some restrictions.
I am not allowed to use any build in functions such as matrix(),cbind,rbind (except length()) and any loop.I must use apply function for this problem
the function have only one parameter lets say 7 to generate this matrix above.
Any thoughts?
My approach is to this problem is I have to have a starting vector and then convert this starting vector to a matrix by using sapply function.And then operate on that matrix to get the required output.
[1]: https://i.stack.imgur.com/uBEzU.png | 0debug |
static void gen_spr_ne_601 (CPUPPCState *env)
{
spr_register(env, SPR_DSISR, "DSISR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_DAR, "DAR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_DECR, "DECR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_decr, &spr_write_decr,
0x00000000);
spr_register(env, SPR_SDR1, "SDR1",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_sdr1, &spr_write_sdr1,
0x00000000);
}
| 1threat |
void cpu_ppc_store_hdecr (CPUPPCState *env, uint32_t value)
{
PowerPCCPU *cpu = ppc_env_get_cpu(env);
_cpu_ppc_store_hdecr(cpu, cpu_ppc_load_hdecr(env), value, 0);
}
| 1threat |
Use Perl to only print if value of column A is present for each value in Column B : So in Perl how can I go through a sample file like so:
1 D Z
1 E F
1 G L
2 D I
2 E L
3 D P
3 G L
So here I want to be able to print out only the values that have the same first value across all values in the second column. Thus output would look like this:
1 D Z
1 E F
1 G L
| 0debug |
static QObject *pci_get_dev_dict(PCIDevice *dev, PCIBus *bus, int bus_num)
{
int class;
QObject *obj;
obj = qobject_from_jsonf("{ 'bus': %d, 'slot': %d, 'function': %d," "'class_info': %p, 'id': %p, 'regions': %p,"
" 'qdev_id': %s }",
bus_num,
PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn),
pci_get_dev_class(dev), pci_get_dev_id(dev),
pci_get_regions_list(dev),
dev->qdev.id ? dev->qdev.id : "");
if (dev->config[PCI_INTERRUPT_PIN] != 0) {
QDict *qdict = qobject_to_qdict(obj);
qdict_put(qdict, "irq", qint_from_int(dev->config[PCI_INTERRUPT_LINE]));
}
class = pci_get_word(dev->config + PCI_CLASS_DEVICE);
if (class == 0x0604) {
QDict *qdict;
QObject *pci_bridge;
pci_bridge = qobject_from_jsonf("{ 'bus': "
"{ 'number': %d, 'secondary': %d, 'subordinate': %d }, "
"'io_range': { 'base': %" PRId64 ", 'limit': %" PRId64 "}, "
"'memory_range': { 'base': %" PRId64 ", 'limit': %" PRId64 "}, "
"'prefetchable_range': { 'base': %" PRId64 ", 'limit': %" PRId64 "} }",
dev->config[0x19], dev->config[PCI_SECONDARY_BUS],
dev->config[PCI_SUBORDINATE_BUS],
pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_IO),
pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_IO),
pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_MEMORY),
pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY),
pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_PREFETCH),
pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_PREFETCH));
if (dev->config[0x19] != 0) {
qdict = qobject_to_qdict(pci_bridge);
qdict_put_obj(qdict, "devices",
pci_get_devices_list(bus, dev->config[0x19]));
}
qdict = qobject_to_qdict(obj);
qdict_put_obj(qdict, "pci_bridge", pci_bridge);
}
return obj;
}
| 1threat |
How to initialize a list to 0 or a string? : I have a list and I want to check if it's null then handle it properly
public List<Entitys.Member> GetALLMembers()
{
List<Models.EF_Model.Member> list = new Models.CRUD.Member().Get_AllMemeberRecords();
//this is null and it throws exception => list
List<Entitys.Member> ListMember = new List<Entitys.Member>();
if (list!=null)
{
foreach (var item in list)
{
ListMember.Add(new Entitys.Member()
{
//doing sth
});
}
return ListMember;
}
else
{
return()
}
}
want to initialize it to sth or a string and then in my controller throw a message
how can I initialize a List in this way?
| 0debug |
what is the red arrow on the left of the line numbers in Sublime : <p><a href="https://i.stack.imgur.com/FiyG0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FiyG0.png" alt="see the red arrow on the left of the picture"></a></p>
<p>what does the red arrow mean in Sublime text editor between line 13 and 14?</p>
| 0debug |
AWS: Custom SSL certificate option is disabled in CloudFront, but I created a SSL certificate using AWS Certificate Manager : <p>I am creating a SSL certificate for my amazon S3 static website. I created a SSL certificate using Certificate Manager for my domain and its status is 'Issued'. I am creating a CloudFront Distribution, but the Custom SSL Certificate option is disabled. </p>
<p>Will it take some time (a day or more) before I can see my custom SSL certificate? Or am I doing something wrong?</p>
| 0debug |
Sorting list of dicts in order of values : <p>How can i do this:</p>
<blockquote>
<p>In: </p>
</blockquote>
<pre><code>a = [{'10100': u'Z'}, {u'00101': u'C'}, {u'01100': u'B'}, {u'00111': u'T'}]
</code></pre>
<blockquote>
<p>Out:</p>
</blockquote>
<pre><code>a = [{u'01100': u'B'}, {u'00101': u'C'}, {u'00111': u'T'}, {'10100': u'Z'}]
</code></pre>
<p>I mean in order to value</p>
| 0debug |
Rails: Can't verify CSRF token authenticity when making a POST request : <p>I want to make <code>POST request</code> to my local dev, like this:</p>
<pre><code> HTTParty.post('http://localhost:3000/fetch_heroku',
:body => {:type => 'product'},)
</code></pre>
<p>However, from the server console it reports </p>
<pre><code>Started POST "/fetch_heroku" for 127.0.0.1 at 2016-02-03 23:33:39 +0800
ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by AdminController#fetch_heroku as */*
Parameters: {"type"=>"product"}
Can't verify CSRF token authenticity
Completed 422 Unprocessable Entity in 1ms
</code></pre>
<p>Here is my controller and routes setup, it's quite simple. </p>
<pre><code> def fetch_heroku
if params[:type] == 'product'
flash[:alert] = 'Fetch Product From Heroku'
Heroku.get_product
end
end
post 'fetch_heroku' => 'admin#fetch_heroku'
</code></pre>
<p>I'm not sure what I need to do? To turn off the CSRF would certainly work, but I think it should be my mistake when creating such an API.</p>
<p>Is there any other setup I need to do?</p>
| 0debug |
how to add info while copying from multiple fields using javascript? : i have a tiny request.. how can i add javascript to a single button as to copy text to the clipboard from multiple HTML input areas including a fixed text, while inserting a line break between each field?
to give you a better idea, it's simply a webpage that will allow us at work to take very repetitive notes that we we always write (same points) made of 10 points, and with a click it'll copy the entire fields + the text that refers to the input in a form that is ready to be pasted anywhere.
thank you very much ♥ | 0debug |
static av_always_inline int simple_limit(uint8_t *p, ptrdiff_t stride, int flim)
{
LOAD_PIXELS
return 2 * FFABS(p0 - q0) + (FFABS(p1 - q1) >> 1) <= flim;
}
| 1threat |
unable to generate proper output : <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.harshil.home.myapplication">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.harshil.home.myapplication.CustomActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<action android:name="com.harshil.home.myapplication.LAUNCH"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="http"/>
</intent-filter>
</activity>
</application>
</manifest>
What is wrong with above android manifest.xml?
Everytime my app is crashing. I m new to stackoverflow so didnt know how to post so i just copy pasted.
| 0debug |
How to disable automatic build from scm change in Jenkinsfile : <p>I have a Jenkinsfile that I've set up with a <code>cron</code> for a <code>pipelineTriggers</code> parameter. I can't seem to figure out how to disable the job from building from a merge to the master branch of the repo. Is there a way in the Jenkinsfile to disable the automatic build from an scm change?</p>
| 0debug |
Triggering a Lambda function upon deleting a user on AWS Cognito User Pool : <p>AWS Cognito User Pools have some pre-defined events to handle user signup, confirmation etc. The full list is <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html#cognito-user-pools-lambda-trigger-event-parameter-shared" rel="noreferrer">here</a>.</p>
<p>However, there is no apparent trigger for <strong>deleting a user</strong>. </p>
<p>So, is there any way one can trigger a Lambda function when a user is deleted from Cognito User Pool (of course, with arguments like username and/or email address)?</p>
| 0debug |
Flag N+1 queries with bullet in Rspec : <p>I'm trying to flag N+1 and places in the code where I can add counter caches, using the <a href="https://github.com/flyerhzm/bullet" rel="noreferrer">bullet gem</a>. But doing everything manually to check N+1 queries, seems very painfully, so I tried to use Bullet with Rspec, using the setup steps they recommend:</p>
<pre><code># config/environments/test.rb
config.after_initialize do
Bullet.enable = true
Bullet.bullet_logger = true
Bullet.raise = true # raise an error if n+1 query occurs
end
# spec/spec_helper.rb
if Bullet.enable?
config.before(:each) do
Bullet.start_request
end
config.after(:each) do
Bullet.perform_out_of_channel_notifications if Bullet.notification?
Bullet.end_request
end
end
</code></pre>
<p>But when I run the specs, seems to flag N+1 queries within specs itself rather than the app. Do you know if it's possible to achieve what I want?</p>
| 0debug |
void qmp_migrate_set_downtime(double value, Error **errp)
{
value *= 1e9;
value = MAX(0, MIN(UINT64_MAX, value));
max_downtime = (uint64_t)value;
}
| 1threat |
static uint64_t find_any_startcode(ByteIOContext *bc, int64_t pos){
uint64_t state=0;
if(pos >= 0)
url_fseek(bc, pos, SEEK_SET);
while(bytes_left(bc)){
state= (state<<8) | get_byte(bc);
if((state>>56) != 'N')
continue;
switch(state){
case MAIN_STARTCODE:
case STREAM_STARTCODE:
case KEYFRAME_STARTCODE:
case INFO_STARTCODE:
case INDEX_STARTCODE:
return state;
}
}
return 0;
}
| 1threat |
Hide/Show bottomNavigationView on Scroll : <p>I have to hide bottom navigation view on up scroll and show on down scroll .how to implement this?
my layout is like this </p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_above="@+id/navigation"
android:layout_alignParentTop="true"
android:layout_marginBottom="5dp">
<FrameLayout
android:id="@+id/container1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="?android:attr/windowBackground"
app:layout_scrollFlags="scroll|enterAlways|snap"
app:menu="@menu/dashboard_slider_menu" />
</RelativeLayout>
</code></pre>
<p>I have attached screenshot of view. Kindly check it.</p>
<p><a href="https://i.stack.imgur.com/Hwm9I.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Hwm9I.png" alt="enter image description here"></a></p>
| 0debug |
static unsigned int dec_addi_acr(DisasContext *dc)
{
TCGv t0;
DIS(fprintf (logfile, "addi.%c $r%u, $r%u, $acr\n",
memsize_char(memsize_zz(dc)), dc->op2, dc->op1));
cris_cc_mask(dc, 0);
t0 = tcg_temp_new(TCG_TYPE_TL);
tcg_gen_shl_tl(t0, cpu_R[dc->op2], tcg_const_tl(dc->zzsize));
tcg_gen_add_tl(cpu_R[R_ACR], cpu_R[dc->op1], t0);
return 2;
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.