Skip to content

Instantly share code, notes, and snippets.

@tapichu
tapichu / polynomials.py
Created March 21, 2013 00:24
Calculate polynomials and their derivatives
from itertools import imap
def polynomial(coefs, x):
"""computes the value of a polynomial with
the given coefficients for a given value x"""
# For example, if coefs contains 3 values then exponents is [2 1 0]
exponents = reversed(range(len(coefs)))
return sum(map(lambda c,e: c * x**e, coefs, exponents))
def derivative(coefs, x):
@tapichu
tapichu / valgrind-make-output
Created June 30, 2012 20:10
Error building Valgrind
==> ./configure --prefix=/usr/local/Cellar/valgrind/3.7.0 --mandir=/usr/local/Cellar/valgrind/3.7.0/share/man --enable-only64bit --build=amd64-darwin
==> make
echo "# This is a generated file, composed of the following suppression rules:" > default.supp
echo "# " exp-sgcheck.supp xfree-3.supp xfree-4.supp darwin10-drd.supp darwin11.supp >> default.supp
cat exp-sgcheck.supp xfree-3.supp xfree-4.supp darwin10-drd.supp darwin11.supp >> default.supp
make all-recursive
Making all in include
make[2]: Nothing to be done for `all'.
Making all in VEX
make all-am
@tapichu
tapichu / fibo.clj
Created February 21, 2012 22:16
Fibonacci with Clojure
; Credit: Programming Clojure http://pragprog.com/book/shcloj/programming-clojure
; Fibonacci infinite sequence
(defn lazy-seq-fibo
([]
(concat [0 1] (lazy-seq-fibo 0N 1N)))
([a b]
(let [n (+ a b)]
(lazy-seq
(cons n (lazy-seq-fibo b n))))))
@tapichu
tapichu / polynomials.clj
Created December 16, 2011 23:20
Calculate polynomials and their derivatives
; Credit: http://java.ociweb.com/mark/clojure/article.html
(defn- polynomial
"computes the value of a polynomial
with the given coefficients for a given value x"
[coefs x]
; For example, if coefs contains 3 values then exponents is (2 1 0).
(let [exponents (reverse (range (count coefs)))]
; Multiply each coefficient by x raised to the corresponding exponent
; and sum those results.
@tapichu
tapichu / Questions
Created July 13, 2011 21:31
Magma Rails Give-away
Day Job: Software engineer / technical lead
Open Source contribution (if any): I've contributed to vimerl.
Tell me about your experience with Ruby/Rails: I use ruby and sinatra for side projects. I've contributed to MrT (command-line competion). I tend to do round-robin between ruby and python for scripting. I'm very often using ruby in my projects, even if it's not directly: git custom workflows, presentations (showoff), configuration management (puppet, vagrant), email client (vmail), etc.
How do you use GitHub: I use it all the time. I use it to follow projects I'm interested in or to find new projects. I put my side projects and presentations on github. And I also use it at work with private repositories (pull requests, code review, issues, etc.). I couldn't live without it.
Favorite luchador(es): Octagón and el Santo.
module.exports = function( exports, imports ) {
return imports( function
( run
, node$listen
, node$fs
, route
, html
, head
, sleep
public List getPromocionesSeleccionadas() {
List promociones = null;
List promoList = getPromociones();
if ( promoList != null && promoList.size() > 0 ) {
promociones = new ArrayList();
Iterator iter = promoList.iterator();
while (iter.hasNext()) {
Integer promoId = (Integer) iter.next();
String promocion = (String) promocionesDisponibles.get(promoId);
promociones.add(promocion);