Skip to content

Instantly share code, notes, and snippets.

@pedrojimenezp
pedrojimenezp / ppt.py
Created May 28, 2012 04:20
Sencillo juego en consola de piedra, papel o tijeras...
#Juego para aprender un poco sobre python orientado a objetos por @pedrojimenezp
#Clase que tiene los atributos y metodos de un jugador, en este caso solo tiene el nombre y los puntos
class Jugador():
#cada atributo que inicie por dos guiones bajos (__) es un atributo privado de la clase...
#lo mismo se aplica para los metodos
# metodo contructor que recibe dos parametros el nombre y los puntos del jugador...
def __init__(self, n="",p=0):
# __nombre y __puntos son atributos privados de la clase Jugador
@pedrojimenezp
pedrojimenezp / auto_compile.sh
Created November 27, 2012 14:05
Script para autocompilar archivos .less inmediatamente cuando estos has sido modificados
#!/bin/bash
#Este script permanece observando los archivos de un directorio y si alguno cambia re-compila los archivos .less
#Recibe 3 parámetros
# 1. El directorio donde están los archivos .less que se desean observar
# 2. El directorio donde se guardara el nuevo archivo .css compilado
# 3. El nombre del archivo .less que se quiere compilar
#este script por ahora solo compila un archivo pasado como parámetro, pero lo compila cuando cualquiera de los ficheros de un directorio sean modificados
@pedrojimenezp
pedrojimenezp / interpolacion_newton.py
Created January 31, 2013 14:35
Metodo de interpolacion de newton hecho en python
print "------- Interpolacion Polinomica (Newton) -------"
n = int(raw_input("Ingrese el grado del polinomio a evaluar: "))+1
# print "El grado del polinomio es: ", n
matriz = [0.0] * n
for i in range(n):
matriz[i] = [0.0] * n
vector = [0.0] * n
@pedrojimenezp
pedrojimenezp / havel-hakimi.py
Created March 7, 2014 04:11
Este codigo verifica si una sucesion de grados es una sucesion grafica mediante el algoritmo de Havel-Hakimi
"""
This function counts how many pairs degrees have the succcession list
"""
def numbers_pairs_degrees(succession_list):
n = 0
for degree in succession_list:
if degree % 2 != 0:
n += 1
return n
@pedrojimenezp
pedrojimenezp / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@pedrojimenezp
pedrojimenezp / javascript_resources.md
Last active August 29, 2015 14:06 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@pedrojimenezp
pedrojimenezp / python_resources.md
Last active August 29, 2015 14:06 — forked from jookyboi/python_resources.md
Python-related modules and guides.

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides

@pedrojimenezp
pedrojimenezp / css_resources.md
Last active August 29, 2015 14:06 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@pedrojimenezp
pedrojimenezp / flatten.js
Last active November 9, 2016 01:39
Function that takes an array of arbitrarily nested arrays and returns a flat array
// this function takes an array and return a flattened array
function flatten(array) {
// Iterates over the given array to return just one flatten array
return array.reduce((newArray, item) => {
// Check if the item to add is an array itself to call the function again to make the item a flatten array
if (item.constructor === Array) return newArray.concat(flatten(item));
// If is not an array just adds the item to the new array
return newArray.concat(item);
}, []);
}
@pedrojimenezp
pedrojimenezp / combine.js
Last active January 23, 2017 19:24
Function that combine many arrays into one array
function combine(mapFunc) {
return function() {
const args = Array.prototype.slice.call(arguments);
const lengths = args.map(arg => arg.length)
const minLength = Math.min.apply(this, lengths)
const combined = []
for (let i = 0; i < minLength; i++) {
combined.push(mapFunc(args.map(arg => arg[i])))
}
return combined