Posts

asp.net - Return user roles from bearer token of Web API -

i developing web api 2 project. authentication using bearer token. on successful authentication api returns json object. {"access_token":"vn2kwvz...", "token_type":"bearer", "expires_in":1209599, "username":"username", ".issued":"sat, 07 jun 2014 10:43:05 gmt", ".expires":"sat, 21 jun 2014 10:43:05 gmt"} now want return user roles in json object. changes need make in order user roles json response? after searching lot found can create custom properties , can set them authentication ticket. in way can customize response can have custom values may required @ caller end. here code send user roles along token. requirement. 1 can modify code send required data. public override async task grantresourceownercredentials(oauthgrantresourceownercredentialscontext context) { using (usermanager<applicationuser> usermanager = _usermanage...

c# - No connection could be made because the target machine actively refused it 127.0.0.1:57240 at System.Net.Sockets.Socket -

i have been developing web service , windows service, web service have deployed in server, , windows service have deployed works in own server, use windows service call web service. fine, in few days have received below message: system.net.webexception: unable connect remote server ---> system.net.sockets.socketexception: no connection made because target machine actively refused 127.0.0.1:57240 @ system.net.sockets.socket.doconnect(endpoint endpointsnapshot, socketaddress socketaddress) @ system.net.sockets.socket.internalconnect(endpoint remoteep) @ system.net.servicepoint.connectsocketinternal(boolean connectfailure, socket s4,socket s6, socket& socket, ipaddress& address, connectsocketstate state, iasyncresult asyncresult, int32 timeout, exception& exception) --- end of inner exception stack trace - -- @ system.net.httpwebrequest.getrequeststream(transportcontext& context) @ system.net.httpwebrequest.getrequeststream() @ system.web.services.protocols.s...

ios - dismissViewControllerAnimated not passing back data to vc1 -

i have vc1 , vc2. need vc2 set vc1's variable when vc2 dismissed. this relevant code in vc1.h - (ibaction)btnclick:(id)sender; @property (strong, nonatomic) nsstring *mystr; this relevant code in vc1.m - (ibaction)btnclick:(id)sender { uistoryboard * storyboard = self.storyboard; nsstring * storyboardname = [storyboard valueforkey:@"name"]; //in storyboard named vc2 "ctrl2" identifier viewcontroller2 *temp = [[uistoryboard storyboardwithname:storyboardname bundle:nil] instantiateviewcontrollerwithidentifier:@"ctrl2"]; [self presentviewcontroller:temp animated:yes completion:null]; } - (void)viewwillappear:(bool)animated{ nslog(@"in viewwillappear mystr %@", self.mystr); } - (void)viewdidload{ [super viewdidload]; nslog(@"my str %@", self.mystr); } this relevant code in vc2.h @class viewcontroller; - (ibaction)btnclkd:(id)sender; @property(nonatomic, weak)viewcontroller *v...

swift - How to call ambiguous method? -

given code extension array { func filter(includeelement: (t) -> bool) -> t[] { var ret = t[]() e in self { if includeelement(e) { ret += e } } return ret } } var = [1,2] var b = a.filter() {i in print(i); return true} it can't compile error message error: ambiguous use of 'filter' var b = a.filter() {i in print(i); return true} ^ swift.array<t>:84:8: note: found candidate func filter(includeelement: (t) -> bool) -> array<t> ^ <repl>:30:10: note: found candidate func filter(includeelement: (t) -> bool) -> t[] { ^ so looks allowed create extension method duplicated method , signature, somehow need special way call btw, default array.filter broken, calls closure twice each element , crashes repl or give rubbish result in playground if result inconsistent xiliangchen-imac:~ xiliangchen$ xcrun swift welcome swift! ...

java - Workaround for passing a method into a method? -

i looking way pass method parameter method. i trying simulate newton's-method ( http://en.wikipedia.org/wiki/newton%27s_method ) in java following code: public class newton { // iterationmethod public void newtoncalc(double x0) { double x; // counter int = 0; //newton-iteration x0 x = x0 - (y2(x0) / y2deriv(x0)); while (math.sqrt(y2(x)*y2(x)) >= math.pow(10, -10)){ //newton-iteration x(n+1) x = x - (y2(x))/ y2deriv(x); i++; system.out.printf("%d. %.11f\n",i,y2(x)); } system.out.printf("%d steps necessary resolution of 10^-10", i); } // function (2) public static double y2(double x) { return math.sin(x) / (1 - math.tan(x)); } // derivative (2) public static double y2deriv(double x) { return (math.cos(x) + math.sin(x) * math.tan(x) * math.tan(x)) / ((math.tan(x) - 1) * (math.tan(x) - 1)); } // function (4) public static double y4(double x) { return math.exp(...

Apache Worker and APC user cache -

anybody tried apcu zendopcache in mpm worker ? went problems mpm worker-apc found article https://engineyard.zendesk.com/entries/26902267 my target achieve apache mpm worker mod_fcgi [ mod_spdy work ] , zendopcache apcu ( user cache ) , varnish on top. run centos 6.4 on kvm. any oppinion appreciated. disclaimer: jetty developer, since asked opinion, here go. a alternative option run jetty fastcgi module (this link wordpress run jetty , chrome it's served via spdy - via alpn ). jetty java server known spdy support (the server transparent spdy push ), , fastcgi support too; has small memory footprint , it's highly scalable because asynchronous. with haproxy in front (mostly ssl offloading) satisfied of setup.

lisp - How do I ensure the correct precedence in Emacs highlighting keywords? -

Image
i'm trying write simple major mode lisp dialect. here's mode: (defconst example-font-lock-keywords (list `(";.*" . font-lock-comment-face) `(,(regexp-opt '("function" "macro") 'symbols) . font-lock-builtin-face) `("\"[^\"]+?\"" . font-lock-string-face)) "highlighting example mode.") (defvar example-mode-syntax-table (make-syntax-table)) (define-derived-mode example-mode lisp-mode "example" "major mode editing example lisp code." :syntax-table example-mode-syntax-table (set (make-local-variable 'font-lock-defaults) '(example-font-lock-keywords))) here's sample program: ; highlighting tests. ; comment despite "quotes" (function foo () "bar") here's result i'm seeing: what doing wrong? why string regexp 'win' against comment regexp? emacs highlights buffer in 2 phases. first syntactic phase, b...