Category Archives: Reference - Page 2

Configuring LDAP with TWiki

I’m currently trying to get a knowledge base set up at my place of work.  Initially, I had used 68kb to set it up.  It was fantastic to work with (especially after installing TinyMCE as a plug in) but it had no access control or authentication, so management asked I look into alternatives with those features.  I found TWiki and set it up with LDAP / AD (Active Directory) authentication.  Since the documentation wasn’t helping me, I wrote some of my own in case anyone else needs some help, or if I would need to do it again.

Read more »

Lockup when using Nawcom’s Mod CD / Empire EFI / iBoot

I’m in the process of making my machine dual boot Windows 7 and OSX.  I was having some trouble getting the Nawcom Mod CD to do anything other than freeze.  Pressing F5 crashes the installer, as does selecting a device to boot from.   This is an issue stemming from the Empire EFI swap CD they’re working from, as several variations were showing the same behavior.

The disc started working normally once I disabled two extra JMicron SATA controllers integrated into my motherboard, as well as my unused IDE controller.  I’m guessing that there is a driver missing from the boot CD that makes it unable to handle those JMicron controllers.  I haven’t had the chance to cycle through each one to see if a specifc one is causing it, or if it’s just the IDE or just the JMicrons.

In any case, if someone else has this issue hopefully they will stumble across this post.  Now to figure out why I’m getting a Kernel Panic before I even see the install screen…

Fast output into TextArea

Note: The example here has been written in VBScript, but the principles should apply to JavaScript as well.

While I was working on the KML generator for work, I wanted a text log to show errors if they came up.  The information wasn’t important enough to save to a file, but it needed to be displayed to the user.  However, as the HTA would go through data, the speed at which the log file would update would become slower and slower, eventually appearing to lock up.  Considering it was dealing with approx. 500kb across three CSV files, this was not acceptable.

Here is a simplified version of the HTA script:

<HEAD>
  <TITLE>KML Generator</TITLE>
  {Omitted}
</HEAD>
<SCRIPT LANGUAGE="VBScript">
Do Until (conditions)
  {Code}
  realTimeOutput.value = realtimeinfo.value & "Message. " & vbCrLf
  Loop
</SCRIPT>
<BODY>
   <textarea id="realTimeOutput" readonly>Waiting for data.</textarea>
</BODY>

The code in red is fine for a quick addition, but terrible for fast successive additions to the textarea.  The content of the textarea was being copied, the addition appended, then the entire value was being written back in.  So, after several searches and attempting other re-workings of that same idea, I found this method of doing it:

realTimeOutput.appendChild(document.createtextnode("Message" & vbCrLf))

In this case everything (except vbCrLf) is carried out via DOM functions, allowing the text to be appended into the textarea without copying everything already in there.  The speed difference was very apparent, as what would come to a near-lockup was now instant.  It seems unusual to create a new text node just to add text, but it’s the only way to update the textarea via the DOM.  In a more memory-sensitive environment, you could assign the node to a variable and null it out as needed. But honestly, at that point I’d ask why VBScript is still being used.

Norton Ghost, Virtual Machines, and weird MBRs.

So, here is something to show you, a physical laptop backup restored into a VirtualBox machine:

Laptop Running in VM

Laptop running in VM

I’m doing this for work, and while it was a fun “just to do it” project, it also served the purpose of testing the backup, and giving us a place to test fixes and (as shown) attempting upgrades.

Ultimately, the backup was done with Norton Ghost 15.0.  I was really hoping to be able to do it with CloneZilla, saving some cash and using Open Source software.  However, no matter what options I entered in that software, it could not restore into the VM. At first I thought it was just the difficulties of moving an OS to another machine. But trying fixes from MergeIDE to UBCD4Win’s Fix IDE / Fix HDC to no avail, it was something else.  I was seeing that there was something detected on the drive – no “Operating System Not Found” error - but it clearly wasn’t loading the OS. 

The fact that this laptop was registering as having 5 partitions, one of which was without a file system, and the other labeled as “DOS” told me that there may be an abnormal MBR structure or partition table in there 😉

When we moved to Ghost, I was seeing the same errors.  Fortunately, Ghost has some extra utilities on their live CD, allowing me to save the MBR and Partition Table separately:

Extra Options in Norton Ghost

Ghost Options

