Skip to content

Instantly share code, notes, and snippets.

View categulario's full-sized avatar
🚲
Always remote

Abraham Toriz Cruz categulario

🚲
Always remote
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am categulario on github.
  • I am categulario (https://keybase.io/categulario) on keybase.
  • I have a public key whose fingerprint is 5443 81E7 7008 CCC2 AEC3 1AA4 0DD5 A530 A716 D609

To claim this, I am signing this object:

@categulario
categulario / xkcd.py
Created November 4, 2016 22:29
Downloads comics from xkcd.com
import requests
import os
import re
def get_line(iterator, condition):
counter = 0
for line in iterator:
if condition(line):
return line
counter += 1
@categulario
categulario / make_tree.py
Last active July 29, 2016 16:17
given an array of strings make a tree of common prefixes
import unittest
from itertools import takewhile, dropwhile, zip_longest
import json
from pprint import pprint
def largest_prefix(string1, string2):
return '/'.join(
map(
lambda x:x[0],
takewhile(
@categulario
categulario / cantor.py
Created June 20, 2015 04:22
Crea el fractal de la alfombra de cantor usando la tortuga de python
from turtle import *
def square(size):
for i in range(4):
forward(size)
left(90)
def cantor(size, tolerance):
init = pos()
@categulario
categulario / clock.html
Created October 3, 2014 14:22
A simple html clock (requires moment.js, jquery.js)
<!doctype html>
<html>
<head>
<meta charset="utf8">
<title>Clock</title>
<style type="text/css">
.hero-circle{
width:180px;
height:180px;
position:relative;
@categulario
categulario / MOUNTAIN_README.md
Last active January 18, 2017 21:40
Cosas para ir a la montaña

Cosas para ir a la montaña

Estas son algunas cosas que deberían pensar en tener en su mochila para salir de campamento a media montaña. Eviten a toda costa llevar cosas en las manos para viajar más cómodos, así que traten de meterlo todo en una mochila.

El equipaje se divide en abrigo, comidaytodo lo demás`.

Abrigo

El abrigo se suele dividir en tres capas, de la más interna a la más externa. Durante la caminta de ascenso es recomendable ir más bien ligero pues al caminar se suda, con un suéter o chaleco basta para cubrir las primeras tres cuartas partes del viaje.

@categulario
categulario / stdlog.php
Created August 13, 2014 13:24
Simple helper for logging things to a file in php
<?php
if(!defined('STDOUT'))
{
define('STDOUT', fopen(base_path().'/application.log', 'a'));
}
/**
* provides an useful function for logging things to a file instead of sendind
* anything to the browser, for example var_dumps
*/
@categulario
categulario / compare_digest.py
Created June 23, 2014 15:15
Validate GitHub signature in python
# validate github signature
import hashlib
import hmac
import json
signature = hmac.new(GITHUB_TOKEN, payload, hashlib.sha1).hexdigest()
# assuming that the 'payload' variable keeps the content sent by github as plain text
# and 'headers' variable keeps the headers sent by GitHub
@categulario
categulario / change.php
Created June 20, 2014 17:44
php change file encoding
<?php
$filename = "changeme.csv";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
if (!mb_check_encoding($contents, 'UTF-8')
OR !($contents === mb_convert_encoding(mb_convert_encoding($contents, 'UTF-32', 'UTF-8' ), 'UTF-8', 'UTF-32'))) {