Search...

14 January 2013

Installing Visual Studio 2012 (Windows 7)

Some things in life should be as simple but aren't! After years of installing various versions of Visual Studio you would think I would be prepared for battle but Visual Studio 2012 still managed to get me!

tl;dr Use this iso file to install Visual Studio 2012 Pro, the web installer doesn't work!

(As a side note, I long for the day where installing something on Windows is as easy as it is on *nix. I can install a whole operating system and associated programs in the time it takes to install Office! Alas, that is a separate post!)

Being a modern kind of guy I opted to try and install Visual Studio 2012 Pro via the web installer. I have a decent internet connection and was not expecting a 2 hour install. I was even more disgruntled when it failed! It apparently had not managed to install the Javascript or Sql 2012 tools packages. Reading the ever interesting log files provided no useful (translate : Google'able) info and so I tried to repair the installation. That also failed only this time with a longer list of failed packages.

I then decided I would try a clean install using the old fashioned iso provided by Microsoft. I tried to uninstall Visual Studio 2012 and .... it failed! (I can see a patten forming here.) I tried various things and finally after three tries managed to uninstall it. By try various things I mean I rebooted, I tried to kill various processes that looked like the installer was orphaning and clearing out %temp%.

I then installed this iso file (via the excellent daemon-tools). Forty minutes and another coffee later and it worked and installed.

You would think that in this day and age the web installer would be fail safe. It should know what packages you need download them and install them in a fast and successful manner. Come on Microsoft, it's not hard!

13 December 2012

A Simple Bash open() function That Is Platform Independent.

I use Bash as my shell of choice. This is partly laziness, I learnt Bash first and it has always been the default on clean installs, and also because if I end up on a server or a machine that has just been set up I know what I am doing and don't miss fancy functionality provided by other shells. That's not to say that on my To Do list for 2013 is to learn more about zsh.

One of the tasks I have been trying to do over the last couple of months is tame my dot-files. In doing this I have been trying to clean up functions that I have added to my .bashrc and make them more machine/platform independent. (Once I have done this I will write up how I have structured my dot-files and point you to my GitHub repo).

One of my more frequently used functions is open(). I use Bash extensively on Windows via Cygwin as well as on *nix machines. The aim of the function I started out with was to allow me to open files directly from Cygwin's Bash shell that were standard Windows files (such as Word and Excel files). Since I got in the habit of using the function on Windows I wanted something that worked the same on Linux. Below is the (very) simple function I ended up with

 1 function open()
 2 {
 3     UNAME=`uname`
 4     OSLINUX="Linux"
 5     OSCYGWIN="CYGWIN_NT-6.1-WOW64"
 6 
 7     if [ "$UNAME" = "$OSLINUX" ]; then
 8         if [ "$1" = "" ]; then
 9             echo "open Failed, No file specified to open."
10         else
11             xdg-open "$1"
12         fi
13     elif [ "$UNAME" = "$OSCYGWIN" ]; then
14         if [ "$1" = "" ]; then
15             NATIVE_PATH="."
16         else
17             NATIVE_PATH="$1"
18         fi
19 
20         WIN_PATH=`cygpath -w -a "${NATIVE_PATH}"`
21         cmd /C start "" "$WIN_PATH"
22     fi
23 }

I am sure that the function will be cleaned up some more and made simpler however, it works as I need it to in the 5 mins I worked on it.

The function use's xdg-open which is desktop independent on Linux so it should "just work" otherwise on Cygwin it just uses 'cygpath' to generate the correct file path before using 'cmd' to launch the path.

Please Note :: The path provided to cmd is hard coded to my C:\ drive. I have long given up on using partitioned Windows disks so I took the lazy route here.

Once added to your .bashrc you can just call $open file or $open . or $open ../ to open a file or open the File Manager in the current directory or parent directory.

25 October 2012

Internet Explorer JavaScript - Changing An Elements Type.

Note to Self : When attempting to change an elements type attribute in JavaScript use the setAttribute() function as it is the only way to do it that works with Internet Explorer.

Note to Browser Developers : Please standardise this stuff as it takes too much time to achieve simple solutions!

3 October 2012

Powershell XML Configuration Files.

Recently I have been playing with Powershell and while I still prefer Bash as a shell (long time user) I was impressed with the amount that can be achieved with Powershell.

One of the things that I was looking at doing was automating our build process as we had hit a css file count limit in Internet Explorer (31). I should point out that our css is not that badly laid out but we load specific css files dynamically based on the client's needs. So my aim was to minify our css with the Ajax Minifer tool which can be found on Codeplex. The only issue with our current development set up is that my co-developer hosts his svn working directories on a different drive to mine so I needed to provide a configuration file to specify the path to Ajax Minifer and our code.

Turns our this is really easy in Powershell as it can natively parse XML and provides a nice tree structure to use. The following reads, parses and provides the XML configuration file as said tree :

# read the local config file for various settings ...
$cfgFile = "$PATH_TO_FILE"
$root = "$NAME_OF_ROOT_NODE"
$cfg = [xml](gc $cfgFile)

At this point you have access to the child nodes through $cfg. For example $cfg.$root.EnableDebugging -eq "True" returns the value of the <EnableDebugging> child node and check's whether it's value is set to True.

As with all scripting and shells there appears to be more than one way to achieve this but it works perfectly for what I needed.

20 September 2012

Passing Arrays Between Contexts In Javascript

Today I have found a nasty gotcha that stumped me for some time while creating a snippet of JavaScript which called a function that included an Array as a parameter.

I was trying to call a function on an object bound to the window which contains some utility classes. I created my Array, populated the values and sent it to the function. However, it didn't work as expected. After some head scratching and debugging in Chrome I found that the receiving code was not seeing the Array parameter as an instance of Array. Instead it was seeing it as an object.

After checking my calling code to ensure I was not having a daft moment, and after much trial and error I hit Google. The answer was actually rather obvious once I found it. The problem I was having was that the calling code was in an iframe in my page. When you create an Array you are actually creating a window.Array object. This of course means that the object's prototype is not available to in the window context (i.e. the parent page) and so the receiving function was treating it as an object.

The answer, as I realised while talking to my co-developer, was that in order for the parameter to be seen in the receiving code as an Array, it needed to be declared as new parent.Array(). Once this change was made everything worked as expected.

20 August 2012

Ruby on Rails Arch Linux Basic Instal

I have been playing with Ruby on Rails for a while after completing a Coursera based SaaS course recently. While undertaking the course I worked on an Ubuntu VM which was provided by the course. However, as in all things I hack around with on Linux I really wanted to set up a basic Rails development environment on my main Arch Linux machine.

While the guide on the Arch wiki was fine when I reached the point of testing my environment I got the following output in bash ....

/usr/lib/ruby/gems/1.9.1/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.

A quick hunt around the forums did not help me!

Following the link in the above error message I read up on execjs and found that you need a supported runtime. I opted for therubyracer, an implementation of the Google v8 javascript runtime.

In bash I ran gem install therubyracer which installed the runtime. I then added the following line to my test applications Gemfile :

gem 'therubyracer', :require => 'v8'

Running rails server now served up my test app on the default port (using WEBrick).

8 August 2012

Arch Linux glibc Update

Arch Linux has made a rather big change to the file system recently and has moved the files in the /lib directory to the /usr/lib directory and /lib is now a symlink to usr/lib. You can get an overview of the change here and here. Both of these pages give instructions and possible issue resolutions for most case's.

However, as searching the Arch Forums on glibc will show, the resolutions outlined in the above documents do not always work. There are a large number of users that have had problems due to various files that are left in the /lib directory. To quote Zamboniman from the Arch Forums "This has been one of the more frustrating upgrades in my history with Arch." After running pacman -Syu recently I discovered I was one of these people!

I have now resolved my issue and wanted to detail it incase it is any help to anyone else still struggling with the issue. For a little background I am running Arch 64bit.

NOTE DO NOT USE --force WITH pacman IN ANY FORM TO RESOLVE THIS ISSUE AND DO NOT DELETE OR MOVE ANY FILES MANUALLY.

First, I followed the recommended update method and ran pacman -Syy and then pacman -Syu --ignore glibc. This brought the system up to date and I then ran pacman -Su which will update glibc. However, like so many others, I got the following error output :

error: failed to commit transaction (conflicting files) glibc: /lib exists in filesystem

This, apparently, is caused by files remaining in the /lib directory. As per a number of the suggested solutions I then ran find /lib -exec pacman -Qo -- {} + which lists who owns the files left in the /lib directory. As recommended in one forum post I started to look for files not owned by glibc. There was one file and that was lib32-glibc. A lot of the solutions suggested at this point to just delete the file or uninstall the program that it is installed by however, looking at the file version (2.15-10) I noticed that there was a newer version available. The file is installed from the Multilib repository and I was at a loss as to how it was not being updated. After a little more digging I found that the Multilib repository was commented out in the /etc/pacman.conf file. I uncommented the repository entry in the file and ran pacman -Syy and then pacman -Syu --ignore glibc and then ran pacman -Su.

This all appeared to work. As a final check I ran ls -ld /lib which should output lrwxrwxrwx 1 root root 7 Jul 7 11:09 /lib -> usr/lib which denotes that everything has worked.

This solution will probably not fix everyone's issue with regard to this update and the links below are to forum threads that helped me track down the solution to my problem

  • https://bbs.archlinux.org/viewtopic.php?id=145006&p=1
  • https://wiki.archlinux.org/index.php/DeveloperWiki:usrlib
  • https://bbs.archlinux.org/viewtopic.php?pid=1129890 - This thread contains Zamboniman's excellent advice which appears to have helped a number of people with slightly different issues to mine.
  • https://bbs.archlinux.org/viewtopic.php?id=109765 - Multilib related.
Now, to get on with playing with KDE 4.9!