Posts

java - Why the getApplication() from Service Class on android can still return its sub class obj? -

as title, i've seen code below in custom service class of kiahapplication acquire app's application obj: ((kiahapplication)super.getapplication()).setservicerunning(true); but how android.app.service class's getapplication method know & return custom application obj? android.app.service should not part of custom application, and it's not recorded in application's manifest file should definition of app's members. thank helping! super.getapplication() call getapplication in super class, android.app.service ((kiahapplication)super.getapplication()) cast result of super.getapplication() kiahapplication , class kiahapplication extends application ((kiahapplication)super.getapplication()).setservicerunning(true); call setservicerunning(true); on kiahapplication class but how service class's getapplication method know & return custom application obj? because it's singleton. anywhere call getapplication() retu...

PESEL checksum validation(Javascript/HTML) -

im student studying home , im stuck on checksum problem. script supposed validate pesel(polish equivilant of social security number think), anyway checksum works follows pesel: 70051012347 pesel:7,0,0,5,1,0,1,2,3,4 (7) (multiply each pesel number corresponding check number) check:1,3,7,9,1,3,7,9,1,3 (sum each number) sum: + 7,0,0,45,1,0,7,18,3,12 =93 mod: 93 mod 10 = 3 10 - 3 = 7(last digit of pesel) where mod 10 doesn't equal 0, result of sum%10 subtracted 10 , matched final digit in original number, if match good, if not bad. need have or bad result. i'm pretty sure have of fine in code , there's simple solution cant see it. @ massively appreciated. <html> <head> <meta charset="utf-8"> <title>pesel checker</title> <script type="text/javascript"> function peselgood(y) { //sample pesel's //type 1 //70051012347 //02070803628 //07020803628 //type 2 //83102570819...

css - media-query specificity - why is the largest style used when using max-width media queries? -

i have following (simplified) example code: ( jsbin: http://jsbin.com/cisahilido/1/edit?html,css,output ) scss: .container { background: none; } @media screen , (max-width: 480px) { .container { background: red; } } @media screen , (max-width: 768px) { .container { background: white; } } @media screen , (max-width: 1024px) { .container { background: blue; } } markup: <!doctype html> <html> <head> <meta charset="utf-8"> <title>js bin</title> </head> <body> <div class="container"> hello! </div> </body> </html> now, when screen 480px or less, expect .container have red background. however, seems have blue background, until 1024px breakpoint, has no background. why max-width styles override smaller breakpoints bigger ones? because 480 less last max-width of 1024. css uses last valid value, need order max-width media queries larg...

windows - CreateRestrictedToken( ) from WinAPI -

my question winapi createrestrictedtoken( ) function. how can create token allows process initialize , start itself, restrict access all files on computer, except specified files? obviously should enable logon sid in token (to let process use window station). i'm bit confused sidstodisable , sidstorestrict function. usage not clear me. the plan start process logon sid enabled, , grant permission logon sid files. seems not work. i'm stuck, , need help.

javascript - How can call on_menu_about(); function of UserMenu.js in Odoo 9? -

i want create odoo backend theme, use icon about tab, means when click on icon popup generated. tried code don't work: .xml <xpath expr="//ul[@class='nav navbar-nav navbar-right oe_user_menu_placeholder']" position="inside"> <li><a href="#" onclick="web.usermenu.on_menu_about();" data-menu="about" title="about"><i class="fa fa-question-circle"></i></a></li> </xpath> but did not work. so follow code answer . .xml <xpath expr="//ul[@class='nav navbar-nav navbar-right oe_user_menu_placeholder']" position="inside"> <li><a href="#" class="about" title="about"><i class="fa fa-question-circle"></i></a></li> </xpath> then in .js file include this var usermenu = require('web.usermenu'); var self=this; var u...

java - Send logs from a REST service to an HTML page -

i have rest service on server a. service doing stuff , logging messages log4j. aside, have web page on server b calling service ajax , getting response. apart receiving response (which works fine me), print on page log messages server side. in other words, every time there new log message on server side, view display it. any ideas achieve ? edit: how use websocket retrieve logs log4j socket appender? you create rest endpoint retrieve raw log data text/plain . following: get /logs http/1.1 accept: text/plain you provide query string parameters filter logs date , time, following: get /logs?from=2016-07-03t10:00:00z&to=2016-07-04t10:00:00z http/1.1 accept: text/plain then client can request such endpoint, retrieve data want , display logs in html page. if prefer rendering html page on server side, instead of accepting text/plain , accept text/html . for real time logging, consider websockets .

javascript - onDrag event raised with incoherent values when mouse released -

i far being html/javascript expert , going crazy around problem. did not find on net regarding this, tried multiple things without success. basically using drag functionality achieve something. don't need drag/drop, interested in drag. here very simple sample illustrating issue : https://jsfiddle.net/fhdolz70/2/ the div can dragged around , logging event.clientx value. values correct during drag, when release mouse, ondrag event raised once more incoherent clientx value (completely out of bounds, negative value). same happens clienty , other values associated event (not interested in other values clientx , clienty haven't checked). why ondrag raised when mouse released ? drag on ... , why hold such weird values ? how can avoid receive last event on mouse release ? thanks lot. what you're seeing oddity jsfiddle. ondrag event fired on release, typically return zero. if took same code , placed in standalone file this: <!doctype html> ...