After saving and restoring the MBR and Partition Tables manually, the image booted without issue in the Virtual Machine.  What strikes me as strange is that CloneZilla will back up the MBR and partition table automatically.  This issue shouldn’t have come up with CloneZilla if it’s working as it is supposed to.  I may have to look into that later if I get the time.

If I was looking to do a straight physical to virtual conversion, there are much better options to use.  Disk2Vhd would be one of them, as @CC_DKP pointed out on Twitter.  But the purpose here was just to test a backup, so I was working from a regular backup, not a VHD file.

One last note about Ghost:  While I like 15.0, I can’t recommend it for legacy hardware.  The only reason I got it to work with this laptop is because we installed more RAM.  Worth it?  Completely.  But if the laptop couldn’t take the upgrade we would’ve been dead in the water.

Setting Network Type for Hamachi Connections

Recently ran into an issue with Hamachi / Windows 7 where I couldn’t set the Network Type for the Hamachi connection.  I use Windows Firewall, and wanted to specify the Hamachi network as “Home.”  However, the normal option to change network type wasn’t there in Network and Sharing Center.  It just said “Unidentified Network” with blank space underneath:

Network and Sharing Center - Before

It turns out, Windows 7 (and I assume Vista) will do this when there is no Default Gateway set up on the network.  For Hamachi, this can be set to the same address as their DHCP server: 5.0.0.1.  To avoid having to manually enter an address, this should be entered separately in the Advanced TCP / IP settings window:

Advanced TCP / IP settings window

That window is accessible through the “Advanced” button where you would normally set a static IP address.  After that, the option was available, and the network was no longer listed as unidentified:

Network Sharing Center - After

Just another reference post.  Hope this is useful!

Sources:

http://www.tomshardware.com/forum/215-63-change-network-type
http://windows7forums.com/windows-7-networking/4416-how-change-network-type-2.html#post21820

Changing WordPress Title Formats

I fixed the title formats on here today.  Not especially noteworthy, but I wanted to make a small post about it for my own reference.

So, the change I wanted to make was to make John-AM.com appear after the post title.  In this theme’s header.php, there is a line like this:

<title><?php bloginfo('name'); ?><?php wp_title(); ?></title>

I swapped the postition of wp_title and bloginfo(‘name’), but then I had the separator (») at the beginning of the title.  Well, it turns out wp_title will take whatever you put into it, and append it to the title.  If nothing is passed, it automatically uses ».  So I changed that, and you can choose the location where it is appended.  So, here is mine:

<?php wp_title(' | ',true,'right'); ?>

Which puts a nice | between the title name and my blog name, which is now after the post name.

Netgear WNR2000 – A Common Favorite

A few weeks ago I was asked to set up a Wireless link for my Dad’s business in Sabula, IA.  DD-WRT on a pair of consumer grade routers seemed like a good fit, as the link only crossed a street, and the business really isn’t big enough to warrant more expensive hardware.

So the morning of I got online to find out what was available, and what would work with DD-WRT.  And while it isn’t perfect, I really liked the Netgear WNR2000(V2).  It was available at my local Best Buy for $70, and with the Broadcom chipset and 32mb (!) of RAM it really was a no brainer.  The single downside is that it doesn’t have enough flash to support a standard DD-WRT installation.  It has 4MB which should be enough, but forum posts say otherwise.  The closest you can get is the standard image minus the Kaid software.  Also, there is a firmware package available for this router, so the upgrade can be performed from the stock web interface.

I was able to use it to set up the wireless link without issue, and without optimal router placement either.  The two routers have several walls between them, on top of going out one building and into the other.  Through all that, the connection was rock solid.  Bandwidth tests on the far end were giving me the full speed of the Internet connection.

So the WNR2000 is a nice router, but the important part is that it’s a common router.  Given the choice, I’d rather buy a Buffalo WZR-HP-G300NH or WHR-HP-G300N.  But they’re not available locally and I didn’t have the time to order them.  But from now on if I’m in a scenario where I need a router quickly, I can turn to the WNR2000.

Making Circles in Google Charts – Undocumented Chart Types for Google Charts

So it looks like the Google Charts API has a couple of small undocumented charts in it!

There isn’t anything I can find about this written elsewhere, so here is my personal documentation for it.  The information here has been distilled from the MarkerIconCreator webpage. Where you can play with these chart types to have the URLs created for you.  I had to look all of this up for the KML generator I mentioned a few posts ago.

