$ cat mongo_mapper.rb
$ cat mongo_mapper.rb | ruby rewrite.rb
class Foo
include Mongoid::Document
key :name, String
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
# Search who cause the test function succeed from candidates | |
# | |
# @param [Array<T>] array of candidates | |
# @param [(Array<T>) -> bool] lambda function to test subset of candidates | |
# @return [T] last survivor against test function | |
def bisection_search(candidates, test) | |
loop do | |
head = candidates[0...candidates.length/2] | |
tail = candidates - head | |
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
# on your local machine | |
heroku run bash | |
# on one-off dyno | |
wget -O - https://github.com/sqldef/sqldef/releases/latest/download/psqldef_linux_amd64.tar.gz | tar xvz | |
./psqldef --user ${USERNAME_FROM_DATABASE_URL} --password-prompt --host ${HOSTNAME_FROM_DATABASE_URL} --export ${DATABASE_NAME_FROM_DATABASE_URL} | |
Enter Password:${PASSWORD_FROM_DATABASE_URL} |
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
#!/usr/bin/env ruby | |
require "bundler/inline" | |
gemfile do | |
source "https://rubygems.org" | |
gem "mongo_mapper" | |
end | |
# You can boot MongoDB with Docker: |
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
package main | |
import ( | |
"bufio" | |
"bytes" | |
"context" | |
"encoding/json" | |
"fmt" | |
"io" | |
"log" |
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
#!/usr/bin/env ruby | |
# c.f. https://github.com/domainersuitedev/delicious-api/blob/master/api/posts.md#v1postsall | |
# | |
# <posts tag="" user="user"> | |
# <post href="http://www.weather.com/" description="weather.com" | |
# hash="6cfedbe75f413c56b6ce79e6fa102aba" tag="weather reference" | |
# time="2005-11-29T20:30:47Z" /> | |
# ... | |
# <post href="http://www.nytimes.com/" |
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
#!/usr/bin/env ruby | |
require "bundler/inline" | |
gemfile do | |
source "https://rubygems.org" | |
gem "activesupport", "~> #{ENV["AS_VERSION"]}" | |
end | |
require "active_support" |
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 Mod | |
module A | |
def message | |
"A" | |
end | |
end | |
module B | |
def message | |
"B#{super}B" |
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> | |
<meta charset="UTF-8"> | |
<title>{{.Header.Title}}</title> | |
</head> | |
<body> | |
<h1>{{.Header.Title}}</h1> |
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
line_tracer = TracePoint.new(:line) do |tp| | |
p [tp.path, tp.lineno] | |
end | |
RSpec.configure do |config| | |
# enable for each test case | |
config.around do |example| | |
line_tracer.enable do | |
example.run | |
end |
NewerOlder