Skip to content

Send Mac to sleep with external screen and closing the lid (Yosemite)

October 17, 2012

I had the problem of my Mac not going into sleep when external screen is connected and closing the lid. Luckly I came across this advice which indeed, did the trick:

  1. Disable external Monitor
  2. Type sudo nvram boot-args="iog=0x0"
  3. and restart

Voilà!

Update : With Yosemite you need to type:

sudo nvram boot-args="niog=1"

Source: https://discussions.apple.com/thread/6601019

MySQL Hack: Hide unwanted variable declaration

October 17, 2012

Little MySQL to hide a unwanted variable declaration:

problem

SELECT
@l:="tempvalue" AS unwanted_output,
"actual output" AS ouput,
@l AS position;

Solution - ‘hide’ the var assignment within a Wrap variable inside a IFdefenition:

SELECT
IF(@l:="tempvalue", "actual output", "dummy") AS ouput,
@l AS position;

Ruby Curly braces

July 24, 2012

In ruby curly braces have different meanings:

1. A hash:

my_hash = {:a => 1, :b => 2}

or the same but more JSON like syntax ( ruby >= 1.9 only)

my_hash = {a:1, b:2}

same as:

my_hash = Hash.new
my_hash[:a] = 1
my_hash[:b] = 2

2. A block:

in rough and short: a block is a piece of code which will/can be executed either ‘later in time’ or ‘in a different context’

3.times do
 puts "HI"
end

or

3.times {
 puts "HI"
}

especially in one line it reads nice:

3.times { puts "HI" }

usually blocks have parameters which allows them easily to be identified:

  3.times { |index| puts "Loop: #{index}" }

oh and here’s a third case:

3. curly braces us variable within a string_

name = "Heinz"
puts "#{name} Ketchup is toll"

same as

name = "Heinz"
puts name + " Ketchup is toll"

I hope this helps to understand. I have to admit, curley braces have lots of different meanings in ruby and are indeed confusing - quite often they are ‘shortcuts’ to make your code read nice.

Hack your whiteboard - and clean it quick!

July 13, 2012

For the record: Here’s my favorite realworld hack I got once told by my lovley coworker Roel:

How to clean a messy whiteboard.

Remember the situation when one used the wrong pen for the whiteboard and can’t clean it? Just take another pen which can be erased and go over the non erasable parts - suddenly everything gets clean away:

Or in the words of TvLesson:
Take another dry erase marker (preferably darker than the marks that you are trying to remove) and draw on top of the messy marks. Then wipe the marks away with a dry erase eraser or soft cloth.

The new layer of dry erase marker will lift and loosen the underlying marks. It’s simple but may not work for tougher messy marks.

http://www.tvlesson.com/article/13405_how-to-erase-a-messy-whiteboard.html

CSS div State

June 22, 2012

Example code for multiple FE state toggled via CSS classes only

<html>
<body>

<div id="state" class="pending">
  <div id="pending">Pending</div>
  <div id="success">Successful</div>
  <div id="fail">Failed</div>
</div>

<style>
#state div {
  display: none;
}

#state.pending #pending  {
  display: block;
}

#state.success #success {
  display: block;
}

#state.fail #fail {
  display: block;
}

#state.debug div {
  display: block;
}


</style>

</body>
</html>

Rspec - Useful How To and Best Practices

June 21, 2012

Here are two *very* good update-to-date sources of Rspec howtos and best practices:

The first on by Andrea Reginato(@lelylan) gives a very good overview. Start here:
https://docs.google.com/a/soundcloud.com/document/d/1gi00-wwPaLk5VvoAJhBVNh9Htw4Rwmj-Ut88T4M2MwI/mobilebasic?pli=1&hl=en

The second one by Jeff Pollard features ninja-kick-ass shared spec examples:
http://bitfluxx.com/2011/05/23/some-rspec-tips-and-best-practices.html

Andrea did already a good job with the Google Doc, but what about collection all tipps into git repo so everyone can easily collaborate - let’s fork, PR and drive it forward!

More sources to follow - spec it, run it, kick it!

[kind of unrelated but nice picture ‘borrowed’ from global nerdy]

Lego Sumo Robot - Team SoundCloud

March 14, 2012

Uh, long, long time ago, (aka. last year autumn) I’ve been to GoTo Conference 2011 in Århus to present SoundCloud. For the evening program, a Lego Mindstorm Sumo fight was organized which, for sure, we couldn’t miss. Watch our sweet robot in action -
the first round of the sumo battle, where Team SoundCloud flips over the opponent!

http://vimeo.com/30364841

Unfortunately that was already it’s glorious time - we dropped out for the second round. Anyway - it was big-huge-massive fun. Make sure you grab some lego bricks and build your own.

In case you’re interested in the code, it wasn’t much and nothing to be proud of - but worked!
https://gist.github.com/1280779

DelJect - delete & eject USB card easily

March 09, 2012

Here’s another little AppleScript I recently wrote:

DelJect - an AppleScript to delete and eject any external Cards/USB Stick

A friend asked for this little script: His problem was, that his photography camera couldn’t deal with apple’s hidden files like.DS_STORE etc. To workaorund that, he had to delete those files each time before ejecting. DelJect automates this manual process. Voila!

Download the latest version here: DelJect.app

