Posts

Showing posts from September, 2013

swift - NSScanner scanString: intoString: not working in playground -

i'm trying make swift version of xml parser som weather data: import cocoa import foundation let string2: nsstring? = "cdefg jajaja <time> bbb" let scanner = nsscanner(string: string2) scanner.string let searchstring:nsstring? = "<time" var result: nsstring? = nil //= autoreleasingunsafepointer<nsstring?> scanner.characterstobeskipped = nil scanner.scanstring(searchstring, intostring: nil) // not working (false) scanner.scanuptostring( ">", intostring: &result) // working result // result = "cdefg jajaja <time" why "scanner.scanstring(searchstring, intostring: nil)" returning nil? actually, problem has nothing swift (equivalent objective-c code same) – you're using nsscanner wrong. docs scanstring:intostring: return value yes if string matches characters @ scan location, otherwise no. basically, scanstring:intostring: either finds searchstring @ current position (

java - Have to move screen to get JTextArea to appear -

i have desktop pane program user inputs data , jtextarea appears results. instead of having text area, wanted add scroll pane, did. created new scroll pane, , added text area it. now, when put in data text area in scroll pane not appear until move page. in other words, works, have move page little in order results , scroll pane show on screen. any ideas on why happening? private jtextarea matchlistresults = new jtextarea(); private jpanel matchpanelbase = new jpanel(new borderlayout()); private jscrollpane mresults = new jscrollpane(); private void matchresframe(string[] matchresultarray) throws ioexception, sqlexception { dimension size = new dimension(); size.setsize(400, 300); matchlistresults.setpreferredsize(size); matchlistresults.setfont(font); . . . mresults.getviewport().add(matchlistresults); matchlistresults.setvisible(true); matchpanelbase.add(mresults, borderlayout.center); }

How to make a group of regex characters optional? -

i'm trying create regex allows unicode letters, digits, -, , apostrophes first character letter or number, while subsequent characters can letters, numbers, -, or '. think regex works fine except in case user enters single letter or number. there anyway make 2+ characters optional? below current regex: /^[\p{l}0-9]+[-\'\p{l}0-9']+$/u thanks! -eric without using ? can use: /^[\p{l}0-9]+[-\'\p{l}0-9']*$/u to allow single alpha-numeric in input since [-\'\p{l}0-9']* means 0 or matches.

rest - Spring Enterprise Application Best Practices -

after read gordon's article best practices build enterprise application using spring framework, share ideas service layer. my architecture represents gordon described in image http://gordondickens.com/wordpress/wp-content/uploads/2012/07/spring-app-layers.png the application complex, has heavy business rule , demands use different resources database, soap, rest , file handle in same use case. for scenery have described above, have service class needs perform soap , rest requests , handle database data. so, have autowired in service class soap , rest component , repository handle database stuff. i'm concerned if best approach handle integration between services , resources soap, rest, database , etc. thanks so, have autowired in service class soap , rest component , repository handle database stuff. sounds problematic though work. think dependency between layers. service layer depend on repository layer (business logic layer depend on data layer

nitrousio - How can one check cron.log on Nitrous.io? -

we attempting implement cron job, on nitrous.io. however, cron not working. entry present in crontab. unable check cron.log , find cron.log what way check cron.log, using nitrous.io? and is there service start , stop cron on nitrous? cron default logs syslog, not accessible nitrous.io users. want log command output custom file instead. here quick example of how log ping request on nitrous.io box: navigate workspace folder , create new log file called cron.log : $ cd ~/workspace $ touch cron.log edit crontab run ping command every minute: $ crontab -e this open vim. add following line 1 , save file: * * * * * /bin/ping -c 1 192.168.0.1 > /home/action/workspace/cron.log check contents after minute see if log has been populated. $ cat ~/workspace/cron.log

javascript - jQuery losing $(this) object after DOM update -

html <ul> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> js $('ul').on('hover', 'li', function(){ // ajax call data // , put response data current li html $(this).html(data); // here $(this) lost if both event fire @ same time , dom updated via second ajax response }); $( window ).scroll(function() { // ajax call next content , append list $( "ul" ).append( data ); }); i loading data via ajax. there 2 events (1) hover on li , (2) scroll if user fires both events @ same time , response of scroll ajax call comes first elements dom appended, , response of second ajax call came, , getting $(this) lost in success callback. seems context:this, should used in ajax call, if using jquery.ajax() method can add context in options of it: $.ajax({ url:'', ...... context: this, ...... }); if use context context provided i

audio - Getting pronunciation of a word using Google Translate API -

i trying save pronunciation of french word .wav or .mp3 file. i wondering if there anywhere on google translate api (since has pronunciation functionality) allows me achieve objective. other libraries work too. similar functionality provided speech synthesis api (under development). third-party libraries there, such responsivevoice.js .

java - Why is parsing a single item String into a JSONArray failing -

i wondering why parsing code not working. trying responses webserver ( get ) request jasonarray . working multiple items (using get http://10.0.2.2:8000/exercises ). if try receive single item ( get http://10.0.2.2:8000/exercises/1 ) fails. found cause of problem. respjson = new jsonarray(resp); seems fail on string not surounded [ , ] , can see sample output. can tell me doing wrong here? should use different method, designed simgle item requests handle this? use simple check first character in string, such hack, cant believe best way todo it. (i posting minimal code of use + output) httphost target = new httphost(host, port, "http"); httpget getrequest = new httpget(requestpath); getrequest.setheader("content-type", "application/json"); getrequest.setheader("accept", "application/json"); response = httpclient.execute(target, getrequest); entity = response.getentity(); string resp = entityutils.tostring(entity); return new

c# - How to hide Windows Phone 8.1 StatusBar in only landscape orientation? -

i'm using code hide command bar landscape mode couldn't hide status bar . need hide watching full , clean screen youtube videos in app . void current_sizechanged(object sender, windows.ui.core.windowsizechangedeventargs e) { string currentviewstate = applicationview.getforcurrentview().orientation.tostring(); if (currentviewstate == "portrait") bottombar.visibility = visibility.visible; if (currentviewstate == "landscape") bottombar.visibility = visibility.collapsed; } i have found solution. here codes. void current_sizechanged(object sender, windows.ui.core.windowsizechangedeventargs e) { // new view state string currentviewstate = applicationview.getforcurrentview().orientation.tostring(); var statusbar = windows.ui.viewmanagement.statusbar.getforcurrentview(); if (currentviewstate == "portrait") { bottombar.visibility = visibility.visible; showstatusbar()

Passing data from ArrayList in back end to JComboBox GUI front end - Java Swing -

Image
this fileiomanagement class want handle of reading text files etc grabs data display in gui. this code current fileiomanagement class: package swinging; import java.io.file; import java.io.filenotfoundexception; import java.util.arraylist; import java.util.collections; import java.util.hashset; import java.util.scanner; public class fileiomanagement { private arraylist<string> namelist = new arraylist<string>(); private arraylist<string> courselist = new arraylist<string>(); private arraylist<string> semesterlist = new arraylist<string>(); private arraylist<string> moderatorlist = new arraylist<string>(); private arraylist<string> programlist = new arraylist<string>(); private arraylist<string> majorlist = new arraylist<string>(); public fileiomanagement(){ readtextfile(); } private void readtextfile(){ try{ scanner scan

objective c - How Can I Display Battery Percentage for iOS 7? -

this question has answer here: ios: how correctly battery level 1 answer i need help. i'm trying make battery monitor , can't figure out how too. i'm not sure how of uidevice works... see related post below. hate add should search stackoverflow first see if has answered question. ios: how correctly battery level

ios - Make a UIButton programmatically in Swift -

i trying build ui's programmatically. how action working? developing swift. code in viewdidload: override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. let myfirstlabel = uilabel() let myfirstbutton = uibutton() myfirstlabel.text = "i made label on screen #toogood4you" myfirstlabel.font = uifont(name: "markerfelt-thin", size: 45) myfirstlabel.textcolor = uicolor.redcolor() myfirstlabel.textalignment = .center myfirstlabel.numberoflines = 5 myfirstlabel.frame = cgrectmake(15, 54, 300, 500) myfirstbutton.settitle("✸", forstate: .normal) myfirstbutton.settitlecolor(uicolor.bluecolor(), forstate: .normal) myfirstbutton.frame = cgrectmake(15, -50, 300, 500) myfirstbutton.addtarget(self, action: "pressed", forcontrolevents: .touchupinside) self.view.addsubview(myfirstlabel)

ruby - Gem not working after update to OS X 10.10 Yosemite Beta -

i have trouble getting gem work after updating 10.10 yosemite. running (or other gem install / uninstall): sudo gem install mysql2psql and give me following error: /library/ruby/site/2.0.0/rubygems/ext/builder.rb:159:in `synchronize': error: failed build gem native extension. (gem::ext::builderror) error: failed build gem native extension. deadlock; recursive locking gem files remain installed in /library/ruby/gems/2.0.0/gems/mysql-2.9.1 inspection. results logged /library/ruby/gems/2.0.0/extensions/universal-darwin-14/2.0.0/mysql-2.9.1/gem_make.out gem files remain installed in /library/ruby/gems/2.0.0/gems/mysql-2.9.1 inspection. results logged /library/ruby/gems/2.0.0/extensions/universal-darwin-14/2.0.0/mysql-2.9.1/gem_make.out /library/ruby/site/2.0.0/rubygems/ext/builder.rb:159:in `build_extension' /library/ruby/site/2.0.0/rubygems/ext/builder.rb:198:in `block in build_extensions' /library/ruby/site/2.0.0/rubygems/ext/builder.rb:19

Python: Find a word within a string -

i'm trying find word within string python. str1 = 'this string' if 'is' in str1: print str1 in above example want not print str1. while in following example want print str2. str2 = 'this string' if 'is' in str2: print str2 how go doing in python? split string words , search them: if 'is' in str1.split(): # 'is' in ['this', 'string'] print(str1) # never printed if 'is' in str2.split(): # 'is' in ['this', 'is', 'a', 'string'] print(str2) # printed

bash - Dividing double-precision shell variables in a shell script -

i working shell scripting on linux. i have 2 double variables , want divide them, , put results variable. i tried following (does not work) : #!/bin/bash a=333.33 b=111.11 c="$a / $b" | bc -l although following work: #!/bin/bash a=333.33 b=111.11 echo "$a / $b" | bc -l what doing wrong? thanks matt pipes work on output streams, and: c="$a / $b" | bc -l does not send "$a / $b" output stream, instead sends eof. you can this: c=$(echo "$a / $b" | bc -l) to result c .

c++ - Unable to access static member -> unresolved external symbol i -

this question has answer here: unresolved external symbol on static class members 2 answers class test { private: static int i; public: static void foo() { = 10; } static int geti(){ return i; } }; int _tmain(int argc, _tchar* argv[]) { test::foo(); std::cout << test::geti(); return 0; } this simple test, think wrong static use in program. because "unresolved external symbol i". why ? you have define static member variables outside class definition: int test::i=10; //or value or definition do. in class declaring , not defining. without definition, linker not

java - IBM websphere and BPM SSO -

i have 2 websphere servers.one server has java web application deployed , other has bpm processes.i have configured sso between 2 servers,both servers admin console opening sso. i have open ibm bpm coach inside web application sso, should in web application open coach directly without given user , password. for establishing sso between multiple websphere servers, have enable sso @ server level, ensure ltpa token generated on successful login webapplication. once ltpa created, same propogated 2nd webapp/any other webapp access since cookie created websphere exists in browser , can consumed websphere server participates in sso. i trying setup sso between 2 websphere servers unable admin console apps logged in seamlessly. can confirm steps followed? hope using custom standalone registry(referring user.props & group.props eg)

swift - What is the expected result of subscripting a range? -

i can't find documentation explaining subscripting range supposed do. i'd expect yield nth value of range, seems return subscripted value, itself. let range = 10...20 let valuefromrange = range[2] in case, i'd expect valuefromrange equal 12 , it's equal 2 . seems case ranges (or, @ least ranges of type range<int> , range<double> ). is value i'm supposed get? besides defying think commonly expected behavior, behavior useless. you should convert range array if want subscript that: let range = array(10..20) range[2] // returns 12 while can add range.startindex , subscript directly particular range, can't subscript strided ranges @ without converting them: let range = (10..20).by(3) range[2] // error: 'stridedrangegenerator<int>' not have member named 'subscript'

objective c - Random number from a range without a certain number in the middle of the range -

i'm generating number 0 11 randomly this: int n = arc4random() % 12; but, i'd not 5 or 6 output. how can that? if have such constraint, make explicit in code: int n; { n = arc4random() % 12; } while (n == 5 || n == 6); //retry if encountered 1 of unallowable values

unity3d - Up-Down, Left-Right facing ratio shader -

Image
a little basic question can't head around. need create shader works facing ratio shader containing up-down , left-right (in screen space). just this: i want work without having original geometry, having normals, point position , camera position. how should approach this? here's shader: #pragma vertex vert #pragma fragment frag #pragma fragmentoption arb_precision_hint_fastest #include "unitycg.cginc" struct app2vert { float4 position: position; float3 normal: normal; }; struct vert2frag { float4 position: position; float3 normal: texcoord0; }; vert2frag vert(app2vert input) { vert2frag output; output.position = mul(unity_matrix_mvp, input.position); output.normal = mul((float3x3)unity_matrix_it_mv, input.normal); return output; } float4 frag(vert2frag input) : color { float3 normal = normalize(input.normal); float4 output = fixed4(normal.x, normal.y, normal.z, 1.0f); return output; }

c# - Simulate movement of game object as if server handles requests with lag -

question: can give me idea how can write custom algorithm, move object point point b latency? i using pretty simple algorithm: while(input held) add point current existing list of points check if list exceeds maximum offset (a given number of points) -> a.move object on 0 index point. b.delete 0 index point. loop 1. but algorithm not give me desired results.i looking maybe kind of math expression lag simulation, not sure can produced math anyway headed first here ask question. assuming have sort of user input , way process events. one approach explicitly delay user input events (or other events) later time. i.e. when user clicks send game object new position instead of setting new immediate target can put action list of future events "move point b, starting currenttime + delay". as result code not aware of request change destination , continue moving object previous target till "delay" time passed.

java - Writing a Unix installer for a Jar file -

i have written java application, , have created executable jar file runs application java -jar myjar.jar . have executable shell script called launchmyprogram wraps launching of jar (and offers various flags --help etc.). target output directory looks this: $ ls /path/to/myproject/target/ archive-tmp/ classes/ myjar.jar what standard method me write installer unix-only application? assume correct drop launchmyprogram executable in /usr/local/bin. put jar file? should make own subdirectory somewhere program's files? need copy classes directory above output same directory jar? run via makefile of course users may override choices. basically, want user able run make && make install , , able run application launchmyprogram , , want place files (one jar, 'classes' folder, , shell script) in typical places possible. one of best ways has been reinvented many times unfortunately not yet standard. since jar zip file allowed have a

c# 4.0 - parsing lambdas for dynamic database validation rules -

i have situation i'm needing copy bunch of records 1 database another, , transfer involves lot of transformation. have run case in addition transformation, need validate , reject column values in source data. (for example, i'm dealing weights of dogs , cats, , occasional typos in source data resulted in exorbitant weights incorrect, never validated in source data.) anyway, these exorbitant weights aren't allowed in new database, have identify , set bad values aside. what want have rule string expression can invoke during transformation. rule stored column mapping instruction. particulars of aren't question, rather how turn plain string expression runtime expression. (preface: have muddled around lambdas fair amount, tripped time.) here's have.... have isvalid method accepts value sqldatareader. partial class columnrow dataset, , has validationrule string property referenced in code below. basically, if there no rule specified or if incoming value null, ass

android - Sqlite Gives Error -

i'm trying implement loading data database , put different views. the log cat returns error, cannot find "_id" column . can me this? sqlhelper code: public class fibosqlhelper extends sqliteopenhelper { public static final string table_filmdb = "fibofilmtop250"; public static final string column_id = "_id"; private static final string database_name = "fibofilmdb250.sqlite"; private static final int database_version = 1; public static final string column_title = "title"; public static final string column_rating = "rating"; public static final string column_genre = "genre"; public static final string column_time = "time"; public static final string column_premdate = "premdate"; public static final string column_plot = "plot"; private static final string database_create = "create table " + table_fil

javascript - Map Route Direction Zoom to Segment -

basically trying zoom route segment when getting direction on onemap. here javascript codes trying plot route , zoom route segment: function getdirections() { var routedata = new route; var = document.getelementbyid('txtfrom').value var = document.getelementbyid('txtto').value //draw out line cordinate cordinate routedata.routestops = + ";" + to; //what type of mode routedata.routemode = "drive"; //can draw out untill following coordiante routedata.barriers = '36908.388637,35897.420831'; { if (document.getelementbyid('cbavoid').checked) { routedata.avoiderp = "1"; } else routedata.avoiderp = "0"; } routedata.getroute(showroutedata) } function showroutedata(routeresults) { if (routeresults.results == "no results") { alert("no route found, please try other location.") return } $('#divcomputeddirection').show(); directions

Android Problems with a TextView -

this sounds easy @ beginning driving me insane. so downloaded latest android sdk , eclipse , there somthing new.... : when iam creating activity , layout generates me 2 layout files somthing like: main_laout.xml , fragment_main.xml however eclipse opend fragment file , made gui there. when iam starting application buttons , textviews there. press button , second activity starts. and here problem: second activity first 1 (the 2 layout xml files here called status) when iam trying change textview there nullpointer exception. can plz me iam getting crazy. my code far: statusactivity: public class statusactivity extends actionbaractivity{ private textview version,dbstatus,dbrows; private button done,refresh; networktask task; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_status); if (savedinstancestate == null) { getsupportfragmentmanager().begintransaction()

ios - Move UITableViewCell index in TableView [SWIFT] -

i move uitableviewcell end of array once selected. how change index of uitableviewcell? var tableviewdata = ["1", "2","3","4"] ... func tableview(tableview: uitableview!, didselectrowatindexpath indexpath: nsindexpath!){ let myselectedcell:uitableviewcell = tableview.cellforrowatindexpath(indexpath) // move cell ... } thanks this should work specific example ( note assumes table view has 1 section ): // remove item data array let item = data.removeatindex(indexpath.row) // add item again, @ end of array data.append(item) // move corresponding row in table view reflect change tableview.moverowatindexpath(indexpath, toindexpath: nsindexpath(forrow: data.count - 1, insection: 0))

amazon web services - What are the best practices for user uploads with S3? -

i wondering recommend running user upload system s3. plan on using mongodb storing metadata such uploader, size, etc. how should go storing actual file in s3. here of ideas, think best? of these examples involve saving metadata mongodb. 1.should store files in bucket? 2. maybe organize them dates (e.g. 6/8/2014/mypicture.png)? 3.should save them in 1 bucket, added string (such d1jdaz9-mypicture.png) avoid duplicates. 4. or should generate long string folder, , store file in folder. (to retain original file name). e.g. sh8sb36zkj391k4dhqk4n5e4ndsqule6/mypicture.png this depends on how intend use pictures , objects/classes/modules/etc. in code deal retrieving them. if find wanting things - "all user uploads on particular day" - simple naming convention folders year, month , day along folder @ top level user's unique id solve problem. if want ensure uniqueness , avoid collisions in bucket, generate unique string too. however, since you've

actionscript 3 - SoundTouch Class Example -

i've classes , i'm trying call function of class main swf. i'm getting error 1120. here's main fla: import playerclass; simpleplayer.play(sound1); edit: i've found example i'm still getting error. var source:sound = new sound1(); var output:sound = new sound(); var soundtouch:soundtouch = new soundtouch(); soundtouch.pitchsemitones = -6; var filter:simplefilter = new simplefilter(sound, soundtouch); output.addeventlistener(sampledataevent.sample_data, filter.handlesampledata); output.play(); this gives me error: sahne 1, katman ‘katman 1’, kare 1, satır 18, sütun 44 1120: sound tanımlanmamış özelliÄŸinin eriÅŸimi. when try: var source:sound = new sound1(); var output:sound = new sound(); var soundtouch:soundtouch = new soundtouch(); output.play(); i'm getting error argumenterror: error #2068: invalid sound. @ flash.media::sound/play() @ adsız_08_fla::maintimeline/frame1() the class source here: https://github.com/also/sou

objective c - iOS 8 Today Widget - SLComposeViewController not displaying properly -

Image
i've created extension, in fact today widget, using xcode 6 , run on ios 8 beta device (i registered ios developer). however, being new development, i've encountered issue slcomposeviewcontroller being 'stuck' inside view (shown below), deeming user unable interact , not able consequently post tweet. is there way fix , bring slcomposeviewcontroller front, in front of notification centre pane? appreciated. edit: (yay, fixed "hello world" text) 2nd edit: here's slcomposeviewcontroller code: - (ibaction)twittershare:(id)sender; { if ([slcomposeviewcontroller isavailableforservicetype:slservicetypetwitter]) { slcomposeviewcontroller *tweetsheet = [slcomposeviewcontroller composeviewcontrollerforservicetype:slservicetypetwitter]; [self presentviewcontroller:tweetsheet animated:yes completion:nil]; } else { uialertview *twitteralert = [[uialertview

windows phone 8 - Telerik RadDataBoundListBox Reset -

how can reset or delete old data in telerik raddataboundlistbox json parse , display in raddataboundlistbox raddataboundlistbox load old data every time, if click button load new data want delete or reset old data becouse every time displaying old data public void getmaindata() { string mainurldata = "http://www.mydomain.com/app.json"; webclient wc = new webclient(); wc.downloadstringcompleted += wc_downloadstringcompleted; wc.downloadstringasync(new uri(mainurldata)); } void wc_downloadstringcompleted(object sender, downloadstringcompletedeventargs e) { try { string result = e.result.tostring(); jsonconvert.populateobject(result, populatedata); newslist.itemssource = populatedata; } } little late, hope helps.. with mvvmlight use httpclient: public async task<observable

asp.net - Foundation fire event on modal popup -

i use modal of foundation( http://foundation.zurb.com/docs/components/reveal.html ) have button inside modal , want fire event when user press on button. event don't fire.. can me?! i find soulation: define linkbutton insead button:

c - Code doesn't work, getting error: segmentation fault(core dumped) -

can explain why snippet of code doesn't work? intended duplicate file, when compile segmentation fault(core dumped), appreciate critics. sorry if there typos. #include <stdio.h> #include <stdlib.h> #define bufsize 256 #define maxlen 30 void copy(file *source,file *dest); int main(void) { file *fs, *fa; // fs source file, fa copy char file_src[maxlen]; // name of source file char file_app[maxlen]; // name of copy file puts("file copy program\n\n"); puts("enter name of source file:"); gets(file_src); // file name if(fs=fopen(file_src,"r")==null) // error checking { fprintf(stderr,"cant open %s.\n",file_src); exit(exit_failure); } if(setvbuf(fs,null,_iofbf,bufsize)!=0) // set buffer fs { fprint

types - Confusion due to Swift lacking implicit conversion of CGFloat -

trying arithmetic in function returns `cgfloat, error: couldn't find overload '/' accepts supplied arguments func kdccontroldegreestoradians(x : cgfloat) -> cgfloat { return (m_pi * (x) / 180.0) // error here. } has else seen type of issue? this problem double float conversion. on 64-bit machine, cgfloat defined double , compile without problems because m_pi , x both doubles. on 32-bit machine, cgfloat float m_pi still double. unfortunately, there no implicit casts in swift, have cast explicitly: return (cgfloat(m_pi) * (x) / 180.0) the type 180.0 literal inferred. in swift 3 m_pi deprecated, use cgfloat.pi instead: return (x * .pi / 180.0)

Does logging in a Java based web application slow the server? -

i working on java j2ee based web application. when take pages, loading slowly. noticed lot of unnecessary lines in log file... does logging in java based web application slow server? as in environement, i/o (here, disk writings) expensive operation, yes, spamming tons of data logs, can slow down applcation. has indeed lot of data (eg. turn on show_sql in hibernate ) feel performance impact dring normal application usage.

ssl - Size of Data transfer Via TLS (Transfer Layer Security) -

what amount of data can transferred on t.l.s. (transfer layer security) protocol? any amount like. tcp byte stream protocol , tls. under hood, both packetize, can't control that, or see in cases.

c# - Find element in Selenium using XPATH or CSS Selector -

i m trying find element "import" using selenium webdriver in c#. have tried following codes nothing find it. driver.findelement(by.xpath("//*[@class='menu_bg']/ul/li[3]")).click(); driver.findelement(by.xpath("//*[@id='import']/a")).click(); driver.findelement(by.cssselector("#import>a")).click(); driver.findelement(by.xpath("//*[@class='menu_bg']/ul/li[3]/a")).click(); driver.findelement(by.cssselector("ul[@class='menu_bg']>li[value='3']")).click(); please me out. design page looks below: <body> <div class="header_bg"></div> <div class="menu_bg"> <ul class="menu"> <li id="retrieve"></li> <li id="scan" class="test"></li> <li id="import"> <a target="main" href="

android - Change list item background in custom adapter -

i have custom adapter , want pick out new messages. adapter looks like. new messages have new_message icon. public class inputmessagesadapter extends baseadapter { private context context; private layoutinflater layoutinflater; private list<message> messagelist; private list<sellerstatement> sellerstatementlist; private list<integer> messagesids; private string arrayname = "messagesids"; private sharedpreferences prefs; public inputmessagesadapter(context context, list<message> messagelist, list<sellerstatement> sellerstatementlist) { this.context = context; layoutinflater = (layoutinflater) this.context.getsystemservice(context.layout_inflater_service); this.messagelist = messagelist; this.sellerstatementlist = sellerstatementlist; prefs = preferencemanager.getdefaultsharedpreferences(context); int size = prefs.getint(arrayname + "_size", 0); integer[] temparray = new

vb.net - how to add childItem to another childItem in a menuItem ASP.NET -

i need whit code, have next menuitem in asp.net: 1 -> 1.1 and need add menu 1.1 new child (1.1.1) 1 -> 1.1 -----> 1.1.1 but not know how it, code: dim menu = new menuitem() menu .text = "1" menu .navigateurl = "" menu1.items.add(menu) dim menuchild = new menuitem() menuchild .text = "1.1" menuchild .navigateurl = "" menu.childitems.add(menuchild) thanks! this works... dim submenuchild = new menuitem() submenuchild.text = "1.1.1" submenuchild.navigateurl = "" menuchild.childitems.add(submenuchild) or else looking for?

android - After replacing Fragment, Activity still detects Fragment is visible -

i have 1 activity hosts many fragments . in fragment a , adding dialog when user presses button ask if sure if want leave fragment. added code in activity's onbackpressed control this: @override public void onbackpressed() { fragmenta fragmenta = (fragmenta) getsupportfragmentmanager().findfragmentbytag("fragmenta"); if (fragmenta != null && fragmenta.isvisible()) { fragmenta.showexitdialog(); return; } else { super.onbackpressed(); } } and dialog works in fragment a, when leaves fragment , goes fragment b (same activity) code: getactivity().getsupportfragmentmanager().begintransaction().replace(r.id.container, fragmentb.newinstance(), "fragmentb").commit(); and press button in fragment b, shows same exit dialog again. thus, code, saying fragmenta not null , still visible after did replace function. why fragment still visible when replaced fragment b?

c++ - How to read txt file into vector and cout the file? -

#include <iostream> #include <fstream> #include <vector> #include <string> using namespace std; int main() { vector<int> temp; ifstream infile; infile.open("numbers"); if (infile.fail()) { cout << "could not open file numbers." << "\n"; return 1; } int data; infile >> data; while (!infile.eof()) { temp.push_back(data); infile >> data; } cout << data << " " << endl; } i trying cout numbers text file "numbers" using vector. 15 10 32 24 50 60 25 my experience pretty nil, , guidance on why fails open helpful. your code fine you're printing wrong thing. change bottom of main this int data; while (infile >> data) { temp.push_back(data); } for( vector<int>::iterator = temp.begin(); != temp.end(); i++) { cout << *i << endl; } *edited after readin

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(14), -

creating search engine website of sphider but when creating mysql database tables following error message showed error sql query: create table query_log ( query varchar(255), time timestamp(14), elapsed float(2), results int) mysql said: documentation #1064 - have error in sql syntax; check manual corresponds mysql server version right syntax use near '(14), elapsed float(2), results int)' @ line 3 the problem lies number following timestamp declaration. mysql documentation says of timestamp type: the display width fixed @ 19 characters, , format 'yyyy-mm-dd hh:mm:ss'. so, code can fixed making following modification: create table query_log ( query varchar(255), time timestamp, elapsed float(2), results int ) as far number "14" goes, it's unclear going that. project working on require timestamp of specific length? if so, might best use data type, or convert timestamp desired format after p

angularjs - Window level events in angular directives are not executing as expected -

title may confusing. please find code below: //html <div id="test1" test></div> <div id="test2" test></div> //module var myapp = angular.module('app', []); myapp.directive('test', function () { return { link: function (scope,el,attr) { window.onbeforeunload = function () { console.log("test1"); } } }; }) i have " window.onbeforeunload" event callback function defined. have same directive on 2 different dom elements.when "onbeforeunload" event raised, executed once. thought execute twice can capture element level info. not happening. executing in context of element "test1". may doing wrong.any inputs please.. window.onbeforeunload can take 1 event handler function, each time new 1 assigned, existing 1 removed. 1 way around "appen

hadoop - How to install mahout using ambari server -

i have created hadoop cluster using 3 slaves , 1 master using ambari server(hortonworks). need install mahout 0.9 in master machine in order run mahout jobs in cluster. how do that? i using ambari 1.5.1 , hdp 2.1. hello fellow hortonworker! mahout in hdp repositories, it's not available in ambari install wizard (i.e. services->add service). therefore way install via: yum install mahout as noted here , should install on master node. note mahout library not service . there nothing ambari monitor in terms of additional services run on nodes. if using maven manage build dependencies, can add following pom.xml <dependency> <groupid>org.apache.mahout</groupid> <artifactid>mahout-core</artifactid> <version>0.9</version> </dependency>

python - How to show multiple windows simultaneously in simpleCV after cropping image in four segments -

i have write down code getting images video "vd.mpg" , cropping images in 1/4 , while calling show() method @ end showing 1 window live streaming of cropped video want make changes in given code can able visualize 1/4 part of cropped video simultaneously from simplecv import * simplecv import virtualcamera #from pylab import * #from pylab import plot, show #from time import * vir = virtualcamera("vd.mpg", "video") while true: previous = vir.getimage() cropped_1 = previous.crop(0,0,320,240) cropped_2 = previous.crop(320,0,320,240) cropped_3 = previous.crop(0,240,320,240) cropped_4 = previous.crop(320,240,320,240) cropped_1.show() cropped_2.show() cropped_3.show() cropped_4.show() please me changes should make in given code. in advance. from simplecv import * crops = ((0,0,320,240),(320,0,320,240),(0,240,320,240),(320,240,320,240)) cam=virtualcamera('vd.mpg','video') while true: imgs=[

interface - how to bring abstraction in java application..logic for abstraction in project -

i know abstract classes , interfaces in java want know how bring abstraction in working software/project? how thing in such way brings abstraction. your question vague @ best, usage of interfaces helps abstraction because not working concrete types. instance: iprinter p = printerfactory.getprinter(conditions); ... p.print(content); in below line, not aware of what printer using. since using logic, not care. care factory give printer after , print method print content right stream. if want change printer being used, make amendments in factory class different iprinter implementation need (which in case print other media). mean have changed outcome of piece of code without changing of it.

java - How to Capture photo from webcam in JFrame? -

i want build simple program using eclipse tool, , in program need use webcam of computer ! need simple code photo webcam helping... the above comments invalid "extremely hard". was, still upto level, not much. if image processing (process image once picture) use javacv . can access web cam. wrapper opencv c++ library setup might invloved. do not try jmf, vlcj, fmj because outdated. have @ this link . have @ answer image, webcam project java, find github project here

image processing - MATLAB Auto Crop -

Image
i trying automatically crop image below bounding box. background same colour. have tried answers @ find edges of image , crop in matlab , various applications , examples on mathworks' file exchange stuck @ getting proper boundingbox. i thinking convert image black , white, converting binary , removing that's closer white black, i'm not sure how go it. following answer of shai , present way circumvent regionprops (image processing toolbox) based on find on black-white image. % load img = im2double(imread('http://i.stack.imgur.com/zuiet.jpg')); % black-white image threshold on check how far each pixel "white" bw = sum((1-img).^2, 3) > .5; % show bw image figure; imshow(bw); title('bw image'); % bounding box (first row, first column, number rows, number columns) [row, col] = find(bw); bounding_box = [min(row), min(col), max(row) - min(row) + 1, max(col) - min(col) + 1]; % display rectangle rect = bounding_box([2,1,4,3]); %

How to place file pointer one line up before writing in file using python? -

scenario there file contains 2 blank lines @ end. when append file, gets written after 2 blank lines (which certain). but want 1 blank line , remove second blank line. in place of second blank line, appending data should written. #-------original file line 1 line 2 [--blank line--] line 3 line 4 [--blank line--] [--blank line--] appending "this line 5" , "this line 6" in above file. what happening right now! #-------original file line 1 line 2 [--blank line--] line 3 line 4 [--blank line--] [--blank line--] line 5 line 6 what want ! #-------original file line 1 line 2 [--blank line--] line 3 line 4 [--blank line--] #only 1 blank line. second blank line should removed line 5 line 6 i have researched , came solution moving file pointer. while appending contents file, file pointer may present after second blank line. work if move file pointer 1 line , append "this line 5" , "this line 6" ? if yes, pl

asp.net - Disabling Tabs in Master Page for specfic views -

it first time me use master page layout. at moment have 3 tabs in menu: login/add/edit i have 1 tab visible on login page (default page) , after login successful login tab disabled (because user logged in) , add/edit tabs enabled. <asp:menu id="loginmenu" runat="server" cssclass="menu" enableviewstate="false" includestyleblock="false" orientation="horizontal"> <items> <asp:menuitem text="login" navigateurl="login.aspx" /> </items> </asp:menu> <asp:menu id="navigationmenu" runat="server" cssclass="menu" enableviewstate="false" includestyleblock="false" orientation="horizontal"> <items> <asp:menuitem text="add" navigateurl="add.aspx" /> <asp:menuitem text="edit" navigateurl="edit.aspx" /> </items> </

qt - QML: TextField horizontalAlignment not working for entered text in Ubuntu SDK -

i'm complete newbie qml , qt, forgive me if trivial question. i'm using following code center-align text in textfield. work placeholder text, entered text isn't center-aligned. haven't been able figure out i'm missing. :( textfield { id: pwdtf x: 52 y: 190 z: 6 color: ubuntucolors.lightaubergine visible: true placeholdertext: "<font color=\"lightsteelblue\">enter password #</font>" horizontalalignment: textinput.alignhcenter echomode: textinput.password } set width property. horizontalalignment doesn't work without it.