Posts

Showing posts from June, 2011

python - How do I repeatedly shift and pad elements in a list to get a list of lists? -

i have list a = [1, 2, 3, ..., n] , want repeatedly shift list list of lists. first row should a , second row [2, 3, 4, ...] , third row [3, 4, 5, ...] , until last row [n, 0, 0, ...] . missing elements in last columns should zeros. trying put them individually, n >= 100 manually padding zeros take long. how do this? edit same question numpy arrays, have. >>> = [1, 2, 3, 4] >>> [ a[i:] + i*[0] in range(len(a))] [[1, 2, 3, 4], [2, 3, 4, 0], [3, 4, 0, 0], [4, 0, 0, 0]] how works to i'th shifted list, can use: a[i:] + i*[0] . list comprehension repeatedly i's need. using numpy + means different numpy arrays normal python lists. consequently, above code needs tweaks adapt numpy: >>> import numpy np >>> = np.arange(1, 5) >>> [ np.concatenate((a[i:], np.zeros(i))) in range(len(a))] [array([1, 2, 3, 4]), array([2, 3, 4, 0]), array([3, 4, 0, 0]), array([4, 0, 0, 0])] if want final result numpy array: ...

rubymotion - How to use ProMotion-Menu? -

Image
i did new project code shown in promotion-menu's readme . have : # app_delegate.rb class appdelegate < pm::delegate def on_load(app, options) @menu = open menudrawer end def show_menu @menu.show :left end end #menu_drawer.rb class menudrawer < pm::menu::drawer def setup self.center = homescreen.new(nav_bar: true) self.left = navigationscreen self.to_show = [:pan_bezel, :pan_nav_bar] self.transition_animation = :swinging_door self.max_left_width = 250 self.shadow = false end end #navigation_screen.rb class navigationscreen < promotion::tablescreen def table_data [{ title: nil, cells: [{ title: 'overwrite method', action: :swap_center_controller, arguments: homescreen }] }] end def swap_center_controller(screen_class) app_delegate.menu.center_controller = screen_class end end my app running there no sidebar can see here : did miss ? n...

how to insert specific json into sqlite database using python 3 -

using python 3, want download api data, returned json, , want insert specific (columns or fields or whatever?) sqlite database. so, here's i've got , issues have: using python's request module: ##### import modules import sqlite3 import requests import json headers = { 'authorization' : 'ujbosdlknfsodiflksdonosb4aa=', 'accept' : 'application/json' } r = requests.get( 'https://api.lendingclub.com/api/investor/v1/accounts/94837758/detailednotes', headers=headers ) okay, first issue how requested json data (a dictionary?) python can use. that... jason.loads(r.text) then create table want insert specific data: curs.execute('''create table data( loanid integer not null, noteamount real not null, )''') no problem there...but now, though json data looks (although there hundreds of records)... { "mynotes": [ { "loanid":11111, "noteid":22222, "orde...

configuration - Adding skip-grant-tables to MySQL my.ini does not seem to be working -

i trying reset lost root@localhost password, explained in this question . adding line skip-grant-tables directly underneath [wampmysqld] / [mysqld] known way gain access in order reset passwords, in case not doing anything. after making sure mysql not running, editing file, restarting , opening mysql console, password prompt appears, stuck. what possibly overlooking? my stack wamp 2.5, mysql 5.6.17. my my.ini file looks this: # example mysql config file medium systems. # # system little memory (32m - 64m) mysql plays # important part, or systems 128m mysql used # other programs (such web server) # # can copy file # /etc/my.cnf set global options, # mysql-data-dir/my.cnf set server-specific options (in # installation directory c:\mysql\data) or # ~/.my.cnf set user-specific options. # # in file, can use long options program supports. # if want know options program supports, run program # "--help" option. # following options passed mysql clients [client] #p...

java - ByteBuddy fails when trying to redefine sun.reflect.GeneratedMethodAccessor1 -

