Skip to content

Instantly share code, notes, and snippets.

View berlotto's full-sized avatar

Sérgio Berlotto Jr berlotto

View GitHub Profile
@berlotto
berlotto / record-screencast.sh
Last active December 14, 2015 07:58
Record screencast from with sound in MP4 h264/AAC codecs
avconv -f alsa -i pulse -f x11grab -r 30 -s 1366x768 -i :0.0 -vcodec libx264 -preset ultrafast -ab 320k -threads 8 myscreencast.mp4
@berlotto
berlotto / format_pendrive.sh
Created March 29, 2013 02:34
Format pendrive and change label
mkdosfs -n "BERLOTTO" -I /dev/sdb1
@berlotto
berlotto / .bashrc
Last active December 16, 2015 01:39
My .bashrc file to ElemntaryOS.
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
@berlotto
berlotto / download_faster.sh
Created April 16, 2013 20:32
How to download faster, a ISO for example.
# Using 2 connections per host
aria2c -x2 http://a/f.iso
# Using 2 sources
aria2c http://a/f.iso ftp://b/f.iso
@berlotto
berlotto / repair-mysql.sh
Created April 30, 2013 17:51
Repair all databases in your MySql and optimize if possible
mysqlcheck --all-databases --auto-repair --optimize -u <user> -p<passwd>
@berlotto
berlotto / .vimrc
Created June 14, 2013 03:20
My .vimrc
" vimrc file for following the coding standards specified in PEP 7 & 8.
"
" To use this file, source it in your own personal .vimrc file (``source
" <filename>``) or, if you don't have a .vimrc file, you can just symlink to it
" (``ln -s <this file> ~/.vimrc``). All options are protected by autocmds
" (read below for an explanation of the command) so blind sourcing of this file
" is safe and will not affect your settings for non-Python or non-C files.
"
"
" All setting are protected by 'au' ('autocmd') statements. Only files ending
@berlotto
berlotto / convert_file.sh
Created July 30, 2013 02:12
Convertg ISO-8859-1 file to UTF-8
iconv --from-code=ISO-8859-1 --to-code=UTF-8 ./oldfile.htm > ./newfile.html
@berlotto
berlotto / password.py
Created August 1, 2013 13:21
Random choice string to generate passwords
import random
import string
pwd = ''.join(random.choice(string.printable) for x in range(8))
print pwd
@berlotto
berlotto / functions.php
Created August 19, 2013 14:14
Save and retrive data to Wordpress options with HTML content !
$var_to_save = htmlentities(stripslashes($_POST["YOUR_FORM_FIELD_NAME"]));
update_option("your_option_name", $var_to_save);
...
$var_to_sdhow = html_entity_decode(get_option("gd_seminario_aovivo"));
@berlotto
berlotto / app.py
Created August 21, 2013 14:16
Slugify function to use in Flask (Python)
_slugify_strip_re = re.compile(r'[^\w\s-]')
_slugify_hyphenate_re = re.compile(r'[-\s]+')
def slugify(value):
"""
Normalizes string, converts to lowercase, removes non-alpha characters,
and converts spaces to hyphens.
From Django's "django/template/defaultfilters.py".
"""
import unicodedata