Posts

ios - Why not change my background and title after accelerometer data is recieved? SWIFT -

print , func call successful both time, background , title change when restart app , works 1 times. here code: var motionmanager = cmmotionmanager() override func viewdidappear(animated: bool) { super.viewdidappear(animated) startmotionmanager() } func startmotionmanager() { if motionmanager.accelerometeravailable { motionmanager.accelerometerupdateinterval = 0.2 motionmanager.startaccelerometerupdatestoqueue(nsoperationqueue(), withhandler: { [weak self] (data, error) in print(data!.acceleration.z) if(data!.acceleration.z > 0.8) { self!.win() print("win") } if (data!.acceleration.z < -0.9){ self!.pass() print("pass") } return }) } } func pass() { print("passfunction") self.testlabel.text = "pass" self.view.backgroundcolor = uicolor.redcolor() } func win() { testlabel.text...

javascript - Add function to set of DOM elements using jQuery? -

my journey being @ least on above basic level in front end still on , stumbled upon quite big problem recently. i can select dom element, like var element=document.getelementbyid("elementid") and add function it, this function testfunction() { alert(this.getattribute('data-self')); } element.customfunction=testfunction; but there chance way of doing using jquery? tried attr() , prop() , data() , without luck on matter. data() close 1 though, because allows me execute function using $('#my-element-id').data('customfunction')(); example, still doesn't solve problem, new property of selected buttons not accessible other way. to sum up: simplest way add generic function (like in example) collection of dom elements in way it's accessible other property? adding function directly dom element not considered practice variety of reasons. i'd suggest jquery plugin method pretty easy: jquery.fn.mymethod = function(...

database - Insert query into Access C# -

i'm working access data base, have users table. i have insert query : database.execute("insert users(userid,firstname,secondname,username,password,permission) values(" + obj.personid + ",'" + obj.firstname + "','" + obj.lastname + "','" + username + "','" + psw + "'," + permission + ")"); i checked parameters' values same table's ones... says there syntax error in insert query. parameters, parameters, parameters. first benefit code, forget single quotes. second, avoid dreaded sql injection vulnerability. third, code easier read. consider this: string insertquery = "insert table (field1, field2, field3) values (@par1, @par2, @par3)"; database.execute(insertquery, var1, var2, var3); where var1 , var2 , var3 variables containing values need insert. there's simpler (but worse, because it's still vulnerable s...

VBA (Excel): Step Over debug and crash down with application.run -

i'm working vba excel. have following function: function (...) ... application.run "subname"... ... end function first question: while i'm debugging step on (shift f8) @ application.run line, debugger go "subname" sub that's step debug (f8 alone) instead of step on (shift f8). so question is: possible step on debug application-run? second question: if stop macro during execution of application.run command excel automatically close! so question is: there alternative application.run command? thanks i have been experiencing same problem mentioned , tested creating application object run method, solved crash. an example: function addspace(val1) string addspace = val1 & " " end function sub testrunanotherfunction() dim result, o set o = application() result = o.run("addspace", "one") result = result & "detail" end sub but not satisfied , wanted figure out why...

how can I access the javascript variable value in my qt-code -

i'm beginner in qt. tell me how use javascript variable value in qt-code? in advance. here documentation should answer question: http://qt-project.org/doc/qt-4.8/qwebframe.html#evaluatejavascript http://qt-project.org/doc/qt-4.8/qtwebkit-bridge.html http://qt-project.org/doc/qt-4.8/qwebframe.html#addtojavascriptwindowobject http://qt-project.org/doc/qt-4.8/qwebframe.html#javascriptwindowobjectcleared just looking @ docs, need call addtojavascriptwindowobject() , , maybe need make sure object doesn't cleared when javascript finishes. hope helps.

ruby on rails - Website screen capture on Linux server -

i have webpage written in angularjs needs turned image , sent email once week clients. webpage on s3 , backend server written partly in rails , partly in node. ideas how this? you can use phantomjs (or based on phantom casperjs) - library selenium, headless browser. possible create screenshots different device resolution , user-agent. http://phantomjs.org/screen-capture.html

javascript - Angular - Only show a div if something is present -

im trying make div appear if there no comments on article not sure how use ng-if correctly here. in scope have "comments" empty array if there no comments on article im not sure how check im using ng-repeat list comments id hide div if there no results in ng-repeat. this code default articles hide div if there no articles overall doesnt narrow down individual items comments. ng-if="articles.$resolved && !articles.length" how can change comments on article? the comments not embedded in article model. separate model article id value in comments model. if understand correctly want hide div if there no articles , no comments. if case, try this: <div ng-if="articles.length> 0 && comments.length>0"> <!-- content --> </div>