How to install Huawei e173 on Mac OS Lion

I live in Sweden and bought a Huawei e173 from the Swedish operator Telia. The only problem is that the 3G modem came with drivers and software for Snow Leopard (Mac OS X 10.6).

To start off, I installed the modem on a windows machine and disabled the PIN-code on the simcard. I personally get quite annoyed when I have to enter a PIN-code everyone I connect a 3G modem..

Next, I downloaded the drivers on my own from mobinil.com, installed them and configured the modem with the following settings:

Dial: *99#

Vendor:Generic

Model: GPRS (GSM/3G)

APN: online.telia.se

Note that the APN is different on every carrier. Just Google it…

Linked: How To Upgrade VMware ESXi 3.5 To 4.1 Update 1 (Free Version)

One more great guide from the guys at TheHowToForge!

A step by step instruction on how to use the Host Update Utility from VMware.

http://www.howtoforge.com/how-to-upgrade-vmware-esxi-3.5-to-4.1-update-1-free-version

Enforce HTTPS with a .htaccess file

Start by enabling mod_rewrite then create an .htaccess file in the directory that you want to force HTTPS.

The content of the .htaccess-file:

RewriteEngine On RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} somefolder 
RewriteRule ^(.*)$ https://www.domain.com/somefolder/$1 [R,L]

Now if you go to http://www.domain.com/somefolder you will be redirected to https://www.domain.com/somefolder.

How to force TotalTerminal to always display on top of the dock

I have been using TotalTerminal for a while now. But since the latest 1.1.1 the visor is displayed under the dock. (I have my dock on the left side of my screen) This is both annoying and renders the TotalTerminal useless.

This is all due to a bug fix in 1.1.1. There is a way to fix this issue.

Open a new terminal.app window and enter the following line:

defaults write com.apple.Terminal TotalTerminalVisorWindowOnHighLevel -bool YES 

Restart Terminal.app with TotalTerminal.

The TotalTerminal visor is now shown on top of the dock.

Source: GetSatisfaction

Linked: How to Ensure Ethernet Connects Before AirPort on Your Mac

Some time ago I found this great blog-post about how to prioritize the Ethernet connection over Wi-Fi. In my case this is when I’m at home.

Sometimes, your Mac will connect to a janky Wi-Fi network. The connection is slow or you’re on the other side of a lead wall and you’re getting a really poor signal. When you finally find an Ethernet jack to plug into, you may notice you’re still connected to the Wi-Fi network that was giving you problems. This is because your Network Service Order list is out of its proper order to allow the Ethernet to take over when plugged in. Don’t fret, we’ll show you how to reset the Service Order list on your Mac to ensure that Ethernet takes priority over AirPort.

Read the full post at maclife.com

Linked: How To Rebuild LaunchServices to Remove Duplicates from “Open With” Menu

Have you ever used the right-click “Open With” feature in Finder when opening a specific type of file?  While this feature is usually pretty handy, if you install and remove applications on a regular basis there may still be traces of those applications that have been long-gone from your Mac. In this how-to, we’ll show how you can rebuild this list so it remains up-to-date and only shows what you currently have on your hard drive.

Basically you open a terminal and run the following command…And wait.

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

Source

Logging my work to a text file and making it readable in VIM

I use VIM to edit text-files on my mac. Or I use VIM to edit a couple of text-files containing my my worklogs. So I can keep track of what I have done on different projects and at what time.

Creating a quick log entry

I have edited my .bash_profile with the following line
alias wl='vim + ~/Dropbox/NV/worklog.txt; clear'

This in combination with quick access to terminal.app using Visor makes appending to my worklog almost instant.

  1. Visor keyboard shortcut, in my case Alt + § (On a Swedish keyboard It makes sense)
  2. I type wl and press enter
  3. VIM opens the last line in my worklog
  4. To enter insert mode and append to the end of the line i type A.
  5. I type enter -> nnow ,which is my TextExpander abbreviation for inserting a date and time stamp, on the new line. (Example: 2011-04-12 20.20 [Tuesday] )
  6. The I write a short log of what I’m doing at the moment.
  7. I save and exit the worklog file by typing Esc (to exit insert mode), then wq -> enter.

