Skip to content

Instantly share code, notes, and snippets.

View mallamanis's full-sized avatar
:octocat:

Miltos mallamanis

:octocat:
View GitHub Profile
@mallamanis
mallamanis / gist:1943075
Created February 29, 2012 18:06
Bash Script to automatically backup dbs in separete files
#!/bin/bash
# adapted from sonia 16-nov-05 ( www.snowfrog.net/2005/11/16/backup-multiple-databases-into-separate-files/ )
# backup each mysql db into a different file, rather than one big file
# as with --all-databases - will make restores easier
# rotate daily, keep one week's long
USER="SQLSuperUserName"
PASSWORD="SQLSuperUserPasswordHere"
OUTPUTDIR="/path/to/backups/dbbackup"
MYSQLDUMP="/usr/bin/mysqldump"
@mallamanis
mallamanis / gist:1942916
Created February 29, 2012 17:54
Expect commands for remote backup
set timeout 18000
spawn ssh [email protected] mysqldump --database db_name -u db_user -p --single-transaction >/path/to/backup
expect "*[email protected]'s password:*";
send "superSecurePassword\r";
expect "*?assword:*";
send "superSecureDBpass\r";
@mallamanis
mallamanis / bashrc_ssh_autocomplete
Created January 20, 2012 17:49
ssh autocomplete hosts
complete -W "$(echo $(grep '^ssh ' .bash_history | sort -u | sed 's/^ssh //'))" ssh
@mallamanis
mallamanis / texttilling.py
Created December 31, 2011 18:47
Text-tilling implementation with nltk
#!/usr/bin/env python
import nltk
from nltk.stem.porter import PorterStemmer
def preprocessText(text):
# To lower case
text = text.lower();
# Tokenize text
@mallamanis
mallamanis / gist:1247758
Created September 28, 2011 11:53
Print all messages in ROS
#!/bin/bash
for line in $(rospack list-names)
do
for msg in $(rosmsg package $line)
do
echo 'Message ' $msg ' in ' $line
rosmsg show $msg
echo '-----------------------------------------------------'
done
@mallamanis
mallamanis / gist:1229904
Created September 20, 2011 18:36
Make all possible accent combinations of something (reading from file)
#!/usr/bin/env python
def generateChars(char):
if char == u'\u03ac' or char == u'\u03b1': #alpha
return (u'\u03ac',u'\u03b1');
elif char == u'\u03b5' or char == u'\u03ad': #epsilon
return (u'\u03b5', u'\u03ad');
elif char == u'\u03b7' or char == u'\u03ae': #ita
return (u'\u03b7',u'\u03ae');
@mallamanis
mallamanis / gist:1227178
Created September 19, 2011 18:22
convert unicode to international domain names from file
import encodings.idna
filename = '/path/to/names';
filePointer = open(filename,'r');
content = filePointer.read();
content = content.split("\n");
for line in content:
line = line.decode('utf-8');
@mallamanis
mallamanis / mysqldump_pre_commit_hook.bash
Created August 23, 2011 10:50 — forked from nuclearsandwich/mysqldump_pre_commit_hook.bash
A pre-commit hook for git which dumps and adds a mysql database to the repository just before commit.
#!/bin/bash
# Pre-commit hook to make a mysql dump right before committing and add it to the commit.
#
## Change the following values to suit your local setup.
# The name of a database user with read access to the database.
DBUSER=root
# The password associated with the above user. Leave commented if none.
DBPASS=seekrit
# The database associated with this repository.
DBNAME=dplay
@mallamanis
mallamanis / gist:1106769
Created July 26, 2011 13:33
Addition to .bashrc for showing current git branch
export PS1="\[\033[38m\]\u@\h\[\033[01;34m\] \w \[\033[31m\]\`ruby -e \"print (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').gsub(/^\* (.+)$/, '(\1) ')\"\`\[\033[37m\]$\[\033[00m\] "
@mallamanis
mallamanis / DBbackup.sh
Created June 7, 2011 21:50
Simple MySQL Dump backup
#!/bin/bash
mysqldump --all-databases --user="username" --password="password" --single-transaction >/destination/folder/all_databases.sql
cd /destination/folder/
# Create new archive
ARCHIVE_NAME=DBs$(date '+%G%m%d%k').tar
tar -cvvf $ARCHIVE_NAME all_databases.sql