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 'mongoid' | |
require 'minitest' | |
require 'minitest/autorun' | |
class Foo | |
include Mongoid::Document | |
field :x, type: Integer | |
field :y, type: Integer | |
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 docs = []; | |
for(var i = 0; i < 20000; i++) { | |
docs.push({rnd: _rand(), t: "2013-06-23", N:7*i, A:1, V:0, n:"1234"}); | |
} | |
docs.sort(function(a, b) { | |
return a.rnd - b.rnd; | |
}); | |
var t0 = Date.now(); | |
db.foos.insert(docs); |
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 Post < ActiveRecord::Base | |
attr_accessible :body, :price, :title | |
validates_presence_of :title | |
validates_length_of :title, minimum: 10 | |
validates_presence_of :body | |
validates_numericality_of :price, greater_than: 0 | |
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
#!/usr/bin/env ruby | |
# encoding: UTF-8 | |
require 'nokogiri' | |
require 'open3' | |
html = Open3.popen2('redcarpet') do |stdin, stdout| | |
stdin.write(STDIN.read) | |
stdin.close |
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 'tempfile' | |
require 'debugger' | |
DEBUGGER_MONKEY_PATCH = <<'EOF' | |
module Debugger | |
class << self | |
def stop_remote | |
return unless @thread || @control_thread | |
@stopped = true |
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! Rtest() | |
ruby <<END | |
line = $curbuf.line | |
fn = nil | |
if line =~ /^\s*test\s+["']([^"']+)["']\s+do/ | |
fn = "test_#{$1.gsub(/ /, '_')}" | |
elsif line =~ /^\s*def\s+(test_.+)/ | |
fn = $1 | |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="require.js"></script> | |
<script> | |
require(['jquery', 'underscore', 'backbone'], | |
function($) | |
{ | |
var UBlog = {}; |
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
# Usage: | |
# In premake4.lua use StaticLib for libraries; ConsoleApp for applications. | |
# Then run `rake xcode && rake xcodebuild` | |
ENV_DEFAULTS = { | |
'CONFIGURATION' => "Debug", | |
'SDK' => "iphonesimulator", | |
} | |
SDK_TO_ARCH = { |
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
{-# LANGUAGE RecordWildCards #-} | |
{-# LANGUAGE NamedFieldPuns #-} | |
-- Chris Yuen <chris@kizzx2.com> | |
-- ITA Software's "Word Numbers" puzzle (http://www.itasoftware.com/careers/puzzle_archive.html) | |
import Data.Function | |
import Data.List | |
-- | For this problem we'll trie like structure. An "umbrella" value is |
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
-- Solitaire Cipher | |
-- http://www.rubyquiz.com/quiz1.html | |
module Solitaire where | |
import Data.Sequence ((><), (|>), (<|)) | |
import qualified Data.Sequence as S | |
import Debug.Trace | |
import Control.Arrow |