Skip to content

Instantly share code, notes, and snippets.

@Xpktro
Xpktro / turtle.logo
Created August 23, 2015 08:55
Turtle Academy variation on showcase script
@Xpktro
Xpktro / values.py
Created March 19, 2015 19:46
Get values from iterable consisting of dicts or lists in a flattened list
def values(iterable):
if type(iterable) == dict:
return sum([values(iterable.values())], [])
elif type(iterable) == list:
return sum(map(values, iterable), [])
return [iterable]
# >>> values([1, 2, 3, {'1': 2, '2': [4, 5, 6]}, [7, 8, 9]])
# [1, 2, 3, 2, 4, 5, 6, 7, 8, 9]
@Xpktro
Xpktro / slow.ck
Created October 11, 2014 05:30
One of my ChucK experiments
// Our sound chain is quite simple buy nice-sounding.
// The Rhodey instrument (even when not shown in lectures, is
// a STK instrument and meets the evaluation criteria) is a nice
// Rhodes-keyboard-like sound, I love it and now I can use it.
// (you should REALLY hear the ChucK website demo)
Rhodey rho[3];
Pan2 rhoPan[3];
Gain rhoGain => NRev rhoRev => dac;
// I'm using really low gain parameters to avoid distorsion
@Xpktro
Xpktro / generadores.py
Last active August 29, 2015 14:03
Cryptography snippets (commented and developed in spanish)
def buscar_generadores(p):
# Se define el grupo Zp = {1, 2, ..., p-1}
grupo = set([x + 1 for x in range(p-1)])
# Buscar generadores implica que se busquen numeros n tal que:
for n in grupo:
resultados = []
# Para cada k en [1; p-1]
for k in range(1, p):
@Xpktro
Xpktro / acpe.cfdg
Created June 4, 2014 17:01
ArtCoders.pe Propuesta de Logo (Context-Free Art)
// ArtCoders.pe - Propuesta de Logo
// Variación recomendada: BQP
import i_pix.cfdg
import i_polygons.cfdg
startshape ccpe
CF::Background = [h -140.10 sat 0.8835 b -0.9448]
shape ccpe {
backg[x -6.65 4 1]
title[z 1]
@Xpktro
Xpktro / capicua.py
Created April 16, 2014 00:01
Academic Excercises with Python (in spanish)
def capicua(numero):
numero = str(numero)
if numero == '' or len(numero) == 1:
return True
elif numero[0] == numero[-1]:
return capicua(numero[1:-1])
return False
print capicua(123321)
@Xpktro
Xpktro / iptables.md
Last active August 29, 2015 13:57
Iptables spanish quickstart

Tutorial Iptables

Iptables es un comando que permite controlar el tráfico entrante, saliente y circulante del equipo, a través de una serie de reglas agrupadas en algo llamado tablas.

Para utilizar iptables se necesita estar en una consola de root, para iniciar sesión como root:

sudo su -
@Xpktro
Xpktro / zen.sh
Created March 4, 2014 16:59
Github Zen consumer one-liner
python -c "import urllib; print urllib.urlopen('https://api.github.com/zen').read()"
@Xpktro
Xpktro / greet.js
Created September 14, 2013 04:19
Programmer's day one-liner greeter.
(function(){var today = new Date(); var firstday = new Date(today.getFullYear(), 0, 1); if(Math.ceil((today-firstday)/86400000) === 256) console.log('Happy Programmers Day!');})();
@Xpktro
Xpktro / des.py
Last active May 26, 2022 11:34
des.py: A pure Python academic-only implementation of the DES cipher.
#coding:utf-8
"""des.py: A pure Python academic-only implementation of the DES cipher."""
__author__ = u'Moisés Cachay Tello'
__copyright__ = u'Copyright 2013, Moisés Cachay Tello'
import binascii
class BinString(str):