Just for Fun Video: Cutting Card Stock Boxes on my Electronic Cutting Machine

Well, today is the first Sunday of Advent… time to play around with my cutting machine. ūüėČ

I got¬†inspired by a post on Hackaday.com (on Laser-cut Gift Boxes).¬†The post presents a really nice source¬†for DXF files for¬†various shapes for card stock boxes. Out of curiosity I simply ‘threw’ some of their design files at my electronic cutting machine. They might¬†save me some time (gift wrap, you know). The result is a short video of the process, nothing special:

Continue reading

Reviving (jump-starting) a dead R.O.GNT Speaker Lithion-Ion Battery

I recently had to revive a (as it at first seemed) dead Li-Ion battery. It was the battery of a newly bought R.O.GNT external speaker which refused to work or even charge.¬†The device was DOA (dead on arrival) but it was so cheap that sending it back would have cost more than I’ve paid for it.

The speaker has an internal Lithium-Ion battery to allow mobile usage. My guess was that this battery slowly discharged while waiting for a buyer and at some point the undervoltage protection kicked in. Normally this protection should prevent a defective cell from being charged. In my case I hoped the cell would still be okay and survive a jump-start. It was successfully done before in other cases. Continue reading

Unbricking a HP LaserJet M1212nf stuck in an “initialization loop”

I recently helped¬†to repair a bricked HP LaserJet M1212nf printer that was stuck in an “initialization loop”. It booted up normally, but after 10-20 seconds the printer stopped to accept any kind of commands¬†and the text “initializing” was¬†shown on the LC-Display. It then restarted and the whole boot/init¬†started¬†over again and again.

My first approach was to make a hard reset, i.e. set the printer to factory defaults. This can be achieved by:

  1. Turning off the printer
  2. Pressing and holding the “Start Copy” and the “Cancel” button. (Easy, both are below¬†each other.)
  3. Turning on the printer

After setting the initial configs¬†(language, country) the initialization loop reappeared — ¬†the problem was not fixed by the hard reset.

Next, I tried to reinstall the latest firmware which failed due to the loop —¬†there simply was not enough time to upload the firmware I would guess.

I then tried to find out if there is¬†some kind of low level bootloader that would accept a firmware image (many devices nowadays have such a semi-failsafe mode) when the printer is¬†turned on — but did not find any info on that either.

My final approach was just to try out if there would be a firmware upload possibility right after a hard reset (steps as described above). I had recognized that the initial settings/configs right after a hard reset were not affected by the reboot loop. To my surprise this actually worked. I was able to upload the firmware when the first init-setting appeared. After updating the firmware the loop was gone and the printer worked again as before.

I hope this description helps others who are also affected by this problem as I have not yet seen any other solution in the HP forum. I can only guess how the “initializing loop” occurred: maybe an automatic firmware update failed and bricked the printer. Anyways, the 200+ MB printer driver software by HP is a PITA and their web site is a maze…

Edit Git commit messages including root commit

From time to time I need to clean-up a Git repository before making it accessible to others. One step is to fix unspecific commit messages and add version tags.

Caution: The following modification should not be done if the repository is already shared with others.

Most of the job can be done with the interactive rebase command, but if you want to also clean-up the root commit message you have to invest a bit more work. This is a modified/adapted solution from a thread found on stack overflow.

First fetch the SHA1 checksum of the first/root commit:

git rev-list --max-parents=0 HEAD

Checkout that commit, ignore the warning message:

git checkout <root-sha1>

Now you can use the amend feature of the git commit command to fix the (from this point of view most recent) root commit:

git commit --amend

Now you can add the remaining commits to the modified root commit. By making it interactive you can either meld multiple commits (squash) or just edit their commit messages (reword):

git rebase -i --onto HEAD HEAD master

Watched the Solar Eclipse with a Quick and Dirty Pinhole Camera

