problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
getting error missing right parenthesis but i think there is some issue with interval : select max(valdate) from CORE_TOTEM.TOTEM_MONTHEND_COVERAGE
where valdate<=sysdate and valdate>= DATE_ADD(sysdate, INTERVAL 5 DAY) | 0debug |
static MOVFragmentStreamInfo * get_current_frag_stream_info(
MOVFragmentIndex *frag_index)
{
MOVFragmentIndexItem * item = &frag_index->item[frag_index->current];
if (item->current >= 0 && item->current < item->nb_stream_info)
return &item->stream_info[item->current];
} | 1threat |
static int mmu_translate_segment(CPUS390XState *env, target_ulong vaddr,
uint64_t asc, uint64_t st_entry,
target_ulong *raddr, int *flags, int rw)
{
CPUState *cs = CPU(s390_env_get_cpu(env));
uint64_t origin, offs, pt_entry;
if (st_entry & _SEGMENT_ENTRY_RO) {
*flags &= ~PAGE_WRITE;
}
if ((st_entry & _SEGMENT_ENTRY_FC) && (env->cregs[0] & CR0_EDAT)) {
*raddr = (st_entry & 0xfffffffffff00000ULL) | (vaddr & 0xfffff);
PTE_DPRINTF("%s: SEG=0x%" PRIx64 "\n", __func__, st_entry);
return 0;
}
origin = st_entry & _SEGMENT_ENTRY_ORIGIN;
offs = (vaddr & VADDR_PX) >> 9;
pt_entry = ldq_phys(cs->as, origin + offs);
PTE_DPRINTF("%s: 0x%" PRIx64 " + 0x%" PRIx64 " => 0x%016" PRIx64 "\n",
__func__, origin, offs, pt_entry);
return mmu_translate_pte(env, vaddr, asc, pt_entry, raddr, flags, rw);
}
| 1threat |
convert array to string java : <p>Given an array of numbers (integers) how would I go about converting it to a string.</p>
<p>I am from JS so in we normally do : </p>
<pre><code>[1 , 2 , 3 , 4 , 5].join(separator)
</code></pre>
<p>But Java doesn't seem to do that. </p>
<p>I tried : </p>
<pre><code> array.join(" ")
</code></pre>
<p>But that throws an error on that it cannot find symbol. </p>
<hr>
<p>Here is the code : </p>
<pre><code>class Conv {
public static String findOut(int[] arr) {
return arr.join(" ");
}
}
</code></pre>
| 0debug |
email validation checking in Javascript : <p>I want to varify if the entered string is in email format or not. I am bit confused. I tried to write below code but failed. Can ayone help me please.</p>
<pre><code>Javascript Code:
<script>
function emailValidation(id)
{
var emailPattern = var emailPattern = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
if (emailPattern.test(id) === false)
{
alert("not a valid email address.");
}
document.getElementById(id).value = "";
}
</script>
HTML Code:
<input type="text" id="empemail" onblur="emailValidation('empemail')" name="email" placeholder="eg: aaa@abc.ca" required="">
</code></pre>
| 0debug |
What type of techniques should be used to display a moving cursor in circular path in java? : <p>I am trying to code using loop but i don't know how to move the cursor up from bottom of the screen and how to use delay method in java. Can anyone help me?
Thanks in advance.</p>
| 0debug |
Automated refactoring tool for java - eclipse IDE : <p>Our team wants to adopt a coherent coding style, that has an automated refactor tool to spread the style across the team easily (not in terms of formatting - more like preventing "mistakes" and detecting general pitfalls in the code).</p>
<p>We have those needs:</p>
<p><strong>- Working well with Eclipse, cross platform (linux/windows)</strong></p>
<p><strong>- Manipulate the code without changing its semantics</strong></p>
<p><strong>- Configurable (option to enable/disable rules)</strong></p>
<p><strong>- Optional: "Short Style" preferred ('v' instead of 'variable', if there is such tool that can do it)</strong></p>
<p>A bit strict needs - but I'm sure SO community will do it :)</p>
| 0debug |
Sum of very very large numbers : <p>Given two very large numbers <code>a</code> and <code>b</code> where <code>a < b</code>, the problem is to find the following sum:</p>
<pre><code>a + (a + 1) + (a + 2) + ... + (b - 2) + (b - 1) + b
</code></pre>
<p>The numbers <code>a</code> and <code>b</code> can be very very large (can contain millions of digits).</p>
<p>As these are very large numbers, programming languages cannot find the sum using integer data types.
So, the only option is to use strings.</p>
<p>What is the most efficient way to do so?</p>
| 0debug |
Teleprompter app in Xcode using Swift : <p>I have finished an online course in iOS development on Udemy and I'm ready to start developing my first (real) app.</p>
<p>My goal is to make a teleprompter app similar to: <a href="https://itunes.apple.com/dk/app/video-teleprompter-lite/id1031079244?mt=8" rel="nofollow">https://itunes.apple.com/dk/app/video-teleprompter-lite/id1031079244?mt=8</a></p>
<p>To start with, I would like to create just the moving text. I have looked at various concepts such as Core Animation, Text View, Segue from one view controller to another etc. But none of them seem to be able to display the moving text in the proper "teleprompter way". </p>
<p>I would really appreciate suggestions as to how to start/which relevant concepts to look at in this context. </p>
| 0debug |
How to use Ceiling function in Swift? : Really simple thing, but trying to convert this Excel formula into Swift
=CEILING(date+1,14)-1
Any ideas?
Thanks | 0debug |
develop android aplication in offline mode : I'm tried to develop an application but, I need to work offline because I do not have access to Internet and I can't access to many services of Google. My question: What do I need to develop in offline mode?, I have access to many different versions of Android Studio, gradle and sdk but I don't know what versions do I need. I use w8. How do I need to config Andorid Studio for work in offline mode? What version of gradle use?. Thanks in advance sorry for my English. I have these versions. (pictures)[Android Studio][1]
[Gradle][2]
[1]: https://i.stack.imgur.com/uXZi5.png
[2]: https://i.stack.imgur.com/TiQaZ.png | 0debug |
How to get rid of the warning .ts file is part of the TypeScript compilation but it's unused : <p>I Just updated angular to latest <code>9.0.0-next.4</code>. I am not using routing but suddenly after updating I keep seeing this warning. How Do I remove this warning</p>
<blockquote>
<p>WARNING in <code>src/war/angular/src/app/app-routing.module.ts</code> is part of
the TypeScript compilation but it's unused. Add only entry points to
the 'files' or 'include' properties in your tsconfig.</p>
</blockquote>
<p><strong>package.json</strong></p>
<pre><code> "dependencies": {
"@angular/animations": "^9.0.0-next.4",
"@angular/cdk": "^8.1.4",
"@angular/common": "^9.0.0-next.4",
"@angular/compiler": "^9.0.0-next.4",
"@angular/core": "^9.0.0-next.4",
"@angular/forms": "^9.0.0-next.4",
"@angular/material": "^8.1.4",
"@angular/platform-browser": "^9.0.0-next.4",
"@angular/platform-browser-dynamic": "^9.0.0-next.4",
"@angular/router": "^9.0.0-next.4",
"@ng-bootstrap/ng-bootstrap": "^5.1.0",
"bootstrap": "^4.3.1",
"hammerjs": "^2.0.8",
"moment": "^2.24.0",
"ng-image-slider": "^2.0.1",
"panzoom": "^8.1.2",
"rxjs": "~6.5.2",
"tslib": "^1.9.0",
"zone.js": "^0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.803.2",
"@angular/cli": "^8.3.2",
"@angular/compiler-cli": "^9.0.0-next.4",
"@angular/language-service": "^9.0.0-next.4",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "^5.15.0",
"typescript": "^3.5.3"
}
</code></pre>
<p><strong>tsconfig.json</strong></p>
<pre><code> {
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "esnext",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
}
}
</code></pre>
| 0debug |
ESLint React-Router v4 - How to validate Match params props? : <p>I'm using React-Router v4's <a href="https://reacttraining.com/react-router/web/api/match" rel="noreferrer">Match object</a> to pass down params to the next component. Where my Routing is like:</p>
<pre><code><Switch>
<Route exact path="/" component={ExperimentListPage} />
<Route path="/experiment/:experiment" component={ExperimentResultsPage} />
</Switch>
</code></pre>
<p>and my subcomponent looks like:</p>
<pre><code>const ExperimentResultsPage = props => (
<ExperimentResultsContainer experimentName={props.match.params.experiment} />
);
export default withRouter(ExperimentResultsPage);
</code></pre>
<p>And it all works as intended, however ESLint is really unhappy with me using <code>match.params.experiment</code> and it errors with <code>[eslint] 'match.params.experiment' is missing in props validation (react/prop-types)</code></p>
<p>I saw in the React docs that I could use <a href="https://facebook.github.io/react/docs/typechecking-with-proptypes.html" rel="noreferrer"><code>PropTypes.shape</code></a> however my params object but I was hoping there is a better way especially because the Match object contains a lot of fields.</p>
<p>Is there a better way of adding your Match route object to the props validation? How would that look like? If not, am I missing some other approach that could help solve this?</p>
| 0debug |
static int parse_video_var(AVFormatContext *avctx, AVStream *st, const char *name, int size)
{
AVIOContext *pb = avctx->pb;
if (!strcmp(name, "__DIR_COUNT")) {
st->nb_frames = st->duration = var_read_int(pb, size);
} else if (!strcmp(name, "COMPRESSION")) {
char * str = var_read_string(pb, size);
if (!strcmp(str, "1")) {
st->codec->codec_id = AV_CODEC_ID_MVC1;
} else if (!strcmp(str, "2")) {
st->codec->pix_fmt = AV_PIX_FMT_ABGR;
st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
} else if (!strcmp(str, "3")) {
st->codec->codec_id = AV_CODEC_ID_SGIRLE;
} else if (!strcmp(str, "10")) {
st->codec->codec_id = AV_CODEC_ID_MJPEG;
} else if (!strcmp(str, "MVC2")) {
st->codec->codec_id = AV_CODEC_ID_MVC2;
} else {
av_log_ask_for_sample(avctx, "unknown video compression %s\n", str);
}
av_free(str);
} else if (!strcmp(name, "FPS")) {
st->time_base = av_inv_q(var_read_float(pb, size));
} else if (!strcmp(name, "HEIGHT")) {
st->codec->height = var_read_int(pb, size);
} else if (!strcmp(name, "PIXEL_ASPECT")) {
st->sample_aspect_ratio = var_read_float(pb, size);
av_reduce(&st->sample_aspect_ratio.num, &st->sample_aspect_ratio.den,
st->sample_aspect_ratio.num, st->sample_aspect_ratio.den, INT_MAX);
} else if (!strcmp(name, "WIDTH")) {
st->codec->width = var_read_int(pb, size);
} else if (!strcmp(name, "ORIENTATION")) {
if (var_read_int(pb, size) == 1101) {
st->codec->extradata = av_strdup("BottomUp");
st->codec->extradata_size = 9;
}
} else if (!strcmp(name, "Q_SPATIAL") || !strcmp(name, "Q_TEMPORAL")) {
var_read_metadata(avctx, name, size);
} else if (!strcmp(name, "INTERLACING") || !strcmp(name, "PACKING")) {
avio_skip(pb, size);
} else
return -1;
return 0;
}
| 1threat |
void ff_imdct_calc_3dn2(MDCTContext *s, FFTSample *output,
const FFTSample *input, FFTSample *tmp)
{
long n8, n4, n2, n;
x86_reg k;
const uint16_t *revtab = s->fft.revtab;
const FFTSample *tcos = s->tcos;
const FFTSample *tsin = s->tsin;
const FFTSample *in1, *in2;
FFTComplex *z = (FFTComplex *)tmp;
n = 1 << s->nbits;
n2 = n >> 1;
n4 = n >> 2;
n8 = n >> 3;
in1 = input;
in2 = input + n2 - 1;
for(k = 0; k < n4; k++) {
asm volatile(
"movd %0, %%mm0 \n\t"
"movd %2, %%mm1 \n\t"
"punpckldq %1, %%mm0 \n\t"
"punpckldq %3, %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"pfmul %%mm1, %%mm0 \n\t"
"pswapd %%mm1, %%mm1 \n\t"
"pfmul %%mm1, %%mm2 \n\t"
"pfpnacc %%mm2, %%mm0 \n\t"
::"m"(in2[-2*k]), "m"(in1[2*k]),
"m"(tcos[k]), "m"(tsin[k])
);
asm volatile(
"movq %%mm0, %0 \n\t"
:"=m"(z[revtab[k]])
);
}
ff_fft_calc(&s->fft, z);
for(k = 0; k < n4; k++) {
asm volatile(
"movq %0, %%mm0 \n\t"
"movd %1, %%mm1 \n\t"
"punpckldq %2, %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"pfmul %%mm1, %%mm0 \n\t"
"pswapd %%mm1, %%mm1 \n\t"
"pfmul %%mm1, %%mm2 \n\t"
"pfpnacc %%mm2, %%mm0 \n\t"
"movq %%mm0, %0 \n\t"
:"+m"(z[k])
:"m"(tcos[k]), "m"(tsin[k])
);
}
k = n-8;
asm volatile("movd %0, %%mm7" ::"r"(1<<31));
asm volatile(
"1: \n\t"
"movq (%4,%0), %%mm0 \n\t"
"neg %0 \n\t"
"pswapd -8(%4,%0), %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"pxor %%mm7, %%mm2 \n\t"
"punpckldq %%mm1, %%mm2 \n\t"
"pswapd %%mm2, %%mm3 \n\t"
"punpckhdq %%mm1, %%mm0 \n\t"
"pswapd %%mm0, %%mm4 \n\t"
"pxor %%mm7, %%mm0 \n\t"
"pxor %%mm7, %%mm4 \n\t"
"movq %%mm3, -8(%3,%0) \n\t"
"movq %%mm4, -8(%2,%0) \n\t"
"neg %0 \n\t"
"movq %%mm0, (%1,%0) \n\t"
"movq %%mm2, (%2,%0) \n\t"
"sub $8, %0 \n\t"
"jge 1b \n\t"
:"+r"(k)
:"r"(output), "r"(output+n2), "r"(output+n), "r"(z+n8)
:"memory"
);
asm volatile("femms");
}
| 1threat |
Fetching drafts forbidden in Wordpress rest api : <p>I am using the <a href="https://www.npmjs.com/package/wpapi" rel="noreferrer">wpapi</a> npm module to interface with the WP rest api in a node app. I am authenticated and my user created some draft posts. When I go to the dashboard with the same credentials, I can see/edit the draft posts as well.</p>
<p>I am using this method to list the drafts:</p>
<pre><code>wp.posts().auth().param( 'context', 'edit' ).param( 'status', 'draft' )
</code></pre>
<p>But I keep getting this error:</p>
<pre><code>{ code: 'rest_invalid_param',
message: 'Invalid parameter(s): status',
data: { status: 400, params: { status: 'Status is forbidden.' } } }
</code></pre>
<p><a href="https://github.com/WP-API/node-wpapi/issues/154#issuecomment-312186212" rel="noreferrer">Here's where I've commented on the issue and some helpful context.</a></p>
<p>The curl response to <a href="http://localhost:8000/wp-json/wp/v2/posts?status=draft" rel="noreferrer">http://localhost:8000/wp-json/wp/v2/posts?status=draft</a> is the same error message so I don't believe the issue is with the node module.</p>
| 0debug |
How do I change the language of Android Studio manual : <p><a href="https://developer.android.com/studio/intro/index.html" rel="nofollow noreferrer">https://developer.android.com/studio/intro/index.html</a></p>
<p>Somehow I have left side in English and content side in Portuguese. It`s annoying and there is no options or something so I could change this. Please help.</p>
| 0debug |
What is the right approach to "This AsyncTask class should be static or leaks might occur" in Kotlin Android? : <p>There are many questions here dealing with <code>This class should be static or leaks might occur</code> in java android.</p>
<p><a href="https://stackoverflow.com/questions/11407943/this-handler-class-should-be-static-or-leaks-might-occur-incominghandler">This Handler class should be static or leaks might occur: IncomingHandler</a></p>
<p><a href="https://stackoverflow.com/questions/37188519/this-handler-class-should-be-static-or-leaks-might-occurasyncqueryhandler">This Handler class should be static or leaks might occur:AsyncQueryHandler</a></p>
<p><a href="https://stackoverflow.com/questions/44309241/this-asynctask-class-should-be-static-or-leaks-might-occur-anonymous-android-os">This AsyncTask class should be static or leaks might occur (anonymous android.os.AsyncTask)</a></p>
<p>The warning is due to the fact that inner class holds an implicit reference to the outer class, and hence preventing the outer class from GC'd.
The solution lies in the warning itself that the class should be declared static.</p>
<p>However, the solution is java specific. Given that kotlin has no <code>static</code> modifier, the closest thing is <a href="https://kotlinlang.org/docs/reference/object-declarations.html#companion-objects" rel="noreferrer">companion object</a> and companion object does hold reference to it's "outer class". </p>
<p>Below are my [failed] attempts with remarks</p>
<pre><code>class MyActivity : AppCompatActivity(), MyListener {
companion object {
class Attempt3Task(val callback: MyListener) : AsyncTask<Unit, Unit, Unit>() {
override fun doInBackground(vararg params: Unit?) {
TODO("")
}
override fun onPostExecute(result: Unit?) {
callback.updateUi()
}
}
}
inner class Attempt2Task : AsyncTask<Unit, Unit, Unit> () {
override fun doInBackground(vararg params: Unit?) {
TODO("
}
}
// Gives warning "This AsyncTask class should be static or leaks might occur"
val attempt_1 = object: AsyncTask<Unit, Unit, Unit>() {
override fun doInBackground(vararg params: Unit?) {
TODO("")
}
}
// Does not give warning but, as far as I can tell, is conceptually same as attempt_1
val attempt_2 = Attempt2Task()
// Does not give warning but companion object does have reference to the activity, no?
val attempt_3 = Attempt3Task(this)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
}
</code></pre>
<p>Are the assertion about attempt2 and attempt3 correct that even without the linter warning, the code is still leaking?</p>
<p>What options do we have to avoid the leaking?
Should I resolve to plain old top-level <code>class MyTask : AsyncTask<Unit, Unit, Unit> ()</code> with a member of <code>WeakReference</code> to callback?</p>
| 0debug |
Graphing any rational functions in python considering the asymptotes : <p>How to graph any rational function in python matplotlib (considering the asymptotes)</p>
<pre><code>numerator = input ("numerator: ")
denominator = input ("denominator: ")
</code></pre>
| 0debug |
void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size)
{
RTPMuxContext *s = s1->priv_data;
int len, max_packet_size;
uint8_t *p;
if ((s1->streams[0]->codec->extradata_size) == 0) {
size -= 7;
buff += 7;
}
max_packet_size = s->max_payload_size - MAX_AU_HEADERS_SIZE;
len = (s->buf_ptr - s->buf);
if ((s->num_frames == MAX_FRAMES_PER_PACKET) || (len && (len + size) > s->max_payload_size)) {
int au_size = s->num_frames * 2;
p = s->buf + MAX_AU_HEADERS_SIZE - au_size - 2;
if (p != s->buf) {
memmove(p + 2, s->buf + 2, au_size);
}
p[0] = ((au_size * 8) & 0xFF) >> 8;
p[1] = (au_size * 8) & 0xFF;
ff_rtp_send_data(s1, p, s->buf_ptr - p, 1);
s->num_frames = 0;
}
if (s->num_frames == 0) {
s->buf_ptr = s->buf + MAX_AU_HEADERS_SIZE;
s->timestamp = s->cur_timestamp;
}
if (size <= max_packet_size) {
p = s->buf + s->num_frames++ * 2 + 2;
*p++ = size >> 5;
*p = (size & 0x1F) << 3;
memcpy(s->buf_ptr, buff, size);
s->buf_ptr += size;
} else {
if (s->buf_ptr != s->buf + MAX_AU_HEADERS_SIZE) {
av_log(s1, AV_LOG_ERROR, "Strange...\n");
av_abort();
}
max_packet_size = s->max_payload_size - 4;
p = s->buf;
p[0] = 0;
p[1] = 16;
while (size > 0) {
len = FFMIN(size, max_packet_size);
p[2] = len >> 5;
p[3] = (size & 0x1F) << 3;
memcpy(p + 4, buff, len);
ff_rtp_send_data(s1, p, len + 4, len == size);
size -= len;
buff += len;
}
}
}
| 1threat |
static int colo_packet_compare_udp(Packet *spkt, Packet *ppkt)
{
int ret;
trace_colo_compare_main("compare udp");
ret = colo_packet_compare_common(ppkt, spkt);
if (ret) {
trace_colo_compare_udp_miscompare("primary pkt size", ppkt->size);
qemu_hexdump((char *)ppkt->data, stderr, "colo-compare", ppkt->size);
trace_colo_compare_udp_miscompare("Secondary pkt size", spkt->size);
qemu_hexdump((char *)spkt->data, stderr, "colo-compare", spkt->size);
}
return ret;
}
| 1threat |
Difference between lib and dist folders when packaging library using webpack? : <p>Ive just published my first package (a react component) to npm but im having some trouble understanding the difference between what the <code>lib</code> directory is compared to the <code>dist</code>.</p>
<p>Currently I generate both <code>lib</code> and <code>dist</code> however my package "main" points to the <code>dist</code> unminified js file which has been built using webpack and output as UMD. The lib folder is built using <code>babel</code> taking the <code>src</code> and outputting to <code>lib</code>.</p>
<p>The dist folder contains both [unminified/minified].js files as well as [unminified/minified].css files.</p>
<p>My main confusion is with the lib folder since imports from there currently wouldn't work seeing as I just transform <code>src -> lib</code> meaning the scss references are still there and the scss files aren't transformed either.</p>
<p>I use CSS Modules (css-loader, styles-loader, postcss-loader etc) to generate my CSS files and this is where the confusion is since, wouldn't I also need to use webpack to generate my <code>lib</code> folder seeing as the <code>scss</code> files/import references need to be transformed to <code>css</code>?</p>
<p><strong>Are you meant to have both lib and dist or is the UMD build in dist fulling the same purpose as that of having a lib folder?</strong></p>
<p><strong>If you are supposed to have both how would I achieve this, since I couldnt find any info regarding generating the lib folder when using CSS modules within your js files and still maintaing the same folder structure of that of src (while still generating dist)?</strong></p>
| 0debug |
coroutine_fn iscsi_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
int count, BdrvRequestFlags flags)
{
IscsiLun *iscsilun = bs->opaque;
struct IscsiTask iTask;
uint64_t lba;
uint32_t nb_blocks;
bool use_16_for_ws = iscsilun->use_16_for_rw;
if (!is_byte_request_lun_aligned(offset, count, iscsilun)) {
return -ENOTSUP;
}
if (flags & BDRV_REQ_MAY_UNMAP) {
if (!use_16_for_ws && !iscsilun->lbp.lbpws10) {
use_16_for_ws = true;
}
if (use_16_for_ws && !iscsilun->lbp.lbpws) {
flags &= ~BDRV_REQ_MAY_UNMAP;
use_16_for_ws = iscsilun->use_16_for_rw;
}
}
if (!(flags & BDRV_REQ_MAY_UNMAP) && !iscsilun->has_write_same) {
return -ENOTSUP;
}
lba = offset / iscsilun->block_size;
nb_blocks = count / iscsilun->block_size;
if (iscsilun->zeroblock == NULL) {
iscsilun->zeroblock = g_try_malloc0(iscsilun->block_size);
if (iscsilun->zeroblock == NULL) {
return -ENOMEM;
}
}
iscsi_co_init_iscsitask(iscsilun, &iTask);
retry:
if (use_16_for_ws) {
iTask.task = iscsi_writesame16_task(iscsilun->iscsi, iscsilun->lun, lba,
iscsilun->zeroblock, iscsilun->block_size,
nb_blocks, 0, !!(flags & BDRV_REQ_MAY_UNMAP),
0, 0, iscsi_co_generic_cb, &iTask);
} else {
iTask.task = iscsi_writesame10_task(iscsilun->iscsi, iscsilun->lun, lba,
iscsilun->zeroblock, iscsilun->block_size,
nb_blocks, 0, !!(flags & BDRV_REQ_MAY_UNMAP),
0, 0, iscsi_co_generic_cb, &iTask);
}
if (iTask.task == NULL) {
return -ENOMEM;
}
while (!iTask.complete) {
iscsi_set_events(iscsilun);
qemu_coroutine_yield();
}
if (iTask.status == SCSI_STATUS_CHECK_CONDITION &&
iTask.task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
(iTask.task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE ||
iTask.task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB)) {
iscsilun->has_write_same = false;
scsi_free_scsi_task(iTask.task);
return -ENOTSUP;
}
if (iTask.task != NULL) {
scsi_free_scsi_task(iTask.task);
iTask.task = NULL;
}
if (iTask.do_retry) {
iTask.complete = 0;
goto retry;
}
if (iTask.status != SCSI_STATUS_GOOD) {
return iTask.err_code;
}
if (flags & BDRV_REQ_MAY_UNMAP) {
iscsi_allocationmap_clear(iscsilun, offset >> BDRV_SECTOR_BITS,
count >> BDRV_SECTOR_BITS);
} else {
iscsi_allocationmap_set(iscsilun, offset >> BDRV_SECTOR_BITS,
count >> BDRV_SECTOR_BITS);
}
return 0;
}
| 1threat |
static void init_vlcs(void)
{
static int done = 0;
if (!done) {
done = 1;
init_vlc(&dc_lum_vlc, DC_VLC_BITS, 12,
vlc_dc_lum_bits, 1, 1,
vlc_dc_lum_code, 2, 2);
init_vlc(&dc_chroma_vlc, DC_VLC_BITS, 12,
vlc_dc_chroma_bits, 1, 1,
vlc_dc_chroma_code, 2, 2);
init_vlc(&mv_vlc, MV_VLC_BITS, 17,
&mbMotionVectorTable[0][1], 2, 1,
&mbMotionVectorTable[0][0], 2, 1);
init_vlc(&mbincr_vlc, MBINCR_VLC_BITS, 36,
&mbAddrIncrTable[0][1], 2, 1,
&mbAddrIncrTable[0][0], 2, 1);
init_vlc(&mb_pat_vlc, MB_PAT_VLC_BITS, 64,
&mbPatTable[0][1], 2, 1,
&mbPatTable[0][0], 2, 1);
init_vlc(&mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7,
&table_mb_ptype[0][1], 2, 1,
&table_mb_ptype[0][0], 2, 1);
init_vlc(&mb_btype_vlc, MB_BTYPE_VLC_BITS, 11,
&table_mb_btype[0][1], 2, 1,
&table_mb_btype[0][0], 2, 1);
init_rl(&rl_mpeg1);
init_rl(&rl_mpeg2);
init_2d_vlc_rl(&rl_mpeg1);
init_2d_vlc_rl(&rl_mpeg2);
}
}
| 1threat |
How do I use jQuery and jQuery-ui with Parcel (bundler)? : <p>I installed jquery(3.2.1) and jquery-ui-dist(1.12.1) via npm. (they're not included as script tags in html)</p>
<p>In client script I use:</p>
<pre><code>window.$ = require('jquery');// plain jQuery stuff works fine
import 'jquery-ui-dist'; // breaks whole jQuery, with Error (missing module 8)
</code></pre>
| 0debug |
React | How to detect Page Refresh (F5) : <p>I'm using <a href="https://reactjs.org/docs/hello-world.html" rel="noreferrer">React js</a>. I need to detect <code>page refresh</code>. When user hits refresh icon or press F5, I need to find out the event.</p>
<p>I tried with <a href="https://stackoverflow.com/questions/47368578/react-js-detect-page-refresh">stackoverflow post</a> by using javascript functions</p>
<p>I used javascript function <code>beforeunload</code> still no luck.</p>
<pre><code>onUnload(event) {
alert('page Refreshed')
}
componentDidMount() {
window.addEventListener("beforeunload", this.onUnload)
}
componentWillUnmount() {
window.removeEventListener("beforeunload", this.onUnload)
}
</code></pre>
<p>here I have full code on <a href="https://stackblitz.com/edit/react-vtu3x3" rel="noreferrer">stackblitz</a></p>
| 0debug |
How to make a running text file in qt creator? Code below is not working : I want a running text file meaning when I close the program the file will still be there and if I add to the text file then the text from before the addition will still be there.
This is how I would do what I want to do in c++:
ofstream fout("filename.txt", ios::app)
Here is how I am trying to do this in QT creator:
void addToDatabase::on_pushButton_clicked() {
QString make = ui->lineEdit->text();
QString model = ui->lineEdit_2->text();
QString price = ui->lineEdit_3->text();
QString miles = ui->lineEdit_4->text();
QFile myDatabase(myDatabasePath);
if (myDatabase.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) {
QTextStream out(&myDatabase);
out << make << " " << model << " " << price << " " << miles << endl;
myDatabase.flush();
myDatabase.close();
}
this->close();
}
In summary, I want the database file to not get overwritten when I add a new QString to it. I've noticed that when I try to read my QFile it doesn't work either. I think this is because the declaration of myDatabase on line 7 is overwriting the old database.txt file at that path.
Any help would be very much appreciated. Thank you!
| 0debug |
How to make a letter move foward by one space with Javascript? : <p>For example, I got this :<br>
<code>_T___</code><br>
And I want to move the T foward by one space and destroy the next letter like this:<br>
<code>__T__</code><br>
Is it possible? If it's possible then how can I do this using Javascript? Thanks a lot!</p>
| 0debug |
Homebrew will not run wget command (Library not loaded) : <p>I received the following message when I try to use wget command after installation on Homebrew (running Mac High Sierra 10.13).</p>
<pre><code>dyld: Library not loaded: /usr/local/opt/gettext/lib/libintl.8.dylib
Referenced from: /usr/local/bin/wget
Reason: image not found
Abort trap: 6
</code></pre>
<p>I tried to reinstall wget. Issue still persists.</p>
| 0debug |
iOS 11 iPhone X simulator UITabBar icons and titles being rendered on top covering eachother : <p>Anyone having issue with the iPhone X simulator around the UITabBar component?</p>
<p>Mine seem to be rendering the icons and title on top of each other, I'm not sure if I'm missing anything, I also ran it in the iPhone 8 simulator, and one actual devices where it looks fine just as shown on the story board.</p>
<p><strong>iPhone X:</strong></p>
<p><a href="https://i.stack.imgur.com/gerXV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gerXV.png" alt="iPhone X UITabBar bug"></a></p>
<p><strong>iPhone 8</strong></p>
<p><a href="https://i.stack.imgur.com/LMNeu.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LMNeu.png" alt="iPhone 8 UITabBar works"></a></p>
| 0debug |
why can not modify the Integer instance in HashSet in java? : example:
ArrayList<Integer> a = new ArrayList<Integer>();
a.add(1);
a.add(2);
System.out.println(a.get(0));
a.get(0) = 10;
it comes with an error --- variable expected. But if I do not use classes declared by myself, I can easily modify the elements. why? | 0debug |
DescRing *desc_ring_alloc(Rocker *r, int index)
{
DescRing *ring;
ring = g_malloc0(sizeof(DescRing));
if (!ring) {
return NULL;
}
ring->r = r;
ring->index = index;
return ring;
}
| 1threat |
Questions and solutions for angular js controller errors :
function remove() {
var result = confirm("delete?");
if (result) {
blockUI.start();
userService.delete(vm.user).then(function (resp) {
if (resp.result == "00") {
toastr.success(resp.message, "result");
vm.linkList();
//removeGrid();
vm.search();
} else {
throw resp.message;
}
}, function (errResp) {
throw errResp;
}).catch(function (errResp) {
errResp = errResp || "HTTP error";
toastr.error(errResp, "error", { closeButton: true });
}).finally(function () {
blockUI.stop();
});
}
}
The information will not be deleted
error:"Bad Request"
exception:"org.springframework.web.bind.MissingServletRequestParameterException"
message:"Required String parameter 'id' is not present"
path:"/api/user/delete"
status:400
timestamp:1489648924119
Let me know the solution to this error. | 0debug |
Unsigned const var? unsigned const what? : <p>I'm digging through some code, and a function that I found takes (as one of the arguments)</p>
<pre><code>unsigned const cookie
</code></pre>
<p>What does that mean? Does the compiler default that to an unsigned integer, or is unsigned itself a datatype (That doesn't make sense to me)?</p>
| 0debug |
C++ Passing overloaded constructor to function between classes : I have to put overloaded constructor form class "Parameters" into function in class "Solver".
Here is Paramerers Header:
#ifndef Parameters
#define Parameters
#include <iostream>
#include<conio.h>
#include<fstream>
#include<string>
using namespace std;
class Parameters
{
int M;
double dx;
double eps;
public:
Parameters( );
Parameters(int M1, double dx1, double eps1 );
Parameters( string fileName);
};
#endif
Constructor initializes M, dx, eps with default values or chosen by user from keyboard or from file.
I want to have another class which will be containing this initialized values (in order to solve some equation lately, also in this class).
The problem is that although I tried to do this by value, reference or/an pointers, there was always some error or code compiled but done nothing.
Here's my Solver class:
#include "ParametersH.h"
#include "EquationH.h"
#include <iostream>
#include<conio.h>
#include<fstream>
#include<string>
#include<vector>
using namespace std;
class Solver
{
private:
public:
int Solve( Parameters& obj );
};
int Solver::Solve( Parameters& obj )
{
cout << obj.M; *// M is private so it fails :<*
*// another attempt was like this:*
*Parameters *pointer = new Parameters();*
}
int main()
{
Solver Solve();
return( 0 );
}
I really couldn't handle this, hope someone will help.
| 0debug |
Perl - how to count words in specific columns for multiple files : I'm new to Perl and must change an existing Perl script. I need to be able to count all the '500' in columns 1-3 in an entire file before moving on to the next command for that file, and then the next file. I can have multiple input files. I'm guessing the start would be something like this:
@files = <*INPUTFILENAMES>;
foreach $file (@files) {
open (DATA,$file);
then do the counts here}
| 0debug |
Upload file name in database with rename in PHP : <p>I am trying to insert file name in database in php. And file will move to CV folder. I used a function to reneme that file.It does not work .</p>
<pre><code><form method="POST" enctype="multipart/form-data">
<input type="file" name="file" required>
<input type="submit" name="job_post" value="Submit">
</form>
</code></pre>
<p><strong>PHP</strong></p>
<pre><code>if($_SERVER["REQUEST_METHOD"] == "POST"){
function getFileName($file)
{
return date('mdhms'). '.' . $file->extension();
}
$f_name= $_POST['file'];
$filename = getFileName($f_name);
move(base_path('cv'), $filename);
$job_post_sql="INSERT INTO applications (cv,flag) VALUES ('$filename','1')";
$job_post_sql_result=mysqli_query($con,$job_post_sql);
}
</code></pre>
| 0debug |
static int lag_read_prob_header(lag_rac *rac, GetBitContext *gb)
{
int i, j, scale_factor;
unsigned prob, cumulative_target;
unsigned cumul_prob = 0;
unsigned scaled_cumul_prob = 0;
rac->prob[0] = 0;
rac->prob[257] = UINT_MAX;
for (i = 1; i < 257; i++) {
if (lag_decode_prob(gb, &rac->prob[i]) < 0) {
av_log(rac->avctx, AV_LOG_ERROR, "Invalid probability encountered.\n");
return -1;
}
if ((uint64_t)cumul_prob + rac->prob[i] > UINT_MAX) {
av_log(rac->avctx, AV_LOG_ERROR, "Integer overflow encountered in cumulative probability calculation.\n");
return -1;
}
cumul_prob += rac->prob[i];
if (!rac->prob[i]) {
if (lag_decode_prob(gb, &prob)) {
av_log(rac->avctx, AV_LOG_ERROR, "Invalid probability run encountered.\n");
return -1;
}
if (prob > 256 - i)
prob = 256 - i;
for (j = 0; j < prob; j++)
rac->prob[++i] = 0;
}
}
if (!cumul_prob) {
av_log(rac->avctx, AV_LOG_ERROR, "All probabilities are 0!\n");
return -1;
}
scale_factor = av_log2(cumul_prob);
if (cumul_prob & (cumul_prob - 1)) {
uint64_t mul = softfloat_reciprocal(cumul_prob);
for (i = 1; i <= 128; i++) {
rac->prob[i] = softfloat_mul(rac->prob[i], mul);
scaled_cumul_prob += rac->prob[i];
}
if (scaled_cumul_prob <= 0) {
av_log(rac->avctx, AV_LOG_ERROR, "Scaled probabilities invalid\n");
return AVERROR_INVALIDDATA;
}
for (; i < 257; i++) {
rac->prob[i] = softfloat_mul(rac->prob[i], mul);
scaled_cumul_prob += rac->prob[i];
}
scale_factor++;
cumulative_target = 1 << scale_factor;
if (scaled_cumul_prob > cumulative_target) {
av_log(rac->avctx, AV_LOG_ERROR,
"Scaled probabilities are larger than target!\n");
return -1;
}
scaled_cumul_prob = cumulative_target - scaled_cumul_prob;
for (i = 1; scaled_cumul_prob; i = (i & 0x7f) + 1) {
if (rac->prob[i]) {
rac->prob[i]++;
scaled_cumul_prob--;
}
}
}
rac->scale = scale_factor;
for (i = 1; i < 257; i++)
rac->prob[i] += rac->prob[i - 1];
return 0;
}
| 1threat |
what is an elegant way to trigger selection of the first item in this scenario? : <p>I have a master-detail setup like this:</p>
<p><a href="https://stackblitz.com/angular/jxgxoekjyeb?file=src%2Fapp%2Fhero-detail%2Fhero-detail.component.html" rel="nofollow noreferrer">https://stackblitz.com/angular/jxgxoekjyeb?file=src%2Fapp%2Fhero-detail%2Fhero-detail.component.html</a></p>
<p>I want the default browser display to show the detail view of the first master item. In the example provided at the url above, a detail item isn't displayed until a user manually selects an item from the master list. What would be an elegant way to dynamically trigger selection of the first item in this scenario so that the detail view is displayed on page load?</p>
| 0debug |
max() just checks first value in a list/tuple for multiple lists/tuples? : <p><code>max((12,1),(1,),(2,1,2)</code> : So is it a wrong format to check which tuple is the greatest respective to the number of values in the tuple?</p>
<p>Because only the first value of each tuple is considered in this case.</p>
| 0debug |
Why C# List<T> Add method is very slow : I have asp.net mvc project with dapper read data from database and I need export to excel.
Dapper is fast ! `ExecuteReader` only 35 seconds.
But `list.Add(InStock);` spend too much time !!! Over 1020 seconds !!
Is there any idea ?? Thank you !!
public List<InStock> GetList(string stSeId, string edSeId, string stSeDay, string edSeDay, string qDate)
{
List<InStock> list = new List<InStock>();
InStock InStock = null;
IDataReader reader;
using (var conn = _connection.GetConnection())
{
try
{
conn.Open();
//******************Only 35 seconds*****
reader = conn.ExecuteReader(fileHelper.GetScriptFromFile("GetInStock"),
new { STSeId = stSeId, EDSeId = edSeId, STSeDay = stSeDay, EDSeDay = edSeDay, qDate = qDate });
//*************************************
//******************Over 1020 seconds**********
while (reader.Read())
{
InStock = new InStock();
InStock.ColA = reader.GetString(reader.GetOrdinal("ColA"));
InStock.ColB = reader.GetString(reader.GetOrdinal("ColB"));
InStock.ColC = reader.GetString(reader.GetOrdinal("ColC"));
list.Add(InStock);
}
//*********************************************
return list;
}
catch (Exception err)
{
throw err;
}
}
}
[1]: https://i.stack.imgur.com/gJJ1k.png | 0debug |
Trouble with my angular project and my Apache Server : <hr>
<p>Look, i recently finished my project and went happy to send it to my Apache server. </p>
<p>My Apache server has the standard folder structure <strong>www</strong> as the source and inside of it you put you files. </p>
<p>I ran the command in my project: <code>ng build --prod</code>, and gave me the following files:
<a href="https://i.stack.imgur.com/kFH6H.png" rel="nofollow noreferrer">my folder structure</a> </p>
<p>So i copied the content of the dist file and paste it in the path: <code>./www/test/FitProject</code> in my Apache folder and ran my server.<br>
But the console hitted me with an error saying:</p>
<ol>
<li>localhost:8080/Polyfills.js error 404, this file wasn't found</li>
<li>localhost:8080/Runtime.js error 404, this file wasn't found</li>
<li>localhost:8080/styles.css error 404, this file wasn't found</li>
</ol>
<p>So i tought, maybe it is searching for these files in the source folder(www) so i copied these files and paste it in the www folder and work out just fine. </p>
<blockquote>
<p>So what can i do to stop this error and tells to the angular project to look for these files inside it's own folder, not in www ?</p>
</blockquote>
| 0debug |
void nonono(const char* file, int line, const char* msg) {
fprintf(stderr, "Nonono! %s:%d %s\n", file, line, msg);
exit(-5);
}
| 1threat |
Divide oranges into different sized boxes. Java Puzzle : <p>Theres three boxes</p>
<p>User inputs the number of oranges.</p>
<p>Large box holds 20, medium 10 and the small 5 oranges. </p>
<p>The shipping cost of a large box is $8.80, medium box, $6.00 and small box $4.50. </p>
<p>The order is shipped in the least expensive manner. </p>
<p>For example, the order of 52 oranges will be shipped in four boxes: two large, one medium, and one small. </p>
<p>This is where it gets tricky.</p>
<p>The rule for packing is to fill the large and medium boxes completely; that is, the box is fully packed. </p>
<p>Only the small boxes can have empty spaces. For example, to ship 52 oranges, you could have used 3 large boxes, but that would leave the third box not fully packed.</p>
<p>Shipping cost should be displayed and method should be used in java </p>
<p>Anyone care to help an old guy learning java out?</p>
| 0debug |
static void csrhci_in_packet_vendor(struct csrhci_s *s, int ocf,
uint8_t *data, int len)
{
int offset;
uint8_t *rpkt;
switch (ocf) {
case OCF_CSR_SEND_FIRMWARE:
if (len >= 18 + 8 && data[12] == 0x01 && data[13] == 0x00) {
offset = 18;
s->bd_addr.b[0] = data[offset + 7];
s->bd_addr.b[1] = data[offset + 6];
s->bd_addr.b[2] = data[offset + 4];
s->bd_addr.b[3] = data[offset + 0];
s->bd_addr.b[4] = data[offset + 3];
s->bd_addr.b[5] = data[offset + 2];
s->hci->bdaddr_set(s->hci, s->bd_addr.b);
fprintf(stderr, "%s: bd_address loaded from firmware: "
"%02x:%02x:%02x:%02x:%02x:%02x\n", __FUNCTION__,
s->bd_addr.b[0], s->bd_addr.b[1], s->bd_addr.b[2],
s->bd_addr.b[3], s->bd_addr.b[4], s->bd_addr.b[5]);
}
rpkt = csrhci_out_packet_event(s, EVT_VENDOR, 11);
rpkt[9] = 0x00;
rpkt[10] = 0x00;
break;
default:
fprintf(stderr, "%s: got a bad CMD packet\n", __FUNCTION__);
return;
}
csrhci_fifo_wake(s);
}
| 1threat |
How to run html file using node js : <p>I have a simple html page with angular js as follows:</p>
<pre><code> //Application name
var app = angular.module("myTmoApppdl", []);
app.controller("myCtrl", function ($scope) {
//Sample login function
$scope.signin = function () {
var formData =
{
email: $scope.email,
password: $scope.password
};
console.log("Form data is:" + JSON.stringify(formData));
};
});
</code></pre>
<p>HTML file:</p>
<pre><code><html>
<head>
<link href="bootstrap.min.css" rel="stylesheet" type="text/css"/>
</head>
<body ng-app="myTmoApppdl" ng-controller="myCtrl">
<div class="container">
<div class="form-group">
<form class="form" role="form" method="post" ng-submit="signin()">
<div class="form-group col-md-6">
<label class="">Email address</label>
<input type="email" class="form-control" ng-model="email" id="exampleInputEmail2" placeholder="Email address" required>
</div>
<div class="form-group col-md-6">
<label class="">Password</label>
<input type="password" class="form-control" id="exampleInputPassword2" ng-model="password" placeholder="Password" required>
</div>
</form>
<button type="submit" class="btn btn-primary btn-block">Sign in</button>
</div>
</div>
</body>
<script src="angular.min.js" type="text/javascript"></script>
<!--User defined JS files-->
<script src="app.js" type="text/javascript"></script>
<script src="jsonParsingService.js" type="text/javascript"></script>
</html>
</code></pre>
<p>I am new to node js. I have installed node js server in my system but I am not sure how to run a simple html file using node js?</p>
| 0debug |
static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
{
BDRVRawState *s = bs->opaque;
char *buf;
if (bs->sg || !s->needs_alignment) {
bs->request_alignment = 1;
s->buf_align = 1;
return;
}
bs->request_alignment = 0;
s->buf_align = 0;
if (probe_logical_blocksize(fd, &bs->request_alignment) < 0) {
bs->request_alignment = 0;
}
#ifdef CONFIG_XFS
if (s->is_xfs) {
struct dioattr da;
if (xfsctl(NULL, fd, XFS_IOC_DIOINFO, &da) >= 0) {
bs->request_alignment = da.d_miniosz;
}
}
#endif
if (!s->buf_align) {
size_t align;
buf = qemu_memalign(MAX_BLOCKSIZE, 2 * MAX_BLOCKSIZE);
for (align = 512; align <= MAX_BLOCKSIZE; align <<= 1) {
if (pread(fd, buf + align, MAX_BLOCKSIZE, 0) >= 0) {
s->buf_align = align;
break;
}
}
qemu_vfree(buf);
}
if (!bs->request_alignment) {
size_t align;
buf = qemu_memalign(s->buf_align, MAX_BLOCKSIZE);
for (align = 512; align <= MAX_BLOCKSIZE; align <<= 1) {
if (pread(fd, buf, align, 0) >= 0) {
bs->request_alignment = align;
break;
}
}
qemu_vfree(buf);
}
if (!s->buf_align || !bs->request_alignment) {
error_setg(errp, "Could not find working O_DIRECT alignment. "
"Try cache.direct=off.");
}
}
| 1threat |
static void align_position(AVIOContext *pb, int64_t offset, uint64_t size)
{
if (avio_tell(pb) != offset + size)
avio_seek(pb, offset + size, SEEK_SET);
}
| 1threat |
static uint16List **host_memory_append_node(uint16List **node,
unsigned long value)
{
*node = g_malloc0(sizeof(**node));
(*node)->value = value;
return &(*node)->next;
}
| 1threat |
void rgb15tobgr16(const uint8_t *src, uint8_t *dst, long src_size)
{
long i;
long num_pixels = src_size >> 1;
for(i=0; i<num_pixels; i++)
{
unsigned b,g,r;
register uint16_t rgb;
rgb = src[2*i];
r = rgb&0x1F;
g = (rgb&0x3E0)>>5;
b = (rgb&0x7C00)>>10;
dst[2*i] = (b&0x1F) | ((g&0x3F)<<5) | ((r&0x1F)<<11);
}
}
| 1threat |
static void encode_picture(MpegEncContext *s, int picture_number)
{
int mb_x, mb_y, pdif = 0;
int i;
int bits;
MpegEncContext best_s, backup_s;
uint8_t bit_buf[2][3000];
uint8_t bit_buf2[2][3000];
uint8_t bit_buf_tex[2][3000];
PutBitContext pb[2], pb2[2], tex_pb[2];
for(i=0; i<2; i++){
init_put_bits(&pb [i], bit_buf [i], 3000, NULL, NULL);
init_put_bits(&pb2 [i], bit_buf2 [i], 3000, NULL, NULL);
init_put_bits(&tex_pb[i], bit_buf_tex[i], 3000, NULL, NULL);
}
s->picture_number = picture_number;
s->block_wrap[0]=
s->block_wrap[1]=
s->block_wrap[2]=
s->block_wrap[3]= s->mb_width*2 + 2;
s->block_wrap[4]=
s->block_wrap[5]= s->mb_width + 2;
s->current_picture.mb_var_sum = 0;
s->current_picture.mc_mb_var_sum = 0;
#ifdef CONFIG_RISKY
if (s->codec_id == CODEC_ID_MPEG1VIDEO || (s->h263_pred && !s->h263_msmpeg4))
ff_set_mpeg4_time(s, s->picture_number);
#endif
s->scene_change_score=0;
s->qscale= (int)(s->frame_qscale + 0.5);
if(s->msmpeg4_version){
if(s->pict_type==I_TYPE)
s->no_rounding=1;
else if(s->flipflop_rounding)
s->no_rounding ^= 1;
}else if(s->out_format == FMT_H263){
if(s->pict_type==I_TYPE)
s->no_rounding=0;
else if(s->pict_type!=B_TYPE)
s->no_rounding ^= 1;
}
s->mb_intra=0;
if(s->pict_type != I_TYPE){
if(s->pict_type != B_TYPE){
if((s->avctx->pre_me && s->last_non_b_pict_type==I_TYPE) || s->avctx->pre_me==2){
s->me.pre_pass=1;
s->me.dia_size= s->avctx->pre_dia_size;
for(mb_y=s->mb_height-1; mb_y >=0 ; mb_y--) {
for(mb_x=s->mb_width-1; mb_x >=0 ; mb_x--) {
s->mb_x = mb_x;
s->mb_y = mb_y;
ff_pre_estimate_p_frame_motion(s, mb_x, mb_y);
}
}
s->me.pre_pass=0;
}
}
s->me.dia_size= s->avctx->dia_size;
for(mb_y=0; mb_y < s->mb_height; mb_y++) {
s->block_index[0]= s->block_wrap[0]*(mb_y*2 + 1) - 1;
s->block_index[1]= s->block_wrap[0]*(mb_y*2 + 1);
s->block_index[2]= s->block_wrap[0]*(mb_y*2 + 2) - 1;
s->block_index[3]= s->block_wrap[0]*(mb_y*2 + 2);
for(mb_x=0; mb_x < s->mb_width; mb_x++) {
s->mb_x = mb_x;
s->mb_y = mb_y;
s->block_index[0]+=2;
s->block_index[1]+=2;
s->block_index[2]+=2;
s->block_index[3]+=2;
if(s->pict_type==B_TYPE)
ff_estimate_b_frame_motion(s, mb_x, mb_y);
else
ff_estimate_p_frame_motion(s, mb_x, mb_y);
}
}
}else {
memset(s->motion_val[0], 0, sizeof(int16_t)*(s->mb_width*2 + 2)*(s->mb_height*2 + 2)*2);
memset(s->p_mv_table , 0, sizeof(int16_t)*(s->mb_width+2)*(s->mb_height+2)*2);
memset(s->mb_type , MB_TYPE_INTRA, sizeof(uint8_t)*s->mb_width*s->mb_height);
if(!s->fixed_qscale){
for(mb_y=0; mb_y < s->mb_height; mb_y++) {
for(mb_x=0; mb_x < s->mb_width; mb_x++) {
int xx = mb_x * 16;
int yy = mb_y * 16;
uint8_t *pix = s->new_picture.data[0] + (yy * s->linesize) + xx;
int varc;
int sum = s->dsp.pix_sum(pix, s->linesize);
varc = (s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)(sum*sum))>>8) + 500 + 128)>>8;
s->current_picture.mb_var [s->mb_width * mb_y + mb_x] = varc;
s->current_picture.mb_mean[s->mb_width * mb_y + mb_x] = (sum+128)>>8;
s->current_picture.mb_var_sum += varc;
}
}
}
}
emms_c();
if(s->scene_change_score > 0 && s->pict_type == P_TYPE){
s->pict_type= I_TYPE;
memset(s->mb_type , MB_TYPE_INTRA, sizeof(uint8_t)*s->mb_width*s->mb_height);
}
if(s->pict_type==P_TYPE || s->pict_type==S_TYPE) {
s->f_code= ff_get_best_fcode(s, s->p_mv_table, MB_TYPE_INTER);
ff_fix_long_p_mvs(s);
}
if(s->pict_type==B_TYPE){
int a, b;
a = ff_get_best_fcode(s, s->b_forw_mv_table, MB_TYPE_FORWARD);
b = ff_get_best_fcode(s, s->b_bidir_forw_mv_table, MB_TYPE_BIDIR);
s->f_code = FFMAX(a, b);
a = ff_get_best_fcode(s, s->b_back_mv_table, MB_TYPE_BACKWARD);
b = ff_get_best_fcode(s, s->b_bidir_back_mv_table, MB_TYPE_BIDIR);
s->b_code = FFMAX(a, b);
ff_fix_long_b_mvs(s, s->b_forw_mv_table, s->f_code, MB_TYPE_FORWARD);
ff_fix_long_b_mvs(s, s->b_back_mv_table, s->b_code, MB_TYPE_BACKWARD);
ff_fix_long_b_mvs(s, s->b_bidir_forw_mv_table, s->f_code, MB_TYPE_BIDIR);
ff_fix_long_b_mvs(s, s->b_bidir_back_mv_table, s->b_code, MB_TYPE_BIDIR);
}
if (s->fixed_qscale)
s->frame_qscale = s->current_picture.quality;
else
s->frame_qscale = ff_rate_estimate_qscale(s);
if(s->adaptive_quant){
#ifdef CONFIG_RISKY
switch(s->codec_id){
case CODEC_ID_MPEG4:
ff_clean_mpeg4_qscales(s);
break;
case CODEC_ID_H263:
case CODEC_ID_H263P:
ff_clean_h263_qscales(s);
break;
}
#endif
s->qscale= s->current_picture.qscale_table[0];
}else
s->qscale= (int)(s->frame_qscale + 0.5);
if (s->out_format == FMT_MJPEG) {
s->intra_matrix[0] = ff_mpeg1_default_intra_matrix[0];
for(i=1;i<64;i++){
int j= s->idct_permutation[i];
s->intra_matrix[j] = CLAMP_TO_8BIT((ff_mpeg1_default_intra_matrix[i] * s->qscale) >> 3);
}
convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16,
s->q_intra_matrix16_bias, s->intra_matrix, s->intra_quant_bias, 8, 8);
}
s->current_picture.key_frame= s->pict_type == I_TYPE;
s->current_picture.pict_type= s->pict_type;
if(s->current_picture.key_frame)
s->picture_in_gop_number=0;
s->last_bits= get_bit_count(&s->pb);
switch(s->out_format) {
case FMT_MJPEG:
mjpeg_picture_header(s);
break;
#ifdef CONFIG_RISKY
case FMT_H263:
if (s->codec_id == CODEC_ID_WMV2)
ff_wmv2_encode_picture_header(s, picture_number);
else if (s->h263_msmpeg4)
msmpeg4_encode_picture_header(s, picture_number);
else if (s->h263_pred)
mpeg4_encode_picture_header(s, picture_number);
else if (s->h263_rv10)
rv10_encode_picture_header(s, picture_number);
else
h263_encode_picture_header(s, picture_number);
break;
#endif
case FMT_MPEG1:
mpeg1_encode_picture_header(s, picture_number);
break;
}
bits= get_bit_count(&s->pb);
s->header_bits= bits - s->last_bits;
s->last_bits= bits;
s->mv_bits=0;
s->misc_bits=0;
s->i_tex_bits=0;
s->p_tex_bits=0;
s->i_count=0;
s->f_count=0;
s->b_count=0;
s->skip_count=0;
for(i=0; i<3; i++){
s->last_dc[i] = 128;
s->current_picture.error[i] = 0;
}
s->mb_incr = 1;
s->last_mv[0][0][0] = 0;
s->last_mv[0][0][1] = 0;
s->last_mv[1][0][0] = 0;
s->last_mv[1][0][1] = 0;
s->last_mv_dir = 0;
#ifdef CONFIG_RISKY
if (s->codec_id==CODEC_ID_H263 || s->codec_id==CODEC_ID_H263P)
s->gob_index = ff_h263_get_gob_height(s);
if(s->codec_id==CODEC_ID_MPEG4 && s->partitioned_frame)
ff_mpeg4_init_partitions(s);
#endif
s->resync_mb_x=0;
s->resync_mb_y=0;
s->first_slice_line = 1;
s->ptr_lastgob = s->pb.buf;
s->ptr_last_mb_line = s->pb.buf;
for(mb_y=0; mb_y < s->mb_height; mb_y++) {
s->y_dc_scale= s->y_dc_scale_table[ s->qscale ];
s->c_dc_scale= s->c_dc_scale_table[ s->qscale ];
s->block_index[0]= s->block_wrap[0]*(mb_y*2 + 1) - 1;
s->block_index[1]= s->block_wrap[0]*(mb_y*2 + 1);
s->block_index[2]= s->block_wrap[0]*(mb_y*2 + 2) - 1;
s->block_index[3]= s->block_wrap[0]*(mb_y*2 + 2);
s->block_index[4]= s->block_wrap[4]*(mb_y + 1) + s->block_wrap[0]*(s->mb_height*2 + 2);
s->block_index[5]= s->block_wrap[4]*(mb_y + 1 + s->mb_height + 2) + s->block_wrap[0]*(s->mb_height*2 + 2);
for(mb_x=0; mb_x < s->mb_width; mb_x++) {
int mb_type= s->mb_type[mb_y * s->mb_width + mb_x];
const int xy= (mb_y+1) * (s->mb_width+2) + mb_x + 1;
int dmin=10000000;
s->mb_x = mb_x;
s->mb_y = mb_y;
s->block_index[0]+=2;
s->block_index[1]+=2;
s->block_index[2]+=2;
s->block_index[3]+=2;
s->block_index[4]++;
s->block_index[5]++;
#ifdef CONFIG_RISKY
if(s->rtp_mode){
int current_packet_size, is_gob_start;
current_packet_size= pbBufPtr(&s->pb) - s->ptr_lastgob;
is_gob_start=0;
if(s->codec_id==CODEC_ID_MPEG4){
if(current_packet_size + s->mb_line_avgsize/s->mb_width >= s->rtp_payload_size
&& s->mb_y + s->mb_x>0){
if(s->partitioned_frame){
ff_mpeg4_merge_partitions(s);
ff_mpeg4_init_partitions(s);
}
ff_mpeg4_encode_video_packet_header(s);
if(s->flags&CODEC_FLAG_PASS1){
int bits= get_bit_count(&s->pb);
s->misc_bits+= bits - s->last_bits;
s->last_bits= bits;
}
ff_mpeg4_clean_buffers(s);
is_gob_start=1;
}
}else{
if(current_packet_size + s->mb_line_avgsize*s->gob_index >= s->rtp_payload_size
&& s->mb_x==0 && s->mb_y>0 && s->mb_y%s->gob_index==0){
h263_encode_gob_header(s, mb_y);
is_gob_start=1;
}
}
if(is_gob_start){
s->ptr_lastgob = pbBufPtr(&s->pb);
s->first_slice_line=1;
s->resync_mb_x=mb_x;
s->resync_mb_y=mb_y;
}
}
#endif
if( (s->resync_mb_x == s->mb_x)
&& s->resync_mb_y+1 == s->mb_y){
s->first_slice_line=0;
}
if(mb_type & (mb_type-1)){
int next_block=0;
int pb_bits_count, pb2_bits_count, tex_pb_bits_count;
copy_context_before_encode(&backup_s, s, -1);
backup_s.pb= s->pb;
best_s.data_partitioning= s->data_partitioning;
best_s.partitioned_frame= s->partitioned_frame;
if(s->data_partitioning){
backup_s.pb2= s->pb2;
backup_s.tex_pb= s->tex_pb;
}
if(mb_type&MB_TYPE_INTER){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->p_mv_table[xy][0];
s->mv[0][0][1] = s->p_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, MB_TYPE_INTER, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&MB_TYPE_INTER4V){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_8X8;
s->mb_intra= 0;
for(i=0; i<4; i++){
s->mv[0][i][0] = s->motion_val[s->block_index[i]][0];
s->mv[0][i][1] = s->motion_val[s->block_index[i]][1];
}
encode_mb_hq(s, &backup_s, &best_s, MB_TYPE_INTER4V, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&MB_TYPE_FORWARD){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_forw_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, MB_TYPE_FORWARD, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
}
if(mb_type&MB_TYPE_BACKWARD){
s->mv_dir = MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[1][0][0] = s->b_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_back_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, MB_TYPE_BACKWARD, pb, pb2, tex_pb,
&dmin, &next_block, s->mv[1][0][0], s->mv[1][0][1]);
}
if(mb_type&MB_TYPE_BIDIR){
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 0;
s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];
s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];
encode_mb_hq(s, &backup_s, &best_s, MB_TYPE_BIDIR, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
if(mb_type&MB_TYPE_DIRECT){
int mx= s->b_direct_mv_table[xy][0];
int my= s->b_direct_mv_table[xy][1];
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
s->mb_intra= 0;
#ifdef CONFIG_RISKY
ff_mpeg4_set_direct_mv(s, mx, my);
#endif
encode_mb_hq(s, &backup_s, &best_s, MB_TYPE_DIRECT, pb, pb2, tex_pb,
&dmin, &next_block, mx, my);
}
if(mb_type&MB_TYPE_INTRA){
s->mv_dir = 0;
s->mv_type = MV_TYPE_16X16;
s->mb_intra= 1;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
encode_mb_hq(s, &backup_s, &best_s, MB_TYPE_INTRA, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
if(s->h263_pred || s->h263_aic)
s->mbintra_table[mb_x + mb_y*s->mb_width]=1;
}
copy_context_after_encode(s, &best_s, -1);
pb_bits_count= get_bit_count(&s->pb);
flush_put_bits(&s->pb);
ff_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count);
s->pb= backup_s.pb;
if(s->data_partitioning){
pb2_bits_count= get_bit_count(&s->pb2);
flush_put_bits(&s->pb2);
ff_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count);
s->pb2= backup_s.pb2;
tex_pb_bits_count= get_bit_count(&s->tex_pb);
flush_put_bits(&s->tex_pb);
ff_copy_bits(&backup_s.tex_pb, bit_buf_tex[next_block^1], tex_pb_bits_count);
s->tex_pb= backup_s.tex_pb;
}
s->last_bits= get_bit_count(&s->pb);
} else {
int motion_x, motion_y;
int intra_score;
int inter_score= s->current_picture.mb_cmp_score[mb_x + mb_y*s->mb_width];
if(!(s->flags&CODEC_FLAG_HQ) && s->pict_type==P_TYPE){
if((s->avctx->mb_cmp&0xFF)==FF_CMP_SSE){
intra_score= (s->current_picture.mb_var[mb_x + mb_y*s->mb_width]<<8) - 500;
}else{
uint8_t *dest_y;
int mean= s->current_picture.mb_mean[mb_x + mb_y*s->mb_width];
mean*= 0x01010101;
dest_y = s->new_picture.data[0] + (mb_y * 16 * s->linesize ) + mb_x * 16;
for(i=0; i<16; i++){
*(uint32_t*)(&s->me.scratchpad[i*s->linesize+ 0]) = mean;
*(uint32_t*)(&s->me.scratchpad[i*s->linesize+ 4]) = mean;
*(uint32_t*)(&s->me.scratchpad[i*s->linesize+ 8]) = mean;
*(uint32_t*)(&s->me.scratchpad[i*s->linesize+12]) = mean;
}
s->mb_intra=1;
intra_score= s->dsp.mb_cmp[0](s, s->me.scratchpad, dest_y, s->linesize);
}
if(s->avctx->mb_cmp&FF_CMP_CHROMA){
int i;
s->mb_intra=1;
for(i=1; i<3; i++){
uint8_t *dest_c;
int mean;
if(s->out_format == FMT_H263){
mean= (s->dc_val[i][mb_x + (mb_y+1)*(s->mb_width+2)] + 4)>>3; not exact but simple ;)
}else{
mean= (s->last_dc[i] + 4)>>3;
}
dest_c = s->new_picture.data[i] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8;
mean*= 0x01010101;
for(i=0; i<8; i++){
*(uint32_t*)(&s->me.scratchpad[i*s->uvlinesize+ 0]) = mean;
*(uint32_t*)(&s->me.scratchpad[i*s->uvlinesize+ 4]) = mean;
}
intra_score+= s->dsp.mb_cmp[1](s, s->me.scratchpad, dest_c, s->uvlinesize);
}
}
switch(s->avctx->mb_cmp&0xFF){
default:
case FF_CMP_SAD:
intra_score+= 32*s->qscale;
break;
case FF_CMP_SSE:
intra_score+= 24*s->qscale*s->qscale;
break;
case FF_CMP_SATD:
intra_score+= 96*s->qscale;
break;
case FF_CMP_DCT:
intra_score+= 48*s->qscale;
break;
case FF_CMP_BIT:
intra_score+= 16;
break;
case FF_CMP_PSNR:
case FF_CMP_RD:
intra_score+= (s->qscale*s->qscale*109*8 + 64)>>7;
break;
}
if(intra_score < inter_score)
mb_type= MB_TYPE_INTRA;
}
s->mv_type=MV_TYPE_16X16;
switch(mb_type){
case MB_TYPE_INTRA:
s->mv_dir = 0;
s->mb_intra= 1;
motion_x= s->mv[0][0][0] = 0;
motion_y= s->mv[0][0][1] = 0;
break;
case MB_TYPE_INTER:
s->mv_dir = MV_DIR_FORWARD;
s->mb_intra= 0;
motion_x= s->mv[0][0][0] = s->p_mv_table[xy][0];
motion_y= s->mv[0][0][1] = s->p_mv_table[xy][1];
break;
case MB_TYPE_INTER4V:
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_8X8;
s->mb_intra= 0;
for(i=0; i<4; i++){
s->mv[0][i][0] = s->motion_val[s->block_index[i]][0];
s->mv[0][i][1] = s->motion_val[s->block_index[i]][1];
}
motion_x= motion_y= 0;
break;
case MB_TYPE_DIRECT:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
s->mb_intra= 0;
motion_x=s->b_direct_mv_table[xy][0];
motion_y=s->b_direct_mv_table[xy][1];
#ifdef CONFIG_RISKY
ff_mpeg4_set_direct_mv(s, motion_x, motion_y);
#endif
break;
case MB_TYPE_BIDIR:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mb_intra= 0;
motion_x=0;
motion_y=0;
s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];
s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];
s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];
break;
case MB_TYPE_BACKWARD:
s->mv_dir = MV_DIR_BACKWARD;
s->mb_intra= 0;
motion_x= s->mv[1][0][0] = s->b_back_mv_table[xy][0];
motion_y= s->mv[1][0][1] = s->b_back_mv_table[xy][1];
break;
case MB_TYPE_FORWARD:
s->mv_dir = MV_DIR_FORWARD;
s->mb_intra= 0;
motion_x= s->mv[0][0][0] = s->b_forw_mv_table[xy][0];
motion_y= s->mv[0][0][1] = s->b_forw_mv_table[xy][1];
break;
default:
motion_x=motion_y=0;
printf("illegal MB type\n");
}
encode_mb(s, motion_x, motion_y);
s->last_mv_dir = s->mv_dir;
}
if(s->mb_intra ){
s->p_mv_table[xy][0]=0;
s->p_mv_table[xy][1]=0;
}
MPV_decode_mb(s, s->block);
if(s->flags&CODEC_FLAG_PSNR){
int w= 16;
int h= 16;
if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16;
if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16;
s->current_picture.error[0] += sse(
s,
s->new_picture .data[0] + s->mb_x*16 + s->mb_y*s->linesize*16,
s->current_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16,
w, h, s->linesize);
s->current_picture.error[1] += sse(
s,
s->new_picture .data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,
s->current_picture.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,
w>>1, h>>1, s->uvlinesize);
s->current_picture.error[2] += sse(
s,
s->new_picture .data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,
s->current_picture.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,
w>>1, h>>1, s->uvlinesize);
}
}
if (s->rtp_mode) {
if (mb_y==0)
s->mb_line_avgsize = pbBufPtr(&s->pb) - s->ptr_last_mb_line;
else {
s->mb_line_avgsize = (s->mb_line_avgsize + pbBufPtr(&s->pb) - s->ptr_last_mb_line) >> 1;
}
s->ptr_last_mb_line = pbBufPtr(&s->pb);
}
}
emms_c();
#ifdef CONFIG_RISKY
if(s->codec_id==CODEC_ID_MPEG4 && s->partitioned_frame)
ff_mpeg4_merge_partitions(s);
if (s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == I_TYPE)
msmpeg4_encode_ext_header(s);
if(s->codec_id==CODEC_ID_MPEG4)
ff_mpeg4_stuffing(&s->pb);
#endif
if (s->rtp_mode) {
flush_put_bits(&s->pb);
pdif = pbBufPtr(&s->pb) - s->ptr_lastgob;
if (s->rtp_callback)
s->rtp_callback(s->ptr_lastgob, pdif, s->gob_number);
s->ptr_lastgob = pbBufPtr(&s->pb);
}
}
| 1threat |
Using the COM for opening Excel, can't select a particular sheet. : I am using the COM to work with Excel 2007. When I use the following code, it opens to the first sheet by default.
Excel = Sys.OleObject("Excel.Application");
Delay (3000); // Wait until Excel starts
Excel.Visible = true;
Excel.Workbooks.Open("G:\\Documentation\\CalCit Excel Files\\2004 Test Data v3 FINAL_new.xlsx");
I need to select different sheets. I tryed using the following code from the DDTdriver code.
Excel = Sys.OleObject("Excel.Application");
Delay (3000); // Wait until Excel starts
Excel.Visible = true;
Excel.Workbooks.Open("G:\\Documentation\\CalCit Excel Files\\2004 Test Data v3 FINAL_new.xlsx", "sheet2", true);
But this does not work. I have tryed many other configs and still get nothing.
| 0debug |
Room database migration if only new table is added : <p>Let't assume, I have a simple Room database:</p>
<pre><code>@Database(entities = {User.class}, version = 1)
abstract class AppDatabase extends RoomDatabase {
public abstract Dao getDao();
}
</code></pre>
<p>Now, I'm adding a new entity: <code>Pet</code> and bumping version to 2:</p>
<pre><code>@Database(entities = {User.class, Pet.class}, version = 2)
abstract class AppDatabase extends RoomDatabase {
public abstract Dao getDao();
}
</code></pre>
<p>Of course, Room throws an exception: <code>java.lang.IllegalStateException: A migration from 1 to 2 is necessary.</code></p>
<p>Assuming, I haven't changed <code>User</code> class (so all data is safe), I have to provide migration which just creates a new table. So, I'm looking into classes generated by Room, searching for generated query to create my new table, copying it and pasting into migration:</p>
<pre><code>final Migration MIGRATION_1_2 =
new Migration(1, 2) {
@Override
public void migrate(@NonNull final SupportSQLiteDatabase database) {
database.execSQL("CREATE TABLE IF NOT EXISTS `Pet` (`name` TEXT NOT NULL, PRIMARY KEY(`name`))");
}
};
</code></pre>
<p>However I find it inconvenient to do it manually.
Is there a way to tell Room: <em>I'm not touching any of the existing table, so data is safe. Please create migration for me?</em></p>
| 0debug |
What is the point of calling super in custom error classes in python? : <p>So I have a simple custom error class in Python that I created based on the Python 2.7 documentation:</p>
<pre><code>class InvalidTeamError(Exception):
def __init__(self, message='This user belongs to a different team'):
self.message = message
</code></pre>
<p>This gives me warning <code>W0231: __init__ method from base class %r is not called</code> in PyLint so I go look it up and am given the very helpful description of "explanation needed." I'd normally just ignore this error but I have noticed that a ton code online includes a call to super in the beginning of the <strong>init</strong> method of custom error classes so my question is: Does doing this actually serve a purpose or is it just people trying to appease a bogus pylint warning?</p>
| 0debug |
static int count_contiguous_clusters(uint64_t nb_clusters, int cluster_size,
uint64_t *l2_table, uint64_t mask)
{
int i;
uint64_t offset = be64_to_cpu(l2_table[0]) & ~mask;
if (!offset)
return 0;
for (i = 0; i < nb_clusters; i++)
if (offset + i * cluster_size != (be64_to_cpu(l2_table[i]) & ~mask))
break;
return i;
}
| 1threat |
Constructors for variable types : <p>This is a very basic question but for declaration of variables are constructors called?</p>
<pre><code>int x; //Global variable
class A{
public:
int y;
A()
}
</code></pre>
| 0debug |
Jest mocking reference error : <p>I'm trying to use the following mock:</p>
<pre><code>const mockLogger = jest.fn();
jest.mock("./myLoggerFactory", () => (type) => mockLogger);
</code></pre>
<p>but mockLogger throws a reference error.</p>
<p>I know jest is trying to protect me from reaching outside of the scope of the mock, but I need a reference to <code>jest.fn()</code> so I can assert that it was called correctly.</p>
<p>I'm only mocking this because I'm doing an outside-in acceptance test of a library. Otherwise I would thread the reference to the logger all the way through as a parameter rather than mocking.</p>
<p>How can I achieve this?</p>
| 0debug |
static void qemu_laio_process_completion(struct qemu_laio_state *s,
struct qemu_laiocb *laiocb)
{
int ret;
s->count--;
ret = laiocb->ret;
if (ret != -ECANCELED) {
if (ret == laiocb->nbytes)
ret = 0;
else if (ret >= 0)
ret = -EINVAL;
laiocb->common.cb(laiocb->common.opaque, ret);
}
qemu_aio_release(laiocb);
}
| 1threat |
How to prevent my process fro being killed on logout in windows : How can I allow my process to persist after logout and not be killed, preferably without requiring the process to have administrator privileges. I am unable to use a service/scheduled task duebto some peculiarities in the program. | 0debug |
React - adding class to children components : <p>im using react and I have a component that simply needs to render the children and add them a class according to a condition.
Whats the best way of doing it?</p>
| 0debug |
Hi again XD, now I'm trying to kill/re-spawn my enemy each time my player goes through the doors : import pygame
import os,sys
import random
import math
img_path = os.path.join("punch.png")
img_blob = os.path.join("blob.png")
img_bullet = os.path.join("bullet.png")
img_heart = os.path.join("heart.png")
score = 0
class Actor(pygame.sprite.Sprite):
def __init__(self, x, y):
super(Actor,self).__init__()
self.image = pygame.Surface([116,116])
self.image.set_colorkey(black)
self.rect = self.image.get_rect()
self.rect.x = x
self.rect.y = y
self.speed = 2
class Enemy(Actor):
def __init__(self, x, y):
super(Enemy, self).__init__(x, y)
self.target = None
self.image.blit(pygame.image.load(img_blob),(0,0))
def update(self, enemies):
if self.target:
dx,dy = self.target.rect.x - self.rect.x, self.target.rect.y - self.rect.y
dist = math.hypot(dx,dy)
dx,dy = dx / dist,dy / dist
self.rect.x += dx * self.speed
self.rect.y += dy * self.speed
class Character(Actor):
def __init__(self, x = 275, y = 250):
super(Character, self).__init__(x, y)
self.speed = 10
self.image.blit(pygame.image.load(img_path),(0,0))
self.score = 0
self.heart = 5
def update(self, enemies):
if pygame.sprite.spritecollide(self, enemies, False):
self.heart -= 1
pygame.sprite.spritecollide(self, enemies, True)
key = pygame.key.get_pressed()
if key[pygame.K_w]:
self.rect.y -= self.speed
elif key[pygame.K_s]:
self.rect.y += self.speed
if key[pygame.K_a]:
self.rect.x -= self.speed
elif key[pygame.K_d]:
self.rect.x += self.speed
if self.rect.x > 1110:
self.rect.x = 1110
if self.rect.y < 20:
self.rect.y = 20
elif self.rect.y > 710:
self.rect.y = 710
if self.rect.x <20:
self.rect.x = 20
elif self.rect.x == 1110 and self.rect.y > 300 and self.rect.y < 400:
self.rect.x = 25
if self.rect.y == 20 and self.rect.x >500 and self.rect.x < 600:
self.rect.y = 715
elif self.rect.x == 20 and self.rect.y > 300 and self.rect.y < 400:
self.rect.x = 1090
if self.rect.y == 710 and self.rect.x >500 and self.rect.x < 600:
self.rect.y = 25
class Bullet(pygame.sprite.Sprite):
def __init__(self,mouse,bird):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load(img_bullet)
self.mouse_x,self.mouse_y = mouse[0], mouse[1]
self.bird = bird
self.rect = self.image.get_rect()
def update(self,enemies):
if pygame.sprite.spritecollide(self, enemies, False):
bird.score += 10
pygame.sprite.spritecollide(self, enemies, True)
speed = -10.
range = 50
distance = [self.mouse_x - self.bird[0],self.mouse_y - self.bird[1]]
norm = math.sqrt(distance[0] ** 2 + distance[1] ** 2)
direction = [distance[0] / norm, distance[1] / norm]
bullet_vector = [direction[0] * speed,direction[1] * speed]
self.rect.x -=bullet_vector[0]
self.rect.y -= bullet_vector[1]
pygame.init() # Pygame is initialised (starts running)
players = pygame.sprite.Group()
screen = pygame.display.set_mode([1250,850]) # Set the width and height of the screen [width,height]
pygame.display.set_caption("My Game") # Name your window
background_image = pygame.image.load("untilted.png")
done = False # Loop until the user clicks the close button.
clock = pygame.time.Clock() # Used to manage how fast the screen updates
black = ( 0, 0, 0) # Define some colors using rgb values. These can be
white = ( 255, 255, 255) # used throughout the game instead of using rgb values.
font = pygame.font.Font(None,36)
# Define additional Functions and Procedures here
score = 0
bird = Character()
bullet = Bullet(pygame.mouse.get_pos(),[bird.rect.x,bird.rect.y])
blob = Enemy(random.randint(200,1000),random.randint(200,300))
blob.target=bird
all_sprites = pygame.sprite.Group([blob, bird])
enemies = pygame.sprite.Group([blob])
# -------- Main Program Loop -----------
while done == False:
for event in pygame.event.get(): # Check for an event (mouse click, key press)
key = pygame.key.get_pressed()
if event.type == pygame.QUIT: # If user clicked close window
done = True # Flag that we are done so we exit this loop
elif key[pygame.K_e]:
bullet = Bullet(pygame.mouse.get_pos(),[bird.rect.x,bird.rect.y])
bullet.rect.x = bird.rect.x
bullet.rect.y = bird.rect.y
all_sprites.add(bullet)
screen.blit(background_image, (0, 0))
all_sprites.update(enemies)
all_sprites.draw(screen)
textImg = font.render("Score: " + str(bird.score),1,white)
textImg2 = font.render("Lives: " + str(bird.heart),1,white)
screen.blit(textImg,(10,10))
screen.blit(textImg2,(150,10))
pygame.display.update() # Go ahead and update the screen with what we've drawn.
clock.tick(20) # Limit to 20 frames per second
if bird.heart == 0:
pygame.quit()
pygame.quit()
so in the Character class, in the update part, the bottom of it is where it is going through the doors, but when it goes through the doors, i an wanting to kill the enemy and then re-spawn it so it looks as if the player is going into a different room. | 0debug |
Remotely access a database : My client is using a hotel management software that uses Microsoft SQL server for database and now I need to extract their database for further doing work on it.So can I use connection string to remotely access my clients database? | 0debug |
Layout in SwiftUI with horizontal and vertical alignment : <p>I'm trying to accomplish this layout</p>
<p><a href="https://i.stack.imgur.com/fetjK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fetjK.png" alt="desired layout"></a></p>
<p>If I try HStack wrapped in VStack, I get this:</p>
<p><a href="https://i.stack.imgur.com/yXRmj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yXRmj.png" alt="HStack in VStack"></a></p>
<p>If I try VStack wrapped in HStack, I get this:</p>
<p><a href="https://i.stack.imgur.com/GaFAh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GaFAh.png" alt="VStack in HStack"></a></p>
<p>Is there a way to baseline align the text with the textfield and get standard spacing from the longest label to the start of the aligned textfields?</p>
| 0debug |
what does "for letter in greeting" do in the given code? : unanswered
greeting = 'Hello!'
count = 0
for letter in greeting:
count += 1
if count % 2 == 0:
print(letter)
print(letter)
print('done')
#please explain the output | 0debug |
static void test_visitor_in_struct(TestInputVisitorData *data,
const void *unused)
{
TestStruct *p = NULL;
Visitor *v;
v = visitor_input_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }");
visit_type_TestStruct(v, NULL, &p, &error_abort);
g_assert_cmpint(p->integer, ==, -42);
g_assert(p->boolean == true);
g_assert_cmpstr(p->string, ==, "foo");
g_free(p->string);
g_free(p);
}
| 1threat |
how to architect/organize a react application : <p>From a maintenance/architecture/performance perspective, when writing a react application, is it better to put all components in a super/parent component and bind it once to a page, or to have multiple mount nodes on the page for each piece of functionality?</p>
<p>My current approach is to have multiple mount nodes on the page so I can have a more flexible design. Basically like a bunch of 'component boxes' in different parts of the page, that way I can easily move an entire box to another part of the page and everything still works the same without being dependent on each other.</p>
<p>Is there a "best practice" for this (in terms of future maintenance), or has react not been around long enough to establish such a thing?</p>
| 0debug |
TypeError: must be str, not int, don't understand what i'm doing wrong : I need help with the following code, because i can't understand what i'm doing wrong.
It's a function for my the game Minesweeper which receives a position like "C3" and has to return an int to search a position in a list of available positions.
def evalua_jugada(posicion,posiciones_posibles):
"""Convierte a la posicion ingresada en un numero de la lista de posiciones posibles"""
indice_en_posiciones_posibles = (8 * list(ascii_uppercase).index(posicion[0].upper())) + (posicion[1] + 1)
return(posiciones_posibles[indice_en_posiciones_posibles])
this is my very first post so i don't know how to ident well jajaja.
Anyway hope you can help me.`` | 0debug |
static int ast_write_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIOContext *pb = s->pb;
ASTMuxContext *ast = s->priv_data;
AVCodecContext *enc = s->streams[0]->codec;
int size = pkt->size / enc->channels;
if (enc->frame_number == 1)
ast->fbs = size;
ffio_wfourcc(pb, "BLCK");
avio_wb32(pb, size);
avio_wb64(pb, 0);
avio_wb64(pb, 0);
avio_wb64(pb, 0);
avio_write(pb, pkt->data, pkt->size);
return 0;
}
| 1threat |
static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIContext *avi = s->priv_data;
ByteIOContext *pb = s->pb;
int n, d[8], size;
offset_t i, sync;
void* dstr;
if (ENABLE_DV_DEMUXER && avi->dv_demux) {
size = dv_get_packet(avi->dv_demux, pkt);
if (size >= 0)
return size;
}
if(avi->non_interleaved){
int best_stream_index = 0;
AVStream *best_st= NULL;
AVIStream *best_ast;
int64_t best_ts= INT64_MAX;
int i;
for(i=0; i<s->nb_streams; i++){
AVStream *st = s->streams[i];
AVIStream *ast = st->priv_data;
int64_t ts= ast->frame_offset;
if(ast->sample_size)
ts /= ast->sample_size;
ts= av_rescale(ts, AV_TIME_BASE * (int64_t)st->time_base.num, st->time_base.den);
if(ts < best_ts && st->nb_index_entries){
best_ts= ts;
best_st= st;
best_stream_index= i;
}
}
best_ast = best_st->priv_data;
best_ts= av_rescale(best_ts, best_st->time_base.den, AV_TIME_BASE * (int64_t)best_st->time_base.num);
if(best_ast->remaining)
i= av_index_search_timestamp(best_st, best_ts, AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD);
else
i= av_index_search_timestamp(best_st, best_ts, AVSEEK_FLAG_ANY);
if(i>=0){
int64_t pos= best_st->index_entries[i].pos;
pos += best_ast->packet_size - best_ast->remaining;
url_fseek(s->pb, pos + 8, SEEK_SET);
assert(best_ast->remaining <= best_ast->packet_size);
avi->stream_index= best_stream_index;
if(!best_ast->remaining)
best_ast->packet_size=
best_ast->remaining= best_st->index_entries[i].size;
}
}
resync:
if(avi->stream_index >= 0){
AVStream *st= s->streams[ avi->stream_index ];
AVIStream *ast= st->priv_data;
int size;
if(ast->sample_size <= 1)
size= INT_MAX;
else if(ast->sample_size < 32)
size= 64*ast->sample_size;
else
size= ast->sample_size;
if(size > ast->remaining)
size= ast->remaining;
av_get_packet(pb, pkt, size);
if(ast->has_pal && pkt->data && pkt->size<(unsigned)INT_MAX/2){
ast->has_pal=0;
pkt->size += 4*256;
pkt->data = av_realloc(pkt->data, pkt->size + FF_INPUT_BUFFER_PADDING_SIZE);
if(pkt->data)
memcpy(pkt->data + pkt->size - 4*256, ast->pal, 4*256);
}
if (ENABLE_DV_DEMUXER && avi->dv_demux) {
dstr = pkt->destruct;
size = dv_produce_packet(avi->dv_demux, pkt,
pkt->data, pkt->size);
pkt->destruct = dstr;
pkt->flags |= PKT_FLAG_KEY;
} else {
pkt->dts = ast->frame_offset;
if(ast->sample_size)
pkt->dts /= ast->sample_size;
pkt->stream_index = avi->stream_index;
if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
AVIndexEntry *e;
int index;
assert(st->index_entries);
index= av_index_search_timestamp(st, pkt->dts, 0);
e= &st->index_entries[index];
if(index >= 0 && e->timestamp == ast->frame_offset){
if (e->flags & AVINDEX_KEYFRAME)
pkt->flags |= PKT_FLAG_KEY;
}
} else {
pkt->flags |= PKT_FLAG_KEY;
}
if(ast->sample_size)
ast->frame_offset += pkt->size;
else
ast->frame_offset++;
}
ast->remaining -= size;
if(!ast->remaining){
avi->stream_index= -1;
ast->packet_size= 0;
}
return size;
}
memset(d, -1, sizeof(int)*8);
for(i=sync=url_ftell(pb); !url_feof(pb); i++) {
int j;
for(j=0; j<7; j++)
d[j]= d[j+1];
d[7]= get_byte(pb);
size= d[4] + (d[5]<<8) + (d[6]<<16) + (d[7]<<24);
if( d[2] >= '0' && d[2] <= '9'
&& d[3] >= '0' && d[3] <= '9'){
n= (d[2] - '0') * 10 + (d[3] - '0');
}else{
n= 100;
}
if(i + size > avi->fsize || d[0]<0)
continue;
if( (d[0] == 'i' && d[1] == 'x' && n < s->nb_streams)
||(d[0] == 'J' && d[1] == 'U' && d[2] == 'N' && d[3] == 'K')
||(d[0] == 'i' && d[1] == 'd' && d[2] == 'x' && d[3] == '1')){
url_fskip(pb, size);
goto resync;
}
if( d[0] >= '0' && d[0] <= '9'
&& d[1] >= '0' && d[1] <= '9'){
n= (d[0] - '0') * 10 + (d[1] - '0');
}else{
n= 100;
}
if(n < s->nb_streams){
AVStream *st;
AVIStream *ast;
st = s->streams[n];
ast = st->priv_data;
if(s->nb_streams>=2){
AVStream *st1 = s->streams[1];
AVIStream *ast1= st1->priv_data;
if( d[2] == 'w' && d[3] == 'b'
&& n==0
&& st ->codec->codec_type == CODEC_TYPE_VIDEO
&& st1->codec->codec_type == CODEC_TYPE_AUDIO
&& ast->prefix == 'd'*256+'c'
&& (d[2]*256+d[3] == ast1->prefix || !ast1->prefix_count)
){
n=1;
st = st1;
ast = ast1;
av_log(s, AV_LOG_WARNING, "Invalid stream+prefix combination, assuming audio\n");
}
}
if( (st->discard >= AVDISCARD_DEFAULT && size==0)
|| st->discard >= AVDISCARD_ALL){
if(ast->sample_size) ast->frame_offset += pkt->size;
else ast->frame_offset++;
url_fskip(pb, size);
goto resync;
}
if (d[2] == 'p' && d[3] == 'c' && size<=4*256+4) {
int k = get_byte(pb);
int last = (k + get_byte(pb) - 1) & 0xFF;
get_le16(pb);
for (; k <= last; k++)
ast->pal[k] = get_be32(pb)>>8;
ast->has_pal= 1;
goto resync;
} else if( ((ast->prefix_count<5 || sync+9 > i) && d[2]<128 && d[3]<128) ||
d[2]*256+d[3] == ast->prefix
) {
if(d[2]*256+d[3] == ast->prefix)
ast->prefix_count++;
else{
ast->prefix= d[2]*256+d[3];
ast->prefix_count= 0;
}
avi->stream_index= n;
ast->packet_size= size + 8;
ast->remaining= size;
{
uint64_t pos= url_ftell(pb) - 8;
if(!st->index_entries || !st->nb_index_entries || st->index_entries[st->nb_index_entries - 1].pos < pos){
av_add_index_entry(st, pos, ast->frame_offset / FFMAX(1, ast->sample_size), size, 0, AVINDEX_KEYFRAME);
}
}
goto resync;
}
}
}
} | 1threat |
How can i validate smtp host in asp.net MVC : public int Smtp_Id{ get; set; }
[Display(Name="Mail From")]
[Required(ErrorMessage = "Please enter senders mail address.")]
[EmailAddress(ErrorMessage = "Invalid Email Address")]
public string Smtp_mailfrom { get; set; }
[Display(Name = "SMTP Host")]
[Required(ErrorMessage = "Please enter host name.")]
public string Smtp_Host { get; set; }
[Display(Name = "User Name")]
[Required(ErrorMessage = "Please enter username.")]
[MaxLength(50,ErrorMessage="Username Should not be more than 50 charachters.")]
public string Smtp_username { get; set; }
[Display(Name = "Password")]
[MaxLength(50, ErrorMessage = "Password Should not be more than 50 charachters.")]
[Required(ErrorMessage = "Please enter password.")]
public string Smtp_password { get; set; }
[Display(Name = "SMTP Port")]
[Required(ErrorMessage = "Please enter Port.")]
public int Smtp_Port { get; set; }
i want to validate smtp host and port Please let me know how can i do this?
i want to smtp.gmail.com or smtp-mail.outlook.com
But now my code is allowing numbers also
Please help me buddy | 0debug |
static int msnwc_tcp_read_packet(AVFormatContext *ctx, AVPacket *pkt)
{
AVIOContext *pb = ctx->pb;
uint16_t keyframe;
uint32_t size, timestamp;
avio_skip(pb, 1);
avio_skip(pb, 2);
avio_skip(pb, 2);
keyframe = avio_rl16(pb);
size = avio_rl32(pb);
avio_skip(pb, 4);
avio_skip(pb, 4);
timestamp = avio_rl32(pb);
if(!size || av_get_packet(pb, pkt, size) != size)
return -1;
avio_skip(pb, 1);
pkt->pts = timestamp;
pkt->dts = timestamp;
pkt->stream_index = 0;
if(keyframe&1)
pkt->flags |= AV_PKT_FLAG_KEY;
return HEADER_SIZE + size;
}
| 1threat |
static void qemu_kvm_init_cpu_signals(CPUState *env)
{
int r;
sigset_t set;
struct sigaction sigact;
memset(&sigact, 0, sizeof(sigact));
sigact.sa_handler = dummy_signal;
sigaction(SIG_IPI, &sigact, NULL);
#ifdef CONFIG_IOTHREAD
pthread_sigmask(SIG_BLOCK, NULL, &set);
sigdelset(&set, SIG_IPI);
sigdelset(&set, SIGBUS);
r = kvm_set_signal_mask(env, &set);
if (r) {
fprintf(stderr, "kvm_set_signal_mask: %s\n", strerror(-r));
exit(1);
}
#else
sigemptyset(&set);
sigaddset(&set, SIG_IPI);
sigaddset(&set, SIGIO);
sigaddset(&set, SIGALRM);
pthread_sigmask(SIG_BLOCK, &set, NULL);
pthread_sigmask(SIG_BLOCK, NULL, &set);
sigdelset(&set, SIGIO);
sigdelset(&set, SIGALRM);
#endif
sigdelset(&set, SIG_IPI);
sigdelset(&set, SIGBUS);
r = kvm_set_signal_mask(env, &set);
if (r) {
fprintf(stderr, "kvm_set_signal_mask: %s\n", strerror(-r));
exit(1);
}
}
| 1threat |
Apache Spark: Group by condition : <p>I have a table which is like:</p>
<pre><code>+-----+-----+
| name|value|
+-----+-----+
|Alice| 1.2|
| Lisa| 3.4|
| Nick| 0.8|
| Jack| 10.1|
| Cici| 4.4|
+-----+-----+
</code></pre>
<p>I want to group the data by condition such as [value < 1, 1 <= value < 5, value >= 5] and know the percentile of each group, so my expect group will be like this:</p>
<pre><code>group percentile
value < 1 0.20
1<=value<5 0.60
value >= 5 0.20
</code></pre>
<p>Is there a simple and clear way to do this?</p>
| 0debug |
document.location = 'http://evil.com?username=' + user_input; | 1threat |
Failure to get nonnegative integer single number : number = int(input('Enter a nonnegative integer: '))
product=1
for i in range(number):
product = product * (i+1)
print(product)
The result is the nonnegative integer is
1
2
6
24...
5040
But I only need the nonnegative integer of 7 which is 5040, how do I get that? | 0debug |
iOS safari input caret color : <p>I have a small CSS issue with Safari on iPhone device. My search input is blue and when user focuses on it, caret is almost invisible:</p>
<p><a href="https://i.stack.imgur.com/7cBaT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7cBaT.png" alt="Caret"></a></p>
<p>In all desktop browsers, it has right color (white), even on desktop Safari. Any idea how to fix this and change caret color on iOS device?</p>
<p>Input styles:</p>
<pre><code>input {
background-color: $stateBlue;
height: $navbarItemHeight;
padding: 0 10px;
vertical-align: bottom;
color: $white;
border-radius: $borderRadius;
font-size: 1.1666666667em; // 16px
-moz-appearance:none;
-webkit-appearance:none;
&::-webkit-input-placeholder {
text-shadow: none;
-webkit-text-fill-color: initial;
}
}
</code></pre>
| 0debug |
Why doesn't Javascript bind my dot expression correctly? : <p>I am wondering whether dot-abstraction methods (e.g. <code>dog.bark</code>) bind at runtime or at compile-time. My question concerns the following code, which throws an error:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>(true ? ''.toLowerCase : ''.toUpperCase)()</code></pre>
</div>
</div>
</p>
<p>But the following does not:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>true ? ''.toLowerCase() : ''.toUpperCase()</code></pre>
</div>
</div>
</p>
<p>Why is my string literal <code>''</code> not getting resolved in the first example?</p>
| 0debug |
What does "using var_name = data_type;" in c/c++ means? : I found a piece of code that uses the following statement:
using var_name = data_type;
This is the first time that I encountered it. What does it mean or do? | 0debug |
Cannot create platform OpenGL context : <p>On my ubuntu 18.04, when I start android emulator:</p>
<pre><code>$ANDROID_HOME/emulator/emulator -avd pixel
Warning: QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are
enabled ((null):0, (null))
emulator: INFO: QtLogger.cpp:66: Warning: QXcbIntegration: Cannot create platform OpenGL
context, neither GLX nor EGL are enabled ((null):0, (null))
</code></pre>
<p>Just standard Android workflow... I can't believe this is unic issue... </p>
| 0debug |
Free Basics Platform(internet.org) : <p>Free Basics has a policy that you need to disable Javascript code in your website now I have a desktop version website and I want to register it on Free Basics platform should I responsive the same website and disable or hide the Javascript using some Php scripts or css or I have to make a new responsive website with not even a single line of Javascript code?
help will be much appreciated thanks </p>
| 0debug |
Multiple dex files define Lcom/google/firebase/FirebaseException : <p>I encountered a problem with the Firebase integration. First of all, I have added rules to the root-level <code>build.gradle</code> file:</p>
<pre><code>buildscript {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
</code></pre>
<p>And the module Gradle file:</p>
<pre><code>apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 14
targetSdkVersion 24
versionCode 2
versionName "0.9"
}
buildTypes {
///
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.firebase:firebase-core:9.0.2'
compile 'com.google.firebase:firebase-crash:9.0.2'
}
apply plugin: 'com.google.gms.google-services'
</code></pre>
<p>During the build of the project, I get the error:</p>
<blockquote>
<p>Error:Error converting bytecode to dex: Cause:
com.android.dex.DexException: Multiple dex files define
Lcom/google/firebase/FirebaseException;</p>
</blockquote>
<p>Error reason is clear, but I didn't compile any library twice. Should I exclude <code>FirebaseException</code> class from the build process manually? If so, how? Perhaps this is a bug within the Firebase dependencies?</p>
<p>Thanks.</p>
| 0debug |
Assembly - how to use less variables : I am making the game "Connect Four". I have a square board which is 4x4. For each tile on the board I have to draw a disc (squre shaped) which has an x value and a y value. The problem is that I have to make 32 variables or a lot of procedures which change the two variables all the time but these options seem very unefficient and the code would be very long. If you have any suggestions of how to it more efficient, please tell.
Thanks for the help. | 0debug |
int qemu_socket(int domain, int type, int protocol)
{
int ret;
#ifdef SOCK_CLOEXEC
ret = socket(domain, type | SOCK_CLOEXEC, protocol);
#else
ret = socket(domain, type, protocol);
if (ret >= 0) {
qemu_set_cloexec(ret);
}
#endif
return ret;
}
| 1threat |
Install mysql2 gem on macOS Sierra : <p>I'm trying to install mysql2 gem (0.4.5) on macOS Sierra (10.12.1) and getting the error. I don't have local mysql server, it's remote. </p>
<p>Here is error log:</p>
<pre><code>checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /usr/local/Cellar/mysql-connector-c/6.1.9/lib
-----
creating Makefile
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/user/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-16/2.3.0-static/mysql2-0.4.4/mkmf.log
current directory: /Users/user/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/mysql2-0.4.4/ext/mysql2
make "DESTDIR=" clean
current directory: /Users/user/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/mysql2-0.4.4/ext/mysql2
make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
compiling statement.c
linking shared-object mysql2/mysql2.bundle
ld: library not found for -l-lpthread
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1
make failed, exit code 2
</code></pre>
<p>Did anyone meet similar error? </p>
| 0debug |
av_cold void ff_vp9dsp_init(VP9DSPContext *dsp, int bpp)
{
if (bpp == 8) {
ff_vp9dsp_init_8(dsp);
} else if (bpp == 10) {
ff_vp9dsp_init_10(dsp);
} else {
av_assert0(bpp == 12);
ff_vp9dsp_init_12(dsp);
}
if (ARCH_X86) ff_vp9dsp_init_x86(dsp, bpp);
if (ARCH_MIPS) ff_vp9dsp_init_mips(dsp, bpp);
}
| 1threat |
def min_difference(test_list):
temp = [abs(b - a) for a, b in test_list]
res = min(temp)
return (res) | 0debug |
How to find n-letter word in text file? : <p>I am trying to find one-letter word, two-letter word, three-letter word and so on, for a shakespeare sonnet text file. I want to find n-letter words, assign them in a separate list according to 'n' letters in the form of list.</p>
<p>How shall i proceed with such a file?</p>
| 0debug |
How can I find initial password for jenkins? : <p>I already searched the related questions like here;</p>
<p><a href="https://stackoverflow.com/questions/37146063/how-do-i-get-initial-admin-password-for-jenkins-on-mac">How do I get initial admin password for jenkins on Mac?</a></p>
<p>and here;</p>
<p><a href="https://stackoverflow.com/questions/17467139/how-to-recover-jenkins-password">How to recover Jenkins password</a></p>
<p>However, I cannot find a solution for my problem.</p>
<p>I am following the instructions to install jenkins on this link;</p>
<p><a href="https://jenkins.io/doc/book/installing/" rel="noreferrer">https://jenkins.io/doc/book/installing/</a></p>
<p>and I have run the following commands to install and tried to make it run on my local machine (mac os);</p>
<pre><code>docker run \
-u root \
--rm \
-d \
-p 8080:8080 \
-p 50000:50000 \
-v jenkins-data:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
jenkinsci/blueocean
</code></pre>
<p>It installs it properly but when I get to the login screen it asks for the initial admin password. Because the installation runs in (-d mode) backend, I cannot see the initial password after the installation completes. When I remove -d for the installation, then the installation does not work. </p>
<p>I also checked the shared folder (User/Shared/Jenkins/Home) directory and there was no <code>secrets</code> folder in it. So I created one manually and followed the instructions (in the answers) on this link again;</p>
<p><a href="https://stackoverflow.com/questions/37146063/how-do-i-get-initial-admin-password-for-jenkins-on-mac">How do I get initial admin password for jenkins on Mac?</a></p>
<p>Afterwards, I removed the related docker process and restarted all the installation process from the beginning but I got the same result.</p>
<p>In this case, how can I find this initial admin password or how can I generate it again?</p>
<p>BTW: I am also checking the logs (where in <code>/var/log/jenkins</code>) but it seems that it stopped writing there after my first install attempt and I also couldn't find the initial password there).</p>
| 0debug |
void replay_shutdown_request(void)
{
if (replay_mode == REPLAY_MODE_RECORD) {
replay_mutex_lock();
replay_put_event(EVENT_SHUTDOWN);
replay_mutex_unlock();
}
}
| 1threat |
viewsource:Link hey guys, How to use Python to scrape Source View of a Page : I'm trying to scrape a page by its sourceview. For example:
view-source:https://www.youtube.com/watch?v=t3-zAlsCJ4c&t=1607s
I can not get it by this code:
res = requests.get('view-source:https://www.youtube.com/watch?v=t3-zAlsCJ4c&t=1607s')
It cause Error like this:
> Traceback (most recent call last):
File "C:\Users\hdtra\Desktop\In processing\Facebook_spider.py", line 31, in <module>
res = requests.get('view-source:https://www.facebook.com/pg/vuonraunhatrang/about/?ref=page_internal')
File "C:\Program Files\Python36\lib\site-packages\requests\api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "C:\Program Files\Python36\lib\site-packages\requests\api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Program Files\Python36\lib\site-packages\requests\sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "C:\Program Files\Python36\lib\site-packages\requests\sessions.py", line 612, in send
adapter = self.get_adapter(url=request.url)
File "C:\Program Files\Python36\lib\site-packages\requests\sessions.py", line 703, in get_adapter
raise InvalidSchema("No connection adapters were found for '%s'" % url)
requests.exceptions.InvalidSchema: No connection adapters were found for 'view-source:https://www.facebook.com/pg/vuonraunhatrang/about/?ref=page_internal'
>>>
Can someone please show me how I can scrape this Viewsource link ?
For some reason scrape using .get() method does not work on my project.
I don't have enough information from that normal page, but with this viewsource windows, it works perfectly.
Thanks guys ! | 0debug |
static void dvbsub_parse_region_segment(AVCodecContext *avctx,
uint8_t *buf, int buf_size)
{
DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data;
uint8_t *buf_end = buf + buf_size;
int region_id, object_id;
DVBSubRegion *region;
DVBSubObject *object;
DVBSubObjectDisplay *display;
int fill;
if (buf_size < 10)
return;
region_id = *buf++;
region = get_region(ctx, region_id);
if (region == NULL)
{
region = av_mallocz(sizeof(DVBSubRegion));
region->id = region_id;
region->next = ctx->region_list;
ctx->region_list = region;
fill = ((*buf++) >> 3) & 1;
region->width = AV_RB16(buf);
buf += 2;
region->height = AV_RB16(buf);
buf += 2;
if (region->width * region->height != region->buf_size) {
if (region->pbuf != 0)
av_free(region->pbuf);
region->buf_size = region->width * region->height;
region->pbuf = av_malloc(region->buf_size);
fill = 1;
region->depth = 1 << (((*buf++) >> 2) & 7);
region->clut = *buf++;
if (region->depth == 8)
region->bgcolour = *buf++;
else {
buf += 1;
if (region->depth == 4)
region->bgcolour = (((*buf++) >> 4) & 15);
else
region->bgcolour = (((*buf++) >> 2) & 3);
#ifdef DEBUG
av_log(avctx, AV_LOG_INFO, "Region %d, (%dx%d)\n", region_id, region->width, region->height);
#endif
if (fill) {
memset(region->pbuf, region->bgcolour, region->buf_size);
#ifdef DEBUG
av_log(avctx, AV_LOG_INFO, "Fill region (%d)\n", region->bgcolour);
#endif
delete_region_display_list(ctx, region);
while (buf + 5 < buf_end) {
object_id = AV_RB16(buf);
buf += 2;
object = get_object(ctx, object_id);
if (object == NULL) {
object = av_mallocz(sizeof(DVBSubObject));
object->id = object_id;
object->next = ctx->object_list;
ctx->object_list = object;
object->type = (*buf) >> 6;
display = av_mallocz(sizeof(DVBSubObjectDisplay));
display->object_id = object_id;
display->region_id = region_id;
display->x_pos = AV_RB16(buf) & 0xfff;
buf += 2;
display->y_pos = AV_RB16(buf) & 0xfff;
buf += 2;
if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) {
display->fgcolour = *buf++;
display->bgcolour = *buf++;
display->region_list_next = region->display_list;
region->display_list = display;
display->object_list_next = object->display_list;
object->display_list = display;
| 1threat |
Illegal instruction (core dumped) after running import tensorflow : <p>I created a fresh virtual environment: <code>virtualenv -p python2 test_venv/</code>
And installed tensorflow: <code>pip install --upgrade --no-cache-dir tensorflow</code></p>
<p><code>import tensorflow</code> gives me <code>Illegal instruction (core dumped)</code></p>
<p>Please help me understand what's going on and how I can fix it. Thank you.</p>
<h3>CPU information:</h3>
<pre><code>-cpu
description: CPU
product: Intel(R) Core(TM) i3 CPU M 330 @ 2.13GHz
bus info: cpu@0
version: CPU Version
capabilities: x86-64 fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 popcnt lahf_lm tpr_shadow vnmi flexpriority ept vpid dtherm arat cpufreq
</code></pre>
<h3>Stacktrace obtained with gdb:</h3>
<pre><code>#0 0x00007fffe5793880 in std::pair<std::__detail::_Node_iterator<std::pair<tensorflow::StringPiece const, std::function<bool (tensorflow::Variant*)> >, false, true>, bool> std::_Hashtable<tensorflow::StringPiece, std::pair<tensorflow::StringPiece const, std::function<bool (tensorflow::Variant*)> >, std::allocator<std::pair<tensorflow::StringPiece const, std::function<bool (tensorflow::Variant*)> > >, std::__detail::_Select1st, std::equal_to<tensorflow::StringPiece>, tensorflow::StringPieceHasher, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_emplace<std::pair<tensorflow::StringPiece, std::function<bool (tensorflow::Variant*)> > >(std::integral_constant<bool, true>, std::pair<tensorflow::StringPiece, std::function<bool (tensorflow::Variant*)> >&&) ()
from /media/gerry/hdd_1/ws_hdd/test_venv/local/lib/python2.7/site-packages/tensorflow/python/../libtensorflow_framework.so
#1 0x00007fffe5795735 in tensorflow::UnaryVariantOpRegistry::RegisterDecodeFn(std::string const&, std::function<bool (tensorflow::Variant*)> const&) () from /media/gerry/hdd_1/ws_hdd/test_venv/local/lib/python2.7/site-packages/tensorflow/python/../libtensorflow_framework.so
#2 0x00007fffe5770a7c in tensorflow::variant_op_registry_fn_registration::UnaryVariantDecodeRegistration<tensorflow::Tensor>::UnaryVariantDecodeRegistration(std::string const&) ()
from /media/gerry/hdd_1/ws_hdd/test_venv/local/lib/python2.7/site-packages/tensorflow/python/../libtensorflow_framework.so
#3 0x00007fffe56ea165 in _GLOBAL__sub_I_tensor.cc ()
from /media/gerry/hdd_1/ws_hdd/test_venv/local/lib/python2.7/site-packages/tensorflow/python/../libtensorflow_framework.so
#4 0x00007ffff7de76ba in call_init (l=<optimized out>, argc=argc@entry=2, argv=argv@entry=0x7fffffffd5c8, env=env@entry=0xa7b4d0)
at dl-init.c:72
#5 0x00007ffff7de77cb in call_init (env=0xa7b4d0, argv=0x7fffffffd5c8, argc=2, l=<optimized out>) at dl-init.c:30
#6 _dl_init (main_map=main_map@entry=0xa11920, argc=2, argv=0x7fffffffd5c8, env=0xa7b4d0) at dl-init.c:120
#7 0x00007ffff7dec8e2 in dl_open_worker (a=a@entry=0x7fffffffb5c0) at dl-open.c:575
#8 0x00007ffff7de7564 in _dl_catch_error (objname=objname@entry=0x7fffffffb5b0, errstring=errstring@entry=0x7fffffffb5b8,
mallocedp=mallocedp@entry=0x7fffffffb5af, operate=operate@entry=0x7ffff7dec4d0 <dl_open_worker>, args=args@entry=0x7fffffffb5c0)
at dl-error.c:187
#9 0x00007ffff7debda9 in _dl_open (
file=0x7fffea7cbc34 "/media/gerry/hdd_1/ws_hdd/test_venv/local/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so", mode=-2147483646, caller_dlopen=0x51ad19 <_PyImport_GetDynLoadFunc+233>, nsid=-2, argc=<optimized out>, argv=<optimized out>, env=0xa7b4d0)
at dl-open.c:660
#10 0x00007ffff75ecf09 in dlopen_doit (a=a@entry=0x7fffffffb7f0) at dlopen.c:66
#11 0x00007ffff7de7564 in _dl_catch_error (objname=0x9b1870, errstring=0x9b1878, mallocedp=0x9b1868, operate=0x7ffff75eceb0 <dlopen_doit>,
args=0x7fffffffb7f0) at dl-error.c:187
#12 0x00007ffff75ed571 in _dlerror_run (operate=operate@entry=0x7ffff75eceb0 <dlopen_doit>, args=args@entry=0x7fffffffb7f0) at dlerror.c:163
#13 0x00007ffff75ecfa1 in __dlopen (file=<optimized out>, mode=<optimized out>) at dlopen.c:87
#14 0x000000000051ad19 in _PyImport_GetDynLoadFunc ()
#15 0x000000000051a8e4 in _PyImport_LoadDynamicModule ()
#16 0x00000000005b7b1b in ?? ()
#17 0x00000000004bc3fa in PyEval_EvalFrameEx ()
#18 0x00000000004c136f in PyEval_EvalFrameEx ()
#19 0x00000000004b9ab6 in PyEval_EvalCodeEx ()
#20 0x00000000004b97a6 in PyEval_EvalCode ()
#21 0x00000000004b96df in PyImport_ExecCodeModuleEx ()
#22 0x00000000004b2b06 in ?? ()
#23 0x00000000004a4ae1 in ?? ()
</code></pre>
| 0debug |
How to remove bullets from ul? : <p>I've read multiple topics with this same question and tried following all instructions but I can't seem to remove the bullets from the following <code><ul> <li></code> segment.</p>
<pre><code><div id="mobile-contact-bar-outer">
<ul>
<li><a data-rel="external" href="tel:+18885551212"><span class="fa-stack fa-3x"><i class="fa-fw fas fa-phone"></i>
<span class="screen-reader-text">Phone Number for calling</span></span></a></li>
<li><a data-rel="external" href="mailto:name@email.com"><span class="fa-stack fa-3x"><i class="fa-fw far fa-envelope"></i><span class="screen-reader-text">Email Address</span></span></a></li>
</ul>
</div>
</code></pre>
<p>I've added both:</p>
<pre><code>div#mobile-contact-bar-outer {
list-style-type: none!important;
}
div#mobile-contact-bar {
list-style-type: none!important;
}
</code></pre>
<p>Neither have any effect. What am I missing? No caching on site.</p>
| 0debug |
`createStackNavigator()` has been moved to `react-navigation-stack` : <p>I'm using react-navigation in my project, and this error pops up.</p>
<p>I googled this error message and found no result.</p>
<p>(I can't post images yet)</p>
<p>The error message reads:</p>
<pre><code>`createStackNavigator()` has been moved to `react-navigation-stack`. See https://reactnavigation.org/docs/4.x/stack-navigator.html for more details.
</code></pre>
<p>The code worked on my friend's machine, somehow</p>
| 0debug |
What is the Difference between Angular Js, Angular 1,2,3 and 4 ? : <p>From where I should start reading if I want to know completely about angular ? Need Answers in detail.. Thanks in advance.</p>
| 0debug |
TS2304: cannot find name require and process : <p>When I want to start my angular 2 app using "npm start". I get errors:
<a href="https://i.stack.imgur.com/IPbFH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IPbFH.png" alt="enter image description here"></a></p>
<p>I tried a lot of "solutions" from internet, but nothing works.
My versions: </p>
<ol>
<li>npm - 4.1.2</li>
<li>typings - 2.1.0</li>
<li>node - 7.5.0</li>
</ol>
<p><strong>tsconfig.json</strong></p>
<pre><code>{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es2015", "dom"],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
</code></pre>
<p><strong>polyfills.ts</strong></p>
<pre><code>import 'core-js/es6';
import 'core-js/es7/reflect';
require('zone.js/dist/zone');
if (process.env.ENV === 'production') {
// Production
} else {
// Development and test
Error['stackTraceLimit'] = Infinity;
require('zone.js/dist/long-stack-trace-zone');
}
</code></pre>
<p><strong>package.json</strong></p>
<pre><code>{
"name": "storyWorld",
"version": "1.0.0",
"description": "Write your story.",
"scripts": {
"start": "webpack-dev-server --inline --progress --port 8080",
"test": "karma start",
"build": "rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail"
},
"license": "MIT",
"dependencies": {
"@angular/common": "~2.4.0",
"@angular/compiler": "~2.4.0",
"@angular/core": "~2.4.0",
"@angular/forms": "~2.4.0",
"@angular/http": "~2.4.0",
"@angular/platform-browser": "~2.4.0",
"@angular/platform-browser-dynamic": "~2.4.0",
"@angular/router": "~3.4.0",
"core-js": "^2.4.1",
"rxjs": "5.0.1",
"zone.js": "^0.7.4"
},
"devDependencies": {
"@types/jasmine": "^2.5.35",
"@types/node": "^6.0.63",
"angular2-template-loader": "^0.6.0",
"awesome-typescript-loader": "^3.0.0-beta.18",
"css-loader": "^0.26.1",
"extract-text-webpack-plugin": "2.0.0-beta.5",
"file-loader": "^0.9.0",
"html-loader": "^0.4.3",
"html-webpack-plugin": "^2.16.1",
"jasmine-core": "^2.4.1",
"karma": "^1.2.0",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.2",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.1",
"node-sass": "^4.5.0",
"null-loader": "^0.1.1",
"phantomjs-prebuilt": "^2.1.7",
"raw-loader": "^0.5.1",
"rimraf": "^2.5.2",
"sass-loader": "^5.0.1",
"style-loader": "^0.13.1",
"typescript": "~2.0.10",
"webpack": "2.2.0",
"webpack-dev-server": "2.2.0-rc.0",
"webpack-merge": "^2.4.0"
}
}
</code></pre>
<p><strong>webpack.common.js</strong></p>
<pre><code> var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var helpers = require('./helpers');
module.exports = {
entry: {
'polyfills': './src/polyfills.ts',
'vendor': './src/vendor.ts',
'app': './src/main.ts'
},
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
loaders: [{
loader: 'awesome-typescript-loader',
options: { configFileName: helpers.root('src', 'tsconfig.json') }
} , 'angular2-template-loader']
},
{
test: /\.html$/,
loader: 'html-loader'
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
loader: 'file-loader?name=assets/[name].[hash].[ext]'
},
{
test: /\.css$/,
exclude: helpers.root('src', 'app'),
loader: ExtractTextPlugin.extract({ fallbackLoader: 'style-loader', loader: 'css-loader?sourceMap' })
},
{
test: /\.css$/,
include: helpers.root('src', 'app'),
loader: 'raw-loader'
},
{
test: /\.scss$/,
exclude: /node_modules/,
loaders: ['raw-loader', 'sass-loader'] // sass-loader not scss-loader
}
]
},
plugins: [
// Workaround for angular/angular#11580
new webpack.ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
helpers.root('./src'), // location of your src
{} // a map of your routes
),
new webpack.optimize.CommonsChunkPlugin({
name: ['app', 'vendor', 'polyfills']
}),
new HtmlWebpackPlugin({
template: 'src/index.html'
})
]
};
</code></pre>
| 0debug |
syntax error, unexpected T_VARIABLE in subquwery : <p><a href="http://i.stack.imgur.com/3OkbU.jpg" rel="nofollow">i have syntax error in line 213 please need some help</a></p>
| 0debug |
cursor.execute('SELECT * FROM users WHERE username = ' + user_input) | 1threat |
R date format when written in excel comes as general not date : I am using openxlsx package to write back a file. i have already used as.date and format function to make my fates look like dd-mmm-yyyy
but when I open the excel file, even though the date comes as, say "12-may-2018", I cannot filter them out like excel dates. it shows that the type of the data is general. even if I convert it to date format in excel, it still doesn't let me filter it out by year, month and day, which happens for excel dates. I can convert them to date type by manually palcing my cursor in the middle of a cell and pressing the return key. Doing that for the whole data will be too much manual effort which I want to reduce. Is there any way to make it happen. Thanks for any suggestions that you guys give. | 0debug |
int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
{
int i;
Picture *pic;
s->mb_skipped = 0;
assert(s->last_picture_ptr==NULL || s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3);
if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->f.data[0]) {
if(s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3){
free_frame_buffer(s, s->last_picture_ptr);
if(!s->encoding){
for(i=0; i<s->picture_count; i++){
if (s->picture[i].f.data[0] && &s->picture[i] != s->next_picture_ptr && s->picture[i].f.reference) {
av_log(avctx, AV_LOG_ERROR, "releasing zombie picture\n");
free_frame_buffer(s, &s->picture[i]);
}
}
}
}
}
if(!s->encoding){
ff_release_unused_pictures(s, 1);
if (s->current_picture_ptr && s->current_picture_ptr->f.data[0] == NULL)
pic= s->current_picture_ptr;
else{
i= ff_find_unused_picture(s, 0);
pic= &s->picture[i];
}
pic->f.reference = 0;
if (!s->dropable){
if (s->codec_id == CODEC_ID_H264)
pic->f.reference = s->picture_structure;
else if (s->pict_type != AV_PICTURE_TYPE_B)
pic->f.reference = 3;
}
pic->f.coded_picture_number = s->coded_picture_number++;
if(ff_alloc_picture(s, pic, 0) < 0)
return -1;
s->current_picture_ptr= pic;
s->current_picture_ptr->f.top_field_first = s->top_field_first;
if(s->codec_id == CODEC_ID_MPEG1VIDEO || s->codec_id == CODEC_ID_MPEG2VIDEO) {
if(s->picture_structure != PICT_FRAME)
s->current_picture_ptr->f.top_field_first = (s->picture_structure == PICT_TOP_FIELD) == s->first_field;
}
s->current_picture_ptr->f.interlaced_frame = !s->progressive_frame && !s->progressive_sequence;
s->current_picture_ptr->field_picture = s->picture_structure != PICT_FRAME;
}
s->current_picture_ptr->f.pict_type = s->pict_type;
s->current_picture_ptr->f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
ff_copy_picture(&s->current_picture, s->current_picture_ptr);
if (s->pict_type != AV_PICTURE_TYPE_B) {
s->last_picture_ptr= s->next_picture_ptr;
if(!s->dropable)
s->next_picture_ptr= s->current_picture_ptr;
}
if(s->codec_id != CODEC_ID_H264){
if ((s->last_picture_ptr == NULL || s->last_picture_ptr->f.data[0] == NULL) &&
(s->pict_type!=AV_PICTURE_TYPE_I || s->picture_structure != PICT_FRAME)){
if (s->pict_type != AV_PICTURE_TYPE_I)
av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n");
else if (s->picture_structure != PICT_FRAME)
av_log(avctx, AV_LOG_INFO, "allocate dummy last picture for field based first keyframe\n");
i= ff_find_unused_picture(s, 0);
s->last_picture_ptr= &s->picture[i];
if(ff_alloc_picture(s, s->last_picture_ptr, 0) < 0)
return -1;
ff_thread_report_progress((AVFrame*)s->last_picture_ptr, INT_MAX, 0);
ff_thread_report_progress((AVFrame*)s->last_picture_ptr, INT_MAX, 1);
}
if ((s->next_picture_ptr == NULL || s->next_picture_ptr->f.data[0] == NULL) && s->pict_type == AV_PICTURE_TYPE_B) {
i= ff_find_unused_picture(s, 0);
s->next_picture_ptr= &s->picture[i];
if(ff_alloc_picture(s, s->next_picture_ptr, 0) < 0)
return -1;
ff_thread_report_progress((AVFrame*)s->next_picture_ptr, INT_MAX, 0);
ff_thread_report_progress((AVFrame*)s->next_picture_ptr, INT_MAX, 1);
}
}
if(s->last_picture_ptr) ff_copy_picture(&s->last_picture, s->last_picture_ptr);
if(s->next_picture_ptr) ff_copy_picture(&s->next_picture, s->next_picture_ptr);
assert(s->pict_type == AV_PICTURE_TYPE_I || (s->last_picture_ptr && s->last_picture_ptr->f.data[0]));
if(s->picture_structure!=PICT_FRAME && s->out_format != FMT_H264){
int i;
for(i=0; i<4; i++){
if(s->picture_structure == PICT_BOTTOM_FIELD){
s->current_picture.f.data[i] += s->current_picture.f.linesize[i];
}
s->current_picture.f.linesize[i] *= 2;
s->last_picture.f.linesize[i] *= 2;
s->next_picture.f.linesize[i] *= 2;
}
}
s->error_recognition= avctx->error_recognition;
if(s->mpeg_quant || s->codec_id == CODEC_ID_MPEG2VIDEO){
s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;
s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;
}else if(s->out_format == FMT_H263 || s->out_format == FMT_H261){
s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
}else{
s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;
s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;
}
if(s->dct_error_sum){
assert(s->avctx->noise_reduction && s->encoding);
update_noise_reduction(s);
}
if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
return ff_xvmc_field_start(s, avctx);
return 0;
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.