Skip to content

Instantly share code, notes, and snippets.

View ootoovak's full-sized avatar

Juna Ootoovak ootoovak

View GitHub Profile
@ootoovak
ootoovak / gem_leaderboard.rb
Created November 23, 2011 04:04
Place in your a directory with Bundler projects and run to create a leaderboard of your Gems.
#!/usr/bin/ruby -w
puts "Counting your gems ..."
gems = {}
project_folders = Dir.entries(".").select{ |d| d !~ /^\..*/ && !File.file?(d) }
project_folders.each do |folder|
Dir.chdir(folder) do
if File.exists?('Gemfile') && File.file?('Gemfile')
@ootoovak
ootoovak / carousel.rb
Created May 17, 2012 23:08
1D Packing Problem - Recursive Solution
@ootoovak
ootoovak / buckybackup
Created June 6, 2012 23:04
backup bucky
#!/bin/sh
BACKUPDIR=/Users/developer/backup/bucky/production/
DAYSTAMP=`date "+%d"`
HOURSTAMP=`date "+%H"`
DAYFILE="daily_$DAYSTAMP.dump"
HOURFILE="hourly_$HOURSTAMP.dump"
DAYPATH=$BACKUPDIR$DAYFILE
HOURPATH=$BACKUPDIR$HOURFILE
@ootoovak
ootoovak / tb_fluid_inside_static.haml
Created September 1, 2012 07:11
Twitter Bootstrap Fluid Inside Static
%body
.container
.row
.span2
.span10
.container-fluid
.row-fluid
.span3
.span3
.row-fluid
@ootoovak
ootoovak / fast_spec_helper.rb
Last active December 13, 2015 17:48
Something I'm working with at the moment. WIP
require 'active_attr'
RELATIVE_APP_PATH = File.expand_path("../../app", __FILE__)
def construct_require_path(middle_path, name)
"#{RELATIVE_APP_PATH}/#{middle_path}/#{name}.rb"
end
def require_model(name)
require construct_require_path('models', name)
@ootoovak
ootoovak / example_usage.rb
Created May 21, 2013 00:02
Helper methods to load as few files as possible to get tests to run. Some create require paths to load files and others to init required constants.
require 'fast_spec_helper'
require 'date'
require_model 'generate_required_daily_lists'
required_constants %w(Distributor PackingList DeliveryList)
---- OR ----
require 'fast_spec_helper'
require_model 'exporter', sub_dir: 'sales_csv'
require_model 'delivery_exporter', sub_dir: 'sales_csv'
@ootoovak
ootoovak / Problem.rb
Last active December 18, 2015 16:29
Don't recreate another object if you don't need to.
# Want to pass in a hash or instance of object. Was hoping to avoid is_a? or creating a new object but
# think that can only be done with is_a? or overriding new. Also, I might be missing the point as
# avoiding is_a? should mean I am using Duck Typing but if I'm using Duck Typing then I shouldn't be
# checking object equality anyway. See RSpec test for details.
describe MyClass do
let(:hash) { { name: 'Duck Type', description: 'Quacks like a duck?' } }
before do
@my_instance_1 = MyClass.new(hash)
@ootoovak
ootoovak / Learn Rails And Ruby Resources.md
Last active December 19, 2015 17:18
Learn Rails And Ruby
@ootoovak
ootoovak / capybara cheat sheet.rb
Last active December 19, 2015 17:19 — forked from zhengjia/capybara cheat sheet
Capybara Cheat Sheet
# Navigating
visit('/projects')
visit(post_comments_path(post))
# Clicking links and buttons
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
@ootoovak
ootoovak / essential_internet_tools.md
Last active December 23, 2015 23:09
Essential Internet Tools: Protect yourself from the horrors of the internet.