Posts

python - Weird behavior on when replacing timezone using pytz timezones vs timezone strings -

i expect replacing tzinfo using 'us/central', give same result using timezone object ( pytz.timezone('us/central') ), apparently it's not: in [5]: import arrow in [6]: d = arrow.get() in [7]: cst = pytz.timezone('us/central') in [8]: d.replace(tzinfo=cst) out[8]: <arrow [2015-07-22t17:40:30.947579-06:00]> in [9]: d.replace(tzinfo='us/central') out[9]: <arrow [2015-07-22t17:40:30.947579-05:00]> note how output of line 8 has different utc offset output of line 9. which way correct way of replacing timezone using arrow , pytz? this seems bug. guessing seeing issue 154 - .to() incompatible pytz.timezone you may seeing same thing .replace() method. issue still open. i use arrow one, seems arrow , pytz not compatible.

caching - Spring JAAS Authentication with database authorization -

i using spring security 4.0. login module configured in application server have authentication using jaas user details stored in database, once authenticated user object created querying database. please let me know how achieve i.e. ldap authentication , load user details database. how cache user object using eh-cache, user object can accessed in service / dao layer. this can achieved using customauthentication provider. below codes. import java.util.arrays; import java.util.list; import org.springframework.security.authentication.authenticationprovider; import org.springframework.security.authentication.badcredentialsexception; import org.springframework.security.authentication.usernamepasswordauthenticationtoken; import org.springframework.security.authentication.dao.daoauthenticationprovider; import org.springframework.security.authentication.jaas.jaasgrantedauthority; import org.springframework.security.core.authentication; import org.springframework.security.core.a...

ios - Swift Delegate in own class -

i trying write first swift mac application. have hard times refactoring code class. current status: import cocoa class testclass: nsobject, nstextstoragedelegate { @iboutlet var codetextview: nstextview! var syntaxparser:trexsyntaxkitparser? var textstorage : nstextstorage! init(syntaxparser:trexsyntaxkitparser, textview:nstextview) { self.syntaxparser = syntaxparser super.init() if let textviewstorage = textview.textstorage { self.textstorage = textviewstorage self.textstorage.delegate = self } } func textstoragedidprocessediting(notification: nsnotification) { let inputstring = self.textstorage.string let wholerange = nsmakerange(0, count(inputstring)) self.textstorage.removeattribute(nsforegroundcolorattributename, range:wholerange) let attributes = self.syntaxparser!.parse(inputstring) print("attributes: \(attributes)") attribdict...

java - Android local unit test - new View(null) returns null -

i'm experimenting local android tests (the ones run on local jvm, not on device). understand classes in android.jar can't used unless mocked, reason when try instantiate new view (or own class inherited view)- null. totally breaks belief "new" never returns null in java. here's test code ( src/test/java/com/example/footest.java ): package com.example; import android.view.view; import org.junit.test; public class footest { @test public void testview() { view v = new view(null); system.out.println("view = " + v); } } this code prints in test report output view null. here's build.gradle (the rest of project generated android create project , of no interest): buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.3+' } } apply plugin: 'android' android { compilesdkversion 'android-22' buildtoolsversion...

c++builder - How can I find the number of elements of a multidimentional dynamic array -

my pointer declared in header file: int (*array)[10]; i pass argument function initializes array: void __fastcall tform1::initarray(const int cnt) { try { form1->array = new int[cnt][53]; } catch(bad_alloc xa) { application->messageboxa("memory allocation error sel. ", mb_ok); } form1->zeroarray(); } //--------------------------------------------------------------------------- i set element of array "0": void __fastcall tform1::zeroarray() { __int16 cnt = sizeof_array(array); // here notice problem. cnt not correct size of first level of array. if(cnt) { for(int n = 0; n < cnt; n++) { for(int x = 0; x < 53; x++) { form1->array[n][x] = 0; } } } } //--------------------------------------------------------------------------- this d...

c++ - SFINAE to enable cast operator only from derived to base class -

i have class template cfoo<t> . want allow implicit casts other instantiations of cfoo , template argument base class of t . i tried use sfinae, neither of attempts worked on compiler tried (vc 2012 or gcc): #include <type_traits> template <class t> class cfoo { public: template <class q> operator // typename std::enable_if<std::is_base_of<q, t>::value, cfoo<q>&>::type // should work? // typename std::enable_if<1, cfoo<q>&>::type // should work? cfoo<q>& // compiles, doesn't restrict on q want () const { return *(cfoo<q>*)this; } }; class {}; class b : public {}; int main(int argc, char* argv[]) { cfoo<b> b; cfoo<a>& = b; return 0; } why don't either of commented out attempts @ sfinae work here? in both cases error invalid initialization of a , if operator didn't called. according...

forms - Outputting to Convertto-html Cmdlet Powershell -

evening everyone, i've spent while having play on google learning how create basic form powershell. i'm having problem coming grips how basic form output html file @ click of button have managed work services ie - get-service | convertto-html | out-file "location" however i'm wanting input data on form , once submit button pressed, puts data table , outputs html file. add-type -assemblyname system.drawing add-type -assemblyname system.windows.forms $form = new-object system.windows.forms.form $form.text = "basicform" $form.width = 800 $form.autoscroll = $true #vrn label $objlabel = new-object system.windows.forms.label $objlabel.location = new-object system.drawing.size(50,75) $objlabel.text = "num:" $objlabel.autosize = $true $form.controls.add($objlabel) #vrn textbox $objtextbox = new-object system.windows.forms.textbox $objtextbox.location = new-object system.drawing.size(100,75) $objtextbox.size = new-object system.drawing...