problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
static av_cold int nvenc_alloc_surface(AVCodecContext *avctx, int idx)
{
NvencContext *ctx = avctx->priv_data;
NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs;
NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs;
NVENCSTATUS nv_status;
NV_ENC_CREATE_BITSTREAM_BUFFER allocOut = { 0 };
allocOut.version = NV_ENC_CREATE_BITSTREAM_BUFFER_VER;
if (avctx->pix_fmt == AV_PIX_FMT_CUDA) {
ctx->surfaces[idx].in_ref = av_frame_alloc();
if (!ctx->surfaces[idx].in_ref)
return AVERROR(ENOMEM);
} else {
NV_ENC_CREATE_INPUT_BUFFER allocSurf = { 0 };
ctx->surfaces[idx].format = nvenc_map_buffer_format(ctx->data_pix_fmt);
if (ctx->surfaces[idx].format == NV_ENC_BUFFER_FORMAT_UNDEFINED) {
av_log(avctx, AV_LOG_FATAL, "Invalid input pixel format: %s\n",
av_get_pix_fmt_name(ctx->data_pix_fmt));
return AVERROR(EINVAL);
}
allocSurf.version = NV_ENC_CREATE_INPUT_BUFFER_VER;
allocSurf.width = (avctx->width + 31) & ~31;
allocSurf.height = (avctx->height + 31) & ~31;
allocSurf.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED;
allocSurf.bufferFmt = ctx->surfaces[idx].format;
nv_status = p_nvenc->nvEncCreateInputBuffer(ctx->nvencoder, &allocSurf);
if (nv_status != NV_ENC_SUCCESS) {
return nvenc_print_error(avctx, nv_status, "CreateInputBuffer failed");
}
ctx->surfaces[idx].input_surface = allocSurf.inputBuffer;
ctx->surfaces[idx].width = allocSurf.width;
ctx->surfaces[idx].height = allocSurf.height;
}
ctx->surfaces[idx].lockCount = 0;
allocOut.size = 1024 * 1024;
allocOut.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED;
nv_status = p_nvenc->nvEncCreateBitstreamBuffer(ctx->nvencoder, &allocOut);
if (nv_status != NV_ENC_SUCCESS) {
int err = nvenc_print_error(avctx, nv_status, "CreateBitstreamBuffer failed");
if (avctx->pix_fmt != AV_PIX_FMT_CUDA)
p_nvenc->nvEncDestroyInputBuffer(ctx->nvencoder, ctx->surfaces[idx].input_surface);
av_frame_free(&ctx->surfaces[idx].in_ref);
return err;
}
ctx->surfaces[idx].output_surface = allocOut.bitstreamBuffer;
ctx->surfaces[idx].size = allocOut.size;
return 0;
}
| 1threat |
What is best way to handle global connection of Mongodb in NodeJs : <p>I using <a href="https://github.com/mongodb/node-mongodb-native" rel="noreferrer">Node-Mongo-Native</a> and trying to set a global connection variable, but I am confused between two possible solutions. Can you guys help me out with which one would be the good one?
1. Solution ( which is bad because every request will try to create a new connection.)</p>
<pre><code>var express = require('express');
var app = express();
var MongoClient = require('mongodb').MongoClient;
var assert = require('assert');
// Connection URL
var url = '[connectionString]]';
// start server on port 3000
app.listen(3000, '0.0.0.0', function() {
// print a message when the server starts listening
console.log("server starting");
});
// Use connect method to connect to the server when the page is requested
app.get('/', function(request, response) {
MongoClient.connect(url, function(err, db) {
assert.equal(null, err);
db.listCollections({}).toArray(function(err, collections) {
assert.equal(null, err);
collections.forEach(function(collection) {
console.log(collection);
});
db.close();
})
response.send('Connected - see console for a list of available collections');
});
});
</code></pre>
<ol start="2">
<li><p>Solution ( to connect at app init and assign the connection string to a global variable). but I believe assigning connection string to a global variable is a not a good idea.</p>
<p>var mongodb;
var url = '[connectionString]';
MongoClient.connect(url, function(err, db) {<br>
assert.equal(null, err);
mongodb=db;
}
);</p></li>
</ol>
<p>I want to create a connection at the app initialization and use throughout the app lifetime.</p>
<p>Can you guys help me out? Thanks.</p>
| 0debug |
static void inc_refcounts(BlockDriverState *bs,
uint16_t *refcount_table,
int refcount_table_size,
int64_t offset, int64_t size)
{
BDRVQcowState *s = bs->opaque;
int64_t start, last, cluster_offset;
int k;
if (size <= 0)
return;
start = offset & ~(s->cluster_size - 1);
last = (offset + size - 1) & ~(s->cluster_size - 1);
for(cluster_offset = start; cluster_offset <= last;
cluster_offset += s->cluster_size) {
k = cluster_offset >> s->cluster_bits;
if (k < 0 || k >= refcount_table_size) {
fprintf(stderr, "ERROR: invalid cluster offset=0x%" PRIx64 "\n",
cluster_offset);
} else {
if (++refcount_table[k] == 0) {
fprintf(stderr, "ERROR: overflow cluster offset=0x%" PRIx64
"\n", cluster_offset);
}
}
}
}
| 1threat |
win32.Dispatch vs win32.gencache in Python. What are the pros and cons? : <p>I have been recently using win32com.client from python as an API for windows applications but am struggling to understand some basic things.</p>
<p>I had been using it with a program called WEAP, in the following way</p>
<pre><code>import win32com.client
win32com.client.Dispatch("WEAP.WEAPApplication")
</code></pre>
<p>Now, I want to use it with Excel and have found alternatives to the previous lines, one of them as follows (taken from <a href="https://stackoverflow.com/questions/39877278/python-open-excel-workbook-using-win32-com-api">Python: Open Excel Workbook using Win32 COM Api</a>)</p>
<pre><code>import win32com.client as win32
excel = win32.gencache.EnsureDispatch('Excel.Application')
</code></pre>
<p>Does anyone know the difference between using </p>
<pre><code>win32.Dispatch
</code></pre>
<p>and </p>
<pre><code>win32.gencache.EnsureDispatch
</code></pre>
<p>and other alternatives? Does anyone know pros and cons of each one? or some advice regarding when one or another should be used?</p>
<p>I have looked for advice and i have found some useful answers, eg:</p>
<p><a href="https://stackoverflow.com/questions/39877278/python-open-excel-workbook-using-win32-com-api">Python: Open Excel Workbook using Win32 COM Api</a></p>
<p><a href="https://stackoverflow.com/questions/11623461/win32com-client-dispatch-works-but-not-win32com-client-gencache-ensuredispatch">win32com.client.Dispatch works but not win32com.client.gencache.EnsureDispatch</a></p>
<p><a href="http://pythonexcels.com/python-excel-mini-cookbook/" rel="noreferrer">http://pythonexcels.com/python-excel-mini-cookbook/</a></p>
<p><a href="https://mail.python.org/pipermail/python-win32/2011-August/011738.html" rel="noreferrer">https://mail.python.org/pipermail/python-win32/2011-August/011738.html</a></p>
<p>However, they are usually focused on answering specific issues, and not describing the bigger picture of the differences between Dispatch, gencache.EnsureDispatch, and perhaps further alternatives, which is what i want.</p>
<p>Any advice would be greatly appreciated.</p>
| 0debug |
why is .center only working in the y axis for me? : class ViewController: UIViewController {
@IBOutlet var friendsButton: UIImageView! //Friends Button
@IBOutlet var circleButton: UIImageView! //Circle Button
@IBOutlet var profileButton: UIImageView! //Profile Button
@IBOutlet var whiteBoxSelector: UIImageView! //White Box Selector
override func viewDidLayoutSubviews() {
whiteBoxSelector.center = self.friendsButton.center //line that doesn't seem to run properly
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Once i run this, my whiteBoxSelector moves to the friends button, but only in the y axis, and the x position seems to be 0. I havemt set any constrains for the white box | 0debug |
HOW CAN I SEND A USSD CODE FROM PHP TO ANY NETWORK PROVIDER? : How can i send USSD code like *556# from php to any network provider like MTN,GLO or Airtel.
For instance ,say i have two inputs where user can enter USSD code and Phone number. On getting to the server(PHP),the received code will be dialed on the received phone number and send to the network provider. please is this possible? thanks
| 0debug |
def same_order(l1, l2):
common_elements = set(l1) & set(l2)
l1 = [e for e in l1 if e in common_elements]
l2 = [e for e in l2 if e in common_elements]
return l1 == l2 | 0debug |
Fixed length loop in Python? : <p>I have googled on how to write a fixed length loop in Python but haven't found anything, so I ask here:</p>
<pre><code> for i in range(0, 25):
index = int(random.uniform(0, len(characters)))
code += characters[index]
return code
</code></pre>
<p>As you see I don't need <code>i</code>. How can I rewrite this to be a fixed length loop where I don't have to define <code>i</code>?</p>
| 0debug |
How can I see which webpack loaders are used for which files? : <p>Is there a way to make webpack display the exact loader used for each module?</p>
<p>I want to verify that <code>babel-loader</code> is being used for certain modules. How can I validate that my <code>module.rules[].test</code> regular expressions are working as I intend?</p>
<p>The <code>--verbose</code> option does not display loader info.</p>
| 0debug |
static void spr_write_40x_sler (void *opaque, int sprn)
{
DisasContext *ctx = opaque;
gen_op_store_40x_sler();
RET_STOP(ctx);
}
| 1threat |
Convert Map<List> to List<NewType> with new java 9 streams : I need help using the java 8 streams API to convert
Map<String, List<Entry<Parameter, String>>> inputData
to
List<TestSession> testList
with the following test session
private static class TestSession {
final String mServiceName;
final String mData;
public TestSession(
final String aServiceName,
final String aData) {
mServiceName = aServiceName;
mData= aData;
}
}
and
enum Parameter {
Foo,
Bar,
Baz
}
Lets say that input data contains the following
{"ABC", {{Parameter.Foo, "hello"},{Parameter.Bar, "bye"} }
{"DEF", {{Parameter.Baz, "hello1"},{Parameter.Foo, "bye1"} }
I would like the testList to contain
{
TestSession("ABC", Parameter.Foo, "hello"),
TestSession("ABC", Parameter.Bar, "bye"),
TestSession("DEF", Parameter.Baz, "hello1"),
TestSession("DEF", Parameter.Foo, "bye1")
}
The idea is that each `TestSession` is constructed using the Key from the `inputData` and | 0debug |
Scala - How to Fetch top 10 Product Prices for each Category : I am new to scala and have a DataFrame, I need to find the top 10 product prices for each category_id. top 20 rows of a dataframe is as below
[enter image description here][1]
[1]: https://i.stack.imgur.com/TezNc.png
Please let me know how to do this. | 0debug |
rtsp_read_reply (AVFormatContext *s, RTSPMessageHeader *reply,
unsigned char **content_ptr, int return_on_interleaved_data)
{
RTSPState *rt = s->priv_data;
char buf[4096], buf1[1024], *q;
unsigned char ch;
const char *p;
int ret, content_length, line_count = 0;
unsigned char *content = NULL;
memset(reply, 0, sizeof(*reply));
rt->last_reply[0] = '\0';
for(;;) {
q = buf;
for(;;) {
ret = url_read_complete(rt->rtsp_hd, &ch, 1);
#ifdef DEBUG_RTP_TCP
dprintf(s, "ret=%d c=%02x [%c]\n", ret, ch, ch);
#endif
if (ret != 1)
return -1;
if (ch == '\n')
break;
if (ch == '$') {
if (return_on_interleaved_data) {
return 1;
} else
rtsp_skip_packet(s);
} else if (ch != '\r') {
if ((q - buf) < sizeof(buf) - 1)
*q++ = ch;
}
}
*q = '\0';
dprintf(s, "line='%s'\n", buf);
if (buf[0] == '\0')
break;
p = buf;
if (line_count == 0) {
get_word(buf1, sizeof(buf1), &p);
get_word(buf1, sizeof(buf1), &p);
reply->status_code = atoi(buf1);
} else {
rtsp_parse_line(reply, p);
av_strlcat(rt->last_reply, p, sizeof(rt->last_reply));
av_strlcat(rt->last_reply, "\n", sizeof(rt->last_reply));
}
line_count++;
}
if (rt->session_id[0] == '\0' && reply->session_id[0] != '\0')
av_strlcpy(rt->session_id, reply->session_id, sizeof(rt->session_id));
content_length = reply->content_length;
if (content_length > 0) {
content = av_malloc(content_length + 1);
(void)url_read_complete(rt->rtsp_hd, content, content_length);
content[content_length] = '\0';
}
if (content_ptr)
*content_ptr = content;
else
av_free(content);
if (reply->notice == 2101 ||
reply->notice == 2104 ||
reply->notice == 2306 )
rt->state = RTSP_STATE_IDLE;
else if (reply->notice >= 4400 && reply->notice < 5500)
return AVERROR(EIO);
else if (reply->notice == 2401 ||
(reply->notice >= 5500 && reply->notice < 5600) )
return AVERROR(EPERM);
return 0;
}
| 1threat |
static inline int IRQ_testbit(IRQQueue *q, int n_IRQ)
{
return test_bit(q->queue, n_IRQ);
}
| 1threat |
working of compareTo() method of Comparable interface : I have one Employee class and the requirement is to sort the objects using comparable interface. The output with this code is :
The difference of this id and other id is..** 6 other id**1
The difference of this id and other id is..** 3 other id**6
The difference of this id and other id is..** 3 other id**6
The difference of this id and other id is..** 3 other id**1
The difference of this id and other id is..** 11 other id**3
The difference of this id and other id is..** 11 other id**6
[Employee [name=lalit, id=1], Employee [name=zanjan, id=3], Employee [name=rmit, id=6], Employee [name=harjot, id=11]]
public class Employee implements Comparable<Employee> {
private String name;
private Integer id;
@Override
public String toString() {
return "Employee [name=" + name + ", id=" + id + "]";
}
public Employee(Integer id, String name) {
this.name = name;
this.id = id;
}
public String getName() {
return name;
}
public Integer id() {
return id;
}
public void setName(String name) {
this.name = name;
}
public void setID(Integer id) {
this.id = id;
}
@Override
public int compareTo(Employee o) {
System.out.println("The difference of this id and other id is..** " + id + " other id**" + o.id);
System.out.println(this.id);
System.out.println(o.id);
return this.id - o.id;
}
}
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
public class ComparableDemo
{
public static void main(String args[])
{
Employee e1 = new Employee(1, "lalit");
Employee e2 = new Employee(6, "rmit");
Employee e3 = new Employee(3, "zanjan");
Employee e4 = new Employee(11, "harjot");
List<Employee> empList = new ArrayList<Employee>();
empList.add(e1);
empList.add(e2);
empList.add(e3);
empList.add(e4);
Collections.sort(empList);
System.out.println(empList);
}
}
My questions are :
1. How the first comparison would be between 6 & 1.
2. How number 6 is assigned to this.id ?
3. What is the need of comparing 3 & 6 two times? in the second and third line
of output.
4. How actually compareTo method works, means how this subtraction leads to
sorting using Comparable.
5. What are the values for this.id and how these values are assigned in this.id | 0debug |
Generate All Possible Combinations - Java : <p>I have a list of items {a,b,c,d} and I need to generate all possible combinations when, </p>
<ul>
<li>you can select any number of items</li>
<li>the order is not important (ab = ba)</li>
<li>empty set is not considered</li>
</ul>
<p>If we take the possibilities, it should be, </p>
<pre><code>n=4, number of items
total #of combinations = 4C4 + 4C3 + 4C2 + 4C1 = 15
</code></pre>
<p>I used the following recursive method:</p>
<pre><code>private void countAllCombinations (String input,int idx, String[] options) {
for(int i = idx ; i < options.length; i++) {
String output = input + "_" + options[i];
System.out.println(output);
countAllCombinations(output,++idx, options);
}
}
public static void main(String[] args) {
String arr[] = {"A","B","C","D"};
for (int i=0;i<arr.length;i++) {
countAllCombinations(arr[i], i, arr);
}
}
</code></pre>
<p>Is there a more efficient way of doing this when the array size is large?</p>
| 0debug |
Can I use HighCharts without paying : I am doing a calculator web app . Can I use HighCharts for that without paying! Can I use demo charts at least. The price is too high. Is there any open source site like highcharts so that I can use it for free. | 0debug |
Integer 0 is found in vector calling for the -1 index? : When I initialize a vector:
std::vector <int> someVec;
and I call:
std::cout << someVec[-1];
with an arbitrary number of elements, 0 is always returned. Is there someway to get around this? This fault in cpp is messing up my "sort" function. Is there anyway to initialize said vector differently in order to return the last element in the vector, rather than 0 which seems to be the default. It seems that any index called outside the range of the vector will result in 0. It isn't wrapped which is baffling me. Thanks for the help, kind stranger!
| 0debug |
void ppc_set_irq(PowerPCCPU *cpu, int n_IRQ, int level)
{
CPUState *cs = CPU(cpu);
CPUPPCState *env = &cpu->env;
unsigned int old_pending = env->pending_interrupts;
if (level) {
env->pending_interrupts |= 1 << n_IRQ;
cpu_interrupt(cs, CPU_INTERRUPT_HARD);
} else {
env->pending_interrupts &= ~(1 << n_IRQ);
if (env->pending_interrupts == 0) {
cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
}
}
if (old_pending != env->pending_interrupts) {
#ifdef CONFIG_KVM
kvmppc_set_interrupt(cpu, n_IRQ, level);
#endif
}
LOG_IRQ("%s: %p n_IRQ %d level %d => pending %08" PRIx32
"req %08x\n", __func__, env, n_IRQ, level,
env->pending_interrupts, CPU(cpu)->interrupt_request);
}
| 1threat |
How to explicitly set the storage path of an image clicked using Cordova API? : I am extremely new to Cordova and I'm working on the Android platform, and need to store the image at a custom location.
The 'navigator.camera.getPicture' method stores the clicked image in the cache, but I need to store that image at a custom folder in the root. How to do that? | 0debug |
IIS Express, ASP.NET Core - Invalid URI: The hostname could not be parsed : <p>Back from my weekend and went to debug my web project which is an ASP.NET Core Web Api. It started giving me an error: Invalid URI: The hostname could not be parsed.</p>
<p>I can start a new asp.net core web api project and it debugs fine so I'm pretty sure its something with my configuration for this project. Any ideas?</p>
<p>James</p>
| 0debug |
const char * avdevice_configuration(void)
{
return FFMPEG_CONFIGURATION;
}
| 1threat |
Typescript "error TS2532: Object is possibly 'undefined'" even after undefined check : <p>I'm trying to use the <code>--strict</code> option on <code>tsc</code> but I ran into the following "weird" case that I don't seem to understand.</p>
<p>If I write:</p>
<pre><code>function testStrict(input: {query?: {[prop: string]: string}}) {
if (input.query) {
Object.keys(input.query).forEach(key => {
input.query[key];
})
}
return input;
}
</code></pre>
<p>the compiler complains about:</p>
<blockquote>
<p>test.ts(5,9): error TS2532: Object is possibly 'undefined'.</p>
</blockquote>
<p>(the offending line is <code>input.query[key];</code>)</p>
<p>What I don't understand is, I have already checked for undefined with the if guard on the first line of the function <code>if (input.query)</code>, so <strong>why does the compiler think it could possibly be undefined?</strong></p>
<p>I fixed this by adding another identical guard before the object access, like:</p>
<pre><code>function testStrict(input: {query?: {[prop: string]: string}}) {
if (input.query) {
Object.keys(input.query).forEach(key => {
if (input.query) {
input.query[key];
}
})
}
return input;
}
</code></pre>
<p>but I don't understand why another identical line would be required.</p>
| 0debug |
void ppc_store_sdr1(CPUPPCState *env, target_ulong value)
{
LOG_MMU("%s: " TARGET_FMT_lx "\n", __func__, value);
if (env->spr[SPR_SDR1] != value) {
env->spr[SPR_SDR1] = value;
#if defined(TARGET_PPC64)
if (env->mmu_model & POWERPC_MMU_64) {
target_ulong htabsize = value & SDR_64_HTABSIZE;
if (htabsize > 28) {
fprintf(stderr, "Invalid HTABSIZE 0x" TARGET_FMT_lx
" stored in SDR1\n", htabsize);
htabsize = 28;
}
env->htab_mask = (1ULL << (htabsize + 18)) - 1;
env->htab_base = value & SDR_64_HTABORG;
} else
#endif
{
env->htab_mask = ((value & SDR_32_HTABMASK) << 16) | 0xFFFF;
env->htab_base = value & SDR_32_HTABORG;
}
tlb_flush(env, 1);
}
}
| 1threat |
uint32 float32_to_uint32( float32 a STATUS_PARAM )
{
int64_t v;
uint32 res;
v = float32_to_int64(a STATUS_VAR);
if (v < 0) {
res = 0;
float_raise( float_flag_invalid STATUS_VAR);
} else if (v > 0xffffffff) {
res = 0xffffffff;
float_raise( float_flag_invalid STATUS_VAR);
} else {
res = v;
}
return res;
}
| 1threat |
How do I make text bold, italic, or underline in React Native? : <p>Surprisingly there isn't one question that groups these all together yet on Stack Overflow; there hasn't been an answer on SO for italics or underline, in fact, only <a href="https://stackoverflow.com/questions/35718143/react-native-add-bold-or-italics-to-single-words-in-text-field">this question</a> for bold. I self-answered this quesiton below.</p>
| 0debug |
How to upload images to a database with other details using postman : <p>I want to upload a image with other details like employee id, employee name etc using spring boot and spring data jpa, trying to send request using postman.I have searched a lot but I cannot find any examples sending both image and other details in one method, as I am a fresher unable to find exact solution and also I don't want to use ObjectMapper to read values.Can some one help me.
Thanks in advance</p>
| 0debug |
Cannot run XAMARIN UI TEST on xamarin.forms, error System.Exception : <p>I want ton run Xamarin UI test, but when i run the test i have this error : </p>
<pre><code>System.Exception : 'The running adb server is incompatible with the Android SDK version in use by UITest:
C:\Program Files (x86)\Android\android-sdk
</code></pre>
<p>my start command-line : <code>
return ConfigureApp.Android.ApkFile("/Users/Jerem/source/repos/App4/App4/App4.Android/bin/Debug/com.companyname.App4-Signed.apk").StartApp();</code></p>
<p>Thanks for our helping </p>
| 0debug |
void bdrv_detach(BlockDriverState *bs, DeviceState *qdev)
{
assert(bs->peer == qdev);
bs->peer = NULL;
bs->change_cb = NULL;
bs->change_opaque = NULL;
}
| 1threat |
my program is throughing exceptions and i cant figure out why : i am trying to create a snake game but my code is giving me exceptions and i cant figure out what it might be.
i am creating this snake game because i want to learn more c# since my teacher said that 4th quarter i get to choose what i want to do with my time.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace snake_game
{
class Program
{
static void Main(string[] args)
{
int xposition = 26;
int yposition = 26;
int LeftColumn = 1;
int rightcolumn = 50;
int topcolumn = 1;
int bottomcolumn = 50;
string[,] map = new string[51, 51];
map = buildWall(LeftColumn, rightcolumn, topcolumn,
bottomcolumn, map);
//places down the player and updates the map to tell where you
are
Console.SetCursorPosition(xposition, yposition);
Console.Write((char)2);
map[xposition, yposition] = "player";
map = generateRandomApple(map, LeftColumn, rightcolumn,
topcolumn, bottomcolumn);
placeApple(map);
Console.ReadKey();
}
private static void placeApple(string[,] map)
{
//places down the apple
for (int x = 0; x < map.Length; x++)
{
for (int y = 0; y < map.Length; y++)
{
if (map[x, y].Equals("apple"))
{
Console.Write("a");
break;
}
}
}
}
private static string[,] generateRandomApple(string[,] map, int lc, int
rc, int tc, int bc)
{
Random rnd = new Random();
int xposition;
int yposition;
while (true)
{
//generates random cordinates to place down the apple
xposition = rnd.Next(lc, rc);
yposition = rnd.Next(tc, bc);
//sets the property that the apple wants to be at to the apple
if it isnt open in the map
if ((!map[xposition, yposition].Equals("the wall")) &&
(!map[xposition, yposition].Equals("player")))
{
map[xposition, yposition] = "apple";
break;
}
}
return map;
}
private static string[,] buildWall(int leftcolumn, int rightcolumn, int
topcolumn, int bottomcolumn, string[,] map)
{
//generates the left and right walls
for (int i = leftcolumn; i <= rightcolumn ; i++)
{
Console.SetCursorPosition(leftcolumn, i);
Console.BackgroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write("#");
map[leftcolumn, i] = "the wall";
Console.SetCursorPosition(rightcolumn, i);
Console.Write("#");
map[rightcolumn, i] = "the wall";
}
//generates the top and bottom walls
for (int i = topcolumn; i <= bottomcolumn; i++)
{
Console.SetCursorPosition(i, topcolumn);
Console.Write("#");
map[i, topcolumn] = "the wall";
Console.SetCursorPosition(i, bottomcolumn);
Console.Write("#");
map[i, bottomcolumn] = "the wall";
}
return map;
}
}
}
can anyone help me figure out what might be giving me the exceptions. i would appreciate the help | 0debug |
Sorting digits in a string or integer? : <p>I have a combination lock with 10 buttons and I have to press in 4 buttons and then hit Open. Order of the buttons doesn't matter and each button can only be pressed once.</p>
<p>I am sure there are some probability theory and permutation that makes this an easy problem, but I would like to solve it in Ruby.</p>
<p>My thought is to have a while loop and then sort the digits in the counter and if each digit only occur once, then try to insert it in a hash, where I than can get the length of the hash at the end to have number of combinations.</p>
<p>But how can I sort the digits in a string or inter?</p>
<p>Or is there a smarter algorithm for this?</p>
| 0debug |
static int config(struct vf_instance *vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
return ff_vf_next_config(vf, width * vf->priv->scalew,
height / vf->priv->scaleh - vf->priv->skipline, d_width, d_height, flags, IMGFMT_YV12);
}
| 1threat |
How to reduce numbers of AND used in this MYSQL query : This is the query I am working on and somehow it takes to much time and eventually times out, which makes me think if I can reduce the number of AND in the WHERE Clause. I am new to this Huge Queries, Please help me out. Thank you :)
SELECT sfog.entity_id,
(
CASE
WHEN sfog.status = 'delivered' THEN 'Order'
WHEN sfog.status IN ('return','rtndelivered','closed') THEN 'Return Order'
WHEN sfog.status = 'CanceledBS' THEN 'CanceledBS Order'
END) AS Type,
CONCAT(cev1.value,' ', cev2.value) AS 'Vendor Name',
sfog.status AS Status,
sfog.increment_id AS OrderNo ,
sfosh.created_at AS 'Invoice Date',
mo.tracking_number AS 'Tracking Number',
CONCAT(sfoa.firstname,' ', sfoa.lastname) AS 'Customer Name',
CONCAT(sfoa.street,' ',sfoa.city,' ',sfoa.region,' ',sfoa.postcode) AS 'Address',
sfoa.email AS 'Email',
group_concat( DISTINCT sfoi.sku SEPARATOR ', ') AS `Product Name`,
sfo.total_qty_ordered AS 'Qty',
SUM(ms.totalamountut) AS 'Order Value'
FROM sales_flat_order_grid sfog, sales_flat_order_status_history sfosh, customer_entity_varchar cev1, customer_entity_varchar cev2, marketplace_orders mo, sales_flat_order_address sfoa, sales_flat_order_item sfoi, sales_flat_order sfo, marketplace_saleslist ms
WHERE sfog.status IN ('delivered','return','rtndelivered','closed','CanceledBS') and sfosh.parent_id = sfog.entity_id and cev1.attribute_id = '5' and cev2.attribute_id = '7' and mo.seller_id = cev1.entity_id and mo.seller_id = cev2.entity_id and mo.order_id = sfog.entity_id and sfoa.parent_id = sfog.entity_id and sfoi.order_id = sfog.entity_id and sfo.entity_id = sfog.entity_id and ms.mageorderid = sfog.entity_id GROUP BY sfog.entity_id; | 0debug |
PHP7 with APCu - Call to undefined function apc_fetch() : <p>I have installed APCu extension in PHP7</p>
<p>But I get this error</p>
<pre><code>Call to undefined function apc_fetch()
</code></pre>
<p><a href="https://i.stack.imgur.com/WpQc8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WpQc8.png" alt="enter image description here"></a></p>
| 0debug |
Is there any cheat sheet for opencv-python? : <p>I've been working on face tracking turret with OpenCV_Python version 4.1.0, but I don't know a lot of commands and functions. So I tried to look up Google or other documentation to see if there's any cheat sheet for OpenCV_Python that has all the possible functions and brief explanations about them. </p>
<p>I only found a cheat sheet for OpenCV_C++ version 2.7.0, but couldn't find any cheat sheet for OpenCV_Python. </p>
<p>I saw the official OpenCV 3.0.0 documentation for Python as well, but that only shows few functions for general things you can do. </p>
<p>Is there any source or document(or book) that I can learn all the possible functions of OpenCV_Python?</p>
| 0debug |
npm install doesn't create node_modules dir : <p>I have a node js application. In package.json I inserted the dependences, but when I execute 'npm install' the node_modules dir has a strange structure:</p>
<p>the dependences of my dependency are installed in the node_modules of my application. An example.
Consider this dependency graph</p>
<pre><code>foo
-- a
+-- b
-- c
+-- d
-- e
-- f
-- g
</code></pre>
<p>I expected this folder structure: </p>
<pre><code>foo
+--node_modules
-- a
-- b
+--node_modules
-- c
+-- d
+--node_modules
-- e
-- f
+--node_modules
-- g
</code></pre>
<p>Instead all modules are installed in </p>
<pre><code>foo
+--node_modules
-- a
-- b
-- c
-- d
-- e
-- f
-- g
</code></pre>
| 0debug |
static QObject *parse_value(JSONParserContext *ctxt, QList **tokens, va_list *ap)
{
QObject *obj;
obj = parse_object(ctxt, tokens, ap);
if (obj == NULL) {
obj = parse_array(ctxt, tokens, ap);
}
if (obj == NULL) {
obj = parse_escape(ctxt, tokens, ap);
}
if (obj == NULL) {
obj = parse_keyword(ctxt, tokens);
}
if (obj == NULL) {
obj = parse_literal(ctxt, tokens);
}
return obj;
}
| 1threat |
static int encode_dvd_subtitles(AVCodecContext *avctx,
uint8_t *outbuf, int outbuf_size,
const AVSubtitle *h)
{
DVDSubtitleContext *dvdc = avctx->priv_data;
uint8_t *q, *qq;
int offset1, offset2;
int i, rects = h->num_rects, ret;
unsigned global_palette_hits[33] = { 0 };
int cmap[256];
int out_palette[4];
int out_alpha[4];
AVSubtitleRect vrect;
uint8_t *vrect_data = NULL;
int x2, y2;
if (rects == 0 || h->rects == NULL)
vrect = *h->rects[0];
if (rects > 1) {
int xmin = h->rects[0]->x, xmax = xmin + h->rects[0]->w;
int ymin = h->rects[0]->y, ymax = ymin + h->rects[0]->h;
for (i = 1; i < rects; i++) {
xmin = FFMIN(xmin, h->rects[i]->x);
ymin = FFMIN(ymin, h->rects[i]->y);
xmax = FFMAX(xmax, h->rects[i]->x + h->rects[i]->w);
ymax = FFMAX(ymax, h->rects[i]->y + h->rects[i]->h);
vrect.x = xmin;
vrect.y = ymin;
vrect.w = xmax - xmin;
vrect.h = ymax - ymin;
if ((ret = av_image_check_size(vrect.w, vrect.h, 0, avctx)) < 0)
return ret;
global_palette_hits[0] = vrect.w * vrect.h;
global_palette_hits[0] -= h->rects[i]->w * h->rects[i]->h;
count_colors(avctx, global_palette_hits, h->rects[i]);
select_palette(avctx, out_palette, out_alpha, global_palette_hits);
if (rects > 1) {
if (!(vrect_data = av_calloc(vrect.w, vrect.h)))
return AVERROR(ENOMEM);
vrect.pict.data [0] = vrect_data;
vrect.pict.linesize[0] = vrect.w;
for (i = 0; i < rects; i++) {
build_color_map(avctx, cmap, (uint32_t *)h->rects[i]->pict.data[1],
out_palette, out_alpha);
copy_rectangle(&vrect, h->rects[i], cmap);
for (i = 0; i < 4; i++)
cmap[i] = i;
} else {
build_color_map(avctx, cmap, (uint32_t *)h->rects[0]->pict.data[1],
out_palette, out_alpha);
av_log(avctx, AV_LOG_DEBUG, "Selected palette:");
for (i = 0; i < 4; i++)
av_log(avctx, AV_LOG_DEBUG, " 0x%06x@@%02x (0x%x,0x%x)",
dvdc->global_palette[out_palette[i]], out_alpha[i],
out_palette[i], out_alpha[i] >> 4);
av_log(avctx, AV_LOG_DEBUG, "\n");
q = outbuf + 4;
offset1 = q - outbuf;
if ((q - outbuf) + vrect.w * vrect.h / 2 + 17 + 21 > outbuf_size) {
av_log(NULL, AV_LOG_ERROR, "dvd_subtitle too big\n");
ret = AVERROR_BUFFER_TOO_SMALL;
goto fail;
dvd_encode_rle(&q, vrect.pict.data[0], vrect.w * 2,
vrect.w, (vrect.h + 1) >> 1, cmap);
offset2 = q - outbuf;
dvd_encode_rle(&q, vrect.pict.data[0] + vrect.w, vrect.w * 2,
vrect.w, vrect.h >> 1, cmap);
qq = outbuf + 2;
bytestream_put_be16(&qq, q - outbuf);
bytestream_put_be16(&q, (h->start_display_time*90) >> 10);
bytestream_put_be16(&q, (q - outbuf) + 8 + 12 + 2);
*q++ = 0x03;
*q++ = (out_palette[3] << 4) | out_palette[2];
*q++ = (out_palette[1] << 4) | out_palette[0];
*q++ = 0x04;
*q++ = (out_alpha[3] & 0xF0) | (out_alpha[2] >> 4);
*q++ = (out_alpha[1] & 0xF0) | (out_alpha[0] >> 4);
x2 = vrect.x + vrect.w - 1;
y2 = vrect.y + vrect.h - 1;
*q++ = 0x05;
*q++ = vrect.x >> 4;
*q++ = (vrect.x << 4) | ((x2 >> 8) & 0xf);
*q++ = x2;
*q++ = vrect.y >> 4;
*q++ = (vrect.y << 4) | ((y2 >> 8) & 0xf);
*q++ = y2;
*q++ = 0x06;
bytestream_put_be16(&q, offset1);
bytestream_put_be16(&q, offset2);
*q++ = 0x01;
*q++ = 0xff;
bytestream_put_be16(&q, (h->end_display_time*90) >> 10);
bytestream_put_be16(&q, (q - outbuf) - 2 );
*q++ = 0x02;
*q++ = 0xff;
qq = outbuf;
bytestream_put_be16(&qq, q - outbuf);
av_log(NULL, AV_LOG_DEBUG, "subtitle_packet size=%td\n", q - outbuf);
ret = q - outbuf;
fail:
av_free(vrect_data);
return ret;
| 1threat |
Is google-services.json safe from hackers? : <p>If a hacker decompiled my APK would he be able to see my API keys from this file? I am not worried about my source code repository. I am just worried about a hacker being able to see this API key from my APK somehow. I'm trying to encrypt this file and decrypt it at runtime but having some issues </p>
| 0debug |
How to create type safe enums? : <p>To achieve type safety with enums in C is problematic, since they are essentially just integers. And enumeration constants are in fact defined to be of type <code>int</code> by the standard.</p>
<p>To achieve a bit of type safety I do tricks with pointers like this:</p>
<pre><code>typedef enum
{
BLUE,
RED
} color_t;
void color_assign (color_t* var, color_t val)
{
*var = val;
}
</code></pre>
<p>Because pointers have stricter type rules than values, so this prevents code such as this:</p>
<pre><code>int x;
color_assign(&x, BLUE); // compiler error
</code></pre>
<p>But it doesn't prevent code like this:</p>
<pre><code>color_t color;
color_assign(&color, 123); // garbage value
</code></pre>
<p>This is because the enumeration constant is essentially just an <code>int</code> and can get implicitly assigned to an enumeration variable. </p>
<p>Is there a way to write such a function or macro <code>color_assign</code>, that can achieve complete type safety even for enumeration constants?</p>
| 0debug |
window.location.href = 'http://attack.com?user=' + user_input; | 1threat |
Why is my number coming up as 0? : <p>I am trying to make a calculator that calculates the amount of calories that have been burned in a certain amount of time, but whenever I run it, I get 0 as the output. I have tried setting the calorieCountOut variable to an arbitrary number, and then it works fine, but every time I run it with this code here, I get 0. Here is my code:</p>
<pre><code>const AGECONST = 0.2017;
const WEIGHTCONST = 0.09036;
const HRCONST = 0.6309;
const SUBTRACTCONST = 55.0969;
const TIMECONST = 4.184;
//var gender = document.getElementById("gender").innerHTML;
var gender = "male";
var weight = document.getElementById("weight");
var age = document.getElementById("age");
var time = document.getElementById("time");
var hr = 140;//dummy number
function calculate(){
if (gender = "male"){
var calorieCount = ((age * AGECONST) - (weight * WEIGHTCONST) + (hr * HRCONST) - SUBTRACTCONST) * time / TIMECONST;
}
//else if (gender = "female"){
//}
var calorieCountOut = calorieCount.toString();
document.getElementById("output").innerHTML = calorieCountOut;
}
</code></pre>
| 0debug |
Why will this Js function return undefined? : <p>My goal is to pass in a variable that will apply to many processes within the function, but some rule im unaware of must be coming into play. It will return my passed variable, but will not return the full object including my variable as a parent...</p>
<pre><code>var test = {number:1,color:'red'};
function Make(data){
console.log(data) //returns test
console.log(test.number) //returns 1
console.log(data,test.number) //returns test 1
console.log(data.number) //returns undefined
};
Make("test");
</code></pre>
| 0debug |
static void video_audio_display(VideoState *s)
{
int i, i_start, x, y1, y, ys, delay, n, nb_display_channels;
int ch, channels, h, h2, bgcolor, fgcolor;
int16_t time_diff;
int rdft_bits, nb_freq;
for (rdft_bits = 1; (1 << rdft_bits) < 2 * s->height; rdft_bits++)
;
nb_freq = 1 << (rdft_bits - 1);
channels = s->audio_tgt.channels;
nb_display_channels = channels;
if (!s->paused) {
int data_used= s->show_mode == SHOW_MODE_WAVES ? s->width : (2*nb_freq);
n = 2 * channels;
delay = s->audio_write_buf_size;
delay /= n;
if (audio_callback_time) {
time_diff = av_gettime() - audio_callback_time;
delay -= (time_diff * s->audio_tgt.freq) / 1000000;
}
delay += 2 * data_used;
if (delay < data_used)
delay = data_used;
i_start= x = compute_mod(s->sample_array_index - delay * channels, SAMPLE_ARRAY_SIZE);
if (s->show_mode == SHOW_MODE_WAVES) {
h = INT_MIN;
for (i = 0; i < 1000; i += channels) {
int idx = (SAMPLE_ARRAY_SIZE + x - i) % SAMPLE_ARRAY_SIZE;
int a = s->sample_array[idx];
int b = s->sample_array[(idx + 4 * channels) % SAMPLE_ARRAY_SIZE];
int c = s->sample_array[(idx + 5 * channels) % SAMPLE_ARRAY_SIZE];
int d = s->sample_array[(idx + 9 * channels) % SAMPLE_ARRAY_SIZE];
int score = a - d;
if (h < score && (b ^ c) < 0) {
h = score;
i_start = idx;
}
}
}
s->last_i_start = i_start;
} else {
i_start = s->last_i_start;
}
bgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);
if (s->show_mode == SHOW_MODE_WAVES) {
fill_rectangle(screen,
s->xleft, s->ytop, s->width, s->height,
bgcolor, 0);
fgcolor = SDL_MapRGB(screen->format, 0xff, 0xff, 0xff);
h = s->height / nb_display_channels;
h2 = (h * 9) / 20;
for (ch = 0; ch < nb_display_channels; ch++) {
i = i_start + ch;
y1 = s->ytop + ch * h + (h / 2);
for (x = 0; x < s->width; x++) {
y = (s->sample_array[i] * h2) >> 15;
if (y < 0) {
y = -y;
ys = y1 - y;
} else {
ys = y1;
}
fill_rectangle(screen,
s->xleft + x, ys, 1, y,
fgcolor, 0);
i += channels;
if (i >= SAMPLE_ARRAY_SIZE)
i -= SAMPLE_ARRAY_SIZE;
}
}
fgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0xff);
for (ch = 1; ch < nb_display_channels; ch++) {
y = s->ytop + ch * h;
fill_rectangle(screen,
s->xleft, y, s->width, 1,
fgcolor, 0);
}
SDL_UpdateRect(screen, s->xleft, s->ytop, s->width, s->height);
} else {
nb_display_channels= FFMIN(nb_display_channels, 2);
if (rdft_bits != s->rdft_bits) {
av_rdft_end(s->rdft);
av_free(s->rdft_data);
s->rdft = av_rdft_init(rdft_bits, DFT_R2C);
s->rdft_bits = rdft_bits;
s->rdft_data = av_malloc(4 * nb_freq * sizeof(*s->rdft_data));
}
{
FFTSample *data[2];
for (ch = 0; ch < nb_display_channels; ch++) {
data[ch] = s->rdft_data + 2 * nb_freq * ch;
i = i_start + ch;
for (x = 0; x < 2 * nb_freq; x++) {
double w = (x-nb_freq) * (1.0 / nb_freq);
data[ch][x] = s->sample_array[i] * (1.0 - w * w);
i += channels;
if (i >= SAMPLE_ARRAY_SIZE)
i -= SAMPLE_ARRAY_SIZE;
}
av_rdft_calc(s->rdft, data[ch]);
}
for (y = 0; y < s->height; y++) {
double w = 1 / sqrt(nb_freq);
int a = sqrt(w * sqrt(data[0][2 * y + 0] * data[0][2 * y + 0] + data[0][2 * y + 1] * data[0][2 * y + 1]));
int b = (nb_display_channels == 2 ) ? sqrt(w * sqrt(data[1][2 * y + 0] * data[1][2 * y + 0]
+ data[1][2 * y + 1] * data[1][2 * y + 1])) : a;
a = FFMIN(a, 255);
b = FFMIN(b, 255);
fgcolor = SDL_MapRGB(screen->format, a, b, (a + b) / 2);
fill_rectangle(screen,
s->xpos, s->height-y, 1, 1,
fgcolor, 0);
}
}
SDL_UpdateRect(screen, s->xpos, s->ytop, 1, s->height);
if (!s->paused)
s->xpos++;
if (s->xpos >= s->width)
s->xpos= s->xleft;
}
}
| 1threat |
SerialState *serial_mm_init(MemoryRegion *address_space,
hwaddr base, int it_shift,
qemu_irq irq, int baudbase,
CharDriverState *chr, enum device_endian end)
{
SerialState *s;
Error *err = NULL;
s = g_malloc0(sizeof(SerialState));
s->it_shift = it_shift;
s->irq = irq;
s->baudbase = baudbase;
s->chr = chr;
serial_realize_core(s, &err);
if (err != NULL) {
error_report("%s", error_get_pretty(err));
error_free(err);
exit(1);
}
vmstate_register(NULL, base, &vmstate_serial, s);
memory_region_init_io(&s->io, NULL, &serial_mm_ops[end], s,
"serial", 8 << it_shift);
memory_region_add_subregion(address_space, base, &s->io);
serial_update_msl(s);
return s;
}
| 1threat |
php game Rock, paper, scissors : <p>So, I am creating a Rock, Paper, Scissor game in php. I am creating two webpages. The first webpage will contain three radio buttons for rock, paper, scissor and one submit button. The first page will send the information to the second page. The second page is the computer. The computer will randomly choose between rock, paper, scissor.</p>
<p>This is what I have right now. It is just not sending the information in the right way.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>First page:
<?php
session_start(); //session start
if(!isset($_SESSION['username'])) //if session not found redirect to homepage
{
header('location:login.php');
}
else{
echo '<form action="game.php" method="post" />
<input type="radio" name="user_choice" value="Rock" title="Rock" />Rock <br /><br />
<input type="radio" name="user_choice" value="Paper" title="Paper" />Paper <br /><br />
<input type="radio" name="user_choice" value="Scissors" title="Scissors" />Scissors <br /><br />
<input type="submit" name="form_submit" value="submit"/>
</form> ';
}
?>
Second Page:
<?php
session_start(); //session start
//if session not found redirect to homepage
if(!isset($_SESSION['username'])) {
header('location:login.php');
} elseif {
if($_POST['user_choice']) {
$user_choice = $_POST['user_choice'];
$Choosefrom= array('Rock', 'Paper', 'Scissors');
$Choice= rand(0,2);
$Computer=$Choosefrom[$Choice];
if($user_choice == $Computer) {
echo 'Player: '.$user_choice.' CPU: '.$Computer.'. Result: Win';
} else {
echo 'Player: '.$user_choice.' CPU: '.$Computer.'. Result: Lose';
}
}
}
?></code></pre>
</div>
</div>
</p>
| 0debug |
static int open_f(BlockDriverState *bs, int argc, char **argv)
{
int flags = 0;
int readonly = 0;
int growable = 0;
int c;
QemuOpts *qopts;
QDict *opts;
while ((c = getopt(argc, argv, "snrgo:")) != EOF) {
switch (c) {
case 's':
flags |= BDRV_O_SNAPSHOT;
break;
case 'n':
flags |= BDRV_O_NOCACHE | BDRV_O_CACHE_WB;
break;
case 'r':
readonly = 1;
break;
case 'g':
growable = 1;
break;
case 'o':
if (!qemu_opts_parse(&empty_opts, optarg, 0)) {
printf("could not parse option list -- %s\n", optarg);
qemu_opts_reset(&empty_opts);
return 0;
}
break;
default:
qemu_opts_reset(&empty_opts);
return qemuio_command_usage(&open_cmd);
}
}
if (!readonly) {
flags |= BDRV_O_RDWR;
}
qopts = qemu_opts_find(&empty_opts, NULL);
opts = qopts ? qemu_opts_to_qdict(qopts, NULL) : NULL;
qemu_opts_reset(&empty_opts);
if (optind == argc - 1) {
return openfile(argv[optind], flags, growable, opts);
} else if (optind == argc) {
return openfile(NULL, flags, growable, opts);
} else {
return qemuio_command_usage(&open_cmd);
}
} | 1threat |
react-transform-catch-errors does not look like a React component : <p>I'm working on a react project and we are using react starter kit. I am new to the project and when I clone the project from github and start the project using <code>npm start</code> it start the server but in web inspector I get following error.</p>
<p><code>Uncaught Error: imports[1] for react-transform-catch-errors does not look like a React component.</code></p>
<p>People who already working in the project doesn't get this error. But when I ask from one friend to get a new clone and do the same thing I did he also got the same error.</p>
<p>I don't know what details need to post so if anybody need more details please ask.</p>
| 0debug |
installing mysql connection in python : sudo apt-get install python-pip python-dev libmysqlclient-dev
when i run above :
I got:
> Reading package lists... Done
Building dependency tree
Reading state information... Done
libmysqlclient-dev is already the newest version.
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
python-pip : Depends: python-setuptools (>= 0.6c1) but it is not going to be installed
Depends: python-requests but it is not going to be installed
Recommends: python-dev-all (>= 2.6) but it is not installable
E: Unable to correct problems, you have held broken packages | 0debug |
void gen_intermediate_code(CPUAlphaState *env, struct TranslationBlock *tb)
{
AlphaCPU *cpu = alpha_env_get_cpu(env);
CPUState *cs = CPU(cpu);
DisasContext ctx, *ctxp = &ctx;
target_ulong pc_start;
target_ulong pc_mask;
uint32_t insn;
ExitStatus ret;
int num_insns;
int max_insns;
pc_start = tb->pc;
ctx.tb = tb;
ctx.pc = pc_start;
ctx.tbflags = tb->flags;
ctx.mem_idx = cpu_mmu_index(env, false);
ctx.implver = env->implver;
ctx.amask = env->amask;
ctx.singlestep_enabled = cs->singlestep_enabled;
#ifdef CONFIG_USER_ONLY
ctx.ir = cpu_std_ir;
#else
ctx.palbr = env->palbr;
ctx.ir = (ctx.tbflags & ENV_FLAG_PAL_MODE ? cpu_pal_ir : cpu_std_ir);
#endif
ctx.tb_rm = -1;
ctx.tb_ftz = -1;
TCGV_UNUSED_I64(ctx.zero);
TCGV_UNUSED_I64(ctx.sink);
TCGV_UNUSED_I64(ctx.lit);
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0) {
max_insns = CF_COUNT_MASK;
if (max_insns > TCG_MAX_INSNS) {
max_insns = TCG_MAX_INSNS;
if (in_superpage(&ctx, pc_start)) {
pc_mask = (1ULL << 41) - 1;
} else {
pc_mask = ~TARGET_PAGE_MASK;
gen_tb_start(tb);
tcg_clear_temp_count();
do {
tcg_gen_insn_start(ctx.pc);
num_insns++;
if (unlikely(cpu_breakpoint_test(cs, ctx.pc, BP_ANY))) {
ret = gen_excp(&ctx, EXCP_DEBUG, 0);
ctx.pc += 4;
break;
if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
insn = cpu_ldl_code(env, ctx.pc);
ctx.pc += 4;
ret = translate_one(ctxp, insn);
free_context_temps(ctxp);
if (ret == NO_EXIT
&& ((ctx.pc & pc_mask) == 0
|| tcg_op_buf_full()
|| num_insns >= max_insns
|| singlestep
|| ctx.singlestep_enabled)) {
ret = EXIT_FALLTHRU;
} while (ret == NO_EXIT);
if (tb->cflags & CF_LAST_IO) {
gen_io_end();
switch (ret) {
case EXIT_GOTO_TB:
case EXIT_NORETURN:
break;
case EXIT_FALLTHRU:
if (use_goto_tb(&ctx, ctx.pc)) {
tcg_gen_goto_tb(0);
tcg_gen_movi_i64(cpu_pc, ctx.pc);
tcg_gen_exit_tb((uintptr_t)ctx.tb);
case EXIT_PC_STALE:
tcg_gen_movi_i64(cpu_pc, ctx.pc);
case EXIT_PC_UPDATED:
if (!use_exit_tb(&ctx)) {
tcg_gen_lookup_and_goto_ptr(cpu_pc);
break;
case EXIT_PC_UPDATED_NOCHAIN:
if (ctx.singlestep_enabled) {
gen_excp_1(EXCP_DEBUG, 0);
} else {
tcg_gen_exit_tb(0);
break;
default:
g_assert_not_reached();
gen_tb_end(tb, num_insns);
tb->size = ctx.pc - pc_start;
tb->icount = num_insns;
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
qemu_log_lock();
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(cs, pc_start, ctx.pc - pc_start, 1);
qemu_log("\n");
qemu_log_unlock();
#endif | 1threat |
void qemu_thread_create(QemuThread *thread, const char *name,
void *(*start_routine)(void*),
void *arg, int mode)
{
sigset_t set, oldset;
int err;
pthread_attr_t attr;
err = pthread_attr_init(&attr);
if (err) {
error_exit(err, __func__);
}
if (mode == QEMU_THREAD_DETACHED) {
err = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (err) {
error_exit(err, __func__);
}
}
sigfillset(&set);
pthread_sigmask(SIG_SETMASK, &set, &oldset);
err = pthread_create(&thread->thread, &attr, start_routine, arg);
if (err)
error_exit(err, __func__);
if (name_threads) {
qemu_thread_set_name(thread, name);
}
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
pthread_attr_destroy(&attr);
}
| 1threat |
Can't get Root View from Data Binding after enabling safe-args plugin : <p>I'm working on an Android app using dataBinding and am currently trying to add the safe-args plugin, but after enabling the plugin, I can no longer get the root view via binding.root - Android Studio gives the error: </p>
<pre><code>Unresolved Reference
None of the following candidates is applicable because of a receiver type mismatch:
* internal val File.root: File defined in kotlin.io
</code></pre>
<p>How can I get databinding and safe-args to play nice together?</p>
<p>Note that while the code snippet is in Kotlin I will happily take Java answers. Not as comfortable in Java but I can easily read it and translate it.</p>
<p>I haven't been able to find anyone else with the same problem by Googling the error message and "safe args". I tried first with the classpath listed in the Android docs here: <a href="https://developer.android.com/guide/navigation/navigation-pass-data" rel="noreferrer">https://developer.android.com/guide/navigation/navigation-pass-data</a></p>
<pre><code>classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.1.0"
</code></pre>
<p>And then also found a tutorial suggesting I use:</p>
<pre><code>classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha07"
</code></pre>
<p>Both had the same issue: binding.root gave an error with the plugin activated</p>
<p>Here is my onCreateView() for my fragment. That return line works properly when safe-args isn't enabled and doesn't work when it is enabled</p>
<pre><code> override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_encoder, container, false)
return binding.root
}
</code></pre>
<p>Any help solving or understanding this problem is most appreciated!</p>
| 0debug |
redirect to login as part of session check : <p>for the life of me can't get the header redirect or the java redirect to work in this lock.php </p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><?php
include 'config.php' ;
session_start();
$user_check=$_SESSION['login_user'];
$ses_sql=mysqli_query($db,"select username from users where username='$user_check' ");
$row=mysqli_fetch_array($ses_sql,MYSQLI_ASSOC); //confirm username from users table
$login_session=$row['username'];
if ($login_session ==""){
// echo "the variable is empty"; //when i check this works here.
//header ("Location: login.php"); //redirect to login -tried this, fail
echo "<script> location.href='login.php'; </script>"; // tried this, fail
exit(); //stop execution of any further script
}
?></code></pre>
</div>
</div>
</p>
| 0debug |
static int rtl8139_can_receive(VLANClientState *nc)
{
RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque;
int avail;
if (!s->clock_enabled)
return 1;
if (!rtl8139_receiver_enabled(s))
return 1;
if (rtl8139_cp_receiver_enabled(s)) {
return 1;
} else {
avail = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr,
s->RxBufferSize);
return (avail == 0 || avail >= 1514);
}
} | 1threat |
Is Anyone have a Listview Renderer for chat : <p>I need a ListView Renderer for Chat like whatsapp.</p>
<p>when if the new Message comes its automatically scroll down.</p>
<p>Please let me know if have a sample for this.</p>
<p>thanks</p>
| 0debug |
static int svq3_decode_slice_header(AVCodecContext *avctx)
{
SVQ3Context *svq3 = avctx->priv_data;
H264Context *h = &svq3->h;
MpegEncContext *s = &h->s;
const int mb_xy = h->mb_xy;
int i, header;
header = get_bits(&s->gb, 8);
if (((header & 0x9F) != 1 && (header & 0x9F) != 2) || (header & 0x60) == 0) {
av_log(avctx, AV_LOG_ERROR, "unsupported slice header (%02X)\n", header);
return -1;
} else {
int length = header >> 5 & 3;
svq3->next_slice_index = get_bits_count(&s->gb) +
8 * show_bits(&s->gb, 8 * length) +
8 * length;
if (svq3->next_slice_index > s->gb.size_in_bits) {
av_log(avctx, AV_LOG_ERROR, "slice after bitstream end\n");
return -1;
}
s->gb.size_in_bits = svq3->next_slice_index - 8 * (length - 1);
skip_bits(&s->gb, 8);
if (svq3->watermark_key) {
uint32_t header = AV_RL32(&s->gb.buffer[(get_bits_count(&s->gb) >> 3) + 1]);
AV_WL32(&s->gb.buffer[(get_bits_count(&s->gb) >> 3) + 1],
header ^ svq3->watermark_key);
}
if (length > 0) {
memcpy((uint8_t *) &s->gb.buffer[get_bits_count(&s->gb) >> 3],
&s->gb.buffer[s->gb.size_in_bits >> 3], length - 1);
}
skip_bits_long(&s->gb, 0);
}
if ((i = svq3_get_ue_golomb(&s->gb)) == INVALID_VLC || i >= 3) {
av_log(h->s.avctx, AV_LOG_ERROR, "illegal slice type %d \n", i);
return -1;
}
h->slice_type = golomb_to_pict_type[i];
if ((header & 0x9F) == 2) {
i = (s->mb_num < 64) ? 6 : (1 + av_log2(s->mb_num - 1));
s->mb_skip_run = get_bits(&s->gb, i) -
(s->mb_y * s->mb_width + s->mb_x);
} else {
skip_bits1(&s->gb);
s->mb_skip_run = 0;
}
h->slice_num = get_bits(&s->gb, 8);
s->qscale = get_bits(&s->gb, 5);
s->adaptive_quant = get_bits1(&s->gb);
skip_bits1(&s->gb);
if (svq3->unknown_flag)
skip_bits1(&s->gb);
skip_bits1(&s->gb);
skip_bits(&s->gb, 2);
while (get_bits1(&s->gb))
skip_bits(&s->gb, 8);
if (s->mb_x > 0) {
memset(h->intra4x4_pred_mode + h->mb2br_xy[mb_xy - 1] + 3,
-1, 4 * sizeof(int8_t));
memset(h->intra4x4_pred_mode + h->mb2br_xy[mb_xy - s->mb_x],
-1, 8 * sizeof(int8_t) * s->mb_x);
}
if (s->mb_y > 0) {
memset(h->intra4x4_pred_mode + h->mb2br_xy[mb_xy - s->mb_stride],
-1, 8 * sizeof(int8_t) * (s->mb_width - s->mb_x));
if (s->mb_x > 0)
h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride - 1] + 3] = -1;
}
return 0;
}
| 1threat |
Private parameters in Typescript : <p>I am learning <code>Angular2</code> and working with <code>classes</code> in <code>javascript</code> first time.</p>
<p>What does the <code>private</code> parameter and why it couldn't be simply <code>heroService: HeroService</code> ? </p>
<pre><code>constructor(private heroService: HeroService) { }
</code></pre>
| 0debug |
button function for all fetch row : now i m doing project for my university. i have a problem,i create page where user can send friend request.here i fetch data from another table and put button for each row data. my problem is when one button click other row button also was change to friend request. i need a solution for it. how to make one add friend request button is equal to one row id and how to avoid other button affected whenever click particular row.Below i attach my code. I hope you guys will help me. thanks in advance.
php
<?php
session_start();
$_SESSION['myid'];
$mysqli=new MySQLi('127.0.0.1','root','','learning_malaysia');
$sql = "SELECT * FROM tutor_register INNER JOIN tutorskill ON tutor_register.register_ID = tutorskill.register_ID ORDER BY
tutor_register.register_ID='".$_SESSION['myid']."'desc";
$result= mysqli_query($mysqli,$sql);
if(mysqli_num_rows($result)>0)
{
while($row = mysqli_fetch_array($result))
{
$register_ID=$row["register_ID"];
$username = $row['username'];
$profile = $row['profile'];
$email = $row['email'];
$address=$row['address'];
$gender=$row['gender'];
$main_subject=$row["main_subject"];
$subject_add=$row["subject_add"];
$rate_main=$row["rate_main"];
$rate_add=$row["rate_add"];
$qualification=$row["qualification"];
?>
<table><form method="post">
<tr class="border_bottom">
<td height="230"><img src='<?php echo $profile;?>'width="200" height="200"/> </td><td><td></td></td>
<?php
if($register_ID == $_SESSION['myid']){
?>
<td><label>Your Profile</label></td>
<?php
} else {
?>
<form method="post">
<td><button class='friendBtn unfriend' name="" data-type="unfriend">Unfriend</button>
<input type="hidden" name="id" value="<?php echo $row['register_ID'];?>" />
<input type="submit" name="addfriend" data-type='addfriend' id="addfriend" value="<?php
if($_SESSION['status'] == 'yes'){
echo 'Request Sent';
}
else {
echo 'Addfriend';}
?>" data-uid=<?php echo $row['register_ID'];?>/></td> </form>
<?php
}
}
?>
</tr>
</div>
</table>
</form>
<?php
if(isset($_POST['id']) ) {
$user_id = $_SESSION['myid'];
$friend_id = $_POST['id'];
$sql="INSERT INTO friends(user_id,status,friend_id)" ."VALUES('$user_id','yes','$friend_id') ";
if($mysqli->query($sql)=== true) {
$_SESSION['status']="yes";
$_SESSION['id']=$row['id'];
} else {}
}
}
?>
</body>
</html>
| 0debug |
How can get HttpClient Status Code in Angular 4 : <p>In Http Module I can easily get the response code using response.status, but when I used HttpClient Module I cannot get the response.status, it shows undefined.</p>
<p>So, how can I get the response.status using HttpClient module in Angular 4. Please help.</p>
| 0debug |
Is there a way to integrate git with Jupyter and have a version control over the notebooks created? : <p>I have hosted jupyterhub on a server and added many users into it. I want the users to have an option of version control for their work. So is there any way to add a git kernel or extension do have this done?</p>
| 0debug |
Run code on application startup Phoenix Framework (Elixir) : <p>Were would you put code which you want to run only when your application/api starts in vanilla Phoenix application? Let's say I want to make sure some mnesia tables are created or configure my logger backend. The other thing is runtime configuration. They mention it in documentation but it's not clear to me where one would define/change runtime configuration. </p>
<p><code>Endpoint.ex</code> seems like a place where initial configuration is done but by looking at docs I can't find any callback that would allow me to run code only once at startup.</p>
| 0debug |
my android api level in unity is 0 : i have installed android-sdk on my computer. my API level is 27. but when i want to built an android app in unity i have an error that says the minimum API level you need is 23 but the android API level on my computer is 0.
i have uninstalled and reinstalled android SDK. i changed the name of my android folder in tools folder from android 8.0.1 to android_23 and android_27.
i changed the folder of android SDK.
and i don't have android studio on my PC.
i don't know what to do. help please. | 0debug |
Select distinct occurances of substring from a column in SQL : I am trying to find a portion of distinct email addresses (@gmail.com)
in a column which contains a paragraph of text which may contain one or more instances of the email address. My table contains several rows with paragraphs and I am trying to indentify the unique email address that use @gmail.com.
Thanks in advance | 0debug |
Is the HEAP a term for ram, processor memory or BOTH? And how many unions can I allocate for at once? : <p>I was hoping someone had some schooling they could lay down about the whole HEAP and stack ordeal. I am trying to make a program that would attempt to create about 20,000 instances of just one union and if so some day I may want to implement a much larger program. Other than my current project consisting of a maximum of just 20,000 unions stored where ever c++ will allocate them do you think I could up the anti into the millions while retaining a reasonable return speed on function calls, approximately 1,360,000 or so? And how do you think it will handle 20,000?</p>
| 0debug |
what this program prints the wrong reutls : <p>What I am trying to do is:</p>
<p>I have a list of values, and I want to list each three of them. For example:</p>
<p>I have: </p>
<pre><code>"one", "two", "three", "four", "five"
</code></pre>
<p>And I want to print the following:</p>
<pre><code>one two three
one two four
one four five
two three four
two three five
and so on
</code></pre>
<p>You got the point, I want every three values (not in order off course)</p>
<p>What I did is:</p>
<pre><code>import java.util.*;
public class Solution {
public static void main(String args[]) {
String[] people = new String[] { "one", "two", "three", "four",
"five" };
Solution s = new Solution();
s.solve(people, 3, new LinkedList<>(), 0);
}
public void solve(String[] people, int n, List<String> data, int i) {
if (data.size() == n) {
System.out.println(data.toString());
} else if (i < people.length) {
String value = people[i];
solve(people, n, data, i + 1);
data.add(value);
solve(people, n, data, i + 1);
}
}
}
</code></pre>
<p>You can run it:</p>
<p>My problem is that it prints:</p>
<blockquote>
<p>[five, four, five]</p>
</blockquote>
<p>Which is obviously wrong, how can It print two same values? In my code, I add the value once and I don't add it another time</p>
<p>Could you help?</p>
| 0debug |
sort string array in c, but program crashes : <p>I'm looping through a file to find matching records for a user input, then I need to print them in an ascending order. My program keeps crashing. I need help please. I've written a few functions to do the work.</p>
<pre><code>static int myCompare (const void * a, const void * b)
{
return strcmp (*(const char **) a, *(const char **) b);
}
void sort(const char *arr[], int n)
{
qsort (arr, n, sizeof (const char *), myCompare);
}
void search_contact() {
FILE * fp;
bool found = false;
char *records;
fp = fopen("contact.txt", "r");
system("cls");
printf("\t*****SEARCH CONTACT*****");
printf("\n\t Enter Mobile: ");
char mobile[20];
scanf("%s", mobile);
char mobile1[20], name[20];
while (fscanf(fp, "%s %s", name, mobile1) != EOF) {
if (strcmp(mobile, mobile1) == 0) {
records = malloc(sizeof(name));
strcpy(records,name);
int i;
// printf(" %s", records);
found = true;
} else {
found = false;
}
}
if(found){
int n = sizeof(records)/sizeof(records[0]);
sort(records, n);
int i;
for (i = 0; i < n; i++)
printf("%s \n", records[i]);
}
else{
printf("\n No Records Found!");
}
fclose(fp);
printf("\n\tPRESS ANY KEY TO CONTINUE");
getch();
main();
}
</code></pre>
| 0debug |
Failed to find 'ANDROID_HOME' environment variable : <p>I am trying to build an ionic-android project and i have android sdk installed. </p>
<p><a href="https://i.stack.imgur.com/Bmoa3.png"><img src="https://i.stack.imgur.com/Bmoa3.png" alt="SDK manager installed packages"></a></p>
<p>The name of my project is myApp.I have successfully added android platform to myApp. But when i tries to build the project</p>
<pre><code>~/myApp$ sudo ionic build android
</code></pre>
<p>result is </p>
<pre><code>Running command: /home/hari/myApp/hooks/after_prepare/010_add_platform_class.js /home/hari/myApp
add to body class: platform-android
ERROR building one of the platforms: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
You may not have the required environment or OS to build this project
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
</code></pre>
<p>see the ANDROID_HOME and PATH variable</p>
<pre><code>echo $ANDROID_HOME
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/hari/Android/Sdk
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/hari/Android/Sdk/tools:/home/hari/Android/Sdk/platform-tools:/usr/local/bin:/opt/gradle/bin
</code></pre>
<p>I have seen almost the same kind of questions on stack overflow, but none works for me. Is there anything wrong with my android-sdk configuration? How can i build this project? </p>
| 0debug |
My file is not working and reading the context from the file in C++ : <p>I tried to open a certain file and read the content to put it into a string named letters but then every time I typed the file name I keep getting error can't find open the file.</p>
<p>void createTree()
{</p>
<pre><code>BTS tree;
string filename;
string letters;
ifstream file;
int input = 0;
cout<<"Enter the file name: "; // ask the user to input the file name
cin >>filename; //input the user input into filename
file.open(filename.c_str());
if(file)
{
cout<<"File is open";
while(!file.eof())
{
cout<< "In the while loop"<<endl;
getline(file, letters);
tree.insertWord(letters);
}
}
else
cout<<"Error can't open the file"<<endl;
tree.printTree();
file.close();
</code></pre>
<p>}</p>
| 0debug |
What's the difference between the given two codes. One gives time limit exceeded when run on ideone and the other works fine : <p>1st code: works fine gives success with time of 0sec</p>
<pre><code> int main()
{
int n=100000;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
{}
cout<<"ffdfdf";
}
</code></pre>
<p>2nd code: gives a time limit exceeded</p>
<pre><code> int main()
{
int n=100000;
bool **a=new bool*[n];
for(int i=0;i<n;i++)
{
bool[i]=new bool[n];
for(int j=0;j<n;j++)
{
bool[i][j]=1;
}
}
cout<<"ffdfdf";
}
</code></pre>
<p>can anyone explain why the two code fragments have a vast time difference.I am not understanding it.</p>
| 0debug |
background fill the padding only except of : the background color *black* fills the padding area only *As show below* and i need it to cover the whole div area.
[![the black area is padding only!!][1]][1]
here's html: [Html Code][2]
here's Css:[Css Code][3]
[1]: https://i.stack.imgur.com/Aao47.png
[2]: http://pastebin.com/EJTDPBG8
[3]: http://pastebin.com/vmtKzyqQ | 0debug |
Multidimensional Arrays with nested for : I can't get this answer
Multidimensional arrays, nested(do..while,while,for)
char[,] stars = new char[5, 3];
for (int i = 0; i < 5; i++)
{
for(int x=0;x<3;x++)
{
stars[i,x]=char.Parse("*");
Console.Write(stars[i, x]);
I expect 5 stars then 4 then 3 then 2 then 1
| 0debug |
Parse error with php function : <p>I've been going through w3schools trying to get to grips with php. I've done a little Java and C++ in the past but nothing web side. I can't figure out why I'm getting a parse error</p>
<pre><code> <!DOCTYPE html>
<html>
<body>
<?php
// calling a variable can be done with $variable or . $Variable .
// php is loosely typed - you do not have to tell it that a var is a int or string etc
$color = "red"; //variables are case sensitive
echo "My car is " . $color . "<br>";
//scopes for vars are either local, global or static. Local are declared inside a function and global are declared outside a function
function myTest()
{
$x = 5; //local scope
echo "<p> Variable X inside function is: $x</p>;
}
?>
</body>
</html>
</code></pre>
<p>This returns a "Parse error: syntax error, unexpected end of file in C:\inetpub\wwwroot\phpinfo.php on line 28"</p>
<p>This runs fine with the function removed. What am I missing? </p>
| 0debug |
Show image from : I have small problem but I need your help. I have successfully inserted pictures into the DB therefore, I am tried to access those images through datagridview. Whenever I clcik dgv row/cell I need the picture(s) to appear in the picture box. here is my code.
SqlConnection con = new SqlConnection(ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Candidates WHERE CandidateID = '" + dataGridViewCandidate.SelectedRows[0].Cells[0].Value.ToString() + "'", con);
DataTable dt = new DataTable();
da.Fill(dt);
//dataGridViewCandidate.DataSource = dt;
byte[] binaryimage = (byte[])dt.Rows[0][1];
Bitmap image;
using (MemoryStream stream = new MemoryStream(binaryimage))
{
image = new Bitmap(stream);
}
EmployeePhoto.Image = image;
The error I am getting is below;
Unable to cast object of type 'System.DateTime' to type 'System.Byte[]'
Thank you for your help. | 0debug |
android patern plotting in python : for school i need to make make a android patern or just a patern in a 3x3 matrix
the pattern is [8, 7, 6, 5, 4, 3, 2, 0, 1] and i need to plot it in a 3x3 matrix
the first entry in the pattern is the beginningpoint and it connects to the second in the row
the result needs to be
8,9,7
6,5,4
3,2,1
patern = [8, 7, 6, 5, 4, 3, 2, 0, 1]
matrix = [0,0,0,0,0,0,0,0,0]
lijst = ([matrix[i:i + 3] for i in range(0, len(matrix), 3)])
for i in lijst:
print(i)
for char in patern:
matrix[char]=char
| 0debug |
static bool msix_vector_masked(PCIDevice *dev, int vector, bool fmask)
{
unsigned offset = vector * PCI_MSIX_ENTRY_SIZE + PCI_MSIX_ENTRY_VECTOR_CTRL;
return fmask || dev->msix_table[offset] & PCI_MSIX_ENTRY_CTRL_MASKBIT;
}
| 1threat |
static int ppc_hash64_check_prot(int prot, int rwx)
{
int ret;
if (rwx == 2) {
if (prot & PAGE_EXEC) {
ret = 0;
} else {
ret = -2;
}
} else if (rwx == 1) {
if (prot & PAGE_WRITE) {
ret = 0;
} else {
ret = -2;
}
} else {
if (prot & PAGE_READ) {
ret = 0;
} else {
ret = -2;
}
}
return ret;
}
| 1threat |
Turn Off Whole Line Copy in Visual Studio Code : <p>I'm trying to disable the function in Visual Studio Code where if you don't have a selection highlighted, ctrl+c copies the entire line. I have never tried to do this on purpose, but I am always doing it accidentally when I hit ctrl+c instead of ctrl+v.</p>
<p>Here's what I have tried, which seems like it should work:</p>
<p>Under File->Preferences->Keyboard Shortcuts, there is the default setting:</p>
<pre><code>{ "key": "ctrl+c", "command": "editor.action.clipboardCopyAction",
"when": "editorTextFocus" },
</code></pre>
<p>I have attempted to change this, so that it only copies when something is selected, by placing the following in my keybindings.json file:</p>
<pre><code>{ "key": "ctrl+c", "command": "-editor.action.clipboardCopyAction"},
{ "key": "ctrl+c", "command": "editor.action.clipboardCopyAction",
"when": "editorHasSelection" }
</code></pre>
<p>I think this should clear the previous binding before re-binding the copy action to only function when something is actually selected. HOWEVER, it doesn't work. The editor still copies a whole line when nothing is selected. If I only have the first line in there, it successfully removes the binding completely, so I know it's doing something, but the "when" tag doesn't seem to be functioning the way it should.</p>
<p>Is there any way to get the editor to do what I want?</p>
| 0debug |
i want to print helloworld recursively no times : i want to print helloworld recursively no times i want this code in this way.........................................................................................................................................................................
import java.util.*;
class ddr{
//int n;
static void hh(int n){
if(n<1) System.out.println("ffbdf");
hh(n-1);
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int no = in.nextInt();
ddr k = new ddr();
hh(no);
//hh(no);
}
| 0debug |
i want output in sql : AWBNO STATUS
123 DELIVERED
125 DELIVERED
124 RTO
126 RTO
127 NDR
128 NDR
131 DELIVERED
132 DELIVERED
133 NDR
134 DELIVERED
I want output in this way:-
TOTAL DELIVERED RTO NDR
10 5 2 3
| 0debug |
How do I send a hexadecimal code through powershell : I'm trying to send a command line through powershell so I can power on a projector via serial port. I'm using a NEC projector and the command for turn on and turn off the projector are these:
Power On:
02H 00H 00H 00H 00H 02H
Power Off:
02H 01H 00H 00H 00H 03H
I use the manufacture's software and I did monitor what it sent and for turn it on it use the following:
Open COM port
wrote:
00 bf 00 00 01 00 c0
read:
20 bf 01 20 10 00 ff 22 4d 33 35 33 57 53 00 00
00 08 12 00 00 dd
wrote:
00 bf 00 00 01 02 c2
read:
20 bf 01 20 10 02 0f ff ff ff ff 00 00 00 00 00
00 00 00 00 00 1d
Wrote(this is the command line I identified in the manual):
02 00 00 00 00 02
and then it close the open COM port.
I'm trying to figure out how to send the command.
I did some digging and found out the command
$port.WriteLine
but it doesnt send hex, it sends this:
30 30 20 62 66 20 30 30 20 30 30 20 30 31 20 30 00 bf 00 00 01 0
30 20 63 30 0a 0 c0.
any help is well appreciated!! | 0debug |
Split text at the right time in javascript : <p>I have a text in a variable, for example: "Lancer Square super / CIT" and I would like to divide the text into 2 variables after the mark, namely: "Square super" and "CIT"</p>
| 0debug |
How to use Text Watcher for multiple edit text in android? : <p>I have a situation where there will be two EditText controls, one for entering Rate Before Tax value and another one for entering Rate After Tax. I will be changing both Rate BT and Rate AT values. When I change Rate BT, then Rate AT text should change depending on Rate BT and vice versa.</p>
<p>Please help</p>
| 0debug |
shell script to find and replace words line by line : I have a file consists of hundreds of records like this
100,502030,0,444,RSVYU,10
101,501412,1,555,DDGTH,11
102,502269,0,222,DDERF,60
103,508877,2,111,SDEFV,23
How can I use shell script to replace the value of the 4th column with 000 if the value of the 3rd column is 0. | 0debug |
static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size)
{
AcpiPciHpState *s = opaque;
uint32_t val = 0;
int bsel = s->hotplug_select;
if (bsel < 0 || bsel > ACPI_PCIHP_MAX_HOTPLUG_BUS) {
return 0;
}
switch (addr) {
case PCI_UP_BASE:
val = s->acpi_pcihp_pci_status[bsel].up;
if (!s->legacy_piix) {
s->acpi_pcihp_pci_status[bsel].up = 0;
}
ACPI_PCIHP_DPRINTF("pci_up_read %" PRIu32 "\n", val);
break;
case PCI_DOWN_BASE:
val = s->acpi_pcihp_pci_status[bsel].down;
ACPI_PCIHP_DPRINTF("pci_down_read %" PRIu32 "\n", val);
break;
case PCI_EJ_BASE:
ACPI_PCIHP_DPRINTF("pci_features_read %" PRIu32 "\n", val);
break;
case PCI_RMV_BASE:
val = s->acpi_pcihp_pci_status[bsel].hotplug_enable;
ACPI_PCIHP_DPRINTF("pci_rmv_read %" PRIu32 "\n", val);
break;
case PCI_SEL_BASE:
val = s->hotplug_select;
ACPI_PCIHP_DPRINTF("pci_sel_read %" PRIu32 "\n", val);
default:
break;
}
return val;
}
| 1threat |
Composer warning "Package zendframework/zend-code is abandoned" : <p>I get a warning from composer:</p>
<p>Package zendframework/zend-code is abandoned, you should avoid using it. Use laminas/laminas-code instead.
Package zendframework/zend-eventmanager is abandoned, you should avoid using it. Use laminas/laminas-eventmanager instead.</p>
<p>However, I can't see any reference to zend in my composer.json (see below). Should I be worrying about it? Can I simply install laminas/laminas-code, etc to make it go away?</p>
<p>Any info welcome.</p>
<p>Thanks</p>
<p>Martyn</p>
<pre><code>{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"easycorp/easyadmin-bundle": "^2.0",
"edwin-luijten/oauth2-strava": "^1.3",
"egulias/email-validator": "^2.1",
"knpuniversity/oauth2-client-bundle": "^1.32",
"martynwheeler/oauth2-komoot": "dev-master",
"sensio/framework-extra-bundle": "^5.2",
"symfony/apache-pack": "^1.0",
"symfony/asset": "4.4.*",
"symfony/console": "4.4.*",
"symfony/dotenv": "4.4.*",
"symfony/expression-language": "4.4.*",
"symfony/filesystem": "4.4.*",
"symfony/flex": "^1.1",
"symfony/form": "4.4.*",
"symfony/framework-bundle": "4.4.*",
"symfony/monolog-bundle": "^3.1",
"symfony/orm-pack": "*",
"symfony/process": "4.4.*",
"symfony/security-bundle": "4.4.*",
"symfony/serializer-pack": "*",
"symfony/swiftmailer-bundle": "^3.1",
"symfony/translation": "4.4.*",
"symfony/twig-bundle": "4.4.*",
"symfony/validator": "4.4.*",
"symfony/web-link": "4.4.*",
"symfony/yaml": "4.4.*"
},
"require-dev": {
"symfony/debug-pack": "*",
"symfony/maker-bundle": "^1.0",
"symfony/profiler-pack": "*",
"symfony/test-pack": "*",
"symfony/web-server-bundle": "4.4.*"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"paragonie/random_compat": "2.*",
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "4.4.*"
}
}
}
</code></pre>
| 0debug |
Android studio java compiler error, cannot resolve R, build failed : I'm newbie here, I have some problem in my script
Hope you guys help me
[In this picture, My R script cannot resolve, and My Build failed, and Java Compiler error][1]
[1]: https://i.stack.imgur.com/Pyn0Q.png
This build failed logs
org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':app:mergeDebugResources'.
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.android.build.gradle.tasks.ResourceException: Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
and this Java Compiler error logs
Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
**FYI**
> I have done all the ways to solve this problem from various sources such as threads on this web, google, and youtube
but all did not work
I really hope that some of you will be kind enough to help me solve this problem
Thank You | 0debug |
why JavaScript function gives error when we pass this as an argument : function log(this) {
console.log(this);
}
it throws an error Unexpected token this. so why it don't accept this as a argument in JavaScript. | 0debug |
static void dec_b(DisasContext *dc)
{
if (dc->r0 == R_RA) {
LOG_DIS("ret\n");
} else if (dc->r0 == R_EA) {
LOG_DIS("eret\n");
} else if (dc->r0 == R_BA) {
LOG_DIS("bret\n");
} else {
LOG_DIS("b r%d\n", dc->r0);
}
if (dc->r0 == R_EA) {
TCGv t0 = tcg_temp_new();
int l1 = gen_new_label();
tcg_gen_andi_tl(t0, cpu_ie, IE_EIE);
tcg_gen_ori_tl(cpu_ie, cpu_ie, IE_IE);
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, IE_EIE, l1);
tcg_gen_andi_tl(cpu_ie, cpu_ie, ~IE_IE);
gen_set_label(l1);
tcg_temp_free(t0);
} else if (dc->r0 == R_BA) {
TCGv t0 = tcg_temp_new();
int l1 = gen_new_label();
tcg_gen_andi_tl(t0, cpu_ie, IE_BIE);
tcg_gen_ori_tl(cpu_ie, cpu_ie, IE_IE);
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, IE_BIE, l1);
tcg_gen_andi_tl(cpu_ie, cpu_ie, ~IE_IE);
gen_set_label(l1);
tcg_temp_free(t0);
}
tcg_gen_mov_tl(cpu_pc, cpu_R[dc->r0]);
dc->is_jmp = DISAS_JUMP;
}
| 1threat |
void ff_ass_init(AVSubtitle *sub)
{
memset(sub, 0, sizeof(*sub));
}
| 1threat |
static uint64_t omap_uwire_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
struct omap_uwire_s *s = (struct omap_uwire_s *) opaque;
int offset = addr & OMAP_MPUI_REG_MASK;
if (size != 2) {
return omap_badwidth_read16(opaque, addr);
}
switch (offset) {
case 0x00:
s->control &= ~(1 << 15);
return s->rxbuf;
case 0x04:
return s->control;
case 0x08:
return s->setup[0];
case 0x0c:
return s->setup[1];
case 0x10:
return s->setup[2];
case 0x14:
return s->setup[3];
case 0x18:
return s->setup[4];
}
OMAP_BAD_REG(addr);
return 0;
}
| 1threat |
int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
{
unsigned int first_mb_in_slice;
unsigned int pps_id;
int ret;
unsigned int slice_type, tmp, i, j;
int last_pic_structure, last_pic_droppable;
int must_reinit;
int needs_reinit = 0;
int field_pic_flag, bottom_field_flag;
int first_slice = sl == h->slice_ctx && !h->current_slice;
int frame_num, picture_structure, droppable;
PPS *pps;
h->qpel_put = h->h264qpel.put_h264_qpel_pixels_tab;
h->qpel_avg = h->h264qpel.avg_h264_qpel_pixels_tab;
first_mb_in_slice = get_ue_golomb_long(&sl->gb);
if (first_mb_in_slice == 0) {
if (h->current_slice) {
if (h->cur_pic_ptr && FIELD_PICTURE(h) && h->first_field) {
ff_h264_field_end(h, sl, 1);
h->current_slice = 0;
} else if (h->cur_pic_ptr && !FIELD_PICTURE(h) && !h->first_field && h->nal_unit_type == NAL_IDR_SLICE) {
av_log(h, AV_LOG_WARNING, "Broken frame packetizing\n");
ff_h264_field_end(h, sl, 1);
h->current_slice = 0;
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 1);
h->cur_pic_ptr = NULL;
} else
return AVERROR_INVALIDDATA;
}
if (!h->first_field) {
if (h->cur_pic_ptr && !h->droppable) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
h->picture_structure == PICT_BOTTOM_FIELD);
}
h->cur_pic_ptr = NULL;
}
}
slice_type = get_ue_golomb_31(&sl->gb);
if (slice_type > 9) {
av_log(h->avctx, AV_LOG_ERROR,
"slice type %d too large at %d\n",
slice_type, first_mb_in_slice);
return AVERROR_INVALIDDATA;
}
if (slice_type > 4) {
slice_type -= 5;
sl->slice_type_fixed = 1;
} else
sl->slice_type_fixed = 0;
slice_type = golomb_to_pict_type[slice_type];
sl->slice_type = slice_type;
sl->slice_type_nos = slice_type & 3;
if (h->nal_unit_type == NAL_IDR_SLICE &&
sl->slice_type_nos != AV_PICTURE_TYPE_I) {
av_log(h->avctx, AV_LOG_ERROR, "A non-intra slice in an IDR NAL unit.\n");
return AVERROR_INVALIDDATA;
}
if (
(h->avctx->skip_frame >= AVDISCARD_NONREF && !h->nal_ref_idc) ||
(h->avctx->skip_frame >= AVDISCARD_BIDIR && sl->slice_type_nos == AV_PICTURE_TYPE_B) ||
(h->avctx->skip_frame >= AVDISCARD_NONINTRA && sl->slice_type_nos != AV_PICTURE_TYPE_I) ||
(h->avctx->skip_frame >= AVDISCARD_NONKEY && h->nal_unit_type != NAL_IDR_SLICE) ||
h->avctx->skip_frame >= AVDISCARD_ALL) {
return SLICE_SKIPED;
}
h->pict_type = sl->slice_type;
pps_id = get_ue_golomb(&sl->gb);
if (pps_id >= MAX_PPS_COUNT) {
av_log(h->avctx, AV_LOG_ERROR, "pps_id %u out of range\n", pps_id);
return AVERROR_INVALIDDATA;
}
if (!h->pps_buffers[pps_id]) {
av_log(h->avctx, AV_LOG_ERROR,
"non-existing PPS %u referenced\n",
pps_id);
return AVERROR_INVALIDDATA;
}
if (h->au_pps_id >= 0 && pps_id != h->au_pps_id) {
av_log(h->avctx, AV_LOG_ERROR,
"PPS change from %d to %d forbidden\n",
h->au_pps_id, pps_id);
return AVERROR_INVALIDDATA;
}
pps = h->pps_buffers[pps_id];
if (!h->sps_buffers[pps->sps_id]) {
av_log(h->avctx, AV_LOG_ERROR,
"non-existing SPS %u referenced\n",
h->pps.sps_id);
return AVERROR_INVALIDDATA;
}
if (first_slice)
h->pps = *h->pps_buffers[pps_id];
if (pps->sps_id != h->sps.sps_id ||
pps->sps_id != h->current_sps_id ||
h->sps_buffers[pps->sps_id]->new) {
if (!first_slice) {
av_log(h->avctx, AV_LOG_ERROR,
"SPS changed in the middle of the frame\n");
return AVERROR_INVALIDDATA;
}
h->sps = *h->sps_buffers[h->pps.sps_id];
if (h->mb_width != h->sps.mb_width ||
h->mb_height != h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag) ||
h->cur_bit_depth_luma != h->sps.bit_depth_luma ||
h->cur_chroma_format_idc != h->sps.chroma_format_idc
)
needs_reinit = 1;
if (h->bit_depth_luma != h->sps.bit_depth_luma ||
h->chroma_format_idc != h->sps.chroma_format_idc) {
h->bit_depth_luma = h->sps.bit_depth_luma;
h->chroma_format_idc = h->sps.chroma_format_idc;
needs_reinit = 1;
}
if ((ret = ff_h264_set_parameter_from_sps(h)) < 0)
return ret;
}
h->avctx->profile = ff_h264_get_profile(&h->sps);
h->avctx->level = h->sps.level_idc;
h->avctx->refs = h->sps.ref_frame_count;
must_reinit = (h->context_initialized &&
( 16*h->sps.mb_width != h->avctx->coded_width
|| 16*h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag) != h->avctx->coded_height
|| h->cur_bit_depth_luma != h->sps.bit_depth_luma
|| h->cur_chroma_format_idc != h->sps.chroma_format_idc
|| h->mb_width != h->sps.mb_width
|| h->mb_height != h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag)
));
if (h->avctx->pix_fmt == AV_PIX_FMT_NONE
|| (non_j_pixfmt(h->avctx->pix_fmt) != non_j_pixfmt(get_pixel_format(h, 0))))
must_reinit = 1;
if (first_slice && av_cmp_q(h->sps.sar, h->avctx->sample_aspect_ratio))
must_reinit = 1;
h->mb_width = h->sps.mb_width;
h->mb_height = h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag);
h->mb_num = h->mb_width * h->mb_height;
h->mb_stride = h->mb_width + 1;
h->b_stride = h->mb_width * 4;
h->chroma_y_shift = h->sps.chroma_format_idc <= 1;
h->width = 16 * h->mb_width;
h->height = 16 * h->mb_height;
ret = init_dimensions(h);
if (ret < 0)
return ret;
if (h->sps.video_signal_type_present_flag) {
h->avctx->color_range = h->sps.full_range>0 ? AVCOL_RANGE_JPEG
: AVCOL_RANGE_MPEG;
if (h->sps.colour_description_present_flag) {
if (h->avctx->colorspace != h->sps.colorspace)
needs_reinit = 1;
h->avctx->color_primaries = h->sps.color_primaries;
h->avctx->color_trc = h->sps.color_trc;
h->avctx->colorspace = h->sps.colorspace;
}
}
if (h->context_initialized &&
(must_reinit || needs_reinit)) {
if (sl != h->slice_ctx) {
av_log(h->avctx, AV_LOG_ERROR,
"changing width %d -> %d / height %d -> %d on "
"slice %d\n",
h->width, h->avctx->coded_width,
h->height, h->avctx->coded_height,
h->current_slice + 1);
return AVERROR_INVALIDDATA;
}
av_assert1(first_slice);
ff_h264_flush_change(h);
if ((ret = get_pixel_format(h, 1)) < 0)
return ret;
h->avctx->pix_fmt = ret;
av_log(h->avctx, AV_LOG_INFO, "Reinit context to %dx%d, "
"pix_fmt: %s\n", h->width, h->height, av_get_pix_fmt_name(h->avctx->pix_fmt));
if ((ret = h264_slice_header_init(h, 1)) < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"h264_slice_header_init() failed\n");
return ret;
}
}
if (!h->context_initialized) {
if (sl != h->slice_ctx) {
av_log(h->avctx, AV_LOG_ERROR,
"Cannot (re-)initialize context during parallel decoding.\n");
return AVERROR_PATCHWELCOME;
}
if ((ret = get_pixel_format(h, 1)) < 0)
return ret;
h->avctx->pix_fmt = ret;
if ((ret = h264_slice_header_init(h, 0)) < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"h264_slice_header_init() failed\n");
return ret;
}
}
if (first_slice && h->dequant_coeff_pps != pps_id) {
h->dequant_coeff_pps = pps_id;
ff_h264_init_dequant_tables(h);
}
frame_num = get_bits(&sl->gb, h->sps.log2_max_frame_num);
if (!first_slice) {
if (h->frame_num != frame_num) {
av_log(h->avctx, AV_LOG_ERROR, "Frame num change from %d to %d\n",
h->frame_num, frame_num);
return AVERROR_INVALIDDATA;
}
}
sl->mb_mbaff = 0;
h->mb_aff_frame = 0;
last_pic_structure = h->picture_structure;
last_pic_droppable = h->droppable;
droppable = h->nal_ref_idc == 0;
if (h->sps.frame_mbs_only_flag) {
picture_structure = PICT_FRAME;
} else {
if (!h->sps.direct_8x8_inference_flag && slice_type == AV_PICTURE_TYPE_B) {
av_log(h->avctx, AV_LOG_ERROR, "This stream was generated by a broken encoder, invalid 8x8 inference\n");
return -1;
}
field_pic_flag = get_bits1(&sl->gb);
if (field_pic_flag) {
bottom_field_flag = get_bits1(&sl->gb);
picture_structure = PICT_TOP_FIELD + bottom_field_flag;
} else {
picture_structure = PICT_FRAME;
h->mb_aff_frame = h->sps.mb_aff;
}
}
if (h->current_slice) {
if (last_pic_structure != picture_structure ||
last_pic_droppable != droppable) {
av_log(h->avctx, AV_LOG_ERROR,
"Changing field mode (%d -> %d) between slices is not allowed\n",
last_pic_structure, h->picture_structure);
return AVERROR_INVALIDDATA;
} else if (!h->cur_pic_ptr) {
av_log(h->avctx, AV_LOG_ERROR,
"unset cur_pic_ptr on slice %d\n",
h->current_slice + 1);
return AVERROR_INVALIDDATA;
}
}
h->picture_structure = picture_structure;
h->droppable = droppable;
h->frame_num = frame_num;
sl->mb_field_decoding_flag = picture_structure != PICT_FRAME;
if (h->current_slice == 0) {
if (h->frame_num != h->prev_frame_num) {
int unwrap_prev_frame_num = h->prev_frame_num;
int max_frame_num = 1 << h->sps.log2_max_frame_num;
if (unwrap_prev_frame_num > h->frame_num)
unwrap_prev_frame_num -= max_frame_num;
if ((h->frame_num - unwrap_prev_frame_num) > h->sps.ref_frame_count) {
unwrap_prev_frame_num = (h->frame_num - h->sps.ref_frame_count) - 1;
if (unwrap_prev_frame_num < 0)
unwrap_prev_frame_num += max_frame_num;
h->prev_frame_num = unwrap_prev_frame_num;
}
}
if (h->first_field) {
assert(h->cur_pic_ptr);
assert(h->cur_pic_ptr->f.buf[0]);
assert(h->cur_pic_ptr->reference != DELAYED_PIC_REF);
if (h->cur_pic_ptr->tf.owner == h->avctx) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
last_pic_structure == PICT_BOTTOM_FIELD);
}
if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
if (last_pic_structure != PICT_FRAME) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
last_pic_structure == PICT_TOP_FIELD);
}
} else {
if (h->cur_pic_ptr->frame_num != h->frame_num) {
if (last_pic_structure != PICT_FRAME) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
last_pic_structure == PICT_TOP_FIELD);
}
} else {
if (!((last_pic_structure == PICT_TOP_FIELD &&
h->picture_structure == PICT_BOTTOM_FIELD) ||
(last_pic_structure == PICT_BOTTOM_FIELD &&
h->picture_structure == PICT_TOP_FIELD))) {
av_log(h->avctx, AV_LOG_ERROR,
"Invalid field mode combination %d/%d\n",
last_pic_structure, h->picture_structure);
h->picture_structure = last_pic_structure;
h->droppable = last_pic_droppable;
return AVERROR_INVALIDDATA;
} else if (last_pic_droppable != h->droppable) {
avpriv_request_sample(h->avctx,
"Found reference and non-reference fields in the same frame, which");
h->picture_structure = last_pic_structure;
h->droppable = last_pic_droppable;
return AVERROR_PATCHWELCOME;
}
}
}
}
while (h->frame_num != h->prev_frame_num && !h->first_field &&
h->frame_num != (h->prev_frame_num + 1) % (1 << h->sps.log2_max_frame_num)) {
H264Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL;
av_log(h->avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n",
h->frame_num, h->prev_frame_num);
if (!h->sps.gaps_in_frame_num_allowed_flag)
for(i=0; i<FF_ARRAY_ELEMS(h->last_pocs); i++)
h->last_pocs[i] = INT_MIN;
ret = h264_frame_start(h);
if (ret < 0) {
h->first_field = 0;
return ret;
}
h->prev_frame_num++;
h->prev_frame_num %= 1 << h->sps.log2_max_frame_num;
h->cur_pic_ptr->frame_num = h->prev_frame_num;
h->cur_pic_ptr->invalid_gap = !h->sps.gaps_in_frame_num_allowed_flag;
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 1);
ret = ff_generate_sliding_window_mmcos(h, 1);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
return ret;
ret = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
return ret;
if (h->short_ref_count) {
if (prev) {
av_image_copy(h->short_ref[0]->f.data,
h->short_ref[0]->f.linesize,
(const uint8_t **)prev->f.data,
prev->f.linesize,
h->avctx->pix_fmt,
h->mb_width * 16,
h->mb_height * 16);
h->short_ref[0]->poc = prev->poc + 2;
}
h->short_ref[0]->frame_num = h->prev_frame_num;
}
}
if (h->first_field) {
assert(h->cur_pic_ptr);
assert(h->cur_pic_ptr->f.buf[0]);
assert(h->cur_pic_ptr->reference != DELAYED_PIC_REF);
if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
h->missing_fields ++;
h->cur_pic_ptr = NULL;
h->first_field = FIELD_PICTURE(h);
} else {
h->missing_fields = 0;
if (h->cur_pic_ptr->frame_num != h->frame_num) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
h->picture_structure==PICT_BOTTOM_FIELD);
h->first_field = 1;
h->cur_pic_ptr = NULL;
} else {
h->first_field = 0;
}
}
} else {
h->first_field = FIELD_PICTURE(h);
}
if (!FIELD_PICTURE(h) || h->first_field) {
if (h264_frame_start(h) < 0) {
h->first_field = 0;
return AVERROR_INVALIDDATA;
}
} else {
release_unused_pictures(h, 0);
}
if (FIELD_PICTURE(h)) {
for(i = (h->picture_structure == PICT_BOTTOM_FIELD); i<h->mb_height; i++)
memset(h->slice_table + i*h->mb_stride, -1, (h->mb_stride - (i+1==h->mb_height)) * sizeof(*h->slice_table));
} else {
memset(h->slice_table, -1,
(h->mb_height * h->mb_stride - 1) * sizeof(*h->slice_table));
}
h->last_slice_type = -1;
}
h->cur_pic_ptr->frame_num = h->frame_num;
av_assert1(h->mb_num == h->mb_width * h->mb_height);
if (first_mb_in_slice << FIELD_OR_MBAFF_PICTURE(h) >= h->mb_num ||
first_mb_in_slice >= h->mb_num) {
av_log(h->avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n");
return AVERROR_INVALIDDATA;
}
sl->resync_mb_x = sl->mb_x = first_mb_in_slice % h->mb_width;
sl->resync_mb_y = sl->mb_y = (first_mb_in_slice / h->mb_width) <<
FIELD_OR_MBAFF_PICTURE(h);
if (h->picture_structure == PICT_BOTTOM_FIELD)
sl->resync_mb_y = sl->mb_y = sl->mb_y + 1;
av_assert1(sl->mb_y < h->mb_height);
if (h->picture_structure == PICT_FRAME) {
h->curr_pic_num = h->frame_num;
h->max_pic_num = 1 << h->sps.log2_max_frame_num;
} else {
h->curr_pic_num = 2 * h->frame_num + 1;
h->max_pic_num = 1 << (h->sps.log2_max_frame_num + 1);
}
if (h->nal_unit_type == NAL_IDR_SLICE)
get_ue_golomb(&sl->gb);
if (h->sps.poc_type == 0) {
h->poc_lsb = get_bits(&sl->gb, h->sps.log2_max_poc_lsb);
if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME)
h->delta_poc_bottom = get_se_golomb(&sl->gb);
}
if (h->sps.poc_type == 1 && !h->sps.delta_pic_order_always_zero_flag) {
h->delta_poc[0] = get_se_golomb(&sl->gb);
if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME)
h->delta_poc[1] = get_se_golomb(&sl->gb);
}
ff_init_poc(h, h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc);
if (h->pps.redundant_pic_cnt_present)
sl->redundant_pic_count = get_ue_golomb(&sl->gb);
ret = ff_set_ref_count(h, sl);
if (ret < 0)
return ret;
if (slice_type != AV_PICTURE_TYPE_I &&
(h->current_slice == 0 ||
slice_type != h->last_slice_type ||
memcmp(h->last_ref_count, sl->ref_count, sizeof(sl->ref_count)))) {
ff_h264_fill_default_ref_list(h, sl);
}
if (sl->slice_type_nos != AV_PICTURE_TYPE_I) {
ret = ff_h264_decode_ref_pic_list_reordering(h, sl);
if (ret < 0) {
sl->ref_count[1] = sl->ref_count[0] = 0;
return ret;
}
}
if ((h->pps.weighted_pred && sl->slice_type_nos == AV_PICTURE_TYPE_P) ||
(h->pps.weighted_bipred_idc == 1 &&
sl->slice_type_nos == AV_PICTURE_TYPE_B))
ff_pred_weight_table(h, sl);
else if (h->pps.weighted_bipred_idc == 2 &&
sl->slice_type_nos == AV_PICTURE_TYPE_B) {
implicit_weight_table(h, sl, -1);
} else {
sl->use_weight = 0;
for (i = 0; i < 2; i++) {
sl->luma_weight_flag[i] = 0;
sl->chroma_weight_flag[i] = 0;
}
}
if (h->nal_ref_idc) {
ret = ff_h264_decode_ref_pic_marking(h, &sl->gb,
!(h->avctx->active_thread_type & FF_THREAD_FRAME) ||
h->current_slice == 0);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
}
if (FRAME_MBAFF(h)) {
ff_h264_fill_mbaff_ref_list(h, sl);
if (h->pps.weighted_bipred_idc == 2 && sl->slice_type_nos == AV_PICTURE_TYPE_B) {
implicit_weight_table(h, sl, 0);
implicit_weight_table(h, sl, 1);
}
}
if (sl->slice_type_nos == AV_PICTURE_TYPE_B && !sl->direct_spatial_mv_pred)
ff_h264_direct_dist_scale_factor(h, sl);
ff_h264_direct_ref_list_init(h, sl);
if (sl->slice_type_nos != AV_PICTURE_TYPE_I && h->pps.cabac) {
tmp = get_ue_golomb_31(&sl->gb);
if (tmp > 2) {
av_log(h->avctx, AV_LOG_ERROR, "cabac_init_idc %u overflow\n", tmp);
return AVERROR_INVALIDDATA;
}
sl->cabac_init_idc = tmp;
}
sl->last_qscale_diff = 0;
tmp = h->pps.init_qp + get_se_golomb(&sl->gb);
if (tmp > 51 + 6 * (h->sps.bit_depth_luma - 8)) {
av_log(h->avctx, AV_LOG_ERROR, "QP %u out of range\n", tmp);
return AVERROR_INVALIDDATA;
}
sl->qscale = tmp;
sl->chroma_qp[0] = get_chroma_qp(h, 0, sl->qscale);
sl->chroma_qp[1] = get_chroma_qp(h, 1, sl->qscale);
if (sl->slice_type == AV_PICTURE_TYPE_SP)
get_bits1(&sl->gb);
if (sl->slice_type == AV_PICTURE_TYPE_SP ||
sl->slice_type == AV_PICTURE_TYPE_SI)
get_se_golomb(&sl->gb);
sl->deblocking_filter = 1;
sl->slice_alpha_c0_offset = 0;
sl->slice_beta_offset = 0;
if (h->pps.deblocking_filter_parameters_present) {
tmp = get_ue_golomb_31(&sl->gb);
if (tmp > 2) {
av_log(h->avctx, AV_LOG_ERROR,
"deblocking_filter_idc %u out of range\n", tmp);
return AVERROR_INVALIDDATA;
}
sl->deblocking_filter = tmp;
if (sl->deblocking_filter < 2)
sl->deblocking_filter ^= 1;
if (sl->deblocking_filter) {
sl->slice_alpha_c0_offset = get_se_golomb(&sl->gb) * 2;
sl->slice_beta_offset = get_se_golomb(&sl->gb) * 2;
if (sl->slice_alpha_c0_offset > 12 ||
sl->slice_alpha_c0_offset < -12 ||
sl->slice_beta_offset > 12 ||
sl->slice_beta_offset < -12) {
av_log(h->avctx, AV_LOG_ERROR,
"deblocking filter parameters %d %d out of range\n",
sl->slice_alpha_c0_offset, sl->slice_beta_offset);
return AVERROR_INVALIDDATA;
}
}
}
if (h->avctx->skip_loop_filter >= AVDISCARD_ALL ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&
h->nal_unit_type != NAL_IDR_SLICE) ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONINTRA &&
sl->slice_type_nos != AV_PICTURE_TYPE_I) ||
(h->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
sl->slice_type_nos == AV_PICTURE_TYPE_B) ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONREF &&
h->nal_ref_idc == 0))
sl->deblocking_filter = 0;
if (sl->deblocking_filter == 1 && h->max_contexts > 1) {
if (h->avctx->flags2 & CODEC_FLAG2_FAST) {
sl->deblocking_filter = 2;
} else {
h->max_contexts = 1;
if (!h->single_decode_warning) {
av_log(h->avctx, AV_LOG_INFO,
"Cannot parallelize slice decoding with deblocking filter type 1, decoding such frames in sequential order\n"
"To parallelize slice decoding you need video encoded with disable_deblocking_filter_idc set to 2 (deblock only edges that do not cross slices).\n"
"Setting the flags2 libavcodec option to +fast (-flags2 +fast) will disable deblocking across slices and enable parallel slice decoding "
"but will generate non-standard-compliant output.\n");
h->single_decode_warning = 1;
}
if (sl != h->slice_ctx) {
av_log(h->avctx, AV_LOG_ERROR,
"Deblocking switched inside frame.\n");
return SLICE_SINGLETHREAD;
}
}
}
sl->qp_thresh = 15 -
FFMIN(sl->slice_alpha_c0_offset, sl->slice_beta_offset) -
FFMAX3(0,
h->pps.chroma_qp_index_offset[0],
h->pps.chroma_qp_index_offset[1]) +
6 * (h->sps.bit_depth_luma - 8);
h->last_slice_type = slice_type;
memcpy(h->last_ref_count, sl->ref_count, sizeof(h->last_ref_count));
sl->slice_num = ++h->current_slice;
if (sl->slice_num)
h->slice_row[(sl->slice_num-1)&(MAX_SLICES-1)]= sl->resync_mb_y;
if ( h->slice_row[sl->slice_num&(MAX_SLICES-1)] + 3 >= sl->resync_mb_y
&& h->slice_row[sl->slice_num&(MAX_SLICES-1)] <= sl->resync_mb_y
&& sl->slice_num >= MAX_SLICES) {
av_log(h->avctx, AV_LOG_WARNING, "Possibly too many slices (%d >= %d), increase MAX_SLICES and recompile if there are artifacts\n", sl->slice_num, MAX_SLICES);
}
for (j = 0; j < 2; j++) {
int id_list[16];
int *ref2frm = sl->ref2frm[sl->slice_num & (MAX_SLICES - 1)][j];
for (i = 0; i < 16; i++) {
id_list[i] = 60;
if (j < sl->list_count && i < sl->ref_count[j] &&
sl->ref_list[j][i].parent->f.buf[0]) {
int k;
AVBuffer *buf = sl->ref_list[j][i].parent->f.buf[0]->buffer;
for (k = 0; k < h->short_ref_count; k++)
if (h->short_ref[k]->f.buf[0]->buffer == buf) {
id_list[i] = k;
break;
}
for (k = 0; k < h->long_ref_count; k++)
if (h->long_ref[k] && h->long_ref[k]->f.buf[0]->buffer == buf) {
id_list[i] = h->short_ref_count + k;
break;
}
}
}
ref2frm[0] =
ref2frm[1] = -1;
for (i = 0; i < 16; i++)
ref2frm[i + 2] = 4 * id_list[i] + (sl->ref_list[j][i].reference & 3);
ref2frm[18 + 0] =
ref2frm[18 + 1] = -1;
for (i = 16; i < 48; i++)
ref2frm[i + 4] = 4 * id_list[(i - 16) >> 1] +
(sl->ref_list[j][i].reference & 3);
}
h->au_pps_id = pps_id;
h->sps.new =
h->sps_buffers[h->pps.sps_id]->new = 0;
h->current_sps_id = h->pps.sps_id;
if (h->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(h->avctx, AV_LOG_DEBUG,
"slice:%d %s mb:%d %c%s%s pps:%u frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s %s\n",
sl->slice_num,
(h->picture_structure == PICT_FRAME ? "F" : h->picture_structure == PICT_TOP_FIELD ? "T" : "B"),
first_mb_in_slice,
av_get_picture_type_char(sl->slice_type),
sl->slice_type_fixed ? " fix" : "",
h->nal_unit_type == NAL_IDR_SLICE ? " IDR" : "",
pps_id, h->frame_num,
h->cur_pic_ptr->field_poc[0],
h->cur_pic_ptr->field_poc[1],
sl->ref_count[0], sl->ref_count[1],
sl->qscale,
sl->deblocking_filter,
sl->slice_alpha_c0_offset, sl->slice_beta_offset,
sl->use_weight,
sl->use_weight == 1 && sl->use_weight_chroma ? "c" : "",
sl->slice_type == AV_PICTURE_TYPE_B ? (sl->direct_spatial_mv_pred ? "SPAT" : "TEMP") : "");
}
return 0;
}
| 1threat |
R code - restructure data, three columns of stacked data to rows : <p>In this example data, three people sorted 10 items into a variable number of groups and provided a text label for each group.
Person and label are text fields. Item var when downloaded and read into R is read as an integer. Item variable is actually categorical data and defines text for the item; an item number for a test is a good analogy. Labels, items and persons can be in any order, I typically sort the data as you see here to make visual inspection possible. Each person has 10 items in this example, in the real world there are usually 100 items. Each person has a variable number of labels. Each label has a variable number of items. All items are associated with one and only one label and all items (1-10 in this example) appear once for each person, there is no missing data.</p>
<p><strong>person group item</strong></p>
<p>person_1 label_A 1</p>
<p>person_1 label_A 2</p>
<p>person_1 label_A 3</p>
<p>person_1 label_A 4</p>
<p>person_1 label_B 5</p>
<p>person_1 label_B 6</p>
<p>person_1 label_C 7</p>
<p>person_1 label_C 8</p>
<p>person_1 label_C 9</p>
<p>person_1 label_C 10</p>
<p>person_2 label_D 1</p>
<p>person_2 label_D 2</p>
<p>person_2 label_D 3</p>
<p>person_2 label_D 4</p>
<p>... remaining lines omitted for brevity</p>
<p>I need the data restructured into the format that follows. Each line is a label variable with the associated items, labels are on one and only one line. Each person is repeated for as many times as they have unique labels. I have searched stack overflow and have made multiple attempts with reshape and tidyr, the best I can produce is a rectangular binary matrix where there are ones or zeros in the data frame with a column for person and label and then 10 columns labeled 1:10 for each item value in this example. I can post-process to get what i want in excel but would rather get it all done in R, I need the actual item value in the column as shown here. Ideally, the max ncol would be one each for peson & label and as many as needed to represent the sorting. Person3,label_H needed 7 col for items so there could be NA or 0 in those column or other rows.
Any help would be most appreciated, I can normally find the answer I need on StackOverflow, this time I am stumped.</p>
<p><strong>person group items</strong></p>
<p>person_1 label_A 1 2 3 4<br>
person_1 label_B 5 6<br>
person_1 label_C 7 8 9 10<br>
person_2 label_D 1 2 3 4<br>
person_2 label_E 5 6 7<br>
person_2 label_F 8 9 10<br>
person_3 label_G 1 2 3<br>
person_3 label_H 4 5 6 7 8 9 10</p>
| 0debug |
Flutter Release apk is not working properly? : <p>I had run this <code>flutter build apk</code> to release my App. Now I had build verison 2 of that. </p>
<p>Now again I want to release my version 2 App.To get the release apk I again run this <code>flutter build apk</code> again. I get released apk but It was my version 1 released apk.
I go to my released directory and deleted my deleted released apk and tried again then also I get verion 1 released apk.
<a href="https://i.stack.imgur.com/yv0oz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yv0oz.png" alt="I tried this too but It is allso giving me Verion 1 apk"></a></p>
<p>While building verion 2 I was testing in debugging mode. everthing was/is working fine in dung mode .</p>
<p>Here is Github Link to that App: <a href="https://github.com/nitishk72/Flutter-Github-API" rel="noreferrer">https://github.com/nitishk72/Flutter-Github-API</a></p>
| 0debug |
need assistance with a input issue in java : <p><strong>My Task:</strong></p>
<p>Create a class called Icosahedron which will be used to represent a regular icosahedron, that is a convex polyhedron with 20 equilateral triangles as faces. The class should have the following features:</p>
<ul>
<li><p>A private instance variable, <strong>edge</strong>, of type <strong>double</strong>, that holds the
edge
length.</p></li>
<li><p>A private static variable, <strong>count</strong>, of type <strong>int</strong>, that holds the
number of Icosahedron objects that have been created.</p></li>
<li><p>A constructor that takes one <strong>double</strong> argument which specifies the edge length.</p></li>
<li><p>An
instance method <strong>surface()</strong> which returns the surface area of the
icosahedron. This can be calculated using the formula <strong>5*√3 edge².</strong></p></li>
<li><p>An
instance method <strong>volume()</strong> which returns the volume of the icosahedron.
This can be calculated using the formula <strong>5*(3+√5)/12*edge³</strong>.</p></li>
<li><p>An
instance method <strong>toString()</strong> which returns a string with the edge
length, surface area and volume as in the example below:</p>
<p><code>Icosahedron[edge= 3.000, surface= 77.942, volume= 58.906]</code> </p></li>
</ul>
<p>The numbers in this string should be in floating point format with a field
that is (at least) <strong>7 characters wide</strong> and showing <strong>3 decimal places</strong>.</p>
<p>Please use the static method <strong>String.format</strong> with a suitable formatting
string to achieve this. A static method <strong>getCount()</strong> which returns the
value of the static variable count. </p>
<p>Finally, add the following main method to your Icosahedron class so that it can be run and tested:</p>
<pre><code>public static void main(String[] args) {
System.out.println("Number of Icosahedron objects created: " + getCount());
Icosahedron[] icos = new Icosahedron[4];
for (int i = 0; i < icos.length; i++)
icos[i] = new Icosahedron(i+1);
for (int i = 0; i < icos.length; i++)
System.out.println(icos[i]);
System.out.println("Number of Icosahedron objects created: " + getCount());
}
</code></pre>
<p>Okay. so heres what i have started on:</p>
<pre><code>import java.util.Scanner;
public class Icosahedron {
private double edge = 0;
private int count = 0;
Scanner input = new Scanner(System.in);
double useredge = input.nextDouble();
System.out.println("Enter Edge Length: ");
}
</code></pre>
<p>i receive an error on the last line. i cant use println() what am i doing wrong? or maybe im understanding the question wrong? any guidance would be appreciated.</p>
<p>thanks.</p>
| 0debug |
static void ehci_advance_periodic_state(EHCIState *ehci)
{
uint32_t entry;
uint32_t list;
const int async = 0;
switch(ehci_get_state(ehci, async)) {
case EST_INACTIVE:
if (!(ehci->frindex & 7) && ehci_periodic_enabled(ehci)) {
ehci_set_state(ehci, async, EST_ACTIVE);
} else
break;
case EST_ACTIVE:
if (!(ehci->frindex & 7) && !ehci_periodic_enabled(ehci)) {
ehci_queues_rip_all(ehci, async);
ehci_set_state(ehci, async, EST_INACTIVE);
break;
}
list = ehci->periodiclistbase & 0xfffff000;
if (list == 0) {
break;
}
list |= ((ehci->frindex & 0x1ff8) >> 1);
pci_dma_read(&ehci->dev, list, &entry, sizeof entry);
entry = le32_to_cpu(entry);
DPRINTF("PERIODIC state adv fr=%d. [%08X] -> %08X\n",
ehci->frindex / 8, list, entry);
ehci_set_fetch_addr(ehci, async,entry);
ehci_set_state(ehci, async, EST_FETCHENTRY);
ehci_advance_state(ehci, async);
ehci_queues_rip_unused(ehci, async, 0);
break;
default:
fprintf(stderr, "ehci: Bad periodic state %d. "
"Resetting to active\n", ehci->pstate);
assert(0);
}
}
| 1threat |
what is classes, enumerations, Interfaces, Attributes? : i am develop unity game. i just still don't understand detail about classes, enumerations, Interfaces, Attributes?how classes working? how enumerations working? how Interfaces working? how Attributes working? what difefrent between my classes ( i have to create )and unity scripting api classes ( already exist)? | 0debug |
How to implement "inverse" ioctl so the the driver notify the callback to the called user application? : '''
BOOL DeviceIoControl(
HANDLE hDevice,
DWORD dwIoControlCode,
LPVOID lpInBuffer,
DWORD nInBufferSize,
LPVOID lpOutBuffer,
DWORD nOutBufferSize,
LPDWORD lpBytesReturned,
LPOVERLAPPED lpOverlapped
);
''' | 0debug |
static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table)
{
BDRVQcowState *s = bs->opaque;
uint64_t old_l2_offset;
uint64_t *l2_table;
int64_t l2_offset;
int ret;
old_l2_offset = s->l1_table[l1_index];
trace_qcow2_l2_allocate(bs, l1_index);
l2_offset = qcow2_alloc_clusters(bs, s->l2_size * sizeof(uint64_t));
if (l2_offset < 0) {
return l2_offset;
}
ret = qcow2_cache_flush(bs, s->refcount_block_cache);
if (ret < 0) {
goto fail;
}
trace_qcow2_l2_allocate_get_empty(bs, l1_index);
ret = qcow2_cache_get_empty(bs, s->l2_table_cache, l2_offset, (void**) table);
if (ret < 0) {
return ret;
}
l2_table = *table;
if ((old_l2_offset & L1E_OFFSET_MASK) == 0) {
memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
} else {
uint64_t* old_table;
BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_COW_READ);
ret = qcow2_cache_get(bs, s->l2_table_cache,
old_l2_offset & L1E_OFFSET_MASK,
(void**) &old_table);
if (ret < 0) {
goto fail;
}
memcpy(l2_table, old_table, s->cluster_size);
ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &old_table);
if (ret < 0) {
goto fail;
}
}
BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_WRITE);
trace_qcow2_l2_allocate_write_l2(bs, l1_index);
qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
ret = qcow2_cache_flush(bs, s->l2_table_cache);
if (ret < 0) {
goto fail;
}
trace_qcow2_l2_allocate_write_l1(bs, l1_index);
s->l1_table[l1_index] = l2_offset | QCOW_OFLAG_COPIED;
ret = write_l1_entry(bs, l1_index);
if (ret < 0) {
goto fail;
}
*table = l2_table;
trace_qcow2_l2_allocate_done(bs, l1_index, 0);
return 0;
fail:
trace_qcow2_l2_allocate_done(bs, l1_index, ret);
qcow2_cache_put(bs, s->l2_table_cache, (void**) table);
s->l1_table[l1_index] = old_l2_offset;
return ret;
}
| 1threat |
how to add more value to ==>> <condition> ? <value if true> : <value if false> : how to add more value to
str[1] = (Setting.DBL(this.fieldTxt3.Tag.ToString()) >= 3000 ? **Setting.IP5 : Setting.IP4 : Setting.IP1 : Setting.IP6 : ....)**;
str[3] = (Setting.DBL(this.fieldTxt3.Tag.ToString()) == 1000 ? **"TBSS2" : "TBSS4": "TBSS1": "TBSS6" : ....)**;
private void UPDATE_CLIENT(int C)
{
string[] str;
if (Setting.SQLDB == "TBSS5")
{
SqlConnection sqlConnection2 = new SqlConnection(this.SQLConnStr);
str = new string[] { "Data Source=", null, null, null, null };
str[1] = (Setting.DBL(this.fieldTxt3.Tag.ToString()) == 1000 ? Setting.IP2 : Setting.IP4);
str[2] = ";Initial Catalog=";
str[3] = (Setting.DBL(this.fieldTxt3.Tag.ToString()) == 1000 ? "TBSS2" : "TBSS4");
str[4] = ";Integrated Security=false;UID=sa;pwd=;";
SqlConnection sqlConnection3 = new SqlConnection(string.Concat(str));
string str4 = "_TBS_BRANCH_TRANSMIT";
DateTime dateTime = DateTime.Now; | 0debug |
I have published an Android app on app store but whenever I search it by name or package name i can't find it even in the long list of apps : <p>But I can only find it when I click on the button <strong>"View Apps on Playstore"</strong> .What seems to be the problem. It's been almost two days since my app is published.</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.