Posts

c# - Trying to refine several if statements down -

i'm trying find more elegant way reduce if statements down, have right little messy , reckon done better, suggestions? if(ship.position.y >= transform.position.y + ybound) { hitbounds = true; } if(ship.position.y <= transform.position.y - ybound) { hitbounds = true; } if(ship.position.x >= transform.position.x + xbound) { hitbounds = true; } if(ship.position.x <= transform.position.x - xbound) { hitbounds = true; } thanks time! update if(mathf.abs(ship.position.x - transform.position.x) >= xbound || mathf.abs(ship.position.y - transform.position.y) >= ybound) { hitbounds = true; } worked treat, million! hitbounds = math.abs(ship.position.x - transform.position.x) >= xbound || math.abs(ship.position.y - transform.position.y) >= ybound;

javascript - Using web workers with chrome extension -

what trying achieve here, execute xhrhttprequest() on worker speedup extension. using worker_proxy.js here . working totally fine except unable figure out how pass string worker. here code: manifest.json "permissions": [ "alarms", "activetab", "tabs", "webnavigation", "http://*/*", "https://*/*", "cookies" ], "options_page": "options.html", "background": { "persistent": false, "scripts": [ "worker_proxy.js","background.js"] }, "content_scripts": [ { "matches": ["https://*/*","http://*/*"], "js": ["jquery-2.1.4.js","hmac-sha256.js","enc-base64-min.js","worker_proxy.js","content.js"] } ], "web_accessible_resources": [ "worker_proxy.html",...

How i can create while loop as SINGLE LINE for command-line /bin/sh -

i can't create cycle single line in /bin/sh i tried: while true; do; sleep 1; done how can it? if want sleep 1 , remove ; after do . if want run command , sleep 1 , add command after do so: while true; echo "hi"; sleep 1; done

spring - Trying to delete a record from a parent entity java class -

i have 2 entity java classes . trying delete record parent entity throwing error : org.hsqldb.hsqlexception: integrity constraint violation: foreign key no action; sys_fk_10142 table: child . **parent class** @entity @table(name = "parent") public class parent { @id @generatedvalue(strategy = generationtype.identity) private long id; @notblank @column(name = "data") private string data; public long getid() { return id; } public void setid(long id) { this.id = id; } public string getdata() { return data; } public void setdata(string data) { this.data = data; } } **child class** @entity @table(name = "child") public class child { @id @generatedvalue(strategy = generationtype.identity) private long id; @notblank private string model; @manytoone() @ondelete(action= org.hibernate.annotations.ondeleteaction.cascade) private parent parent; public long getid() { return id; }...

ruby - Properly set / match routes in routes.rb -

i've implemented basic tagging in app, posts can filtered tags. there's route in routes.rb that get 'tags/:tag', to: 'links#index', as: :tag however, have url /tags lists tags (triggers index action in tag controller). i've set route up get 'tags' => 'tags#index' in tag view have index.html.erb <% @tags.each |tag| %> <div class="row"> <%= link_to tag.name, tag_path(tag) %> </div> <% end %> the problem <%= link_to tag.name, tag_path(tag) %> leads /tags/:id instead of /tags/:tag , doesn't work. how set up? add following to_param method tag model: def to_param name end

Rails Route URL segment with + (plus) sign character in id is not parsed correctly -

i have tagscontroller class, route following (in routes.rb) resources :tags now, when go http://localhost:3000/tags/test it works correctly. however, when go to http://localhost:3000/tags/c++ rails seems parsing "c++" "c ", results in "404 not found" could give me instructions on how fix this? for rails 4 rails provides constrain options determine regex parameter in routes: this constrains allowing access param /photos/1 or /photos/rr27 resources :tags, constraints: { id: /[a-z][a-z][0-9]+/ } for advance constraint by default :id parameter doesn't accept dots - because dot used separator formatted routes. if need use dot within :id add constraint overrides - example id: /[^/]+/ allows except slash. resources :tags, constraints: { id: /[^\/]+/ } these details of specifying constraint routes. hope can you.

jquery - Mobile menu breakpoint in Foundation -

Image
when resize browser, mobile menu shows @ 568x320 default breakpoint is. so want create breakpoint around 900px rid of menu issue (menu big) see in image below have no idea how it. i've been trying 5 hrs. straight , can't figure out. help? fiddle here . thanks. <nav class="top-bar" data-topbar role="navigation"> <ul class="title-area"> <li class="name"> <h1><a href="#">my site</a></h1> </li> <!-- remove class "menu-icon" rid of menu icon. take out "menu" have icon alone --> <li class="toggle-topbar menu-icon"><a href="#"><span>menu</span></a> </li> </ul> <section class="top-bar-section"> <!-- right nav section --> <ul class="right"> <li class="ha...