Skip to content

Instantly share code, notes, and snippets.

@rubyisbeautiful
rubyisbeautiful / test.rb
Created February 9, 2022 21:28
Test conditional logic with/without parens
#!/usr/bin/env ruby
def is_foo(foo='bar')
foo == 'foo'
end
def is_bar(foo='bar')
foo == 'bar'
end
@rubyisbeautiful
rubyisbeautiful / changes.csv
Last active May 18, 2018 16:08
Proposed Change processes
thing currently proposed
update docs and publish to s3 change not a change
update api gateway key (generated new) change liteweight change (auto approved)
import existing api gateway key change change
@rubyisbeautiful
rubyisbeautiful / flattener.rb
Created March 3, 2018 14:45
arbitrarily nested array of integers flattener
# frozen_string_literal: true
# Will flatten an arbitrary nested array of Integer
#
# NB: I am not very happy with this solution.
# I preferred to do it in either Scala or Elm.
# I'm out of practice in Scala and still learning Elm.
# I did try to keep this "functinal thinking"
# to have a deterministic function and
# eliminate any side effects.
@rubyisbeautiful
rubyisbeautiful / gist:4945fa431d18c8703f888c8dfc9af3a9
Last active February 21, 2018 23:49 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@rubyisbeautiful
rubyisbeautiful / 01_add_cors.config.yaml
Last active April 4, 2017 21:37 — forked from vsviridov/01_add_cors.config.yaml
Add CORS to Nginx on AWS Elastic Beanstalk
# This doesn't quite work, and neither do any of the others I found.
# At EB deploy time, it generates the config found in /tmp/passenger-standalone* from a template
#
container_commands:
01_fix_static_cors:
command: "/tmp/fix_static_cors.sh"
files:
"/tmp/fix_static_cors.sh":
mode: "000755"
owner: root
@rubyisbeautiful
rubyisbeautiful / gitpr
Created May 2, 2016 15:25
git push and open PR
#!/usr/bin/env ruby
unless RUBY_PLATFORM =~ /darwin/i
puts 'This really only works on Mac I think'
exit 0
end
output = `git #{ARGV.join(' ').chomp} 2>&1`
if match = output.match(/(https:\/\/git.sabre.com\/.*compare\/.*$)/)
@rubyisbeautiful
rubyisbeautiful / get-setup.md
Created February 10, 2016 16:00
Getting setup with necessary tools

You are eventually going to be using ruby and related tools and dependent libraries. There are dozens maybe hundreds of ruby versions and interpreters. The system we use to manage this is called 'rbenv'. You need to be able to run rbenv commands from your terminal. Once rbenv is ready you have to install MRI ruby version 2.1.5.

The ruby library system is called 'gem' Since there are many thousands of gems, each with different versions, there are tools to manage this. Like maven. We (and pretty much everyone) use bundler. You specify exactly what dependencies are needed, and bundler installs them.

You often will see commands we share like 'bundle exec rake' -- on a properly setup system this will execute the command 'rake'

@rubyisbeautiful
rubyisbeautiful / force-remove-json-181.sh
Last active December 13, 2016 14:17
Force removal of JSON 1.8.1
#!/bin/bash
# TODO: get ruby version from rbenv
# TODO: match major.minor version of rbenv_ruby_version to be use in path that is hardcoded
# rbenv_ruby_version=$(rbenv local)
ruby_version="2.2.6"
ruby_path="2.2.0"
mv /apps/opt/rbenv/versions/$ruby_version/lib/ruby/gems/$ruby_path/specifications/default/json-1.8.1.gemspec /apps/opt/rbenv/versions/$ruby_version/lib/ruby/gems/$ruby_path/specifications
@rubyisbeautiful
rubyisbeautiful / test-curl-bash.sh
Created February 5, 2016 19:19
Dumb test script
#!/bin/bash
echo "oh yeah"
@rubyisbeautiful
rubyisbeautiful / force-remove-json-183.sh
Created February 5, 2016 19:17
Force removal of (default) gem son 1.8.3
#!/bin/bash
mv /apps/opt/rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/specifications/default/json-1.8.3.gemspec /apps/opt/rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/specifications
gem uninstall json -v '1.8.3'
echo "done!"