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
require 'spy' | |
require 'spy/util' | |
TypeAnalysis = Module.new | |
TypeAnalysis.extend(Spy::API) | |
singleton_spy = TypeAnalysis.on_object(NegativeKeywordSelectorTrie) | |
singleton_spy = Spy::Util::TypeAnalysis.new(singleton_spy).decorate | |
class_spy = TypeAnalysis.on_class(NegativeKeywordSelectorTrie) | |
class_spy = Spy::Util::TypeAnalysis.new(class_spy).decorate |
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
require 'arel/attributes/attribute' | |
module ColumnAlias | |
module ArelAttributePatch | |
def name | |
return super unless relation.engine.respond_to?(:column_aliases) | |
name_given = super | |
relation.engine.column_aliases[name_given] || name_given | |
end | |
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
iostat -xmt 2 | |
# Example output: | |
06/04/2018 03:29:38 PM | |
avg-cpu: %user %nice %system %iowait %steal %idle | |
11.14 0.00 0.75 1.00 0.13 86.98 | |
Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await svctm %util | |
xvda 0.00 65.00 18.00 1450.50 0.21 23.29 32.79 6.17 4.20 0.08 11.40 |
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
ps -eo min_flt,maj_flt,cmd | grep mongod.conf | grep -v grep |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>audio edge test</title> | |
</head> | |
<body> | |
</body> | |
<script> | |
var audioCtx = new AudioContext(); |
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
module TermTerm | |
def self.start!(command) | |
master, slave = PTY.open | |
comand = "script --return -c '#{command}' /dev/null" | |
i,_,e,t = Open3.popen3(command, out: slave) | |
multi = TermTerm::Multiplexer.new | |
multi.forward($stdin, i) | |
multi.forward(master, $stdout) | |
multi.forward(e, $stderr) | |
multi.run! |
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
lsof -i :3081 |
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
## | |
# Run syntax checks before pushing | |
# | |
# Installation: | |
# 1. Copy this gist to .git/hooks/pre-push | |
# 2. chmod +x .git/hooks/pre-push | |
# | |
# NOTE: you can also just call `rubocop --auto-correct` if you would rather | |
#! /usr/bin/env sh |
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
#! /usr/bin/env ruby | |
require 'yaml' | |
require 'hipchat' | |
def config | |
@config ||= YAML.load_file(File.expand_path File.join(__FILE__, '../.env.yml')) | |
end | |
def hipchat |
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
# To use, simply define @__callbacks as a hash where the keys are events | |
# and the values respond to #call (e.g. lambdas, procs, methods) | |
# | |
# This implementation assumes you only have one callback per event, but | |
# you could use an array instead if you wanted | |
module SimpleCallbacks | |
def run_callback(type, *args) | |
@__callbacks[type].call(*args) if @__callbacks.has_key?(type) | |
end | |
end |