Personal Development
The Passionate Programmer
Ruby
The Ruby Programming Language - David Flanagan, Yukihiro Matsumoto
Programming Ruby 1.9 - Dave Thomas, Chad Fowler, Andy Hunt
#!/usr/bin/env ruby | |
require 'open-uri' | |
require 'JSON' | |
require 'digest/sha2' | |
require 'pry' | |
require 'bigdecimal' | |
require 'bitcoin' # Because I need to cheat every now and then | |
# Usage: | |
# gem install pry json ffi ruby-bitcoin |
This is the default .slate file. | |
# If no ~/.slate file exists this is the file that will be used. | |
config defaultToCurrentScreen true | |
config nudgePercentOf screenSize | |
config resizePercentOf screenSize | |
# General aliases | |
alias sox screenOriginX | |
alias soy screenOriginY |
# Custom Keymap for RubyMine (by fxn) | |
The keymap I work with, inspired by my past Emacs years, these are configurable | |
in Preferences -> Keymap. | |
Most of these have no conflict with the existing shortcuts, I use the default | |
keymap for Mac OS X and add these ones (an action can have several shortcuts). | |
To configure two strokes enter the first one in the main textfield (eg, C-g), | |
check "Second Stroke" and the second one there (eg, c). |
#!/usr/bin/env bash | |
set -e | |
if [[ $# > 0 ]]; then | |
case "$1" in | |
-h | -\? | --help ) | |
{ | |
echo "Add a todo:" | |
echo " todo Reformulate the widget plans." |
# Encryption functions. Requires the GNUpg "gpg" commandline tool. On OS X, "brew install gnupg" | |
# Explanation of options here: | |
# --symmetric - Don't public-key encrypt, just symmetrically encrypt in-place with a passphrase. | |
# -z 9 - Compression level | |
# --require-secmem - Require use of secured memory for operations. Bails otherwise. | |
# cipher-algo, s2k-cipher-algo - The algorithm used for the secret key | |
# digest-algo - The algorithm used to mangle the secret key | |
# s2k-mode 3 - Enables multiple rounds of mangling to thwart brute-force attacks | |
# s2k-count 65000000 - Mangles the passphrase this number of times. Takes over a second on modern hardware. | |
# compress-algo BZIP2- Uses a high quality compression algorithm before encryption. BZIP2 is good but not compatible with PGP proper, FYI. |
#!/bin/sh | |
WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x' `&& | |
HALF=$(($WIDTH/2)) && | |
wmctrl -r :ACTIVE: -b remove,maximized_horz && | |
wmctrl -r :ACTIVE: -b add,maximized_vert && | |
wmctrl -r :ACTIVE: -e 0,0,0,$HALF,-1 |
config defaultToCurrentScreen true | |
config windowHintsShowIcons true | |
config windowHintsIgnoreHiddenWindows false | |
config windowHintsSpread true | |
config windowHintsSpreadPadding 40 | |
config windowHintsSpreadSearchWidth 80 | |
config windowHintsSpreadSearchHeight 80 | |
config switchIconPadding 2 | |
config switchBackgroundColor 50;53;58;0.7 | |
config switchSelectedPadding 4 |
# The fact that YAML.load will instantiate arbitrary ruby objects | |
# means that calling `YAML.load` on untrusted data is virtually always | |
# equivalent to executing arbitrary code in a complex app. | |
# This code fragment globally neuters YAML to disable this behavior, | |
# which should (hopefully) cut off all such attacks from the start. | |
# I don't promise this closes all possible attacks, but this closes | |
# off the trivial case. You should audit and upgrade all your | |
# dependencies, as well. |
" About: | |
" | |
" How often do you forget which keys you should use to select/modify strings | |
" in the ' or " or in other pairs? I often use viw/ciw instead of vi'/vi" for | |
" the first time because it easier for my fingers (but after that I remember | |
" about vi'). This script allows you always use the same shortcut for all | |
" cases. When you want to select string in the ' use viv. Do you want to | |
" select all in the '()'? Use viv. All in the '[]'? Use viv. | |
" | |
" How it works: |
Personal Development
The Passionate Programmer
Ruby
The Ruby Programming Language - David Flanagan, Yukihiro Matsumoto
Programming Ruby 1.9 - Dave Thomas, Chad Fowler, Andy Hunt