problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
How to fix the calculation? : So the following is the code that I am working on. Everything works the way that I want it to except for the function "tipConvert(tip)". I want it to change a number, such as 15, into .15 which would be decimal representation of a percentage.
#include <stdio.h>
float tipConvert(int tip);
int main(){
char value;
int intValue tip;
float bill, result;
intValue = 1;
while(intValue == 1)
{
printf("Would you like to calculate a tip: y or n?\n");
scanf("%s", &value);
if(value == 'y')
{
printf("Enter the bill amount:\n");
scanf("%f", &bill);
printf("Enter the tip amount as an integer:\n");
scanf("%i", &tip);
result = tipConvert(tip)*bill;
printf("Tip for %.2f is %.2f\n", bill,result);
}
else if(value == 'n')
{
printf("Thank you for using Tip Calculator.");
break;
}
else
printf("Please select y or n.\n");
}
return 0;
}
float tipConvert(int tip)
{
return tip / 100;
}
| 0debug
|
PYTHON | FIND METHOD : def count_substring(string, sub_string):
count = 0
for i in range(0 , len(string)):
if ( string[i: ].find(sub_string)) == True:
count = count +1
return count
STRING = 'ininini'
SUB_STRING = 'ini'
CORRECT OUTPUT : 3
MY OUTPUT : 2
it is not detecting the last substring.
| 0debug
|
Whats wrong with my python program : <h1>tip and tax calculator</h1>
<pre><code>bill = price + tax + tip
price = raw_input("What is the price of the meal")
tax = price * .06
tip = price * 0.20
</code></pre>
<p>what is wrong with my code
I have tried everything
please answer and get back to me</p>
| 0debug
|
while looping in c languge iteration : ***I don't know where is my mistake, please I need your help. When I enter a wrong data in my username and password and it will ask if YES or NO to try again. If I type Y as a YES I can't type in username anymore. WHY!?***
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main (){
printf ("\n\t\t Welcome To Your Payroll Account!");
printf ("\n\t\t Please Enter Your Username & Password To Proceed.");
printf ("\n\t ********************************************************* \n \n \n");
char password [10], username [10], ch;
char name [10] = "username";
char pass[10] = "password";
char month, ename, address;
float regpay,regov,RD,RDOT,meal;
float SSS,PH,PI,Union,other,SSSsal,Loan,Hloan,ULoan,ELoan,TD;
float TE,Netpay;
int n,day,year,i;
char input;
char again = 'Y';
while (again == 'Y' || again =='y'){
printf("Username: ");
gets (username);
printf("Password: ");
for (i = 0; i<8; i++){
ch = getch();
password[i] = ch;
printf ("*");
}
password[i] = 0;
printf("\n Your password is: ");
for (i =0;i<8;i++){
printf("%c", password[i]);
}
if(strcmp(pass,password) == 0 && strcmp(name,username) == 0){
printf("\n \n You are logged in! \n");
printf("Enter # to proceed \n");
scanf("%c", &input);
}else{
printf("\n \n Incorrect username or password");
printf("\n\n Do you want to try again? YES(Y) / NO(N) \n");
printf("Continue? ");
scanf("%c", &again);
again;
if (again == 'N' || again == 'n'){
system ("pause");
return 0;
}else{
again;
}
}
}
system ("pause");
return 0;
}
| 0debug
|
static BusState *qbus_find(const char *path)
{
DeviceState *dev;
BusState *bus;
char elem[128], msg[256];
int pos, len;
if (path[0] == '/') {
bus = main_system_bus;
pos = 0;
} else {
if (sscanf(path, "%127[^/]%n", elem, &len) != 1) {
qemu_error("path parse error (\"%s\")\n", path);
return NULL;
}
bus = qbus_find_recursive(main_system_bus, elem, NULL);
if (!bus) {
qemu_error("bus \"%s\" not found\n", elem);
return NULL;
}
pos = len;
}
for (;;) {
if (path[pos] == '\0') {
return bus;
}
if (sscanf(path+pos, "/%127[^/]%n", elem, &len) != 1) {
qemu_error("path parse error (\"%s\" pos %d)\n", path, pos);
return NULL;
}
pos += len;
dev = qbus_find_dev(bus, elem);
if (!dev) {
qbus_list_dev(bus, msg, sizeof(msg));
qemu_error("device \"%s\" not found\n%s\n", elem, msg);
return NULL;
}
if (path[pos] == '\0') {
switch (dev->num_child_bus) {
case 0:
qemu_error("device has no child bus (%s)\n", path);
return NULL;
case 1:
return LIST_FIRST(&dev->child_bus);
default:
qbus_list_bus(dev, msg, sizeof(msg));
qemu_error("device has multiple child busses (%s)\n%s\n",
path, msg);
return NULL;
}
}
if (sscanf(path+pos, "/%127[^/]%n", elem, &len) != 1) {
qemu_error("path parse error (\"%s\" pos %d)\n", path, pos);
return NULL;
}
pos += len;
bus = qbus_find_bus(dev, elem);
if (!bus) {
qbus_list_bus(dev, msg, sizeof(msg));
qemu_error("child bus \"%s\" not found\n%s\n", elem, msg);
return NULL;
}
}
}
| 1threat
|
static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode)
{
int fd, ret;
fd = openat_file(dirfd, name, O_RDONLY, 0);
if (fd == -1) {
if (errno == EACCES) {
fd = openat_file(dirfd, name, O_WRONLY, 0);
}
if (fd == -1 && errno == EISDIR) {
errno = EACCES;
}
}
if (fd == -1) {
return -1;
}
ret = fchmod(fd, mode);
close_preserve_errno(fd);
return ret;
}
| 1threat
|
Android @Intdef for flags how to use it : <p>I am not clear how to use @Intdef when making it a flag like this:</p>
<pre><code>@IntDef(
flag = true
value = {NAVIGATION_MODE_STANDARD, NAVIGATION_MODE_LIST, NAVIGATION_MODE_TABS})
</code></pre>
<p>this example is straight from the <a href="http://developer.android.com/reference/android/support/annotation/IntDef.html" rel="noreferrer">docs</a>. What does this actually mean ? does it mean all of them are initially set to true ? if i do a "or" on the following:</p>
<pre><code>NAVIGATION_MODE_STANDARD | NAVIGATION_MODE_LIST
</code></pre>
<p>what does it mean ...im a little confused whats happening here. </p>
| 0debug
|
ggsave(): Error in UseMethod("grid.draw") : no applicable method for 'grid.draw' applied to an object of class "character" : <p>I am trying to save a plot with <code>ggsave()</code>. I enter the following:</p>
<pre><code>library(ggplot2)
Test = data.frame("X" = seq(1, 10, 1), "Y" = 2*seq(1, 10, 1))
P = ggplot(
Test, aes(x=X, y=Y))+
geom_line()
ggsave(P, "test.pdf", device = "pdf")
</code></pre>
<p>But get the error:</p>
<pre><code>Saving 7 x 7 in image
Error in UseMethod("grid.draw") :
no applicable method for 'grid.draw' applied to an object of class "character"
</code></pre>
| 0debug
|
vorbis_header (AVFormatContext * s, int idx)
{
ogg_t *ogg = s->priv_data;
ogg_stream_t *os = ogg->streams + idx;
AVStream *st = s->streams[idx];
oggvorbis_private_t *priv;
if (os->seq > 2)
return 0;
if (os->seq == 0) {
os->private = av_mallocz(sizeof(oggvorbis_private_t));
if (!os->private)
return 0;
}
priv = os->private;
priv->len[os->seq] = os->psize;
priv->packet[os->seq] = av_mallocz(os->psize);
memcpy(priv->packet[os->seq], os->buf + os->pstart, os->psize);
if (os->buf[os->pstart] == 1) {
uint8_t *p = os->buf + os->pstart + 11;
st->codec->channels = *p++;
st->codec->sample_rate = AV_RL32(p);
p += 8;
st->codec->bit_rate = AV_RL32(p);
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_VORBIS;
st->time_base.num = 1;
st->time_base.den = st->codec->sample_rate;
} else if (os->buf[os->pstart] == 3) {
vorbis_comment (s, os->buf + os->pstart + 7, os->psize - 8);
} else {
st->codec->extradata_size =
fixup_vorbis_headers(s, priv, &st->codec->extradata);
}
return os->seq < 3;
}
| 1threat
|
static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt)
{
LavfiContext *lavfi = avctx->priv_data;
double min_pts = DBL_MAX;
int stream_idx, min_pts_sink_idx = 0;
AVFilterBufferRef *ref;
AVPicture pict;
int ret, i;
int size = 0;
for (i = 0; i < avctx->nb_streams; i++) {
AVRational tb = lavfi->sinks[i]->inputs[0]->time_base;
double d;
int ret;
if (lavfi->sink_eof[i])
continue;
ret = av_buffersink_get_buffer_ref(lavfi->sinks[i],
&ref, AV_BUFFERSINK_FLAG_PEEK);
if (ret == AVERROR_EOF) {
av_dlog(avctx, "EOF sink_idx:%d\n", i);
lavfi->sink_eof[i] = 1;
continue;
} else if (ret < 0)
return ret;
d = av_rescale_q(ref->pts, tb, AV_TIME_BASE_Q);
av_dlog(avctx, "sink_idx:%d time:%f\n", i, d);
if (d < min_pts) {
min_pts = d;
min_pts_sink_idx = i;
}
}
if (min_pts == DBL_MAX)
return AVERROR_EOF;
av_dlog(avctx, "min_pts_sink_idx:%i\n", min_pts_sink_idx);
av_buffersink_get_buffer_ref(lavfi->sinks[min_pts_sink_idx], &ref, 0);
stream_idx = lavfi->sink_stream_map[min_pts_sink_idx];
if (ref->video) {
size = avpicture_get_size(ref->format, ref->video->w, ref->video->h);
if ((ret = av_new_packet(pkt, size)) < 0)
return ret;
memcpy(pict.data, ref->data, 4*sizeof(ref->data[0]));
memcpy(pict.linesize, ref->linesize, 4*sizeof(ref->linesize[0]));
avpicture_layout(&pict, ref->format, ref->video->w,
ref->video->h, pkt->data, size);
} else if (ref->audio) {
size = ref->audio->nb_samples *
av_get_bytes_per_sample(ref->format) *
av_get_channel_layout_nb_channels(ref->audio->channel_layout);
if ((ret = av_new_packet(pkt, size)) < 0)
return ret;
memcpy(pkt->data, ref->data[0], size);
}
if (ref->metadata) {
uint8_t *metadata;
AVDictionaryEntry *e = NULL;
AVBPrint meta_buf;
av_bprint_init(&meta_buf, 0, AV_BPRINT_SIZE_UNLIMITED);
while ((e = av_dict_get(ref->metadata, "", e, AV_DICT_IGNORE_SUFFIX))) {
av_bprintf(&meta_buf, "%s", e->key);
av_bprint_chars(&meta_buf, '\0', 1);
av_bprintf(&meta_buf, "%s", e->value);
av_bprint_chars(&meta_buf, '\0', 1);
}
if (!av_bprint_is_complete(&meta_buf) ||
!(metadata = av_packet_new_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA,
meta_buf.len))) {
av_bprint_finalize(&meta_buf, NULL);
return AVERROR(ENOMEM);
}
memcpy(metadata, meta_buf.str, meta_buf.len);
av_bprint_finalize(&meta_buf, NULL);
}
pkt->stream_index = stream_idx;
pkt->pts = ref->pts;
pkt->pos = ref->pos;
pkt->size = size;
avfilter_unref_buffer(ref);
return size;
}
| 1threat
|
problems with if in a function [python] : I am doing a simple program just to the program say if a number is even or not and to when the raw_input isn't a number, the program will complain about it:
def f():
t = raw_input('Enter a number and we will send an inormation: ')
if t != type(int):
print 'is this a number?'
elif int(t) % 2 == 0:
print t
print 'it is an even number'
elif int(t) % 2 > 0:
print t
print 'it is an odd number'
else:
print '???'
but when the program run it returns ONLY the if condition (when i write 90 or a word it returns 'is this a number?'. it should only return this if I Write a string). And I can't figure out where is the problem.
| 0debug
|
Interactive android apps : <p>I am new to Android App Development. I am trying to build an interactive app where there are two screens. On the first screen there will be a button. When the button is touched, then another screen will appear. I have already made the first screen. But how do I link the second screen to the first screen? Please help.</p>
| 0debug
|
How to turn on User Location - Blue Dot : <p>I'm playing with this example - <a href="https://www.raywenderlich.com/425-mapkit-tutorial-overlay-views" rel="nofollow noreferrer">https://www.raywenderlich.com/425-mapkit-tutorial-overlay-views</a></p>
<p>But how do I turn on User Location? (Blue dot)</p>
<p>Thanks</p>
| 0debug
|
How can I check if a sequence of numbers is a fibonnaci sequence and obtain the next value In R? : <p>How can we create a function to do this? So given these numbers, how can we check whether they are in fact a fibonacci sequence and then predict the next value in the sequence?</p>
<p>1 1 2 3 5<br>
1 2 3 5 8<br>
2 3 5 8 13<br>
3 5 8 13 21<br>
5 8 13 21 34<br>
8 13 21 34 55<br>
13 21 34 55 89<br>
21 34 55 89 144<br>
34 55 89 144 233</p>
| 0debug
|
How to insert method in object in javscript and call it? : I've been looking for how to properly format a method in an object in javscript and how to execute it I keep getting errors and dont Know how to call a method console keeps giving me errors so I just wanted to ask if anyone knows how to properly place a method in an object and how to call it.
| 0debug
|
static size_t qemu_rdma_save_page(QEMUFile *f, void *opaque,
ram_addr_t block_offset, ram_addr_t offset,
size_t size, int *bytes_sent)
{
QEMUFileRDMA *rfile = opaque;
RDMAContext *rdma = rfile->rdma;
int ret;
CHECK_ERROR_STATE();
qemu_fflush(f);
if (size > 0) {
ret = qemu_rdma_write(f, rdma, block_offset, offset, size);
if (ret < 0) {
fprintf(stderr, "rdma migration: write error! %d\n", ret);
goto err;
}
if (bytes_sent) {
*bytes_sent = 1;
}
} else {
uint64_t index, chunk;
ret = qemu_rdma_search_ram_block(rdma, block_offset,
offset, size, &index, &chunk);
if (ret) {
fprintf(stderr, "ram block search failed\n");
goto err;
}
qemu_rdma_signal_unregister(rdma, index, chunk, 0);
}
while (1) {
uint64_t wr_id, wr_id_in;
int ret = qemu_rdma_poll(rdma, &wr_id_in);
if (ret < 0) {
fprintf(stderr, "rdma migration: polling error! %d\n", ret);
goto err;
}
wr_id = wr_id_in & RDMA_WRID_TYPE_MASK;
if (wr_id == RDMA_WRID_NONE) {
break;
}
}
return RAM_SAVE_CONTROL_DELAYED;
err:
rdma->error_state = ret;
return ret;
}
| 1threat
|
Can't make thread from a function in another file : <p>I have two files. <strong>sim.c</strong> and <strong>devices.c</strong>.</p>
<p>Here's the <strong>sim.c</strong> </p>
<pre><code>...
#include "devices.h"
int main(int argc, char **argv) {
pthread_t *tid;
tid = (pthread_t *) malloc(sizeof(pthread_t) * 3);
// this is where I start the 3 threads located in devices.c
if (pthread_create(&tid[0], NULL, device_one, NULL)) {
exit(1);
}
if (pthread_create(&tid[1], NULL, device_two, NULL)) {
exit(1);
}
if (pthread_create(&tid[2], NULL, device_three, NULL)) {
exit(1);
}
// wait for 3 threads to finish
int i;
for (i = 0; i < 3; i++) {
if (pthread_join(tid[i], NULL)) {
exit(1);
}
}
}
</code></pre>
<p>Here's <strong>devices.c</strong> </p>
<pre><code>...
#include "devices.h"
extern void *device_one(void *arg) {
printf("device one is called\n");
return NULL;
}
extern void *device_two(void *arg) {
printf("device two is called\n");
return NULL;
}
extern void *device_three(void *arg) {
printf("device three is called\n");
return NULL;
}
</code></pre>
<p>And here's <strong>devices.h</strong> </p>
<pre><code>#ifndef DEVICES_H
#define DEVICES_H
extern void *device_one(void *arg);
extern void *device_two(void *arg);
extern void *device_three(void *arg);
</code></pre>
<p>However, when I compile, I get 3 errors under sim.c saying<br>
<em>undefined reference to 'device_one'<br>
undefined reference to 'device_two'<br>
undefined reference to 'device_three'</em></p>
| 0debug
|
static inline float to_float(uint8_t exp, int16_t mantissa)
{
return ((float) (mantissa * scale_factors[exp]));
}
| 1threat
|
static void pxb_dev_realize(PCIDevice *dev, Error **errp)
{
if (pci_bus_is_express(dev->bus)) {
error_setg(errp, "pxb devices cannot reside on a PCIe bus");
return;
}
pxb_dev_realize_common(dev, false, errp);
}
| 1threat
|
Why the "m" after assigning a vale to a decimal? : <p>In the C# language, why would a decimal data type require an "m" at the end of the value? Would simply not just declaring the data type as 'decimal' be enough as is the case with other numeric data types such as 'int' or 'double'? (I'm new to this and am just curious as it seems to go against my own sense of logical behavior).</p>
<pre><code>{
decimal variableName = 489872.76m; //<---
double variableName = 39.768;
int variableName = 14;
}
</code></pre>
| 0debug
|
I want to translate english text to hindi using followong API : **Following is my TextActivity**
package com.ds.texar;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
import com.google.api.translate.Language;
import com.google.api.translate.Translate;
import java.util.Locale;
import java.util.concurrent.ExecutionException;
public class TextActivity extends AppCompatActivity {
Context context;
TextToSpeech textToSpeech;
private String textFromMain = "";
ToggleButton languageToggleButton;
private String outputHindiString = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_text);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//setting text string received from main activity
final TextView textView = (TextView)findViewById(R.id.mtextview);
textFromMain = getIntent().getStringExtra("mytext");
textView.setText(textFromMain);
context = getApplicationContext();
textToSpeech = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener(){
@Override
public void onInit(int status) {
if(status != TextToSpeech.ERROR) {
textToSpeech.setLanguage(Locale.UK);
}
}
});
languageToggleButton = (ToggleButton) findViewById(R.id.language_toggle_button);
languageToggleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(languageToggleButton.isChecked()){
try {
Translate.setHttpReferrer("http://android-er.blogspot.com/");
outputHindiString = Translate.execute(textFromMain,
Language.ENGLISH, Language.HINDI);
} catch (Exception ex) {
ex.printStackTrace();
outputHindiString = "Error";
}
textView.setText(outputHindiString);
}
else{
textView.setText(textFromMain);
}
}
});
FloatingActionButton copyText = (FloatingActionButton) findViewById(R.id.copy_text);
copyText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
// .setAction("Action", null).show();
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("myText", textFromMain);
clipboard.setPrimaryClip(clip);
Toast.makeText(context, "Your text copied.", Toast.LENGTH_SHORT).show();
// toast.setGravity(Gravity.TOP| Gravity.LEFT, 10, 300);
// toast.show();
}
});
final FloatingActionButton textToSpeechButton = (FloatingActionButton) findViewById(R.id.text_to_speech);
textToSpeechButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Toast.makeText(getApplicationContext(), textFromMain, Toast.LENGTH_SHORT).show();
textToSpeech.speak(textFromMain, TextToSpeech.QUEUE_FLUSH, null, null);
}
});
}
@Override
public void onPause(){
if(textToSpeech !=null){
textToSpeech.stop();
textToSpeech.shutdown();
}
super.onPause();
}
}
Here is Layout xml file
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.ds.texar.TextActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include
android:id="@+id/include2"
layout="@layout/content_text" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/text_to_speech"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|end"
app:srcCompat="@android:drawable/ic_lock_silent_mode_off" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/copy_text"
android:layout_width="51dp"
android:layout_height="55dp"
android:layout_gravity="top|left"
android:layout_margin="16dp"
android:clickable="true"
app:fabSize="mini"
app:layout_anchor="@+id/include2"
app:layout_anchorGravity="bottom|right"
app:srcCompat="?attr/actionModeCopyDrawable" />
<ToggleButton
android:id="@+id/language_toggle_button"
android:layout_width="65dp"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
android:layout_margin="16dp"
android:background="@drawable/check"
android:textOff=""
android:textOn=""
android:focusable="false"
android:focusableInTouchMode="false"
app:layout_anchor="@+id/include2"
app:layout_anchorGravity="bottom|center_horizontal" />
</android.support.design.widget.CoordinatorLayout>
Here is AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ds.texar">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.sensor.accelerometer" />
<uses-feature android:name="android.hardware.sensor.light" />
<meta-data
android:name="com.google.android.gms.vision.DEPENDENCIES"
android:value="ocr" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".TextActivity"
android:label="@string/title_activity_text"
android:theme="@style/AppTheme.NoActionBar"></activity>
</application>
</manifest>
Error log:
> Information:Gradle tasks [:app:generateDebugSources,
> :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies,
> :app:generateDebugAndroidTestSources, :app:compileDebugSources,
> :app:compileDebugUnitTestSources, :app:compileDebugAndroidTestSources]
> C:\Users\DELL_PC\Desktop\Texar\app\src\main\java\com\ds\texar\TextActivity.java
> Error:(16, 32) error: package com.google.api.translate does not exist
> Error:(17, 32) error: package com.google.api.translate does not exist
> Error:(58, 29) error: cannot find symbol variable Translate Error:(60,
> 37) error: cannot find symbol variable Language Error:(60, 55) error:
> cannot find symbol variable Language Error:(59, 49) error: cannot find
> symbol variable Translate Error:Execution failed for task
> ':app:compileDebugJavaWithJavac'.
> > Compilation failed; see the compiler error output for details. Information:BUILD FAILED Information:Total time: 6.836 secs
> Information:7 errors Information:0 warnings Information:See complete
> output in console
| 0debug
|
SQL query with prp stmts? : i cant print this sql select query, can someone help me ? , i cant see the error, all the link connection are good
<?php
$strsql = "SELECT `time` FROM tssa_banner_central WHERE where co=$codigo'
";
mysqli_fetch_row(execute($strsql));
?>
| 0debug
|
how to get data to dropdownlist from database in html view : I am creating an web page in which i have a drop_down_list. i have to retrieve data for the drop_down_list from the database. is there any way to get data from the database to the html view my html code.`<select name="drop down"><option value="1">@test.list[i]</option></select>`
i got the database value to the list variable.but i don't know how to pass the data to the html view. help in this issue.
| 0debug
|
Getting the last day of month : <p>I need to write a function which returns which day of the week is the last day of the ongoing month. I can get the last day so far but I don't know how to know which day of the week it is.</p>
| 0debug
|
static void spapr_cpu_init(sPAPRMachineState *spapr, PowerPCCPU *cpu,
Error **errp)
{
CPUPPCState *env = &cpu->env;
CPUState *cs = CPU(cpu);
int i;
cpu_ppc_tb_init(env, SPAPR_TIMEBASE_FREQ);
cpu_ppc_set_papr(cpu);
if (cpu->max_compat) {
Error *local_err = NULL;
ppc_set_compat(cpu, cpu->max_compat, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
}
i = numa_get_node_for_cpu(cs->cpu_index);
if (i < nb_numa_nodes) {
cs->numa_node = i;
}
xics_cpu_setup(spapr->xics, cpu);
qemu_register_reset(spapr_cpu_reset, cpu);
spapr_cpu_reset(cpu);
}
| 1threat
|
How do I set the starting position of my turtle of my turtle in python to the bottom left of my screen? : Greetings people of Stackoverflow! Currently, I am working on a project that involves turtles. And I have been trying to find a way to make the turtle start at the bottom left of my screen, as opposed to the coordinates (0,0).
#My Code
import turtle
turtle.setworldcoordinates(-1, -1, 20, 20)
turtle.fd(250)
turtle.rt(90)
turtle.fd(250)
When I tried looking for solutions, I came across a thread from [Stack][1] that suggested multiple ways to solve the problem, such as the `turtle.setworldcoordinates(-1, -1, 20, 20)` references in my code. If anyone has an idea or a soltion, could they please let me know ASAP.
Thanks
Kermit
[1]: https://stackoverflow.com/questions/14713037/python-turtle-set-start-position
| 0debug
|
Create the American flag with html tables : How would i make an american flag out of a table?
I need the stars to be asterisks. Is it possible to just use one table? Do the cells need to have something in it I’ve tried but the stripes won’t work without something in them.
| 0debug
|
static CharDriverState* create_eventfd_chr_device(IVShmemState *s,
EventNotifier *n,
int vector)
{
PCIDevice *pdev = PCI_DEVICE(s);
int eventfd = event_notifier_get_fd(n);
CharDriverState *chr;
s->msi_vectors[vector].pdev = pdev;
chr = qemu_chr_open_eventfd(eventfd);
if (chr == NULL) {
error_report("creating chardriver for eventfd %d failed", eventfd);
return NULL;
}
qemu_chr_fe_claim_no_fail(chr);
if (ivshmem_has_feature(s, IVSHMEM_MSI)) {
s->msi_vectors[vector].pdev = PCI_DEVICE(s);
qemu_chr_add_handlers(chr, ivshmem_can_receive, fake_irqfd,
ivshmem_event, &s->msi_vectors[vector]);
} else {
qemu_chr_add_handlers(chr, ivshmem_can_receive, ivshmem_receive,
ivshmem_event, s);
}
return chr;
}
| 1threat
|
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
| 1threat
|
Specify @Input() parameter for Angular root component/module : <p>I have 3 root components that get bootstrapped by the root <code>AppModule</code>.</p>
<p>How do you go about specifying an <code>@Input()</code> parameter to one of those components?</p>
<p>Neither</p>
<pre><code><app-modal [id]="'hard-coded value'"></app-modal>
<app-modal [id]="constantExportedByAppmodule"></app-modal>
</code></pre>
<p>are picked up by <code>AppModalComponent</code>:</p>
<pre><code>@Input() id: string;
</code></pre>
<p>It is undefined.</p>
| 0debug
|
React Hooks and POST method : <p>I need to understand how can I setup a custom hook in React, for a POST method.</p>
<p>If I need to POST some data after a click, but I can't use the custom hook in an event handler, how can I do It?</p>
<p>I made a custom Hook with all the fetch logic and the relative reducers... but I dunno how to use It in a click, without breaking the rules.</p>
<p>Thanks.</p>
| 0debug
|
I want to concole.log the text of the h2 tag whenever users clicks the tag and when clicks another h2 tag it should display the text of that h2 tag : <p>I want to concole.log the text of the h2 tag whenever users clicks the tag and when clicks another h2 tag it should display the text of that h2 tag the class and id of the tags are same.. </p>
| 0debug
|
SafeValue must use [property]=binding: : <p>I got the following error inside my input:</p>
<pre><code>SafeValue must use [property]=binding: http://www.myurl.com (see http://g.co/ng/security#xss)
</code></pre>
<p>I did in my component: </p>
<pre><code>this.myInputURL = this.sanitizer.bypassSecurityTrustUrl('http://www.myurl.com');
</code></pre>
<p>And in my template:</p>
<pre><code>Share URL: <md-input [value]="myInputURL" type="text"></md-input>
</code></pre>
<p>What's wrong?</p>
| 0debug
|
Which is best pdf viewer in android? : <p>Which is best pdf viewer in android? Jio magzine which pdf viewer used?</p>
| 0debug
|
How do you call .Distinct() on an Array of objects : <p>So in the controller, I accept a list of objects as follows:</p>
<pre><code> public virtual ActionResult Grid_Read([DataSourceRequest]DataSourceRequest request, IEnumerable<ObjDTO> objects)
{
var DistinctList = objects.Distinct();
return Json(DistinctList.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
</code></pre>
<p>But the .Distinct() does nothing to the list.</p>
| 0debug
|
How to get average, minimum and maximum with fewer database round-trips? : <p>In an ASP.NET Core Razor Pages application, using Entity Framework Core, I'm using the code below to populate a list with average, minimum and maximum values from a database. While this works OK with the relatively small volume of data recorded so far, I don't think it's going to scale well as the volume of data grows. Is there a more efficient way to do this in the application, or should I forget about doing it in the application code and get it from a stored procedure instead?</p>
<pre class="lang-cs prettyprint-override"><code>ServerStatsList = _context
.PerfLog
.Select(l => new ServerStats {
CompanyName = l.CompanyName,
ServerName = l.ServerName,
Average = 0,
Minimum = 0,
Maximum = 0
})
.Distinct()
.ToList();
foreach (ServerStats s in ServerStatsList)
{
s.Average = _context
.PerfLog
.Where(l => l.CompanyName == s.CompanyName && l.ServerName == s.ServerName)
.Average(l => l.MemoryAvailableMBytes);
s.Minimum = _context
.PerfLog
.Where(l => l.CompanyName == s.CompanyName && l.ServerName == s.ServerName)
.Min(l => l.MemoryAvailableMBytes);
s.Maximum = _context
.PerfLog
.Where(l => l.CompanyName == s.CompanyName && l.ServerName == s.ServerName)
.Max(l => l.MemoryAvailableMBytes);
}
</code></pre>
| 0debug
|
static void jpeg_prepare_row24(VncState *vs, uint8_t *dst, int x, int y,
int count)
{
VncDisplay *vd = vs->vd;
uint32_t *fbptr;
uint32_t pix;
fbptr = (uint32_t *)(vd->server->data + y * ds_get_linesize(vs->ds) +
x * ds_get_bytes_per_pixel(vs->ds));
while (count--) {
pix = *fbptr++;
*dst++ = (uint8_t)(pix >> vs->ds->surface->pf.rshift);
*dst++ = (uint8_t)(pix >> vs->ds->surface->pf.gshift);
*dst++ = (uint8_t)(pix >> vs->ds->surface->pf.bshift);
}
}
| 1threat
|
C language, How can I Convert Number to String? : <p>if I've a large number stored in 10 bytes of memory, how can I convert this number to string? like How do C %d converts number to string?</p>
<p>I'm not looking for some library or function, I wan't to know how to convert large byte numbers to string, that is what i need to know.</p>
| 0debug
|
static void z2_init(MachineState *machine)
{
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
MemoryRegion *address_space_mem = get_system_memory();
uint32_t sector_len = 0x10000;
PXA2xxState *mpu;
DriveInfo *dinfo;
int be;
void *z2_lcd;
I2CBus *bus;
DeviceState *wm;
if (!cpu_model) {
cpu_model = "pxa270-c5";
}
mpu = pxa270_init(address_space_mem, z2_binfo.ram_size, cpu_model);
#ifdef TARGET_WORDS_BIGENDIAN
be = 1;
#else
be = 0;
#endif
dinfo = drive_get(IF_PFLASH, 0, 0);
if (!dinfo && !qtest_enabled()) {
fprintf(stderr, "Flash image must be given with the "
"'pflash' parameter\n");
exit(1);
}
if (!pflash_cfi01_register(Z2_FLASH_BASE,
NULL, "z2.flash0", Z2_FLASH_SIZE,
dinfo ? blk_bs(blk_by_legacy_dinfo(dinfo)) : NULL,
sector_len, Z2_FLASH_SIZE / sector_len,
4, 0, 0, 0, 0, be)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
exit(1);
}
pxa27x_register_keypad(mpu->kp, map, 0x100);
pxa2xx_mmci_handlers(mpu->mmc,
NULL,
qdev_get_gpio_in(mpu->gpio, Z2_GPIO_SD_DETECT));
type_register_static(&zipit_lcd_info);
type_register_static(&aer915_info);
z2_lcd = ssi_create_slave(mpu->ssp[1], "zipit-lcd");
bus = pxa2xx_i2c_bus(mpu->i2c[0]);
i2c_create_slave(bus, TYPE_AER915, 0x55);
wm = i2c_create_slave(bus, "wm8750", 0x1b);
mpu->i2s->opaque = wm;
mpu->i2s->codec_out = wm8750_dac_dat;
mpu->i2s->codec_in = wm8750_adc_dat;
wm8750_data_req_set(wm, mpu->i2s->data_req, mpu->i2s);
qdev_connect_gpio_out(mpu->gpio, Z2_GPIO_LCD_CS,
qemu_allocate_irq(z2_lcd_cs, z2_lcd, 0));
z2_binfo.kernel_filename = kernel_filename;
z2_binfo.kernel_cmdline = kernel_cmdline;
z2_binfo.initrd_filename = initrd_filename;
z2_binfo.board_id = 0x6dd;
arm_load_kernel(mpu->cpu, &z2_binfo);
}
| 1threat
|
How do I indicate to a screen reader that a time is hours and minutes, not minutes and seconds? : <p>I've got the following fragment of markup in a webpage:</p>
<pre><code>Time spent: <span id="time_spent">00:02</span>
</code></pre>
<p>JAWS reads this as "Time spent colon zero minutes and two seconds". How do I indicate to JAWS that this should be read as "zero hours and two minutes" (or just plain "two minutes")? Ideally, any solution would also work with other screen readers as well.</p>
| 0debug
|
static void qcow2_close(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
g_free(s->l1_table);
s->l1_table = NULL;
if (!(bs->open_flags & BDRV_O_INCOMING)) {
qcow2_cache_flush(bs, s->l2_table_cache);
qcow2_cache_flush(bs, s->refcount_block_cache);
qcow2_mark_clean(bs);
}
qcow2_cache_destroy(bs, s->l2_table_cache);
qcow2_cache_destroy(bs, s->refcount_block_cache);
g_free(s->unknown_header_fields);
cleanup_unknown_header_ext(bs);
g_free(s->cluster_cache);
qemu_vfree(s->cluster_data);
qcow2_refcount_close(bs);
qcow2_free_snapshots(bs);
}
| 1threat
|
def prime_num(num):
if num >=1:
for i in range(2, num//2):
if (num % i) == 0:
return False
else:
return True
else:
return False
| 0debug
|
R line chart from columns : any ideas how to create a Line chart? I tried but I got some error. my screenshot below there is a chart from Google Data studio and I want to re-create it in R.
I tried to run this code but I got an error:
plot(data[,1], data[,2],'l',col='blue')
where I think data[,1] <-- is the 'send time' from my column.
and data[,2] <-- is the 'open rate' I doubt that's correct but please help.
please see screenshot:
[see screenshot][1]
[1]: https://i.stack.imgur.com/SeQvP.jpg
| 0debug
|
How to write a form that catches all errors,c#? : I want to write a form in my Windows Application Solution that catches all the error and instead of showing that ugly error page shows me sth beatifully designed (by myself)?
Thanks for your answer in advance.
| 0debug
|
Error: Please select Android SDK in Android Studio 2.0 : <p>I am using Android Studio 2.0 Beta2, and i am trying to run old project that uses google maps api v1 (package <em>com.google.android.maps</em>) as *.jar file. To run this old project i need specify compileSdkVersion older than the last one (23). I used </p>
<pre><code>compileSdkVersion 'Google Inc.:Google APIs:17'
</code></pre>
<p>But i got <strong>Error: Please select Android SDK</strong> error in Android Studio. How i can run this old project with older compileSdkVersion?</p>
| 0debug
|
Iam Applying Autolayouts programatically But i received below type of message Can anyone pls help me : Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x7f844b716390 H:|-(30)-[UIButton:0x7f844b4be3c0'LOGIN'] (Names: '|':UIView:0x7f844b492a80 )>",
"<NSLayoutConstraint:0x7f844b706ee0 H:[UIButton:0x7f844b4be3c0'LOGIN'(100)]>",
"<NSLayoutConstraint:0x7f844b705dd0 H:[UIButton:0x7f844b4be3c0'LOGIN']-(80)-[UIButton:0x7f844b4c0520'SIGNUP']>",
"<NSLayoutConstraint:0x7f844b706f30 H:[UIButton:0x7f844b4c0520'SIGNUP'(100)]>",
"<NSLayoutConstraint:0x7f844b7147c0 H:[UIButton:0x7f844b4c0520'SIGNUP']-(30)-| (Names: '|':UIView:0x7f844b492a80 )>",
"<NSLayoutConstraint:0x7f844b519f70 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7f844b492a80(375)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7f844b705dd0 H:[UIButton:0x7f844b4be3c0'LOGIN']-(80)-[UIButton:0x7f844b4c0520'SIGNUP']>
| 0debug
|
void audio_init(ISABus *isa_bus, PCIBus *pci_bus)
{
}
| 1threat
|
can i use GET method instead of POST method in SpringMVC? : <p>In SpringMVC if suppose I can use POST method instead of the GET method and it works. Then what is the purpose of these methods and how can we differentiate these methods.</p>
| 0debug
|
Can I use property name of object as parameter? : <p>I want to make Favorite module in my app. I'm using React-native and Firestore. Here is my code:</p>
<pre><code>addFavorite() {
getPlaceName().doc(this.selectedPlaceName.id).set({
favorite: {
uid : true
}
}, { merge: true }).then(() => {
console.log('Added')
}).catch((e) => {
console.log('error', e)
})
}
removeFavorite() {
getPlaceName().doc(this.selectedPlaceName.id).set({
favorite: {
uid: false
}
}, { merge: true }).then(() => {
console.log('Removed')
}).catch((e) => {
console.log('error', e)
})
}
</code></pre>
<p>I store Favorite as a map in Firestore:</p>
<pre><code>favorite: {
u001: true,
u002: false}
</code></pre>
<p>So are there any ways to achieve it? Or do you guys have any other ideas how to get this favorite thing done?</p>
| 0debug
|
Curl is configured to use SSL, but we have not been able to determine which SSL backend it is using : <p>When I perform <code>pip install thumbor</code> I get the following error:</p>
<pre><code>Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/t9/***********************/T/pip-install-knrabyuy/pycurl/setup.py", line 913, in <module>
ext = get_extension(sys.argv, split_extension_source=split_extension_source)
File "/private/var/folders/t9/***********************/T/pip-install-knrabyuy/pycurl/setup.py", line 582, in get_extension
ext_config = ExtensionConfiguration(argv)
File "/private/var/folders/t9/***********************/T/pip-install-knrabyuy/pycurl/setup.py", line 99, in __init__
self.configure()
File "/private/var/folders/t9/***********************/T/pip-install-knrabyuy/pycurl/setup.py", line 316, in configure_unix
specify the SSL backend manually.''')
__main__.ConfigurationError: Curl is configured to use SSL, but we have not been able to determine which SSL backend it is using. Please see PycURL documentation for how to specify the SSL backend manually.
</code></pre>
<p>I've tried <code>brew install curl</code> (which was successfull) however I get the same error when I perform <code>pip install thumbor</code>.</p>
<p>Any idea why?</p>
| 0debug
|
Best way to remove unknown characters and spaces using C#? : <p>Unknown Characters:</p>
<p>|b9-12-2016,¢Xocoak¡LO2A35(2)(b)¡ÓocORe3ao-i|],¢Xa?u¡±o¡±i?¢X$3,597,669On 9-12-2016, the price adjusted to $3,597,669 dueto the reason allowed under section 35(2)(b) of theOrdinance</p>
<p>Good Result:</p>
<p>$3,597,669On 9-12-2016, the price adjusted to $3,597,669 due to the reason allowed under section 35 of the Ordinance</p>
| 0debug
|
Quadratic Formula without import math : <p>Can somebody help me write a code using python 3 that can solve the quadratic formula without using "import math"? Please !</p>
| 0debug
|
How to set $path for node.js? : First of all, I know no node.js or any command line commands. Second of all, I am using Windows XP. So another question that I have is what is the latest version of Windows XP? I know that this is a noob question so please don't dislike for this reason because the I know nothing about what I am asking.
I need to this because a lot of sublime text 3 build 3126 plugins are putting node.js as a requirement (the most important ones being the linting tools, especially js-hint.) Also, how do I the same for tidy-html (does not require node.js but does require $path set to the tidy-html app)? They are all part of SublimeLinter framework.
| 0debug
|
How to backspace or delete? : <p>In Windows 10, when I launch MS PowerShell to ssh through a container in Kitematic at windows, I've noticed that I can't backspace or delete, instead I get ^H for backspace instead of actually delete previous character.</p>
<p>Do I miss something?</p>
| 0debug
|
static int mjpeg_decode_app(MJpegDecodeContext *s)
{
int len, id, i;
len = get_bits(&s->gb, 16);
if (len < 6)
return AVERROR_INVALIDDATA;
if (8 * len > get_bits_left(&s->gb))
return AVERROR_INVALIDDATA;
id = get_bits_long(&s->gb, 32);
len -= 6;
if (s->avctx->debug & FF_DEBUG_STARTCODE) {
char id_str[32];
av_get_codec_tag_string(id_str, sizeof(id_str), av_bswap32(id));
av_log(s->avctx, AV_LOG_DEBUG, "APPx (%s / %8X) len=%d\n", id_str, id, len);
}
if (id == AV_RB32("AVI1")) {
s->buggy_avid = 1;
i = get_bits(&s->gb, 8); len--;
av_log(s->avctx, AV_LOG_DEBUG, "polarity %d\n", i);
#if 0
skip_bits(&s->gb, 8);
skip_bits(&s->gb, 32);
skip_bits(&s->gb, 32);
len -= 10;
#endif
}
if (id == AV_RB32("JFIF")) {
int t_w, t_h, v1, v2;
skip_bits(&s->gb, 8);
v1 = get_bits(&s->gb, 8);
v2 = get_bits(&s->gb, 8);
skip_bits(&s->gb, 8);
s->avctx->sample_aspect_ratio.num = get_bits(&s->gb, 16);
s->avctx->sample_aspect_ratio.den = get_bits(&s->gb, 16);
if ( s->avctx->sample_aspect_ratio.num <= 0
|| s->avctx->sample_aspect_ratio.den <= 0) {
s->avctx->sample_aspect_ratio.num = 0;
s->avctx->sample_aspect_ratio.den = 1;
}
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO,
"mjpeg: JFIF header found (version: %x.%x) SAR=%d/%d\n",
v1, v2,
s->avctx->sample_aspect_ratio.num,
s->avctx->sample_aspect_ratio.den);
len -= 8;
if (len >= 2) {
t_w = get_bits(&s->gb, 8);
t_h = get_bits(&s->gb, 8);
if (t_w && t_h) {
if (len -10 - (t_w * t_h * 3) > 0)
len -= t_w * t_h * 3;
}
len -= 2;
}
}
if ( id == AV_RB32("Adob")
&& len >= 7
&& show_bits(&s->gb, 8) == 'e'
&& show_bits_long(&s->gb, 32) != AV_RB32("e_CM")) {
skip_bits(&s->gb, 8);
skip_bits(&s->gb, 16);
skip_bits(&s->gb, 16);
skip_bits(&s->gb, 16);
s->adobe_transform = get_bits(&s->gb, 8);
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, "mjpeg: Adobe header found, transform=%d\n", s->adobe_transform);
len -= 7;
}
if (id == AV_RB32("LJIF")) {
int rgb = s->rgb;
int pegasus_rct = s->pegasus_rct;
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO,
"Pegasus lossless jpeg header found\n");
skip_bits(&s->gb, 16);
skip_bits(&s->gb, 16);
skip_bits(&s->gb, 16);
skip_bits(&s->gb, 16);
switch (i=get_bits(&s->gb, 8)) {
case 1:
rgb = 1;
pegasus_rct = 0;
break;
case 2:
rgb = 1;
pegasus_rct = 1;
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "unknown colorspace %d\n", i);
}
len -= 9;
if (s->got_picture)
if (rgb != s->rgb || pegasus_rct != s->pegasus_rct) {
av_log(s->avctx, AV_LOG_WARNING, "Mismatching LJIF tag\n");
}
s->rgb = rgb;
s->pegasus_rct = pegasus_rct;
}
if (id == AV_RL32("colr") && len > 0) {
s->colr = get_bits(&s->gb, 8);
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, "COLR %d\n", s->colr);
len --;
}
if (id == AV_RL32("xfrm") && len > 0) {
s->xfrm = get_bits(&s->gb, 8);
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, "XFRM %d\n", s->xfrm);
len --;
}
if (s->start_code == APP3 && id == AV_RB32("_JPS") && len >= 10) {
int flags, layout, type;
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, "_JPSJPS_\n");
skip_bits(&s->gb, 32); len -= 4;
skip_bits(&s->gb, 16); len -= 2;
skip_bits(&s->gb, 8);
flags = get_bits(&s->gb, 8);
layout = get_bits(&s->gb, 8);
type = get_bits(&s->gb, 8);
len -= 4;
s->stereo3d = av_stereo3d_alloc();
if (!s->stereo3d) {
}
if (type == 0) {
s->stereo3d->type = AV_STEREO3D_2D;
} else if (type == 1) {
switch (layout) {
case 0x01:
s->stereo3d->type = AV_STEREO3D_LINES;
break;
case 0x02:
s->stereo3d->type = AV_STEREO3D_SIDEBYSIDE;
break;
case 0x03:
s->stereo3d->type = AV_STEREO3D_TOPBOTTOM;
break;
}
if (!(flags & 0x04)) {
s->stereo3d->flags = AV_STEREO3D_FLAG_INVERT;
}
}
}
if (s->start_code == APP1 && id == AV_RB32("Exif") && len >= 2) {
GetByteContext gbytes;
int ret, le, ifd_offset, bytes_read;
const uint8_t *aligned;
skip_bits(&s->gb, 16);
len -= 2;
aligned = align_get_bits(&s->gb);
bytestream2_init(&gbytes, aligned, len);
ret = ff_tdecode_header(&gbytes, &le, &ifd_offset);
if (ret) {
av_log(s->avctx, AV_LOG_ERROR, "mjpeg: invalid TIFF header in EXIF data\n");
} else {
bytestream2_seek(&gbytes, ifd_offset, SEEK_SET);
ret = avpriv_exif_decode_ifd(s->avctx, &gbytes, le, 0, &s->exif_metadata);
if (ret < 0) {
av_log(s->avctx, AV_LOG_ERROR, "mjpeg: error decoding EXIF data\n");
}
}
bytes_read = bytestream2_tell(&gbytes);
skip_bits(&s->gb, bytes_read << 3);
len -= bytes_read;
}
if ((s->start_code == APP1) && (len > (0x28 - 8))) {
id = get_bits_long(&s->gb, 32);
len -= 4;
if (id == AV_RB32("mjpg")) {
#if 0
skip_bits(&s->gb, 32);
skip_bits(&s->gb, 32);
skip_bits(&s->gb, 32);
skip_bits(&s->gb, 32);
skip_bits(&s->gb, 32);
skip_bits(&s->gb, 32);
skip_bits(&s->gb, 32);
skip_bits(&s->gb, 32);
#endif
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, "mjpeg: Apple MJPEG-A header found\n");
}
}
out:
if (len < 0)
av_log(s->avctx, AV_LOG_ERROR,
"mjpeg: error, decode_app parser read over the end\n");
while (--len > 0)
skip_bits(&s->gb, 8);
return 0;
}
| 1threat
|
static void gen_dmfc0 (DisasContext *ctx, int reg, int sel)
{
const char *rn = "invalid";
switch (reg) {
case 0:
switch (sel) {
case 0:
gen_op_mfc0_index();
rn = "Index";
break;
case 1:
rn = "MVPControl";
case 2:
rn = "MVPConf0";
case 3:
rn = "MVPConf1";
default:
goto die;
}
break;
case 1:
switch (sel) {
case 0:
gen_op_mfc0_random();
rn = "Random";
break;
case 1:
rn = "VPEControl";
case 2:
rn = "VPEConf0";
case 3:
rn = "VPEConf1";
case 4:
rn = "YQMask";
case 5:
rn = "VPESchedule";
case 6:
rn = "VPEScheFBack";
case 7:
rn = "VPEOpt";
default:
goto die;
}
break;
case 2:
switch (sel) {
case 0:
gen_op_dmfc0_entrylo0();
rn = "EntryLo0";
break;
case 1:
rn = "TCStatus";
case 2:
rn = "TCBind";
case 3:
rn = "TCRestart";
case 4:
rn = "TCHalt";
case 5:
rn = "TCContext";
case 6:
rn = "TCSchedule";
case 7:
rn = "TCScheFBack";
default:
goto die;
}
break;
case 3:
switch (sel) {
case 0:
gen_op_dmfc0_entrylo1();
rn = "EntryLo1";
break;
default:
goto die;
}
break;
case 4:
switch (sel) {
case 0:
gen_op_dmfc0_context();
rn = "Context";
break;
case 1:
rn = "ContextConfig";
default:
goto die;
}
break;
case 5:
switch (sel) {
case 0:
gen_op_mfc0_pagemask();
rn = "PageMask";
break;
case 1:
gen_op_mfc0_pagegrain();
rn = "PageGrain";
break;
default:
goto die;
}
break;
case 6:
switch (sel) {
case 0:
gen_op_mfc0_wired();
rn = "Wired";
break;
case 1:
rn = "SRSConf0";
case 2:
rn = "SRSConf1";
case 3:
rn = "SRSConf2";
case 4:
rn = "SRSConf3";
case 5:
rn = "SRSConf4";
default:
goto die;
}
break;
case 7:
switch (sel) {
case 0:
gen_op_mfc0_hwrena();
rn = "HWREna";
break;
default:
goto die;
}
break;
case 8:
switch (sel) {
case 0:
gen_op_dmfc0_badvaddr();
rn = "BadVaddr";
break;
default:
goto die;
}
break;
case 9:
switch (sel) {
case 0:
gen_op_mfc0_count();
rn = "Count";
break;
default:
goto die;
}
break;
case 10:
switch (sel) {
case 0:
gen_op_dmfc0_entryhi();
rn = "EntryHi";
break;
default:
goto die;
}
break;
case 11:
switch (sel) {
case 0:
gen_op_mfc0_compare();
rn = "Compare";
break;
default:
goto die;
}
break;
case 12:
switch (sel) {
case 0:
gen_op_mfc0_status();
rn = "Status";
break;
case 1:
gen_op_mfc0_intctl();
rn = "IntCtl";
break;
case 2:
gen_op_mfc0_srsctl();
rn = "SRSCtl";
break;
case 3:
gen_op_mfc0_srsmap();
rn = "SRSMap";
break;
default:
goto die;
}
break;
case 13:
switch (sel) {
case 0:
gen_op_mfc0_cause();
rn = "Cause";
break;
default:
goto die;
}
break;
case 14:
switch (sel) {
case 0:
gen_op_dmfc0_epc();
rn = "EPC";
break;
default:
goto die;
}
break;
case 15:
switch (sel) {
case 0:
gen_op_mfc0_prid();
rn = "PRid";
break;
case 1:
gen_op_dmfc0_ebase();
rn = "EBase";
break;
default:
goto die;
}
break;
case 16:
switch (sel) {
case 0:
gen_op_mfc0_config0();
rn = "Config";
break;
case 1:
gen_op_mfc0_config1();
rn = "Config1";
break;
case 2:
gen_op_mfc0_config2();
rn = "Config2";
break;
case 3:
gen_op_mfc0_config3();
rn = "Config3";
break;
default:
goto die;
}
break;
case 17:
switch (sel) {
case 0:
gen_op_dmfc0_lladdr();
rn = "LLAddr";
break;
default:
goto die;
}
break;
case 18:
switch (sel) {
case 0:
gen_op_dmfc0_watchlo0();
rn = "WatchLo";
break;
case 1:
rn = "WatchLo1";
case 2:
rn = "WatchLo2";
case 3:
rn = "WatchLo3";
case 4:
rn = "WatchLo4";
case 5:
rn = "WatchLo5";
case 6:
rn = "WatchLo6";
case 7:
rn = "WatchLo7";
default:
goto die;
}
break;
case 19:
switch (sel) {
case 0:
gen_op_mfc0_watchhi0();
rn = "WatchHi";
break;
case 1:
rn = "WatchHi1";
case 2:
rn = "WatchHi2";
case 3:
rn = "WatchHi3";
case 4:
rn = "WatchHi4";
case 5:
rn = "WatchHi5";
case 6:
rn = "WatchHi6";
case 7:
rn = "WatchHi7";
default:
goto die;
}
break;
case 20:
switch (sel) {
case 0:
gen_op_dmfc0_xcontext();
rn = "XContext";
break;
default:
goto die;
}
break;
case 21:
switch (sel) {
case 0:
gen_op_mfc0_framemask();
rn = "Framemask";
break;
default:
goto die;
}
break;
case 22:
rn = "'Diagnostic";
break;
case 23:
switch (sel) {
case 0:
gen_op_mfc0_debug();
rn = "Debug";
break;
case 1:
rn = "TraceControl";
case 2:
rn = "TraceControl2";
case 3:
rn = "UserTraceData";
case 4:
rn = "TraceBPC";
default:
goto die;
}
break;
case 24:
switch (sel) {
case 0:
gen_op_dmfc0_depc();
rn = "DEPC";
break;
default:
goto die;
}
break;
case 25:
switch (sel) {
case 0:
gen_op_mfc0_performance0();
rn = "Performance0";
break;
case 1:
rn = "Performance1";
case 2:
rn = "Performance2";
case 3:
rn = "Performance3";
case 4:
rn = "Performance4";
case 5:
rn = "Performance5";
case 6:
rn = "Performance6";
case 7:
rn = "Performance7";
default:
goto die;
}
break;
case 26:
rn = "ECC";
break;
case 27:
switch (sel) {
case 0 ... 3:
rn = "CacheErr";
break;
default:
goto die;
}
break;
case 28:
switch (sel) {
case 0:
case 2:
case 4:
case 6:
gen_op_mfc0_taglo();
rn = "TagLo";
break;
case 1:
case 3:
case 5:
case 7:
gen_op_mfc0_datalo();
rn = "DataLo";
break;
default:
goto die;
}
break;
case 29:
switch (sel) {
case 0:
case 2:
case 4:
case 6:
gen_op_mfc0_taghi();
rn = "TagHi";
break;
case 1:
case 3:
case 5:
case 7:
gen_op_mfc0_datahi();
rn = "DataHi";
break;
default:
goto die;
}
break;
case 30:
switch (sel) {
case 0:
gen_op_dmfc0_errorepc();
rn = "ErrorEPC";
break;
default:
goto die;
}
break;
case 31:
switch (sel) {
case 0:
gen_op_mfc0_desave();
rn = "DESAVE";
break;
default:
goto die;
}
break;
default:
goto die;
}
#if defined MIPS_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "dmfc0 %s (reg %d sel %d)\n",
rn, reg, sel);
}
#endif
return;
die:
#if defined MIPS_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "dmfc0 %s (reg %d sel %d)\n",
rn, reg, sel);
}
#endif
generate_exception(ctx, EXCP_RI);
}
| 1threat
|
best online tutorials for J2EE and J2ME : <p>I am very new to J2EE and J2ME but I am familiar with core java.
Now I have started learning J2EE and J2ME.
I request you all to suggest the best online tutorials both (pdf and videos) for J2EE and J2ME.
Also please guide me How to start learning the MVC Frame works,which should start first and which is the best?</p>
<p>Thank you </p>
| 0debug
|
static void add_flagname_to_bitmaps(char *flagname, uint32_t *features,
uint32_t *ext_features,
uint32_t *ext2_features,
uint32_t *ext3_features)
{
int i;
int found = 0;
for ( i = 0 ; i < 32 ; i++ )
if (feature_name[i] && !strcmp (flagname, feature_name[i])) {
*features |= 1 << i;
found = 1;
}
for ( i = 0 ; i < 32 ; i++ )
if (ext_feature_name[i] && !strcmp (flagname, ext_feature_name[i])) {
*ext_features |= 1 << i;
found = 1;
}
for ( i = 0 ; i < 32 ; i++ )
if (ext2_feature_name[i] && !strcmp (flagname, ext2_feature_name[i])) {
*ext2_features |= 1 << i;
found = 1;
}
for ( i = 0 ; i < 32 ; i++ )
if (ext3_feature_name[i] && !strcmp (flagname, ext3_feature_name[i])) {
*ext3_features |= 1 << i;
found = 1;
}
if (!found) {
fprintf(stderr, "CPU feature %s not found\n", flagname);
}
}
| 1threat
|
How to add / between spaces in a date : <p>How can I take a string that returns it in a list with " / " between them, like dates. </p>
<p>for example</p>
<p>Taking 5,11,2013 and the output be 5/11/2013</p>
| 0debug
|
int get_physical_address (CPUState *env, mmu_ctx_t *ctx, target_ulong eaddr,
int rw, int access_type)
{
int ret;
#if 0
qemu_log("%s\n", __func__);
#endif
if ((access_type == ACCESS_CODE && msr_ir == 0) ||
(access_type != ACCESS_CODE && msr_dr == 0)) {
ret = check_physical(env, ctx, eaddr, rw);
} else {
ret = -1;
switch (env->mmu_model) {
case POWERPC_MMU_32B:
case POWERPC_MMU_601:
case POWERPC_MMU_SOFT_6xx:
case POWERPC_MMU_SOFT_74xx:
#if defined(TARGET_PPC64)
case POWERPC_MMU_620:
case POWERPC_MMU_64B:
#endif
if (env->nb_BATs != 0)
ret = get_bat(env, ctx, eaddr, rw, access_type);
if (ret < 0) {
ret = get_segment(env, ctx, eaddr, rw, access_type);
}
break;
case POWERPC_MMU_SOFT_4xx:
case POWERPC_MMU_SOFT_4xx_Z:
ret = mmu40x_get_physical_address(env, ctx, eaddr,
rw, access_type);
break;
case POWERPC_MMU_BOOKE:
ret = mmubooke_get_physical_address(env, ctx, eaddr,
rw, access_type);
break;
case POWERPC_MMU_MPC8xx:
cpu_abort(env, "MPC8xx MMU model is not implemented\n");
break;
case POWERPC_MMU_BOOKE_FSL:
cpu_abort(env, "BookE FSL MMU model not implemented\n");
return -1;
case POWERPC_MMU_REAL:
cpu_abort(env, "PowerPC in real mode do not do any translation\n");
return -1;
default:
cpu_abort(env, "Unknown or invalid MMU model\n");
return -1;
}
}
#if 0
qemu_log("%s address " ADDRX " => %d " PADDRX "\n",
__func__, eaddr, ret, ctx->raddr);
#endif
return ret;
}
| 1threat
|
Python - What's wrong with my code : Python beginner here! I am trying to execute the following:
print("Are you old enough to vote? Please enter your age below:")
input()
age = 18
if age < 18:
print('You must be 18 to vote.')
elif age >= 18:
print ('You are of voting age.')
When I run it, the program prints "You are of voting age" no matter how low the number input is... can someone help me? I'm sure this is really basic, but I'm stuck!
Thanks!
| 0debug
|
static void decode_band_structure(GetBitContext *gbc, int blk, int eac3,
int ecpl, int start_subband, int end_subband,
const uint8_t *default_band_struct,
uint8_t *band_struct, int *num_subbands,
int *num_bands, uint8_t *band_sizes)
{
int subbnd, bnd, n_subbands, n_bands;
uint8_t bnd_sz[22];
n_subbands = end_subband - start_subband;
if (!eac3 || get_bits1(gbc)) {
for (subbnd = 0; subbnd < n_subbands - 1; subbnd++) {
band_struct[subbnd] = get_bits1(gbc);
}
} else if (!blk) {
memcpy(band_struct,
&default_band_struct[start_subband+1],
n_subbands-1);
}
band_struct[n_subbands-1] = 0;
if (num_bands || band_sizes ) {
n_bands = n_subbands;
bnd_sz[0] = ecpl ? 6 : 12;
for (bnd = 0, subbnd = 1; subbnd < n_subbands; subbnd++) {
int subbnd_size = (ecpl && subbnd < 4) ? 6 : 12;
if (band_struct[subbnd-1]) {
n_bands--;
bnd_sz[bnd] += subbnd_size;
} else {
bnd_sz[++bnd] = subbnd_size;
}
}
}
if (num_subbands)
*num_subbands = n_subbands;
if (num_bands)
*num_bands = n_bands;
if (band_sizes)
memcpy(band_sizes, bnd_sz, n_bands);
}
| 1threat
|
How to hide elements from the form editor : <p>so I'm making a chat room, and it has several different scenes. However, for maximum efficiency, I need to have a clean workspace. However, the start here:
<a href="https://i.stack.imgur.com/iopTE.png" rel="nofollow noreferrer">First scene</a>. Is hard to have in the background when I'm placing stuff around. I know how to hide it once it runs, but is there any way to keep it alive, but invisible when I'm editing?</p>
| 0debug
|
how to run all (unit and instrumented) tests with one click in Android Studio : <p>I am developing an Android app in Android Studio.
I have unit tests and instrumented tests.</p>
<p>I want to run them all to see if I broke something.</p>
<p>Right now my workflow is:</p>
<ul>
<li>go to Project view
<ul>
<li>navigate to <code>${app}/src/androidTest/java/</code></li>
<li>right-click that node and select <code>Run 'All Tests'</code></li>
<li>select my device</li>
<li>run instrumented tests</li>
</ul></li>
</ul>
<p>then</p>
<ul>
<li>go to Project view
<ul>
<li>navigate to <code>${app}/src/androidTest/java/${package}</code></li>
<li>right-click that node and select <code>Run 'Tests in ${package}'</code></li>
<li>run unit tests</li>
</ul></li>
</ul>
<p>What I am really looking for is a big green button that runs all of the tests and reports back the result of OK/FAILED for both unit and instrumented tests together. How can I do that?</p>
| 0debug
|
Apply function on each element in parameter pack : <p>I have the following template function with specialization:</p>
<pre><code>// Pass the argument through ...
template<typename T, typename U=T>
U convert(T&& t) {
return std::forward<T>(t);
}
// ... but convert std::strings
const char* convert(std::string s) {
return s.c_str();
}
</code></pre>
<p>If I then have a variadic template function like:</p>
<pre><code>template<typename ... Args>
void doSomething(Args ... args) {
// Convert parameter pack using convert function above
// and call any other variadic templated function with
// the converted args.
}
</code></pre>
<p>Is there any way to convert the parameter pack using the convert function as in the comment?</p>
<p>My original goal was being to be able to pass std::string to '%s' in a printf like function without having to manually calling .c_str() on the strings first. But I am also interested in general if this can be done in a simple way, my tries so far failed.</p>
| 0debug
|
How can I turn off a liquid valve when a flame goes out? : <p>I'm trying to make my family's life easier and cheaper. I'm heating my barn with a waste oil drip heater. I want to be able to automatically turn off the oil feed valve in case the burner goes out which would cause the barn to fill up with oil and possibly cause a fire.The oil tank will be under about 10 pounds of pressure with a 60 of used oil. Normally it would be attended, but just a few minute error can cause a disaster. I can imagine this could be started out with a hot water heater or dryer flame sensor. But, I don't know where to go from there.</p>
| 0debug
|
uint32_t ide_ioport_read(void *opaque, uint32_t addr1)
{
IDEBus *bus = opaque;
IDEState *s = idebus_active_if(bus);
uint32_t addr;
int ret, hob;
addr = addr1 & 7;
hob = 0;
switch(addr) {
case 0:
ret = 0xff;
break;
case 1:
if ((!bus->ifs[0].bs && !bus->ifs[1].bs) ||
(s != bus->ifs && !s->bs))
ret = 0;
else if (!hob)
ret = s->error;
else
ret = s->hob_feature;
break;
case 2:
if (!bus->ifs[0].bs && !bus->ifs[1].bs)
ret = 0;
else if (!hob)
ret = s->nsector & 0xff;
else
ret = s->hob_nsector;
break;
case 3:
if (!bus->ifs[0].bs && !bus->ifs[1].bs)
ret = 0;
else if (!hob)
ret = s->sector;
else
ret = s->hob_sector;
break;
case 4:
if (!bus->ifs[0].bs && !bus->ifs[1].bs)
ret = 0;
else if (!hob)
ret = s->lcyl;
else
ret = s->hob_lcyl;
break;
case 5:
if (!bus->ifs[0].bs && !bus->ifs[1].bs)
ret = 0;
else if (!hob)
ret = s->hcyl;
else
ret = s->hob_hcyl;
break;
case 6:
if (!bus->ifs[0].bs && !bus->ifs[1].bs)
ret = 0;
else
ret = s->select;
break;
default:
case 7:
if ((!bus->ifs[0].bs && !bus->ifs[1].bs) ||
(s != bus->ifs && !s->bs))
ret = 0;
else
ret = s->status;
qemu_irq_lower(bus->irq);
break;
}
#ifdef DEBUG_IDE
printf("ide: read addr=0x%x val=%02x\n", addr1, ret);
#endif
return ret;
}
| 1threat
|
I have one folder in that different formats like .py, .json, .spec, .png , I want to convert this folder to .exe format : I have one folder in that different formats like .py, .json, .spec, .png , I want to convert this folder to .exe format.. How to convert plz guide me
| 0debug
|
Possible bug with Bcrypt implementation on Spring : <p>I'm testing to move our password hash from sha-256 to sha-512 or bcrypt. For that, I've implemented a very simple test, but I've found out that with a specific rawPassword when Bcrypt tries to match it against the same rawPassword + anything else, it fails, returning true instead of false. Maybe it is related to the encoding, but I'm not sure.</p>
<pre class="lang-java prettyprint-override"><code>...
@Test
public void testEncodePassword() {
final String rawPassword = "¡Oh envidia, raíz de infinitos males y carcoma de las virtudes!";
PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
String encodedPassword = passwordEncoder.encode(rawPassword);
assertTrue(passwordEncoder.matches(rawPassword,encodedPassword));
assertFalse(passwordEncoder.matches("dds",encodedPassword));
assertFalse(passwordEncoder.matches("dds"+rawPassword,encodedPassword));
assertFalse(passwordEncoder.matches(rawPassword+"something else",encodedPassword));
}
...
</code></pre>
| 0debug
|
SQL SERVER 2012 : I want to fetch specific values from a string for Ex: String 1 {cm_documentation_.chk_phone_call_physician}=1 & {cm_documentation_.txt_phone_call_code}="99441" & ({cm_documentation_.txt_units_mins}!="" & ({local.units_mins}<5 |{local.units_mins}>10) | {cm_documentation_.txt_units_mins}="")
String 2:{@This}="93015" | {@This}="78454" | {@This}="78453" | {@This}="78452" | {@This}="78451" | {@This}="78480" | {@This}="78478" | {@This}="78465" | {@This}="78499" | {@This}="78492" | {@This}="78491" | {@This}="78459"
I wan to fetch values after = symbol
Result:
99441
93015
78454
78453
.
.
.
.
.
.
.
So on.....
| 0debug
|
void kvm_set_phys_mem(target_phys_addr_t start_addr,
ram_addr_t size,
ram_addr_t phys_offset)
{
KVMState *s = kvm_state;
ram_addr_t flags = phys_offset & ~TARGET_PAGE_MASK;
KVMSlot *mem;
if (start_addr & ~TARGET_PAGE_MASK) {
fprintf(stderr, "Only page-aligned memory slots supported\n");
abort();
}
phys_offset &= ~IO_MEM_ROM;
mem = kvm_lookup_slot(s, start_addr);
if (mem) {
if (flags >= IO_MEM_UNASSIGNED) {
mem->memory_size = 0;
mem->start_addr = start_addr;
mem->phys_offset = 0;
mem->flags = 0;
kvm_set_user_memory_region(s, mem);
} else if (start_addr >= mem->start_addr &&
(start_addr + size) <= (mem->start_addr +
mem->memory_size)) {
KVMSlot slot;
target_phys_addr_t mem_start;
ram_addr_t mem_size, mem_offset;
if ((phys_offset - (start_addr - mem->start_addr)) ==
mem->phys_offset)
return;
memcpy(&slot, mem, sizeof(slot));
mem->memory_size = 0;
kvm_set_user_memory_region(s, mem);
mem_start = slot.start_addr;
mem_size = start_addr - slot.start_addr;
mem_offset = slot.phys_offset;
if (mem_size)
kvm_set_phys_mem(mem_start, mem_size, mem_offset);
kvm_set_phys_mem(start_addr, size, phys_offset);
mem_start = start_addr + size;
mem_offset += mem_size + size;
mem_size = slot.memory_size - mem_size - size;
if (mem_size)
kvm_set_phys_mem(mem_start, mem_size, mem_offset);
return;
} else {
printf("Registering overlapping slot\n");
abort();
}
}
if (flags >= IO_MEM_UNASSIGNED)
return;
mem = kvm_alloc_slot(s);
mem->memory_size = size;
mem->start_addr = start_addr;
mem->phys_offset = phys_offset;
mem->flags = 0;
kvm_set_user_memory_region(s, mem);
}
| 1threat
|
Multhithread old legacy applications in modern CPUs : <p>I was explaining why volatile keyword is necessary to accessing a shared memory structure by different threads.</p>
<p>My argument is suppose that CPU have two cores and two local caches inside them. Suppose that one thread is running in one core and other thread is running in next core. Then when 1st thread is writing that memory , and 2nd thread is reading it, the up-to date version would not be visible to the 2nd thread due to it's local cache yet not updated.</p>
<p>But my friend come up with an argument, he argue what's happen before the 'volatile' keyword , the old multi-threaded application binaries brought and run in a modern processor, will they fail ? For a example a old 32-bit application brought back and run in multi-core CPU in windows 7? A application that written in era where CPU cores were not introduced so only single cache is there? </p>
<p>Is my friends argument is correct. Or can it fail ? What is the time-frame that 'volatile' keyword was introduced to C/C++?</p>
| 0debug
|
Google Ads solution for PWA/SPA? : <p>I've made a single page app via Angular, and plan to also make it a progressive web app in the next few days. </p>
<p>I recently realized that Google AdSense apparently doesn't like SPAs and my application has been denied twice. My app is a tool that allows users to create, manage, and share specific content, which I believe offers a ton of value. When I was researching AdSense a while back, I definitely thought I would qualify as I didn't realize 'valuable content' specifically referred only to having a ton of words.</p>
<p>With that being said, it's 2019...is there no solution for serving Google ads on a web app that's not focused on articles, etc??
Google has tons of articles talking about how great PWAs are for users, yet it doesn't seem that they support ads for PWAs at all. I don't want to make a native mobile app, because I think a PWA that works on any device just makes more sense, so AdMob isn't an option. I've come across a few articles that indicate Doubleclick for Publishers (DFP) may be a solution, but when I try to login to that platform, it seems to be linked to my AdSense application and is either showing pending or access denied, depending on my current AdSense application status. I don't have another website that I could get approved first and then piggy back this app on that. </p>
<p>I'm also using firebase as my backed, which is why I'm pretty keen on advertising with Google as well. But obviously, if I have to go in a totally different direction to generate ad revenue with my app, I will. </p>
<p>Any insight into how I could make Google Ads work for my app or another good solution would be very much appreciated. </p>
| 0debug
|
load Json file in Javascript not same result on Chrome and Firefox : <p>I have a problem and i don't know how solve it.
I would load a json file in Javascript. In firefox it's ok but in chrome, i don't know why but it doesn't work. I have this exception :
jquery-3.1.1.min.js:4 XMLHttpRequest cannot load file://france.intra.corp .../pieChart.json. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
The json file exist and when i search this i find the good file.
<a href="https://i.stack.imgur.com/lVmfR.png" rel="nofollow noreferrer">html code</a>,
<a href="https://i.stack.imgur.com/5iLnD.png" rel="nofollow noreferrer">javascript code</a></p>
<p>Thank you.</p>
| 0debug
|
How to write/read data to a file in Visual Studio 2017 : <p>I'm creating an application in C# Universal Windows and I would like to know how would would I go about writing data to a file so that I can read from it later. I was thinking of making a class <code>System.Serializable</code> and then write objects of that class as files to the user's device so then I can read those files back as objects again but I don't know how to go about doing that.</p>
| 0debug
|
window.location.href = 'http://attack.com?user=' + user_input;
| 1threat
|
Uses of for row loop in template : <p>I searched in the docs but could not find tag mentioned below . I want to know where can we use it and Please provide link so i can read more about this tag. </p>
<pre><code>{% for row in qs %} {{ row.total_income }} {% endfor %}
</code></pre>
| 0debug
|
void start_auth_sasl(VncState *vs)
{
const char *mechlist = NULL;
sasl_security_properties_t secprops;
int err;
char *localAddr, *remoteAddr;
int mechlistlen;
VNC_DEBUG("Initialize SASL auth %d\n", vs->csock);
if (!(localAddr = vnc_socket_local_addr("%s;%s", vs->csock)))
goto authabort;
if (!(remoteAddr = vnc_socket_remote_addr("%s;%s", vs->csock))) {
free(localAddr);
goto authabort;
}
err = sasl_server_new("vnc",
NULL,
NULL,
localAddr,
remoteAddr,
NULL,
SASL_SUCCESS_DATA,
&vs->sasl.conn);
free(localAddr);
free(remoteAddr);
localAddr = remoteAddr = NULL;
if (err != SASL_OK) {
VNC_DEBUG("sasl context setup failed %d (%s)",
err, sasl_errstring(err, NULL, NULL));
vs->sasl.conn = NULL;
goto authabort;
}
#ifdef CONFIG_VNC_TLS
if (vs->vd->auth == VNC_AUTH_VENCRYPT &&
vs->vd->subauth == VNC_AUTH_VENCRYPT_X509SASL) {
gnutls_cipher_algorithm_t cipher;
sasl_ssf_t ssf;
cipher = gnutls_cipher_get(vs->tls.session);
if (!(ssf = (sasl_ssf_t)gnutls_cipher_get_key_size(cipher))) {
VNC_DEBUG("%s", "cannot TLS get cipher size\n");
sasl_dispose(&vs->sasl.conn);
vs->sasl.conn = NULL;
goto authabort;
}
ssf *= 8;
err = sasl_setprop(vs->sasl.conn, SASL_SSF_EXTERNAL, &ssf);
if (err != SASL_OK) {
VNC_DEBUG("cannot set SASL external SSF %d (%s)\n",
err, sasl_errstring(err, NULL, NULL));
sasl_dispose(&vs->sasl.conn);
vs->sasl.conn = NULL;
goto authabort;
}
} else
#endif
vs->sasl.wantSSF = 1;
memset (&secprops, 0, sizeof secprops);
if (strncmp(vs->vd->display, "unix:", 5) == 0
#ifdef CONFIG_VNC_TLS
|| (vs->vd->auth == VNC_AUTH_VENCRYPT &&
vs->vd->subauth == VNC_AUTH_VENCRYPT_X509SASL)
#endif
) {
secprops.min_ssf = 0;
secprops.max_ssf = 0;
secprops.maxbufsize = 8192;
secprops.security_flags = 0;
} else {
secprops.min_ssf = 56;
secprops.max_ssf = 100000;
secprops.maxbufsize = 8192;
secprops.security_flags =
SASL_SEC_NOANONYMOUS | SASL_SEC_NOPLAINTEXT;
}
err = sasl_setprop(vs->sasl.conn, SASL_SEC_PROPS, &secprops);
if (err != SASL_OK) {
VNC_DEBUG("cannot set SASL security props %d (%s)\n",
err, sasl_errstring(err, NULL, NULL));
sasl_dispose(&vs->sasl.conn);
vs->sasl.conn = NULL;
goto authabort;
}
err = sasl_listmech(vs->sasl.conn,
NULL,
"",
",",
"",
&mechlist,
NULL,
NULL);
if (err != SASL_OK) {
VNC_DEBUG("cannot list SASL mechanisms %d (%s)\n",
err, sasl_errdetail(vs->sasl.conn));
sasl_dispose(&vs->sasl.conn);
vs->sasl.conn = NULL;
goto authabort;
}
VNC_DEBUG("Available mechanisms for client: '%s'\n", mechlist);
if (!(vs->sasl.mechlist = strdup(mechlist))) {
VNC_DEBUG("Out of memory");
sasl_dispose(&vs->sasl.conn);
vs->sasl.conn = NULL;
goto authabort;
}
mechlistlen = strlen(mechlist);
vnc_write_u32(vs, mechlistlen);
vnc_write(vs, mechlist, mechlistlen);
vnc_flush(vs);
VNC_DEBUG("Wait for client mechname length\n");
vnc_read_when(vs, protocol_client_auth_sasl_mechname_len, 4);
return;
authabort:
vnc_client_error(vs);
return;
}
| 1threat
|
How do I add rows based on first string in R : <p>I have a data frame that looks something like this. </p>
<pre><code> NAME NUMBER
1 A 3
2 B 4
3 A 7
4 B 1
</code></pre>
<p>And I want it to look like </p>
<pre><code> NAME NUMBER
1 A 10
2 B 5
</code></pre>
<p>What's the easiest way to do this for a data frame with 4932 rows?</p>
| 0debug
|
How to return response after async call is finished? : <p>I have some express.js app and I have a "Pay" button in my UI.</p>
<p>When I click on it, I want the server to call the checkout API of Stripe and then return a response only when I get the response from the API call (card can be expired, for example).</p>
<p>I know it's a bad practice, but how can my response wait till the async call finishes?</p>
<p>And what's the right way to do such call in express.js?</p>
| 0debug
|
static void pci_apb_iowriteb (void *opaque, target_phys_addr_t addr,
uint32_t val)
{
cpu_outb(addr & IOPORTS_MASK, val);
}
| 1threat
|
method overriding in java with same number of parameter but different return type : class TestOverride{
public int testVlaue(int a,int b){
return a + b;
}
public float testValue(int x,int y){
return x + y;
}
public float testValue(float x){
return x;
}
}
public class CodeTester{
public static void main(String a[]){
TestOverride objTest = new TestOverride();
System.out.println(objTest.testValue(2));
System.out.println(objTest.testValue(2,3));
}
}
//why the output is
//2.0
//5.0,
//It can also take the return type int instead of float for return value 5?
| 0debug
|
int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
{
int i, ret;
Picture *pic;
s->mb_skipped = 0;
if (s->pict_type != AV_PICTURE_TYPE_B && s->last_picture_ptr &&
s->last_picture_ptr != s->next_picture_ptr &&
s->last_picture_ptr->f->buf[0]) {
ff_mpeg_unref_picture(s->avctx, s->last_picture_ptr);
}
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
if (&s->picture[i] != s->last_picture_ptr &&
&s->picture[i] != s->next_picture_ptr &&
s->picture[i].reference && !s->picture[i].needs_realloc) {
ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
}
}
ff_mpeg_unref_picture(s->avctx, &s->current_picture);
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
if (!s->picture[i].reference)
ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
}
if (s->current_picture_ptr && !s->current_picture_ptr->f->buf[0]) {
pic = s->current_picture_ptr;
} else {
i = ff_find_unused_picture(s->avctx, s->picture, 0);
if (i < 0) {
av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
return i;
}
pic = &s->picture[i];
}
pic->reference = 0;
if (!s->droppable) {
if (s->pict_type != AV_PICTURE_TYPE_B)
pic->reference = 3;
}
pic->f->coded_picture_number = s->coded_picture_number++;
if (alloc_picture(s, pic, 0) < 0)
return -1;
s->current_picture_ptr = pic;
s->current_picture_ptr->f->top_field_first = s->top_field_first;
if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO ||
s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
if (s->picture_structure != PICT_FRAME)
s->current_picture_ptr->f->top_field_first =
(s->picture_structure == PICT_TOP_FIELD) == s->first_field;
}
s->current_picture_ptr->f->interlaced_frame = !s->progressive_frame &&
!s->progressive_sequence;
s->current_picture_ptr->field_picture = s->picture_structure != PICT_FRAME;
s->current_picture_ptr->f->pict_type = s->pict_type;
s->current_picture_ptr->f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
if ((ret = ff_mpeg_ref_picture(s->avctx, &s->current_picture,
s->current_picture_ptr)) < 0)
return ret;
if (s->pict_type != AV_PICTURE_TYPE_B) {
s->last_picture_ptr = s->next_picture_ptr;
if (!s->droppable)
s->next_picture_ptr = s->current_picture_ptr;
}
ff_dlog(s->avctx, "L%p N%p C%p L%p N%p C%p type:%d drop:%d\n",
s->last_picture_ptr, s->next_picture_ptr,s->current_picture_ptr,
s->last_picture_ptr ? s->last_picture_ptr->f->data[0] : NULL,
s->next_picture_ptr ? s->next_picture_ptr->f->data[0] : NULL,
s->current_picture_ptr ? s->current_picture_ptr->f->data[0] : NULL,
s->pict_type, s->droppable);
if ((!s->last_picture_ptr || !s->last_picture_ptr->f->buf[0]) &&
(s->pict_type != AV_PICTURE_TYPE_I ||
s->picture_structure != PICT_FRAME)) {
int h_chroma_shift, v_chroma_shift;
av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt,
&h_chroma_shift, &v_chroma_shift);
if (s->pict_type != AV_PICTURE_TYPE_I)
av_log(avctx, AV_LOG_ERROR,
"warning: first frame is no keyframe\n");
else if (s->picture_structure != PICT_FRAME)
av_log(avctx, AV_LOG_INFO,
"allocate dummy last picture for field based first keyframe\n");
i = ff_find_unused_picture(s->avctx, s->picture, 0);
if (i < 0) {
av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
return i;
}
s->last_picture_ptr = &s->picture[i];
s->last_picture_ptr->reference = 3;
s->last_picture_ptr->f->pict_type = AV_PICTURE_TYPE_I;
if (alloc_picture(s, s->last_picture_ptr, 0) < 0) {
s->last_picture_ptr = NULL;
return -1;
}
memset(s->last_picture_ptr->f->data[0], 0,
avctx->height * s->last_picture_ptr->f->linesize[0]);
memset(s->last_picture_ptr->f->data[1], 0x80,
(avctx->height >> v_chroma_shift) *
s->last_picture_ptr->f->linesize[1]);
memset(s->last_picture_ptr->f->data[2], 0x80,
(avctx->height >> v_chroma_shift) *
s->last_picture_ptr->f->linesize[2]);
ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 1);
}
if ((!s->next_picture_ptr || !s->next_picture_ptr->f->buf[0]) &&
s->pict_type == AV_PICTURE_TYPE_B) {
i = ff_find_unused_picture(s->avctx, s->picture, 0);
if (i < 0) {
av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
return i;
}
s->next_picture_ptr = &s->picture[i];
s->next_picture_ptr->reference = 3;
s->next_picture_ptr->f->pict_type = AV_PICTURE_TYPE_I;
if (alloc_picture(s, s->next_picture_ptr, 0) < 0) {
s->next_picture_ptr = NULL;
return -1;
}
ff_thread_report_progress(&s->next_picture_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&s->next_picture_ptr->tf, INT_MAX, 1);
}
if (s->last_picture_ptr) {
ff_mpeg_unref_picture(s->avctx, &s->last_picture);
if (s->last_picture_ptr->f->buf[0] &&
(ret = ff_mpeg_ref_picture(s->avctx, &s->last_picture,
s->last_picture_ptr)) < 0)
return ret;
}
if (s->next_picture_ptr) {
ff_mpeg_unref_picture(s->avctx, &s->next_picture);
if (s->next_picture_ptr->f->buf[0] &&
(ret = ff_mpeg_ref_picture(s->avctx, &s->next_picture,
s->next_picture_ptr)) < 0)
return ret;
}
if (s->pict_type != AV_PICTURE_TYPE_I &&
!(s->last_picture_ptr && s->last_picture_ptr->f->buf[0])) {
av_log(s, AV_LOG_ERROR,
"Non-reference picture received and no reference available\n");
return AVERROR_INVALIDDATA;
}
if (s->picture_structure!= PICT_FRAME) {
int i;
for (i = 0; i < 4; i++) {
if (s->picture_structure == PICT_BOTTOM_FIELD) {
s->current_picture.f->data[i] +=
s->current_picture.f->linesize[i];
}
s->current_picture.f->linesize[i] *= 2;
s->last_picture.f->linesize[i] *= 2;
s->next_picture.f->linesize[i] *= 2;
}
}
if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;
s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;
} else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) {
s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
} else {
s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;
s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;
}
#if FF_API_XVMC
FF_DISABLE_DEPRECATION_WARNINGS
if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
return ff_xvmc_field_start(s, avctx);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
return 0;
}
| 1threat
|
int bdrv_all_delete_snapshot(const char *name, BlockDriverState **first_bad_bs,
Error **err)
{
int ret = 0;
BlockDriverState *bs;
BdrvNextIterator *it = NULL;
QEMUSnapshotInfo sn1, *snapshot = &sn1;
while (ret == 0 && (it = bdrv_next(it, &bs))) {
AioContext *ctx = bdrv_get_aio_context(bs);
aio_context_acquire(ctx);
if (bdrv_can_snapshot(bs) &&
bdrv_snapshot_find(bs, snapshot, name) >= 0) {
ret = bdrv_snapshot_delete_by_id_or_name(bs, name, err);
}
aio_context_release(ctx);
}
*first_bad_bs = bs;
return ret;
}
| 1threat
|
How to delete a record in databse C# : How do I remove a record?
I need to remove a record that I found by using the foreign key. I stored it as a var but now I can't delete it. Any suggestions?
// POST: Account/Delete/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Delete(int id, Leerling ll)
{
var login = from l in db.myLogin
where id == l.leerlingId
select l;
db.myLogin.Remove(login???);
db.Entry(ll).State = System.Data.Entity.EntityState.Deleted;
db.SaveChanges();
return RedirectToAction("Index");// het record verwijderen en redirecten als het gelukt is
}
| 0debug
|
AG Grid tooltip takes long time to render : <p>I was following <a href="https://www.ag-grid.com/javascript-grid-tooltip-component/" rel="noreferrer">this example</a> and found out that the table takes quite some time to render the tooltip. It doesn't seem to have any delay whatsoever, and I have tried both defaultBrowserTooltip as well as the custom one but both of them are slow. Any given tips on this?</p>
<p>P/S: I'm using React</p>
<p>Some way that I have tried:</p>
<pre><code>tooltipField: 'myTooltipField'
tooltip: (value: string): string => value
</code></pre>
| 0debug
|
Why does the `operator<<` not work on member pointing to derived type? : <p>I have a class <code>Base</code> with a member pointing to a derived type <code>Derv</code>:</p>
<pre><code>class Derv;
class Base
{
protected:
std::vector<std::shared_ptr<Derv>> opnds;
...
}
</code></pre>
<p>The derived class looks like this:</p>
<pre><code>#include "Base.h"
class Derv:
public Base
{
...
}
</code></pre>
<p>Now I want to <code>cout</code> all <code>Base</code> and derived types by serializing the items from <code>opnds</code>. I read that something like the following is the standard approach for that (since I might want to override the serialization from other derived classes). I included into <code>Base.h</code>:</p>
<pre><code>friend std::ostream &operator<<(std::ostream &os, math_struct const &m);
virtual void serialize(std::ostream& os) const;
</code></pre>
<p>In <code>Base.cpp</code> I implemented:</p>
<pre><code>#include <string>
void Base::serialize(std::ostream& os) const
{
for (std::size_t i = 0; i < this->opnds.size(); ++i) {
os << ", " << *this->opnds[i]; // Error: no operator "<<" matches these operands
}
}
std::ostream& operator<<(std::ostream &os, math_struct const &m) {
m.serialize(os);
return os;
}
</code></pre>
<p>But the recursive application of <code><<</code> in <code>Base::serialize</code> serialize doesn't work. It seems to have to do with the derived class being referenced in the base class member. An earlier version where I head <code>std::vector<std::shared_ptr<Base>> opnds</code> worked fine.</p>
<p>I'm new to C++, so probably I got something basic wrong...</p>
| 0debug
|
static void final(const short *i1, const short *i2,
void *out, int *statbuf, int len)
{
int x, i;
unsigned short int work[50];
short *ptr = work;
memcpy(work, statbuf,20);
memcpy(work + 10, i2, len * 2);
for (i=0; i<len; i++) {
int sum = 0;
for(x=0; x<10; x++)
sum += i1[9-x] * ptr[x];
sum >>= 12;
if (ptr[10] - sum < -32768 || ptr[10] - sum > 32767) {
memset(out, 0, len * 2);
memset(statbuf, 0, 20);
return;
}
ptr[10] -= sum;
ptr++;
}
memcpy(out, work+10, len * 2);
memcpy(statbuf, work + 40, 20);
}
| 1threat
|
void virtio_config_writew(VirtIODevice *vdev, uint32_t addr, uint32_t data)
{
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
uint16_t val = data;
if (addr > (vdev->config_len - sizeof(val)))
return;
stw_p(vdev->config + addr, val);
if (k->set_config) {
k->set_config(vdev, vdev->config);
}
}
| 1threat
|
static bool ohci_eof_timer_needed(void *opaque)
{
OHCIState *ohci = opaque;
return ohci->eof_timer != NULL;
}
| 1threat
|
static void adb_mouse_initfn(Object *obj)
{
ADBDevice *d = ADB_DEVICE(obj);
d->devaddr = ADB_DEVID_MOUSE;
}
| 1threat
|
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
{
int ret = 0;
void *dst, *target_obj;
const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
if (!o || !target_obj)
return AVERROR_OPTION_NOT_FOUND;
if (!val && (o->type != AV_OPT_TYPE_STRING &&
o->type != AV_OPT_TYPE_PIXEL_FMT && o->type != AV_OPT_TYPE_SAMPLE_FMT &&
o->type != AV_OPT_TYPE_IMAGE_SIZE && o->type != AV_OPT_TYPE_VIDEO_RATE &&
o->type != AV_OPT_TYPE_DURATION && o->type != AV_OPT_TYPE_COLOR &&
o->type != AV_OPT_TYPE_CHANNEL_LAYOUT && o->type != AV_OPT_TYPE_BOOL))
return AVERROR(EINVAL);
if (o->flags & AV_OPT_FLAG_READONLY)
return AVERROR(EINVAL);
dst = ((uint8_t *)target_obj) + o->offset;
switch (o->type) {
case AV_OPT_TYPE_BOOL:
return set_string_bool(obj, o, val, dst);
case AV_OPT_TYPE_STRING:
return set_string(obj, o, val, dst);
case AV_OPT_TYPE_BINARY:
return set_string_binary(obj, o, val, dst);
case AV_OPT_TYPE_FLAGS:
case AV_OPT_TYPE_INT:
case AV_OPT_TYPE_INT64:
case AV_OPT_TYPE_FLOAT:
case AV_OPT_TYPE_DOUBLE:
case AV_OPT_TYPE_RATIONAL:
return set_string_number(obj, target_obj, o, val, dst);
case AV_OPT_TYPE_IMAGE_SIZE:
return set_string_image_size(obj, o, val, dst);
case AV_OPT_TYPE_VIDEO_RATE:
return set_string_video_rate(obj, o, val, dst);
case AV_OPT_TYPE_PIXEL_FMT:
return set_string_pixel_fmt(obj, o, val, dst);
case AV_OPT_TYPE_SAMPLE_FMT:
return set_string_sample_fmt(obj, o, val, dst);
case AV_OPT_TYPE_DURATION:
if (!val) {
*(int64_t *)dst = 0;
return 0;
} else {
if ((ret = av_parse_time(dst, val, 1)) < 0)
av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as duration\n", val);
return ret;
}
break;
case AV_OPT_TYPE_COLOR:
return set_string_color(obj, o, val, dst);
case AV_OPT_TYPE_CHANNEL_LAYOUT:
if (!val || !strcmp(val, "none")) {
*(int64_t *)dst = 0;
} else {
int64_t cl = av_get_channel_layout(val);
if (!cl) {
av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as channel layout\n", val);
ret = AVERROR(EINVAL);
}
*(int64_t *)dst = cl;
return ret;
}
break;
}
av_log(obj, AV_LOG_ERROR, "Invalid option type.\n");
return AVERROR(EINVAL);
}
| 1threat
|
Excel help --- wants to get rid of zero value cells : <p><a href="https://i.stack.imgur.com/TP3i5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TP3i5.png" alt="first two columns are automated data d and e columns is my requirement"></a></p>
<p>Hi i need help with this i want to get rid of all zero value cells without vba and any manual method. first two columns A and B is automated data generated by a software all i want is to show data in D and E like i showed in the example. is there any way to do it without vba and manually?</p>
| 0debug
|
How to get enum from raw value in Swift? : <p>I'm trying to get enum type from raw value:</p>
<pre><code>enum TestEnum: String {
case Name
case Gender
case Birth
var rawValue: String {
switch self {
case .Name: return "Name"
case .Gender: return "Gender"
case .Birth: return "Birth Day"
}
}
}
let name = TestEnum(rawValue: "Name") //Name
let gender = TestEnum(rawValue: "Gender") //Gender
</code></pre>
<p>But it seems that <code>rawValue</code> doesn't work for string with spaces:</p>
<pre><code>let birth = TestEnum(rawValue: "Birth Day") //nil
</code></pre>
<p>Any suggestions how to get it?</p>
| 0debug
|
def find_remainder(arr, lens, n):
mul = 1
for i in range(lens):
mul = (mul * (arr[i] % n)) % n
return mul % n
| 0debug
|
connection.query('SELECT * FROM users WHERE username = ' + input_string)
| 1threat
|
What is the purpose of the [i] in the for loop : <p>I have some line of code that I don't fully understand. I am looking through objects in an api and was wondering what is the purpose of the [i] in d2.follows[i].user.display_name if the code is:</p>
<pre><code>$.getJSON(followerURL, function(d2){
for(var i=0; i<d2.follows.length; i++){
var displayName = d2.follows[i].user.display_name;
following.push(displayName);
</code></pre>
<p>I'm searching through object to find the number of followers a channel has. is <a href="https://i.stack.imgur.com/PZUuB.png" rel="nofollow noreferrer">Here is an image of the object</a> I would greatly appreciate an explanation of this block of code.</p>
| 0debug
|
grlib_gptimer_writel(void *opaque, target_phys_addr_t addr, uint32_t value)
{
GPTimerUnit *unit = opaque;
target_phys_addr_t timer_addr;
int id;
addr &= 0xff;
switch (addr) {
case SCALER_OFFSET:
value &= 0xFFFF;
unit->scaler = value;
trace_grlib_gptimer_writel(-1, "scaler:", unit->scaler);
return;
case SCALER_RELOAD_OFFSET:
value &= 0xFFFF;
unit->reload = value;
trace_grlib_gptimer_writel(-1, "reload:", unit->reload);
grlib_gptimer_set_scaler(unit, value);
return;
case CONFIG_OFFSET:
trace_grlib_gptimer_writel(-1, "config (Read Only):", 0);
return;
default:
break;
}
timer_addr = (addr % TIMER_BASE);
id = (addr - TIMER_BASE) / TIMER_BASE;
if (id >= 0 && id < unit->nr_timers) {
switch (timer_addr) {
case COUNTER_OFFSET:
trace_grlib_gptimer_writel(id, "counter:", value);
unit->timers[id].counter = value;
grlib_gptimer_enable(&unit->timers[id]);
return;
case COUNTER_RELOAD_OFFSET:
trace_grlib_gptimer_writel(id, "reload:", value);
unit->timers[id].reload = value;
return;
case CONFIG_OFFSET:
trace_grlib_gptimer_writel(id, "config:", value);
if (value & GPTIMER_INT_PENDING) {
value &= ~GPTIMER_INT_PENDING;
} else {
value |= unit->timers[id].config & GPTIMER_INT_PENDING;
}
unit->timers[id].config = value;
if (value & GPTIMER_LOAD) {
grlib_gptimer_restart(&unit->timers[id]);
} else if (value & GPTIMER_ENABLE) {
grlib_gptimer_enable(&unit->timers[id]);
}
value &= ~(GPTIMER_LOAD & GPTIMER_DEBUG_HALT);
unit->timers[id].config = value;
return;
default:
break;
}
}
trace_grlib_gptimer_unknown_register("write", addr);
}
| 1threat
|
static int protocol_client_vencrypt_init(VncState *vs, uint8_t *data, size_t len)
{
if (data[0] != 0 ||
data[1] != 2) {
VNC_DEBUG("Unsupported VeNCrypt protocol %d.%d\n", (int)data[0], (int)data[1]);
vnc_write_u8(vs, 1);
vnc_flush(vs);
vnc_client_error(vs);
} else {
VNC_DEBUG("Sending allowed auth %d\n", vs->subauth);
vnc_write_u8(vs, 0);
vnc_write_u8(vs, 1);
vnc_write_u32(vs, vs->subauth);
vnc_flush(vs);
vnc_read_when(vs, protocol_client_vencrypt_auth, 4);
}
return 0;
}
| 1threat
|
build_qp_table(PPS *pps, int index)
{
int i;
for(i = 0; i < 255; i++)
pps->chroma_qp_table[i & 0xff] = chroma_qp[av_clip(i + index, 0, 51)];
pps->chroma_qp_index_offset = index;
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.