Skip to content

Instantly share code, notes, and snippets.

View llazzaro's full-sized avatar
👨‍🚒
Fighting fire with fire 🔥

Leonardo Lazzaro llazzaro

👨‍🚒
Fighting fire with fire 🔥
View GitHub Profile
@llazzaro
llazzaro / shell.py
Last active August 29, 2015 14:03 — forked from samv/shell.py
"""
The SQLAlchemy Shell.
This is just a wrapper for code.InteractiveConsole with some useful
defaults for using SQLAlchemy
"""
import sys
from IPython import embed
root@OpenWrt:~# cat /etc/config/network
config 'interface' 'loopback'
option 'ifname' 'lo'
option 'proto' 'static'
option 'ipaddr' '127.0.0.1'
option 'netmask' '255.0.0.0'
config 'interface' 'lan'
option 'ifname' 'eth0.1'
option 'type' 'bridge'
#!/bin/bash
NAME="hello_app" # Name of the application
DJANGODIR=/webapps/hello_django/hello # Django project directory
SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket
USER=hello # the user to run as
GROUP=webapps # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use
DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name
@llazzaro
llazzaro / ejercicio_b.hs
Created July 19, 2014 23:29
Ejercicio de Parcial Haskell
encontrarMinimo :: Perm a -> a -> Integer
encontrarMinimo permutacion x0 = foldr (\x rec -> if ((aplicarNVeces permutacion x0 x)== x0) then rec else rec + 1) 0 [0..]
ciclo :: Eq a => Perm a -> a -> a -> [a]
ciclo p inicial = [aplicarNVeces p inicial x| x <- [0..(encontrarMinimo p inicial)]]
aplicarNVeces :: Perm a -> a -> Int -> a
aplicarNVeces p x0 x = foldr (\x rec -> (p rec)) x0 [0..x]

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

#!/bin/bash
set -o errexit
# ---------------UPDATE ME-------------------------------#
# Increment me any time the environment should be rebuilt.
# This includes dependncy changes, directory renames, etc.
# Simple integer secuence: 1, 2, 3...
environment_version=39
#--------------------------------------------------------#
@llazzaro
llazzaro / build_cgminer_openwrt.sh
Created August 14, 2014 00:35
Script for cross-compile cgminer for OpenWRT
#!/bin/bash
A_OPENWRT_DIR=/home/pepe/openwrt_buildroot/openwrt
A_TARGET=mips_34kc
# export STAGING_DIR="${A_OPENWRT_DIR}/staging_dir"
export TOOLCHAIN_PATH=${A_OPENWRT_DIR}/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2
export PATH=$PATH:$TOOLCHAIN_PATH/bin/:${A_OPENWRT_DIR}/staging_dir/host/bin
export AR=$TOOLCHAIN_PATH/bin/mips-openwrt-linux-uclibc-ar
export AS=$TOOLCHAIN_PATH/bin/mips-openwrt-linux-uclibc-as
/*
gulpfile from one of my React applications which has a gulp --production build
set up.
Assumptions:
1. All your own .js/.jsx modules are somewhere under ./src, have unique
filenames and use Node.js-style requires WITHOUT any path information, just
the name of another module somewhere under ./src
@llazzaro
llazzaro / setup_logging.py
Created October 6, 2014 01:16
python logger initialize code
import logging
def init_logging():
logger = logging.getLogger('logger_name')
logger.setLevel(logging.INFO)
# create file handler which logs even debug messages
fh = logging.FileHandler('logger_name.log')
fh.setLevel(logging.INFO)
# create console handler with a higher log level
ch = logging.StreamHandler()
@llazzaro
llazzaro / mywallet.py
Last active August 29, 2015 14:08 — forked from fcicq/mywallet.py
#!/usr/bin/env python
import base64, hashlib, hmac, json, sys, getpass
from Crypto.Cipher import AES
from Crypto.Hash import RIPEMD, SHA256
base58_chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
def prompt(p):
return getpass.getpass(p + ": ")