Looking Up Crash Reports In OS X

If you find yourself–like me–in the situation that your Mac has crashed and you want to retrieve the crash reports (some call them logs 😉 )? Well, there are basically two ways.

You can look them up with the “Console” tool (find it in 

/Applications/Utilities/Console

  or with Spotlight). Open the “System Diagnostic Reports” section on the left and find an entry similar to 

Kernel_<date>_<your_pc_name>.panic

  at the top.

You can also find these reports as text files under 

/Library/Logs/DiagnosticReports

with the same names. OS X will open them with the Console tool per default.

Cheers. 😀

Unsafe Chrome Sometimes Necessary

In my work – every now and then – I found myself in need of a browser with reduced security checks (mainly to gloss over cross domain XMLHttpRequests and SSL certificate violations) for testing purposes. I didn’t want to take the risk and use my main browser session with these settings, so I made me a script (also available as a Gist). 🙂

Tip:
If you use oh my ZSH you can save this file in

~/.oh-my-zsh/custom/plugins/chrome-unsafe/chrome-unsafe.plugin.zsh

and add “chrome-unsafe” to your list of used plugins in

~/.zshrc

 

Fixing Bioshock’s Language Settings

I got myself Bioshock 1 and 2 during Steam’s Summer Sale and just came around to play it.
After installation I found out that the game was in German (while my Windows and Steam are in English)!?!? … I hate dubbed films and games!

Sadly Bioshiock doesn’t allow you to change the language in the settings menu so I had to look around. After piecing together information from several 5+ year old, outdated forum posts I found the solution.

  1. Close the game
  2. Open C:\Users\<Username>\AppData\Roaming\Bioshock\bioshock.ini
  3. Find the
    [Engine.Engine]

      section

  4. Set
    Language=int

      (“int” is for international i.e. English)

  5. Save the file and restart the game

Everything should be in English now. 😀

Maintaining Maintenance

Sometimes well-intentioned features have unintended side effects. Case in point: WordPress’ maintenance mode. Whenever you update plugins WP will automatically enter maintenance mode, which displays a nice message to your visitors that the site will be back online shortly. It will automatically go out of maintenance once the updates are done.

Well, sometimes unexpected things happen: you are stuck in maintenance mode. WP will effectively lock you out … even the admin section will not be accessible. *ugh* This is the moment you start panicking … luckily if you wait 10 minutes or delete the .maintenance file manually you’ll be able to access your site again. *phew*

Just went though that whole cycle. m(

Convert any file VLC can play to mp3

I just felt the need for a script that could extract the audio track of a video, transcode it and save it as an mp3 file … 2 hours later I was finished (get the Gist). 😀 It uses VLC to do hard work. 😉

Thanks to Kris Hom for the inspiration. 🙂

Update 2014-03-01:

  • Check whether VLC is installed
  • Should also work on Linux now
  • Increase default bit rate to 192kbit/s
  • Fixed bug where the file/playlist would repeat endlessly

Update 2014-11-05:

  • Also look for VLC in “~/Application/”

Update 2016-03-05

Default Values for Boolean Options in Ruby

Let’s say you read settings from a YAML file and have some sort of settings object. Then you check if certain options are set with custom values or you have to set default/fall-back values on them. If you are dealing with Boolean options you have to be careful … as I had to find out myself.

Initially you would probably do something like the following to set a default value on a Boolean option:

settings[:some_option] ||= true # set default value if nothing set

Do you see the problem? What happens if the option was deliberately set to

false

? You would overwrite it because both cases

nil

(i.e. nothing set) and

false

would evaluate to

false

in the context of the

||=

operator and you would in both cases assign the right hand value (and overriding an explicit user choice in one case) … *ouch*.

So the correct solution is something like the following:

settings[:some_option] = true if settings[:some_option].nil?

Just be careful … 😀

Render Rails assets to string

If you ever needed a way to render a Rails assets to a string, Hongli Lai from Phusion describes how. 🙂

I prepared a Gist wrapping it into a nice helper. 😀

module ApplicationHelper
  # thanks to http://blog.phusion.nl/2011/08/14/rendering-rails-3-1-assets-to-string/
  # you may need to change the owner of the tmp/cache/* directories to the web servers user
  # e.g. for Debian systems: `chown -R www-data:www-data tmp/cache/*`
  def render_asset(asset)
    Conferator::Application.assets.find_asset(asset).body.html_safe
  end
end