<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.8.5">Jekyll</generator><link href="https://larsnordeide.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://larsnordeide.com/" rel="alternate" type="text/html" /><updated>2020-12-30T00:11:17+01:00</updated><id>https://larsnordeide.com/feed.xml</id><title type="html">larsnordeide.com</title><subtitle>Homepage and blog for Lars Magnus Nordeide</subtitle><author><name>Lars Magnus Nordeide</name></author><entry><title type="html">Goodbye Octopress, Hello Jekyll</title><link href="https://larsnordeide.com/blog/goodbye-octopress-hello-jekyll.html" rel="alternate" type="text/html" title="Goodbye Octopress, Hello Jekyll" /><published>2019-05-06T21:38:14+02:00</published><updated>2019-05-06T21:38:14+02:00</updated><id>https://larsnordeide.com/blog/goodbye-octopress-hello-jekyll</id><content type="html" xml:base="https://larsnordeide.com/blog/goodbye-octopress-hello-jekyll.html">&lt;p&gt;It has been almost four years since I last tinkered with my site. I recently got a message from my service provider that the hardware of my old server was being discontinued, requiring me to move to a new one. As usual this is a good opportunity to refresh the technology I am using and update the design of the site.&lt;/p&gt;

&lt;p&gt;I have been using Octopress for years now, first Octopress 2.0 which relied on cloning a Github repo and modifying the content, then Octopress 3.0 which was refactored to providing all enhancements as Jekyll plugins.&lt;/p&gt;

&lt;p&gt;I had originally planned to just upgrade to latest versions of packages and changing the theme I used, but this proved challenging. Octopress hasn’t been updated by the author for a long time and pull requests provided by others are mainly untouched so the tool seems pretty dead by now. This also means that it isn’t compatible with a lot of the latest Ruby and Jekyll packages. I therefore decided it was just as easy to find a nice Jekyll theme and start over with a fresh Jekyll site.&lt;/p&gt;

&lt;p&gt;I am not advanced enough to create a Jekyll theme from scratch on my own. I therefore rely on the work of others. The last iteration of my site I used the &lt;a href=&quot;https://mademistakes.com/work/hpstr-jekyll-theme/&quot;&gt;HPSTR&lt;/a&gt; theme from &lt;a href=&quot;https://mademistakes.com/&quot;&gt;Made Mistakes&lt;/a&gt;. Though I was medium happy with the design, the theme itself was feature rich and very well put together. It was therefore easy choice to start at the same place this time, too.&lt;/p&gt;

&lt;p&gt;The theme &lt;a href=&quot;https://mademistakes.com/work/minimal-mistakes-jekyll-theme/&quot;&gt;Minimal Mistakes&lt;/a&gt; is very simple and clean. I really like this one. It is very easy to customize, well documented and provides almost all features that Octopress was providing for me earlier. This has let me eliminate nearly all Octopress plugins I was using. I have kept the main &lt;a href=&quot;https://github.com/octopress/octopress&quot;&gt;Octopress&lt;/a&gt; plugin as the commands it has for post management and site deployment is still very convenient to use.&lt;/p&gt;

&lt;p&gt;Another really nice feature of this theme is that it is gem-based. All the theme defaults are packaged into a Ruby gem which significantly reduces the number of files you need to manage. Just include the gem in your Gemfile and make a &lt;code class=&quot;highlighter-rouge&quot;&gt;_config.yml&lt;/code&gt; and you are good to go.&lt;/p&gt;

&lt;p&gt;As part of the tool refresh, I have started to use &lt;code class=&quot;highlighter-rouge&quot;&gt;wsl&lt;/code&gt; (Windows Subsystem for Linux) with Ubuntu distribution for all command line operations, i.e. Jekyll compiling and site deployment. This was a step change as most site management tools are Linux based, and I don’t have to spend time trying to find Windows versions of common Linux commands any more. E.g. it let’s me use &lt;code class=&quot;highlighter-rouge&quot;&gt;ruby-install&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;chruby&lt;/code&gt; to manage Ruby versions.&lt;/p&gt;

&lt;p&gt;I made this post to document for myself the changes needed to migrate to new theme and Jekyll 3 like I did when I migrated from &lt;a href=&quot;/blog/migrating-to-octopress-3-0.html&quot;&gt;Octopress 2 to 3&lt;/a&gt;, but this operation was quite painless and needed very little customization and change of my old posts.&lt;/p&gt;</content><author><name>Lars Magnus Nordeide</name></author><category term="jekyll" /><category term="octopress" /><category term="blog" /><summary type="html">Refreshing my site and update the tools used to manage it. TLDR: I am eliminating reliance on Octopress and going pure Jekyll.</summary></entry><entry><title type="html">Migrating from Octopress 2.0 to Octopress 3.0</title><link href="https://larsnordeide.com/blog/migrating-to-octopress-3-0.html" rel="alternate" type="text/html" title="Migrating from Octopress 2.0 to Octopress 3.0" /><published>2015-07-25T23:29:34+02:00</published><updated>2015-07-25T23:29:34+02:00</updated><id>https://larsnordeide.com/blog/migrating-to-octopress-3-0</id><content type="html" xml:base="https://larsnordeide.com/blog/migrating-to-octopress-3-0.html">&lt;p&gt;I have been planning to move my blog to a new server and I thought it would be a good opportunity to try to migrate to the latest version of Octopress. I have noticed the development ongoing on Octopress 3.0 for a long time, and after the write-up about it on the main &lt;a href=&quot;http://octopress.org/2015/01/15/octopress-3.0-is-coming/&quot;&gt;Octopress site&lt;/a&gt; I have been looking for the right time to test it.&lt;/p&gt;

&lt;p&gt;To be clear, Octopress 3.0 is not done yet, but it has come pretty far. I am not sure if you can call it in beta stage yet, but it is pretty stable and works well.&lt;/p&gt;

&lt;p&gt;Using Octopress 3.0 is very different than Octopress 2.0, but it is much simpler. Gone is the requirement to clone the official repository, instead Octopress is now a collection of Jekyll plugins. Styling can be done with Jekyll themes or Octopress 3.0 themes. There isn’t much of  Octopress 3.0 specific themes available yet, the only one I have found is the Genesis theme in the Octopress repository and that is still under development. For the migration I am sticking with the default theme and will look into using Octopress Ink to create my own later.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;h2 id=&quot;using-octopress-30&quot;&gt;Using Octopress 3.0&lt;/h2&gt;
&lt;p&gt;Instead of the custom rake commands that was used by 2.0, Octopress now has a separate ‘octopress’ command which is used to create and manage posts, and to deploy the site. Compiling the site is done using standard ‘jekyll’ commands. Check the documentation &lt;a href=&quot;https://github.com/octopress/octopress&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;installing&quot;&gt;Installing&lt;/h2&gt;
&lt;p&gt;Installing Octopress 3.0 is as simple as installing the Jekyll gem and then add the Octopress gems as Jekyll plugins.&lt;/p&gt;

&lt;h3 id=&quot;set-up-gems&quot;&gt;Set up gems&lt;/h3&gt;
&lt;p&gt;Install &lt;a href=&quot;http://bundler.io/&quot;&gt;Bundler&lt;/a&gt; and create a Gemfile with the following:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;source&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'https://rubygems.org'&lt;/span&gt;
 
&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'jekyll'&lt;/span&gt;
 
&lt;span class=&quot;n&quot;&gt;group&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:jekyll_plugins&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'octopress'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'~&amp;gt; 3.0'&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Install gems with&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bundle install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;create-a-new-site&quot;&gt;Create a new site&lt;/h3&gt;
&lt;p&gt;Create a new site with the command&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;octopress new &amp;lt;site&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This creates a folder with the scaffolding needed for your site. Remember to move the Gemfile to the generated site folder. This enables automatic use of gems added to bundle. If you don’t do this you have to add each gem to &lt;code class=&quot;highlighter-rouge&quot;&gt;_config.yml&lt;/code&gt; to enable them.&lt;/p&gt;

&lt;p&gt;You can test the new site with the command&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;jekyll serve
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;migrating-old-posts&quot;&gt;Migrating old posts&lt;/h2&gt;

