Skip to content

Instantly share code, notes, and snippets.

View joona's full-sized avatar

Joona Kulmala joona

  • Rootz LTD
  • Finland
View GitHub Profile
@joona
joona / gist:3825811
Created October 3, 2012 08:33 — forked from leplatrem/gist:1415767
Leaflet Offline Tiles using SQL Storage
/*
* L.TileLayer.LocalCache : A tile layer using SQL Storage, if available.
*/
L.TileLayer.LocalCache = L.TileLayer.extend({
options: {
minZoom: 0,
maxZoom: 18,
tileSize: 256,
subdomains: 'abc',
@joona
joona / savon_client.rb
Created August 8, 2012 07:04 — forked from hoverlover/savon_client.rb
Using my forks of Akami and Savon to sign a request with a X.509 certificate. See https://github.com/genuitytech/akami and https://github.com/genuitytech/savon.
client = Savon::Client.new do
# This can be a URL also
wsdl.document = "/Path/to/your.wsdl"
# These are optional, only if your WSDL sucks :)
wsdl.endpoint = "https://your_endpoint"
wsdl.namespace = "http://your_namespace"
certs = Akami::WSSE::Certs.new :cert_file => "/path/to/cert.crt", :private_key_file => "/path/to/private/key.pem", :private_key_password => "password"
wsse.sign_with = Akami::WSSE::Signature.new certs
@joona
joona / EASounds.as
Created September 16, 2011 15:54
Simple ExternalInterface Sound Player interface to be used with JavaScript to play Music and UI sounds on a web site
package
{
import flash.events.*;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.utils.Timer;
import flash.external.ExternalInterface;
import flash.net.URLRequest;
import flash.display.Sprite;
desc "Watch the site and regenerate when it changes"
task :watch do
require 'fssm'
puts "Watching for Changes "
FSSM.monitor(File.join(File.dirname(__FILE__), 'content'), '**/*') do
update {|base, relative| rebuild_site(relative)}
delete {|base, relative| rebuild_site(relative)}
create {|base, relative| rebuild_site(relative)}
end
end
@joona
joona / IBAN.rb
Created November 23, 2010 13:04
quick hack for BBAN <=> IBAN conversion for Finnish bank account numbers, attached to String-class.
$BANK_PREFIXES = [1, 2, 31, 33, 34, 36, 37, 38, 39, 4, 5, 6, 8]
class String
# converts bank account to numeric format
def to_account
if self.include?('-')
return self.sub(/\-(\d)(\d+)$/, "\\1" << '0' * ((14 - self.length)+1) << "\\2").to_i if ['4','5'].include?(self[0..0])
return self.sub('-', '0' * ((14 - self.length) + 1)).to_i
end