Skip to content

Instantly share code, notes, and snippets.

@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
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 / 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>
def helper(&block)
content_tag(:div, &block)
end
# or ...
def helper(&block)
%(<div>
#{yield}
</div>}
@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
@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:1300452
Created October 20, 2011 04:57
Vagrant error on new veewee box with user "deploy"
Feature: vagrant box validation
As a valid vagrant box
I need to comply to a set of rules
Scenario: Checking login # /Users/andrew/.rvm/gems/ruby-1.9.2-p180@ops/gems/veewee-0.2.0/lib/veewee/../../validation/vagrant.feature:5
.. When I ssh to "127.0.0.1" with the following credentials: # veewee-0.2.0/validation/features/steps/ssh_steps.rb:56
| username | password | port |
| vagrant | vagrant | 7222 |
expected no Exception, got #<Net::SSH::AuthenticationFailed: vagrant> (RSpec::Expectations::ExpectationNotMetError)
And I run "whoami" # veewee-0.2.0/validation/features/steps/ssh_steps.rb:98
diff --cc cookbooks/mysql/metadata.json
index 9010798,b3ab7ec..0000000
--- a/cookbooks/mysql/metadata.json
+++ b/cookbooks/mysql/metadata.json
resize
COLUMNS=181;
LINES=63;
export COLUMNS LINES;
%
@avit
avit / pwd.rb
Created November 9, 2011 08:19
Is there any way to get the pwd as the symlink directory I'm working in?
puts Dir.pwd