Circle (chart type it): Circle Example - With "X" in the middle.

Parameters: cht=it&chs=32×32&chco=FF0000,000000ff,ffffff01&chl=X&chx=FFFFFF,0&chf=bg,s,00000000

The important part to note is cht=it.  That chart type is not documented in the Google Charts API. 

Rounded Rectangle (chart type itr): Rounded Rectangle

Parameters: cht=itr&chs=32×32&chco=FF0000,000000ff,ffffff01&chl=X&chx=FFFFFF,0&chf=bg,s,00000000

Again, note cht=itr.

There are some other parts in both URLs  which are different from the documentation in how they’re used.  It’s not too hard to figure out via trial and error; but here are some quick explanations:

Color: chco=FF0000,000000ff,ffffff00

The API shows chco as series color, but it’s used a little bit differently for this chart type.  The first color is your shape color.  The second is your first shadow color, and the third is your background-shadow color.  These are regular hexidecimal colors, but with an added byte of values on the end to represent transparency.  If you are using this in a KML file, I recommend setting both shadow colors to 00.

Here are some examples with chco=00FF00,FF0000ff,0000ffAA: chco=00FF00,FF0000ff,0000ffAA chco=00FF00,FF0000ff,0000ffAA

Label Color: chx=FFFFFF

Chx doesn’t exsit on its own in the API. Other forms do, like chxt, chxr, etc.  It is the color for the label text.  It also supports adding an extra byte at the end for transparency.

Here are some examples with chx=00FFFF: Label Color Examplechx=00FFFF

Background color (gradient?): chf=bg,s,00000000

Chf is listed in the official documentation as a fill option.  Only the solid variety works here.  Then the coloring is the same Hex + transparency we’ve seen above. 

Here are the examples, chf=bg,s,00AA00FF: chf=bg,s,00AA00FF chf=bg,s,00AA00FF

Building a self-contained HTA with embedded Images and Icons.

I’m working on an HTA to generate KML files from a given CSV.  I’ve set a goal for myself to keep everything contained in the one HTA file.  Being HTML / CSS and VBScript, this is easy for the most part.  Images and icons are a little harder though. But not impossible!

For images, look at Data URI schemes.  I’ll borrow Wikipedia’s example here:

<img src="data:image/png;base64,
iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGP
C/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IA
AAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1J
REFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jq
ch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0
vr4MkhoXe0rZigAAAABJRU5ErkJggg==" alt="Red dot" />

It’s a bit longer than the usual <img src=”image.png” alt=”Image”> tag. But it allows for images in an HTA without additional files.  The way it works is by taking the file you want to embed, and converting it to Base64.  There are several online tools to do this, but I’ve been using this command line utility for the sake of bandwidth.

Once you have the blob of Base64 data, start an image tag with the src attribute set to “data:image/png;base64,” and append the data afterward.  The first part is needed to tell the browser what the image type is, and the encoding.  The image type doesn’t need to be PNG, any type can be used as long as the MIME type is changed accordingly.  Data URI’s work for most media types, so other things besides images can be embedded this way.

Note that because HTAs are rendered in IE, you’ll need to be aware of your target audience for this to work.  IE8 only supports data URIs up to 32KB.  IE7 and IE6 compatibility is not there, although it may be possible through this MHTML /CSS hack.  I’ll have to test it once my HTA is ready to go.

Now for Icons.  I found this piece of information on the MSDN page for the HTA Icon property.  The solution is to use the copy command, which will append the icon data onto the front of the HTA.  Before the HTML starts.

First, add this line to your HTA to specify the icon. If you have an hta: application tag already, you can add the “icon=”#”” line to it:

<hta:application icon="#">

Then, open a command prompt, and use this command, substituting the appropriate names:

copy icon.ico /b /y +original.hta originalWithIcon.hta

The + before original.hta tells the copy command to append that file onto the file being copied. With originalWithIcon.hta being the output file. /b tells copy that icon.ico is a binary file. And /y just suppresses the overwrite messages.

At this point, if you open the new HTA in a text editor you’ll see some unreadable characters before the HTML starts. That is the icon data.  With that embedded, the icon will now appear in your system tray when you run the file.  Unfortunately (at least on Windows XP) it doesn’t show up in Explorer.

Now you have an HTA with embedded images and Icons!