Skip to content

Instantly share code, notes, and snippets.

View iuridiniz's full-sized avatar

Iuri Diniz iuridiniz

View GitHub Profile
@iuridiniz
iuridiniz / bash_alias.sh
Created May 25, 2012 16:06
bash util functions and aliases
function timestamp() {
[ -z "$1" ] && date "+%s" && return
date -d "$1" "+%s"
}
function ts2dt() {
date -d "@$1"
}
@iuridiniz
iuridiniz / convert_mp3.sh
Last active August 9, 2023 11:30
Scripts to convert mp3 files
#!/bin/sh
############################################################################
# Convert all mp3 files of a directory to a constant bitrate
############################################################################
BITRATE=96
if [ "x$1" != "x" ]; then
DIR=$( (cd -P "`dirname "$1"/.`" && pwd) )
else
BASEDIR=$( (cd -P "`dirname "$0"`" && pwd) )
@iuridiniz
iuridiniz / translit.php
Created June 9, 2012 21:22
Transliterators
#!/usr/bin/env php
<?php
setlocale(LC_ALL, 'en_US.UTF8');
$string = "Iúri Diniz come açúcar";
echo iconv('UTF-8', 'ASCII//TRANSLIT', $string) . "\n";
?>
@iuridiniz
iuridiniz / set-gnome-fonts.sh
Created July 1, 2012 05:11
Set Gnome Font Sizes
#!/bin/bash
SIZE=8
change_font() {
local schema="$1"
local key="$2"
local size="$3"
local new_font=$( gsettings get "$schema" "$key" |perl -pe "s/\\d+/$size/" )
@iuridiniz
iuridiniz / remove_old_kernels.sh
Created July 3, 2012 11:14
Remove OLD Kernels from ubuntu
#!/bin/sh
current=$( uname -r )
find /boot -name 'vmlinuz-*' | while read i; do
version_full=$( echo $i | perl -pe 's/^.*?vmlinuz-//' )
version_mini=$( echo $version_full | perl -pe 's/-\D+//g' )
if [ "$version_full" = "$current" ]; then
@iuridiniz
iuridiniz / vpn_ssh.sh
Created July 4, 2012 01:16
Script to build a VPN through SSH
#!/usr/bin/sudo sh
# Configure this
SSH_HOST="myhost.com.br"
SSH_PORT="2222"
###########
SSH_LOGIN="root" # ONLY root CAN SETUP TUNNELS :-(
#######################################################
# USUALLY, you don't need to configure this
@iuridiniz
iuridiniz / devel-terminal
Created July 20, 2012 01:42
Scripts in order to setup env's with android, ruby, node, ...
#!/bin/sh
READLINK=`which readlink`
SCRIPT_LOCATION=$0
if [ -x "$READLINK" ]; then
while [ -L "$SCRIPT_LOCATION" ]; do
SCRIPT_LOCATION=`"$READLINK" -e "$SCRIPT_LOCATION"`
done
fi
SCRIPT_HOME=`dirname "$SCRIPT_LOCATION"`
@iuridiniz
iuridiniz / mongod.27017.sh
Created August 30, 2012 01:04
script in order to run mongodb
#!/bin/sh
DBPATH="$HOME/.mongodb"
PORT="27017"
IP="127.0.0.1"
BASENAME=$(basename "$0")
PID="/tmp/$BASENAME.pid"
LOG="/tmp/$BASENAME.log"
MONGOD_CONFIG="/tmp/$BASENAME.config"
@iuridiniz
iuridiniz / _python_env_run_bin.sh
Created September 7, 2012 18:57
Script to run python files under VIRTUAL_ENV/bin
#!/bin/sh
#######
# use:
# ln -s $THIS $DESIRED_BINARY_AT_VIRTUAL_ENV_BIN
. ~/Sources/PYTHON/bin/activate
EXEC=$(basename $0)
EXECFULL="$VIRTUAL_ENV/bin/$EXEC"
@iuridiniz
iuridiniz / .gitignore
Created October 15, 2012 02:46
Django Tests with dynamic fields in hstore
*.pyc
.project
.pydevproject