Posts

Showing posts from January, 2010

xcode - iOS BarButton padding and font size -

Image
i have storyboard , text in center , how can move text in height center of nav bar change font size of bar button is uinavigationbar? , i'm assuming title nil, , "text" uibarbuttonitem? can change offset of bar button settitlepositionadjustment:forbarmetrics: . but don't think can change font size. may need substitute in view initwithcustomview: . might easier way adjust vertical positioning @ same time.

r - read.table, one line matrices, etc -

i'm struggling presumably simple issue cannot fix, possibly want of right keywords up... i have following file (test.data): th ba rb la ce nd sm eu pm 0.0813 6.049 0.5353 0.6139 1.6011 1.1892 0.3865 0.1456 v.morb 0.333 0.459 0.356 0.261 0.224 0.203 0.189 note tab-separated (not visible on screen, sorry), no trailing tabs, 1 item less in first line parsed colnames. note there missing item (second line, col. "nd"); totally empty in file (i.e. 2 successive tabs, nothing in between) > foo<-read.table("test.data",sep="\t") > foo th ba rb la ce nd sm eu pm 0.0813 6.049 0.5353 0.6139 1.6011 1.1892 0.3865 0.1456 v.morb 0.3330 0.459 0.3560 0.2610 0.2240 na 0.2030 0.1890 > rownames(foo) [1] "pm" "v.morb" > colnames(foo) [1] "th" "ba" "rb" "la" "ce" "nd" "sm" "e

sql - MySQL SELECT values with more than three words -

i have following code select * list name '___' order name; i trying shows names 3 or more words. displays names 3 characters cannot seem work out correct syntax this. any appreciated thankyou if assume there no double spaces, can do: where name '% % %' to names 3 or more words. if can have double spaces (or other punctuation), want regular expression. like: where name regexp '^[^ ]+[ ]+[^ ]+.*$'

how to remove index.php file from url in codeigniter? -

i trying remove index.php url, confused code used in .htaccess file , changes have make on related file in codeigniter . just use .htaccess rewriteengine on rewritecond $1 !^(index\.php|images|robots\.txt) rewriterule ^(.*)$ /index.php/$1 [l] taken here

Is it ok for a REST api to be exposed via two HTTP methods? -

the problem have complex query string search api , want let users have convenience of using body instead. want allow both , post(or put). i understand there debate of search being read operation , should per rest standards. put not cache friendly understand. know ok deviate @ times rest standards. make sense have 2 methods client's convenience? using post directly query data not thing, precisely reasons mentioned. if search string complex, perhaps simplify things splitting querying process in 2 steps - 1 involving post , , 1 involving straight get s. the first step creates query template using post . query string sent via message body, , becomes new resource users can query through get . query string allows parameters, in way similar sql queries. taking wild guess @ how query might look, here example: (username = $name) || (createdbefore > $asof && deleted=false) your users post in message body, , new resource identifier back. resource identifies

mysql - JOINING more then once? -

i have table of users: users have table booths users =============================== id | name | sid ------------------------------- 1 cillia abcd 2 ted efgh booth ===================================================== booth_id | booth_owner | booth_manager ----------------------------------------------------- 1 1 2 2 2 4 3 1 3 i create query make clear specific booth, name of manager , name of owner. best approach that? you link users table booth table twice: select b.booth_id, s1.name boothowner, s2.name boothmanager booth b inner join users s1 on b.booth_owner = s1.id inner join users s2 on b.booth_manager = s2.id

javascript - Changing a three.js object's geometry -

i trying change geometry of objects in three.js scene. have almost-working piece of code mouse click triggers change, got following problem: (rendered) shape changed on first mouse click, though geometry modified each following clicks. using v66 or v68 of three.js library, if relevant. i read three.js: change object's geometry , updating geometry inside mesh nothing couldn't code work far. relevant parts of code: var count = 0, item, geometry; var geoms = [new three.spheregeometry(2), new three.boxgeometry(3, 3, 3)]; function init() { geometry = geoms[count]; item = new three.mesh(geometry, material); scene.add(item); } // mouse click listener. function handleclick(event) { count = 1 - count; geometry = geoms[count]; item.geometry = geometry; /* next line, on first click, sphere * becomes cube (as intended), further clicks don't * change view anymore, though item.geometry * modified. */ item.geometry.buf

groovy - How to fix "identifier of an instance of X was altered from 2 to null" in grails -

i have 2 domain classes in grails. 1 called book , other called author. book class looks this, class book { string name static constraints = { name nullable:false } } and author class: class author { string name book book1 book book2 book book3 static constraints = { name nullable:false book1 nullable:false book2 nullable:true book3 nullable:true } } ff create author 2 books , edit 1 book got following error: identifier of instance of com.apps.book altered 2 null how fix it? using grails 2.1.1 , sql server 2008. try set null book2 , book3 properties before line authorinstance.properties = params in update method this: book2 = null book3 = null authorinstance.properties = params

