vemod.net http://termos.vemod.net/ ... Datorbutiker i Lund http://termos.vemod.net/datorbutiker-i-lund <p>Som en uppföljare till den populära <a href="http://termos.vemod.net/datorbutiker-i-malmo">Datorbutiker i Malmö</a>-sidan finns nu här en lista för Lund.</p> <p>Var vänlig och <a href="mailto:christoffer.sawicki@gmail.com?subject=Datorbutiker i Lund">meddela mig</a> om någon butik saknas.</p> <h2>Butiker i centrala Lund</h2> <ul> <li><a href="http://www.itel.se/" class="external">Itel</a></li> <li><a href="http://www.ghdata.se/" class="external">GHdata</a></li> <li><a href="http://www.macsupport.se" class="external">MacSupport</a></li> <li><a href="http://www.kjell.com/" class="external">Kjell &#38; Company</a></li> </ul> <h2>Butiker lite varstans</h2> <ul> <li><a href="http://www.compliq.se/" class="external">Compliq</a></li> </ul> <h2>Butiker ute på <a href="http://www.novalund.se/" class="external">Nova Lund</a></h2> <ul> <li><a href="http://www.elgiganten.se/">Elgiganten</a></li> <li><a href="http://www.expert.se/">Expert</a></li> <li><a href="http://www.mediamarkt.se/">Media Markt</a></li> <li><a href="http://www.onoff.se/"><span class="caps">ONOFF</span></a></li> <li><a href="http://www.siba.se/"><span class="caps">SIBA</span></a></li> </ul> Mon, 08 Mar 2010 23:09:34 +0100 http://termos.vemod.net/datorbutiker-i-lund 2010-03-08T23:09:34+01:00 Cinematekets program i iCalendar-format http://termos.vemod.net/cinametekets-program-i-icalendar-format <p><a href="http://en.wikipedia.org/wiki/ICalendar" class="external">iCalendar</a> (även kallat iCal) är ett standardiserat filformat för kalendrar som gör det möjligt att enkelt utbyta kalenderinformation mellan olika datorer (inkl. smartphones med kalenderfunktion). <a href="http://www.sfi.se/sv/cinemateket/" class="external">Cinemateket</a> erbjuder inga iCalendar-filer för sina program själva så därför har jag genererat sådana filer.</p> <p>Dessa kalendrar är senast uppdaterade för våren 2010:s program men innehåller tyvärr inte januaris filmer. Filmernas sluttid är inte korrekt utan jag har räknat med att varje film är 2 timmar lång. <a href="mailto:christoffer.sawicki@gmail.com?subject=Cinematekets program i iCalendar-format">Kontakta gärna mig om du stöter på något problem.</a></p> <p>Prenumerera på kalendern istället för att ladda ner den för att automatiskt få uppdateringar.</p> <h2>Malmö</h2> <ul> <li><a href="http://www.google.com/calendar/ical/v1ndctiq4p2qprnef14pm5l5js%40group.calendar.google.com/public/basic.ics" class="external">Ladda ner kalendern</a></li> <li><a href="webcal://www.google.com/calendar/ical/v1ndctiq4p2qprnef14pm5l5js%40group.calendar.google.com/public/basic.ics" class="external">Prenumerera på kalendern</a></li> <li><a href="http://www.google.com/calendar/embed?src=v1ndctiq4p2qprnef14pm5l5js%40group.calendar.google.com&#38;ctz=Europe/Stockholm" class="external">Se kalendern som webbsida</a></li> </ul> <h2>Göteborg</h2> <ul> <li><a href="http://www.google.com/calendar/ical/p397cogot601fhcgdnkq900f0s%40group.calendar.google.com/public/basic.ics" class="external">Ladda ner kalendern</a></li> <li><a href="webcal://www.google.com/calendar/ical/p397cogot601fhcgdnkq900f0s%40group.calendar.google.com/public/basic.ics" class="external">Prenumerera på kalendern</a></li> <li><a href="http://www.google.com/calendar/embed?src=p397cogot601fhcgdnkq900f0s%40group.calendar.google.com&#38;ctz=Europe/Stockholm" class="external">Se kalendern som webbsida</a></li> </ul> <h2>Stockholm</h2> <p>Har just nu inget program.</p> Fri, 12 Feb 2010 15:20:18 +0100 http://termos.vemod.net/cinametekets-program-i-icalendar-format 2010-02-12T15:20:18+01:00 Page Caching with Rails and Passenger http://termos.vemod.net/page-caching-with-rails-and-passenger <p>This page documents my favorite way of handling page caching with <a href="http://termos.vemod.net/rails">Rails</a> and <a href="http://www.modrails.com/" class="external">Passenger</a>. It&#8217;s a simple and elegant technique if cache invalidation is infrequent and you can afford to sweep the entire cache once it happens. I&#8217;d appreciate any feedback on this article &#8211; just <a href="http://termos.vemod.net/contact">contact me</a>.</p> <h2>Step 0: Start page caching</h2> <p>Use <a href="http://api.rubyonrails.com/classes/ActionController/Caching/Pages/ClassMethods.html" class="external"><code>cache_page</code> or <code>caches_page</code></a> in your controllers.</p> <h2>Step 1: Write cached files into <code>public/cache</code></h2> <p>I don&#8217;t like polluting the <code>public</code> directory of my <a href="http://termos.vemod.net/rails">Rails</a> applications with cache files so I dedicate a <code>public/cache</code> directory for them. Add this to your application configuration:</p> <pre><code class="ultraviolet">config.<span class="FunctionName">action_controller</span>.<span class="FunctionName">page_cache_directory</span> <span class="Operator">=</span> <span class="String"><span class="String">&quot;</span><span class="String"><span class="String">#{</span><span class="LibraryClassType">Rails</span><span class="String"><span class="String">.</span><span class="FunctionName">root</span></span><span class="String">}</span></span>/public/cache<span class="String">&quot;</span></span> </code></pre> <p><em>Note:</em> Replace <code>Rails.root</code> with <code>RAILS_ROOT</code> if you&#8217;re running an old version of Rails.</p> <h2>Step 2: Sweep your cache</h2> <pre><code class="ultraviolet"><span class="Keyword">class</span> <span class="TypeName">CacheSweeper<span class="InheritedClass"> <span class="InheritedClass">&lt;</span> ActiveRecord::Observer</span></span> observe <span class="Variable">YourModel</span>, <span class="Variable">YourSuperModel</span> <span class="Keyword">def</span> <span class="FunctionName">self.sweep_cache!</span> pattern <span class="Operator">=</span> <span class="String"><span class="String">&quot;</span><span class="String"><span class="String">#{</span><span class="LibraryClassType">ActionController</span><span class="String"><span class="String">::</span><span class="FunctionName">Base</span></span><span class="String"><span class="String">.</span><span class="FunctionName">page_cache_directory</span></span><span class="String">}</span></span>/**/*.html<span class="String">&quot;</span></span> <span class="LibraryClassType">Dir</span>.<span class="FunctionName">glob</span>(pattern) <span class="Keyword">do </span>|<span class="Variable">filename</span>| <span class="LibraryClassType">File</span>.<span class="FunctionName">delete</span>(filename) <span class="Keyword">end</span> <span class="Keyword">end</span> <span class="Keyword">def</span> <span class="FunctionName">after_save</span>(<span class="FunctionArgument"><span class="Operator">*</span>_</span>) <span class="Variable">self</span>.<span class="FunctionName">class</span>.<span class="FunctionName">sweep_cache!</span> <span class="Keyword">end</span> <span class="Keyword">def</span> <span class="FunctionName">after_destroy</span>(<span class="FunctionArgument"><span class="Operator">*</span>_</span>) <span class="Variable">self</span>.<span class="FunctionName">class</span>.<span class="FunctionName">sweep_cache!</span> <span class="Keyword">end</span> <span class="Keyword">end</span> </code></pre> <p>Activate this observer with <code class="ultraviolet">config.<span class="FunctionName">active_record</span>.observers </code> or invoke <code class="ultraviolet"><span class="LibraryClassType">CacheSweeper</span>.sweep_cache! </code> yourself. Please note that it sweeps the <em>entire</em> cache.</p> <h2>Step 3: Configure Apache and Passenger</h2> <pre><code>RailsAllowModRewrite On RewriteEngine On RewriteCond %{THE_REQUEST} ^(GET|HEAD) RewriteCond %{REQUEST_URI} ^/([^.]+)$ RewriteCond %{DOCUMENT_ROOT}/cache/%1.html -f RewriteRule ^/[^.]+$ /cache/%1.html [QSA,L] RewriteCond %{THE_REQUEST} ^(GET|HEAD) RewriteCond %{DOCUMENT_ROOT}/cache/index.html -f RewriteRule ^/$ /cache/index.html [QSA,L]</code></pre> <p>Use <a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriteloglevel" class="external"><code>RewriteLogLevel</code></a> and <a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritelog" class="external"><code>RewriteLog</code></a> if you need to troubleshoot <a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html" class="external"><code>mod_rewrite</code></a>.</p> <h2>Page History</h2> <ul> <li>2009-05-14: <code>ActionController::Caching::Sweeper</code> was replaced with <code>ActiveRecord::Observer</code>.</li> </ul> <ul> <li>2009-05-16: The rewrite rules were revised after feedback from Jared Moody.</li> </ul> <ul> <li>2009-08-28: Vince Wadhwani wrote and pointed out that the rules shouldn&#8217;t affect <span class="caps">POST</span> requests. Added an additional guard for that.</li> </ul> <ul> <li>2009-10-04: Kevin Swope discovered that the last change, as implemented by me, effectively disabled the cache. Fixed by rearranging two lines.</li> </ul> <ul> <li>2010-01-19: The stupid <code>define_method</code> stuff was replaced with plain methods.</li> </ul><p><small>Tags: <a href="http://termos.vemod.net/rails" class="tag" rel="tag">Rails</a></small></p> Tue, 19 Jan 2010 23:22:36 +0100 http://termos.vemod.net/page-caching-with-rails-and-passenger 2010-01-19T23:22:36+01:00 How to Set Cache-Control for Rails Assets with Apache http://termos.vemod.net/how-to-set-cache-control-for-rails-assets-with-apache <pre><code>RewriteCond "%{QUERY_STRING}" "[0-9]+$" RewriteRule "^.*$" "$0" [L,E=CACHE:True] # Match all. Header onsuccess set "Cache-Control" "public, max-age=31536000" env=CACHE</code></pre> <p>Dependencies: <code>mod_rewrite</code> and <code>mod_headers</code></p> <p>Please <a href="http://termos.vemod.net/contact">contact me</a> if you know an even nicer way.</p><p><small>Tags: <a href="http://termos.vemod.net/rails" class="tag" rel="tag">Rails</a></small></p> Thu, 07 Jan 2010 00:20:20 +0100 http://termos.vemod.net/how-to-set-cache-control-for-rails-assets-with-apache 2010-01-07T00:20:20+01:00 Contact http://termos.vemod.net/contact <p>Feel free to contact me (<a href="http://termos.vemod.net/christoffer-sawicki">Christoffer Sawicki</a>) if you have anything in your heart to disclose.</p> <p><strong>My e-mail, Jabber and Windows Live Messenger<sup><a href="#fn1">1</a></sup> address is <a href="mailto:christoffer.sawicki@gmail.com" class="external">christoffer.sawicki@gmail.com</a>.</strong></p> <p>If you want to call me, you can find my phone number at the expected services on the web.</p> <p id="fn1"><sup>1</sup> <em>Ugh</em>, such a long name! I can hear the giggles at Microsoft&#8217;s marketing department &#8211; no wonder we call the service &#8220;MSN&#8221; over here. I understand that the employees need some entertainment while <a href="http://news.softpedia.com/news/Top-Microsoft-Executives-Are-Leaving-the-Company-Like-Rats-from-a-Sinking-Ship-76553.shtml" class="external">the ship that is Microsoft is sinking</a>.</p> Wed, 06 Jan 2010 23:17:59 +0100 http://termos.vemod.net/contact 2010-01-06T23:17:59+01:00 Christoffer Sawicki http://termos.vemod.net/christoffer-sawicki <p>Hello! My name is Christoffer Sawicki and this is my domain on the web. I live in the south of <a href="http://en.wikipedia.org/wiki/Sweden" class="external">Sweden</a> in <a href="http://en.wikipedia.org/wiki/Lund" class="external">the city of Lund</a> where I practice <a href="http://www.data.lth.se/">Computer Science and Engineering</a>-fu at <a href="http://www.lth.se/" class="external"><span class="caps">LTH</span></a><sup><a href="#fn1">1</a></sup>. I really enjoy instructing computers to do sophisticated things. Preferably while listening to <a href="music" class="external">music</a>, mostly metal but also some post-rock and folk tunes. I also enjoy <em>s-st-st-</em>stuttering, drinking tea, <a href="http://quotes.vemod.net/" class="external">collecting quotes</a> and <a href="http://photos.vemod.net/" class="external">taking photographs</a>.</p> <div style="display: none">According to some surrealist, I&#8217;m simply <a href="http://thesurrealist.co.uk/priorart.cgi?ref=Qerub" class="external">a pudding that communicates via Instant Messenger</a> and I agree wholeheartedly. And oh, I&#8217;m called <a href="http://termos.vemod.net/qerub">Qerub</a> in some contexts.</div> <p>Feel free to <a href="http://termos.vemod.net/contact">contact me</a> if you want.</p> <p id="fn1"><sup>1</sup> The Faculty of Engineering at <a href="http://www.lu.se/" class="external">Lund University</a></p> Wed, 06 Jan 2010 23:15:14 +0100 http://termos.vemod.net/christoffer-sawicki 2010-01-06T23:15:14+01:00 My Shortwave Commands http://termos.vemod.net/my-shortwave-commands <p><a href="http://shortwaveapp.com/" class="external">Shortwave</a> is a great service that keyword search-enables any JavaScript-capable web browser. (I use Shortwave instead of <a href="http://alexstaubo.github.com/keywurl/" class="external">Keywurl</a> for Safari because it has a much better UI and isn&#8217;t a hack.)</p> <p>My Shortwave commands are available at <a href="http://vemod.net/misc/waves.txt" class="external">http://vemod.net/misc/waves.txt</a>. Copy what you like.</p> Sat, 19 Dec 2009 15:22:53 +0100 http://termos.vemod.net/my-shortwave-commands 2009-12-19T15:22:53+01:00 interactEither http://termos.vemod.net/interacteither <p><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:interact" class="external"><code>interact</code></a> is a very handy function, but it doesn&#8217;t handle computations that can fail. Here&#8217;s another convenience function that addresses that:</p> <pre><code class="ultraviolet"><span class="Keyword">import</span> <span class="UserDefinedConstant">System</span>.<span class="UserDefinedConstant">IO</span> <span class="Keyword">import</span> <span class="UserDefinedConstant">System</span>.<span class="UserDefinedConstant">Exit</span> <span class="FunctionName">interactEither</span> :: <span class="UserDefinedConstant">Show</span> <span class="Variable">a</span> =&gt; (<span class="UserDefinedConstant">String</span> -&gt; <span class="UserDefinedConstant">Either</span> <span class="Variable">a</span> <span class="UserDefinedConstant">String</span>) -&gt; <span class="UserDefinedConstant">IO</span> () interactEither f = <span class="FunctionName">getContents</span> &gt;&gt;= either (<span class="FunctionName">error</span> . <span class="FunctionName">show</span>) success . f <span class="Keyword">where</span> success x = hPutStrLn stdout x &gt;&gt; exitSuccess <span class="FunctionName">error</span> x = hPutStrLn stderr x &gt;&gt; exitFailure </code></pre><p><small>Tags: <a href="http://termos.vemod.net/haskell" class="tag" rel="tag">Haskell</a></small></p> Sun, 06 Dec 2009 00:37:02 +0100 http://termos.vemod.net/interacteither 2009-12-06T00:37:02+01:00 isInteger http://termos.vemod.net/isinteger <p>A useful snippet:</p> <pre><code class="ultraviolet"><span class="Keyword">import</span> <span class="UserDefinedConstant">Text</span>.<span class="UserDefinedConstant">Regex</span>.<span class="UserDefinedConstant">Posix</span> ((=~)) <span class="FunctionName">isInteger</span> :: <span class="UserDefinedConstant">String</span> -&gt; <span class="UserDefinedConstant">Bool</span> isInteger = (=~ <span class="String"><span class="String">&quot;</span>^[0-9]+$<span class="String">&quot;</span></span>) </code></pre><p><small>Tags: <a href="http://termos.vemod.net/haskell" class="tag" rel="tag">Haskell</a></small></p> Sun, 06 Dec 2009 00:31:57 +0100 http://termos.vemod.net/isinteger 2009-12-06T00:31:57+01:00 List of Static File CMSes http://termos.vemod.net/list-of-static-file-cmses <p>...with a rather wide meaning of the name <acronym title="Content Management System">CMS</acronym>.</p> <p>This list is supposed to be comprehensive, so please <a href="http://termos.vemod.net/contact">contact me</a> if some system is missing.</p> <h2><a href="http://termos.vemod.net/haskell">Haskell</a> Powered</h2> <ul> <li><a href="http://github.com/jaspervdj/Hakyll" class="external">Hakyll</a></li> </ul> <h2><a href="http://termos.vemod.net/ruby">Ruby</a> Powered</h2> <ul> <li><a href="http://hobix.github.com/hobix/" class="external">Hobix</a></li> <li><a href="http://github.com/mojombo/jekyll/tree/master" class="external">Jekyll</a></li> <li><a href="http://nanoc.stoneship.org/" class="external">Nanoc</a></li> <li><a href="http://rassmalog.rubyforge.org/" class="external">Rassmalog</a></li> <li><a href="http://rog.rubyforge.org/" class="external">Rog</a></li> <li><a href="http://rote.rubyforge.org/" class="external">Rote</a></li> <li><a href="http://www.apeth.com/RubyFrontierDocs/default.html" class="external">RubyFrontier</a></li> <li><a href="http://staticmatic.rubyforge.org/" class="external">StaticMatic</a></li> <li><a href="http://staticweb.rubyforge.org/" class="external">StaticWeb</a></li> <li><a href="http://github.com/chneukirchen/trivium/tree/master" class="external">Trivium</a></li> <li><a href="http://webby.rubyforge.org/" class="external">Webby</a></li> <li><a href="http://webgen.rubyforge.org/" class="external">webgen</a></li> <li><a href="http://yurtcms.roberthahn.ca/" class="external">Yurt <span class="caps">CMS</span></a></li> <li><a href="http://www.zenspider.com/ZSS/Products/ZenWeb/" class="external">ZenWeb</a></li> </ul> <h2>Perl Powered</h2> <ul> <li><a href="http://ikiwiki.info/" class="external">ikiwiki</a></li> <li><a href="http://www.blosxom.com/" class="external">blosxom</a></li> </ul> <h2><a href="http://termos.vemod.net/python">Python</a> Powered</h2> <ul> <li><a href="http://github.com/lethain/aym-cms/tree/master" class="external"><span class="caps">AYM CMS</span></a></li> <li><a href="http://github.com/lakshmivyas/hyde/tree/master" class="external">Hyde</a></li> <li><a href="http://pyblosxom.sourceforge.net/" class="external">PyBlosxom</a></li> </ul> <h2>Thanks!</h2> <p>Thanks to <a href="http://tosh.at/" class="external">Thomas Schranz</a> for sending me two more entries.</p><p><small>Tags: <a href="http://termos.vemod.net/ruby" class="tag" rel="tag">Ruby</a>, <a href="http://termos.vemod.net/web" class="tag" rel="tag">Web</a>, and <a href="http://termos.vemod.net/python" class="tag" rel="tag">Python</a></small></p> Sat, 05 Dec 2009 14:45:35 +0100 http://termos.vemod.net/list-of-static-file-cmses 2009-12-05T14:45:35+01:00 Termos