The squirrels are blogging


posted in HowTo, 28.05.10 19:47


HowTo: Share a session with mutliple subdomains in Rails

Sharing a Session between multiple subdomains/rails-apps is quite easy.

Make shure you're using the ActiveRecord (db-based) session store and all instances share the same secret (- obviously the same db, too). In config/environment.rb (config-block):

  config.action_controller.session_store = :active_record_store #store session in db
  config.action_controller.session = {
	:session_key => '_MYWEBAPP', #has to mach over all instances
	:secret      => 'mysecretmysecretmysecret' #has to mach over all instances
  }

Tell rails to set the session-cookie on "all subdomains" by adding this line to config/environments/myenvironment.rb. Note the leading dot in ".mydomain.com".

	ActionController::Base.session = { :domain => '.mydomain.com' }

(Apprently this works only for rails >= 2.3)


posted in HowTo, 02.09.09 16:32


HowTo write invoices in LaTeX

The latex-invoice package makes it really easy to write invoices in LaTeX.

For debian-users installing latex-invoice is straightforward:

apt-get install texlive-latex-extra

Here's an example document. This is what it will look like.

\documentclass{letter}
\usepackage{invoice}
\address{My Name \\ My Street \\ My Zip\\ my@mail.com \\ etc}
\signature{Fnord Prefake}
\date{23. May 2009}

\begin{document}
  \begin{letter}{Customer name \\
                      Customer street \\
                      Customer zip}
    \opening{Invoice no. 1}
    My greeting
    \begin{invoice}{Euro}{0}
      \ProjectTitle{Example Project}%
      \Fee{Development} {1000.00} {1}
    \end{invoice}

    \closing{My closing}
  \end{letter}
\end{document}

posted in HowTo, 19.08.09 22:38


HowTo migrate from SQLite to MySQL

Grab the (sqlite) sql dump an fire up your editor:

sqlite3 db/development.sqlite .dump .quit > dump.sql
  • replace all double-quotes (") with grave accents (´) (in vim just type :%s/"/´/)
  • replace "autoincrement" with "auto_increment"
  • remove "BEGIN TRANSACTION;" from the beginnig of the dump
  • remove "COMMIT;" from the end of the dump
  • remove all lines containing "sqlite_sequence"

You're done. Just import your new MySQL dump.