Of course neither me nor any of my colleagues had an appropriate protection to view the upcoming solar eclipse. So I had to ‘hack’ together a device to still be able to watch the eclipse pass¬†in a safe manner.

Solar Eclipse (Munich, Germany, 2015.03.20 10:40 CET) viewed though a simple (5 minute hack) pinhole camera:
Simple Pinhole CameraThe camera was built from an old rolled conference poster, some adhesive tape, plastic foil, and a cardboard box. I think it is self-explanatory:
One side was covered with opaque foil, only a tiny pin hole (< 1 mm) let light through. The other side was simple plastic foil (from my lunch). The box acted as a shield to protect from accidentally looking into the sun.
Simple Pinhole Camera showing the Solar Eclipse

It’s a mirror image, by the way.

Additionally (out of curiosity) I’ve taken a photo with my¬†iPhone 4S:
Solar Eclipse Photo  / iPhone CameraThe eclipse can be seen in the lense flare (here a 100% cut-out):
Solar Eclipse Photo  / iPhone Camera (Lense Flare)

Suitable paper rolls for the Sharp CE-150 printer

It’s not that easy as it may sound to find paper rolls for a 30 years old printer, the Sharp CE-150. The printer is used in combination with a Sharp PC-1500/1500A pocket computer.

I’ve looked at my small amount of paper rolls, the leftovers¬†I’ve found in a box on the attic. Interestingly they were differing in size (can’t remember¬†why):

Sharp CE-150 Paper Rolls

(Left to Right) Core Diameter Tube Diameter Outer Diameter Width
Roll 1 7.7 mm 14.7 mm 28.5 mm 57.4 mm
Roll 2 8.3 mm 13.0 mm 29.3 mm 57.6 mm
Roll 3 11.1 mm 17.0 mm 33.0 mm 58.7 mm
Roll 4 9.7 mm - 19.7 mm 58.3

Their width¬†and outer diameters did not differ significantly, but the core diameters did. Paper rolls with core diameters of 7-9 mm are hard to get, the rolls sold today mostly have a diameter of 12 mm. I’ve successfully tested thermal (yes: thermal) paper rolls with this diameter in the CE-150, and these are really cheap to get (e.g. on eBay Germany). The ink doesn’t run, but there might be¬†paper rolls¬†with different coatings. I did not check that.

Maybe as a warning: Thermal papers mostly contain Bisphenol A (BPA), a substance that exhibits hormone-like properties!

The approximate dimensions you should look for are:
Width: 57 mm; Inner / outer diameter: 12 / 30 mm; Length: 10 m

Sharp CE-150 Still available paper roll (dimension)

How to extract a subdirectory from a Git repository while keeping its history

This is more or less to document a procedure I needed a few days ago: the extraction of a sub-directory from a Git repository into a separate (new) repository. The nice thing here is, that the whole history of the respective directory is kept.

First I created a check-out of the existing repository and removed the link to its origin.

git clone SOURCE.git
git remote rm origin

The next step is the actual extraction. We will remove all directories but the desired one throughout the whole history. This also works with more than one directory, i.e. here: DIR1 and DIR2

git filter-branch --tree-filter 'ls -1 |grep -v -e DIR1 -e DIR2 | xargs -i rm -rf {}' --prune-empty -f HEAD

Now the repository should only contain the (here) two directories. But the removed files still are in the packed object references. We have to manually let them expire and remove them.

git reflog expire --expire=now --all
git gc --aggr --prune=now

Finally I did some cleaning, but this is optionally:

git repack -a -d -l
git clean -f -d

Finally we can for example create a new (bare) repository from our NEW-REPO and further use it. I recommend to just remove the extracted directory from the source repository and keep its history, just in case.

The steps are similar if you need to instead remove a directory including its history. The only difference is in the actual removal command:

git filter-branch --tree-filter 'ls -1 |grep -e DIRECTORY |xargs -i rm -rf {}' --prune-empty -f HEAD

