Skip to content

Instantly share code, notes, and snippets.

@dmitrydyomin
dmitrydyomin / simple_git_deploy.sh
Created September 9, 2015 17:23
Simple website deploy from GIT repo. Just exports provided ref to a temp directory, then swaps directories and removes the old one.
#!/bin/bash
if [ "$#" -ne 3 ]; then
echo "Usage: deploy REPO REF DIR"
echo "e.g. deploy /opt/git/example.git master /var/www/example.com"
exit
fi
REPO=$1
REF=$2
@dmitrydyomin
dmitrydyomin / apache-files-download.py
Last active August 29, 2015 14:25
Downloads files from Apache server with +Indexes option to a local folder. Restores badly encoded CP-1251 filenames. To restart the download just run it once again.
#!/Library/Frameworks/Python.framework/Versions/2.7/bin/python
from bs4 import BeautifulSoup
import urllib2, urllib
import re, os
# create a password manager
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
baseurl = "http://example.com/files/"
user = 'foo'
password = 'bar'
@dmitrydyomin
dmitrydyomin / backup_mysql.sh
Last active August 29, 2015 14:05
MySQL backup script
#!/bin/bash
if [ $# == 1 ] && [ $1 != "--daily" ]; then
declare -a databases=("$1")
else
declare -a databases=("db1 db2")
fi
for database in "${databases[@]}"
do