Posts

functional programming - Clojure - more idiomatic to return a closure, or partially apply the function? -

i'm using external library, , passing function write. this, example: (ext-func my-func) ... my-func needs given data computation. way see it, have 2 basic choices: 1) write my-func in such way accepts data, , returns function, have data bound via closure when external library calls it. example: (defn my-func [mydata] (fn [] (... access mydata via closure ... ))) (ext-func (my-func somedata)) 2) not return function my-func , bind data when pass ext-func : (defn my-func [mydata] (... evaluate, use mydata, etc.)) (ext-func (partial my-func somedata)) i suppose 1 use answered how intend use function otherwise. if i'm going using other places, may prefer not return function, example. but, other things being equal... ...which of these more idiomatic approach? partial sugar create anonymous function. check out it's source . so, they're equivalent. take pick. neither more idiomatic, matter of personal preference.

reactjs - react-css-modules with decorators not working -

trying decorator syntax working react css modules shown here. https://github.com/gajus/react-css-modules#decorator i've got react-css-modules working using function syntax, e.g. cssmodules(table, styles) but when using decorators, e.g. @cssmodules(styles) export default class extends react.component {} nothing seems instantiated , no errors thrown either. i've got babel-plugin-syntax-decorators loaded. what missing? thanks!!

angularjs - Trouble with Protractor and Angular 2 application with Angular sign in -

i've been having issues getting protractor e2e test work. application i'm testing angular 2 , sign in through separate angularjs site. i'm trying create test logging in, checking site loads correctly given credentials, , logging out. can log in fine, navigate site, , navigate auth page. however, once gets there, protractor stops before clicks sign out button , webdriver stays stuck on page instead of closing. here page object code functions: `var loginpage = function() { this.loginemail = element(by.css('[id="email-input"]')); this.loginpassword = element(by.css('[ng-model="loginform.password"]')); this.signinbutton = element(by.css('[name="signin"]')); this.twofactorcodeinput = element(by.css('[id="code-input"]')); this.verifytwofactorbutton = element(by.css('[name="verifytwofactor"]')); this.signoutbutton = element(by.css('[ng-click="signout()"]...

google bigquery - Big Query InsertAll using C# -

i'm using code while trying insert data using big query. running without exceptions, table empty. problem code? string service_account_email = "myaccount"; var certificate = new x509certificate2(@"xxx.p12", "notasecret", x509keystorageflags.exportable); serviceaccountcredential credential = new serviceaccountcredential( new serviceaccountcredential.initializer(service_account_email) { scopes = new[] { bigqueryservice.scope.bigqueryinsertdata, bigqueryservice.scope.bigquery } }.fromcertificate(certificate)); // create service. var service = new bigqueryservice(new baseclientservice.initializer() { httpclientinitializer = credential, applicationname = "test" }); google.apis.bigquery.v2.data.tabledatainsertallrequest tabreq = new google.apis.bigquery.v2.data.tabledatainsertallrequest(); list<goo...

Rotating model in openGL 2 in iOS -

i'm working opengl on ios , android, i'm trying draw model, sphere, set camera/eye coords inside sphere, set texture , enable panning , zoom achieve 360 degree effect, made android using opengl 1.0, having lot of problems in ios, made using opengl 2.0, set , working, i'm having problem panning, in order rotate model view matrix, i'm applying rotate transformation, works if change axis rotation, messes other 2 axis, @ end if apply rotation in both axis, x , y, sphere rotates if kind of transformation has been don in z axis, texture ends upside-down or being displayed in diagonal, i'm doing exact same transformations in android , don't have problem there, has experience issue? suggestion? clue? code? article? think when apply first transformation coords in space change , next transformation not being applied properly. here's ios code : - (void)glkview:(glkview *)view drawinrect:(cgrect)rect { glclear(gl_color_buffer_bit); glkmatrixstackpush(_o...

python - unbound method must be called with instance as first argument -

i trying build simple fraction calculator in python2.x from fractions import fraction class thefraction: def __init__(self,a,b): self.a = self.b =b def add(self): return a+b def subtract(self,a,b): return a-b def divide(self,a,b): return a/b def multiply(self,a,b): return a/b if __name__=='__main__': try: = fraction(input('please type first fraction ')) b = fraction(input('please type second fraction ')) choice = int(input('please select 1 of these 1. add 2. subtract 3. divide 4. multiply ')) if choice ==1: print(thefraction.add(a,b)) elif choice==2: print(thefraction.subtract(a,b)) elif choice==3: print(thefraction.divide(a,b)) elif choice==4: print(thefraction.multiply(a,b)) except valueerror: print('value error!!!!!') i not sure made correct class c...

nosql - Storing MongoDB query in the database -

i have collection subscribers . i want segment of subscribers applying complex filters in query db.subscribers.find({ age: { $gt: 20 }, ...etc }) , don't want save result, since inefficient. instead, save filters applied in query set of rules in segments collection. is approach , efficient way that? should save query object document or define more restrictive schema before saving?