Homemade minimal Raspberry Pi (Raspbian) image

I have to admit that I’m a big fan of single-board computers for specific tasks like home-automatation, backup systems, network gateways, or file-sharing. I also like the approach of the Raspberry Pi Foundation to provide an image file with Raspbian (an adapted Debian) for easy use. For most people out there it is the best way to fetch an SD-Card with a¬†capacity of at¬†least 4 GBytes, download and copy the Raspbian image onto the card. I have a few unused 1 and 2 GByte SD-Cards lying around which should be sufficient for my tasks but are too small for the ‘generic’ Raspbian image. So I had to create my own minimalistic Raspbian installation. Here is a step-by-step example of the creation process.

I started with the installation of a few later required packages. I’m pretty¬†sure this¬†list is incomplete as I’ve already had quite a lot dev-tool packages installed before…

sudo aptitude install qemu-user-static \
binfmt-support fakeroot debootstrap git

To get Qemu running to support armhf I had to add a parameter to itc configuration file:

echo "EXTRA_OPTS=\"-L/usr/lib/arm-linux-gnueabihf\"" > /etc/qemu-binfmt.conf

I used “/tmp/” as my working directory which might not be the best location (temporary, as the name says). Feel free to use another dir, but you might need to keep an eye on the (root) access permissions…

cd /tmp/
mkdir raspi raspi/bootfs
cd raspi

Next I downloaded a minimalistic list of Raspian packages that will later go onto the root partition. I’ve tried to avoid working with root permissions as far as possible (therefore ‘fakeroot’).

fakeroot debootstrap --foreign --no-check-gpg --include=ca-certificates --arch=armhf testing rootfs http://archive.raspbian.com/raspbian

No we need to (temporarily) add some arm binaries to the root directory.

cp $(which qemu-arm-static) rootfs/usr/bin

The following step will start the actual installation process of the Raspian packages. For some reason I was not able to continue at this point without root permissions. (Any tips to fix this are welcome.)

sudo chown root.root rootfs -R

sudo chroot rootfs/ \
/debootstrap/debootstrap --second-stage --verbose

You will need some of the¬†Raspberry Pi firmware files. The following commands download and install them . The Git repository is huge (3.1 GB), so this might take some time…

git clone \

