Skip to content

Instantly share code, notes, and snippets.

@jalberto
jalberto / 0_reuse_code.js
Created October 3, 2013 15:39
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jalberto
jalberto / linecache19_install.sh
Last active December 20, 2015 02:09 — forked from tvdeyen/gist:2711329
Small script to install linecache19
#!/bin/bash
# Install with:
# bash < <(curl -L https://gist.github.com/jalberto/6053996/raw/bcbb6e14d4f26b56c6c589882f047a96a3ab587a/linecache19_install)
#
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
ruby_version="$(rvm info ruby | grep version | head -n1 | awk '{print $2}' | tr '"' ' ')"
echo "Installing ruby-debug with $ruby_version ..."
@jalberto
jalberto / crontab
Last active December 19, 2015 02:58
Simple Backup script
# m h dom mon dow command
0 2 * * * ruby /path/to/db_backup.rb -d -e production -t dayly
0 2 * * 1 ruby /path/to/db_backup.rb -d -e production -t weekly
@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 / _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}
# Detects user's browser.
def browser_name
ua = request.user_agent.downcase
if ua =~ /firefox\//
:firefox
elsif ua =~ /opera\//
:opera
elsif ua =~ /chrome\//