Skip to content

Instantly share code, notes, and snippets.

View rafaelmv's full-sized avatar
🏠
Working from home

Rafa Miranda rafaelmv

🏠
Working from home
View GitHub Profile
def factorial(num):
return (1 if num == 0 else num * factorial(num - 1))
public class Mamifero {
private int patas;
private String nombre;
public void imprimirPatas() {
System.out.println(nombre + ” tiene ” + patas + ” patas\n”);
}
public Mamifero(String nombre, int patas) {
this.nombre = nombre;
var menu = document.getElementsByClassName("your-elements");
for(var i = 0; i < menu.length; i++){
if(menu[i].getAttribute("href") == window.location.pathname){
menu[i].id = "devf-selected-menu"
}
}
@rafaelmv
rafaelmv / Movies.md
Last active January 8, 2016 20:17
A movies wishlist
  • The Hitchhiker's Guide to the Galaxy (2005), dir. Garth Jennings
  • End of Watch (2012), dir. David Ayer
  • October Sky (1999), dir. Joe Johnston
  • The Runaways (2010), dir. Floria Sigismondi
  • Apt Pupil (1998), dir. Bryan Singer
  • Girl with a Pearl Earring (2003), dir. Peter Webber
  • Pierrot le Fou (1965), dir. Jean-Luc Godard
  • Brokeback Mountain (2005), dir. Ang Lee
  • Badlands (1973), dir. Terrence Malick
  • Into the Wild (2007), dir. Sean Penn
@rafaelmv
rafaelmv / nginx.conf
Created October 9, 2015 02:15
Nginx config for a simple server
server {
listen 80;
server_name subdomain1.domain.com;
location / {
proxy_pass http://localhost:{YOUR_PORT};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
@rafaelmv
rafaelmv / elixir.md
Last active November 22, 2015 03:21
Elixir notes

Elixir

Funciones -> Funciones Misma entrada, misma salida Efecto Vegas: Lo que pasa en la función se queda en la función.

Extensiones

  • .exs -> Script como buena práctica siempre finaliza con s
  • .ex -> Compilar

Python Super Powers

Argument Unpacking

In Python we can unpack a list or a dictionary as function arguments using * and **.

def print_numbers(x, y):
	print x
	print y
@rafaelmv
rafaelmv / born.py
Last active September 20, 2016 19:35
from datetime import date
year = int(input("Anio de nacimiento: "))
month = int(input("Mes de nacimiento: "))
day = int(input("Dia de nacimiento: "))
def born(year, month, day):
today = date.today()
return today.year - year - ((today.month, today.day) < (month, day))
from __future__ import print_function, division
import sys
def contfrac_to_frac(seq):
''' Convert the simple continued fraction in `seq`
into a fraction, num / den
'''
num, den = 1, 0
for u in reversed(seq):
num, den = den + num*u, num