brew update brew install postgresql
Create a database:
initdb /usr/local/var/postgres
If this is your first install, automatically load on login with:
mkdir -p ~/Library/LaunchAgents
# usage: | |
# it "should return a result of 5" do | |
# eventually { long_running_thing.result.should eq(5) } | |
# end | |
module AsyncHelper | |
def eventually(:options = {}) | |
timeout = options[:timeout] || 2 | |
interval = options[:interval] || 0.1 | |
time_limit = Time.now + timeout | |
loop do |
require 'active_record/connection_adapters/abstract/transaction' | |
module ActiveRecord | |
module ConnectionAdapters | |
class SavepointTransaction < OpenTransaction | |
def perform_commit_with_transactional_fixtures | |
commit_records if number == 1 | |
perform_commit_without_transactional_fixtures | |
end | |
alias_method_chain :perform_commit, :transactional_fixtures |
module Wysihtml5Helper | |
def fill_in_wysihtml5(text) | |
#js must be enabled | |
page.execute_script("editor.setValue('#{text}')") | |
end | |
end |
require "spec_helper" | |
describe ExampleController do | |
context "GET #index" do | |
let(:resources) { FactoryGirl.create_list(:resource) } | |
before do | |
get :index | |
end |
class EmailValidator < ActiveModel::EachValidator | |
require 'resolv' | |
def validate_each(record, attribute, value) | |
unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i | |
record.errors[attribute] << (options[:message] || I18n.t('email.wrong')) | |
end | |
split_email = value.split("@") | |
domain = split_email[1].to_s |
# https://minhajuddin.com/2016/03/03/put-this-in-your-code-to-debug-anything | |
require 'rouge' | |
require 'method_source' | |
require 'pp' | |
class Dbg | |
def initialize(object, to:) | |
@object, @stream = object, to | |
end |
defmodule SqlParser do | |
def run() do | |
input = "select col1 from ( | |
select col2, col3 from ( | |
select col4, col5, col6 from some_table | |
) | |
) | |
" | |
IO.puts("input: #{inspect(input)}\n") | |
IO.inspect(parse(input)) |