Skip to content

Instantly share code, notes, and snippets.

View jpsilvashy's full-sized avatar
🎯
Focusing

JP Silvashy jpsilvashy

🎯
Focusing
  • Raad
  • Las Vegas, San Francisco & New York
  • 22:44 (UTC -07:00)
  • X @jpsilvashy
View GitHub Profile
@jpsilvashy
jpsilvashy / find()
Created September 6, 2012 18:25
Snippets from IronCache blog post
def self.find(name)
@name = name
@messages = JSON.parse(settings.ironcache.cache(@name).get('messages').value)
Channel.new(@name, @messages)
end
@jpsilvashy
jpsilvashy / juggernaut_channels.rb
Created July 31, 2012 22:08 — forked from arnabc/juggernaut_channels.rb
Sinatra Server Side Event streaming with private channels.
# Usage: redis-cli publish message.achannel hello
require 'sinatra'
require 'redis'
conns = Hash.new {|h, k| h[k] = [] }
Thread.abort_on_exception = true
get '/' do
# http://jpsilvashy.com/posts/deploying-a-rails-application-on-amazon-ec2/
set :application, "blog"
set :scm, :git
set :repository, "[email protected]:jpsilvashy/blog.git"
set :scm_passphrase, ""
set :user, "ubuntu"
set :deploy_to, "/var/www/blog"
@jpsilvashy
jpsilvashy / serve_directory.sh
Created April 25, 2012 19:15
Serve the current directory from Python's simple server, then open the page up in a web browser.
python -m SimpleHTTPServer 8888 & sleep 2 && open http://localhost:8888
@jpsilvashy
jpsilvashy / simple_server.rb
Created February 28, 2012 08:24
simple_server
#! /usr/bin/env ruby
require 'webrick'
root = File.absolute_path(".")
server = WEBrick::HTTPServer.new :Port => 8000, :DocumentRoot => root
# catch int and shutdown
trap 'INT' do server.shutdown end
@jpsilvashy
jpsilvashy / install.rb
Created February 28, 2012 08:17
WEBrick bin link installer for Simple Server
#!/bin/sh
#
# Install Simple Server by running this command:
# curl https://raw.github.com/gist/1930743/c5b9b6d6579701e2c376f84d5073d8367001bc9e/install.rb | sh
#
# Set up the environment. Respect $VERSION if it's set.
set -e
SS_ROOT="$HOME/Library/Application Support/Simple Server"
@jpsilvashy
jpsilvashy / pow.sh
Created February 28, 2012 08:10
pow
#!/bin/sh
# W
# R RW W.
# RW::::RW DR::R
# :RRRRRWWWWRt:::::::RRR::::::E jR
# R.::::::::::::::::::::::::::Ri jiR:::R
# R:::::::.RERRRRWWRERR,::::::Efi:::::::R GjRRR Rj
# R::::::.R R:::::::::::::;G RRj WWR RjRRRRj
# Rt::::WR RRWR R::::::::::::::::fWR::R; WRW RW R
# WWWWRR:::EWR E::W WRRW:::EWRRR::::::::: RRED WR RRW RR
@jpsilvashy
jpsilvashy / simple_server.sh
Created February 24, 2012 18:51
Simple Server
python -m SimpleHTTPServer 8888
@jpsilvashy
jpsilvashy / deploy.rb
Created October 3, 2011 05:41
Same deploy.rb for a Rails 3 project
require "bundler/capistrano"
load 'deploy/assets'
# Rake helper task.
# http://pastie.org/255489
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/
def run_remote_rake(rake_cmd)
rake_args = ENV['RAKE_ARGS'].to_s.split(',')
cmd = "cd #{fetch(:latest_release)} && #{fetch(:rake, "rake")} RAILS_ENV=#{fetch(:rails_env, "production")} #{rake_cmd}"
@jpsilvashy
jpsilvashy / generate_bson_ids.rb
Created September 19, 2011 18:55
Generate 20 BSON Ids
#!/usr/bin/env ruby
# encoding: utf-8
require 'bson'
20.times do
puts BSON::ObjectId.new
end