Skip to content

Instantly share code, notes, and snippets.

View tuupola's full-sized avatar

Mika Tuupola tuupola

View GitHub Profile
$(".editable").editable("http://www.example.com/save.php", {
type : "textarea",
submit : "OK",
data: function(value, settings) {
var retval = value.replace(/<br[\s\/]?>/gi, '\n');
return retval;
}
});
@tuupola
tuupola / isikukood.js
Created September 3, 2009 14:13
Validate Estonian national identification number (isikukood).
/*
* Validate Estonian national identification code.
*
* Copyright (c) 2009 Mika Tuupola
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*/
function isikukood(kood) {
@tuupola
tuupola / thin.rb
Created June 6, 2010 08:32
Fixed Thin tasks for Vlad 1.4.
# Fixed Thin tasks for Vlad when using port and not socket (tuupola).
#
# $GEM_HOME/gems/vlad-1.4.0/lib/vlad/thin.rb
# Thin tasks for Vlad the Deployer
# By cnantais
require 'vlad'
namespace :vlad do
##
# Thin app server
@tuupola
tuupola / .htaccess
Created June 16, 2010 18:29
Rake tasks for easier Facebook development.
RewriteEngine On
RewriteBase /
# Everything not found goes to Sinatra / Rack
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) http://127.0.0.1:4567%{REQUEST_URI} [L,P,QSA]
@tuupola
tuupola / httpd-vhosts.conf
Created August 19, 2010 14:17
Automated dev.* subdomains for Apache.
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@localhost
VirtualDocumentRoot "/Users/tuupola/Code/www/%0/htdocs"
ServerName dev.subdomains
ServerAlias dev.*
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
ErrorLog "/Users/tuupola/Code/www/logs/vhosts-error_log"
CustomLog "/Users/tuupola/Code/www/logs/vhosts-access_log" vcommon
@tuupola
tuupola / gist:555130
Created August 28, 2010 13:33
Cherry picking commits from commandline.
git remote add someguy http://github.com/someguy/repository.git
git fetch someguy
git cherry-pick xxxxxxx
$("a.delete").live("click", function(event) {
var self = this;
$.post(this.href, {_method: "delete"}, function(data) {
$(self).parent().parent().hide();
});
return false;
});
@tuupola
tuupola / gist:827545
Created February 15, 2011 13:51
CentOS 5.5 rmagick installation
sudo bin/gem install rmagick --version '= 1.15.17' -- --build-flags --enable-allow-example-errors
@tuupola
tuupola / gist:870771
Created March 15, 2011 14:20
jQuery tools calendar translation for Estonian, Russian, Latvian and Lithuanian.
var estonian = {
months: "Jaanuar,Veebruar,Märts,Aprill,Mai,Juuni,Juuli,August,September,Oktoober,November,Detsember",
shortMonths: "jaan.,veebr.,märts,apr.,mai,juuni,juuli,aug.,sept.,okt.,nov.,dets.",
days: "Pühapäev,Esmaspäev,Teisipäev,Kolmapäev,Neljapäev,Reede,Laupäev",
shortDays: "P,E,T,K,N,R,L"
};
var russian = {
months: "Январь,Февраль,Март,Апрель,Май,Июнь,Июль,Август,Сентябрь,Октябрь,Ноябрь,Декабрь",
shortMonths: "янв,фев,мар,апр,май,июн,июл,авг,сен,окт,ноя,дек",
@tuupola
tuupola / app.rb
Created March 17, 2011 18:27
Safari Authorization header broken after 302 redirect
# Run the app (ruby app.rb or shotgun app.rb)
#
# Open the page. Login with test and test. Reload a few times. Page loads fine. Then
# click the link which make 302 redirect back to original page. Now when you reload it asks for
# username and password again. If you check the logs you can see credentials are now broken.
# Also tcpdump shows Authorization header is broken.
#
# Tested with Safari 5.0.4 (6533.20.27), Safari 5.0.3 (6533.19.4)
# Webkit Nightly 5.0.3 (6533.19.4, r80833)