Skip to content

Instantly share code, notes, and snippets.

@T-800
T-800 / form.rb
Created March 20, 2018 09:03 — forked from igor-alexandrov/form.rb
dry-validation conditional validation
class Fund::CreateCallForm < BaseForm
property :type
property :fund
validation do
required(:type) { filled? & included_in?(TRANSACTION_TYPES['Fund::Call']) }
end
validation if: -> (results) { rebalance? } do
required(:fund).filled
@T-800
T-800 / readme.md
Created December 5, 2017 10:52 — forked from maxivak/readme.md
Integrating Gem/Engine and Main Rails App
@T-800
T-800 / application.rb
Created December 4, 2017 07:49 — forked from oki/application.rb
Disable Rails generators you don't need :)
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)
module FooBar
class Application < Rails::Application
@T-800
T-800 / fixup.txt
Created October 10, 2017 10:59 — forked from lucasdavila/fixup.txt
Fixing mac os yosemite issue "bash: fork: Resource temporarily unavailable"
# see the current limits
$ sysctl -a | grep maxproc
# increase it
$ sudo sysctl -w kern.maxproc=xxxx
$ sudo sysctl -w kern.maxprocperuid=xxx
# run at startup
$ sudo vim /etc/sysctl.conf
@T-800
T-800 / chrome_driver_path
Created September 29, 2017 08:11 — forked from mubbashir/chrome_driver_path
setting up chrome-driver path in ruby
require 'selenium-webdriver'
Selenium::WebDriver::Chrome.driver_path="/path/to/chrome_driver_binary/chromedriver"
driver = Selenium::WebDriver.for :chrome
driver.get("http://google.com")
@T-800
T-800 / s3Sync.sh
Created September 28, 2017 08:43 — forked from kellyrmilligan/s3Sync.sh
Sync files to s3 and set cache control headers
#!/bin/bash
if [[ "$1" != "" ]]; then
S3BUCKETNAME="$1"
else
echo ERROR: Failed to supply S3 bucket name
exit 1
fi
aws s3 sync build s3://$S3BUCKETNAME --delete --cache-control max-age=31536000,public
@T-800
T-800 / gist:a9fd7de6b9736155e5169f074cce622b
Created August 16, 2017 08:58 — forked from hirakiuc/gist:bcb7991ff3b01405f4f2
StringIO with binary in ruby
require 'stringio'
# Create StringIO object from binary data file
StringIO.new(File.binread('pict.jpg'), 'rb')
# Create StringIO object from text data file
StringIO.new(File.read('memo.txt', encoding: Encoding::UTF_8), 'r')