Posts

Showing posts from March, 2011

ios - Unable to open new window on successful login Post - Swift -

Image
i new swift. trying build app - i have login screen , once user types in correct username , password, user redirected new window. have managed http post requests after unable open new window on successful login. @ibaction func signintapped(sender: uibutton) { let parameters = "{\"email\": \""+txtusername.text+"\", \"password\": \""+txtpassword.text+"\"}" ;//as dictionary<string, string> //create url nsurl let url = nsurl(string: "https://myurl") //change url //create session object var session = nsurlsession.sharedsession() let request = nsmutableurlrequest(url: url!) request.httpmethod = "post" //set http method post var err: nserror? request.httpbody = parameters.datausingencoding(nsutf8stringencoding, allowlossyconversion: true);//nsjsonserialization.datawithjsonobject(parameters, options: nil, error: &err) // pass dic...

php - set session variable or local storage in javascript -

i have many php pages have different forms. want submit forms page called insertproc.php in call stored procedures insert data. submitting form data using jquery.should set session variables in jquery script after every form submission ? or can acheive other functionality. example: if have 3 pages page1.php, page2.php, page3.php has 1 form each form1.php, form2.php, form3.php. have submit 3 forms insertproc.php. in insertproc.php have check form have submitted. accordingly have run respective stored procedure. should set session variable in jquery after submit form $session['proc_name'] = 'insert_user'; and check in insertproc.php value of session variable call respective stored procedure. please guide me how can achieve functionality. if submit form jquery can add input field <form> element says form it, example, form1.php : <form ...> ... <input type="hidden" name="source" value="form1"/> </fo...

ios - iPhone6 screen size returns 375 on simulator -

my project has launch images iphones ios7,ios8. anyway keeps returning wrong value screen width in simulator: nslog(@"%f",[uiscreen mainscreen].bounds.size.width); nslog(@"%f",self.view.frame.size.width); both 375.0. what missing ? the actual screen size of iphone6 750 pixels, ios not return pixel size in frame or bounds, point size! if want know how many pixels in point have use [uiscreen mainscreen].scale . for iphone6plus more complicated since introduces 'native scale'. drawn larger image , reduced down 1920x1080 screen iphone 6 has. use [uiscreen mainscreen].nativescale [careful, native scale available on ios8 , app crash if use on ios.] p.s. if not using splash image (other -568h@2x), 320x568 iphone 6 , 6+.

sql - Create a view using latest address record -

i'm trying create view joins 2 tables , returns relevant address details of particular date. i have 2 tables: employee: id (primary key) name employeeaddress: id (pk), (fk employee.id) datevalidfrom (pk) addressline1 addressline2 postcode how join 2 employee details , address of date? one way use query finds latest datevalidfrom each id , use derived table join other tables with, this: select * employee e join employeeaddress ea on e.id = ea.id join (select id, max(datevalidfrom) max_date employeeaddress group id) ea2 on ea.id = ea2.id , ea.datevalidfrom = ea2.max_date by joining max(datevalidfrom) in derived table limit rest of query (that rows) latest. and turn view: create view employee_latest_address select e.id, e.name, ea.datevalidfrom, ea.addressline1, ea.addressline2, ea.postcode employee e join employeeaddress ea on e.id = ea.id join (select id, max(datevalidfrom) max_date employeeaddress group id) ea2 on ea.id = ea2.id , ea.datevalidf...

ios - Adjusting image size on imagView and left bar button item -

Image
in project have 'change logo' option. on clicking gray logo in front of change logo, gallery opens , user chooses photo it. done using following code: -(void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info{ uiimage *image = info[uiimagepickercontrolleroriginalimage]; [imagepicker dismissviewcontrolleranimated:yes completion:nil]; imgtobesaved = image; self.imgviewchooselogo.contentmode = uiviewcontentmodescaleaspectfit; self.imgviewchooselogo.image = image; imagechanged = yes; } now image saved in documents directory. image should serve logo view controllers. have set left bar button item using following code: nsdata *imagedata = [nsdata datawithcontentsoffile:[appdelegate documentdirectorywithfilepath]]; uiimage *image = [uiimage imagewithdata:imagedata]; uiimage *new = [appdelegate imagewithimage:image scaledtosize:cgsizemake(150, 40)]; uiimage *new1 = [new imagewithrenderingmode...

google maps - How to check nearby any road is there or not by using lat/long values in android -

i developing gps tracker application android, , trying track bus route , show in google map, getting latitude , longitude value of bus location bus moving or not moving also. my problem:- bus moving on road , getting lat/long values , throw in google map. problem marker moving on building,river bus going on road my requirement:- marker should move on road not on building suppose if lat/long values off road(outside road) should check near road there or not if there marker has locate on road how check nearby road there or not using lat/long values could please me? there google maps roads api has snap road feature. have sample app android explains how use it. specifically, see this file project. other that, need key beyond normal google maps one. this app requires 2 keys before run, 1 google maps api android , 1 roads api. to obtain google maps api android key, follow instructions in api's getting started guide , add google_maps_key field in ...

php - Tooltip not functioning when routed to a new url path -

Image
i have template php files dates , sharing. 1 file this: date-share.php: <div class="date"><?php echo date('m d'); ?><span><?php echo date('y'); ?></span></div> <a href="javascript:void(0);" class="share-button"><span class="plus"></span>share</a> <!-- tooltip --> <div class="tooltip-social-network clearfix" style="margin-top: -10px"> <span class='st_facebook_large' displaytext='facebook'></span> <span class='st_twitter_large' displaytext='tweet'></span> <span class='st_googleplus_large' displaytext='google +'></span> <span class='st_p...

python - Simpler code to combine multiple lists into one array? I actually wish "lists" are still "lists" in that array -

i have question similar this , that , solutions lists "united" lack of "differentiation". my python code following: y = np.empty([1,len(test)]) count = -1 feature in test : n = engine.neighbours(np.asarray(feature)) if len(n) != 4096: print "error" continue count = count + 1 y [count] = engine.neighbours(np.asarray(feature)) i wondering if there simplified code job? the linked questions have flattening list of lists. in code processing list of lists (i'm guessing), filtering out some, , collecting rest in 2d array. oops! y initialized 1 row, yet try place values in y[count] , count increase size of test . y = np.empty([1,len(test)]) count = -1 # prefer start 0, thats style issue feature in test : n = engine.neighbours(np.asarray(feature)) # engine.neighbors requires array; , returns array? if len(n) != 4096: print "error" ...

Accessing external hosts from docker container -

i trying dockerize application. have 2 servers, server1 , server2. server1 uses webservice hosted on server2. have in /etc/default/docker on server1: docker_opts="--dns 8.8.8.8 --dns 8.8.4.4 --iptables=false" as understand prevents docker making changes iptables, overriding ufw settings. ufw status shows this: status: active action -- ------ ---- 22 allow anywhere 443 allow anywhere 2375/tcp allow anywhere 22 (v6) allow anywhere (v6) 443 (v6) allow anywhere (v6) 2375/tcp (v6) allow anywhere (v6) now trouble not able access server2 app runs in container on server1. if don't use --iptables=false flag can access server2. can access server2 container without having sacrifice ufw ? if matters , both server1 , server2 on digitalocean , have private networ...

syntax - changing letter into an encryption in java. simple call -

what other way change "a" e.g."\n65" or other call in java based on ascii? not taught java developers anymore nice know. forgot, need use our project acutally \u0061 = 1 , forth, primitive way code think. not nuclear weapon program. :) not know this.

javascript - How to check first checkbox from ng-repeat loop in angular js? -

filters, want select first 1 radio button. restorent1 ✔ | restorent 2 | restorent3 | restorent4 <div ng-repeat="restorent_type in restaurant_types" style="margin:5px;" class="col col-offset-10"> <label class="item item-radio radio-label {{restorent_type.rescod}}"> <input type="radio" name="group" ng-model="restorent.types" value="{{restorent_type.rescod}}" ng-click="filters.rescod = restorent_type.rescod"> <div class="item-content"> {{restorent_type.rescod}} </div> <i class="radio-icon ion-checkmark"></i> </label> </div> you can use $first also <div ng-repeat="restorent_type in restaurant_types" style="margin:5px;" class="col col-offset-10"> <label class="item item-radio radio-label {{restorent_type.resc...

c# - ICorProfilerCallback2: CLR profiler does not log all Leave calls -

i trying write profiler logs .net method calls in process. goal make highly performant , keep let's last 5-10 minutes in memory (fixed buffer, cyclically overwrite old info) until user triggers info written disk. intended use track down reproducing performance issues. i started off simpleclrprofiler project https://github.com/appneta/simpleclrprofiler . profiler makes use of icorprofilercallback2 callback interface of .net profiling. got compile , work in environment (win 8.1, .net 4.5, vs2012). however, noticed leave calls missing enter calls logged. example of console.writeline call (i reduced output of dbgview minimally necessary understand): line 1481: entering system.console.writeline line 1483: entering synctextwriter.writeline line 1485: entering system.io.textwriter.writeline line 1537: leaving synctextwriter.writeline two entering calls don't have corresponding leaving calls. profiled .net code looks this: console.writeline("hello, simple profiler!...

how to use KeyValue in KeyPress event in C# -

in key press event can use keychar property , in keydown event can use keyvalue . need use keyvalue , keychar property in keypress event. how can it? you can not access keyvalue in keypress event . can use keydown event instead. can use keyvalue , e.keycode.tostring() keychar . in keydown event : e.keycode.tostring() = keychar example: private void yourcontrol_keydown(sender object, e keyeventargs) { var keychar = e.keycode.tostring() var keyvalue = e.keyvalue }

c# - How to understand a packet is TCP CLOSE packet with sharPcap -

i trying read packets sent clients server. using sharppcap in c#. how can understand packet tcp close packet in event: private static void device_onpacketarrival(object sender, captureeventargs e) { var time = e.packet.timeval.date; var len = e.packet.data.length; var packet = packetdotnet.packet.parsepacket(e.packet.linklayertype, e.packet.data); var tcppacket = packetdotnet.tcppacket.getencapsulated(packet); if(tcppacket != null) { var ippacket = (packetdotnet.ippacket)tcppacket.parentpacket; system.net.ipaddress srcip = ippacket.sourceaddress; system.net.ipaddress dstip = ippacket.destinationaddress; int srcport = tcppacket.sourceport; int dstport = tcppacket.destinationport; console.writeline("{0}:{1}:{2},{3} len={4} {5}:{6} -> {7}:{8}", time.hour, time.minute, time.second, time.millisecond, len, ...

ruby on rails - ActionView::MissingTemplate: ActionView::MissingTemplate: Missing template /members with {:locale=>[:en], :formats=>[:html], -

an integration test returning 'missing template' error. microposts_interface_test.rb errors on /members . may because /members view uses micropostscontroller i'm unsure how fix test. error["test_micropost_interface", micropostsinterfacetest, 2015-06-19 06:40:32 +0800] test_micropost_interface#micropostsinterfacetest (1434667232.75s) actionview::missingtemplate: actionview::missingtemplate: missing template /members {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :haml, :jbuilder]}. searched in: * "/home/me/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/web-console-2.0.0.beta3/lib/action_dispatch/templates" * "/home/me/development/my_app/app/views" * "/home/me/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/web-console-2.0.0.beta3/app/views" * "/home/me/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/phrasing-4....

concurrency - C Semaphore strange precedence behavior -

i'm practicing concurrency in c, , seem encounter problems semaphores. i'm using xcode 6.3.2 in macosx. here sample program seems act strangely: purpose of example print either abcd or bacd strings #include <stdio.h> #include <semaphore.h> #include <pthread.h> #include <errno.h> void *thread1(void*); void *thread2(void*); sem_t *sem0, *sem1, *sem2;; int main(int argc, const char * argv[]) { pthread_t t1, t2; sem0 = sem_open("sem0", o_creat, 0600, 2); sem1 = sem_open("sem1", o_creat, 0600, 0); sem2 = sem_open("sem2", o_creat, 0600, 0); // quick check if (sem0 == sem_failed || sem1 == sem_failed || sem2 == sem_failed) { printf("something went wrong\n"); return 0; } pthread_create(&t1, null, thread1, null); pthread_create(&t2, null, thread2, null); pthread_join(t1, null); pthread_join(t2, null); sem_close(sem0); sem_close(sem1...

openstreetmap - Editing xml data -

i have .osm file xml. remove elements in not have "highway" tag in it. highway tag simple xml attribute. it's quite large file , it's not easy manually. quick way remove elements? you probally want make use of osmosis , osmfilter , ... tools understand osm fileformat , it's semantic.

asynchronous - node.js continues execution without waiting for a require to complete. -

i'm trying access variable in required node file. file requiring continues without waiting variable set. how app.coffee wait before continuing? i have 2 files: db.coffee: databaseurl = 'mongodb://localhost/db' mongoose = require('mongoose') mongoose.connect(databaseurl) db = mongoose.connection records = [] db.on('error', console.error.bind(console, 'connection error:')) db.once('open', () -> console.log('connected database: ', databaseurl) ) schema = new mongoose.schema({play_counts: {type: number}, album_name: {type: string }}) albums = mongoose.model('albums', schema) albums.find({}, {}, (err, data) -> if err? console.log("error: failure retrieve albums.") return else records = data ) console.log(records) module.export = records and app.coffee: db = require('./db') console.log(db) when run app.coffee output ...

c# - How can I safely render HTML content from a WYSIWYG editor in ASP.NET? -

what best practice safely encoding output of content created using wysiwyg editor in asp.net/mvc5? tags related formatting , layout etc. render html @ same time avoid xss attacks. editor summernote, not should matter. obviously, highly insecure: @html.raw(model.content); this wrong: @model.content and microsoft sanitizer goes far other way, removing formatting added wysiwyg editor. @html.raw(microsoft.security.application.sanitizer.getsafehtmlfragment(model.content)) is there built-in or popular library can used? afaik there no "best practice" doing this. you're fighting framework. mvc designed render model (a bag properties) view (a template). in theory, might able strip out content wysiwyg output derived user input (i.e. stuff might cause xss , sql injection), sanitize pieces, , put them in. wouldn't that.

android - Update userpositon to server periodically using Endpoints -

i update users position google endpoint in google app engine periodically. fact i'm using endpoints important, because that's why cant use intentservice , alarmmanger schedule task. the problem following: update position server need objects not accessible in service. let me try sketch it: public class myservice extends intentservice { [...] @override public int onstartcommand(intent intent, int flags, int startid) { endpointshandler.updateposition() return super.onstartcommand(intent, flags, startid); } } here need objects of endpointshandler . cannot create new object, because depends on other objects googleapiclient . but cannot add objects server because when initialize alarmmanager there no way pass objects alarmmanager alarmmanager = (alarmmanager) getsystemservice(alarm_service); intent updaterintent = new intent(this, myservice.class); pendingintent pendingintent = pendingintent.getservice(this, 0, updaterintent, 0); al...

python - get text by beautifulsoap without using str.text.strip() -

i want text tag using beautiful soap, try code on computer(running mac osx yosemite) , works correctly when run code on linux server(running ubuntu 10.4) error: mtemp = div_tag.text.strip() attributeerror: 'nonetype' object has no attribute 'text' and code it: div_tag = soup.find('div', class_='span12 path_item') mtemp = div_tag.text.strip() print mtemp i need text tag, don't know why code doesn't run on server , have find way pure text tag out using div_tag.text.strip() if can see div_tag content(text/ want html code) , div_tag self here: صفحه اصلی مکان‌ها گردشگری میراث فرهنگی کاخ موزه گلستان <div class="span12 path_item"> <a href="/" style="margin-right: 5px;"><i class="fa fa-arrow-left"></i> صفحه اصلی</a> <a href="/list/show-places" id="placeholderdivm...

python - Splitting a CSV file into equal parts? -

i have large csv file split number equal number of cpu cores in system. want use multiprocess have cores work on file together. however, having trouble splitting file parts. i've looked on google , found sample code appears want. here have far: def split(infilename, num_cpus=multiprocessing.cpu_count()): read_buffer = 2**13 total_file_size = os.path.getsize(infilename) print total_file_size files = list() open(infilename, 'rb') infile: in xrange(num_cpus): files.append(tempfile.temporaryfile()) this_file_size = 0 while this_file_size < 1.0 * total_file_size / num_cpus: files[-1].write(infile.read(read_buffer)) this_file_size += read_buffer files[-1].write(infile.readline()) # possible remainder files[-1].seek(0, 0) return files files = split("sample_simple.csv") print len(files) ifile in files: reader = csv.reader(ifile) row in rea...

java - Jar ignoring all methods -

i making pretty simple jar unzip zip , run jar inside of it. problem i've run doesn't @ all. this main, , class file jar. manifest point correctly it, , loads without errors. import java.io.file; import java.io.ioexception; import java.io.outputstream; import java.io.filewriter; import java.io.bufferedwriter; import java.io.bufferedoutputstream; import java.io.bufferedinputstream; import java.io.bufferedreader; import java.io.fileoutputstream; import java.io.fileinputstream; import java.io.filenotfoundexception; import java.io.inputstream; import java.io.inputstreamreader; import static java.lang.integer.parseint; import java.net.urlconnection; import java.net.url; import java.util.zip.zipfile; import java.util.zip.zipentry; import java.util.zip.zipinputstream; import java.util.enumeration; import sign.signlink; import java.nio.file.*; import java.io.filereader; public class clientupdater { private string filetoextractnew = "/client.zip"; privat...

arrays - Passing buffers in C with MISRA compliance -

misra frustrating our developers. we getting misra errors "do not apply pointer arithmetic pointer" , "pointer not point array". we using syntax of: uint8_t const * p_buffer to pass buffer function writes buffer spi bus. given example code fragment: static void write_byte_to_spi_bus(uint8_t byte); void write_buffer_to_spi_bus(uint8_t const * p_buffer, unsigned int quantity) { (unsigned int = 0; < quantity; ++i) { write_byte_to_spi_bus(*p_buffer++); } } is there way have pointer cell in array , increment satisfy misra? my interpretation misra wants incrementing indices array , not pointer: void write_array_to_spi_bus(uint8_t const p_array[], unsigned int quantity) { (unsigned int = 0; < quantity; ++i) { write_byte_to_spi_bus(p_array[i]); } } many of developers old school , prefer use pointers uint8_t rather passing array. j...

How would I do a pop on a PG::Result in Ruby? -

running pop on result set pgsql database get: undefined method `pop' #<pg::result:0x0000000273dc08> i want first 5 of result set, it, again next 5. don't want run query twice long query. how in ruby? i running ruby 2.1 , rails 3.0. pg::result enumerable use each_slice on it: your_pg_result.each_slice(5) |array| # array @ 5 rows result set # on each iteration whatever needs done end if need differentiate iterations throw with_index mix: your_pg_result.each_slice(5).with_index |array, i| # ... end

database - Two error messages received when accessing or adding entries to Java DB -

package deadb; import java.sql.connection; import java.sql.drivermanager; import java.sql.sqlexception; import java.sql.statement; import java.sql.resultset; import java.util.scanner; public class deadb { public static void main(string[] args) { try{ int controller; string host = "jdbc:derby://localhost:1527/deadornas"; string uname = "tmybr11"; string upass = "1324132448"; connection con = drivermanager.getconnection( host, uname, upass ); statement stmt = con.createstatement( resultset.type_forward_only, resultset.concur_read_only ); string sql = "select * deadornas"; resultset rs = stmt.executequery( sql ); scanner input = new scanner( system.in ); int beta = 0; while( beta == 0 ){ system.out.printf( "\ncompany's data base. want do?\n" ); system.o...

css - Prevent words from cutting off into a new line -

i'm wanting prevent each word within hover element cutting off new line. here's jsbin of issue . it's vital alignment of tooltip central hover element, , hover element width of long string of text becomes (no set width). how may this? [data-tooltip]:hover { position:relative; } [data-tooltip]:hover:after { margin-top:7px; padding:8px; content:attr(data-tooltip); text-align:center; color:#fff; border-radius:3px; background:rgba(0, 0, 0, .8); } [data-tooltip]:hover:after, [data-tooltip]:hover:before { position:absolute; top:100%; left:50%; -webkit-transform:translatex(-50%); -ms-transform:translatex(-50%); transform:translatex(-50%) } [data-tooltip]:hover:before { margin-top:2px; content:''; border-right:6px solid transparent; border-bottom:6px solid rgba(0, 0, 0, .8); border-left:6px solid transparent; } <span data-tooltip="boo">boo...

java - When I set some items to view.invisible in getView(), others don't appear -

visiin custom adapter getview method, have switch case different types of layout cells. refer 1 layout xml these cells , show/hide elements setvisibility(view....) in first cell, "streamlayout," want show 1 imageview, "boombox". set image view invisible in other layouts, when this, won't show in first one. provide getview method , layout xml: getview: @override public view getview(final int position, view convertview, viewgroup parent) { holder = null; int type = getitemviewtype(position); if (convertview == null) { convertview = minflater.inflate(r.layout.listview_cell, null); holder = new viewholder(); } else { holder = (viewholder) convertview.gettag(); } switch (type) { case stream_layout: convertview = minflater.inflate(r.layout.listview_cell, null); imageview boombox = (imageview) convertview.findv...

c# - Why background thread not exiting when form closes? -

as understand it, if set _mythread.isbackground = true thread should exit when form closed. unfortunately i'm not finding thread exiting. here code looks like: private void mainform_load(object sender, eventargs e) { // <snip> daemon = new daemon(); // <snip> } public daemon() { // start main thread of connection checking , work _mainthread = new thread(() => mainthread(this)); _mainthread.isbackground = true; _mainthread.start(); } /// <summary> /// work main thread does. /// </summary> private void mainthread(daemon daemon) { while(true) { try { // things. thread.sleep(2000); // sleep bit not hammer. } catch (exception e) { logger.exception(e); } } } i thought since thread started form setting isbackground=true force close on form exit. am missing or misinterpreting something? according document...

user interface - Android, Unexpected button left and right paddings -

Image
i want make button, left right top , bottom paddings same. this: here layout: <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content"> <textview android:id="@+id/people_number_label" android:text="@string/number_of_people" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <button android:id="@+id/people_number" android:layout_torightof="@+id/people_number_label" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </relativelayout> so way button works text view background drawable. drawable 1 you're seeing. text centered within drawable, see here. if want text appear in line prompt, button isn't going ...

vbscript - VB script will not traverse every file in a given folder -

i new vbscript , looking write simple script changes couple cells in few thousand csv files in given folder location. have start, , seems working, except fact when run script (from .bat file calls script) changes , moves 3-8 files @ time. number of files changes random, not changes 5 files or something. not sure wrong in code why not edit , move every single file , couple @ time, here have far, in advance help: set objfso = wscript.createobject("scripting.filesystemobject") set colfiles = objfso.getfolder("c:\users\xxx\badcsvs").files set xl = createobject("excel.application") each objfile in colfiles if lcase(objfso.getextensionname(objfile)) = "csv" set wb = xl.workbooks.open(objfile) set sht = xl.activesheet if(sht.cells(1,11) <> "") sht.cells(1,8) = sht.cells(1,8) & sht.cells(1,9) sht.cells(1,9) = sht.cells(1,10) sht.cells(1,10) = sht.cells(1,11) sht.cells(1,11) =...

Python csv to dictionary with first line as title -

i have file file.csv data: fn,ln,tel john,doe,023322 jul,dap,024322 jab,sac,0485 i have array can access this: file = 'file.csv' open(file,'ru') f: reader = csv.dictreader(f) print reader[0].fn so prints first name first record. unfortunately, error: valueerror: i/o operation on closed file how can done don't need keep file opened , can play array. btw, don't need write in csv file, need use data , that, array can modify best. you need access reader *within with block, not outside of it: file = 'file.csv' open(file,'ru') f: reader = csv.dictreader(f) first_row = next(reader) print first_row['fn'] as move code outside block, f file object closed , cannot obtain rows reader anymore. kind of point of with statement. if want have random access rows in file, convert reader list first: file = 'file.csv' open(file,'ru') f: reader = csv.dictreader(f) all_rows = list(...

python - Why is this regex experiencing catastrophic backtracking? -

i've read the articles , other questions on catastrophic backtracking in regular expressions , how can caused nested + , * quantifiers. however, regexes still encountering catastrophic backtracking without nested quantifiers. can me understand why? i wrote these regexes search a specific type of rhyme in lines of welsh poetry. rhyme consists of consonants in beginning of line being repeated @ end, , there must space between beginning , end consonants. i've removed vowels, there 2 exceptions make these regexes ugly. first, there allowed consonants in middle don't repeat, , if there any, it's different type of rhyme. second, letters m, n, r, h, , v allowed interrupt rhyme (appear in beginning not in end or vice versa), can't ignored because rhyme consists of letters. my script automatically builds regex each line , tests it. works rest of time, 1 line giving catastrophic backtracking. line's text without vowels is: nn frvvn frv v the regex aut...

java - Parser pattern for monthOfYear that is not zero-padded with no literal text separation -

is possible parse date 8302011 using jodatime? in less painful format, 8/30/2011 , pattern mm/dd/yyyy . what i've tried: pattern mddyyyy 8302011 -> cannot parse "8302011": value 83 monthofyear must in range [1,12] 12302011 -> 2011-12-30t00:00:00.000z fortunately, date not ambiguous day represented 2 digits. month, however, either 1 or 2 digits. i realize simple enough pad zeros on left 8 characters, in case, unable that. i know below different jodatime can try use simpledateformat parse date alternative one import java.text.parseexception; import java.text.simpledateformat; import java.util.date; /** * created luan on 9/12/16. */ public class datetimeformattest { public simpledateformat simpledateformat = new simpledateformat("mddyyyy"); public simpledateformat simpledateformat2 = new simpledateformat("mm/dd/yyyy"); public date getdate(string source){ date date = null; try { ...

Java Nashorn expose java class (not instance) to javascript -

i using clearscript .net expose classes javascript. used expose class (not instance of class js) : engine.addhosttype("worker", typeof(worker)); use var x = new worker(); in javascript ; now in nashorn java not work. able expose instance of class : factory.getbindings().put("worker", new worker()); is there way expose class type javascript nashorn. thank you! your script can directly access java class qualified name such as var vector = java.type("java.util.vector"); // or equivalently: var vector = java.util.vector; // java.type better throws exception if class not found if don't want script directly refer java class or perhaps want provide different name, this: import javax.script.*; public class main { public static void main(string[] args) throws scriptexception { scriptenginemanager m = new scriptenginemanager(); scriptengine e = m.getenginebyname("nashorn"); // eval "java...

c# - How to make xml to csv parsing/conversion faster? -

i'm using snippet below convert xml data(not formed) .csv format after doing processing in between. converts elements in xml data contain integer list testlist ( list<int> testlist ). converts , writes file once match has been made. need use algorithm files several gb's in size. processes 1 gb file in ~7.5 minutes. can suggest changes make improve performance? i've fixed won't faster. appreciated! note: message.tryparse external parsing method have use , can't exclude or change. note: streamelements customized xmlreader improves performance. foreach (var element in streamelements(p, "xml")) { string joined = string.concat(element.tostring().split().take(3)) + string.join(" ", element. tostring().split().skip(3)); list<string> listx = new list<string>(); listx.add(joined.tostring()); message msg = nul...

java - Android Advanced Image processing -

i want build image editing application. i've gone through convolution matrix creating basic color filters want app have advanced editing capabilities highlight/shadow adjustment, vignette, curves adjustments etc. any chances might find examples same learn more it. also, kind of helpful resources great help. p.s. if there existing image editing library/sdk can job done, great too you should @ opencv , vxl. libraries of computer vision functions , have open source community around them. opencv big library/community. looking image processing libraries ideas have (permanantly stuck in pre-development due lack of time) , have played them bit on linux. i'm still opencv/vxl n00b though. https://en.wikipedia.org/wiki/opencv i found vxl bit faster started with. https://en.wikipedia.org/wiki/vxl there support opencv on android: http://opencv.org/platforms/android.html there not support vxl on android far can see. now, both of these pretty big projects. there...

java - AWS SNS sending with Spring Cloud. Trying to understand -

i newbie in spring. trying learn through practice implementing simple push server ios app documentation , samples on github. wrong , cannot understand what. me, please? so snssendercontroller code is: import org.slf4j.logger; import org.slf4j.loggerfactory; import org.springframework.beans.factory.annotation.autowired; import org.springframework.cloud.aws.messaging.core.notificationmessagingtemplate; import org.springframework.http.httpstatus; import org.springframework.web.bind.annotation.*; @restcontroller @requestmapping("/sns") public class snssendercontroller { private static final logger thelogger = loggerfactory.getlogger(snssendercontroller.class); private final notificationmessagingtemplate notificationmessagingtemplate; @autowired public snssendercontroller(notificationmessagingtemplate notificationmessagingtemplate) { this.notificationmessagingtemplate = notificationmessagingtemplate; } @requ...