problem
stringlengths
26
131k
labels
class label
2 classes
Infinite child object type : <p>I need to create a Parent and Child class but A child class might contain Parent class, How can I do that in java?</p> <p>For example:</p> <pre><code>ParentClass { ChildClass childClass; } ChildClass { ParentClass parentClass; } </code></pre> <p>is this possible? and if possible, what is the term in Java?</p>
0debug
Easily check if a number is in a given Range in Dart? : <p>Is there an operator or function in Dart to easily verify if a number is in a range? Something like Kotlin <code>in</code> operator: </p> <p><a href="https://kotlinlang.org/docs/reference/ranges.html" rel="noreferrer">https://kotlinlang.org/docs/reference/ranges.html</a></p> <pre><code>if (i in 1..10) { // equivalent of 1 &lt;= i &amp;&amp; i &lt;= 10 println(i) } </code></pre>
0debug
static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret; ret = av_get_packet(s->pb, pkt, MP3_PACKET_SIZE); pkt->stream_index = 0; if (ret <= 0) { return AVERROR(EIO); } if (ret > ID3v1_TAG_SIZE && memcmp(&pkt->data[ret - ID3v1_TAG_SIZE], "TAG", 3) == 0) ret -= ID3v1_TAG_SIZE; pkt->size = ret; return ret; }
1threat
How to handle Web Workers "standard" syntax with webpack? : <p>I wonder if it's actually possible to handle Web Worker "standard syntax" in webpack (e.g <code>var worker = new Worker('my-worker-file.js');</code>) and how? </p> <p>I know about <a href="https://github.com/webpack/worker-loader">worker-loader</a> but as far as I understand it needs a specific syntax and is not compatible with the standard one.</p> <p>In other words, is it possible to bundle that file with webpack without changing the code? -> <a href="https://github.com/mdn/simple-web-worker/blob/gh-pages/main.js#L8">https://github.com/mdn/simple-web-worker/blob/gh-pages/main.js#L8</a></p> <p>With <a href="http://browserify.org/">browserify</a>, I would use <a href="https://www.npmjs.com/package/workerify">workerify</a> transform, but I can't find anything in webpack's world.</p>
0debug
static coroutine_fn void nbd_read_reply_entry(void *opaque) { NBDClientSession *s = opaque; uint64_t i; int ret = 0; Error *local_err = NULL; while (!s->quit) { assert(s->reply.handle == 0); ret = nbd_receive_reply(s->ioc, &s->reply, &local_err); if (ret < 0) { error_report_err(local_err); } if (ret <= 0) { break; } i = HANDLE_TO_INDEX(s, s->reply.handle); if (i >= MAX_NBD_REQUESTS || !s->requests[i].coroutine || !s->requests[i].receiving || (nbd_reply_is_structured(&s->reply) && !s->info.structured_reply)) { break; } aio_co_wake(s->requests[i].coroutine); qemu_coroutine_yield(); } s->quit = true; nbd_recv_coroutines_wake_all(s); s->read_reply_co = NULL; }
1threat
size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt, size_t iov_off, int fillc, size_t size) { size_t iovec_off, buf_off; unsigned int i; iovec_off = 0; buf_off = 0; for (i = 0; i < iov_cnt && size; i++) { if (iov_off < (iovec_off + iov[i].iov_len)) { size_t len = MIN((iovec_off + iov[i].iov_len) - iov_off , size); memset(iov[i].iov_base + (iov_off - iovec_off), fillc, len); buf_off += len; iov_off += len; size -= len; } iovec_off += iov[i].iov_len; } return buf_off; }
1threat
Get path to ActiveStorage file on disk : <p>I need to get the path to the file on disk which is using <code>ActiveStorage</code>. The file is stored locally.</p> <p>When I was using paperclip, I used the <code>path</code> method on the attachment which returned the full path.</p> <p>Example:</p> <pre><code>user.avatar.path </code></pre> <p>While looking at the <a href="http://edgeguides.rubyonrails.org/active_storage_overview.html#linking-to-files" rel="noreferrer"> Active Storage Docs</a>, it looked like <code>rails_blob_path</code> would do the trick. After looking at what it returned though, it does not provide the path to the document. Thus, it returns this error:</p> <blockquote> <p>No such file or directory @ rb_sysopen - </p> </blockquote> <p><strong>Background</strong></p> <p>I need the path to the document because I am using the <a href="https://rubygems.org/gems/combine_pdf" rel="noreferrer">combine_pdf</a> gem in order to combine multiple pdfs into a single pdf. </p> <p>For the paperclip implementation, I iterated through the full_paths of the selected pdf attachments and <code>load</code> them into the combined pdf:</p> <pre><code>attachment_paths.each {|att_path| report &lt;&lt; CombinePDF.load(att_path)} </code></pre>
0debug
$_POST is not what I expect it to be : <p>I want to write a very simple web page. There is only one button which triggers a POST method which is called on a PHP file. But the $_POST variable in the PHP file remains empty when the button is clicked. Here are my codes:</p> <p>index.html:</p> <pre><code>&lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;script src="script.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="jquery-3.4.1.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;meta charset="utf-8"&gt; &lt;/head&gt; &lt;body&gt; &lt;button type="button" onclick="mypost();"&gt;POST&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>script.js:</p> <pre><code>function mypost(){ $.post("test.php","Hello World!"); } </code></pre> <p>test.php:</p> <pre><code>&lt;?php print_r ($_POST); </code></pre>
0debug
static int fourxm_read_header(AVFormatContext *s) { AVIOContext *pb = s->pb; unsigned int fourcc_tag; unsigned int size; int header_size; FourxmDemuxContext *fourxm = s->priv_data; unsigned char *header; int i, ret; AVStream *st; fourxm->track_count = 0; fourxm->tracks = NULL; fourxm->fps = 1.0; avio_skip(pb, 12); GET_LIST_HEADER(); header_size = size - 4; if (fourcc_tag != HEAD_TAG || header_size < 0) return AVERROR_INVALIDDATA; header = av_malloc(header_size); if (!header) return AVERROR(ENOMEM); if (avio_read(pb, header, header_size) != header_size){ av_free(header); return AVERROR(EIO); for (i = 0; i < header_size - 8; i++) { fourcc_tag = AV_RL32(&header[i]); size = AV_RL32(&header[i + 4]); if (size > header_size - i - 8 && (fourcc_tag == vtrk_TAG || fourcc_tag == strk_TAG)) { av_log(s, AV_LOG_ERROR, "chunk larger than array %d>%d\n", size, header_size - i - 8); return AVERROR_INVALIDDATA; if (fourcc_tag == std__TAG) { fourxm->fps = av_int2float(AV_RL32(&header[i + 12])); } else if (fourcc_tag == vtrk_TAG) { if (size != vtrk_SIZE) { ret= AVERROR_INVALIDDATA; fourxm->width = AV_RL32(&header[i + 36]); fourxm->height = AV_RL32(&header[i + 40]); st = avformat_new_stream(s, NULL); if (!st){ ret= AVERROR(ENOMEM); avpriv_set_pts_info(st, 60, 1, fourxm->fps); fourxm->video_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_4XM; st->codec->extradata_size = 4; st->codec->extradata = av_malloc(4); AV_WL32(st->codec->extradata, AV_RL32(&header[i + 16])); st->codec->width = fourxm->width; st->codec->height = fourxm->height; i += 8 + size; } else if (fourcc_tag == strk_TAG) { int current_track; if (size != strk_SIZE) { ret= AVERROR_INVALIDDATA; current_track = AV_RL32(&header[i + 8]); if((unsigned)current_track >= UINT_MAX / sizeof(AudioTrack) - 1){ av_log(s, AV_LOG_ERROR, "current_track too large\n"); if (current_track + 1 > fourxm->track_count) { fourxm->tracks = av_realloc_f(fourxm->tracks, sizeof(AudioTrack), current_track + 1); if (!fourxm->tracks) { ret = AVERROR(ENOMEM); memset(&fourxm->tracks[fourxm->track_count], 0, sizeof(AudioTrack) * (current_track + 1 - fourxm->track_count)); fourxm->track_count = current_track + 1; fourxm->tracks[current_track].adpcm = AV_RL32(&header[i + 12]); fourxm->tracks[current_track].channels = AV_RL32(&header[i + 36]); fourxm->tracks[current_track].sample_rate = AV_RL32(&header[i + 40]); fourxm->tracks[current_track].bits = AV_RL32(&header[i + 44]); fourxm->tracks[current_track].audio_pts = 0; if( fourxm->tracks[current_track].channels <= 0 || fourxm->tracks[current_track].sample_rate <= 0 || fourxm->tracks[current_track].bits < 0){ av_log(s, AV_LOG_ERROR, "audio header invalid\n"); i += 8 + size; st = avformat_new_stream(s, NULL); if (!st){ ret= AVERROR(ENOMEM); st->id = current_track; avpriv_set_pts_info(st, 60, 1, fourxm->tracks[current_track].sample_rate); fourxm->tracks[current_track].stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_tag = 0; st->codec->channels = fourxm->tracks[current_track].channels; st->codec->sample_rate = fourxm->tracks[current_track].sample_rate; st->codec->bits_per_coded_sample = fourxm->tracks[current_track].bits; st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * st->codec->bits_per_coded_sample; st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample; if (fourxm->tracks[current_track].adpcm){ st->codec->codec_id = CODEC_ID_ADPCM_4XM; }else if (st->codec->bits_per_coded_sample == 8){ st->codec->codec_id = CODEC_ID_PCM_U8; }else st->codec->codec_id = CODEC_ID_PCM_S16LE; GET_LIST_HEADER(); if (fourcc_tag != MOVI_TAG){ ret= AVERROR_INVALIDDATA; av_free(header); fourxm->video_pts = -1; return 0; fail: av_freep(&fourxm->tracks); av_free(header); return ret;
1threat
When to use GO sync.Mutex with net/http and gorilla/mux? : As far as I know, the "net/http" package uses goroutines for the handlers. Is it necessary that I lock even a map with sync.Mutex in order to prevent possible bugs in the "nextId" function cause the function could count an old state of the map? Here is my example code: package main import ( "net/http" "github.com/gorilla/mux" "io/ioutil" "fmt" ) var testData = map[int]string { 1: "foo", 2: "bar", } func main() { r := mux.NewRouter() r.HandleFunc("/data", getData).Methods("GET") r.HandleFunc("/data", addData).Methods("POST") http.ListenAndServe(":3000", r) } func getData(writer http.ResponseWriter, request *http.Request) { for k, v := range testData { fmt.Fprintf(writer, "Key: %d\tValue: %v\n", k, v) } } func addData(writer http.ResponseWriter, request *http.Request) { if data, err := ioutil.ReadAll(request.Body); err == nil { if len(data) == 0 { writer.WriteHeader(http.StatusBadRequest) return } id := nextId() testData[id] = string(data) url := request.URL.String() writer.Header().Set("Location", fmt.Sprintf("%s", url)) writer.WriteHeader(http.StatusCreated) } else { writer.WriteHeader(http.StatusBadRequest) } } func nextId() int { id := 1 for k, _ := range testData { if k >= id { id = k + 1; } } return id }
0debug
Need a Regex to match an int of upto 8 digits including, leading or trailing 0's but not single digit "0" : <p>Need help with Regx, I want to match int of 8 digits including leading or trailing 0' but not single 0 EX: Should not match "0" Should match "00001234" "12345678" "00012000" "01234560 "00000001" (edited) </p>
0debug
I would like to transpose 3 rows into 3 columns like 2,3,4 row as 1,2,3 column, I tried using Macros coding but it didnt help me much : [This is my dataset which requires to be transposed][1] [1]: https://i.stack.imgur.com/6WVkE.png
0debug
convert dict in list to one dict : <pre><code>result = [{u'timestamp': 1464246000, u'value': 36.9}, {u'timestamp': 1464246900, u'value': 34.61}, {u'timestamp': 1464247200, u'value': 34.84}] zzz = {} for x in result: zzz[x['timestamp']] = x['value'] print zzz </code></pre> <p>{1464246000: 36.9, 1464247200: 34.84, 1464246900: 34.61}</p> <p>But, I need some like this(dict comprehension):</p> <pre><code>lst = [{'1': 'A'},{'2': 'B'},{'3': 'C'}] print {k:v for x in lst for k,v in x.items()} {'2': 'B', '3': 'C', '1': 'A'} </code></pre> <p>How to do this ?</p>
0debug
void show_licence(void) { printf( "ffmpeg version " FFMPEG_VERSION "\n" "Copyright (c) 2000, 2001, 2002 Gerard Lantau\n" "This program is free software; you can redistribute it and/or modify\n" "it under the terms of the GNU General Public License as published by\n" "the Free Software Foundation; either version 2 of the License, or\n" "(at your option) any later version.\n" "\n" "This program is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" "GNU General Public License for more details.\n" "\n" "You should have received a copy of the GNU General Public License\n" "along with this program; if not, write to the Free Software\n" "Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n" ); exit(1); }
1threat
Python: Importing csv with comma delimiter not working for me : I am having trouble importing a csv into python. I am importing a single column list of baseball player stats separated by commas and was trying to import it into python using `pd.read_csv` and setting the `delimiter=','`. But it did not work. I also tried to find the encoding and apply that but that also failed. Next I added `quoting=3`. This worked but then it caused the first column and all its values to have double quotes in front [(Pic of data frame)][1] and double quotes at the end of the last column and all its values. Also I am not sure why but as you see in the pic the second column has this strange y with a colon on it. Any help with this would be appreciated. Thanks! [1]: https://i.stack.imgur.com/0gKxv.png
0debug
Developing Heroku Addon : I read this documentation: https://devcenter.heroku.com/articles/building-an-add-on but I'm very confused about it. They only provide examples for the Ruby language, but is it possible to do this in an other language aswell (Java + Spring for example)? I tried to look up some examples on how to implement this but I can't find any. Thanks for your help!
0debug
Notice: Undefined index: action in /opt/lampp/htdocs/contacts.php on line 6 : <p>I was developing one simple PHP script in window machine and was testing in xampp. I have completed it and its working fine in my windows machine. Now I have tried to move it in my centos 7 machine which also have xampp. Its giving me error like below</p> <pre><code>Notice: Undefined index: action in /opt/lampp/htdocs/contacts.php on line 6 </code></pre> <p>My code for that function is like below</p> <pre><code>if($_GET['action']=="change_status" &amp;&amp; $_GET['contact_id']&gt;0 ) { $upd_qry = "update contacts set status = ? where id=?"; $stmt = mysqli_prepare($mysqli, $upd_qry); mysqli_stmt_bind_param($stmt, "ii", $_GET['status'],$_GET['contact_id']); $result = mysqli_stmt_execute($stmt); $_SESSION['msg']="11"; header( "Location:contacts.php"); exit; } </code></pre> <p>I have marked that similar errors in 1-2 more files too. I do not understanding why this happening. I have php 7.2 in my windows machine and in centos its 7.0 let me know if someone know what is wrong with it. Thanks</p>
0debug
How to compile and run haskell program in ubuntu linux system? : <p>I am new in ubuntu platform, i don't have idea how i can compile and run haskell code in ubuntu system, haskell is in my syllabus so i have to configure my system for haskell. Please show me the way.</p>
0debug
gcloud app deploy : This deployment has too many files : <p>I got the below error, when I tried to deploy my GAE app through gcloud.</p> <pre><code>Updating service [default]...failed. ERROR: (gcloud.app.deploy) Error Response: [400] This deployment has too many files. New versions are limited to 10000 files for this app. Details: [ [ { "@type": "type.googleapis.com/google.rpc.BadRequest", "fieldViolations": [ { "description": "This deployment has too many files. New versions are limited to 10000 files for this app.", "field": "version.deployment.files[...]" } ] } ] ] </code></pre> <p>Is there any way to tackle this problem? </p>
0debug
Superclass/Subclass methods : <p>I have a situation</p> <pre><code>public class Animal { String noise; public String makeNoise() { return noise; } } </code></pre> <p>Then there will be a subclass with the concrete definition of the noise.</p> <pre><code>public class Dog extends Animal{ String noise = "woof"; } </code></pre> <p>also</p> <pre><code>public class Cat extends Animal{ String noise = "meow"; } </code></pre> <p>What I want to do is</p> <pre><code> Animal cat = new Cat(); cat.makeNoise(); // This will be 'meow' </code></pre> <p>and </p> <pre><code>Animal dog = new Dog(); dog.makeNoise(); // This will be 'woof' </code></pre> <p>Basically, I don't want to repeat the makeNoise() method when I create an animal. However, this will not work. (Noise is an empty string)</p> <p>I could use a static object like </p> <pre><code>static String NoiseDog = "woof" static String NoiseCat = "meow" </code></pre> <p>but then again I have to write the makeNoise() method for each animal. Is there a better way to architect this?</p>
0debug
The usage of super() in Python : <p>I'm using Python 3.5 on Pycharm. And I tried to define 2 classes. The first one to be a superclass, the second to be its subclass. the code are as follows:<a href="https://i.stack.imgur.com/C3zm0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C3zm0.jpg" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/BtI5b.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BtI5b.jpg" alt="enter image description here"></a> and problem occurs: <a href="https://i.stack.imgur.com/FU0el.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FU0el.jpg" alt="enter image description here"></a> . The problem is with the p2 in the class Game (the second picture). </p> <p>It says :This inspection reports discrepancies between declared parameters and actual arguments, as well as incorrect arguments (e.g. duplicate named arguments) and incorrect argument order. Decorators are analyzed, too.</p> <p>So what's the problem here?</p>
0debug
Parse Factor in R : <p>I have a column of ID data (class factor) in the following format: 01-001 etc.</p> <p>I'd like to extract the first two digits (01) and create a separate column using these digits, ensuring they are numeric.</p> <p>I did this a few years ago but can't find my old code. Any help would be much appreciated.</p>
0debug
static inline int mpeg4_is_resync(MpegEncContext *s){ const int bits_count= get_bits_count(&s->gb); if(s->workaround_bugs&FF_BUG_NO_PADDING){ return 0; } if(bits_count + 8 >= s->gb.size*8){ int v= show_bits(&s->gb, 8); v|= 0x7F >> (7-(bits_count&7)); if(v==0x7F) return 1; }else{ if(show_bits(&s->gb, 16) == ff_mpeg4_resync_prefix[bits_count&7]){ int len; GetBitContext gb= s->gb; skip_bits(&s->gb, 1); align_get_bits(&s->gb); for(len=0; len<32; len++){ if(get_bits1(&s->gb)) break; } s->gb= gb; if(len>=ff_mpeg4_get_video_packet_prefix_length(s)) return 1; } } return 0; }
1threat
How SSH Tunnel from Windows VM to the host system, which is running Mac : <p>I am trying to ssh tunnel from a Windows VM to the host system, which is running Mac.</p> <p>I am running this command:</p> <pre><code>ssh -L 80:localhost:5454 10.0.2.2 </code></pre> <p>It then prompts me three times for a password like this:</p> <pre><code>Password: Password: Password: </code></pre> <p>Each time I enter my password for the windows vm, and it then prompts me for another password:</p> <pre><code>John Smith@10.0.2.2's password: </code></pre> <p>Now this I think is the password I am using for my Mac host system, but it says permission denied and thats it.</p> <p>So my question is what are these passwords referring to? My ssh password? Even though I have never set one of these up.</p> <p>Any help would be great!</p>
0debug
Scope Issue in java : <pre><code>public class Calculator { private int total; private int value; public Calculator(int startingValue){ int total = startingValue; value = 0; } public int add(int value){ int total = total + value; return total; } /** * Adds the instance variable value to the total */ public int add(){ int total += value; return total; } public int multiple(int value){ int total *= value; return total; } public void setValue(int value){ value = value; } public int getValue(){ return value; } } </code></pre> <p>The assignment says "For this exercise, we are going to take a look at an alternate Calculator class, but this one is broken. There are several scope issues in the calculator class that are preventing it from running.</p> <p>Your task is to fix the Calculator class so that it runs and prints out the correct results. The CalculatorTester is completed and should function correctly once you fix the Calculator class."</p> <p>I thought i did it right but it keeps telling me its wrong and the code will not run, how do i fix this scope issue?</p>
0debug
def max_sum_list(lists): return max(lists, key=sum)
0debug
Splitting sentences into strings accross multiple lines : Hi I'm trying to read and work with the text inside of a file. The problem is I need to split it into sentences and can't think of a way to do it... **Here's an example of the text file:** I went to a shop. I bought a pack of sausages and some milk. Sadly I forgot about the potatoes. I'm on my way to the store to buy potatoes. As you can see sentences can go across multiple lines before ending. I know i should use Regex but can't think of a way to do it...
0debug
echo OOP php method : <p>I had one lesson in OOP which included messaging between classes. On the tutorial, the guy just showed var_dump output version of that. I wanted to play with the code and change from var_dump to echo output, because it would me more useful in future. I just couldn't find any solution so you guys are my only option. Here's the code.</p> <pre><code>&lt;?php class Person { protected $name; public function __construct($name) { $this-&gt;name = $name; } public function getName() { return $this-&gt;name; } } class Business { // adding Staff class to Business public function __construct(Staff $staff) { $this-&gt;staff = $staff; } // manual hire(adding Person to Staff) public function hire(Person $person) { // add to staff $this-&gt;staff-&gt;add($person); } // fetch members public function getStaffMembers() { return $this-&gt;staff-&gt;members(); } } class Staff { // adding people from Person class to "member" variable protected $members = []; public function __construct($members = []) { $this-&gt;members = $members; } // adding person to members public function add(Person $person) { $this-&gt;members[] = $person; } public function members() { return $this-&gt;members; } } // you can also create an array with this method $bros = [ 'Bro', 'Zdenko', 'Miljan', 'Kesten' ]; // pretty simple to understand this part $employees = new Person([$bros]); $staff = new Staff([$employees]); $business = new Business($staff); var_dump($business-&gt;getStaffMembers()); // or the print_r, it doesn't matter print_r($business-&gt;getStaffMembers()); ?&gt; </code></pre>
0debug
static long do_rt_sigreturn_v1(CPUARMState *env) { abi_ulong frame_addr; struct rt_sigframe_v1 *frame = NULL; sigset_t host_set; frame_addr = env->regs[13]; if (frame_addr & 7) { goto badframe; } if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) goto badframe; target_to_host_sigset(&host_set, &frame->uc.tuc_sigmask); sigprocmask(SIG_SETMASK, &host_set, NULL); if (restore_sigcontext(env, &frame->uc.tuc_mcontext)) goto badframe; if (do_sigaltstack(frame_addr + offsetof(struct rt_sigframe_v1, uc.tuc_stack), 0, get_sp_from_cpustate(env)) == -EFAULT) goto badframe; #if 0 if (ptrace_cancel_bpt(current)) send_sig(SIGTRAP, current, 1); #endif unlock_user_struct(frame, frame_addr, 0); return env->regs[0]; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV ); return 0; }
1threat
First appearance of specific key in subhashes Ruby : I have a hash: hash = {{"number" => "7", "disk" => "70"},{"number" => "12", "disk" => "150", "global" => "yes"},{"number" => "8", "disk" => "250", "global" => "yes"}} I want to define a string containing of value of first "global" key appearance. I know how to loop over that hash but I can't figure out how to define the first appearance of that key.
0debug
Kotlin how to return a SINGLE object from a list that contains a specific id? : <p>Good day, i'm stuck figuring out how to get a single object from a list, i did google but all the topics show how to return a <code>List</code> with sorted objects or something similar.</p> <p>I have a <code>User Class</code></p> <pre><code>class User() { var email: String = "" var firstname: String = "" var lastname: String = "" var password: String = "" var image: String = "" var userId: String = "" constructor(email:String, firstname: String, lastname: String, password: String, image: String, userId : String) : this() { this.email = email this.firstname = firstname this.lastname = lastname this.password = password this.image = image this.userId = userId } } </code></pre> <p>In java i would write something like</p> <pre><code> User getUserById(String id) { User user = null; for(int i = 0; i &lt; myList.size;i++;) { if(id == myList.get(i).getUserId()) user = myList.get(i) } return user; } </code></pre> <p>How can i achieve the same result in kotlin?</p>
0debug
Getting the targetdir variable must be provided when invoking this installer while installing python 3.5 : <p>I have Python 2.7 on my Window 7. Problem is with python 3.5 and 3.6 version only.</p>
0debug
how can i api control this? : **how can i API control this?** i want use `ble` problem is that in api lower than 21 i should use `startlescan()` and in API 21 i should use `startscan()` and its scan callback that is not for API less than 21. how can i separate those code to have both in my app? [this is error][1] [1]: http://i.stack.imgur.com/r29WD.jpg i want something like this: if(api < 21) startlescan(); if(api >= 21) startscan();
0debug
Reconstructing an image after using extract_image_patches : <p>I have an autoencoder that takes an image as an input and produces a new image as an output.</p> <p>The input image (1x1024x1024x3) is split into patches (1024x32x32x3) before being fed to the network.</p> <p>Once I have the output, also a batch of patches size 1024x32x32x3, I want to be able to reconstruct a 1024x1024x3 image. I thought I had this sussed by simply reshaping, but here's what happened.</p> <p>First, the image as read by Tensorflow: <img src="https://i.imgur.com/euaZxKf.png" alt="Input image"></p> <p>I patched the image with the following code</p> <pre><code>patch_size = [1, 32, 32, 1] patches = tf.extract_image_patches([image], patch_size, patch_size, [1, 1, 1, 1], 'VALID') patches = tf.reshape(patches, [1024, 32, 32, 3]) </code></pre> <p>Here are a couple of patches from this image:</p> <p><img src="https://i.imgur.com/oseI4Cv.png[/img]" alt="Patched input #168"> <img src="https://i.imgur.com/s7g3l2B.png[/img]" alt="Patched input #169"></p> <p>But it's when I reshape this patch data back into an image that things go pear-shaped.</p> <pre><code>reconstructed = tf.reshape(patches, [1, 1024, 1024, 3]) converted = tf.image.convert_image_dtype(reconstructed, tf.uint8) encoded = tf.image.encode_png(converted) </code></pre> <p><img src="https://i.imgur.com/XI1CZwp.jpg[/img]" alt="Reconstructed output"></p> <p>In this example, no processing has been done between patching and reconstructing. I have made a <a href="https://pastebin.com/vPyRGcQG" rel="noreferrer">version of the code</a> you can use to test this behaviour. To use it, run the following:</p> <pre><code>echo "/path/to/test-image.png" &gt; inputs.txt mkdir images python3 image_test.py inputs.txt images </code></pre> <p>The code will make one input image, one patch image, and one output image for each of the 1024 patches in each input image, so comment out the lines that create input and output images if you're only concerned in saving all the patches.</p> <p>Somebody please explain what happened :(</p>
0debug
iOS - How to remove Japanese non-meaning spaces in swift 2.2 [URGENT] : I have a problem with String in Swift 2.2. I want to remove (or replace by "") the whitespace characters in a Japanese String like this: "こんにちわ    こんにちわ" But it seems that impossible. Plz help me!
0debug
int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl) { int list, index, pic_structure; print_short_term(h); print_long_term(h); for (list = 0; list < sl->list_count; list++) { memcpy(sl->ref_list[list], h->default_ref_list[list], sl->ref_count[list] * sizeof(sl->ref_list[0][0])); if (get_bits1(&sl->gb)) { int pred = h->curr_pic_num; for (index = 0; ; index++) { unsigned int modification_of_pic_nums_idc = get_ue_golomb_31(&sl->gb); unsigned int pic_id; int i; H264Picture *ref = NULL; if (modification_of_pic_nums_idc == 3) break; if (index >= sl->ref_count[list]) { av_log(h->avctx, AV_LOG_ERROR, "reference count overflow\n"); return -1; } switch (modification_of_pic_nums_idc) { case 0: case 1: { const unsigned int abs_diff_pic_num = get_ue_golomb(&sl->gb) + 1; int frame_num; if (abs_diff_pic_num > h->max_pic_num) { av_log(h->avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n"); return AVERROR_INVALIDDATA; } if (modification_of_pic_nums_idc == 0) pred -= abs_diff_pic_num; else pred += abs_diff_pic_num; pred &= h->max_pic_num - 1; frame_num = pic_num_extract(h, pred, &pic_structure); for (i = h->short_ref_count - 1; i >= 0; i--) { ref = h->short_ref[i]; assert(ref->reference); assert(!ref->long_ref); if (ref->frame_num == frame_num && (ref->reference & pic_structure)) break; } if (i >= 0) ref->pic_id = pred; break; } case 2: { int long_idx; pic_id = get_ue_golomb(&sl->gb); long_idx = pic_num_extract(h, pic_id, &pic_structure); if (long_idx > 31) { av_log(h->avctx, AV_LOG_ERROR, "long_term_pic_idx overflow\n"); return AVERROR_INVALIDDATA; } ref = h->long_ref[long_idx]; assert(!(ref && !ref->reference)); if (ref && (ref->reference & pic_structure)) { ref->pic_id = pic_id; assert(ref->long_ref); i = 0; } else { i = -1; } break; } default: av_log(h->avctx, AV_LOG_ERROR, "illegal modification_of_pic_nums_idc %u\n", modification_of_pic_nums_idc); return AVERROR_INVALIDDATA; } if (i < 0) { av_log(h->avctx, AV_LOG_ERROR, "reference picture missing during reorder\n"); memset(&sl->ref_list[list][index], 0, sizeof(sl->ref_list[0][0])); } else { for (i = index; i + 1 < sl->ref_count[list]; i++) { if (sl->ref_list[list][i].parent && ref->long_ref == sl->ref_list[list][i].parent->long_ref && ref->pic_id == sl->ref_list[list][i].pic_id) break; } for (; i > index; i--) { sl->ref_list[list][i] = sl->ref_list[list][i - 1]; } ref_from_h264pic(&sl->ref_list[list][index], ref); if (FIELD_PICTURE(h)) { pic_as_field(&sl->ref_list[list][index], pic_structure); } } } } } for (list = 0; list < sl->list_count; list++) { for (index = 0; index < sl->ref_count[list]; index++) { if ( !sl->ref_list[list][index].parent || (!FIELD_PICTURE(h) && (sl->ref_list[list][index].reference&3) != 3)) { int i; av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref_list[list][0].poc); for (i = 0; i < FF_ARRAY_ELEMS(h->last_pocs); i++) h->last_pocs[i] = INT_MIN; if (h->default_ref_list[list][0].parent && !(!FIELD_PICTURE(h) && (h->default_ref_list[list][0].reference&3) != 3)) sl->ref_list[list][index] = h->default_ref_list[list][0]; else return -1; } av_assert0(av_buffer_get_ref_count(sl->ref_list[list][index].parent->f->buf[0]) > 0); } } return 0; }
1threat
ReSampleContext *av_audio_resample_init(int output_channels, int input_channels, int output_rate, int input_rate, enum AVSampleFormat sample_fmt_out, enum AVSampleFormat sample_fmt_in, int filter_length, int log2_phase_count, int linear, double cutoff) { ReSampleContext *s; if (input_channels > MAX_CHANNELS) { av_log(NULL, AV_LOG_ERROR, "Resampling with input channels greater than %d is unsupported.\n", MAX_CHANNELS); return NULL; } if (output_channels > 2 && !(output_channels == 6 && input_channels == 2) && output_channels != input_channels) { av_log(NULL, AV_LOG_ERROR, "Resampling output channel count must be 1 or 2 for mono input; 1, 2 or 6 for stereo input; or N for N channel input.\n"); return NULL; } s = av_mallocz(sizeof(ReSampleContext)); if (!s) { av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for resample context.\n"); return NULL; } s->ratio = (float)output_rate / (float)input_rate; s->input_channels = input_channels; s->output_channels = output_channels; s->filter_channels = s->input_channels; if (s->output_channels < s->filter_channels) s->filter_channels = s->output_channels; s->sample_fmt[0] = sample_fmt_in; s->sample_fmt[1] = sample_fmt_out; s->sample_size[0] = av_get_bits_per_sample_fmt(s->sample_fmt[0]) >> 3; s->sample_size[1] = av_get_bits_per_sample_fmt(s->sample_fmt[1]) >> 3; if (s->sample_fmt[0] != AV_SAMPLE_FMT_S16) { if (!(s->convert_ctx[0] = av_audio_convert_alloc(AV_SAMPLE_FMT_S16, 1, s->sample_fmt[0], 1, NULL, 0))) { av_log(s, AV_LOG_ERROR, "Cannot convert %s sample format to s16 sample format\n", av_get_sample_fmt_name(s->sample_fmt[0])); av_free(s); return NULL; } } if (s->sample_fmt[1] != AV_SAMPLE_FMT_S16) { if (!(s->convert_ctx[1] = av_audio_convert_alloc(s->sample_fmt[1], 1, AV_SAMPLE_FMT_S16, 1, NULL, 0))) { av_log(s, AV_LOG_ERROR, "Cannot convert s16 sample format to %s sample format\n", av_get_sample_fmt_name(s->sample_fmt[1])); av_audio_convert_free(s->convert_ctx[0]); av_free(s); return NULL; } } #define TAPS 16 s->resample_context = av_resample_init(output_rate, input_rate, filter_length, log2_phase_count, linear, cutoff); *(const AVClass**)s->resample_context = &audioresample_context_class; return s; }
1threat
static int usb_serial_handle_control(USBDevice *dev, int request, int value, int index, int length, uint8_t *data) { USBSerialState *s = (USBSerialState *)dev; int ret; DPRINTF("got control %x, value %x\n",request, value); ret = usb_desc_handle_control(dev, request, value, index, length, data); if (ret >= 0) { return ret; } ret = 0; switch (request) { case DeviceRequest | USB_REQ_GET_STATUS: data[0] = (0 << USB_DEVICE_SELF_POWERED) | (dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP); data[1] = 0x00; ret = 2; break; case DeviceOutRequest | USB_REQ_CLEAR_FEATURE: if (value == USB_DEVICE_REMOTE_WAKEUP) { dev->remote_wakeup = 0; } else { goto fail; } ret = 0; break; case DeviceOutRequest | USB_REQ_SET_FEATURE: if (value == USB_DEVICE_REMOTE_WAKEUP) { dev->remote_wakeup = 1; } else { goto fail; } ret = 0; break; case DeviceRequest | USB_REQ_GET_CONFIGURATION: data[0] = 1; ret = 1; break; case DeviceOutRequest | USB_REQ_SET_CONFIGURATION: ret = 0; break; case DeviceRequest | USB_REQ_GET_INTERFACE: data[0] = 0; ret = 1; break; case InterfaceOutRequest | USB_REQ_SET_INTERFACE: ret = 0; break; case EndpointOutRequest | USB_REQ_CLEAR_FEATURE: ret = 0; break; case DeviceOutVendor | FTDI_RESET: switch (value) { case FTDI_RESET_SIO: usb_serial_reset(s); break; case FTDI_RESET_RX: s->recv_ptr = 0; s->recv_used = 0; break; case FTDI_RESET_TX: break; } break; case DeviceOutVendor | FTDI_SET_MDM_CTRL: { static int flags; qemu_chr_ioctl(s->cs,CHR_IOCTL_SERIAL_GET_TIOCM, &flags); if (value & FTDI_SET_RTS) { if (value & FTDI_RTS) flags |= CHR_TIOCM_RTS; else flags &= ~CHR_TIOCM_RTS; } if (value & FTDI_SET_DTR) { if (value & FTDI_DTR) flags |= CHR_TIOCM_DTR; else flags &= ~CHR_TIOCM_DTR; } qemu_chr_ioctl(s->cs,CHR_IOCTL_SERIAL_SET_TIOCM, &flags); break; } case DeviceOutVendor | FTDI_SET_FLOW_CTRL: break; case DeviceOutVendor | FTDI_SET_BAUD: { static const int subdivisors8[8] = { 0, 4, 2, 1, 3, 5, 6, 7 }; int subdivisor8 = subdivisors8[((value & 0xc000) >> 14) | ((index & 1) << 2)]; int divisor = value & 0x3fff; if (divisor == 1 && subdivisor8 == 0) subdivisor8 = 4; if (divisor == 0 && subdivisor8 == 0) divisor = 1; s->params.speed = (48000000 / 2) / (8 * divisor + subdivisor8); qemu_chr_ioctl(s->cs, CHR_IOCTL_SERIAL_SET_PARAMS, &s->params); break; } case DeviceOutVendor | FTDI_SET_DATA: switch (value & FTDI_PARITY) { case 0: s->params.parity = 'N'; break; case FTDI_ODD: s->params.parity = 'O'; break; case FTDI_EVEN: s->params.parity = 'E'; break; default: DPRINTF("unsupported parity %d\n", value & FTDI_PARITY); goto fail; } switch (value & FTDI_STOP) { case FTDI_STOP1: s->params.stop_bits = 1; break; case FTDI_STOP2: s->params.stop_bits = 2; break; default: DPRINTF("unsupported stop bits %d\n", value & FTDI_STOP); goto fail; } qemu_chr_ioctl(s->cs, CHR_IOCTL_SERIAL_SET_PARAMS, &s->params); break; case DeviceInVendor | FTDI_GET_MDM_ST: data[0] = usb_get_modem_lines(s) | 1; data[1] = 0; ret = 2; break; case DeviceOutVendor | FTDI_SET_EVENT_CHR: s->event_chr = value; break; case DeviceOutVendor | FTDI_SET_ERROR_CHR: s->error_chr = value; break; case DeviceOutVendor | FTDI_SET_LATENCY: s->latency = value; break; case DeviceInVendor | FTDI_GET_LATENCY: data[0] = s->latency; ret = 1; break; default: fail: DPRINTF("got unsupported/bogus control %x, value %x\n", request, value); ret = USB_RET_STALL; break; } return ret; }
1threat
static int raw_create(const char *filename, QemuOpts *opts, Error **errp) { int fd; int result = 0; int64_t total_size = 0; bool nocow = false; PreallocMode prealloc; char *buf = NULL; Error *local_err = NULL; strstart(filename, "file:", &filename); total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE); nocow = qemu_opt_get_bool(opts, BLOCK_OPT_NOCOW, false); buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC); prealloc = qapi_enum_parse(PreallocMode_lookup, buf, PREALLOC_MODE__MAX, PREALLOC_MODE_OFF, &local_err); g_free(buf); if (local_err) { error_propagate(errp, local_err); result = -EINVAL; goto out; } fd = qemu_open(filename, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0644); if (fd < 0) { result = -errno; error_setg_errno(errp, -result, "Could not create file"); goto out; } if (nocow) { #ifdef __linux__ int attr; if (ioctl(fd, FS_IOC_GETFLAGS, &attr) == 0) { attr |= FS_NOCOW_FL; ioctl(fd, FS_IOC_SETFLAGS, &attr); } #endif } if (ftruncate(fd, total_size) != 0) { result = -errno; error_setg_errno(errp, -result, "Could not resize file"); goto out_close; } switch (prealloc) { #ifdef CONFIG_POSIX_FALLOCATE case PREALLOC_MODE_FALLOC: result = -posix_fallocate(fd, 0, total_size); if (result != 0) { error_setg_errno(errp, -result, "Could not preallocate data for the new file"); } break; #endif case PREALLOC_MODE_FULL: { int64_t num = 0, left = total_size; buf = g_malloc0(65536); while (left > 0) { num = MIN(left, 65536); result = write(fd, buf, num); if (result < 0) { result = -errno; error_setg_errno(errp, -result, "Could not write to the new file"); break; } left -= result; } if (result >= 0) { result = fsync(fd); if (result < 0) { result = -errno; error_setg_errno(errp, -result, "Could not flush new file to disk"); } } g_free(buf); break; } case PREALLOC_MODE_OFF: break; default: result = -EINVAL; error_setg(errp, "Unsupported preallocation mode: %s", PreallocMode_lookup[prealloc]); break; } out_close: if (qemu_close(fd) != 0 && result == 0) { result = -errno; error_setg_errno(errp, -result, "Could not close the new file"); } out: return result; }
1threat
How to have a class in another class by different name? : So i have a class called Playership and i have another class called Game. I wanna have Playership class in Game class by the name of player. i don't know how to do that.
0debug
Can obfuscated code be useful sometimes? : <p>While creating a custom 3D <code>Point</code> class with single-precision coordinate values in C#, I had to write a method to calculate the distance between two points. Then I thought about the <code>A -&gt; B</code> graph notation meaning "from A to B", and I thought about overloading the <code>&gt;</code> operator, as it has no sense thinking about a point A being "greater" than a point B (besides, the <code>-&gt;</code> operator cannot be overloaded).</p> <p>So I created the following methods:</p> <pre><code>/// &lt;summary&gt; /// Calculates the Manhattan distance between the two points. /// &lt;/summary&gt; public static float operator&gt;(Point p1, Point p2) { return Math.Abs(p1.X - p2.X) + Math.Abs(p1.Y - p2.Y) + Math.Abs(p1.Z - p2.Z); } /// &lt;summary&gt; /// Calculates the euclidean distance between the two points. /// &lt;/summary&gt; public static double operator&gt;=(Point p1, Point p2) { return Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2) + Math.Pow(p1.Z - p2.Z, 2)); } </code></pre> <p>This results in code like this:</p> <pre><code>var manhattan = A &gt; B; var euclidean = A &gt;= B; </code></pre> <p>The code seems to be obfuscated but once you get the grasp of it, it is quite simple to read, and shorter than using <code>A.DistanceTo(B)</code>. </p> <p>The question is, should I completely avoid this kind of code? If so, what's the reason why? I am quite concerned with Clean Code, and I'm not sure this could be considered <em>clean</em> or not. If you think such code is sometimes allowed, could you provide examples?</p>
0debug
Css transition from display none to display block, navigation with subnav : <p>This is what I have <a href="https://jsfiddle.net/vour8ad9/" rel="noreferrer">jsFiddle link</a></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>nav.main ul ul { position: absolute; list-style: none; display: none; opacity: 0; visibility: hidden; padding: 10px; background-color: rgba(92, 91, 87, 0.9); -webkit-transition: opacity 600ms, visibility 600ms; transition: opacity 600ms, visibility 600ms; } nav.main ul li:hover ul { display: block; visibility: visible; opacity: 1; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;nav class="main"&gt; &lt;ul&gt; &lt;li&gt; &lt;a href=""&gt;Lorem&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=""&gt;Ipsum&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;Dolor&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;Sit&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;Amet&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/nav&gt;</code></pre> </div> </div> </p> <p>Why is there no transition? If I set </p> <pre><code>nav.main ul li:hover ul { display: block; visibility: visible; opacity: 0; /* changed this line */ } </code></pre> <p>Then the "subnav" will never appear (of course ) but why does the transition on the opacity not trigger? How to get the transition working?</p>
0debug
Random Colour Picker : I know this question has been asked before but I can never seem to find it in the right context. For my website, I want, upon loading the page, a random colour to be generated (1 of the rainbow). Then whenever I hover over a div (it is one that is repeated), that div/s will become the specified colour. .shape:hover { background-color: green; transition-duration: 0.1s; } That's the CSS. The current background colour is green but that's the property I want to be randomly selected upon the page loading. Thanks.
0debug
Tried detecting the a self created DeadLock : I wrote the below Java code for creating the Deadlock, I passed a resource String variable to the threads and locked it using **synchronized** block and put up an infinite loop inside that so that first thread will never ever leave it, so the second thread will not be able to access it forever. public class MainClass { public static void main(String[] args) { String resourcs = "testResource"; MainClass M = new MainClass(); Thread firstThread = new Thread(M.new MyThread("First",resourcs)); Thread seconThread = new Thread(M.new MyThread("Second",resourcs)); firstThread.start(); seconThread.start(); } class MyThread implements Runnable{ String resource; String name; public MyThread(String name,String resource) { this.resource = resource; this.name = name; } @Override public void run() { synchronized (resource) { while(true) { try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("Still working on the thread :"+name); } } } } } Then in the other window, I wrote the code for detecting the Deadlock like below, import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; import java.lang.management.ThreadMXBean; public class DetectDeadLock { public static void main(String args[]) { ThreadMXBean bean = ManagementFactory.getThreadMXBean(); long[] threadIds = bean.findDeadlockedThreads(); if (threadIds != null) { ThreadInfo[] infos = bean.getThreadInfo(threadIds); for (ThreadInfo info : infos) { StackTraceElement[] stack = info.getStackTrace(); System.out.println("here"); // Log or store stack trace information. } } } } But the Watch Dog detected nothing. ---------- 1. Have I created the dead lock correctly? (I think yes, because the console is only printing the first thread's code) 2. Do i have to wait for some time(idk how much) for the 'Watch Dog' code to detect the Deadlock?
0debug
iOS 10: cicontext.render() makes transparent areas black : <p>I'm using</p> <pre><code>ciContext.render(overlayImg, to: pixelBuffer, bounds: bufferFrame, colorSpace: nil) </code></pre> <p>where <code>overlayImg</code> is an image with transparent areas. Pre-iOS10 this worked as expected, but since iOS 10 the transparent areas are black.</p> <p>I don't know exactly what changed, but how can I achieve the rendering with transparency again?</p>
0debug
Create directory structure in unix : <p>I want to create directory structure based on year, month and julian day as given below.</p> <pre><code>/home/applications/app_name/year/month/julian day e.g.: /home/applications/app_name/2016/June/155 </code></pre> <p>I am writting a script to create such directories for next entire month and script will be scheduled monthly. if I am running the script on 01st of June, script should create all directories for month of July.</p> <pre><code>e.g: /home/applications/app_name/2016/July/(julian days) </code></pre> <p>Thanks in Advance</p>
0debug
whats the assert keysize doing hear : def encryptData(key, data,mode=AESModeOfOperation.modeOfOperation["CBC"]): """encrypt `data` using `key` `key` should be a string of bytes. returned cipher is a string of bytes prepended with the initialization vector. """ key = map(ord, key) if mode == AESModeOfOperation.modeOfOperation["CBC"]: data = append_PKCS7_padding(data) keysize = len(key) assert keysize in AES.keySize.values(), 'invalid key size: %s' % keysize # create a new iv using random data iv = [ord(i) for i in os.urandom(16)] moo = AESModeOfOperation() (mode, length, ciph) = moo.encrypt(data, mode, key, keysize, iv) # With padding, the original length does not need to be known. It's a bad # idea to store the original message length. # prepend the iv. return ''.join(map(chr, iv)) + ''.join(map(chr, ciph))
0debug
How to set Australia Sydney Time Zone in My app programatically : <p>I need it in my app. I searched some of the results but I could not get the correct Result. Whenever I am setting the Time Zone to Australia/Sydney it always returns the Current Location Time Zone. </p>
0debug
Compass Plugin for Cross (Android & Ios) : i wanna design compass with plugin if you have idea for this please share with me.. [enter image description here][1] [1]: https://i.stack.imgur.com/OEOg6.gif Thanks
0debug
How to load listview items scrolldown to 10 after 10 in android : <p>How to load listview items when scrolldown to 10 after 10 in android</p>
0debug
SQL: Get all rows where ID occurs : Given this data set: > ID ProductID quantity > > 1 1 4 > > 1 2 13 > > 1 4 12 > > 1 19 3 > > 2 19 4 > > 2 22 2 > > 2 2 6 > > 2 38 1 > > 2 14 4 > > 3 11 5 > > 3 12 6 > > 4 13 3 > > 4 14 11 > > 5 15 2 > > 6 16 3 > > 7 17 4 > > 8 18 9 > > 8 19 8 and my result set should look like this: > ID ProductID quantity > > 1 1 4 > > 1 2 13 > > 1 4 12 > > 1 19 3 > > 2 19 4 > > 2 22 2 > > 2 2 6 > > 2 38 1 > > 2 14 4 > > 8 18 9 > > 8 19 8 How does this work? i tried different types of subqueries and JOINS but i couldn't manage this. Thanks for any help in advance!
0debug
How to remove duplicated value with specail charecter from array in php : Here i have this array $myArray = array(5) { [0]=> string(62) "läs våra leveransvillkor/reservationer" [1]=> string(61) "läs våra leveransvillkor/reservationer" [2]=> string(60) "läs våra leveransvillkor/reservationer" [3]=> string(107) "om skorstenen bryter nock, ränndal, bjälke, el, vent etc tillkommer kostnad för vinklar eller avväxling" [4]=> string(59) "läs våra leveransvillkor/reservationer" } I have four values are the same so i want to keep only one. I did try to use array_unique , and even i did try this `array_map("unserialize", array_unique(array_map("serialize", $myArray)));` But i was not succeed in removing duplicates .I guess the issue is because of the special character . Any help would be appreciated .
0debug
Symbol to signify the root of a project : <p>Is there a well accepted symbol in the programming world for the root of a project?</p> <p>For example, the tilde ~ is the user's home directory, but this not just convention, but part of UNIX. </p> <p>I am looking for a symbol that is merely convention.</p>
0debug
Session has not been configured for this application or request error : <p>I am very new to asp.net I recently I came across this exception:</p> <blockquote> <p>System.InvalidOperationException</p> </blockquote> <p>The details of the exception says:</p> <blockquote> <p>Session has not been configured for this application or request.</p> </blockquote> <p>Here is the code snippet where it happens:</p> <pre><code>[HttpPost] public object Post([FromBody]loginCredentials value) { if (value.username.Equals("Admin") &amp;&amp; value.password.Equals("admin")) { HttpContext.Session.Set("userLogin", System.Text.UTF8Encoding.UTF8.GetBytes(value.username)); //This the line that throws the exception. return new { account = new { email = value.username } }; } throw new UnauthorizedAccessException("invalid credentials"); } </code></pre> <p>I have no idea why it's happening or what does this error actually mean. Can someone please explain what might be causing this?</p>
0debug
Bad Request - Invalid Hostname ASP.net Visual Studio 2015 : <p>After debugging my website in Visual Studio 2015, I can visit it via localhost:50544. I would like to visit my website on a different computer from which it is being served upon that is also on the same network. To do this I should be able to visit that computers address which is 192.168.1.13:50544.</p> <p>However when visiting this address I get a 'Bad request, invalid host name' error. Even if I visit it on the same machine as the website is being served on.</p> <p>Following the advice <a href="https://stackoverflow.com/questions/22044470/bad-request-invalid-hostname-while-connect-to-localhost-via-wifi-from-mobile-ph">here</a> I have created the following windows firewall rule and have also tried turning the firewall off entirely. <a href="https://i.stack.imgur.com/p30Oj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/p30Oj.png" alt="picture of firewall rule"></a></p> <p>I'm using IIS express and so have added to the '~\Documents\IISExpress\config\applicationhost.config' file</p> <pre><code>&lt;binding protocol="http" bindingInformation=":8080:localhost" /&gt; //original rule &lt;binding protocol="http" bindingInformation="*:50544:192.168.1.13" /&gt; </code></pre> <p>But visiting 192.168.1.13:50544 on any machine still results in the 'Bad Request' error. </p>
0debug
How to align 2 images with OpenCV with ORB? (fail to compile) : First of all, this is my first time using C++. I'm using C++ because OpenCV is very limited in C. OpenCV documentation isn't the most explicative I've seen. I have tried to rewrite this [ORB example][1] for use in my project. The code is: `img_orb.cpp`: /****************************************************************************** ******* headers ************************************************************** ******************************************************************************/ /* Standard (C++) ------------------------------------------------------------*/ /* std::vector */ #include <vector> /* Packages ------------------------------------------------------------------*/ /* opencv */ #include <opencv2/opencv.hpp> #include <opencv2/features2d/features2d.hpp> /* Project -------------------------------------------------------------------*/ #include "img_orb.hpp" /****************************************************************************** ******* macros *************************************************************** ******************************************************************************/ # define MAX_FEATURES (500) # define GOOD_MATCH_P (0.15) /****************************************************************************** ******* main ***************************************************************** ******************************************************************************/ void img_orb_align (struct _IplImage *pattern, struct _IplImage *imgptr) { /* Transform (struct _IplImage *) to (class cv::Mat) */ /* Make a copy so that they aren't modified */ class cv::Mat img_0; class cv::Mat img_1; img_0 = cv::cvarrToMat(pattern, true); img_1 = cv::cvarrToMat(imgptr, true); /* Variables to store keypoints & descriptors */ std::vector <class cv::KeyPoint> keypoints_0; std::vector <class cv::KeyPoint> keypoints_1; class cv::Mat descriptors_0; class cv::Mat descriptors_1; /* Detect ORB features & compute descriptors */ class cv::Ptr <class cv::Feature2D> orb; orb = cv::ORB::create(MAX_FEATURES); orb->detectAndCompute(img_0, cv::Mat(), keypoints_0, descriptors_0); orb->detectAndCompute(img_1, cv::Mat(), keypoints_1, descriptors_1); /* Match structures */ std::vector <struct cv::DMatch> matches; cv::Ptr <class cv::DescriptorMatcher> matcher; matcher = cv::DescriptorMatcher::create("BruteForce-Hamming"); matcher->match(descriptors_1, descriptors_0, matches, cv::Mat()); /* Sort matches by score */ std::sort(matches.begin(), matches.end()); /* Remove not so good matches */ int good_matches; good_matches = GOOD_MATCH_P * matches.size(); matches.erase(matches.begin() + good_matches, matches.end()); /* Draw top matches */ class cv::Mat img_matches; cv::drawMatches(img_1, keypoints_1, img_0, keypoints_0, matches, img_matches); cv::imwrite("matches.jpg", img_matches); /* Extract location of good matches */ std::vector <class cv::Point_ <float>> points_0; std::vector <class cv::Point_ <float>> points_1; int i; for (i = 0; i < matches.size(); i++) { points_1.push_back(keypoints_1[matches[i].queryIdx].pt); points_0.push_back(keypoints_0[matches[i].trainIdx].pt); } /* Find homography */ class cv::Mat img_hg; img_hg = cv::findHomography(points_1, points_0, CV_RANSAC); /* Use homography to warp image */ class cv::Mat img_align; cv::warpPerspective(img_1, img_align, img_hg, img_0.size()); /* Write img_align into imgptr */ *imgptr = img_align; } /****************************************************************************** ******* end of file ********************************************************** ******************************************************************************/ Note: When I write C, I always try to follow the Linux Kernel Coding Style; that's the reason I avoided `typedef`s, `namespace`s, and wrote `class` and all that stuff before everything; I like to have everything be very explicit. The first thing is that I had to remove `#include "opencv2/xfeatures2d.hpp"` because that header does not exist on my system (Debian Stretch). However, I read that header [here][2], and it doesn't seem to contain the solution to my problem. When I compile that file, I get the following errors: /.../img_orb.cpp: In function ‘void img_orb_align(_IplImage*, _IplImage*)’: /.../img_orb.cpp:78:36: error: no matching function for call to ‘cv::ORB::create(int)’ orb = cv::ORB::create(MAX_FEATURES); ^ In file included from /usr/include/opencv2/opencv.hpp:53:0, from /.../img_orb.cpp:19: /usr/include/opencv2/features2d/features2d.hpp:269:35: note: candidate: static cv::Ptr<cv::Feature2D> cv::Feature2D::create(const string&) CV_WRAP static Ptr<Feature2D> create( const string& name ); ^~~~~~ /usr/include/opencv2/features2d/features2d.hpp:269:35: note: no known conversion for argument 1 from ‘int’ to ‘const string& {aka const std::__cxx11::basic_string<char>&}’ /.../img_orb.cpp:79:7: error: ‘class cv::Feature2D’ has no member named ‘detectAndCompute’; did you mean ‘detectImpl’? orb->detectAndCompute(img_0, cv::Mat(), keypoints_0, descriptors_0); ^~~~~~~~~~~~~~~~ /.../img_orb.cpp:80:7: error: ‘class cv::Feature2D’ has no member named ‘detectAndCompute’; did you mean ‘detectImpl’? orb->detectAndCompute(img_1, cv::Mat(), keypoints_1, descriptors_1); ^~~~~~~~~~~~~~~~ Makefile:101: recipe for target 'img_orb.s' failed Is the example I took simply broken? Does it fail because I lack one header? Does it fail because I didn't understand some C++ stuff? Else? [1]: https://www.learnopencv.com/image-alignment-feature-based-using-opencv-c-python/ [2]: https://github.com/opencv/opencv_contrib/blob/master/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp
0debug
Got an exception while running the query in hql : @Query("select new map(count(t.status) as allCount,sum(case when t.status='Approved' then 1 else 0 end) as approvedCount, " + "sum(case when t.status='Overdue' then 1 else 0 end) as overdueCount," + "sum(case when t.status='Rejected' then 1 else 0 end) as rejectedCount," + "sum(case when t.status='Awaiting Approval' then 1 else 0 end) as awaitingApprovalCount," + "sum(case when t.status='Not Submitted' then 1 else 0 end) as notSubmittedCount) " + "from Timesheet as t where t.emplId=:employeeId and (t.startDate between date_add(:startDate, interval -6 day) and date_add(:endDate,interval 6 day))" + "and (t.endDate between date_add(:startDate, interval -6 day) and date_add(:endDate,interval 6 day))") where it throws an exception as org.hibernate.hql.internal.ast.QuerySyntaxException : Expecting CLOSE, found 'day' near line 1.
0debug
R Markdown: openBinaryFile: does not exist (No such file or directory) : <p>I've developed a shiny app that allows user to download a HTML report via R Markdown. I'm trying to include custom css and images into my rmarkdown file. However, I keep getting this error message:</p> <pre><code>pandoc: Could not fetch (either css or image file) openBinaryFile: does not exist (No such file or directory) </code></pre> <p>When I knit the .rmd file on R Studio, it is able to reference the image file or css that I want. However, when I run the Shiny app and download the html file, I get the above error message. I've even tried to put the images and css files in the same working directory as the .rmd file, but to no avail...</p> <pre><code>output: html_document: css: pandoc.css (same error message as above) </code></pre> <p>Been trying to find a solution for this but can't seem to...can anyone help here?</p>
0debug
I cannot able to add strings to my array list : public class Thirdfragment extends Fragment { List names = new ArrayList(); public Thirdfragment() { // Required empty public constructor } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ParseQuery<ParseObject> query = ParseQuery.getQuery("serviceop"); query.findInBackground(new FindCallback<ParseObject>() { public void done(List<ParseObject> objects, ParseException e) { if (e == null) { if (objects.size() > 0) { for (ParseObject object : objects) { String Currentdatatype = object.getString("name"); names.add("s"); Log.d("added",Currentdatatype); } } else { Log.d("no data","left or right"); } } else { Log.d("awserror","left or right"); } } }); // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_blank, container, false); RecyclerView rv = (RecyclerView) rootView.findViewById(R.id.rv_recycler_view); rv.setHasFixedSize(true); System.out.println("Using for loop"); System.out.println("--------------"); for (int i = 0; i < names.size(); i++) { System.out.println(names.get(i)); } System.out.println(names.size()); MyAdapter adapter = new MyAdapter(new String[]{"ssd","sd"}); rv.setAdapter(adapter); LinearLayoutManager llm = new LinearLayoutManager(getActivity()); rv.setLayoutManager(llm); return rootView; } } i need little hand here because i kept on trying add strings but the size of the names is still showing me 0 i dont why it is happening, in the logcat i dont see any values it still showing me the null value, i cannnot able to post log values here because the stack overflow is not accepting my question and they were showing some errors
0debug
static void realize(DeviceState *d, Error **errp) { sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(d); sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); Object *root_container; char link_name[256]; gchar *child_name; Error *err = NULL; DPRINTFN("drc realize: %x", drck->get_index(drc)); root_container = container_get(object_get_root(), DRC_CONTAINER_PATH); snprintf(link_name, sizeof(link_name), "%x", drck->get_index(drc)); child_name = object_get_canonical_path_component(OBJECT(drc)); DPRINTFN("drc child name: %s", child_name); object_property_add_alias(root_container, link_name, drc->owner, child_name, &err); if (err) { error_report("%s", error_get_pretty(err)); error_free(err); object_unref(OBJECT(drc)); } DPRINTFN("drc realize complete"); }
1threat
window.location.href = 'http://attack.com?user=' + user_input;
1threat
how to flip the elements of a list without using list[::-1] in PYTHON : <p>How can a I take a list of any size and reverse the order of the elements?</p> <p>list=[1,5,9,23....n]</p> <p>and it spits out [n...23,9,5,1] without using list[::-1]?</p>
0debug
How to set Go environment variables globally : <p>when I declare my Go environment (namely GOPATH and GOROOT using simple export:</p> <pre><code>export GOROOT=/usr/lib/go-1.9/ export GOPATH=/my/workspace/go </code></pre> <p>the current terminal recognizes the variables normally, but if I open another terminal window, these variables are not set and they need to be reconfigured from scratch. How can I change this variables to become permanent for the system (and all future terminals)? Is there some file I need to alter or should I execute a different command?</p>
0debug
My IP checker is checking if IP is technically valid, I want to check if it's online : <pre><code>import socket def is_valid_ipv4_address(address): try: socket.inet_pton(socket.AF_INET, address) except AttributeError: # no inet_pton here, sorry try: socket.inet_pton() except socket.error: return False return address.count('.') == 3 except socket.error: # not a valid address return False return True def is_valid_ipv6_address(address): try: socket.inet_pton(socket.AF_INET6, address) except AttributeError: # no inet_pton here, sorry try: socket.inet_pton() except socket.error: return False return address.count('.') == 3 except socket.error: # not a valid address return False return True def checkStatus(): websiteToCheck = input("Enter IP: ").replace(" ", "") if is_valid_ipv4_address(websiteToCheck) or is_valid_ipv6_address(websiteToCheck): print("Valid") elif len(websiteToCheck) == 0: print("Please input something") else: print("Invalid") checkStatus() </code></pre> <p>It gives the expected output when it's not valid, like when the number is over 255, when the input contains letters of the alphabet etc.. However, let's say I input 10.111.111.111 as my IP. It prints "Valid", even though if you tried to access that IP right now you'd fail.</p> <p>How do I check if an IP is online as opposed to whether it's numerically valid?</p>
0debug
static int ftp_shutdown(URLContext *h, int flags) { FTPContext *s = h->priv_data; av_dlog(h, "ftp protocol shutdown\n"); if (s->conn_data) return ffurl_shutdown(s->conn_data, flags); return AVERROR(EIO); }
1threat
JS: How to hide a bootstrap modal so that the input data doesn't persist? : <p>I have a modal I am including in my app and during the the checkout process, I <code>show</code> the modal. If the transaction fails, I hide the modal using <code>$('#my-modal').modal('hide')</code> but my issue is that when the user goes to enter the checkout process again and it shows the modal, it still has the data that was there before. Is it possible to destroy the instance so that the data doesn't persist that?</p>
0debug
Is there a communication standard for IP cameras? : <p>I am trying to chose an IP camera for outdoor surveillance, but I am not sure how I will be able to communicate with it. Afaik. these cameras have an IP address on the local network, which I can access to get the video stream. But what about the controlling part, like rotation, zoom, IR movement sensor, etc? Is there a communication standard for that, or should I try to find some kind of developer documentation?</p>
0debug
How can I make this code work? (lambda) (PyGtk) : So I am trying to work with the lambda function to connect the buttons of my calculator with a funtion. Here is some of my code: button1 = Gtk.Button(label = "1") lambda event: self.button_clicked(event, "1"), button1 vbox.pack_start(button1 ,True, True, 0) vbox.pack_end(button1,True,True,0) self.add(button1) def button_clicked(self, value): if (value != None): if (value != "="): # Add something to the text self.entry.set_text(self.entry.get_text() + str(value)) else: # Evaluate the text self.result = eval(self.entry.get_text()) self.entry.set_text(self.result) else: # Clear the text self.entry.set_text("") Am I using the lambda function the right way? And if not how can I change the code. I would appreciate an answer.
0debug
static void ivshmem_io_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { IVShmemState *s = opaque; uint16_t dest = val >> 16; uint16_t vector = val & 0xff; addr &= 0xfc; IVSHMEM_DPRINTF("writing to addr " TARGET_FMT_plx "\n", addr); switch (addr) { case INTRMASK: ivshmem_IntrMask_write(s, val); break; case INTRSTATUS: ivshmem_IntrStatus_write(s, val); break; case DOORBELL: if (dest > s->max_peer) { IVSHMEM_DPRINTF("Invalid destination VM ID (%d)\n", dest); break; } if (vector < s->peers[dest].nb_eventfds) { IVSHMEM_DPRINTF("Notifying VM %d on vector %d\n", dest, vector); event_notifier_set(&s->peers[dest].eventfds[vector]); } break; default: IVSHMEM_DPRINTF("Invalid VM Doorbell VM %d\n", dest); } }
1threat
FIlter data coloum with value in other file with python : I have the data file.log, I want to display all row from the four fields file.log that has the same value in the file list.txt from the results of other data filters example value in list.txt 2 3 7 10 12 etc this is my code import csv fileopen = open('file.log', 'r') fileout = open('fileout.txt', 'w') filefin = open('list.txt', 'r') for line in fileopen: col = line.split(',') if len(col) > 1 and col[3] in filefin.readlines(): fileout.write(line) else: pass fileopen.close() fileout.close() i have the problem. my code is not running
0debug
(react-window) How to pass props to {Row} in <FixedSizeList>{Row}</FixedSizeList> : <p>I am using library called <a href="https://github.com/bvaughn/react-window" rel="noreferrer">react-window</a></p> <p>When I pass props to its row like this:</p> <pre><code>{Row({...props, {otherProps}})} </code></pre> <p>it gave me an error something like:</p> <blockquote> <p>React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: ...</p> </blockquote> <p>How is the correct way to do that?</p>
0debug
static void mainstone_common_init(ram_addr_t ram_size, int vga_ram_size, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model, enum mainstone_model_e model, int arm_id) { uint32_t sector_len = 256 * 1024; target_phys_addr_t mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 }; struct pxa2xx_state_s *cpu; qemu_irq *mst_irq; int i, index; if (!cpu_model) cpu_model = "pxa270-c5"; if (ram_size < MAINSTONE_RAM + MAINSTONE_ROM + 2 * MAINSTONE_FLASH + PXA2XX_INTERNAL_SIZE) { fprintf(stderr, "This platform requires %i bytes of memory\n", MAINSTONE_RAM + MAINSTONE_ROM + 2 * MAINSTONE_FLASH + PXA2XX_INTERNAL_SIZE); exit(1); } cpu = pxa270_init(mainstone_binfo.ram_size, cpu_model); cpu_register_physical_memory(0, MAINSTONE_ROM, qemu_ram_alloc(MAINSTONE_ROM) | IO_MEM_ROM); cpu->env->regs[15] = mainstone_binfo.loader_start; for (i = 0; i < 2; i ++) { index = drive_get_index(IF_PFLASH, 0, i); if (index == -1) { fprintf(stderr, "Two flash images must be given with the " "'pflash' parameter\n"); exit(1); } if (!pflash_cfi01_register(mainstone_flash_base[i], qemu_ram_alloc(MAINSTONE_FLASH), drives_table[index].bdrv, sector_len, MAINSTONE_FLASH / sector_len, 4, 0, 0, 0, 0)) { fprintf(stderr, "qemu: Error registering flash memory.\n"); exit(1); } } mst_irq = mst_irq_init(cpu, MST_FPGA_PHYS, PXA2XX_PIC_GPIO_0); printf("map addr %p\n", &map); pxa27x_register_keypad(cpu->kp, map, 0xe0); pxa2xx_mmci_handlers(cpu->mmc, NULL, mst_irq[MMC_IRQ]); smc91c111_init(&nd_table[0], MST_ETH_PHYS, mst_irq[ETHERNET_IRQ]); mainstone_binfo.kernel_filename = kernel_filename; mainstone_binfo.kernel_cmdline = kernel_cmdline; mainstone_binfo.initrd_filename = initrd_filename; mainstone_binfo.board_id = arm_id; arm_load_kernel(cpu->env, &mainstone_binfo); }
1threat
static int preallocate(BlockDriverState *bs) { uint64_t nb_sectors; uint64_t offset; int num; int ret; QCowL2Meta meta; nb_sectors = bdrv_getlength(bs) >> 9; offset = 0; QLIST_INIT(&meta.dependent_requests); meta.cluster_offset = 0; while (nb_sectors) { num = MIN(nb_sectors, INT_MAX >> 9); ret = qcow2_alloc_cluster_offset(bs, offset, 0, num, &num, &meta); if (ret < 0) { return -1; } if (qcow2_alloc_cluster_link_l2(bs, &meta) < 0) { qcow2_free_any_clusters(bs, meta.cluster_offset, meta.nb_clusters); return -1; } run_dependent_requests(&meta); nb_sectors -= num; offset += num << 9; } if (meta.cluster_offset != 0) { uint8_t buf[512]; memset(buf, 0, 512); bdrv_write(bs->file, (meta.cluster_offset >> 9) + num - 1, buf, 1); } return 0; }
1threat
How to apt-get install in a GitHub action? : <p>In the new GitHub actions, I am trying to install a package in order to use it in one of the next steps.</p> <pre><code>name: CI on: [push, pull_request] jobs: translations: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 with: fetch-depth: 1 - name: Install xmllint run: apt-get install libxml2-utils # ... </code></pre> <p>However this fails with</p> <pre><code>Run apt-get install libxml2-utils apt-get install libxml2-utils shell: /bin/bash -e {0} E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root? ##[error]Process completed with exit code 100. </code></pre> <p>What's the best way to do this? Do it need to reach for Docker?</p>
0debug
python coin flip program that needs a repeat loop 10 times added and that is where i am stuck : I need to add a repeat loop that repeats the flip 10 times import random def coinflip() return random.randrange(2) if coinflip == 0: print("Heads") else: print("Tails")
0debug
Scipy sparse CSR matrix to TensorFlow SparseTensor - Mini-Batch gradient descent : <p>I have a Scipy sparse CSR matrix created from sparse TF-IDF feature matrix in SVM-Light format. The number of features is huge and it is sparse so I have to use a SparseTensor or else it is too slow. </p> <p>For example, number of features is 5, and a sample file can look like this:</p> <pre><code>0 4:1 1 1:3 3:4 0 5:1 0 2:1 </code></pre> <p>After parsing, the training set looks like this:</p> <pre><code>trainX = &lt;scipy CSR matrix&gt; trainY = np.array( [0,1,00] ) </code></pre> <p>I have two important questions:</p> <p>1) How I do convert this to a SparseTensor (sp_ids, sp_weights) efficiently so that I perform fast multiplication (W.X) using lookup: <a href="https://www.tensorflow.org/versions/master/api_docs/python/nn.html#embedding_lookup_sparse" rel="noreferrer">https://www.tensorflow.org/versions/master/api_docs/python/nn.html#embedding_lookup_sparse</a></p> <p>2) How do I randomize the dataset at each epoch and recalculate sp_ids, sp_weights to so that I can feed (feed_dict) for the mini-batch gradient descent.</p> <p>Example code on a simple model like logistic regression will be very appreciated. The graph will be like this:</p> <pre><code># GRAPH mul = tf.nn.embedding_lookup_sparse(W, X_sp_ids, X_sp_weights, combiner = "sum") # W.X z = tf.add(mul, b) # W.X + b cost_op = tf.reduce_sum(tf.nn.sigmoid_cross_entropy_with_logits(z, y_true)) # this already has built in sigmoid apply train_op = tf.train.GradientDescentOptimizer(0.05).minimize(cost_op) # construct optimizer predict_op = tf.nn.sigmoid(z) # sig(W.X + b) </code></pre>
0debug
Cant access to variable value in array : I have array of values var info_tab = [ ["Aaaa", 53.12040528310657, 23.258056640625,1,ikona3], ["Bbbb", 53.09402405506325, 18.0010986328125,2,ikona2], ]; And here I use it in function to pass value as parameters... Problem is with this section: label: info_tab[i][1] var markers = locations.map(function(location, i) { return new google.maps.Marker({ position: location, icon: ikona2, label: info_tab[i][1] }); }); And i got error Uncaught TypeError: Cannot read property '1' of undefined. I i show this via window.alert(info_tab[i][1]) it shows good value... Where is my mistake ?
0debug
void tcg_op_remove(TCGContext *s, TCGOp *op) { int next = op->next; int prev = op->prev; tcg_debug_assert(op != &s->gen_op_buf[0]); s->gen_op_buf[next].prev = prev; s->gen_op_buf[prev].next = next; memset(op, 0, sizeof(*op)); #ifdef CONFIG_PROFILER atomic_set(&s->prof.del_op_count, s->prof.del_op_count + 1); #endif }
1threat
Where do I find the object names of icons in the FontAwesome free packages? : <p><a href="https://fontawesome.com/" rel="noreferrer">FontAwesome</a> is a collection of libraries of icons. In their <a href="https://www.npmjs.com/package/@fortawesome/react-fontawesome" rel="noreferrer">Usage documentation</a>, they write as an example that you can use their coffee icon by importing the coffee icon's object from the free-solid-svg-icons package, like this:</p> <pre class="lang-js prettyprint-override"><code>import ReactDOM from 'react-dom' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faCoffee } from '@fortawesome/free-solid-svg-icons' const element = &lt;FontAwesomeIcon icon={faCoffee} /&gt; ReactDOM.render(element, document.body) </code></pre> <p>Looking at the <a href="https://fontawesome.com/icons/coffee?style=solid" rel="noreferrer">FontAwesome Coffee Icon documentation</a>, I can see no reference to what package the coffee icon is included in, or what its object name is. We know from the example code that its object name is <code>faCoffee</code> and that it's included in the <code>@fortawesome/free-solid-svg-icons</code> package, but what about any of the <a href="https://fontawesome.com/icons" rel="noreferrer">other 5,365 icons</a>?</p> <p><strong>Q:</strong> How can I find what React object name a FontAwesome icon has, and what React package it's included in?</p>
0debug
i want to convert multidimensional array to single array : I am having this array array ( 0 => array ( 'sno' => 'q3', 'result' => '15', ), 1 => array ( 'sno' => 'q1', 'result' => '5', ), 2 => array ( 'sno' => 'q2', 'result' => '10', ), ) i want this resulting array array ( 'q3' => '15', 'q1' => '5','q2' =>'10' ) without using any loop
0debug
Dynamic links in Facebook mobile app is not deep linked to app : <p><strong>Problem</strong> — when opening a Firebase Dynamic Link on Facebook Mobile, the Facebook Browser consumes the deep link and does not open the intended mobile app</p> <p><strong>Question</strong> — is there a good work around in <strong>Firebase</strong> to help Facebook deliver on the promise of presenting my Dynamic Link as intended? </p> <p>We are aware of <a href="http://applinks.org">http://applinks.org</a>, and that Facebook is a contributor. Does <strong>Firebase</strong> have a way to configure their server using the AppLinks spec, so that Facebook will pass through the Deep Link to our app instead of consuming it.</p> <p><strong>Background</strong> — I have created a <a href="https://firebase.google.com/docs/dynamic-links/">Firebase Dynamic Link</a> for an iOS and Android app. </p> <p>The Dynamic link delivers everything I expect, and is a fantastic experience.</p> <ol> <li>When opened on iOS, it navigates to the App. If not installed, goes App Store </li> <li>When opened on Android, it navigates to the App. If not installed, goes to Play Store</li> <li>When opened on non-mobile, it navigates to our Website</li> <li>On Facebook mobile, neither 1 nor 2 happens. Result is that it goes straight to the mobile web experience, thereby eliminating the promise of the Firebase Dynamic Link</li> </ol>
0debug
static inline void RENAME(yuy2ToY)(uint8_t *dst, uint8_t *src, long width) { #ifdef HAVE_MMX asm volatile( "movq "MANGLE(bm01010101)", %%mm2\n\t" "mov %0, %%"REG_a" \n\t" "1: \n\t" "movq (%1, %%"REG_a",2), %%mm0 \n\t" "movq 8(%1, %%"REG_a",2), %%mm1 \n\t" "pand %%mm2, %%mm0 \n\t" "pand %%mm2, %%mm1 \n\t" "packuswb %%mm1, %%mm0 \n\t" "movq %%mm0, (%2, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" " js 1b \n\t" : : "g" (-width), "r" (src+width*2), "r" (dst+width) : "%"REG_a ); #else int i; for(i=0; i<width; i++) dst[i]= src[2*i]; #endif }
1threat
how click on the edit button on any line : I want to click on the edit button in any row. For example, I would like to click on the edit button the record with 777DDD in it. Below is the html source of the Edit button: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <tbody><tr role="row" class="odd"><td class="font-w600 sorting_1">Müzakereli</td><td>05/01/2018 18:00</td><td class="hidden-xs"></td><td>GÖKHAN VOTING1</td><td class="text-center"><i class="fa fa-exclamation-circle fa-2x" id="meeting_info_1" style="color: rgb(92, 144, 210);"></i></td><td class="text-center"><div class="btn-group"><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Düzenle"><i class="fa fa-pencil"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Sil"><i class="fa fa-trash"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Toplantı Odası"><i class="si si-globe"></i></button><button class="btn btn-sm btn-info" type="button" data-toggle="tooltip" title="" data-original-title="Fiziksel Katılımcı Ekle "><i class="si si-user-follow"></i></button></div></td></tr><tr role="row" class="even"><td class="font-w600 sorting_1">Müzakereli</td><td>15/01/2018 08:12</td><td class="hidden-xs">15/01/2018 09:06</td><td>0070KEMAL1982-1</td><td class="text-center"><i class="fa fa-exclamation-circle fa-2x" id="meeting_info_4" style="color: rgb(92, 144, 210);"></i></td><td class="text-center"><div class="btn-group"><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Düzenle"><i class="fa fa-pencil"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Sil"><i class="fa fa-trash"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Toplantı Odası"><i class="si si-globe"></i></button><button class="btn btn-sm btn-info" type="button" data-toggle="tooltip" title="" data-original-title="Fiziksel Katılımcı Ekle "><i class="si si-user-follow"></i></button></div></td></tr><tr role="row" class="odd"><td class="font-w600 sorting_1">Müzakereli</td><td>16/01/2018 13:55</td><td class="hidden-xs">27/12/2017 22:00</td><td>SVL-SİLME</td><td class="text-center"><i class="fa fa-exclamation-circle fa-2x" id="meeting_info_5" style="color: rgb(92, 144, 210);"></i></td><td class="text-center"><div class="btn-group"><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Düzenle"><i class="fa fa-pencil"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Sil"><i class="fa fa-trash"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Toplantı Odası"><i class="si si-globe"></i></button><button class="btn btn-sm btn-info" type="button" data-toggle="tooltip" title="" data-original-title="Fiziksel Katılımcı Ekle "><i class="si si-user-follow"></i></button></div></td></tr><tr role="row" class="even"><td class="font-w600 sorting_1">Müzakereli</td><td>23/01/2018 15:37</td><td class="hidden-xs"></td><td>NİSA TEST Votin</td><td class="text-center"><i class="fa fa-exclamation-circle fa-2x" id="meeting_info_6" style="color: rgb(92, 144, 210);"></i></td><td class="text-center"><div class="btn-group"><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Düzenle"><i class="fa fa-pencil"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Sil"><i class="fa fa-trash"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Toplantı Odası"><i class="si si-globe"></i></button><button class="btn btn-sm btn-info" type="button" data-toggle="tooltip" title="" data-original-title="Fiziksel Katılımcı Ekle "><i class="si si-user-follow"></i></button></div></td></tr><tr role="row" class="odd"><td class="font-w600 sorting_1">Müzakereli</td><td>23/01/2018 15:42</td><td class="hidden-xs"></td><td>NISA2323</td><td class="text-center"><i class="fa fa-exclamation-circle fa-2x" id="meeting_info_7" style="color: rgb(92, 144, 210);"></i></td><td class="text-center"><div class="btn-group"><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Düzenle"><i class="fa fa-pencil"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Sil"><i class="fa fa-trash"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Toplantı Odası"><i class="si si-globe"></i></button><button class="btn btn-sm btn-info" type="button" data-toggle="tooltip" title="" data-original-title="Fiziksel Katılımcı Ekle "><i class="si si-user-follow"></i></button></div></td></tr><tr role="row" class="even"><td class="font-w600 sorting_1">Müzakereli</td><td>25/01/2018 15:21</td><td class="hidden-xs"></td><td>TEST2328</td><td class="text-center"><i class="fa fa-exclamation-circle fa-2x" id="meeting_info_8" style="color: rgb(92, 144, 210);"></i></td><td class="text-center"><div class="btn-group"><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Düzenle"><i class="fa fa-pencil"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Sil"><i class="fa fa-trash"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Toplantı Odası"><i class="si si-globe"></i></button><button class="btn btn-sm btn-info" type="button" data-toggle="tooltip" title="" data-original-title="Fiziksel Katılımcı Ekle "><i class="si si-user-follow"></i></button></div></td></tr><tr role="row" class="odd"><td class="font-w600 sorting_1">Müzakereli</td><td>26/01/2018 00:00</td><td class="hidden-xs"></td><td>777DDD</td><td class="text-center"><i class="fa fa-exclamation-circle fa-2x" id="meeting_info_9" style="color: rgb(92, 144, 210);"></i></td><td class="text-center"><div class="btn-group"><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Düzenle"><i class="fa fa-pencil"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Sil"><i class="fa fa-trash"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Toplantı Odası"><i class="si si-globe"></i></button><button class="btn btn-sm btn-info" type="button" data-toggle="tooltip" title="" data-original-title="Fiziksel Katılımcı Ekle "><i class="si si-user-follow"></i></button></div></td></tr><tr role="row" class="even"><td class="font-w600 sorting_1">Müzakereli</td><td>26/01/2018 09:18</td><td class="hidden-xs"></td><td>NISA2301</td><td class="text-center"><i class="fa fa-exclamation-circle fa-2x" id="meeting_info_10" style="color: rgb(92, 144, 210);"></i></td><td class="text-center"><div class="btn-group"><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Düzenle"><i class="fa fa-pencil"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Sil"><i class="fa fa-trash"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Toplantı Odası"><i class="si si-globe"></i></button><button class="btn btn-sm btn-info" type="button" data-toggle="tooltip" title="" data-original-title="Fiziksel Katılımcı Ekle "><i class="si si-user-follow"></i></button></div></td></tr><tr role="row" class="odd"><td class="font-w600 sorting_1">Müzakereli</td><td>01/07/2018 00:00</td><td class="hidden-xs"></td><td>888SSS</td><td class="text-center"><i class="fa fa-exclamation-circle fa-2x" id="meeting_info_11" style="color: rgb(92, 144, 210);"></i></td><td class="text-center"><div class="btn-group"><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Düzenle"><i class="fa fa-pencil"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Sil"><i class="fa fa-trash"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Toplantı Odası"><i class="si si-globe"></i></button><button class="btn btn-sm btn-info" type="button" data-toggle="tooltip" title="" data-original-title="Fiziksel Katılımcı Ekle "><i class="si si-user-follow"></i></button></div></td></tr><tr role="row" class="even"><td class="font-w600 sorting_1">Müzakeresiz</td><td></td><td class="hidden-xs">04/01/2018 23:19</td><td>SİLME - FURKAN</td><td class="text-center"></td><td class="text-center"><div class="btn-group"><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Düzenle"><i class="fa fa-pencil"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Sil"><i class="fa fa-trash"></i></button><button class="btn btn-sm btn-default" type="button" data-toggle="tooltip" title="" data-original-title="Toplantı Odası"><i class="si si-globe"></i></button><button class="btn btn-sm btn-info" type="button" data-toggle="tooltip" disabled="" title="" data-original-title="Fiziksel Katılımcı Ekle "><i class="si si-user-follow"></i></button></div></td></tr></tbody> <!-- end snippet --> Thank you so much.
0debug
Where sources committed to Git are stored in the server? : <p>I created a shared Git repository in the server:</p> <pre><code>git init --bare repo_name.git </code></pre> <p>All works fine, I can clone the repository to the local folder and commit the files to the repository.</p> <p>But I do not see commited files in my <em>repo_name.git</em> directory in the server, only config files:</p> <ul> <li>branches</li> <li>config</li> <li>description</li> <li>HEAD</li> <li>hooks</li> <li>info</li> <li>objects</li> <li>refs</li> </ul> <p>So there my committed sources are stored in the server?</p>
0debug
make complex dictionary with two arrays : I have df1 and df2. for each element in df1 I want to check if it exist in df2 and print df3 df1=['c_1', 'd_1', 'f_1', 'h_1', 'i_1', 'n_1', 'v_1', 'm_1'] df2=[['lia', 'f_1', 'n_1', 'v_1'], ['eli', 'f_1', 'n_1', 'v_1', 'm_1']] I want an output like this df3=[('f_1', {'lia': 1}), ('n_1', {'lia': 1}), ('v_1', {'lia': 1}),('c_1', {'lia': 0}), ('d_1', {'lia': 0}), ('h_1', {'lia': 0}), ('i_1', {'lia': 0}), ('m_1', {'lia': 0}), ('f_1', {'eli': 1}), ...] I tried some ilterations but it didn't work. If you want I can share them. Thanks
0debug
Division with if condition : <p>I just start learning ruby with an online course and in my very first exercise, I can't complete the challenge. I have to create functions to sum, subtract, multiply and divide that meet the specs conditions.</p> <p>For the division, I need to check if it will divide per 0 or not, give the result or a warning. My code is </p> <pre><code>def divisao(primeiro_numero, segundo_numero) if segundo_numero &gt; 0 primeiro_numero / segundo_numero else puts 'Opa! Zero como divisor' end </code></pre> <p>But when I run the specs, I get the following warning</p> <pre><code>0 examples, 0 failures, 1 error occurred outside of examples </code></pre> <p>I have changed all the functions, but this one doesn't seem to work. I added the complete functions and specs file here:<a href="https://gist.github.com/isafloriano/86c170400b2f5fc63dc5e8edd8913525" rel="nofollow noreferrer">https://gist.github.com/isafloriano/86c170400b2f5fc63dc5e8edd8913525</a></p> <p>Can anyone give me a clue why this doesn't work?</p>
0debug
static void diag288_timer_expired(void *dev) { qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n"); watchdog_perform_action(); switch (get_watchdog_action()) { case WDT_DEBUG: case WDT_NONE: case WDT_PAUSE: return; } wdt_diag288_reset(dev); }
1threat
static double bessel(double x){ double v=1; double lastv=0; double t=1; int i; static const double inv[100]={ 1.0/( 1* 1), 1.0/( 2* 2), 1.0/( 3* 3), 1.0/( 4* 4), 1.0/( 5* 5), 1.0/( 6* 6), 1.0/( 7* 7), 1.0/( 8* 8), 1.0/( 9* 9), 1.0/(10*10), 1.0/(11*11), 1.0/(12*12), 1.0/(13*13), 1.0/(14*14), 1.0/(15*15), 1.0/(16*16), 1.0/(17*17), 1.0/(18*18), 1.0/(19*19), 1.0/(20*20), 1.0/(21*21), 1.0/(22*22), 1.0/(23*23), 1.0/(24*24), 1.0/(25*25), 1.0/(26*26), 1.0/(27*27), 1.0/(28*28), 1.0/(29*29), 1.0/(30*30), 1.0/(31*31), 1.0/(32*32), 1.0/(33*33), 1.0/(34*34), 1.0/(35*35), 1.0/(36*36), 1.0/(37*37), 1.0/(38*38), 1.0/(39*39), 1.0/(40*40), 1.0/(41*41), 1.0/(42*42), 1.0/(43*43), 1.0/(44*44), 1.0/(45*45), 1.0/(46*46), 1.0/(47*47), 1.0/(48*48), 1.0/(49*49), 1.0/(50*50), 1.0/(51*51), 1.0/(52*52), 1.0/(53*53), 1.0/(54*54), 1.0/(55*55), 1.0/(56*56), 1.0/(57*57), 1.0/(58*58), 1.0/(59*59), 1.0/(60*60), 1.0/(61*61), 1.0/(62*62), 1.0/(63*63), 1.0/(64*64), 1.0/(65*65), 1.0/(66*66), 1.0/(67*67), 1.0/(68*68), 1.0/(69*69), 1.0/(70*70), 1.0/(71*71), 1.0/(72*72), 1.0/(73*73), 1.0/(74*74), 1.0/(75*75), 1.0/(76*76), 1.0/(77*77), 1.0/(78*78), 1.0/(79*79), 1.0/(80*80), 1.0/(81*81), 1.0/(82*82), 1.0/(83*83), 1.0/(84*84), 1.0/(85*85), 1.0/(86*86), 1.0/(87*87), 1.0/(88*88), 1.0/(89*89), 1.0/(90*90), 1.0/(91*91), 1.0/(92*92), 1.0/(93*93), 1.0/(94*94), 1.0/(95*95), 1.0/(96*96), 1.0/(97*97), 1.0/(98*98), 1.0/(99*99), 1.0/(10000) }; x= x*x/4; for(i=0; v != lastv; i++){ lastv=v; t *= x*inv[i]; v += t; } return v; }
1threat
static void s390_virtio_serial_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass); k->init = s390_virtio_serial_init; dc->props = s390_virtio_serial_properties; dc->alias = "virtio-serial"; }
1threat
static av_cold int libopenjpeg_encode_close(AVCodecContext *avctx) { LibOpenJPEGContext *ctx = avctx->priv_data; opj_destroy_compress(ctx->compress); opj_image_destroy(ctx->image); av_freep(&avctx->coded_frame); return 0; }
1threat
static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) { LavfiContext *lavfi = avctx->priv_data; double min_pts = DBL_MAX; int stream_idx, min_pts_sink_idx = 0; AVFrame *frame = lavfi->decoded_frame; AVPicture pict; AVDictionary *frame_metadata; int ret, i; int size = 0; if (lavfi->subcc_packet.size) { *pkt = lavfi->subcc_packet; av_init_packet(&lavfi->subcc_packet); lavfi->subcc_packet.size = 0; lavfi->subcc_packet.data = NULL; return pkt->size; } for (i = 0; i < lavfi->nb_sinks; i++) { AVRational tb = lavfi->sinks[i]->inputs[0]->time_base; double d; int ret; if (lavfi->sink_eof[i]) continue; ret = av_buffersink_get_frame_flags(lavfi->sinks[i], frame, AV_BUFFERSINK_FLAG_PEEK); if (ret == AVERROR_EOF) { av_dlog(avctx, "EOF sink_idx:%d\n", i); lavfi->sink_eof[i] = 1; continue; } else if (ret < 0) return ret; d = av_rescale_q_rnd(frame->pts, tb, AV_TIME_BASE_Q, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); av_dlog(avctx, "sink_idx:%d time:%f\n", i, d); av_frame_unref(frame); if (d < min_pts) { min_pts = d; min_pts_sink_idx = i; } } if (min_pts == DBL_MAX) return AVERROR_EOF; av_dlog(avctx, "min_pts_sink_idx:%i\n", min_pts_sink_idx); av_buffersink_get_frame_flags(lavfi->sinks[min_pts_sink_idx], frame, 0); stream_idx = lavfi->sink_stream_map[min_pts_sink_idx]; if (frame->width ) { size = avpicture_get_size(frame->format, frame->width, frame->height); if ((ret = av_new_packet(pkt, size)) < 0) return ret; memcpy(pict.data, frame->data, 4*sizeof(frame->data[0])); memcpy(pict.linesize, frame->linesize, 4*sizeof(frame->linesize[0])); avpicture_layout(&pict, frame->format, frame->width, frame->height, pkt->data, size); } else if (av_frame_get_channels(frame) ) { size = frame->nb_samples * av_get_bytes_per_sample(frame->format) * av_frame_get_channels(frame); if ((ret = av_new_packet(pkt, size)) < 0) return ret; memcpy(pkt->data, frame->data[0], size); } frame_metadata = av_frame_get_metadata(frame); if (frame_metadata) { uint8_t *metadata; AVDictionaryEntry *e = NULL; AVBPrint meta_buf; av_bprint_init(&meta_buf, 0, AV_BPRINT_SIZE_UNLIMITED); while ((e = av_dict_get(frame_metadata, "", e, AV_DICT_IGNORE_SUFFIX))) { av_bprintf(&meta_buf, "%s", e->key); av_bprint_chars(&meta_buf, '\0', 1); av_bprintf(&meta_buf, "%s", e->value); av_bprint_chars(&meta_buf, '\0', 1); } if (!av_bprint_is_complete(&meta_buf) || !(metadata = av_packet_new_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA, meta_buf.len))) { av_bprint_finalize(&meta_buf, NULL); return AVERROR(ENOMEM); } memcpy(metadata, meta_buf.str, meta_buf.len); av_bprint_finalize(&meta_buf, NULL); } if ((ret = create_subcc_packet(avctx, frame, min_pts_sink_idx)) < 0) { av_frame_unref(frame); av_packet_unref(pkt); return ret; } pkt->stream_index = stream_idx; pkt->pts = frame->pts; pkt->pos = av_frame_get_pkt_pos(frame); pkt->size = size; av_frame_unref(frame); return size; }
1threat
Notice: Undefined variable: data in C:\xampp\htdocs\public\ruangweb2\apps\views\index.view.php on line 67 : I need help on some codes. This isn't made by me, i just copy a source code to make a website from another developer. I still don't know what is the problem although I have searched all the solutions online, because I am still learning. <?php $limit = 5; $pagination = isset($_GET['pagination']) ? $_GET['pagination'] : ""; if (empty($pagination)) { $position = 0; $pagination = 1; } else { $position = ($pagination - 1) * $limit; } $query = $connect->execute("SELECT pinjam.id_peminjaman, pinjam.id_user, user.nama_user, pinjam.id_ruang, ruang.nama_ruang, pinjam.id_hari, hari.nama_hari, pinjam.tgl_pinjam, pinjam.jam_awal, pinjam.jam_akhir, pinjam.keterangan, pinjam.status FROM tbl_peminjaman AS pinjam LEFT JOIN tbl_user AS user ON pinjam.id_user = user.id_user LEFT JOIN tbl_ruang AS ruang ON pinjam.id_ruang = ruang.id_ruang LEFT JOIN tbl_hari AS hari ON pinjam.id_hari = hari.id_hari ORDER BY pinjam.updated_at DESC LIMIT $position, $limit"); $no = 1 + $position; $check_search = $query->num_rows; while ($query->fetch_object()) { if ($data->status == 'DITERIMA') { $color = "green-text"; } elseif ($data->status == 'DITOLAK') { $color = "red-text"; } elseif ($data->status == 'MENUNGGU') { $color = "yellow-text"; } else { $color = "grey-text"; } ?> Sorry, i haven't know yet how to modify the undetected variable. So please, help me. Thanks :)
0debug
How can I convert string variable into byte type in python? : <p>I want to encrypt a messages which I got from user input using Cryptography:</p> <p>I have the following simple code:</p> <pre><code>import os from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from cryptography.hazmat.backends import default_backend backend = default_backend() messages = input("Please, insert messages to encrypt: ") key = os.urandom(24) print(key) cipher = Cipher(algorithms.TripleDES(key), modes.ECB(), backend=backend) encryptor = cipher.encryptor() cryptogram = encryptor.update(b"a secret message") + encryptor.finalize() print(cryptogram) </code></pre> <p>When I hard code the messages <kbd>"a secret message"</kbd> with <kbd>b</kbd> prefix in the code it works fine. What I wanted to do is to use <kbd>messages</kbd>variable to get the text from user input.</p> <pre><code>messages = input("Please, insert messages to encrypt: ") </code></pre> <p>I've tried several ways to covert the string type from the input to byte type and pass it to encryptor.update method but nothing works for me.</p> <pre><code>messages = input(b"Please, insert messages to encrypt: ") cryptogram = encryptor.update(byte, message) + encryptor.finalize() ... </code></pre> <p>Versions:</p> <p>Python 3.7.0</p> <p>Cryptography 2.4</p> <p>Mac OS</p>
0debug
static uint32_t hpet_time_after64(uint64_t a, uint64_t b) { return ((int64_t)(b) - (int64_t)(a) < 0); }
1threat
void ich9_lpc_pm_init(PCIDevice *lpc_pci, bool smm_enabled) { ICH9LPCState *lpc = ICH9_LPC_DEVICE(lpc_pci); qemu_irq sci_irq; sci_irq = qemu_allocate_irq(ich9_set_sci, lpc, 0); ich9_pm_init(lpc_pci, &lpc->pm, smm_enabled, sci_irq); ich9_lpc_reset(&lpc->d.qdev); }
1threat
sql server testing for 1 value in multiple columns : I have a table that has columns and I want to find out if all the columns contain that value. if they do not all contain that value I want to return the columns that do not contain it. can ANY or the IN clause be used for this?
0debug
Display an integer in reversed order : <p>I have this problem in school, and I have no idea how to start.</p> <p><strong>Here are the directions:</strong></p> <p>Write a method with the following header to display an integer in reversed order:</p> <p>public static int reverse (int number)</p> <p>Example Output:</p> <p>Enter an integer: 12345 in reversed order is 54321</p> <p>Note:</p> <p>You will need to... </p> <ol> <li>Find the length of the integer </li> <li>Extract each digit</li> <li>In the event that the expected outputs do not match the output tests or the code is incomplete that the program fails to run, points will be given to the sections that the codes are written properly</li> </ol> <p>~~~~~~~~~~~~~~~~~~~~~~~~~</p> <p>And here is the skeleton that they give me to work with:</p> <pre><code> import java.util.Scanner; public class ReverseNumber { public static int reverse (int number) { // FIXME 1 (50 points): Complete the method to return the number in reversed order } public static void main (String[] args) { // FIXME 2 (25 points): Write the statements to prompt the user enter an integer and store it in an integer variable System.out.println("Enter an integer: "); /* FIXME 3 (25 points): Write the statements to call the reverse (int number) method Print the result in the required format */ System.out.println("12345 in reverse order is 54321"); } } </code></pre> <p>I need to know what to put in here and where to put it in order to get it to output some thing like the example. Don't change the skeleton, just add to it.</p>
0debug
How do i add form submission on my website : <p>I,m building a website and need form submission to an e-mail address, whats the best programming language to use and how would i go about it, I'd rather not use php if possible, many thanks for suggestions</p>
0debug
static int qemu_chr_open_win_file(HANDLE fd_out, CharDriverState **pchr) { CharDriverState *chr; WinCharState *s; chr = g_malloc0(sizeof(CharDriverState)); s = g_malloc0(sizeof(WinCharState)); s->hcom = fd_out; chr->opaque = s; chr->chr_write = win_chr_write; qemu_chr_generic_open(chr); *pchr = chr; return 0; }
1threat
void gicv3_cpuif_update(GICv3CPUState *cs) { int irqlevel = 0; int fiqlevel = 0; ARMCPU *cpu = ARM_CPU(cs->cpu); CPUARMState *env = &cpu->env; trace_gicv3_cpuif_update(gicv3_redist_affid(cs), cs->hppi.irq, cs->hppi.grp, cs->hppi.prio); if (cs->hppi.grp == GICV3_G1 && !arm_feature(env, ARM_FEATURE_EL3)) { cs->hppi.grp = GICV3_G0; } if (icc_hppi_can_preempt(cs)) { bool isfiq; switch (cs->hppi.grp) { case GICV3_G0: isfiq = true; break; case GICV3_G1: isfiq = (!arm_is_secure(env) || (arm_current_el(env) == 3 && arm_el_is_aa64(env, 3))); break; case GICV3_G1NS: isfiq = arm_is_secure(env); break; default: g_assert_not_reached(); } if (isfiq) { fiqlevel = 1; } else { irqlevel = 1; } } trace_gicv3_cpuif_set_irqs(gicv3_redist_affid(cs), fiqlevel, irqlevel); qemu_set_irq(cs->parent_fiq, fiqlevel); qemu_set_irq(cs->parent_irq, irqlevel); }
1threat