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
person = { | |
save: function(){ | |
$.ajax('...', { | |
context: this, | |
success: this.saved, | |
error: this.errored | |
}) | |
}, | |
saved: function(data){ | |
console.log('OMG. USEFUL SCOPING.') |
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
// iOS Media Queries | |
// Goal: capture styles for iPhone, iPhone 3G, iPhone 3GS, iPhone 4, iPhone 4S, iPad, and iPad 2 | |
// | |
// Author: Tony Schneider (@tonywok) | |
// Please tell me where I fail. :) | |
// iPhone v(4,4S) portrait | |
// test: black text (overwritten by v* portrait) with blue background | |
@media all and (-webkit-min-device-pixel-ratio: 2) and (orientation: portrait) { | |
a { |
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
#include <stdlib.h> | |
#include <stdio.h> | |
int(*outer(int val))() { | |
int inner() { | |
return val; | |
} | |
return inner; | |
} |
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
require 'test/unit' | |
require File.expand_path(File.dirname(__FILE__) + '/../lib/calculator') | |
class CalculatorTest < Test::Unit::TestCase | |
def test_default_value | |
calc = Calculator.new | |
assert_equal 0, calc.value | |
end | |
def test_setting_initial_value |
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
def error_messages_for(*objects) | |
options = objects.extract_options! | |
options[:header_message] ||= I18n.t(:"activerecord.errors.header", :default => "Invalid Fields") | |
options[:message] ||= I18n.t(:"activerecord.errors.message", :default => "Correct the following errors and try again.") | |
messages = objects.compact.map { |o| o.errors.full_messages }.flatten | |
unless messages.empty? | |
content_tag(:div, :class => "error_messages") do | |
list_items = messages.map { |msg| content_tag(:li, msg) } | |
content_tag(:h2, options[:header_message]) + content_tag(:p, options[:message]) + content_tag(:ul, list_items.join.html_safe) | |
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 Hello() | |
{ | |
alert("caller is " + arguments.callee.caller.toString()); | |
} | |
arguments.callee.caller.name |
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
My annual reread book is The School of Niklaus Wirth: The Art of Simplicity | |
Others I love: | |
Compiler Construction, Wirth | |
Effective TCP/IP Programming: 44 Tips to Improve Your Network Programs | |
C Programming Language | |
The Annotated C++ Reference Manual (first and last good book on C++, besides meyers) | |
Structure and Interpretation of Computer Programs | |
The Little Schemer, The Seasoned Schemer, (and probably Reasoned Schemer, but I haven't gotten through that yet). |
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
# autoload concerns | |
module YourApp | |
class Application < Rails::Application | |
config.autoload_paths += %W( | |
#{config.root}/app/controllers/concerns | |
#{config.root}/app/models/concerns | |
) | |
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
# This is just an hint for a simple Redis caching "framework" using Sinatra | |
# A friend of mine asked for something like that, after checking the first two gems realized there was | |
# a lot of useless complexity (IMHO). That's the result. | |
# | |
# The use_cache parameter is useful if you want to cache only if the user is authenticated or | |
# something like that, so you can do cache_url(ttl,User.logged_in?, ...) | |
require 'rubygems' | |
require 'sinatra' | |
require 'redis' |
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
require 'ruby-debug'; Debugger.start; Debugger.settings[:autoeval] = 1; Debugger.settings[:autolist] = 1; debugger |