Posts

scheme - laziness in action? (Haskell) -

in chapter 6 of learn haskell , following function introduced: zipwith' :: (a -> b -> c) -> [a] -> [b] -> [c] zipwith' _ [] _ = [] zipwith' _ _ [] = [] zipwith' f (x:xs) (y:ys) = f x y : zipwith' f xs ys the author gives couple examples of use found easy enough follow. one: ghci> zipwith' (zipwith' (*)) [[1,2,3],[3,5,6],[2,3,4]] [[3,2,2],[3,4,5],[5,4,3]] which outputs [[3,4,6],[9,20,30],[10,12,12]] is example of lazy evaluation? tried translate zipwith' scheme (see below). got working "easy" examples, not last one, makes me think haskell's laziness might making difference. (define zipwith (lambda (f lista listb) (cond ((null? lista) (quote ())) ((null? listb) (quote ())) (else (cons (f (car lista) (car listb)) (zipwith f (cdr lista) (cdr listb))))))) no, although example evaluated lazily (like other function in haskell), behaviour doesn't depend on that. on finite lists ...

c# - log4net fallback appender configuration in case of missing config file? -

i've got c# (.net 3.5) application extensively use log4net. log4net configuration resides in app.config file. configuration done using [assembly: xmlconfigurator(watch = true)] in assemlyinfo.cs app uses single application-wide logger instance, instantiated in static constructor of logger wrapper class: public class logger{ //.... private static readonly ilog logger; static logger() { logger = logmanager.getlogger(assembly.getentryassembly().getname().name); appdomain.currentdomain.unhandledexception += onunhandledexception; } //.... } the app designed run on distant server, scheduler, no human presense, alone in dark. :) problem is, in case of missing config file silently crashes (no log4net config => no logging). are there way check if there appenders in config, , if not - programmatically add kind of fallback appender. i'm rather new log4x loggers family, so, if i'm asking trivial - please kind, log4net documen...

asp.net RegularExpressionValidator not working in mulitline textbox -

i using regularexpressionvalidator stop user using apostrophe (symbol '). working fine in single line textbox. shows error message when user uses enter key new line. validationexpression using is:validationexpression="^(?:(?!['].))*$" and code:   errormessage="you not allowed use apostorphene" controltovalidate="tbdrivinglicenseother" validationexpression="^(?:(?!['].))*$"> can not find solution anywhere on web. can help? it isn't clear me, trying prevent along apostrophs current regex... following expression: validationexpression="^[^']*$" prevents input of apostrophes in both textbox , multi-line textbox.

c# - Create a password encrypted and store it in sqlite to use in authentication -

i have winforms application, login form, , want store username , password encrypted in sqlite database. saw can use salt , hash, don't know how encrypt password in code, , compare when authenticate. any please? you need take username , password (the password masked text box, preferably second box confirmation) salt it, , create hash password, , insert plaintext username , salted hash of password in database. can verify users password in future comparing database stored version salted (same salt!) hash of user enters. note each user should have own salt randomly generate user when create account. (this more secure global salt value hacker discover). take @ this article . pretty covers bases, don't use sha-1 recommended in article. want slow hash function computationally expensive such bcrypt, or pbkdf2 (which included in .net). see "what makes hash function passwords" . (thanks @codeinchaos pointing out). you can use rfc2898derivebytes in system....

z3 - Efficiency of constraint strengthening in SMT solvers -

one way solve optimisation problems use smt solver ask whether (bad) solution exists, progressively add tighter cost constraints until proposition no longer satisfiable. approach discussed in, example, http://www.lsi.upc.edu/~oliveras/espai/papers/sat06.pdf , http://isi.uni-bremen.de/agra/doc/konf/08_isvlsi_optprob.pdf . is approach efficient , though? i.e. solver re-use information previous solutions when attempting solve additional constraints? the solver can reuse lemmas learned when trying solve previous queries. keep in mind in z3 whenever execute pop lemmas (created since corresponding push ) forgotten. so, accomplish must avoid push , pop commands , use "assumptions" if need retract assertions. in following question, describe how use "assumptions" in z3: soft/hard constraints in z3 regarding efficiency, approach not efficient 1 every problem domain. on other hand, can implemented on top of smt solvers. moreover, pseudo-boolean solvers ...

grails / log4j / conversion pattern / %throwable -

i use log4j 1.2.16 regarding "dependency-report". my conversion pattern '%d{yyyy-mm-dd hh:mm:ss,sss} %-5p %c: %m%n %throwable{short}' but %throwable not recognized, instead loglines contain '...hrowable{short}...' any idea ? i assume in appender? using enhancedpatternlayout (i believe need %throwable{n} ) console name: 'stdout', layout: new enhancedpatternlayout(conversionpattern: "%d{yyyy-mm-dd hh:mm:ss,sss} %-5p %c: %m%n %throwable{short}")

php - Parameter after url is not passed to called function when Parameter contains : or \ -

i passing keyword inputed user function search_result($input) in cakephp fron javascript www.example.com/search_result/input javascript input user gives error when input contains : no arguments found search_result . working fine other inputs. you want encode search term before passing php javascript (which assume means you're using ajax). you can using: encodeuricomponent : encodeuricomponent(term);