Skip to content

Instantly share code, notes, and snippets.

View RichardJordan's full-sized avatar

Richard Jordan RichardJordan

  • Los Angeles, CA
View GitHub Profile

Keybase proof

I hereby claim:

  • I am RichardJordan on github.
  • I am richardjordan (https://keybase.io/richardjordan) on keybase.
  • I have a public key whose fingerprint is 217B 1FFF 0ACF EC83 09D8 E21F 1440 73A6 F579 B5DE

To claim this, I am signing this object:

@RichardJordan
RichardJordan / ruby_block_syntax_precedence.md
Last active August 29, 2015 14:24
Ruby Block Syntax Precedence

Block syntax comes in two forms:

{}

do...end

These will behave very differently in certain contexts due to predecence and this can be a bit of a gotcha.

For example, this creates an error:

@RichardJordan
RichardJordan / prompt_rdj_setup
Last active August 29, 2015 14:13
Prompt for zshell & prezto
pmodload 'helper'
CURRENT_BG='NONE'
SEGMENT_SEPARATOR='⮀'
prompt_segment() {
local bg fg
[[ -n $1 ]] && bg="%K{$1}" || bg="%k"
[[ -n $2 ]] && fg="%F{$2}" || fg="%f"
if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
# RVM / rbenv
#
if [[ -d ~/.rvm/ ]] && [[ -d ~/.rbenv/ ]]; then
# TODO: colorize
echo '***************************************************************'
echo 'ERROR! Found both ~/.rvm & ~/.rbenv directories. You cannot use'
echo 'RVM and rbenv simultaneously. Please delete one and reload zsh.'
echo '***************************************************************'
echo ''
else
#!/usr/bin/env rake
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec => :dummy_app) do |t|
t.pattern = File.expand_path('../spec/**/*_spec.rb', __FILE__)
end
task :default => :spec
desc 'Generates a dummy app for testing'
task :dummy_app => [:setup, :migrate]
# RSpec matcher to spec delegations.
#
# Usage:
#
# describe Post do
# it { should delegate(:name).to(:author).with_prefix } # post.author_name
# it { should delegate(:month).to(:created_at) }
# it { should delegate(:year).to(:created_at) }
# end
require 'net/ftp'
CONTENT_SERVER_DOMAIN_NAME = "one-of-the-ftp-server.thought-sauce.com.hk"
CONTENT_SERVER_FTP_LOGIN = "saucy-ftp-server-login"
CONTENT_SERVER_FTP_PASSWORD = "saucy-ftp-server-password"
# LOGIN and LIST available files at default home directory
Net::FTP.open(CONTENT_SERVER_DOMAIN_NAME, CONTENT_SERVER_FTP_LOGIN, CONTENT_SERVER_FTP_PASSWORD) do |ftp|
files = ftp.list
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require_relative 'spec_helper_ar'
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
RSpec.configure do |config|
@RichardJordan
RichardJordan / helpers-all.rb
Created March 21, 2014 08:22
Adds attr instantiation and .all method to a class
module Helpers
module All
def self.included(base)
base.extend ClassMethods
end
def initialize(attributes = {})
attributes.each do |key, value|
instance_variable_set("@#{key}", value)
@RichardJordan
RichardJordan / download oracle java
Created March 18, 2014 07:52
Download oracle java for linux in deploy scripts
wget --no-check-certificate --no-cookies - --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.tar.gz