Posts

Showing posts from January, 2010

javascript - using populate to display username instead of id -

i'm running expressjs mongoosejs made connection between collections customerid below: . . /** * customer schema */ var customerschema = new schema({ id : number, name: string, joined: { type: date, default: date.now }, city: string }); mongoose.model('customer', customerschema); . . /** * order schema */ var orderschema = new schema({ id : number, products: [schema.types.mixed], total: number, comments: string, customerid: {type: number, ref: 'customer'} }); mongoose.model('order', orderschema); . . exports.customerorders = function (req, res) { return order.find({customerid: req.params.customerid}, function (err, orders) { order.populate(orders, {path: 'customerid', model: 'order'}, function (err, orders) { if (!err) { return res.json(orders); } else { return res.send(err); } }); }); }; the above code generate following error: { m

c++ - Multiple instances of class using single instance of another class -

i have class (class a) there exist many instances of @ run time. class uses class (class r) handles resource allocation. due fact second class (class r) doing resource allocation instances of class there must single copy of it. so looks this: class p (parent) class a[64], childs of class p each of these requires access single instance of class r i'm wondering best solution of this. let parent (class p) instantiate class r , pass instance each class a. problem : class p doesn't care class r , has no use it. seems daft have manage it. global variable, perhaps hidden in namespace problem : can use it, , should restricted class a. static variable inside class a, instances of class have access same instance of class r. problem : static class variables evil or i've not thought of? let class r contain instance itself, ie. singleton pattern. then can do: class { r *resource; public: a() { resource = r::getinstance(); } } and on use 'resource&

debugging - lldb set maximum watchpoint count -

i facing little problem lldb, whenever want watch expression, error: error: watchpoint creation failed (addr=0x61f2e70, size=4). error: number of supported hardware watchpoints (0) has been reached and when watchpoint list -b it tells me number of supported hardware watchpoints: 0 no watchpoints set. is there command in lldb set maximum count of possible watchpoints / supported watchpoints? thanks the platform you're debugging not support hardware breakpoints, or if does, support not configured version of lldb you're using.

scalatest - SBT console encoding for test results -

i have sbt + scalatest project. tests log in console this: [info] - should *** failed *** [info] java.lang.exception: ╧ЁштхЄ! that's not useful of cause.. exception text in cyrillic have set cp866 charset on console stream display correctly. i've tried console.setout(new printstream(system.out, true, "cp866")) but sbt ignores it. seems sbt constructs it's own stream logging various messages, can't find , how alter it.. there way add custom logger, it's overkill. i've found solution. can create custom logmanager val customlogmanager = logmanager.defaultmanager(consoleout.printstreamout(new java.io.printstream(system.out, true, "cp866"))) and set in project settings: logmanager := customlogmanager though, i'm not sure if best solution. 1 flaw have provide logmanager setting every project. inheriting build settings doesn't work reason.

php - Populate html markup with data from the database -

i'm trying translate between php , asp.net. in php can connect database, run query, , print out results in html tags shown below: $query="select * comments;"; $result=$mysqli->query($query); while($row=$result->fetch_object()) { echo "<div class=\"comment\">"; echo "<h1>".$row->title."</h1>"; echo "<p>".$row->comment."</p>"; echo "</div>"; } ?> in asp.net c#, how this? i'm aware have use sqlconnection() , sqlcommand() , possibly sqldatareader(). how make asp.net have php doing above? , place code? in page load method? or in middle of html? i have looked using grid views , table views pull data database, don't allow me make page how want. want data database populate html template mark up, not predefined grid or table structure. thanks i guess of in sql-server well. see below .... test data decla

php - codeigniter validation not working in bootsrap modal window -

i trying validation class working in codeigniter within bootstrap modal window. function in controller contains codes not being seen form-open function. this modal form: <div class="modal fade" id="login" tabindex="-1" aria-labelledby="modallabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button> <h4 class="modal-title" id="mymodallabel">login</h4> </div> <div class="modal-body"> <?php echo validation_errors();?> <?php echo form_open('site/login_validation');?> <form> <div class="input-group"> <span class=&q

javascript - Get current slide number when using bookblock.js? -

