problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
How to store all the numbers in one variable called numbers in python 3 : I am a beginner in python and for practice I decided to make a calculator so I
need to add numbers to other numbers so numbers must be a variable how can I store all the integer and float numbers into only one variable | 0debug |
static void DEF(put, pixels8_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
{
MOVQ_BFE(mm6);
__asm__ volatile(
"lea (%3, %3), %%"REG_a" \n\t"
"movq (%1), %%mm0 \n\t"
".p2align 3 \n\t"
"1: \n\t"
"movq (%1, %3), %%mm1 \n\t"
"movq (%1, %%"REG_a"),%%mm2 \n\t"
PAVGBP(%%mm1, %%mm0, %%mm4, %%mm2, %%mm1, %%mm5)
"movq %%mm4, (%2) \n\t"
"movq %%mm5, (%2, %3) \n\t"
"add %%"REG_a", %1 \n\t"
"add %%"REG_a", %2 \n\t"
"movq (%1, %3), %%mm1 \n\t"
"movq (%1, %%"REG_a"),%%mm0 \n\t"
PAVGBP(%%mm1, %%mm2, %%mm4, %%mm0, %%mm1, %%mm5)
"movq %%mm4, (%2) \n\t"
"movq %%mm5, (%2, %3) \n\t"
"add %%"REG_a", %1 \n\t"
"add %%"REG_a", %2 \n\t"
"subl $4, %0 \n\t"
"jnz 1b \n\t"
:"+g"(h), "+S"(pixels), "+D"(block)
:"r"((x86_reg)line_size)
:REG_a, "memory");
}
| 1threat |
`npm run watch` not working in Laravel 5.4 : <p>Using Laravel 5.4 and Mix, when I run <code>npm run watch</code> it compiles everything once and looks like it is waiting for changes, but when I make changes to any of my asset files it doesn't seem to detect anything. Is anyone else having this issue in 5.4 or have a solution?</p>
| 0debug |
Blocked autofocusing on a form control in a cross-origin subframe : <p>Using Chrome, when I'm trying to change values of an input located in an IFrame of another app on our server, I get an error in Chrome:</p>
<blockquote>
<p>"Blocked autofocusing on a form control in a cross-origin subframe."</p>
</blockquote>
<p>On production (when the two apps are hosted on the same domain) it's working, but on localhost development I can't make it to work.</p>
<p>I've already tried starting Chrome with the following:</p>
<ul>
<li>--disable-web-security </li>
<li>--ignore-certificate-errors </li>
<li>--disable-site-isolation-trials </li>
<li>--allow-external-pages </li>
<li>--disable-site-isolation-for-policy</li>
</ul>
<p>but none worked.</p>
<p>Has anyone has an idea how to make it work?
If any change on server side needed, it's also an option.</p>
| 0debug |
regular expression to allow at least one dot and all character : Could any of you help me with a regular expression which will accept these:
ex1: nagarjuna.nag@vm.com
ex2 :nagarjuna12.nag@vm.com | 0debug |
get multiple Elements By Tag Name in JavaScript? : <p>Hello there am trying to make an image gallery for example lets say that I have multiple images and I want to change their opacity when I hover over them by using JavaScript I know that this is possible with CSS but am trying to accomplish this with JavaScript I tried using get Elements By Tag Name method but the problem it just can access one element by time so can I do that thanks </p>
| 0debug |
Reason why this C program stopped working : <p>I wonder why this program stopped working when I increase the value of array a[]
If it has, plaese tell me how to increase this value without crashing
Thanks</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int i, j, save;
char a[2082001];
memset(a,'1',2082000);
for (i=2;i<=2082000;i++)
{
if (a[i]=='1')
{
save=i;
for (j=i*2;j<=2082000;j+=i)
a[j]='0';
}
}
printf("save = %d",save);
return 0;
}
</code></pre>
| 0debug |
how insert different images into rows of a listview : how can i insert different `imageView` into rows of a `list view`?
I hope that you can help me!
Thanks in advance everybody!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> PLANET ADAPTER:
public abstract class PlanetAdapter extends ArrayAdapter<Planet> implements CompoundButton.OnCheckedChangeListener
{
private List<Planet> planetList = null;
private Context context = null;
ArrayList<Birra> objects;
public boolean Checked;
public PlanetAdapter(List<Planet> planetList, Context context) {
super(context, R.layout.single_listview_item, planetList);
this.planetList = planetList;
this.context = context;
}
public class PlanetHolder {
public TextView planetName;
public TextView distView;
public TextView valuta;
public CheckBox chkBox;
public EditText edit;
public TextView caratteristica;
public boolean checked;
public TextView id;
public ImageView image;
}
@Override
public int getCount() {
return planetList.size();
}
@Override
public Planet getItem(int position) {
return planetList.get(position);
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View row = convertView;
PlanetHolder holder = null;
if (row == null) {
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
row = inflater.inflate(R.layout.single_listview_item, parent, false);
holder = new PlanetHolder();
holder.planetName = (TextView) row.findViewById(R.id.name);
holder.distView = (TextView) row.findViewById(R.id.dist);
holder.valuta = (TextView) row.findViewById(R.id.valuta);
holder.chkBox = (CheckBox) row.findViewById(R.id.chk_box);
holder.edit = (EditText) row.findViewById(R.id.editText);
holder.caratteristica=(TextView) row.findViewById(R.id.caratteristica);
holder.image=(ImageView) row.findViewById(R.id.ivImage);
holder.edit.setVisibility(View.GONE);
holder.edit.setEnabled(false);
// holder.id = (TextView) row.findViewById(R.id.id);
row.setTag(holder);
} else {
holder = (PlanetHolder) row.getTag();
}
final Planet p = planetList.get(position);
holder.planetName.setText(p.getName());
holder.distView.setText("" + p.getDistance());
holder.valuta.setText("" + p.getValuta());
holder.chkBox.setChecked(p.isSelected());
holder.chkBox.setTag(p);
holder.caratteristica.setText(p.getCaratteristica());
holder.edit.setEnabled(false);
SharedPreferences states = getContext().getSharedPreferences("states", Context.MODE_PRIVATE);
boolean isChecked = states.getBoolean("holder.chkBox" + holder.planetName.getText().toString(), false);
System.out.println(isChecked);
if (isChecked) {
holder.chkBox.setChecked(true);
holder.edit.setVisibility(View.VISIBLE);
holder.edit.setEnabled(true);
SharedPreferences statess = getContext().getSharedPreferences("states", Context.MODE_PRIVATE);
String string = statess.getString("finalHolder.edit" + holder.planetName.getText().toString(), holder.edit.getText().toString().trim());
holder.edit.setText(string);
} else {
holder.chkBox.setChecked(false);
holder.edit.setVisibility(View.GONE);
holder.edit.setEnabled(false);
}
holder.chkBox.setOnCheckedChangeListener(PlanetAdapter.this);
// final BirraHolder finalHolder = birraHolder;
final PlanetHolder finalHolder = holder;
holder.chkBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (finalHolder.chkBox.isChecked()) {
finalHolder.edit.setVisibility(View.VISIBLE);
finalHolder.edit.setEnabled(true);
SharedPreferences states = getContext().getSharedPreferences("states", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = states.edit();
editor.putBoolean("holder.chkBox" + finalHolder.planetName.getText().toString(), true);
editor.commit();
finalHolder.edit.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
p.setQuantità(finalHolder.edit.getText().toString().trim());
SharedPreferences states = getContext().getSharedPreferences("states", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = states.edit();
editor.putString("finalHolder.edit" + finalHolder.planetName.getText().toString(), finalHolder.edit.getText().toString().trim());
editor.commit();
}
});
/* SharedPreferences states = getContext().getSharedPreferences("states", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = states.edit();
editor.putBoolean("holder.chkBox" + finalHolder.planetName.getText().toString(), true);
editor.commit();*/
//Utility.putPizzaItem(p);
//Utility.getPizzaItem(p);
} else {
finalHolder.edit.setVisibility(View.GONE);
finalHolder.edit.setEnabled(false);
finalHolder.edit.setText("");
}
}
});
/*holder.chkBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (finalHolder.chkBox.isChecked()) {
finalHolder.edit.setVisibility(View.VISIBLE);
finalHolder.edit.setEnabled(true);
SharedPreferences states = getContext().getSharedPreferences("states", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = states.edit();
editor.putBoolean("holder.chkBox", true);
//pizzaSelected.put(p.getId(), p);
System.out.println(p.getId());
} else {
finalHolder.edit.setVisibility(View.GONE);
finalHolder.edit.setEnabled(false);
finalHolder.edit.setText(null);
pizzaSelected.remove(p.getId());
}
}
});
*/
/* finalHolder.edit.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
p.setQuantità(finalHolder.edit.getText().toString().trim());
SharedPreferences states = getContext().getSharedPreferences("states", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = states.edit();
editor.putString("finalHolder.edit" + finalHolder.planetName.getText().toString(), finalHolder.edit.getText().toString().trim());
editor.commit();
}
});
*/
// holder.planetName.setText(p.getName());
// holder.distView.setText("" + p.getDistance());
// holder.valuta.setText("" + p.getValuta());
// holder.chkBox.setChecked(p.isSelected());
// holder.chkBox.setTag(p);
// holder.edit.setEnabled(false);
// holder.id.setId(p.getId());
return row;
}
ArrayList<Planet> getBox() {
ArrayList<Planet> box = new ArrayList<Planet>();
for (Planet p : planetList) {
if (p.isSelected())
box.add(p);
}
return box;
}
}
> PLANET:
public class Planet {
private String name;
private String distance;
private String quantità;
private String valuta;
private String caratteristica;
private boolean selected = false;
//boolean mCheckBoxState;
public String getCaratteristica() {
return caratteristica;
}
public void setCaratteristica(String caratteristica) {
this.caratteristica = caratteristica;
}
public Planet(String name, String distance, String valuta,String caratteristica) {
super();
this.name = name;
this.distance = distance;
this.valuta = valuta;
this.caratteristica=caratteristica;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDistance() {
return distance;
}
public void setDistance(String distance) {
this.distance = distance;
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
public String getQuantità() {
return quantità;
}
public void setQuantità(String quantità) {
this.quantità = quantità;
}
public String getValuta() {
return valuta;
}
public void setValuta(String valuta) {
this.valuta = valuta;
}
}
| 0debug |
static inline uint32_t efsctui(uint32_t val)
{
CPU_FloatU u;
u.l = val;
if (unlikely(float32_is_nan(u.f)))
return 0;
return float32_to_uint32(u.f, &env->vec_status);
}
| 1threat |
What is the difference betwen @Input and @Output in Angular2 : <p>I am just learning Angular2 and I came across @Input and @Output. What is the difference between the two.</p>
| 0debug |
static QPCIDevice *start_ahci_device(QPCIDevice *ahci, void **hba_base)
{
*hba_base = qpci_iomap(ahci, 5, NULL);
qpci_device_enable(ahci);
return ahci;
}
| 1threat |
ES6 Singleton vs Instantiating a Class once : <p>I see patterns which make use of a singleton pattern using ES6 classes and I am wondering why I would use them as opposed to just instantiating the class at the bottom of the file and exporting the instance. Is there some kind of negative drawback to doing this? For example:</p>
<p><strong><em>ES6 Exporting Instance:</em></strong></p>
<pre><code>import Constants from '../constants';
class _API {
constructor() {
this.url = Constants.API_URL;
}
getCities() {
return fetch(this.url, { method: 'get' })
.then(response => response.json());
}
}
const API = new _API();
export default API;
</code></pre>
<p><strong>Usage:</strong></p>
<pre><code>import API from './services/api-service'
</code></pre>
<p>What is the difference from using the following Singleton pattern? Are there any reasons for using one from the other? Im actually more curious to know if the first example I gave can have issues that I am not aware of.</p>
<p><strong><em>Singleton Pattern:</em></strong></p>
<pre><code>import Constants from '../constants';
let instance = null;
class API {
constructor() {
if(!instance){
instance = this;
}
this.url = Constants.API_URL;
return instance;
}
getCities() {
return fetch(this.url, { method: 'get' })
.then(response => response.json());
}
}
export default API;
</code></pre>
<p><strong><em>Usage:</em></strong></p>
<pre><code>import API from './services/api-service';
let api = new API()
</code></pre>
| 0debug |
static uint64_t serial_ioport_read(void *opaque, hwaddr addr, unsigned size)
{
SerialState *s = opaque;
uint32_t ret;
addr &= 7;
switch(addr) {
default:
case 0:
if (s->lcr & UART_LCR_DLAB) {
ret = s->divider & 0xff;
} else {
if(s->fcr & UART_FCR_FE) {
ret = fifo8_is_full(&s->recv_fifo) ?
0 : fifo8_pop(&s->recv_fifo);
if (s->recv_fifo.num == 0) {
s->lsr &= ~(UART_LSR_DR | UART_LSR_BI);
} else {
qemu_mod_timer(s->fifo_timeout_timer, qemu_get_clock_ns (vm_clock) + s->char_transmit_time * 4);
}
s->timeout_ipending = 0;
} else {
ret = s->rbr;
s->lsr &= ~(UART_LSR_DR | UART_LSR_BI);
}
serial_update_irq(s);
if (!(s->mcr & UART_MCR_LOOP)) {
qemu_chr_accept_input(s->chr);
}
}
break;
case 1:
if (s->lcr & UART_LCR_DLAB) {
ret = (s->divider >> 8) & 0xff;
} else {
ret = s->ier;
}
break;
case 2:
ret = s->iir;
if ((ret & UART_IIR_ID) == UART_IIR_THRI) {
s->thr_ipending = 0;
serial_update_irq(s);
}
break;
case 3:
ret = s->lcr;
break;
case 4:
ret = s->mcr;
break;
case 5:
ret = s->lsr;
if (s->lsr & (UART_LSR_BI|UART_LSR_OE)) {
s->lsr &= ~(UART_LSR_BI|UART_LSR_OE);
serial_update_irq(s);
}
break;
case 6:
if (s->mcr & UART_MCR_LOOP) {
ret = (s->mcr & 0x0c) << 4;
ret |= (s->mcr & 0x02) << 3;
ret |= (s->mcr & 0x01) << 5;
} else {
if (s->poll_msl >= 0)
serial_update_msl(s);
ret = s->msr;
if (s->msr & UART_MSR_ANY_DELTA) {
s->msr &= 0xF0;
serial_update_irq(s);
}
}
break;
case 7:
ret = s->scr;
break;
}
DPRINTF("read addr=0x%" HWADDR_PRIx " val=0x%02x\n", addr, ret);
return ret;
}
| 1threat |
How to convert a csv file to parquet using Python : I'm new in BigData, and I don't know how to convert a csv file to Parquet format. I searched a lot, but couldn't find any good explication how to do it. Please, help me ! | 0debug |
#if #else #endif directives : <pre><code>#if DEBUG
e.Handled = false;
#else
ShowUnhandledException(e);
#endif
</code></pre>
<p>When trying to use the above directives the line after "if" appears as code and executes but the line after else remains grey and does not execute. The endif statement works. How to get the else directive to work as a line of code?</p>
<p>DEBUG define constant is ticked in setup!</p>
| 0debug |
static int vnc_refresh_server_surface(VncDisplay *vd)
{
int width = pixman_image_get_width(vd->guest.fb);
int height = pixman_image_get_height(vd->guest.fb);
int y;
uint8_t *guest_row;
uint8_t *server_row;
int cmp_bytes;
VncState *vs;
int has_dirty = 0;
pixman_image_t *tmpbuf = NULL;
struct timeval tv = { 0, 0 };
if (!vd->non_adaptive) {
gettimeofday(&tv, NULL);
has_dirty = vnc_update_stats(vd, &tv);
}
cmp_bytes = 64;
if (cmp_bytes > vnc_server_fb_stride(vd)) {
cmp_bytes = vnc_server_fb_stride(vd);
}
if (vd->guest.format != VNC_SERVER_FB_FORMAT) {
int width = pixman_image_get_width(vd->server);
tmpbuf = qemu_pixman_linebuf_create(VNC_SERVER_FB_FORMAT, width);
}
guest_row = (uint8_t *)pixman_image_get_data(vd->guest.fb);
server_row = (uint8_t *)pixman_image_get_data(vd->server);
for (y = 0; y < height; y++) {
if (!bitmap_empty(vd->guest.dirty[y], VNC_DIRTY_BITS)) {
int x;
uint8_t *guest_ptr;
uint8_t *server_ptr;
if (vd->guest.format != VNC_SERVER_FB_FORMAT) {
qemu_pixman_linebuf_fill(tmpbuf, vd->guest.fb, width, y);
guest_ptr = (uint8_t *)pixman_image_get_data(tmpbuf);
} else {
guest_ptr = guest_row;
}
server_ptr = server_row;
for (x = 0; x + 15 < width;
x += 16, guest_ptr += cmp_bytes, server_ptr += cmp_bytes) {
if (!test_and_clear_bit((x / 16), vd->guest.dirty[y]))
continue;
if (memcmp(server_ptr, guest_ptr, cmp_bytes) == 0)
continue;
memcpy(server_ptr, guest_ptr, cmp_bytes);
if (!vd->non_adaptive)
vnc_rect_updated(vd, x, y, &tv);
QTAILQ_FOREACH(vs, &vd->clients, next) {
set_bit((x / 16), vs->dirty[y]);
}
has_dirty++;
}
}
guest_row += pixman_image_get_stride(vd->guest.fb);
server_row += pixman_image_get_stride(vd->server);
}
qemu_pixman_image_unref(tmpbuf);
return has_dirty;
}
| 1threat |
relative import in pycharm 2018 does not work like relative import in python 3.6 : <p>I have read endless discussions on relative import in python, I think that one of the reasons it is so confusing is that it changes fro one Python version to another (my version is 3.6). But here the culprit seems to be PyCharm (unless i'm mistaken..) and i wonder if anyone came across a solution to this issue.
for a project with this layout:</p>
<pre><code>/project
|-- __init__.py
|---subfolder
|-- __init__.py
|-- AA.py
|-- BB.py
</code></pre>
<p>Let's imagine that AA.py contains some fuction <code>myfunc</code>
inside the file <code>BB.py</code> if i write this import:</p>
<pre><code>from AA import myfunc
</code></pre>
<p>Then python works <strong>perfectly</strong>, but PyCharm sees it as an error:
<a href="https://i.stack.imgur.com/U0RLU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/U0RLU.png" alt="enter image description here"></a></p>
<p>So to make PyCharm happy i can add the <code>.</code> to the import and then the error is seemingly resolved:</p>
<pre><code>from .AA import myfunc
</code></pre>
<p>But then python is not happy, giving me the error: <code>ModuleNotFoundError: No module named '__main__.AA'; '__main__' is not a package</code></p>
<p>So to conclude, I use the import that actually works (i.e. <code>from AA import myfunc</code>) but it would be great if i could make PyCharm agree to it somehow because then it offers features such as auto complete, go to definition and so on.</p>
<p><strong>not duplicates:</strong>
I know it seems like this subject was discussed over and over but it also has many aspects. Here i'm talking about the pycharm aspect and therefore this topic is new as far as i know.</p>
<ol>
<li><a href="https://stackoverflow.com/questions/23830917/how-does-pycharm-handle-relative-imports-of-modules">How does PyCharm handle relative imports of modules?</a> - is a user who didn't add the root project dir to PYTHONPATH</li>
<li><a href="https://stackoverflow.com/questions/48702550/pycharm-auto-relative-imports">Pycharm auto relative imports</a> - is talking about auto-import feature that is not the case here</li>
<li><a href="https://stackoverflow.com/questions/45954981/subpackages-and-relative-imports-in-pycharm">Subpackages and relative imports in PyCharm</a> - is talking about import issue in python 2.7 but in here i'm not having any issue to import</li>
<li><a href="https://stackoverflow.com/questions/14132789/relative-imports-for-the-billionth-time">Relative imports for the billionth time</a> - offeres a great review of importing issues and also features a very detailed answer - none of it helps in my case because i don't have any import issue. not to mention that it is python 2.7 topic and not 3.x</li>
</ol>
| 0debug |
static void *bsd_vmalloc(size_t size)
{
void *p;
mmap_lock();
p = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
if (h2g_valid(p)) {
abi_ulong addr = h2g(p);
page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + size),
PAGE_RESERVED);
}
mmap_unlock();
return p;
}
| 1threat |
static int cpu_mips_register (CPUMIPSState *env, const mips_def_t *def)
{
env->CP0_PRid = def->CP0_PRid;
env->CP0_Config0 = def->CP0_Config0;
#ifdef TARGET_WORDS_BIGENDIAN
env->CP0_Config0 |= (1 << CP0C0_BE);
#endif
env->CP0_Config1 = def->CP0_Config1;
env->CP0_Config2 = def->CP0_Config2;
env->CP0_Config3 = def->CP0_Config3;
env->CP0_Config6 = def->CP0_Config6;
env->CP0_Config7 = def->CP0_Config7;
env->SYNCI_Step = def->SYNCI_Step;
env->CCRes = def->CCRes;
env->CP0_Status_rw_bitmask = def->CP0_Status_rw_bitmask;
env->CP0_TCStatus_rw_bitmask = def->CP0_TCStatus_rw_bitmask;
env->CP0_SRSCtl = def->CP0_SRSCtl;
env->current_tc = 0;
env->SEGBITS = def->SEGBITS;
env->SEGMask = (target_ulong)((1ULL << def->SEGBITS) - 1);
#if defined(TARGET_MIPS64)
if (def->insn_flags & ISA_MIPS3) {
env->hflags |= MIPS_HFLAG_64;
env->SEGMask |= 3ULL << 62;
}
#endif
env->PABITS = def->PABITS;
env->PAMask = (target_ulong)((1ULL << def->PABITS) - 1);
env->CP0_SRSConf0_rw_bitmask = def->CP0_SRSConf0_rw_bitmask;
env->CP0_SRSConf0 = def->CP0_SRSConf0;
env->CP0_SRSConf1_rw_bitmask = def->CP0_SRSConf1_rw_bitmask;
env->CP0_SRSConf1 = def->CP0_SRSConf1;
env->CP0_SRSConf2_rw_bitmask = def->CP0_SRSConf2_rw_bitmask;
env->CP0_SRSConf2 = def->CP0_SRSConf2;
env->CP0_SRSConf3_rw_bitmask = def->CP0_SRSConf3_rw_bitmask;
env->CP0_SRSConf3 = def->CP0_SRSConf3;
env->CP0_SRSConf4_rw_bitmask = def->CP0_SRSConf4_rw_bitmask;
env->CP0_SRSConf4 = def->CP0_SRSConf4;
env->insn_flags = def->insn_flags;
#ifndef CONFIG_USER_ONLY
mmu_init(env, def);
#endif
fpu_init(env, def);
mvp_init(env, def);
return 0;
}
| 1threat |
static inline void RENAME(uyvytoyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
long width, long height,
long lumStride, long chromStride, long srcStride)
{
long y;
const long chromWidth= width>>1;
for(y=0; y<height; y+=2)
{
#ifdef HAVE_MMX
asm volatile(
"xorl %%eax, %%eax \n\t"
"pcmpeqw %%mm7, %%mm7 \n\t"
"psrlw $8, %%mm7 \n\t"
ASMALIGN16
"1: \n\t"
PREFETCH" 64(%0, %%eax, 4) \n\t"
"movq (%0, %%eax, 4), %%mm0 \n\t"
"movq 8(%0, %%eax, 4), %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
"pand %%mm7, %%mm0 \n\t"
"pand %%mm7, %%mm1 \n\t"
"psrlw $8, %%mm2 \n\t"
"psrlw $8, %%mm3 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"packuswb %%mm3, %%mm2 \n\t"
MOVNTQ" %%mm2, (%1, %%eax, 2) \n\t"
"movq 16(%0, %%eax, 4), %%mm1 \n\t"
"movq 24(%0, %%eax, 4), %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
"movq %%mm2, %%mm4 \n\t"
"pand %%mm7, %%mm1 \n\t"
"pand %%mm7, %%mm2 \n\t"
"psrlw $8, %%mm3 \n\t"
"psrlw $8, %%mm4 \n\t"
"packuswb %%mm2, %%mm1 \n\t"
"packuswb %%mm4, %%mm3 \n\t"
MOVNTQ" %%mm3, 8(%1, %%eax, 2) \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
"psrlw $8, %%mm0 \n\t"
"psrlw $8, %%mm1 \n\t"
"pand %%mm7, %%mm2 \n\t"
"pand %%mm7, %%mm3 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"packuswb %%mm3, %%mm2 \n\t"
MOVNTQ" %%mm0, (%3, %%eax) \n\t"
MOVNTQ" %%mm2, (%2, %%eax) \n\t"
"addl $8, %%eax \n\t"
"cmpl %4, %%eax \n\t"
" jb 1b \n\t"
::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (chromWidth)
: "memory", "%eax"
);
ydst += lumStride;
src += srcStride;
asm volatile(
"xorl %%eax, %%eax \n\t"
ASMALIGN16
"1: \n\t"
PREFETCH" 64(%0, %%eax, 4) \n\t"
"movq (%0, %%eax, 4), %%mm0 \n\t"
"movq 8(%0, %%eax, 4), %%mm1 \n\t"
"movq 16(%0, %%eax, 4), %%mm2 \n\t"
"movq 24(%0, %%eax, 4), %%mm3 \n\t"
"psrlw $8, %%mm0 \n\t"
"psrlw $8, %%mm1 \n\t"
"psrlw $8, %%mm2 \n\t"
"psrlw $8, %%mm3 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"packuswb %%mm3, %%mm2 \n\t"
MOVNTQ" %%mm0, (%1, %%eax, 2) \n\t"
MOVNTQ" %%mm2, 8(%1, %%eax, 2) \n\t"
"addl $8, %%eax \n\t"
"cmpl %4, %%eax \n\t"
" jb 1b \n\t"
::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (chromWidth)
: "memory", "%eax"
);
#else
long i;
for(i=0; i<chromWidth; i++)
{
udst[i] = src[4*i+0];
ydst[2*i+0] = src[4*i+1];
vdst[i] = src[4*i+2];
ydst[2*i+1] = src[4*i+3];
}
ydst += lumStride;
src += srcStride;
for(i=0; i<chromWidth; i++)
{
ydst[2*i+0] = src[4*i+1];
ydst[2*i+1] = src[4*i+3];
}
#endif
udst += chromStride;
vdst += chromStride;
ydst += lumStride;
src += srcStride;
}
#ifdef HAVE_MMX
asm volatile( EMMS" \n\t"
SFENCE" \n\t"
:::"memory");
#endif
}
| 1threat |
Sorting multiple strings into an order : <p>I need an help on my php code</p>
<p>I got string array. It contains multiple values inside. Such as 'XXL', 'X', '1', '1.5','2', '3', 'T', '1K','1.5K','5K','Adult','One Size'.</p>
<p>Now I want it to be sorted as follows.
2T, 3T, 4T, YXXS, YXS, YS, YM, YL, YXL, XXS, XS, S, M, L, XL, XXL, XXXL, WXXS, WXS, WS, WM, WL, WXL, WXXL, Youth, Adult, One Size, 8K, 8.5K, 9K, 9.5K, 10K, 10.5K, 11K, 11.5K 12K, 12.5K, 13K, 13.5K, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.5, 13, 13.5, 14, 14.5, 15, Futsal</p>
<p>I need a sorting function or an algorithm to fix this issue</p>
| 0debug |
BASH -- grep'ing for perl-regex : <p>Beginner here and I'm trying to understand this. Can someone please break down the part in between the single quotes and describe what it does?</p>
<pre><code>grep -oP '(?<=\S\/1\.\d.\s)[345]\d+'
</code></pre>
<p>Many thanks in advance!</p>
| 0debug |
Hello!!! I am trying to convert an apk file to zip file. i have watched videos on youtube but its not working : At first, I have choose an apk named as bdteam. I tried utmost to find the source code. But i can not convert apk file to zip file. How can I solve my problem?
| 0debug |
Java. How to check that the string contains (if) only allowed html tags? : Allowed tags are stored in the list. I need a simple validation method that returns false if the test string contains *any* "not allowed tags". | 0debug |
rock paper cizor java method : I'm fairly new at coding. I've been exercising, trying out a Rock-Paper-Cizor java code.
Although, i'm blocked and i can't figure out why i have so many error within my method, and why each of my int k is wrong.
I know there's probably an easier way to code this but keep in mind i'm new at all this ;)
Thanks :)
import java.util.Scanner;
import java.util.Random;
public class chifoumi {
public static void main(String[] args) {
System.out.println("Bienvenu à CHIFOUMI...");
Scanner sc = new Scanner(System.in);
System.out.println("Pierre, feuille, ciseaux?");
System.out.println("Tape 0, 1 où 2"); // 0 : Pierre
int joueur = sc.nextInt(); // 1 : Feuille
// 2 : Ciseaux
int V = jeu(joueur);
if (V == 1)
System.out.println("Vous avez gagné !");
else
if (V == 0)
System.out.println("Vous avez perdu... ");
else
if (V == 2)
System.out.println("Egalité ! Recommencez ;)");
}
public static int jeu(int x){
Random random = new Random();
int ordi;
ordi = random.nextInt(3);
if (x == 0 || ordi == 1)
int k = 0;
return k;
if (x == 0 || ordi == 2)
int k = 1;
return k;
if (x == 1 || ordi == 0)
int k = 1;
return k;
if (x == 1 || ordi == 2)
int k = 0;
return k;
if (x == 2 || ordi == 0)
int k = 0;
return k;
if (x == 2 || ordi == 1)
int k = 1;
return k;
if (ordi == x)
int k =2;
return k;
}
}
Apparently, within my method, all of my int k = ... are wrong... can't figure out why
| 0debug |
How do I set the value of a key in on array as the key in an other array : I am trying to get the value("feature_1") of a key("name") from the array("data") and set the value of that key as the key to another array("asset") which has an array as value. Is that possible ?
Example :
```
//input:
data: {
name: "feature_1",
value_a: 1,
value_b: 2
}
//Output:
asset: {
feature_1:[{1},{2}]
}
| 0debug |
i have error regarding the addition of select or dropdown with options inside the php $output . Here is the code: : Please help me with this code.. I have to give an dropdown . now when i select a dropdown and submit it in my db the entire text that is : "Open this select menu
One
Two
Three" is coming. i only want the text which i select from dropdown
Ive tried many solutions from stack overflow related to this but everything doesnt work for me. please help me with this specefic code. iam just a begineer in php.
```
$rows = mysqli_num_rows($result);
if($rows > 0)
{
if($rows > 10)
{
$delete_records = $rows - 10;
$delete_sql = "DELETE FROM tbl_sample LIMIT $delete_records";
mysqli_query($connect, $delete_sql);
}
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td class="first_name" data-id1="'.$row["id"].'" contenteditable>'.$row["first_name"].'</td>
<td class="last_name" data-id2="'.$row["id"].'" contenteditable>'.$row["last_name"].'</td>
<td><button type="button" name="delete_btn" data-id3="'.$row["id"].'" class="btn btn-xs btn-danger btn_delete">x</button></td>
</tr>
';
}
//Main code here... //
$output .= '
<tr>
<td id="first_name" contenteditable>
<select class="custom-select" multiple>
<option selected>Open this select menu</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
</td>
<td id="last_name" contenteditable></td>
<td><button type="button" name="btn_add" id="btn_add" class="btn btn-xs btn-success">+</button></td>
</tr>
';
}
else
{
$output .= '
<tr>
<td id="first_name" contenteditable></td>
<td id="last_name" contenteditable></td>
<td><button type="button" name="btn_add" id="btn_add" class="btn btn-xs btn-success">+</button></td>
</tr>';
}
$output .= '</table>
</div>';
echo $output;
?> ``` | 0debug |
javascript - parse string and store it in differents variables : my problem is the next one :
I have a string with a special character that 'separates' the string in different parts.
var str = "this could be part 1 -- this is part 2 -- here is part3";
Here i chose '--' as special group of characters to delimit the parts.
And i would like from this string to be able to be able to separate these parts and put one of each in an array and get this result :
this could be part 1 , this is part 2 , here is part3
What is the better way to do this ?
Thank you in advance for your answer
| 0debug |
static uint32_t timer_int_route(struct HPETTimer *timer)
{
uint32_t route;
route = (timer->config & HPET_TN_INT_ROUTE_MASK) >> HPET_TN_INT_ROUTE_SHIFT;
return route;
}
| 1threat |
How to obtain part of the url with php : <p>I am coming up with a way to display user profiles. Right now I am able to insert the user_id into the url when going to a user's profile, but I am unsure of how to get the user_id from the url.</p>
<p>So at the end of the url I have this:</p>
<p>profile?user=41</p>
<p>I just want to be able to get the 41 (please note this number will change per profile) and then set it to a variable.</p>
<p>How would I do this?</p>
| 0debug |
get size of collection in nested hashmap? : <p>I have data structure of type <code>Map<String, Map <String, List<ExciseReportDataPoint>>> Data</code> I would like to calculate number of entries in <code>List<ExciseReportDataPoint></code> for each top level key.</p>
<p>We can think about the hashmap in logical manner as <code>Map<LiquorCategory, Map<LiquorBrand, List<LiquorBottles>>></code>. Basically I want to know how many liquor bottles for each LiquorCategory.</p>
| 0debug |
How to change DBeaver timezone / How to stop DBeaver from converting date and time : <p>When I use DBeaver with Cassandra, it shows an offset of +01:00 even though the data is stored in Date or Times formats, that don't have any timezones. This results in some weird queries like this: </p>
<pre><code>SELECT "Time"
FROM keyspace."Table"
ORDER BY "Time" DESC;
Time
00:00:00
23:00:00
22:00:00
...
01:00:00
</code></pre>
<p>So, how do I remove the conversions or do I set the timezone to UTC?</p>
| 0debug |
Bash trap on exit from function : <p>Is there possible in bash to call some command when function exits. I mean something like:</p>
<pre><code>function foo
{
# something like this maybe?
trap "echo \"exit function foo\"" EXIT
# do something
}
foo
</code></pre>
<p>And i want exit function foo to be printed out.</p>
| 0debug |
def big_sum(nums):
sum= max(nums)+min(nums)
return sum | 0debug |
Please how do i get the final Url from a link in Java : This is a link generated from Google Alerts, and i would like to get the real url of the site with Java. I have checked for the response but no location header redirect.
https://www.google.com/url?rct=j&sa=t&url=http://naija247news.com/2016/03/nigerian-bond-yields-rise-after-cbns-interest-rate-hike-aimed-at-luring-investors/&ct=ga&cd=CAIyGjA3ZmJiYzk0ZDM0N2U2MjU6Y29tOmVuOlVT&usg=AFQjCNGs7HsYSodEUnECfdAatG6KgY18DA | 0debug |
static void guest_suspend(const char *pmutils_bin, const char *sysfile_str,
Error **err)
{
pid_t pid;
char *pmutils_path;
pmutils_path = g_find_program_in_path(pmutils_bin);
pid = fork();
if (pid == 0) {
int fd;
setsid();
reopen_fd_to_null(0);
reopen_fd_to_null(1);
reopen_fd_to_null(2);
if (pmutils_path) {
execle(pmutils_path, pmutils_bin, NULL, environ);
}
if (!sysfile_str) {
_exit(EXIT_FAILURE);
}
fd = open(LINUX_SYS_STATE_FILE, O_WRONLY);
if (fd < 0) {
_exit(EXIT_FAILURE);
}
if (write(fd, sysfile_str, strlen(sysfile_str)) < 0) {
_exit(EXIT_FAILURE);
}
_exit(EXIT_SUCCESS);
}
g_free(pmutils_path);
if (pid < 0) {
error_set(err, QERR_UNDEFINED_ERROR);
return;
}
}
| 1threat |
Loading ASP.Net Core authorization policy from database : <p>In ASP.Net Core we defined authorization policy in ConfigureServices method as below.</p>
<pre><code>public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddAuthorization(options =>
{
options.AddPolicy("Founders", policy =>
policy.RequireClaim ("EmployeeNumber", "1", "2", "3", "4", "5"));
}
}
</code></pre>
<p>and we use it on controller action as below.</p>
<pre><code>[Authorize("Founders")]
public IActionResult GenerateReport()
{
return View();
}
</code></pre>
<p>This is all fine and works perfectly. Now my question is, instead of defining "Founders" policy in code (using AddPolicy method in above snippet) how can I add policy details (name,claimtype, value) from database? Is there any hook provided in framework which I can use to populate policies from database?</p>
<p>Idea here is I should be able to add new Employee numbers to list (in database) and policy should be evaluated against that list. Obliviously I can pull this list from database in ConfigureServices itself however any new addition to employee list will not be picked up until application is restarted. Any pointers around this highly appreciated. </p>
| 0debug |
void do_interrupt(CPUARMState *env)
{
uint32_t addr;
uint32_t mask;
int new_mode;
uint32_t offset;
if (IS_M(env)) {
do_interrupt_v7m(env);
return;
}
switch (env->exception_index) {
case EXCP_UDEF:
new_mode = ARM_CPU_MODE_UND;
addr = 0x04;
mask = CPSR_I;
if (env->thumb)
offset = 2;
else
offset = 4;
break;
case EXCP_SWI:
if (semihosting_enabled) {
if (env->thumb) {
mask = lduw_code(env->regs[15] - 2) & 0xff;
} else {
mask = ldl_code(env->regs[15] - 4) & 0xffffff;
}
if (((mask == 0x123456 && !env->thumb)
|| (mask == 0xab && env->thumb))
&& (env->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {
env->regs[0] = do_arm_semihosting(env);
return;
}
}
new_mode = ARM_CPU_MODE_SVC;
addr = 0x08;
mask = CPSR_I;
offset = 0;
break;
case EXCP_BKPT:
if (env->thumb && semihosting_enabled) {
mask = lduw_code(env->regs[15]) & 0xff;
if (mask == 0xab
&& (env->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR) {
env->regs[15] += 2;
env->regs[0] = do_arm_semihosting(env);
return;
}
}
case EXCP_PREFETCH_ABORT:
new_mode = ARM_CPU_MODE_ABT;
addr = 0x0c;
mask = CPSR_A | CPSR_I;
offset = 4;
break;
case EXCP_DATA_ABORT:
new_mode = ARM_CPU_MODE_ABT;
addr = 0x10;
mask = CPSR_A | CPSR_I;
offset = 8;
break;
case EXCP_IRQ:
new_mode = ARM_CPU_MODE_IRQ;
addr = 0x18;
mask = CPSR_A | CPSR_I;
offset = 4;
break;
case EXCP_FIQ:
new_mode = ARM_CPU_MODE_FIQ;
addr = 0x1c;
mask = CPSR_A | CPSR_I | CPSR_F;
offset = 4;
break;
default:
cpu_abort(env, "Unhandled exception 0x%x\n", env->exception_index);
return;
}
if (env->cp15.c1_sys & (1 << 13)) {
addr += 0xffff0000;
}
switch_mode (env, new_mode);
env->spsr = cpsr_read(env);
env->condexec_bits = 0;
env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M) | new_mode;
env->uncached_cpsr |= mask;
env->thumb = (env->cp15.c1_sys & (1 << 30)) != 0;
env->regs[14] = env->regs[15] + offset;
env->regs[15] = addr;
env->interrupt_request |= CPU_INTERRUPT_EXITTB;
}
| 1threat |
How to delete multiple objects from an array? -- Javascript - Angular : How to delete multiple objects from an array?
currently I have
let arry1 = [ {
id:0,
name:'My App',
another:'thing',
},{
id:1,
name:'My New App',
another:'things'
},{
id:2,
name:'My New App',
another:'things'
},
];
Then I have an indexes array like this
let arry2 = [ 1, 2 ]; // Indexes to delete
finally the result has to be...
let arry1 = [ {
id:0,
name:'My App',
another:'thing',
}]
| 0debug |
static int s390x_write_all_elf64_notes(const char *note_name,
WriteCoreDumpFunction f,
S390CPU *cpu, int id,
void *opaque)
{
Note note;
const NoteFuncDesc *nf;
int note_size;
int ret = -1;
for (nf = note_func; nf->note_contents_func; nf++) {
memset(¬e, 0, sizeof(note));
note.hdr.n_namesz = cpu_to_be32(sizeof(note.name));
note.hdr.n_descsz = cpu_to_be32(nf->contents_size);
strncpy(note.name, note_name, sizeof(note.name));
(*nf->note_contents_func)(¬e, cpu);
note_size = sizeof(note) - sizeof(note.contents) + nf->contents_size;
ret = f(¬e, note_size, opaque);
if (ret < 0) {
return -1;
}
}
return 0;
}
| 1threat |
const char *path(const char *name)
{
if (!base || name[0] != '/')
return name;
return follow_path(base, name) ?: name;
}
| 1threat |
static av_cold int vp3_decode_init(AVCodecContext *avctx)
{
Vp3DecodeContext *s = avctx->priv_data;
int i, inter, plane;
int c_width;
int c_height;
int y_fragment_count, c_fragment_count;
if (avctx->codec_tag == MKTAG('V','P','3','0'))
s->version = 0;
else
s->version = 1;
s->avctx = avctx;
s->width = FFALIGN(avctx->width, 16);
s->height = FFALIGN(avctx->height, 16);
if (avctx->pix_fmt == PIX_FMT_NONE)
avctx->pix_fmt = PIX_FMT_YUV420P;
avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
if(avctx->idct_algo==FF_IDCT_AUTO)
avctx->idct_algo=FF_IDCT_VP3;
ff_dsputil_init(&s->dsp, avctx);
ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);
for (i = 0; i < 3; i++)
s->qps[i] = -1;
avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_x_shift, &s->chroma_y_shift);
s->y_superblock_width = (s->width + 31) / 32;
s->y_superblock_height = (s->height + 31) / 32;
s->y_superblock_count = s->y_superblock_width * s->y_superblock_height;
c_width = s->width >> s->chroma_x_shift;
c_height = s->height >> s->chroma_y_shift;
s->c_superblock_width = (c_width + 31) / 32;
s->c_superblock_height = (c_height + 31) / 32;
s->c_superblock_count = s->c_superblock_width * s->c_superblock_height;
s->superblock_count = s->y_superblock_count + (s->c_superblock_count * 2);
s->u_superblock_start = s->y_superblock_count;
s->v_superblock_start = s->u_superblock_start + s->c_superblock_count;
s->macroblock_width = (s->width + 15) / 16;
s->macroblock_height = (s->height + 15) / 16;
s->macroblock_count = s->macroblock_width * s->macroblock_height;
s->fragment_width[0] = s->width / FRAGMENT_PIXELS;
s->fragment_height[0] = s->height / FRAGMENT_PIXELS;
s->fragment_width[1] = s->fragment_width[0] >> s->chroma_x_shift;
s->fragment_height[1] = s->fragment_height[0] >> s->chroma_y_shift;
y_fragment_count = s->fragment_width[0] * s->fragment_height[0];
c_fragment_count = s->fragment_width[1] * s->fragment_height[1];
s->fragment_count = y_fragment_count + 2*c_fragment_count;
s->fragment_start[1] = y_fragment_count;
s->fragment_start[2] = y_fragment_count + c_fragment_count;
if (!s->theora_tables)
{
for (i = 0; i < 64; i++) {
s->coded_dc_scale_factor[i] = vp31_dc_scale_factor[i];
s->coded_ac_scale_factor[i] = vp31_ac_scale_factor[i];
s->base_matrix[0][i] = vp31_intra_y_dequant[i];
s->base_matrix[1][i] = vp31_intra_c_dequant[i];
s->base_matrix[2][i] = vp31_inter_dequant[i];
s->filter_limit_values[i] = vp31_filter_limit_values[i];
}
for(inter=0; inter<2; inter++){
for(plane=0; plane<3; plane++){
s->qr_count[inter][plane]= 1;
s->qr_size [inter][plane][0]= 63;
s->qr_base [inter][plane][0]=
s->qr_base [inter][plane][1]= 2*inter + (!!plane)*!inter;
}
}
for (i = 0; i < 16; i++) {
init_vlc(&s->dc_vlc[i], 11, 32,
&dc_bias[i][0][1], 4, 2,
&dc_bias[i][0][0], 4, 2, 0);
init_vlc(&s->ac_vlc_1[i], 11, 32,
&ac_bias_0[i][0][1], 4, 2,
&ac_bias_0[i][0][0], 4, 2, 0);
init_vlc(&s->ac_vlc_2[i], 11, 32,
&ac_bias_1[i][0][1], 4, 2,
&ac_bias_1[i][0][0], 4, 2, 0);
init_vlc(&s->ac_vlc_3[i], 11, 32,
&ac_bias_2[i][0][1], 4, 2,
&ac_bias_2[i][0][0], 4, 2, 0);
init_vlc(&s->ac_vlc_4[i], 11, 32,
&ac_bias_3[i][0][1], 4, 2,
&ac_bias_3[i][0][0], 4, 2, 0);
}
} else {
for (i = 0; i < 16; i++) {
if (init_vlc(&s->dc_vlc[i], 11, 32,
&s->huffman_table[i][0][1], 8, 4,
&s->huffman_table[i][0][0], 8, 4, 0) < 0)
goto vlc_fail;
if (init_vlc(&s->ac_vlc_1[i], 11, 32,
&s->huffman_table[i+16][0][1], 8, 4,
&s->huffman_table[i+16][0][0], 8, 4, 0) < 0)
goto vlc_fail;
if (init_vlc(&s->ac_vlc_2[i], 11, 32,
&s->huffman_table[i+16*2][0][1], 8, 4,
&s->huffman_table[i+16*2][0][0], 8, 4, 0) < 0)
goto vlc_fail;
if (init_vlc(&s->ac_vlc_3[i], 11, 32,
&s->huffman_table[i+16*3][0][1], 8, 4,
&s->huffman_table[i+16*3][0][0], 8, 4, 0) < 0)
goto vlc_fail;
if (init_vlc(&s->ac_vlc_4[i], 11, 32,
&s->huffman_table[i+16*4][0][1], 8, 4,
&s->huffman_table[i+16*4][0][0], 8, 4, 0) < 0)
goto vlc_fail;
}
}
init_vlc(&s->superblock_run_length_vlc, 6, 34,
&superblock_run_length_vlc_table[0][1], 4, 2,
&superblock_run_length_vlc_table[0][0], 4, 2, 0);
init_vlc(&s->fragment_run_length_vlc, 5, 30,
&fragment_run_length_vlc_table[0][1], 4, 2,
&fragment_run_length_vlc_table[0][0], 4, 2, 0);
init_vlc(&s->mode_code_vlc, 3, 8,
&mode_code_vlc_table[0][1], 2, 1,
&mode_code_vlc_table[0][0], 2, 1, 0);
init_vlc(&s->motion_vector_vlc, 6, 63,
&motion_vector_vlc_table[0][1], 2, 1,
&motion_vector_vlc_table[0][0], 2, 1, 0);
for (i = 0; i < 3; i++) {
s->current_frame.data[i] = NULL;
s->last_frame.data[i] = NULL;
s->golden_frame.data[i] = NULL;
}
return allocate_tables(avctx);
vlc_fail:
av_log(avctx, AV_LOG_FATAL, "Invalid huffman table\n");
return -1;
}
| 1threat |
uint64_t helper_fctid(CPUPPCState *env, uint64_t arg)
{
CPU_DoubleU farg;
farg.ll = arg;
if (unlikely(float64_is_signaling_nan(farg.d))) {
farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN |
POWERPC_EXCP_FP_VXCVI);
} else if (unlikely(float64_is_quiet_nan(farg.d) ||
float64_is_infinity(farg.d))) {
farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXCVI);
} else {
farg.ll = float64_to_int64(farg.d, &env->fp_status);
}
return farg.ll;
}
| 1threat |
def find_lists(Input):
if isinstance(Input, list):
return 1
else:
return len(Input) | 0debug |
How to break up string into multiple on newline character? : <p>I have the details of an amazon order, the literal string is separated by the newline character \n. </p>
<pre class="lang-py prettyprint-override"><code>str = 'Linon Hampton Stool Fabric Top, 24-inch \nSold by: Amazon.com Services, Inc \n$33.99'
</code></pre>
<p>I want to split it up into n number of strings for each new line so that it looks like.</p>
<pre class="lang-py prettyprint-override"><code>str1 = 'Linon Hampton Stool Fabric Top, 24-inch'
str2 = 'Sold by: Amazon.com Services, Inc '
str3 = '$33.99'
</code></pre>
| 0debug |
Unable to find string in list : <p>While I need to test a condition whether some strings are existing in the list or not, I'm getting always same answer. </p>
<p>Like in below list I need to check for string "Inactive" or "Dead", if found print something. </p>
<pre><code>list = [u'\u25cf multi-user.target - Multi-User System\n', u' Loaded: loaded (/lib/systemd/system/multi-user .target; static; vendor preset: enabled)\n', u' Active: active since Mon 2017-02-20 20:58:28 HKT; 1h 20min ago\n ', u' Docs: man:systemd.special(7)\n', u'\n', u'Feb 20 20:58:28 ubuntu systemd[1]: Reached target Multi-User S ystem.\n']
</code></pre>
<p><strong>Code:</strong> </p>
<pre><code>if 'Inactive' or 'Dead' in list:
print "Service not active"
</code></pre>
<p>Tried pouring the output to a file, variable etc, but nothing seemed to work. Have already gone through solutions over the web but no luck. Please help. </p>
| 0debug |
int ff_mjpeg_decode_sos(MJpegDecodeContext *s,
const uint8_t *mb_bitmask, const AVFrame *reference)
{
int len, nb_components, i, h, v, predictor, point_transform;
int index, id;
const int block_size= s->lossless ? 1 : 8;
int ilv, prev_shift;
len = get_bits(&s->gb, 16);
nb_components = get_bits(&s->gb, 8);
if (nb_components == 0 || nb_components > MAX_COMPONENTS){
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: nb_components (%d) unsupported\n", nb_components);
return -1;
}
if (len != 6+2*nb_components)
{
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: invalid len (%d)\n", len);
return -1;
}
for(i=0;i<nb_components;i++) {
id = get_bits(&s->gb, 8) - 1;
av_log(s->avctx, AV_LOG_DEBUG, "component: %d\n", id);
for(index=0;index<s->nb_components;index++)
if (id == s->component_id[index])
break;
if (index == s->nb_components)
{
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: index(%d) out of components\n", index);
return -1;
}
if (s->avctx->codec_tag == MKTAG('M', 'T', 'S', 'J')
&& nb_components == 3 && s->nb_components == 3 && i)
index = 3 - i;
if(nb_components == 3 && s->nb_components == 3 && s->avctx->pix_fmt == PIX_FMT_GBR24P)
index = (i+2)%3;
s->comp_index[i] = index;
s->nb_blocks[i] = s->h_count[index] * s->v_count[index];
s->h_scount[i] = s->h_count[index];
s->v_scount[i] = s->v_count[index];
s->dc_index[i] = get_bits(&s->gb, 4);
s->ac_index[i] = get_bits(&s->gb, 4);
if (s->dc_index[i] < 0 || s->ac_index[i] < 0 ||
s->dc_index[i] >= 4 || s->ac_index[i] >= 4)
goto out_of_range;
if (!s->vlcs[0][s->dc_index[i]].table || !s->vlcs[1][s->ac_index[i]].table)
goto out_of_range;
}
predictor= get_bits(&s->gb, 8);
ilv= get_bits(&s->gb, 8);
if(s->avctx->codec_tag != AV_RL32("CJPG")){
prev_shift = get_bits(&s->gb, 4);
point_transform= get_bits(&s->gb, 4);
}else
prev_shift= point_transform= 0;
for(i=0;i<nb_components;i++)
s->last_dc[i] = 1024;
if (nb_components > 1) {
s->mb_width = (s->width + s->h_max * block_size - 1) / (s->h_max * block_size);
s->mb_height = (s->height + s->v_max * block_size - 1) / (s->v_max * block_size);
} else if(!s->ls) {
h = s->h_max / s->h_scount[0];
v = s->v_max / s->v_scount[0];
s->mb_width = (s->width + h * block_size - 1) / (h * block_size);
s->mb_height = (s->height + v * block_size - 1) / (v * block_size);
s->nb_blocks[0] = 1;
s->h_scount[0] = 1;
s->v_scount[0] = 1;
}
if(s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_DEBUG, "%s %s p:%d >>:%d ilv:%d bits:%d skip:%d %s comp:%d\n", s->lossless ? "lossless" : "sequential DCT", s->rgb ? "RGB" : "",
predictor, point_transform, ilv, s->bits, s->mjpb_skiptosod,
s->pegasus_rct ? "PRCT" : (s->rct ? "RCT" : ""), nb_components);
for (i = s->mjpb_skiptosod; i > 0; i--)
skip_bits(&s->gb, 8);
if(s->lossless){
av_assert0(s->picture_ptr == &s->picture);
if(CONFIG_JPEGLS_DECODER && s->ls){
if(ff_jpegls_decode_picture(s, predictor, point_transform, ilv) < 0)
return -1;
}else{
if(s->rgb){
if(ljpeg_decode_rgb_scan(s, nb_components, predictor, point_transform) < 0)
return -1;
}else{
if(ljpeg_decode_yuv_scan(s, predictor, point_transform) < 0)
return -1;
}
}
}else{
if(s->progressive && predictor) {
av_assert0(s->picture_ptr == &s->picture);
if(mjpeg_decode_scan_progressive_ac(s, predictor, ilv, prev_shift, point_transform) < 0)
return -1;
} else {
if(mjpeg_decode_scan(s, nb_components, prev_shift, point_transform,
mb_bitmask, reference) < 0)
return -1;
}
}
if (s->yuv421) {
uint8_t *line = s->picture_ptr->data[2];
for (i = 0; i < s->height / 2; i++) {
for (index = s->width - 1; index; index--)
line[index] = (line[index / 2] + line[(index + 1) / 2]) >> 1;
line += s->linesize[2];
}
} else if (s->yuv442) {
uint8_t *dst = &((uint8_t *)s->picture_ptr->data[2])[(s->height - 1) * s->linesize[2]];
for (i = s->height - 1; i; i--) {
uint8_t *src1 = &((uint8_t *)s->picture_ptr->data[2])[i / 2 * s->linesize[2]];
uint8_t *src2 = &((uint8_t *)s->picture_ptr->data[2])[(i + 1) / 2 * s->linesize[2]];
if (src1 == src2) {
memcpy(dst, src1, s->width);
} else {
for (index = 0; index < s->width; index++)
dst[index] = (src1[index] + src2[index]) >> 1;
}
dst -= s->linesize[2];
}
}
emms_c();
return 0;
out_of_range:
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: ac/dc index out of range\n");
return -1;
}
| 1threat |
How I Can Keybind a Button? : I Need help to keybind this button, Wich mainly got this function:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Toggle = Toggle + 1
If Toggle = 1 Then
Timer1.Start()
Button1.Text = "Toggle Off"
Else
Timer1.Stop()
Toggle = 0
Button1.Text = "Toggle On"
End If
| 0debug |
onclick javascript regrex required on the click of a button : I am looking for the regrex when i click on the button it should be able to perform "Pay Later" action, currently when this button is clicked it display the values in form of parameter to jmeter along with the post.Where i am able to fetch different id by manually adding through csv data but i need a regex for randomly performing the action
For example
<button id="carFlyOutBtn" class="carFlyOutBtn" onclick="javascript:setPayType('0','0',2,1); Analytics.trackEvent('Car Selection','Pay Later',$('#costco_page_name').val());">Pay Later</button>
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/7FPxh.png | 0debug |
Select only inline code blocks : <p>I need to select every inline code blocks (not multilane)</p>
<p>Here is text <a href="https://regex101.com/r/8e7nPL/7" rel="nofollow noreferrer">https://regex101.com/r/8e7nPL/7</a></p>
<p>Example of inline blocks that I need to extract: <code>f.call();</code>, <code>yield()</code>, <code>Fiber</code></p>
| 0debug |
How to Write an or statement with Int : i have tried to run it multiple ways, but the dialog box comes up even if one is selected. How do i get the dialog box to come up if only one of the buttons is not selected?
if (!shapesButtons[0].isSelected())
{
JOptionPane.showMessageDialog(null,"Please select one of the Buttons ");
}
else if (!shapesButtons[1].isSelected())
{
JOptionPane.showMessageDialog(null,"Please select one of the Buttons ");
}
else
{
return;
} | 0debug |
static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize, int64_t pts)
{
MBContext *mb = ctx->priv;
int x,y,i, in_cidx=0, next_cidx=0, tmp_cidx;
double scale= mb->start_scale*pow(mb->end_scale/mb->start_scale, pts/mb->end_pts);
int use_zyklus=0;
fill_from_cache(ctx, NULL, &in_cidx, NULL, mb->start_y+scale*(-mb->h/2-0.5), scale);
for(y=0; y<mb->h; y++){
const double ci=mb->start_y+scale*(y-mb->h/2);
memset(color+linesize*y, 0, sizeof(*color)*mb->w);
fill_from_cache(ctx, color+linesize*y, &in_cidx, &next_cidx, ci, scale);
tmp_cidx= in_cidx;
fill_from_cache(ctx, color+linesize*y, &tmp_cidx, NULL, ci + scale/2, scale);
for(x=0; x<mb->w; x++){
const double cr=mb->start_x+scale*(x-mb->w/2);
double zr=cr;
double zi=ci;
uint32_t c=0;
double dv= mb->dither / (double)(1LL<<32);
mb->dither= mb->dither*1664525+1013904223;
if(color[x + y*linesize] & 0xFF000000)
continue;
use_zyklus= (x==0 || mb->inner!=BLACK ||color[x-1 + y*linesize] == 0xFF000000);
#define Z_Z2_C(outr,outi,inr,ini)\
outr= inr*inr - ini*ini + cr;\
outi= 2*inr*ini + ci;
#define Z_Z2_C_ZYKLUS(outr,outi,inr,ini, Z)\
Z_Z2_C(outr,outi,inr,ini)\
if(use_zyklus){\
if(Z && mb->zyklus[i>>1][0]==outr && mb->zyklus[i>>1][1]==outi)\
break;\
mb->zyklus[i][0]= outr;\
mb->zyklus[i][1]= outi;\
}
for(i=0; i<mb->maxiter-8; i++){
double t;
Z_Z2_C_ZYKLUS(t, zi, zr, zi, 0)
i++;
Z_Z2_C_ZYKLUS(zr, zi, t, zi, 1)
i++;
Z_Z2_C_ZYKLUS(t, zi, zr, zi, 0)
i++;
Z_Z2_C_ZYKLUS(zr, zi, t, zi, 1)
i++;
Z_Z2_C_ZYKLUS(t, zi, zr, zi, 0)
i++;
Z_Z2_C_ZYKLUS(zr, zi, t, zi, 1)
i++;
Z_Z2_C_ZYKLUS(t, zi, zr, zi, 0)
i++;
Z_Z2_C_ZYKLUS(zr, zi, t, zi, 1)
if(zr*zr + zi*zi > mb->bailout){
i-= FFMIN(7, i);
for(; i<mb->maxiter; i++){
zr= mb->zyklus[i][0];
zi= mb->zyklus[i][1];
if(zr*zr + zi*zi > mb->bailout){
switch(mb->outer){
case ITERATION_COUNT: zr = i; break;
case NORMALIZED_ITERATION_COUNT: zr= i + log2(log(mb->bailout) / log(zr*zr + zi*zi)); break;
}
c= lrintf((sin(zr)+1)*127) + lrintf((sin(zr/1.234)+1)*127)*256*256 + lrintf((sin(zr/100)+1)*127)*256;
break;
}
}
break;
}
}
if(!c){
if(mb->inner==PERIOD){
int j;
for(j=i-1; j; j--)
if(SQR(mb->zyklus[j][0]-zr) + SQR(mb->zyklus[j][1]-zi) < 0.0000000000000001)
break;
if(j){
c= i-j;
c= ((c<<5)&0xE0) + ((c<<16)&0xE000) + ((c<<27)&0xE00000);
}
}else if(mb->inner==CONVTIME){
c= floor(i*255.0/mb->maxiter+dv)*0x010101;
} else if(mb->inner==MINCOL){
int j;
double closest=9999;
int closest_index=0;
for(j=i-1; j>=0; j--)
if(SQR(mb->zyklus[j][0]) + SQR(mb->zyklus[j][1]) < closest){
closest= SQR(mb->zyklus[j][0]) + SQR(mb->zyklus[j][1]);
closest_index= j;
}
closest = sqrt(closest);
c= lrintf((mb->zyklus[closest_index][0]/closest+1)*127+dv) + lrintf((mb->zyklus[closest_index][1]/closest+1)*127+dv)*256;
}
}
c |= 0xFF000000;
color[x + y*linesize]= c;
if(next_cidx < mb->cache_allocated){
mb->next_cache[next_cidx ].p[0]= cr;
mb->next_cache[next_cidx ].p[1]= ci;
mb->next_cache[next_cidx++].val = c;
}
}
fill_from_cache(ctx, NULL, &in_cidx, &next_cidx, ci + scale/2, scale);
}
FFSWAP(void*, mb->next_cache, mb->point_cache);
mb->cache_used = next_cidx;
if(mb->cache_used == mb->cache_allocated)
av_log(0, AV_LOG_INFO, "Mandelbrot cache is too small!\n");
}
| 1threat |
If there are some identical row names in Table1 and Table2 table then how to read them in java? : <p>If there are some identical row names in Table1 and Table2 table then how to read them in java?
Currently, for reading the column values I use table1.coulmn_name. But it will only return the Table1 column value.</p>
<pre><code>Table1 executeQuery(String billId)
{
ResultSetHandler<Table1> resultHandler = new BeanHandler<Table1>(Table1.class)
table1 table1 = run.query("SELECT * FROM Table1 JOIN Table2 ON Table1.payment_id =Table2.payment_id WHERE Table1.bill_id="+billId, resultHandler)
return table1
}
</code></pre>
| 0debug |
Java Division Of Integer With Brackets : <p>In my app I ask the user to provide their hourly rate, I then have a Chronometer which I want to work out how much they have earned since the time started. To do this I need to turn their hourly rate into a seconds rate and multiply it by the seconds from the Chronometer.</p>
<pre><code> timer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener()
{
@Override
public void onChronometerTick(Chronometer chronometer){
long timeElapsed = SystemClock.elapsedRealtime() - timer.getBase();
int hours = (int) (timeElapsed / 3600000);
int minutes = (int) (timeElapsed - hours * 3600000) / 60000;
int seconds = (int) (timeElapsed - hours * 3600000 - minutes * 60000) / 1000;
int hrlyRate = Integer.parseInt(hourlyRate.getText().toString());
secondsRate = (hrlyRate / 60) / 60;
moneyEarned = secondsRate * seconds;
Log.d("hrlyRate", Integer.toString(hrlyRate));
Log.d("secondsRate", Integer.toString(secondsRate));
}
});
</code></pre>
<p>Say the user enters 40 into the hourlyRate field which I get from an EditText, why is the calculation of secondsRate = 0? Shouldn't it be (40 / 60) / 60 = $0.01 / second?</p>
| 0debug |
App Insights: Disable SQL Dependency telemetry : <p>I'm using Azure Application Insights for a website (Azure App Service).
On that I'm using a clustered Umbraco setup and hangfire. These two alone keep hitting the database every minute and are flooding my 'App Insights'.</p>
<p>So my question is, how do I disable the Sql Dependency Tracker?
I've had a look at the ApplicationInsights.config and couldn't find anything obvious.
I can see <code>Microsoft.ApplicationInsights.DependencyCollector</code> which is probably responsible, but I don't want to remove all types of dependency telemetry, <strong>only</strong> sql.</p>
<p>Thanks</p>
| 0debug |
static int64_t qemu_next_deadline(void)
{
int64_t delta;
if (active_timers[QEMU_CLOCK_VIRTUAL]) {
delta = active_timers[QEMU_CLOCK_VIRTUAL]->expire_time -
qemu_get_clock(vm_clock);
} else {
delta = INT32_MAX;
}
if (delta < 0)
delta = 0;
return delta;
}
| 1threat |
Typescript : How to resolve 'rxjs/Rx has no exported member 'SubscriptionLike' : <p>I'm trying to follow this example here <a href="https://www.youtube.com/watch?v=gxCu5TEmxXE" rel="noreferrer">https://www.youtube.com/watch?v=gxCu5TEmxXE</a>, but when doing <code>tsc -p</code>, I get an error. Is there something I need to import?</p>
<p><strong>ERROR:</strong></p>
<p><code>node_modules/@angular/common/src/location/location.d.ts(1,10): error TS2305: Module '"...functions/node_modules/rxjs/Rx"' has no exported member 'SubscriptionLike'.</code></p>
<p><strong>TS FILE</strong></p>
<pre><code>import "zone.js/dist/zone-node";
import * as functions from "firebase-functions";
import * as express from "express"
import { renderModuleFactory } from "@angular/platform-server"
import * as fs from "fs"
const document = fs.readFileSync(__dirname + "/dist-server/index.html", "utf8");
const AppServerModuleNgFactory = require(__dirname + "/dist-server/main.bundle");
const app = express();
app.get("**", (req, res) => {
const url = req.path;
renderModuleFactory(AppServerModuleNgFactory, { document, url }).then(html => {
res.send(html);
});
});
exports.post = functions.https.onRequest(app);
</code></pre>
<p><strong>CONFIG</strong></p>
<pre><code>{
"compilerOptions": {
"module": "commonjs",
"target": "es2015",
"rootDir": ".",
"outDir": "../functions"
},
"files": [
"index.ts"
]
}
</code></pre>
| 0debug |
static void bench_cb(void *opaque, int ret)
{
BenchData *b = opaque;
BlockAIOCB *acb;
if (ret < 0) {
error_report("Failed request: %s\n", strerror(-ret));
exit(EXIT_FAILURE);
}
if (b->in_flush) {
assert(b->in_flight == 0);
b->in_flush = false;
} else if (b->in_flight > 0) {
int remaining = b->n - b->in_flight;
b->n--;
b->in_flight--;
if (b->flush_interval && remaining % b->flush_interval == 0) {
if (!b->in_flight || !b->drain_on_flush) {
BlockCompletionFunc *cb;
if (b->drain_on_flush) {
b->in_flush = true;
cb = bench_cb;
} else {
cb = bench_undrained_flush_cb;
}
acb = blk_aio_flush(b->blk, cb, b);
if (!acb) {
error_report("Failed to issue flush request");
exit(EXIT_FAILURE);
}
}
if (b->drain_on_flush) {
return;
}
}
}
while (b->n > b->in_flight && b->in_flight < b->nrreq) {
if (b->write) {
acb = blk_aio_pwritev(b->blk, b->offset, b->qiov, 0,
bench_cb, b);
} else {
acb = blk_aio_preadv(b->blk, b->offset, b->qiov, 0,
bench_cb, b);
}
if (!acb) {
error_report("Failed to issue request");
exit(EXIT_FAILURE);
}
b->in_flight++;
b->offset += b->step;
b->offset %= b->image_size;
}
}
| 1threat |
static void enable_logging(void)
{
ga_enable_logging(ga_state);
}
| 1threat |
F# type providers vs C# interfaces + Entity Framework : <p>The question is very technical, and it sits deeply between F# / C# differences. It is quite likely that I might’ve missed something. If you find a conceptual error, please, comment and I will update the question.</p>
<p>Let’s start from C# world. Suppose that I have a simple business object, call it <code>Person</code> (but, please, keep in mind that there are 100+ objects far more complicated than that in the business domain that we work with):</p>
<pre><code>public class Person : IPerson
{
public int PersonId { get; set; }
public string Name { get; set; }
public string LastName { get; set; }
}
</code></pre>
<p>and I use DI / IOC and so that I never actually pass a <code>Person</code> around. Rather, I would always use an interface (mentioned above), call it <code>IPerson</code>:</p>
<pre><code>public interface IPerson
{
int PersonId { get; set; }
string Name { get; set; }
string LastName { get; set; }
}
</code></pre>
<p>The business requirement is that the person can be serialized to / deserialized from the database. Let’s say that I choose to use Entity Framework for that, but the actual implementation seems irrelevant to the question. At this point I have an option to introduce “database” related class(es), e.g. <code>EFPerson</code>:</p>
<pre><code>public class EFPerson : IPerson
{
public int PersonId { get; set; }
public string Name { get; set; }
public string LastName { get; set; }
}
</code></pre>
<p>along with the relevant database related attributes and code, which I will skip for brevity, and then use Reflection to copy properties of <code>IPerson</code> interface between <code>Person</code> and <code>EFPerson</code> OR just use <code>EFPerson</code> (passed as <code>IPerson</code>) directly OR do something else. This is fairly irrelevant, as the consumers will always see <code>IPerson</code> and so the implementation can be changed at any time without the consumers knowing anything about it. </p>
<p>If I need to add a property, then I would update the interface <code>IPerson</code> first (let’s say I add a property <code>DateTime DateOfBirth { get; set; }</code>) and then the compiler will tell me what to fix. However, if I remove the property from the interface (let’s say that I no longer need <code>LastName</code>), then the compiler won’t help me. However, I can write a Reflection-based test, which would ensure that the properties of <code>IPerson</code>, <code>Person</code>, <code>EFPerson</code>, etc. are identical. This is not really needed, but it can be done and then it will work like magic (and yes, we do have such tests and they do work like magic).</p>
<p>Now, let’s get to F# world. Here we have the type providers, which completely remove the need to create database objects in the code: they are created automatically by the type providers! </p>
<p>Cool! But is it?</p>
<p>First, somebody has to create / update the database objects and if there is more than one developer involved, then it is natural that the database may and will be upgraded / downgraded in different branches. So far, from my experience, this is an extreme pain on the neck when F# type providers are involved. Even if C# EF Code First is used to handle migrations, some “extensive shaman dancing” is required to make F# type providers “happy”.</p>
<p>Second, everything is immutable in F# world by default (unless we make it mutable), so we clearly don’t want to pass mutable database objects upstream. Which means that once we load a mutable row from the database, we want to convert it into a “native” F# immutable structure as soon as possible so that to work only with pure functions upstream. After all, using pure functions decreases the number of required tests in, I guess, 5 – 50 times, depending on the domain. </p>
<p>Let’s get back to our <code>Person</code>. I will skip any possible re-mapping for now (e.g. database integer into F# DU case and similar stuff). So, our F# <code>Person</code> would look like that:</p>
<pre><code>type Person =
{
personId : int
name : string
lastName : string
}
</code></pre>
<p>So, if “tomorrow” I need to add <code>dateOfBirth : DateTime</code> to this type, then the compiler will tell me about all places where this needs to be fixed. This is great because C# compiler will not tell me where I need to add that date of birth, … except the database. The F# compiler will not tell me that I need to go and add a database column to the table <code>Person</code>. However, in C#, since I would have to update the interface first, the compiler will tell me which objects must be fixed, including the database one(s).</p>
<p>Apparently, I want the best from both worlds in F#. And while this can be achieved using interfaces, it just does not feel the F# way. After all, the analog of DI / IOC is done very differently in F# and it is usually achieved by passing functions rather than interfaces.</p>
<p>So, here are two questions.</p>
<ol>
<li><p>How can I easily manage database up / down migrations in F# world? And, to start from, what is the proper way to actually do the database migrations in F# world when many developers are involved?</p></li>
<li><p>What is the F# way to achieve “the best of C# world” as described above: when I update F# type <code>Person</code> and then fix all places where I need to add / remove properties to the record, what would be the most appropriate F# way to “fail” either at compile time or at least at test time when I have not updated the database to match the business object(s)?</p></li>
</ol>
| 0debug |
Is there any react js alternative that doesn't use jsx? Maybe native html code? : <p>I am trying to find something that doesn't use JSX to build. Is there any alternative other framework that will accomplish this as fast as react does?</p>
| 0debug |
static void cin_decode_rle(const unsigned char *src, int src_size,
unsigned char *dst, int dst_size)
{
int len, code;
unsigned char *dst_end = dst + dst_size;
const unsigned char *src_end = src + src_size;
while (src < src_end && dst < dst_end) {
code = *src++;
if (code & 0x80) {
len = code - 0x7F;
memset(dst, *src++, FFMIN(len, dst_end - dst));
} else {
len = code + 1;
memcpy(dst, src, FFMIN(len, dst_end - dst));
src += len;
}
dst += len;
}
}
| 1threat |
int kvm_init_vcpu(CPUState *env)
{
KVMState *s = kvm_state;
long mmap_size;
int ret;
DPRINTF("kvm_init_vcpu\n");
ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, env->cpu_index);
if (ret < 0) {
DPRINTF("kvm_create_vcpu failed\n");
goto err;
}
env->kvm_fd = ret;
env->kvm_state = s;
mmap_size = kvm_ioctl(s, KVM_GET_VCPU_MMAP_SIZE, 0);
if (mmap_size < 0) {
DPRINTF("KVM_GET_VCPU_MMAP_SIZE failed\n");
goto err;
}
env->kvm_run = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED,
env->kvm_fd, 0);
if (env->kvm_run == MAP_FAILED) {
ret = -errno;
DPRINTF("mmap'ing vcpu state failed\n");
goto err;
}
#ifdef KVM_CAP_COALESCED_MMIO
if (s->coalesced_mmio && !s->coalesced_mmio_ring) {
s->coalesced_mmio_ring =
(void *)env->kvm_run + s->coalesced_mmio * PAGE_SIZE;
}
#endif
ret = kvm_arch_init_vcpu(env);
if (ret == 0) {
qemu_register_reset(kvm_reset_vcpu, env);
kvm_arch_reset_vcpu(env);
}
err:
return ret;
}
| 1threat |
static int unpack_modes(Vp3DecodeContext *s, GetBitContext *gb)
{
int i, j, k, sb_x, sb_y;
int scheme;
int current_macroblock;
int current_fragment;
int coding_mode;
int custom_mode_alphabet[CODING_MODE_COUNT];
if (s->keyframe) {
for (i = 0; i < s->fragment_count; i++)
s->all_fragments[i].coding_method = MODE_INTRA;
} else {
scheme = get_bits(gb, 3);
if (scheme == 0) {
for (i = 0; i < 8; i++)
custom_mode_alphabet[i] = MODE_INTER_NO_MV;
for (i = 0; i < 8; i++)
custom_mode_alphabet[get_bits(gb, 3)] = i;
}
for (sb_y = 0; sb_y < s->y_superblock_height; sb_y++) {
for (sb_x = 0; sb_x < s->y_superblock_width; sb_x++) {
for (j = 0; j < 4; j++) {
int mb_x = 2*sb_x + (j>>1);
int mb_y = 2*sb_y + (((j>>1)+j)&1);
int frags_coded = 0;
current_macroblock = mb_y * s->macroblock_width + mb_x;
if (mb_x >= s->macroblock_width || mb_y >= s->macroblock_height)
continue;
#define BLOCK_X (2*mb_x + (k&1))
#define BLOCK_Y (2*mb_y + (k>>1))
for (k = 0; k < 4; k++) {
current_fragment = BLOCK_Y*s->fragment_width + BLOCK_X;
if (s->all_fragments[current_fragment].coding_method != MODE_COPY)
break;
}
if (k == 4) {
s->macroblock_coding[current_macroblock] = MODE_INTER_NO_MV;
continue;
}
if (scheme == 7)
coding_mode = get_bits(gb, 3);
else if(scheme == 0)
coding_mode = custom_mode_alphabet
[get_vlc2(gb, s->mode_code_vlc.table, 3, 3)];
else
coding_mode = ModeAlphabet[scheme-1]
[get_vlc2(gb, s->mode_code_vlc.table, 3, 3)];
s->macroblock_coding[current_macroblock] = coding_mode;
for (k = 0; k < 4; k++) {
current_fragment =
BLOCK_Y*s->fragment_width + BLOCK_X;
if (s->all_fragments[current_fragment].coding_method !=
MODE_COPY)
s->all_fragments[current_fragment].coding_method =
coding_mode;
}
for (k = 0; k < 2; k++) {
current_fragment = s->fragment_start[k+1] +
mb_y*(s->fragment_width>>1) + mb_x;
if (s->all_fragments[current_fragment].coding_method !=
MODE_COPY)
s->all_fragments[current_fragment].coding_method =
coding_mode;
}
}
}
}
}
return 0;
}
| 1threat |
av_cold void ff_MPV_common_init_x86(MpegEncContext *s)
{
#if HAVE_INLINE_ASM
int cpu_flags = av_get_cpu_flags();
if (cpu_flags & AV_CPU_FLAG_MMX) {
s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_mmx;
s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_mmx;
s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_mmx;
s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_mmx;
if(!(s->flags & CODEC_FLAG_BITEXACT))
s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_mmx;
s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_mmx;
if (cpu_flags & AV_CPU_FLAG_SSE2) {
s->denoise_dct= denoise_dct_sse2;
} else {
s->denoise_dct= denoise_dct_mmx;
}
}
#endif
}
| 1threat |
intro programming on java with compareTo : <p>just got some computer science from my friend, I believe it is a intro to programming assignment, and I was trying on it, but it seems there are so many issue, seems I am majoring CS, can someone help me on those questions step by step, would be appreciated. in instructions are following:</p>
<p>Create a public class Movie with private instance variables String title
and int year. The class should declare that it implements the
Comparable interface, and should provide the following:</p>
<p>• A constructor that takes 2 arguments: a String and an int (in that order)<br>
for initializing title and year.</p>
<p>• A method that satisfies the Comparable interface. Movies should be compared first by title and then by year.</p>
<p>{ The Maltese Falcon 1941, The Thomas Crown Affair 1968, The Thomas Crown Affair 1999}</p>
<p>An equals() method that is compatible with the method that satisfies the
Comparable interface.</p>
<p>• A toString() method that prints “Movie” followed by 1 space followed by<br>
the title followed by 1 space followed by open-parenthesis followed by<br>
the year followed by close-parenthesis. Example:
The Maltese Falcon (1941)</p>
<p>• A public static method getTestMovies(), which returns an array of 10<br>
unique Movie instances. The 0th and 1st array elements must be 2 movies<br>
with the same title but from different years (e.g. The Thomas Crown<br>
Affair 1968 and The Thomas Crown Affair 1999, or True Grit 1969 and
True Grit 2010). The 2nd and 3rd elements must 2 movies with different<br>
titles but from the same year (e.g. The Martian 2015 and Bridge of Spies<br>
2015). The 4th and 5th elements must be 2 different objects that<br>
represent the same movie.</p>
<p>• A hashCode() method. Use the following:</p>
<pre><code>public int hashCode()
{
return title.hashCode() + year;
}
</code></pre>
<p>the following is what I have so far, I have the constructor and the starter, but I am sure how to do it.</p>
<pre><code>public class Movie implements Comparable<Movie>{
private String title;
private int year;
public Movie(String title, int year){
this.title = title;
this.year = year;
}
@Override
public int compareTo(Movie that) {
int value = 0;
if(this.title == that.title)
{
if(this.year < that.year){
value = 0;
}
else{
value = -1;
}
}
return value;
}
public static void getTestMovie(){
}
public boolean equals(Object x)
{
</code></pre>
<p>}
}</p>
<p>Any Helps are appreciated!</p>
| 0debug |
static void xan_unpack(unsigned char *dest, const unsigned char *src, int dest_len)
{
unsigned char opcode;
int size;
unsigned char *dest_end = dest + dest_len;
while (dest < dest_end) {
opcode = *src++;
if (opcode < 0xe0) {
int size2, back;
if ( (opcode & 0x80) == 0 ) {
size = opcode & 3;
back = ((opcode & 0x60) << 3) + *src++ + 1;
size2 = ((opcode & 0x1c) >> 2) + 3;
} else if ( (opcode & 0x40) == 0 ) {
size = *src >> 6;
back = (bytestream_get_be16(&src) & 0x3fff) + 1;
size2 = (opcode & 0x3f) + 4;
} else {
size = opcode & 3;
back = ((opcode & 0x10) << 12) + bytestream_get_be16(&src) + 1;
size2 = ((opcode & 0x0c) << 6) + *src++ + 5;
if (size + size2 > dest_end - dest)
return;
}
memcpy(dest, src, size); dest += size; src += size;
av_memcpy_backptr(dest, back, size2);
dest += size2;
} else {
int finish = opcode >= 0xfc;
size = finish ? opcode & 3 : ((opcode & 0x1f) << 2) + 4;
memcpy(dest, src, size); dest += size; src += size;
if (finish)
return;
}
}
}
| 1threat |
static inline void RENAME(rgb15ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
{
int i;
assert(src1 == src2);
for(i=0; i<width; i++)
{
int d0= ((uint32_t*)src1)[i];
int dl= (d0&0x03E07C1F);
int dh= ((d0>>5)&0x03E0F81F);
int dh2= (dh>>11) + (dh<<21);
int d= dh2 + dl;
int g= d&0x7F;
int r= (d>>10)&0x7F;
int b= d>>21;
dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1-3)) + 128;
dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1-3)) + 128;
}
}
| 1threat |
pdf to txt tvs or vcf in R, ubuntu : <p>I have the next link</p>
<p>[1] <a href="https://drive.google.com/open?id=0ByCmoyvCype7ODBMQjFTSlNtTzQ" rel="nofollow noreferrer">https://drive.google.com/open?id=0ByCmoyvCype7ODBMQjFTSlNtTzQ</a></p>
<p>This is a pdf file. The author of a paper gave the list of mutation in this format.
I need to annotate the mutation of this file.
I need a txt or TVS or VCF file to be reading by annovar.</p>
<p>Can you help me to convert this using R or other software in ubuntu?</p>
| 0debug |
How to check the content of the string AND the length of it in c#? : Basically, im trying to write a game something like a jackpot with 3 slots in console. According to user input, user will be awarded. But first, i need the user to write the correct string, if user input it something different, program will re-ask the input. user can enter 3 of the following :
X , Y , Z, x, y, z and J.
Some examples of user input : XyZ, XXJ, ZJy...
And i need to check if user input length is 3 characters long, and contains XYZxyzJ using loops and if-else statements. Any help would be appreciated! | 0debug |
my PDO update query is inserting undefined value in only one column , why? : <p>i have four fields of record in my table</p>
<ol>
<li>name</li>
<li>email</li>
<li>phone</li>
<li>address</li>
</ol>
<p>i am using PDO method for updating record in php with ajax, when i call insert query it works fine but when i update my record it updates only three starting fields , in address field they inserted <em>undefined</em> text value , where i am doing mistake ?</p>
<p>screenshot of my front end
<a href="https://drive.google.com/open?id=0B-PfnAjLGR2xendqM2NsaUVuLW8" rel="nofollow noreferrer">https://drive.google.com/open?id=0B-PfnAjLGR2xendqM2NsaUVuLW8</a></p>
<h2># My html code #</h2>
<p> </p>
<pre><code> <div class="modal-body">
<input type="hidden" id="<?php echo $row['id']; ?>" value="<?php echo $row['id']; ?>">
<div class="form-group">
<label for="nm">Name</label>
<input type="text" class="form-control" id="nm-<?php echo $row['id']; ?>" value= "<?php echo $row['name']; ?>">
</div>
<div class="form-group">
<label for="em">Email</label>
<input type="Email" class="form-control" id="em-<?php echo $row['id']; ?>" value= "<?php echo $row['email']; ?>">
</div>
<div class="form-group">
<label for="ph">Phone</label>
<input type="number" class="form-control" id="ph-<?php echo $row['id']; ?>" value= "<?php echo $row['phone']; ?>">
</div>
<div class="form-group">
<label for="ad">Address</label>
<textarea type="text" class="form-control" id="ph-<?php echo $row['id']; ?>" > <?php echo $row['address'];?> </textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" onclick="updateData(<?php echo $row['id']; ?>)" class="btn btn-primary">Update</button>
</div>
</form>
</code></pre>
<h2>my ajax script code</h2>
<pre><code><script type="text/javascript">
function updateData(str){
var id = str;
var name = $('#nm-'+str).val();
var email = $('#em-'+str).val();
var phone = $('#ph-'+str).val();
var address = $('#ad-'+str).val();
$.ajax({
type:"POST",
url: "server.php?p=edit" ,
data : "nm="+name+"&em="+email+"&ph="+phone+"&ad="+address+"&id="+id,
success :function(data){
viewData();
}
});
}
</script>
</code></pre>
<h2>PDO file code</h2>
<pre><code>else if($page=='edit'){
$id = $_POST['id'];
$name = $_POST['nm'];
$email = $_POST['em'];
$phone = $_POST['ph'];
$address = $_POST['ad'];
$stmt = $db->prepare(" update crud set name=? , email=? , phone=? , address=? where id=?");
$stmt->bindValue(1,$name);
$stmt->bindValue(2,$email);
$stmt->bindValue(3,$phone);
$stmt->bindValue(4,$address);
$stmt->bindValue(5,$id);
if($stmt->execute()){
echo "succesfully updated";
}
else{
echo "failed updated data";
}
}
</code></pre>
| 0debug |
My Duration is String. duration = @"00:06:29" how to get the float time value to move my uislider bar : how to get the float time value for my json data. below code i got my duration in string then how can i convert into the float value to pass my uislider bar total length of the audio. please help me to move my uislider bar.
//Json Data
{
duration = "00:03:45";
id = 8;
}
//Audio player sider bar function
if(audioController.playbackState == MPMusicPlaybackStatePlaying){
if (isSelected == YES) {
currentAutio = audioList[selectedAudio];
} else {
currentAutio = audioList[0];
}
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
numberFormatter.numberStyle = NSNumberFormatterDecimalStyle;
float value = [numberFormatter numberFromString:currentAutio.duration].floatValue;
float currentPlaybackTime = [audioController currentPlaybackTime];
float TotalLength = value;
float remainingPlaybackTime = TotalLength - currentPlaybackTime;
float sliderPosition = (currentPlaybackTime *100) / TotalLength;
NSLog(@"current playbacktime %f",currentPlaybackTime);
NSLog(@"TotalLength %f",TotalLength);
NSLog(@"remainingPlaybackTime %f",remainingPlaybackTime);
NSLog(@"sliderPosition %f",sliderPosition);
//Update slider
[progressSlider setValue:sliderPosition];
//Update labels
NSDate* d1 = [NSDate dateWithTimeIntervalSince1970:currentPlaybackTime];
NSDate* d2 = [NSDate dateWithTimeIntervalSince1970:remainingPlaybackTime];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"mm:ss"];
NSString *currentTime = [dateFormatter stringFromDate:d1];
NSString *ramainingTime = [dateFormatter stringFromDate:d2];
[trackCurrentPlaybackTimeLabel setText:currentTime];
[trackLengthLabel setText:[NSString stringWithFormat:@"-%@",ramainingTime]];
}
out put: Value = 0.00000 | 0debug |
Memory Error: Would their be away to make this shorter or incremental so this doesnt happen? : #This is Where Everything about the Player is stored
class Player_Data:
def Player_Data_Vars(self):
import sys
#print(sys.getrecursionlimit())
sys.setrecursionlimit()
#print(sys.getrecursionlimit())
def Xp(self):
Level = 0
Xp = 0
Xp = Xp + 10
if Xp == 10:
Xp = 0
Level = Level + 1
if Xp == 0:
Hp(self)
return
def Hp(self):
Level = Xp('Level')
Base_Hp = 100
Level_Up_Hp = + 20 * Level
Base_Hp = Base_Hp + Level_Up_Hp
print(Base_Hp)
return
def Atk(self):
Fists = 10
Stick = 10
Weopon = Fists
Wand = Stick
Level = 0
Level_Up_Magic_Dmg = + 10 * Level
Level_Up_Dmg = + 10 * Level
Base_Player_Dmg = 10 + Weopon + Level_Up_Dmg
Base_Magic_Dmg = 10 + Wand + Level
print(Base_Magic_Dmg, Base_Player_Dmg)
return
Xp('self')
print('')
Atk('self')
print('')
Hp('self')
Player_Data_Vars('self')
Player_Data = Player_Data
this is my results
Traceback (most recent call last):
File "C:/Users/Luke/Desktop/Game Project Folder Python/Player Data.py", line 20, in Hp
Level = Xp('Level')
File "C:/Users/Luke/Desktop/Game Project Folder Python/Player Data.py", line 17, in Xp
Hp(self)
File "C:/Users/Luke/Desktop/Game Project Folder Python/Player Data.py", line 20, in Hp
Level = Xp('Level')
File "C:/Users/Luke/Desktop/Game Project Folder Python/Player Data.py", line 17, in Xp
Hp(self)
File "C:/Users/Luke/Desktop/Game Project Folder Python/Player Data.py", line 20, in Hp
Level = Xp('Level')
File "C:/Users/Luke/Desktop/Game Project Folder Python/Player Data.py", line 17, in Xp
Hp(self)
File "C:/Users/Luke/Desktop/Game Project Folder Python/Player Data.py", line 20, in Hp
Level = Xp('Level')
File "C:/Users/Luke/Desktop/Game Project Folder Python/Player Data.py", line 17, in Xp
Hp(self)
File "C:/Users/Luke/Desktop/Game Project Folder Python/Player Data.py", line 20, in Hp
Level = Xp('Level')
File "C:/Users/Luke/Desktop/Game Project Folder Python/Player Data.py", line 17, in Xp
Hp(self)
File "C:/Users/Luke/Desktop/Game Project Folder Python/Player Data.py", line 20, in Hp
Level = Xp('Level')
File "C:/Users/Luke/Desktop/Game Project Folder Python/Player Data.py", line 17, in Xp
Hp(self)
File "C:/Users/Luke/Desktop/Game Project Folder Python/Player Data.py", line 20, in Hp
Level = Xp('Level')
File "C:/Users/Luke/Desktop/Game Project Folder Python/Player Data.py", line 17, in Xp
MemoryError: Stack overflow
repeated:
| 0debug |
static int rebuild_refcount_structure(BlockDriverState *bs,
BdrvCheckResult *res,
uint16_t **refcount_table,
int64_t *nb_clusters)
{
BDRVQcowState *s = bs->opaque;
int64_t first_free_cluster = 0, reftable_offset = -1, cluster = 0;
int64_t refblock_offset, refblock_start, refblock_index;
uint32_t reftable_size = 0;
uint64_t *on_disk_reftable = NULL;
uint16_t *on_disk_refblock;
int i, ret = 0;
struct {
uint64_t reftable_offset;
uint32_t reftable_clusters;
} QEMU_PACKED reftable_offset_and_clusters;
qcow2_cache_empty(bs, s->refcount_block_cache);
write_refblocks:
for (; cluster < *nb_clusters; cluster++) {
if (!(*refcount_table)[cluster]) {
continue;
}
refblock_index = cluster >> s->refcount_block_bits;
refblock_start = refblock_index << s->refcount_block_bits;
if (first_free_cluster < refblock_start) {
first_free_cluster = refblock_start;
}
refblock_offset = alloc_clusters_imrt(bs, 1, refcount_table,
nb_clusters, &first_free_cluster);
if (refblock_offset < 0) {
fprintf(stderr, "ERROR allocating refblock: %s\n",
strerror(-refblock_offset));
res->check_errors++;
ret = refblock_offset;
goto fail;
}
if (reftable_size <= refblock_index) {
uint32_t old_reftable_size = reftable_size;
uint64_t *new_on_disk_reftable;
reftable_size = ROUND_UP((refblock_index + 1) * sizeof(uint64_t),
s->cluster_size) / sizeof(uint64_t);
new_on_disk_reftable = g_try_realloc(on_disk_reftable,
reftable_size *
sizeof(uint64_t));
if (!new_on_disk_reftable) {
res->check_errors++;
ret = -ENOMEM;
goto fail;
}
on_disk_reftable = new_on_disk_reftable;
memset(on_disk_reftable + old_reftable_size, 0,
(reftable_size - old_reftable_size) * sizeof(uint64_t));
reftable_offset = -1;
}
on_disk_reftable[refblock_index] = refblock_offset;
if (refblock_index == (*nb_clusters - 1) >> s->refcount_block_bits &&
reftable_offset < 0)
{
uint64_t reftable_clusters = size_to_clusters(s, reftable_size *
sizeof(uint64_t));
reftable_offset = alloc_clusters_imrt(bs, reftable_clusters,
refcount_table, nb_clusters,
&first_free_cluster);
if (reftable_offset < 0) {
fprintf(stderr, "ERROR allocating reftable: %s\n",
strerror(-reftable_offset));
res->check_errors++;
ret = reftable_offset;
goto fail;
}
}
ret = qcow2_pre_write_overlap_check(bs, 0, refblock_offset,
s->cluster_size);
if (ret < 0) {
fprintf(stderr, "ERROR writing refblock: %s\n", strerror(-ret));
goto fail;
}
on_disk_refblock = qemu_blockalign0(bs->file, s->cluster_size);
for (i = 0; i < s->refcount_block_size &&
refblock_start + i < *nb_clusters; i++)
{
on_disk_refblock[i] =
cpu_to_be16((*refcount_table)[refblock_start + i]);
}
ret = bdrv_write(bs->file, refblock_offset / BDRV_SECTOR_SIZE,
(void *)on_disk_refblock, s->cluster_sectors);
qemu_vfree(on_disk_refblock);
if (ret < 0) {
fprintf(stderr, "ERROR writing refblock: %s\n", strerror(-ret));
goto fail;
}
cluster = refblock_start + s->refcount_block_size - 1;
}
if (reftable_offset < 0) {
uint64_t post_refblock_start, reftable_clusters;
post_refblock_start = ROUND_UP(*nb_clusters, s->refcount_block_size);
reftable_clusters = size_to_clusters(s,
reftable_size * sizeof(uint64_t));
if (first_free_cluster < post_refblock_start) {
first_free_cluster = post_refblock_start;
}
reftable_offset = alloc_clusters_imrt(bs, reftable_clusters,
refcount_table, nb_clusters,
&first_free_cluster);
if (reftable_offset < 0) {
fprintf(stderr, "ERROR allocating reftable: %s\n",
strerror(-reftable_offset));
res->check_errors++;
ret = reftable_offset;
goto fail;
}
goto write_refblocks;
}
assert(on_disk_reftable);
for (refblock_index = 0; refblock_index < reftable_size; refblock_index++) {
cpu_to_be64s(&on_disk_reftable[refblock_index]);
}
ret = qcow2_pre_write_overlap_check(bs, 0, reftable_offset,
reftable_size * sizeof(uint64_t));
if (ret < 0) {
fprintf(stderr, "ERROR writing reftable: %s\n", strerror(-ret));
goto fail;
}
assert(reftable_size < INT_MAX / sizeof(uint64_t));
ret = bdrv_pwrite(bs->file, reftable_offset, on_disk_reftable,
reftable_size * sizeof(uint64_t));
if (ret < 0) {
fprintf(stderr, "ERROR writing reftable: %s\n", strerror(-ret));
goto fail;
}
cpu_to_be64w(&reftable_offset_and_clusters.reftable_offset,
reftable_offset);
cpu_to_be32w(&reftable_offset_and_clusters.reftable_clusters,
size_to_clusters(s, reftable_size * sizeof(uint64_t)));
ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader,
refcount_table_offset),
&reftable_offset_and_clusters,
sizeof(reftable_offset_and_clusters));
if (ret < 0) {
fprintf(stderr, "ERROR setting reftable: %s\n", strerror(-ret));
goto fail;
}
for (refblock_index = 0; refblock_index < reftable_size; refblock_index++) {
be64_to_cpus(&on_disk_reftable[refblock_index]);
}
s->refcount_table = on_disk_reftable;
s->refcount_table_offset = reftable_offset;
s->refcount_table_size = reftable_size;
return 0;
fail:
g_free(on_disk_reftable);
return ret;
}
| 1threat |
Angular 4 Image sliders : <p>I'm searching for recommendations for a good Angular4 image slider component, I've tried ngx-bootstrap and ng2-owl-carousel but they don't work as good as they say and theres not too much documentation about them, if you know about a well documented component for Angular4 I'll be grateful for the info!</p>
| 0debug |
Macro Programming in Word : In Word, what is the macro vba code necessary for me to find a phrase, goto the beginning of the line the phrase is in, insert a page break, then leave myself in a position to execute the macro again. | 0debug |
how to create table in database and call into php for creating a website? : I create the table in database but the data including users id/account does not record in database table. That problem issued me in a php during the creating a sign up & login page. | 0debug |
active android studio app by using phone balance : I have a question about android codes, I want to understand some developers use some codes to buy or active his app, for example, I have Dictionary and it is not free, but I want user full active dictionary by using a balance of phone number, when the user send me a balance I send to user number to active, please I want understanding that it how?! | 0debug |
alert('Hello ' + user_input); | 1threat |
When creating a file in C++, where is the created file saved at? : <p>After executing the code, i couldn't find the newly created file in my desktop. Could anyone tell where a created file will be saved in?</p>
<pre><code>#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream testfile("testing.txt");
if (testfile.is_open())
{
testfile << "This is a line.\n";
testfile << "This the second line.\n";
testfile.close();
}
else cout << "Unable to open file";
return 0;
}
</code></pre>
| 0debug |
Using python to get current time in yyyy-mm-ddThh:mm:ss.000Z format and also add days : <p>I'm using python and I need to get the time in a certain format that this API uses. So I need to get current time in the format of yyyy-mm-ddThh:mm:ss.000Z and then also create a new date in the future by adding a number of days to it. So if I could get the current time of 2017-08-19T07:00:00.000Z and add 30 days to it to get 2017-09-18T07:00:00.000Z. What would be the easiest way to write this in python?</p>
<p>Thanks!</p>
| 0debug |
static int aio_write_f(BlockBackend *blk, int argc, char **argv)
{
int nr_iov, c;
int pattern = 0xcd;
struct aio_ctx *ctx = g_new0(struct aio_ctx, 1);
int flags = 0;
ctx->blk = blk;
while ((c = getopt(argc, argv, "CfqP:uz")) != -1) {
switch (c) {
case 'C':
ctx->Cflag = true;
break;
case 'f':
flags |= BDRV_REQ_FUA;
break;
case 'q':
ctx->qflag = true;
break;
case 'u':
flags |= BDRV_REQ_MAY_UNMAP;
break;
case 'P':
pattern = parse_pattern(optarg);
if (pattern < 0) {
g_free(ctx);
return 0;
}
break;
case 'z':
ctx->zflag = true;
break;
default:
g_free(ctx);
return qemuio_command_usage(&aio_write_cmd);
}
}
if (optind > argc - 2) {
g_free(ctx);
return qemuio_command_usage(&aio_write_cmd);
}
if (ctx->zflag && optind != argc - 2) {
printf("-z supports only a single length parameter\n");
g_free(ctx);
return 0;
}
if ((flags & BDRV_REQ_MAY_UNMAP) && !ctx->zflag) {
printf("-u requires -z to be specified\n");
g_free(ctx);
return 0;
}
if (ctx->zflag && ctx->Pflag) {
printf("-z and -P cannot be specified at the same time\n");
g_free(ctx);
return 0;
}
ctx->offset = cvtnum(argv[optind]);
if (ctx->offset < 0) {
print_cvtnum_err(ctx->offset, argv[optind]);
g_free(ctx);
return 0;
}
optind++;
if (ctx->zflag) {
int64_t count = cvtnum(argv[optind]);
if (count < 0) {
print_cvtnum_err(count, argv[optind]);
g_free(ctx);
return 0;
}
ctx->qiov.size = count;
blk_aio_write_zeroes(blk, ctx->offset, count, flags, aio_write_done,
ctx);
} else {
nr_iov = argc - optind;
ctx->buf = create_iovec(blk, &ctx->qiov, &argv[optind], nr_iov,
pattern);
if (ctx->buf == NULL) {
block_acct_invalid(blk_get_stats(blk), BLOCK_ACCT_WRITE);
g_free(ctx);
return 0;
}
gettimeofday(&ctx->t1, NULL);
block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size,
BLOCK_ACCT_WRITE);
blk_aio_pwritev(blk, ctx->offset, &ctx->qiov, flags, aio_write_done,
ctx);
}
return 0;
}
| 1threat |
What does "! []" Elm code syntax in Todomvc mean : <p>Coming from react, I am learning to understand Elm.</p>
<p>In the <a href="https://github.com/evancz/elm-todomvc/blob/master/Todo.elm">Todomvc example code</a>, there is the following code snippet:</p>
<pre><code>-- How we update our Model on a given Msg?
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
NoOp ->
model ! [] <-- What is this?
</code></pre>
<p>What I (think I) understand, is that the <code>update</code> function takes in a <code>msg</code> of type <code>Msg</code> and a <code>model</code> of type <code>Model</code>, and returns a tuple of containing a <code>Model</code> and a <code>Cmd Msg</code>.</p>
<p>But how should I read the return statement?</p>
<pre><code>model ! []
</code></pre>
<p>What does this statement mean? return a "model [something] empty list"?<br>
Did I miss something in the docs where this is explained? (Googling "elm !" did not get me far :)</p>
| 0debug |
void fork_end(int child)
{
mmap_fork_end(child);
if (child) {
CPUState *cpu, *next_cpu;
CPU_FOREACH_SAFE(cpu, next_cpu) {
if (cpu != thread_cpu) {
QTAILQ_REMOVE(&cpus, thread_cpu, node);
}
}
pending_cpus = 0;
pthread_mutex_init(&exclusive_lock, NULL);
pthread_mutex_init(&cpu_list_mutex, NULL);
pthread_cond_init(&exclusive_cond, NULL);
pthread_cond_init(&exclusive_resume, NULL);
pthread_mutex_init(&tcg_ctx.tb_ctx.tb_lock, NULL);
gdbserver_fork(thread_cpu);
} else {
pthread_mutex_unlock(&exclusive_lock);
pthread_mutex_unlock(&tcg_ctx.tb_ctx.tb_lock);
}
}
| 1threat |
static void set_bit(Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
Error *local_err = NULL;
bool value;
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
return;
}
visit_type_bool(v, &value, name, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
bit_prop_set(dev, prop, value);
}
| 1threat |
how to retrive array values into individual varriables : i have an api which returns a response in form of an array. i want to extract the elements in this array and save them in my database. can any one help.i have tried the explode function but seems am missing something. below is an exact sample response from the api
Array
(
[Response] => Array
(
[external_reference] => bablaba
[withdraw_request_id] => babalalal
[amount] => bababababa
[status] => ababababab
[message] => ababababa.
[new_balance] => babababa
[amount_sent] => ababababa
[currency_sent] => ababababa
[charge_amount] => ababababa
[charge_currency] => babababa
[currency] => abababaab
)
) | 0debug |
conda info --envs doesn't list all my environments : <p>When I run the code,</p>
<pre><code>conda info --envs
</code></pre>
<p>it lists three environments, but I know I have more environments because when I activate other environments (that I remember creating), it works.</p>
<p>Is this an indication that something is wrong with my conda environments?
Is there a way to fix it?</p>
<p>I'm running a windows 10 system. python 3.5 installed</p>
| 0debug |
static int wma_decode_block(WMADecodeContext *s)
{
int n, v, a, ch, code, bsize;
int coef_nb_bits, total_gain, parse_exponents;
DECLARE_ALIGNED_16(float, window[BLOCK_MAX_SIZE * 2]);
int nb_coefs[MAX_CHANNELS];
float mdct_norm;
#ifdef TRACE
tprintf("***decode_block: %d:%d\n", s->frame_count - 1, s->block_num);
#endif
if (s->use_variable_block_len) {
n = av_log2(s->nb_block_sizes - 1) + 1;
if (s->reset_block_lengths) {
s->reset_block_lengths = 0;
v = get_bits(&s->gb, n);
if (v >= s->nb_block_sizes)
return -1;
s->prev_block_len_bits = s->frame_len_bits - v;
v = get_bits(&s->gb, n);
if (v >= s->nb_block_sizes)
return -1;
s->block_len_bits = s->frame_len_bits - v;
} else {
s->prev_block_len_bits = s->block_len_bits;
s->block_len_bits = s->next_block_len_bits;
}
v = get_bits(&s->gb, n);
if (v >= s->nb_block_sizes)
return -1;
s->next_block_len_bits = s->frame_len_bits - v;
} else {
s->next_block_len_bits = s->frame_len_bits;
s->prev_block_len_bits = s->frame_len_bits;
s->block_len_bits = s->frame_len_bits;
}
s->block_len = 1 << s->block_len_bits;
if ((s->block_pos + s->block_len) > s->frame_len)
return -1;
if (s->nb_channels == 2) {
s->ms_stereo = get_bits(&s->gb, 1);
}
v = 0;
for(ch = 0; ch < s->nb_channels; ch++) {
a = get_bits(&s->gb, 1);
s->channel_coded[ch] = a;
v |= a;
}
if (!v)
goto next;
bsize = s->frame_len_bits - s->block_len_bits;
total_gain = 1;
for(;;) {
a = get_bits(&s->gb, 7);
total_gain += a;
if (a != 127)
break;
}
if (total_gain < 15)
coef_nb_bits = 13;
else if (total_gain < 32)
coef_nb_bits = 12;
else if (total_gain < 40)
coef_nb_bits = 11;
else if (total_gain < 45)
coef_nb_bits = 10;
else
coef_nb_bits = 9;
n = s->coefs_end[bsize] - s->coefs_start;
for(ch = 0; ch < s->nb_channels; ch++)
nb_coefs[ch] = n;
if (s->use_noise_coding) {
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
int i, n, a;
n = s->exponent_high_sizes[bsize];
for(i=0;i<n;i++) {
a = get_bits(&s->gb, 1);
s->high_band_coded[ch][i] = a;
if (a)
nb_coefs[ch] -= s->exponent_high_bands[bsize][i];
}
}
}
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
int i, n, val, code;
n = s->exponent_high_sizes[bsize];
val = (int)0x80000000;
for(i=0;i<n;i++) {
if (s->high_band_coded[ch][i]) {
if (val == (int)0x80000000) {
val = get_bits(&s->gb, 7) - 19;
} else {
code = get_vlc2(&s->gb, s->hgain_vlc.table, HGAINVLCBITS, HGAINMAX);
if (code < 0)
return -1;
val += code - 18;
}
s->high_band_values[ch][i] = val;
}
}
}
}
}
parse_exponents = 1;
if (s->block_len_bits != s->frame_len_bits) {
parse_exponents = get_bits(&s->gb, 1);
}
if (parse_exponents) {
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
if (s->use_exp_vlc) {
if (decode_exp_vlc(s, ch) < 0)
return -1;
} else {
decode_exp_lsp(s, ch);
}
}
}
} else {
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
interpolate_array(s->exponents[ch], 1 << s->prev_block_len_bits,
s->block_len);
}
}
}
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
VLC *coef_vlc;
int level, run, sign, tindex;
int16_t *ptr, *eptr;
const uint16_t *level_table, *run_table;
tindex = (ch == 1 && s->ms_stereo);
coef_vlc = &s->coef_vlc[tindex];
run_table = s->run_table[tindex];
level_table = s->level_table[tindex];
ptr = &s->coefs1[ch][0];
eptr = ptr + nb_coefs[ch];
memset(ptr, 0, s->block_len * sizeof(int16_t));
for(;;) {
code = get_vlc2(&s->gb, coef_vlc->table, VLCBITS, VLCMAX);
if (code < 0)
return -1;
if (code == 1) {
break;
} else if (code == 0) {
level = get_bits(&s->gb, coef_nb_bits);
run = get_bits(&s->gb, s->frame_len_bits);
} else {
run = run_table[code];
level = level_table[code];
}
sign = get_bits(&s->gb, 1);
if (!sign)
level = -level;
ptr += run;
if (ptr >= eptr)
{
av_log(NULL, AV_LOG_ERROR, "overflow in spectral RLE, ignoring\n");
break;
}
*ptr++ = level;
if (ptr >= eptr)
break;
}
}
if (s->version == 1 && s->nb_channels >= 2) {
align_get_bits(&s->gb);
}
}
{
int n4 = s->block_len / 2;
mdct_norm = 1.0 / (float)n4;
if (s->version == 1) {
mdct_norm *= sqrt(n4);
}
}
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
int16_t *coefs1;
float *coefs, *exponents, mult, mult1, noise, *exp_ptr;
int i, j, n, n1, last_high_band;
float exp_power[HIGH_BAND_MAX_SIZE];
coefs1 = s->coefs1[ch];
exponents = s->exponents[ch];
mult = pow(10, total_gain * 0.05) / s->max_exponent[ch];
mult *= mdct_norm;
coefs = s->coefs[ch];
if (s->use_noise_coding) {
mult1 = mult;
for(i = 0;i < s->coefs_start; i++) {
*coefs++ = s->noise_table[s->noise_index] * (*exponents++) * mult1;
s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1);
}
n1 = s->exponent_high_sizes[bsize];
exp_ptr = exponents +
s->high_band_start[bsize] -
s->coefs_start;
last_high_band = 0;
for(j=0;j<n1;j++) {
n = s->exponent_high_bands[s->frame_len_bits -
s->block_len_bits][j];
if (s->high_band_coded[ch][j]) {
float e2, v;
e2 = 0;
for(i = 0;i < n; i++) {
v = exp_ptr[i];
e2 += v * v;
}
exp_power[j] = e2 / n;
last_high_band = j;
tprintf("%d: power=%f (%d)\n", j, exp_power[j], n);
}
exp_ptr += n;
}
for(j=-1;j<n1;j++) {
if (j < 0) {
n = s->high_band_start[bsize] -
s->coefs_start;
} else {
n = s->exponent_high_bands[s->frame_len_bits -
s->block_len_bits][j];
}
if (j >= 0 && s->high_band_coded[ch][j]) {
mult1 = sqrt(exp_power[j] / exp_power[last_high_band]);
mult1 = mult1 * pow(10, s->high_band_values[ch][j] * 0.05);
mult1 = mult1 / (s->max_exponent[ch] * s->noise_mult);
mult1 *= mdct_norm;
for(i = 0;i < n; i++) {
noise = s->noise_table[s->noise_index];
s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1);
*coefs++ = (*exponents++) * noise * mult1;
}
} else {
for(i = 0;i < n; i++) {
noise = s->noise_table[s->noise_index];
s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1);
*coefs++ = ((*coefs1++) + noise) * (*exponents++) * mult;
}
}
}
n = s->block_len - s->coefs_end[bsize];
mult1 = mult * exponents[-1];
for(i = 0; i < n; i++) {
*coefs++ = s->noise_table[s->noise_index] * mult1;
s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1);
}
} else {
for(i = 0;i < s->coefs_start; i++)
*coefs++ = 0.0;
n = nb_coefs[ch];
for(i = 0;i < n; i++) {
*coefs++ = coefs1[i] * exponents[i] * mult;
}
n = s->block_len - s->coefs_end[bsize];
for(i = 0;i < n; i++)
*coefs++ = 0.0;
}
}
}
#ifdef TRACE
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
dump_floats("exponents", 3, s->exponents[ch], s->block_len);
dump_floats("coefs", 1, s->coefs[ch], s->block_len);
}
}
#endif
if (s->ms_stereo && s->channel_coded[1]) {
float a, b;
int i;
if (!s->channel_coded[0]) {
tprintf("rare ms-stereo case happened\n");
memset(s->coefs[0], 0, sizeof(float) * s->block_len);
s->channel_coded[0] = 1;
}
for(i = 0; i < s->block_len; i++) {
a = s->coefs[0][i];
b = s->coefs[1][i];
s->coefs[0][i] = a + b;
s->coefs[1][i] = a - b;
}
}
{
int i, next_block_len, block_len, prev_block_len, n;
float *wptr;
block_len = s->block_len;
prev_block_len = 1 << s->prev_block_len_bits;
next_block_len = 1 << s->next_block_len_bits;
wptr = window + block_len;
if (block_len <= next_block_len) {
for(i=0;i<block_len;i++)
*wptr++ = s->windows[bsize][i];
} else {
n = (block_len / 2) - (next_block_len / 2);
for(i=0;i<n;i++)
*wptr++ = 1.0;
for(i=0;i<next_block_len;i++)
*wptr++ = s->windows[s->frame_len_bits - s->next_block_len_bits][i];
for(i=0;i<n;i++)
*wptr++ = 0.0;
}
wptr = window + block_len;
if (block_len <= prev_block_len) {
for(i=0;i<block_len;i++)
*--wptr = s->windows[bsize][i];
} else {
n = (block_len / 2) - (prev_block_len / 2);
for(i=0;i<n;i++)
*--wptr = 1.0;
for(i=0;i<prev_block_len;i++)
*--wptr = s->windows[s->frame_len_bits - s->prev_block_len_bits][i];
for(i=0;i<n;i++)
*--wptr = 0.0;
}
}
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
DECLARE_ALIGNED_16(FFTSample, output[BLOCK_MAX_SIZE * 2]);
float *ptr;
int n4, index, n;
n = s->block_len;
n4 = s->block_len / 2;
s->mdct_ctx[bsize].fft.imdct_calc(&s->mdct_ctx[bsize],
output, s->coefs[ch], s->mdct_tmp);
index = (s->frame_len / 2) + s->block_pos - n4;
ptr = &s->frame_out[ch][index];
s->dsp.vector_fmul_add_add(ptr,window,output,ptr,0,2*n,1);
if (s->ms_stereo && !s->channel_coded[1]) {
ptr = &s->frame_out[1][index];
s->dsp.vector_fmul_add_add(ptr,window,output,ptr,0,2*n,1);
}
}
}
next:
s->block_num++;
s->block_pos += s->block_len;
if (s->block_pos >= s->frame_len)
return 1;
else
return 0;
}
| 1threat |
I am getting the following error when trying to deploy my SSRS reports on our SQL 2014 R2 Server : I am getting the following error when trying to deploy my SSRS reports on our SQL 2014 Server "The report server cannot decrypt the symmetric key that is used to access sensitive or encrypted data in a report server database.
You must either restore a backup key or delete all encrypted content. (rsReportServerDisabled) Get Online Help Keyset does not exist (Exception from HRESULT: 0x80090016)The report server cannot decrypt the symmetric key that is used to access sensitive or encrypted data in a report server database. You must either restore a backup key or delete all encrypted content.(rsReportServerDisabled) Get Online Help Keyset does not exist (Exception from HRESULT: 0x80090016) "
Thanks in Advance. | 0debug |
static int vdi_check(BlockDriverState *bs)
{
BDRVVdiState *s = (BDRVVdiState *)bs->opaque;
int n_errors = 0;
uint32_t blocks_allocated = 0;
uint32_t block;
uint32_t *bmap;
logout("\n");
bmap = qemu_malloc(s->header.blocks_in_image * sizeof(uint32_t));
memset(bmap, 0xff, s->header.blocks_in_image * sizeof(uint32_t));
for (block = 0; block < s->header.blocks_in_image; block++) {
uint32_t bmap_entry = le32_to_cpu(s->bmap[block]);
if (bmap_entry != VDI_UNALLOCATED) {
if (bmap_entry < s->header.blocks_in_image) {
blocks_allocated++;
if (bmap[bmap_entry] == VDI_UNALLOCATED) {
bmap[bmap_entry] = bmap_entry;
} else {
fprintf(stderr, "ERROR: block index %" PRIu32
" also used by %" PRIu32 "\n", bmap[bmap_entry], bmap_entry);
}
} else {
fprintf(stderr, "ERROR: block index %" PRIu32
" too large, is %" PRIu32 "\n", block, bmap_entry);
n_errors++;
}
}
}
if (blocks_allocated != s->header.blocks_allocated) {
fprintf(stderr, "ERROR: allocated blocks mismatch, is %" PRIu32
", should be %" PRIu32 "\n",
blocks_allocated, s->header.blocks_allocated);
n_errors++;
}
qemu_free(bmap);
return n_errors;
}
| 1threat |
What exactly does this compiler error want me to perform? : <p>Thank you in advance for reading ! So this is the code : </p>
<pre><code>#include<iostream>
#include<vector>
std::vector<int> MonkeyCount(int n);
int main() {
MonkeyCount(4);
return 0;
}
std::vector<int> MonkeyCount(int n) {
std::vector<int> MonkeyCountV;
for (unsigned int i = 1; i <= n; i++) {
MonkeyCountV.push_back(i);
}
for (unsigned int i = 0; i <= MonkeyCountV.size(); i++) {
std::cout << MonkeyCount.at(i) << " ";
}
return MonkeyCountV;
}
</code></pre>
<p>and the error is on line 23 : error C2227: left of '->at' must point to class/struct/union/generic type
Now i red something about this, but i use this from an example i found on the internet on how to print a vector, and in that exaple, in works. The exaple is this : </p>
<pre><code>#include <iostream>
#include <vector>
void print(std::vector<int> const& input);
int main()
{
std::vector<int> input = { 1, 2, 3, 4, 5 };
print(input);
return 0;
}
void print(std::vector<int> const& input)
{
for (unsigned int i = 0; i < input.size(); i++) {
std::cout << input.at(i) << ' ';
}
}
</code></pre>
| 0debug |
static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr,
SpectrumParameters *spectrum)
{
unsigned int temp, max_qmf_subbands = 0;
unsigned int start_min, stop_min;
int k;
const int8_t *sbr_offset_ptr;
int16_t stop_dk[13];
if (sbr->sample_rate < 32000) {
temp = 3000;
} else if (sbr->sample_rate < 64000) {
temp = 4000;
} else
temp = 5000;
start_min = ((temp << 7) + (sbr->sample_rate >> 1)) / sbr->sample_rate;
stop_min = ((temp << 8) + (sbr->sample_rate >> 1)) / sbr->sample_rate;
switch (sbr->sample_rate) {
case 16000:
sbr_offset_ptr = sbr_offset[0];
break;
case 22050:
sbr_offset_ptr = sbr_offset[1];
break;
case 24000:
sbr_offset_ptr = sbr_offset[2];
break;
case 32000:
sbr_offset_ptr = sbr_offset[3];
break;
case 44100: case 48000: case 64000:
sbr_offset_ptr = sbr_offset[4];
break;
case 88200: case 96000: case 128000: case 176400: case 192000:
sbr_offset_ptr = sbr_offset[5];
break;
default:
av_log(ac->avctx, AV_LOG_ERROR,
"Unsupported sample rate for SBR: %d\n", sbr->sample_rate);
return -1;
}
sbr->k[0] = start_min + sbr_offset_ptr[spectrum->bs_start_freq];
if (spectrum->bs_stop_freq < 14) {
sbr->k[2] = stop_min;
make_bands(stop_dk, stop_min, 64, 13);
qsort(stop_dk, 13, sizeof(stop_dk[0]), qsort_comparison_function_int16);
for (k = 0; k < spectrum->bs_stop_freq; k++)
sbr->k[2] += stop_dk[k];
} else if (spectrum->bs_stop_freq == 14) {
sbr->k[2] = 2*sbr->k[0];
} else if (spectrum->bs_stop_freq == 15) {
sbr->k[2] = 3*sbr->k[0];
} else {
av_log(ac->avctx, AV_LOG_ERROR,
"Invalid bs_stop_freq: %d\n", spectrum->bs_stop_freq);
return -1;
}
sbr->k[2] = FFMIN(64, sbr->k[2]);
if (sbr->sample_rate <= 32000) {
max_qmf_subbands = 48;
} else if (sbr->sample_rate == 44100) {
max_qmf_subbands = 35;
} else if (sbr->sample_rate >= 48000)
max_qmf_subbands = 32;
if (sbr->k[2] - sbr->k[0] > max_qmf_subbands) {
av_log(ac->avctx, AV_LOG_ERROR,
"Invalid bitstream, too many QMF subbands: %d\n", sbr->k[2] - sbr->k[0]);
return -1;
}
if (!spectrum->bs_freq_scale) {
int dk, k2diff;
dk = spectrum->bs_alter_scale + 1;
sbr->n_master = ((sbr->k[2] - sbr->k[0] + (dk&2)) >> dk) << 1;
if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
return -1;
for (k = 1; k <= sbr->n_master; k++)
sbr->f_master[k] = dk;
k2diff = sbr->k[2] - sbr->k[0] - sbr->n_master * dk;
if (k2diff < 0) {
sbr->f_master[1]--;
sbr->f_master[2]-= (k2diff < -1);
} else if (k2diff) {
sbr->f_master[sbr->n_master]++;
}
sbr->f_master[0] = sbr->k[0];
for (k = 1; k <= sbr->n_master; k++)
sbr->f_master[k] += sbr->f_master[k - 1];
} else {
int half_bands = 7 - spectrum->bs_freq_scale;
int two_regions, num_bands_0;
int vdk0_max, vdk1_min;
int16_t vk0[49];
if (49 * sbr->k[2] > 110 * sbr->k[0]) {
two_regions = 1;
sbr->k[1] = 2 * sbr->k[0];
} else {
two_regions = 0;
sbr->k[1] = sbr->k[2];
}
num_bands_0 = lrintf(half_bands * log2f(sbr->k[1] / (float)sbr->k[0])) * 2;
if (num_bands_0 <= 0) {
av_log(ac->avctx, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0);
return -1;
}
vk0[0] = 0;
make_bands(vk0+1, sbr->k[0], sbr->k[1], num_bands_0);
qsort(vk0 + 1, num_bands_0, sizeof(vk0[1]), qsort_comparison_function_int16);
vdk0_max = vk0[num_bands_0];
vk0[0] = sbr->k[0];
for (k = 1; k <= num_bands_0; k++) {
if (vk0[k] <= 0) {
av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk0[%d]: %d\n", k, vk0[k]);
return -1;
}
vk0[k] += vk0[k-1];
}
if (two_regions) {
int16_t vk1[49];
float invwarp = spectrum->bs_alter_scale ? 0.76923076923076923077f
: 1.0f;
int num_bands_1 = lrintf(half_bands * invwarp *
log2f(sbr->k[2] / (float)sbr->k[1])) * 2;
make_bands(vk1+1, sbr->k[1], sbr->k[2], num_bands_1);
vdk1_min = array_min_int16(vk1 + 1, num_bands_1);
if (vdk1_min < vdk0_max) {
int change;
qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), qsort_comparison_function_int16);
change = FFMIN(vdk0_max - vk1[1], (vk1[num_bands_1] - vk1[1]) >> 1);
vk1[1] += change;
vk1[num_bands_1] -= change;
}
qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), qsort_comparison_function_int16);
vk1[0] = sbr->k[1];
for (k = 1; k <= num_bands_1; k++) {
if (vk1[k] <= 0) {
av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk1[%d]: %d\n", k, vk1[k]);
return -1;
}
vk1[k] += vk1[k-1];
}
sbr->n_master = num_bands_0 + num_bands_1;
if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
return -1;
memcpy(&sbr->f_master[0], vk0,
(num_bands_0 + 1) * sizeof(sbr->f_master[0]));
memcpy(&sbr->f_master[num_bands_0 + 1], vk1 + 1,
num_bands_1 * sizeof(sbr->f_master[0]));
} else {
sbr->n_master = num_bands_0;
if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
return -1;
memcpy(sbr->f_master, vk0, (num_bands_0 + 1) * sizeof(sbr->f_master[0]));
}
}
return 0;
}
| 1threat |
get value of edittext without button event handling in android : <p>I am trying to show my database data into list view. And I want a text box in which user will enter age and according to that age list view will be updated. But I want to filter those result without button event. Is this possible? If so, then how?</p>
| 0debug |
static int expand_rle_row(const uint8_t *in_buf, const uint8_t* in_end,
unsigned char *out_buf, uint8_t* out_end, int pixelstride)
{
unsigned char pixel, count;
unsigned char *orig = out_buf;
while (1) {
if(in_buf + 1 > in_end) return -1;
pixel = bytestream_get_byte(&in_buf);
if (!(count = (pixel & 0x7f))) {
return (out_buf - orig) / pixelstride;
}
if(out_buf + pixelstride * count >= out_end) return -1;
if (pixel & 0x80) {
while (count--) {
*out_buf = bytestream_get_byte(&in_buf);
out_buf += pixelstride;
}
} else {
pixel = bytestream_get_byte(&in_buf);
while (count--) {
*out_buf = pixel;
out_buf += pixelstride;
}
}
}
}
| 1threat |
How to load json with focus event? : I have basic event with `focus` as below:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
(document).on("focus", '#checkin,#checkout', function() {
$.getJSON('data.json', function(data) {
//load here...
});
});
<!-- end snippet -->
and I want to load my json data, actually code is work as expect when I focus on my input .json data has been loading but I see result if I focus on my input twice..
how can I load my json data when I focus my input once ?
[Plunker Demo With Full Project](http://plnkr.co/edit/KPUPjzKG0sooF2WZIc6h?p=preview) | 0debug |
qht_entry_move(struct qht_bucket *to, int i, struct qht_bucket *from, int j)
{
qht_debug_assert(!(to == from && i == j));
qht_debug_assert(to->pointers[i]);
qht_debug_assert(from->pointers[j]);
to->hashes[i] = from->hashes[j];
atomic_set(&to->pointers[i], from->pointers[j]);
from->hashes[j] = 0;
atomic_set(&from->pointers[j], NULL);
}
| 1threat |
static int wav_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
int size;
unsigned int tag;
ByteIOContext *pb = s->pb;
AVStream *st;
WAVContext *wav = s->priv_data;
tag = get_le32(pb);
if (tag != MKTAG('R', 'I', 'F', 'F'))
return -1;
get_le32(pb);
tag = get_le32(pb);
if (tag != MKTAG('W', 'A', 'V', 'E'))
return -1;
size = find_tag(pb, MKTAG('f', 'm', 't', ' '));
if (size < 0)
return -1;
st = av_new_stream(s, 0);
if (!st)
return AVERROR(ENOMEM);
get_wav_header(pb, st->codec, size);
st->need_parsing = AVSTREAM_PARSE_FULL;
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
size = find_tag(pb, MKTAG('d', 'a', 't', 'a'));
if (size < 0)
return -1;
wav->data_end= url_ftell(pb) + size;
return 0;
}
| 1threat |
Is It Mandatory to use npm modules? : I am new to `nodeJs` and trying to understand node features. now I am developing an `angular2` project where i can see every plugin is imported from **npm_modules** folder.
My question is, is it mandatory to import everything from **npm_modules**? what if i have CDN link to be used?
For example, if I want to use **datatable** and i have the links of its CDN(https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js ), rather than using from npm_modules.
| 0debug |
How to add multiple numbers using a method in java? : <p>I have a PHP function for adding multiple numbers,</p>
<pre><code>function add(...$numbers) {
$sum = 0;
$ad = array();
foreach ($numbers as $n) {
$sum += $n;
$ad[] = $n;
}
$ret = "Sum of ".implode(" , ", $ad)." is ".$sum;
return $ret;
}
</code></pre>
<p>what I want is how to convert this PHP function into java method,
THANK YOU VERY MUCH to those who will answer my question.</p>
| 0debug |
How to convert a string to a color hex code with R? : Is there a function which converts a string to a color hex code in R?
For example:
"foo" -> "#F123FA
Converting a number with 4 digits into a hex code would be also totally fine, but the problem is that my numbers are very similar.
Does someone know a good solution in R? | 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.