problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static void gen_tlbsx_booke206(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
TCGv t0;
if (unlikely(!ctx->mem_idx)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
if (rA(ctx->opcode)) {
t0 = tcg_temp_new();
tcg_gen_mov_tl(t0, cpu_gpr[rD(ctx->opcode)]);
} else {
t0 = tcg_const_tl(0);
}
tcg_gen_add_tl(t0, t0, cpu_gpr[rB(ctx->opcode)]);
gen_helper_booke206_tlbsx(cpu_env, t0);
#endif
}
| 1threat
|
How To add new namespace in C# : I am creating MVC project behind i am using C# code. i have
`CloudConfigurationManager`
in using read db value . its showing red Error . i have searched google i need to add namespace.
`using Microsoft.Azure;`
i have added that also but again Getting Error Like this
type or namespace 'Azure' does not exist in the namespace 'microsoft' (are you missing an assembly reference?) showing like this how to fix this issue how can i add namespace Azure?
| 0debug
|
Is this a good approach for finding number of prime numbers within a certain range? : <p>During my programming exam in college I was told to write a program that can find the prime numbers from 0 to n.</p>
<p>My approach was divide the numbers by 2,3,5 and 7, and the ones that doesn't returns a remainder of value 0 would be a prime number.</p>
<p>Is this a good approach for the solution?</p>
<p>Thanks!</p>
| 0debug
|
How to set table name for @ElementCollection in hibernate : <p>I am using</p>
<pre><code>public class UserTask extends BaseObject implements Serializable {
@ElementCollection(targetClass = java.lang.String.class)
private List<String> userTaskMessage = new ArrayList<>();
.
.
.
.
</code></pre>
<p>Hibernate generate table, which name is <code>usertask_usertaskmessage</code>.</p>
<p>How do I set my name? For example <code>my_table_example</code></p>
<p>Thank you for your help!</p>
| 0debug
|
Is the Google Strategy in Passport.js deprecated with the end of Google+ : <p>I use Passport.js and passport-google-oauth20 in my nodejs aplication for authenticating with a "Google Strategy".
I just received an email from Google indicating that I use "plus.people.get" from the Google+ API and that it will be deprecated.
Should I change something? I do not use directly this API call but maybe Passport does? </p>
| 0debug
|
how to get next user id? : I wanna print two rows, first with next five users and second with next 25 users after 5, I am getting an error while getting next id
$quary= mysql_query("SELECT * FROM user ORDER BY id ASC ");
while($auto_inc_result = mysql_fetch_array($quary))
{
$last_id = $auto_inc_result['id'];
}
$next_id = ($last_id+1);
echo $next_id;
| 0debug
|
Visual Studio 2012 Price only shows up as $0.00 : I'm trying to make a menu that calculates the total cost at the end, however the end cost is supposed to show up in the text box but it only shows $0.00 can anyone help. It is supposed to display as a total cost for your choice of main dish as well as how many sides and/or toppings the customer would choose.See code attached.
Public Class frmMenu
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
'Set variables
Dim decCBurger As Decimal = 11D
Dim decChicken As Decimal = 7.49D
Dim decFries As Decimal = 5.99D
Dim decOnionRings As Decimal = 5.99
Dim decSalad As Decimal = 5.99
Dim decSoup As Decimal = 5.99
Dim decFP As Decimal = 5.99
Dim decPickle As Decimal = 0.99
Dim decOnion As Decimal = 0.99
Dim decTomato As Decimal = 0.99
Dim decBacon As Decimal = 0.99
Dim decEgg As Decimal = 0.99
Dim decTotalCost As Decimal
Dim decSides As Decimal
Dim decTop As Decimal
Dim decMain As Decimal
'Display cost and label
txtTotalCost.Text = decTotalCost.ToString("C")
decTotalCost = decTop + decSides + decMain
' Check for main dish
If radCBurger.Checked Then
decMain = decCBurger
ElseIf radChicken.Checked Then
decMain = decChicken
End If
'Check for side dishes
If chkFries.Checked Then
decSides = decFries
End If
If chkOnionRings.Checked Then
decSides = decOnionRings
End If
If chkFP.Checked Then
decSides = decFP
End If
If chkSoup.Checked Then
decSides = decSoup
End If
If chkSalad.Checked Then
decSides = decSalad
End If
'Check for Toppings
If chkOnion.Checked Then
decTop = decOnion
End If
If chkTomato.Checked Then
decTop = decTomato
End If
If chkBacon.Checked Then
decTop = decBacon
End If
If chkEgg.Checked Then
decTop = decEgg
End If
If chkPickle.Checked Then
decTop = decPickle
End If
| 0debug
|
I got this QR code and what does this random text from qr code means? : <p><a href="https://i.stack.imgur.com/VeQrA.jpg" rel="nofollow noreferrer">QR code</a></p>
<p>and this is the text I got after scanning : FPfX2KMf5fK5nOmMAl4TeHcVRf9FMxZCyViuvzUq2DP9T+rFxoYooeJ3OscXAWRF7RmysClQZW4nijM/ynxlCWK7M8nqg949Iq+X0WJ8icP+Yfks7PFOrevtAAP1YhESqkglzrcbSWRt9shhUHnQrX0o+FpBKyMzlqlvnvj5lCgzc5qkbBQWlmLJ+RtbAlWifBVwbWpbQDqn2oCwo7EJg292fln1onVjXs+7JmH5CgtZGnmZAuVXau3yXhnmqGsmOXuk7d6bk83/9bHQvB9Nkls9Ny4YzYvz7hxr6YyODKrAcNTnecmsc+zaQXKVQXPCqORAvvuel68hnXy36/iEoey9YF7MvAzgNI5DDL8xSFiyqXNKOBSlaacCDYgTwdBAos8W44r+bR1FwU5/JUoROLFy9Wi4IQHZuVvEpYoBn6z5oxryZour8tixV36BdCYfO8ezLawUYOxGC+o3YYQmnvc+w2rAELFSJLuvuQeRivHCNAesp7efqymiApuF8lOZmrji20/qmqVwCzAkvHk8l/hWgmx2JDP18tVc1qLp7oGYtxPaqxCbv/64Gg3lNkUpBEtlBEtnt/O8Cmtq7LKLRipo76cqXpjmUEAh7BiG/63QJG2jPiXR0QcI/l0dThC2pU0JBKwyG05t/wT4QsgKkehv8xYlb+Fjqd/VFe2/usPEaW6zA9EGR7fBfdDjDSVeC/1BVC0OyRXJhjd9QAuCI3D20MQUjhQGDA8NXwFIg+0AyuEQs8beTuJ9pyXvpyWljdHKZBCa5RLnEHvjJ3KXMNESxndpJW6PxCqYoHpccg/WgKcvkXNBRjplTtQIcRTLwbt3FqdqAEVkdJSdffKEC6uAC+THr7XefdNwn1UdCwwxJnpAQDYp7MvkVdUt2XtjeyAS/SSNehe5rbFRCCkX1IRJMxCvQFXF08cbcQ36v48amPg/K8OsxM44md5sN0ejjmxg9gnw+0NdfcWlnpf8qrpjg1y2DqJfRHO07a0CSiRctRBvaRYOvWqxuuqEvpkaOR5O0NDaguAMOgq5bJN6oPS7vJEZBC4dN+p5keODncq5FM/+Qf0oeXzFllrcrGtV9CmZO8fTVa1db7lzmlQAVA==#QR5315900021</p>
| 0debug
|
Is it possible to shuffle or randomly select entire rows of an array in Python? : <p>I'm working with a multidimensional array where each column contains ordered data and each row is a different sample. I would like to randomly downsample to a specific number of rows, but I don't know how to randomly select an entire row or how to randomly shuffle only the orders of the rows of the array.</p>
| 0debug
|
I want to do String validation : <p>We need to consider the below string as use cases , First I want to split
by "," then by "@"</p>
<p>After Splitting by @ if all the domain are same(either all gmail or all yahoo) its valid
else invalid.</p>
<p>Help me with split part.</p>
<pre><code>String input1 = example@gmail.com , example1@gmail.com;
String input2 = example@yahoo.com , example1@gmail.com;
String input 1 == valid.
String input 2 == Invalid.
</code></pre>
| 0debug
|
Explain the out put of this code about Pointers : #include<stdio.h>
main()
{
char *p="Hello world";
int *q;
p++;
q=(int*)p;
q++;
printf("\n %s\n%s",p,q);
}
The output of this program is this:
ello world
world
Can anybody explain how this program works
| 0debug
|
ImportError: libcudnn when running a TensorFlow program : <p>I encountered the following error when trying to run a TensorFlow program:</p>
<pre>
ImportError: libcudnn.<i>Version</i>: cannot open shared object file: No such file or director
</pre>
| 0debug
|
Programs that lock the computer : <p>At my school we have started using a new typing software for our exams. This software is called Digiexam: <a href="https://www.digiexam.se/en/" rel="nofollow">https://www.digiexam.se/en/</a> When Digiexam is started the computer freezes so that the program window won't be shut down until the essay is handed in. As I have understood most of the code is written in css and javascript. To my question: How can you freeze the computer like this using code? </p>
| 0debug
|
static void tracked_request_end(BdrvTrackedRequest *req)
{
QLIST_REMOVE(req, list);
}
| 1threat
|
How to manipulate datetime.timedelta and string (Python) : I was trying to sort out the average response time on services provided from **raw data**
**What I did:**
for aline in rows:
delta_a = datetime.datetime.strptime(aline[0], "%Y-%m-%d")
delta_b = datetime.datetime.strptime(aline[1], "%Y-%m-%d")
delta = (delta_b - delta_a)/2
print "The average response time for %s is %d" %(aline[5],delta.days)
**Results:**
The average response time for Medical Services is 2
The average response time for Medical Services is 2
The average response time for Physical Therapy is 5
The average response time for Physical Therapy is 3
The average response time for Chiropractic is 0
**What I wanted to be: (but couldn't carry on from here)**
The average response time for Medical Services is 2 days
(note that it should remove duplicates)
The average response time for Physical Therapy is 5 days
(note that there are two Physical Therapy but I took the highest number of days from it which is 5)
The average response time for Chiropractic is less than 24 hours
(note that if it was 0 days then it should change to "less than 24 hours")
_
Thank you for reading.
This was to read from a CSV file and manipulate the data. Reason for repeated line, because this is a raw data provided so it means that there are patients register on each type of services
Is it possible to store string and datetime.timedelta into list or dictionary?
| 0debug
|
Add a Foreign Key in PgAdmin : <p>I have <code>studidtemplates</code> table below:</p>
<p><a href="https://i.stack.imgur.com/fSHCa.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fSHCa.png" alt="enter image description here"></a></p>
<p><code>template_id</code> is the primary_key</p>
<p><a href="https://i.stack.imgur.com/JQ9vn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JQ9vn.png" alt="enter image description here"></a></p>
<p>I want to create a new table referencing <code>template_id</code> as a <code>foreign key</code>. It is named <code>studidtemplatetextelements</code>. See image below:</p>
<p><a href="https://i.stack.imgur.com/WNCk0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WNCk0.png" alt="enter image description here"></a></p>
<p>I created a column <code>template_id</code> in the second table and want to make it a foreign key referencing <code>template_id</code> in <code>studidtemplates</code> table. I did it by clicking the button in the <code>Constraints</code> tab,pointed by an arrow in the image below.</p>
<p><a href="https://i.stack.imgur.com/S2Gsh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/S2Gsh.png" alt="enter image description here"></a></p>
<p>I notice something different. In 'Referencing' option there's no <code>template_id</code> option available. See image below:</p>
<p><a href="https://i.stack.imgur.com/gCkBf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gCkBf.png" alt="enter image description here"></a></p>
<p>Where am I missing?</p>
| 0debug
|
qcrypto_block_luks_open(QCryptoBlock *block,
QCryptoBlockOpenOptions *options,
QCryptoBlockReadFunc readfunc,
void *opaque,
unsigned int flags,
Error **errp)
{
QCryptoBlockLUKS *luks;
Error *local_err = NULL;
int ret = 0;
size_t i;
ssize_t rv;
uint8_t *masterkey = NULL;
size_t masterkeylen;
char *ivgen_name, *ivhash_name;
QCryptoCipherMode ciphermode;
QCryptoCipherAlgorithm cipheralg;
QCryptoIVGenAlgorithm ivalg;
QCryptoCipherAlgorithm ivcipheralg;
QCryptoHashAlgorithm hash;
QCryptoHashAlgorithm ivhash;
char *password = NULL;
if (!(flags & QCRYPTO_BLOCK_OPEN_NO_IO)) {
if (!options->u.luks.key_secret) {
error_setg(errp, "Parameter 'key-secret' is required for cipher");
return -1;
}
password = qcrypto_secret_lookup_as_utf8(
options->u.luks.key_secret, errp);
if (!password) {
return -1;
}
}
luks = g_new0(QCryptoBlockLUKS, 1);
block->opaque = luks;
rv = readfunc(block, opaque, 0,
(uint8_t *)&luks->header,
sizeof(luks->header),
errp);
if (rv < 0) {
ret = rv;
goto fail;
}
be16_to_cpus(&luks->header.version);
be32_to_cpus(&luks->header.payload_offset);
be32_to_cpus(&luks->header.key_bytes);
be32_to_cpus(&luks->header.master_key_iterations);
for (i = 0; i < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS; i++) {
be32_to_cpus(&luks->header.key_slots[i].active);
be32_to_cpus(&luks->header.key_slots[i].iterations);
be32_to_cpus(&luks->header.key_slots[i].key_offset);
be32_to_cpus(&luks->header.key_slots[i].stripes);
}
if (memcmp(luks->header.magic, qcrypto_block_luks_magic,
QCRYPTO_BLOCK_LUKS_MAGIC_LEN) != 0) {
error_setg(errp, "Volume is not in LUKS format");
ret = -EINVAL;
goto fail;
}
if (luks->header.version != QCRYPTO_BLOCK_LUKS_VERSION) {
error_setg(errp, "LUKS version %" PRIu32 " is not supported",
luks->header.version);
ret = -ENOTSUP;
goto fail;
}
ivgen_name = strchr(luks->header.cipher_mode, '-');
if (!ivgen_name) {
ret = -EINVAL;
error_setg(errp, "Unexpected cipher mode string format %s",
luks->header.cipher_mode);
goto fail;
}
*ivgen_name = '\0';
ivgen_name++;
ivhash_name = strchr(ivgen_name, ':');
if (!ivhash_name) {
ivhash = 0;
} else {
*ivhash_name = '\0';
ivhash_name++;
ivhash = qcrypto_block_luks_hash_name_lookup(ivhash_name,
&local_err);
if (local_err) {
ret = -ENOTSUP;
error_propagate(errp, local_err);
goto fail;
}
}
ciphermode = qcrypto_block_luks_cipher_mode_lookup(luks->header.cipher_mode,
&local_err);
if (local_err) {
ret = -ENOTSUP;
error_propagate(errp, local_err);
goto fail;
}
cipheralg = qcrypto_block_luks_cipher_name_lookup(luks->header.cipher_name,
ciphermode,
luks->header.key_bytes,
&local_err);
if (local_err) {
ret = -ENOTSUP;
error_propagate(errp, local_err);
goto fail;
}
hash = qcrypto_block_luks_hash_name_lookup(luks->header.hash_spec,
&local_err);
if (local_err) {
ret = -ENOTSUP;
error_propagate(errp, local_err);
goto fail;
}
ivalg = qcrypto_block_luks_ivgen_name_lookup(ivgen_name,
&local_err);
if (local_err) {
ret = -ENOTSUP;
error_propagate(errp, local_err);
goto fail;
}
if (ivalg == QCRYPTO_IVGEN_ALG_ESSIV) {
if (!ivhash_name) {
ret = -EINVAL;
error_setg(errp, "Missing IV generator hash specification");
goto fail;
}
ivcipheralg = qcrypto_block_luks_essiv_cipher(cipheralg,
ivhash,
&local_err);
if (local_err) {
ret = -ENOTSUP;
error_propagate(errp, local_err);
goto fail;
}
} else {
ivcipheralg = cipheralg;
}
if (!(flags & QCRYPTO_BLOCK_OPEN_NO_IO)) {
if (qcrypto_block_luks_find_key(block,
password,
cipheralg, ciphermode,
hash,
ivalg,
ivcipheralg,
ivhash,
&masterkey, &masterkeylen,
readfunc, opaque,
errp) < 0) {
ret = -EACCES;
goto fail;
}
block->kdfhash = hash;
block->niv = qcrypto_cipher_get_iv_len(cipheralg,
ciphermode);
block->ivgen = qcrypto_ivgen_new(ivalg,
ivcipheralg,
ivhash,
masterkey, masterkeylen,
errp);
if (!block->ivgen) {
ret = -ENOTSUP;
goto fail;
}
block->cipher = qcrypto_cipher_new(cipheralg,
ciphermode,
masterkey, masterkeylen,
errp);
if (!block->cipher) {
ret = -ENOTSUP;
goto fail;
}
}
block->payload_offset = luks->header.payload_offset *
QCRYPTO_BLOCK_LUKS_SECTOR_SIZE;
luks->cipher_alg = cipheralg;
luks->cipher_mode = ciphermode;
luks->ivgen_alg = ivalg;
luks->ivgen_hash_alg = ivhash;
luks->hash_alg = hash;
g_free(masterkey);
g_free(password);
return 0;
fail:
g_free(masterkey);
qcrypto_cipher_free(block->cipher);
qcrypto_ivgen_free(block->ivgen);
g_free(luks);
g_free(password);
return ret;
}
| 1threat
|
Sharing data across my gunicorn workers : <p>I have a Flask app, served by Nginx and Gunicorn with 3 workers. My Flask app is a API microservice designed for doing NLP stuff and I am using the spaCy library for it. </p>
<p>My problem is that they are taking huge number of RAM as loading the spaCy pipeline <code>spacy.load('en')</code> is very memory-intensive and since I have 3 gunicorn workers, each will take about 400MB of RAM. </p>
<p>My question is, is there a way to load the pipeline once and share it across all my gunicorn workers?</p>
| 0debug
|
static void blend_image_rgba(AVFilterContext *ctx, AVFrame *dst, const AVFrame *src, int x, int y)
{
blend_image_packed_rgb(ctx, dst, src, 1, x, y, 0);
}
| 1threat
|
static void hpet_reset(void *opaque) {
HPETState *s = opaque;
int i;
static int count = 0;
for (i=0; i<HPET_NUM_TIMERS; i++) {
HPETTimer *timer = &s->timer[i];
hpet_del_timer(timer);
timer->tn = i;
timer->cmp = ~0ULL;
timer->config = HPET_TN_PERIODIC_CAP | HPET_TN_SIZE_CAP;
timer->config |= 0x00000004ULL << 32;
timer->state = s;
timer->period = 0ULL;
timer->wrap_flag = 0;
}
s->hpet_counter = 0ULL;
s->hpet_offset = 0ULL;
s->capability = 0x8086a201ULL;
s->capability |= ((HPET_CLK_PERIOD) << 32);
s->config = 0ULL;
if (count > 0)
hpet_pit_enable();
count = 1;
}
| 1threat
|
VIOsPAPRBus *spapr_vio_bus_init(void)
{
VIOsPAPRBus *bus;
BusState *qbus;
DeviceState *dev;
dev = qdev_create(NULL, "spapr-vio-bridge");
qdev_init_nofail(dev);
qbus = qbus_create(TYPE_SPAPR_VIO_BUS, dev, "spapr-vio");
bus = DO_UPCAST(VIOsPAPRBus, bus, qbus);
bus->next_reg = 0x1000;
spapr_register_hypercall(H_VIO_SIGNAL, h_vio_signal);
spapr_register_hypercall(H_PUT_TCE, h_put_tce);
spapr_register_hypercall(H_REG_CRQ, h_reg_crq);
spapr_register_hypercall(H_FREE_CRQ, h_free_crq);
spapr_register_hypercall(H_SEND_CRQ, h_send_crq);
spapr_register_hypercall(H_ENABLE_CRQ, h_enable_crq);
spapr_rtas_register("ibm,set-tce-bypass", rtas_set_tce_bypass);
spapr_rtas_register("quiesce", rtas_quiesce);
return bus;
}
| 1threat
|
Is it valid to "hide" a base class virtual function by making it pure virtual in derived classes? : <p>Consider the example:</p>
<pre><code>#include <iostream>
class A {
public:
virtual void f();
};
void A::f()
{
std::cout << "f() from A\n";
}
class B: public A {
public:
virtual void f() = 0;
};
class C: public B {
public:
void f();
};
void C::f()
{
std::cout << "f() from C\n";
}
int main()
{
C o;
o.f();
}
</code></pre>
<p><code>A::f()</code> implementation is "hidden" from class C, which provides its own implementation for <code>f()</code> - effectively making <code>A::f()</code> more or less pointless. I see little value in such class hierarchy design, but my question whether this is a valid C++ or just "works" (such as undefined behaviours)?</p>
| 0debug
|
System Error C++ : <p>So I'm making a script to make a txt file and put data on it, but when I run the system(); function, I get a strange error. Here's the code.</p>
<pre><code>#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;
int main()
{
string textFileName = "SavedPasswords.txt";
string currentPassword = "Pas123!()";
string currentName = "Home";
string seperator = "====================";
ofstream textFile(textFileName.c_str());
textFile << "N: " << currentName << endl << "P: " << currentPassword << endl << endl << seperator << endl;
string directory;
size_t path = textFileName.rfind("\\");
if(string::npos != path)
{
directory = textFileName.substr(0, path);
}
string systemCommands[3] = {"cd\\",
"cd " + directory,
"start " + textFileName};
system(systemCommands[0]);
system(systemCommands[1]);
system(systemCommands[2]);
}
</code></pre>
<p>C:\Users\User\Desktop\SavePasswords\main.cpp|29|error: cannot convert 'std::string {aka std::basic_string}' to 'const char*' for argument '1' to 'int system(const char*)'|</p>
<p>I get the same error for the next two lines.</p>
| 0debug
|
static int read_header(AVFormatContext *s1)
{
VideoDemuxData *s = s1->priv_data;
int first_index, last_index, ret = 0;
int width = 0, height = 0;
AVStream *st;
enum PixelFormat pix_fmt = PIX_FMT_NONE;
AVRational framerate;
s1->ctx_flags |= AVFMTCTX_NOHEADER;
st = avformat_new_stream(s1, NULL);
if (!st) {
return AVERROR(ENOMEM);
}
if (s->pixel_format && (pix_fmt = av_get_pix_fmt(s->pixel_format)) == PIX_FMT_NONE) {
av_log(s1, AV_LOG_ERROR, "No such pixel format: %s.\n", s->pixel_format);
return AVERROR(EINVAL);
}
if (s->video_size && (ret = av_parse_video_size(&width, &height, s->video_size)) < 0) {
av_log(s, AV_LOG_ERROR, "Could not parse video size: %s.\n", s->video_size);
return ret;
}
if ((ret = av_parse_video_rate(&framerate, s->framerate)) < 0) {
av_log(s, AV_LOG_ERROR, "Could not parse framerate: %s.\n", s->framerate);
return ret;
}
av_strlcpy(s->path, s1->filename, sizeof(s->path));
s->img_number = 0;
s->img_count = 0;
if (s1->iformat->flags & AVFMT_NOFILE)
s->is_pipe = 0;
else{
s->is_pipe = 1;
st->need_parsing = AVSTREAM_PARSE_FULL;
}
avpriv_set_pts_info(st, 60, framerate.den, framerate.num);
if (width && height) {
st->codec->width = width;
st->codec->height = height;
}
if (!s->is_pipe) {
s->use_glob = is_glob(s->path);
if (s->use_glob) {
#if HAVE_GLOB
char *p = s->path, *q, *dup;
int gerr;
dup = q = av_strdup(p);
while (*q) {
if ((p - s->path) >= (sizeof(s->path) - 2))
break;
if (*q == '%' && strspn(q + 1, "%*?[]{}"))
++q;
else if (strspn(q, "\\*?[]{}"))
*p++ = '\\';
*p++ = *q++;
}
*p = 0;
av_free(dup);
gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);
if (gerr != 0) {
return AVERROR(ENOENT);
}
first_index = 0;
last_index = s->globstate.gl_pathc - 1;
#endif
} else {
if (find_image_range(&first_index, &last_index, s->path,
s->start_number, s->start_number_range) < 0) {
av_log(s1, AV_LOG_ERROR,
"Could find no file with with path '%s' and index in the range %d-%d\n",
s->path, s->start_number, s->start_number + s->start_number_range - 1);
return AVERROR(ENOENT);
}
}
s->img_first = first_index;
s->img_last = last_index;
s->img_number = first_index;
st->start_time = 0;
st->duration = last_index - first_index + 1;
}
if(s1->video_codec_id){
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = s1->video_codec_id;
}else if(s1->audio_codec_id){
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = s1->audio_codec_id;
}else{
const char *str= strrchr(s->path, '.');
s->split_planes = str && !av_strcasecmp(str + 1, "y");
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = ff_guess_image2_codec(s->path);
if (st->codec->codec_id == AV_CODEC_ID_LJPEG)
st->codec->codec_id = AV_CODEC_ID_MJPEG;
}
if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO && pix_fmt != PIX_FMT_NONE)
st->codec->pix_fmt = pix_fmt;
return 0;
}
| 1threat
|
m48t59_t *m48t59_init (qemu_irq IRQ, target_phys_addr_t mem_base,
uint32_t io_base, uint16_t size,
int type)
{
DeviceState *dev;
SysBusDevice *s;
M48t59SysBusState *d;
dev = qdev_create(NULL, "m48t59");
qdev_prop_set_uint32(dev, "type", type);
qdev_prop_set_uint32(dev, "size", size);
qdev_prop_set_uint32(dev, "io_base", io_base);
qdev_init(dev);
s = sysbus_from_qdev(dev);
sysbus_connect_irq(s, 0, IRQ);
if (io_base != 0) {
register_ioport_read(io_base, 0x04, 1, NVRAM_readb, s);
register_ioport_write(io_base, 0x04, 1, NVRAM_writeb, s);
}
if (mem_base != 0) {
sysbus_mmio_map(s, 0, mem_base);
}
d = FROM_SYSBUS(M48t59SysBusState, s);
return &d->state;
}
| 1threat
|
long do_sigreturn(CPUSPARCState *env)
{
abi_ulong sf_addr;
struct target_signal_frame *sf;
uint32_t up_psr, pc, npc;
target_sigset_t set;
sigset_t host_set;
int err=0, i;
sf_addr = env->regwptr[UREG_FP];
trace_user_do_sigreturn(env, sf_addr);
if (!lock_user_struct(VERIFY_READ, sf, sf_addr, 1)) {
goto segv_and_exit;
}
if (sf_addr & 3)
goto segv_and_exit;
__get_user(pc, &sf->info.si_regs.pc);
__get_user(npc, &sf->info.si_regs.npc);
if ((pc | npc) & 3) {
goto segv_and_exit;
}
__get_user(up_psr, &sf->info.si_regs.psr);
env->psr = (up_psr & (PSR_ICC ))
| (env->psr & ~(PSR_ICC ));
env->pc = pc;
env->npc = npc;
__get_user(env->y, &sf->info.si_regs.y);
for (i=0; i < 8; i++) {
__get_user(env->gregs[i], &sf->info.si_regs.u_regs[i]);
}
for (i=0; i < 8; i++) {
__get_user(env->regwptr[i + UREG_I0], &sf->info.si_regs.u_regs[i+8]);
}
__get_user(set.sig[0], &sf->info.si_mask);
for(i = 1; i < TARGET_NSIG_WORDS; i++) {
__get_user(set.sig[i], &sf->extramask[i - 1]);
}
target_to_host_sigset_internal(&host_set, &set);
do_sigprocmask(SIG_SETMASK, &host_set, NULL);
if (err) {
goto segv_and_exit;
}
unlock_user_struct(sf, sf_addr, 0);
return env->regwptr[0];
segv_and_exit:
unlock_user_struct(sf, sf_addr, 0);
force_sig(TARGET_SIGSEGV);
}
| 1threat
|
how to get which value has duplicate maximum times in php array : i have an array and i want to find out which value has duplicated maximum times in the array.Can you please help me to solve it?
Array ( [0] => 1 [1] => 2 [2] => 2 [3] => 1 [4] => 2 [5] => 2)
The output i want is 2 as it has duplicated 4 times
| 0debug
|
create 2-D character array in java : <p>I want to create a character array like this one below:
<a href="https://i.stack.imgur.com/k1BTG.png" rel="nofollow noreferrer">character array</a></p>
<p>i am unable to find a method . Please help me out. Beginner in java</p>
| 0debug
|
builtins.TypeError: cannot convert 'method' object to bytes : <p>I am getting "builtins.TypeError: cannot convert 'method' object to bytes" while trying to decode bson data which I have encoded just before. I would like to get the decoded data into a dict for each loop (to insert it in a mongoDb Collection). </p>
<p>I have tried to decode it like that : </p>
<p>1 - decode_datas = bson.BSON(bs).decode() who returns the TypeError</p>
<p>2 - transform = bytes(bs)</p>
<p>decode_data = bson.BSON(transform).decode() : it returns the same error.</p>
<pre><code> for row in metaData:
bs = bson.BSON.encode
(
{
'dt': datetime.now(),
'cid': str(row['clt_id']),
'pid': str(row['clt_pro_id']),
'sid': str(row['sit_id']),
'mtr mid': mid,
'mtr ez': int(row['met_eziview']),
'mtr gwt': int(row['met_is_greenwatch_trading']),
'mtr gs': int(row['met_is_greenstart']),
'mtr net': int(row['met_without_gprs_network']),
'mtr act': int(row['sim_is_deactivated']) if row['sim_is_deactivated'] is not None else 1,
'mtr dt': row['met_first_production_date'] if row['met_first_production_date'] is not None else datetime.min,
'mtr hea': int(row['inv_pan_heading']),
'mtr slo': int(row['inv_pan_slope']),
'mtr wp': wp,
'mtr _t': sMtdPhases,
'adr lat': float(row['ad_latitude']),
'adr lon': float(row['ad_longitude']),
'adr zip': str(row['ad_cp']),
}
)
decode_datas = bson.BSON(bs).decode
</code></pre>
| 0debug
|
int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname)
{
char line[1024], group[64], id[64], arg[64], value[1024];
Location loc;
QemuOptsList *list = NULL;
QemuOpts *opts = NULL;
int res = -1, lno = 0;
loc_push_none(&loc);
while (fgets(line, sizeof(line), fp) != NULL) {
loc_set_file(fname, ++lno);
if (line[0] == '\n') {
continue;
}
if (line[0] == '#') {
continue;
}
if (sscanf(line, "[%63s \"%63[^\"]\"]", group, id) == 2) {
list = find_list(lists, group);
if (list == NULL)
goto out;
opts = qemu_opts_create(list, id, 1);
continue;
}
if (sscanf(line, "[%63[^]]]", group) == 1) {
list = find_list(lists, group);
if (list == NULL)
goto out;
opts = qemu_opts_create(list, NULL, 0);
continue;
}
if (sscanf(line, " %63s = \"%1023[^\"]\"", arg, value) == 2) {
if (opts == NULL) {
error_report("no group defined");
goto out;
}
if (qemu_opt_set(opts, arg, value) != 0) {
goto out;
}
continue;
}
error_report("parse error");
goto out;
}
if (ferror(fp)) {
error_report("error reading file");
goto out;
}
res = 0;
out:
loc_pop(&loc);
return res;
}
| 1threat
|
static int ape_probe(AVProbeData * p)
{
if (p->buf[0] == 'M' && p->buf[1] == 'A' && p->buf[2] == 'C' && p->buf[3] == ' ')
return AVPROBE_SCORE_MAX;
return 0;
}
| 1threat
|
Merge Vue props with default values : <p>I have an options prop in my Vue component that has a default value.</p>
<pre><code>export default {
props: {
options: {
required: false,
type: Object,
default: () => ({
someOption: false,
someOtherOption: {
a: true,
b: false,
},
}),
},
},
};
</code></pre>
<p>If the options object is passed as a prop to the component, the default value is replaced. For example, when passed <code>{ someOption: true }</code>, now the options object contains only that value.</p>
<p>How can I pass a partial object and override the default values with the given values instead of replacing the whole object?</p>
| 0debug
|
How to fixed the unexpected $EOF in this script?, i've trying to fix but can't : <p>How to fixed the unexpected $EOF in this code, i've trying to delete some thing and adding some thing but it not work, i was using google to learn how to fixed it but i not found some thing are work well to my code, this it a code:</p>
<pre><code> <html>
<head>
//Head Content
<head>
<body>
SOME HTML CODES
<?php
if (!isset($_GET['fburl'])) {
if (filter_var($url, FILTER_VALIDATE_URL) === false) {
die('url invalid!');
} else {
function random19() {
$number = "";
for($i=0; $i<19; $i++) {
$min = ($i == 0) ? 1:0;
$number .= mt_rand($min,9);
}
return $number;
}
echo random19();
}
?>
</body>
</html> //this it line was unexpected $EOF
</code></pre>
| 0debug
|
double parse_number_or_die(const char *context, const char *numstr, int type,
double min, double max)
{
char *tail;
const char *error;
double d = av_strtod(numstr, &tail);
if (*tail)
error = "Expected number for %s but found: %s\n";
else if (d < min || d > max)
error = "The value for %s was %s which is not within %f - %f\n";
else if (type == OPT_INT64 && (int64_t)d != d)
error = "Expected int64 for %s but found %s\n";
else if (type == OPT_INT && (int)d != d)
error = "Expected int for %s but found %s\n";
else
return d;
av_log(NULL, AV_LOG_FATAL, error, context, numstr, min, max);
exit(1);
return 0;
}
| 1threat
|
How to add the same element N times? : <p>I have two lists:</p>
<pre><code>list1 = [1,2,6]
list2 = []
</code></pre>
<p>And i have a number: N</p>
<p>How can I append the numbers of list1 to list2 so that the sum of the list2 is equal to N.</p>
<p>Exemple:</p>
<pre><code>n = 10
list2 = [2,2,6]
</code></pre>
<p>I could not find a way to add the 2 until the sum equal to 10 </p>
| 0debug
|
C++: How do I assign a value from a 2D dynamic array to another 2D dynamic array since 'temp[0][0] = array[0][0]' doesn't work? : <p>I'm new to c++, and I'm trying to figure out how to get a 2D dynamic array called temp to get values from another 2D dynamic array called array. I couldn't figure out how to assign any values from array to temp because the statement 'temp[0][0] = array[0][0];' doesn't seem to assign the value of array[0][0] which is 1 to temp[0][0]. Instead, temp[0][0] seems to have the same random number in it after 'temp[0][0] = array[0][0]' before any value was assign to temp[0][0]. I tried to assign temp[0][0] to 2 and it works. I don't really know how to exactly assign values from one 2d dynamic array to another. Anyway thanks in advance for helping me out!</p>
<pre><code> ...
//initializing first 2D dynamic array
int x=2;
int y=2;
int** array = new int*[x];
for(int i=0; i<x; i++) array[i] = new int[y];
//initializing second 2D dynamic array
int new_x=3;
int new_y=3;
int** temp = new int*[new_x];
for(int i=0; i<new_x; i++) temp[i] = new int[new_y];
//assigning values
array[0][0] = 1;
cout << array[0][0] << endl; //output is 1
//before assigning values to temp[0][0]
cout << temp[0][0] << endl; //out is a huge random number
temp[0][0] = array[0][0];
cout << temp[0][0] << endl; //output is the same huge random number
temp[0][0] = 2;
cout << temp[0][0] << endl; //output is 2
...
</code></pre>
| 0debug
|
static int disas_dsp_insn(CPUState *env, DisasContext *s, uint32_t insn)
{
int acc, rd0, rd1, rdhi, rdlo;
TCGv tmp, tmp2;
if ((insn & 0x0ff00f10) == 0x0e200010) {
rd0 = (insn >> 12) & 0xf;
rd1 = insn & 0xf;
acc = (insn >> 5) & 7;
if (acc != 0)
return 1;
tmp = load_reg(s, rd0);
tmp2 = load_reg(s, rd1);
switch ((insn >> 16) & 0xf) {
case 0x0:
gen_helper_iwmmxt_muladdsl(cpu_M0, cpu_M0, tmp, tmp2);
break;
case 0x8:
gen_helper_iwmmxt_muladdsw(cpu_M0, cpu_M0, tmp, tmp2);
break;
case 0xc:
case 0xd:
case 0xe:
case 0xf:
if (insn & (1 << 16))
tcg_gen_shri_i32(tmp, tmp, 16);
if (insn & (1 << 17))
tcg_gen_shri_i32(tmp2, tmp2, 16);
gen_helper_iwmmxt_muladdswl(cpu_M0, cpu_M0, tmp, tmp2);
break;
default:
return 1;
}
dead_tmp(tmp2);
dead_tmp(tmp);
gen_op_iwmmxt_movq_wRn_M0(acc);
return 0;
}
if ((insn & 0x0fe00ff8) == 0x0c400000) {
rdhi = (insn >> 16) & 0xf;
rdlo = (insn >> 12) & 0xf;
acc = insn & 7;
if (acc != 0)
return 1;
if (insn & ARM_CP_RW_BIT) {
iwmmxt_load_reg(cpu_V0, acc);
tcg_gen_trunc_i64_i32(cpu_R[rdlo], cpu_V0);
tcg_gen_shri_i64(cpu_V0, cpu_V0, 32);
tcg_gen_trunc_i64_i32(cpu_R[rdhi], cpu_V0);
tcg_gen_andi_i32(cpu_R[rdhi], cpu_R[rdhi], (1 << (40 - 32)) - 1);
} else {
tcg_gen_concat_i32_i64(cpu_V0, cpu_R[rdlo], cpu_R[rdhi]);
iwmmxt_store_reg(cpu_V0, acc);
}
return 0;
}
return 1;
}
| 1threat
|
Flutter background of unsafe area in SafeArea widget. : <p>When I provide the <code>SafeArea</code> to a Widget, then it gets some margin from the notches and home button (horizontal line in iPhone X +). How can I change the background of the unsafe area ? (The margin portion)? </p>
| 0debug
|
Modern Web Application - Design : <p>I am building a large web application in node.js and I'm always faced with the question 'where should the heavy lifting be done?' I was always taught that the 'logic' should always be done in the backend of the application, but with modern computers and browsers being so powerful it begs the question if some of the heavy lifting logic can go in the front end. </p>
<p>So context to my specific application. Using angularjs and postgres. A specific question is: would it be a bad practice to have the back end api fetch the rows from the database and pass it to the front end. And then have the front end deal with the logic of deriving the information from the rows? Things like counts with in date ranges and such. (ignore security for this question) or should all the be done on the backend? </p>
| 0debug
|
Sequelize: Using Multiple Databases : <p>Do I need to create multiple instances of Sequelize if I want to use two databases? That is, two databases on the same machine.</p>
<p>If not, what's the proper way to do this? It seems like overkill to have to connect twice to use two databases, to me.</p>
<p>So for example, I have different databases for different functions, for example, let's say I have customer data in one database, and statistical data in another. </p>
<p>So in MySQL:</p>
<pre><code>MySQL [customers]> show databases;
+--------------------+
| Database |
+--------------------+
| customers |
| stats |
+--------------------+
</code></pre>
<p>And I have this to connect with sequelize</p>
<pre><code>// Create a connection....
var Sequelize = require('sequelize');
var sequelize = new Sequelize('customers', 'my_user', 'some_password', {
host: 'localhost',
dialect: 'mysql',
pool: {
max: 5,
min: 0,
idle: 10000
},
logging: function(output) {
if (opts.log_queries) {
log.it("sequelize_log",{log: output});
}
}
});
// Authenticate it.
sequelize.authenticate().nodeify(function(err) {
// Do stuff....
});
</code></pre>
<p>I tried to "trick" it by in a definition of a model using dot notation</p>
<pre><code>var InterestingStatistics = sequelize.define('stats.interesting_statistics', { /* ... */ });
</code></pre>
<p>But that creates the table <code>customers.stats.interesting_statistics</code>. I need to use an existing table in the stats database.</p>
<p>What's the proper way to achieve this? Thanks.</p>
| 0debug
|
Where is the default .NET Core SDK path in MacOS : <p>I've recently installed the .NET Core SDK for MacOS in order to create a demo application using the new JetBrains Rider EAP.</p>
<pre><code>Project 'WebApi' load failed
Can't initialize DotNetCore: Please select DotNet Core SDK path.
To get instructions how to setup visit https://www.microsoft.com/net/download/core
</code></pre>
<p>After the installation I tried to find the path to the DotNet Core SDK without success.</p>
<p>Any idea about the location of the .NET Core SDK?</p>
| 0debug
|
Member specialization of alias declaration in different namespaces : <p>I just encountered a strange difference in behavior between clang and gcc where I wanted to compile code which looks similar to the following:</p>
<pre class="lang-cpp prettyprint-override"><code>namespace n1 {
template <class T1, class T2>
struct MyTemplate {
struct Inner {};
};
}
using namespace n1;
namespace n2 {
using MyClass = MyTemplate<int, int>;
}
namespace n1 {
using n2::MyClass;
template<> struct MyClass::Inner {
int member;
};
MyClass::Inner inner{0};
}
</code></pre>
<p>Clang happily compiles this:</p>
<pre><code>$ clang++ -std=c++11 -c -o alias_specialization.o alias_specialization.cc
</code></pre>
<p>but gcc throws the following error: </p>
<pre><code>$ g++ -std=c++11 -c -o alias_specialization.o alias_specialization.cc
alias_specialization:15:30: error: declaration of ‘struct n1::MyTemplate<int, int>::Inner’ in namespace ‘n1’ which does not enclose ‘using MyClass = struct n1::MyTemplate<int, int>’
template<> struct MyClass::Inner {
</code></pre>
<p>I know I can just write the full name of the original type (<code>MyTemplate<int, int></code>) instead of <code>MyClass</code> in line 15.
But I'm simply wondering which of the two compilers is "right".
The exact compilers in use are:</p>
<pre><code>$ clang++ --version
clang version 4.0.0
$ g++ --version
g++ (GCC) 6.3.1 20170306
</code></pre>
| 0debug
|
static int doTest(uint8_t *ref[4], int refStride[4], int w, int h,
enum AVPixelFormat srcFormat, enum AVPixelFormat dstFormat,
int srcW, int srcH, int dstW, int dstH, int flags,
struct Results *r)
{
static enum AVPixelFormat cur_srcFormat;
static int cur_srcW, cur_srcH;
static uint8_t *src[4];
static int srcStride[4];
uint8_t *dst[4] = { 0 };
uint8_t *out[4] = { 0 };
int dstStride[4];
int i;
uint64_t ssdY, ssdU = 0, ssdV = 0, ssdA = 0;
struct SwsContext *dstContext = NULL, *outContext = NULL;
uint32_t crc = 0;
int res = 0;
if (cur_srcFormat != srcFormat || cur_srcW != srcW || cur_srcH != srcH) {
struct SwsContext *srcContext = NULL;
int p;
for (p = 0; p < 4; p++)
av_freep(&src[p]);
av_image_fill_linesizes(srcStride, srcFormat, srcW);
for (p = 0; p < 4; p++) {
srcStride[p] = FFALIGN(srcStride[p], 16);
if (srcStride[p])
src[p] = av_mallocz(srcStride[p] * srcH + 16);
if (srcStride[p] && !src[p]) {
perror("Malloc");
res = -1;
goto end;
}
}
srcContext = sws_getContext(w, h, AV_PIX_FMT_YUVA420P, srcW, srcH,
srcFormat, SWS_BILINEAR, NULL, NULL, NULL);
if (!srcContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[AV_PIX_FMT_YUVA420P].name,
av_pix_fmt_descriptors[srcFormat].name);
res = -1;
goto end;
}
sws_scale(srcContext, ref, refStride, 0, h, src, srcStride);
sws_freeContext(srcContext);
cur_srcFormat = srcFormat;
cur_srcW = srcW;
cur_srcH = srcH;
}
av_image_fill_linesizes(dstStride, dstFormat, dstW);
for (i = 0; i < 4; i++) {
dstStride[i] = FFALIGN(dstStride[i], 16);
if (dstStride[i])
dst[i] = av_mallocz(dstStride[i] * dstH + 16);
if (dstStride[i] && !dst[i]) {
perror("Malloc");
res = -1;
goto end;
}
}
dstContext = sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat,
flags, NULL, NULL, NULL);
if (!dstContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[srcFormat].name,
av_pix_fmt_descriptors[dstFormat].name);
res = -1;
goto end;
}
printf(" %s %dx%d -> %s %3dx%3d flags=%2d",
av_pix_fmt_descriptors[srcFormat].name, srcW, srcH,
av_pix_fmt_descriptors[dstFormat].name, dstW, dstH,
flags);
fflush(stdout);
sws_scale(dstContext, src, srcStride, 0, srcH, dst, dstStride);
for (i = 0; i < 4 && dstStride[i]; i++)
crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), crc, dst[i],
dstStride[i] * dstH);
if (r && crc == r->crc) {
ssdY = r->ssdY;
ssdU = r->ssdU;
ssdV = r->ssdV;
ssdA = r->ssdA;
} else {
for (i = 0; i < 4; i++) {
refStride[i] = FFALIGN(refStride[i], 16);
if (refStride[i])
out[i] = av_mallocz(refStride[i] * h);
if (refStride[i] && !out[i]) {
perror("Malloc");
res = -1;
goto end;
}
}
outContext = sws_getContext(dstW, dstH, dstFormat, w, h,
AV_PIX_FMT_YUVA420P, SWS_BILINEAR,
NULL, NULL, NULL);
if (!outContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[dstFormat].name,
av_pix_fmt_descriptors[AV_PIX_FMT_YUVA420P].name);
res = -1;
goto end;
}
sws_scale(outContext, dst, dstStride, 0, dstH, out, refStride);
ssdY = getSSD(ref[0], out[0], refStride[0], refStride[0], w, h);
if (hasChroma(srcFormat) && hasChroma(dstFormat)) {
ssdU = getSSD(ref[1], out[1], refStride[1], refStride[1],
(w + 1) >> 1, (h + 1) >> 1);
ssdV = getSSD(ref[2], out[2], refStride[2], refStride[2],
(w + 1) >> 1, (h + 1) >> 1);
}
if (isALPHA(srcFormat) && isALPHA(dstFormat))
ssdA = getSSD(ref[3], out[3], refStride[3], refStride[3], w, h);
ssdY /= w * h;
ssdU /= w * h / 4;
ssdV /= w * h / 4;
ssdA /= w * h;
sws_freeContext(outContext);
for (i = 0; i < 4; i++)
if (refStride[i])
av_free(out[i]);
}
printf(" CRC=%08x SSD=%5"PRId64 ",%5"PRId64 ",%5"PRId64 ",%5"PRId64 "\n",
crc, ssdY, ssdU, ssdV, ssdA);
end:
sws_freeContext(dstContext);
for (i = 0; i < 4; i++)
if (dstStride[i])
av_free(dst[i]);
return res;
}
| 1threat
|
Automatic cookie handling with OkHttp 3 : <p>I am using okhttp 3.0.1. </p>
<p>Every where I am getting example for cookie handling that is with okhttp2 </p>
<pre><code>OkHttpClient client = new OkHttpClient();
CookieManager cookieManager = new CookieManager();
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
client.setCookieHandler(cookieManager);
</code></pre>
<p>Can please some one guide me how to use in version 3. setCookieHandler method is not present in the version 3.</p>
| 0debug
|
Specific questions about Blockchain : <p>I have familiarized with the blockchain technology for some time through internet research and tutorials, but, as blockchain often appears as a business topic, I could not find good answers to some technical questions. I hope, some of you could help me:</p>
<ol>
<li>The concept of blockchain says that all transaction data is stored on every node (e.g. computer) of the network. Isn’t that a huge and continuously growing amount of data every single participant should store? (If the answer is that just certain nodes have to save the whole history, wouldn’t this be in contrast to the idea of decentralization?)</li>
<li>What is the purpose for the very complex hashing procedure of Bitcoin? As far as I understand it, hashing is needed for the immutability of the chain, but why does it have to be so time-consuming as it is? On the other hand hashing is often considered as a „signature“ of the miner; what does that mean? Doesn’t signature usually mean something like a private key? </li>
<li>As blockchain is of course not bitcoin, is this complex hashing procedure also needed for other use cases (like supply chain applications…) or can it be replace by simpler hashes?</li>
<li>To protect privacy the participants of a blockchain are mostly hashed as well, which is often listed as a great advantage of the technology. In more exclusive blockchains than the bitcoin, isn’t it very simple to conclude some players through their behavior. I mean, if a very big party participates in the blockchain, it is well detectable by e.g. the frequency or volume of deals.</li>
<li>If a miner has hashed and added a block, do all the other miners instantly reject the block they currently try to create?</li>
<li>How does blockchain synchronize the transactions? In distributed systems it is always a big deal to clarify which action happened first. Some of the blockchain literature sources say that all transactions of a blockchain are first stored in a pool before adding to a block. This would be bad in e.g. auction-like deals.</li>
<li>Some sources state that a chain is considered correct when the majority (51%) of the nodes contains it. How does it work/ when is this checked? On the homepage <a href="https://medium.com/coinmonks/what-is-a-51-attack-or-double-spend-attack-aa108db63474" rel="nofollow noreferrer">https://medium.com/coinmonks/what-is-a-51-attack-or-double-spend-attack-aa108db63474</a> the 51% refer to the computational capacities and not the number of nodes and in the context of an attack…</li>
</ol>
<p>Thank you very much in advance! I will appreciate your answers.</p>
| 0debug
|
int av_write_frame(AVFormatContext *s, int stream_index, const uint8_t *buf,
int size)
{
AVStream *st;
int64_t pts_mask;
int ret, frame_size;
st = s->streams[stream_index];
pts_mask = (1LL << s->pts_wrap_bits) - 1;
ret = s->oformat->write_packet(s, stream_index, buf, size,
st->pts.val & pts_mask);
if (ret < 0)
return ret;
switch (st->codec.codec_type) {
case CODEC_TYPE_AUDIO:
frame_size = get_audio_frame_size(&st->codec, size);
if (frame_size >= 0 && (size || st->pts.num!=st->pts.den>>1 || st->pts.val)) {
av_frac_add(&st->pts,
(int64_t)s->pts_den * frame_size);
}
break;
case CODEC_TYPE_VIDEO:
av_frac_add(&st->pts,
(int64_t)s->pts_den * st->codec.frame_rate_base);
break;
default:
break;
}
return ret;
}
| 1threat
|
Visual Studio not downloading DLL for NuGet package : <p>We have a few NuGet packages on our local TeamCity server, and use these in various projects. I have just come back from holiday, grabbed the latest from source code, and tried to rebuild, only to get a pile of compilation errors due to a missing DLL.</p>
<p>It seems that the DLL for one of our packages was not downloaded from NuGet. I tried starting a new WPF project, and adding three of the packages. All three appear in the packages.config file, but only two of them have the DLLs downloaded. The third has only the *.pdb file downloaded.</p>
<p>No-one else on the team has this problem, and I tried it on my spare machine, and it downloaded fine, so it looks like it's an issue with my machine, Visual Studio or NuGet installation. However, as I can grab other packages from the same source without problem, it doesn't look like it's a global problem with either VS or NuGet.</p>
<p>I realise there isn't much to go on, but I don't know what else to tell you. If anyone can suggest anything, I would be very grateful. As the package source is our own, I can't share that unfortunately.</p>
<p>I'm using Visual Studio Enterprise 2015 Update 3 (build 14.0.25424.00) with NuGet package manager version 3.4.4.1321 on Windows 10 Pro 64 bit (version 1607, build 14393.105). If there's anything else I can add, please let me know.</p>
| 0debug
|
Convert dd/mm/yyyy to yyyy-mm-dd in php : <p>I need to convert date format in php , But i am getting getting error</p>
<p>here is my code </p>
<pre><code> $test = new DateTime('23/09/2016');
echo date_format($test, 'Y-m-d');
</code></pre>
<p>But i am getting error as </p>
<pre><code>Message: DateTime::__construct(): Failed to parse time string (23/09/2016) at position 0 (2): Unexpected character
</code></pre>
<p>How to resolve the issue </p>
| 0debug
|
static int mpeg1_decode_picture(AVCodecContext *avctx,
UINT8 *buf, int buf_size)
{
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
int ref, f_code;
init_get_bits(&s->gb, buf, buf_size);
ref = get_bits(&s->gb, 10);
s->pict_type = get_bits(&s->gb, 3);
dprintf("pict_type=%d number=%d\n", s->pict_type, s->picture_number);
skip_bits(&s->gb, 16);
if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) {
s->full_pel[0] = get_bits1(&s->gb);
f_code = get_bits(&s->gb, 3);
if (f_code == 0)
return -1;
s->mpeg_f_code[0][0] = f_code;
s->mpeg_f_code[0][1] = f_code;
}
if (s->pict_type == B_TYPE) {
s->full_pel[1] = get_bits1(&s->gb);
f_code = get_bits(&s->gb, 3);
if (f_code == 0)
return -1;
s->mpeg_f_code[1][0] = f_code;
s->mpeg_f_code[1][1] = f_code;
}
s->current_picture.pict_type= s->pict_type;
s->current_picture.key_frame= s->pict_type == I_TYPE;
s->y_dc_scale = 8;
s->c_dc_scale = 8;
s->first_slice = 1;
return 0;
}
| 1threat
|
Terms in neural networks : I’m reading a paper about sound separation by using neural network method and I have problems with some terms on it I hope you guys can help in definitions,
Here is the question what is the effect of annealing the temperature parameter in a softmax activation function?
| 0debug
|
static int dv_decode_video_segment(AVCodecContext *avctx, void *arg)
{
DVVideoContext *s = avctx->priv_data;
DVwork_chunk *work_chunk = arg;
int quant, dc, dct_mode, class1, j;
int mb_index, mb_x, mb_y, last_index;
int y_stride, linesize;
DCTELEM *block, *block1;
int c_offset;
uint8_t *y_ptr;
const uint8_t *buf_ptr;
PutBitContext pb, vs_pb;
GetBitContext gb;
BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1;
LOCAL_ALIGNED_16(DCTELEM, sblock, [5*DV_MAX_BPM], [64]);
LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [80 + 4]);
LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [5 * 80 + 4]);
const int log2_blocksize = 3-s->avctx->lowres;
int is_field_mode[5];
assert((((int)mb_bit_buffer) & 7) == 0);
assert((((int)vs_bit_buffer) & 7) == 0);
memset(sblock, 0, 5*DV_MAX_BPM*sizeof(*sblock));
buf_ptr = &s->buf[work_chunk->buf_offset*80];
block1 = &sblock[0][0];
mb1 = mb_data;
init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80);
for (mb_index = 0; mb_index < 5; mb_index++, mb1 += s->sys->bpm, block1 += s->sys->bpm * 64) {
quant = buf_ptr[3] & 0x0f;
buf_ptr += 4;
init_put_bits(&pb, mb_bit_buffer, 80);
mb = mb1;
block = block1;
is_field_mode[mb_index] = 0;
for (j = 0; j < s->sys->bpm; j++) {
last_index = s->sys->block_sizes[j];
init_get_bits(&gb, buf_ptr, last_index);
dc = get_sbits(&gb, 9);
dct_mode = get_bits1(&gb);
class1 = get_bits(&gb, 2);
if (DV_PROFILE_IS_HD(s->sys)) {
mb->idct_put = s->idct_put[0];
mb->scan_table = s->dv_zigzag[0];
mb->factor_table = &s->sys->idct_factor[(j >= 4)*4*16*64 + class1*16*64 + quant*64];
is_field_mode[mb_index] |= !j && dct_mode;
} else {
mb->idct_put = s->idct_put[dct_mode && log2_blocksize == 3];
mb->scan_table = s->dv_zigzag[dct_mode];
mb->factor_table = &s->sys->idct_factor[(class1 == 3)*2*22*64 + dct_mode*22*64 +
(quant + dv_quant_offset[class1])*64];
}
dc = dc << 2;
dc += 1024;
block[0] = dc;
buf_ptr += last_index >> 3;
mb->pos = 0;
mb->partial_bit_count = 0;
av_dlog(avctx, "MB block: %d, %d ", mb_index, j);
dv_decode_ac(&gb, mb, block);
if (mb->pos >= 64)
bit_copy(&pb, &gb);
block += 64;
mb++;
}
av_dlog(avctx, "***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), mb_index);
block = block1;
mb = mb1;
init_get_bits(&gb, mb_bit_buffer, put_bits_count(&pb));
flush_put_bits(&pb);
for (j = 0; j < s->sys->bpm; j++, block += 64, mb++) {
if (mb->pos < 64 && get_bits_left(&gb) > 0) {
dv_decode_ac(&gb, mb, block);
if (mb->pos < 64)
break;
}
}
if (j >= s->sys->bpm)
bit_copy(&vs_pb, &gb);
}
av_dlog(avctx, "***pass 3 size=%d\n", put_bits_count(&vs_pb));
block = &sblock[0][0];
mb = mb_data;
init_get_bits(&gb, vs_bit_buffer, put_bits_count(&vs_pb));
flush_put_bits(&vs_pb);
for (mb_index = 0; mb_index < 5; mb_index++) {
for (j = 0; j < s->sys->bpm; j++) {
if (mb->pos < 64) {
av_dlog(avctx, "start %d:%d\n", mb_index, j);
dv_decode_ac(&gb, mb, block);
}
if (mb->pos >= 64 && mb->pos < 127)
av_log(avctx, AV_LOG_ERROR, "AC EOB marker is absent pos=%d\n", mb->pos);
block += 64;
mb++;
}
}
block = &sblock[0][0];
mb = mb_data;
for (mb_index = 0; mb_index < 5; mb_index++) {
dv_calculate_mb_xy(s, work_chunk, mb_index, &mb_x, &mb_y);
if ((s->sys->pix_fmt == PIX_FMT_YUV420P) ||
(s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8)) ||
(s->sys->height >= 720 && mb_y != 134)) {
y_stride = (s->picture.linesize[0] << ((!is_field_mode[mb_index]) * log2_blocksize));
} else {
y_stride = (2 << log2_blocksize);
}
y_ptr = s->picture.data[0] + ((mb_y * s->picture.linesize[0] + mb_x) << log2_blocksize);
linesize = s->picture.linesize[0] << is_field_mode[mb_index];
mb[0] .idct_put(y_ptr , linesize, block + 0*64);
if (s->sys->video_stype == 4) {
mb[2].idct_put(y_ptr + (1 << log2_blocksize) , linesize, block + 2*64);
} else {
mb[1].idct_put(y_ptr + (1 << log2_blocksize) , linesize, block + 1*64);
mb[2].idct_put(y_ptr + y_stride, linesize, block + 2*64);
mb[3].idct_put(y_ptr + (1 << log2_blocksize) + y_stride, linesize, block + 3*64);
}
mb += 4;
block += 4*64;
c_offset = (((mb_y >> (s->sys->pix_fmt == PIX_FMT_YUV420P)) * s->picture.linesize[1] +
(mb_x >> ((s->sys->pix_fmt == PIX_FMT_YUV411P) ? 2 : 1))) << log2_blocksize);
for (j = 2; j; j--) {
uint8_t *c_ptr = s->picture.data[j] + c_offset;
if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8)) {
uint64_t aligned_pixels[64/8];
uint8_t *pixels = (uint8_t*)aligned_pixels;
uint8_t *c_ptr1, *ptr1;
int x, y;
mb->idct_put(pixels, 8, block);
for (y = 0; y < (1 << log2_blocksize); y++, c_ptr += s->picture.linesize[j], pixels += 8) {
ptr1 = pixels + (1 << (log2_blocksize - 1));
c_ptr1 = c_ptr + (s->picture.linesize[j] << log2_blocksize);
for (x = 0; x < (1 << (log2_blocksize - 1)); x++) {
c_ptr[x] = pixels[x];
c_ptr1[x] = ptr1[x];
}
}
block += 64; mb++;
} else {
y_stride = (mb_y == 134) ? (1 << log2_blocksize) :
s->picture.linesize[j] << ((!is_field_mode[mb_index]) * log2_blocksize);
linesize = s->picture.linesize[j] << is_field_mode[mb_index];
(mb++)-> idct_put(c_ptr , linesize, block); block += 64;
if (s->sys->bpm == 8) {
(mb++)->idct_put(c_ptr + y_stride, linesize, block); block += 64;
}
}
}
}
return 0;
}
| 1threat
|
Why do I get a 'cannot find symbol' error in this program? : <p>When I run the following program, I get a 'cannot find symbol' error. It is probably caused by a stupid mistake, but I have spent about an hour trying to fix it and I have no idea what the problem is. Here is the code:</p>
<pre><code>import java.util.*;
public class Purse{
private ArrayList<String> coins;
public Purse(){
coins = new ArrayList<String>();
}
public void addCoin(String coin){
if(coin == "Quarter" || coin == "Dime" || coin == "Nickel")
coins.add(coin);
}
public void removeCoin(String coin){
coins.remove(coin);
}
public void transfer(Purse other){
for(int i = 0; i < other.coins.size(); i++)
coins.add(other.coins.get(i));
other.remove(i);
}
}
</code></pre>
<p>and here is the error it gives me:</p>
<pre><code>Purse.java:23: error: cannot find symbol
other.remove(i);
^
symbol: variable i
location: class Purse
1 error
</code></pre>
<p>the program is supposed to be 'moving' items from one ArrayList to another.</p>
| 0debug
|
Getting facebook page with app_scoped_user_id is not possible anymore? : <p>Below url gaves the user's facebook page till yesterday. But it's not working anymore.</p>
<p><a href="https://www.facebook.com/app_scoped_user_id/xxxxxxxxxxxxx/" rel="noreferrer">https://www.facebook.com/app_scoped_user_id/xxxxxxxxxxxxx/</a></p>
<p>Is there any way to get user's facebook page or it's disabled for a security reason?</p>
| 0debug
|
How can I use javacript std input/output in repl.it : I write a program for finding the factorial of a given number. But I can't find the place where I give std input and std output on this website.
[Website][1]
[1]: https://repl.it/@AshiqurRahman1/Stdin-and-Stdout-in-jS
| 0debug
|
int qemu_init_main_loop(void)
{
int ret;
qemu_init_sigbus();
ret = qemu_signal_init();
if (ret) {
return ret;
}
ret = qemu_event_init();
if (ret) {
return ret;
}
qemu_cond_init(&qemu_cpu_cond);
qemu_cond_init(&qemu_system_cond);
qemu_cond_init(&qemu_pause_cond);
qemu_cond_init(&qemu_work_cond);
qemu_cond_init(&qemu_io_proceeded_cond);
qemu_mutex_init(&qemu_global_mutex);
qemu_mutex_lock(&qemu_global_mutex);
qemu_thread_get_self(&io_thread);
return 0;
}
| 1threat
|
void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,
int64_t bps_wr,
int64_t iops,
int64_t iops_rd,
int64_t iops_wr,
bool has_bps_max,
int64_t bps_max,
bool has_bps_rd_max,
int64_t bps_rd_max,
bool has_bps_wr_max,
int64_t bps_wr_max,
bool has_iops_max,
int64_t iops_max,
bool has_iops_rd_max,
int64_t iops_rd_max,
bool has_iops_wr_max,
int64_t iops_wr_max,
bool has_iops_size,
int64_t iops_size, Error **errp)
{
ThrottleConfig cfg;
BlockDriverState *bs;
AioContext *aio_context;
bs = bdrv_find(device);
if (!bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
memset(&cfg, 0, sizeof(cfg));
cfg.buckets[THROTTLE_BPS_TOTAL].avg = bps;
cfg.buckets[THROTTLE_BPS_READ].avg = bps_rd;
cfg.buckets[THROTTLE_BPS_WRITE].avg = bps_wr;
cfg.buckets[THROTTLE_OPS_TOTAL].avg = iops;
cfg.buckets[THROTTLE_OPS_READ].avg = iops_rd;
cfg.buckets[THROTTLE_OPS_WRITE].avg = iops_wr;
if (has_bps_max) {
cfg.buckets[THROTTLE_BPS_TOTAL].max = bps_max;
}
if (has_bps_rd_max) {
cfg.buckets[THROTTLE_BPS_READ].max = bps_rd_max;
}
if (has_bps_wr_max) {
cfg.buckets[THROTTLE_BPS_WRITE].max = bps_wr_max;
}
if (has_iops_max) {
cfg.buckets[THROTTLE_OPS_TOTAL].max = iops_max;
}
if (has_iops_rd_max) {
cfg.buckets[THROTTLE_OPS_READ].max = iops_rd_max;
}
if (has_iops_wr_max) {
cfg.buckets[THROTTLE_OPS_WRITE].max = iops_wr_max;
}
if (has_iops_size) {
cfg.op_size = iops_size;
}
if (!check_throttle_config(&cfg, errp)) {
return;
}
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
if (!bs->io_limits_enabled && throttle_enabled(&cfg)) {
bdrv_io_limits_enable(bs);
} else if (bs->io_limits_enabled && !throttle_enabled(&cfg)) {
bdrv_io_limits_disable(bs);
}
if (bs->io_limits_enabled) {
bdrv_set_io_limits(bs, &cfg);
}
}
| 1threat
|
Multiple if Statments issue : I am having a problem with multiple if statements. I am using && but it seems to only work for the first statement.
The code is like such:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
global $post;
$args = array( 'post_id' => $post->ID );
$comment = get_comments( $args );
$user = wp_get_current_user();
if ( 3 <= count( $comment ) && $post->post_author == $user->ID) {
echo do_shortcode( '[button]' );
} else {
comment_form();
}
<!-- end snippet -->
It basically stats that if there is less than 3 comments then show the comment form but if there is more than 3 and is the post author then show a button. The button shows but only if there are more than 3 comments. It doesn't check if it is only the post author or not, like i want it to.
| 0debug
|
static int bands_dist(OpusPsyContext *s, CeltFrame *f, float *total_dist)
{
int i, tdist = 0.0f;
OpusRangeCoder dump;
ff_opus_rc_enc_init(&dump);
ff_celt_enc_bitalloc(f, &dump);
for (i = 0; i < CELT_MAX_BANDS; i++) {
float bits = 0.0f;
float dist = f->pvq->band_cost(f->pvq, f, &dump, i, &bits, s->lambda);
tdist += dist;
}
*total_dist = tdist;
return 0;
}
| 1threat
|
static int ebml_read_binary(AVIOContext *pb, int length, EbmlBin *bin)
{
av_free(bin->data);
if (!(bin->data = av_malloc(length)))
return AVERROR(ENOMEM);
bin->size = length;
bin->pos = avio_tell(pb);
if (avio_read(pb, bin->data, length) != length) {
av_freep(&bin->data);
return AVERROR(EIO);
}
return 0;
}
| 1threat
|
Just upgrade my site to 1.9.3.0 and got error SQLSTATE[42S22]: Column not found: 1054 Unknown column 'catalog_product_entity_group_price.is_percent' : <p>Before I was using Magento 1.9.2.4 and today I got message that need to upgrade my magento with latest update some critical updates too.</p>
<p>After upgrading my website from downloader section everything went well no error etc, two things happen that I notices after update my index.php permission was change to 666 website is opening correctly I mean front page display, but when I click on any product It show error page with following information.</p>
<p>There has been an error processing your request</p>
<pre><code>SQLSTATE[42S22]: Column not found: 1054 Unknown column 'catalog_product_entity_group_price.is_percent' in 'field list', query was: SELECT `catalog_product_entity_group_price`.`value_id` AS `price_id`, `catalog_product_entity_group_price`.`website_id`, `catalog_product_entity_group_price`.`all_groups`, `catalog_product_entity_group_price`.`customer_group_id` AS `cust_group`, `catalog_product_entity_group_price`.`value` AS `price`, `catalog_product_entity_group_price`.`is_percent` FROM `catalog_product_entity_group_price` WHERE (entity_id='84') AND (website_id = 0)
Trace:
#0 /home/MyWebsite/public_html/app/Mage.php(463): Mage_Core_Model_Config->getModelInstance('eav/entity_attr...', 'SQLSTATE[42S22]...')
#1 /home/MyWebsite/public_html/app/code/core/Mage/Eav/Model/Entity/Abstract.php(661): Mage::getModel('eav/entity_attr...', 'SQLSTATE[42S22]...')
#2 /home/MyWebsite/public_html/app/code/core/Mage/Eav/Model/Entity/Abstract.php(1641): Mage_Eav_Model_Entity_Abstract->walkAttributes('backend/afterLo...', Arr
</code></pre>
<p>Not know how to roll back because I did not get backup as they says it is stable, or not able to resolve this error.</p>
<p>Thanks in advance</p>
| 0debug
|
static void xhci_runtime_write(void *ptr, hwaddr reg,
uint64_t val, unsigned size)
{
XHCIState *xhci = ptr;
int v = (reg - 0x20) / 0x20;
XHCIInterrupter *intr = &xhci->intr[v];
trace_usb_xhci_runtime_write(reg, val);
if (reg < 0x20) {
trace_usb_xhci_unimplemented("runtime write", reg);
return;
switch (reg & 0x1f) {
case 0x00:
if (val & IMAN_IP) {
intr->iman &= ~IMAN_IP;
intr->iman &= ~IMAN_IE;
intr->iman |= val & IMAN_IE;
if (v == 0) {
xhci_intx_update(xhci);
xhci_msix_update(xhci, v);
break;
case 0x04:
intr->imod = val;
break;
case 0x08:
intr->erstsz = val & 0xffff;
break;
case 0x10:
intr->erstba_low = val & 0xfffffff0;
break;
case 0x14:
intr->erstba_high = val;
xhci_er_reset(xhci, v);
break;
case 0x18:
intr->erdp_low &= ~ERDP_EHB;
intr->erdp_low = (val & ~ERDP_EHB) | (intr->erdp_low & ERDP_EHB);
break;
case 0x1c:
intr->erdp_high = val;
xhci_events_update(xhci, v);
break;
default:
trace_usb_xhci_unimplemented("oper write", reg);
| 1threat
|
void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
qmp_block_set_io_throttle(qdict_get_str(qdict, "device"),
qdict_get_int(qdict, "bps"),
qdict_get_int(qdict, "bps_rd"),
qdict_get_int(qdict, "bps_wr"),
qdict_get_int(qdict, "iops"),
qdict_get_int(qdict, "iops_rd"),
qdict_get_int(qdict, "iops_wr"), &err);
hmp_handle_error(mon, &err);
}
| 1threat
|
How to write this code cleaner, without repetition? : <pre><code> $("#yl").click(function(){updateYear("sub")});
$("#yr").click(function(){updateYear("add")});
$("#ml").click(function(){updateMonth("sub")});
$("#mr").click(function(){updateMonth("add")});
$("#dl").click(function(){updateDay("sub")});
$("#dr").click(function(){updateDay("add")});
</code></pre>
<p>Is there a way to write this code cleaner, smarter without repetitions?</p>
| 0debug
|
PHP check youtube channel existence without API : <p>I want to make simple <code>curl</code> call to check if youtube channel exists.
Is it possible without using google API ?</p>
| 0debug
|
Swift tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) is not called : I have a Viewcontroller -> UIVIew -> UITableview.
`tableView(_ tableView: UITableView, numberOfRowsInSection section: Int)` and `tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath)` is called but not `tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)` not called.
class ViewcontrollerA : UIViewController , UITableViewDelegate , UITableViewDataSource {
override func viewDidLoad() {
super.viewDidLoad()
self.doctortableView.delegate = self
self.doctortableView.dataSource = self
self.doctortableView.allowsSelection = true
}
func callTable() {
doctortableView.frame = CGRect(......)
view1.addSubview(doctortableView)
doctortableView.isUserInteractionEnabled = true
self.view.addSubview(view1)
}
//Tableview Functions
//Number of Sections in Table
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
var count = Int()
return count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell = UITableViewCell()
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//This function is not called
}
| 0debug
|
How to create parameters with arrays? : <p>I'm trying to set a parameter as an array, but I get "unexpected token..." at {name[2]}.</p>
<pre><code>// javascript
const name = ['Jin', 'Kazuya', 'Heiachi']
function Intro(name, profession, city) {
document.write("My name is " + name + ", I'm a" + profession + " from" + city);
}
Intro({name[2]}, ' salesman', ' Chicago');
</code></pre>
| 0debug
|
Access Google spreadsheet API without auth token : <p>I have created Google Spreadsheet, and given edit access to all (can edit even without login).</p>
<p>Here is the <a href="https://docs.google.com/spreadsheets/d/1DKp_nAw37yppmAcfmVI7h340mC2kkI89EOHPGdxu620/edit#gid=0" rel="noreferrer">link</a>. I would like to update this sheet with Google Spreadsheet API. But I am getting error. My requirement is update the sheet thru API even without access credential.</p>
<p><a href="https://i.stack.imgur.com/7phCv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7phCv.png" alt="enter image description here"></a></p>
| 0debug
|
How to code a "if X or If Y AND Z" in JavaScript? : <p>I'm trying to code something who could be say by "If X or if Y AND Z" but it looks like I made a mistake</p>
<pre><code>if((machine.isUsed == false) || (if(this.whoUseIt.includes(Session.get("loggedUser")))&&(machine.isUsed))){
</code></pre>
<p>I need to do this test to avoid a code duplication. If you have a better idea I'm still opened to it.</p>
| 0debug
|
int ff_cbs_write_packet(CodedBitstreamContext *ctx,
AVPacket *pkt,
CodedBitstreamFragment *frag)
{
int err;
err = ff_cbs_write_fragment_data(ctx, frag);
if (err < 0)
return err;
av_new_packet(pkt, frag->data_size);
if (err < 0)
return err;
memcpy(pkt->data, frag->data, frag->data_size);
pkt->size = frag->data_size;
return 0;
}
| 1threat
|
ReactJS Bootstrap Navbar and Routing not working together : <p>I am trying to create a simple Webapp using ReactJS, and I wanted to use the <code>Navbar</code> provided by React-Bootstrap. </p>
<p>I created a <code>Navigation.js</code> file containing a class <code>Navigation</code> to separate the <code>Navbar</code> and the Routing from the <code>App.js</code> file. However, both parts do not seem to work. When I load the page, it is just empty, there is no Navbar. Can anyone spot a mistake?</p>
<p>Navigation.js:</p>
<pre><code>import React, { Component } from 'react';
import { Navbar, Nav, Form, FormControl, Button, NavItem } from 'react-bootstrap';
import { Switch, Route } from 'react-router-dom';
import { Home } from './Page';
class Navigation extends Component {
render() {
return (
<div>
<div>
<Navbar>
<Navbar.Brand href="/">React-Bootstrap</Navbar.Brand>
<Navbar.Collapse>
<Nav className="mr-auto">
<NavItem eventkey={1} href="/">
<Nav.Link href="/">Home</Nav.Link>
</NavItem>
</Nav>
<Form inline>
<FormControl type="text" placeholder="Search" className="mr-sm-2" />
<Button variant="outline-success">Search</Button>
</Form>
</Navbar.Collapse>
</Navbar>
</div>
<div>
<Switch>
<Route exact path='/' component={Home} />
<Route render={function () {
return <p>Not found</p>
}} />
</Switch>
</div>
</div>
);
}
}
export default Navigation;
</code></pre>
<p>App.js:</p>
<pre><code>import React, { Component } from 'react';
import Navigation from './components/routing/Navigation';
class App extends Component {
render() {
return (
<div id="App">
<Navigation />
</div>
);
}
}
export default App;
</code></pre>
<p>I tried using a <code>NavItem</code> containing a <code>LinkContainer</code> from <code>react-router-bootstrap</code> already, which led to the same result. </p>
<p>Just for completeness, Page.js:</p>
<pre><code>import React, { Component } from 'react';
import { Link } from 'react-router-dom';
export const Page = ({ title }) => (
<div className="App">
<div className="App-header">
<h2>{title}</h2>
</div>
<p className="App-intro">
This is the {title} page.
</p>
<p>
<Link to="/">Home</Link>
</p>
<p>
<Link to="/about">About</Link>
</p>
<p>
<Link to="/settings">Settings</Link>
</p>
</div>
);
export const About = (props) => (
<Page title="About"/>
);
export const Settings = (props) => (
<Page title="Settings"/>
);
export const Home = (props) => (
<Page title="Home"/>
);
</code></pre>
| 0debug
|
int vnc_zlib_send_framebuffer_update(VncState *vs, int x, int y, int w, int h)
{
int old_offset, new_offset, bytes_written;
vnc_framebuffer_update(vs, x, y, w, h, VNC_ENCODING_ZLIB);
old_offset = vs->output.offset;
vnc_write_s32(vs, 0);
vnc_zlib_start(vs);
vnc_raw_send_framebuffer_update(vs, x, y, w, h);
bytes_written = vnc_zlib_stop(vs);
if (bytes_written == -1)
return 0;
new_offset = vs->output.offset;
vs->output.offset = old_offset;
vnc_write_u32(vs, bytes_written);
vs->output.offset = new_offset;
return 1;
}
| 1threat
|
Does casting a char array to another type violate strict-aliasing rules? : <p>Consider these two functions:</p>
<pre><code>int f1()
{
alignas(int) char buf[sizeof(int)] = {};
return *reinterpret_cast<int*>(buf);
}
int f2()
{
alignas(int) char buf[sizeof(int)] = {};
char* ptr = buf;
return *reinterpret_cast<int*>(ptr);
}
</code></pre>
<p>GCC warns that the first violates strict-aliasing rules. But the second is OK.</p>
<p>Clang accepts both without complaint.</p>
<p>Is the warning legitimate?</p>
| 0debug
|
void set_numa_modes(void)
{
CPUArchState *env;
int i;
for (env = first_cpu; env != NULL; env = env->next_cpu) {
for (i = 0; i < nb_numa_nodes; i++) {
if (node_cpumask[i] & (1 << env->cpu_index)) {
env->numa_node = i;
}
}
}
}
| 1threat
|
Angular2 keyup event update ngModel cursor position jumps to end : <p>I am having an issue with an Angular2 directive that should do the following:</p>
<ul>
<li>Detect if the user enters '.' character.</li>
<li>If the next char is also '.', remove the duplicate '.' and move the cursor position to after the '.' char</li>
</ul>
<p>I have the above working, however, when using this in combination with ngModel, the cursor position jumps to the end every time the model is updated.</p>
<p>The input:</p>
<pre><code><input type="text" name="test" [(ngModel)]="testInput" testDirective/>
</code></pre>
<p>The directive:</p>
<pre><code> import {Directive, ElementRef, Renderer, HostListener, Output, EventEmitter} from '@angular/core';
@Directive({
selector: '[testDirective][ngModel]'
})
export class TestDirective {
@Output() ngModelChange: EventEmitter<any> = new EventEmitter();
constructor(private el: ElementRef,
private render: Renderer) { }
@HostListener('keyup', ['$event']) onInputChange(event) {
// get position
let pos = this.el.nativeElement.selectionStart;
let val = this.el.nativeElement.value;
// if key is '.' and next character is '.', skip position
if (event.key === '.' &&
val.charAt(pos) === '.') {
// remove duplicate periods
val = val.replace(duplicatePeriods, '.');
this.render.setElementProperty(this.el.nativeElement, 'value', val);
this.ngModelChange.emit(val);
this.el.nativeElement.selectionStart = pos;
this.el.nativeElement.selectionEnd = pos;
}
}
}
</code></pre>
<p>This works, except the cursor position jumps to the end. Removing the line:</p>
<pre><code>this.ngModelChange.emit(val);
</code></pre>
<p>Fixes the issue and the cursor position is correct, however the model is not updated.</p>
<p>Can anyone recommend a solution to this? Or maybe I am taking the wrong approach to the problem?</p>
<p>Thanks</p>
| 0debug
|
document.getElementById('input').innerHTML = user_input;
| 1threat
|
static int raw_open_common(BlockDriverState *bs, const char *filename,
int bdrv_flags, int open_flags)
{
BDRVRawState *s = bs->opaque;
int fd, ret;
ret = raw_normalize_devicepath(&filename);
if (ret != 0) {
return ret;
}
s->open_flags = open_flags | O_BINARY;
s->open_flags &= ~O_ACCMODE;
if (bdrv_flags & BDRV_O_RDWR) {
s->open_flags |= O_RDWR;
} else {
s->open_flags |= O_RDONLY;
}
if ((bdrv_flags & BDRV_O_NOCACHE))
s->open_flags |= O_DIRECT;
if (!(bdrv_flags & BDRV_O_CACHE_WB))
s->open_flags |= O_DSYNC;
s->fd = -1;
fd = qemu_open(filename, s->open_flags, 0644);
if (fd < 0) {
ret = -errno;
if (ret == -EROFS)
ret = -EACCES;
return ret;
}
s->fd = fd;
s->aligned_buf = NULL;
if ((bdrv_flags & BDRV_O_NOCACHE)) {
s->aligned_buf_size = 32 * MAX_BLOCKSIZE;
s->aligned_buf = qemu_memalign(MAX_BLOCKSIZE, s->aligned_buf_size);
if (s->aligned_buf == NULL) {
goto out_close;
}
}
if (paio_init() < 0) {
goto out_free_buf;
}
#ifdef CONFIG_LINUX_AIO
if ((bdrv_flags & (BDRV_O_NOCACHE|BDRV_O_NATIVE_AIO)) ==
(BDRV_O_NOCACHE|BDRV_O_NATIVE_AIO)) {
s->aio_ctx = laio_init();
if (!s->aio_ctx) {
goto out_free_buf;
}
s->use_aio = 1;
} else
#endif
{
#ifdef CONFIG_LINUX_AIO
s->use_aio = 0;
#endif
}
#ifdef CONFIG_XFS
if (platform_test_xfs_fd(s->fd)) {
s->is_xfs = 1;
}
#endif
return 0;
out_free_buf:
qemu_vfree(s->aligned_buf);
out_close:
qemu_close(fd);
return -errno;
}
| 1threat
|
What is faster, and how can I measure such things? : <pre><code>using System.Collections.Generic;
using System.IO
</code></pre>
<p>Which variant is faster?</p>
<p>This?</p>
<pre><code>List<short> a = new List<short>();
a.Add(0);
a.Add(1);
a.Add(2);
FileStream fs = new FileStream("file", FileMode.OpenOrCreate, FileAccess.Write){
using ( BinaryWriter bw = new BinaryWriter(fs)){
foreach ( short b in a ){
bw.Write(b);
}
}
}
</code></pre>
<p>or this?</p>
<pre><code>string a = "";
a += "0";
a += "1";
a += "2";
File.WriteAllText("file", a);
</code></pre>
<p>or this?</p>
<pre><code>short[] a = new short[3];
a[0] = 0;
a[1] = 1;
a[2] = 2;
FileStream fs = new FileStream("file", FileMode.OpenOrCreate, FileAccess.Write){
using ( BinaryWriter bw = new BinaryWriter(fs)){
foreach ( short b in a ){
bw.Write(b);
}
}
</code></pre>
<p>}</p>
<p>I would like to know how fast each of these pieces of code compiles, and and how can I measure the speed myself.</p>
| 0debug
|
Building a Search Engine. : <p>I am trying to build a website. User able input certain data from the search field which returns relevant information from the database. What approach should I take to do this project? I am new in programming. I just need suggestions and steps. Thank you. Preferred P.L is Java and MySQL.</p>
| 0debug
|
Navigating through links using Selenium in Python : <p>I'm trying to scrape data from a site with multiple pages linked via a <strong>NEXT</strong> button </p>
<p>The successive page URL has no correspondence with the previous page URL as one might assume</p>
<p>(In that case modifying the path would've solved the problem)</p>
<p>This is what I plan to do -</p>
<p>1.Start with an initial URL </p>
<p>2.Extract information</p>
<p>3.Click <strong>NEXT</strong></p>
<p>Repeat 2 and 3 <em>n</em> times</p>
<p>Specifically, I wanted to know how to get the new page URL on clicking </p>
<p>This is what I've come up with so far</p>
<pre><code>def startWebDriver():
global driver
options = Options()
options.add_argument("--disable-extensions")
driver = webdriver.Chrome(executable_path = '/path/to/driver/chromedriver_linux64/chromedriver',options=options)
#URL of the initial page
driver.get('https://openi.nlm.nih.gov/detailedresult.php?img=CXR1_1_IM-0001-3001&query=&coll=cxr&req=4&npos=1')
time.sleep(4)
#XPATH of the "NEXT" button
element = driver.find_element_by_xpath('//*[@id="imageClassM"]/div/a[2]/img').click()
</code></pre>
<p>Any help would be appreciated</p>
| 0debug
|
Does Spark maintain parquet partitioning on read? : <p>I am having a lot trouble finding the answer to this question. Let's say I write a dataframe to parquet and I use <code>repartition</code> combined with <code>partitionBy</code> to get a nicely partitioned parquet file. See Below:</p>
<pre><code>df.repartition(col("DATE")).write.partitionBy("DATE").parquet("/path/to/parquet/file")
</code></pre>
<p>Now later on I would like to read the parquet file so I do something like this:</p>
<pre><code>val df = spark.read.parquet("/path/to/parquet/file")
</code></pre>
<p>Is the dataframe partitioned by <code>"DATE"</code>? In other words if a parquet file is partitioned does spark maintain that partitioning when reading it into a spark dataframe. Or is it randomly partitioned?</p>
<p>Also the why and why not to this answer would be helpful as well.</p>
| 0debug
|
static int bad_mode_switch(CPUARMState *env, int mode)
{
switch (mode) {
case ARM_CPU_MODE_USR:
case ARM_CPU_MODE_SYS:
case ARM_CPU_MODE_SVC:
case ARM_CPU_MODE_ABT:
case ARM_CPU_MODE_UND:
case ARM_CPU_MODE_IRQ:
case ARM_CPU_MODE_FIQ:
return 0;
case ARM_CPU_MODE_HYP:
return !arm_feature(env, ARM_FEATURE_EL2)
|| arm_current_el(env) < 2 || arm_is_secure(env);
case ARM_CPU_MODE_MON:
return !arm_is_secure(env);
default:
return 1;
}
}
| 1threat
|
How to access Flutter Back button functionality? : <p>I would like to present an AdWords interstitial before the user returns to the previous page. How can I do this when the return button is pressed?</p>
| 0debug
|
static void ppc_core99_init(QEMUMachineInitArgs *args)
{
ram_addr_t ram_size = args->ram_size;
const char *cpu_model = args->cpu_model;
const char *kernel_filename = args->kernel_filename;
const char *kernel_cmdline = args->kernel_cmdline;
const char *initrd_filename = args->initrd_filename;
const char *boot_device = args->boot_device;
PowerPCCPU *cpu = NULL;
CPUPPCState *env = NULL;
char *filename;
qemu_irq *pic, **openpic_irqs;
MemoryRegion *unin_memory = g_new(MemoryRegion, 1);
int linux_boot, i;
MemoryRegion *ram = g_new(MemoryRegion, 1), *bios = g_new(MemoryRegion, 1);
hwaddr 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 *escc_bar = g_new(MemoryRegion, 1);
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++) {
cpu = cpu_ppc_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
}
env = &cpu->env;
cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
qemu_register_reset(ppc_core99_reset, cpu);
}
memory_region_init_ram(ram, "ppc_core99.ram", ram_size);
vmstate_register_ram_global(ram);
memory_region_add_subregion(get_system_memory(), 0, ram);
memory_region_init_ram(bios, "ppc_core99.bios", BIOS_SIZE);
vmstate_register_ram_global(bios);
if (bios_name == NULL)
bios_name = PROM_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
memory_region_set_readonly(bios, true);
memory_region_add_subregion(get_system_memory(), PROM_ADDR, bios);
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_mmio_init(0xf2000000, 0x00800000);
memory_region_init_io(unin_memory, &unin_ops, NULL, "unin", 0x1000);
memory_region_add_subregion(get_system_memory(), 0xf8000000, 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(&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(0, pic[0x25], pic[0x24],
serial_hds[0], serial_hds[1], ESCC_CLOCK, 4);
memory_region_init_alias(escc_bar, "escc-bar",
escc_mem, 0, memory_region_size(escc_mem));
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]);
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_bar);
if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
pci_create_simple(pci_bus, -1, "pci-ohci");
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
|
Simple password-protection for React app on Heroku : <p>I have a simple React app, created with create-react-app, that I'd like to deploy to Heroku (or somewhere easy) and password-protect. The protection can be really simple—just a single password is fine.</p>
<p>I started looking into HTTP basic auth but didn't find an easy answer. The closest I found was in <a href="https://blog.snajdr.de/adding-password-protection-to-zero-configuration-webpack-react-app-1bd3fc976996" rel="noreferrer">this post</a>, but (a) I don't love the idea of having to eject my app, and (b) I couldn't get it working. I was hoping I could find a Heroku plugin, but no luck there either.</p>
<p>It wouldn't be too hard to write a component that wraps my app and requests a password before showing it. The problem is that it executes client-side. I want to store the correct password server-side (or a hash thereof), and have the app send password attempts up to the server.</p>
<p>Since create-react-app operates on top of Node, I'm hoping there's an easy way to tell it to execute and store certain things on the server, but maybe I'm wrong. Any suggestions?</p>
| 0debug
|
How can i use a TRIM fonction in a SQL Query? : Hi i would like to use the trim fonction but don't realy know how it working.
I need to select items in a table and export it on a CSV file.
It's working fine but sometime when i have a specif data (here it's a string), the csv file write it with à CR LF and write at the line after.
I think that a problem with the data in the data base and that there "something" after my data in this specific field.
I have this query
string request = "SELECT * FROM " + tableName;
And i want to try this but i'm not sure.
string request = "SELECT * TRIM(TRAILING FROM ") + tableName;
Can you please help me ?
sorry for my bad english
Thanks
| 0debug
|
static inline int mpeg2_decode_block_intra(MpegEncContext *s,
int16_t *block, int n)
{
int level, dc, diff, i, j, run;
int component;
RLTable *rl;
uint8_t *const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix;
const int qscale = s->qscale;
int mismatch;
if (n < 4) {
quant_matrix = s->intra_matrix;
component = 0;
} else {
quant_matrix = s->chroma_intra_matrix;
component = (n & 1) + 1;
}
diff = decode_dc(&s->gb, component);
if (diff >= 0xffff)
return AVERROR_INVALIDDATA;
dc = s->last_dc[component];
dc += diff;
s->last_dc[component] = dc;
block[0] = dc << (3 - s->intra_dc_precision);
ff_tlog(s->avctx, "dc=%d\n", block[0]);
mismatch = block[0] ^ 1;
i = 0;
if (s->intra_vlc_format)
rl = &ff_rl_mpeg2;
else
rl = &ff_rl_mpeg1;
{
OPEN_READER(re, &s->gb);
for (;;) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],
TEX_VLC_BITS, 2, 0);
if (level == 127) {
break;
} else if (level != 0) {
i += run;
if (i > MAX_INDEX)
break;
j = scantable[i];
level = (level * qscale * quant_matrix[j]) >> 4;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -
SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
} else {
run = SHOW_UBITS(re, &s->gb, 6) + 1;
LAST_SKIP_BITS(re, &s->gb, 6);
UPDATE_CACHE(re, &s->gb);
level = SHOW_SBITS(re, &s->gb, 12);
SKIP_BITS(re, &s->gb, 12);
i += run;
if (i > MAX_INDEX)
break;
j = scantable[i];
if (level < 0) {
level = (-level * qscale * quant_matrix[j]) >> 4;
level = -level;
} else {
level = (level * qscale * quant_matrix[j]) >> 4;
}
}
mismatch ^= level;
block[j] = level;
}
CLOSE_READER(re, &s->gb);
}
block[63] ^= mismatch & 1;
check_scantable_index(s, i);
s->block_last_index[n] = i;
return 0;
}
| 1threat
|
How can I use database with javascript? : <pre><code><script>
function process_Login(){
var c = document.getElementById("usr").value;
var d = document.getElementById("pwd").value;
if(c.length==0){
alert("ERROR: Your ID account is NULL");
}
else if(isNaN(c)){
alert("ERROR: Your ID must be number");
}
else
{
$con = mysql_connect("localhost", "root", "");
if(!$con){
die("cound not connect");
}
//select database
mysql_select_db("db_atmvisual");
$query = mysql_query("SELECT * FROM tb_account WHERE account_id='c' AND account_pin='d'");
$row = mysql_num_rows($query);
if($row!=0){
window.location = "http://127.0.0.1:8080/atmvisual/processlogin.php";
}
else
alert("loginfail");
}
}
</script>
</code></pre>
<p>I'm trying use javascript to connect my code with sql, but I don't know why it doesn't run! if it's ok it'll change to the other page, else it'll print an alert! Can you tell me my error? and how can I improve my code?</p>
| 0debug
|
Beginner programmer, and I received an error : printf("The rate of train 1 and train 2 respectively are what values?\n");
scanf("%d%d", &rate_1_mph, &rate_2_mph);
printf("What was the total distance the trains were apart initially?\n");
scanf("%d", &distance_total_mile);
printf("The time it takes both trains to arrive side-by-side is %.31f minutes.\n", time_minute);
printf("The distance train 1 had to travel was %.21f miles.\n", distance_1_mile);
printf("The distance train 2 had to travel was %.21f miles.\n", distance_2_mile);
return 0;
}
The error I received was: "warning: format '%f' expects argument of type 'double', but argument 2 has type 'int *".
I've tried looking this up on this site, and I saw the same question solved two different ways but neither seemed to work. I also didn't post the entire code because the other example I saw didn't either, and their question was answered.
| 0debug
|
Tarck anonymous users without forcing users to go through authentication proccess : i want to track all users ( both authenticated users and anonymous users) , so far the solution i found are not good.
first of all we can use cookie but as we all know its not a reliable solution ,
second of all we can use browser finger printing, but until this moment i did not find any solution for server side.
i found this solution [valve][1] but it is for client side , i want an approach which user does not find any token in request , i want to create the key in server side so i can track users.
does any one know any solution ?
note : my server side technology is Asp.net Mvc
use case : users can comment on m site and also they can like or dislike comments, i want to allow all users to do this and also i want to track users before action ( like or dislike )
[1]: https://github.com/Valve/fingerprintjs
| 0debug
|
Trying ot create an admin "login" : I am trying to make an "admin" login and it isn't working, help?
@echo off
title RPG BETA
color 0b
set /p player=Welcome to Xero, what's your name?:
if '%player%' == 'Admin' goto admin
:intro
echo Hello %player%!
pause
goto start
:admin
set /p password:What is the admin password?:
if %password% == [not giving out password] goto true
if %password not [not giving out password] goto false
| 0debug
|
Use static_cast to dynamic polymorphism : <p>I used a static_cast to polymorphism.
I read that I should use dynamic_cast, but I can't get why.
Code works in both way (with static and dynamic cast).</p>
<p>Could anybody show me an example with necessary dynamic_cast operator? </p>
<pre><code>class Base
{
public:
virtual void foo() = 0;
};
class D1 : public Base
{
public:
void foo()
{
std::cout << "D1()";
}
};
class D2 : public Base
{
public:
void foo()
{
std::cout << "D2()";
}
};
int main()
{
srand( time( NULL ) );
int r = std::rand()%2;
Base* b_ptr;
if(r == 0)
{
b_ptr = static_cast<Base*>(new D1);
}
else
{
b_ptr = static_cast<Base*>(new D2);
}
b_ptr->foo();
}
</code></pre>
| 0debug
|
matplotlib ylabel TypeError: 'str' object is not callable : <p>I have noticed some strange behavior that I can't understand in matplotlib.pyplot </p>
<p>When I call the ylabel method I get as TypeError as seen below. This does not happen with the xlabel method. The string value there is find and my plot prints.</p>
<p>What have I missed?</p>
<pre><code>TypeError Traceback (most recent call last)
<ipython-input-85-5a3cfeebed52> in <module>()
4 plt.grid(False)
5 #plt.ylabel('Relative Search Freq')
----> 6 plt.ylabel('This is the Y Label')
7 plt.xlabel('This is the X Label')
8 plt.legend()
TypeError: 'str' object is not callable
</code></pre>
<p>The plot does print but without the ylabel or any of the code after the error which seems normal behavior.</p>
| 0debug
|
How to detect a 401 with axios and stop the console error : <p>I am trying to use axios to call an API and return data.</p>
<p>I have the following code which works fine</p>
<pre><code>axios.get('http://api/courses')
.catch(function (error) {
if (error.response) {
console.log(error.response.status);
} else {
console.log('Error', error.message);
}
})
.then(response => {
console.log(response.data)
});
</code></pre>
<p>This works fine, the API returns a 200 and data so in the console I get the data returned.</p>
<p>However this does not work</p>
<pre><code>axios.get('http://api/courses')
.catch(function (error) {
if (error.response) {
console.log(error.response.status);
} else {
console.log('Error', error.message);
}
})
.then(response => {
console.log(response.data)
});
</code></pre>
<p>On the above call i get a 401 returned from the API, I want to be able to detect that and do something (where i am currently doing a console.log). However in the console I get the following errors:</p>
<pre><code>GET http://api/courses 401 (Unauthorized)
(anonymous) @ spread.js:25
e.exports @ spread.js:25
e.exports @ spread.js:25
Promise.then (async)
r.request @ spread.js:25
r.(anonymous function) @ spread.js:25
(anonymous) @ index.js:20
(anonymous) @ (index):49
(index):58 Uncaught (in promise) TypeError: Cannot read property 'data' of undefined
at axios.get.catch.then.response ((index):58)
at <anonymous>
</code></pre>
<p>Is there a way to capture a 401? It seems like common practice by API's that require auth, but I cannot seem to work it out.
Thanks</p>
| 0debug
|
static void grlib_gptimer_enable(GPTimer *timer)
{
assert(timer != NULL);
ptimer_stop(timer->ptimer);
if (!(timer->config & GPTIMER_ENABLE)) {
trace_grlib_gptimer_disabled(timer->id, timer->config);
return;
}
trace_grlib_gptimer_enable(timer->id, timer->counter + 1);
ptimer_set_count(timer->ptimer, timer->counter + 1);
ptimer_run(timer->ptimer, 1);
}
| 1threat
|
static int set_palette(AVFrame * frame, const uint8_t * palette_buffer, int buf_size)
{
uint32_t * palette = (uint32_t *)frame->data[1];
int a;
if (buf_size < 256*3)
return AVERROR_INVALIDDATA;
for(a = 0; a < 256; a++){
palette[a] = AV_RB24(&palette_buffer[a * 3]) * 4;
}
frame->palette_has_changed = 1;
return 256*3;
}
| 1threat
|
Why inbuilt classes in Java doesn't have default constructors and arguments need to be passes while creating an object of that class? : I wanted to know why inbuilt classes in Java doesn't have default constructors but arguments need to be passed while creating an object of that class?
Ex:
public final class String
extends Object
implements Serializable, Comparable<String>, CharSequence
public final class Array
extends Object
public final class String
extends Object
implements Serializable, Comparable<String>, CharSequence
| 0debug
|
How to center the Clicked position in the Recyclerview : <p>I want to center the clicked position in the <code>Recyclerview</code>. I am able to scroll the <code>Recyclerview</code> to certain position but i want to middle that position in the screen.
I used this method to scroll to that position.</p>
<pre><code>videoRecyclerview.scrollToPosition(position);
</code></pre>
| 0debug
|
Codeigniter session is not working on PHP 7 : <p>I am using <strong>codeigniter version 3.0.6</strong> on <strong>PHP 5.6</strong> and it works fine. but when I run same project on <strong>PHP 7.1</strong> , codeigniter session is not working. I set session like below</p>
<pre><code>$login_session = $this->session->set_userdata("user_session",$session_data);
</code></pre>
<p>when I print <strong>$login_session</strong> it is blank on PHP 7</p>
| 0debug
|
how to compare the elemnts of an array : <p>Given a non-empty array, return true if there is a place to split the array so that the sum of the numbers on one side is equal to the sum of the numbers on the other side. </p>
| 0debug
|
i want to get style attribute using jquery : Hello i want get height from below div using Jquery
<div class="profile-tracker" style="width: 577px; height: 404px; position: absolute; top: -2px; left: -2px; z-index: 290;"></div>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.