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
/** This can be replace with Intl.NumberFormatter */ | |
commafy = (num) => { | |
const [whole, decimal] = num.toString().split('.'); | |
const collection = []; | |
const places = whole.split(''); | |
while (places.length > 0) { | |
const three = []; | |
for (let i = 0 ; i < 3 ; i++) { | |
if (places.length) { | |
three.unshift(places.pop()); |
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
// WIP: Work in progress!!! | |
// TODO (ryan): | |
// 1. Further classify style attributes (HTML vs. SVG vs. Condensible) | |
// 2. Create dispatch table/handlers for special cases (e.g., column-*, where if column-count == 'auto', | |
// drop all column styles. Or for attrs like background-image: url(...), go fetch the image and | |
// inline it as a Data URL. | |
condenser = (() => { | |
const Vendor = { | |
WebKit: 'webkit' |
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
// Assumes selected node in Chrome Developer tools | |
[...$0.getAttributeNames()].map((name) => [name, $0.getAttribute(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
module ThreeDTicTacToe | |
class Game | |
attr_reader :length_to_win | |
def initialize(length_to_win = 3) |
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
1.upto(7) do |order_of_magnitude| | |
quantity_of_items_to_sort = 10 ** order_of_magnitude | |
items_to_sort = Array.new(quantity_of_items_to_sort) {|index| rand(quantity_of_items_to_sort)} | |
sorted_with_qsort = nil | |
time_with_built_in_qsort = Benchmark.realtime do | |
sorted_with_qsort = items_to_sort.sort | |
end |