MyModule.configure do |config|
#stuff inside
end
This file contains 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
# ~/.bash_profile | |
_thorcomplete() { | |
local cur | |
_get_comp_words_by_ref -n : cur | |
COMPREPLY=($(compgen -W "`bundle exec thor list | grep 'thor ' | cut -d " " -f 2`" -- $cur)) | |
__ltrim_colon_completions "$cur" | |
} |
This file contains 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 join(strings, delimiter) | |
raise ArgumentError, "Invalid delimiter \"\\\"" if delimiter == "\\" | |
strings.map do |s| | |
s.gsub(/(\\|#{Regexp.escape(delimiter)})/, '\\\\\1') | |
end.join(delimiter) | |
end | |
def split(string, delimiter) |
This file contains 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
// ==UserScript== | |
// @name Close Zoom Tabs | |
// @namespace Violentmonkey Scripts | |
// @match https://*.zoom.us/j/* | |
// @grant none | |
// @version 1.0 | |
// @author Matthew Eagar <meagar@hey.com> | |
// @description Close the tabs Zoom spawns | |
// @homepage https://gist.github.com/meagar/9c902cf83d464c0572ea8dd37a7faa00 | |
// ==/UserScript== |
This file contains 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
# Source: https://blog.dnsimple.com/2018/03/elapsed-time-with-ruby-the-right-way/ | |
starting = Process.clock_gettime(Process::CLOCK_MONOTONIC) | |
# time consuming operation | |
ending = Process.clock_gettime(Process::CLOCK_MONOTONIC) | |
elapsed = ending - starting | |
elapsed # => 9.183449000120163 seconds |
This file contains 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
SIDES = %w(R L B F U D) | |
TURNS = ["", "2", "'"] # one turn, two turns, one counter-turn | |
moves = 20.times.inject([]) { |memo, _| memo + [(SIDES - [memo.last]).sample] } | |
p moves.zip(TURNS.cycle).map(&:join) # ["F", "L2", "U'", "B", "L2", "R'", "D", "U2", "B'", "D", "F2", "U'", "L", "B2", "U'", "D", "R2", "L'", "D", "F2"] |
This file contains 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
SIDES = %w(R L B F U D) | |
TURNS = ["", "2", "'"] # one turn, two turns, one counter-turn | |
N = 20 | |
last = "" | |
moves = N.times.map do | |
side = (SIDES - [last]).sample | |
turn = TURNS.sample | |
last = side | |
[side, turn].join |
This file contains 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
# benchmark for http://stackoverflow.com/q/44097717/229044 | |
require 'set' | |
require 'benchmark' | |
def make_data(size = 25_000) | |
t = Time.now | |
size.downto(0).map do |i| | |
{ | |
'timestamp-value' => (t - i * 60).to_s[0..15], |
This file contains 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 is pure data, it's the definition of a category | |
class Category | |
has_many :clues | |
# name: string | |
end | |
# This is pure data, it's the definition of a category, it's not tied to any user or game | |
class Clue |
This file contains 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
// ---- | |
// Sass (v3.4.12) | |
// Compass (v1.0.3) | |
// ---- | |
.loggedIn | |
margin: 0 | |
&.active | |
margin: auto |
NewerOlder