&lt;p&gt;Copy posts from your old site to the &lt;code class=&quot;highlighter-rouge&quot;&gt;_posts&lt;/code&gt; folder and images to the &lt;code class=&quot;highlighter-rouge&quot;&gt;image&lt;/code&gt; folder. Basic installation of Octopress 3.0 does not have support of everything version 2.0 has, but there are plugins for almost everything. E.g. to use the image tag &lt;code class=&quot;highlighter-rouge&quot;&gt;{% img %}&lt;/code&gt; just install the &lt;a href=&quot;https://github.com/octopress/image-tag&quot;&gt;octopress-image-tag&lt;/a&gt; plugin. I recommend copying posts one-by-one to make it easier to catch which Octopress plugins you need. The output from &lt;code class=&quot;highlighter-rouge&quot;&gt;jekyll build&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;jekyll serve&lt;/code&gt; will show when something is missing.&lt;/p&gt;

&lt;p&gt;You find the full list of available Octopress plugins on the &lt;a href=&quot;https://github.com/octopress&quot;&gt;GitHub site&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is the Gemfile I ended up with after migrating all posts:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;source&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'https://rubygems.org'&lt;/span&gt;
 
&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'jekyll'&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'wdm'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'&amp;gt;= 0.1.0'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Gem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;win_platform?&lt;/span&gt;
 
&lt;span class=&quot;n&quot;&gt;group&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:jekyll_plugins&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'octopress'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'~&amp;gt; 3.0'&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'octopress-codeblock'&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'octopress-codefence'&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'octopress-solarized'&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'octopress-pullquote-tag'&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'octopress-image-tag'&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'octopress-render-code'&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;styling-and-layout&quot;&gt;Styling and layout&lt;/h2&gt;

&lt;p&gt;The difference in styling and layout of your migrated post will, of course, depend on the theme you are using. I wanted to focus on getting the content and plugins in place first, so I selected to use the default Jekyll theme while migrating and only do minimal tweaks to the CSS layout when needed to make the posts look reasonable.&lt;/p&gt;

&lt;h3 id=&quot;code-block-styling&quot;&gt;Code block styling&lt;/h3&gt;

&lt;p&gt;To get the same code styling as is default in Octopress 2.0, i.e. Solarized, use the &lt;a href=&quot;https://github.com/octopress/solarized&quot;&gt;octopress-solarized&lt;/a&gt; plugin. Remember to add &lt;code class=&quot;highlighter-rouge&quot;&gt;{% css_asset_tag %}&lt;/code&gt; to the site layout if you are using a Jekyll based theme. In the default layout you add it to &lt;code class=&quot;highlighter-rouge&quot;&gt;_layout/default.html&lt;/code&gt;.&lt;/p&gt;

&lt;h3 id=&quot;image-layout&quot;&gt;Image layout&lt;/h3&gt;
&lt;p&gt;Default theme is pretty basic and does not contain much styling of images, so there is no support of the layout options for the &lt;code class=&quot;highlighter-rouge&quot;&gt;{% img %}&lt;/code&gt; tag. I added basic layout support by copying from the Octopress 2.0 layout.&lt;/p&gt;

