Skip to content

Instantly share code, notes, and snippets.

View javierwilson's full-sized avatar

javier wilson javierwilson

  • Managua, Nicaragua
View GitHub Profile
@javierwilson
javierwilson / superglue.py
Created October 5, 2015 21:22
Glues together different lists of dictionaries using a common key
def superglue(data=(), key='id', default=0):
"Glues together different lists of dictionaries using a common key"
alldata = []
for datum in data:
# cast as lists
datum = list(datum)
alldata = alldata + datum
print datum
@javierwilson
javierwilson / .vimrc
Created February 18, 2016 19:23
vimrc
" enable syntax highlighting
syntax enable
" show line numbers
set number
" set tabs to have 4 spaces
set ts=4
" indent when moving to the next line while writing code
@javierwilson
javierwilson / bms.sh
Last active September 27, 2016 20:19
bootstrap my shell
#!/bin/bash
dnf -y install vim
dnf -y install zsh
dnf -y install wget
dnf -y install curl
dnf -y install git
dnf -y install bind-utils
dnf -y install whois
dnf -y install util-linux-user
cd ~
@javierwilson
javierwilson / iptables
Created April 22, 2016 17:59
iptables - router
#
# /etc/sysconfig/iptables
#
# em1 - public IP connected to the Internet
# em2 - private IP, local area network (LAN)
#
# Allow NAT, MASQUERADEing...
*nat
:PREROUTING ACCEPT [0:0]
#!/bin/bash
BACKUP_DIR="/var/lib/mysql/backup"
if [ -n "`pidof mysqld`" ] && [ -f "/var/lib/mysql/.my.cnf" ]; then
mkdir -p $BACKUP_DIR
chown mysql $BACKUP_DIR
# backup datqabases
# please create /var/lib/mysql/.my.cnf
bash-completion
bc
bind-utils
net-tools
elinks
ethtool
ftp
binutils
dropbear
htop
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2
mQENBFOHkbcBCADZO1tfHU2UIvJK/hyTmcBb51baUzYsJ1sZX3n2PxMzZ7l7gwae
oHBUcIjctO0wwYPMV1FYPe5fAoVMTYaxxBX+ltr7QAKOQNCF/ybRoqjFD1rI58if
ews54++uBKNBxBwRwye5kQLXqsrFfzMQgxR3go2NZrJEsdJjyYDTmZkKOoURS9MV
7q4KaOp8gweHi1KIXHwnpU1VzHO//yIy/XLKvE7GGHknLac2Ztrz7w5PVJgauGUp
M5dkF5Vy75DumAasU0htpweV2HSSCC2+o3PwEeYurEyZ+ECuNucSSIhiB8LxU0Y+
fCvF6c65B17WXIno9XYFfp/XziKVkMudUhCdABEBAAG0IUphdmllciBXaWxzb24g
PGphdmllckBndWVndWUubmV0PokBPgQTAQIAKAUCU4eRtwIbAwUJEswDAAYLCQgH
@javierwilson
javierwilson / polls.py
Created August 26, 2016 04:24
parse html election results
import glob
from lxml.html import parse
poll_files = glob.glob("*.html")
for poll_file in poll_files:
poll = poll_file[0:poll_file.index('.')]
names = poll.split(',',2)
page = parse(poll_file)
trs = page.xpath("body/div/div//div/table")[0].findall("tr")
from askbot.models import User
users = User.objects.filter(askbot_profile__reputation=1)
for u in users:
print u
profile = u.askbot_profile
profile.reputation = 100
profile.save()
@javierwilson
javierwilson / deploy.sh
Last active December 11, 2016 06:58
deploy matos
#!/bin/bash
USER=matos
APP=$USER
DIR=/var/www/$APP
REPO=https://github.com/javierwilson/$APP
mkdir $DIR
find $DIR -name "*.pyc"|xargs rm
git clone $REPO $DIR