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
# First iteration of Ad | |
class Ad | |
attr_accessor :message | |
def view | |
"For sale #{message} call #{owner.name}" | |
end | |
end # Ad |
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
require 'delegate' | |
require 'oj' | |
require 'strscan' | |
# JSONPath like access to Oj JSON structs. | |
# | |
# @note Array access is identical to Array#[] | |
class Oj::Path < SimpleDelegator | |
class Error < StandardError; end | |
class MissingError < Error; 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
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.host; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#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
(function ($) { | |
var providers = {}; | |
/* | |
Given a URL find a provider that can OEmbed the url given. | |
*/ | |
function find (url) { | |
var site = url.match(/^https?:\/\/([^/]+)/)[1]; | |
for (var domain in providers) | |
if (site.indexOf(domain) > -1) |
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
#pragma once | |
#include <iostream> | |
#include <sstream> | |
#include <string> | |
template<typename T> | |
T string_to(const std::string& p_string) { | |
std::istringstream iss(p_string); | |
T x; |
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
<?php | |
# Mysql | |
# | |
# require_once('mysql.php'); | |
# $db = new Mysql(dbname, server, user, pass); | |
# $sth = $db->query('select * from blah where name = ? limit 1', 'fred') || die($db->error()); | |
# while ($row = mysql_fetch_assoc($sth)) | |
# ... | |
# |
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
/ | |
/bin | |
#{project} | |
#{project}-cli | |
#{project}-db | |
#{project}-job | |
#{project}-web | |
#{project}-config | |
... | |
* We stole the CLI command hierarchy from git. E.g. ./bin/project web (start|stop|status) [options] |
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
$ cd /usr/src | |
$ wget http://nginx.org/download/nginx-0.8.52.tar.gz | |
$ tar xzvf ./nginx-0.8.52.tar.gz | |
$ rm ./nginx-0.8.52.tar.gz | |
$ gem install s3sync capistrano capistrano-ext passenger --no-ri --no-rdoc | |
$ passenger-install-nginx-module | |
# Automatically download and install Nginx? 2. No: I want to customize my Nginx installation | |
# Where is your Nginx source code located?: /usr/src/nginx-0.8.52 | |
# Where do you want to install Nginx to?: /opt/nginx |
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
require 'sinatra/base' | |
require 'rack/utils' | |
module Sinatra | |
class Base | |
module Map | |
def map path, klass | |
path = map_compile path | |
[:get, :put, :post, :delete, :head].each do |verb| | |
send(verb, path) do |
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
require 'set' | |
#==== See | |
# * http://github.com/matpalm/resemblance | |
class String | |
module Shingles | |
N_GRAM_LENGTH = 3 | |
def shingles | |
@shingles ||= -> do |