This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
SCRIPT="script/myapp-${1}.sh" | |
shift | |
exec ${SCRIPT} ${@} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In your .gitconfig add this alias: | |
# [alias] | |
# sred = "!source ~/.git_sred_log && sred_log" | |
# Assumes input date is formatted as YYYY-MM-DD, | |
# passes additional arguments to git-log. | |
sred_log() { | |
sred_date="${1:-$(date +"%Y-%m-%d")}" | |
shift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generates combinations of letters or numbers, or anything really. The combinations | |
# include repeating values, unlike Ruby's regular Array#permutation method. | |
# | |
# Usage: | |
# generate('a'..'c', 3) do |seq| | |
# puts seq.inspect #=> [a,a,a], [a,a,b], [a,a,c], [a,b,a]... | |
# end | |
def generate(range, comb_len) | |
range = range.to_a | |
range_len = range.length |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
# Not guaranteed to work. | |
require 'fileutils' | |
require 'pathname' | |
root = Pathname.new %x(git rev-parse --show-toplevel) | |
podfile_path = root + 'Podfile.lock' | |
pods_path = root + 'Pods' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Usage: To execute a Ruby file with some library included | |
" :RunCmd ruby -i lib/my_lib | |
" Then you can run your script by pressing <leader>r | |
command! -nargs=1 RunCmd nnoremap <leader>r :w \| !clear; <args> % <CR> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TanksForAllTheFish < RTanque::Bot::Brain | |
NAME = 'Tanks For All the Fish' | |
MAX_RANGE = 400.0 | |
include RTanque::Bot::BrainHelper | |
def tick! | |
if targets_nearby? | |
command.speed = 2.0 | |
command.heading = Random.rand(-1.0..1.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Proof of concept | |
e = 2 | |
c = 10**e | |
amt = 5.67 | |
amt_i = (amt * c).to_i | |
amt_f = amt_i.to_f / c | |
tax = 11 | |
tax_f = tax.to_f / 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_random_person | |
slug = $person_count.inc! | |
name = random_name | |
puts "Creating #{name} - #{slug}" | |
person = Person.create!( :slug => slug, :name => name, :TMP => true ) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- score: 5.0090723 | |
title: Buffy the Vampire Slayer | |
first_air_date: 1997-03-10 19:00:00 Z | |
last_air_date: 2001-05-15 18:00:00 Z | |
mid: 144z | |
external_ids: | |
thetvdb: "70327" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kernel | |
# Returns the object's singleton class. | |
def singleton_class | |
class << self | |
self | |
end | |
end unless respond_to?(:singleton_class) # exists in 1.9.2 | |
end |