problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
void opt_output_file(const char *filename)
{
AVStream *st;
AVFormatContext *oc;
int use_video, use_audio, nb_streams, input_has_video, input_has_audio;
int codec_id;
if (!strcmp(filename, "-"))
filename = "pipe:";
oc = av_mallocz(sizeof(AVFormatContext));
if (!file_format) {
file_format = guess_format(NULL, filename, NULL);
if (!file_format)
file_format = &mpeg_mux_format;
}
oc->format = file_format;
if (!strcmp(file_format->name, "ffm") &&
strstart(filename, "http:", NULL)) {
if (read_ffserver_streams(oc, filename) < 0) {
fprintf(stderr, "Could not read stream parameters from '%s'\n", filename);
exit(1);
}
} else {
use_video = file_format->video_codec != CODEC_ID_NONE;
use_audio = file_format->audio_codec != CODEC_ID_NONE;
check_audio_video_inputs(&input_has_video, &input_has_audio);
if (!input_has_video)
use_video = 0;
if (!input_has_audio)
use_audio = 0;
if (audio_disable) {
use_audio = 0;
}
if (video_disable) {
use_video = 0;
}
nb_streams = 0;
if (use_video) {
AVCodecContext *video_enc;
st = av_mallocz(sizeof(AVStream));
if (!st) {
fprintf(stderr, "Could not alloc stream\n");
exit(1);
}
video_enc = &st->codec;
codec_id = file_format->video_codec;
if (video_codec_id != CODEC_ID_NONE)
codec_id = video_codec_id;
video_enc->codec_id = codec_id;
video_enc->codec_type = CODEC_TYPE_VIDEO;
video_enc->bit_rate = video_bit_rate;
video_enc->frame_rate = frame_rate;
video_enc->width = frame_width;
video_enc->height = frame_height;
if (!intra_only)
video_enc->gop_size = gop_size;
else
video_enc->gop_size = 0;
if (video_qscale || same_quality) {
video_enc->flags |= CODEC_FLAG_QSCALE;
video_enc->quality = video_qscale;
}
if (oc->format == &ppm_format ||
oc->format == &ppmpipe_format) {
video_enc->pix_fmt = PIX_FMT_RGB24;
}
oc->streams[nb_streams] = st;
nb_streams++;
}
if (use_audio) {
AVCodecContext *audio_enc;
st = av_mallocz(sizeof(AVStream));
if (!st) {
fprintf(stderr, "Could not alloc stream\n");
exit(1);
}
audio_enc = &st->codec;
codec_id = file_format->audio_codec;
if (audio_codec_id != CODEC_ID_NONE)
codec_id = audio_codec_id;
audio_enc->codec_id = codec_id;
audio_enc->codec_type = CODEC_TYPE_AUDIO;
audio_enc->bit_rate = audio_bit_rate;
audio_enc->sample_rate = audio_sample_rate;
audio_enc->channels = audio_channels;
oc->streams[nb_streams] = st;
nb_streams++;
}
oc->nb_streams = nb_streams;
if (!nb_streams) {
fprintf(stderr, "No audio or video streams available\n");
exit(1);
}
if (str_title)
nstrcpy(oc->title, sizeof(oc->title), str_title);
if (str_author)
nstrcpy(oc->author, sizeof(oc->author), str_author);
if (str_copyright)
nstrcpy(oc->copyright, sizeof(oc->copyright), str_copyright);
if (str_comment)
nstrcpy(oc->comment, sizeof(oc->comment), str_comment);
}
output_files[nb_output_files] = oc;
dump_format(oc, nb_output_files, filename, 1);
nb_output_files++;
strcpy(oc->filename, filename);
if (oc->format->flags & AVFMT_NEEDNUMBER) {
if (filename_number_test(oc->filename) < 0)
exit(1);
}
if (!(oc->format->flags & AVFMT_NOFILE)) {
if (!file_overwrite &&
(strchr(filename, ':') == NULL ||
strstart(filename, "file:", NULL))) {
if (url_exist(filename)) {
int c;
printf("File '%s' already exists. Overwrite ? [y/N] ", filename);
fflush(stdout);
c = getchar();
if (toupper(c) != 'Y') {
fprintf(stderr, "Not overwriting - exiting\n");
exit(1);
}
}
}
if (url_fopen(&oc->pb, filename, URL_WRONLY) < 0) {
fprintf(stderr, "Could not open '%s'\n", filename);
exit(1);
}
}
file_format = NULL;
audio_disable = 0;
video_disable = 0;
audio_codec_id = CODEC_ID_NONE;
video_codec_id = CODEC_ID_NONE;
}
| 1threat |
Sql sever wirdest error ever : The C# code:
SqlConnection c;
string str = "Data Source =(LocalDB)\\MSSQLLocalDB;";
str += "AttachDbFilename=|DataDirectory|\\DinoData.mdf;";
str += "Integrated Security= True";
c = new SqlConnection(str);
if (Session["Conect"] != null)
{
if ((bool)Session["Conect"])
{
logdiv.Visible = false;
Usernamec.InnerHtml = (string)Session["CurentUserid"];
Connected.Visible = true;
SqlCommand exp = new SqlCommand("SELECT xp FROM[User] Where Username = @username", c);
exp.Parameters.AddWithValue("@username", (string)Session["CurentUserid"]);
c.Open();
Session["exp"] = exp.ExecuteReader();
c.Close();
int b = (int)Session["exp"] / 2;
string a = b + "px";
xp.Style.Add("width", ((string)Session["exp"])+"%");
}
else
{
Connected.Visible = false;
logdiv.Visible = true;
}
}
The Error:
> An exception of type 'System.InvalidCastException' occurred in
> App_Web_ump4h2pq.dll but was not handled in user code
>
> Additional information: Specified cast is not valid. | 0debug |
What is the use of this line. i am new for lua programming char lua :
code=55
local convert=string.char(4,1,0,0,0,0,math.floor(224 + (code/16)), code % 16)
print(convert)
here-string.character inside using (4,1,0,0,0,0,0) what is purpose this using. anyone have to answer please help me.
| 0debug |
Write sql query to Entity Framwork : select * from [InterViewerComment] where commentID in(
select max(commentID) as commentID from [InterViewerComment] where jobID=45 group by qenID)
This Query is correct in SQl but i want to re write it in EntityFramwork
basically i want latest comment for each qenID based on job ID | 0debug |
Laravel environment variables leaking between applications when they call each other through GuzzleHttp : <p>I have two Laravel 5.2 applications (lets call them A and B) on my local machine, both configured on two different virtualhosts on my local Apache 2.4 development server.</p>
<p>Both applications sometimes are calling each other through GuzzleHttp. </p>
<p>At one point I wanted to use encryption and I started getting "mac is invalid" exceptions from Laravel's Encrypter.</p>
<p>While investigating the issue, I found that when app A calls app B, app B suddenly gets encryption key (app.key) from app A! This causes encryption to break because the values on app B where encrypted using app's B encryption key.</p>
<p>While debugging, I found the Dotenv library has some logic to keep existing variables if they are set. I found that both $_ENV and $_SERVER do not have leaked variables, but <code>getenv()</code> has them!</p>
<p>I'm a bit confused because PHP <code>putenv</code> says:</p>
<blockquote>
<p>The environment variable will only exist for the duration of the current request.</p>
</blockquote>
<p>It seems, if during current request I launch another request through GuzzleHttp, the variables set by Dotenv in A using <code>putenv()</code> suddenly become available in app B which is being requested by GuzzleHttp!</p>
<p>I understand that this will not be an issue on production servers where config cache will be used instead of Dotenv and most probably both apps will run on different Apache servers, but this behavior is breaking my development process.</p>
<p><strong>How do I configure Laravel or GuzzleHttp or Apache or PHP to prevent this <code>putenv()</code> leakage from app A into app B?</strong></p>
| 0debug |
static av_cold int xma_decode_init(AVCodecContext *avctx)
{
XMADecodeCtx *s = avctx->priv_data;
int i, ret;
for (i = 0; i < avctx->channels / 2; i++) {
ret = decode_init(&s->xma[i], avctx);
s->frames[i] = av_frame_alloc();
if (!s->frames[i])
return AVERROR(ENOMEM);
s->frames[i]->nb_samples = 512;
if ((ret = ff_get_buffer(avctx, s->frames[i], 0)) < 0) {
return AVERROR(ENOMEM);
}
}
return ret;
}
| 1threat |
Android weird test sharding : <p>I'm experimenting with test sharding on Android and I'm getting pretty weird results:</p>
<pre><code>+ adb -s emulator-5580 shell am instrument -e numShards 2 -e shardIndex 0 -e class com.package.etc.automation.Tests.SanityTest.SanityTest -w com.package.etc.test/android.support.test.runner.AndroidJUnitRunner
com.package.etc.automation.Tests.SanityTest.SanityTest:..........
Time: 306.578
OK (10 tests)
+ adb -s emulator-5582 shell am instrument -e numShards 2 -e shardIndex 1 -e class com.package.etc.automation.Tests.SanityTest.SanityTest -w com.package.etc.test/android.support.test.runner.AndroidJUnitRunner
com.package.etc.automation.Tests.SanityTest.SanityTest:......................
Time: 645.723
OK (22 tests)
</code></pre>
<p>As you can see, adb split the tests into two uneven groups. The second one has twice as many tests as the first one and executes twice as long. Not the best parallelism if you ask me.</p>
<p>Is there a possibility to control the distribution of tests, or at least force adb to split the tests evenly?</p>
| 0debug |
Angular 2 Http testing multiple connections : <p>Can anyone help me with testing Http requests in Angular 2. I have a service that gets a stream from two http requests. How do I mock this behaviour in my test?</p>
<pre><code>loadData() {
return Observable.forkJoin(
this.http.get('file1.json').map((res:Response) => res.json()),
this.http.get('file2.json').map((res:Response) => res.json())
).map(data => {
return {
x: data[0],
y: data[1]
}
});
}
</code></pre>
<p>Here is my test code, I have tried to use an array of connections but I get an error message saying "Failed: Connection has already been resolved". I have left the body of the connections blank to avoid exposing sensitive data. </p>
<pre><code>describe('Test Load Init Data', () => {
it('should load Menu Zones and Menu Sections',
inject([XHRBackend, AppInitService], (mockBackend, appInitService) => {
console.log('Lets do some testing');
//first we register a mock response
mockBackend.connections.subscribe(
(connection:MockConnection) => {
return [
connection.mockRespond(new Response(
new ResponseOptions({
body: []
})
)),
connection.mockRespond(new Response(
new ResponseOptions({
body: []
})
))
];
});
appInitService.loadData().subscribe(data => {
expect(data.x.length).toBeGreaterThan(0);
expect(data.y.length).toBeGreaterThan(0);
});
}));
});
</code></pre>
| 0debug |
static void do_commit(int argc, const char **argv)
{
int i;
for (i = 0; i < MAX_DISKS; i++) {
if (bs_table[i])
bdrv_commit(bs_table[i]);
}
}
| 1threat |
static void vfio_platform_realize(DeviceState *dev, Error **errp)
{
VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(dev);
SysBusDevice *sbdev = SYS_BUS_DEVICE(dev);
VFIODevice *vbasedev = &vdev->vbasedev;
VFIOINTp *intp;
int i, ret;
vbasedev->type = VFIO_DEVICE_TYPE_PLATFORM;
vbasedev->ops = &vfio_platform_ops;
trace_vfio_platform_realize(vbasedev->name, vdev->compat);
ret = vfio_base_device_init(vbasedev);
if (ret) {
error_setg(errp, "vfio: vfio_base_device_init failed for %s",
vbasedev->name);
return;
}
for (i = 0; i < vbasedev->num_regions; i++) {
vfio_map_region(vdev, i);
sysbus_init_mmio(sbdev, &vdev->regions[i]->mem);
}
QLIST_FOREACH(intp, &vdev->intp_list, next) {
vfio_start_eventfd_injection(intp);
}
}
| 1threat |
How to fix a While Loop only running once : Im trying to calculate how long until India surpasses China in population, my while loop only executes the first iteration though.
I have tried setting a while loop to execute within the loop itself and it just became an infinite loop instead,i have tried indenting print within and outside the loop as well.
while India<China :
China += Cgrowth*China
India += Igrowth*India
count += 1
print(count)
My output always ends in 1.
i did the math out and even after one loop the statement is still true, so why is print(count) being ran while the loops conditions are false? | 0debug |
How do i query mysql database using where like or like in array? : <p>How do i query mysql database using where like (array) or like (array)? </p>
| 0debug |
Its showing some error .. How to correct this query? : My problem is when I run this query , its showing some error like
Warning: mysqli::query(): (21000/1242): Subquery returns more than 1 row
Help me to correct this query. Thank You in advance
"SELECT a.sname,a.date,a.Roll_Number,b.branch,
COUNT(DISTINCT a.date) AS totaldays,
(SELECT COUNT(a.attendance_status)
FROM attendance as a , branch as b
WHERE a.attendance_status='Present' and b.id='".$_GET['id']."' and a.branch=b.branch GROUP BY a.sid )
as present_days
FROM attendance as a , branch as b
WHERE b.id='".$_GET['id']."'
and a.branch=b.branch
GROUP BY a.sname "; | 0debug |
Vector Drawable in the circle : <p>is there an easy way to generate Vector Drawable that is a circle with the icon inside from the existing vector drawable?</p>
<p>Example:
<a href="https://i.stack.imgur.com/X73Vn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/X73Vn.png" alt="existing vector drawable"></a></p>
<p><a href="https://i.stack.imgur.com/1774u.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1774u.png" alt="generated vector drawable, circle with empty icon inside"></a></p>
| 0debug |
static void vmdk_refresh_limits(BlockDriverState *bs, Error **errp)
{
BDRVVmdkState *s = bs->opaque;
int i;
for (i = 0; i < s->num_extents; i++) {
if (!s->extents[i].flat) {
bs->bl.write_zeroes_alignment =
MAX(bs->bl.write_zeroes_alignment,
s->extents[i].cluster_sectors);
}
}
}
| 1threat |
I need it to run in a way that it wont need any spaces. : I need this program to be able to run without requiring any spaces between each character. As of right not, this code will calculate the expressions if there is a space in between every character entered, I need it to run so that it will run without or with spaces as well. Thank you
public class InfixEval {
Stack<String> operandsStk; //for operands
Stack<Character> operatorsStk;//for operators +,-,*,/,(,)
InfixEval()
{
//instantiate the stacks
operandsStk=new Stack<String>();
operatorsStk=new Stack<Character>();
}
//evaluates and returns the result
public int evaluate(String exp) throws ArithmeticException
{
boolean fail=false;
try
{
//tokenize the expression
String tokens[]=exp.split("");
for(int i=0;i<tokens.length;i++)
{
//if it is an operand push it onto the operand stack
if(!tokens[i].equals("+")&& !tokens[i].equals("*")&&!tokens[i].equals("-")
&&!tokens[i].equals("/") && !tokens[i].equals("(")&&!tokens[i].equals(")"))
{
operandsStk.push(tokens[i]);
}
//if it is a left parenthesis
else if(tokens[i].equals("("))
{
//push it onto the operator stack
operatorsStk.push((Character)tokens[i].charAt(0));
}
//it is a right parenthesis
else if(tokens[i].equals(")"))
{
//while top of the operator stack is not a left parenthesis
while(operatorsStk.peek()!='(')
{
// pop two operands and an operator
int x=Integer.parseInt(operandsStk.pop());
int y=Integer.parseInt(operandsStk.pop());
char opr=operatorsStk.pop();
// perform the calculation
int result=0;
if (opr=='+')
{
result= y+x;
//push the result onto the operand stack
operandsStk.push(result+"");
}
else if(opr=='-')
{
result= y-x;
//push the result onto the operand stack
operandsStk.push(result+"");
}
else if(opr=='*')
{
result= y*x;
//push the result onto the operand stack
operandsStk.push(result+"");
}
else if(opr=='/')
{
result=y/x;
//push the result onto the operand stack
operandsStk.push(result+"");
}
}
//pop top of the operator stack and ignore it
operatorsStk.pop();
}
//if it is an operator
else if(tokens[i].equals("+")||tokens[i].equals("-")
||tokens[i].equals("*")||tokens[i].equals("/"))
{
//while the operator stack is not empty and
//the operator at the top of the stack has higher
//or the same precedence than the current operator
while(!operatorsStk.empty()&&hasHigherPrecedence(operatorsStk.peek(),tokens[i].charAt(0)))
{
//pop two operands
int x=Integer.parseInt(operandsStk.pop());
int y=Integer.parseInt(operandsStk.pop());
char opr=operatorsStk.pop();
//perform the calculation
int result=0;
if (opr=='+')
{
result= y+x;
//push the result onto the operand stack
operandsStk.push(result+"");
}
else if(opr=='-')
{
result= y-x;
//push the result onto the operand stack
operandsStk.push(result+"");
}
else if(opr=='*')
{
result= y*x;
//push the result onto the operand stack
operandsStk.push(result+"");
}
else if(opr=='/')
{
result=y/x;
//push the result onto the operand stack
operandsStk.push(result+"");
}
}
operatorsStk.push(tokens[i].charAt(0));
}
}
//while the operator stack is not empty
while(!operatorsStk.empty())
{
// pop two operands and an operator
int x=Integer.parseInt(operandsStk.pop());
int y=Integer.parseInt(operandsStk.pop());
char opr=operatorsStk.pop();
//perform the calculation
int result=0;
if (opr=='+')
{
result= y+x;
// push the result onto the operand stack
operandsStk.push(result+"");
}
else if(opr=='-')
{
result= y-x;
// push the result onto the operand stack
operandsStk.push(result+"");
}
else if(opr=='*')
{
result= y*x;
// push the result onto the operand stack
operandsStk.push(result+"");
}
else if(opr=='/')
{
result=y/x;
// push the result onto the operand stack
operandsStk.push(result+"");
}
}
}
catch(EmptyStackException e)
{
//if an error occurs
fail=true;
}
if(fail==false)
//the final result is at the top of the operand stack and return it
return Integer.parseInt(operandsStk.pop());
else
return -1;
}
//returns true, if the top has high precedence than current
boolean hasHigherPrecedence(char top, char current)
{
int topPre=-1;
int curPre=-1;
if(top == '+' || top == '-')
{
topPre=0;
}
if(top == '*' || top == '/' || top== '%')
{
topPre=1;
}
if(current == '+' || current == '-')
{
curPre=0;
}
if(current == '*' || current == '/' )
{
curPre=1;
}
if(topPre>=curPre)
return true;
else
return false;
}
} | 0debug |
static int nvme_init(PCIDevice *pci_dev)
{
NvmeCtrl *n = NVME(pci_dev);
NvmeIdCtrl *id = &n->id_ctrl;
int i;
int64_t bs_size;
uint8_t *pci_conf;
if (!(n->conf.bs)) {
return -1;
}
bs_size = bdrv_getlength(n->conf.bs);
if (bs_size < 0) {
return -1;
}
blkconf_serial(&n->conf, &n->serial);
if (!n->serial) {
return -1;
}
pci_conf = pci_dev->config;
pci_conf[PCI_INTERRUPT_PIN] = 1;
pci_config_set_prog_interface(pci_dev->config, 0x2);
pci_config_set_class(pci_dev->config, PCI_CLASS_STORAGE_EXPRESS);
pcie_endpoint_cap_init(&n->parent_obj, 0x80);
n->num_namespaces = 1;
n->num_queues = 64;
n->reg_size = 1 << qemu_fls(0x1004 + 2 * (n->num_queues + 1) * 4);
n->ns_size = bs_size / (uint64_t)n->num_namespaces;
n->namespaces = g_malloc0(sizeof(*n->namespaces)*n->num_namespaces);
n->sq = g_malloc0(sizeof(*n->sq)*n->num_queues);
n->cq = g_malloc0(sizeof(*n->cq)*n->num_queues);
memory_region_init_io(&n->iomem, OBJECT(n), &nvme_mmio_ops, n,
"nvme", n->reg_size);
pci_register_bar(&n->parent_obj, 0,
PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64,
&n->iomem);
msix_init_exclusive_bar(&n->parent_obj, n->num_queues, 4);
id->vid = cpu_to_le16(pci_get_word(pci_conf + PCI_VENDOR_ID));
id->ssvid = cpu_to_le16(pci_get_word(pci_conf + PCI_SUBSYSTEM_VENDOR_ID));
strpadcpy((char *)id->mn, sizeof(id->mn), "QEMU NVMe Ctrl", ' ');
strpadcpy((char *)id->fr, sizeof(id->fr), "1.0", ' ');
strpadcpy((char *)id->sn, sizeof(id->sn), n->serial, ' ');
id->rab = 6;
id->ieee[0] = 0x00;
id->ieee[1] = 0x02;
id->ieee[2] = 0xb3;
id->oacs = cpu_to_le16(0);
id->frmw = 7 << 1;
id->lpa = 1 << 0;
id->sqes = (0x6 << 4) | 0x6;
id->cqes = (0x4 << 4) | 0x4;
id->nn = cpu_to_le32(n->num_namespaces);
id->psd[0].mp = cpu_to_le16(0x9c4);
id->psd[0].enlat = cpu_to_le32(0x10);
id->psd[0].exlat = cpu_to_le32(0x4);
n->bar.cap = 0;
NVME_CAP_SET_MQES(n->bar.cap, 0x7ff);
NVME_CAP_SET_CQR(n->bar.cap, 1);
NVME_CAP_SET_AMS(n->bar.cap, 1);
NVME_CAP_SET_TO(n->bar.cap, 0xf);
NVME_CAP_SET_CSS(n->bar.cap, 1);
n->bar.vs = 0x00010001;
n->bar.intmc = n->bar.intms = 0;
for (i = 0; i < n->num_namespaces; i++) {
NvmeNamespace *ns = &n->namespaces[i];
NvmeIdNs *id_ns = &ns->id_ns;
id_ns->nsfeat = 0;
id_ns->nlbaf = 0;
id_ns->flbas = 0;
id_ns->mc = 0;
id_ns->dpc = 0;
id_ns->dps = 0;
id_ns->lbaf[0].ds = BDRV_SECTOR_BITS;
id_ns->ncap = id_ns->nuse = id_ns->nsze =
cpu_to_le64(n->ns_size >>
id_ns->lbaf[NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas)].ds);
}
return 0;
}
| 1threat |
Hello, please help in fixing error related to combintion of IF and choose function below : I have used used choose function to extract data from 4 diff sheets =CHOOSE($H$3,sheet1!A2,sheet2!A2,sheet3!A2,sheet4!A2). Now, I want to use "IF" function with CHOOSE to replace the false results with "". But it's not working, please let me know is there any problem with syntax below.
=IF(CHOOSE($H$3,sheet1!A2,sheet2!A2,sheet3!A2,sheet4!A2),CHOOSE($H$3,sheet1!A2,sheet2!A2,sheet3!A2,sheet4!A2),"") | 0debug |
Unused parameters passed to Capybara::Queries::SelectorQuery : <p>I have spec like this:</p>
<pre><code> it 'contains Delete link' do
expect(page).to have_link('Delete', admin_disease_path(disease))
end
</code></pre>
<p>when I run specs it returns warning in the console:</p>
<pre><code>Unused parameters passed to Capybara::Queries::SelectorQuery : ["/admin/diseases/913"]
</code></pre>
<p>How can I fix this?</p>
| 0debug |
void virtio_scsi_dataplane_start(VirtIOSCSI *s)
{
int i;
int rc;
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
if (s->dataplane_started ||
s->dataplane_starting ||
s->dataplane_fenced ||
s->ctx != iothread_get_aio_context(vs->conf.iothread)) {
return;
}
s->dataplane_starting = true;
rc = k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, true);
if (rc != 0) {
fprintf(stderr, "virtio-scsi: Failed to set guest notifiers (%d), "
"ensure -enable-kvm is set\n", rc);
goto fail_guest_notifiers;
}
aio_context_acquire(s->ctx);
rc = virtio_scsi_vring_init(s, vs->ctrl_vq, 0);
if (rc) {
goto fail_vrings;
}
rc = virtio_scsi_vring_init(s, vs->event_vq, 1);
if (rc) {
goto fail_vrings;
}
for (i = 0; i < vs->conf.num_queues; i++) {
rc = virtio_scsi_vring_init(s, vs->cmd_vqs[i], i + 2);
if (rc) {
goto fail_vrings;
}
}
s->dataplane_starting = false;
s->dataplane_started = true;
aio_context_release(s->ctx);
return;
fail_vrings:
virtio_scsi_clear_aio(s);
aio_context_release(s->ctx);
for (i = 0; i < vs->conf.num_queues + 2; i++) {
k->set_host_notifier(qbus->parent, i, false);
}
k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false);
fail_guest_notifiers:
s->dataplane_fenced = true;
s->dataplane_starting = false;
s->dataplane_started = true;
}
| 1threat |
static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)
{
BlockDriverState *source = s->common.bs;
int nb_sectors, sectors_per_chunk, nb_chunks;
int64_t end, sector_num, next_chunk, next_sector, hbitmap_next_sector;
uint64_t delay_ns = 0;
MirrorOp *op;
s->sector_num = hbitmap_iter_next(&s->hbi);
if (s->sector_num < 0) {
bdrv_dirty_iter_init(source, s->dirty_bitmap, &s->hbi);
s->sector_num = hbitmap_iter_next(&s->hbi);
trace_mirror_restart_iter(s,
bdrv_get_dirty_count(source, s->dirty_bitmap));
assert(s->sector_num >= 0);
}
hbitmap_next_sector = s->sector_num;
sector_num = s->sector_num;
sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS;
end = s->bdev_length / BDRV_SECTOR_SIZE;
nb_chunks = 0;
nb_sectors = 0;
next_sector = sector_num;
next_chunk = sector_num / sectors_per_chunk;
while (test_bit(next_chunk, s->in_flight_bitmap)) {
trace_mirror_yield_in_flight(s, sector_num, s->in_flight);
qemu_coroutine_yield();
}
do {
int added_sectors, added_chunks;
if (!bdrv_get_dirty(source, s->dirty_bitmap, next_sector) ||
test_bit(next_chunk, s->in_flight_bitmap)) {
assert(nb_sectors > 0);
break;
}
added_sectors = sectors_per_chunk;
if (s->cow_bitmap && !test_bit(next_chunk, s->cow_bitmap)) {
bdrv_round_to_clusters(s->target,
next_sector, added_sectors,
&next_sector, &added_sectors);
if (next_sector < sector_num) {
assert(nb_sectors == 0);
sector_num = next_sector;
next_chunk = next_sector / sectors_per_chunk;
}
}
added_sectors = MIN(added_sectors, end - (sector_num + nb_sectors));
added_chunks = (added_sectors + sectors_per_chunk - 1) / sectors_per_chunk;
while (nb_chunks == 0 && s->buf_free_count < added_chunks) {
trace_mirror_yield_buf_busy(s, nb_chunks, s->in_flight);
qemu_coroutine_yield();
}
if (s->buf_free_count < nb_chunks + added_chunks) {
trace_mirror_break_buf_busy(s, nb_chunks, s->in_flight);
break;
}
bitmap_set(s->in_flight_bitmap, next_chunk, added_chunks);
nb_sectors += added_sectors;
nb_chunks += added_chunks;
next_sector += added_sectors;
next_chunk += added_chunks;
if (!s->synced && s->common.speed) {
delay_ns = ratelimit_calculate_delay(&s->limit, added_sectors);
}
} while (delay_ns == 0 && next_sector < end);
op = g_slice_new(MirrorOp);
op->s = s;
op->sector_num = sector_num;
op->nb_sectors = nb_sectors;
qemu_iovec_init(&op->qiov, nb_chunks);
next_sector = sector_num;
while (nb_chunks-- > 0) {
MirrorBuffer *buf = QSIMPLEQ_FIRST(&s->buf_free);
size_t remaining = (nb_sectors * BDRV_SECTOR_SIZE) - op->qiov.size;
QSIMPLEQ_REMOVE_HEAD(&s->buf_free, next);
s->buf_free_count--;
qemu_iovec_add(&op->qiov, buf, MIN(s->granularity, remaining));
if (next_sector > hbitmap_next_sector
&& bdrv_get_dirty(source, s->dirty_bitmap, next_sector)) {
hbitmap_next_sector = hbitmap_iter_next(&s->hbi);
}
next_sector += sectors_per_chunk;
}
bdrv_reset_dirty(source, sector_num, nb_sectors);
s->in_flight++;
s->sectors_in_flight += nb_sectors;
trace_mirror_one_iteration(s, sector_num, nb_sectors);
bdrv_aio_readv(source, sector_num, &op->qiov, nb_sectors,
mirror_read_complete, op);
return delay_ns;
}
| 1threat |
Problemns with return the json : **Hi, everyone, i have a funtion in json and this function i call controller passing the parameter the type string, and in this function I enter into the database and retrieve the desired information , so that´s okay. however my result dont show in this view. returning a error and not a information wanted. Can someone help me**
**MY CODDE**
$('#btnPesquisarPaciente').click(function () {
var nomePesquisado = $('#txtNomePaciente').val();
if (nomePesquisado != '') {
$.ajax({
type: 'GET',
url: "pacientes/recuperaPacientePorNome",
data: { nomePaciente: nomePesquisado },
success: function (data) {
// console.log('nome encontrado' + data.NOME);
$('#lblPaciente').text = 'fa';
//var pacienteEncontrado = $('lblPaciente').html();
//pacienteEncontrado.append($('<p/>').html('<b>' + paciente.NOME + '</b>'));
},
error: function () {
alert('NÃO FOI POSSÍVEL ENCONTRAR ESTE PACIENTE');
}
})
} else {
alert('INFORME O NOME DO PACIENTE DESEJADO');
}
})
MY CONTROLLER
public JsonResult recuperaPacientePorNome(string nomePaciente)
{
paciente p = null;
if (!string.IsNullOrEmpty(nomePaciente))
{
using (db = new crm_webEntities())
{
p = (from x in db.paciente where x.NOME.ToUpper().StartsWith(nomePaciente.ToUpper()) select x).FirstOrDefault();
}
}
return Json(p, JsonRequestBehavior.AllowGet);
} | 0debug |
static int rtmp_packet_read_one_chunk(URLContext *h, RTMPPacket *p,
int chunk_size, RTMPPacket **prev_pkt_ptr,
int *nb_prev_pkt, uint8_t hdr)
{
uint8_t buf[16];
int channel_id, timestamp, size;
uint32_t ts_field;
uint32_t extra = 0;
enum RTMPPacketType type;
int written = 0;
int ret, toread;
RTMPPacket *prev_pkt;
written++;
channel_id = hdr & 0x3F;
if (channel_id < 2) {
buf[1] = 0;
if (ffurl_read_complete(h, buf, channel_id + 1) != channel_id + 1)
return AVERROR(EIO);
written += channel_id + 1;
channel_id = AV_RL16(buf) + 64;
}
if ((ret = ff_rtmp_check_alloc_array(prev_pkt_ptr, nb_prev_pkt,
channel_id)) < 0)
return ret;
prev_pkt = *prev_pkt_ptr;
size = prev_pkt[channel_id].size;
type = prev_pkt[channel_id].type;
extra = prev_pkt[channel_id].extra;
hdr >>= 6;
if (hdr == RTMP_PS_ONEBYTE) {
ts_field = prev_pkt[channel_id].ts_field;
} else {
if (ffurl_read_complete(h, buf, 3) != 3)
return AVERROR(EIO);
written += 3;
ts_field = AV_RB24(buf);
if (hdr != RTMP_PS_FOURBYTES) {
if (ffurl_read_complete(h, buf, 3) != 3)
return AVERROR(EIO);
written += 3;
size = AV_RB24(buf);
if (ffurl_read_complete(h, buf, 1) != 1)
return AVERROR(EIO);
written++;
type = buf[0];
if (hdr == RTMP_PS_TWELVEBYTES) {
if (ffurl_read_complete(h, buf, 4) != 4)
return AVERROR(EIO);
written += 4;
extra = AV_RL32(buf);
}
}
}
if (ts_field == 0xFFFFFF) {
if (ffurl_read_complete(h, buf, 4) != 4)
return AVERROR(EIO);
timestamp = AV_RB32(buf);
} else {
timestamp = ts_field;
}
if (hdr != RTMP_PS_TWELVEBYTES)
timestamp += prev_pkt[channel_id].timestamp;
if (!prev_pkt[channel_id].read) {
if ((ret = ff_rtmp_packet_create(p, channel_id, type, timestamp,
size)) < 0)
return ret;
p->read = written;
p->offset = 0;
prev_pkt[channel_id].ts_field = ts_field;
prev_pkt[channel_id].timestamp = timestamp;
} else {
RTMPPacket *prev = &prev_pkt[channel_id];
p->data = prev->data;
p->size = prev->size;
p->channel_id = prev->channel_id;
p->type = prev->type;
p->ts_field = prev->ts_field;
p->extra = prev->extra;
p->offset = prev->offset;
p->read = prev->read + written;
p->timestamp = prev->timestamp;
prev->data = NULL;
}
p->extra = extra;
prev_pkt[channel_id].channel_id = channel_id;
prev_pkt[channel_id].type = type;
prev_pkt[channel_id].size = size;
prev_pkt[channel_id].extra = extra;
size = size - p->offset;
toread = FFMIN(size, chunk_size);
if (ffurl_read_complete(h, p->data + p->offset, toread) != toread) {
ff_rtmp_packet_destroy(p);
return AVERROR(EIO);
}
size -= toread;
p->read += toread;
p->offset += toread;
if (size > 0) {
RTMPPacket *prev = &prev_pkt[channel_id];
prev->data = p->data;
prev->read = p->read;
prev->offset = p->offset;
return AVERROR(EAGAIN);
}
prev_pkt[channel_id].read = 0;
return p->read;
} | 1threat |
How Convert packages to units : <p>I have a question, I'm programming in Java if I have a decimal "3.02" (this is equivalent to 3 packages (1 package = 10 units) and 2 units) and want to convert to "32" (this is equivalent to 32 units ). Does anyone know how to do it? There is a feature that allows java?</p>
| 0debug |
How to get only all HTML tags to list from string using javascript or jquery? : <p>How to get list with only all HTML tags from string? We can use javascript, jquery or any C# library or api.
We have one big string:</p>
<pre><code><html>
<head>
</head>
<body>
qwe
<button type="button">Click Me!</button>
<a>xyz</a>
<button type="button"/>
</body>
</html>
</code></pre>
<p>I want to get list = {<code><html>,<head>,<body>,<button type="button">,<button>,<a>,<button></code>}
I need to count how many times occurs each HTML tag in string and show 3 the most common.</p>
| 0debug |
Copy a directory when logged in via ssh to my desktop via terminal : <p>How can I copy a directory to my local desktop from a remote machine ? I accessing the remote machine via ssh in the terminal.</p>
| 0debug |
static void add_to_pool(BufferPoolEntry *buf)
{
AVBufferPool *pool;
BufferPoolEntry *cur, *end = buf;
if (!buf)
return;
pool = buf->pool;
while (end->next)
end = end->next;
while ((cur = avpriv_atomic_ptr_cas((void * volatile *)&pool->pool, NULL, buf))) {
cur = get_pool(pool);
end->next = cur;
while (end->next)
end = end->next;
}
}
| 1threat |
Java subclass methods are not overriding despite explicit use of @Override : <p>I am trying to make an abstract algorithm class for informed search with different heuristics. My idea was to have different subclasses overwrite the default heuristic() method, but the dynamic binding seems not to be working when I call the subclasses.</p>
<p>In <strong>astar.java</strong>:</p>
<pre><code>public interface Astar {
abstract String heuristic();
}
</code></pre>
<p>In <strong>search.java</strong></p>
<pre><code>public class Search implements Astar {
public String heuristic() { return "default heuristic"; }
}
</code></pre>
<p>In <strong>EuclidianSearch.java</strong>:</p>
<pre><code>public class EuclidianSearch extends Search {
@Override
public String heuristic() { return "Euclidian"; }
}
</code></pre>
<p>In <strong>ChebyshevSearch.java</strong>:</p>
<pre><code>public class ChebyshevSearch extends Search {
@Override
public String heuristic() { return "Chebyshev"; }
}
</code></pre>
<p>In <strong>main.java</strong>:</p>
<pre><code>EuclidianSearch e_search = null; ChebyshevDistance ch_search = null;
Search[] SearchObjects = {e_search, ch_search};
for(Search so : SearchObjects) {
System.out.println(so.heuristic());
}
</code></pre>
<p>When run, it displays:</p>
<pre><code>default heuristic
default heuristic
</code></pre>
<p>I define the array in terms of <code>Search</code> so I can be flexible: eventually, I want to have five or more different heuristics. Why doesn't the <code>heuristic()</code> method of the subclass override that of the superclass?</p>
| 0debug |
How to improve camera quality in ARKit : <p>I am building an ARKit app where we want to be able to take a photo of the scene. I am finding the image quality of the ARCamera view is not good enough to take photos with on an iPad Pro.</p>
<p><strong>Standard camera image:</strong>
<a href="https://i.stack.imgur.com/hNzEB.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/hNzEB.jpg" alt="Standard camera image"></a></p>
<p><strong>ARCamera image:</strong>
<a href="https://i.stack.imgur.com/THFMw.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/THFMw.jpg" alt="ARCamera image"></a></p>
<p>I have seen an Apple forum post that mentions this could be iPad Pro 10.5 specific and is related to fixed lens position (<a href="https://forums.developer.apple.com/message/262950#262950" rel="noreferrer">https://forums.developer.apple.com/message/262950#262950</a>).</p>
<p>Is there are public way to change the setting?</p>
<p>Alternatively, I have tried to use AVCaptureSession to take a normal photo and apply it to <code>sceneView.scene.background.contents</code> to switch out a blurred image for higher res image at the point the photo is taken but can't get AVCapturePhotoOutput to work with ARKit</p>
| 0debug |
Commenting on Python : I am a student taking my first Python class and am using Anaconda & Jupyter for Python 3. I have read up on commenting and understand they begin with a hash mark ( # ) and whitespace character and continue to the end of the line. It is my understanding that they should not affect the execution of the code.
When I run "ls" in order to display my working directory it runs perfectly fine. However, when I add a comment just above it, it does not run. Can someone please help me understand why this might be? Pictures attached.
This is the error I receive with a comment: **---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-9-96a2904231e9> in <module>()
1 # show working directory
----> 2 ls
NameError: name 'ls' is not defined**
![run 1] https://i.stack.imgur.com/tS4aW.png
! [run 2] https://i.stack.imgur.com/fYegx.png | 0debug |
static int open_self_maps(void *cpu_env, int fd)
{
#if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_UNICORE32)
CPUState *cpu = ENV_GET_CPU((CPUArchState *)cpu_env);
TaskState *ts = cpu->opaque;
#endif
FILE *fp;
char *line = NULL;
size_t len = 0;
ssize_t read;
fp = fopen("/proc/self/maps", "r");
if (fp == NULL) {
return -EACCES;
}
while ((read = getline(&line, &len, fp)) != -1) {
int fields, dev_maj, dev_min, inode;
uint64_t min, max, offset;
char flag_r, flag_w, flag_x, flag_p;
char path[512] = "";
fields = sscanf(line, "%"PRIx64"-%"PRIx64" %c%c%c%c %"PRIx64" %x:%x %d"
" %512s", &min, &max, &flag_r, &flag_w, &flag_x,
&flag_p, &offset, &dev_maj, &dev_min, &inode, path);
if ((fields < 10) || (fields > 11)) {
continue;
}
if (!strncmp(path, "[stack]", 7)) {
continue;
}
if (h2g_valid(min) && h2g_valid(max)) {
dprintf(fd, TARGET_ABI_FMT_lx "-" TARGET_ABI_FMT_lx
" %c%c%c%c %08" PRIx64 " %02x:%02x %d %s%s\n",
h2g(min), h2g(max), flag_r, flag_w,
flag_x, flag_p, offset, dev_maj, dev_min, inode,
path[0] ? " " : "", path);
}
}
free(line);
fclose(fp);
#if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_UNICORE32)
dprintf(fd, "%08llx-%08llx rw-p %08llx 00:00 0 [stack]\n",
(unsigned long long)ts->info->stack_limit,
(unsigned long long)(ts->info->start_stack +
(TARGET_PAGE_SIZE - 1)) & TARGET_PAGE_MASK,
(unsigned long long)0);
#endif
return 0;
}
| 1threat |
void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
int linesize_align[AV_NUM_DATA_POINTERS])
{
int i;
int w_align= 1;
int h_align= 1;
switch(s->pix_fmt){
case PIX_FMT_YUV420P:
case PIX_FMT_YUYV422:
case PIX_FMT_UYVY422:
case PIX_FMT_YUV422P:
case PIX_FMT_YUV440P:
case PIX_FMT_YUV444P:
case PIX_FMT_GBRP:
case PIX_FMT_GRAY8:
case PIX_FMT_GRAY16BE:
case PIX_FMT_GRAY16LE:
case PIX_FMT_YUVJ420P:
case PIX_FMT_YUVJ422P:
case PIX_FMT_YUVJ440P:
case PIX_FMT_YUVJ444P:
case PIX_FMT_YUVA420P:
case PIX_FMT_YUV420P9LE:
case PIX_FMT_YUV420P9BE:
case PIX_FMT_YUV420P10LE:
case PIX_FMT_YUV420P10BE:
case PIX_FMT_YUV422P9LE:
case PIX_FMT_YUV422P9BE:
case PIX_FMT_YUV422P10LE:
case PIX_FMT_YUV422P10BE:
case PIX_FMT_YUV444P9LE:
case PIX_FMT_YUV444P9BE:
case PIX_FMT_YUV444P10LE:
case PIX_FMT_YUV444P10BE:
case PIX_FMT_GBRP9LE:
case PIX_FMT_GBRP9BE:
case PIX_FMT_GBRP10LE:
case PIX_FMT_GBRP10BE:
w_align = 16;
h_align = 16 * 2;
break;
case PIX_FMT_YUV411P:
case PIX_FMT_UYYVYY411:
w_align=32;
h_align=8;
break;
case PIX_FMT_YUV410P:
if(s->codec_id == CODEC_ID_SVQ1){
w_align=64;
h_align=64;
}
case PIX_FMT_RGB555:
if(s->codec_id == CODEC_ID_RPZA){
w_align=4;
h_align=4;
}
case PIX_FMT_PAL8:
case PIX_FMT_BGR8:
case PIX_FMT_RGB8:
if(s->codec_id == CODEC_ID_SMC){
w_align=4;
h_align=4;
}
break;
case PIX_FMT_BGR24:
if((s->codec_id == CODEC_ID_MSZH) || (s->codec_id == CODEC_ID_ZLIB)){
w_align=4;
h_align=4;
}
break;
default:
w_align= 1;
h_align= 1;
break;
}
*width = FFALIGN(*width , w_align);
*height= FFALIGN(*height, h_align);
if(s->codec_id == CODEC_ID_H264 || s->lowres)
*height+=2;
for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
linesize_align[i] = STRIDE_ALIGN;
#if HAVE_MMX
if(s->codec_id == CODEC_ID_SVQ1 || s->codec_id == CODEC_ID_VP5 ||
s->codec_id == CODEC_ID_VP6 || s->codec_id == CODEC_ID_VP6F ||
s->codec_id == CODEC_ID_VP6A) {
for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
linesize_align[i] = 16;
}
#endif
}
| 1threat |
Docker + Virtual Box = VT-x is not available (VERR_VMX_NO_VMX) : <p>I installed docker. During installation, it complained that you can't have two virtualization environments, and that it would make docker the primary one. I said: "OK."</p>
<p>Now, I need to go back to enabling virtualbox. I uninstalled Docker, hoping it would put things back the way they were, but: no joy.</p>
<p>How do I re-enable virtualization for VirtualBox now that docker is gone?</p>
<p>Note: Virtualization bit is set / enabled on the chip.</p>
<p>OS: Win10 Enterprise.</p>
| 0debug |
static double lfo_get_value(SimpleLFO *lfo)
{
double phs = FFMIN(100, lfo->phase / FFMIN(1.99, FFMAX(0.01, lfo->pwidth)) + lfo->offset);
double val;
if (phs > 1)
phs = fmod(phs, 1.);
switch (lfo->mode) {
case SINE:
val = sin(phs * 2 * M_PI);
break;
case TRIANGLE:
if (phs > 0.75)
val = (phs - 0.75) * 4 - 1;
else if (phs > 0.25)
val = -4 * phs + 2;
else
val = phs * 4;
break;
case SQUARE:
val = phs < 0.5 ? -1 : +1;
break;
case SAWUP:
val = phs * 2 - 1;
break;
case SAWDOWN:
val = 1 - phs * 2;
break;
}
return val * lfo->amount;
} | 1threat |
What is the best option here to manage DAO layer in ASP.net based project? : <p>Moved from Java based Sites to ASP.net. What is the best option here to manage DAO layer here. </p>
| 0debug |
query = 'SELECT * FROM customers WHERE email = ' + email_input | 1threat |
Pack multiple assemblies with dotnet pack : <p>Just as the question says really, how can I pack multiple projects / assemblies using dotnet pack?</p>
<p>Using VS2017 with new csproj files.</p>
| 0debug |
static int encode_init(AVCodecContext * avctx){
WMACodecContext *s = avctx->priv_data;
int i, flags1, flags2;
uint8_t *extradata;
s->avctx = avctx;
if(avctx->channels > MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "too many channels: got %i, need %i or fewer",
avctx->channels, MAX_CHANNELS);
return AVERROR(EINVAL);
}
if(avctx->bit_rate < 24*1000) {
av_log(avctx, AV_LOG_ERROR, "bitrate too low: got %i, need 24000 or higher\n",
avctx->bit_rate);
return AVERROR(EINVAL);
}
flags1 = 0;
flags2 = 1;
if (avctx->codec->id == CODEC_ID_WMAV1) {
extradata= av_malloc(4);
avctx->extradata_size= 4;
AV_WL16(extradata, flags1);
AV_WL16(extradata+2, flags2);
} else if (avctx->codec->id == CODEC_ID_WMAV2) {
extradata= av_mallocz(10);
avctx->extradata_size= 10;
AV_WL32(extradata, flags1);
AV_WL16(extradata+4, flags2);
}else
assert(0);
avctx->extradata= extradata;
s->use_exp_vlc = flags2 & 0x0001;
s->use_bit_reservoir = flags2 & 0x0002;
s->use_variable_block_len = flags2 & 0x0004;
ff_wma_init(avctx, flags2);
for(i = 0; i < s->nb_block_sizes; i++)
ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 0, 1.0);
avctx->block_align=
s->block_align= avctx->bit_rate*(int64_t)s->frame_len / (avctx->sample_rate*8);
avctx->frame_size= s->frame_len;
return 0;
}
| 1threat |
float32 HELPER(ucf64_negs)(float32 a)
{
return float32_chs(a);
}
| 1threat |
Markdown: How to reference an item in a numbered list, by number (like LaTeX's \ref / \label)? : <p>Is there any way in markdown to do the equivalent of the cross-referencing in this LaTeX snippet? (Taken from <a href="http://texblog.org/2012/03/21/cross-referencing-list-items/" rel="noreferrer">here</a>.)</p>
<pre><code>\begin{enumerate}
\item \label{itm:first} This is a numbered item
\item Another numbered item \label{itm:second}
\item \label{itm:third} Same as \ref{itm:first}
\end{enumerate}
Cross-referencing items \ref{itm:second} and \ref{itm:third}.
</code></pre>
<p>This LaTeX produces</p>
<pre><code>1. This is a numbered item
2. This is another numbered item
3. Same as 1
Cross-referencing items 2 and 3.
</code></pre>
<p>That is, I would like to be able to refer to items in a markdown list without explicitly numbering them, so that I could change the above list to the following without having to manually update the cross references:</p>
<pre><code>1. This is the very first item
2. This is a numbered item
3. This is another numbered item
4. Same as 2
Cross-referencing items 3 and 4.
</code></pre>
| 0debug |
Disable zoom in WKWebView? : <p>Does anyone know a nice simple way to disable double-click and pinch zooming in a WKWebView? Nothing I've tried works:</p>
<pre><code>Webview.scrollView.allowsMagnification = false; // Error: value of type WKWebView has no member allowsMagnification
Webview.scrollView.isMultipleTouchEnabled = false; // doesn't do anything
</code></pre>
<p>In the html:</p>
<pre><code><meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> // pile of crap, does nothing
</code></pre>
| 0debug |
IntelliJ: “Output exceeds cutoff limit” in scala worksheet : <p>How can I grow the number of output lines in IntelliJ, such that I do not receive any more this message in Scala worksheet:</p>
<pre><code>Output exceeds cutoff limit.
</code></pre>
<p><a href="https://i.stack.imgur.com/BvOzb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BvOzb.png" alt="screenshot of worksheet"></a></p>
| 0debug |
kotlin-android-extensions in ViewHolder : <pre><code>class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
fun bindata(text: SingleText){
itemView.title.text = text.title
itemView.desc.text = text.desc
}
}
</code></pre>
<p>like this code, Kotlin has any cache in android-extensions?</p>
<p>when i decompile kotlin bytecode </p>
<pre><code>public final void bindata(@NotNull SingleText text) {
Intrinsics.checkParameterIsNotNull(text, "text");
((AppCompatTextView)this.itemView.findViewById(id.title)).setText((CharSequence)text.getTitle());
((AppCompatTextView)this.itemView.findViewById(id.desc)).setText((CharSequence)text.getDesc());
}
</code></pre>
<p>it means when i called binData in Adapter.onBindViewHolder(), it will called findViewById each time</p>
<p>This significantly increases the loss of performance,and It does not achieve the purpose of layout reuse</p>
<p>Kotlin has any cache logic in android-extensions with ViewHolder?</p>
| 0debug |
Infinite loop while traversing through linked list : <p>Deleting and viewing entire queue causes the problem- I'm assuming it is an infinite loop case for traversing. It works perfectly fine for adding the element but execution stops right after 2 or 3 are selected by the user.</p>
<p>I'm just adding some lines of random text before the code because stack isn't allowing such a big code with a small explanation.</p>
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</p>
<pre><code>#include<iostream>
using namespace std;
class linkedlist
{
struct node
{
int number;
node *next;
}*HEAD;
public:
void addelement(int num);
void exitelement();
void displayqueue();
};
void linkedlist::addelement(int num)
{
node *t;
t= new node;
t -> number=num;
t -> next=HEAD;
HEAD=t;
cout<<num<<"has successfully been added to the queue /n";
}
void linkedlist::exitelement()
{
node *t;
t=HEAD;
while(t -> next !=NULL)
{
t=t -> next;
}
cout<<t->number;
delete t;
}
void linkedlist::displayqueue()
{
node *t;
t=HEAD;
while(t->next !=NULL)
{
cout<<t -> number<<"\t";
t=t->next;
}
cout<<" \n that's the end of the list \n";
}
int main()
{
int lol;
linkedlist m;
int rpt=1;
while(rpt==1)
{
int c;
cout<<"\n please select 1 to add an element, 2 to remove an element from the queue and 3 to display the entire queue \n";
cin>>c;
cout<<"/n";
if(c==1)
{
cout<<"enter the number: ";
cin>>lol;
m.addelement(lol);
}
else if(c==2)
{
m.exitelement();
}
else if(c==3)
{
m.displayqueue();
}
else
{
cout<<"you have entered an invalid input. Sorry \n";
}
cout<<"\n Do you wish to start the queue again??? \n";
cin>>rpt;
}
}
</code></pre>
| 0debug |
Vector comparison in C++ without set_intersection or set_difference : <p>just a novice learning C++. It's a great language with a steep learning curve and I am climbing that mountain. </p>
<p>Currently, I want to compare two vector, the first vector already has predefined elements, while the other vector's elements are inputted on the go (i.e. "cin in a while loop"). The output of the vector comparison should be a string, "bleep", whenever similar strings are matched between the two sorted vectors. Else, the vector with the inputted words will print out it's elements.</p>
<p>Side Note: The code is a bit religious (I decided to use a standard text that I know - the Bible). So I am not trying to condemn anyone I just needed a standard text we all have access to. Also, I have searched online and some suggestions for comparing vectors required that I used set_difference, set_intersection etc. I have checked them out, but I realised that it will take a novice like me more time to understand the interator syntax. So that is why I am here.</p>
<p>So please I need your help because the code keeps giving this error from the implementation file:
<a href="https://i.stack.imgur.com/O9juM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O9juM.jpg" alt="enter image description here"></a></p>
<p>I know. I wish i could solve the error (Error's are actually the topic for the next chapter in the book I am reading)</p>
<p>So enough small talk here is the code I have been working on. Any pointers will be appreciated. Thanks in advance:)</p>
<pre><code>#include "stdafx.h"
#include "Std_lib_facilities.h"
int main()
{
// Introduction
cout << "This program will compare the your input to already predefined works which are found in Galatians 5:19-24.";
// Vectors of disliked by God in Galatians 5:19-24. These are the works of the flesh. And I copied them from the Bible.
// Side comment:I know we are all sinners- I am not judging anyone. I myself am working on some with the help of the Holy Spirit and my spirit is getting stronger everyday.
vector <string> disliked; disliked[0]= "hatred"; disliked[1] = "envy"; disliked[2] = "adultery"; disliked[3] = "fornication"; disliked[4] = "anger"; disliked[5] = "malice";
disliked[6] = "gluttony"; disliked[7] = "lying"; disliked[8] = "stealing"; disliked[9] = "greed"; disliked[10] = "uncleanliness"; disliked[11] = "lewdness"; disliked[12] = "idolatry";
disliked[13] = "sorcery"; disliked[14] = "contentions"; disliked[15] = "jealousy"; disliked[16] = "selfish ambition"; disliked[17] = "dissensions"; disliked[18] = "heresies";
disliked[19] = "murder"; disliked[20] = "drunkeness"; disliked[21] = "revelries";
// Sorted the vectors so that they could be compared with what are liked.
sort(disliked.begin(), disliked.end());
cout << "Please enter the fruits of the Holy Spirit in Galatians 5:22-23, while purposely adding some of the works of the flesh which are found in Galatians 5:19-24: \n" <<
"Also inset a Ctrl+Z and click enter when you have finished inserting the works"<< endl;
string first_input; // String for the input of the likes. Please, you are to purposely insert some words that are not listed in Galatians 5:22-23. Rather include some from Galatians 5:19-24
vector <string> liked; // Vector of liked qualities
while (cin >> first_input) // cin iostream is used to insert the whitespace separated strings into first_input
liked.push_back(first_input); // push_back inserts the strings from first_input into the vector liked
sort(liked.begin(), liked.end()); // the vector liked is sorted.
for (int i = 0; i < liked.size(); ++i) // Using the loop for the comparison of the sorted vectors in the next if statment
if (disliked == liked) // if strings are similar give a bleep!
cout << "Bleep!" << endl;
else
cout << liked[i]; // if strings are not similar cout the list of liked qualities.
}
</code></pre>
| 0debug |
How does the "Or" operator work? (In C++) : <pre><code>#include "stdafx.h"
#include <iostream>
int x = 0;
int main(){
std::cin >> x;
if (x == 5 || 6) {
std::cout << "5 or 6\n";
}
else {
std::cout << "Not 5 or 6\n";
}
return 0;
}
</code></pre>
<p>This simple code only returns "5 or 6" to the console, no matter what number you put in it. I really don't understand why. If || is the or operator, then it should work. If x is 5 or 6 it should display "5 or 6". If it's not, display "Not 5 or 6". Could someone please explain?</p>
| 0debug |
for loop with table wchich return 12 values(month) php : I write this code when i try to return 12 numbers from 1 to 12:
public function getMonths()
{
for($monthNum = 1; $monthNum <= 12; $monthNum++)
{
$month[$monthNum]=$monthNum;
}
return [$month];
}
How can i return this 12 numbers? I have now zero in my first return value. Anyone know how to resolve this? I need only 12 numbers without 0?
| 0debug |
def min_Jumps(a, b, d):
temp = a
a = min(a, b)
b = max(temp, b)
if (d >= b):
return (d + b - 1) / b
if (d == 0):
return 0
if (d == a):
return 1
else:
return 2 | 0debug |
Is there a way to check if an element is enabled only after let's say 30 seconds : I have a link in my application which gets enabled after 30 seconds. I have to verify this scenario using selenium , that the link only gets enabled after 30 seconds not before that.
I have used fluent wait but it didn't work. | 0debug |
how to count alphabetic characters in a string : ok so im kinda new to php and still learning and i can't figure out how to do this:
$string = "this is a test sentence";
so what i wanted to do was search for alphabetic characters in that sting and show how many of each character is in there something like this --->
'T' is used 3 times in the sentence.
'i' is used 2 times in the sentence.
i tried ctype_alpha() and some other things but i can't get quite the answer im looking for. and sorry if my question is kinda basic -____- | 0debug |
static int qxl_init_secondary(PCIDevice *dev)
{
static int device_id = 1;
PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, dev);
ram_addr_t ram_size = msb_mask(qxl->vga.vram_size * 2 - 1);
qxl->id = device_id++;
if (ram_size < 16 * 1024 * 1024) {
ram_size = 16 * 1024 * 1024;
}
qxl->vga.vram_size = ram_size;
qxl->vga.vram_offset = qemu_ram_alloc(&qxl->pci.qdev, "qxl.vgavram",
qxl->vga.vram_size);
qxl->vga.vram_ptr = qemu_get_ram_ptr(qxl->vga.vram_offset);
pci_config_set_class(dev->config, PCI_CLASS_DISPLAY_OTHER);
return qxl_init_common(qxl);
}
| 1threat |
14/9 PL/SQL: Statement ignored 14/13 PLS-00222: no function with name 'P' exists in this scope : Package Specification :-
`CREATE OR REPLACE PACKAGE dt_pkg IS
PROCEDURE Simpleint(p NUMBER,n number,r number := 10);
PROCEDURE Compoundint(
p number,n number, r number);
END dt_pkg;
/`
Package BODY:-
CREATE OR REPLACE PACKAGE BODY dt_pkg IS
PROCEDURE Simpleint (p NUMBER,n number,r NUMBER) IS
si number :=0;
BEGIN
si:=p*n*r;
DBMS_OUTPUT.PUT_LINE('sIMPLE INT: '||si);
END Simpleint;
PROCEDURE Compoundint (p number,n number,r number) IS
ci number:=0;
BEGIN
ci:=p(1+r/100)**n;
DBMS_OUTPUT.PUT_LINE('COMPOUND INTEREST: '||ci);
END Compoundint;
END dt_pkg;
/
ERROR I GET
LINE/COL ERROR
-------- -----------------------------------------------------------------
14/9 PL/SQL: Statement ignored
14/13 PLS-00222: no function with name 'P' exists in this scope
please help
Thank you. | 0debug |
static int kvm_s390_supports_mem_limit(KVMState *s)
{
struct kvm_device_attr attr = {
.group = KVM_S390_VM_MEM_CTRL,
.attr = KVM_S390_VM_MEM_LIMIT_SIZE,
};
return (kvm_vm_ioctl(s, KVM_HAS_DEVICE_ATTR, &attr) == 0);
}
| 1threat |
Query on non-key attribute : <p>It appears that dynamodb's <code>query</code> method must include the partition key as part of the filter. How can a query be performed if you do not know the partition key?</p>
<p>For example, you have a User table with the attribute <code>userid</code> set as the partition key. Now we want to look up a user by their phone number. Is it possible to perform the query without the partition key? Using the <code>scan</code> method, this goal can be achieved, but at the expense of pulling every item from the table before the filter is applied, as far as I know.</p>
| 0debug |
static int xsub_encode(AVCodecContext *avctx, unsigned char *buf,
int bufsize, void *data)
{
AVSubtitle *h = data;
uint64_t startTime = h->pts / 1000;
uint64_t endTime = startTime + h->end_display_time - h->start_display_time;
int start_tc[4], end_tc[4];
uint8_t *hdr = buf + 27;
uint8_t *rlelenptr;
uint16_t width, height;
int i;
PutBitContext pb;
if (bufsize < 27 + 7*2 + 4*3) {
av_log(avctx, AV_LOG_ERROR, "Buffer too small for XSUB header.\n");
return -1;
}
if (h->num_rects > 1)
av_log(avctx, AV_LOG_WARNING, "Only single rects supported (%d in subtitle.)\n", h->num_rects);
if (!h->rects[0]->pict.data[0] || !h->rects[0]->pict.data[1]) {
av_log(avctx, AV_LOG_WARNING, "No subtitle bitmap available.\n");
return -1;
}
if (h->rects[0]->nb_colors > 4)
av_log(avctx, AV_LOG_WARNING, "No more than 4 subtitle colors supported (%d found.)\n", h->rects[0]->nb_colors);
if (((uint32_t *)h->rects[0]->pict.data[1])[0] & 0xff)
av_log(avctx, AV_LOG_WARNING, "Color index 0 is not transparent. Transparency will be messed up.\n");
if (make_tc(startTime, start_tc) || make_tc(endTime, end_tc)) {
av_log(avctx, AV_LOG_WARNING, "Time code >= 100 hours.\n");
return -1;
}
snprintf(buf, 28,
"[%02d:%02d:%02d.%03d-%02d:%02d:%02d.%03d]",
start_tc[3], start_tc[2], start_tc[1], start_tc[0],
end_tc[3], end_tc[2], end_tc[1], end_tc[0]);
width = FFALIGN(h->rects[0]->w, 2) + PADDING * 2;
height = FFALIGN(h->rects[0]->h, 2);
bytestream_put_le16(&hdr, width);
bytestream_put_le16(&hdr, height);
bytestream_put_le16(&hdr, h->rects[0]->x);
bytestream_put_le16(&hdr, h->rects[0]->y);
bytestream_put_le16(&hdr, h->rects[0]->x + width);
bytestream_put_le16(&hdr, h->rects[0]->y + height);
rlelenptr = hdr;
hdr+=2;
for (i=0; i<4; i++)
bytestream_put_be24(&hdr, ((uint32_t *)h->rects[0]->pict.data[1])[i]);
init_put_bits(&pb, hdr, bufsize - (hdr - buf) - 2);
if (xsub_encode_rle(&pb, h->rects[0]->pict.data[0],
h->rects[0]->pict.linesize[0]*2,
h->rects[0]->w, (h->rects[0]->h + 1) >> 1))
return -1;
bytestream_put_le16(&rlelenptr, put_bits_count(&pb) >> 3);
if (xsub_encode_rle(&pb, h->rects[0]->pict.data[0] + h->rects[0]->pict.linesize[0],
h->rects[0]->pict.linesize[0]*2,
h->rects[0]->w, h->rects[0]->h >> 1))
return -1;
if (h->rects[0]->h & 1) {
put_xsub_rle(&pb, h->rects[0]->w, PADDING_COLOR);
align_put_bits(&pb);
}
flush_put_bits(&pb);
return hdr - buf + put_bits_count(&pb)/8;
}
| 1threat |
Msg 195, Level 15, State 10, Line 2 'CONCAT' is not a recognized built-in function name : SELECT
CONCAT(CCYYMM,RIGHT(C.AMT001,2)) ACCDAT
,CSTCOD
,PRPCOD
,C.RevenueAmount
,D.RevenueAllowance
,OUTLET
,AMTYTD
,ALWYTD
,MODCOD
,RECTYP
,RECCOD
,GRPCOD
,DEPCOD
,[CSTCTR]
,[GLCODE]
FROM PMS.FMNASTBL
CROSS APPLY
(
VALUES
('AMT001',AMT001 )
) c (AMT001,RevenueAmount)
CROSS APPLY
(
VALUES
('ALW001',ALW001 )
) D (ALW001,RevenueAllowance) | 0debug |
static int smvjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt)
{
const AVPixFmtDescriptor *desc;
SMVJpegDecodeContext *s = avctx->priv_data;
AVFrame* mjpeg_data = s->picture[0];
int i, cur_frame = 0, ret = 0;
cur_frame = avpkt->pts % s->frames_per_jpeg;
if (!cur_frame) {
av_frame_unref(mjpeg_data);
ret = avcodec_decode_video2(s->avctx, mjpeg_data, &s->mjpeg_data_size, avpkt);
if (ret < 0) {
s->mjpeg_data_size = 0;
return ret;
}
} else if (!s->mjpeg_data_size)
return AVERROR(EINVAL);
desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
av_assert0(desc);
if (mjpeg_data->height % (s->frames_per_jpeg << desc->log2_chroma_h)) {
av_log(avctx, AV_LOG_ERROR, "Invalid height\n");
return AVERROR_INVALIDDATA;
}
*data_size = s->mjpeg_data_size;
avctx->pix_fmt = s->avctx->pix_fmt;
ret = ff_set_dimensions(avctx, mjpeg_data->width, mjpeg_data->height / s->frames_per_jpeg);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Failed to set dimensions\n");
return ret;
}
if (*data_size) {
s->picture[1]->extended_data = NULL;
s->picture[1]->width = avctx->width;
s->picture[1]->height = avctx->height;
s->picture[1]->format = avctx->pix_fmt;
smv_img_pnt(s->picture[1]->data, mjpeg_data->data, mjpeg_data->linesize,
avctx->pix_fmt, avctx->width, avctx->height, cur_frame);
for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
s->picture[1]->linesize[i] = mjpeg_data->linesize[i];
ret = av_frame_ref(data, s->picture[1]);
}
return ret;
} | 1threat |
How to add code in variable in bat file? : I have written bat file to get path from system variable using %JAVA_HOME% and assigned it into one variable, now how to use as set path, because in set path its asking me this path between "" code, which i am not able to add in.
Please help me to add it, how ? | 0debug |
This isnt working. it isnt actually accepting that this is actually entered... when i enter manually it works.selenium python : im trying to get this code to work, but it isnt. i enter manually and it works but not when i automate it
import selenium
import time
import os
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
num = 1
while num != 1000:
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get('https://mobile.brawlhalla.com/?kid=1415HM')
id_box = driver.find_element_by_id('email')
id_box.send_keys(str(num) +'@1.com')
login_button = driver.find_element_by_id('btn-id-6zgew9flrfn')
login_button.click()
time.sleep(10)
os.system("taskkill /im chrome.exe /f")
num = num + 1
| 0debug |
How to reduce git repository size : <p>Earlier I pushed some big files to git branch which increased the repository size. Later I removed those redundant files from that branch using,</p>
<pre class="lang-sh prettyprint-override"><code>git rm big_file
git commit -m 'rm bg file'
git push origin branch-name
</code></pre>
<p>But the file size of git repository remained unchanged. </p>
<p>Then I tried using <a href="https://stackoverflow.com/a/26000395/11652623">this</a> method to clear commit history but it didn't worked, the repo size is still the same.</p>
| 0debug |
static void qtest_process_command(CharDriverState *chr, gchar **words)
{
const gchar *command;
g_assert(words);
command = words[0];
if (qtest_log_fp) {
qemu_timeval tv;
int i;
qtest_get_time(&tv);
fprintf(qtest_log_fp, "[R +" FMT_timeval "]",
(long) tv.tv_sec, (long) tv.tv_usec);
for (i = 0; words[i]; i++) {
fprintf(qtest_log_fp, " %s", words[i]);
}
fprintf(qtest_log_fp, "\n");
}
g_assert(command);
if (strcmp(words[0], "irq_intercept_out") == 0
|| strcmp(words[0], "irq_intercept_in") == 0) {
DeviceState *dev;
NamedGPIOList *ngl;
g_assert(words[1]);
dev = DEVICE(object_resolve_path(words[1], NULL));
if (!dev) {
qtest_send_prefix(chr);
qtest_send(chr, "FAIL Unknown device\n");
return;
}
if (irq_intercept_dev) {
qtest_send_prefix(chr);
if (irq_intercept_dev != dev) {
qtest_send(chr, "FAIL IRQ intercept already enabled\n");
} else {
qtest_send(chr, "OK\n");
}
return;
}
QLIST_FOREACH(ngl, &dev->gpios, node) {
if (ngl->name) {
continue;
}
if (words[0][14] == 'o') {
int i;
for (i = 0; i < ngl->num_out; ++i) {
qemu_irq *disconnected = g_new0(qemu_irq, 1);
qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler,
disconnected, i);
*disconnected = qdev_intercept_gpio_out(dev, icpt,
ngl->name, i);
}
} else {
qemu_irq_intercept_in(ngl->in, qtest_irq_handler,
ngl->num_in);
}
}
irq_intercept_dev = dev;
qtest_send_prefix(chr);
qtest_send(chr, "OK\n");
} else if (strcmp(words[0], "outb") == 0 ||
strcmp(words[0], "outw") == 0 ||
strcmp(words[0], "outl") == 0) {
uint16_t addr;
uint32_t value;
g_assert(words[1] && words[2]);
addr = strtoul(words[1], NULL, 0);
value = strtoul(words[2], NULL, 0);
if (words[0][3] == 'b') {
cpu_outb(addr, value);
} else if (words[0][3] == 'w') {
cpu_outw(addr, value);
} else if (words[0][3] == 'l') {
cpu_outl(addr, value);
}
qtest_send_prefix(chr);
qtest_send(chr, "OK\n");
} else if (strcmp(words[0], "inb") == 0 ||
strcmp(words[0], "inw") == 0 ||
strcmp(words[0], "inl") == 0) {
uint16_t addr;
uint32_t value = -1U;
g_assert(words[1]);
addr = strtoul(words[1], NULL, 0);
if (words[0][2] == 'b') {
value = cpu_inb(addr);
} else if (words[0][2] == 'w') {
value = cpu_inw(addr);
} else if (words[0][2] == 'l') {
value = cpu_inl(addr);
}
qtest_send_prefix(chr);
qtest_send(chr, "OK 0x%04x\n", value);
} else if (strcmp(words[0], "writeb") == 0 ||
strcmp(words[0], "writew") == 0 ||
strcmp(words[0], "writel") == 0 ||
strcmp(words[0], "writeq") == 0) {
uint64_t addr;
uint64_t value;
g_assert(words[1] && words[2]);
addr = strtoull(words[1], NULL, 0);
value = strtoull(words[2], NULL, 0);
if (words[0][5] == 'b') {
uint8_t data = value;
cpu_physical_memory_write(addr, &data, 1);
} else if (words[0][5] == 'w') {
uint16_t data = value;
tswap16s(&data);
cpu_physical_memory_write(addr, &data, 2);
} else if (words[0][5] == 'l') {
uint32_t data = value;
tswap32s(&data);
cpu_physical_memory_write(addr, &data, 4);
} else if (words[0][5] == 'q') {
uint64_t data = value;
tswap64s(&data);
cpu_physical_memory_write(addr, &data, 8);
}
qtest_send_prefix(chr);
qtest_send(chr, "OK\n");
} else if (strcmp(words[0], "readb") == 0 ||
strcmp(words[0], "readw") == 0 ||
strcmp(words[0], "readl") == 0 ||
strcmp(words[0], "readq") == 0) {
uint64_t addr;
uint64_t value = UINT64_C(-1);
g_assert(words[1]);
addr = strtoull(words[1], NULL, 0);
if (words[0][4] == 'b') {
uint8_t data;
cpu_physical_memory_read(addr, &data, 1);
value = data;
} else if (words[0][4] == 'w') {
uint16_t data;
cpu_physical_memory_read(addr, &data, 2);
value = tswap16(data);
} else if (words[0][4] == 'l') {
uint32_t data;
cpu_physical_memory_read(addr, &data, 4);
value = tswap32(data);
} else if (words[0][4] == 'q') {
cpu_physical_memory_read(addr, &value, 8);
tswap64s(&value);
}
qtest_send_prefix(chr);
qtest_send(chr, "OK 0x%016" PRIx64 "\n", value);
} else if (strcmp(words[0], "read") == 0) {
uint64_t addr, len, i;
uint8_t *data;
g_assert(words[1] && words[2]);
addr = strtoull(words[1], NULL, 0);
len = strtoull(words[2], NULL, 0);
data = g_malloc(len);
cpu_physical_memory_read(addr, data, len);
qtest_send_prefix(chr);
qtest_send(chr, "OK 0x");
for (i = 0; i < len; i++) {
qtest_send(chr, "%02x", data[i]);
}
qtest_send(chr, "\n");
g_free(data);
} else if (strcmp(words[0], "write") == 0) {
uint64_t addr, len, i;
uint8_t *data;
size_t data_len;
g_assert(words[1] && words[2] && words[3]);
addr = strtoull(words[1], NULL, 0);
len = strtoull(words[2], NULL, 0);
data_len = strlen(words[3]);
if (data_len < 3) {
qtest_send(chr, "ERR invalid argument size\n");
return;
}
data = g_malloc(len);
for (i = 0; i < len; i++) {
if ((i * 2 + 4) <= data_len) {
data[i] = hex2nib(words[3][i * 2 + 2]) << 4;
data[i] |= hex2nib(words[3][i * 2 + 3]);
} else {
data[i] = 0;
}
}
cpu_physical_memory_write(addr, data, len);
g_free(data);
qtest_send_prefix(chr);
qtest_send(chr, "OK\n");
} else if (qtest_enabled() && strcmp(words[0], "clock_step") == 0) {
int64_t ns;
if (words[1]) {
ns = strtoll(words[1], NULL, 0);
} else {
ns = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);
}
qtest_clock_warp(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ns);
qtest_send_prefix(chr);
qtest_send(chr, "OK %"PRIi64"\n", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
} else if (qtest_enabled() && strcmp(words[0], "clock_set") == 0) {
int64_t ns;
g_assert(words[1]);
ns = strtoll(words[1], NULL, 0);
qtest_clock_warp(ns);
qtest_send_prefix(chr);
qtest_send(chr, "OK %"PRIi64"\n", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
} else {
qtest_send_prefix(chr);
qtest_send(chr, "FAIL Unknown command `%s'\n", words[0]);
}
}
| 1threat |
PCIDevice *pci_try_create_multifunction(PCIBus *bus, int devfn,
bool multifunction,
const char *name)
{
DeviceState *dev;
dev = qdev_try_create(&bus->qbus, name);
if (!dev) {
return NULL;
}
qdev_prop_set_uint32(dev, "addr", devfn);
qdev_prop_set_bit(dev, "multifunction", multifunction);
return DO_UPCAST(PCIDevice, qdev, dev);
}
| 1threat |
What is the signature of method which gets four double numbers and returns a double array? : <p>I'm a bloody Java beginner and need some help.</p>
<p>I was wondering what the signature of a public method called "feld" looks like which gets four double numbers and returns a double array.</p>
<p>My exercise says "return a double array". But can i even do that or do i need to return values of my Array? My code won't work at all.</p>
<pre><code>public double [] feld (double q, double w, double e, double r){
double [] A = {q;w;e;r};
return A;
}
</code></pre>
| 0debug |
sum of list elements of specific index of list : I want to find the sum of elements of the list of index 2, index3 and index3,index4 and index4,index5 on so on
like:- list=[7,5,9,4,7,11]
aspSum=[12,14,13,11,18] ## 7+5, 5+9, 9+4, 4+7, 7+11
please help me. I am new user of stackOverFlow, | 0debug |
static void set_stream_info_from_input_stream(AVStream *st, struct playlist *pls, AVStream *ist)
{
avcodec_parameters_copy(st->codecpar, ist->codecpar);
if (pls->is_id3_timestamped)
avpriv_set_pts_info(st, 33, 1, MPEG_TIME_BASE);
else
avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den);
st->internal->need_context_update = 1;
}
| 1threat |
static void visitor_reset(TestOutputVisitorData *data)
{
visitor_output_teardown(data, NULL);
visitor_output_setup(data, NULL);
}
| 1threat |
Uploading a file to a S3 bucket with a prefix using Boto3 : <p>I am attempting to upload a file into a S3 bucket, but I don't have access to the root level of the bucket and I need to upload it to a certain prefix instead. The following code:</p>
<pre><code>import boto3
s3 = boto3.resource('s3')
open('/tmp/hello.txt', 'w+').write('Hello, world!')
s3_client.upload_file('/tmp/hello.txt', bucket_name, prefix+'hello-remote.txt')
</code></pre>
<p>Gives me an error:</p>
<p><code>An error occurred (AccessDenied) when calling the PutObject operation: Access Denied: ClientError Traceback (most recent call last): File "/var/task/tracker.py", line 1009, in testHandler s3_client.upload_file('/tmp/hello.txt', bucket_name, prefix+'hello-remote.txt') File "/var/runtime/boto3/s3/inject.py", line 71, in upload_file extra_args=ExtraArgs, callback=Callback) File "/var/runtime/boto3/s3/transfer.py", line 641, in upload_file self._put_object(filename, bucket, key, callback, extra_args) File "/var/runtime/boto3/s3/transfer.py", line 651, in _put_object **extra_args) File "/var/runtime/botocore/client.py", line 228, in _api_call return self._make_api_call(operation_name, kwargs) File "/var/runtime/botocore/client.py", line 492, in _make_api_call raise ClientError(parsed_response, operation_name) ClientError: An error occurred (AccessDenied) when calling the PutObject operation: Access Denied
</code></p>
<p><code>bucket_name</code> is in the format <code>abcd</code> while <code>prefix</code> is in the format <code>a/b/c/d/</code>. I'm not sure if the error is due to the slashes being wrong or if there's some way you can specify the prefix elsewhere, or if I don't have write permissions (although I supposedly do).</p>
<p>This code executes without any errors:</p>
<pre><code>for object in output_bucket.objects.filter(Prefix=prefix):
print(object.key)
</code></pre>
<p>Although there is no output as the bucket is empty. </p>
| 0debug |
Creating a chrome extension that allow you see a HTML in all tabs : I was think in a project to study how Google Extensions works,
what is my idea?
I want to create a HTML that works in all tabs in the same moment.
Example: I'm in the first tab of Chrome and will have a button in html element when I press the button appears a div saying "Yes" and when I switch the tab for the second, the idea is the div saying "Yes" will continue in the same place.
The best scenario for me is the same DIV that are in the first tab will be the same in the second.
For this project I need to know if it is possible and how do and start to do this,
Thanks!! | 0debug |
I want to know whether there is a default functionality for updating a django template from the server side based on an event : <p>I am a beginner django developer. I am supposed to make an auction website. I have to update the template which shows the listing of the items and bids and I will have to update the template with latest bids each time a bidder makes one without having to refresh the page for each new update.</p>
<p>I have thought of querying the table each second and make ajax calls at the same intervals but I want to have real time updates without the extra overhead of polling and ajax calls each second, thus this question.</p>
<p>I am not looking for a specific piece of code to accomplish this, I just wanted to know whether there is any relevant package available to aid me in this, if not I'd request you to suggest me with a generic direction to accomplish this.</p>
| 0debug |
Time schedule algorithm : <p>I have been trying for some time solve a scheduling problem for an App that I used to work at. This problem is as follows...</p>
<p>First time the list gets populated:</p>
<ul>
<li>will look at all contacts that a user has made “Active” in the Contacts list.</li>
<li>For each, it should look at their selected contact frequency (e.g. x days, x weeks, x months.) </li>
<li>will compare their “last contact date” with today’s date. For any contact where the difference between these dates is greater than their assigned contact frequency, the person is a candidate to be added to the Agent list.</li>
</ul>
<p>The order of how people will appear on the Agent list should adhere to the following rules:</p>
<ul>
<li>Contacts with longest gap between last contact are higher on the list</li>
<li>Contacts marked as Favorite go to the top of the list</li>
<li>isApp users take priority</li>
</ul>
<p>From this list of “candidates”, the algorithm should then also review contact history for each. For contacts with the following assigned contact frequency, follow these rules </p>
<ul>
<li>Every x Days – Do not take history into account. Just add when they’re past due </li>
<li>Every x Weeks – if contact already within the last 3 days, do not show, and skip to the next time they will be up for contacting. </li>
<li>Every x Months – if contact already within the last 7 days, do not show, and skip to the next time they will be up for contacting.</li>
<li>Every x Year – if contacted in the last month, do not show, and skip to the next time they will be up for contacting.</li>
</ul>
| 0debug |
Regex for to validate only US and India retail number : I am trying to get a regex which serves belwo Requirements.
1) validates US,India Retail phone no
2) exclude special purpose/Business purpose phone nos in both countries. i.e. starting from 800, 888, 877, and 866,900,at least 10 digits for US, there can be more guidelines but above is just for example.
3) It should validate special chars if any like (,),+,1,0 if included but satisfies all this points than should be a valid phone no.
4) If preceded by STD,ISD consider it as valid.
5) Landline,Mobile both should be valid.
I tried alot on google to get some clue if some one came across same requirements but solutions I am getting serving diff requirements and not exact one I am looking for. This is last hope. Thank you very much for your help. Thanks. | 0debug |
static int upload_texture(SDL_Texture *tex, AVFrame *frame, struct SwsContext **img_convert_ctx) {
int ret = 0;
switch (frame->format) {
case AV_PIX_FMT_YUV420P:
ret = SDL_UpdateYUVTexture(tex, NULL, frame->data[0], frame->linesize[0],
frame->data[1], frame->linesize[1],
frame->data[2], frame->linesize[2]);
break;
case AV_PIX_FMT_BGRA:
ret = SDL_UpdateTexture(tex, NULL, frame->data[0], frame->linesize[0]);
break;
default:
*img_convert_ctx = sws_getCachedContext(*img_convert_ctx,
frame->width, frame->height, frame->format, frame->width, frame->height,
AV_PIX_FMT_BGRA, sws_flags, NULL, NULL, NULL);
if (*img_convert_ctx != NULL) {
uint8_t *pixels;
int pitch;
if (!SDL_LockTexture(tex, NULL, (void **)&pixels, &pitch)) {
sws_scale(*img_convert_ctx, (const uint8_t * const *)frame->data, frame->linesize,
0, frame->height, &pixels, &pitch);
SDL_UnlockTexture(tex);
}
} else {
av_log(NULL, AV_LOG_FATAL, "Cannot initialize the conversion context\n");
ret = -1;
}
break;
}
return ret;
}
| 1threat |
MongoDB query $in with regex array of element : <p>Ok i am trying to implement a query, which is trying to perform regex search ( which contains an array list ) on a bunch of document</p>
<p>Its hard for me to explain...so I am basically coming to direct point.</p>
<p>There is query which works with regex array...</p>
<pre><code>db.paper.find({"category": {$in: [ /xd/, /sd/, /ad/ ] }})
</code></pre>
<p>There is query which doesn't works with regex array...</p>
<pre><code>db.paper.find({"category": {$in: [ "/xd/", "/sd/", "/ad/" ] }})
</code></pre>
<p>So basically what I want is remove "" sign from string array...so that i can perform below query..</p>
<pre><code>var sea = [ "/xd/", "/sd/", "/ad/" ];
db.paper.find({"category": {$in: sea }});
</code></pre>
| 0debug |
static int decode_hextile(VmncContext *c, uint8_t* dst, uint8_t* src, int w, int h, int stride)
{
int i, j, k;
int bg = 0, fg = 0, rects, color, flags, xy, wh;
const int bpp = c->bpp2;
uint8_t *dst2;
int bw = 16, bh = 16;
uint8_t *ssrc=src;
for(j = 0; j < h; j += 16) {
dst2 = dst;
bw = 16;
if(j + 16 > h) bh = h - j;
for(i = 0; i < w; i += 16, dst2 += 16 * bpp) {
if(i + 16 > w) bw = w - i;
flags = *src++;
if(flags & HT_RAW) {
paint_raw(dst2, bw, bh, src, bpp, c->bigendian, stride);
src += bw * bh * bpp;
} else {
if(flags & HT_BKG) {
bg = vmnc_get_pixel(src, bpp, c->bigendian); src += bpp;
}
if(flags & HT_FG) {
fg = vmnc_get_pixel(src, bpp, c->bigendian); src += bpp;
}
rects = 0;
if(flags & HT_SUB)
rects = *src++;
color = (flags & HT_CLR);
paint_rect(dst2, 0, 0, bw, bh, bg, bpp, stride);
for(k = 0; k < rects; k++) {
if(color) {
fg = vmnc_get_pixel(src, bpp, c->bigendian); src += bpp;
}
xy = *src++;
wh = *src++;
paint_rect(dst2, xy >> 4, xy & 0xF, (wh>>4)+1, (wh & 0xF)+1, fg, bpp, stride);
}
}
}
dst += stride * 16;
}
return src - ssrc;
}
| 1threat |
react-intl vs react-i18next for ReactJS internationalization (i18n) : <p>I need to build a multilanguage application using ReactJS. The application needs a custom dictionary for different languages as well as automatic formatting of date/time, numbers and currency.</p>
<p>From all I´ve seen there are 2 very popular libraries:</p>
<p><strong><a href="https://github.com/yahoo/react-intl" rel="noreferrer">reac-intl</a></strong> and <strong><a href="https://github.com/i18next/react-i18next" rel="noreferrer">react-i18next</a></strong></p>
<p>What would be the advantages between one and another ?
What is the most supported and popular one ?</p>
<p>What is the general choice for a ReactJS application supporting multiple languages ?</p>
| 0debug |
!= operator condition usage in c# : <p>I know that in C++ you can do this kind of declarations:</p>
<pre><code>size = 8 * (x % 8 != 0);
</code></pre>
<p>What would be the equivalent in C#? Do I have to use an "if"? Thanks for the help!</p>
| 0debug |
Move a player in the direction it is facing? Using transform matrix : <p>I have two characters in 3d space. I want the enemy to move towards the player.
I've just finished making a function which takes the transform of two objects, and returns a matrix, which I then apply to my enemy (overwrite the position part), and as a result he is always looking at the player. I can't figure out how can I have him move in that direction.</p>
| 0debug |
why is the output contains 4 time 0's? : <p>why is the output contains 4 time 0's.The main call again and again until if condition become false and then it should be exit from if block.</p>
<pre><code>#include <stdio.h>
int main()
{
static int i=5;
if(--i)
{
main();
printf("%d ",i);
}
}
</code></pre>
| 0debug |
Excluding Ip Address With custom Html : I have a custom landing page i would like to use for my website. Everyone who visit my website is redirected to For2dayprinting/for2day.html. How ever when I'm Editing my Wordpress i am also redirected to the landing page is there a plugin or code any one could recommend for me to exclude my ip? | 0debug |
I can't figure out what's wrong with my Java code : <p>I am making a currency converter app which converts CAD to Pounds. It gives me a error:</p>
<pre><code>Error:(16, 41) error: class expected
Error:(16, 57) error: ';' expected
Error:(16, 96) error: ';' expected
</code></pre>
<p>I can't find anything. </p>
<p>Here's my code. --> <a href="https://pastebin.com/DeWyghRh" rel="nofollow noreferrer">https://pastebin.com/DeWyghRh</a></p>
| 0debug |
Need to fetch the password using Regular expression : <pre><code>a= <<EOF
Password
:
7UV1ceFQ (You will be asked to change this after logging in for the first time)
EOF
</code></pre>
<p>I need to extract the value "7UV1ceFQ" using regular expression, I have tried using '/Password : 7UV1ceFQ/ but it's not working, I think it's because next line character is included, Can anyone please suggest me to exact this value? </p>
| 0debug |
Rename columns in postgres : <p>I am running next postgres command in cmd to rename column, but getting next error: </p>
<pre><code>postgres=> ALERT TABLE tableName RENAME "colum1" TO "column2";
ERROR: syntax error at or near "ALERT"
LINE 1: ALERT TABLE tableName RENAME "colum1" TO "co...
</code></pre>
| 0debug |
how to solve the ` Component should be written as a pure function ` error in eslint-react? : <pre><code>class Option extends React.Component {
constructor(props) {
super(props);
this.handleClickOption = this.handleClickOption.bind(this);
}
handleClickOption() {
// some code
}
render() {
return (
<li onClick={this.handleClickOption}>{this.props.option}</li>
);
}
}
</code></pre>
<p>I use <a href="https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb" rel="noreferrer">eslint-config-airbnb</a> to check the above code and it show me an error msg like <code>Component should be written as a pure function</code> .</p>
<p>So how to change the above component to pure function?</p>
<p>Thanks for your help.</p>
| 0debug |
static void setup_rt_frame(int sig, struct target_sigaction *ka,
target_siginfo_t *info,
target_sigset_t *set, CPUX86State *env)
{
abi_ulong frame_addr, addr;
struct rt_sigframe *frame;
int i, err = 0;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
__put_user(current_exec_domain_sig(sig), &frame->sig);
addr = frame_addr + offsetof(struct rt_sigframe, info);
__put_user(addr, &frame->pinfo);
addr = frame_addr + offsetof(struct rt_sigframe, uc);
__put_user(addr, &frame->puc);
copy_siginfo_to_user(&frame->info, info);
__put_user(0, &frame->uc.tuc_flags);
__put_user(0, &frame->uc.tuc_link);
__put_user(target_sigaltstack_used.ss_sp, &frame->uc.tuc_stack.ss_sp);
__put_user(sas_ss_flags(get_sp_from_cpustate(env)),
&frame->uc.tuc_stack.ss_flags);
__put_user(target_sigaltstack_used.ss_size,
&frame->uc.tuc_stack.ss_size);
setup_sigcontext(&frame->uc.tuc_mcontext, &frame->fpstate, env,
set->sig[0], frame_addr + offsetof(struct rt_sigframe, fpstate));
for(i = 0; i < TARGET_NSIG_WORDS; i++) {
if (__put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]))
goto give_sigsegv;
}
if (ka->sa_flags & TARGET_SA_RESTORER) {
__put_user(ka->sa_restorer, &frame->pretcode);
} else {
uint16_t val16;
addr = frame_addr + offsetof(struct rt_sigframe, retcode);
__put_user(addr, &frame->pretcode);
__put_user(0xb8, (char *)(frame->retcode+0));
__put_user(TARGET_NR_rt_sigreturn, (int *)(frame->retcode+1));
val16 = 0x80cd;
__put_user(val16, (uint16_t *)(frame->retcode+5));
}
if (err)
goto give_sigsegv;
env->regs[R_ESP] = frame_addr;
env->eip = ka->_sa_handler;
cpu_x86_load_seg(env, R_DS, __USER_DS);
cpu_x86_load_seg(env, R_ES, __USER_DS);
cpu_x86_load_seg(env, R_SS, __USER_DS);
cpu_x86_load_seg(env, R_CS, __USER_CS);
env->eflags &= ~TF_MASK;
unlock_user_struct(frame, frame_addr, 1);
return;
give_sigsegv:
unlock_user_struct(frame, frame_addr, 1);
if (sig == TARGET_SIGSEGV)
ka->_sa_handler = TARGET_SIG_DFL;
force_sig(TARGET_SIGSEGV );
}
| 1threat |
static void exynos4210_rtc_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
Exynos4210RTCState *s = (Exynos4210RTCState *)opaque;
switch (offset) {
case INTP:
if (value & INTP_ALM_ENABLE) {
qemu_irq_lower(s->alm_irq);
s->reg_intp &= (~INTP_ALM_ENABLE);
}
if (value & INTP_TICK_ENABLE) {
qemu_irq_lower(s->tick_irq);
s->reg_intp &= (~INTP_TICK_ENABLE);
}
break;
case RTCCON:
if (value & RTC_ENABLE) {
exynos4210_rtc_update_freq(s, value);
}
if ((value & RTC_ENABLE) > (s->reg_rtccon & RTC_ENABLE)) {
ptimer_set_count(s->ptimer_1Hz, RTC_BASE_FREQ);
ptimer_run(s->ptimer_1Hz, 1);
DPRINTF("run clock timer\n");
}
if ((value & RTC_ENABLE) < (s->reg_rtccon & RTC_ENABLE)) {
ptimer_stop(s->ptimer);
ptimer_stop(s->ptimer_1Hz);
DPRINTF("stop all timers\n");
}
if (value & RTC_ENABLE) {
if ((value & TICK_TIMER_ENABLE) >
(s->reg_rtccon & TICK_TIMER_ENABLE) &&
(s->reg_ticcnt)) {
ptimer_set_count(s->ptimer, s->reg_ticcnt);
ptimer_run(s->ptimer, 1);
DPRINTF("run tick timer\n");
}
if ((value & TICK_TIMER_ENABLE) <
(s->reg_rtccon & TICK_TIMER_ENABLE)) {
ptimer_stop(s->ptimer);
}
}
s->reg_rtccon = value;
break;
case TICCNT:
if (value > TICNT_THRESHHOLD) {
s->reg_ticcnt = value;
} else {
fprintf(stderr,
"[exynos4210.rtc: bad TICNT value %u ]\n",
(uint32_t)value);
}
break;
case RTCALM:
s->reg_rtcalm = value;
break;
case ALMSEC:
s->reg_almsec = (value & 0x7f);
break;
case ALMMIN:
s->reg_almmin = (value & 0x7f);
break;
case ALMHOUR:
s->reg_almhour = (value & 0x3f);
break;
case ALMDAY:
s->reg_almday = (value & 0x3f);
break;
case ALMMON:
s->reg_almmon = (value & 0x1f);
break;
case ALMYEAR:
s->reg_almyear = (value & 0x0fff);
break;
case BCDSEC:
if (s->reg_rtccon & RTC_ENABLE) {
s->current_tm.tm_sec = (int)from_bcd((uint8_t)value);
}
break;
case BCDMIN:
if (s->reg_rtccon & RTC_ENABLE) {
s->current_tm.tm_min = (int)from_bcd((uint8_t)value);
}
break;
case BCDHOUR:
if (s->reg_rtccon & RTC_ENABLE) {
s->current_tm.tm_hour = (int)from_bcd((uint8_t)value);
}
break;
case BCDDAYWEEK:
if (s->reg_rtccon & RTC_ENABLE) {
s->current_tm.tm_wday = (int)from_bcd((uint8_t)value);
}
break;
case BCDDAY:
if (s->reg_rtccon & RTC_ENABLE) {
s->current_tm.tm_mday = (int)from_bcd((uint8_t)value);
}
break;
case BCDMON:
if (s->reg_rtccon & RTC_ENABLE) {
s->current_tm.tm_mon = (int)from_bcd((uint8_t)value) - 1;
}
break;
case BCDYEAR:
if (s->reg_rtccon & RTC_ENABLE) {
s->current_tm.tm_year = (int)from_bcd((uint8_t)value) +
(int)from_bcd((uint8_t)((value >> 8) & 0x0f)) * 100;
}
break;
default:
fprintf(stderr,
"[exynos4210.rtc: bad write offset " TARGET_FMT_plx "]\n",
offset);
break;
}
}
| 1threat |
prototype does not match function definition, but it does : <p>I have a program with 2 functions, one of them counts number of words in a file, and works perfectly, and the other one counts the number of tymes a specific word appears in file. This las function does work perfectly (i have tested it isolated from the main), but when i ordered everything in the main, with a functions.h file, i get this.</p>
<p>The function with the problem is word_cnt(FILE*, char*)</p>
<p>when i compile, i get this:</p>
<p><code>word.c:3:5: error: conflicting types for ‘word_cnt’
</code>
<code>int word_cnt(FILE* fp, char* argv[2])
</code></p>
<pre><code>In file included from word.c:1:
functions.h:7:5: note: previous declaration of ‘word_cnt’ was here
int word_cnt(FILE*, char*);
</code></pre>
<p>in the word.c file, (file which contains the word_cnt function with the problem) the function is defined like this </p>
<pre><code>int word_cnt(FILE* fp, char* argv[2])
</code></pre>
<p>and in the header file, the prototype is like this:</p>
<pre><code>int word_cnt(FILE*, char*);
</code></pre>
<p>I do not understand....the definition is correct, why does the compiler think i am redefyning it?</p>
<p>IMAGE HERE
<a href="https://drive.google.com/open?id=1zhS3iaFURJ0HyRgcy733NsT4trfzFDve" rel="nofollow noreferrer">https://drive.google.com/open?id=1zhS3iaFURJ0HyRgcy733NsT4trfzFDve</a></p>
| 0debug |
Sorted() in lambda's not working as intended - Java 8 : <p>While learning lambda's, I found sorted method is not working as intended.</p>
<p>The following program is giving <code>[1, 33, 2, 4, 5, 11]</code> as an output, however I am expecting a sorted output.</p>
<p>Strange thing is when I replace the <code>[33, 2, 1, 4, 5, 11]</code> with <code>[ 3, 1,2, 4, 5]</code> every thing works fine and I got the sorted output as expected.</p>
<pre><code>public class Test {
public static void main(String[] args) {
List<Integer> list = Arrays.asList(33, 2, 1, 4, 5, 11);
Set<Integer> set = list.stream().sorted().collect(Collectors.toSet());
System.out.println(set);
}
}
</code></pre>
<p>Please help me understand this behavior.</p>
| 0debug |
Why isn't this "if statement" working? : <p>I have built a weather app that works perfectly. I decided to add in icons that change with the weather id variable from an API which has been assigned. It works for the first id in the if statement, but when I add else if statements inside it don't work for the else if parts here is my code: </p>
<pre><code> //weather icons check
if(weatherId=800){
$('#type').css('background-image', 'url(http://publicdomainvectors.org/photos/weather-clear.png)');
}
else if(weatherId>=801 && weatherId<=804){
$('#type').css('background-image','url(http://publicdomainvectors.org/tn_img/stylized_basic_cloud.png)');
}
else if(weatherId>=300 && weatherId<=531){
$('#type').css('background-image','url(http://publicdomainvectors.org/tn_img/sivvus_weather_symbols_4.png)');
}
</code></pre>
<p>am I missing something in this statement??? </p>
| 0debug |
syntax of join in sql : <p>i want to know the syntax of joins in sql so please help regarding this</p>
<p>thanks</p>
| 0debug |
how to get selected values to jquery? :
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
foreach($data as $row)
{
$output .= '
<tr>
<td class="col-xs-3">'.$row->policyno.'</td>
<td class="col-xs-3">'.$row->q_tree.'</td>
<td class="col-xs-3">'.$row->Tt_tree.'</td>
<td class="col-xs-3">
<input id="checkbox" style="margin-left:20px" value='.$row->policyno.' type="checkbox" name="plcdata[]" />
</td>
</tr>
';
}
<!-- end snippet -->
I use this loop to view data inside a table and pass to view page using ajax and i have added check box as a input for select rows in the table.how to get selected rows using javascript **name="plcdata[]** array of checkbox input? | 0debug |
How does vector's growth function work? : <pre><code>int main () {
std::vector <int> elements;
elements.push_back (1);
elements [10000] = 102;
std:: cout << elements [10000];
return 0;
}
</code></pre>
<p>How does the above code work? As far as I have read, vector's growth will be 1.5 - 2x. So how is the 10000th element stored here? Isn't the expected behavior here a "Segmentation fault"? But the above runs successfully.</p>
| 0debug |
static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
AVIOContext *pb = s->pb;
DXAContext *c = s->priv_data;
AVStream *st, *ast;
uint32_t tag;
int32_t fps;
int w, h;
int num, den;
int flags;
tag = avio_rl32(pb);
if (tag != MKTAG('D', 'E', 'X', 'A'))
return -1;
flags = avio_r8(pb);
c->frames = avio_rb16(pb);
if(!c->frames){
av_log(s, AV_LOG_ERROR, "File contains no frames ???\n");
return -1;
}
fps = avio_rb32(pb);
if(fps > 0){
den = 1000;
num = fps;
}else if (fps < 0){
den = 100000;
num = -fps;
}else{
den = 10;
num = 1;
}
w = avio_rb16(pb);
h = avio_rb16(pb);
c->has_sound = 0;
st = av_new_stream(s, 0);
if (!st)
return -1;
if(avio_rl32(pb) == MKTAG('W', 'A', 'V', 'E')){
uint32_t size, fsize;
c->has_sound = 1;
size = avio_rb32(pb);
c->vidpos = avio_tell(pb) + size;
avio_skip(pb, 16);
fsize = avio_rl32(pb);
ast = av_new_stream(s, 0);
if (!ast)
return -1;
ff_get_wav_header(pb, ast->codec, fsize);
while(avio_tell(pb) < c->vidpos && !pb->eof_reached){
tag = avio_rl32(pb);
fsize = avio_rl32(pb);
if(tag == MKTAG('d', 'a', 't', 'a')) break;
avio_skip(pb, fsize);
}
c->bpc = (fsize + c->frames - 1) / c->frames;
if(ast->codec->block_align)
c->bpc = ((c->bpc + ast->codec->block_align - 1) / ast->codec->block_align) * ast->codec->block_align;
c->bytes_left = fsize;
c->wavpos = avio_tell(pb);
avio_seek(pb, c->vidpos, SEEK_SET);
}
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_DXA;
st->codec->width = w;
st->codec->height = h;
av_reduce(&den, &num, den, num, (1UL<<31)-1);
av_set_pts_info(st, 33, num, den);
if(flags & 0xC0){
st->codec->height >>= 1;
}
c->readvid = !c->has_sound;
c->vidpos = avio_tell(pb);
s->start_time = 0;
s->duration = (int64_t)c->frames * AV_TIME_BASE * num / den;
av_log(s, AV_LOG_DEBUG, "%d frame(s)\n",c->frames);
return 0;
}
| 1threat |
The way to use background-image in css files with Django : <p>I'd like to use an image file as a background-image on <code>Django</code>. But I do not know how.
First, I read <a href="https://docs.djangoproject.com/en/1.10/intro/tutorial06/" rel="noreferrer">this</a> and tried to write like following this in a css file.</p>
<pre><code>#third{
background: url("img/sample.jpeg") 50% 0 no-repeat fixed;
color: white;
height: 650px;
padding: 100px 0 0 0;
}
</code></pre>
<p>But this does not work.</p>
<pre><code>{% load staticfiles %}
#third{
background: url({% static "img/sample.jpeg" %}) 50% 0 no-repeat fixed;
}
</code></pre>
<p>and</p>
<pre><code>#third{
background: url("../img/sample.jpeg") 50% 0 no-repeat fixed;
}
</code></pre>
<p>don't work, too. </p>
<p>How do you usually write css file when you use background-image on css files? Would you please give me some advices?</p>
<pre><code>C:\~~~~~~> dir hello\static\img
2016/09/28 19:56 2,123 logo.png
2016/09/24 14:53 104,825 sample.jpeg
C:\~~~~~~> dir hello\static\css
2016/09/29 20:27 1,577 site.css
C:\~~~~~~> more lemon\settings.py
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(PROJECT_ROOT, 'static'),
)
C:\~~~~~~> more hello\templates\base.html
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static "css/site.css" %}" />
</code></pre>
<p>Django version: 1.9.2</p>
| 0debug |
static int bmp_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
BMPContext *s = avctx->priv_data;
AVFrame *picture = data;
AVFrame *p = &s->picture;
unsigned int fsize, hsize;
int width, height;
unsigned int depth;
BiCompression comp;
unsigned int ihsize;
int i, j, n, linesize;
uint32_t rgb[3];
uint32_t alpha = 0;
uint8_t *ptr;
int dsize;
const uint8_t *buf0 = buf;
GetByteContext gb;
if(buf_size < 14){
av_log(avctx, AV_LOG_ERROR, "buf size too small (%d)\n", buf_size);
return -1;
}
if(bytestream_get_byte(&buf) != 'B' ||
bytestream_get_byte(&buf) != 'M') {
av_log(avctx, AV_LOG_ERROR, "bad magic number\n");
return -1;
}
fsize = bytestream_get_le32(&buf);
if(buf_size < fsize){
av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d), trying to decode anyway\n",
buf_size, fsize);
fsize = buf_size;
}
buf += 2;
buf += 2;
hsize = bytestream_get_le32(&buf);
ihsize = bytestream_get_le32(&buf);
if(ihsize + 14 > hsize){
av_log(avctx, AV_LOG_ERROR, "invalid header size %d\n", hsize);
return -1;
}
if(fsize == 14 || fsize == ihsize + 14)
fsize = buf_size - 2;
if(fsize <= hsize){
av_log(avctx, AV_LOG_ERROR, "declared file size is less than header size (%d < %d)\n",
fsize, hsize);
return -1;
}
switch(ihsize){
case 40:
case 56: v3
case 64:
case 108: v4
case 124: v5
width = bytestream_get_le32(&buf);
height = bytestream_get_le32(&buf);
break;
case 12:
width = bytestream_get_le16(&buf);
height = bytestream_get_le16(&buf);
break;
default:
av_log(avctx, AV_LOG_ERROR, "unsupported BMP file, patch welcome\n");
return -1;
}
if(bytestream_get_le16(&buf) != 1){
av_log(avctx, AV_LOG_ERROR, "invalid BMP header\n");
return -1;
}
depth = bytestream_get_le16(&buf);
if (ihsize >= 40)
comp = bytestream_get_le32(&buf);
else
comp = BMP_RGB;
if(comp != BMP_RGB && comp != BMP_BITFIELDS && comp != BMP_RLE4 && comp != BMP_RLE8){
av_log(avctx, AV_LOG_ERROR, "BMP coding %d not supported\n", comp);
return -1;
}
if(comp == BMP_BITFIELDS){
buf += 20;
rgb[0] = bytestream_get_le32(&buf);
rgb[1] = bytestream_get_le32(&buf);
rgb[2] = bytestream_get_le32(&buf);
alpha = bytestream_get_le32(&buf);
}
avctx->width = width;
avctx->height = height > 0? height: -height;
avctx->pix_fmt = AV_PIX_FMT_NONE;
switch(depth){
case 32:
if(comp == BMP_BITFIELDS){
if (rgb[0] == 0xFF000000 && rgb[1] == 0x00FF0000 && rgb[2] == 0x0000FF00)
avctx->pix_fmt = alpha ? AV_PIX_FMT_ABGR : AV_PIX_FMT_0BGR;
else if (rgb[0] == 0x00FF0000 && rgb[1] == 0x0000FF00 && rgb[2] == 0x000000FF)
avctx->pix_fmt = alpha ? AV_PIX_FMT_BGRA : AV_PIX_FMT_BGR0;
else if (rgb[0] == 0x0000FF00 && rgb[1] == 0x00FF0000 && rgb[2] == 0xFF000000)
avctx->pix_fmt = alpha ? AV_PIX_FMT_ARGB : AV_PIX_FMT_0RGB;
else if (rgb[0] == 0x000000FF && rgb[1] == 0x0000FF00 && rgb[2] == 0x00FF0000)
avctx->pix_fmt = alpha ? AV_PIX_FMT_RGBA : AV_PIX_FMT_RGB0;
else {
av_log(avctx, AV_LOG_ERROR, "Unknown bitfields %0X %0X %0X\n", rgb[0], rgb[1], rgb[2]);
return AVERROR(EINVAL);
}
} else {
avctx->pix_fmt = AV_PIX_FMT_BGRA;
}
break;
case 24:
avctx->pix_fmt = AV_PIX_FMT_BGR24;
break;
case 16:
if(comp == BMP_RGB)
avctx->pix_fmt = AV_PIX_FMT_RGB555;
else if (comp == BMP_BITFIELDS) {
if (rgb[0] == 0xF800 && rgb[1] == 0x07E0 && rgb[2] == 0x001F)
avctx->pix_fmt = AV_PIX_FMT_RGB565;
else if (rgb[0] == 0x7C00 && rgb[1] == 0x03E0 && rgb[2] == 0x001F)
avctx->pix_fmt = AV_PIX_FMT_RGB555;
else if (rgb[0] == 0x0F00 && rgb[1] == 0x00F0 && rgb[2] == 0x000F)
avctx->pix_fmt = AV_PIX_FMT_RGB444;
else {
av_log(avctx, AV_LOG_ERROR, "Unknown bitfields %0X %0X %0X\n", rgb[0], rgb[1], rgb[2]);
return AVERROR(EINVAL);
}
}
break;
case 8:
if(hsize - ihsize - 14 > 0)
avctx->pix_fmt = AV_PIX_FMT_PAL8;
else
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
break;
case 1:
case 4:
if(hsize - ihsize - 14 > 0){
avctx->pix_fmt = AV_PIX_FMT_PAL8;
}else{
av_log(avctx, AV_LOG_ERROR, "Unknown palette for %d-colour BMP\n", 1<<depth);
return -1;
}
break;
default:
av_log(avctx, AV_LOG_ERROR, "depth %d not supported\n", depth);
return -1;
}
if(avctx->pix_fmt == AV_PIX_FMT_NONE){
av_log(avctx, AV_LOG_ERROR, "unsupported pixel format\n");
return -1;
}
if(p->data[0])
avctx->release_buffer(avctx, p);
p->reference = 0;
if(avctx->get_buffer(avctx, p) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
p->pict_type = AV_PICTURE_TYPE_I;
p->key_frame = 1;
buf = buf0 + hsize;
dsize = buf_size - hsize;
n = ((avctx->width * depth + 31) / 8) & ~3;
if(n * avctx->height > dsize && comp != BMP_RLE4 && comp != BMP_RLE8){
av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n",
dsize, n * avctx->height);
return -1;
}
if(comp == BMP_RLE4 || comp == BMP_RLE8)
memset(p->data[0], 0, avctx->height * p->linesize[0]);
if(height > 0){
ptr = p->data[0] + (avctx->height - 1) * p->linesize[0];
linesize = -p->linesize[0];
} else {
ptr = p->data[0];
linesize = p->linesize[0];
}
if(avctx->pix_fmt == AV_PIX_FMT_PAL8){
int colors = 1 << depth;
memset(p->data[1], 0, 1024);
if(ihsize >= 36){
int t;
buf = buf0 + 46;
t = bytestream_get_le32(&buf);
if(t < 0 || t > (1 << depth)){
av_log(avctx, AV_LOG_ERROR, "Incorrect number of colors - %X for bitdepth %d\n", t, depth);
}else if(t){
colors = t;
}
}
buf = buf0 + 14 + ihsize;
if((hsize-ihsize-14) < (colors << 2)){
for(i = 0; i < colors; i++)
((uint32_t*)p->data[1])[i] = (0xff<<24) | bytestream_get_le24(&buf);
}else{
for(i = 0; i < colors; i++)
((uint32_t*)p->data[1])[i] = 0xFFU << 24 | bytestream_get_le32(&buf);
}
buf = buf0 + hsize;
}
if(comp == BMP_RLE4 || comp == BMP_RLE8){
if(height < 0){
p->data[0] += p->linesize[0] * (avctx->height - 1);
p->linesize[0] = -p->linesize[0];
}
bytestream2_init(&gb, buf, dsize);
ff_msrle_decode(avctx, (AVPicture*)p, depth, &gb);
if(height < 0){
p->data[0] += p->linesize[0] * (avctx->height - 1);
p->linesize[0] = -p->linesize[0];
}
}else{
switch(depth){
case 1:
for (i = 0; i < avctx->height; i++) {
int j;
for (j = 0; j < n; j++) {
ptr[j*8+0] = buf[j] >> 7;
ptr[j*8+1] = (buf[j] >> 6) & 1;
ptr[j*8+2] = (buf[j] >> 5) & 1;
ptr[j*8+3] = (buf[j] >> 4) & 1;
ptr[j*8+4] = (buf[j] >> 3) & 1;
ptr[j*8+5] = (buf[j] >> 2) & 1;
ptr[j*8+6] = (buf[j] >> 1) & 1;
ptr[j*8+7] = buf[j] & 1;
}
buf += n;
ptr += linesize;
}
break;
case 8:
case 24:
case 32:
for(i = 0; i < avctx->height; i++){
memcpy(ptr, buf, n);
buf += n;
ptr += linesize;
}
break;
case 4:
for(i = 0; i < avctx->height; i++){
int j;
for(j = 0; j < n; j++){
ptr[j*2+0] = (buf[j] >> 4) & 0xF;
ptr[j*2+1] = buf[j] & 0xF;
}
buf += n;
ptr += linesize;
}
break;
case 16:
for(i = 0; i < avctx->height; i++){
const uint16_t *src = (const uint16_t *) buf;
uint16_t *dst = (uint16_t *) ptr;
for(j = 0; j < avctx->width; j++)
*dst++ = av_le2ne16(*src++);
buf += n;
ptr += linesize;
}
break;
default:
av_log(avctx, AV_LOG_ERROR, "BMP decoder is broken\n");
return -1;
}
}
*picture = s->picture;
*data_size = sizeof(AVPicture);
return buf_size;
}
| 1threat |
Why is the Visual Studio C++ Compiler rejecting an enum as a template parameter? : <p>I'm using the Microsoft Visual Studio 2019 compiler (cl.exe), and it is rejecting some code accepted by both Clang and GCC, related to using enums as template parameters, where the templates are specialized for particular enum values.</p>
<pre><code>enum Foo {
Bar,
Baz
};
template<enum Foo = Bar> class Clazz {
};
template<> class Clazz<Baz> {
};
</code></pre>
<p>The VC++ compiler reports several errors on the template specialization:</p>
<pre><code><source>(10): error C2440: 'specialization': cannot convert from 'Foo' to 'Foo'
<source>(10): note: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
</code></pre>
<p>This code is accepted without errors by both Clang and GCC. Is this a bug with VC++?</p>
<p>Replacing the 'enum Foo' in the template declaration with just 'int' causes the errors to go away. However, this is not an acceptable answer, as I'm trying to port a large code base over to VC++.</p>
| 0debug |
Why my regex doesn't match : it's the first time i use regex. I used .Net regex tester...all is ok....but in my C# application, IsMatch return false.
Here is my code :
Regex reg = new Regex(@"^[0 - 9]{ 3}_RE_[0 - 9]{ 4}[0-9]{2}[0-9]{2}_[0 - 9]{2}[0-9]{2}[0-9]{2}.TXT$");
string fileName = "102_RE_20120102_091013.TXT"
if (reg.IsMatch(fileName))
{
// Code Never go here :(
}
What is wrong please ? I don't see my mistake :(
Thanks a lot :)
| 0debug |
GoLang Int24 to Int32 : <p>Hi guys i wrote this function in GoLang to cast a 24 bit int (3 bytes) to a 32 bit int (4 bytes)</p>
<pre><code>func int24ToInt32(bytes []byte) uint32 {
return binary.BigEndian.Uint32(append([]byte{0x00}, bytes...))
}
</code></pre>
<p>I want to know if this is a bad solution to the problem. Maybe someone can guide me out to a better and efficient solution</p>
| 0debug |
Where gcc come from when using lunux terminal? : I'm a beginner of linux, and I don't know the commands details now. I have a question about where I can get some packages from. For example, when I want to get "gcc", I entered "yum install gcc". Where it comes from Internet Web? or linux has it from the beginning? I was a windows user ,and then I went to Websites to get "gcc" and download it at the page. I'm puzzled where I can get "gcc" from. | 0debug |
How to Use PHP headers() in Wordpress to Download Files from my Custom Plugin Page? : <!-- What are you trying to accomplish? (Please include sample data.) -->
I am Trying to Use **PHP headers() in wordpress to download files from my plugin page view** but is not working as this Error Message return for each header line present in my script:
> Warning: Cannot modify header information - headers already sent by (output started at D:\xampp\wordpress\wp-includes\formatting.php:5100) in D:\xampp\wordpress\wp-content\plugins\pxw-test\pxw-test.php on line 33
and so on for each line of present headers(); in my script..
<!-- Paste the part of the code that shows the problem. (Please indent 4 spaces.) -->
**In order to replicate my Errors Download The Test Plugin named " pxw-test " :**
[pxw-test.zip][1] > https://ufile.io/ld2v4
**The plugin contain 2 files:**
1. The plugin itself very light = pxw-test.php
2. The file to download = file.txt
Which I Uploaded Today, the link will be valid for 30 days only and I will Update the link when expired, if it does not work please let me know..
Before download You can have a look at the pxw-test.php file Content (The Plugin Itself) Below:
<?php
/*
Plugin Name: Test Headers
Description: Download File Test Plugin for Headers Response errors.
Version: 1.0
Author: Tester
Text Domain: pxw_test
*/
//Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ){
exit;
}
//Admin Menu
function pxw_test_menu() {
//create custom top-level menu
add_menu_page(
'Dashboard',
'Test Headers',
'manage_options',
'pxw_test',
'pxw_test_dashboard_page',
null,
20
);
}
//Function needed to display top-level page as the main page
function pxw_test_dashboard_page(){
//Download
if(isset($_POST['download'])){
//File To Download
$filename = 'file.txt';
// http headers for Downloads
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=$filename");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize(plugin_dir_path(__FILE__).$filename));
//You can try the following
// while (ob_get_level()) {
// ob_end_clean();
// }
// @readfile(plugin_dir_path(__FILE__).$filename);
}
else{}
?>
<form action="" method="POST" enctype="multipart/form-data" style="text-align:center;padding: 100px 0;">
<button type="submit" onclick="this.form.submit();" style="background:red;padding:10px;color:#fff;cursor:pointer;"><b>Download File</b></button>
<input type="hidden" name="download" />
</form>
<?php
}
//Finally Display the menu
add_action('admin_menu', 'pxw_test_menu' );?>
Before Usual Nonsense Reply such as 'check the spaces before/after <?php / ?> tags' and similar attempt solutions,
**Please check the test plugin** so you can spot easily the real problem or solution for my case.
<!-- What do you expect the result to be? -->
> My goal is to **Download** a file and **delete** the file after Download.
**Of course I am not looking for:**
**function.php** solution as I am building a plugin.
**But Anything short and manageable from my plugin folder is welcomed.**
Such as:
1. PHP
2. javascript
3. Jquery
4. Html5 such as `<iframe>` **but not** the `<a download></a>` as I will need to make actions such as delete file after download and if file downloaded or not.
I hope someone of the wordpress guru out there can unveil the mistery behind it and explain exactly in short why that happens and how to resolve it.
I thank you all very much in advance for your help and interest!!
<!-- What is the actual result you get? (Please include any errors.) -->
[1]: https://ufile.io/ld2v4 | 0debug |
How to pick a Kafka transaction.id : <p>I wonder could I get some help understanding transactions in Kafka and in particular how I use transaction.id. Here's the context:</p>
<ol>
<li>My Kafka application follows the pattern: consume message from input topic, process, publish to output topic. </li>
<li>I am using not using the Kafka Streams API.</li>
<li>I have multiple consumers in a single consumer group and each consumer is in its own polling thread.</li>
<li>There is a thread pool with worker threads that do the message processing and publishing to the output topic. At the moment, each thread has its own producer instance.</li>
<li>I am using the published transactions API to ensure that the update of the consume offset and the publishing to the output topic happen atomically</li>
</ol>
<p>My assumptions to date have included:</p>
<ol>
<li>If my process crashed in mid transaction then nothing from that transaction would have published and no consume offset would have moved. So upon restart, I would simply start the transaction again from the original consume offset. </li>
<li>For the producer transaction.id, all that mattered was that it was unique. I could therefore generate a timestamp based id at start-up</li>
</ol>
<p>Then I read the following blog: <a href="https://www.confluent.io/blog/transactions-apache-kafka/" rel="noreferrer">https://www.confluent.io/blog/transactions-apache-kafka/</a>. In particular in the section "How to pick a transaction id" it seems to imply that I need to guarantee that a producer instance per input partition. It says "The key to fencing out zombies properly is to ensure that the input topics and partitions in the read-process-write cycle is always the same for a given transactional.id.". It further cites the problem example as follows: "For instance, in a distributed stream processing application, suppose topic-partition tp0 was originally processed by transactional.id T0. If, at some point later, it could be mapped to another producer with transactional.id T1, there would be no fencing between T0 and T1. So it is possible for messages from tp0 to be reprocessed, violating the exactly once processing guarantee."</p>
<p>I can't quite understand why this is the case. To my mind, I shouldn't care what producer handles messages from any partition as long as transactions are atomic. I've been struggling with this for a day and I wonder if someone could tell me what I've missed here. So, why can't I assign work to any producer instance with any transaction.id setting as long as it is unique. And why do they say that messages can leak through the fencing provided by transactions if you do this.</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.