Done.

Making the text file readable in VIM

To make this logfile more readable I use a customized color formatting.

Edit the ~/.vimrc file

This is the content of my .vimrc file.

colorscheme desert
syntax on

au BufRead,BufNewFile *.txt set filetype=txt
au! Syntax newlang source ~/.vim/syntax/txt.vim

Create the ~/.vim/syntax/txt.vim

Source

I downloaded Tomasz Kalkosinski’s universal syntax script for all txt docs. But I added a couple of changes of my own:

syn match logDate /^\d\{4}-\d\{2}-\d\{2}/
syn match logTime /\d\{2}:\d\{2}:\d\{2},\d\{3}/

And later in the file:

HiLink  logDate Comment
HiLink  logTime Todo

You can download my vim.txt file here.

How I manually migrated from vCenter 4.0(32-bit) to 4.1u1(64-bit)

Last week I upgraded a vCenter 4.0 installation to 4.1u1. The vCenter was installed on a 32-bit VM so I needed to migrate the installation to a new 64-bit host.

I tried to do the migration according to the vSphere 4.1 upgrade pre-installation requirements and considerations guide. But sadly I got an error during the migration process.

RESTORE FILELIST is terminating abnormally.

The error is described in this thread at vmware communities.

Also, the datamigration scripts makes the original vCenter database corrupt. So if the datamigration fails, as it did for me, the original installation is trashed. (Luckily the datamigration scripts exports a backup before trashing it. But this procedure stinks anyway.)

So how did I migrate? Well I found a workaround and did the following.:

On the old vCenter 4.0 server (32-bit)

  1. Stop the vCenter service
  2. Install Microsoft SQL Server Management Studio Express
  3. Open Management Studio and detached the vCenter database.
  4. Copy the database files.
  5. Copy the % ProgramData% \ VMware \ VMware VirtualCenter \ SSL folder.
  6. Shutdown the vCenter VM.

On the new vCenter 4.1u1 server (64-bit)

  1. Install vCenter 4.1u1 with all the default settings. (This installs SQLExpress and the vCenter database)
  2. Uninstall vCenter from add and remove programs. (This does not remove the SQLExpress installation)
  3. Restore the % ProgramData% \ VMware \ VMware VirtualCenter \ SSL
  4. Install Microsoft SQL Server Management Studio Express
  5. Detach the newly installed database and attach the one from the old vCenter server.
  6. Create a ODBC connection to the local SQLExpress server with the old vCenter database.
  7. Install vCenter 4.1u1 and choose existing ODBC connection during the installation. The installer will detect the old vCenter database and upgrade it.

I wonder why VMware don’t recommend this procedure in the first place?

Install VMware Tools on Trixbox

Recently I had to install VMware Tools on a Trixbox installation.

1. First, in the VMware console, run ‘install vmware tools’ in the menu
2. Mount the cd-rom drive in an empty folder:

cd /media
mkdir cdrom
mount /dev/cdrom /media/cdrom
cd /media/cdrom

3. Copy the .tar.gz file to somewhere such as /home & extract..

cp VMware-tools.xxxxxxxxx.tar.gz /home
tar xvfz VMware-tools.xxxxxxxxx.tar.gz
cd /home/vmware-tools-distrib

4. Run the installation:

./vmware-install.pl

Source

Aligning VM Partitions Without Losing Data

If you align your virtual disks the performance of your VM:s increases. The only problem is when you have a n already installed VM that doesn’t have aligned disks.

Do you really want to create a new VM with aligned disks and then install the OS, VMware tools, applications etc?

I found a great guide on how to align partitions without losing data on tuxyturvy.com.

It basically boils down to the following:

