All posts by naklih_blogger

R’s annoying slash problem on windows – a quick and dirty solution…

R’s annoying slash problem on windows – a quick and dirty solution…

R on windows uses a Unix (/) rather than a MS-DOS (\) slash which makes copying paths etc a problem. I have a quick and dirty solution that uses a simple dos program to do the conversion and then put the result on the clipboard. The only minor annoyance with this approach is that it momentarily flashes a dos box up while the app executes but it seems a small price to pay to avoid messing about with com and shell extensions.

To Use
Create a registry Key in [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Copy Path Unix Format]
and a registry entry in [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Copy Path Unix Format\Command] @="*PUT_PATH_HERE*\UnixDirectoryFormatting.exe \"%1\""

After this Your Registry tree Will look like this
SOFTWARE |->Classes |->* |->shell |->Copy Path Unix Format |-> Command
and in command you will have a single key (Default) of type REG_SZ with data ?:...\UnixDirectoryFormatting.exe "%1"

Now if you right click any file in windows explorer you will see the Copy Path Unix Format menu.

The Git hub code for this is here… or if you would prefer the compiled code it is here as a zip file…

StarHub Maxmobile Prepaid Renewal – Sorry, the data plan is not available for your SIM

The starhub maxmobile prepaid service here in Singapore is a pretty good deal, it’s SGD$18 for 5 days access up to 2 GB/day and after this you can renew for SGD$32  for  a further 60 days (at 3.5GB /day) , which is an even better deal.

The problem is the renewal process is a pain in the neck and every time I have tried to do it on the phone( *123#31) it comes up with Sorry, the data plan is not available for your SIM. Please call 1633 for assistance.

This is annoying,  especially if you just spent SGD$32 and loaded 4  x SGD$8 sim cards onto a phone you think you can no longer use! and don’t expect much insight if you do call 1633…

However, the fix is relatively easy… you have to know the number for your phone (which was on the outside of the sim card pack when you bought it) and the password (which is the last 6 digits on the simcard itself – starhub have a graphic to show this on the login page.)

with these two bits of information you then go here and when logged in it shows you your balance and allows you to activate the plan.

 

Invalid (NULL) left side of Assignment in R

I was trying to compile a function in R and came across this error

loadchar() <- function( path, filename){ …

}

Error in loadchar() <- function(path, filename) { :
invalid (NULL) left side of assignment

I couldn’t find much on the internet but the answer (in my case at least)  was simple…

The issue is the brackets in the function name ie it should be

loadchar <- function( path, filename){ …

}

an easy mistake to make … especially if you are jumping between languages regularly

Excel 2010’s lack of a calendar control

For some reason Microsoft have left the calendar control out of excel 2010. Which is a bit of a pain if you need to have a calendar in your sheet. Microsoft blogger sam-radakovitz has created a very good date picker control but it is an add in and so if you need to deploy it in an organisation everyone has to have it installed. This is a bit of a flaw with excel and sometimes it is easier to embed the code into your excel sheet to avoid external dependencies. He also locked the add in so it is difficult to view the source. I knocked up a very basic calendar control here in an afternoon which anyone is welcome to use if they have the need to embed a datepicker into their spreadsheets.  Its not perfect, I could clean up and comment the code a bit better and  it doesn’t do things like position the form underneath the cell but it is functional for day to day use.

There  are 8 steps to using it in your excel sheet

  • Download the zip file including the form from here into a directory on your local drive
  • In the developer tab click Visual Basic
  • In your vba project right click and choose import file
  • choose the form you just downloaded in the first step.
  • On the spreadsheet, again in the developer tab Choose insert and the image control
  • Draw on your sheet where you want the control to be
  • Go into image properties and choose the image you want
  • Double click on the image icon you just created and insert the following code…

Dim myForm As frmCalendar
Set myForm = New frmCalendar
myForm.StorageCell = ActiveSheet.Range(“A2”) ‘ this is the cell you want ‘to update…
myForm.Show

I have put an example sheet in the zip file as well.

I hope that it helps!

I get hundreds of spam comments on this post per day.  If you’re thinking of posting spam, don’t – I won’t publish it and you are wasting your time.  If it is your job to post spam – get a new one ;-)!

Javascript/Css Tip

This has probably been around for ages but I only learnt about it today

When you have a static file but you want to control caching just add a query string as in

<script src=”cachedfile.js?ver=1″ type=”text/javascript”>

next time you want to edit it just change it to

<script src=”cachedfile.js?ver=2″ type=”text/javascript”>

Simple but effective!