&lt;div class=&quot;language-sass highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nc&quot;&gt;.basic-alignment&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;err&quot;&gt;&amp;amp;.&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;err&quot;&gt; { &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;margin-right&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;.5em&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;err&quot;&gt;&amp;amp;.&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;right&lt;/span&gt;&lt;span class=&quot;err&quot;&gt; { &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;right&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;margin-left&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;.5em&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;err&quot;&gt;&amp;amp;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;err&quot;&gt; { &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;auto&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;.5em&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;err&quot;&gt;&amp;amp;.&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;, &amp;amp;.&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;right&lt;/span&gt;&lt;span class=&quot;err&quot;&gt; { &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;margin-bottom&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;.8em&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;flex-content&lt;/span&gt;&lt;span class=&quot;err&quot;&gt; { &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;max-width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;100%&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;@extend&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;.flex-content&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;@extend&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;.basic-alignment&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;pull-quotes&quot;&gt;Pull-quotes&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&quot;https://github.com/octopress/pullquote-tag&quot;&gt;pull-quote&lt;/a&gt; plugin does not ship with it’s own CSS styling so to make them show up it is necessary to add the styling classes to the theme. Inspired by &lt;a href=&quot;http://miekd.com/articles/pull-quotes-with-html5-and-css/&quot;&gt;this article&lt;/a&gt; I added the following to theme layout.&lt;/p&gt;

&lt;div class=&quot;language-sass highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cm&quot;&gt;/*
&lt;/span&gt; &lt;span class=&quot;cm&quot;&gt;* Pull quotes
&lt;/span&gt; &lt;span class=&quot;cm&quot;&gt;*/
&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;.pullquote-right&lt;/span&gt;&lt;span class=&quot;nd&quot;&gt;:before&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;cm&quot;&gt;/* Reset metrics. */
&lt;/span&gt;    &lt;span class=&quot;nl&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nl&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;cm&quot;&gt;/* Content */
&lt;/span&gt;    &lt;span class=&quot;nl&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;attr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data-pullquote&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;cm&quot;&gt;/* Pull out to the right, modular scale based margins. */
&lt;/span&gt;    &lt;span class=&quot;nl&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;right&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nl&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;320px&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nl&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;12px&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0px&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;24px&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;36px&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;cm&quot;&gt;/* Baseline correction */
&lt;/span&gt;    &lt;span class=&quot;nl&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;relative&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nl&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;5px&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;cm&quot;&gt;/* Typography (30px line-height equals 25% incremental leading) */
&lt;/span&gt;    &lt;span class=&quot;nl&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;23px&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nl&quot;&gt;line-height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;30px&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nc&quot;&gt;.pullquote-left&lt;/span&gt;&lt;span class=&quot;nd&quot;&gt;:before&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;cm&quot;&gt;/* Reset metrics. */
&lt;/span&gt;    &lt;span class=&quot;nl&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nl&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;cm&quot;&gt;/* Content */
&lt;/span&gt;    &lt;span class=&quot;nl&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;attr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data-pullquote&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;cm&quot;&gt;/* Pull out to the left, modular scale based margins. */
&lt;/span&gt;    &lt;span class=&quot;nl&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nl&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;251px&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nl&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;12px&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;31px&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;24px&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0px&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;cm&quot;&gt;/* Baseline correction */
&lt;/span&gt;    &lt;span class=&quot;nl&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;relative&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nl&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;5px&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;cm&quot;&gt;/* Typography (30px line-height equals 25% incremental leading) */
&lt;/span&gt;    &lt;span class=&quot;nl&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;23px&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nl&quot;&gt;line-height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;30px&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;deployment&quot;&gt;Deployment&lt;/h2&gt;
&lt;p&gt;Octopress 3.0 have built in deployment using git, s3, rsync and more. As I am hosting my site using nginx on my own server I use rsync to deploy.&lt;/p&gt;

&lt;p&gt;Again, Octopress 3.0 makes it pretty simple to set it up, just use&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;octopress deploy init rsync
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;to create your deployment configuration &lt;code class=&quot;highlighter-rouge&quot;&gt;_deploy.yml&lt;/code&gt; which you can edit to set specific configuration.&lt;/p&gt;

&lt;h3 id=&quot;rsync&quot;&gt;Rsync&lt;/h3&gt;
&lt;p&gt;If you deploy from Windows you need to install the rsync command yourself. I used &lt;a href=&quot;https://www.itefix.net/cwrsync&quot;&gt;cwRsync&lt;/a&gt; which has a free version based on cygwin. Simply download zip, extract and add to path. Modify &lt;code class=&quot;highlighter-rouge&quot;&gt;cwrsync.cmd&lt;/code&gt; to match your environment.&lt;/p&gt;

&lt;h3 id=&quot;permissions&quot;&gt;Permissions&lt;/h3&gt;
&lt;p&gt;nginx is quite strict on file permissions on the host, and I found with help from &lt;a href=&quot;http://www.papayasoft.com/2013/12/10/octopress-rsync-custom-chmod-permission/&quot;&gt;this article&lt;/a&gt; that you need to set the permissions every time you deploy. Adding the following rsync flags to &lt;code class=&quot;highlighter-rouge&quot;&gt;_deploy.yml&lt;/code&gt; fixed it.&lt;/p&gt;

&lt;p&gt;OSX:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;flags:  -avz --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Windows:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;flags:  -avz -e &quot;ssh -i /cygdrive/C/key/id_rsa&quot; --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;On Windows it is also necessary to add the full path to the SSH key, on OSX you can just add the key to your key chain.&lt;/p&gt;

&lt;h2 id=&quot;tips&quot;&gt;Tips&lt;/h2&gt;

&lt;h3 id=&quot;installingupdating-ruby-on-windows&quot;&gt;Installing/updating Ruby on Windows&lt;/h3&gt;
&lt;p&gt;On Windows use &lt;a href=&quot;https://github.com/scottmuc/yari&quot;&gt;yari&lt;/a&gt;.
To use Ruby 2.2.2 use the command &lt;code class=&quot;highlighter-rouge&quot;&gt;yari 2.2.2&lt;/code&gt; which will download Ruby and set-up the path.&lt;/p&gt;

&lt;h3 id=&quot;ruby-222-gems&quot;&gt;Ruby 2.2.2 gems&lt;/h3&gt;
&lt;p&gt;Ruby 2.2.2 is fairly recent and not all pre-compiled gems supports it yet. Running &lt;code class=&quot;highlighter-rouge&quot;&gt;jekyll serve&lt;/code&gt; may lead to exceptions like this&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;yari/ruby-2.2.2-i386-mingw32/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- hitimes/hitimes (LoadError)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If this happens you must remove the gem that causes the LoadError and re-install it using &lt;code class=&quot;highlighter-rouge&quot;&gt;--platform ruby&lt;/code&gt; when installing.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gem uninstall hitimes

**Remove ALL versions**

gem install hitimes -v 1.2.2 --platform ruby
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will recompile the gem on your system.&lt;/p&gt;

&lt;h3 id=&quot;displaying-liquid-tags-in-posts&quot;&gt;Displaying liquid tags in posts&lt;/h3&gt;
&lt;p&gt;Displaying liquid tags like &lt;code class=&quot;highlighter-rouge&quot;&gt;{% codeblock %}&lt;/code&gt; in posts like this can be hard as these tags are always interpreted by Jekyll. There is no short and easy way to escape them, especially in inline text. Some Googling showed that it it is possible with some esoteric use of &lt;code class=&quot;highlighter-rouge&quot;&gt;{% raw %}&lt;/code&gt; to escape liquid tags inline, but it is really awkward. The simple solution is to use the Octopress plugin &lt;a href=&quot;https://github.com/octopress/escape-code&quot;&gt;octopress-escape-code&lt;/a&gt; which automatically escapes code blocks and more. Just add the plugin to the Gemfile and add &lt;code class=&quot;highlighter-rouge&quot;&gt;escape_code: true&lt;/code&gt; to the posts YAML front-matter.&lt;/p&gt;</content><author><name>Lars Magnus Nordeide</name></author><category term="octopress" /><category term="blog" /><category term="jekyll" /><summary type="html">I have been planning to move my blog to a new server and I thought it would be a good opportunity to try to migrate to the latest version of Octopress. I have noticed the development ongoing on Octopress 3.0 for a long time, and after the write-up about it on the main Octopress site I have been looking for the right time to test it. To be clear, Octopress 3.0 is not done yet, but it has come pretty far. I am not sure if you can call it in beta stage yet, but it is pretty stable and works well. Using Octopress 3.0 is very different than Octopress 2.0, but it is much simpler. Gone is the requirement to clone the official repository, instead Octopress is now a collection of Jekyll plugins. Styling can be done with Jekyll themes or Octopress 3.0 themes. There isn’t much of Octopress 3.0 specific themes available yet, the only one I have found is the Genesis theme in the Octopress repository and that is still under development. For the migration I am sticking with the default theme and will look into using Octopress Ink to create my own later.</summary></entry><entry><title type="html">Upgrading the BIOS of a HP Z820 Workstation</title><link href="https://larsnordeide.com/hardware/upgrading-the-bios-of-a-hp-z820-workstation.html" rel="alternate" type="text/html" title="Upgrading the BIOS of a HP Z820 Workstation" /><published>2014-03-24T18:52:48+01:00</published><updated>2014-03-24T18:52:48+01:00</updated><id>https://larsnordeide.com/hardware/upgrading-the-bios-of-a-hp-z820-workstation</id><content type="html" xml:base="https://larsnordeide.com/hardware/upgrading-the-bios-of-a-hp-z820-workstation.html">&lt;p&gt;I recently bought a SSD drive for my HP Z820 workstation for use as the main drive. This weekend when I installed it I discovered that I needed to upgrade my BIOS as the one I had did not fully support AHCI mode. I haven’t had any need to upgrade the BIOS earlier so the BIOS version (01.02) was two years old. I always find such an operation a bit scary so as long as the BIOS does what it needs to I leave it pretty much alone. But now that I had the need I went to the &lt;a href=&quot;http://h20565.www2.hp.com/portal/site/hpsc/public/psi/swdHome/?cc=no&amp;amp;cc=no&amp;amp;lang=en&amp;amp;lang=no&amp;amp;sp4ts.oid=5225043&amp;amp;ac.admitted=1395684595056.876444892.492883150&quot;&gt;HP support site&lt;/a&gt; and downloaded the latest BIOS for this workstation. Right now this is version 03.65.&lt;/p&gt;

&lt;p&gt;After extracting the SoftPAQ I ran the Microsoft Windows utility to install the BIOS (HPQFlash.exe). It ran through the full upgrade procedure, first saving the current BIOS then flashing the new one. As soon as it completed writing the last block it immediately threw up this scary error message: &lt;code class=&quot;highlighter-rouge&quot;&gt;An unrecoverable error has occurred while flashing the BIOS. Error code = 0x0D.&lt;/code&gt;&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;This is not what you want to see when flashing the BIOS. Luckily, the BIOS was not trashed. It seems like the BIOS is only actually flashed when HPQFlash has successfully finished writing all the BIOS blocks, so big thanks to the HP engineers for that. But still I was not able to do the BIOS upgrade. I also tried to do the upgrade from the Computer Setup menu (F10), but that wouldn’t even  accept the .BIN file.&lt;/p&gt;

&lt;p&gt;That last attempt made me suspicious and after digging around a bit I found that it is not possible to upgrade directly to the latest BIOS from such an old BIOS version as 01.02. It is necessary to go via an interim version first. The solution was to download and install &lt;a href=&quot;http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareDescription.jsp?lang=en&amp;amp;cc=us&amp;amp;prodTypeId=12454&amp;amp;prodSeriesId=5225041&amp;amp;prodNameId=5225043&amp;amp;swEnvOID=4059&amp;amp;swLang=13&amp;amp;mode=2&amp;amp;taskId=135&amp;amp;swItem=wk-116863-1&quot;&gt;BIOS version 01.20&lt;/a&gt; first. After successfully updating to this version I was then able to upgrade to BIOS version 03.65 after.&lt;/p&gt;</content><author><name>Lars Magnus Nordeide</name></author><category term="hardware" /><category term="hp" /><summary type="html">I recently bought a SSD drive for my HP Z820 workstation for use as the main drive. This weekend when I installed it I discovered that I needed to upgrade my BIOS as the one I had did not fully support AHCI mode. I haven’t had any need to upgrade the BIOS earlier so the BIOS version (01.02) was two years old. I always find such an operation a bit scary so as long as the BIOS does what it needs to I leave it pretty much alone. But now that I had the need I went to the HP support site and downloaded the latest BIOS for this workstation. Right now this is version 03.65. After extracting the SoftPAQ I ran the Microsoft Windows utility to install the BIOS (HPQFlash.exe). It ran through the full upgrade procedure, first saving the current BIOS then flashing the new one. As soon as it completed writing the last block it immediately threw up this scary error message: An unrecoverable error has occurred while flashing the BIOS. Error code = 0x0D.</summary></entry><entry><title type="html">PySDL2: Playing a sound from a WAV file take two - using SDL2_mixer</title><link href="https://larsnordeide.com/python/pysdl2-playing-a-sound-from-a-wav-file-with-sdlmixer.html" rel="alternate" type="text/html" title="PySDL2: Playing a sound from a WAV file take two - using SDL2_mixer" /><published>2014-02-10T20:40:00+01:00</published><updated>2014-02-10T20:40:00+01:00</updated><id>https://larsnordeide.com/python/pysdl2-playing-a-sound-from-a-wav-file-with-sdlmixer</id><content type="html" xml:base="https://larsnordeide.com/python/pysdl2-playing-a-sound-from-a-wav-file-with-sdlmixer.html">&lt;p&gt;Yesterday I wrote about &lt;a href=&quot;/python/pysdl2-playing-a-sound-from-a-wav-file.html&quot;&gt;playing a WAVE sound using basic PySDL2&lt;/a&gt;. I also mentioned that I thought that using the &lt;a href=&quot;http://www.libsdl.org/projects/SDL_mixer/docs/index.html&quot;&gt;SDL2_mixer&lt;/a&gt; extension (or &lt;code class=&quot;highlighter-rouge&quot;&gt;sdl2.sdlmixer&lt;/code&gt; as it is called in PySDL2) would probably be easier. What I didn’t anticipate was how much easier it would be. Using &lt;code class=&quot;highlighter-rouge&quot;&gt;sdl2.sdlmixer&lt;/code&gt; more than halved the lines of code necessary to play the wav file, most importantly by removing the requirement to create a callback function to feed frames to the sound buffer.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;The caveat is that you have to install the SDL2_mixer extension, of course. Just follow the instructions from the &lt;a href=&quot;http://pysdl2.readthedocs.org/en/latest/install.html&quot;&gt;PySDL2 documentation&lt;/a&gt;, the simplest is to download the pre-built binaries. Then you have to make PySDL2 find the extension libraries. The installation guide talks about installing to the system or modifying &lt;code class=&quot;highlighter-rouge&quot;&gt;PYTHONPATH&lt;/code&gt;, but the preferred method is actually to store the libraries in a custom folder and setting &lt;code class=&quot;highlighter-rouge&quot;&gt;PYSDL2_DLL_PATH&lt;/code&gt; to the full path of that folder.&lt;/p&gt;

&lt;p&gt;Once the extension is installed and working the code is simply this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sdl2&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sdl2.ext&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Resources&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sdl2.ext.compat&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;byteify&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sdl2.sdlmixer&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;except&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;ImportError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;traceback&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;traceback&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;print_exc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;RESOURCES&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Resources&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__file__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;assets&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SDL_Init&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SDL_INIT_AUDIO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;RuntimeError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Cannot initialize audio system: {}&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SDL_GetError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()))&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Mix_OpenAudio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;44100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MIX_DEFAULT_FORMAT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1024&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;RuntimeError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Cannot open mixed audio: {}&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Mix_GetError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()))&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;sound_file&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RESOURCES&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;tada.wav&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sample&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Mix_LoadWAV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;byteify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sound_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sample&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;RuntimeError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Cannot open audio file: {}&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Mix_GetError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;channel&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Mix_PlayChannel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sample&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;channel&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;RuntimeError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Cannot play sample: {}&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Mix_GetError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()))&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Mix_Playing&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;channel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;SDL_Delay&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;Mix_CloseAudio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;SDL_Quit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SDL_INIT_AUDIO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;The code is simply initialize the audio system using standard &lt;code class=&quot;highlighter-rouge&quot;&gt;SDL_Init&lt;/code&gt; then initialize the mixer API with &lt;code class=&quot;highlighter-rouge&quot;&gt;Mix_OpenAudio&lt;/code&gt; before loading the wav file. This is different than the basic SDL2 API where you load the file first and then open the audio device. Finally, play the sound with &lt;code class=&quot;highlighter-rouge&quot;&gt;Mix_PlayChannel&lt;/code&gt; and wait until it has completed.&lt;/p&gt;</content><author><name>Lars Magnus Nordeide</name></author><category term="Python" /><category term="PySDL2" /><category term="audio" /><summary type="html">Yesterday I wrote about playing a WAVE sound using basic PySDL2. I also mentioned that I thought that using the SDL2_mixer extension (or sdl2.sdlmixer as it is called in PySDL2) would probably be easier. What I didn’t anticipate was how much easier it would be. Using sdl2.sdlmixer more than halved the lines of code necessary to play the wav file, most importantly by removing the requirement to create a callback function to feed frames to the sound buffer.</summary></entry><entry><title type="html">PySDL2: Playing a sound from a WAV file</title><link href="https://larsnordeide.com/python/pysdl2-playing-a-sound-from-a-wav-file.html" rel="alternate" type="text/html" title="PySDL2: Playing a sound from a WAV file" /><published>2014-02-09T23:14:55+01:00</published><updated>2014-02-09T23:14:55+01:00</updated><id>https://larsnordeide.com/python/pysdl2-playing-a-sound-from-a-wav-file</id><content type="html" xml:base="https://larsnordeide.com/python/pysdl2-playing-a-sound-from-a-wav-file.html">&lt;p&gt;For the last couple of weeks I have been playing around with &lt;a href=&quot;http://pysdl2.readthedocs.org/&quot;&gt;PySDL2&lt;/a&gt; to learn a bit of game programming. Figuring that prototyping in Python was a good place to start learning, I originally planned to use &lt;a href=&quot;http://pygame.org/&quot;&gt;Pygame&lt;/a&gt; which is a popular wrapper and extension of SDL. Now it seems that SDL (and Pygame) has been discontinued and PySDL2 looks to be the successor.&lt;/p&gt;