1.  Make sure the disk is defragmented
2.  Boot the system with the Gparted live CD.
3.  Select the parition you are wanting to resize and choose (Move/Resize)
4.  Shrink the volume by some amount, the smaller you shrink it the faster it will copy during the move step.  I usually shrink it a GB or so larger than the amount of data on the drive.
5.  Move the partition to right by a few MB’s to free up space at the start of the disk.
6.  Once the move completes, exit Gparted, not the entire live CD, just the Gparted application
7.  Start the terminal window on the live CD
8.  In the command window type ‘parted /dev/sda’ (substitute your actual device here) to start the command line parted editor
9.  Create a new partition at the start of the disk to fill in the space up to the section where you want to align your parition.  For example, if you want your system partition to start at sector 128, create a very small partition that takes up space from sectors 63-127.  The command would be something like this:

mkpart primary 63s 127s

This tells parted to create a new primary partition from sector 63 to sector 127.  That means the very next sector available is 128, a stripe aligned partition.  You may want a different start sector based on your array (some use 64K, some 128K, some bigger) but I’ve found the 128K alignment to work well with both 64K (Equallogic) and 128K (EMC Clariiion) stripe sizes.

10.  Exit parted and restart the Gparted GUI by clicking the Gparted icon.
11.  Use the Move/Resize option to resize the NTFS partition to fill the entire remaining space.  As pointed out by several users, you MUST uncheck the “Round to Cylinders” option prior to this.  I guess I thought this was obvious since we’re trying to align to a specific sector but that’s why I’m not a documentation writer.
12.  Exit gparted, run parted again, remove the small partition you created earlier and reboot.

How to import/export files to/from a Sharepoint server

I found a great way to migrate all your files from a Sharepoint server. I have kind of had it with Sharepoint, at least for small installations. (You can read more about my new setup in How I built a Apache front-end for a Windows Share with SSL and LDAP Authentication)

The problem came up when I wanted to export all the files form the Sharepoint server. My first instinct was to open Sharepoint in Windows Explorer. But it kept throwing me the “your client does not support opening this list with windows explorer” when I tried to open the Sharepoint in Windows Explorer.

I was almost ready to give up when i found SPIEFolder. A great little application that did exactly what I wanted. I just downloaded is and ran it on the Sharepoint server, 2 minutes later the Sharepoint was exported.

….If only Microsoft could write tools like this. ;)

Introduction

Allows you to either Import a file system folder (And all files and subfolders) into a SharePoint Document Library, and also export a SharePoint Document Library to the file system for WSS 2.0/SPS2003 or WSS 3.0/MOSS 2007. This tool completely replicates the a document libraries folder hierarchy to the file system when exporting, and replicates the folder hierarchy from the file system to the document library when importing.

Importing

