h1

iPods, iPhones, Safari and Evernote

29/09/2009

The default browser on the iPhone and iPod is Safari which is a built in application.  As it currently stands inbuilt applications on Apple’s hand held device operating system doesn’t give much to developers who would like to be able to add extra functionality (at least not without jail breaking).  The option to send page content to EverNote from Safari is something I had hoped would be easily available, but found myself having to manually copy content from Safari to EverNote.

After a little investigation I discovered that it is possible to add an EverNote bookmarklet into Safari’s bookmarks, making things a little easier.  The downside is that this bookmarklet only works for adding the whole page and not just a portion of the page (as it does in browsers on more  fully fledged computer platforms).  If you want a page fragment, copy and paste is still the only option.

So here’s the 10 simple steps to add your EverNote bookmarklet…

  1. Bookmark this page in Safari on your iPod or iPhone.
  2. Copy the text in the bookmarklet section below this list of instructions.
  3. Select your bookmarks list.
  4. Select “Edit”.
  5. Select the bookmark you just made.
  6. Rename the bookmark to something relevant – e.g. “Send to EverNote”.
  7. Delete the URL.
  8. Paste the text you copied from the bookmarklet section below into the URL.
  9. Select “Done”.
  10. Select “Done” and you should return to the browser window.
Bookmarklet
javascript:(function(){EN_CLIP_HOST='http://www.evernote.com';try{var%20x=document.createElement('SCRIPT');x.type='text/javascript';x.src=EN_CLIP_HOST+'/public/bookmarkClipper.js?'+(new%20Date().getTime()/100000);document.getElementsByTagName('head')[0].appendChild(x);}catch(e){location.href=EN_CLIP_HOST+'/clip.action?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);}})();

When you want to add a page to EverNote, just select this newly created bookmark. An in place window will appear which will then allow you to login to your EverNote account. Once logged in (and you can set it to remember your details), you can then add the page directly into an EverNote notebook, tag the page, etc.

Please note that the bookmarklet content above was created by EverNote and not by me.  I’m displaying it here as plain text as it was the only way I found to be able to get it into Safari on my iPod.  If EverNote update their system, the bookmarklet presented here may no longer work.  If this does occur try taking a look at the (new) original EverNote bookmarklet URL (available from EverNote’s web clipper page) in your desktop browser.

h1

Caps Lock on iPod Touch and iPhone

29/09/2009

I recently bought an iPod touch and for several days struggled whenever trying to type in acronyms like “BBC” as the iPod’s on screen keyboard didn’t seem to have a way to lock capitals on.  I finally came across the solution when looking through some of the settings.

So to enable caps lock functionality on your iPod Touch /iPhone.

  1. Select the settings option on your device.
  2. Select the “General” settings.
  3. Select the “Keyboard” settings.
  4. Turn “Enable Caps Lock” on.

When using the on screen keyboard double tap the shift key.  It will turn blue and the caps lock will be turned on.  Tap the shift key again to disable it.

I still don’t know why Apple disable caps lock by default but at least now you can enable it on your iPod touch or iPhone.

h1

VB.Net – Hide Form at Startup

28/08/2009

I’ve been using Microsoft Visual Basic 2008 (Express Edition) recently to create some utilities.  As part of this I needed to have an application start-up but only display as an icon in the system tray.  After attaching a notify icon control to my main form I set the form’s load method to set the display in task bar and visible properties of the form to be false.

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
notifyiconMain.Visible = True
Me.WindowState = FormWindowState.Minimized
Me.Visible = False
End Sub

However this code doesn’t have quite the effect you think it should – i.e. hiding the form and displaying the icon in the system tray.  What in fact happens (at least on Windows XP) is the window is squished up next to the start menu (the icon in the system tray is also there – as we would want).

That window shouldn't be visible

That window shouldn't be visible

These few lines of code work fine once the form is created and displayed, so the issue is definitely linked to the initial creation of the form.

After trying several options (such as minimise, restore, minimise) I succumbed to Googling for an answer and whilst I found lots of answers they were all complicated, a little laborious or just bad coding practice.  However I did find a different and surprisingly simple solution.

Rather than setting the window as minimised in the load method just set the WindowState property of the form to “Minimized“.  The load method then simply becomes…

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
notifyiconMain.Visible = True
Me.Visible = False
End Sub
h1

Excel: Last Entry

28/08/2009

I was challenged to work out a little problem someone was having with Excel today.  The expectation was that I could write some VBA to resolve it, but once I found out what the task was I quickly managed to put together a purely Excel function based solution.

The task was to pick the last entry from a vertical list of cells.  The list is sequential so there are no blank lines which makes the choice of algorithm to find the last entry quite open.   The algorithm I chose was based on a list length and vector approach.

Example

Example

So to start with I needed to know how many entries were in the list.  The COUNTA function will provide this.  This in effect tells us how many rows we have to step down to get to the last entry.  The OFFSET function allows us to carry out these steps based on the first entry in the list.  Because we’re starting at the first entry then we don’t need to move if there is only one entry, so we need to subtract one from the count to give us the number of “steps” to take from the first cell.

The screen shot illustrates how this is built up for a list in column A starting at cell A1.  The function we would use is simply =OFFSET(A1,COUNTA(A:A)-1,0,1,1)

However this does give us a #REF! if the list has no entries – which looks like an error if you give someone a blank list (essentially because it is).  So if you need to account for this, just include an IF.

=IF(COUNT(A:A)=0,”",OFFSET(A1,COUNTA(A:A)-1,0,1,1))

h1

Quit XBMC when it freezes (MAC)

24/08/2009

I run XBMC on a Mac Mini plugged into my TV.  Sometimes XBMC gets a bit caught up and freezes or gets locked into some sort of loop.  I have it running in full screen which makes it rather hard to quite when the application with focus is non-responsive.  So to get past this, press F8 to bring up Spaces and navigate to another space.  From here right click on XBMC in the dock to reveal and select Force Quit.

h1

Send Web Cam Pictures to EverNote with SnapIT

23/08/2009

Since Google Notebook went out of development earlier this year I’ve made the migration over to EverNote. It has many cool features one of the coolest being the ability to upload images and have EverNote run OCR to index the content of the image.  The mobile phone EverNote applications allow a phone’s camera to be used to take a snapshot image and to upload it to EverNote over a 3G connection.  Unfortunately the Windows desktop application has no functionality for capturing images in the same way through a web camera and with the proliferation of netbooks I feel that this is a feature that is sadly missing – well for me anyway.   So after a bit of research I embarked on a quick weekend VB.Net project to put together a little application that could do this – and so I created SnapIT.

SnapIT Main Screen

SnapIT Main Screen

SnapIT allows you to take a photo with an attached or built in camera (by pressing the “Capture Image” button) and save it (by pressing the “Store Image” button) to a specified folder as a JPEG with a file name based on the time at which it was taken.  It also allows you to send the image off to an EverNote database with options to specify which notebook it gets sent to (it will of course default to the default notebook), a title and tags (separated by commas).  Where the image ends up is determined by the checkbox options that have been selected (next to the “Store Image” button).

Settings window

Settings window

It’s a standalone executable and stores a few settings in an INI file it creates in the same folder.  When you first use it (assuming you want to save images or send them to EverNote) you will need to set a few file/folder paths.  This can be done from File > Settings.  You need to set a folder to store images in, the location of ENScript.exe (used to send the image to the database) and the location of the EverNote database file to which images should be sent.

This is just something I threw together for my own use and given that I wrote it in just a day or so it really hasn’t gone through much testing, so please keep that in mind when using it.  That being said if you find a bug then add a comment to this blog post and if I can reproduce it I may just find the time to fix it and post a new version.

h1

ENScript – Scripting Evernote in Windows

21/08/2009

I’ve spent a little while today looking at putting something together for EverNote.  Hopefully I’ll have it finished pretty soon and I’ll probably share it with you when it’s done, but whilst I’ve been experimenting, I’ve also been looking at ENScript a command line utility that allows you to interact with an EverNote database.

The one thing I haven’t yet managed to get to grips with is the use of @filename to create a response file.  I just get “Unknown command” or “Can’t open Database … error FILE_NOT_FOUND”.  Now this may be due to my set-up, but I get the feeling that it may be something else.  The reason I suggest it could be my set-up is because I actually run the portable version of EverNote and unfortunately ENScript is only deployed in the Windows installer.  So I had to copy it from the installation directory of a machine with the Windows version installed.  In any case even without the use of a response file, you can just make multiple calls so I don’t think I’ve lost out on any functionality … but if anyone has worked out how to use this please feel free to add a comment and example to this post.

The documentation for ENScript’s use is found at the command line (using “enscript /?” and “enscript [command] /?“) and I couldn’t find a nice expanded list of the documentation so I used a bit of old school command line work and extracted the full set of help to a note in my EverNote database.

… and just in case you would like to experiment with ENScript, you may find this documentation useful too.

- – - – - – - – - – - – - – - – -

Usage: ENScript <command> [options]
Commands:

createNote     - creates note from the specified file path or url
importNotes    - imports notes from the specified export file
showNotes      - displays specified notes in the Evernote window
printNotes     - prints specified notes from the Evernote window
exportNotes    - exports specified notes into a file
createNotebook – creates a notebook
listNotebooks  - lists specified notebooks to standard output
syncDatabase   - synchronizes database to the service

@filename – specifies response file name containing options one per line. Command line options that follow response file name specification override options specified in the response file.

Usage: ENScript createNote [options]
Options:

/s file – file containing the plain text note contents. If omitted, note contents are read from standard input.
/n notebook – notebook to create the note in. If does not exist, lazy create. If omitted, use default notebook.
/i title – specifies note title. If omitted, note title will be generated automatically.
/t tag – specifies note tag. If tag does not exist, lazy create it. Use multiple /t options to specify multiple tags.
/a filename – specifies file attachment. Use multiple /a options to specify multiple file attachments.
/c dttm – note creation date/time. { “YYYY/MM/DD hh:mm:ss” | filetime }. If omitted, use current time.
/u username – user name if not the same as database file name.
/p password – user password to confirm Evernote service access.
/d database – database file name if user name is not specified.

If both database file name and user name are not specified, last login name is used and if there is none, USERNAME environment variable value is used as a user name.

Usage: ENScript importNotes [options]
Options:

/s {file|url} – source .enex file or url. If omitted, stdin is used to gather source specification.
/n notebook – notebook to create the note in. If does not exist, lazy create. If omitted, use default notebook.
/u username – user name if not the same as database file name.
/p password – user password to confirm Evernote service access.
/d database – database file name if user name is not specified.

If both database file name and user name are not specified, last login name is used and if there is none, USERNAME environment variable value is used as a user name.

Usage: ENScript showNotes [options]
Options:

/q query – query to filter the notes. If omitted, stdin is used to gather query specification.
/u username – user name if not the same as database file name.
/p password – user password to confirm Evernote service access.
/d database – database file name if user name is not specified.

If both database file name and user name are not specified, last login name is used and if there is none, USERNAME environment variable value is used as a user name.

Usage: ENScript printNotes [options]
Options:

/q query – query to filter the notes. If omitted, stdin is used to gather query specification.
/u username – user name if not the same as database file name.
/p password – user password to confirm Evernote service access.
/d database – database file name if user name is not specified.

If both database file name and user name are not specified, last login name is used and if there is none, USERNAME environment variable value is used as a user name.

Usage: ENScript exportNotes [options]
Options:

/q query – query to filter the notes. If omitted, stdin is used to gather query specification.
/f file – export .enex file. If omitted, stdout is used.
/u username – user name if not the same as database file name.
/p password – user password to confirm Evernote service access.
/d database – database file name if user name is not specified.

If both database file name and user name are not specified, last login name is used and if there is none, USERNAME environment variable value is used as a user name.

Usage: ENScript createNotebook [options]
Options:

/n notebook – name of the notebook to create. If omitted, the notebook name is read from standard input.
/t {local|synced} – type of the notebook to create. If omitted, creates a synchronized notebook.
/u username – user name if not the same as database file name.
/p password – user password to confirm Evernote service access.
/d database – database file name if user name is not specified.

If both database file name and user name are not specified, last login name is used and if there is none, USERNAME environment variable value is used as a user name.

Usage: ENScript listNotebooks [options]
Options:

/t {local|synced} – type of the notebooks to list on stdout. If omitted, list all existing notebooks.
/u username – user name if not the same as database file name.
/p password – user password to confirm Evernote service access.
/d database – database file name if user name is not specified.

If both database file name and user name are not specified, last login name is used and if there is none, USERNAME environment variable value is used as a user name.

Usage: ENScript syncDatabase [options]
Options:

/l file name – log file name. Use standard log if omitted. Ignored in GUI implementation.
/u username – user name if not the same as database file name.
/p password – user password to confirm Evernote service access.
/d database – database file name if user name is not specified.

If both database file name and user name are not specified, last login name is used and if there is none, USERNAME environment variable value is used as a user name.

- – - – - – - – - – - – - – - – -

I also noted that as well as the ENScript command line option if you just want a quick and dirty method of adding a note to your default EverNote database you can pass it straight to the EverNote executable as a parameter.  This will add the file (e.g. a text or image file) to your default or currently selected (if you have EverNote open) notebook.

h1

How to Feed Twitter to FeedBurner

20/08/2009

I tried adding my Twitter RSS feed to FeedBurner a little earlier.  Even though FeedValidator identified the feed as valid FeedBurner wouldn’t.  Googling this suggested that either Twitter isn’t producing nice RSS feeds (which FeedValidator’s validation seems to contradict) or FeedBurner has blocked it.

I decided to try passing the RSS feed through another tool.  I considered using Yahoo Pipes, but then decided that the feed aggregator from XFruits would be the quickest way.  I set-up a feed as an aggregation of just a single feed, passed that to FeedBurner and everything now seems to work.

h1

The Little Things

20/08/2009

I’ve just completed a few updates to the RebootIT and FlagIT blogs.  The main thing is I’ve changed the RSS feeds published on the site to got to Feed Burner and I’ve set them up there  to make use of the Pub Sub Hubbub so please consider updating any RSS subscriptions you might have.

h1

Skype and Web Servers

08/08/2009

I briefly had a problem with the web server that’s running my personal wiki yesterday.  Try as I might it just wouldn’t start-up.  I hadn’t had a problem before and after three or four attempts at clicking the start option I took a step back and surveyed my machine – a useful option in many circumstances.

I spotted the culprit straight away as I had come across the issue before – Skype.  When Skype starts up if the default port (51907 on my current instance of Skype) is unavailable (because another application is using it or more likely a firewall is blocking it) it tries to set-up on a port that is more likely to be available – 80 or 443 which are used by web servers for insecure and secure traffic respectively.

Whilst there is an advanced option in Skype to force it away from these two alternative ports often there are no other convenient ones to choose from.  This is because it is good practice security to block unused ports and Skype isn’t always a top runner so to speak on ports to have open.

The moral of the story is simple – start your web server before you start Skype.

However this got me to wondering what else might pick a port that could conflict and how would you know what it was without just systematically working through all the applications and services you have running … which for me could be a large number.  My solution was to use some DOS commands.  NETSTAT can be used to examine what ports are in use by what processes.  TASKLIST can be used then to identify the executable.

To smooth things over a little I’ve concocted a little script to automate this process.  It’s really just a bit of a nicer front end to the whole thing and whilst several command prompt windows may briefly flash up as it runs, the script will take in the information from the commands and process them to filter out the pertinent information.

Option Explicit

Dim objCommandPort
Dim astrResults
Dim astrInfoLine
Dim strOutput
Dim strPortCommand
Dim strPID
Dim strApps

strPortCommand = "netstat -ano" 

set objCommandPort = New clsDOSCommandExecutor

objCommandPort.ExecuteCommand(strPortCommand)
strOutput = objCommandPort.GetOutput
astrResults = split(strOutput, vbCrLf)

strApps = "PORT: APPLICATION" & vbCrLf
AssessPort "80"
strApps = strApps & vbCrLf
AssessPort "443"

MsgBox strApps, vbInformation + vbOKOnly, "Applications using web server ports"

Sub AssessPort(p_strPort)
 Dim intCounter

 For intCounter = 1 to Ubound(astrResults)
 If inStr(astrResults(intCounter), ":" & p_strPort) > 0 Then
 astrInfoLine = split(astrResults(intCounter))
 strPID = astrInfoLine(ubound(astrInfoLine))
 strApps = strApps & vbCrLf & p_strPort & ": " & AppOnPort(strPID)
 End If
 Next
End Sub

Function AppOnPort(p_strPID)
 Dim objCommandPID
 Dim strPIDCommand
 Dim strPIDOut
 Dim astrPIDOut

 set objCommandPID = New clsDOSCommandExecutor
 strPIDCommand = "tasklist /fi ""PID eq " & p_strPID & """"

 objCommandPID.ExecuteCommand(strPIDCommand)

 strPIDOut = Right(objCommandPID.GetOutput, len(objCommandPID.GetOutput) - inStrRev(objCommandPID.GetOutput, "=" & vbcrlf))
 astrPIDOut = split(strPIDOut)

 AppOnPort = Replace(astrPIDout(0), vbCrLf, "")
End Function

Class clsDOSCommandExecutor
 Dim objShell, objExec
 Dim strCommand
 Dim strError
 Dim objError
 Dim objOutput
 Dim strOutput

 Sub ExecuteCommand(p_strCommand)
 strCommand = "cmd /c " & p_strCommand
 Set objShell = CreateObject("Wscript.Shell" )

 objShell.Exec(strCommand)

 Set objExec = objShell.Exec(strCommand)

 Do Until objExec.Status
 Wscript.Sleep 200
 Loop

 Set objError = objExec.StdErr
 strError = objError.ReadAll

 Set objOutput = objExec.stdOut
 strOutput = objOutput.ReadAll
 End Sub

 Function GetOutput()
 GetOutput = strOutput
 End Function

 Function GetError()
 GetError = strError
 End Function

 Function Failed()
 If strError = "" Then
 Failed = false
 Else
 Failed = true
 End If
 End Function
End Class