&lt;p&gt;So far, using PySDL2 has been both easy and fun to create graphics and move them around, especially when using the extensions methods in &lt;a href=&quot;http://pysdl2.readthedocs.org/en/latest/modules/sdl2ext.html&quot;&gt;sdl2.ext&lt;/a&gt;. But when adding sound to the mix, I hit upon a bit of trouble. For playing sounds it is necessary to use the SDL2 library functions. I decided to use a WAVE file (.wav) for my sound testing which meant using &lt;code class=&quot;highlighter-rouge&quot;&gt;SDL_LoadWav&lt;/code&gt; to load the file. PySDL2 uses a &lt;a href=&quot;http://docs.python.org/library/ctypes.html#ctypes&quot;&gt;ctypes&lt;/a&gt; wrapper around the SDL2 library so that you can use the methods in almost the exact same way as from C code. This is both good and bad. The bad, at least for me, was that I had very little experience with ctypes and spent a lot of time figuring out how to declare the variables and types to use in the function calls. PySDL2 offer very little documentation on how to do it, and the SDL2 documentation doesn’t have too much example code on using &lt;code class=&quot;highlighter-rouge&quot;&gt;SDL_LoadWav&lt;/code&gt; with &lt;code class=&quot;highlighter-rouge&quot;&gt;SDL_OpenAudio&lt;/code&gt;. After a lot of trying and failing I finally figured out a way that worked.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;I also hit on a bug in the PySDL2 wrapper: &lt;code class=&quot;highlighter-rouge&quot;&gt;SDL_LoadWav&lt;/code&gt; is a macro that calls &lt;code class=&quot;highlighter-rouge&quot;&gt;SDL_LoadWav_RW&lt;/code&gt; wrapping the RWOPS part. What I found was that the PySDL2 macro uses wrong encoding of the mode string in the &lt;code class=&quot;highlighter-rouge&quot;&gt;SDL_RWFromFile&lt;/code&gt; call which makes &lt;code class=&quot;highlighter-rouge&quot;&gt;SDL_LoadWav&lt;/code&gt; fail. To make it work I had to call &lt;code class=&quot;highlighter-rouge&quot;&gt;SDL_LoadWav_RW&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;SDL_RWFromFile&lt;/code&gt; myself as you see below. Also note the use of the compatibility method byteify() to convert the file name string to the encoding that &lt;code class=&quot;highlighter-rouge&quot;&gt;SDL_RWFromFile&lt;/code&gt; expects.&lt;/p&gt;

&lt;p&gt;Here is the code:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;ctypes&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sdl2&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sdl2.ext&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Resources&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sdl2.ext.compat&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;byteify&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;except&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;ImportError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;traceback&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;traceback&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;print_exc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;RESOURCES&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Resources&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__file__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;assets&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;WavSound&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WavSound&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_buf&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;POINTER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Uint8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)()&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Uint32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_bufpos&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;spec&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SDL_AudioSpec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_load_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;spec&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;callback&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SDL_AudioCallback&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_play_next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;done&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__del__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;SDL_FreeWAV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_buf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;_load_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;rw&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SDL_RWFromFile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;byteify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;rb&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;sp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SDL_LoadWAV_RW&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rw&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;byref&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;spec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;byref&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_buf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;byref&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sp&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;RuntimeError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Could not open audio file: {}&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SDL_GetError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()))&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;_play_next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;notused&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;numbytes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_bufpos&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numbytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_buf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_bufpos&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_bufpos&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numbytes&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;# If not enough bytes in buffer, add silence
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;rest&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numbytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;# Are we done playing sound?
&lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_bufpos&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;done&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SDL_Init&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SDL_INIT_AUDIO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;RuntimeError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Cannot initialize audio system: {}&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SDL_GetError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()))&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;sound_file&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RESOURCES&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;tada.wav&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;sound&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;WavSound&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sound_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;devid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SDL_OpenAudioDevice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sound&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;spec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;devid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;RuntimeError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Unable to open audio device: {}&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SDL_GetError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()))&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;SDL_PauseAudioDevice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;devid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sound&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;done&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;SDL_Delay&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;SDL_CloseAudioDevice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;devid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;SDL_Quit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SDL_INIT_AUDIO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__name__&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'__main__'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;I realize that I could have used &lt;a href=&quot;http://www.libsdl.org/projects/SDL_mixer/docs/index.html&quot;&gt;SDL2_mixer&lt;/a&gt; for probably an easier way to do this, but I found this an interesting learning experience and worth sharing.&lt;/p&gt;

