require './bm'
bm = BM.new
bm.add(:sleep_long) { sleep 0.1 }
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
# Usage: | |
# $ rackup -p3000 | |
# $ curl localhost:3000 | |
require 'rack' | |
require 'yaml' | |
run proc { |env| [200, {'Content-Type' => 'text/html'}, [env.select { |key| key.include?('HTTP_') }.to_yaml ] ] } |
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
require 'socket' | |
title "UDP Test" | |
action :server do | |
s = UDPSocket.new | |
s.bind(nil, 1234) | |
5.times do | |
text, sender = s.recvfrom(16) | |
puts "received #{text} from #{sender}" |
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 Helpers | |
# Replace standard input with faked one StringIO. | |
def stdin_send(*args) | |
begin | |
$stdin = StringIO.new | |
$stdin.puts(args.shift) until args.empty? | |
$stdin.rewind | |
yield | |
ensure | |
$stdin = STDIN |
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure(2) do |config| | |
forward_port = ->(guest, host = guest) do | |
config.vm.network :forwarded_port, | |
guest: guest, | |
host: host, | |
auto_correct: true | |
end |
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
# Run a ruby or shell script remotely | |
# | |
# Install: | |
# - Put the file in your home directory | |
# - Source it from your .bashrc: | |
# if [ -f $HOME/ssx ]; then source $HOME/ssx; fi | |
ssx() { | |
show_usage() { | |
echo "Run a ruby or shell script remotely" |
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
1. | |
LOGIN_PAGE=http://localhost/users/sign_in | |
curl --cookie-jar cookie_file $LOGIN_PAGE | grep csrf-token | |
2. | |
<meta content="csrf-token" name="csrf-token" /> | |
Sometimes you want to have a subdirectory on the master
branch be the root directory of a repository’s gh-pages
branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master
branch alongside the rest of your code.
For the sake of this example, let’s pretend the subfolder containing your site is named dist
.
Remove the dist
directory from the project’s .gitignore
file (it’s ignored by default by Yeoman).
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
; Chrome Refresh On Focus | |
; Refresh Chrome whenever it receives focus | |
#SingleInstance force | |
#Persistent | |
Gosub WaitForChrome | |
Return | |
WaitForChrome: |
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
# See https://github.com/thomasfl/filewatcher/issues/24 | |
$ gem install filewatcher -v0.4.0 | |
$ gem uninstall filewatcher -v0.5.0 | |
$ rvm list | |
$ ruby -v | |
$ gem list filewatcher | |
$ ./test.rb | |
$ gem install filewatcher | |
$ gem list filewatcher |