problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Fb login linked to a menu page Objective c : I have set up a facebook login for my app and it works but what I don't know how to do is when you log in the app through facebook, the app should take you to a menu screen. Right now with facebook login it is taking me to the log out page. Any help would be appreciated. | 0debug |
Cannot run `source` in AWS Codebuild : <p>I am using AWS CodeBuild along with Terraform for automated deployment of a Lambda based service. I have a very simple <code>buildscript.yml</code> that accomplishes the following:</p>
<ul>
<li>Get dependencies</li>
<li>Run Tests</li>
<li>Get AWS credentials and save to file (detailed below)</li>
<li>Source the creds file</li>
<li>Run Terraform</li>
</ul>
<p>The step "source the creds file" is where I am having my difficulty. I have a simply bash one-liner that grabs the AWS container creds off of <code>curl 169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI</code> and then saves them to a file in the following format:</p>
<pre><code>export AWS_ACCESS_KEY_ID=SOMEACCESSKEY
export AWS_SECRET_ACCESS_KEY=MYSECRETKEY
export AWS_SESSION_TOKEN=MYSESSIONTOKEN
</code></pre>
<p>Of course, the obvious step is to simply <code>source</code> this file so that these variables can be added to my environment for Terraform to use. However, when I do <code>source /path/to/creds_file.txt</code>, CodeBuild returns: </p>
<pre><code>[Container] 2017/06/28 18:28:26 Running command source /path/to/creds_file.txt
/codebuild/output/tmp/script.sh: 4: /codebuild/output/tmp/script.sh: source: not found
</code></pre>
<p>I have tried to install <code>source</code> through <code>apt</code> but then I get an error saying that <code>source</code> cannot be found (yes, I've run <code>apt update</code> etc.). I am using a standard Ubuntu image with the Python 2.7 environment for CodeBuild. What can I do to either get Terraform working credentials for source this credentials file in Codebuild.</p>
<p>Thanks!</p>
| 0debug |
void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector,
int nr_sectors)
{
BdrvDirtyBitmap *bitmap;
QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) {
hbitmap_set(bitmap->bitmap, cur_sector, nr_sectors);
}
}
| 1threat |
static void cchip_write(void *opaque, target_phys_addr_t addr,
uint64_t v32, unsigned size)
{
TyphoonState *s = opaque;
uint64_t val, oldval, newval;
if (addr & 4) {
val = v32 << 32 | s->latch_tmp;
addr ^= 4;
} else {
s->latch_tmp = v32;
return;
}
switch (addr) {
case 0x0000:
break;
case 0x0040:
break;
case 0x0080:
newval = oldval = s->cchip.misc;
newval &= ~(val & 0x10000ff0);
if (val & 0x100000) {
newval &= ~0xff0000ull;
} else {
newval |= val & 0x00f00000;
if ((newval & 0xf0000) == 0) {
newval |= val & 0xf0000;
}
}
newval |= (val & 0xf000) >> 4;
newval &= ~0xf0000000000ull;
newval |= val & 0xf0000000000ull;
s->cchip.misc = newval;
if ((newval ^ oldval) & 0xff0) {
int i;
for (i = 0; i < 4; ++i) {
CPUAlphaState *env = s->cchip.cpu[i];
if (env) {
if (newval & (1 << (i + 8))) {
cpu_interrupt(env, CPU_INTERRUPT_SMP);
} else {
cpu_reset_interrupt(env, CPU_INTERRUPT_SMP);
}
if ((newval & (1 << (i + 4))) == 0) {
cpu_reset_interrupt(env, CPU_INTERRUPT_TIMER);
}
}
}
}
break;
case 0x00c0:
break;
case 0x0100:
case 0x0140:
case 0x0180:
case 0x01c0:
break;
case 0x0200:
s->cchip.dim[0] = val;
cpu_irq_change(s->cchip.cpu[0], val & s->cchip.drir);
break;
case 0x0240:
s->cchip.dim[0] = val;
cpu_irq_change(s->cchip.cpu[1], val & s->cchip.drir);
break;
case 0x0280:
case 0x02c0:
case 0x0300:
break;
case 0x0340:
break;
case 0x0380:
s->cchip.iic[0] = val & 0xffffff;
break;
case 0x03c0:
s->cchip.iic[1] = val & 0xffffff;
break;
case 0x0400:
case 0x0440:
case 0x0480:
case 0x04c0:
break;
case 0x0580:
break;
case 0x05c0:
break;
case 0x0600:
s->cchip.dim[2] = val;
cpu_irq_change(s->cchip.cpu[2], val & s->cchip.drir);
break;
case 0x0640:
s->cchip.dim[3] = val;
cpu_irq_change(s->cchip.cpu[3], val & s->cchip.drir);
break;
case 0x0680:
case 0x06c0:
break;
case 0x0700:
s->cchip.iic[2] = val & 0xffffff;
break;
case 0x0740:
s->cchip.iic[3] = val & 0xffffff;
break;
case 0x0780:
break;
case 0x0c00:
case 0x0c40:
case 0x0c80:
case 0x0cc0:
break;
default:
cpu_unassigned_access(cpu_single_env, addr, 1, 0, 0, size);
return;
}
}
| 1threat |
Firebase and Crashlytics - Which one to use? : <p>Since the presentation of Firebase Crash Reporting, one of the most prominent questions has been wether moving from Crashlytics or not.</p>
<p>What are the pros and cons when comparing the two crash reporting services?</p>
| 0debug |
Convert image to binary to apply Image Steganography : <p>I was trying to convert a ".jpg" image to binary and then change its binary value to hide some data. But couldn't find anything. Any ideas anyone?</p>
| 0debug |
await await vs Unwrap() : <p>Given a method such as</p>
<pre><code>public async Task<Task> ActionAsync()
{
...
}
</code></pre>
<p>What is the difference between</p>
<pre><code>await await ActionAsync();
</code></pre>
<p>and</p>
<pre><code>await ActionAsync().Unwrap();
</code></pre>
<p>if any.</p>
| 0debug |
static void string_serialize(void *native_in, void **datap,
VisitorFunc visit, Error **errp)
{
StringSerializeData *d = g_malloc0(sizeof(*d));
d->sov = string_output_visitor_new(false);
visit(string_output_get_visitor(d->sov), &native_in, errp);
*datap = d;
}
| 1threat |
What is the difference between these instruction : What is the difference between these instruction
-Add (R0), R3
-Add R0, (R3)
And why the place () have been changed | 0debug |
How Can Uploads Images To Folder and Sends Image Path to Database And how Change Image Name to my UserName Using ADO.NET : In this code Eror occurs when Save file to disk and I want Want Convert image name to my UserName What I can Do??? please Check the Error and Another problem is that FullUrl are Saved When work Code My 2nd Code :(
if (ModelState.IsValid)
{
if (account.file != null)
{
string FileName = Path.GetFileName(account.file.FileName);
//Save files to disk
account.file.SaveAs(Server.MapPath("Uploads/" + FileName));
//Add Entry to DataBase
string conection = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(conection))
{
string InsertAccount = "Insert into tblUser (FirstName,LastName,EmailAdress,UserName,Password,UserImage) values(@fname,@lname,@emailadress,@username,@password,@Userimagepath)";
SqlCommand cmd = new SqlCommand(InsertAccount, con);
cmd.Parameters.AddWithValue("@fname", account.FirstName);
cmd.Parameters.AddWithValue("@lname", account.LastName);
cmd.Parameters.AddWithValue("@emailadress", account.EmailAddress);
cmd.Parameters.AddWithValue("@username", account.Username);
cmd.Parameters.AddWithValue("@password", account.Password);
cmd.Parameters.AddWithValue("@UserimagePath", "Uploads/" + FileName);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
Could not find a part of the path 'E:\Projects\FBClone\FBClone\Account\Uploads\14494605_1912172235673452_6934911680009623037_n.jpg'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'E:\Projects\FBClone\FBClone\Account\Uploads\14494605_1912172235673452_6934911680009623037_n.jpg'.
Source Error:
Line 30: string FileName = Path.GetFileName(account.file.FileName);
Line 31: //Save files to disk
Line 32: account.file.SaveAs(Server.MapPath("Uploads/" + FileName));
Line 33:
Line 34: //Add Entry to DataBase
Source File: E:\Projects\FBClone\FBClone\Controllers\AccountController.cs Line: 32
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
This Is My 2nd Code
// Set uploads dir
var uploadsDir = new DirectoryInfo(string.Format("{0}Uploads", Server.MapPath(@"\")));
// Check if a file was uploaded
if (file != null && file.ContentLength > 0)
{
// Get extension
string ext = file.ContentType.ToLower();
// Verify extension
if (ext != "image/jpg" &&
ext != "image/jpeg" &&
ext != "image/pjpeg" &&
ext != "image/gif" &&
ext != "image/x-png" &&
ext != "image/png")
{
ModelState.AddModelError("", "The image was not uploaded - wrong image extension.");
return View("Index", account);
}
// Set image name
string imageName = account.Username + ".jpg";
// Set image path
var path = string.Format("{0}\\{1}", uploadsDir, imageName);
account.image = path;
//Insert Value funtion
account.CreateAccount();
// Save image
file.SaveAs(path);
}
}
<!-- end snippet -->
}
return Redirect("~/");
} | 0debug |
Difference between IOptionsMonitor vs. IOptionsSnapshot : <p>According to <a href="https://stackoverflow.com/a/46570073/1987788">this answer</a>, <code>IOptionsMonitor</code> is registered in DI container as <strong>singleton</strong> and is capable of detecting changes through <code>OnChange</code> event subscription. It has a <code>CurrentValue</code> property.</p>
<p>In the other hand, <code>IOptionsSnapshot</code> is registered as <strong>scoped</strong> and also have a change detection capability by reading the last options for each request, but it doesn't have the <code>OnChange</code> event. It has a <code>Value</code> property.</p>
<p>Using both injected into a view for instance gives us the exactly same behavior:</p>
<pre><code>using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Options;
using UsingOptionsSample.Models;
using UsingOptionsSample.Services;
namespace UsingOptionsSample.Pages
{
public class MyOptions
{
public MyOptions()
{
// Set default value.
Option1 = "value1_from_ctor";
}
public string Option1 { get; set; }
public int Option2 { get; set; } = 5;
}
public class OptionsTestModel : PageModel
{
private readonly MyOptions _snapshotOptions;
private readonly MyOptions _monitorOptions;
public OptionsTestModel(
IOptionsMonitor<MyOptions> monitorOptionsAcessor,
IOptionsSnapshot<MyOptions> snapshotOptionsAccessor)
{
_snapshotOptions = snapshotOptionsAccessor.Value;
_monitorOptions = monitorOptionsAcessor.CurrentValue;
}
public string SnapshotOptions { get; private set; }
public string MonitorOptions { get; private set; }
public void OnGetAsync()
{
//Snapshot options
var snapshotOption1 = _snapshotOptions.Option1;
var snapshotOption2 = _snapshotOptions.Option2;
SnapshotOptions =
$"snapshot option1 = {snapshotOption1}, " +
$"snapshot option2 = {snapshotOption2}";
//Monitor options
var monitorOption1 = _monitorOptions.Option1;
var monitorOption2 = _monitorOptions.Option2;
MonitorOptions =
$"monitor option1 = {monitorOption1}, " +
$"monitor option2 = {monitorOption2}";
}
}
}
</code></pre>
<p>So, what's the point of having these two interfaces/implementation if they look like the same thing, just with different life times? The code is <a href="https://github.com/aspnet/Docs/tree/master/aspnetcore/fundamentals/configuration/options/sample" rel="noreferrer">based on this sample</a>, which surprisinly doesn't include an <code>IOptionsMonitor</code> usage sample.</p>
<p>Why one have a "Value" property and other have "CurrentValue" if both gets the "current value" of an option?</p>
<p>Why/when should I use <code>IOptionsSnapshot</code> instead of <code>IOptionsMonitor</code>?</p>
<p>I don't think I got it straight, I must be missing some very important aspect regarding these dependencies injection.</p>
| 0debug |
Android - How to detect if night mode is on when using AppCompatDelegate.MODE_NIGHT_AUTO : <p>I'm using Androids built in day/night mode functionality and I'd like to add an option to my app for <code>AppCompatDelegate.MODE_NIGHT_AUTO</code></p>
<p>I'm having a problem though because my app requires certain things to be colored programmatically, and I can't figure out how to check if the app considers itself in night or day mode. Without that, I can't set a flag to choose the right colors.</p>
<p>Calling <code>AppCompatDelegate.getDefaultNightMode()</code> just returns AppCompatDelegate.MODE_NIGHT_AUTO which is useless.</p>
<p>I don't see anything else that would tell me, but there must be something?</p>
| 0debug |
static void backup_set_speed(BlockJob *job, int64_t speed, Error **errp)
{
BackupBlockJob *s = container_of(job, BackupBlockJob, common);
if (speed < 0) {
error_setg(errp, QERR_INVALID_PARAMETER, "speed");
return;
}
ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);
}
| 1threat |
static inline void cris_ftag_i(unsigned int x)
{
register unsigned int v asm("$r10") = x;
asm ("ftagi\t[%0]\n" : : "r" (v) );
}
| 1threat |
unresolved external symbol when passing a function pointer : <p>I'm trying to create a generic button and I want to be able to pass a function to call when I click it.</p>
<p>main.cpp:</p>
<pre><code>#include "Window.h"
int testfunction() {
print("Test");
return 1;
}
...other stuff...
window->SetButtonFunction_NoArgs<int>(" *unrelated stuff* ", &testfunction);
</code></pre>
<p>window is a WindowMain class:</p>
<p>window.h:</p>
<pre><code>class WindowMain {
*Stuff*
template <class R1> void SetButtonFunction_NoArgs(string id, R1(*func)());
*Other Stuff*
};
</code></pre>
<p>window.cpp:</p>
<pre><code>///Find the object of that id and set the fuction to it
template <class R1> void WindowMain::SetButtonFunction_NoArgs(string id, R1(*func)()) {
for (int i = 0; i < objects_.size(); i++) {
if (objects_[i].getId() == id) {
objects_[i]->AddButton_NoArgs<R1>(func);
}
}
}
</code></pre>
<p>The problem is here somewhere I think but I can't find it... When I try to compile it gives me this:</p>
<pre><code>1>main.obj : error LNK2019: unresolved external symbol "public: void __cdecl WindowMain::SetButtonFunction_NoArgs<int>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int (__cdecl*)(void))" (??$SetButtonFunction_NoArgs@H@WindowMain@@QEAAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@P6AHXZ@Z) referenced in function "void __cdecl Create(void)" (?Create@@YAXXZ)
</code></pre>
<p>Thanks for help!</p>
| 0debug |
How to permanently set GOPATH environmental variable - Ubuntu : I set ```GOPATH``` as an environment variable on my **Ubuntu** VM as the following: ```export GOPATH="/go"``` and it works fine.
The problem is, after I reboot my machine ```GOPATH``` is no longer an environment variable.
Why is that and how can I set it permanently? | 0debug |
static void omap2_inth_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque;
int offset = addr;
int bank_no, line_no;
struct omap_intr_handler_bank_s *bank = NULL;
if ((offset & 0xf80) == 0x80) {
bank_no = (offset & 0x60) >> 5;
if (bank_no < s->nbanks) {
offset &= ~0x60;
bank = &s->bank[bank_no];
}
}
switch (offset) {
case 0x10:
s->autoidle &= 4;
s->autoidle |= (value & 1) << 2;
if (value & 2)
omap_inth_reset(&s->busdev.qdev);
case 0x48:
s->mask = (value & 4) ? 0 : ~0;
if (value & 2) {
qemu_set_irq(s->parent_intr[1], 0);
s->new_agr[1] = ~0;
omap_inth_update(s, 1);
}
if (value & 1) {
qemu_set_irq(s->parent_intr[0], 0);
s->new_agr[0] = ~0;
omap_inth_update(s, 0);
}
case 0x4c:
if (value & 1)
fprintf(stderr, "%s: protection mode enable attempt\n",
__FUNCTION__);
case 0x50:
s->autoidle &= ~3;
s->autoidle |= value & 3;
case 0x84:
bank->mask = value;
omap_inth_update(s, 0);
omap_inth_update(s, 1);
case 0x88:
bank->mask &= ~value;
omap_inth_update(s, 0);
omap_inth_update(s, 1);
case 0x8c:
bank->mask |= value;
case 0x90:
bank->irqs |= bank->swi |= value;
omap_inth_update(s, 0);
omap_inth_update(s, 1);
case 0x94:
bank->swi &= ~value;
bank->irqs = bank->swi & bank->inputs;
case 0x100 ... 0x300:
bank_no = (offset - 0x100) >> 7;
if (bank_no > s->nbanks)
break;
bank = &s->bank[bank_no];
line_no = (offset & 0x7f) >> 2;
bank->priority[line_no] = (value >> 2) & 0x3f;
bank->fiq &= ~(1 << line_no);
bank->fiq |= (value & 1) << line_no;
case 0x00:
case 0x14:
case 0x40:
case 0x44:
case 0x80:
case 0x98:
case 0x9c:
OMAP_RO_REG(addr);
}
} | 1threat |
ArrayList or Hashmap in Java Text Files : <p>I'm wondering which to use to write my text file's record into it, ArrayList or Hashmap.</p>
<p>Records in my text file looks like this:</p>
<pre><code>1,Alice,34
2,James,12
3,Jim,21
</code></pre>
<p>I'll be doing adding, deleting, editing, searching in future. Which on should I use to store my data in?</p>
| 0debug |
Please help making me do exceptions with random numbers : I've made this code for practicing and I want to make a list that keeps every numbers that this code wrote before so I dont want to get duplicates.
Sorry for my english
It's just guessing random numbers and I don't want it to guess the number that it already guessed before.
Just to be clear I want to make it as a list
int password = 432678;
int valt = 999999;
for (int i = 0; i < valt; i++)
{
int[] test2 = new int[valt];
Random randNum = new Random();
for (int j = 0; j < test2.Length; j++)
{
test2[i] = randNum.Next(1, valt);
Console.WriteLine("CURRENT: " + test2[i]);
if (test2[i] == password)
{
goto Back;
}
}
}
Back:
Console.WriteLine("password: "+ password);
Console.ReadLine(); | 0debug |
SyntaxError when calling an async static function : <p>I'm playing a bit with async/await of Node 8.3.0 and I have some issue with static function. </p>
<p><em>MyClass.js</em></p>
<pre><code>class MyClass {
static async getSmthg() {
return true;
}
}
module.exports = MyClass
</code></pre>
<p><em>index.js</em></p>
<pre><code>try {
const result = await MyClass.getSmthg();
} catch(e) {}
</code></pre>
<p>With this code I've got an <code>SyntaxError: Unexpected token</code> on <code>MyClass</code>.
Why is that? Can't use a static function with <code>await</code> or have I made a mistake?</p>
<p>Thank you</p>
| 0debug |
How do I save a text file into an array? : <p>This is how I print out the text file</p>
<pre><code>FILE *file;
char array[200];
file = fopen("test.txt", "r");
fread(array,1, 200, file);
printf("\n%s", array);
fclose(file);
</code></pre>
<p>Instead I want to save the text file rows to an array so i can print out the text file with the array.</p>
<p>I can only use those fopen,fprintf,fwrite,fscanf,fread,fseek,fclose. Not fget.</p>
<p>How do i save the text file lines to an array?</p>
| 0debug |
How to put data from a text file into a form input value using perl : helpers, i have a big problem here and i have tried but it seems not to comply with what i want.
I have a text file that shows a list of all the currency exchanges rates that i want to use with the update of all my currency's values. The list has a lot of white space so i wanted to create a program that will execute this.
But i need to first correct all the white spaces by the form input value. I have already got the first line of the text file content and i need this line to be inserted in the value of the input form.
Here is my code, so far.-
#!/usr/local/bin/perl
use strict;
use warnings;
use CGI qw(:standard);
#use Data::Dumper;
use CGI;
my $q = CGI->new;
my %data;
$data{name} = $q->param('name');
print header;
my $file = '/admin/currencyX.txt';
open my $info, $file or die "Could not open $file: $!";
while( my $line = <$info>) {
print $line,"<br>";
last if $. == 1;
}
print start_html('A Simple Example'),
h1('A Simple Example'),
start_form,
"What's your value? <br>",textfield(-name =>'name', -class =>'nm', -value =>'$line'),
p,
submit(-value => 'Add', -name => 'ed'),
end_form,
hr;
if ($ENV{'REQUEST_METHOD'} eq "POST"){
#validate form here
if ($data{name} eq '') {
print "Please provide the input";
exit;
}
#print "response " . Dumper \%data;
}
if (param()) {
print
"Your name is",em(param('name')),
hr;
}
print end_html;
The text file has a similar values like :-
AFN Afghan Afghani 73.0556951371 0.0136881868
ALL Albanian Lek 108.3423252926 0.0092300031
DZD Algerian Dinar 117.9799583224 0.0084760159
AOA Angolan Kwanza 249.2606313396 0.0040118650
ARS Argentine Peso 28.2508833695 0.0353971232
AMD Armenian Dram 482.0941933740 0.0020742834
I need a correction to make this work fine. | 0debug |
void boot_sector_test(void)
{
uint8_t signature_low;
uint8_t signature_high;
uint16_t signature;
int i;
#define TEST_DELAY (1 * G_USEC_PER_SEC / 10)
#define TEST_CYCLES MAX((90 * G_USEC_PER_SEC / TEST_DELAY), 1)
for (i = 0; i < TEST_CYCLES; ++i) {
signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET);
signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
signature = (signature_high << 8) | signature_low;
if (signature == SIGNATURE) {
break;
}
g_usleep(TEST_DELAY);
}
g_assert_cmphex(signature, ==, SIGNATURE);
}
| 1threat |
System Linq Enumerable error while using intersect : <p>I have 3 lists and I'm trying to display their common items in a text box, and while I am implementing the method</p>
<pre><code>var result = l1.Intersect(l2);
textBox1.Text = "";
textBox1.Text = result.ToString();
</code></pre>
<p>while l1 is my first list and l2 is my second list
I get the error:</p>
<blockquote>
<p>System.Linq.Enumerable+d__70`1[System.String]</p>
</blockquote>
<p>any help would be appreciated.</p>
| 0debug |
static inline void gen_op_eval_fbne(TCGv dst, TCGv src,
unsigned int fcc_offset)
{
gen_mov_reg_FCC0(dst, src, fcc_offset);
gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset);
tcg_gen_or_tl(dst, dst, cpu_tmp0);
}
| 1threat |
How to write a string and see if it is an expression? : <p>I am solving now an algorithmic problem using recursion. So what you need to find out in this problem is that if the string you inputed is an expression. So for example you have string "256+300-500" - this is an expression. So an expression is a string that contains numbers and the signes "+" and "-". The signs + and - cant stay one near eachother and also there cant be to + or 2 - near eachother. So "256++300" and "256+-600-500" is not an expression. Also if the number contains a letter in it then it is not an expression "54e2". So please help me make this program. I have done the part which sees if the number string is a number.</p>
<pre><code>#include <iostream>
#include <cmath>
#include<string>
using namespace std;
int cif(char c)
{
if(isdigit(c))return 1;
else return 0;
}
int num (string s)
{
int z=s.length();
if(z==1) return cif(s[0]);
else
{
char c =s[0];
s=s.substr(1);
if(cif(c) && num(s))return 1; else return 0;
}
}
int main()
{
cout << num("2353Y3554");
return 0;
}
</code></pre>
<p>The output of this program is 0 becase it is not a number, if it was the output would have been 1. Please help me make the program that I need continueing with this one, please.</p>
| 0debug |
static void piix4_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->no_hotplug = 1;
k->init = piix4_initfn;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->device_id = PCI_DEVICE_ID_INTEL_82371AB_0;
k->class_id = PCI_CLASS_BRIDGE_ISA;
dc->desc = "ISA bridge";
dc->no_user = 1;
dc->vmsd = &vmstate_piix4;
}
| 1threat |
PHP UPDATE ORDER BY DATE ADDED not working : function post_data($update_data){
$session_user_id = $_SESSION ['user_id'];
$user_data = user_data($session_user_id, 'username', 'email');
$email= $user_data['email'];
$update= array();
array_walk($update_data, 'array_sanitize');
foreach ($update_data as $field => $data) {
$update[] = '`'. $field . '` =\''.$data .'\'';
}
mysql_query("UPDATE `user_post` SET " . implode(', ', $update) . " WHERE `email` = '$email' ORDER BY date_added DESC ");
}
Hi, the function above update a mysql table, please how do i make sure that when the code is executed, it is displayed in the order of last inserted.
This is the code that fetch the values from the table;
$query = mysql_query("SELECT * FROM user_post WHERE `username` = '$get_user' ORDER BY date_added DESC LIMIT 3 ");
$newsCount = @mysql_num_rows($query); // count the output amount
if ($newsCount > 0) {
while($row = mysql_fetch_assoc($query)){
$id = $row["id"];
$username = $row["username"];
$body = $row["body"];
$profile_pix = $row["profile_pix"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
Thanks. | 0debug |
Ruby: syntax error, unexpected end-of-input, expecting keyword_end : <p>I am working on some simple ruby exercises and cannot figure out why I am getting the "syntax error, unexpected end-of-input, expecting keyword_end". I keep running over my code and don't see what is wrong, although I am new to ruby.</p>
<pre><code>def SimpleSymbols(str)
spec_char = "+="
alpha = "abcdefghijklmnopqrstuvwxyz"
str.each_char do |i|
if spec_char.include? i
next
else alpha.include? i
if spec_char.include? str[str.index(i) + 1] && if spec_char.include? str[str.index(i) - 1]
next
else
return false
end
end
end
return true
end
SimpleSymbols(STDIN.gets.chomp)
</code></pre>
| 0debug |
How can I use function with parameters in stored procedure sql-server : I need use dbo.function(@nb int) in stored procedure sql-server but I cant get the good result (table is empty):
CREATE PROCEDURE dbo.procedure (@var int) <br>
AS<br>
BEGIN<br>
DECLARE @Qry varchar(Max)<br>
SET <br>
'SELECT * FROM dbo.function(CONVERT(int,' + @var + '))'<br>
EXEC(@Qry)<br>
END<br>
...<br>
Thank you for help | 0debug |
How to use companion objects on xml layout? : <p>I am trying to use a companion object property inside the layout but the compiler doesn't recognise it.</p>
<p><strong>Kotlin Class</strong></p>
<pre><code>class MyClass {
companion object {
val SomeProperty = "hey"
}
}
</code></pre>
<p><strong>XML Layout</strong></p>
<pre><code><layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fancy="http://schemas.android.com/tools">
<data>
<import type="package.MyClass"/>
</data>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@{MyClass.Companion.SomeProperty}"/>
</layout>
</code></pre>
<p>And I got this error:</p>
<pre><code>e: java.lang.IllegalStateException: failed to analyze: android.databinding.tool.util.LoggedErrorException: Found data binding errors.
****/ data binding error ****msg:Could not find accessor package.MyClass.Companion.SomeProperty file:/path/to/my/layout.xml loc:21:67 - 21:103 ****\ data binding error ****
at org.jetbrains.kotlin.analyzer.AnalysisResult.throwIfError(AnalysisResult.kt:57)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.kt:138)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:154)
...
Caused by: android.databinding.tool.util.LoggedErrorException: Found data binding errors.
****/ data binding error ****msg:Could not find accessor package.MyClass.Companion.SomeProperty file:/path/to/my/layout.xml loc:21:67 - 21:103 ****\ data binding error ****
at android.databinding.tool.processing.Scope.assertNoError(Scope.java:112)
at android.databinding.annotationprocessor.ProcessDataBinding.doProcess(ProcessDataBinding.java:101)
at android.databinding.annotationprocessor.ProcessDataBinding.process(ProcessDataBinding.java:65)
...
</code></pre>
<p>I've tried to use <code>companion</code> instead of <code>Companion</code>, but no luck.</p>
<p>Is it possible to use companion objects on xml layout with databinding? How can I proceed? Thanks in advance for any help :)</p>
| 0debug |
i am intrested in accessing the uibutton method from external method but i getting lot of errors :
below is my code , i have 9 buttons in my view whose background image is to be changed.. please help me out. thanks in advance....
import UIKit
class ViewController: UIViewController {
let alerts = UIAlertController(title: "Hi", message: "Hello", preferredStyle: UIAlertControllerStyle.alert)
let action1 = UIAlertAction(title: "Yes", style: UIAlertActionStyle.default) { (<#UIAlertAction#>) in
for i in 0..<9
{
let newButton = self.view.viewWithTag(i) as! UIButton
newButton.setBackgroundImage(UIImage.init(named: ""), for: .normal)
}
}
@IBAction func buttonPressed(_ sender: UIButton)
{
sender.setBackgroundImage(UIImage.init(named: "cross.png"), for:.normal)
}
}
| 0debug |
static int tgq_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt){
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
const uint8_t *buf_start = buf;
const uint8_t *buf_end = buf + buf_size;
TgqContext *s = avctx->priv_data;
int x,y;
int big_endian = AV_RL32(&buf[4]) > 0x000FFFFF;
buf += 8;
if(8>buf_end-buf) {
av_log(avctx, AV_LOG_WARNING, "truncated header\n");
return -1;
}
s->width = big_endian ? AV_RB16(&buf[0]) : AV_RL16(&buf[0]);
s->height = big_endian ? AV_RB16(&buf[2]) : AV_RL16(&buf[2]);
if (s->avctx->width!=s->width || s->avctx->height!=s->height) {
avcodec_set_dimensions(s->avctx, s->width, s->height);
if (s->frame.data[0])
avctx->release_buffer(avctx, &s->frame);
}
tgq_calculate_qtable(s, buf[4]);
buf += 8;
if (!s->frame.data[0]) {
s->frame.key_frame = 1;
s->frame.pict_type = AV_PICTURE_TYPE_I;
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID;
if (avctx->get_buffer(avctx, &s->frame)) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
}
for (y=0; y<(avctx->height+15)/16; y++)
for (x=0; x<(avctx->width+15)/16; x++)
tgq_decode_mb(s, y, x, &buf, buf_end);
*data_size = sizeof(AVFrame);
*(AVFrame*)data = s->frame;
return buf-buf_start;
}
| 1threat |
Xamarin.IOS Error - Can not resolve reference: C:/Program Files (x86)/../Xamarin.iOS/v1.0/Facades/System.Private.CoreLib.InteropServices.dll : <p>I working on Cross-platform PCL Xamarin Forms (Android,IOS) Project.</p>
<p>I am using Visual Studio 2015 and Window 10 OS to make xamarin project. I have installed Xamarin studio in MAC PC to run IOS project.</p>
<p>My IOS and android project was successfully running but when I update the Xamarin studio in MAC PC it started giving error in ios project:</p>
<p><strong>Can not resolve reference: C:/Program Files (x86)/Reference Assemblies/Microsoft/Framework/Xamarin.iOS/v1.0/Facades/System.Private.CoreLib.InteropServices.dll</strong> </p>
<p>Please suggest me what to do to solve this error.</p>
<p>Thanks in advance</p>
| 0debug |
How do you read a password protected excel file into r? : <p>How do you read a password protected excel file into r? </p>
<p>I have tried excel.link but its not available for R version 3.2.3 (My version)</p>
<p>I also tried RDCOMClient but it is also not available for R version 3.2.3</p>
| 0debug |
Best way to Programatically write HTML : <p>What would be the best way to go about programatically writing many lines of HTML in the following format:</p>
<pre><code><div class="grid-item"> <img src="gifs/image-GLITCH.gif" alt="image-GLITCH"/> </div>
<div class="grid-item"> <img src="gifs/image.gif"
alt="image"/> </div>
<div class="grid-item"> <img src="gifs/image-GLITCH.gif"
alt="image-GLITCH"/> </div>
</code></pre>
<p>The end result is a grid of gifs where the center column contains a normal image, while the left and right columns contain "GLITCH" versions of the image.</p>
<p>Desired end result: many many rows of the following:
<a href="https://i.stack.imgur.com/nG08z.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/nG08z.jpg</a></p>
<p>I've thought about using php like:</p>
<pre><code>$images = glob("gifs/*.gif}");
foreach($images as $image) {
echo <div class="grid-item"> <img src=$image alt=""/> </div>
}
</code></pre>
<p>Please note that the above is not the exact php I would use, I don't know how to exclude search strings with glob (I believe you can't do that). But this question is meant to ask:</p>
<p>"What is the best way to programatically write html in order to create a grid of images like that contained in the attached image." [i.e this question is not about the actual code to write, but instead what method of writing code should be used: javascript? php?]</p>
| 0debug |
Chartjs v2 - format tooltip for multiple data sets (bar and line) : <p>Reading up a lot on how to format the tooltip in ChartJS v2.x utilizing the tooltip callback. I've had success thus far, but find that I'm unable to define two separate formats for the two data sets I have.</p>
<p>As a bit more context, I have a line chart overlayed on top of a bar chart:</p>
<ul>
<li>My bar data is numerical (in the millions, and needs to be rounded and truncated). </li>
<li>Example: <b>22345343</b> needs to be shown as <b>22M</b> in the tooltip</li>
</ul>
<hr>
<ul>
<li>My line data is a currency</li>
<li>Example: <b>146.36534</b> needs to shown as <b>$146.37</b> in the tooptip</li>
</ul>
<hr>
<p>Here's my short WIP code thus far. This formats the tooltip to round and include the $ sign. How can I expand this so that I can separately format my bar data correctly in the tooltip?</p>
<hr>
<pre><code>tooltips: {
mode: 'index',
intersect: false,
callbacks: {
label: function(tooltipItem, data) {
return "$" + Number(tooltipItem.yLabel).toFixed(2).replace(/./g, function(c, i, a) {
return i > 0 && c !== "." && (a.length - i) % 3 === 0 ? "," + c : c;
});
}
}
}
</code></pre>
| 0debug |
static int piix3_post_load(void *opaque, int version_id)
{
PIIX3State *piix3 = opaque;
int pirq;
piix3->pic_levels = 0;
for (pirq = 0; pirq < PIIX_NUM_PIRQS; pirq++) {
piix3_set_irq_level_internal(piix3, pirq,
pci_bus_get_irq_level(piix3->dev.bus, pirq));
}
return 0;
}
| 1threat |
include common headers and footers django : I am working with Django templates, most of the templates have common header and footer like CSS, scripts etc,
so instead of writing them in every template, how can I attach templates with common header and footer files. | 0debug |
Select dropdown option redirecting on clicking on button : <p>I had created a sample drop down list, below is the code.</p>
<pre><code><select id="select-id">
<option value="" selected="">Pick a E-commerce</option>
<option value="">Amazon</option>
<option value="">Flipkart</option>
<option value="">Snapdeal</option>
</select>
<button>GO</button>
</code></pre>
<p>After selecting the dropdown item and clicking on GO button i want to redirect the page to respective sites like, <a href="https://www.amazon.in/" rel="nofollow noreferrer">https://www.amazon.in/</a> ,<a href="https://www.flipkart.com/" rel="nofollow noreferrer">https://www.flipkart.com/</a> and <a href="https://www.snapdeal.com/" rel="nofollow noreferrer">https://www.snapdeal.com/</a> respectively.</p>
<p>Kindly help me how can i do this</p>
| 0debug |
How using inline if statement inside bracket : <p>I want using inline if statement in angular2 template like this?</p>
<pre><code><select [(ngModel)]="value" class="form-control" (blur)="onBlur()">
<option *ngFor="let item of items" [ngValue]="item">{{item.name?item.name:item}}</option>
</select>
</code></pre>
<p>how to make <code>{{item.name?item.name:item}}</code> posible using inline if statement?</p>
| 0debug |
how to get all videos duration before or without playing the video using jquery or javaScript : Hello I have problem in my code to getting duration of all videos. error showing me undefined below my code please help me anyone for that.
$("video").each(function(){
var duration = $(this).attr('duration');
alert(duration);
});
its giving me undefined alert please tell me where i doing wrong i want all videos duration before playing video Thanks hopes help | 0debug |
Adding Marker to Google Maps in google-map-react : <p>I am using the <a href="https://github.com/istarkov/google-map-react" rel="noreferrer"><code>google-map-react</code></a> NPM package to create a Google Map and several markers.</p>
<p><strong>Question:</strong> How can we add the default Google Maps markers to the map?</p>
<p><a href="https://github.com/istarkov/google-map-react/issues/173" rel="noreferrer">From this Github issue</a>, it seems that we need to access the internal Google Maps API using the <a href="https://github.com/istarkov/google-map-react#ongoogleapiloaded-func" rel="noreferrer">onGoogleApiLoaded</a> function. </p>
<p>Referring to <a href="https://developers.google.com/maps/documentation/javascript/examples/marker-simple" rel="noreferrer">an example from the Google Maps JS API docs</a>, we can use the following code to render the marker, but how do we define the references to <code>map</code>?</p>
<pre><code>var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: 'Hello World!'
});
</code></pre>
<p><strong>Current Code:</strong></p>
<pre><code>renderMarkers() {
...
}
render() {
return (
<div style={{'width':800,'height':800}}>
<GoogleMap
bootstrapURLKeys={{key: settings.googleMapApiKey}}
defaultZoom={13}
defaultCenter={{
lat: this.props.user.profile.location.coordinates[1],
lng: this.props.user.profile.location.coordinates[0]
}}
onGoogleApiLoaded={({map, maps}) => this.renderMarkers()}
yesIWantToUseGoogleMapApiInternals
>
</GoogleMap>
</div>
);
}
</code></pre>
| 0debug |
Python mock call_args_list unpacking tuples for assertion on arguments : <p>I'm having some trouble dealing with the nested tuple which <code>Mock.call_args_list</code> returns.</p>
<pre><code>def test_foo(self):
def foo(fn):
fn('PASS and some other stuff')
f = Mock()
foo(f)
foo(f)
foo(f)
for call in f.call_args_list:
for args in call:
for arg in args:
self.assertTrue(arg.startswith('PASS'))
</code></pre>
<p>I would like to know if there is a better way to unpack that call_args_list on the mock object in order to make my assertion. This loop works, but it feels like there must be a more straight forward way.</p>
| 0debug |
Creating an API endpoint in a .NET Windows Service : <p>I have an ASP.NET project and a .NET Windows service running on the same machine, and I want them to communicate (currently only ASP.NET => Service one way). </p>
<p>The most convenient way to do this (IMO) would be a REST / other API endpoint in the service which the ASP.NET project would call (since ASP.NET works with APIs anyway and they can be protected etc.). The problem is that I can't seem to find a way to do this in a Windows service. Is there a native method / library to support this?</p>
<p>Using .NET Framework 4.5.2 in both projects.</p>
<p>Thanks.</p>
| 0debug |
Is the amount of RAM used in dot-net projects more than other projects? : <p>Is the amount of <strong>RAM</strong> used in <strong>.net-Core</strong> projects more than other projects</p>
| 0debug |
Python max() not working? Not actually giving me the maximum : <p>Having a problem recently when using the max() function in python. Here is my code:</p>
<pre><code>x = ["AJK","exit","Down","World","HappyASD"]
max(x)
</code></pre>
<p>But instead of getting "HappyASD", I get "exit".
Any help?</p>
| 0debug |
How to Make Ansible variable mandatory : <p>I'm looking for the way how to make Ansible to analyze playbooks for required and mandatory variables before run playbook's execution like:</p>
<pre><code>- name: create remote app directory hierarchy
file:
path: "/opt/{{ app_name | required }}/"
state: directory
owner: "{{ app_user | required }}"
group: "{{ app_user_group | required }}"
...
</code></pre>
<p>and rise error message if variable is undefined, like:</p>
<pre><code>please set "app_name" variable before run (file XXX/main.yml:99)
</code></pre>
| 0debug |
How do I print out this string from within my class? : <p>I would like to know how to make it so I can print the string variables from my class. I would also like to know if I am using the correct way to to write out my array.</p>
<pre><code>#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
class ColorPicker {
public:
string Color[7][10] = { "red" , "orange", "yellow", "green", "blue", "indigo", "violet" };
};
int main()
{
cout << ColorPicker << endl;
system("pause");
return 0;
}
</code></pre>
| 0debug |
window.location.href = 'http://attack.com?user=' + user_input; | 1threat |
Adding text to my div, shifts my div down. : [Image][1]
[1]: https://i.stack.imgur.com/sa9xN.png
I tried to do vertical-align: top; on my div id, and nothing will move every thing stays the same. I tried to add position absolute and that wont work either. Am I missing something else? | 0debug |
How can i create a RegEx for Strings with Tabulator? : I have an input string/text like this:
<span id="salutation">
Mister
</span><div class="c"></div>
With which pattern can i get the string Mister?
This pattern:
string pattern = "<span id=\"salutation\"> (.*) </span>";
have no success for me.
Greets | 0debug |
dplyr: transpose a list (length-n) in a cell to n-rows : <p>I have this style of data:</p>
<pre><code>df=tibble(a=letters[23:25],b='k',c='m',d=list(runif(4)))
df
# A tibble: 3 x 4
a b c d
<chr> <chr> <chr> <list>
1 w k m <dbl [4]>
2 x k m <dbl [4]>
3 y k m <dbl [4]>
</code></pre>
<p>I'd like to have each value in the list <code>d</code> be an entry in a column named <code>m</code>, which is the contents of <code>c</code>. Specifically:</p>
<pre><code># A tibble: 3 x 12
a b m
<chr> <chr> <dbl>
1 w k 0.57
2 x k 0.45
3 y k 0.34
</code></pre>
<p>If possible I'd like to use only <code>dplyr</code>, or at least something from the <code>tidyverse</code></p>
| 0debug |
Passive event listener on JQuery : <p>Passive event listeners are a new feature in the DOM spec that enable developers to improve scroll performance, with a simple javascript piece of code like this:</p>
<pre><code>document.addEventListener('touchstart', handler, {passive: true});
</code></pre>
<p>Is there a way to propagate this feature on jQuery function .on() or the only solution is to migrate all jQuery .on() to addEventListener?</p>
| 0debug |
what is the best way to store Numbers of a Bingo Card in database table : <p>I wanna create a web-based bingo game using MVC and EF, I want to store 24 numbers for each card in the database table as a record,I'm not sure how to create my Bingo cards table,one way that comes to my mind is design a table with 24 integer field for each cell's number this way when I fetch the record in business logic I can't traverse the numbers because they are in the separate fields(actually I can but I think this way is not the right way to do)the other way is I concatenate all numbers together and separate it with comma and store it as a string so when I fetch the record I can split the string of comma and have all numbers in an array or something
so what is the best solution for this situation ?
how can I design my table for storing numbers of a bingo card ?</p>
| 0debug |
decode_lpc(WmallDecodeCtx *s)
{
int ch, i, cbits;
s->lpc_order = get_bits(&s->gb, 5) + 1;
s->lpc_scaling = get_bits(&s->gb, 4);
s->lpc_intbits = get_bits(&s->gb, 3) + 1;
cbits = s->lpc_scaling + s->lpc_intbits;
for(ch = 0; ch < s->num_channels; ch++) {
for(i = 0; i < s->lpc_order; i++) {
s->lpc_coefs[ch][i] = get_sbits(&s->gb, cbits);
}
}
}
| 1threat |
int ff_h264_decode_extradata(H264Context *h, const uint8_t *buf, int size)
{
AVCodecContext *avctx = h->s.avctx;
if (!buf || size <= 0)
return -1;
if (buf[0] == 1) {
int i, cnt, nalsize;
const unsigned char *p = buf;
h->is_avc = 1;
if (size < 7) {
av_log(avctx, AV_LOG_ERROR, "avcC too short\n");
return -1;
}
h->nal_length_size = 2;
cnt = *(p + 5) & 0x1f;
p += 6;
for (i = 0; i < cnt; i++) {
nalsize = AV_RB16(p) + 2;
if(nalsize > size - (p-buf))
return -1;
if (decode_nal_units(h, p, nalsize) < 0) {
av_log(avctx, AV_LOG_ERROR,
"Decoding sps %d from avcC failed\n", i);
return -1;
}
p += nalsize;
}
cnt = *(p++);
for (i = 0; i < cnt; i++) {
nalsize = AV_RB16(p) + 2;
if(nalsize > size - (p-buf))
return -1;
if (decode_nal_units(h, p, nalsize) < 0) {
av_log(avctx, AV_LOG_ERROR,
"Decoding pps %d from avcC failed\n", i);
return -1;
}
p += nalsize;
}
h->nal_length_size = (buf[4] & 0x03) + 1;
} else {
h->is_avc = 0;
if (decode_nal_units(h, buf, size) < 0)
return -1;
}
return size;
}
| 1threat |
static void print_final_stats(int64_t total_size)
{
uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0;
uint64_t subtitle_size = 0;
uint64_t data_size = 0;
float percent = -1.0;
int i, j;
for (i = 0; i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
switch (ost->st->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO: video_size += ost->data_size; break;
case AVMEDIA_TYPE_AUDIO: audio_size += ost->data_size; break;
case AVMEDIA_TYPE_SUBTITLE: subtitle_size += ost->data_size; break;
default: other_size += ost->data_size; break;
}
extra_size += ost->st->codec->extradata_size;
data_size += ost->data_size;
}
if (data_size && total_size >= data_size)
percent = 100.0 * (total_size - data_size) / data_size;
av_log(NULL, AV_LOG_INFO, "\n");
av_log(NULL, AV_LOG_INFO, "video:%1.0fkB audio:%1.0fkB subtitle:%1.0fkB other streams:%1.0fkB global headers:%1.0fkB muxing overhead: ",
video_size / 1024.0,
audio_size / 1024.0,
subtitle_size / 1024.0,
other_size / 1024.0,
extra_size / 1024.0);
if (percent >= 0.0)
av_log(NULL, AV_LOG_INFO, "%f%%", percent);
else
av_log(NULL, AV_LOG_INFO, "unknown");
av_log(NULL, AV_LOG_INFO, "\n");
for (i = 0; i < nb_input_files; i++) {
InputFile *f = input_files[i];
uint64_t total_packets = 0, total_size = 0;
av_log(NULL, AV_LOG_VERBOSE, "Input file #%d (%s):\n",
i, f->ctx->filename);
for (j = 0; j < f->nb_streams; j++) {
InputStream *ist = input_streams[f->ist_index + j];
enum AVMediaType type = ist->st->codec->codec_type;
total_size += ist->data_size;
total_packets += ist->nb_packets;
av_log(NULL, AV_LOG_VERBOSE, " Input stream #%d:%d (%s): ",
i, j, media_type_string(type));
av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets read (%"PRIu64" bytes); ",
ist->nb_packets, ist->data_size);
if (ist->decoding_needed) {
av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames decoded",
ist->frames_decoded);
if (type == AVMEDIA_TYPE_AUDIO)
av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ist->samples_decoded);
av_log(NULL, AV_LOG_VERBOSE, "; ");
}
av_log(NULL, AV_LOG_VERBOSE, "\n");
}
av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) demuxed\n",
total_packets, total_size);
}
for (i = 0; i < nb_output_files; i++) {
OutputFile *of = output_files[i];
uint64_t total_packets = 0, total_size = 0;
av_log(NULL, AV_LOG_VERBOSE, "Output file #%d (%s):\n",
i, of->ctx->filename);
for (j = 0; j < of->ctx->nb_streams; j++) {
OutputStream *ost = output_streams[of->ost_index + j];
enum AVMediaType type = ost->st->codec->codec_type;
total_size += ost->data_size;
total_packets += ost->packets_written;
av_log(NULL, AV_LOG_VERBOSE, " Output stream #%d:%d (%s): ",
i, j, media_type_string(type));
if (ost->encoding_needed) {
av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames encoded",
ost->frames_encoded);
if (type == AVMEDIA_TYPE_AUDIO)
av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ost->samples_encoded);
av_log(NULL, AV_LOG_VERBOSE, "; ");
}
av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets muxed (%"PRIu64" bytes); ",
ost->packets_written, ost->data_size);
av_log(NULL, AV_LOG_VERBOSE, "\n");
}
av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) muxed\n",
total_packets, total_size);
}
if(video_size + data_size + audio_size + subtitle_size + extra_size == 0){
av_log(NULL, AV_LOG_WARNING, "Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)\n");
}
}
| 1threat |
Adding an Object to an Arraylist results in nullpointerexception : <p>I cannot add any (or maybe just the first?) Objects to my Arraylist</p>
<p>A Bikestore is an Object which contains a name and an Arraylist of all it's bikes</p>
<p>bikes have 3 different attributes (2 Strings, 1 double)</p>
<p>Bikes are added to the Store within an "addbiketocollection()" method and within this method I use the .add function.</p>
<pre><code> public class Bikes
String brand ;
String color;
double price;
Bike(String brand, String color, double price){
this.brand = brand;
this.color = color;
this.price = price;
}
public class Bikestore {
String name;
ArrayList<Bike> Collection = new ArrayList<>();
Bikestore (String name, ArrayList<Bike> Collection){
this.name = name;
this.Collection = Collection;
}
public void AddBikeToCollection (Bike NewBike) {
Collection.add(NewBike);
}
Mainclass
Bike Bike1 = new Bike ("Cube", "Black", 400);
Bikestore SellingBikes = new Bikestore ("SellingBikes", null);
SellingBikes.AddBikeToCollection(Bike1);
}
</code></pre>
<p>when I try to add bikes to the bikestore I get a nullpointerxception
Exception in thread "main" java.lang.NullPointerException</p>
<p>I have already googled my problem and watched some videos but none of these contained an arraylist with objects.</p>
| 0debug |
How can I change the default compiler of linux mint 18.0 from version 5.3.1 to a version below 4.0? : I need to compile a special program (i.e. configuring, making, and making install processes of nest) by an old version of g++ such as 3.3 or 3.4. however, I don't have such versions in my package manager. I downloaded g++-3.0-3.0.4-7_alpha-deb, but I don't know if it is the true version for linux, or how can I install it and set as the default compiler. I will appreciate if any one informs me of its possible dangers to my linux (as I read in Google).
Quick reply is appreciated. | 0debug |
Eslint AirBNB with 4 spaces for indent : <p>I am configuring eslint and am using the AirBNB style guide.</p>
<p>I want to over-ride the indent (supposed to be 2 spaces) to be 4 spaces. But no matter what I do within my .eslintrc I cannot get this error supressed so that I can use indentation of 4 spaces.</p>
<p>I have the message "Expected indentation of 2 spaces chatacters but found 4. (react/jsx-indent)" everywhere within my code base.</p>
<p>I am using eslint 4.9.0. How can I resolve this? Thanks.</p>
| 0debug |
How can a container be given to a macro in c++? :
#define x.contains(a) x.find(a)!=x.end()
void main(){
vector<int> v = {1,2,3,4};
if(v.contains(2))
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
I have following piece of code where I am using a macro for a checking if element is present in the vector or not. But on compilation it gives following error:
ISO C++11 requires whitespace after the macro name #define x.contains(a) x.find(a)!=x.end()
Please show me a way out.
Thanks. | 0debug |
Which directory is the real location that `brew cask install` use? : <p>Which directory is the real location that <code>brew cask install</code> use?</p>
<p>I want to find the real location of app, not the symlink in <code>/Application</code></p>
| 0debug |
I am getting error as value of java.lang.String cannot be converted to JSONObject : <p>my JSONResponse looks as follows</p>
<p>[["1","somevalue","1234567890","1239876093","some"], ["2","somevalue","1234567890","1234567890","some"]]</p>
<p>and code accessing it is as follows</p>
<pre><code> try{
String[] details = {""};
JSONArray array1 = new JSONArray(response);
JSONArray array = array1.getJSONArray(0);
JSONObject object;
//print(array.length() + "");
for(int i = 0; i < array.length(); i++){
object = array.getJSONObject(i);
details[i] = object.getString("roll") + " " + object.getString("name");
ArrayList<String> list = new ArrayList<>();
list.addAll(Arrays.asList(details));
ArrayAdapter<String> defaulters = new ArrayAdapter<String>(ShowDefaulters.this, android.R.layout.simple_list_item_1, list);
listView.setAdapter(defaulters);
}
}
catch (Exception e){
print(e.getMessage());
}
</code></pre>
| 0debug |
static void rv34_idct_add_c(uint8_t *dst, ptrdiff_t stride, DCTELEM *block){
int temp[16];
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int i;
rv34_row_transform(temp, block);
memset(block, 0, 16*sizeof(DCTELEM));
for(i = 0; i < 4; i++){
const int z0 = 13*(temp[4*0+i] + temp[4*2+i]) + 0x200;
const int z1 = 13*(temp[4*0+i] - temp[4*2+i]) + 0x200;
const int z2 = 7* temp[4*1+i] - 17*temp[4*3+i];
const int z3 = 17* temp[4*1+i] + 7*temp[4*3+i];
dst[0] = cm[ dst[0] + ( (z0 + z3) >> 10 ) ];
dst[1] = cm[ dst[1] + ( (z1 + z2) >> 10 ) ];
dst[2] = cm[ dst[2] + ( (z1 - z2) >> 10 ) ];
dst[3] = cm[ dst[3] + ( (z0 - z3) >> 10 ) ];
dst += stride;
}
}
| 1threat |
void ff_decode_dxt1(const uint8_t *s, uint8_t *dst,
const unsigned int w, const unsigned int h,
const unsigned int stride) {
unsigned int bx, by, qstride = stride/4;
uint32_t *d = (uint32_t *) dst;
for (by=0; by < h/4; by++, d += stride-w)
for (bx=0; bx < w/4; bx++, s+=8, d+=4)
dxt1_decode_pixels(s, d, qstride, 0, 0LL);
}
| 1threat |
static void ps_add_squares_c(INTFLOAT *dst, const INTFLOAT (*src)[2], int n)
{
int i;
for (i = 0; i < n; i++)
dst[i] += AAC_MADD28(src[i][0], src[i][0], src[i][1], src[i][1]);
}
| 1threat |
Why people use `rel="noopener noreferrer"` instead of just `rel="noreferrer"` : <p>I often see following pattern:</p>
<pre><code><a href="<external>" target="_blank" rel="noopener noreferrer"></a>
</code></pre>
<p>But as far as I see, <code>noreferrer</code> implies the effect of <code>noopener</code>. So why is <code>noopener</code> even needed here?</p>
<p><a href="https://html.spec.whatwg.org/multipage/links.html#link-type-noreferrer" rel="noreferrer">https://html.spec.whatwg.org/multipage/links.html#link-type-noreferrer</a></p>
<blockquote>
<p><code><a href="..." rel="noreferrer" target="_blank"></code> has the same behavior as <code><a href="..." rel="noreferrer noopener" target="_blank"></code>.</p>
</blockquote>
<p>Note that <code>noreferrer</code> browser support is strictly wider that one of <code>noopener</code>
<a href="https://caniuse.com/#feat=rel-noreferrer" rel="noreferrer">https://caniuse.com/#feat=rel-noreferrer</a>
<a href="https://caniuse.com/#feat=rel-noopener" rel="noreferrer">https://caniuse.com/#feat=rel-noopener</a></p>
| 0debug |
static void aux_slave_dev_print(Monitor *mon, DeviceState *dev, int indent)
{
AUXBus *bus = AUX_BUS(qdev_get_parent_bus(dev));
AUXSlave *s;
if (aux_bus_is_bridge(bus, dev)) {
return;
}
s = AUX_SLAVE(dev);
monitor_printf(mon, "%*smemory " TARGET_FMT_plx "/" TARGET_FMT_plx "\n",
indent, "",
object_property_get_int(OBJECT(s->mmio), "addr", NULL),
memory_region_size(s->mmio));
}
| 1threat |
What is .build-deps for apk add --virtual command? : <p>What is <code>.build-deps</code> in the following command? I can't find an explanation in the Alpine docs. Is this a file that is predefined? Is see this referenced in many Dockerfiles.</p>
<pre><code>RUN apk add --no-cache --virtual .build-deps \
gcc \
freetype-dev \
musl-dev
RUN pip install --no-cache-dir <packages_that_require_gcc...> \
RUN apk del .build-deps
</code></pre>
| 0debug |
SQL Server and Azure Websites : <p>I am thinking about putting a SQL Server behind my Azure website. Is the sql server also free when using Windows Azure Websites? </p>
| 0debug |
Hello guys, i'm getting this error while submitting a simple form. i honestly don't know what is : Someone could point me where the error this.
package mvc.controller;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import mvc.bean.PollBean;
import mvc.dao.PollDAO;
@WebServlet("/pollControll")
public class PollController extends HttpServlet {
private static final long serialVersionUID = 1L;
private PollDAO pd;
public PollController() {
pd = new PollDAO();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String action = request.getParameter("action");
if (action.equalsIgnoreCase("SelectALL")) {
request.setAttribute("polls", pd.SelectAll());
}
response.getWriter().append("Served at: ").append(request.getContextPath());
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String action = request.getParameter("action");
if (action.equalsIgnoreCase(("insert"))) {
PollDAO pp = new PollDAO();
PollBean p = new PollBean();
int note = Integer.parseInt(request.getParameter("note"));
String email = request.getParameter("email");
p.setNote(note);
p.setEmail(email);
pp.insert(p);
RequestDispatcher direct = request.getRequestDispatcher("/home.jsp");
direct.forward(request, response);
} else if (action.equalsIgnoreCase("ResetALL")) {
PollBean p = new PollBean();
pd.ResetALL(p);
} else if (action.equalsIgnoreCase("Activated")) {
PollBean p = new PollBean();
pd.Activated(p);
RequestDispatcher direct = request.getRequestDispatcher("/PollAdmin.jsp");
direct.forward(request, response);
} else if (action.equalsIgnoreCase("Deactivated")) {
PollBean p = new PollBean();
pd.Deactivated(p);
RequestDispatcher direct = request.getRequestDispatcher("/PollAdmin.jsp");
direct.forward(request, response);
}
doGet(request, response);
}
}
Servlet.service() for servlet [mvc.controller.PollController] in context with path [/Enquete_eduCAPES] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: java.time.temporal.TemporalField
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1858)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1701)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:320)
at org.postgresql.Driver.makeConnection(Driver.java:406)
at org.postgresql.Driver.connect(Driver.java:274)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at mvc.util.ConexaoDAO.getConnection(ConexaoDAO.java:29)
at mvc.dao.PollDAO.insert(PollDAO.java:40)
at mvc.controller.PollController.doPost(PollController.java:60)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
| 0debug |
Mysql query - Count the founded rows on joined table : <p>I have two tables</p>
<p>First one: Offers</p>
<p>id
user_id
user_data</p>
<p>The second one: Orders</p>
<p>id
user_id</p>
<h2>order_data</h2>
<p>Now, the goal is, to get the list of the OFFERS including the count of the orders table, where orders.user_id == offers.user_id</p>
<p>the result must be:</p>
<p>id
user_id
orders_count</p>
<hr>
<p>Thank you in advance!</p>
| 0debug |
static void h264_h_loop_filter_luma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
{
h264_loop_filter_luma_c(pix, 1, stride, alpha, beta, tc0);
}
| 1threat |
Oracle MySQL: Appropriate Join/Connection For This Scenario? : I want to join two tables together which I have done
I also want to join them based on a condition, where a paricular column has a specific value, and I also have done this successfully. I used an inner join and a where clause so far.
However, for this result set, I want to further filter it by selecting ONLY the columns where a particular string appears more than once for a set of columns, eg;
employee_ID and CERTIFICATE
I'd like to group where employee_id has CERTIFICATE count > 2. This is after I have joined the tables together using a where clause.
I am perhaps thinking of using a subquery in my WHERE clause (which is the 3rd line that is also last)
Please helpt his is urgent, thanks! I am using Oracle.
For further clarification, I want to display only employees who have a certificate count greater than 2. By certificate, I am referencing a table with a string 'Certificate' under a column 'Skill'. In other words, select only columns where the string 'Certificate' appears TWICE for a particular employee ID
| 0debug |
Docker nodejs image : I'm pretty new to the whole docker thing,
I would to create a node-js image from scratch
I searched the internet a bit, but all I found was images based on other nodejs images.
I tried adding the node executables and editing the path accordingly, but still no luck. (Worked with java)
Am I missing something?
| 0debug |
Angular 4 Nested *ngFor not working : <p>i am getting data from rest API, 1 Level data is repeating good but Children are not working. Somebody help me please.</p>
<pre><code><div *ngFor="let item of list">
<div class="isolate">
<div class="info-box">
<span class="info-box-text">{{item.Name}}</span>
<div>{{item.Stores.length}}</div>
</div>
<div *ngIf="item.HasChildren">
<div *ngFor="let child of list">
<div class="info-box">
<span class="info-box-text">{{child.Children.Name}}</span>
</div>
</div>
</div>
</div>
</code></pre>
<p></p>
| 0debug |
vmxnet3_init_msix(VMXNET3State *s)
{
PCIDevice *d = PCI_DEVICE(s);
int res = msix_init(d, VMXNET3_MAX_INTRS,
&s->msix_bar,
VMXNET3_MSIX_BAR_IDX, VMXNET3_OFF_MSIX_TABLE,
&s->msix_bar,
VMXNET3_MSIX_BAR_IDX, VMXNET3_OFF_MSIX_PBA(s),
VMXNET3_MSIX_OFFSET(s));
if (0 > res) {
VMW_WRPRN("Failed to initialize MSI-X, error %d", res);
s->msix_used = false;
} else {
if (!vmxnet3_use_msix_vectors(s, VMXNET3_MAX_INTRS)) {
VMW_WRPRN("Failed to use MSI-X vectors, error %d", res);
msix_uninit(d, &s->msix_bar, &s->msix_bar);
s->msix_used = false;
} else {
s->msix_used = true;
}
}
return s->msix_used;
}
| 1threat |
IndexOutOfBoundsException when i write excel document using list of string : <p>i have 2 ArrayList of string and i want to copy their content in an excel document. I am using HSSF class to make this and if i create statically the document it works perfectly, but when i use a for loop to copy arraylist content i get <code>IndexOutOfBoundsException</code> exception</p>
<p>Here the code:</p>
<pre><code>import java.io.FileOutputStream;
import java.util.ArrayList;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
public class createExcel {
public void write(ArrayList<String> FirstList, ArrayList<String> SecondList) {
try {
String filename = "mypath\\file.xlsx" ;
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Report");
for(int i=0; i<FirstList.size()+SecondList.size(); i++) {
HSSFRow row = sheet.createRow((short)i);
row.createCell(0).setCellValue(FirstList.get(i));
row.createCell(1).setCellValue(SecondList.get(i));
}
FileOutputStream fileOut = new FileOutputStream(filename);
workbook.write(fileOut);
fileOut.close();
System.out.println("Your excel file has been generated!");
} catch ( Exception ex ) {
System.out.println(ex);
}
}
}
</code></pre>
<p>Thanks</p>
| 0debug |
Apple Pay iOS in app payments : <p>I am looking at integrating a payment mechanism into an app. </p>
<p>I have used stripe and Apple Pay and can successfully take payments.</p>
<p>My question is do all Apple iPhones support Apple Pay? </p>
<p>Is having just Apple Pay sufficient or do I need another system if Apple Pay is not available on some devices? </p>
<p>What is the best way of approaching this?</p>
| 0debug |
uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size)
{
AVDictionaryEntry *t = NULL;
uint8_t *data = NULL;
*size = 0;
if (!dict)
return NULL;
while ((t = av_dict_get(dict, "", t, AV_DICT_IGNORE_SUFFIX))) {
const int keylen = strlen(t->key);
const int valuelen = strlen(t->value);
const size_t new_size = *size + keylen + 1 + valuelen + 1;
uint8_t *const new_data = av_realloc(data, new_size);
if (!new_data)
goto fail;
data = new_data;
memcpy(data + *size, t->key, keylen + 1);
memcpy(data + *size + keylen + 1, t->value, valuelen + 1);
*size = new_size;
}
return data;
fail:
av_freep(&data);
*size = 0;
return NULL;
}
| 1threat |
Login form witout mysql, changepassword in db.txt plz help me : Hay,
i have update password any users...but not working my code, plz see
function change_pass($user_accounts_file, $username, $oldpass, $newpass) {
if(false === file_exists($user_accounts_file)) {
trigger_error(
sprintf(
'Акаунта $user_accounts_file не съществува на определеното местоположение: %s ',
$user_accounts_file
),
E_USER_ERROR
);
return false;
}
foreach(file($user_accounts_file) as $entry) {
list($entry_key, $entry_username, $entry_password) = array_map('trim', explode('|', $entry));
if($entry_username === $username && $entry_password === $oldpass) {
if ( $entry_username == $username ) {
$entry_key = $entry_key;
$entry_username = $username;
$new_password = $newpass;
return (bool)file_put_contents(
$user_accounts_file,
sprintf(
"%s|%s|%s\r\n",
$entry_key,
$entry_username,
$new_password
),
FILE_APPEND | LOCK_EX
);
} else {
return false;
}
}
}
return false;
}
I think the problem is here. Saves a new user instead of updating his password
return (bool)file_put_contents(
$user_accounts_file,
sprintf(
"%s|%s|%s\r\n",
$entry_key,
$entry_username,
$new_password
),
FILE_APPEND | LOCK_EX
);
db.txt structure
ea55e673b8189b3140a1b2dc67a0fe605ca0e605|admin|admin
xa55de673b81e05ca0e631123131231212312130|moderator|moderator
ea55e673b8189b3140a1b2dc67a0fe605ca0e605|admin|admin123
when changing it should look like this;
ea55e673b8189b3140a1b2dc67a0fe605ca0e605|admin|admin123
xa55de673b81e05ca0e631123131231212312130|moderator|moderator | 0debug |
Async validation with Formik, Yup and React : <p>I want to make async validation with formik and validationschema with yup but i can't find the example or demo.</p>
| 0debug |
vector iterators incompatible when i have collision detection : <p>so i have DEBUG_ERROR("vector iterators incompatible"); whenever i have collision detection between blackHole & planet. but when i have collision detection between anything else like asteroid & planet or blackHole & asteroid, then its work with no problem the code is basically the same but yet with this one i have crash</p>
<pre><code>//Blackhole& Planet Collide
for (vector<Entity*>::iterator it = gameEntities.begin(); it < gameEntities.end(); ++it) // This loop usses an iterator (google c++ iterator) to go through all game entites objects
{
BlackHole* blackHole1 = dynamic_cast<BlackHole*> (*it); // As the iterator is of generic type Entity we need to convert it to a type we can use, Ball. Dynamic cast performs the conversion only if the entity is actually a Ball otherwise it gives back a null pointer
if (blackHole1 != nullptr) // we check if the conversion was successful
{
for (vector<Entity*>::iterator it1 = gameEntities.begin(); it1 < gameEntities.end(); ++it1) // and we iterate on the remaining elements in the container
{
if (it != it1)
{
Planet* planet = dynamic_cast<Planet*> (*it1); // we convert the remaining element
if (planet != nullptr) // check if the conversion happended
{
// collision detection: black hole & planet
if (blackHolePlanetCollision(*blackHole1, *planet))
{
blackHole1->increaseMass(blackHole1->getRadius(), planet->getRadius());
delete *it1;
it1 = gameEntities.erase(it1);
//--it1;
</code></pre>
<p>any idea what is wrong with it? with any other collision this code works</p>
| 0debug |
static inline CopyRet copy_frame(AVCodecContext *avctx,
BC_DTS_PROC_OUT *output,
void *data, int *got_frame)
{
BC_STATUS ret;
BC_DTS_STATUS decoder_status = { 0, };
uint8_t trust_interlaced;
uint8_t interlaced;
CHDContext *priv = avctx->priv_data;
int64_t pkt_pts = AV_NOPTS_VALUE;
uint8_t pic_type = 0;
uint8_t bottom_field = (output->PicInfo.flags & VDEC_FLAG_BOTTOMFIELD) ==
VDEC_FLAG_BOTTOMFIELD;
uint8_t bottom_first = !!(output->PicInfo.flags & VDEC_FLAG_BOTTOM_FIRST);
int width = output->PicInfo.width;
int height = output->PicInfo.height;
int bwidth;
uint8_t *src = output->Ybuff;
int sStride;
uint8_t *dst;
int dStride;
if (output->PicInfo.timeStamp != 0) {
OpaqueList *node = opaque_list_pop(priv, output->PicInfo.timeStamp);
if (node) {
pkt_pts = node->reordered_opaque;
pic_type = node->pic_type;
av_free(node);
} else {
pic_type = PICT_BOTTOM_FIELD;
}
av_log(avctx, AV_LOG_VERBOSE, "output \"pts\": %"PRIu64"\n",
output->PicInfo.timeStamp);
av_log(avctx, AV_LOG_VERBOSE, "output picture type %d\n",
pic_type);
}
ret = DtsGetDriverStatus(priv->dev, &decoder_status);
if (ret != BC_STS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR,
"CrystalHD: GetDriverStatus failed: %u\n", ret);
return RET_ERROR;
}
trust_interlaced = avctx->codec->id != AV_CODEC_ID_H264 ||
!(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) ||
priv->need_second_field ||
(decoder_status.picNumFlags & ~0x40000000) ==
output->PicInfo.picture_number;
if (output->PicInfo.picture_number == priv->last_picture && !priv->need_second_field) {
av_log(avctx, AV_LOG_WARNING,
"Incorrectly guessed progressive frame. Discarding second field\n");
return RET_OK;
}
interlaced = (output->PicInfo.flags & VDEC_FLAG_INTERLACED_SRC) &&
trust_interlaced;
if (!trust_interlaced && (decoder_status.picNumFlags & ~0x40000000) == 0) {
av_log(avctx, AV_LOG_VERBOSE,
"Next picture number unknown. Assuming progressive frame.\n");
}
av_log(avctx, AV_LOG_VERBOSE, "Interlaced state: %d | trust_interlaced %d\n",
interlaced, trust_interlaced);
if (priv->pic->data[0] && !priv->need_second_field)
av_frame_unref(priv->pic);
priv->need_second_field = interlaced && !priv->need_second_field;
if (!priv->pic->data[0]) {
if (ff_get_buffer(avctx, priv->pic, AV_GET_BUFFER_FLAG_REF) < 0)
return RET_ERROR;
}
bwidth = av_image_get_linesize(avctx->pix_fmt, width, 0);
if (priv->is_70012) {
int pStride;
if (width <= 720)
pStride = 720;
else if (width <= 1280)
pStride = 1280;
else pStride = 1920;
sStride = av_image_get_linesize(avctx->pix_fmt, pStride, 0);
} else {
sStride = bwidth;
}
dStride = priv->pic->linesize[0];
dst = priv->pic->data[0];
av_log(priv->avctx, AV_LOG_VERBOSE, "CrystalHD: Copying out frame\n");
if (interlaced) {
int dY = 0;
int sY = 0;
height /= 2;
if (bottom_field) {
av_log(priv->avctx, AV_LOG_VERBOSE, "Interlaced: bottom field\n");
dY = 1;
} else {
av_log(priv->avctx, AV_LOG_VERBOSE, "Interlaced: top field\n");
dY = 0;
}
for (sY = 0; sY < height; dY++, sY++) {
memcpy(&(dst[dY * dStride]), &(src[sY * sStride]), bwidth);
dY++;
}
} else {
av_image_copy_plane(dst, dStride, src, sStride, bwidth, height);
}
priv->pic->interlaced_frame = interlaced;
if (interlaced)
priv->pic->top_field_first = !bottom_first;
priv->pic->pts = pkt_pts;
#if FF_API_PKT_PTS
FF_DISABLE_DEPRECATION_WARNINGS
priv->pic->pkt_pts = pkt_pts;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (!priv->need_second_field) {
*got_frame = 1;
if ((ret = av_frame_ref(data, priv->pic)) < 0) {
return ret;
}
}
if (!interlaced && (output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) &&
(pic_type == PICT_TOP_FIELD || pic_type == PICT_BOTTOM_FIELD)) {
av_log(priv->avctx, AV_LOG_VERBOSE, "Fieldpair from two packets.\n");
return RET_SKIP_NEXT_COPY;
}
return priv->need_second_field &&
(!(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) ||
pic_type == PICT_FRAME) ?
RET_COPY_NEXT_FIELD : RET_OK;
}
| 1threat |
how to delete only 10 digits numbers from a text file which contains array of both alpha numerical and numbers : Let's say i have a text file which contains both alphanumerical values and only numerical values of length 10 digits line by line, like the one shown below.
abcdefgh
0123456789
edf6543jewjew
9876543219
here i want to delete all the lines which contains only those random 10 digit numbers
**how to do this in python 3.x?** | 0debug |
Processing: How to destroy an object once it leaves the screen? : In my code I have a class, `Key()` that can create a key at a random coordinate. When a key is pressed, that key is added to an `ArrayList`. The `ArrayList` is iterated in the `draw()` method, and the key falls at a certain velocity. Multiple keys can be displayed at once. I want to remove a `Key` from the `ArrayList` once it leaves the view of the screen.
I have tried something like `if (key.location.y - textAscent() > height) {keys.remove(key)}` which either causes the program to stop working, or causes a letter to stop moving but remain in view once it reaches the bottom of the screen. Any suggestions?
PFont f;
ArrayList<Key> keys;
void setup() {
fullScreen(1);
f=createFont("Bahnschrift", 300, true);
textFont(f);
keys = new ArrayList();
}
void draw() {
fill(#FF5254);
rect(0, 0, width, height);
for (Key k : keys) {
k.display();
k.fall();
}
}
void keyPressed() {
keys.add(new Key());
}
class Key {
PVector location, velocity;
char k;
color c;
public Key() {
this.c = 0;
this.k=key;
this.location = new PVector(random(width), random(height));
this.velocity = new PVector(0, int(random(1, 11)));
}
void display() {
fill(c);
text(k, location.x, location.y);
}
void fall() {
this.location.add(velocity);
}
}
| 0debug |
Base64 encoded string of the Security Credential, which is encrypted using public key : <p>I am working on an API that requires encryption of security credentials. I have not done any encryption.</p>
<p>Security credentials are generated by encrypting the base64 encoded password with a public key, a X509 certificate.</p>
<p>The algorithm for generating security credentials is as follows:
Write the unencrypted password into a byte array.
Encrypt the array with the public key certificate. Use the RSA algorithm, and use PKCS #1.5 padding (not OAEP), and add the result to the encrypted stream.
Convert the resulting encrypted byte array into a string using base64 encoding. The resulting base64 encoded string is the security credential.</p>
<p>Can anyone help me achieve this in php?</p>
| 0debug |
AWS security group inbound rule. allow lambda function : <p>I run a service on my EC2 instance and I want to setup an inbound rule that only allows my lambda function to access it. The security group allows me to restrict access by a specific IP, but I don't think that lambda functions have a specific IP assigned. Is there a way to do what I want?</p>
| 0debug |
how to make bruteforce without itertools in python : i'm new in python,
i try calculate 3 ** 16(¹[0-f] ² [0-f] ³ [0-f] but not working properly.
this is my code, please help me to corrected my code.
inp = str(input('value len 0-3 digit:'))
hexa = ('0123456789abcdef');
//len(hexa) = 16 digit
//pass = '36f'
pass = inp
for x in range(0, 3 ** len(hexa)):
// range = 0..(3 ^ 16)
if(hexa[x] == pass):
found = hexa[x]
//if result valid
print("pos: %d, pass: %s" % (x, found))
//print position
but i got error "index out of bound",
i need output like this.
000 #first
001
002
...
...
fff #last
how to fix it?
thanks before. ;) | 0debug |
Is there a way to check an email ID and a value next to it in database from frontend without submitting the form? : <p>I have a registration form and I would like to check if the email is already in database (PSQL) without submitting the form. Vanilla javascript or jQuery only please. No PHP</p>
| 0debug |
How does assignment operator work on a 2D character array? : For the below code snippet , I am not getting how can we assign a value to
names[1][2] since it returns the address of the 2nd column in Row 1 ,so how can we assign names[2][1] which returns address of column 1 in Row 2 to names[1][2] ?
I am unable to get how can one column address can be stored in another column address .
what is the significance of the statement :
> names[1][2]=names[2][1] ; // what is it doing
int main()
{
char names[3][20]={"success","gateway","engineers"};
int i;
char *t;
t=names[1][2];
names[1][2]=names[2][1];
names[2][1]=t;
for(i=0;i<=2;i++)
printf("%s ",names[i]);
return 0;
}
| 0debug |
Laravel 5.4 change the subject of markdown mail : <p>I have used <a href="https://laravel.com/docs/5.4/mail#markdown-mailables" rel="noreferrer">markdown mailables</a> which is a new feature in laravel 5.4. I have successfully implemented a mail sender. It seems, the subject of the mail is named as the name of the <code>mailable</code> class. I need to change the subject of the mail and it's hard to find any resources regarding this. </p>
| 0debug |
OpenGL (C Language) : Make the shapes to be moved with keyboard (distortion issue) : <p>Well, we have the following C (GLUT Project) for OpenGL. I use CodeBlocks to compile it (with removed the extra main() function file).
I have based in some examples, sorry if the way I wrote OpenGL is bad. The main thing is to make it work fine.</p>
<p>The result I need is: all the shapes (head, body, hands, legs) of "Mr Robot", to be moved via the keyboard arrow keys. It works as expected but from some points and then, some of the shapes are distorted. I don't know why and how to fix it.</p>
<pre><code> #include <GL/glut.h>
GLuint kefali_x1=5, kefali_y1=30, kefali_x2=15, kefali_y2=30, kefali_x3=15, kefali_y3=40, kefali_x4=5,kefali_y4=40;
GLuint soma_x1=0, soma_y1=10, soma_x2=20, soma_y2=10, soma_x3=20, soma_y3=30, soma_x4=0, soma_y4=30;
GLuint podia_x1=10, podia_y1=10, podia_x2=20, podia_y2=0, podia_x3=10, podia_y3=-5, podia_x4=0, podia_y4=0;
GLuint dexi_xeri_x1=20, dexi_xeri_y1=30, dexi_xeri_x2=30, dexi_xeri_y2=27.5, dexi_xeri_x3=20, dexi_xeri_y3=25;
GLuint aristero_xeri_x1=-10, aristero_xeri_y1=27.5, aristero_xeri_x2=0, aristero_xeri_y2=30, aristero_xeri_x3=0, aristero_xeri_y3=25;
// σύνθετο σχήμα
GLuint listID;
void MrRobot(GLsizei displayListID)
{
glNewList(displayListID,GL_COMPILE);
//Save current colour state
glPushAttrib(GL_CURRENT_BIT);
// σώμα
glColor3f(0.5,0.5,0.5);
glBegin(GL_POLYGON);
glVertex2f(soma_x1,soma_y1);
glVertex2f(soma_x2,soma_y2);
glVertex2f(soma_x3,soma_y3);
glVertex2f(soma_x4,soma_y4);
glEnd();
// κεφάλι
glColor3f(0,0,1);
glBegin(GL_POLYGON);
glVertex2f(kefali_x1,kefali_y1);
glVertex2f(kefali_x2,kefali_y2);
glVertex2f(kefali_x3,kefali_y3);
glVertex2f(kefali_x4,kefali_y4);
glEnd();
// πόδια
glColor3f(1,0,0);
glBegin(GL_TRIANGLE_FAN);
glVertex2f(podia_x1,podia_y1);
glVertex2f(podia_x2,podia_y2);
glVertex2f(podia_x3,podia_y3);
glVertex2f(podia_x4,podia_y4);
glEnd();
// δεξί χέρι
glColor3f(0,1,0);
glBegin(GL_TRIANGLES);
glVertex2f(dexi_xeri_x1,dexi_xeri_y1);
glVertex2f(dexi_xeri_x2,dexi_xeri_y2);
glVertex2f(dexi_xeri_x3,dexi_xeri_y3);
glEnd();
// αριστερό χέρι
glColor3f(0,1,0);
glBegin(GL_TRIANGLES);
glVertex2f(aristero_xeri_x1,aristero_xeri_y1);
glVertex2f(aristero_xeri_x2,aristero_xeri_y2);
glVertex2f(aristero_xeri_x3,aristero_xeri_y3);
glEnd();
//Recall saved colour state
glPopAttrib();
glEndList();
}
void display()
{
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1,0,0);
listID=glGenLists(1);
MrRobot(listID);
//Execute the display list (the modelview matrix will be applied)
glCallList(listID);
glFlush();
}
void keyboard(unsigned char key,int x, int y)
{
printf("\nKeyboard event detected. \nCharacter key: %c\nMouse pointer position: x=%d y=%d",key,x,y);
if (key==GLUT_KEY_UP)
{
kefali_y1++;
kefali_y2++;
kefali_y3++;
kefali_y4++;
soma_y1++;
soma_y2++;
soma_y3++;
soma_y4++;
podia_y1++;
podia_y2++;
podia_y3++;
podia_y4++;
dexi_xeri_y1++;
dexi_xeri_y2++;
dexi_xeri_y3++;
aristero_xeri_y1++;
aristero_xeri_y2++;
aristero_xeri_y3++;
}
if (key==GLUT_KEY_DOWN)
{
kefali_y1--;
kefali_y2--;
kefali_y3--;
kefali_y4--;
soma_y1--;
soma_y2--;
soma_y3--;
soma_y4--;
podia_y1--;
podia_y2--;
podia_y3--;
podia_y4--;
dexi_xeri_y1--;
dexi_xeri_y2--;
dexi_xeri_y3--;
aristero_xeri_y1--;
aristero_xeri_y2--;
aristero_xeri_y3--;
}
if (key==GLUT_KEY_LEFT)
{
kefali_x1--;
kefali_x2--;
kefali_x3--;
kefali_x4--;
soma_x1--;
soma_x2--;
soma_x3--;
soma_x4--;
podia_x1--;
podia_x2--;
podia_x3--;
podia_x4--;
dexi_xeri_x1--;
dexi_xeri_x2--;
dexi_xeri_x3--;
aristero_xeri_x1--;
aristero_xeri_x2--;
aristero_xeri_x3--;
}
if (key==GLUT_KEY_RIGHT)
{
kefali_x1++;
kefali_x2++;
kefali_x3++;
kefali_x4++;
soma_x1++;
soma_x2++;
soma_x3++;
soma_x4++;
podia_x1++;
podia_x2++;
podia_x3++;
podia_x4++;
dexi_xeri_x1++;
dexi_xeri_x2++;
dexi_xeri_x3++;
aristero_xeri_x1++;
aristero_xeri_x2++;
aristero_xeri_x3++;
}
glutPostRedisplay();
}
int main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitWindowPosition(50,50);
glutInitWindowSize(800,600);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutCreateWindow("MrROBOT");
glMatrixMode(GL_MODELVIEW);
gluOrtho2D(-10,50,-10,50);
glScalef(0.4,0.4,0.4);
glutDisplayFunc(display);
glutSpecialFunc(keyboard);
glutMainLoop();
return 0;
}
</code></pre>
| 0debug |
Close Gitlab issue via commit : <p>I spend my day doing this:</p>
<ol>
<li>Read an issue on a Gitlab-powered issue tracker,</li>
<li>Fix the issue,</li>
<li>Commit and push to the same Gitlab-powered Git server,</li>
<li>Mark the issue as closed.</li>
</ol>
<p>To remove the 4th step, how can I close the issue automatically when committing?</p>
| 0debug |
QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id)
{
QemuOpts *opts;
QTAILQ_FOREACH(opts, &list->head, next) {
if (!opts->id) {
if (!id) {
return opts;
}
continue;
}
if (strcmp(opts->id, id) != 0) {
continue;
}
return opts;
}
return NULL;
}
| 1threat |
Difference between AXML and XAML? : <p>I'm new to Visual Studio Xamarin Cross-platform mobile development and I keep on searching about AXML I just can't find any tutorial for designing and applying an MVC approach.</p>
<p>I have a lot of questions regarding this actually. But i'll just leave this 3 here first.</p>
<ol>
<li>What is their difference?</li>
<li>Can xaml designs be applied in axml?</li>
<li>How do I apply my css to axml files?</li>
</ol>
| 0debug |
How to remove more than one elements from list in python at a time? : <p>Let's say i have <code>a=[1,0,1,0,1,1,1,0,0,0,0]</code></p>
<p> I want to remove all the zero's at the same time. can i do that?</p>
| 0debug |
static int decode_frame_header (bit_buffer_t *bitbuf,MpegEncContext *s) {
int frame_size_code;
get_bits (bitbuf, 8);
s->pict_type = get_bits (bitbuf, 2);
if (s->pict_type == 3)
return -1;
if (s->pict_type == SVQ1_FRAME_INTRA) {
if (s->f_code == 0x50 || s->f_code == 0x60) {
get_bits (bitbuf, 16);
}
if ((s->f_code ^ 0x10) >= 0x50) {
skip_bits(bitbuf,8*get_bits (bitbuf, 8));
}
get_bits (bitbuf, 2);
get_bits (bitbuf, 2);
get_bits (bitbuf, 1);
frame_size_code = get_bits (bitbuf, 3);
if (frame_size_code == 7) {
s->width = get_bits (bitbuf, 12);
s->height = get_bits (bitbuf, 12);
if (!s->width || !s->height)
return -1;
} else {
s->width = frame_size_table[frame_size_code].width;
s->height = frame_size_table[frame_size_code].height;
}
}
if (get_bits (bitbuf, 1) == 1) {
get_bits (bitbuf, 1);
get_bits (bitbuf, 1);
if (get_bits (bitbuf, 2) != 0)
return -1;
}
if (get_bits (bitbuf, 1) == 1) {
get_bits (bitbuf, 1);
get_bits (bitbuf, 4);
get_bits (bitbuf, 1);
get_bits (bitbuf, 2);
while (get_bits (bitbuf, 1) == 1) {
get_bits (bitbuf, 8);
}
}
return 0;
}
| 1threat |
How to give canvas an id : <p>How can i give these canvas' in JS/html an id?</p>
<p>I want to make multiple flashing images on a single page and when I do only one image displays as there is no way to know which canvas to display, below is a link to my project.</p>
<p><a href="https://glitch.com/edit/#!/join/4cb25634-5dc4-45b8-8e28-060e6b1a98aa" rel="nofollow noreferrer">My project on glitch</a></p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.