Skip to content

Instantly share code, notes, and snippets.

@edgarrmondragon
edgarrmondragon / mx_tj.json
Last active September 13, 2018 05:53
Mexico's municipalities and states TopoJSON
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@edgarrmondragon
edgarrmondragon / homicide.tsv
Created September 13, 2018 05:55
Homicides in Mexico per 100,000 inhabitants from 2008 to 2017
ID Entidad federativa de registro 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017
1 Aguascalientes 5 6 6 7 4 4 4 3 4 6
2 Baja California 33 48 47 25 17 23 21 25 32 60
3 Baja California Sur 6 5 8 6 5 7 12 24 30 91
4 Campeche 7 7 6 6 9 8 9 7 10 8
5 Coahuila de Zaragoza 7 10 16 26 41 28 16 11 8 9
6 Colima 9 9 20 24 39 32 20 31 82 113
7 Chiapas 6 11 4 4 8 10 9 10 10 11
8 Chihuahua 76 105 182 126 77 59 48 42 47 59
9 Ciudad de México 10 11 12 12 12 12 12 12 14 15
@edgarrmondragon
edgarrmondragon / timefunc.py
Created September 24, 2018 23:40
Python decorator to time function execution
import time
def timefunc(f, *args, **kwargs):
time1 = time.time()
result = f(*args, **kwargs)
time2 = time.time()
elapsed = time2 - time1
return result, elapsed
@timefunc
@edgarrmondragon
edgarrmondragon / custom_lex.py
Created October 16, 2018 04:30
Custom lexicographical order in Python
alphabet = <CustomAlphabet>
def goes_before(s, t):
if s == t:
return True
elif len(t) == 0:
return False
elif len(s) == 0:
return True
elif alphabet.index(s[0]) < alphabet.index(t[0]):
@edgarrmondragon
edgarrmondragon / django_deploy.md
Created December 21, 2018 15:50 — forked from bradtraversy/django_deploy.md
Django Deployment - Digital Ocean

Django Deployment to Ubuntu 18.04

In this guide I will go through all the steps to create a VPS, secure it and deploy a Django application. This is a summarized document from this digital ocean doc

Any commands with "$" at the beginning run on your local machine and any "#" run when logged into the server

Create A Digital Ocean Droplet

Use this link and get $10 free. Just select the $5 plan unless this a production app.

@edgarrmondragon
edgarrmondragon / vscode_tricks.md
Created February 14, 2019 02:06
Some VS Code tricks

Toggle terminal/editor with Ctrl+Alt+[SemiColon]

[
    {
        "key": "ctrl+alt+[SemiColon]",
        "command": "workbench.action.terminal.focus"
    },
    {
 "key": "ctrl+alt+[SemiColon]",
@edgarrmondragon
edgarrmondragon / MongoDBSeed.Dockerfile
Last active March 22, 2019 00:01
Working MongoDB seeding container in docker-compose
FROM mongo:3.6
ADD ./data/mongo_dump /mongo_dump
CMD mongorestore /mongo_dump
import pendulum
date_period = pendulum.period(
pendulum.datetime(2019, 1, 1),
pendulum.datetime(2019, 3, 20),
)
for dt in date_period.range("days"):
start, end = dt.start_of("day"), dt.end_of("end")
@edgarrmondragon
edgarrmondragon / audit_triggers.sql
Created March 26, 2019 00:38
PostgreSQL triggers for data change audits
DROP SCHEMA IF EXISTS edgar CASCADE;
CREATE SCHEMA edgar AUTHORIZATION spoton;
DROP TABLE IF EXISTS edgar.people;
CREATE TABLE edgar.people (id INTEGER PRIMARY KEY, name TEXT NOT NULL);
DROP TABLE IF EXISTS edgar.dumb_audits;
CREATE TABLE edgar.dumb_audits (
op TEXT NOT NULL,
stamp TIMESTAMP NOT NULL,
@edgarrmondragon
edgarrmondragon / docker-compose.yml
Last active March 15, 2024 14:04
Generate SchemaSpy database documentation using docker-compose
# You might need to run `sudo chown -R $USER schemaspy/`
version: '3'
services:
postgres:
image: postgres
schemaspy:
image: schemaspy/schemaspy:snapshot
volumes: