Skip to content

Instantly share code, notes, and snippets.

View mgaitan's full-sized avatar
🛠️
devex

Martín Gaitán mgaitan

🛠️
devex
View GitHub Profile
@fmasanori
fmasanori / guess_names.py
Created April 8, 2014 21:54
Guess girl names
import random
girls = '''Júlia Sophia Isabella Manuela Giovanna Alice Laura
Luiza Beatriz Mariana Yasmin Gabriela Rafaela Isabelle Lara
Letícia Valentina Nicole Sarah Vitória Isadora Lívia Helena
Lorena Clara Larissa Emanuelly Heloisa Marina Melissa Gabrielly
Eduarda Rebeca Amanda Alícia Bianca Lavínia Fernanda Ester
Carolina Emily Cecília Pietra Milena Marcela Laís Natália
Maria Bruna Camila Luana Catarina Olivia Agatha Mirella
Sophie Stella Stefany Isabel Kamilly Elisa Luna Eloá Joana
Mariane Bárbara Juliana Rayssa Alana Caroline Brenda Evelyn
@Thimoteus
Thimoteus / Popcorn-Time-installer
Created May 15, 2014 11:47
Install Popcorn Time on Ubuntu
#!/bin/bash
##############
# PRELIMINARIES
##############
user=$(id -u)
INSTALL_PATH="$HOME/Popcorn-Time"
DESKTOP_PATH="$HOME/.local/share/applications"
ICON_PATH="$HOME/.local/share/icons/hicolor/256x256/apps"
@inklesspen
inklesspen / post-checkout.py
Created June 10, 2014 21:54
Post-checkout hook to detect alembic issues when switching branches.
#!/usr/bin/env python
"""
Provide useful alembic information after switching branches.
"""
import argparse
import subprocess
import os
import os.path
import py.path
@bsweger
bsweger / useful_pandas_snippets.md
Last active April 4, 2025 21:20
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@hynekcer
hynekcer / post-checkout.py
Last active November 27, 2019 20:14
Git post-checkout hook for Python to remove orphan *.pyc files and empty dir
#!/bin/env python
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
"""
A hook to git that removes orphan files "*.pyc" and "*.pyo" for "*.py"
beeing deleted or renamed by git checkout. It also removes their empty parent
directories.
Place it to "my_local_repository/.git/hooks/post-checkout" and make it executable.
Nothing is cleaned for .py files deleted manually or by "git rm" etc.
Related to http://stackoverflow.com/q/1504724/448474
#!/usr/bin/env python
"""
no more embarrasing "removed pdb, sorry" commits
install
-------
save it as .git/hooks/pre-commit giving +x permission
"""
@mgaitan
mgaitan / post-checkout.py
Created March 3, 2016 12:42 — forked from inklesspen/post-checkout.py
Post-checkout hook to detect alembic issues when switching branches.
#!/usr/bin/env python
"""
Provide useful alembic information after switching branches.
"""
import argparse
import subprocess
import os
import os.path
import py.path
@h4
h4 / env.py
Last active May 6, 2025 12:44
Setup alembic to work properly with PostgreSQL schemas
from __future__ import with_statement
from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig
from models import Base
config = context.config
fileConfig(config.config_file_name)
@dschep
dschep / py-comp-to-js.md
Last active September 10, 2024 00:15
Python Comprehensions to JS

Python list & dict comprehensions translated to JavasScript

Comprehensions are a really useful feature of Python that aren't available in JavaScript (or many languages). These concepts of course can be tranlsated into using map instead. But especially the dictionaries are a bit trickier.

Lists / Arrays

>>> foobar = range(5)
>>> [x + 1 for x in foobar]
[1, 2, 3, 4, 5]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.