Archive

Author Archive

change shell on a mac

February 6th, 2014 1 comment

Hi,

trying to change my login shell to zsh using the zsh built with homebrew i faced a small issue as OS X claimed:
chsh: /usr/local/bin/zsh: non-standard shell

The solution was to add the shell to the “approved” list:
echo "/usr/local/bin/zsh" >/etc/shells

The a simple chsh -s /usr/local/bin/zsh will do the trick.

Categories: Uncategorized Tags:

OSX from a stick

February 5th, 2014 No comments

My macbook completely crashed today trying to recover from some severe file system corruptions. The symptoms were system freezes that took between 5-45 seconds each. Using Xcode was impossible so I did some tests and dsikutil tried to fix it – a non bootable OS was the result.

No problem, I have backups (timemachine + tivoli) and fast wifi at work so I rebooted into recovery mode using the option key but disk util failed to format my 2 partition disk (bootcamp) into 1 new file system because it claimed a disk still being mounted (which turned out to be the recovery image itself – rather stupid setup…).

So I needed a Mavericks boot stick. Downloaded OSX installer from the app store, waited patiently and then ran the following command:

sudo /Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/16GB --applicationpath /Applications/Install\ OS\ X\ Mavericks.app --nointeraction

with /Volumes/16GB being the mountpoint of the USB-Stick I used (that one will be formatted – You have been warned).

Again wait patiently for the process to finish (expect ~30mins depending on your thumbdrive-speed) and you should have a bootable Mavericks installer:

Erasing Disk: 0%... 10%... 20%... 30%...100%...
Copying installer files to disk...
Copy complete.
Making disk bootable...
Copying boot files...
Copy complete.
Done.

Categories: software Tags:

Pipe view

February 4th, 2014 2 comments

a rather handy little helper is simply called “pv” – pipe view. I mainly use it when copying vms or lots of small files:
tar cf - ./src | pv --timer --rate --average-rate --bytes | ssh machine tar xpf - -C /dst
which then prints something like this:
4.54GiB 0:06:55 [11.2MiB/s] [11.2MiB/s]

pv can also be used to set a rate limit to the transfer using “-L 1m” to restrict the bandwidth to 1 MB/s. For the Mac users out there – homebrew has knows “pv”.

Categories: Uncategorized Tags:

reverse bits in a byte

July 25th, 2013 No comments

Working on a code for an arduino project I had the problem that the letters i had created for my 8×8 LED matrix were all mirrored. A letter looks like this:

byte letter_A[8] = { 0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00};

Now the rows are in the correct order (letter not upside down), but the leds of one row are wrong meaning the LSB should be the MSB. I found 3 solutions on the net which are all 3 cool in their own way:

The first version is a 1 to 1 translation of how i would do it on paper. Take the most left and swap it with the most right. Then take the second and swap it with the second last and so on …

// "00110011" becomes "11001100"
byte byteShift(byte num) {
  byte var = 0;     
  int i, x, y, p;
  int s = 8;    // number of bits in 'num'.
 
  for (i = 0; i < (s / 2); i++) {
    // extract bit on the left, from MSB
    p = s - i - 1;
    x = num & (1 << p);
    x = x >> p;  
    // extract bit on the right, from LSB
    y = num & (1 < < i);
    y = y >> i;
 
    var = var | (x < < i);       // apply x
    var = var | (y << p);       // apply y
  }
  return var;
}

The next version uses bit masks for reversing the order of bits

// Reverse the order of bits in a byte. 
// I.e. MSB is swapped with LSB, etc. 
byte Bit_Reverse( byte x ) 
{ 
    //          01010101  |         10101010
    x = ((x >> 1) & 0x55) | ((x < < 1) & 0xaa);
    //          00110011  |         11001100 
    x = ((x >> 2) & 0x33) | ((x < < 2) & 0xcc);
    //          00001111  |         11110000 
    x = ((x >> 4) & 0x0f) | ((x < < 4) & 0xf0); 
    return x;    
}

The last one is not pretty but pretty fast 😉