driven curiosity, tried export bytecode of generatedmethodaccessor1 (generated jvm when using reflection). i try bytecode of class following way: public class methodextractor { public static void main(string[] args) throws exception { exampleclass example = new exampleclass(); method examplemethod = exampleclass.class .getdeclaredmethod("examplemethod"); examplemethod.setaccessible(true); int rndsum = 0; (int = 0; < 20; i++) { rndsum += (integer) examplemethod.invoke(example); } field field = method.class.getdeclaredfield("methodaccessor"); field.setaccessible(true); object methodaccessor = field.get(examplemethod); field delegate = methodaccessor.getclass().getdeclaredfield("delegate"); delegate.setaccessible(true); object gma = delegate.get(methodaccessor); bytebuddyagent.installonopenjdk(); try ...

excel - SUMIFS based on name and date range -

i'm trying formula sum values on cells based on 2 criteria, date range , name. column contains date, column b contains text, column c contains employee name, need sum on different ws values column e "qty" based on criteria column h "date" , column c "employee name", column d contains text, column e contains number (this 1 need add up), column f contains employee #, column g contains number , column h contains date. rows go 2 100. i've tried vlookup find "employee name" , sumifs date range i've been unable combine both formulas desired result. as example need sum "qty" employee "jones, mary" during month of march , come result = 5. with march 1, 2015 in a1, jones, mary in b1 , 'different ws' called sheet2, try, =sumifs('sheet2'!e:e, 'sheet2'!f:f, b1, 'sheet2'!h:h, ">="&a1, 'sheet2'!h:h, "<"&edate(a1, 1))

javascript - Angular ui-router is not instantiated, giving an inject module error -

hello have weird problem angular ui-router. renew webapp , want angular. have heard lot of things ui-router not getting work. following tutorial on how set views, error: uncaught error: [$injector:modulerr] failed instantiate module fqmapp due to: typeerror: undefined not function i using cdn's import angular , ui-router. exact code: <!doctype html> <html ng-app="fqmapp"> <head> <script src="https://code.angularjs.org/1.3.9/angular.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.13/angular-ui-router.min.js"></script> <script src="app.js"></script> </head> <body> <div ui-view> </div> <a ui-sref="state1">state 1</a> <a ui-sref="state2">state 2</a> </body> </html> js "use str...

php - Multiple connection source for sql localdb -

i have winform application. using sql localdb. server connection string below; string.format(@"data source=(localdb)\v11.0;attachdbfilename={0};integrated security=true", "c:\database\mydb.mdf"); i connect same db php pdo. installed sqsrv.dll etc. php , works. couldn't connect localdb when winform using it. codes below tried. new pdo('sqlsrv:server=(localdb)\v11.0;attachdbfilename=c:\database\mydb.mdf;database=mydb', null, null); above codes give error "couldn't attach because mdf file using another..." new pdo( 'sqlsrv:server=(localdb)\v11.0', null, null); above code give error "database object not found" thank in advance. new pdo('sqlsrv:server=(localdb)\v11.0;attachdbfilename=c:\database\mydb.mdf;database=mydb', null, null); above codes working if apache runs not service. may helps someone.

linux - What does this piece of code in the kernel.h mean? -

the below code linux kernel: /** 639 * container_of - cast member of structure out containing structure 640 * @ptr: pointer member. 641 * @type: type of container struct embedded in. 642 * @member: name of member within struct. 643 * 644 */ 645 #define container_of(ptr, type, member) ({ \ 646 const typeof( ((type *)0)->member ) *__mptr = (ptr); \ 647 (type *)( (char *)__mptr - offsetof(type,member) );}) 648 i fail understand @ line 646-648. know these 2 lines comments above it, dont understand code word word. can explain me this? the intent given anonymous pointer, know pointer element of larger structure, calculates beginning address of larger structure.

Using native git not jgit in Eclipse git? -

is there way configure egit use native (os) git , not jgit implementation? if not, there alternative git eclipse plugins? edit #1 - should note, aws codecommit uses credential helper auth, .gitconfig: [credential] helper = !/usr/local/bin/aws --profile codecommitprofile codecommit credential-helper $@ usehttppath = true i'm guessing specific codecommit , not in jgit. egit strictly uses jgit , java implementation of git. the git plugin in aptana sudio3 seems embedded in product sources ( github.com/aptana/studio3 ), uses native git. there class jgit.transport.amazons3 , illustrated in this question , this 1 (setting iam) . there interesting discussion in thread can offer clue patch: having looked @ how jgit access s3 host , jgit tries access bucket using virtual hosted style requests - http://bucketname.s3.amazonaws.com/ - request style works fine buckets in standard zone, other regions s3 redirects http 307 redirect correct region. ...

Android MediaPlayer - setDataSource and Release - IllegalStateException -

i wrote own mediaplayer class play files @ specific path , play files assets folder. here class: public class cmediaplayer extends mediaplayer{ public void play(string audiopath){ this.setoncompletionlistener(new oncompletionlistener() { @override public void oncompletion(mediaplayer mp) { mp.release(); } }); file f = new file(audiopath); if(f.exists()){ try{ fileinputstream fis = new fileinputstream(f); filedescriptor filed = fis.getfd(); this.setdatasource(filed); this.prepare(); }catch(ioexception e){ } this.start(); } } public void play(assetfiledescriptor descriptor){ this.setoncompletionlistener(new oncompletionlistener() { @override public void oncompletion(mediaplayer mp) { mp.release(); } }); try { this.setdatasource(descriptor.getfiledescriptor()...

vba - Grouping similar names in a column and offset to sum that grouped range -

Image
i have macro running in excel. have companies’ names in column “d”. name of column security description (long 1). trying group similar sounding names or identical names , insert row between groups. macro working grouping not accurate right now. code below: dim rowcount integer dim n integer rowcount = range(range("a15000").end(xlup), "a7").rows.count range("d6").select if selection <> "" n = 1 rowcount + 1 selection.offset(1, 0).select if selection <> selection.offset(-1, 0) if selection.offset(-1, 0) "* security description (long 1)*" selection.entirerow.insert shift:=xldown selection.entirerow.insert shift:=xldown selection.offset(2, 0).select else selection.entirerow.insert shift:=xldown selection.entirerow.insert shift:=xldown if selection.offset(-2) = vbnullstring ...

spring - Saving an object via getSessionFactory().getCurrentSession().save(item) -

even if operation seems extremely used haven't found problem in code. in dao class have: public class itemdaoimpl extends hibernatedaosupport implements itemdao { @transactional public void additem(item item){ getsessionfactory().getcurrentsession().save(item); } @transactional(readonly = true) public list<item> findallitem(){ return getsessionfactory().getcurrentsession().createquery("from item").list(); }} findallitem() works well, whereas additem() doesn't. when click button invokes additem() following error thrown: java.lang.classcastexception: com.z.item.model.item cannot cast java.util.map javax.faces.el.evaluationexception: java.lang.classcastexception: com.z.item.model.item cannot cast java.util.map @ javax.faces.component.methodbindingmethodexpressionadapter.invoke(methodbindingmethodexpressionadapter.java:98) @ com.sun.faces.application.actionlistenerimpl.processaction(actionlistenerimpl.ja...

if statement - Php retrieve query and use in If statment -

ok, trying able pretty easy in asp reason, despite reading documentation, can figure out why if statement displaying code. i trying retrieve query string of ?fs=success if true display html, if not nothing. going wrong page displays code if no query string present. thanks if ($_get['fs'] = 'success') { echo "<div class='container'><div class='row configurecellsplitbg-ouline color-contrast-yellow text-center'><h3>thank you</h3><p>we have recieved message , soon!</p></div></div>"; } single = sets it, double equals checks value. http://php.net/manual/en/language.operators.comparison.php if ($_get['fs'] == 'success') {

ios - retrievePeripherals deprecated in IOS7 how to substitude it with retrievePeripheralsWithIdentifiers -

i using "[self.manager retrieveperipherals:[nsarray arraywithobject:(id)aperipheral.uuid]];” works fine deprecated in ios7. found have use “ retrieveperipheralswithidentifiers ” instead. can not figure out right syntax new function. can please translate "[self.manager retrieveperipherals:[nsarray arraywithobject:(id)aperipheral.uuid]];” to new function “retrieveperipheralswithidentifiers”. // invoked when central discovers heart rate peripheral while scanning. - (void) centralmanager:(cbcentralmanager *)central diddiscoverperipheral:(cbperipheral *)aperipheral advertisementdata:(nsdictionary *)advertisementdata rssi:(nsnumber *)rssi { nsmutablearray *peripherals = [self mutablearrayvalueforkey:@"heartratemonitors"]; if(![self.heartratemonitors containsobject:aperipheral]) [peripherals addobject:aperipheral]; // retrieve known devices [self.manager retrieveperipherals:[nsarray arraywithobject:(id)aperipheral.uuid]]; } ...

python - Append a list of arrays as column to pandas Data Frame with same column indices -

i have list of arrays (one-dimensional numpy array) (a_) , list (l_) , want have dataframe them columns. this: a_: [array([381]), array([376]), array([402]), array([400])...] l_: [1.5,2.34,4.22,...] i can by: df_l = pd.dataframe(l_) df_a = pd.dataframe(a_) df = pd.concat([df_l, df_a], axis=1) is there shorter way of doing it? tried use pd.append : df_l = pd.dataframe(l_) df_l = df_l.append(a_) however, because columns indices both 0, adds a_ end of dataframe column, resulting in single column. there this: l_ = l_.append(a_).reset(columns) that set new column index appended array? well, not work! the desired output like: 0 0 0 1.50 381 1 2.34 376 2 4.22 402 ... thanks. suggestion: df_l = pd.dataframe(l_) df_1['a_'] = pd.series(a_list, index=df_1.index) example #1: l = list(data) = list(data) data_frame = pd.dataframe(l) data_frame['a'] = pd.series(a, index=data_frame.index) example #2 - same ...

wordpress - PHP Session Variable Set in Root not Visible in Subdirectory -

i have wordpress running on windows shared hosting (iis) w/ godaddy. wordpress running out of it's own subdirectory "/wordpress". if set php session value e.g. $_session["test1"] = "value set root: /"; in php root, can see session's value fine long php code running out of root. if try , access session value /wordpress folder, not found. vice versa applies. if set session value under /wordpress , subdirectories, can view session , values great long operate within /wordpress folder. if try , access session value set within /wordpress in root not accessible. i've checked session ids , both same root , /wordpress folder. i've inspected cookies set both , have same path & domain. i'm @ loss why setting php session values root versus /wordpress folder not global. appreciated. thanks. /set_session.php <?php session_start(); $_session["test1"] = "value set root: /"; ?> /wordpress/set_session.p...

php - Possible to have Mysql table with 2 unique columns -

i save game scores using code: function submitscore() { global $result, $db; $playername = $db->real_escape_string(strip_tags($_post["playername"])); $score = $db->real_escape_string(strip_tags($_post["score"])); $fbusername = $db->real_escape_string(strip_tags($_post["fbusername"])); $gamelevel = $db->real_escape_string(strip_tags($_post["gamelevel"])); $query1 = "select * leaderboard playername = '$playername'"; $query2 = "insert leaderboard (playername, score,fbusername,gamelevel) values ('$playername', $score,'$fbusername','$gamelevel')"; $query3 = "update leaderboard set score = $score playername = '$playername'"; $scores = $db->query($query1); if ($scores->num_rows == 0) { $db->query($query2); $result = "0:new entry"; } else { $row = $scores->fetch_object(); $oldscore = $row->scor...

java - Comparing charAt(x) to String array = letter [y] -

i trying write piece of code produces letter frequency using arrays. getting bit stuck on how compare letter in string letter in array. basic pseudo code follows. import java.util.scanner; public class test { public static void main (string[]args){ scanner sc = new scanner (system.in); system.out.print ("please enter sentence: "); string str = sc.nextline(); string [] let = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}; float [] freq = new float [25]; int x,a = 0,b = 0, strcount = 0; string str1; str1 = str.replaceall(" ", ""); ...

java - regular expression to read a line separated by quotation marks and semicolon -

for example, have 1 line of code: "12345";"isbn345";"8" i want write regular expression extract 12345, isbn345, 8. how write regular expression? updated:sorry. i did not make clear. there real data : "276729";"052165615x";"3" (my data has many lines , line example). want extract 276729 (user id) 1 element, 052165615x (book number) one, 3 (book rating) one(that means need match regular expression 3 times per line,so can create 3 objects each time read 1 line) not extract 276729 052165615x 3 @ 1 time "([^"]+)"(;"([^"]+)")* [^"]+ match non-empty sequence of non-quote characters. can switch + * if strings can empty. this entire regex 1 quote sequence of not-quotes followed 0 or more quoted sequences separated semicolons.

c# - Repository and query objects pattern. How to implement complex queries -

i have read lot of posts of repository pattern there few practical problems doesn't seem solve or explain. understand 2 patterns: the repository , query pattern complementary: query objects represents business logic (where clausules) , repository pattern has get(ipredicate) method takes query object , returns select result the repository should not have business logic: business logic must go on query objects currently have class wraps each logical object (wich single entity object) implements multiple "get" methods implement complex queries (joins, groupby, etc...), isn't pattern because classes tend grow lot because of boilerplate code similar queries , public methods dependent on context class used, thus, making classes unusable multiple projects depends on same database, wich primary goal project refactoring. how queries more complex single select implemented 2 patterns without leaking business logic repository? or if business logic doesn't fi...

python - How to make document names to be clickable hyperlinks? -

this question has answer here: hyperlink in tkinter text widget? 2 answers i writing search engine indexes collection of files on hard drive. have script takes query query = raw_input() , outputs set of file names. i want file names clickable hyperlinks open file when user clicks on them. how do this? interface (if requires interface) search box , output box. this appears possible in matlab . also, if there's ide allows this, acceptable (but not preferable). import webbrowser ... self.entryfield = entry(self.frame) ... mybutton = button(self.frame, text="open site", command= lambda: webbrowser.open(self.entryfield.get())) if user enters http://www.stackoverflow.com self.entryfield , clicks mybutton , it'll open browser , go so. see webbrowser .

R trouble with substitute when formula writing -

i'd iterate on formula independent variable passed string. i'm using substitute , expression don't know why it's failing. please see following: > coxph(substitute(survivaloutcome ~ x, list(x = as.name(colnames(combineddata)[1]))), data = combineddata) error in terms.default(formula, special, data = data) : no terms component nor attribute > substitute(survivaloutcome ~ x, list(x = as.name(colnames(combineddata)[1]))) survivaloutcome ~ pmm2 > coxph(survivaloutcome ~ pmm2, data = combineddata) call: coxph(formula = survivaloutcome ~ pmm2, data = combineddata) coef exp(coef) se(coef) z p pmm2 0.0445 1.05 0.146 0.305 0.76 likelihood ratio test=0.09 on 1 df, p=0.761 n= 206, number of events= 129 > > colnames(combineddata)[1] [1] "pmm2" as can see, expression matches perfectly, don't know why fails?

ios - Key-Value Observe in Swift not showing insertions and removals in arrays -

i created class contains array. added observer array in view controller , performed modifications array. the problem when print change dictionary returned observevalueforkeypath() method can see changes of kind nskeyvaluechangesetting. in other words, method tells me array has changed, provides me old , new arrays (containing elements) receive information of specific items added or removed. here example code. this class array observed. private let _observedclass = observedclass() class observedclass: nsobject { dynamic var animals = [string]() dynamic var cars = [string]() class var sharedinstance: observedclass { return _observedclass } } and code @ view controller. class viewcontroller: uiviewcontroller { var observedclass = observedclass.sharedinstance required init(coder adecoder: nscoder) { super.init(coder: adecoder) observedclass.addobserver(self, forkeypath: "animals", options: .new | .old, context: ni...

c# - ASP.NET authentication using unique numbers -

i not know called. thought called 2-factor authentication references on web refer email or pin emailed reset password. i'd have asp.net mvc site require username/password and unique ever-changing number such 1 iphone's authenticator app. little keychanges used have numbers changing? i have not settled on authentication method yet: azure active directory or custom. have @ 10 users of system, each different "roles": admin, manager (rw) , user (r). if have opinion here, please main question first paragraph. any / pointers appreciated. thanks, -ed

ruby on rails - Getting duplications when listing records when using has_many :through -

i have 3 tables: manager , site , visit . goal i able create visits in way when find valid manager , valid site create valid visit. problems when tried simple has_many :though association got unexpected results(i haven't been using often). i have set way: class manager < activerecord::base has_many :sites, through: :visits has_many :visits end class site < activerecord::base has_many :managers, through: :visits has_many :visits end class visit < activerecord::base belongs_to :manager belongs_to :site end the first problem have when find manager , site: manager = manager.find(3) site = site.find(5) and create 2 visits: visit.create(manager: manager, site: site) visit.create(manager: manager, site: site) i have 2 visits expected: manager.visits.count #2 site.visits.count #2 but haven't expected , don't wont 2 sites manager: manager.sites.count #2 i manager.sites return 1 site manager has visited 1 site:/ problem 2...

xcode - Linker Error with SoundCloud iOS SDK -

i trying link frameworks needed soundcloud sdk based on tutorial https://developers.soundcloud.com/docs/api/ios-quickstart#installation it tells link libsoundcloudapi.a, libsoundcloudui.a, etc , appear in workspace folder when add them after add them appear red , xcode cannot find them. when build mach -o linker error because xcode cannot locate these files. i've searched through frameworks , couldn't find them. any , appreciated. i afraid soundcloud decided not maintain anymore library, decided create own 1 , publish it. maybe can you. abmsoundcloudapi on github

javascript - What does mean "Server(srv:http#Server, opts:Object)" in socket.io api doc? -

mentioning above, want know meaning of special character in socket.io api document, link below. https://github.com/automattic/socket.io#serversrvhttpserver-optsobject at document, title use #, :, srv, , can't understand mean. another question is, know tutorial or guidance post of socket.io? official document has few examples , explanation insufficient me. thanks. i've spent last 12 weeks building production app using socket.io, , feel documentation frustrations. dave's answer going tell regarding actual command. regarding decyphering documentation: the colon ( : ) used specify type of parameter being accepted. hashtag ( # ) seems represent properties of particular object. srv i'm not sure, i'm guessing refers particular serve method you're opting use. if i'm correct srv, why? specific syntax use bind socket.io can vary depending on other npm modules you're using. documentation on socket.io shows there's different...

How can I repair foxpro .dbf database error message? -

i have client received error message when foxpro application initiated, foxpro v9.0 error msg: "unrecognized database format". my client reported had power failure , problem appeared after rebooted pc. it appears foxpro database corruption caused power failure. any suggestions, friends... here link vfp code repair corrupt table headers in vfp. provided have vfp, low-level file open, checks entire file size, detects record size , resets record count. have client still has vfp apps going, , once in great while, have whatever power outage / surges / network connectivity issues , corrupts header. run routine , in business...

python - Pythonic way of reading text file using Swift -

i know python , i'm trying learn swift... trying figure out how read plain text file absolute file path in python, #!/usr/bin/python path= '/users/mu/desktop/test_file.txt' in_file= open(path,'w').read() #open file reading line in in_file.split('\n'): #split line breaks , print lines print line tried one: swift - read files got: "string.type not have member name stringwithcontentsoffile" in python, it's easy. there must simple way read text file , create list of strings separated line breaks. my question how read text file can iterate through lines once read file, just: for line in in_file { println(line) } you can use nsfilemanager , nsstring parse lines eg : var path = "somepath" let filemanager = nsfilemanager.defaultmanager() let data:nsdata = filemanager.contentsatpath(path)! var strs = nsstring(data: data, encoding: nsutf8stringencoding)

Removing docker image errors "No such id" with a different image ID -

parallels@ubuntu:~$ sudo docker images [sudo] password parallels: repository tag image id created virtual size ubuntu 14.10 525b6e4a4cc8 6 days ago 194.4 mb <none> <none> 4faa69f72743 6 days ago 188.3 mb <none> <none> 78949b1e1cfd 3 weeks ago 194.4 mb <none> <none> 2d24f826cb16 3 weeks ago 188.3 mb <none> <none> 1f80e9ca2ac3 3 weeks ago 131.5 mb <none> <none> 5ba9dab47459 6 weeks ago 188.3 mb <none> <none> c5881f11ded9 9 months ago 172.2 mb <none> <none> 463ff6be4238 9 months ago 169.4 mb <none> <none> ...

php - setting php_flag error_reporting not working -

i have found error_reporting frustrating, need set following in .htaccess file: php_flag error_reporting 22519 for legacy code. and while i'm in right place (phpinfo() says value has been changed), value changed 0!! i can't change in php.ini - value shows in phpinfo() 22527. idea i'm doing wrong? i tried: php_flag error_reporting 1 just grins - works. tried other values, , revert 0. its "php_value", not php_flag. heres comprehensive reference on php error reporting values demystify little you: http://www.bx.com.au/tools/ultimate-php-error-reporting-wizard

android - can I read public static final field inside a nested public static abstract class in Java -

so while created sqlitehelper class in android app. i'm not 100% why, table , column names public static final fields in nested public static abstract class. recall, goal protect fields being modified. works great things starting sophisticated app , want populate fields in other classes public static final table , column name fields. after trial , error, , reading abstract classes, static classes, , nesting classes, occurred me can call field directly, in. string mytable = mysqlitehelper.dbfields.table_name_reminder; even though i've read on these topics, how comes in specific case still making me scratch head. question is, since fields static final, nesting fields provide additional protection, , if nested class static, why make abstract? static , abstract required call directly without needing instantiate outer , nested classes? thanks help. i'm trying head wrapped around various class implementations. here's key elements of class : public class m...

javascript - Set global instance of toastmessage using akquinet jquery toast message plugin -

i using jquery plugin show toast message on click of button given condition. , when click on button new toast message shown. want show 1 toast message being shown on click of button meaning, should not show toast message when first toast message still on screen. is there way have global instance of , showing same each time rather show new 1 ? any appreciated. in advance. you use boolean remember if toast message displayed. see jsfiddle (forked official demo ). use mytoast variable "boolean" in similar way. $(document).ready(function() { var isdisplaying = false; var yourtext = 'success dialog not sticky', toastmessagesettings = { text: yourtext, sticky: false, position: 'top-right', type: 'success', closetext: '', close: function() { console.log("toast closed ..."); isdisplaying = ...

regex - Regular Expression in JavaScript for String Comma Separated -

i have string follows new york, new york, united states i need regular expression ether @ least 1 comma or @ least 2 comma or 3 words 2 commas in between . ^[^,\n]+,(?:[^,\n]+,?)*$ you can use this.replace * {1,2} if want 3 words.see demo. ^[^,\n]+,(?:[^,\n]+,?){0,2}$ https://regex101.com/r/bw3ar1/11 var re = /^[^,\n]+(?:,[^,\n]+)*$/gm; var str = 'new york, new york, united states\nnew york, new york\nnew york\nnew york, new york, united states,'; var m; while ((m = re.exec(str)) != null) { if (m.index === re.lastindex) { re.lastindex++; } // view result using m-variable. // eg m[0] etc. }

finding the nth prime javascript -

the functions below supposed spit out nth prime number. however, keeps on spitting out 3. can please help? cheers, anthony function prime(num) { output = true (i=2 ; i<num ; i++) { if (num%i === 0) { output = false ; break } } return output } function primemover(num) { var count = 0 (i=2 ; i<10000 ; i++) { if (prime(i) === true) { count = count + 1 } if (count === num) { return break } } } you have created loop counter i in global scope .so both primemover , prime mutates same global i .in every iteration ,primemover assigns i=2 .after prime assigns i=2 .your i variable's value changed between 2 , 3 .use local loop counter variable var i=0; function prime(num) { output = true (var i=2 ; i<num ; i++) { //var i=2 if (num%i === 0) { output = false ; break } } return output } function primemover(num) { var count = 0 ...