Posted on Leave a comment

Solving “insecure string pickle” in youtube-dl

I am trying to use youtube-dl to download something for my missus, and the error “insecure string pickle” issue is preventing the video being downloaded. After a few hours of searching the internet finally the following blog solved my problem.

The solution is quite simple:

brew install libav ffmpeg rtmpdump

Just to note my system is Hackintosh running el-capitan with homebrew installed.

Posted on Leave a comment

TERM support in Screen command

When you get the following error message when trying to start screen

Cannot find terminfo entry for 'xterm-256color'.

you will need to find the which TERM is supported:

ls /usr/share/terminfo/x

this will give you a list of supported TERMs i.e.


set the environment variable:

export TERM=xterm-xfree86

and then run the screen command

TERMINFO='/usr/share/terminfo/' screen
Posted on Leave a comment

Fixing corrupted Time Machine backup

If you are a MAC user, the following message pop up at times.

“Time Machine completed a verification of your backups. To improve reliability, Time Machine must create a new backup for you.”

This means that:

  • Time machine will delete all your existing backups, and
  • Create a new initial backup

You will loose all your previous backups. So let’s try to fix this.

Step 1. Preparations

Time Machine will save all backups and every piece of meta information into a *.sparsebundle file on your network storage device. So this is the file we need to fix.

In order to access it, you need to connect to your networks device share that contains the backup with Finder. It will hold one or more *.sparsebundle files in its root, one for each Mac that uses this drive with Time Machine.

After that, open a Terminal window and switch to the root (=admin) user with the following command:

sudo su -

Enter your password if you’re asked to do so.

When you see the error message I talked about above for the first time, Time Machine has already flagged your backups *.sparsebundle file as bad. As a first step, we need to undo this:

chflags -R nouchg /Volumes/<name of network share>/<name of backup>.sparsebundle

Make sure to replace <name of network share> and <name of backup> accordingly and give it a while to finish.

Step 2. Mounting your backup

Next, we need to mount your backups *.sparsebundle file to enable your system to run a few checks on it:

hdiutil attach -nomount -noverify -noautofsck /Volumes/<name of network share>/<name of backup>.sparsebundle

his command will return something like this:

/dev/diskX Apple_partition_scheme
/dev/diskXs1 Apple_partition_map
/dev/diskXs2 Apple_HFS

What is important to us is the line containing Apple_HFS or Apple_HFSX(this usually is the last line) which is the device ID followed by the device type. The X will be replaced with a number which will be anywhere between 2 and 6 or even higher. So, you want to take note of the device ID that looks something like /dev/disk2s2 or /dev/disk3s2.

Step 3. Repairing the *.sparsebundle

Now we can finally let OS X do its magic of trying to repair the file. Run the following command after replacing the dummy device ID with your own:

fsck_hfs -drfy /dev/diskXs2

With this kicked of, you may want to go have a coffee or two as this may take anywhere from 15 minutes to multiple hours, depending on the size of your backup and the speed of your network connection.

After the command finished, you’ll either see »The Volume was repaired successfully« or »The Volume could not be repaired«.

Either way, you need to unmount the backup before taking any further steps:

hdiutil detach /dev/diskXs2

Step 4. Finishing touches

If the repair command from the previous step failed, there’s not much you can do about it and your backups are lost for real probably. You should just let Time Machine create a new backup for you.

If it succeeded though, there is a last step we need to take in order to convince Time Machine to keep using the existing backup.

Use the Finder to navigate to the backups *.sparsebundle file and with a right click, choose »Show package contents« to get a look inside. There you’ll find a file called Since Time Machine uses this file to mark bad backups, too, we need to modify it slightly.

Open the file with a text editor of your choice and find the line saying


and remove them completely. Next find the lines


and change them to


Done. You probably want to eject/unmount the network share from your finder and tell Time Machine to do another backup now.

Posted on Leave a comment

How to unprotect Excel workbook if you don’t have the password

This method only works for Excel in .xlsx format. Hence, if your Excel workbook is in .xls format, just open it and then save it as .xlsx format.
Step 1: Change the Excel file name extension from .xlsx to .zip. Just click on Yes to make sure when prompted.

Step 2: Open the ZIP archive as 7-ZIP. Open the folder xl->worksheets and you can see threesheet.xml files. Select the sheet1.xml file inside the xl>worksheets directory. Right click on it and select Edit. Choose to open it withNotepad.

Step 3: Delete the tag beginning with sheetProtection. Then save and close the sheet1.xml file.

Step 4: Update the modified sheet1.xml file in the ZIP archive when prompted. Then close the ZIP archive.

Step 5: Repeat Step 2 for sheet2.xml, sheet3.xml … for all the sheet that is protected.

Step 6: Change the ZIP fie name extension back to .xlsx. At this point, the Excel sheet has been unprotected. Open it and you can edit the sheet without password.

“With great power comes great responsibility”

Posted on Leave a comment

How to bulk rename file extension in Linux or Mac

There are times where you want to rename file extension or file ending in bulk, e.g.: from

Something_ONE.jpg to Something.jpg

Someotherfile_ONE.jpg to Someotherfile.jpg

the following command can be used, but before test it with the following

ls *_ONE.jpg

for file in *_ONE.jpg
 ls "$file" 

If the above command return the right files then you can rename the files using:

for file in *_ONE.jpg
 mv "$file" "${file%_ONE.jpg}.jpg"
Posted on Leave a comment

How to change where screenshots are saved on Mac

