Skip to content

Instantly share code, notes, and snippets.

View rjsamson's full-sized avatar

Robert J Samson rjsamson

View GitHub Profile

Keybase proof

I hereby claim:

  • I am rjsamson on github.
  • I am rjs (https://keybase.io/rjs) on keybase.
  • I have a public key whose fingerprint is B1FC CB7B 03E4 CF72 3329 82F2 FB0D 66B6 B800 4318

To claim this, I am signing this object:

@rjsamson
rjsamson / RealmResultsHelpers.swift
Last active August 29, 2015 14:18
Extension for RLMResults to provide take(limit: Int) and toArray()
import Realm
extension RLMResults {
func take (limit: Int) -> [RLMObject] {
var array = [RLMObject]()
let indices: UInt = limit < Int(self.count) ? UInt(limit) - 1 : self.count - 1
for index in 0...indices {
array.append(self[index] as RLMObject)
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
)
func main() {
@rjsamson
rjsamson / gist:3929092
Created October 22, 2012 00:37
rvm rbx-head install --trace (zsh)
rbx-head --trace
rvm 1.16.15 (master) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
+__rvm_parse_args:639> [[ -n 4.3.11 ]]
+__rvm_parse_args:674> [[ -z reinstall ]]
+__rvm_parse_args:677> [[ error == reinstall || 0 -eq 1 || -n '' ]]
+__rvm_parse_args:16> [[ -n '' ]]
+__rvm_parse_args:682> : rvm_ruby_args:0::
+__rvm_parse_args:684> [[ -n '' ]]
@rjsamson
rjsamson / test_substr.rb
Created November 3, 2012 14:02
Illustration of Rubinius Encoding Issues with Substring Ranges
puts "Substring Range Test"
str = "utf-8 character (\u20AC) in a utf-8 string"
str2 = "normal ASCII-ONLY string"
puts "str: #{str}"
puts "str2: #{str2}"
puts "str[1...-1]: #{str[1...-1]}" # => "tf-8 character (€) in a utf-8 string"
puts "str2[1...-1]: #{str2[1...-1]}" # => "ormal ASCII-ONLY Strin"
@rjsamson
rjsamson / test.rb
Created November 3, 2012 13:49
Illustration of Rubinius Encoding Issues with String Interpolation
str = "a utf-8 string (\u20AC) with utf-8 chars".force_encoding("utf-8")
str2 = "This string is #{str} but looks like ascii-only"
puts "str: #{str}"
puts "str.ascii_only?: #{str.ascii_only?}" # => false
puts "str2: #{str2}"
puts "str2 encoding: #{str2.encoding}" # => UTF-8
puts "str2.ascii_only?: #{str2.ascii_only?}" # => true
puts "str2.dup.ascii_only?: #{str2.dup.ascii_only?}"
puts "<< broken encoding:"
str3 = "an ascii string with "
/lib/vagrant-digitalocean/actions/create.rb:98:in `terminate': uninitialized constant VagrantPlugins::DigitalOcean::Actions::Create::ActionDispatch (NameError)
from /Users/rjsamson/.vagrant.d/gems/gems/vagrant-digitalocean-0.0.4/lib/vagrant-digitalocean/actions/create.rb:89:in `recover'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.0/lib/vagrant/action/warden.rb:66:in `block in recover'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.0/lib/vagrant/action/warden.rb:63:in `each'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.0/lib/vagrant/action/warden.rb:63:in `recover'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.0/lib/vagrant/action/warden.rb:52:in `rescue in call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.0/lib/vagrant/action/warden.rb:28:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.0/lib/vagrant/action/builder.rb:109:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.0/lib/vagrant/action/runner.rb
Bringing machine 'default' up with 'digital_ocean' provider...
[default] Creating the droplet ...
[default] Waiting for the droplet to become active (>= 1 min) ...
[default] Making alterations to the sudoers file where necessary ...
[default] Creating user 'vagrant' and setting password ...
[default] Enabling sudo for user 'vagrant' ...
[default] Adding public key to authorized_keys ...
[default] Installing provisioner: chef-solo (>= 2 min) ...
[default] Droplet IP: 198.211.XXX.XXX ...
[default] Host IP: 192.168.1.10 ...
@rjsamson
rjsamson / Gemfile
Created October 29, 2013 15:56
Todo App Gemfile and Rakefile
source "https://rubygems.org"
ruby "2.0.0"
gem "ProMotion", "~> 1.0.4"
gem "teacup"
gem 'formotion'
gem 'motion_data_wrapper'
gem "sugarcube", :require => 'sugarcube-all'
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"math/rand"
"net/http"
"strconv"