Skip to content

Instantly share code, notes, and snippets.

View dalibor's full-sized avatar

Dalibor Nasevic dalibor

View GitHub Profile
@dalibor
dalibor / gist:293474
Created February 3, 2010 08:26
JavaScript Micro-Templating
// Simple JavaScript Templating
// John Resig - http://ejohn.org/ - MIT Licensed
// http://ejohn.org/blog/javascript-micro-templating/
(function(){
var cache = {};
this.tmpl = function tmpl(str, data){
// Figure out if we're getting a template, or if we need to
// load the template - and be sure to cache the result.
var fn = !/\W/.test(str) ?
cache[str] = cache[str] ||
@dalibor
dalibor / require tree
Created January 31, 2010 09:05
Track requires order
$rlevel = []
alias :orig_require :require
def require(file)
puts "#{$rlevel.join}#{file}"
$rlevel << "-"
req = orig_require(file)
$rlevel.pop
req
end
@dalibor
dalibor / Gemspec file template
Created January 6, 2010 22:17
Gemspec file template
#
# Reference: http://rubygems.rubyforge.org/rdoc/Gem/Specification.html
#
# Another reference, which displays all of the defaults and shows useful
# examples: http://docs.rubygems.org/read/chapter/20
#
Gem::Specification.new do |s|
# This gem’s name. Required.
s.name = 'my-gem'
@dalibor
dalibor / Rails model without table
Created November 7, 2009 11:03
Rails model without table
#In app/models/tableless.rb
class Tableless < ActiveRecord::Base
def self.columns
@columns ||= [];
end
def self.column(name, sql_type = nil, default = nil, null = true)
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default,
sql_type.to_s, null)
end