Skip to content

Instantly share code, notes, and snippets.

PROMPT='%{$fg[cyan]%}%c%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}% %{$reset_color%}:'
ZSH_THEME_GIT_PROMPT_PREFIX="(%{$fg[blue]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[red]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
@Bodacious
Bodacious / id_rsa.pub
Created May 15, 2012 08:41
My Macbook Public Key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDN+R6PtOsWqdznRlZwFaV2NYw3FNFqnfbiCZYTKCgt0U3ho8Ycy3SZmNWqkwYKsgWVjWTD/v9Emp5Y8jL6eyW+2MrsOeKOaV38kOEcV/+aUJOMh3+m35V0yIgJZ+0XyVWYBAx6CHd1jPVYE3EMUHm6oOEqPHffVF3QUKr6IB8at5l/vNZbRCsDK81DwAz7jCFLC9M5aNSzIYZmZmi7ZtRU76leVDQ2E/OQqnap2JhCxKFKUCX25pCBMw4L5/egV7CNuzkDw+YMMdSJ9+hb5vd8DeKJVTGyLKoF0kVqQpJcntQPRTzEVBTv7GijYFVku9rwh2ss/ye9t0Jfo1HNesA9 gavin@gavinmorrice.com
@Bodacious
Bodacious / Explanation.md
Created May 11, 2012 08:53
RubyMotion method name explanation...

RubyMotion comes with some syntax idioms that are not strictly idiomatic Ruby.

For example, in an iOS app we'd often see these two methods defined in a subclass of UITableViewController

    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
      // callback code for selecting table rows goes here...
@Bodacious
Bodacious / my_controller.rb
Created March 14, 2012 20:19
Responding to a JSON PUT/DELETE request with JSON
class MyController < ApplicationController
def update
if resource.update_attributes(params[:resource])
render json: resource, status: :ok # status is :ok by default so feel free to remove this option
else
render json: { errors: resource.errors }, status: :unprocessable_entity
end
end
@Bodacious
Bodacious / datetime.rb
Created March 2, 2012 10:50
Custom date/time formats in Ruby on Rails
[Time, Date].map do |klass|
klass::DATE_FORMATS[:variable] = lambda do |t|
date =
case
# display today's date as "today"
when t >= Date.today then "today"
# display yesterday's date as 'Yesterday'
when (t >= Date.yesterday and t <= Date.today) then "yesterday"
# otherwise, display date: eg. Mon 4th June
else
@Bodacious
Bodacious / README.md
Created January 24, 2012 20:29
New York Address generator

NY Address Generator

60% of the time it works EVERY time!

Installing

  gem 'ny_address', git: 'git://gist.github.com/1672379.git'
@Bodacious
Bodacious / application.html.erb
Created January 18, 2012 17:25
Adding a tag cloud to your Blogit blog
...
<aside id="right">
<nav id="tag_cloud">
<h3>Browse by topic:</h3>
<% tag_cloud(tags, %w(tag1 tag2 tag3 tag4 tag5 tag6)) do |tag, tag_class| %>
<%= link_to tag.name, tagged_blog_posts_path(tag: tag.name), :class => "tag #{tag_class}" %>
<% end %>
</nav>
</aside>
@Bodacious
Bodacious / users_controller.rb
Created January 10, 2012 21:37
Build a RESTful API in Rails 3 Controller refactored: http://vimeo.com/user7965808/building-a-rest-api-in-rails-3
class UsersController < ApplicationController
# This can be moved to ApplicationController if
# every action within the application should respond to these MIME Types
respond_to :html, :json, :xml
def index
respond_with users
end
@Bodacious
Bodacious / .tm_properties
Created December 21, 2011 12:43
TextMate 2 Default Values
# ~/.tm_properties
softTabs = true
tabSize = 2
showInvisibles = true
fontName = 'Bitstream Vera Sans Mono'
fontSize = 20
spellingLanguage = 'en_GB'
@Bodacious
Bodacious / inject.rb
Created November 16, 2011 09:22
Enumerable inject
string = ["b", "c", "d"].inject("a") { |result, element| result + element }
puts string