Skip to content

Instantly share code, notes, and snippets.

View fayimora's full-sized avatar
🕺

Fayi FB fayimora

🕺
  • London, England
View GitHub Profile
@fayimora
fayimora / gist:1094465
Created July 20, 2011 06:40 — forked from JosephPecoraro/shell-execution.rb
Shell Execution in Ruby
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Returns the result of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
@fayimora
fayimora / role.rb
Created February 12, 2012 18:19 — forked from mongrelion/role.rb
Dynamic Role methods for Role and User models
class Role < ActiveRecord::Base
ROLES = [ :group_admin, :agency_admin ]
# - Relationships -
has_many :user_roles
has_many :users, :through => :user_roles
# - Class Methods -
class << self
@fayimora
fayimora / post.rb
Created February 20, 2012 20:46 — forked from davidcelis/post.rb
Polymorphism 101
class Post < ActiveRecord::Base
has_many :tag_links, :as => :tags
# ...
end
@fayimora
fayimora / post.rb
Created February 23, 2012 01:04 — forked from davidcelis/post.rb
Polymorphism 101
class Post < ActiveRecord::Base
has_many :tag_links
has_many :tags, :through => :tag_links
# ...
end
@fayimora
fayimora / gfm.rb
Created February 26, 2012 15:57 — forked from mojombo/gfm.rb
require 'digest/md5'
def gfm(text)
# Extract pre blocks
extractions = {}
text.gsub!(%r{<pre>.*?</pre>}m) do |match|
md5 = Digest::MD5.hexdigest(match)
extractions[md5] = match
"{gfm-extraction-#{md5}}"
end
@fayimora
fayimora / gist:2568651
Created May 1, 2012 15:08 — 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
@fayimora
fayimora / bootstrap-plugins.txt
Created May 7, 2012 05:17 — forked from mklabs/bootstrap-plugins.txt
h5bp + twitter bootstrap integration
bootstrap-tooltip.js
bootstrap-popover.js
bootstrap-alert.js
bootstrap-button.js
bootstrap-carousel.js
bootstrap-collapse.js
bootstrap-dropdown.js
bootstrap-modal.js
bootstrap-scrollspy.js
bootstrap-tab.js

A Backbone.js demo app (Sinatra Backend)

Oct 16 2010

Updates

  • 04/10/2011 - Updated application.js and application.rb thanks to @rebo's comments

In this article, I will walk through some simple steps to get a [demo app][2] up and running with [Backbone.js][3] and [Sinatra][4] on [Heroku][5].

@fayimora
fayimora / gist:4137828
Created November 24, 2012 00:33 — forked from dahu/gist:4137807
ftplugin/help.vim
" help.vim - ftplugin for better Help navigation and operation
" Barry Arthur
" jump to links with CR
nmap <buffer> <CR> <C-]>
" jump back with BS
nmap <buffer> <BS> <C-T>
" skip to next option link
nmap <buffer> o /'[a-z]\{2,\}'<CR>
" skip to previous option link
@fayimora
fayimora / .ctags
Created November 24, 2012 10:50 — forked from anonymous/.ctags
--langdef=Scala
--langmap=Scala:.scala
--regex-Scala=/^[ \t]*class[ \t]*([a-zA-Z0-9_]+)/\1/c,classes/
--regex-Scala=/^[ \t]*object[ \t]*([a-zA-Z0-9_]+)/\1/o,objects/
--regex-Scala=/^[ \t]*trait[ \t]*([a-zA-Z0-9_]+)/\1/t,traits/
--regex-Scala=/^[ \t]*case[ \t]*class[ \t]*([a-zA-Z0-9_]+)/\1/r,cclasses/
--regex-Scala=/^[ \t]*abstract[ \t]*class[ \t]*([a-zA-Z0-9_]+)/\1/a,aclasses/
--regex-Scala=/^[ \t]*def[ \t]*([a-zA-Z0-9_=]+)[ \t]*.*[:=]/\1/m,methods/
--regex-Scala=/[ \t]*val[ \t]*([a-zA-Z0-9_]+)[ \t]*[:=]/\1/V,values/
--regex-Scala=/[ \t]*var[ \t]*([a-zA-Z0-9_]+)[ \t]*[:=]/\1/v,variables/