Skip to content

Instantly share code, notes, and snippets.

View thepug's full-sized avatar

Nathan Zorn thepug

View GitHub Profile
@thepug
thepug / collatz.rb
Created October 10, 2017 16:29 — forked from trishume/collatz.rb
Collatz conjecture chains in ruby
# small recursive version
def collatzr(num,arr = [])
return arr if arr.unshift(num)[0] == 1
num.even? ? collatzr(num / 2,arr) : collatzr(num * 3 + 1,arr)
end
# pretty looping version
def collatz(num,arr = [])
while num != 1
arr << num
num = num.even? ? num / 2 : num * 3 + 1
@thepug
thepug / imgblur-refactor.rb
Created August 31, 2017 15:37 — forked from spilledmilk/imgblur-refactor.rb
Refactored code for Image Blur challenges (incl. Manhattan Distance)
class Image
attr_accessor :array
def initialize(array)
@array = array
end
def blur(distance = 1)
distance.times do
transform
@thepug
thepug / fabfile.py
Created March 20, 2012 14:24 — forked from cyberdelia/fabfile.py
Fabric deploy script with : south migrations, rollback and maintenance page.
from fabric.api import env, run, sudo, local, put
def production():
"""Defines production environment"""
env.user = "deploy"
env.hosts = ['example.com',]
env.base_dir = "/var/www"
env.app_name = "app"
env.domain_name = "app.example.com"
env.domain_path = "%(base_dir)s/%(domain_name)s" % { 'base_dir':env.base_dir, 'domain_name':env.domain_name }