Posts

javascript - Is there any way to use $http inside the config function or there is any way call the url inside config to get the value in angular js -

i want call servlet inside config function of angular js accept language using $http inside config function possible or alternate solutions please.as new angular js uhm reading ask, think can use function inside .config() , inside function inject services need. i'll leave example using function ui.router can make idea of how use it. app = angular.module('myapp', []) .config(function ($stateprovider) { var dosomething = function ($http, $cookies, myservice) { //here logic } $stateprovider .state('mystate', { url: '/', resolve: { dosomething: dosomething },//for example here can use function templateurl: "views/login.html", controller: 'logincontroller' }); }); otherwise can use providers inject on .config() , use it.

http - How to perform callback in angular2? -

i have following code in angular2 service : this.returned: string; parseresponse() : void { console.log("response:",this.returned); } sendhttp(text: string): void { var to_send = json.stringify({"text": text}); var headers = new headers(); headers.append('content-type', 'application/json'); this.http .post('http://localhost:8080/', to_send, { headers: headers }) .map(res => { this.parseresponse() }) .subscribe( function(response) { console.log("success response" + response)}, function(error) { console.log("error happened" + error)}, function() { parseresponse(); } ); } but unfortunately parseresponse() not running after nodejs server returns "testing". however, request received correctly. me please? edit: this actual code. nothing console.logged. request sent. no callbacks executed. parseresponse(res: response) : void { cons...

unity3d - Trail renderer always black? -

Image
for reason 2d trail renderer stays black no matter change color. idea why? the answer easy. use mobile/diffuse shader not accept main color multiply texture. need shader has main color . can use (it varation of mobile/diffuse main color ) shader "mobile/diffuse color" { properties { // adds color field can modify _color ("main color", color) = (1, 1, 1, 1) _maintex ("base (rgb)", 2d) = "white" {} } subshader { tags { "rendertype"="opaque" } lod 100 pass { lighting off settexture [_maintex] { // sets our color 'constant' variable constantcolor [_color] // multiplies color (in constant) texture combine constant * texture } } } fallback "mobile/vertexlit" } also should use texture, can 2x2 resolutio...

highlighting - Intellij: Highlight current block of code -

Image
i wondering if possible highlight block of code working on in intellij idea. there similar question here: is there way highlight active code block in visual studio 2010? . so mean if have clicked e.g. method or while loop... ,the background of whole block becomes bit lighter or whatever. there's 1 such feature, it's more subtle, in form of vertical line inside left gutter... can't recall whether it's enabled default or not, can activate file -> settings -> editor -> general , scroll highlight on caret movement section (about half of page). i looked around while have not yet found way change appearance match description, although prefer less intrusive highlight having background changed. p.s. not sure relevant or useful you, there plugin tried while ago called codeglance offered scrollable-map of class:

numpy - how to load a dataframe from a python requests stream that is downloading a csv file? -

i create dataframe csv file retrieve via streaming: import requests url = "https://{0}:8443/gateway/default/webhdfs/v1/{1}?op=open".format(host, filepath) r = requests.get(url, auth=(username, password), verify=false, allow_redirects=true, stream=true) chunk_size = 1024 chunk in r.iter_content(chunk_size): # how load data how can data loaded spark http stream? note isn't possible use hdfs format retrieving data - webhdfs must used. you can pre-generate rdd of chunks' boundaries, use process file inside worker. examples: def process(start, finish): // download file // process downloaded content in range [start, finish) // return list of item partition_size = file_size / num_partition boundaries = [(i, i+paritition_size - 1) in range(0, file_size, partition_size)] rrd = sc.parallelize(boundaries).flatmap(process) df = sqlcontext.createdataframe(rrd)

web2py - Restful API with authentication -

i try built api web2py application. # -*- coding: utf-8 -*- auth.settings.allow_basic_login = true @auth.requires_login() @request.restful() def api(): response.view = 'generic.json' def get(tablename, id): if not tablename == 'division': raise http(400) result = db(db.division.title == id).select() return dict(result = result) return locals() but everytime try connect via curl answer: you being redirected <a href=\"/my_manager/login?_next=/my_manager/api/get_all_divisions/1.json\">here</a> when comment out line @auth.requires_login() everythink works fine. i've searched hints, didn't found helpful information topic far. any appreciated. i know pretty old question still answer other people might experience same issue: well in case using @auth.requires_login() needs user logged in. so need send basic auth credentials while making calls api. a simplest curl ...

tar untar files loses modification date -

when tar file , untar it, lose modification , creation date of file. there way protect date? need because have jenkins job uses aws sync command after untaring , keeps uploading same files s3. tar --atime-preserve preserve access time, creation , modification times not preserved. if receiving file system time stamps important, might have more success dump , restore commands (provided supported). believe there more options on how handle time stamps, intended backup , restore.