problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
what shebang to use for python scripts run under a pyenv virtualenv : <p>When a python script is supposed to be run from a <code>pyenv</code> <code>virtualenv</code> what is the correct shebang for the file?</p>
<p>As an example test case, the default python on my system (OSX) does not have <code>pandas</code> installed. The pyenv virtualenv <code>venv_name</code> does. I tried getting the path of the python executable from the virtualenv.</p>
<pre><code>$ pyenv activate venv_name
(venv_name)$ which python
/Users/username/.pyenv/shims/python
</code></pre>
<p><br/>
So I made my example <code>script.py</code>:</p>
<pre><code>#!/Users/username/.pyenv/shims/python
import pandas as pd
print 'success'
</code></pre>
<p><br/>
But when I tried running the script, I got an error:</p>
<pre><code>(venv_name) $ ./script.py
./script.py: line 2: import: command not found
./script.py: line 3: print: command not found
</code></pre>
<p><br/>
Although running that path on the command line works fine:</p>
<pre><code>(venv_name) $ /Users/username/.pyenv/shims/python script.py
success
(venv_name) $ python script.py # also works
success
</code></pre>
<p>What is the proper shebang for this? Ideally, I want something generic so that it will point at the python of whatever my current venv is.</p>
| 0debug
|
I am getting error when open new activity on button click android studio : <p>i created one android project . i tried to open new activity. but i got error.</p>
<p>my code:</p>
<pre><code> <Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="141dp"
android:id="@+id/btn1"
android:onClick="onClickA" />
public void onClickA()
{
startActivity(new Intent(this,LoginActivity.class));
}
</code></pre>
<p>error </p>
<pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp.i, PID: 1635
java.lang.IllegalStateException: Could not find method onClickA(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.AppCompatButton with id 'btn1'
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:327)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:284)
at android.view.View.performClick(View.java:5609)
at android.view.View$PerformClick.run(View.java:22259)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
</code></pre>
<p>can you help to solve this error.
thank you.</p>
| 0debug
|
R 3.4.1 Console Interface Very Slow on Mac : <p>I have upgraded R from 3.3.3 to 3.4.1 and am finding that typing text directly into the R Console quickly becomes very laggy, even when R isn't using a lot of resources. I have observed this behavior running the last couple versions of macos sierra (10.12.6, etc.).</p>
<p>It is notable that R functions are not particularly slow when executed. Most of the time I use Textmate 2 to pass code to the console and the code passed in this fashion runs without delay.</p>
<p>I've done extensive searching, but I haven't found anyone else reporting this problem. I've found this behavior on two different macs: 2013 Macbook 13" and 2017 Macbook 15" and have encountered the same problem.</p>
<p>Is there an easy solution to this problem that I'm missing?</p>
| 0debug
|
How can I add 20px margin only to divs on the left hand side (flex) : <p>The divs are using flex & flex-wrap, and I only want to apply margin-right to the divs on the left hand side as when clicked the border is pushed up against the divs on the right hand side. Any ideas how to achieve this?</p>
<p><a href="https://i.stack.imgur.com/WPmC4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WPmC4.jpg" alt="enter image description here"></a></p>
| 0debug
|
static void v9fs_wstat(void *opaque)
{
int32_t fid;
int err = 0;
int16_t unused;
V9fsStat v9stat;
size_t offset = 7;
struct stat stbuf;
V9fsFidState *fidp;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
pdu_unmarshal(pdu, offset, "dwS", &fid, &unused, &v9stat);
trace_v9fs_wstat(pdu->tag, pdu->id, fid,
v9stat.mode, v9stat.atime, v9stat.mtime);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
if (donttouch_stat(&v9stat)) {
err = v9fs_co_fsync(pdu, fidp, 0);
goto out;
}
if (v9stat.mode != -1) {
uint32_t v9_mode;
err = v9fs_co_lstat(pdu, &fidp->path, &stbuf);
if (err < 0) {
goto out;
}
v9_mode = stat_to_v9mode(&stbuf);
if ((v9stat.mode & P9_STAT_MODE_TYPE_BITS) !=
(v9_mode & P9_STAT_MODE_TYPE_BITS)) {
err = -EIO;
goto out;
}
err = v9fs_co_chmod(pdu, &fidp->path,
v9mode_to_mode(v9stat.mode,
&v9stat.extension));
if (err < 0) {
goto out;
}
}
if (v9stat.mtime != -1 || v9stat.atime != -1) {
struct timespec times[2];
if (v9stat.atime != -1) {
times[0].tv_sec = v9stat.atime;
times[0].tv_nsec = 0;
} else {
times[0].tv_nsec = UTIME_OMIT;
}
if (v9stat.mtime != -1) {
times[1].tv_sec = v9stat.mtime;
times[1].tv_nsec = 0;
} else {
times[1].tv_nsec = UTIME_OMIT;
}
err = v9fs_co_utimensat(pdu, &fidp->path, times);
if (err < 0) {
goto out;
}
}
if (v9stat.n_gid != -1 || v9stat.n_uid != -1) {
err = v9fs_co_chown(pdu, &fidp->path, v9stat.n_uid, v9stat.n_gid);
if (err < 0) {
goto out;
}
}
if (v9stat.name.size != 0) {
err = v9fs_complete_rename(pdu, fidp, -1, &v9stat.name);
if (err < 0) {
goto out;
}
}
if (v9stat.length != -1) {
err = v9fs_co_truncate(pdu, &fidp->path, v9stat.length);
if (err < 0) {
goto out;
}
}
err = offset;
out:
put_fid(pdu, fidp);
out_nofid:
v9fs_stat_free(&v9stat);
complete_pdu(s, pdu, err);
}
| 1threat
|
How to split data into training and validation in R? : <p>The question says:</p>
<p>Load the data and split it into 75% training and 25% validation data using set.seed(4650).</p>
<p>this is what I have:</p>
<pre><code>setwd("C:/Users/Downloads")
cat = read.csv("cat.csv")
set.seed(4650)
train = sample(c(TRUE, TRUE, TRUE, FALSE), nrow(cat), rep = TRUE)
validation = (!train)
</code></pre>
<p>And I need to provide summary of the training data.</p>
<pre><code>summary(train)
</code></pre>
<p>which gives me</p>
<pre><code>Mode FALSE TRUE
logical 830 2463
</code></pre>
<p>Am I splitting the data in the right way?</p>
<p>Thank you very much.</p>
| 0debug
|
Last ID inserted with c# and Microsoft Access : <p>How to have last ID inserted? I need new ID for child table.
Thanks.</p>
| 0debug
|
How can I parse a string of an array into an array? : <pre><code>{scenarios: "[{purchasePrice:11,downPayment:1,term:30,rate:1}]"}
</code></pre>
<p>That's my object. I want to turn the value of scenarios into the array its trying to be from the string it is. </p>
<p>Is there a quick tool so I don't have to hack it together from .splits?</p>
| 0debug
|
Why do ajax returns a TypeError undefined error if it calls a function on success? : <p>Im trying to get the contents of a json file from my localhost and display it on my page, i made a custom function <code>displayProfile</code> that is called inside the <code>success</code> whenever the file exist on the directory. the problem is i get an error saying: </p>
<blockquote>
<p>TypeError: data is undefined</p>
</blockquote>
<p><strong>JQUERY code version 1</strong></p>
<pre><code>$.ajax({
url:'api/profile.json',
dataType:'json',
data: {format: "json"},
success:function(data){
displayProfile();
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
//alert(textStatus+' '+errorThrown);
$("#myfirstname").text('Firstname');
$("#mymiddlename").text('M.I.');
$("#mylastname").text("Lastname");
$("#mybiography").text("Biography")
$("#myprofpic").attr("src","default.jpg");
$("#mycoverphoto").css("background-image","url(defaultcover.jpg");
}
});
var displayProfile = function(data){
// initialize values
var firstname = data.profile.firstname;
var middlename = data.profile.middlename;
var lastname = data.profile.lastname;
var biography = data.profile.biography;
var prof_pic = data.profile.profpic;
var cover_photo = data.profile.coverphoto;
// set values
$("#myfirstname").text(firstname);
$("#mymiddlename").text(middlename.substr(0,1)+".");
$("#mylastname").text(lastname);
$("#mybiography").text(biography)
$("#myprofpic").attr('src',prof_pic);
$("#mycoverphoto").css("background-image","url("+cover_photo+")");
};
</code></pre>
<p>But it works when i just copy the content of the function and paste it inside the success like this:</p>
<p><strong>JQUERY code version 2</strong></p>
<pre><code>$.ajax({
url:'api/profile.json',
dataType:'json',
data: {format: "json"},
success:function(data){
// initialize values
var firstname = data.profile.firstname;
var middlename = data.profile.middlename;
var lastname = data.profile.lastname;
var biography = data.profile.biography;
var prof_pic = data.profile.profpic;
var cover_photo = data.profile.coverphoto;
// set values
$("#myfirstname").text(firstname);
$("#mymiddlename").text(middlename.substr(0,1)+".");
$("#mylastname").text(lastname);
$("#mybiography").text(biography)
$("#myprofpic").attr('src',prof_pic);
$("#mycoverphoto").css("background-image","url("+cover_photo+")");
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
//alert(textStatus+' '+errorThrown);
$("#myfirstname").text('Firstname');
$("#mymiddlename").text('M.I.');
$("#mylastname").text("Lastname");
$("#mybiography").text("Biography")
$("#myprofpic").attr("src","default.jpg");
$("#mycoverphoto").css("defaultcover.jpg)");
}
});
</code></pre>
<p>Can you guys explain why version 2 works? i am a beginner with this languages. Thanks!</p>
| 0debug
|
How to make code? : <p>I have 3 data.</p>
<pre><code>code2 data : code data(ex:a1,b1,c1)
field data : field data(ex:a2,b2,c2)
file data: row data
</code></pre>
<p>row data format is next line</p>
<pre><code>field1|field2|field3
a1 |a2 |value1
a1 |b2 |value2
a1 |c2 |value3
b1 |a2 |value4
b1 |b2 |value5
...
</code></pre>
<p>I want to make new data. New data format is next line</p>
<pre><code>index|a2|b2|c2
a1 |value1|value2|value3
b1 |vlaue4|value5 ...
</code></pre>
<p>I used numpy and pandas 's array lib but I can't make a newdata</p>
<p>My code is next line</p>
<pre><code>f = open('D:\\file.txt','r')
g = open('D:\\code2.txt','r')
h = open('D:\\field.txt','r')
k = open('D:\\data.txt','w')
import numpy as np
a=[]
b=[]
c = [0 for _ in range(102218)]
d = [0 for _ in range(63)]
f_1 = f.readlines()[1:]
g_1 = g.readlines()
h_1 = h.readlines()
for i in range(0,102219):
c[i]=""
for lineG in g_1:
a = lineG.split('|')
code = int(a)
for lineH in h_1:
b = lineH.split('|')
for lineF in f_1:
z = lineF.split(',')
if a == z[1] and b == z[2]:
array1 = np.arange(6542080).reshape(len(lineG),len(lineH))
array1 = np.array(ro)
break
else:
continue
k.close()
h.close()
g.close()
f.close()
</code></pre>
| 0debug
|
static void print_type_size(Visitor *v, const char *name, uint64_t *obj,
Error **errp)
{
StringOutputVisitor *sov = to_sov(v);
static const char suffixes[] = { 'B', 'K', 'M', 'G', 'T', 'P', 'E' };
uint64_t div, val;
char *out;
int i;
if (!sov->human) {
out = g_strdup_printf("%"PRIu64, *obj);
string_output_set(sov, out);
return;
}
val = *obj;
frexp(val / (1000.0 / 1024.0), &i);
i = (i - 1) / 10;
assert(i < ARRAY_SIZE(suffixes));
div = 1ULL << (i * 10);
out = g_strdup_printf("%"PRIu64" (%0.3g %c%s)", val,
(double)val/div, suffixes[i], i ? "iB" : "");
string_output_set(sov, out);
}
| 1threat
|
How to resolve ' error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.'? : <p>I am importing a .js file (so not a .ts-file) called Auth.js into my reactjs&typescript application, so in my component I have this:</p>
<pre><code>import * as Auth from '../Auth/Auth';
..
const auth = new Auth();
</code></pre>
<p>This is part of my Auth.js:</p>
<pre><code> export default class Auth {
auth0 = new auth0.WebAuth({
domain: AUTH_CONFIG.domain,
clientID: AUTH_CONFIG.clientId,
redirectUri: AUTH_CONFIG.callbackUrl,
audience: `https://${AUTH_CONFIG.domain}/userinfo`,
responseType: 'token id_token',
scope: 'openid'
});
constructor() {
this.login = this.login.bind(this);
this.logout = this.logout.bind(this);
this.handleAuthentication = this.handleAuthentication.bind(this);
this.isAuthenticated = this.isAuthenticated.bind(this);
}
..
</code></pre>
<p>When I run webpack I get the following error message:</p>
<pre><code>ERROR in ./src/containers/main.tsx
(16,14): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
</code></pre>
<p>How can I resolve this TS-error?</p>
| 0debug
|
Error: Initializer 'init(_:)' requires that 'Binding<String>' conform to 'StringProtocol' : <p>I am getting the above error and couldn't figure out how to solve it. I have an array of objects that contain a boolean value, and need to show a toggle for each of these boolean.</p>
<p>Below is the code.</p>
<pre><code>class Item: Identifiable {
var id: String
var label: String
var isOn: Bool
}
class Service: ObservableObject {
var didChange = PassthroughSubject<Void, Never>()
var items: [Item] {
didSet {
didChange.send(())
}
}
}
struct MyView: View {
@ObservedObject var service: Service
var body: some View {
List {
ForEach(service.items, id: \.self) { (item: Binding<Item>) in
Section(header: Text(item.label)) { // Error: Initializer 'init(_:)' requires that 'Binding<String>' conform to 'StringProtocol'
Toggle(isOn: item.isOn) {
Text("isOn")
}
}
}
}
.listStyle(GroupedListStyle())
}
}
</code></pre>
| 0debug
|
static int64_t coroutine_fn cow_co_get_block_status(BlockDriverState *bs,
int64_t sector_num, int nb_sectors, int *num_same)
{
BDRVCowState *s = bs->opaque;
int ret = cow_co_is_allocated(bs, sector_num, nb_sectors, num_same);
int64_t offset = s->cow_sectors_offset + (sector_num << BDRV_SECTOR_BITS);
if (ret < 0) {
return ret;
}
return (ret ? BDRV_BLOCK_DATA : 0) | offset | BDRV_BLOCK_OFFSET_VALID;
}
| 1threat
|
Why am I having Invalid Syntax? : Why am I having Invalid Syntax, please don't be mad at me if I am so stupid thanks
`import os
gateway = raw_input("What is your gateway IP: ")
target = raw_input("What is your target IP: ")
interface = raw_input("What is your network interface: ")
os.system('arpspoof -i {0} -t {1} {2} 2>/dev/null 1>/dev/null &'.format(interface, gateway, target))
os.system('arpspoof -i {0} -t {1} {2} 2>/dev/null 1>/dev/null &'.format(interface, target, gateway))
while True:
try:
stop_command = raw_input("If you want to exit type stop: ")
if stop_command != "stop":
print("You didn't type stop")
continue
else:
break`
| 0debug
|
Reading integers from a text file containing integers and strings : So here is my code and the only options I have in the chapter we are on are the while (!scan.hasNextInt()). This is my code and it works until I try to read a file with strings. The file looks like this:
1
2
John
3
4
Black
5
Jason
7
8
I do not understand how to use this method.
My code:
import java.util.Scanner;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
int number;
int temp;
int i;
boolean isPrime = true;
double count = 0.0;
double total = 0.0;
File inputFile = new File("Values.txt");
Scanner file = new Scanner(inputFile);
while (file.hasNext())
{
if (!file.hasNextInt()) {
String s = file.nextLine();
}
else {
number = file.nextInt();
}
for (i = 2; i <= (number / 2); i++)
{
temp = number % i;
if (temp == 0)
{
isPrime = false;
break;
}
}
if (isPrime) {
//System.out.println(number);
total = total + number;
count = count + 1.0;
}
isPrime = true;
}
//System.out.println(total);
//System.out.println(count);
System.out.println(total / count);
System.out.println("File is Empty");
file.close();
}
}
| 0debug
|
Interval calculation in Python : <p>I am writing a program where I need to calculate the total watch time of a movie.</p>
<pre><code>1st watch = (0,10)
2nd Watch =(13,18)
3rd watch =(15,23)
4th watch =(21,26)
</code></pre>
<p>Total movie watched=10+5+5+3=23 min</p>
<p>How can I implement this in Python</p>
| 0debug
|
Can anyone help me how to pass multiple values to a popup form through button ??like : <button class="btn btn-success edit-company" data-id="{{ $cp->companyId }}" data-name="{{ $cp->companyName }}" data-nature="{{ $cp->businessNature }}" data-address="{{ $cp->companyAddress }}" data-zip="{{ $cp->companyZipcode }}" data-area="{{ $cp->companyAddressArea }}" data-email="{{ $cp->companyEmail }}" data-phone="{{ $cp->companyPhoneNumber }}" data-website="{{ $cp->companyWebsite }}"><i class="fa fa-edit m-right-xs"></i>Edit Profile</button>
| 0debug
|
static void create_gic(VirtBoardInfo *vbi, qemu_irq *pic, int type, bool secure)
{
DeviceState *gicdev;
SysBusDevice *gicbusdev;
const char *gictype;
int i;
gictype = (type == 3) ? gicv3_class_name() : gic_class_name();
gicdev = qdev_create(NULL, gictype);
qdev_prop_set_uint32(gicdev, "revision", type);
qdev_prop_set_uint32(gicdev, "num-cpu", smp_cpus);
qdev_prop_set_uint32(gicdev, "num-irq", NUM_IRQS + 32);
if (!kvm_irqchip_in_kernel()) {
qdev_prop_set_bit(gicdev, "has-security-extensions", secure);
}
qdev_init_nofail(gicdev);
gicbusdev = SYS_BUS_DEVICE(gicdev);
sysbus_mmio_map(gicbusdev, 0, vbi->memmap[VIRT_GIC_DIST].base);
if (type == 3) {
sysbus_mmio_map(gicbusdev, 1, vbi->memmap[VIRT_GIC_REDIST].base);
} else {
sysbus_mmio_map(gicbusdev, 1, vbi->memmap[VIRT_GIC_CPU].base);
}
for (i = 0; i < smp_cpus; i++) {
DeviceState *cpudev = DEVICE(qemu_get_cpu(i));
int ppibase = NUM_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS;
int irq;
const int timer_irq[] = {
[GTIMER_PHYS] = ARCH_TIMER_NS_EL1_IRQ,
[GTIMER_VIRT] = ARCH_TIMER_VIRT_IRQ,
[GTIMER_HYP] = ARCH_TIMER_NS_EL2_IRQ,
[GTIMER_SEC] = ARCH_TIMER_S_EL1_IRQ,
};
for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) {
qdev_connect_gpio_out(cpudev, irq,
qdev_get_gpio_in(gicdev,
ppibase + timer_irq[irq]));
}
sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
sysbus_connect_irq(gicbusdev, i + smp_cpus,
qdev_get_gpio_in(cpudev, ARM_CPU_FIQ));
}
for (i = 0; i < NUM_IRQS; i++) {
pic[i] = qdev_get_gpio_in(gicdev, i);
}
fdt_add_gic_node(vbi, type);
if (type == 3) {
create_its(vbi, gicdev);
} else {
create_v2m(vbi, pic);
}
}
| 1threat
|
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in : <p>I have this problem with short php code I am using in to get suggestions for JQuery autocomplete. I have tried many things but I am unable to find solution:</p>
<pre><code>//connect to your database
<?php require('Connections/con_1.php');?>
<?php
//retrieve the search term that autocomplete sends
$term = trim(strip_tags($_REQUEST['term']));
//save search queries to csv file
$file = fopen("searchqueries.csv","a");
fputcsv($file,explode(',',$term));
fclose($file);
//query the database for entries containing the term
$qstring ="USE database_2";"SELECT DISTINCT Pracodawca as value FROM Pensje WHERE Pracodawca LIKE '%".$term."%'";
$result = mysql_query($qstring) or die($result.mysql_error());
//loop through the retrieved values
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
//build an array
$row['value']=htmlspecialchars(stripslashes($row['value']));
$row_set[] = $row['value'];
$row['value']=
$row_set[] = array('value' => ($row['value']));
}
//format the array into json data
echo json_encode($row_set, JSON_UNESCAPED_UNICODE);
?>
</code></pre>
<p>I get error <em>"Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in"</em> and the result is <em>NULL</em>.</p>
<p>What I am doing wrong?</p>
| 0debug
|
generate reports on agent per environment in UDeploy : We have a requirement to generate reports on agents per application /Environment in UDeploy
Do we have an API from Udeploy for this ?
Do we have any way to do this ?
you help is much appreciated
| 0debug
|
SQL skip a number in sequence of numbers generated using connect by : Select Rownum From dual Connect By Rownum <= '4' ;
Am using this SQL to list numbers from 1 to 4.
i want to list 1 to 4 skipping 3. so that the result looks like
1
2
4
Kindly help
| 0debug
|
bool memory_region_get_dirty(MemoryRegion *mr, hwaddr addr,
hwaddr size, unsigned client)
{
assert(mr->terminates);
return cpu_physical_memory_get_dirty(mr->ram_addr + addr, size, client);
}
| 1threat
|
void kvmppc_set_papr(CPUPPCState *env)
{
struct kvm_enable_cap cap = {};
struct kvm_one_reg reg = {};
struct kvm_sregs sregs = {};
int ret;
uint64_t hior = env->spr[SPR_HIOR];
cap.cap = KVM_CAP_PPC_PAPR;
ret = kvm_vcpu_ioctl(env, KVM_ENABLE_CAP, &cap);
if (ret) {
goto fail;
}
reg.id = KVM_REG_PPC_HIOR;
reg.addr = (uintptr_t)&hior;
ret = kvm_vcpu_ioctl(env, KVM_SET_ONE_REG, ®);
if (ret) {
fprintf(stderr, "Couldn't set HIOR. Maybe you're running an old \n"
"kernel with support for HV KVM but no PAPR PR \n"
"KVM in which case things will work. If they don't \n"
"please update your host kernel!\n");
}
ret = kvm_vcpu_ioctl(env, KVM_GET_SREGS, &sregs);
if (ret) {
goto fail;
}
sregs.u.s.sdr1 = env->spr[SPR_SDR1];
ret = kvm_vcpu_ioctl(env, KVM_SET_SREGS, &sregs);
if (ret) {
goto fail;
}
return;
fail:
cpu_abort(env, "This KVM version does not support PAPR\n");
}
| 1threat
|
Angular 7, IE11 throw Expected identifier SCRIPT1010 on vendor.js in WEBPACK VAR INJECTION : I have issue with Expected identifier ERROR code: SCRIPT1010 which points on vendor.js in WEBPACK VAR INJECTION section. Debugger points on line with:
const { keccak256, keccak256s } = __webpack_require__(/*! ./hash */ "./node_modules/web3-eth-accounts/node_modules/eth-lib/lib/hash.js");
tsconfig
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2015.promise",
"es2018",
"dom"
]
}
}
polyfils:
import 'classlist.js'
(window as any).__Zone_enable_cross_context_check = true;
index.html:
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
What shoud I do to fix that? Please for hints and comments, thanks!
| 0debug
|
I am trying to connect twitter API from angularJS i am not able to. can anyone please help me on this : how to connect twitter api from angularJS.
$http.get('https://api.twitter.com/1.1/search/tweets.json).then(function(data){
$scope.data = data;
},
function(error){
});
| 0debug
|
Adding Google Analytics to React : <p>I am trying to add Google Analytics to a React Web Application.</p>
<p>I know how to do it in HTML/CSS/JS sites and I have integrated it in an AngularJS app too. But, I'm not quite sure how to go about it when it comes to react.</p>
<p>With HTML/CSS/JS, I had just added it to every single page.</p>
<p>What I had done with AngularJS was adding GTM and GA script to index.html and added UA-labels to the HTML divs (and buttons) to get clicks. </p>
<p><strong>How can I do that with React?</strong></p>
<p>Please help!</p>
| 0debug
|
Python Restful API : <p>I have written a python script that will connect to the oracle database using cx_oracle and gets data and performs some action on it. </p>
<p>I want to expose this python script as a Restful API. In google, I read that using flask we can deploy a Python script as a Web service.</p>
<p>What I am not clear </p>
<ol>
<li>The flask itself behaves like a server? </li>
<li>Can I deploy the python Webservice in the Web logic server?</li>
<li>I want to deploy this Webservice in production. How can I provide security to this?</li>
<li>In another site, I read using Connection, Swagger we can implement it. </li>
<li>I am actually written using flask, flask-jsonpify, flask-sqlalchemy, flask-restful. </li>
<li>Please suggest which packages i need to use to deploy it as WebService.</li>
</ol>
<p>Let me know in case of any other details needed. Thanks in advance for your suggestions and guidance. </p>
<p>Vijay</p>
| 0debug
|
static void extrapolate_isf(float out[LP_ORDER_16k], float isf[LP_ORDER])
{
float diff_isf[LP_ORDER - 2], diff_mean;
float *diff_hi = diff_isf - LP_ORDER + 1;
float corr_lag[3];
float est, scale;
int i, i_max_corr;
memcpy(out, isf, (LP_ORDER - 1) * sizeof(float));
out[LP_ORDER_16k - 1] = isf[LP_ORDER - 1];
for (i = 0; i < LP_ORDER - 2; i++)
diff_isf[i] = isf[i + 1] - isf[i];
diff_mean = 0.0;
for (i = 2; i < LP_ORDER - 2; i++)
diff_mean += diff_isf[i] * (1.0f / (LP_ORDER - 4));
i_max_corr = 0;
for (i = 0; i < 3; i++) {
corr_lag[i] = auto_correlation(diff_isf, diff_mean, i + 2);
if (corr_lag[i] > corr_lag[i_max_corr])
i_max_corr = i;
}
i_max_corr++;
for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++)
out[i] = isf[i - 1] + isf[i - 1 - i_max_corr]
- isf[i - 2 - i_max_corr];
est = 7965 + (out[2] - out[3] - out[4]) / 6.0;
scale = 0.5 * (FFMIN(est, 7600) - out[LP_ORDER - 2]) /
(out[LP_ORDER_16k - 2] - out[LP_ORDER - 2]);
for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++)
diff_hi[i] = scale * (out[i] - out[i - 1]);
for (i = LP_ORDER; i < LP_ORDER_16k - 1; i++)
if (diff_hi[i] + diff_hi[i - 1] < 5.0) {
if (diff_hi[i] > diff_hi[i - 1]) {
diff_hi[i - 1] = 5.0 - diff_hi[i];
} else
diff_hi[i] = 5.0 - diff_hi[i - 1];
}
for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++)
out[i] = out[i - 1] + diff_hi[i] * (1.0f / (1 << 15));
for (i = 0; i < LP_ORDER_16k - 1; i++)
out[i] *= 0.8;
}
| 1threat
|
Azure web app service time zone change issue : <p>We are using azure web app service for multi tenant application. But default time zone of app service is UTC taking i want to change that time zone for that region only.</p>
<p>I have tried WEB_TIMEZONE variable in app setting but not working.</p>
| 0debug
|
private arguments not saving things help c++ : main.cpp
#include <iostream>
#include <string>
#include <vector>
#include "Figuras.h"
using namespace std;
void error(){
cout<<"algo ha ido mal vuelve a empezar"<<endl;
exit(0);
}
int main(){
Figuras fig;
vec V;
string tip;
cout << "Triangle = Tr / Cuadrat = Cu / Rectangle = Re / Segment = Se / Cercle = Ce" << endl;
cin >> tip;
if(tip=="Tr"){
V = vector<pair<double,double>>(3);
}
else if(tip == "Cu" or tip == "Re"){
V = vector<pair<double,double>>(4);
}
else if (tip == "Se" or tip == "Ce"){
V = vector<pair<double,double>>(2);
}
else error();
for (int i = 0; i < V.size(); i++) { //fill vector with coords
cout << "Introdueix coordenada numero: " << i<<" format (double,double): " <<endl;
cout << "x: ";
cin >> V[i].first;
cout << "y: ";
cin >> V[i].second;
}
fig.crea_figura(tip,V);
fig.mostrar_fig();
}
Figuras.cpp
#include "Figuras.h"
using namespace std;
/*void Figuras::Figura(){
tipo = NULL;
Coord = NULL;
}*/
string Figuras::get_tipo (){
return tipo;
};
vec Figuras::get_coords (){
return Coord;
};
punto Figuras::get_inicio (){
return inicio;
};
void Figuras::Set_tipo (string typ){
tipo = typ;
};
void Figuras::Set_Coord (vec V){
punto p;
int x= V.size();
Coord=vector<pair<double,double>>(x);
for ( int i =0; i<x; i++){
Coord[i].first = p.first;
Coord[i].second = p.second;
}
};
void Figuras::Set_inicio (punto ini){
inicio = ini;
};
void Figuras::crea_figura (string tip, vec V){
Set_tipo(tip);
Set_Coord(V);
};
void Figuras::trasladar (punto P){
double difx,dify;
difx=P.first - inicio.first;
dify=P.second - inicio.second;
vec V;
Figuras::get_coords();
if (!Coord.empty()){
for(int i=0; i<Coord.size(); i++){
Coord[i].first += difx;
Coord[i].second += dify;
}
}
else cout<< "no hay coords"<<endl;
};
void Figuras::mostrar_fig (){
vec V;
V=get_coords();
punto ini;
ini=get_inicio();
string tip;
tip=get_tipo();
cout<<"tipo: "<<tip<<endl;
for (int i =0; i<V.size(); i++){
cout<<"punto "<< i+1<<": "<<"("<<V[i].first<<","<<V[i].second<<")"<<endl;
}
cout<< "punto inicial: ("<<ini.first<<","<<ini.second<<")"<<endl;
};
Figuras.h
#ifndef FIGURAS_H
#define FIGURAS_H
#include <vector>
#include <iostream>
#include <string>
using namespace std;
typedef vector < pair < double, double >>vec;
typedef pair < double, double >punto;
class Figuras
{
private:
string tipo;
vec Coord;
punto inicio={0.0,0.0};
public:
string get_tipo ();
vec get_coords ();
punto get_inicio ();
void Set_tipo (string typ);
void Set_Coord (vec V);
void Set_inicio (punto ini);
void crea_figura (string tip, vec vec);
void trasladar (punto P);
void mostrar_fig ();
};
#endif
hi guys let me explain the problem when i do, `crea_figura(tip,V);`
and then mostrar_fig() at main.cpp line 39,40
this happens:
Triangle = Tr / Cuadrat = Cu / Rectangle = Re / Segment = Se / Cercle = Ce
Tr
Introdueix coordenada numero: 0 format (double,double):
x: 1.1
y: 1.1
Introdueix coordenada numero: 1 format (double,double):
x: 2.2
y: 2.2
Introdueix coordenada numero: 2 format (double,double):
x: 3.1
y: 1.1
tipo: Tr
punto 1: (0,0)
punto 2: (0,0)
punto 3: (0,0)
punto inicial: (0,0)
any help with that? if u hadn't noticed all points appear to be empty and i can not realize why is that for. Please help me and if you know any other way to initialize the class (another type of constructor), i will really appreciate that.
| 0debug
|
Visual Studio (2017) - How do you separate integers into two separate variables? : I encountered a problem with my code. I made a program which asks the user(s) to enter a 'number of days' which is then separated into weeks and remainder of days.
Here is the code I've written so far (please click the link because I have not been given permission to post images yet):
[*http://imgur.com/fJB2dze*][1]
Some guidance would be appreciated.
[1]: https://i.stack.imgur.com/R8H2B.png
| 0debug
|
Date picker card for Facebook Messenger bot : <p>I know that there are various CTA cards that Facebook bot can use as seen <a href="https://developers.facebook.com/blog/post/2016/04/12/bots-for-messenger/" rel="noreferrer">here</a>.</p>
<p>What I really need is a datepicker card that can be sent to the user where they can choose a date and send it back. Is this possible using Facebook bots?</p>
| 0debug
|
Python making list of lists from list : <p>My code now: <code>random_lst = [1,2,3,4,5,6,7,8,9]</code></p>
<p>What's practical way in Python to make list of lists from list?</p>
<p>My goal: <code>[[1,2,3],[4,5,6],[7,8,9]]</code></p>
| 0debug
|
static int vpx_decode(AVCodecContext *avctx,
void *data, int *got_frame, AVPacket *avpkt)
{
VPxContext *ctx = avctx->priv_data;
AVFrame *picture = data;
const void *iter = NULL;
const void *iter_alpha = NULL;
struct vpx_image *img, *img_alpha;
int ret;
uint8_t *side_data = NULL;
int side_data_size = 0;
ret = decode_frame(avctx, &ctx->decoder, avpkt->data, avpkt->size);
if (ret)
return ret;
side_data = av_packet_get_side_data(avpkt,
AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,
&side_data_size);
if (side_data_size > 1) {
const uint64_t additional_id = AV_RB64(side_data);
side_data += 8;
side_data_size -= 8;
if (additional_id == 1) {
if (!ctx->has_alpha_channel) {
ctx->has_alpha_channel = 1;
ret = vpx_init(avctx,
#if CONFIG_LIBVPX_VP8_DECODER && CONFIG_LIBVPX_VP9_DECODER
(avctx->codec_id == AV_CODEC_ID_VP8) ?
&vpx_codec_vp8_dx_algo : &vpx_codec_vp9_dx_algo,
#elif CONFIG_LIBVPX_VP8_DECODER
&vpx_codec_vp8_dx_algo,
#else
&vpx_codec_vp9_dx_algo,
#endif
1);
if (ret)
return ret;
ret = decode_frame(avctx, &ctx->decoder_alpha, side_data,
side_data_size);
if (ret)
return ret;
if ((img = vpx_codec_get_frame(&ctx->decoder, &iter)) &&
(!ctx->has_alpha_channel ||
(img_alpha = vpx_codec_get_frame(&ctx->decoder_alpha, &iter_alpha)))) {
uint8_t *planes[4];
int linesizes[4];
if ((ret = set_pix_fmt(avctx, img, ctx->has_alpha_channel)) < 0) {
#ifdef VPX_IMG_FMT_HIGHBITDEPTH
av_log(avctx, AV_LOG_ERROR, "Unsupported output colorspace (%d) / bit_depth (%d)\n",
img->fmt, img->bit_depth);
#else
av_log(avctx, AV_LOG_ERROR, "Unsupported output colorspace (%d) / bit_depth (%d)\n",
img->fmt, 8);
#endif
return ret;
if ((int) img->d_w != avctx->width || (int) img->d_h != avctx->height) {
av_log(avctx, AV_LOG_INFO, "dimension change! %dx%d -> %dx%d\n",
avctx->width, avctx->height, img->d_w, img->d_h);
ret = ff_set_dimensions(avctx, img->d_w, img->d_h);
if (ret < 0)
return ret;
if ((ret = ff_get_buffer(avctx, picture, 0)) < 0)
return ret;
planes[0] = img->planes[VPX_PLANE_Y];
planes[1] = img->planes[VPX_PLANE_U];
planes[2] = img->planes[VPX_PLANE_V];
planes[3] =
ctx->has_alpha_channel ? img_alpha->planes[VPX_PLANE_Y] : NULL;
linesizes[0] = img->stride[VPX_PLANE_Y];
linesizes[1] = img->stride[VPX_PLANE_U];
linesizes[2] = img->stride[VPX_PLANE_V];
linesizes[3] =
ctx->has_alpha_channel ? img_alpha->stride[VPX_PLANE_Y] : 0;
av_image_copy(picture->data, picture->linesize, (const uint8_t**)planes,
linesizes, avctx->pix_fmt, img->d_w, img->d_h);
*got_frame = 1;
return avpkt->size;
| 1threat
|
Eight Queens Python - Kattis : Attempting the Eight Queens problem in python (https://open.kattis.com/problems/8queens).
I've written some code which works for all input I've been able to imagine for the last hour - but the program still fails the Kattis test cases.
This is the code:
https://paste.ofcode.org/9KMu88hkfuR2hrF6YSkWne
It's not very efficient, or well structured, but since the problem shouldnt require speed I didnt really care.
What I'm doing is checking every position, if there is a queen there - I check horizontally, vertically and diagonally. I figured that it's probably the diagonal checking code that's wrong since the other 2 are very straight forward, but I can't figure it out...
Thanks for help!
| 0debug
|
In Android How do I change colour of status bar transparent as shown in bellow photograph : <p><a href="https://i.stack.imgur.com/Y9rDh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Y9rDh.png" alt="This is a image of Android home screen."></a></p>
<p>Can I change status bar colour like this in my app?</p>
| 0debug
|
static void rtsp_cmd_setup(HTTPContext *c, const char *url,
RTSPHeader *h)
{
FFStream *stream;
int stream_index, port;
char buf[1024];
char path1[1024];
const char *path;
HTTPContext *rtp_c;
RTSPTransportField *th;
struct sockaddr_in dest_addr;
RTSPActionServerSetup setup;
url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url);
path = path1;
if (*path == '/')
path++;
for(stream = first_stream; stream != NULL; stream = stream->next) {
if (!stream->is_feed && !strcmp(stream->fmt->name, "rtp")) {
if (!strcmp(path, stream->filename)) {
if (stream->nb_streams != 1) {
rtsp_reply_error(c, RTSP_STATUS_AGGREGATE);
return;
}
stream_index = 0;
goto found;
}
for(stream_index = 0; stream_index < stream->nb_streams;
stream_index++) {
snprintf(buf, sizeof(buf), "%s/streamid=%d",
stream->filename, stream_index);
if (!strcmp(path, buf))
goto found;
}
}
}
rtsp_reply_error(c, RTSP_STATUS_SERVICE);
return;
found:
if (h->session_id[0] == '\0')
snprintf(h->session_id, sizeof(h->session_id), "%08x%08x",
av_random(&random_state), av_random(&random_state));
rtp_c = find_rtp_session(h->session_id);
if (!rtp_c) {
th = find_transport(h, RTSP_PROTOCOL_RTP_UDP);
if (!th) {
th = find_transport(h, RTSP_PROTOCOL_RTP_TCP);
if (!th) {
rtsp_reply_error(c, RTSP_STATUS_TRANSPORT);
return;
}
}
rtp_c = rtp_new_connection(&c->from_addr, stream, h->session_id,
th->protocol);
if (!rtp_c) {
rtsp_reply_error(c, RTSP_STATUS_BANDWIDTH);
return;
}
if (open_input_stream(rtp_c, "") < 0) {
rtsp_reply_error(c, RTSP_STATUS_INTERNAL);
return;
}
}
if (rtp_c->stream != stream) {
rtsp_reply_error(c, RTSP_STATUS_SERVICE);
return;
}
if (rtp_c->rtp_ctx[stream_index]) {
rtsp_reply_error(c, RTSP_STATUS_STATE);
return;
}
th = find_transport(h, rtp_c->rtp_protocol);
if (!th || (th->protocol == RTSP_PROTOCOL_RTP_UDP &&
th->client_port_min <= 0)) {
rtsp_reply_error(c, RTSP_STATUS_TRANSPORT);
return;
}
setup.transport_option[0] = '\0';
dest_addr = rtp_c->from_addr;
dest_addr.sin_port = htons(th->client_port_min);
if (rtp_new_av_stream(rtp_c, stream_index, &dest_addr, c) < 0) {
rtsp_reply_error(c, RTSP_STATUS_TRANSPORT);
return;
}
rtsp_reply_header(c, RTSP_STATUS_OK);
url_fprintf(c->pb, "Session: %s\r\n", rtp_c->session_id);
switch(rtp_c->rtp_protocol) {
case RTSP_PROTOCOL_RTP_UDP:
port = rtp_get_local_port(rtp_c->rtp_handles[stream_index]);
url_fprintf(c->pb, "Transport: RTP/AVP/UDP;unicast;"
"client_port=%d-%d;server_port=%d-%d",
th->client_port_min, th->client_port_min + 1,
port, port + 1);
break;
case RTSP_PROTOCOL_RTP_TCP:
url_fprintf(c->pb, "Transport: RTP/AVP/TCP;interleaved=%d-%d",
stream_index * 2, stream_index * 2 + 1);
break;
default:
break;
}
if (setup.transport_option[0] != '\0')
url_fprintf(c->pb, ";%s", setup.transport_option);
url_fprintf(c->pb, "\r\n");
url_fprintf(c->pb, "\r\n");
}
| 1threat
|
Pandas reset inner level of MultiIndex : <p>I have a DF in the following format:</p>
<pre><code> col1 col2
ID Date
1 1993-12-31 4 6
1994-12-31 8 5
1995-12-31 4 7
1996-12-31 3 3
2 2000-12-31 7 8
2001-12-31 5 9
2002-12-31 8 4
</code></pre>
<p>And I want to reset the 'Date' index giving the following:</p>
<pre><code> col1 col2
ID Date
1 0 4 6
1 8 5
2 4 7
3 3 3
2 0 7 8
1 5 9
2 8 4
</code></pre>
<p>I thought simply <code>df.reset_index(level='Date', inplace=True, drop=True)</code> would do it, but it does not.</p>
| 0debug
|
Do i need an iphone to build in xcode and upload to appstore? : I'm building a unity game ready to be uploaded to appstore. Xcode gives me this error.
[image][1]
I do not have an iphone.
So the question is: do i need an iphone to build in xcode and upload to appstore?
Is there other way around this?
Thanks.
[1]: https://i.stack.imgur.com/EjnBu.png
| 0debug
|
How do I make a reset button for a simple xcode application? : I am making my first non "hello World app". I have a very simple application that I am making. My app has a date field, some input fields, some switches and a text view. I want to make a reset button that will put the app back to how it was when you first open it.
here is my code so far:
import UIKit
class ViewController: UIViewController {
// i will need to use these later
@IBOutlet weak var SubmitB: UIButton!
@IBOutlet weak var DateB: UIDatePicker!
@IBOutlet weak var ResetB: UIButton!
@IBOutlet weak var LotI: UITextField!
@IBOutlet weak var BlockI: UITextField!
@IBOutlet weak var EmailI: UITextField!
@IBOutlet weak var BuilderI: UITextField!
@IBOutlet weak var SubdivisionI: UITextField!
@IBOutlet weak var FilingI: UITextField!
@IBOutlet weak var AddressI: UITextField!
@IBOutlet weak var HSSPPP: UISwitch!
@IBOutlet weak var HSUTSLNC: UISwitch!
@IBOutlet weak var HSOSC: UISwitch!
@IBOutlet weak var FFCPPPP: UISwitch!
@IBOutlet weak var FFCFSC: UISwitch!
@IBOutlet weak var FFCOSC: UISwitch!
@IBOutlet weak var RGSSPPP: UISwitch!
@IBOutlet weak var RGSOSC: UISwitch!
@IBOutlet weak var ISSSFR: UISwitch!
@IBOutlet weak var ISFNC: UISwitch!
@IBOutlet weak var ISOSC: UISwitch!
@IBOutlet weak var GSPSSFG: UISwitch!
@IBOutlet weak var GSFGF: UISwitch!
@IBOutlet weak var GSFDNMC: UISwitch!
@IBOutlet weak var GSOSC: UISwitch!
@IBOutlet weak var CommentsI: UITextView!
@IBAction func ResetBA(_ sender: Any) {
//this is where i am stuck
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a
nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Any help would be great.
Thanks
| 0debug
|
void vnc_init_state(VncState *vs)
{
vs->initialized = true;
VncDisplay *vd = vs->vd;
bool first_client = QTAILQ_EMPTY(&vd->clients);
vs->last_x = -1;
vs->last_y = -1;
vs->as.freq = 44100;
vs->as.nchannels = 2;
vs->as.fmt = AUD_FMT_S16;
vs->as.endianness = 0;
qemu_mutex_init(&vs->output_mutex);
vs->bh = qemu_bh_new(vnc_jobs_bh, vs);
QTAILQ_INSERT_TAIL(&vd->clients, vs, next);
if (first_client) {
vnc_update_server_surface(vd);
}
graphic_hw_update(vd->dcl.con);
vnc_write(vs, "RFB 003.008\n", 12);
vnc_flush(vs);
vnc_read_when(vs, protocol_version, 12);
reset_keys(vs);
if (vs->vd->lock_key_sync)
vs->led = qemu_add_led_event_handler(kbd_leds, vs);
vs->mouse_mode_notifier.notify = check_pointer_type_change;
qemu_add_mouse_mode_change_notifier(&vs->mouse_mode_notifier);
}
| 1threat
|
Javascript if a<x<b and c<y<d and x>y return value : ----------
Can some one explain if this is correct in javascript?
Or how to achieve that?
X - constant imput
y - constant imput
X>Y
if a<x<b and c<y<d and x>y return value
Option 1: if(100=<x=<500 && 1=<y=<7) return 5;
or
Option 2: if(100<=x && x=<5000 && 12<=y && y<17) return 5;
Best regards
| 0debug
|
compile a java program in serverside and display the output in client side : <p>I have a website,my problem is how to run and compile a java program in server side and display the output or error in client side</p>
| 0debug
|
How to remove the default CRA react favicon? : <p>I already remove the link in the head tag and still the favicon gets rendered, is there anyway this can be remove or change?</p>
| 0debug
|
How to manually add a path to be resolved in eslintrc : <p>I have a folder in my project <code>main</code> that I am resolving like a module. For instance <code>import x from 'main/src'</code> imports <code>main/src/index.js</code>. This is done through webpack's resolve alias configuration.</p>
<p>An issue I am having is getting rid of the errors via eslint. I know eslint provides a webpack resolve plugin, however, I've been having trouble getting it to work. I suspect it is because I am on webpack 2 and using es6 in my webpack config files.</p>
<p>Is there a manual way to write a resolve setting that fixes this problem for my eslint?</p>
<hr>
<p>The only other hack I've seen work is using <code>import/core-modules</code> but then I have to list out every folder in the subdirectory tree <code>main/src/bar</code>, <code>main/src/foo</code>. This would not be ideal.</p>
| 0debug
|
Is Comment consider as a token? : Usually we consider Identifiers, keywords, separators, operators and literals as token. Can we also consider comment as a token.
| 0debug
|
void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty)
{
int reslevelno, bandno, precno;
for (reslevelno = 0;
comp->reslevel && reslevelno < codsty->nreslevels;
reslevelno++) {
Jpeg2000ResLevel *reslevel;
if (!comp->reslevel)
continue;
reslevel = comp->reslevel + reslevelno;
for (bandno = 0; bandno < reslevel->nbands; bandno++) {
Jpeg2000Band *band;
if (!reslevel->band)
continue;
band = reslevel->band + bandno;
for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++) {
if (band->prec) {
Jpeg2000Prec *prec = band->prec + precno;
av_freep(&prec->zerobits);
av_freep(&prec->cblkincl);
av_freep(&prec->cblk);
}
}
av_freep(&band->prec);
}
av_freep(&reslevel->band);
}
ff_dwt_destroy(&comp->dwt);
av_freep(&comp->reslevel);
av_freep(&comp->i_data);
av_freep(&comp->f_data);
}
| 1threat
|
Object with ID '203618703567212' does not exist, cannot be loaded due to missing permissions, or does not support this operation : <p>After the facebook have updated the Graph API and it's request I am facing this error</p>
<blockquote>
<p>Unsupported get request. Object with ID '203618703567212' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at <a href="https://developers.facebook.com/docs/graph-api" rel="noreferrer">https://developers.facebook.com/docs/graph-api</a></p>
</blockquote>
<p>I have the access token with all the valid permissions and access token is valid too,</p>
<p>URL is
<a href="https://graph.facebook.com/v2.9/203618703567212/?fields=cover&access_token=Access" rel="noreferrer">https://graph.facebook.com/v2.9/203618703567212/?fields=cover&access_token=Access</a> Token Here
It was working previously before the Update but now it is just crashing. Any help on this will be appreciated , I have read all blogs and everything where i could ask for solution but found nothing.</p>
| 0debug
|
How to display integers in android studio using for loop : How can i display integers inside this loop? When i run this code it only display 1 value.
public View.OnClickListener buttonClick = new View.OnClickListener() {
@Override
public void onClick(View v) {
int inputFirst = Integer.parseInt(etTxt1.getText().toString());
int inputSec = Integer.parseInt(etTxt2.getText().toString());
for (int i = inputFirst; i <= inputSec; i++){
tView.setText(i); ;
}
}
};
| 0debug
|
static void scsi_cancel_io(SCSIDevice *d, uint32_t tag)
{
DPRINTF("scsi_cancel_io 0x%x\n", tag);
SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, d);
SCSIGenericReq *r;
DPRINTF("Cancel tag=0x%x\n", tag);
r = scsi_find_request(s, tag);
if (r) {
if (r->req.aiocb)
bdrv_aio_cancel(r->req.aiocb);
r->req.aiocb = NULL;
scsi_req_dequeue(&r->req);
}
}
| 1threat
|
static void nic_cleanup(NetClientState *nc)
{
dp8393xState *s = qemu_get_nic_opaque(nc);
memory_region_del_subregion(s->address_space, &s->mmio);
memory_region_destroy(&s->mmio);
timer_del(s->watchdog);
timer_free(s->watchdog);
g_free(s);
}
| 1threat
|
static void vmxnet3_complete_packet(VMXNET3State *s, int qidx, uint32_t tx_ridx)
{
struct Vmxnet3_TxCompDesc txcq_descr;
PCIDevice *d = PCI_DEVICE(s);
VMXNET3_RING_DUMP(VMW_RIPRN, "TXC", qidx, &s->txq_descr[qidx].comp_ring);
txcq_descr.txdIdx = tx_ridx;
txcq_descr.gen = vmxnet3_ring_curr_gen(&s->txq_descr[qidx].comp_ring);
vmxnet3_ring_write_curr_cell(d, &s->txq_descr[qidx].comp_ring, &txcq_descr);
smp_wmb();
vmxnet3_inc_tx_completion_counter(s, qidx);
vmxnet3_trigger_interrupt(s, s->txq_descr[qidx].intr_idx);
}
| 1threat
|
inserting column in database in kotlin android : I'm facing a problem in inserting column in the database in kotlin android.
I'm programming a note app in kotlin
this the error
> 08-04 19:45:03.781 14302-14302/com.example.hello.note E/Zygote: v2
08-04 19:45:03.781 14302-14302/com.example.hello.note E/Zygote: accessInfo : 0
08-04 19:45:20.471 14302-14302/com.example.hello.note E/Qmage: isQIO : stream is not a QIO file
08-04 19:45:20.521 14302-14302/com.example.hello.note E/Qmage: isQIO : stream is not a QIO file
08-04 19:45:20.531 14302-14302/com.example.hello.note E/Qmage: isQIO : stream is not a QIO file
08-04 19:45:20.541 14302-14302/com.example.hello.note E/MotionRecognitionManager: mSContextService = null
08-04 19:45:20.541 14302-14302/com.example.hello.note E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@78b77
08-04 19:45:47.991 14302-14302/com.example.hello.note E/Qmage: isQIO : stream is not a QIO file
08-04 19:45:47.991 14302-14302/com.example.hello.note E/Qmage: isQIO : stream is not a QIO file
08-04 19:45:47.991 14302-14302/com.example.hello.note E/Qmage: isQIO : stream is not a QIO file
08-04 19:47:40.311 14302-14302/com.example.hello.note E/Qmage: isQIO : stream is not a QIO file
08-04 19:48:14.131 14302-14302/com.example.hello.note E/SQLiteLog: (1) no such table: Notes
08-04 19:48:14.141 14302-14302/com.example.hello.note E/SQLiteDatabase: Error inserting Title=note Desc=desc
android.database.sqlite.SQLiteException: no such table: Notes (code 1): , while compiling: INSERT INTO Notes(Title,Desc) VALUES (?,?)
#################################################################
Error Code : 1 (SQLITE_ERROR)
Caused By : SQL(query) error or missing database.
(no such table: Notes (code 1): , while compiling: INSERT INTO Notes(Title,Desc) VALUES (?,?))
#################################################################
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1004)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:569)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1633)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1505)
at com.example.hello.note.DbManger.Insert(DbManger.kt:40)
at com.example.hello.note.addNotes.buAdd(addNotes.kt:24)
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java:5721)
at android.widget.TextView.performClick(TextView.java:10931)
at android.view.View$PerformClick.run(View.java:22620)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7409)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
and thank you :)
| 0debug
|
static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
Error **errp)
{
VFIOContainer *container;
int ret, fd;
VFIOAddressSpace *space;
space = vfio_get_address_space(as);
QLIST_FOREACH(container, &space->containers, next) {
if (!ioctl(group->fd, VFIO_GROUP_SET_CONTAINER, &container->fd)) {
group->container = container;
QLIST_INSERT_HEAD(&container->group_list, group, container_next);
vfio_kvm_device_add_group(group);
return 0;
fd = qemu_open("/dev/vfio/vfio", O_RDWR);
if (fd < 0) {
error_setg_errno(errp, errno, "failed to open /dev/vfio/vfio");
ret = -errno;
goto put_space_exit;
ret = ioctl(fd, VFIO_GET_API_VERSION);
if (ret != VFIO_API_VERSION) {
error_setg(errp, "supported vfio version: %d, "
"reported version: %d", VFIO_API_VERSION, ret);
ret = -EINVAL;
goto close_fd_exit;
container = g_malloc0(sizeof(*container));
container->space = space;
container->fd = fd;
QLIST_INIT(&container->giommu_list);
QLIST_INIT(&container->hostwin_list);
if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU) ||
ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1v2_IOMMU)) {
bool v2 = !!ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1v2_IOMMU);
struct vfio_iommu_type1_info info;
ret = ioctl(group->fd, VFIO_GROUP_SET_CONTAINER, &fd);
error_setg_errno(errp, errno, "failed to set group container");
ret = -errno;
goto free_container_exit;
container->iommu_type = v2 ? VFIO_TYPE1v2_IOMMU : VFIO_TYPE1_IOMMU;
error_setg_errno(errp, errno, "failed to set iommu for container");
ret = -errno;
goto free_container_exit;
info.argsz = sizeof(info);
ret = ioctl(fd, VFIO_IOMMU_GET_INFO, &info);
if (ret || !(info.flags & VFIO_IOMMU_INFO_PGSIZES)) {
info.iova_pgsizes = 4096;
vfio_host_win_add(container, 0, (hwaddr)-1, info.iova_pgsizes);
} else if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_IOMMU) ||
ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_v2_IOMMU)) {
struct vfio_iommu_spapr_tce_info info;
bool v2 = !!ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_v2_IOMMU);
ret = ioctl(group->fd, VFIO_GROUP_SET_CONTAINER, &fd);
error_setg_errno(errp, errno, "failed to set group container");
ret = -errno;
goto free_container_exit;
container->iommu_type =
v2 ? VFIO_SPAPR_TCE_v2_IOMMU : VFIO_SPAPR_TCE_IOMMU;
error_setg_errno(errp, errno, "failed to set iommu for container");
ret = -errno;
goto free_container_exit;
if (!v2) {
ret = ioctl(fd, VFIO_IOMMU_ENABLE);
error_setg_errno(errp, errno, "failed to enable container");
ret = -errno;
goto free_container_exit;
} else {
container->prereg_listener = vfio_prereg_listener;
memory_listener_register(&container->prereg_listener,
&address_space_memory);
if (container->error) {
memory_listener_unregister(&container->prereg_listener);
ret = container->error;
error_setg(errp,
"RAM memory listener initialization failed for container");
goto free_container_exit;
info.argsz = sizeof(info);
ret = ioctl(fd, VFIO_IOMMU_SPAPR_TCE_GET_INFO, &info);
error_setg_errno(errp, errno,
"VFIO_IOMMU_SPAPR_TCE_GET_INFO failed");
ret = -errno;
if (v2) {
memory_listener_unregister(&container->prereg_listener);
goto free_container_exit;
if (v2) {
ret = vfio_spapr_remove_window(container, info.dma32_window_start);
error_setg_errno(errp, -ret,
"failed to remove existing window");
goto free_container_exit;
} else {
vfio_host_win_add(container, info.dma32_window_start,
info.dma32_window_start +
info.dma32_window_size - 1,
0x1000);
} else {
error_setg(errp, "No available IOMMU models");
ret = -EINVAL;
goto free_container_exit;
vfio_kvm_device_add_group(group);
QLIST_INIT(&container->group_list);
QLIST_INSERT_HEAD(&space->containers, container, next);
group->container = container;
QLIST_INSERT_HEAD(&container->group_list, group, container_next);
container->listener = vfio_memory_listener;
memory_listener_register(&container->listener, container->space->as);
if (container->error) {
ret = container->error;
error_setg_errno(errp, -ret,
"memory listener initialization failed for container");
goto listener_release_exit;
container->initialized = true;
return 0;
listener_release_exit:
QLIST_REMOVE(group, container_next);
QLIST_REMOVE(container, next);
vfio_kvm_device_del_group(group);
vfio_listener_release(container);
free_container_exit:
g_free(container);
close_fd_exit:
close(fd);
put_space_exit:
vfio_put_address_space(space);
return ret;
| 1threat
|
Import Range Into Every Nth Row in Google Sheets : I have a Column of data in one sheet.
I want to copy that Column into *another* sheet, but this one has cells that are merged.
If I do an import range, or a simple formula like ='Sheet'!A1, it will only get some of the data, because the formula doesn't work that specifically.
This image shows the issue and goal:
[Imgur Link][1]
[1]: https://i.stack.imgur.com/n8Ty2.png
| 0debug
|
Select MySQL rows with timestamp older than 12 hours? : <p>In my table <code>monitoring</code>, I want to select the content from the content <code>domain</code>. But I only want to select it for rows where the timestamp on them is older than 12 hours and it should list the oldest entries first.</p>
<p>Here's what I've got so far and need help with:</p>
<pre><code>SELECT domain FROM monitoring WHERE status = 'active' AND WHERE submit_time = '?????' ORDER BY '?????'
</code></pre>
<p>I know there are similar questions posted here about this. However, the answers all seem dependent on the format of your time. Here's how the time is listed in the database:</p>
<pre><code>01-20-2016 23:12:13
</code></pre>
<p>Any help would be appreciated.</p>
| 0debug
|
AndroidX Build Fails in Release Mode regarding appComponentFactory : <p>I'm using Android P and compiling against AndroidX. Works great in debug/beta, but when I make a release I get a cryptic crash during runtime:</p>
<blockquote>
<p>2018-06-24 00:21:26.080 11971-11971/? E/LoadedApk: Unable to
instantiate appComponentFactory
java.lang.ClassNotFoundException: Didn't find class "androidx.core.app.CoreComponentFactory" on path: DexPathList[[zip
file
"/data/app/app.itsyour.elegantstocks-EuVZWdDgzplhm0Hpa90VwA==/base.apk"],nativeLibraryDirectories=[/data/app/app.itsyour.elegantstocks-EuVZWdDgzplhm0Hpa90VwA==/lib/x86,
/system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:126)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.LoadedApk.createAppFactory(LoadedApk.java:226)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:731)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:772)
at android.app.LoadedApk.getResources(LoadedApk.java:994)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2345)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5736)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1634)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6642)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
2018-06-24 00:21:26.145 1667-1854/? E/SurfaceFlinger:
ro.sf.lcd_density must be defined as a build property 2018-06-24
00:21:26.233 1667-1703/? E/SurfaceFlinger: ro.sf.lcd_density must be
defined as a build property 2018-06-24 00:21:29.627 1796-1913/?
E/TaskPersister: File error accessing recents directory (directory
doesn't exist?). 2018-06-24 00:21:30.087 11971-11971/?
E/AndroidRuntime: FATAL EXCEPTION: main
Process: app.itsyour.elegantstocks, PID: 11971
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method c.d.b.h.b, parameter $receiver
at app.itsyour.elegantstocks.a.b.a(Unknown Source:2)
at app.itsyour.elegantstocks.feature.navigator.b.a$a.a(Unknown Source:24)
at app.itsyour.elegantstocks.feature.navigator.b.a.a(Unknown Source:13)
at app.itsyour.elegantstocks.feature.navigator.b.a.a(Unknown Source:2)
at androidx.recyclerview.widget.RecyclerView$a.a(Unknown Source:0)
at androidx.recyclerview.widget.RecyclerView$a.b(Unknown Source:29)
at androidx.recyclerview.widget.RecyclerView$p.a(Unknown Source:39)
at androidx.recyclerview.widget.RecyclerView$p.a(Unknown Source:510)
at androidx.recyclerview.widget.RecyclerView$p.a(Unknown Source:5)
at androidx.recyclerview.widget.RecyclerView$p.c(Unknown Source:1)
at androidx.recyclerview.widget.LinearLayoutManager$c.a(Unknown
Source:11)
at androidx.recyclerview.widget.LinearLayoutManager.a(Unknown Source:0)
at androidx.recyclerview.widget.LinearLayoutManager.a(Unknown Source:44)
at androidx.recyclerview.widget.LinearLayoutManager.c(Unknown Source:371)
at androidx.recyclerview.widget.RecyclerView.O(Unknown Source:42)
at androidx.recyclerview.widget.RecyclerView.q(Unknown Source:41)
at androidx.recyclerview.widget.RecyclerView.onLayout(Unknown Source:5)
at android.view.View.layout(View.java:20670)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20670)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at androidx.constraintlayout.widget.ConstraintLayout.onLayout(Unknown
Source:66)
at android.view.View.layout(View.java:20670)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20670)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at androidx.swiperefreshlayout.widget.SwipeRefreshLayout.onLayout(Unknown
Source:60)
at android.view.View.layout(View.java:20670)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at androidx.coordinatorlayout.widget.CoordinatorLayout.d(Unknown
Source:143)
at androidx.coordinatorlayout.widget.CoordinatorLayout.a(Unknown
Source:32)
at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout(Unknown
Source:48)
at android.view.View.layout(View.java:20670)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20670)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
at android.view.View.layout(View.java:20670)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20670)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
at android.view.View.layout(View.java:20670)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:753)
at android.view.View.layout(View.java:20670) 2018-06-24 00:21:30.087 11971-11971/? E/AndroidRuntime: at
android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2767)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2294)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1447)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7130)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:935)
at android.view.Choreographer.doCallbacks(Choreographer.java:747)
at android.view.Choreographer.doFrame(Choreographer.java:682)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:921)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6642)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
2018-06-24 00:21:30.137 1796-1880/? E/InputDispatcher: channel
'5896582
app.itsyour.elegantstocks/app.itsyour.elegantstocks.feature.navigator.NavigatorActivity
(server)' ~ Channel is unrecoverably broken and will be disposed!
2018-06-24 00:21:30.253 5198-9377/? E/EntrySyncManager: Cannot
determine account name: drop request 2018-06-24 00:21:30.253
5198-9377/? E/NowController: Failed to access data from EntryProvider.
ExecutionException.
java.util.concurrent.ExecutionException: com.google.android.apps.gsa.sidekick.main.h.n: Could not complete
scheduled request to refresh entries. ClientErrorCode: 3
at com.google.common.util.concurrent.d.eA(SourceFile:85)
at com.google.common.util.concurrent.d.get(SourceFile:23)
at com.google.common.util.concurrent.l.get(SourceFile:2)
at com.google.android.apps.gsa.staticplugins.nowstream.b.a.be.caI(SourceFile:47)
at com.google.android.apps.gsa.staticplugins.nowstream.b.a.be.caH(SourceFile:176)
at com.google.android.apps.gsa.staticplugins.nowstream.b.a.bh.run(Unknown
Source:2)
at com.google.android.apps.gsa.shared.util.concurrent.at.run(SourceFile:4)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at com.google.android.apps.gsa.shared.util.concurrent.b.g.run(Unknown
Source:4)
at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4)
at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
at com.google.android.apps.gsa.shared.util.concurrent.b.i.run(SourceFile:6)
Caused by: com.google.android.apps.gsa.sidekick.main.h.n: Could not complete scheduled request to refresh entries. ClientErrorCode: 3
at com.google.android.apps.gsa.staticplugins.nowstream.b.a.aq.az(Unknown
Source:4)
at com.google.common.util.concurrent.q.ap(SourceFile:7)
at com.google.common.util.concurrent.p.run(SourceFile:32)
at com.google.common.util.concurrent.bt.execute(SourceFile:3)
at com.google.common.util.concurrent.d.b(SourceFile:275)
at com.google.common.util.concurrent.d.addListener(SourceFile:135)
at com.google.common.util.concurrent.p.b(SourceFile:3)
at com.google.android.apps.gsa.shared.util.concurrent.h.a(SourceFile:16)
at com.google.android.apps.gsa.shared.util.concurrent.h.a(SourceFile:13)
at com.google.android.apps.gsa.staticplugins.nowstream.b.a.be.caI(SourceFile:45)
at com.google.android.apps.gsa.staticplugins.nowstream.b.a.be.caH(SourceFile:176)
at com.google.android.apps.gsa.staticplugins.nowstream.b.a.bh.run(Unknown
Source:2)
at com.google.android.apps.gsa.shared.util.concurrent.at.run(SourceFile:4)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at com.google.android.apps.gsa.shared.util.concurrent.b.g.run(Unknown
Source:4)
at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4)
at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
at com.google.android.apps.gsa.shared.util.concurrent.b.i.run(SourceFile:6)</p>
</blockquote>
<p>My gradle files.
Project gradle:</p>
<pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules.
ext {
androidXVersion = '1.0.0-alpha3'
supportLibraryVersion = '28.0.0-alpha1'
}
buildscript {
ext.kotlin_version = '1.2.50'
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-beta01'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects
{
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
</code></pre>
<p>App gradle:</p>
<pre><code>apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
def versionMajor = 1
def versionMinor = 0
def versionPatch = project.hasProperty('buildNumber') ? project.getProperties().get('buildNumber').toInteger() : 0
android {
compileSdkVersion 28
defaultConfig {
applicationId "app.itsyour.elegantstocks"
minSdkVersion 25
targetSdkVersion 28
// Version
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
versionCode versionMajor * 1000000 * versionMinor * 10000 + versionPatch
resValue "string", "build_number", "Version ${versionName}"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
kapt {
arguments {
arg("room.schemaLocation", "$projectDir/schemas".toString())
}
}
}
buildTypes {
release {
resValue "string", "app_name", "Elegant Stocks"
signingConfig signingConfigs.release
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-release.pro'
}
staging {
resValue "string", "app_name", "Elegant Stocks"
signingConfig signingConfigs.staging
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-staging.pro'
}
beta {
signingConfig signingConfigs.beta
debuggable true
minifyEnabled false
applicationIdSuffix ".beta"
versionNameSuffix "-BETA"
resValue "string", "app_name", "Elegant Stocks Beta"
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-beta.pro'
}
debug {
debuggable true
minifyEnabled false
resValue "string", "app_name", "Elegant Stocks Debug"
applicationIdSuffix ".debug"
versionNameSuffix = "-DEBUG"
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
testOptions {
unitTests {
includeAndroidResources = true
all {
testLogging {
events "passed", "failed", "skipped"
}
}
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.appcompat:appcompat:$androidXVersion"
implementation "androidx.fragment:fragment-ktx:$androidXVersion"
implementation "com.google.android.material:material:$androidXVersion"
implementation "androidx.recyclerview:recyclerview:$androidXVersion"
implementation "androidx.core:core-ktx:$androidXVersion"
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
// Dagger 2
implementation 'com.google.dagger:dagger:2.16'
implementation 'com.google.dagger:dagger-android:2.16'
implementation 'com.google.dagger:dagger-android-support:2.16'
kapt 'com.google.dagger:dagger-compiler:2.16'
kapt 'com.google.dagger:dagger-android-processor:2.16'
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
// Stetho
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'
// Rx
implementation 'io.reactivex.rxjava2:rxjava:2.1.13'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxkotlin:2.2.0'
implementation 'com.jakewharton.rxbinding2:rxbinding-kotlin:2.1.1'
implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7-kotlin:2.1.1'
implementation 'com.jakewharton.rx2:replaying-share:2.0.1'
// Room
implementation "androidx.room:room-runtime:2.0.0-alpha1"
implementation "androidx.room:room-rxjava2:2.0.0-alpha1"
kapt "androidx.room:room-compiler:2.0.0-alpha1"
// Logging
implementation 'com.jakewharton.timber:timber:4.7.0'
// Time
implementation 'com.jakewharton.threetenabp:threetenabp:1.1.0'
// UI
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation 'net.opacapp:multiline-collapsingtoolbar:27.1.1'
implementation 'com.balysv:material-ripple:1.0.2'
// Testing
androidTestImplementation "com.android.support.test:runner:1.0.2"
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
testImplementation 'junit:junit:4.12'
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:${kotlin_version}"
testImplementation "com.nhaarman:mockito-kotlin-kt1.1:1.5.0"
testImplementation "org.mockito:mockito-core:2.18.3"
testImplementation "org.robolectric:robolectric:3.8"
testImplementation "org.robolectric:shadows-multidex:3.8"
}
</code></pre>
<p>Proguard:</p>
<pre><code># Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn org.codehaus.mojo.animal_sniffer.**
-dontwarn javax.annotation.**
-dontwarn org.conscrypt.**
</code></pre>
| 0debug
|
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
| 1threat
|
Javascript Ad Banner Rotator for my website? : <p>I have a website that I want to rotate my affiliate links on a stream player that I have created. I have searched everywhere for a script but can not find one. I am not trying to use a service that does it for me. I want to script it myself. Any suggestions?</p>
| 0debug
|
static void scsi_dma_complete_noio(SCSIDiskReq *r, int ret)
{
assert(r->req.aiocb == NULL);
if (r->req.io_canceled) {
scsi_req_cancel_complete(&r->req);
goto done;
}
if (ret < 0) {
if (scsi_handle_rw_error(r, -ret, false)) {
goto done;
}
}
r->sector += r->sector_count;
r->sector_count = 0;
if (r->req.cmd.mode == SCSI_XFER_TO_DEV) {
scsi_write_do_fua(r);
return;
} else {
scsi_req_complete(&r->req, GOOD);
}
done:
scsi_req_unref(&r->req);
}
| 1threat
|
static void h264_h_loop_filter_chroma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
{
h264_loop_filter_chroma_c(pix, 1, stride, alpha, beta, tc0);
}
| 1threat
|
How to Submit generic "runtime.Object" to Kubernetes API using client-go : <p>I'm using AWS' EKS which is Kubernetes v1.10 and I'm using client-go v7.0.0.</p>
<p>What I'm trying to do is parse a .yml file with multiple Kubernetes resource definitions in a file and submit those resources to the Kubernetes API. I can successfully parse the files using this code <code>scheme.Codecs.UniversalDeserializer().Decode</code>, and I get back an array of <code>runtime.Object</code>.</p>
<p>I know that all the Kubernetes resources conform to the <code>runtime.Object</code> interface, but I can't find a way to submit the generic interface to the API. Most methods I've seen use the methods on the concrete types like Deployment, Pod, etc.</p>
<p>I've seen some code around a generic RESTClient like this <code>clientset.RESTClient().Put().Body(obj).Do()</code>, but that doesn't work and I can't figure it out.</p>
<p>I know my clientset is configured correctly because I can successfully list all Pods.</p>
| 0debug
|
Find text and show value iif condition is met : Can someone help me a little bit. Picture is attached.
What I need is a code that will find "TOTAL PURCHASE" that has offset(-9)="USD" and then in cell D1 show the value of 100.
[1] https://imgur.com/a/oa0n0
| 0debug
|
Js, function not working : <pre><code>`var y = 0 ;
var x = 0;
function atm(num1, num2){
console.log((num1 - num2));
return num1 - num2 ;
}
var items =[1,2,3,4,5,6,7,8,9,10];
function vm(y, x){
if( atm(y , items[x]) < 0 ){
result = "U Do not have enough money to pay";
}
else if ( atm(y , items[x]) === 0 );{
result = "Ur money just matches the required paying fee";
}
if ( atm(y , items[x]) > 0 );{
result="U will reserve atm(y, items[x]) as a remainder";
}
}
vm(2, 3);`
</code></pre>
<p>**the error is that it gives me 3 answers as u can see:
\\
-2</p>
<p>"U Do not have enough money to pay"</p>
<p>"Ur money just matches the required paying fee"</p>
<p>-2</p>
<p>"U will reserve atm(y, items[x]) as a remainder"
\\</p>
<p>\\
also the 3rd result " result="U will reserve atm(y, items[x]) as a remainder" " wont show the remainder</p>
<p>"y goes to the amount of money u hold"</p>
<p>"x goes to the number of items from array"</p>
<p>vm is the vending machine and what it should do is show 1 answer of these up </p>
<p>1- u do not have enough money to pay</p>
<p>2- Ur money just matches the required paying fee</p>
<p>3- is that he has more money and he will reserve " y - items[x] " as remainder</p>
<p><strong>Please when u got my error write me the error and the full code, sometimes it gets hard on me, im still new...</strong></p>
| 0debug
|
How to assign values to Nested Json array : <p>I am using C#. I want the Json array in the below structure</p>
<pre><code>"bed_configurations": [
[{
"type": "standard",
"code": 3,
"count": 1
},
{
"type": "custom",
"name": "Loft",
"count": 1
}]
]
</code></pre>
<p>Please any one can help me..</p>
| 0debug
|
static int h261_decode_gob(H261Context *h){
MpegEncContext * const s = &h->s;
int v;
ff_set_qscale(s, s->qscale);
v= show_bits(&s->gb, 15);
if(get_bits_count(&s->gb) + 15 > s->gb.size_in_bits){
v>>= get_bits_count(&s->gb) + 15 - s->gb.size_in_bits;
}
if(v==0){
h261_decode_mb_skipped(h, 0, 33);
return 0;
}
while(h->current_mba <= MAX_MBA)
{
int ret;
ret= h261_decode_mb(h, s->block);
if(ret<0){
const int xy= s->mb_x + s->mb_y*s->mb_stride;
if(ret==SLICE_END){
MPV_decode_mb(s, s->block);
if(h->loop_filter){
ff_h261_loop_filter(h);
}
h->loop_filter = 0;
h261_decode_mb_skipped(h, h->current_mba-h->mba_diff, h->current_mba-1);
h261_decode_mb_skipped(h, h->current_mba, 33);
return 0;
}else if(ret==SLICE_NOEND){
av_log(s->avctx, AV_LOG_ERROR, "Slice mismatch at MB: %d\n", xy);
return -1;
}
av_log(s->avctx, AV_LOG_ERROR, "Error at MB: %d\n", xy);
return -1;
}
MPV_decode_mb(s, s->block);
if(h->loop_filter){
ff_h261_loop_filter(h);
}
h->loop_filter = 0;
h261_decode_mb_skipped(h, h->current_mba-h->mba_diff, h->current_mba-1);
}
return -1;
}
| 1threat
|
Random button generator needs fixing. Any help would be very much appreciated : My web page:
-http://www.theeventlister.com/landingpage/events/uk/boardmasters.html
Okay so on this website, I have a random button generator, named 'next event'. The button is okay however needs an improvement. Sometimes this button loads the same page the user is on multiple times, I'm not sure how to edit this, this is my code.
my code:
var sites = [
'http://www.theeventlister.com/landingpage/events/uk/boardmasters.html',
'http://www.theeventlister.com/landingpage/events/uk/reading.html',
'http://www.theeventlister.com/landingpage/events/uk/rizefest.html',
'http://www.theeventlister.com/landingpage/events/uk/bestival.html',
'http://www.theeventlister.com/landingpage/events/uk/creamfields.html',
'http://www.theeventlister.com/landingpage/events/uk/feastival.html',
'http://www.theeventlister.com/landingpage/events/uk/fusion.html',
];
function randomSite() {
var i = parseInt(Math.random() * sites.length);
location.href = sites[i];
}
Thank you!
| 0debug
|
static void sigchld_bh_handler(void *opaque)
{
ChildProcessRecord *rec, *next;
QLIST_FOREACH_SAFE(rec, &child_watches, next, next) {
if (waitpid(rec->pid, NULL, WNOHANG) == rec->pid) {
QLIST_REMOVE(rec, next);
g_free(rec);
}
}
}
| 1threat
|
Issues iterating through JSON list in Python? : <p>I have a file with JSON data in it, like so:</p>
<pre><code>{
"Results": [
{"Id": "001",
"Name": "Bob",
"Items": {
"Cars": "1",
"Books": "3",
"Phones": "1"}
},
{"Id": "002",
"Name": "Tom",
"Items": {
"Cars": "1",
"Books": "3",
"Phones": "1"}
},
{"Id": "003",
"Name": "Sally",
"Items": {
"Cars": "1",
"Books": "3",
"Phones": "1"}
}]
}
</code></pre>
<p>I can not figure out how to properly loop through the JSON. I would like to loop through the data and get a Name with the Cars for each member in the dataset. How can I accomplish this?</p>
<pre><code>import json
with open('data.json') as data_file:
data = json.load(data_file)
print data["Results"][0]["Name"] # Gives me a name for the first entry
print data["Results"][0]["Items"]["Cars"] # Gives me the number of cars for the first entry
</code></pre>
<p>I have tried looping through them with:</p>
<pre><code>for i in data["Results"]:
print data["Results"][i]["Name"]
</code></pre>
<p>But recieve an error:
<strong>TypeError: list indices must be integers, not dict</strong></p>
| 0debug
|
static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
{
char *pix_fmts;
OutputStream *ost = ofilter->ost;
AVCodecContext *codec = ost->st->codec;
AVFilterContext *last_filter = out->filter_ctx;
int pad_idx = out->pad_idx;
int ret;
char name[255];
snprintf(name, sizeof(name), "output stream %d:%d", ost->file_index, ost->index);
ret = avfilter_graph_create_filter(&ofilter->filter,
avfilter_get_by_name("buffersink"),
name, NULL, pix_fmts, fg->graph);
if (ret < 0)
return ret;
if (codec->width || codec->height) {
char args[255];
AVFilterContext *filter;
snprintf(args, sizeof(args), "%d:%d:flags=0x%X",
codec->width,
codec->height,
(unsigned)ost->sws_flags);
snprintf(name, sizeof(name), "scaler for output stream %d:%d",
ost->file_index, ost->index);
if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"),
name, args, NULL, fg->graph)) < 0)
return ret;
if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
return ret;
last_filter = filter;
pad_idx = 0;
}
if ((pix_fmts = choose_pix_fmts(ost))) {
AVFilterContext *filter;
snprintf(name, sizeof(name), "pixel format for output stream %d:%d",
ost->file_index, ost->index);
if ((ret = avfilter_graph_create_filter(&filter,
avfilter_get_by_name("format"),
"format", pix_fmts, NULL,
fg->graph)) < 0)
return ret;
if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
return ret;
last_filter = filter;
pad_idx = 0;
av_freep(&pix_fmts);
}
if (ost->frame_rate.num) {
AVFilterContext *fps;
char args[255];
snprintf(args, sizeof(args), "fps=%d/%d", ost->frame_rate.num,
ost->frame_rate.den);
snprintf(name, sizeof(name), "fps for output stream %d:%d",
ost->file_index, ost->index);
ret = avfilter_graph_create_filter(&fps, avfilter_get_by_name("fps"),
name, args, NULL, fg->graph);
if (ret < 0)
return ret;
ret = avfilter_link(last_filter, pad_idx, fps, 0);
if (ret < 0)
return ret;
last_filter = fps;
pad_idx = 0;
}
if ((ret = avfilter_link(last_filter, pad_idx, ofilter->filter, 0)) < 0)
return ret;
return 0;
}
| 1threat
|
Check that if-statement was true several times at a stretch : I have a loop
count = 0;
do
{
...
if (statement)
count++;
...
} while (count != 3);
How to check that if statement was true three times at a stretch?
| 0debug
|
What is the better and secure way to login and logout in PHP? : <p>I'm a beginner in PHP. my login page is a <strong><em>login.html</em></strong> page and it posts inputted data to a <strong><em>logged.php</em></strong> page. and in this page it checks inputted data with my DB and if it was true, it showed this <strong><em>logedd.php</em></strong> page or if not, it returns to <strong><em>login.html</em></strong> page with the code below:</p>
<pre><code>header('Location:Login.html');
</code></pre>
<p>and also when I press Logout icon in <strong><em>logged.php</em></strong>, it returns to <strong><em>login.html</em></strong> by a href link in it. like this:</p>
<pre><code><a href="login.php" target="_self"> press to logout </a>
</code></pre>
<p>Now my question is, Is this login and logout way secure or not? if not please describe why and how to make it secure? thanks.</p>
| 0debug
|
Finding remaining months from given Ruby Array : I am building a tax calculation system in Ruby. In our country fiscal year starts from 4th month of the year. I need to calculate the number of remaining months from the given month. For example I have the array
months = [4,5,6,7,8,9,10,11,12,1,2,3]
Now If I give input 4 it should return 11, if 10 it should return 5.
But the problem is that if 2 is given it should return 1 and even if 3 is given it should return 1 because if it returns 0 if 3 is given, the calculation has multiplication and whole expression becomes 0. So I need 1 when 2 and 3 is given.
How I solved for now is
@month == 3 ? annual_taxable_income += total_monthly_income_present_month : annual_taxable_income += total_monthly_income_present_month + @basic_salary * fiscal_months_array[@month-3, 12].size
The idea is I used ternary operator to check if there is 3 and if there is then do not find remaining months. The solution is working but I need a better way to do this so someone won't laugh looking at the code lol. Sorry if question is little dumb.
| 0debug
|
int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan)
{
TAPState *s;
int fd, vnet_hdr = 0;
if (qemu_opt_get(opts, "fd")) {
if (qemu_opt_get(opts, "ifname") ||
qemu_opt_get(opts, "script") ||
qemu_opt_get(opts, "downscript") ||
qemu_opt_get(opts, "vnet_hdr")) {
qemu_error("ifname=, script=, downscript= and vnet_hdr= is invalid with fd=\n");
return -1;
}
fd = net_handle_fd_param(mon, qemu_opt_get(opts, "fd"));
if (fd == -1) {
return -1;
}
fcntl(fd, F_SETFL, O_NONBLOCK);
vnet_hdr = tap_probe_vnet_hdr(fd);
} else {
if (!qemu_opt_get(opts, "script")) {
qemu_opt_set(opts, "script", DEFAULT_NETWORK_SCRIPT);
}
if (!qemu_opt_get(opts, "downscript")) {
qemu_opt_set(opts, "downscript", DEFAULT_NETWORK_DOWN_SCRIPT);
}
fd = net_tap_init(opts, &vnet_hdr);
if (fd == -1) {
return -1;
}
}
s = net_tap_fd_init(vlan, "tap", name, fd, vnet_hdr);
if (!s) {
close(fd);
return -1;
}
if (tap_set_sndbuf(s->fd, opts) < 0) {
return -1;
}
if (qemu_opt_get(opts, "fd")) {
snprintf(s->nc.info_str, sizeof(s->nc.info_str), "fd=%d", fd);
} else {
const char *ifname, *script, *downscript;
ifname = qemu_opt_get(opts, "ifname");
script = qemu_opt_get(opts, "script");
downscript = qemu_opt_get(opts, "downscript");
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
"ifname=%s,script=%s,downscript=%s",
ifname, script, downscript);
if (strcmp(downscript, "no") != 0) {
snprintf(s->down_script, sizeof(s->down_script), "%s", downscript);
snprintf(s->down_script_arg, sizeof(s->down_script_arg), "%s", ifname);
}
}
if (vlan) {
vlan->nb_host_devs++;
}
return 0;
}
| 1threat
|
I want to open a page when a button is pressed in React js : I am creating a function in react js where a user will be redirected to the dashboard when he click sign in.
handleSubmit(){
this.props.history.push('/blog-overview');
}
When i click on the button, the page is refreshed rather than redirecting to that path specified.
| 0debug
|
How to extend String Prototype and use it next, in Typescript? : <p>I am extending String prototype chain with a new method but when I try to use it it throws me an error: <code>property 'padZero' does not exist on type 'string'</code>. Could anyone solve this for me?</p>
<p>The code is below. You can also see the same error in Typescript Playground.</p>
<pre><code>interface NumberConstructor {
padZero(length: number);
}
interface StringConstructor {
padZero(length: number): string;
}
String.padZero = (length: number) => {
var s = this;
while (s.length < length) {
s = '0' + s;
}
return s;
};
Number.padZero = function (length) {
return String(this).padZero(length);
}
</code></pre>
| 0debug
|
void virtio_queue_set_notification(VirtQueue *vq, int enable)
{
vq->notification = enable;
if (vq->vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX)) {
vring_avail_event(vq, vring_avail_idx(vq));
} else if (enable) {
vring_used_flags_unset_bit(vq, VRING_USED_F_NO_NOTIFY);
} else {
vring_used_flags_set_bit(vq, VRING_USED_F_NO_NOTIFY);
| 1threat
|
static int ffm_write_packet(AVFormatContext *s, int stream_index,
UINT8 *buf, int size, int force_pts)
{
AVStream *st = s->streams[stream_index];
FFMStream *fst = st->priv_data;
INT64 pts;
UINT8 header[FRAME_HEADER_SIZE];
int duration;
if (st->codec.codec_type == CODEC_TYPE_AUDIO) {
duration = ((float)st->codec.frame_size / st->codec.sample_rate * 1000000.0);
} else {
duration = (1000000.0 * FRAME_RATE_BASE / (float)st->codec.frame_rate);
}
pts = fst->pts;
header[0] = stream_index;
header[1] = 0;
if (st->codec.coded_picture->key_frame)
header[1] |= FLAG_KEY_FRAME;
header[2] = (size >> 16) & 0xff;
header[3] = (size >> 8) & 0xff;
header[4] = size & 0xff;
header[5] = (duration >> 16) & 0xff;
header[6] = (duration >> 8) & 0xff;
header[7] = duration & 0xff;
ffm_write_data(s, header, FRAME_HEADER_SIZE, pts, 1);
ffm_write_data(s, buf, size, pts, 0);
fst->pts += duration;
return 0;
}
| 1threat
|
Python - What are some Alternatives to enumerate function. : I have a question I need to solve using python, using a def function. Basically take a list of numbers, and then and add a letter at the end of each element in the list.
I was finally able to do it, but for various reasons I need to find an alternative way that does not use enumerate. Is there any way to make this work without using enumerate function, something simpler. here is my working code.
def addletter( mylist ):
for index, item in enumerate(mylist):
mylist[index] = str(item)
for i in range(len(mylist)):
mylist[i] = mylist[i] + randomletter
return
# Now you can call addletter function
mylist = [1,2,3,4,5,6,7,8,9,];
randomletter= 'a'
addletter( mylist );
print (mylist)
| 0debug
|
Convert std::chrono::system_clock::time_point to struct timeval and back : <p>I´m writing a C++ code that needs to access an old C library that uses timeval as a representation of the current time.</p>
<p>In the old package to get the current date/time we used:</p>
<pre><code>struct timeval dateTime;
gettimeofday(&dateTime, NULL);
function(dateTime); // The function will do its task
</code></pre>
<p>Now I need to use C++ chrono, something as:</p>
<pre><code> system_clock::time_point now = system_clock::now();
struct timeval dateTime;
dateTime.tv_sec = ???? // Help appreaciated here
dateTime.tv_usec = ???? // Help appreaciated here
function(dateTime);
</code></pre>
<p>Later in code I need the way back, building a <code>time_point</code> variable from the returned <code>struct timeval</code>:</p>
<pre><code> struct timeval dateTime;
function(&dateTime);
system_clock::time_point returnedDateTime = ?? // Help appreacited
</code></pre>
<p>I´m using C++11. </p>
| 0debug
|
How to create a 2D Array list in Android Studio? : Looking at a few articles on here i learned that To declare a 2D array in android studio you must do something like
String[][] stations=new String[1][10];
And to insert data into the 2D array i just created I Did This
stations[1][0]= "New York";
stations[2][0]= "Boston";
stations[3][0]= "Las Vegas";
stations[4][0]= "Miami";
stations[5][0]= "Chicago";
stations[6][0]= "New England";
stations[7][0]= "Detroit";
stations[8][0]= "Michigan";
stations[9][0]= "Austin";
When I run this i get the error message
Unfortunately DB Has Stopped
And so I decided to comment out the code where I coped the strings into the arrays and the app ran perfectly.
What am i doing wrong with these assignment operations?
Heres my source code:
public class MainActivity extends AppCompatActivity {
Button trainSearch;
String[][] stations=new String[1][10];
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
trainSearch=(Button)findViewById(R.id.button);
trainSearch.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
search();
}
});
}
public void search()
{
Toast.makeText(MainActivity.this, "function called Successfully", Toast.LENGTH_SHORT).show();
/*stations[1][0]= "New York";
stations[2][0]= "Boston";
stations[3][0]= "Las Vegas";
stations[4][0]= "Miami";
stations[5][0]= "Chicago";
stations[6][0]= "New England";
stations[7][0]= "Detroit";
stations[8][0]= "Michigan";
stations[9][0]= "Austin";*/
SQLiteDatabase db = openOrCreateDatabase( "Train_list.db", SQLiteDatabase.CREATE_IF_NECESSARY , null);
try{
String query = "CREATE TABLE IF NOT EXISTS Stations ("
+ "Station_name VARCHAR);";
db.execSQL(query);
Toast.makeText(MainActivity.this, "Table created", Toast.LENGTH_LONG).show();
/*int i=0;
for(i=0;i<10;i++)
{
query = "INSERT or replace INTO stations (Station_name) VALUES(" + stations[0][i] + ");";
db.execSQL(query);
Toast.makeText(MainActivity.this, "Added Staation"+stations[0][i], Toast.LENGTH_SHORT).show();
}*/
}catch (Exception e){
Toast.makeText(MainActivity.this, "An Error has occured", Toast.LENGTH_SHORT).show();
}
}
public void calladminactivity(View v)
{
startActivity(new Intent(MainActivity.this, adminlogin.class));
}
}
| 0debug
|
static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,
AVPacket *pkt) {
int chunk_type;
if (s->audio_chunk_offset && s->audio_channels && s->audio_bits) {
if (s->audio_type == AV_CODEC_ID_NONE) {
av_log(s->avf, AV_LOG_ERROR, "Can not read audio packet before"
"audio codec is known\n");
return CHUNK_BAD;
}
if (s->audio_type != AV_CODEC_ID_INTERPLAY_DPCM) {
s->audio_chunk_offset += 6;
s->audio_chunk_size -= 6;
}
avio_seek(pb, s->audio_chunk_offset, SEEK_SET);
s->audio_chunk_offset = 0;
if (s->audio_chunk_size != av_get_packet(pb, pkt, s->audio_chunk_size))
return CHUNK_EOF;
pkt->stream_index = s->audio_stream_index;
pkt->pts = s->audio_frame_count;
if (s->audio_type != AV_CODEC_ID_INTERPLAY_DPCM)
s->audio_frame_count +=
(s->audio_chunk_size / s->audio_channels / (s->audio_bits / 8));
else
s->audio_frame_count +=
(s->audio_chunk_size - 6 - s->audio_channels) / s->audio_channels;
av_log(s->avf, AV_LOG_TRACE, "sending audio frame with pts %"PRId64" (%d audio frames)\n",
pkt->pts, s->audio_frame_count);
chunk_type = CHUNK_VIDEO;
} else if (s->decode_map_chunk_offset) {
if (av_new_packet(pkt, 2 + s->decode_map_chunk_size + s->video_chunk_size))
return CHUNK_NOMEM;
if (s->has_palette) {
uint8_t *pal;
pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE,
AVPALETTE_SIZE);
if (pal) {
memcpy(pal, s->palette, AVPALETTE_SIZE);
s->has_palette = 0;
}
}
if (s->changed) {
ff_add_param_change(pkt, 0, 0, 0, s->video_width, s->video_height);
s->changed = 0;
}
pkt->pos= s->decode_map_chunk_offset;
avio_seek(pb, s->decode_map_chunk_offset, SEEK_SET);
s->decode_map_chunk_offset = 0;
AV_WL16(pkt->data, s->decode_map_chunk_size);
if (avio_read(pb, pkt->data + 2, s->decode_map_chunk_size) !=
s->decode_map_chunk_size) {
av_packet_unref(pkt);
return CHUNK_EOF;
}
avio_seek(pb, s->video_chunk_offset, SEEK_SET);
s->video_chunk_offset = 0;
if (avio_read(pb, pkt->data + 2 + s->decode_map_chunk_size,
s->video_chunk_size) != s->video_chunk_size) {
av_packet_unref(pkt);
return CHUNK_EOF;
}
pkt->stream_index = s->video_stream_index;
pkt->pts = s->video_pts;
av_log(s->avf, AV_LOG_TRACE, "sending video frame with pts %"PRId64"\n", pkt->pts);
s->video_pts += s->frame_pts_inc;
chunk_type = CHUNK_VIDEO;
} else {
avio_seek(pb, s->next_chunk_offset, SEEK_SET);
chunk_type = CHUNK_DONE;
}
return chunk_type;
}
| 1threat
|
static inline void RENAME(rgb32tobgr16)(const uint8_t *src, uint8_t *dst, unsigned int src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
mm_end = end - 15;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psllq $8, %%mm0\n\t"
"psllq $8, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $19, %%mm2\n\t"
"psrlq $19, %%mm5\n\t"
"pand %2, %%mm2\n\t"
"pand %2, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_16mask):"memory");
d += 4;
s += 16;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
const int src= *s; s += 4;
*d++ = ((src&0xF8)<<8) + ((src&0xFC00)>>5) + ((src&0xF80000)>>19);
}
}
| 1threat
|
static int oss_init_out (HWVoiceOut *hw, struct audsettings *as)
{
OSSVoiceOut *oss = (OSSVoiceOut *) hw;
struct oss_params req, obt;
int endianness;
int err;
int fd;
audfmt_e effective_fmt;
struct audsettings obt_as;
oss->fd = -1;
req.fmt = aud_to_ossfmt (as->fmt, as->endianness);
req.freq = as->freq;
req.nchannels = as->nchannels;
req.fragsize = conf.fragsize;
req.nfrags = conf.nfrags;
if (oss_open (0, &req, &obt, &fd)) {
return -1;
}
err = oss_to_audfmt (obt.fmt, &effective_fmt, &endianness);
if (err) {
oss_anal_close (&fd);
return -1;
}
obt_as.freq = obt.freq;
obt_as.nchannels = obt.nchannels;
obt_as.fmt = effective_fmt;
obt_as.endianness = endianness;
audio_pcm_init_info (&hw->info, &obt_as);
oss->nfrags = obt.nfrags;
oss->fragsize = obt.fragsize;
if (obt.nfrags * obt.fragsize & hw->info.align) {
dolog ("warning: Misaligned DAC buffer, size %d, alignment %d\n",
obt.nfrags * obt.fragsize, hw->info.align + 1);
}
hw->samples = (obt.nfrags * obt.fragsize) >> hw->info.shift;
oss->mmapped = 0;
if (conf.try_mmap) {
oss->pcm_buf = mmap (
NULL,
hw->samples << hw->info.shift,
PROT_READ | PROT_WRITE,
MAP_SHARED,
fd,
0
);
if (oss->pcm_buf == MAP_FAILED) {
oss_logerr (errno, "Failed to map %d bytes of DAC\n",
hw->samples << hw->info.shift);
}
else {
int err;
int trig = 0;
if (ioctl (fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
oss_logerr (errno, "SNDCTL_DSP_SETTRIGGER 0 failed\n");
}
else {
trig = PCM_ENABLE_OUTPUT;
if (ioctl (fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
oss_logerr (
errno,
"SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed\n"
);
}
else {
oss->mmapped = 1;
}
}
if (!oss->mmapped) {
err = munmap (oss->pcm_buf, hw->samples << hw->info.shift);
if (err) {
oss_logerr (errno, "Failed to unmap buffer %p size %d\n",
oss->pcm_buf, hw->samples << hw->info.shift);
}
}
}
}
if (!oss->mmapped) {
oss->pcm_buf = audio_calloc (
AUDIO_FUNC,
hw->samples,
1 << hw->info.shift
);
if (!oss->pcm_buf) {
dolog (
"Could not allocate DAC buffer (%d samples, each %d bytes)\n",
hw->samples,
1 << hw->info.shift
);
oss_anal_close (&fd);
return -1;
}
}
oss->fd = fd;
return 0;
}
| 1threat
|
SonarQube Runner vs Scanner : <p>What is the difference btw Sonar Runner and Sonar Scanner?.</p>
<p>And which version of "Sonarqube" and Sonar runner is required for JDK7?</p>
| 0debug
|
HTML <a herf link does not work : So i wanted to create link to YouTube, but it does not work when i click on the text nothing hapens. Here is the code:
<div>
<p>Source to <a herf="https://www.youtube.com/">
<span style="clolor:red">Youtube</span></a>.</p>
</div>
Thanks for answers
| 0debug
|
static uint32_t bonito_sbridge_pciaddr(void *opaque, target_phys_addr_t addr)
{
PCIBonitoState *s = opaque;
PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost);
uint32_t cfgaddr;
uint32_t idsel;
uint32_t devno;
uint32_t funno;
uint32_t regno;
uint32_t pciaddr;
if ((s->regs[BONITO_PCIMAP_CFG] & 0x10000) != 0x0) {
return 0xffffffff;
}
cfgaddr = addr & 0xffff;
cfgaddr |= (s->regs[BONITO_PCIMAP_CFG] & 0xffff) << 16;
idsel = (cfgaddr & BONITO_PCICONF_IDSEL_MASK) >> BONITO_PCICONF_IDSEL_OFFSET;
devno = ffs(idsel) - 1;
funno = (cfgaddr & BONITO_PCICONF_FUN_MASK) >> BONITO_PCICONF_FUN_OFFSET;
regno = (cfgaddr & BONITO_PCICONF_REG_MASK) >> BONITO_PCICONF_REG_OFFSET;
if (idsel == 0) {
fprintf(stderr, "error in bonito pci config address " TARGET_FMT_plx
",pcimap_cfg=%x\n", addr, s->regs[BONITO_PCIMAP_CFG]);
exit(1);
}
pciaddr = PCI_ADDR(pci_bus_num(phb->bus), devno, funno, regno);
DPRINTF("cfgaddr %x pciaddr %x busno %x devno %d funno %d regno %d\n",
cfgaddr, pciaddr, pci_bus_num(phb->bus), devno, funno, regno);
return pciaddr;
}
| 1threat
|
static int vnc_zlib_stop(VncState *vs, int stream_id)
{
z_streamp zstream = &vs->zlib_stream[stream_id];
int previous_out;
vs->zlib = vs->output;
vs->output = vs->zlib_tmp;
if (zstream->opaque != vs) {
int err;
VNC_DEBUG("VNC: initializing zlib stream %d\n", stream_id);
VNC_DEBUG("VNC: opaque = %p | vs = %p\n", zstream->opaque, vs);
zstream->zalloc = Z_NULL;
zstream->zfree = Z_NULL;
err = deflateInit2(zstream, vs->tight_compression, Z_DEFLATED, MAX_WBITS,
MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY);
if (err != Z_OK) {
fprintf(stderr, "VNC: error initializing zlib\n");
return -1;
}
zstream->opaque = vs;
}
buffer_reserve(&vs->output, vs->zlib.offset + 64);
zstream->next_in = vs->zlib.buffer;
zstream->avail_in = vs->zlib.offset;
zstream->next_out = vs->output.buffer + vs->output.offset;
zstream->avail_out = vs->output.capacity - vs->output.offset;
zstream->data_type = Z_BINARY;
previous_out = zstream->total_out;
if (deflate(zstream, Z_SYNC_FLUSH) != Z_OK) {
fprintf(stderr, "VNC: error during zlib compression\n");
return -1;
}
vs->output.offset = vs->output.capacity - zstream->avail_out;
return zstream->total_out - previous_out;
}
| 1threat
|
int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type,
int wanted_stream_nb, int related_stream,
AVCodec **decoder_ret, int flags)
{
int i, nb_streams = ic->nb_streams;
int ret = AVERROR_STREAM_NOT_FOUND, best_count = -1, best_bitrate = -1, best_multiframe = -1, count, bitrate, multiframe;
unsigned *program = NULL;
const AVCodec *decoder = NULL, *best_decoder = NULL;
if (related_stream >= 0 && wanted_stream_nb < 0) {
AVProgram *p = av_find_program_from_stream(ic, NULL, related_stream);
if (p) {
program = p->stream_index;
nb_streams = p->nb_stream_indexes;
}
}
for (i = 0; i < nb_streams; i++) {
int real_stream_index = program ? program[i] : i;
AVStream *st = ic->streams[real_stream_index];
AVCodecContext *avctx = st->codec;
if (avctx->codec_type != type)
continue;
if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
continue;
if (wanted_stream_nb != real_stream_index &&
st->disposition & (AV_DISPOSITION_HEARING_IMPAIRED |
AV_DISPOSITION_VISUAL_IMPAIRED))
continue;
if (type == AVMEDIA_TYPE_AUDIO && !avctx->channels)
continue;
if (decoder_ret) {
decoder = find_decoder(ic, st, st->codec->codec_id);
if (!decoder) {
if (ret < 0)
ret = AVERROR_DECODER_NOT_FOUND;
continue;
}
}
count = st->codec_info_nb_frames;
bitrate = avctx->bit_rate;
if (!bitrate)
bitrate = avctx->rc_max_rate;
multiframe = FFMIN(5, count);
if ((best_multiframe > multiframe) ||
(best_multiframe == multiframe && best_bitrate > bitrate) ||
(best_multiframe == multiframe && best_bitrate == bitrate && best_count >= count))
continue;
best_count = count;
best_bitrate = bitrate;
best_multiframe = multiframe;
ret = real_stream_index;
best_decoder = decoder;
if (program && i == nb_streams - 1 && ret < 0) {
program = NULL;
nb_streams = ic->nb_streams;
i = 0;
}
}
if (decoder_ret)
*decoder_ret = (AVCodec*)best_decoder;
return ret;
}
| 1threat
|
I am trying to display information from decoded JSON (Swift 4) in a label, but I can't seem to do it. How does one do this? : I am trying to display information taken from JSON. I've used .decode to get it. Now I want to put its text onto a simple label on my storyboard. At the bottom under ".resume()" is my attempt and it isn't working. I can't seem to figure this out.
***
import UIKit
struct WebsiteDescription: Decodable {
var name : String
var description : String
var courses : [Course]
}
struct Course: Decodable {
let id: Int
let name: String
let link: String
let imageUrl: String
}
class ViewController: UIViewController {
@IBOutlet weak var displayLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
let jsonUrlString = "https://api.letsbuildthatapp.com/jsondecodable/website_description"
guard let url = URL(string: jsonUrlString) else {return}
URLSession.shared.dataTask(with: url) { (data, response, err) in
guard let data = data else {return}
do {
let websiteDescription = try JSONDecoder().decode(WebsiteDescription.self, from: data)
print(websiteDescription.name, websiteDescription.description, websiteDescription.courses)
//let courses = try JSONDecoder().decode([Course].self, from: data)
} catch let jsonErr {
print("Error serializing json", jsonErr)
}
}.resume()
let displayLabel.text = websiteDescription.name
}
}
| 0debug
|
Can someone please thoroughly explain what a URI is? : <p>I understand it has something to do with databases but I am not exactly sure what it does.. I looked on the android developer page and they don't explain it very well. </p>
| 0debug
|
Loop while checking if element in a list in Python : <p>Let's say I have a simple piece of code like this:</p>
<pre><code>for i in range(1000):
if i in [150, 300, 500, 750]:
print(i)
</code></pre>
<p>Does the list <code>[150, 300, 500, 750]</code> get created every iteration of the loop? Or can I assume that the interpreter (say, CPython 2.7) is smart enough to optimize this away?</p>
| 0debug
|
How to create a slant button looks like this in xcode? : i want the result to be exact as the given image
how can i create a slant button like the image given below
https://i.stack.imgur.com/0GRjd.jpg
i don't want to use image as backgroud.
| 0debug
|
static void unblock_io_signals(void)
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGUSR2);
sigaddset(&set, SIGIO);
sigaddset(&set, SIGALRM);
pthread_sigmask(SIG_UNBLOCK, &set, NULL);
sigemptyset(&set);
sigaddset(&set, SIGUSR1);
pthread_sigmask(SIG_BLOCK, &set, NULL);
}
| 1threat
|
static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt)
{
int delay = FFMAX(st->codec->has_b_frames, st->codec->max_b_frames > 0);
int num, den, frame_size, i;
av_dlog(s, "compute_pkt_fields2: pts:%s dts:%s cur_dts:%s b:%d size:%d st:%d\n",
av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts), delay, pkt->size, pkt->stream_index);
if (pkt->duration == 0) {
ff_compute_frame_duration(&num, &den, st, NULL, pkt);
if (den && num) {
pkt->duration = av_rescale(1, num * (int64_t)st->time_base.den * st->codec->ticks_per_frame, den * (int64_t)st->time_base.num);
if (pkt->pts == AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE && delay == 0)
pkt->pts = pkt->dts;
if ((pkt->pts == 0 || pkt->pts == AV_NOPTS_VALUE) && pkt->dts == AV_NOPTS_VALUE && !delay) {
static int warned;
if (!warned) {
av_log(s, AV_LOG_WARNING, "Encoder did not produce proper pts, making some up.\n");
warned = 1;
pkt->dts =
pkt->pts = st->pts.val;
if (pkt->pts != AV_NOPTS_VALUE && pkt->dts == AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY) {
st->pts_buffer[0] = pkt->pts;
for (i = 1; i < delay + 1 && st->pts_buffer[i] == AV_NOPTS_VALUE; i++)
st->pts_buffer[i] = pkt->pts + (i - delay - 1) * pkt->duration;
for (i = 0; i<delay && st->pts_buffer[i] > st->pts_buffer[i + 1]; i++)
FFSWAP(int64_t, st->pts_buffer[i], st->pts_buffer[i + 1]);
pkt->dts = st->pts_buffer[0];
if (st->cur_dts && st->cur_dts != AV_NOPTS_VALUE &&
((!(s->oformat->flags & AVFMT_TS_NONSTRICT) &&
st->cur_dts >= pkt->dts) || st->cur_dts > pkt->dts)) {
av_log(s, AV_LOG_ERROR,
"Application provided invalid, non monotonically increasing dts to muxer in stream %d: %s >= %s\n",
st->index, av_ts2str(st->cur_dts), av_ts2str(pkt->dts));
return AVERROR(EINVAL);
if (pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts < pkt->dts) {
av_log(s, AV_LOG_ERROR, "pts (%s) < dts (%s) in stream %d\n",
av_ts2str(pkt->pts), av_ts2str(pkt->dts), st->index);
return AVERROR(EINVAL);
av_dlog(s, "av_write_frame: pts2:%s dts2:%s\n",
av_ts2str(pkt->pts), av_ts2str(pkt->dts));
st->cur_dts = pkt->dts;
st->pts.val = pkt->dts;
switch (st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
frame_size = (pkt->flags & AV_PKT_FLAG_UNCODED_FRAME) ?
((AVFrame *)pkt->data)->nb_samples :
ff_get_audio_frame_size(st->codec, pkt->size, 1);
if (frame_size >= 0 && (pkt->size || st->pts.num != st->pts.den >> 1 || st->pts.val)) {
frac_add(&st->pts, (int64_t)st->time_base.den * frame_size);
break;
case AVMEDIA_TYPE_VIDEO:
frac_add(&st->pts, (int64_t)st->time_base.den * st->codec->time_base.num);
break;
default:
break;
return 0;
| 1threat
|
Laravel installer has been install but laravel command not found ... wtf? : I've got an issue with trying tu use laravel installer.
I follow each steps to install laravel installer globally from https://laravel.com/docs/6.x,
- sudo composer global require laravel/installer
- export PATH="/home/hedwin/.composer/vendor/bin:$PATH"
But laravel command isn't found in sudo, but it's found with error without sudo ...
You cah see my picture for details : [Terminal][1]
[1]: https://i.stack.imgur.com/Surh6.png
i'm on ubuntu 18.04.
Thanks a lot for every help..
| 0debug
|
ASP.Net Core SAML authentication : <p>I am trying to add SAML 2.0 authentication to an ASP.Net Core solution. I can't find any documentation on the subject, so I am unsure where to start. There is probably documentation out there, but I don't want to spend 3 days becoming an expert on this.</p>
<p>From what I can see ASP.Net Core has changed something from the old OWIN assemblies/namespaces. There are third party libraries to simplify SAML 2.0 implementation such as <a href="https://github.com/KentorIT/authservices" rel="noreferrer">Kentor.AuthServices</a>.</p>
<p>I am unsure how to combine this with ASP.Net 5 RC 1 / ASP.Net Core. For example making use of the AspNet* tables in SQL.</p>
<p>ASP.Net 5 RC 1 comes with several libraries to implement authentication (client).</p>
<p>For example:</p>
<ul>
<li><a href="https://github.com/aspnet/Security/tree/1.0.0-rc1/src/Microsoft.AspNet.Authentication.OAuth" rel="noreferrer">Microsoft.AspNet.Authentication.OAuth</a></li>
<li><a href="https://github.com/aspnet/Security/tree/1.0.0-rc1/src/Microsoft.AspNet.Authentication.Facebook" rel="noreferrer">Microsoft.AspNet.Authentication.Facebook</a></li>
<li><a href="https://github.com/aspnet/Security/tree/1.0.0-rc1/src/Microsoft.AspNet.Authentication.Google" rel="noreferrer">Microsoft.AspNet.Authentication.Google</a></li>
<li><a href="https://github.com/aspnet/Security/tree/1.0.0-rc1/src/Microsoft.AspNet.Authentication.Twitter" rel="noreferrer">Microsoft.AspNet.Authentication.Twitter</a></li>
</ul>
<p>Implementing these is a matter of calling a simple extension method in <code>Startup.cs</code>:</p>
<pre><code>app.UseIdentity()
.UseFacebookAuthentication(new FacebookOptions
{
AppId = "ID",
AppSecret = "KEY"
})
.UseGoogleAuthentication(new GoogleOptions
{
ClientId = "ID",
ClientSecret = "SECRET"
})
.UseTwitterAuthentication(new TwitterOptions
{
ConsumerKey = "KEY",
ConsumerSecret = "SECRET"
});
</code></pre>
<p>Once that is done the ASP.Net sample project automatically shows social buttons for login/manage account:</p>
<p><a href="https://i.stack.imgur.com/QHpeA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QHpeA.png" alt="Social buttons"></a></p>
<p>In the backend code the authentication providers are retrieved using <code>var otherLogins = _signInManager.GetExternalAuthenticationSchemes().Where(auth => userLogins.All(ul => auth.AuthenticationScheme != ul.LoginProvider)).ToList();</code>. This means the authentication providers are registered somewhere that makes them available by calling <code>_signInManager.GetExternalAuthenticationSchemes()</code>.</p>
<p>How can I implement SAML 2.0 authentication in ASP.Net 5 RC1 / ASP.Net Core?</p>
| 0debug
|
Golang unable to parse TOML file in GoLand : I am using the GoLand editor on Windows and initially I installed dependency using:
go get github.com/BurntSushi/toml
I created a toml file in the same folder as my `main.go`:
```
.
|-- cloud.toml
`-- main.go
```
### cloud.toml
[database]
host = "localhost"
port = 8086
secure = false
username = "test"
password = "password"
dbName = "test"
### main.go
package main
import (
"fmt"
"github.com/BurntSushi/toml"
)
type tomlConfig struct {
DB dbInfo
}
type dbInfo struct {
Host string `toml:"host"`
Port int `toml: "port"`
Secure bool `toml: "secure"`
Username string `toml: "username"`
Password string `toml: "password"`
DbName string `toml:"dbName"`
}
func main() {
var dbConfig tomlConfig
if _, err := toml.DecodeFile("cloud.toml", &dbConfig); err != nil {
fmt.Println(err)
return
}
fmt.Println("Database Configuration")
fmt.Printf("Host: %s\n", dbConfig.DB.Host)
fmt.Printf("Port: %d\n", dbConfig.DB.Port)
}
### Output
go run main.go
Database Configuration
Host:
Port: 0
What am I doing wrong here?
my `go env` is:
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\des\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\des\go
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\des\AppData\Local\Temp\go-build309995570=/tmp/go-build -gno-record-gcc-switches
| 0debug
|
IndexError: index 5 is out of bounds for axis 1 with size 5 python : I am using a dataset that I created it should have 5 classes and it contain 500 samples for training and 100 samples for testing
I can't perform this operation
Y_train = np_utils.to_categorical(y_train, num_classes)
Y_test = np_utils.to_categorical(y_test, num_classes)
as it keep give me
Y[i, y[i]] = 1.
IndexError: index 5 is out of bounds for axis 1 with size 5
if I changed the value of classes to 6 it works but this not correct I have 5 classes only
please I need to help
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.