problem
stringlengths
26
131k
labels
class label
2 classes
Error: Could not find or load main class : <p>I am new to java and I am currently trying to run a program for a class assignment and it compiles however, every time I run it I get this error "Error: Could not find or load main class sailboat.java" To make things worse I need to submit this in a different way from standard assignments logging onto the main server of my campus and transfer it from my directory to another yet every time I do it, it tells me it can't open the source file.</p> <p>Would these two situations because by the same thing? Is this something caused by a mistake in my code, or is it something wrong with my Classpath?</p> <p>here's the code I made, I used notepad++ </p> <pre><code>import java.text.*; import java.io.*; import java.math.*; public class sailboat { public static void main (String argv []) throws IOException { BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in)); String inputValue; //Tartan 34C Title System.out.println("Sailboat: Tartan 34C"); //Tartan 34C inputs double LOA = Double.parseDouble("34.50"); double LWL = Double.parseDouble("24.00"); double beam = Double.parseDouble("10.20"); double displace = Double.parseDouble("11200.00"); double displace_Ton = Double.parseDouble("5.60"); double sail_Area = Double.parseDouble("483.00"); //Hull Speed Formula double hull_Speed = Math.sqrt(LWL) * 1.34; System.out.println("Hull Speed:" + hull_Speed); //Displacement to Waterline Length Formula double displace_Lng = displace_Ton / 0.01 * Math.pow(LWL, 3.0); System.out.println("Displacement to water lenght:" + displace_Lng); //Sail Area to Displacement Formula double sail_Area_Displace = sail_Area / Math.pow((displace / 64), 0.67); System.out.println("Sail Area to displacement:" + sail_Area_Displace); //Capsize Screening Index Formula double Cap_I = beam / Math.pow((displace / 64), 0.33); System.out.println("Capsize Screening Index:" + Cap_I); //Comfort Index Formula double Comf_I = displace / (0.7 * LWL + 0.3 * LOA) * 0.65 * Math.pow(beam, 1.33); System.out.println("Comfort Index:" + Comf_I + "\n"); </code></pre> <p>any input would be helpful.</p>
0debug
static int segment_start(AVFormatContext *s, int write_header) { SegmentContext *c = s->priv_data; AVFormatContext *oc = c->avf; int err = 0; if (write_header) { avformat_free_context(oc); c->avf = NULL; if ((err = segment_mux_init(s)) < 0) return err; oc = c->avf; } if (c->wrap) c->number %= c->wrap; if (av_get_frame_filename(oc->filename, sizeof(oc->filename), s->filename, c->number++) < 0) return AVERROR(EINVAL); if ((err = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL)) < 0) return err; if (oc->oformat->priv_class && oc->priv_data) av_opt_set(oc->priv_data, "resend_headers", "1", 0); if (write_header) { if ((err = avformat_write_header(oc, NULL)) < 0) return err; } return 0; }
1threat
Google Maps not loading after publishing on play store even after updating SHA 1 fingerprint for release key : <p>A newbie here to google maps api and android app development. I am facing some strange issue and struggling with this from two days. I have developed an app in which I have used Google maps. I have launched the app to play store. The google map loads perfectly fine when I install the signed apk directly to mobile but not when I install through play store.</p> <p>I have updated google maps api console with release key SHA 1 fingerprint. I am not able to find any solutions online also and did not get any support from google support team also. Somebody please help!</p>
0debug
void cpu_loop(CPUCRISState *env) { CPUState *cs = CPU(cris_env_get_cpu(env)); int trapnr, ret; target_siginfo_t info; while (1) { cpu_exec_start(cs); trapnr = cpu_cris_exec(cs); cpu_exec_end(cs); switch (trapnr) { case 0xaa: { info.si_signo = TARGET_SIGSEGV; info.si_errno = 0; info.si_code = TARGET_SEGV_MAPERR; info._sifields._sigfault._addr = env->pregs[PR_EDA]; queue_signal(env, info.si_signo, &info); } break; case EXCP_INTERRUPT: break; case EXCP_BREAK: ret = do_syscall(env, env->regs[9], env->regs[10], env->regs[11], env->regs[12], env->regs[13], env->pregs[7], env->pregs[11], 0, 0); env->regs[10] = ret; break; case EXCP_DEBUG: { int sig; sig = gdb_handlesig(cs, TARGET_SIGTRAP); if (sig) { info.si_signo = sig; info.si_errno = 0; info.si_code = TARGET_TRAP_BRKPT; queue_signal(env, info.si_signo, &info); } } break; default: printf ("Unhandled trap: 0x%x\n", trapnr); cpu_dump_state(cs, stderr, fprintf, 0); exit(EXIT_FAILURE); } process_pending_signals (env); } }
1threat
Webpack output is empty object : <p>I want to build a react component library as a node module to then import it into different projects. But if I try to import a component it just returns an empty object.</p> <p>button.jsx:</p> <pre><code>import React, {Component} from 'react' export class Button extends Component { render() { return &lt;button className='btn'&gt;Hello Button comp&lt;/button&gt; } } export default Button </code></pre> <p>index.js</p> <pre><code>var Button = require('./button/button').default; module.exports = { Button: Button } </code></pre> <p>webpack.config.js</p> <pre><code>const Path = require('path'); module.exports = { resolve: { extensions: ['.js', '.jsx'] }, entry: { app: './src/components/index.js' }, output: { path: __dirname, filename: 'bundle.js' }, module: { rules: [ { test: /\.jsx$/, loader: 'babel-loader', query: { presets: [ 'es2015', 'react' ] }, exclude: /node_modules/, include: [ Path.resolve(__dirname, 'src') ] }, { test: /\.js$/, loader: 'babel-loader', query: { presets: [ 'es2015', 'react' ] }, exclude: /node_modules/, include: [ Path.resolve(__dirname, 'src') ] } ] } } </code></pre> <p>Main property in package.json is bundle.js</p> <p>I figured out that when I import Button in a project it is just an empty object. It seems to me as if webpack doesn't bundle the index file properly. Any ideas what could be wrong here?</p>
0debug
static av_cold int truemotion1_decode_init(AVCodecContext *avctx) { TrueMotion1Context *s = avctx->priv_data; s->avctx = avctx; s->frame = av_frame_alloc(); if (!s->frame) return AVERROR(ENOMEM); av_fast_malloc(&s->vert_pred, &s->vert_pred_size, s->avctx->width * sizeof(unsigned int)); if (!s->vert_pred) return AVERROR(ENOMEM); return 0; }
1threat
How to request a url with % witouth making it be %25? : <p>URL encoding replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits.</p> <pre><code>% %25 %25 </code></pre> <p>I have this form with a hidden input that has the value something like "%56756%234" but when i submit the form it replaces my % for %25 and it goes like "%2556756%25234" and doesn't work, is it possible to send the original value with form?</p>
0debug
How to install sagemath kernel in Jupyter : <p>I could use Python Kernel with Jupyter. I am looking for a way to use sagemath inside Jupyter.I couldnt see a way for installing it. How to do that?</p>
0debug
boto3: Spot Instance Creation : <p>I'm trying to create a spot instance using boto3. Although I follow the <a href="http://boto3.readthedocs.org/en/latest/reference/services/ec2.html#EC2.Client.request_spot_instances" rel="noreferrer">API documentation</a>, I receive an exception I couldn't be able to figure out. The code I'm using is: </p> <pre><code>import boto3 import datetime client = boto3.client('ec2') response = client.request_spot_instances( DryRun=False, SpotPrice='0.10', ClientToken='string', InstanceCount=1, Type='one-time', LaunchSpecification={ 'ImageId': 'ami-fce3c696', 'KeyName': 'awskey.pem', 'SecurityGroups': ['sg-709f8709'], 'InstanceType': 'm4.large', 'Placement': { 'AvailabilityZone': 'us-east-1a', }, 'BlockDeviceMappings': [ { 'Ebs': { 'SnapshotId': 'snap-f70deff0', 'VolumeSize': 100, 'DeleteOnTermination': True, 'VolumeType': 'gp2', 'Iops': 300, 'Encrypted': False }, }, ], 'EbsOptimized': True, 'Monitoring': { 'Enabled': True }, 'SecurityGroupIds': [ 'sg-709f8709', ] } ) </code></pre> <p>And I receive the following exception:</p> <pre><code>botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the RequestSpotInstances operation: Value () for parameter groupId is invalid. The value cannot be empty </code></pre> <p>The thing is there is no groupId parameter in the request in the <a href="http://boto3.readthedocs.org/en/latest/reference/services/ec2.html#EC2.Client.request_spot_instances" rel="noreferrer">API documentation</a>. </p> <p>Am I missing something?</p>
0debug
Check if a value exists in an object : <p>I'm trying do some validations based of an object with key-value pairs like below</p> <p><code>var map = {'1': ['a','b','c'], '2': ['d','e'], '3': 'f'}</code></p> <p>and I want to check if my desired value is in a particular key segment <code>if('a' in map[1])</code></p> <p>is there a way where we can check it like above?</p>
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
static int mv_read_packet(AVFormatContext *avctx, AVPacket *pkt) { MvContext *mv = avctx->priv_data; AVIOContext *pb = avctx->pb; AVStream *st = avctx->streams[mv->stream_index]; const AVIndexEntry *index; int frame = mv->frame[mv->stream_index]; int ret; uint64_t pos; if (frame < st->nb_index_entries) { index = &st->index_entries[frame]; pos = avio_tell(pb); if (index->pos > pos) avio_skip(pb, index->pos - pos); else if (index->pos < pos) { if (!pb->seekable) return AVERROR(EIO); ret = avio_seek(pb, index->pos, SEEK_SET); if (ret < 0) return ret; } ret = av_get_packet(pb, pkt, index->size); if (ret < 0) return ret; pkt->stream_index = mv->stream_index; pkt->pts = index->timestamp; pkt->flags |= AV_PKT_FLAG_KEY; mv->frame[mv->stream_index]++; mv->eof_count = 0; } else { mv->eof_count++; if (mv->eof_count >= avctx->nb_streams) return AVERROR_EOF; return AVERROR(EAGAIN); } mv->stream_index++; if (mv->stream_index >= avctx->nb_streams) mv->stream_index = 0; return 0; }
1threat
int ff_MPV_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic_arg, int *got_packet) { MpegEncContext *s = avctx->priv_data; int i, stuffing_count, ret; int context_count = s->slice_context_count; s->picture_in_gop_number++; if (load_input_picture(s, pic_arg) < 0) return -1; if (select_input_picture(s) < 0) { return -1; } if (s->new_picture.f->data[0]) { if (!pkt->data && (ret = ff_alloc_packet(pkt, s->mb_width*s->mb_height*MAX_MB_BYTES)) < 0) return ret; if (s->mb_info) { s->mb_info_ptr = av_packet_new_side_data(pkt, AV_PKT_DATA_H263_MB_INFO, s->mb_width*s->mb_height*12); s->prev_mb_info = s->last_mb_info = s->mb_info_size = 0; } for (i = 0; i < context_count; i++) { int start_y = s->thread_context[i]->start_mb_y; int end_y = s->thread_context[i]-> end_mb_y; int h = s->mb_height; uint8_t *start = pkt->data + (size_t)(((int64_t) pkt->size) * start_y / h); uint8_t *end = pkt->data + (size_t)(((int64_t) pkt->size) * end_y / h); init_put_bits(&s->thread_context[i]->pb, start, end - start); } s->pict_type = s->new_picture.f->pict_type; ret = frame_start(s); if (ret < 0) return ret; vbv_retry: if (encode_picture(s, s->picture_number) < 0) return -1; avctx->header_bits = s->header_bits; avctx->mv_bits = s->mv_bits; avctx->misc_bits = s->misc_bits; avctx->i_tex_bits = s->i_tex_bits; avctx->p_tex_bits = s->p_tex_bits; avctx->i_count = s->i_count; avctx->p_count = s->mb_num - s->i_count - s->skip_count; avctx->skip_count = s->skip_count; frame_end(s); if (CONFIG_MJPEG_ENCODER && s->out_format == FMT_MJPEG) ff_mjpeg_encode_picture_trailer(&s->pb, s->header_bits); if (avctx->rc_buffer_size) { RateControlContext *rcc = &s->rc_context; int max_size = rcc->buffer_index * avctx->rc_max_available_vbv_use; if (put_bits_count(&s->pb) > max_size && s->lambda < s->avctx->lmax) { s->next_lambda = FFMAX(s->lambda + 1, s->lambda * (s->qscale + 1) / s->qscale); if (s->adaptive_quant) { int i; for (i = 0; i < s->mb_height * s->mb_stride; i++) s->lambda_table[i] = FFMAX(s->lambda_table[i] + 1, s->lambda_table[i] * (s->qscale + 1) / s->qscale); } s->mb_skipped = 0; if (s->pict_type == AV_PICTURE_TYPE_P) { if (s->flipflop_rounding || s->codec_id == AV_CODEC_ID_H263P || s->codec_id == AV_CODEC_ID_MPEG4) s->no_rounding ^= 1; } if (s->pict_type != AV_PICTURE_TYPE_B) { s->time_base = s->last_time_base; s->last_non_b_time = s->time - s->pp_time; } for (i = 0; i < context_count; i++) { PutBitContext *pb = &s->thread_context[i]->pb; init_put_bits(pb, pb->buf, pb->buf_end - pb->buf); } goto vbv_retry; } assert(s->avctx->rc_max_rate); } if (s->flags & CODEC_FLAG_PASS1) ff_write_pass1_stats(s); for (i = 0; i < 4; i++) { s->current_picture_ptr->f->error[i] = s->current_picture.f->error[i]; avctx->error[i] += s->current_picture_ptr->f->error[i]; } if (s->flags & CODEC_FLAG_PASS1) assert(avctx->header_bits + avctx->mv_bits + avctx->misc_bits + avctx->i_tex_bits + avctx->p_tex_bits == put_bits_count(&s->pb)); flush_put_bits(&s->pb); s->frame_bits = put_bits_count(&s->pb); stuffing_count = ff_vbv_update(s, s->frame_bits); if (stuffing_count) { if (s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb) >> 3) < stuffing_count + 50) { av_log(s->avctx, AV_LOG_ERROR, "stuffing too large\n"); return -1; } switch (s->codec_id) { case AV_CODEC_ID_MPEG1VIDEO: case AV_CODEC_ID_MPEG2VIDEO: while (stuffing_count--) { put_bits(&s->pb, 8, 0); } break; case AV_CODEC_ID_MPEG4: put_bits(&s->pb, 16, 0); put_bits(&s->pb, 16, 0x1C3); stuffing_count -= 4; while (stuffing_count--) { put_bits(&s->pb, 8, 0xFF); } break; default: av_log(s->avctx, AV_LOG_ERROR, "vbv buffer overflow\n"); } flush_put_bits(&s->pb); s->frame_bits = put_bits_count(&s->pb); } if (s->avctx->rc_max_rate && s->avctx->rc_min_rate == s->avctx->rc_max_rate && s->out_format == FMT_MPEG1 && 90000LL * (avctx->rc_buffer_size - 1) <= s->avctx->rc_max_rate * 0xFFFFLL) { int vbv_delay, min_delay; double inbits = s->avctx->rc_max_rate * av_q2d(s->avctx->time_base); int minbits = s->frame_bits - 8 * (s->vbv_delay_ptr - s->pb.buf - 1); double bits = s->rc_context.buffer_index + minbits - inbits; if (bits < 0) av_log(s->avctx, AV_LOG_ERROR, "Internal error, negative bits\n"); assert(s->repeat_first_field == 0); vbv_delay = bits * 90000 / s->avctx->rc_max_rate; min_delay = (minbits * 90000LL + s->avctx->rc_max_rate - 1) / s->avctx->rc_max_rate; vbv_delay = FFMAX(vbv_delay, min_delay); assert(vbv_delay < 0xFFFF); s->vbv_delay_ptr[0] &= 0xF8; s->vbv_delay_ptr[0] |= vbv_delay >> 13; s->vbv_delay_ptr[1] = vbv_delay >> 5; s->vbv_delay_ptr[2] &= 0x07; s->vbv_delay_ptr[2] |= vbv_delay << 3; avctx->vbv_delay = vbv_delay * 300; } s->total_bits += s->frame_bits; avctx->frame_bits = s->frame_bits; pkt->pts = s->current_picture.f->pts; if (!s->low_delay) { if (!s->current_picture.f->coded_picture_number) pkt->dts = pkt->pts - s->dts_delta; else pkt->dts = s->reordered_pts; s->reordered_pts = s->input_picture[0]->f->pts; } else pkt->dts = pkt->pts; if (s->current_picture.f->key_frame) pkt->flags |= AV_PKT_FLAG_KEY; if (s->mb_info) av_packet_shrink_side_data(pkt, AV_PKT_DATA_H263_MB_INFO, s->mb_info_size); } else { s->frame_bits = 0; } assert((s->frame_bits & 7) == 0); pkt->size = s->frame_bits / 8; *got_packet = !!pkt->size; return 0; }
1threat
static void arm_gic_common_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->reset = arm_gic_common_reset; dc->realize = arm_gic_common_realize; dc->props = arm_gic_common_properties; dc->vmsd = &vmstate_gic; dc->no_user = 1; }
1threat
int avresample_get_matrix(AVAudioResampleContext *avr, double *matrix, int stride) { int in_channels, out_channels, i, o; in_channels = av_get_channel_layout_nb_channels(avr->in_channel_layout); out_channels = av_get_channel_layout_nb_channels(avr->out_channel_layout); if ( in_channels < 0 || in_channels > AVRESAMPLE_MAX_CHANNELS || out_channels < 0 || out_channels > AVRESAMPLE_MAX_CHANNELS) { av_log(avr, AV_LOG_ERROR, "Invalid channel layouts\n"); return AVERROR(EINVAL); } switch (avr->mix_coeff_type) { case AV_MIX_COEFF_TYPE_Q8: if (!avr->am->matrix_q8[0]) { av_log(avr, AV_LOG_ERROR, "matrix is not set\n"); return AVERROR(EINVAL); } for (o = 0; o < out_channels; o++) for (i = 0; i < in_channels; i++) matrix[o * stride + i] = avr->am->matrix_q8[o][i] / 256.0; break; case AV_MIX_COEFF_TYPE_Q15: if (!avr->am->matrix_q15[0]) { av_log(avr, AV_LOG_ERROR, "matrix is not set\n"); return AVERROR(EINVAL); } for (o = 0; o < out_channels; o++) for (i = 0; i < in_channels; i++) matrix[o * stride + i] = avr->am->matrix_q15[o][i] / 32768.0; break; case AV_MIX_COEFF_TYPE_FLT: if (!avr->am->matrix_flt[0]) { av_log(avr, AV_LOG_ERROR, "matrix is not set\n"); return AVERROR(EINVAL); } for (o = 0; o < out_channels; o++) for (i = 0; i < in_channels; i++) matrix[o * stride + i] = avr->am->matrix_flt[o][i]; break; default: av_log(avr, AV_LOG_ERROR, "Invalid mix coeff type\n"); return AVERROR(EINVAL); } return 0; }
1threat
static void gen_arm_parallel_addsub(int op1, int op2, TCGv a, TCGv b) { TCGv tmp; switch (op1) { #define gen_pas_helper(name) glue(gen_helper_,name)(a, a, b, tmp) case 1: tmp = tcg_temp_new(TCG_TYPE_PTR); tcg_gen_addi_ptr(tmp, cpu_env, offsetof(CPUState, GE)); PAS_OP(s) break; case 5: tmp = tcg_temp_new(TCG_TYPE_PTR); tcg_gen_addi_ptr(tmp, cpu_env, offsetof(CPUState, GE)); PAS_OP(u) break; #undef gen_pas_helper #define gen_pas_helper(name) glue(gen_helper_,name)(a, a, b) case 2: PAS_OP(q); break; case 3: PAS_OP(sh); break; case 6: PAS_OP(uq); break; case 7: PAS_OP(uh); break; #undef gen_pas_helper } }
1threat
Why does AWS Lambda function always time out? : <p>I am testing out aws lambda, using nodejs with the 4.3 version. I'm able to successfully complete all the statements in my handler function within the console test, which includes connecting to a mongodb host within our vpc. But, the function always times out. I've found several posts and resources that discuss using the callback, and setting properties on the context, and IAM role permissions, but no matter what I do, it always ends up timing out. Current code:</p> <pre><code>'use strict'; var Mongoose = require('mongoose'); var Device = require('./device_model'); var Alarm = require('./alarm_model'); var Event = require('./event_model'); var mongoConnection = process.env.MONGO_URL; var connection = Mongoose.connect(mongoConnection); Mongoose.connection.once('open', function() { console.log("Connecting to mongo at: " + mongoConnection); console.log("Mongoose connection in lambda opened"); }); Mongoose.connection.on('error', function(){ console.error("Error creating mongoose connection in lambda, exiting!"); process.exit(1); }); exports.check_alarms = function(event, context, callback) { context.callbackWaitsForEmtpyEventLoop = false; console.log("The incoming event: " + JSON.stringify(event)); var device = null; Device.findByUUID(event.uuid, function(error, result){ if(!error){ device = result; console.log("the device: " + JSON.stringify(device)); if(event.Ale &amp;&amp; event.Ale.length &gt; 0) { console.log("We have an alarm, checking if already set"); callback(null, {"status":"alarms"}); } else { console.log("Event contains no alarm; checking for historic active"); callback(null, {"status":"no alarms"}); } } else { console.log("there's a problem on mongo"); callback("problem", "status not so good"); } }); callback(null, {"status":"outside of device find block"}); } </code></pre>
0debug
How to declare multiple dimensional array in TypeScript : In my app, I need to define an element like: commandsList:[RegExp, string, string]; but when I tried to push the array elements into it, as below: public registerCommand(command:RegExp, cb:string, phrase:string):void{ this.commandsList.push({ command: command, callback: cb, originalPhrase: phrase }); } I got the below error at the `command:command` > [ts] Argument of type '{ command: RegExp; callback: string; > originalPhrase: string; }' is not assignable to parameter of type > 'string | RegExp'. Object literal may only specify known properties, > and 'command' does not exist in type 'string | RegExp'. (parameter) > command: RegExp The full code is in my other question [here][1]. What is the mistake I've, and how to solve it? [1]: http://stackoverflow.com/q/41315930/2441637
0debug
Convert factor to number with this command correct : <p>Im trying to convert the following factor to number in RStudio, can I use this commands?</p> <p><code>NewFactor &lt;- factor(c(31, 764, 9.6, 513, 125.344, 3131.657, 9853));as.numeric(NewFactor)</code></p>
0debug
c# don't understand calling methods. object orientated programming : I've just started object orientated programming and i don't quite understand how to call another method. I wanted to calculate the percentage increase and then put out the resulting overall price. This would be done by calling the method to do the working out then returning the value to the other method. However i'm unsure about how to cross over between methods. Could someone please explain how i'm meant to do this. Preferably not just giving the answer so i can fully understand what's happening. p.s. this piece of code is in a class called RetailPricing. As i've copied and pasted it, it doesn't look like it's all formatted properly. (i understand how to call this class to the main program) Thank you in advance! namespace week7exercise2 { class RetailPricing { public void CalculateRetailPrice() { double inputcost; double inputpercent; string inputitemcost; string inputmarkup; Console.Write("Please Input The Cost Of The Item: "); inputitemcost = Console.ReadLine(); inputcost = double.Parse(inputitemcost); Console.Write("Please Input The Markup Percentage: "); inputmarkup = Console.ReadLine(); inputpercent = double.Parse(inputmarkup); Console.Write("Your Retail Price Is: " + newprice); } public double sum(double MarkUpPercentage, double overallprice, double newprice) { MarkUpPercentage = inputpercent + 100; overallprice = MarkUpPercentage / 100; newprice = inputcost * overallprice; return newprice; } } }
0debug
Can you run a macro from one excel sheet in another? Xlwings : I want to run a macro on CSV files that are sent to me using an xlwings script. As such storing the Macro in each new file would be a pain. Is there anyway to run the scrip from another workbook, or even just directly send the code to the CSV file?
0debug
need help i have table in sql server with set of colunms i just want to select values between from and to columns in sql : select Q.mem_id from tb_mem_share Q,tb_member MB where MB.mem_id=Q.mem_id AND Q.share_num_from between '42368' and '42378' select * from tb_mem_share where share_num_from >= 42368 and share_num_from <=42378 by giving this i can get only second record ,i need data which lies between from and to mem_id share_num_from share_num_to no_of_shares share_amt KA003871 42360 42369 10 10000 KA000401 42370 42379 10 10000
0debug
import math def find_Index(n): x = math.sqrt(2 * math.pow(10,(n - 1))); return round(x);
0debug
ASP.NET Core 2 + Get instance of db context : <p>I am trying to get an instance of the DbContext (so I can do some additional work upon startup with it), I get the following error when trying to get an instance in the Configure method:</p> <p>System.InvalidOperationException: 'Cannot resolve scoped service 'MyApp.Data.MyDbContext' from root provider.'</p> <pre><code>public void ConfigureServices(IServiceCollection services) { services.AddDbContext&lt;MyDbContext&gt;( options =&gt; options.UseSqlServer(Configuration.GetConnectionString("MyDbContext"))); } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { var dbContext = app.ApplicationServices.GetService(typeof(MyDbContext)) as MyDbContext; } </code></pre> <p>I can access an instance of the DbContext fine via the controller, etc</p>
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
static off_t read_uint32(BlockDriverState *bs, int64_t offset) { uint32_t buffer; if (bdrv_pread(bs->file, offset, &buffer, 4) < 4) return 0; return be32_to_cpu(buffer); }
1threat
Remove transparency/alpha from any image using PIL : <p>How do I replace the alpha channel of any image (png, jpg, rgb, rbga) with specified background color? It must also work with images that do not have an alpha channel.</p>
0debug
Not able to comment, android developers please read! WebView display : since i don't have the 50 rep required to comment -.- stupid idea... This is my first app development so please bare with me on this ^^. ill simply have to ask this question here again, it's topic related to this: https://stackoverflow.com/questions/14423981/android-webview-display-only-some-part-of-website/14424866#14424866 and it's about this code that is written there: public class MyWebClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } @Override public void onPageFinished(WebView view, String url) { view.loadUrl("javascript:your javascript"); } } ......... final MyWebClient myWebViewClient = new MyWebClient(); mWebView.setWebViewClient(myWebViewClient); Im having difficulties running this code even after modified like this: public class MyWebClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { webView.loadUrl("http://tid.mspot.nu"); return true; } @Override public void onPageFinished(WebView view, String url) { view.loadUrl("document.getElementsByClassName('white').style.visibility = 'hidden'"); } } final MyWebClient myWebViewClient = new MyWebClient(); mWebView.setWebViewClient(myWebViewClient); > error: class, interface, or enum expected > error: class, interface, or enum expected Since im not a java developer this gets a bit confused (mainly working with PHP) and some parts im totally familiar with. Here is my currently working code: import android.annotation.TargetApi; import android.net.http.SslError; import android.os.Build; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.KeyEvent; import android.webkit.SslErrorHandler; import android.webkit.WebResourceRequest; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends AppCompatActivity { private WebView webView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); webView = (WebView)findViewById(R.id.webView); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setDomStorageEnabled(true); webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); webView.setVerticalScrollBarEnabled(false); webView.setHorizontalScrollBarEnabled(false); webView.getSettings().setUseWideViewPort(true); webView.setWebViewClient(new WebViewClient() { @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed();// super.onReceivedSslError(view, handler, error); } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { return false; } @TargetApi(Build.VERSION_CODES.N) @Override public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { return false; } }); webView.loadUrl("http://tid.mspot.nu"); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: if (webView.canGoBack()) { webView.goBack(); } else { finish(); } return true; } } return super.onKeyDown(keyCode, event); } } and i would love to be able to implement that feature of hiding this "btn_white" class i know it's supposed to be an id which ill change right now. This is just a button to download the app that i wan't to hide in the app, makes sense i suppose ^^ would love to have some help with this since it's my first time developing anything for android. Thanks!
0debug
How can parse the dunamic json with newtonsoft? : I have this json:<br/> > "{'service_list': [], 'session_id': '234234DSSF', 'user': > {'basic_info': {'recharge_deposit': 0.0, 'status': 'Recharged', > 'user_id': 8, 'deposit': 0.0, 'isp_id': 0, 'group_id': 5, > 'creation_date': '2017-04-19 08:11:26.882558', 'nearest_exp_date': > '2017-05-19 08:56:00', 'group_name': 'IRN-U2'}, 'id': 8, 'is_prepaid': > True, 'attrs': {'normal_password': 'subh1', 'real_first_login': > '1492592160', 'normal_username': 'subh1', 'user_id': 8, 'first_login': > '1492592160'}}, 'event': 'first_login', 'event_datetime': '2017-05-10 > 10:00:00', 'remote_ip': ['127.0.0.1']}" <br/> and want to parse with this c# code:<br/> dynamic obj = JsonConvert.DeserializeObject(x); <br/> but get this error on that line:<br/> > Unexpected character encountered while parsing value: T. Path > 'user.is_prepaid', line 1, position 317 <br/> How can i solve that?thanks.
0debug
void slirp_select_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set *xfds) { }
1threat
Pandas - Slice Large Dataframe in Chunks : <p>I have a large dataframe (>3MM rows) that I'm trying to pass through a function (the one below is largely simplified), and I keep getting a <code>Memory Error</code> message. </p> <p>I think I'm passing too large of a dataframe into the function, so I'm trying to:</p> <p>1) Slice the dataframe into smaller chunks <strong>(preferably sliced by <code>AcctName</code>)</strong></p> <p>2) Pass the dataframe into the function</p> <p>3) Concatenate the dataframes back into one large dataframe</p> <pre><code>def trans_times_2(df): df['Double_Transaction'] = df['Transaction'] * 2 large_df AcctName Timestamp Transaction ABC 12/1 12.12 ABC 12/2 20.89 ABC 12/3 51.93 DEF 12/2 13.12 DEF 12/8 9.93 DEF 12/9 92.09 GHI 12/1 14.33 GHI 12/6 21.99 GHI 12/12 98.81 </code></pre> <p>I know that my function works properly, since it will work on a smaller dataframe (e.g. 40,000 rows). I tried the following, but I was unsuccessful with concatenating the small dataframes back into one large dataframe.</p> <pre><code>def split_df(df): new_df = [] AcctNames = df.AcctName.unique() DataFrameDict = {elem: pd.DataFrame for elem in AcctNames} key_list = [k for k in DataFrameDict.keys()] new_df = [] for key in DataFrameDict.keys(): DataFrameDict[key] = df[:][df.AcctNames == key] trans_times_2(DataFrameDict[key]) rejoined_df = pd.concat(new_df) </code></pre> <p><strong>How I envision the dataframes being split:</strong></p> <pre><code>df1 AcctName Timestamp Transaction Double_Transaction ABC 12/1 12.12 24.24 ABC 12/2 20.89 41.78 ABC 12/3 51.93 103.86 df2 AcctName Timestamp Transaction Double_Transaction DEF 12/2 13.12 26.24 DEF 12/8 9.93 19.86 DEF 12/9 92.09 184.18 df3 AcctName Timestamp Transaction Double_Transaction GHI 12/1 14.33 28.66 GHI 12/6 21.99 43.98 GHI 12/12 98.81 197.62 </code></pre>
0debug
void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value) { uint64_t *copy; copy = g_malloc(sizeof(value)); *copy = cpu_to_le64(value); fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value)); }
1threat
void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, uintptr_t addr) { if (TCG_TARGET_REG_BITS == 64) { tcg_insn_unit i1, i2; intptr_t tb_diff = addr - tc_ptr; intptr_t br_diff = addr - (jmp_addr + 4); uint64_t pair; if (tb_diff == (int16_t)tb_diff) { i1 = ADDI | TAI(TCG_REG_TB, TCG_REG_TB, tb_diff); i2 = B | (br_diff & 0x3fffffc); } else { intptr_t lo = (int16_t)tb_diff; intptr_t hi = (int32_t)(tb_diff - lo); assert(tb_diff == hi + lo); i1 = ADDIS | TAI(TCG_REG_TB, TCG_REG_TB, hi >> 16); i2 = ADDI | TAI(TCG_REG_TB, TCG_REG_TB, lo); } #ifdef HOST_WORDS_BIGENDIAN pair = (uint64_t)i1 << 32 | i2; #else pair = (uint64_t)i2 << 32 | i1; #endif atomic_set((uint64_t *)jmp_addr, pair); flush_icache_range(jmp_addr, jmp_addr + 8); } else { intptr_t diff = addr - jmp_addr; tcg_debug_assert(in_range_b(diff)); atomic_set((uint32_t *)jmp_addr, B | (diff & 0x3fffffc)); flush_icache_range(jmp_addr, jmp_addr + 4); } }
1threat
What is the difference between ACL and SCO Link in Bluetooth? : <p>ACL= Asynchronous Connection-Less. SCO = Synchronous Connection Oriented.</p> <p>SCO is Point to Point Connection between only one master and only one slave.</p> <p>ACL is multipoint connection between one master and many slaves. </p> <p>What are the other differences? </p>
0debug
static void handle_windowevent(SDL_Event *ev) { struct sdl2_console *scon = get_scon_from_window(ev->window.windowID); switch (ev->window.event) { case SDL_WINDOWEVENT_RESIZED: { QemuUIInfo info; memset(&info, 0, sizeof(info)); info.width = ev->window.data1; info.height = ev->window.data2; dpy_set_ui_info(scon->dcl.con, &info); sdl2_redraw(scon); break; case SDL_WINDOWEVENT_EXPOSED: sdl2_redraw(scon); break; case SDL_WINDOWEVENT_FOCUS_GAINED: case SDL_WINDOWEVENT_ENTER: if (!gui_grab && (qemu_input_is_absolute() || absolute_enabled)) { absolute_mouse_grab(scon); break; case SDL_WINDOWEVENT_FOCUS_LOST: if (gui_grab && !gui_fullscreen) { sdl_grab_end(scon); break; case SDL_WINDOWEVENT_RESTORED: update_displaychangelistener(&scon->dcl, GUI_REFRESH_INTERVAL_DEFAULT); break; case SDL_WINDOWEVENT_MINIMIZED: update_displaychangelistener(&scon->dcl, 500); break; case SDL_WINDOWEVENT_CLOSE: if (!no_quit) { no_shutdown = 0; qemu_system_shutdown_request(); break; case SDL_WINDOWEVENT_SHOWN: if (scon->hidden) { SDL_HideWindow(scon->real_window); break; case SDL_WINDOWEVENT_HIDDEN: if (!scon->hidden) { SDL_ShowWindow(scon->real_window); break;
1threat
Turn on/off gps using button without getting into setting menu : <p>I want to ask about turn on gps in android without getting into setting menu. 1. Does that method possibly to do? 2. If yes how to do that? Thank you.</p>
0debug
How to traverse a treeview in WPF and get values from all nodes : Okay, I'm ready for the downvotes and the snide comments but I can't find an answer to this question now matter how I ask it. There appears to be solutions if the treeview is in WinForms but not if it's in WPF. I'm loading an XML file at runtime that is bound to a treeview called OOB. The user can perform all kinds of edits to the treeview (adding and deleting nodes, changing the node's contents, etc.). All of this works perfectly. Now, I have to save it back out as an XML file. Apparently, this is near impossible in WPF. At this point all I can think of doing is traversing the entire tree (from what I've read it may be necessary to first expand all nodes which is easily enough done) and then I can, one by one, read the nodes and write them to an XML file using `xmlWriter`. So, unless somebody has a better idea, how can I in C# and WPF traverse an entire tree, getting the contents of each `Node.name`? Once I have the contents of each node I should be able to reconstitute the tree structure and write them out as an XML file. Thanks in advance!
0debug
void enable_kvm_pv_eoi(void) { kvm_default_features |= kvm_pv_eoi_features; }
1threat
Boolean - Int conversion in Kotlin : <p>Is there no built-in way to convert between boolean - int in Kotlin? I am talking about the usual:</p> <pre><code>true -&gt; 1 false -&gt; 0 </code></pre> <p>If not, what is an idiomatic way to do it?</p>
0debug
int find_utlb_entry(CPUState * env, target_ulong address, int use_asid) { uint8_t urb, urc; urb = ((env->mmucr) >> 18) & 0x3f; urc = ((env->mmucr) >> 10) & 0x3f; urc++; if (urc == urb || urc == UTLB_SIZE - 1) urc = 0; env->mmucr = (env->mmucr & 0xffff03ff) | (urc << 10); return find_tlb_entry(env, address, env->utlb, UTLB_SIZE, use_asid); }
1threat
static void pxa2xx_pic_mem_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) { PXA2xxPICState *s = (PXA2xxPICState *) opaque; switch (offset) { case ICMR: s->int_enabled[0] = value; break; case ICMR2: s->int_enabled[1] = value; break; case ICLR: s->is_fiq[0] = value; break; case ICLR2: s->is_fiq[1] = value; break; case ICCR: s->int_idle = (value & 1) ? 0 : ~0; break; case IPR0 ... IPR31: s->priority[0 + ((offset - IPR0 ) >> 2)] = value & 0x8000003f; break; case IPR32 ... IPR39: s->priority[32 + ((offset - IPR32) >> 2)] = value & 0x8000003f; break; default: printf("%s: Bad register offset " REG_FMT "\n", __FUNCTION__, offset); return; } pxa2xx_pic_update(opaque); }
1threat
Create networks automatically in Docker Compose : <p>When using custom networks in Docker like</p> <pre><code>networks: default: external: name: service-tier </code></pre> <p>And try to run that, I´m getting the error</p> <blockquote> <p>ERROR: Network service-tier declared as external, but could not be found. Please create the network manually using <code>docker network create service-tier</code> and try again.</p> </blockquote> <p>Is it possible to create networks automatically with docker-compose or is there no other way than creating them manually first?</p>
0debug
static void tight_pack24(VncState *vs, uint8_t *buf, size_t count, size_t *ret) { uint32_t *buf32; uint32_t pix; int rshift, gshift, bshift; buf32 = (uint32_t *)buf; if ((vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG) == (vs->ds->surface->flags & QEMU_BIG_ENDIAN_FLAG)) { rshift = vs->clientds.pf.rshift; gshift = vs->clientds.pf.gshift; bshift = vs->clientds.pf.bshift; } else { rshift = 24 - vs->clientds.pf.rshift; gshift = 24 - vs->clientds.pf.gshift; bshift = 24 - vs->clientds.pf.bshift; } if (ret) { *ret = count * 3; } while (count--) { pix = *buf32++; *buf++ = (char)(pix >> rshift); *buf++ = (char)(pix >> gshift); *buf++ = (char)(pix >> bshift); } }
1threat
Access Jupyter notebook running on Docker container : <p>I created a docker image with python libraries and Jupyter. I start the container with the option <code>-p 8888:8888</code>, to link ports between host and container. When I launch a Jupyter kernel inside the container, it is running on <code>localhost:8888</code> (and does not find a browser). I used the command <code>jupyter notebook</code></p> <p>But from my host, what is the IP address I have to use to work with Jupyter in host's browser ? </p> <p>With the command <code>ifconfig</code>, I find <code>eth0</code>, <code>docker</code>, <code>wlan0</code>, <code>lo</code> ...</p> <p>Thanks ! </p>
0debug
static int smjpeg_read_packet(AVFormatContext *s, AVPacket *pkt) { SMJPEGContext *sc = s->priv_data; uint32_t dtype, ret, size, timestamp; int64_t pos; if (s->pb->eof_reached) return AVERROR_EOF; pos = avio_tell(s->pb); dtype = avio_rl32(s->pb); switch (dtype) { case SMJPEG_SNDD: timestamp = avio_rb32(s->pb); size = avio_rb32(s->pb); ret = av_get_packet(s->pb, pkt, size); pkt->stream_index = sc->audio_stream_index; pkt->pts = timestamp; pkt->pos = pos; break; case SMJPEG_VIDD: timestamp = avio_rb32(s->pb); size = avio_rb32(s->pb); ret = av_get_packet(s->pb, pkt, size); pkt->stream_index = sc->video_stream_index; pkt->pts = timestamp; pkt->pos = pos; break; case SMJPEG_DONE: ret = AVERROR_EOF; break; default: av_log(s, AV_LOG_ERROR, "unknown chunk %x\n", dtype); ret = AVERROR_INVALIDDATA; break; } return ret; }
1threat
static void migrate_fd_put_notify(void *opaque) { MigrationState *s = opaque; qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); qemu_file_put_notify(s->file); if (qemu_file_get_error(s->file)) { migrate_fd_error(s); } }
1threat
Error with OMP_NUM_THREADS when using dask distributed : <p>I am using <a href="http://distributed.readthedocs.io/en/latest/" rel="noreferrer">distributed</a>, a framework to allow parallel computation. In this, my primary use case is with NumPy. When I include NumPy code that relies on <code>np.linalg</code>, I get an error with <code>OMP_NUM_THREADS</code>, which is related to the <a href="https://en.wikipedia.org/wiki/OpenMP" rel="noreferrer">OpenMP library</a>.</p> <p>An minimal example:</p> <pre><code>from distributed import Executor import numpy as np e = Executor('144.92.142.192:8786') def f(x, m=200, n=1000): A = np.random.randn(m, n) x = np.random.randn(n) # return np.fft.fft(x) # tested; no errors # return np.random.randn(n) # tested; no errors return A.dot(y).sum() # tested; throws error below s = [e.submit(f, x) for x in [1, 2, 3, 4]] s = e.gather(s) </code></pre> <p>When I test with the linalg test, <code>e.gather</code> fails as each job throws the following error:</p> <pre><code>OMP: Error #34: System unable to allocate necessary resources for OMP thread: OMP: System error #11: Resource temporarily unavailable OMP: Hint: Try decreasing the value of OMP_NUM_THREADS. </code></pre> <p>What should I set <code>OMP_NUM_THREADS</code> to?</p>
0debug
static int mjpeg_decode_init(AVCodecContext *avctx) { MJpegDecodeContext *s = avctx->priv_data; MpegEncContext s2; s->avctx = avctx; memset(&s2, 0, sizeof(MpegEncContext)); s2.flags= avctx->flags; s2.avctx= avctx; s2.width = 8; s2.height = 8; if (MPV_common_init(&s2) < 0) return -1; s->scantable= s2.intra_scantable; s->idct_put= s2.idct_put; MPV_common_end(&s2); s->mpeg_enc_ctx_allocated = 0; s->buffer_size = 102400; s->buffer = av_malloc(s->buffer_size); if (!s->buffer) return -1; s->start_code = -1; s->first_picture = 1; s->org_width = avctx->width; s->org_height = avctx->height; build_vlc(&s->vlcs[0][0], bits_dc_luminance, val_dc_luminance, 12); build_vlc(&s->vlcs[0][1], bits_dc_chrominance, val_dc_chrominance, 12); build_vlc(&s->vlcs[1][0], bits_ac_luminance, val_ac_luminance, 251); build_vlc(&s->vlcs[1][1], bits_ac_chrominance, val_ac_chrominance, 251); if (avctx->flags & CODEC_FLAG_EXTERN_HUFF) { printf("mjpeg: using external huffman table\n"); init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size); mjpeg_decode_dht(s); } return 0; }
1threat
Controlling motors from html web page : I am working on a project and the ultimate goal is to control some simple motors through a web page. I have created the web page using HTML and I am wondering what would be the best way to go about doing this is? I am wanting to send a command after the button is clicked to the server where a C# script running the motors will pick up the message and then control the motors accordingly. Would the best way to do this be through JSON and/or Jquery? So far I have a .load function written in jquery that is sending a simple message to ther server then that function is being called upon button press by the html document. My main question is if this is the most best route to go when communicating between HTML, a server, and C#. Thank you.
0debug
Hooks and Redux Saga : <p>I am learning redux hooks and wondering how to use it along with redux saga.</p> <p>Currently the code written in saga is as follows.</p> <blockquote> <p>centers.js</p> </blockquote> <pre><code>componentDidMount() { this.props.getCenters(); } ... &lt;tbody&gt; { this.props.centers ? &lt;React.Fragment&gt; { centers.map((center, index) =&gt; &lt;tr key={index}&gt; &lt;td&gt;{center.name}&lt;/td&gt; &lt;td&gt;{center.zip}&lt;/td&gt; &lt;/tr&gt; ) } &lt;/React.Fragment&gt; : &lt;tr&gt; &lt;td&gt; No data available&lt;/td&gt; &lt;/tr&gt; } &lt;/tbody&gt; </code></pre> <p>The actions file is defined as follows.</p> <pre><code>export const getCenters = () =&gt; ({ type: types.CENTERS_REQUEST, }); </code></pre> <p>The saga file is defined as follows.</p> <pre><code>import { DEFAULT_ERROR_MSG } from '../../constants'; import { instance as centerProvider } from '../services/centerProvider'; function* fetchCenters() { try { const response = yield call(centerProvider.getCenters); const centers = response.data.data.centers; // dispatch a success action to the store yield put({ type: types.CENTERS_SUCCESS, centers}); } catch (error) { // dispatch a failure action to the store with the error yield put(DEFAULT_ERROR_MSG); } } export function* watchCenterRequest() { yield takeLatest(types.CENTERS_REQUEST, fetchCenters); } export default function* centerSaga() { yield all([ watchCenterRequest() ]); } </code></pre> <p>So the question is,</p> <ul> <li>Do we still need redux if we use hooks?</li> <li>How can we rewrite the above code using hooks?</li> </ul>
0debug
convert Java to Json Array please assist : I have to convert an Arraylist of users to from java to Json I figured out how to get the user to convert I don't know how to use the syntax for the array This is in the driver: // Convert a User to JSON String testStr = JsonUserConverter.convertUserToJson(bob); System.out.println(testStr); // Convert JSON string to a User User testUser = JsonUserConverter.convertJsonToUser(jsonUserString); System.out.println(testUser); // Convert an ArrayList of Users to JSON and I have to populate this public static String convertUsersArrayToJson(ArrayList<User>users){} with my User data from my User class. I only just learned about ObjectMapper. I assume there's something in my library to convert but I don't know. Help.
0debug
int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared) { int i, ret; if (shared) { assert(pic->f.data[0]); pic->shared = 1; } else { assert(!pic->f.data[0]); if (alloc_frame_buffer(s, pic) < 0) return -1; s->linesize = pic->f.linesize[0]; s->uvlinesize = pic->f.linesize[1]; } if (!pic->qscale_table_buf) ret = alloc_picture_tables(s, pic); else ret = make_tables_writable(pic); if (ret < 0) goto fail; if (s->encoding) { pic->mb_var = (uint16_t*)pic->mb_var_buf->data; pic->mc_mb_var = (uint16_t*)pic->mc_mb_var_buf->data; pic->mb_mean = pic->mb_mean_buf->data; } pic->mbskip_table = pic->mbskip_table_buf->data; pic->qscale_table = pic->qscale_table_buf->data + 2 * s->mb_stride + 1; pic->mb_type = (uint32_t*)pic->mb_type_buf->data + 2 * s->mb_stride + 1; if (pic->motion_val_buf[0]) { for (i = 0; i < 2; i++) { pic->motion_val[i] = (int16_t (*)[2])pic->motion_val_buf[i]->data + 4; pic->ref_index[i] = pic->ref_index_buf[i]->data; } } return 0; fail: av_log(s->avctx, AV_LOG_ERROR, "Error allocating a picture.\n"); ff_mpeg_unref_picture(s, pic); free_picture_tables(pic); return AVERROR(ENOMEM); }
1threat
Deploying Java SE application on AWS : <p>Hello I want to know how to deploy Java SE application on aws? I have created one java application.Now I want to run that application on aws </p>
0debug
void blk_io_limits_disable(BlockBackend *blk) { assert(blk->public.throttle_group_member.throttle_state); bdrv_drained_begin(blk_bs(blk)); throttle_group_unregister_tgm(&blk->public.throttle_group_member); bdrv_drained_end(blk_bs(blk)); }
1threat
Vue + Laravel: How to properly download a PDF file? : <p><strong>THE SITUATION:</strong></p> <p>Frontend: Vue. Backend: Laravel.</p> <p>Inside the web app I need to let the user download certain pdf files:</p> <ul> <li>I need Laravel to take the file and return it as a response of an API GET request.</li> <li>Then inside my Vue web app I need to get the file and download it.</li> </ul> <p><strong>THE CODE:</strong></p> <p><strong>API:</strong></p> <pre><code>$file = public_path() . "/path/test.pdf"; $headers = [ 'Content-Type' =&gt; 'application/pdf', ]; return response()-&gt;download($file, 'test.pdf', $headers); </code></pre> <p><strong>Web app:</strong></p> <pre><code>downloadFile() { this.$http.get(this.apiPath + '/download_pdf') .then(response =&gt; { let blob = new Blob([response.data], { type: 'application/pdf' }) let link = document.createElement('a') link.href = window.URL.createObjectURL(blob) link.download = 'test.pdf' link.click() }) } </code></pre> <p><strong>OUTCOME:</strong></p> <p>Using this code I do manage to download a pdf file. The problem is that the pdf is blank. </p> <p>Somehow the data got corrupted (not a problem of this particular pdf file, I have tried with several pdf files - same outcome)</p> <p><strong>RESPONSE FROM SERVER:</strong></p> <p>The response itself from the server is fine:</p> <p><a href="https://i.stack.imgur.com/E0nCJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/E0nCJ.png" alt="enter image description here"></a></p> <p><strong>PDF:</strong></p> <p>The problem may be with the pdf file. It definitely looks corrupted data. This is an excerpt of how it looks like the <code>response.data</code>:</p> <p><a href="https://i.stack.imgur.com/0F2OW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0F2OW.png" alt="enter image description here"></a></p> <p><strong>THE QUESTION:</strong></p> <p>How can I properly download a pdf file using Laravel for the API and Vue for the web app?</p> <p>Thanks!</p>
0debug
SP taking more time : I have an Stored procedure in my database. When i am calling stored procedure, some time it takes 1 minute, some time it takes 10 minutes, some time it takes more than that. the below step alone taking more time in the whole process, not sure if this poor query and need to re-write the SP or some other server issue IF (EXISTS (SELECT 1 FROM table1 PWI (NOLOCK) INNER JOIN table2 W (NOLOCK) ON PWI.ID = W.ID WHERE W.Flag = 1 AND PWI.PatID IN (SELECT PatID FROM @table3) AND W.SubID IN (SELECT SubID FROM @table4))) Please help to fix this issue
0debug
How do you use Python to clean API results to get say just the headlines of the news articles? : I am very new to programming using Python and have been having trouble finding a way to pull out specific text info from the Guardian API for my dissertation. I have managed to get all my text onto Python but how do you then clean it to get say, just the headlines of the news articles? This is a snippet of the API result that I want to pull out info from: {"response":{"status":"ok","userTier":"developer","total":1869990,"startIndex":1,"pageSize":10,"currentPage":1,"pages":186999,"orderBy":"newest","results":[{"id":"sport/live/2016/jul/09/tour-de-france-2016-stage-eight-live","type":"liveblog","sectionId":"sport","sectionName":"Sport","webPublicationDate":"2016-07-09T13:21:36Z","webTitle":"Tour de France 2016: stage eight – live!","webUrl":"https://www.theguardian.com/sport/live/2016/jul/09/tour-de-france-2016-stage-eight-live","apiUrl":"https://content.guardianapis.com/sport/live/2016/jul/09/tour-de-france-2016-stage-eight-live","isHosted":false},{"id":"sport/live/2016/jul/09/serena-williams-v-angelique-kerber-wimbledon-womens-final-live","type":"liveblog","sectionId":"sport","sectionName":"Sport","webPublicationDate":"2016-07-09T13:21:02Z","webTitle":"Serena Williams v Angelique Kerber: Wimbledon women's final – Any help would be greatly appreciated! Many thanks! I am also more familiar with R so if anyone knows of any easier way there let me know. Otherwise I would like to know the Python way as well.
0debug
static int x8_decode_intra_mb(IntraX8Context* const w, const int chroma){ MpegEncContext * const s= w->s; uint8_t * scantable; int final,run,level; int ac_mode,dc_mode,est_run,dc_level; int pos,n; int zeros_only; int use_quant_matrix; int sign; assert(w->orient<12); s->dsp.clear_block(s->block[0]); if(chroma){ dc_mode=2; }else{ dc_mode=!!w->est_run; } if(x8_get_dc_rlf(w, dc_mode, &dc_level, &final)) return -1; n=0; zeros_only=0; if(!final){ use_quant_matrix=w->use_quant_matrix; if(chroma){ ac_mode = 1; est_run = 64; }else{ if (w->raw_orient < 3){ use_quant_matrix = 0; } if(w->raw_orient > 4){ ac_mode = 0; est_run = 64; }else{ if(w->est_run > 1){ ac_mode = 2; est_run=w->est_run; }else{ ac_mode = 3; est_run = 64; } } } x8_select_ac_table(w,ac_mode); scantable = w->scantable[ (0x928548>>(2*w->orient))&3 ].permutated; pos=0; do { n++; if( n >= est_run ){ ac_mode=3; x8_select_ac_table(w,3); } x8_get_ac_rlf(w,ac_mode,&run,&level,&final); pos+=run+1; if(pos>63){ return -1; } level= (level+1) * w->dquant; level+= w->qsum; sign = - get_bits1(&s->gb); level = (level ^ sign) - sign; if(use_quant_matrix){ level = (level*quant_table[pos])>>8; } s->block[0][ scantable[pos] ]=level; }while(!final); s->block_last_index[0]=pos; }else{ s->block_last_index[0]=0; if(w->flat_dc && ((unsigned)(dc_level+1)) < 3){ int32_t divide_quant= !chroma ? w->divide_quant_dc_luma: w->divide_quant_dc_chroma; int32_t dc_quant = !chroma ? w->quant: w->quant_dc_chroma; dc_level+= (w->predicted_dc*divide_quant + (1<<12) )>>13; dsp_x8_put_solidcolor( av_clip_uint8((dc_level*dc_quant+4)>>3), s->dest[chroma], s->current_picture.f.linesize[!!chroma]); goto block_placed; } zeros_only = (dc_level == 0); } if(!chroma){ s->block[0][0] = dc_level*w->quant; }else{ s->block[0][0] = dc_level*w->quant_dc_chroma; } if( (unsigned int)(dc_level+1) >= 3 && (w->edges&3) != 3 ){ int direction; direction= (0x6A017C>>(w->orient*2))&3; if (direction != 3){ x8_ac_compensation(w, direction, s->block[0][0]); } } if(w->flat_dc){ dsp_x8_put_solidcolor(w->predicted_dc, s->dest[chroma], s->current_picture.f.linesize[!!chroma]); }else{ w->dsp.spatial_compensation[w->orient]( s->edge_emu_buffer, s->dest[chroma], s->current_picture.f.linesize[!!chroma] ); } if(!zeros_only) s->dsp.idct_add ( s->dest[chroma], s->current_picture.f.linesize[!!chroma], s->block[0] ); block_placed: if(!chroma){ x8_update_predictions(w,w->orient,n); } if(s->loop_filter){ uint8_t* ptr = s->dest[chroma]; int linesize = s->current_picture.f.linesize[!!chroma]; if(!( (w->edges&2) || ( zeros_only && (w->orient|4)==4 ) )){ w->dsp.h_loop_filter(ptr, linesize, w->quant); } if(!( (w->edges&1) || ( zeros_only && (w->orient|8)==8 ) )){ w->dsp.v_loop_filter(ptr, linesize, w->quant); } } return 0; }
1threat
Compare substring of elements in one list to strings in another list (convert my for loop to list comprehension) : I'd like to compare a substring of each element in a list of strings to the elements in another list of strings...BUT I want it in a list comprehension (for loops aren't as concise for my tastes) The code below works....can someone convert to list comprehension for me? mylist = [] for x in list1: mat = False for y in list2: if x[:-14] in y: mat = True if not mat: mylist.append(x)
0debug
ReactJS: How to determine if the application is being viewed on mobile or desktop browser : <p>In ReactJS, is there a way to determine if the website is being viewed on mobile or desktop? Because, depending on which device I would like to render different things.</p> <p>Thank you</p>
0debug
python blackjack -- dictionary output : def get_card_value(s): s = ' ' cards ={'A':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'10':10,'J':10,'Q':10,'K':10} for s in cards.keys(): return cards.values(s) else: raise ValueError("No card found") get_card_value(A) Hi, I am a beginner to python and I am making a blackjack game, I am stuck on the first part where I need to define a function that gets the integer points for the card "s". So Input is string value of card and Output returns the integer score of the card, can anyone help with what I've written??
0debug
static uint64_t ntohll(uint64_t v) { union { uint32_t lv[2]; uint64_t llv; } u; u.llv = v; return ((uint64_t)ntohl(u.lv[0]) << 32) | (uint64_t) ntohl(u.lv[1]); }
1threat
void ff_rtsp_close_streams(AVFormatContext *s) { RTSPState *rt = s->priv_data; int i; RTSPStream *rtsp_st; ff_rtsp_undo_setup(s); for (i = 0; i < rt->nb_rtsp_streams; i++) { rtsp_st = rt->rtsp_streams[i]; if (rtsp_st) { if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context) rtsp_st->dynamic_handler->close( rtsp_st->dynamic_protocol_context); } } av_free(rt->rtsp_streams); if (rt->asf_ctx) { av_close_input_stream (rt->asf_ctx); rt->asf_ctx = NULL; } av_free(rt->p); av_free(rt->recvbuf); }
1threat
Reversing the order of a linked-list FORTRAN (gen_ll.f90) : I've recently adopted the use of linked lists in FORTRAN and after some reading decided to use the [gen_ll.f90 package][1] from the [FORTRAN WIKI][2] which seemed simple and sufficient to my needs. It was only later that I realized that I must reverse the order of the terms in the list (i.e. 1->2->3->...->N->NULL needs to be N->...->3->2->1->NULL). I was trying to generate a function which replaces the pointers %P%Next to the previous instead of the next. The logic seemed good, but I keep messing it up somehow. I would ask for your help with coding this small function. The source code is attached in the [gen_ll.f90][1] link and the function/subroutine is straight-forward. Thank you so much! [1]: http://fortran.com/gen_ll.f90 [2]: http://fortranwiki.org/fortran/show/Linked+list
0debug
int ff_jpegls_decode_lse(MJpegDecodeContext *s) { int id; int tid, wt, maxtab, i, j; int len = get_bits(&s->gb, 16); id = get_bits(&s->gb, 8); switch (id) { case 1: s->maxval = get_bits(&s->gb, 16); s->t1 = get_bits(&s->gb, 16); s->t2 = get_bits(&s->gb, 16); s->t3 = get_bits(&s->gb, 16); s->reset = get_bits(&s->gb, 16); break; case 2: s->palette_index = 0; case 3: tid= get_bits(&s->gb, 8); wt = get_bits(&s->gb, 8); if (len < 5) return AVERROR_INVALIDDATA; if (wt < 1 || wt > MAX_COMPONENTS) { avpriv_request_sample(s->avctx, "wt %d", wt); return AVERROR_PATCHWELCOME; } if (!s->maxval) maxtab = 255; else if ((5 + wt*(s->maxval+1)) < 65535) maxtab = s->maxval; else maxtab = 65530/wt - 1; if(s->avctx->debug & FF_DEBUG_PICT_INFO) { av_log(s->avctx, AV_LOG_DEBUG, "LSE palette %d tid:%d wt:%d maxtab:%d\n", id, tid, wt, maxtab); } if (maxtab >= 256) { avpriv_request_sample(s->avctx, ">8bit palette"); return AVERROR_PATCHWELCOME; } maxtab = FFMIN(maxtab, (len - 5) / wt + s->palette_index); if (s->palette_index > maxtab) return AVERROR_INVALIDDATA; if ((s->avctx->pix_fmt == AV_PIX_FMT_GRAY8 || s->avctx->pix_fmt == AV_PIX_FMT_PAL8) && (s->picture_ptr->format == AV_PIX_FMT_GRAY8 || s->picture_ptr->format == AV_PIX_FMT_PAL8)) { uint32_t *pal = s->picture_ptr->data[1]; s->picture_ptr->format = s->avctx->pix_fmt = AV_PIX_FMT_PAL8; for (i=s->palette_index; i<=maxtab; i++) { pal[i] = 0; for (j=0; j<wt; j++) { pal[i] |= get_bits(&s->gb, 8) << (8*(wt-j-1)); } } s->palette_index = i; } break; case 4: avpriv_request_sample(s->avctx, "oversize image"); return AVERROR(ENOSYS); default: av_log(s->avctx, AV_LOG_ERROR, "invalid id %d\n", id); return AVERROR_INVALIDDATA; } av_dlog(s->avctx, "ID=%i, T=%i,%i,%i\n", id, s->t1, s->t2, s->t3); return 0; }
1threat
Can Spring Data REST's QueryDSL integration be used to perform more complex queries? : <p>I'm currently building a REST API in which I want clients to easily filter on most properties of a specific entity. Using <a href="http://querydsl.com/" rel="noreferrer">QueryDSL</a> in combination with <a href="http://projects.spring.io/spring-data-rest/" rel="noreferrer">Spring Data REST</a> (<a href="https://gist.github.com/olivergierke/decf03d4948cd58a51bc" rel="noreferrer">an example by Oliver Gierke</a>) allows me to easily get to 90% of what I want by allowing clients to filter by combining query parameters which refer to properties (e.g. <code>/users?firstName=Dennis&amp;lastName=Laumen</code>).</p> <p>I can even customize the mapping between the query parameters and an entity's properties by implementing the <code>QuerydslBinderCustomizer</code> interface (e.g. for case insensitive searches or partial string matches). This is all great, however I also want the clients to be able to filter some types using ranges. For example with regards to a property like date of birth I'd like to do something like the following, <code>/users?dateOfBirthFrom=1981-1-1&amp;dateOfBirthTo=1981-12-31</code>. The same goes for number based properties, <code>/users?idFrom=100&amp;idTo=200</code>. I have the feeling this should be possible using the <code>QuerydslBinderCustomizer</code> interface but the integration between these two libraries isn't documented very extensively.</p> <p><strong><em>Concluding, is this possible using Spring Data REST and QueryDSL? If so, how?</em></strong></p>
0debug
Android replace strings doesnt work : <p>in this below String arrays i have this tags:</p> <pre><code>String[] tags = { "&lt;mft:A&gt;", "&lt;mft:S&gt;", "&lt;mft:R&gt;", "&lt;/mft:A&gt;", "&lt;/mft:S&gt;", "&lt;/mft:R&gt;" }; </code></pre> <p>and i want to replace them with this <code>html</code> tags:</p> <pre><code>String[] replacementHtmlTags = { "&lt;font color=\"red\"&gt;", "&lt;font color=\"green\"&gt;", "&lt;font color=\"blue\"&gt;", "&lt;/font&gt;", "&lt;/font&gt;", "&lt;/font&gt;" }; </code></pre> <p>now after define targets and replacements my code doesn't work:</p> <pre><code>String rawParagraph = "11111 &lt;mft:A&gt;22222&lt;/mft:A&gt; 33333 &lt;mft:S&gt; 44444 &lt;mft:A&gt; 555555 &lt;mft:S&gt; 66666 &lt;/mft:S&gt;&lt;/mft:A&gt;&lt;/mft:S&gt;&lt;mft:R&gt; 77777 &lt;/mft:R&gt;" for (int tag = 0; tag &lt; tags.length; tag++) { rawParagraph.replace(tags[tag], replacementHtmlTags[tag]); } </code></pre>
0debug
static void do_video_out(AVFormatContext *s, OutputStream *ost, AVFrame *in_picture, int *frame_size) { int ret, format_video_sync; AVPacket pkt; AVCodecContext *enc = ost->st->codec; *frame_size = 0; format_video_sync = video_sync_method; if (format_video_sync == VSYNC_AUTO) format_video_sync = (s->oformat->flags & AVFMT_NOTIMESTAMPS) ? VSYNC_PASSTHROUGH : (s->oformat->flags & AVFMT_VARIABLE_FPS) ? VSYNC_VFR : VSYNC_CFR; if (format_video_sync != VSYNC_PASSTHROUGH && ost->frame_number && in_picture->pts != AV_NOPTS_VALUE && in_picture->pts < ost->sync_opts) { nb_frames_drop++; av_log(NULL, AV_LOG_VERBOSE, "*** drop!\n"); return; } if (in_picture->pts == AV_NOPTS_VALUE) in_picture->pts = ost->sync_opts; ost->sync_opts = in_picture->pts; if (!ost->frame_number) ost->first_pts = in_picture->pts; av_init_packet(&pkt); pkt.data = NULL; pkt.size = 0; if (ost->frame_number >= ost->max_frames) return; if (s->oformat->flags & AVFMT_RAWPICTURE && enc->codec->id == AV_CODEC_ID_RAWVIDEO) { enc->coded_frame->interlaced_frame = in_picture->interlaced_frame; enc->coded_frame->top_field_first = in_picture->top_field_first; pkt.data = (uint8_t *)in_picture; pkt.size = sizeof(AVPicture); pkt.pts = av_rescale_q(in_picture->pts, enc->time_base, ost->st->time_base); pkt.flags |= AV_PKT_FLAG_KEY; write_frame(s, &pkt, ost); } else { int got_packet; if (ost->st->codec->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME) && ost->top_field_first >= 0) in_picture->top_field_first = !!ost->top_field_first; in_picture->quality = ost->st->codec->global_quality; if (!enc->me_threshold) in_picture->pict_type = 0; if (ost->forced_kf_index < ost->forced_kf_count && in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) { in_picture->pict_type = AV_PICTURE_TYPE_I; ost->forced_kf_index++; } ret = avcodec_encode_video2(enc, &pkt, in_picture, &got_packet); if (ret < 0) { av_log(NULL, AV_LOG_FATAL, "Video encoding failed\n"); exit(1); } if (got_packet) { if (pkt.pts != AV_NOPTS_VALUE) pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base); if (pkt.dts != AV_NOPTS_VALUE) pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base); write_frame(s, &pkt, ost); *frame_size = pkt.size; video_size += pkt.size; if (ost->logfile && enc->stats_out) { fprintf(ost->logfile, "%s", enc->stats_out); } } } ost->sync_opts++; ost->frame_number++; }
1threat
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
how to keep spaces with escape sequences stringbuilder c# : I have a `stringbuilder` setup with escape sequences to show a ASCII like art to text. Here is my code: sb.AppendLine(@" _____ ______ ___ ___ ________ "); sb.AppendLine(@" |\ _ \ _ \|\ \|\ \|\ ___ \ "); sb.AppendLine(@" \ \ \\\__\ \ \ \ \\\ \ \ \_|\ \ "); sb.AppendLine(@" \ \ \\|__| \ \ \ \\\ \ \ \ \\ \ "); sb.AppendLine(@" \ \ \ \ \ \ \ \\\ \ \ \_\\ \ "); sb.AppendLine(@" \ \__\ \ \__\ \_______\ \_______\ "); sb.AppendLine(@" \|__| \|__|\|_______|\|_______| "); sb.AppendLine(@" "); And here is the output: _____ ______ ___ ___ ________ |\ _ \ _ \|\ \|\ \|\ ___ \ \ \ \\\__\ \ \ \ \\\ \ \ \_|\ \ \ \ \\|__| \ \ \ \\\ \ \ \ \\ \ \ \ \ \ \ \ \ \\\ \ \ \_\\ \ \ \__\ \ \__\ \_______\ \_______\ \|__| \|__|\|_______|\|_______| How can I keep my strings just as I typed them?
0debug
void RENAME(interleaveBytes)(uint8_t *src1, uint8_t *src2, uint8_t *dest, long width, long height, long src1Stride, long src2Stride, long dstStride){ long h; for(h=0; h < height; h++) { long w; #ifdef HAVE_MMX #ifdef HAVE_SSE2 asm( "xor %%"REG_a", %%"REG_a" \n\t" "1: \n\t" PREFETCH" 64(%1, %%"REG_a") \n\t" PREFETCH" 64(%2, %%"REG_a") \n\t" "movdqa (%1, %%"REG_a"), %%xmm0 \n\t" "movdqa (%1, %%"REG_a"), %%xmm1 \n\t" "movdqa (%2, %%"REG_a"), %%xmm2 \n\t" "punpcklbw %%xmm2, %%xmm0 \n\t" "punpckhbw %%xmm2, %%xmm1 \n\t" "movntdq %%xmm0, (%0, %%"REG_a", 2)\n\t" "movntdq %%xmm1, 16(%0, %%"REG_a", 2)\n\t" "add $16, %%"REG_a" \n\t" "cmp %3, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(dest), "r"(src1), "r"(src2), "r" (width-15) : "memory", "%"REG_a"" ); #else asm( "xor %%"REG_a", %%"REG_a" \n\t" "1: \n\t" PREFETCH" 64(%1, %%"REG_a") \n\t" PREFETCH" 64(%2, %%"REG_a") \n\t" "movq (%1, %%"REG_a"), %%mm0 \n\t" "movq 8(%1, %%"REG_a"), %%mm2 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "movq (%2, %%"REG_a"), %%mm4 \n\t" "movq 8(%2, %%"REG_a"), %%mm5 \n\t" "punpcklbw %%mm4, %%mm0 \n\t" "punpckhbw %%mm4, %%mm1 \n\t" "punpcklbw %%mm5, %%mm2 \n\t" "punpckhbw %%mm5, %%mm3 \n\t" MOVNTQ" %%mm0, (%0, %%"REG_a", 2)\n\t" MOVNTQ" %%mm1, 8(%0, %%"REG_a", 2)\n\t" MOVNTQ" %%mm2, 16(%0, %%"REG_a", 2)\n\t" MOVNTQ" %%mm3, 24(%0, %%"REG_a", 2)\n\t" "add $16, %%"REG_a" \n\t" "cmp %3, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(dest), "r"(src1), "r"(src2), "r" (width-15) : "memory", "%"REG_a ); #endif for(w= (width&(~15)); w < width; w++) { dest[2*w+0] = src1[w]; dest[2*w+1] = src2[w]; } #else for(w=0; w < width; w++) { dest[2*w+0] = src1[w]; dest[2*w+1] = src2[w]; } #endif dest += dstStride; src1 += src1Stride; src2 += src2Stride; } #ifdef HAVE_MMX asm( EMMS" \n\t" SFENCE" \n\t" ::: "memory" ); #endif }
1threat
C - Trying to do bubble sort : I think this is C. but trying to figure out why my bubble sort isn't working. I was following an existing example so perhaps my integration with this code isn't right but not too sure. #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { if (argc != 2) { printf("%s <student-id>\n", argv[0]); exit(0); } int i; int size = 10000; int seed = atoi(argv[1]); srand(seed % 4); int *int_array = malloc(sizeof(int)*size); for (i = 0; i < size; i++) { int_array[i] = rand(); } // This part int j; for (i = 0; i < size; i += 1) { for (j = i - 1; j >= 0 && int_array[j] > int_array[j + 1]; j+= 1) { swap(int_array,j); } ] int failed = 0; for (i = 0; i < size; i++) { if (int_array[i] < int_array[i+1]) { failed = 1; break; } } free(int_array); return 0; }
0debug
NLTK: corpus-level bleu vs sentence-level BLEU score : <p>I have imported nltk in python to calculate BLEU Score on Ubuntu. I understand how sentence-level BLEU score works, but I don't understand how corpus-level BLEU score work.</p> <p>Below is my code for corpus-level BLEU score:</p> <pre><code>import nltk hypothesis = ['This', 'is', 'cat'] reference = ['This', 'is', 'a', 'cat'] BLEUscore = nltk.translate.bleu_score.corpus_bleu([reference], [hypothesis], weights = [1]) print(BLEUscore) </code></pre> <p>For some reason, the bleu score is 0 for the above code. I was expecting a corpus-level BLEU score of at least 0.5.</p> <p>Here is my code for sentence-level BLEU score</p> <pre><code>import nltk hypothesis = ['This', 'is', 'cat'] reference = ['This', 'is', 'a', 'cat'] BLEUscore = nltk.translate.bleu_score.sentence_bleu([reference], hypothesis, weights = [1]) print(BLEUscore) </code></pre> <p>Here the sentence-level BLEU score is 0.71 which I expect, taking into account the brevity-penalty and the missing word "a". However, I don't understand how corpus-level BLEU score work.</p> <p>Any help would be appreciated.</p>
0debug
static inline int RENAME(yuv420_rgb32)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ int y, h_size; if(c->srcFormat == PIX_FMT_YUV422P){ srcStride[1] *= 2; srcStride[2] *= 2; } h_size= (c->dstW+7)&~7; if(h_size*4 > FFABS(dstStride[0])) h_size-=8; __asm__ __volatile__ ("pxor %mm4, %mm4;" ); for (y= 0; y<srcSliceH; y++ ) { uint8_t *_image = dst[0] + (y+srcSliceY)*dstStride[0]; uint8_t *_py = src[0] + y*srcStride[0]; uint8_t *_pu = src[1] + (y>>1)*srcStride[1]; uint8_t *_pv = src[2] + (y>>1)*srcStride[2]; long index= -h_size/2; __asm__ __volatile__ ( "movd (%2, %0), %%mm0;" "movd (%3, %0), %%mm1;" "movq (%5, %0, 2), %%mm6;" "1: \n\t" YUV2RGB "pxor %%mm3, %%mm3;" "movq %%mm0, %%mm6;" "movq %%mm1, %%mm7;" "movq %%mm0, %%mm4;" "movq %%mm1, %%mm5;" "punpcklbw %%mm2, %%mm6;" "punpcklbw %%mm3, %%mm7;" "punpcklwd %%mm7, %%mm6;" MOVNTQ " %%mm6, (%1);" "movq %%mm0, %%mm6;" "punpcklbw %%mm2, %%mm6;" "punpckhwd %%mm7, %%mm6;" MOVNTQ " %%mm6, 8 (%1);" "punpckhbw %%mm2, %%mm4;" "punpckhbw %%mm3, %%mm5;" "punpcklwd %%mm5, %%mm4;" MOVNTQ " %%mm4, 16 (%1);" "movq %%mm0, %%mm4;" "punpckhbw %%mm2, %%mm4;" "punpckhwd %%mm5, %%mm4;" MOVNTQ " %%mm4, 24 (%1);" "movd 4 (%2, %0), %%mm0;" "movd 4 (%3, %0), %%mm1;" "pxor %%mm4, %%mm4;" "movq 8 (%5, %0, 2), %%mm6;" "add $32, %1 \n\t" "add $4, %0 \n\t" " js 1b \n\t" : "+r" (index), "+r" (_image) : "r" (_pu - index), "r" (_pv - index), "r"(&c->redDither), "r" (_py - 2*index) ); } __asm__ __volatile__ (EMMS); return srcSliceH; }
1threat
static OSStatus ffat_decode_callback(AudioConverterRef converter, UInt32 *nb_packets, AudioBufferList *data, AudioStreamPacketDescription **packets, void *inctx) { AVCodecContext *avctx = inctx; ATDecodeContext *at = avctx->priv_data; if (at->eof) { *nb_packets = 0; if (packets) { *packets = &at->pkt_desc; at->pkt_desc.mDataByteSize = 0; } return 0; } av_packet_move_ref(&at->in_pkt, &at->new_in_pkt); at->new_in_pkt.data = 0; at->new_in_pkt.size = 0; if (!at->in_pkt.data) { *nb_packets = 0; return 1; } data->mNumberBuffers = 1; data->mBuffers[0].mNumberChannels = 0; data->mBuffers[0].mDataByteSize = at->in_pkt.size; data->mBuffers[0].mData = at->in_pkt.data; *nb_packets = 1; if (packets) { *packets = &at->pkt_desc; at->pkt_desc.mDataByteSize = at->in_pkt.size; } return 0; }
1threat
Ho to convert CSV file into SQL file easily? : <p>I want to convert the data in a CSV file into SQL queries. What is the easiest and the fastest method to convert a CSV into an SQL file?</p>
0debug
Is it possible to map only a portion of an array? (Array.map()) : <p>I am building a project using React.js as a front-end framework. On one particular page I am displaying a full data set to the user. I have an Array which contains this full data set. It is an array of JSON objects. In terms of presenting this data to the user, I currently have it displaying the whole data set by returning each item of data using Array.map().</p> <p>This is a step in the right direction, but now I need to display only a portion of the data-set, not the whole thing, I also want some control in terms of knowing how much of the total data set has been displayed, and how much of the data set is yet to be displayed. Basically I am building something like a "view more" button that loads more items of data to the user. </p> <p>Here is what I am using now where 'feed' represents my Array of JSON objects. (this displays the whole data set.)</p> <pre><code> return ( &lt;div className={feedClass}&gt; { feed.map((item, index) =&gt; { return &lt;FeedItem key={index} data={item}/&gt; }) } &lt;/div&gt; ); </code></pre> <p>I am wondering if it is possible to use .map() on only a portion of the array without having to break up the array before hand? I know that a possible solution would be to hold the full data set, and break it off into portions, and then .map() those portions, but is there a way to .map() a portion of the array without having to break it up?</p> <p>Any and all feedback is appreciated. Thanks!</p>
0debug
How can I combine each string together from two or more lists of strings? : <p>What I am trying to do is say I have a List of Lists of string where the lists are...</p> <pre><code>list1 = "A", "B", "C" list2 = "1", "2", "3" list3 = "Dog" ... </code></pre> <p>then I get a list with </p> <pre><code> newList = "A1Dog", "A2Dog", "A3Dog", "B1Dog", "B2Dog", "B3Dog", "C1Dog", "C2Dog", "C3Dog" </code></pre> <p>Is there a way to do this with LINQ or is there a better way to do it?</p>
0debug
Python: Cannot uninstall 'six' while pip install tld : <pre><code>$ pip install tld Collecting tld Using cached https://files.pythonhosted.org/packages/fa/78/dbeaeb20db795c42deb81271fd65a35c040ce2e946024eaeef5c6b184176/tld-0.9-py2.py3-none-any.whl Collecting six&gt;=1.9 (from tld) Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl Installing collected packages: six, tld Found existing installation: six 1.4.1 Cannot uninstall 'six'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall. </code></pre> <p>When installing tld module getting error of cannot uninstall existing 'six' module.</p>
0debug
static void cdg_load_palette(CDGraphicsContext *cc, uint8_t *data, int low) { uint8_t r, g, b; uint16_t color; int i; int array_offset = low ? 0 : 8; uint32_t *palette = (uint32_t *) cc->frame.data[1]; for (i = 0; i < 8; i++) { color = (data[2 * i] << 6) + (data[2 * i + 1] & 0x3F); r = ((color >> 8) & 0x000F) * 17; g = ((color >> 4) & 0x000F) * 17; b = ((color ) & 0x000F) * 17; palette[i + array_offset] = 0xFF << 24 | r << 16 | g << 8 | b; } cc->frame.palette_has_changed = 1; }
1threat
Items collection must be empty before using ItemsSource. : <p>I Have "Items collection must be empty before using ItemsSource." Error In My Code</p> <p>I Test All Answer in StackOverFlow Links But They Did not Work! My Xaml :</p> <pre><code>&lt;Window x:Class="FirstWpfTestApplication.Main" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:FirstWpfTestApplication" xmlns:valConverter="clr-namespace:FirstWpfTestApplication.Model.ValueConverters" mc:Ignorable="d" Title="Main" Height="500" Width="800" WindowStartupLocation="CenterScreen"&gt; &lt;UserControl&gt; &lt;UserControl.Resources&gt; &lt;valConverter:GenderConverter x:Key="GenderConverter"/&gt; &lt;valConverter:EnumList x:Key="EnumConverter"/&gt; &lt;Style TargetType="TextBox"&gt; &lt;Setter Property="MinWidth" Value="100"/&gt; &lt;Setter Property="Margin" Value="5"/&gt; &lt;/Style&gt; &lt;Style TargetType="TextBlock"&gt; &lt;Setter Property="Margin" Value="5"/&gt; &lt;/Style&gt; &lt;Style TargetType="RadioButton"&gt; &lt;Setter Property="Margin" Value="5"/&gt; &lt;/Style&gt; &lt;Style TargetType="CheckBox"&gt; &lt;Setter Property="Margin" Value="5"/&gt; &lt;/Style&gt; &lt;Style TargetType="ComboBox"&gt; &lt;Setter Property="MinWidth" Value="100"/&gt; &lt;/Style&gt; &lt;Style TargetType="Button"&gt; &lt;Setter Property="Margin" Value="5"/&gt; &lt;Setter Property="MinWidth" Value="60"/&gt; &lt;/Style&gt; &lt;/UserControl.Resources&gt; &lt;Grid&gt; &lt;DockPanel&gt; &lt;!--&lt;ListBox Name="lstPeople" DockPanel.Dock="Left"&gt; &lt;DataTemplate&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;TextBlock Text="Name:" Margin="10 0"/&gt; &lt;TextBlock Text="{Binding Name}" Margin="10 0"/&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ListBox&gt;--&gt; &lt;Border BorderThickness="2" BorderBrush="Black" CornerRadius="1"&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="auto"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="auto"/&gt; &lt;RowDefinition Height="auto"/&gt; &lt;RowDefinition Height="auto"/&gt; &lt;RowDefinition Height="auto"/&gt; &lt;RowDefinition Height="auto"/&gt; &lt;/Grid.RowDefinitions&gt; &lt;StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="0" Margin="10"&gt; &lt;TextBlock&gt;Name:&lt;/TextBlock&gt; &lt;TextBox Text="{Binding Name}"&gt;&lt;/TextBox&gt; &lt;/StackPanel&gt; &lt;StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="1" Margin="10"&gt; &lt;TextBlock VerticalAlignment="Center"&gt;Gender:&lt;/TextBlock&gt; &lt;WrapPanel Orientation="Vertical"&gt; &lt;RadioButton IsChecked="{Binding Gender,Converter={StaticResource GenderConverter},ConverterParameter=True}" Name="rdMan"&gt; Man &lt;/RadioButton&gt; &lt;RadioButton IsChecked="{Binding Gender,Converter={StaticResource GenderConverter},ConverterParameter=False}" Name="rdWoman"&gt; WoMan &lt;/RadioButton&gt; &lt;/WrapPanel&gt; &lt;/StackPanel&gt; &lt;StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="2" Margin="10"&gt; &lt;TextBlock&gt;Field Of Work:&lt;/TextBlock&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;CheckBox Name="chActor" IsChecked="{Binding FieldOfWorks,Converter={StaticResource EnumConverter},ConverterParameter=Actor}"&gt; Actor &lt;/CheckBox&gt; &lt;CheckBox Name="chDirector" IsChecked="{Binding FieldOfWorks,Converter={StaticResource EnumConverter},ConverterParameter=Director}"&gt; Director &lt;/CheckBox&gt; &lt;CheckBox Name="chProducer" IsChecked="{Binding FieldOfWorks,Converter={StaticResource EnumConverter},ConverterParameter=Producer}"&gt; Producer &lt;/CheckBox&gt; &lt;/StackPanel&gt; &lt;/StackPanel&gt; &lt;StackPanel Grid.Row="3" Orientation="Horizontal"&gt; &lt;TextBlock&gt;Country:&lt;/TextBlock&gt; &lt;ComboBox Name="cbCountries"&gt; &lt;DataTemplate&gt; &lt;TextBlock Text="{Binding Name}"/&gt; &lt;/DataTemplate&gt; &lt;/ComboBox&gt; &lt;/StackPanel&gt; &lt;StackPanel Margin="0 10" HorizontalAlignment="Left" Orientation="Horizontal" Grid.Row="4"&gt; &lt;Button&gt;Save&lt;/Button&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; &lt;/Border&gt; &lt;/DockPanel&gt; &lt;/Grid&gt; &lt;/UserControl&gt; </code></pre> <p></p> <p>And My C# Code:</p> <pre><code> public partial class Main : Window { public List&lt;People&gt; PeopleContext; public Main() { InitializeComponent(); this.DataContext = People.GetPeople(); cbCountries.ItemsSource = new Country().GetCountries();//In This Line Exception Will Throw } } </code></pre> <p>Please Help To Fix This Problem In WPF</p>
0debug
RUBY: How to read an array from a file and store it in an array : I am trying to read an array from a file and save it in myArray[]. Ex File1.txt is ["abc", "def"...] I want to be able to parse myArray[0] which is "abc", myArray[1] which is "def" and so on..How do I do it in Ruby?
0debug
How to record a video in Selenium webdriver and Java API : <p>I have automated scripts that run every night (around 50 scripts or testcases). I want to record a video of each test case (Selenium Java API + Cucumber). Is there any tool or way that i can use to control video recording for each test case separately? I want during a test case setup start recording and during teardown stop recording and save the video locally with a specified name and date. So I should have 50 videos for each testcase (more preferably save only videos for the failed test cases)</p> <p>Is there a way of integrating this functionality in the code I use for my setups and teardowns?</p>
0debug
socket_sockaddr_to_address_inet(struct sockaddr_storage *sa, socklen_t salen, Error **errp) { char host[NI_MAXHOST]; char serv[NI_MAXSERV]; SocketAddressLegacy *addr; InetSocketAddress *inet; int ret; ret = getnameinfo((struct sockaddr *)sa, salen, host, sizeof(host), serv, sizeof(serv), NI_NUMERICHOST | NI_NUMERICSERV); if (ret != 0) { error_setg(errp, "Cannot format numeric socket address: %s", gai_strerror(ret)); return NULL; } addr = g_new0(SocketAddressLegacy, 1); addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET; inet = addr->u.inet.data = g_new0(InetSocketAddress, 1); inet->host = g_strdup(host); inet->port = g_strdup(serv); if (sa->ss_family == AF_INET) { inet->has_ipv4 = inet->ipv4 = true; } else { inet->has_ipv6 = inet->ipv6 = true; } return addr; }
1threat
static void pmuserenr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { env->cp15.c9_pmuserenr = value & 1; }
1threat
static int vqa_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; VqaContext *s = avctx->priv_data; s->buf = buf; s->size = buf_size; if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); if (avctx->get_buffer(avctx, &s->frame)) { av_log(s->avctx, AV_LOG_ERROR, " VQA Video: get_buffer() failed\n"); return -1; } vqa_decode_chunk(s); memcpy(s->frame.data[1], s->palette, PALETTE_COUNT * 4); s->frame.palette_has_changed = 1; *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; return buf_size; }
1threat
How to verify users current password? : <p>So, maybe I missed this somewhere in the docs but I couldn't find anything of the sort. </p> <p>I wan't my users to have to type in their current password to be able to create a new one. From what I understand if the user is authenticated he is able to update his password without providing his current one. </p> <p>Even if this might be somewhat secure I would rather have him type his old one to prevent people from going on already authenticated sessions from say family members or so and changing the pw. </p> <p>Is there any way to do this?</p> <p>(I have no problem using the Admin SDK since I already set up a server for these kind of things)</p>
0debug
Detached HEAD Issue in Android Studio : <p>I am new to Android Studio and have began developing a Navigation Drawer app.</p> <p>After having made a mistake in a commit, I played around with the Version control's "Checkout Revision" and now I can no longer push my project onto Github due to a "Detached HEAD".</p> <p>How can I fix this problem? My app runs perfectly fine in the emulator.</p> <p>Thanks</p>
0debug
html css absolute position overlay problem : I got 2 blocks, top and bottom. Bottom block has: position: absolute; bottom: 0 styles. In bottom block there is an image that should overlay top block in one place. it overlays Ok but I can't click on element from top block cause browser think i click on bottom. How can it be resolved? Maybe z-index or something else?
0debug
How to play streaming audio using pyglet? : <p>The goal of this question is trying to figure out how to play streaming audio using pyglet. The first is just making sure you're able to play mp3 files using pyglet, that's the purpose of this first snippet:</p> <pre><code>import sys import inspect import requests import pyglet from pyglet.media import * pyglet.lib.load_library('avbin') pyglet.have_avbin = True def url_to_filename(url): return url.split('/')[-1] def download_file(url, filename=None): filename = filename or url_to_filename(url) with open(filename, "wb") as f: print("Downloading %s" % filename) response = requests.get(url, stream=True) total_length = response.headers.get('content-length') if total_length is None: f.write(response.content) else: dl = 0 total_length = int(total_length) for data in response.iter_content(chunk_size=4096): dl += len(data) f.write(data) done = int(50 * dl / total_length) sys.stdout.write("\r[%s%s]" % ('=' * done, ' ' * (50 - done))) sys.stdout.flush() url = "https://freemusicarchive.org/file/music/ccCommunity/DASK/Abiogenesis/DASK_-_08_-_Protocell.mp3" filename = "mcve.mp3" download_file(url, filename) music = pyglet.media.load(filename) music.play() pyglet.app.run() </code></pre> <p>If you've installed the libraries <code>pip install pyglet requests</code> and also installed <a href="https://avbin.github.io/AVbin/Download.html" rel="noreferrer">AVBin</a> at this point you should be able to listen the mp3 once it's been downloaded.</p> <p>Once we've reached this point, I'd like to figure out how to play &amp; buffering the file in a similar way to mostly of the existing web video/audio players using pyglet+requests. This means playing the files without waiting till the file has been downloaded completely.</p> <p>After reading the pyglet media <a href="http://pyglet.readthedocs.io/en/pyglet-1.3-maintenance/modules/media.html#classes" rel="noreferrer">docs</a> you can see there are available these classes:</p> <pre><code>media sources base AudioData AudioFormat Source SourceGroup SourceInfo StaticSource StreamingSource VideoFormat player Player PlayerGroup </code></pre> <p>I've seen there are another similar SO questions but they haven't been solved properly and their content doesn't provide a lot of relevant details:</p> <ul> <li><a href="https://stackoverflow.com/questions/11344548/play-streaming-audio-using-pyglet">Play streaming audio using pyglet</a></li> <li><a href="https://stackoverflow.com/questions/45842385/how-can-i-play-audio-stream-without-saving-it-into-the-file-with-pyglet">How can I play audio stream without saving it into the file with pyglet?</a></li> </ul> <p>That's why I've created a new question. How do you play streaming audio using pyglet? Could you provide a little example using the above mcve as a base?</p>
0debug
float32 float32_scalbn( float32 a, int n STATUS_PARAM ) { flag aSign; int16 aExp; uint32_t aSig; a = float32_squash_input_denormal(a STATUS_VAR); aSig = extractFloat32Frac( a ); aExp = extractFloat32Exp( a ); aSign = extractFloat32Sign( a ); if ( aExp == 0xFF ) { return a; } if ( aExp != 0 ) aSig |= 0x00800000; else if ( aSig == 0 ) return a; aExp += n - 1; aSig <<= 7; return normalizeRoundAndPackFloat32( aSign, aExp, aSig STATUS_VAR ); }
1threat
C# Overloaded Method does not use int imput : I'm trying to create console app to understand method overloading. I got Class lib like this namespace GetStringName { public class GetString { public void Player(double num) { double number = num * 2; Console.Write(number); } public void Player(string name) { char[] charr = name.ToCharArray(); Array.Reverse(charr); Console.Write(charr); } } } And I got my Console app like below using GetStringName; using System; namespace ConsoleApp1 { class Program { static void Main(string[] args) { GetString y = new GetString(); y.Player(Console.ReadLine()); Console.ReadLine(); } } } And whatever I type (string or integer) it always does the revert string thing. Can you please tell me what I'm doing wrong?
0debug
Is it true that the dimension of an array is determined the moment the array is created, and cannot be changed later on? : <pre><code>int main() { int a[3]={1,2,3}; int *b; b=&amp;a[10]; printf("%u\n",b); printf("%d",*b); } </code></pre> <p>I thought that the above program would give me an <strong>error</strong> as <code>a</code> is a collection of only <em>3 data items</em>, and <code>b=&amp;a[10];</code> by this <code>b</code> stored the address of the <em>11th data member</em> of <code>a</code>. But in place of error it gives the address of 11th data member.</p> <p>Size of the array is 3 and but it can store the variables beyond of its size! so how does it possible?</p>
0debug
what is the regular expressions in "R" that find all words that: Start with a letter1 and End with another letter2? : i'm trying to work out the exercise from a book called "R for data science" on regular expressions. there's this question which i'm unable to solve : 1.Given the corpus of common words in stringr::words, create regular expressions that find all words that: 1.Start with “y”. 2.End with “x” 3.Have seven letters or more. example : sentence <- "i want to extract these - yandx,ynx and yrax,romanav " #it would be helpful to find how to do these with stringr::str_view() function. also please suggest me some good resources to refer for learning regex in r .
0debug
Multiple And condition in Where Clause in Sql : I have a table like this ID Process Work A1 | 0 | Done A1 | 1 | Progress A2 | 0 | Done A2 | 1 | Done A2 | 2 | Progress A3 | 0 | Done A3 | 1 | Done A3 | 2 | Progress I need to output ID of only that work whose Process=0 and Work=Done and if Process>0 and Work=Progress. Hence in this case it will output only A1 since for Process>0 A2 and A3 have Work=Done. How do I use multiple And statements in where condition?
0debug
void event_notifier_init_fd(EventNotifier *e, int fd) { e->fd = fd; }
1threat
Trying to creat my first class, getting object has no attribute file error : I'm trying to teach myself object programming in python. I want my verbals to be just for that instance of the object, which I thought was done by using self.verbalname. Right now I getting a error for every line that has self.file in it saying OBJECT HAS NO ATTRIBUTE FILE exanple in def open(self): # open file self.file = open(self.filename,"r",1); I get the error message CODE class spreedsheet(object): def __init__(self, name): self.filename = name def getFileName(self): print(self.filename) def open(self): # open file THIS LINE GIVES ME A ERROR SAYING OBJECT HAS NO ATTRIBUTE FILE self.file = open(self.filename,"r",1); def close(self): # close file THIS LINE GIVES ME A ERROR SAYING OBJECT HAS NO ATTRIBUTE FILE self.file.close(); def addString(self,add): # add a string to a line of the spreed sheet THIS LINE GIVES ME A ERROR SAYING FILE DOES NOT EXIST self.file.write(add) self.write(",") def addStringRet(self,name): # add a string to a line of the spreed sheet THIS LINE GIVES ME A ERROR SAYING FILE DOES NOT EXIST self.file.write(add) self.write("\r\n") # Add a new string and start a new col myobject = spreedsheet("agraphdata.txt") myobject.addString("tedt") myobject.close()
0debug
static int RENAME(swScale)(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]) { const int srcW= c->srcW; const int dstW= c->dstW; const int dstH= c->dstH; const int chrDstW= c->chrDstW; const int chrSrcW= c->chrSrcW; const int lumXInc= c->lumXInc; const int chrXInc= c->chrXInc; const enum PixelFormat dstFormat= c->dstFormat; const int flags= c->flags; int16_t *vLumFilterPos= c->vLumFilterPos; int16_t *vChrFilterPos= c->vChrFilterPos; int16_t *hLumFilterPos= c->hLumFilterPos; int16_t *hChrFilterPos= c->hChrFilterPos; int16_t *vLumFilter= c->vLumFilter; int16_t *vChrFilter= c->vChrFilter; int16_t *hLumFilter= c->hLumFilter; int16_t *hChrFilter= c->hChrFilter; int32_t *lumMmxFilter= c->lumMmxFilter; int32_t *chrMmxFilter= c->chrMmxFilter; int32_t av_unused *alpMmxFilter= c->alpMmxFilter; const int vLumFilterSize= c->vLumFilterSize; const int vChrFilterSize= c->vChrFilterSize; const int hLumFilterSize= c->hLumFilterSize; const int hChrFilterSize= c->hChrFilterSize; int16_t **lumPixBuf= c->lumPixBuf; int16_t **chrPixBuf= c->chrPixBuf; int16_t **alpPixBuf= c->alpPixBuf; const int vLumBufSize= c->vLumBufSize; const int vChrBufSize= c->vChrBufSize; uint8_t *formatConvBuffer= c->formatConvBuffer; const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample; const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample); int lastDstY; uint32_t *pal=c->pal_yuv; int dstY= c->dstY; int lumBufIndex= c->lumBufIndex; int chrBufIndex= c->chrBufIndex; int lastInLumBuf= c->lastInLumBuf; int lastInChrBuf= c->lastInChrBuf; if (isPacked(c->srcFormat)) { src[0]= src[1]= src[2]= src[3]= src[0]; srcStride[0]= srcStride[1]= srcStride[2]= srcStride[3]= srcStride[0]; } srcStride[1]<<= c->vChrDrop; srcStride[2]<<= c->vChrDrop; DEBUG_BUFFERS("swScale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n", src[0], srcStride[0], src[1], srcStride[1], src[2], srcStride[2], src[3], srcStride[3], dst[0], dstStride[0], dst[1], dstStride[1], dst[2], dstStride[2], dst[3], dstStride[3]); DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d dstY: %d dstH: %d\n", srcSliceY, srcSliceH, dstY, dstH); DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize: %d vChrBufSize: %d\n", vLumFilterSize, vLumBufSize, vChrFilterSize, vChrBufSize); if (dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0 || dstStride[3]%8 != 0) { static int warnedAlready=0; if (flags & SWS_PRINT_INFO && !warnedAlready) { av_log(c, AV_LOG_WARNING, "Warning: dstStride is not aligned!\n" " ->cannot do aligned memory accesses anymore\n"); warnedAlready=1; } } if (srcSliceY ==0) { lumBufIndex=-1; chrBufIndex=-1; dstY=0; lastInLumBuf= -1; lastInChrBuf= -1; } lastDstY= dstY; for (;dstY < dstH; dstY++) { unsigned char *dest =dst[0]+dstStride[0]*dstY; const int chrDstY= dstY>>c->chrDstVSubSample; unsigned char *uDest=dst[1]+dstStride[1]*chrDstY; unsigned char *vDest=dst[2]+dstStride[2]*chrDstY; unsigned char *aDest=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3]+dstStride[3]*dstY : NULL; const int firstLumSrcY= vLumFilterPos[dstY]; const int firstLumSrcY2= vLumFilterPos[FFMIN(dstY | ((1<<c->chrDstVSubSample) - 1), dstH-1)]; const int firstChrSrcY= vChrFilterPos[chrDstY]; int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; int lastLumSrcY2=firstLumSrcY2+ vLumFilterSize -1; int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; int enough_lines; if (firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1; if (firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1; assert(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1); assert(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1); DEBUG_BUFFERS("dstY: %d\n", dstY); DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n", firstLumSrcY, lastLumSrcY, lastInLumBuf); DEBUG_BUFFERS("\tfirstChrSrcY: %d lastChrSrcY: %d lastInChrBuf: %d\n", firstChrSrcY, lastChrSrcY, lastInChrBuf); enough_lines = lastLumSrcY2 < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample); if (!enough_lines) { lastLumSrcY = srcSliceY + srcSliceH - 1; lastChrSrcY = chrSrcSliceY + chrSrcSliceH - 1; DEBUG_BUFFERS("buffering slice: lastLumSrcY %d lastChrSrcY %d\n", lastLumSrcY, lastChrSrcY); } while(lastInLumBuf < lastLumSrcY) { const uint8_t *src1= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0]; const uint8_t *src2= src[3]+(lastInLumBuf + 1 - srcSliceY)*srcStride[3]; lumBufIndex++; assert(lumBufIndex < 2*vLumBufSize); assert(lastInLumBuf + 1 - srcSliceY < srcSliceH); assert(lastInLumBuf + 1 - srcSliceY >= 0); RENAME(hyscale)(c, lumPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize, formatConvBuffer, pal, 0); if (CONFIG_SWSCALE_ALPHA && alpPixBuf) RENAME(hyscale)(c, alpPixBuf[ lumBufIndex ], dstW, src2, srcW, lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize, formatConvBuffer, pal, 1); lastInLumBuf++; DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n", lumBufIndex, lastInLumBuf); } while(lastInChrBuf < lastChrSrcY) { const uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1]; const uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2]; chrBufIndex++; assert(chrBufIndex < 2*vChrBufSize); assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH)); assert(lastInChrBuf + 1 - chrSrcSliceY >= 0); if (c->needs_hcscale) RENAME(hcscale)(c, chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc, hChrFilter, hChrFilterPos, hChrFilterSize, formatConvBuffer, pal); lastInChrBuf++; DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n", chrBufIndex, lastInChrBuf); } if (lumBufIndex >= vLumBufSize) lumBufIndex-= vLumBufSize; if (chrBufIndex >= vChrBufSize) chrBufIndex-= vChrBufSize; if (!enough_lines) break; #if COMPILE_TEMPLATE_MMX c->blueDither= ff_dither8[dstY&1]; if (c->dstFormat == PIX_FMT_RGB555 || c->dstFormat == PIX_FMT_BGR555) c->greenDither= ff_dither8[dstY&1]; else c->greenDither= ff_dither4[dstY&1]; c->redDither= ff_dither8[(dstY+1)&1]; #endif if (dstY < dstH-2) { const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; const int16_t **chrSrcPtr= (const int16_t **) chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL; #if COMPILE_TEMPLATE_MMX int i; if (flags & SWS_ACCURATE_RND) { int s= APCK_SIZE / 8; for (i=0; i<vLumFilterSize; i+=2) { *(const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ]; *(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)]; lumMmxFilter[s*i+APCK_COEF/4 ]= lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ] + (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0); if (CONFIG_SWSCALE_ALPHA && alpPixBuf) { *(const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ]; *(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)]; alpMmxFilter[s*i+APCK_COEF/4 ]= alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ]; } } for (i=0; i<vChrFilterSize; i+=2) { *(const void**)&chrMmxFilter[s*i ]= chrSrcPtr[i ]; *(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrSrcPtr[i+(vChrFilterSize>1)]; chrMmxFilter[s*i+APCK_COEF/4 ]= chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ] + (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0); } } else { for (i=0; i<vLumFilterSize; i++) { lumMmxFilter[4*i+0]= (int32_t)lumSrcPtr[i]; lumMmxFilter[4*i+1]= (uint64_t)lumSrcPtr[i] >> 32; lumMmxFilter[4*i+2]= lumMmxFilter[4*i+3]= ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001; if (CONFIG_SWSCALE_ALPHA && alpPixBuf) { alpMmxFilter[4*i+0]= (int32_t)alpSrcPtr[i]; alpMmxFilter[4*i+1]= (uint64_t)alpSrcPtr[i] >> 32; alpMmxFilter[4*i+2]= alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2]; } } for (i=0; i<vChrFilterSize; i++) { chrMmxFilter[4*i+0]= (int32_t)chrSrcPtr[i]; chrMmxFilter[4*i+1]= (uint64_t)chrSrcPtr[i] >> 32; chrMmxFilter[4*i+2]= chrMmxFilter[4*i+3]= ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001; } } #endif if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) { const int chrSkipMask= (1<<c->chrDstVSubSample)-1; if (dstY&chrSkipMask) uDest= NULL; c->yuv2nv12X(c, vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, dest, uDest, dstW, chrDstW, dstFormat); } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { const int chrSkipMask= (1<<c->chrDstVSubSample)-1; if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; if (is16BPS(dstFormat) || isNBPS(dstFormat)) { yuv2yuvX16inC( vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, (uint16_t *) dest, (uint16_t *) uDest, (uint16_t *) vDest, (uint16_t *) aDest, dstW, chrDstW, dstFormat); } else if (vLumFilterSize == 1 && vChrFilterSize == 1) { const int16_t *lumBuf = lumSrcPtr[0]; const int16_t *chrBuf= chrSrcPtr[0]; const int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpSrcPtr[0] : NULL; c->yuv2yuv1(c, lumBuf, chrBuf, alpBuf, dest, uDest, vDest, aDest, dstW, chrDstW); } else { c->yuv2yuvX(c, vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW); } } else { assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); assert(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2); if (vLumFilterSize == 1 && vChrFilterSize == 2) { int chrAlpha= vChrFilter[2*dstY+1]; if(flags & SWS_FULL_CHR_H_INT) { yuv2rgbXinC_full(c, vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, dest, dstW, dstY); } else { c->yuv2packed1(c, *lumSrcPtr, *chrSrcPtr, *(chrSrcPtr+1), alpPixBuf ? *alpSrcPtr : NULL, dest, dstW, chrAlpha, dstFormat, flags, dstY); } } else if (vLumFilterSize == 2 && vChrFilterSize == 2) { int lumAlpha= vLumFilter[2*dstY+1]; int chrAlpha= vChrFilter[2*dstY+1]; lumMmxFilter[2]= lumMmxFilter[3]= vLumFilter[2*dstY ]*0x10001; chrMmxFilter[2]= chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001; if(flags & SWS_FULL_CHR_H_INT) { yuv2rgbXinC_full(c, vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, dest, dstW, dstY); } else { c->yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrSrcPtr, *(chrSrcPtr+1), alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL, dest, dstW, lumAlpha, chrAlpha, dstY); } } else { if(flags & SWS_FULL_CHR_H_INT) { yuv2rgbXinC_full(c, vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, dest, dstW, dstY); } else { c->yuv2packedX(c, vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, dest, dstW, dstY); } } } } else { const int16_t **lumSrcPtr= (const int16_t **)lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; const int16_t **chrSrcPtr= (const int16_t **)chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **)alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL; if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) { const int chrSkipMask= (1<<c->chrDstVSubSample)-1; if (dstY&chrSkipMask) uDest= NULL; yuv2nv12XinC( vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, dest, uDest, dstW, chrDstW, dstFormat); } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { const int chrSkipMask= (1<<c->chrDstVSubSample)-1; if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; if (is16BPS(dstFormat) || isNBPS(dstFormat)) { yuv2yuvX16inC( vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, (uint16_t *) dest, (uint16_t *) uDest, (uint16_t *) vDest, (uint16_t *) aDest, dstW, chrDstW, dstFormat); } else { yuv2yuvXinC( vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW); } } else { assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); assert(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2); if(flags & SWS_FULL_CHR_H_INT) { yuv2rgbXinC_full(c, vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, dest, dstW, dstY); } else { yuv2packedXinC(c, vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, alpSrcPtr, dest, dstW, dstY); } } } } if ((dstFormat == PIX_FMT_YUVA420P) && !alpPixBuf) fillPlane(dst[3], dstStride[3], dstW, dstY-lastDstY, lastDstY, 255); #if COMPILE_TEMPLATE_MMX if (flags & SWS_CPU_CAPS_MMX2 ) __asm__ volatile("sfence":::"memory"); if (flags & SWS_CPU_CAPS_3DNOW) __asm__ volatile("femms" :::"memory"); else __asm__ volatile("emms" :::"memory"); #endif c->dstY= dstY; c->lumBufIndex= lumBufIndex; c->chrBufIndex= chrBufIndex; c->lastInLumBuf= lastInLumBuf; c->lastInChrBuf= lastInChrBuf; return dstY - lastDstY; }
1threat
javafx-how to sum up arrayed choiceBox<integer> value : Please I need help ,I think I wrote my java code well but am still getting expection error This is the code : All procedures met,let me go straight to the portion of the code with problem. Int sumofc = 0; VBox vlay = new VBox(10); ChoiceBox<Integer> c1[] = new ChoiceBox[10] For (int x=0;x<10;x++){ c1[x] = new ChoiceBox<>(); C1[x].getItems().add(1); C1[x].getItems().add(2); C1[x].getItems().add(3); Vlay.getChildren().add(c1[x]); sumofc += c1[x].getValue(); } The sumofc is not adding the values
0debug
divide a string into two halves in python : <p>this is my question:</p> <pre><code>F. front_back # Consider dividing a string into two halves. # If the length is even, the front and back halves are the same length. # If the length is odd, we'll say that the extra char goes in the front half. # e.g. 'abcde', the front half is 'abc', the back half 'de'. # Given 2 strings, a and b, return a string of the form # a-front + b-front + a-back + b-back </code></pre> <p>and this is my answer:</p> <pre><code>def front_back(a, b): s = "" if len(a) % 2 == 0: s = s + a[:len(a) / 2] if len(b) % 2 == 0: s = s + b[:len(b) / 2] s = s + a[len(a) / 2:] s = s + b[len(b) / 2:] else: s = s + b[:len(b) / 2 + 1] s = s + a[len(a) / 2 + 1:] s = s + b[len(b) / 2 + 1:] else: s = s + a[:len(a) / 2 + 1] if len(b) % 2 == 0: s = s + b[:len(b) / 2] s = s + a[len(a) / 2:] s = s + b[len(b) / 2:] else: s = s + b[:len(b) / 2 + 1] s = s + a[len(a) / 2 + 1:] s = s + b[len(b) / 2 + 1:] return s </code></pre> <p>this answer isn't work on all strings and i don't understand what is the problem.</p>
0debug