Skip to content

Instantly share code, notes, and snippets.

View gist:f2e22f3da64f4eca704ed93e5fc4a391

I'm Daven, a Canadian and aspiring developer living in Japan.


  • B.A. Economics: University of Waterloo (2008-2012)
  • Study abroad at Ritsumeikan APU (立命館アジア太平洋大学)
  • English teacher for 8 years


Najaf / mechanize-cheat-sheet.rb
Last active Oct 15, 2019
Mechanize Cheat Sheet, take a look at the real documentation here:
View mechanize-cheat-sheet.rb
# Initialize Mechanize Agent
agent =
# Visit a web page
agent.get 'http://localhost:3000/'
# get the url of the current page #=> http://localhost:3000
# agent remembers the scheme + host, so no need to supply it when navigating somewhere else
View simple-response.rb
#! /usr/bin/env ruby
require 'socket'
def log(source, message)
time ="%Y-%m-%d %H:%M:%S")
puts "[%s] %s => %s" % [time, source, message]
# Class representing HTTP Requests
View request-line.rb
#! /usr/bin/env ruby
require 'socket'
def log( source, message)
time ="%Y-%m-%d %H:%M:%S")
puts "[%s] %s => %s" % [time, source, message]
server = ARGV.first.to_i
Najaf / bwt.rb
Created May 2, 2017
Rough implementation of Burrows-Wheeler
View bwt.rb
# Rough implementation of BW transform
# As described at the wikipedia page:
EOF_CHAR = '|'
def bwt(string)
string_with_eof = string + EOF_CHAR
rotations = []
0.upto(string_with_eof.length - 1) do |i|
rotations << string_with_eof.chars.rotate(i).join

Keybase proof

I hereby claim:

  • I am Najaf on github.
  • I am alinajaf ( on keybase.
  • I have a public key whose fingerprint is 989E 6487 8C4A CDA3 0AF0 0A5B F7B3 0CFC 4514 0684

To claim this, I am signing this object:

View -
def test_gist_from_cli
puts "hello world"
Najaf / gist:5431024
Last active Dec 16, 2015
Quick tip for implementing access control
View gist:5431024
# So your PicsController probably looks something like this:
class PicsController < ApplicationController
def update
@pic = Pic.find(params[:id])
# You want to change that to this:
class PicsController < ApplicationController

A literal haskell gist file

someHaskellCode :: a -> [a]