Skip to content

Instantly share code, notes, and snippets.

@mydiemho
mydiemho / gist:98a8340438a2ef326b36dacb17da08cd
Created July 17, 2017 22:09 — forked from jmtame/gist:6458832
ruby blocks and yield explained by a bloc mentor

The following is an explanation of Ruby blocks and yield by another Bloc mentor (Adam Louis) who was trying to explain it to one of his students.

On my very first day programming, if someone asked me for "the sum of the numbers from 1 to 10", I'd have written:

puts 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10

Easy enough.

@mydiemho
mydiemho / gist:91fb262c0ba68b2d1b89b4ab72180e0f
Created November 4, 2016 20:04 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@mydiemho
mydiemho / fizzbuzz_modulo.py
Created June 30, 2016 04:48 — forked from curtisforrester/fizzbuzz_modulo.py
Python FizzBuzz with modulo comparisons
import cProfile
import pstats
import StringIO
pr = cProfile.Profile()
pr.enable()
iNot = set()
iFizz = set()
iBuzz = set()
@mydiemho
mydiemho / fizzbuzz_sets.py
Created June 30, 2016 04:47 — forked from curtisforrester/fizzbuzz_sets.py
Python FizzBuzz with lookup sets
import cProfile
import pstats
import StringIO
pr = cProfile.Profile()
pr.enable()
threes = {num for num in range(3, 100, 3)}
fives = {num for num in range(5, 100, 5)}
not_in = {num for num in range(1, 100) if num not in threes and num not in fives}