problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Scala program to display the output in format below. : Find the missing code in the Scala program to display the output in the following format.
Output: Array[(Int, String)] = Array((4,anar), (5,applelichi), (6,bananagrapes), (7,oranges))
Program
val a = sc.parallelize(List("apple","banana","oranges","grapes","lichi","anar"))
val b = a.map(x =>(x.length,x))
<Write your code> | 0debug |
ReactJS Module build failed: SyntaxError: Unexpected token - ReactDOM.render : <p>Why am I getting this error below? My statement <code>ReactDOM.render(<App />, container);</code> is 100% legit code.</p>
<p>My github repo: <a href="https://github.com/leongaban/react_starwars" rel="noreferrer">https://github.com/leongaban/react_starwars</a></p>
<p><a href="https://i.stack.imgur.com/FR8Ae.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/FR8Ae.jpg" alt="enter image description here"></a></p>
<p>The app.js file</p>
<pre><code>import react from 'react'
import ReactDom from 'react-dom'
import App from 'components/App'
require('index.html');
// Create app
const container = document.getElementById('app-container');
// Render app
ReactDOM.render(<App />, container);
</code></pre>
<p>The components/App file</p>
<pre><code>import React from 'react'
const App = () =>
<div className='container'>
<div className='row'>
</div>
<div className='row'>
</div>
</div>;
export default App;
</code></pre>
<p>My webpack.config</p>
<pre><code>const webpack = require('webpack');
const path = require('path');
module.exports = {
entry: [
'./src/app.js'
],
output: {
path: path.resolve(__dirname, './build'),
filename: 'app.bundle.js',
},
module: {
loaders: [
{
test: /\.html$/,
loader: 'file-loader?name=[name].[ext]',
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
],
},
plugins: [
new webpack.NamedModulesPlugin(),
]
};
</code></pre>
| 0debug |
how to create an sql table without using create keyword? : <p>is there any options available to create a new sql table without using 'create' keyword</p>
| 0debug |
static uint64_t master_abort_mem_read(void *opaque, hwaddr addr, unsigned size)
{
return -1ULL;
}
| 1threat |
static bool bdrv_exceed_io_limits(BlockDriverState *bs, int nb_sectors,
bool is_write, int64_t *wait)
{
int64_t now, max_wait;
uint64_t bps_wait = 0, iops_wait = 0;
double elapsed_time;
int bps_ret, iops_ret;
now = qemu_get_clock_ns(vm_clock);
if ((bs->slice_start < now)
&& (bs->slice_end > now)) {
bs->slice_end = now + BLOCK_IO_SLICE_TIME;
} else {
bs->slice_start = now;
bs->slice_end = now + BLOCK_IO_SLICE_TIME;
memset(&bs->slice_submitted, 0, sizeof(bs->slice_submitted));
}
elapsed_time = now - bs->slice_start;
elapsed_time /= (NANOSECONDS_PER_SECOND);
bps_ret = bdrv_exceed_bps_limits(bs, nb_sectors,
is_write, elapsed_time, &bps_wait);
iops_ret = bdrv_exceed_iops_limits(bs, is_write,
elapsed_time, &iops_wait);
if (bps_ret || iops_ret) {
max_wait = bps_wait > iops_wait ? bps_wait : iops_wait;
if (wait) {
*wait = max_wait;
}
now = qemu_get_clock_ns(vm_clock);
if (bs->slice_end < now + max_wait) {
bs->slice_end = now + max_wait;
}
return true;
}
if (wait) {
*wait = 0;
}
bs->slice_submitted.bytes[is_write] += (int64_t)nb_sectors *
BDRV_SECTOR_SIZE;
bs->slice_submitted.ios[is_write]++;
return false;
}
| 1threat |
static int print_drive(DeviceState *dev, Property *prop, char *dest, size_t len)
{
DriveInfo **ptr = qdev_get_prop_ptr(dev, prop);
return snprintf(dest, len, "%s", (*ptr)->id);
}
| 1threat |
How to check that an image come from the device camera HTML5 : I'm having a trouble a bit rare, at least for me.
The thing is that I'm developing a web site that simulates to be an mobile app (something like a web mobile first site) and to do this, I found around a method to open the device camera when the user click on a input file.
Until there, every works fine. The problem come when I open the web site on my laptop, where when I click the input file, instead of open the device camera, it open a file selector.
Also when I click the input file in some mobile devices, sometimes the following options appear: 1-select photo from the galery 2-open the camera
Which doesn't work for my proyect, due to it only can accept recent photos(taken at that moment).
Anybody knows how to control this?
Really thanks!!! | 0debug |
Retrieving an array from within an a JSONArray in android : I've got the following JSON String:
{
"error":false,
"message":"modules retrieved successfully",
"subjectsEnrolled":
{
"studentNumber":"PT2014-1282",
"courseId":1,
"moduleNames":["Internet Programming and E-commerce","Operating Systems","Java and Distributed Systems"]
}
}
and I would like to retrieve the values in `moduleNames`.
Current method to try and retrieve the values is:
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
try {
JSONObject object = new JSONObject(s);
JSONArray array = object.getJSONArray("moduleNames");
if (!object.getBoolean("error")) {
Toast.makeText(getActivity(), object.getString("message"), Toast.LENGTH_SHORT).show();
} else {
}
} catch (JSONException e) {
e.printStackTrace();
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
}
Followed with the following trace:
10-29 20:48:50.741 14484-14484/com.example.vhuhwavho.mylms W/System.err: org.json.JSONException: No value for moduleNames
10-29 20:48:50.741 14484-14484/com.example.vhuhwavho.mylms W/System.err: at org.json.JSONObject.get(JSONObject.java:355)
10-29 20:48:50.741 14484-14484/com.example.vhuhwavho.mylms W/System.err: at org.json.JSONObject.getJSONArray(JSONObject.java:549)
10-29 20:48:50.741 14484-14484/com.example.vhuhwavho.mylms W/System.err: at com.example.vhuhwavho.mylms.ModulesFragment$PerformNetworkRequest.onPostExecute(ModulesFragment.java:166)
10-29 20:48:50.741 14484-14484/com.example.vhuhwavho.mylms W/System.err: at com.example.vhuhwavho.mylms.ModulesFragment$PerformNetworkRequest.onPostExecute(ModulesFragment.java:137)
10-29 20:48:50.741 14484-14484/com.example.vhuhwavho.mylms W/System.err: at android.os.AsyncTask.finish(AsyncTask.java:632)
10-29 20:48:50.741 14484-14484/com.example.vhuhwavho.mylms W/System.err: at android.os.AsyncTask.access$600(AsyncTask.java:177)
10-29 20:48:50.741 14484-14484/com.example.vhuhwavho.mylms W/System.err: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
10-29 20:48:50.741 14484-14484/com.example.vhuhwavho.mylms W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
10-29 20:48:50.741 14484-14484/com.example.vhuhwavho.mylms W/System.err: at android.os.Looper.loop(Looper.java:146)
10-29 20:48:50.741 14484-14484/com.example.vhuhwavho.mylms W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5487)
10-29 20:48:50.741 14484-14484/com.example.vhuhwavho.mylms W/System.err: at java.lang.reflect.Method.invokeNative(Native Method)
10-29 20:48:50.741 14484-14484/com.example.vhuhwavho.mylms W/System.err: at java.lang.reflect.Method.invoke(Method.java:515)
10-29 20:48:50.746 14484-14484/com.example.vhuhwavho.mylms W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
10-29 20:48:50.746 14484-14484/com.example.vhuhwavho.mylms W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
10-29 20:48:50.746 14484-14484/com.example.vhuhwavho.mylms W/System.err: at dalvik.system.NativeStart.main(Native Method)
10-29 20:48:50.746 14484-14484/com.example.vhuhwavho.mylms E/JSON Parser: Error parsing data org.json.JSONException: No value for moduleNames
Any advice?
| 0debug |
Python2.7 sort list of dictionaries alphabetically by Country, value : So I have a list of dictionaries in python, called all_data, here is an example of one such dictionary in all data:
'URL: 104.214.150.216/aa.exe, IP Address: 104.214.150.216, Country: US, ASN: 8075, MD5: bdd562a14e1fb7308a92a50e7cf017de'
As you can see, it has a country in it: Country:\s(\w*)
There are over 5000 dictionaries in this list just like the one above.
I want to sort all of the lists by country alphabetical order, and then print them in order.
I am not sure where to start, any help would be greatly appreciated :)
Thanks in advance! | 0debug |
static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
int i, AVIOContext *pb, int default_stream_exists)
{
AVStream *st = s->streams[i];
AVCodecContext *codec = st->codec;
ebml_master subinfo, track;
int native_id = 0;
int qt_id = 0;
int bit_depth = av_get_bits_per_sample(codec->codec_id);
int sample_rate = codec->sample_rate;
int output_sample_rate = 0;
int display_width_div = 1;
int display_height_div = 1;
int j, ret;
AVDictionaryEntry *tag;
avpriv_set_pts_info(st, 64, 1, 1000);
if (codec->codec_type == AVMEDIA_TYPE_ATTACHMENT) {
mkv->have_attachments = 1;
return 0;
}
if (!bit_depth && codec->codec_id != AV_CODEC_ID_ADPCM_G726)
bit_depth = av_get_bytes_per_sample(codec->sample_fmt) << 3;
if (!bit_depth)
bit_depth = codec->bits_per_coded_sample;
if (codec->codec_id == AV_CODEC_ID_AAC)
get_aac_sample_rates(s, codec, &sample_rate, &output_sample_rate);
track = start_ebml_master(pb, MATROSKA_ID_TRACKENTRY, 0);
put_ebml_uint (pb, MATROSKA_ID_TRACKNUMBER,
mkv->is_dash ? mkv->dash_track_number : i + 1);
put_ebml_uint (pb, MATROSKA_ID_TRACKUID,
mkv->is_dash ? mkv->dash_track_number : i + 1);
put_ebml_uint (pb, MATROSKA_ID_TRACKFLAGLACING , 0);
if ((tag = av_dict_get(st->metadata, "title", NULL, 0)))
put_ebml_string(pb, MATROSKA_ID_TRACKNAME, tag->value);
tag = av_dict_get(st->metadata, "language", NULL, 0);
if (mkv->mode != MODE_WEBM || codec->codec_id != AV_CODEC_ID_WEBVTT) {
put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, tag && tag->value ? tag->value:"und");
} else if (tag && tag->value) {
put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, tag->value);
}
if (default_stream_exists && !(st->disposition & AV_DISPOSITION_DEFAULT))
put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGDEFAULT, !!(st->disposition & AV_DISPOSITION_DEFAULT));
if (st->disposition & AV_DISPOSITION_FORCED)
put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGFORCED, 1);
if (mkv->mode == MODE_WEBM && codec->codec_id == AV_CODEC_ID_WEBVTT) {
const char *codec_id;
if (st->disposition & AV_DISPOSITION_CAPTIONS) {
codec_id = "D_WEBVTT/CAPTIONS";
native_id = MATROSKA_TRACK_TYPE_SUBTITLE;
} else if (st->disposition & AV_DISPOSITION_DESCRIPTIONS) {
codec_id = "D_WEBVTT/DESCRIPTIONS";
native_id = MATROSKA_TRACK_TYPE_METADATA;
} else if (st->disposition & AV_DISPOSITION_METADATA) {
codec_id = "D_WEBVTT/METADATA";
native_id = MATROSKA_TRACK_TYPE_METADATA;
} else {
codec_id = "D_WEBVTT/SUBTITLES";
native_id = MATROSKA_TRACK_TYPE_SUBTITLE;
}
put_ebml_string(pb, MATROSKA_ID_CODECID, codec_id);
} else {
for (j = 0; ff_mkv_codec_tags[j].id != AV_CODEC_ID_NONE; j++) {
if (ff_mkv_codec_tags[j].id == codec->codec_id) {
put_ebml_string(pb, MATROSKA_ID_CODECID, ff_mkv_codec_tags[j].str);
native_id = 1;
break;
}
}
}
if (codec->codec_type == AVMEDIA_TYPE_AUDIO && codec->delay && codec->codec_id == AV_CODEC_ID_OPUS) {
put_ebml_uint(pb, MATROSKA_ID_CODECDELAY,
av_rescale_q(codec->delay, (AVRational){ 1, codec->sample_rate },
(AVRational){ 1, 1000000000 }));
}
if (codec->codec_id == AV_CODEC_ID_OPUS) {
put_ebml_uint(pb, MATROSKA_ID_SEEKPREROLL, OPUS_SEEK_PREROLL);
}
if (mkv->mode == MODE_WEBM && !(codec->codec_id == AV_CODEC_ID_VP8 ||
codec->codec_id == AV_CODEC_ID_VP9 ||
codec->codec_id == AV_CODEC_ID_OPUS ||
codec->codec_id == AV_CODEC_ID_VORBIS ||
codec->codec_id == AV_CODEC_ID_WEBVTT)) {
av_log(s, AV_LOG_ERROR,
"Only VP8 or VP9 video and Vorbis or Opus audio and WebVTT subtitles are supported for WebM.\n");
return AVERROR(EINVAL);
}
switch (codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_VIDEO);
if( st->avg_frame_rate.num > 0 && st->avg_frame_rate.den > 0
&& 1.0/av_q2d(st->avg_frame_rate) > av_q2d(codec->time_base))
put_ebml_uint(pb, MATROSKA_ID_TRACKDEFAULTDURATION, 1E9 / av_q2d(st->avg_frame_rate));
else
put_ebml_uint(pb, MATROSKA_ID_TRACKDEFAULTDURATION, av_q2d(codec->time_base)*1E9);
if (!native_id &&
ff_codec_get_tag(ff_codec_movvideo_tags, codec->codec_id) &&
(!ff_codec_get_tag(ff_codec_bmp_tags, codec->codec_id) ||
codec->codec_id == AV_CODEC_ID_SVQ1 ||
codec->codec_id == AV_CODEC_ID_SVQ3 ||
codec->codec_id == AV_CODEC_ID_CINEPAK))
qt_id = 1;
if (qt_id)
put_ebml_string(pb, MATROSKA_ID_CODECID, "V_QUICKTIME");
else if (!native_id) {
put_ebml_string(pb, MATROSKA_ID_CODECID, "V_MS/VFW/FOURCC");
mkv->tracks[i].write_dts = 1;
}
subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKVIDEO, 0);
put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELWIDTH , codec->width);
put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELHEIGHT, codec->height);
if ((tag = av_dict_get(st->metadata, "stereo_mode", NULL, 0)) ||
(tag = av_dict_get( s->metadata, "stereo_mode", NULL, 0))) {
int st_mode = MATROSKA_VIDEO_STEREO_MODE_COUNT;
for (j=0; j<MATROSKA_VIDEO_STEREO_MODE_COUNT; j++)
if (!strcmp(tag->value, ff_matroska_video_stereo_mode[j])){
st_mode = j;
break;
}
if (mkv_write_stereo_mode(s, pb, st_mode, mkv->mode) < 0)
return AVERROR(EINVAL);
switch (st_mode) {
case 1:
case 8:
case 9:
case 11:
display_width_div = 2;
break;
case 2:
case 3:
case 6:
case 7:
display_height_div = 2;
break;
}
}
if ((tag = av_dict_get(st->metadata, "alpha_mode", NULL, 0)) ||
(tag = av_dict_get( s->metadata, "alpha_mode", NULL, 0)) ||
(codec->pix_fmt == AV_PIX_FMT_YUVA420P)) {
put_ebml_uint(pb, MATROSKA_ID_VIDEOALPHAMODE, 1);
}
if (st->sample_aspect_ratio.num) {
int64_t d_width = av_rescale(codec->width, st->sample_aspect_ratio.num, st->sample_aspect_ratio.den);
if (d_width > INT_MAX) {
av_log(s, AV_LOG_ERROR, "Overflow in display width\n");
return AVERROR(EINVAL);
}
put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYWIDTH , d_width / display_width_div);
put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYHEIGHT, codec->height / display_height_div);
} else if (display_width_div != 1 || display_height_div != 1) {
put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYWIDTH , codec->width / display_width_div);
put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYHEIGHT, codec->height / display_height_div);
}
if (codec->codec_id == AV_CODEC_ID_RAWVIDEO) {
uint32_t color_space = av_le2ne32(codec->codec_tag);
put_ebml_binary(pb, MATROSKA_ID_VIDEOCOLORSPACE, &color_space, sizeof(color_space));
}
end_ebml_master(pb, subinfo);
break;
case AVMEDIA_TYPE_AUDIO:
put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_AUDIO);
if (!native_id)
put_ebml_string(pb, MATROSKA_ID_CODECID, "A_MS/ACM");
subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKAUDIO, 0);
put_ebml_uint (pb, MATROSKA_ID_AUDIOCHANNELS , codec->channels);
put_ebml_float (pb, MATROSKA_ID_AUDIOSAMPLINGFREQ, sample_rate);
if (output_sample_rate)
put_ebml_float(pb, MATROSKA_ID_AUDIOOUTSAMPLINGFREQ, output_sample_rate);
if (bit_depth)
put_ebml_uint(pb, MATROSKA_ID_AUDIOBITDEPTH, bit_depth);
end_ebml_master(pb, subinfo);
break;
case AVMEDIA_TYPE_SUBTITLE:
if (!native_id) {
av_log(s, AV_LOG_ERROR, "Subtitle codec %d is not supported.\n", codec->codec_id);
return AVERROR(ENOSYS);
}
if (mkv->mode != MODE_WEBM || codec->codec_id != AV_CODEC_ID_WEBVTT)
native_id = MATROSKA_TRACK_TYPE_SUBTITLE;
put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, native_id);
break;
default:
av_log(s, AV_LOG_ERROR, "Only audio, video, and subtitles are supported for Matroska.\n");
return AVERROR(EINVAL);
}
if (mkv->mode != MODE_WEBM || codec->codec_id != AV_CODEC_ID_WEBVTT) {
ret = mkv_write_codecprivate(s, pb, codec, native_id, qt_id);
if (ret < 0)
return ret;
}
end_ebml_master(pb, track);
return 0;
}
| 1threat |
What is the use of encapsulation parameter in component portion in angular js 2 : Kindly explain the `encapsulation` parameter in angular js 2. when i add this parameter i have some error message. how can i remove it.
@Component({
selector: 'app-add',
templateUrl: './add.component.html',
styleUrls: ['./add.component.css'],
encapsulation: ViewEncapsulation.None
}) | 0debug |
PLSQL DYNAMIC INSERTION : I have a TABLE_A,which contains a column with comma separeted values as data,now i have to put these comma separated values into TABLE B of 250 columns,this has to be done dynamically? | 0debug |
def get_ludic(n):
ludics = []
for i in range(1, n + 1):
ludics.append(i)
index = 1
while(index != len(ludics)):
first_ludic = ludics[index]
remove_index = index + first_ludic
while(remove_index < len(ludics)):
ludics.remove(ludics[remove_index])
remove_index = remove_index + first_ludic - 1
index += 1
return ludics | 0debug |
static int local_name_to_path(FsContext *ctx, V9fsPath *dir_path,
const char *name, V9fsPath *target)
{
if (dir_path) {
v9fs_path_sprintf(target, "%s/%s", dir_path->data, name);
} else {
v9fs_path_sprintf(target, "%s", name);
}
return 0;
}
| 1threat |
Bootstrap overriding my custom css : <p>I am creating a website for an internship I'm in at the moment and we opted to include a drop-down navbar. The navbar works fine, but the css involved seems to be overriding my custom css as it applies to my html tag background colour and my h1 tag fonts, sizes, colours, etc. any suggestions? screenshots attached. <a href="https://i.stack.imgur.com/VCj8c.png" rel="nofollow noreferrer">Sample w/o navbar</a><a href="https://i.stack.imgur.com/Wcc2p.png" rel="nofollow noreferrer">sample with navbar</a></p>
| 0debug |
How to get url from parameter using Javascript/ jQuery : <p>I was trying to make a site just like <a href="https://null-24.com/download/?link=" rel="nofollow noreferrer">https://null-24.com/download/?link=</a>"Your site"</p>
<p>if i enter <a href="https://null-24.com/download/?link=https://www.instandroid.net" rel="nofollow noreferrer">https://null-24.com/download/?link=https://www.instandroid.net</a>
then the download button will take me <a href="https://www.instandroid.net/" rel="nofollow noreferrer">https://www.instandroid.net/</a> when i click. </p>
<p><a href="https://i.stack.imgur.com/b9q62.png" rel="nofollow noreferrer">Download button</a>
How can i write the function for this?</p>
| 0debug |
static inline uint8_t *ram_chunk_end(const RDMALocalBlock *rdma_ram_block,
uint64_t i)
{
uint8_t *result = ram_chunk_start(rdma_ram_block, i) +
(1UL << RDMA_REG_CHUNK_SHIFT);
if (result > (rdma_ram_block->local_host_addr + rdma_ram_block->length)) {
result = rdma_ram_block->local_host_addr + rdma_ram_block->length;
}
return result;
}
| 1threat |
static av_cold void construct_perm_table(TwinContext *tctx,enum FrameType ftype)
{
int block_size;
const ModeTab *mtab = tctx->mtab;
int size = tctx->avctx->channels*mtab->fmode[ftype].sub;
int16_t *tmp_perm = (int16_t *) tctx->tmp_buf;
if (ftype == FT_PPC) {
size = tctx->avctx->channels;
block_size = mtab->ppc_shape_len;
} else
block_size = mtab->size / mtab->fmode[ftype].sub;
permutate_in_line(tmp_perm, tctx->n_div[ftype], size,
block_size, tctx->length[ftype],
tctx->length_change[ftype], ftype);
transpose_perm(tctx->permut[ftype], tmp_perm, tctx->n_div[ftype],
tctx->length[ftype], tctx->length_change[ftype]);
linear_perm(tctx->permut[ftype], tctx->permut[ftype], size,
size*block_size);
}
| 1threat |
Android studio grid layout don't show any view : I have a grid layout that is a child of another layout (like frame layout or constraint layout ) . I drag and drop views on it like button or image view but it didn't show !! . How can i fix this problem ?
[pic1][1]
[pic2][2]
[1]: https://i.stack.imgur.com/xYbyQ.png
[2]: https://i.stack.imgur.com/YN8Ws.png | 0debug |
static int r3d_read_redv(AVFormatContext *s, AVPacket *pkt, Atom *atom)
{
AVStream *st = s->streams[0];
int tmp;
int av_unused tmp2;
uint64_t pos = avio_tell(s->pb);
unsigned dts;
int ret;
dts = avio_rb32(s->pb);
tmp = avio_rb32(s->pb);
av_dlog(s, "frame num %d\n", tmp);
tmp = avio_r8(s->pb);
tmp2 = avio_r8(s->pb);
av_dlog(s, "version %d.%d\n", tmp, tmp2);
tmp = avio_rb16(s->pb);
av_dlog(s, "unknown %d\n", tmp);
if (tmp > 4) {
tmp = avio_rb16(s->pb);
av_dlog(s, "unknown %d\n", tmp);
tmp = avio_rb16(s->pb);
av_dlog(s, "unknown %d\n", tmp);
tmp = avio_rb32(s->pb);
av_dlog(s, "width %d\n", tmp);
tmp = avio_rb32(s->pb);
av_dlog(s, "height %d\n", tmp);
tmp = avio_rb32(s->pb);
av_dlog(s, "metadata len %d\n", tmp);
}
tmp = atom->size - 8 - (avio_tell(s->pb) - pos);
if (tmp < 0)
return -1;
ret = av_get_packet(s->pb, pkt, tmp);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "error reading video packet\n");
return -1;
}
pkt->stream_index = 0;
pkt->dts = dts;
if (st->avg_frame_rate.num)
pkt->duration = (uint64_t)st->time_base.den*
st->avg_frame_rate.den/st->avg_frame_rate.num;
av_dlog(s, "pkt dts %"PRId64" duration %d\n", pkt->dts, pkt->duration);
return 0;
}
| 1threat |
static void do_video_out(AVFormatContext *s,
OutputStream *ost,
AVFrame *next_picture,
double sync_ipts)
{
int ret, format_video_sync;
AVPacket pkt;
AVCodecContext *enc = ost->enc_ctx;
AVCodecContext *mux_enc = ost->st->codec;
int nb_frames, nb0_frames, i;
double delta, delta0;
double duration = 0;
int frame_size = 0;
InputStream *ist = NULL;
AVFilterContext *filter = ost->filter->filter;
if (ost->source_index >= 0)
ist = input_streams[ost->source_index];
if (filter->inputs[0]->frame_rate.num > 0 &&
filter->inputs[0]->frame_rate.den > 0)
duration = 1/(av_q2d(filter->inputs[0]->frame_rate) * av_q2d(enc->time_base));
if(ist && ist->st->start_time != AV_NOPTS_VALUE && ist->st->first_dts != AV_NOPTS_VALUE && ost->frame_rate.num)
duration = FFMIN(duration, 1/(av_q2d(ost->frame_rate) * av_q2d(enc->time_base)));
if (!ost->filters_script &&
!ost->filters &&
next_picture &&
ist &&
lrintf(av_frame_get_pkt_duration(next_picture) * av_q2d(ist->st->time_base) / av_q2d(enc->time_base)) > 0) {
duration = lrintf(av_frame_get_pkt_duration(next_picture) * av_q2d(ist->st->time_base) / av_q2d(enc->time_base));
}
if (!next_picture) {
nb0_frames = nb_frames = mid_pred(ost->last_nb0_frames[0],
ost->last_nb0_frames[1],
ost->last_nb0_frames[2]);
} else {
delta0 = sync_ipts - ost->sync_opts;
delta = delta0 + duration;
nb0_frames = 0;
nb_frames = 1;
format_video_sync = video_sync_method;
if (format_video_sync == VSYNC_AUTO) {
if(!strcmp(s->oformat->name, "avi")) {
format_video_sync = VSYNC_VFR;
} else
format_video_sync = (s->oformat->flags & AVFMT_VARIABLE_FPS) ? ((s->oformat->flags & AVFMT_NOTIMESTAMPS) ? VSYNC_PASSTHROUGH : VSYNC_VFR) : VSYNC_CFR;
if ( ist
&& format_video_sync == VSYNC_CFR
&& input_files[ist->file_index]->ctx->nb_streams == 1
&& input_files[ist->file_index]->input_ts_offset == 0) {
format_video_sync = VSYNC_VSCFR;
}
if (format_video_sync == VSYNC_CFR && copy_ts) {
format_video_sync = VSYNC_VSCFR;
}
}
if (delta0 < 0 &&
delta > 0 &&
format_video_sync != VSYNC_PASSTHROUGH &&
format_video_sync != VSYNC_DROP) {
double cor = FFMIN(-delta0, duration);
if (delta0 < -0.6) {
av_log(NULL, AV_LOG_WARNING, "Past duration %f too large\n", -delta0);
} else
av_log(NULL, AV_LOG_DEBUG, "Cliping frame in rate conversion by %f\n", -delta0);
sync_ipts += cor;
duration -= cor;
delta0 += cor;
}
switch (format_video_sync) {
case VSYNC_VSCFR:
if (ost->frame_number == 0 && delta - duration >= 0.5) {
av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta - duration));
delta = duration;
delta0 = 0;
ost->sync_opts = lrint(sync_ipts);
}
case VSYNC_CFR:
if (frame_drop_threshold && delta < frame_drop_threshold && ost->frame_number) {
nb_frames = 0;
} else if (delta < -1.1)
nb_frames = 0;
else if (delta > 1.1) {
nb_frames = lrintf(delta);
if (delta0 > 1.1)
nb0_frames = lrintf(delta0 - 0.6);
}
break;
case VSYNC_VFR:
if (delta <= -0.6)
nb_frames = 0;
else if (delta > 0.6)
ost->sync_opts = lrint(sync_ipts);
break;
case VSYNC_DROP:
case VSYNC_PASSTHROUGH:
ost->sync_opts = lrint(sync_ipts);
break;
default:
av_assert0(0);
}
}
nb_frames = FFMIN(nb_frames, ost->max_frames - ost->frame_number);
nb0_frames = FFMIN(nb0_frames, nb_frames);
memmove(ost->last_nb0_frames + 1,
ost->last_nb0_frames,
sizeof(ost->last_nb0_frames[0]) * (FF_ARRAY_ELEMS(ost->last_nb0_frames) - 1));
ost->last_nb0_frames[0] = nb0_frames;
if (nb0_frames == 0 && ost->last_droped) {
nb_frames_drop++;
av_log(NULL, AV_LOG_VERBOSE,
"*** dropping frame %d from stream %d at ts %"PRId64"\n",
ost->frame_number, ost->st->index, ost->last_frame->pts);
}
if (nb_frames > (nb0_frames && ost->last_droped) + (nb_frames > nb0_frames)) {
if (nb_frames > dts_error_threshold * 30) {
av_log(NULL, AV_LOG_ERROR, "%d frame duplication too large, skipping\n", nb_frames - 1);
nb_frames_drop++;
return;
}
nb_frames_dup += nb_frames - (nb0_frames && ost->last_droped) - (nb_frames > nb0_frames);
av_log(NULL, AV_LOG_VERBOSE, "*** %d dup!\n", nb_frames - 1);
}
ost->last_droped = nb_frames == nb0_frames && next_picture;
for (i = 0; i < nb_frames; i++) {
AVFrame *in_picture;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
if (i < nb0_frames && ost->last_frame) {
in_picture = ost->last_frame;
} else
in_picture = next_picture;
if (!in_picture)
return;
in_picture->pts = ost->sync_opts;
#if 1
if (!check_recording_time(ost))
#else
if (ost->frame_number >= ost->max_frames)
#endif
return;
if (s->oformat->flags & AVFMT_RAWPICTURE &&
enc->codec->id == AV_CODEC_ID_RAWVIDEO) {
if (in_picture->interlaced_frame)
mux_enc->field_order = in_picture->top_field_first ? AV_FIELD_TB:AV_FIELD_BT;
else
mux_enc->field_order = AV_FIELD_PROGRESSIVE;
pkt.data = (uint8_t *)in_picture;
pkt.size = sizeof(AVPicture);
pkt.pts = av_rescale_q(in_picture->pts, enc->time_base, ost->st->time_base);
pkt.flags |= AV_PKT_FLAG_KEY;
write_frame(s, &pkt, ost);
} else {
int got_packet, forced_keyframe = 0;
double pts_time;
if (enc->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME) &&
ost->top_field_first >= 0)
in_picture->top_field_first = !!ost->top_field_first;
if (in_picture->interlaced_frame) {
if (enc->codec->id == AV_CODEC_ID_MJPEG)
mux_enc->field_order = in_picture->top_field_first ? AV_FIELD_TT:AV_FIELD_BB;
else
mux_enc->field_order = in_picture->top_field_first ? AV_FIELD_TB:AV_FIELD_BT;
} else
mux_enc->field_order = AV_FIELD_PROGRESSIVE;
in_picture->quality = enc->global_quality;
in_picture->pict_type = 0;
pts_time = in_picture->pts != AV_NOPTS_VALUE ?
in_picture->pts * av_q2d(enc->time_base) : NAN;
if (ost->forced_kf_index < ost->forced_kf_count &&
in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
ost->forced_kf_index++;
forced_keyframe = 1;
} else if (ost->forced_keyframes_pexpr) {
double res;
ost->forced_keyframes_expr_const_values[FKF_T] = pts_time;
res = av_expr_eval(ost->forced_keyframes_pexpr,
ost->forced_keyframes_expr_const_values, NULL);
av_dlog(NULL, "force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n",
ost->forced_keyframes_expr_const_values[FKF_N],
ost->forced_keyframes_expr_const_values[FKF_N_FORCED],
ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N],
ost->forced_keyframes_expr_const_values[FKF_T],
ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T],
res);
if (res) {
forced_keyframe = 1;
ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] =
ost->forced_keyframes_expr_const_values[FKF_N];
ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] =
ost->forced_keyframes_expr_const_values[FKF_T];
ost->forced_keyframes_expr_const_values[FKF_N_FORCED] += 1;
}
ost->forced_keyframes_expr_const_values[FKF_N] += 1;
} else if ( ost->forced_keyframes
&& !strncmp(ost->forced_keyframes, "source", 6)
&& in_picture->key_frame==1) {
forced_keyframe = 1;
}
if (forced_keyframe) {
in_picture->pict_type = AV_PICTURE_TYPE_I;
av_log(NULL, AV_LOG_DEBUG, "Forced keyframe at time %f\n", pts_time);
}
update_benchmark(NULL);
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "encoder <- type:video "
"frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
av_ts2str(in_picture->pts), av_ts2timestr(in_picture->pts, &enc->time_base),
enc->time_base.num, enc->time_base.den);
}
ost->frames_encoded++;
ret = avcodec_encode_video2(enc, &pkt, in_picture, &got_packet);
update_benchmark("encode_video %d.%d", ost->file_index, ost->index);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Video encoding failed\n");
exit_program(1);
}
if (got_packet) {
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "encoder -> type:video "
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &enc->time_base),
av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &enc->time_base));
}
if (pkt.pts == AV_NOPTS_VALUE && !(enc->codec->capabilities & CODEC_CAP_DELAY))
pkt.pts = ost->sync_opts;
av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base);
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "encoder -> type:video "
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ost->st->time_base),
av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->st->time_base));
}
frame_size = pkt.size;
write_frame(s, &pkt, ost);
if (ost->logfile && enc->stats_out) {
fprintf(ost->logfile, "%s", enc->stats_out);
}
}
}
ost->sync_opts++;
ost->frame_number++;
if (vstats_filename && frame_size)
do_video_stats(ost, frame_size);
}
if (!ost->last_frame)
ost->last_frame = av_frame_alloc();
av_frame_unref(ost->last_frame);
if (next_picture)
av_frame_ref(ost->last_frame, next_picture);
else
av_frame_free(&ost->last_frame);
}
| 1threat |
What is the difference between Component, Behaviour and MonoBehaviour? And why these are separated? : <p>MonoBehaviour extends Behaviour and Behaviour extends Component.
I want to know why these classes are separated and semantic meanings of these classes.
Are there any purpose to separate these classes? And are there any classes extending Behaviour or Component directly?</p>
<p>I know we must use MonoBehaviour to create C# codes in Unity.
However, I'm interesting in architecture of Unity as a game engine.</p>
| 0debug |
static uint32_t get_generic_seed(void)
{
uint8_t tmp[120];
struct AVSHA *sha = (void*)tmp;
clock_t last_t = 0;
static uint64_t i = 0;
static uint32_t buffer[512] = { 0 };
unsigned char digest[20];
uint64_t last_i = i;
av_assert0(sizeof(tmp) >= av_sha_size);
if(TEST){
memset(buffer, 0, sizeof(buffer));
last_i = i = 0;
}else{
#ifdef AV_READ_TIME
buffer[13] ^= AV_READ_TIME();
buffer[41] ^= AV_READ_TIME()>>32;
#endif
}
for (;;) {
clock_t t = clock();
if (last_t == t) {
buffer[i & 511]++;
} else {
buffer[++i & 511] += (t - last_t) % 3294638521U;
if (last_i && i - last_i > 4 || i - last_i > 64 || TEST && i - last_i > 8)
break;
}
last_t = t;
}
if(TEST)
buffer[0] = buffer[1] = 0;
av_sha_init(sha, 160);
av_sha_update(sha, (const uint8_t *)buffer, sizeof(buffer));
av_sha_final(sha, digest);
return AV_RB32(digest) + AV_RB32(digest + 16);
}
| 1threat |
static int64_t *concat_channels_lists(const int64_t *layouts, const int *counts)
{
int nb_layouts = 0, nb_counts = 0, i;
int64_t *list;
if (layouts)
for (; layouts[nb_layouts] != -1; nb_layouts++);
if (counts)
for (; counts[nb_counts] != -1; nb_counts++);
if (nb_counts > INT_MAX - 1 - nb_layouts)
return NULL;
if (!(list = av_calloc(nb_layouts + nb_counts + 1, sizeof(*list))))
return NULL;
for (i = 0; i < nb_layouts; i++)
list[i] = layouts[i];
for (i = 0; i < nb_counts; i++)
list[nb_layouts + i] = FF_COUNT2LAYOUT(counts[i]);
list[nb_layouts + nb_counts] = -1;
return list;
}
| 1threat |
static void syborg_virtio_writel(void *opaque, target_phys_addr_t offset,
uint32_t value)
{
SyborgVirtIOProxy *s = opaque;
VirtIODevice *vdev = s->vdev;
DPRINTF("writel 0x%x = 0x%x\n", (int)offset, value);
if (offset >= SYBORG_VIRTIO_CONFIG) {
return virtio_config_writel(vdev, offset - SYBORG_VIRTIO_CONFIG,
value);
}
switch (offset >> 2) {
case SYBORG_VIRTIO_GUEST_FEATURES:
if (vdev->set_features)
vdev->set_features(vdev, value);
vdev->guest_features = value;
break;
case SYBORG_VIRTIO_QUEUE_BASE:
if (value == 0)
virtio_reset(vdev);
else
virtio_queue_set_addr(vdev, vdev->queue_sel, value);
break;
case SYBORG_VIRTIO_QUEUE_SEL:
if (value < VIRTIO_PCI_QUEUE_MAX)
vdev->queue_sel = value;
break;
case SYBORG_VIRTIO_QUEUE_NOTIFY:
virtio_queue_notify(vdev, value);
break;
case SYBORG_VIRTIO_STATUS:
virtio_set_status(vdev, value & 0xFF);
if (vdev->status == 0)
virtio_reset(vdev);
break;
case SYBORG_VIRTIO_INT_ENABLE:
s->int_enable = value;
virtio_update_irq(vdev);
break;
case SYBORG_VIRTIO_INT_STATUS:
vdev->isr &= ~value;
virtio_update_irq(vdev);
break;
default:
BADF("Bad write offset 0x%x\n", (int)offset);
break;
}
}
| 1threat |
how to do the activat route in angular? : My url
http://xx.xx.xxx.xxx:xxxx/#/Test?name=7779394
how can i get '7779394'?
i tried the follow code:
this.activatedRoute.queryParams.subscribe(params => {
this.ind = params.name;
console.log("this.ind " + params.name);
});
but the result is undefined first, after undefined, the function run again
and god 7779394
but it should run one time only
how to fix this ? | 0debug |
Not able to add Intent in menifest : I want to add intent to differebt values of the navigation drawer but i am getting an error
> java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.tanis.myapplication/com.example.tanis.myapplication.MenuItems.Home}: java.lang.ClassCastException: com.example.tanis.myapplication.MenuItems.Home cannot be cast to android.app.Activity
please help
package com.example.tanis.myapplication.MenuItems;
/**
* Created by tanis on 27-06-2018.
*/
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import com.example.tanis.myapplication.Adapters.CardItemString;
import com.example.tanis.myapplication.Adapters.CardPagerAdapterS;
import com.example.tanis.myapplication.Adapters.ViewPagerAdapter;
import com.example.tanis.myapplication.R;
import com.example.tanis.myapplication.Services.website_designing;
import java.util.Timer;
import java.util.TimerTask;
public class Home extends Fragment {
ViewPager mViewPager;
CardPagerAdapterS mCardAdapter;
ShadowTransformer mCardShadowTransformer;
private Context context;
ViewPager viewPager;
String titlesText [] = {" Website Design", " Digital Marketing", " Domain Registration", "Graphics Design", " Mobile Apps", " Server Hosting",
" Software Development", " Content Marketing", " Security (SSl)"};
String detailsArray [] = {
"Your website is your digital home. We create, design, redesign, develop, improvise, and implement. We make beautiful websites",
"We help your business reach potential customers on every possible digital device through all possible media channels ",
"To launch your website the first thing you need is the domain name. You can choose your domain name with us here ",
"We generate creative solutions and can create a wide range of graphic for your clients which match their business ",
"We are mobile. And we make you mobile. We make responsive websites and mobile apps which compliment your business ",
"When you are hosting your website in the India you will benefit from a higher ping rate and lowest latency ",
"Our team is competent at coding web apps with keen attention to detail & intuitive functionality that is high on design & creativity",
"Content is the heart of your digital presence. We create the right content with the right focus for your business",
"Secure your site with the world's leading provider of online security and get these exclusive features at no added cost",
};
int[] images = {R.drawable.website_design, R.drawable.digita,R.drawable.domain_registration,R.drawable.gric,
R.drawable.mob,R.drawable.server,R.drawable.software_development,R.drawable.ontent,R.drawable.ssl};
public Home() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment.
*
* @return A new instance of fragment FragmentAction.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
View v = inflater.inflate(R.layout.home,container,false);
TextView txt = (TextView)v.findViewById( R.id.textView12 );
txt.setText("\u25BA Creative & Dedicated Team");
TextView txt1 = (TextView)v.findViewById( R.id.textView13 );
txt1.setText("\u25BA Affordable Cost");
TextView txt2 = (TextView)v.findViewById( R.id.textView14 );
txt2.setText("\u25BA Maintain Long Relationship");
TextView txt3 = (TextView)v.findViewById( R.id.textView15 );
txt3.setText("\u25BA Timely Deliverly ");
context = this.getContext();
Button b = (Button) v.findViewById( R.id.button7 ) ;
b.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent( getActivity(), website_designing.class);
}
} );
mViewPager = (ViewPager)v.findViewById(R.id.viewpager1);
mCardAdapter = new CardPagerAdapterS();
for (int i=0; i<titlesText.length; i++){
mCardAdapter.addCardItemS(new CardItemString( titlesText[i], detailsArray[i],images[i]));
}
mCardShadowTransformer = new ShadowTransformer(mViewPager, mCardAdapter);
mViewPager.setAdapter(mCardAdapter);
mViewPager.setPageTransformer(false, mCardShadowTransformer);
mViewPager.setOffscreenPageLimit(3);
viewPager = (ViewPager)v.findViewById( R.id.viewpager );
ViewPagerAdapter viewPagerAdapter = new ViewPagerAdapter( this.getContext() );
viewPager.setAdapter( viewPagerAdapter );
Timer timer = new Timer( );
timer.scheduleAtFixedRate( new Mytime(),2000,4000 );
FloatingActionButton floatingActionButton = (FloatingActionButton)v.findViewById( R.id.floatingActionButton );
floatingActionButton.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity( new Intent( getActivity(),Registration.class ) );
}
} );
return v;
}
public class Mytime extends TimerTask {
@Override
public void run() {
getActivity().runOnUiThread( new Runnable() {
@Override
public void run() {
if(viewPager.getCurrentItem() == 0) {
viewPager.setCurrentItem( 1 );
}
else if (viewPager.getCurrentItem()== 1){
viewPager.setCurrentItem( 2 );
}
else if (viewPager.getCurrentItem()== 2){
viewPager.setCurrentItem( 3 );
}
else if (viewPager.getCurrentItem()== 3){
viewPager.setCurrentItem( 4 );
}
else {
viewPager.setCurrentItem(0);
}
}
} );
}
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
}
| 0debug |
Efficient table comarison : What is the best way to find way to select values present in one table but not in other - left join,not in or not exists.
There probably isn't a universal answer - so would appreciate the used-case where each is advisable.
| 0debug |
How to run NUnit test in Visual Studio Team Services : <p>When I try to execute <strong>NUnit</strong> test in VSTS task I am getting the following error:</p>
<pre><code>Warning: The path 'C:\a\1\s\INCASOL.IP\packages' specified in the 'TestAdapterPath' does not contain any test adapters, provide a valid path and try again.
</code></pre>
<p>I have these tasks in VSTS:</p>
<p><a href="https://i.stack.imgur.com/pEPFo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pEPFo.png" alt="enter image description here"></a></p>
<p>The "Run unit test" task is configured as follows:
<a href="https://i.stack.imgur.com/9g8Ix.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9g8Ix.png" alt="enter image description here"></a></p>
<p>Note I have set the "Path to Custom Test Adapters".</p>
<p>I think the dlls for NUnit are properly copied to packages folder because in "Nuget restore" task I can see the following:</p>
<pre><code>Added package 'NUnit.2.6.4' to folder 'C:\a\1\s\INCASOL.IP\packages'
</code></pre>
<p>Notes: The NUnit version is 2.6.4 and I'm using Hosted Agent</p>
| 0debug |
How to get "Manage User Secrets" in a .NET Core console-application? : <p>When I create a new ASP .NET Core <strong>Web</strong>-Application, I can right-click the project in Visual Studio, and I see a context-menu entry called "Manage User Secrets". </p>
<p>When I create a new .NET Core <strong>Console</strong>-Application, I don't see this context-menu entry. </p>
<p>However, a "Web"-Application shows as "console" application in the project settings. Is there any way I can get this context-menu entry in a console-application ? </p>
| 0debug |
How to check a condition in android alwaysly? : i want to develop an app to change device audio status , if that is silent change it with a button to Normal and so on.
i Want to check Audio Status of device in my app always and if device is silent change my button text to silent and if it was normal , change it to normal.
here is my only class :
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button btn1= (Button) findViewById(R.id.btn1);
final AudioManager audio = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
if (audio.getRingerMode()==AudioManager.RINGER_MODE_NORMAL)
{
btn1.setText("Normal");
}
else if (audio.getRingerMode()==AudioManager.RINGER_MODE_SILENT)
{
btn1.setText("Silent");
}
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (audio.getRingerMode()==AudioManager.RINGER_MODE_NORMAL)
{
audio.setRingerMode(AudioManager.RINGER_MODE_SILENT);
btn1.setText("Silent");
}
else if (audio.getRingerMode()==AudioManager.RINGER_MODE_SILENT)
{
audio.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
btn1.setText("Normal");
}
}
});
}
});
how i can check this condition always in android ? | 0debug |
How to decode Base64 URL safe? : <p>I need to decode a value from Base64 URL safe, what is best approach to do that? </p>
<p>I didn't find any good solution over the web, and I also have no code which I built myself. </p>
| 0debug |
opening a file gives not expexted return value : could someone please explain me, why file opening is not successful? why printing "file" will give -1? Is it a problem with char *source ?
int opf(char *source){
int file;
file=open(source,O_RWR);
printf("%d",file);
}
And is it possible to do something like this:
file is in another directory, so
int opf(char *source){
int file;
file=open("some_directory/ %s",source,O_RWR);
printf("%d",file);
}
here I get the "makes integer from pointer without a cast" error. I tried many different things but i guess the problem lies with me not grasping correctly the concept of pointers.
I am making some basic mistakes here . So, sorry if I do offend someone with this bad coding.
with best regards | 0debug |
static void rtl8139_transfer_frame(RTL8139State *s, const uint8_t *buf, int size, int do_interrupt)
{
if (!size)
{
DEBUG_PRINT(("RTL8139: +++ empty ethernet frame\n"));
return;
}
if (TxLoopBack == (s->TxConfig & TxLoopBack))
{
DEBUG_PRINT(("RTL8139: +++ transmit loopback mode\n"));
rtl8139_do_receive(s, buf, size, do_interrupt);
}
else
{
qemu_send_packet(s->vc, buf, size);
}
}
| 1threat |
Java J-Date Choosers cannot be resolved : my datechoosers are coming up as if they don't exist and I'm very confused what im doing wrong :( I originally had textfields for dates then swapped them to jdatechoosers and this is coming up for both areas(ignore that it says arrival time and departure time instead of departure date, it just needs to be updated - https://i.imgur.com/yy2HOCP.png
private Flight getinputFlightData() {
if (textField_FlightId.getText().isEmpty())
return null;
int flightID = Integer.parseInt(textField_FlightId.getText());
String departureAirport = textField_departureAirport.getText();
String arrivalAirport = textField_arrivalAirport.getText();
Date departureTime = dc_departureDate.getDate();
Date arrivalTime = dc_arrivalDate.getDate();;
short flightSeats = Byte.parseByte(textField_FlightSeats.getText());
float flightPrice = Float.parseFloat(textField_FlightPrice.getText());
boolean isDelayed = Boolean.parseBoolean(textField_isDelayed.getText());
Flight flight = new Flight(flightID, departureAirport, arrivalAirport, departureTime, arrivalTime, flightSeats, flightPrice, isDelayed);
return flight;
} | 0debug |
Convert dd-MON-yyyy to julian date : I want to convert dd-MON-yyyy to Julian date as part of SQL query. It would be of great help if anyone could guide on how to achieve this.
new JulianDate().ConvertToJulian(date1) worked when date1 was in mm/dd/yyyy format. But when date1 is in dd-MON-yyyy format i get the error:
java.text.ParseException: Unparseable date: "16-Mar-2017"
| 0debug |
i have written the code(vim ubuntu) correct but on HACKERS EARTH it is showing compilation error : #include<stdio.h>
main(){
int n;
scanf("%d",&n);
int zz,count;
int i=5;
while(zz>=1)
{
zz=n/i;
count+=zz;
i=i*5;
}
printf("%d",count);
}
code to find trailling 0's in factorial of a number.
giving different output in ubuntu n codeblocks[windows].
| 0debug |
sql query to delete data from 2 tables : currently trying to accomplish the following task adn i using this sql to doit but still not working
'' DoCmd.RunSQL " delete tbl_siphon_req_info.* from tbl_siphon_req_info a, tbl_siphon_PO b where concat(a.ross_PO_nbr, a.ross_sku12) = Concat(b.PO_ID, Sbstr(bitem_id,1,12))"
if any one can help me to correct and complete what i need to do... thanks
| 0debug |
static void tcg_reg_sync(TCGContext *s, TCGReg reg, TCGRegSet allocated_regs)
{
TCGTemp *ts = s->reg_to_temp[reg];
assert(ts->val_type == TEMP_VAL_REG);
if (!ts->mem_coherent && !ts->fixed_reg) {
if (!ts->mem_allocated) {
temp_allocate_frame(s, temp_idx(s, ts));
} else if (ts->indirect_reg) {
tcg_regset_set_reg(allocated_regs, ts->reg);
temp_load(s, ts->mem_base,
tcg_target_available_regs[TCG_TYPE_PTR],
allocated_regs);
}
tcg_out_st(s, ts->type, reg, ts->mem_base->reg, ts->mem_offset);
}
ts->mem_coherent = 1;
}
| 1threat |
Filter text file with another text file using php : I have got two text files and i need to filter file1 with file2 and put the results in file3.
file1:
1232131-72-427-Q john johnson -----more data----------more data-----<br>
8765438-43-542-T peter dudeson -----more data----- -----more data-----<br>
3456761-21-742-G frank zena -----more data----------more data-----<br>
0924560-23-124-O marin franklin -----more data----------more data-----<br>
2345333-21-423-P pin dudeson-----more data----------more data-----<br>
5434225-21-983-A chow ching -----more data----------more data-----
file2:<br>
8765438-43-542-T<br>
0924560-23-124-O<br>
5434225-21-983-A
outputfile:<br>
8765438-43-542-T peter dudeson-----more data----------more data----- <br>
0924560-23-124-O marin franklin-----more data----------more data----- <br>
5434225-21-983-A chow ching-----more data----------more data-----
so basically it has to check the numbers+oneletter and delete all the lines that do not match and keep the full lines that do match. I hope someone helps me with this because im stuck on it for way too long now. | 0debug |
static void vp8_decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata,
int jobnr, int threadnr)
{
decode_mb_row_no_filter(avctx, tdata, jobnr, threadnr, 0);
}
| 1threat |
I want to Add a column that show the record number sequence : <p>I want to search top 5 salary from record that i have done but i want another column that contain the number sequence of these salaries like who is at number One and who is at number second and so on </p>
| 0debug |
nodeJs - can't acces required properties : <p>I have 2 separate files - the main script file and config.js located in the same folder.</p>
<p>I then require the config.js as a variable, and try to access it's url property, but somehow it does not get injected properly. What am I doing wrong?</p>
<p>If I define a local variable with the url, and pass it into my function everything works as expected.</p>
<p>main.js:</p>
<pre><code>//import configuration
var config = ("./config.js");
casper.start(config.url);
</code></pre>
<p>config.js</p>
<pre><code>module.exports = {
url: 'http://stage2.btobet.net/en',
credentials: [{ user: 'Tester', password: '' },
{ user: 'Automat', password: '' }]
};
</code></pre>
<p>Thanks for the help.</p>
| 0debug |
def last(arr,x,n):
low = 0
high = n - 1
res = -1
while (low <= high):
mid = (low + high) // 2
if arr[mid] > x:
high = mid - 1
elif arr[mid] < x:
low = mid + 1
else:
res = mid
low = mid + 1
return res | 0debug |
void cpu_check_irqs(CPUState *env)
{
uint32_t pil = env->pil_in | (env->softint & ~SOFTINT_TIMER) |
((env->softint & SOFTINT_TIMER) << 14);
if (pil && (env->interrupt_index == 0 ||
(env->interrupt_index & ~15) == TT_EXTINT)) {
unsigned int i;
for (i = 15; i > 0; i--) {
if (pil & (1 << i)) {
int old_interrupt = env->interrupt_index;
env->interrupt_index = TT_EXTINT | i;
if (old_interrupt != env->interrupt_index) {
CPUIRQ_DPRINTF("Set CPU IRQ %d\n", i);
cpu_interrupt(env, CPU_INTERRUPT_HARD);
}
break;
}
}
} else if (!pil && (env->interrupt_index & ~15) == TT_EXTINT) {
CPUIRQ_DPRINTF("Reset CPU IRQ %d\n", env->interrupt_index & 15);
env->interrupt_index = 0;
cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
}
}
| 1threat |
how to change value of a var in reverse geocoding function : <p>I am trying to get address info for my project. I can see the address by alert() method if i write it inside the geocode function. but if i outside of the function, it returns <strong>undefined</strong>. </p>
<p>tried to write the variable name like <strong>window.adres</strong> but didnt work. i think because of an another function with is parent of this.</p>
<p>how to make that variable global and change the value? </p>
<pre><code>var geocoder = new google.maps.Geocoder;
var adres;
var latlng = {lat: parseFloat(lat), lng: parseFloat(lon)};
geocoder.geocode({'location': latlng}, function(results, status) {
if (status === 'OK') {
if (results[0]) {
adres = results[0].formatted_address;
//window.adres = ... is not working. i think because of an another function which is parent of these lines.
alert(adres); //returns address
}
} else {
window.alert('Geocoder failed due to: ' + status);
}
alert(adres); //returns undefined
</code></pre>
<p>also i tried that</p>
<pre><code>var geocoder = new google.maps.Geocoder;
var latlng = {lat: parseFloat(lat), lng: parseFloat(lon)};
var adres = geocoder.geocode({'location': latlng}, function(results, status) {
if (status === 'OK') {
if (results[0]) {
return results[0].formatted_address;
}
} else {
window.alert('Geocoder failed due to: ' + status);
}
alert(adres); //returns undefined too
</code></pre>
| 0debug |
cannot access rules in external CSSStyleSheet : <p>I am having trouble figuring out why <code>.cssRules</code> and <code>.rules</code> won't work in my simplistic color generator project.</p>
<p>I have a <code><link></code> element to link my external CSS file:</p>
<pre><code><link href="ColorGenerator.css" type="text/css" rel="stylesheet">
</code></pre>
<p>And a <code><script></code> element to link my external JS file before the <code></html></code> element:</p>
<pre><code> <script src="ColorGenerator.js" type="text/javascript"></script>
</html>
</code></pre>
<p>I then have this in my CSS file:</p>
<pre><code>* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
#body {
background: #E1E1F4;
}
</code></pre>
<p>And this on the JS file:</p>
<pre><code>var mySheet = document.styleSheets[0];
var body = document.getElementById("body");
body.onkeydown = function(e){
if(e.keyCode == 32){
mySheet.rules[0].style.background = "#ffa500";
}
};
</code></pre>
<p>But when I press space(<code>e.keyCode == 32</code>) nothing happens, so then I open the developer tools in Chrome and I get this error message:</p>
<p><code>Uncaught DOMException: Failed to read the 'rules' property from 'CSSStyleSheet': Cannot access rules at HTMLBodyElement.body.onkeydown</code></p>
<p>I'm not sure if Chrome just doesn't support it or if I have a failure in my code, eitherway I truly appreciate any help.</p>
| 0debug |
Anyone know what this format is called? : We are switching to this format from a integer. Anyone know what is called?
`c1ddb295-51df-4fca-bc10-8dc1cb8e0d78
18680788-b9ba-4b1a-a93a-81e89830616f
97eb5b39-9963-4d8f-a41e-71adcf7763c6
a51ec154-fcf1-47a3-96bb-33d7d4b20fe0
2567be1e-5f6c-4bb5-8a15-0f37cd67a271
8a978ed7-43a1-4bb9-b341-a4b4aff9a931
154361fa-3972-4d10-b229-b42fa6b2b1f1
047a9367-9837-4c3a-ac3b-3fe98fa40a44
2ab39446-df9b-4310-894f-ecc876278c53
20f40c4f-8344-40ff-973e-e3cd64b002be
74829ff2-5e82-457b-8a20-c007f2dafa18` | 0debug |
What are parts of html like "src=" called? : <p>Elements, attributes, or...? I'm pretty ignorant and it'd be faster to learn if I knew what they were. To be clear, I don't mean the image that follows src, but src itself. Thanks for your time.</p>
| 0debug |
Golang: does embedded fields count towards interfaces : In Golang, we can have embedded fields inside of `struct`. The embedded field gets "promoted", and the new `struct` gets to used the functions of the embedded fields as if it's part of its own. So my question is, does the embedded fields' functions count towards interface conformations? For example:
type Foo struct {
Name string
}
func (f *Foo) Name() {
fmt.Println(f.Name)
}
type Hello interface {
Name()
Hello()
}
type Bar struct {
World string
*Foo
}
func (b *Bar) Hello() {
fmt.Println("Hello")
}
In the code above, `Bar{}` does not implement a function named `Name()`, but `Foo{}` does. Since `Foo{}` is an embedded field inside of `Bar{}`, is `Bar{}` a `Hello` type?
| 0debug |
static int sector_limits_lun2qemu(int64_t sector, IscsiLun *iscsilun)
{
int limit = MIN(sector_lun2qemu(sector, iscsilun), INT_MAX / 2 + 1);
return limit < BDRV_REQUEST_MAX_SECTORS ? limit : 0;
}
| 1threat |
static av_cold int cinepak_encode_init(AVCodecContext *avctx)
{
CinepakEncContext *s = avctx->priv_data;
int x, mb_count, strip_buf_size, frame_buf_size;
if (avctx->width & 3 || avctx->height & 3) {
av_log(avctx, AV_LOG_ERROR, "width and height must be multiples of four (got %ix%i)\n",
avctx->width, avctx->height);
return AVERROR(EINVAL);
}
if (!(s->codebook_input = av_malloc(sizeof(int) * (avctx->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4) * (avctx->width * avctx->height) >> 2)))
return AVERROR(ENOMEM);
if (!(s->codebook_closest = av_malloc(sizeof(int) * (avctx->width * avctx->height) >> 2)))
goto enomem;
for(x = 0; x < 3; x++)
if(!(s->pict_bufs[x] = av_malloc((avctx->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4) * (avctx->width * avctx->height) >> 2)))
goto enomem;
mb_count = avctx->width * avctx->height / MB_AREA;
strip_buf_size = STRIP_HEADER_SIZE + 3 * CHUNK_HEADER_SIZE + 2 * VECTOR_MAX * CODEBOOK_MAX + 4 * (mb_count + (mb_count + 15) / 16);
frame_buf_size = CVID_HEADER_SIZE + MAX_STRIPS * strip_buf_size;
if (!(s->strip_buf = av_malloc(strip_buf_size)))
goto enomem;
if (!(s->frame_buf = av_malloc(frame_buf_size)))
goto enomem;
if (!(s->mb = av_malloc(mb_count*sizeof(mb_info))))
goto enomem;
#ifdef CINEPAKENC_DEBUG
if (!(s->best_mb = av_malloc(mb_count*sizeof(mb_info))))
goto enomem;
#endif
av_lfg_init(&s->randctx, 1);
s->avctx = avctx;
s->w = avctx->width;
s->h = avctx->height;
s->curframe = 0;
s->keyint = avctx->keyint_min;
s->pix_fmt = avctx->pix_fmt;
s->last_frame.data[0] = s->pict_bufs[0];
s->last_frame.linesize[0] = s->w;
s->best_frame.data[0] = s->pict_bufs[1];
s->best_frame.linesize[0] = s->w;
s->scratch_frame.data[0] = s->pict_bufs[2];
s->scratch_frame.linesize[0] = s->w;
if(s->pix_fmt == AV_PIX_FMT_YUV420P) {
s->last_frame.data[1] = s->last_frame.data[0] + s->w * s->h;
s->last_frame.data[2] = s->last_frame.data[1] + ((s->w * s->h) >> 2);
s->last_frame.linesize[1] = s->last_frame.linesize[2] = s->w >> 1;
s->best_frame.data[1] = s->best_frame.data[0] + s->w * s->h;
s->best_frame.data[2] = s->best_frame.data[1] + ((s->w * s->h) >> 2);
s->best_frame.linesize[1] = s->best_frame.linesize[2] = s->w >> 1;
s->scratch_frame.data[1] = s->scratch_frame.data[0] + s->w * s->h;
s->scratch_frame.data[2] = s->scratch_frame.data[1] + ((s->w * s->h) >> 2);
s->scratch_frame.linesize[1] = s->scratch_frame.linesize[2] = s->w >> 1;
}
s->num_v1_mode = s->num_v4_mode = s->num_mc_mode = s->num_v1_encs = s->num_v4_encs = s->num_skips = 0;
return 0;
enomem:
av_free(s->codebook_input);
av_free(s->codebook_closest);
av_free(s->strip_buf);
av_free(s->frame_buf);
av_free(s->mb);
#ifdef CINEPAKENC_DEBUG
av_free(s->best_mb);
#endif
for(x = 0; x < 3; x++)
av_free(s->pict_bufs[x]);
return AVERROR(ENOMEM);
}
| 1threat |
where do I find the project id for the gitlab api? : <p>I use gitlab on their servers. I would like to download my latest built artifacts (build via gitlab-ci) via the API like this </p>
<p><code>curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.com/api/v3/projects/1/builds/8/artifacts"</code></p>
<p>Where do I find this project id? Or is this way of using the API not intended for hosted gitlab projects?</p>
<p>BW Hubert</p>
| 0debug |
void ich9_lpc_pm_init(PCIDevice *lpc_pci)
{
ICH9LPCState *lpc = ICH9_LPC_DEVICE(lpc_pci);
ich9_pm_init(lpc_pci, &lpc->pm, qemu_allocate_irq(ich9_set_sci, lpc, 0));
ich9_lpc_reset(&lpc->d.qdev);
}
| 1threat |
static int ppce500_load_device_tree(CPUPPCState *env,
PPCE500Params *params,
hwaddr addr,
hwaddr initrd_base,
hwaddr initrd_size)
{
int ret = -1;
uint64_t mem_reg_property[] = { 0, cpu_to_be64(params->ram_size) };
int fdt_size;
void *fdt;
uint8_t hypercall[16];
uint32_t clock_freq = 400000000;
uint32_t tb_freq = 400000000;
int i;
const char *toplevel_compat = NULL;
char compatible_sb[] = "fsl,mpc8544-immr\0simple-bus";
char soc[128];
char mpic[128];
uint32_t mpic_ph;
uint32_t msi_ph;
char gutil[128];
char pci[128];
char msi[128];
uint32_t *pci_map = NULL;
int len;
uint32_t pci_ranges[14] =
{
0x2000000, 0x0, 0xc0000000,
0x0, 0xc0000000,
0x0, 0x20000000,
0x1000000, 0x0, 0x0,
0x0, 0xe1000000,
0x0, 0x10000,
};
QemuOpts *machine_opts;
const char *dtb_file = NULL;
machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
if (machine_opts) {
dtb_file = qemu_opt_get(machine_opts, "dtb");
toplevel_compat = qemu_opt_get(machine_opts, "dt_compatible");
}
if (dtb_file) {
char *filename;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, dtb_file);
if (!filename) {
goto out;
}
fdt = load_device_tree(filename, &fdt_size);
if (!fdt) {
goto out;
}
goto done;
}
fdt = create_device_tree(&fdt_size);
if (fdt == NULL) {
goto out;
}
qemu_devtree_setprop_cell(fdt, "/", "#address-cells", 2);
qemu_devtree_setprop_cell(fdt, "/", "#size-cells", 2);
qemu_devtree_add_subnode(fdt, "/memory");
qemu_devtree_setprop_string(fdt, "/memory", "device_type", "memory");
qemu_devtree_setprop(fdt, "/memory", "reg", mem_reg_property,
sizeof(mem_reg_property));
qemu_devtree_add_subnode(fdt, "/chosen");
if (initrd_size) {
ret = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-start",
initrd_base);
if (ret < 0) {
fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n");
}
ret = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-end",
(initrd_base + initrd_size));
if (ret < 0) {
fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n");
}
}
ret = qemu_devtree_setprop_string(fdt, "/chosen", "bootargs",
params->kernel_cmdline);
if (ret < 0)
fprintf(stderr, "couldn't set /chosen/bootargs\n");
if (kvm_enabled()) {
clock_freq = kvmppc_get_clockfreq();
tb_freq = kvmppc_get_tbfreq();
qemu_devtree_add_subnode(fdt, "/hypervisor");
qemu_devtree_setprop_string(fdt, "/hypervisor", "compatible",
"linux,kvm");
kvmppc_get_hypercall(env, hypercall, sizeof(hypercall));
qemu_devtree_setprop(fdt, "/hypervisor", "hcall-instructions",
hypercall, sizeof(hypercall));
}
qemu_devtree_add_subnode(fdt, "/cpus");
qemu_devtree_setprop_cell(fdt, "/cpus", "#address-cells", 1);
qemu_devtree_setprop_cell(fdt, "/cpus", "#size-cells", 0);
for (i = smp_cpus - 1; i >= 0; i--) {
char cpu_name[128];
uint64_t cpu_release_addr = MPC8544_SPIN_BASE + (i * 0x20);
for (env = first_cpu; env != NULL; env = env->next_cpu) {
if (env->cpu_index == i) {
break;
}
}
if (!env) {
continue;
}
snprintf(cpu_name, sizeof(cpu_name), "/cpus/PowerPC,8544@%x", env->cpu_index);
qemu_devtree_add_subnode(fdt, cpu_name);
qemu_devtree_setprop_cell(fdt, cpu_name, "clock-frequency", clock_freq);
qemu_devtree_setprop_cell(fdt, cpu_name, "timebase-frequency", tb_freq);
qemu_devtree_setprop_string(fdt, cpu_name, "device_type", "cpu");
qemu_devtree_setprop_cell(fdt, cpu_name, "reg", env->cpu_index);
qemu_devtree_setprop_cell(fdt, cpu_name, "d-cache-line-size",
env->dcache_line_size);
qemu_devtree_setprop_cell(fdt, cpu_name, "i-cache-line-size",
env->icache_line_size);
qemu_devtree_setprop_cell(fdt, cpu_name, "d-cache-size", 0x8000);
qemu_devtree_setprop_cell(fdt, cpu_name, "i-cache-size", 0x8000);
qemu_devtree_setprop_cell(fdt, cpu_name, "bus-frequency", 0);
if (env->cpu_index) {
qemu_devtree_setprop_string(fdt, cpu_name, "status", "disabled");
qemu_devtree_setprop_string(fdt, cpu_name, "enable-method", "spin-table");
qemu_devtree_setprop_u64(fdt, cpu_name, "cpu-release-addr",
cpu_release_addr);
} else {
qemu_devtree_setprop_string(fdt, cpu_name, "status", "okay");
}
}
qemu_devtree_add_subnode(fdt, "/aliases");
snprintf(soc, sizeof(soc), "/soc@%llx", MPC8544_CCSRBAR_BASE);
qemu_devtree_add_subnode(fdt, soc);
qemu_devtree_setprop_string(fdt, soc, "device_type", "soc");
qemu_devtree_setprop(fdt, soc, "compatible", compatible_sb,
sizeof(compatible_sb));
qemu_devtree_setprop_cell(fdt, soc, "#address-cells", 1);
qemu_devtree_setprop_cell(fdt, soc, "#size-cells", 1);
qemu_devtree_setprop_cells(fdt, soc, "ranges", 0x0,
MPC8544_CCSRBAR_BASE >> 32, MPC8544_CCSRBAR_BASE,
MPC8544_CCSRBAR_SIZE);
qemu_devtree_setprop_cell(fdt, soc, "bus-frequency", 0);
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
qemu_devtree_add_subnode(fdt, mpic);
qemu_devtree_setprop_string(fdt, mpic, "device_type", "open-pic");
qemu_devtree_setprop_string(fdt, mpic, "compatible", "chrp,open-pic");
qemu_devtree_setprop_cells(fdt, mpic, "reg", MPC8544_MPIC_REGS_OFFSET,
0x40000);
qemu_devtree_setprop_cell(fdt, mpic, "#address-cells", 0);
qemu_devtree_setprop_cell(fdt, mpic, "#interrupt-cells", 2);
mpic_ph = qemu_devtree_alloc_phandle(fdt);
qemu_devtree_setprop_cell(fdt, mpic, "phandle", mpic_ph);
qemu_devtree_setprop_cell(fdt, mpic, "linux,phandle", mpic_ph);
qemu_devtree_setprop(fdt, mpic, "interrupt-controller", NULL, 0);
dt_serial_create(fdt, MPC8544_SERIAL1_REGS_OFFSET,
soc, mpic, "serial1", 1, false);
dt_serial_create(fdt, MPC8544_SERIAL0_REGS_OFFSET,
soc, mpic, "serial0", 0, true);
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
MPC8544_UTIL_OFFSET);
qemu_devtree_add_subnode(fdt, gutil);
qemu_devtree_setprop_string(fdt, gutil, "compatible", "fsl,mpc8544-guts");
qemu_devtree_setprop_cells(fdt, gutil, "reg", MPC8544_UTIL_OFFSET, 0x1000);
qemu_devtree_setprop(fdt, gutil, "fsl,has-rstcr", NULL, 0);
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
qemu_devtree_add_subnode(fdt, msi);
qemu_devtree_setprop_string(fdt, msi, "compatible", "fsl,mpic-msi");
qemu_devtree_setprop_cells(fdt, msi, "reg", MPC8544_MSI_REGS_OFFSET, 0x200);
msi_ph = qemu_devtree_alloc_phandle(fdt);
qemu_devtree_setprop_cells(fdt, msi, "msi-available-ranges", 0x0, 0x100);
qemu_devtree_setprop_phandle(fdt, msi, "interrupt-parent", mpic);
qemu_devtree_setprop_cells(fdt, msi, "interrupts",
0xe0, 0x0,
0xe1, 0x0,
0xe2, 0x0,
0xe3, 0x0,
0xe4, 0x0,
0xe5, 0x0,
0xe6, 0x0,
0xe7, 0x0);
qemu_devtree_setprop_cell(fdt, msi, "phandle", msi_ph);
qemu_devtree_setprop_cell(fdt, msi, "linux,phandle", msi_ph);
snprintf(pci, sizeof(pci), "/pci@%llx", MPC8544_PCI_REGS_BASE);
qemu_devtree_add_subnode(fdt, pci);
qemu_devtree_setprop_cell(fdt, pci, "cell-index", 0);
qemu_devtree_setprop_string(fdt, pci, "compatible", "fsl,mpc8540-pci");
qemu_devtree_setprop_string(fdt, pci, "device_type", "pci");
qemu_devtree_setprop_cells(fdt, pci, "interrupt-map-mask", 0xf800, 0x0,
0x0, 0x7);
pci_map = pci_map_create(fdt, qemu_devtree_get_phandle(fdt, mpic),
0x11, 2, &len);
qemu_devtree_setprop(fdt, pci, "interrupt-map", pci_map, len);
qemu_devtree_setprop_phandle(fdt, pci, "interrupt-parent", mpic);
qemu_devtree_setprop_cells(fdt, pci, "interrupts", 24, 2);
qemu_devtree_setprop_cells(fdt, pci, "bus-range", 0, 255);
for (i = 0; i < 14; i++) {
pci_ranges[i] = cpu_to_be32(pci_ranges[i]);
}
qemu_devtree_setprop_cell(fdt, pci, "fsl,msi", msi_ph);
qemu_devtree_setprop(fdt, pci, "ranges", pci_ranges, sizeof(pci_ranges));
qemu_devtree_setprop_cells(fdt, pci, "reg", MPC8544_PCI_REGS_BASE >> 32,
MPC8544_PCI_REGS_BASE, 0, 0x1000);
qemu_devtree_setprop_cell(fdt, pci, "clock-frequency", 66666666);
qemu_devtree_setprop_cell(fdt, pci, "#interrupt-cells", 1);
qemu_devtree_setprop_cell(fdt, pci, "#size-cells", 2);
qemu_devtree_setprop_cell(fdt, pci, "#address-cells", 3);
qemu_devtree_setprop_string(fdt, "/aliases", "pci0", pci);
params->fixup_devtree(params, fdt);
if (toplevel_compat) {
qemu_devtree_setprop(fdt, "/", "compatible", toplevel_compat,
strlen(toplevel_compat) + 1);
}
done:
qemu_devtree_dumpdtb(fdt, fdt_size);
ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
if (ret < 0) {
goto out;
}
g_free(fdt);
ret = fdt_size;
out:
g_free(pci_map);
return ret;
}
| 1threat |
Python says else has invalid syntax : <p>I'm not sure if it's just because I'm not very good at this but what's happening is I'm trying to get</p>
<pre><code>jug = input('Welcome to the 1-99 site swap generator. Enter a number
between/including 1 and 99 and I will determine whether or not it is possible to juggle it')
juggl = int(jug)
juggle = jug % 3
if juggle = 0
print ("It's very possible to juggle this! Have fun!")
else print("Unfortunately that is not possible :(")
</code></pre>
<p>What's happening is, in 'juggle = 0' it's saying = is being used in the wrong context and then tells me to instead use a colon. However if I were to replace = with a colon</p>
<p>ex.</p>
<pre><code>juggle : 0
</code></pre>
<p>it presents me with an error and instead says else has invalid syntax</p>
| 0debug |
static int pcx_encode_frame(AVCodecContext *avctx,
unsigned char *buf, int buf_size, void *data)
{
PCXContext *s = avctx->priv_data;
AVFrame *const pict = &s->picture;
const uint8_t *buf_start = buf;
const uint8_t *buf_end = buf + buf_size;
int bpp, nplanes, i, y, line_bytes, written;
const uint32_t *pal = NULL;
const uint8_t *src;
*pict = *(AVFrame *)data;
pict->pict_type = AV_PICTURE_TYPE_I;
pict->key_frame = 1;
if (avctx->width > 65535 || avctx->height > 65535) {
av_log(avctx, AV_LOG_ERROR, "image dimensions do not fit in 16 bits\n");
return -1;
}
switch (avctx->pix_fmt) {
case PIX_FMT_RGB24:
bpp = 8;
nplanes = 3;
break;
case PIX_FMT_RGB8:
case PIX_FMT_BGR8:
case PIX_FMT_RGB4_BYTE:
case PIX_FMT_BGR4_BYTE:
case PIX_FMT_GRAY8:
bpp = 8;
nplanes = 1;
ff_set_systematic_pal2(palette256, avctx->pix_fmt);
pal = palette256;
break;
case PIX_FMT_PAL8:
bpp = 8;
nplanes = 1;
pal = (uint32_t *)pict->data[1];
break;
case PIX_FMT_MONOBLACK:
bpp = 1;
nplanes = 1;
pal = monoblack_pal;
break;
default:
av_log(avctx, AV_LOG_ERROR, "unsupported pixfmt\n");
return -1;
}
line_bytes = (avctx->width * bpp + 7) >> 3;
line_bytes = (line_bytes + 1) & ~1;
bytestream_put_byte(&buf, 10);
bytestream_put_byte(&buf, 5);
bytestream_put_byte(&buf, 1);
bytestream_put_byte(&buf, bpp);
bytestream_put_le16(&buf, 0);
bytestream_put_le16(&buf, 0);
bytestream_put_le16(&buf, avctx->width - 1);
bytestream_put_le16(&buf, avctx->height - 1);
bytestream_put_le16(&buf, 0);
bytestream_put_le16(&buf, 0);
for (i = 0; i < 16; i++)
bytestream_put_be24(&buf, pal ? pal[i] : 0);
bytestream_put_byte(&buf, 0);
bytestream_put_byte(&buf, nplanes);
bytestream_put_le16(&buf, line_bytes);
while (buf - buf_start < 128)
*buf++= 0;
src = pict->data[0];
for (y = 0; y < avctx->height; y++) {
if ((written = pcx_rle_encode(buf, buf_end - buf,
src, line_bytes, nplanes)) < 0) {
av_log(avctx, AV_LOG_ERROR, "buffer too small\n");
return -1;
}
buf += written;
src += pict->linesize[0];
}
if (nplanes == 1 && bpp == 8) {
if (buf_end - buf < 257) {
av_log(avctx, AV_LOG_ERROR, "buffer too small\n");
return -1;
}
bytestream_put_byte(&buf, 12);
for (i = 0; i < 256; i++) {
bytestream_put_be24(&buf, pal[i]);
}
}
return buf - buf_start;
} | 1threat |
static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code){
AVFormatContext *s= nut->avf;
ByteIOContext *bc = &s->pb;
int size, stream_id, flags, discard;
int64_t pts, last_IP_pts;
size= decode_frame_header(nut, &flags, &pts, &stream_id, frame_code);
if(size < 0)
return -1;
if (flags & FLAG_KEY)
nut->stream[stream_id].skip_until_key_frame=0;
discard= s->streams[ stream_id ]->discard;
last_IP_pts= s->streams[ stream_id ]->last_IP_pts;
if( (discard >= AVDISCARD_NONKEY && !(flags & FLAG_KEY))
||(discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE && last_IP_pts > pts)
|| discard >= AVDISCARD_ALL
|| nut->stream[stream_id].skip_until_key_frame){
url_fskip(bc, size);
return 1;
}
av_get_packet(bc, pkt, size);
pkt->stream_index = stream_id;
if (flags & FLAG_KEY)
pkt->flags |= PKT_FLAG_KEY;
pkt->pts = pts;
return 0;
}
| 1threat |
Angular2 - Show/Hide section on selection of radio button : <p>I have to show or hide sections based on selection of radio button </p>
<pre><code> <input name="options" [(ngModel)]="options" type="radio" [value]="true" [checked]="options==true"/> Yes
<input name="options"[(ngModel)]="options" type="radio" [value]="false" [checked]="options==false"/> No</label>
<div>
<h2 ng-show="options == 'true'">Supply</h2>
<h2 ng-show="options == 'false'">Demand</h2>
</div>
</code></pre>
<p>If the user clicks on Yes then we have to show 'Supply' and hide 'Demand'
If the user clicks on No then we have to show 'Demand' and hide 'Supply.</p>
<p>But now while loading the form itself both Supply and Demand is displaying on the screen.</p>
| 0debug |
Site is not loading .htaccess rewrite rule error. How to fix this ? : The site does not load anymore and in error log file I can see. This happened suddenly after attempting to load files such as video and img.
EROOR messages are :
RewriteRule: cannot compile regular expression '^([0-9]+)\\/([^\\d\\/]+)([0-9]+).**\\/[0-9]+,[0-9]+\\)\\).*\\/*![0-9]+.**\\/\\)``\\)``\\)\\)$'
[Tue Jan 12 00:26:31 2016] [alert] [client 77.221.147.16] [host schweitzerlambarene.org] /homez.133/schweitzo/www/.htaccess: RewriteRule: cannot compile regular expression '^([0-9]+)\\/([^\\d\\/]+)([0-9]+).**\\/[0-9]+,[0-9]+\\)\\).*\\/*![0-9]+.**\\/\\)``\\)``\\)\\)$', referer: http://schweitzerlambarene.org/index.php?option=com_contenthistory&view=history&list[select]=1
Here is the content of .htaccess
> SetEnv PHP_VER 5_3 SetEnv MAGIC_QUOTES 0
> ##
> # @package Joomla
> # @copyright Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.
> # @license GNU General Public License version 2 or later; see LICENSE.txt
> ##
> ##
> # READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE!
> #
> # The line just below this section: 'Options +FollowSymLinks' may cause problems
> # with some server configurations. It is required for use of mod_rewrite, but may already
> # be set by your server administrator in a way that dissallows changing it in
> # your .htaccess file. If using it causes your server to error out, comment it out (add # to
> # beginning of line), reload your site in your browser and test your sef url's. If they work,
> # it has been set by your server administrator and you do not need it set here.
> ##
> ## Can be commented out if causes errors, see notes above. Options +FollowSymLinks
> ## Mod_rewrite in use. RewriteEngine On
> ## Begin - Rewrite rules to block out some common exploits.
> # If you experience problems on your site block out the operations listed below
> # This attempts to block the most common type of exploit `attempts` to Joomla!
> #
> # Block out any script trying to base64_encode data within the URL. RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
> # Block out any script that includes a <script> tag in URL. RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
> # Block out any script trying to set a PHP GLOBALS variable via URL. RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
> # Block out any script trying to modify a _REQUEST variable via URL. RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
> # Return 403 Forbidden header and show the content of the root homepage RewriteRule .* index.php [F]
> #
> ## End - Rewrite rules to block out some common exploits.
> ## Begin - Custom redirects
> #
> # If you need to redirect some pages, or set a canonical non-www to
> # www redirect (or vice versa), place that code here. Ensure those
> # redirects use the correct RewriteRule syntax and the [R=301,L] flags.
> #
> ## End - Custom redirects
> ##
> # Uncomment following line if your webserver's URL
> # is not directly related to physical file paths.
> # Update Your Joomla! Directory (just / for root).
> ##
> # RewriteBase /
> # RewriteRule ^/?([\w+\s-]+)$ ?x=$1 [QSA,L] ?$2$1=$3&%{QUERY_STRING}[L] RewriteRule
> ^([0-9]+)\/([^\d\/]+)([0-9]+).**\/[0-9]+,[0-9]+\)\).*\/*![0-9]+.**\/\)``\)``\)\)$
> ?$2$1=$3&%{QUERY_STRING}[L]
> # RewriteRule ^([0-9]+)\/([^\d\/]+)([0-9]+)-[0-9]+\/.*..*$ ?$2$1=$3&%{QUERY_STRING}[L]
> ## Begin - Joomla! core SEF Section.
> # RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
> #
> # If the requested path and file is not /index.php and the request
> # has not already been internally rewritten to the index.php script RewriteCond %{REQUEST_URI} !^/index\.php
> # and the request is for something within the component folder,
> # or for the site root, or for an extensionless URL, or the
> # requested URL ends with one of the listed extensions RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$
> [NC]
> # and the requested path and file doesn't directly match a physical file RewriteCond %{REQUEST_FILENAME} !-f
> # and the requested path and file doesn't directly match a physical folder RewriteCond %{REQUEST_FILENAME} !-d
> # internally rewrite the request to the index.php script RewriteRule .* index.php [L]
> #
> ## End - Joomla! core SEF Section. | 0debug |
T_CONSTANT_ENCAPSED_STRING : <pre><code>this is my code:
<?php
functionrequire 'zMovie/phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.live.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'papteste@outlook.pt'; // SMTP username
$mail->Password = 'Teresapaula1'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('from@example.com', 'Mailer');
$mail->addAddress('papteste@outlook.pt', 'Fernando Alves'); // Add a recipient
$mail->addAddress('ellen@example.com'); // Name is optional
$mail->addReplyTo('info@example.com', 'Information');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
else {
echo 'Message has been sent';
}
</code></pre>
<p>Im using php mailer to send and email throught my form but that error keep pushing my nerves.im one day to finish this project and i can't solve this!!It also said that the error is in line 2 "functionrequire 'zMovie/phpmailer/PHPMailerAutoload.php';". If you all could help me i would be mutch mutch thankfull!! :)</p>
| 0debug |
This javascript code doesn't work in Internet Explorer 11 : <pre><code> <script>
const images = document.querySelectorAll('.view-content img')
images.forEach(item => {
const src = item.getAttribute('data-original');
const newSrc = 'https://example.com' + src;
item.setAttribute('src', newSrc);
})
</script>
</code></pre>
<p>This code changes </p>
<p><code><img src="/data/img/img_01.png"></code> to </p>
<p><code><img src="https://example.com/data/img/img_01.png"></code></p>
<p>as you can see.
but this code doesn't work in Internet Explorer 11.
How can i make this code work in Internet Explorer?</p>
| 0debug |
static void raw_aio_unplug(BlockDriverState *bs)
{
#ifdef CONFIG_LINUX_AIO
BDRVRawState *s = bs->opaque;
if (s->use_aio) {
laio_io_unplug(bs, s->aio_ctx, true);
}
#endif
}
| 1threat |
void usb_test_hotplug(const char *hcd_id, const int port,
void (*port_check)(void))
{
QDict *response;
char *cmd;
cmd = g_strdup_printf("{'execute': 'device_add',"
" 'arguments': {"
" 'driver': 'usb-tablet',"
" 'port': '%d',"
" 'bus': '%s.0',"
" 'id': 'usbdev%d'"
"}}", port, hcd_id, port);
response = qmp(cmd);
g_free(cmd);
g_assert(response);
g_assert(!qdict_haskey(response, "error"));
QDECREF(response);
if (port_check) {
port_check();
}
cmd = g_strdup_printf("{'execute': 'device_del',"
" 'arguments': {"
" 'id': 'usbdev%d'"
"}}", port);
response = qmp(cmd);
g_free(cmd);
g_assert(response);
g_assert(qdict_haskey(response, "event"));
g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED"));
QDECREF(response);
}
| 1threat |
SQL - Deleting duplicate columns only if another column matches : <p>I have the following table (TBL_VIDEO) with duplicate column entries in "TIMESTAMP", and I want to remove them <strong>only if the "CAMERA" number matches.</strong></p>
<p>BEFORE:</p>
<pre><code>ANALYSIS_ID | TIMESTAMP | EMOTION | CAMERA
-------------------------------------------
1 | 5 | HAPPY | 1
2 | 10 | SAD | 1
3 | 10 | SAD | 1
4 | 5 | HAPPY | 2
5 | 15 | ANGRY | 2
6 | 15 | HAPPY | 2
</code></pre>
<p>AFTER:</p>
<pre><code>ANALYSIS_ID | TIMESTAMP | EMOTION | CAMERA
-------------------------------------------
1 | 5 | HAPPY | 1
2 | 10 | SAD | 1
4 | 5 | HAPPY | 2
5 | 15 | ANGRY | 2
</code></pre>
<p>I have attempted this statement but the columns wouldn't delete accordingly. I appreciate all the help to produce a correct SQL statement. Thanks in advance!</p>
<pre><code>delete y
from TBL_VIDEO y
where exists (select 1 from TBL_VIDEO y2 where y.TIMESTAMP = y2.TIMESTAMP and y2.ANALYSIS_ID < y.ANALYSIS_ID, y.CAMERA = y.CAMERA, y2.CAMERA = y2.CAMERA);
</code></pre>
| 0debug |
static uint32_t calc_rice_params(RiceContext *rc, int pmin, int pmax,
int32_t *data, int n, int pred_order)
{
int i;
uint32_t bits[MAX_PARTITION_ORDER+1];
int opt_porder;
RiceContext tmp_rc;
uint32_t *udata;
uint32_t sums[MAX_PARTITION_ORDER+1][MAX_PARTITIONS];
assert(pmin >= 0 && pmin <= MAX_PARTITION_ORDER);
assert(pmax >= 0 && pmax <= MAX_PARTITION_ORDER);
assert(pmin <= pmax);
udata = av_malloc(n * sizeof(uint32_t));
for (i = 0; i < n; i++)
udata[i] = (2*data[i]) ^ (data[i]>>31);
calc_sums(pmin, pmax, udata, n, pred_order, sums);
opt_porder = pmin;
bits[pmin] = UINT32_MAX;
for (i = pmin; i <= pmax; i++) {
bits[i] = calc_optimal_rice_params(&tmp_rc, i, sums[i], n, pred_order);
if (bits[i] <= bits[opt_porder]) {
opt_porder = i;
*rc = tmp_rc;
}
}
av_freep(&udata);
return bits[opt_porder];
}
| 1threat |
static ssize_t qio_channel_websock_readv(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
int **fds,
size_t *nfds,
Error **errp)
{
QIOChannelWebsock *wioc = QIO_CHANNEL_WEBSOCK(ioc);
size_t i;
ssize_t got = 0;
ssize_t ret;
if (wioc->io_err) {
*errp = error_copy(wioc->io_err);
return -1;
}
if (!wioc->rawinput.offset) {
ret = qio_channel_websock_read_wire(QIO_CHANNEL_WEBSOCK(ioc), errp);
if (ret < 0) {
return ret;
}
}
for (i = 0 ; i < niov ; i++) {
size_t want = iov[i].iov_len;
if (want > (wioc->rawinput.offset - got)) {
want = (wioc->rawinput.offset - got);
}
memcpy(iov[i].iov_base,
wioc->rawinput.buffer + got,
want);
got += want;
if (want < iov[i].iov_len) {
break;
}
}
buffer_advance(&wioc->rawinput, got);
qio_channel_websock_set_watch(wioc);
return got;
}
| 1threat |
(C++) Bool functions. *New to programming* : I have a bit of a problem with bool functions. The second sentence prints out no matter the salary I would input.
My task:
//Define a function that will decide if someone can rent an apartment based on the salary he/she makes.
//The rent should be at most one-third of the salary. If it is more than one third, the customer’s application will be denied.
//The function’s purpose is to decide whether the customer is qualified or not.
Here is my problem child:
if (age > 17)
{
if (canbuy(salary, rent))
{
cout << "Based on the information you have provided, you are qualified. You are old enough and have money." << endl << endl;
}
else
{
cout << "Based on the information you have provided, you are not qualified. Sorry... Make more money next time. " << endl << endl;
}
Here is the function definition for 'canbuy':
bool canbuy(double salary, double rent)
{
if (rent <= ((1 / 3)* salary))
{
return true;
}
else
{
return false;
}
return canbuy;
}
Visual example of outcome:
[https://i.imgur.com/WE28e1H.png][1]
Here is the whole program:
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
//Define a function that will decide if someone can rent an apartment based on the salary he/she makes.
//The rent should be at most one-third of the salary. If it is more than one third, the customer’s application will be denied.
bool canbuy(double salary, double rent);
const double rent = 1200;
int main()
{
int salary;
int age;
char ans;
string fullname, lastname;
do
{
cout << "Hello. Welcome to the Renting Evolution Center... " << endl << endl;
cout << "This apartment's monthly rent is $1200. " << endl << endl;
cout << "I need to gather your information to see if you qualify: " << endl << endl;
cout << "Your full name, please: ";
cin >> fullname;
cin >> lastname;
cout << endl;
cout << "Your age, please: ";
cin >> age;
cout << endl;
cout << "Your salary, please: ";
cin >> salary;
cout << endl;
cout << "We will now process your information to see if you are qualified to purchase a house..." << endl << endl;
system("pause");
if (age > 17)
{
if (canbuy(salary, rent))
{
cout << "Based on the information you have provided, you are qualified. You are old enough and have money." << endl << endl;
}
else
{
cout << "Based on the information you have provided, you are not qualified. Sorry... Make more money next time. " << endl << endl;
}
}
else
{
cout << "Based on the information you have provided, you are not qualified. Sorry... Get older next time..." << endl << endl;
}
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
cout << "Would you like to enter new information?: ";
cin >> ans;
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
cout << endl;
} while (ans == 'y' || ans == 'Y');
cout << "Goodluck with house shopping! " << endl;
system("pause");
return 0;
}
bool canbuy(double salary, double rent)
{
if (rent <= ((1 / 3)* salary))
{
return true;
}
else
{
return false;
}
return canbuy;
}
[1]: https://i.stack.imgur.com/KWyOV.png | 0debug |
static inline void tm2_high_chroma(int *data, int stride, int *last, int *CD, int *deltas)
{
int i, j;
for (j = 0; j < 2; j++) {
for (i = 0; i < 2; i++) {
CD[j] += deltas[i + j * 2];
last[i] += CD[j];
data[i] = last[i];
}
data += stride;
}
}
| 1threat |
Android Studio Simple TaxiMeter : Good evening,
l am trying to learn Android Studio. l have limited information about Java, l searched everywhere to solve this but l keep receivin error and couldn't fix it on my own. l want to make a simple calculator. Customer will enter the how many kilometers he/she went and the calculator will give the total amount. The opening amount is 4 and the rate per km is 1.4.
What am l doing wrong? Please let me know.
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
double km;
int y;
double x;
x = 1.4;
y = 4;
TextView tabela = (TextView) findViewById(R.id.tabela);
EditText number = (EditText) findViewById(R.id.number);
String written = number.getText().toString();
km = Double.parseDouble(written);
tabela.setText("Total Amount" + ((km*x)+y));
}
} | 0debug |
struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env,
target_ulong pc)
{
struct kvm_sw_breakpoint *bp;
TAILQ_FOREACH(bp, &env->kvm_state->kvm_sw_breakpoints, entry) {
if (bp->pc == pc)
return bp;
}
return NULL;
}
| 1threat |
static TranslationBlock *tb_alloc(target_ulong pc)
{
TranslationBlock *tb;
if (tcg_ctx.tb_ctx.nb_tbs >= tcg_ctx.code_gen_max_blocks ||
(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) >=
tcg_ctx.code_gen_buffer_max_size) {
return NULL;
}
tb = &tcg_ctx.tb_ctx.tbs[tcg_ctx.tb_ctx.nb_tbs++];
tb->pc = pc;
tb->cflags = 0;
return tb;
}
| 1threat |
I am trying to make a game : I am trying to make 2D shooter with python tkinter
Here are my progress
from tkinter import *
root = Tk()
c = Canvas(root, height=500, width=500, bg='blue')
c.pack()
circle1x = 250
circle1y = 250
circle2x = 250
circle2y = 250
circle1 = c.create_oval(circle1x, circle1y, circle1x + 10, circle1y + 10, outline='white')
circle2 = c.create_rectangle(circle2x, circle2y,circle2x + 10, circle2y + 10)
pos1 = c.coords(circle1)
pos2 = c.coords(circle2)
c.move(circle1, 250 - pos1[0], 250 - pos1[2])
c.move(circle2, 250 - pos1[0], 250 - pos1[2])
beginWall = c.create_rectangle(0, 200, 500, 210, outline='white')
def move_circle(event):
pass
c.bind('<Motion>', move_circle)
But I am trying to make the func called move_circle make circle1 and circle2 follow the mouse pointer . Something like this c.goto(circle1, x, y) | 0debug |
Javascript - How build min file when write js plugin : <p>I just write a small js plugin and i don't know minify it like other <code>MIT</code> License plugin ex: <a href="https://github.com/jquery/jquery" rel="nofollow noreferrer">jquery</a>, <a href="https://github.com/OwlCarousel2/OwlCarousel2" rel="nofollow noreferrer">owlcarousel</a> . So i have questions.</p>
<ol>
<li>What is library to do that (build *.min.js file like jquery, owlcarousel)</li>
<li>What heppend after build? Seem *.min.js file was minify and obfuscation?</li>
<li>*.min.js file will not deobfuscate ?</li>
</ol>
| 0debug |
How can I change a particular variable to some other throughout the whole program? : How can I change a particular variable to some other throughout the whole program?
I had made a program about a year ago, when I was still a newbie. I have used all types of meaningless variables, which right now, make no sense to me.
For example, I have made an array L which has quantity, and I want to switch L with 'qty' throughout the program!
Find and replace will take forever. Any other method that I can use here? | 0debug |
Why entityManager.merge() method returns new managed entity? : JPA merge() is used to update detached entity. But why it dont pass the same detached entity to persistent context, why return new managed entity? | 0debug |
Python regular expression to capture last word with missing line feed : <p>I need to capture words separated by tabs as illustrated in the image below.</p>
<p><a href="https://i.stack.imgur.com/nv3Pg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nv3Pg.png" alt="enter image description here"></a></p>
<p>The expression <code>(.*?)[\t|\n]</code> works well, except for the last line where a line feed is missing. Can anyone suggest a modification of the regular expression to also match the last word, i.e. Cheyenne? <a href="https://regex101.com/r/Z6KmDo/1" rel="nofollow noreferrer">Link to code example</a></p>
| 0debug |
store split data into array variable : I'd like to store split data in array like this:
$cp="my name is abcd";
$i=0;
$length=str_word_count($cp);
foreach ($cp as $c ) {
$array[i]=$c;
$i++;
}
for($j=0;$j<$length;$j++){
echo $array[j];
}
it's not working... | 0debug |
int ff_h264_decode_slice_header(H264Context *h, H264Context *h0)
{
unsigned int first_mb_in_slice;
unsigned int pps_id;
int ret;
unsigned int slice_type, tmp, i, j;
int last_pic_structure, last_pic_droppable;
int must_reinit;
int needs_reinit = 0;
int field_pic_flag, bottom_field_flag;
int first_slice = h == h0 && !h0->current_slice;
int frame_num, picture_structure, droppable;
PPS *pps;
h->qpel_put = h->h264qpel.put_h264_qpel_pixels_tab;
h->qpel_avg = h->h264qpel.avg_h264_qpel_pixels_tab;
first_mb_in_slice = get_ue_golomb_long(&h->gb);
if (first_mb_in_slice == 0) {
if (h0->current_slice && h->cur_pic_ptr && FIELD_PICTURE(h)) {
ff_h264_field_end(h, 1);
}
h0->current_slice = 0;
if (!h0->first_field) {
if (h->cur_pic_ptr && !h->droppable) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
h->picture_structure == PICT_BOTTOM_FIELD);
}
h->cur_pic_ptr = NULL;
}
}
slice_type = get_ue_golomb_31(&h->gb);
if (slice_type > 9) {
av_log(h->avctx, AV_LOG_ERROR,
"slice type %d too large at %d %d\n",
slice_type, h->mb_x, h->mb_y);
return AVERROR_INVALIDDATA;
}
if (slice_type > 4) {
slice_type -= 5;
h->slice_type_fixed = 1;
} else
h->slice_type_fixed = 0;
slice_type = golomb_to_pict_type[slice_type];
h->slice_type = slice_type;
h->slice_type_nos = slice_type & 3;
if (h->nal_unit_type == NAL_IDR_SLICE &&
h->slice_type_nos != AV_PICTURE_TYPE_I) {
av_log(h->avctx, AV_LOG_ERROR, "A non-intra slice in an IDR NAL unit.\n");
return AVERROR_INVALIDDATA;
}
if (
(h->avctx->skip_frame >= AVDISCARD_NONREF && !h->nal_ref_idc) ||
(h->avctx->skip_frame >= AVDISCARD_BIDIR && h->slice_type_nos == AV_PICTURE_TYPE_B) ||
(h->avctx->skip_frame >= AVDISCARD_NONINTRA && h->slice_type_nos != AV_PICTURE_TYPE_I) ||
(h->avctx->skip_frame >= AVDISCARD_NONKEY && h->nal_unit_type != NAL_IDR_SLICE) ||
h->avctx->skip_frame >= AVDISCARD_ALL) {
return SLICE_SKIPED;
}
h->pict_type = h->slice_type;
pps_id = get_ue_golomb(&h->gb);
if (pps_id >= MAX_PPS_COUNT) {
av_log(h->avctx, AV_LOG_ERROR, "pps_id %u out of range\n", pps_id);
return AVERROR_INVALIDDATA;
}
if (!h0->pps_buffers[pps_id]) {
av_log(h->avctx, AV_LOG_ERROR,
"non-existing PPS %u referenced\n",
pps_id);
return AVERROR_INVALIDDATA;
}
if (h0->au_pps_id >= 0 && pps_id != h0->au_pps_id) {
av_log(h->avctx, AV_LOG_ERROR,
"PPS change from %d to %d forbidden\n",
h0->au_pps_id, pps_id);
return AVERROR_INVALIDDATA;
}
pps = h0->pps_buffers[pps_id];
if (!h0->sps_buffers[pps->sps_id]) {
av_log(h->avctx, AV_LOG_ERROR,
"non-existing SPS %u referenced\n",
h->pps.sps_id);
return AVERROR_INVALIDDATA;
}
if (first_slice)
h->pps = *h0->pps_buffers[pps_id];
if (pps->sps_id != h->sps.sps_id ||
pps->sps_id != h->current_sps_id ||
h0->sps_buffers[pps->sps_id]->new) {
if (!first_slice) {
av_log(h->avctx, AV_LOG_ERROR,
"SPS changed in the middle of the frame\n");
return AVERROR_INVALIDDATA;
}
h->sps = *h0->sps_buffers[h->pps.sps_id];
if (h->mb_width != h->sps.mb_width ||
h->mb_height != h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag) ||
h->avctx->bits_per_raw_sample != h->sps.bit_depth_luma ||
h->cur_chroma_format_idc != h->sps.chroma_format_idc
)
needs_reinit = 1;
if (h->bit_depth_luma != h->sps.bit_depth_luma ||
h->chroma_format_idc != h->sps.chroma_format_idc) {
h->bit_depth_luma = h->sps.bit_depth_luma;
h->chroma_format_idc = h->sps.chroma_format_idc;
needs_reinit = 1;
}
if ((ret = ff_h264_set_parameter_from_sps(h)) < 0)
return ret;
}
h->avctx->profile = ff_h264_get_profile(&h->sps);
h->avctx->level = h->sps.level_idc;
h->avctx->refs = h->sps.ref_frame_count;
must_reinit = (h->context_initialized &&
( 16*h->sps.mb_width != h->avctx->coded_width
|| 16*h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag) != h->avctx->coded_height
|| h->avctx->bits_per_raw_sample != h->sps.bit_depth_luma
|| h->cur_chroma_format_idc != h->sps.chroma_format_idc
|| h->mb_width != h->sps.mb_width
|| h->mb_height != h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag)
));
if (non_j_pixfmt(h0->avctx->pix_fmt) != non_j_pixfmt(get_pixel_format(h0, 0)))
must_reinit = 1;
if (first_slice && av_cmp_q(h->sps.sar, h->avctx->sample_aspect_ratio))
must_reinit = 1;
h->mb_width = h->sps.mb_width;
h->mb_height = h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag);
h->mb_num = h->mb_width * h->mb_height;
h->mb_stride = h->mb_width + 1;
h->b_stride = h->mb_width * 4;
h->chroma_y_shift = h->sps.chroma_format_idc <= 1;
h->width = 16 * h->mb_width;
h->height = 16 * h->mb_height;
ret = init_dimensions(h);
if (ret < 0)
return ret;
if (h->sps.video_signal_type_present_flag) {
h->avctx->color_range = h->sps.full_range>0 ? AVCOL_RANGE_JPEG
: AVCOL_RANGE_MPEG;
if (h->sps.colour_description_present_flag) {
if (h->avctx->colorspace != h->sps.colorspace)
needs_reinit = 1;
h->avctx->color_primaries = h->sps.color_primaries;
h->avctx->color_trc = h->sps.color_trc;
h->avctx->colorspace = h->sps.colorspace;
}
}
if (h->context_initialized &&
(must_reinit || needs_reinit)) {
if (h != h0) {
av_log(h->avctx, AV_LOG_ERROR,
"changing width %d -> %d / height %d -> %d on "
"slice %d\n",
h->width, h->avctx->coded_width,
h->height, h->avctx->coded_height,
h0->current_slice + 1);
return AVERROR_INVALIDDATA;
}
av_assert1(first_slice);
ff_h264_flush_change(h);
if ((ret = get_pixel_format(h, 1)) < 0)
return ret;
h->avctx->pix_fmt = ret;
av_log(h->avctx, AV_LOG_INFO, "Reinit context to %dx%d, "
"pix_fmt: %s\n", h->width, h->height, av_get_pix_fmt_name(h->avctx->pix_fmt));
if ((ret = h264_slice_header_init(h, 1)) < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"h264_slice_header_init() failed\n");
return ret;
}
}
if (!h->context_initialized) {
if (h != h0) {
av_log(h->avctx, AV_LOG_ERROR,
"Cannot (re-)initialize context during parallel decoding.\n");
return AVERROR_PATCHWELCOME;
}
if ((ret = get_pixel_format(h, 1)) < 0)
return ret;
h->avctx->pix_fmt = ret;
if ((ret = h264_slice_header_init(h, 0)) < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"h264_slice_header_init() failed\n");
return ret;
}
}
if (h == h0 && h->dequant_coeff_pps != pps_id) {
h->dequant_coeff_pps = pps_id;
h264_init_dequant_tables(h);
}
frame_num = get_bits(&h->gb, h->sps.log2_max_frame_num);
if (!first_slice) {
if (h0->frame_num != frame_num) {
av_log(h->avctx, AV_LOG_ERROR, "Frame num change from %d to %d\n",
h0->frame_num, frame_num);
return AVERROR_INVALIDDATA;
}
}
h->mb_mbaff = 0;
h->mb_aff_frame = 0;
last_pic_structure = h0->picture_structure;
last_pic_droppable = h0->droppable;
droppable = h->nal_ref_idc == 0;
if (h->sps.frame_mbs_only_flag) {
picture_structure = PICT_FRAME;
} else {
if (!h->sps.direct_8x8_inference_flag && slice_type == AV_PICTURE_TYPE_B) {
av_log(h->avctx, AV_LOG_ERROR, "This stream was generated by a broken encoder, invalid 8x8 inference\n");
return -1;
}
field_pic_flag = get_bits1(&h->gb);
if (field_pic_flag) {
bottom_field_flag = get_bits1(&h->gb);
picture_structure = PICT_TOP_FIELD + bottom_field_flag;
} else {
picture_structure = PICT_FRAME;
h->mb_aff_frame = h->sps.mb_aff;
}
}
if (h0->current_slice) {
if (last_pic_structure != picture_structure ||
last_pic_droppable != droppable) {
av_log(h->avctx, AV_LOG_ERROR,
"Changing field mode (%d -> %d) between slices is not allowed\n",
last_pic_structure, h->picture_structure);
return AVERROR_INVALIDDATA;
} else if (!h0->cur_pic_ptr) {
av_log(h->avctx, AV_LOG_ERROR,
"unset cur_pic_ptr on slice %d\n",
h0->current_slice + 1);
return AVERROR_INVALIDDATA;
}
}
h->picture_structure = picture_structure;
h->droppable = droppable;
h->frame_num = frame_num;
h->mb_field_decoding_flag = picture_structure != PICT_FRAME;
if (h0->current_slice == 0) {
if (h->frame_num != h->prev_frame_num) {
int unwrap_prev_frame_num = h->prev_frame_num;
int max_frame_num = 1 << h->sps.log2_max_frame_num;
if (unwrap_prev_frame_num > h->frame_num)
unwrap_prev_frame_num -= max_frame_num;
if ((h->frame_num - unwrap_prev_frame_num) > h->sps.ref_frame_count) {
unwrap_prev_frame_num = (h->frame_num - h->sps.ref_frame_count) - 1;
if (unwrap_prev_frame_num < 0)
unwrap_prev_frame_num += max_frame_num;
h->prev_frame_num = unwrap_prev_frame_num;
}
}
if (h0->first_field) {
assert(h0->cur_pic_ptr);
assert(h0->cur_pic_ptr->f.buf[0]);
assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
if (h0->cur_pic_ptr->tf.owner == h0->avctx) {
ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
last_pic_structure == PICT_BOTTOM_FIELD);
}
if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
if (last_pic_structure != PICT_FRAME) {
ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
last_pic_structure == PICT_TOP_FIELD);
}
} else {
if (h0->cur_pic_ptr->frame_num != h->frame_num) {
if (last_pic_structure != PICT_FRAME) {
ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
last_pic_structure == PICT_TOP_FIELD);
}
} else {
if (!((last_pic_structure == PICT_TOP_FIELD &&
h->picture_structure == PICT_BOTTOM_FIELD) ||
(last_pic_structure == PICT_BOTTOM_FIELD &&
h->picture_structure == PICT_TOP_FIELD))) {
av_log(h->avctx, AV_LOG_ERROR,
"Invalid field mode combination %d/%d\n",
last_pic_structure, h->picture_structure);
h->picture_structure = last_pic_structure;
h->droppable = last_pic_droppable;
return AVERROR_INVALIDDATA;
} else if (last_pic_droppable != h->droppable) {
avpriv_request_sample(h->avctx,
"Found reference and non-reference fields in the same frame, which");
h->picture_structure = last_pic_structure;
h->droppable = last_pic_droppable;
return AVERROR_PATCHWELCOME;
}
}
}
}
while (h->frame_num != h->prev_frame_num && !h0->first_field &&
h->frame_num != (h->prev_frame_num + 1) % (1 << h->sps.log2_max_frame_num)) {
H264Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL;
av_log(h->avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n",
h->frame_num, h->prev_frame_num);
if (!h->sps.gaps_in_frame_num_allowed_flag)
for(i=0; i<FF_ARRAY_ELEMS(h->last_pocs); i++)
h->last_pocs[i] = INT_MIN;
ret = h264_frame_start(h);
if (ret < 0) {
h0->first_field = 0;
return ret;
}
h->prev_frame_num++;
h->prev_frame_num %= 1 << h->sps.log2_max_frame_num;
h->cur_pic_ptr->frame_num = h->prev_frame_num;
h->cur_pic_ptr->invalid_gap = !h->sps.gaps_in_frame_num_allowed_flag;
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 1);
ret = ff_generate_sliding_window_mmcos(h, 1);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
return ret;
ret = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
return ret;
if (h->short_ref_count) {
if (prev) {
av_image_copy(h->short_ref[0]->f.data,
h->short_ref[0]->f.linesize,
(const uint8_t **)prev->f.data,
prev->f.linesize,
h->avctx->pix_fmt,
h->mb_width * 16,
h->mb_height * 16);
h->short_ref[0]->poc = prev->poc + 2;
}
h->short_ref[0]->frame_num = h->prev_frame_num;
}
}
if (h0->first_field) {
assert(h0->cur_pic_ptr);
assert(h0->cur_pic_ptr->f.buf[0]);
assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
h0->missing_fields ++;
h0->cur_pic_ptr = NULL;
h0->first_field = FIELD_PICTURE(h);
} else {
h0->missing_fields = 0;
if (h0->cur_pic_ptr->frame_num != h->frame_num) {
ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
h0->picture_structure==PICT_BOTTOM_FIELD);
h0->first_field = 1;
h0->cur_pic_ptr = NULL;
} else {
h0->first_field = 0;
}
}
} else {
h0->first_field = FIELD_PICTURE(h);
}
if (!FIELD_PICTURE(h) || h0->first_field) {
if (h264_frame_start(h) < 0) {
h0->first_field = 0;
return AVERROR_INVALIDDATA;
}
} else {
release_unused_pictures(h, 0);
}
if (FIELD_PICTURE(h)) {
for(i = (h->picture_structure == PICT_BOTTOM_FIELD); i<h->mb_height; i++)
memset(h->slice_table + i*h->mb_stride, -1, (h->mb_stride - (i+1==h->mb_height)) * sizeof(*h->slice_table));
} else {
memset(h->slice_table, -1,
(h->mb_height * h->mb_stride - 1) * sizeof(*h->slice_table));
}
h0->last_slice_type = -1;
}
if (h != h0 && (ret = clone_slice(h, h0)) < 0)
return ret;
for (i = 0; i < h->slice_context_count; i++)
if (h->thread_context[i]) {
ret = alloc_scratch_buffers(h->thread_context[i], h->linesize);
if (ret < 0)
return ret;
}
h->cur_pic_ptr->frame_num = h->frame_num;
av_assert1(h->mb_num == h->mb_width * h->mb_height);
if (first_mb_in_slice << FIELD_OR_MBAFF_PICTURE(h) >= h->mb_num ||
first_mb_in_slice >= h->mb_num) {
av_log(h->avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n");
return AVERROR_INVALIDDATA;
}
h->resync_mb_x = h->mb_x = first_mb_in_slice % h->mb_width;
h->resync_mb_y = h->mb_y = (first_mb_in_slice / h->mb_width) <<
FIELD_OR_MBAFF_PICTURE(h);
if (h->picture_structure == PICT_BOTTOM_FIELD)
h->resync_mb_y = h->mb_y = h->mb_y + 1;
av_assert1(h->mb_y < h->mb_height);
if (h->picture_structure == PICT_FRAME) {
h->curr_pic_num = h->frame_num;
h->max_pic_num = 1 << h->sps.log2_max_frame_num;
} else {
h->curr_pic_num = 2 * h->frame_num + 1;
h->max_pic_num = 1 << (h->sps.log2_max_frame_num + 1);
}
if (h->nal_unit_type == NAL_IDR_SLICE)
get_ue_golomb(&h->gb);
if (h->sps.poc_type == 0) {
h->poc_lsb = get_bits(&h->gb, h->sps.log2_max_poc_lsb);
if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME)
h->delta_poc_bottom = get_se_golomb(&h->gb);
}
if (h->sps.poc_type == 1 && !h->sps.delta_pic_order_always_zero_flag) {
h->delta_poc[0] = get_se_golomb(&h->gb);
if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME)
h->delta_poc[1] = get_se_golomb(&h->gb);
}
ff_init_poc(h, h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc);
if (h->pps.redundant_pic_cnt_present)
h->redundant_pic_count = get_ue_golomb(&h->gb);
ret = ff_set_ref_count(h);
if (ret < 0)
return ret;
if (slice_type != AV_PICTURE_TYPE_I &&
(h0->current_slice == 0 ||
slice_type != h0->last_slice_type ||
memcmp(h0->last_ref_count, h0->ref_count, sizeof(h0->ref_count)))) {
ff_h264_fill_default_ref_list(h);
}
if (h->slice_type_nos != AV_PICTURE_TYPE_I) {
ret = ff_h264_decode_ref_pic_list_reordering(h);
if (ret < 0) {
h->ref_count[1] = h->ref_count[0] = 0;
return ret;
}
}
if ((h->pps.weighted_pred && h->slice_type_nos == AV_PICTURE_TYPE_P) ||
(h->pps.weighted_bipred_idc == 1 &&
h->slice_type_nos == AV_PICTURE_TYPE_B))
ff_pred_weight_table(h);
else if (h->pps.weighted_bipred_idc == 2 &&
h->slice_type_nos == AV_PICTURE_TYPE_B) {
implicit_weight_table(h, -1);
} else {
h->use_weight = 0;
for (i = 0; i < 2; i++) {
h->luma_weight_flag[i] = 0;
h->chroma_weight_flag[i] = 0;
}
}
if (h->nal_ref_idc) {
ret = ff_h264_decode_ref_pic_marking(h0, &h->gb,
!(h->avctx->active_thread_type & FF_THREAD_FRAME) ||
h0->current_slice == 0);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
}
if (FRAME_MBAFF(h)) {
ff_h264_fill_mbaff_ref_list(h);
if (h->pps.weighted_bipred_idc == 2 && h->slice_type_nos == AV_PICTURE_TYPE_B) {
implicit_weight_table(h, 0);
implicit_weight_table(h, 1);
}
}
if (h->slice_type_nos == AV_PICTURE_TYPE_B && !h->direct_spatial_mv_pred)
ff_h264_direct_dist_scale_factor(h);
ff_h264_direct_ref_list_init(h);
if (h->slice_type_nos != AV_PICTURE_TYPE_I && h->pps.cabac) {
tmp = get_ue_golomb_31(&h->gb);
if (tmp > 2) {
av_log(h->avctx, AV_LOG_ERROR, "cabac_init_idc %u overflow\n", tmp);
return AVERROR_INVALIDDATA;
}
h->cabac_init_idc = tmp;
}
h->last_qscale_diff = 0;
tmp = h->pps.init_qp + get_se_golomb(&h->gb);
if (tmp > 51 + 6 * (h->sps.bit_depth_luma - 8)) {
av_log(h->avctx, AV_LOG_ERROR, "QP %u out of range\n", tmp);
return AVERROR_INVALIDDATA;
}
h->qscale = tmp;
h->chroma_qp[0] = get_chroma_qp(h, 0, h->qscale);
h->chroma_qp[1] = get_chroma_qp(h, 1, h->qscale);
if (h->slice_type == AV_PICTURE_TYPE_SP)
get_bits1(&h->gb);
if (h->slice_type == AV_PICTURE_TYPE_SP ||
h->slice_type == AV_PICTURE_TYPE_SI)
get_se_golomb(&h->gb);
h->deblocking_filter = 1;
h->slice_alpha_c0_offset = 0;
h->slice_beta_offset = 0;
if (h->pps.deblocking_filter_parameters_present) {
tmp = get_ue_golomb_31(&h->gb);
if (tmp > 2) {
av_log(h->avctx, AV_LOG_ERROR,
"deblocking_filter_idc %u out of range\n", tmp);
return AVERROR_INVALIDDATA;
}
h->deblocking_filter = tmp;
if (h->deblocking_filter < 2)
h->deblocking_filter ^= 1;
if (h->deblocking_filter) {
h->slice_alpha_c0_offset = get_se_golomb(&h->gb) * 2;
h->slice_beta_offset = get_se_golomb(&h->gb) * 2;
if (h->slice_alpha_c0_offset > 12 ||
h->slice_alpha_c0_offset < -12 ||
h->slice_beta_offset > 12 ||
h->slice_beta_offset < -12) {
av_log(h->avctx, AV_LOG_ERROR,
"deblocking filter parameters %d %d out of range\n",
h->slice_alpha_c0_offset, h->slice_beta_offset);
return AVERROR_INVALIDDATA;
}
}
}
if (h->avctx->skip_loop_filter >= AVDISCARD_ALL ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&
h->nal_unit_type != NAL_IDR_SLICE) ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONINTRA &&
h->slice_type_nos != AV_PICTURE_TYPE_I) ||
(h->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
h->slice_type_nos == AV_PICTURE_TYPE_B) ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONREF &&
h->nal_ref_idc == 0))
h->deblocking_filter = 0;
if (h->deblocking_filter == 1 && h0->max_contexts > 1) {
if (h->avctx->flags2 & CODEC_FLAG2_FAST) {
h->deblocking_filter = 2;
} else {
h0->max_contexts = 1;
if (!h0->single_decode_warning) {
av_log(h->avctx, AV_LOG_INFO,
"Cannot parallelize slice decoding with deblocking filter type 1, decoding such frames in sequential order\n"
"To parallelize slice decoding you need video encoded with disable_deblocking_filter_idc set to 2 (deblock only edges that do not cross slices).\n"
"Setting the flags2 libavcodec option to +fast (-flags2 +fast) will disable deblocking across slices and enable parallel slice decoding "
"but will generate non-standard-compliant output.\n");
h0->single_decode_warning = 1;
}
if (h != h0) {
av_log(h->avctx, AV_LOG_ERROR,
"Deblocking switched inside frame.\n");
return SLICE_SINGLETHREAD;
}
}
}
h->qp_thresh = 15 -
FFMIN(h->slice_alpha_c0_offset, h->slice_beta_offset) -
FFMAX3(0,
h->pps.chroma_qp_index_offset[0],
h->pps.chroma_qp_index_offset[1]) +
6 * (h->sps.bit_depth_luma - 8);
h0->last_slice_type = slice_type;
memcpy(h0->last_ref_count, h0->ref_count, sizeof(h0->last_ref_count));
h->slice_num = ++h0->current_slice;
if (h->slice_num)
h0->slice_row[(h->slice_num-1)&(MAX_SLICES-1)]= h->resync_mb_y;
if ( h0->slice_row[h->slice_num&(MAX_SLICES-1)] + 3 >= h->resync_mb_y
&& h0->slice_row[h->slice_num&(MAX_SLICES-1)] <= h->resync_mb_y
&& h->slice_num >= MAX_SLICES) {
av_log(h->avctx, AV_LOG_WARNING, "Possibly too many slices (%d >= %d), increase MAX_SLICES and recompile if there are artifacts\n", h->slice_num, MAX_SLICES);
}
for (j = 0; j < 2; j++) {
int id_list[16];
int *ref2frm = h->ref2frm[h->slice_num & (MAX_SLICES - 1)][j];
for (i = 0; i < 16; i++) {
id_list[i] = 60;
if (j < h->list_count && i < h->ref_count[j] &&
h->ref_list[j][i].f.buf[0]) {
int k;
AVBuffer *buf = h->ref_list[j][i].f.buf[0]->buffer;
for (k = 0; k < h->short_ref_count; k++)
if (h->short_ref[k]->f.buf[0]->buffer == buf) {
id_list[i] = k;
break;
}
for (k = 0; k < h->long_ref_count; k++)
if (h->long_ref[k] && h->long_ref[k]->f.buf[0]->buffer == buf) {
id_list[i] = h->short_ref_count + k;
break;
}
}
}
ref2frm[0] =
ref2frm[1] = -1;
for (i = 0; i < 16; i++)
ref2frm[i + 2] = 4 * id_list[i] + (h->ref_list[j][i].reference & 3);
ref2frm[18 + 0] =
ref2frm[18 + 1] = -1;
for (i = 16; i < 48; i++)
ref2frm[i + 4] = 4 * id_list[(i - 16) >> 1] +
(h->ref_list[j][i].reference & 3);
}
h0->au_pps_id = pps_id;
h->sps.new =
h0->sps_buffers[h->pps.sps_id]->new = 0;
h->current_sps_id = h->pps.sps_id;
if (h->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(h->avctx, AV_LOG_DEBUG,
"slice:%d %s mb:%d %c%s%s pps:%u frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s %s\n",
h->slice_num,
(h->picture_structure == PICT_FRAME ? "F" : h->picture_structure == PICT_TOP_FIELD ? "T" : "B"),
first_mb_in_slice,
av_get_picture_type_char(h->slice_type),
h->slice_type_fixed ? " fix" : "",
h->nal_unit_type == NAL_IDR_SLICE ? " IDR" : "",
pps_id, h->frame_num,
h->cur_pic_ptr->field_poc[0],
h->cur_pic_ptr->field_poc[1],
h->ref_count[0], h->ref_count[1],
h->qscale,
h->deblocking_filter,
h->slice_alpha_c0_offset, h->slice_beta_offset,
h->use_weight,
h->use_weight == 1 && h->use_weight_chroma ? "c" : "",
h->slice_type == AV_PICTURE_TYPE_B ? (h->direct_spatial_mv_pred ? "SPAT" : "TEMP") : "");
}
return 0;
}
| 1threat |
static void gic_dist_writew(void *opaque, target_phys_addr_t offset,
uint32_t value)
{
gic_dist_writeb(opaque, offset, value & 0xff);
gic_dist_writeb(opaque, offset + 1, value >> 8);
}
| 1threat |
Spring controller gets invoked but returns 404 : <p>I am writing a Spring Boot application. I have written a simple controller that gets invoked whenever the endpoint is hit, but it still returns status 404 and not the specified return value.</p>
<p><strong>HelloController</strong></p>
<pre><code>@Controller
public class MessageRequestController {
@RequestMapping(method = RequestMethod.GET, value = "/hello", produces = "application/json")
public String hello() {
System.out.println("Hit me!");
return "Hello, you!";
}
}
</code></pre>
<p>Now whenever I call <code>localhost:8080/hello</code>, I see the console log <code>"Hit me!"</code>, but <code>"Hello, you!"</code> is never returned. Postman outputs:</p>
<pre><code>{
"timestamp": 1516953147719,
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/hello"
}
</code></pre>
<p><strong>Application.java</strong></p>
<pre><code>@SpringBootApplication
@ComponentScan({"com.sergialmar.wschat"}) // this is the root package of everything
@EntityScan("com.sergialmar.wschat")
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
</code></pre>
| 0debug |
Flattering objects + arrays + objects into one object javascript : <p>I will go straight to the point, so here is what I have:</p>
<pre><code> const someObj = {
one: [
{
id: 123,
text: "lalala"
},
{
id: 456,
text: "lalala2"
},
{
id: 789,
text: "lalala3"
}
],
two: [
{
id: 111,
text: "text random"
},
{
id: 222,
text: "text random2"
},
{
id: 333,
text: "text random3"
}
]
};
</code></pre>
<p>and this is what I need to have: </p>
<pre><code> const someOtherObj = {
111: {
id: 111,
text: "text random"
},
222: {
id: 222,
text: "text random2"
},
333: {
id: 333,
text: "text random3"
},
123: {
id: 123,
text: "lalala"
},
456: {
id: 456,
text: "lalala2"
},
789: {
id: 789,
text: "lalala3"
}
};
</code></pre>
<p>I know this can be achieved without million loops, just I can't think of any smart solution. :/ So, maybe someone can help me to solve this puzzle? :)</p>
<p>Thanks :)</p>
| 0debug |
How do I receive files from my Android app on my website? : I would like the users of my Android app to be able to send zip files to my server using `http`. The use case I am imaging looks like this:
- The user sends a zip file and a String containing a password using a `HttpClient` and `HttpPost` (as described [here][1]) to my server.
- By logging in on `www.example.com/my_app` with existing password, users can download the files that the people have sent to my server under the given password.
I don't understand how to do the second step. What code do I need to write on my website to receive files that the Android users have been sending? I have a shared server under my hosting plan and a simple website.
[1]: https://stackoverflow.com/a/4126746/2784835 | 0debug |
How do I generate a list of the text with that has given color with MS Word? : I am looking for a way to create a new document containing all the text with a specific format from my document.
See below for what I wrote so far, but I'm stuck at two points:
- how do I stop my loop when end of document is reached?
- how do I add intelligence to my code to avoid a static loop, and rather do a "scan all my document"?
----
Option Explicit
Sub Macro1()
Dim objWord As Application
Dim objDoc As Document
Dim objSelection As Selection
Dim mArray() As String
Dim i As Long
Dim doc As Word.Document
For i = 1 To 100
ReDim Preserve mArray(i)
With Selection.Find
.ClearFormatting
.Font.Color = wdColorBlue
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.Execute
End With
mArray(i) = Selection.Text
Next
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add
objWord.Visible = True
Set objSelection = objWord.Selection
For i = 1 To 100
objSelection.TypeText (mArray(i))
Next
End Sub
Any help appreciated. | 0debug |
How do I replace all of Column A's values with Column B's values unless Column B's value is NaN? : <p>Given the following DataFrame:</p>
<pre><code>import numpy as np
import pandas as pd
df = pd.DataFrame({"ColA": [1, 2, np.nan, 4, np.nan],
"ColB": [np.nan, 7, np.nan, 9, 10]})
ColA ColB
0 1.0 NaN
1 2.0 7.0
2 NaN NaN
3 4.0 9.0
4 NaN 10.0
</code></pre>
<p>I want to replace the values of ColA with those of ColB, but I never want a NaN value to replace a non-NaN value. My desired output is the following DataFrame:</p>
<pre><code> ColA ColB
0 1.0 NaN
1 7.0 7.0
2 NaN NaN
3 9.0 9.0
4 10.0 10.0
</code></pre>
<p>My actual data is quite large, so while I know that I can iterate row-by-row I am looking for a more efficient approach.</p>
| 0debug |
Questa CDC. Is there any command to invoke CDC in questa CDC (like in midelsim .vsim for simulation, in cadence simvision)? : Is there any command to invoke CDC in questa CDC (like in midelsim .vsim for simulation, in cadence simvision)? | 0debug |
Confused with comma's in PHP : <p>I know is a stupid question but well i am trying so hard but i can't figure out on where i am missing the comma i am totally confused ,The below code is giving me an error.</p>
<p>it would be great if someone can help me out with a referencing on comma and tips / Tricks on them :) </p>
<p>i tried replacing the commas in different places but still it didn't worked out.</p>
<pre><code> <td><?php echo <a href="test1.php?id=<?php echo $row['ID'];?>"/>Download! ?></a></td>
</code></pre>
<p>Thanks :) </p>
| 0debug |
UIStackView inside UICollectionViewCell autolayout issues after running on Xcode 10 beta : <p>My stack view contains an image and label to display some tasks. They were all left aligned on multiple rows. </p>
<p>I didn't have any issue running on Xcode 9, but when I run on Xcode 10 beta 6, I get some autolayout issues, I always get errors like for the stack view:</p>
<pre><code>Need constraint for X position
Need constraint for Y position
</code></pre>
<p>My current constraints for stack view are:</p>
<pre><code>Leading edge to cell - 5
Trailing edge to cell - 5
Bottom edge to cell - 2
Top edge to cell - 2
</code></pre>
<p>So I don't see what changed to complain about this, for me it's obvious that I have the X and Y set already.</p>
<p>Here is two screenshots with how it looks when it runs (label is truncated) and the storyboard:</p>
<p><a href="https://i.stack.imgur.com/xBico.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xBico.png" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/5qsAF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5qsAF.png" alt="enter image description here"></a></p>
| 0debug |
static bool raw_is_inserted(BlockDriverState *bs)
{
return bdrv_is_inserted(bs->file->bs);
}
| 1threat |
static uint64_t unin_data_read(void *opaque, hwaddr addr,
unsigned len)
{
UNINState *s = opaque;
PCIHostState *phb = PCI_HOST_BRIDGE(s);
uint32_t val;
val = pci_data_read(phb->bus,
unin_get_config_reg(phb->config_reg, addr),
len);
UNIN_DPRINTF("read addr %" TARGET_FMT_plx " len %d val %x\n",
addr, len, val);
return val;
}
| 1threat |
How to remove view controller stack and only show one view controller : <p>When I present another view controller, it shows this view:</p>
<p><a href="https://i.stack.imgur.com/85FPy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/85FPy.png" alt="enter image description here"></a></p>
<p>How do I change it so that my program only shows the destination view controller without this effect?</p>
| 0debug |
a very very simple fortran question for you but a maddening chalenge for me: : a very very simple question for you but a maddening chalenge for me:
whats wrong whit this Fortran code:
program NAME
implicit none
real :: i, j(i)
do i=1, 100
j(i)=2*i
write(*,*) i , j(i)
end do
pause
end program
| 0debug |
How to take arbitrary number of pranthesis from user for add function : add(5)(10)(20) i.e. one should be able to supply arbitrary number of parenthesis.Any help? | 0debug |
void ff_release_unused_pictures(MpegEncContext *s, int remove_current)
{
int i;
for(i=0; i<s->picture_count; i++){
if(s->picture[i].data[0] && !s->picture[i].reference
&& s->picture[i].owner2 == s
&& (remove_current || &s->picture[i] != s->current_picture_ptr)
){
free_frame_buffer(s, &s->picture[i]);
}
}
}
| 1threat |
Why go doesn't report "slice bounds out of range" in this case? : <p>Here's the code to reproduce:</p>
<pre><code>package main
import "fmt"
func main() {
var v []int
v = append(v,1)
v = append(v,v[1:]...)
fmt.Println("hi", v)
}
</code></pre>
<p><code>v[1]</code> will report <code>index out of range</code>, but <code>v[1:]...</code> won't, why? </p>
| 0debug |
static void lsi_mmio_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
LSIState *s = opaque;
lsi_reg_writeb(s, addr & 0xff, val);
}
| 1threat |
Why sorting mixed list does not work : <p>Been scratching my head this one for quite some time:</p>
<pre><code>mixed = [-131.23, 33213, 4454, 566, -33, 465. -377.312, 5.6656]
print(sorted(mixed, key=float))
</code></pre>
<p>Expected output is:</p>
<pre><code>[-131.23, -377.312, -33, 5.6656, 566, 4454, 33213]
</code></pre>
<p>Instead I'm always getting this</p>
<pre><code>[-131.23, -33, 5.6656, 87.68799999999999, 566, 4454, 33213]
</code></pre>
<p>Why -337.312 gets converted to 87.6879999999?? I assume each element gets converted to float when using key=float...so why this behaviour?</p>
| 0debug |
Is there an array method in ruby for "must include at least one of these but can't include anything else"? : I'm doing an exercise where the input is an array containing multiple n, s, e and w strings denoting directions. I need a way to give a false if anything else is in there, but the array doesn't necessarily have to include each of the n, s, e, w, just at least one of them. Is there a pre-defined method for this that'll get me close at least? | 0debug |
ReGex Help -- extracting the number beside the word : <p>Using PHP, I need to know how to obtain the number that's beside the phrase "Page count:". Here's how the output looks like.</p>
<pre><code>$string = 'Author: Microtest Windows Version 1.1
Creation time: 2016-02-12 02:51:00
Last modified by: Some Name
Last modification time: 2016-02-12 15:51:00
Page count: 14
Word count: 5142';
</code></pre>
<p>In this case, I want to store the page count as $page_number. I.e.</p>
<pre><code>echo $page_number; --> 14
</code></pre>
<p>How would I do this using REGEX</p>
| 0debug |
executeQuery NullPointerException Error : <p>I'm begginer at this that's probably why I'm having this error while I'm trying to do something very simple.</p>
<p>I just want to get the current user ID and use it in other classes. But I'm getting NullPointerException Error for the ExecuteQuery() line.</p>
<p>Let me share the code:</p>
<pre><code>public class LoginPage extends javax.swing.JFrame {
private Connection conn=null;
private ResultSet rs=null;
private PreparedStatement pst=null;
private PreparedStatement sta=null;
ConnectionDB connect=new ConnectionDB();
public LoginPage() {
initComponents();
}
public void getCurrentUser(){
try{
PreparedStatement c;
conn=connect.getConnection();
PreparedStatement stmt = conn.prepareStatement("SELECT * FROM users where Mail=?");
stmt.setString(1, lMail.getText());
ResultSet rss=sta.executeQuery();
if(rss.next()){
int CurrentUserID=rss.getInt("ID");
}
}
catch(SQLException ex){
System.out.println("SQL Exception Error!1");
}
}
private void loginButtonActionPerformed(java.awt.event.ActionEvent evt) {
String sql="SELECT * from users where Mail=? and Password=?";
try{
conn=connect.getConnection();
pst=conn.prepareStatement(sql);
pst.setString(1,lMail.getText());
pst.setString(2,lPass.getText());
rs=pst.executeQuery();
if(rs.next()){
getCurrentUser();
JOptionPane.showMessageDialog(null, "Welcome!");
new ListPage().setVisible(true);
dispose();
}
else
{
JOptionPane.showMessageDialog(null, "Wrong mail-password combination!");
lPass.setText("");
}
}
catch(SQLException ex){
System.out.println("SQL Exception Error!");
}
}
</code></pre>
<p>"ResultSet rss=sta.executeQuery();" is the NullPointerException part.</p>
<p>I gave hours to solve this but I couldn't so I need your help.</p>
<p>Thank you</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.