problem
stringlengths
26
131k
labels
class label
2 classes
how do if fix the NullPointerException on an arrylist? : <p>how do if fix the Exception in thread "main" java.lang.NullPointerException at BankSystem.Branches.findCustomer(Branches.java:44) I'm new to coding and java is my first language and I keep getting this error I don't know to fix it.</p> <pre><code>package BankSystem; import java.util.ArrayList; public class Branches { private String name; private ArrayList&lt;Customers&gt; newCustomer; public Branches(){ } public Branches(String name) { this.name = name; this.newCustomer = new ArrayList&lt;&gt;(); } public ArrayList&lt;Customers&gt; getNewCustomer(){ return newCustomer; } public String getName() { return name; } public boolean addCustomer(String name, double amount) { if (findCustomer(name) == null) { this.newCustomer.add(new Customers(name, amount)); return true; } return false; } public boolean addTranstraction(String name, Double amount) { Customers existingCustomer = findCustomer(name); if (existingCustomer != null) { existingCustomer.addTransactions(amount); return true; } return false; } private Customers findCustomer(String name) { for(int i=0; i&lt;this.newCustomer.size(); i++){ Customers checkedCustomer = this.newCustomer.get(i); if(checkedCustomer.getName().equals(name)) { return checkedCustomer; } } return null; } </code></pre> <p>}</p>
0debug
uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) { uint32_t mask; unsigned el = arm_current_el(env); switch (reg) { case 0 ... 7: mask = 0; if ((reg & 1) && el) { mask |= XPSR_EXCP; } if (!(reg & 4)) { mask |= XPSR_NZCV | XPSR_Q; } return xpsr_read(env) & mask; break; case 20: return env->v7m.control; } if (el == 0) { return 0; } switch (reg) { case 8: return (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) ? env->v7m.other_sp : env->regs[13]; case 9: return (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) ? env->regs[13] : env->v7m.other_sp; case 16: return env->v7m.primask[env->v7m.secure]; case 17: case 18: return env->v7m.basepri[env->v7m.secure]; case 19: return env->v7m.faultmask[env->v7m.secure]; default: qemu_log_mask(LOG_GUEST_ERROR, "Attempt to read unknown special" " register %d\n", reg); return 0; } }
1threat
How to get string and two integer input in same line : string N M where N M is index value . i want this input in same line i have tried input().split() but it dsnt works alphabets = input().split() ## what to do next
0debug
selecting an icon using query selector : <p>I found this code online a couple weeks ago. and what it does is, it selects the like button icon under a youtube video and then clicks on it.</p> <pre><code>likeButton = document.querySelector('#icon[alt^="like this"]').parentNode.parentNode.parentNode likeButton.click(); </code></pre> <p>recently, youtube changed their UI and i'm assuming their code changed, so this doesn't work anymore, I was also dumb enough to never understand and research the code.</p> <p>I was wondering if someone could help me understand this part <code>'#icon[alt^="like this"]'</code>,</p> <p>what does the <code>alt^=</code> mean and where would I go looking for the icon name "like this"</p> <p>thanks for your help</p>
0debug
static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) { AVCodecContext *avctx = s->avctx; Mpeg1Context *s1 = (Mpeg1Context *) s; int ret; if (s->picture_structure == PICT_FRAME) s->first_field = 0; else s->first_field ^= 1; if (s->first_field || s->picture_structure == PICT_FRAME) { AVFrameSideData *pan_scan; if ((ret = ff_mpv_frame_start(s, avctx)) < 0) return ret; ff_mpeg_er_frame_start(s); s->current_picture_ptr->f->repeat_pict = 0; if (s->repeat_first_field) { if (s->progressive_sequence) { if (s->top_field_first) s->current_picture_ptr->f->repeat_pict = 4; else s->current_picture_ptr->f->repeat_pict = 2; } else if (s->progressive_frame) { s->current_picture_ptr->f->repeat_pict = 1; } } pan_scan = av_frame_new_side_data(s->current_picture_ptr->f, AV_FRAME_DATA_PANSCAN, sizeof(s1->pan_scan)); if (!pan_scan) return AVERROR(ENOMEM); memcpy(pan_scan->data, &s1->pan_scan, sizeof(s1->pan_scan)); if (s1->a53_caption) { AVFrameSideData *sd = av_frame_new_side_data( s->current_picture_ptr->f, AV_FRAME_DATA_A53_CC, s1->a53_caption_size); if (sd) memcpy(sd->data, s1->a53_caption, s1->a53_caption_size); av_freep(&s1->a53_caption); } if (s1->has_stereo3d) { AVStereo3D *stereo = av_stereo3d_create_side_data(s->current_picture_ptr->f); if (!stereo) return AVERROR(ENOMEM); *stereo = s1->stereo3d; s1->has_stereo3d = 0; } if (s1->has_afd) { AVFrameSideData *sd = av_frame_new_side_data(s->current_picture_ptr->f, AV_FRAME_DATA_AFD, 1); if (!sd) return AVERROR(ENOMEM); *sd->data = s1->afd; s1->has_afd = 0; } if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME)) ff_thread_finish_setup(avctx); } else { int i; if (!s->current_picture_ptr) { av_log(s->avctx, AV_LOG_ERROR, "first field missing\n"); return AVERROR_INVALIDDATA; } if (s->avctx->hwaccel && (s->avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD)) { if (s->avctx->hwaccel->end_frame(s->avctx) < 0) av_log(avctx, AV_LOG_ERROR, "hardware accelerator failed to decode first field\n"); } for (i = 0; i < 4; i++) { s->current_picture.f->data[i] = s->current_picture_ptr->f->data[i]; if (s->picture_structure == PICT_BOTTOM_FIELD) s->current_picture.f->data[i] += s->current_picture_ptr->f->linesize[i]; } } if (avctx->hwaccel) { if ((ret = avctx->hwaccel->start_frame(avctx, buf, buf_size)) < 0) return ret; } #if FF_API_XVMC FF_DISABLE_DEPRECATION_WARNINGS if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration) if (ff_xvmc_field_start(s, avctx) < 0) return -1; FF_ENABLE_DEPRECATION_WARNINGS #endif return 0; }
1threat
static int mp3_write_xing(AVFormatContext *s) { MP3Context *mp3 = s->priv_data; AVCodecContext *codec = s->streams[mp3->audio_stream_idx]->codec; int32_t header; MPADecodeHeader mpah; int srate_idx, i, channels; int bitrate_idx; int best_bitrate_idx = -1; int best_bitrate_error = INT_MAX; int xing_offset; int ver = 0; int bytes_needed, lsf; const char *vendor = (codec->flags & CODEC_FLAG_BITEXACT) ? "Lavf" : LIBAVFORMAT_IDENT; if (!s->pb->seekable || !mp3->write_xing) return 0; for (i = 0; i < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); i++) { const uint16_t base_freq = avpriv_mpa_freq_tab[i]; if (codec->sample_rate == base_freq) ver = 0x3; else if (codec->sample_rate == base_freq / 2) ver = 0x2; else if (codec->sample_rate == base_freq / 4) ver = 0x0; .5 else continue; srate_idx = i; break; } if (i == FF_ARRAY_ELEMS(avpriv_mpa_freq_tab)) { av_log(s, AV_LOG_WARNING, "Unsupported sample rate, not writing Xing header.\n"); return -1; } switch (codec->channels) { case 1: channels = MPA_MONO; break; case 2: channels = MPA_STEREO; break; default: av_log(s, AV_LOG_WARNING, "Unsupported number of channels, " "not writing Xing header.\n"); return -1; } header = 0xffU << 24; header |= (0x7 << 5 | ver << 3 | 0x1 << 1 | 0x1) << 16; /audio-version/layer 3/no crc*/ header |= (srate_idx << 2) << 8; header |= channels << 6; for (bitrate_idx = 1; bitrate_idx < 15; bitrate_idx++) { int bit_rate = 1000 * avpriv_mpa_bitrate_tab[lsf][3 - 1][bitrate_idx]; int error = FFABS(bit_rate - codec->bit_rate); if (error < best_bitrate_error) { best_bitrate_error = error; best_bitrate_idx = bitrate_idx; } } av_assert0(best_bitrate_idx >= 0); for (bitrate_idx = best_bitrate_idx; ; bitrate_idx++) { int32_t mask = bitrate_idx << (4 + 8); if (15 == bitrate_idx) return -1; header |= mask; avpriv_mpegaudio_decode_header(&mpah, header); xing_offset=xing_offtbl[mpah.lsf == 1][mpah.nb_channels == 1]; bytes_needed = 4 + xing_offset + 4 + 4 + 4 + 4 + XING_TOC_SIZE + 24 ; if (bytes_needed <= mpah.frame_size) break; header &= ~mask; } avio_wb32(s->pb, header); ffio_fill(s->pb, 0, xing_offset); mp3->xing_offset = avio_tell(s->pb); ffio_wfourcc(s->pb, "Xing"); avio_wb32(s->pb, 0x01 | 0x02 | 0x04); / size / TOC mp3->size = mpah.frame_size; mp3->want=1; mp3->seen=0; mp3->pos=0; avio_wb32(s->pb, 0); avio_wb32(s->pb, 0); for (i = 0; i < XING_TOC_SIZE; ++i) avio_w8(s->pb, (uint8_t)(255 * i / XING_TOC_SIZE)); for (i = 0; i < strlen(vendor); ++i) avio_w8(s->pb, vendor[i]); for (; i < 21; ++i) avio_w8(s->pb, 0); avio_wb24(s->pb, FFMAX(codec->delay - 528 - 1, 0)<<12); ffio_fill(s->pb, 0, mpah.frame_size - bytes_needed); return 0; }
1threat
how to simulate saturations and thresholds with scipy? : how to simulate saturations and thresholds with scipy? If it is not directly possible, you have another method to simulate?
0debug
Mobile View of Website : <p>I'm currently developing a site that can be found at <a href="http://bnlfinance.com" rel="nofollow">http://bnlfinance.com</a>, and I'm having issues with bootstrap with wordpress. The homepage, and the posts, do not resize correctly on mobile. The about us page does resize. I'm sure it's something simple, but this is the first website that I've created using wordpress. Thanks in advance for all the help!</p>
0debug
In Angular 2, how do I submit an input type="text" value upon pressing enter? : <p>I'm building a search box in my Angular 2 app, trying to submit the value upon hitting 'Enter' (the form does not include a button). </p> <p><strong>Template</strong></p> <pre><code>&lt;input type="text" id="search" class="form-control search-input" name="search" placeholder="Search..." [(ngModel)]="query" (ngSubmit)="this.onSubmit(query)"&gt; </code></pre> <p>With a simple onSubmit function for testing purposes...</p> <pre><code>export class HeaderComponent implements OnInit { constructor() {} onSubmit(value: string): void { alert('Submitted value: ' + value); } } </code></pre> <p>ngSubmit doesn't seem to work in this case. So what is the 'Angular 2 way' to solve this? (Preferably without hacks like hidden buttons)</p>
0debug
static void apply_loop_filter(Vp3DecodeContext *s, int plane, int ystart, int yend) { int x, y; int *bounding_values= s->bounding_values_array+127; int width = s->fragment_width[!!plane]; int height = s->fragment_height[!!plane]; int fragment = s->fragment_start [plane] + ystart * width; int stride = s->current_frame.linesize[plane]; uint8_t *plane_data = s->current_frame.data [plane]; if (!s->flipped_image) stride = -stride; plane_data += s->data_offset[plane] + 8*ystart*stride; for (y = ystart; y < yend; y++) { for (x = 0; x < width; x++) { if( s->all_fragments[fragment].coding_method != MODE_COPY ) { if (x > 0) { s->dsp.vp3_h_loop_filter( plane_data + 8*x, stride, bounding_values); } if (y > 0) { s->dsp.vp3_v_loop_filter( plane_data + 8*x, stride, bounding_values); } if ((x < width - 1) && (s->all_fragments[fragment + 1].coding_method == MODE_COPY)) { s->dsp.vp3_h_loop_filter( plane_data + 8*x + 8, stride, bounding_values); } if ((y < height - 1) && (s->all_fragments[fragment + width].coding_method == MODE_COPY)) { s->dsp.vp3_v_loop_filter( plane_data + 8*x + 8*stride, stride, bounding_values); } } fragment++; } plane_data += 8*stride; } }
1threat
hive> set x='test variable'; hive> ${hiveconf:x}; FAILED: Parse Error: line 1:0 cannot recognize input near ''test variable'' '<EOF>' '<EOF>' : passing parameter in hive is not working for me please see below. Example 1) hive> set x='test variable'; hive> ${hiveconf:x}; FAILED: Parse Error: line 1:0 cannot recognize input near ''test variable'' '<EOF>' '<EOF>'
0debug
Tkinter Function attached to Button executed immediately : <p>What I need is to attach a function to a button that is called with a parameter. When I write the code as below however, the code is executed once when the button is created and then no more. Also, the code works fine if I get rid of the parameter and parentheses when I declare the function as an attribute of the button. How can I call the function with a parameter only when the button is pressed?</p> <pre><code>from Tkinter import * root =Tk() def function(parameter): print parameter button = Button(root, text="Button", function=function('Test')) button.pack() root.mainloop() </code></pre>
0debug
void OPPROTO op_idivb_AL_T0(void) { int num, den, q, r; num = (int16_t)EAX; den = (int8_t)T0; if (den == 0) { raise_exception(EXCP00_DIVZ); } q = (num / den) & 0xff; r = (num % den) & 0xff; EAX = (EAX & ~0xffff) | (r << 8) | q; }
1threat
What is the pros and cons of using Rails asset pipeline vs. webpack to hold assets? : <p>From the <a href="https://github.com/rails/webpacker" rel="noreferrer">webpacker gem</a>:</p> <blockquote> <p>Webpacker makes it easy to use the JavaScript pre-processor and bundler Webpack 2.x.x+ to manage application-like JavaScript in Rails. It coexists with the asset pipeline, as the primary purpose for Webpack is app-like JavaScript, not images, CSS, or even JavaScript Sprinkles (that all continues to live in app/assets).</p> <p>However, it is possible to use Webpacker for CSS, images and fonts assets as well, in which case you may not even need the asset pipeline. This is mostly relevant when exclusively using component-based JavaScript frameworks.</p> </blockquote> <p>Why is it more relevant for component-base frameworks to use Webpacker for assets? If I'm using React, what difference does it make to get assets from asset pipepline vs Webpack?</p>
0debug
difficulty in choosing algorithm for similarity checker software : I am planning to build a project for final year that is similar to similarity checker. In the project, I am planning to check the similarity percentage among the submitted assignments i.e offline. For example: 1) When first student submits assignment, it is not checked with any other assignments. 2) When second student submits assignment, it is checked with the first assignment. 3) When third student submit assignment, it is checked with first and second submitted assignments. 4) Similarly if there are 35 students than the 36th submitted assignment is checked with rest 35 submitted assignments. Now, here comes the question that how to compare two assignments. In this case comparison is similarity between the texts in the documents. I want the result similar to this: [![Similarity checking between the documents][1]][1] [1]: https://i.stack.imgur.com/jmQ9W.jpg I just want to show percentage of similar sentences and what they are? What I did: I studied different algorithms like td-idf, cosine similarity algorithm but I am unable to correctly interpolate the results of algorithm. so, I want to know which algorithm is best in this situation and I want know how this is done. Is there any references to any sites, blogs that would help me??
0debug
How to read realtime microphone audio volume in python and ffmpeg or similar : <p>I'm trying to read, in <em>near-realtime</em>, the volume coming from the audio of a USB microphone in Python. </p> <p>I have the pieces, but can't figure out how to put it together. </p> <p>If I already have a .wav file, I can pretty simply read it using <strong>wavefile</strong>:</p> <pre><code>from wavefile import WaveReader with WaveReader("/Users/rmartin/audio.wav") as r: for data in r.read_iter(size=512): left_channel = data[0] volume = np.linalg.norm(left_channel) print volume </code></pre> <p>This works great, but I want to process the audio from the microphone in real-time, not from a file.</p> <p>So my thought was to use something like ffmpeg to PIPE the real-time output into WaveReader, but my Byte knowledge is somewhat lacking. </p> <pre><code>import subprocess import numpy as np command = ["/usr/local/bin/ffmpeg", '-f', 'avfoundation', '-i', ':2', '-t', '5', '-ar', '11025', '-ac', '1', '-acodec','aac', '-'] pipe = subprocess.Popen(command, stdout=subprocess.PIPE, bufsize=10**8) stdout_data = pipe.stdout.read() audio_array = np.fromstring(stdout_data, dtype="int16") print audio_array </code></pre> <p>That looks pretty, but it doesn't do much. It fails with a <strong>[NULL @ 0x7ff640016600] Unable to find a suitable output format for 'pipe:'</strong> error. </p> <p>I assume this is a fairly simple thing to do given that I only need to check the audio for volume levels. </p> <p>Anyone know how to accomplish this simply? FFMPEG isn't a requirement, but it does need to work on OSX &amp; Linux. </p>
0debug
On Windows, running "import tensorflow" generates No module named "_pywrap_tensorflow" error : <p>On Windows, TensorFlow reports either or both of the following errors after executing an <code>import tensorflow</code> statement:</p> <ul> <li><code>No module named "_pywrap_tensorflow"</code></li> <li><code>DLL load failed.</code></li> </ul>
0debug
Writing unit test for component which uses mat-autocomplete : <p>I am new to Angular, I am trying to build a text field with autocomplete using Angular 5. </p> <p>I found this example in <a href="https://material.angular.io/components/autocomplete/examples" rel="noreferrer">Angular Material docs</a>: </p> <p><a href="https://stackblitz.com/angular/kopqvokeddbq?file=app%2Fautocomplete-overview-example.ts" rel="noreferrer">https://stackblitz.com/angular/kopqvokeddbq?file=app%2Fautocomplete-overview-example.ts</a></p> <p>I was wondering how to write a unit test for testing the autocomplete functionality. I am setting a value to the input element and triggering an 'input' event and tried selecting the mat-option elements, but see that none of them got created:</p> <p>Relevant part of my component html:</p> <pre><code>&lt;form&gt; &lt;mat-form-field class="input-with-icon"&gt; &lt;div&gt; &lt;i ngClass="jf jf-search jf-lg md-primary icon"&gt;&lt;/i&gt; &lt;input #nameInput matInput class="input-field-with-icon" placeholder="Type name here" type="search" [matAutocomplete]="auto" [formControl]="userFormControl" [value]="inputField"&gt; &lt;/div&gt; &lt;/mat-form-field&gt; &lt;/form&gt; &lt;mat-autocomplete #auto="matAutocomplete"&gt; &lt;mat-option *ngFor="let option of filteredOptions | async" [value]="option.name" (onSelectionChange)="onNameSelect(option)"&gt; {{ option.name }} &lt;/mat-option&gt; &lt;/mat-autocomplete&gt; </code></pre> <p>Spec file:</p> <pre><code>it('should filter users based on input', fakeAsync(() =&gt; { const hostElement = fixture.nativeElement; sendInput('john').then(() =&gt; { fixture.detectChanges(); expect(fixture.nativeElement.querySelectorAll('mat-option').length).toBe(1); expect(hostElement.textContent).toContain('John Rambo'); }); })); function sendInput(text: string) { let inputElement: HTMLInputElement; inputElement = fixture.nativeElement.querySelector('input'); inputElement.focus(); inputElement.value = text; inputElement.dispatchEvent(new Event('input')); fixture.detectChanges(); return fixture.whenStable(); } </code></pre> <p>Component html:</p> <pre><code>userFormControl: FormControl = new FormControl(); ngOnInit() { this.filteredOptions = this.userFormControl.valueChanges .pipe( startWith(''), map(val =&gt; this.filter(val)) ); } filter(val: string): User[] { if (val.length &gt;= 3) { console.log(' in filter'); return this.users.filter(user =&gt; user.name.toLowerCase().includes(val.toLowerCase())); } } </code></pre> <p>Before this, I realised that for making the FormControl object set the value, I have to do a inputElement.focus() first, this is something to do with using mat input of angular material. Is there something I have to do to trigger opening the mat-options pane?</p> <p>How do I make this test work?</p>
0debug
Any idea for Next/Previous with json and swift file : <p>In swift, when I display a quote with id = 103, how can I get the next/previous quotes from my json result?</p> <p>I implement method for swipe left and right in My ViewController :</p> <pre><code>@objc func handleGesture(gesture: UISwipeGestureRecognizer) -&gt; Void { if gesture.direction == UISwipeGestureRecognizer.Direction.right { print("Swipe Right") } else if gesture.direction == UISwipeGestureRecognizer.Direction.left { print("Swipe Left") } } </code></pre> <p>and my json result is like: </p> <pre><code>{ "LOVE_METER": [ { "id": "105", "cat_id": "57", "quote": "My quote 1", "quotes_likes": "0", "quotes_unlikes": "0", "cid": "57", "category_name": "SMS d'amour" }, { "id": "104", "cat_id": "57", "quote": "My quote 2", "quotes_likes": "0", "quotes_unlikes": "0", "cid": "57", "category_name": "SMS d'amour" }, { "id": "103", "cat_id": "57", "quote": "My quote 3", "quotes_likes": "0", "quotes_unlikes": "0", "cid": "57", "category_name": "SMS d'amour" } ] } </code></pre> <p>Any idea ?</p>
0debug
super keyword unexpected here : <p>According to ES6 shorthand initialiser, following 2 methods are same:</p> <h2>In ES5</h2> <pre><code>var person = { name: "Person", greet: function() { return "Hello " + this.name; } }; </code></pre> <h2>In ES6</h2> <pre><code>var person = { name: "Person", greet() { return "Hello " + this.name; } }; </code></pre> <p>Do the ES6 way is in anyway different from the previous way? If not then using "super" inside them should be also treated as equal, which doesn't hold true, please see below two variaiton:</p> <h2>Below works</h2> <pre><code>let person = { greet(){ super.greet(); } }; Object.setPrototypeOf(person, { greet: function(){ console.log("Prototype method"); } }); person.greet(); </code></pre> <h2>Below fails</h2> <pre><code>let person = { greet: function(){ super.greet(); // Throw error: Uncaught SyntaxError: 'super' keyword unexpected here } }; Object.setPrototypeOf(person, { greet: function(){ console.log("Prototype method"); } }); person.greet(); </code></pre> <hr> <p>The only difference in above 2 examples is the way we declare method greet in person object, which should be same. So, why do we get error?</p>
0debug
PHP header("Location:bla") already exists : <p>I have a question. When I want to log in to my website, I get a really weird error, "Warning: Cannot modify header information - headers already sent by (output started at script:29) in script on line 44"</p> <pre><code>&lt;?php $verhalten = 0; include("connect.php"); if(!isset($_SESSION["email"]) and !isset($_GET["page"])) { $verhalten = 0; } if (isset($_GET["page"]) &amp;&amp; ($_GET["page"]) == "log") { $user = $_POST["user"]; $passwort = md5($_POST["passwort"]); } ?&gt; if($email == $row-&gt;Email &amp;&amp; $pass_hash == $row-&gt;Passwort) { header("Location: such_form_kunden.php?ID=$row-&gt;Kundennr"); $_SESSION["email"] = $email; $verhalten = 1; exit; } </code></pre>
0debug
How to fix this code? It is a code to send a different welcome message every time : The code is to send a different welcome message every time a new member logs on to the server (DM message ) It does not know how to fix mistakes   The error is in the line -- client.on('guildMemberAdd', ReBeL => { client.on('guildMemberAdd', ReBeL => { var bel = ["Welcome 1 @","Welcome 2 @!","Welcome 3 @"] var moon = bel[Math.floor(Math.random() * bel.length)]; moon = moon.replace('@', ReBeL.user) setTimeout(function() { member.createDM().then(function (channel) { return channel.send(moon) }).catch(console.error) },4000) });
0debug
16 bit encoding that has all bits mapped to some value : UTF-32 has its last bits zeroed. As I understand it UTF-16 doesn't use all its bits either. Is there a 16 bit encoding that has all bit combinations mapped to some value, preferably a subset of UTF, like ASCII for 7 bit?
0debug
How do i convert datetime to date? : I've got this SQL and my table is DATETIME $sql = "SELECT * FROM rapport WHERE user_checkin LIKE '".$cYear."-".$cMonth."-%' "; what I want is convert that to just give me the date so far I've tested CAST, DATE, DATE_FORMAT. with no success.
0debug
static const uint8_t *pcx_rle_decode(const uint8_t *src, const uint8_t *end, uint8_t *dst, unsigned int bytes_per_scanline, int compressed) { unsigned int i = 0; unsigned char run, value; if (compressed) { while (i < bytes_per_scanline && src < end) { run = 1; value = *src++; if (value >= 0xc0 && src < end) { run = value & 0x3f; value = *src++; } while (i < bytes_per_scanline && run--) dst[i++] = value; } } else { memcpy(dst, src, bytes_per_scanline); src += bytes_per_scanline; } return src; }
1threat
Need to write junit for scala code : I am new to scala and spark. Actually I need to write junit for the word count program of my scala code.My code looks like this. import org.apache.spark.SparkContext import org.apache.spark.SparkContext._ import org.apache.spark._ object SparkWordCount { def main(args: Array[String]) { meth() } def meth() { //Spark Config object having cluster information val sparkConfig = new SparkConf() .setAppName("SparkWordCount") .setMaster("local") val sc = new SparkContext(sparkConfig) val input = sc.textFile("C:\\SparkW\\input\\inp.txt") val count = input.flatMap(line ⇒ line.split(" ")) .map(word ⇒ (word, 1)) .reduceByKey(_ + _) count.saveAsTextFile("outfile") System.out.println("OK"); } } Can you please help me to write junit for above code.
0debug
static void dma_init2(struct dma_cont *d, int base, int dshift, int page_base, int pageh_base, qemu_irq *cpu_request_exit) { int i; d->dshift = dshift; d->cpu_request_exit = cpu_request_exit; memory_region_init_io(&d->channel_io, NULL, &channel_io_ops, d, "dma-chan", 8 << d->dshift); memory_region_add_subregion(isa_address_space_io(NULL), base, &d->channel_io); isa_register_portio_list(NULL, page_base, page_portio_list, d, "dma-page"); if (pageh_base >= 0) { isa_register_portio_list(NULL, pageh_base, pageh_portio_list, d, "dma-pageh"); } memory_region_init_io(&d->cont_io, NULL, &cont_io_ops, d, "dma-cont", 8 << d->dshift); memory_region_add_subregion(isa_address_space_io(NULL), base + (8 << d->dshift), &d->cont_io); qemu_register_reset(dma_reset, d); dma_reset(d); for (i = 0; i < ARRAY_SIZE (d->regs); ++i) { d->regs[i].transfer_handler = dma_phony_handler; } }
1threat
int gdbserver_start(const char *port) { GDBState *s; char gdbstub_port_name[128]; int port_num; char *p; CharDriverState *chr; if (!port || !*port) return -1; port_num = strtol(port, &p, 10); if (*p == 0) { snprintf(gdbstub_port_name, sizeof(gdbstub_port_name), "tcp::%d,nowait,nodelay,server", port_num); port = gdbstub_port_name; } chr = qemu_chr_open("gdb", port); if (!chr) return -1; s = qemu_mallocz(sizeof(GDBState)); if (!s) { return -1; } s->env = first_cpu; s->chr = chr; qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive, gdb_chr_event, s); qemu_add_vm_stop_handler(gdb_vm_stopped, s); return 0; }
1threat
Java function to C# : Hi i can't seem to get this to work after converting it to C# I need it to work like the Java one but i can't seem to be able to do that what am i doing wrong? Can anyone supply a fix and explain it please. C#: public static string Encrypt1(string strIn) { string strOut = ""; int lenIn = strIn.Length; int i = 0; while (i < lenIn) { double numRand = (int)Math.Floor(new Random().NextDouble() * 66) + 33; strOut += Convert.ToString((int)(strIn[i] + (char)numRand), 27) + Convert.ToString((int)numRand, 27); i++; } return strOut; } Java: public String Encrypt1(String strIn) { String strOut = ""; int lenIn = strIn.length(); int i = 0; double numRand; while (i < lenIn) { numRand = Math.floor(Math.random() * 66) + 36; strOut += Integer.toString((int)(strIn.charAt(i) + (char)numRand), 27) + Integer.toString((int)numRand, 27); i++; } return strOut; }
0debug
Android blurry screen sometimes : <p>This device:<br> <a href="https://www.amazon.de/Sony-Tablet-PC-Touchscreen-GHz-Quad-Core-Prozessor-interner/dp/B00IN1N66I" rel="noreferrer">https://www.amazon.de/Sony-Tablet-PC-Touchscreen-GHz-Quad-Core-Prozessor-interner/dp/B00IN1N66I</a> </p> <ul> <li>Sony Xperia Tablet Z2 SGP511 (10,1") Tablet-PC (Touchscreen, 2,3 GHz-Quad-Core-Prozessor, 3GB RAM, 16GB)</li> <li>Android version 5.1.1 (Lollipop)</li> </ul> <p>I'm developing an app with cordova (hybrid) and the screen gets blurry sometimes for no appearant reason.</p> <p>This usually goes away when I tap the screen in a random place inside the div or element that is blurry.</p> <p><strong>Blurry:</strong></p> <p><a href="https://i.stack.imgur.com/kACaG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kACaG.png" alt="enter image description here"></a></p> <p>=============================================</p> <p><strong>Clear:</strong></p> <p><a href="https://i.stack.imgur.com/TISKP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TISKP.png" alt="enter image description here"></a></p>
0debug
import re def remove_extra_char(text1): pattern = re.compile('[\W_]+') return (pattern.sub('', text1))
0debug
What assert do in dart? : <p>I just want to know what's the use of assert in a Dart. I was tried to figure it out by myself but I'm not able to do that. It would great if someone explains me about assert.</p>
0debug
static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che) { int num_gain = 0; int c, g, sfb, ret; int sign; INTFLOAT scale; SingleChannelElement *sce = &che->ch[0]; ChannelCoupling *coup = &che->coup; coup->coupling_point = 2 * get_bits1(gb); coup->num_coupled = get_bits(gb, 3); for (c = 0; c <= coup->num_coupled; c++) { num_gain++; coup->type[c] = get_bits1(gb) ? TYPE_CPE : TYPE_SCE; coup->id_select[c] = get_bits(gb, 4); if (coup->type[c] == TYPE_CPE) { coup->ch_select[c] = get_bits(gb, 2); if (coup->ch_select[c] == 3) num_gain++; } else coup->ch_select[c] = 2; } coup->coupling_point += get_bits1(gb) || (coup->coupling_point >> 1); sign = get_bits(gb, 1); scale = AAC_RENAME(cce_scale)[get_bits(gb, 2)]; if ((ret = decode_ics(ac, sce, gb, 0, 0))) return ret; for (c = 0; c < num_gain; c++) { int idx = 0; int cge = 1; int gain = 0; INTFLOAT gain_cache = FIXR10(1.); if (c) { cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb); gain = cge ? get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60: 0; gain_cache = GET_GAIN(scale, gain); } if (coup->coupling_point == AFTER_IMDCT) { coup->gain[c][0] = gain_cache; } else { for (g = 0; g < sce->ics.num_window_groups; g++) { for (sfb = 0; sfb < sce->ics.max_sfb; sfb++, idx++) { if (sce->band_type[idx] != ZERO_BT) { if (!cge) { int t = get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; if (t) { int s = 1; t = gain += t; if (sign) { s -= 2 * (t & 0x1); t >>= 1; } gain_cache = GET_GAIN(scale, t) * s; } } coup->gain[c][idx] = gain_cache; } } } } } return 0; }
1threat
How can i solve this err in java : I'm KIMYONGGEE I wonder what's wrong with this **JAVA project** class Sample { public int a; private int b; int c; } public class ex { public static void main(String[] args) { Sample aClass = new Sample(); aClass.a = 10; aClass.b = 10; aClass.c = 10; } }
0debug
static gboolean tcp_chr_chan_close(GIOChannel *channel, GIOCondition cond, void *opaque) { CharDriverState *chr = opaque; if (cond != G_IO_HUP) { return FALSE; } tcp_chr_disconnect(chr); if (chr->fd_hup_tag) { g_source_remove(chr->fd_hup_tag); chr->fd_hup_tag = 0; } return TRUE; }
1threat
u64 decimal to hex using C : <p>I have a titleID u64 array in which the first position consists of 16 decimal numbers.</p> <pre><code>u64 titleID[] = {1266656072911941} </code></pre> <p>In this function:</p> <pre><code>APT_PrepareToDoApplicationJump(0, 0x000_LL, 0); </code></pre> <p>How can I replace the <code>_</code> with the hex value of <code>titleID[0]</code>? The <code>0x000_LL</code> parameter needs to have a u64 type as well.</p> <p>Example using the provided titleID:</p> <pre><code>APT_PrepareToDoApplicationJump(0, 0x0004800459474C45LL, 0); </code></pre>
0debug
I need complete C++ Implementation of General Tree with arbitrary number of nodes : I am googling from the last two days to find complete C++ implementation of general tree but I only found the binary tree implementation that is why I am posting my question here.
0debug
SQL Image field divided by 2 : <p>Could anyone help me on the below please?</p> <p>I have a field called F1.Images and I need to divide by 2 ONLY when my other field W1.Plex is Duplex else I need to retain the F1.Images count.</p> <p>Thanks Satya</p>
0debug
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
re.findall not finding all, only some. How could this be? : <p>I have a text file containing five websites. In each of these websites are multiple amazon links, in which my goal is to collect all of them. However, one of the five websites uses "amzn.to" to lead to the amazon link instead of "amazon.com", which I initially thought was solvable by just using this:</p> <pre><code>any(re.findall(r'(amazon.com|amzn.to)', str, re.IGNORECASE)) </code></pre> <p>There's supposed to be ten <code>amzn.to</code> links included in my overall list of amazon links but only two are found.</p> <p>Here's my entire code:</p> <pre><code>import requests import re from bs4 import BeautifulSoup from collections import OrderedDict file_name = raw_input("Enter file name: ") filepath = "%s"%(file_name) with open(filepath) as f: listoflinks = [line.rstrip('\n') for line in f] raw_links = [] for i in listoflinks: html = requests.get(i).text bs = BeautifulSoup(html) possible_links = bs.find_all('a') for link in possible_links: if link.has_attr('href'): raw_links.append(link.attrs['href']) amazon_links = [] for str in raw_links: if (any(re.findall(r'(amazon.com|amzn.to)', str, re.IGNORECASE))) and (str not in amazon_links): amazon_links.append(str) for i in amazon_links: print i print len(amazon_links) </code></pre> <p>I know it works, but not as well as I'd like it to. Please help me pinpoint the problem.</p>
0debug
VirtIOSCSIReq *virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq) { VirtIOSCSIReq *req; VirtIOSCSICommon *vs = (VirtIOSCSICommon *)s; const size_t zero_skip = offsetof(VirtIOSCSIReq, vring); req = g_malloc(sizeof(*req) + vs->cdb_size); req->vq = vq; req->dev = s; qemu_sglist_init(&req->qsgl, DEVICE(s), 8, &address_space_memory); qemu_iovec_init(&req->resp_iov, 1); memset((uint8_t *)req + zero_skip, 0, sizeof(*req) - zero_skip); return req; }
1threat
static void qpi_init(void) { kqemu_comm_base = 0xff000000 | 1; qpi_io_memory = cpu_register_io_memory( qpi_mem_read, qpi_mem_write, NULL); cpu_register_physical_memory(kqemu_comm_base & ~0xfff, 0x1000, qpi_io_memory); }
1threat
static void write_packet(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) { AVStream *st = ost->st; int ret; if (!(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->encoding_needed)) { if (ost->frame_number >= ost->max_frames) { av_packet_unref(pkt); return; } ost->frame_number++; } if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR, NULL); ost->quality = sd ? *(int *)sd : -1; if (ost->frame_rate.num) { pkt->duration = av_rescale_q(1, av_inv_q(ost->frame_rate), ost->st->time_base); } } if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS) && ost->last_mux_dts != AV_NOPTS_VALUE && pkt->dts < ost->last_mux_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT)) { av_log(NULL, AV_LOG_WARNING, "Non-monotonous DTS in output stream " "%d:%d; previous: %"PRId64", current: %"PRId64"; ", ost->file_index, ost->st->index, ost->last_mux_dts, pkt->dts); if (exit_on_error) { av_log(NULL, AV_LOG_FATAL, "aborting.\n"); exit_program(1); } av_log(NULL, AV_LOG_WARNING, "changing to %"PRId64". This may result " "in incorrect timestamps in the output file.\n", ost->last_mux_dts + 1); pkt->dts = ost->last_mux_dts + 1; if (pkt->pts != AV_NOPTS_VALUE) pkt->pts = FFMAX(pkt->pts, pkt->dts); } ost->last_mux_dts = pkt->dts; ost->data_size += pkt->size; ost->packets_written++; pkt->stream_index = ost->index; ret = av_interleaved_write_frame(s, pkt); if (ret < 0) { print_error("av_interleaved_write_frame()", ret); exit_program(1); } }
1threat
INLINE flag extractFloat64Sign( float64 a ) { return a>>63; }
1threat
How can i add an image into a image using UWP XAML C#? : <p>I use a button and its background is an image.I want to put an logo into it but i don't know how to put an image into image. Help me please thanks </p>
0debug
static int mpegps_read_header(AVFormatContext *s, AVFormatParameters *ap) { MpegDemuxContext *m = s->priv_data; uint8_t buffer[8192]; char *p; m->header_state = 0xff; s->ctx_flags |= AVFMTCTX_NOHEADER; get_buffer(&s->pb, buffer, sizeof(buffer)); if ((p=memchr(buffer, 'S', sizeof(buffer)))) if (!memcmp(p, "Sofdec", 6)) m->sofdec = 1; url_fseek(&s->pb, -sizeof(buffer), SEEK_CUR); return 0; }
1threat
Could you explain what is happening in this code? : <p>Please explain what is happening in the code.</p> <p>I tried the if else that did not work. </p> <pre><code>#include &lt;stdio.h&gt; int isLeapYear(int year) { return ((!(year % 4) &amp;&amp; year % 100) || !(year % 400)); } </code></pre>
0debug
void qemu_input_event_send(QemuConsole *src, InputEvent *evt) { QemuInputHandlerState *s; if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) { qemu_input_event_trace(src, evt); if (graphic_rotate && (evt->kind == INPUT_EVENT_KIND_ABS)) { qemu_input_transform_abs_rotate(evt); s = qemu_input_find_handler(1 << evt->kind); s->handler->event(s->dev, src, evt); s->events++;
1threat
Giving error 'Error Bad file descriptor' during execution of PERL : When I am using the following command for executing prop.obj **"perl sendXssl.pl *hostname* *port* prop.obj"**, It is giving error as "Error Bad file descriptor". Please help me to solve this. My Perl program is given below... #Perl# use IO::Socket::SSL qw( SSL_VERIFY_NONE ); $|=1; $sock = new IO::Socket::SSL->new( PeerHost => $ARGV[0], PeerPort => $ARGV[1], SSL_verify_mode => SSL_VERIFY_NONE) or die "Error $!\n"; print $sock "X"; $file = $ARGV[2]; open($fh,'+<',$file) or die "Error $!\n"; { local $/; $data = <$fh>; } close($fh); $pack = $data; print $sock $pack; I created **prop.obj** object from the following java file #Java# import java.io.FileOutputStream; import java.io.ObjectOutputStream; import java.util.Properties; public class PropertiesX { public static void main(String[] args) { try { String[] s = new String[1]; s[0] = "notepad.exe"; Properties p = new Properties(); p.put("commandArgs",s); p.setProperty("parent", "c:\\windows\\system32\\notepad.exe"); FileOutputStream fos = new FileOutputStream("prop.obj"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(p); oos.close(); System.out.println(p.toString()); } catch (Exception ex) { ex.printStackTrace(); } } }
0debug
static int xan_decode_init(AVCodecContext *avctx) { XanContext *s = avctx->priv_data; int i; s->avctx = avctx; if ((avctx->codec->id == CODEC_ID_XAN_WC3) && (s->avctx->palctrl == NULL)) { av_log(avctx, AV_LOG_ERROR, " WC3 Xan video: palette expected.\n"); return -1; } avctx->pix_fmt = PIX_FMT_PAL8; avctx->has_b_frames = 0; dsputil_init(&s->dsp, avctx); for (i = 0; i < 256; i++) { y_r_table[i] = Y_R * i; y_g_table[i] = Y_G * i; y_b_table[i] = Y_B * i; u_r_table[i] = U_R * i; u_g_table[i] = U_G * i; u_b_table[i] = U_B * i; v_r_table[i] = V_R * i; v_g_table[i] = V_G * i; v_b_table[i] = V_B * i; } if(avcodec_check_dimensions(avctx, avctx->width, avctx->height)) return -1; s->buffer1 = av_malloc(avctx->width * avctx->height); s->buffer2 = av_malloc(avctx->width * avctx->height); if (!s->buffer1 || !s->buffer2) return -1; return 0; }
1threat
void cpu_exec_realizefn(CPUState *cpu, Error **errp) { CPUClass *cc = CPU_GET_CLASS(cpu); cpu_list_add(cpu); if (tcg_enabled() && !cc->tcg_initialized) { cc->tcg_initialized = true; cc->tcg_initialize(); } #ifndef CONFIG_USER_ONLY if (qdev_get_vmsd(DEVICE(cpu)) == NULL) { vmstate_register(NULL, cpu->cpu_index, &vmstate_cpu_common, cpu); } if (cc->vmsd != NULL) { vmstate_register(NULL, cpu->cpu_index, cc->vmsd, cpu); } #endif }
1threat
Git rebase one branch on top of another branch : <p>In my git repo, I have a <code>Master</code> branch. One of the remote devs created a branch <code>Branch1</code> and had a bunch of commits on it. I branched from <code>Branch1</code>, creating a new branch called <code>Branch2</code> (<code>git checkout -b Branch2 Branch1</code>) such that <code>Branch2</code> head was on the last commit added to <code>Branch1</code>:(Looks like this)</p> <pre><code>Master--- \ Branch1--commit1--commit2 \ Branch2 (my local branch) </code></pre> <p><code>Branch1</code> has had a number of changes. The other dev squashed his commits and then added a few more commits. Meanwhile, ive had a bunch of changes in my branch but havent committed anything yet. Current structure looks like this:</p> <pre><code> Master--- \ Branch1--squashed commit1,2--commit3--commit4 \ Branch2 (my local branch) </code></pre> <p>Now I want have to rebase my changes on top of <code>Branch1</code>. I am supremely confused on how to go about this. I know the 1st step will be to commit my changes using <code>git add .</code> and <code>git commit -m "message"</code>. But do i then push? using <code>git push origin Branch2</code> ? or <code>git push origin Branch2 Branch1</code> ? Help is much needed and GREATLY appreciated, also if I can some how create a backup of my branch, it will be great in case I screw something up</p>
0debug
How to get a uniform distribution in a range [r1,r2] in PyTorch? : <p>The question says it all. I want to get a 2-D <code>torch.Tensor</code> with size <code>[a,b]</code> filled with values from a uniform distribution (in range <code>[r1,r2]</code>) in PyTorch.</p>
0debug
static int cng_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { AVFrame *frame = data; CNGContext *p = avctx->priv_data; int buf_size = avpkt->size; int ret, i; int16_t *buf_out; float e = 1.0; float scaling; if (avpkt->size) { int dbov = -avpkt->data[0]; p->target_energy = 1081109975 * ff_exp10(dbov / 10.0) * 0.75; memset(p->target_refl_coef, 0, p->order * sizeof(*p->target_refl_coef)); for (i = 0; i < FFMIN(avpkt->size - 1, p->order); i++) { p->target_refl_coef[i] = (avpkt->data[1 + i] - 127) / 128.0; if (p->inited) { p->energy = p->energy / 2 + p->target_energy / 2; for (i = 0; i < p->order; i++) p->refl_coef[i] = 0.6 *p->refl_coef[i] + 0.4 * p->target_refl_coef[i]; } else { p->energy = p->target_energy; memcpy(p->refl_coef, p->target_refl_coef, p->order * sizeof(*p->refl_coef)); p->inited = 1; make_lpc_coefs(p->lpc_coef, p->refl_coef, p->order); for (i = 0; i < p->order; i++) e *= 1.0 - p->refl_coef[i]*p->refl_coef[i]; scaling = sqrt(e * p->energy / 1081109975); for (i = 0; i < avctx->frame_size; i++) { int r = (av_lfg_get(&p->lfg) & 0xffff) - 0x8000; p->excitation[i] = scaling * r; ff_celp_lp_synthesis_filterf(p->filter_out + p->order, p->lpc_coef, p->excitation, avctx->frame_size, p->order); frame->nb_samples = avctx->frame_size; if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; buf_out = (int16_t *)frame->data[0]; for (i = 0; i < avctx->frame_size; i++) buf_out[i] = p->filter_out[i + p->order]; memcpy(p->filter_out, p->filter_out + avctx->frame_size, p->order * sizeof(*p->filter_out)); *got_frame_ptr = 1; return buf_size;
1threat
from collections import defaultdict def get_unique(test_list): res = defaultdict(list) for sub in test_list: res[sub[1]].append(sub[0]) res = dict(res) res_dict = dict() for key in res: res_dict[key] = len(list(set(res[key]))) return (str(res_dict))
0debug
static void unterminated_escape(void) { QObject *obj = qobject_from_json("\"abc\\\"", NULL); g_assert(obj == NULL); }
1threat
How can I make this piece of code asynchronous via promises ? : Any Glue. ***Please do not give example of SETTIMEOUT.*** My supervisor said that it is unnecessary having more then() statement if the then()'s do not return any new promise.I could not get it completely, I have looked at Exploring ES6 but there is no very well example of my situation. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> let readData = new Promise(function (resolve, reject) { fs.readFile('/home/geek/Desktop/activity-logs.csv', 'utf8', (err, data) => { if (err) reject(); resolve(data); }); }); readData .then((data) => { bankLogs = splitString(data, ';') }) .then(() => { for (let index = 2; index < bankLogs.length; index += 5) { objectOfUsers[bankLogs[index]] = {} temporarySymbols.push(bankLogs[index].concat(bankLogs[index + 1])); } Object.keys(objectOfUsers).forEach(function (element) { objectKeys.push(element) }); for (let index = 0; index < objectKeys.length; index++) createObject(index); console.log(objectOfUsers) }) .catch((err) => console.log('Error happened : ' + err)); <!-- end snippet -->
0debug
SQL syntax don't work : below syntax don't work. when I run below command which is SELECT * FROM table1 WHERE DOJ = '19-Feb-14'; an error message show which is below Data type mismatch in criteria expression. Pls give me solution.
0debug
Autowiring BuildProperties bean from Gradle - NoSuchBeanDefinitionException : <p>I am trying to obtain the version in my Java application from the Gradle build file. I am following the instructions here;</p> <p><a href="https://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html" rel="noreferrer">https://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html</a></p> <p><strong>build.gradle</strong></p> <pre><code>buildscript { repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle- plugin:1.5.7.RELEASE") } } project.version = '0.1.0' apply plugin: 'java' apply plugin: 'war' apply plugin: 'idea' apply plugin: 'org.springframework.boot' springBoot { buildInfo() } jar { baseName = 'ci-backend' } war { baseName = 'ci-backend' } repositories { mavenCentral() } sourceCompatibility = 1.8 targetCompatibility = 1.8 dependencies { compile("org.springframework.boot:spring-boot-starter-web") compile("org.springframework:spring-jdbc") compile("joda-time:joda-time") compile("com.opencsv:opencsv:3.9") compile("org.springframework.batch:spring-batch-core") testCompile('org.springframework.boot:spring-boot-starter-test') providedRuntime('org.springframework.boot:spring-boot-starter-tomcat') } </code></pre> <p>After building with gradle the <code>build-info.properties</code> file is present in build/resources/main/META-INF/build-info.properties</p> <p>In my <code>@RestController</code> I am trying to autowire the build properties bean</p> <pre><code>@Autowired private BuildProperties buildProperties; </code></pre> <p>I am getting the following error;</p> <pre><code>Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.info.BuildProperties' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1493) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585) ... 41 more </code></pre> <p>I would assume that the <code>BuildProperties</code> bean is automatically created when the build-info.properties is present. It does not seem to be the case.</p>
0debug
How to print 3 dot at the end of the text if text is over flow? : <p>which CSS properties is used to print 3 dot at the end of the text if text is over flow?</p>
0debug
static void scsi_write_complete(void * opaque, int ret) { SCSIDiskReq *r = (SCSIDiskReq *)opaque; SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); uint32_t n; if (r->req.aiocb != NULL) { r->req.aiocb = NULL; block_acct_done(bdrv_get_stats(s->qdev.conf.bs), &r->acct); } if (r->req.io_canceled) { goto done; } if (ret < 0) { if (scsi_handle_rw_error(r, -ret)) { goto done; } } n = r->qiov.size / 512; r->sector += n; r->sector_count -= n; if (r->sector_count == 0) { scsi_write_do_fua(r); return; } else { scsi_init_iovec(r, SCSI_DMA_BUF_SIZE); DPRINTF("Write complete tag=0x%x more=%zd\n", r->req.tag, r->qiov.size); scsi_req_data(&r->req, r->qiov.size); } done: if (!r->req.io_canceled) { scsi_req_unref(&r->req); } }
1threat
Hi! I'm building a media player app, my application is getting a FATAL EXCEPTION! idk what to do now, I'm new to android, Anyone help please : package com.example.macbookpro.myplayer; import android.media.MediaPlayer; import android.net.Uri; import android.os.Handler; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.SeekBar; import android.widget.TextView; import java.io.File; import java.io.IOException; import java.util.ArrayList; public class AudioPlayer extends AppCompatActivity implements SeekBar.OnSeekBarChangeListener, MediaPlayer.OnCompletionListener { ImageView btn_play; Button btn_pause; ImageView btn_next; ImageView btn_prev; ImageView btn_forward; ImageView btn_backward; TextView song_title; int currentsongindex; int seekForwardTime = 5000; int seekBackwardTime = 5000; private Utilities utilities; Handler mHandler1=new Handler(); SeekBar song_progressbar; final ArrayList<File> arrayList = new ArrayList<File>(); MediaPlayer mp = new MediaPlayer(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_audio_player); btn_play = (ImageView) findViewById(R.id.btn_play); btn_next = (ImageView) findViewById(R.id.btn_next); btn_prev = (ImageView) findViewById(R.id.btn_prev); btn_forward = (ImageView) findViewById(R.id.btn_forward); btn_backward = (ImageView) findViewById(R.id.btn_backwrd); song_title = (TextView) findViewById(R.id.tw); song_progressbar=(SeekBar)findViewById(R.id.song_progressbar); song_progressbar.setOnSeekBarChangeListener(this); mp.setOnCompletionListener(this); try { PlaySongtwo(getIntent().getStringExtra("index")); } catch (IOException e) { e.printStackTrace(); } final String[] sec = getIntent().getStringArrayExtra("index2"); currentsongindex = Integer.parseInt((getIntent().getStringExtra("positionofcurrentsong"))); utilities = new Utilities(); // Button for playing the song btn_play.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { if (mp.isPlaying()) { if (mp != null) { mp.pause(); btn_play.setImageResource(R.drawable.button_play); } else { if (mp != null) { mp.start(); btn_play.setImageResource(R.drawable.button_pause); } } } else { if (mp != null) { mp.start(); btn_play.setImageResource(R.drawable.button_pause); } } } }); // Button for the next song in the list btn_next.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { Log.e("currenttt song is ",currentsongindex+""); if(currentsongindex < (sec.length-1)){ int cc=currentsongindex+1; Log.e("value in cc",cc+""); try { PlaySongtwo(sec[cc]); } catch (IOException e) { e.printStackTrace(); } Log.e("next song number is ",cc +""); currentsongindex = currentsongindex +1; }else { try { PlaySongtwo(sec[0]); } catch (IOException e) { e.printStackTrace(); } currentsongindex = 0; } } }); //Button for the previous song in the list btn_prev.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { if(currentsongindex > 0){ int prevsong= currentsongindex-1; try { PlaySongtwo(sec[prevsong]); } catch (IOException e) { e.printStackTrace(); } Log.e("prev song",prevsong+""); currentsongindex = prevsong; }else { try { PlaySongtwo(String.valueOf((sec.length-1))); } catch (IOException e) { e.printStackTrace(); } currentsongindex = sec.length-1; } } }); //Button for fast-forwarding the song btn_forward.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { int currentPosition = mp.getCurrentPosition(); if(currentPosition + seekForwardTime <= mp.getDuration() ){ mp.seekTo(currentPosition + seekForwardTime); }else { mp.seekTo(mp.getDuration()); } } }); //Button for fast-backwarding the song btn_backward.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { int currentPostion = mp.getCurrentPosition(); if(currentPostion - seekBackwardTime >= 0){ mp.seekTo(currentPostion - seekBackwardTime); }else { mp.seekTo(0); } } }); } private void PlaySongtwo(String path) throws IOException { try { String songname = path.substring(path.lastIndexOf("/") + 1); song_title.setText(songname); mp.reset(); Uri myUri = Uri.parse(path); mp.setDataSource(AudioPlayer.this, myUri); mp.prepare(); mp.start(); btn_play.setImageResource(R.drawable.button_pause); song_progressbar.setProgress(0); song_progressbar.setMax(100); updateProgressBar1(); } catch (IOException e) { e.printStackTrace(); } } private void updateProgressBar1() { mHandler1.postDelayed(mUpdateTimeTask1,100); } private Runnable mUpdateTimeTask1=new Runnable() { @Override public void run() { long totalDuration = mp.getDuration(); long currentDuration=mp.getCurrentPosition(); int progress=(int)(utilities.getProgresspercentage(currentDuration,totalDuration)); song_progressbar.setProgress(progress); mHandler1.postDelayed(this,100); } }; @Override protected void onDestroy () { super.onDestroy(); mp.release(); } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { mHandler1.removeCallbacks(mUpdateTimeTask1); } @Override public void onStopTrackingTouch(SeekBar seekBar) { mHandler1.removeCallbacks(mUpdateTimeTask1); int totalDuration=mp.getDuration(); int currentPosition=utilities.progressToTimer(seekBar.getProgress(),totalDuration); mp.seekTo(currentPosition); updateProgressBar1(); } @Override public void onCompletion(MediaPlayer mp1) { enter code here } } This is the error I'm facing. 11-06 13:30:03.935 1060-1060/com.example.macbookpro.myplayer E/MediaPlayer: Should have subtitle controller already set 11-06 13:30:04.031 1060-1060/com.example.macbookpro.myplayer E/MediaPlayer: Should have subtitle controller already set 11-06 13:30:22.260 1060-1060/com.example.macbookpro.myplayer D/AndroidRuntime: Shutting down VM 11-06 13:30:22.261 1060-1060/com.example.macbookpro.myplayer E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.macbookpro.myplayer, PID: 1060 java.lang.IllegalStateException at android.media.MediaPlayer.getDuration(Native Method) at com.example.macbookpro.myplayer.AudioPlayer$6.run(AudioPlayer.java:220) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
0debug
int parse_debug_env(const char *name, int max, int initial) { char *debug_env = getenv(name); char *inv = NULL; int debug; if (!debug_env) { return initial; } debug = strtol(debug_env, &inv, 10); if (inv == debug_env) { return initial; } if (debug < 0 || debug > max) { fprintf(stderr, "warning: %s not in [0, %d]", name, max); return initial; } return debug; }
1threat
Are function attributes inherited? : <p>If I have a virtual function that carries an <a href="http://en.cppreference.com/w/cpp/language/attributes" rel="noreferrer">attribute</a></p> <pre><code>[[nodiscard]] virtual bool some_function() = 0; </code></pre> <p>Does that attribute get implicitly applied to overrides of that function?</p> <pre><code>bool some_function() override; </code></pre> <p>Or do I need the attribute again?</p> <pre><code>[[nodiscard]] bool some_function() override; </code></pre>
0debug
static int microdvd_probe(AVProbeData *p) { unsigned char c; const uint8_t *ptr = p->buf; int i; if (AV_RB24(ptr) == 0xEFBBBF) ptr += 3; for (i=0; i<3; i++) { if (sscanf(ptr, "{%*d}{}%c", &c) != 1 && sscanf(ptr, "{%*d}{%*d}%c", &c) != 1 && sscanf(ptr, "{DEFAULT}{}%c", &c) != 1) return 0; ptr += strcspn(ptr, "\n") + 1; } return AVPROBE_SCORE_MAX; }
1threat
Can I put script comands in one line? : Do I have to place script commands for .ahk file in new line each, or I can just put them in one line? So instead of having Send, {F9} Sleep, 1000 Send, {F9} Sleep, 1000 Can I have Send, {F9} Sleep, 1000 Send, {F9} Sleep, 1000 ?
0debug
How to make a drag and drop page builder from scratch : <p>My goal is to make a tool to add html elements on a blank page to make a web page. I know it could be done with jquery's drag and drop but the problem is I don't have any idea how to organize the elements when you drag another one below it.</p> <p>Like for real I don't have the slightest idea on meeting my goal. Any suggestions would help me alot.</p>
0debug
static void avc_luma_mid_and_aver_dst_8w_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, int32_t height) { uint32_t loop_cnt; v16i8 src0, src1, src2, src3, src4; v16i8 mask0, mask1, mask2; v8i16 hz_out0, hz_out1, hz_out2, hz_out3; v8i16 hz_out4, hz_out5, hz_out6, hz_out7, hz_out8; v16u8 dst0, dst1, dst2, dst3; v8i16 res0, res1, res2, res3; LD_SB3(&luma_mask_arr[0], 16, mask0, mask1, mask2); LD_SB5(src, src_stride, src0, src1, src2, src3, src4); XORI_B5_128_SB(src0, src1, src2, src3, src4); src += (5 * src_stride); hz_out0 = AVC_HORZ_FILTER_SH(src0, src0, mask0, mask1, mask2); hz_out1 = AVC_HORZ_FILTER_SH(src1, src1, mask0, mask1, mask2); hz_out2 = AVC_HORZ_FILTER_SH(src2, src2, mask0, mask1, mask2); hz_out3 = AVC_HORZ_FILTER_SH(src3, src3, mask0, mask1, mask2); hz_out4 = AVC_HORZ_FILTER_SH(src4, src4, mask0, mask1, mask2); for (loop_cnt = (height >> 2); loop_cnt--;) { LD_SB4(src, src_stride, src0, src1, src2, src3); XORI_B4_128_SB(src0, src1, src2, src3); src += (4 * src_stride); hz_out5 = AVC_HORZ_FILTER_SH(src0, src0, mask0, mask1, mask2); hz_out6 = AVC_HORZ_FILTER_SH(src1, src1, mask0, mask1, mask2); hz_out7 = AVC_HORZ_FILTER_SH(src2, src2, mask0, mask1, mask2); hz_out8 = AVC_HORZ_FILTER_SH(src3, src3, mask0, mask1, mask2); res0 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, hz_out5); res1 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out1, hz_out2, hz_out3, hz_out4, hz_out5, hz_out6); res2 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out2, hz_out3, hz_out4, hz_out5, hz_out6, hz_out7); res3 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out3, hz_out4, hz_out5, hz_out6, hz_out7, hz_out8); LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); ILVR_D2_UB(dst1, dst0, dst3, dst2, dst0, dst1); CONVERT_UB_AVG_ST8x4_UB(res0, res1, res2, res3, dst0, dst1, dst, dst_stride); dst += (4 * dst_stride); hz_out3 = hz_out7; hz_out1 = hz_out5; hz_out5 = hz_out4; hz_out4 = hz_out8; hz_out2 = hz_out6; hz_out0 = hz_out5; } }
1threat
static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src, long width, enum PixelFormat srcFormat) { __asm__ volatile( "movq 24(%4), %%mm6 \n\t" "mov %3, %%"REG_a" \n\t" "pxor %%mm7, %%mm7 \n\t" "1: \n\t" PREFETCH" 64(%0) \n\t" "movd (%0), %%mm0 \n\t" "movd 2(%0), %%mm1 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movq %%mm0, %%mm2 \n\t" "movq %%mm1, %%mm3 \n\t" "pmaddwd (%4), %%mm0 \n\t" "pmaddwd 8(%4), %%mm1 \n\t" "pmaddwd 16(%4), %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" "paddd %%mm1, %%mm0 \n\t" "paddd %%mm3, %%mm2 \n\t" "movd 6(%0), %%mm1 \n\t" "movd 8(%0), %%mm3 \n\t" "add $12, %0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "movq %%mm1, %%mm4 \n\t" "movq %%mm3, %%mm5 \n\t" "pmaddwd (%4), %%mm1 \n\t" "pmaddwd 8(%4), %%mm3 \n\t" "pmaddwd 16(%4), %%mm4 \n\t" "pmaddwd %%mm6, %%mm5 \n\t" "paddd %%mm3, %%mm1 \n\t" "paddd %%mm5, %%mm4 \n\t" "movq "MANGLE(ff_bgr24toUVOffset)", %%mm3 \n\t" "paddd %%mm3, %%mm0 \n\t" "paddd %%mm3, %%mm2 \n\t" "paddd %%mm3, %%mm1 \n\t" "paddd %%mm3, %%mm4 \n\t" "psrad $15, %%mm0 \n\t" "psrad $15, %%mm2 \n\t" "psrad $15, %%mm1 \n\t" "psrad $15, %%mm4 \n\t" "packssdw %%mm1, %%mm0 \n\t" "packssdw %%mm4, %%mm2 \n\t" "packuswb %%mm0, %%mm0 \n\t" "packuswb %%mm2, %%mm2 \n\t" "movd %%mm0, (%1, %%"REG_a") \n\t" "movd %%mm2, (%2, %%"REG_a") \n\t" "add $4, %%"REG_a" \n\t" " js 1b \n\t" : "+r" (src) : "r" (dstU+width), "r" (dstV+width), "g" ((x86_reg)-width), "r"(ff_bgr24toUV[srcFormat == PIX_FMT_RGB24]) : "%"REG_a ); }
1threat
When is apache Storm 2.0 expected to be released? : <p>Apache Storm 2.0 SNAPSHOT has been tagged on github for a long time (years?) but isn't available for download and I cant find an ETA/roadmap.</p> <p>My understanding was 2.0 removed a lot of clojure and improved performance (I might be wrong on the later), but is 2.0 dead?</p>
0debug
int fd_start_outgoing_migration(MigrationState *s, const char *fdname) { s->fd = monitor_get_fd(s->mon, fdname); if (s->fd == -1) { DPRINTF("fd_migration: invalid file descriptor identifier\n"); goto err_after_get_fd; } if (fcntl(s->fd, F_SETFL, O_NONBLOCK) == -1) { DPRINTF("Unable to set nonblocking mode on file descriptor\n"); goto err_after_open; } s->get_error = fd_errno; s->write = fd_write; s->close = fd_close; migrate_fd_connect(s); return 0; err_after_open: close(s->fd); err_after_get_fd: return -1; }
1threat
What is the way to understand Proximal Policy Optimization Algorithm in RL? : <p>I know the basics of Reinforcement Learning, but what terms it's necessary to understand to be able read <a href="https://arxiv.org/abs/1707.06347" rel="noreferrer">arxiv PPO paper</a> ?</p> <p>What is the roadmap to learn and use <a href="https://blog.openai.com/openai-baselines-ppo/" rel="noreferrer">PPO</a> ?</p>
0debug
Why does Ubuntu have old versions of nodejs and npm in their apt-get package manager? : <p>When I install nodejs and npm with apt-get </p> <pre><code>sudo apt-get update sudo apt-get install nodejs modejs-legacy npm I have the versions </code></pre> <p>I get the following versions</p> <pre><code>npm -v 1.3.10 nodejs -v v0.10.25 </code></pre> <p>I know how to update these manually, but why does the apt-get package manager have old versions of these packages?</p>
0debug
Getting a list of classes that inherit a specific interface? : <p>I'm using dependency injection in my project and wondered if it would be easier to just register all 30+ of my classes that inherit a certain interface using a for each, that way it works dynamically.</p> <p>I've looked it up on Google, SO, RJ, YHA, and more Q&amp;A sites but nothing helps. It just explains if you already have a collection of them classes, and none show you how to do it from just an interface.</p> <p>For example, I need to get a list of Class1, 2 and 3, and any other clases that inherit IClass.</p> <pre><code>class Class1 : IClass {} class Class2 : IClass {} class Class3 : IClass {} </code></pre> <p>If I were to later on declare these, they would also be found.</p> <pre><code>class Class4 : IClass {} class Class5 : IClass {} class Class6 : IClass {} </code></pre>
0debug
static void mpegts_close_filter(MpegTSContext *ts, MpegTSFilter *filter) { int pid; pid = filter->pid; if (filter->type == MPEGTS_SECTION) av_freep(&filter->u.section_filter.section_buf); av_free(filter); ts->pids[pid] = NULL;
1threat
static void imx_timerp_write(void *opaque, target_phys_addr_t offset, uint64_t value, unsigned size) { IMXTimerPState *s = (IMXTimerPState *)opaque; DPRINTF("p-write(offset=%x, value = %x)\n", (unsigned int)offset >> 2, (unsigned int)value); switch (offset >> 2) { case 0: if (value & CR_SWR) { imx_timerp_reset(&s->busdev.qdev); value &= ~CR_SWR; } s->cr = value & 0x03ffffff; set_timerp_freq(s); if (s->freq && (s->cr & CR_EN)) { if (!(s->cr & CR_ENMOD)) { ptimer_set_count(s->timer, s->lr); } ptimer_run(s->timer, 0); } else { ptimer_stop(s->timer); } break; case 1: s->int_level = 0; imx_timerp_update(s); break; case 2: s->lr = value; ptimer_set_limit(s->timer, value, !!(s->cr & CR_IOVW)); break; case 3: s->cmp = value; if (value) { IPRINTF( "Values for EPIT comparison other than zero not supported\n" ); } break; default: IPRINTF("imx_timerp_write: Bad offset %x\n", (int)offset >> 2); } }
1threat
static void port92_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->no_user = 1; dc->realize = port92_realizefn; dc->reset = port92_reset; dc->vmsd = &vmstate_port92_isa; }
1threat
Integrate React-Semantic-UI and redux-form : <p>I'm using <strong>redux-form</strong> (awesome libs) to handle my form &amp; <strong>redux</strong> store in <strong>React</strong> app. Everything works well, important forms and nested json output.</p> <p>I'm trying to use <strong>React-Semantic-UI</strong> Component with <strong>redux-form</strong>. I searched inside the docs how about integrate custom component with redux form, and here we go : <a href="http://redux-form.com/6.5.0/docs/faq/CustomComponent.md/" rel="noreferrer">http://redux-form.com/6.5.0/docs/faq/CustomComponent.md/</a> Seems perfect.</p> <p>But when i integrate Semantic and this, it doenst work.</p> <p>This is my simple test with pseudo code :</p> <pre><code>const TestComponent = props =&gt; ( &lt;Form&gt; &lt;Field name="dropdownTest" component={ TestSelect } /&gt; &lt;/Form&gt; ) </code></pre> <p>and here my CustomComponent using Dropdown. You can found the dropdown documentation &amp; props (onChange &amp; value ) here :</p> <p><a href="http://react.semantic-ui.com/modules/dropdown" rel="noreferrer">http://react.semantic-ui.com/modules/dropdown</a></p> <pre><code>import Form , Dropdown from 'semantic-ui-react' import {myOption from './myOption' const TestSelect = field = ( &lt;Form.Field&gt; &lt;label&gt; Test dropdown &lt;/label&gt; &lt;Dropdown option={myOption} selection value={{val : field.input.value}} onChange={ param =&gt; field.input.onChange(param.val)} /&gt; &lt;/Form.Field&gt; ) </code></pre> <p>As in the documentation, I added value &amp; onChange props on my Custom Component.</p> <p>I clearly miss something here. Is someone have simple example with redux-form and semantc ui ? </p> <p>Thanks for helping.</p>
0debug
Kafka-connect sink task ignores file offset storage property : <p>I'm experiencing quite weird behavior working with Confluent JDBC connector. I'm pretty sure that it's not related to Confluent stack, but to Kafka-connect framework itself.</p> <p>So, I define <code>offset.storage.file.filename</code> property as default <code>/tmp/connect.offsets</code> and run my sink connector. Obviously, I expect connector to persist offsets in the given file (it doesn't exist on file system, but it should be automatically created, right?). Documentation says:</p> <blockquote> <p><code>offset.storage.file.filename</code> The file to store connector offsets in. By storing offsets on disk, a standalone process can be stopped and started on a single node and resume where it previously left off.</p> </blockquote> <p>But Kafka behaves in completely different manner.</p> <ol> <li>It checks if the given file exists.</li> <li>It it's not, Kafka just ignores it and persists offsets in Kafka topic.</li> <li>If I create given file manually, reading fails anyway (EOFException) and offsets are being persisted in topic again.</li> </ol> <p>Is it a bug or, more likely, I don't understand how to work with this configurations? I understand difference between two approaches to persist offsets and file storage is more convenient for my needs.</p>
0debug
Backslashing 2017-03-30 gives 7-03-30 Javascript : I am trying to output the current page URL for Disqus comments. Since my page URL structure is like: https://www.example.com/post/1234/2017-03-30/ I am having a little issue with backslahing. I don't know if this has been asked before, I tried searching for reasonable answer but couldn't find any. I am trying to backslash date, since including it like 2017-03-30 will only subtract it. This is the PHP code that outputs Javascript: echo 'this.page.url = "https://www.example.com/post/'. $id . '/\\'. $date . '\\/";'; This is the output: this.page.url = "https://www.example.com/post/1234/\2017-03-30\/"; But the problem is Disqus will show the URL like: https://www.example.com/post/1234/7-03-30 I know the problem is with \201 but what I don't know is how to fix it. I tried different ways. Nothing seems to be working. I am pretty much lost here. :/
0debug
static void truemotion1_decode_16bit(TrueMotion1Context *s) { int y; int pixels_left; unsigned int predictor_pair; unsigned int horiz_pred; unsigned int *vert_pred; unsigned int *current_pixel_pair; unsigned char *current_line = s->frame->data[0]; int keyframe = s->flags & FLAG_KEYFRAME; const unsigned char *mb_change_bits = s->mb_change_bits; unsigned char mb_change_byte; unsigned char mb_change_byte_mask; int mb_change_index; int index_stream_index = 0; int index; memset(s->vert_pred, 0, s->avctx->width * sizeof(unsigned int)); GET_NEXT_INDEX(); for (y = 0; y < s->avctx->height; y++) { horiz_pred = 0; current_pixel_pair = (unsigned int *)current_line; vert_pred = s->vert_pred; mb_change_index = 0; mb_change_byte = mb_change_bits[mb_change_index++]; mb_change_byte_mask = 0x01; pixels_left = s->avctx->width; while (pixels_left > 0) { if (keyframe || ((mb_change_byte & mb_change_byte_mask) == 0)) { switch (y & 3) { case 0: if (s->block_width == 2) { APPLY_C_PREDICTOR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); APPLY_C_PREDICTOR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); } else { APPLY_C_PREDICTOR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); } break; case 1: case 3: APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); break; case 2: if (s->block_type == BLOCK_2x2) { APPLY_C_PREDICTOR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); APPLY_C_PREDICTOR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); } else if (s->block_type == BLOCK_4x2) { APPLY_C_PREDICTOR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); } else { APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); APPLY_Y_PREDICTOR(); OUTPUT_PIXEL_PAIR(); } break; } } else { *vert_pred++ = *current_pixel_pair++; horiz_pred = *current_pixel_pair - *vert_pred; *vert_pred++ = *current_pixel_pair++; } if (!keyframe) { mb_change_byte_mask <<= 1; if (!mb_change_byte_mask) { mb_change_byte = mb_change_bits[mb_change_index++]; mb_change_byte_mask = 0x01; } } pixels_left -= 4; } if (((y + 1) & 3) == 0) mb_change_bits += s->mb_change_bits_row_size; current_line += s->frame->linesize[0]; } }
1threat
static void DEF(avg, pixels8_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h) { MOVQ_BFE(mm6); __asm__ volatile( "lea (%3, %3), %%"REG_a" \n\t" "movq (%1), %%mm0 \n\t" ".p2align 3 \n\t" "1: \n\t" "movq (%1, %3), %%mm1 \n\t" "movq (%1, %%"REG_a"), %%mm2 \n\t" PAVGBP(%%mm1, %%mm0, %%mm4, %%mm2, %%mm1, %%mm5) "movq (%2), %%mm3 \n\t" PAVGB_MMX(%%mm3, %%mm4, %%mm0, %%mm6) "movq (%2, %3), %%mm3 \n\t" PAVGB_MMX(%%mm3, %%mm5, %%mm1, %%mm6) "movq %%mm0, (%2) \n\t" "movq %%mm1, (%2, %3) \n\t" "add %%"REG_a", %1 \n\t" "add %%"REG_a", %2 \n\t" "movq (%1, %3), %%mm1 \n\t" "movq (%1, %%"REG_a"), %%mm0 \n\t" PAVGBP(%%mm1, %%mm2, %%mm4, %%mm0, %%mm1, %%mm5) "movq (%2), %%mm3 \n\t" PAVGB_MMX(%%mm3, %%mm4, %%mm2, %%mm6) "movq (%2, %3), %%mm3 \n\t" PAVGB_MMX(%%mm3, %%mm5, %%mm1, %%mm6) "movq %%mm2, (%2) \n\t" "movq %%mm1, (%2, %3) \n\t" "add %%"REG_a", %1 \n\t" "add %%"REG_a", %2 \n\t" "subl $4, %0 \n\t" "jnz 1b \n\t" :"+g"(h), "+S"(pixels), "+D"(block) :"r"((x86_reg)line_size) :REG_a, "memory"); }
1threat
void vga_reset(void *opaque) { VGAState *s = (VGAState *) opaque; s->lfb_addr = 0; s->lfb_end = 0; s->map_addr = 0; s->map_end = 0; s->lfb_vram_mapped = 0; s->bios_offset = 0; s->bios_size = 0; s->sr_index = 0; memset(s->sr, '\0', sizeof(s->sr)); s->gr_index = 0; memset(s->gr, '\0', sizeof(s->gr)); s->ar_index = 0; memset(s->ar, '\0', sizeof(s->ar)); s->ar_flip_flop = 0; s->cr_index = 0; memset(s->cr, '\0', sizeof(s->cr)); s->msr = 0; s->fcr = 0; s->st00 = 0; s->st01 = 0; s->dac_state = 0; s->dac_sub_index = 0; s->dac_read_index = 0; s->dac_write_index = 0; memset(s->dac_cache, '\0', sizeof(s->dac_cache)); s->dac_8bit = 0; memset(s->palette, '\0', sizeof(s->palette)); s->bank_offset = 0; #ifdef CONFIG_BOCHS_VBE s->vbe_index = 0; memset(s->vbe_regs, '\0', sizeof(s->vbe_regs)); s->vbe_regs[VBE_DISPI_INDEX_ID] = VBE_DISPI_ID0; s->vbe_start_addr = 0; s->vbe_line_offset = 0; s->vbe_bank_mask = (s->vram_size >> 16) - 1; #endif memset(s->font_offsets, '\0', sizeof(s->font_offsets)); s->graphic_mode = -1; s->shift_control = 0; s->double_scan = 0; s->line_offset = 0; s->line_compare = 0; s->start_addr = 0; s->plane_updated = 0; s->last_cw = 0; s->last_ch = 0; s->last_width = 0; s->last_height = 0; s->last_scr_width = 0; s->last_scr_height = 0; s->cursor_start = 0; s->cursor_end = 0; s->cursor_offset = 0; memset(s->invalidated_y_table, '\0', sizeof(s->invalidated_y_table)); memset(s->last_palette, '\0', sizeof(s->last_palette)); memset(s->last_ch_attr, '\0', sizeof(s->last_ch_attr)); switch (vga_retrace_method) { case VGA_RETRACE_DUMB: break; case VGA_RETRACE_PRECISE: memset(&s->retrace_info, 0, sizeof (s->retrace_info)); break; } }
1threat
static int omx_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet) { OMXCodecContext *s = avctx->priv_data; int ret = 0; OMX_BUFFERHEADERTYPE* buffer; OMX_ERRORTYPE err; if (frame) { uint8_t *dst[4]; int linesize[4]; int need_copy; buffer = get_buffer(&s->input_mutex, &s->input_cond, &s->num_free_in_buffers, s->free_in_buffers, 1); buffer->nFilledLen = av_image_fill_arrays(dst, linesize, buffer->pBuffer, avctx->pix_fmt, s->stride, s->plane_size, 1); if (s->input_zerocopy) { uint8_t *src[4] = { NULL }; int src_linesize[4]; av_image_fill_arrays(src, src_linesize, frame->data[0], avctx->pix_fmt, s->stride, s->plane_size, 1); if (frame->linesize[0] == src_linesize[0] && frame->linesize[1] == src_linesize[1] && frame->linesize[2] == src_linesize[2] && frame->data[1] == src[1] && frame->data[2] == src[2]) { AVFrame *local = av_frame_clone(frame); if (!local) { append_buffer(&s->input_mutex, &s->input_cond, &s->num_free_in_buffers, s->free_in_buffers, buffer); return AVERROR(ENOMEM); } else { buffer->pAppPrivate = local; buffer->pOutputPortPrivate = NULL; buffer->pBuffer = local->data[0]; need_copy = 0; } } else { uint8_t *buf = av_malloc(av_image_get_buffer_size(avctx->pix_fmt, s->stride, s->plane_size, 1)); if (!buf) { append_buffer(&s->input_mutex, &s->input_cond, &s->num_free_in_buffers, s->free_in_buffers, buffer); return AVERROR(ENOMEM); } else { buffer->pAppPrivate = buf; buffer->pOutputPortPrivate = (void*) 1; buffer->pBuffer = buf; need_copy = 1; buffer->nFilledLen = av_image_fill_arrays(dst, linesize, buffer->pBuffer, avctx->pix_fmt, s->stride, s->plane_size, 1); } } } else { need_copy = 1; } if (need_copy) av_image_copy(dst, linesize, (const uint8_t**) frame->data, frame->linesize, avctx->pix_fmt, avctx->width, avctx->height); buffer->nFlags = OMX_BUFFERFLAG_ENDOFFRAME; buffer->nOffset = 0; buffer->nTimeStamp = to_omx_ticks(av_rescale_q(frame->pts, avctx->time_base, AV_TIME_BASE_Q)); err = OMX_EmptyThisBuffer(s->handle, buffer); if (err != OMX_ErrorNone) { append_buffer(&s->input_mutex, &s->input_cond, &s->num_free_in_buffers, s->free_in_buffers, buffer); av_log(avctx, AV_LOG_ERROR, "OMX_EmptyThisBuffer failed: %x\n", err); return AVERROR_UNKNOWN; } s->num_in_frames++; } while (!*got_packet && ret == 0) { buffer = get_buffer(&s->output_mutex, &s->output_cond, &s->num_done_out_buffers, s->done_out_buffers, !frame && s->num_out_frames < s->num_in_frames); if (!buffer) break; if (buffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG && avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { if ((ret = av_reallocp(&avctx->extradata, avctx->extradata_size + buffer->nFilledLen + AV_INPUT_BUFFER_PADDING_SIZE)) < 0) { avctx->extradata_size = 0; goto end; } memcpy(avctx->extradata + avctx->extradata_size, buffer->pBuffer + buffer->nOffset, buffer->nFilledLen); avctx->extradata_size += buffer->nFilledLen; memset(avctx->extradata + avctx->extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); } else { if (buffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) s->num_out_frames++; if (!(buffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) || !pkt->data) { int newsize = s->output_buf_size + buffer->nFilledLen + AV_INPUT_BUFFER_PADDING_SIZE; if ((ret = av_reallocp(&s->output_buf, newsize)) < 0) { s->output_buf_size = 0; goto end; } memcpy(s->output_buf + s->output_buf_size, buffer->pBuffer + buffer->nOffset, buffer->nFilledLen); s->output_buf_size += buffer->nFilledLen; if (buffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) { if ((ret = av_packet_from_data(pkt, s->output_buf, s->output_buf_size)) < 0) { av_freep(&s->output_buf); s->output_buf_size = 0; goto end; } s->output_buf = NULL; s->output_buf_size = 0; } } else { if ((ret = ff_alloc_packet2(avctx, pkt, s->output_buf_size + buffer->nFilledLen, 0)) < 0) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size %d.\n", (int)(s->output_buf_size + buffer->nFilledLen)); goto end; } memcpy(pkt->data, s->output_buf, s->output_buf_size); memcpy(pkt->data + s->output_buf_size, buffer->pBuffer + buffer->nOffset, buffer->nFilledLen); av_freep(&s->output_buf); s->output_buf_size = 0; } if (buffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) { pkt->pts = av_rescale_q(from_omx_ticks(buffer->nTimeStamp), AV_TIME_BASE_Q, avctx->time_base); pkt->dts = pkt->pts; if (buffer->nFlags & OMX_BUFFERFLAG_SYNCFRAME) pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; } } end: err = OMX_FillThisBuffer(s->handle, buffer); if (err != OMX_ErrorNone) { append_buffer(&s->output_mutex, &s->output_cond, &s->num_done_out_buffers, s->done_out_buffers, buffer); av_log(avctx, AV_LOG_ERROR, "OMX_FillThisBuffer failed: %x\n", err); ret = AVERROR_UNKNOWN; } } return ret; }
1threat
what is side effects in javascript functional programming and may i get clear information with proper examples : <p>Many of the programming design patterns or programming styles discussion, they asking about the side effects of designs.</p> <p>what is side effects in javascript programming and may i get clear information with proper examples.</p>
0debug
yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint16_t *dest, uint16_t *uDest, uint16_t *vDest, uint16_t *aDest, int dstW, int chrDstW, int big_endian, int output_bits) { int i; int shift = 11 + 16 - output_bits; #define output_pixel(pos, val) \ if (big_endian) { \ if (output_bits == 16) { \ AV_WB16(pos, av_clip_uint16(val >> shift)); \ } else { \ AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \ } \ } else { \ if (output_bits == 16) { \ AV_WL16(pos, av_clip_uint16(val >> shift)); \ } else { \ AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \ } \ } for (i = 0; i < dstW; i++) { int val = 1 << (26-output_bits); int j; for (j = 0; j < lumFilterSize; j++) val += lumSrc[j][i] * lumFilter[j]; output_pixel(&dest[i], val); } if (uDest) { for (i = 0; i < chrDstW; i++) { int u = 1 << (26-output_bits); int v = 1 << (26-output_bits); int j; for (j = 0; j < chrFilterSize; j++) { u += chrUSrc[j][i] * chrFilter[j]; v += chrVSrc[j][i] * chrFilter[j]; } output_pixel(&uDest[i], u); output_pixel(&vDest[i], v); } } if (CONFIG_SWSCALE_ALPHA && aDest) { for (i = 0; i < dstW; i++) { int val = 1 << (26-output_bits); int j; for (j = 0; j < lumFilterSize; j++) val += alpSrc[j][i] * lumFilter[j]; output_pixel(&aDest[i], val); } } #undef output_pixel }
1threat
static bool qemu_gluster_test_seek(struct glfs_fd *fd) { off_t ret, eof; eof = glfs_lseek(fd, 0, SEEK_END); if (eof < 0) { return false; } ret = glfs_lseek(fd, eof, SEEK_DATA); return (ret < 0) && (errno == ENXIO); }
1threat
document.getElementById('input').innerHTML = user_input;
1threat
YouTube Data API returns "Access Not Configured" error, although it is enabled : <p>My internally used web solution to retrieve YouTube video statistics that is based on this example (<a href="https://developers.google.com/youtube/v3/quickstart/js" rel="noreferrer">https://developers.google.com/youtube/v3/quickstart/js</a>) now fails to work. Not sure when exactly it happened, but it used to work couple of months ago.</p> <p>I now tried to run unedited example code (apart from adjusting the CLIENT_ID, of course), and I am getting exactly the same error:</p> <pre><code>{ "domain": "usageLimits", "reason": "accessNotConfigured", "message": "Access Not Configured. YouTube Data API has not been used in project 123 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=123 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.", "extendedHelp": "https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=123" } ], "code": 403, "message": "Access Not Configured. YouTube Data API has not been used in project 123 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=123 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry." } </code></pre> <p>When I check the YouTube API in developer console, it shows enabled status, and the Credentials compatible with this API include the ID used to authenticate the client. I can see the statistics for credential use increment when I retry the API call attempts, and the metrics reflect the number of requests and also show that the error rate is 100%. But there is no extra info on those failed attempts in the console to help on debugging the problem.</p> <p>I have deleted and recreated API key and OAuth key, but that did not change anything.</p> <p>Had there been any extra info on those errors on the developer console side, for example client quote exceeded, I could see how to fix this. Now I am completely stuck.</p>
0debug
static uint64_t esp_pci_io_read(void *opaque, target_phys_addr_t addr, unsigned int size) { PCIESPState *pci = opaque; uint32_t ret; if (addr < 0x40) { ret = esp_reg_read(&pci->esp, addr >> 2); } else if (addr < 0x60) { ret = esp_pci_dma_read(pci, (addr - 0x40) >> 2); } else if (addr == 0x70) { trace_esp_pci_sbac_read(pci->sbac); ret = pci->sbac; } else { trace_esp_pci_error_invalid_read((int)addr); ret = 0; } ret >>= (addr & 3) * 8; ret &= ~(~(uint64_t)0 << (8 * size)); return ret; }
1threat
why this query takes so much time to execute ?please suggest for about efficiency of this query and is there is any better way to write this? : select Date,NeName,KPINAME,SUB_TYPE1,KPI from ggsn_kpi_2017 where date in ('2017-08-19','2017-08-18','2017-08-17','2017-08-16','2017-08-15','2017-08-14','2017-08-13') and KPINAME in('SM_SUCC_SESS_ACT_GGSN','SM_FAIL_SESS_ACT_GGSN','SM_SUCC_SESS_ACT_P_GW','SM_FAIL_SESS_ACT_P_GW','SM_SUCC_SESS_ACT_SAE_GW','SM_FAIL_SESS_ACT_SAE_GW','SM_DOWNLINK_BYTES_M2M','SM_UPLINK_BYTES_M2M') group by Date,NeName,KPINAME union select Date,NeName,KPINAME,SUB_TYPE1,KPI from ggsn_kpi_2016 where date in ('2017-08-19','2017-08-18','2017-08-17','2017-08-16','2017-08-15','2017-08-14','2017-08-13') and KPINAME in('SM_SUCC_SESS_ACT_GGSN','SM_FAIL_SESS_ACT_GGSN','SM_SUCC_SESS_ACT_P_GW','SM_FAIL_SESS_ACT_P_GW','SM_SUCC_SESS_ACT_SAE_GW','SM_FAIL_SESS_ACT_SAE_GW','SM_DOWNLINK_BYTES_M2M','SM_UPLINK_BYTES_M2M') group by Date,NeName,KPINAME
0debug
Angular 2\4 assets path files not found after prod build : <p>I have an Angular app and I have placed an image and custom font under assets folder(src/assets/images/bg.jpg and src/assets/fonts/segoeui.ttf).</p> <p>I have referenced bg.jpg and segoeui.ttf in scss file, like so:</p> <p>styles.css:</p> <pre><code>@font-face { font-family: "AppFont"; src: url("/assets/fonts/segoeui.ttf"); } @font-face { font-family: "AppFont"; src: url("/assets/fonts/segoeuib.ttf"); font-weight: bold; } html, body { font-family: 'AppFont', Verdana, Geneva, Tahoma, sans-serif; } </code></pre> <p>login.scss:</p> <pre><code>#login { background: url("/assets/images/bg.jpg"); background-position: center; background-attachment: fixed; background-size: cover; height: 100vh; } </code></pre> <p>And I am also using lazy loaded modules. Everything works as expected in development mode(when I run ng serve). However, when I release a prod build (ng build --prod), a dist folder is created with all js\css files. If I move these files in a virtual directory of a server, images and fonts stored in assets are pointing to root of the server, instead of pointing to the virtual directory. For example, I have project located in <code>myserver.com/myproject/index.html</code> whereas, this app looks for images in <code>myserver.com/assets/bg.jpg</code>, instead of <code>myserver.com/myproject/assets/bg.jpg</code> . Same problem with custom font too. Any idea if any of you have come across this issue? If yes, kindly let me know how to fix this. </p> <p>Earlier, even the built js\css files were referenced from root directory and not from virtual directory. To fix this, I changed index.html from <code>&lt;base href="/"&gt;</code> to <code>&lt;base href="./"&gt;</code></p> <p>Version details:</p> <pre><code>@angular/cli: 1.0.1 node: 6.10.2 os: win32 x64 @angular/common: 4.1.1 @angular/compiler: 4.1.1 @angular/core: 4.1.1 @angular/forms: 4.1.1 @angular/http: 4.1.1 @angular/platform-browser: 4.1.1 @angular/platform-browser-dynamic: 4.1.1 @angular/router: 4.1.1 @angular/cli: 1.0.1 @angular/compiler-cli: 4.1.1 </code></pre>
0debug
Stay signed in option with cookie-session in express : <p>I would like to have a "Stay signed in" option such as the one provided by Gmail. This way, the user <strong>can decide</strong> if they want to keep the session open upon opening a new browser session after previously closing it.</p> <p>Looking into the github issues I saw <a href="https://github.com/expressjs/cookie-session/issues/21#issuecomment-52973886">the cookie-session component doesn't provide a way to upate the <code>maxAge</code> property dynamilly</a>. </p> <p>I'm wondering then if there's any way at all to achieve the "Stay signed in" feature with the <code>cookie-session</code> component.</p> <p>It seems to me a basic feature for a component which is being downloaded <a href="https://www.npmjs.com/package/cookie-session">80K times a month</a>.</p>
0debug
static void test_sanity(void) { AHCIQState *ahci; ahci = ahci_boot(); ahci_shutdown(ahci); }
1threat
is one hot encoding is free of the dummy trap : <p>there is a thing called dummy trap in one hot encoder that is when we encode the categorical column with 3 categories lest say a,b,and c then with one hot encoder we get 3 categories like or columns a, b ,and c but when we use get_dummies we get 2 columns instead a, and b then it is save from dummy trap. is one hot encoding exposed to dummy trap or it takes care of it . am i right? which one is save of dummy trap? or is it ok to use both with our removing columns, iam using the dataset for many algorithms.</p> <p>looking for help . thanks in advance. </p>
0debug
static void gen_spr_620 (CPUPPCState *env) { spr_register(env, SPR_620_PMR0, "PMR0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_620_PMR1, "PMR1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_620_PMR2, "PMR2", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_620_PMR3, "PMR3", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_620_PMR4, "PMR4", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_620_PMR5, "PMR5", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_620_PMR6, "PMR6", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_620_PMR7, "PMR7", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_620_PMR8, "PMR8", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_620_PMR9, "PMR9", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_620_PMRA, "PMR10", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_620_PMRB, "PMR11", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_620_PMRC, "PMR12", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_620_PMRD, "PMR13", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_620_PMRE, "PMR14", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_620_PMRF, "PMR15", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_620_HID8, "HID8", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_620_HID9, "HID9", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); }
1threat
Random selection from array list : <p>I want to select a student randomly for <code>messfood()</code>. Trying to print the student name there.Each week, any of the student should be selected for mess food charge. Tried with <code>String random = list.get(new Random().nextInt(list.size()));</code>. But is shows error. Help me with this. </p> <pre><code>public class Student { int rollNo, yearOfStudy; String fName, lName, activity; Student(int rollNo, String fName, String lName, int yearOfStudy) { this.rollNo = rollNo; this.fName = fName; this.lName = lName; this.yearOfStudy = yearOfStudy; } public void display(){ System.out.println("Roll Number: "+rollNo +"\nName: "+fName+ " "+lName + "\nYear Of Study: "+yearOfStudy+"\n\n"); } public void messFood(){ System.out.println("week 1, Mess food Incharge: "); } } class Collection { public static void main(String[] args) { Student s1 = new Student(1, "Alex", "Iwobi", 2013); Student s2 = new Student(2, "Denis", "Suarez", 2013); Student s3 = new Student(3, "Gerard", "Deulofeu", 2013); Student s4 = new Student(4, "Petr", "Cech", 2013); List studentList = new ArrayList(); studentList.add(s1); studentList.add(s2); studentList.add(s3); studentList.add(s4); Iterator it = studentList.iterator(); while(it.hasNext()){ Student s=(Student)it.next(); s.display(); } } } </code></pre>
0debug
Compiling java on each line in a file as input : I am new to bash Scripting. I want to run a java program on script on each line of a file I am writing this script, but I don't know what's the correct script. I however am able to extract all the lines individually. Following is the script I use: #!/bin/bash IFS=$'\n' # make newlines the only separator set -f # disable globbing for i in $(cat "$1"); do java Interpreter $i >output.txt done I want the output to be in a file or atleast on the screen. Interpreter is the name of my program. Thanks in advance. :)
0debug
SQL Plus command line: Arrow keys not giving previous commands back : <p>I am using Oracle 10g Express Edition on Fedora core 5 32+ bit os. The problem is when I use the SQL Plus command line to make SQL statements I can not get the previously typed command back at the prompt when I use the up and down arrow keys on my keyboard. This is quite easy when I am using a shell, but here with this Oracle command line interface it is not working at all. Here is the example as what actually is happening whe I press the up or down arrow keys.</p> <p>SQL> drop table mailorders;</p> <p>Table dropped.</p> <p>SQL> ^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A</p>
0debug
TextView selected when entering a view in iOS : <p>I have a ViewController specifically for making a comment, it opens when "Comment" button is pressed in MainVC and only contains a UITextView.</p> <p>User has to click on the UITextView for the keyboard to appear to start typing.</p> <p>Is it possible to make the UITextView selected by default when entering the view?</p>
0debug