problem
stringlengths
26
131k
labels
class label
2 classes
"No component factory found for" Error When trying to push from one Page to another : <p>I get an error when trying to push from one page to another. When I try to push to same page, it won't give that error. Only i get error when pushing from one page to another. 'setRoot()' also not giving an error. </p> <pre><code>this.navCtrl.push( Page7 ); </code></pre> <p>I have added the Page7 to app.module.ts.</p> <pre><code>import { NgModule } from '@angular/core'; import { IonicApp, IonicModule } from 'ionic-angular'; import { MyApp } from './app.component'; import { Page1 } from '../pages/page1/page1'; import { Page2 } from '../pages/page2/page2'; import { Page3 } from '../pages/page3/page3'; import { Page4 } from '../pages/page4/page4'; import { Page5 } from '../pages/page5/page5'; import { Page6 } from '../pages/page6/page6'; import { Page7 } from '../pages/page7/page7'; @NgModule({ declarations: [ MyApp, Page1, Page2, Page3, Page4, Page5, Page6, Page7 ], imports: [ IonicModule.forRoot(MyApp) ], bootstrap: [IonicApp], entryComponents: [ MyApp, Page1, Page2, Page3, Page4, Page5, Page6, Page7 ], providers: [] }) export class AppModule {} </code></pre> <p>This is a ionic 2 Application. It Gives this error. </p> <pre><code>EXCEPTION: Error in ./Page6 class Page6 - inline template:21:56 caused by: No component factory found for Page7 </code></pre> <p><a href="http://i.stack.imgur.com/QAcQo.png">console error</a></p>
0debug
iBeacon possible to wake up an app? : <p>We have requirement to integrate ibeacon in our iphone app.When user reached nearest to a beacon ,</p> <p>1)App need to wake up and open automatically.Is it possible? or 2)We need a local notification first and click on it will open the app?</p> <p>First one is possible , help is highly appreciable</p> <p>Thanks,</p>
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
What is this regex means? : <p>I found this regex as an email validation but i can't understand what is means, I tried to enter multiple forms of emails but they didn't work, I think there is a problem in this regex.</p> <p><strong>^[A-Z0-9][A-Z0-9._%+-]{0,63}@(?:[A-Z0-9]{1,63}.){1,125}[A-Z]{2,63}$</strong></p> <p>can anyone explain what is this regex means and give an example for it.</p> <p>Thanks in advance.</p>
0debug
Convert multidimensional array to string : <pre><code>Array ( [0] =&gt; Array ( [0] = &gt; 1 [1] = &gt; 2 [2] = &gt; 3 ) [1] = &gt; Array ( [0] = &gt; 4 [1] = &gt; 5 [2] = &gt; 6 ) ) </code></pre> <p>I have a multidimensional array, I want to convert the inner array to string with this format using php loop statement</p> <pre><code>$array[0] = 1,2,3 $array[1] = 4,5,6 </code></pre>
0debug
Jenkins with Xcode 8 - Cannot find Provisioning Profiles : <p>Jenkins cannot find our recently updated provisioning profiles and after trying every known solution I'm running out of ideas what could be wrong.</p> <p>Build jobs fail with error:</p> <blockquote> <p>No profile matching 'xxxxx' found: Xcode couldn't find a profile matching 'xxxxx'.</p> </blockquote> <p>The build server is a Mac, running Xcode 8 and we're using Jenkins with the Xcode plugin.</p> <p>Building and signing with Xcode 8 directly on the same machine is successful and I installed all the required profiles by double-clicking them.</p> <p>Does anyone know any workable solution to fix this issue?</p>
0debug
the founction not returning any value : hey this is my code for school and its not working i should check in this code if the arr in the prev position is bigger or smaller from the follow one if its bigger for all the array so i should return the value 1 if in some point in the array the prev position of the arr is bigger then then folow one so its shold reutrn the value 0 thank for any help #include <stdio.h> #include <stdlib.h> int Up_array(int *arr,int Size ) { int i; for(i=0;i<Size;i++) if (arr[i] > arr[i+1]) { return 0; } else if(arr[i] <= arr[i+1]) { return 1; } } void main () { int *arr,Size,i; printf("please enter the size of the array\n"); scanf("%d",&Size); arr=(int*)malloc(Size*sizeof(int)); printf("please enter the array\n"); for (i=0; i<Size ;i++) scanf("%d",&arr[i]); Up_array(arr,Size); free(arr); system("pause"); }
0debug
static inline void put_codeword(PutBitContext *pb, vorbis_enc_codebook *cb, int entry) { assert(entry >= 0); assert(entry < cb->nentries); assert(cb->lens[entry]); put_bits(pb, cb->lens[entry], cb->codewords[entry]); }
1threat
Convert decimal number to BigInteger in Java : <p>I am trying to convert <code>10000000000000000000000000000000</code> to <code>BigInteger</code>. But it is not converting. My code is </p> <p><code>BigInteger number = BigInteger.valueOf(10000000000000000000000000000000);</code> </p> <p>It is showing <code>The literal 10000000000000000000000000000000 of type int is out of range</code>.</p> <p>Is there any way to convert this number as I have to use this number as integer in my programme?</p>
0debug
SQL Query so as to match content on 2 fields in database : i have a table #__newtoys_variants having many fields of which id and v_prod_id are there. Now although id is unique - the v_prod_id is product id for instance id v_prod_id price 1 7 200 2 7 220 3 1 250 4 1 270 5 2 300 6 10 350 7 9 220 8 7 195 Now i intend that 404 error should be displayed in front end - if the id and v_prod_id is not matched in front end Actually this is my url structure example.com/index.php?option=com_newtoys&id=2&vid=7 here id value is extracted from #__newtoys_variants and vid is v_prod_id as extracted from #__newtoys_variants In case a user changes url to say example.com/index.php?option=com_newtoys&id=2&vid=1 then want 404 error to be displayed in front end Here is Table Database [![enter image description here][1]][1] Can any one help on it to achieve same Here is a brief function - unsure what exactly should be in sql query so that id & v_prod_id should be matched and in case result is zero then error message can be displayed function loadProduct($id ,$vid){ $mainframe =JFactory::getApplication(); $option = JRequest::getCmd('option'); $db =JFactory::getDBO(); global $Itemid; $sql = ""; $db->setQuery($sql); if ($rows = $db->loadObjectlist()) { return $rows[0]; } else { if ($db->getErrorNum()) { JError::raiseError(500, "Something went horribly wrong, the query returned the error ". $db->getErrorMsg()); } else { JError::raiseError(404, "404, Page does not Exists ". $db->getErrorMsg()); } } } [1]: https://i.stack.imgur.com/LAZ7n.png
0debug
this application has requested the runtime to terminate it in an unusual way : when I try to run java code the "this application has requested the runtime to terminate it in an unusual way" is coming and after that at my console window this message is showing "terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::erase" OS: Windows 7 This issue is only coming in jdk 1.8.0_161 64 bit But the code is working in jdk 9 and 7 64 bit Please help me out!!
0debug
Add something in front of domain name : <p>I own a domain, suppose <strong>www.something.com</strong>. How can I make a web page with a link like <strong>www.abc.something.com</strong> ? I want to add something in front of the root domain name. Please help.</p>
0debug
Why will my remove function find strings but not ints? : <p>We are working on generics which requires us to have an array of AnyType (the driver implements an array of strings then integers). One of the functions is a boolean function called 'remove' which finds 'x' and removes it, then it returns true. It has no issues finding and removing a string but can't seem to find ints. Why is this?</p> <p>the code is</p> <pre><code>public boolean remove(AnyType x) { for(int i = 0; i &lt; length; i++) { if(arr[i] == x) { for(int j = i; j &lt; length - 1; j++) { arr[j] = arr[j + 1]; } length--; return true; } } return false; } </code></pre>
0debug
variable out of type PrintStream in Java (not printIn problem) : <p>When I run this Java code I get the error "System.out.printLn("Java is more complicated than python"); ^ symbol: method printLn(String) location: variable out of type PrintStream" My Code is:</p> <pre><code>class complicated{ public static void main(String args[]){ System.out.printLn("Java is more complicated than python"); } } </code></pre> <p>P.S I know this question has been asked before but I don't have System.out.printIn instead of System.out.printLn. </p>
0debug
Copy Two-dimensional arrays in Javascript : ** Hello everyone, I met a problem when coding in Javascript, and I'm seeking for a solution for "What should I do with a Two Dimensional Array if I want copy each line of them and make them a new Two-Dim array?" Thx a lot if any one can help~ Here is the format of this two-Dim array: ------------------------------------------------------------------------ ** ------------------------------------------------------------------------ ======================================================================== > {"localTrain":"T7", "TC":"2", "TimeSheet":[ > ["01","London","BXP","T7","1632","1640"], > ["02","Shanghai","QWE","T7","1200","1240"], > ["03","LosAngeles","DFG","T7","1300","1340"], > ["04","NewDelhi","VGH","T7","1400","1440"], > ["05","Sydney","SAW","T7","1500","1540"], > ["06","Tokyo","SAT","T7","1600","1640"], > ["07","Seoul","BBT","T7","1700","1740"], > ["08","CapeTown","OOP","T7","1800","1840"],] } And they should be look like this: > {"localTrain":"T7", "TC":"2", "TimeSheet":[ > ["01","London","BXP","T7","1632","1640"], > ["01","London","BXP","T7","1632","1640"], > ["02","Shanghai","QWE","T7","1200","1240"], > ["02","Shanghai","QWE","T7","1200","1240"], > ["03","LosAngeles","DFG","T7","1300","1340"], > ["03","LosAngeles","DFG","T7","1300","1340"], > ["04","NewDelhi","VGH","T7","1400","1440"], > ["04","NewDelhi","VGH","T7","1400","1440"], > ["05","Sydney","SAW","T7","1500","1540"], > ["04","NewDelhi","VGH","T7","1400","1440"], > ["06","Tokyo","SAT","T7","1600","1640"], > ["06","Tokyo","SAT","T7","1600","1640"], > ["07","Seoul","BBT","T7","1700","1740"], > ["07","Seoul","BBT","T7","1700","1740"], > ["08","CapeTown","OOP","T7","1800","1840"], > ["08","CapeTown","OOP","T7","1800","1840"],] }
0debug
Renaming table system unavailable SQL Azure : I have to perform the exchange of two tables and it's making my system unavailable for 20 minutes(are many data). My sample code: query = "DROP TABLE MY_TABLE; "; query += "EXEC sp_rename MY_TABLE_TEMP, MY_TABLE; "; query += "ALTER TABLE MY_TABLE ADD CONSTRAINT PK_MY_TABLE PRIMARY KEY CLUSTERED (ID ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]"; I wonder if it's like not to leave as Unavailable.
0debug
How do i create the dots used for slides,with only html and css? : <p>how do i create the dots used in navigation,slides.Using only Html and CSS.</p> <p>Like this one: <a href="http://i.stack.imgur.com/qocTe.jpg" rel="nofollow">http://i.stack.imgur.com/qocTe.jpg</a></p> <p>Thanks in advance.</p>
0debug
when I class a div and assign css to that class it doest do anything : Sorry, i'm relatively new to programming. My question is, is that I have the div classed as .logo, so when i go over to my css file, I want to assign some different dimensions to the gif, as you can see in the css snippet, but the thing is that it just doesn't work... <div class="logo"> <img src="giphy.gif"> </div> .logo { width: 333px; height: 396px; }
0debug
pandas multiply using dictionary values across several columns : <p>Given the following dataframe:</p> <pre><code>import pandas as pd df = pd.DataFrame({ 'a': [1,2,3,4,5], 'b': [5,4,3,3,4], 'c': [3,2,4,3,10], 'd': [3, 2, 1, 1, 1] }) </code></pre> <p>And the following list of parameters:</p> <pre><code>params = {'a': 2.5, 'b': 3.0, 'c': 1.3, 'd': 0.9} </code></pre> <p>Produce the following desired output:</p> <pre><code> a b c d output 0 1 5 3 3 24.1 1 2 4 2 2 21.4 2 3 3 4 1 22.6 3 4 3 3 1 23.8 4 5 4 10 1 38.4 </code></pre> <p>I have been using this to produce the result:</p> <pre><code>df['output'] = [np.sum(params[col] * df.loc[idx, col] for col in df) for idx in df.index] </code></pre> <p>However, this is a very slow approach and I'm thinking there has to be a better way using built-in pandas functionality.</p> <p>I also thought of this:</p> <pre><code># Line up the parameters col_sort_key = list(df) params_sorted = sorted(params.items(), key=lambda k: col_sort_key.index(k[0])) # Repeat the parameters *n* number of times values = [v for k, v in params_sorted] values = np.array([values] * df.shape[0]) values array([[ 2.5, 3. , 1.3, 0.9], [ 2.5, 3. , 1.3, 0.9], [ 2.5, 3. , 1.3, 0.9], [ 2.5, 3. , 1.3, 0.9], [ 2.5, 3. , 1.3, 0.9]]) # Multiply and add product = df[col_sort_key].values * values product array([[ 2.5, 15. , 3.9, 2.7], [ 5. , 12. , 2.6, 1.8], [ 7.5, 9. , 5.2, 0.9], [ 10. , 9. , 3.9, 0.9], [ 12.5, 12. , 13. , 0.9]]) np.sum(product, axis=1) array([ 24.1, 21.4, 22.6, 23.8, 38.4]) </code></pre> <p>But that seems a bit convoluted! Any thoughts on a native pandas try?</p>
0debug
static ssize_t vc_sendv_compat(VLANClientState *vc, const struct iovec *iov, int iovcnt) { uint8_t buffer[4096]; size_t offset = 0; int i; for (i = 0; i < iovcnt; i++) { size_t len; len = MIN(sizeof(buffer) - offset, iov[i].iov_len); memcpy(buffer + offset, iov[i].iov_base, len); offset += len; } vc->receive(vc->opaque, buffer, offset); return offset; }
1threat
Linkedin: Sharing URL Summary not appearing : <p>I'm not sure if this is new behaviour or if it didn't work at all. So I'm using the LinkedIn Customized URL feature, you can look it up <a href="https://developer.linkedin.com/docs/share-on-linkedin" rel="noreferrer">here</a>. The URL looks like this:</p> <p><code>https://www.linkedin.com/shareArticle?mini=true&amp;url=http://developer.linkedin.com&amp;title=LinkedIn%20Developer%20Network&amp;summary=My%20favorite%20developer%20program&amp;source=LinkedIn</code></p> <p>Once I share the URL the provided <code>summary</code> is not shown in the post preview:</p> <p><a href="https://i.stack.imgur.com/vuf0z.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vuf0z.png" alt="LinkedIn Screenshot containing a shared post sample"></a></p> <p>So I tried with other services like Youtube, Reddit etc. and all posts <strong>do not</strong> include the provided summary.</p> <p>Unfortunately I can't provide you the open-graph tags I used on my site as it's running in a corporate environment and I'm not sure if I can provide these snippets as of now.</p> <p>However, running linkedin's <a href="https://www.linkedin.com/post-inspector/" rel="noreferrer">Post Inspector</a> shows that it detects my summary without problems:</p> <p><a href="https://i.stack.imgur.com/fsczt.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fsczt.png" alt="PostInspector Output"></a> <em>Values are in German if anyone wonders...</em></p> <p>So my quick and fairly simple questions, which might be answered in a comment as well, are:</p> <p>Did linkedin change something on their side? Is there some other undocumented property which neither youtube nor me included in the customized URL and therefore the summary does not show up? Is there any post from linkedin developers which note this change? Was it like that all the time or is it just a temporary thing? </p>
0debug
static int vmdk_open(BlockDriverState *bs, int flags) { int ret; BDRVVmdkState *s = bs->opaque; if (vmdk_open_sparse(bs, bs->file, flags) == 0) { s->desc_offset = 0x200; } else { ret = vmdk_open_desc_file(bs, flags, 0); if (ret) { goto fail; } } ret = vmdk_parent_open(bs); if (ret) { goto fail; } s->parent_cid = vmdk_read_cid(bs, 1); qemu_co_mutex_init(&s->lock); return ret; fail: vmdk_free_extents(bs); return ret; }
1threat
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]; trace_user_do_rt_sigreturn(env, frame_addr); 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); set_sigmask(&host_set); 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 -TARGET_QEMU_ESIGRETURN; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV ); return 0; }
1threat
How to Identify maven archtype? : I have an existing maven project for java services So is there any way to identify archetype from pom file or is there any way? The folder structure for this project is: src/test/java src/main/java src/main/resource And it has "Referenced Libraries" not "Maven Dependencies". Can anyone please let me know which archetype was selected from the list maven archetypes.
0debug
void *address_space_map(AddressSpace *as, hwaddr addr, hwaddr *plen, bool is_write) { AddressSpaceDispatch *d = as->dispatch; hwaddr len = *plen; hwaddr todo = 0; int l; hwaddr page; MemoryRegionSection *section; ram_addr_t raddr = RAM_ADDR_MAX; ram_addr_t rlen; void *ret; while (len > 0) { page = addr & TARGET_PAGE_MASK; l = (page + TARGET_PAGE_SIZE) - addr; if (l > len) l = len; section = phys_page_find(d, page >> TARGET_PAGE_BITS); if (!(memory_region_is_ram(section->mr) && !section->readonly)) { if (todo || bounce.buffer) { break; } bounce.buffer = qemu_memalign(TARGET_PAGE_SIZE, TARGET_PAGE_SIZE); bounce.addr = addr; bounce.len = l; if (!is_write) { address_space_read(as, addr, bounce.buffer, l); } *plen = l; return bounce.buffer; } if (!todo) { raddr = memory_region_get_ram_addr(section->mr) + memory_region_section_addr(section, addr); } len -= l; addr += l; todo += l; } rlen = todo; ret = qemu_ram_ptr_length(raddr, &rlen); *plen = rlen; return ret; }
1threat
How to calculate the time different between two columns(max value) : [the table in database look like this][1] [1]: https://i.stack.imgur.com/zJOsn.jpg I want to calculate the time different between MAX(salinity) and MAX(Depth) on a day. How can I do it? SELECT `r`.`date` , `r`.`time` , `r`.`salinity` FROM `samlae` r INNER JOIN ( SELECT `date` , MAX( `salinity` ) AS `maxsalinity` FROM `samlae` GROUP BY `date` )t ON `t`.`date` = `r`.`date` AND `t`.`maxsalinity` = `r`.`salinity` Thank you.
0debug
Flutter Bloc Pattern - How to navigate to another screen after stream event? : <p>my question is about Navigation used with the bloc pattern.</p> <p>In my LoginScreen widget I have a button that adds an event into the EventSink of the bloc. The bloc calls the API and authenticates the user. The question is where in the LoginScreen Widget I have to listen to the stream, and how to navigate to another screen after it returns a success status.</p> <p>Hope I made myself clear. Thanks!</p>
0debug
Python remove from beginning to first specific character in a string? : <p>Assuming I have the following string:</p> <pre><code>this is ;a cool test </code></pre> <p>How can I remove everything from the start up to the first time a <code>;</code> occurs? The expected output would be <code>a cool test</code>.</p> <p>I only know how to remove a fixed amount of characters using the bracket notation, which is not helpful here because the location of the <code>;</code> is not fixed.</p>
0debug
Angular Material Datepicker: Change event not firing when selecting date : <p>I'm using Angular and Angular Material's Datepicker. Everything is working fine for the most part, however I added a <code>(change)</code> event that is only working when the user manually types in a date. It does not get triggered when the user clicks on a date from the datepicker popup. To be clear, the value for <code>date</code> does in fact change when the user clicks on a date, it is just the <code>(change)</code> event, and ultimately my <code>updateCalcs()</code> function that for some reason doesn't get triggered. How can I trigger an event when the user clicks on a date from the datepicker?</p> <pre><code>&lt;md-input-container&gt; &lt;input mdInput [mdDatepicker]="datePicker" placeholder="Choose Date" name="date" [(ngModel)]="date" (change)="updateCalcs()" required&gt; &lt;button mdSuffix [mdDatepickerToggle]="datePicker"&gt;&lt;/button&gt; &lt;/md-input-container&gt; &lt;md-datepicker #datePicker&gt;&lt;/md-datepicker&gt; </code></pre>
0debug
modifying a an array of strings in C : I know when we declared a `char *c ="Hello";` means that we cannot modify this string. But how come I was able to modify this array of string in C. char *p [] = {"Hello","World"}; *p= "Mode"; Should not that give me an error for attempting to modify it.
0debug
Draw a rectangle and a text in it using PIL : <p>I want to draw a rectangle and a text in it, here's a part of my code and it's a bit obfuscated:</p> <pre><code>from PIL import Image from PIL import ImageFont from PIL import ImageDraw from PIL import ImageEnhance source_img = Image.open(file_name).convert("RGB") img1 = Image.new("RGBA", img.size, (0,0,0,0)) draw1 = ImageDraw.Draw(watermark, "RGBA") draw1.rectangle(((0, 00), (100, 100)), fill="black") img_rectangle = Image.composite(img1, source_img, img1) draw2 = ImageDraw.Draw(img1, "RGBA") draw2.text((20, 70), "something123", font=ImageFont.truetype("font_path123")) Image.composite(img1, source_img, img1).save(out_file, "JPEG") </code></pre> <p>This draws them both, but they're separate: the text is under the rectangle. Whereas I want a text to be drawn inside the rectangle. How can I do that? Should I <strong>necessarily</strong> compose them or what?</p>
0debug
Flutter: Move to a new screen without back : <p>I'm implementing an authentication flow in my Flutter app.</p> <p>After a sign in attempt, the CheckAuth <em>(which checks whether a user is signed in or not and then opens home screen or sign up screen accordingly)</em> is opened with this code: </p> <pre><code> void _signIn() async { await _auth .signInWithEmailAndPassword( email: _userEmail.trim(), password: _userPassword.trim()) .then((task) { // go to home screen if (task.getIdToken() != null) { setState(() { Navigator.pushReplacement( context, new MaterialPageRoute( builder: (BuildContext context) =&gt; new CheckAuth())); }); } else { print("Authentication failed"); } }); } </code></pre> <p>Problem: I can successfully sign in to the app, but if I tap back button after I sign in, it goes back to the sign in screen (while I expect it to exit from the app).</p> <p>Question: <strong>How to move from one screen to another in Flutter without the way back?</strong> </p> <p>Do I need to somehow delete the navigator history? Or don't use navigator at all? I tried <em>Navigator.replace</em> method, but it didn't seem to work.</p>
0debug
static void put_unused_buffer(QEMUFile *f, void *pv, size_t size) { static const uint8_t buf[1024]; int block_len; while (size > 0) { block_len = MIN(sizeof(buf), size); size -= block_len; qemu_put_buffer(f, buf, block_len); } }
1threat
generate random no. but at 1st position character 2nd&3rd number and 4thcharacter at last confirm the generated no. : i want to input a string="abcde12345ABCDE" using scanner and then generate the random number of length 4 but at 1st place it should be character 2nd place it should be number 3place it should be number and at 4th place it should se character..... at last i want to match the generated number... say: Input String="abcde12345ABCDE"; \\Processing.... Output A25b \*generated no. 1.charater 2.number 3.number & 4.character.*/ Plz enter the generated no.!! A25b
0debug
Call a javascript function after Single time every 7 days : <p>I am working on node.js. I created a function I want to call it 1 time after every 7 days. I am able to call it after 7 days but I want to call this after every 7 days. </p>
0debug
Why do Django developers use Django builtin admin panel? is it said that must to use instead of a html theme? : <p>I want to develop full functional web application in python django. I want to use bootstrap admin theme to develop admin site. I want to know is it required to use django admin while you are a django developer? or it's just a optional function if some one interested to complete tasks fast?</p>
0debug
TypeScript keyof returning specific type : <p>If I have the following type</p> <pre><code>interface Foo { bar: string; baz: number; qux: string; } </code></pre> <p>can I use <code>typeof</code> to type a parameter such that it only takes keys of <code>Foo</code> that return <code>string</code> (<code>'bar'</code> or <code>'qux'</code>)?</p>
0debug
Counting Duplicate Row in Itab : ABAP Friends, I need to count the number of duplicate row in ITAB base on one field. I have tried create work area and counting the duplicate data but the problem its counting all duplicate data. my purpose is to count duplicate data by the same date. DATA: gv_line TYPE i. gv_line = 0. LOOP AT i_sect_proe. IF wa_sect_proe IS INITIAL. wa_sect_proe = i_sect_proe. CONTINUE. ENDIF. IF wa_sect_proe-/smr/wondat EQ i_final_f-/smr/wondat. gv_line = gv_line + 1. ENDIF. i_sect_proe-/smr/line = gv_line. ENDLOOP. The code i've tried displaying number off all duplicate data.
0debug
Why can't I pass a sentence value to a jQuery function? : <p>I am trying to run a function like this:</p> <p><code>onclick="preConfirm(New Lots Avenue,40.660223,-73.896668);"</code></p> <p>But I always get an error in the console saying</p> <p><code>Uncaught SyntaxError: missing ) after argument list</code></p> <p>What am I doing wrong?</p>
0debug
Infinite loop after memory de-allocation : I have some issues with my code during my memory deallocaiton process. Here is the error I am getting: [![I make it to the part where my memory should be deallocated but instead of deallocation I get an infinite loop][1]][1] bool LinkedList::addArtist(){ cout << "Enter artist name: "; char *name = new char[0](); cin >> name; cin.ignore(1); '/n'; cout << "Enter artists top story: "; char *topStory = new char[0]; cin >> topStory; cin.ignore(1); '/n'; cout << "Enter artist description: "; char *description = new char[0]; cin >> description; cin.ignore(1); '/n'; this->addAtBeginning(*&name, *&topStory, *&description); cout << "made it out" << endl; delete[] name; delete[] topStory; delete[] description; return true; } as you can see I get the "made it out" notification yet my program gets frozen and doesn't allow me to do anything. Any thoughts? [1]: https://i.stack.imgur.com/TOUDh.png
0debug
how to filter betwenn date in codeigniter : i have a problem , how to filter between date if i only have one column date in my table ? anyone can help me ?
0debug
How to rotate a view continuously in IOS Swift 3 : <p>I will answer my own question to share my solution for this piece of code.</p> <p>How can i rotate any view continuously with a constant speed in IOS Swift 3?</p>
0debug
Error:(67, 51) java: diamond operator is not supported in -source 1.6 (use -source 7 or higher to enable diamond operator) : <p>I want to use <a href="https://github.com/guoguibing/librec" rel="nofollow">this</a> library, I cloned it and imported it into IntelliJ IDEA 14.0.3, with JDK 1.8.0_77, but when I want to run the main method I get this error:</p> <pre><code>Error:(422, 50) java: diamond operator is not supported in -source 1.6 (use -source 7 or higher to enable diamond operator) </code></pre> <p>what is going on here? how can I resolve it?</p>
0debug
Swift protocol generic as function return type : <p>I want to use generic protocol type as a function return type like this:</p> <pre><code>protocol P { associatedtype T func get() -&gt; T? func set(v: T) } class C&lt;T&gt;: P { private var v: T? func get() -&gt; T? { return v } func set(v: T) { self.v = v } } class Factory { func createC&lt;T&gt;() -&gt; P&lt;T&gt; { return C&lt;T&gt;() } } </code></pre> <p>But this code compile with errors complained:</p> <ol> <li>Cannot specialize non-generic type 'P'</li> <li>Generic parameter 'T' is not used in function signature</li> </ol> <p>Is there any way to achieve similar function with Swift?</p>
0debug
How to view 100k images? : <p>I'm looking for an efficient JavaScript library or web app with which I can scroll through 10-100k images that I have sorted in a remote directory.</p> <p>When I tried using plain HTML and img tags the browser would crash from memory pressure.</p>
0debug
static void vp5_parse_coeff(VP56Context *s) { VP56RangeCoder *c = &s->c; VP56Model *model = s->modelp; uint8_t *permute = s->idct_scantable; uint8_t *model1, *model2; int coeff, sign, coeff_idx; int b, i, cg, idx, ctx, ctx_last; int pt = 0; for (b=0; b<6; b++) { int ct = 1; if (b > 3) pt = 1; ctx = 6*s->coeff_ctx[ff_vp56_b6to4[b]][0] + s->above_blocks[s->above_block_idx[b]].not_null_dc; model1 = model->coeff_dccv[pt]; model2 = model->coeff_dcct[pt][ctx]; coeff_idx = 0; for (;;) { if (vp56_rac_get_prob_branchy(c, model2[0])) { if (vp56_rac_get_prob_branchy(c, model2[2])) { if (vp56_rac_get_prob_branchy(c, model2[3])) { s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx] = 4; idx = vp56_rac_get_tree(c, ff_vp56_pc_tree, model1); sign = vp56_rac_get(c); coeff = ff_vp56_coeff_bias[idx+5]; for (i=ff_vp56_coeff_bit_length[idx]; i>=0; i--) coeff += vp56_rac_get_prob(c, ff_vp56_coeff_parse_table[idx][i]) << i; } else { if (vp56_rac_get_prob_branchy(c, model2[4])) { coeff = 3 + vp56_rac_get_prob(c, model1[5]); s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx] = 3; } else { coeff = 2; s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx] = 2; } sign = vp56_rac_get(c); } ct = 2; } else { ct = 1; s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx] = 1; sign = vp56_rac_get(c); coeff = 1; } coeff = (coeff ^ -sign) + sign; if (coeff_idx) coeff *= s->dequant_ac; s->block_coeff[b][permute[coeff_idx]] = coeff; } else { if (ct && !vp56_rac_get_prob_branchy(c, model2[1])) break; ct = 0; s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx] = 0; } coeff_idx++; if (coeff_idx >= 64) break; cg = vp5_coeff_groups[coeff_idx]; ctx = s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx]; model1 = model->coeff_ract[pt][ct][cg]; model2 = cg > 2 ? model1 : model->coeff_acct[pt][ct][cg][ctx]; } ctx_last = FFMIN(s->coeff_ctx_last[ff_vp56_b6to4[b]], 24); s->coeff_ctx_last[ff_vp56_b6to4[b]] = coeff_idx; if (coeff_idx < ctx_last) for (i=coeff_idx; i<=ctx_last; i++) s->coeff_ctx[ff_vp56_b6to4[b]][i] = 5; s->above_blocks[s->above_block_idx[b]].not_null_dc = s->coeff_ctx[ff_vp56_b6to4[b]][0]; } }
1threat
preventDefault() Not Working With Ajax : the eventDefault isn't working and I have no clue why! I checked other forums and this should be working I also tried $(document).ready(function() ) but that didn't work either. The java and html are in that exact order if it makes a difference. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script type="text/javascript"> $("#my_form").submit(function(event){ event.preventDefault(); //prevent default action var post_url = $(this).attr("action"); //get form action url var request_method = $(this).attr("method"); //get form GET/POST method var form_data = $(this).serialize(); //Encode form elements for submission $.ajax({ url : post_url, type: request_method, data : form_data }).done(function(response){ // $("#server-results").html(response); }); }); </script> <body> <form id="my_form" method="post" action="http://link.php"> <input type="text" id="fullname" name="fname"> <input type="submit" id="submit_post" value="Post" > </form> <div id="server-results"></div> </body> thanks
0debug
static void nbd_accept(void *opaque) { int server_fd = (uintptr_t) opaque; struct sockaddr_in addr; socklen_t addr_len = sizeof(addr); int fd = accept(server_fd, (struct sockaddr *)&addr, &addr_len); nbd_started = true; if (fd >= 0 && nbd_client_new(exp, fd, nbd_client_closed)) { nb_fds++; } }
1threat
Restrict Special and CNTRL+V character java script : How can we restrict, special characters and CNTRL+V from Javascript (Not JQUERY), but it should allow (-) hyphen.
0debug
static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size, int x, int y, int w, int h, int wmv9_mask) { MSS2Context *ctx = avctx->priv_data; MSS12Context *c = &ctx->c; VC1Context *v = avctx->priv_data; MpegEncContext *s = &v->s; AVFrame *f; int ret; ff_mpeg_flush(avctx); init_get_bits(&s->gb, buf, buf_size * 8); s->loop_filter = avctx->skip_loop_filter < AVDISCARD_ALL; if (ff_vc1_parse_frame_header(v, &s->gb) < 0) { av_log(v->s.avctx, AV_LOG_ERROR, "header error\n"); return AVERROR_INVALIDDATA; } if (s->pict_type != AV_PICTURE_TYPE_I) { av_log(v->s.avctx, AV_LOG_ERROR, "expected I-frame\n"); return AVERROR_INVALIDDATA; } avctx->pix_fmt = AV_PIX_FMT_YUV420P; if ((ret = ff_MPV_frame_start(s, avctx)) < 0) { av_log(v->s.avctx, AV_LOG_ERROR, "ff_MPV_frame_start error\n"); avctx->pix_fmt = AV_PIX_FMT_RGB24; return ret; } ff_mpeg_er_frame_start(s); v->bits = buf_size * 8; v->end_mb_x = (w + 15) >> 4; s->end_mb_y = (h + 15) >> 4; if (v->respic & 1) v->end_mb_x = v->end_mb_x + 1 >> 1; if (v->respic & 2) s->end_mb_y = s->end_mb_y + 1 >> 1; ff_vc1_decode_blocks(v); ff_er_frame_end(&s->er); ff_MPV_frame_end(s); f = &s->current_picture.f; if (v->respic == 3) { ctx->dsp.upsample_plane(f->data[0], f->linesize[0], w, h); ctx->dsp.upsample_plane(f->data[1], f->linesize[1], w >> 1, h >> 1); ctx->dsp.upsample_plane(f->data[2], f->linesize[2], w >> 1, h >> 1); } else if (v->respic) avpriv_request_sample(v->s.avctx, "Asymmetric WMV9 rectangle subsampling"); av_assert0(f->linesize[1] == f->linesize[2]); if (wmv9_mask != -1) ctx->dsp.mss2_blit_wmv9_masked(c->rgb_pic + y * c->rgb_stride + x * 3, c->rgb_stride, wmv9_mask, c->pal_pic + y * c->pal_stride + x, c->pal_stride, f->data[0], f->linesize[0], f->data[1], f->data[2], f->linesize[1], w, h); else ctx->dsp.mss2_blit_wmv9(c->rgb_pic + y * c->rgb_stride + x * 3, c->rgb_stride, f->data[0], f->linesize[0], f->data[1], f->data[2], f->linesize[1], w, h); avctx->pix_fmt = AV_PIX_FMT_RGB24; return 0; }
1threat
AWS Cognito; unauthorized_client error when hitting /oauth2/token : <p>Steps taken so far:</p> <ul> <li>Set up new user pool in cognito</li> <li>Generate an app client with <em>no secret</em>; let's call its id <code>user_pool_client_id</code></li> <li>Under the user pool client settings for <code>user_pool_client_id</code> check the "Cognito User Pool" box, add <code>https://localhost</code> as a callback and sign out url, check "Authorization Code Grant", "Implicit Grant" and everything under "Allowed OAuth Scopes"</li> <li>Create a domain name; let's call it <code>user_pool_domain</code></li> </ul> <p>Create a new user with a username/password</p> <p>Now, I can successfully go to:</p> <p><code>https://{{user_pool_domain}}.auth.us-east-2.amazoncognito.com/oauth2/authorize?response_type=code&amp;client_id={{user_pool_client_id}}&amp;redirect_uri=https%3A%2F%2Flocalhost</code></p> <p>This presents me with a login page and I am able to login as my user which returns me to <code>https://localhost/?code={{code_uuid}}</code></p> <p>I then try the following: <code> curl -X POST https://{{user_pool_domain}}.auth.us-east-2.amazoncognito.com/oauth2/token -H 'Content-Type: application/x-www-form-urlencoded' -d 'grant_type=authorization_code&amp;redirect_uri=https%3A%2F%2Flocalhost&amp;code={{code_uuid}}&amp;client_id={{user_pool_client_id}}' </code></p> <p>However, this just returns back the following: <code> {"error":"unauthorized_client"} </code></p> <p>The <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/token-endpoint.html" rel="noreferrer">token endpoint docs</a> say that <code>unauthorized_client</code> is because "Client is not allowed for code grant flow or for refreshing tokens." which is confusing because I checked the boxes allowing the client to use the code grant flow.</p>
0debug
paxos vs raft for leader election : <p>After reading paxos and raft paper, I have following confusion: paxos paper only describe consensus on single log entry, which is equivalent the leader election part of the raft algorithm. What's the advantage of paxos's approach over the simple random timeout approach in raft's leader election?</p>
0debug
Using dot notation with variable to get object value in javascript : <p>I have a config object like this</p> <pre><code>{ config: { params: { football: { url: '' }, soccer: { url: '' } } } </code></pre> <p>I simply need to get at the <code>football</code> or <code>soccer</code> url value using a variable, so something like </p> <pre><code>let sport = 'soccer'; let path = config.params.`sport`.url; </code></pre> <p>I've tried bracket notation like <code>config.params[sport]</code> and the <code>eval</code> function but neither seem to do the trick. I'm sure I'm misnaming what I'm trying to do which is likely why I can't seem to find an answer.</p> <p>thanks</p>
0debug
How to grab specific text from a website with Python : <p>I was wondering how could I make a program that will grab information from this webiste: <a href="https://growtopiagame.com/" rel="nofollow noreferrer">https://growtopiagame.com/</a> (Or any at general), But I don't want to grab every text from it: I just want to grab Part where it says "4231 Players Online", And store it in variable that I can use later on...</p>
0debug
static void pl110_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); k->init = pl110_initfn; set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); dc->no_user = 1; dc->vmsd = &vmstate_pl110; }
1threat
When should we use '=== ' operator in javascript? : <p>When and why should we use '===' in javascript or jquery. Is it recommended to test string using === and if yes why. I have a code where i am checking a condition on the string like. if(a == "some-thing") is this right or should i use '===' </p>
0debug
Why I am getting this output. Need Explanation : #include <stdio.h> int main() { int x, y, z; x=y=z=3; z = ++x || ++y && ++z; printf("%d, %d, %d", x, y,z); return 0; } I am getting output 2, 1, 1. I need and explanation why Y is 1 in output?
0debug
How can i avoid cast numbers to booleans in C#? : <p>I am writing a component for grasshopper in c#. But went i pass a number through a boolean it give me a a false or a true value. How can i add a exception to this event. I only want to pass as parameter booleans types</p>
0debug
Python: goto command : My current assignment asks me to code a graphical representation of some nested squares varying in size from 20-80, like this https://imgur.com/NLt1csa . After creating the first square I need to move position to the start of the next square I use the goto command for this. My problem is the goto command, I use two variables for the horizontal and vertical inputs but only one of them works at a time, I need them both to work. Any help would be appreciated. (sorry about the formatting, this is my first post) #Draw a set of nested squares, increasing in size from turtle import * number_of_shapes = 4 for shape in range(1, number_of_shapes + 1): #Draw a square for sides in range(1,5): forward(20 + shape * 10) right(90) #Move to position of next square penup() goto(shape * 10, shape * 10) pendown()
0debug
How can I copy the <td> value(Command column) by clicking the copy button? : <p><a href="https://preview.linuxcommand.dev/" rel="nofollow noreferrer">https://preview.linuxcommand.dev/</a></p> <p>This is my website I'm trying to build, So right now its static and not dynamic, So all are same command you see that. So I want when the copy button on the right side is clicked, It will copy the command text of that column. I don't want to push a different ID of each . Without this, Is there any way to possible?</p>
0debug
Using Django URLs with AngularJs routeProvider : <p>for a project, I am using Django on the back-end and AngularJs on the front end.</p> <p>Basically, what I want is to run the Angular app only when the url starts with <code>projectkeeper/</code>.</p> <p>In other words, lets say my website is example.com. I want the angular app to run for the URLs <code>example.com/projectkeeper/dashboard/</code>, <code>example.com/projectkeeper/projects/</code> and so on, but not on <code>example.com/about/</code>.</p> <p>Hope I have made myself clear. Anyway, in order to do this, I am doing the following with my code:</p> <p><strong>urls.py</strong></p> <pre><code>urlpatterns = [ url(r'^projectkeeper/$', TemplateView.as_view(template_name='base.html')), ] </code></pre> <p>In the template <strong>base.html</strong>, I refer to my angular app obviously. For the angular routing, I have done the following:</p> <pre><code>myapp.config(['$routeProvider', function($routeProvider) { $routeProvider .when('/dashboard/', { title: 'Dashboard', controller : 'DashboardController', templateUrl : 'static/app_partials/projectkeeper/dashboard.html' }) .otherwise({ redirectTo : '/' }); }]); </code></pre> <p>So, ideally, what I thought was that going to <code>example.com/projectkeeper/#/dashboard/</code> would run the DashboardController from my angular app. However, this is not the case, I only get an empty page which means the routing was incorrect.</p> <p>Any solutions to this? As I said before, I want is to run the Angular app <strong>only</strong> when the url starts with <code>projectkeeper/</code>.</p>
0debug
How to show part of next/previous card RecyclerView : <p>What is the best strategy to achieve this feature:</p> <p><a href="https://i.stack.imgur.com/IKaKq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IKaKq.png" alt="enter image description here"></a></p> <p>I Have a horizontal RecyclerView with cards. Each card will fulfil the entire screen, but I want it to show part of the next card and previous one if it has more than one item.</p> <p>I know I can achieve this by setting my card <code>android:layout_width</code> at the adapter to have a specific DP like 250dp instead of <code>match_parent</code>. But it doesn't look like a proper solution.</p> <p>This is my code:</p> <p>Activity with RecyclerView:</p> <pre><code> class ListPokemon : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val items = createListPokemons() recyclerView.adapter = PokemonAdapter(items) recyclerView.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false) recyclerView.setHasFixedSize(true) val pagerSnapHelper = PagerSnapHelper() pagerSnapHelper.attachToRecyclerView(recyclerView) } private fun createListPokemons(): List&lt;Pokemon&gt; { val pokemons = ArrayList&lt;Pokemon&gt;() pokemons += createPokemon("Pikachu") pokemons += createPokemon("Bulbasaur") pokemons += createPokemon("Charmander") pokemons += createPokemon("Squirtle") return pokemons } private fun createPokemon(name: String) = Pokemon(name = name, height = 1, weight = 69, id = 1) } </code></pre> <p>Layout of Activity:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"&gt; &lt;android.support.v7.widget.RecyclerView android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="wrap_content" app:layoutManager="android.support.v7.widget.LinearLayoutManager"/&gt; &lt;/android.support.constraint.ConstraintLayout&gt; </code></pre> <p>Adapter:</p> <pre><code>class PokemonAdapter(val list: List&lt;Pokemon&gt;) : RecyclerView.Adapter&lt;PokemonAdapter.PokemonVH&gt;() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PokemonAdapter.PokemonVH { return PokemonVH(LayoutInflater.from(parent.context) .inflate(R.layout.pokemon_item, parent, false)) } override fun onBindViewHolder(holder: PokemonAdapter.PokemonVH, position: Int) { holder.textViewName.text = list[position].name } override fun getItemCount(): Int { return list.size } class PokemonVH(itemView: View) : RecyclerView.ViewHolder(itemView) { var textViewName: TextView = itemView.findViewById(R.id.textViewName) } } </code></pre> <p>Layout of Adapter:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.v7.widget.CardView android:layout_gravity="center_horizontal" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="16dp" android:layout_marginEnd="16dp" app:cardCornerRadius="8dp" app:cardElevation="4dp"&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"&gt; &lt;TextView android:padding="36dp" android:id="@+id/textViewName" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:textSize="22sp" tools:text="Teste String"/&gt; &lt;/LinearLayout&gt; &lt;/android.support.v7.widget.CardView&gt; </code></pre> <p>This is my result:</p> <p><a href="https://i.stack.imgur.com/7D9XB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7D9XB.png" alt="enter image description here"></a></p> <p>I would like to show part of the next card at this situation. How can I do this?</p> <p>Thanks.</p>
0debug
Index Bounds on Mongo Regex Search : <p>I'm using MongoDB, and I have a collection of documents with the following structure:</p> <pre><code>{ fName:"Foo", lName:"Barius", email:"fbarius@example.com", search:"foo barius" } </code></pre> <p>I am building a function that will perform a regular expression search on the <code>search</code> field. To optimize performance, I have indexed this collection on the search field. However, things are still a bit slow. So I ran an <code>explain()</code> on a sample query:</p> <pre><code>db.Collection.find({search:/bar/}).explain(); </code></pre> <p>Looking under the winning plan, I see the following index bounds used:</p> <pre><code>"search": [ "[\"\", {})", "[/.*bar.*/, /.*bar.*/]" ] </code></pre> <p>The second set makes sense - it's looking from anything that contains bar to anything that contains bar. However, the first set baffles me. It appears to be looking in the bounds of <code>""</code> inclusive to <code>{}</code> exclusive. I'm concerned that this extra set of bounds is slowing down my query. Is it necessary to keep? If it's not, how can I prevent it from being included?</p>
0debug
static double fade_gain(int curve, int64_t index, int range) { double gain; gain = av_clipd(1.0 * index / range, 0, 1.0); switch (curve) { case QSIN: gain = sin(gain * M_PI / 2.0); break; case IQSIN: gain = 0.636943 * asin(gain); break; case ESIN: gain = 1.0 - cos(M_PI / 4.0 * (pow(2.0*gain - 1, 3) + 1)); break; case HSIN: gain = (1.0 - cos(gain * M_PI)) / 2.0; break; case IHSIN: gain = 0.318471 * acos(1 - 2 * gain); break; case EXP: gain = pow(0.1, (1 - gain) * 5.0); break; case LOG: gain = av_clipd(0.0868589 * log(100000 * gain), 0, 1.0); break; case PAR: gain = 1 - sqrt(1 - gain); break; case IPAR: gain = (1 - (1 - gain) * (1 - gain)); break; case QUA: gain *= gain; break; case CUB: gain = gain * gain * gain; break; case SQU: gain = sqrt(gain); break; case CBR: gain = cbrt(gain); break; case DESE: gain = gain <= 0.5 ? pow(2 * gain, 1/3.) / 2: 1 - pow(2 * (1 - gain), 1/3.) / 2; break; case DESI: gain = gain <= 0.5 ? pow(2 * gain, 3) / 2: 1 - pow(2 * (1 - gain), 3) / 2; break; } return gain; }
1threat
static void tb_gen_code(CPUState *env, target_ulong pc, target_ulong cs_base, int flags, int cflags) { TranslationBlock *tb; uint8_t *tc_ptr; target_ulong phys_pc, phys_page2, virt_page2; int code_gen_size; phys_pc = get_phys_addr_code(env, pc); tb = tb_alloc(pc); if (!tb) { tb_flush(env); tb = tb_alloc(pc); } tc_ptr = code_gen_ptr; tb->tc_ptr = tc_ptr; tb->cs_base = cs_base; tb->flags = flags; tb->cflags = cflags; cpu_gen_code(env, tb, CODE_GEN_MAX_SIZE, &code_gen_size); code_gen_ptr = (void *)(((unsigned long)code_gen_ptr + code_gen_size + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1)); virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK; phys_page2 = -1; if ((pc & TARGET_PAGE_MASK) != virt_page2) { phys_page2 = get_phys_addr_code(env, virt_page2); } tb_link_phys(tb, phys_pc, phys_page2); }
1threat
void hd_geometry_guess(BlockDriverState *bs, int *pcyls, int *pheads, int *psecs) { int cylinders, heads, secs, translation; bdrv_get_geometry_hint(bs, &cylinders, &heads, &secs); translation = bdrv_get_translation_hint(bs); if (cylinders != 0) { *pcyls = cylinders; *pheads = heads; *psecs = secs; return; } if (guess_disk_lchs(bs, &cylinders, &heads, &secs) < 0) { guess_chs_for_size(bs, pcyls, pheads, psecs); } else if (heads > 16) { guess_chs_for_size(bs, pcyls, pheads, psecs); if (translation == BIOS_ATA_TRANSLATION_AUTO) { bdrv_set_translation_hint(bs, *pcyls * *pheads <= 131072 ? BIOS_ATA_TRANSLATION_LARGE : BIOS_ATA_TRANSLATION_LBA); } } else { *pcyls = cylinders; *pheads = heads; *psecs = secs; if (translation == BIOS_ATA_TRANSLATION_AUTO) { bdrv_set_translation_hint(bs, BIOS_ATA_TRANSLATION_NONE); } } bdrv_set_geometry_hint(bs, *pcyls, *pheads, *psecs); trace_hd_geometry_guess(bs, *pcyls, *pheads, *psecs, translation); }
1threat
TypeError: softmax() got an unexpected keyword argument 'axis' : <p>When I use this it does not give any error</p> <pre><code>out_layer = tf.add(tf.matmul(layer_4 , weights['out']) , biases['out']) out_layer = tf.nn.softmax(out_layer) </code></pre> <p>But when I use this </p> <pre><code>model=Sequential() model.add(Dense(100, input_dim= n_dim, activation='tanh',kernel_initializer='uniform')) keras.layers.core.Dropout(0.3, noise_shape=None, seed=None) model.add(Dense(50,input_dim=1000,activation='sigmoid')) keras.layers.core.Dropout(0.4, noise_shape=None, seed=None) model.add(Dense(15,input_dim=500,activation='sigmoid')) keras.layers.core.Dropout(0.2, noise_shape=None, seed=None) model.add(Dense(units=n_class)) model.add(Activation('softmax')) </code></pre> <p>I get error as</p> <blockquote> <p>TypeError: softmax() got an unexpected keyword argument 'axis'</p> </blockquote> <p>What should I do? I am using python2 Thanks</p>
0debug
Nodejs - Joi Check if string is in a given list : <p>I'm using <a href="https://github.com/hapijs/joi/blob/v10.1.0/API.md" rel="noreferrer">Joi package</a> for server side Validation.<br> I want to check if a given string is in a given list or if it is not in a given list.(define black list or white list for values)<br> sth like an <em>"in"</em> or <em>"notIn"</em> function.how can I do that?</p> <pre><code>var schema = Joi.object().keys({ firstname: Joi.string().in(['a','b']), lastname : Joi.string().notIn(['c','d']), }); </code></pre>
0debug
DriveInfo *drive_get_by_blockdev(BlockDriverState *bs) { return bs->blk ? blk_legacy_dinfo(bs->blk) : NULL; }
1threat
yuv2rgb_1_c_template(SwsContext *c, const int16_t *buf0, const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, int y, enum PixelFormat target, int hasAlpha) { const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0]; int i; if (uvalpha < 2048) { for (i = 0; i < (dstW >> 1); i++) { int Y1 = (buf0[i * 2 ] + 64) >> 7; int Y2 = (buf0[i * 2 + 1] + 64) >> 7; int U = (ubuf0[i] + 64) >> 7; int V = (vbuf0[i] + 64) >> 7; int A1, A2; const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM], *g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]), *b = c->table_bU[U + YUVRGB_TABLE_HEADROOM]; if (hasAlpha) { A1 = (abuf0[i * 2 ] + 64) >> 7; A2 = (abuf0[i * 2 + 1] + 64) >> 7; } yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0, r, g, b, y, target, hasAlpha); } } else { const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1]; for (i = 0; i < (dstW >> 1); i++) { int Y1 = (buf0[i * 2 ] + 64) >> 7; int Y2 = (buf0[i * 2 + 1] + 64) >> 7; int U = (ubuf0[i] + ubuf1[i] + 128) >> 8; int V = (vbuf0[i] + vbuf1[i] + 128) >> 8; int A1, A2; const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM], *g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]), *b = c->table_bU[U + YUVRGB_TABLE_HEADROOM]; if (hasAlpha) { A1 = (abuf0[i * 2 ] + 64) >> 7; A2 = (abuf0[i * 2 + 1] + 64) >> 7; } yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0, r, g, b, y, target, hasAlpha); } } }
1threat
About my Java Code Function : http://jsfiddle.net/MrBigglesWorth/Lwxoeyyp/408/ This code is suppose to save the checkboxs I've ticked after clicking the Save button. Currently that is working but only for one Button. I'm trying to get it to work on all of them to allow me to check them all and save and I plan on adding more than 9 buttons. Trying to pass through ID's through a function. Not sure how to do it though. when I click save on it with more than one of the boxs checked, it only keeps the first one checked cause that has the ID box1 is what the javascript is calling in the function. What Code do I need and how do I go about using this function for each btn. I was thinking of a onclick with .this might work but I am not sure.
0debug
def find_last_occurrence(A, x): (left, right) = (0, len(A) - 1) result = -1 while left <= right: mid = (left + right) // 2 if x == A[mid]: result = mid left = mid + 1 elif x < A[mid]: right = mid - 1 else: left = mid + 1 return result
0debug
What is the default encoding for source files in visual studio 2017 : <p>It seems visual studio 2017 always saves new files as UTF8-BOM. It also seems this was not the case with earlier versions of visual studio, but i could not find any documentation. </p> <p>Also there has been an option "Advanced Save Options\Encoding" which did allow to change the encoding of newly saved files which is missing in VS2017.</p> <p>Questions:</p> <ul> <li>Are all files types saved with UTF8-BOM encoding in VS2017</li> <li>Is it possible to configure the encoding for new files in VS2017</li> <li>Will VS2017 change the encoding of "old" files which don't have UTF8-BOM</li> <li>Is there any documentation about this topic</li> </ul>
0debug
int bdrv_block_status(BlockDriverState *bs, int64_t offset, int64_t bytes, int64_t *pnum, int64_t *map, BlockDriverState **file) { int64_t ret; int n; assert(QEMU_IS_ALIGNED(offset | bytes, BDRV_SECTOR_SIZE)); assert(pnum); bytes = MIN(bytes, BDRV_REQUEST_MAX_BYTES); ret = bdrv_get_block_status_above(bs, backing_bs(bs), offset >> BDRV_SECTOR_BITS, bytes >> BDRV_SECTOR_BITS, &n, file); if (ret < 0) { assert(INT_MIN <= ret); *pnum = 0; return ret; } *pnum = n * BDRV_SECTOR_SIZE; if (map) { *map = ret & BDRV_BLOCK_OFFSET_MASK; } else { ret &= ~BDRV_BLOCK_OFFSET_VALID; } return ret & ~BDRV_BLOCK_OFFSET_MASK; }
1threat
build_facs(GArray *table_data, GArray *linker) { AcpiFacsDescriptorRev1 *facs = acpi_data_push(table_data, sizeof *facs); memcpy(&facs->signature, "FACS", 4); facs->length = cpu_to_le32(sizeof(*facs)); }
1threat
static void free_buffers(AVCodecContext *avctx) { CFHDContext *s = avctx->priv_data; int i; for (i = 0; i < 4; i++) { av_freep(&s->plane[i].idwt_buf); av_freep(&s->plane[i].idwt_tmp); } s->a_height = 0; s->a_width = 0; }
1threat
HOW TO FETCH FULL TABLE IN FUNCTION IN SNOWFLAKE AND TEST THAT FUNCTION AS IT IS WORKING FINE OR NOT : CREATE OR REPLACE function FN_TABLE_ROWS() returns TABLE(ID NUMBER,NAME VARCHAR) as 'select 111 AS ID,'' NEERAJ'' AS NAME from DUAL'; SELECT FN_TABLE_ROWS() FROM DUAL;
0debug
make a div a square in css : how do i make those box divs look like a little box or a square however you want to call them, please, i set #header's width and height and on those it doesn't work... <!DOCTYPE HTML> <html lang="en"> <head> <title>A Page</title> <link type="text/css" rel="stylesheet" href="css/main.css" /> <!-- GOOGLE FONTS --> <link href="https://fonts.googleapis.com/css?family=Prompt" rel="stylesheet" /> </head> <body> <div id="header"> <div id="search"> <form> <div id="box" class="text"> <input type="text" placeholder="Search" /> </div> <div id="box" class="small"> <input type="image" src="" alt="submit" /> </div> </form> </div> <div id="menu"> <a href=""><div id="box" class="big"></div></a> <a><div id="box" class="small"><img></img></div></a> <a><div id="box" class="small"><img></img></div></a> <span id="notifications"></span> </div> </div> <br /> <div id="box" class="big"> </div> and this is the css i tried: body{ font-family: 'Prompt', sans-serif; background: #707070; } #header{ background: #e2ecf2; opacity: 0.87; border-radius: 30px; height: 60px; width: 1000px; position: fixed; left: 50%; top: 25px; transform: translateX(-50%); } #box{ outline: 3px; outline-style: solid; outline-color: #d7d7d7; } #box .small{ width: 35px; height: 35px; } #box .big{ width: 50px; height: 50px; } #header #search{ margin-left: 37px; } #header #search input{ float: left; margin-left: 20px; } pls. i doesn't make any sense... i am litterally crashing here :((
0debug
PyCharm: Configuring multi-hop remote Interpreters via SSH : <p>To connect to the computer at my office I need to run ssh twice. First to connect to the host-1 and then from host-1 to host-2 and each one has different credentials. However the configuration menu in Pycharm only accepts one ssh tunnel.</p> <p><a href="http://i.stack.imgur.com/KE7Sz.jpg" rel="noreferrer">Configure Remote Python Interpreter dialog box</a></p> <p>Is there any way to set a multi-hop ssh to have access to the interpreter and data files on the host from local?</p>
0debug
Differences between Spring Boot and spring MVC : <p>just starting out learning Spring, could you tell me the main differences between Spring Boot and MVC? Which one is recommended for a beginner?</p> <p>Thanks.</p>
0debug
build_spcr(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info) { AcpiSerialPortConsoleRedirection *spcr; const MemMapEntry *uart_memmap = &guest_info->memmap[VIRT_UART]; int irq = guest_info->irqmap[VIRT_UART] + ARM_SPI_BASE; spcr = acpi_data_push(table_data, sizeof(*spcr)); spcr->interface_type = 0x3; spcr->base_address.space_id = AML_SYSTEM_MEMORY; spcr->base_address.bit_width = 8; spcr->base_address.bit_offset = 0; spcr->base_address.access_width = 1; spcr->base_address.address = cpu_to_le64(uart_memmap->base); spcr->interrupt_types = (1 << 3); spcr->gsi = cpu_to_le32(irq); spcr->baud = 3; spcr->parity = 0; spcr->stopbits = 1; spcr->flowctrl = (1 << 1); spcr->term_type = 0; spcr->pci_device_id = 0xffff; spcr->pci_vendor_id = 0xffff; build_header(linker, table_data, (void *)spcr, "SPCR", sizeof(*spcr), 2, NULL); }
1threat
Dagger 2 Singleton Component Depend On Singleton : <p>I've got a strange problem here, and I'm not quite sure why what I'm doing isn't allowed. I've got the following modules:</p> <pre><code>@Module public final class AppModule { private Context mContext; @Provides @Singleton @AppContext public Context provideContext() { return mContext; } } @Module public final class NetModule { @Provides @Singleton public OkHttpClient provideOkHttp() { return new OkHttpClient.Builder().build(); } } </code></pre> <p>For various reasons, I don't want to have these two modules in the same component (basically due to my project structure). So I tried to create the following components:</p> <pre><code>@Singleton @Component(modules = AppModule.class) public interface AppComponent { @AppContext Context appContext(); } @Singleton @Component(dependencies = AppComponent.class, modules = NetModule.class) public interface NetComponent { Retrofit retrofit(); } </code></pre> <p>But when I try to compile this, I get the following error message:</p> <p><code>Error:(12, 1) error: This @Singleton component cannot depend on scoped components: @Singleton com.myapp.service.dagger.AppComponent</code></p> <p>I understand why depending on <em>different</em> scopes would be bad and disallowed. But why is Singleton depends-on Singleton not allowed? This feels like it should work, since all I'm doing is declaring sibling components. What am I missing?</p>
0debug
Meaning of "Allowed to push" and "Allowed to merge" in Gitlab : <p>What's the meaning of "Allowed to push" and "Allowed to merge" in Gitlab protected branches</p>
0debug
int av_vsrc_buffer_add_frame2(AVFilterContext *buffer_filter, AVFrame *frame, int64_t pts, AVRational pixel_aspect, int width, int height, enum PixelFormat pix_fmt, const char *sws_param) { BufferSourceContext *c = buffer_filter->priv; int ret; if (c->has_frame) { av_log(buffer_filter, AV_LOG_ERROR, "Buffering several frames is not supported. " "Please consume all available frames before adding a new one.\n" ); } if(width != c->w || height != c->h || pix_fmt != c->pix_fmt){ AVFilterContext *scale= buffer_filter->outputs[0]->dst; AVFilterLink *link; av_log(buffer_filter, AV_LOG_INFO, "Changing filter graph input to accept %dx%d %d (%d %d)\n", width,height,pix_fmt, c->pix_fmt, scale->outputs[0]->format); if(!scale || strcmp(scale->filter->name,"scale")){ AVFilter *f= avfilter_get_by_name("scale"); av_log(buffer_filter, AV_LOG_INFO, "Inserting scaler filter\n"); if(avfilter_open(&scale, f, "Input equalizer") < 0) return -1; if((ret=avfilter_init_filter(scale, sws_param, NULL))<0){ avfilter_free(scale); return ret; } if((ret=avfilter_insert_filter(buffer_filter->outputs[0], scale, 0, 0))<0){ avfilter_free(scale); return ret; } scale->outputs[0]->format= c->pix_fmt; } c->pix_fmt= scale->inputs[0]->format= pix_fmt; c->w= scale->inputs[0]->w= width; c->h= scale->inputs[0]->h= height; link= scale->outputs[0]; if ((ret = link->srcpad->config_props(link)) < 0) return ret; } memcpy(c->frame.data , frame->data , sizeof(frame->data)); memcpy(c->frame.linesize, frame->linesize, sizeof(frame->linesize)); c->frame.interlaced_frame= frame->interlaced_frame; c->frame.top_field_first = frame->top_field_first; c->frame.key_frame = frame->key_frame; c->frame.pict_type = frame->pict_type; c->pts = pts; c->pixel_aspect = pixel_aspect; c->has_frame = 1; return 0; }
1threat
Randomly changing background of JButtons in array? : <p>I'm currently attempting to create a Battleship game. The part I'm having trouble with is when I select the "Randomize" button, I would like it to put the ships at a random part of the grid.</p> <p>For example, the Carrier ship would cover 5 JButtons within the array. How do I randomly select 5 JButtons within the array that are next to each other?</p> <pre><code>import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import java.awt.GridLayout; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JButton; import java.util.Random; public class View { private JFrame frame; private JPanel panel1; private JPanel panel2; private JButton grid1[][]; private JButton randomize; private String[] alphabet = { "", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }; private String[] numbers = { "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }; public View() { configureFrame(); configurePanels(); configureComponents(); frame.setVisible(true); } private void configureFrame() { frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(900, 600); frame.setResizable(false); frame.setLocationRelativeTo(null); } private void configurePanels() { panel1 = new JPanel(); panel1.setLayout(new GridLayout(11, 11)); frame.getContentPane().add(panel1, BorderLayout.WEST); panel2 = new JPanel(); panel2.setSize(frame.getWidth(), frame.getHeight()); panel2.setLayout(null); frame.getContentPane().add(panel2); } private void configureComponents() { grid1 = new JButton[11][11]; for(int i = 0; i &lt; grid1.length; i++) { for(int j = 0; j &lt; grid1[i].length; j++) { grid1[i][j] = new JButton(); panel1.add(grid1[i][j]); } } for(int i = 0; i &lt; alphabet.length &amp;&amp; i &lt; numbers.length; i++) { grid1[0][i].setText(alphabet[i]); grid1[i][0].setText(numbers[i]); grid1[0][i].setFont(new Font("Tahoma", Font.BOLD, 19)); grid1[i][0].setFont(new Font("Tahoma", Font.BOLD, 19)); grid1[0][i].setEnabled(false); grid1[i][0].setEnabled(false); grid1[0][i].setBackground(Color.BLACK); grid1[i][0].setBackground(Color.BLACK); } grid1[0][0].setBackground(Color.BLACK); randomize = new JButton("Randomize"); randomize.setLocation(50, 65); randomize.setSize(100, 50); randomize.setFocusPainted(false); randomize.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { /* Want to randomly put the carrier on the grid somewhere grid1[2][3].setBackground(Color.LIGHT_GRAY); grid1[3][3].setBackground(Color.LIGHT_GRAY); grid1[4][3].setBackground(Color.LIGHT_GRAY); grid1[5][3].setBackground(Color.LIGHT_GRAY); grid1[6][3].setBackground(Color.LIGHT_GRAY); */ } }); panel2.add(randomize); } } </code></pre> <p>I'm very new to Java, so I apologize in advance if I'm not making any sense.</p>
0debug
How to test a variable is null in python : <pre><code>val = "" del val if val is None: print("null") </code></pre> <p>I ran above code, but got <code>NameError: name 'val' is not defined</code>.</p> <p>How to decide whether a variable is null, and avoid NameError?</p>
0debug
Unable to load the mojo 'test' - org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test : <p>I am building my apps with Maven-3 and i guess after auto-refresh of maven-surefire-plugin to 3.0.0-M1 i am not able to do build and getting the below error. </p> <p>As a initial step, I have cleared the directory /org/apache/maven in my repository however still i am facing the issue. Can anyone advise. Note - if i am downgrading the surefire plugin to 2.x then I am able to build it.</p> <p>Error log</p> <pre><code>[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 15.444s [INFO] Finished at: Thu Nov 08 16:04:53 GMT 2018 [INFO] Final Memory: 60M/704M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test (default-test) on project TEST_PROJECT: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test failed: Unable to load the mojo 'test' (or one of its required components) from the plugin 'org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1': com.google.inject.ProvisionException: Guice provision errors: [ERROR] [ERROR] 1) No implementation for org.codehaus.plexus.languages.java.jpms.LocationManager was bound. [ERROR] while locating org.apache.maven.plugin.surefire.SurefirePlugin [ERROR] at ClassRealm[plugin&gt;org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1, parent: sun.misc.Launcher$AppClassLoader@5c647e05] [ERROR] while locating org.apache.maven.plugin.Mojo annotated with @com.google.inject.name.Named(value=org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test) [ERROR] [ERROR] 1 error [ERROR] role: org.apache.maven.plugin.Mojo [ERROR] roleHint: org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test [ERROR] -&gt; [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test (default-test) on project TEST_PROJECT: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test failed: Unable to load the mojo 'test' (or one of its required components) from the plugin 'org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1' at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test failed: Unable to load the mojo 'test' (or one of its required components) from the plugin 'org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1' at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:115) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more Caused by: org.apache.maven.plugin.PluginContainerException: Unable to load the mojo 'test' (or one of its required components) from the plugin 'org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1' at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:488) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:92) ... 20 more Caused by: org.codehaus.plexus.component.repository.exception.ComponentLookupException: com.google.inject.ProvisionException: Guice provision errors: 1) No implementation for org.codehaus.plexus.languages.java.jpms.LocationManager was bound. while locating org.apache.maven.plugin.surefire.SurefirePlugin at ClassRealm[plugin&gt;org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1, parent: sun.misc.Launcher$AppClassLoader@5c647e05] while locating org.apache.maven.plugin.Mojo annotated with @com.google.inject.name.Named(value=org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test) 1 error role: org.apache.maven.plugin.Mojo roleHint: org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:257) at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:245) at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:455) ... 21 more Caused by: com.google.inject.ProvisionException: Guice provision errors: 1) No implementation for org.codehaus.plexus.languages.java.jpms.LocationManager was bound. while locating org.apache.maven.plugin.surefire.SurefirePlugin at ClassRealm[plugin&gt;org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1, parent: sun.misc.Launcher$AppClassLoader@5c647e05] while locating org.apache.maven.plugin.Mojo annotated with @com.google.inject.name.Named(value=org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test) 1 error at com.google.inject.internal.InjectorImpl$3.get(InjectorImpl.java:974) at com.google.inject.Scopes$1$1.get(Scopes.java:59) at org.sonatype.guice.bean.locators.LazyBeanEntry.getValue(LazyBeanEntry.java:83) at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:49) at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:253) ... 23 more </code></pre>
0debug
converting string value from text field to integer in Swift 3 &/or Swift 4 : I'm really new to Swift and am having problems with the conversion of a string (entered in a text field) to an integer. I'm trying to create a small calculation app in XCode 8 (I was following a tutorial on YouTube but it's old). My app has 3 text fields, a label (that is meant to display the result), and a button to start the calculation. I'm currently using Swift 3 but if someone could give me the answer for doing it in Swift 3 & Swift 4 I'd be grateful. Here's the code: import UIKit class ViewController: UIViewController { @IBOutlet weak var valueA: UITextField! @IBOutlet weak var valueB: UITextField! @IBOutlet weak var valueC: UITextField! @IBOutlet weak var result: UILabel! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } @IBAction func calculateTotal(_ sender: Any) { var a:Int? = Int(valueA.text) var b:Int? = Int(valueB.text) var c:Int? = Int(valueA.text) var answer = a! * b! * c! } }
0debug
c# How can i replace backslash in a string? : <p>I am working on a c# project and have some strings like this </p> <p><strong>first string</strong></p> <pre><code>"[\"2018\\/02\\/12\",[\"Test1\",\"Test2\",\"Test3\",\"Test4\"]]" </code></pre> <p>But this string format is not not suitable for my application. I want to change first string to this :</p> <p><strong>second string</strong></p> <pre><code>2018-02-12,"Test1","Test2","Test3","Test4" </code></pre> <p>I've done some of it, but I'm having trouble getting a backslash. Actually backslash did not changed.</p> <p><strong>my code :</strong></p> <pre><code>string MyString = "[\"2018\\/02\\/12\",[\"Test1\",\"Test2\",\"Test3\",\"Test4\"]]"; MyString = MyString.Replace("[", "").Replace("]", "").Replace("\\", ""); </code></pre> <p>How can I get the second string?</p>
0debug
XCODE I tried to add music to my app that I'm trying to make, I added the code below but there's no sound coming from the simulator, help please~! : I'm trying to add loop music to my App. The Simulator runs, but there's no music coming out. Help Please, Thanks. import AVFoundation class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() var audioPlayer = AVAudioPlayer() func startAudio() { let filePath = Bundle.main.path(forResource: "backsong", ofType: "mp3") let fileURL = NSURL.fileURL(withPath: filePath!) do { audioPlayer = try AVAudioPlayer.init(contentsOf: fileURL, fileTypeHint: AVFileType.mp3.rawValue) audioPlayer.numberOfLoops = -1 audioPlayer.volume = 1 } catch { self.present(UIAlertController.init(title: "Error", message: "Error Message", preferredStyle: .alert), animated: true, completion: nil) } audioPlayer.play()
0debug
static void rtas_set_tce_bypass(sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { VIOsPAPRBus *bus = spapr->vio_bus; VIOsPAPRDevice *dev; uint32_t unit, enable; if (nargs != 2) { rtas_st(rets, 0, -3); return; } unit = rtas_ld(args, 0); enable = rtas_ld(args, 1); dev = spapr_vio_find_by_reg(bus, unit); if (!dev) { rtas_st(rets, 0, -3); return; } if (enable) { dev->flags |= VIO_PAPR_FLAG_DMA_BYPASS; } else { dev->flags &= ~VIO_PAPR_FLAG_DMA_BYPASS; } rtas_st(rets, 0, 0); }
1threat
How can I convert epoch datetime in python? : <p>I'm calling an api and getting the datetime field in this format /Date(1500462505221)/ . My motive is to convert it to this format "2018-05-11 23:25:47" . How do I accomplish this ?</p>
0debug
Hash an integer in Python to match Oracle's STANDARD_HASH : <p>In Oracle, my data has been hashed by passing an integer into `STANDARD_HASH' as follows. How can I get the same hash value using Python?</p> <p>Result in Oracle when an integer passed to STANDARD_HASH:</p> <pre><code>SELECT STANDARD_HASH(123, 'SHA256') FROM DUAL; # A0740C0829EC3314E5318E1F060266479AA31F8BBBC1868DA42B9E608F52A09F </code></pre> <p>Result in Python when a string is passed in:</p> <pre><code>import hashlib hashlib.sha256(str.encode(str(123))).hexdigest().upper() # A665A45920422F9D417E4867EFDC4FB8A04A1F3FFF1FA07E998E86F7F7A27AE3 # I want to modify this function to get the hash value above. </code></pre> <p>Maybe this information will also help. I cannot change anything on the Oracle side, but if I could, I would convert the column to <code>CHAR</code> and it would give the same value as my current Python implementation. An example follows.</p> <p>Result in Oracle when a string passed to STANDARD_HASH:</p> <pre><code>SELECT STANDARD_HASH('123', 'SHA256') FROM DUAL; # A665A45920422F9D417E4867EFDC4FB8A04A1F3FFF1FA07E998E86F7F7A27AE3 (matches Python result) </code></pre> <p>I've made several attempts, like simply passing in an integer to Python, but this results in the error that a string is required. I've also searched for a way to encode the integer, but haven't made any progress.</p>
0debug
How to average every 12 columns for each row in r : <p>I have a matrix which contains 100 rows and 120 columns, I wonder how I can find the mean value for every 12 columns for each row. so I can have the annual mean. Thanks.</p> <pre><code>set.seed(1234) data=rnorm(100*120) data=matrix(data,nrow = 100,ncol = 120) </code></pre>
0debug
Pattern Matching for Country codes in JAVA : <p>I have a requirement to filter out data based on the country codes . For example if the phone numbers are +911234567891,+922234567891,+933234567893. Now we need to dynamically create patterns to get the country codes for the phone numbers. Some country codes might be +91,+3581,+93 etc.</p> <p>can you please suggest an approach</p>
0debug
static int usb_msd_handle_control(USBDevice *dev, int request, int value, int index, int length, uint8_t *data) { MSDState *s = (MSDState *)dev; int ret; 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] = (1 << 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 DeviceOutRequest | USB_REQ_SET_INTERFACE: ret = 0; break; case EndpointOutRequest | USB_REQ_CLEAR_FEATURE: ret = 0; break; case InterfaceOutRequest | USB_REQ_SET_INTERFACE: ret = 0; break; case ClassInterfaceOutRequest | MassStorageReset: s->mode = USB_MSDM_CBW; ret = 0; break; case ClassInterfaceRequest | GetMaxLun: data[0] = 0; ret = 1; break; default: fail: ret = USB_RET_STALL; break; } return ret; }
1threat
void ff_put_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels, int line_size) { int i; uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; for(i=0;i<8;i++) { pixels[0] = cm[block[0]]; pixels[1] = cm[block[1]]; pixels[2] = cm[block[2]]; pixels[3] = cm[block[3]]; pixels[4] = cm[block[4]]; pixels[5] = cm[block[5]]; pixels[6] = cm[block[6]]; pixels[7] = cm[block[7]]; pixels += line_size; block += 8; } }
1threat
How do you tell pylint what the members of a protobuf-generated object are? : <p>I would like to release a python package for a set of protobuf messages. The protobuf compiler (<code>protoc</code>) generates a python library that does not actually define types/classes the typical sense, but rather dynamically constructs them. Is there any way to hint to pylint what the members and fields of these classes are?</p> <p>For example, consider the following simple protobuf message specification:</p> <pre><code>message Person { required string name = 1; required int32 id = 2; optional string email = 3; } </code></pre> <p>The compiler generates the following long pile of code:</p> <pre><code># Generated by the protocol buffer compiler. DO NOT EDIT! # source: test.proto import sys _b=sys.version_info[0]&lt;3 and (lambda x:x) or (lambda x:x.encode('latin1')) from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message from google.protobuf import reflection as _reflection from google.protobuf import symbol_database as _symbol_database from google.protobuf import descriptor_pb2 # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() DESCRIPTOR = _descriptor.FileDescriptor( name='test.proto', package='', serialized_pb=_b('\n\ntest.proto\"1\n\x06Person\x12\x0c\n\x04name\x18\x01 \x02(\t\x12\n\n\x02id\x18\x02 \x02(\x05\x12\r\n\x05\x65mail\x18\x03 \x01(\t') ) _sym_db.RegisterFileDescriptor(DESCRIPTOR) _PERSON = _descriptor.Descriptor( name='Person', full_name='Person', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='name', full_name='Person.name', index=0, number=1, type=9, cpp_type=9, label=2, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='id', full_name='Person.id', index=1, number=2, type=5, cpp_type=1, label=2, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='email', full_name='Person.email', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, extension_ranges=[], oneofs=[ ], serialized_start=14, serialized_end=63, ) DESCRIPTOR.message_types_by_name['Person'] = _PERSON Person = _reflection.GeneratedProtocolMessageType('Person', (_message.Message,), dict( DESCRIPTOR = _PERSON, __module__ = 'test_pb2' # @@protoc_insertion_point(class_scope:Person) )) _sym_db.RegisterMessage(Person) # @@protoc_insertion_point(module_scope) </code></pre>
0debug
static av_cold int dvvideo_encode_init(AVCodecContext *avctx) { DVVideoContext *s = avctx->priv_data; FDCTDSPContext fdsp; MECmpContext mecc; PixblockDSPContext pdsp; int ret; s->sys = av_dv_codec_profile(avctx->width, avctx->height, avctx->pix_fmt); if (!s->sys) { av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video. " "Valid DV profiles are:\n", avctx->width, avctx->height, av_get_pix_fmt_name(avctx->pix_fmt)); ff_dv_print_profiles(avctx, AV_LOG_ERROR); return AVERROR(EINVAL); } ret = ff_dv_init_dynamic_tables(s, s->sys); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error initializing work tables.\n"); return ret; } avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) return AVERROR(ENOMEM); dv_vlc_map_tableinit(); ff_fdctdsp_init(&fdsp, avctx); ff_me_cmp_init(&mecc, avctx); ff_pixblockdsp_init(&pdsp, avctx); ff_set_cmp(&mecc, mecc.ildct_cmp, avctx->ildct_cmp); s->get_pixels = pdsp.get_pixels; s->ildct_cmp = mecc.ildct_cmp[5]; s->fdct[0] = fdsp.fdct; s->fdct[1] = fdsp.fdct248; return ff_dvvideo_init(avctx); }
1threat