problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
how to check for an empty array java : <p>I wanted to know if this code is valid for checking whether an array is empty, or should I check for null?</p>
<pre><code>if(arrayName={})
System.out.println("array empty");
else System.out.println("array not empty");
</code></pre>
<p>Thank you!</p>
| 0debug
|
static inline void vmsvga_update_rect(struct vmsvga_state_s *s,
int x, int y, int w, int h)
{
#ifndef DIRECT_VRAM
int line = h;
int bypl = s->bypp * s->width;
int width = s->bypp * w;
int start = s->bypp * x + bypl * y;
uint8_t *src = s->vram + start;
uint8_t *dst = s->ds->data + start;
for (; line > 0; line --, src += bypl, dst += bypl)
memcpy(dst, src, width);
#endif
dpy_update(s->ds, x, y, w, h);
}
| 1threat
|
How to formal float 0.5 to float 0.50 : I am studying FreeCodeCamp course-"Exact Change".
I need to convert float-type-data 0.5 to float-type-data 0.50, I have try some solutions but not work!
float.toFixed(2) return a string-type "0.50", and if I use parseFloat("0.50") it will return float-type-data 0.5!
How can i solve this issue?
| 0debug
|
Mapbox Examples in android studio - how to begin : I'd like to begin loading mapbox examples in AndroidStudio. I followed guides, but I'm struggling with dependencies problems.
Can someone help me, please?
I downloaded examples from github and loaded it in my AndroidStudio.
I follow all explanations, dependencies.... repositories... ecc
I syncronized Gradle and it is ok.
But example don't works !
Is there any example that simply I can download and works?
Thank and bye.
| 0debug
|
void dump_exec_info(FILE *f, fprintf_function cpu_fprintf)
{
int i, target_code_size, max_target_code_size;
int direct_jmp_count, direct_jmp2_count, cross_page;
TranslationBlock *tb;
target_code_size = 0;
max_target_code_size = 0;
cross_page = 0;
direct_jmp_count = 0;
direct_jmp2_count = 0;
for (i = 0; i < tcg_ctx.tb_ctx.nb_tbs; i++) {
tb = &tcg_ctx.tb_ctx.tbs[i];
target_code_size += tb->size;
if (tb->size > max_target_code_size) {
max_target_code_size = tb->size;
}
if (tb->page_addr[1] != -1) {
cross_page++;
}
if (tb->tb_next_offset[0] != 0xffff) {
direct_jmp_count++;
if (tb->tb_next_offset[1] != 0xffff) {
direct_jmp2_count++;
}
}
}
cpu_fprintf(f, "Translation buffer state:\n");
cpu_fprintf(f, "gen code size %td/%zd\n",
tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer,
tcg_ctx.code_gen_buffer_max_size);
cpu_fprintf(f, "TB count %d/%d\n",
tcg_ctx.tb_ctx.nb_tbs, tcg_ctx.code_gen_max_blocks);
cpu_fprintf(f, "TB avg target size %d max=%d bytes\n",
tcg_ctx.tb_ctx.nb_tbs ? target_code_size /
tcg_ctx.tb_ctx.nb_tbs : 0,
max_target_code_size);
cpu_fprintf(f, "TB avg host size %td bytes (expansion ratio: %0.1f)\n",
tcg_ctx.tb_ctx.nb_tbs ? (tcg_ctx.code_gen_ptr -
tcg_ctx.code_gen_buffer) /
tcg_ctx.tb_ctx.nb_tbs : 0,
target_code_size ? (double) (tcg_ctx.code_gen_ptr -
tcg_ctx.code_gen_buffer) /
target_code_size : 0);
cpu_fprintf(f, "cross page TB count %d (%d%%)\n", cross_page,
tcg_ctx.tb_ctx.nb_tbs ? (cross_page * 100) /
tcg_ctx.tb_ctx.nb_tbs : 0);
cpu_fprintf(f, "direct jump count %d (%d%%) (2 jumps=%d %d%%)\n",
direct_jmp_count,
tcg_ctx.tb_ctx.nb_tbs ? (direct_jmp_count * 100) /
tcg_ctx.tb_ctx.nb_tbs : 0,
direct_jmp2_count,
tcg_ctx.tb_ctx.nb_tbs ? (direct_jmp2_count * 100) /
tcg_ctx.tb_ctx.nb_tbs : 0);
cpu_fprintf(f, "\nStatistics:\n");
cpu_fprintf(f, "TB flush count %d\n", tcg_ctx.tb_ctx.tb_flush_count);
cpu_fprintf(f, "TB invalidate count %d\n",
tcg_ctx.tb_ctx.tb_phys_invalidate_count);
cpu_fprintf(f, "TLB flush count %d\n", tlb_flush_count);
tcg_dump_info(f, cpu_fprintf);
}
| 1threat
|
alert('Hello ' + user_input);
| 1threat
|
What does command cat /etc/group mean : <p>I have used a command called 'cat /etc/group' what does this command mean and do.Can you tell me what each part of the command does please use simple terms.</p>
| 0debug
|
Unable to read MySQL log file : <p>Hey I am trying to read any "root" string in the log file name "SHIKHAR.log" but the compiler keeps on showing.</p>
<pre><code>dam.java:12: error: cannot find symbol
System.out.println("I found in file " +SHIKHAR.getName());
^
symbol: variable SHIKHAR
location: class dam
1 error
</code></pre>
<p>I am not sure what's wrong with it I have tried appending the extensions and try it otherwise aswell but it doesn't work.</p>
<pre><code>import java.util.Scanner;
import java.io.*;
class dam
{
public static void main (String arg[])
{
final Scanner scanner = new Scanner("SHIKHAR");
while (scanner.hasNextLine()) {
final String lineFromFile = scanner.nextLine();
if(lineFromFile.contains("root")) {
// a match!
System.out.println("I found in file " +SHIKHAR.getName());
break;
}
}
}
}
</code></pre>
| 0debug
|
Selecting multiple checkboxes from a table javascript : <p>first question here and novice programmer, i'll try to keep it simple and to the point. </p>
<p>In my HTML code, I have a table consisting of hundreds of rows, with a checkbox next to each one, so the user can 'select' which lines they want. I need to have it so if the user picks lines, lets say line 300 and line 400 (arbitrary numbers), lines 300-400 will all be checked. I'm not quite sure at all how to do this, my coworkers say it is possible, any help would be greatly appreciated. Thanks guys.</p>
| 0debug
|
round a column in dataframe : <p>I have a dataframe 'dayData' and I am trying to round a zero decimal places one of the columns (the column is called 'trace')</p>
<p>I have tried using the following but with no success:</p>
<pre><code>dayData["trace"] = dayData["trace"].round(0)
</code></pre>
<p>I get the exception:</p>
<pre><code>AttributeError: 'numpy.float64' object has no attribute 'rint'
</code></pre>
<p>Could someone let me know the correct syntax please.</p>
<p>Many thanks</p>
| 0debug
|
static void build_file_streams(void)
{
FFStream *stream, *stream_next;
AVFormatContext *infile;
int i;
for(stream = first_stream; stream != NULL; stream = stream_next) {
stream_next = stream->next;
if (stream->stream_type == STREAM_TYPE_LIVE &&
!stream->feed) {
stream->ap_in = av_mallocz(sizeof(AVFormatParameters));
if (!strcmp(stream->fmt->name, "rtp")) {
stream->ap_in->mpeg2ts_raw = 1;
stream->ap_in->mpeg2ts_compute_pcr = 1;
}
if (av_open_input_file(&infile, stream->feed_filename,
stream->ifmt, 0, stream->ap_in) < 0) {
http_log("%s not found", stream->feed_filename);
fail:
remove_stream(stream);
} else {
if (av_find_stream_info(infile) < 0) {
http_log("Could not find codec parameters from '%s'",
stream->feed_filename);
av_close_input_file(infile);
goto fail;
}
extract_mpeg4_header(infile);
for(i=0;i<infile->nb_streams;i++)
add_av_stream1(stream, infile->streams[i]->codec);
av_close_input_file(infile);
}
}
}
}
| 1threat
|
Using 'ref' on React Styled Components is not working : <p>I am having difficulty using <code>ref</code>s with Styled Components. When I try to access them in my class methods like below, I get the following error:</p>
<blockquote>
<p>Edit.js:42 Uncaught TypeError: this.....contains is not a function</p>
</blockquote>
<pre><code> constructor(props) {
....
this.setWrapperRef = this.setWrapperRef.bind(this);
this.handleClickOutside = this.handleClickOutside.bind(this);
}
----------
setWrapperRef = (node) => {
this.wrapperRef = node;
}
handleEdit = (e) => {
e.preventDefault();
this.props.onEdit(this.props.id, this.state.title);
}
----------
<Wrapper onSubmit={this.handleEdit} ref={this.setWrapperRef}>
...
</Wrapper>
</code></pre>
<p>I found the code from <a href="https://stackoverflow.com/questions/32553158/detect-click-outside-react-component">this question</a></p>
<p>What am I doing wrong here?</p>
| 0debug
|
Getting Used Undeclared dependencies : <p>While installing project, I have got an error which says "Used undeclared dependencies found"</p>
<p>I tried using maven dependency plugin and used tag. But still, the error is same.</p>
<p>Then I tried explicitly adding the dependency in the main pom, but still the same error was thrown.</p>
<p>Can anyone help me in this situation?</p>
<p>Thanks in advance.</p>
| 0debug
|
static void gen_rfe(DisasContext *s, TCGv_i32 pc, TCGv_i32 cpsr)
{
gen_set_cpsr(cpsr, CPSR_ERET_MASK);
tcg_temp_free_i32(cpsr);
store_reg(s, 15, pc);
s->is_jmp = DISAS_JUMP;
}
| 1threat
|
Using variables from other functions in Javascript : <p>I have searched the internet trying to find a good answer for this question. What I mainly found is suggestions to move the variable in the global scope, or using the functions as parameters for the function I want to use the variable in, but without explanation on how that works</p>
<p>To explain my dilema, lets say we have this piece of code:</p>
<pre><code>function foo(){
var x = 2;
}
function bar(){
var z = 2;
}
function compare(foo,bar){
if ( z === x ) {
console.log("text");
}
}
</code></pre>
<p>This is the problem I'm facing. Is the code I've written above correct and if I call the compare() function it should console log "text" ?</p>
| 0debug
|
static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)
{
#if COMPILE_TEMPLATE_MMX
RENAME(bgr24ToUV_mmx)(dstU, dstV, src1, width, PIX_FMT_BGR24);
#else
int i;
for (i=0; i<width; i++) {
int b= src1[3*i + 0];
int g= src1[3*i + 1];
int r= src1[3*i + 2];
dstU[i]= (RU*r + GU*g + BU*b + (257<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT;
dstV[i]= (RV*r + GV*g + BV*b + (257<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT;
}
#endif
assert(src1 == src2);
}
| 1threat
|
static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pic_arg, int *got_packet)
{
MpegEncContext *s = avctx->priv_data;
AVFrame *pic;
int i, ret;
int chroma_h_shift, chroma_v_shift;
av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift, &chroma_v_shift);
if(s->avctx->flags & CODEC_FLAG_EMU_EDGE)
return AVERROR(EINVAL);
if (avctx->height & 15) {
av_log(avctx, AV_LOG_ERROR,
"Height must be a multiple of 16, also note, "
"if you have a AMV sample thats mod 16 != 0, please contact us\n");
return AVERROR(EINVAL);
}
pic = av_frame_clone(pic_arg);
if (!pic)
return AVERROR(ENOMEM);
for(i=0; i < 3; i++) {
int vsample = i ? 2 >> chroma_v_shift : 2;
pic->data[i] += (pic->linesize[i] * (vsample * (8 * s->mb_height -((s->height/V_MAX)&7)) - 1 ));
pic->linesize[i] *= -1;
}
ret = ff_MPV_encode_picture(avctx, pkt, pic, got_packet);
av_frame_free(&pic);
return ret;
}
| 1threat
|
Am working on a site using django framework and i got this AttributeError telling me 'str' object has no attribute 'get' : <p>`AttributeError at /polls/ </p>
<p>'str' object has no attribute 'get' </p>
<p>Request Method: GET</p>
<p>Request URL: <a href="http://127.0.0.1:8000/polls/" rel="nofollow noreferrer">http://127.0.0.1:8000/polls/</a></p>
<p>Django Version: 2.0.2</p>
<p>Exception Type: AttributeError</p>
<p>Exception Value: 'str' object has no attribute 'get'</p>
<p>Exception Location: C:\Python34\lib\site-packages\django-2.0.2-py3.4.egg\django\middleware\clickjacking.py in process_response, line 26</p>
<p>Python Executable: C:\Python34\python.exe</p>
<p>Python Version: 3.4.1</p>
<p>Python Path: ['C:\Users\WUESE PHILIP\Desktop\vibezt',</p>
<p>'C:\Python34\python34.zip',</p>
<p>'C:\Python34\DLLs',</p>
<p>'C:\Python34\lib',</p>
<p>'C:\Python34',</p>
<p>'C:\Python34\lib\site-packages',</p>
<p>'C:\Python34\lib\site-packages\setuptools-33.1.1-py3.4.egg',</p>
<p>'C:\Python34\lib\site-packages\django-2.0.2-py3.4.egg',</p>
<p>'C:\Python34\lib\site-packages\pytz-2019.3-py3.4.egg']`</p>
<p><code>polls urls.py</code></p>
<p><code>from django.urls import path</code></p>
<p><code>from . import views</code></p>
<p>`urlpatterns = [</p>
<p>path('', views.index, name='index'),</p>
<p>]`</p>
<p><code>views.py</code></p>
<p><code>from django.shortcuts import render</code></p>
<p>`from django.http import HttpResponse</p>
<p>def index(request):</p>
<pre><code>return("<h2>Welcome to my First Python Django Project</h2>")`
</code></pre>
<p><code>vibezt urls.py</code></p>
<p>`from django.contrib import admin</p>
<p>from django.urls import include, path`</p>
<p>`urlpatterns = [</p>
<p>path('polls/', include('polls.urls')),</p>
<p>path('admin/', admin.site.urls),</p>
<p>]`</p>
| 0debug
|
VBScript : How to Remove blank lines in email signature in outlook? : As per client requirement, I have to remove blank lines from reply message in Email Signature.
1) First Image
[![enter image description here][1]][1]
2) After clicking on OutLook-->Formate Text --> Plain Text
[![enter image description here][2]][2]
[1]: https://i.stack.imgur.com/6hb1c.png
[2]: https://i.stack.imgur.com/aoN7W.png
Here I want to remove these 5 lines using VBScript.
If Not BannerImage = "" And Not Left(BannerImage, 8) = "Excluded" Then
debugLog("Setting Marketing Banner")
selection.TypeParagraph()
Set Logo = selection.InlineShapes.AddPicture(BannerImage)
document.Hyperlinks.Add logo.Range, BannerURL
selection.TypeParagraph()
End If
selection.TypeParagraph()
selection.Font.Name = "Arial"
selection.Font.Size = "7"
If recordset.Fields("co") <> "Netherlands" Then
debugLog("Setting Facebook Logo")
Set Logo = selection.InlineShapes.AddPicture(FacebookLogo)
document.Hyperlinks.Add logo.Range, FacebookURL
Logo.Height = 19
Logo.Width = 19
End If
debugLog("Setting LinkedIn Logo")
Set Logo = selection.InlineShapes.AddPicture(LinkedInLogo)
document.Hyperlinks.Add logo.Range, LinkedInURL
Logo.Height = 19
Logo.Width = 19
debugLog("Setting Twitter Logo")
Set Logo = selection.InlineShapes.AddPicture(TwitterLogo)
document.Hyperlinks.Add logo.Range, TwitterURL
Logo.Height = 19
Logo.Width = 19
debugLog("Setting YouTube Logo")
Set Logo = selection.InlineShapes.AddPicture(YouTubeLogo)
document.Hyperlinks.Add logo.Range, YouTubeURL
Logo.Height = 19
Logo.Width = 19
debugLog("Setting Disclaimers")
If Not Disclaimer1Text = "" Then
selection.TypeText Chr(11)
selection.TypeText Chr(11)
Please Help me on this.
Thanks in advance.
| 0debug
|
How can I check the clicked element has also class x? : <p>Here is my code:</p>
<pre><code>doc.on("click", ".add_your_qora", function(e){
// in here I need to know, has this element also "myclass" class too?
})
</code></pre>
<p>As I've commented in the code, I need to know, has <code>.add_your_qora</code> element also <code>myclass</code> or not? How can I determine that? </p>
| 0debug
|
Java - Read line using InputStream : <p>I use InputStream to read some data, so I want to read characters until new line or '\n'. </p>
| 0debug
|
static int decode_frame(FLACContext *s, int alloc_data_size)
{
int bs_code, sr_code, bps_code, i;
int ch_mode, bps, blocksize, samplerate;
GetBitContext *gb = &s->gb;
skip_bits(&s->gb, 16);
bs_code = get_bits(gb, 4);
sr_code = get_bits(gb, 4);
ch_mode = get_bits(gb, 4);
if (ch_mode < FLAC_MAX_CHANNELS && s->channels == ch_mode+1) {
ch_mode = FLAC_CHMODE_INDEPENDENT;
} else if (ch_mode > FLAC_CHMODE_MID_SIDE || s->channels != 2) {
av_log(s->avctx, AV_LOG_ERROR, "unsupported channel assignment %d (channels=%d)\n",
ch_mode, s->channels);
return -1;
}
bps_code = get_bits(gb, 3);
if (bps_code == 0)
bps= s->bps;
else if ((bps_code != 3) && (bps_code != 7))
bps = sample_size_table[bps_code];
else {
av_log(s->avctx, AV_LOG_ERROR, "invalid sample size code (%d)\n",
bps_code);
return -1;
}
if (bps > 16) {
s->avctx->sample_fmt = SAMPLE_FMT_S32;
s->sample_shift = 32 - bps;
s->is32 = 1;
} else {
s->avctx->sample_fmt = SAMPLE_FMT_S16;
s->sample_shift = 16 - bps;
s->is32 = 0;
}
s->bps = s->avctx->bits_per_raw_sample = bps;
if (get_bits1(gb)) {
av_log(s->avctx, AV_LOG_ERROR, "broken stream, invalid padding\n");
return -1;
}
if (get_utf8(gb) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "utf8 fscked\n");
return -1;
}
if (bs_code == 0) {
av_log(s->avctx, AV_LOG_ERROR, "reserved blocksize code: 0\n");
return -1;
} else if (bs_code == 6)
blocksize = get_bits(gb, 8)+1;
else if (bs_code == 7)
blocksize = get_bits(gb, 16)+1;
else
blocksize = ff_flac_blocksize_table[bs_code];
if (blocksize > s->max_blocksize) {
av_log(s->avctx, AV_LOG_ERROR, "blocksize %d > %d\n", blocksize,
s->max_blocksize);
return -1;
}
if (blocksize * s->channels * (s->is32 ? 4 : 2) > alloc_data_size)
return -1;
if (sr_code == 0)
samplerate= s->samplerate;
else if (sr_code < 12)
samplerate = ff_flac_sample_rate_table[sr_code];
else if (sr_code == 12)
samplerate = get_bits(gb, 8) * 1000;
else if (sr_code == 13)
samplerate = get_bits(gb, 16);
else if (sr_code == 14)
samplerate = get_bits(gb, 16) * 10;
else {
av_log(s->avctx, AV_LOG_ERROR, "illegal sample rate code %d\n",
sr_code);
return -1;
}
skip_bits(gb, 8);
if (av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, gb->buffer,
get_bits_count(gb)/8)) {
av_log(s->avctx, AV_LOG_ERROR, "header crc mismatch\n");
return -1;
}
s->blocksize = blocksize;
s->samplerate = samplerate;
s->bps = bps;
s->ch_mode = ch_mode;
for (i = 0; i < s->channels; i++) {
if (decode_subframe(s, i) < 0)
return -1;
}
align_get_bits(gb);
skip_bits(gb, 16);
return 0;
}
| 1threat
|
Something wrong with PHP - facebook like count : <?php
function fbLikeCount($id,$access_token){
//Request URL
$retrievedID == 1633003770266238; // dynamic variable from another field $output["id"];
$json_url ='https://graph.facebook.com/'.$id.'?fields=fan_count&access_token='.$access_token;
$json = file_get_contents($json_url);
$json_output = json_decode($json);
//Extract the likes count from the JSON object
if($json_output->fan_count){
return $likes = $json_output->fan_count;
}else{
return 0;
}
}
echo fbLikeCount($retrievedID,'288268074855652|b36552b96683cbcfa794b4f6185e6daa');
?>
This code has been working since I want to use $retrievedID as a dynamic and get the value from other variable.. Now the count is not showing at all and gets the error. Please help
| 0debug
|
New to ruby --- getting the wrong count assigned to a variable : I am trying to store the highest count to a variable. I seem to show the right counts when I loop through my array but the assignment to the high count variable always seems to be the count of the last item checked in the array.
def calculate_word_frequency(content, line_number)
looper = 0
wordCounter = ""
#CREATE AN ARRAY FROM EACH LINE
myArray = content.split
#LOOP THROUGH ARRAY COUNTING INSTANCES OF WORDS
while looper < myArray.length
p myArray[looper]
wordCounter = myArray[looper]
puts myArray.count(wordCounter)
if highest_wf_count < myArray.count
highest_wf_count = myArray.count
end
looper +=1
end
puts highest_wf_count
end
Any help would be appreciated
| 0debug
|
static int virtio_rng_load_device(VirtIODevice *vdev, QEMUFile *f,
int version_id)
{
virtio_rng_process(VIRTIO_RNG(vdev));
return 0;
}
| 1threat
|
How I compare two picturebox array's? : I've been working on this app for long time. It has it's flaws, like, instead of using arrays, I could use 2d array, but it is difficult to get in the next row without messing somethings up. I have 6 arrays of pictureboxes on one side and same thing on other. On the bottom I have array of avaliable pictures that get be the right combination. The problem accured when I tried to compare the right combination with the one that user selected. Here is my code.
private void button1_Click(object sender, EventArgs e)
{
if (pb0.Image.ToString() == pb24.Image.ToString())
{
nizKomb[0].Image = Image.FromFile(@"Slike\crvena.png");
}
if(pb1.Image.ToString() == pb25.Image.ToString())
{
nizKomb[1].Image = Image.FromFile(@"Slike\crvena.png");
}
if(pb2.Image.ToString() == pb26.Image.ToString())
{
nizKomb[2].Image = Image.FromFile(@"Slike\crvena.png");
}
if(pb3.Image.ToString() == pb27.Image.ToString())
{
nizKomb[3].Image = Image.FromFile(@"Slike\crvena.png");
}
btnOK2.Visible = true;
ctrl = 1;
}
private void btnOK2_Click(object sender, EventArgs e)
{
for (int i = 0; i < 4; i++)
{
if (boxes2[i].Image.RawFormat == kombinacija[i].Image.RawFormat)
{
nizKomb2[i].Image = Image.FromFile(@"Slike\crvena.png");
}
}
if (boxes2[0].Image == null || boxes2[1].Image == null || boxes2[2].Image == null || boxes2[3].Image == null)
{
MessageBox.Show("Unesite kombinaciju.");
}
else if (boxes2[0].Image != null && boxes2[1].Image != null && boxes2[2].Image != null && boxes2[3].Image != null)
{
btnOK3.Visible = true;
ctrl = 2;
}
}
| 0debug
|
How to dump results of for loop into a .txt file using Python? : <p>I am working with this python script. I want it to dump all hosts which are alive into a text file and discard all hosts which don't respond to the ping. Currently I have this part.</p>
<pre><code>#!/usr/bin/python2
import subprocess
import sys
ip = "10.11.1."
for sub in range (0,255):
sweep = subprocess.Popen("ping -c 1 "+ ip+str(sub), shell=True,
stderr=subprocess.PIPE)
out = sweep.stderr.read(1)
sys.stdout.write(out)
</code></pre>
<p>How would I add the part dumping relevant information into a .txt file?</p>
| 0debug
|
How to check if collection contains any element from other collection in Scala? : <p>Title says it all, what is the best practice for finding out if collection contains any element of other collection?</p>
<p>In java I would execute it like this</p>
<pre><code>CollectionUtils.containsAny(a, b)
</code></pre>
<p>using common apache collection utils, where variables a/b are collections.</p>
<p>How to implement this behavior in scala? Or is there library like CollectionUtils from above?</p>
<p>I dont want to use the common-apache library because i would have to convert scala collection to java collection.</p>
| 0debug
|
I can't get the right path to bootstrap.css.min : I'm not able to get the correct css path
I have this code on my index.jsp head
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="javascript/jquery-3.1.1.min.js"></script>
<script src="javascript/bootstrap.min.js"></script>
<script src="javascript/angular.min.js"></script>
Note that if I use this:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
css shows correctly.
Here it's my [project buildpath][1]
Here it's a [similar question not answered][2]
[1]: https://i.stack.imgur.com/xcUto.png
[2]: http://stackoverflow.com/questions/24652697/css-not-working-maven-ee
| 0debug
|
How to fix HttpException: Connection closed before full header was received : <p>I have recently upgraded my flutter version in my app. But when I want to debug the application, it shows me the following error.</p>
<p>Error connecting to the service protocol: HttpException: Connection closed before full header was received, uri = <a href="http://127.0.0.1:50795/ws" rel="noreferrer">http://127.0.0.1:50795/ws</a></p>
<p>Is there anyone facing the same issue after upgrading the flutter version? If is there any workaround, please share.</p>
| 0debug
|
How do I identify the Python version code was written for : <p>how do I identify if Python code was written for 2.7 or 3.x automatically. </p>
<p>Thank you </p>
| 0debug
|
System.Timers.Timer difference between Enabled = true and .Start() : <p>System.Timers.Timer difference between Enabled = true and .Start()? What is the difference?</p>
| 0debug
|
static void test_qga_fstrim(gconstpointer fix)
{
const TestFixture *fixture = fix;
QDict *ret;
QList *list;
const QListEntry *entry;
ret = qmp_fd(fixture->fd, "{'execute': 'guest-fstrim',"
" arguments: { minimum: 4194304 } }");
g_assert_nonnull(ret);
qmp_assert_no_error(ret);
list = qdict_get_qlist(ret, "return");
entry = qlist_first(list);
g_assert(qdict_haskey(qobject_to_qdict(entry->value), "paths"));
QDECREF(ret);
}
| 1threat
|
void FUNC(ff_simple_idct_add)(uint8_t *dest_, int line_size, DCTELEM *block)
{
pixel *dest = (pixel *)dest_;
int i;
line_size /= sizeof(pixel);
for (i = 0; i < 8; i++)
FUNC(idctRowCondDC)(block + i*8);
for (i = 0; i < 8; i++)
FUNC(idctSparseColAdd)(dest + i, line_size, block + i);
}
| 1threat
|
Reading mails through gmail apis : <p>I am trying to build an application which needs to read mails of user once authorised. As a starter, I want to know, whether gmail allows third party applications to do so, if yes, how to get started on it.</p>
| 0debug
|
I am trying to get the questions in a quiz to be asked in a random order with limited sucess : <pre><code>print("Transferring you to the quiz...")
print("Rules: ")
print("This quiz features questions about online safety. The questions are multiple choice so enter the number which corresponds to your answer. For every question you get right you will get a point. Good luck!")
score = 0
goes = 0
questions = ['0', '1', '2', '3', '4']
import random
from random import shuffle
random.shuffle(questions)
print(questions)
if questions == 0:
questions.remove(0)
q1 = input("What is CEOP? 1.Child Exploitation and Online Protection 2.Criminal Exploration and Online Protection 3.Child Exploitation and Organised Protectors: ")
if q1 == "1":
print("That's right, well done!")
score = score + 1
goes = goes + 1
else:
print("That's wrong, unlucky!")
goes = goes + 1
elif questions == 1:
questions.remove(1)
q2 = input("When you get an email from someone you do not know, what should you do? 1.Reply and say hello 2.Forward to your friends 3.Delete it and mark as spam: ")
if q2 == "3":
print("That's right, well done!")
score = score + 1
goes = goes + 1
else:
print("That's wrong, unlucky!")
goes = goes + 1
elif questions == 2:
questions.remove(2)
q3 = input("How secret should you keep your passwords? 1.Give them only to your best friends 2.Never give out passwords except to your parents 3.Give them to strangers: ")
if q3 == "2":
print("That's right, well done!")
score = score + 1
goes = goes + 1
else:
print("That's wrong, unlucky!")
goes = goes + 1
elif questions == 3:
questions.remove(3)
q4 = input("When an online contact who frightens you asks to meet you in person what should you do? 1.Arrange to meet them 2.Arrange to meet them with your best friend 3.Report to CEOP: ")
if q4 == "3":
print("That's right, well done!")
score = score + 1
goes = goes + 1
else:
print("That's wrong, unlucky!")
goes = goes + 1
elif questions == 4:
questions.remove(4)
q5 = input("If an email asks you to enter your bank account details because of a problem with your account what should you do? 1.Contact the bank to check if they sent the email 2.Reply to the email 3.Enter your bank account details: ")
if q5 == "1":
print("That's right, well done!")
score = score + 1
goes = goes + 1
else:
print("That's wrong, unlucky!")
goes = goes + 1
while goes == 5:
print("End of quiz")
print("Well done, your score was {0}".format(score))
break
</code></pre>
<p>I am trying to get the questions of the quiz to be asked in a random order. I have shuffled the questions but after printing the random list the quiz stops...
I know some of the indenting is not correct but it is in my code...</p>
| 0debug
|
Iam not retriving the value : ArrayList<Object> push=new ArrayList<Object>();
pin=(EditText)findViewById(R.id.editText2);
push.add("amam");
JSONObject json = new JSONObject();
try {
json.put("uniqueArrays", new JSONArray(push));
} catch (JSONException e) {
e.printStackTrace();
}
JSONObject jsosn = new JSONObject();
JSONArray items = jsosn.optJSONArray("uniqueArrays");
Log.d("retrived values",String.valueOf(items));
Iam trying to insert array list and retrive it ,can anyone help me with best method or guide me int the correct way
| 0debug
|
static av_cold int read_specific_config(ALSDecContext *ctx)
{
GetBitContext gb;
uint64_t ht_size;
int i, config_offset;
MPEG4AudioConfig m4ac;
ALSSpecificConfig *sconf = &ctx->sconf;
AVCodecContext *avctx = ctx->avctx;
uint32_t als_id, header_size, trailer_size;
init_get_bits(&gb, avctx->extradata, avctx->extradata_size * 8);
config_offset = avpriv_mpeg4audio_get_config(&m4ac, avctx->extradata,
avctx->extradata_size * 8, 1);
if (config_offset < 0)
return -1;
skip_bits_long(&gb, config_offset);
if (get_bits_left(&gb) < (30 << 3))
return -1;
als_id = get_bits_long(&gb, 32);
avctx->sample_rate = m4ac.sample_rate;
skip_bits_long(&gb, 32);
sconf->samples = get_bits_long(&gb, 32);
avctx->channels = m4ac.channels;
skip_bits(&gb, 16);
skip_bits(&gb, 3);
sconf->resolution = get_bits(&gb, 3);
sconf->floating = get_bits1(&gb);
sconf->msb_first = get_bits1(&gb);
sconf->frame_length = get_bits(&gb, 16) + 1;
sconf->ra_distance = get_bits(&gb, 8);
sconf->ra_flag = get_bits(&gb, 2);
sconf->adapt_order = get_bits1(&gb);
sconf->coef_table = get_bits(&gb, 2);
sconf->long_term_prediction = get_bits1(&gb);
sconf->max_order = get_bits(&gb, 10);
sconf->block_switching = get_bits(&gb, 2);
sconf->bgmc = get_bits1(&gb);
sconf->sb_part = get_bits1(&gb);
sconf->joint_stereo = get_bits1(&gb);
sconf->mc_coding = get_bits1(&gb);
sconf->chan_config = get_bits1(&gb);
sconf->chan_sort = get_bits1(&gb);
sconf->crc_enabled = get_bits1(&gb);
sconf->rlslms = get_bits1(&gb);
skip_bits(&gb, 5);
skip_bits1(&gb);
if (als_id != MKBETAG('A','L','S','\0'))
return -1;
ctx->cur_frame_length = sconf->frame_length;
if (sconf->chan_config)
sconf->chan_config_info = get_bits(&gb, 16);
if (sconf->chan_sort && avctx->channels > 1) {
int chan_pos_bits = av_ceil_log2(avctx->channels);
int bits_needed = avctx->channels * chan_pos_bits + 7;
if (get_bits_left(&gb) < bits_needed)
return -1;
if (!(sconf->chan_pos = av_malloc(avctx->channels * sizeof(*sconf->chan_pos))))
return AVERROR(ENOMEM);
for (i = 0; i < avctx->channels; i++) {
sconf->chan_pos[i] = get_bits(&gb, chan_pos_bits);
if (sconf->chan_pos[i] >= avctx->channels) {
av_log(avctx, AV_LOG_WARNING, "Invalid original channel position.\n");
sconf->chan_sort = 0;
break;
}
}
align_get_bits(&gb);
} else {
sconf->chan_sort = 0;
}
if (get_bits_left(&gb) < 64)
return -1;
header_size = get_bits_long(&gb, 32);
trailer_size = get_bits_long(&gb, 32);
if (header_size == 0xFFFFFFFF)
header_size = 0;
if (trailer_size == 0xFFFFFFFF)
trailer_size = 0;
ht_size = ((int64_t)(header_size) + (int64_t)(trailer_size)) << 3;
if (get_bits_left(&gb) < ht_size)
return -1;
if (ht_size > INT32_MAX)
return -1;
skip_bits_long(&gb, ht_size);
if (sconf->crc_enabled) {
if (get_bits_left(&gb) < 32)
return -1;
if (avctx->err_recognition & (AV_EF_CRCCHECK|AV_EF_CAREFUL)) {
ctx->crc_table = av_crc_get_table(AV_CRC_32_IEEE_LE);
ctx->crc = 0xFFFFFFFF;
ctx->crc_org = ~get_bits_long(&gb, 32);
} else
skip_bits_long(&gb, 32);
}
dprint_specific_config(ctx);
return 0;
}
| 1threat
|
C++ PRESS ENTER TO CONTINUE : Evening, I am looking for a way to get the program to continue on instead of exiting out after asking to press enter to continue. [1] I cannot use the list command because im calling function "seatingChart" in another function and having the list command sends me back into the menu. Any suggestions?
void seatingChart()
{
for(row = 0; SEATROWS > row; ++row) // Placeholder for '#'
for (seat = 0; SEATS > seat; ++seat) // Placeholder for '#'
theater[row][seat] = '#'; // Applying '#' to the chart
cout << "\n\t\tSeats";
cout << "\n 123456789012345678901234567890" << endl; //seat header
for (int row = 0; SEATROWS > row; ++row) { // Initializing 15 rows
cout << "\nRow " << setw(2) << row+1 << "\t";
for (int seat = 0; SEATS > seat; ++seat){ // Initializing 30 seats
cout << theater [row][seat];} //display seating chart
}
cout << "\n\n\n\tLegend:\t* = Sold";
cout << "\n\t\t# = Available";
cout << "\n\n\nPress the Enter key to continue.";
cin.ignore();
cin.get();
}
[1]: http://i.stack.imgur.com/VpAzm.png
| 0debug
|
static int mjpeg_decode_com(MJpegDecodeContext *s)
{
int i;
UINT8 *cbuf;
unsigned int len = get_bits(&s->gb, 16)-2;
cbuf = av_malloc(len+1);
for (i = 0; i < len; i++)
cbuf[i] = get_bits(&s->gb, 8);
if (cbuf[i-1] == '\n')
cbuf[i-1] = 0;
else
cbuf[i] = 0;
printf("mjpeg comment: '%s'\n", cbuf);
if (!strcmp(cbuf, "AVID"))
{
s->buggy_avid = 1;
}
av_free(cbuf);
return 0;
}
| 1threat
|
How to install my own python module (package) via conda and watch its changes : <p>I have a file <code>mysql.py</code>, which I use in almost all of my projects. Since I do not want to copy and paste the same file into each of these projects I wrote a module - possibly a package in the future. </p>
<h1>Question</h1>
<p>How do I add a local module to my conda environment, and automatically update or watch it when I change something in <code>mysql.py</code>? How to do the same for a package?</p>
<p>I would like to avoid to set up a local channel/repository and just reference to the folder with <code>mysql.py</code>.</p>
| 0debug
|
SQL SERVER RDS WITH ELASTICCCAHE : Can RDS SQL Server be integrated with Elasticache . Can sql server read replica be created ?
| 0debug
|
passing data from my page to iframe using javascript : <p>I want to use Payment Gateway in PhoneGap but Payment Gateway not made for PhoneGap then I thought that using java script pass data to another jsp page using Iframe that control Payment Gateway .i just only pass value to that page .have anyone solution.</p>
| 0debug
|
static int usb_xhci_post_load(void *opaque, int version_id)
{
XHCIState *xhci = opaque;
PCIDevice *pci_dev = PCI_DEVICE(xhci);
XHCISlot *slot;
XHCIEPContext *epctx;
dma_addr_t dcbaap, pctx;
uint32_t slot_ctx[4];
uint32_t ep_ctx[5];
int slotid, epid, state, intr;
dcbaap = xhci_addr64(xhci->dcbaap_low, xhci->dcbaap_high);
for (slotid = 1; slotid <= xhci->numslots; slotid++) {
slot = &xhci->slots[slotid-1];
if (!slot->addressed) {
slot->ctx =
xhci_mask64(ldq_le_pci_dma(pci_dev, dcbaap + 8 * slotid));
xhci_dma_read_u32s(xhci, slot->ctx, slot_ctx, sizeof(slot_ctx));
slot->uport = xhci_lookup_uport(xhci, slot_ctx);
assert(slot->uport && slot->uport->dev);
for (epid = 1; epid <= 31; epid++) {
pctx = slot->ctx + 32 * epid;
xhci_dma_read_u32s(xhci, pctx, ep_ctx, sizeof(ep_ctx));
state = ep_ctx[0] & EP_STATE_MASK;
if (state == EP_DISABLED) {
epctx = xhci_alloc_epctx(xhci, slotid, epid);
slot->eps[epid-1] = epctx;
xhci_init_epctx(epctx, pctx, ep_ctx);
epctx->state = state;
if (state == EP_RUNNING) {
timer_mod(epctx->kick_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
for (intr = 0; intr < xhci->numintrs; intr++) {
if (xhci->intr[intr].msix_used) {
msix_vector_use(pci_dev, intr);
} else {
msix_vector_unuse(pci_dev, intr);
return 0;
| 1threat
|
static int pte64_check (mmu_ctx_t *ctx,
target_ulong pte0, target_ulong pte1, int h, int rw)
{
return _pte_check(ctx, 1, pte0, pte1, h, rw);
}
| 1threat
|
react.js application showing 404 not found in nginx server : <p>I uploaded react.js application to server. I'm using nginx server. Application is working fine. But when I go to other page & refresh, site is not working. It's showing 404 Not found error.</p>
<p>How can I solve this.</p>
<p>Thank You.</p>
| 0debug
|
tqdm progressbar and zip built-in do not work together : <p>tqdm is a Python module to easily print in the console a dynamically updating progressbar. For example</p>
<pre><code>from tqdm import tqdm
from time import sleep
for _ in tqdm(range(10)):
sleep(0.1)
</code></pre>
<p>prints a dynamic progressbar in the console for 1sec as the iteration executes:
<a href="https://i.stack.imgur.com/yHtf3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yHtf3.png" alt="enter image description here"></a></p>
<p>I have not figured out how to use tqdm with the builtin zip object.<br>
The use case of this would be to iterate over two corresponding lists with a console progressbar.<br>
For example, I would expect this to work:</p>
<pre><code>for _, _ in tqdm(zip(range(10), range(10))):
sleep(0.1)
</code></pre>
<p>but the progressbar printed to the console in this case is not correct:
<a href="https://i.stack.imgur.com/A0Pmu.png" rel="noreferrer"><img src="https://i.stack.imgur.com/A0Pmu.png" alt="enter image description here"></a></p>
<p>A workaround is to use tqdm with enumerate, however then an iterator index must be defined and managed.</p>
| 0debug
|
what is HiveServer and Thrift server : <p>I just started learning Hive.There are three terms which often I seen in Hive books or Hive tutorials. Hive Server,Hive Service and Thrift Server.
What is these ?
how they are related ?.
what is the difference ?.
when each of these are used?
please explain</p>
| 0debug
|
C# how can I make a if/else statement with feilds instead of types : I need help, I need to make a Audio button for my screen recorder. I need to make a if/else statement with feilds,
private void Audiotext_Click(object sender, EventArgs e)
{
Audiotext.Text = "Audio: ON";
EncoderDevice AudioDevices()
{
EncoderDevice foundDevice = null;
Collection<EncoderDevice> audioDevices = EncoderDevices.FindDevices(EncoderDeviceType.Audio);
try
{
foundDevice = audioDevices.First();
}
catch (Exception ex)
{
MessageBox.Show("Cannot Find Perfered Audio Device Using " + audioDevices[0].Name + ex.Message);
}
return foundDevice;
}
-----> if (Audiotext.Text == "Audio: ON") <-----
{
}
It says the error is, 'Armored_Screen_Recorder.Form1.Audiotext' is a feild but is used like a type. Can you guys help me?
| 0debug
|
OpenCV: How to create a mask in the shape of a polygon? : <p>I have a list of points which are the vertices of a polygon, like this:</p>
<pre><code>std::vector<cv::Point2d> polygonPoints;
</code></pre>
<p>I need to create a mask for the <code>goodFeaturesToTrack</code> function in openCV. For a rectangle, the easiest way to fill the desired area with <code>1</code>'s is like this:</p>
<pre><code>cv::Mat mask = cv::Mat::zeros(img.rows, img.cols, CV_8U);
mask(boundingbox) = 1;
</code></pre>
<p>How do I do this with a polygon that has 10+ edges? Is there an equivalent solution for n-sided polygons?</p>
| 0debug
|
Python regex remove all character except 4 digitals : <pre><code>+1511
0716
+4915 CZECHY
+3815/0616 PORT MO,
AO
_3615 USA *, SUV run on flat
+4515 PORT SUV
*, SUV
+3215 USA *, SUV
+4414
+4815 NIEM
_0616 NIEM * / MO
+2115 NIEM J
</code></pre>
<p>I need get only first 4 digits </p>
<blockquote>
<p>+<strong>3715</strong> NIEM</p>
</blockquote>
<p>Please help.</p>
| 0debug
|
why OrderByDescending not working in linq? : I have a query that returns weekending in datetime format, i want to sort it by descending but seems that order by not working..
see the [image][1]
```
var WeekEnd = db.mqTimeReportingTimeLogs.OrderByDescending(e=>e.tlWeekEnding).Select(c => c.tlWeekEnding).Distinct().ToList();
```
i also tried:
```
WeekEnd=WeekEnd.OrderByDescending(x=>x.tlWeekEnding).ToList();
```
but here x.tlWeekEnding does not appears
[1]: https://i.stack.imgur.com/q43iy.png
| 0debug
|
how can i bold part of a string from JSON in swift : i have a json file like this. i have to make bold part of string which is shown in json. how can i make parse this Json.
[enter image description here][1]
[1]: https://i.stack.imgur.com/3dyXg.png
| 0debug
|
Layout design is diffrent on android mobiles and emulator : i had designed android app and i when i open the app in emulator and mobile phone the designs are very bad , the buttons and images overlapped in design and it's very bad , how can i make it plz ??
[here is the design in android studio][1]
[here is the activity in BlueStacks][2]
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="385dp"
android:layout_height="510dp"
android:orientation="vertical"
tools:context="bishoy.homeactivity.Main2">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="34dp"
android:text="Christianity"
android:textAllCaps="true"
android:textColor="?attr/actionModeSplitBackground"
android:textSize="40sp"
android:textStyle="bold|italic"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="140dp"
android:layout_height="140dp"
app:srcCompat="@drawable/abomaar"
tools:layout_editor_absoluteX="32dp"
tools:layout_editor_absoluteY="289dp" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="140dp"
android:layout_height="140dp"
app:layout_constraintRight_toRightOf="parent"
app:srcCompat="@drawable/anba"
tools:layout_editor_absoluteY="289dp"
android:layout_marginRight="36dp" />
<ImageView
android:id="@+id/imageView4"
android:layout_width="140dp"
android:layout_height="140dp"
app:srcCompat="@drawable/quots"
tools:layout_editor_absoluteX="209dp"
tools:layout_editor_absoluteY="103dp" />
<ImageView
android:id="@+id/imageView5"
android:layout_width="140dp"
android:layout_height="140dp"
android:layout_weight="1"
app:layout_constraintLeft_toLeftOf="parent"
app:srcCompat="@drawable/jesus"
tools:layout_editor_absoluteY="103dp"
android:layout_marginLeft="32dp" />
</android.support.constraint.ConstraintLayout>
<!-- end snippet -->
[1]: https://i.stack.imgur.com/h0iUy.png
[2]: https://i.stack.imgur.com/XydBz.png
| 0debug
|
UMModuleRegistryAdapter.h not found when running React Native app in iOS simulator : <p>I have a simple React Native app that I've been testing on Android and now want to test on iOS. It's using React Navigation.</p>
<p>I ran <code>npm run ios</code> but I'm getting the following error:</p>
<pre><code>info In file included from
/Users/rbbit/reactnative/testproj1/ios/testproj1/main.m:10:
/Users/rbbit/reactnative/testproj1/ios/testproj1/AppDelegate.h:9:9: fatal error: 'UMReactNativeAdapter/UMModuleRegistryAdapter.h' file not found
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
info 1 error generated.
</code></pre>
<p>I opened XCode but I'm basically getting the same message, nothing else that would help me debug this.</p>
<p>I do see that there is a package called react-native-adapter (<a href="https://github.com/expo/expo/tree/master/packages/%40unimodules/react-native-adapter" rel="noreferrer">https://github.com/expo/expo/tree/master/packages/%40unimodules/react-native-adapter</a>), however I'm hesitant to just install this since I followed the instructions on how to include react-navigation and didn't mention that, assuming this is related.</p>
<p>Also, that page says <code>If you are using react-native-unimodules, this package will already be installed and configured!</code>, and <code>react-native-unimodules</code> already is in my dependencies.</p>
<p>Any pointers on how to solve this? Thank you!</p>
| 0debug
|
Device orientation issue : <p>I have an issue with android device orientation. When the device's auto rotation is on, the device screen goes to landscape mode, while it is in portrait(vertical). And it goes into portrait mode, while the device is in landscape(horizontal). And when the device's rotation is locked, the device always locks into landscape and never into portrait.</p>
| 0debug
|
static void coroutine_fn wait_serialising_requests(BdrvTrackedRequest *self)
{
BlockDriverState *bs = self->bs;
BdrvTrackedRequest *req;
bool retry;
if (!bs->serialising_in_flight) {
return;
}
do {
retry = false;
QLIST_FOREACH(req, &bs->tracked_requests, list) {
if (req == self || (!req->serialising && !self->serialising)) {
continue;
}
if (tracked_request_overlaps(req, self->overlap_offset,
self->overlap_bytes))
{
assert(qemu_coroutine_self() != req->co);
qemu_co_queue_wait(&req->wait_queue);
retry = true;
break;
}
}
} while (retry);
}
| 1threat
|
Local variable referenced before assigment Python Programming : I have a small problem concerning an error in my method (as inside a class), I am currently working on a AI wanting to sort out the best move the bot can do, but when I want to return bestMove, it tells me the error...
def computerMove(self, tile, newBoard, legalMoves, isOnCorner):
legitMoves = self.getLegalMoves(self.board, tile)
for x, y in legitMoves:
if self.isOnCorner(x, y):
return [x, y]
highestPoints = -1
for x, y in legitMoves:
computerBoard = self.getComputerBoard(self.newBoard)
makeYourMove(computerBoard, tile, x, y)
points = countPoints(computerBoard)[tile]
if points > highestPoints:
highestPoints = points
bestMove = [x][y]
return bestMove
but the error states `UnboundLocalError: local variable 'bästaDrag' referenced before assignment`
| 0debug
|
array of data not binding in select2 ,beleow is the my code : this array of data not binding,can anyoneset it
presentProfile = Object {authenticateCode: null,frontendPermission:
Array(3)
0:"administrator"
1:"author"
2:"contributor" }
jQuery.each(presentProfile.frontendPermission, function (index, data) {
jQuery("#bis_frontend_display_roles").select2("val", data);
});
| 0debug
|
Variable array for alternating outcomes (javascript) : Hi im making a small javascript drinking game just for abit of fun n to learn certain aspects of javascript, iv looked over the code i have wrote n cant see why it doesnt work
Im trying to show a random array taken from the 2 variable arrays and alternate between them both, i dnt care for storage as the game wont need to be reloaded n there is no links to other pages so that is not a problem.
Please can people give me some pointers on what im doing wrong
<!DOCTYPE HTML5>
<html>
<head>
<script>
var boy = ["have a shot","item 2","item 3"];
var girl = ["have a shot","item 2","item 3"];
var selector = 1;
function rbg()
if (selector == 1)
{
document.getElementById("ppp").innerHTML = boy [Math.floor(Math.random() * boy.length)];
selector = 2;
}
else if (selector == 2)
{
document.getElementById("ppp").innerHTML = girl [Math.floor(Math.random() * girl.length)];
selector = 0;
}
else
{
document.getElementById("ppp".innerHTML = "have a shot each";
selector = 1;
}
</script>
<title>Home</title>
</head>
<body>
<div id="random" onclick="rbg()">Random</div>
<p id="ppp">outcome</p>
</body>
</html>
| 0debug
|
Animated overlay for videos on iOS : <p>What's the common modern standard for animated video overlays? (e.g. if you want to add an animated logo to video recorded from the camera)</p>
<p>During research, I've found the following options:</p>
<ul>
<li><p>GIF - seems to be pretty outdated technology</p></li>
<li><p>FLV - supports alpha-channel, but no longer supported by Adobe.
Requires FFMPEG.</p></li>
<li><p>PNG sequence - the downside of this is having multiple files for each
frame.</p></li>
</ul>
<p>What's the right format/technology to use?</p>
<p>Ideally, what is natively supported on iOS (doesn't require FFMPEG)?</p>
| 0debug
|
Node.js: Python not found exception due to node-sass and node-gyp : <p>Suddenly in one of my jenkins environment build has started failing, while in local machine it seems to be working fine as i have python installed,</p>
<p>From the logs i was able to detect that the problem is with internal dependency that is <strong>node-gyp v3.5.0</strong> from <strong>node-sass v3.8.0</strong> when i researched by visiting <a href="https://github.com/nodejs/node-gyp" rel="noreferrer">this</a> about node-gyp and found the prerequisite that Python needs to be installed.</p>
<p>So my question is that what version of node-sass can i install to bypass this or is there a better solution as my build was running fine till this morning on the same environment.</p>
<p><strong>Node v5.10.1</strong></p>
<p><strong>ERROR LOG</strong></p>
<pre><code>gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed at getNotFoundError (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:80:29)
gyp verb `which` failed at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:89:16
gyp verb `which` failed at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\isexe\index.js:44:5
gyp verb `which` failed at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\isexe\windows.js:29:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:82:15)
gyp verb `which` failed python2 { [Error: not found: python2] code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` failed Error: not found: python
gyp verb `which` failed at getNotFoundError (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:80:29)
gyp verb `which` failed at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:89:16
gyp verb `which` failed at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\isexe\index.js:44:5
gyp verb `which` failed at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\isexe\windows.js:29:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:82:15)
gyp verb `which` failed python { [Error: not found: python] code: 'ENOENT' }
gyp verb could not find "python". checking python launcher
gyp verb could not find "python". guessing location
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at Object.failNoPython (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\node-gyp\lib\configure.js:454:19)
gyp ERR! stack at Object.<anonymous> (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\node-gyp\lib\configure.js:480:16)
gyp ERR! stack at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files (x86)\\Jenkins\\jobs\\NdbSite-hot-fix-Manual-PreBuild\\workspace\\src\\NdbSite.UI\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\node-sass
gyp ERR! node -v v5.10.1
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
Build failed
</code></pre>
<p>Any thoughts are much appreciated, Thanks. </p>
| 0debug
|
static void uhci_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
{
UHCIState *s = opaque;
addr &= 0x1f;
DPRINTF("uhci: writew port=0x%04x val=0x%04x\n", addr, val);
switch(addr) {
case 0x00:
if ((val & UHCI_CMD_RS) && !(s->cmd & UHCI_CMD_RS)) {
s->expire_time = qemu_get_clock_ns(vm_clock) +
(get_ticks_per_sec() / FRAME_TIMER_FREQ);
qemu_mod_timer(s->frame_timer, qemu_get_clock_ns(vm_clock));
s->status &= ~UHCI_STS_HCHALTED;
} else if (!(val & UHCI_CMD_RS)) {
s->status |= UHCI_STS_HCHALTED;
}
if (val & UHCI_CMD_GRESET) {
UHCIPort *port;
USBDevice *dev;
int i;
for(i = 0; i < NB_PORTS; i++) {
port = &s->ports[i];
dev = port->port.dev;
if (dev) {
usb_send_msg(dev, USB_MSG_RESET);
}
}
uhci_reset(s);
return;
}
if (val & UHCI_CMD_HCRESET) {
uhci_reset(s);
return;
}
s->cmd = val;
break;
case 0x02:
s->status &= ~val;
if (val & UHCI_STS_USBINT)
s->status2 = 0;
uhci_update_irq(s);
break;
case 0x04:
s->intr = val;
uhci_update_irq(s);
break;
case 0x06:
if (s->status & UHCI_STS_HCHALTED)
s->frnum = val & 0x7ff;
break;
case 0x10 ... 0x1f:
{
UHCIPort *port;
USBDevice *dev;
int n;
n = (addr >> 1) & 7;
if (n >= NB_PORTS)
return;
port = &s->ports[n];
dev = port->port.dev;
if (dev) {
if ( (val & UHCI_PORT_RESET) &&
!(port->ctrl & UHCI_PORT_RESET) ) {
usb_send_msg(dev, USB_MSG_RESET);
}
}
port->ctrl &= UHCI_PORT_READ_ONLY;
port->ctrl |= (val & ~UHCI_PORT_READ_ONLY);
port->ctrl &= ~(val & UHCI_PORT_WRITE_CLEAR);
}
break;
}
}
| 1threat
|
What goes in to the parentheses of studentList.addStudent()? : <p>So I have a <strong>GUI</strong> class with the <code>addStudent()</code> method that is meant to call the method: <code>addStudent(Student aNewStudentObj)</code> of the <strong>Manager</strong> class to then create an object of the <strong>Student</strong> class using the information inputted by the user. This object is then meant to be stored in the Linked List that is in the <strong>Manager</strong> class. </p>
<p>My question is, what goes in the parentheses of the <code>addStudent()</code> method that is located in the <strong>GUI</strong> class if anything is meant to go in there? </p>
<p>I have literally tried everything that I could think of and now I am at the point of losing my hair so all help possible would very much be appreciated. Please. </p>
<p>I believe all required code is below but if you need the full <strong>GUI</strong> class, let me know. I also have a <strong>Module</strong> class but I don't think that will be necessary for this question.</p>
<p><code>addStudent()</code> method from <strong>GUI</strong> class below</p>
<pre><code>public void addStudent() {
Manager studentList = new Manager();
studentList.addStudent(); <----------------- What goes in those brackets?
}
</code></pre>
<p><strong>Student</strong> class below</p>
<pre><code>public class Student {
private String firstName;
private String surname;
private String email;
private int yearOfStudy;
private int studentId;
private Queue<Module> mods = new LinkedList<>();
public String getFirstName() {
return firstName;
}
public String getSurname() {
return surname;
}
public String getEmail() {
return email;
}
public int getYearOfStudy() {
return yearOfStudy;
}
public int getStudentId() {
return studentId;
}
public String print() {
return "Student ID: " + studentId + "\n"
+ "First Name: " + firstName + "\n"
+ "Surname: " + surname + "\n"
+ "Email: " + email + "\n"
+ "Year of Study: " + yearOfStudy;
}
public void addModule(int id, String mCode, int mMark) {
if (mods.size() == 4) {
mods.remove();
}
Module module = new Module();
mods.add(module);
}
//this method returns the module list of this student sorted by marks
public String getModulesSortedByMarks(int id) {
Object[] sortedMods;
sortedMods = mods.toArray();
Arrays.sort(sortedMods);
String sortedModulesList = "";
for (int i = 0; i < sortedMods.length; i++) {
sortedModulesList = "\n" + ((Module) sortedMods[i]).print();
}
return sortedModulesList;
}
}
</code></pre>
<p><strong>Manager</strong> class below</p>
<pre><code>public class Manager {
List<Student> studs = new LinkedList<>();
public void addStudent(Student aNewStudentObj) {
studs.add(aNewStudentObj);
}
public void displayStudent(int studentId) {
System.out.println(studs.get(studentId));
}
public void displayMarks(int studentId) {
Student marks = new Student();
marks.getModulesSortedByMarks(studentId);
}
public void deleteStudent(int studentId) {
studs.remove(studentId);
}
public void displayAll() {
for (Student student : studs) {
student.print();
System.out.println();
}
}
}
</code></pre>
| 0debug
|
static int kvm_put_msrs(X86CPU *cpu, int level)
{
CPUX86State *env = &cpu->env;
int i;
int ret;
kvm_msr_buf_reset(cpu);
kvm_msr_entry_add(cpu, MSR_IA32_SYSENTER_CS, env->sysenter_cs);
kvm_msr_entry_add(cpu, MSR_IA32_SYSENTER_ESP, env->sysenter_esp);
kvm_msr_entry_add(cpu, MSR_IA32_SYSENTER_EIP, env->sysenter_eip);
kvm_msr_entry_add(cpu, MSR_PAT, env->pat);
if (has_msr_star) {
kvm_msr_entry_add(cpu, MSR_STAR, env->star);
}
if (has_msr_hsave_pa) {
kvm_msr_entry_add(cpu, MSR_VM_HSAVE_PA, env->vm_hsave);
}
if (has_msr_tsc_aux) {
kvm_msr_entry_add(cpu, MSR_TSC_AUX, env->tsc_aux);
}
if (has_msr_tsc_adjust) {
kvm_msr_entry_add(cpu, MSR_TSC_ADJUST, env->tsc_adjust);
}
if (has_msr_misc_enable) {
kvm_msr_entry_add(cpu, MSR_IA32_MISC_ENABLE,
env->msr_ia32_misc_enable);
}
if (has_msr_smbase) {
kvm_msr_entry_add(cpu, MSR_IA32_SMBASE, env->smbase);
}
if (has_msr_bndcfgs) {
kvm_msr_entry_add(cpu, MSR_IA32_BNDCFGS, env->msr_bndcfgs);
}
if (has_msr_xss) {
kvm_msr_entry_add(cpu, MSR_IA32_XSS, env->xss);
}
#ifdef TARGET_X86_64
if (lm_capable_kernel) {
kvm_msr_entry_add(cpu, MSR_CSTAR, env->cstar);
kvm_msr_entry_add(cpu, MSR_KERNELGSBASE, env->kernelgsbase);
kvm_msr_entry_add(cpu, MSR_FMASK, env->fmask);
kvm_msr_entry_add(cpu, MSR_LSTAR, env->lstar);
}
#endif
if (level >= KVM_PUT_RESET_STATE) {
kvm_msr_entry_add(cpu, MSR_IA32_TSC, env->tsc);
kvm_msr_entry_add(cpu, MSR_KVM_SYSTEM_TIME, env->system_time_msr);
kvm_msr_entry_add(cpu, MSR_KVM_WALL_CLOCK, env->wall_clock_msr);
if (has_msr_async_pf_en) {
kvm_msr_entry_add(cpu, MSR_KVM_ASYNC_PF_EN, env->async_pf_en_msr);
}
if (has_msr_pv_eoi_en) {
kvm_msr_entry_add(cpu, MSR_KVM_PV_EOI_EN, env->pv_eoi_en_msr);
}
if (has_msr_kvm_steal_time) {
kvm_msr_entry_add(cpu, MSR_KVM_STEAL_TIME, env->steal_time_msr);
}
if (has_msr_architectural_pmu) {
kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR_CTRL, 0);
kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_CTRL, 0);
for (i = 0; i < MAX_FIXED_COUNTERS; i++) {
kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR0 + i,
env->msr_fixed_counters[i]);
}
for (i = 0; i < num_architectural_pmu_counters; i++) {
kvm_msr_entry_add(cpu, MSR_P6_PERFCTR0 + i,
env->msr_gp_counters[i]);
kvm_msr_entry_add(cpu, MSR_P6_EVNTSEL0 + i,
env->msr_gp_evtsel[i]);
}
kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_STATUS,
env->msr_global_status);
kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_OVF_CTRL,
env->msr_global_ovf_ctrl);
kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR_CTRL,
env->msr_fixed_ctr_ctrl);
kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_CTRL,
env->msr_global_ctrl);
}
if (has_msr_hv_hypercall) {
kvm_msr_entry_add(cpu, HV_X64_MSR_GUEST_OS_ID,
env->msr_hv_guest_os_id);
kvm_msr_entry_add(cpu, HV_X64_MSR_HYPERCALL,
env->msr_hv_hypercall);
}
if (has_msr_hv_vapic) {
kvm_msr_entry_add(cpu, HV_X64_MSR_APIC_ASSIST_PAGE,
env->msr_hv_vapic);
}
if (has_msr_hv_tsc) {
kvm_msr_entry_add(cpu, HV_X64_MSR_REFERENCE_TSC, env->msr_hv_tsc);
}
if (has_msr_hv_crash) {
int j;
for (j = 0; j < HV_X64_MSR_CRASH_PARAMS; j++)
kvm_msr_entry_add(cpu, HV_X64_MSR_CRASH_P0 + j,
env->msr_hv_crash_params[j]);
kvm_msr_entry_add(cpu, HV_X64_MSR_CRASH_CTL,
HV_X64_MSR_CRASH_CTL_NOTIFY);
}
if (has_msr_hv_runtime) {
kvm_msr_entry_add(cpu, HV_X64_MSR_VP_RUNTIME, env->msr_hv_runtime);
}
if (cpu->hyperv_synic) {
int j;
kvm_msr_entry_add(cpu, HV_X64_MSR_SCONTROL,
env->msr_hv_synic_control);
kvm_msr_entry_add(cpu, HV_X64_MSR_SVERSION,
env->msr_hv_synic_version);
kvm_msr_entry_add(cpu, HV_X64_MSR_SIEFP,
env->msr_hv_synic_evt_page);
kvm_msr_entry_add(cpu, HV_X64_MSR_SIMP,
env->msr_hv_synic_msg_page);
for (j = 0; j < ARRAY_SIZE(env->msr_hv_synic_sint); j++) {
kvm_msr_entry_add(cpu, HV_X64_MSR_SINT0 + j,
env->msr_hv_synic_sint[j]);
}
}
if (has_msr_hv_stimer) {
int j;
for (j = 0; j < ARRAY_SIZE(env->msr_hv_stimer_config); j++) {
kvm_msr_entry_add(cpu, HV_X64_MSR_STIMER0_CONFIG + j * 2,
env->msr_hv_stimer_config[j]);
}
for (j = 0; j < ARRAY_SIZE(env->msr_hv_stimer_count); j++) {
kvm_msr_entry_add(cpu, HV_X64_MSR_STIMER0_COUNT + j * 2,
env->msr_hv_stimer_count[j]);
}
}
if (has_msr_mtrr) {
kvm_msr_entry_add(cpu, MSR_MTRRdefType, env->mtrr_deftype);
kvm_msr_entry_add(cpu, MSR_MTRRfix64K_00000, env->mtrr_fixed[0]);
kvm_msr_entry_add(cpu, MSR_MTRRfix16K_80000, env->mtrr_fixed[1]);
kvm_msr_entry_add(cpu, MSR_MTRRfix16K_A0000, env->mtrr_fixed[2]);
kvm_msr_entry_add(cpu, MSR_MTRRfix4K_C0000, env->mtrr_fixed[3]);
kvm_msr_entry_add(cpu, MSR_MTRRfix4K_C8000, env->mtrr_fixed[4]);
kvm_msr_entry_add(cpu, MSR_MTRRfix4K_D0000, env->mtrr_fixed[5]);
kvm_msr_entry_add(cpu, MSR_MTRRfix4K_D8000, env->mtrr_fixed[6]);
kvm_msr_entry_add(cpu, MSR_MTRRfix4K_E0000, env->mtrr_fixed[7]);
kvm_msr_entry_add(cpu, MSR_MTRRfix4K_E8000, env->mtrr_fixed[8]);
kvm_msr_entry_add(cpu, MSR_MTRRfix4K_F0000, env->mtrr_fixed[9]);
kvm_msr_entry_add(cpu, MSR_MTRRfix4K_F8000, env->mtrr_fixed[10]);
for (i = 0; i < MSR_MTRRcap_VCNT; i++) {
kvm_msr_entry_add(cpu, MSR_MTRRphysBase(i),
env->mtrr_var[i].base);
kvm_msr_entry_add(cpu, MSR_MTRRphysMask(i),
env->mtrr_var[i].mask);
}
}
}
if (env->mcg_cap) {
int i;
kvm_msr_entry_add(cpu, MSR_MCG_STATUS, env->mcg_status);
kvm_msr_entry_add(cpu, MSR_MCG_CTL, env->mcg_ctl);
if (has_msr_mcg_ext_ctl) {
kvm_msr_entry_add(cpu, MSR_MCG_EXT_CTL, env->mcg_ext_ctl);
}
for (i = 0; i < (env->mcg_cap & 0xff) * 4; i++) {
kvm_msr_entry_add(cpu, MSR_MC0_CTL + i, env->mce_banks[i]);
}
}
ret = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, cpu->kvm_msr_buf);
if (ret < 0) {
return ret;
}
assert(ret == cpu->kvm_msr_buf->nmsrs);
return 0;
}
| 1threat
|
count all the characters I have used in a textbox c# : <p>I want to calculate all the number of characters I have used in a textbox.
For example: If I write this equation in textbox:
5x-2(3y+2)*3y(8)
so what code or line should I write for counting all the parenthesis used here?</p>
| 0debug
|
static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx)
{
switch (mmu_idx) {
case ARMMMUIdx_S2NS:
case ARMMMUIdx_S1E2:
return 2;
case ARMMMUIdx_S1E3:
return 3;
case ARMMMUIdx_S1SE0:
return arm_el_is_aa64(env, 3) ? 1 : 3;
case ARMMMUIdx_S1SE1:
case ARMMMUIdx_S1NSE0:
case ARMMMUIdx_S1NSE1:
return 1;
default:
g_assert_not_reached();
}
}
| 1threat
|
How to pass parameters to AWS Lambda function : <p>I know that it is possible to pass parameters to a Java program running on AWS Lambda in order to test it. But I do not know how to pass those parameters if this program gets called by a schedule event.</p>
<p>Does anyone know if this is possible? If yes, how?
I was not able to find anything about it.</p>
<p>Thanks in advance</p>
| 0debug
|
Reading JSON with Apache Spark - `corrupt_record` : <p>I have a <code>json</code> file, <code>nodes</code> that looks like this:</p>
<pre><code>[{"toid":"osgb4000000031043205","point":[508180.748,195333.973],"index":1}
,{"toid":"osgb4000000031043206","point":[508163.122,195316.627],"index":2}
,{"toid":"osgb4000000031043207","point":[508172.075,195325.719],"index":3}
,{"toid":"osgb4000000031043208","point":[508513,196023],"index":4}]
</code></pre>
<p>I am able to read and manipulate this record with Python.</p>
<p>I am trying to read this file in <code>scala</code> through the <code>spark-shell</code>.</p>
<p>From this <a href="http://xinhstechblog.blogspot.be/2015/06/reading-json-data-in-spark-dataframes.html" rel="noreferrer">tutorial</a>, I can see that it is possible to read <code>json</code> via <code>sqlContext.read.json</code></p>
<pre><code>val vfile = sqlContext.read.json("path/to/file/nodes.json")
</code></pre>
<p>However, this results in a <code>corrupt_record</code> error:</p>
<pre><code>vfile: org.apache.spark.sql.DataFrame = [_corrupt_record: string]
</code></pre>
<p>Can anyone shed some light on this error? I can read and use the file with other applications and I am confident it is not corrupt and sound <code>json</code>.</p>
| 0debug
|
def min_Swaps(s1,s2) :
c0 = 0; c1 = 0;
for i in range(len(s1)) :
if (s1[i] == '0' and s2[i] == '1') :
c0 += 1;
elif (s1[i] == '1' and s2[i] == '0') :
c1 += 1;
result = c0 // 2 + c1 // 2;
if (c0 % 2 == 0 and c1 % 2 == 0) :
return result;
elif ((c0 + c1) % 2 == 0) :
return result + 2;
else :
return -1;
| 0debug
|
What does an _ (underline character) on the left side of a C# lambda operator mean? : <p>What does an _ (underline character) on the left side of a C# lambda operator mean? as in:</p>
<pre><code> Movment = this.FixedUpdateAsObservable()
.Select(_ =>
{
var x = Input.GetAxis("Horizontal");
var y = Input.GetAxis("Vertical");
return new Vector2(x, y).normalized;
}
);
</code></pre>
| 0debug
|
Default Access Specifier of constructor in Inheritance : I did a little web search and came to know that default constructor's access specifier is same as the access level of class, but take a look here
her's one class
package package2;
`public class TestClass1 {
TestClass1()
{
System.out.println("In parent's contructor");
}
}
and here another which inherits the previous one
package package2;
public class TestClass2 extends TestClass1 {
TestClass2()
{
System.out.println("In TestClass2's contructor");
}
}
`
but when i try to create the object of `TestClass2`
import package2.*;
class MainClass {
public static void main(String[] args)
{
TestClass2 t2 = new TestClass2(); //Says the constructor TestClass2() is not visible.
}
}
I don't understand both classes `TestClass1` and `TestClass2` have public access so their constructors must also be implicitly public, Which concept am I missing here ? o.O
| 0debug
|
How to reorder elements using bootstrap 4? : <p>I have a simple section in which I want to display nested elements using bootstrap.</p>
<p>Here is what I have so far</p>
<p>HTML ;</p>
<pre><code><div class="container">
<div class="row d-flex d-lg-block">
<div class="col-lg-8 order-1 float-left">
<div class="card card-body tall">2</div>
</div>
<div class="col-lg-4 order-0 float-left">
<div class="card card-body">1</div>
</div>
<div class="col-lg-4 order-1 float-left">
<div class="card card-body">3</div>
</div>
</div>
</div>
</code></pre>
<p>This give me this result</p>
<p>desktop version</p>
<pre><code>--------- ------
| 2 || 1 |
| || |
| |-------
| || 3 |
| || |
| |-------
| |
| |
---------
</code></pre>
<p>No I want the same but reversed , something like this</p>
<pre><code> --------- ---
| 1 | | 2 |
| | | |
------- | |
| 3 | | |
| | | |
------- | |
-----
</code></pre>
<p>mobile version (stacked in order) like this</p>
<pre><code> --------
| 1 |
| |
--------
| 2 |
| |
| |
| |
| |
| |
--------
| 3 |
| |
--------
</code></pre>
<p>I tried to use <code>float-right</code> but unfortunately, it's not working</p>
<p>what do I need to change to get what I want?</p>
| 0debug
|
static int init_input_stream(int ist_index, char *error, int error_len)
{
int i;
InputStream *ist = input_streams[ist_index];
if (ist->decoding_needed) {
AVCodec *codec = ist->dec;
if (!codec) {
snprintf(error, error_len, "Decoder (codec id %d) not found for input stream #%d:%d",
ist->st->codec->codec_id, ist->file_index, ist->st->index);
return AVERROR(EINVAL);
}
for (i = 0; i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
if (ost->source_index == ist_index) {
update_sample_fmt(ist->st->codec, codec, ost->st->codec);
break;
}
}
if (codec->type == AVMEDIA_TYPE_VIDEO && codec->capabilities & CODEC_CAP_DR1) {
ist->st->codec->get_buffer = codec_get_buffer;
ist->st->codec->release_buffer = codec_release_buffer;
ist->st->codec->opaque = ist;
}
if (!av_dict_get(ist->opts, "threads", NULL, 0))
av_dict_set(&ist->opts, "threads", "auto", 0);
if (avcodec_open2(ist->st->codec, codec, &ist->opts) < 0) {
snprintf(error, error_len, "Error while opening decoder for input stream #%d:%d",
ist->file_index, ist->st->index);
return AVERROR(EINVAL);
}
assert_codec_experimental(ist->st->codec, 0);
assert_avoptions(ist->opts);
if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
for (i = 0; i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
if (ost->source_index == ist_index) {
if (!ist->st->codec->channel_layout || !ost->st->codec->channel_layout)
get_default_channel_layouts(ost, ist);
break;
}
}
}
}
ist->last_dts = ist->st->avg_frame_rate.num ? - ist->st->codec->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0;
ist->next_dts = AV_NOPTS_VALUE;
init_pts_correction(&ist->pts_ctx);
ist->is_start = 1;
return 0;
}
| 1threat
|
C# grandchild project DLLs not included in msbuild package : <p>I have a C# project X that references a C# project Y that references a C# project Z. So the dependency chain looks like this: X => Y => Z. There is no direct/explicit dependency X => Z. When I build a package for publication using msbuild command</p>
<pre><code>msbuild DesignService.csproj /m /p:Configuration="Debug" /p:Platform="AnyCPU" /verbosity:quiet /t:Package /p:PackageLocation=X.zip /p:PackageAsSingleFile=True
</code></pre>
<p>I get a zip file that has DLLs for X and Y, but not Z. Then when the package is published (to an Azure App Service) I get runtime errors when a call is made to code in Z, saying the DLL can not be found. If I add Z as a direct/explicit reference in X, it works just fine. But I don't think I should have to do this. </p>
<p>How can I get DLLs for Z in my publish package from msbuild without adding an explicit reference in X?</p>
| 0debug
|
How to scroll a div's content when the cursor is outside of this div using jquery or js? : <p>As on my question title, i want to allow users to scroll the content inside a div even when their mouse pointer is outside of the div with id="scrolldiv". Here is a quick mockup.</p>
<p><a href="https://imgur.com/a/5pMHfLG" rel="nofollow noreferrer">https://imgur.com/a/5pMHfLG</a></p>
| 0debug
|
What does "Challenge" term stand for? : <p><code>ControllerBase</code> class has <code>Challenge</code> method, that returns an object of the <code>ChallengeResult</code> class.
<code>CookieAuthenticationOptions</code> class has <code>AutomaticChallenge</code> property.</p>
<p>I believe <code>ChallengeResult</code> has something to do with external logins. But how does it actually work? Where does the term "Challenge" come from? What does lay inside this.</p>
| 0debug
|
What is the rails way equivalent of mailto: and tel:? : <p>My model have contact:string and email:string attributes. In pure html, we can write</p>
<p><code><a href="mailto:sample@email.com">email us</a></code></p>
<p>and </p>
<pre><code><a href="tel:123-456">123-456</a>
</code></pre>
<p>How do we convert these two into rails code assuming my model name is sample. My guess would be something like</p>
<pre><code><%= link_to @sample.email, "#" %>
<%= link_to @sample.contact, "#" %>
</code></pre>
<p>What should be in the <code>"#"</code> ?</p>
| 0debug
|
i want to use carbon format time with jquery but I don't nkow how to convert jquery data to php : <p><a href="https://i.stack.imgur.com/iRLrm.png" rel="nofollow noreferrer">I want to use carbon format time with juery</a></p>
| 0debug
|
static void vp8_h_loop_filter_simple_c(uint8_t *dst, ptrdiff_t stride, int flim)
{
int i;
for (i = 0; i < 16; i++)
if (simple_limit(dst + i * stride, 1, flim))
filter_common(dst + i * stride, 1, 1);
}
| 1threat
|
Using css modules with Extract Text Plugin : <p>Webpack 2 build doesn't work as expected in production mode using css modules option in css-loader with extract-text-webpack-plugin.</p>
<p>the correct generated classes are created on html elements, implying that css-loader is working as intended, but the extracted css file from the extract-text-webpack-plugin is lacking the css identifiers.</p>
<p>I'm using a method for implementing both global css and css modules together as discussed here: <a href="https://github.com/css-modules/css-modules/pull/65" rel="noreferrer">https://github.com/css-modules/css-modules/pull/65</a>
and here: <a href="https://github.com/kitze/custom-react-scripts/issues/29" rel="noreferrer">https://github.com/kitze/custom-react-scripts/issues/29</a>.</p>
<p>I'm using different loader tests for files which end with .css and files which end with .cssm.css indicating that they should be loaded using modules.</p>
<p>relevant part of config: </p>
<pre><code>const extractTextPlugin = new ExtractTextPlugin({filename: '[name].[id].[contenthash].css', allChunks: true});
return {
module: {
rules: [
{
test: /\.cssm.(css|less)$/,
loader: extractTextPlugin.extract({
fallbackLoader: 'style-loader',
loader: [
{
loader: 'css-loader',
query: {
importLoaders: 1,
modules: true,
localIdentName: '[name]_[local]_[hash:base64:5]'
}
},
{
loader: 'postcss-loader',
query: {
ident: 'postcss',
plugins: function() {
return [
require('autoprefixer')
];
}
}
},
{
loader: 'less-loader'
}
]
})
},
{
test: /\.(css|less)$/,
include: paths,
loader: extractTextPlugin.extract({
fallbackLoader: 'style-loader',
loader: [
{
loader: 'css-loader',
query: {
importLoaders: 1
}
},
{
loader: 'postcss-loader',
query: {
ident: 'postcss',
plugins: function() {
return [
require('autoprefixer')
];
}
}
},
{
loader: 'less-loader'
}
]
})
}
]
},
plugins: [
extractTextPlugin
]
};
</code></pre>
<p>I have tried suggested solutions like using webpack 1 style of writing loaders, but that didn't help.</p>
<p>I'm using webpack version: 2.6.1
and extract-text-webpack-plugin: 2.1.2.</p>
<p>I also tried other versions, which didn't seem to help either.</p>
<p>my global css files work fine, only the imported .cssm.css files are being ignored when used with extract-text-webpack-plugin. </p>
<p>How do I fix the problem of css module files not being extracted properly with other global css?</p>
| 0debug
|
JHipster configure maven wrapper proxy : <p>According to <a href="https://jhipster.github.io/configuring-a-corporate-proxy/" rel="noreferrer">https://jhipster.github.io/configuring-a-corporate-proxy/</a> I have set up my proxy settings in /.m2/settings.xml like this : </p>
<pre><code> <proxies>
<proxy>
<id>myId</id>
<active>true</active>
<protocol>http</protocol>
<username>myDomain\myUsername</username>
<password>myPassword</password>
<host>myHost</host>
<port>myPort</port>
</proxy>
</proxies>
</code></pre>
<p>But somehow it is not working when I'm trying to mvnw the project, it's giving me :</p>
<pre><code>Exception in thread "main" java.net.ConnectException: Connection refused: connect
</code></pre>
<p>I managed to get it work while passing below parameters to MAVEN_OPTS but I would like to do so with settings.xml file only.</p>
<pre><code>set MAVEN_OPTS=-Dhttps.proxyHost=myHost -Dhttps.proxyPort=myPort -Dhttps.proxyUser=myDomain\myUsername -Dhttps.proxyPassword=myPassword
</code></pre>
<p>Anyone can help ?</p>
<p>Thanks in advance.</p>
| 0debug
|
Swift Use array in Json : <p>When I add an array in my JSON object and convert it to JSON, after printing there is parenthesis instead of curly brace.</p>
<pre><code>var jsonObject : [String: Any] = [:]
var x = [1,2,3,4]
jsonObject["arr"] = x
do{
let jsonData = try JSONSerialization.data(withJSONObject: jsonObject, options: [])
let decoded = try JSONSerialization.jsonObject(with: jsonData, options: [])
print(decoded)
} ...
</code></pre>
<p>And the result of printing: </p>
<pre><code>{
arr = (
1,
2,
3,
4
);
}
</code></pre>
<p>But in JSON, to show an array it uses [ instead of (.</p>
<p>What's wrong? </p>
| 0debug
|
Kotlin: Constructor of inner class can be called only with receiver of containing class : <p>I was trying inner classes in Kotlin and came across this error but didn't quite understand it. I tried to look at the documentation <a href="https://kotlinlang.org/docs/reference/nested-classes.html" rel="noreferrer">here</a> but didn't quite get any direction as to how outer classes can access inner class constructors</p>
<pre><code>class OuterClass {
fun someFun(): InnerClassSuper {
return InnerClassX("Hello") //Error: Constructor of inner class InnerClassX can be called only with receiver of containing class
}
sealed class InnerClassSuper {
inner class InnerClassX(val x: String): InnerClassSuper()
}
}
</code></pre>
<p>Would appreciate if someone explains the error and directs how to fix it.
Thanks.</p>
| 0debug
|
Function in R to arrange coins in staircase.Task is to determine the number of complete rows of coins in the finished staircase : <p>Coins arrangement Example-
If there are 6 coins then a staircase with 1 coin in the top row, 2 in the second row & 3 in the third row.So, in total 3 rows can be completed.To complete the 4th row, 4 more coins would be required i.e. in total 10 coins.</p>
<p><strong>Each row should have exactly one coin more than the row above it.</strong></p>
<p>I have to generate a function that arranges the coin such that, for each coins [k] function must print an integer denoting the max. no of complete rows that can be created.
Arranging coin has the following conditions-
1.coins[coins[0], -------coins[m-1] an array of long integers each representing the number of coins
2. m is in the range of 1 to 10^5.
3.coins[k] is in the range between 1 to 10^15.</p>
| 0debug
|
Is it possible to decompile a .dll/.pyd file to extract Python Source Code? : <p>Are there any ways to decompile a dll and/or a .pyd file in order to extract source code written in Python? </p>
<p>Thanks in advance</p>
| 0debug
|
blkdebug_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
QEMUIOVector *qiov, int flags)
{
BDRVBlkdebugState *s = bs->opaque;
BlkdebugRule *rule = NULL;
QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) {
uint64_t inject_offset = rule->options.inject.offset;
if (inject_offset == -1 ||
(inject_offset >= offset && inject_offset < offset + bytes))
{
break;
if (rule && rule->options.inject.error) {
return inject_error(bs, rule);
return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);
| 1threat
|
Java cooperating generic classes : I have two abstract generic classes. They cooperate and hence depend on each other. Occasionally one needs to pass `this` to the other. I am trying to find a type safe way to do this.
public abstract class AbstractA<T extends AbstractB<? extends AbstractA<T>>> {
void foo(T aB) {
aB.bar(this);
}
}
public abstract class AbstractB<T extends AbstractA<? extends AbstractB<T>>> {
public void bar(T theA) {
// ... theA ...
}
}
I get a compiler error message at the call to `aB.bar()`: The method bar(capture#1-of ? extends AbstractA<T>) in the type AbstractB<capture#1-of ? extends AbstractA<T>> is not applicable for the arguments (AbstractA<T>).
I was thinking my problem may be related to the one discussed in http://stackoverflow.com/questions/8021900/java-generics-compilation-error-the-method-methodclasscapture1-of-extends. Inspired from that thread I coded a workaround in `AbstractB`:
@SuppressWarnings("unchecked")
// Parameter inexactly declared just AbstractA<? extends AbstractB<?>>
// because the compiler didn’t accept my call to setA(T theA)
public void setA(AbstractA<? extends AbstractB<?>> theA) {
// Unchecked cast from AbstractA<capture#1-of ? extends AbstractB<?>> to T
// ... (T) theA ...
}
It works, but it’s not so nice with the inexact parameter type and the unchecked cast. In that other thread I liked the reply by Tom Hawtin - tackling, but I have not found a way to apply it to my situation. Can anyone think of clean solution?
(`class AbstractA<T extends AbstractB<? extends AbstractA<T>>>` looks a bit complicated; I think I need it for concrete subclasses to know each other’s exact types.)
| 0debug
|
static int piix3_pre_save(void *opaque)
{
int i;
PIIX3State *piix3 = opaque;
for (i = 0; i < ARRAY_SIZE(piix3->pci_irq_levels_vmstate); i++) {
piix3->pci_irq_levels_vmstate[i] =
pci_bus_get_irq_level(piix3->dev.bus, i);
}
return 0;
}
| 1threat
|
Regarding "User setup for Windows" what should I do after download? : <p>I just upgraded vscode on windows 10 to v 1.26.1. A popup came up & said,
"We recommend switching to User Setup distribution of Code for Windows. Click <a href="https://code.visualstudio.com/updates/v1_26#_user-setup-for-windows" rel="noreferrer">here</a> for more info."</p>
<p>Well i clicked & it said to download and i did. The page said,"If you are a current user of the system-wide Windows setup, you will be prompted to switch to the user setup, which we recommend using from now on. <strong>Don't worry, all your settings and extensions will be kept</strong> during the transition."</p>
<p>Then when i ran the downloaded .exe a popup comes up & says
<a href="https://i.stack.imgur.com/4xsph.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/4xsph.jpg" alt="enter image description here"></a></p>
<p>So now I am worried. Are you folks <strong>sure</strong> my settings, etc. will be preserved if i click yes?</p>
| 0debug
|
Can I add more start menu items to my program with JavaFX? : <p>I'm using the <a href="https://github.com/FibreFoX/javafx-gradle-plugin" rel="noreferrer">JavaFX Gradle plugin</a> to build my JavaFX application. Is it possible to add more than one start menu item to the finished installer?</p>
| 0debug
|
My else statement is not effective but if statement is. Java : <p>I was going to let user enter 10 names and make it as array.
Then again I will let user to enter the names they want to search, then present the search result.
However, when I search something that was not in the array, the result still shows it. Is any problem in my code? Hope anyone could help, thanks.</p>
<pre><code>import java.util.Scanner;
import java.util.*;
public class Main
{
static List<String> name = new ArrayList<String>();
public static void main (String[]args)
{
Scanner input=new Scanner(System.in);
Scanner input2=new Scanner(System.in);
int i;
String sname;
System.out.println("Please enter 10 student names.");
for(i=1;i<11;i++){
name.add(input.next());
}
System.out.println("Namelist is " + name);
String[] namearray = name.toArray(new String[0]);
System.out.println("Arraylist is "+ Arrays.toString(namearray));
System.out.println("Please enter the names that you want to search.");
sname=input2.nextLine();
search(namearray, sname);
}
public static void search(String[]namearray,String sname)
{
int i;
boolean check;
for(i = 0; i < namearray.length; i++){
if(namearray[i].equals(sname))
check=true;
else
check=false;
}
if(check=true){
System.out.println("Found Result: "+sname);
}
else if (check=false){
System.out.println("Not Found.");
}
}
}
</code></pre>
<p>Thank you.</p>
| 0debug
|
How to write Rootkit in powershell : <p>My teacher tells me rootkit is the easiest program ever.
Is my teacher correct?
I already tried to write the hello world</p>
<pre><code>Write-Host 'Hello World!'
</code></pre>
| 0debug
|
Saving and retrieving date in Firebase : <p>I have a model with the following structure </p>
<pre><code>public class OfferModel {
private String mImageUrl;
private String mOfferCode;
private String mOfferTitle;
private String mOfferDescription;
private boolean mIsRunning;
private String mCreatorUid;
private Date mStartDate;
}
</code></pre>
<p>Everything else works fine on saving. It saves in Firebase Realtime database as</p>
<pre><code>startDate
date: 22
day: 3
hours: 23
minutes: 20
month: 5
seconds: 50
time: 1466617850476
timezoneOffset: -330
year: 116
</code></pre>
<p>But when I try to retrieve it, the date gives the following error - </p>
<pre><code>java.lang.ClassCastException: java.util.HashMap cannot be cast to java.util.Date
at com.localvine.models.OfferModel.<init>(OfferModel.java:37)
at com.localvine.managers.OfferManager$1.onDataChange(OfferManager.java:62)
at com.google.android.gms.internal.zzafp.zza(Unknown Source)
at com.google.android.gms.internal.zzagp.zzSu(Unknown Source)
at com.google.android.gms.internal.zzags$1.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:615)
</code></pre>
<p>I understand that Firebase doesn't support Java Date object, but since it's saving them in a map, how can I get back the date from that map? Is there any proper way of saving and retrieving dates in Firebase Android?</p>
| 0debug
|
static int vmdk_snapshot_create(const char *filename, const char *backing_file)
{
int snp_fd, p_fd;
int ret;
uint32_t p_cid;
char *p_name, *gd_buf, *rgd_buf;
const char *real_filename, *temp_str;
VMDK4Header header;
uint32_t gde_entries, gd_size;
int64_t gd_offset, rgd_offset, capacity, gt_size;
char p_desc[DESC_SIZE], s_desc[DESC_SIZE], hdr[HEADER_SIZE];
static const char desc_template[] =
"# Disk DescriptorFile\n"
"version=1\n"
"CID=%x\n"
"parentCID=%x\n"
"createType=\"monolithicSparse\"\n"
"parentFileNameHint=\"%s\"\n"
"\n"
"# Extent description\n"
"RW %u SPARSE \"%s\"\n"
"\n"
"# The Disk Data Base \n"
"#DDB\n"
"\n";
snp_fd = open(filename, O_RDWR | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE, 0644);
if (snp_fd < 0)
return -errno;
p_fd = open(backing_file, O_RDONLY | O_BINARY | O_LARGEFILE);
if (p_fd < 0) {
close(snp_fd);
return -errno;
}
if (lseek(p_fd, 0x0, SEEK_SET) == -1) {
ret = -errno;
goto fail;
}
if (read(p_fd, hdr, HEADER_SIZE) != HEADER_SIZE) {
ret = -errno;
goto fail;
}
if (lseek(snp_fd, 0x0, SEEK_SET) == -1) {
ret = -errno;
goto fail;
}
if (write(snp_fd, hdr, HEADER_SIZE) == -1) {
ret = -errno;
goto fail;
}
memset(&header, 0, sizeof(header));
memcpy(&header,&hdr[4], sizeof(header));
if (ftruncate(snp_fd, header.grain_offset << 9)) {
ret = -errno;
goto fail;
}
if (lseek(p_fd, 0x200, SEEK_SET) == -1) {
ret = -errno;
goto fail;
}
if (read(p_fd, p_desc, DESC_SIZE) != DESC_SIZE) {
ret = -errno;
goto fail;
}
if ((p_name = strstr(p_desc,"CID")) != NULL) {
p_name += sizeof("CID");
sscanf(p_name,"%x",&p_cid);
}
real_filename = filename;
if ((temp_str = strrchr(real_filename, '\\')) != NULL)
real_filename = temp_str + 1;
if ((temp_str = strrchr(real_filename, '/')) != NULL)
real_filename = temp_str + 1;
if ((temp_str = strrchr(real_filename, ':')) != NULL)
real_filename = temp_str + 1;
snprintf(s_desc, sizeof(s_desc), desc_template, p_cid, p_cid, backing_file,
(uint32_t)header.capacity, real_filename);
if (lseek(snp_fd, 0x200, SEEK_SET) == -1) {
ret = -errno;
goto fail;
}
if (write(snp_fd, s_desc, strlen(s_desc)) == -1) {
ret = -errno;
goto fail;
}
gd_offset = header.gd_offset * SECTOR_SIZE;
rgd_offset = header.rgd_offset * SECTOR_SIZE;
capacity = header.capacity * SECTOR_SIZE;
gt_size = (int64_t)header.num_gtes_per_gte * header.granularity * SECTOR_SIZE;
if (!gt_size) {
ret = -EINVAL;
goto fail;
}
gde_entries = (uint32_t)(capacity / gt_size);
gd_size = gde_entries * sizeof(uint32_t);
rgd_buf = qemu_malloc(gd_size);
if (lseek(p_fd, rgd_offset, SEEK_SET) == -1) {
ret = -errno;
goto fail_rgd;
}
if (read(p_fd, rgd_buf, gd_size) != gd_size) {
ret = -errno;
goto fail_rgd;
}
if (lseek(snp_fd, rgd_offset, SEEK_SET) == -1) {
ret = -errno;
goto fail_rgd;
}
if (write(snp_fd, rgd_buf, gd_size) == -1) {
ret = -errno;
goto fail_rgd;
}
qemu_free(rgd_buf);
gd_buf = qemu_malloc(gd_size);
if (lseek(p_fd, gd_offset, SEEK_SET) == -1) {
ret = -errno;
goto fail_gd;
}
if (read(p_fd, gd_buf, gd_size) != gd_size) {
ret = -errno;
goto fail_gd;
}
if (lseek(snp_fd, gd_offset, SEEK_SET) == -1) {
ret = -errno;
goto fail_gd;
}
if (write(snp_fd, gd_buf, gd_size) == -1) {
ret = -errno;
goto fail_gd;
}
qemu_free(gd_buf);
close(p_fd);
close(snp_fd);
return 0;
fail_gd:
qemu_free(gd_buf);
fail_rgd:
qemu_free(rgd_buf);
fail:
close(p_fd);
close(snp_fd);
return ret;
}
| 1threat
|
Flutter - Push and Get value between routes : <p>How do I send the green string from the HomePage page to the ContaPage page?</p>
<p>I think it's so <code>Navigator.of(context).pushNamed('/conta/green');</code> but I do not know how to get in the page <code>conta</code> the <code>green</code> string</p>
<p>So, by getting the value of the string I can for example change the color of the backgroundColor of <code>appBar</code> in <code>ContaPage</code>.</p>
<p><strong>main.dart</strong></p>
<pre><code>import "package:flutter/material.dart";
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: "MyApp",
home: new HomePage(),
routes: <String, WidgetBuilder> {
'/home': (BuildContext context) => new HomePage(),
'/conta': (BuildContext context) => new ContaPage()
},
);
}
}
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) => new Scaffold(
appBar: new AppBar(
backgroundColor: new Color(0xFF26C6DA),
),
body: new ListView (
children: <Widget>[
new FlatButton(
child: new Text("ok"),
textColor: new Color(0xFF66BB6A),
onPressed: () {
Navigator.of(context).pushNamed('/conta');
},
),
],
)
);
}
class ContaPage extends StatelessWidget {
@override
Widget build(BuildContext context) => new Scaffold(
appBar: new AppBar(
backgroundColor: new Color(0xFF26C6DA),
),
);
}
</code></pre>
| 0debug
|
I'm confused how to proceed with creating a user defined function (PHP) : I'm taking a highschool CS class but the one homework question is really confusing me. So essentially, I'm supposed to create a function that uses 2 arguments. Both of the arguments are strings. One of the arguments is this text (Placeholder text here.) and the other argument is a letter, either A or B. If it's A, I need to change the case using the built in php function of the text to upper case. If it's B, I need to change the case using the built in php function of the text to lower case.
Okay, so I know I have to use an elseif statement, but I'm just not sure how I should proceed. If anyone could give me some starters that would be much appreciated.
Thank you for reading!
| 0debug
|
int float32_lt_quiet( float32 a, float32 b STATUS_PARAM )
{
flag aSign, bSign;
if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )
|| ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )
) {
if ( float32_is_signaling_nan( a ) || float32_is_signaling_nan( b ) ) {
float_raise( float_flag_invalid STATUS_VAR);
}
return 0;
}
aSign = extractFloat32Sign( a );
bSign = extractFloat32Sign( b );
if ( aSign != bSign ) return aSign && ( (bits32) ( ( a | b )<<1 ) != 0 );
return ( a != b ) && ( aSign ^ ( a < b ) );
}
| 1threat
|
please help me to write my function in haskell & Gtk : I've got a question concerning the writing of a function in haskell, using Gtk (via the package Gtk2Hs); here are my requirements:
- the function should have the signature :
affiche :: ((Double,Double), (Double,Double)) -> IO Bool
- the parameters are noted ((a0,a), (b0,b)); the function should use an external function called mandelbrot : if mandelbrot (a,b) is true, then there must be a call to : postGUIAsync affiche2 a0 b0, where affiche2 is (I also introduced my try to write affiche):
affiche2 :: Double -> Double -> Render()
affiche2 a b = do
C.rectangle a b 1 1
stroke
affiche :: ((Double,Double), (Double,Double)) -> IO Bool
affiche ((a0,a), (b0,b)) = when (mandelbrot a b) $ affiche2 a0 b0
my attempt to write affiche does not use postGUIAsync, and it raises the error:
Error: Couldn't match type ‘Render’ with ‘IO’
Expected type: IO Bool
Actual type: Render ()
| 0debug
|
If / Then fomula : I want a formula that answers if x <= y then "a" but if x <= z then "b" but if > z then "0"
I've tried several things, this is the closest I've come to solving.
=IF(A36>8,0,IF(A36<=8,"1 Case",IF(A36<=4,"2 Cases")))
anything less than 8 always gives me the 1 case answer.
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.