problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
How to extract phrases from corpus using gensim : <p>For preprocessing the corpus I was planing to extarct common phrases from the corpus, for this I tried using <strong>Phrases</strong> model in gensim, I tried below code but it's not giving me desired output.</p>
<p><strong>My code</strong></p>
<pre><code>from gensim.models import Phrases
documents = ["the mayor of new york was there", "machine learning can be useful sometimes"]
sentence_stream = [doc.split(" ") for doc in documents]
bigram = Phrases(sentence_stream)
sent = [u'the', u'mayor', u'of', u'new', u'york', u'was', u'there']
print(bigram[sent])
</code></pre>
<p><strong>Output</strong></p>
<pre><code>[u'the', u'mayor', u'of', u'new', u'york', u'was', u'there']
</code></pre>
<p><strong>But it should come as</strong> </p>
<pre><code>[u'the', u'mayor', u'of', u'new_york', u'was', u'there']
</code></pre>
<p>But when I tried to print vocab of train data, I can see bigram, but its not working with test data, where I am going wrong?</p>
<pre><code>print bigram.vocab
defaultdict(<type 'int'>, {'useful': 1, 'was_there': 1, 'learning_can': 1, 'learning': 1, 'of_new': 1, 'can_be': 1, 'mayor': 1, 'there': 1, 'machine': 1, 'new': 1, 'was': 1, 'useful_sometimes': 1, 'be': 1, 'mayor_of': 1, 'york_was': 1, 'york': 1, 'machine_learning': 1, 'the_mayor': 1, 'new_york': 1, 'of': 1, 'sometimes': 1, 'can': 1, 'be_useful': 1, 'the': 1})
</code></pre>
| 0debug |
Error on scalatest compilation in IDEA : <p>I am trying to compile Scala project which contains scalatest.
It compiles normal on sbt </p>
<pre><code>sbt
> compile
> test:compile
</code></pre>
<p>, but when I am trying to build it with IDEA, it shows the following error:</p>
<pre><code>Error:(37, 11) exception during macro expansion:
java.lang.NoSuchMethodError: org.scalactic.BooleanMacro.genMacro(Lscala/reflect/api/Exprs$Expr;Ljava/lang/String;Lscala/reflect/api/Exprs$Expr;)Lscala/reflect/api/Exprs$Expr;
at org.scalatest.AssertionsMacro$.assert(AssertionsMacro.scala:34)
assert((ElementMeasures.baseElementDistance(mEl1, mEl2) - 0.33333).abs < 0.001)
^
</code></pre>
<p>for each <code>assert</code> function in test.</p>
<p><code>build.sbt</code> file contains following:</p>
<pre><code>name := "ner-scala"
organization := "ml.generall"
version := "1.0-SNAPSHOT"
scalaVersion := "2.11.8"
libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.0"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"
...
</code></pre>
| 0debug |
static void test_hash_base64(void)
{
size_t i;
g_assert(qcrypto_init(NULL) == 0);
for (i = 0; i < G_N_ELEMENTS(expected_outputs) ; i++) {
int ret;
char *digest;
ret = qcrypto_hash_base64(i,
INPUT_TEXT,
strlen(INPUT_TEXT),
&digest,
NULL);
g_assert(ret == 0);
g_assert(g_str_equal(digest, expected_outputs_b64[i]));
g_free(digest);
}
}
| 1threat |
How can i design this layout in android : [how to add this a clickable image inside edittext and also a button with EditText,how can i design this.][1]
[1]: https://i.stack.imgur.com/wu9tZ.jpg | 0debug |
Install Qt on Ubuntu : <p>Need to build simple GUI application. For this reason I decided to install Qt on my Ubuntu 16. I have downloaded open source Qt edition <a href="https://www.qt.io/download-qt-installer?hsCtaTracking=9f6a2170-a938-42df-a8e2-a9f0b1d6cdce%7C6cb0de4f-9bb5-4778-ab02-bfb62735f3e5" rel="noreferrer">from theirs site</a>. Got error while run:</p>
<pre><code>g@ubuntu:~/Downloads$ ./qt-unified-linux-x86-2.0.5-2-online.run
./qt-unified-linux-x86-2.0.5-2-online.run: error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directory
</code></pre>
<p>How to fix that?</p>
| 0debug |
Find prime number in the coordinate of Prime Spiral : I have a question which says that all prime numbers are arranged in the spiral form (the ulam spiral)
I will be entering 2 first which will show that I have to enter 2 coordinates and then at those coordinates values will be shown.
Input:
2
1,0
0,1
Expected output:
3
7
In this case at two coordinates 1,0 and 0,1 values are assigned i.e, 3 and 7 which are result. Please help me with this problem
| 0debug |
static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
uint32_t val, int len)
{
pci_default_write_config(pci_dev, address, val, len);
msix_write_config(pci_dev, address, val, len);
}
| 1threat |
static void mxf_write_partition(AVFormatContext *s, int bodysid,
int indexsid,
const uint8_t *key, int write_metadata)
{
MXFContext *mxf = s->priv_data;
ByteIOContext *pb = s->pb;
int64_t header_byte_count_offset;
unsigned index_byte_count = 0;
uint64_t partition_offset = url_ftell(pb);
if (mxf->edit_units_count) {
index_byte_count = 109 + (s->nb_streams+1)*6 +
mxf->edit_units_count*(11+mxf->slice_count*4);
index_byte_count += 16 + klv_ber_length(index_byte_count);
index_byte_count += klv_fill_size(index_byte_count);
}
if (!memcmp(key, body_partition_key, 16)) {
mxf->body_partition_offset =
av_realloc(mxf->body_partition_offset,
(mxf->body_partitions_count+1)*
sizeof(*mxf->body_partition_offset));
mxf->body_partition_offset[mxf->body_partitions_count++] = partition_offset;
}
put_buffer(pb, key, 16);
klv_encode_ber_length(pb, 88 + 16 * mxf->essence_container_count);
put_be16(pb, 1);
put_be16(pb, 2);
put_be32(pb, KAG_SIZE);
put_be64(pb, partition_offset);
if (!memcmp(key, body_partition_key, 16) && mxf->body_partitions_count > 1)
put_be64(pb, mxf->body_partition_offset[mxf->body_partitions_count-2]);
else if (!memcmp(key, footer_partition_key, 16))
put_be64(pb, mxf->body_partition_offset[mxf->body_partitions_count-1]);
else
put_be64(pb, 0);
put_be64(pb, mxf->footer_partition_offset);
header_byte_count_offset = url_ftell(pb);
put_be64(pb, 0);
put_be64(pb, index_byte_count);
put_be32(pb, index_byte_count ? indexsid : 0);
if (bodysid && mxf->edit_units_count) {
uint64_t partition_end = url_ftell(pb) + 8 + 4 + 16 + 8 +
16*mxf->essence_container_count;
put_be64(pb, partition_end + klv_fill_size(partition_end) +
index_byte_count - mxf->first_edit_unit_offset);
} else
put_be64(pb, 0);
put_be32(pb, bodysid);
if (s->nb_streams > 1) {
put_buffer(pb, op1a_ul, 14);
put_be16(pb, 0x0900);
} else {
put_buffer(pb, op1a_ul, 16);
}
mxf_write_essence_container_refs(s);
if (write_metadata) {
int64_t pos, start;
unsigned header_byte_count;
mxf_write_klv_fill(s);
start = url_ftell(s->pb);
mxf_write_primer_pack(s);
mxf_write_header_metadata_sets(s);
pos = url_ftell(s->pb);
header_byte_count = pos - start + klv_fill_size(pos);
url_fseek(pb, header_byte_count_offset, SEEK_SET);
put_be64(pb, header_byte_count);
url_fseek(pb, pos, SEEK_SET);
}
put_flush_packet(pb);
}
| 1threat |
How to escape special character in jquery split method : How to use jQuery.Split() to split like
Love24|, LLC,Love 100|, LTE
It return as
Love24|, LLC
Love 100|, LTE
| 0debug |
View cannot be converted to MotionEvent : plz help getting error View cannot be converted to MotionEvent and MotionEvent cannot be converted to View ..
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.OnItemTouchListener;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.View;
public class RecyclerTouchListener implements OnItemTouchListener {
private ClickListener clickListener;
private GestureDetector gestureDetector;
public interface ClickListener {
void onClick(View view, int i);
void onLongClick(View view, int i);
}
public void onRequestDisallowInterceptTouchEvent(boolean z) {
}
public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
}
public RecyclerTouchListener(Context context, final RecyclerView recyclerView, final ClickListener clickListener) {
this.clickListener = clickListener;
this.gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
public boolean onSingleTapUp(MotionEvent motionEvent) {
return true;
}
public void onLongPress(MotionEvent motionEvent) {
motionEvent = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
if (motionEvent != null && clickListener != null) {
clickListener.onLongClick(motionEvent, recyclerView.getChildPosition(motionEvent));
}
}
});
}
public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
View findChildViewUnder = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
if (!(findChildViewUnder == null || this.clickListener == null || this.gestureDetector.onTouchEvent(motionEvent) == null)) {
this.clickListener.onClick(findChildViewUnder, recyclerView.getChildPosition(findChildViewUnder));
}
return null;
}
}
don't know how I can solve this problem.
Thank you in advance for your help
I hope to be clear, I'm sorry if there are mistakes | 0debug |
AWS Aurora: What is 'delayed send/commit ok done' process state : <p>I am using AWS aurora instance and in process list I saw many processes with state 'delayed send ok done' and 'delayed commit ok done' and these are in sleep mode.</p>
<p>These are not MySQL state so looks like these are Aurora specific states. Does anyone know what these states actually mean?</p>
| 0debug |
static int source_request_frame(AVFilterLink *outlink)
{
Frei0rContext *frei0r = outlink->src->priv;
AVFilterBufferRef *picref = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
int ret;
picref->video->pixel_aspect = (AVRational) {1, 1};
picref->pts = frei0r->pts++;
picref->pos = -1;
ret = ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0));
if (ret < 0)
goto fail;
frei0r->update(frei0r->instance, av_rescale_q(picref->pts, frei0r->time_base, (AVRational){1,1000}),
NULL, (uint32_t *)picref->data[0]);
ret = ff_draw_slice(outlink, 0, outlink->h, 1);
if (ret < 0)
goto fail;
ret = ff_end_frame(outlink);
fail:
avfilter_unref_buffer(picref);
return ret;
}
| 1threat |
How to use a decrypted python string as a zip file to import files from? : <p>i have encrypted a python zip file made with zipfile module, in my code I'm decrypting the zip file it's self and returning string. If i make this string an actual .zip file it works like a zip file. But i want to store the decrypted string as a dynamic in memory zip and, import files from it so the encrypted zip won't be touched or decrypted. How can i do this?</p>
| 0debug |
Unable to exhaust the content of all the identical urls used within my scraper : <p>I've written a scraper in python using BeautifulSoup library to parse all the names traversing different pages of a website. I could manage it if it were not for more than one urls with different pagination, meaning some urls have pagination some does not as the content are few. </p>
<p>My question is: how could I manage to compile them within a function to handle whether they have pagination or not?</p>
<p>My initial attempt (it is able to parse the content from each url's first page only):</p>
<pre><code>import requests
from bs4 import BeautifulSoup
urls = {
'https://www.mobilehome.net/mobile-home-park-directory/maine/all',
'https://www.mobilehome.net/mobile-home-park-directory/rhode-island/all',
'https://www.mobilehome.net/mobile-home-park-directory/new-hampshire/all',
'https://www.mobilehome.net/mobile-home-park-directory/vermont/all'
}
def get_names(link):
r = requests.get(link)
soup = BeautifulSoup(r.text,"lxml")
for items in soup.select("td[class='table-row-price']"):
name = items.select_one("h2 a").text
print(name)
if __name__ == '__main__':
for url in urls:
get_names(url)
</code></pre>
<p>I could have managed to do the whole thing, if there is a single url with pagination like below:</p>
<pre><code>from bs4 import BeautifulSoup
import requests
page_no = 0
page_link = "https://www.mobilehome.net/mobile-home-park-directory/new-hampshire/all/page/{}"
while True:
page_no+=1
res = requests.get(page_link.format(page_no))
soup = BeautifulSoup(res.text,'lxml')
container = soup.select("td[class='table-row-price']")
if len(container)<=1:break
for content in container:
title = content.select_one("h2 a").text
print(title)
</code></pre>
<p>But, all the urls do not have pagination. So, how can i manage to grab all of them whether there is any pagination or not?</p>
| 0debug |
How to save boolean values in laravel eloquent : <p>I have made the following migration in Laravel:</p>
<pre><code><?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class QualityCheckTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('quality_check', function (Blueprint $table) {
$table->increments('id');
$table->boolean('favicon');
$table->boolean('title');
$table->boolean('image-optimization');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('quality_check');
}
}
</code></pre>
<p>I have the following controller method that runs when the form in the frontEnd is submitted:</p>
<pre><code>public function store(CreateArticleRequest $request) {
// $input = Request::all();
Article::create($request->all());
return redirect('articles');
}
</code></pre>
<p>My form looks like , so:</p>
<pre><code>{!! Form::open([ 'action' => 'QualityCheckController@validateSave' , 'class'=>'quality-check-form' , 'method' => 'POST' ]) !!}
<div class="input-wrpr">
{!! Form::label('favicon', 'Favicon') !!}
{!! Form::checkbox('favicon', 'value' ); !!}
</div>
<div class="input-wrpr">
{!! Form::label('title', 'Page Title') !!}
{!! Form::checkbox('title', 'value'); !!}
</div>
<div class="input-wrpr">
{!! Form::label('image-optimization', 'Image Optimization') !!}
{!! Form::checkbox('image-optimization', 'value'); !!}
</div>
{!! Form::submit('Click Me!') !!}
{!! Form::close() !!}
</code></pre>
<p>So when the method runs the values of the checkboxes are saved to the database.</p>
<p>As of now , all entries are showing as <code>0</code> , Like so:</p>
<p><a href="https://i.stack.imgur.com/HmaM7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HmaM7.png" alt="enter image description here"></a></p>
<p>Now how to make it such that when the checkbox is checked , <code>1</code> is saved and when the checkbox is left unchecked the value in is left at <code>0</code> ??</p>
| 0debug |
void qmp_block_dirty_bitmap_clear(const char *node, const char *name,
Error **errp)
{
AioContext *aio_context;
BdrvDirtyBitmap *bitmap;
BlockDriverState *bs;
bitmap = block_dirty_bitmap_lookup(node, name, &bs, &aio_context, errp);
if (!bitmap || !bs) {
return;
}
if (bdrv_dirty_bitmap_frozen(bitmap)) {
error_setg(errp,
"Bitmap '%s' is currently frozen and cannot be modified",
name);
goto out;
} else if (!bdrv_dirty_bitmap_enabled(bitmap)) {
error_setg(errp,
"Bitmap '%s' is currently disabled and cannot be cleared",
name);
goto out;
}
bdrv_clear_dirty_bitmap(bitmap, NULL);
out:
aio_context_release(aio_context);
}
| 1threat |
valgrind showing invalid write of size 4 at fread and memory leaks : the load function below tries to load contents of file pointed by pointer "file" and save it's location at "content" and length in "length". The code works fine but with valgrind show error of "invalid write at fread" and several memory leaks while using realloc.
Following is the code
bool load(FILE* file, BYTE** content, size_t* length) {
// providing default values to content and length
*content = NULL;
*length = 0;
// initializing buffer to hold file data
int size = 512;
BYTE* buffer = NULL;
buffer = (BYTE*) malloc(sizeof(BYTE) * size);
if(buffer == NULL)
return false;
// bytes_read will store bytes read at a time
int bytes_read = 0;
// reading 512 bytes at a time and incrmenting writing location by 512
// reading stops if less than 512 bytes read
while((bytes_read = fread(buffer + size - 512 , 1, 512, file)) == 512)
{
//increasing the size of
size = size + 512;
if(realloc(buffer,size) == NULL)
{
free(buffer);
return false;
}
}
// undoing final increment of 512 and increasing the size by bytes_read on last iteration
size = size - 512 + bytes_read;
// triming buffer to minimum size
if(size > 0)
{
BYTE* minimal_buffer = malloc(size + 1);
memcpy(minimal_buffer, buffer, size);
minimal_buffer[size] = '\0';
free(buffer);
*content = minimal_buffer;
*length = size;
return true;
}
return false;
}
| 0debug |
void commit_start(BlockDriverState *bs, BlockDriverState *base,
BlockDriverState *top, int64_t speed,
BlockdevOnError on_error, BlockDriverCompletionFunc *cb,
void *opaque, Error **errp)
{
CommitBlockJob *s;
BlockReopenQueue *reopen_queue = NULL;
int orig_overlay_flags;
int orig_base_flags;
BlockDriverState *overlay_bs;
Error *local_err = NULL;
if ((on_error == BLOCKDEV_ON_ERROR_STOP ||
on_error == BLOCKDEV_ON_ERROR_ENOSPC) &&
!bdrv_iostatus_is_enabled(bs)) {
error_set(errp, QERR_INVALID_PARAMETER_COMBINATION);
return;
}
if (top == bs) {
error_setg(errp,
"Top image as the active layer is currently unsupported");
return;
}
if (top == base) {
error_setg(errp, "Invalid files for merge: top and base are the same");
return;
}
overlay_bs = bdrv_find_overlay(bs, top);
if (overlay_bs == NULL) {
error_setg(errp, "Could not find overlay image for %s:", top->filename);
return;
}
orig_base_flags = bdrv_get_flags(base);
orig_overlay_flags = bdrv_get_flags(overlay_bs);
if (!(orig_base_flags & BDRV_O_RDWR)) {
reopen_queue = bdrv_reopen_queue(reopen_queue, base,
orig_base_flags | BDRV_O_RDWR);
}
if (!(orig_overlay_flags & BDRV_O_RDWR)) {
reopen_queue = bdrv_reopen_queue(reopen_queue, overlay_bs,
orig_overlay_flags | BDRV_O_RDWR);
}
if (reopen_queue) {
bdrv_reopen_multiple(reopen_queue, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
}
}
s = block_job_create(&commit_job_driver, bs, speed, cb, opaque, errp);
if (!s) {
return;
}
s->base = base;
s->top = top;
s->active = bs;
s->base_flags = orig_base_flags;
s->orig_overlay_flags = orig_overlay_flags;
s->on_error = on_error;
s->common.co = qemu_coroutine_create(commit_run);
trace_commit_start(bs, base, top, s, s->common.co, opaque);
qemu_coroutine_enter(s->common.co, s);
}
| 1threat |
Hide Div Which Have no class with Jquery : I want to hide the specific div(Example 2) but it has no class or id so i am unable to apply jquery on that specific div(Example 2)...Please guide me how can hide that div with jquery.
Here is my div structure:
<div class="purhist-desc-col">
<h5>Heading Sample</h5>
<div class="purchase-price"></div>
<div>Example 1/div>
<div class="booking-hide-on-wholeday">00:00 Check-out 00:00</div>
<div>Example 2</div>
</div> | 0debug |
static void uhci_async_cancel_all(UHCIState *s)
{
UHCIQueue *queue, *nq;
QTAILQ_FOREACH_SAFE(queue, &s->queues, next, nq) {
uhci_queue_free(queue);
}
}
| 1threat |
Module not found: Error: Can't resolve 'ts-loader' : <p>Following is my webpack.config.js</p>
<pre><code> var webpack = require('webpack'),
path = require('path'),
yargs = require('yargs');
var libraryName = 'MyLib',
plugins = [],
outputFile;
if (yargs.argv.p) {
plugins.push(new webpack.optimize.UglifyJsPlugin({
minimize: true
}));
outputFile = libraryName + '.min.js';
} else {
outputFile = libraryName + '.js';
}
var config = {
entry: [
__dirname + '/src/TestClass.ts'
],
devtool: 'source-map',
output: {
path: path.join(__dirname, '/dist'),
filename: outputFile,
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true
},
module: {
rules: [{
test: /\.tsx?$/,
use: 'ts-loader', //Something wrong here
exclude: /node_modules/
}]
},
resolve: {
modules: [__dirname],
extensions: ['.ts', '.js', '.tsx']
},
plugins: plugins
};
module.exports = config;
</code></pre>
<p>Its a typescript project.</p>
<p>When I run build and minify the typescript project using webpack version 4.5.0, I get following error</p>
<p><strong>Module not found: Error: Can't resolve 'ts-loader'</strong></p>
<p>Not sure whats wrong.</p>
<p>I use ts-loader version 4.2.0</p>
<p>Typescript version 2.8.1</p>
<p>Kindly advice.</p>
| 0debug |
RxSwift - Debounce/Throttle "inverse" : <p>Let's say I have an instant messaging app that plays a beep sound every time a message arrives. I want to <code>debounce</code> the beeps, but I'd like to play the beep sound for the first message arrived and not for the following ones (in a timespan of, say, 2 seconds).</p>
<p>Another example might be: my app sends typing notifications (so the user I'm chatting with can see that I'm typing a message). I want to send a typing notification when I start typing, but only send new ones in X-seconds intervals, so I don't send a typing notification for every character I type.</p>
<p>Does this make sense? Is there an operator for that? Could it be achieved with the existing operators?</p>
<p>This is my code for the first example. I'm solving it now with <code>debounce</code>, but it's not ideal. If I receive 1000 messages in intervals of 1 second, it won't play the sound until the last message arrives (I'd like to play the sound on the first one).</p>
<pre><code>self.messagesHandler.messages
.asObservable()
.skip(1)
.debounce(2, scheduler: MainScheduler.instance)
.subscribeNext { [weak self] message in
self?.playMessageArrivedSound()
}.addDisposableTo(self.disposeBag)
</code></pre>
<p>Thanks!</p>
| 0debug |
Python if something repeat function : <p>I don't how to make the script repeat this function if the user doesn't input the correct information.</p>
<pre><code>def installer(x):
if x == "Y" or x == "y":
print("Ok, Getting On with the install")
noncustompath()
elif x == "N" or x == "n":
print("Ok, Cool")
else:
#Repeat function
</code></pre>
<p>Thanks.</p>
| 0debug |
listing out strings with the Regexp_Like() function : <p>I am curious to see if there is a way to input a list of strings within the regexp_like() function in SQL. </p>
<p>Example: </p>
<pre><code>SELECT *
FROM TABLE_1
AND REGEXP_LIKE(COLUMN_1, '2007239,;
2007294,
2007296,
2007295,
2007297,
1398852,
1398837,
1398744')
;
</code></pre>
<p>I understand that this is not possible but is there a way to do this without being too repetitive (i.e. having too many regexp_like() in one query). </p>
| 0debug |
static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
const char *boot_device,
DisplayState *ds, const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
CPUState *env, *envs[MAX_CPUS];
unsigned int i;
void *iommu, *espdma, *ledma, *main_esp, *nvram;
qemu_irq *cpu_irqs[MAX_CPUS], *slavio_irq, *slavio_cpu_irq,
*espdma_irq, *ledma_irq;
qemu_irq *esp_reset, *le_reset;
qemu_irq *fdc_tc;
qemu_irq *cpu_halt;
ram_addr_t ram_offset, prom_offset, tcx_offset, idreg_offset;
unsigned long kernel_size;
int ret;
char buf[1024];
BlockDriverState *fd[MAX_FD];
int drive_index;
void *fw_cfg;
if (!cpu_model)
cpu_model = hwdef->default_cpu_model;
for(i = 0; i < smp_cpus; i++) {
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "qemu: Unable to find Sparc CPU definition\n");
exit(1);
}
cpu_sparc_set_id(env, i);
envs[i] = env;
if (i == 0) {
qemu_register_reset(main_cpu_reset, env);
} else {
qemu_register_reset(secondary_cpu_reset, env);
env->halted = 1;
}
cpu_irqs[i] = qemu_allocate_irqs(cpu_set_irq, envs[i], MAX_PILS);
env->prom_addr = hwdef->slavio_base;
}
for (i = smp_cpus; i < MAX_CPUS; i++)
cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
if ((uint64_t)RAM_size > hwdef->max_mem) {
fprintf(stderr,
"qemu: Too much memory for this machine: %d, maximum %d\n",
(unsigned int)(RAM_size / (1024 * 1024)),
(unsigned int)(hwdef->max_mem / (1024 * 1024)));
exit(1);
}
ram_offset = qemu_ram_alloc(RAM_size);
cpu_register_physical_memory(0, RAM_size, ram_offset);
prom_offset = qemu_ram_alloc(PROM_SIZE_MAX);
cpu_register_physical_memory(hwdef->slavio_base,
(PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) &
TARGET_PAGE_MASK,
prom_offset | IO_MEM_ROM);
if (bios_name == NULL)
bios_name = PROM_FILENAME;
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL);
if (ret < 0 || ret > PROM_SIZE_MAX)
ret = load_image_targphys(buf, hwdef->slavio_base, PROM_SIZE_MAX);
if (ret < 0 || ret > PROM_SIZE_MAX) {
fprintf(stderr, "qemu: could not load prom '%s'\n",
buf);
exit(1);
}
slavio_intctl = slavio_intctl_init(hwdef->intctl_base,
hwdef->intctl_base + 0x10000ULL,
&hwdef->intbit_to_level[0],
&slavio_irq, &slavio_cpu_irq,
cpu_irqs,
hwdef->clock_irq);
if (hwdef->idreg_base) {
static const uint8_t idreg_data[] = { 0xfe, 0x81, 0x01, 0x03 };
idreg_offset = qemu_ram_alloc(sizeof(idreg_data));
cpu_register_physical_memory(hwdef->idreg_base, sizeof(idreg_data),
idreg_offset | IO_MEM_ROM);
cpu_physical_memory_write_rom(hwdef->idreg_base, idreg_data,
sizeof(idreg_data));
}
iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version,
slavio_irq[hwdef->me_irq]);
espdma = sparc32_dma_init(hwdef->dma_base, slavio_irq[hwdef->esp_irq],
iommu, &espdma_irq, &esp_reset);
ledma = sparc32_dma_init(hwdef->dma_base + 16ULL,
slavio_irq[hwdef->le_irq], iommu, &ledma_irq,
&le_reset);
if (graphic_depth != 8 && graphic_depth != 24) {
fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
exit (1);
}
tcx_offset = qemu_ram_alloc(hwdef->vram_size);
tcx_init(ds, hwdef->tcx_base, phys_ram_base + tcx_offset, tcx_offset,
hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
if (nd_table[0].model == NULL)
nd_table[0].model = "lance";
if (strcmp(nd_table[0].model, "lance") == 0) {
lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
} else if (strcmp(nd_table[0].model, "?") == 0) {
fprintf(stderr, "qemu: Supported NICs: lance\n");
exit (1);
} else {
fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
exit (1);
}
nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0,
hwdef->nvram_size, 8);
slavio_timer_init_all(hwdef->counter_base, slavio_irq[hwdef->clock1_irq],
slavio_cpu_irq, smp_cpus);
slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[hwdef->ms_kb_irq],
nographic, ESCC_CLOCK, 1);
escc_init(hwdef->serial_base, slavio_irq[hwdef->ser_irq], serial_hds[1],
serial_hds[0], ESCC_CLOCK, 1);
cpu_halt = qemu_allocate_irqs(cpu_halt_signal, NULL, 1);
slavio_misc = slavio_misc_init(hwdef->slavio_base, hwdef->apc_base,
hwdef->aux1_base, hwdef->aux2_base,
slavio_irq[hwdef->me_irq], cpu_halt[0],
&fdc_tc);
if (hwdef->fd_base) {
memset(fd, 0, sizeof(fd));
drive_index = drive_get_index(IF_FLOPPY, 0, 0);
if (drive_index != -1)
fd[0] = drives_table[drive_index].bdrv;
sun4m_fdctrl_init(slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd,
fdc_tc);
}
if (drive_get_max_bus(IF_SCSI) > 0) {
fprintf(stderr, "qemu: too many SCSI bus\n");
exit(1);
}
main_esp = esp_init(hwdef->esp_base, 2,
espdma_memory_read, espdma_memory_write,
espdma, *espdma_irq, esp_reset);
for (i = 0; i < ESP_MAX_DEVS; i++) {
drive_index = drive_get_index(IF_SCSI, 0, i);
if (drive_index == -1)
continue;
esp_scsi_attach(main_esp, drives_table[drive_index].bdrv, i);
}
if (hwdef->cs_base)
cs_init(hwdef->cs_base, hwdef->cs_irq, slavio_intctl);
kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename,
RAM_size);
nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
boot_device, RAM_size, kernel_size, graphic_width,
graphic_height, graphic_depth, hwdef->nvram_machine_id,
"Sun4m");
if (hwdef->ecc_base)
ecc_init(hwdef->ecc_base, slavio_irq[hwdef->ecc_irq],
hwdef->ecc_version);
fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth);
}
| 1threat |
static int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
{
int i;
int s;
const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
const vector unsigned char permclear = (vector unsigned char){255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0};
vector unsigned char perm1 = vec_lvsl(0, pix1);
vector unsigned char perm2 = vec_lvsl(0, pix2);
vector unsigned char t1, t2, t3,t4, t5;
vector unsigned int sum;
vector signed int sumsqr;
sum = (vector unsigned int)vec_splat_u32(0);
for (i = 0; i < h; i++) {
vector unsigned char pix1l = vec_ld( 0, pix1);
vector unsigned char pix1r = vec_ld(15, pix1);
vector unsigned char pix2l = vec_ld( 0, pix2);
vector unsigned char pix2r = vec_ld(15, pix2);
t1 = vec_and(vec_perm(pix1l, pix1r, perm1), permclear);
t2 = vec_and(vec_perm(pix2l, pix2r, perm2), permclear);
t3 = vec_max(t1, t2);
t4 = vec_min(t1, t2);
t5 = vec_sub(t3, t4);
sum = vec_msum(t5, t5, sum);
pix1 += line_size;
pix2 += line_size;
}
sumsqr = vec_sums((vector signed int) sum, (vector signed int) zero);
sumsqr = vec_splat(sumsqr, 3);
vec_ste(sumsqr, 0, &s);
return s;
}
| 1threat |
Holding Temporary Data in ASP.NET MVC for Shopping Cart : <p>Which mechanism will be suitable for storing temporary data in Asp.net MVC? I dont want to hit to database everytime customer adds the product to cart.I read some of the articles and i am little bit confused. I want to know which mechanism would be better or any other options?
1) Cookies
2) Session
3) Text File</p>
| 0debug |
Who can explain this numpy voodoo? : I'm trying to get my data correct for the deep learning models I am creating and I stumbled into something peculiar.
I have the following data: <br>
original_data.shape = (220, 145, 145) <br>
all_data = np.transpose(original_data, (1,2,0)) <br>
---> all_data.shape = (145, 145, 220) ----- As I require it.
Now when I try to use numpy 'shortcuts' to use this data I get the following:
temp = original_data[:][:][0] <br>
----> temp.shape = (145, 145) <br>
This is already confusing as in my mind the shape should be (220, 145)
temp = all_data[:][:][0] <br>
----> temp.shape = (145, 220) <br>
But why??? It would make more sense for it to be (145, 145). But I accepted it as it is and tried the others as well <br> <br>
temp = all_data[:][0][:] <br>
----> temp.shape = (145, 220) <br>
WHYYYY???? <br>
temp = all_data[0][:][:] <br>
----> temp.shape = (145, 220) <br>
This is blowing my mind <br>
Anyone understand what's going on here?
Thanks in advance :) | 0debug |
Chrome Dev tools - Is there a way to persist the filter in Chrome Dev Tools? : <p>Is there a way to preserve the filter on the Network tab in Chrome Dev tools???</p>
<p>E.g. if I use a filter like "-status-code:204" to exclude all responses with 204 status, it works as long as the tool window is open but would be helpful if it could be retained for new window instances.</p>
| 0debug |
NetCDF Subtracting time steps : I have a question regarding specific netcdf file manipulation. I am not sure how exactly to solve this issue.
I have a netcdf file that has 21 time steps and thickness data in the variable 'lithk'.
I would like to substract the first time step from the last to get the change of the thickness between the first and the last time step.
Then I would like to get this newly calculated data added back to the netcdf file as a new variable.
I have tried many solution and could not come up with the one that works so far.
I would really apprechiate any help on this.
Many Thanks | 0debug |
void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)
{
MigrationState *s = migrate_get_current();
if (params->has_compress_level &&
(params->compress_level < 0 || params->compress_level > 9)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level",
"is invalid, it should be in the range of 0 to 9");
return;
}
if (params->has_compress_threads &&
(params->compress_threads < 1 || params->compress_threads > 255)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"compress_threads",
"is invalid, it should be in the range of 1 to 255");
return;
}
if (params->has_decompress_threads &&
(params->decompress_threads < 1 || params->decompress_threads > 255)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"decompress_threads",
"is invalid, it should be in the range of 1 to 255");
return;
}
if (params->has_cpu_throttle_initial &&
(params->cpu_throttle_initial < 1 ||
params->cpu_throttle_initial > 99)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"cpu_throttle_initial",
"an integer in the range of 1 to 99");
return;
}
if (params->has_cpu_throttle_increment &&
(params->cpu_throttle_increment < 1 ||
params->cpu_throttle_increment > 99)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"cpu_throttle_increment",
"an integer in the range of 1 to 99");
return;
}
if (params->has_max_bandwidth &&
(params->max_bandwidth < 0 || params->max_bandwidth > SIZE_MAX)) {
error_setg(errp, "Parameter 'max_bandwidth' expects an integer in the"
" range of 0 to %zu bytes/second", SIZE_MAX);
return;
}
if (params->has_downtime_limit &&
(params->downtime_limit < 0 || params->downtime_limit > 2000000)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"downtime_limit",
"an integer in the range of 0 to 2000000 milliseconds");
return;
}
if (params->has_x_checkpoint_delay && (params->x_checkpoint_delay < 0)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"x_checkpoint_delay",
"is invalid, it should be positive");
}
if (params->has_compress_level) {
s->parameters.compress_level = params->compress_level;
}
if (params->has_compress_threads) {
s->parameters.compress_threads = params->compress_threads;
}
if (params->has_decompress_threads) {
s->parameters.decompress_threads = params->decompress_threads;
}
if (params->has_cpu_throttle_initial) {
s->parameters.cpu_throttle_initial = params->cpu_throttle_initial;
}
if (params->has_cpu_throttle_increment) {
s->parameters.cpu_throttle_increment = params->cpu_throttle_increment;
}
if (params->has_tls_creds) {
g_free(s->parameters.tls_creds);
s->parameters.tls_creds = g_strdup(params->tls_creds);
}
if (params->has_tls_hostname) {
g_free(s->parameters.tls_hostname);
s->parameters.tls_hostname = g_strdup(params->tls_hostname);
}
if (params->has_max_bandwidth) {
s->parameters.max_bandwidth = params->max_bandwidth;
if (s->to_dst_file) {
qemu_file_set_rate_limit(s->to_dst_file,
s->parameters.max_bandwidth / XFER_LIMIT_RATIO);
}
}
if (params->has_downtime_limit) {
s->parameters.downtime_limit = params->downtime_limit;
}
if (params->has_x_checkpoint_delay) {
s->parameters.x_checkpoint_delay = params->x_checkpoint_delay;
if (migration_in_colo_state()) {
colo_checkpoint_notify(s);
}
}
}
| 1threat |
static int qemu_balloon(ram_addr_t target)
{
if (!balloon_event_fn) {
return 0;
}
trace_balloon_event(balloon_opaque, target);
balloon_event_fn(balloon_opaque, target);
return 1;
}
| 1threat |
How i can get image from printer scanner using javascript library : <p>I want to make node js script that allows to user to get scanned image from printer scanner </p>
| 0debug |
Protect Web application from Fishing : Hope this was asked earlier but i couldn't able to find the right one at one place. Following are my concerns on my webpage
- How to disable the user from viewing my web-page cache
- How to protect user from viewing my source code and the variable (Even they can put breakpoint to debug or hack)
- I saw facebook not allowing user to view fb page as developer / inspect. How to achieve this
Kindly do the needful. | 0debug |
static int piix4_pm_initfn(PCIDevice *dev)
{
PIIX4PMState *s = DO_UPCAST(PIIX4PMState, dev, dev);
uint8_t *pci_conf;
pci_conf = s->dev.config;
pci_conf[0x06] = 0x80;
pci_conf[0x07] = 0x02;
pci_conf[0x09] = 0x00;
pci_conf[0x3d] = 0x01;
apm_init(dev, &s->apm, apm_ctrl_changed, s);
if (s->kvm_enabled) {
pci_conf[0x5B] = 0x02;
}
pci_conf[0x90] = s->smb_io_base | 1;
pci_conf[0x91] = s->smb_io_base >> 8;
pci_conf[0xd2] = 0x09;
pm_smbus_init(&s->dev.qdev, &s->smb);
memory_region_set_enabled(&s->smb.io, pci_conf[0xd2] & 1);
memory_region_add_subregion(pci_address_space_io(dev),
s->smb_io_base, &s->smb.io);
memory_region_init(&s->io, "piix4-pm", 64);
memory_region_set_enabled(&s->io, false);
memory_region_add_subregion(pci_address_space_io(dev),
0, &s->io);
acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_cnt_init(&s->ar, &s->io);
acpi_gpe_init(&s->ar, GPE_LEN);
s->powerdown_notifier.notify = piix4_pm_powerdown_req;
qemu_register_powerdown_notifier(&s->powerdown_notifier);
s->machine_ready.notify = piix4_pm_machine_ready;
qemu_add_machine_init_done_notifier(&s->machine_ready);
qemu_register_reset(piix4_reset, s);
piix4_acpi_system_hot_add_init(pci_address_space_io(dev), dev->bus, s);
return 0;
}
| 1threat |
static int ff_asf_get_packet(AVFormatContext *s, AVIOContext *pb)
{
ASFContext *asf = s->priv_data;
uint32_t packet_length, padsize;
int rsize = 8;
int c, d, e, off;
off= 32768;
if (s->packet_size > 0)
off= (avio_tell(pb) - s->data_offset) % s->packet_size + 3;
c=d=e=-1;
while(off-- > 0){
c=d; d=e;
e= avio_r8(pb);
if(c == 0x82 && !d && !e)
break;
}
if (c != 0x82) {
if (pb->error == AVERROR(EAGAIN))
return AVERROR(EAGAIN);
if (!url_feof(pb))
av_log(s, AV_LOG_ERROR, "ff asf bad header %x at:%"PRId64"\n", c, avio_tell(pb));
}
if ((c & 0x8f) == 0x82) {
if (d || e) {
if (!url_feof(pb))
av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n");
return -1;
}
c= avio_r8(pb);
d= avio_r8(pb);
rsize+=3;
}else{
avio_seek(pb, -1, SEEK_CUR);
}
asf->packet_flags = c;
asf->packet_property = d;
DO_2BITS(asf->packet_flags >> 5, packet_length, s->packet_size);
DO_2BITS(asf->packet_flags >> 1, padsize, 0);
DO_2BITS(asf->packet_flags >> 3, padsize, 0);
if(!packet_length || packet_length >= (1U<<29)){
av_log(s, AV_LOG_ERROR, "invalid packet_length %d at:%"PRId64"\n", packet_length, avio_tell(pb));
return -1;
}
if(padsize >= packet_length){
av_log(s, AV_LOG_ERROR, "invalid padsize %d at:%"PRId64"\n", padsize, avio_tell(pb));
return -1;
}
asf->packet_timestamp = avio_rl32(pb);
avio_rl16(pb);
if (asf->packet_flags & 0x01) {
asf->packet_segsizetype = avio_r8(pb); rsize++;
asf->packet_segments = asf->packet_segsizetype & 0x3f;
} else {
asf->packet_segments = 1;
asf->packet_segsizetype = 0x80;
}
asf->packet_size_left = packet_length - padsize - rsize;
if (packet_length < asf->hdr.min_pktsize)
padsize += asf->hdr.min_pktsize - packet_length;
asf->packet_padsize = padsize;
av_dlog(s, "packet: size=%d padsize=%d left=%d\n", s->packet_size, asf->packet_padsize, asf->packet_size_left);
return 0;
}
| 1threat |
Graphing using ggplot : Any advice appreciated.
library(ggplot2)
ggplot(data = mpg) + geom_point(aes(x = displ^2, x = hwy))
mpgfil=fliter(mpg, cyl = 8)
mpg_manu=select(mpg, starts_with("man")& ends_with("rv")
| 0debug |
Which one is faster; Shared Preference or Sqlite Database : <p>This seems to be a common question, but i am unable to find out a straight away answer.</p>
<p>I get <code>JSONObject</code> from server, each activity needs to access it and get some data from it, that's the reason i am more concerned about the performance here. </p>
<p>This is what i do. Following operation runs for each activity.</p>
<pre><code>DatabaseHandler db = new DatabaseHandler(context);
dataObject = db.getAllData();
jsonObject = new JSONObject(dataObject );
value = jsonObject.optString(key);
</code></pre>
<p>The data is pretty straight forward, its a simple <code>JsonObject</code>, i can also put this in <code>sharedPreference</code>, but before moving to <code>sharedPreference</code>, i want to be sure that <code>sharedPreference</code> are faster than <code>sqlite database</code>, or moving to <code>sharedPreference</code> can give me performance improvement. </p>
| 0debug |
int ff_rtp_get_payload_type(AVFormatContext *fmt,
AVCodecContext *codec, int idx)
{
int i;
AVOutputFormat *ofmt = fmt ? fmt->oformat : NULL;
if (ofmt && ofmt->priv_class && fmt->priv_data) {
int64_t payload_type;
if (av_opt_get_int(fmt->priv_data, "payload_type", 0, &payload_type) >= 0 &&
payload_type >= 0)
return (int)payload_type;
}
for (i = 0; rtp_payload_types[i].pt >= 0; ++i)
if (rtp_payload_types[i].codec_id == codec->codec_id) {
if (codec->codec_id == AV_CODEC_ID_H263 && (!fmt ||
!fmt->oformat->priv_class ||
!av_opt_flag_is_set(fmt->priv_data, "rtpflags", "rfc2190")))
continue;
if (codec->codec_id == AV_CODEC_ID_ADPCM_G722 &&
codec->sample_rate == 16000 && codec->channels == 1)
return rtp_payload_types[i].pt;
if (codec->codec_type == AVMEDIA_TYPE_AUDIO &&
((rtp_payload_types[i].clock_rate > 0 &&
codec->sample_rate != rtp_payload_types[i].clock_rate) ||
(rtp_payload_types[i].audio_channels > 0 &&
codec->channels != rtp_payload_types[i].audio_channels)))
continue;
return rtp_payload_types[i].pt;
}
if (idx < 0)
idx = codec->codec_type == AVMEDIA_TYPE_AUDIO;
return RTP_PT_PRIVATE + idx;
}
| 1threat |
static int jpg_decode_data(JPGContext *c, int width, int height,
const uint8_t *src, int src_size,
uint8_t *dst, int dst_stride,
const uint8_t *mask, int mask_stride, int num_mbs,
int swapuv)
{
GetBitContext gb;
int mb_w, mb_h, mb_x, mb_y, i, j;
int bx, by;
int unesc_size;
int ret;
if ((ret = av_reallocp(&c->buf,
src_size + FF_INPUT_BUFFER_PADDING_SIZE)) < 0)
return ret;
jpg_unescape(src, src_size, c->buf, &unesc_size);
memset(c->buf + unesc_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
init_get_bits8(&gb, c->buf, unesc_size);
width = FFALIGN(width, 16);
mb_w = width >> 4;
mb_h = (height + 15) >> 4;
if (!num_mbs)
num_mbs = mb_w * mb_h * 4;
for (i = 0; i < 3; i++)
c->prev_dc[i] = 1024;
bx =
by = 0;
c->bdsp.clear_blocks(c->block[0]);
for (mb_y = 0; mb_y < mb_h; mb_y++) {
for (mb_x = 0; mb_x < mb_w; mb_x++) {
if (mask && !mask[mb_x * 2] && !mask[mb_x * 2 + 1] &&
!mask[mb_x * 2 + mask_stride] &&
!mask[mb_x * 2 + 1 + mask_stride]) {
bx += 16;
continue;
}
for (j = 0; j < 2; j++) {
for (i = 0; i < 2; i++) {
if (mask && !mask[mb_x * 2 + i + j * mask_stride])
continue;
num_mbs--;
if ((ret = jpg_decode_block(c, &gb, 0,
c->block[i + j * 2])) != 0)
return ret;
c->idsp.idct(c->block[i + j * 2]);
}
}
for (i = 1; i < 3; i++) {
if ((ret = jpg_decode_block(c, &gb, i, c->block[i + 3])) != 0)
return ret;
c->idsp.idct(c->block[i + 3]);
}
for (j = 0; j < 16; j++) {
uint8_t *out = dst + bx * 3 + (by + j) * dst_stride;
for (i = 0; i < 16; i++) {
int Y, U, V;
Y = c->block[(j >> 3) * 2 + (i >> 3)][(i & 7) + (j & 7) * 8];
U = c->block[4 ^ swapuv][(i >> 1) + (j >> 1) * 8] - 128;
V = c->block[5 ^ swapuv][(i >> 1) + (j >> 1) * 8] - 128;
yuv2rgb(out + i * 3, Y, U, V);
}
}
if (!num_mbs)
return 0;
bx += 16;
}
bx = 0;
by += 16;
if (mask)
mask += mask_stride * 2;
}
return 0;
}
| 1threat |
how to convert nsstring to nsarray? : <p>I have a string
Afar,Abkhazian,Afrikaans,Amharic
and i wish to convert it into the NSArray. Currently i am using the code:</p>
<pre><code> NSArray *languagesuserArray = [self.languagesOfUser componentsSeparatedByString:@""];
</code></pre>
<p>But next when i checked like this:</p>
<pre><code>NSLog(@"Languages array %@",[languagesuserArray objectAtIndex:0]);
</code></pre>
<p>the output comes:</p>
<pre><code>Afar,Abkhazian,Afrikaans,Amharic
</code></pre>
<p>But i want only afar.. How to do this?</p>
| 0debug |
Visitor *string_output_get_visitor(StringOutputVisitor *sov)
{
return &sov->visitor;
}
| 1threat |
static int assign_device(AssignedDevice *dev)
{
uint32_t flags = KVM_DEV_ASSIGN_ENABLE_IOMMU;
int r;
if (!kvm_check_extension(kvm_state, KVM_CAP_PCI_SEGMENT) &&
dev->host.domain) {
error_report("Can't assign device inside non-zero PCI segment "
"as this KVM module doesn't support it.");
return -ENODEV;
}
if (!kvm_check_extension(kvm_state, KVM_CAP_IOMMU)) {
error_report("No IOMMU found. Unable to assign device \"%s\"",
dev->dev.qdev.id);
return -ENODEV;
}
if (dev->features & ASSIGNED_DEVICE_SHARE_INTX_MASK &&
kvm_has_intx_set_mask()) {
flags |= KVM_DEV_ASSIGN_PCI_2_3;
}
r = kvm_device_pci_assign(kvm_state, &dev->host, flags, &dev->dev_id);
if (r < 0) {
switch (r) {
case -EBUSY: {
char *cause;
cause = assign_failed_examine(dev);
error_report("Failed to assign device \"%s\" : %s\n%s",
dev->dev.qdev.id, strerror(-r), cause);
g_free(cause);
break;
}
default:
error_report("Failed to assign device \"%s\" : %s",
dev->dev.qdev.id, strerror(-r));
break;
}
}
return r;
}
| 1threat |
Can't find modules required in React : <p>I was going through the React codebase, and I noticed how React's <code>require</code> doesn't quite behave like in Nodejs. I don't get what's going on here.</p>
<p>Looking at line 19 on ReactClass.js for instance, there's a <code>require('emptyObject')</code>, but emptyObject isn't listed in package.json, nor does it say anywhere where that module's coming from.</p>
<p><a href="https://github.com/facebook/react/blob/master/src/isomorphic/classic/class/ReactClass.js#L19" rel="nofollow">https://github.com/facebook/react/blob/master/src/isomorphic/classic/class/ReactClass.js#L19</a></p>
<p>I did find <a href="https://www.npmjs.com/package/emptyObject" rel="nofollow">"emptyObject" on npmjs</a>, but the API there seems different from the one used in React; the <code>.isEmpty</code> grepped in React isn't related to emptyObject.</p>
<p>So where is emptyObject getting loaded from, and how is React's <code>require</code> doing what it's doing? This is not intuitive. At all.</p>
| 0debug |
static int dvvideo_close(AVCodecContext *c)
{
DVVideoContext *s = c->priv_data;
av_free(s->dv_anchor);
return 0;
}
| 1threat |
gaierror: [Errno 8] nodename nor servname provided, or not known (with macOS Sierra) : <p>socket.gethostbyname(socket.gethostname()) worked well on OS X El Capitan. However, it's not working now after the Mac updated to macOS Sierra.</p>
<p>Thanks!</p>
<pre><code>import socket
socket.gethostbyname(socket.gethostname())
Traceback (most recent call last):
File "<pyshell#26>", line 1, in <module>
socket.gethostbyname(socket.gethostname())
gaierror: [Errno 8] nodename nor servname provided, or not known
</code></pre>
| 0debug |
This method must return a result of type double : <pre><code>public double getBalance(int account){
for(int i=0; i<this.account.size(); i++) {
BankAccount anAccount = this.account.get(i);
if(anAccount.getAccountNumber()==account) {
double balance = anAccount.getBalance();
return balance;
}
}
}
</code></pre>
<p>The error this method gives me is that the method must return a result of type double even tho I clearly return balance which is from the getBalance() method which returns a double. Why doesn't it work? I don't understand.</p>
| 0debug |
void memory_region_destroy(MemoryRegion *mr)
{
assert(QTAILQ_EMPTY(&mr->subregions));
mr->destructor(mr);
memory_region_clear_coalescing(mr);
g_free((char *)mr->name);
g_free(mr->ioeventfds);
} | 1threat |
Is it possible to track geolocation with a service worker while PWA is not open : <p>Is it possible to read from local storage and track geolocation in PWAs with a service worker while app is not open on phone (in background)</p>
<p>So far my research is pointing to no, and I am finding that the PWA needs to be open for location services.</p>
<p>Thank you,</p>
| 0debug |
Date and Time from string to php time : <p>Hi Im trying to get the string "25.01.2017 08:22:10" to a valid php time </p>
<pre><code>date_default_timezone_set('Europe/Berlin');
$format = 'Y-m-d H:i:s';
$date = DateTime::createFromFormat($format, 25.01.2017 08:22:10);
</code></pre>
<p>does not work. Maybe its because of the dots... </p>
| 0debug |
How can i create a C# structure(class) for Unity3D? : I need to edit this structure in object inspector just like on screenshot:
[Structure]
[Structure]: https://i.stack.imgur.com/cnHE5.jpg | 0debug |
how to fix the error <identifier> expected? : a code returns error <identifier> expected i dont't know why this error is occuring. I'm new to programming someone please help.!!!!!
package com.company;
import java.util.Scanner;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
intro();
time();
}
public static void intro()
{
System.out.println("Welcome");
System.out.println("What is your name");
Scanner input=new Scanner(System.in);
String name=input.nextLine();
System.out.println("Nice to meet you,"+name+" where are you travelling to?");
String dest=input.nextLine();
System.out.println("Great!"+dest+" sounds like a great trip");
}
public static void time()
{
Scanner input=new Scanner(System.in);
int hours,minutes;
float perd,perdc,change;
System.out.println("How many days are you going to spend travelling?");
int days=input.int();
hours=days*24;
minutes=hours*60;
System.out.println("How much money in USD are you going to spend?");
Double money=input.double();
perd=(money/days);
System.out.println("What is the three letter currency symbol of your destination?");
String curr=input.nextLine();
System.out.println("How many"+curr+ "are there in 1USD?");
Double ex=input.double();
change=money*ex;
perdc=perd*ex;
System.out.println("If you are travelling for"+days+"that is the same as"+hours+"or"+minutes+"minutes");
System.out.println("If you are going to spend"+money+"$USD that means per day you can spend upto $"+perd+"USD");
System.out.println("Your total budget in"+ex+"is"+change+ex+",which per day is "+perdc+curr);
}
}
a code returns error <identifier> expected i dont't know why this error is occuring. I'm new to programming someone please help.!!!!!
reports <identifier> expected | 0debug |
It's the correct format about this robot script ? But run it Error report : It is a robot script.
It's the Settings.
*** Settings ***
Suite Setup GetUrl
Test Setup Create HTTP Context ${conturl[0]["Host"]}
Library JsonLibb.py
Library RequestsLibrary
Library HttpLibrary.HTTP
It's the Test Cases.
*** Test Cases ***
Msg
Log ${con}
Run Keyword If ${con}==1 Zerocon Onecon
... ELSE If ${con}==2 Zerocon Onecon Twocon
... ELSE Log 'Error'
It's the Keywords.
*** Keywords ***
GetUrl
${conturl} Get URL Json
Set Global Variable ${conturl}
${conturl_lenth}= Get Length ${conturl}
Set Global Variable ${conturl_lenth}
:FOR ${url_lenth} IN RANGE ${conturl_lenth}
\ Set Global Variable ${url_lenth}
\ Log ${url_lenth}
${content} Get HEADER Json
Set Global Variable ${content}
${content_lenth}= Get Length ${content}
Set Global Variable ${content_lenth}
:FOR ${con} IN RANGE ${content_lenth}
\ Set Global Variable ${con}
${contbody} Get BODY Json
Set Global Variable ${contbody}
${contbody_lenth}= Get Length ${contbody}
Set Global Variable ${contbody_lenth}
:FOR ${body_lenth} IN RANGE ${contbody_lenth}
\ Set Global Variable ${body_lenth}
Zerocon
Set Request Header Cookie ${content[${0}]["COOKIE"]}
Set Request Header X-Requested-With ${content[${0}]["X-Requested-With"]}
Run Keyword If '${content[0]["method"]}'=='POST' POSTRequest
ELSE If '${content[0]["method"]}'=='GET' GETRequest
ELSE Log 'ErrorZero'
Onecon
Set Request Header Cookie ${content[${1}]["COOKIE"]}
Set Request Header X-Requested-With ${content[${1}]["X-Requested-With"]}
Run Keyword If '${content[1]["method"]}'=='POST' POSTRequest
ELSE If '${content[1]["method"]}'=='GET' GETRequest
ELSE Log 'ErrorOne'
Twocon
Set Request Header Cookie ${content[${2}]["COOKIE"]}
Set Request Header X-Requested-With ${content[${2}]["X-Requested-With"]}
Run Keyword If '${content[2]["method"]}'=='POST' POSTRequest
ELSE If '${content[2]["method"]}'=='GET' GETRequest
ELSE Log 'ErrorTwo'
POSTRequest
Run Keyword If '${url_lenth}'=='1' HttpLibrary.HTTP.POST ${conturl[0]["Uri"]}
Set Request Body ${contbody[0]}
Response Status Code Should Equal 200
Response Body Should Contain "code":0,"msg":"","data":[]
Log Response Body
HttpLibrary.HTTP.POST ${conturl[1]["Uri"]}
Set Request Body ${contbody[1]}
Response Status Code Should Equal 200
Response Body Should Contain "code":0,"msg":"","data":[]
Log Response Body
ElSE If '${url_lenth}'=='2' HttpLibrary.HTTP.POST ${conturl[0]["Uri"]}
Set Request Body ${contbody[0]}
Response Status Code Should Equal 200
Response Body Should Contain "code":0,"msg":"","data":[]
Log Response Body
HttpLibrary.HTTP.POST ${conturl[1]["Uri"]}
Set Request Body ${contbody[1]}
Response Status Code Should Equal 200
Response Body Should Contain "code":0,"msg":"","data":[]
Log Response Body
HttpLibrary.HTTP.POST ${conturl[2]["Uri"]}
Set Request Body ${contbody[2]}
Response Status Code Should Equal 200
Response Body Should Contain "code":0,"msg":"","data":[]
Log Response Body
ELSE Log "Error"
GETRequest
Run Keyword If '${url_lenth}'=='1' HttpLibrary.HTTP.GET ${conturl[0]["Uri"]}
Response Status Code Should Equal 200
Response Body Should Contain "code":0,"msg":"","data":[]
Log Response Body
HttpLibrary.HTTP.GET ${conturl[1]["Uri"]}
Response Status Code Should Equal 200
Response Body Should Contain "code":0,"msg":"","data":[]
Log Response Body
ElSE If '${url_lenth}'=='2' HttpLibrary.HTTP.GET ${conturl[0]["Uri"]}
Response Status Code Should Equal 200
Response Body Should Contain "code":0,"msg":"","data":[]
Log Response Body
HttpLibrary.HTTP.GET ${conturl[1]["Uri"]}
Response Status Code Should Equal 200
Response Body Should Contain "code":0,"msg":"","data":[]
Log Response Body
HttpLibrary.HTTP.GET ${conturl[2]["Uri"]}
Response Status Code Should Equal 200
Response Body Should Contain "code":0,"msg":"","data":[]
Log Response Body
ELSE Log "Error"
And this is the error.
===========Output============
Documentation:
Runs the given keyword with the given arguments, if condition is true.
Start / End / Elapsed: 20170317 00:42:03.544 / 20170317 00:42:03.545 / 00:00:00.001
00:00:00.001KEYWORD Zerocon Onecon, ELSE If, ${con}==2, Zerocon, Onecon, Twocon
Start / End / Elapsed: 20170317 00:42:03.544 / 20170317 00:42:03.545 / 00:00:00.001
00:42:03.545 FAIL Keyword 'Zerocon' expected 0 arguments, got 6. | 0debug |
static void fd_revalidate(FDrive *drv)
{
int rc;
FLOPPY_DPRINTF("revalidate\n");
if (drv->blk != NULL) {
drv->ro = blk_is_read_only(drv->blk);
if (!blk_is_inserted(drv->blk)) {
FLOPPY_DPRINTF("No disk in drive\n");
drv->disk = FLOPPY_DRIVE_TYPE_NONE;
} else if (!drv->media_validated) {
rc = pick_geometry(drv);
if (rc) {
FLOPPY_DPRINTF("Could not validate floppy drive media");
} else {
drv->media_validated = true;
FLOPPY_DPRINTF("Floppy disk (%d h %d t %d s) %s\n",
(drv->flags & FDISK_DBL_SIDES) ? 2 : 1,
drv->max_track, drv->last_sect,
drv->ro ? "ro" : "rw");
}
}
} else {
FLOPPY_DPRINTF("No drive connected\n");
drv->last_sect = 0;
drv->max_track = 0;
drv->flags &= ~FDISK_DBL_SIDES;
drv->drive = FLOPPY_DRIVE_TYPE_NONE;
drv->disk = FLOPPY_DRIVE_TYPE_NONE;
}
} | 1threat |
3 decimal precision in Java : <pre><code> Float x = 4;
Float answer = 4/16;
</code></pre>
<p>The answer for this is <code>0.25</code>, but I want to display the answer upto <strong>3 decimal places</strong>, like <code>0.250</code>.</p>
<p>How to achieve that? Please help?</p>
| 0debug |
Changing the value of a variable in every iteration using python : <p>Suppose
a=0
b=a+5
print b</p>
<p>I want to update the value of variable <strong>a</strong> five times. The initial value is zero. So for the next five iterations the value of <strong>a</strong> should be updated as: 10,25,50,75 and 100.</p>
| 0debug |
pass class name as argument to function : <p>Is it possible to pass ClassA as argument without using typeof or initializing it?</p>
<pre><code>class ClassA {
}
class ClassB {
public void Function([something here] clazz) {
......
}
}
class ClassC {
public void main() {
ClassB asdf = new ClassB();
asdf.Function(ClassA); // pass like that, not typeof() or something else
}
}
</code></pre>
| 0debug |
Python - Way to iterate through a string xe-1/2/3 : I have been trying this for days but nothing.
I extract multiple values of type xe-1/2/3 and so on. I have to write a python script in such a way that,
for xe-1/1/3,
if it is 1, and the next value is 1, the value gets saved for FPC1: PIC1
for xe-1/2/3
if it is 1, and the next value is 2, the value gets saved for FPC1: PIC2
for xe-2/1/3
if it is 2, and the next value is 1, the value gets saved for FPC2: PIC1
and so on ...
Need urgent help ! | 0debug |
static void arm926_initfn(Object *obj)
{
ARMCPU *cpu = ARM_CPU(obj);
cpu->dtb_compatible = "arm,arm926";
set_feature(&cpu->env, ARM_FEATURE_V5);
set_feature(&cpu->env, ARM_FEATURE_VFP);
set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN);
cpu->midr = 0x41069265;
cpu->reset_fpsid = 0x41011090;
cpu->ctr = 0x1dd20d2;
cpu->reset_sctlr = 0x00090078;
} | 1threat |
why value is undefined in node which is returned by database : <p>I am learning nedb and Node.js</p>
<p>Here is the database.js file:</p>
<pre><code>// Initialize the database
var Datastore = require('nedb');
db = new Datastore({ filename: 'db/persons.db', autoload: true });
//Returns a specific Person
exports.getPerson = function(id){
//Get the selected person details from the database
db.findOne({ _id: id }, function(err, doc){
console.log(doc);
//Execute the parameter function
return doc;
});
}
</code></pre>
<p>Now in my main.js file I am calling the getPerson function as follows:</p>
<pre><code>//Get person from the database
var person = database.getPerson(id);
console.log(id);
console.log(person);
document.getElementById('firstname').value = person.firstname;
document.getElementById('lastname').value = person.lastname;
</code></pre>
<p>In the output window of chrome browser:</p>
<p><a href="https://i.stack.imgur.com/QAz2Y.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QAz2Y.jpg" alt="enter image description here"></a></p>
| 0debug |
static void put_uint32(QEMUFile *f, void *pv, size_t size)
{
uint32_t *v = pv;
qemu_put_be32s(f, v);
}
| 1threat |
static void kvm_reset_vcpu(void *opaque)
{
CPUState *env = opaque;
kvm_arch_reset_vcpu(env);
if (kvm_arch_put_registers(env)) {
fprintf(stderr, "Fatal: kvm vcpu reset failed\n");
abort();
}
}
| 1threat |
Multiple where in one mysql query : I want to get all results which these queries give with one query;
1- $query = mysql_query("select * from table where view='1'");
2- $query = mysql_query("select * from table where view='2'");
3- $query = mysql_query("select * from table where view='3'");
4- $query = mysql_query("select * from table where view='4'");
.
.
.
999999- $query = mysql_query("select * from table where view='999999'");
How can I do that easily? | 0debug |
static inline long double compute_read_bwidth(void)
{
assert(block_mig_state.total_time != 0);
return (block_mig_state.reads * BLOCK_SIZE)/ block_mig_state.total_time;
}
| 1threat |
Cannot get MNIST database through Anaconda/jupyter : <p>Hu guys,</p>
<p>I'm new to python/anaconda/jupyter/numPy, panda, etc.... so please excuse me if it's a really stupid question.
I'm trying to obtain MNIST database by using anaconda/jupyter. But everytime I get an HTTP error 500 at the end. Is it really a server problem (as 500 would suggest) or am I doing something wrong?</p>
<p>Input in jupyter:</p>
<pre><code>from sklearn.datasets import fetch_mldata
mnist = fetch_mldata('MNIST original')
</code></pre>
<p>Result:</p>
<pre><code> ---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
<ipython-input-1-15dc285fb373> in <module>()
1 from sklearn.datasets import fetch_mldata
----> 2 mnist = fetch_mldata('MNIST original')
e:\ProgramData\Anaconda3\lib\site-packages\sklearn\datasets\mldata.py in fetch_mldata(dataname, target_name, data_name, transpose_data, data_home)
140 urlname = MLDATA_BASE_URL % quote(dataname)
141 try:
--> 142 mldata_url = urlopen(urlname)
143 except HTTPError as e:
144 if e.code == 404:
e:\ProgramData\Anaconda3\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
221 else:
222 opener = _opener
--> 223 return opener.open(url, data, timeout)
224
225 def install_opener(opener):
e:\ProgramData\Anaconda3\lib\urllib\request.py in open(self, fullurl, data, timeout)
530 for processor in self.process_response.get(protocol, []):
531 meth = getattr(processor, meth_name)
--> 532 response = meth(req, response)
533
534 return response
e:\ProgramData\Anaconda3\lib\urllib\request.py in http_response(self, request, response)
640 if not (200 <= code < 300):
641 response = self.parent.error(
--> 642 'http', request, response, code, msg, hdrs)
643
644 return response
e:\ProgramData\Anaconda3\lib\urllib\request.py in error(self, proto, *args)
562 http_err = 0
563 args = (dict, proto, meth_name) + args
--> 564 result = self._call_chain(*args)
565 if result:
566 return result
e:\ProgramData\Anaconda3\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args)
502 for handler in handlers:
503 func = getattr(handler, meth_name)
--> 504 result = func(*args)
505 if result is not None:
506 return result
e:\ProgramData\Anaconda3\lib\urllib\request.py in http_error_302(self, req, fp, code, msg, headers)
754 fp.close()
755
--> 756 return self.parent.open(new, timeout=req.timeout)
757
758 http_error_301 = http_error_303 = http_error_307 = http_error_302
e:\ProgramData\Anaconda3\lib\urllib\request.py in open(self, fullurl, data, timeout)
530 for processor in self.process_response.get(protocol, []):
531 meth = getattr(processor, meth_name)
--> 532 response = meth(req, response)
533
534 return response
e:\ProgramData\Anaconda3\lib\urllib\request.py in http_response(self, request, response)
640 if not (200 <= code < 300):
641 response = self.parent.error(
--> 642 'http', request, response, code, msg, hdrs)
643
644 return response
e:\ProgramData\Anaconda3\lib\urllib\request.py in error(self, proto, *args)
568 if http_err:
569 args = (dict, 'default', 'http_error_default') + orig_args
--> 570 return self._call_chain(*args)
571
572 # XXX probably also want an abstract factory that knows when it makes
e:\ProgramData\Anaconda3\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args)
502 for handler in handlers:
503 func = getattr(handler, meth_name)
--> 504 result = func(*args)
505 if result is not None:
506 return result
e:\ProgramData\Anaconda3\lib\urllib\request.py in http_error_default(self, req, fp, code, msg, hdrs)
648 class HTTPDefaultErrorHandler(BaseHandler):
649 def http_error_default(self, req, fp, code, msg, hdrs):
--> 650 raise HTTPError(req.full_url, code, msg, hdrs, fp)
651
652 class HTTPRedirectHandler(BaseHandler):
HTTPError: HTTP Error 500: INTERNAL SERVER ERROR
</code></pre>
| 0debug |
static bool qapi_dealloc_start_union(Visitor *v, bool data_present,
Error **errp)
{
return data_present;
}
| 1threat |
static void disas_comp_b_imm(DisasContext *s, uint32_t insn)
{
unsigned int sf, op, rt;
uint64_t addr;
int label_match;
TCGv_i64 tcg_cmp;
sf = extract32(insn, 31, 1);
op = extract32(insn, 24, 1);
rt = extract32(insn, 0, 5);
addr = s->pc + sextract32(insn, 5, 19) * 4 - 4;
tcg_cmp = read_cpu_reg(s, rt, sf);
label_match = gen_new_label();
tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ,
tcg_cmp, 0, label_match);
gen_goto_tb(s, 0, s->pc);
gen_set_label(label_match);
gen_goto_tb(s, 1, addr);
}
| 1threat |
Get specific text from html tag jquery : <p>How would I go about retrieving specific text from the HTML code? for example:</p>
<pre><code><a class="shopitem" data-minitooltip="item_123"><img src="#" alt=""></a>
</code></pre>
<p>How would I get <em>item_123</em> as text from that line using jquery?</p>
| 0debug |
static void hpet_ram_writel(void *opaque, target_phys_addr_t addr,
uint32_t value)
{
int i;
HPETState *s = opaque;
uint64_t old_val, new_val, val, index;
DPRINTF("qemu: Enter hpet_ram_writel at %" PRIx64 " = %#x\n", addr, value);
index = addr;
old_val = hpet_ram_readl(opaque, addr);
new_val = value;
if (index >= 0x100 && index <= 0x3ff) {
uint8_t timer_id = (addr - 0x100) / 0x20;
HPETTimer *timer = &s->timer[timer_id];
DPRINTF("qemu: hpet_ram_writel timer_id = %#x \n", timer_id);
if (timer_id > s->num_timers) {
DPRINTF("qemu: timer id out of range\n");
return;
}
switch ((addr - 0x100) % 0x20) {
case HPET_TN_CFG:
DPRINTF("qemu: hpet_ram_writel HPET_TN_CFG\n");
if (activating_bit(old_val, new_val, HPET_TN_FSB_ENABLE)) {
update_irq(timer, 0);
}
val = hpet_fixup_reg(new_val, old_val, HPET_TN_CFG_WRITE_MASK);
timer->config = (timer->config & 0xffffffff00000000ULL) | val;
if (new_val & HPET_TN_32BIT) {
timer->cmp = (uint32_t)timer->cmp;
timer->period = (uint32_t)timer->period;
}
if (activating_bit(old_val, new_val, HPET_TN_ENABLE)) {
hpet_set_timer(timer);
} else if (deactivating_bit(old_val, new_val, HPET_TN_ENABLE)) {
hpet_del_timer(timer);
}
break;
case HPET_TN_CFG + 4:
DPRINTF("qemu: invalid HPET_TN_CFG+4 write\n");
break;
case HPET_TN_CMP:
DPRINTF("qemu: hpet_ram_writel HPET_TN_CMP \n");
if (timer->config & HPET_TN_32BIT) {
new_val = (uint32_t)new_val;
}
if (!timer_is_periodic(timer)
|| (timer->config & HPET_TN_SETVAL)) {
timer->cmp = (timer->cmp & 0xffffffff00000000ULL) | new_val;
}
if (timer_is_periodic(timer)) {
new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1;
timer->period =
(timer->period & 0xffffffff00000000ULL) | new_val;
}
timer->config &= ~HPET_TN_SETVAL;
if (hpet_enabled(s)) {
hpet_set_timer(timer);
}
break;
case HPET_TN_CMP + 4: high order
DPRINTF("qemu: hpet_ram_writel HPET_TN_CMP + 4\n");
if (!timer_is_periodic(timer)
|| (timer->config & HPET_TN_SETVAL)) {
timer->cmp = (timer->cmp & 0xffffffffULL) | new_val << 32;
} else {
new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1;
timer->period =
(timer->period & 0xffffffffULL) | new_val << 32;
}
timer->config &= ~HPET_TN_SETVAL;
if (hpet_enabled(s)) {
hpet_set_timer(timer);
}
break;
case HPET_TN_ROUTE:
timer->fsb = (timer->fsb & 0xffffffff00000000ULL) | new_val;
break;
case HPET_TN_ROUTE + 4:
timer->fsb = (new_val << 32) | (timer->fsb & 0xffffffff);
break;
default:
DPRINTF("qemu: invalid hpet_ram_writel\n");
break;
}
return;
} else {
switch (index) {
case HPET_ID:
return;
case HPET_CFG:
val = hpet_fixup_reg(new_val, old_val, HPET_CFG_WRITE_MASK);
s->config = (s->config & 0xffffffff00000000ULL) | val;
if (activating_bit(old_val, new_val, HPET_CFG_ENABLE)) {
s->hpet_offset =
ticks_to_ns(s->hpet_counter) - qemu_get_clock_ns(vm_clock);
for (i = 0; i < s->num_timers; i++) {
if ((&s->timer[i])->cmp != ~0ULL) {
hpet_set_timer(&s->timer[i]);
}
}
} else if (deactivating_bit(old_val, new_val, HPET_CFG_ENABLE)) {
s->hpet_counter = hpet_get_ticks(s);
for (i = 0; i < s->num_timers; i++) {
hpet_del_timer(&s->timer[i]);
}
}
if (activating_bit(old_val, new_val, HPET_CFG_LEGACY)) {
hpet_pit_disable();
qemu_irq_lower(s->irqs[RTC_ISA_IRQ]);
} else if (deactivating_bit(old_val, new_val, HPET_CFG_LEGACY)) {
hpet_pit_enable();
qemu_set_irq(s->irqs[RTC_ISA_IRQ], s->rtc_irq_level);
}
break;
case HPET_CFG + 4:
DPRINTF("qemu: invalid HPET_CFG+4 write \n");
break;
case HPET_STATUS:
val = new_val & s->isr;
for (i = 0; i < s->num_timers; i++) {
if (val & (1 << i)) {
update_irq(&s->timer[i], 0);
}
}
break;
case HPET_COUNTER:
if (hpet_enabled(s)) {
DPRINTF("qemu: Writing counter while HPET enabled!\n");
}
s->hpet_counter =
(s->hpet_counter & 0xffffffff00000000ULL) | value;
DPRINTF("qemu: HPET counter written. ctr = %#x -> %" PRIx64 "\n",
value, s->hpet_counter);
break;
case HPET_COUNTER + 4:
if (hpet_enabled(s)) {
DPRINTF("qemu: Writing counter while HPET enabled!\n");
}
s->hpet_counter =
(s->hpet_counter & 0xffffffffULL) | (((uint64_t)value) << 32);
DPRINTF("qemu: HPET counter + 4 written. ctr = %#x -> %" PRIx64 "\n",
value, s->hpet_counter);
break;
default:
DPRINTF("qemu: invalid hpet_ram_writel\n");
break;
}
}
}
| 1threat |
bool qemu_co_queue_next(CoQueue *queue)
{
struct unlock_bh *unlock_bh;
Coroutine *next;
next = QTAILQ_FIRST(&queue->entries);
if (next) {
QTAILQ_REMOVE(&queue->entries, next, co_queue_next);
QTAILQ_INSERT_TAIL(&unlock_bh_queue, next, co_queue_next);
trace_qemu_co_queue_next(next);
unlock_bh = qemu_malloc(sizeof(*unlock_bh));
unlock_bh->bh = qemu_bh_new(qemu_co_queue_next_bh, unlock_bh);
qemu_bh_schedule(unlock_bh->bh);
}
return (next != NULL);
}
| 1threat |
Trouble writing If-Statements : //main code\\
<html>
<head>
<script language="javascript" type="text/javascript" src="codeChallenge3.js"></script>
</head>
<body>
<head>CONDITIONALS CODE </head>
<p></p>
<hr/>
<h2>Task #1</h2>
<script>
//#2
var phoneNum = "555-5555";
document.write("Check the following phone number: ", phoneNum, " = ", validPhone(phoneNum));
</script>
</body>
</html>
//function\\
function validPhone(phoneNum)
var
if () {
return "True"
}
else() {
return "False";
}
I have trouble writing if statements so can someone help me by giving me hints to determine if a number is a valid home phone number (without area code) | 0debug |
Mean for every columm of a matrix in R : How,can I get the mean of each column, each column contain multiple value, and there are 1000 of column. I dont want to use loop for efficiency reason.
For example data look like
col1 col2 .........coln
v1 c(10,11,12....) c(12,11,9....) c(12,11,9....)
v2 c(1,1,1,1,1,1...) c(1,1,1,1,1,1...) c(1,1,1,1,1,1...)
v3 c(0 ,0,1,2,3,..) c(0 ,0,2,2,2,3,..) c(0 ,0,2,2,2,3,..)
v4 c(date1,dat2,....) c(date1,dat2,....) c(date1,dat2,....)
I want to calculate the mean for V1 row for every column.
Thanks | 0debug |
import math
def radian_degree(degree):
radian = degree*(math.pi/180)
return radian | 0debug |
static void kvm_s390_flic_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
S390FLICStateClass *fsc = S390_FLIC_COMMON_CLASS(oc);
dc->realize = kvm_s390_flic_realize;
dc->vmsd = &kvm_s390_flic_vmstate;
dc->reset = kvm_s390_flic_reset;
fsc->register_io_adapter = kvm_s390_register_io_adapter;
fsc->io_adapter_map = kvm_s390_io_adapter_map;
fsc->add_adapter_routes = kvm_s390_add_adapter_routes;
fsc->release_adapter_routes = kvm_s390_release_adapter_routes;
fsc->clear_io_irq = kvm_s390_clear_io_flic;
} | 1threat |
Python-docx, how to set cell width in tables? : <p>How to set cell width in tables?, so far I got:</p>
<pre><code>from docx import Document
from docx.shared import Cm, Inches
document = Document()
table = document.add_table(rows=2, cols=2)
table.style = 'TableGrid' #single lines in all cells
table.autofit = False
col = table.columns[0]
col.width=Inches(0.5)
#col.width=Cm(1.0)
#col.width=360000 #=1cm
document.save('test.docx')
</code></pre>
<p>No mater what number or units I set in col.width, its width does not change.</p>
| 0debug |
static void ivshmem_common_realize(PCIDevice *dev, Error **errp)
{
IVShmemState *s = IVSHMEM_COMMON(dev);
Error *err = NULL;
uint8_t *pci_conf;
uint8_t attr = PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_PREFETCH;
Error *local_err = NULL;
if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD) &&
!ivshmem_has_feature(s, IVSHMEM_MSI)) {
error_setg(errp, "ioeventfd/irqfd requires MSI");
return;
}
pci_conf = dev->config;
pci_conf[PCI_COMMAND] = PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
memory_region_init_io(&s->ivshmem_mmio, OBJECT(s), &ivshmem_mmio_ops, s,
"ivshmem-mmio", IVSHMEM_REG_BAR_SIZE);
pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY,
&s->ivshmem_mmio);
if (s->not_legacy_32bit) {
attr |= PCI_BASE_ADDRESS_MEM_TYPE_64;
}
if (s->hostmem != NULL) {
IVSHMEM_DPRINTF("using hostmem\n");
s->ivshmem_bar2 = host_memory_backend_get_memory(s->hostmem,
&error_abort);
} else {
Chardev *chr = qemu_chr_fe_get_driver(&s->server_chr);
assert(chr);
IVSHMEM_DPRINTF("using shared memory server (socket = %s)\n",
chr->filename);
resize_peers(s, 16);
ivshmem_recv_setup(s, &err);
if (err) {
error_propagate(errp, err);
return;
}
if (s->master == ON_OFF_AUTO_ON && s->vm_id != 0) {
error_setg(errp,
"master must connect to the server before any peers");
return;
}
qemu_chr_fe_set_handlers(&s->server_chr, ivshmem_can_receive,
ivshmem_read, NULL, s, NULL, true);
if (ivshmem_setup_interrupts(s) < 0) {
error_setg(errp, "failed to initialize interrupts");
return;
}
}
if (s->master == ON_OFF_AUTO_AUTO) {
s->master = s->vm_id == 0 ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF;
}
if (!ivshmem_is_master(s)) {
error_setg(&s->migration_blocker,
"Migration is disabled when using feature 'peer mode' in device 'ivshmem'");
migrate_add_blocker(s->migration_blocker, &local_err);
if (local_err) {
error_propagate(errp, local_err);
error_free(s->migration_blocker);
return;
}
}
vmstate_register_ram(s->ivshmem_bar2, DEVICE(s));
pci_register_bar(PCI_DEVICE(s), 2, attr, s->ivshmem_bar2);
}
| 1threat |
static void bdrv_aio_bh_cb(void *opaque)
{
BlockDriverAIOCBSync *acb = opaque;
if (!acb->is_write)
qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size);
qemu_vfree(acb->bounce);
acb->common.cb(acb->common.opaque, acb->ret);
qemu_bh_delete(acb->bh);
acb->bh = NULL;
qemu_aio_release(acb);
}
| 1threat |
How do i install gradle on WINDOWS 10 : <p>I tried some ways with the path thing but it didnt work because when i edit the path in System variables it opens up all the paths not like in tutorials where i should just put the ;%GRADLE_HOME%\bin at the end.</p>
<p><a href="https://i.stack.imgur.com/CJTlf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/CJTlf.png" alt="enter image description here"></a> </p>
<p><a href="https://i.stack.imgur.com/mZUTk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mZUTk.png" alt="enter image description here"></a></p>
| 0debug |
Using C# 7.2 in modifier for parameters with primitive types : <p>C# 7.2 introduced the <code>in</code> modifier for passing arguments by reference with the guarantee that the recipient will not modify the parameter.</p>
<p>This <a href="https://blogs.msdn.microsoft.com/seteplia/2018/03/07/the-in-modifier-and-the-readonly-structs-in-c/" rel="noreferrer">article</a> says:</p>
<blockquote>
<p>You should never use a non-readonly struct as the in parameters because it may negatively affect performance and could lead to an obscure behavior if the struct is mutable</p>
</blockquote>
<p>What does this mean for built-in primitives such as <code>int</code>, <code>double</code>?</p>
<p>I would like to use <code>in</code> to express intent in code, but not at the cost of performance losses to defensive copies.</p>
<p>Questions</p>
<ul>
<li>Is it safe to pass primitive types via <code>in</code> arguments and not have defensive copies made?</li>
<li>Are other commonly used framework structs such as <code>DateTime</code>, <code>TimeSpan</code>, <code>Guid</code>, ... considered <code>readonly</code> by the JIT?
<ul>
<li>If this varies by platform, how can we find out which types are safe in a given situation?</li>
</ul></li>
</ul>
| 0debug |
void OPPROTO op_subfco (void)
{
do_subfco();
RETURN();
}
| 1threat |
static int mp_dacl_removexattr(FsContext *ctx,
const char *path, const char *name)
{
int ret;
char *buffer;
buffer = rpath(ctx, path);
ret = lremovexattr(buffer, MAP_ACL_DEFAULT);
if (ret == -1 && errno == ENODATA) {
errno = 0;
ret = 0;
}
g_free(buffer);
return ret;
}
| 1threat |
How to prevent page refresh after sending email? : <p>I made a landing site with a email form.</p>
<p>Every time I click submit, whether the form is completely filled out or not, the page refreshes and goes to the top.</p>
<p>How can I not letting it refresh and still send the mail?</p>
<p>If that's not possible, how do I automatically go back to the contact section/div after the page refresh?</p>
| 0debug |
void h263_encode_picture_header(MpegEncContext * s, int picture_number)
{
int format;
align_put_bits(&s->pb);
put_bits(&s->pb, 22, 0x20);
put_bits(&s->pb, 8, ((s->picture_number * 30 * FRAME_RATE_BASE) /
s->frame_rate) & 0xff);
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 0);
format = h263_get_picture_format(s->width, s->height);
if (!s->h263_plus) {
put_bits(&s->pb, 3, format);
put_bits(&s->pb, 1, (s->pict_type == P_TYPE));
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 5, s->qscale);
put_bits(&s->pb, 1, 0);
} else {
put_bits(&s->pb, 3, 7);
put_bits(&s->pb,3,1);
if (format == 7)
put_bits(&s->pb,3,6);
else
put_bits(&s->pb, 3, format);
put_bits(&s->pb,1,0);
umvplus = (s->pict_type == P_TYPE) && s->unrestricted_mv;
put_bits(&s->pb, 1, umvplus);
put_bits(&s->pb,1,0);
put_bits(&s->pb,1,0);
put_bits(&s->pb,1,0);
put_bits(&s->pb,1,0);
put_bits(&s->pb,1,0);
put_bits(&s->pb,1,0);
put_bits(&s->pb,1,0);
put_bits(&s->pb,1,0);
put_bits(&s->pb,1,0);
put_bits(&s->pb,1,1);
put_bits(&s->pb,3,0);
put_bits(&s->pb, 3, s->pict_type == P_TYPE);
put_bits(&s->pb,1,0);
put_bits(&s->pb,1,0);
put_bits(&s->pb,1,0);
put_bits(&s->pb,2,0);
put_bits(&s->pb,1,1);
put_bits(&s->pb, 1, 0);
if (format == 7) {
put_bits(&s->pb,4,2);
put_bits(&s->pb,9,(s->width >> 2) - 1);
put_bits(&s->pb,1,1);
put_bits(&s->pb,9,(s->height >> 2));
}
if (umvplus)
put_bits(&s->pb,1,1);
put_bits(&s->pb, 5, s->qscale);
}
put_bits(&s->pb, 1, 0);
}
| 1threat |
Can i make a opening text for website for the amount of time given? : <p>I want to make a website having a opening text that will appear for 5seconds without having to make a new page.
Can i do that without making a new page and just use some scripts or something cuz i dont want to make a new page.</p>
| 0debug |
static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
MpegEncContext * const s = &h->s;
int i, j;
int current_ref_assigned=0;
Picture *pic;
if((s->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0)
av_log(h->s.avctx, AV_LOG_DEBUG, "no mmco here\n");
for(i=0; i<mmco_count; i++){
int structure, frame_num, unref_pic;
if(s->avctx->debug&FF_DEBUG_MMCO)
av_log(h->s.avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_pic_num, h->mmco[i].long_arg);
switch(mmco[i].opcode){
case MMCO_SHORT2UNUSED:
if(s->avctx->debug&FF_DEBUG_MMCO)
av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n", h->mmco[i].short_pic_num, h->short_ref_count);
frame_num = pic_num_extract(h, mmco[i].short_pic_num, &structure);
pic = find_short(h, frame_num, &j);
if (pic) {
if (unreference_pic(h, pic, structure ^ PICT_FRAME))
remove_short_at_index(h, j);
} else if(s->avctx->debug&FF_DEBUG_MMCO)
av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref short failure\n");
break;
case MMCO_SHORT2LONG:
if (FIELD_PICTURE && mmco[i].long_arg < h->long_ref_count &&
h->long_ref[mmco[i].long_arg]->frame_num ==
mmco[i].short_pic_num / 2) {
} else {
int frame_num = mmco[i].short_pic_num >> FIELD_PICTURE;
pic= remove_long(h, mmco[i].long_arg);
if(pic) unreference_pic(h, pic, 0);
h->long_ref[ mmco[i].long_arg ]= remove_short(h, frame_num);
if (h->long_ref[ mmco[i].long_arg ]){
h->long_ref[ mmco[i].long_arg ]->long_ref=1;
h->long_ref_count++;
}
}
break;
case MMCO_LONG2UNUSED:
j = pic_num_extract(h, mmco[i].long_arg, &structure);
pic = h->long_ref[j];
if (pic) {
if (unreference_pic(h, pic, structure ^ PICT_FRAME))
remove_long_at_index(h, j);
} else if(s->avctx->debug&FF_DEBUG_MMCO)
av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref long failure\n");
break;
case MMCO_LONG:
unref_pic = 1;
if (FIELD_PICTURE && !s->first_field) {
if (h->long_ref[mmco[i].long_arg] == s->current_picture_ptr) {
unref_pic = 0;
} else if (s->current_picture_ptr->reference) {
av_log(h->s.avctx, AV_LOG_ERROR,
"illegal long term reference assignment for second "
"field in complementary field pair (first field is "
"short term or has non-matching long index)\n");
unref_pic = 0;
}
}
if (unref_pic) {
pic= remove_long(h, mmco[i].long_arg);
if(pic) unreference_pic(h, pic, 0);
h->long_ref[ mmco[i].long_arg ]= s->current_picture_ptr;
h->long_ref[ mmco[i].long_arg ]->long_ref=1;
h->long_ref_count++;
}
s->current_picture_ptr->reference |= s->picture_structure;
current_ref_assigned=1;
break;
case MMCO_SET_MAX_LONG:
assert(mmco[i].long_arg <= 16);
for(j = mmco[i].long_arg; j<16; j++){
pic = remove_long(h, j);
if (pic) unreference_pic(h, pic, 0);
}
break;
case MMCO_RESET:
while(h->short_ref_count){
pic= remove_short(h, h->short_ref[0]->frame_num);
if(pic) unreference_pic(h, pic, 0);
}
for(j = 0; j < 16; j++) {
pic= remove_long(h, j);
if(pic) unreference_pic(h, pic, 0);
}
s->current_picture_ptr->poc=
s->current_picture_ptr->field_poc[0]=
s->current_picture_ptr->field_poc[1]=
h->poc_lsb=
h->poc_msb=
h->frame_num=
s->current_picture_ptr->frame_num= 0;
break;
default: assert(0);
}
}
if (!current_ref_assigned && FIELD_PICTURE &&
!s->first_field && s->current_picture_ptr->reference) {
if (h->short_ref_count && h->short_ref[0] == s->current_picture_ptr) {
s->current_picture_ptr->reference = PICT_FRAME;
} else if (s->current_picture_ptr->long_ref) {
av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term reference "
"assignment for second field "
"in complementary field pair "
"(first field is long term)\n");
} else {
assert(0);
}
current_ref_assigned = 1;
}
if(!current_ref_assigned){
pic= remove_short(h, s->current_picture_ptr->frame_num);
if(pic){
unreference_pic(h, pic, 0);
av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term buffer state detected\n");
}
if(h->short_ref_count)
memmove(&h->short_ref[1], &h->short_ref[0], h->short_ref_count*sizeof(Picture*));
h->short_ref[0]= s->current_picture_ptr;
h->short_ref[0]->long_ref=0;
h->short_ref_count++;
s->current_picture_ptr->reference |= s->picture_structure;
}
if (h->long_ref_count + h->short_ref_count > h->sps.ref_frame_count){
av_log(h->s.avctx, AV_LOG_ERROR,
"number of reference frames exceeds max (probably "
"corrupt input), discarding one\n");
if (h->long_ref_count && !h->short_ref_count) {
for (i = 0; i < 16; ++i)
if (h->long_ref[i])
break;
assert(i < 16);
pic = h->long_ref[i];
remove_long_at_index(h, i);
} else {
pic = h->short_ref[h->short_ref_count - 1];
remove_short_at_index(h, h->short_ref_count - 1);
}
unreference_pic(h, pic, 0);
}
print_short_term(h);
print_long_term(h);
return 0;
}
| 1threat |
Downloading mutliple stocks at once from yahoo finance python : <p>I have a question about the function of yahoo finance using the pandas data reader. I'm using for months now a list with stock tickers and execute it in the following lines:</p>
<pre><code>import pandas_datareader as pdr
import datetime
stocks = ["stock1","stock2",....]
start = datetime.datetime(2012,5,31)
end = datetime.datetime(2018,3,1)
f = pdr.DataReader(stocks, 'yahoo',start,end)
</code></pre>
<p>Since yesterday i get the error "IndexError: list index out of range", which appears only if I try to get multiple stocks.</p>
<p>Has anything changed in recent days which I have to consider or do you have a better solution for my problem?</p>
| 0debug |
Scroll second child in AppBarLayout : <p>I'm trying to obtain this effect where if the user scroll a <code>RecyclerView</code> a certain layout scroll up together with the recycler and disappear behind a <code>Toolbar</code>.</p>
<p>A similar behavior could be obtained using the <code>CoordinatorLayout</code>, this would be possible by setting</p>
<pre><code>app:layout_behavior="@string/appbar_scrolling_view_behavior"
</code></pre>
<p>on the said Recycler, and doing</p>
<pre><code><android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.AppBarLayout>
</code></pre>
<p>Also, If I put a second child inside the <code>AppBarLayout</code>, and set <code>app:layout_scrollFlags</code> to it, the effect obtained is the same, with both layout scrolling together with the Recycler.</p>
<p>What I'm trying to achieve is to keep the first child (The toolbar) fixed in position, and let the second child (a <code>LinearLayout</code>) to scroll and hide behind the toolbar. Unfortunately I couldn't get to this behavior.</p>
<p>Is it possible without using 3rd part library?
Thanks in advance and sorry for my english.</p>
| 0debug |
take an arrary as input in golang : <p>How am I goingt take an array as input in golang ?</p>
<pre><code>func main() {
var inPut []float32
fmt.Printf("Input? ")
fmt.Scanf("%s", &inPut)
fmt.Println(inPut)
for _, value := range inPut {
fmt.Print(value)
}
}
</code></pre>
<p>I tried the code above and it doesn't give me the right answer, should I use another type of scanner ? </p>
<p>the input I want to take in is something like [3.2 -6.77 42 -0.9]</p>
| 0debug |
static void send_scsi_cdb_read10(QPCIDevice *dev, void *ide_base,
uint64_t lba, int nblocks)
{
Read10CDB pkt = { .padding = 0 };
int i;
g_assert_cmpint(lba, <=, UINT32_MAX);
g_assert_cmpint(nblocks, <=, UINT16_MAX);
g_assert_cmpint(nblocks, >=, 0);
pkt.opcode = 0x28;
pkt.lba = cpu_to_be32(lba);
pkt.nblocks = cpu_to_be16(nblocks);
for (i = 0; i < sizeof(Read10CDB)/2; i++) {
qpci_io_writew(dev, ide_base + reg_data,
le16_to_cpu(((uint16_t *)&pkt)[i]));
}
}
| 1threat |
What's the difference between localhost.log, catalina.log, manager.log, host-manager.log ? : <p>I'm using Tomee. The logs folder contains files like this </p>
<ol>
<li>localhost_access_log.2016-12-02.txt</li>
<li>localhost.2016-12-02.log</li>
<li>catalina.2016-12-02.log</li>
<li>host-manager.2016-12-02.log</li>
<li>manager.2016-12-02.log</li>
</ol>
<p>I was looking for an explanation in the documentation but could find anything. It's my understanding that those <code>localhost</code> files log only the 'host computer' activity. It this right? What is the difference between these file? Do they record different types of messages? </p>
| 0debug |
def odd_Equivalent(s,n):
count=0
for i in range(0,n):
if (s[i] == '1'):
count = count + 1
return count | 0debug |
bad input in Python what shoul i do : I hava a Problem to invert the variable sum to float, the Problem seems from the line under try.
while True:
num = input("Enter a number: ")
if num == "done" : break
try:
**fnum = float(num)**
except:
print("Invalid input")
continue
print(fnum) | 0debug |
bool qemu_aio_wait(void)
{
AioHandler *node;
fd_set rdfds, wrfds;
int max_fd = -1;
int ret;
bool busy;
if (qemu_bh_poll()) {
return true;
}
walking_handlers++;
FD_ZERO(&rdfds);
FD_ZERO(&wrfds);
busy = false;
QLIST_FOREACH(node, &aio_handlers, node) {
if (node->io_flush) {
if (node->io_flush(node->opaque) == 0) {
continue;
}
busy = true;
}
if (!node->deleted && node->io_read) {
FD_SET(node->fd, &rdfds);
max_fd = MAX(max_fd, node->fd + 1);
}
if (!node->deleted && node->io_write) {
FD_SET(node->fd, &wrfds);
max_fd = MAX(max_fd, node->fd + 1);
}
}
walking_handlers--;
if (!busy) {
return false;
}
ret = select(max_fd, &rdfds, &wrfds, NULL, NULL);
if (ret > 0) {
walking_handlers++;
node = QLIST_FIRST(&aio_handlers);
while (node) {
AioHandler *tmp;
if (!node->deleted &&
FD_ISSET(node->fd, &rdfds) &&
node->io_read) {
node->io_read(node->opaque);
}
if (!node->deleted &&
FD_ISSET(node->fd, &wrfds) &&
node->io_write) {
node->io_write(node->opaque);
}
tmp = node;
node = QLIST_NEXT(node, node);
if (tmp->deleted) {
QLIST_REMOVE(tmp, node);
g_free(tmp);
}
}
walking_handlers--;
}
return true;
}
| 1threat |
can I send vedios to android devices using gcm? : If not please suggest me how to send videos to android devices using c#. Earlier I have succeeded using gcm I easily sent out pushnotifications to android devices. My doubt is can I sent videos to android devices using gcm? | 0debug |
R: How to Delete All Columns in a Dataframe Except A Specified Few By String : <p>I have a data frame in R that consists of around 400 variables (as columns), though I only need 25 of them. While I know how to delete specific columns, because of the impracticality of deleting 375 variables - is there any method in which I could delete all of them, except the specified 25 by using the variable's string name? </p>
<p>Thanks. </p>
| 0debug |
PHP/MySQLi: Get recent 10 entries from all tables : Is there any way to get last entry from all tables? I even did not find way to query all tables, tried this: [code]SELECT * FROM *[/code]. | 0debug |
static void free_texture(void *opaque, uint8_t *data)
{
ID3D11Texture2D_Release((ID3D11Texture2D *)opaque);
} | 1threat |
getting maximum value from array in c++ using pointer : I am gonna want maximum value from the array using pointer. But am not getting the accurate value. Please, help.
#include <iostream>
using namespace std;
int main()
{
int* largest;
int a[5]={4,5,666,7,8};
largest=a;
for(int i=1; i<5; i++)
{
if(*largest<*(largest+i))
{
*largest=*(largest+i);
largest=largest+i;
}
}
cout<<*largest;
}
I am getting 7339544 as output rather than 666. I don't know what I am doing wrong. | 0debug |
Jquery stop calculation using this : <p>I am trying to make some calculations between inputs , I have 7 inputs and what I want to do is making calculations between them , so this is my code </p>
<pre><code> $('.empCosts').on('input', function () {
var perHour = parseInt($('#per_hour').val());
var hours = parseInt($('#hour').val());
var perDay = parseInt($('#per_day').val());
var days = parseInt($('#day').val());
var perMonth = parseInt($('#per_month').val());
var month = parseInt($('#months').val());
var perYear = parseInt($('#per_year').val());
var perdayVal = parseInt(perHour * hours);
var perMonthVal = parseInt(perDay * days);
var perYearVal = parseInt(perMonth * month);
var perHourVal = parseInt(perDay / hours);
var perMonthDivide = parseInt(perYearVal / month);
$("#per_day").val(perdayVal);
$("#per_month").val(perMonthVal);
$("#per_year").val(perYearVal);
$("#per_hour").val(perHourVal);
if($(this).is(":focus")){
alert('sdfasdfad');
}
});
</code></pre>
<p>these inputs should be connected either you multiply or divide , when I try to change per_day value it doesn't change because I already set the value of that input with var <code>perdayVal = parseInt(perHour * hours);</code>, I want either you increase the number or decrease it , it should make the calculation either multiplying or dividing the inputs, here you have the fiddle</p>
<p><a href="https://jsfiddle.net/2jb2e3Lv/" rel="nofollow noreferrer">DEMO</a></p>
| 0debug |
How a dbms server sends a ResultSet to a client? : <p>I know that ResultSet cannot be serializable due to the connection details present in it. How a database server is able to send a ResultSet which has a connection in it? Can anyone explain this process? I am not able to understand this concept properly. I searched on the internet, and I could not find the relevant details.</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.