// 36 bytes small, inelegant assembler, but faster 
byte bitswap (byte x)
{
  byte result;
 
    asm("mov __tmp_reg__, %[in] \n\t"
      "lsl __tmp_reg__  \n\t"   /* shift out high bit to carry */
      "ror %[out] \n\t"  /* rotate carry __tmp_reg__to low bit (eventually) */
      "lsl __tmp_reg__  \n\t"   /* 2 */
      "ror %[out] \n\t"
      "lsl __tmp_reg__  \n\t"   /* 3 */
      "ror %[out] \n\t"
      "lsl __tmp_reg__  \n\t"   /* 4 */
      "ror %[out] \n\t"
 
      "lsl __tmp_reg__  \n\t"   /* 5 */
      "ror %[out] \n\t"
      "lsl __tmp_reg__  \n\t"   /* 6 */
      "ror %[out] \n\t"
      "lsl __tmp_reg__  \n\t"   /* 7 */
      "ror %[out] \n\t"
      "lsl __tmp_reg__  \n\t"   /* 8 */
      "ror %[out] \n\t"
      : [out] "=r" (result) : [in] "r" (x));
      return(result);
}

Categories: arduino Tags:

hope and other stuff

July 7th, 2013 No comments

There is an enlightening article on why maybe – only maybe – not all hope is lost in the long run. While the western world is shaken by the latest leaks and what followed in its wake, there is this story about true DIY hackerism in one of the most improbable places in the world. Here comes a positively strange (but seemingly true) story about Afghanistan:

http://www.psmag.com/culture/the-merry-pranksters-who-hacked-the-afghan-war-60873/

If you’d like to know how Dr Dave Warner looks like: https://www.youtube.com/watch?v=nGdk9JwZWzY

Categories: Uncategorized Tags:

Who has your back??

July 6th, 2013 No comments

The the Electronic Frontier Foundation knows – here:

https://www.eff.org/who-has-your-back-2013

Nice overview of which company/website is really trying to protect your data. I suddenly feel the urge to twitter more and blog less as WordPress doesn’t look to good but Twitter does.

Categories: political, software Tags:

google this

June 7th, 2013 1 comment

try googling this:

he is “100000000..900000000” years old

gnihihihi

Categories: Uncategorized Tags:

Case Sensitivity on MacOSX

May 28th, 2013 No comments

The files system HFS+ on a MAC is kind of crooked when it comes to case sensitivity (Wikipedia: HFS+). In case you come across a piece of software that relies on case sensitivity beeing there you can use a (sparse) volume formatted with case sensitivity to get the job done. Lets use a generic name 😉

NAME=scorep

First, create the volume, mount it and save the UUID so you recognize the volume later:

hdiutil create -volname ${NAME} -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 40g ~/${NAME}.dmg
hdiutil attach ~/${NAME}.dmg.sparseimage -mountpoint /Volumes/${NAME}
diskutil info /Volumes/${NAME} | grep UUID | awk '{ print $3 }' > ~/.${NAME}voluuid

To automatically mount the volume in case it is not mounted whenever you open a shell, add the following to your ~/.bash_profile:

TMPUUID=`cat ~/.${NAME}voluuid`
MNTPNT=`diskutil info ${TMPUUID} | grep "Mount Point" | awk '{ print $3 }'`
if [ "$MNTPNT" = "" ]; then hdiutil attach ~/${NAME}.dmg.sparseimage -mountpoint /Volumes/${NAME}; fi

Cheers,
Willi

Categories: bashism, software Tags:

The good ol’times – Part 2

April 19th, 2013 1 comment

This is serious:

http://www2.warnerbros.com/spacejam/movie/jam.htm
http://viewaskew.com/mallrats/
http://youvegotmail.warnerbros.com/

and there are a few sites dedicated to preserve this stuff (besides “the archive”):
http://www.internetarchaeology.org/

and then there is a site that simply does not need an overhaul – just because its “The Best Page in the Universe”:
http://maddox.xmission.com/

aaaand then there’s real science 😉
http://venus.web.cern.ch/venus/

Categories: fun Tags:

The good ol’times

April 10th, 2013 No comments

Back in 1998, snake was one of only 3 games available on my Nokia 6110 (the other two games are memory and logic). The cool thing was, you had a two player mode using infrared!!!

Snake

Snake

Categories: games, nerdcore Tags: