Skip to content

Instantly share code, notes, and snippets.

@alazaro
alazaro / generate_iso_country_json.py
Created February 23, 2021 17:35
Generate a JSON file with ISO codes as keys and country name as values, getting the data from a CSV file.
import pandas as pd
countries = pd.read_csv(
'https://gist.githubusercontent.com/cpl/3dc2d19137588d9ae202d67233715478/raw/3d801e76e1ec3e6bf93dd7a87b7f2ce8afb0d5de/countries_codes_and_coordinates.csv',
index_col='Alpha-2 code',
skipinitialspace=True,
keep_default_na=False
)
countries['Country'].to_json('iso_country.json')
@alazaro
alazaro / regex_merge_conflicts
Created June 21, 2020 16:00
Regular expresion for solving merge conflicts. Substitute with $1 for 'ours' or with $2 for 'theirs'
<<<+.*\n((?:.*\n)*?)===+.*\n((:?.*\n)*?)>>>+.*\n

Keybase proof

I hereby claim:

  • I am alazaro on github.
  • I am alazaro (https://keybase.io/alazaro) on keybase.
  • I have a public key ASCh2kv8f7kj6uJy3sYH8bMu_MzPuV1IaJVeOWnyO2RvWAo

To claim this, I am signing this object:

@alazaro
alazaro / wmd.fish
Last active March 17, 2017 16:12
Fish shell function to run python tests on Mac. Shows notification when passed/failed. Requires watchdog (https://pypi.python.org/pypi/watchdog)
function wmd
watchmedo shell-command -R -W -w --interval 3 -p '*.py' -c $argv\ '&&
out=$?
if [[ $out && 0 -eq $out ]]; then
osascript -e \'display notification "OK"\';
else
osascript -e \'display notification "Failed"\';
fi'
end
@alazaro
alazaro / cervantes.py
Created October 12, 2015 21:08
Just a stupid POC of a python program writing another python program
# -*- coding: utf-8 -*-
class Cervantes(object):
"""
Cervantes writes python programs like a pro
"""
writer = None
_indent = 0
@alazaro
alazaro / elasticsearch-0.90.0.RC1.rb
Created April 8, 2013 13:12
Homebrew formula for elasticsearch 0.90.0.RC1
require 'formula'
class Elasticsearch0900Rc1 < Formula
homepage 'http://www.elasticsearch.org'
url 'https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.0.RC1.tar.gz'
sha1 'e5e4a99d5a992c7da736ab5976d2fa6cb0e2cb94'
head 'https://github.com/elasticsearch/elasticsearch.git'
depends_on 'maven' if build.head?
@alazaro
alazaro / postgres9.1.6.rb
Last active December 14, 2015 14:18 — forked from nebiros/postgresql.rb
Homebrew formula for Postgres 9.1.6. To install it, just copy this file into /usr/local/Library/Formula/postgres9.1.6.rb and execute brew install postgres9.1.6. If you already have a Postgres instalation you must run brew link --overwrite postgres9.1.6
require 'formula'
class Postgres916 < Formula
homepage 'http://www.postgresql.org/'
url 'http://ftp.postgresql.org/pub/source/v9.1.6/postgresql-9.1.6.tar.bz2'
sha1 'a24b7c002463572ee7371f055e566b69e39cda3e'
depends_on 'readline'
depends_on 'libxml2' if MacOS.leopard? # Leopard libxml is too old
depends_on 'ossp-uuid' unless build.include? 'without-ossp-uuid'
@alazaro
alazaro / spain_postcodes.json
Created February 21, 2013 11:18
Spain post codes
[0, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1012, 1013, 1015, 1070, 1071, 1080, 1110, 1117, 1118, 1120, 1128, 1129, 1130, 1138, 1139, 1160, 1165, 1169, 1170, 1171, 1191, 1192, 1193, 1194, 1195, 1196, 1200, 1206, 1207, 1208, 1211, 1212, 1213, 1216, 1220, 1230, 1240, 1250, 1260, 1300, 1306, 1307, 1308, 1309, 1320, 1321, 1322, 1330, 1340, 1400, 1408, 1409, 1420, 1423, 1426, 1427, 1428, 1430, 1439, 1440, 1449, 1450, 1468, 1470, 1474, 1476, 1477, 1478, 1479, 1510, 1520, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2049, 2070, 2071, 2080, 2100, 2110, 2120, 2124, 2125, 2127, 2129, 2130, 2136, 2137, 2139, 2140, 2141, 2142, 2150, 2151, 2152, 2153, 2154, 2155, 2156, 2160, 2161, 2162, 2200, 2210, 2211, 2212, 2213, 2214, 2215, 2220, 2230, 2240, 2246, 2247, 2248, 2249, 2250, 2251, 2252, 2253, 2260, 2270, 2300, 2310, 2311, 2312, 2313, 2314, 2315, 2316, 2320, 2326, 2327, 2328, 2329, 2340, 2350, 2359, 2360, 2400, 2409, 2410, 2420, 2430, 2434, 2435, 2436, 2437, 2439, 2440, 2448, 2449, 2450, 2459, 2460, 2461,
@alazaro
alazaro / mediaquery_test.html
Created August 3, 2012 10:00
Test for mediaqueries
<html>
<head>
<style type="text/css">
.box {
height: 100%;
width: 100%;
}
@media (min-width: 128px) and (max-width: 255px) {.box {background-color: red}}
@alazaro
alazaro / add_input.html
Created May 2, 2012 13:54
Auto add inputs to a form when an event occurs.
<html>
<head><title>Hello World!!</title></head>
<body>
<form id="myForm">
<input type="text" id="in1" />
</form>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {