Posts

javascript - function prototype inheritance with new keyword -

i making sure understood javascript's new , prototype keywords correctly simple code put not behaving expect. var classa = function() { return { shout: function() { alert("i can shout"); } }; }; classa.prototype.shoutlouder = function() { alert("i can shout"); }; var instance = new classa(); instance.shout(); // why not available? instance.shoutlouder(); when instance variable attempts invoke shoutlouder it's failing "uncaught typeerror: instance.shoutlouder not function" . but, in mozilla docs , says when using new create object: a new object created, inheriting foo.prototype. where wrong in understanding? here jsbin above code-snippit. you're losing access function's (class') prototype object because you're returning new object out of function: var classa = function() { return { shout: function() { alert("i can shout"...

javascript - Countdown and bootstrap progress bar "bump" -

i'm working on little "web app" quiz. each slide has got amount of time answered (or 0 infinite time). i find js here countdown: function countdown(options) { var timer, instance = this, seconds = options.seconds || 10, updatestatus = options.onupdatestatus || function () {}, counterend = options.oncounterend || function () {}; function decrementcounter() { updatestatus(seconds); if (seconds === 0) { counterend(); instance.stop(); } seconds--; } this.start = function () { clearinterval(timer); timer = 0; seconds = options.seconds; timer = setinterval(decrementcounter, 1000); }; this.stop = function () { clearinterval(timer)...

javascript - how to keep resolving Q promises when polling -

i'm trying poll endpoint , use q resolve request. understand can't q, once promise resolved it's done. is there way can approach using q along polling? my setup like: class poller { poll() { const deferred = q.defer(); const promise = $.ajax({ //stuff }); promise.done((resp) => { // resolves once, how can keep resolving // on future xhr calls? deferred.resolve(resp); }); promise.always(() => { settimeout(() => { this.poll.call(this); }, 5000) }) return deferred.promise; } } const poller = new poller(); poller.poll().then((resp) => { // keep trigging updates polling }) the whole point of promise can resolved once. structure looking event .

Move Camera in UnityScript 2d in C# -

i have started programming unity 2d, , have faced 1 large problem: how move camera? script attached object "player". want move player. thanks! /* */ using unityengine; using system.collections; public class playercontroller : monobehaviour { public float speed = 10; //float speed public string haxis = "horizontal"; void start () { //empty } void fixedupdate () { if (input.getaxis (haxis) < 0) //left { vector3 newscale = transform.localscale; newscale.y = 1.0f; newscale.x = 1.0f; transform.localscale = newscale; } else if (input.getaxis (haxis) > 0) //right { vector3 newscale =transform.localscale; newscale.x = 1.0f; transform.localscale = newscale; } //position transformation transform.position = transform.position + transform.right * input.geta...

JWT and server side token storage -

every article i've read vouching advantages of jwt state 1 of these advantages ability auth system distributed across multiple servers. i.e . aren't relying on central repository of user auth details lookup on every request. however when comes implementation, i've read in many places added security shouldn't rely on jwt signature verification itself, , should maintain list of black or white list tokens generated server. doesn't defeat advantage i've listed above, list of tokens need stored centrally servers can access , require lookup on each request? how have people implemented on end? you making points in question. make sense store oauth token @ central location in order make easier implement signout/revoke functionality. if relied on token signature couldn't have possibly implemented such feature. suppose user wanted revoke access token. in case if didn't have central location/datastore tokens have invalidated , relied on token sig...

spring - SpringSecurity - Concurrent Session does not work -

i implementing control of concurrent session spring security. but when login in system chrome user , after on firefox same user, not display error message. no exception in console. my web.xml : <!-- ... --> <listener> <listener-class> org.springframework.security.web.session.httpsessioneventpublisher </listener-class> </listener> <!-- .... --> my security.xml : <-- .... --> <security:http auto-config="true" use-expressions="true"> <security:intercept-url pattern="/**" access="isauthenticated()" /> <security:form-login login-page="/login" default-target-url="/home" authentication-failure-url="/login?logout=true" authentication-success-handler-ref="authenticationsuccesshandler" authentication-failure-handler-ref="authenticationfail...

linux - wkhtmltopdf doesn't show desktop size page in pdf -

i have been trying set wkthmltopdf convert html pdf documents on-the-fly on linux web server. i've looked around solutions around default 800x600 issue , found this: /usr/bin/xvfb-run --server-args="-screen 0, 1024x768x24" wkhtmltopdf --use-xserver http://domain.com /home/location/apps/test1.pdf however, still gives resulting pdf width of 800. missing? i've tried run xvfb-run ssh command line , works flawlessly. creates pdf normal output.. it's width not being recognized... just guess, might need set of quotes around "0, 1024x768x24' it's considered single argument after being passed on. this: /usr/bin/xvfb-run --server-args="-screen \"0, 1024x768x24\"" wkhtmltopdf --use-xserver http://domain.com /home/location/apps/test1.pdf they escaped \ xvfb-run command not consider them argument delimiters, rather passes them on wkhtmltopdf. (i don't know xvfb-run, assume in turn building wkhtmltopdf command line....