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
| require 'set' | |
| require 'pp' | |
| require 'date' | |
| require 'pry' | |
| class Index | |
| include Enumerable | |
| def initialize |
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 Binding | |
| def +(other) | |
| self.eval do | |
| other.eval do | |
| binding | |
| end | |
| end | |
| end | |
| 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
| /*! | |
| * jQuery throttle / debounce - v1.1 - 3/7/2010 | |
| * http://benalman.com/projects/jquery-throttle-debounce-plugin/ | |
| * | |
| * Copyright (c) 2010 "Cowboy" Ben Alman | |
| * Dual licensed under the MIT and GPL licenses. | |
| * http://benalman.com/about/license/ | |
| */ | |
| // Script: jQuery throttle / debounce: Sometimes, less is more! |
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
| def notify(msg) | |
| system("notify-send", msg) | |
| end | |
| Signal.trap("HUP") { | |
| 3.downto(1) { |n| notify("#{n}..."); sleep 1 } | |
| notify("DEATH!") | |
| exit | |
| } |
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
| require 'net/http' | |
| require 'uri' | |
| module URI | |
| def ssl?; scheme == 'https'; end | |
| end | |
| class WebFile |
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
| require 'pry' | |
| ObjectSpace.each_object do |o| | |
| o.methods(false).each do |meth| | |
| name = "#{o.class}##{meth}" | |
| result = Pry::Method.from_str(name) | |
| if result.nil? | |
| puts "#{name}" |
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
| def weave(*enums, &key_getter) | |
| enums = enums.map { |e| e.to_enum.each } | |
| Enumerator.new do |yielder| | |
| while enums.any? | |
| enums.sort_by! { |enum| key_getter.call(enum.peek) rescue 0 } | |
| begin | |
| yielder << enums.first.next |
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
| require 'pp' | |
| class Word < Hash | |
| attr_accessor :original | |
| def initialize(word) | |
| @original = word | |
| h = super(0) | |
| word.chars.each { |c| h[c] += 1 } |
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
| $ -> | |
| page_size = 4 | |
| container = $(".texts-container") | |
| all_texts = -> container.find(".texts") | |
| total_pages = -> all_texts().length | |
| # Show the first page. | |
| current = null | |
| width = null |
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
| ########################################################################### | |
| # Base64 Fixed-point Calculator | |
| ########################################################################### | |
| SEED = ":D" # The initial string to Base64 encode | |
| AMOUNT = 1500 # How many bytes should the fixed point end up being? | |
| ########################################################################### | |
| require 'base64' |