&lt;p class=&quot;notice--success&quot;&gt;&lt;strong&gt;Update:&lt;/strong&gt; I tried SDL2_mixer and &lt;a href=&quot;/python/pysdl2-playing-a-sound-from-a-wav-file-with-sdlmixer.html&quot;&gt;it was much easier&lt;/a&gt;.&lt;/p&gt;</content><author><name>Lars Magnus Nordeide</name></author><category term="Python" /><category term="PySDL2" /><category term="audio" /><summary type="html">For the last couple of weeks I have been playing around with PySDL2 to learn a bit of game programming. Figuring that prototyping in Python was a good place to start learning, I originally planned to use Pygame which is a popular wrapper and extension of SDL. Now it seems that SDL (and Pygame) has been discontinued and PySDL2 looks to be the successor. So far, using PySDL2 has been both easy and fun to create graphics and move them around, especially when using the extensions methods in sdl2.ext. But when adding sound to the mix, I hit upon a bit of trouble. For playing sounds it is necessary to use the SDL2 library functions. I decided to use a WAVE file (.wav) for my sound testing which meant using SDL_LoadWav to load the file. PySDL2 uses a ctypes wrapper around the SDL2 library so that you can use the methods in almost the exact same way as from C code. This is both good and bad. The bad, at least for me, was that I had very little experience with ctypes and spent a lot of time figuring out how to declare the variables and types to use in the function calls. PySDL2 offer very little documentation on how to do it, and the SDL2 documentation doesn’t have too much example code on using SDL_LoadWav with SDL_OpenAudio. After a lot of trying and failing I finally figured out a way that worked.</summary></entry><entry><title type="html">New year, new look with Octostrap3</title><link href="https://larsnordeide.com/blog/new-year-new-look.html" rel="alternate" type="text/html" title="New year, new look with Octostrap3" /><published>2014-01-19T22:06:53+01:00</published><updated>2014-01-19T22:06:53+01:00</updated><id>https://larsnordeide.com/blog/new-year-new-look</id><content type="html" xml:base="https://larsnordeide.com/blog/new-year-new-look.html">&lt;p class=&quot;notice--info&quot;&gt;&lt;strong&gt;Update:&lt;/strong&gt; This obviously doesn’t match the current site anymore.  I have moved it and switched themes a few times after writing this post.&lt;/p&gt;

&lt;p&gt;I was getting a bit tired of the look of this site which was using a slightly modified version of the classic Octopress theme. By chance, I came across &lt;a href=&quot;http://kaworu.github.io/octopress/&quot;&gt;Octostrap3&lt;/a&gt; which is an Octopress theme based on &lt;a href=&quot;http://getbootstrap.com/&quot;&gt;Twitter Bootstrap 3.&lt;/a&gt;. There seem to be some debate about whether Bootstrap is good or bad, but it is widely used and has some nice themes so I am going to try this out for a while.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;The great thing about Octostrap3 is that it is very easy to setup and install. You just clone the theme from Github and install it with &lt;code class=&quot;highlighter-rouge&quot;&gt;rake install&lt;/code&gt;. Be aware that the theme install may overwrite some of your custom modifications so I recommend backing up your blog before doing this. But then it is just two simple commands:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-bat&quot;&gt;&amp;gt; git clone https://github.com/kAworu/octostrap3.git .themes/octostrap3
&amp;gt; rake install[octostrap3]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code class=&quot;highlighter-rouge&quot;&gt;rake install&lt;/code&gt; command overwrote my custom &lt;strong&gt;about&lt;/strong&gt; aside and I had to restore it from my backup.&lt;/p&gt;

&lt;p&gt;The documentation of Octostrap3 contain some tips on patching the panel and category labels to improve the look and make them more compatible with Bootstrap. There is a warning that these patches can affect upgrades to Octopress. So of course I implemented these patches. But since I check in  all my changes to my clone of the Octopress repository, I made sure that these patches was checked in as a separate commit so that it is easy to revert or restore these patches later.&lt;/p&gt;

&lt;p&gt;The last step was to I decide on a Bootstrap theme to  use. The default theme is nice enough, but a bit too bright so I landed on the Flatly theme from &lt;a href=&quot;http://bootswatch.com/&quot;&gt;Bootswatch&lt;/a&gt;. Installation was easy. Just download the bootstrap.min.css from Bootswatch, rename it to &lt;em&gt;flatly.min.css&lt;/em&gt; and store it in &lt;code class=&quot;highlighter-rouge&quot;&gt;/source/assets/bootstrap/dist/css&lt;/code&gt;. Then edit &lt;code class=&quot;highlighter-rouge&quot;&gt;/source/_includes/custom/head.html&lt;/code&gt; replacing the two lines that include &lt;em&gt;bootstrap.min.css&lt;/em&gt; and &lt;em&gt;bootstrap-theme.min.css&lt;/em&gt; with one that includes &lt;em&gt;flatly.min.css&lt;/em&gt; likes this:&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;link&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;href=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/assets/bootstrap/dist/css/flatly.min.css&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;rel=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;stylesheet&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/css&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;&amp;lt;!-- &amp;lt;link href=&quot;/assets/bootstrap/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&amp;gt; --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;&amp;lt;!-- &amp;lt;link href=&quot;/assets/bootstrap/dist/css/bootstrap-theme.min.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&amp;gt; --&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Lars Magnus Nordeide</name></author><category term="octopress" /><category term="blog" /><summary type="html">Update: This obviously doesn’t match the current site anymore. I have moved it and switched themes a few times after writing this post. I was getting a bit tired of the look of this site which was using a slightly modified version of the classic Octopress theme. By chance, I came across Octostrap3 which is an Octopress theme based on Twitter Bootstrap 3.. There seem to be some debate about whether Bootstrap is good or bad, but it is widely used and has some nice themes so I am going to try this out for a while.</summary></entry><entry><title type="html">Freshening up Sublime Text - part three: Finding new packages</title><link href="https://larsnordeide.com/tools/freshening-up-sublime-text-part-three.html" rel="alternate" type="text/html" title="Freshening up Sublime Text - part three: Finding new packages" /><published>2014-01-13T21:46:00+01:00</published><updated>2014-01-13T21:46:00+01:00</updated><id>https://larsnordeide.com/tools/freshening-up-sublime-text-part-three</id><content type="html" xml:base="https://larsnordeide.com/tools/freshening-up-sublime-text-part-three.html">&lt;p&gt;&lt;em&gt;This is the third  post in a series where I am cleaning up and improving my Sublime Text environment. In the first part I &lt;a href=&quot;/tools/freshening-up-sublime-text.html&quot;&gt;found a new theme&lt;/a&gt; and in the second part I &lt;a href=&quot;/tools/freshening-up-sublime-text-part-two.html&quot;&gt;updated with some of my old favourite packages&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Sublime text is great! If you look at my blog you quickly see that I really, really like it. It seem to be all that I write about recently. As a text editor, Sublime Text is outstanding by itself, but the killer feature is the ability to extend the functionality through plugin packages. This is greatly supported by &lt;a href=&quot;https://sublime.wbond.net/&quot;&gt;Package Control&lt;/a&gt; and the wast community of package creators. But to quote Kevin Smith’s SModcast commercials: “There is so many to choose from”. Luckily there are a few good ways to find packages and keep up with what is happening.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;The first choice is obviously the Package Control web site. Version 2.0 was released last summer with a revamped version of the web site which added some great new discoverability features. In addition to the all-important search feature, it provides lists of popular, new and trending packages which makes it easier to browse and discover packages. Package Control also has a twitter feed at &lt;a href=&quot;https://twitter.com/SublimePackages&quot;&gt;@SublimePackages&lt;/a&gt; with a curated list of the latest published packages. There is also the twitter feed &lt;a href=&quot;https://twitter.com/SublimeTxtTips&quot;&gt;@SublimeTxtTips&lt;/a&gt; which provides and relays tips and tricks for Sublime Text.&lt;/p&gt;

