Skip to content

Instantly share code, notes, and snippets.

@alexmchale
alexmchale / term_size.rb
Last active November 3, 2015 12:47 — forked from nixpulvis/term_size.rb
Get the terminal window size. Not in a bullshit ENV dependent manor.
# From the tty_ioctl man page in Linux.
#
# TIOCGWINSZ struct winsize *argp
# Get window size.
#
# TIOCSWINSZ const struct winsize *argp
# Set window size.
#
# The struct used by these ioctls is defined as
#
require 'active_support/core_ext/kernel/reporting'
require 'active_support/core_ext/module/aliasing'
require 'monitor'
# This is my variation on Tom Meier's monkey-patch to fix a problem in Rails
# I've run into with RSpec. I've tweaked it a bit to use `alias_method_chain`
# instead of just overloading the original method and copying its code.
#
# See the original Gist here:
#
/*
Sample Propane caveatPatchor.js file based on tmm1's avatar hack.
You'll need at least version 1.1.1 to experiment with this:
http://propaneapp.com/appcast/Propane.1.1.1.zip
Once I'm sure exposing this hack-injection point doesn't cause problems
I'll do an official auto-updating version.
As of version 1.1.1, Propane will load and execute the contents of