problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Multiple row updates at a time using single query statement from code behind file : <p>I am new to ASP.NET and I am trying to <strong>update multiple rows</strong> at a time using <strong>single query</strong> statement. I am getting <strong>row IDs</strong> on button click through hidden field which are separated by <strong>commas</strong> like "140","141","142"</p>
<p>My .cs file code is </p>
<pre><code>protected void ibtnNoBid_Click(Object sender, EventArgs e)
{
var req_id_values = hfrequestid.Value;//retrieveing values from hidden field on button click
//single update query for multiple req_id_values separated by comma
}
</code></pre>
| 0debug
|
Why does std::make_pair not return a pair? Or does it? : <p>My internal sanity check failed so I'm rerunning it on Stackoverflow.</p>
<p>The following code:</p>
<pre><code>#include <iostream>
#include <typeinfo>
#include <utility>
int main()
{
constexpr auto pair_of_ints = std::make_pair(1, 2);
std::cerr << typeid(pair_of_ints).name();
//static_assert(std::is_same<decltype(pair_of_ints), std::pair<int, int>>::value, "WTF");
}
</code></pre>
<p>produces the mangled symbol name for <code>std::__1::pair<int, int></code> on my system (XCode Clang 8.x).</p>
<p>If I then enable the <code>static_assert</code>, it fails. I have no idea why.
How can I make this work? I have a function that returns a pair or tuple depending on the arguments passed to it and would like to verify it actually returns a pair or tuple in the correct cases.</p>
| 0debug
|
php if{} elseif{} else{} syntax error : <p>pls help me with code i dont get where is the error</p>
<pre><code>$userrole = $row['type'];
if ($userrole = "admin") {
$_SESSION['name'] = $row['name'];
header("Location: ../index.php");
} elseif ($userrole = "encoder") {
$_SESSION['name'] = $row['name'];
header("Location: ../mencode.php");
} elseif ($userrole = "verifier") {
$_SESSION['name'] = $row['name'];
header("Location: ../mverify.php");
} else ($userrole = "approver") {
$_SESSION['name'] = $row['name'];
header("Location: ../mapproved.php"); }
</code></pre>
<p>thnx in advance</p>
| 0debug
|
deprecation error in sklearn about empty array without any empty array in my code : <p>I am just playing around encoding and decoding but I get this error from sklearn:</p>
<blockquote>
<p>Warning (from warnings module):
File "C:\Python36\lib\site-packages\sklearn\preprocessing\label.py", line 151
if diff:
DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use <code>array.size > 0</code> to check that an array is not empty.</p>
</blockquote>
<p>Here is the full code, you can run it yourself in python 3+</p>
<p>My question is why is it saying I use an empty array as I clearly don't in my code, thanks for taking your time to answer my question.</p>
<pre><code>### label encoding ###
import numpy as np
from sklearn import preprocessing
# Sample input labels
input_labels = ["red", "black", "red", "green",\
"black", "yellow", "white"]
# Create label encoder abd fit the label
encoder = preprocessing.LabelEncoder()
encoder.fit(input_labels)
# Print the mapping
print("\nLabel mapping:")
for i, item in enumerate(encoder.classes_):
print(item, "-->", i)
# Encode a set of labels using encoder
test_labels = ["green", "red", "black"]
encoded_values = encoder.transform(test_labels)
print("\nLabels =", test_labels)
print("Encoded values =", list(encoded_values))
# Decode a set of values using the encoder
encoded_values = [3, 0, 4, 1]
decoded_list = encoder.inverse_transform(encoded_values)
print("\nEncoded values =", encoded_values)
print("Decoded labels=", list(decoded_list))
</code></pre>
| 0debug
|
"error: expected primary-expression before '<' token." What am I missing? : <p>I've done a very similar code in C without such errors.</p>
<p>I'm assuming that I got all the header files I need? </p>
<pre><code>#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int main(){
double percentage;
cout << "enter percentage" << endl;
cin >> percentage;
string letter;
if (percentage >= 98)
letter = "A+";
</code></pre>
<p>This is where the error starts to appear on every condition line. I deleted the rest of the grades in this sample to avoid redundancy. </p>
<pre><code>else if (percentage >= 92 && < 98) //"error: expected primary-expression before '<' token."
{
letter = "A";
}
else if (percentage >= 90 && < 92) //"error: expected primary-expression before '<' token."
{
letter = "A-";
}
else if (percentage >= 88 && < 90) //"error: expected primary-expression before '<' token."
{
letter = "B+";
}
</code></pre>
<p>This is where it stops</p>
<pre><code>else {letter = "F";}
cout << "Grade: " << letter << endl;
return 0;
}
</code></pre>
| 0debug
|
static int v4l2_send_frame(AVCodecContext *avctx, const AVFrame *frame)
{
V4L2m2mContext *s = avctx->priv_data;
V4L2Context *const output = &s->output;
return ff_v4l2_context_enqueue_frame(output, frame);
}
| 1threat
|
pyhton replace char or number with spaces given start position and length : In a specific string I would be given start position and length.
for eg input string "abcdefgh" . start position : 3 and length :2.I want to replace characters with space
so the output string should " ab efgh" .
how can i do that in python
| 0debug
|
static int s390_ipl_init(SysBusDevice *dev)
{
S390IPLState *ipl = S390_IPL(dev);
int kernel_size;
if (!ipl->kernel) {
int bios_size;
char *bios_filename;
if (bios_name == NULL) {
bios_name = ipl->firmware;
}
bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (bios_filename == NULL) {
hw_error("could not find stage1 bootloader\n");
}
bios_size = load_elf(bios_filename, NULL, NULL, &ipl->start_addr, NULL,
NULL, 1, ELF_MACHINE, 0);
if (bios_size == -1) {
bios_size = load_image_targphys(bios_filename, ZIPL_IMAGE_START,
4096);
ipl->start_addr = ZIPL_IMAGE_START;
if (bios_size > 4096) {
hw_error("stage1 bootloader is > 4k\n");
}
}
g_free(bios_filename);
if (bios_size == -1) {
hw_error("could not load bootloader '%s'\n", bios_name);
}
return 0;
} else {
uint64_t pentry = KERN_IMAGE_START;
kernel_size = load_elf(ipl->kernel, NULL, NULL, &pentry, NULL,
NULL, 1, ELF_MACHINE, 0);
if (kernel_size == -1) {
kernel_size = load_image_targphys(ipl->kernel, 0, ram_size);
}
if (kernel_size == -1) {
fprintf(stderr, "could not load kernel '%s'\n", ipl->kernel);
return -1;
}
if (pentry == KERN_IMAGE_START || pentry == 0x800) {
ipl->start_addr = KERN_IMAGE_START;
strcpy(rom_ptr(KERN_PARM_AREA), ipl->cmdline);
} else {
ipl->start_addr = pentry;
}
}
if (ipl->initrd) {
ram_addr_t initrd_offset;
int initrd_size;
initrd_offset = INITRD_START;
while (kernel_size + 0x100000 > initrd_offset) {
initrd_offset += 0x100000;
}
initrd_size = load_image_targphys(ipl->initrd, initrd_offset,
ram_size - initrd_offset);
if (initrd_size == -1) {
fprintf(stderr, "qemu: could not load initrd '%s'\n", ipl->initrd);
exit(1);
}
stq_p(rom_ptr(INITRD_PARM_START), initrd_offset);
stq_p(rom_ptr(INITRD_PARM_SIZE), initrd_size);
}
return 0;
}
| 1threat
|
How do you adb to bluestacks 4? : <p>I'd like to connect to android emulator on bluestacks 4 with adb.
but I've got an error with <code>adb.exe -s emulator-5554 shell</code></p>
<p>checking devices. </p>
<pre><code>$ adb.exe devices
List of devices attached
BH901... device
CB512... unauthorized
emulator-5554 device
</code></pre>
<p>once I shutdown bluestacks window, the <code>emulator-5554</code> will be hidden from above command's result. thus I think <code>emulator-5554</code> means bluestacks.</p>
<p>then commnad as below to use adb.</p>
<pre><code>$ adb.exe -s emulator-5554 shell
error: closed
</code></pre>
<p>but as you know, an error occured.</p>
| 0debug
|
GraphQL large integer error: Int cannot represent non 32-bit signed integer value : <p>I´m trying to store a UNIX timestamp in <code>MongoDB</code> using <code>GraphQL</code>, but it seens that GraphQL has a limit to handle integers. See the mutation below:</p>
<pre><code>const addUser = {
type: UserType,
description: 'Add an user',
args: {
data: {
name: 'data',
type: new GraphQLNonNull(CompanyInputType)
}
},
resolve(root, params) {
params.data.creationTimestamp = Date.now();
const model = new UserModel(params.data);
const saved = model.save();
if (!saved)
throw new Error('Error adding user');
return saved;
}
}
</code></pre>
<p>Result:</p>
<pre><code> "errors": [
{
"message": "Int cannot represent non 32-bit signed integer value: 1499484833027",
"locations": [
{
"line": 14,
"column": 5
}
],
"path": [
"addUser",
"creationTimestamp"
]
}
</code></pre>
<p>I´m currently using <code>GraphQLInteger</code> for this field on type definition:</p>
<pre><code>creationTimestamp: {
type: GraphQLInt
}
</code></pre>
<p>How can I solve that situation if there is no larger <code>GraphQLInt</code> available in <code>GraphQL</code> ?</p>
| 0debug
|
void i8042_setup_a20_line(ISADevice *dev, qemu_irq *a20_out)
{
ISAKBDState *isa = I8042(dev);
KBDState *s = &isa->kbd;
s->a20_out = a20_out;
}
| 1threat
|
How do I make my discord bot send images? [Help Request] : these are all my imports.. Do I need to add more?
some of these imports I used for other commands that work perfectly
import discord
from discord.ext import commands
from discord.ext.commands import Bot
import asyncio
import random
import time
import ftplib
Then I have this code
bot = commands.Bot(command_prefix="2")
Then I have this one that when I launch my run.py it shows me some prints in the app
@bot.event
async def on_ready():
print("I'm running on: " + bot.user.name)
print ("With the ID: " + (bot.user.id))
print("The commands are \n" + "#ping \n #pong \n #info (@user) \n #embedtest \n #hello \n #hug \n #kill \n ")
This is my code for the picture, so this code should make a picture pop up from the same folder as my run.py program is located.
@bot.command(pass_context=True)
async def image(ctx):
myImage = open('UDST.png', 'rb')
await bot.send_file(myImage)
But then when I run it, it gives me this error that I don't understand.
----------------------------------------------------------------------------
await bot.send_file(myImage)
^
IndentationError: unindent does not match any outer indentation level
----------------------------------------------------------------------------
Also sorry I'm new with stackoverflow so I might've screwed up somewhere while making this help request.
Thanks to anyone that helps me successfully. >:)
| 0debug
|
Implementing hierarchical clustering in Python using Levenshtein distance : <p>Following up on my previous question, I have implemented a clustering algorithm for a huge number of strings using Python & Levenshtein distance..But it is taking a very long time to complete clustering. Any suggestions please?</p>
<p><>
iterate thro the list in a for loop
for each item in list
run through the list again, to find similarity percentage
if similarity > threshold, move to cluster
end for loop</p>
| 0debug
|
StringBuilder deleteCharAt not working : <pre><code> String s = "world";
StringBuilder str = new StringBuilder(s);
str.deleteCharAt(0);
System.out.println(s);
</code></pre>
<p>this code outputs the following result : world , what am i doing wrong ? why is the first character of string not being deleted ?</p>
| 0debug
|
Remove text between two square brackets in javascript : <p>How can I change this:</p>
<pre><code>This is a string [[remove]] this
</code></pre>
<p>To:</p>
<pre><code>This is a string this
</code></pre>
<p>I managed to figure out how to remove a string between one set of brackets but I couldn't get it right with two:</p>
<pre><code>var myString = "This is my string [remove] this"
myString.replace(/ *\[[^\]]*]/, '');
</code></pre>
| 0debug
|
how we can convert categorical data in a column into numbered data : <p>Lets take an example, suppose my table values are:</p>
<p><strong>subjects</strong></p>
<p>english </p>
<p>mathematics </p>
<p>science </p>
<p>english </p>
<p>science</p>
<p>how can i convert these string data into numbered data as shown in table below.</p>
<p><strong>subjects</strong></p>
<p>1</p>
<p>2</p>
<p>3</p>
<p>1</p>
<p>3</p>
| 0debug
|
fetchline(void)
{
char *p, *line = malloc(MAXREADLINESZ);
if (!line)
return NULL;
printf("%s", get_prompt());
fflush(stdout);
if (!fgets(line, MAXREADLINESZ, stdin)) {
free(line);
return NULL;
}
p = line + strlen(line);
if (p != line && p[-1] == '\n')
p[-1] = '\0';
return line;
}
| 1threat
|
Dropdown HTML File Download : <p>I need a dropdown menu like this: <a href="http://www.w3schools.com/howto/howto_js_dropdown.asp" rel="nofollow noreferrer">http://www.w3schools.com/howto/howto_js_dropdown.asp</a>
but with a submit button, that on press downloads the selected file. I hope anyone can help me.</p>
| 0debug
|
UICollectionView using UICollectionViewFlowLayout is centering and missaligning cells : I'm using a standard `UICollectionViewFlowLayout` but it seems to do some overwork as it is centering the cells of section with one item and if the section contains 2 or 3 items, they are not distributed to fit width
How to get always the same distribution (to left) and margins (as with more than 3 items)
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/dAUL5.png
| 0debug
|
aio_write_f(int argc, char **argv)
{
int nr_iov, c;
int pattern = 0xcd;
struct aio_ctx *ctx = calloc(1, sizeof(struct aio_ctx));
BlockDriverAIOCB *acb;
while ((c = getopt(argc, argv, "CqP:")) != EOF) {
switch (c) {
case 'C':
ctx->Cflag = 1;
break;
case 'q':
ctx->qflag = 1;
break;
case 'P':
pattern = atoi(optarg);
break;
default:
return command_usage(&aio_write_cmd);
}
}
if (optind > argc - 2)
return command_usage(&aio_write_cmd);
ctx->offset = cvtnum(argv[optind]);
if (ctx->offset < 0) {
printf("non-numeric length argument -- %s\n", argv[optind]);
return 0;
}
optind++;
if (ctx->offset & 0x1ff) {
printf("offset %lld is not sector aligned\n",
(long long)ctx->offset);
return 0;
}
nr_iov = argc - optind;
ctx->buf = create_iovec(&ctx->qiov, &argv[optind], nr_iov, pattern);
gettimeofday(&ctx->t1, NULL);
acb = bdrv_aio_writev(bs, ctx->offset >> 9, &ctx->qiov,
ctx->qiov.size >> 9, aio_write_done, ctx);
if (!acb)
return -EIO;
return 0;
}
| 1threat
|
static void vp7_luma_dc_wht_c(int16_t block[4][4][16], int16_t dc[16])
{
int i, a1, b1, c1, d1;
int16_t tmp[16];
for (i = 0; i < 4; i++) {
a1 = (dc[i * 4 + 0] + dc[i * 4 + 2]) * 23170;
b1 = (dc[i * 4 + 0] - dc[i * 4 + 2]) * 23170;
c1 = dc[i * 4 + 1] * 12540 - dc[i * 4 + 3] * 30274;
d1 = dc[i * 4 + 1] * 30274 + dc[i * 4 + 3] * 12540;
tmp[i * 4 + 0] = (a1 + d1) >> 14;
tmp[i * 4 + 3] = (a1 - d1) >> 14;
tmp[i * 4 + 1] = (b1 + c1) >> 14;
tmp[i * 4 + 2] = (b1 - c1) >> 14;
}
for (i = 0; i < 4; i++) {
a1 = (tmp[i + 0] + tmp[i + 8]) * 23170;
b1 = (tmp[i + 0] - tmp[i + 8]) * 23170;
c1 = tmp[i + 4] * 12540 - tmp[i + 12] * 30274;
d1 = tmp[i + 4] * 30274 + tmp[i + 12] * 12540;
AV_ZERO64(dc + i * 4);
block[0][i][0] = (a1 + d1 + 0x20000) >> 18;
block[3][i][0] = (a1 - d1 + 0x20000) >> 18;
block[1][i][0] = (b1 + c1 + 0x20000) >> 18;
block[2][i][0] = (b1 - c1 + 0x20000) >> 18;
}
}
| 1threat
|
static bool all_cpu_threads_idle(void)
{
CPUState *env;
for (env = first_cpu; env != NULL; env = env->next_cpu) {
if (!cpu_thread_is_idle(env)) {
return false;
}
}
return true;
}
| 1threat
|
Mulitplying bits : <p>My textbook says this:</p>
<p><a href="https://i.stack.imgur.com/spBV5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/spBV5.png" alt="enter image description here"></a></p>
<p>I don’t get this quote in the multiplication section:</p>
<blockquote>
<p>The first observation is that the number of digits in the product is considerably larger than the number in either the multiplicand or the multiplier. In fact, if we ignore the sign bits, the length of the multiplication of an n-bit multiplicand and an m-bit multiplier is a product that is n + m bits long. That is, n + m bits are required to represent all possible products.</p>
</blockquote>
<p>I see 7 digits in the product but this quote implies there should be 8</p>
| 0debug
|
Set a value in a javascript object based on another key's value in the same object : <p>I'd like to define a javascript object in which the value of a key depends on the value of another, like so :</p>
<pre><code>var params = {
width : 100,
margins : 10,
realWidth : width - margins
}
</code></pre>
<p>If I try this I get an error about width not being defined.
Is it even possible to do that ? </p>
| 0debug
|
Failed to load the hostfxr.dll after install net core : <p>Anyone has this problem i change Pc and tried to install net core framework but vs code return this info when i tried to write
dontet --info </p>
<pre><code>Failed to load the dll from [C:\Program
Files\dotnet\host\fxr\2.1.0\hostfxr.dll], HRESULT: 0x80070057
The library hostfxr.dll was found, but loading it from C:\Program
Files\dotnet\host\fxr\2.1.0\hostfxr.dll failed
- Installing .NET Core prerequisites might help resolve this problem.
http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
</code></pre>
| 0debug
|
Can I initialize an array using the std::initializer_list instead of brace-enclosed initializer? : <p>Can I initialize an array using the <code>std::initializer_list</code> object instead of brace-enclosed initializer?</p>
<p>As known, we can do this: <a href="http://en.cppreference.com/w/cpp/language/aggregate_initialization">http://en.cppreference.com/w/cpp/language/aggregate_initialization</a></p>
<pre><code>unsigned char b[5]{"abc"};
// equivalent to unsigned char b[5] = {'a', 'b', 'c', '\0', '\0'};
int ar[] = {1,2,3};
std::array<int, 3> std_ar2{ {1,2,3} }; // std::array is an aggregate
std::array<int, 3> std_ar1 = {1, 2, 3};
</code></pre>
<p>But I can't initialize an array by <code>std::initializer_list il;</code>: </p>
<p><a href="http://ideone.com/f6aflX">http://ideone.com/f6aflX</a></p>
<pre><code>#include <iostream>
#include <initializer_list>
#include <array>
int main() {
int arr1[] = { 1, 2, 3 }; // OK
std::array<int, 3> arr2 = { 1, 2, 3 }; // OK
std::initializer_list<int> il = { 1, 2, 3 };
constexpr std::initializer_list<int> il_constexpr = { 1, 2, 3 };
//int arr3[] = il; // error
//int arr4[] = il_constexpr; // error
//std::array<int, 3> arr5 = il; // error
//std::array<int, 3> arr6 = il_constexpr; // error
return 0;
}
</code></pre>
<p>But how can I use <code>std::initializer_list il;</code> to initialize an array?</p>
| 0debug
|
How to properly replace toast message with alert Dialog : I am new to android development and am working on a audio stream app. I need help on something urgently. I initially put a toast message to notify users when an error occurred while streaming audio service. However, i wanted to replace it with an alert dialog. But i have been getting an error.
Here is my previous code:
public boolean onError(MediaPlayer mp, int what, int extra) {
Toast.makeText(this, "There was an error playing the stream, Check your network connection", Toast.LENGTH_LONG).show();
mediaPlayer.reset();
return false;
}
Here is the updated one which throws an error:
| 0debug
|
Why bcp query not work in the c#? : I'm beginner in c#,i want use the bcp utilities in c#,write this code:<br/>
string connstr = "Data Source=192.168.50.172;Initial Catalog=CDRDB;User ID=CDRLOGIN;Password=beh1368421";
//string connstr = "Enter your connection string here";
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "bcp";
proc.StartInfo.Arguments = @"select * from CDRTABLE"" queryout c:\filename.csv -S 192.168.50.172 -U CDRLOGIN -P beh1368421 -f -w";
proc.Start();
<br/>
that's code run but ,`filename.csv` not create in my c drive,what happen?how can i solve that problem?
| 0debug
|
def smallest_multiple(n):
if (n<=2):
return n
i = n * 2
factors = [number for number in range(n, 1, -1) if number * 2 > n]
while True:
for a in factors:
if i % a != 0:
i += n
break
if (a == factors[-1] and i % a == 0):
return i
| 0debug
|
How JavaScript works when multiply a string (as a number) & number (1+"1-1") :
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
console.log("1" * "123")//123
console.log(1 * "123")//123
console.log("1" * 123)//123
console.log("ABC" * 123)//NaN
console.log("ABC" * "ABC")//NaN
console.log("0" * ("1-2"))//NAN
console.log("0" * (1-2))//0
<!-- end snippet -->
>"123" is a string type but the value is a number. So JavaScript allow to multiplication.
as same as "1-2" is a string type but the value is number.why it does not allow to multiplication? And how JavaScript handle this?
| 0debug
|
static void nbd_attach_aio_context(BlockDriverState *bs,
AioContext *new_context)
{
BDRVNBDState *s = bs->opaque;
nbd_client_session_attach_aio_context(&s->client, new_context);
}
| 1threat
|
fastest method to find nth root of a number : The problem is to find nth root of a number and if the root is an integer i need to print it else i will have to print -1.I had used this method but i get tle.Is there any method faster than the one i have implemented.Here is my code:
public class Sqrt {
public static double nthroot(int n, double x)
{
return Math.pow(x,1./n);
}
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int t,n,m;
double x;
String[] y;
t=Integer.parseInt(br.readLine());
while(t-->0)
{
y=br.readLine().split(" ");
n=Integer.parseInt(y[1]);//the exp
m=Integer.parseInt(y[0]);//the number
x=nthroot(m,n);
x= BigDecimal.valueOf(x)
.setScale(5, RoundingMode.HALF_UP)
.doubleValue();
if(x==(int)x)
{
System.out.println((int)x);
}
else
{
System.out.println(-1);
}
}
}
}
| 0debug
|
Jenkins does not recognize command sh? : <p>I've been having a lot of trouble trying to get a Jenkinsfile to work.
I've been trying to run this test script:</p>
<pre><code>#!/usr/bin/env groovy
node {
stage('Build') {
echo 'Building....'
// Create virtualenv
sh 'echo "hi"'
}
stage('Test') {
echo 'Building....'
}
stage('Deploy') {
echo 'Deploying....'
}
}
</code></pre>
<p>But I keep getting this error when trying to build:</p>
<pre><code>Warning: JENKINS-41339 probably bogus PATH=/usr/lib64/ccache:/usr/lib64/ccache:$PATH; perhaps you meant to use ‘PATH+EXTRA=/something/bin’?
[test-job-jenkinsfile-pipeline] Running shell script
nohup: failed to run command `sh': No such file or directory
</code></pre>
<p>I updated all the pipeline plugins to the latest version and still run into this error. Any help?</p>
| 0debug
|
static void img_copy(uint8_t *dst, int dst_wrap,
uint8_t *src, int src_wrap,
int width, int height)
{
for(;height > 0; height--) {
memcpy(dst, src, width);
dst += dst_wrap;
src += src_wrap;
}
}
| 1threat
|
static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset,
size_t size)
{
int64_t len;
if (size > INT_MAX) {
return -EIO;
}
if (!bdrv_is_inserted(bs))
return -ENOMEDIUM;
if (bs->growable)
return 0;
len = bdrv_getlength(bs);
if (offset < 0)
return -EIO;
if ((offset > len) || (len - offset < size))
return -EIO;
return 0;
}
| 1threat
|
void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp)
{
QIOChannel *ioc;
const char *argv[] = { "/bin/sh", "-c", command, NULL };
trace_migration_exec_outgoing(command);
ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv,
O_WRONLY,
errp));
if (!ioc) {
return;
}
migration_set_outgoing_channel(s, ioc);
object_unref(OBJECT(ioc));
}
| 1threat
|
Support Urdu in android app : Hiiiii
I want make support of my application English,Hindi,Urdu
For that I created two values strings folders like values-hi,values-ur then default strings.xml for English when I click on Urdu I need to load Urdu strings file for all labels and make UI RTL support.
| 0debug
|
How opencv 4.x API is different from previous version? : <p>I noted that opencv 4 is released and one difference is that API changed to be c++11 compliant.</p>
<p>What this really means?</p>
<p>How should I change my codes to be compatible with this version?</p>
| 0debug
|
Objects to Array : <p>I need to push keys of obj into the array, what is wrong with my code:</p>
<pre><code>function getAllKeys(obj) {
var arr = [];
var sample = {
name : 'Sam',
age : 25,
hasPets : true
}
for(var key in obj){
arr.push(obj[key])
}
return arr;
}
getAllKeys()
</code></pre>
| 0debug
|
static bool virtio_scsi_data_plane_handle_event(VirtIODevice *vdev,
VirtQueue *vq)
{
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
assert(s->ctx && s->dataplane_started);
return virtio_scsi_handle_event_vq(s, vq);
}
| 1threat
|
why it has a NaN value when cut the data to bins : <p>I encounter a question:
<a href="https://i.stack.imgur.com/Wxblz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wxblz.png" alt="enter image description here"></a></p>
<p>why it has a NaN value</p>
| 0debug
|
static void arm_cpu_reset(CPUState *s)
{
ARMCPU *cpu = ARM_CPU(s);
ARMCPUClass *acc = ARM_CPU_GET_CLASS(cpu);
CPUARMState *env = &cpu->env;
acc->parent_reset(s);
memset(env, 0, offsetof(CPUARMState, end_reset_fields));
g_hash_table_foreach(cpu->cp_regs, cp_reg_reset, cpu);
g_hash_table_foreach(cpu->cp_regs, cp_reg_check_reset, cpu);
env->vfp.xregs[ARM_VFP_FPSID] = cpu->reset_fpsid;
env->vfp.xregs[ARM_VFP_MVFR0] = cpu->mvfr0;
env->vfp.xregs[ARM_VFP_MVFR1] = cpu->mvfr1;
env->vfp.xregs[ARM_VFP_MVFR2] = cpu->mvfr2;
cpu->power_state = cpu->start_powered_off ? PSCI_OFF : PSCI_ON;
s->halted = cpu->start_powered_off;
if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
env->iwmmxt.cregs[ARM_IWMMXT_wCID] = 0x69051000 | 'Q';
}
if (arm_feature(env, ARM_FEATURE_AARCH64)) {
env->aarch64 = 1;
#if defined(CONFIG_USER_ONLY)
env->pstate = PSTATE_MODE_EL0t;
env->cp15.sctlr_el[1] |= SCTLR_UCT | SCTLR_UCI | SCTLR_DZE;
env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 2, 3);
#else
if (arm_feature(env, ARM_FEATURE_EL3)) {
env->pstate = PSTATE_MODE_EL3h;
} else if (arm_feature(env, ARM_FEATURE_EL2)) {
env->pstate = PSTATE_MODE_EL2h;
} else {
env->pstate = PSTATE_MODE_EL1h;
}
env->pc = cpu->rvbar;
#endif
} else {
#if defined(CONFIG_USER_ONLY)
env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 4, 0xf);
#endif
}
#if defined(CONFIG_USER_ONLY)
env->uncached_cpsr = ARM_CPU_MODE_USR;
env->vfp.xregs[ARM_VFP_FPEXC] = 1 << 30;
if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
env->cp15.c15_cpar = 3;
} else if (arm_feature(env, ARM_FEATURE_XSCALE)) {
env->cp15.c15_cpar = 1;
}
#else
env->uncached_cpsr = ARM_CPU_MODE_SVC;
env->daif = PSTATE_D | PSTATE_A | PSTATE_I | PSTATE_F;
if (arm_feature(env, ARM_FEATURE_M)) {
uint32_t initial_msp;
uint32_t initial_pc;
uint8_t *rom;
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
env->v7m.secure = true;
}
env->v7m.ccr = R_V7M_CCR_STKALIGN_MASK;
env->regs[14] = 0xffffffff;
rom = rom_ptr(0);
if (rom) {
initial_msp = ldl_p(rom);
initial_pc = ldl_p(rom + 4);
} else {
initial_msp = ldl_phys(s->as, 0);
initial_pc = ldl_phys(s->as, 4);
}
env->regs[13] = initial_msp & 0xFFFFFFFC;
env->regs[15] = initial_pc & ~1;
env->thumb = initial_pc & 1;
}
if (A32_BANKED_CURRENT_REG_GET(env, sctlr) & SCTLR_V) {
env->regs[15] = 0xFFFF0000;
}
env->vfp.xregs[ARM_VFP_FPEXC] = 0;
#endif
if (arm_feature(env, ARM_FEATURE_PMSA)) {
if (cpu->pmsav7_dregion > 0) {
if (arm_feature(env, ARM_FEATURE_V8)) {
memset(env->pmsav8.rbar[M_REG_NS], 0,
sizeof(*env->pmsav8.rbar[M_REG_NS])
* cpu->pmsav7_dregion);
memset(env->pmsav8.rlar[M_REG_NS], 0,
sizeof(*env->pmsav8.rlar[M_REG_NS])
* cpu->pmsav7_dregion);
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
memset(env->pmsav8.rbar[M_REG_S], 0,
sizeof(*env->pmsav8.rbar[M_REG_S])
* cpu->pmsav7_dregion);
memset(env->pmsav8.rlar[M_REG_S], 0,
sizeof(*env->pmsav8.rlar[M_REG_S])
* cpu->pmsav7_dregion);
}
} else if (arm_feature(env, ARM_FEATURE_V7)) {
memset(env->pmsav7.drbar, 0,
sizeof(*env->pmsav7.drbar) * cpu->pmsav7_dregion);
memset(env->pmsav7.drsr, 0,
sizeof(*env->pmsav7.drsr) * cpu->pmsav7_dregion);
memset(env->pmsav7.dracr, 0,
sizeof(*env->pmsav7.dracr) * cpu->pmsav7_dregion);
}
}
env->pmsav7.rnr[M_REG_NS] = 0;
env->pmsav7.rnr[M_REG_S] = 0;
env->pmsav8.mair0[M_REG_NS] = 0;
env->pmsav8.mair0[M_REG_S] = 0;
env->pmsav8.mair1[M_REG_NS] = 0;
env->pmsav8.mair1[M_REG_S] = 0;
}
set_flush_to_zero(1, &env->vfp.standard_fp_status);
set_flush_inputs_to_zero(1, &env->vfp.standard_fp_status);
set_default_nan_mode(1, &env->vfp.standard_fp_status);
set_float_detect_tininess(float_tininess_before_rounding,
&env->vfp.fp_status);
set_float_detect_tininess(float_tininess_before_rounding,
&env->vfp.standard_fp_status);
#ifndef CONFIG_USER_ONLY
if (kvm_enabled()) {
kvm_arm_reset_vcpu(cpu);
}
#endif
hw_breakpoint_update_all(cpu);
hw_watchpoint_update_all(cpu);
}
| 1threat
|
How to efficiently reduce this combinatory logic sentence? : I have a sentence that describes a circuit, like this:
I x (Q1 x Q0 + not Q1 x not Q0) + not I x (not Q1 x Q0 + Q1 x not Q0)
I have translated it like this:
I and ((Q1 and Q0) or (!Q1 and !Q0)) or !I and ((!Q1 and Q0) or (Q1 and !Q0)) ->
I and ((Q1 and Q0) or !(Q1 or Q0)) or !I and ((!Q1 and Q0) or (Q1 and !Q0)) ->
I and (!(Q1 xor Q0)) or !I and ((!Q1 and Q0) or (Q1 and !Q0))
but I get stuck at this point, is there an easy way to make it even more compact or I'll have to solve the bit-by-bit table?
| 0debug
|
Undefined Reference to Function() : <p>So GCC keeps spouting out this error that keeps boggling my mind</p>
<p><code>undefined reference to 'GPS::isValidSentence(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'</code></p>
<p>my header file <code>parseNMEA.h</code> is as follows:</p>
<pre><code>#ifndef PARSENMEA_H_211217
#define PARSENMEA_H_211217
#include <string>
#include <list>
#include <vector>
#include <utility>
#include "position.h"
namespace GPS
{
using std::string;
using std::vector;
using std::pair;
bool isValidSentence(const string &);
}
#endif
</code></pre>
<p>and my source file <code>parseNMEA.cpp</code> is:</p>
<pre><code>#include "parseNMEA.h"
using namespace GPS;
bool isValidSentence(const string &n)
{
string test = n;
bool result;
if (test.find("$GP") != string::npos) //Find the prefix
{
if (test.size() > 5) //Check if it has 3 char identifier
{
//check if it has ',' after identifier
if (test[6] == ',')
{
//check for a '*'
if(test.find("*",7))
{
result = true;
}
}
}
}
else
result = false;
return result;
}
</code></pre>
<p>Any ideas as to whats going on? I've tried <code>bool isValidSentence (const string &n)</code> in the header file but the same error code</p>
| 0debug
|
Convert a x.0 float to int function : <p>Ok, kinda hard question to ask in a title, but here is what i want to do.</p>
<p>I want to basically detect if my float has a 0 after the . so that i can skip printing out the - for example - 1.0 and just print 1. Anyone have an idea as to how to do this ?
I was thinking of some sort of modulus operator but cant really figure out a good way for that.
Any help would be greatly appreciated.</p>
| 0debug
|
jQuery Datatables align center 1 column : <p>Want to align center just the first column called "Status":</p>
<pre><code> $("#TransactionTable").DataTable({
ajax: {
url: '/Transaction/SearchMockup',
type: 'POST',
data: {
cardEndingWith: $("#ccn").val(),
status: $("#status").val(),
supplier: $("#supplier").val(),
fromDate: $("#fromDate").val(),
toDate: $("#toDate").val()
}
},
columns: [
{
data: 'Status', render: function (data, type, row) {
switch (data) {
case 1:
return '<div id="circleRed"></div>'
break;
case 2:
return '<div id="circleGreen"></div>'
break;
case 3:
return '<div id="circleOrange"></div>'
break;
}
}
},
{ data: 'TransactionId' },
{ data: 'CreditCardNumber' },
{ data: 'Supplier' },
{ data: 'CreatedAt' },
{ data: 'Amount' }
]
});
</code></pre>
<p>What i need to add the columns option to make it happen? I try to read all the Datatables doc and google.</p>
| 0debug
|
Where should I save a view file in laravel? : <p>As I am new to laravel, I would like to know where to save a view file which I created as form.php and how to call it using routes.php</p>
| 0debug
|
I want to retrieve user information from the google signin and put it on the navigation sidebar. : I have made a login page for my app and then a navigation bar activity on Android studio. I am using firebase in my app for the Google SignIn. I want to retrieve the user information such as Name, email address and their profile picture and display it on the navigation side bar!
I am new to coding and Android studio so It would be helpful if you can give me a detailed procedure to do the thing mentioned above.
| 0debug
|
static void qvirtio_scsi_pci_free(QVirtIOSCSI *vs)
{
int i;
for (i = 0; i < vs->num_queues + 2; i++) {
qvirtqueue_cleanup(vs->dev->bus, vs->vq[i], vs->qs->alloc);
}
qvirtio_pci_device_disable(container_of(vs->dev, QVirtioPCIDevice, vdev));
g_free(vs->dev);
qvirtio_scsi_stop(vs->qs);
g_free(vs);
}
| 1threat
|
static void memory_region_iorange_read(IORange *iorange,
uint64_t offset,
unsigned width,
uint64_t *data)
{
MemoryRegion *mr = container_of(iorange, MemoryRegion, iorange);
if (mr->ops->old_portio) {
const MemoryRegionPortio *mrp = find_portio(mr, offset, width, false);
*data = ((uint64_t)1 << (width * 8)) - 1;
if (mrp) {
*data = mrp->read(mr->opaque, offset - mrp->offset);
}
return;
}
*data = mr->ops->read(mr->opaque, offset, width);
}
| 1threat
|
Corporate Github behind proxy: Received HTTP code 503 from proxy after CONNECT : <p>I am trying to clone from a corporate git repo, but always receive this error message after a while:</p>
<p>fatal: unable to access URL: Received HTTP code 503 from proxy after CONNECT</p>
<p>I have the following .gitconfig file:</p>
<pre><code>[https]
sslVerify = false
proxy = https://proxy.corpadderess:8080
[http]
sslVerify = false
proxy = http://proxy.corpadderess:8080
</code></pre>
| 0debug
|
Is it possible to have a [OneTimeSetup] for ALL tests? : <p>I'm using NUnit to run some Selenium tests and I've got a minor issue I want to see if I can get corrected. What's happening is that the <em>[OneTimeSetUp]</em> and <em>[OneTimeTearDown]</em> is running after each fixture finishes. What I want is to run [OneTimeSetUp] once when the tests are started, and the teardown to run once ALL fixtures have finished.</p>
<p><strong>TestBaseClass.cs</strong></p>
<pre><code>public class TestBaseClass
{
[OneTimeSetUp]
public void Init()
{
// Login
}
[OneTimeTearDown]
public void TearDown()
{
Driver.Close();
}
}
</code></pre>
<p><strong>NavigationTests</strong></p>
<pre><code>[TestFixture]
public class NavigationTests : TestBaseClass
{
// Tests
}
</code></pre>
<p><strong>MainPageTests</strong></p>
<pre><code>[TestFixture]
public class MainPageTests : TestBaseClass
{
// Tests
}
</code></pre>
| 0debug
|
int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
{
int ret = 0;
if (ff_lockmgr_cb) {
if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN))
return -1;
}
entangled_thread_counter++;
if(entangled_thread_counter != 1){
av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n");
ret = -1;
goto end;
}
if(avctx->codec || !codec) {
ret = AVERROR(EINVAL);
goto end;
}
if (codec->priv_data_size > 0) {
if(!avctx->priv_data){
avctx->priv_data = av_mallocz(codec->priv_data_size);
if (!avctx->priv_data) {
ret = AVERROR(ENOMEM);
goto end;
}
if(codec->priv_class){
*(AVClass**)avctx->priv_data= codec->priv_class;
av_opt_set_defaults(avctx->priv_data);
}
}
} else {
avctx->priv_data = NULL;
}
if(avctx->coded_width && avctx->coded_height)
avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
else if(avctx->width && avctx->height)
avcodec_set_dimensions(avctx, avctx->width, avctx->height);
if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height)
&& ( av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx) < 0
|| av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0)) {
av_log(avctx, AV_LOG_WARNING, "ignoring invalid width/height values\n");
avcodec_set_dimensions(avctx, 0, 0);
}
if (codec->decode)
av_freep(&avctx->subtitle_header);
#define SANE_NB_CHANNELS 128U
if (avctx->channels > SANE_NB_CHANNELS) {
ret = AVERROR(EINVAL);
goto free_and_end;
}
avctx->codec = codec;
if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == codec->type) &&
avctx->codec_id == CODEC_ID_NONE) {
avctx->codec_type = codec->type;
avctx->codec_id = codec->id;
}
if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type
&& avctx->codec_type != AVMEDIA_TYPE_ATTACHMENT)) {
av_log(avctx, AV_LOG_ERROR, "codec type or id mismatches\n");
ret = AVERROR(EINVAL);
goto free_and_end;
}
avctx->frame_number = 0;
if (HAVE_THREADS && !avctx->thread_opaque) {
ret = ff_thread_init(avctx);
if (ret < 0) {
goto free_and_end;
}
}
if (avctx->codec->max_lowres < avctx->lowres) {
av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n",
avctx->codec->max_lowres);
ret = AVERROR(EINVAL);
goto free_and_end;
}
if (avctx->codec->sample_fmts && avctx->codec->encode) {
int i;
for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++)
if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
break;
if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n");
ret = AVERROR(EINVAL);
goto free_and_end;
}
}
if(avctx->codec->init && !(avctx->active_thread_type&FF_THREAD_FRAME)){
ret = avctx->codec->init(avctx);
if (ret < 0) {
goto free_and_end;
}
}
end:
entangled_thread_counter--;
if (ff_lockmgr_cb) {
(*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE);
}
return ret;
free_and_end:
av_freep(&avctx->priv_data);
avctx->codec= NULL;
goto end;
}
| 1threat
|
static int mov_preroll_write_stbl_atoms(AVIOContext *pb, MOVTrack *track)
{
struct sgpd_entry {
int count;
int16_t roll_distance;
int group_description_index;
};
struct sgpd_entry *sgpd_entries = NULL;
int entries = -1;
int group = 0;
int i, j;
const int OPUS_SEEK_PREROLL_MS = 80;
int roll_samples = av_rescale_q(OPUS_SEEK_PREROLL_MS,
(AVRational){1, 1000},
(AVRational){1, 48000});
if (track->entry) {
sgpd_entries = av_malloc_array(track->entry, sizeof(*sgpd_entries));
if (!sgpd_entries)
return AVERROR(ENOMEM);
}
av_assert0(track->par->codec_id == AV_CODEC_ID_OPUS);
for (i = 0; i < track->entry; i++) {
int roll_samples_remaining = roll_samples;
int distance = 0;
for (j = i - 1; j >= 0; j--) {
roll_samples_remaining -= get_cluster_duration(track, j);
distance++;
if (roll_samples_remaining <= 0)
break;
}
if (roll_samples_remaining > 0)
distance = 0;
av_assert0(distance == 0 || (distance >= 2 && distance <= 32));
if (i && distance == sgpd_entries[entries].roll_distance) {
sgpd_entries[entries].count++;
} else {
entries++;
sgpd_entries[entries].count = 1;
sgpd_entries[entries].roll_distance = distance;
sgpd_entries[entries].group_description_index = distance ? ++group : 0;
}
}
entries++;
if (!group)
return 0;
avio_wb32(pb, 24 + (group * 2));
ffio_wfourcc(pb, "sgpd");
avio_wb32(pb, 1 << 24);
ffio_wfourcc(pb, "roll");
avio_wb32(pb, 2);
avio_wb32(pb, group);
for (i = 0; i < entries; i++) {
if (sgpd_entries[i].group_description_index) {
avio_wb16(pb, -sgpd_entries[i].roll_distance);
}
}
avio_wb32(pb, 20 + (entries * 8));
ffio_wfourcc(pb, "sbgp");
avio_wb32(pb, 0);
ffio_wfourcc(pb, "roll");
avio_wb32(pb, entries);
for (i = 0; i < entries; i++) {
avio_wb32(pb, sgpd_entries[i].count);
avio_wb32(pb, sgpd_entries[i].group_description_index);
}
av_free(sgpd_entries);
return 0;
}
| 1threat
|
infinite while loop even after increment is declared : <p>Why this code print 10 indefinitely even if the increment of i is declared</p>
<pre><code>#include <stdio.h>
int main()
{
int i;
while (i = 10)
{
printf("%d\n",i);
i = i+1;//according to me this will increase the value of i from i = 10 to 11
}
return 0;
}
</code></pre>
<p>the expected outcome according to me is 10 but only 1 time as the value of i will change to 11 and the loop will no execute.</p>
| 0debug
|
static uint64_t get_v(ByteIOContext *bc)
{
uint64_t val = 0;
for(; bytes_left(bc) > 0; )
{
int tmp = get_byte(bc);
if (tmp&0x80)
val= (val<<7) + tmp - 0x80;
else
return (val<<7) + tmp;
}
return -1;
}
| 1threat
|
xgboost sklearn wrapper value 0for Parameter num_class should be greater equal to 1 : <p>I am trying to use the <code>XGBClassifier</code> wrapper provided by <code>sklearn</code> for a multiclass problem. My classes are [0, 1, 2], the objective that I use is <code>multi:softmax</code>. When I am trying to fit the classifier I get </p>
<blockquote>
<p>xgboost.core.XGBoostError: value 0for Parameter num_class should be greater equal to 1</p>
</blockquote>
<p>If I try to set the num_class parameter the I get the error</p>
<blockquote>
<p>got an unexpected keyword argument 'num_class'</p>
</blockquote>
<p>Sklearn is setting this parameter automatically so I am not supposed to pass that argument. But why do I get the first error?</p>
| 0debug
|
Web development question? I am using MEN stack(mongo, express,node) : I'm working on a project wherein I am using a news api to show the contents of a specified user typed topic,for eg "technology" , but the problem is sometimes i get thousands of results and all are displayed on a single page,but i want the number of pages of the search result to change dynamically with the typed topic,for example tech may have 100 pages while sports may have 500 pages.
How do i do this for my website?
Any sources,links,source code might help me a lot.
Thanks.
| 0debug
|
static ExitStatus trans_fop_wew_0c(DisasContext *ctx, uint32_t insn,
const DisasInsn *di)
{
unsigned rt = extract32(insn, 0, 5);
unsigned ra = extract32(insn, 21, 5);
return do_fop_wew(ctx, rt, ra, di->f_wew);
}
| 1threat
|
C++ invalid use of void, why? : <pre><code>char mem[8];
uint64_t *memory{(uint64_t*)(void*)&mem[0]};
std::cout << "diff: " << (void*)memory - (void*)(&mem[0]) << std::endl;
</code></pre>
<p>Trivial example, error message with gcc is:</p>
<pre><code>error: invalid use of ‘void’
std::cout << "diff: " << (void*)memory - (void*)(&mem[0]) << std::endl;
</code></pre>
| 0debug
|
static void pred4x4_horizontal_vp8_c(uint8_t *src, const uint8_t *topright, int stride){
const int lt= src[-1-1*stride];
LOAD_LEFT_EDGE
AV_WN32A(src+0*stride, ((lt + 2*l0 + l1 + 2) >> 2)*0x01010101);
AV_WN32A(src+1*stride, ((l0 + 2*l1 + l2 + 2) >> 2)*0x01010101);
AV_WN32A(src+2*stride, ((l1 + 2*l2 + l3 + 2) >> 2)*0x01010101);
AV_WN32A(src+3*stride, ((l2 + 2*l3 + l3 + 2) >> 2)*0x01010101);
}
| 1threat
|
what is difference between rem==0 and rem=0 in this code? : <p>THEY WERE ASKING ME TO ADD SOMETHING
.I DINT KNOW WHAT TO ADD.THIS LINE IS A WASTE.
SUGGEST ME AN EDIT</p>
<p>#include
using namespace std;</p>
<pre><code>typedef long long lli;
lli mod = 1000000007;
int n;
char a[200000 + 10];
lli dp[200000 + 10][9];
lli solve(int pos, int rem)
{
if (pos == n) //**HERE**
return (rem == 0);
if (dp[pos][rem] != -1)
return dp[pos][rem];
dp[pos][rem] = 0;
if (pos + 1 <= n)
dp[pos][rem] = solve(pos + 1, (rem * 10 + (a[pos] - '0')) % 8);
if (pos + 1 <= n)
dp[pos][rem] += solve(pos + 1, rem);
dp[pos][rem] %= mod;
return dp[pos][rem];
}
</code></pre>
| 0debug
|
static int read_huffman_tables(HYuvContext *s, uint8_t *src, int length){
GetBitContext gb;
int i;
init_get_bits(&gb, src, length*8);
for(i=0; i<3; i++){
read_len_table(s->len[i], &gb);
if(generate_bits_table(s->bits[i], s->len[i])<0){
return -1;
}
#if 0
for(j=0; j<256; j++){
printf("%6X, %2d, %3d\n", s->bits[i][j], s->len[i][j], j);
}
#endif
free_vlc(&s->vlc[i]);
init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0);
}
generate_joint_tables(s);
return (get_bits_count(&gb)+7)/8;
}
| 1threat
|
Disabling Spring Security headers does not work : <p>I need to disable the cache control headers in my Spring Security conf.</p>
<p>According to the documentation a simple <code>http.headers.disable()</code> should do it, but I still see the</p>
<pre><code>Cache-Control:no-cache, no-store, max-age=0, must-revalidate
Expires:0
Pragma:no-cache
</code></pre>
<p>headers in responses.</p>
<p>My current security config is:</p>
<pre><code>http.antMatcher("/myPath/**") // "myPath" is of course not the real path
.headers().disable()
.authorizeRequests()
// ... abbreviated
.anyRequest().authenticated();
</code></pre>
<p><strong>Things I've tried so far:</strong></p>
<p><strong>application.properties</strong></p>
<p>I added the <code>security.headers.cache=false</code> line, but that made no difference.</p>
<p><strong>Using a filter</strong></p>
<p>I tried the following filter:</p>
<pre><code>@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
chain.doFilter(request, new HttpServletResponseWrapper((HttpServletResponse) response) {
@Override
public void setHeader(String name, String value) {
if (name.equalsIgnoreCase("Cache-Control")) {
value = "";
} else if (name.equalsIgnoreCase("Expires")) {
value = "";
} else if (name.equalsIgnoreCase("Pragma")) {
value = "";
}
super.setHeader(name, value);
}
});
}
</code></pre>
<p>After adding logging I saw that this filter only writes the <code>X-XSS-Protection</code> header, all the cache headers are written somewhere later and this filter doesn't have access to "override" them. This happens even if I add this filter at the last position of the security filter chain.</p>
<p><strong>Using an interceptor</strong></p>
<p>I tried the following interceptor:</p>
<pre><code>@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
String requestUri = request.getRequestURI();
response.setHeader("Cache-Control", "max-age=3600");
response.setHeader("Expires", "3600");
response.setHeader("Pragma", "");
}
</code></pre>
<p>This (quite predictably) just added the headers, meaning that the original <code>no-cache</code> headers still appear in addition to the ones added by the interceptor.</p>
<p>I'm at my wits end here. How do I get rid of the cache control header set by Spring security?</p>
| 0debug
|
How can I turn list of strings to list of lists? : <p>I am new in programming and in stackoverflow. Sorry is this seems too basic.
I am trying to turn this:</p>
<p>I am trying to train a AI for predicting destination a car based on historical data.
It is inside a column and I must iterate over all of them.
I a single list it is working, but in a column, it is not for some reason.</p>
<p>I am trying this on windows 10 in anaconda , jupyter notebook </p>
<p>I am trying to turn this:</p>
<pre><code>lst = ['55.7492,12.5405', '55.7492,12.5405', '55.7492,12.5406', '55.7492,12.5406']
</code></pre>
<p>into this </p>
<pre><code>lst = [[55.7492,12.5405], [55.7492,12.5405], [55.7492,12.5406], [55.7492,12.5406]]
</code></pre>
<p>I have a column with a lot of those in a csv file.</p>
<p>I tryed to turn them like this:</p>
<pre><code>
[[x] for x in lst]
[['55.7492,12.5405'],
['55.7492,12.5405'],
['55.7492,12.5406'],
['55.7492,12.5406']]
</code></pre>
<p>So its working find outside of the csv but when I try to do it for every box in the colomn:</p>
<pre><code>for stuff in data['column']:
[[x] for x in stuff]
for stuff in data_train['locations']:
[map(int,x.split()) for x in stuff]
</code></pre>
<p>Nothing changes in the column .</p>
| 0debug
|
Make a button image change when pressed / focused / disabled : <p>I have several pictures of the same button, each one representing it in a different sate: normal, pressed, focused, disabled.</p>
<p>How can I make it into an html button that automatically shows the correct picture (and also has an onClick event) ?</p>
<p>Feel free to use html / css / javascript. </p>
<p>The tag also doesn't need to be a button, it could be an image, , or whatever you want, but hopefully written in a generic enough way for others to use your solution too</p>
<p>Thanks!</p>
| 0debug
|
Jquery - difference between previous row : I have the following table:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<table>
<tr>
<th>Year</th>
<th>Total</th>
<th>Diff</th>
<th>Percentage</th>
</tr>
<tr>
<td>2017</td>
<td>80,000</td>
<td>?</td>
<td>?</td>
</tr>
<tr>
<td>2016</td>
<td>65,000</td>
<td>?</td>
<td>?</td>
</tr>
<tr>
<td>2015</td>
<td>59,000</td>
<td>?</td>
<td>?</td>
</tr>
<tr>
<td>2014</td>
<td>32,000</td>
<td>?</td>
<td>?</td>
</tr>
</table>
<!-- end snippet -->
Where the question marks are for DIFF and % I need to compare previous rows against each other and work out the difference in total and by percentage.
I relatively new to jquery and completely bewildered on how to achieve this.
Any help would be amazing.
| 0debug
|
Getting 'you cannot reject the app version in the current state' error trying to reject binary waiting for review : <p>I'm trying to reject an app binary from app store connect because I discovered a bug and made a new build.
The application status is 'waiting for review'.</p>
<p>There's a button to reject the binary shown here.</p>
<p><a href="https://i.stack.imgur.com/RvOWf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RvOWf.png" alt="enter image description here"></a></p>
<p>Clicking 'remove this version from review' presents me with the dialog below. When I click 'Remove' the red error message appears and the page is redirected to app store connect home page</p>
<p><a href="https://i.stack.imgur.com/3iRIW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3iRIW.png" alt="When I click 'Remove' the red error message appears and the page is redirected to app store connect home page"></a></p>
<p>I tried a lot but I get the same error and redirection every time.</p>
<p>Thanks for advance.</p>
| 0debug
|
Pandas: `item` has been deprecated : <p>So far I used this line of code here:</p>
<pre><code>max_total_gross = event_data["max_total_gross"].loc[event_data["event_id"] == event_id].item()
</code></pre>
<p>Since I updated Pandas I receive the future warning:</p>
<blockquote>
<p>/opt/conda/lib/python3.7/site-packages/ipykernel_launcher.py:12:
FutureWarning: <code>item</code> has been deprecated and will be removed in a
future version if sys.path[0] == '':</p>
</blockquote>
<p>I tried to fix it that way, but it's not the same outcome:</p>
<pre><code>event_data.loc[event_data.event_id == event_id, 'max_total_gross']
</code></pre>
<p>I expected a single integer.</p>
| 0debug
|
Kali Linux: Broken Java : <p>Java stopped working in kali linux. When I run the jar file I get the exception. For example, exception from CobaltStrike. I have it on 2.5, 3.6 and 3.8 versions.</p>
<pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: sun/swing/plaf/synth/SynthIcon
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1009)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:801)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:699)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:622)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:580)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1009)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:801)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:699)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:622)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:580)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:374)
at java.desktop/com.sun.beans.finder.ClassFinder.findClass(ClassFinder.java:103)
at java.desktop/com.sun.beans.finder.ClassFinder.resolveClass(ClassFinder.java:171)
at java.desktop/com.sun.beans.decoder.DocumentHandler.findClass(DocumentHandler.java:406)
at java.desktop/com.sun.beans.decoder.NewElementHandler.addAttribute(NewElementHandler.java:80)
at java.desktop/com.sun.beans.decoder.ObjectElementHandler.addAttribute(ObjectElementHandler.java:102)
at java.desktop/com.sun.beans.decoder.DocumentHandler.startElement(DocumentHandler.java:296)
at java.desktop/javax.swing.plaf.synth.SynthParser.startElement(SynthParser.java:1227)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at java.xml/javax.xml.parsers.SAXParser.parse(SAXParser.java:394)
at java.xml/javax.xml.parsers.SAXParser.parse(SAXParser.java:197)
at java.desktop/javax.swing.plaf.synth.SynthParser.parse(SynthParser.java:242)
at java.desktop/javax.swing.plaf.synth.SynthLookAndFeel.load(SynthLookAndFeel.java:579)
at de.javasoft.plaf.synthetica.SyntheticaLookAndFeel.loadXMLConfig(SyntheticaLookAndFeel.java:401)
at de.javasoft.plaf.synthetica.SyntheticaLookAndFeel.<init>(SyntheticaLookAndFeel.java:339)
at de.javasoft.plaf.synthetica.SyntheticaBlueIceLookAndFeel.<init>(SyntheticaBlueIceLookAndFeel.java:31)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
at java.base/java.lang.Class.newInstance(Class.java:560)
at java.desktop/javax.swing.UIManager.setLookAndFeel(UIManager.java:632)
at aggressor.ui.UseSynthetica.setup(UseSynthetica.java:29)
at aggressor.Aggressor.main(Aggressor.java:34)
Caused by: java.lang.ClassNotFoundException: sun.swing.plaf.synth.SynthIcon
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 52 more
</code></pre>
<p>I have openjdk-9-jdk and jre installed with headless versions. So i have openjdk-8-jre, how i can run jars throught 8 jre? Any help?
I have purged and reinstalled java, but no solution was found(
Previously, everything was run without problems</p>
| 0debug
|
Memory allocation using calloc : <p>I want to initialize my large 2D array to zero.
if i allocate memory through calloc it will automatically initialize all the cells to zero.
Whether it is possible to allocate memory for 2D array using single calloc function ?
Thank you</p>
| 0debug
|
static int split_field_ref_list(Picture *dest, int dest_len,
Picture *src, int src_len,
int parity, int long_i){
int i = split_field_half_ref_list(dest, dest_len, src, long_i, parity);
dest += i;
dest_len -= i;
i += split_field_half_ref_list(dest, dest_len, src + long_i,
src_len - long_i, parity);
return i;
}
| 1threat
|
static void ide_sector_read_cb(void *opaque, int ret)
{
IDEState *s = opaque;
int n;
s->pio_aiocb = NULL;
s->status &= ~BUSY_STAT;
if (ret == -ECANCELED) {
return;
}
block_acct_done(bdrv_get_stats(s->bs), &s->acct);
if (ret != 0) {
if (ide_handle_rw_error(s, -ret, IDE_RETRY_PIO |
IDE_RETRY_READ)) {
return;
}
}
n = s->nsector;
if (n > s->req_nb_sectors) {
n = s->req_nb_sectors;
}
ide_transfer_start(s, s->io_buffer, n * BDRV_SECTOR_SIZE, ide_sector_read);
ide_set_irq(s->bus);
ide_set_sector(s, ide_get_sector(s) + n);
s->nsector -= n;
}
| 1threat
|
how to add a row in a datagridview via other form using C# : <p>I'm stuck in a problem in windown form (C#). I have MainUI form consist of a DataGridView, that contains data in my database and a button called BtnRegister. And I have Register form containing some TextBoxs, CheckBoxs... and a confirm button. When I click BtnRegister, Register form is shown and I can input data by typing in textboxs, ... and confirm data inputed by clicking confirm button. The problem is that I dont known how to add a new row into DataGridView in MainUI form by clicking confirm button in Register form. <a href="https://i.stack.imgur.com/J52ta.png" rel="nofollow noreferrer">enter image description here</a></p>
<p>Sorry, my English is not good. But I have a significant hope that some one can help to solve this problem. Thank you.</p>
| 0debug
|
Finding the minimum and maximum value within a Metal texture : <p>I have a <code>MTLTexture</code> containing 16bit unsigned integers (<code>MTLPixelFormatR16Uint</code>). The values range from about 7000 to 20000, with 0 being used as a 'nodata' value, which is why it is skipped in the code below. I'd like to find the minimum and maximum values so I can rescale these values between 0-255. Ultimately I'll be looking to base the minimum and maximum values on a histogram of the data (it has some outliers), but for now I'm stuck on simply extracting the min/max.</p>
<p><em>I can read the data from the GPU to CPU and pull the min/max values out but would prefer to perform this task on the GPU.</em></p>
<p><strong>First attempt</strong></p>
<p>The command encoder is dispatched with 16x16 threads per thread group, the number of thread groups is based on the texture size (eg; width = textureWidth / 16, height = textureHeight / 16).</p>
<pre><code>typedef struct {
atomic_uint min;
atomic_uint max;
} BandMinMax;
kernel void minMax(texture2d<ushort, access::read> band1 [[texture(0)]],
device BandMinMax &out [[buffer(0)]],
uint2 gid [[thread_position_in_grid]])
{
ushort value = band1.read(gid).r;
if (value != 0) {
uint currentMin = atomic_load_explicit(&out.min, memory_order_relaxed);
uint currentMax = atomic_load_explicit(&out.max, memory_order_relaxed);
if (value > currentMax) {
atomic_store_explicit(&out.max, value, memory_order_relaxed);
}
if (value < currentMin) {
atomic_store_explicit(&out.min, value, memory_order_relaxed);
}
}
}
</code></pre>
<p>From this I get a minimum and maximum value, but for the same dataset the min and max will often return different values. Fairly certain this is the min and max from a single thread when there are multiple threads running.</p>
<p><strong>Second attempt</strong></p>
<p>Building on the previous attempt, this time I'm storing the individual min/max values from each thread, all 256 (16x16).</p>
<pre><code>kernel void minMax(texture2d<ushort, access::read> band1 [[texture(0)]],
device BandMinMax *out [[buffer(0)]],
uint2 gid [[thread_position_in_grid]],
uint tid [[ thread_index_in_threadgroup ]])
{
ushort value = band1.read(gid).r;
if (value != 0) {
uint currentMin = atomic_load_explicit(&out[tid].min, memory_order_relaxed);
uint currentMax = atomic_load_explicit(&out[tid].max, memory_order_relaxed);
if (value > currentMax) {
atomic_store_explicit(&out[tid].max, value, memory_order_relaxed);
}
if (value < currentMin) {
atomic_store_explicit(&out[tid].min, value, memory_order_relaxed);
}
}
}
</code></pre>
<p>This returns an array containing 256 sets of min/max values. From these I guess I could find the lowest of the minimum values, but this seems like a poor approach. Would appreciate a pointer in the right direction, thanks!</p>
| 0debug
|
Android Layouting Inquiry : Hi I would like to know ho to make this layout in android I will be adding an image on the 2 columns below that is clickable. This is my first time doing android development
[![enter image description here][1]][1]
[1]: http://i.stack.imgur.com/RUEDg.jpg
| 0debug
|
Install multiple versions of cuda and cudnn : <p>I am currently using cuda version 7.5 with cuDNN version 5 for MatConvNet. I'd like to install version 8.0 and cuDNN version 5.1 and I want to know if there will be any conflicts if I have the environment paths pointing to both versions of cuda and cudnn</p>
| 0debug
|
django aggregation: sum then average : <p>Using django's ORM annotate() and/or aggregate(): I want to sum up based on one category field and then average over the category values per date. I tried to do it using two annotate() statements but got a FieldError.</p>
<p>I'm doing this: </p>
<pre><code>queryset1 = self.data.values('date', 'category').annotate(sum_for_field=Sum('category'))
</code></pre>
<p>Which outputs a ValuesQuerySet object with things like (so a sum for each value of category):</p>
<pre><code>[{'category': 'apples', 'date': '2015-10-12', sum_for_field=2000},
{'category': 'carrots', 'date': '2015-10-12', sum_for_field=5000},
{'category': 'apples', 'date': '2015-10-13', sum_for_field=3000},
{'category': 'carrots', 'date': '2015-10-13', sum_for_field=6000}, ...
]
</code></pre>
<p>I then want to average the sum_for_field field for each date to output something like:</p>
<pre><code>[ {'date': '2015-10-12', avg_final: 3500},
{'date': '2015-10-13', avg_final: 4500}, ...
]
</code></pre>
<p>I tried doing this:</p>
<pre><code>queryset2 = queryset1.values('date', 'sum_for_field')
result = queryset2.annotate(avg_final=Avg('sum_for_field'))
</code></pre>
<p>But I got this FieldError: </p>
<pre><code>FieldError: FieldError: Cannot compute Avg('sum_for_field'): 'sum_for_field' is an aggregate
</code></pre>
| 0debug
|
void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr)
{
CPUState *cpu;
PageDesc *p;
uint32_t h;
tb_page_addr_t phys_pc;
assert_tb_locked();
atomic_set(&tb->invalid, true);
phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK);
h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->trace_vcpu_dstate);
qht_remove(&tcg_ctx.tb_ctx.htable, tb, h);
if (tb->page_addr[0] != page_addr) {
p = page_find(tb->page_addr[0] >> TARGET_PAGE_BITS);
tb_page_remove(&p->first_tb, tb);
invalidate_page_bitmap(p);
}
if (tb->page_addr[1] != -1 && tb->page_addr[1] != page_addr) {
p = page_find(tb->page_addr[1] >> TARGET_PAGE_BITS);
tb_page_remove(&p->first_tb, tb);
invalidate_page_bitmap(p);
}
h = tb_jmp_cache_hash_func(tb->pc);
CPU_FOREACH(cpu) {
if (atomic_read(&cpu->tb_jmp_cache[h]) == tb) {
atomic_set(&cpu->tb_jmp_cache[h], NULL);
}
}
tb_remove_from_jmp_list(tb, 0);
tb_remove_from_jmp_list(tb, 1);
tb_jmp_unlink(tb);
tcg_ctx.tb_ctx.tb_phys_invalidate_count++;
}
| 1threat
|
Redirecting command output in docker : <p>I want to do some simple logging for my server which is a small Flask app running in a Docker container.</p>
<p>Here is the Dockerfile</p>
<pre><code># Dockerfile
FROM dreen/flask
MAINTAINER dreen
WORKDIR /srv
# Get source
RUN mkdir -p /srv
COPY perfektimprezy.tar.gz /srv/perfektimprezy.tar.gz
RUN tar x -f perfektimprezy.tar.gz
RUN rm perfektimprezy.tar.gz
# Run server
EXPOSE 80
CMD ["python", "index.py", "1>server.log", "2>server.log"]
</code></pre>
<p>As you can see on the last line I redirect stderr and stdout to a file. Now I run this container and shell into it</p>
<pre><code>docker run -d -p 80:80 perfektimprezy
docker exec -it "... id of container ..." bash
</code></pre>
<p>And observe the following things:</p>
<p>The server is running and the website working</p>
<p>There is no <code>/srv/server.log</code></p>
<p><code>ps aux | grep python</code> yields:</p>
<pre><code>root 1 1.6 3.2 54172 16240 ? Ss 13:43 0:00 python index.py 1>server.log 2>server.log
root 12 1.9 3.3 130388 16740 ? Sl 13:43 0:00 /usr/bin/python index.py 1>server.log 2>server.log
root 32 0.0 0.0 8860 388 ? R+ 13:43 0:00 grep --color=auto python
</code></pre>
<p>But there are no logs... HOWEVER, if I <code>docker attach</code> to the container I can see the app generating output in the console.</p>
<p>How do I properly redirect stdout/err to a file when using Docker?</p>
| 0debug
|
Basemap with Python 3.5 Anaconda on Windows : <p>I use Python 3.5 with latest version of Anaconda on Windows (64 bit). I wanted to install Basemap using <code>conda install basemap</code>. Apparently there is a conflict between Python 3 and basemap. After some googling indeed I found that basemap is not supported on Python 3 for Windows users (ex: <a href="https://groups.google.com/a/continuum.io/forum/#!topic/anaconda/TjAwi3ilQaU" rel="noreferrer">https://groups.google.com/a/continuum.io/forum/#!topic/anaconda/TjAwi3ilQaU</a>).</p>
<p>For obvious reasons I do not want to downgrade to Python 2. What would then be the simplest alternative solution?</p>
<ul>
<li>Is there an alternative package similar to basemap for ploting maps, etc.?</li>
<li>Should I use a second environment which uses Python 2 and basemap? I have never done that but it seems possible (<a href="http://conda.pydata.org/docs/py2or3.html" rel="noreferrer">http://conda.pydata.org/docs/py2or3.html</a>). Is it "safe"? Should I install again all the other packages (matplotlib, numpy, etc.) on the second environment? </li>
</ul>
<p>Thanks in advance for the help and advice. </p>
| 0debug
|
static int vmdk_open(BlockDriverState *bs, const char *filename, int flags)
{
BDRVVmdkState *s = bs->opaque;
uint32_t magic;
int l1_size, i, ret;
if (parent_open)
flags = BDRV_O_RDONLY;
fprintf(stderr, "(VMDK) image open: flags=0x%x filename=%s\n", flags, bs->filename);
ret = bdrv_file_open(&s->hd, filename, flags | BDRV_O_AUTOGROW);
if (ret < 0)
return ret;
if (bdrv_pread(s->hd, 0, &magic, sizeof(magic)) != sizeof(magic))
goto fail;
magic = be32_to_cpu(magic);
if (magic == VMDK3_MAGIC) {
VMDK3Header header;
if (bdrv_pread(s->hd, sizeof(magic), &header, sizeof(header)) != sizeof(header))
goto fail;
s->cluster_sectors = le32_to_cpu(header.granularity);
s->l2_size = 1 << 9;
s->l1_size = 1 << 6;
bs->total_sectors = le32_to_cpu(header.disk_sectors);
s->l1_table_offset = le32_to_cpu(header.l1dir_offset) << 9;
s->l1_backup_table_offset = 0;
s->l1_entry_sectors = s->l2_size * s->cluster_sectors;
} else if (magic == VMDK4_MAGIC) {
VMDK4Header header;
if (bdrv_pread(s->hd, sizeof(magic), &header, sizeof(header)) != sizeof(header))
goto fail;
bs->total_sectors = le64_to_cpu(header.capacity);
s->cluster_sectors = le64_to_cpu(header.granularity);
s->l2_size = le32_to_cpu(header.num_gtes_per_gte);
s->l1_entry_sectors = s->l2_size * s->cluster_sectors;
if (s->l1_entry_sectors <= 0)
goto fail;
s->l1_size = (bs->total_sectors + s->l1_entry_sectors - 1)
/ s->l1_entry_sectors;
s->l1_table_offset = le64_to_cpu(header.rgd_offset) << 9;
s->l1_backup_table_offset = le64_to_cpu(header.gd_offset) << 9;
if (parent_open)
s->is_parent = 1;
else
s->is_parent = 0;
if (vmdk_parent_open(bs, filename) != 0)
goto fail;
s->parent_cid = vmdk_read_cid(bs,1);
} else {
goto fail;
}
l1_size = s->l1_size * sizeof(uint32_t);
s->l1_table = qemu_malloc(l1_size);
if (!s->l1_table)
goto fail;
if (bdrv_pread(s->hd, s->l1_table_offset, s->l1_table, l1_size) != l1_size)
goto fail;
for(i = 0; i < s->l1_size; i++) {
le32_to_cpus(&s->l1_table[i]);
}
if (s->l1_backup_table_offset) {
s->l1_backup_table = qemu_malloc(l1_size);
if (!s->l1_backup_table)
goto fail;
if (bdrv_pread(s->hd, s->l1_backup_table_offset, s->l1_backup_table, l1_size) != l1_size)
goto fail;
for(i = 0; i < s->l1_size; i++) {
le32_to_cpus(&s->l1_backup_table[i]);
}
}
s->l2_cache = qemu_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint32_t));
if (!s->l2_cache)
goto fail;
return 0;
fail:
qemu_free(s->l1_backup_table);
qemu_free(s->l1_table);
qemu_free(s->l2_cache);
bdrv_delete(s->hd);
return -1;
}
| 1threat
|
Rendering components on a button click in React.js : Im creating a page in that if user clicks a add more button text box should be added as many time the user clicks
I have created a component there I created texbox. I tried to render this component to another component on button click but it is not rendering`enter code here`
----------
class Addmore extends React.Component {
render() {
return (
<div>
<label className="float-left"> CC</label>
<input type="text" class="form-control" />
</div>
);
}
}
class abc extends React.Component {
constructor(props)
{
super(props);
}
state = {
addcomp: false
};
click() {
this.setState({
addcomp: true,
});
var x= document.getElementById("more");
x.parentNode.appendChild(<Add/>);
}
render() {
return (
<div class="row">
<div class="col-3">
<label className="float-left"> BU</label>
<input type="text" class="form-control" />
<div id="more">
//HERE I HAVE TO RENDER ADDMORE
COMPONENT
</div>
<div class="col-3">
<button type="button" onClick={this.click.bind()}>
Add more
</button>
</div>
);
}
}
export default abc;
| 0debug
|
How can I check in javascript if it's day time or night time on the client? : <p>Using <a href="https://date-fns.org/v2.9.0/docs/isBefore" rel="nofollow noreferrer"><code>date-nfs</code></a>, how can I check if <code>new Date()</code> is between 8am and 8pm?</p>
| 0debug
|
How to print object notation from variable (javascript) : I have a question about using variables with object notations. Lets say i have the following code:
let anObject = {
name: 'Joaquin',
age: 27,
occupation: 'software developer',
interests: ['walking', 'Arduino', 'working']
}
let print = 'interests[0]';
console.log(anObject.interests[0]); //prints the result
console.log(anObject.print); //prints undefined
If i log `anObject.interests[0]` it prints the expected result. But when i store `interests[0]` in a variable and print it again it doesn't.
How can we overcome this problem and why is it not printing the expected result?
| 0debug
|
Get all %(name)s placeholders in python : <p>I have a string that contains <code>%(name)s</code> placeholders and I would like to get all the names, for example: <code>This is a %(name)s example string %(foo)s I would like %(bar)s to extract all the placeholders from %(place)s</code></p>
<p>I would like to get a list containing <code>name</code>, <code>foo</code>, <code>bar</code>, <code>place</code></p>
| 0debug
|
Jersey-Spring-Hibernate Maven Project Setup : **Project is based on JERSEY 2.25, SPRING 4.3.5 RELEASE, HIBERNATE 5.5.6 Final, USING MAVEN**
I am placing this request, because i couldn't find any complete solution for JERSEY-SPRING-HIBERNATE setup and configuration. As i went through a lot to problem to find the solution. I thought of sharing my knowledge on creating basic setup, to give a kick start to your project.
You can also refer to my Github project [Jersey-Spring-Hibernate-Project][1]
[1]:https://github.com/prayagkr/Jersey-Spring-Hibernate-Project
.
----------
To setup our project we need 4 files to configure.
1. web.xml
2. pom.xml
3. applicationContext.xml
4. MyApplication.java
----------
File name: **src/main/webapp/WEB-INF/web.xml**
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<!-- REGISTERING LISTNER -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- TO REGISTER THE BEANS -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<!-- TO REGISTER THE SERVLET which is mentioned in the MyApplication -->
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>org.pramod.config.MyApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/webapi/*</url-pattern>
</servlet-mapping>
</web-app>
----------
File Name: **src/main/resources/applicationContext.xml**
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/jerseyspringhibernate"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>org.pramod.model.Customer</value>
</list>
</property>
</bean>
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>
<bean id="customerService" class="org.pramod.service.CustomerServiceImpl"/>
<bean id="customerDao" class="org.pramod.dao.CustomerDaoImpl"/>
</beans>
----------
File Name : **pom.xml**
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.pramod</groupId>
<artifactId>JerseySpringHibernate</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>JerseySpringHibernate</name>
<build>
<finalName>JerseySpringHibernate</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
</dependency>
<!--
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
<exclusions>
<exclusion>
<artifactId>javax.servlet</artifactId>
<groupId>servlet-api</groupId>
</exclusion>
</exclusions>
</dependency>
-->
<!-- ******************************************************** -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- ********************** SPRING 4.3.4 ***************************** -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-instrument</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-instrument-tomcat</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc-portlet</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-websocket</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- ********************* HIBERNATE 5.5.6 ************************* -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId>
<version>${hibernate.version}</version>
</dependency>
<!-- ********************* MY SQL CONNECTOR ************************* -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
</dependencies>
<properties>
<jersey.version>2.25</jersey.version>
<spring.version>4.3.5.RELEASE</spring.version>
<hibernate.version>5.5.6.Final</hibernate.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
----------
Below mentioned Files are all java files, which are placed in the **src/main/java/** followed by package name. Package name is **org.pramod**. Example **src/main/java/org.pramod.***
File Name : **org.pramod.config.MyApplication.java**
package org.pramod.config;
import org.glassfish.jersey.server.ResourceConfig;
public class MyApplication extends ResourceConfig{
public MyApplication(){
register(MyResource.class);
register(CustomerResource.class);
}
}
----------
**THESE ARE THE SERVLET RESOURCE. 1. MyResource and 2. CustomerResource can be moved to org.pramod.resource package**
File Name : **org.pramod.config.MyResource.java**
package org.pramod.config;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.pramod.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Root resource (exposed at "myresource" path)
*/
@Path("myresource")
public class MyResource {
@Autowired
CustomerService customerService;
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getIt() {
return customerService.getStringTest();
}
}
----------
File Name: **org.pramod.config.CustomerResource.java**
package org.pramod.config;
import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.pramod.model.Customer;
import org.pramod.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
@Path("customers")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class CustomerResource {
@Autowired
CustomerService customerService;
@GET
public List<Customer> getCustomers(){
return customerService.getAllCustomer();
}
@GET
@Path("/{customerId}")
public Customer getCustomer(@PathParam("customerId") int id){
return customerService.getCustomerById(id);
}
@POST
public Customer saveCustomer(Customer customer){
return customerService.addCustomer(customer);
}
@PUT
@Path("/{customerId}")
public Customer updateCustomer(@PathParam("customerId") int id, Customer customer){
return customerService.updateCustomer(id, customer);
}
@DELETE
@Path("/{customerId}")
public Customer removeCustomer(@PathParam ("customerId") int id ){
return customerService.deleteCustomer(id);
}
}
----------
**THESE ARE THE Spring Service Files and Interface. 1. CustomerService and 2. CustomerServiceImpl**
File Name: **org.pramod.service.CustomerService.java**
package org.pramod.service;
import java.util.List;
import org.pramod.model.Customer;
public interface CustomerService {
String getStringTest();
Customer addCustomer(Customer customer);
Customer updateCustomer(int id, Customer customer);
Customer deleteCustomer(int id);
Customer getCustomerById(int id);
List<Customer> getAllCustomer();
}
----------
File Name: **org.pramod.service.CustomerServiceImpl.java**
package org.pramod.service;
import java.util.List;
import org.pramod.dao.CustomerDao;
import org.pramod.model.Customer;
import org.springframework.beans.factory.annotation.Autowired;
public class CustomerServiceImpl implements CustomerService {
@Autowired
private CustomerDao customerDao;
@Override
public String getStringTest() {
return customerDao.getStringTest();
}
@Override
public Customer addCustomer(Customer customer) {
return customerDao.addCustomer(customer);
}
@Override
public Customer updateCustomer(int id, Customer customer) {
return customerDao.updateCustomer(id, customer);
}
@Override
public Customer deleteCustomer(int id) {
return customerDao.deleteCustomer(id);
}
@Override
public Customer getCustomerById(int id) {
return customerDao.getCustomerById(id);
}
@Override
public List<Customer> getAllCustomer() {
return customerDao.getAllCustomer();
}
}
----------
**These are the Hibernate Implementation Files and Interface.**
**1. CustomerDao and 2. CustomerDaoImpl.**
**If you dont want to implement HIBERNATE, than you can omit this two files and in the applicationContext.xml file DELETE the bean with id's "dataSource" and "sessionFactory". Remove the dependency of HIBERNATE in pom.xml**
----------
File Name: **org.pramod.dao.CustomerDao.java**
package org.pramod.dao;
import java.util.List;
import org.pramod.model.Customer;
public interface CustomerDao {
String getStringTest();
Customer addCustomer(Customer customer);
Customer updateCustomer(int id, Customer customer);
Customer deleteCustomer(int id);
Customer getCustomerById(int id);
List<Customer> getAllCustomer();
}
----------
File Name: **org.pramod.dao.CustomerDaoImpl.java**
package org.pramod.dao;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.pramod.model.Customer;
import org.springframework.beans.factory.annotation.Autowired;
public class CustomerDaoImpl implements CustomerDao {
@Autowired
SessionFactory sessionFactory;
@Override
public String getStringTest(){
String save = "Got it";
return save;
}
@Override
public Customer addCustomer(Customer customer) {
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
try{
session.save(customer);
tx.commit();
return customer;
}catch(Exception e){
tx.rollback();
return null;
}
}
@Override
public Customer updateCustomer(int id, Customer cust) {
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
try{
Customer customer = cust;
customer.setId(id);
session.update(customer);
tx.commit();
return customer;
}catch(Exception e){
tx.rollback();
return null;
}
}
@Override
public Customer deleteCustomer(int id) {
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
try{
Customer cust = session.get(Customer.class,id);
session.delete(cust);
tx.commit();
return cust;
}catch(Exception e){
tx.rollback();
return null;
}
}
@Override
public Customer getCustomerById(int id) {
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
try{
Customer cust = session.get(Customer.class,id);
tx.commit();
session.close();
return cust;
}catch(Exception e){
tx.rollback();
session.close();
return null;
}
}
@Override
public List<Customer> getAllCustomer() {
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
try{
Query query = session.createQuery("from Customer");
List<Customer> customers = query.list();
tx.commit();
session.close();
return customers;
}catch(Exception e){
tx.rollback();
session.close();
return null;
}
}
}
----------
**This is the Entity or Object of Customer type. If you don't want to you use Hibernate. Remove All the annotation**
File Name: **org.pramod.model.Customer.java**
package org.pramod.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="CUSTOMER")
public class Customer {
@Id @GeneratedValue
@Column(name="customer_id")
private int id;
@Column
private String firstName;
@Column
private String lastName;
@Column
private String street;
@Column
private String city;
@Column
private String state;
@Column
private int pin;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public int getPin() {
return pin;
}
public void setPin(int pin) {
this.pin = pin;
}
}
| 0debug
|
static void ppc_core99_init (ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
const char *cpu_model)
{
CPUState *env = NULL;
char *filename;
qemu_irq *pic, **openpic_irqs;
int unin_memory;
int linux_boot, i;
ram_addr_t ram_offset, bios_offset;
target_phys_addr_t kernel_base, initrd_base, cmdline_base = 0;
long kernel_size, initrd_size;
PCIBus *pci_bus;
MacIONVRAMState *nvr;
int bios_size;
MemoryRegion *pic_mem, *dbdma_mem, *cuda_mem, *escc_mem;
MemoryRegion *ide_mem[3];
int ppc_boot_device;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
void *fw_cfg;
void *dbdma;
int machine_arch;
linux_boot = (kernel_filename != NULL);
if (cpu_model == NULL)
#ifdef TARGET_PPC64
cpu_model = "970fx";
#else
cpu_model = "G4";
#endif
for (i = 0; i < smp_cpus; i++) {
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
}
cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
qemu_register_reset((QEMUResetHandler*)&cpu_reset, env);
}
ram_offset = qemu_ram_alloc(NULL, "ppc_core99.ram", ram_size);
cpu_register_physical_memory(0, ram_size, ram_offset);
bios_offset = qemu_ram_alloc(NULL, "ppc_core99.bios", BIOS_SIZE);
if (bios_name == NULL)
bios_name = PROM_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
cpu_register_physical_memory(PROM_ADDR, BIOS_SIZE, bios_offset | IO_MEM_ROM);
if (filename) {
bios_size = load_elf(filename, NULL, NULL, NULL,
NULL, NULL, 1, ELF_MACHINE, 0);
g_free(filename);
} else {
bios_size = -1;
}
if (bios_size < 0 || bios_size > BIOS_SIZE) {
hw_error("qemu: could not load PowerPC bios '%s'\n", bios_name);
exit(1);
}
if (linux_boot) {
uint64_t lowaddr = 0;
int bswap_needed;
#ifdef BSWAP_NEEDED
bswap_needed = 1;
#else
bswap_needed = 0;
#endif
kernel_base = KERNEL_LOAD_ADDR;
kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,
NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);
if (kernel_size < 0)
kernel_size = load_aout(kernel_filename, kernel_base,
ram_size - kernel_base, bswap_needed,
TARGET_PAGE_SIZE);
if (kernel_size < 0)
kernel_size = load_image_targphys(kernel_filename,
kernel_base,
ram_size - kernel_base);
if (kernel_size < 0) {
hw_error("qemu: could not load kernel '%s'\n", kernel_filename);
exit(1);
}
if (initrd_filename) {
initrd_base = round_page(kernel_base + kernel_size + KERNEL_GAP);
initrd_size = load_image_targphys(initrd_filename, initrd_base,
ram_size - initrd_base);
if (initrd_size < 0) {
hw_error("qemu: could not load initial ram disk '%s'\n",
initrd_filename);
exit(1);
}
cmdline_base = round_page(initrd_base + initrd_size);
} else {
initrd_base = 0;
initrd_size = 0;
cmdline_base = round_page(kernel_base + kernel_size + KERNEL_GAP);
}
ppc_boot_device = 'm';
} else {
kernel_base = 0;
kernel_size = 0;
initrd_base = 0;
initrd_size = 0;
ppc_boot_device = '\0';
for (i = 0; boot_device[i] != '\0'; i++) {
if (boot_device[i] >= 'c' && boot_device[i] <= 'f') {
ppc_boot_device = boot_device[i];
break;
}
}
if (ppc_boot_device == '\0') {
fprintf(stderr, "No valid boot device for Mac99 machine\n");
exit(1);
}
}
isa_mem_base = 0x80000000;
isa_mmio_init(0xf2000000, 0x00800000);
unin_memory = cpu_register_io_memory(unin_read, unin_write, NULL,
DEVICE_NATIVE_ENDIAN);
cpu_register_physical_memory(0xf8000000, 0x00001000, unin_memory);
openpic_irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *));
openpic_irqs[0] =
g_malloc0(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
for (i = 0; i < smp_cpus; i++) {
switch (PPC_INPUT(env)) {
case PPC_FLAGS_INPUT_6xx:
openpic_irqs[i] = openpic_irqs[0] + (i * OPENPIC_OUTPUT_NB);
openpic_irqs[i][OPENPIC_OUTPUT_INT] =
((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT];
openpic_irqs[i][OPENPIC_OUTPUT_CINT] =
((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT];
openpic_irqs[i][OPENPIC_OUTPUT_MCK] =
((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_MCP];
openpic_irqs[i][OPENPIC_OUTPUT_DEBUG] = NULL;
openpic_irqs[i][OPENPIC_OUTPUT_RESET] =
((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_HRESET];
break;
#if defined(TARGET_PPC64)
case PPC_FLAGS_INPUT_970:
openpic_irqs[i] = openpic_irqs[0] + (i * OPENPIC_OUTPUT_NB);
openpic_irqs[i][OPENPIC_OUTPUT_INT] =
((qemu_irq *)env->irq_inputs)[PPC970_INPUT_INT];
openpic_irqs[i][OPENPIC_OUTPUT_CINT] =
((qemu_irq *)env->irq_inputs)[PPC970_INPUT_INT];
openpic_irqs[i][OPENPIC_OUTPUT_MCK] =
((qemu_irq *)env->irq_inputs)[PPC970_INPUT_MCP];
openpic_irqs[i][OPENPIC_OUTPUT_DEBUG] = NULL;
openpic_irqs[i][OPENPIC_OUTPUT_RESET] =
((qemu_irq *)env->irq_inputs)[PPC970_INPUT_HRESET];
break;
#endif
default:
hw_error("Bus model not supported on mac99 machine\n");
exit(1);
}
}
pic = openpic_init(NULL, &pic_mem, smp_cpus, openpic_irqs, NULL);
if (PPC_INPUT(env) == PPC_FLAGS_INPUT_970) {
pci_bus = pci_pmac_u3_init(pic, get_system_memory(), get_system_io());
machine_arch = ARCH_MAC99_U3;
} else {
pci_bus = pci_pmac_init(pic, get_system_memory(), get_system_io());
machine_arch = ARCH_MAC99;
}
pci_vga_init(pci_bus);
escc_mem = escc_init(0x80013000, pic[0x25], pic[0x24],
serial_hds[0], serial_hds[1], ESCC_CLOCK, 4);
for(i = 0; i < nb_nics; i++)
pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL);
ide_drive_get(hd, MAX_IDE_BUS);
dbdma = DBDMA_init(&dbdma_mem);
ide_mem[0] = NULL;
ide_mem[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
ide_mem[2] = pmac_ide_init(&hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 0x1a, pic[0x02]);
if (machine_arch == ARCH_MAC99_U3) {
usb_enabled = 1;
}
cuda_init(&cuda_mem, pic[0x19]);
adb_kbd_init(&adb_bus);
adb_mouse_init(&adb_bus);
macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem,
dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_mem);
if (usb_enabled) {
usb_ohci_init_pci(pci_bus, -1);
}
if (machine_arch == ARCH_MAC99_U3) {
usbdevice_create("keyboard");
usbdevice_create("mouse");
}
if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
graphic_depth = 15;
nvr = macio_nvram_init(0x2000, 1);
pmac_format_nvram_partition(nvr, 0x2000);
macio_nvram_setup_bar(nvr, get_system_memory(), 0xFFF04000);
fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, machine_arch);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
if (kernel_cmdline) {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, cmdline_base);
pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE, kernel_cmdline);
} else {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
}
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base);
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
if (kvm_enabled()) {
#ifdef CONFIG_KVM
uint8_t *hypercall;
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());
hypercall = g_malloc(16);
kvmppc_get_hypercall(env, hypercall, 16);
fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid());
#endif
} else {
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, get_ticks_per_sec());
}
qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
}
| 1threat
|
Hello, i have 2 pages and how can i make invisible the frame but from the another page : > Hello, i have 2 pages and how can i make invisible the frame but from
> the another page.
public class test{
public static void main(String[] args){
JButton b = new JButton("Blinky");
JFrame f = new JFrame("Blinkly Frame");
f.add(b);
f.setSize(100, 100);
f.setVisible(true);
}
}
| 0debug
|
struct pxa2xx_state_s *pxa270_init(unsigned int sdram_size,
DisplayState *ds, const char *revision)
{
struct pxa2xx_state_s *s;
struct pxa2xx_ssp_s *ssp;
int iomemtype, i;
s = (struct pxa2xx_state_s *) qemu_mallocz(sizeof(struct pxa2xx_state_s));
if (revision && strncmp(revision, "pxa27", 5)) {
fprintf(stderr, "Machine requires a PXA27x processor.\n");
exit(1);
}
s->env = cpu_init();
cpu_arm_set_model(s->env, revision ?: "pxa270");
register_savevm("cpu", 0, 0, cpu_save, cpu_load, s->env);
cpu_register_physical_memory(PXA2XX_SDRAM_BASE,
sdram_size, qemu_ram_alloc(sdram_size) | IO_MEM_RAM);
cpu_register_physical_memory(PXA2XX_INTERNAL_BASE,
0x40000, qemu_ram_alloc(0x40000) | IO_MEM_RAM);
s->pic = pxa2xx_pic_init(0x40d00000, s->env);
s->dma = pxa27x_dma_init(0x40000000, s->pic[PXA2XX_PIC_DMA]);
pxa27x_timer_init(0x40a00000, &s->pic[PXA2XX_PIC_OST_0],
s->pic[PXA27X_PIC_OST_4_11]);
s->gpio = pxa2xx_gpio_init(0x40e00000, s->env, s->pic, 121);
s->mmc = pxa2xx_mmci_init(0x41100000, s->pic[PXA2XX_PIC_MMC], s->dma);
for (i = 0; pxa270_serial[i].io_base; i ++)
if (serial_hds[i])
serial_mm_init(pxa270_serial[i].io_base, 2,
s->pic[pxa270_serial[i].irqn], serial_hds[i], 1);
else
break;
if (serial_hds[i])
s->fir = pxa2xx_fir_init(0x40800000, s->pic[PXA2XX_PIC_ICP],
s->dma, serial_hds[i]);
if (ds)
s->lcd = pxa2xx_lcdc_init(0x44000000, s->pic[PXA2XX_PIC_LCD], ds);
s->cm_base = 0x41300000;
s->cm_regs[CCCR >> 4] = 0x02000210;
s->clkcfg = 0x00000009;
iomemtype = cpu_register_io_memory(0, pxa2xx_cm_readfn,
pxa2xx_cm_writefn, s);
cpu_register_physical_memory(s->cm_base, 0xfff, iomemtype);
register_savevm("pxa2xx_cm", 0, 0, pxa2xx_cm_save, pxa2xx_cm_load, s);
cpu_arm_set_cp_io(s->env, 14, pxa2xx_cp14_read, pxa2xx_cp14_write, s);
s->mm_base = 0x48000000;
s->mm_regs[MDMRS >> 2] = 0x00020002;
s->mm_regs[MDREFR >> 2] = 0x03ca4000;
s->mm_regs[MECR >> 2] = 0x00000001;
iomemtype = cpu_register_io_memory(0, pxa2xx_mm_readfn,
pxa2xx_mm_writefn, s);
cpu_register_physical_memory(s->mm_base, 0xfff, iomemtype);
register_savevm("pxa2xx_mm", 0, 0, pxa2xx_mm_save, pxa2xx_mm_load, s);
for (i = 0; pxa27x_ssp[i].io_base; i ++);
s->ssp = (struct pxa2xx_ssp_s **)
qemu_mallocz(sizeof(struct pxa2xx_ssp_s *) * i);
ssp = (struct pxa2xx_ssp_s *)
qemu_mallocz(sizeof(struct pxa2xx_ssp_s) * i);
for (i = 0; pxa27x_ssp[i].io_base; i ++) {
s->ssp[i] = &ssp[i];
ssp[i].base = pxa27x_ssp[i].io_base;
ssp[i].irq = s->pic[pxa27x_ssp[i].irqn];
iomemtype = cpu_register_io_memory(0, pxa2xx_ssp_readfn,
pxa2xx_ssp_writefn, &ssp[i]);
cpu_register_physical_memory(ssp[i].base, 0xfff, iomemtype);
register_savevm("pxa2xx_ssp", i, 0,
pxa2xx_ssp_save, pxa2xx_ssp_load, s);
}
if (usb_enabled) {
usb_ohci_init_pxa(0x4c000000, 3, -1, s->pic[PXA2XX_PIC_USBH1]);
}
s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000);
s->pcmcia[1] = pxa2xx_pcmcia_init(0x30000000);
s->rtc_base = 0x40900000;
iomemtype = cpu_register_io_memory(0, pxa2xx_rtc_readfn,
pxa2xx_rtc_writefn, s);
cpu_register_physical_memory(s->rtc_base, 0xfff, iomemtype);
pxa2xx_rtc_init(s);
register_savevm("pxa2xx_rtc", 0, 0, pxa2xx_rtc_save, pxa2xx_rtc_load, s);
s->i2c[0] = pxa2xx_i2c_init(0x40301600, s->pic[PXA2XX_PIC_I2C], 1);
s->i2c[1] = pxa2xx_i2c_init(0x40f00100, s->pic[PXA2XX_PIC_PWRI2C], 0);
s->pm_base = 0x40f00000;
iomemtype = cpu_register_io_memory(0, pxa2xx_pm_readfn,
pxa2xx_pm_writefn, s);
cpu_register_physical_memory(s->pm_base, 0xfff, iomemtype);
register_savevm("pxa2xx_pm", 0, 0, pxa2xx_pm_save, pxa2xx_pm_load, s);
s->i2s = pxa2xx_i2s_init(0x40400000, s->pic[PXA2XX_PIC_I2S], s->dma);
pxa2xx_gpio_handler_set(s->gpio, 1, pxa2xx_reset, s);
return s;
}
| 1threat
|
Number input is string not integer in React : <p>I have a react component. Im passing the updateInventory function down from my top level component. </p>
<pre><code>class Inventory extends Component {
constructor(props) {
super(props);
this.state = {
name: this.props.name,
price: this.props.price,
id: this.props.id
};
this.handleChange = this.handleChange.bind(this);
}
handleChange(e) {
this.setState({
[e.target.name]: e.target.value
});
}
render(props) {
return (
<form onSubmit={(e)=>this.props.updateInventory(e, this.state)}>
<input name='name' value={this.state.name} onChange={this.handleChange} />
<input name='price' type='number' value={this.state.price} onChange={this.handleChange} />
<button type='submit'>Update</button>
</form>
)
}
};
export default Inventory;
</code></pre>
<p>In my top level component: </p>
<pre><code>updateInventory = (e, state) => {
let pizzaState = this.state.pizzas;
const index = pizzaState.findIndex((pizza)=>{
return pizza.id === state.id;
});
Object.assign(pizzaState[index], state);
console.log( pizzaState );
e.preventDefault();
};
</code></pre>
<p>This appears to be working so far (I havn't updated my top level state yet) but I can see that when I update the price the new value is a string not an integer. I was hoping to just have the one handleChange function for all my inputs as ill be adding some more, is this possible? </p>
| 0debug
|
static int mkv_write_tags(AVFormatContext *s)
{
ebml_master tags = {0};
int i, ret;
ff_metadata_conv_ctx(s, ff_mkv_metadata_conv, NULL);
if (av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) {
ret = mkv_write_tag(s, s->metadata, 0, 0, &tags);
if (ret < 0) return ret;
}
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (!av_dict_get(st->metadata, "", 0, AV_DICT_IGNORE_SUFFIX))
continue;
ret = mkv_write_tag(s, st->metadata, MATROSKA_ID_TAGTARGETS_TRACKUID, i + 1, &tags);
if (ret < 0) return ret;
}
for (i = 0; i < s->nb_chapters; i++) {
AVChapter *ch = s->chapters[i];
if (!av_dict_get(ch->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
continue;
ret = mkv_write_tag(s, ch->metadata, MATROSKA_ID_TAGTARGETS_CHAPTERUID, ch->id, &tags);
if (ret < 0) return ret;
}
if (tags.pos)
end_ebml_master(s->pb, tags);
return 0;
}
| 1threat
|
How to proper bind image source link to wpf xaml using C# : <StackPanel x:Uid="Style_1" x:Name="ForAdsImagePath" Grid.Row="1"
Orientation="Horizontal" Margin="0,17,0,0" Visibility="Collapsed" HorizontalAlignment="Center" VerticalAlignment="Stretch">
<Image x:Name="img1" Source="http://qa-ads.transim.com/www/delivery/avw.php?zoneid=9&cb=131441234131313&n=a25d26ed"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MouseLeftButtonDown="Image_MouseLeftButtonDown" />
</StackPanel>
How i do write code in binding an image source and c# i tried this step but it gets an erron upon initializing.
Source="{Binding Path, Converter={StaticResource MyPathConverter}}"
private void MyPathConverter()
{
try
{
string Path = @"http://qa-ads.transim.com/www/delivery/avw.php?zoneid=9&cb=131441234131313&n=a25d26ed";
Image image = new Image();
image.UriSource = new Uri(Path);
}
catch (Exception ex) { /*Ignoe Function*/ }
}
| 0debug
|
int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush,
int (*get_packet)(AVFormatContext *, AVPacket *, AVPacket *, int),
int (*compare_ts)(AVFormatContext *, AVPacket *, AVPacket *))
{
int i;
if (pkt) {
AVStream *st = s->streams[pkt->stream_index];
AudioInterleaveContext *aic = st->priv_data;
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
unsigned new_size = av_fifo_size(aic->fifo) + pkt->size;
if (new_size > aic->fifo_size) {
if (av_fifo_realloc2(aic->fifo, new_size) < 0)
return -1;
aic->fifo_size = new_size;
}
av_fifo_generic_write(aic->fifo, pkt->data, pkt->size, NULL);
} else {
pkt->pts = pkt->dts = aic->dts;
aic->dts += pkt->duration;
ff_interleave_add_packet(s, pkt, compare_ts);
}
pkt = NULL;
}
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
AVPacket new_pkt;
while (ff_interleave_new_audio_packet(s, &new_pkt, i, flush))
ff_interleave_add_packet(s, &new_pkt, compare_ts);
}
}
return get_packet(s, out, pkt, flush);
}
| 1threat
|
int cpu_breakpoint_remove(CPUState *cpu, vaddr pc, int flags)
{
#if defined(TARGET_HAS_ICE)
CPUBreakpoint *bp;
QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {
if (bp->pc == pc && bp->flags == flags) {
cpu_breakpoint_remove_by_ref(cpu, bp);
return 0;
}
}
return -ENOENT;
#else
return -ENOSYS;
#endif
}
| 1threat
|
Is it possible to discover and run third-party Android Instant Apps on an emulated device? : <p>I'm currently trying to learn about Android instant apps. Since I don't own any real devices that support them, I'm using the emulator (from Android Studio 3.0 Canary 9). I can successfully run "toy" instant apps (<a href="https://developer.android.com/topic/instant-apps/getting-started/first-instant-app.html" rel="noreferrer">like this</a>) on my emulated Nexus 5x (with Play Store), so I believe that my development environment is configured correctly.</p>
<p>However, I was curious to learn about the discovery process for third-party apps, and find out what the user experience is like. Lacking a suitable device of my own, I used the emulated Chrome browser to search for sites (like Stack Exchange) that have instant apps enabled. But these searches only give me the usual websites (not instant apps).</p>
<p>I read <a href="https://stackoverflow.com/questions/44250681/is-it-possible-to-use-published-instant-appsbuzzfeed-wish-etc-on-the-emulato">this post</a> with great interest, because it seems to suggest that this <em>should</em> work. However, those answers didn't seem to help me. </p>
<ul>
<li>I'm in Australia, which should be <a href="https://support.google.com/googleplay/android-developer/answer/7381861#production" rel="noreferrer">one of the countries where Instant Apps are supported</a>.</li>
<li>As suggested in one answer, I've tried sending links that should open in instant apps in emails and then clicking on them, but it still just sends me to a browser link.</li>
<li>The answer about DAL verification is interesting, but doesn't seem like it should apply when opening links in a browser?</li>
</ul>
<p>The API 24 and API 26 emulated devices (both of which include the Play Store)
are currently in somewhat different conditions, probably because I've been trying all sorts of tricks to make it work. (TLDR: Nothing's working for me.)</p>
<ul>
<li><p>On the API 24 emulated device, if I type <code>adb shell pm list packages grep "com.google.android.instantapps.supervisor"</code> then it outputs <code>package:com.google.android.instantapps.supervisor</code> as one answer suggests (but it still doesn't work).</p></li>
<li><p>The API 24 device has <code>Google Play services for Instant Apps (version 1.9-sdk-155682639)</code> installed.</p></li>
<li><p>The API 24 device has a "lightning bolt" notification at the top of the screen saying "Development Mode Active": <code>URLs will be routed to Dev Manager in order to launch Instant Apps locally. Uninstall Dev Manager to disable Development Mode.</code></p></li>
<li><p>On the API 24 device, Settings -> Google -> Instant Apps, instant apps is set to true</p></li>
<li><p>On the API 26 emulated device, if I type <code>adb shell pm list packages grep "com.google.android.instantapps.supervisor"</code> returns nothing</p></li>
<li><p>On the API 26 device, <code>Google Play services for Instant Apps</code> isn't installed, and there isn't any "lightning bolt" notification either</p></li>
<li><p>On the API 26 device, Settings -> Google doesn't list Instant Apps (so there's nothing to set)</p></li>
</ul>
<p>Here are some additional details, in case they're relevant:</p>
<ul>
<li>My development machine runs Windows 10 <sub><sup>(not by choice)</sup></sub></li>
<li>The emulated devices are Nexus 5x (API 24 and 26) with Play Store</li>
<li>I also tried the "x86" images, since some people recommended them for Windows, but they didn't work either. (This may be because the "x86" images don't come with Play Store, which I think is required for Instant Apps?)</li>
<li>I'm logged into a real Google user account on the emulated devices.</li>
</ul>
<p>With the development environment I've set up now, I can continue to develop my own instant app, deploy it on my own emulated devices, and test it. I was really just curious to see how other people's instant apps work. And another post (linked above) suggested that I should be able to do this.</p>
<p>So here's my question: Is it possible to discover and open third-party Instant Apps on an emulated device (and if so, how)?</p>
| 0debug
|
static int vfio_mmap_bar(VFIOBAR *bar, MemoryRegion *mem, MemoryRegion *submem,
void **map, size_t size, off_t offset,
const char *name)
{
int ret = 0;
if (size && bar->flags & VFIO_REGION_INFO_FLAG_MMAP) {
int prot = 0;
if (bar->flags & VFIO_REGION_INFO_FLAG_READ) {
prot |= PROT_READ;
}
if (bar->flags & VFIO_REGION_INFO_FLAG_WRITE) {
prot |= PROT_WRITE;
}
*map = mmap(NULL, size, prot, MAP_SHARED,
bar->fd, bar->fd_offset + offset);
if (*map == MAP_FAILED) {
*map = NULL;
ret = -errno;
goto empty_region;
}
memory_region_init_ram_ptr(submem, name, size, *map);
} else {
empty_region:
memory_region_init(submem, name, 0);
}
memory_region_add_subregion(mem, offset, submem);
return ret;
}
| 1threat
|
Multiple conditions in if statement in JAVA problem : private String setDepartment (){
int code = Integer.parseInt(JOptionPane.showInputDialog("Enter The Department Code:\n" +
"1:Sales\n" +
"2:Development\n" +
"3:Accounting\n" +
"4:None"));
if (code !=1 || code !=2 || code !=3 || code !=4)
/*Why this if statement is always true? How do i solve it? */
{
JOptionPane.showMessageDialog(null, "Invalid Number.Enter a number between 1-4");
setDepartment();
}
if (code==1){
return "Sales";
}
else if (code==2){
return "Development";
}
else if (code==3){
return "Accounting";
}
else
return "";
}
| 0debug
|
Are Kotlin data types built off primitive or non-primitive Java data types? : <p>I am new to Kotlin and was playing around with the data types. I took an <code>Int</code> type and then tried to cast it as a <code>Double</code> by saying <code>num as Double</code>, a call that is valid in java (non syntactically but you get the point). However, this failed, saying that Int cannot be cast to Double. I am assuming this is because it is built off the Integer class rather than the raw int data type. Am I correct, and what is the most efficient way to cast values? There is a <code>.toDouble()</code> function, but this seems inefficient and unwieldy. </p>
| 0debug
|
Return difference in time using php : <p>With the following line i get a DATE in Y-m-d format.</p>
<pre><code>echo date('Y-m-d',strtotime($result["created_at"]));
</code></pre>
<p>Its the creation date of an account. now id like to calculate how old the account is so i can print it out like 5 Years, 5 Months as a example.</p>
<p>any ideas?</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.