java - Load a file content to be used in a test with JMeter and a AbstractJavaSamplerClient -

so there i'm missing here how use jmeter. i reading in user guide can use java sampler run test. it's ok because need read file content in , send storage engine. so starting writing unit tests implement version of javasample using class abstractjavasamplerclient. i counting load file in setup once, puzzles me fact can;t pass runtest method using sampler context. how do this? mean, if lose time loading file each time test has no meaning wouldn't easier use __filetostring() function wherever it's required? if want file read 1 time once controller can used read file jmeter variable if you're going re-use variable in multiple thread groups vlns says should converted jmeter property variables scope limited current thread group only. see how use variables in different thread groups .guide implementation details.

c# - Recursive yield method to traverse object graph and return visited nodes -

i'm trying write extension method supposed traverse object graph , return visited objects. i'm not sure if approach best, please comment on that. yield frying brain... i'm sure answer obvious :/ model public class myclass { public myclass parent {get;set;} } method public static ienumerable<t> selectnested<t> (this t source, func<t, t> selector) t : class { yield return source; var parent = selector(source); if (parent == null) yield break; yield return selectnestedparents(parent, selector).firstordefault(); } usage var list = myobject.selectnested(x => x.parent); the problem it's working. visits 2 objects. self , parent. so given graph c -> b -> a starting c . c, b returned not quite wanted. the result i'm looking b, c in last line of selectnested return first parent: yield return selectnestedparents(parent, selector).firstordefault(); you have return parents:

Something's wrong with my Python code (complete beginner) -

so new python , can't figure out what's wrong code. i need write program asks name of existing text file , of other one, doesn't need exist. task of program take content of first file, convert upper-case letters , paste second file. should return number of symbols used in file(s). the code is: file1 = input("the name of first text file: ") file2 = input("the name of second file: ") f = open(file1) file1content = f.read() f.close f2 = open(file2, "w") file2content = f2.write(file1content.upper()) f2.close print("there ", len(str(file2content)), "symbols in second file.") i created 2 text files check whether python performs operations correctly. turns out length of file(s) incorrect there 18 symbols in file(s) , python showed there 2. could please me one? issues see code: close method, need use () operator otherwise f.close not think. it preferred in case use with form of opening file -- close au

javascript - How to automatially go to the otherpage after clearing some fields? -

i making scratchcard game , need know how check if cleared go next page. show u part of code have i got 9 of these scratch pads , want go other page when cleared nine: var images = [], index = 0; images[0] = "images/slide1.jpg"; images[1] = "images/slide2.jpg"; images[2] = "images/slide3.jpg"; images[3] = "images/logo.jpg"; images[4] = "images/winner.png"; images[5] = "images/scratch-to-win.png"; index = math.floor(math.random() * images.length); $('#nummer9').wscratchpad({ scratchmove: function (e, percent) { console.log(percent); if (percent > 70) { this.clear(); } } }); $("#nummer9").wscratchpad('bg', images[index]); $("#nummer9").wscratchpad('fg', 'images/overlay.png');

sqlTables in R from RODBC package not getting correct set of tables -

i have 2 schemas in mysql database. 1 labeled p73, other labeled p75. trying set of tables associated p75 however, when call tables <- sqltables (channel, schema - "p75") still set of tables associated p73. how solve problem? here code script library(rodbc) print("enter dsn name") dsn <- readline() print("enter user name") user <- readline() print("enter password") pw<- readline() channel<- odbcconnect(dsn, user, pw) print("please enter project name (ex: p73)") pj <- readline() tables <- sqltables (channel, schema - pj)

python - Remove lines in dataframe using a list in Pandas -

it's generic question filtering pandas dataframe using list. problem following: i have pandas dataframe df column field i have list of banned fields, example ban_field=['field1','field2','field3'] all elements of ban_field appear in df.field for moment, retrieve dataframe without banned field, proceed follows: for f in ban_field: df = df[df.field!=f] is there more pythonic way proceed (in 1 line?)? method #1: use isin , boolean array selector: in [47]: df = pd.dataframe({"a": [2]*10, "field": range(10)}) in [48]: ban_field = [3,4,6,7,8] in [49]: df[~df.field.isin(ban_field)] out[49]: field 0 2 0 1 2 1 2 2 2 5 2 5 9 2 9 [5 rows x 2 columns] method #2: use query : in [51]: df.query("field not in @ban_field") out[51]: field 0 2 0 1 2 1 2 2 2 5 2 5 9 2 9 [5 rows x 2 columns]

c - How to properly use qsort()? -

