Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / zpreztorc
Last active August 29, 2015 14:09
My ZSH config
#
# Sets Prezto options.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
#
# General
#
@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 / 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 / git-utils
Created March 21, 2015 23:49
Untrack files from Git usgin gitignore
git rm --cached `git ls-files -i -X .gitignore`
# Detects user's browser.
def browser_name
ua = request.user_agent.downcase
if ua =~ /firefox\//
:firefox
elsif ua =~ /opera\//
:opera
elsif ua =~ /chrome\//
@jalberto
jalberto / _form.html.haml
Created April 7, 2012 12:11
dynamic form with cocoon
= semantic_form_for(@event, :html => {:multipart => true, :id => "logoUpload", :'data-ajax' => false}) do |f|
= f.inputs do
= f.input(:logo, :as => :file)
= f.input(:logo_cache, :as => :hidden)
= f.input(:name)
= f.input(:info)
#matches
= f.inputs :for => [:matches] do |mf|
= render :partial => 'match_fields', :locals => {:f => mf}
@jalberto
jalberto / list_bootstrap.rb
Created April 16, 2012 22:33
simple-navigation render for twiter bootstrap nav-list
class ListBootstrap < SimpleNavigation::Renderer::Base
def render(item_container)
list = item_container.items.inject([]) do |list, item|
if item.html_options[:opts]
if item.html_options[:opts][:nav_header]
list << li_header(item)
elsif item.html_options[:opts][:icon]
list << li_icon(item)
end
else
@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.