problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
I want to recovre the filename in java I/O : i had name file in JAVA I/O: f1 = new File("C:\\Program Files\directory\FileDir\file.txt");
I want to recovre the filename only: FileDir(type String)
thank you.
| 0debug
|
static int exec_close(MigrationState *s)
{
int ret = 0;
DPRINTF("exec_close\n");
ret = qemu_fclose(s->opaque);
s->opaque = NULL;
s->fd = -1;
if (ret >= 0 && !(WIFEXITED(ret) && WEXITSTATUS(ret) == 0)) {
ret = -EIO;
}
return ret;
}
| 1threat
|
why list comprehension could select columns of a matrix? : Why the list comprehension could select the columns of a matrix? I am a bit confused by the for loop.
m=[[1,2,3],[4,5,6],[7,8,9]]
col=[x for x in m]
col2=col[1]
col2
[4, 5, 6]
Obivious the **below** codes give the right answer, but **why is that**? Because in each iteration, the `for loop` takes in a whole instead of a number?
m=[[1,2,3],[4,5,6],[7,8,9]]
col2=[x[1] for x in m
col2
[2, 5, 8]]
| 0debug
|
List of int get the records up to a certain value : <p>I have a <code>List<int></code> and I need all the first records that total reaches a value</p>
<p><code>List<int> Values= new List{10,30,70,50,60};</code>
and value is 100 so i need list with 10,30,70 how can i get it with linq</p>
| 0debug
|
docker run pass arguments to entrypoint : <p>I am able to pass the environment variables using -e option.
But i am not sure how to pass command line arguments to the jar in entrypoint using the docker run command. </p>
<p>Dockerfile</p>
<pre><code>FROM openjdk
ADD . /dir
WORKDIR /dir
COPY ./test-1.0.1.jar /dir/test-1.0.1.jar
ENTRYPOINT java -jar /dir/test-1.0.1.jar
</code></pre>
<p>test.sh</p>
<pre><code>#! /bin/bash -l
export AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id)
export AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key)
$value=7
docker run -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY -i -t testjava $value
</code></pre>
| 0debug
|
need a sql query for this can any one suggest two join simultaneously : Table Product
Id name t1 t2
1 A 1 4
2 B 5 2
3 C 3 1
4 D 4 5
Tan Table
id tan
1 tanA
2 tanB
3 tanC
4 tanD
5 tanE
I have two above table and i want the result as below in expecting result how it is possible please assist
Expecting result
A tanA tanD
B tanE tanB
C tanC tanA
D tanD tanE
| 0debug
|
void qmp_output_visitor_cleanup(QmpOutputVisitor *v)
{
QStackEntry *e, *tmp;
QTAILQ_FOREACH_SAFE(e, &v->stack, node, tmp) {
QTAILQ_REMOVE(&v->stack, e, node);
g_free(e);
}
qobject_decref(v->root);
g_free(v);
}
| 1threat
|
document.location = 'http://evil.com?username=' + user_input;
| 1threat
|
void helper_ldxfsr(CPUSPARCState *env, uint64_t new_fsr)
{
env->fsr = (new_fsr & FSR_LDXFSR_MASK) | (env->fsr & FSR_LDXFSR_OLDMASK);
set_fsr(env);
}
| 1threat
|
Where are the additional command line options in Android Studio version 1.5.1 for the emulator : <p>After the latest update to AS, the emulator's additional command line options are missing. I use this primarily for -http-proxy and -scale commands. Any help in locating these options, or it's replacement, would be appreciated.</p>
| 0debug
|
static float ppp_pvq_search_c(float *X, int *y, int K, int N)
{
int i, y_norm = 0;
float res = 0.0f, xy_norm = 0.0f;
for (i = 0; i < N; i++)
res += FFABS(X[i]);
res = K/(res + FLT_EPSILON);
for (i = 0; i < N; i++) {
y[i] = lrintf(res*X[i]);
y_norm += y[i]*y[i];
xy_norm += y[i]*X[i];
K -= FFABS(y[i]);
}
while (K) {
int max_idx = 0, max_den = 1, phase = FFSIGN(K);
float max_num = 0.0f;
y_norm += 1.0f;
for (i = 0; i < N; i++) {
const int ca = 1 ^ ((y[i] == 0) & (phase < 0));
const int y_new = y_norm + 2*phase*FFABS(y[i]);
float xy_new = xy_norm + 1*phase*FFABS(X[i]);
xy_new = xy_new * xy_new;
if (ca && (max_den*xy_new) > (y_new*max_num)) {
max_den = y_new;
max_num = xy_new;
max_idx = i;
}
}
K -= phase;
phase *= FFSIGN(X[max_idx]);
xy_norm += 1*phase*X[max_idx];
y_norm += 2*phase*y[max_idx];
y[max_idx] += phase;
}
return (float)y_norm;
}
| 1threat
|
Check if an object is a QuerySet : <p>I have an object variable <code>obj</code>. Is it possible to check whether its a Queryset or not? </p>
<p>(Couldn't find any posts on this on searching)</p>
| 0debug
|
CUDA_HOME path for Tensorflow : <p>The <a href="https://www.tensorflow.org/install/install_linux" rel="noreferrer">Tensorflow linux installation instructions</a> say:</p>
<blockquote>
<p>Ensure that you create the CUDA_HOME environment variable as described
in the NVIDIA documentation.</p>
</blockquote>
<p>I cannot find any mention of CUDA_HOME in the NVIDIA instructions for cuDNN v6 or in the <a href="http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#introduction" rel="noreferrer">NVIDIA CUDA Toolkit install instructions</a>. Does anyone know how this variable should be set on linux?</p>
| 0debug
|
DataTable not binding to DataGrid in WPF MVVM : <p>Can't figure out why my DataGrid isn't populating when I fill it's binded DataTable. I've checked other Stackoverflow posts but nothing seems to solve my problem. I know that my DataTable is getting filled up because the row count is over 50. The method that fills the DataTable (ReturnOperators) is sucessfully getting called (It's when the SelectedItem in a listbox is changed)</p>
<p>Here is my code:</p>
<p>Xaml:</p>
<pre><code> <DataGrid x:Name="dgOperators"
ItemsSource="{Binding DtOperators}"
AutoGenerateColumns="True"
Background="#0d0d0d"
Foreground="White"
Margin="10"
Grid.Row="1"
IsReadOnly="True" />
</code></pre>
<p>MainWindow.xaml.cs:</p>
<p>private ViewModel vm;</p>
<pre><code> public MainWindow()
{
InitializeComponent();
vm = new ViewModel();
this.DataContext = vm;
}
</code></pre>
<p>ViewModel:</p>
<pre><code>private DataTable dtOperators;
public DataTable DtOperators
{
get { return dtOperators; }
set
{
dtOperators = value;
OnPropertyChanged("DtOperators");
}
}
public void ReturnOperators()
{
string query = "My SQL Query Here";
using (SqlConnection con = new SqlConnection(connectionString))
using (SqlCommand cmd = new SqlCommand(query, con))
using (SqlDataAdapter adapter = new SqlDataAdapter(cmd))
{
DtOperators.Clear();
adapter.Fill(DtOperators);
}
}
</code></pre>
| 0debug
|
Is sendKeys ever going to work properly with Java Selenium? : <p>how am I ever going to write any selenium automation code that can have the same outcome everytime and could ever ever ever be trusted?
as most of you should know sendKeys is simply shit.</p>
<p>-it doesnt write the complete input</p>
<p>-sometimes it doesnt write at all</p>
<p>-its skips to other elements and messes up the input</p>
<p>-it cant write longer character sequences</p>
<p>-you cant check it correctly</p>
<p>-you cant make it wait.until everything is sent</p>
<p>and this all is simply randomized into a clusterfuck of one-to-a-billion
my at this moment examples (I probably changed my approach more than 10 times)</p>
<pre><code>public static void sendKeys(By by, String input) {
if (by == null) {
throw new IllegalArgumentException("Parameter 'by' is null.");
}
if (input == null) {
throw new IllegalArgumentException("Parameter 'input' is null.");
}
LOGGER.info("sendKeys() - By locator '{}'", by.toString());
WebElement elem = WebElementFinder.getElement(by);
elem.clear();
elem.sendKeys(input);
checkKeySendResult(by, input);
}
public static void checkKeySendResult(By by, String input) {
WebElement elem = WebElementFinder.getElement(by);
String value = elem.getAttribute("value");
if (!value.equals(input)) {
LOGGER.info("sendKeys() - didn't work");
elem.clear();
elem.sendKeys(input);
checkKeySendResult(by, input);
} else {
LOGGER.info("sendKeys() - sent all characters");
}
}
</code></pre>
<p>you know what I expect; </p>
<p>-all keys should be sent</p>
<p>-sendKeys shouldn't stop midway of typing and then go somewhere else</p>
<p>-I should be able to correctly check if the input is right</p>
<p>-if incorrect, I should be able to correct it easily and unwaveringly</p>
<p>and please dont tell me to use a waiter, cause I obviously did try out waiters in every single step...</p>
<p>I'll test out any kind of advice offered here as I do hope everyone does and hopefully someone can open my eyes to a steady sendKeys method.</p>
<p>if you cant help me, please do use this thread to ragingly describe your hatred towards sendKeys and how frustrating it is to be working with it.</p>
<p>Thank you all for your input.</p>
<p>obs: sorry for my french</p>
| 0debug
|
Jenkins email plugin doesn't send email to user who broke the build : <p>I've setup Jenkins to send emails only to users who broke the build using email-ext plugin, but I'm getting this error:</p>
<blockquote>
<p>Not sending mail to unregistered user user@example.com because your SCM claimed this was associated with a user ID ‘John Smith' which your security realm does not recognize; you may need changes in your SCM plugin</p>
</blockquote>
<p>I don't really understand what this error means, is the problem in our SCM, or in the email plugin? The emails are taken from the commit history, should I register them somewhere so Jenkins will start working?</p>
<p>For reference, <a href="https://github.com/jenkinsci/email-ext-plugin/blob/master/src/main/java/hudson/plugins/emailext/plugins/recipients/RecipientProviderUtilities.java#L209" rel="noreferrer">this is the code around the error message</a> in the plugin's source code:</p>
<pre><code> } catch (UsernameNotFoundException x) {
if (SEND_TO_UNKNOWN_USERS) {
listener.getLogger().printf("Warning: %s is not a recognized user, but sending mail anyway%n", userAddress);
} else {
listener.getLogger().printf("Not sending mail to unregistered user %s because your SCM"
........
</code></pre>
<p>How do I enable <code>SEND_TO_UNKNOWN_USERS</code>?</p>
<p>The error message is also mentioned in this <a href="https://issues.jenkins-ci.org/browse/JENKINS-43268" rel="noreferrer">bug report</a>.</p>
| 0debug
|
static inline void expand_category(COOKContext *q, int *category,
int *category_index)
{
int i;
for (i = 0; i < q->num_vectors; i++)
++category[category_index[i]];
}
| 1threat
|
static int synchronize_audio(VideoState *is, int nb_samples)
{
int wanted_nb_samples = nb_samples;
if (get_master_sync_type(is) != AV_SYNC_AUDIO_MASTER) {
double diff, avg_diff;
int min_nb_samples, max_nb_samples;
diff = get_audio_clock(is) - get_master_clock(is);
if (fabs(diff) < AV_NOSYNC_THRESHOLD) {
is->audio_diff_cum = diff + is->audio_diff_avg_coef * is->audio_diff_cum;
if (is->audio_diff_avg_count < AUDIO_DIFF_AVG_NB) {
is->audio_diff_avg_count++;
} else {
avg_diff = is->audio_diff_cum * (1.0 - is->audio_diff_avg_coef);
if (fabs(avg_diff) >= is->audio_diff_threshold) {
wanted_nb_samples = nb_samples + (int)(diff * is->audio_src.freq);
min_nb_samples = ((nb_samples * (100 - SAMPLE_CORRECTION_PERCENT_MAX) / 100));
max_nb_samples = ((nb_samples * (100 + SAMPLE_CORRECTION_PERCENT_MAX) / 100));
wanted_nb_samples = FFMIN(FFMAX(wanted_nb_samples, min_nb_samples), max_nb_samples);
}
av_dlog(NULL, "diff=%f adiff=%f sample_diff=%d apts=%0.3f %f\n",
diff, avg_diff, wanted_nb_samples - nb_samples,
is->audio_clock, is->audio_diff_threshold);
}
} else {
is->audio_diff_avg_count = 0;
is->audio_diff_cum = 0;
}
}
return wanted_nb_samples;
}
| 1threat
|
static void avc_luma_mid_4w_msa(const uint8_t *src, int32_t src_stride,
uint8_t *dst, int32_t dst_stride,
int32_t height)
{
uint32_t loop_cnt;
v16i8 src0, src1, src2, src3, src4;
v16i8 mask0, mask1, mask2;
v8i16 hz_out0, hz_out1, hz_out2, hz_out3;
v8i16 hz_out4, hz_out5, hz_out6, hz_out7, hz_out8;
v8i16 dst0, dst1, dst2, dst3;
LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2);
LD_SB5(src, src_stride, src0, src1, src2, src3, src4);
src += (5 * src_stride);
XORI_B5_128_SB(src0, src1, src2, src3, src4);
hz_out0 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1,
mask0, mask1, mask2);
hz_out2 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3,
mask0, mask1, mask2);
PCKOD_D2_SH(hz_out0, hz_out0, hz_out2, hz_out2, hz_out1, hz_out3);
hz_out4 = AVC_HORZ_FILTER_SH(src4, src4, mask0, mask1, mask2);
for (loop_cnt = (height >> 2); loop_cnt--;) {
LD_SB4(src, src_stride, src0, src1, src2, src3);
src += (4 * src_stride);
XORI_B4_128_SB(src0, src1, src2, src3);
hz_out5 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1,
mask0, mask1,
mask2);
hz_out7 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3,
mask0, mask1,
mask2);
PCKOD_D2_SH(hz_out5, hz_out5, hz_out7, hz_out7, hz_out6, hz_out8);
dst0 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out0, hz_out1, hz_out2,
hz_out3, hz_out4, hz_out5);
dst1 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out1, hz_out2, hz_out3,
hz_out4, hz_out5, hz_out6);
dst2 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out2, hz_out3, hz_out4,
hz_out5, hz_out6, hz_out7);
dst3 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out3, hz_out4, hz_out5,
hz_out6, hz_out7, hz_out8);
PCKEV_B2_SB(dst1, dst0, dst3, dst2, src0, src1);
XORI_B2_128_SB(src0, src1);
ST4x4_UB(src0, src1, 0, 2, 0, 2, dst, dst_stride);
dst += (4 * dst_stride);
hz_out0 = hz_out4;
hz_out1 = hz_out5;
hz_out2 = hz_out6;
hz_out3 = hz_out7;
hz_out4 = hz_out8;
}
}
| 1threat
|
Saving prediction results to CSV : <p>I am storing the results from a sklearn regression model to the varibla prediction.</p>
<pre><code>prediction = regressor.predict(data[['X']])
print(prediction)
</code></pre>
<p>The values of the prediction output looks like this</p>
<pre><code>[ 266.77832991 201.06347505 446.00066136 499.76736079 295.15519906
214.50514991 422.1043505 531.13126879 287.68760191 201.06347505
402.68859792 478.85808879 286.19408248 192.10235848]
</code></pre>
<p>I am then trying to use the to_csv function to save the results to a local CSV file:</p>
<pre><code>prediction.to_csv('C:/localpath/test.csv')
</code></pre>
<p>But the error I get back is:</p>
<pre><code>AttributeError: 'numpy.ndarray' object has no attribute 'to_csv'
</code></pre>
<p>I am using Pandas/Numpy/SKlearn. Any idea on the basic fix?</p>
| 0debug
|
Haskell function non-exaustive patters in function error : <p>I'm trying to make a function that finds the local Maximum number in a list.</p>
<pre><code>localMaxima :: [Integer] -> [Integer]
localMaxima [] = []
localMaxima [x] = []
localMaxima (e1:e2:e3:xs)
| (e2 > e3) && (e2 > e1) = e2 : (localMaxima (e2:(e3:xs)))
| otherwise = (localMaxima (e2:(e3:xs)))
</code></pre>
<p>After inputting a list of [2,3,4,1,5], the console outputs: </p>
<p>Non-exhaustive patterns in function localMaxima</p>
| 0debug
|
static int dec_scc_r(CPUCRISState *env, DisasContext *dc)
{
int cond = dc->op2;
LOG_DIS("s%s $r%u\n",
cc_name(cond), dc->op1);
if (cond != CC_A) {
int l1;
gen_tst_cc(dc, cpu_R[dc->op1], cond);
l1 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_R[dc->op1], 0, l1);
tcg_gen_movi_tl(cpu_R[dc->op1], 1);
gen_set_label(l1);
} else {
tcg_gen_movi_tl(cpu_R[dc->op1], 1);
}
cris_cc_mask(dc, 0);
return 2;
}
| 1threat
|
Get font resource from TypedArray before API 26 : <p>Android O introduced fonts in xml back to API 16 via the support library. However I am unable to find the support equivalent of <code>TypedArray.getFont()</code>, which required API level 26.</p>
<pre><code>val array = context.obtainStyledAttributes(styleResId, R.styleable.TextAppearance)
val font = array.getFont(R.styleable.TextAppearance_android_fontFamily) // nope
</code></pre>
<p>Is there some kind of compat utility class I can use to retrieve a font from a style resource id?</p>
| 0debug
|
How to display countdown timer on status bar in android, like time display? : <p>I am making an app which allows the user to pick a date and time. Once the date and time are reached,it will display an animation on the screen. Before its time, it will just show countdown time (like xxx:xx:xx) on screen. I achieved this using a textview which changes every second. How can I display this text on status bar, like time is displayed</p>
<p>I have tried using Notification constructor like in some post I found here but they are depricated and wont work anymore.
I tried with NotificationCompat.Builder but it doesnt really have a way to set text which could be displayed on status bar.</p>
<p>Anyone knows any work arpund solution for it, please give me an answer. I just need to display a text on status bar insted of icon</p>
| 0debug
|
Web interface for a command line interface : <p>I am using a command-line program and I'd like to build a web interface for ease of access</p>
<p>I mean, the interface should have textfield, some popup-menu to let the users insert the input. Then, I've to show the output when the user click the "Execute" button.</p>
<p>When I hit a button from Web GUI, it should go hit the cli and run the command, display output on cli. Now I need to display this output on web gui.</p>
<p>Do you have any suggestion? I need to build this interface as soon as possible. So what's the fastest way to build such web app?</p>
<p>My question is exactly same as asked in below link, but I didnt get the proper answer for that:
<a href="https://stackoverflow.com/questions/11692641/web-interface-for-a-command-line-program">Web interface for a command-line program</a></p>
| 0debug
|
ArrayList project at college, some questions : So hey guys I have some things to ask,
I have to program my first, call it project, in my first semester. It's about programming an appointment calendar (don't really know how it's called in english, like a scheduleish thing :P). Until now we've learned the major stuff (for, if, etc.), how to connect classes, create a constructor and about objects. So we have to program this schedule pretty easily with ArrayList and it should delete, edit, create, list the entries. You have to just type in a date and an entry,
f. e.: 10.01.16 "example".
It doesn't even have to sort it after the date, but I'm really struggling at some points.
1. I listened to some dudes in my class and one said, he would have
wrote 9 classes. I couldn't even think of that, why so many?
2. Also how do I save the entries? Just with examplelist.add and it
just saves like that?
3. Why do I need a getter and setter, if I could just wrote that stuff
in my constructor?
4. How do I make it look nice, just a println/printf("\n") in a loop
after each entry?
First of all, thanks for reading this and spending time for helping a lowbie, I appreciate everything you have to offer. I will go to bed now, spending my whole day tomorrow to write that. Most likely I will have some more questions.
| 0debug
|
static void l2x0_priv_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
l2x0_state *s = (l2x0_state *)opaque;
offset &= 0xfff;
if (offset >= 0x730 && offset < 0x800) {
return;
}
switch (offset) {
case 0x100:
s->ctrl = value & 1;
break;
case 0x104:
s->aux_ctrl = value;
break;
case 0x108:
s->tag_ctrl = value;
break;
case 0x10C:
s->data_ctrl = value;
break;
case 0xC00:
s->filter_start = value;
break;
case 0xC04:
s->filter_end = value;
break;
case 0xF40:
return;
case 0xF60:
return;
case 0xF80:
return;
default:
fprintf(stderr, "l2x0_priv_write: Bad offset %x\n", (int)offset);
break;
}
}
| 1threat
|
void memory_region_sync_dirty_bitmap(MemoryRegion *mr)
{
FlatRange *fr;
FOR_EACH_FLAT_RANGE(fr, &address_space_memory.current_map) {
if (fr->mr == mr) {
MEMORY_LISTENER_UPDATE_REGION(fr, &address_space_memory,
Forward, log_sync);
}
}
}
| 1threat
|
uint32_t ide_data_readl(void *opaque, uint32_t addr)
{
IDEBus *bus = opaque;
IDEState *s = idebus_active_if(bus);
uint8_t *p;
int ret;
if (!(s->status & DRQ_STAT) || !ide_is_pio_out(s)) {
p = s->data_ptr;
ret = cpu_to_le32(*(uint32_t *)p);
p += 4;
s->data_ptr = p;
if (p >= s->data_end)
s->end_transfer_func(s);
return ret;
| 1threat
|
React-router v4 - cannot GET *url* : <p>I started to use react-router v4. I have a simple <code><Router></code> in my app.js with some navigation links (see code below). If I navigate to <code>localhost/vocabulary</code>, router redirects me to the right page. However, when I press reload (F5) afterwards (<code>localhost/vocabulary</code>), all content disappear and browser report <code>Cannot GET /vocabulary</code>. How is that possible? Can somebody gives me any clue how to solve that (reload the page correctly)?</p>
<p>App.js:</p>
<pre><code>import React from 'react'
import ReactDOM from 'react-dom'
import { BrowserRouter as Router, Route, Link } from 'react-router-dom'
import { Switch, Redirect } from 'react-router'
import Login from './pages/Login'
import Vocabulary from './pages/Vocabulary'
const appContainer = document.getElementById('app')
ReactDOM.render(
<Router>
<div>
<ul>
<li><Link to="/">Home</Link></li>
<li><Link to="/vocabulary">Vocabulary</Link></li>
</ul>
<Switch>
<Route exact path="/" component={Login} />
<Route exact path="/vocabulary" component={Vocabulary} />
</Switch>
</div>
</Router>,
appContainer)
</code></pre>
| 0debug
|
Php display select result : I'm busy for a whole afternoon and I can't find the answer on my question. I tried to build a select query that I can use for the future login form where I can say that an user is activated or not.
So As test I did the following:
<?php
$con = mysql_connect("localhost","steven","PASSWORD!","leercentrum");
echo("This Works");
$query = "SELECT activated FROM users WHERE username = 'steven' ";
$result = mysql_query($con, $query);
print_var($result);
?>
The query works on my database via SQL Workbench.
I also attached a screenshot of my Mysql database (Table users).
[1]: https://i.stack.imgur.com/uef3g.jpg
I hope some could help me with this issue. The only thing what I want to do in the future is an If function where I can see of the user is activated (1) or not activated (0)
Regards
Steven
| 0debug
|
How to count from a sentence in C# : <p>So, I am creating a word filter for a game server in C# and basically I am trying to scourer the sentence for banned words and replace them with clean words. I've already done so, but now I'm up to the part where I want to scan the sentence for a list of sentence banned words. I'm hopeless at this bit, and I can't seem to wrap my head around it.</p>
<p>Basically I am <code>CheckSentence(Message)</code> in the ChatManager, and need the following code to count and return <code>continue;</code> if the value is more than 5. So far I have:</p>
<pre><code>public bool CheckSentence(string Message)
{
foreach (WordFilter Filter in this._filteredWords.ToList())
{
if (Message.ToLower().Contains(Filter.Word) && Filter.IsSentence)
{
// count Message, if message contains >5
// from (Message.Contains(Filter.Word))
// continue; else (ignore)
}
}
return false;
}
</code></pre>
<p>I'm not too sure if that makes much sense, but I want it to continue; if there are more than 5 <code>Message.Contains(Filter.Word)</code> </p>
| 0debug
|
static int svq1_decode_delta_block(AVCodecContext *avctx, DSPContext *dsp,
GetBitContext *bitbuf,
uint8_t *current, uint8_t *previous,
int pitch, svq1_pmv *motion, int x, int y)
{
uint32_t block_type;
int result = 0;
block_type = get_vlc2(bitbuf, svq1_block_type.table, 2, 2);
if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) {
motion[0].x =
motion[0].y =
motion[x / 8 + 2].x =
motion[x / 8 + 2].y =
motion[x / 8 + 3].x =
motion[x / 8 + 3].y = 0;
}
switch (block_type) {
case SVQ1_BLOCK_SKIP:
svq1_skip_block(current, previous, pitch, x, y);
break;
case SVQ1_BLOCK_INTER:
result = svq1_motion_inter_block(dsp, bitbuf, current, previous,
pitch, motion, x, y);
if (result != 0) {
av_dlog(avctx, "Error in svq1_motion_inter_block %i\n", result);
break;
}
result = svq1_decode_block_non_intra(bitbuf, current, pitch);
break;
case SVQ1_BLOCK_INTER_4V:
result = svq1_motion_inter_4v_block(dsp, bitbuf, current, previous,
pitch, motion, x, y);
if (result != 0) {
av_dlog(avctx, "Error in svq1_motion_inter_4v_block %i\n", result);
break;
}
result = svq1_decode_block_non_intra(bitbuf, current, pitch);
break;
case SVQ1_BLOCK_INTRA:
result = svq1_decode_block_intra(bitbuf, current, pitch);
break;
}
return result;
}
| 1threat
|
SSIS package to update SQL table : <p>I have a file that contains Client information (client number, client name, client type, etc.) and I imported that into a SQL table.</p>
<p>Client information can change, and when it changes it changes it in the file.</p>
<p>Now, what I want to do is create a SSIS package that will read the file and search for any differences between the file and SQL table and if any changes are picked up, it needs to update the table according to the file (the file will always contain the latest information).</p>
<p>How would I achieve this? Is this possible from an SSIS perspective?</p>
| 0debug
|
Django: ContentTypes during migration while running tests : <p>I migrated a <code>ForeignKey</code> to a <code>GenericForeignKey</code>, using the <code>contrib.contenttypes</code> framework. To access the <code>ContentType</code> object I need to migrate the data, I used this code:</p>
<pre><code>ContentType = apps.get_model('contenttypes', 'ContentType')
my_model_content_type = ContentType.objects.get(
app_label='my_app',
model='my_model'
)
</code></pre>
<p>The migration works when I run <code>manage.py migrate</code>, and I can then play with the updated model in the shell without problems.</p>
<p>However, when I attempt to run <code>manage.py test</code>, I get the following error in the <code>ContentTypes.object.get()</code> line:</p>
<pre><code>__fake__.DoesNotExist: ContentType matching query does not exist.
</code></pre>
<p>Querying for <code>ContentType.objects.all()</code> at that time returns an empty queryset.</p>
<p>I have tried (as directed by another answer here in SO) to run this before my query, but to no avail:</p>
<pre><code>update_contenttypes(apps.app_configs['contenttypes'])
update_contenttypes(apps.app_configs['my_app'])
</code></pre>
<p>How can I ensure that the <code>ContentType</code> rows exist at that point in the test database migration?</p>
| 0debug
|
Almost increase sequence : // Given a sequence of integers as an array, determine whether it is possible to obtain a strictly increasing sequence by removing no more than one element from the array.
// Example
// For sequence = [1, 3, 2, 1], the output should be
// almostIncreasingSequence(sequence) = false;
// There is no one element in this array that can be removed in order to get a strictly increasing sequence.
// For sequence = [1, 3, 2], the output should be
// almostIncreasingSequence(sequence) = true.
// You can remove 3 from the array to get the strictly increasing sequence [1, 2]. Alternately, you can remove 2 to get the strictly increasing sequence [1, 3].
function almostIncreasingSequence(sequence) {
//compare current int to previous, return true if greater than
//remove int at index and compare with new values, return false if comparison fails
var result = false;
for(var i = 0; i < sequence.length; i++){
var newSequence = sequence.slice();
var subSequence = newSequence.splice(i, 1);
for(var j = 0; j < newSequence.length - 1; j++){
if(newSequence === newSequence.sort((a,b) => a < b).reverse()){
result = true;
}
}
}
return result;
}
I'm trying to figure out how to solve this problem. I feel like I'm very close but for some reason when I call reverse in the conditional statement it also sorts out the newSequence variable. Its sorting two variables in the conditional not one. As a result it resolves to true. I'm not clear why this is happening. Any feedback is appreciated.
| 0debug
|
How distinguish two different buttons in same event click? : <p>On WPF, if I have only one button click event shared for two or more (52 being more precise) is there a way to distinguish which button the event come from?</p>
<pre><code> private void Button_Card_Click(object sender, RoutedEventArgs e)
{
// for testing
// it works for each button, but which one has been clicked?
MessageBox.Show("Clicked");
}
</code></pre>
<p><a href="https://i.stack.imgur.com/uzNlm.png" rel="nofollow noreferrer">First button object with event set up</a></p>
<p><a href="https://i.stack.imgur.com/4kSrX.png" rel="nofollow noreferrer">Second button object with event set up</a></p>
| 0debug
|
Work with elm and select : <p>I try to understand how elm works with a custom example.</p>
<pre><code>durationOption duration =
option [value (toString duration) ] [ text (toString duration)]
view : Model -> Html Msg
view model =
Html.div []
[ h2 [] [ text "Month selector"]
, select []
(List.map durationOption [1..12])
]
</code></pre>
<p>It's an easy example to work with a select. I would like, each time I change the month value it multiplies to value by 10 for example. According to the documentation there is not events like <code>onChange</code> or <code>onSelect</code>, do I have to create mine with <a href="http://package.elm-lang.org/packages/evancz/elm-html/4.0.2/Html-Events#on">on</a> ?</p>
| 0debug
|
what are the steps to install prediction IO on windows 7 : <p>i am new to predictionio and i am not able to install the predictionio on my PC. The steps given on the apache site i am not able to understand command like
$ tar zxvf apache-predictionio-0.12.1.tar.gz
$ gpg --verify apache-predictionio-0.12.1.tar.gz.asc apache-predictionio-0.12.1.tar.gz
.
.
.
which are given on site document
can you please provide step by step installation for windows.</p>
| 0debug
|
void pci_bridge_write_config(PCIDevice *d,
uint32_t address, uint32_t val, int len)
{
PCIBridge *s = PCI_BRIDGE(d);
uint16_t oldctl = pci_get_word(d->config + PCI_BRIDGE_CONTROL);
uint16_t newctl;
pci_default_write_config(d, address, val, len);
if (ranges_overlap(address, len, PCI_COMMAND, 2) ||
ranges_overlap(address, len, PCI_IO_BASE, 2) ||
ranges_overlap(address, len, PCI_MEMORY_BASE, 20) ||
ranges_overlap(address, len, PCI_BRIDGE_CONTROL, 2)) {
pci_bridge_update_mappings(s);
}
newctl = pci_get_word(d->config + PCI_BRIDGE_CONTROL);
if (~oldctl & newctl & PCI_BRIDGE_CTL_BUS_RESET) {
pci_bus_reset(&s->sec_bus);
}
}
| 1threat
|
void cpu_x86_frstor(CPUX86State *s, uint8_t *ptr, int data32)
{
CPUX86State *saved_env;
saved_env = env;
env = s;
helper_frstor(ptr, data32);
env = saved_env;
}
| 1threat
|
Deploying basic Angular 2 app to Google App Engine : <p>I can use Angular 2 to create basic front-end applications and can use python to create back-ends with endpoints on Google App engine. I can't however seem to figure out how to put the two together and deploy them with the cloud SDK.</p>
<p>Here is a basic example where I can't even host a simple angular2 app with no back-end calls on GAE. I have taken the dist folder after building with angular2 CLI and tried to connect to it with the app.yaml file. It seems to work in the browser developer (dev_appserver.py app.yaml) although I get some 404 errors in SDK with the GET requests to do with my index.html file I think. I then create a blank index.yaml file and try to deploy it but get a 404 Error at the appspot.com location. This is the app.yaml file:</p>
<pre><code>application:
version:
runtime: python27
threadsafe: true
api_version: 1
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: (.*)/
static_files: dist\1/index.html
upload: dist
- url: (.*)
static_files: dist\1
upload: dist
</code></pre>
<p>I really have no idea what I am doing wrong. Do I need some kind of a main.application python back-end to connect to the dist files or? Do I need to include node modules or some other kind or files from Angular2? Any help would be massively appreciated! Thanks</p>
| 0debug
|
Changing span text of a class : <p>I am having troubles changing text of a span class on a website.
I've tried many things but nothing is happening.
What i want to do is to change from value 0 to 245.</p>
<pre><code><td>Coins: <span class="myCoins">0</span></td>
</code></pre>
<p>This is link to the compiler <a href="http://jsfiddle.net/dVBRm/6/" rel="nofollow">Fiddle</a></p>
| 0debug
|
Matlab - Incorrect dimensions for raising a matrix to a power : <p>Suppose we have <code>a=60</code> and <code>B=60</code>. I am trying to calculate this area:</p>
<p><a href="https://i.stack.imgur.com/qE4bT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qE4bT.png" alt="enter image description here"></a></p>
<p>when I try this:</p>
<pre class="lang-matlab prettyprint-override"><code>W = ((u^2)* cot(B) + (v^2 * cot(a))/8;
</code></pre>
<p>I get this error:</p>
<blockquote>
<p>Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers,
use '.^'.</p>
</blockquote>
<p>How can I use <code>u^2</code> in the right way?</p>
| 0debug
|
static void decompress_data_with_multi_threads(QEMUFile *f,
void *host, int len)
{
int idx, thread_count;
thread_count = migrate_decompress_threads();
while (true) {
for (idx = 0; idx < thread_count; idx++) {
if (!decomp_param[idx].start) {
qemu_get_buffer(f, decomp_param[idx].compbuf, len);
decomp_param[idx].des = host;
decomp_param[idx].len = len;
start_decompression(&decomp_param[idx]);
break;
}
}
if (idx < thread_count) {
break;
}
}
}
| 1threat
|
void *etraxfs_eth_init(NICInfo *nd, CPUState *env,
qemu_irq *irq, target_phys_addr_t base, int phyaddr)
{
struct etraxfs_dma_client *dma = NULL;
struct fs_eth *eth = NULL;
qemu_check_nic_model(nd, "fseth");
dma = qemu_mallocz(sizeof *dma * 2);
eth = qemu_mallocz(sizeof *eth);
dma[0].client.push = eth_tx_push;
dma[0].client.opaque = eth;
dma[1].client.opaque = eth;
dma[1].client.pull = NULL;
eth->env = env;
eth->irq = irq;
eth->dma_out = dma;
eth->dma_in = dma + 1;
eth->phyaddr = phyaddr & 0x1f;
tdk_init(ð->phy);
mdio_attach(ð->mdio_bus, ð->phy, eth->phyaddr);
eth->ethregs = cpu_register_io_memory(0, eth_read, eth_write, eth);
cpu_register_physical_memory (base, 0x5c, eth->ethregs);
eth->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
eth_receive, eth_can_receive, eth);
eth->vc->opaque = eth;
eth->vc->link_status_changed = eth_set_link;
return dma;
}
| 1threat
|
BlockAIOCB *bdrv_aio_flush(BlockDriverState *bs,
BlockCompletionFunc *cb, void *opaque)
{
trace_bdrv_aio_flush(bs, opaque);
Coroutine *co;
BlockAIOCBCoroutine *acb;
bdrv_inc_in_flight(bs);
acb = qemu_aio_get(&bdrv_em_co_aiocb_info, bs, cb, opaque);
acb->need_bh = true;
acb->req.error = -EINPROGRESS;
co = qemu_coroutine_create(bdrv_aio_flush_co_entry, acb);
qemu_coroutine_enter(co);
bdrv_co_maybe_schedule_bh(acb);
return &acb->common;
}
| 1threat
|
yuv2gray16_X_c_template(SwsContext *c, const int16_t *lumFilter,
const int32_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int32_t **chrUSrc,
const int32_t **chrVSrc, int chrFilterSize,
const int32_t **alpSrc, uint16_t *dest, int dstW,
int y, enum PixelFormat target)
{
int i;
for (i = 0; i < (dstW >> 1); i++) {
int j;
int Y1 = 1 << 14;
int Y2 = 1 << 14;
for (j = 0; j < lumFilterSize; j++) {
Y1 += lumSrc[j][i * 2] * lumFilter[j];
Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
}
Y1 >>= 15;
Y2 >>= 15;
if ((Y1 | Y2) & 0x10000) {
Y1 = av_clip_uint16(Y1);
Y2 = av_clip_uint16(Y2);
}
output_pixel(&dest[i * 2 + 0], Y1);
output_pixel(&dest[i * 2 + 1], Y2);
}
}
| 1threat
|
CAN standard frame and extended frame related : <p>Is it possible to have both CAN standard frame and CAN extended frame coexist on a single CAN bus ?</p>
<p>can bus protocol allows this to happen?</p>
| 0debug
|
pairs two different list to a map : I have two lists in java:
List<String> ENODE = Arrays.asList("ENB1", "ENB2", "ENB3", "ENB4", "ENB5");
List<String> CLOUD = Arrays.asList("C1", "C2", "C3", "C4");
And I want to iterate the elements in both of the lists to produce a hash map that pairs all element in list 1 with all element in list 2 which result in something like below:
("ENB1","C1"), ("ENB1","C2"), ("ENB1","C3"),("ENB1","C4")
("ENB2","C1"), ("ENB2","C2"), ("ENB2","C3"),("ENB2","C4") and so on..
Any idea on how I could do this?
| 0debug
|
static inline void gen_op_addw_ESP_im(int32_t val)
{
tcg_gen_ld_tl(cpu_tmp0, cpu_env, offsetof(CPUState, regs[R_ESP]));
tcg_gen_addi_tl(cpu_tmp0, cpu_tmp0, val);
tcg_gen_st16_tl(cpu_tmp0, cpu_env, offsetof(CPUState, regs[R_ESP]) + REG_W_OFFSET);
}
| 1threat
|
stored procedure Select in : How to execute stored procedure by select in instead of = by vb.net and mssql stored procedure
Dim sSQL As String
Dim objConn As SqlConnection
Dim objcmd As SqlCommand
Dim da As SqlDataAdapter
Dim ds = New DataSet()
sSQL = "getinvoice"
objConn = utility.getconnect
objcmd = New SqlCommand(sSQL, objConn)
objcmd.CommandType = CommandType.StoredProcedure
objcmd.Parameters.Add("@invoiceid", SqlDbType.VarChar)
objcmd.Parameters.Item("@invoiceid").Value = "1,5,13,18" '<-- problem
da = New SqlDataAdapter(objcmd)
da.Fill(ds)
ALTER PROCEDURE [dbo].[getinvoices]
@invoiceid varchar(50)
AS
BEGIN
select * from invoice where invoiceid in @invoiceid '<-- problem
END
| 0debug
|
Convert datetime value from one timezone to UTC timezone using sql query : <p>I have a datetime value.
That datetime value may be in any timezone like 'Eastern Standard Time' or 'India Standard Time'.
I want to convert that datetime value to UTC timezone in sql.
Here from timezone value will be the given parameter.
I can achieve this using c# code also.But I need this in sql query.</p>
<p>Can anyone tell me how can I convert that?</p>
| 0debug
|
static int vp5_parse_coeff(VP56Context *s)
{
VP56RangeCoder *c = &s->c;
VP56Model *model = s->modelp;
uint8_t *permute = s->idct_scantable;
uint8_t *model1, *model2;
int coeff, sign, coeff_idx;
int b, i, cg, idx, ctx, ctx_last;
int pt = 0;
if (c->end >= c->buffer && c->bits >= 0) {
av_log(s->avctx, AV_LOG_ERROR, "End of AC stream reached in vp5_parse_coeff\n");
return AVERROR_INVALIDDATA;
}
for (b=0; b<6; b++) {
int ct = 1;
if (b > 3) pt = 1;
ctx = 6*s->coeff_ctx[ff_vp56_b6to4[b]][0]
+ s->above_blocks[s->above_block_idx[b]].not_null_dc;
model1 = model->coeff_dccv[pt];
model2 = model->coeff_dcct[pt][ctx];
coeff_idx = 0;
for (;;) {
if (vp56_rac_get_prob_branchy(c, model2[0])) {
if (vp56_rac_get_prob_branchy(c, model2[2])) {
if (vp56_rac_get_prob_branchy(c, model2[3])) {
s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx] = 4;
idx = vp56_rac_get_tree(c, ff_vp56_pc_tree, model1);
sign = vp56_rac_get(c);
coeff = ff_vp56_coeff_bias[idx+5];
for (i=ff_vp56_coeff_bit_length[idx]; i>=0; i--)
coeff += vp56_rac_get_prob(c, ff_vp56_coeff_parse_table[idx][i]) << i;
} else {
if (vp56_rac_get_prob_branchy(c, model2[4])) {
coeff = 3 + vp56_rac_get_prob(c, model1[5]);
s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx] = 3;
} else {
coeff = 2;
s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx] = 2;
}
sign = vp56_rac_get(c);
}
ct = 2;
} else {
ct = 1;
s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx] = 1;
sign = vp56_rac_get(c);
coeff = 1;
}
coeff = (coeff ^ -sign) + sign;
if (coeff_idx)
coeff *= s->dequant_ac;
s->block_coeff[b][permute[coeff_idx]] = coeff;
} else {
if (ct && !vp56_rac_get_prob_branchy(c, model2[1]))
break;
ct = 0;
s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx] = 0;
}
coeff_idx++;
if (coeff_idx >= 64)
break;
cg = vp5_coeff_groups[coeff_idx];
ctx = s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx];
model1 = model->coeff_ract[pt][ct][cg];
model2 = cg > 2 ? model1 : model->coeff_acct[pt][ct][cg][ctx];
}
ctx_last = FFMIN(s->coeff_ctx_last[ff_vp56_b6to4[b]], 24);
s->coeff_ctx_last[ff_vp56_b6to4[b]] = coeff_idx;
if (coeff_idx < ctx_last)
for (i=coeff_idx; i<=ctx_last; i++)
s->coeff_ctx[ff_vp56_b6to4[b]][i] = 5;
s->above_blocks[s->above_block_idx[b]].not_null_dc = s->coeff_ctx[ff_vp56_b6to4[b]][0];
}
return 0;
}
| 1threat
|
Passing an options hash to a sidekiq worker : <p>I remember when I tried passing a params (JSON) option to a sidekiq worker method and it didn't work out well because I was referencing the option like:</p>
<pre><code>options[:email_address]
</code></pre>
<p>But I think it would have worked if I did:</p>
<pre><code>options["email_address"]
</code></pre>
<p>So for some reason when it gets serialized and deserialized the hash can only be referenced with a string not a symbol.</p>
<p><strong>Is this a safe practise?</strong></p>
<p>I have a transaction email worker that looks like:</p>
<pre><code>class TransactionEmailWorker
include Sidekiq::Worker
def perform(action, options)
case action
when 'welcome'
welcome(options["email_address"], options["something_else"])
when 'reset_password'
reset_password(options["email_address"])
end
end
def welcome(email, title)
# ...
end
def reset_password(email)
# ..
end
</code></pre>
| 0debug
|
Using an object (Vector3) as a value of a dictionary in Unity C# : Currently, I'm coding a chess game in Unity. What I'm trying to do is have a dictionary which contains each square (A1, A2, etc) as a key value and it's value being a Vector3 object (eg. 0, 0, 10) with the location of square, to which the chess piece would move. Here's my code at the moment.
IDictionary<string, Vector3> locations = new Dictionary<string, Vector3>(){
{"A1", Vector3(0.0f, 0.0f, 0.0f)},
{"A2", Vector3(0.0f, 0.0f, 10.0f)}
};
When I run it, Unity's console says the following:
Expression denotes a `type', where a `variable', `value' or `method group' was expected
Does anyone know how to fix it / a better way to code it?
| 0debug
|
post parameter not being passed zend framework 2 : <p>I've run into a bit of a problem with passing post parameters to a controller action via a ajax call. I'm not sure why it is doing it, because the other ajax calls perform as intended. The response I'm getting is as follows: </p>
<pre><code>Notice: Undefined index: user_bio in C:\xampp\htdocs\module\Members\src\Members\Controller\ProfileController.php on line 149
</code></pre>
<p>The controller code is:</p>
<pre><code>public function changebioAction()
{
$layout = $this->layout();
$layout->setTerminal(true);
$view_model = new ViewModel();
$view_model->setTerminal(true);
if ($this->request->isPost()) {
try {
$params = $this->params()->fromPost();
$this->getProfileService()->editProfile(array('bio' => ltrim($params['user_bio'])));
} catch (ProfileException $e) {
$this->flashMessenger()->addErrorMessage($e->getMessage());
return $this->redirect()->toRoute('members/profile', array('action' => 'change-failure'));
}
}
return $view_model;
}
</code></pre>
<p>The javascript and html:</p>
<pre><code>// handle quick edit of bio
function quickEditBio(element, button) {
var edited_data = $(element).html();
var data = $(element).blur(function() {
edited_data = $(element).map(function() {
return this.innnerHTML;
}).get();
});
$(button).on('click', function() {
$.ajax({
method : "POST",
url : "/members/profile/change-bio",
data : {
user_bio : edited_data[0]
}
}).done(function(msg) {
// bio saved
// go back to profile page
//location.href = '/members/profile';
alert(msg);
}).fail(function() {
alert("Error changing bio, please try again.");
});
});
}
<button onclick="expand('bio')" class="w3-btn-block w3-theme-d2 w3-left-align">
<i class="fa fa-book fa-fw w3-margin-right"></i> Bio
</button>
<div id="bio" class="w3-accordion-content w3-container">
<div class="w3-display-container">
<p id="bio-user" contenteditable="true">
<?php echo $this->layout()->bio; ?>
</p>
<div class="w3-display-right">
<button class="w3-btn-block w3-theme-d2" id="save-bio">Save</button>
</div>
<script type="text/javascript">
quickEditBio('#bio-user[contenteditable=true]', $('#save-bio'));
</script>
</div>
</div>
</code></pre>
<p>As stated before, the error I'm getting is that the index user_bio is undefined :</p>
<pre><code>Notice: Undefined index: user_bio in C:\xampp\htdocs\module\Members\src\Members\Controller\ProfileController.php on line 149
</code></pre>
<p>The part that is really confusing is that other parts use this same code and work just fine. </p>
<p>Any help would be appreciated.</p>
<p>Thanks!</p>
| 0debug
|
static inline void RENAME(hScale)(int16_t *dst, int dstW, const uint8_t *src, int srcW, int xInc,
const int16_t *filter, const int16_t *filterPos, long filterSize)
{
#if COMPILE_TEMPLATE_MMX
assert(filterSize % 4 == 0 && filterSize>0);
if (filterSize==4) {
x86_reg counter= -2*dstW;
filter-= counter*2;
filterPos-= counter/2;
dst-= counter/2;
__asm__ volatile(
#if defined(PIC)
"push %%"REG_b" \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"push %%"REG_BP" \n\t"
"mov %%"REG_a", %%"REG_BP" \n\t"
".p2align 4 \n\t"
"1: \n\t"
"movzwl (%2, %%"REG_BP"), %%eax \n\t"
"movzwl 2(%2, %%"REG_BP"), %%ebx \n\t"
"movq (%1, %%"REG_BP", 4), %%mm1 \n\t"
"movq 8(%1, %%"REG_BP", 4), %%mm3 \n\t"
"movd (%3, %%"REG_a"), %%mm0 \n\t"
"movd (%3, %%"REG_b"), %%mm2 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm0 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"movq %%mm0, %%mm4 \n\t"
"punpckldq %%mm3, %%mm0 \n\t"
"punpckhdq %%mm3, %%mm4 \n\t"
"paddd %%mm4, %%mm0 \n\t"
"psrad $7, %%mm0 \n\t"
"packssdw %%mm0, %%mm0 \n\t"
"movd %%mm0, (%4, %%"REG_BP") \n\t"
"add $4, %%"REG_BP" \n\t"
" jnc 1b \n\t"
"pop %%"REG_BP" \n\t"
#if defined(PIC)
"pop %%"REG_b" \n\t"
#endif
: "+a" (counter)
: "c" (filter), "d" (filterPos), "S" (src), "D" (dst)
#if !defined(PIC)
: "%"REG_b
#endif
);
} else if (filterSize==8) {
x86_reg counter= -2*dstW;
filter-= counter*4;
filterPos-= counter/2;
dst-= counter/2;
__asm__ volatile(
#if defined(PIC)
"push %%"REG_b" \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"push %%"REG_BP" \n\t"
"mov %%"REG_a", %%"REG_BP" \n\t"
".p2align 4 \n\t"
"1: \n\t"
"movzwl (%2, %%"REG_BP"), %%eax \n\t"
"movzwl 2(%2, %%"REG_BP"), %%ebx \n\t"
"movq (%1, %%"REG_BP", 8), %%mm1 \n\t"
"movq 16(%1, %%"REG_BP", 8), %%mm3 \n\t"
"movd (%3, %%"REG_a"), %%mm0 \n\t"
"movd (%3, %%"REG_b"), %%mm2 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm0 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"movq 8(%1, %%"REG_BP", 8), %%mm1 \n\t"
"movq 24(%1, %%"REG_BP", 8), %%mm5 \n\t"
"movd 4(%3, %%"REG_a"), %%mm4 \n\t"
"movd 4(%3, %%"REG_b"), %%mm2 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm4 \n\t"
"pmaddwd %%mm2, %%mm5 \n\t"
"paddd %%mm4, %%mm0 \n\t"
"paddd %%mm5, %%mm3 \n\t"
"movq %%mm0, %%mm4 \n\t"
"punpckldq %%mm3, %%mm0 \n\t"
"punpckhdq %%mm3, %%mm4 \n\t"
"paddd %%mm4, %%mm0 \n\t"
"psrad $7, %%mm0 \n\t"
"packssdw %%mm0, %%mm0 \n\t"
"movd %%mm0, (%4, %%"REG_BP") \n\t"
"add $4, %%"REG_BP" \n\t"
" jnc 1b \n\t"
"pop %%"REG_BP" \n\t"
#if defined(PIC)
"pop %%"REG_b" \n\t"
#endif
: "+a" (counter)
: "c" (filter), "d" (filterPos), "S" (src), "D" (dst)
#if !defined(PIC)
: "%"REG_b
#endif
);
} else {
const uint8_t *offset = src+filterSize;
x86_reg counter= -2*dstW;
filterPos-= counter/2;
dst-= counter/2;
__asm__ volatile(
"pxor %%mm7, %%mm7 \n\t"
".p2align 4 \n\t"
"1: \n\t"
"mov %2, %%"REG_c" \n\t"
"movzwl (%%"REG_c", %0), %%eax \n\t"
"movzwl 2(%%"REG_c", %0), %%edx \n\t"
"mov %5, %%"REG_c" \n\t"
"pxor %%mm4, %%mm4 \n\t"
"pxor %%mm5, %%mm5 \n\t"
"2: \n\t"
"movq (%1), %%mm1 \n\t"
"movq (%1, %6), %%mm3 \n\t"
"movd (%%"REG_c", %%"REG_a"), %%mm0 \n\t"
"movd (%%"REG_c", %%"REG_d"), %%mm2 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"pmaddwd %%mm1, %%mm0 \n\t"
"pmaddwd %%mm2, %%mm3 \n\t"
"paddd %%mm3, %%mm5 \n\t"
"paddd %%mm0, %%mm4 \n\t"
"add $8, %1 \n\t"
"add $4, %%"REG_c" \n\t"
"cmp %4, %%"REG_c" \n\t"
" jb 2b \n\t"
"add %6, %1 \n\t"
"movq %%mm4, %%mm0 \n\t"
"punpckldq %%mm5, %%mm4 \n\t"
"punpckhdq %%mm5, %%mm0 \n\t"
"paddd %%mm0, %%mm4 \n\t"
"psrad $7, %%mm4 \n\t"
"packssdw %%mm4, %%mm4 \n\t"
"mov %3, %%"REG_a" \n\t"
"movd %%mm4, (%%"REG_a", %0) \n\t"
"add $4, %0 \n\t"
" jnc 1b \n\t"
: "+r" (counter), "+r" (filter)
: "m" (filterPos), "m" (dst), "m"(offset),
"m" (src), "r" ((x86_reg)filterSize*2)
: "%"REG_a, "%"REG_c, "%"REG_d
);
}
#else
#if COMPILE_TEMPLATE_ALTIVEC
hScale_altivec_real(dst, dstW, src, srcW, xInc, filter, filterPos, filterSize);
#else
int i;
for (i=0; i<dstW; i++) {
int j;
int srcPos= filterPos[i];
int val=0;
for (j=0; j<filterSize; j++) {
val += ((int)src[srcPos + j])*filter[filterSize*i + j];
}
dst[i] = FFMIN(val>>7, (1<<15)-1);
}
#endif
#endif
}
| 1threat
|
Ruby on Rails Purchase item from Amazon using API? : <p>I'd like to programmatically automate making a purchase on Amazon from my rails app as I have to manually make the same purchases week after week. This would be using my own billing information/account, not on behalf of a user.</p>
<p>I've searched through most of their APIs and found that you can search for an item, add it to a cart, etc. but I can't seem to find a way to actually make the purchase.</p>
<p>Does anyone know of a way to do this via API? It'd be great automate our manual process. It seems like it should be possible as <a href="https://zincapi.com/" rel="noreferrer">https://zincapi.com/</a> seems to facilitate this.</p>
| 0debug
|
Replace an element in array using jquery : I have got this array
var left=[323,345,654,123];
How can i replace `345` using Jquery I have tried
left[2]=456
But it did not really work
| 0debug
|
Replace option value text from select with Javascript : <p>I need to replace the text English from option value with javascript. Code is next:</p>
<pre><code><div>
<select name="input_14" id="input_29_14">
<option value="English">English</option>
</select>
</div>
</code></pre>
<p>So this is what I tried:</p>
<pre><code>document.querySelector("div.selector option[value=English]").text = "Inglés";
</code></pre>
<p>But it doesn't change the text. Anyone can provide me an alternative function?</p>
<p>Thank you</p>
| 0debug
|
Chech whether the USER is authenticated/not while trying to browse using direct URL : Thanks in advance.
I want to restrict users based on their authorization to my application while they are trying to access URL directly in browser. We are getting the flags from Database table whether the user has access to perticular services or not. We are having n number of controllers, so I can't use session variables. Can you please suggest that how can I use those flags to restrict users by custom actionfilters.
| 0debug
|
static void mpic_irq_raise(openpic_t *mpp, int n_CPU, IRQ_src_t *src)
{
int n_ci = IDR_CI0 - n_CPU;
if(test_bit(&src->ide, n_ci)) {
qemu_irq_raise(mpp->dst[n_CPU].irqs[OPENPIC_OUTPUT_CINT]);
}
else {
qemu_irq_raise(mpp->dst[n_CPU].irqs[OPENPIC_OUTPUT_INT]);
}
}
| 1threat
|
What is my Lambda doing between startup and first line? : <p>I have some Lambda functions written in C# running in the .NET Core 2.1 runtime in AWS. The cold start time on them is very large (>8s with 256MB, >4s with 512).</p>
<p>However, I'm not sure if it is just cold start time or something else; I have other lambdas that are written in dotnet and they seem to have shorter startup times. </p>
<p>An X-Ray trace shows a big gap between "Initilization" being completed and anything happening. I start an X-Ray subsegment on the first line of my handler (seen in the trace as "Configure").</p>
<p>Is there something I'm missing?</p>
<p><a href="https://i.stack.imgur.com/bDeDq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bDeDq.png" alt="AWS X-Ray trace"></a></p>
| 0debug
|
How to write the definition of a derived class in c++? : <p>I don't know the syntax for writing the definition of a class function with templates. </p>
<p>I get an error, the complier expected ; , so that be
void plus;
Anyone knows to fix that!</p>
<pre><code>template<class Type
class basic{
protected:
Type x;
public:
int value;
//virtual void print() =0;
basic(Type xArg):x(xArg){}
};
template<class Type>
class plus:public basic<Type>{
public:
Type y;
plus(Type xArg, Type yArg):basic<Type>(xArg),y(yArg){}
void print();
};
//template<class Type>
void plus<Type>::print(){
cout << "x : " << x << endl;
cout << "y : " << y << endl;
}
</code></pre>
| 0debug
|
How would you automate downloading a file from a site everyday using python? : <p>How to automate the download a file from this page <a href="https://www.nseindia.com/products/content/equities/equities/homepage_eq.htm" rel="nofollow noreferrer">https://www.nseindia.com/products/content/equities/equities/homepage_eq.htm</a>, I tried it using python using urllib.</p>
<pre><code>import urllib
testfile = urllib.URLopener()
testfile.retrieve("https://www.nseindia.com/products/content/historical/EQUITIES/2017/JUN?cm23JUN2017bhav.csv.zip8", "file.zip8")
</code></pre>
<p>Even that doesn't seem to work I don't know why but how do you go about downloading file from such a site with changing uri to files, just see pattern and add code like in the above case using <em>dates</em>? and why doesn't the above code work?</p>
| 0debug
|
static void test_visitor_in_alternate(TestInputVisitorData *data,
const void *unused)
{
Visitor *v;
Error *err = NULL;
UserDefAlternate *tmp;
WrapAlternate *wrap;
v = visitor_input_test_init(data, "42");
visit_type_UserDefAlternate(v, NULL, &tmp, &error_abort);
g_assert_cmpint(tmp->type, ==, QTYPE_QINT);
g_assert_cmpint(tmp->u.i, ==, 42);
qapi_free_UserDefAlternate(tmp);
v = visitor_input_test_init(data, "'string'");
visit_type_UserDefAlternate(v, NULL, &tmp, &error_abort);
g_assert_cmpint(tmp->type, ==, QTYPE_QSTRING);
g_assert_cmpstr(tmp->u.s, ==, "string");
qapi_free_UserDefAlternate(tmp);
v = visitor_input_test_init(data, "{'integer':1, 'string':'str', "
"'enum1':'value1', 'boolean':true}");
visit_type_UserDefAlternate(v, NULL, &tmp, &error_abort);
g_assert_cmpint(tmp->type, ==, QTYPE_QDICT);
g_assert_cmpint(tmp->u.udfu->integer, ==, 1);
g_assert_cmpstr(tmp->u.udfu->string, ==, "str");
g_assert_cmpint(tmp->u.udfu->enum1, ==, ENUM_ONE_VALUE1);
g_assert_cmpint(tmp->u.udfu->u.value1->boolean, ==, true);
g_assert_cmpint(tmp->u.udfu->u.value1->has_a_b, ==, false);
qapi_free_UserDefAlternate(tmp);
v = visitor_input_test_init(data, "false");
visit_type_UserDefAlternate(v, NULL, &tmp, &err);
error_free_or_abort(&err);
qapi_free_UserDefAlternate(tmp);
v = visitor_input_test_init(data, "{ 'alt': 42 }");
visit_type_WrapAlternate(v, NULL, &wrap, &error_abort);
g_assert_cmpint(wrap->alt->type, ==, QTYPE_QINT);
g_assert_cmpint(wrap->alt->u.i, ==, 42);
qapi_free_WrapAlternate(wrap);
v = visitor_input_test_init(data, "{ 'alt': 'string' }");
visit_type_WrapAlternate(v, NULL, &wrap, &error_abort);
g_assert_cmpint(wrap->alt->type, ==, QTYPE_QSTRING);
g_assert_cmpstr(wrap->alt->u.s, ==, "string");
qapi_free_WrapAlternate(wrap);
v = visitor_input_test_init(data, "{ 'alt': {'integer':1, 'string':'str', "
"'enum1':'value1', 'boolean':true} }");
visit_type_WrapAlternate(v, NULL, &wrap, &error_abort);
g_assert_cmpint(wrap->alt->type, ==, QTYPE_QDICT);
g_assert_cmpint(wrap->alt->u.udfu->integer, ==, 1);
g_assert_cmpstr(wrap->alt->u.udfu->string, ==, "str");
g_assert_cmpint(wrap->alt->u.udfu->enum1, ==, ENUM_ONE_VALUE1);
g_assert_cmpint(wrap->alt->u.udfu->u.value1->boolean, ==, true);
g_assert_cmpint(wrap->alt->u.udfu->u.value1->has_a_b, ==, false);
qapi_free_WrapAlternate(wrap);
}
| 1threat
|
Running R and packages on GCP cloud function : <p>I have been using AWS Lambda to execute some R code by packaging the dependencies (CRAN Packages) and deploying it along with AWS Lambda.
This helps me parrallelise running a small chunk of R code over huge set of data compared to running it on an instance.
I have referred to this article <a href="https://aws.amazon.com/blogs/compute/analyzing-genomics-data-at-scale-using-r-aws-lambda-and-amazon-api-gateway/" rel="noreferrer">GENOMICS ON AWS LAMBDA</a>
The Lambda executes using RPY2 on Python.</p>
<p>I am exploring possibility of running the R code on Google Cloud Functions as I am using Big Query for querying some data.</p>
<p>I see that Google Cloud Functions now supports only NodeJS. There are few ways to execute R script from NodeJS.
<a href="https://www.npmjs.com/package/r-script" rel="noreferrer">NPM</a>
<a href="https://stackoverflow.com/questions/17665565/is-there-a-way-to-run-r-code-from-javascript">Stackoverflow</a></p>
<p>But I need to package all the necessary packages to run my R code also. On AWS I did it by using a AWS AMI to install all R packages then create a Zip which would get deployed.</p>
<p>I wonder if someone has tried running R code with packages on Google Cloud functions.</p>
| 0debug
|
static void switch_v7m_sp(CPUARMState *env, bool new_spsel)
{
uint32_t tmp;
bool old_spsel = env->v7m.control & R_V7M_CONTROL_SPSEL_MASK;
if (old_spsel != new_spsel) {
tmp = env->v7m.other_sp;
env->v7m.other_sp = env->regs[13];
env->regs[13] = tmp;
env->v7m.control = deposit32(env->v7m.control,
R_V7M_CONTROL_SPSEL_SHIFT,
R_V7M_CONTROL_SPSEL_LENGTH, new_spsel);
}
}
| 1threat
|
How to save leap date '02/29/2006' to sql server database? : <p>I can' t save this leap date '02/29/2006' to sql server database. I'm using C#. Is there any particular code for this? Your help will be very much appreciated. Thanks</p>
| 0debug
|
Run cmd locally from webpage : <p>I am trying to have a webpage call a cmd command and execute on the local machine hitting the page and not the web server. Any ideas of how this could be done? </p>
| 0debug
|
Spark DataFrame mapPartitions : <p>I need to proceed distributed calculation on Spark DataFrame invoking some arbitrary (not SQL) logic on chunks of DataFrame.
I did:</p>
<pre><code>def some_func(df_chunk):
pan_df = df_chunk.toPandas()
#whatever logic here
df = sqlContext.read.parquet(...)
result = df.mapPartitions(some_func)
</code></pre>
<p>Unfortunatelly it leads to:</p>
<blockquote>
<p>AttributeError: 'itertools.chain' object has no attribute 'toPandas'</p>
</blockquote>
<p>I expected to have spark DataFrame object within each map invocation, instead I got 'itertools.chain'. Why? And how to overcome this?</p>
| 0debug
|
int av_copy_packet_side_data(AVPacket *pkt, AVPacket *src)
{
if (src->side_data_elems) {
int i;
DUP_DATA(pkt->side_data, src->side_data,
src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC);
memset(pkt->side_data, 0,
src->side_data_elems * sizeof(*src->side_data));
for (i = 0; i < src->side_data_elems; i++) {
DUP_DATA(pkt->side_data[i].data, src->side_data[i].data,
src->side_data[i].size, 1, ALLOC_MALLOC);
pkt->side_data[i].size = src->side_data[i].size;
pkt->side_data[i].type = src->side_data[i].type;
}
}
return 0;
failed_alloc:
av_destruct_packet(pkt);
return AVERROR(ENOMEM);
}
| 1threat
|
Issue with creating a VIEW inside a Stored Procedure : I needed to Parse a JSON string from a column in a SQL Server 2008 r2 table, so I used 2 Views and 3 tables and several stepped queries. Everything worked. Now after populating several databases I need to allow for Triggers to be placed on a specific table. Since only a Stored Procedure can be called from a Trigger I was converting everything into an SP. All went well except for a CREATE VIEW statement. I've wrapped that into EXEC but I'm still getting a syntax error regarding an unclosed quote. I've tried several different ways of enclosing keywords but nothing worked. Here's a snippet of the code:
EXEC ('If object_ID(''vw_BuildLookup01'',''V'') IS NOT NULL
DROP VIEW vw_BuildLookup01;')
EXEC ('If object_ID(''vw_BuildLookup02'',''V'') IS NOT NULL
DROP VIEW vw_BuildLookup02;')
EXEC ('CREATE VIEW [dbo].[vw_BuildLookup01]
AS
SELECT DISTINCT t.tblKey, t.Name AS MetricTypesName, m.tblKey AS MetricKey, m.Name AS MetricName, m.MetricLimitedValues, f.Value
FROM OccurrenceMetricFacts f
INNER JOIN Metrics m ON f.MetricKey = m.tblKey
INNER JOIN MetricTypes t ON m.MetricTypeKey = t.tblKey
WHERE m.MetricLimitedValues IS NOT NULL AND t.DeletedDate IS NULL AND f.Value IS NOT NULL
')
EXEC ('CREATE VIEW [dbo].[vw_BuildLookup02]
AS
SELECT v.tblKey, v.MetricTypesName, v.MetricKey, v.MetricName,
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(v.MetricLimitedValues, '"Name":"', ''),'","Value"', ''),'{', ''), '}',''),'[', ''), ']', '') AS MetricLimitedValues, v.Value
FROM vw_BuildLookup01 v
INNER JOIN MetricTypes t ON t.tblKey = v.tblKey
WHERE t.DeletedDate IS NULL
')
The syntax error is in the CREATE VIEW [dbo].[vw_BuildLookup02] after the nested REPLACE commands the '"Name":"' has the dreaded red squiggly line underneath. I've read too many articles, rewrote the query too many ways, I need help. Thanks in advance.
| 0debug
|
printing session variables in php : <p>How do I print these sessions using the <code>print_r</code> function. <br>
I'm new to php.<br><br>
Theses are the sessions.</p>
<pre><code>$studentID = $_SESSION['StudentID'];
$offeringID=$_SESSION['OfferingID'];
$email=$_SESSION['email'];
</code></pre>
<p><br>
Any help would be very much appreciated.</p>
| 0debug
|
Incorrect syntax near COUNT(*) : <pre><code>SELECT D.Drank_Naam , D.Drank_Prijs, SUM(K.Aantal) AS Aantal COUNT(*) AS StudentDeelnemer,
+ FROM Kassa K,
+ JOIN DrankVoorraad AS D ON K.Drink_ID = D.ID,
+ JOIN StudentDeelnemer AS S on K.Student_Id = S.StudentNummer,
+ group by D.Drank_Naam, D.Drank_Prijs;
</code></pre>
<p>I want to calculate the sum of drinks sold and the price, but i get an incorrect syntax near COUNT(*)</p>
| 0debug
|
CSV Upload in SQL : I am working on sql server. I am trying to insert a csv file into a table in the database. The process needs to be automated since it will be done on a monthly basis with many files. The issue that i am facing is, in the data the last row has an arrow in it. It is not a character but seems to be because of the process' done to create the csv file. I want a way to upload all the data without that arrow. Number of rows changes every month. Request help for the same. Thank you in advance.
| 0debug
|
static int mov_get_h264_codec_tag(AVFormatContext *s, MOVTrack *track)
{
int tag = track->par->codec_tag;
int interlaced = track->par->field_order > AV_FIELD_PROGRESSIVE;
AVStream *st = track->st;
int rate = av_q2d(find_fps(s, st));
if (!tag)
tag = MKTAG('a', 'v', 'c', 'i');
if (track->par->format == AV_PIX_FMT_YUV420P10) {
if (track->par->width == 960 && track->par->height == 720) {
if (!interlaced) {
if (rate == 24) tag = MKTAG('a','i','5','p');
else if (rate == 25) tag = MKTAG('a','i','5','q');
else if (rate == 30) tag = MKTAG('a','i','5','p');
else if (rate == 50) tag = MKTAG('a','i','5','q');
else if (rate == 60) tag = MKTAG('a','i','5','p');
}
} else if (track->par->width == 1440 && track->par->height == 1080) {
if (!interlaced) {
if (rate == 24) tag = MKTAG('a','i','5','3');
else if (rate == 25) tag = MKTAG('a','i','5','2');
else if (rate == 30) tag = MKTAG('a','i','5','3');
} else {
if (rate == 50) tag = MKTAG('a','i','5','5');
else if (rate == 60) tag = MKTAG('a','i','5','6');
}
}
} else if (track->par->format == AV_PIX_FMT_YUV422P10) {
if (track->par->width == 1280 && track->par->height == 720) {
if (!interlaced) {
if (rate == 24) tag = MKTAG('a','i','1','p');
else if (rate == 25) tag = MKTAG('a','i','1','q');
else if (rate == 30) tag = MKTAG('a','i','1','p');
else if (rate == 50) tag = MKTAG('a','i','1','q');
else if (rate == 60) tag = MKTAG('a','i','1','p');
}
} else if (track->par->width == 1920 && track->par->height == 1080) {
if (!interlaced) {
if (rate == 24) tag = MKTAG('a','i','1','3');
else if (rate == 25) tag = MKTAG('a','i','1','2');
else if (rate == 30) tag = MKTAG('a','i','1','3');
} else {
if (rate == 25) tag = MKTAG('a','i','1','5');
else if (rate == 50) tag = MKTAG('a','i','1','5');
else if (rate == 60) tag = MKTAG('a','i','1','6');
}
} else if ( track->par->width == 4096 && track->par->height == 2160
|| track->par->width == 3840 && track->par->height == 2160
|| track->par->width == 2048 && track->par->height == 1080) {
tag = MKTAG('a','i','v','x');
}
}
return tag;
}
| 1threat
|
static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc,
TCGv r_cond)
{
unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29));
target_ulong target = dc->pc + offset;
if (cond == 0x0) {
if (a) {
dc->pc = dc->npc + 4;
dc->npc = dc->pc + 4;
} else {
dc->pc = dc->npc;
dc->npc = dc->pc + 4;
}
} else if (cond == 0x8) {
if (a) {
dc->pc = target;
dc->npc = dc->pc + 4;
} else {
dc->pc = dc->npc;
dc->npc = target;
tcg_gen_mov_tl(cpu_pc, cpu_npc);
}
} else {
flush_cond(dc, r_cond);
gen_fcond(r_cond, cc, cond);
if (a) {
gen_branch_a(dc, target, dc->npc, r_cond);
dc->is_br = 1;
} else {
dc->pc = dc->npc;
dc->jump_pc[0] = target;
dc->jump_pc[1] = dc->npc + 4;
dc->npc = JUMP_PC;
}
}
}
| 1threat
|
static void guess_dc(MpegEncContext *s, int16_t *dc, int w,
int h, int stride, int is_luma)
{
int b_x, b_y;
int16_t (*col )[4] = av_malloc(stride*h*sizeof( int16_t)*4);
uint32_t (*dist)[4] = av_malloc(stride*h*sizeof(uint32_t)*4);
if(!col || !dist) {
av_log(s->avctx, AV_LOG_ERROR, "guess_dc() is out of memory\n");
goto fail;
}
for(b_y=0; b_y<h; b_y++){
int color= 1024;
int distance= -1;
for(b_x=0; b_x<w; b_x++){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_x;
}
col [b_x + b_y*stride][1]= color;
dist[b_x + b_y*stride][1]= distance >= 0 ? b_x-distance : 9999;
}
color= 1024;
distance= -1;
for(b_x=w-1; b_x>=0; b_x--){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_x;
}
col [b_x + b_y*stride][0]= color;
dist[b_x + b_y*stride][0]= distance >= 0 ? distance-b_x : 9999;
}
}
for(b_x=0; b_x<w; b_x++){
int color= 1024;
int distance= -1;
for(b_y=0; b_y<h; b_y++){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_y;
}
col [b_x + b_y*stride][3]= color;
dist[b_x + b_y*stride][3]= distance >= 0 ? b_y-distance : 9999;
}
color= 1024;
distance= -1;
for(b_y=h-1; b_y>=0; b_y--){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_y;
}
col [b_x + b_y*stride][2]= color;
dist[b_x + b_y*stride][2]= distance >= 0 ? distance-b_y : 9999;
}
}
for (b_y = 0; b_y < h; b_y++) {
for (b_x = 0; b_x < w; b_x++) {
int mb_index, error, j;
int64_t guess, weight_sum;
mb_index = (b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride;
error = s->error_status_table[mb_index];
if (IS_INTER(s->current_picture.f.mb_type[mb_index]))
continue;
if (!(error & ER_DC_ERROR))
continue;
weight_sum = 0;
guess = 0;
for (j = 0; j < 4; j++) {
int64_t weight = 256 * 256 * 256 * 16 / FFMAX(dist[b_x + b_y*stride][j], 1);
guess += weight*(int64_t)col[b_x + b_y*stride][j];
weight_sum += weight;
}
guess = (guess + weight_sum / 2) / weight_sum;
dc[b_x + b_y * stride] = guess;
}
}
av_freep(&col);
av_freep(&dist);
}
| 1threat
|
How to escap "..." : <p>I R imports columns with no colname as ...1 I need to replace this ... with something else</p>
<p>Trying:</p>
<pre><code>str_replace("hi_...","/././.","&")
</code></pre>
| 0debug
|
Three gray dots under variable names in Visual Studio : <p><img src="https://i.stack.imgur.com/xiexo.png" alt="Two variable names with three gray dots under each of them"></p>
<p>What do these three gray dots mean? I recently updated to Visual Studio 2017, and I haven't ever seen them in other versions of VS.</p>
| 0debug
|
static int coroutine_enter_func(void *arg)
{
Coroutine *co = arg;
qemu_coroutine_enter(co, NULL);
return 0;
}
| 1threat
|
static BlockDriverState *get_bs_snapshots(void)
{
BlockDriverState *bs;
DriveInfo *dinfo;
if (bs_snapshots)
return bs_snapshots;
TAILQ_FOREACH(dinfo, &drives, next) {
bs = dinfo->bdrv;
if (bdrv_can_snapshot(bs))
goto ok;
}
return NULL;
ok:
bs_snapshots = bs;
return bs;
}
| 1threat
|
void ppce500_init(PPCE500Params *params)
{
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
PCIBus *pci_bus;
CPUPPCState *env = NULL;
uint64_t elf_entry;
uint64_t elf_lowaddr;
hwaddr entry=0;
hwaddr loadaddr=UIMAGE_LOAD_BASE;
target_long kernel_size=0;
target_ulong dt_base = 0;
target_ulong initrd_base = 0;
target_long initrd_size=0;
int i=0;
unsigned int pci_irq_nrs[4] = {1, 2, 3, 4};
qemu_irq **irqs, *mpic;
DeviceState *dev;
CPUPPCState *firstenv = NULL;
MemoryRegion *ccsr_addr_space;
SysBusDevice *s;
PPCE500CCSRState *ccsr;
if (params->cpu_model == NULL) {
params->cpu_model = "e500v2_v30";
}
irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *));
irqs[0] = g_malloc0(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
for (i = 0; i < smp_cpus; i++) {
PowerPCCPU *cpu;
qemu_irq *input;
cpu = cpu_ppc_init(params->cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to initialize CPU!\n");
exit(1);
}
env = &cpu->env;
if (!firstenv) {
firstenv = env;
}
irqs[i] = irqs[0] + (i * OPENPIC_OUTPUT_NB);
input = (qemu_irq *)env->irq_inputs;
irqs[i][OPENPIC_OUTPUT_INT] = input[PPCE500_INPUT_INT];
irqs[i][OPENPIC_OUTPUT_CINT] = input[PPCE500_INPUT_CINT];
env->spr[SPR_BOOKE_PIR] = env->cpu_index = i;
env->mpic_cpu_base = MPC8544_CCSRBAR_BASE +
MPC8544_MPIC_REGS_OFFSET + 0x20000;
ppc_booke_timers_init(env, 400000000, PPC_TIMER_E500);
if (!i) {
struct boot_info *boot_info;
boot_info = g_malloc0(sizeof(struct boot_info));
qemu_register_reset(ppce500_cpu_reset, cpu);
env->load_info = boot_info;
} else {
qemu_register_reset(ppce500_cpu_reset_sec, cpu);
}
}
env = firstenv;
ram_size &= ~(RAM_SIZES_ALIGN - 1);
memory_region_init_ram(ram, "mpc8544ds.ram", ram_size);
vmstate_register_ram_global(ram);
memory_region_add_subregion(address_space_mem, 0, ram);
dev = qdev_create(NULL, "e500-ccsr");
object_property_add_child(qdev_get_machine(), "e500-ccsr",
OBJECT(dev), NULL);
qdev_init_nofail(dev);
ccsr = CCSR(dev);
ccsr_addr_space = &ccsr->ccsr_space;
memory_region_add_subregion(address_space_mem, MPC8544_CCSRBAR_BASE,
ccsr_addr_space);
mpic = mpic_init(ccsr_addr_space, MPC8544_MPIC_REGS_OFFSET,
smp_cpus, irqs, NULL);
if (!mpic) {
cpu_abort(env, "MPIC failed to initialize\n");
}
if (serial_hds[0]) {
serial_mm_init(ccsr_addr_space, MPC8544_SERIAL0_REGS_OFFSET,
0, mpic[42], 399193,
serial_hds[0], DEVICE_BIG_ENDIAN);
}
if (serial_hds[1]) {
serial_mm_init(ccsr_addr_space, MPC8544_SERIAL1_REGS_OFFSET,
0, mpic[42], 399193,
serial_hds[1], DEVICE_BIG_ENDIAN);
}
dev = qdev_create(NULL, "mpc8544-guts");
qdev_init_nofail(dev);
s = SYS_BUS_DEVICE(dev);
memory_region_add_subregion(ccsr_addr_space, MPC8544_UTIL_OFFSET,
sysbus_mmio_get_region(s, 0));
dev = qdev_create(NULL, "e500-pcihost");
qdev_init_nofail(dev);
s = SYS_BUS_DEVICE(dev);
sysbus_connect_irq(s, 0, mpic[pci_irq_nrs[0]]);
sysbus_connect_irq(s, 1, mpic[pci_irq_nrs[1]]);
sysbus_connect_irq(s, 2, mpic[pci_irq_nrs[2]]);
sysbus_connect_irq(s, 3, mpic[pci_irq_nrs[3]]);
memory_region_add_subregion(ccsr_addr_space, MPC8544_PCI_REGS_OFFSET,
sysbus_mmio_get_region(s, 0));
pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0");
if (!pci_bus)
printf("couldn't create PCI controller!\n");
sysbus_mmio_map(sysbus_from_qdev(dev), 1, MPC8544_PCI_IO);
if (pci_bus) {
for (i = 0; i < nb_nics; i++) {
pci_nic_init_nofail(&nd_table[i], "virtio", NULL);
}
}
sysbus_create_simple("e500-spin", MPC8544_SPIN_BASE, NULL);
if (params->kernel_filename) {
kernel_size = load_uimage(params->kernel_filename, &entry,
&loadaddr, NULL);
if (kernel_size < 0) {
kernel_size = load_elf(params->kernel_filename, NULL, NULL,
&elf_entry, &elf_lowaddr, NULL, 1,
ELF_MACHINE, 0);
entry = elf_entry;
loadaddr = elf_lowaddr;
}
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
params->kernel_filename);
exit(1);
}
}
if (params->initrd_filename) {
initrd_base = (loadaddr + kernel_size + INITRD_LOAD_PAD) &
~INITRD_PAD_MASK;
initrd_size = load_image_targphys(params->initrd_filename, initrd_base,
ram_size - initrd_base);
if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
params->initrd_filename);
exit(1);
}
}
if (params->kernel_filename) {
struct boot_info *boot_info;
int dt_size;
dt_base = (loadaddr + kernel_size + DTC_LOAD_PAD) & ~DTC_PAD_MASK;
dt_size = ppce500_load_device_tree(env, params, dt_base, initrd_base,
initrd_size);
if (dt_size < 0) {
fprintf(stderr, "couldn't load device tree\n");
exit(1);
}
boot_info = env->load_info;
boot_info->entry = entry;
boot_info->dt_base = dt_base;
boot_info->dt_size = dt_size;
}
if (kvm_enabled()) {
kvmppc_init();
}
}
| 1threat
|
Fragment open on click event of button : Hey Guys I know its very silly question but i'm facing it from last few days
This is my click event
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this,NewCase.class);
startActivity(i);
Fragment newCase = new NewCase();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(, newCase ); // give your fragment container id in first parameter
transaction.addToBackStack(null); // if written, this transaction will be added to backstack
transaction.commit();
}
});
And this is my fragment class
public class NewCase extends Fragment {}
Now let me know how to open fragment class with xml view in android Thanks in advance
| 0debug
|
angular2 and formControlName value in template : <p>Oh angular2...why so hard?</p>
<pre><code><input type="text" formControlName="exposure" type="hidden">
<label>{{exposure}}</label>
</code></pre>
<p>If I use the formControlName in the input the value is correct.</p>
<p>How do I get the value of exposure in template? Its blank in the label</p>
| 0debug
|
Dump executable memory regions content : A project i'm working on requires me to log every executable regions content, at any time.
By 'log', i mean:
- Save the content of the pages into a file.
- Save the range addresses of the regions into a file.
- Intercept changes in the address you've already saved, update the log file
with the new content of the pages.
My current implementation assumes DEP support, and it is a simple automata:
1. Inject a DLL into the process before the entry point is executed.
2. Register an exception handler via: `AddVectoredExceptionHandler`
3. Iterate on the process virtual memory layout(Using `VirtualQueryEx`) log every executable region, and turn off the execute permission(if exists) for that region.
4. Hook `NtProtectVirtualMemory`, `NtAllocateVirtualMemory`.
4. Jump to the process's entry point.
If someone changed a region protection to: `PAGE_EXECUTE_READWRITE` `PAGE_EXECUTE` `PAGE_EXECUTE_READ`, i intercept that in the Ntdll hooks, disable the execute permission for these pages, and log them.
Now, everytime an exception is thrown, i check if the address that triggered the exception is caused by any of the regions that i logged. If it did, it means that someone tried to execute one of the pages, so i turn on the execute permission via `VirtualProtect`, and turn of the write permission(if present)
Next, if i get an exception for the same region, it means that the process tried to write to it, so i enable the write permission, and disable the execute.
Next time i get an exception, i will log the region.
This method seems to work on 99% of the cases, but results in very poor performence and massive process flow interference. Also, it seems that i don't catch every exception, so on some application just crash because i can't enable the execution.
Any ideas on how to improve performence / use a whole new method?
| 0debug
|
int qemu_chr_fe_get_msgfd(CharDriverState *s)
{
int fd;
return (qemu_chr_fe_get_msgfds(s, &fd, 1) == 1) ? fd : -1;
}
| 1threat
|
I keep getting compiling error expected ‘;’, identifier or ‘(’ before ‘void’ void *runner(void *param) : <p>I am trying to compile this c program that uses threads to multiple matrices together. However I keep getting this error. </p>
<p>expected ‘;’, identifier or ‘(’ before ‘void’
void *runner(void *param)</p>
<p>Below is the code that it is referring to.</p>
<pre><code>//The thread will begin control in this function
void *runner(void *param)
{
struct v *data = param;
int n, sum = 0;
for(n = 0; n < X; n++)
{
sum += a[data->i][n] * b[n][data->j];
}
c[data->i][data->j] = sum;
pthread_exit(0);
}
void *runner(void *param);
</code></pre>
| 0debug
|
jQuery clone variable content into a div : I have a button which on click will append the content before an element. But instead I need to append the content to the **closest parent** div of the button. (.content div)
[JS Fiddle][1]
$('#layoutTextArea').click(function(){
var toAppend=$('#appendTextArea').children();
toAppend.clone().insertBefore('#layoutCanvas');
});
HTML
<div id="layoutCanvas">
<div class="content">
<p>
On click of the button append within "content" div
</p>
<button id="layoutTextArea" class="btn btn-primary">Click Here</button>
</div>
</div>
<div class="d-none" id="appendTextArea">
<h1>
Test Block
</h1>
</div>
[1]: http://jsfiddle.net/680u7p2m/
| 0debug
|
Database suggestion for chat app Java : <p>I am building p2p Chat in Java and I need a DB for accounts, friendlists and whoIsOnline. My idea is to create a server, which is receiving periodicly KeepAlive messages and updates whoIsOnline list, then sends back to clients this list only for their friendlists. Any suggestion what DB should I use?</p>
| 0debug
|
Is it possible to write a code of c++ one input swap Without using any CONDITIONAL statement? : Is it possible to write a code of c++ like if we enter 9 then the program return 6 and if we input 6 the program return us 9 as output? Without using any CONDITIONAL statement?
| 0debug
|
Responsive tool for showing me the current browser size : <p>I am looking for a <strong>tool</strong> out there with which I can determine the <strong>current browser size</strong> to find out the <strong>breakpoints</strong> for <strong>responsive design</strong>...</p>
<p>And an other question i´m interesting in is...
how do you deal with those issues to find your breakpoints doing responive design in HTML/CSS?</p>
| 0debug
|
R data.table - Need to convert char type data.table column to date type : I have a data.table with a column named 'Date'and type char and it looks like below. I need to convert this to date type column so that i can perform date operations.
Date
"10/11/2018"
"13/11/2013"
"22/11/2011"
"--"
"--"
"10/11/2018"
I tried this, but doesnt work - MyTable$Date <- as.POXISlt(MyTable$Date)
| 0debug
|
What is the difference between Enum and a SinglTone class : I found few of the difference between Enum and Singletone class but not fully convinced whether ENum can be used in place of Singletone or not.
And if it can be used then what is the need of defining singleton class?
| 0debug
|
start next line from the first for text view : [![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/SPbBB.jpg
i have to text view in each line and i want the next line start from the start of layout but it start from where text view is placed . is there any attribute for text view to achieve this ?
<RelativeLayout
android:layout_width="match_parent"
android:layout_marginTop="5dp"
android:id="@+id/relative_english"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="MainTranslation:"
android:textColor="@android:color/holo_green_light"
android:id="@+id/english_lable_offer"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="saf"
android:id="@+id/tv_english_show_offer"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/english_lable_offer"
android:layout_toEndOf="@+id/english_lable_offer" />
</RelativeLayout>
this are my code for my text views
| 0debug
|
Array size and elements by user input : <p>I want a program that asks first for the size of an array and next asks for the element. The size of the array is int and the stored values are double. Like this:</p>
<pre><code>How many numbers? 5 // 5 is user input
Please type the numbers:
1,111
4
11,45
21
3
The numbers in reverse order are:
3.0 21.0 11.45 4.0 1.111
</code></pre>
<p>My problem is, how to ask for the size and for the elements? Thanks in advance!</p>
| 0debug
|
How can I use 'watch' in my npm scripts? : <p>I have the following directory structure:</p>
<p><a href="https://i.stack.imgur.com/0yvkT.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/0yvkT.jpg" alt="enter image description here"></a></p>
<p>And my <code>package.json</code> looks like this:</p>
<pre><code>{
"name": "personal_site",
"version": "1.0.0",
"description": "My personal website.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"node-sass": "node-sass --output-style compressed --include-path node_modules/bourbon/app/assets/stylesheets/ --include-path node_modules/bourbon-neat/app/assets/stylesheets/ 'src/scss/styles.scss' 'dist/css/bundle.min.css'",
"html-minifier": "html-minifier --collapse-whitespace --remove-comments --remove-attribute-quotes -o 'dist/index.html' 'src/index.html'",
"imagemin": "imagemin src/images dist/images",
"serve": "http-server ./dist"
},
"author": "Dean Gibson",
"license": "ISC",
"dependencies": {
"bourbon": "^4.2.6",
"bourbon-neat": "^1.7.4",
"normalize-scss": "^4.0.3"
},
"devDependencies": {
"html-minifier": "^1.3.0",
"http-server": "^0.9.0",
"node-sass": "^3.4.2"
}
}
</code></pre>
<p>So firstly, I have to run each of these scripts individually e.g. <code>npm run node-sass</code> or <code>npm run html-minifier</code> etc. What I'd ideally want is to run <code>npm serve</code> which will do the following:</p>
<ol>
<li>run html-minifier </li>
<li>run node-sass </li>
<li>run run image-min </li>
<li>run http-server </li>
<li>Lastly, watch everything in my <code>src</code> folder and run
the respective scripts as files change e.g. <code>node-sass</code> etc..</li>
</ol>
<p>How can I best tackle this problem?</p>
| 0debug
|
static av_always_inline int cmp_inline(MpegEncContext *s, const int x, const int y, const int subx, const int suby,
const int size, const int h, int ref_index, int src_index,
me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, int qpel, int chroma){
MotionEstContext * const c= &s->me;
const int stride= c->stride;
const int uvstride= c->uvstride;
const int dxy= subx + (suby<<(1+qpel));
const int hx= subx + (x<<(1+qpel));
const int hy= suby + (y<<(1+qpel));
uint8_t * const * const ref= c->ref[ref_index];
uint8_t * const * const src= c->src[src_index];
int d;
int uvdxy;
if(dxy){
if(qpel){
c->qpel_put[size][dxy](c->temp, ref[0] + x + y*stride, stride);
if(chroma){
int cx= hx/2;
int cy= hy/2;
cx= (cx>>1)|(cx&1);
cy= (cy>>1)|(cy&1);
uvdxy= (cx&1) + 2*(cy&1);
}
}else{
c->hpel_put[size][dxy](c->temp, ref[0] + x + y*stride, stride, h);
if(chroma)
uvdxy= dxy | (x&1) | (2*(y&1));
}
d = cmp_func(s, c->temp, src[0], stride, h);
}else{
d = cmp_func(s, src[0], ref[0] + x + y*stride, stride, h);
if(chroma)
uvdxy= (x&1) + 2*(y&1);
}
if(chroma){
uint8_t * const uvtemp= c->temp + 16*stride;
c->hpel_put[size+1][uvdxy](uvtemp , ref[1] + (x>>1) + (y>>1)*uvstride, uvstride, h>>1);
c->hpel_put[size+1][uvdxy](uvtemp+8, ref[2] + (x>>1) + (y>>1)*uvstride, uvstride, h>>1);
d += chroma_cmp_func(s, uvtemp , src[1], uvstride, h>>1);
d += chroma_cmp_func(s, uvtemp+8, src[2], uvstride, h>>1);
}
return d;
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.