Skip to content

Instantly share code, notes, and snippets.

View colltoaction's full-sized avatar
👋

Martin Coll colltoaction

👋
View GitHub Profile
@colltoaction
colltoaction / probar_funcion.py
Created July 3, 2012 16:31
Una función en python para mostrar cómo testear una función de forma sencilla
def funcion_que_prueba_la_suma():
suma = 1 + 2
assert suma == 3, 'La suma no funciona correctamente, su resultado fue ' + str(suma) + ', distinto de 3'
# si el assert no corta la ejecución, entonces funcionó bien
print 'La suma funciona correctamente'
@colltoaction
colltoaction / error_vectores.c
Created July 30, 2012 15:40
Problemas con C
// *** funciona ***
#include <stdio.h>
#define MAX 2
int main(){
int vector[MAX];
for (int i=0; i<=MAX; i++){
int a;
printf("Ingrese un numero:");
scanf("%i", &a);
@colltoaction
colltoaction / tracer_bullets.txt
Created July 30, 2012 16:35
Extracto del libro Pragmatic Programmer
Tracer Bullets
--------------
Ready, fire, aim...
There are two ways to fire a machine gun in the dark. You can find out exactly where your target is (range, elevation, and azimuth). You can determine the environmental conditions (temperature, humidity, air pressure, wind, and so on). You can determine the precise specifications of the cartridges and bullets you are using, and their interactions with the actual gun you are firing. You can then use tables or a firing computer to calculate the exact bearing and elevation of the barrel. If everything works exactly as specified, your tables are correct, and the environment doesn't change, your bullets should land close to their target.
Or you could use tracer bullets.
Tracer bullets are loaded at intervals on the ammo belt alongside regular ammunition. When they're fired, their phosphorus ignites and leaves a pyrotechnic trail from the gun to whatever they hit. If the tracers are hitting the target, then so are the regular bullets.
// ******* NO COMPILÉ ESTE ARCHIVO **********
abstract class MailMessageBuilder
{
private MailMessage mailMessage = new MailMessage();
public MailMessageBuilder WithTo(string to)
{
mailMessage.To.Add(to);
return this;
try
{
$key = 'HKLM:\SOFTWARE\Microsoft\Microsoft SDKs\ServiceHosting'
$registryProperty = Get-ChildItem $key -ErrorAction Stop | Sort CreationTime -Descending | Select -First 1 | Get-ItemProperty -ErrorAction Stop
$fullVersion = ($registryProperty | Select FullVersion).FullVersion
$installPath = ($registryProperty | Select InstallPath).InstallPath
if ($fullVersion -lt "2.2.0000.0") { throw }
$ref1 = "${installPath}ref\Microsoft.WindowsAzure.Storage.dll"
$ref2 = "${installPath}ref\Microsoft.WindowsAzure.StorageClient.dll"
@colltoaction
colltoaction / decidir_materias.py
Created February 27, 2014 23:43 — forked from anonymous/decidir_materias.py
No sé qué materias elegir, así que lo estoy intentando de la mejor manera que sé: programando
if curso_proba:
asignar(Grynberg)
if curso_analisis:
asignar(Hagman)
elif curso_numerico:
asignar(Menendez, demora = ~30min)
elif prioridad(Murmis) == alta:
asignar(Murmis)
asignar(Menendez, demora = ~30min)
else:
#! /usr/bin/env python2
# coding=utf8
class Cruz(object):
def __repr__(self):
return "X"
def __eq__(self, other):
return isinstance(other, self.__class__)
def replicar(lista, repeticiones):
if len(lista) <= 1:
return lista * repeticiones
mitad = len(lista) / 2
return replicar(lista[:mitad], repeticiones) + replicar(lista[mitad:], repeticiones)
@colltoaction
colltoaction / escalera.py
Created August 29, 2014 22:42
Ejercicio de la escalera implementado con y sin Programación Dinámica.
def escalera_feo(n):
if n == 1:
return 1
elif n == 2:
return 2
return escalera_feo(n - 1) + escalera_feo(n - 2)
def escalera(n):
d = { 1 : 1, 2 : 2 }
return escalera_r(n, d)
@colltoaction
colltoaction / buscar_persona_iter_interno1.c
Last active August 29, 2015 14:07
Ejemplos de iterador interno
struct paramentro_buscador_de_persona {
char* nombre;
persona_t* salida;
};
// Función usada para buscar una persona con un nombre usando
// struct paramentro_buscador_de_persona como extra
bool buscador_de_persona(void* dato, void* extra){
struct paramentro_buscador_de_persona* param = extra;
char* nombre = param->nombre;
persona_t* persona = dato;