adapted from this blog
# YAML
name: Jon# YAML
object:| require 'net/http' | |
| require 'rack' | |
| # todo | |
| # - detect ssl | |
| # - keepalive? | |
| module Rack | |
| class Forwarder | |
| def initialize(host, port=80) |
| helpers do | |
| # Construct a link to +url_fragment+, which should be given relative to | |
| # the base of this Sinatra app. The mode should be either | |
| # <code>:path_only</code>, which will generate an absolute path within | |
| # the current domain (the default), or <code>:full_url</code>, which will | |
| # include the site name and port number. The latter is typically necessary | |
| # for links in RSS feeds. Example usage: | |
| # | |
| # link_to "/foo" # Returns "http://example.com/myapp/foo" | |
| # |
| # Rails Cheat Sheet | |
| # and list of helpers worth keeping | |
| # command line | |
| script/generate controller | |
| # route | |
| map.root :controller => "controller_name" |
| #!/bin/bash | |
| ## | |
| # MySQL DB dump to Git commit | |
| # | |
| # Dumps the specified mysql database to the given location and commits it and | |
| # the previous database to the Git repository. | |
| # | |
| # It is assumed you have already setup the Git respository to only be the | |
| # a checkout of the database backup location |
| import static org.junit.Assert.*; | |
| import static org.hamcrest.CoreMatchers.is; | |
| import static org.mockito.Mockito.*; | |
| import static org.mockito.BDDMockito.*; | |
| import org.hamcrest.BaseMatcher; | |
| import org.hamcrest.Description; | |
| import org.hamcrest.Matcher; |
| [ | |
| { "keys": ["f12"], "command": "htmlprettify"}, | |
| { "keys": ["f1"], "command": "fold" }, | |
| { "keys": ["f2"], "command": "unfold" }, | |
| { "keys": ["ctrl+à"], "command": "show_overlay", "args": {"overlay": "goto", "text": "@"} }, | |
| { "keys": ["ctrl+!"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} }, | |
| { "keys": ["ctrl+space"], "command": "auto_complete" }, | |
| { "keys": ["ctrl+space"], "command": "replace_completion_with_auto_complete", "context": | |
| [ | |
| { "key": "last_command", "operator": "equal", "operand": "insert_best_completion" }, |
| require 'rubygems' | |
| require 'net/ssh' | |
| # Run this on the machine (node) which needs to tunnel out to forward the UI to the remote system (console) | |
| Net::SSH.start("remote_host", "remote_user") do |ssh| | |
| # since we are running sinatra locally we will forward 43210 on the remote_host to our localhost 4567 | |
| # This is effectively the same as: | |
| # ssh -R 4567:localhost:43210 remote_user@remote_host | |
| ssh.forward.remote(4567, "localhost", 43210) | |
| ssh.loop { true } |
adapted from this blog
# YAML
name: Jon# YAML
object:| #!/bin/bash | |
| # | |
| # Copy data from a Time Machine volume mounted on a Linux box. | |
| # | |
| # Usage: copy-from-time-machine.sh <source> <target> | |
| # | |
| # source: the source directory inside a time machine backup | |
| # target: the target directory in which to copy the reconstructed | |
| # directory trees. Created if it does not exists. | |
| # |
| #!/bin/bash | |
| # Sync Homebrew installations between Macs via Dropbox | |
| # | |
| BREW="/usr/local/bin/brew" | |
| # first get local settings | |
| echo "Reading local settings ..." | |
| rm -f /tmp/brew-sync.* |