im working on online book children, , im using bookblock.js flip animations. im using popcorn.js provide audio when im on current slide , highlight words when audio playing. problem (and maybe stupid question - im kinda new in javascript world) dont know how current slide can autoplay appropriate audio file. managed attach audio file on each slide , play when clicking custom play button , pause when clicking custom pause button, want autoplay appropriate audio file when clicking on next button user don't have press play every time on new slide. this main div have 2 more divs (bb-custom-side) in 1 (the right) have image, , in left bb-custom-side have 2 buttons (play/pause working should), have image (background) , text. <div class="bb-item" id="check3"> <div class="bb-custom-side"> <a class="play" id="play1" onclick="this.firstchild.play()"><audio clas

php - Mysql_query for all items inside array -

i have array() in php. want search through mysql database simultaneously array items. example cars array below: $cars=array("volvo","bmw","toyota"); besides array size variable. need search inside mysql database , see if specific row contains array values or not? something this: mysql_query("select * person personcar contains $cars[0] , $cars[1] , $cars[2]); personcar string. example "volvo, bmw, toyota, benz, ..." besides array size variable. appreciate if help. i've thought of loop , foreach loop don't know method in case. $tmp = array(); foreach ($cars $car) { $tmp[] = "personcar '%".$car."%'"; } $tmp = implode(" , ", $tmp); //" or " if want person owns of cars mysql_query("select * person {$tmp};");

How to search through multiple xml files for the occurence of a string in between 2 tags in linux? -

i have around 100 xml files in there inconsistency of how euro sign (€) displayed character or ( &amp;euro ). first prove these 2 strings occured in same files, used grep : grep -e "&amp;euro" -e "€" -r /home/xml/ -o &amp;euro occurs between tags <conditions> , <directions> . e.g. <directions> text text text : price : 19.99 &amp;euro text text&amp;euro </directions> <conditions><tag><tag2> text text text &amp;euro text&amp;euro </tag2></tag></conditions> i search occurence of € sign in strings in between these tags. how can achieve this? here's how i'd element 'directions': find . -name "*.xml" | xargs grep "<directions>.*\&amp;euro.*<\/directions>" same can applied 'conditions' element.

c# - Get all combinations of items in an array -

i have text files in folder such f1.txt,f2.txt,....f15.txt . want combination of them has length 2. the final result should {f1.txt, f2.txt}, {f1.txt, f3.txt}.... i used code static ienumerable<ienumerable<t>> getkcombs<t>(ienumerable<t> list, int length) t : icomparable { if (length == 1) return list.select(t => new t[] { t }); return getkcombs(list, length - 1) .selectmany(t => list.where(o => o.compareto(t.last()) > 0), (t1, t2) => t1.concat(new t[] { t2 })); } then call main method. string[] files = directory.getfiles(@"c:\users\downloads\samples", "*.txt"); ienumerable<ienumerable<string>> filescombination = getkcombs(files, 2); but why got nothing? edit: foreach(var x in filescombination) { console.writeline(x); } in immediate window, have ?x {system.linq.enumerable.concatiterator<string&

php - undefined variable $url, unsure why I am getting this error -

can tell me why getting following undefined variable ($url) error script. error if statement if ($url) . newbie. thanks an error occurred in script 'testnew/edit_your_sites.php' on line 28: undefined variable: url <div class="text"> <?php $page_title = 'edit account'; include ('includes/header.html'); include ('includes/functions.php'); include ('includes/config.inc.php'); if (isset($_get['id']) && is_numeric($_get['id'])){ $id = $_get['id']; } elseif (isset($_post['id']) && is_numeric($_post['id'])) { $id = $_post['id']; } else { echo '<p class="error">this page has been accessed in error.</p>'; include ('includes/footer.html'); exit(); } if (isset($_session['userid'])){ require (mysql); $scrubbed = array_map('spa

unpack(C*,data) Eats Memory [php exhausting memory on unpack function] -

i want read binary file byte[] in php , suggested here unpack 'ed fread's output . have like: $file=fopen($filename,'r'); fseek($file, $offset); //file 500mb take 10mb @ time $tmp = fread($file,$len); //so far , $tmp includes 10mb of data var_dump(strlen($tmp)); //int(10485760) 10mb var_dump(memory_get_usage(true)); //int(11272192) 11mb $data = unpack('c*',$tmp); this throws php fatal error: allowed memory size of 536870912 bytes exhausted (tried allocate 32 bytes) in [myfile.php] on line [unpack line] as error suggests memory limit set @ 512mb , according memory_get_usage 11/512mb used , unpacking 10mb string . @ should need 30mb (10mb $tmp , 10mb $data , 10mb internal variables). why explode , can't unpack $tmp 512mb ram ? so question is , doing wrong here or bug? , there other way array of bytes (0 255) read binary files in php or should switch language this? additional notes : code works 117kb file. php -v php 5.5.3-1ubuntu2.2 (

android - How to ScaleAnimation to a specific size -

i have view starting size (width1 , height1). want create animation change size end size (width2 , height2). have been reading scaleanimation cannot understand scaling factor. could please tell me values a, b, c & d constructor: scaleanimation scaleanimation = new scaleanimation(a, b, c, d); thanks parameters of 4-floats scaleanimation constructor following: fromx horizontal scaling factor apply @ start of animation tox horizontal scaling factor apply @ end of animation fromy vertical scaling factor apply @ start of animation toy vertical scaling factor apply @ end of animation all values float--they represent not sizes in pixels, relative scaling factors. scale width1 width2 , height1 height2 need set: scaleanimation scaleanimation = new scaleanimation(1f, 1f * width2 / width1, 1f, 1f * height2 / height1);

javascript - stuck on using addEventListener -

im @ javascript , dom. i'd below codes when append tr , click 2nd td (last name), 2nd td value changed bold. when click 2nd td value again, normal. i've done changing bold cant make go normal. know if add button onclick method calling dethandler. not allowed make button that. need click name again go normal. guys have ideas? <script type="text/javascript"> function appenduser() { var fname=prompt("please enter first name"); var lname=prompt("please enter last name"); var email=prompt("please enter email address"); var table=document.getelementbyid("appendable"); var tr=document.createelement("tr"); var td1=document.createelement("td"); var td2=document.createelement("td"); td2.id="p1"; var td3=document.createelement("td"); td1.innerhtml = fname; td2.innerhtml = lname; td3.innerhtml = email; tr.appendchild(td

Ruby: How do you use .uniq! on an array to look for duplicates based on a regex .scan? -

i'm having hard time grasping .uniq! method. i'm trying remove duplicate ips alerts in view. if use code in original code: receive alerts ips in index view: . show alerts, example; receive 500 alerts can condensed down 1 alert based on signature id (sid), source ip (ip_src), , destination ip (ip_dst). if append .uniq! (if thats how should used) don't different results, assume not work because timestamps , source ports not same, unique. here 2 sample messages should 1 instead of two. 04/04-16:13:47.451062 [**] [1:10000001:1] <dna0:dna1> drop - wp-admin attempt [**] [classification: web application attack] [priority: 1] {tcp} 10.17.21.37:55749 -> 173.239.96.163:80 04/04-16:13:28.474894 [**] [1:10000001:1] <dna0:dna1> drop - wp-admin attempt [**] [classification: web application attack] [priority: 1] {tcp} 10.17.21.37:55707 -> 173.239.96.163:80 i use signature id (sid), source ip (ip_src), , destination ip (ip_dst) of every message, , remove dupl

powershell - Make windows login through Face Authentication -

i have made face verification code using opencv, have made application in windows form vs2010 using c++. want execute app on windows login screen , bypass login when authenticates face. efforts side this: have search this, , have idea have write startup script in powershell this. dont know how this. helpful if can give pointers should next. note: thought might not possible(as security issue), found people have done here: http://face-detection-recognition.com/ which means possible achieve. thanks, as far know need create custom credention provider , extend/modify logonui implement (face recognition). unfortunately, i'm no developer can't explain furter. check out link: create custom login experiences credential providers windows vista

yii - ActiveRecord result return by findAll method needs in different format -

i executed following statement $posts = post::model()->with(array( 'category', 'member', 'profile' ))->findall(); i printed $posts in log file. got following result. array ( [0] => post object ( [_new:cactiverecord:private] => [_attributes:cactiverecord:private] => array ( [id] => 1 [post_text] => sales needs increase end of month. don't wnat reason behind this. [member_id] => 2 [category_id] => 3 [published] => 0 [draft] => 1 [date_added] => 2014-04-06 ) [_related:cactiverecord:private] => array ( [category] => category object ( [_new:cactiverecord:private] => [_attribu

c++ - How to use lambda functions or std::function with an API that takes function pointers? -

suppose want implement simple abstraction on pthreads. (or c api takes function pointers callbacks or threads). like std::thread, want interface able take function objects in general. how bridge gap in way works cases? (that includes binds, lambda functions, etc.) i know std::function::target afaik, not need. if api takes functions void* user data as, e.g., pthread_create() does, you'd pass pointer function user data, call trampoline casts user data function type, , calls function. example: #include <functional> #include <pthread.h> extern "c" void* trampoline(void* userdata) { return (*static_cast<std::function<void*()>*>(userdata))(); } void* start() { // ... return 0; } int main() { pthread_t thread; std::function<void*()> entry(start); pthread_create(&thread, 0, &trampoline, &entry); // ... } the immediate implication is, however, function object life-time isn't contr

Need help in 3D plot using MATLAB (X,Y,Z,V) -

Image
i need ask in plotting 3d volume in matlab. data set includes x, y, z coordinate , corresponding intensity value, v. i using pcolor (x,y,v) , shading interp while doing 2d images got stuck when create 3d images. have tried scatter3, smooth3 , slice seems not fit function need. my goal plot 3d grid corresponding intensity value per coordinate , apply shading interp between these points. i new in 3d plotting , appreciate in achieving goal. thank much! here example of images trying create link http://www.ndt.net/article/ndtce03/papers/v073/fig11.jpg link http://www.bam.de/de/_pic_u_film/web/kompetenzen/abteilung_8/fg82/fg82_fotos/fg82_fusion_pk_270.jpg i have solution first example, in show 3 cross-sections of volume data. solution can plot several pcolor different orientations, in 1 same 3d figure. first, need data different slices. had when did pcolor(x,y,v) plot cross section in 2d, x, y , v 2 dimensional matrices. need create matrix z z-position of slice (e.g.

android - setTextSize - sets the text bigger than expected -

i use code set text 1 sp bigger increases size much... public void dothis(menuitem item){ size = text.gettextsize(); text.settextsize(typedvalue.complex_unit_sp, (float) (size + 1)); } i want add 1 sp... thanks help because obtain size in pixels , use translate sp. first need convert size sp: float scaleddensity = context.getresources().getdisplaymetrics().scaleddensity; float sizenew = text.gettextsize() / scaleddensity; // obtain current size in sp sizenew += 1f; // add 1 sp text.settextsize(typedvalue.complex_unit_sp, sizenew); // set new size in sp

android - Service updating an activity that is not active -

what best way accomplish this? 1) mainactivity (i.e. ui) created , starts service starts listening tcp socket (should intentservice, since mainactivity client?). 2) service receives messagges , updates ui when comes (using localbroadcastmanager?). 3) user closes activity clicking or home button. mainactivity not active anymore, service should keep running in background, receiving messages , somehow communicating mainactivity (which not there). have no idea this, runonuithread()? 4) when user comes , resumes mainactivity, ui should not show new messages, "old" ones: every message has received since service started. 5) messages not permanent: should deleted if entire app killed, phone turned off ecc. have same life-cycle of service. my fear there's no such thing communicating activity not active (point 3) , should write messages in local file, checking updates oncreate() , onresume(). there smarter way? points 3 , 4 critical ones. best wa

git - gitignore everything except specific files -

i've been reading on stack overflow using gitignore ignore except specific files. i've tried bunch of different suggestions, can't work me. here's i'm trying do: want exclude except 1 file in main directory , couple other files in subdirectory. so, want these files: flightsofideas.rb /flightsofideas/svgexporttools.rb /flightsofideas/svgexport.rb my latest version of gitignore is: * !flightsofideas.rb !/flightsofideas/svgexporttools.rb !/flightsofideas/svgexport.rb but git includes flightsofideas.rb , doesn't files in subdirectory. you should add !*/ not ignore directories, or not directories include files. still similar problem what's difference between git ignoring directory , directory/*? . * !*/ !/flightsofideas.rb !/flightsofideas/svgexporttools.rb !/flightsofideas/svgexport.rb

delphi - How to know which control was clicked when sharing an action? -

this question has answer here: which way taction has been fired? 1 answer i'm implementing actions (in tactionmanager ) user interface. controls, when clicked, execute same action. however, in action handler, need know control clicked user. sender taction instead of originating control. how can identify control using action pressed user? you can obtain information actioncomponent property of action.

php - CGridview Conditional display related model data -

i trying filter product record in gridview category_id i have 3 table productmst(product_id,name) categorymst(category_id,category_nme) promoteduserproduct(category_id,product_id) ====> junction table productmst model rules this public function relations() { return array( 'categorymsts' => array(self::many_many, 'categorymst', 'promoted_user_product(user_product_id, category_id)'), ); } controller code this $criteria=new cdbcriteria(); $categorycondition=array(); if(isset($_get['category_id']) && $_get['category_id']!==""){ $categorycondition=array('select'=>false, 'condition'=>'categorymsts.category_id=1', 'jointype'=>'inner join '); } $criteria->with=array( 'categorymsts'=>$categorycondition); $datapr

node.js - Use angular $parser on the server side in Node -

i'd use $parser module of angular inside open source library i'm maintaining. library templating engine .docx . benefit filtering functionality, , parser in general (+ operations, dot syntax) what best way have access module. given library should work in nodejs? i can specify parser this: doc.parser=function(expression) { return {get:function(scope) {return scope[expression].touppercase() } } the parser first param expression parse (for example user.name ), returns object function can call, in same philosophy $parser module. parser create demo parser shows can uppercase values of expression. i'm seeking way say: doc.parser=$parser(), or this, , should work in nodejs , in browser. i found file: https://raw.githubusercontent.com/angular/angular.js/master/src/ng/parse.js responsible parsing, needs $filter module, ... you cannot use $parse method out of box angularjs consider using angular expressions - want. , works on bot server , client side

oracle - UPDATE using collection -

i testing code in want delete table using values stored in table type variable. it's list of id. far have tried below.. declare type rec_type table of dept.department_id%type; t_type rec_type; begin select department_id bulk collect t_type ( select department_id dept intersect select department_id emp ); forall c in t_type.first..t_type.last delete dept department_id=t_type(c).department_id; dbms_output.put_line(sql%rowcount); end; create table dept select * departments; create table emp select * employees; but getting error pls-00487: invalid reference variable 'dept.department_id%type' ora-06550: line 17, column 29: pl/sql: ora-22806: not object or ref ora-06550: line 16, column 8: pl/sql: sql statement ignored 06550. 00000 - "line %s, column %s:\n%s" *cause: pl/sql compilation error. not sure correct. appreciated :) the problem here type rec_type ta

Add element to end of tuple list in Haskell -

im new in haskell , try add element end of tuple list for example: [(1,2,3),(2,3,4)] want add (3,4,5) . [(1,2,3),(2,3,4),(3,4,5)] adding end of list inefficient can use ++ : [(1,2,3),(2,3,4)] ++ [(3,4,5)] if need keep adding end of collection use data.sequence instead: import data.sequence (fromlist [(1,2,3),(2,3,4)]) |> (3,4,5)

java - How do I within SQLite, return a row based on 3 values rather than just one? (Already done code for 1) -

within sqlite, can search table particular row contains 1 values instance player name want return row based on 3 values instance player name, team name , favorite color etc. how alter below code this? code searching based upon 1 value below: public backupdatastore getentry(string value, string columnname) { sqlitedatabase db = this.getreadabledatabase(); cursor cursor = db.query(table_name, new string[] { key_id, key_team_name, key_ref_name, key_date, key_player_1, key_player_2, key_player_3, key_player_4, key_player_5, key_player_6, key_player_7 , key_player_8},

string - Unexpected output in for loop - Python -

i have list: t=[['universitario de deportes'],['lancaster'],['universitario de'],['juan aurich'],['muni'],['juan']] i want reorder list according jaccard distance. if reorder t expected ouput should be: [['universitario de deportes'],['universitario de'],['lancaster'],['juan aurich'],['juan'],['muni']] the code of jackard distance working ok, rest of code doesn't give expected output.the code below: def jack(a,b): x=a.split() y=b.split() k=float(len(set(x)&set(y)))/float(len((set(x) | set(y)))) return k t=[['universitario de deportes'],['lancaster'],['universitario de'],['juan aurich'],['muni'],['juan']] import copy cp b=cp.deepcopy(t) c=[] while (len(b)>0): c.append(b[0][0]) d=b[0][0] del b[0] m in range (0 , len(b)+1): if m > len(b): break if ja

audio - lambda function c++ 11 -

any idea how rewrite lambda function pre c++11? if (maxvol != 0) std::transform(&spec[0], &spec[samplesize], &spec[0] , [maxvol] (float db) -> float { return db / maxvol; }); the code http://katyscode.wordpress.com/2013/01/16/cutting-your-teeth-on-fmod-part-4-frequency-analysis-graphic-equalizer-beat-detection-and-bpm-estimation thanks origional code: if (maxvol != 0) std::transform(&spec[0], &spec[samplesize], &spec[0], [maxvol] (float db) -> float { return db / maxvol; }); lambda: [maxvol] (float db) -> float { return db / maxvol; } replacement lambda: struct percent_of { //that lambda captures maxvol copy when constructed percent_of(float maxvol) : maxvol(maxvol) {} //the lambda takes "float db" , returns float float operator()(float db) const { return db / maxvol; } private: float maxvol; }; replacement full code: if (maxvol != 0) std:

ruby on rails - How to refer to the object I'm Fabricating inside my Fabricator? -

i'm using ruby 2.1.1p76 , rails 4.0.4 , fabrication gem . is possible refer object being fabricated? i have class foo , class bar. have fabricators each. problem each of class foo , bar contain field refers other class: class foo < activerecord::base has_many :bars belongs_to :current_bar, class_name: "bar" end class bar < activerecord::base belongs_to: :foo end it's bothersome have fabricate one, other , set reference first in specs: let!( :foo ) { fabricate( :foo ) } let!( :bar ) { fabricate( :bar, foo: foo ) } before( :each ) foo.update( current_bar: bar ) end i'd rather fabricate foo , have current_bar fabricated , referring foo i'm fabricating. i've read through fabrication gem documentation , can't find way possible. may overlooking it. know of way accomplish this? for completeness -- fabricators: fabricator( :foo ) current_bar nil end fabricator( :bar ) foo end yup. overlooked in docu

java - Verify signature always returns false -

in application server sends signed packet client using udp. packet contains x509encoded public key of server. on receipt of packet, client verifies signature against received data. verify() returns false. following code. please tell me wrong in code. //drply.java public class drply implements serializable, cpacket { private static final long serialversionuid = 1l; private byte ptype; private string name; private byte[] bpub; private string ip; private byte[] bsign; public drply(string n, byte[] bp, string i, privatekey prk) throws unsupportedencodingexception { name = n; bpub = bp; ip = i; ptype = (byte)2; bsign = gensignature(new string(name + bpub + ip + ptype).getbytes("utf-8"), prk); } public byte[] gensignature(byte[] bdata, privatekey prk) { byte[] bsign = null; try { signature sig = signature.getinstance("sha1withrsa"); sig.initsign(prk); //update signature data signed sig.upda

ms access - SQL query to select people interviewed more than once in a year -

first of query done in access, i'm trying find details of people have been interviewed more once in specific year. needs multi tabled, both sort out people have been interviewed more once in 2013, , details of people. example tables follows: interview | id | interviewdate | | 123| 13-12-04 | | 789| 14-01-10| | 123| 13-12-21 | person | id | name | number | location | | 123| john| 128231 | usa | 789| max | 123556 | europe so list bit larger, ideally want able make query count had interview more once in 2013 , details table. i have query apparently works i'm sure there's better way show may have flaws. select p.id, name, number, location, count(year(interviewdate) interviewno, year(interviewdate) year person p innerjoin interview on p.id = i.id group p.id, name, number, location, year(inteviewdate) having count(year(interviewdate)) > 1 , year(interviewdate)='2013' i feel year(interviewdate) wron

Can't move neither mp3 nor jpg with Files.move in java -

i finished reading question of same type unfortunaetly didn't me lot. i have problem moving files mp3 , jpg folder created before trying move files. here's code: public class filessorter { private string extension; public filessorter(string ext) { this.setextension(ext); } public void setextension(string extension) { this.extension = extension; } public void sortit(path path, path filename) { string stringpath = path.tostring(); switch (this.extension) { case "folder": return; case "txt": file folderdocs = new file(stringpath + ("\\documents")); if (!folderdocs.exists()) { folderdocs.mkdir(); } path sourcedocs = path.resolve(filename); path targetdocs = folderdocs.topath().resolve(filename); try { files.move(sourcedocs, targetdocs, atomic_move); } catc

php - Symfony2 getter validation -

i need validate datetime values booking system hostels , hotels. that, need getter validation. implemented isarrivaldatevalid() method return false (for testing purposes). when try run method in twig form_errors(form.arrivaldatevalid), keep getting arrivaldatevalid not exist although symfony knows method. the same problem here but solved error_bubbling mine isn't, no matter if error_bubbling true or false; have feeling basic problem last hour, cannot solve no matter do. any appreciated. edit: here validation.yml... hotel\rezervacijabundle\entity\rezervacija: properties: ime : - notblank : { message : "ime je obavezno" } prezime : - notblank: { message: "prezime je obavezno" } email : - notblank : { message: "e-mail je obavezan" } - email : { message: "e-mail mora biti ispravan" } getters: arrivaldatevalid : - "false&

sas - How to use tranwrd in a data step? -

i try substitute y x tried used tranwrd function in data step . result 1 row data test2 ; set test ; address = tranwrd(address , 'y' , 'x' ) ; put address ; run; test data follows id address 1 123 y street 2 234 y street 3 345 street the code, written, should work. removing put line prevent each line being written log (this speed things if have large data set): data test2 ; set test ; address = tranwrd(address , 'y' , 'x' ) ; run; the address = tranwrd(address , 'y' , 'x' ) ; adequately defines variable value. the put statement writes value of address sas log @ point in data step. you can read more put statement here : http://www2.sas.com/proceedings/sugi27/p104-27.pdf

AHow to get current IP in Java? -

i use code current ip: public string getipaddress() throws nullpointerexception, malformedurlexception, ioexception { url whatismyip = new url("http://checkip.amazonaws.com"); bufferedreader in = null; try { in = new bufferedreader(new inputstreamreader( whatismyip.openstream())); string ip = in.readline(); return ip; } { if (in != null) { try { in.close(); } catch (ioexception e) { e.printstacktrace(); } } } } but return value incorrect. what's wrong in code? you can use will's code on thread : getting 'external' ip address in java he use amazon service "external ip". here code : import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstreamreader; import java.net.url; public class ipchecker { public static string getip() throws exception {

mysql - How to count by current age given DOB and registration date sql -

i have users table includes: userid, username, dob, registrationdate. count members current age members registered since 2000. know latter part of query struggle counting part: select count (dob) registration_date >= ‘01/01/2000’ any help. thanks you need group member ages need calculate age in group clause. complicated because need account leap years. (i borrowed leap year part here .) create table users (userid int, username varchar(10), dob date, registrationdate date); insert users values (1,'bob','1990-06-01','2005-06-01') ,(1,'old gus','1990-06-01','1995-06-01') ,(1,'joe','1991-01-01','2010-06-01') ,(1,'jim','1950-01-01','2010-06-01') select year(curdate()) - year(dob) - (date_format(curdate(), '%m%d') < date_format(dob, '%m%d')) ,count(1) users registrationdate >= '01/01/2012' group year(curdate()) - year(dob) - (date_