Posts

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

i have date time below conversion logic in javascript converting utc time passed timezone's local time. wondering logic work fine during daylight transition? if not remedy that? can't use third party library. have use pure javascript or angular js. function mytime() { var d1= document.getelementbyid("txtdate").value; var zoffset = document.getelementbyid("txtoffset").value; console.log("date1",d1); var d2 = new date(d1.replace(/ /g,'t')); var d3= d2.gettime()+(d2.gettimezoneoffset()*60000); console.log("date2",d2); console.log("date3",d3); var d4 = new date(d3 + (3600000 * zoffset)); console.log("date3",d3); console.log("date 4",d4); var d5 = d4.tolocaletimestring(); console.log("date 5",d5); ...

How to check data type in C++? -

i'm new c++, i've been using python. i'm trying check type of variable of value stored in objects i'm working on. remember in python there comand isinstance use condition run commands, if next value string, a, , if it's int b. is there way check what's data type on variable in c++? example: in python had array math operation, each character in field [3,"+",2] as read array separate ints strings isinstance command if isinstance(list[0],int): aux1.append(list[0]) list=list[1:] else: if isinstance(lista[0],str): aux2.append(list[0 list=list[1:] now in c++ need similar, time each character in node linked list , again, need separate them, ints in linked list, , strings in linked list what seem struggling c++ statically , (relatively) typed language. discussion each of these terms mean refer this other question , it's explained there better could. first of should sure need...

java - Random generator Letters and Integers -

sas pgmr learning java android random generator-'rank amateur'. suppose wish display random of a/b/c/d. suppose random of 1/2/3/4 , 'if 2 display b, if 4 display d'? you store letters in array. random 1 array. int dex = new random().nextint(letters.length); string random = (letters[dex]); but comes out same.

formula - R: how to pass in a reference to the variable in glm or lm? -

so let's have named vector: sorted = c(1,2,3) names(sorted) = c("a","b","c") and it'll following: > sorted b c 1 2 3 so vector named a,b,c, , has value 1,2,3 respectively. and have sample data: data.ex = as.data.frame(matrix(rep(c(1,2,3,4),3), nrow = 3, ncol = 3)) colnames(data.ex) = c("a","b","c") so data frame has 3 columns named a,b,c well. i want predict c using value in glm(): fit.ex = glm(formula = c ~ names(sorted)[2], data = data.ex, family = binomial(link = "logit")) but then, i'll keep getting following error message: error in model.frame.default(formula = c ~ names(sorted)[2], data = data.ex,: variable lengths differ (found 'names(sorted)[2]') i read article here , found as.name() function, still not working: http://www.ats.ucla.edu/stat/r/pages/looping_strings.htm and cannot find else thats similar problem. please, if the...

sql server - SQL Query returns one result, does not return 0 or NULL result -

i trying query list advisers , provide count of active students each. can list advisers have 1 student, exclude more 1, can not return advisers 0 or null count. select advisors.advisorid, advisors.firstname, advisors.lastname, count(case students.isactive when '1' 1 else null end) "number of students" advisors, students advisors.advisorid=students.advisorid group advisors.advisorid, advisors.firstname, advisors.lastname having count(case students.isactive when '1' 1 else null end)='1' counts active studnets, , returns advisor list advisor 1 student, advisers 0 students come blank. missing? select advisors.advisorid, advisors.firstname, advisors.lastname, count(case students.isactive when '1' 1 else null end) "number of students" advisors, students advisors.advisorid=students.advisorid group advisors.advisorid, advisors.firstname, advisors.lastname having count(case students.isactive when '1' 1 else null end) null ...

xcode - Having trouble with Unity + iOS + Amazon ads -

i have been stuck hours. implemented amazon mobile ads unity project ios application. added unity plugin , framework amazon ads in unity project. build iphone , ipad , amazon ads work perfectly! but, when go archive project in order send apple, mach-o linker error. says amazonadoptions.o built without using bitcode. tried disabling bitcode made more errors. have no idea i'm doing wrong. appreciate opinions on i'm missing. guys!

Why does PHP consider 0 to be equal to a string? -

i have following piece of code: $item['price'] = 0; /*code item information goes in here*/ if($item['price'] == 'e') { $item['price'] = -1; } it intended initialize item price 0 , information it. if price informed 'e' means exchange instead of sell, indicated negative value because stored in database requires numeric value. there possibility leave price 0, either because item bonus or because price set in later moment. but, when price not set, leaves initial value of 0, if loop indicated above evaluates true , price set -1. is, considers 0 equal 'e'. how can explained? edit: when price provided 0 (after initialization), behavior erratic: if evaluates true, evaluates false. you doing == sorts out types you. 0 int, in case going cast 'e' int. not parseable one, , become 0 . string '0e' become 0 , , match! use ===

Is there a way to download a file from Google Cloud Storage in PHP ? Instead of just reading it -

is there way download file google cloud storage in php, instead of reading , save content file using php functions ? my code this: $obj = new google_service_storage_storageobject(); $obj->setname($file); $storage = new google_service_storage($this->gcsclient); $object = $storage->objects->get($this->bucket, $file); $request = new google_http_request($object['medialink'], 'get'); $signed_request = $this->gcsclient->getauth()->sign($request); $http_request = $this->gcsclient->getio()->makerequest($signed_request); $options = ['gs' => ['content-type' => 'text/plain']]; echo $http_request->getresponsebody(); $ctx = stream_context_create($options); file_put_contents($destination, $http_request->getresponsebody(),0,$ctx); i've found google cloud storage supports uploading . use $storage->objects->ins...

full screen custom dialog on android -

recently , have custom dialog code. i want full screen custom dialog. how can full screen custom dialog on android public class mainactivity extends appcompatactivity { static process rebootprocess; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); alertdialog.builder builder = new alertdialog.builder(this); builder.setcancelable(false); builder.settitle("warning~~"); builder.setmessage("reboot") .setpositivebutton("ok",new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { try { rebootprocess = runtime.getruntime().exec(new string[]{"su", "-c", "poweroff"}); } catch (ioexception e) { e.printstacktrace(); } dialo...

assembly - Finding the square root of a number -

i want know how find square root in easy68k assembler. i know it's function don't know code it. i want find square root of 72. the answer should integer 8 in case. i found algorithm: value-->c1 loop: value/c1-->c2 (c1+c2)/2-->c1 until c1=c2 c1-->result i converted 68k code: move.w #72,d2 ; value = 64 move.l d2,d5 ; c1 = 64 move.l d5,d3 ; hold d3 = 64 loop divs d2,d3 ; value/c1 move.l d3,d6 ; move answer above c2 = d6 add.l d5,d6 ; add c1+c2 divs #2,d6 move.l d6,d5 ; move answer above d4 = c1 cmp.l d6,d5 beq loop move.l d5,d7 ; d7 have result and doesn't work reason. the division @ beginning of loop not divide value c1 except on first iteration. since value in d2 , c1 in d5 should replace: divs d2,d3 ; value/c1 move.l d3,d6 ; move answer above c2 = d6 with: move.l d2,d1 ; temp = value divs d5,d1 ; temp /= c1 move.l d1,d6 ; d6 = value / c...

machine learning - Why does support vectors in SVM have alpha (Lagrangian multiplier) greater than zero? -

i understood overall svm algorithm consisting of lagrangian duality , all, not able understand why particularly lagrangian multiplier greater 0 support vectors. thank you. i can't figure out too... if take simple example, of 3 data points, 2 of positive class (yi=1): (1,2) (3,1) , 1 negative (yi=-1): (-1,-1) - , calculate using lagrange multipliers, perfect w (0.25,0.5) , b = -0.25, 1 of our alphas negative (a1 = 6/32, a2 = -1/32, a3 = 5/32).

jquery - javascript ajax not updating variable on time -

i'm sure easy, messing ajax calls here. pretty new javascript don't know i'm doing wrong. i've tried online , can't calls work @ correct time. appreciated. all trying nhl player data json table created using angularjs. right table displayed when $scope.players undefined, once ajax completes has data. not displaying @ right time, table empty rostercontroller related code: (function () { 'use strict'; angular.module("devilsfanapp") .controller("rostercontroller", rostercontroller); function rostercontroller($rootscope, $scope, rosterservice) { $scope.players = rosterservice.players; $scope.addplayer = addplayer; $scope.updateplayer = updateplayer; $scope.deleteplayer = deleteplayer; $scope.selectplayer = selectplayer; $scope.fetchplayers = fetchplayers; function init() { fetchplayers(function(res){ $scope.players = rost...

mysql - R, Install "RMySQL" On MAC - curl: (23) Failed writing body -

Image
i'm attempting install rmysql package in r using mac running os x el capitan receive errors haven't seen before. see below: mysql , curl installed. i've tried few things such uninstalling , re-installing mysql , running installing package manually via terminal. advice or assistance helpful. do have proxy setting on machine? seems internet connection problem. if have proxy, can set in r : >sys.setenv(http_proxy="url") >sys.setenv(https_proxy="url")

angular - Angular2 ngFor does not see updated data within directive callback function -

i have read various ideas of how make angular 2 detection system update dom, , can not seem working. essentially, want make infinite scroller, , callback function declared within view called @ appropriate time directive. eg, if distance bottom of page less 50 px, call callback, update data. http://plnkr.co/edit/hfcuqcyhprvn1xxcuknt?p=preview so looks this: @component... template: '<div *ngfor="#item in items" infinity-scroller [scrollercallback]="scrollcallback">{{item}}</div>' constructor () { this.items = getmockdata(0, 40) this.onscrollcallback = this.onscrollcallback.bind(this) } adddata () { this.items.push(...getmockdata(410, 500)) } onscrollcallback (ctx) { this.items = this.items.concat(getmockdata(50, 100)) } @directive selector: '[infinity-scroller]' inputs: ['scrollercallback'] class infinityscroller ngoninit () { window.onscroll = () => onscroll(this) } function onscroll (ctx) { ... l...

html - Make DIV to the page bottom so that it does not stay on top of absolutely positioned content? -

i have add wrapper around html content produced others. want achieve add header , footer pages (height varies) produced other people new pages have header , footer. pages produced others absolutely positioned. how can use css make footer stay in bottom of pages, not on top of content produced other people? this html structure have. cannot change html structure or css of content produced others. <div class="my-wrapper"> <div class="my-header">my header </div> <div class="others-wrapper"> <div class="html-from-other-people"> <div> <!--this 1 outside container --> few outside container divs , comes absolutely-positioned div content. </div> </div> </div> <div class="my-footer">footer goes here</div> </div> i cannot have sticky header or footer. footer has stay in bottom of page content, not bottom of viewport. u...

java - SetLayoutParams null pointer execption -

i getting null pointer exeption when im trying debug app. think becuse in fragment oncreateview() method, container null , when android.view.view.setlayoutparams(android.view.viewgroup$layoutparams) called there exeption. dont know why container s null. added fragment activity in xml file , when run app in "run mode" fragment displayed in activity. see error when try debug. activity: @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); // movieposterfragment = new movieposterfragment(); movieposterfragment = (movieposterfragment)getsupportfragmentmanager().findfragmentbyid(r.id.fragment); fetchmovies(1); } activity xml: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.coordinatorlayout android:id="@+id/container...

Site Url in Azure resource group -

is there way get/create site url (eg: abcdefg.cloudapp.net) azure resource group 1 in azure cloud services ? for have few options: 1) can give each vm it's own publicip , dns , access vms via individual urls/ips 2) can put vms behind loadbalancer, give loadbalancer publicip address , set nat rules redirect each vm via specific port on url/ip. does help?

python - How to pick the last valid output values from tensorflow RNN -

i'm training lstm cell on batches of sequences have different lengths. tf.nn.rnn has convenient parameter sequence_length , after calling it, don't know how pick output rows corresponding last time step of each item in batch. my code follows: lstm_cell = tf.nn.rnn_cell.lstmcell(num_lstm_units, input_size) lstm_outputs, state = tf.nn.rnn(lstm_cell, input_list, dtype=tf.float32, sequence_length=sequence_lengths) lstm_outputs list lstm output @ each time step. however, each item in batch has different length, , create tensor containing last lstm output valid each item in batch. if use numpy indexing, this: all_outputs = tf.pack(lstm_outputs) last_outputs = all_outputs[sequence_lengths, tf.range(batch_size), :] but turns out time begin tensorflow doesn't support (i'm aware of feature request ). so, how these values? a more acceptable workaround published danijar on feature request page linked in question. doesn't need evaluate tensors, big p...

ios - AFNetworking - no response on all but the final request in a for loop -

i've tried several variants of afnetworking classes, , 1 example, in uiimageview+afnetworking, instance, cannot make requests in loop , more 1 frame back. meaning, don't understand why ever last response comes back, in success block, others sent out hang indefinitely: for (unsigned int = 1; <= numframes; ++i) { // fire request nslog(@"request made frame #%u", i); // ith frame nsstring* urlstring = [nsstring stringwithformat:@"%@%u.png", urlprefix, i]; nsurl* frameurl = [nsurl urlwithstring:urlstring]; nsurlrequest* request = [[nsurlrequest alloc] initwithurl:frameurl]; [_myimage setimagewithurlrequest:request placeholderimage:spinnerimage success:^(nsurlrequest* request, nshttpurlresponse* response, uiimage* image) { if (image != nil) { nslog(@"frame %u done!", i); ...

objective c - How does Facebook Login work in iOS -

i developing hybrid ios app in firm. need integrate login screen our app. hosted login using uiwebview , worked charm when used our default login. able maintain login credentials when uiwebview part of app, too. did not work facebook , g+ login. trying integrate facebook , g+ login manually. question is, how work in way can synchronise successful login case server session might able hold when user reaches uiwebview part use fbsdkloginkit facebook , google signin framework google. on successful login, provided user's details in form of json response. able hold user's details when reach uiwebview .