This file contains 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 Module | |
alias_method :include_without_hooks, :include | |
def include(*modules) | |
include_before_hook(*modules) | |
include_without_hooks(*modules) | |
include_after_hook(*modules) | |
end | |
def include_before_hook(*modules) |
This file contains 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
/* Example DataDapper Model */ | |
class User { | |
struct Properties { | |
DD_Property!(int,"id") id; | |
DD_Property!(string,"username") username; | |
DD_Property!(double,"score") score; | |
} | |
Properties properties; |
This file contains 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
import std.stdio; | |
class KdTree { | |
private int _dimensions; | |
int dimensions() { | |
return _dimensions; | |
} | |
KdNode *rootNode; |
This file contains 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
# anybody already using an Object monkey-patch like the one below: | |
class Object | |
def send_chain(v) | |
this = self | |
v.each { |k| this = this.send(*k) } | |
this | |
end | |
end |
This file contains 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
> ruby -rmath_functions.rb -e "puts MathFunctions.factorial(2)" | |
2 | |
> ruby --test -rmath_functions.rb | |
. | |
Finished in 1.000706 seconds. | |
1 tests, 2 assertions, 0 failures, 0 errors |
This file contains 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 MappedProperty | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def mapped_property(name, geocoder = "Location") | |
class_eval <<-END, __FILE__, __LINE__ | |
property :#{name}, String | |
property :#{name}_lng, Float |
This file contains 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
Lacking a social network that leaves us: | |
1. owners of our own content, | |
2. managers of own privacy, and | |
3. just as capable of discovering the serendipities within our social graph. | |
We set forth to build an online network that: | |
1. decentralizes the control of content by placing it firmly with its | |
individual users, |
This file contains 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 ApplicationController < ActionController::Base | |
before_filter :compound_date_values | |
protected | |
def compound_date_values(h=params,prefix=[]) | |
to_fix = {} | |
h.each do |k, v| | |
if v.is_a? Hash |
This file contains 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
def is_ajax_request? | |
if respond_to? :content_type | |
if request.xhr? | |
true | |
else | |
false | |
end | |
else | |
false | |
end |
This file contains 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 Jekyll | |
require 'haml' | |
class HamlConverter < Converter | |
safe true | |
priority :low | |
def matches(ext) | |
ext =~ /haml/i | |
end |
OlderNewer