&lt;p&gt;I have been following the above twitter feeds for the last half year and have noted quite a few packages that I want to try out and which may enhance my development and writing work flow. In this post I will write about my first impressions as a review of some of these packages.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Since I am exclusively using Sublime Text 3 now, many of these packages are for ST3 only.&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;edit-preferences&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/Edit%20Preferences&quot;&gt;Edit Preferences&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Edit Preferences is a plugin that can list keyboard shortcuts, preferences, commands and more from both Sublime Text and the installed packages. This is listed in the QuickPanel with the possibility to jump to the edit location. When I first saw this plugin I was very eager to try this out. There are a lot of preferences and keyboard shortcuts in Sublime Text and having the possibility to quickly search through them is a highly desired functionality. There are a couple of animations on the plugin page demonstrating the features that makes this look very cool.&lt;/p&gt;

&lt;p&gt;However, when I installed it the look and behaviour is somewhat different than shown in the animation. The original demo looks like this:
&lt;img src=&quot;https://github-camo.global.ssl.fastly.net/1f896b33715a6e2f019465222fe1a44a7f913fe9/687474703a2f2f6e6475646669656c642e636f6d2f7a656e636f64696e672f6f6c642f6564697470726566732e676966&quot; /&gt;
In my Sublime Text the keyboard shortcut list looks like this
&lt;img src=&quot;https://larsnordeide.com/assets/images/editprefs.png&quot; /&gt;
I don’t know why this is so different. Maybe something has changed in later versions of ST3. The package hasn’t been updated in 11 months and there have been several updates to ST3 since.&lt;/p&gt;

&lt;p&gt;This, together with the documentation being a bit sketchy, makes the  impression of the package less impressive that it first looked. Still, the possibility of quickly searching through the preferences and shortcuts are nice to have. If all you want is a good way to search for keyboard shortcuts you are better off with the Keymap plugin described below.&lt;/p&gt;

&lt;p&gt;Here is a tip if you decide to use this package: The package comes with some keyboard shortcut definitions, but they are not enabled by default. To enable them, open the file &lt;a href=&quot;https://github.com/sublimator/EditPreferences/blob/master/Default.sublime-keymap.template&quot;&gt;Default.sublime-keymap.template&lt;/a&gt; and copy the shortcuts to your User keymap.&lt;/p&gt;

&lt;h3 id=&quot;markdownediting&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/MarkdownEditing&quot;&gt;MarkdownEditing&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;I spend a lot of time writing markdown. All posts for this blog are written in markdown thanks to the excellent framework from &lt;a href=&quot;http://octopress.org/&quot;&gt;Octopress&lt;/a&gt;. It is therefore great to get some assistance from Sublime Text when writing and there are many packages that extends Sublime Text’s handling of markdown. MarkdownEditing is one of the more feature rich packages. Have a look &lt;a href=&quot;https://github.com/SublimeText-Markdown/MarkdownEditing/tree/master#features&quot;&gt;here&lt;/a&gt; for a list of the features it provides.&lt;/p&gt;

&lt;p&gt;It is said that it is important to make a good first impression, but for MarkdownEditing the power comes after using it for some time. When I first installed it I was initially put off of how intrusive it was by changing so many of the default styles when editing markdown. For example, it changes your default font, tab settings and cursor. It also moves the text to the centre of the window with a fixed with and with word wrap enabled. You are also forced to use one of the included colour schemes to get full use of the syntax highlighting. After using the package for some time now I feel that the changes the plugin makes is actually well thought out and helps focusing the writing on the text, especially combined with Sublime Texts distraction free mode.&lt;/p&gt;

&lt;p&gt;The MarkdownEditing package is very good and I especially like the following features:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;List handling which auto insert new list item bullets and manages the indent/unindent list level with &lt;code class=&quot;highlighter-rouge&quot;&gt;Tab&lt;/code&gt;/&lt;code class=&quot;highlighter-rouge&quot;&gt;Shift+Tab&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Markdown headers are Project Symbols so you can jump to them using &lt;code class=&quot;highlighter-rouge&quot;&gt;Ctrl+Shift+R&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Smart key bindings including simplification of link specification&lt;/li&gt;
  &lt;li&gt;Good documentation&lt;/li&gt;
  &lt;li&gt;Separate settings file for each markdown flavour so that you can change any of the default settings if you prefer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is always room for improvements, though. Here is a couple of things I have noticed: The interpretation of GFM fenced code blocks is too rigid so that the inline syntax highlighting of code doesn’t work well with the way Octopress’ use them. It doesn’t allow for a space between the ticks and the language specification. Also, if there are any trailing text on the same line as the language specification the highlighing doesn’t work. Another gotcha is that the package disables and replaces the native Sublime Text Markdown package. I had an old Markdown.sublime-settings in my User folder as I had previously bound the Markdown language to a custom file extension. After installing this package starting Sublime Text gave me an error message every time until I manually deleted my old Markdown.sublime-settings file.&lt;/p&gt;

&lt;h3 id=&quot;sublime-text-api-helper&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/Sublime%20Text%20API%20Helper&quot;&gt;Sublime Text API Helper&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;A plugin that shows the Sublime Text API reference in a quick panel. It is pretty simple, but very useful when creating Sublime Text plugins. Just a quick &lt;code class=&quot;highlighter-rouge&quot;&gt;Ctrl+Alt+P&lt;/code&gt; to list API classes and when a class is selected all class methods are shown with a short description.&lt;br /&gt;
&lt;img src=&quot;https://larsnordeide.com/assets/images/api-helper-commands.png&quot; width=&quot;400&quot; /&gt; &lt;img src=&quot;https://larsnordeide.com/assets/images/api-helper-methods.png&quot; width=&quot;300&quot; /&gt;&lt;br /&gt;
Since it is a quick panel it is easy to search in the methods, and when a method is selected the method template is inserted at the text cursor position.&lt;/p&gt;

&lt;h3 id=&quot;keymaps&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/Keymaps&quot;&gt;Keymaps&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The Sublime Text Keymap Helper makes it easy to discover keyboard shortcuts for functions. With its “Find keymap for…” function it lists all commands with a shortcut in a quick panel for easy searching. The selected  command can be  executed by hitting enter. This plugin solves much of the same problem as the EditPrefrences plugin and does it in a much better way. The discover keyboard shortcut function was my main reason for keeping EditPrefences around, but with the Keymap plugin available I can remove EditPreferences from my collection.&lt;/p&gt;

&lt;p&gt;The “Find keymap for…” function alone would be enough to make this plugin worth having, but it offers another feature that should make this plugin an essential part of your collection. It can create a cheat sheet of all keymap bindings that is searchable and colour coded. The cheat sheet is created in a separate Sublime Text tab and is nicely formatted and sorted for each plugin you have, and have the possibility to jump to the selected keymap file to edit it.&lt;/p&gt;

&lt;h3 id=&quot;lastmodifiedindicator&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/LastModifiedIndicator&quot;&gt;LastModifiedIndicator&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Last Modified Indicator is a little package that adds a visual indication of the last line that you changed. It has two ways of showing the modified line which can be switched by a simple setting. It does no more nor less than just showing the last modified line, but it can be quite useful when programming to find where you last made a change to the code. It is a feature that Sublime Text really should have built in. One obvious extension to this package that would make it even more useful is if it could mark &lt;strong&gt;all&lt;/strong&gt; changed lines since last save.&lt;/p&gt;

&lt;h3 id=&quot;easysettings&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/EasySettings&quot;&gt;EasySettings&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This package provides auto-completion of settings in a settings file which is very useful as Sublime Text has A LOT of settings. The plugin is also supposed to show the documentation when a setting is selected, but I could not get that to work.&lt;/p&gt;

&lt;h3 id=&quot;theme-editor&quot;&gt;&lt;a href=&quot;http://tmtheme-editor.herokuapp.com&quot;&gt;Theme editor&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This is not a plugin, but an HTML5 web app for visual editing of a Sublime Text theme. I haven’t tried it much, but it seems pretty slick and is much much easier than editing a plist file.&lt;/p&gt;

