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 / 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
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 / 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;
@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 / 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 / gist:3825826
Created October 3, 2012 08:39 — forked from leplatrem/gist:1415795
Tiles serialization in base64 using django and landez
import base64
from StringIO import StringIO
from django.http import HttpResponse
from django.utils import simplejson
from easydict import EasyDict as edict
from landez import TilesManager
from . import app_settings
@joona
joona / .bash_profile
Created November 14, 2012 22:09
Recipe for success with NVM on CentOS with default Python 2.4 and Python 2.6 installed.
# add these modifications to your path
export PATH="$HOME/bin:$PATH"
# activate NVM
. ~/.nvm/nvm.sh
@joona
joona / deploy.rb
Created November 15, 2012 15:12 — forked from alkema/deploy.rb
Capistrano task for a Node.js app with github Forever and NPM.
set :application, "appname"
set :deploy_to, "/var/www"
set :scm, :git
set :repository, "git@github.com:user/app.git"
default_run_options[:pty] = true
set :user, "www-data"
set :domain, "foo.tld"
set :normalize_asset_timestamps, false
# It'd be great to get this running via AppleScript and sans Alfred if anyone with more knowledge than me knows how :)
### STEP 1
#!/bin/sh
# Save this file as /bin/rvm_ruby, and do chmod 755 /bin/rvm_ruby
# to give it the proper permissions
# From http://www.aeonscope.net/2011/05/29/connecting-alfred-to-bitly-via-ruby/
if [[ -s ~/.rvm/scripts/rvm ]]; then
@joona
joona / main.java
Created March 13, 2015 12:45
Google service account JSON key to Google OAuth2 access token request
package io.inbot;
import com.github.jsonj.JsonObject;
import com.github.jsonj.tools.JsonParser;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.security.InvalidKeyException;