Usage
Just run the binary, select the device (USB stick), confirm delete and unplug the stick. Done!

As a litte gotcha, DelJect will remeber the device - so next time, just confirm & go.

Thanks to Niels for the idea and thanks Icon-Land for Icon.

https://github.com/rngtng/DelJect

Hacking the Nabaztag - Arduino injects via I2C data into RFID Reader

January 10, 2012

Wow! After more than two years I finally got my hands dirty hacking the Nabaztag rabbit. The release of the source code last summer were very encouraging here! Expect some awesome results in the next time :-)

Let’s start with NabaztagInjector , an Arduino Library to inject data:

What bothered me for long was the missing possibility to connect external devices to the rabbit. How awesome would it be to use the rabbit for sending data into the net? Imagine it as WIFI shield you Arduino.

Guess what - that’s possible: replacing the RFID reader with an Arduino (both use the I2C bus) running a simulation of the RFID reader chip, enabled me to inject any custom data to the rabbit. Hacked!

As result, I created this tiny Arduino library to encapsulates the full process behind and easy API:

[gist id=1582447]

Check out the full Readme, Source code and Examples here:
http://www.rngtng.com/nabaztag-injector-arduino-rfid-hack/

Big Sitemaps are Big - Google Sitemaps at SoundCloud

January 09, 2012

Big Sitemaps are Big - Google Sitemaps at SoundCloud Hack and Tell @Cbase Sept’11

Me speaking about Sitemaps at SoundCloud and presenting the big_sitemaps gem to handle to load easily.

https://vimeo.com/34774323

Sugru rocks! Or: how I fixed my broken iPhone Display glass from falling off.

November 08, 2011

Unfortunately I kept on dropping my iPhone until its display glass broke. Typical me. But after that, even worse, the little bits of broken glass where loose, slowly felt off one after another destroying the displays protection completely. Whereas the drop (besides the broken glass) didn’t effect the phones functionaries at all (even its touch capabilities are 100% working), the vanishing glass revealed the display which could get destroyed by dust and moist easily. Luckily I found a solution: Sugru.

Sugru is this fantastic super modeling clay made by Jane from Ireland. It allows you to hack the world and fix stuff. First its soft, sticks on nearly and material allowing you to put it in any shape, later it hardens and keeps its form. Perfect for me!

Check my hack, where I used Sugru replacing the missing glass pieces and preventing the loose ones from falling of. My display is protected again, and the phone is working - yay!

Visit the Sugru Website and get some for yourself: http://sugru.com

Long time ago: 'Die besten JavaScripts - SizeIt!'

August 12, 2011

Wuhooo, look what I found in my archives:

In my early webdeveloper days I created a small javascript which named ‘SizeIt!’. It purpose was to resize all website elements according to the size of users viewpoint. So regardless which screen resolution the user has, the website propotions would always be the same. Honestly, it worked only in very special cases and was slooooow (these days) :)

But the idea was great and it even gave me second place in a competition - ‘Die besten JavaScripts’ of Internet-World in August 2000. Read the result here (german only, sorry).

Not sure where I do have source code, will continue searching archive and post it here someday - stay tuned …

Meet me at Chaos Communication Camp 2011

August 02, 2011

Yay, I’ll be at CCC Camp 2011 - and for sure I’ll bring my arduino/rainbowduino stuff with me. So come over, say hello and join in the crazy hackingingz!

[videofile]ftp://ftp.ccc.de/events/camp2011/trailer/camp2011_trailer.m4v[/videofile]

http://events.ccc.de/camp/2011/

HowTo: resque-web, resque scheduler and passenger

July 29, 2011

Here’s how you get resque-web and resque scheduler playing well with passenger:

Follow these instructions from resque readme (apache, ngnix) and check out current resque repo. Now update following two files:

  1. Add gem "resque-scheduler","2.0.0.d" to Gemfile
  2. Run bundle
  3. Add require 'resque_scheduler' to config.ru

Restart you webserver and are ready to go - Happy scheduling!

Both file after editing:
[gist id=1101580]

Rails 3.1 Hackfest - get rid of Javascript Runtime dependency in production

July 25, 2011

This weekend was Rails 3.1 Hackfest. The rails community was called to test the upcoming version 3.1 to its limits, to find bugs and or flaws and get it polished for the final release. So I did:

I’m working with the rails 3.1 since it first release candidate, but never tried in production. So I made my task to finally test this, and bring my app in the wild - on my (not root) server. Rails 3.0 is running there smoothly so I didn’t expect any problems - wrong!
Show stopper was the Javascript Runtime dependency on production. Reason was quickly found: Coffee-Script - ahrg! It depends on ExecJS, which depends on a Javascript Runtime. Unfortunately, and that’s because I’m not on a root server, I got neither node.js, therubyraser, Mustang nor Johnson installed there.

I read this article, which supposed to precompile the assets - didn’t help either and runtime is needed again.

In the End, the solution was as simple as obvious: just don’t use coffee-script in production :-) I did, removed the coffee-script gem form my Gemfile - and tatatata: it works! Uhh! This took me quite a long time to get it right. Javascript Runtime dependecy no good for prodcution, and reading Mr. Katz it’s looking good to get this fixed for the final release - uff! Happy so get tin final one soon! Yeah!

[cheesey image taken from PragDave - thx]