&lt;hr /&gt;
&lt;p&gt;By the end of this my package collection now consist of the following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/AAAPackageDev&quot;&gt;AAAPackageDev&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/Alignment&quot;&gt;Alignment&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/EasySettings&quot;&gt;EasySettings&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/GenerateUUID&quot;&gt;Generate​UUID&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/Indent%20XML&quot;&gt;Indent XML&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/Keymaps&quot;&gt;Keymaps&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/MarkdownEditing&quot;&gt;MarkdownEditing&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/NSIS&quot;&gt;NSIS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;OLGA&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/&quot;&gt;Package Control&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/PlainTasks&quot;&gt;PlainTasks&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/Sublime%20Text%20API%20Helper&quot;&gt;Sublime Text API Helper&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/Theme%20-%20Flatland&quot;&gt;Theme - Flatland&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/TOML&quot;&gt;TOML&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/WordCount&quot;&gt;WordCount&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next: Setting Sublime Text up as the perfect Python development environment.&lt;/p&gt;</content><author><name>Lars Magnus Nordeide</name></author><category term="Sublime Text" /><category term="packages" /><summary type="html">This is the third post in a series where I am cleaning up and improving my Sublime Text environment. In the first part I found a new theme and in the second part I updated with some of my old favourite packages. Sublime text is great! If you look at my blog you quickly see that I really, really like it. It seem to be all that I write about recently. As a text editor, Sublime Text is outstanding by itself, but the killer feature is the ability to extend the functionality through plugin packages. This is greatly supported by Package Control and the wast community of package creators. But to quote Kevin Smith’s SModcast commercials: “There is so many to choose from”. Luckily there are a few good ways to find packages and keep up with what is happening.</summary></entry><entry><title type="html">Freshening up Sublime Text - part two: Update favourite packages</title><link href="https://larsnordeide.com/tools/freshening-up-sublime-text-part-two.html" rel="alternate" type="text/html" title="Freshening up Sublime Text - part two: Update favourite packages" /><published>2014-01-09T18:22:00+01:00</published><updated>2014-01-09T18:22:00+01:00</updated><id>https://larsnordeide.com/tools/freshening-up-sublime-text-part-two</id><content type="html" xml:base="https://larsnordeide.com/tools/freshening-up-sublime-text-part-two.html">&lt;p&gt;Continuing my work to improve my development environment by tinkering with my Sublime Text 3 setup started in &lt;a href=&quot;/tools/freshening-up-sublime-text.html&quot;&gt;“Freshening up Sublime Text - part one”&lt;/a&gt;. I will now look at the packages that I used in Sublime Text 2 that I haven’t yet migrated to ST3, either because they weren’t available for ST3 or I haven’t had a use for them yet. Now it is time to install the ones I want to use or find a replacement if they are still not available for ST3.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;These are the packages I have installed in ST2, but not in ST3:&lt;/p&gt;

&lt;h3 id=&quot;alignment&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/Alignment&quot;&gt;Alignment&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Alignment is a package for simple alignment of multi-line and multiple selections. It is great for simple code formatting without having to use a full language-specific formatter. This is now available for ST3 so this is definitely being added.&lt;/p&gt;

&lt;h3 id=&quot;bullet&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/Bullet&quot;&gt;Bullet&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Bullet improves support for markdown by automatically adding list markdown (*, +, -, &amp;gt; etc). It is useful when writing a lot in markdown, like this blog. It hasn’t been upgraded to ST3 so it is no use as is. According to the Github repository it hasn’t been updated in two years and there is a one year old pull request that has not been processed, so it seems pretty dead. A quick search in Package Control reveals many packages that extends the markdown support in Sublime Text and both &lt;a href=&quot;https://sublime.wbond.net/packages/MarkdownEditing&quot;&gt;MarkdownEditing&lt;/a&gt; and &lt;a href=&quot;https://sublime.wbond.net/packages/SmartMarkdown&quot;&gt;SmartMarkdown &lt;/a&gt; provides the same functionality as Bullet, in addition to much more.  Having evaluated both, I am replacing this package with MarkdownEditing.&lt;/p&gt;

&lt;h3 id=&quot;filediffs&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/FileDiffs&quot;&gt;FileDiffs&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;FileDiffs shows diffs between the current file and clipboard, another file, or unsaved changes. These are all useful features, but the plugin is a bit clunky to use so I am going to hold off on installing it to see if I really need it.&lt;/p&gt;

&lt;h3 id=&quot;fortran&quot;&gt;Fortran&lt;/h3&gt;
&lt;p&gt;Textmate bundle for syntax highlighting Fortran. I am not using Fortran much so I do not need this package. As a side note I must say that it is very cool that Sublime Text can use Textmate bundles. If any syntax highlighting is missing as a Sublime Text package, you can almost always find it as a Textmate bundle.&lt;/p&gt;

&lt;h3 id=&quot;function-name-display&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/Function%20Name%20Display&quot;&gt;Function Name Display&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Function Name Display displays the current file, class and function name on the status bar. Somewhat useful, but not enough that I will bother with this now. Maybe later.&lt;/p&gt;

&lt;h3 id=&quot;generateuuid&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/GenerateUUID&quot;&gt;Generate​UUID&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Generate​UUID is a simple tool that can insert an UUID in the text via command or keyboard short cut. Very handy when coding so I am adding this to my packages.&lt;/p&gt;

&lt;h3 id=&quot;hexviewer&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/HexViewer&quot;&gt;HexViewer&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;HexViewer is a plugin that enables view and edit of hex code. This is not really necessary as ST3 has built in support for hex editing of binary files.&lt;/p&gt;

&lt;h3 id=&quot;indent-xml&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/Indent%20XML&quot;&gt;Indent XML&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Indent XML does exactly what it’s name suggests, i.e. it indents or reindents XML text. It can format all text or just selected text and also supports multiple selections. Oh, and it also does the same for JSON. It is very nice and goes into my collection.&lt;/p&gt;

&lt;h3 id=&quot;ini&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/INI&quot;&gt;INI&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Simple syntax highlighting of INI files. It is maybe a bit surprising that Sublime Text doesn’t come with this built in. On Windows, this file format is still used many places, but less and less. This package therefore goes into to the “wait until needed” pile.&lt;/p&gt;

&lt;h3 id=&quot;octopress-snippets&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/Octopress%20Snippets&quot;&gt;Octopress snippets&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;A package with snippets for some Octopress macros. Useful when writing posts for blogs using Octopress. Sadly it hasn’t been upgraded for ST3 so this is no go.&lt;/p&gt;

&lt;h3 id=&quot;pascal&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/Pascal&quot;&gt;Pascal&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Syntax highlighting of Pascal/Delphi code. It hasn’t been updated for ST3 and I don’t really need it either.&lt;/p&gt;

&lt;h3 id=&quot;powershell&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/PowerShell&quot;&gt;PowerShell&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Another syntax definition packages. This has syntax highlighting and snippets for PowerShell. I played around with PowerShell for a bit to learn it with the intention to use it as a better shell than cmd, but gave up in disgust and went back to good old Command Prompt. Why do Microsoft have to make everything so unnecessary complicated? And why do they have to invent something new every time? If I ever need something better than cmd I will rather use a real shell like Bash or similar, but that is a whole other blog post. It will suffice to say that I am not touching this package.&lt;/p&gt;

&lt;h3 id=&quot;sass&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/Sass&quot;&gt;Sass&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This package adds syntax highlighting and code completion for the CSS macro language &lt;em&gt;Sass&lt;/em&gt;. This was nice to have when I was setting up this blog as Octopress uses Sass stylesheets. For now, it goes in the “wait until needed” pile.&lt;/p&gt;

&lt;h3 id=&quot;wordcount&quot;&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/WordCount&quot;&gt;WordCount&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;WordCount provides real-time word count of the current file in the status bar. I found this useful when writing posts for this blog, but stopped using it when I upgraded to ST3 as it took time before it become compatible. Now that it is available, it goes into my collection.&lt;/p&gt;

&lt;p&gt;That was all ST2 packages that I used earlier. So after this my package collection now consists of the following packages:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/AAAPackageDev&quot;&gt;AAAPackageDev&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/Alignment&quot;&gt;Alignment&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/GenerateUUID&quot;&gt;Generate​UUID&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/Indent%20XML&quot;&gt;Indent XML&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/MarkdownEditing&quot;&gt;MarkdownEditing&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/NSIS&quot;&gt;NSIS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;OLGA&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/&quot;&gt;Package Control&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/PlainTasks&quot;&gt;PlainTasks&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/Theme%20-%20Flatland&quot;&gt;Theme - Flatland&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/TOML&quot;&gt;TOML&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/WordCount&quot;&gt;WordCount&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next up: &lt;a href=&quot;/tools/freshening-up-sublime-text-part-three.html&quot;&gt;Trying out some of the latest new packages&lt;/a&gt;.&lt;/p&gt;</content><author><name>Lars Magnus Nordeide</name></author><category term="Sublime Text" /><category term="packages" /><summary type="html">Continuing my work to improve my development environment by tinkering with my Sublime Text 3 setup started in “Freshening up Sublime Text - part one”. I will now look at the packages that I used in Sublime Text 2 that I haven’t yet migrated to ST3, either because they weren’t available for ST3 or I haven’t had a use for them yet. Now it is time to install the ones I want to use or find a replacement if they are still not available for ST3.</summary></entry><entry><title type="html">Freshening up Sublime Text - part one: Clean-up and new theme</title><link href="https://larsnordeide.com/tools/freshening-up-sublime-text.html" rel="alternate" type="text/html" title="Freshening up Sublime Text - part one: Clean-up and new theme" /><published>2014-01-01T02:27:00+01:00</published><updated>2014-01-01T02:27:00+01:00</updated><id>https://larsnordeide.com/tools/freshening-up-sublime-text</id><content type="html" xml:base="https://larsnordeide.com/tools/freshening-up-sublime-text.html">&lt;p&gt;Before starting a new project I always like to start with some cleaning and maintenance of my development tools. Lately, most of my development is done with my favourite editor &lt;a href=&quot;http://www.sublimetext.com/&quot;&gt;Sublime Text&lt;/a&gt;. As it has been some time since I used it I want to look at my custom settings and packages, cleaning up and removing those I don’t use much any more. There are also released a lot of new interesting packages that I want to try that may be very helpful for development.&lt;/p&gt;