sudo cp -r firmware/hardfp/opt/* rootfs/opt/

At this point you could create a custom kernel image based on the downloaded files. In my opinion the stock kernel is just fine so I just used it as is:

mkdir -p rootfs/lib/modules/

sudo cp -r firmware/modules/* rootfs/lib/modules/

Create the boot partition (i.e. copy the necessary files):

mkdir bootfs
cp -r firmware/boot/* bootfs/

Next we can make some adaptions to the future image files: set a new root password, hostname, adapt the sources list, etc…

sudo chroot rootfs/ /usr/bin/passwd

vim rootfs/etc/hostname

cat >> rootfs/etc/apt/sources.list deb http://mirrordirector.raspbian.org/raspbian/ testing main contrib non-free rpi

It might also be a good idea to adapt the future system to your local settings, e.g. keyboard layout.

sudo chroot rootfs/ apt-get update

chroot rootfs/ apt-get install console-data \ 
console-common console-setup tzdata most locales keyboard-configuration

sudo chroot rootfs/ dpkg-reconfigure locales

sudo chroot rootfs/ dpkg-reconfigure \

sudo chroot rootfs/ dpkg-reconfigure tzdata

Now we can do some clean-up:

sudo rm rootfs/usr/bin/qemu-arm-static

Next step is the creation of the actual boot and root partitions on a SD-Card. I’ve not documented these steps in detail as everyone has a different¬†favourite partition manager. This step can be done with fdisk, (g)parted, or other tools.

You have to create two partitions on your SD-Card. For the boot partition 64 MB are sufficient, the remaining space is used for the root partition. The boot partition needs to be a FAT32 partition. The nice thing about the Raspberry Pi is, that boots of the first FAT32 partition without further installing a boot block or so.

Here an example how a 2 GB SD-Card could look like:

fdisk -l /dev/sdd
  /dev/sdd1 2048 133119 65536 b W95 FAT32
  /dev/sdd2 133120 3987455 1927168 83 Linux

Now we can copy the files from the two directories we previously created onto the two SD-Card partitions (you might need to mount them first) and test the card.

cp -R rootfs/* /media/USER/root/ && sync
cp -R bootfs/* /media/USER/boot/ && sync

I also have created an image file, mounted is (as a block device), partitioned it similar to the steps above. But I have not yet documented these steps. Might be added¬†in a future update…

Fix Eclipse (luna/mars/neon) display on Ubuntu 14.04 and newer

Update: This ‘trick’ still works for newer versions of Eclipse (e.g. mars, neon, oxygen) and Ubuntu versions (14.10, 15.04, 15.10, 16.04, 16.10). I’m using ‘rolling’ updates so I’ve tested most versions¬†mentioned above.

I recently installed Eclipse ‘Luna’ on an Ubuntu 14.04 system and encountered a few display issues. Eclipse was rendered unusable for some GTK reasons…

It took me a while to find a somewhat related blog post that led me to a solution for the missing views and errors when starting Eclipse.

In case of starting Eclipse from a console two environment variables need to be set in advance  to avoid a corrupted Eclipse window:

export SWT_GTK3=0

In my case I created a desktop entry ~/.local/share/applications/eclipse.desktop to facilitate the startup. Adapt it to your needs:

[Desktop Entry]
Comment=Eclipse IDE
Exec=env UBUNTU_MENUPROXY=0 SWT_GTK3=0 /home/kai/eclipse/eclipse

Linux: Direct Flash Video Download

Update: Found a nice Linux console tool that allows downloading Youtube (and other) videos directly only by passing its URL as an argument: cclive

From time to time I find an interesting video in the web I want to buffer (temporarily store) for later offline viewing. In most cases these videos are hosted on one of the major video sites (e.g. YouTube or Vimeo) and are accessible via Flash plugin. But downloading is in most cases prevented (although many videos are under a creative commons license) and “download helper” tools (at least for Chrome) are not really usable.

When viewing such a video in the browser window, the video is locally cached but not directly accessible — or so I thought.¬†A few weeks ago I stumbled across a posting which describes how to copy the contents of such a cached video into a file and thereby creating a direct copy of the video.¬†Please note: I do not take credit for the following steps — I have read them in a Linux (Ubuntu?) forum but forgot to store a direct link to the original source. Sorry.

The first step is to open the video (and only one to avoid confusion) in your browser. Let the flash video start and thereby being cached onto your hard drive.¬†Flash creates an inode with the name “/tmp/FlashXXzzzzzz”. It keeps the file handle open but deletes the file itself right after its creation, rendering it (in theory) inaccessible. But as the file is still open, the shell command “lsof” is still able to show it. So entering

$ lsof +L1 | grep /tmp/Flash

in the console will show all open files with “/tmp/Flash” in their name (grep) that are unlinked (+L1).

chromium- 12345 kai 25u REG 8,3 121314 0 1425364 /tmp/FlashXX1AbcdE (deleted)
chromium- <PID> kai <FD> REG 8,3 121314 0 1425364 /tmp/FlashXX1AbcdE (deleted)

In the sample above I’m using Chromium as browser, the process ID <PID> is “12345”. The interesting number is the “25u” which represents the file descriptor <FD>. In combination with the process ID¬†it can be used to access the cached video data. (This might have to be done with root permissions.)

$ cp /proc/12345/fd/25 /tmp/video.mp4
$ cp /proc/<PID>/fd/<FD> /tmp/video.mp4

Now the file “video.mp4” should contain the video (stream) data in a playable form. Keep in mind: if the caching process was not finished while copying, the video file will also be incomplete.