Skip to content

Instantly share code, notes, and snippets.

@avit
avit / development.rb
Created October 17, 2011 21:11
Using chef roles...
name "development"
description "The development environment"
# Using a role because chef-solo doesn't support environments.
override_attributes "app_environment" => "development",
override_attributes "mysql" => {
:allow_remote_root => true,
:server_root_password => "",
@avit
avit / gist:1290023
Created October 15, 2011 19:22
Safari bug
When accessing short URL links e.g. from Twitter.app, Safari's History records
only the shortened http://t.co/HASHKEY address. This makes it impossible to
find previously viewed pages.
The address bar is redirected to the expanded URI, but the redirected
destination is not recorded in history, and can't be found by page title, URL,
or indexed content.
Furthermore, reloading the destination page also doesn't add the page to
history. The only workaround is to copy the address to a NEW tab and load it
def helper(&block)
content_tag(:div, &block)
end
# or ...
def helper(&block)
%(<div>
#{yield}
</div>}
@avit
avit / application.html.erb
Created May 6, 2011 16:45
Rails Layout & yield blocks
<html>
<head>
<title>My Cool Site : <%= yield :title %></title>
</head>
<body>
<div id="main">
<%= yield %>
</div>
function remove_fields(link) {
$(link).prev("input[type=hidden]").val("1");
$(link).closest('.repeating_fields').slideUp();
}
function add_fields(link, association, content) {
var newId = new Date().getTime();
var regexp = new RegExp("new_" + association, "g");
var newItem = $(content.replace(regexp, newId)).hide();
$(link).prev('.fields').append(newItem);
@avit
avit / config.sh
Created November 15, 2010 03:16
zsh function: Launch man pages in browser if available
# loaded by .zshrc
# Load man pages with Bwana
# requires http://www.bruji.com/bwana/
if [[ -z $SSH_CONNECTION ]]; then
USE_BWANA=`/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump | grep 'bindings:\W*man:'`
fi
// Gets called whenever an en event is fired
Handle = function(ev){
// Step 1: Event setup
var elements = [],
target = ev.target,
isPropagationStopped = false,
isDefaultPrevented = false;
// We are on the Capture Phase to start with
// Align text baselines for blocks with different font sizes, so both elements have the same height.
//
// Suitable for aligning single-line elements while keeping the same height.
//
// Block elements with different font-sizes and the same line-height have
// their middles aligned vertically instead of the same baseline. Use this
// to make floated or inline-block elements align on the same baseline.
//
// This mixin should be used on the smaller font-size element to align its
// baseline to the larger text element's line-height.
@avit
avit / config.rb
Created September 17, 2010 17:51
# Require any additional compass plugins here.
load 'compass-layouts'
# Set this to the root of your project when deployed:
http_path = ""
sass_dir = "src"
css_dir = "public/stylesheets"
images_dir = "public/images"
javascripts_dir = "public/javascripts"
http_stylesheets_path = "stylesheets"
http_images_path = "images"
$global-reset-applied: false;
@mixin global-reset {
$global-reset-applied: true !global;
}