This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Commit < Struct.new(:path) | |
class << self | |
def all | |
commits = `git log --decorate --pretty=oneline` | |
[].tap do |refs| | |
commits.split(/\n/).each do |commit| | |
refs << Commit.new(commit) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Taken from http://coderrr.wordpress.com/2008/04/22/building-the-right-class-with-sti-in-rails/ | |
class GenericClass < ActiveRecord::Base | |
class << self | |
def new_with_cast(*a, &b) | |
if (h = a.first).is_a? Hash and (type = h[:type] || h['type']) and (klass = type.constantize) != self | |
raise "wtF hax!!" unless klass < self # klass should be a descendant of us | |
return klass.new(*a, &b) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$.extend($, { | |
updateContent : function updateContent(event, newContent) { | |
var $contentKeyElements = $(newContent).filter('[data-content-key]'); | |
$contentKeyElements.each(function() { | |
var contentKey = $(this).attr("data-content-key"); | |
$("[data-content-key=" + contentKey + "]").html($(this).html()); | |
}); | |
$(document).trigger('content-updated'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AdminController < ApplicationController | |
before_filter do |controller| | |
controller.redirect_to login_path unless logged_in? | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass | |
def self.my_method | |
100.times do |index| | |
yield 100, index + 1 if block_given? | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Davids-MacBook-Pro:blog daviddotterweich$ git.add | |
-bash: git.add: command not found | |
Davids-MacBook-Pro:blog daviddotterweich$ git. | |
-bash: git.: command not found | |
Davids-MacBook-Pro:blog daviddotterweich$ git. add | |
-bash: git.: command not found | |
Davids-MacBook-Pro:blog daviddotterweich$ git | |
usage: git [--version] [--exec-path[=<path>]] [--html-path] | |
[-p|--paginate|--no-pager] [--no-replace-objects] | |
[--bare] [--git-dir=<path>] [--work-tree=<path>] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var vm = require('vm'); | |
var emberjs = fs.readFileSync('public/javascripts/vendor/ember-0.9.5.min.js', 'utf8'); | |
var templatesDir = 'templates'; | |
var destinationDir = 'public/javascripts/templates'; | |
function compileHandlebarsTemplate(templatesDir, fileName) { | |
var file = templatesDir + '/' + fileName; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Solar Sound Inc | Entertainment </title> | |
<%= stylesheet_link_tag "application" %> | |
<%= javascript_include_tag "application" %> | |
<%= csrf_meta_tags %> | |
<style type="text/css"> | |
body { | |
padding-top: 60px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Foo | |
class Bar | |
end | |
private_constant :Bar | |
end | |
module Foo | |
p Bar.new # => works fine because we're scoped to Foo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gemfile.lock | |
junk.* |