&lt;p&gt;This series of posts will document my changes to the Sublime Text settings and the packages I end up using.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;h2 id=&quot;clean-up-of-installed-packages&quot;&gt;Clean up of installed packages&lt;/h2&gt;
&lt;p&gt;I don’t have many packages installed. This is because I am using Sublime Text 3 (ST3) which I haven’t updated in quite a while. Last time I updated, many of my favourite packages from Sublime Text 2 (ST2) wasn’t available for ST3. One of the tasks I want to do now is to check if more of my favourite packages from ST2 now is available for ST3, or if there are any good replacements.&lt;/p&gt;

&lt;p&gt;Looking at the list of installed packages there aren’t any packages that is obvious for deletion:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/&quot;&gt;Package Control&lt;/a&gt; is, of course, obligatory for all users of Sublime Text.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/AAAPackageDev&quot;&gt;AAAPackageDev&lt;/a&gt; - This is a nice collection of helper tools and snippets for developing packages or syntax definitions. It is not officially supported for ST3 yet. The version I am using is my own fork of &lt;em&gt;AAAPackageDev&lt;/em&gt; where I have done a quick (and dirty) port to ST3. If you are interested you can find it &lt;a href=&quot;https://github.com/lmno/AAAPackageDev&quot;&gt;here&lt;/a&gt;. I have seen a recent announcement of another package that offer some of the same functionality so this is a package I am looking to replace.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/NSIS&quot;&gt;NSIS&lt;/a&gt; - A syntax definition for NSIS (Nullsoft Scriptable Install System), which is my preferred installer system when creating an installer.&lt;/li&gt;
  &lt;li&gt;OLGA - My own syntax definition for OLGA 7. It is not completed and therefore not published yet.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/PlainTasks&quot;&gt;PlainTasks&lt;/a&gt; - This is a genius plugin for creating and maintaining todo-lists in Sublime Text and has become an important part of my development projects.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/acondiff/flatui-theme/&quot;&gt;Theme - FlatUI&lt;/a&gt; - As the name says, a flat UI theme for Sublime Text. I am only partly happy with it so this is open for replacement.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sublime.wbond.net/packages/TOML&quot;&gt;TOML&lt;/a&gt; - Another syntax definition I have made. This is for the excellent &lt;a href=&quot;https://github.com/mojombo/toml&quot;&gt;TOML file format&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So no packages to remove, but two packages (AAAPackageDev and Theme - FlatUI) to consider replacing.&lt;/p&gt;

&lt;h2 id=&quot;replacing-the-sublime-text-theme&quot;&gt;Replacing the Sublime Text theme&lt;/h2&gt;
&lt;p&gt;The default Sublime Text theme is not too bad, but in my opinion there is one big flaw which is my main reason for using a different theme: The visual difference between the active tab and the other tabs are too subtle. 
&lt;img src=&quot;https://larsnordeide.com/assets/images/default-tabs.png&quot; /&gt;
On some screens and lighting conditions I spend too much time looking for which file is the active one. With Sublime Texts functionality to restore all previously open tabs when you start it, the time to recognize which is the active one should be immediate.&lt;/p&gt;

&lt;p&gt;There are many nice themes for Sublime Text, but regrettably this is a common problem in many of the available themes. I have been using the FlatUI theme for some time and although the contrast between active tab and the others is better, the colour choices of the theme cannot exactly be called subtle. After evaluating all themes available through Package Control I have ended up using the &lt;a href=&quot;https://sublime.wbond.net/packages/Theme%20-%20Flatland&quot;&gt;Flatland&lt;/a&gt; theme. It has several ways to distinguish the active tab:
&lt;img src=&quot;https://larsnordeide.com/assets/images/flatland-tabs.png&quot; /&gt;&lt;br /&gt;
Both the active tab background and the tab text is brighter than the other tabs which both contribute to set the active tab apart from the others. Additionally, the active tab background colour is extended below all tabs. This really helps to quickly find the active tab. Wherever you start to look in the window, you can just follow the line to the active tab.&lt;/p&gt;

&lt;p&gt;Next post: &lt;a href=&quot;/tools/freshening-up-sublime-text-part-two.html&quot;&gt;Looking for updates or replacements of favourite Sublime Text 2 packages&lt;/a&gt;.&lt;/p&gt;</content><author><name>Lars Magnus Nordeide</name></author><category term="Sublime Text" /><category term="ux" /><category term="design" /><summary type="html">Before starting a new project I always like to start with some cleaning and maintenance of my development tools. Lately, most of my development is done with my favourite editor Sublime Text. As it has been some time since I used it I want to look at my custom settings and packages, cleaning up and removing those I don’t use much any more. There are also released a lot of new interesting packages that I want to try that may be very helpful for development. This series of posts will document my changes to the Sublime Text settings and the packages I end up using.</summary></entry><entry><title type="html">Sublime Text 2 tip: Get Sublime Text 3</title><link href="https://larsnordeide.com/tools/sublime-text-2-tip-get-sublime-text-3.html" rel="alternate" type="text/html" title="Sublime Text 2 tip: Get Sublime Text 3" /><published>2013-04-01T18:56:00+02:00</published><updated>2013-04-01T18:56:00+02:00</updated><id>https://larsnordeide.com/tools/sublime-text-2-tip-get-sublime-text-3</id><content type="html" xml:base="https://larsnordeide.com/tools/sublime-text-2-tip-get-sublime-text-3.html">&lt;p&gt;Yes, you read that right. The best way to improve Sublime Text 2 is to get version 3. It’s pretty obvious of course, but at the moment Sublime Text 3 is only available as a public beta and you may not know about it.&lt;/p&gt;

&lt;p&gt;The new version has many great improvements. The one I am probably most happy about is how blazingly fast it now starts. The developers have done some amazing work to bring the startup time down to almost nothing. In addition, adding packages no longer degrade the startup time further.&lt;/p&gt;

&lt;p&gt;My second favourite improvement is the symbol indexing. Sublime Text 3 automatically scans and indexes all files in a project and you can now &lt;em&gt;Goto Definition&lt;/em&gt; and &lt;em&gt;Goto Symbol in Project&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Sublime Text 3 is available for download from the &lt;a href=&quot;http://www.sublimetext.com/3&quot;&gt;Sublime Text 3 page&lt;/a&gt;. The beta version is only available to registered users. If you are a registered user you just use you current license when installing Sublime Text 3 beta. If you are not a registered user, then shame on you. Even though it is fully usable without registering, it only costs $70 and is worth every penny.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: I have nothing to do with the development or sale of Sublime Text. I am just a very happy user.&lt;/em&gt;&lt;/p&gt;</content><author><name>Lars Magnus Nordeide</name></author><category term="Sublime Text" /><summary type="html">Yes, you read that right. The best way to improve Sublime Text 2 is to get version 3. It’s pretty obvious of course, but at the moment Sublime Text 3 is only available as a public beta and you may not know about it. The new version has many great improvements. The one I am probably most happy about is how blazingly fast it now starts. The developers have done some amazing work to bring the startup time down to almost nothing. In addition, adding packages no longer degrade the startup time further. My second favourite improvement is the symbol indexing. Sublime Text 3 automatically scans and indexes all files in a project and you can now Goto Definition and Goto Symbol in Project. Sublime Text 3 is available for download from the Sublime Text 3 page. The beta version is only available to registered users. If you are a registered user you just use you current license when installing Sublime Text 3 beta. If you are not a registered user, then shame on you. Even though it is fully usable without registering, it only costs $70 and is worth every penny. Note: I have nothing to do with the development or sale of Sublime Text. I am just a very happy user.</summary></entry></feed>