Taking a screenshot on a Mac is effortless. Simply hold down Command-Shift-3 to capture the entire screen, or Command-Shift-4 to capture a highlighted area. You can even hold down Command-Shift-4 and then hit the space bar to screenshot a specific window or menu.

How to change where screenshots are saved on Mac

Step 1: Open Terminal

Step 2: Create the folder where the screenshots will be saved, for this example, I will save it to ~Documents/Screenshots, so type the following command:

mkdir ~/Documents/Screenshots


Step 2:  Now you can change the default setting by typing the following command:

defaults write location ~/Documents/Screenshots

Step 3: To apply the changes, enter the following command:

killall SystemUIServer

Posted on Leave a comment

Making a bootable USB key from an .iso image on Mac OS X

Prepare the USB key

We’re going to wipe the partition structure on the USB key. WARNING! THIS WILL DESTROY ALL DATA ON THE KEY!

Open up Disk Utility (it’s in /Applications/Utilities/).


Now do the following:

  1. Select the USB key (select the root device, not its partitions)
  2. Select the partition section at the top
  3. Change the Scheme to 1 Partition
  4. Change the Format to Free Space
  5. Click Apply

You will get a confirmation dialog appear ensuring you really want to delete all data on the key, choose Partition.

Once it’s completed you can quit out of Disk Utility.

Update: The purpose of doing this is mainly to ensure that the USB key is in a consistent known state and also to ensure that any volumes are not mounted by OS X. It is not required and you can skip it if you’d rather just unmount the volumes yourself.

Preparing the ISO image

Now that our USB key is ready, we need to get our .iso image into a format that we can copy to it. Open up a Terminal (it too is in /Application/Utilities, and I’ll assume you know how to use the terminal).

Now, convert the image from a ISO to a Read/Write Universal Disk Image Format (or UDRW). Here I’m using the Debian 6.0.7 Net Installation ISO, but you can use anything else that’s an ISO file.

[#542]: hdiutil convert -format UDRW -o debian-6.0.7-amd64-netinst.img debian-6.0.7-amd64-netinst.iso 
Reading Master Boot Record (MBR : 0)…
Reading Debian 6.0.7 amd64 1             (Apple_ISO : 1)…
Reading  (Windows_NTFS_Hidden : 2)…
Elapsed Time:  2.054s
Speed: 81.8Mbytes/sec
Savings: 0.0%
created: /Users/evan/Downloads/debian-6.0.7-amd64-netinst.img.dmg

Once completed this will create the .img file. The hdiutil function likes to append a .dmg suffix to the file so it will probably end up .img.dmg after conversion.

Copy the image to the USB key

We’re finally here. The easy part, actually copying the image to the USB key.

First run diskutil list to get a listing of the disks in your machine so you can identify the USB key. It will look like this:

[#543]: diskutil list
   0: GUID_partition_scheme *250.1 GB disk0
   1: EFI 209.7 MB disk0s1
   2: Apple_HFS Macintosh HD 249.7 GB disk0s2

   0: *1.0 GB disk1

Here mine’s /dev/disk1.

Update: We want to use the RAW disk device so that our copy will happen much faster because the RAW disk device provides unbuffered access to the device (See this Apple mailing list post for more info). This is accomplished by simply prepending ‘r’ to the device so that /dev/disk1 is going to become /dev/rdisk1

Update 2: Specifying a blocksize of 1m will also significantly speed things up.

Next we use the dd command to copy the image over.

[#544]: dd if=./xbmc-9.11-live-repack.img.dmg of=/dev/rdisk1 bs=1m

On the command line we specify the Input File using if= and the Output File using of= and dd will copy the data from input to output, block by block.

Once it’s completed you can exit Terminal and remove the USB key from your OS X machine, it should now be able to bootup your ISO on another machine.

Posted on Leave a comment

How to copy a file with I/O errors?

If you encounter the following error

To salvage all readable data, we will use a fault-tolerant copy utility called dd.

dd stands for “disk duplication”. This is a command-line utility bundled with Mac OS X. A free version for Windows is also available for download.

Be extremely careful, even if you are familiar with command line, because dd can cause unrecoverable damage to your data if you don’t specify correctly input and output. You have been warned.

The arguments of dd are straight-forward:

if=path_of_file_with_IO_errors specifies input path
of=path_of_clean_copy_to_create specifies output path
conv=noerror,sync tells dd to be fault-tolerant

Posted on Leave a comment

How to remove all Mac “._” files from a Network Drive

So many of us Mac users have experienced a time where we’re browsing Web Access and discover what appears to be duplicate files that all start with ‘._’

These files are created automatically in Finder on your Mac (Finder metadata) and won’t show up in Finder when viewing your Jungle Disk Network Drive or any of your local drives either. However, they do show up on Windows PCs and also in Web Access and this can create confusion and result in some strange support conversations.

The most common question we receive about these files is “How do I get rid of them?”
Much like Linux, Macs have the ‘find’ command. This powerful command has the ability to recursively delete files that meet search parameters in a directory path.

Note: Terminal is located under /Applications/Utilities/Terminal

The format of this command is going to be: find /Volumes/[your-online-disk-name] -name “._*”

So here’s an example, using my Online Disk, which is called “Storage”

EXAMPLE: find /Volumes/Storage -name “._*”

Running the find command in this way will output all files on your Online Disk starting with “._” to your terminal window. This command is recursive, which means that this will also identify files in your subfolders.
After you’ve confirmed that the command was run appropriately and you’re not seeing any references to directories outside of your Online Disk, it’s safe to re-run the command (but this time, include the -delete flag)

EXAMPLE: find /Volumes/Storage -name “._*” -delete