Posts

database - ISOdate/POSIXct vs Milliseconds -

this more of thinking question. have been working around different time/date formats, , noticed seems preferred store date/time objects variables unique classes (like isodate or posixct) in databases (like mongo, mysql, postegen). i why 1 want convert such format when analyzing data, wondering what's advantage when store in format in data-base? do these formats tend take less space conventional numbers? can't seem find answer online. for arguments sake let's talk simple date type (just date, no time or time zone) - such date type in mysql. say stored string of 2014-12-31 . what's 1 day later? human, it's easy come answer 2015-01-01 , computer needs have algorithms programmed in. while these types might expose apis have algorithms dealing calendar math, under hood store information whole number of days since starting date (which called "epoch"). 2014-12-31 stored 16701 . computer can efficiently add 1 16702 next day. this make...

spring security - Authenticate using SAML-based Basic Authentication? -

i have use case web application needs let users authenticate in 2 different ways using same user data store (aka idp) via saml. user's browser redirected idp , redirected saml assertion (aka websso profile). user makes request sp providing credentials via basic authentication. sp need send user's credentials idp , idp provide assertion through channel (server server). i'm using spring security saml extension. sample application in spring saml contains both basic authentication username , password , saml-based authentication basic auth portion uses local accounts defined in securitycontext.xml file. need use user accounts on idp. possible? if so, how configure spring saml? there no standard saml websso mechanism allow sp request assertion specific user providing credentials. might want ws-trust standard covers such use-cases using request security token methods (rst/rstr calls). quite standardized way client credentials grant of oauth 2.0 . both out of s...

dialog - AlertDialog for getting password android -

i'm programming in java using android studio. want get password user using alertdialog , show using alertdialog . problem without prompt entering password see second dialog. in other words message "your pass null" . wrong in codes? i run dialog codes in button onclick event: string s = messagebox.showpasswordbox(this, "", "enter password" , "ok" , "cancel"); messagebox.show(this, "showing pass", "your pass " + s , "ok" , "cancel"); where show , showpasswordbox codes are: public static messageboxresult show(context context, string title, string message, string positivemessage, string negativemessage) { result = messageboxresult.closed; alertdialog.builder builder = new alertdialog.builder(context); builder.settitle(title); builder.setmessage(message); builder.setpositivebutton(positivemessage, new dialoginterface.onclicklistener() { public void o...

algorithm - Scala - sort based on Future result predicate -

i have array of objects want sort, predicate sorting asynchronous. scala have either standard or 3rd party library function sorting based on predicate type signature of (t, t) -> future[bool] rather (t, t) -> bool ? alternatively, there other way structure code? i've considered finding 2-pair permutations of list elements, running predicate on each pair , storing result in map((t, t), bool) or structure effect, , sorting on - suspect have many more comparisons executed naive sorting algorithm would. if predicate async may prefer async result , avoid blocking threads using await if want sort list[(t,t)] according future boolean predicate, easiest sort list[(t,t,boolean)] so given have list[(t,t)] , predicate (t, t) -> future[bool] , how can list[(t,t,boolean)] ? or rather future[list[(t,t,boolean)]] want keep async behavior. val list: list[(t,t)] = ... val predicate = ... val listoffutures: list[future[(t,t,boolean]] = list.map { tuple2 => pr...

ruby - How to solve in `basename': no implicit conversion of Array into String -

i filename viddlrb without extension. if i'm running get_names method youtube url i'm getting array. i'm doing that: file = viddlrb.get_names(url) file.first file.to_s puts file filename = file.basename(file, '.*') but if i'm running i'm getting: in `basename': no implicit conversion of array string maybe knows why breaks? thought file.to_s job. when call file.to_s , it's returning result of string conversion, it's not modifying file variable. same call .first . consider example: file = ["filename.txt"] file.first file.to_s => "[\"filename.txt\"]" puts file => ["filename.txt"] the easiest way solve call first , to_s within basename argument. so: filename = file.basename(file.first.to_s, '.*') you alternately make variable before passing in.

polymer - Using the custom element body for data -

i looking implementing custom datagrid want data provided inline contents of custom element: <x-datagrid> <row> <col>value 1</col><col>value 2</col> </row> </x-datagrid> you can achieve menu , tab elements populate based on this...how done though? have looked @ component source core-dropdown-menu: https://github.com/polymer/core-dropdown-menu/blob/master/core-dropdown-menu.html doesn't tell me much...where else look? i able polymer.dom(this) in ready function. an example, loads data child <option> elements component's data property: ready: function() { var self = this; // since "this" gets lost in foreach polymer.dom(this).queryselectorall('option').foreach(function(opt) { self.push('data', {id: opt.value, text: opt.textcontent}); }); }, where component looks like: <my-component> <option value="1">option 1</option> ...

sqlite android extract contacts with phone number -

i'm facing sqlite issue in i'm trying extract contacts have phone number/s following query: cursor cursor = context.getcontentresolver(). query(contactscontract.commondatakinds.phone.content_uri, new string[]{ contactscontract.commondatakinds.phone.contact_id, contactscontract.commondatakinds.phone.number, contactscontract.contacts.display_name, contactscontract.contacts.photo_uri }, contactscontract.contacts.has_phone_number + ">?", new string [] {"0"}, contactscontract.commondatakinds.phone.display_name + " asc" ); the problem in case contact has more 1 phone number result in form: id: 451, name: maria, photouri: null, has_phone_number: 1, phone_number: 0700 000 000 id: 451, name: maria, photouri: null, has_phone_number: 1, phone_number: 0800 000 000 id: 451, name: maria, photouri: null, has_phone_number...