Skip to content

Instantly share code, notes, and snippets.

#!/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
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>
@mikeys
mikeys / gist:e1a9e03d6af2d5e3012e
Last active August 29, 2015 14:16
Laptop Script with relevant Bash commands explained
#!/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"
@mikeys
mikeys / version.rb
Last active May 25, 2016 22:05
Version helper class
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])
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}")
require 'thread'
require 'monitor'
class ThreadPool
class Thread
attr_reader :thread
def initialize(pool)
@thread = ::Thread.new do
@active = true
{
"env": {
"browser": true,
"node": true,
"es6": true,
"jest": true
},
"extends": [
"airbnb",
"plugin:react/recommended",