Skip to content

Instantly share code, notes, and snippets.

View vesan's full-sized avatar

Vesa Vänskä vesan

View GitHub Profile

Keybase proof

I hereby claim:

  • I am vesan on github.
  • I am vesan (https://keybase.io/vesan) on keybase.
  • I have a public key whose fingerprint is 170B 9C28 719A DB97 3711 EA7B E681 FE54 DF8F C3E3

To claim this, I am signing this object:

@vesan
vesan / paypal_bogus_gateway.rb
Created November 23, 2014 21:46
ActiveMerchant testing gateway for Paypal Express
# from: https://github.com/sideshowcoder/active_merchant/blob/192f49762172dc41450d7a3605158d45eb55b83b/lib/active_merchant/billing/gateways/paypal_bogus.rb
require File.dirname(__FILE__) + '/paypal/paypal_common_api'
require File.dirname(__FILE__) + '/paypal/paypal_express_response'
require File.dirname(__FILE__) + '/paypal_express_common'
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class PaypalBogusGateway < BogusGateway
@vesan
vesan / redis_helper.rb
Last active August 29, 2015 14:19 — forked from wxmn/redis_helper.rb
module RedisHelper
# decode Redis value back to Ruby object
def self.decode(json)
self.new(ActiveSupport::JSON.decode(json)["#{self.name.downcase}"])
end
# encode Ruby object for Redis
def encoded
self.updated_at = nil
self.to_json
[*1..99].reverse.each do |i|
phrase = ["#{i} bottles of beer on the wall",
"#{i} bottles of beer",
"You take one down",
"You pass it around",
"#{i - 1} bottles of beer on the wall.."].join(".. ")
`say #{phrase}`
end
@vesan
vesan / httpdump
Created April 4, 2009 07:40 — forked from peterc/httpdump
# Monitor HTTP requests being made from your machine with a one-liner..
# Replace "en1" below with your network interface's name (usually en0 or en1)
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"
# OR.. to be able to use as "httpdump" from anywhere, drop this into ~/.bash_profile:
# (again replace "en1" with correct network interface name)
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*""
# All the above tested only on OS X.
@vesan
vesan / Gemfile
Created March 30, 2010 13:39 — forked from lifo/Gemfile
gem 'cramp'
gem 'erubis', '2.6.5'
gem 'usher', "0.6.0"
@vesan
vesan / gemspec
Created May 13, 2010 19:54 — forked from defunkt/gemspec
#!/usr/bin/env ruby
# Usage: gemspec [-s] GEMNAME
#
# Prints a basic gemspec for GEMNAME based on your git-config info.
# If -s is passed, saves it as a GEMNAME.gemspec in the current
# directory. Otherwise prints to standard output.
#
# Once you check this gemspec into your project, releasing a new gem
# is dead simple:
#
class DownloadsController < ApplicationController
def show
if @current_user
send_file "#{Rails.root}/downloads/test.pdf"
else
head(:not_found)
end
end
end
@vesan
vesan / gist:538407
Created August 19, 2010 17:17 — forked from qoobaa/gist:208616
require "rubygems"
require "nokogiri"
require "uri"
module Rack
class KarmaChameleon
def initialize(app, options = {})
@ext = options[:extension] || "html5"
@ext_regexp = /\.#@ext$/
@app = app