Skip to content

Instantly share code, notes, and snippets.

View abitdodgy's full-sized avatar
😃
Out to lunch!

Mohamad El-Husseini abitdodgy

😃
Out to lunch!
View GitHub Profile
@abitdodgy
abitdodgy / creating_a_chef_kitchen.md
Last active August 29, 2015 13:58
Creating a chef recipe.

Creating a New Chef Kitchen

A kitchen is a collection of recipes associated with a deployment. For example, a kitchen can contain cookbooks for installing Ruby, MySQL, and nginx.

knife init solo kitchen_name

This will create the necessary stucture for the kitchen.

@abitdodgy
abitdodgy / email_address.rb
Created January 29, 2015 18:15
EmailAddress class with unit tests.
require "i18n"
class EmailAddress
VALID_EMAIL_ADDRESS_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
def self.malformed?(email)
email !~ VALID_EMAIL_ADDRESS_REGEX
end
def self.valid?(email)
@abitdodgy
abitdodgy / _flash.html.erb
Last active August 29, 2015 14:14
An application.html.erb layout file for Rails 4 to use with Sublime Text's Insert Gist feature
<% flash.each do |key, message| %>
<%= content_tag :div, class: "alert alert-full-page alert-#{key} alert-dismissable", role: "alert" do %>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<%= message %>
<% end %>
<% end %>
@abitdodgy
abitdodgy / turbolinks_example.js
Created April 18, 2015 15:19
Turbolinks example. Binding on document.ready and page:change.
@abitdodgy
abitdodgy / documents.rb
Last active August 29, 2015 14:23 — forked from dhh/documents.rb
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
- provide :title, ts(:title)
- page_header :projects
= form_for [@workspace, @project, Upload.new], html: { class: 'form-horizontal' } do |f|
div class="panel panel-default panel-upload"
/ div class="panel-heading"
div class="panel-title" Upload Files
/ div class="panel-body text-center"
@abitdodgy
abitdodgy / Heroku_Staging.md
Last active August 29, 2015 14:27 — forked from stevenyap/Heroku_Staging.md
Staging workflow on Heroku

This describes the workflow to use Heroku as a staging environment. It assumes you already have an existing heroku app in production.

# rename your git remote heroku to something else like production
git remote rename heroku production

# so now you will push as: git push production master

# create the staging app
heroku apps:create staging-appname
@abitdodgy
abitdodgy / gist:4007431
Created November 3, 2012 13:50 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@doc ~s"""
Takes a string and an atom that refers to any function name in `Gibran.Counter`.
It tokenises the string, then applies the given function to the resulting tokens. The function
name must be an `atom`. You can pass a list of options to the tokeniser as `opts` and a list
of options to the receiving function as `fn_opts`.
For example, the following two calls are equivalent:
Gibran.from_string("The Prophet", :token_count)