It can be challenging to use Ruby for handling raw binary data, involving a lot of Array#pack
and String#unpack
with the possibility of String#ord
and Numeric#chr
for good measure. Some of these tools might make the job a bit easier, allowing your to define schemas of the binary data and how to parse it, or even just allowing your to specify the format in a more verbose way.
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
$vdiff_difftool = 'ksdiff' | |
require 'pp' | |
class Object | |
def vdiff(other) | |
require 'tempfile' | |
t1 = Tempfile.new(['vdiff', '.rb']) | |
t2 = Tempfile.new(['vdiff', '.rb']) | |
PP.pp self, t1 | |
PP.pp other, t2 |
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 'http://rubygems.org' | |
gem 'activesupport', :require => 'active_support' | |
gem 'actionpack', :require => 'action_pack' | |
gem 'actionmailer', :require => 'action_mailer' | |
gem 'railties', :require => 'rails' | |
gem 'mysql2' | |
DM_VERSION = '~> 1.2.0.rc1' |
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
export RBENV_ROOT="$HOME/.rbenv" | |
export RBENV_PLUGINS="$RBENV_ROOT/plugins" | |
git clone https://github.com/sstephenson/rbenv.git "$RBENV_ROOT" | |
export PATH="$RBENV_ROOT/bin:$PATH" | |
echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> ~/.bash_profile | |
eval "$(rbenv init -)" | |
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile |
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/bash | |
# run this like: `curl https://gist.github.com/acook/1444793/raw/ruby_dev_machine_setup.sh | bash` | |
echo "Enter password to install packages..." | |
sudo apt-get update | |
sudo apt-get install -y build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libtool ack-grep vim-nox ctags | |
\curl -#L https://get.rvm.io | bash -s stable --ruby | |
source ~/.bashrc |
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 PubSub | |
class << self | |
def create type, channel, object | |
channel = channel.to_sym | |
case type | |
when :listener | |
listeners[channel] ||= Array.new | |
listeners[channel] << object | |
channels[channel] ||= Array.new |
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/bash | |
# run this like: `curl https://gist.github.com/acook/6192391/raw/ubuntu_server_setup.bash | bash` | |
echo "Enter the email address for this server's SSH key: " | |
read email | |
mkdir ~/.ssh | |
ssh-keygen -t rsa -C $email | |
echo "Enter password to install packages: " |
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 AttributeAccessor < Module | |
def initialize(name) | |
@name = name | |
module_eval { define_accessors } | |
end | |
private | |
def define_accessors | |
ivar = "@#{@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
urxvt.termName: rxvt | |
urxvt.loginShell: true | |
urxvt*urlLauncher: /usr/bin/chromium | |
urxvt*perl-lib: /usr/lib/urxvt/perl/ | |
urxvt*perl-ext-common: default,matcher,searchable-scrollback | |
urxvt*font: xft:DejaVu Sans Mono:pixelsize=10 | |
urxvt*boldFont: xft:DejaVu Sans Mono:pixelsize=10 | |
urxvt.scrollBar: false | |
urxvt.saveLines: 65535 | |
urxvt.secondaryScroll: 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
Model.new.foo |
OlderNewer