Create a File of a Specific Size

Sometimes, you just have a need to have a file that is of a specific size.  For example, I want to test the real throughput of copying a file to my external drive over different connections (eSATA/FW800/USB2.0).

 

You can do this with the dd command.

 

Here is an example that will create a 100MB file file:

dd if=/dev/zero of=testfile bs=1024 count=102400

The bs operand tells you what byte size to use and the count operand tells you how many of bs you want.  So in the example, we are essentially asking dd to use a 1KB bs x's 102400.

 

You can also use k, m, g to instead of the full byte amount.  For example:

dd if=/dev/zero of=testfile bs=1m count=100

Now you can use the time command to see how fast you copy goes:

time cp testfile /Volumes/externaldrive/

Google Chrome Application Shortcuts For Mac

I recently purchased a MacBook Pro.  It's not my first Mac as I have a Mac Pro that stands as the "family" computer. Although it houses all of our media and important family data, I really don't use it much with the exception of remoting in to do our finances.  This new laptop however, has enabled me to really dig into OS X and get more comfortable with the OS and all the great applications available for the Mac.

I have been investing a considerable amount of time staging my laptop with all the apps that I will need to use moving forward.  One of those apps is the Google Chrome web broswer.

I don't use Chrome as my default browser, primarily because of site rendering issues.  I do however love the application shortcut feature that Chrome has for Windows/Linux and use it quite heavily.  I was terribly dissapointed when that feature was not available in Chrome for Mac.

Knowing that an OS X app is really a folder with special permissions that contain application data and configuration, I sought out to find a way to create and application shortcut for my web apps.  Below you will find instruction on how to do this.

The example I will use is for the toodledo.com web app.  You will want to just substitute Toodledo in the example with the name & info for your web app.  These instructions assume you already have Google Chrome installed.  It also assumes you know what a text editor is.  TextEdit, Word, Pages are word processors and CANNOT be used.  You can use Terminal based editors like vi or nano.  If you want a gui based text editor, TextMate has a 30 day trial you can use.

1.  In Finder, go to your Applications folder.  Create a new folder called yourapplication.app (where yourapplication is the name you wish to give your new app shortcut, mine was Toodled.app).

2.  You will be asked if you are sure that you want to add the extension ".app" to the end of the name, click add.
3.  Secondary click yourapplication.app, select "Show Package Contents".
4.  Now, create a new folder called "Contents" then open the "Contents" folder.
5.  In the "Contents" folder, create two new folders: "MacOS" & "Resources"
6.  Using your favorite text editor, create a text file called "Info.plist".  It is important that it ends in plist and that no other file extention is appended.  In this file, copy & paste the following information then close and save the fle:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0>
<dict>
<key>CFBundleExecutable</key
<string>Toodledo</string>
<key>CFBundleIconFile</key>
<string>toodledo</string>
</dict>
</plist>


7.  Open the "MacOS" folder and create a new text file called yourapplication, where yourapplication is the name of your app minus .app.  In this file, copy & paste the following infomation:

#!/bin/sh
open /Applications/Google\ Chrome.app -n --args --app="https://www.toodledo.com/views/duedate.php"

Here, you will want to replace my toodledo.com url with the url to your web app.  Close and save the file.

You now have your application shortcut!  Drag it to your Dock and fire it up!

If you have an image you would like to use for your icon, simply:

1.  Copy the image to your clipboard.
2.  Secondary click your new app, select "Get Info".

3.  Click the temporary icon that the OS gave you (the upper left corner of the screen) then issue command-V to paste your new image in.

This is a crude way to get an application shortcut, but it works.  If Chrome gives you any permissions errors, simply quit Chrome, then try your app shortcut again.

-boogybren

Run A Command Every N Seconds

Short story long…

This week, Apple officially release support for Windows 7 in BootCamp 3.1.  I thought to myself “Self, you have a wonderfully powerful Mac Pro with 8 cores and 10GB RAM that is being completely unused by your XP install, you really should upgrade to to Win7 x64 now that Apple officially supports it”.

So, that’s what I did, with no thought as to how much MORE disk space I would need on my BootCamp partition.

So after installing Windows 7 and a bunch of games, I received my you only have < 500MB of disk space left alert.

This brought me to a point where I needed to resize my OSX HFS partition and grow my Windows NTFS partition.  During this madness, I realized that with BootCamp 3.1, I could view my HFS partitions from Windows!  But much to my chagrin, I couldn’t see my slice that had all of my useful data because it was a part of a concatenated RAID.

After resizing my OS partitions, I decided to move data off my RAID slice so I could break it then just create a normal HFS partition that can be viewed from Windows.  The problem is, moving almost a TB of data can take a long time and turning from my laptop to my left 45 degrees to my desktop on my right every time I wanted to see how my disk space looked left me with a pain in my neck!

I was at that very moment reminded about using while & sleep. Below is a handy little command that will run any command every number of seconds until you break (ctrl-c) it.

while truedocommandsleep 30 (seconds)done

I personally ran:

while truedodf -h | grep disk1s2sleep 30done

Which allowed me to monitor the growth of the destination disk I was copying to.

-boogybren