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
{ | |
"env": { | |
"browser": true, | |
"node": true, | |
"es6": true, | |
"jest": true | |
}, | |
"extends": [ | |
"airbnb", | |
"plugin:react/recommended", |
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 'thread' | |
require 'monitor' | |
class ThreadPool | |
class Thread | |
attr_reader :thread | |
def initialize(pool) | |
@thread = ::Thread.new do | |
@active = true |
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 self.exec_with_cursor(sql, params: [], buffer_size: 10_000) | |
raise ArgumentError, 'Must provide a block' unless block_given? | |
cursor_name = "C#{SecureRandom.hex}" | |
sql = "DECLARE #{cursor_name} CURSOR FOR #{sql}" | |
connection.transaction do | |
connection.exec_params(sql, params) | |
loop do | |
res = connection.exec("FETCH #{buffer_size} IN #{cursor_name}") |
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
class Version | |
include Comparable | |
PATTERN = /^(?<major>0|[1-9][0-9]*)(\.(?<minor>0|[1-9][0-9]*))?(\.(?<revision>0|[1-9][0-9]*))?$/ | |
attr_reader :major, :minor, :revision | |
def initialize(options) | |
[:major, :minor, :revision].each do |field| | |
validate_field(field, options[field]) |
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
#!/bin/sh | |
# Welcome to the thoughtbot laptop script! | |
# Be prepared to turn your laptop (or desktop, no haters here) | |
# into an awesome development machine. | |
fancy_echo() { | |
# Set local variable fmt to a string containing the first argument | |
local fmt="$1" |
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
set background=dark | |
" Disable mouse in vim | |
if has('mouse') | |
set mouse-=a | |
endif | |
" Beautify JSON (requires npm install jsonlint) | |
vnoremap <leader>jt :!jsonlint<CR> | |
nnoremap <leader>jt :%!jsonlint<CR> |
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
#!/bin/sh | |
# Create a temporary file which will hold the GDB Commands | |
TMPFILE=`mktemp /tmp/gdbcommands.XXXXXX` || exit 1 | |
# Add commands to the newly created file | |
cat <<-EOF > $TMPFILE | |
define redirect_stdout | |
call rb_eval_string("\$_old_stdout, \$stdout = \$stdout, File.open('/tmp/ruby-debug.' + Process.pid.to_s, 'a'); \$stdout.sync = true") | |
end |