Skip to content

Instantly share code, notes, and snippets.

@jalberto
jalberto / git-utils
Created March 21, 2015 23:49
Untrack files from Git usgin gitignore
git rm --cached `git ls-files -i -X .gitignore`
@jalberto
jalberto / gitconfig
Created February 6, 2015 12:02
GIT configuration with some useful aliases
# Just drop this file in ~/.gitconfig
[user]
name = Jose Alberto
email = ja@josealberto.org
[giggle]
main-window-view = HistoryView
history-view-vpane-position = 501
main-window-maximized = true
main-window-geometry = 0x0+0+0
@jalberto
jalberto / dashboard.sh
Created January 16, 2015 14:08
Basic console dashboard (tmux/byobu)
#!/bin/bash
plexer=byobu
$plexer send-keys -t 0.0 '' C-m
$plexer send-keys -t 0.0 nice\ goaccess\ -f\ /var/log/nginx/access.log C-m
$plexer splitw -t 0
$plexer select-layout -t 0 main-horizontal
@jalberto
jalberto / zpreztorc
Last active August 29, 2015 14:09
My ZSH config
#
# Sets Prezto options.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
#
# General
#
@jalberto
jalberto / ngram.rb
Last active August 29, 2015 14:06
Ngram library base in Tony Byrne code
#
# Extract uni, bi, and trigrams.
#
# "one two three".ngram(1) # unigrams
# "one two three".ngram(2) # bigrams
# "one two three".ngram(3) # trigrams
#
module Ngram
TOKENIZER_REGEX = /[[:word:]'’\-\£\€]+/
@jalberto
jalberto / web_typography.md
Last active August 29, 2015 14:02
Notes on web typography

Web Typography Tips

http://blog.typekit.com/2013/05/01/hi-dpi-typography/

What makes a device “hi-DPI” or not. In general, a device is hi-DPI if it has both of these things:

  • A display with a (relatively) high pixel density, say, over 200 pixels per inch (PPI) for mobile devices or over 150 PPI for laptops.
  • Pixel scaling, where the on-screen graphics are rendered using extra physical pixels so that they appear sharper and clearer than on a standard display.

Font Weight

@jalberto
jalberto / remote_cache_with_project_root_strategy.rb
Created May 6, 2014 14:17
Capistrano 3.1.x Strategy to deploy git projects with subdirectories
# Usage:
# 1. Drop this file into lib/capistrano/remote_cache_with_project_root_strategy.rb
# 2. Add the following to your Capfile:
# require 'capistrano/git'
# require './lib/capistrano/remote_cache_with_project_root_strategy'
# 3. Add the following to your config/deploy.rb
# set :git_strategy, RemoteCacheWithProjectRootStrategy
# set :project_root, 'subdir/path'
# Define a new SCM strategy, so we can deploy only a subdirectory of our repo.
@jalberto
jalberto / Capfile.rb
Created January 28, 2014 16:19
Basic capistrano 3 deploy
require 'capistrano/bundler'
require 'capistrano/rails'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/rvm'
@jalberto
jalberto / backup.rake
Created December 16, 2013 22:30
Simple Rails backup script using Backup gem
# lib/tasks/backup.rake
namespace :backup do
desc "Back up the database"
task :db do
sh "backup perform --trigger backupdb --config_file config/backup.rb --data-path db --log-path log --tmp-path tmp"
end
end
@jalberto
jalberto / to_utf8.sh
Created November 21, 2013 15:05
Bash script to change encoding recursively. Use: sh to_utf8.sh path/dir
#!/bin/bash
# vim: set sw=2 sts=2 tw=80 :
shopt -s globstar
for file in $1/**
do
if test -f $file
then
CHARSET="$(file -bi "$file"|awk -F "=" '{print $2}')"
if [ "$CHARSET" != binary ]; then
if [ "$CHARSET" != utf-8 ]; then