Skip to content

Instantly share code, notes, and snippets.

View mynameisrufus's full-sized avatar

Rufus Post mynameisrufus

View GitHub Profile
@mynameisrufus
mynameisrufus / ansible-tower-backup-pull.yml
Created December 2, 2015 01:43
Migration of Ansible Tower 2.1.2 to 2.4.1 with large database
---
# This orchestration will perform a backup of a Tower machine and pull the
# backup files down to a bastion server for use with a later restore.
#
# http://docs.ansible.com/ansible-tower/latest/html/installandreference/upgrade_tower.html
# https://support.ansible.com/hc/en-us/articles/203295497-Tower-Manual-Backup-Restore
- name: Pull Ansible Tower backup
hosts: tower
def putin(_o); puts "You dont put Putin.\nPutin puts you..."; nil; end
@mynameisrufus
mynameisrufus / Vagrantfile
Last active July 15, 2016 19:31
Vagrant dynamic port mapping
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
# Load mappings.yml
MAPPINGS = YAML.load_file('mappings.yml')
@mynameisrufus
mynameisrufus / Gemfile
Last active August 29, 2015 14:04
Optimistic locking in Grape
source 'http://rubygems.org'
gem 'grape'
@mynameisrufus
mynameisrufus / binstub.sh
Created January 31, 2014 00:58
Use binstub for ruby project.
export PATH="./bin:$PATH"
bundle install --path=.gems --binstubs=.bin
@mynameisrufus
mynameisrufus / m3uSupport.js
Last active December 21, 2015 03:59
Detect m3u streaming support.
// Detect m3u support
//
// Mime type found here:
// http://developer.apple.com/library/ios/documentation/networkinginternet/conceptual/streamingmediaguide/DeployingHTTPLiveStreaming/DeployingHTTPLiveStreaming.html
//
var testEl = document.createElement('audio'), supported
supported = testEl.canPlayType('audio/x-mpegurl') != ""
@mynameisrufus
mynameisrufus / mario.rb
Created July 30, 2013 09:37
Using cache with data you don't know has changed or not.
class Mario
def initialize data_hash
@data_hash = data_hash
end
def cache_key
Digest::MD5.hexdigest @data_hash.to_s
end
end
### Problem, rigid dependency injection ###
class Demo
def initialize
@instancev = Something.new
end
def method_1
do_that
@instancev.something
end
@mynameisrufus
mynameisrufus / ARDirty.rb
Created May 29, 2012 10:06
Using AR dirty to log changes from a controller
@foo.attributes = params[:foo]
if @foo.changed?
@foo.changes.each do |change|
# do something with the current_user
end
end
@foo.save
@mynameisrufus
mynameisrufus / js.rb
Created May 16, 2012 01:02
After months of JS
def foo
Foo.new do |f|
f.thing &bar
end
end
def bar
proc do |thing|
thing.title = "woop"
thing.time = Time.now