Skip to content

Instantly share code, notes, and snippets.

require 'net/http'
require 'json'
class GithubAPI
HOST = "github.com"
API = "/api/v2"
attr_accessor :format
attr_reader :response, :user
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# - a browser with WebSocket support
#
# Usage:
# ruby redis_pubsub_demo.rb
#
class Array
def columnize(n=1)
rows = []
y = (self.size / n.to_f).ceil
nmulti = (0...n).map {|n| y * n}
y.times do |x|
rows << self.values_at(*nmulti.map {|z| z + x}).compact
end
rows