problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
static void pty_chr_read(void *opaque)
{
CharDriverState *chr = opaque;
PtyCharDriver *s = chr->opaque;
int size, len;
uint8_t buf[1024];
len = sizeof(buf);
if (len > s->read_bytes)
len = s->read_bytes;
if (len == 0)
return;
size = read(s->fd, buf, len);
if ((size == -1 && errno == EIO) ||
(size == 0)) {
pty_chr_state(chr, 0);
return;
}
if (size > 0) {
pty_chr_state(chr, 1);
qemu_chr_read(chr, buf, size);
}
}
| 1threat |
How can I get a value from the select box in JQuery : I want to get the value of the selected option from the selected box by using JQuery but it ain't working.
I have tried a million ways to do it. Trying to get its text instead, tried to get the value from multiple ways. To know what is coming in my jquery variable.
```
<!-- HTML Code -->
<select class="form-control" id="cateogry" name="category">
<option value="0" disabled selected>Choose Project Category</option>
<option value="active">Active Project</option>
<option value="drafted">Drafted Project</option>
</select>
<!-- JQuery Script -->
<script>
$(document).ready(function () {
//First thing i tried
var category = $('#category').val();
alert(Category);
//Second thing i tried
var category = $('#category').filter(":selected").val();
alert(Category);
//Third thing i tried
var category = $('#category').find(":selected").text();
alert(Category);
//Fourth thing i tried
var category = $('#category').find(":selected").val();
alert(Category);
//Fourth thing i tried
var category = document.getElementById('category').value;
alert(Category);
//Now directly taking the value of selected option by id
alert($("#category :selected").attr('value'));
//These are the code snippets I tried at different times so don't
think that I did this all a time which can obviously throw some
exception.
});
</script>
```
All the options I have given above and tried all of them one by one and put an alert to see what is it getting and the alert said undefined. What can I do? | 0debug |
php how to save the day , month and year enter by user in variables to show value in database : <p>User enter the date , month and year and then press a button to show him the value of database based on the day he picked but I do not know how to save the day , month and year in $d , $m and $y variables</p>
<pre><code><style>
.button {border-radius: 8px;}
.button1 {font-size: 20px;}
</style>
<form>
اليوم : <input id="txtDay" type="text" placeholder="DD" />
الشهر : <input id="txtMonth" type="text" placeholder="MM" />
السنة : <input id="txtYear" type="text" placeholder="YYYY" />
<button id="but" onclick="daily()">إظهار الإستهلاك اليومي</button>
</form>
<script>// <![CDATA[
// to show the right value from database
function daily() {
$current_user=get_current_user_id();// to fetch the right data for the right user
// takes the values entered by the user
global $wpdb;
$d=???????????//define variable to store the day enter by user
$m=???????????//define variable to store the month enter by user
$y=???????????//define variable to store the year enter by user
$daily_amount= $wpdb->get_var("SELECT daily_amount FROM arduino_period_use where ID=$current_user and day=$d and month=$m and year=$y ");
print_r($daily_amount);
}
// ]]></script
</code></pre>
| 0debug |
How to manage Base activity with navigation drawer : <p>In my navigation drawer I don wanted t wanted to use activity and how to use fragment in proper way.</p>
| 0debug |
static int of_dpa_cmd_flow_add(OfDpa *of_dpa, uint64_t cookie,
RockerTlv **flow_tlvs)
{
OfDpaFlow *flow = of_dpa_flow_find(of_dpa, cookie);
int err = ROCKER_OK;
if (flow) {
return -ROCKER_EEXIST;
}
flow = of_dpa_flow_alloc(cookie);
if (!flow) {
return -ROCKER_ENOMEM;
}
err = of_dpa_cmd_flow_add_mod(of_dpa, flow, flow_tlvs);
if (err) {
g_free(flow);
return err;
}
return of_dpa_flow_add(of_dpa, flow);
}
| 1threat |
static int flush_blks(QEMUFile *f)
{
BlkMigBlock *blk;
int ret = 0;
DPRINTF("%s Enter submitted %d read_done %d transferred %d\n",
__FUNCTION__, block_mig_state.submitted, block_mig_state.read_done,
block_mig_state.transferred);
blk_mig_lock();
while ((blk = QSIMPLEQ_FIRST(&block_mig_state.blk_list)) != NULL) {
if (qemu_file_rate_limit(f)) {
break;
}
if (blk->ret < 0) {
ret = blk->ret;
break;
}
QSIMPLEQ_REMOVE_HEAD(&block_mig_state.blk_list, entry);
blk_mig_unlock();
blk_send(f, blk);
blk_mig_lock();
g_free(blk->buf);
g_free(blk);
block_mig_state.read_done--;
block_mig_state.transferred++;
assert(block_mig_state.read_done >= 0);
}
blk_mig_unlock();
DPRINTF("%s Exit submitted %d read_done %d transferred %d\n", __FUNCTION__,
block_mig_state.submitted, block_mig_state.read_done,
block_mig_state.transferred);
return ret;
}
| 1threat |
How to decode value from json, php ios swift : hi friends i am new in php can you please help me to decode the below json from a mobile app
Array
(
[{"unm":"admin","pw”:”password”}] =>
)
and my php code is
$obj1 = print_r($_REQUEST, true); //get $_request variable data(responce of login) data as it is
foreach($obj1 as $key => $value)
{
$obj2 = $key; //get first key
}
$obj3 = json_decode($obj2); //decode json data to obj3
$mob_user_name = $obj2['unm']; //getting json username field value
$mob_user_pass`enter code here`word = $obj2['pw']; //getting json password field value
anyone please help me to decode this json to | 0debug |
static long gethugepagesize(const char *path, Error **errp)
{
struct statfs fs;
int ret;
do {
ret = statfs(path, &fs);
} while (ret != 0 && errno == EINTR);
if (ret != 0) {
error_setg_errno(errp, errno, "failed to get page size of file %s",
path);
return 0;
}
return fs.f_bsize;
}
| 1threat |
What should be approach to understand a new project : <p>If one joins a new project, how should that person approach it if
there is no documentation of the code and program is quite big to understand. Team members are also not that much informative.
Should the person debug the code line by line?But it can be highly time consuming and exhaustive.</p>
| 0debug |
How to Disable the visualization of Injected Environment variables in Jenkins : <p>Jenkins SECURITY-248 states that I should "Disable the visualization of Injected Environment variables in the global configuration." I cannot find this setting in the Configuration. Any help will be appreciated.</p>
| 0debug |
static void data_plane_blk_remove_notifier(Notifier *n, void *data)
{
VirtIOBlockDataPlane *s = container_of(n, VirtIOBlockDataPlane,
remove_notifier);
assert(s->conf->conf.blk == data);
data_plane_remove_op_blockers(s);
}
| 1threat |
Adding more li elements with 2variables : <p>Hey i want to do something like to-do list. But with counter.</p>
<p>So when user input a title and date then there will be new element with time counter and title.</p>
<p>For now i got something like this: </p>
<pre><code>`https://jsfiddle.net/678z5pgy/1/`
</code></pre>
<p>But it only changes the "add-new" item h2 and p. I want to append new child for container as li element.</p>
<p>But when i make it as appendchild it will add me new element every second.</p>
<p>(Please don't make it for me just tell me what can i do and where i can look for answer, maybe for loop?)</p>
<p><a href="https://codepen.io/ludzik/pen/YMzKKP" rel="nofollow noreferrer">https://codepen.io/ludzik/pen/YMzKKP</a></p>
| 0debug |
getting unknow type error, something like segmentation fault(code dumped) : I am new to data structure and i am trying to implement link list data structure,i am getting segmentation fault(core dumped), during run time.I am using linux terminal to compile and run the program. I have written a insert_element() function to insert function at the beginning and a recursive function print() to print the list.Plz..help me.Thanks in advance.
struct node{
int data;
struct node* link;
};
struct node* insert_element(struct node* A,int ino)
{
struct node *temp=(struct node*)malloc(sizeof(struct node));
temp->data=ino;
temp->link=NULL;
if(A=NULL)
{
A=temp;
}
else
{
struct node* temp1=A;
while(temp1->link!=NULL)
{
temp1=temp1->link;
}
temp1->link=temp;
}
return A;
}
void print(struct node* ptr)
{
if(ptr==NULL)
return;
printf("%d",ptr->data);
print(ptr->link);
}
int main()
{
struct node* head=NULL;
head=insert_element(head,5);
head=insert_element(head,5);
head=insert_element(head,6);
head=insert_element(head,3);
head=insert_element(head,5);
print(head);
return 0;
}
| 0debug |
void qio_channel_test_validate(QIOChannelTest *test)
{
g_assert_cmpint(memcmp(test->input,
test->output,
test->len), ==, 0);
g_assert(test->readerr == NULL);
g_assert(test->writeerr == NULL);
g_free(test->inputv);
g_free(test->outputv);
g_free(test->input);
g_free(test->output);
g_free(test);
}
| 1threat |
How to upgrade minikube? : <p>I had installed <em>minikube</em> a few months ago and wanted to upgrade as newer versions are available.</p>
<p>I am unable to find out how to upgrade <em>minikube</em>. I see a feature request for an upgrade command here - <a href="https://github.com/kubernetes/minikube/issues/1171" rel="noreferrer">https://github.com/kubernetes/minikube/issues/1171</a></p>
<p>I tried to then uninstall <em>minikube</em> and hit another brickwall again. I don't see a command to uninstall <em>minikube</em>. The information that came closest to this was not very helpful - <a href="https://github.com/kubernetes/minikube/issues/1043" rel="noreferrer">https://github.com/kubernetes/minikube/issues/1043</a></p>
<p>I guess we need ways to upgrade these (at least once every 6 months or so).</p>
| 0debug |
Can't figure out NullPointerException when I run my tests : <p>I keep getting a null pointer exception and I can't seem to figure out why. I'm running some tests and that is when I get the null pointer exception, however, when I run it from Pangrams main(), I get no problems whatsoever. I've included the code, tests and stack trace below. Any help would be greatly appreciated and thanks in advance!</p>
<pre><code>import java.util.Map;
import java.util.TreeMap;
public class Pangrams {
private static TreeMap<Character, Integer> letterCount;
public static void main(String[] args) {
Pangrams pan = new Pangrams();
System.out.println(pan.isPangram("the quick brown fox jumps over the lazy dog"));
pan.getLetterCount();
}
public Pangrams() {
letterCount = new TreeMap<>();
populateMap();
}
public static boolean isPangram(String text) {
if(text.length() < 26) return false;
addToMap(text);
for(Map.Entry<Character, Integer> entry : letterCount.entrySet()) {
System.out.println(entry.getKey() + ": " + entry.getValue());
if(!(entry.getValue() >= 1)) {
return false;
}
}
return true;
}
public static void populateMap() {
for(char x = 'a'; x <= 'z'; x++) {
letterCount.put(Character.valueOf(x), 0);
}
}
public static void addToMap(String text) {
char[] textArray = text.toLowerCase().replace(" ", "").toCharArray();
// System.out.println(textArray.length);
for(char letter : textArray) {
if(letterCount.containsKey(letter)) {
int count = letterCount.get(letter);
letterCount.put(letter, ++count);
System.out.println(letterCount.get(letter));
}
else if(!Character.isWhitespace(letter)) {
letterCount.put(letter, 1);
}
}
}
public static void getLetterCount() {
for(Map.Entry<Character, Integer> entry : letterCount.entrySet()) {
System.out.println(entry.getKey() + ": " + entry.getValue());
}
}
}
</code></pre>
<p>Here are the tests:</p>
<pre><code>import org.junit.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
public class PangramTest {
@Test
public void emptySentence() {
assertFalse(Pangrams.isPangram(""));
}
@Test
public void testLowercasePangram() {
assertTrue(Pangrams.isPangram("the quick brown fox jumps over the lazy dog"));
}
@Test
public void missingCharacterX() {
assertFalse(Pangrams.isPangram("a quick movement of the enemy will jeopardize five gunboats"));
}
@Test
public void mixedCaseAndPunctuation() {
assertTrue(Pangrams.isPangram("\"Five quacking Zephyrs jolt my wax bed.\""));
}
@Test
public void nonAsciiCharacters() {
assertTrue(Pangrams.isPangram("Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich."));
}
}
</code></pre>
<p>Here is the full stack trace:</p>
<pre><code>java.lang.NullPointerException
at Pangrams.addToMap(Pangrams.java:47)
at Pangrams.isPangram(Pangrams.java:24)
at PangramTest.testLowercasePangram(PangramTest.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:253)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
</code></pre>
| 0debug |
static int validate_codec_tag(AVFormatContext *s, AVStream *st)
{
const AVCodecTag *avctag;
int n;
enum AVCodecID id = AV_CODEC_ID_NONE;
unsigned int tag = 0;
for (n = 0; s->oformat->codec_tag[n]; n++) {
avctag = s->oformat->codec_tag[n];
while (avctag->id != AV_CODEC_ID_NONE) {
if (avpriv_toupper4(avctag->tag) == avpriv_toupper4(st->codec->codec_tag)) {
id = avctag->id;
if (id == st->codec->codec_id)
return 1;
}
if (avctag->id == st->codec->codec_id)
tag = avctag->tag;
avctag++;
}
}
if (id != AV_CODEC_ID_NONE)
return 0;
if (tag && (st->codec->strict_std_compliance >= FF_COMPLIANCE_NORMAL))
return 0;
return 1;
}
| 1threat |
static int parse_packet_header(WMAVoiceContext *s)
{
GetBitContext *gb = &s->gb;
unsigned int res;
if (get_bits_left(gb) < 11)
return 1;
skip_bits(gb, 4);
s->has_residual_lsps = get_bits1(gb);
do {
res = get_bits(gb, 6);
if (get_bits_left(gb) < 6 * (res == 0x3F) + s->spillover_bitsize)
return 1;
} while (res == 0x3F);
s->spillover_nbits = get_bits(gb, s->spillover_bitsize);
return 0;
}
| 1threat |
akku powered esp8266 led stripe system : <p>I want to create a system to control a led stripe with an esp8266, it would be easy if I had a socket for the power supply,
but it has to be mobile so I need a akku for it</p>
<p>Could you guys please give me some tips for my idea :)</p>
| 0debug |
what does console.readline do when i code string username = console.readline(); What is specific purpose of console.readline in this code? : String username = Console.Readline();
String password = Console.Readline();
String Valid = (username = "Kmp" && password = "Kmp")? "Valid user": "Invalid User";
Console.Writeline(Valid);
/*I am noob player ;), i need your help as much as you can give.*/ | 0debug |
Making a loop in a dictionary with list of keys Python : Dict = {
1 = ['5', '1', '1', '1', '2', '1', '3', '1', '1', 'benign']
2 = ['5', '4', '4', '5', '7', '10', '3', '2', '1', 'benign']
3 = ['3', '1', '1', '1', '2', '2', '3', '1', '1', 'benign']
4 = ['6', '8', '8', '1', '3', '4', '3', '7', '1', 'benign']
5 = ['4', '1', '1', '3', '2', '1', '3', '1', '1', 'benign'] }
i have a dictionary as above. i want to make a loop something like this
q = [3,5]
for x in q:
print(datadic[][q])
So what i mean is a want to print every 3rd and 5th element of every value.I guess i have to make another loop but i couldnt find out how
| 0debug |
Selecting specific fields using select_related in Django : <p>I have two models Article and Blog related using a foreign key. I want to select only blog name while extracting the article.</p>
<pre><code>articles = Articles.objects.all().select_related('blog__name')
</code></pre>
<p>The query generated shows that it selected all the fields from the Blog model.
I tried using only() and defer() with select_related but both didn't work out.</p>
<pre><code>articles = Articles.objects.all().select_related('blog__name').only('blog__name', 'title', 'create_time')
</code></pre>
<p>The above query resulted in error: Invalid field name(s) given in select_related: Choices are: blog</p>
<p>How do i generate a query so that only article fields and blog name is selected?</p>
| 0debug |
Why is SVG scrolling performance so much worse than PNG? : <p>A site I'm working on displays a large number (>50) of complex SVG images in a scrolling dialog window. When viewing the site in Chrome, the scrolling performance of the dialog window is very poor - it is noticeably laggy and slow. However, if I replace the SVG images with PNG images, the scrolling is perfectly smooth and responsive.</p>
<p>Here's a demonstration of the difference: <a href="https://jsfiddle.net/NathanFriend/42knwc1s/" rel="noreferrer">https://jsfiddle.net/NathanFriend/42knwc1s/</a></p>
<p>Why is the SVG scrolling performance so much worse than the PNG scrolling performance? After the browser renders an SVG image, I would assume it doesn't need to rerender the image until the image is manipulated in some way (like resizing). Does scrolling an element that contains SVG images cause the images to be rerendered for every frame of the scroll animation?</p>
<p><br /></p>
<pre><code> `
</code></pre>
| 0debug |
display inline doesnt work but display flex does : so i am able to get a horizontal nav bar one way but not the other and i am getting confused as to why. strange things happen when i use float left as well so im not sure if ive got my elements labelled in the best format. the relevant html and css are below:
<nav class="main-nav">
<ul class="navtext">
<li><a href="index.html">Index</a></li>
<li><a href="p2.html">P2</a></li>
<li><a href="p3.html">P3</a></li>
</ul>
</nav>
.main-nav{
padding-top: 0px;
padding-bottom: 0px;
padding-left: 60px;
padding-right: 60px;
background-image: url("images/navimage.jpg");
text-align: center;
border: solid 10px black;
font-size: 20px;
text-shadow:
-1px -1px 0 #000,
1px -1px 0 #000,
-1px 1px 0 #000,
1px 1px 0 #000;
.navtext{ list-style: none;
padding: 3rem;
margin: none;
display: flex;}
ive tried doing the whole nav as main-nav but then list style: none has no effect
| 0debug |
error CS0030: Cannot convert type 'void' to 'double' : The compiler gives an error CS0030: Cannot convert type 'void' to 'double'. Help me please.
The code here:
static public double Decode(string a)
{
double c=double.Parse(a);
return (double)Console.WriteLine(c%3);
} | 0debug |
static void set_int32(Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
int32_t *ptr = qdev_get_prop_ptr(dev, prop);
Error *local_err = NULL;
int64_t value;
if (dev->state != DEV_STATE_CREATED) {
error_set(errp, QERR_PERMISSION_DENIED);
return;
}
visit_type_int(v, &value, name, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
if (value > prop->info->min && value <= prop->info->max) {
*ptr = value;
} else {
error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
dev->id?:"", name, value, prop->info->min,
prop->info->max);
}
}
| 1threat |
Read from a .txt file and display it : <p>I want to be able to have a .txt file with some text in it and have my program be able to read it and display it. How would I do this?</p>
<p>It just needs to be as simple as displaying it on the screen. No other code. Then I can just input it into my program! :)</p>
| 0debug |
Cannot assign value to variable by reference in Javascript : <p>I would like to assign value to the variable IMLoginReq inside a ProtoBuf load function, but its not working, can anyone help?</p>
<pre><code>var IMLoginReq;
protobuf.load("./pb/IM.Login.proto", (err, root) => {
// Obtain a message type
IMLoginReq = root.lookup("IM.Login.IMLoginReq");
console.log(IMLoginReq);//<== is not undefined
});
console.log(IMLoginReq);//<== is undefined
</code></pre>
| 0debug |
Parse error: syntax error, unexpected 'echo' (T_ECHO) in C:\... on line 12 : <p>I've looked around can't find an answer that helps me and can't see any obvious problems. I've been getting this error: </p>
<blockquote>
<p>Parse error: syntax error, unexpected 'echo' (T_ECHO) in C:... on
line 12</p>
</blockquote>
<pre><code><?php
include 'dbh.php';
$uid = $_POST['uid'];
$pwd = $_POST['pwd'];
$sql = "SELECT * FROM user WHERE uid='$uid' AND pwd='$pwd'";
$result = mysqli_query($conn, $sql);
if (!$row = mysqli_fetch_assoc($result) {
echo "Your username or password is incorrect!";
} else {
echo "You are logged in!";
}
</code></pre>
<p>Any help is appreciated!</p>
| 0debug |
static void *qemu_tcg_cpu_thread_fn(void *arg)
{
CPUState *cpu = arg;
qemu_tcg_init_cpu_signals();
qemu_thread_get_self(cpu->thread);
qemu_mutex_lock(&qemu_global_mutex);
CPU_FOREACH(cpu) {
cpu->thread_id = qemu_get_thread_id();
cpu->created = true;
cpu->exception_index = -1;
cpu->can_do_io = 1;
}
qemu_cond_signal(&qemu_cpu_cond);
while (QTAILQ_FIRST(&cpus)->stopped) {
qemu_cond_wait(tcg_halt_cond, &qemu_global_mutex);
CPU_FOREACH(cpu) {
qemu_wait_io_event_common(cpu);
}
}
while (1) {
tcg_exec_all();
if (use_icount) {
int64_t deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);
if (deadline == 0) {
qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
}
}
qemu_tcg_wait_io_event();
}
return NULL;
}
| 1threat |
Smallest Number formed from an Array : Number formed from an Array
Given a list of non negative integers, arrange them in such a manner that they form the smallest number possible.
The result is going to be very large, hence return the result in the form of a string.
// Input array {20, 1, 5}
// Result: 1205
private String getSmallestNumber(Integer[] nums) {
}
//Suggest me good algorithm asap.
| 0debug |
Build a React App in Elastic Beanstalk : <p>I followed <a href="https://facebook.github.io/react/docs/installation.html" rel="noreferrer">these instructions</a> and I made a hello world app with React. I uploaded the development files in my EBS and it worked.</p>
<p>After that I used the command <strong>npm run build</strong>, I followed the instructions, I installed the <strong>push-state</strong> and I tested using localhost. Everything worked fine. </p>
<p>But I uploaded the build files to my EBS and it complains that the app does not have the <strong>package.json</strong> file and the app does not work.</p>
<p>What do I have to do to put in package.json to deploy my react app using Elastic Beanstalk? How to deploy the build files generated by <strong>npm run build</strong> in EBS?</p>
| 0debug |
static void blizzard_screen_dump(void *opaque, const char *filename,
bool cswitch, Error **errp)
{
BlizzardState *s = (BlizzardState *) opaque;
DisplaySurface *surface = qemu_console_surface(s->con);
blizzard_update_display(opaque);
if (s && surface_data(surface)) {
ppm_save(filename, surface, errp);
}
}
| 1threat |
void cpu_loop(CPUPPCState *env)
{
CPUState *cs = CPU(ppc_env_get_cpu(env));
target_siginfo_t info;
int trapnr;
target_ulong ret;
for(;;) {
cpu_exec_start(cs);
trapnr = cpu_ppc_exec(cs);
cpu_exec_end(cs);
switch(trapnr) {
case POWERPC_EXCP_NONE:
break;
case POWERPC_EXCP_CRITICAL:
cpu_abort(cs, "Critical interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_MCHECK:
cpu_abort(cs, "Machine check exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_DSI:
EXCP_DUMP(env, "Invalid data memory access: 0x" TARGET_FMT_lx "\n",
env->spr[SPR_DAR]);
switch (env->error_code & 0xFF000000) {
case 0x40000000:
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
break;
case 0x04000000:
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_ILLADR;
break;
case 0x08000000:
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_ACCERR;
break;
default:
EXCP_DUMP(env, "Invalid segfault errno (%02x)\n",
env->error_code);
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
break;
}
info._sifields._sigfault._addr = env->nip;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_ISI:
EXCP_DUMP(env, "Invalid instruction fetch: 0x\n" TARGET_FMT_lx
"\n", env->spr[SPR_SRR0]);
switch (env->error_code & 0xFF000000) {
case 0x40000000:
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
break;
case 0x10000000:
case 0x08000000:
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_ACCERR;
break;
default:
EXCP_DUMP(env, "Invalid segfault errno (%02x)\n",
env->error_code);
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
break;
}
info._sifields._sigfault._addr = env->nip - 4;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_EXTERNAL:
cpu_abort(cs, "External interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_ALIGN:
EXCP_DUMP(env, "Unaligned memory access\n");
info.si_signo = TARGET_SIGBUS;
info.si_errno = 0;
info.si_code = TARGET_BUS_ADRALN;
info._sifields._sigfault._addr = env->nip;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_PROGRAM:
switch (env->error_code & ~0xF) {
case POWERPC_EXCP_FP:
EXCP_DUMP(env, "Floating point program exception\n");
info.si_signo = TARGET_SIGFPE;
info.si_errno = 0;
switch (env->error_code & 0xF) {
case POWERPC_EXCP_FP_OX:
info.si_code = TARGET_FPE_FLTOVF;
break;
case POWERPC_EXCP_FP_UX:
info.si_code = TARGET_FPE_FLTUND;
break;
case POWERPC_EXCP_FP_ZX:
case POWERPC_EXCP_FP_VXZDZ:
info.si_code = TARGET_FPE_FLTDIV;
break;
case POWERPC_EXCP_FP_XX:
info.si_code = TARGET_FPE_FLTRES;
break;
case POWERPC_EXCP_FP_VXSOFT:
info.si_code = TARGET_FPE_FLTINV;
break;
case POWERPC_EXCP_FP_VXSNAN:
case POWERPC_EXCP_FP_VXISI:
case POWERPC_EXCP_FP_VXIDI:
case POWERPC_EXCP_FP_VXIMZ:
case POWERPC_EXCP_FP_VXVC:
case POWERPC_EXCP_FP_VXSQRT:
case POWERPC_EXCP_FP_VXCVI:
info.si_code = TARGET_FPE_FLTSUB;
break;
default:
EXCP_DUMP(env, "Unknown floating point exception (%02x)\n",
env->error_code);
break;
}
break;
case POWERPC_EXCP_INVAL:
EXCP_DUMP(env, "Invalid instruction\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
switch (env->error_code & 0xF) {
case POWERPC_EXCP_INVAL_INVAL:
info.si_code = TARGET_ILL_ILLOPC;
break;
case POWERPC_EXCP_INVAL_LSWX:
info.si_code = TARGET_ILL_ILLOPN;
break;
case POWERPC_EXCP_INVAL_SPR:
info.si_code = TARGET_ILL_PRVREG;
break;
case POWERPC_EXCP_INVAL_FP:
info.si_code = TARGET_ILL_COPROC;
break;
default:
EXCP_DUMP(env, "Unknown invalid operation (%02x)\n",
env->error_code & 0xF);
info.si_code = TARGET_ILL_ILLADR;
break;
}
break;
case POWERPC_EXCP_PRIV:
EXCP_DUMP(env, "Privilege violation\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
switch (env->error_code & 0xF) {
case POWERPC_EXCP_PRIV_OPC:
info.si_code = TARGET_ILL_PRVOPC;
break;
case POWERPC_EXCP_PRIV_REG:
info.si_code = TARGET_ILL_PRVREG;
break;
default:
EXCP_DUMP(env, "Unknown privilege violation (%02x)\n",
env->error_code & 0xF);
info.si_code = TARGET_ILL_PRVOPC;
break;
}
break;
case POWERPC_EXCP_TRAP:
cpu_abort(cs, "Tried to call a TRAP\n");
break;
default:
cpu_abort(cs, "Unknown program exception (%02x)\n",
env->error_code);
break;
}
info._sifields._sigfault._addr = env->nip - 4;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_FPU:
EXCP_DUMP(env, "No floating point allowed\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_COPROC;
info._sifields._sigfault._addr = env->nip - 4;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_SYSCALL:
cpu_abort(cs, "Syscall exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_APU:
EXCP_DUMP(env, "No APU instruction allowed\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_COPROC;
info._sifields._sigfault._addr = env->nip - 4;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_DECR:
cpu_abort(cs, "Decrementer interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_FIT:
cpu_abort(cs, "Fix interval timer interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_WDT:
cpu_abort(cs, "Watchdog timer interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_DTLB:
cpu_abort(cs, "Data TLB exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_ITLB:
cpu_abort(cs, "Instruction TLB exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_SPEU:
EXCP_DUMP(env, "No SPE/floating-point instruction allowed\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_COPROC;
info._sifields._sigfault._addr = env->nip - 4;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_EFPDI:
cpu_abort(cs, "Embedded floating-point data IRQ not handled\n");
break;
case POWERPC_EXCP_EFPRI:
cpu_abort(cs, "Embedded floating-point round IRQ not handled\n");
break;
case POWERPC_EXCP_EPERFM:
cpu_abort(cs, "Performance monitor exception not handled\n");
break;
case POWERPC_EXCP_DOORI:
cpu_abort(cs, "Doorbell interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_DOORCI:
cpu_abort(cs, "Doorbell critical interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_RESET:
cpu_abort(cs, "Reset interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_DSEG:
cpu_abort(cs, "Data segment exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_ISEG:
cpu_abort(cs, "Instruction segment exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_HDECR:
cpu_abort(cs, "Hypervisor decrementer interrupt "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_TRACE:
break;
case POWERPC_EXCP_HDSI:
cpu_abort(cs, "Hypervisor data storage exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_HISI:
cpu_abort(cs, "Hypervisor instruction storage exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_HDSEG:
cpu_abort(cs, "Hypervisor data segment exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_HISEG:
cpu_abort(cs, "Hypervisor instruction segment exception "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_VPU:
EXCP_DUMP(env, "No Altivec instructions allowed\n");
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_COPROC;
info._sifields._sigfault._addr = env->nip - 4;
queue_signal(env, info.si_signo, &info);
break;
case POWERPC_EXCP_PIT:
cpu_abort(cs, "Programmable interval timer interrupt "
"while in user mode. Aborting\n");
break;
case POWERPC_EXCP_IO:
cpu_abort(cs, "IO error exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_RUNM:
cpu_abort(cs, "Run mode exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_EMUL:
cpu_abort(cs, "Emulation trap exception not handled\n");
break;
case POWERPC_EXCP_IFTLB:
cpu_abort(cs, "Instruction fetch TLB exception "
"while in user-mode. Aborting");
break;
case POWERPC_EXCP_DLTLB:
cpu_abort(cs, "Data load TLB exception while in user-mode. "
"Aborting");
break;
case POWERPC_EXCP_DSTLB:
cpu_abort(cs, "Data store TLB exception while in user-mode. "
"Aborting");
break;
case POWERPC_EXCP_FPA:
cpu_abort(cs, "Floating-point assist exception not handled\n");
break;
case POWERPC_EXCP_IABR:
cpu_abort(cs, "Instruction address breakpoint exception "
"not handled\n");
break;
case POWERPC_EXCP_SMI:
cpu_abort(cs, "System management interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_THERM:
cpu_abort(cs, "Thermal interrupt interrupt while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_PERFM:
cpu_abort(cs, "Performance monitor exception not handled\n");
break;
case POWERPC_EXCP_VPUA:
cpu_abort(cs, "Vector assist exception not handled\n");
break;
case POWERPC_EXCP_SOFTP:
cpu_abort(cs, "Soft patch exception not handled\n");
break;
case POWERPC_EXCP_MAINT:
cpu_abort(cs, "Maintenance exception while in user mode. "
"Aborting\n");
break;
case POWERPC_EXCP_STOP:
break;
case POWERPC_EXCP_BRANCH:
break;
case POWERPC_EXCP_SYSCALL_USER:
env->crf[0] &= ~0x1;
ret = do_syscall(env, env->gpr[0], env->gpr[3], env->gpr[4],
env->gpr[5], env->gpr[6], env->gpr[7],
env->gpr[8], 0, 0);
if (ret == -TARGET_ERESTARTSYS) {
env->nip -= 4;
break;
}
if (ret == (target_ulong)(-TARGET_QEMU_ESIGRETURN)) {
break;
}
if (ret > (target_ulong)(-515)) {
env->crf[0] |= 0x1;
ret = -ret;
}
env->gpr[3] = ret;
break;
case POWERPC_EXCP_STCX:
if (do_store_exclusive(env)) {
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
info._sifields._sigfault._addr = env->nip;
queue_signal(env, info.si_signo, &info);
}
break;
case EXCP_DEBUG:
{
int sig;
sig = gdb_handlesig(cs, TARGET_SIGTRAP);
if (sig) {
info.si_signo = sig;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
queue_signal(env, info.si_signo, &info);
}
}
break;
case EXCP_INTERRUPT:
break;
default:
cpu_abort(cs, "Unknown exception 0x%d. Aborting\n", trapnr);
break;
}
process_pending_signals(env);
}
} | 1threat |
background image responsive but menu no : when page is resizing menu and content is decreases faster than image and when page have larger width than picture picture is alighed on left side
on normal resizing on pc site is normal image no but when it is on mobile or mobile mode on pc is it broken
i tried
background-size: 100% auto;
background-size: cover;
and nothing works so help me plz i need it thx
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
/* font-family: 'Montserrat', sans-serif; */
body {
background: #000;
font-family: 'Lato', sans-serif;
}
header {
width: 100%;
background: #fff;
}
nav > * {
list-style: none;
}
nav {
max-width: 960px;
margin: 0 auto;
display: flex;
flex-direction: row;
justify-content: space-between;
padding: 10px;
}
ul {
padding: 0;
}
nav > ul {
display: flex;
flex-direction: row;
}
.logo {
background: url('../img/01.png') no-repeat;
width: 150px;
height: 50px;
}
.menu {
display: flex;
text-decoration: none;
margin: 0 10px 0 10px;
color: #3a3b3b;
}
.menu:hover {
color: #d96e5d;
transition: all 0.5s ease;
}
strong.menu {
font-weight: normal;
color: #d96e5d;
}
.top-bg {
background: url('../img/topbg.jpg') no-repeat;
background-size: cover;
}
.top-img > h1 {
font-family: 'Montserrat', sans-serif;
text-transform: uppercase;
color: white;
}
.content {
position: absolute;
top: 800px;
color: white;
font-size: 80px;
}
@media ( max-width:500px ) {
nav > ul {
flex-direction: column;
align-items: center;
}
nav {
flex-direction: column;
align-items: center;
}
.item{
padding: 10px;
width: 90vw;
background: #d3d0d0;
margin: 2px 0 2px 0;
}
.menu {
justify-content: center;
}
}
<!-- language: lang-html -->
<header>
<nav>
<a class="logo" href="#"></a>
<ul>
<li class="item"><a href="aktivity.php" class="menu">Aktivity</a></li><li class="item"><strong class="menu">Index</strong></li><li class="item"><a href="kontakt.php" class="menu">Kontakt</a></li><li class="item"><a href="onas.php" class="menu">Onas</a></li>
</ul>
</nav>
</header>
<main>
<section class="topimg">
<h1>Coupe Invest</h1>
<img src="assets/img/topbg.jpg" alt="background">
</section>
<section class="content">
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Dolorem a et laboriosam illum recusandae nesciunt veniam architecto saepe ratione! Eaque quas provident voluptates facere consectetur repellendus amet nulla ea nisi! Lorem ipsum dolor, sit amet consectetur adipisicing elit. Consectetur odio, quos suscipit laudantium quo doloribus nulla sit ut cupiditate mollitia nihil maiores. Vitae ipsum excepturi quibusdam nam molestias ullam! Enim. Lorem ipsum dolor, sit amet consectetur adipisicing elit. Cumque, ut amet laboriosam quaerat, expedita nam neque placeat molestias non hic sit voluptate quam quia beatae nulla rem est eius fugiat. Lorem ipsum dolor sit amet consectetur adipisicing elit. Excepturi fugiat, cumque distinctio consequuntur asperiores quia veniam suscipit tenetur, nobis adipisci ad voluptate quisquam ducimus nesciunt id, voluptatem odio neque molestias. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus aliquid eum adipisci quaerat ducimus pariatur natus velit voluptates! Odit amet tempora quisquam mollitia fugit aliquam neque vitae molestiae debitis aperiam?</p>
</section>
</main>
<!-- end snippet -->
| 0debug |
Android - Button with if condition :
I am newbie in Android, and i am trying to make a one button open 2 activities but is not working for me.
for ex:
on `Mainacitivity`, there is `btn_mathematics` and `btn_physics` open the same activity (`Main2acitivity`) and find `btn_semester1` and `btn_semester2`, each button will open 2 other activities for the semester modules.
If the user on Mainacitivity clicked on:
`btn_mathematics` ---> `btn_semester1`---> will have `ModulesMAT`
and if clicked on the btn_semester1 same button:
`btn_physics` ---> `btn_semester1` ---> will have `ModulesPHY` .
**MainActivity XML:**
<Button
android:id="@+id/btn_mathematics"
android:onClick="btn_mathematics"
android:text="@string/btn_mathematics/>
<Button
android:id="@+id/btn_physics"
android:onClick="btn_physics"
android:text="@string/btn_physics"/>
**Main2Activity XML:**
<Button
android:id="@+id/btn_semester1"
android:onClick="btn_semester1"
android:text="@string/btn_semester1"/>
<Button
android:id="@+id/btn_semester2"
android:onClick="btn_s2"
android:text="@string/btn_semester2"/>
I guess that no need to add xml for ModulesMAT and ModulesPHY, its pretty similar to the the others.
and now the java code:
**MainActivity.java:**
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void btn_mathematics (View v) {
Intent intent = new Intent(MainActivity.this, Main2Activity.class);
startActivity(intent);
}
`public void btn_physics (View v) {
Intent intent = new Intent(MainActivity.this, Main2Activity.class);
startActivity(intent);
}
}
**Main2Activity.java:**
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
}
public void btn_semester1 (View v)
{
Intent i = getIntent();
String id = i.getStringExtra("id");
if(id == "btn_mathematics")
{
i = new Intent(this, ModulesMAT.class);
startActivity(i);
}
else if (id == "btn_physics")
{
i = new Intent(this, ModulesPHY.class);
startActivity(i);
}
}
public void btn_semester2 (View v)
{
Intent i = getIntent();
String id = i.getStringExtra("id");
if(id == "btn_mathematics")
{
i = new Intent(this, ModulesMAT2.class);
startActivity(i);
}
else if (id == "btn_physics")
{
i = new Intent(this, ModulesPHY2.class);
startActivity(i);
}
}
| 0debug |
void virtio_scsi_handle_cmd_req_submit(VirtIOSCSI *s, VirtIOSCSIReq *req)
{
SCSIRequest *sreq = req->sreq;
if (scsi_req_enqueue(sreq)) {
scsi_req_continue(sreq);
}
bdrv_io_unplug(sreq->dev->conf.bs);
scsi_req_unref(sreq);
}
| 1threat |
static void pxa2xx_cm_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
PXA2xxState *s = (PXA2xxState *) opaque;
switch (addr) {
case CCCR:
case CKEN:
s->cm_regs[addr >> 2] = value;
break;
case OSCC:
s->cm_regs[addr >> 2] &= ~0x6c;
s->cm_regs[addr >> 2] |= value & 0x6e;
if ((value >> 1) & 1)
s->cm_regs[addr >> 2] |= 1 << 0;
break;
default:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
break;
}
}
| 1threat |
Is creating Equilateral responsinve triangle with backgroung image in css even possibe? : And it also should work in IE11.
I've tried:
- Usuall triangle-crating techinces using border - **Failed**, no background image.
- Clip-path - **Failed** no ie support (damn)
- Triangles with skewing and transfroming have to war of having proper percedt-based lenghts. After ~3 hours of trying to fugure it out - **Failed**
My last desperate effort will probbaly be creating an SVG mask with triangle cutted in it and placing it on top of the <div> with desiered image. But it feels so damn hacky.
And no, it is not my wish to complicate my life so much, its a test task ive got, and i've allready burned away whole day of time, and shitton amount of nerves. Please help! | 0debug |
Flatlist getItemLayout usecase : <p>Why we use getItemLayout in flatlist ,how it help to improve performance of a flatlist .check the react-native docs but didn't find a satisfying answer. </p>
<pre><code> getItemLayout={(data, index) => (
{length: ITEM_HEIGHT, offset: ITEM_HEIGHT * index, index}
)}
</code></pre>
<p>what is offset here ,what it does?</p>
| 0debug |
display images in asp.net c#? : How to display images in different formats?
I tried this.
context.Response.ContentType = "image/jpeg";
This will display only jpeg images.But I need to display images in different formats.
| 0debug |
conditional expression inside a conditional expression : <p>What is your way to write a conditional expression inside a conditional expression and so on. In the most beautiful way regarding indentation. </p>
<pre><code>conditionalExpression1 ? expression1 :
conditionalExpression2 ? expression1 : conditionalExpression3...;
</code></pre>
<p>thanks</p>
| 0debug |
zsh: command not found: mysql : <p>Trying to use MySQL for rails app and downloaded it from dev.mysql.com.</p>
<p>After successfully installing the package and seeing the option to start and stop the server from Preference Pane, if I go ahead and execute following command in my terminal</p>
<pre><code>mysql --version
</code></pre>
<p>I end up with error as -</p>
<pre><code>zsh: command not found: mysql
</code></pre>
<p>I've been looking for this error and understand that this has something to do with my <code>$PATH</code> variable and if display the value by <code>echo $PATH</code> I get following output - </p>
<pre><code>/Library/Frameworks/Python.framework/Versions/3.4/bin:/Users/aniruddhabarapatre1/.rvm/gems/ruby-2.2.1/bin:/Users/aniruddhabarapatre1/.rvm/gems/ruby-2.2.1@global/bin:/Users/aniruddhabarapatre1/.rvm/rubies/ruby-2.2.1/bin:/usr/local/bin:/Users/aniruddhabarapatre1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/opt/ImageMagick/bin:/usr/local/MacGPG2/bin:/Users/aniruddhabarapatre1/.rvm/bin
</code></pre>
<p>How do I resolve this error to get Mysql up and running.</p>
| 0debug |
int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
{
MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp;
int mmco_index = 0, i;
assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count);
if (h->short_ref_count &&
h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count &&
!(FIELD_PICTURE(h) && !h->first_field && h->cur_pic_ptr->reference)) {
mmco[0].opcode = MMCO_SHORT2UNUSED;
mmco[0].short_pic_num = h->short_ref[h->short_ref_count - 1]->frame_num;
mmco_index = 1;
if (FIELD_PICTURE(h)) {
mmco[0].short_pic_num *= 2;
mmco[1].opcode = MMCO_SHORT2UNUSED;
mmco[1].short_pic_num = mmco[0].short_pic_num + 1;
mmco_index = 2;
}
}
if (first_slice) {
h->mmco_index = mmco_index;
} else if (!first_slice && mmco_index >= 0 &&
(mmco_index != h->mmco_index ||
(i = check_opcodes(h->mmco, mmco_temp, mmco_index)))) {
av_log(h->avctx, AV_LOG_ERROR,
"Inconsistent MMCO state between slices [%d, %d, %d]\n",
mmco_index, h->mmco_index, i);
return AVERROR_INVALIDDATA;
}
return 0;
}
| 1threat |
Is there a naming convention for C language implementation only (private) constants? : <p>Let's say that I am writing a library named <code>my</code>, which has a module <code>myString</code>.</p>
<p>Publicly exposed functions and constants for <code>myString</code> are declared in <code>myString.h</code> with the following convention:</p>
<pre><code>typedef struct myString myString;
extern const size_t MY_STRING_MAX_LEN;
myString *my_string_new();
</code></pre>
<p>Private implementation only functions and struct members are declared in <code>myString.c</code> with the following convention:</p>
<pre><code>_grow_buffer(myString *this);
char *_buffer;
</code></pre>
<p>My question: Is there a similar convention for private, implementation only constants?</p>
<p>For example, <code>_CHUNK_SIZE</code> is what I initially wanted to go with. Then I read that the C language specification says not to use an underscore followed by an uppercase letter at the start of a name, as such names may be used in future versions of the language.</p>
<p>I like using the starting underscore convention, as it removes a lot of verbosity. I could use <code>MY_STRING_CHUNK_SIZE</code> or some variation, but that's not as pretty IMO.</p>
| 0debug |
What is the pythonic way for 'do_this() if condition else do_that() '? : There is exists a pythonic way for doing somethings like that?
>> list.append(elem) if condition else pass
>> list.append(elem) if condition else other_list.append(elem)
I have needed sometimes something like that and I don't know the best way for accomplish it.
Thanks. | 0debug |
Do you need to allocate memory to operate on an array in CUDA? : <p>I've seen CUDA programs where you allocate memory on the device, operate on it, and then copy it back to the host, like this:</p>
<pre><code>float* h_a = (float*) malloc(numBytes);
float* d_a = 0;
cudaMalloc((void**) &a, numBytes);
cuda_function<<< N/blockSize, blockSize>>>(d_a);
cudaMemcpy(d_a, h_a, numBytes, cudaMemcpyDeviceToHost);
</code></pre>
<p>But then I've also seen code where the CUDA program just operates on memory whose reference was passed to it, like this:</p>
<pre><code>__global__ void cuda_function(int* a)
{
...<operate on a>...
}
int main()
{
cuda_function<<<N/256, 256>>>(a)
}
</code></pre>
<p>What's the different between these two approaches?</p>
<p>Thanks!</p>
| 0debug |
int nbd_receive_reply(int csock, struct nbd_reply *reply)
{
uint8_t buf[NBD_REPLY_SIZE];
uint32_t magic;
memset(buf, 0xAA, sizeof(buf));
if (read_sync(csock, buf, sizeof(buf)) != sizeof(buf)) {
LOG("read failed");
errno = EINVAL;
return -1;
}
magic = be32_to_cpup((uint32_t*)buf);
reply->error = be32_to_cpup((uint32_t*)(buf + 4));
reply->handle = be64_to_cpup((uint64_t*)(buf + 8));
TRACE("Got reply: "
"{ magic = 0x%x, .error = %d, handle = %" PRIu64" }",
magic, reply->error, reply->handle);
if (magic != NBD_REPLY_MAGIC) {
LOG("invalid magic (got 0x%x)", magic);
errno = EINVAL;
return -1;
}
return 0;
}
| 1threat |
Guys what is the error, Msg 208, Level 16, State 1, Line 1 Invalid object name 'registration' : Guys i want to insert following info in the table but it is giving me following error from the following code:
ERROR:
Msg 208, Level 16, State 1, Line 1
Invalid object name 'registration'.
create table registration
(
id int identity primary key,
first_name varchar(100),
last_name varchar(100),
username varchar(100),
[password] varchar(100),
email varchar(100),
[address] varchar(100),
gender varchar(10),
dob date,
reg_date date,
country varchar(50),
city varchar(50),
[status] bit
)
select * from registration
insert into registration (first_name,last_name,username,password,email,[address],gender,dob,reg_date,country,city,status) values ('Ali','Khan','alik','123','alikhan@gmail.com','Male','19930318','20170318','Pakistan','Karachi')
ERROR:
Msg 208, Level 16, State 1, Line 1
Invalid object name 'registration'.
| 0debug |
static int encode_tile(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile, int tileno)
{
int compno, reslevelno, bandno, ret;
Jpeg2000T1Context t1;
Jpeg2000CodingStyle *codsty = &s->codsty;
for (compno = 0; compno < s->ncomponents; compno++){
Jpeg2000Component *comp = s->tile[tileno].comp + compno;
av_log(s->avctx, AV_LOG_DEBUG,"dwt\n");
if ((ret = ff_dwt_encode(&comp->dwt, comp->i_data)) < 0)
return ret;
av_log(s->avctx, AV_LOG_DEBUG,"after dwt -> tier1\n");
for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){
Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno;
for (bandno = 0; bandno < reslevel->nbands ; bandno++){
Jpeg2000Band *band = reslevel->band + bandno;
Jpeg2000Prec *prec = band->prec;
int cblkx, cblky, cblkno=0, xx0, x0, xx1, y0, yy0, yy1, bandpos;
yy0 = bandno == 0 ? 0 : comp->reslevel[reslevelno-1].coord[1][1] - comp->reslevel[reslevelno-1].coord[1][0];
y0 = yy0;
yy1 = FFMIN(ff_jpeg2000_ceildivpow2(band->coord[1][0] + 1, band->log2_cblk_height) << band->log2_cblk_height,
band->coord[1][1]) - band->coord[1][0] + yy0;
if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1])
continue;
bandpos = bandno + (reslevelno > 0);
for (cblky = 0; cblky < prec->nb_codeblocks_height; cblky++){
if (reslevelno == 0 || bandno == 1)
xx0 = 0;
else
xx0 = comp->reslevel[reslevelno-1].coord[0][1] - comp->reslevel[reslevelno-1].coord[0][0];
x0 = xx0;
xx1 = FFMIN(ff_jpeg2000_ceildivpow2(band->coord[0][0] + 1, band->log2_cblk_width) << band->log2_cblk_width,
band->coord[0][1]) - band->coord[0][0] + xx0;
for (cblkx = 0; cblkx < prec->nb_codeblocks_width; cblkx++, cblkno++){
int y, x;
if (codsty->transform == FF_DWT53){
for (y = yy0; y < yy1; y++){
int *ptr = t1.data[y-yy0];
for (x = xx0; x < xx1; x++){
*ptr++ = comp->i_data[(comp->coord[0][1] - comp->coord[0][0]) * y + x] << NMSEDEC_FRACBITS;
}
}
} else{
for (y = yy0; y < yy1; y++){
int *ptr = t1.data[y-yy0];
for (x = xx0; x < xx1; x++){
*ptr = (comp->i_data[(comp->coord[0][1] - comp->coord[0][0]) * y + x]);
*ptr = (int64_t)*ptr * (int64_t)(16384 * 65536 / band->i_stepsize) >> 15 - NMSEDEC_FRACBITS;
ptr++;
}
}
}
encode_cblk(s, &t1, prec->cblk + cblkno, tile, xx1 - xx0, yy1 - yy0,
bandpos, codsty->nreslevels - reslevelno - 1);
xx0 = xx1;
xx1 = FFMIN(xx1 + (1 << band->log2_cblk_width), band->coord[0][1] - band->coord[0][0] + x0);
}
yy0 = yy1;
yy1 = FFMIN(yy1 + (1 << band->log2_cblk_height), band->coord[1][1] - band->coord[1][0] + y0);
}
}
}
av_log(s->avctx, AV_LOG_DEBUG, "after tier1\n");
}
av_log(s->avctx, AV_LOG_DEBUG, "rate control\n");
truncpasses(s, tile);
if ((ret = encode_packets(s, tile, tileno)) < 0)
return ret;
av_log(s->avctx, AV_LOG_DEBUG, "after rate control\n");
return 0;
}
| 1threat |
Export/Import Visual Studio 2015 rule set into SonarQube : <p><strong>Environment</strong>: We are building C# code within Visual Studio 2015 and generating CodeAnalysis report using default ruleset available within Visual Studio 2015.<br/><br/>
<strong>Problem Statement</strong>: While running same code into SonarQube integrated with our Continuous integration environment Jenkins, we are getting different Code analysis report, so we want to import <em>default</em> rule set of Visual studio 2015 to be used within SonarQube 5.6 or later (<em>I am ready to upgrade Sonar if there is solution</em>). But problem is SonarQube is not able to recognize ruleset starting with <strong>CS</strong>, like..</p>
<pre><code><Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp" RuleNamespace="Microsoft.CodeAnalysis.CSharp">
<Rule Id="AD0001" Action="Error" />
<Rule Id="CS0028" Action="Error" />
<Rule Id="CS0078" Action="Error" />
<Rule Id="CS0105" Action="Error" />
<Rule Id="CS0108" Action="Error" />
<Rule Id="CS0109" Action="Error" />
</code></pre>
<p>I already have following plugins installed:</p>
<ol>
<li><strong>Code Analyzer for C#</strong></li>
<li><strong>CodeCracker for C#</strong></li>
</ol>
| 0debug |
Show sum of values for all checkboxes that are checked : <p>I’m creating an HTML form and want to achieve the following with JS, please provide the code i should use to do so.</p>
<p>1.Add values of all the checked checkboxes and show them as total.</p>
<p>2.Add a restriction the user must select at least 2 checkboxes.
Here is my code.</p>
<pre><code><input class="iput" type="checkbox" name="E33" value="4500" />
<input class="iput" type="checkbox" name="E34" value="3000" />
<input class="iput" type="checkbox" name="E36" value="6000" />
<p>Your Total is = </p>
</code></pre>
<p>Also code should be such that if i add or remove checkboxes i should not have to modify the JS code too. </p>
| 0debug |
Convert SQL query to a Laravel query builder : Good day, I have this query:
SELECT * FROM table
WHERE ( name = '%alex%'
OR address = '%alex%'
OR lastname = '%alex%'
) AND id = '%alex%'
AND email = '%alex%'
How would I go about converting this SQL query using Laravel Query Builder? Thanks in advance. | 0debug |
How to check out a branch with GitPython : <p>I have cloned a repository with GitPython, now I would like to checkout a branch and update the local repository's working tree with the contents of that branch. Ideally, I'd also be able to check if the branch exists before doing this. This is what I have so far:</p>
<pre><code>import git
repo_clone_url = "git@github.com:mygithubuser/myrepo.git"
local_repo = "mytestproject"
test_branch = "test-branch"
repo = git.Repo.clone_from(repo_clone_url, local_repo)
# Check out branch test_branch somehow
# write to file in working directory
repo.index.add(["test.txt"])
commit = repo.index.commit("Commit test")
</code></pre>
<p>I am not sure what to put in the place of the comments above. The <a href="http://gitpython.readthedocs.io/en/stable/tutorial.html#switching-branches" rel="noreferrer">documentation</a> seems to give an example of how to detach the HEAD, but not how to checkout an named branch.</p>
| 0debug |
static void vp8_idct_add_c(uint8_t *dst, DCTELEM block[16], ptrdiff_t stride)
{
int i, t0, t1, t2, t3;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
DCTELEM tmp[16];
for (i = 0; i < 4; i++) {
t0 = block[0*4+i] + block[2*4+i];
t1 = block[0*4+i] - block[2*4+i];
t2 = MUL_35468(block[1*4+i]) - MUL_20091(block[3*4+i]);
t3 = MUL_20091(block[1*4+i]) + MUL_35468(block[3*4+i]);
block[0*4+i] = 0;
block[1*4+i] = 0;
block[2*4+i] = 0;
block[3*4+i] = 0;
tmp[i*4+0] = t0 + t3;
tmp[i*4+1] = t1 + t2;
tmp[i*4+2] = t1 - t2;
tmp[i*4+3] = t0 - t3;
}
for (i = 0; i < 4; i++) {
t0 = tmp[0*4+i] + tmp[2*4+i];
t1 = tmp[0*4+i] - tmp[2*4+i];
t2 = MUL_35468(tmp[1*4+i]) - MUL_20091(tmp[3*4+i]);
t3 = MUL_20091(tmp[1*4+i]) + MUL_35468(tmp[3*4+i]);
dst[0] = cm[dst[0] + ((t0 + t3 + 4) >> 3)];
dst[1] = cm[dst[1] + ((t1 + t2 + 4) >> 3)];
dst[2] = cm[dst[2] + ((t1 - t2 + 4) >> 3)];
dst[3] = cm[dst[3] + ((t0 - t3 + 4) >> 3)];
dst += stride;
}
}
| 1threat |
How to sort an array who's sorting order is in another array? : // 0 = eldest = pre
//everytime i run this code i get names in pattern that makes no sense to me
public class cousin {
public static void main(String[] args)
{
String[] children = {"Arm", "Jo", "Ra", "Jas", "Pre", "She"};
int[] sortAge = {2, 4, 3, 5, 0, 1};
int x = 0;
int y = 1;
while ( x < 6)
{
int ref = sortAge[x];
System.out.print(y+ "\t");
System.out.println(children[ref]);
x = x + 1;
y = y + 1; }
}
}
| 0debug |
.NET Scaling project : <p>What would be better in terms of speed for a far larger database between these two? they don't have to talk to their foreign key counterparts because a loop will occur sending an email from the table and deleting the entry so there be no view. I don't know if having the foreign keys and getting it to read each time but only storing a fraction of the data, or storing the data again and not having it read other tables?</p>
<pre><code>namespace Linkofy.Models
{
public class AutoSending
{
public int ID { get; set; }
[Display(Name = "Receipiant Name")]
public string receiptName { get; set; }
[Display(Name = "Receipiant Emial")]
public string receiptMail { get; set; }
[Display(Name = "Sender Name")]
public string senderName { get; set; }
[Display(Name = "Email Address")]
public string emailAddress { get; set; }
[Display(Name = "Password")]
public string password { get; set; }
[Display(Name = "Send subject")]
public string subject { get; set; }
[Display(Name = "Send body")]
public string Body { get; set; }
[Required(ErrorMessage = "Send Time")]
public DateTime sendDate { get; set; }
public int autoListID { get; set; }
public int? UserTableID { get; set; }
public virtual UserTable UserTable { get; set; }
}
}
namespace Linkofy.Models
{
public class autoList
{
public int ID { get; set; }
public int? OutreachNamesID { get; set; }
public virtual OutreachNames OutreachNames { get; set; }
public int EmailAccountID { get; set; }
public virtual EmailAccount EmailAccounts { get; set; }
public int TemplateID { get; set; }
public virtual Template Templates { get; set; }
[Required(ErrorMessage = "Emails Sent")]
public int sent { get; set; }
[Required(ErrorMessage = "Total to Send")]
public int total { get; set; }
[Required(ErrorMessage = "Start Date")]
public int startDate { get; set; }
[Required(ErrorMessage = "End Date")]
public DateTime endDate { get; set; }
public int? UserTableID { get; set; }
public virtual UserTable UserTable { get; set; }
}
}
</code></pre>
| 0debug |
How do you create a multi-line text inside a ScrollView in SwiftUI? : <p>Since <code>List</code> doesn't look like its configurable to remove the row dividers at the moment, I'm using a <code>ScrollView</code> with a <code>VStack</code> inside it to create a vertical layout of text elements. Example below:</p>
<pre class="lang-swift prettyprint-override"><code>ScrollView {
VStack {
// ...
Text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer mattis ullamcorper tortor, nec finibus sapien imperdiet non. Duis tristique eros eget ex consectetur laoreet.")
.lineLimit(0)
}.frame(width: UIScreen.main.bounds.width)
}
</code></pre>
<p>The resulting <code>Text</code> rendered is truncated single-line. Outside of a <code>ScrollView</code> it renders as multi-line. How would I achieve this inside a <code>ScrollView</code> other than explicitly setting a height for the <code>Text</code> frame ?</p>
| 0debug |
Object *object_resolve_path_component(Object *parent, const gchar *part)
{
ObjectProperty *prop = object_property_find(parent, part, NULL);
if (prop == NULL) {
return NULL;
}
if (object_property_is_link(prop)) {
LinkProperty *lprop = prop->opaque;
return *lprop->child;
} else if (object_property_is_child(prop)) {
return prop->opaque;
} else {
return NULL;
}
}
| 1threat |
static void mpeg_decode_picture_coding_extension(MpegEncContext *s)
{
s->full_pel[0] = s->full_pel[1] = 0;
s->mpeg_f_code[0][0] = get_bits(&s->gb, 4);
s->mpeg_f_code[0][1] = get_bits(&s->gb, 4);
s->mpeg_f_code[1][0] = get_bits(&s->gb, 4);
s->mpeg_f_code[1][1] = get_bits(&s->gb, 4);
s->intra_dc_precision = get_bits(&s->gb, 2);
s->picture_structure = get_bits(&s->gb, 2);
s->top_field_first = get_bits1(&s->gb);
s->frame_pred_frame_dct = get_bits1(&s->gb);
s->concealment_motion_vectors = get_bits1(&s->gb);
s->q_scale_type = get_bits1(&s->gb);
s->intra_vlc_format = get_bits1(&s->gb);
s->alternate_scan = get_bits1(&s->gb);
s->repeat_first_field = get_bits1(&s->gb);
s->chroma_420_type = get_bits1(&s->gb);
s->progressive_frame = get_bits1(&s->gb);
dprintf("intra_dc_precion=%d\n", s->intra_dc_precision);
dprintf("picture_structure=%d\n", s->picture_structure);
dprintf("conceal=%d\n", s->concealment_motion_vectors);
dprintf("intra_vlc_format=%d\n", s->intra_vlc_format);
dprintf("alternate_scan=%d\n", s->alternate_scan);
dprintf("frame_pred_frame_dct=%d\n", s->frame_pred_frame_dct);
}
| 1threat |
BlockDriverAIOCB *bdrv_aio_write(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque)
{
BlockDriver *drv = bs->drv;
BlockDriverAIOCB *ret;
if (!drv)
return NULL;
if (bs->read_only)
return NULL;
if (bdrv_wr_badreq_sectors(bs, sector_num, nb_sectors))
return NULL;
if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) {
memcpy(bs->boot_sector_data, buf, 512);
}
ret = drv->bdrv_aio_write(bs, sector_num, buf, nb_sectors, cb, opaque);
if (ret) {
bs->wr_bytes += (unsigned) nb_sectors * SECTOR_SIZE;
bs->wr_ops ++;
}
return ret;
}
| 1threat |
JSON: Add pointer : <p>I have an automatially made json that looks like:</p>
<pre><code>{
"node_id_1": {
"x": -87,
"y": 149
},
"node_id_2": {
"x": -24,
"y": 50
},
"node_id_3": {
"x": 55,
"y": -32
}
}
</code></pre>
<p>I have problems to access the a specific node_id to get its x and y values. My idea is to automatically add an <code>"id:"</code> before e.g. <code>"node_id_1"</code> and then to flatten the array.
Could you give me a hint how to add this <code>"id:"</code>? Or is there another elegant way to access the IDs?
Thank you a lot!
Best regards</p>
| 0debug |
How do I remove non UTF-8 characters from a String in Ruby? : I have the following text:
-~$A§ruGù"š¶/K
I need to remove the non UTF-8 characters from it. I have tried `str.scrub` as well as `str.encode`. None of them seem to work.
`scrub` returns the same result and `encode` resutls in an error.
Here is the snap of the text.
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/RmtYp.png | 0debug |
Yii2 Rest API Bearer Authentication : <p>I've made a Yii2 REST API. With the API you can get a list of cars. Now I want to use the Bearer Authentication to protect the API. But I don't know how it works.</p>
<p>First of all. I set up the authenticator in the behaviors method of my controller.</p>
<pre><code>public function behaviors(){
return [
'contentNegotiator' => [
'class' => ContentNegotiator::className(),
'formats' => [
'application/json' => Response::FORMAT_JSON,
],
],
'authenticator' => [
'class' => CompositeAuth::className(),
'authMethods' => [
HttpBearerAuth::className(),
],
]
];
}
</code></pre>
<p>This works just fine. If I go to the URL I will get an 'Unauthorized' message. </p>
<p>In my wordpress plugin I've made an function to use the API and set the header with the authentication key. </p>
<pre><code>function getJSON($template_url) {
$authorization = "Authorization: Bearer " . get_option("auth_key");
// Create curl resource
$ch = curl_init();
// Set URL
curl_setopt($ch, CURLOPT_URL, $template_url);
// Return transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Set headers
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', $authorization));
// $output contains output as a string
$output = curl_exec($ch);
// Close curl resource
curl_close($ch);
return json_decode($output, true);
}
</code></pre>
<p>But now my question is. How can I check in the API if this key is valid and give me the response. I want to search for the key in de database and if it exists it should also give me the id or email thats in the same row.</p>
<p>I have no idea how to do this.</p>
| 0debug |
static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu,
MSIMessage *origin,
MSIMessage *translated)
{
int ret = 0;
VTD_IR_MSIAddress addr;
uint16_t index;
VTDIrq irq = {0};
assert(origin && translated);
if (!iommu || !iommu->intr_enabled) {
goto do_not_translate;
}
if (origin->address & VTD_MSI_ADDR_HI_MASK) {
VTD_DPRINTF(GENERAL, "error: MSI addr high 32 bits nonzero"
" during interrupt remapping: 0x%"PRIx32,
(uint32_t)((origin->address & VTD_MSI_ADDR_HI_MASK) >> \
VTD_MSI_ADDR_HI_SHIFT));
return -VTD_FR_IR_REQ_RSVD;
}
addr.data = origin->address & VTD_MSI_ADDR_LO_MASK;
if (le16_to_cpu(addr.__head) != 0xfee) {
VTD_DPRINTF(GENERAL, "error: MSI addr low 32 bits invalid: "
"0x%"PRIx32, addr.data);
return -VTD_FR_IR_REQ_RSVD;
}
if (addr.int_mode != VTD_IR_INT_FORMAT_REMAP) {
goto do_not_translate;
}
index = addr.index_h << 15 | le16_to_cpu(addr.index_l);
#define VTD_IR_MSI_DATA_SUBHANDLE (0x0000ffff)
#define VTD_IR_MSI_DATA_RESERVED (0xffff0000)
if (addr.sub_valid) {
index += origin->data & VTD_IR_MSI_DATA_SUBHANDLE;
}
ret = vtd_remap_irq_get(iommu, index, &irq);
if (ret) {
return ret;
}
if (addr.sub_valid) {
VTD_DPRINTF(IR, "received MSI interrupt");
if (origin->data & VTD_IR_MSI_DATA_RESERVED) {
VTD_DPRINTF(GENERAL, "error: MSI data bits non-zero for "
"interrupt remappable entry: 0x%"PRIx32,
origin->data);
return -VTD_FR_IR_REQ_RSVD;
}
} else {
uint8_t vector = origin->data & 0xff;
VTD_DPRINTF(IR, "received IOAPIC interrupt");
if (vector != irq.vector) {
VTD_DPRINTF(GENERAL, "IOAPIC vector inconsistent: "
"entry: %d, IRTE: %d, index: %d",
vector, irq.vector, index);
}
}
irq.msi_addr_last_bits = addr.__not_care;
vtd_generate_msi_message(&irq, translated);
VTD_DPRINTF(IR, "mapping MSI 0x%"PRIx64":0x%"PRIx32 " -> "
"0x%"PRIx64":0x%"PRIx32, origin->address, origin->data,
translated->address, translated->data);
return 0;
do_not_translate:
memcpy(translated, origin, sizeof(*origin));
return 0;
}
| 1threat |
Integer cannot be converted to boolean using "indexOf()" : <p>I'm trying to count how many times the word "ing" occurred in a string asked by a user, I'm having an error saying it cannot be converted.</p>
<p>I tried using s.indexOf("ing")</p>
<pre><code>package javaapplication3;
import java.util.*;
public class JavaApplication3 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s,q = null;
String i = "ing";
int count=0;
System.out.println("Entrer une ligne de texte :");
s = in.next();
if ( s.indexOf("ing") ){
count++;
q = s.replaceAll("ing", "ed");
}
System.out.println("\"ing\" est occuree " +count +" fois.");
System.out.println(q);
}
}
</code></pre>
<p>I expect the output would give me and count how many times it occurred but I'm having an error.</p>
| 0debug |
PHP ERROR : mysqli_stmt_bind_param() Number of variables doesn't match number of parameters in prepared statement : <p>i am facing a problem in my php file, the error is comming from the parameters in the third statement, but i can not find where is it. Here is my PHP file:</p>
<pre><code>$client = "test";
$resto = "test";
$st1 = mysqli_query($con, "SELECT client_id FROM Clients WHERE email = '$client'");
$res1 = mysqli_fetch_array($st1);
$clientID = $res1["client_id"];
echo "CLIENT ID = ";
echo $clientID;
$st2 = mysqli_query($con, "SELECT restaurant_id FROM Restaurants WHERE email = '$resto'");
$res2 = mysqli_fetch_array($st2);
$restaurantID = $res2["restaurant_id"];
echo "RESTO ID = ";
echo $restaurantID;
$statement = mysqli_prepare($con, "INSERT INTO reservations (resto_id, client_id) VALUES ($restaurantID,$clientID)");
mysqli_stmt_bind_param($statement,"ii",$restaurantID,$clientID);
mysqli_stmt_execute($statement);
$response = array();
$response["success"] = true;
echo json_encode($response);
</code></pre>
<p>Thank you in advance for your help.</p>
| 0debug |
Understanding "invalid decimal literal" : <pre><code>100_year = date.today().year - age + 100
^
SyntaxError: invalid decimal literal
</code></pre>
<p>I'm trying to understand what the problem is.</p>
| 0debug |
Capture video data from screen in Python : <p>Is there a way with Python (maybe with OpenCV or PIL) to continuously grab frames of all or a portion of the screen, at least at 15 fps or more? I've seen it done in other languages, so in theory it should be possible. </p>
<p>I do not need to save the image data to a file. I actually just want it to output an array containing the raw RGB data (like in a numpy array or something) since I'm going to just take it and send it to a large LED display (probably after re-sizing it).</p>
| 0debug |
int boot_sector_init(const char *fname)
{
FILE *f = fopen(fname, "w");
size_t len = sizeof boot_sector;
if (!f) {
fprintf(stderr, "Couldn't open \"%s\": %s", fname, strerror(errno));
return 1;
}
if (strcmp(qtest_get_arch(), "ppc64") == 0) {
len = sprintf((char *)boot_sector, "\\ Bootscript\n%x %x c! %x %x c!\n",
LOW(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET,
HIGH(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
}
fwrite(boot_sector, 1, len, f);
fclose(f);
return 0;
}
| 1threat |
static void intel_hda_corb_run(IntelHDAState *d)
{
hwaddr addr;
uint32_t rp, verb;
if (d->ics & ICH6_IRS_BUSY) {
dprint(d, 2, "%s: [icw] verb 0x%08x\n", __FUNCTION__, d->icw);
intel_hda_send_command(d, d->icw);
return;
}
for (;;) {
if (!(d->corb_ctl & ICH6_CORBCTL_RUN)) {
dprint(d, 2, "%s: !run\n", __FUNCTION__);
return;
}
if ((d->corb_rp & 0xff) == d->corb_wp) {
dprint(d, 2, "%s: corb ring empty\n", __FUNCTION__);
return;
}
if (d->rirb_count == d->rirb_cnt) {
dprint(d, 2, "%s: rirb count reached\n", __FUNCTION__);
return;
}
rp = (d->corb_rp + 1) & 0xff;
addr = intel_hda_addr(d->corb_lbase, d->corb_ubase);
verb = ldl_le_pci_dma(&d->pci, addr + 4*rp);
d->corb_rp = rp;
dprint(d, 2, "%s: [rp 0x%x] verb 0x%08x\n", __FUNCTION__, rp, verb);
intel_hda_send_command(d, verb);
}
}
| 1threat |
function that only takes an html structure and call it whenever we want to display that part of HTML dynamically : I have 3 pages that contains some blocks with the same structure, i don't want to repeat the same code several times, so what i want to do is a function that stock an html structure and which i call everytime i need to display that part of HTML dynamically. not sure how to do it correctly ..also what to use ajax call or Jquery ?
this is what i tried to do :
function generateHtml() {
var generateContent = '';
generateContent += '<div id="blockAlarme" name="blockAlarme" clas="clsBlock">';
generateContent += '<div id="blockAlarmeHeader" name="blockAlarmeHeader" class="clsBlockHeader">';
generateContent += '<div class="clsBlockHeaderTitle">Alarme</div>';
generateContent += '<div class="clsBlockHeaderReduce"></div>';
generateContent += '</div>';
generateContent += '<div id="blockAlarmeContent" name="blockAlarmeContent" class="clsBlockContent"></div>';
generateContent += '</div>';
}
and then i have to call it inside an html code that is appended by ajax so that it displays content
Thank you for your help :)
| 0debug |
long check_dcbzl_effect(void)
{
register char *fakedata = (char*)av_malloc(1024);
register char *fakedata_middle;
register long zero = 0;
register long i = 0;
long count = 0;
if (!fakedata)
{
return 0L;
}
fakedata_middle = (fakedata + 512);
memset(fakedata, 0xFF, 1024);
asm volatile("dcbzl %0, %1" : : "b" (fakedata_middle), "r" (zero));
for (i = 0; i < 1024 ; i ++)
{
if (fakedata[i] == (char)0)
count++;
}
av_free(fakedata);
return count;
}
| 1threat |
How can i setup my php code to change my CSS background picture daily : <p>I have a website that has a background, and i want it to change daily.</p>
<p>In my directory I have a background. each background has a number at the end.</p>
<pre><code>././background1.jpg
</code></pre>
<p>In this case this file has a 1 tacked to it. So depending on the day the php will rewrite the css such that on a new day a new background will be set.</p>
| 0debug |
static int l2_load(BlockDriverState *bs, uint64_t l2_offset,
uint64_t **l2_table)
{
BDRVQcowState *s = bs->opaque;
int min_index;
int ret;
*l2_table = seek_l2_table(s, l2_offset);
if (*l2_table != NULL) {
return 0;
}
min_index = l2_cache_new_entry(bs);
*l2_table = s->l2_cache + (min_index << s->l2_bits);
BLKDBG_EVENT(bs->file, BLKDBG_L2_LOAD);
ret = bdrv_pread(bs->file, l2_offset, *l2_table,
s->l2_size * sizeof(uint64_t));
if (ret < 0) {
return ret;
}
s->l2_cache_offsets[min_index] = l2_offset;
s->l2_cache_counts[min_index] = 1;
return 0;
} | 1threat |
getting error - Type 'Any' Has no Subscript Members - swift3 : <pre><code>enter code here
@IBOutlet weak var textfield: UITextView!
@IBOutlet weak var label: UILabel!
var sentimentURL = "https://api.havenondemand.com/1/api/sync/analyzesentiment/v2?text=this+is+lethargic&apikey=e55bc0ff-70a5-4270-b464-aaaf3dfcc8de&text="
var sentimentResponse:NSDictionary!
func getSentiment() {
var error:NSError?
var encodedText = textfield.text.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
Get.JSON(url: sentimentURL+encodedText!) {
(response) in
self.sentimentResponse = response
DispatchQueue.main.async() {
var agggregate = self.sentimentResponse["aggregate"]!["sentiment"]! as String
self.label.text = agggregate
}
}
}
</code></pre>
<p>in this line
" var agggregate = self.sentimentResponse["aggregate"]!["sentiment"]! as String"
im getting error like Type 'Any' Has no Subscript Members.please help me in sorting this problem.thankyou in advance...</p>
| 0debug |
How to change the label of a row based on the most frequent label? : <p>This is apparently a simple problem but I can't figure out what function to use. Following are sample data: </p>
<pre><code>gg <- data.frame(ID = c(15,15,15,16,16,16, 16,17,17,17),
ADO = c(rep("T1", 4), rep("T2", 2), rep("T3", 4)))
</code></pre>
<p>The "ID" is the label or category of a particular "ADO". It should be unique to each ADO. But in this case it is not: </p>
<pre><code>> table(gg$ID, gg$ADO)
T1 T2 T3
15 3 0 0
16 1 2 1
17 0 0 3
</code></pre>
<p>I want to assign the most frequent ID to a particular ADO. So, my desired output is: </p>
<pre><code> ID ADO
1 15 T1
2 15 T1
3 15 T1
4 16 T2
5 16 T2
6 16 T2
7 16 T2
8 17 T3
9 17 T3
10 17 T3
</code></pre>
<p>Please guide me what function can I use to fix this?</p>
| 0debug |
static void json_print_int(WriterContext *wctx, const char *key, int value)
{
char *key_esc = json_escape_str(key);
if (wctx->nb_item) printf(",\n");
printf(INDENT "\"%s\": %d", key_esc ? key_esc : "", value);
av_free(key_esc);
}
| 1threat |
void omap_mpuio_key(struct omap_mpuio_s *s, int row, int col, int down)
{
if (row >= 5 || row < 0)
hw_error("%s: No key %i-%i\n", __FUNCTION__, col, row);
if (down)
s->buttons[row] |= 1 << col;
else
s->buttons[row] &= ~(1 << col);
omap_mpuio_kbd_update(s);
}
| 1threat |
Truth value of empty set : <p>I am interested in the truth value of Python sets like <code>{'a', 'b'}</code>, or the empty set <code>set()</code> (which is not the same as the empty dictionary <code>{}</code>). In particular, I would like to know whether <code>bool(my_set)</code> is <code>False</code> if and only if the set <code>my_set</code> is empty.</p>
<p>Ignoring primitive (such as numerals) as well as user-defined types, <a href="https://docs.python.org/3/library/stdtypes.html#truth" rel="noreferrer">https://docs.python.org/3/library/stdtypes.html#truth</a> says:</p>
<blockquote>
<p>The following values are considered false:</p>
<ul>
<li>[...]</li>
<li>any empty sequence, for example, <code>''</code>, <code>()</code>, <code>[]</code>.</li>
<li>any empty mapping, for example, <code>{}</code>.</li>
<li>[...]</li>
</ul>
<p>All other values are considered true</p>
</blockquote>
<p>According to <a href="https://docs.python.org/3/library/stdtypes.html#sequence-types-list-tuple-range" rel="noreferrer">https://docs.python.org/3/library/stdtypes.html#sequence-types-list-tuple-range</a>, a set is not a sequence (it is unordered, its elements do not have indices, etc.):</p>
<blockquote>
<p>There are three basic sequence types: lists, tuples, and range objects.</p>
</blockquote>
<p>And, according to <a href="https://docs.python.org/3/library/stdtypes.html#mapping-types-dict" rel="noreferrer">https://docs.python.org/3/library/stdtypes.html#mapping-types-dict</a>,</p>
<blockquote>
<p>There is currently only one standard mapping type, the <em>dictionary</em>.</p>
</blockquote>
<p>So, as far as I understand, the set type is not a type that can ever be <code>False</code>. However, when I try, <code>bool(set())</code> evaluates to <code>False</code>.</p>
<p>Questions:</p>
<ul>
<li>Is this a documentation problem, or am I getting something wrong?</li>
<li>Is the empty set the only set whose truth value is <code>False</code>?</li>
</ul>
| 0debug |
CORS filtering not working in 'Authorization' header : <p>I am trying to add OAuth 2.0 in spring mvc app. User should be authenticated in order to get a api call. I have set a headers in spring mvc controller as:</p>
<pre><code>@RequestMapping(value = "/admin-api/get-all-order", method = RequestMethod.GET)
public ResponseEntity getAllOrders(@RequestHeader("Authorization") String bearerToken) {
try {
List<OrderModel> order = orderService.getAllOrders();
return new ResponseEntity(order, HttpStatus.OK);
} catch (HibernateException e) {
return new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
}
}
</code></pre>
<p>For requesting api I have used angular 5. I make a api call in angular like:</p>
<pre><code>return this.http.get<T>(this.getAllOrderUrl, {
headers: {
"Authorization": "bearer " + JSON.parse(localStorage.getItem("token"))["value"],
"Content-type": "application/json"
}
}).catch(error => {
return this.auth.handleError(error);
})
</code></pre>
<p><a href="https://i.stack.imgur.com/i2tS8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i2tS8.png" alt="enter image description here"></a></p>
<p>I have already enabled a CORS for 'localhost:4200'. CORS filtering works fine on other request. </p>
<pre><code>@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) res;
HttpServletRequest request = (HttpServletRequest) req;
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Methods",
"ACL, CANCELUPLOAD, CHECKIN, CHECKOUT, COPY, DELETE, GET, HEAD, LOCK, MKCALENDAR, MKCOL, MOVE, OPTIONS, POST, PROPFIND, PROPPATCH, PUT, REPORT, SEARCH, UNCHECKOUT, UNLOCK, UPDATE, VERSION-CONTROL");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers",
"X-PINGOTHER,Content-Type,X-Requested-With,Accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers,Authorization,Key");
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
response.setStatus(HttpServletResponse.SC_OK);
} else {
chain.doFilter(req, res);
}
}
</code></pre>
<p>If I tried in postman it give me a desired result
<a href="https://i.stack.imgur.com/eCyTQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eCyTQ.png" alt="enter image description here"></a></p>
<p>**Response Header **
<a href="https://i.stack.imgur.com/XV9w2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XV9w2.png" alt="enter image description here"></a>
What am I doing wrong? Please help me out. Hoping for positive response thanks!</p>
| 0debug |
static int wc3_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
Wc3DemuxContext *wc3 = s->priv_data;
ByteIOContext *pb = s->pb;
unsigned int fourcc_tag;
unsigned int size;
int packet_read = 0;
int ret = 0;
unsigned char text[1024];
unsigned int palette_number;
int i;
unsigned char r, g, b;
int base_palette_index;
while (!packet_read) {
fourcc_tag = get_le32(pb);
size = (get_be32(pb) + 1) & (~1);
if (url_feof(pb))
return AVERROR(EIO);
switch (fourcc_tag) {
case BRCH_TAG:
break;
case SHOT_TAG:
palette_number = get_le32(pb);
if (palette_number >= wc3->palette_count)
return AVERROR_INVALIDDATA;
base_palette_index = palette_number * PALETTE_COUNT * 3;
for (i = 0; i < PALETTE_COUNT; i++) {
r = wc3->palettes[base_palette_index + i * 3 + 0];
g = wc3->palettes[base_palette_index + i * 3 + 1];
b = wc3->palettes[base_palette_index + i * 3 + 2];
wc3->palette_control.palette[i] = (r << 16) | (g << 8) | (b);
}
wc3->palette_control.palette_changed = 1;
break;
case VGA__TAG:
ret= av_get_packet(pb, pkt, size);
pkt->stream_index = wc3->video_stream_index;
pkt->pts = wc3->pts;
packet_read = 1;
break;
case TEXT_TAG:
#if 0
url_fseek(pb, size, SEEK_CUR);
#else
if ((unsigned)size > sizeof(text) || (ret = get_buffer(pb, text, size)) != size)
ret = AVERROR(EIO);
else {
int i = 0;
av_log (s, AV_LOG_DEBUG, "Subtitle time!\n");
av_log (s, AV_LOG_DEBUG, " inglish: %s\n", &text[i + 1]);
i += text[i] + 1;
av_log (s, AV_LOG_DEBUG, " doytsch: %s\n", &text[i + 1]);
i += text[i] + 1;
av_log (s, AV_LOG_DEBUG, " fronsay: %s\n", &text[i + 1]);
}
#endif
break;
case AUDI_TAG:
ret= av_get_packet(pb, pkt, size);
pkt->stream_index = wc3->audio_stream_index;
pkt->pts = wc3->pts;
wc3->pts++;
packet_read = 1;
break;
default:
av_log (s, AV_LOG_ERROR, " unrecognized WC3 chunk: %c%c%c%c (0x%02X%02X%02X%02X)\n",
(uint8_t)fourcc_tag, (uint8_t)(fourcc_tag >> 8), (uint8_t)(fourcc_tag >> 16), (uint8_t)(fourcc_tag >> 24),
(uint8_t)fourcc_tag, (uint8_t)(fourcc_tag >> 8), (uint8_t)(fourcc_tag >> 16), (uint8_t)(fourcc_tag >> 24));
ret = AVERROR_INVALIDDATA;
packet_read = 1;
break;
}
}
return ret;
}
| 1threat |
truncate_f(int argc, char **argv)
{
int64_t offset;
int ret;
offset = cvtnum(argv[1]);
if (offset < 0) {
printf("non-numeric truncate argument -- %s\n", argv[1]);
return 0;
}
ret = bdrv_truncate(bs, offset);
if (ret < 0) {
printf("truncate: %s", strerror(ret));
return 0;
}
return 0;
}
| 1threat |
static int qxl_init_common(PCIQXLDevice *qxl)
{
uint8_t* config = qxl->pci.config;
uint32_t pci_device_rev;
uint32_t io_size;
qxl->mode = QXL_MODE_UNDEFINED;
qxl->generation = 1;
qxl->num_memslots = NUM_MEMSLOTS;
qemu_mutex_init(&qxl->track_lock);
qemu_mutex_init(&qxl->async_lock);
qxl->current_async = QXL_UNDEFINED_IO;
qxl->guest_bug = 0;
switch (qxl->revision) {
case 1:
pci_device_rev = QXL_REVISION_STABLE_V04;
io_size = 8;
break;
case 2:
pci_device_rev = QXL_REVISION_STABLE_V06;
io_size = 16;
break;
case 3:
pci_device_rev = QXL_REVISION_STABLE_V10;
io_size = 32;
break;
#if SPICE_SERVER_VERSION >= 0x000b01 && \
defined(CONFIG_QXL_IO_MONITORS_CONFIG_ASYNC)
case 4:
pci_device_rev = QXL_REVISION_STABLE_V12;
io_size = msb_mask(QXL_IO_RANGE_SIZE * 2 - 1);
break;
#endif
default:
error_report("Invalid revision %d for qxl device (max %d)",
qxl->revision, QXL_DEFAULT_REVISION);
return -1;
}
pci_set_byte(&config[PCI_REVISION_ID], pci_device_rev);
pci_set_byte(&config[PCI_INTERRUPT_PIN], 1);
qxl->rom_size = qxl_rom_size();
memory_region_init_ram(&qxl->rom_bar, "qxl.vrom", qxl->rom_size);
vmstate_register_ram(&qxl->rom_bar, &qxl->pci.qdev);
init_qxl_rom(qxl);
init_qxl_ram(qxl);
qxl->guest_surfaces.cmds = g_new0(QXLPHYSICAL, qxl->ssd.num_surfaces);
memory_region_init_ram(&qxl->vram_bar, "qxl.vram", qxl->vram_size);
vmstate_register_ram(&qxl->vram_bar, &qxl->pci.qdev);
memory_region_init_alias(&qxl->vram32_bar, "qxl.vram32", &qxl->vram_bar,
0, qxl->vram32_size);
memory_region_init_io(&qxl->io_bar, &qxl_io_ops, qxl,
"qxl-ioports", io_size);
if (qxl->id == 0) {
vga_dirty_log_start(&qxl->vga);
}
memory_region_set_flush_coalesced(&qxl->io_bar);
pci_register_bar(&qxl->pci, QXL_IO_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_IO, &qxl->io_bar);
pci_register_bar(&qxl->pci, QXL_ROM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->rom_bar);
pci_register_bar(&qxl->pci, QXL_RAM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->vga.vram);
pci_register_bar(&qxl->pci, QXL_VRAM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->vram32_bar);
if (qxl->vram32_size < qxl->vram_size) {
pci_register_bar(&qxl->pci, QXL_VRAM64_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_TYPE_64 |
PCI_BASE_ADDRESS_MEM_PREFETCH,
&qxl->vram_bar);
}
dprint(qxl, 1, "ram/%s: %d MB [region 0]\n",
qxl->id == 0 ? "pri" : "sec",
qxl->vga.vram_size / (1024*1024));
dprint(qxl, 1, "vram/32: %d MB [region 1]\n",
qxl->vram32_size / (1024*1024));
dprint(qxl, 1, "vram/64: %d MB %s\n",
qxl->vram_size / (1024*1024),
qxl->vram32_size < qxl->vram_size ? "[region 4]" : "[unmapped]");
qxl->ssd.qxl.base.sif = &qxl_interface.base;
qxl->ssd.qxl.id = qxl->id;
qemu_spice_add_interface(&qxl->ssd.qxl.base);
qemu_add_vm_change_state_handler(qxl_vm_change_state_handler, qxl);
init_pipe_signaling(qxl);
qxl_reset_state(qxl);
qxl->update_area_bh = qemu_bh_new(qxl_render_update_area_bh, qxl);
return 0;
}
| 1threat |
How to launch a local .html file as a pop-up? : <p>I am wondering what I can add to make an .html or .htm file create a pop-up window instead of creating a normal window and load the content in that window. Is there a way to do this? I have no idea, thanks.</p>
| 0debug |
.Net serial port Basestream reader : My app in c# read integers (string "X/n") from serial port but it isn't work correctly, after sending 30 lines starts to send 1-2 digits with spaces. Is that something with buffor? I try use BaseStream.ReadAsync, but it make too many errors. I'm a novice programmer so please simple explanation.
SerialPort serialPort;
private Action startReading;
int bufferLength = 4096;
public Form1()
{
InitializeComponent();
}
public bool Open()
{
serialPort = new SerialPort("COM4", 9600, Parity.None, 8, StopBits.One);
bool result = false;
try
{
this.serialPort.Open();
result = true;
startReading = StartAsyncSerialReading;
startReading();
}
catch (Exception)
{
this.Close();
result = false;
}
return result;
}
private void StartAsyncSerialReading()
{
byte[] buffer = new byte[bufferLength];
serialPort.BaseStream.BeginRead(buffer, 0, bufferLength, delegate (IAsyncResult ar)
{
try
{
if (serialPort.IsOpen)
{
int actualLength = serialPort.BaseStream.EndRead(ar);
byte[] received = new byte[actualLength];
Buffer.BlockCopy(buffer, 0, received, 0, actualLength);
string data = Encoding.ASCII.GetString(received, 0, actualLength);
Console.WriteLine(data);
}
}
catch (IOException exc)
{
## Heading ##
}
if (serialPort.IsOpen)
startReading();
}, null);
}
public void ClosePort()
{
this.serialPort.Close();
this.serialPort.Dispose();
}
private void button2_Click(object sender, EventArgs e)
{
ClosePort();
}
private void button1_Click(object sender, EventArgs e)
{
Open();
StartAsyncSerialReading();
} | 0debug |
R Studio- Linear Regression : I am trying to use the coef function in r, however I need to know how to use this function by extracting columns from a dataset. I tried coef(rain$spring, rain$autumn) but it returned a message saying I could not use $. The dataset is rain, the variables are spring and autumn. There is another dataset spring so I cannot simply attach the two variables.
Thanks! | 0debug |
static int ipvideo_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
IpvideoContext *s = avctx->priv_data;
AVFrame *frame = data;
int ret;
int send_buffer;
int frame_format;
int video_data_size;
if (av_packet_get_side_data(avpkt, AV_PKT_DATA_PARAM_CHANGE, NULL)) {
av_frame_unref(s->last_frame);
av_frame_unref(s->second_last_frame);
if (buf_size < 8)
return AVERROR_INVALIDDATA;
frame_format = AV_RL8(buf);
send_buffer = AV_RL8(buf + 1);
video_data_size = AV_RL16(buf + 2);
s->decoding_map_size = AV_RL16(buf + 4);
s->skip_map_size = AV_RL16(buf + 6);
switch(frame_format) {
case 0x06:
if (s->decoding_map_size) {
av_log(avctx, AV_LOG_ERROR, "Decoding map for format 0x06\n");
return AVERROR_INVALIDDATA;
if (s->skip_map_size) {
av_log(avctx, AV_LOG_ERROR, "Skip map for format 0x06\n");
return AVERROR_INVALIDDATA;
if (s->is_16bpp) {
av_log(avctx, AV_LOG_ERROR, "Video format 0x06 does not support 16bpp movies\n");
return AVERROR_INVALIDDATA;
s->decoding_map_size = ((s->avctx->width / 8) * (s->avctx->height / 8)) * 2;
s->decoding_map = buf + 8 + 14;
video_data_size -= s->decoding_map_size + 14;
if (video_data_size <= 0)
return AVERROR_INVALIDDATA;
if (buf_size < 8 + s->decoding_map_size + 14 + video_data_size)
return AVERROR_INVALIDDATA;
bytestream2_init(&s->stream_ptr, buf + 8 + s->decoding_map_size + 14, video_data_size);
break;
case 0x10:
if (! s->decoding_map_size) {
av_log(avctx, AV_LOG_ERROR, "Empty decoding map for format 0x10\n");
return AVERROR_INVALIDDATA;
if (! s->skip_map_size) {
av_log(avctx, AV_LOG_ERROR, "Empty skip map for format 0x10\n");
return AVERROR_INVALIDDATA;
if (s->is_16bpp) {
av_log(avctx, AV_LOG_ERROR, "Video format 0x10 does not support 16bpp movies\n");
return AVERROR_INVALIDDATA;
if (buf_size < 8 + video_data_size + s->decoding_map_size + s->skip_map_size)
return AVERROR_INVALIDDATA;
bytestream2_init(&s->stream_ptr, buf + 8, video_data_size);
s->decoding_map = buf + 8 + video_data_size;
s->skip_map = buf + 8 + video_data_size + s->decoding_map_size;
break;
case 0x11:
if (! s->decoding_map_size) {
av_log(avctx, AV_LOG_ERROR, "Empty decoding map for format 0x11\n");
return AVERROR_INVALIDDATA;
if (s->skip_map_size) {
av_log(avctx, AV_LOG_ERROR, "Skip map for format 0x11\n");
return AVERROR_INVALIDDATA;
if (buf_size < 8 + video_data_size + s->decoding_map_size)
return AVERROR_INVALIDDATA;
bytestream2_init(&s->stream_ptr, buf + 8, video_data_size);
s->decoding_map = buf + 8 + video_data_size;
break;
default:
av_log(avctx, AV_LOG_ERROR, "Frame type 0x%02X unsupported\n", frame_format);
if (buf_size < 8 + s->decoding_map_size + video_data_size + s->skip_map_size) {
av_log(avctx, AV_LOG_ERROR, "Invalid IP packet size\n");
return AVERROR_INVALIDDATA;
if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
if (!s->is_16bpp) {
int size;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
if (pal && size == AVPALETTE_SIZE) {
frame->palette_has_changed = 1;
memcpy(s->pal, pal, AVPALETTE_SIZE);
} else if (pal) {
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
switch(frame_format) {
case 0x06:
ipvideo_decode_format_06_opcodes(s, frame);
break;
case 0x10:
ipvideo_decode_format_10_opcodes(s, frame);
break;
case 0x11:
ipvideo_decode_format_11_opcodes(s, frame);
break;
*got_frame = send_buffer;
av_frame_unref(s->second_last_frame);
FFSWAP(AVFrame*, s->second_last_frame, s->last_frame);
if ((ret = av_frame_ref(s->last_frame, frame)) < 0)
return buf_size; | 1threat |
Performance Angular 2 is low - test : <p>I developed this little system here using angular 2.
I lodge in amazon and I am finding it very slow.
my system:</p>
<p><a href="http://www.renatodev.com.br/" rel="nofollow">http://www.renatodev.com.br/</a></p>
<p>login: demo
senha: demo123</p>
<p>is normal this performance?</p>
| 0debug |
Realization of "IsProcessorFeaturePresent" on С++ : Help please remake a small piece of code from C# to C++
class Program
{
static void Main(string[] args)
{
foreach (ProcessorFeature feature in System.Enum.GetValues(typeof(ProcessorFeature)))
{
System.Console.WriteLine(feature.ToString() + "\t: " + IsProcessorFeaturePresent(feature));
}
}
[System.Runtime.InteropServices.DllImport("Kernel32")]
static extern bool IsProcessorFeaturePresent(ProcessorFeature processorFeature);
enum ProcessorFeature : uint
{
PF_FLOATING_POINT_PRECISION_ERRATA = 0,
PF_FLOATING_POINT_EMULATED = 1,
PF_COMPARE_EXCHANGE_DOUBLE = 2,
PF_MMX_INSTRUCTIONS_AVAILABLE = 3,
PF_PPC_MOVEMEM_64BIT_OK = 4,
PF_ALPHA_BYTE_INSTRUCTIONS = 5,
PF_XMMI_INSTRUCTIONS_AVAILABLE = 6,
PF_3DNOW_INSTRUCTIONS_AVAILABLE = 7,
PF_RDTSC_INSTRUCTION_AVAILABLE = 8,
PF_PAE_ENABLED = 9,
PF_XMMI64_INSTRUCTIONS_AVAILABLE = 10,
PF_SSE_DAZ_MODE_AVAILABLE = 11,
PF_NX_ENABLED = 12,
PF_SSE3_INSTRUCTIONS_AVAILABLE = 13,
PF_COMPARE_EXCHANGE128 = 14,
PF_COMPARE64_EXCHANGE128 = 15,
PF_CHANNELS_ENABLED = 16,
PF_XSAVE_ENABLED = 17,
PF_SECOND_LEVEL_ADDRESS_TRANSLATION = 20,
PF_VIRT_FIRMWARE_ENABLED = 21,
}
}
I'm trying to create an enumeration, but the compiler writes "Need an identifier". <BR>
The compiler writes that there is already a definition in "winnt.h"
#define PF_FLOATING_POINT_PRECISION_ERRATA 0
I connected the library as stated in [msdn][1].
#include <winnt.h>
#pragma comment (lib, "Kernel32.lib")
I don't even know how "foreach" is implemented on c ++<BR>
Help please, I really need it.
[1]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724482(v=vs.85).aspx | 0debug |
Logcat full of "input svInfo.flags is 8" while app is running : <p>When I run almost any app on android studio, my logcat gets full of messages like:</p>
<p>"? E/GnssHAL_GnssInterface: gnssSvStatusCb: a: input svInfo.flags is 8
? E/GnssHAL_GnssInterface: gnssSvStatusCb: b: input svInfo.flags is 8"</p>
<p>What's this? Is there something wrong about my app?</p>
| 0debug |
Indexing list in Python : I am trying to create a list in Python but I don't want to write the whole thing out! Is there a way to automatically generate an indexed list?
The list I am trying to create is:
[url_1,url_2,url_3,...,url_500] | 0debug |
How give a app NAME instzead of "sudo sails lift"???!!! own app Name or commandline??? Please!!!`` : How give a app NAME instzead of "sudo sails lift"???!!! own app Name or commandline??? Please!!!`` how can i create a own app name instead of this "sails lift" and with out the boat (grafic) there, when do you lift the app?...
how to create a own commandline for sails app? liek app name etc.? i get this everytime.. but i want change it to a own grafic with out the boat and sails lift...? how doing that and where ? please help!
info: Starting app...
info:
info: .-..-.
info:
info: Sails <| .-..-.
info: v0.11.5 |\
info: /|.\
info: / || \
info: ,' |' \
info: .-'.-==|/_--'
info: `--'-------'
info: __---___--___---___--___---___--___
info: ____---___--___---___--___---___--___-__
info:
info: Server lifted in `/Users/cyberspace/Documents/Apps/www.project.com/project/myapp`
info: To see your app, visit http://localhost
info: To shut down Sails, press <CTRL> + C at any time. | 0debug |
count the total numbers of unique latters occured once in a string in python? : a = 'abhishek'
count = 0
for x in a:
if x in a:
count += 1
print(count)
I have tried this but it gives me the total number of letters. I want only a unique latter that occurs only once. | 0debug |
static void tcx_stip_writel(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
TCXState *s = opaque;
int i;
uint32_t col;
if (!(addr & 4)) {
s->tmpblit = val;
} else {
addr = (addr >> 3) & 0xfffff;
col = cpu_to_be32(s->tmpblit);
if (s->depth == 24) {
for (i = 0; i < 32; i++) {
if (val & 0x80000000) {
s->vram[addr + i] = s->tmpblit;
s->vram24[addr + i] = col;
}
val <<= 1;
}
} else {
for (i = 0; i < 32; i++) {
if (val & 0x80000000) {
s->vram[addr + i] = s->tmpblit;
}
val <<= 1;
}
}
memory_region_set_dirty(&s->vram_mem, addr, 32);
}
}
| 1threat |
Vue js rerender the same component when changing route : <p>I have one auth component that I am using both in the login and the signup route.</p>
<pre><code>const routes = [{
path : '/',
name: 'home',
component: Home
}, {
path : '/signin',
name: 'signin',
component: Auth
},
{
path : '/signup',
name: 'signup',
component: Auth
}];
</code></pre>
<p>If for example, I'm on the login page The problem is if I type something in the text inputs and go to the signup the text is still there, how I force the component to reinitialize?</p>
| 0debug |
Reversing numbers in lines, have a regex already need to modify it : So @horucrux came up with an amazing regex to make all numbers in each line backwards, but it doesnt work in all lines only some lines get made backwards, i noticed some lines start with numbers and they dont get inverted and some with words in the middle dont work either, please if anyone know hows to fix modify this regex, please help and thank you
Regex Horocrux provided
Step 1. Add a marker for the not-yet-inverted digits.
Find:
\b(\w+?)(\d+)\b
Replace:
$1§$2
You can choose other marker instead of §.
Step 2. Do Replace all enough times with these settings:
Find:
\b(\w+)§(\d*)(\d)\b
Replace:
$1$3§$2
Step 3. Delete all markers.
Find:
\b(\w+\d)§
Replace:
$1 | 0debug |
static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
{
VP56RangeCoder *c = &s->c;
int part1_size, hscale, vscale, i, j, ret;
int width = s->avctx->width;
int height = s->avctx->height;
s->profile = (buf[0] >> 1) & 7;
if (s->profile > 1) {
avpriv_request_sample(s->avctx, "Unknown profile %d", s->profile);
return AVERROR_INVALIDDATA;
}
s->keyframe = !(buf[0] & 1);
s->invisible = 0;
part1_size = AV_RL24(buf) >> 4;
buf += 4 - s->profile;
buf_size -= 4 - s->profile;
memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab, sizeof(s->put_pixels_tab));
ff_vp56_init_range_decoder(c, buf, part1_size);
buf += part1_size;
buf_size -= part1_size;
if (s->keyframe) {
width = vp8_rac_get_uint(c, 12);
height = vp8_rac_get_uint(c, 12);
hscale = vp8_rac_get_uint(c, 2);
vscale = vp8_rac_get_uint(c, 2);
if (hscale || vscale)
avpriv_request_sample(s->avctx, "Upscaling");
s->update_golden = s->update_altref = VP56_FRAME_CURRENT;
vp78_reset_probability_tables(s);
memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter,
sizeof(s->prob->pred16x16));
memcpy(s->prob->pred8x8c, vp8_pred8x8c_prob_inter,
sizeof(s->prob->pred8x8c));
for (i = 0; i < 2; i++)
memcpy(s->prob->mvc[i], vp7_mv_default_prob[i],
sizeof(vp7_mv_default_prob[i]));
memset(&s->segmentation, 0, sizeof(s->segmentation));
memset(&s->lf_delta, 0, sizeof(s->lf_delta));
memcpy(s->prob[0].scan, zigzag_scan, sizeof(s->prob[0].scan));
}
if (s->keyframe || s->profile > 0)
memset(s->inter_dc_pred, 0 , sizeof(s->inter_dc_pred));
for (i = 0; i < 4; i++) {
s->feature_enabled[i] = vp8_rac_get(c);
if (s->feature_enabled[i]) {
s->feature_present_prob[i] = vp8_rac_get_uint(c, 8);
for (j = 0; j < 3; j++)
s->feature_index_prob[i][j] =
vp8_rac_get(c) ? vp8_rac_get_uint(c, 8) : 255;
if (vp7_feature_value_size[i])
for (j = 0; j < 4; j++)
s->feature_value[i][j] =
vp8_rac_get(c) ? vp8_rac_get_uint(c, vp7_feature_value_size[s->profile][i]) : 0;
}
}
s->segmentation.enabled = 0;
s->segmentation.update_map = 0;
s->lf_delta.enabled = 0;
s->num_coeff_partitions = 1;
ff_vp56_init_range_decoder(&s->coeff_partition[0], buf, buf_size);
if (!s->macroblocks_base ||
width != s->avctx->width || height != s->avctx->height ||
(width + 15) / 16 != s->mb_width || (height + 15) / 16 != s->mb_height) {
if ((ret = vp7_update_dimensions(s, width, height)) < 0)
return ret;
}
vp7_get_quants(s);
if (!s->keyframe) {
s->update_golden = vp8_rac_get(c) ? VP56_FRAME_CURRENT : VP56_FRAME_NONE;
s->sign_bias[VP56_FRAME_GOLDEN] = 0;
}
s->update_last = 1;
s->update_probabilities = 1;
s->fade_present = 1;
if (s->profile > 0) {
s->update_probabilities = vp8_rac_get(c);
if (!s->update_probabilities)
s->prob[1] = s->prob[0];
if (!s->keyframe)
s->fade_present = vp8_rac_get(c);
}
if (s->fade_present && vp8_rac_get(c)) {
if ((ret = vp7_fade_frame(s ,c)) < 0)
return ret;
}
if (!s->profile)
s->filter.simple = vp8_rac_get(c);
if (vp8_rac_get(c))
for (i = 1; i < 16; i++)
s->prob[0].scan[i] = zigzag_scan[vp8_rac_get_uint(c, 4)];
if (s->profile > 0)
s->filter.simple = vp8_rac_get(c);
s->filter.level = vp8_rac_get_uint(c, 6);
s->filter.sharpness = vp8_rac_get_uint(c, 3);
vp78_update_probability_tables(s);
s->mbskip_enabled = 0;
if (!s->keyframe) {
s->prob->intra = vp8_rac_get_uint(c, 8);
s->prob->last = vp8_rac_get_uint(c, 8);
vp78_update_pred16x16_pred8x8_mvc_probabilities(s, VP7_MVC_SIZE);
}
return 0;
}
| 1threat |
SQL, Case When returning the incorrect results : <p>This error is starting to tick me off so im posting pictures instead sorry......</p>
<p><a href="https://i.stack.imgur.com/4ShQU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4ShQU.png" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/Kcu7S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Kcu7S.png" alt="enter image description here"></a></p>
| 0debug |
static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)
{
sPAPRMachineState *spapr =
(sPAPRMachineState *) object_dynamic_cast(qdev_get_machine(),
TYPE_SPAPR_MACHINE);
sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev));
sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(OBJECT(dev));
CPUCore *cc = CPU_CORE(OBJECT(dev));
size_t size;
Error *local_err = NULL;
void *obj;
int i, j;
if (!spapr) {
error_setg(errp, TYPE_SPAPR_CPU_CORE " needs a pseries machine");
return;
}
size = object_type_get_instance_size(scc->cpu_type);
sc->threads = g_malloc0(size * cc->nr_threads);
for (i = 0; i < cc->nr_threads; i++) {
char id[32];
CPUState *cs;
PowerPCCPU *cpu;
obj = sc->threads + i * size;
object_initialize(obj, size, scc->cpu_type);
cs = CPU(obj);
cpu = POWERPC_CPU(cs);
cs->cpu_index = cc->core_id + i;
cpu->vcpu_id = (cc->core_id * spapr->vsmt / smp_threads) + i;
if (kvm_enabled() && !kvm_vcpu_id_is_valid(cpu->vcpu_id)) {
error_setg(&local_err, "Can't create CPU with id %d in KVM",
cpu->vcpu_id);
error_append_hint(&local_err, "Adjust the number of cpus to %d "
"or try to raise the number of threads per core\n",
cpu->vcpu_id * smp_threads / spapr->vsmt);
goto err;
}
cpu->node_id = sc->node_id;
snprintf(id, sizeof(id), "thread[%d]", i);
object_property_add_child(OBJECT(sc), id, obj, &local_err);
if (local_err) {
goto err;
}
object_unref(obj);
}
for (j = 0; j < cc->nr_threads; j++) {
obj = sc->threads + j * size;
spapr_cpu_core_realize_child(obj, spapr, &local_err);
if (local_err) {
goto err;
}
}
return;
err:
while (--i >= 0) {
obj = sc->threads + i * size;
object_unparent(obj);
}
g_free(sc->threads);
error_propagate(errp, local_err);
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.