Skip to content

Instantly share code, notes, and snippets.

View timuruski's full-sized avatar
🥊
Hit. Don't get hit.

Tim Uruski timuruski

🥊
Hit. Don't get hit.
View GitHub Profile
@timuruski
timuruski / myapp
Last active August 29, 2015 14:04
Replace bulky "git-like" libraries with a directory of scripts and an entry point.
#!/usr/bin/env bash
SCRIPT="script/myapp-${1}.sh"
shift
exec ${SCRIPT} ${@}
@timuruski
timuruski / git_sred_log.sh
Last active August 29, 2015 14:08
Git SRED helper.
# 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
# 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
#! /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'
@timuruski
timuruski / vimrc
Created July 16, 2015 18:14
Vim RunCmd primer
" 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>
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)
# 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
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
---
- 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"
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