The folder can be imported into a Document Library using the following syntax (Note the “import” argument: Example usage:

spiefolder http://krichiemoss "Shared Documents" c:\spiefolder\SeedFiles import

The end result is that the file system folder and complete contents and folder hierarchy is created in the document library on SharePoint

Exporting

To export a SharePoint Document Library to the file system, and replicate it’s folder hierarchy and contents, simply list the sites URL, List Name to read contents from, and File System path to export to. (It is not necessary to supply the optional “export” keyword as it is the default operation.

Example usage:

spiefolder http://krichiemoss "Shared Documents" c:\spiefolder\SeedFiles

This will export the contents of “Shared Documents” to the file system into the folder specified via c:\spiefolder\ and replicate the document libraries folder hierarchy.

Download: http://spiefolder.codeplex.com/

How to install VMware tools on Debian/Ubuntu

I have found that the following set of commands works pretty much across the board when it comes to installing VMware tools on Linux machines. With the exception of how to get the developer tools needed to build the VMware tools…

But here is how it’s done on Debian and Ubuntu.

  1. Mount the virtual CD with the VMware tools on your virtual machine. Using the install VMware Tools option in the VI-client.
  2. Open a console to the virtual machine using the VI-client.
  3. Run the following commands
  4. $ sudo apt-get install build-essential
    $ mount /cdrom
    $ cp /cdrom/VMware* /tmp
    $ umount /cdrom
    $ cd /tmp
    $ tar xvfz VMware*.gz
    $ cd vmware-tools-distrib/
    $ sudo ./vmware-install.pl

  5. Reboot the virtual machine
  6. Done

How I built a Apache front-end for a Windows Share with SSL and LDAP Authentication

When my company migrated from Exchange 2003 to Exchange 2007 public folder became a big issue. Public folders where used to share documents to our road-warriors. So to fix this we installed a sharepoint server

The problem is that the sharepoint install was like using a rocket propelled grenade to kill a fly. It became more of a problem than a nice way to distribute documents to the people on the road.

So I decided to set up a web-based front-end running apache that points to the windows share that everyone in our office uses.

1. Setting up the virtual machine in our VMware vSphere cluster

OS and SSH

I started by installing a basic Debian 5 server without the GUI stuff. I also installed SSH for remote access..

VMware Tools

I installed VMware tools on the newly created VM.

# apt-get install build-essential
# mount /cdrom
# cp /cdrom/VMware* /tmp
# umount /cdrom
# cd /tmp
# tar xvfz VMware*.gz
# cd vmware-tools-distrib/
# ./vmware-install.pl

2. Webserver

Apache 2.2

I installed apache2.2 by running the following command.

# aptitude install apache2

PHP5

PHP is not actually a part of this setup but I figured that I would install it for future use..

# aptitude install php5 libapache2-mod-php5
# /etc/init.d/apache2 restart

Add support for MySQL in PHP

# aptitude install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json
# /etc/init.d/apache2 restart

3. Mount the Windows Share as part of the filesystem.

I mounted the share to the /var/www (to make it simple)..

# apt-get install smbfs 
# update-rc.d -f umountnfs.sh remove
# update-rc.d umountnfs.sh stop 15 0 6 .

I added the following to the fstab: (I have substituted the actual paths and share names with < … >)

//<Windows fileserver>/<Windows share> /var/www/<Windows share> smbfs iocharset=utf8,file_mode=0777,dir_mode=0777,user=<domain>/<username>,password=<password>,gid=33 0 0

To mount the share:

mount -a

4. Security settings

Block access to http://<serverURL>/<Windows share> over port 80 (unencrypted)

I added the following to the /etc/apache2/sites-enabled/000-default

<Directory /var/www/<Windows share> >
Deny from All
</Directory>

Activate support for LDAP authentication in Apache

I created the following symlinks for mod_ldap and mod_authnz_ldap from /etc/apache2/mods-available to mods-enabled

SSL and LDAP authentication

I started by activating SSL by creating a symlink from ssl configuration file (/etc/apache2/sites-available/default-ssl) to the /etc/apache2/sites-enabled directory.

The I made the following changes to the configuration file.

<Directory /var/www/<Windows share> >
    Order deny,allow
    Deny from All
    AuthType Basic
    AuthName "<Name of the share>"
    AuthBasicProvider ldap
    AuthzLDAPAuthoritative on
    AuthLDAPURL ldap://<Windows domaincontroller>:389/dc=<domain>,dc=<local>?sAMAccountName?sub     
    AuthLDAPBindDN "cn=<Bind user that checks the AD>,ou=<some ou with the user>,dc=<domain>,dc=local"
    AuthLDAPBindPassword <password for the binduser>
    Satisfy any
    require valid-user
</Directory>

5. Creating the redirect from http to https

Pretty much every user will open http://<serverURL>/<Windows share> instead of https://<serverURL>/<Windows share>. So I have to create an automatic redirect.

I created the following /var/www/index.php file.

<?php
header( 'Location: https://<serverURL>/<Windows share>');
phpinfo();
?>

6. Nicer looking icons on my index page

I didn’t like the standard Apache index look so I did the following.

# cd /tmp
# apt-get install bzr
# bzr get http://code.ecchi.ca/apache-tango-icons
# ./install.sh

I have also changed the /etc/apache2/mods-enabled/autoindex.conf

IndexIgnore .??* ~* Thumbs.db *.lnk SyncToy_*
IndexStyleSheet "/icons/style.css"

I created/changed the /usr/share/apache2/icons/style.css with the following content.

body {
        font: 85% Arial,Helvetica,Sans-serif;
        color: #444;
        line-height: 2.2em;
        background: #f9f7f5;
}
a:link, a:visited { color: #4265a7; }
.entry a:link, .entry a:visited { font-weight: bold; }
a:hover { color: #993333; }

address {display: none}
table {
border-collapse: collapse;
width: 80%;

}
td, th {
  padding: 2px;
}

References

  1. Debian install ISOs
  2. How to install Apache, mysql etc.
  3. Apache authentication, LDAP etc.
  4. Better lookling icons for the index listing

Notational Velocity: Taking notes like a Boss.

About a year ago reconstructed my note-taking process on my MacBook Pro and iPhone. After listening to Merlin Mann talk about the original Notational Velocity on MacBreak Weekly episode 178. So I decided to give it a try.

At the time I used Evernote for my notes. The problem with Evernote was that if I wanted to edit a note on my iPhone, the iOS version just appended the file. I never liked that. It messed up my notes. The cool thing about Notational Velocity is that it’s all about .txt files. The power of simplicity!

Long story short, I downloaded the original Notational Velocity application on my Mac, created a folder in my dropbox and signed up for Simplenote.

Then came the big revolution with Notational Velocity with a Markdown hack.

My setup today.

I have disabled syncing with simple note. Now I only use Dropbox for syncing my devices. I have also moved from Notational Velocity with markdown to Notational Velocity Alt. The reason being the landscape layout and custom CSS support in NV Alt.

My Custom CSS file for NV Alt

I thought that I would share my CSS file for NV Alt.

After the first time you run the Preview window, look in ~/Library/Application Support/Notational Velocity and you’ll find two files:template.html and custom.css. If you’re handy with HTML and CSS, feel free to customize these in whatever way you like. You can add Javascript as well, but you’ll need to load external scripts from a url or using a full file:// path. If worst comes to worst, you can just delete or rename your customizations and the default files will be put back in place automatically.

body,p,td,div { font-family:Helvetica,Arial,sans-serif;line-height:1.4em;font-size:12px; }
p { margin:0 0 1.7em 0; }
a { color:rgb(13,110,161);text-decoration:none;-webkit-transition:color .2s ease-in-out; }
a:hover { color:#3593d9; }
h1.doctitle { background:#eee;font-size:14px;font-weight:bold;color:#333;line-height:25px;margin:0;padding:0 10px;border-bottom:solid 1px #aaa; }
h1 { font-size:24px;color:#000;margin:12px 0 15px 0; }
h2 { font-size:18px;width:auto;margin:15px 0 10px 2px; }
h2 em { line-height:1.6em;font-size:12px;color:#111;text-shadow:0 1px 0 #FFF;padding-left:10px; }
h3 { font-size:14px; }
h4 { font-size:12px;margin-bottom:1.3em; }
.footnote { font-size:.8em;vertical-align:super;color:rgb(13,110,161); }
#wrapper { background:#fff;position:fixed;top:0;left:0;right:0;bottom:0;-webkit-box-shadow:inset 0px 0px 4px #8F8D87; }
#contentdiv { position:fixed;top:27px;left:5px;right:5px;bottom:5px;background:transparent;color:black;overflow:auto;text-indent:0px;padding:10px; }
#contentdiv::-webkit-scrollbar { width:6px; }
#contentdiv::-webkit-scrollbar:horizontal { height:6px;display:none; }
#contentdiv::-webkit-scrollbar-track { background:transparent;-webkit-border-radius:0;right:10px; }
#contentdiv::-webkit-scrollbar-track:disabled { display:none; }
#contentdiv::-webkit-scrollbar-thumb { border-width:0;min-height:20px;background:#777;opacity:0.4;-webkit-border-radius:5px; }

Boom!