Posts

ios - NSDateFormatter: error in converting date -

i have got following time stamp in milliseconds: nsdate * date = [nsdate datewithtimeintervalsince1970:1470524933.923123]; nsdate * date2 = [nsdate datewithtimeintervalsince1970:1470666561.000]; nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"yyyy-mm-dd 'at' hh:mm:ss"]; nsstring * dateinstring = [dateformatter stringfromdate:date]; when run following: 2016-08-07 @ 00:08:53 , 2016-08-08 @ 15:29:21 however first date should following according epoch time converter website using : your time zone: 8/7/2016, 12:08:53 gmt+1:00 dst it says 00 rather 12. why that? try set timezone of nsdateformatter gmt [dateformatter settimezone:[nstimezone timezonewithabbreviation:@"gmt"]]; as larme , vadian suggested if want 12 hour use format [dateformatter setdateformat:@"yyyy-mm-dd 'at' hh:mm:ss a"];

android - How to read a column value in parse.com without accessing an object or a pointer -

by using code, not able 'name' unless use objectid = xj34weo . suggest way, if not, @ least using pointer. //parse query initialization final parsequery<parseobject> query = parsequery.getquery("myusers"); //to check row has "number"="1234" query.whereequalto("number", "1234"); query.findinbackground(new findcallback<parseobject>() { public void done(list<parseobject> employees, parseexception e) { if (e == null) { try { //xj34we0 objectid query.get("xj34weo").get("name") + ""); } catch (parseexception pe) {} } } }); are trying employee object number? you have list<parseobject> , use it. query.findinbackground(new findcallback<parseobject>() { public void done(list<parseobject> employees, parseexception e) { if (e == null && employ...

serialization - Flink is not able to serialize scala classes / Task Not Serializable -

i have scala class having 2 fields vals flink saying doesn't have setters. task not serializable. i tried setters using var says duplicate setter. vals public why asking setters. flink version 1.1.0 class impression(val map: map[string, string],val keyset:set[string]) my code: val preaggregate = stream .filter(impression => { true }) .map(impression => { val xmap = impression.map val values = valfunction(xmap) new impressionrecord(impression, values._1, values._2, values._3) }) exceptions: **class impression not contain setter field map** 19:54:49.995 [main] info o.a.f.a.java.typeutils.typeextractor - class impression not valid pojo type 19:54:49.997 [main] debug o.a.flink.api.scala.closurecleaner$ - accessedfields: map(class -> set()) exception in thread "main" **org.apache.flink.api.common.invalidprogramexception: task not serializable at** org.apache.flink.api.scala.closurecleaner$.ensureserializable(closurecleaner.scala:172) @ ...

java - I cannot get the program to repeat output in an ordered manner -

i want design program scales strings. if string d = "abc\ndef\nghi",horizontal scalling=2,vertical scalling=2, scaleobj.scale(d,2,2)/ defined below / should output "aabbcc\naabbcc\nddeeff\nddeeff\ngghhii\ngghhii". //output aabbcc aabbcc ddeeff ddeeff gghhii gghhii ive have problem ive defined below: //mainsix.java public class mainsix{ public static void main(string[] args){ scale scaleobj = new scale(); system.out.println(scaleobj.scale("abc\ndef",2,3)); } } class scale { public static string scale(string strng, int k, int v) { //horizontal scalling -k string s=strng.replaceall(".", repeat("$0",k)); //verical scalling string y = repeat(s,v); return y; } public static string repeat(string str, int times){ return new string(new char[times]).replace("\0", str); } } when compile output aabbcc ddeeffaabbcc ddeeffaabbcc dd...

timer - Java TimerTask cancel -

i have following problem. every 2 seconds programm go inside if statement. inside if statement want have timer give me message after 15 seconds. timer should run delay of 1 second. while i'm "waiting" timer, if statement executed 7 times. problem is, have 7 same timertask @ same time running. how can solve problem? if (response == true) { final timer timer = new timer(); final int keepalivetimeout = 15000; //15 seconds timer.schedule(new timertask() { @override public void run() { if (response) { response = false; log.i(tag, "********response******"); timeoutcounter = 0; } else if (timeoutcounter > keepalivetimeout) { log.i(tag, "********timer timeout******"); } log.i(tag, "********timer******"); timeoutcounter = timeoutcounter + 1000; } }, 0, 1000); } from java api : public void schedule(timertask task, long delay, ...

Cannot perform a calling between two emulator in android studio 2.0 -

Image
i turned on 2 emulators port 5556 , 5554 different windows. pressed number 5556 , called. nothing happens. cannot call between 2 emulators in android studio 2.0. how can fix thank in addition, can use block function block virtual call? i don't know if calling between 2 emulators should work or not. can simulate phone call in way: select … in emulator panel. select "phone" in left panel of extended controls dialog. select or type phone number in field. click call device.

ios - Realm swift change primaryKey -

