Wednesday, May 8, 2013
Basketball Tips and Tricks
Greetings everyone, I have launched a new site BasketballTipsAndTricks.com check it out if you are interested in getting better at basketball. More to come soon, thanks!
Friday, November 12, 2010
Automated Testing VS. Unit Testing
I often hear the terms Automated Testing and Unit Testing used in a context that implies that they are one in the same. Lumping these buzz words is misleading and can scare people away from implementing simple automated testing techniques.
Let me describe the two terms with out all the mumbo jumbo and TDD propaganda...
Unit Testing: Testing each part of your code at a granular level.
Automated Testing: Testing by using an automated process that can report success or failure.
Don't assume that to implement automated testing you need to start writing unit tests against all of your code. This is daunting and involves effort, planning, and a shift in paradigm. This is why most development teams shy away from automated tasting. In reality, there are much lower hanging fruit in the automated testing world than unit testing....
Suppose your application is supposed to output 10 folders into C:/web/, each with an html, javascript, and css file within them. So whenever you change your source code, you verify that everything still outputs. So your manually testing your code via something like this:
- Delete C:/web/
- Run your app with correct params
- Open C:/web/
- Verify folders and files exist
- Verify that there is data in the files
This is a fairly tedious test that could easily be automated. JUnit would be a great tool for this (Junit has an unfortunate name because it implies it is only for unit testing.) You could easily create a JUnit test that would do each step for you, and then display green for success or red for failure.
If your not yet doing automated testing, try to think of tasks that you do during development and testing that could be automated, forget about unit testing for now. Check out this article to learn how to create automated tests using JUnit. Like most it focuses on unit testing, but don't get hung up on that.
Monday, October 18, 2010
Removing line breaks in XSLT
I needed to remove the line breaks from my transform output because they were interfering with a 3rd party transform engine. (I could not use normalize-space(.) because I needed to preserve the spacing around mixed content.)
Instead of finding what the carriage return code is (I believe its #xD). I just created the variable $linebreak with the value of an actual linebreak.
The original code:
Updated to remove line breaks:
Utilizes these templates:
This is all possible in XSLT 1.0. If you are using XSLT 2.0 you can use the replace function instead of creating the replace-string template above.
Instead of finding what the carriage return code is (I believe its #xD). I just created the variable $linebreak with the value of an actual linebreak.
The original code:
<xsl:template match="para/text()">
<xsl:value-of select="."/>
</xsl:template>
Updated to remove line breaks:
<xsl:template match="para/text()">
<xsl:call-template name="selectWithoutBreaks"/>
</xsl:template>
Utilizes these templates:
<xsl:template name="selectWithoutBreaks" >
<!-- NOTE: The whitespace between the xsl:text elements is important because it represents the line break -->
<xsl:variable name="linebreak">
<xsl:text>
</xsl:text>
</xsl:variable>
<xsl:call-template name="replace-string">
<xsl:with-param name="text" select="."/>
<xsl:with-param name="replace" select="$linebreak" />
<xsl:with-param name="with" select="''"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="replace-string">
<xsl:param name="text"/>
<xsl:param name="replace"/>
<xsl:param name="with"/>
<xsl:choose>
<xsl:when test="contains($text,$replace)">
<xsl:value-of select="substring-before($text,$replace)"/>
<xsl:value-of select="$with"/>
<xsl:call-template name="replace-string">
<xsl:with-param name="text" select="substring-after($text,$replace)"/>
<xsl:with-param name="replace" select="$replace"/>
<xsl:with-param name="with" select="$with"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
This is all possible in XSLT 1.0. If you are using XSLT 2.0 you can use the replace function instead of creating the replace-string template above.
Monday, October 4, 2010
Great tool for comparing multiple files
I had applied some "hotfixes" to some of our XSLT production code without ever building a new installer. This caused the files in production to get out of sync with what I had in my development environment and in Source safe.
I needed a way to compare multiple files at once because it would of taken forever to go one by one, and I did not want to just guess based on the modified date.
Luckily I found a free tool called KDiff3. I highly recommend this tool, it works just as expected and can potentially save you a lot of time when troubleshooting.

Download it here: http://kdiff3.sourceforge.net/
Does anyone have experience with any other compare tools? After trying KDiff3 I did not bother looking any further because the tool worked so well.
I needed a way to compare multiple files at once because it would of taken forever to go one by one, and I did not want to just guess based on the modified date.
Luckily I found a free tool called KDiff3. I highly recommend this tool, it works just as expected and can potentially save you a lot of time when troubleshooting.

Download it here: http://kdiff3.sourceforge.net/
Does anyone have experience with any other compare tools? After trying KDiff3 I did not bother looking any further because the tool worked so well.
Thursday, August 5, 2010
Remap Capslock to behave as a Control Key
- Open Regedit.exe (Start->Run: regedit or Type regedit in the Windows 7 "Awesome Bar")
- Browse in the Registry Editor to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout

- Click Edit->New->Binary Value and name it "Scancode Map"
- Double click Scancode Map and set the value to:
00,00,00,00, 00,00,00,00, 02,00,00,00, 1d,00,3A,00, 00,00,00,00
Thats it! After restarting your computer your Capslock key will function as a Control key instead.
For a more in depth look at key remapping in Windows please see this How-To-Geek article.
Labels:
Key mapping,
Keyboard layout,
Keyboard usability
Thursday, July 15, 2010
Lifecycle permissions in Documentum "You must be the owner (or superuser)"
I work on a content management system run off of EMC's Documentum. We had a new requirement that users be able to move our modules into different folders.
But every time we tried to move a module, we encountered the following error:
[DM_SYSOBJECT_E_NO_RELATE_ACCESS]error: "No relate access sysobject named 'product_lifecycle'."
I thought... "Why does it care about a lifecycle, I am not modifying the lifecycle, I am just moving the document." But it turns out that the permissions on a lifecycle do not control the permission on the lifecycle itself, they control the permission on the document that it is attached to. So in order to move a document, you must have the write and relate permissions on not only the document's permission set, but also the applied lifecycle.
We did not know this when creating the lifecycle. The lifecycles permissions were much to restrictive. And you cannot edit an installed lifecycle's properties through Webtop. What a pain...
But wait! Have no fear, you do not you do not need to uninstall it and redeploy it with the Documentum Application builder. You can just do the following steps:
You now have the correct permissions on your lifecycle and as long as you have the correct permissions on your documents ACL you will be right as rain.
But every time we tried to move a module, we encountered the following error:
[DM_SYSOBJECT_E_NO_RELATE_ACCESS]error: "No relate access sysobject named 'product_lifecycle'."
I thought... "Why does it care about a lifecycle, I am not modifying the lifecycle, I am just moving the document." But it turns out that the permissions on a lifecycle do not control the permission on the lifecycle itself, they control the permission on the document that it is attached to. So in order to move a document, you must have the write and relate permissions on not only the document's permission set, but also the applied lifecycle.
We did not know this when creating the lifecycle. The lifecycles permissions were much to restrictive. And you cannot edit an installed lifecycle's properties through Webtop. What a pain...
But wait! Have no fear, you do not you do not need to uninstall it and redeploy it with the Documentum Application builder. You can just do the following steps:
- API>uninstall,c,46002af8801037ae
- Now it is uninstalled so update the permissions on the lifecycle easily using the properties->permission screen.
- API>install,c,46002af8801037ae
You now have the correct permissions on your lifecycle and as long as you have the correct permissions on your documents ACL you will be right as rain.
Wednesday, June 9, 2010
Do NOT Use Javascript to Output Content
Javascript is ever increasing in popularity as a tool for web developers. But it can be dangerous.
Reasons for popularity:
- Availability of great javascript libraries.
- Increasing popularity and new uses for AJAX.
- Increasing user acceptance.
- Increasing browser support.
- HTML5 and lack of support for Flash on iPhone/iPad
Overall, javascript is fantastic. It can provide users with a richer, cleaner, and more responsive experience, while saving resources on the web server.
But because it has become so easy to use javascript, developers are using it for something that it should not be used for: outputting content.
So you might be thinking...
"Why does it matter how we output our web content? It looks the same to the user as long as they have javascript turned on, and this is 2010 who doesn't enable javascript in their browser?!?!"
Well, the most important user in the world Mr. Gle does not use javascript. First name Goo by the way.
So your website looks beautiful, you have your wonderfull content on your 6 dozen pages that you worked so hard on. All of them have great headings and title tags and you followed all the other advice you found about SEO. But guess what, thats not what Mr. Gle sees. He sees 72 pages of spam. This is because for all Mr. Gle knows (Google if you haven't gotten it yet) you have created 72 identical pages and repurposed their titles to try and hit more direct keywords. An SEO spam tactic that is similar, but worse than what Jason Calacanis and his guys at Mahalo got in trouble for.
I know its tempting to use an AJAX call to output some database content onto a silver plate for your users. But you must not do so. All content on web pages should be static html that is generated on the server side.
Don't feel bad if you made this mistake because we did the same thing for our startup project Nofouls.com. Our area feed messages are all output by javascript, so Google does not give a &!#@ about them. Therefor all of our city pages (we have about 100) look almost exactly the same to Google. (Sorry Google we are not trying to be evil!)
Sure the content looks decent. But its output by javascript so it really hurts our image in Google's eyes.
In conclusion, just remember that just because javascript may be an easy and clean way to output your content, it is never the right choice.
Friday, October 30, 2009
FTP Issue: LPX-00200: could not convert from encoding UTF-8 to UCS2
I have an application that uploads XML files into an Oracle XML DB Repository. It was workinging succesfully on all documents except a few would fail...
My application would report the error:
FTPConnection closed
And in my Oracle logs I could see this error:
LPX-00200: could not convert from encoding UTF-8 to UCS2
My application would report the error:
FTPConnection closed
And in my Oracle logs I could see this error:
LPX-00200: could not convert from encoding UTF-8 to UCS2
I looked at the failing XML documents and noticed that they all had curly quotes in them. If I took them out, the file would upload.
The issue was that I needed to FTP as Binary and not as Text.
I was using the Java libarary FTPClient (it.sauronsoftware.ftp4j.FTPClient) and needed to set this command:
FTPClient .setType(FTPClient.TYPE_BINARY);
So just remember to use Binary mode when uploading to an Oracle XML DB Repository.
Thursday, October 1, 2009
Get the version number of an IDfSysObject in Documentum using DFC
I was in a situation where I needed to get the version number of a document. Such as 1.0 or 2.6 etc...
Unfortunately Documentum only provides a repeating attribute called r_version_label. This attribute can contain other values such as CURRENT or other user entered values.
But the important thing to note is that Documentum always stores the version number in the first r_version_label value.
Based on this assumption you can retrieve the version number from an IDfSysObject using the following ...
Hope this is helpful.
Unfortunately Documentum only provides a repeating attribute called r_version_label. This attribute can contain other values such as CURRENT or other user entered values.
But the important thing to note is that Documentum always stores the version number in the first r_version_label value.
Based on this assumption you can retrieve the version number from an IDfSysObject using the following ...
IDfSysObject.getRepeatingString("r_version_label", 0);
Hope this is helpful.
Thursday, April 23, 2009
Which is better for advertisers? MySpace or Facebook?
.jpg)
I had been using Facebook for a while... It has a minimum bid of 10 cents. I was able to get a dozen or so hits a day with 15 cents as my maximum bid.
Myspace started getting me a couple dozen clicks a day, while my Facebook clicks skyrocketed and hit my $25 daily limit for a week straight. Financing this out of my pocket money, I cannot afford $25 dollars a day so I had to lower my bid back down.
...This leaving me with the conclussion that MySpace advertising is a waste of money. At least looking at the cost per click. MySpace does show your ad in a big banner though. This works for increasing brand awareness for a company such as Coke, or for a new movie. But for a startup like NoFouls.com, there is no value in showing an ad if the user is not going to visit your site.
So MySpace is a terrible place for startup advertising, Facebook eh... not so bad.
Tuesday, March 17, 2009
How to combine 2 string arrays in java 1.4
/**
* Combines two string array's into one.
*
* @param first The first strings
* @param second The second strings
* @return The result will be a new String[] with the first array items,
* with the second array items appended
*
*
*/
private String[] combineStringArrays(String[] first, String[] second) {
int total = first.length + second.length;
String[] strings = new String[total];
for (int i = 0; i < first.length; i++){
strings[i] = first[i];
}
for (int i = 0; i < second.length; i++){
strings[first.length + i] = second[i];
}
return strings;
}
Wednesday, December 17, 2008
wix - It must use a registry key under HKCU as its KeyPath, not a file.
Took me a few minutes to figure out my problem with this error in wix: It must use a registry key under HKCU as its KeyPath, not a file.
This is what it needed to be:
My original code:
<Directory Id="AppDataFolder" Name="AppDataFolder">
<Directory Id="MyAppFolder" Name="My">
<Component Id="MyComponent" Guid="cc509cb7-c1a1-46cf-8c62-7cbb0017783c">
<File Id="test1.txt" Name="test1.txt" KeyPath="yes" Source="Files\test1.txt" />
</Component>
</Directory>
</Directory>
<Directory Id="MyAppFolder" Name="My">
<Component Id="MyComponent" Guid="cc509cb7-c1a1-46cf-8c62-7cbb0017783c">
<File Id="test1.txt" Name="test1.txt" KeyPath="yes" Source="Files\test1.txt" />
</Component>
</Directory>
</Directory>
This is what it needed to be:
<Directory Id="AppDataFolder" Name="AppDataFolder">
<Directory Id="MyAppFolder" Name="My">
<Component Id="MyComponent" Guid="cc509cb7-c1a1-46cf-8c62-7cbb0017783c">
<RegistryKey Action="none" Key="myKeyName" Root="HKCU" >
<RegistryValue Type="integer" Value="1" KeyPath="yes" />
</RegistryKey>
<File Id="test1.txt" Name="test1.txt" KeyPath="yes" Source="Files\test1.txt" />
</Component>
</Directory>
</Directory>
<Directory Id="MyAppFolder" Name="My">
<Component Id="MyComponent" Guid="cc509cb7-c1a1-46cf-8c62-7cbb0017783c">
<RegistryKey Action="none" Key="myKeyName" Root="HKCU" >
<RegistryValue Type="integer" Value="1" KeyPath="yes" />
</RegistryKey>
<File Id="test1.txt" Name="test1.txt" KeyPath="yes" Source="Files\test1.txt" />
</Component>
</Directory>
</Directory>
Monday, October 13, 2008
Good Technology Podcasts
Podcasts are an important part of developing as a developer.
Recently I have been listening to:
StackOverFlow
TWiT
Herding Code
SE Radio
.Net Rocks
There are a lot more good recomendations at this post:
Wednesday, September 17, 2008
Google Analytics Sucks!

Before I go on, I must say that I use Analytics every day, and it is by far the best tool I have found for monitoring site traffic.
The problem, though, is it does not let you get down to the nitty gritty details about a specific user. For example you could not find out what user, from what region, from what referring site, hit what content. You can find out all this information about groups of users, but not at the same time. I am guessing for privacy reasons (same reason you cannot obtain the IP). This becomes limiting quickly for me.
Maybe all this information is mute once you have hits in the thoasands per day, but when you are getting an average of one signup per day the individual user details are still very interesting and useful.
Maybe all this information is mute once you have hits in the thoasands per day, but when you are getting an average of one signup per day the individual user details are still very interesting and useful.
How to log the referring site
My web startup was deployed in June... It took me until this week to realize I should be recording the referring site for every signup. And no... Google Analytics is not a good solution for this.
The client side code goes something like this:
So now, instead of knowing where I get the most hits from, I know where I get the most account creations from, which is what really matters.
Anyone know of any other super valuable info to record?
The client side code goes something like this:
<form>
<input onfocus="javascript:document.getElementById('referringSite').value=document.referrer"
name="email" />
<!-- or with jquery: -->
<!-- <input onfocus="javascript:$('#referringSite').val(document.referrer);" name="email" />-->
Choose Password
<input type="password" name="password" value="" />
<input type="hidden" name="referringSite" value="" id="referringSite" />
<input name="submit" type="submit" value="Sign up!" />
</form>
So now, instead of knowing where I get the most hits from, I know where I get the most account creations from, which is what really matters.
Anyone know of any other super valuable info to record?
Labels:
data recording,
referring site,
user logging
Friday, August 22, 2008
Clipboard caching utilities
Over the past year or so, I have become dependent upon clipboard caching utilities. These are programs that run in the background that keep track of EVERYTHING copied (ctr-c). I wonder why this functionality is not built into any mainstream operating system. Maybe because Clippy ("one of the worst software design blunders in the annals of computing" -Smithsonian Magazine) was our first taste of clipboard caching.I have been using CLCL which has been working fairly well for me. I have its cache limit set at 100 copies, which goes back a few days (which is suprising for how much I copy!).
But lately my copy function will randomly stop working until I restart. Which brings up two questions I have.
- Does anyone know if this is related to CLCL?
- If so, does the restarting every couple days diminish the productivity gained via the utility?
Labels:
clcl,
Clipboard caching utilities
Monday, August 4, 2008
XSLT example template that returns boolean
In XSLT you can create templates that act as boolean functions.
<xsl:template match="/">
<!-- create variable named cat to store boolean value -->
<xsl:variable name="cat">
<xsl:call-template name="HasCat"/>
</xsl:variable>
<xsl:when test="$cat= 'true'" >
<!-- do something because it has a child element named cat -->
</xsl:when>
</xsl:template>
<xsl:template name="HasCat">
<xsl:choose>
<xsl:when test="count(descendant-or-self::*[contains(local-name(), 'Cat')]) > 0">
<xsl:value-of select="true()"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="false()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Monday, July 14, 2008
What is fully-qualified class name
When people use the term fully-qualified class name in the Java world, they mean the class name with its package name prepended.
For example if I had the class HelloWorld:
Class: HelloWorld
Package: com.blogger.nofoe
Fully-qualified name: com.blogger.nofoe.HelloWorld
Note: The naming convention for packages in java goes {domain extension}.{domain name}.{project name}
For example if I had the class HelloWorld:
Class: HelloWorld
Package: com.blogger.nofoe
Fully-qualified name: com.blogger.nofoe.HelloWorld
Note: The naming convention for packages in java goes {domain extension}.{domain name}.{project name}
java main print out args - snippet
Code to print out all arguments being passed to the main method:
public static void main(String[] args) {
//print out arguments
for (int i = 0; i < args.length; i++) {
System.out.print("args["+i+"]: " + args[i] + "\n");
}
}
Monday, June 23, 2008
How to set a document to its next major version using DFC
The code below overrides DfDocument.doCheckin in my TBO (Type Based Object). The method sets the document to its next major version when it is promoted to lifecycle state Final.
protected void doPromote(String state, boolean override, boolean fTestOnly, Object[] extArgs ) throws DfException {If the code above is not flexible enough... Below is the example from Documentum that uses operations to set the document to the next major version by overriding DfDocument.doCheckin.
super.doPromote(state, override, fTestOnly, extArgs);
if (this.getCurrentStateName().equals("Final")){
if(this.isCheckedOut() == true){
throw new DfException("Cannot version if object is checked out.");
}
String newMajorVersion = this.getVersionPolicy().getNextMajorLabel();
this.mark(newMajorVersion);
this.save();
}
}
public static void doCheckin( String strPath, IDfSession session ) throws DfException {
IDfClientX clientx = new DfClientX();
IDfCheckinOperation operation = clientx.getCheckinOperation();
IDfSysObject sysObj = (IDfSysObject) session.getObjectByPath( strPath );
if( sysObj == null ) {
System.out.println("Object " + strPath + " can not be found.");
return;
}
if (sysObj.isCheckedOut() == false) {
System.out.println("Object " + strPath + " is not checked out.");
return;
}
IDfCheckinNode node;
if( sysObj.isVirtualDocument() ) {
IDfVirtualDocument vDoc = sysObj.asVirtualDocument( "CURRENT", false );
node = (IDfCheckinNode)operation.add(vDoc);
} else {
node = (IDfCheckinNode)operation.add(sysObj);
}
//Other options for setCheckinVersion: VERSION_NOT_SET, NEXT_MAJOR,
// NEXT_MINOR, BRANCH_VERSION
operation.setCheckinVersion(IDfCheckinOperation.NEXT_MAJOR);
operation.execute();
}
Subscribe to:
Posts (Atom)

