problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Hi guys...how do i make this jquery function repeat...its an image morphing function ...its working fine ..i just want it to loop : Heres the code...images morph one into another.I want this function to loop infinite
$(document).ready(function(){
$(".cup2").fadeOut(15000);
$(".cup1").animate({opacity:'1'},15000);
$(".cup1").delay(5000).fadeOut(10000);
$(".cup4").delay(15000).animate({opacity:'1'},15000);
$(".cup4").delay(5000).fadeOut(6000);
$(".cup5").delay(30000).animate({opacity:'1'},15000);
$(".cup5").delay(5000).fadeOut(6000);
$(".cup6").delay(45000).animate({opacity:'1'},15000);
$(".cup6").delay(8000).fadeOut(5000);
$(".cup7").delay(55000).animate({opacity:'1'},15000);
});
| 0debug |
static inline void decode_subband_slice_buffered(SnowContext *s, SubBand *b, slice_buffer * sb, int start_y, int h, int save_state[1]){
const int w= b->width;
int y;
const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16);
int qmul= ff_qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
int qadd= (s->qbias*qmul)>>QBIAS_SHIFT;
int new_index = 0;
if(b->ibuf == s->spatial_idwt_buffer || s->qlog == LOSSLESS_QLOG){
qadd= 0;
qmul= 1<<QEXPSHIFT;
}
if (start_y != 0)
new_index = save_state[0];
for(y=start_y; y<h; y++){
int x = 0;
int v;
IDWTELEM * line = slice_buffer_get_line(sb, y * b->stride_line + b->buf_y_offset) + b->buf_x_offset;
memset(line, 0, b->width*sizeof(IDWTELEM));
v = b->x_coeff[new_index].coeff;
x = b->x_coeff[new_index++].x;
while(x < w){
register int t= ( (v>>1)*qmul + qadd)>>QEXPSHIFT;
register int u= -(v&1);
line[x] = (t^u) - u;
v = b->x_coeff[new_index].coeff;
x = b->x_coeff[new_index++].x;
}
}
save_state[0] = new_index;
return;
}
| 1threat |
Pointer Not Aligned to Address : <p>Few weeks ago it has been informed that Firebase framework is generating a warnings like "Pointer Not Aligned to Address" on Xcode 8.3..
I was having 32 and now 67. Google dev. was working on it, does it clear to anybody when the update will be pushed ?</p>
| 0debug |
React native debugger is too slow : <p>Ok so this is really been a headache for me. I have been trying to develop a react native app but the Debug JS feature on chrome makes it run very very slowly. Each button click and transition takes almost a couple of minutes and sometimes longer making debugging close to impossible.</p>
<p>I have removed many of the unused console.log statements to try and speed things up. I have also pulled the debugging tab into its own separate window. But there no real change in speed. I have also tried to connect the phone over wifi to debug it. I am running the code on the hardware device and have already tried the suggestions given in the following posts </p>
<p><a href="https://github.com/facebook/react-native/issues/10559" rel="noreferrer">https://github.com/facebook/react-native/issues/10559</a>
<a href="https://github.com/facebook/react-native/issues/5632" rel="noreferrer">https://github.com/facebook/react-native/issues/5632</a></p>
<p>What is the best approach to make the debugging faster and more tolerable?</p>
| 0debug |
How to resend SMS verification in Firebase Phone Authentication Android? : <p>According to Firebase documentation (<a href="https://firebase.google.com/docs/auth/android/phone-auth#send-a-verification-code-to-the-users-phone" rel="noreferrer">https://firebase.google.com/docs/auth/android/phone-auth#send-a-verification-code-to-the-users-phone</a>), there is <code>callback</code> for handling the phone number authentication.</p>
<pre><code>mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
Log.d(TAG, "onVerificationCompleted:" + credential);
signInWithPhoneAuthCredential(credential);
}
@Override
public void onVerificationFailed(FirebaseException e) {
Log.w(TAG, "onVerificationFailed", e);
}
@Override
public void onCodeSent(String verificationId,
PhoneAuthProvider.ForceResendingToken token) {
Log.d(TAG, "onCodeSent:" + verificationId);
// Save verification ID and resending token so we can use them later
mVerificationId = verificationId;
mResendToken = token;
}
};
</code></pre>
<p>My question is on <code>onCodeSent</code> method. It said on the doc here (<a href="https://firebase.google.com/docs/reference/android/com/google/firebase/auth/PhoneAuthProvider.ForceResendingToken" rel="noreferrer">https://firebase.google.com/docs/reference/android/com/google/firebase/auth/PhoneAuthProvider.ForceResendingToken</a>) </p>
<p>that the <code>token</code> can be used to force re-sending an SMS verification code. However, after doing some research on the doc I still don't know how.</p>
<p>I would like to ask how to use this <code>token</code> to resend the SMS verification ?</p>
| 0debug |
Empty SQL afte form submission : I've searched and searched I cannot find an answer to this
I've made a form [HERE][1] Its very basic. Somehow it's not submitting the final data. the code is
<
form class="form" action="submit.php" method="post">
<table>
<tr>
<td>Team Name: </td>
<td><input type="text" name="team"></td>
</tr>
<tr>
<td>Captains xbox tag: </td>
<td><input type="text" name="cap"></td>
<tr>
<td>Captains E-mail:</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>Team Mates: </td>
<td><TEXTAREA name="teammates" rows="6" cols="50">
Please place each team member on a new line
</TEXTAREA><br></td>
</tr>
<tr>
<td>Sub team mates: </td>
<td><TEXTAREA name="subs" rows="2" cols="50"></TEXTAREA></td>
</tr>
</table>
<p><input type="submit"></p>
</form>
Thats the form
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "dbname";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO tournament1 (team, teammates, cap, email, subs)
VALUES ('$_POST[team]','$_POST[cap]','$_POST[email]','$_POST[teammates]','$_POST[subs]')";
if ($conn->query($sql) === TRUE) {
echo "Your team has been submitted Thankyou. You will be redirected back to the tournaments page Shortly";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
What am I doing wrong? It will connect and do something because the ID fills because its autoincremented. everything else gets lost.
Thanks in advance guys
Kyle
[1]: http://vixengaming.online/tournaments.html | 0debug |
The method sort(List<T>) in the type Collections is not applicable for the arguments (HashSet<Book>) : I have created **HashSet** which contains elements as Book(name,author) .I have used implemented **comparable interface**.But it giving me above error.<br> <p>Here I have created class as **BookHashSetDemo** where book elements added as below</p>
import java.util.Collections;
import java.util.HashSet;
public class BookHashSetDemo {
public static void main(String[] args) {
HashSet<Book> hashSet=new HashSet<Book>();
Book book1=new Book("ABC","XYZ");
Book book2=new Book("lmn","opq");
Book book3=new Book("rst","uvw");
Book book4=new Book("ABC","XYZ");
hashSet.add(book1);
hashSet.add(book2);
hashSet.add(book3);
hashSet.add(book4);
System.out.println(hashSet);
Book book=new Book();
Collections.sort(hashSet);
}`<br>
And created class **Book** where **Comparable Inteface** implemented as below<br>
class Book implements Comparable<Book> {
String name;
String author;
public Book(String name, String author) {
this.name=name;
this.author=author;
}
public String toString() {
return author+"-->"+name;
}
@Override
public int compareTo(Book o) {
// TODO Auto-generated method stub
return name.compareTo(o.name);
}
}
what I am doing wrong??Thanks in advance.
| 0debug |
How to execute an async fetch request and then retry last failed request? : <p><a href="https://github.com/apollographql/apollo-link/tree/master/packages/apollo-link-error#retrying-failed-requests" rel="noreferrer">Apollo link offers an error handler <code>onError</code></a></p>
<p><strong>Issue:</strong>
Currently, we wish to refresh oauth tokens when they expires during an apollo call and we are unable to execute an async fetch request inside the <code>onError</code> properly. </p>
<p><strong>Code:</strong></p>
<p><code>initApolloClient.js</code>
</p>
<pre><code>import { ApolloClient } from 'apollo-client';
import { onError } from 'apollo-link-error';
import { ApolloLink, fromPromise } from 'apollo-link';
//Define Http link
const httpLink = new createHttpLink({
uri: '/my-graphql-endpoint',
credentials: 'include'
});
//Add on error handler for apollo link
return new ApolloClient({
link: ApolloLink.from([
onError(({ graphQLErrors, networkError, operation, forward }) => {
if (graphQLErrors) {
//User access token has expired
if(graphQLErrors[0].message==="Unauthorized") {
//We assume we have both tokens needed to run the async request
if(refreshToken && clientToken) {
//let's refresh token through async request
return fromPromise(
authAPI.requestRefreshToken(refreshToken,clientToken)
.then((refreshResponse) => {
let headers = {
//readd old headers
...operation.getContext().headers,
//switch out old access token for new one
authorization: `Bearer ${refreshResponse.access_token}`,
};
operation.setContext({
headers
});
//Retry last failed request
return forward(operation);
})
.catch(function (error) {
//No refresh or client token available, we force user to login
return error;
})
)
}
}
}
}
}
}),
</code></pre>
<p>What happens is:</p>
<ol>
<li>Initial graphQL query runs and fails due to unauthorization</li>
<li>The <code>onError</code> function of <code>ApolloLink</code> is executed.</li>
<li>The promise to refresh the token is executed.</li>
<li>The <code>onError</code> function of <code>ApolloLink</code> is executed again??</li>
<li>The promise to refresh the token is completed.</li>
<li>The initial graphQL query result is returned and its data is <code>undefined</code></li>
</ol>
<p>Between step 5 and 6, <em>apollo doesn't re-run the initial failed graphQL query</em> and hence the result is <code>undefined</code>.</p>
<p><strong>Errors from console:</strong></p>
<pre class="lang-js prettyprint-override"><code>Uncaught (in promise) Error: Network error: Error writing result to store for query:
query UserProfile($id: ID!) {
UserProfile(id: $id) {
id
email
first_name
last_name
}
__typename
}
}
</code></pre>
<p>The solution should allow us to:</p>
<ol>
<li>Run an async request when an operation fails</li>
<li>Wait for the result of the request</li>
<li>Retry failed operation with data from the request's result</li>
<li>Operation should succeed to return its intended result</li>
</ol>
| 0debug |
bool arp_table_search(Slirp *slirp, uint32_t ip_addr,
uint8_t out_ethaddr[ETH_ALEN])
{
const uint32_t broadcast_addr =
~slirp->vnetwork_mask.s_addr | slirp->vnetwork_addr.s_addr;
ArpTable *arptbl = &slirp->arp_table;
int i;
DEBUG_CALL("arp_table_search");
DEBUG_ARG("ip = 0x%x", ip_addr);
assert((ip_addr & htonl(~(0xf << 28))) != 0);
if (ip_addr == 0xffffffff || ip_addr == broadcast_addr) {
memset(out_ethaddr, 0xff, ETH_ALEN);
return 1;
}
for (i = 0; i < ARP_TABLE_SIZE; i++) {
if (arptbl->table[i].ar_sip == ip_addr) {
memcpy(out_ethaddr, arptbl->table[i].ar_sha, ETH_ALEN);
DEBUG_ARGS((dfd, " found hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n",
out_ethaddr[0], out_ethaddr[1], out_ethaddr[2],
out_ethaddr[3], out_ethaddr[4], out_ethaddr[5]));
return 1;
}
}
return 0;
}
| 1threat |
Python: how to compare input() string to another string? : <pre><code>def main ():
x = input("print data? (Y/N) ")
while (x != 'Y' or x != 'N'):
x = input("error: wrong input. Please put Y or N only ")
if x == 'Y':
read_serial()
</code></pre>
<p>Trying to check whether or not the keyboard input (x) is equal to a 'Y' or 'N' string. And if not then the loop continues until it is. However the above code seems to compile and run fine except that no matter what the loop keeps running. Don't have much experience with Python 3 yet so could any one tell me what I'm doing wrong?</p>
| 0debug |
document.getElementById('input').innerHTML = user_input; | 1threat |
How do I find the square root of the negative integer -16 or the numbers that it is a multiple of with a while loop : <p>I am more interested in finding out why this doesn't work</p>
<pre><code>x = -16
ans = -1
ans2 = 1
while (ans*ans2 > x):
ans = ans - 1
ans2 = ans + 1
print ans, ans2
</code></pre>
| 0debug |
getting errors in android app development : compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:23.0.0'
in first line it is showing error: the support library should not use the lower version(24)then the targetsdkversion(25)
in the second line error is: the support library should not use the lower version(23)then the compiledsdkversion(24)[enter image description here][1]
[enter image description here][2]
[1]: https://i.stack.imgur.com/XgIji.png
[2]: https://i.stack.imgur.com/gqFQ6.png | 0debug |
static void qemu_tcg_wait_io_event(CPUState *cpu)
{
while (all_cpu_threads_idle()) {
stop_tcg_kick_timer();
qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex);
}
start_tcg_kick_timer();
CPU_FOREACH(cpu) {
qemu_wait_io_event_common(cpu);
}
}
| 1threat |
static uint64_t pci_host_data_read(void *opaque,
hwaddr addr, unsigned len)
{
PCIHostState *s = opaque;
uint32_t val;
if (!(s->config_reg & (1 << 31)))
return 0xffffffff;
val = pci_data_read(s->bus, s->config_reg | (addr & 3), len);
PCI_DPRINTF("read addr " TARGET_FMT_plx " len %d val %x\n",
addr, len, val);
return val;
}
| 1threat |
Exporting training checkpoint to production - idiot's guide required : <p>I'm having a right 'mare.<br>
I'm having real difficulties with trying to get training information to a state where I can deploy to a production server.<br>
I followed <a href="https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10" rel="nofollow noreferrer">this tutorial</a> (which was very granular and perfect for me). I exported the checkpoint to a frozen inference graph and used the test script to see that it worked <a href="https://www.instagram.com/p/Bj1aCnQlPdd/?taken-by=luke_sadler_" rel="nofollow noreferrer">really quite well</a>. I read somewhere that these frozen inference graphs are no good for production and need to export it to a 'SavedModel'.
I spent a good few hours looking for solutions/ guides but so have found a lot of varying answers - some has successfully exported to the '1/saved-model.pb 1/Variables' model folder structure.<br>
Excited, I got myself a digital ocean account, made an Ubuntu VM with Docker pre-installed and set up the following containers:<br>
- <a href="https://hub.docker.com/r/bitnami/tensorflow-serving/" rel="nofollow noreferrer">Bitnami/tensorflow-serving</a><br>
- <a href="https://hub.docker.com/r/bitnami/tensorflow-inception/" rel="nofollow noreferrer">Bitnami/tensorflow-inception</a> </p>
<p>I am then starting them up with a docker-compose that starts up some shared directories etc. With the example model (inception-v3), I can get this system working quite well when passing in a jpg.<br>
The problem arises when I try to serve my exported model I get a lot of errors that I'm really not understanding and am unable to find solutions to online. When trying to run it from docker cli, I get some (I suspect) <a href="https://hastebin.com/egecabefan.swift" rel="nofollow noreferrer">network errors</a>.
When I try to setup a NodeJS server, using package <a href="https://www.npmjs.com/package/tensorflow-serving-node-client" rel="nofollow noreferrer">tensorflow-serving-node-client</a> (which is probably some variation of what I will use to relay my requests from Firebase) comes back complaining about <a href="https://hastebin.com/oyabayimuw.rb" rel="nofollow noreferrer">'tensors' and 'signatures'</a>. </p>
<p>I'm usually pretty good at problem-solving, but unfortunately, due to lack of sleep, time, and an ability to read particularly well, I'm really coming up short on this one. I know that my fundamental knowledge looks to fall short on the entire subject, which is where my problem-solving is failing. </p>
<p>I have a VERY strong suspicion that I've not exported the checkpoint correctly, hence having difficulty in serving it, but from all the YouTube videos and blog posts that I've been scouring (for well over a week) only explain up to the point of setting the training away or from the point you've exported your model and want to serve it. If I'm understanding it correctly, there appears to be some kind of market in explaining that middle bit. I did follow <a href="https://www.tensorflow.org/serving/serving_basic#train_and_export_tensorflow_model" rel="nofollow noreferrer">this official guide</a>, but when it all exported, everything was empty ~4kb files, which is obviously not right. </p>
<p>Is anyone either able to point me in the right direction as to where I can find a concise, reliable guide? The point where I can stop banging my head against the wall would be amazing. I even asked some 'data scientists' at work and they just told me that they've never heard of it and just use R and Excel... </p>
<p>Send help.</p>
<p>Thanks in advance,<br>
Luke </p>
<p>ps. Sorry about the length. I'm sure it will get butchered down by some mod - I'm a bit of a verbose explainer.</p>
| 0debug |
how python sort's key works : class Solution(object):
def moveZeroes(self, nums):
nums.sort(key =lambda x : 1 if x == 0 else 0)
return nums
i have function above, i don't understand how code `key =lambda x : 1 if x == 0 else 0` works.
i tried to change the lambda function to something i know, like below:
def getKey(item):
if item == 0:
return 1
else:
return 0
But i quite don't understand how key which equals to 1 or 0 affects the result. | 0debug |
static int skeleton_header(AVFormatContext *s, int idx)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
AVStream *st = s->streams[idx];
uint8_t *buf = os->buf + os->pstart;
int version_major, version_minor;
int64_t start_num, start_den, start_granule;
int target_idx, start_time;
strcpy(st->codec->codec_name, "skeleton");
st->codec->codec_type = AVMEDIA_TYPE_DATA;
if (os->psize < 8)
return -1;
if (!strncmp(buf, "fishead", 8)) {
if (os->psize < 64)
return -1;
version_major = AV_RL16(buf+8);
version_minor = AV_RL16(buf+10);
if (version_major != 3 && version_major != 4) {
av_log(s, AV_LOG_WARNING, "Unknown skeleton version %d.%d\n",
version_major, version_minor);
return -1;
}
start_num = AV_RL64(buf+12);
start_den = AV_RL64(buf+20);
if (start_den) {
int base_den;
av_reduce(&start_time, &base_den, start_num, start_den, INT_MAX);
avpriv_set_pts_info(st, 64, 1, base_den);
os->lastpts =
st->start_time = start_time;
}
} else if (!strncmp(buf, "fisbone", 8)) {
if (os->psize < 52)
return -1;
target_idx = ogg_find_stream(ogg, AV_RL32(buf+12));
start_granule = AV_RL64(buf+36);
if (target_idx >= 0 && start_granule != -1) {
ogg->streams[target_idx].lastpts =
s->streams[target_idx]->start_time = ogg_gptopts(s, target_idx, start_granule, NULL);
}
}
return 1;
}
| 1threat |
Python - Having user sort list smallest to biggest : So I'm making a code where it asks the user to to swap two places on the list until the list is from smallest to biggest. So it should look like this:
Hello: Your current list is [6, 7, 8, 2 , 9, 10, 12, 15, 16, 17]
Please pick your first location -> 4
Please pick your second location -> 2
Your new list is [6, 2, 8, 7 , 9, 10, 12, 15, 16, 17]
I've gotten to this part but I am currently unable to figure out how to get the USER to do the sorting and not the code.
Your list is not sorted: Please continue
Please pick your first location -> 1
Please pick your second location -> 2
Your new list is [2, 6, 8, 7 , 9, 10, 12, 15, 16, 17]
Please pick your first location -> 3
Please pick your second location -> 4
Your new list is [2, 6, 7, 8 , 9, 10, 12, 15, 16, 17]
Great job, thank you for sorting my list.
Here is my code:
list = [4,2,5,5,6,4,7,6,9,5]
print("Heres your current list", list)
print("Pick a location between 1 and 10")
num = int(input())
if num <= 10 and num >= 1:
print("Please pick another location between 1 and 10")
num1 = int(input())
tempBox1 = list[num-1]
tempBox2 = list[num1-1]
list[num-1] = tempBox2
list[num1-1] = tempBox1
print("Your new list is", list)
Any help would be appreciated, thank you.
| 0debug |
Using useMemo instead of React.memo syntax issue : <p>I need to make a demonstration of using React Hooks useMemo. I have working code that is as follows that does what I want:</p>
<pre><code>const SpeakerCardDetail = React.memo(
({id,...
</code></pre>
<p>I found a <a href="https://github.com/facebook/react/issues/14616" rel="noreferrer">link</a> that shows that I could use syntax more like this but I can't figure it out exactly.</p>
<p>This is as far as I got:</p>
<pre><code>const SpeakerDetail = React.useMemo(() => {
({ id,
</code></pre>
<p>Clearly not it though. I do get that React.memo solves the problem but I do need to show useMemo in action and am hoping there is an alternative syntax that I can use.</p>
| 0debug |
replace <a> with <button> for one instance using JS : <p>I have code that is automatically generated and would like to replace with .</p>
<pre><code><ul>
<li><a href="#">link 1</a></li>
<li><a href="#">link 2</a></li>
</ul>
<script>
var $button = $('<button />');
$('li:first-child a').replaceWith($button);
</script>
</code></pre>
<p>Any help would be greatly appreciated. I only want to change link 2 to a button.</p>
| 0debug |
Java get First and Last duplicate elements of List : <p><br>
In my application i want to get first and repetitive elements from array
eg,</p>
<pre><code>String[] strings = {"one", "one", "one", "one", "one", "one", "one", "one", "one", "one", "one", "one"
, "two", "two", "two", "two", "two", "two", "two", "two", "two", "two", "two", "two", "two", "two", "two"
, "three", "three", "three", "three", "three", "three", "three", "three", "three", "three", "three"
, "four", "four", "four", "four", "four", "four", "four", "four", "four", "four"
, "five", "five", "five", "five", "five", "five"
, "six", "six", "six", "six", "six", "six", "six", "six", "six"
, "seven", "seven", "seven", "seven", "seven", "seven", "seven", "seven"
, "eight", "eight", "eight", "eight", "eight", "eight"
, "nine", "nine", "nine", "nine", "nine", "nine", "nine", "nine", "nine"
, "ten", "ten", "ten", "ten", "ten", "ten", "ten", "ten", "ten"};
</code></pre>
<p>for the above list i want to get output like<br><br>
one<br>
one<br>
two<br>
two<br>
three<br>
three<br>
four<br>
four<br>
five<br>
five<br>
six<br>
six<br>
seven<br>
seven<br>
eight<br>
eight<br>
nine<br>
nine<br>
ten<br>
ten<br></p>
| 0debug |
JOINING TABLES SQL ORACLE WITHOUT JOIN COLUMNS : Okay so Im pretty new to ORACLE here is my question
DISPLAY STUDENTS INFORMATION ( STUDENTID, LASTNAME, FIRSTNAME, COURSEID, COURSENAME AND MARKS. The results of this query must be sorted by coursename.
Table STUDENTS:
1111111111 Smith Carolyn 124 Rolling Hills St Fullerton
2222222222 Maradona Diego 100 Imperial St Brea
3333333333 Messi Lionel 225 Bristol St Irvine
4444444444 Crosby Sidney 869 Coriander St Brea
5555555555 Ali Mohammed 125 Third Street Fullerton
Table COURSES:
J01 Java 4
B01 DataBase 4
Table RESULTS:
1111111111 B01 110 18
2222222222 B01 110 20
3333333333 B01 110 18
4444444444 B01 909 14
5555555555 B01 909 18
1111111111 J01 110 18
2222222222 J01 110 19
3333333333 J01 909 12
4444444444 J01 110 11
5555555555 J01 110 18
1111111111 B01 110 18
2222222222 B01 110 20
3333333333 B01 110 18
4444444444 B01 909 14
5555555555 B01 909 18
1111111111 J01 110 18
2222222222 J01 110 19
3333333333 J01 909 12
4444444444 J01 110 11
5555555555 J01 110 18
1111111111 B01 110 18
2222222222 B01 110 20
3333333333 B01 110 18
4444444444 B01 909 14
5555555555 B01 909 18
1111111111 J01 110 18
2222222222 J01 110 19
3333333333 J01 909 12
4444444444 J01 110 11
5555555555 J01 110 18
This problem is really bothering me I cant figure it out.....
if someone can help me I would really appreciate it!
Thanks everyone! | 0debug |
Clarification regarding NULL pointers in context of Binary tree : I have a data structure like:
struct node
{
int count;
node *left,*right;
node(int count,node* l,node*r)
{
this->count=count;
this->left=l;
this->right=r;
}
node* update(int l,int r,int v);
};
Now i declare a global variable:
**node* p=new node(0,NULL,NULL);**
So this very statement will cause 'p' to have :
p->count=0;
p->left=NULL;
p->right=NULL;
My question is what happens if I write:
p->left=p->right=p;
As far as i understood that it will give memory to
p->left and p->right which were NULL initially.
So, it would be:
p->left->count=0, p->left->left=NULL,p->left->right=NULL;
p->right->count=0, p->right->left=NULL,p->right->right=NULL;
But i do not think that's what happening because when i am calling
update(0,9,0) where l=0, r=9 and v=0, it is working fine if i have
written this statement: p->left=p->right=p before calling this
function.
But it fails to run if i comment this statement (i.e. it tries to access
NULL pointer values i guess).
Please clarify this doubt.
Thank You.
| 0debug |
static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx)
{
switch (mmu_idx) {
case ARMMMUIdx_S1SE0:
case ARMMMUIdx_S1NSE0:
return true;
default:
return false;
case ARMMMUIdx_S12NSE0:
case ARMMMUIdx_S12NSE1:
g_assert_not_reached();
}
} | 1threat |
Why is this not causing an infinite loop? : <p>From Eloquent JavaScript. Since "i" starts at -1 and decrements by 1 in each loop, this should never reach the end condition "i >= 0". Yet the code works.</p>
<pre><code>function arrayToList(array) {
var list = null;
for (var i = array.length - 1; i >= 0; i--)
list = {value: array[i], rest: list};
return list;
}
console.log(arrayToList([]));
//null
</code></pre>
| 0debug |
my app don't working in android 6.0 platform : <p>I did an SMS application. My app working from platform 10 to platform 22. But doesn't work on platform 23 (so android 6 platform). I'm using Android studio. Why my app don't work on android 23 platform?</p>
<p>(Note: On Android 23 platform my app enjoying "stopped error")</p>
| 0debug |
db.execute('SELECT * FROM employees WHERE id = ' + user_input) | 1threat |
static uint64_t get_migration_pass(void)
{
QDict *rsp, *rsp_return, *rsp_ram;
uint64_t result;
rsp = return_or_event(qmp("{ 'execute': 'query-migrate' }"));
rsp_return = qdict_get_qdict(rsp, "return");
if (!qdict_haskey(rsp_return, "ram")) {
result = 0;
} else {
rsp_ram = qdict_get_qdict(rsp_return, "ram");
result = qdict_get_try_int(rsp_ram, "dirty-sync-count", 0);
QDECREF(rsp);
}
return result;
}
| 1threat |
static void seek_to_maindata(MPADecodeContext *s, long backstep)
{
UINT8 *ptr;
ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3);
ptr -= backstep;
memcpy(ptr, s->inbuf1[s->inbuf_index ^ 1] +
BACKSTEP_SIZE + s->old_frame_size - backstep, backstep);
init_get_bits(&s->gb, ptr, s->frame_size + backstep);
s->inbuf_index ^= 1;
s->inbuf = &s->inbuf1[s->inbuf_index][BACKSTEP_SIZE];
s->old_frame_size = s->frame_size;
}
| 1threat |
join 4 table with specified column : SELECT A.UNITCODE, B.FORMATIONCODE, C.UPPERFORMATIONCODE, D.UPPERFORMATIONCODE FROM UNIT AS A.UNITCODE INNER JOIN FORMATION AS B.FORMATIONCODE INNER JOIN UPPERFORMATION_UNIT AS C.UPPERFORMATION INNER JOIN UPPERFORMATION AS D.UPPERFORMATIONCODE WHERE UNITCODE='7000007'
can you guys help me how to join 4 tables with specified column.. please | 0debug |
Am i using reduce method in a wrong way? : In this problem, i trying to sum up the values inside an array of each object.
I expect the output of [{name: "Bob", scores: [75], {name: "Bill", scores: [95], {name: "Charlie", scores: [95]]
````function winner(c1, c2, c3) {
var customerArr = [];
customerArr.push(c1, c2, c3);
// console.log(customerArr);
customerArr.forEach(customer => {
customer.scores = customer.scores.reduce(function(total, scores) {
return total + scores;
}, 0)
// console.log(Array.isArray(customer.scores))
});
return customerArr;
}
c1 = {"name": "Bob", "scores":[10, 65]}
c2 = {"name":"Bill", "scores":[90, 5]}
c3 = {"name":"Charlie", "scores":[40, 55]};
console.log(winner(c1, c2, c2));
O/P:
TypeError: customerArr[i].scores.reduce is not a function | 0debug |
How To insert Image to database from picturebox : **i have a picturebox and i want to save the picture of that in SQLServer Database (VarBinary)** | 0debug |
Bootstrap 4: auto-suggest drop-down as in the official bootstrap site : <p>If you go to <a href="https://getbootstrap.com/docs/4.0/getting-started/introduction/" rel="noreferrer">https://getbootstrap.com/docs/4.0/getting-started/introduction/</a>, you see a auto-suggest dropdown on the left site of the official boostrap site. How do I implement the same thing on my own web pages? What library is the site using for the auto suggest? I have traced the source code but I can't find the relevant code. </p>
<p><a href="https://i.stack.imgur.com/YvNzU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YvNzU.png" alt="enter image description here"></a></p>
| 0debug |
C programming, copying binary files.(Using fread & fwrite) : C programming, problem with copying binary files.(Using fread & fwrite):`
#include <string.h>
#define PER_READ 30
int main(void)
{
char buffer[500] = { 0 };
FILE* CSV = fopen( "CSV.csv", "rb" );
FILE* csvDest = fopen( "CSVDest.csv", "wb" );
unsigned int finished = 0;
unsigned int counter = 0;
do
{
finished = fread( buffer, sizeof( char*), PER_READ, CSV );//Read all from CSV to a string name buffer
finished += PER_READ * counter;
counter++;
} while (finished == PER_READ * counter);
fwrite( buffer, sizeof( char* ), finished, csvDest );// write all to a the file CSVDest
system( "PAUSE" );
return (0);
}`
THANKS PEPOLE. :) | 0debug |
static int local_chown(FsContext *ctx, const char *path, uid_t uid, gid_t gid)
{
return chown(rpath(ctx, path), uid, gid);
}
| 1threat |
The best way to pass data from vanilla Javascript to React? : <p>I am integrating some react+redux code into a website that is made completely in vanilla JS(with some JQuery), CSS, and HTML. The plan is to integrate the entire website into React, but won’t be complete for awhile and for right now the best plan is to integrate the required react code into the current stack. This would be easy if both the react code and the vanilla JS code didn’t have to communicate with each other, but that unfortunately isn’t the case. In particular, I need to be able to pass some of the data from all the vanilla JS already written into particular React components. I am having trouble in deciding the best way to do this. I found this great article which explains how to do this with a publisher/subscriber method, linked here:</p>
<p><a href="http://www.primaryobjects.com/2017/05/08/integrating-react-with-an-existing-jquery-web-application/" rel="nofollow noreferrer">http://www.primaryobjects.com/2017/05/08/integrating-react-with-an-existing-jquery-web-application/</a></p>
<p>This way seems fine, but it is a little convoluted for my use case and will require some significant code refactoring in order to implement properly. Is there an alternative way to accomplish my goal?</p>
<p>NOTE: The React code uses JSX and not JS.</p>
| 0debug |
C structure to Python Class or python Dict defining : I heard and read that, defining large number of information is easy using Class structure, which is defined in C language(see below C Code). I want to defined similar way using python. I need little favour on code, and I am new learner group of python.
And suggest which way make easy to defined. Is going Dict is fine or Class is best.
Example in C Code below: And I have similar more structure and information
typedef struct
{
U16 ID;
S8 Name[32];
S8 Description[96];
S8 Units[16];
enum eType Type;
F32 Scaling;
F32 Offset;
BOOL Writeable;
}sDataInfo;
/* ID's, Name, Description, Unit, Type, Scaling, Offset, Writable */
sDataInfo data_items[] =
{
0x0202, "dtc_num_of_faults_", "Number of DTCs", "", u8, 1, 0, FALSE,
0x2007, "FlBodyVertLocSel_A_Meas_", "FL Vertical Acceleration", "m/s^2", s16, 0.05, 0, FALSE,
0x2008, "FrBodyVertLocSel_A_Meas_", "FR Vertical Acceleration", "m/s^2", s16, 0.05, 0, FALSE,
0x2022, "RlBodyVertLocSel_A_Meas_", "RL Vertical Acceleration","m/s^2", s16, 0.05, 0, FALSE
}
It is important to know every one the above code can be changed in Python.None of question answered for above in any online chain.
And Expecting some examples aswell.
| 0debug |
I have an insecure API (HTTP) that I'm trying to access and Chrome blocks the data. Any way to work around this? : <p>I'm working with an api that is formatted in XML and it hasn't been secured/received an SSL certificate (HTTPS). Is there a way to bypass this and display the data?</p>
<p>I've tested to make sure it wasn't my code that was the problem. I'm using a simple fetch to output the code in my console. It works properly with other secure api's like the star wars api. </p>
<pre><code>
fetch(Url)
.then(data => {
return data.xml()
})
.then(res => {
console.log(res)
})
I'm just trying to output basic data in either JSON or XML format
</code></pre>
| 0debug |
void vnc_sent_lossy_rect(VncState *vs, int x, int y, int w, int h)
{
int i, j;
w = (x + w) / VNC_STAT_RECT;
h = (y + h) / VNC_STAT_RECT;
x /= VNC_STAT_RECT;
y /= VNC_STAT_RECT;
for (j = y; j <= y + h; j++) {
for (i = x; i <= x + w; i++) {
vs->lossy_rect[j][i] = 1;
}
}
}
| 1threat |
db.execute('SELECT * FROM employees WHERE id = ' + user_input) | 1threat |
static bool virtio_scsi_handle_cmd_req_prepare(VirtIOSCSI *s, VirtIOSCSIReq *req)
{
VirtIOSCSICommon *vs = &s->parent_obj;
SCSIDevice *d;
int rc;
rc = virtio_scsi_parse_req(req, sizeof(VirtIOSCSICmdReq) + vs->cdb_size,
sizeof(VirtIOSCSICmdResp) + vs->sense_size);
if (rc < 0) {
if (rc == -ENOTSUP) {
virtio_scsi_fail_cmd_req(req);
} else {
virtio_scsi_bad_req();
}
return false;
}
d = virtio_scsi_device_find(s, req->req.cmd.lun);
if (!d) {
req->resp.cmd.response = VIRTIO_SCSI_S_BAD_TARGET;
virtio_scsi_complete_cmd_req(req);
return false;
}
virtio_scsi_ctx_check(s, d);
req->sreq = scsi_req_new(d, req->req.cmd.tag,
virtio_scsi_get_lun(req->req.cmd.lun),
req->req.cmd.cdb, req);
if (req->sreq->cmd.mode != SCSI_XFER_NONE
&& (req->sreq->cmd.mode != req->mode ||
req->sreq->cmd.xfer > req->qsgl.size)) {
req->resp.cmd.response = VIRTIO_SCSI_S_OVERRUN;
virtio_scsi_complete_cmd_req(req);
return false;
}
scsi_req_ref(req->sreq);
blk_io_plug(d->conf.blk);
return true;
}
| 1threat |
static int virtio_balloon_device_exit(DeviceState *qdev)
{
VirtIOBalloon *s = VIRTIO_BALLOON(qdev);
VirtIODevice *vdev = VIRTIO_DEVICE(qdev);
balloon_stats_destroy_timer(s);
qemu_remove_balloon_handler(s);
unregister_savevm(qdev, "virtio-balloon", s);
virtio_cleanup(vdev);
return 0;
}
| 1threat |
pagging in bootstrap table : I have a table in bootstrap and it has unlimited entries, I want to give it automatically paging, kindly help me
<div class="col-lg-12">
<div class="table-responsive">
<table class="table table-hover" align="center" border="2" style="text-align:center">
<tr height="">
<td><b>S.NO</b></td>
<td><b>DESRIPTION</b></td>
<td><b>RECIEVE</b></td>
<td><b>SENT</b></td>
<td><b>AVAILABLE BALANCE</b></td>
</tr>
<?php
$i=1;
$query = mysqli_query($con , "select * from income where userid='$searchid' ORDER BY `id` DESC");
if(mysqli_num_rows($query)>0){
while($row = mysqli_fetch_array($query)){?>
<tr>
<td><b><?php echo $i++;?></b></td>
<td><?php echo $row['description'] ; ?></td>
<td><?php echo $row['received'] ; ?></td>
<td><?php echo $row['sent'] ; ?></td>
<td><?php echo $row['current_bal'] ; ?></td>
</tr>
<?php
}}else{?>
<tr>
<td colspan='5'>NO Record Found</td>
</tr>
<?php
}
?>
</table>
</div>
</div> <!-- /.row --> | 0debug |
Python class definition syntax (bracket) : <p>I found most guys said there is no difference with or without bracket in class definition. But my codes output different results for it. </p>
<pre><code>#!/usr/bin/env python
class Tree(object):
def __init__(self):
self.left = None
self.right = None
self.data = None
root = Tree()
root.data = "root"
root.left = Tree()
root.left.data = "left"
root.right = Tree()
root.right.data = "right"
print(root.left.data)
Output: left
While
#!/usr/bin/env python
class Tree:
def __init__(self):
self.left = None
self.right = None
self.data = None
root = Tree
root.data = "root"
root.left = Tree
root.left.data = "left"
root.right = Tree
root.right.data = "right"
print(root.left.data)
Output : right
</code></pre>
<p>So what is the problem behind this </p>
| 0debug |
How to import an Excel file to an HTML page : <p>first of all let me tell you that im sorry for my bad english.
i'm working on a project(HTML5,JS,CSS3) and i have to import excel file to a table of HTML.So if u can give me some help ill appreciate that .ty anyway </p>
| 0debug |
Duplicate GlobalKey detected in widget tree : <p>I am running into a <code>globalKey</code> error after I navigate from <code>Screen A</code> to <code>Screen B</code> and click a "Cancel" button to go back to <code>Screen A</code>.</p>
<p>It seems like the issue is that <code>Screen B</code> is either </p>
<ul>
<li>A) Not being disposed of correctly</li>
<li>B) Is not doing something that it otherwise could</li>
</ul>
<p>And I don't actually know:</p>
<ul>
<li>What bad things are happening if I just remove the use of a <code>globalKey</code>? (as to get a better understanding of the fundamentals)</li>
<li>How can I correctly resolve this issue?</li>
</ul>
<p>StatefulWidget documentation states:<a href="https://docs.flutter.io/flutter/widgets/StatefulWidget-class.html" rel="noreferrer">enter link description here</a></p>
<blockquote>
<p>A StatefulWidget keeps the same State object when moving from one
location in the tree to another if its creator used a GlobalKey for
its key. Because a widget with a GlobalKey can be used in at most one
location in the tree, a widget that uses a GlobalKey has at most one
associated element. <strong>The framework takes advantage of this property
when moving a widget with a global key from one location in the tree
to another by grafting the (unique) subtree associated with that
widget</strong> from the old location to the new location (instead of
recreating the subtree at the new location). The State objects
associated with StatefulWidget are grafted along with the rest of the
subtree, which means the State object is reused (instead of being
recreated) in the new location. <strong>However, in order to be eligible for
grafting, the widget must be inserted into the new location in the
same animation frame</strong> in which it was removed from the old location.</p>
</blockquote>
<p>Console Error Output:</p>
<pre><code>══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following assertion was thrown while finalizing the widget tree:
Duplicate GlobalKey detected in widget tree.
The following GlobalKey was specified multiple times in the widget tree. This will lead to parts of
the widget tree being truncated unexpectedly, because the second time a key is seen, the previous
instance is moved to the new location. The key was:
- [LabeledGlobalKey<FormFieldState<String>>#3c76d]
This was determined by noticing that after the widget with the above global key was moved out of its
previous parent, that previous parent never updated during this frame, meaning that it either did
not update at all or updated before the widget was moved, in either case implying that it still
thinks that it should have a child with that global key.
The specific parent that did not update after having one or more children forcibly removed due to
GlobalKey reparenting is:
- Column(direction: vertical, mainAxisAlignment: start, crossAxisAlignment: center, renderObject:
RenderFlex#7595c relayoutBoundary=up1 NEEDS-PAINT)
A GlobalKey can only be specified on one widget at a time in the widget tree.
</code></pre>
<p>So this part of the error output:</p>
<blockquote>
<p>previous parent never updated during this frame, meaning that it
either did not update at all or updated before the widget was moved</p>
</blockquote>
<p>makes me think there was some opportunity for my old Stateful widget to do something (either reposition itself or release something as to be disposed correctly.</p>
<p>This seems to be failing in <code>framework.dart</code> on <code>assert(_children.contains(child))</code>:</p>
<pre><code> @override
void forgetChild(Element child) {
assert(_children.contains(child));
assert(!_forgottenChildren.contains(child));
_forgottenChildren.add(child);
}
</code></pre>
| 0debug |
How to restore default layout for intellij Run/Debug window/tabs? : <p>I accidentally closed the Debugger tab of the Run/Debug panel. Then while attempting to restore it other changes were made that I would like to revert. How to get back to square one?</p>
<p><a href="https://i.stack.imgur.com/SyQLD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SyQLD.png" alt="enter image description here"></a></p>
| 0debug |
DISAS_INSN(cas2w)
{
uint16_t ext1, ext2;
TCGv addr1, addr2;
TCGv regs;
ext1 = read_im16(env, s);
if (ext1 & 0x8000) {
addr1 = AREG(ext1, 12);
} else {
addr1 = DREG(ext1, 12);
}
ext2 = read_im16(env, s);
if (ext2 & 0x8000) {
addr2 = AREG(ext2, 12);
} else {
addr2 = DREG(ext2, 12);
}
regs = tcg_const_i32(REG(ext2, 6) |
(REG(ext1, 6) << 3) |
(REG(ext2, 0) << 6) |
(REG(ext1, 0) << 9));
gen_helper_cas2w(cpu_env, regs, addr1, addr2);
tcg_temp_free(regs);
s->cc_op = CC_OP_CMPW;
s->cc_op_synced = 1;
}
| 1threat |
How to append head of a list to the tail of same list? : <p>Example: List(red,blue,green,black).I want to append head of this list to the tail of same list.So after first iteration my list will be List(blue,green,black,red),after that List(green,black,red,blue) and so on.</p>
| 0debug |
static void gen_vfp_msr(TCGv tmp)
{
tcg_gen_mov_i32(cpu_F0s, tmp);
dead_tmp(tmp);
}
| 1threat |
How can I pass a string to another jsp page? What's wrong in mysql query to select a table, String query ="select * from " + table + ""; : Why mysql query string query ="select * from " + table + "";` is not working the table name is coming from another jsp page.
And why session. setAttribute ("", "table");` is not working to import string from jsp to jsp?
I have two jsp file in my code one is for selection of table for username and password to get login the file name is statement.jsp and other file statement is for showing data in a table that is selected in statement3.jsp. I want to use table string in another jsp page to show that table.
**error**
String query ="select * from " + table + ""; //for selection of table
session.setAttribute("", "table"); //To pass String table from statement.jsp to statement3.jsp to show table.
**[![enter image description here][1]][1]statement3.jsp**
<%
ResultSet rs = null;
session.setAttribute("", "table");
String query ="select * from " + table + "";
rs=st.executeQuery(query);
%>
-------------------------------------
**statement.jsp**
<%
ResultSet rs = null;
String name=request.getParameter("username");
String abc=request.getParameter("password");
String gender = request.getParameter("gender");
if (gender != null) {
String table = gender.equals("teacher") ? "teacher2" : "student";
out.println(table);
String query ="select * from " + table + " where username='"+name+"' AND password='"+abc+"'";
rs=st.executeQuery(query);
out.println(rs);
if(rs.next())
{
response.sendRedirect("statement3.jsp");
}
else
{
response.sendRedirect("index.jsp");
}}
%>
`Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)`
[1]: http://i.stack.imgur.com/1zAt8.jpg | 0debug |
Python itertools.combinations : Itertool.combination code gives me all combination for a target value
I have an array
a=[1,1,2,-2,-4] target =0
output I get from:
Itertools.combination is: [(2, -2), (1, 1, -2), (1, 1, 2, -4)].
But the concern is:- Once the number is used, it should not get repeated.
Required Output:- [(2,-2)] #As 2,-2 pair nets to 0. Code should not use 2 again to sum:1,1,2 and net that off with -4. [I dont want numbers to get repeated once it is used in one of the pair.]
# Reference code:-
import itertools
import numpy as np
def subset_sum(target, numbers):
array_num=np.array(numbers)
for size in xrange(1, len(array_num) + 1):
for c in itertools.combinations(array_num, size):
if sum(c) == target:
temp_var.append(c)
print "Length of array is ",len(array_num)
return temp_var
numbers=[1,1,2,-2,-4]
target=0
output=subset_sum(numbers)
print output
| 0debug |
Im getting "division by zero" error in python and I dont have a clue why : I dont know why but, python says that ```( (x1[0]*(len(x1)-1)) + (x2[0]*(len(x2)-1)) + (x3[0]*(len(x3)-1)))``` equals 0, which shouldnt in my opinion. I've tested that code, separately, without it being a divisor, and it didnt output 0 value.
```
def av(x):
c = 0
alist = x
alist.pop(0)
for a in alist:
c += a*x[0]
return c
average = lambda x1,x2,x3: (av(x1) + av(x2) + av(x3))/( (x1[0]*(len(x1)-1)) + (x2[0]*(len(x2)-1)) + (x3[0]*(len(x3)-1)))
print(average([0,0],[1,4],[1,5]))``` | 0debug |
void qemu_system_powerdown(void)
{
if(pm_state->pmen & PWRBTN_EN) {
pm_state->pmsts |= PWRBTN_EN;
pm_update_sci(pm_state);
}
}
| 1threat |
static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
Error **errp)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
MachineClass *mc = MACHINE_GET_CLASS(spapr);
sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
sPAPRCPUCore *core = SPAPR_CPU_CORE(OBJECT(dev));
CPUCore *cc = CPU_CORE(dev);
CPUState *cs = CPU(core->threads);
sPAPRDRConnector *drc;
Error *local_err = NULL;
void *fdt = NULL;
int fdt_offset = 0;
int smt = kvmppc_smt_threads();
CPUArchId *core_slot;
int index;
bool hotplugged = spapr_drc_hotplugged(dev);
core_slot = spapr_find_cpu_slot(MACHINE(hotplug_dev), cc->core_id, &index);
if (!core_slot) {
error_setg(errp, "Unable to find CPU core with core-id: %d",
cc->core_id);
return;
}
drc = spapr_drc_by_id(TYPE_SPAPR_DRC_CPU, index * smt);
g_assert(drc || !mc->has_hotpluggable_cpus);
fdt = spapr_populate_hotplug_cpu_dt(cs, &fdt_offset, spapr);
if (drc) {
spapr_drc_attach(drc, dev, fdt, fdt_offset, &local_err);
if (local_err) {
g_free(fdt);
error_propagate(errp, local_err);
return;
}
if (hotplugged) {
spapr_hotplug_req_add_by_index(drc);
} else {
spapr_drc_reset(drc);
}
}
core_slot->cpu = OBJECT(dev);
if (smc->pre_2_10_has_unused_icps) {
sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(OBJECT(cc));
const char *typename = object_class_get_name(scc->cpu_class);
size_t size = object_type_get_instance_size(typename);
int i;
for (i = 0; i < cc->nr_threads; i++) {
sPAPRCPUCore *sc = SPAPR_CPU_CORE(dev);
void *obj = sc->threads + i * size;
cs = CPU(obj);
pre_2_10_vmstate_unregister_dummy_icp(cs->cpu_index);
}
}
}
| 1threat |
Passing Array to Python Spark Lit Function : <p>Let's say I have a numpy array a that contains the numbers 1-10. So a is [1 2 3 4 5 6 7 8 9 10].</p>
<p>Now, I also have a Python Spark dataframe to which I want to add my numpy array a. I figure that a column of literals will do the job. So I do the following:</p>
<pre><code>df = df.withColumn("NewColumn", F.lit(a))
</code></pre>
<p>This doesn't work. The error is "Unsupported literal type class java.util.ArrayList".</p>
<p>Now, if I try just one element of the array, as follows, it works.</p>
<pre><code>df = df.withColumn("NewColumn", F.lit(a[0]))
</code></pre>
<p>Is there a way I can do what I'm trying? I've been working on the task I want to complete for days and this is the closest I've come to finishing it. I have looked at all related Stack Overflow questions but I didn't get quite the answer I was looking for. Any help is appreciated. Thanks.</p>
| 0debug |
static int vmdk_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
char *buf;
int ret;
BDRVVmdkState *s = bs->opaque;
uint32_t magic;
Error *local_err = NULL;
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
false, errp);
if (!bs->file) {
return -EINVAL;
}
buf = vmdk_read_desc(bs->file, 0, errp);
if (!buf) {
return -EINVAL;
}
magic = ldl_be_p(buf);
switch (magic) {
case VMDK3_MAGIC:
case VMDK4_MAGIC:
ret = vmdk_open_sparse(bs, bs->file, flags, buf, options,
errp);
s->desc_offset = 0x200;
break;
default:
ret = vmdk_open_desc_file(bs, flags, buf, options, errp);
break;
}
if (ret) {
goto fail;
}
ret = vmdk_parent_open(bs);
if (ret) {
goto fail;
}
s->cid = vmdk_read_cid(bs, 0);
s->parent_cid = vmdk_read_cid(bs, 1);
qemu_co_mutex_init(&s->lock);
error_setg(&s->migration_blocker, "The vmdk format used by node '%s' "
"does not support live migration",
bdrv_get_device_or_node_name(bs));
ret = migrate_add_blocker(s->migration_blocker, &local_err);
if (local_err) {
error_propagate(errp, local_err);
error_free(s->migration_blocker);
goto fail;
}
g_free(buf);
return 0;
fail:
g_free(buf);
g_free(s->create_type);
s->create_type = NULL;
vmdk_free_extents(bs);
return ret;
}
| 1threat |
static void libschroedinger_flush(AVCodecContext *avctx)
{
SchroDecoderParams *p_schro_params = avctx->priv_data;
ff_schro_queue_free(&p_schro_params->dec_frame_queue,
libschroedinger_decode_frame_free);
ff_schro_queue_init(&p_schro_params->dec_frame_queue);
schro_decoder_reset(p_schro_params->decoder);
p_schro_params->eos_pulled = 0;
p_schro_params->eos_signalled = 0;
}
| 1threat |
static void FUNC(hevc_loop_filter_chroma)(uint8_t *_pix, ptrdiff_t _xstride,
ptrdiff_t _ystride, int *_tc,
uint8_t *_no_p, uint8_t *_no_q)
{
int d, j, no_p, no_q;
pixel *pix = (pixel *)_pix;
ptrdiff_t xstride = _xstride / sizeof(pixel);
ptrdiff_t ystride = _ystride / sizeof(pixel);
for (j = 0; j < 2; j++) {
const int tc = _tc[j] << (BIT_DEPTH - 8);
if (tc <= 0) {
pix += 4 * ystride;
continue;
}
no_p = _no_p[j];
no_q = _no_q[j];
for (d = 0; d < 4; d++) {
int delta0;
const int p1 = P1;
const int p0 = P0;
const int q0 = Q0;
const int q1 = Q1;
delta0 = av_clip((((q0 - p0) << 2) + p1 - q1 + 4) >> 3, -tc, tc);
if (!no_p)
P0 = av_clip_pixel(p0 + delta0);
if (!no_q)
Q0 = av_clip_pixel(q0 - delta0);
pix += ystride;
}
}
}
| 1threat |
def extract_symmetric(test_list):
temp = set(test_list) & {(b, a) for a, b in test_list}
res = {(a, b) for a, b in temp if a < b}
return (res) | 0debug |
Mylistview cuase FAILED BINDER TRANSACTION Please help me with my graduation projet : I'm making a ListView with text and Images every thing is okay but when i click on one of the list item the application terminated and it shows E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!
E/AndroidRuntime: Error reporting crash
android.os.TransactionTooLargeException
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:496)
at android.app.ActivityManagerProxy.handleApplicationCrash(ActivityManagerNative.java:4716)
at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:95)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
public class RowItem {
private String title ;
private String descreption;
private int pic_id;
public RowItem(String title, String descreption, int pic_id) {
this.title = title;
this.descreption = descreption;
this.pic_id = pic_id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescreption() {
return descreption;
}
public void setDescreption(String descreption) {
this.descreption = descreption;
}
public int getPic_id() {
return pic_id;
}
public void setPic_id(int pic_id) {
this.pic_id = pic_id;
}
}
public class CustomAdapter extends BaseAdapter{
Context context;
List<RowItem> rowItems;
public CustomAdapter(Context context, List<RowItem> rowItems) {
this.context = context;
this.rowItems = rowItems;
}
@Override
public int getCount() {
return rowItems.size();
}
@Override
public Object getItem(int position) {
return rowItems.get(position);
}
@Override
public long getItemId(int position) {
return rowItems.indexOf(getItemId(position));
}
private class ViewHolder{
ImageView imageView ;
TextView Title;
TextView descrip;
}
@Override
public View getView( int position, View convertView, ViewGroup parent) {
ViewHolder holder ;
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView==null){
convertView = inflater.inflate(R.layout.list_item,null);
holder=new ViewHolder();
holder.Title= (TextView)convertView.findViewById(R.id.title);
holder.imageView=(ImageView)convertView.findViewById(R.id.pic1);
holder.descrip=(TextView)convertView.findViewById(R.id.descrption);
convertView.setTag(holder);
}
else {
holder = (ViewHolder) convertView.getTag();}
RowItem row_po = rowItems.get(position);
holder.imageView.setImageResource(row_po.getPic_id());
holder.Title.setText(row_po.getTitle());
holder.descrip.setText(row_po.getDescreption());
return convertView;
}
}
public class ExploreActivity extends Activity {
String[] Title;
TypedArray pics;
String[] description;
List<RowItem> rowItems;
ListView mylistview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_explore);
poplatelistview();
mylistview = (ListView) findViewById(R.id.list);
CustomAdapter adapter = new CustomAdapter(this, rowItems);
mylistview.setAdapter(adapter);
rgistercalback();
}
private void poplatelistview() {
rowItems = new ArrayList<RowItem>();
Title = getResources().getStringArray(R.array.Title);
pics = getResources().obtainTypedArray(R.array.pics);
description = getResources().getStringArray(R.array.Descrpsions);
for (int i = 0; i < Title.length; i++) {
RowItem item = new RowItem(Title[i], description[i], pics.getResourceId(i, -1));
rowItems.add(item);
}
}
private void rgistercalback() {
ListView list = (ListView) findViewById(R.id.list);
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String title = rowItems.get(position).getTitle();
Toast.makeText(getApplicationContext(),""+title,Toast.LENGTH_LONG).show();
}
});
}
}
| 0debug |
import re
def string_literals(patterns,text):
for pattern in patterns:
if re.search(pattern, text):
return ('Matched!')
else:
return ('Not Matched!') | 0debug |
Why does a hash value change while hashing from different file formats? : <p>I have observed that when I hash data from a *.txt file and a *.docx file the both hash generated are different even though the data is same in both the file.
Why does this happen?</p>
| 0debug |
How to properly implement the Equatable protocol in a class hierarchy? : <p>I'm trying to implement the <code>==</code> operator (from <code>Equatable</code>) in a base class and its subclasses in Swift 3. All of the classes will only be used in Swift so I do not want to involve <code>NSObject</code> or the <code>NSCopying</code> protocol.</p>
<p>I started with a base class and a subclass:</p>
<pre><code>class Base {
var x : Int
}
class Subclass : Base {
var y : String
}
</code></pre>
<p>Now I wanted to add <code>Equatable</code> and the <code>==</code> operator to <code>Base</code>. Seems simple enough. Copy the <code>==</code> operator signature from the documentation:</p>
<pre><code>class Base : Equatable {
var x : Int
static func == (lhs: Base, rhs: Base) -> Bool {
return lhs.x == rhs.x
}
}
</code></pre>
<p>So far so good. Now for the subclass:</p>
<pre><code>class Subclass : Base {
static override func == (lhs: Base, rhs: Base) -> Bool {
return true
}
}
</code></pre>
<p>But this results in an error:</p>
<blockquote>
<p>Operator function overrides a 'final' operator function</p>
</blockquote>
<p>OK. After some research (still learning Swift 3) I learn that <code>static</code> can be replaced with <code>class</code> to indicate the type method can be overridden.</p>
<p>So I attempt to change <code>static</code> to <code>class</code> in <code>Base</code>:</p>
<pre><code>class Base : Equatable {
var x : Int
class func == (lhs: Base, rhs: Base) -> Bool {
return lhs.x == rhs.x
}
}
</code></pre>
<p>But that results in a new error:</p>
<blockquote>
<p>Operator '==' declared in non-final class 'Base' must be 'final'</p>
</blockquote>
<p>Ugh. This is far more complicated than it should be.</p>
<p>How do I implement the <code>Equatable</code> protocol and the <code>==</code> operator properly in a base class and a subclass?</p>
| 0debug |
char pointer value reassignment : <pre><code>#include<stdio.h>
#include<string.h>
int main()
{
int i=0;
char *b,*a="a(a+b))";
b=a;
printf("%s",b);
printf("%d",a);
while(a[i]!='\0')
{
a++;
i++;
}
*a="(a+b)";
printf("%s",a);
}
</code></pre>
<p>initialy i am assigning a value to that char pointer
after moving it to the end using null comparision
can i again assign a value to that char pointer?
Can i do like this?
what is wrong here? can anyone please explain??</p>
| 0debug |
static ram_addr_t find_ram_offset(ram_addr_t size)
{
RAMBlock *block, *next_block;
ram_addr_t offset, mingap = ULONG_MAX;
if (QLIST_EMPTY(&ram_list.blocks))
return 0;
QLIST_FOREACH(block, &ram_list.blocks, next) {
ram_addr_t end, next = ULONG_MAX;
end = block->offset + block->length;
QLIST_FOREACH(next_block, &ram_list.blocks, next) {
if (next_block->offset >= end) {
next = MIN(next, next_block->offset);
}
}
if (next - end >= size && next - end < mingap) {
offset = end;
mingap = next - end;
}
}
return offset;
}
| 1threat |
static void drive_backup_abort(BlkActionState *common)
{
DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common);
BlockDriverState *bs = state->bs;
if (bs && bs->job && bs->job == state->job) {
block_job_cancel_sync(bs->job);
}
}
| 1threat |
regex not working for php form validation : <p>Usernames on my website should only contain A-Z,a-z,0-9. No spaces or special characters.</p>
<p>I have the following php code in my register form however when I input a username which contains only letters it outputs the error, any help?:</p>
<pre><code>if (!preg_match('/[^a-zA-Z0-9]+/gm', $_POST["userName"])) {
$output = json_encode(
array(
'type' => 'error',
'text' => 'Your username must not contain any spaces or special characters.'
));
die($output);
}
</code></pre>
| 0debug |
try exception inside a for loop : i trying to build a for loop with an exception, this is the code:
for( $i = 1; $i <= $contxf; $i++) {
try{
if($i = $icheck) {
throw new Exception('Current Page');
}
echo '<a href="?pag='.$i.'">'. $i .'</a> ';
} catch (Exception $cp) {
echo $i;
$i = $i + 1;
}
But with this code the loop don't continue to add 1 to $i
| 0debug |
Using combo box in c# : <p>I have prepared a program about grocery management. In one place I have to put product category and product brand. Product brands are in one combo box and categories are in another combo box. I want to change the brand combo box according to the text display in category combo box. Eg: if you choose chocolates in category combo box, the brand combo box shows "Mars"," Snickers" and so on. Please help me. I want the c# code for this work. Thank you. I am Sandu.</p>
| 0debug |
how to access data from inside a method : <p>I'm new to vue.js. I'm starting to migrate my angularjs app.
I'm using vue cli to generate a new simple-webpack project.
This creates a new webpack+vueLoader project.
Everything went smoothly but now I have an issue.
on my @click event I want to change my data but I can't access the object.
'this' is not the data instance.</p>
<p>What am I missing here?</p>
<pre><code><template>
<input type="radio" name="account-type" @click="setAccountType(item.id)"/><span>{{item.name}}</span>
</template>
<script>
export default {
data() {
return { accountType: null
},
methods: { setAccountType: (typeId) => this.accountType = typeId
}
</script>
</code></pre>
<p>this is not the data instance as expected and thus ui not updated.
In vuejs doc i can see just addressing this is sufficient while in a method:
<a href="https://vuejs.org/v2/guide/events.html#Method-Event-Handlers" rel="noreferrer">vue js doc</a></p>
<p>Any help is appreciated.</p>
<p>Kind regards.</p>
| 0debug |
no overload for method get touch takes 0 arguments : <p>code:</p>
<pre><code>void Update(){
if (Application.platform == RuntimePlatform.Android) {
foreach (Touch touch in Input.GetTouch()) {
if (touch.fingerId == 0) {
if (!GameManager.instance.isPlaying) {
GameUIManager.instance.showStartGameCanvas (false);
GameManager.instance.isPlaying = true;
myRiggidBody.constraints = RigidbodyConstraints2D.FreezePositionX;
}
isJump = true;
}
}
}
</code></pre>
<p>now comes the error "no overload for method get touch takes 0 arguments"</p>
<p>need help ;)</p>
| 0debug |
Selecting only numeric/string columns names from a Spark DF in pyspark : <p>I have a SparkDataFrame in pyspark (2.1.0) and I am looking to get the names of numeric columns only or string columns only.</p>
<p>For example, this is the Schema of my DF:</p>
<pre><code>root
|-- Gender: string (nullable = true)
|-- SeniorCitizen: string (nullable = true)
|-- MonthlyCharges: double (nullable = true)
|-- TotalCharges: double (nullable = true)
|-- Churn: string (nullable = true)
</code></pre>
<p>This is what I need:</p>
<pre><code>num_cols = [MonthlyCharges, TotalCharges]
str_cols = [Gender, SeniorCitizen, Churn]
</code></pre>
<p>How can I make it? Thank you!</p>
| 0debug |
How can I create a new file with a simple way in spacemacs? : <p>Currently, I know that I can create a new file with the following ways:</p>
<ul>
<li><code>c</code> key in Neotree</li>
<li><code>SPC '</code> in shell layer, and use the <code>touch xxx</code> command</li>
</ul>
<p>I am wondering whether there is a simple way (something like <code>SPC f xxx</code>) or not.</p>
<p>Thanks.</p>
| 0debug |
static void setup_frame(int sig, struct target_sigaction *ka,
target_sigset_t *set, CPUSH4State *regs)
{
struct target_sigframe *frame;
abi_ulong frame_addr;
int i;
int err = 0;
int signal;
frame_addr = get_sigframe(ka, regs->gregs[15], sizeof(*frame));
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
signal = current_exec_domain_sig(sig);
err |= setup_sigcontext(&frame->sc, regs, set->sig[0]);
for (i = 0; i < TARGET_NSIG_WORDS - 1; i++) {
__put_user(set->sig[i + 1], &frame->extramask[i]);
}
if (ka->sa_flags & TARGET_SA_RESTORER) {
regs->pr = (unsigned long) ka->sa_restorer;
} else {
__put_user(MOVW(2), &frame->retcode[0]);
__put_user(TRAP_NOARG, &frame->retcode[1]);
__put_user((TARGET_NR_sigreturn), &frame->retcode[2]);
regs->pr = (unsigned long) frame->retcode;
}
if (err)
goto give_sigsegv;
regs->gregs[15] = frame_addr;
regs->gregs[4] = signal;
regs->gregs[5] = 0;
regs->gregs[6] = frame_addr += offsetof(typeof(*frame), sc);
regs->pc = (unsigned long) ka->_sa_handler;
unlock_user_struct(frame, frame_addr, 1);
return;
give_sigsegv:
unlock_user_struct(frame, frame_addr, 1);
force_sig(TARGET_SIGSEGV);
}
| 1threat |
pythonic dictionary counter? : <p>Easiest explained by example:</p>
<pre><code>events = ['foo', 'bar', 'biz', 'foo', 'foo']
events_counter = {}
for event in events:
if event not in events_counter: # {
events_counter[event] = 1 # {
else: # {
events_counter[event] += 1 # {
print events_counter
# {'biz': 1, 'foo': 3, 'bar': 1}
</code></pre>
<p>Is there a way to implement the highlighted code in a more pythonic way? I feel like there should be a built-in function, i.e:</p>
<pre><code>events_counter.count_up(event)
</code></pre>
<p>And yes, I do know I could just write my own procedure, thanks.</p>
| 0debug |
I Want to move a div to another div on a specific time frame like on 7 am in the morning the code runs and move a div to other div : here is my code
<script type="text/javascript">
jQuery(document).ready(function(){
var tomorrow_sec = jQuery("#day").html();
jQuery("#day-dest").html(tomorrow_sec);
jQuery("#day").html(" ");
});
</script> | 0debug |
inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, uint8_t *src1, uint8_t *src2,
int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter,
int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode,
int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
int32_t *mmx2FilterPos, uint8_t *pal)
{
if (srcFormat==PIX_FMT_YUYV422)
{
RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
else if (srcFormat==PIX_FMT_UYVY422)
{
RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
else if (srcFormat==PIX_FMT_RGB32)
{
RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
else if (srcFormat==PIX_FMT_RGB32_1)
{
RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
else if (srcFormat==PIX_FMT_BGR24)
{
RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
else if (srcFormat==PIX_FMT_BGR565)
{
RENAME(bgr16ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
else if (srcFormat==PIX_FMT_BGR555)
{
RENAME(bgr15ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
else if (srcFormat==PIX_FMT_BGR32)
{
RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
else if (srcFormat==PIX_FMT_BGR32_1)
{
RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
else if (srcFormat==PIX_FMT_RGB24)
{
RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
else if (srcFormat==PIX_FMT_RGB565)
{
RENAME(rgb16ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
else if (srcFormat==PIX_FMT_RGB555)
{
RENAME(rgb15ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
else if (isGray(srcFormat))
{
return;
}
else if (srcFormat==PIX_FMT_RGB8 || srcFormat==PIX_FMT_BGR8 || srcFormat==PIX_FMT_PAL8 || srcFormat==PIX_FMT_BGR4_BYTE || srcFormat==PIX_FMT_RGB4_BYTE)
{
RENAME(palToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, (uint32_t*)pal);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
#ifdef HAVE_MMX
if (!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed))
#else
if (!(flags&SWS_FAST_BILINEAR))
#endif
{
RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
RENAME(hScale)(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
}
else
{
#if defined(ARCH_X86)
#ifdef HAVE_MMX2
int i;
#if defined(PIC)
uint64_t ebxsave __attribute__((aligned(8)));
#endif
if (canMMX2BeUsed)
{
asm volatile(
#if defined(PIC)
"mov %%"REG_b", %6 \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
#ifdef ARCH_X86_64
#define FUNNY_UV_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"REG_b", %%"REG_a"), %%esi \n\t"\
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#else
#define FUNNY_UV_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"REG_b", %%"REG_a"), %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#endif
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
"xor %%"REG_a", %%"REG_a" \n\t"
"mov %5, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"add $"AV_STRINGIFY(VOF)", %%"REG_D" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
FUNNY_UV_CODE
#if defined(PIC)
"mov %6, %%"REG_b" \n\t"
#endif
:: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos),
"m" (funnyUVCode), "m" (src2)
#if defined(PIC)
,"m" (ebxsave)
#endif
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
#if !defined(PIC)
,"%"REG_b
#endif
);
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--)
{
dst[i] = src1[srcW-1]*128;
dst[i+VOFW] = src2[srcW-1]*128;
}
}
else
{
#endif
long xInc_shr16 = (long) (xInc >> 16);
uint16_t xInc_mask = xInc & 0xffff;
asm volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
"xor %%"REG_d", %%"REG_d" \n\t"
"xorl %%ecx, %%ecx \n\t"
ASMALIGN(4)
"1: \n\t"
"mov %0, %%"REG_S" \n\t"
"movzbl (%%"REG_S", %%"REG_d"), %%edi \n\t"
"movzbl 1(%%"REG_S", %%"REG_d"), %%esi \n\t"
"subl %%edi, %%esi \n\t" - src[xx]
"imull %%ecx, %%esi \n\t"
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t"
"movzbl (%5, %%"REG_d"), %%edi \n\t"
"movzbl 1(%5, %%"REG_d"), %%esi \n\t"
"subl %%edi, %%esi \n\t" - src[xx]
"imull %%ecx, %%esi \n\t"
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, "AV_STRINGIFY(VOF)"(%%"REG_D", %%"REG_a", 2) \n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_d" \n\t"
"add $1, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
#if defined(ARCH_X86_64) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
:: "m" (src1), "m" (dst), "g" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#endif
"r" (src2)
: "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi"
);
#ifdef HAVE_MMX2
}
#endif
#else
int i;
unsigned int xpos=0;
for (i=0;i<dstWidth;i++)
{
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst[i+VOFW]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
xpos+=xInc;
}
#endif
}
if(c->srcRange != c->dstRange && !(isRGB(c->dstFormat) || isBGR(c->dstFormat))){
int i;
if(c->srcRange){
for (i=0; i<dstWidth; i++){
dst[i ]= (dst[i ]*1799 + 4081085)>>11;
dst[i+VOFW]= (dst[i+VOFW]*1799 + 4081085)>>11;
}
}else{
for (i=0; i<dstWidth; i++){
dst[i ]= (dst[i ]*4663 - 9289992)>>12;
dst[i+VOFW]= (dst[i+VOFW]*4663 - 9289992)>>12;
}
}
}
}
| 1threat |
static void timer_enable(struct xlx_timer *xt)
{
uint64_t count;
D(printf("%s timer=%d down=%d\n", __func__,
xt->nr, xt->regs[R_TCSR] & TCSR_UDT));
ptimer_stop(xt->ptimer);
if (xt->regs[R_TCSR] & TCSR_UDT)
count = xt->regs[R_TLR];
else
count = ~0 - xt->regs[R_TLR];
ptimer_set_count(xt->ptimer, count);
ptimer_run(xt->ptimer, 1);
}
| 1threat |
void handle_vm86_fault(CPUX86State *env)
{
TaskState *ts = env->opaque;
uint8_t *csp, *pc, *ssp;
unsigned int ip, sp, newflags, newip, newcs, opcode, intno;
int data32, pref_done;
csp = (uint8_t *)(env->segs[R_CS] << 4);
ip = env->eip & 0xffff;
pc = csp + ip;
ssp = (uint8_t *)(env->segs[R_SS] << 4);
sp = env->regs[R_ESP] & 0xffff;
#if defined(DEBUG_VM86)
fprintf(logfile, "VM86 exception %04x:%08x %02x %02x\n",
env->segs[R_CS], env->eip, pc[0], pc[1]);
#endif
data32 = 0;
pref_done = 0;
do {
opcode = csp[ip];
ADD16(ip, 1);
switch (opcode) {
case 0x66: data32=1; break;
case 0x67: break;
case 0x2e: break;
case 0x3e: break;
case 0x26: break;
case 0x36: break;
case 0x65: break;
case 0x64: break;
case 0xf2: break;
case 0xf3: break;
default: pref_done = 1;
}
} while (!pref_done);
switch(opcode) {
case 0x9c:
ADD16(env->eip, 2);
if (data32) {
vm_putl(ssp, sp - 4, get_vflags(env));
ADD16(env->regs[R_ESP], -4);
} else {
vm_putw(ssp, sp - 2, get_vflags(env));
ADD16(env->regs[R_ESP], -2);
}
env->eip = ip;
VM86_FAULT_RETURN;
case 0x9d:
if (data32) {
newflags = vm_getl(ssp, sp);
ADD16(env->regs[R_ESP], 4);
} else {
newflags = vm_getw(ssp, sp);
ADD16(env->regs[R_ESP], 2);
}
env->eip = ip;
CHECK_IF_IN_TRAP();
if (data32) {
if (set_vflags_long(newflags, env))
return;
} else {
if (set_vflags_short(newflags, env))
return;
}
VM86_FAULT_RETURN;
case 0xcd:
intno = csp[ip];
ADD16(ip, 1);
env->eip = ip;
if (ts->vm86plus.vm86plus.flags & TARGET_vm86dbg_active) {
if ( (ts->vm86plus.vm86plus.vm86dbg_intxxtab[intno >> 3] >>
(intno &7)) & 1) {
return_to_32bit(env, TARGET_VM86_INTx + (intno << 8));
return;
}
}
do_int(env, intno);
break;
case 0xcf:
if (data32) {
newip = vm_getl(ssp, sp) & 0xffff;
newcs = vm_getl(ssp, sp + 4) & 0xffff;
newflags = vm_getl(ssp, sp + 8);
ADD16(env->regs[R_ESP], 12);
} else {
newip = vm_getw(ssp, sp);
newcs = vm_getw(ssp, sp + 2);
newflags = vm_getw(ssp, sp + 4);
ADD16(env->regs[R_ESP], 6);
}
env->eip = newip;
cpu_x86_load_seg(env, R_CS, newcs);
CHECK_IF_IN_TRAP();
if (data32) {
if (set_vflags_long(newflags, env))
return;
} else {
if (set_vflags_short(newflags, env))
return;
}
VM86_FAULT_RETURN;
case 0xfa:
env->eip = ip;
clear_IF(env);
VM86_FAULT_RETURN;
case 0xfb:
env->eip = ip;
if (set_IF(env))
return;
VM86_FAULT_RETURN;
default:
return_to_32bit(env, TARGET_VM86_UNKNOWN);
break;
}
}
| 1threat |
static void sclp_execute(SCLPDevice *sclp, SCCB *sccb, uint32_t code)
{
SCLPDeviceClass *sclp_c = SCLP_GET_CLASS(sclp);
SCLPEventFacility *ef = sclp->event_facility;
SCLPEventFacilityClass *efc = EVENT_FACILITY_GET_CLASS(ef);
switch (code & SCLP_CMD_CODE_MASK) {
case SCLP_CMDW_READ_SCP_INFO:
case SCLP_CMDW_READ_SCP_INFO_FORCED:
sclp_c->read_SCP_info(sclp, sccb);
break;
case SCLP_CMDW_READ_CPU_INFO:
sclp_c->read_cpu_info(sclp, sccb);
break;
case SCLP_READ_STORAGE_ELEMENT_INFO:
if (code & 0xff00) {
sclp_c->read_storage_element1_info(sclp, sccb);
} else {
sclp_c->read_storage_element0_info(sclp, sccb);
}
break;
case SCLP_ATTACH_STORAGE_ELEMENT:
sclp_c->attach_storage_element(sclp, sccb, (code & 0xff00) >> 8);
break;
case SCLP_ASSIGN_STORAGE:
sclp_c->assign_storage(sclp, sccb);
break;
case SCLP_UNASSIGN_STORAGE:
sclp_c->unassign_storage(sclp, sccb);
break;
case SCLP_CMDW_CONFIGURE_PCI:
s390_pci_sclp_configure(sccb);
break;
case SCLP_CMDW_DECONFIGURE_PCI:
s390_pci_sclp_deconfigure(sccb);
break;
default:
efc->command_handler(ef, sccb, code);
break;
}
}
| 1threat |
How to reference data variable from another data variable in Vue 2? : <p>I have this in vue data:</p>
<pre><code>data() {
return {
names: [],
length: names.length,
}
</code></pre>
<p>But this does not work as RefereneError ( names is undefined ) is thrown. I used this.names but makes no difference.</p>
| 0debug |
taking length of predefined string vs getting one from input : <p>I seem to be unable to understand why do these two cases behave differently:</p>
<pre><code>const char* TEXT = "hello world!";
int length = (int) strlen(TEXT);
char* array[length];
</code></pre>
<p>this is ok, however this one:</p>
<pre><code>char* text;
scanf("%[^\n]s", text);
// input "hello world!" and press enter
int length = (int) strlen(text);
char* array[length];
</code></pre>
<p>ends with a segmentation fault</p>
<p>what am I missing?</p>
| 0debug |
static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5],
int x, int y, int ref, int plane)
{
Plane *p = &s->plane[plane];
uint8_t **ref_hpel = s->ref_pics[ref]->hpel[plane];
int motion_x = block->u.mv[ref][0];
int motion_y = block->u.mv[ref][1];
int mx, my, i, epel, nplanes = 0;
if (plane) {
motion_x >>= s->chroma_x_shift;
motion_y >>= s->chroma_y_shift;
}
mx = motion_x & ~(-1 << s->mv_precision);
my = motion_y & ~(-1 << s->mv_precision);
motion_x >>= s->mv_precision;
motion_y >>= s->mv_precision;
mx <<= 3 - s->mv_precision;
my <<= 3 - s->mv_precision;
x += motion_x;
y += motion_y;
epel = (mx|my)&1;
if (!((mx|my)&3)) {
nplanes = 1;
src[0] = ref_hpel[(my>>1)+(mx>>2)] + y*p->stride + x;
} else {
nplanes = 4;
for (i = 0; i < 4; i++)
src[i] = ref_hpel[i] + y*p->stride + x;
if (mx > 4) {
src[0] += 1;
src[2] += 1;
x++;
}
if (my > 4) {
src[0] += p->stride;
src[1] += p->stride;
y++;
}
if (!epel) {
if (!(mx&3)) {
src[!mx] = src[2 + !!mx];
nplanes = 2;
} else if (!(my&3)) {
src[0] = src[(my>>1) ];
src[1] = src[(my>>1)+1];
nplanes = 2;
}
} else {
if (mx > 4) {
FFSWAP(const uint8_t *, src[0], src[1]);
FFSWAP(const uint8_t *, src[2], src[3]);
}
if (my > 4) {
FFSWAP(const uint8_t *, src[0], src[2]);
FFSWAP(const uint8_t *, src[1], src[3]);
}
src[4] = epel_weights[my&3][mx&3];
}
}
if (x + p->xblen > p->width +EDGE_WIDTH/2 ||
y + p->yblen > p->height+EDGE_WIDTH/2 ||
x < 0 || y < 0) {
for (i = 0; i < nplanes; i++) {
ff_emulated_edge_mc(s->edge_emu_buffer[i], src[i],
p->stride, p->stride,
p->xblen, p->yblen, x, y,
p->width+EDGE_WIDTH/2, p->height+EDGE_WIDTH/2);
src[i] = s->edge_emu_buffer[i];
}
}
return (nplanes>>1) + epel;
}
| 1threat |
How to use onClick event on react Link component? : <p>I am using the Link component from the reactjs router and I cannot get the onClickevent working. This is the code:</p>
<pre><code><Link to={this.props.myroute} onClick='hello()'>Here</Link>
</code></pre>
<p>Is this the way to do it or another way?</p>
| 0debug |
static void aio_write_done(void *opaque, int ret)
{
struct aio_ctx *ctx = opaque;
struct timeval t2;
gettimeofday(&t2, NULL);
if (ret < 0) {
printf("aio_write failed: %s\n", strerror(-ret));
goto out;
}
if (ctx->qflag) {
goto out;
}
t2 = tsub(t2, ctx->t1);
print_report("wrote", &t2, ctx->offset, ctx->qiov.size,
ctx->qiov.size, 1, ctx->Cflag);
out:
qemu_io_free(ctx->buf);
g_free(ctx);
} | 1threat |
static void msvideo1_decode_8bit(Msvideo1Context *s)
{
int block_ptr, pixel_ptr;
int total_blocks;
int pixel_x, pixel_y;
int block_x, block_y;
int blocks_wide, blocks_high;
int block_inc;
int row_dec;
int stream_ptr;
unsigned char byte_a, byte_b;
unsigned short flags;
int skip_blocks;
unsigned char colors[8];
unsigned char *pixels = s->frame.data[0];
unsigned char *prev_pixels = s->prev_frame.data[0];
int stride = s->frame.linesize[0];
stream_ptr = 0;
skip_blocks = 0;
blocks_wide = s->avctx->width / 4;
blocks_high = s->avctx->height / 4;
total_blocks = blocks_wide * blocks_high;
block_inc = 4;
row_dec = stride + 4;
for (block_y = blocks_high; block_y > 0; block_y--) {
block_ptr = ((block_y * 4) - 1) * stride;
for (block_x = blocks_wide; block_x > 0; block_x--) {
if (skip_blocks) {
COPY_PREV_BLOCK();
block_ptr += block_inc;
skip_blocks--;
total_blocks--;
continue;
}
pixel_ptr = block_ptr;
CHECK_STREAM_PTR(2);
byte_a = s->buf[stream_ptr++];
byte_b = s->buf[stream_ptr++];
if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0))
return;
else if ((byte_b & 0xFC) == 0x84) {
skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1;
COPY_PREV_BLOCK();
} else if (byte_b < 0x80) {
flags = (byte_b << 8) | byte_a;
CHECK_STREAM_PTR(2);
colors[0] = s->buf[stream_ptr++];
colors[1] = s->buf[stream_ptr++];
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
pixels[pixel_ptr++] = colors[(flags & 0x1) ^ 1];
pixel_ptr -= row_dec;
}
} else if (byte_b >= 0x90) {
flags = (byte_b << 8) | byte_a;
CHECK_STREAM_PTR(8);
memcpy(colors, &s->buf[stream_ptr], 8);
stream_ptr += 8;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
pixels[pixel_ptr++] =
colors[((pixel_y & 0x2) << 1) +
(pixel_x & 0x2) + ((flags & 0x1) ^ 1)];
pixel_ptr -= row_dec;
}
} else {
colors[0] = byte_a;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++)
pixels[pixel_ptr++] = colors[0];
pixel_ptr -= row_dec;
}
}
block_ptr += block_inc;
total_blocks--;
}
}
if (s->avctx->pix_fmt == PIX_FMT_PAL8)
memcpy(s->frame.data[1], s->palette, PALETTE_COUNT * 4);
}
| 1threat |
START_TEST(qlist_iter_test)
{
int i;
QList *qlist;
qlist = qlist_new();
for (i = 0; i < iter_max; i++)
qlist_append(qlist, qint_from_int(i));
iter_called = 0;
qlist_iter(qlist, iter_func, NULL);
fail_unless(iter_called == iter_max);
QDECREF(qlist);
}
| 1threat |
Python Pandas Expand a Column of List of Lists to Two New Column : <p>I have a DF which looks like this.</p>
<pre><code>name id apps
john 1 [[app1, v1], [app2, v2], [app3,v3]]
smith 2 [[app1, v1], [app4, v4]]
</code></pre>
<p>I want to expand the apps column such that it looks like this.</p>
<pre><code>name id app_name app_version
john 1 app1 v1
john 1 app2 v2
john 1 app3 v3
smith 2 app1 v1
smith 2 app4 v4
</code></pre>
<p>Any help is appreciated</p>
| 0debug |
reuse twig templates in symfony2 with inheritance : <p>I have a symfony2 project which will be the base for a bundle of domains. Most configuration differences for those domains are done via the database. Like e.g. are the contents randomized, how many are shown on the start page etc.
But for some domains I want to use a different twig template for certain views depending on a categorization I do via the db.</p>
<p>Question 1: Is it possible to set it up like "if you find no template in place A use the default template from place B"? If yes how?</p>
<p>Question 2: Where would I place those templates in relation to the default templates?</p>
| 0debug |
alert('Hello ' + user_input); | 1threat |
void *qemu_thread_join(QemuThread *thread)
{
QemuThreadData *data;
void *ret;
HANDLE handle;
data = thread->data;
if (!data) {
return NULL;
}
EnterCriticalSection(&data->cs);
if (!data->exited) {
handle = OpenThread(SYNCHRONIZE, FALSE, thread->tid);
LeaveCriticalSection(&data->cs);
WaitForSingleObject(handle, INFINITE);
CloseHandle(handle);
} else {
LeaveCriticalSection(&data->cs);
}
ret = data->ret;
DeleteCriticalSection(&data->cs);
g_free(data);
return ret;
}
| 1threat |
static void serial_reset(void *opaque)
{
SerialState *s = opaque;
s->divider = 0;
s->rbr = 0;
s->ier = 0;
s->iir = UART_IIR_NO_INT;
s->lcr = 0;
s->mcr = 0;
s->lsr = UART_LSR_TEMT | UART_LSR_THRE;
s->msr = UART_MSR_DCD | UART_MSR_DSR | UART_MSR_CTS;
s->scr = 0;
s->thr_ipending = 0;
s->last_break_enable = 0;
qemu_irq_lower(s->irq);
}
| 1threat |
Swift NSAttributedString Trim : <p>I want to get ride of the white spaces in front and at the end of my NSAttributedString(Trimming it). I can't simply convert it to string and do trimming because there are images(attachments) in it.
How can i do it?</p>
| 0debug |
Angular Material Autocomplete force selection : <p>In my angular 5 application I have some matAutocomplete, but I want to force the selection of oone of suggestions, so I am following this approach:
<a href="https://stackblitz.com/edit/autocomplete-force-selection-tests-w2fqww?file=app%2Fapp.component.html" rel="noreferrer">stackblitz</a>
but for some reason in one case I have an issue: </p>
<blockquote>
<p>Cannot read property 'panelClosingActions' of undefined
at CustomerDetailComponent.countryClosingActions (customer-detail.component.ts:199)
at CustomerDetailComponent.ngAfterViewInit</p>
</blockquote>
<p>I have multiple matAutocomplete but only this one have problems.
(info about this method is here <a href="https://github.com/angular/material2/issues/3334" rel="noreferrer">github</a></p>
<p><strong>html</strong></p>
<pre><code><mat-form-field>
<input matInput #nation placeholder="{{'customer.detail.labels.country'
| translate }}" required [matAutocomplete]="tdAuto" name="country"
#count="ngModel" [(ngModel)]="selected.country"
(ngModelChange)="searchCountry($event)">
<mat-autocomplete #tdAuto="matAutocomplete" [displayWith]="displayFn">
<mat-option (onSelectionChange)="setCountry(country)" *ngFor="let country of countries" [value]="country">
<div class="row">
<img src="assets/img/flags24/{{country.alpha2Code | lowercase}}.png" />
<span>{{country.name}} ({{country.alpha2Code}})</span>
</div>
</mat-option>
</mat-autocomplete>
</mat-form-field>
</code></pre>
<p><strong>component</strong></p>
<pre><code>@ViewChild('nation', { read: MatAutocompleteTrigger }) trigger: MatAutocompleteTrigger;
subscription: Subscription;
ngAfterViewInit() {
this.countryClosingActions();
}
private countryClosingActions(): void {
if (this.subscription && !this.subscription.closed) {
this.subscription.unsubscribe();
}
this.subscription = this.trigger.panelClosingActions
.subscribe(e => {
console.log('closing')
if (!e || !e.source) {
this.selected.country = null;
this.selfCountry = null;
}
},
err => this.countryClosingActions(),
() => this.countryClosingActions());
}
</code></pre>
| 0debug |
Where is Apache Kafka placed in the PACELC-Theorem : <p>I am starting to learn about Apache Kafka. This <a href="https://engineering.linkedin.com/kafka/intra-cluster-replication-apache-kafka" rel="noreferrer">https://engineering.linkedin.com/kafka/intra-cluster-replication-apache-kafka</a> article states that Kafka is a CA system inside the CAP-Theorem. So it focuses on consistency between replicas and also on overall availability.</p>
<p>I recently heard about an extension of the CAP-Theorem called PACELC (<a href="https://en.wikipedia.org/wiki/PACELC_theorem" rel="noreferrer">https://en.wikipedia.org/wiki/PACELC_theorem</a>).
This theorem could be visualized like this:</p>
<p><a href="https://i.stack.imgur.com/lV2pB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lV2pB.png" alt="enter image description here"></a></p>
<p>My question is how Apache Kafka could be described in PACELC. I would think that Kafka focuses on consistency when a partition occurs but what otherwise if no partition occurs? Is the focus on low latancy or strong consistency?</p>
<p>Thanks!</p>
| 0debug |
static void init_fps(int bf, int audio_preroll, int fps)
{
AVStream *st;
ctx = avformat_alloc_context();
if (!ctx)
exit(1);
ctx->oformat = av_guess_format(format, NULL, NULL);
if (!ctx->oformat)
exit(1);
ctx->pb = avio_alloc_context(iobuf, sizeof(iobuf), AVIO_FLAG_WRITE, NULL, NULL, io_write, NULL);
if (!ctx->pb)
exit(1);
ctx->flags |= AVFMT_FLAG_BITEXACT;
st = avformat_new_stream(ctx, NULL);
if (!st)
exit(1);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_H264;
st->codec->width = 640;
st->codec->height = 480;
st->time_base.num = 1;
st->time_base.den = 30;
st->codec->extradata_size = sizeof(h264_extradata);
st->codec->extradata = av_mallocz(st->codec->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
exit(1);
memcpy(st->codec->extradata, h264_extradata, sizeof(h264_extradata));
st->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
video_st = st;
st = avformat_new_stream(ctx, NULL);
if (!st)
exit(1);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_AAC;
st->codec->sample_rate = 44100;
st->codec->channels = 2;
st->time_base.num = 1;
st->time_base.den = 44100;
st->codec->extradata_size = sizeof(aac_extradata);
st->codec->extradata = av_mallocz(st->codec->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
exit(1);
memcpy(st->codec->extradata, aac_extradata, sizeof(aac_extradata));
st->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
audio_st = st;
if (avformat_write_header(ctx, &opts) < 0)
exit(1);
av_dict_free(&opts);
frames = 0;
gop_size = 30;
duration = video_st->time_base.den / fps;
audio_duration = 1024 * audio_st->time_base.den / audio_st->codec->sample_rate;
if (audio_preroll)
audio_preroll = 2048 * audio_st->time_base.den / audio_st->codec->sample_rate;
bframes = bf;
video_dts = bframes ? -duration : 0;
audio_dts = -audio_preroll;
}
| 1threat |
static void r2d_init(ram_addr_t ram_size, int vga_ram_size,
const char *boot_device,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
CPUState *env;
struct SH7750State *s;
ram_addr_t sdram_addr, sm501_vga_ram_addr;
qemu_irq *irq;
PCIBus *pci;
int i;
if (!cpu_model)
cpu_model = "SH7751R";
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
sdram_addr = qemu_ram_alloc(SDRAM_SIZE);
cpu_register_physical_memory(SDRAM_BASE, SDRAM_SIZE, sdram_addr);
s = sh7750_init(env);
irq = r2d_fpga_init(0x04000000, sh7750_irl(s));
pci = sh_pci_register_bus(r2d_pci_set_irq, r2d_pci_map_irq, irq, 0, 4);
sm501_vga_ram_addr = qemu_ram_alloc(SM501_VRAM_SIZE);
sm501_init(0x10000000, sm501_vga_ram_addr, SM501_VRAM_SIZE,
serial_hds[2]);
mmio_ide_init(0x14001000, 0x1400080c, irq[CF_IDE], 1,
drives_table[drive_get_index(IF_IDE, 0, 0)].bdrv, NULL);
pci_nic_init(pci, &nd_table[0], 2 << 3, "rtl8139");
for (i = 1; i < nb_nics; i++)
pci_nic_init(pci, &nd_table[i], -1, "ne2k_pci");
{
int kernel_size;
stl_phys(SH7750_BCR1, 1<<3);
stw_phys(SH7750_BCR2, 3<<(3*2));
kernel_size = load_image(kernel_filename, phys_ram_base);
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename);
exit(1);
}
env->pc = SDRAM_BASE | 0xa0000000;
}
}
| 1threat |
static int paf_video_decode(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *pkt)
{
PAFVideoDecContext *c = avctx->priv_data;
uint8_t code, *dst, *end;
int i, frame, ret;
if (pkt->size < 2)
return AVERROR_INVALIDDATA;
bytestream2_init(&c->gb, pkt->data, pkt->size);
code = bytestream2_get_byte(&c->gb);
if ((code & 0xF) > 4) {
avpriv_request_sample(avctx, "unknown/invalid code");
return AVERROR_INVALIDDATA;
}
if ((ret = ff_reget_buffer(avctx, c->pic)) < 0)
return ret;
if (code & 0x20) {
for (i = 0; i < 4; i++)
memset(c->frame[i], 0, c->frame_size);
memset(c->pic->data[1], 0, AVPALETTE_SIZE);
c->current_frame = 0;
c->pic->key_frame = 1;
c->pic->pict_type = AV_PICTURE_TYPE_I;
} else {
c->pic->key_frame = 0;
c->pic->pict_type = AV_PICTURE_TYPE_P;
}
if (code & 0x40) {
uint32_t *out = (uint32_t *)c->pic->data[1];
int index, count;
index = bytestream2_get_byte(&c->gb);
count = bytestream2_get_byte(&c->gb) + 1;
if (index + count > 256)
return AVERROR_INVALIDDATA;
if (bytestream2_get_bytes_left(&c->gb) < 3 * count)
return AVERROR_INVALIDDATA;
out += index;
for (i = 0; i < count; i++) {
unsigned r, g, b;
r = bytestream2_get_byteu(&c->gb);
r = r << 2 | r >> 4;
g = bytestream2_get_byteu(&c->gb);
g = g << 2 | g >> 4;
b = bytestream2_get_byteu(&c->gb);
b = b << 2 | b >> 4;
*out++ = (0xFFU << 24) | (r << 16) | (g << 8) | b;
}
c->pic->palette_has_changed = 1;
}
switch (code & 0x0F) {
case 0:
if ((ret = decode_0(c, pkt->data, code)) < 0)
return ret;
break;
case 1:
dst = c->frame[c->current_frame];
bytestream2_skip(&c->gb, 2);
if (bytestream2_get_bytes_left(&c->gb) < c->video_size)
return AVERROR_INVALIDDATA;
bytestream2_get_bufferu(&c->gb, dst, c->video_size);
break;
case 2:
frame = bytestream2_get_byte(&c->gb);
if (frame > 3)
return AVERROR_INVALIDDATA;
if (frame != c->current_frame)
memcpy(c->frame[c->current_frame], c->frame[frame], c->frame_size);
break;
case 4:
dst = c->frame[c->current_frame];
end = dst + c->video_size;
bytestream2_skip(&c->gb, 2);
while (dst < end) {
int8_t code;
int count;
if (bytestream2_get_bytes_left(&c->gb) < 2)
return AVERROR_INVALIDDATA;
code = bytestream2_get_byteu(&c->gb);
count = FFABS(code) + 1;
if (dst + count > end)
return AVERROR_INVALIDDATA;
if (code < 0)
memset(dst, bytestream2_get_byteu(&c->gb), count);
else
bytestream2_get_buffer(&c->gb, dst, count);
dst += count;
}
break;
default:
av_assert0(0);
}
av_image_copy_plane(c->pic->data[0], c->pic->linesize[0],
c->frame[c->current_frame], c->width,
c->width, c->height);
c->current_frame = (c->current_frame + 1) & 3;
if ((ret = av_frame_ref(data, c->pic)) < 0)
return ret;
*got_frame = 1;
return pkt->size;
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.