Skip to content

Instantly share code, notes, and snippets.

@a-leung
a-leung / websocketClient.js
Created June 4, 2015 16:18
Websocket Rails client javascript class
(function(websocketClient, $, undefined) {
var PING_INTERVAL = 42000,
RECONNECT_INTERVAL = 10000,
WEBSOCKET_URL = window.location.host + '/websocket';
var config, reconnectInterval, keepAliveInterval, dispatcher;
websocketClient.init = function(websocketConfig) {
config = websocketConfig;
setupDispatcher();
};
@a-leung
a-leung / .tmux.conf
Last active March 17, 2016 19:23
tmux.conf
###################
# Prefix key setup
###################
set -g prefix C-a # remap prefix to Control + a --> i'm old that way.
# bind 'C-a C-a' to type 'C-a'
bind a send-prefix # send 'C-a' into terminal app by typing: 'C-a a'
bind C-a last-window # bounce between windows just by typing 'C-a C-a'
unbind C-b # get rid of C-b as prefix
########################
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'
# Default screens
screen -t shell1 0
screen -t shell2 1
screen -t server 2 ssh me@myserver
@a-leung
a-leung / random.rb
Created October 25, 2012 17:32
random number guesser - first take
number = rand(10)
puts 'Guess the number!'
input = 'input number'
while input != number
input = gets.to_i # keep getting more numbers
# give out hints to the user
if input > number
puts 'Too high'
end
@a-leung
a-leung / random-v2.rb
Created October 24, 2012 15:15
random number guesser
GUESS_RANGE = 100
guessNumber = rand(GUESS_RANGE)
puts "Guess the number! (Hint: between 0 and #{GUESS_RANGE})"
guessCount = 0
while (userGuess = gets.to_i) != guessNumber # keep getting more numbers
# give out hints to the user
puts 'Too high' if userGuess > guessNumber