Posts

Croping out points from an array list in Java -

crop: has parameters 2 points in cloud. 1 of these 2 points bottom corner, , other diagonally across top corner of rectangle. crop remove points outside rectangle cloud crop image. crop method must deal 2 input points on horizontal or vertical line segment, in case points not on line segment removed, , must deal 2 equal points p1 , p2, in case points p1 removed cloud. for example, if 2 input points (0.0,0,0) , (1.0,1.0), points outside square delimited (0.0,0.0), (0.0,1.0), (1.0,1.0), , (0.0,1.0) removed, if 2 input points (0.0,0,0) , (0.0,1.0), points outside line segment delimited (0.0,0.0), , (0.0,1.0) removed. i'm having hard time approaching logically. if me out thankful. public void crop(point p1, point p2) { point left = points.get(0); point right = points.get(1); point top = points.get(2); point bottom = points.get(3); // point []rectangle2d = {p1,p2}; rectangle2d rect = new rectangle2d.double(p1.getx(), p1.gety(), p2.getx(), p2...

Best approach to add a case in a column for nhibernate -

what best way add query projection in nhibernate? case when account.firstname = '' , account.lastname = '' email.emailaddress else account.firstname + ' ' + account.lastname end should this: var accounts = session.queryover<account>() .select(projections.conditional(restrictions.and( restrictions.eq("firstname", ""), restrictions.eq("lastname", "")), projections.concat(p.lastname, ", ", p.firstname), projections.property(t => t.emailaddress))) .list();

CSS Background Images To Repeat on x left and x Right with out overlapping -

ok trying set background image set like <---repeating image on left --- center image --- repeating image on right ---> the image on left not same image on thie right. i have tried using this body{ background: url(../img/background-01.png) center top no-repeat, url(../img/background-02.png) right 0 repeat-x, url(../img/background-03.png) left 0 repeat-x; background-color:#232323; } but background-02.png overlapping background-03.png resulting in background-02.png repeating on both left right side of page when meant repeating on right. here screen shot of design might give beter idear of trying make white boxes parts of background layer cropt out in there own image use on website [img] http://s7.postimg.org/iy0tm6k2j/screen_shot_2014_06_27_at_5_16_13_pm.png[/img] any apreeseated fix this. ok worked out used '#container{ position:relative; width:1000px; margin: 0 auto; left: 0; right: 0; border:thin solid #000; z-index:4; } #bgcon...

excel - Using application.ontime for a time tomorrow -

i have written timer in vba in excel using application.ontime makes sound , gives message box when end time reached. this works fine when time later in same day, when goes next day timer ends right away, time has passed today. eg if time 7:00 pm , want timer go off @ 6:00 tomorrow, timer goes off because 6:00 has passed today. is there way of incorporating date application.ontime call? better off using other function? thanks caroline you can use: application.ontime date + 1 + timeserial(6,0,0), "macro_name" as long don't close excel before 6am tomorrow. ;)

python - I don't understand the k-means scipy algorithm -

i'm trying use scipy kmeans algorithm. so have simple example: from numpy import array scipy.cluster.vq import vq, kmeans, whiten features = array([[3,4],[3,5],[4,2],[4,2]]) book = array((features[0],features[2])) final = kmeans(features,book) and result is final (array([[3, 4], [4, 2]]), 0.25) what don't understand is, me centroids coordinate should barycentre of points belongings cluster, in exemple [3,9/2] , [4,2] can explain me result scipy algorithm giving? it looks preserving data type giving (int). try: features = array([[3., 4.], [3., 5.], [4., 2.], [4., 2.]])

ruby - How do I download a pdf document from html in rails for a custom path? -

i trying figure out how download pdf document standard html template. using wicked pdf gem generate pdf. i followed instructions in bundle install , set config according https://github.com/mileszs/wicked_pdf following this, trying make work custom route. keeps rendering html instead of delivering pdf specified in form what doing wrong? there better way route pdf download? config/routes.rb match "/profile" => "vacancies#profile", via: :get view <%= form_for(@vacancy, :url => profile_path, :html => {:method => :get, :format => 'pdf'}) |f| %> <%= submit_tag "export profile"%> <%end%> vacancies_controller def profile respond_to |format| format.html{ render :layout => false } format.pdf render :pdf => "temp" render :layout => false end end end i wrote second action following research, download link(in view) works de...

hadoop - hdfs group permission doesn't work -

i'm using hadoop 2.2.0 , found hdfs group permission configs don't work linux filesystem $hadoop fs -ls /user drwxrwx--- - data data 0 2014-06-27 11:18 /user/data $whoami raw $groups raw data this directory belongs user data , group data . when user raw , member of group data , tries list directory /user/data on hdfs following exception raised: ls: permission denied: user=langxian.chen, access=read_execute, inode="/user/data":data:data:drwxrwx--- any idea why?