Posts

angularjs - Is it possible to use parameterized URL templates with angular $http service -

i'm using $resource restful api's , love parameterized url template example 'api/clients/:clientid' this works great crud operations. of api's reports or read-only end points without need full restful treatment. felt overkill use $resource , instead used custom data service $http. the drawback lose parameterized url templates. love define url like 'api/clients/:clientid/orders/:orderid' , pass { clientid: 1, orderid: 1 } . realize can build url dynamically hoping $http supported parameterized template , haven't found yet. all best update 7/5 the word missing in searches 'interpolate'. more information comes when search 'url interpolation in angular $http'. short answer looks 'no' $http doesn't support url interpolation. there few easy ways accomplish however. 1. use $interpolate: documentation $interpolate here var exp = $interpolate('/api/clients/{{clientid}}/jobs/{{jobid}}', false, null, true); ...

How to import a maven module to an Android Studio project -

i include retrofit module in android studio project (because plan on making few modifications retrofit library support json web tokens). problem retrofit maven project , android studio won't let me import it. there way around this? a similar question has been asked before , received no answers. use custom group and/or artifact in pom of clone, clone cannot confused original. build , install clone of retrofit using maven usual: mvn install . (using command line or ide other android studio.) have build retrofit clone manually after each change make it, gradle see changes. add local maven repository gradle script. see https://docs.gradle.org/2.5/dsl/org.gradle.api.artifacts.dsl.repositoryhandler.html#org.gradle.api.artifacts.dsl.repositoryhandler:mavenlocal() : repositories { mavenlocal() } add gav of clone dependency gradle script: dependencies { compile 'com.yourgroup:retrofit:1.9.0-custom' }

How to optimize query when join on varchar column in Sql Server -

i have 2 tables , b select a.id, b.name inner join b on a.name = b.name how optimize query? name column varchar(8) you should create index on both tables , b create index index_name on table_name (column_name) http://www.w3schools.com/sql/sql_create_index.asp

javascript - Wating for all finished request in a loop with node request -

i use node request ajax package. so, have loop, in every iteration makes request server. // realitems needs complete value of items assigned var realitems; var items = []; _.foreach(json.parse(body), (value, key) => { request('myurl/' + id, (error, response, body) => { items = json.parse(body) }); }); how can bundle requests request package, can assign value of items variable realitems @ end? // edit: i use react js, in case realitems state, , can't trigger in every loop iteration, because render triggers on every setstate there number of ways approach this. here's brute force method not preserve order of results: var items = []; var cnt = 0; _.foreach(json.parse(body), (value, key) => { ++cnt; request('myurl/' + value.id, (error, response, body) => { items.push(json.parse(body)); // if requesets done if (--cnt === 0) { // process items here results done } }); }); here's versi...

how do you check if the value is null and replace it by NA in R -

i need write web service call returns data json: {"application":"web","host":"prodwebserver01","datacenter":"nevada","pod":"1"} sometimes data can this: {"application":"null","host":"prodwebserver01","datacenter":"nevada","pod":"1"} or {"application":"web","host":"prodwebserver01","datacenter":"nevada","pod":"null"} sometimes, values application:"null" or datacenter:"null" , when this: zlinux<-data.frame(cbind(tolower(d$guestid),tolower(d$host),d$application,d$pod,tolower(d$datacenter))) keys have null values not show on zlinux data frame. if value null, replace n_a , have 4 columns in data frame. the following code: suppressmessages(library(rcurl)) suppressmessages(library(rvest)) guests<-c("web0...

wpf - VB.net: How to format money/numbers? -

i not know how come code format numbers. example: input textbox : 1000 result in textbox2: 1k example: input textbox : 1000000 result in textbox2: 1m example: input textbox : 1000000000 result in textbox2: 1b example: input textbox : 2147483647 result in textbox2: 2.147483647b example: input textbox : 583967 result in textbox2: 583.967k how do that? please help!! this can achieved conditional arithmetic grouping imports system public module module1 public sub main() dim input ulong console.write("enter number: ") input = convert.touint64(console.readline()) console.writeline(formatnumber(input)) end sub public function formatnumber(byval input ulong) string dim result string = input.tostring() if input >= 1000000000 result = string.format("{0}b", input / 1000000000) else if input >= 1000000 result = string.format("{0}m", input / ...

Getting Oauth token in app engine endpoints -

i looking way of obtaining oauth2 token app engine java endpoint. i aware of doing this, example: @apimethod(name = "getmyresponse", path = "getmyresponse", httpmethod = apimethod.httpmethod.get) public myresponse getmyresponse(final user user, httpservletrequest request) throws userunauthorizedexception { string authorizationheader = request.getheader("authorization"); string token = authorizationheader.substring(7); //do token here } however, looking bit more "civilized", parsing strings http header (like using api, example). ideas? if need token, seems uncivilized, i'd suggest writing yourself. api possibly use add weight codebase. write helper function : private static string gettoken (httpservletrequest req){ string authorizationheader = req.getheader("authorization"); string token = authorizationheader.substring(7); return token; } and in code reference string token = getto...