- Email: mburns@thoughtbot.com
- Twitter: @mikeburns
- Website or Blog: http://mike-burns.com
- Company: thoughtbot
This file contains hidden or 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 Monoid | |
| attr_accessor :value | |
| def initialize(value) | |
| @value = value | |
| end | |
| def self.base | |
| new(const_get(:BASE)) | |
| end |
This file contains hidden or 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
| #!/bin/sh | |
| entry_text=`pwd` | |
| location=`zenity --file-selection --directory --filename=$entry_text --title="Open location"` | |
| if [ "x$?" = "x0" ]; then | |
| xdg-open "$location" | |
| fi |
This file contains hidden or 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 IsFibber | |
| def fibonacci?(n) | |
| perfect_square?(5 * n * n + 4) || perfect_square?(5 * n * n - 4) | |
| end | |
| private | |
| def perfect_square?(f) | |
| sqrt = Math.sqrt(f) | |
| sqrt == sqrt.round |
This file contains hidden or 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
| #!/bin/sh | |
| desktop=`xdotool get_desktop` | |
| window=`xdotool search --onlyvisible --all --desktop $desktop --class gnome-terminal | head -1` | |
| xdotool windowactivate --sync $window type "$@ | |
| " | |
| xdotool windowactivate --sync $window key Return |
This file contains hidden or 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 Literal < Struct.new(:number) | |
| def show | |
| print number | |
| end | |
| end | |
| class Add < Struct.new(:a, :b) | |
| def show | |
| a.show | |
| print ' + ' |
This file contains hidden or 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 User < Params.over(:first_name, :last_name) | |
| def info | |
| "I am a user: #{@first_name} #{@last_name}" | |
| end | |
| end | |
| class Admin < User.params(:awesomeness_level) | |
| def info | |
| "I am a level #{@awesomeness_level} admin: #{@first_name} #{@last_name}" | |
| end |
This file contains hidden or 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
| Array.prototype.groupBy = function(f) { | |
| var hash = {}; | |
| this.forEach(function(e) { | |
| var result = f(e); | |
| if (hash[result] == undefined) | |
| hash[result] = []; | |
| hash[result].push(e); | |
| }); | |
| return hash; | |
| } |
This file contains hidden or 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
| interface List a implements Functor List, Applicative List, Monad List { | |
| def filter(Lambda1 a Boolean) :: List a | |
| } | |
| interface Functor f { | |
| def map(Lambda1 f[0] b) :: f b | |
| } | |
| interface Applicative f implements Functor Applicative { | |
| def self.wrap(b) :: f b |
This file contains hidden or 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
| pipe :: [ a -> a ] -> a -> a | |
| pipe [] xs = xs | |
| pipe (f:fs) xs = pipe fs $ f xs |