Posts

json - Server polling Angular js and get difference between the response -

i have api getdata method returns json data every minute in angularjs. function($scope, $http,$timeout, confirm) { (function tick() { $http.get('myapi.json').success(function(data) { $scope.operation = data ; $timeout(tick, 60000); }) })(); json data looks this. [{ "requests" :"200"} ....] after every minute "requests" value changes. want find difference between previous request value , current request value. tried $scope.$watch doesn't give object value change. please let me know how solve this?

c++ - When should I use pointer or reference members, and when should I pass nullptr or this as parent pointer in Qt? -

the code i've been writing c++ qt knowing works not understanding why things other "i know should doing this". this startup class initialises classes: namespace gui { startup::startup() : qobject(nullptr), m_setuptab(*new setuptab(nullptr)), m_regtab(*new cbcregisterstab(nullptr)), m_datatab(*new datatesttab(nullptr)), m_mainview(*new mainview(nullptr, m_setuptab, m_regtab, m_datatab)), m_systemcontroller(*new systemcontroller(nullptr, provider::getsettingsassingleton())), m_datatest(*new datatest(nullptr, m_systemcontroller)), m_setuptabvm(new setuptabviewmanager(this, m_setuptab, m_systemcontroller, ...

Ruby: get sum of nested hash value -

i have hash departments {"mechnical" => {"boys" => "25", "girls"=>"5"}, "civil"=> {"boys"=>"18", "girls"=>"12"}} i want output this, {"mechanical" => "30", "civil => "30"} do below # if in ruby 2.1 or greater your_hash.map { |k,v| [k, v.reduce(0) { |sum, (_, v)| sum + v.to_i }] }.to_h # => {"mechnical"=>30, "civil"=>30} # below ruby 2.1 hash[your_hash.map { |k,v| [k, v.reduce(0) { |sum, (_, v)| sum + v.to_i }] }] # => {"mechnical"=>30, "civil"=>30} # versions your_hash.each_with_object({}) |(k,v), h| h[k] = v.reduce(0) { |sum, (_, v)| sum + v.to_i } end # => {"mechnical"=>30, "civil"=>30}

ios - App quits unexpectedly but run smoothly when connected with xcode -

i facing strange error, app crashes @ once in start after disconnecting xcode when run app xcode connected works fine. device log is incident identifier: 1c4813 crashreporter key: c3535f303c4f4448be66e3cdefaf61a1b63074ca hardware model: ipad2,1 process: depilex [1295] path: /var/mobile/applications/22ca706f-5055-47ae-8f7c-a3a1558af6c1/depilex.app/depilex identifier: com.arr.depilex version: 1.2 (1.2) code type: arm (native) parent process: launchd [1] date/time: 2014-09-19 16:34:54.972 +0500 os version: ios 7.1 (11d167) report version: 104 exception type: 00000020 exception codes: 0x000000008badf00d highlighted thread: 0 application specific information: com.arr.depilex failed launch in time elapsed total cpu time (seconds): 4.100 (user 4.100, system 0.000), 6% cpu elapsed application cpu time (seconds): 1.121, 2% cpu thread 0: 0 libsystem_kernel.dylib 0x3953eaa8 sema...

css - 'Max' Responsive Breakpoints in em -

i'm working on responsive site using media queries in em, based around bootstrap 3, using sass. the 'max' breakpoints set on basis of browser baseline of 16px. understand media queries based of browser's base font size independent of base font size set on document. i've found articles explaining this, recommending em 'min' breakpoints can't find mention 'max'. is there best practice setting max breakpoints take account scenario browser's baseline isn't 16px? i'm using following: $screen-xs: 30em !default; $screen-xs-min: $screen-xs !default; $screen-phone: $screen-xs-min !default; $screen-sm: 48em !default; $screen-sm-min: $screen-sm !default; $screen-tablet: $screen-sm-min !default; $screen-md: 62em !default; $screen-md-min: $screen-md !default; $screen-desktop: $screen-md-min !default; $scre...

asp.net mvc - a default value for a Dictionary in c# -

this question has answer here: is there idictionary implementation that, on missing key, returns default value instead of throwing? 9 answers dictionary returning default value if key not exist [duplicate] 4 answers i have following pageviewmodel class: public class pageviewmodel : viewmodel<page> { public pageviewmodel () { kywords = new list<keyword>(); answserkeyworddictionary = new dictionary<string, answer>(); } public company company { get; set; } public list<keyword> kywords { get; set; } public dictionary<string, answer> answserkeyworddictionary { get; set; } } in view i'm using property answserkeyworddictionary that: @html.displayaffirmativeanswer(model.answserkeyw...

android - Should developer create a different model of Login Request & Response -

i using gson library in demo android project. want know should create different model login request & login response in json . for request created below public class login { private string username; private string password; public string getusername() { return username; } public void setusername(string username) { this.username = username; } public string getpassword() { return password; } public void setpassword(string password) { this.password = password; } } creating json login request. // creating json using gson library login mlogin = new login(); mlogin.setusername(username); mlogin.setpassword(password); gson gson = new gsonbuilder().create(); string loginjson = gson.tojson(mlogin); so here above created model login request & should create new model of login response again in json or not doing following correct approach. gson helps serialize , deserialize json objects/...