Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# btsync service
# Replace with linux users you want to run BTSync clients for
BTSYNC_USERS="mendel"
DAEMON=/usr/bin/btsync
start() {
for btsuser in $BTSYNC_USERS; do
HOMEDIR=`getent passwd $btsuser | cut -d: -f6`
config=$HOMEDIR/.sync/config.json
@alexsavio
alexsavio / IPTables, block ports
Last active December 17, 2015 14:49
IPTables configuration in Ubuntu 13.04. Secure your ports!
Got this from: https://help.ubuntu.com/community/IptablesHowTo
IPTables setup, which will load and save configurations made in IPTables.
This default setup will block every port except for 80 and 22.
First create the files below in
/etc/iptables.rules
/etc/network/if-post-down.d/iptablessave
/etc/network/if-pre-up.d/iptablesload
@alexsavio
alexsavio / extract_youtube_links
Last active December 28, 2015 18:39
Simple Python script to extract youtube links from a web page
#!/usr/bin/env bash
# This hook is run after a new virtualenv is activated.
# ~/.virtualenvs/postmkvirtualenv
# determine if virtualenv is activated
python -c 'import sys; print(sys.real_prefix)' 2>/dev/null && INVENV=1 || INVENV=0
if [ ! $INVENV == 1 ]; then
echo "You must activate a virtualenv for this to work."
exit -1
fi
@alexsavio
alexsavio / CURL_examples.ipynb
Last active December 31, 2015 05:59
IPython notebooks on how to use Virtualenv and Virtualenvwrapper
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 128m;
client_body_buffer_size 256k;
proxy_connect_timeout 60;
proxy_send_timeout 60;
@alexsavio
alexsavio / kickstart
Last active January 4, 2016 00:18 — forked from ludo/kickstart
install
# Ridiculous URL... I know...
url --url http://nl.archive.ubuntu.com/ubuntu/ubuntu/ubuntu/ubuntu/ubuntu/
text
lang en_US
langsupport en_US
keyboard es
#rootpw pa$$word # you should replace, and use --iscrypted
@alexsavio
alexsavio / pip-update
Last active August 29, 2015 13:56
Python script to use pip and upgrade all packages in the currently activated virtualenv.
#!/usr/bin/env python
import os
import sys
import subprocess
env_root = os.getenv('VIRTUAL_ENV')
if sys.platform == 'win32':
bin = 'Scripts'
@alexsavio
alexsavio / download-subs.py
Last active September 14, 2018 09:20
Python and Subliminal script to download subtitles automatically. (Just use: http://subliminal.readthedocs.org/en/latest/user/usage.html#cli)
#!/usr/bin/env python
#pip install subliminal babelfish
from __future__ import unicode_literals # for python 2 only
import os
import sys
import os.path as op
import logging as log