Posts

python - Passing in variables into functions -

this code uses trigonometry in order find missing sides on triangle. works using sohcahtoa find these sides. problem code when try run code gives me invalid syntax when call user defined function: "get_method". please can tell wrong code , how solve consistent problem occurs in programmes. import math def get_method(question, method): print("lable right-angle triangle.") question = input("what trying find? type 'h' hypotenuse, 'a' adjacent or 'o' opposite.").lower().strip() method = "" if question == "h": opposite_verify = input("do have length of opposite?\n" "type 'yes' or 'no'").strip().lower() if opposite_verify == "yes": method = "sine" elif opposite_verify == "no": adjacent_verify = input("do have length of adjacent?\n" ...

shell - curl call with parameters into variable doesn't work -

i'm working installr api. i'm trying following curl request via script : curl -h "x-installrapptoken: mytoken" https://www.installrapp.com/apps.json/ \ -f 'qqfile=@'$apkpath \ -f 'releasenotes=these release notes' \ -f 'notify=true' and works perfectly. however, when try release notes file variable : releasenotes=`cat "release_notes/test.md"` curl -h "x-installrapptoken: mytoken" https://www.installrapp.com/apps.json/ \ -f 'qqfile=@'$apkpath \ -f 'releasenotes='$releasenotes \ -f 'notify=true' > /dev/null it doesn't work @ all, first word sent. others, have error not resolve host: xxx. i did echo on these 2 curl request , exact same thing printed. cat command return specific format ? probably issue quotes , spaces. can use double-quotes around variable allow variable expansion in shell. releasenotes=$(cat "release_notes/test.md") curl -h "x...

ios - How to put timeout to NSTimer in swift? -

i have nstimer object below : var timer = nstimer.scheduledtimerwithtimeinterval(1, target: self, selector: "updatetimer", userinfo: nil, repeats: true) i want put timeout timer. maybe know postdelayed method in android. want same thing's swift version. how can ? nstimer not suited variable interval times. set 1 specified delay time , can't change that. more elegant solution stopping , starting nstimer every time use dispatch_after . borrowing matt's answer : // makes playground work gcd xcplaygroundpage.currentpage.needsindefiniteexecution = true struct dispatchutils { static func delay(delay:double, closure:()->()) { dispatch_after( dispatch_time( dispatch_time_now, int64(delay * double(nsec_per_sec)) ), dispatch_get_main_queue(), closure) } } class alpha { // delay time var currentdelay : nstimeinterval = 2 // delayed function ...

html - List styling, CSS selectors -

i want select first child(list item) of ordered list, did using. .ci-content ol.my-list > li:first-child{ color:green; //selected item in green.. } check problem here can achieve same without using "my-list" class in selector?...how restrict depth of selection. note: can have ol anywhere, not inside '.ci-content' always. <ol class="my-list">first set <li>one</li> <li>two <ol> <li>two.one </li> <li>two.two</li> <li>two.three</li> </ol> </li> <li>three</li> <li>four</li> </ol> <br><br> <ol class="my-list">second set <li>one</li> <li>two</li> <li>three <ol> <li>three.one</li> <li>three.two</li> <ol> <li>three.two.one</li> ...

Tab-specific, non-intrusive notification in a chrome extension -

i'm developing chrome extension. when user goes options page, might modify setting require them refresh tabs have in they're using extension. if user changes 1 of these settings, goes tab requires refresh, i'd notify them of in non-intrusive way. is there part of api doing sort of thing, or other recommended way of doing it? thinking of maybe little message comes down top of page, can closed, or popup coming out of browser action. you have many options.. name few: do not require it. as can, make (presumably) content script adapt new settings. it's far better ux - in cases. least intrusive update browser action / page action icon if use one. both apis allow per-tab change of icon/badge. animate little bring attention. an in-page notification injected dom. sort of toast or <dialog> . watch tab changes chrome.tabs events, , on activation of affected tab, such chrome.notifications notification .

javascript - Failed initializing html tab with server data -

i creating html page 2 tabs. when click on tab 1, loads table data 1. when click on tab 2, loads table data 2. tab 1 working expected. however, when click on tab 2, data isn't loaded. controllers identical. difference? here relevant html code. tab id "tabledata" loads data , tab id "correlations" doesn't load. <div> <ul class="nav nav-tabs" role="tablist"> <li role="presentation"><a href="#tabledata" aria-controls="tabledata" role="tab" data-toggle="tab">table data</a></li> <li role="presentation"><a href="#correlations" aria-controls="correlations" role="tab" data-toggle="tab">correlations</a></li> </ul> <!-- tab panes --> <div class="tab-content"> ...

php - Rewrite Rule not working or rendering page properly -

i making social networking site have many users. such, need simpler, easier way users page. assume logged in freddy, if go freddy's profile page, url say: http://localhost/profile_page.php . if page, want go to, let's say, alice's profile page, can modify url , type http://localhost/profile_page.php/alice rather writing http://localhost/profile_page.php?u=alice . i have created .htaccess file , have enabled rewrite_module apache modules in wamp. however, page not load appropriately. again, assume logged in freddy, profile page loads perfectly, when edit url go users page, i.e. http://localhost/profile_page.php/alice (who real user, expect go alice's profile page), not render page instructed via css , stays on freddy's profile page. .htaccess : rewritebase /www/ rewriteengine on rewriterule ^([a-za-z0-9_-]+)$ profile.php?u=$1 rewriterule ^([a-za-z0-9_-]+)/$ profile.php?u=$1 well, rules not considering php file here (check i've added slash be...