problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Trying to build user reviews based site : <p>Im trying to build a website based on wordpress that users could add reviews on their products.
Therefore i need
1. an option for the user to fill up form with details (that i have chosen) about the product.
2. an option to add reviews on the same product - just like a comment but with more options.</p>
<p>good example is the site "Trailspace"</p>
<p>appreciate any tips and suggestions! </p>
<p>Thanks</p>
| 0debug |
angularjs directive to angular6 component/directive : <p>I have one angularjs directive as part of old application, I would like to convert that into angular6, As I dont know angularJS and currently working with angular6 version, could anybody please help me with pointer ? below is angularjs code.</p>
<pre><code>define(function (require, exports, module) {
'use strict';
var base = require('base');
var utils = base.utils;
configCompile.$inject = ['$compileProvider'];
module.exports = configCompile;
function configCompile($compileProvider) {
$compileProvider.directive('projCompile', projCompile);
function projCompile($compile) {
return {
scope: {
compile: "=",
scope: "=?",
},
link: link,
}
function link(scope, element, attrs) {
var scope_child = scope.$new();
scope.$watch('compile', function () {
element.empty().append(scope.compile);
$compile(element.contents())(scope_child);
}
);
scope.$watch('scope', function () {
scope.scope = scope.scope || {};
scope_child = scope.$new();
for (var idx in scope.scope) {
scope_child[idx] = scope.scope[idx];
}
scope_child.$this = scope.scope;
element.empty().append(scope.compile);
$compile(element.contents())(scope_child);
}
);
};
};
}
})
</code></pre>
| 0debug |
static void init_2d_vlc_rl(RLTable *rl)
{
int i;
init_vlc(&rl->vlc, TEX_VLC_BITS, rl->n + 2,
&rl->table_vlc[0][1], 4, 2,
&rl->table_vlc[0][0], 4, 2);
rl->rl_vlc[0]= av_malloc(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
for(i=0; i<rl->vlc.table_size; i++){
int code= rl->vlc.table[i][0];
int len = rl->vlc.table[i][1];
int level, run;
if(len==0){
run= 65;
level= MAX_LEVEL;
}else if(len<0){
run= 0;
level= code;
}else{
if(code==rl->n){
run= 65;
level= 0;
}else if(code==rl->n+1){
run= 0;
level= 127;
}else{
run= rl->table_run [code] + 1;
level= rl->table_level[code];
}
}
rl->rl_vlc[0][i].len= len;
rl->rl_vlc[0][i].level= level;
rl->rl_vlc[0][i].run= run;
}
}
| 1threat |
Swift - How to set initial value for NSUserDefaults : <p>I have a switch called soundSwitch, I am saving the state of the button using an user default as such:</p>
<pre><code>@IBAction func soundsChanged(sender: AnyObject) {
if soundSwitch.on{
defaults.setBool(true, forKey: "SoundActive")
print("Sound ON")
}else{
defaults.setBool(false, forKey: "SoundActive")
print("Sound OFF")
}
}
</code></pre>
<p>Currently the actual defaults value is initially false when the user first launches the application. </p>
<p>How do I implement the defaults to be true if the user is first launching the app and it they haven't been configured yet.</p>
<p>I have seen methods in Objective-C, but nothing in Swift. From what I have seen you can do it in the app delegate some how, or in a plist file. How do I do either of those ones?</p>
| 0debug |
Vue components css background-image path error : <p>output</p>
<pre><code> output: {
path: config.build.assetsRoot,
publicPath: process.env.NODE_ENV === 'production' ?
config.build.assetsPublicPath : config.dev.assetsPublicPath,
filename: '[name].js'
}
</code></pre>
<p>base</p>
<pre><code> build: {
env: require('./prod.env'),
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: './',
productionSourceMap: false,
productionGzip: false,
productionGzipExtensions: ['js', 'css']
},
</code></pre>
<p>after build,the index pages work normal, css background-image path like this </p>
<pre><code>background: url(./static/img/bg_certificate.c5cad1e.png) no-repeat 50%;
</code></pre>
<p>but the component css background-image path error, like this </p>
<pre><code>background: url(static/img/btn_my.b9186cc.png) no-repeat 50%;
</code></pre>
<p>It's look like the path lose "./",</p>
| 0debug |
Cannot use [chunkhash] or [contenthash] for chunk in '[name].[chunkhash].js' (use [hash] instead) : <p>I'm getting this error when trying to run <code>webpack build</code> with hashing in my config:</p>
<pre><code>ERROR in chunk main [entry]
[name].[chunkhash].js
Cannot use [chunkhash] or [contenthash] for chunk in '[name].[chunkhash].js'
(use [hash] instead)
</code></pre>
<p>Webpack dev server runs fine</p>
<p>What is the reason for this?</p>
| 0debug |
void *g_malloc_n(size_t nmemb, size_t size)
{
size_t sz;
void *ptr;
__coverity_negative_sink__(nmemb);
__coverity_negative_sink__(size);
sz = nmemb * size;
ptr = __coverity_alloc__(size);
__coverity_mark_as_uninitialized_buffer__(ptr);
__coverity_mark_as_afm_allocated__(ptr, AFM_free);
return ptr;
}
| 1threat |
onclick is not a function : Im trying to make a image to change depending on which field in the form that is active and the first (collar()) works and i copied and tried it for the next field (chest()) it says that isnt a function whats wrong?
<input type="text" name="collar" placeholder="Collar" onclick="collar()"/>
<input type="text" name="chest" placeholder="Chest" onclick="chest()"/>
here is the javascript
function collar()
{
var image=document.getElementById('theImage')
if(image_tracker=='upperbody' || 'chest' || 'waist' || 'under' || 'lenght' || 'shoulder' )
{
image.src="collar.png";
image_tracker = 'collar';
}
else {
{
image.src = "överkropp.png";
image_tracker = 'upperbody'
}
}
}
function chest()
{
var image=document.getElementById('theImage')
if(image_tracker=='upperbody' || 'collar' || 'waist' || 'under' || 'lenght' || 'shoulder' )
{
image.src="http://www.anatomyatlases.org/firstaid/images/suckingthoraxwoundB.jpg";
image_tracker = 'chest';
}
else {
{
image.src = "överkropp.png";
image_tracker = 'upperbody'
}
}
}
| 0debug |
What is the "module" package.json field for? : <p>I've seen some npm packages (<a href="https://github.com/vuejs/vue/blob/v2.2.2/package.json#L6" rel="noreferrer">vue for example</a>) have a <code>pkg.module</code> field in their package.json. Is <code>"module"</code> an official npm property or is this a convention of some kind? Is there documentation for this somewhere? What's it for? esnext path? Unbundled module path?</p>
| 0debug |
Dagger 2.10 Android subcomponents and builders : <p>Using the new (in 2.10) dagger.android classes, I'm trying to inject things using a Subcomponent that depends on other Modules, and, therefore, has a Builder with setters for those modules. The documentation on <a href="https://google.github.io/dagger/android.html" rel="noreferrer">https://google.github.io/dagger/android.html</a> describes this, but is not clear on how to actually write and/or invoke those setters.</p>
<p>Quoting from the above link:</p>
<blockquote>
<p>AndroidInjection.inject() gets a DispatchingAndroidInjector from the Application and passes your activity to inject(Activity). The DispatchingAndroidInjector looks up the AndroidInjector.Factory for your activity’s class (which is YourActivitySubcomponent.Builder), creates the AndroidInjector (which is YourActivitySubcomponent), and passes your activity to inject(YourActivity).</p>
</blockquote>
<p>It seems to me that in order to be able to call the setters for the Builder, I need to get in there somewhere and ensure the Builder has all the necessary data? The problem I'm seeing is that at runtime, I get an <code>IllegalStateException: MODULE must be set</code>, when the generated builder for my Subcomponent is invoked by AndroidInjector.</p>
<p>The Subcomponent in question is in fact for a Fragment, not an Activity, but I'm not sure that should matter. Any ideas about how to do this?</p>
| 0debug |
static void v9fs_read(void *opaque)
{
int32_t fid;
uint64_t off;
ssize_t err = 0;
int32_t count = 0;
size_t offset = 7;
uint32_t max_count;
V9fsFidState *fidp;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
pdu_unmarshal(pdu, offset, "dqd", &fid, &off, &max_count);
trace_v9fs_read(pdu->tag, pdu->id, fid, off, max_count);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
if (fidp->fid_type == P9_FID_DIR) {
if (off == 0) {
v9fs_co_rewinddir(pdu, fidp);
}
count = v9fs_do_readdir_with_stat(pdu, fidp, max_count);
if (count < 0) {
err = count;
goto out;
}
err = offset;
err += pdu_marshal(pdu, offset, "d", count);
err += count;
} else if (fidp->fid_type == P9_FID_FILE) {
QEMUIOVector qiov_full;
QEMUIOVector qiov;
int32_t len;
v9fs_init_qiov_from_pdu(&qiov_full, pdu, offset + 4, max_count, false);
qemu_iovec_init(&qiov, qiov_full.niov);
do {
qemu_iovec_reset(&qiov);
qemu_iovec_copy(&qiov, &qiov_full, count, qiov_full.size - count);
if (0) {
print_sg(qiov.iov, qiov.niov);
}
do {
len = v9fs_co_preadv(pdu, fidp, qiov.iov, qiov.niov, off);
if (len >= 0) {
off += len;
count += len;
}
} while (len == -EINTR && !pdu->cancelled);
if (len < 0) {
err = len;
goto out;
}
} while (count < max_count && len > 0);
err = offset;
err += pdu_marshal(pdu, offset, "d", count);
err += count;
qemu_iovec_destroy(&qiov);
qemu_iovec_destroy(&qiov_full);
} else if (fidp->fid_type == P9_FID_XATTR) {
err = v9fs_xattr_read(s, pdu, fidp, off, max_count);
} else {
err = -EINVAL;
}
trace_v9fs_read_return(pdu->tag, pdu->id, count, err);
out:
put_fid(pdu, fidp);
out_nofid:
complete_pdu(s, pdu, err);
}
| 1threat |
static void ehci_trace_qh(EHCIQueue *q, target_phys_addr_t addr, EHCIqh *qh)
{
trace_usb_ehci_qh(q, addr, qh->next,
qh->current_qtd, qh->next_qtd, qh->altnext_qtd,
get_field(qh->epchar, QH_EPCHAR_RL),
get_field(qh->epchar, QH_EPCHAR_MPLEN),
get_field(qh->epchar, QH_EPCHAR_EPS),
get_field(qh->epchar, QH_EPCHAR_EP),
get_field(qh->epchar, QH_EPCHAR_DEVADDR),
(bool)(qh->epchar & QH_EPCHAR_C),
(bool)(qh->epchar & QH_EPCHAR_H),
(bool)(qh->epchar & QH_EPCHAR_DTC),
(bool)(qh->epchar & QH_EPCHAR_I));
}
| 1threat |
void nelly_decode_block(NellyMoserDecodeContext *s, unsigned char block[NELLY_BLOCK_LEN], float audio[NELLY_SAMPLES])
{
int i,j;
float buf[NELLY_FILL_LEN], pows[NELLY_FILL_LEN];
float *aptr, *bptr, *pptr, val, pval;
int bits[NELLY_BUF_LEN];
unsigned char v;
init_get_bits(&s->gb, block, NELLY_BLOCK_LEN * 8);
bptr = buf;
pptr = pows;
val = nelly_init_table[get_bits(&s->gb, 6)];
for (i=0 ; i<NELLY_BANDS ; i++) {
if (i > 0)
val += nelly_delta_table[get_bits(&s->gb, 5)];
pval = pow(2, val/2048);
for (j = 0; j < nelly_band_sizes_table[i]; j++) {
*bptr++ = val;
*pptr++ = pval;
}
}
get_sample_bits(buf, bits);
for (i = 0; i < 2; i++) {
aptr = audio + i * NELLY_BUF_LEN;
init_get_bits(&s->gb, block, NELLY_BLOCK_LEN * 8);
skip_bits(&s->gb, NELLY_HEADER_BITS + i*NELLY_DETAIL_BITS);
for (j = 0; j < NELLY_FILL_LEN; j++) {
if (bits[j] <= 0) {
aptr[j] = M_SQRT1_2*pows[j];
if (av_random(&s->random_state) & 1)
aptr[j] *= -1.0;
} else {
v = get_bits(&s->gb, bits[j]);
aptr[j] = dequantization_table[(1<<bits[j])-1+v]*pows[j];
}
}
memset(&aptr[NELLY_FILL_LEN], 0,
(NELLY_BUF_LEN - NELLY_FILL_LEN) * sizeof(float));
s->imdct_ctx.fft.imdct_calc(&s->imdct_ctx, s->imdct_out,
aptr, s->imdct_tmp);
for(j = 0; j < NELLY_BUF_LEN / 2; j++) {
aptr[j] = s->imdct_out[j + NELLY_BUF_LEN + NELLY_BUF_LEN / 2];
aptr[j + NELLY_BUF_LEN / 2] = s->imdct_out[j];
}
overlap_and_window(s, s->state, aptr);
}
}
| 1threat |
static ssize_t block_crypto_write_func(QCryptoBlock *block,
void *opaque,
size_t offset,
const uint8_t *buf,
size_t buflen,
Error **errp)
{
struct BlockCryptoCreateData *data = opaque;
ssize_t ret;
ret = blk_pwrite(data->blk, offset, buf, buflen, 0);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not write encryption header");
return ret;
}
return ret;
}
| 1threat |
Confusion about sanity testing of software : <p>I have read several posts regarding smoke and sanity testing. All are almost confusing. Neither explaining them clearly,just repeating the matter except some two or three posts and based on that two or three posts i concluded that following is the formal process:</p>
<p>Smoke testing(generalized health checkup)---then--> Sanity Testing(checking <strong>some main</strong> functionalities to <strong>somewhat</strong> more deeper level)(Specialized health checkup)----------------then--------> Functional testing(full functionality checking at deeper levels)</p>
<p>Am i right in above concept?</p>
<p>I have confusion regarding when sanity is performed. Smoke is performed when build comes very first time. But when sanity is performed? Is sanity is performed <strong>only after</strong> every smoke OR it is performed <strong>every time build undergoes some change</strong>(i.e. even when smoke is not performed because smoke is performed only first time build comes) OR in both cases?</p>
| 0debug |
Difference between Swagger & HATEOAS : <p>Can anyone explain difference between Swagger & HATEOAS. I can Search many time but no buddy can explain the proper detailed answer this two aspects. </p>
| 0debug |
What's the differences between tf.GraphKeys.TRAINABLE_VARIABLES and tf.GraphKeys.UPDATE_OPS in tensorflow? : <p>Here is <a href="https://www.tensorflow.org/api_docs/python/tf/GraphKeys" rel="noreferrer">doc</a> of tf.GraphKeys in tensorflow, such as <code>TRAINABLE_VARIABLES</code>: the subset of Variable objects that will be trained by an optimizer. </p>
<p>And i know <code>tf.get_collection()</code>, which can find some tensor that you want.</p>
<p>When use <code>tensorflow.contrib.layers.batch_norm()</code>, the parameter <code>updates_collections</code> default value is <code>GraphKeys.UPDATE_OPS</code>. </p>
<p>How can we understand those collections, and difference in them.</p>
<p>Besides, we can find more in ops.py.</p>
| 0debug |
Controlling Sankey diagram connections : <p>I'm trying to control which flows connect to each other using the Matplotlib Sankey diagram. I'm modifying the basic two systems example.</p>
<p>I think my confusion comes down to misunderstanding what this actually means:</p>
<blockquote>
<p>Notice that only one connection is specified, but the systems form a circuit since: (1) the lengths of the paths are justified and (2) the orientation and ordering of the flows is mirrored.</p>
</blockquote>
<p>I've made a toy example that uses a single data set and then modifies it for the second systems to make sure that the numbers all match up.</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
from matplotlib.sankey import Sankey
plt.rcParams["figure.figsize"] = (15,10)
system_1 = [
{"label": "1st", "value": 2.00, "orientation": 0},
{"label": "2nd", "value": 0.15, "orientation": -1},
{"label": "3rd", "value": 0.60, "orientation": -1},
{"label": "4th", "value": -0.10, "orientation": -1},
{"label": "5th", "value": 0.25, "orientation": -1},
{"label": "6th", "value": 0.25, "orientation": -1},
{"label": "7th", "value": 0.25, "orientation": -1},
{"label": "8th", "value": 0.25, "orientation": -1},
{"label": "9th", "value": 0.25, "orientation": -1}
]
system_2 = system_1[:4]
system_2.append({"label": "new", "value": -0.25, "orientation": 1})
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, xticks=[], yticks=[], title="Where are all my cows?")
flows = [x["value"] for x in system_1]
labels = [x["label"] for x in system_1]
orientations=[x["orientation"] for x in system_1]
sankey = Sankey(ax=ax, unit="cow")
sankey.add(flows=flows,
labels=labels,
label='one',
orientations=orientations)
sankey.add(flows=[-x["value"] for x in system_2],
labels=[x["label"] for x in system_2],
label='two',
orientations=[-x["orientation"] for x in system_2],
prior=0,
connect= (0,0)
)
diagrams = sankey.finish()
diagrams[-1].patch.set_hatch('/')
plt.legend(loc='best')
plt.show()
</code></pre>
<p>This gives me:</p>
<p><a href="https://i.stack.imgur.com/3MYVq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3MYVq.png" alt="A sankey diagram that doesn't really work"></a></p>
<p>It <em>should</em> join up the flows with matching labels.</p>
<p>I've read <a href="https://stackoverflow.com/questions/20425103/connecting-two-sankey-diagrams-in-matplotlib">this</a> and <a href="https://stackoverflow.com/questions/26677690/connecting-flows-in-matplotlib-sankey-diagram">this</a> but they aren't helping me understand what is actually happening.</p>
| 0debug |
static void qemu_run_timers(QEMUClock *clock)
{
QEMUTimer **ptimer_head, *ts;
int64_t current_time;
if (!clock->enabled)
return;
current_time = qemu_get_clock (clock);
ptimer_head = &active_timers[clock->type];
for(;;) {
ts = *ptimer_head;
if (!ts || ts->expire_time > current_time)
break;
*ptimer_head = ts->next;
ts->next = NULL;
ts->cb(ts->opaque);
}
}
| 1threat |
query = 'SELECT * FROM customers WHERE email = ' + email_input | 1threat |
Image wont load. ive used the jpg and i havent made any typos : I've been trying to load an image from my hard drive, but it wont show. i honestly dont know what im doing as im new to code.
just learning to code
<img src="SPQR.img.jpg" alt="SPQR"> | 0debug |
static int push_samples(AVFilterContext *ctx, int nb_samples)
{
AVFilterLink *outlink = ctx->outputs[0];
LoopContext *s = ctx->priv;
AVFrame *out;
int ret, i = 0;
while (s->loop != 0 && i < nb_samples) {
out = ff_get_audio_buffer(outlink, FFMIN(nb_samples, s->nb_samples - s->current_sample));
if (!out)
return AVERROR(ENOMEM);
ret = av_audio_fifo_peek_at(s->fifo, (void **)out->extended_data, out->nb_samples, s->current_sample);
if (ret < 0)
return ret;
out->pts = s->pts;
out->nb_samples = ret;
s->pts += out->nb_samples;
i += out->nb_samples;
s->current_sample += out->nb_samples;
ret = ff_filter_frame(outlink, out);
if (ret < 0)
return ret;
if (s->current_sample >= s->nb_samples) {
s->current_sample = 0;
if (s->loop > 0)
s->loop--;
}
}
return ret;
}
| 1threat |
Not receving the complete data from arduino via bluetooth in android : #include <SoftwareSerial.h>
int bluetoothTx = 11;
int bluetoothRx = 12;
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
void setup()
{
//Setup usb serial connection to computer
Serial.begin(9600);
bluetooth.begin(9600);
}
void loop()
{
//Read from bluetooth and write to usb serial
if(bluetooth.available())
{
char tosend = (char)bluetooth.read();
Serial.print(tosend);
if ( tosend == '1' )
{
Serial.println("Hello");
bluetooth.println("Hellllo");
}
}
}
this is my ardiuno code ...
in android side i have use this function
public void run() {
byte[] buffer = new byte[1024]; // buffer store for the stream
int bytes = 0; // bytes returned from read()
// Keep listening to the InputStream until an exception occurs
while (true) {
try {
// Read from the InputStream
bytes = mInStream.read(buffer);
// Send the obtained bytes to the UI activity
mHandler.obtainMessage(Constants.MESSAGE_READ, bytes, -1, buffer)
.sendToTarget();
} catch (IOException e) {
Log.i(TAG, e.toString());
break;
}
}
}
Second thing is that even i have not wirtten delay
still my output in android side is splited in thread.
So please help
| 0debug |
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
void *logctx, int is_nalff, int nal_length_size,
enum AVCodecID codec_id)
{
int consumed, ret = 0;
const uint8_t *next_avc = buf + (is_nalff ? 0 : length);
pkt->nb_nals = 0;
while (length >= 4) {
H2645NAL *nal;
int extract_length = 0;
int skip_trailing_zeros = 1;
if (buf == next_avc) {
int i;
for (i = 0; i < nal_length_size; i++)
extract_length = (extract_length << 8) | buf[i];
if (extract_length > length) {
av_log(logctx, AV_LOG_ERROR,
"Invalid NAL unit size (%d > %d).\n",
extract_length, length);
return AVERROR_INVALIDDATA;
}
buf += nal_length_size;
length -= nal_length_size;
next_avc = buf + extract_length;
} else {
int buf_index = find_next_start_code(buf, next_avc);
buf += buf_index;
length -= buf_index;
if (buf == next_avc)
continue;
if (length > 0) {
extract_length = length;
} else if (pkt->nb_nals == 0) {
av_log(logctx, AV_LOG_ERROR, "No NAL unit found\n");
return AVERROR_INVALIDDATA;
} else {
break;
}
}
if (pkt->nals_allocated < pkt->nb_nals + 1) {
int new_size = pkt->nals_allocated + 1;
H2645NAL *tmp = av_realloc_array(pkt->nals, new_size, sizeof(*tmp));
if (!tmp)
return AVERROR(ENOMEM);
pkt->nals = tmp;
memset(pkt->nals + pkt->nals_allocated, 0,
(new_size - pkt->nals_allocated) * sizeof(*tmp));
pkt->nals_allocated = new_size;
}
nal = &pkt->nals[pkt->nb_nals++];
consumed = ff_h2645_extract_rbsp(buf, extract_length, nal);
if (consumed < 0)
return consumed;
if (consumed < length - 3 &&
buf[consumed] == 0x00 && buf[consumed + 1] == 0x00 &&
buf[consumed + 2] == 0x01 && buf[consumed + 3] == 0xE0)
skip_trailing_zeros = 0;
nal->size_bits = get_bit_length(nal, skip_trailing_zeros);
ret = init_get_bits(&nal->gb, nal->data, nal->size_bits);
if (ret < 0)
return ret;
if (codec_id == AV_CODEC_ID_HEVC)
ret = hevc_parse_nal_header(nal, logctx);
else
ret = h264_parse_nal_header(nal, logctx);
if (ret <= 0) {
if (ret < 0) {
av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit %d, skipping.\n",
nal->type);
}
pkt->nb_nals--;
}
buf += consumed;
length -= consumed;
}
return 0;
}
| 1threat |
static void mdct512(AC3MDCTContext *mdct, float *out, float *in)
{
mdct->fft.mdct_calc(&mdct->fft, out, in);
}
| 1threat |
Which one is better option to remove a file from linux system : <p>I want to remove a file present in /tmp, say san.txt</p>
<p>I have two approach, Which one is better and why ?</p>
<p>approach one:</p>
<pre><code>int main(){
int status;
pid_t pid = fork();
if(-1 == pid){
printf("fork() failed");
exit(EXIT_FAILURE);
}else if(pid == 0){
execl("/bin/sh", "sh", "-c", "rm /tmp/san.txt", (char *) NULL);
}else{
printf("[%d]fork with id %d\n",pid);
waitpid(pid,&status,0);
}
return 0;
}
</code></pre>
<p>Approach 2: </p>
<pre><code>int main(){
int ret = unlink("/tmp/san.txt");
if ( 0 == ret){
printf("file removed \n");
}
return 0;
}
</code></pre>
| 0debug |
Gentle animation on website : <p>My client wants something similar to the action that occurs the first time you load the page <a href="http://www.denisechandler.com/" rel="nofollow noreferrer">http://www.denisechandler.com/</a> (the creation of those corals and the gentle drops once it finishes).
I was thinking of doing it with Canvas, but I wanted to ask if you have any ideas how this could have been done?
Maybe there is a better alternative to making it, because you know, canvas is canvas :duh:</p>
| 0debug |
static void init_proc_970MP (CPUPPCState *env)
{
gen_spr_ne_601(env);
gen_spr_7xx(env);
gen_tbl(env);
spr_register(env, SPR_HID0, "HID0",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_clear,
0x60000000);
spr_register(env, SPR_HID1, "HID1",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_970_HID5, "HID5",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
POWERPC970_HID5_INIT);
gen_low_BATs(env);
spr_register(env, SPR_HIOR, "SPR_HIOR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_hior, &spr_write_hior,
0x00000000);
spr_register_kvm(env, SPR_LPCR, "LPCR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
KVM_REG_PPC_LPCR, 0x00000000);
#if !defined(CONFIG_USER_ONLY)
env->slb_nr = 32;
#endif
init_excp_970(env);
env->dcache_line_size = 128;
env->icache_line_size = 128;
ppc970_irq_init(env);
vscr_init(env, 0x00010000);
}
| 1threat |
how to map an IP to a domain name? : I have a website hosted on AWS EC2, it has an IP which is public, I can access the website anywhere from the public IP.
and I have rented a domain name and the provider gave me a console.
I am expecting this console has a field for me to enter public IP. Then it will resolve the connection between the domain name and public IP.
But the console only provide a link called "Modify DNS", and it expects me to provide NS (at least 2). I don't know what to input at all.
In this case, how can I find 2 NS? or there should be another way to do so? | 0debug |
SQL Update error. Instead of updating, its adding. : //for some reason it won't update, instead it will add the new data.
I am a beginner, and I have hard time trying to find out the error.
Thank you for the help.
//Read function was working very properly and insert works just fine as well. Its just the update that doesnt work properly, or inserts instead of updating the query or data.
<?php include "db.php"; ?>
<?php include "functions.php" ?>
<?php
if(isset($_POST['submit']))
{$username = $_POST['username'];
$password = $_POST['password'];
$id = $_POST['id'];
$querys = "UPDATE users SET ";
$querys .= "username = '$username', ";
$querys .= "password = '$password' ";
$querys .= "WHERE id = $id ";
$result = mysqli_query($connection, $querys);
if(!$result)
{
die('Query FAILED'. mysqli_error($connection));
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css
">
</head>
<body>
<div class="container">
<div class="col-xs-6">
<form action="login_create.php" method="post">
<div class="form-group">
<label for="username">Username</label>
<input type="text" name="username" class="form-control">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="password" class="form-control">
</div>
<div class="form-group">
<select name="id" id="">
<?php
showAllData();
?>
</select>
</div>
<input class="btn btn-primary"
type="submit" name="submit" value="Update">
</form>
</div>
</div>
</body>
</html> | 0debug |
void event_notifier_cleanup(EventNotifier *e)
{
CloseHandle(e->event);
} | 1threat |
static void ref405ep_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
char *filename;
ppc4xx_bd_info_t bd;
CPUPPCState *env;
qemu_irq *pic;
MemoryRegion *bios;
MemoryRegion *sram = g_new(MemoryRegion, 1);
ram_addr_t bdloc;
MemoryRegion *ram_memories = g_malloc(2 * sizeof(*ram_memories));
hwaddr ram_bases[2], ram_sizes[2];
target_ulong sram_size;
long bios_size;
target_ulong kernel_base, initrd_base;
long kernel_size, initrd_size;
int linux_boot;
int fl_idx, fl_sectors, len;
DriveInfo *dinfo;
MemoryRegion *sysmem = get_system_memory();
memory_region_allocate_system_memory(&ram_memories[0], NULL, "ef405ep.ram",
0x08000000);
ram_bases[0] = 0;
ram_sizes[0] = 0x08000000;
memory_region_init(&ram_memories[1], NULL, "ef405ep.ram1", 0);
ram_bases[1] = 0x00000000;
ram_sizes[1] = 0x00000000;
ram_size = 128 * 1024 * 1024;
#ifdef DEBUG_BOARD_INIT
printf("%s: register cpu\n", __func__);
#endif
env = ppc405ep_init(sysmem, ram_memories, ram_bases, ram_sizes,
33333333, &pic, kernel_filename == NULL ? 0 : 1);
sram_size = 512 * 1024;
memory_region_init_ram(sram, NULL, "ef405ep.sram", sram_size, &error_abort);
vmstate_register_ram_global(sram);
memory_region_add_subregion(sysmem, 0xFFF00000, sram);
#ifdef DEBUG_BOARD_INIT
printf("%s: register BIOS\n", __func__);
#endif
fl_idx = 0;
#ifdef USE_FLASH_BIOS
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
if (dinfo) {
BlockDriverState *bs = blk_bs(blk_by_legacy_dinfo(dinfo));
bios_size = bdrv_getlength(bs);
fl_sectors = (bios_size + 65535) >> 16;
#ifdef DEBUG_BOARD_INIT
printf("Register parallel flash %d size %lx"
" at addr %lx '%s' %d\n",
fl_idx, bios_size, -bios_size,
bdrv_get_device_name(bs), fl_sectors);
#endif
pflash_cfi02_register((uint32_t)(-bios_size),
NULL, "ef405ep.bios", bios_size,
bs, 65536, fl_sectors, 1,
2, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
1);
fl_idx++;
} else
#endif
{
#ifdef DEBUG_BOARD_INIT
printf("Load BIOS from file\n");
#endif
bios = g_new(MemoryRegion, 1);
memory_region_init_ram(bios, NULL, "ef405ep.bios", BIOS_SIZE,
&error_abort);
vmstate_register_ram_global(bios);
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image(filename, memory_region_get_ram_ptr(bios));
g_free(filename);
if (bios_size < 0 || bios_size > BIOS_SIZE) {
error_report("Could not load PowerPC BIOS '%s'", bios_name);
exit(1);
}
bios_size = (bios_size + 0xfff) & ~0xfff;
memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios);
} else if (!qtest_enabled() || kernel_filename != NULL) {
error_report("Could not load PowerPC BIOS '%s'", bios_name);
exit(1);
} else {
bios_size = -1;
}
memory_region_set_readonly(bios, true);
}
#ifdef DEBUG_BOARD_INIT
printf("%s: register FPGA\n", __func__);
#endif
ref405ep_fpga_init(sysmem, 0xF0300000);
#ifdef DEBUG_BOARD_INIT
printf("%s: register NVRAM\n", __func__);
#endif
m48t59_init(NULL, 0xF0000000, 0, 8192, 8);
linux_boot = (kernel_filename != NULL);
if (linux_boot) {
#ifdef DEBUG_BOARD_INIT
printf("%s: load kernel\n", __func__);
#endif
memset(&bd, 0, sizeof(bd));
bd.bi_memstart = 0x00000000;
bd.bi_memsize = ram_size;
bd.bi_flashstart = -bios_size;
bd.bi_flashsize = -bios_size;
bd.bi_flashoffset = 0;
bd.bi_sramstart = 0xFFF00000;
bd.bi_sramsize = sram_size;
bd.bi_bootflags = 0;
bd.bi_intfreq = 133333333;
bd.bi_busfreq = 33333333;
bd.bi_baudrate = 115200;
bd.bi_s_version[0] = 'Q';
bd.bi_s_version[1] = 'M';
bd.bi_s_version[2] = 'U';
bd.bi_s_version[3] = '\0';
bd.bi_r_version[0] = 'Q';
bd.bi_r_version[1] = 'E';
bd.bi_r_version[2] = 'M';
bd.bi_r_version[3] = 'U';
bd.bi_r_version[4] = '\0';
bd.bi_procfreq = 133333333;
bd.bi_plb_busfreq = 33333333;
bd.bi_pci_busfreq = 33333333;
bd.bi_opbfreq = 33333333;
bdloc = ppc405_set_bootinfo(env, &bd, 0x00000001);
env->gpr[3] = bdloc;
kernel_base = KERNEL_LOAD_ADDR;
kernel_size = load_image_targphys(kernel_filename, kernel_base,
ram_size - kernel_base);
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
printf("Load kernel size %ld at " TARGET_FMT_lx,
kernel_size, kernel_base);
if (initrd_filename) {
initrd_base = INITRD_LOAD_ADDR;
initrd_size = load_image_targphys(initrd_filename, initrd_base,
ram_size - initrd_base);
if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
initrd_filename);
exit(1);
}
} else {
initrd_base = 0;
initrd_size = 0;
}
env->gpr[4] = initrd_base;
env->gpr[5] = initrd_size;
if (kernel_cmdline != NULL) {
len = strlen(kernel_cmdline);
bdloc -= ((len + 255) & ~255);
cpu_physical_memory_write(bdloc, kernel_cmdline, len + 1);
env->gpr[6] = bdloc;
env->gpr[7] = bdloc + len;
} else {
env->gpr[6] = 0;
env->gpr[7] = 0;
}
env->nip = KERNEL_LOAD_ADDR;
} else {
kernel_base = 0;
kernel_size = 0;
initrd_base = 0;
initrd_size = 0;
bdloc = 0;
}
#ifdef DEBUG_BOARD_INIT
printf("bdloc " RAM_ADDR_FMT "\n", bdloc);
printf("%s: Done\n", __func__);
#endif
}
| 1threat |
static void v9fs_clunk(void *opaque)
{
int err;
int32_t fid;
size_t offset = 7;
V9fsFidState *fidp;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
pdu_unmarshal(pdu, offset, "d", &fid);
trace_v9fs_clunk(pdu->tag, pdu->id, fid);
fidp = clunk_fid(s, fid);
if (fidp == NULL) {
err = -ENOENT;
goto out_nofid;
}
fidp->ref++;
err = offset;
put_fid(pdu, fidp);
out_nofid:
complete_pdu(s, pdu, err);
}
| 1threat |
static av_cold int libx265_encode_init(AVCodecContext *avctx)
{
libx265Context *ctx = avctx->priv_data;
ctx->api = x265_api_get(av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth);
if (!ctx->api)
ctx->api = x265_api_get(0);
ctx->params = ctx->api->param_alloc();
if (!ctx->params) {
av_log(avctx, AV_LOG_ERROR, "Could not allocate x265 param structure.\n");
return AVERROR(ENOMEM);
if (ctx->api->param_default_preset(ctx->params, ctx->preset, ctx->tune) < 0) {
int i;
av_log(avctx, AV_LOG_ERROR, "Error setting preset/tune %s/%s.\n", ctx->preset, ctx->tune);
av_log(avctx, AV_LOG_INFO, "Possible presets:");
for (i = 0; x265_preset_names[i]; i++)
av_log(avctx, AV_LOG_INFO, " %s", x265_preset_names[i]);
av_log(avctx, AV_LOG_INFO, "\n");
av_log(avctx, AV_LOG_INFO, "Possible tunes:");
for (i = 0; x265_tune_names[i]; i++)
av_log(avctx, AV_LOG_INFO, " %s", x265_tune_names[i]);
av_log(avctx, AV_LOG_INFO, "\n");
return AVERROR(EINVAL);
ctx->params->frameNumThreads = avctx->thread_count;
ctx->params->fpsNum = avctx->time_base.den;
ctx->params->fpsDenom = avctx->time_base.num * avctx->ticks_per_frame;
ctx->params->sourceWidth = avctx->width;
ctx->params->sourceHeight = avctx->height;
ctx->params->bEnablePsnr = !!(avctx->flags & AV_CODEC_FLAG_PSNR);
if ((avctx->color_primaries <= AVCOL_PRI_BT2020 &&
avctx->color_primaries != AVCOL_PRI_UNSPECIFIED) ||
(avctx->color_trc <= AVCOL_TRC_BT2020_12 &&
avctx->color_trc != AVCOL_TRC_UNSPECIFIED) ||
(avctx->colorspace <= AVCOL_SPC_BT2020_CL &&
avctx->colorspace != AVCOL_SPC_UNSPECIFIED)) {
ctx->params->vui.bEnableVideoSignalTypePresentFlag = 1;
ctx->params->vui.bEnableColorDescriptionPresentFlag = 1;
ctx->params->vui.colorPrimaries = avctx->color_primaries;
ctx->params->vui.transferCharacteristics = avctx->color_trc;
ctx->params->vui.matrixCoeffs = avctx->colorspace;
if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 0) {
char sar[12];
int sar_num, sar_den;
av_reduce(&sar_num, &sar_den,
avctx->sample_aspect_ratio.num,
avctx->sample_aspect_ratio.den, 65535);
snprintf(sar, sizeof(sar), "%d:%d", sar_num, sar_den);
if (ctx->api->param_parse(ctx->params, "sar", sar) == X265_PARAM_BAD_VALUE) {
av_log(avctx, AV_LOG_ERROR, "Invalid SAR: %d:%d.\n", sar_num, sar_den);
switch (avctx->pix_fmt) {
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUV420P10:
case AV_PIX_FMT_YUV420P12:
ctx->params->internalCsp = X265_CSP_I420;
case AV_PIX_FMT_YUV422P:
case AV_PIX_FMT_YUV422P10:
case AV_PIX_FMT_YUV422P12:
ctx->params->internalCsp = X265_CSP_I422;
case AV_PIX_FMT_GBRP:
case AV_PIX_FMT_GBRP10:
case AV_PIX_FMT_GBRP12:
ctx->params->vui.matrixCoeffs = AVCOL_SPC_RGB;
ctx->params->vui.bEnableVideoSignalTypePresentFlag = 1;
ctx->params->vui.bEnableColorDescriptionPresentFlag = 1;
case AV_PIX_FMT_YUV444P:
case AV_PIX_FMT_YUV444P10:
case AV_PIX_FMT_YUV444P12:
ctx->params->internalCsp = X265_CSP_I444;
if (ctx->crf >= 0) {
char crf[6];
snprintf(crf, sizeof(crf), "%2.2f", ctx->crf);
if (ctx->api->param_parse(ctx->params, "crf", crf) == X265_PARAM_BAD_VALUE) {
av_log(avctx, AV_LOG_ERROR, "Invalid crf: %2.2f.\n", ctx->crf);
return AVERROR(EINVAL);
} else if (avctx->bit_rate > 0) {
ctx->params->rc.bitrate = avctx->bit_rate / 1000;
ctx->params->rc.rateControlMode = X265_RC_ABR;
if (!(avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER))
ctx->params->bRepeatHeaders = 1;
if (ctx->x265_opts) {
AVDictionary *dict = NULL;
AVDictionaryEntry *en = NULL;
if (!av_dict_parse_string(&dict, ctx->x265_opts, "=", ":", 0)) {
while ((en = av_dict_get(dict, "", en, AV_DICT_IGNORE_SUFFIX))) {
int parse_ret = ctx->api->param_parse(ctx->params, en->key, en->value);
switch (parse_ret) {
case X265_PARAM_BAD_NAME:
av_log(avctx, AV_LOG_WARNING,
"Unknown option: %s.\n", en->key);
case X265_PARAM_BAD_VALUE:
av_log(avctx, AV_LOG_WARNING,
"Invalid value for %s: %s.\n", en->key, en->value);
default:
av_dict_free(&dict);
ctx->encoder = ctx->api->encoder_open(ctx->params);
if (!ctx->encoder) {
av_log(avctx, AV_LOG_ERROR, "Cannot open libx265 encoder.\n");
libx265_encode_close(avctx);
if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
x265_nal *nal;
int nnal;
avctx->extradata_size = ctx->api->encoder_headers(ctx->encoder, &nal, &nnal);
if (avctx->extradata_size <= 0) {
av_log(avctx, AV_LOG_ERROR, "Cannot encode headers.\n");
libx265_encode_close(avctx);
avctx->extradata = av_malloc(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!avctx->extradata) {
"Cannot allocate HEVC header of size %d.\n", avctx->extradata_size);
libx265_encode_close(avctx);
return AVERROR(ENOMEM);
memcpy(avctx->extradata, nal[0].payload, avctx->extradata_size);
return 0;
| 1threat |
How to convert ed25519 private key to putty ppk? : <p>I want to convert an ed25519 private key (which is generated by <code>ssh-keygen</code> command) to a ppk file. But I got the error.</p>
<blockquote>
<p>Couldn't load private key (unrecognized cipher name)</p>
</blockquote>
<p>Can someone help me?</p>
<ul>
<li><p>tested openssh version: <code>OpenSSH_7.6p1, OpenSSL 1.1.0g 2 Nov 2017</code> and <code>OpenSSH_7.6p1, OpenSSL 1.0.2n 7 Dec 2017</code> (on CoreOS and ArchLinux docker container)</p></li>
<li><p>tested putty version: <code>0.70 64bit</code>, <code>0.70 32bit</code> and <code>snapshot</code> (on windows 10)</p></li>
</ul>
<p>My procedure is as follows.</p>
<h1>1. Generate an ed25519 private key</h1>
<pre><code># ssh-keygen -t ed25519 -a 100
Generating public/private ed25519 key pair.
Enter file in which to save the key (/root/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_ed25519.
Your public key has been saved in /root/.ssh/id_ed25519.pub.
The key fingerprint is:
SHA256:2HfORujStwmC9c91rmDxMbaV9kVMT70gWxnRXAvNrNU root@f46f23bbad55
The key's randomart image is:
+--[ED25519 256]--+
| +X B|
| . +.@E|
| + +.=|
| o o . o.|
| . S o + +oo|
| o = = +.=o|
| . o = B + o|
| o B = o |
| = ...|
+----[SHA256]-----+
# cat .ssh/id_ed25519
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABClhk1367
G8CQYpo/0c7UShAAAAZAAAAAEAAAAzAAAAC3NzaC1lZDI1NTE5AAAAIIJiwIymcly4s66p
za/IL3ZNyT5CiMPj0R+/LnMDmABUAAAAoMJIakdbIL7TOAmX8n4xGSrtp8mc/Mr6qimZAZ
zGB7iRhNUXT+isPdf0YuC9mh5NbX43ZYFl+/sWdi2hVmJxbGTwrjaSdNzF3ZnSpi/aVlzF
t3bUCtdwhHLaLqy9unw0zPHlfcQsB700GS/bf4VKRmm1+imj3cAldUm2RF3VdI0U9/04yX
Mj+VBOmevM0i7R/0d6xUFTH3zj99xxeLI2J6A=
-----END OPENSSH PRIVATE KEY-----
# cat .ssh/id_ed25519.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIJiwIymcly4s66pza/IL3ZNyT5CiMPj0R+/LnMDmABU root@f46f23bbad55
</code></pre>
<h1>2. Run <code>puttygen.exe</code> on windows and try to import the ed25519 private key (<code>.ssh/id_ed25519</code>)</h1>
<blockquote>
<p>Couldn't load private key (unrecognized cipher name)</p>
</blockquote>
| 0debug |
how to get value that often appear? : int[] nilai = {12,10,8,6,12,12,34,10,8,6,9,9,34,12,6,8,10,34,12,10,9,12};
int[] frekuensi = new int[23];
for (int i=0; i<nilai.length; i++) {
frekuensi[i] = 0;
}
for (int i=0; i<nilai.length; i++) {
frekuensi[nilai[i]]++;
}
int modus = 0;
for (int i=0; i<nilai.length; i++) {
if (frekuensi[i] > modus) {
modus = i;
}
}
System.out.println("Nilai Modusnya = " + modus); | 0debug |
static void gpollfds_to_select(int ret)
{
int i;
FD_ZERO(&rfds);
FD_ZERO(&wfds);
FD_ZERO(&xfds);
if (ret <= 0) {
return;
}
for (i = 0; i < gpollfds->len; i++) {
int fd = g_array_index(gpollfds, GPollFD, i).fd;
int revents = g_array_index(gpollfds, GPollFD, i).revents;
if (revents & (G_IO_IN | G_IO_HUP | G_IO_ERR)) {
FD_SET(fd, &rfds);
}
if (revents & (G_IO_OUT | G_IO_ERR)) {
FD_SET(fd, &wfds);
}
if (revents & G_IO_PRI) {
FD_SET(fd, &xfds);
}
}
}
| 1threat |
Catch error if retryWhen:s retries runs out : <p>In the <a href="http://reactivex.io/documentation/operators/retry.html" rel="noreferrer">documentation for RetryWhen</a> the example there goes like this: </p>
<pre><code>Observable.create((Subscriber<? super String> s) -> {
System.out.println("subscribing");
s.onError(new RuntimeException("always fails"));
}).retryWhen(attempts -> {
return attempts.zipWith(Observable.range(1, 3), (n, i) -> i).flatMap(i -> {
System.out.println("delay retry by " + i + " second(s)");
return Observable.timer(i, TimeUnit.SECONDS);
});
}).toBlocking().forEach(System.out::println);
</code></pre>
<p>But how do I propagate the Error if the retries runs out?</p>
<p>Adding <code>.doOnError(System.out::println)</code> <em>after</em> the <code>retryWhen</code> clause does not catch the error. Is it even emitted? </p>
<p>Adding a <code>.doOnError(System.out::println)</code> <em>before</em> retryWhen displays <code>always fails</code> for all retries. </p>
| 0debug |
static int raw_co_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
{
BDRVRawState *s = bs->opaque;
if (s->offset || s->has_size) {
return -ENOTSUP;
}
return bdrv_co_ioctl(bs->file->bs, req, buf);
}
| 1threat |
void ff_aac_search_for_pred(AACEncContext *s, SingleChannelElement *sce)
{
int sfb, i, count = 0, cost_coeffs = 0, cost_pred = 0;
const int pmax = FFMIN(sce->ics.max_sfb, ff_aac_pred_sfb_max[s->samplerate_index]);
float *O34 = &s->scoefs[128*0], *P34 = &s->scoefs[128*1];
float *SENT = &s->scoefs[128*2], *S34 = &s->scoefs[128*3];
float *QERR = &s->scoefs[128*4];
if (sce->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
sce->ics.predictor_present = 0;
return;
}
if (!sce->ics.predictor_initialized) {
reset_all_predictors(sce->predictor_state);
sce->ics.predictor_initialized = 1;
memcpy(sce->prcoeffs, sce->coeffs, 1024*sizeof(float));
for (i = 1; i < 31; i++)
sce->ics.predictor_reset_count[i] = i;
}
update_pred_resets(sce);
memcpy(sce->band_alt, sce->band_type, sizeof(sce->band_type));
for (sfb = PRED_SFB_START; sfb < pmax; sfb++) {
int cost1, cost2, cb_p;
float dist1, dist2, dist_spec_err = 0.0f;
const int cb_n = sce->band_type[sfb];
const int start_coef = sce->ics.swb_offset[sfb];
const int num_coeffs = sce->ics.swb_offset[sfb + 1] - start_coef;
const FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[sfb];
if (start_coef + num_coeffs > MAX_PREDICTORS ||
(s->cur_channel && sce->band_type[sfb] >= INTENSITY_BT2) ||
sce->band_type[sfb] == NOISE_BT)
continue;
abs_pow34_v(O34, &sce->coeffs[start_coef], num_coeffs);
dist1 = quantize_and_encode_band_cost(s, NULL, &sce->coeffs[start_coef], NULL,
O34, num_coeffs, sce->sf_idx[sfb],
cb_n, s->lambda / band->threshold, INFINITY, &cost1, NULL, 0);
cost_coeffs += cost1;
for (i = 0; i < num_coeffs; i++)
SENT[i] = sce->coeffs[start_coef + i] - sce->prcoeffs[start_coef + i];
abs_pow34_v(S34, SENT, num_coeffs);
if (cb_n < RESERVED_BT)
cb_p = find_min_book(find_max_val(1, num_coeffs, S34), sce->sf_idx[sfb]);
else
cb_p = cb_n;
quantize_and_encode_band_cost(s, NULL, SENT, QERR, S34, num_coeffs,
sce->sf_idx[sfb], cb_p, s->lambda / band->threshold, INFINITY,
&cost2, NULL, 0);
for (i = 0; i < num_coeffs; i++)
sce->prcoeffs[start_coef + i] += QERR[i] != 0.0f ? (sce->prcoeffs[start_coef + i] - QERR[i]) : 0.0f;
abs_pow34_v(P34, &sce->prcoeffs[start_coef], num_coeffs);
if (cb_n < RESERVED_BT)
cb_p = find_min_book(find_max_val(1, num_coeffs, P34), sce->sf_idx[sfb]);
else
cb_p = cb_n;
dist2 = quantize_and_encode_band_cost(s, NULL, &sce->prcoeffs[start_coef], NULL,
P34, num_coeffs, sce->sf_idx[sfb],
cb_p, s->lambda / band->threshold, INFINITY, NULL, NULL, 0);
for (i = 0; i < num_coeffs; i++)
dist_spec_err += (O34[i] - P34[i])*(O34[i] - P34[i]);
dist_spec_err *= s->lambda / band->threshold;
dist2 += dist_spec_err;
if (dist2 <= dist1 && cb_p <= cb_n) {
cost_pred += cost2;
sce->ics.prediction_used[sfb] = 1;
sce->band_alt[sfb] = cb_n;
sce->band_type[sfb] = cb_p;
count++;
} else {
cost_pred += cost1;
sce->band_alt[sfb] = cb_p;
}
}
if (count && cost_coeffs < cost_pred) {
count = 0;
for (sfb = PRED_SFB_START; sfb < pmax; sfb++)
RESTORE_PRED(sce, sfb);
memset(&sce->ics.prediction_used, 0, sizeof(sce->ics.prediction_used));
}
sce->ics.predictor_present = !!count;
}
| 1threat |
CI/CD pipeline with PostgreSQL failed with "Database is uninitialized and superuser password is not specified" error : <p>I'm using Bitbucket pipeline with PosgreSQL for CI/CD. According to this <a href="https://confluence.atlassian.com/bitbucket/test-with-databases-in-bitbucket-pipelines-856697462.html" rel="noreferrer">documentation</a> PostgreSQL service has been described in <code>bitbucket-pipelines.yml</code> this way:</p>
<pre><code>definitions:
services:
postgres:
image: postgres:9.6-alpine
</code></pre>
<p>It worked just fine until now. But all my latest pipelines failed with following error:</p>
<pre><code> Error: Database is uninitialized and superuser password is not specified.
You must specify POSTGRES_PASSWORD for the superuser. Use
"-e POSTGRES_PASSWORD=password" to set it in "docker run".
You may also use POSTGRES_HOST_AUTH_METHOD=trust to allow all connections
without a password. This is *not* recommended. See PostgreSQL
documentation about "trust":
https://www.postgresql.org/docs/current/auth-trust.html
</code></pre>
<p>How can I fix it? There was no changes in <code>bitbucket-pipelines.yml</code> file which could be the reason of such error..</p>
| 0debug |
creating the multiple div dynamically using javascript : i have div element and have a class for it,i want to create multiple div using that class,but i dont want to create nested div,i want to create div outside using javascript,i used append property,but its create nested div below is html as i required need help
//have this div
<div class="one"></div>
//need to create multiple div
<div id="one"> </div>
<div id="two"> </div>
<div id="three"> </div>
<div id="four"> </div> | 0debug |
php searching empty fields in the db : <p>I'm constructing a good code to check the database and some more things, but i stopped in the line... it says: </p>
<pre><code>notice: Undefined variable: getUserNew in D:\xampp\htdocs\SilverCommunity(1.6.2)\asp\class\giveaway\winner.php on line 134
</code></pre>
<p>My Started code:</p>
<pre><code> if(isset($_POST['giftID'])) {
//select user from db.
$getUserNew = getUser_ID_($db, $id_us);
if(!empty($getUserNew)) {
//if empty, add new ticket.
newGiveaway($db, $id_us);
$hide = rand_line("../../codes.txt");
echo $hide;
}
else
{
//check dates and return
echo "Next step";
}
}
</code></pre>
<p>Function Code to search the user.</p>
<pre><code> function getUser_ID_($db, $id_us)
{
$id_us = $_SESSION['steamid'];
global $host; $username; $password; $dbname;
$sqlu = "SELECT id_steam FROM public_giveaway WHERE id='$id_us'";
$query = mysqli_query($db, $sqlu);
while($Qrow = mysqli_fetch_array($query))
{
$getUserNew = $Qrow['id_steam'];
}
return $getUserNew;
}
</code></pre>
<p>maybe i'm blind... but i can't find the error.. maybe is an "', or ;"... Really... i don't know...</p>
| 0debug |
Split string in half across 2 divs : <p>Looking to write a code that splits a string in half. For example, if the name entered is "Trishy", 6 letters, first 3 letters go into the the second <code>li</code> of <code><ul class="hardcover_front"></code> and the latter 3 letters go into the first <code>li</code> of <code><ul class="hardcover_back"></code>. </p>
<p>Note that I need this to apply for multiple names of varying character lengths. </p>
<pre><code><div id="book1" class="book">
<ul class="hardcover_front">
<li></li>
<li>Tri</li>
</ul>
<ul class="hardcover_back">
<li>shy</li>
<li></li>
</ul>
<ul class="book_spine">
</ul>
</div>
</code></pre>
| 0debug |
How to get Log table data first using two SQL Table : I need sql query to get Log table data first using two SQL Table, actual why i am using log table because when user will update his file then it will stored in Table_AttachLog but i kind use inner join between two table because that it log table. I know using updateddate column order by desc, we can get but how to use both of table.
Table_AttachLog
RegistrationID uploaded File updateddate
101 myprofile.doc 2018-03-25 00:45:08.500
Table_Registration
RegistrationID Name Email uploaded File submitted
100 Rohan rohan@gmail.com rohanfile.doc 2018-01-12 00:45:08.500
101 mazhar mazhar@gmail.com myprofile.doc 2018-03-13 00:45:08.500
102 raj raj@gmail.com raj.doc 2018-01-16 00:45:08.500
I need query that updateddate of Table_AttachLog should come first order by desc follow below output
RegistrationID Name Email uploaded File submitted
101 mazhar mazhar@gmail.com myprofile.doc 2018-03-13 00:45:08.500
100 Rohan rohan@gmail.com rohanfile.doc 2018-01-12 00:45:08.500
102 raj raj@gmail.com raj.doc 2018-01-16 00:45:08.500
| 0debug |
Grouping dataframe based on similar column values : <pre><code>OFFENSE_ID RULE_ID STATUS
100 1 open
101 2 closed
102 2 open
103 1 open
104 2 closed
105 2 open
</code></pre>
<p>Here's how I want it - </p>
<pre><code>RULE_ID OPEN CLOSED
1 2 0
2 2 2
</code></pre>
<p>Thank you in advance for any help!</p>
| 0debug |
static void create_vorbis_context(venc_context_t * venc, AVCodecContext * avccontext) {
codebook_t * cb;
floor_t * fc;
residue_t * rc;
mapping_t * mc;
int i, book;
venc->channels = avccontext->channels;
venc->sample_rate = avccontext->sample_rate;
venc->blocksize[0] = venc->blocksize[1] = 8;
venc->ncodebooks = 10;
venc->codebooks = av_malloc(sizeof(codebook_t) * venc->ncodebooks);
cb = &venc->codebooks[0];
cb->nentries = 256;
cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);
for (i = 0; i < cb->nentries; i++) cb->entries[i].len = 8;
cb->ndimentions = 0;
cb->min = 0.;
cb->delta = 0.;
cb->seq_p = 0;
cb->lookup = 0;
cb->quantlist = NULL;
ready_codebook(cb);
cb = &venc->codebooks[1];
cb->nentries = 2;
cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);
for (i = 0; i < cb->nentries; i++) cb->entries[i].len = 1;
cb->ndimentions = 200;
cb->min = 0.;
cb->delta = 0.;
cb->seq_p = 0;
cb->lookup = 0;
cb->quantlist = NULL;
ready_codebook(cb);
for (book = 0; book < 8; book++) {
cb = &venc->codebooks[2 + book];
cb->nentries = 5;
cb->entries = av_malloc(sizeof(cb_entry_t) * cb->nentries);
for (i = 0; i < cb->nentries; i++) cb->entries[i].len = i == 2 ? 1 : 3;
cb->ndimentions = 1;
cb->delta = 1 << ((7 - book) * 2);
cb->min = -cb->delta*2;
cb->seq_p = 0;
cb->lookup = 2;
cb->quantlist = av_malloc(sizeof(int) * cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries));
for (i = 0; i < cb->nentries; i++) cb->quantlist[i] = i;
ready_codebook(cb);
}
venc->nfloors = 1;
venc->floors = av_malloc(sizeof(floor_t) * venc->nfloors);
fc = &venc->floors[0];
fc->partitions = 1;
fc->partition_to_class = av_malloc(sizeof(int) * fc->partitions);
for (i = 0; i < fc->partitions; i++) fc->partition_to_class = 0;
fc->nclasses = 1;
fc->classes = av_malloc(sizeof(floor_class_t) * fc->nclasses);
for (i = 0; i < fc->nclasses; i++) {
floor_class_t * c = &fc->classes[i];
int j, books;
c->dim = 1;
c->subclass = 0;
c->masterbook = 0;
books = (1 << c->subclass);
c->books = av_malloc(sizeof(int) * books);
for (j = 0; j < books; j++) c->books[j] = 0;
}
fc->multiplier = 1;
fc->rangebits = venc->blocksize[0];
fc->values = 2;
for (i = 0; i < fc->partitions; i++)
fc->values += fc->classes[fc->partition_to_class[i]].dim;
fc->list = av_malloc(sizeof(*fc->list) * fc->values);
fc->list[0].x = 0;
fc->list[1].x = 1 << fc->rangebits;
for (i = 2; i < fc->values; i++) fc->list[i].x = i * 5;
venc->nresidues = 1;
venc->residues = av_malloc(sizeof(residue_t) * venc->nresidues);
rc = &venc->residues[0];
rc->type = 0;
rc->begin = 0;
rc->end = 1 << venc->blocksize[0];
rc->partition_size = 64;
rc->classifications = 1;
rc->classbook = 1;
rc->books = av_malloc(sizeof(int[8]) * rc->classifications);
for (i = 0; i < 8; i++) rc->books[0][i] = 2 + i;
venc->nmappings = 1;
venc->mappings = av_malloc(sizeof(mapping_t) * venc->nmappings);
mc = &venc->mappings[0];
mc->submaps = 1;
mc->mux = av_malloc(sizeof(int) * venc->channels);
for (i = 0; i < venc->channels; i++) mc->mux[i] = 0;
mc->floor = av_malloc(sizeof(int) * mc->submaps);
mc->residue = av_malloc(sizeof(int) * mc->submaps);
for (i = 0; i < mc->submaps; i++) {
mc->floor[i] = 0;
mc->residue[i] = 0;
}
venc->nmodes = 1;
venc->modes = av_malloc(sizeof(vorbis_mode_t) * venc->nmodes);
venc->modes[0].blockflag = 0;
venc->modes[0].mapping = 0;
}
| 1threat |
Longest substring of repeated characters : <p>I have an assignment for school in which, given an input string of entirely 0's and 1's, I must return the length of the longest substring of repeated 1's. I am not allowed to use I am having trouble fleshing out my idea.
So far I have found the length of the input string and converted the input string to uint8. That way I can use find to find the indices of the ones. My next thought was to do some sort of for loop to store the indices, or maybe the check the length of each subset and only save the longest one? But I'm not sure how to go about this part or if this is even the right way to think about it. Any guidance is appreciated.</p>
| 0debug |
static void test_qemu_strtoull_full_empty(void)
{
const char *str = "";
uint64_t res = 999;
int err;
err = qemu_strtoull(str, NULL, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, 0);
}
| 1threat |
on the click of the image it is not removing-Jquery : selecting the multiple image from the input tag after that i am previewing the selected image but when i click on that image it should delete from the input tag it does not select that picture anymore. but in my case that picture is removing only in preview not in input. And save it into database
here is the code
<?php
include_once 'Functions.php';
$connect=new Connection();
$link=$connect->Connect();
print_r($_FILES['fil']['name']);
?>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
var image=('')
$('input[type="file"]'). change(function(e){
var fileName = e. target. files[0]. name;
alert('The file "' + fileName + '" has been selected.' );
});
$(function() {
var imagesPreview = function(input, placeToInsertImagePreview) {
if (input.files) {
var filesAmount = input.files.length;
for (i = 0; i < filesAmount; i++) {
var reader = new FileReader();
reader.onload = function(event) {
$($.parseHTML('<img class="picture" width="70" name="multipic">')).attr('src', event.target.result).appendTo(placeToInsertImagePreview);
$('.picture').click(function(){
$(this).remove();
});
}
reader.readAsDataURL(input.files[i]);
}
}
};
$('#gallery-photo-add').on('change', function() {
imagesPreview(this,'div.gallery');
});
});
});
</script>
</head>
<body>
<form name="update" enctype='multipart/form-data' method="POST">
<input type="file" name="fil[]" multiple id="gallery-photo-add" class="a1">
<div class="gallery"></div>
<input type="submit" name="btnupdate" value="Update" />
</form>
</body>
</html> | 0debug |
import re
def find_adverb_position(text):
for m in re.finditer(r"\w+ly", text):
return (m.start(), m.end(), m.group(0)) | 0debug |
Why does the compiler parse this as a function pointer and not a recursive call? : <p>In this following code <code>foo()</code> is parsed in two different places and calls two different functions (marked by the <code>********</code>).</p>
<pre><code>#include <cstdio>
typedef int (*func)(void);
int bar()
{
printf("bar\n");
return 4; // guaranteed to be random
}
int foo()
{
printf("foo\n");
static int i = 0;
if(i)
return i;
++i;
i = foo(); // recursive call ********
printf("%d\n", i);
func foo = bar;
i = foo(); // calls bar. Why? ********
printf("%d\n", i);
return i;
}
int main()
{
return foo();
}
</code></pre>
<p>In all the compilers I was able to try (<a href="https://godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAM1QDsCBlZAQwBtMQBGAFlICsupVs1qhkAUgBMAISnTSAZ0ztkBPHUqZa6AMKpWAVwC2tEJNJb0AGTy1MAOWMAjTMTMBOUgAdUCwuto9QxNBHz81Ohs7RyMXN05FZUxVAIYCZmICIONTcyUVCNo0jIIoh2dXD0V0zOyQhIUa0tty2MrOAEpFVANiZA4AcikAZltkQywAanFhnWRG/FQZ7HEABgBBNfWCAE8vTCwqSdsCSYgAKioDWmQOiAA3VDx0DpnZDa2TyacMiFePgDs73Wk1Bky8xBOVAgUkkP2I4gArDpaLDXsNgWDJsRMARerRJtw3pMAPQkybAAwZEQETAHSZEb6YbEidCoIxbcQAgAinI2XxoqD%2BnKBWyxEKhMMkkkFSJRaLeYrBjWYamQx3ox2mw25k1Wio2WLw0Lw/xBWLBOLxxAJeAN5tBcjkdoxStBeG1usFwoxpPJOOQvT892ZLFYrDd4Mh9GhsKkiPQctR0tIx3RmLBVxuk0Fnu%2BGXtRrz3vTfsmYdYCnzCMNYIlMalknjieRyfMacLltx%2BOO9q5vI%2B/M1RmYtmFgIzoKtPZLfZ5Ay6rBAA0RA1IpgGqzXqGXOidMkmCh6fWZI04a4Iy63HS6AGszIihMvuGuN1vSDuBmuFCBVqRL5uC6kHAsBIGgRheHg7BkBQEDgZB0EgMA7jmFQUG0sQP4QE4V5rk4tgZDsy7nqQ4FGFoBAAPK0KwRGAaQWAjqI7C4QxeABmoIY/vRmAAB7JAYtLEWuJzKKxrB4E4xCEXoWDCf%2BkJGMJXQ0PQTBsBwPD8IIwiiCg%2B7yBJTg/pAXSoF4hTcQAtAA6mwrCTFZ%2BzoDSeDIN%2BSQpBoECWHUpgJJYZQxHEoS%2BP4dB%2BaF4QBEFFTxIkBSpE0kUNJ5hTFJksVtPFKq1PoOSCLlzTRHFXBdEevT9GVT4rq%2BrGfrxAAcABsVnNdwFLIOq7gAHSSGcuCECQ0ySMMCSTHoEFQa4I1jR0E0GReuE3qQ96SI%2BS4DC%2B671cu36/v%2By3ATAiAgHxAlEDBlAZMACgAAoiMoDAIKgADuG4kfBUGqgED12Kwz1vW%2Ba5fYhyHmKDriUYJgPvax53IOsxC3XtFj8cgaT4Bua6qYwYaabwAgJLpYgGUIkkmX8H4WQE3HfseVUNAQWN/U9L1wwM56Lsuq47fRDUtW1HXAF1ky9f12Do4Jw0QINl2zZ0C0yHIS2ASta0bc%2BdX86jP5/gB17HfAEBgeyCGuOQlCQ244wiMAAD6BDENct6kGhrAYVhOH0fhtCEfJZEUdRtGsYxdssfR%2BAcXgXHw1LQmcyJ9BifRRnScQOyyYMJFO3gSmJypdB4xpXCE2YQh2/pysyOTxnwGZNN0NZdnho5zmue5CXJIUmjaClFjaFlIUJGE4WBPl9TeGFhRD%2B0XdeUUyUT/58/pU0s85UvwQr0VG/VRVJ7VZtvPAx%2By5Na17XliTZxOy782y/g8tnqmk3m8Qs2SPNe7V9IqvXneB8NVtqn0/PtfWy1uYDEkNrd8YDDpqy6CGTCAQQDcCAA%3D%3D%3D" rel="nofollow noreferrer">gcc, clang</a>, MSVC, and a couple others), the output is:</p>
<blockquote>
<p>foo<br>
foo<br>
1<br>
bar<br>
4 </p>
</blockquote>
<p>Why does the compiler choose to call <code>bar</code> via the function pointer and mask a recursive call? Is this behavior defined? If so, can I please have a reference?</p>
| 0debug |
av_cold void ff_intrax8_common_init(IntraX8Context *w, MpegEncContext *const s)
{
w->s = s;
x8_vlc_init();
assert(s->mb_width > 0);
w->prediction_table = av_mallocz(s->mb_width * 2 * 2);
ff_init_scantable(s->idsp.idct_permutation, &w->scantable[0],
ff_wmv1_scantable[0]);
ff_init_scantable(s->idsp.idct_permutation, &w->scantable[1],
ff_wmv1_scantable[2]);
ff_init_scantable(s->idsp.idct_permutation, &w->scantable[2],
ff_wmv1_scantable[3]);
ff_intrax8dsp_init(&w->dsp);
}
| 1threat |
Have `npm version` not prepend "v" to the git tag : <p>Is there a way to tell <code>npm version</code> not to add the "v" prefix to the git tags? The reason I'm trying to do this is because I'm using dockerhub to build the node/docker project and the tags is used in the version of the docker image, having a "v" there is unusual and pointless.</p>
| 0debug |
Why not causing a segmentation error? : <pre><code>#include <iostream>
using namespace std;
int main(){
int a[3], no;
cout << "Index Value\n";
for(int i = 0; i < 100; i++){
cin >> no;
a[i] = no;
cout << i << "\t" << a[i] << endl;
}
return 0;
}
</code></pre>
<p>Here I initialized <strong>a[ 3 ]</strong>. In for loop, I'm feeding input 100 times to <strong>a[ ]</strong>, exceeding the indices of <strong>[ 3 ]</strong>.<br>
Why don't it give segmentation error right after <em>when i equals 4</em>.<br>
<strong><em>Input</em></strong><br>
<code>1 2 3 4 5 6 7</code><br>
<strong><em>Output</em></strong><br>
<code>Index Value
0 1
1 2
2 3
4 0
5 5
6 6
7 7</code>
<br>
Output is wrong when Index equals 4. <em>Printed 0 . Expected 4</em></p>
| 0debug |
Make sum for one column based on codition from another column in php? : I have one mySql table with two columns: amount (INT) and address (string).
All addresses start with "A" or "B".
How can I calculate the sum of all amounts for which address starts with "A" and sum of all amounts for which address start with "B".
I would prefer to do this in PHP rather than in mysql directlly.
| 0debug |
What is lambda? How can you explain this sorting : <p>Please be gentle I'm still learning Python. I've an example where </p>
<blockquote>
<p>pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]</p>
<p>pairs.sort(key=lambda pair: pair[1])</p>
</blockquote>
<p>The result is</p>
<blockquote>
<p>[(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')]</p>
</blockquote>
<p>Can you please help explain why this is the sequence?</p>
| 0debug |
Can someone please explain what is wrong with this code and how to fix it? (JavaScript closure) : <p>Could someone please explain what is wrong with this code and how to fix it? I'm truly lost. Thanks! </p>
<pre><code>var messageProcessing = function() {
console.log(message);
};
process.on('message', function(message) {
messageProcessing();
});
</code></pre>
| 0debug |
static int thp_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
ThpDemuxContext *thp = s->priv_data;
AVIOContext *pb = s->pb;
unsigned int size;
int ret;
if (thp->audiosize == 0) {
if (thp->frame >= thp->framecnt)
return AVERROR_EOF;
avio_seek(pb, thp->next_frame, SEEK_SET);
thp->next_frame += thp->next_framesz;
thp->next_framesz = avio_rb32(pb);
avio_rb32(pb);
size = avio_rb32(pb);
if (thp->has_audio)
thp->audiosize = avio_rb32(pb);
else
thp->frame++;
ret = av_get_packet(pb, pkt, size);
if (ret != size) {
av_free_packet(pkt);
return AVERROR(EIO);
}
pkt->stream_index = thp->video_stream_index;
} else {
ret = av_get_packet(pb, pkt, thp->audiosize);
if (ret != thp->audiosize) {
av_free_packet(pkt);
return AVERROR(EIO);
}
pkt->stream_index = thp->audio_stream_index;
if (thp->audiosize >= 8)
pkt->duration = AV_RB32(&pkt->data[4]);
thp->audiosize = 0;
thp->frame++;
}
return 0;
}
| 1threat |
static void decode_sigpass(Jpeg2000T1Context *t1, int width, int height,
int bpno, int bandno,
int vert_causal_ctx_csty_symbol)
{
int mask = 3 << (bpno - 1), y0, x, y;
for (y0 = 0; y0 < height; y0 += 4)
for (x = 0; x < width; x++)
for (y = y0; y < height && y < y0 + 4; y++) {
int flags_mask = -1;
if (vert_causal_ctx_csty_symbol && y == y0 + 3)
flags_mask &= ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE | JPEG2000_T1_SGN_S);
if ((t1->flags[y+1][x+1] & JPEG2000_T1_SIG_NB & flags_mask)
&& !(t1->flags[y+1][x+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS))) {
if (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ff_jpeg2000_getsigctxno(t1->flags[y+1][x+1] & flags_mask, bandno))) {
int xorbit, ctxno = ff_jpeg2000_getsgnctxno(t1->flags[y+1][x+1] & flags_mask, &xorbit);
if (t1->mqc.raw)
t1->data[y][x] = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ? -mask : mask;
else
t1->data[y][x] = (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ^ xorbit) ?
-mask : mask;
ff_jpeg2000_set_significance(t1, x, y,
t1->data[y][x] < 0);
}
t1->flags[y + 1][x + 1] |= JPEG2000_T1_VIS;
}
}
}
| 1threat |
void s390_crw_mchk(S390CPU *cpu)
{
if (kvm_enabled()) {
kvm_s390_crw_mchk(cpu);
} else {
cpu_inject_crw_mchk(cpu);
}
}
| 1threat |
Aggregated query without GROUP BY : <p>This query seems to work perfect on my older machine. However, on my new machine with MySQL 5.7.14 and PHP 5.6.25 it seems to throw an error:</p>
<blockquote>
<p>Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[42000]: Syntax error or access violation: 1140 In aggregated
query without GROUP BY, expression #1 of SELECT list contains
nonaggregated column 'pixel_perfect.users.id'; this is incompatible
with sql_mode=only_full_group_by' in C:\wamp64\www</p>
</blockquote>
<p>Here is what my query looks like:</p>
<pre><code>$sql="SELECT id, password, COUNT(id) AS count FROM users WHERE email = :email LIMIT 1";
$stmt=$db->prepare($sql);
$stmt->bindValue(':email', $email);
$stmt->execute();
</code></pre>
<p>Why am I getting this error now and what do I do to resolve it painlessly.</p>
| 0debug |
How to convert python int into numpy.int64? : <p>Given a variable in python of type <code>int</code>, e.g. </p>
<pre><code>z = 50
type(z)
## outputs <class 'int'>
</code></pre>
<p>is there a straightforward way to convert this variable into <code>numpy.int64</code>? </p>
<p>It appears one would have to convert this variable into a numpy array, and then convert this into int64. That feels quite convoluted.</p>
<p><a href="https://docs.scipy.org/doc/numpy-1.13.0/user/basics.types.html" rel="noreferrer">https://docs.scipy.org/doc/numpy-1.13.0/user/basics.types.html</a></p>
| 0debug |
How to convert fortran code to pyhton language : My question is about converting fortran to pyhton language but i couldnt understand the working princible of this part of code.How can i rewrite the code in pyhton and which statement i should use instead of "do if then write " statement ?
[CODE_jpeg][1]
[1]: https://i.stack.imgur.com/tZ0Yp.jpg | 0debug |
Tokenize HTML string in JavaScript : <p>I would like to split a string that looks like:</p>
<pre><code>This is <strong>a</strong> test <a href="#test">link</a> and <br /> line. break
</code></pre>
<p>into the following with JavaScript:</p>
<pre><code>[
'This',
'is',
'<strong>a</strong>',
'test',
'<a href="#test">link</a>',
'<br />',
'line.',
]
</code></pre>
<p>I tried splitting on spaces, and <code><</code> <code>></code>, but that obviously doesn't work for tags like <code>strong</code> and <code>a</code>. I'm not sure how to write a regex that doesn't split within HTML tags. I also tried to use jQuery <code>children()</code>, but it doesn't extract plain text, just the html tags. Any help would be great.</p>
| 0debug |
dynamically initialize a 3D character array in c : <p>I am trying to initialize a 3D character array, but couldn't. when i execute the program crashes.
I need to store 'T' sets of 'N[i]' no.of words in the ***word.characters in each word are less than 20.
"The program executes when static initialized." </p>
<pre><code>#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
#include<math.h>
int main()
{
int i,j,k,T,sum=0;
printf("\nEnter the no of test cases");
scanf("%d",&T);
int *N;
N=(int*)malloc(T*sizeof(int));
int **t;
t=(int**)malloc(T*sizeof(int*));
for(i=0;i<T;i++)
{
t[T]=(int*)malloc(N[i]*sizeof(int));
}
char ***word;
word = (char ***)malloc(T*sizeof(char**));
for (i = 0; i< T; i++)
{
word[T] = (char **) malloc(N[i]*sizeof(char *));
for (j = 0; j < N[i]; j++) {
word[T][N[i]] = (char *)malloc(20*sizeof(char));
}
}
</code></pre>
| 0debug |
static target_ulong h_add_logical_lan_buffer(CPUPPCState *env,
sPAPREnvironment *spapr,
target_ulong opcode,
target_ulong *args)
{
target_ulong reg = args[0];
target_ulong buf = args[1];
VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
VIOsPAPRVLANDevice *dev = (VIOsPAPRVLANDevice *)sdev;
vlan_bd_t bd;
dprintf("H_ADD_LOGICAL_LAN_BUFFER(0x" TARGET_FMT_lx
", 0x" TARGET_FMT_lx ")\n", reg, buf);
if (!sdev) {
hcall_dprintf("Bad device\n");
return H_PARAMETER;
}
if ((check_bd(dev, buf, 4) < 0)
|| (VLAN_BD_LEN(buf) < 16)) {
hcall_dprintf("Bad buffer enqueued\n");
return H_PARAMETER;
}
if (!dev->isopen || dev->rx_bufs >= VLAN_MAX_BUFS) {
return H_RESOURCE;
}
do {
dev->add_buf_ptr += 8;
if (dev->add_buf_ptr >= SPAPR_VIO_TCE_PAGE_SIZE) {
dev->add_buf_ptr = VLAN_RX_BDS_OFF;
}
bd = ldq_tce(sdev, dev->buf_list + dev->add_buf_ptr);
} while (bd & VLAN_BD_VALID);
stq_tce(sdev, dev->buf_list + dev->add_buf_ptr, buf);
dev->rx_bufs++;
dprintf("h_add_logical_lan_buffer(): Added buf ptr=%d rx_bufs=%d"
" bd=0x%016llx\n", dev->add_buf_ptr, dev->rx_bufs,
(unsigned long long)buf);
return H_SUCCESS;
}
| 1threat |
React Native image upload : <p>I am having an issue with uploading an image from my camera roll or to my API. here is the code that I am currently using. I am able to get the image data from both the camera roll and camera. I just am having an issue of posting the data to the server. I don't know where I am getting confused. </p>
<pre><code>import React, { Component } from 'react';
import {
Text,
View,
PixelRatio,
TouchableOpacity,
Image,
Platform,
NativeModules,
DeviceEventEmitter
} from 'react-native';
import { connect } from 'react-redux';
import ImagePicker from 'react-native-image-picker';
import { captureProflieAvitar } from '../../actions';
var RNUploader = NativeModules.RNUploader;
class NewCamera extends Component {
state = {
avatarSource: null,
imgBase64: []
}
componentDidMount() {
// upload progress
DeviceEventEmitter.addListener('RNUploaderProgress', (data) => {
const bytesWritten = data.totalBytesWritten;
const bytesTotal = data.totalBytesExpectedToWrite;
const progress = data.progress;
console.log(bytesWritten, bytesTotal);
console.log( "upload progress: " + progress + "%");
});
}
selectPhotoTapped() {
const options = {
quality: 0.75,
maxWidth: 300,
maxHeight: 300,
storageOptions: {
skipBackup: true
}
};
ImagePicker.showImagePicker(options, (response) => {
console.log('Response = ', response);
if (response.didCancel) {
console.log('User cancelled photo picker');
} else if (response.error) {
console.log('ImagePicker Error: ', response.error);
} else if (response.customButton) {
console.log('User tapped custom button: ', response.customButton);
} else {
let source;
// You can display the image using either:
source = { uri: 'data:image/jpeg;base64,' + response.data, isStatic: true };
const temp = response.data;
//Or:
if (Platform.OS === 'android') {
source = { uri: response.uri, isStatic: true };
} else {
source = { uri: response.uri.replace('file://', ''), isStatic: true };
}
this.setState({
avatarSource: source,
imgBase64: temp,
});
}
});
}
doUpload() {
const files = {
filepath: `data:image/png;base64,${this.state.imgBase64}`,
};
const opts = {
url: 'https://central.tipflip.co?apior=MYAPIKEY&tfReqID3031&tfUserID=1&tfImage=',
files,
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
};
RNUploader.upload(opts, (err, response) => {
if (err) {
console.log(err);
return;
}
const status = response.status;
const responseString = response.data;
const json = JSON.parse(responseString);
console.log('upload complete with status ' + status);
});
}
render() {
return (
<View style={styles.container}>
<TouchableOpacity onPress={this.selectPhotoTapped.bind(this)}>
<View style={[styles.avatar, styles.avatarContainer, { marginBottom: 20 }]}>
{ this.state.avatarSource === null ? <Text>Select a Photo</Text> :
<Image style={styles.avatar} source={this.state.avatarSource} />
}
</View>
</TouchableOpacity>
<TouchableOpacity
style={{
backgroundColor: 'yellow',
width: 60,
height: 20,
marginTop: 20,
justifyContent: 'center',
alignItems: 'center' }}
onPress={this.doUpload.bind(this)}
>
<Text>Upload</Text>
</TouchableOpacity>
<TouchableOpacity
style={{
backgroundColor: 'yellow',
width: 60,
height: 20,
marginTop: 20,
justifyContent: 'center',
alignItems: 'center'
}} onPress={this.props.cancel}
>
<Text>Cancel</Text>
</TouchableOpacity>
</View>
);
}
}
const styles = {
container: {
justifyContent: 'center',
alignItems: 'center'
},
avatarContainer: {
borderColor: '#9B9B9B',
borderWidth: 1 / PixelRatio.get(),
justifyContent: 'center',
alignItems: 'center'
},
avatar: {
borderRadius: 75,
width: 150,
height: 150
}
};
export default connect(null, { captureProflieAvitar })(NewCamera);
</code></pre>
| 0debug |
Use docker-compose with multiple repositories : <p>I'm currently struggling with the deployment of my services and I wanted to ask, what's the proper way when you have to deal with multiple repositories. The repositories are independent, but to run in production, everything needs to be launched.</p>
<p>My Setup:</p>
<ul>
<li>Git Repository Backend:
<ul>
<li>Backend Project Rails</li>
<li>docker-compose: backend(expose 3000), db and redis</li>
</ul></li>
<li>Git Repository Frontend
<ul>
<li>Express.js server</li>
<li>docker-compose: (expose 4200)</li>
</ul></li>
</ul>
<p>Both can be run independently and test can be executed by CI</p>
<ul>
<li>Git Repository Nginx for Production
<ul>
<li>Needs to connect to the other two services (same docker network)</li>
<li>forwards requests to the right service</li>
</ul></li>
</ul>
<p>I have already tried to include the two services as submodules into the Nginx repository and use the docker-compose of the nginx repo, but I'm not really happy with it. </p>
| 0debug |
Symfony FOS user bundle initiation : <p>I have a problem with installing FOS user bundle. I tried to search it everywhere, but probably I'm too dumb and can't find it.</p>
<p>I've created an entity called Admin and tried to run doctrine:schema:update --force
I've got an error: <code>The child node "from_email" at path "fos_user" must be configured.</code> </p>
<p>Here is my config.yml fos part.</p>
<pre><code>fos_user:
db_driver: orm # other valid values are 'mongodb' and 'couchdb'
firewall_name: main
user_class: AppBundle\Entity\Admin
</code></pre>
<p>any suggestions?</p>
| 0debug |
Swift 4 - Find number in string and return location and length : `let myStr = "I have 4.34 apples."`
I need the location range and the length, because I'm using NSRange(location:, length:) to bold the number 4.34
extension String{
func findNumbersAndBoldThem()->NSAttributedString{
//the code
}
} | 0debug |
static void qdict_destroy_obj(QObject *obj)
{
int i;
QDict *qdict;
assert(obj != NULL);
qdict = qobject_to_qdict(obj);
for (i = 0; i < QDICT_BUCKET_MAX; i++) {
QDictEntry *entry = QLIST_FIRST(&qdict->table[i]);
while (entry) {
QDictEntry *tmp = QLIST_NEXT(entry, next);
QLIST_REMOVE(entry, next);
qentry_destroy(entry);
entry = tmp;
}
}
g_free(qdict);
}
| 1threat |
Angular 5 to 6 Upgrade: Property 'map' does not exist on type Observable : <p>Ive upgraded my angular application from version 5 to 6 and im getting this error from the following code.</p>
<pre><code> const request = this.evidenceService.get().map((res) => res.data)
.catch(error => Observable.of(null));
</code></pre>
<blockquote>
<p>Property 'map' does not exist on type 'Observable'.</p>
</blockquote>
| 0debug |
Can a process perfrom IO while residing in secondary memory? : I am confused about suspend wait and block terms in operating system.
I read it as a process which is in wait or block state needs to be thrown in sec memory and resumes with main memory after completing IO. | 0debug |
SQL update column values with substring value : <p>So my table is <a href="https://imgur.com/a/1lfDdB9" rel="nofollow noreferrer">https://imgur.com/a/1lfDdB9</a>.
I want to update the <strong>name</strong> column so that it removes the <em>Telefon mobil</em> part(to look like the first row).</p>
| 0debug |
Is it safe to iterate a dereferenced vector? : <pre><code>std::vector<int>* someVector;
// Initialize vector here and add elements
//****
// Now loop vector after initializing it
for (int val : *someVector)
{
doSomething(val);
}
</code></pre>
<p>In the above example, is it safe to iterate a vector like that?</p>
| 0debug |
int kvm_arch_get_registers(CPUState *cs)
{
PowerPCCPU *cpu = POWERPC_CPU(cs);
CPUPPCState *env = &cpu->env;
struct kvm_regs regs;
struct kvm_sregs sregs;
uint32_t cr;
int i, ret;
ret = kvm_vcpu_ioctl(cs, KVM_GET_REGS, ®s);
if (ret < 0)
return ret;
cr = regs.cr;
for (i = 7; i >= 0; i--) {
env->crf[i] = cr & 15;
cr >>= 4;
}
env->ctr = regs.ctr;
env->lr = regs.lr;
cpu_write_xer(env, regs.xer);
env->msr = regs.msr;
env->nip = regs.pc;
env->spr[SPR_SRR0] = regs.srr0;
env->spr[SPR_SRR1] = regs.srr1;
env->spr[SPR_SPRG0] = regs.sprg0;
env->spr[SPR_SPRG1] = regs.sprg1;
env->spr[SPR_SPRG2] = regs.sprg2;
env->spr[SPR_SPRG3] = regs.sprg3;
env->spr[SPR_SPRG4] = regs.sprg4;
env->spr[SPR_SPRG5] = regs.sprg5;
env->spr[SPR_SPRG6] = regs.sprg6;
env->spr[SPR_SPRG7] = regs.sprg7;
env->spr[SPR_BOOKE_PID] = regs.pid;
for (i = 0;i < 32; i++)
env->gpr[i] = regs.gpr[i];
kvm_get_fp(cs);
if (cap_booke_sregs) {
ret = kvm_vcpu_ioctl(cs, KVM_GET_SREGS, &sregs);
if (ret < 0) {
return ret;
}
if (sregs.u.e.features & KVM_SREGS_E_BASE) {
env->spr[SPR_BOOKE_CSRR0] = sregs.u.e.csrr0;
env->spr[SPR_BOOKE_CSRR1] = sregs.u.e.csrr1;
env->spr[SPR_BOOKE_ESR] = sregs.u.e.esr;
env->spr[SPR_BOOKE_DEAR] = sregs.u.e.dear;
env->spr[SPR_BOOKE_MCSR] = sregs.u.e.mcsr;
env->spr[SPR_BOOKE_TSR] = sregs.u.e.tsr;
env->spr[SPR_BOOKE_TCR] = sregs.u.e.tcr;
env->spr[SPR_DECR] = sregs.u.e.dec;
env->spr[SPR_TBL] = sregs.u.e.tb & 0xffffffff;
env->spr[SPR_TBU] = sregs.u.e.tb >> 32;
env->spr[SPR_VRSAVE] = sregs.u.e.vrsave;
}
if (sregs.u.e.features & KVM_SREGS_E_ARCH206) {
env->spr[SPR_BOOKE_PIR] = sregs.u.e.pir;
env->spr[SPR_BOOKE_MCSRR0] = sregs.u.e.mcsrr0;
env->spr[SPR_BOOKE_MCSRR1] = sregs.u.e.mcsrr1;
env->spr[SPR_BOOKE_DECAR] = sregs.u.e.decar;
env->spr[SPR_BOOKE_IVPR] = sregs.u.e.ivpr;
}
if (sregs.u.e.features & KVM_SREGS_E_64) {
env->spr[SPR_BOOKE_EPCR] = sregs.u.e.epcr;
}
if (sregs.u.e.features & KVM_SREGS_E_SPRG8) {
env->spr[SPR_BOOKE_SPRG8] = sregs.u.e.sprg8;
}
if (sregs.u.e.features & KVM_SREGS_E_IVOR) {
env->spr[SPR_BOOKE_IVOR0] = sregs.u.e.ivor_low[0];
env->spr[SPR_BOOKE_IVOR1] = sregs.u.e.ivor_low[1];
env->spr[SPR_BOOKE_IVOR2] = sregs.u.e.ivor_low[2];
env->spr[SPR_BOOKE_IVOR3] = sregs.u.e.ivor_low[3];
env->spr[SPR_BOOKE_IVOR4] = sregs.u.e.ivor_low[4];
env->spr[SPR_BOOKE_IVOR5] = sregs.u.e.ivor_low[5];
env->spr[SPR_BOOKE_IVOR6] = sregs.u.e.ivor_low[6];
env->spr[SPR_BOOKE_IVOR7] = sregs.u.e.ivor_low[7];
env->spr[SPR_BOOKE_IVOR8] = sregs.u.e.ivor_low[8];
env->spr[SPR_BOOKE_IVOR9] = sregs.u.e.ivor_low[9];
env->spr[SPR_BOOKE_IVOR10] = sregs.u.e.ivor_low[10];
env->spr[SPR_BOOKE_IVOR11] = sregs.u.e.ivor_low[11];
env->spr[SPR_BOOKE_IVOR12] = sregs.u.e.ivor_low[12];
env->spr[SPR_BOOKE_IVOR13] = sregs.u.e.ivor_low[13];
env->spr[SPR_BOOKE_IVOR14] = sregs.u.e.ivor_low[14];
env->spr[SPR_BOOKE_IVOR15] = sregs.u.e.ivor_low[15];
if (sregs.u.e.features & KVM_SREGS_E_SPE) {
env->spr[SPR_BOOKE_IVOR32] = sregs.u.e.ivor_high[0];
env->spr[SPR_BOOKE_IVOR33] = sregs.u.e.ivor_high[1];
env->spr[SPR_BOOKE_IVOR34] = sregs.u.e.ivor_high[2];
}
if (sregs.u.e.features & KVM_SREGS_E_PM) {
env->spr[SPR_BOOKE_IVOR35] = sregs.u.e.ivor_high[3];
}
if (sregs.u.e.features & KVM_SREGS_E_PC) {
env->spr[SPR_BOOKE_IVOR36] = sregs.u.e.ivor_high[4];
env->spr[SPR_BOOKE_IVOR37] = sregs.u.e.ivor_high[5];
}
}
if (sregs.u.e.features & KVM_SREGS_E_ARCH206_MMU) {
env->spr[SPR_BOOKE_MAS0] = sregs.u.e.mas0;
env->spr[SPR_BOOKE_MAS1] = sregs.u.e.mas1;
env->spr[SPR_BOOKE_MAS2] = sregs.u.e.mas2;
env->spr[SPR_BOOKE_MAS3] = sregs.u.e.mas7_3 & 0xffffffff;
env->spr[SPR_BOOKE_MAS4] = sregs.u.e.mas4;
env->spr[SPR_BOOKE_MAS6] = sregs.u.e.mas6;
env->spr[SPR_BOOKE_MAS7] = sregs.u.e.mas7_3 >> 32;
env->spr[SPR_MMUCFG] = sregs.u.e.mmucfg;
env->spr[SPR_BOOKE_TLB0CFG] = sregs.u.e.tlbcfg[0];
env->spr[SPR_BOOKE_TLB1CFG] = sregs.u.e.tlbcfg[1];
}
if (sregs.u.e.features & KVM_SREGS_EXP) {
env->spr[SPR_BOOKE_EPR] = sregs.u.e.epr;
}
if (sregs.u.e.features & KVM_SREGS_E_PD) {
env->spr[SPR_BOOKE_EPLC] = sregs.u.e.eplc;
env->spr[SPR_BOOKE_EPSC] = sregs.u.e.epsc;
}
if (sregs.u.e.impl_id == KVM_SREGS_E_IMPL_FSL) {
env->spr[SPR_E500_SVR] = sregs.u.e.impl.fsl.svr;
env->spr[SPR_Exxx_MCAR] = sregs.u.e.impl.fsl.mcar;
env->spr[SPR_HID0] = sregs.u.e.impl.fsl.hid0;
if (sregs.u.e.impl.fsl.features & KVM_SREGS_E_FSL_PIDn) {
env->spr[SPR_BOOKE_PID1] = sregs.u.e.impl.fsl.pid1;
env->spr[SPR_BOOKE_PID2] = sregs.u.e.impl.fsl.pid2;
}
}
}
if (cap_segstate) {
ret = kvm_vcpu_ioctl(cs, KVM_GET_SREGS, &sregs);
if (ret < 0) {
return ret;
}
ppc_store_sdr1(env, sregs.u.s.sdr1);
#ifdef TARGET_PPC64
memset(env->slb, 0, sizeof(env->slb));
for (i = 0; i < ARRAY_SIZE(env->slb); i++) {
target_ulong rb = sregs.u.s.ppc64.slb[i].slbe;
target_ulong rs = sregs.u.s.ppc64.slb[i].slbv;
if (rb & SLB_ESID_V) {
ppc_store_slb(env, rb, rs);
}
}
#endif
for (i = 0; i < 16; i++) {
env->sr[i] = sregs.u.s.ppc32.sr[i];
}
for (i = 0; i < 8; i++) {
env->DBAT[0][i] = sregs.u.s.ppc32.dbat[i] & 0xffffffff;
env->DBAT[1][i] = sregs.u.s.ppc32.dbat[i] >> 32;
env->IBAT[0][i] = sregs.u.s.ppc32.ibat[i] & 0xffffffff;
env->IBAT[1][i] = sregs.u.s.ppc32.ibat[i] >> 32;
}
}
if (cap_hior) {
kvm_get_one_spr(cs, KVM_REG_PPC_HIOR, SPR_HIOR);
}
if (cap_one_reg) {
int i;
for (i = 0; i < 1024; i++) {
uint64_t id = env->spr_cb[i].one_reg_id;
if (id != 0) {
kvm_get_one_spr(cs, id, i);
}
}
#ifdef TARGET_PPC64
if (cap_papr) {
if (kvm_get_vpa(cs) < 0) {
DPRINTF("Warning: Unable to get VPA information from KVM\n");
}
}
#endif
}
return 0;
}
| 1threat |
How to put a TextView Under a ListView and make the ListView to fill the screen using android layouts : I have this layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingTop="@dimen/all_pages_padding_top"
tools:context="driver.mci.ir.mcicardriver.activity.MessagesActivity">
<ExpandableListView
android:id="@+id/messagesListView"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="@color/colorBackground"
android:layout_gravity="right|top">
</ExpandableListView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="@+id/messagesListView"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<ImageButton
android:id="@id/imageView3"
android:layout_width="@dimen/login_icon_size"
android:layout_height="@dimen/login_icon_size"
android:scaleType="fitXY"
android:src="@drawable/sendmessage"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
/>
<EditText
android:id="@+id/userName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/imageView3"
android:layout_toStartOf="@+id/imageView3" />
</RelativeLayout>
</RelativeLayout>
I want the `ExpandableListView` to fill the screen and i want to out the inner `RelativeLayout` below the `ExpandableListView`, but the `ExpandableListView` will fill the whole screen and i cant see the `RelativeLayout`. What am i doing wrong?
| 0debug |
How to change Region / Zone in Google Cloud? : <p>I am very new to Google Cloud. I was able to setup a wordpress site and am working on it now. However, it appears that my vm instance is using the following asia-east1-a for its zone. I was able to change the Region and Zone using gcloud commands with the following output:</p>
<pre><code>$ gcloud config list compute/region
Your active configuration is: [default]
[compute]
region = us-east4
$ gcloud config list compute/zone
Your active configuration is: [default]
[compute]
zone = us-east4-b
</code></pre>
<p>How does one change the active default to the new set zone? I would like my instance to run in the North East Coast of the USA?</p>
<p>Thanks,
T</p>
| 0debug |
How do I add a top and bottom shadow while scrolling but only when needed? : <p><strong>How do I add a shadow when a container overflows but only when needed?</strong></p>
<p>What I mean by this is:</p>
<ul>
<li>if there is content available to scroll either on top or bottom, show a shadow to tell the user there is more content to scoll</li>
<li>if there isn't content to scroll through, a shadow will not appear</li>
</ul>
<p>And to clarify further</p>
<ul>
<li>if the content of the container overflows (i.e. it scrolls) and the user is at the very top of the content then there should be a shadow on the <em>bottom</em> of the page and not the top.</li>
<li>Same goes if the user is at the bottom of the page expect that there should be a shadow on the top</li>
<li>if the content does not overflow the container, then <em>no</em> shadow should be shown to keep things clean.</li>
</ul>
<p>I have working javascript solutions but I want something <strong>purely css</strong> for performance reasons.</p>
<p>Any ideas?</p>
| 0debug |
Get server time by using ajax : <p>I want to get the server time in a variable. I am creating a count down timer, so that i need the server time. But i don't know how to take time and assign it into a variable (that variable will be used in JavaScript ). Please help me.</p>
| 0debug |
How to stop the Discord bot responds to other bots? (Discord.js) : I'm new to programming a discord bot using discord.js (JavaScript). So, recently My bot got approved by discordbots.org. At the same day, I tested it. The result was other bot responds my command, but my bot wasn't. I check the logs in Heroku app, and there is an error. When I test the command into my server, it responds. So I think that there is a problem with my bot. When i checked my Bot's role in "Discord Bot Lists" server, I see that my bot gets a "Muted" Role. That mean there is a problem with my bot. When I check the mod logs channel, it shows that my bot is muted because my bot respond to other bot. How can I fix this so my bot get unmuted in that server? Sorry for my bad english and not providing the code.
| 0debug |
Debugging in C++ : <p>I came across this code snippet. Can you explain how to use this debugging in the program.</p>
<pre><code>#ifdef TESTING
#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define DEBUG
#define VALUE(x)
#define debug(...)
#endif
</code></pre>
| 0debug |
How to order posts by date added : <p>I have a website in which admins can post news and updates but every time they add a new one it goes from the first one added downwards any idea how to fix this?</p>
| 0debug |
static void single_quote_string(void)
{
int i;
struct {
const char *encoded;
const char *decoded;
} test_cases[] = {
{ "'hello world'", "hello world" },
{ "'the quick brown fox \\' jumped over the fence'",
"the quick brown fox ' jumped over the fence" },
{}
};
for (i = 0; test_cases[i].encoded; i++) {
QObject *obj;
QString *str;
obj = qobject_from_json(test_cases[i].encoded);
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QSTRING);
str = qobject_to_qstring(obj);
g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0);
QDECREF(str);
}
}
| 1threat |
when i type CountDownTimer it not accepting in android studio : new CountDownTimer(30000, 1000) {
public void onTick(long millisUntilFinished) {
mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
}
public void onFinish() {
mTextField.setText("done!");
}
}.start(); | 0debug |
DynamoDB M-M Adjacency List Design Pattern : <p>Referring to <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-adjacency-graphs.html" rel="noreferrer">https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-adjacency-graphs.html</a>. I was wondering if anyone could help me.</p>
<p>The first image is of the table, and the second is the GSI. Here is the table:
<a href="https://i.stack.imgur.com/pA1n6.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/pA1n6.jpg" alt="enter image description here"></a></p>
<p>On the table, I don't understand how one is to create the sort-key? Is this one attribute that stores both Bill-ID and Invoice-ID? or two separate attributes? I have a feeling it's the one flexible attribute, and if so how do you differentiate one from the other? And how are we meant to construct the query on the sort-key?</p>
<p>Is it just by looking the prefix "Bill-" or "Invoice-"?
The practice of DynamoDB seems to make use of dashes ("-") to separate values in an attribute. If anyone can give me use cases of such things, I would be grateful as well, but I am going off tangent unless it's important in this case.</p>
<p>Now, this is very relatable and very interesting <a href="https://youtu.be/xV-As-sYKyg?t=1897" rel="noreferrer">https://youtu.be/xV-As-sYKyg?t=1897</a>, where the presenter uses ONE product table to store various types of items: Books, Song Albums, and Movies; and each has their own attributes.</p>
<p>Again I have a problem understanding the sort-key used there. I understand that productID=1 is bookID, and productID=2 is an Album. Now where it gets confusing now is what I circled in red. These are the tracks of Album 2. However, the structure of the sort key is "albumID:trackID". Now, where is the "trackID"? Is it meant to substitute the word "trackID" with actual ID? or is this meant to be a text exactly as "albumID:trackID"?.</p>
<p>What if I wanted to query a specific trackID? what would be the syntax of my query?</p>
<p>Please see the image here from the youtube:
<a href="https://i.stack.imgur.com/kXJmB.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/kXJmB.jpg" alt="enter image description here"></a></p>
<p>Thank you all in advance!!! :-)</p>
| 0debug |
static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)
{
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
const enum AVPixelFormat *pix_fmts;
#if FF_API_XVMC
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->xvmc_acceleration)
return ff_get_format(avctx, pixfmt_xvmc_mpg2_420);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (s->chroma_format < 2)
pix_fmts = mpeg12_hwaccel_pixfmt_list_420;
else if (s->chroma_format == 2)
pix_fmts = mpeg12_pixfmt_list_422;
else
pix_fmts = mpeg12_pixfmt_list_444;
return ff_get_format(avctx, pix_fmts);
}
| 1threat |
Read XLSB File in Pandas Python : <p>There are many questions on this, but there has been no simple answer on how to read an xlsb file into pandas. Is there an easy way to do this?</p>
| 0debug |
static int cloop_open(BlockDriverState *bs, int flags)
{
BDRVCloopState *s = bs->opaque;
uint32_t offsets_size, max_compressed_block_size = 1, i;
bs->read_only = 1;
if (bdrv_pread(bs->file, 128, &s->block_size, 4) < 4) {
goto cloop_close;
}
s->block_size = be32_to_cpu(s->block_size);
if (bdrv_pread(bs->file, 128 + 4, &s->n_blocks, 4) < 4) {
goto cloop_close;
}
s->n_blocks = be32_to_cpu(s->n_blocks);
offsets_size = s->n_blocks * sizeof(uint64_t);
s->offsets = g_malloc(offsets_size);
if (bdrv_pread(bs->file, 128 + 4 + 4, s->offsets, offsets_size) <
offsets_size) {
goto cloop_close;
}
for(i=0;i<s->n_blocks;i++) {
s->offsets[i] = be64_to_cpu(s->offsets[i]);
if (i > 0) {
uint32_t size = s->offsets[i] - s->offsets[i - 1];
if (size > max_compressed_block_size) {
max_compressed_block_size = size;
}
}
}
s->compressed_block = g_malloc(max_compressed_block_size + 1);
s->uncompressed_block = g_malloc(s->block_size);
if (inflateInit(&s->zstream) != Z_OK) {
goto cloop_close;
}
s->current_block = s->n_blocks;
s->sectors_per_block = s->block_size/512;
bs->total_sectors = s->n_blocks * s->sectors_per_block;
qemu_co_mutex_init(&s->lock);
return 0;
cloop_close:
return -1;
}
| 1threat |
Regex to check for AND : <p>I am trying to check whether a string starts from a particular word And also a particular substring occurs in it. </p>
<p>So lets say if I have a string like this:</p>
<p><code>SCSI\DISK&VEN_MICRON&PROD_1100\4&2096297&0&000200</code></p>
<p>I need to check whether this string has <code>4&2096297&0</code> and also it starts from <code>SCSI</code></p>
<p><strong>I did this</strong> : <code>(^SCSI|\\4&2096297&0)</code> . This is pretty much doing the work but it is also selecting the substring even if the string doesn't start from <code>SCSI</code></p>
<p>Regex101 : <a href="https://regex101.com/r/xV0tHI/3" rel="nofollow noreferrer">Attempt</a></p>
<p>It is working as expected but the problem is it is selecting a substring even if the string doesn't start from <code>SCSI</code>. </p>
<p>Is it possible to put a AND condition to it.</p>
| 0debug |
static void ccid_card_vscard_send_msg(PassthruState *s,
VSCMsgType type, uint32_t reader_id,
const uint8_t *payload, uint32_t length)
{
VSCMsgHeader scr_msg_header;
scr_msg_header.type = htonl(type);
scr_msg_header.reader_id = htonl(reader_id);
scr_msg_header.length = htonl(length);
qemu_chr_fe_write(s->cs, (uint8_t *)&scr_msg_header, sizeof(VSCMsgHeader));
qemu_chr_fe_write(s->cs, payload, length);
}
| 1threat |
Want to know about html and php : <p>I'm new to web design. I started with html and make some pages with ext .html
but now I want to add a contact us form or message us form in my html page . So how can I do that . Actually I want to use html page and that html page can execute php script.</p>
<p>Thanks in advance.</p>
| 0debug |
static int ehci_state_fetchqtd(EHCIQueue *q)
{
EHCIqtd qtd;
EHCIPacket *p;
int again = 0;
get_dwords(q->ehci, NLPTR_GET(q->qtdaddr), (uint32_t *) &qtd,
sizeof(EHCIqtd) >> 2);
ehci_trace_qtd(q, NLPTR_GET(q->qtdaddr), &qtd);
p = QTAILQ_FIRST(&q->packets);
if (p != NULL) {
if (p->qtdaddr != q->qtdaddr ||
(!NLPTR_TBIT(p->qtd.next) && (p->qtd.next != qtd.next)) ||
(!NLPTR_TBIT(p->qtd.altnext) && (p->qtd.altnext != qtd.altnext)) ||
p->qtd.bufptr[0] != qtd.bufptr[0]) {
ehci_cancel_queue(q);
ehci_trace_guest_bug(q->ehci, "guest updated active QH or qTD");
p = NULL;
} else {
p->qtd = qtd;
ehci_qh_do_overlay(q);
}
}
if (!(qtd.token & QTD_TOKEN_ACTIVE)) {
if (p != NULL) {
ehci_cancel_queue(q);
p = NULL;
}
ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);
again = 1;
} else if (p != NULL) {
switch (p->async) {
case EHCI_ASYNC_NONE:
ehci_set_state(q->ehci, q->async, EST_EXECUTE);
break;
case EHCI_ASYNC_INFLIGHT:
ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);
break;
case EHCI_ASYNC_FINISHED:
ehci_set_state(q->ehci, q->async, EST_EXECUTING);
break;
}
again = 1;
} else {
p = ehci_alloc_packet(q);
p->qtdaddr = q->qtdaddr;
p->qtd = qtd;
ehci_set_state(q->ehci, q->async, EST_EXECUTE);
again = 1;
}
return again;
}
| 1threat |
CPUCRISState *cpu_cris_init (const char *cpu_model)
{
CPUCRISState *env;
static int tcg_initialized = 0;
int i;
env = qemu_mallocz(sizeof(CPUCRISState));
if (!env)
return NULL;
cpu_exec_init(env);
cpu_reset(env);
if (tcg_initialized)
return env;
tcg_initialized = 1;
cpu_env = tcg_global_reg_new(TCG_TYPE_PTR, TCG_AREG0, "env");
cc_x = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
offsetof(CPUState, cc_x), "cc_x");
cc_src = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
offsetof(CPUState, cc_src), "cc_src");
cc_dest = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
offsetof(CPUState, cc_dest),
"cc_dest");
cc_result = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
offsetof(CPUState, cc_result),
"cc_result");
cc_op = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
offsetof(CPUState, cc_op), "cc_op");
cc_size = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
offsetof(CPUState, cc_size),
"cc_size");
cc_mask = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
offsetof(CPUState, cc_mask),
"cc_mask");
env_pc = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
offsetof(CPUState, pc),
"pc");
env_btarget = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
offsetof(CPUState, btarget),
"btarget");
env_btaken = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
offsetof(CPUState, btaken),
"btaken");
for (i = 0; i < 16; i++) {
cpu_R[i] = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
offsetof(CPUState, regs[i]),
regnames[i]);
}
for (i = 0; i < 16; i++) {
cpu_PR[i] = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0,
offsetof(CPUState, pregs[i]),
pregnames[i]);
}
TCG_HELPER(helper_raise_exception);
TCG_HELPER(helper_dump);
TCG_HELPER(helper_tlb_flush_pid);
TCG_HELPER(helper_movl_sreg_reg);
TCG_HELPER(helper_movl_reg_sreg);
TCG_HELPER(helper_rfe);
TCG_HELPER(helper_rfn);
TCG_HELPER(helper_evaluate_flags_muls);
TCG_HELPER(helper_evaluate_flags_mulu);
TCG_HELPER(helper_evaluate_flags_mcp);
TCG_HELPER(helper_evaluate_flags_alu_4);
TCG_HELPER(helper_evaluate_flags_move_4);
TCG_HELPER(helper_evaluate_flags_move_2);
TCG_HELPER(helper_evaluate_flags);
TCG_HELPER(helper_top_evaluate_flags);
return env;
}
| 1threat |
static void imx_fec_reset(DeviceState *d)
{
IMXFECState *s = IMX_FEC(d);
s->eir = 0;
s->eimr = 0;
s->rx_enabled = 0;
s->ecr = 0;
s->mscr = 0;
s->mibc = 0xc0000000;
s->rcr = 0x05ee0001;
s->tcr = 0;
s->tfwr = 0;
s->frsr = 0x500;
s->miigsk_cfgr = 0;
s->miigsk_enr = 0x6;
phy_reset(s);
}
| 1threat |
Sorting IEnumerable<string> : <p>I've got an <code>IEnumerable<string></code> with values like:</p>
<ul>
<li>pp</li>
<li>pp.10.0</li>
<li>pp.6.0</li>
<li>pp.6.1</li>
<li>pp.8.3</li>
<li>kp.10.1</li>
<li>kp</li>
<li>kp.3.20</li>
</ul>
<p>... etc</p>
<p>I'd like to organize them alphabetically, but keeping the values with double digits (in example above ones with 10.0 and 10.1) below the ones with single digits. In other words, after sorting it should look like this:</p>
<ul>
<li>kp</li>
<li>kp.3.20</li>
<li>kp.10.1</li>
<li>pp</li>
<li>pp.6.0</li>
<li>pp.6.1</li>
<li>pp.8.3</li>
<li>pp.10.0</li>
</ul>
<p>I tried a simple <code>IEnumerable<string>.OrderBy(x => x, StringComparer.CurrentCultureIgnoreCase)</code> but that doesn't quite work in this case.</p>
<p>Also bear in mind that the <code>pp</code> and <code>kp</code> parts <em>could</em> have dots in them as well, if you're thinking of splitting the string.</p>
| 0debug |
Deleting similar elements from a list in python : <p>I want to delete similar elements from a list in Python and print uniques element in that list without using set(). However my code is not doing the same . please help me out </p>
<p><strong>My code</strong> </p>
<pre><code>T = int(raw_input())
a=[]
for i in range(0,T):
a.append(raw_input())
for i in range(len(a)):
for j in range(i+1, len(a)):
if a[i]==a[j]:
del a[j]
print a
</code></pre>
| 0debug |
SQL Replace multiple different characters in string : <p>I need to replace multiple characters in a string. The result can't contain any '&' or any commas.</p>
<p>I currently have: </p>
<pre><code>REPLACE(T2.[ShipToCode],'&','and')
</code></pre>
<p>But how do you put multiple values in?</p>
<p>Many thanks!</p>
| 0debug |
def get_inv_count(arr, n):
inv_count = 0
for i in range(n):
for j in range(i + 1, n):
if (arr[i] > arr[j]):
inv_count += 1
return inv_count | 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.