so have realm object class registrationplatedb: rlmobject { dynamic var registrationplate : string = "" dynamic var user : string = "" override static func primarykey() -> string? { return "registrationplate" } ... and change class registrationplatedb: object { dynamic var plateid : int = -1 dynamic var registrationplate : string = "" dynamic var name : string = "" dynamic var user : string = "" override static func primarykey() -> string? { return "plateid" } .... so i've written migration migration.enumerate(registrationplatedb.classname()) { oldobject, newobject in newobject!["name"] = "" newobject!["user"] = "" newobject!["registrationplate"] = "" newobject!["plateid"] = -1 newobject!["primarykeyproperty"] = ...

error when looping with macros in the indexing -

i trying create dummy variable identify next 5 observations after selection of cutoffs. first method in code below works, looks bit messy , i'd able adjust number of observations i'm creating dummies without typing out same expression 30 times (usually sign i'm doing hard way). every time put macro indexing, i.e. [_n-`i'] i following error: _= invalid name r(198); i'd grateful advice. sysuse auto.dta, replace global cutoffs 3299 4424 5104 5788 10371 this works sort price gen a=0 foreach x in $cutoffs { replace a=1 if price==`x' replace a=1 if price[_n-1]==`x' replace a=1 if price[_n-2]==`x' replace a=1 if price[_n-3]==`x' replace a=1 if price[_n-4]==`x' replace a=1 if price[_n-5]==`x' } this doesn't. foreach x in $cutoffs { forval `i' = 0/25 { replace a=1 if price[_n-`i']==`x' } } any advice why? in stata terms no loops needed here @ all, except ta...

objective c - How to install root certificate inside iOS app, so it will be trusted when open URL from UIWebView? -

i have ios app in need use uiwebview open web page uses ssl certificate not issued trusted authority. got error. i can manually install ssl certificate, need on every client device, not option, need install root certificate code. but don't know how that. google in cases importing provisioning certificates. any guidance? need direction search. i read there ssl pinning, understand authentication purposes. should stick or not? p.s. url accessed not on our web server, can not manage certificates. reason need trust in general in app. i think cannot install certificate inside app. can show guide tell user how open , install certificate in safari. , open certificate url in safari via codes.

android - extract String between last slash and question mark -

i want extract string between last slash , question mark using regex string path="http://keting.amazonaws.com/media123/mediaattachments/000/000/004/original/shoes_tvc_2013.mp4?1470248308" i need "shoes_tvc_2013.mp4" string. pattern pattern = pattern.compile("need here"); matcher matcher = pattern.matcher(url); if (matcher.find()) { system.out.println(matcher.group(1)); //prints region/country } else { system.out.println("match not found"); } .*\/(.*)\? should trick. see here more.

python - Extract subarray from collection of 2D coordinates? -

in python, have large 2d array containing data, , mx2 2d array containing collection of m 2d coordinates of interest, e.g. coords=[[150, 123], [151, 123], [152, 124], [153, 125]] i extract mx1 array containing values of data array @ these coordinates (indices) locations. obviously, data[coords] not work. i suspect there easy way that, stackoverflow failed me now. in advance help. edit: example be data=[[0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 2, 1, 0, 0], [0, 0, 0, 1, 23, 40, 0, 0], [0, 0, 0, 1, 1, 2, 0, 0], [0, 0, 3, 2, 0, 0, 0, 0], [0, 0, 4, 5, 6, 2, 1, 0], [0, 0, 0, 0, 1, 20, 0, 0], [0, 0, 0, 3, 1, 2, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]] coords=[[1,4],[2,4],[2,5],[5,3],[6,5]] and desired output be out=[2,23,40,5,20] you use list comprehension : in [73]: [data[i][j] i,j in coords] out[73]: [2, 23, 40, 5, 20] the result returned list comprehension equivalent to result = [] i,j in coords: result.append(dat...

php - How scalable is this file-based DB approach? -

i have simple php script calculates things given string input. caches results database , delete entries older number of days. our programmers implemented database as: function cachedcalculatething($input) { $cachefile = 'cache/' . sha1($input) . '.dat'; if (file_exists($cachefile) { return json_decode(file_get_contents($cachefile)); } $retval = ... file_put_contents(json_encode($retval)); } function cleancache() { $stale = time() - 7*24*3600; foreach (new directoryiterator('cache/') $fileinfo) { if ($fileinfo->isfile() && $fileinfo->getctime() < $stale) { unlink($fileinfo->getrealpath()); } } we use ubuntu lamp , ext3. @ number of entries cache lookup become non-constant or violate hard limit? while particular code not "scalable"* @ all, there number of things can improve it: sha1 takes string. non-string $input variable have serialized or json_encoded first, before calculating ...

powerbi - Power Bi does not connect with MySQL Database -

Image
i trying connect powerbi desktop form mysql database on localhost. when enter credential , try connect following popup box. i don't know should error log in powerbi seems encountered same problem did. first result in google: http://community.powerbi.com/t5/service/power-bi-desktop-error-when-connecting-to-local-mysql/td-p/2724

html - boostrap menu active page dont show style -

so want active page use same settings hover settings. no matter how change css cant work... long time since i've worked on page tho might missing easy shit... style.css before changes .navbar-default .navbar-brand { color: #fff; border-left:solid; border-right:solid; border-top:none; border-bottom:none; border-color:#202020; border-width:0.1pt; } .navbar-default .navbar-brand:hover, .navbar-default .navbar-brand:focus { color: #fff; border-left:solid; border-right:solid; border-top:none; border-bottom:none; border-color:#707070; border-width:0.1pt; background: -webkit-linear-gradient(top, rgba(112, 112, 112, 1) 0%, rgba(0, 0, 0, 1) 100%); background: linear-gradient(to bottom, rgba(112, 112, 112, 1) 0%, #404040 20%); } .navbar-default { font-size: 14px; background-color: rgba(0, 0, 0, 1); background: -webkit-linear-gradient(top, rgba(112, 112, 112, 1) 0%, rgba(0, 0, 0, 1) 100%); backgr...

swift - Xcode 7 - Launch Screen localization doesn't work -

Image
i've created splash screen in swift using xcode 7 . i've generated localizations in photo different languages, doesn't work: can help? ok fix after create infoplist.strings , create splash screen each language , add below in each file "uilaunchstoryboardname" = "launchscreen"; "uilaunchstoryboardname" = "launchscreensp";

visual studio 2015 - Error with TFS Build -

Image
i'm new tfs , i'm trying setup automated build run each time there check in. added nuget installer , visual studio build steps looks neither step being executed. tried disabling steps attempt run build nothing still same error bin.rar file. simple mvc project should work default settings. i've looked everywhere , have not found similar error. i have tried removing build steps , queued new build got same error. there no reference bin.rar in sln, csproj, or config files. error on tfs build error in log the problem clear bro, authentication problem . make sure have required permissions before making build. going to build definition -> right hand click-> security-> build administrators -> administer build permissions inherited allow.

c++ - Cast for upcasting only -

we know c-style casts considered evil in c++. why replaced const_cast<> , static_cast<> , , dynamic_cast<> provide more bespoke casting, allowing programmer allow intended classes of conversions. far, good. however, there seems no builtin syntax perform explicit upcast: means perform otherwise implicit conversion in base& baseref = derived explicitly without allowing reverse . while know quite small corner case (most of time implicit conversions work fine), wondering techniques available implement such cast in user code. thinking along lines of template<class t> class upcast { public: template<class u, typename = typename std::enable_if<std::is_convertible<u, t>::value>::type> upcast(u value) : value(value) {} operator t() { return value; } private: t value; }; however, seems complicated good, , since i'm not expert in template-metaprogramming, ask whether there different/better/simp...

jquery - javascript ajax request in rails not able to pass values -

i have rails application in have following controller action. def index .... .... @currency = params["currency"].present? ? params["currency"] : "inr" @check_in_date = params["arrival_date"].present? ? params["arrival_date"] : date.today.to_s @check_out_date = params["departure_date"].present? ? params["departure_date"] : (date.today + 1).to_s .... .... end i have javascript trying make ajax request this. filename.html.haml else{ hotel_id = id.slice(6) $.ajax({ url: "/single_hotel/"+hotel_id, data: {check_in_date: #{@check_in_date}, check_out_date: #{@check_out_date}, longitude: #{@longitude}, latitude: #{@latitude}, rooms: #{@rooms}, adults: #{@adults}, children: #{@children}, currency: #{@currency} }, type: 'get' }); } when check sources tab in chrome console see this. $.ajax({ ...

angularjs - Mocking Components with Angular 2 -

i trying mock heroes-component of 'tour of heroes' angular 2 tutorial . don't know how mock router, needed instantiating heroescomponent. tried create spy jasmine, doesn't work, because missing property 'rootcomponenttype'. how can make work? import {heroescomponent} "./heroes.component"; import {router} "@angular/router-deprecated"; import {heroservice} "./hero.service"; describe('heroescomponent', () => { let heroes:heroescomponent; let router:router; let service:heroservice; beforeeach(() => { router = jasmine.createspyobj('router', ['navigate']); service = new heroservice(/* care later */); heroes = new heroescomponent(router, service); }); it('should defined', () => { expect(heroes).tobedefined(); }); }); it working now: describe('heroescomponent', () => { let router:any; let heroescomponent:hero...

vb.net - concatenate Combobox items from Oracle DB -

i want display 2 table values oracle db in combobox (name , surname). far can display one, , 1 doesn't work criteria. using conn oracleconnection = new oracleconnection("data source=mydb;user id=lucky;password=mypassword;") try conn.open() dim sql string niz = "select name,surname mytable id=1 " dim cmd new oraclecommand(sql, conn) cmd.commandtype = commandtype.text dim dr oracledatareader = cmd.executereader() while (dr.read()) cmbcustomers.items.add(dr.getstring(0)) end while conn.close() catch ex exception messagebox.show(ex.message) conn.dispose() end try anybody knows how display name , surname in combobox, clause ? try using string concatenation way select name ||' ' || surname m...