It is my space, but better than myspace


NetBeans 8 Navigator Empty or Blank When viewing Drupal PHP Files

It was exciting to see NetBeans 8 released as I use it as my primary editor for PHP projects (along with Xdebug of course) but the excitement was short lived when the navigator window frame was empty for all of my Drupal project files. After a bit of googling and checking the NetBeans bug tracker I wasn't getting anywhere until I tried one last ditch generic search on Google which held the answer.

According to this blog posting it was discovered that the .install and .module files lose their content type and aren't parsed as PHP files. A simple configuration change to set the correct content type fixes the issue. Wonderful!

Filed under: Programming, Tech No Comments

Create a Bookmark that Always Points to Today’s Freshbooks Timesheet

Do you want to access your freshbooks timesheet with as few clicks as possible? The directions below walk you through creating a dynamic JavaScript based bookmark that will always point to todays Freshbooks timesheet by calculating the correct URL to go to.

Creating such a link on your browser's bookmark bar or favorites list can be a time saving step for quickly logging in and recording your time.  To create the link follow these steps:

  1. Locate your Freshbooks domain by logging into Freshbooks account and looking at the address bar. The highlighted text in the image below indicates where your freshbooks domain is located in the URL.finding your freshbooks domain
  2. Copy the text below. This is the dynamic JavaScript URL which will always point to your Freshbooks timesheet:
    javascript: var dt = new Date();var d=dt.getDate();var m=dt.getMonth()+1;var y=dt.getFullYear();window.location=''+y+ "-" + (m<=9 ? '0' + m : m) + "-" + (d <= 9 ? '0' + d : d);
  3. Right click on the bookmark bar and create a new bookmark.
  4. Paste the text into the bookmark URL field:creating freshbooks timesheet bookmark
  5. Before saving the bookmark you must change the URL text "YOURFRESHBOOKSDOMAIN" with the Freshbooks domain found in step one. For example, if your domain was "mycoolcorpinc" the URL should read:
    javascript: var dt = new Date();var d=dt.getDate();var m=dt.getMonth()+1;var y=dt.getFullYear();window.location=''+y+ "-" + (m<=9 ? '0' + m : m) + "-" + (d <= 9 ? '0' + d : d);
  6. Save the bookmark. You should now have a bookmark link or favorite that points you to the current day timesheet.

Click on the new bookmark and the browser will direct you to your freshbooks account and compute the current date of the timesheet to display. Your address should resemble the image below except 'yourfreshbooksdomain' will be replaced with your domain i.e. mycoolcorpinc and the date on the end of the URL will be today's date.

freshbooks timesheet url example



Filed under: Programming, Tech No Comments

Coding Tips from Writing Code that isn’t Needed YouTube Video

The above video,Three Flaws in Software Design - Part 1: Writing Code that isn't Needed, was a bit long considering the content presented but there were two ideas worth sharing:

  1. Let the version control system worry about tracking dead code. I've worked in plenty of programs with code that I've been tempted to bypass because it was suspected dead code. Removing the suspected dead code might not cause the customers testing to fail but customers don't always test their own requirements properly. Without the old code it becomes difficult to track how the program once functions unless you use a version control system. Whats worse than trying to avoid making dead code? Working around mysterious code from a long departed coder, unsure if it's still relevant, while trying to make my own logic clear among rotting bits.
  2. Establish when functions can assume variables are well formatted and note them in the function documentation. It's so easy to start coding away, checking for possible conditions that might have been checked closer to the user input. It's painfully agonizing trying to return a high level validation failure from a very low level function.

If the addition videos in the series contain any pearls of wisdom they'll get posted here.

Filed under: Programming No Comments

International Spectrum Article

The company I work with contributes to International Spectrum. The publication serves the multi-value database community with news and new technologies. It was my pleasure to contribute an article. The second part of the two-part article was recently featured in the publication.

The article demonstrates how BASIC-like languages can be extended using the object oriented programming (OOP) concept of encapsulation to protect private variables. The article covers benefits and provides examples of how these modern concepts can further benefit non-OOP languages.

First part

Second part

The entire magazine is available for PDF download. No registration required.

Filed under: Programming No Comments

Loading Specific Versions of .NET Assemblies From the GAC Based on the Assembly Information in a .NET DLL – Visual Basic Example Code

By default the latest version of an assembly is loaded from the GAC (Global Assembly Cache) when the assembly is instantiated. While working on a side project the need arose to load older versions of the assembly without hard coding the assembly versions. The answer, load the existing assembly library from the assembly DLL and interrogate it to find the assembly information. Then ask the GAC to provide a handle to the specific object. The result allows multiple versions of the same assembly to be loaded loaded at the same time.

The Visual Basic .NET example code below loads SampleAppV1\DotNetLibrary.DLL and AnotherSampleAppV2\DotNetLibrary.DLL which are different versions of the same assembly.

'Load assembly using reflection from the file specified so we can get information about it
Dim DLLAssemblyInfo As System.Reflection.Assembly
DLLAssemblyInfo = System.Reflection.Assembly.LoadFrom("\\\\\\SampleAppV1\\DotNetLibrary.DLL")

'Now load the assembly from the GAC using the information in the file. 
Dim GACDLL As System.Reflection.Assembly
GACDLL = System.Reflection.Assembly.Load(AssemblyInfo.FullName, DLLAssemblyInfo.Evidence)
'Load the second version of the same assembly from the newer application
Dim DLLAssemblyInfoV2 As System.Reflection.Assembly
DLLAssemblyInfoV2 = System.Reflection.Assembly.LoadFrom("\\\\\\AnotherSampleAppV2\\DotNetLibrary.DLL")
'Again, use the DLL information from the assembly file to load the assembly from the GAC
Dim GACDLLv2 As System.Reflection.Assembly
GACDLLv2 = System.Reflection.Assembly.Load(AssemblyInfoV2.FullName, DLLAssemblyInfoV2.Evidence)
'At this point in the code we have references to both assemblies loaded from the GAC. The next step is to instantiate an object from each of the references.
'Get an MyAssembly.Library from the old version and run the version method
Dim GACDLLType As Type = GACDLL.GetType("MyAssembly.Library")
Dim MyLibV1 As Object = Activator.CreateInstance(GACDLLType)
Dim v1 As String
v1 = MyLibV1.Version
'Finally, do the same and get the new MyAssembly.Library
Dim GACDLLTypeV2 As Type = GACDLLV2.GetType("MyAssembly.Library")
Dim MyLibV2 As Object = Activator.CreateInstance(GACDLLTypeV2)
Dim v2 As String
v2 = MyLibV2.Version

The variables v1 and v2 were both retrieved from the MyAssembly.Library.Version() method but the variables will not contain the same value because different versions of the assembly were loaded from the GAC during the System.Reflection.Assembly.Load() call.

Why not just load the assembly from each of the DLL files instead of the GAC? Security restrictions prevented untrusted assemblies from being loaded over the network. A possible work around would be to trust the network location or sign the assemblies and trust the signer but that remains for another posting.

Filed under: Programming, Tech No Comments