i trying write simple program find median of array. first tried use qsort put values in order can't quite work. believe has function parameter , pointers. #include <stdio.h> #include <stdlib.h> int cmpfunc (const void * a, const void * b) { return ( *(int*)a - *(int*)b ); } int median(const int* array) { double median; int length =0; while(array[length]) length++; qsort(*array, length, sizeof(int), cmpfunc); if(length %2 ==0) { median=(array[length/2] + array[(length/2)+1])/2; } else { median = array[(length +1/2)]; } return median; } int main () { int array [] = {5, 3, 2, 7, 9}; printf( "%f", median(array)); } beside getting wrong value length snippet while(array[length]) // array not ended 0 length++; // length unexpected value you need return double function median , need 1 more parameter length . double median(int* array, const int

Haskell: class instance with class type parameters -

good day. i'm new haskell. 1 thing not clear me concerning declaring , instantiating custom classes. there standard class integral in haskell. according hackage, integral declares mandatory method quot :: -> -> a . means every instance of class should have method implementation, right? we can declare function, using integral argument, like: proba :: (integral a) => -> -> proba x y = x `quot` y so far good now lets declare our own class proba: class proba proba :: -> -> i can implement int or integer (or other data type) instance this: instance proba integer proba x y = x `quot` y instance proba int proba x y = x `quot` y but don't want to. i want 1 instance every integral. when try it, error: instance (integral a) => proba proba x y = x `quot` y illegal instance declaration `proba a' (all instance types must of form (t a1 ... an) a1 ... *distinct type variables*, , each type variable appears

javascript - Strophe.js client connecting to server, disconnect/timeout -

i have little javascript xmpp client, written strophe, connects server hosted on hosted.im. think hosted.im uses ejabberd on backend. i establish connection using strophe.connection(myboshservice), , able send chat messages , forth. however, after time, seems, there automatic disconnect if there no activity. now, question is, way keep session active, not disconnect. disconnect time seems short, 60 seconds or so. should send kind of activity , forth keep open? or, seems simpler me, should somehow change timout of session. if so, can change this? server-setting, irregardless of strophe.connection object, or can set timeout when initializing strophe.connection? thanks , help. best regards, chris edit: here code use connecting: i manage connection through global variable hello (yes, name awkward, took example): var hello = { connection: null, start_time: null, partner: { jid: null, name: null }, log: function (msg) { $('#log').append("<p

shell - Check if a client is connected to the OwnCloud server -

how 1 check on server ownloud running if client connected? there command provided ownloud or can done via bash ? not possible, yet! can make plugin looks last sync time. , if $time < 60 secs ago client online.

c# - Regex matching chunks of multiline text? -

i have text file contains on 200 records of following format: @inproceedings{rajan-sullivan03, author = {hridesh rajan , kevin j. sullivan}, title = {{{eos}: instance-level aspects integrated system design}}, booktitle = {esec/fse 2003}, year = {2003}, pages = {297--306}, month = sep, isbn = {1-58113-743-5}, location = {helsinki, fn}, owner = {administrator}, timestamp = {2009.03.08} } @inproceedings{ras-mor-models-06, author = {awais rashid , ana moreira}, title = {domain models {not} aspect free}, booktitle = {models}, year = {2006}, editor = {oscar nierstrasz , jon whittle , david harel , gianna reggio}, volume = {4199}, series = {lecture notes in computer science}, pages = {155--169}, publisher = {springer}, bibdate = {2006-12-07}, bibsource = {dblp, http://dblp.uni-trier.de/db/conf/models/models2006.html#rashidm06}, isbn = {3-540-45772-0}, owner = {aljasser}, timestamp = {2008.09.16}, url = {http://dx.doi.org/10.1007/118802

Printing CFLAGS in GNU make exaclty once if source files have changed -

here snippet makefile: all: $(target) $(c_objs): %.o: %.c @ echo -n "compiling " $*.c; @ $(cc) -c $(cflags) $*.c -o $*.o @ echo " ...... done" $(target): $(c_objs) @ $(ar) rus $@ $(c_objs); print_cflags: @ echo "cflags: " $(cflags) "\n" moving forward, want print cflags once if compilation takes place. get make: nothing done "all" message if no modifications has been done previous build. printing cflags optional in case. i feel, can achieved keeping counter inside $(c_objs): %.o: %.c but there better way achieve this? understand specific question appreciated. etan gives number of options. here's one, assuming version of gnu make new enough support eval : print_cflags := $(cflags) $(c_objs): %.o: %.c @ $(if $(print_cflags),echo "cflags: $(print_cflags)" $(eval print_cflags:=)) @ echo -n "compiling " $*.c; @ $(cc) -c $(cflags) $*.c -o

javascript - Why resuming media doesn't work after a playlist is loaded in JW Player 6.9? -

i'm trying push new item jw player playlist update player on-the-fly, using javascript api. i can using: var newitem = {}; // media properties... var playlist = jwplayer().getplaylist(); playlist.push(newitem); jwplayer().load(playlist); and works! new item succesfully added. however, jw player pauses when load new playlist. there's event fired right when new playlist loaded player (after .load() method), .onplaylist() . thought resume playing @ moment... however, .play() doesn't work here. jwplayer().onplaylist(function() { jwplayer().play(); }); i have tried calling .seek() instead of play, seems work people, nothing happened. why wrong? there way resuming media after loading new playlist? edit: i see people achieved this , think using earlier versions of jw player since solution isn't working me. edit 2: here's fiddle: http://jsfiddle.net/4fbm13fz/

lighttable - Console in Light Table is not working -

i'm newbie programmar, working through problem sets, encountered weird problem console in light table. not executing codes. posted image, i'd grateful if me out this. thanks.! please visit http://i.stack.imgur.com/dy7q7.jpg image. console in lighttable not able execute code, @ least yet. way see log. moreover, design of lt makes execute inline (for several language) .. more comfortable. cheers.

javascript - CORS Support Not working with Domain -

i running google super proxy project on local server , trying pull json query data being hosted google appspot website. http://usertest.appspot.com/query?id=ahjzfmnvbm5vcnbosdfsfewdsdxsaxbzmjryfqsscefwavf1zxj5gicagicagiakda the issue keep running not allowed access webpage local server, because don't have cors support. have tried both javascript , jquery enable cors support, i'm still getting 2 error messages in console. know help? 1) failed load resource: server responded status of 405 (method not allowed) http://usertest.appspot.com/query?id=ahjzfmnvbm5vcnboaweewwewxsaxbzmjryfqsscefwavf1zxj5gicagicagiakda 2) xmlhttprequest cannot load http://usertest.appspot.com/query?id=ahjzfmnvbm5vcnboawxsaxbzmjreweadsdyfqsscefwavf1zxj5gicagicagiakda. no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost:8888' therefore not allowed access. index.html: <!doctype html> <html> <head> &

javascript - Json and Jquery in crm 2011 -

i using crm2011 on-premises created ribbon button on task , want create case clicking button. how give reference of jquery , json web resources in java script. add jquery , json web resources in task form. once loaded in form, available javascript ribbon well.

vhdl - Which signal in the sensitivity list triggers the process -

in vhdl, when simulating testbench, have process , sensitivity list. possible see signal in sensitivity list has triggered process? understand may dependent on tools. im using xilinx ise. simulator give information? you can use 'transaction attribute in conjunction 'event determine signals have had transaction in current delta cycle: process(a, b) begin if a'transaction'event report "transaction on a"; end if; if b'transaction'event report "transaction on b"; end if; end process; the 'transaction attribute creates new signal of type bit toggles on each transaction. 'event attribute on signal identifies when transaction has happened on parent signal. you can use not <signal name>'quiet(0 ns) determine signals sensitivity list have had transaction since last time step: process(a, b) begin if not a'quiet(0 ns) report "transaction on a"; end if; if not b'qui

What is the relationship between the javascript API and the COM API of internet explorer? -

we can manipulate content of current web page either javascript in page or calling com external process,like webdriver ie. relationship between 2 sets of apis? 1 built upon other or independent? can done com api while cannot in-page javascript , vice versa ?

Xcode add mutable dictionary from JSON to mutable array -

i have mutable array stories i'm trying add copy of json response yields o stories , nothing in array. doing wrong? json object formatted , can display each component individually not add array. nsstring *str=@"http://www.foo.com/some.php"; nsurl *url=[nsurl urlwithstring:str]; nsdata *data=[nsdata datawithcontentsofurl:url]; nserror *error=nil; nsmutabledictionary *response=[nsjsonserialization jsonobjectwithdata:data options: nsjsonreadingmutablecontainers error:&error]; nslog(@"your json object: %@", response); nslog(@"location: %@", response[@"location"]); nslog(@"service id: %@", response[@"serviceid"]); nslog(@"problem: %@", response[@"problem"]); [stories addobject:[response copy] ]; nslog(@"workorders: %d", [stories count]); nslog(@"wo defined: %@",stories); there go...try nsmutablearray *stories = [nsmutablearray array];

wordpress - add_menu_page not working with in-class function -

i'am trying use add_menu_page create custom "custom_post" page. (is mistake or not ? :-/) here's code won't work : add_menu_page( 'projets' , 'projets' , 'edit_posts', 'ajouter_projet' , array( $this, 'afficher_admin_page' ) , $img_url, 5); but when use add_menu_page( 'projets' , 'projets' , 'edit_posts', 'ajouter_projet' , afficher_admin_page' , $img_url, 5); with function afficher_admin_page out of class, works. what doing wrong ? thank you please use link http://codex.wordpress.org/function_reference/add_menu_page this helps you.

oauth - PHP HMAC-SHA1 function not returning "=" as padding character? -

i trying produce hmac-sha1 signature request access token , token secret tumblr api. using hmac_hash() function in php , understanding algorithm should produce "=" padding @ end of signature, signature returned me function never has padding , think why keep receiving following message tumblr : "oauth_signature not match expected value". have tried using several online signature generators test , produce padding , don't bit confused @ point. here code: $params = array( 'oauth_callback' => $callback, 'oauth_consumer_key' => $consumer_key, 'oauth_nonce' => $oauth_nonce, 'oauth_ver' => $oauth_ver, 'oauth_signature_method' => $signature_method, 'oauth_timestamp' => $time ); ksort($params); //--------------- build param string $params; end($params); // move internal pointer end of array $lastkey = key($params); ksort($params); $pa

web services - Java REST - call method after POST to REST -

i'm using java rest service file upload. file should land on server, does, move amazon s3 bucket. the upload server fine, 2nd call method not work. assume because there timeout issue? the code move file amazon works in app, not able working within rest project. here method: @post @path("/upload") @consumes(mediatype.multipart_form_data) public response uploadfile(@formdataparam("file") inputstream inputstream, @formdataparam("file") formdatacontentdisposition file, @formdataparam("filename") string filename){ logger log = logger.getlogger("mike"); string response = ""; file f = null; try { final string file_destination = "c://uploads//" + file.getfilename(); f = new file(file_destination); outputstream outputstream = new fileoutputstream(f); int size = 0; byte[] bytes = new byte[1024]; while ((size = in

Which jQuery selector is more efficient with .find() -

does tag name hurt or help? 1) $content.find('[name=foo]') or 2) $content.find('input[name=foo]') i wrote quick jsperf test , it's same. both pretty slow (jquery quite slow anyway). i tested $.find() method 2 weeks ago . it's habit use it, it's pretty efficient.

phpmyadmin - Mysql table lists rows not in order -

today inserted row in mysql table strange happened because last added row higher primary id before other rows lower id , after other rows lower id this: +---------+ | user_id | +---------+ | 1 | | 50 | | 69 | <=== wrong place | 63 | +---------+ this how listed in phpmyadmin, , in php script. understand if dont define in php script in order list rows in phpmyadmin dont know why happening. btw first time see this. this result of query: show create table mytable create table `users` ( `user_id` bigint(20) not null auto_increment comment 'auto incrementing user_id of each user, unique index',  `web_id` varchar(166) collate utf8_unicode_ci not null,  `user_name` varchar(64) collate utf8_unicode_ci not null comment 'user''s name',  `user_password_hash` varchar(255) collate utf8_unicode_ci not null comment 'user''s password in salted , hashed format', `user_email` varchar(64) collate utf8_unicode_ci

javascript - How get css rules (class declarations) from stylesheets across all desktop and mobile browsers back to IE8 -

i need class (and nested class) declarations stylesheet in ie8+ modern browsers. in modern browsers easy with: document.stylesheets[ 0 ][ "cssrules" ]; but doesn't work in ie8. how make work in ie8 (which have document.stylesheets)?

javascript - Clone element from div to list -

i need build simple tabs menu. problem must generate somethink ... <ul id="menu"> <li class="first">first</li> <li class="second">second</li> <li class="third">third</li> </ul> ...from somethink that <div class="someclass"> <li class="first">first</li> <p>text</p> </div> <div class="someclass"> <li class="second">second</li> <p>text</p> </div> <div class="someclass"> <li class="third">third</li> <p>text</p> </div> i tried solve broblem pure knowledge in js... <div id="putafter"> <ul id="menu"> <li id="m">first</li> <li id="m">second</li> <li id="m">third</li> </ul>

xml - edit the END TAG ONLY of an element using minidom in python? -

i having few issues python's minidom, , wondering if guys me out! i trying convert xml data wrong format format read our system. have been working on sort of proof-of-concept , figured out except last little issue! here's have far. while y < length: tag = doc_root.getelementsbytagname("p")[y].toxml() xmldata = tag.replace(' region="bottom"','') z = z + 1 xmldata= xmldata.replace(' xml:id="p%d"'%z,'') xmldata = xmldata.replace('<p','p') xmldata = xmldata.replace('/p>','p') print xmldata #div.appendchild(doc_root.getelementsbytagname("p")[x]) print xmldata adddata = doc.createelement(xmldata) div.appendchild(adddata) y = y+1 now works great, except when printed xml this <p begin="00:00:02.470" end="00:00:05.388">organizational communication and<br/>deaf employees<p/>

css - Part of mobile navigation menu items are hidden behind other div -

i'm trying create mobile dropdown menu menu items hidden behind div. tried using z-index apparently i'm doing wrong... i created following jsfiddle show problem: http://jsfiddle.net/hq160xx2/4/ as can see, part of menu item "object 2" hidden behind "home" , "nav2" menu. should add code object 2 appears on top of "home" , "nav2" menu ? ( btw: know changing height of div id="upper" solve problem, that's not i'm looking for. ) simply change overflow:hidden; overflow:visible; on .upper-mobile element: .upper-mobile { overflow: visible; }

ios - Save custom class in Core Data in Swift -

i have tried way long time , couldn't find 1 can understand :( i have custom class made: public class player { private var name : string = "test" private var level : int = 1 private var skill : skill = skill("basic") //skill class } i'm creating object class in view controller: var player = player() now wan't save player, have created entity called saves , attribute called playersaved , transformable type. when save player playersaved crash "unrecognized selector sent instance". thank :) hope done , finish app! you need transform custom class nsmanagedobject : import coredata @objc(player) class player { @nsmanaged var name: string @nsmanaged var level: nsnumber @nsmanaged var skill: skill } this standard way save "custom" classes in core data.

xcode6 - What are all the valid SystemCapabilities keys possible usually generated by Xcode? -

Image
i not use xcode build ipa. tried searching apple documentation, cannot find key values possible system capabilities. in order not lazy, tried archive project these capabilities turned on, , searched through ipa, cannot find xcode6 hiding these entitlements. for users using xcode6 these capabilities listed here since generate ipa manually, need know these keys in order match capabilities set on app identifier. updated here key values, in project.pbxproj file, @colinta systemcapabilities = { com.apple.applicationgroups.ios = { enabled = 1; }; com.apple.backgroundmodes = { enabled = 1; }; com.apple.dataprotection = { enabled = 1; }; com.apple.gamecenter = { enabled = 1; }; com.apple.healthkit = { enabled = 1; }; com.apple.homekit = { enabled = 1; }; com.apple.inapppurchase = { enabled = 1; }; com.apple.interappaudio = { enabled = 1; }; com.apple.keychain = { enabled = 1; }; com.apple.maps.ios = {

If statement ends program inside for loop -

i'm using python 3.3.2 , i'm writing program takes number, , adds list in ascending order. program works, added statement checks see if number user inputs in list, , when true, loop ends , program stops. can give me suggestions why is, , how prevent it? l = float(input('input number: ')) #gets input user list1 = [l] #places first input in list l in list1: #begins loop l = input('input number: ') #more input if l == ('stop'): #user tells program stop print(list1) break #ends program elif l != ('stop'): #the user not stop program l = float(l) if l not in list1: #new input not in list n = len(list1)#length of list m = max(list1)#max value of list m = min(list1)#min value of list if l < m: #checks if input smaller min of list1 list1.insert(0, l)#inserts new input @ start of list elif l > m:#chacks if new input la

php - MySQL LIMIT results with INNER JOIN with more than 2 tables -

Image
i have database user allowed have more 1 email address. want query database instances of job customer. each job returning twice, 1 each email. here query: select customers.first_name, customers.last_name, emails.email, services.title, services.description, jobs.status, jobs.job_id customers inner join emails on customers.user_id=emails.user_id inner join jobs on customers.user_id=jobs.customer_id inner join services on jobs.service_id=services.service_id; it returning this: i want return results first email only. row should not duplicated each email address user has on file. how can done? you can use group by on sql unique column value follows. select customers.first_name, customers.last_name, emails.email, services.title, services.description, jobs.status customers inner join emails on customers.user_id=emails.user_id inner join jobs on customers.user_id=jobs.customer_id inner join services on jobs.service_id=services.service_id; group jobs.job_i

java - Issues parsing a test file with ANTLRv4 -

i've defined grammar in antlrv4, written small example file test it's parsing, , giving me error: line 1:0 mismatched input 'import' expecting 'class' the test file http://pastebin.com/thpuexl5 the grammar file http://pastebin.com/6pauhzrt i have no idea why grammar i've written trying match 'class' instead of 'import' though i've defined import should come first.

How to change paper size to "A5" in printform component in vb.net -

i need change paper size a5 in printform can't set true properties. pf.printersettings.defaultpagesettings.papersize.papername() in line don't know how should write papername i found solution. printform.printersettings.defaultpagesettings.papersize.rawkind = system.drawing.printing.paperkind.a5

angularjs - Angular Avoid Unnecessary Dependency Injection -

i'm not building traditional spa, instead pages generate server-side. have angular app import pages on site. example: var app = angular.module('app',['ui.bootstrap', 'ngtable','textangular']); quite simple question i've failed ask google right question(s) find answer. not pages require textangular example, yet angular app not load unless import script on every page. best practice avoid problem? you don't need load script in every page. angular used in context of spa web app (single page application). means have 1 page (index.html) , use routing change current view. should reference script in index.html if module in application needs feature. if using server generated pages (with asp .net, php, etc.) can add script references every page not usual way work angular. (it called mini spa application). if scenario have reference script textangular (and define dependency in module declaration) on pages need use it.

cucumber - How to setup environment variables with behave (Python BDD framework)? -

so our test environments dynamically change depending on release working on. for example: for abc release url test environment feature-abc.mycompany.com, xyz release url test environment feature-xyz.company.com , on forth. same thing staging: release-abc.mycompany.com, release-xyz.mycompany.com, etc.. production static url: platform.mycompany.com with being said, need specify on url tests executed using behave bdd framework python. to specific im looking equivalent functionality cucumber has ruby using: features/support/env.rb file define multiple url (qa, staging, production, etc) on command-line (terminal) xyz (having qa = feature(the release).mycompany.com something like: how can test different environments (e.g. development|test|production) in cucumber? ok, there pull request (pr #243) able in behave's github repo. in meantime workaround suggested me use os.getenv('variable_name', 'default_value') , , @ command line export variable_n

c# - Hidden pixels in PNG -

Image
i'm designing c# console application converts bitmap vector art (svg) looping through pixels, pixel color in order draw , fill corresponding vector art component color . the issue i'm facing , when loop through pixels colors using code bitmap img = (bitmap)image.fromfile(imagepath); (int x = 0; x < img.width; x++) { (int y = 0; y < img.height; y++) { currentfill = img.getpixel(x, y).name ; } } at x , y black color (#afafaf) not exist in image (or can't seen naked eye) ! issue did not happen jpg or tiff formats instance..any ideas ? png files can have alpha channel. color type has a property represents alpha (transparency).

Add css via javascript -

hy, maybe stupid question , tottaly easy, can't make work please help. here's code. asp=height / width * 100; document.getelementbyid("head_wrap").style["padding-top"] = "'+asp+%'"; using alert(asp); gives correct value, made mistake here "'+asp+%'", want value in percentages said doesn't work. help! you have syntax errors in set value double quotes , single quotes. use property style object, sample: asp = height / width * 100; document.getelementbyid("head_wrap").style.paddingtop = asp + "%"; alternativally, use did, adjusts in code. asp = height / width * 100; document.getelementbyid("head_wrap").style["padding-top"] = asp + "%; i modified jsfiddle , take look here . see also list of properties supported style object htmlelement.style

javascript - How to implement asynchronous computed observable with multiple $.ajax calls? -

i'm attempting implement asynchronous computed observable show here . i can 1 ajax call. challenge have @ moment how perform various ajax calls in loop building array asynchronously , returning array computed observable array using jquery promises. basically html form works in following way: this student course form. for each row, users type person number , on column they'll type list of course ids separated commas. eg 100, 200, 300. the purpose of computed observable store array containing course details courses entered in step 2. the details obtained firing ajax calls each course , storing http response in array. i don't want users wait result, reason implement async computed observable. my problem: i'm having problem returning value of final array observable. it's undefined. ajax calls work fine perhaps i'm still not handling promises correctly. here's code class: function asynccomputed(evaluator, owner) { var result = k

optimization - Matlab fmincon Not Yielding Global Maximum/Minimum -

Image
i new matlab, apologies if question silly. using fmincon function derive elements of matrix (x) maximize following objective function subject non-negativity constraint and: where in code used fmincon used, objective function non-linear: function optim = optim(m,n) a= ones(1,m*n); b = 100; z = zeros(m,n); in = inf(m,n); x = ones(m,n); [x, bestval] = fmincon(@myfun2,x,a,b,[],[],z,in,[]) function f = myfun2(x) alpha = 5; %kappa = 5; zeta = 5; beta = 0.90909; delta = 0.4; gamma = 0.4; pf = 1; pw = 1; i= 1:m f=0; sum(i)=0; j=1:n sum(i) = sum(i) +((beta^(i-1))*(-1)*(zeta)*(((alpha*pf.*((x(i,j)).^delta))- (pw.*x(i,j)))^gamma)); end f = f+sum(i) end end end when code run 5x5 matrix (optim(5,5)), resulting solution x = 1.5439 1.5439 1.5439 1.5439 1.5439 1.5439 1.5439 1.5439 1.5439 1.5439 1.5439 1.5439 1.5439 1.5439 1.5439 1.5439 1.5439 1.5439

internet explorer - ASP.NET TextBox TextMode set to Date not working in IE 11 -

<asp:textbox id="txtdate" runat="server" textmode="date" /> it works in chrome, not in firefox or ie 11. googling around isn't yielding lot of helpful answers. far know, ie 11 html5 compliant. the textmode property corresponds <input type="" /> attribute (excepting multiline renders <textarea /> ). asp.net 4.x introduced additional values corresponding new html5 input types. internet explorer 11 not support of these new input types, not support " date ", " datetime ", nor " time " values. http://caniuse.com/#feat=input-datetime chrome, opera, , mobile safari do.

.net - The quickest way to find an integer in sorted range data -

this question has answer here: fastest way search number in list of ranges 5 answers i have sorted data has starting , ending integers of each range, , contiguous. data might this: number start end 0 0 47 1 48 94 2 95 287 3 288 1123 and on. i integer 113 , want fastest way search data find matching number. can afford stick data structure optimizes retrieval / comparison speed. my data large. edit: chose answer, , code ended with: public function endingcapturenumber(captureend integer) integer endingcapturenumber = captureends.binarysearch(captureend) if endingcapturenumber < 0 return (not endingcapturenumber) - 1 end if end function capture ends list of end of each range. not bitwise compliment. since finds first greater, subtract 1 last not greater. edit: duplicate question rebuttal the

Excel - Copy this row from sheet 1 to next available line in sheet 2 if column H has blank sell -

if column h has empty cell copy whole row cell on onto new sheet next available row, rows can have amount of rows replicate through every row please. sheet1 have potentially hundreds/thousands more rows: ...a.....b.....c......d......e......f......g.....h data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data data sheet2 have brought through first sheet: ...a.....b.....c......d......e......f......g.....h data data data data data data data data data data data data data data struggling days right , have tried multiple pieces of code , deleted whole lot , come on here. please :) :) :) :) :) sub tgr() dim wssrc worksheet 'va

regex - Identifying Difference in string using Perl -

Image
i have 2 stings (sentences) , identify specific difference in both strings (sentences) when not match. my sample code below my $diffpara1 = "this paragraph 1"; $diffpara2 = "this paragraph 2 different first paragraph"; $samepara1 = "this paragraph same"; $samepara2 = "this paragraph same"; print (($diffpara1 eq $diffpara2) ? '<span style="background-color: green">matching</span>' : '<span style="background-color: red">not matching</span>'); print "<br/>".(($samepara1 eq $samepara2) ? '<span style="background-color: green">matching</span>' : '<span style="background-color: red">not matching</span>'); the result above code is: the above indicates if strings (sentences) match or if strings (sentences) doesn't match. generate output indicates different in both strings (sentence). example outp

c - how to pass a char variable to FS_write() function -- EmFile? -

i`m trying use emfile library embedded programing based on c. this structure of fs_write in api documentation : u32 fs_write (fs_file * pfile, const void * pdata, u32 numbytes); i want write own function later use like: void sd_write_to_file(char buff) { if(pfile) { if(0 != fs_write(pfile, buff, strlen(buff))) { } else { fontwrite_position(100,148);//text written position putstringlcd("failed write data file"); } } } the problem when call function , pass char value, can`t use fs_write. example: sprintf(tempwordshow, "%f", realsamples[realsamplescounter]); sd_write_to_file(tempwordshow); realsample[ ] float , tempwordshow char. note if use function : if(0 != fs_write(pfile, "0123456789", 10u)) it working. i think problem way of passing data function . any ideas? thanks in general, make sure functions take pointer argum

sympy: test subexpression for trig function -

i trying test whether sub-expression contains sin function (or trig function) from sympy import sin, symbols, wild a, b, x, y = symbols('a, b, x, y') w1=wild('w1') i can this: >> (a*sin(x)+b*sin(y)).has(sin(x)) out: true but not work: >>: (a*sin(x)+b*sin(y)).has(sin(w1)) out: false how test 1 or more sin functions regardless of argument? if want use wild s, use find : in [11]: (a*sin(x)+b*sin(y)).find(sin(w1)) out[11]: set([sin(x), sin(y)]) but if searching single function sin, , not generic expressions, easier , faster way use atoms : in [12]: (a*sin(x)+b*sin(y)).atoms(sin) out[12]: set([sin(x), sin(y)]) if want check multiple trig functions, atoms takes multiple arguments, more efficient calling multiple times in [14]: (a*sin(x)+b*cos(y)).atoms(sin, cos) out[14]: set([sin(x), cos(y)])

haskell - Conduit simple file read expression not typechecking -

i'm trying simple conduit example under belt, i'm failing @ type-checking phase. in this example , i'm seeing resourcet being used conduit "executor", if makes sense. know that, time, resourcet has been factored-out it's own package . however, still can't simple example working. here code, inspired this article : import qualified data.conduit c import qualified data.conduit.binary cb import qualified data.conduit.list cl import control.monad.trans.resource (runresourcet) import data.bytestring.char8 (unpack) import data.bytestring (bytestring (..)) import system.io printfile file = runresourcet $ cb.sourcefile file c.$$ print' print' :: c.sink bytestring io () print' = cl.mapm_ $ putstrln · unpack and here error i'm getting (my package called "conduit-playground": preprocessing library conduit-playground-0.0.0... [2 of 2] compiling playground ( src/playground.hs, dist/dist-sandbox-13da96d6/build/playg

haskell - Using Monad/ST for non-concurrent message passing in a mutable graph -

i trying work out data structure following situation. graph structure i plan have graph of nodes un-weighted, directed edges: graph = [node] each node has: some tbd internal (persistent) state a queue of incoming messages a type of message can send determined function accepts current node state (with possibility of failure) a list of edges node { nodestate :: nodestate, inbox :: queue nodemessage, nodemessage :: (nodestate -> maybe nodemessage), connections::[nodeedge] } each edge intermediary step capturing pending messages target node nodeedge { pendingmessage:: maybe nodemessage, targetnode :: node } message passing the message passing happens in phases , not-conccurent (though queues may processed in parallel reduce computation time). phase 1: check inbox of every node, processing messages , updating nodestate if relevant. phase 2: have every node run nodemessage , if results in just nodemessage , send nodemessage every connection ( [nodeedge] )