Monday, November 7, 2011

Associating execution of Powershell scripts with the default open action in Windows 7

I've been using Powershell a bit lately and finally got to the point where I'm using it so much I want to be able to simply double click on a *.ps1 script file and have Powershell execute it.  So, in the interest of creating an internet based reference that I can Google myself when I forget this:


*** Note:  Always backup your registry before editing it unless you really like rebuilding things ***

Basically you need to create a default value inside the registry key (if the sequence of keys doesn't exist, create them):

     HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command

Leave the value with the name '(Default)', make it of type REG_SZ, and set the data to:

     \system32\WindowsPowerShell\v1.0\powershell.exe -command "& '%1' "

Where "" is the location of your Windows directory.


The sequence "& '%1' " is important.

BTW, I highly recommend that you make sure your Powershell script execution settings are set to require remote scripts to be signed properly.

Monday, August 15, 2011

When your favorite Firefox extension gets 'obsoleted' on you...

...you can sometimes get around waiting for the developer of the extension to update it for whatever version of FF you're currently on.

Often, the extension will have an attribute specifying the greatest version of Firefox that it can be used on.  This is, of course, a safety mechanism to avoid having a new version of Firefox break the extension and everyone start screaming at the extension developer (which is always a stupid thing to do irrespective of your reasoning) about how their extension is crap/broken/stupid/et cetera.

I have a Firefox extension that I dearly love and for the past few weeks, since I let Firefox update me to version 6.0.* I have been without it.  I ***NEED*** my Morning Coffee I tell you.

So, finally getting my lazy a**, I decided to look into this and found a version attribute in the extensions install.rdf file that limited it to 4.0.*.  I changed that to 8.0.*, and then started up Firefox and voila - lo and behold morning coffee is on.  Thank you God (and Shane Liesegang.)

So, to do this yourself:

1.  Find your morning coffee add-on, or download it (it should be a file ending in *.XPI)

2.  Unzip it (it is basically a zipped folder)

3.  Edit the install.rdf file, changing maxVersion to 8.0.* (or some value matching your current Firefox version or higher (mine says em:maxVersion="8.0.*")

4.  Recompress the folder (make sure you are inside the unzipped folder and select all of the items in the root of the directory because many archiving utilities create an extra folder to store your zipped content in when the compress)

5.  Change the file extension, if necessary, to *.XIP as this is the default extension extension *chuckle* - your honor, your honor...

Sunday, May 29, 2011

Did this about 3 months back - Chepe's Monster Burrito Challenge

If you eat it, in any period of time you can muster, you get a t-shirt.  Trust me, the t-shirt is NOT worth the effort of eating this behemoth.

By the way, in the picture, her arm is nearly touching the back of the burrito - it isn't a trick of perspective.  The thing weighs (supposedly) more than 6 pounds.


The only good things are that it is very tasty (for the first 70 bites or so) and it is cheap - only around $15 if I recall correctly.

I will not be doing this ever again.

Friday, May 20, 2011

F**$#&% Java Policy Files

If you have ever had to modify a policy file, let me warn you of a wrinkle that you may run into IF your applet/java code needs to perform an operation that is authorized by the policy file BUT IS CALLED VIA JavaScript.

Guess what folks?  Java doesn't trust JavaScript any more (and hasn't intermittently over the past 5 years or so - sometimes trusting, sometimes not) so just because you gave your code a valid policy file grant, any code triggered via JavaScript will run as if being run outside the Java codebase (which in a way it is.)  This means that you have two options, one of which is not palatable, and the other can break backwards compatibility in your codebase.

(1)Grant permissions without using the codebase attribute (this is very very bad as your permission change will therefore grant the same permissions to ANY applet that the user runs into.)

(2)Surround the code that needs permissions privileges (and can be called via JavaScript) with a doPrivileged block.  The downside to this is that early versions of Java don't support this functionality; ergo you are (probably) forced to go the trusted/signed applet route (not good for many reasons.)

Luckily for me, I only need this functionality inside of a tool that is hosting my Java code, so I can put the non 1.1.8 jdk compliant code in my dynamically loaded adapter class that only ships with the offline tool.

Anyhow, I hope someone else trying to figure this out learns from this.

If your applet needs policy file permissions and your applet will be called from javascript, you must not only grant the applet the permissions in the appropriate fashion but also surround the code that can be triggered via JavaScript with a doPriveleged block.  This is because Java's runtime no longer executes javascript with the permissions levels of the applet.

Wednesday, April 27, 2011

Skeletal Animation – An overview


I have been meaning to write a series of blog entries around the basics of skeletal animation for a while now but have been unfortunately too busy to do so – until now, so let’s put our learning hats on!

When you need to animate a 3D object in a game or simulation there are 3 primary ways to accomplish the task:

(1)Hierarchical object animation using keyframes
(2)Vertex Animation
(3)Skeletal Animation

Hierarchical object animation is when you have multiple meshes which are, typically, arranged in a parent-child fashion through some sort of scenegraph.  Animation data is typically stored as separate translation and rotation (and sometimes scale) components and each object is animated relative to its local frame of reference.  This works fine for when the object is something like a helicopter and you need to rotate the main and tail rotors; however, when trying to articulate a more complicated and less segmented logical object such as a humanoid character, animation can only occur on the transforms for the object – no vertex data can be changed.  This means that constructing a human out a mesh hierarchy (with a head mesh, neck mesh, chest mesh, upper arm mesh, et cetera – all the appendages you wish to articulate) leads to block or segmented animation because, for example, the forearm object isn’t really connected to the upper arm so that when it is animated the ends of the objects don’t touch completely and your characters looks like they were created out of blocks.  Interstate 76, an amazing old game which I still occasionally replay just for the cut scenes, was animated in this fashion.  Suffice it to say that since that time animators and game developers have been looking for solutions with better visual fidelity.

Vertex animation is when a mesh is manipulated on a per vertex level by comparing one complete set of the mesh’s vertices against another complete set of the mesh’s vertices (each of the sets of vertices representing a particular keyframe of animation data) and interpolating a position between the two based upon how far between keyframe times the current animation clock is.  This approach gives the artist the most creative control and the greatest ability to animate; however, it is very memory intensive and requires art content files that are very large since each keyframe of animation is a complete snapshot of the mesh at a given point and time.  Quake’s MD2 file format is an example of vertex animation – another problem with vertex animation is that it is difficult to apply multiple simultaneous animations to a mesh being animated in this fashion.  Since the animation data is a complete snapshot of the mesh each animation stomps all over the previous one that was applied; now, there are solutions to this that modify vertex animation so that you are using ‘relative vertex animation’ data and you can combine and blend somewhat (and save art content file space by discarding unchanging vertices on a given keyframe) but ultimately as your models scale up in complexity, vertices, and polygons this approach has diminishing returns.  Vertex animation is still a very important approach to the non real-time rendering world; however, in the real-time arena it is rarely seen except for extremely complicated situations and sometimes for facial animation or lip synching.

Skeletal animation is a hybrid of the previous two methods.  The mesh representing the object is not manipulated by interpolating between two complete sets of vertex data (as is the case in vertex animation) but instead by moving treating the vertices of the mesh as if they were the ‘skin’ of the mesh and moving the skin to fit over a skeleton.  The skeleton is like the hierarchical object animation from the old days except that the skeleton, just like the skeleton in your body, is a hierarchy of ‘bones’ (sometimes referred to as ‘joints’) and even though you animate the skeleton, you never actually bother to draw it.  This is because we only want to animate the skeleton because we’re going to force the skin to go along with it.  Half-Life is an early example of a game that used skeletal animation.  Why don’t we simply animate the skin this way?  For all the reasons why we just explained that vertex animation is no longer in favor in the real-time world.  By only storing the rotation and translation (potentially other factors as well) data for each bone for a keyframe of animation we save tons of space in our art content files, and we gain the ability to simply combine animations and blend between them.  We gain performance advantages over complicated relative vertex animation systems when the model’s topology scales (more polygons, more vertices), and we gain the ability to add FK/IK capabilities into our system that would be virtually impossible with vertex animation (any system I can imagine to support this via vertex animation would ultimately require you emulating a skeletal system.)

So, now that I have explained the reasoning why I, and many others, use skeletal animation, let’s start explaining how it works.

The good news is that skeletal animation is actually VERY simple.  The bad news is that it usually either partially explained or people use different terms for differing things.  I will do my best to explain it as simply and yet thoroughly as possible.  The other bad news is because the world is an imperfect place, obtaining an example of skeletal animation data you can use can be difficult because you’re just now learning how it is supposed to work so it can be difficult to discern why art content produced by your artist doesn’t seem to work (is it you?  Is it the artist?  Is it his/her exporter?  Et cetera.)

Luckily, I will provide you with an example COLLADA XML file (*.dae) that has a walk animation included.  We will use the COLLADA format because there are moderately usable exporters for all the major art pipeline tools (Maya/Max/XSi) and your art guy/gal will most likely have experience with one of those tools.

So, ultimately, when this series of posts is over, you’ll be able to import a COLLADA XML file, pull out the mesh geometry, pull out the skeleton, and pull out the animation data, then play it back in your application.

Sunday, March 6, 2011

Windows 7 64-bit and Samsung Kies Mini

I was shocked to find out that AT&T and Samsung had finally provided a Froyo (Android 2.2) update for the Captivate Galaxy S phone.  All I had to do was download Samsung's Kies Mini firmware updating application (the version available was actually an AT&T modified stripped down version) and setup my phone correctly, backup critical data and press 'Upgrade.'

Of course, it never works out that way in the real world but I must admit that even a jaded and cynical software engineer like myself was disgusted and disappointed when every single time I connected my Captivate to my computer with Kies running, the Kies application would identify the phone and then promptly crash.

I Googled, Googled some more, tried compatibility settings, running as Administrator, I even tried using a Windows XP virtual machine in case it was a 32-bit issue - sadly Virtual PC 2007 (what I use on Windows 7) doesn't pass USB to a VM.

In any case, I was getting more and more frustrated and was ready to quit when I ran across an obscure tiny little message on some news server somewhere where a guy mentions - "Oh, yeah, and if you have IE9 installed on your machine, take it off."

Well, I just happened to have an IE9 release candidate installed.  How that crashed Kies escapes me since you'd have to be a pretty crap software engineer to have not tested your Windows only application, which you are releasing to MILLIONS of people to use, against IE6, IE7, IE8, and IE9 - but hey, Samsung are weird that way.  They make some wonderful things and somehow drop the ball on the really trivially simple things.

Long story shorter, uninstalled IE9, ran Kies Mini, phone showed up, chose 'Upgrade', a few minutes later I'm running flash on my Android phone.

Friday, March 4, 2011

AppleScript to add a 'new file' capability to Finder

Another convenience function you may wish to add to a button in your Finder toolbar is a 'new file' button that will deposit a blank file named 'NewFile' in the current Finder window directory. It also auto increments a counter if needed to ensure the new file doesn't overwrite an existing file. The code is below:

tell application "Finder"

#Create filename (avoid overwriting)
set current_path to (POSIX path of (the folder of the front window as text))
set good_filename to false
set loop_count to 0

repeat while good_filename is false

if loop_count is equal to 0 then
set NewFileName to (current_path & "/NewFile")
else
set NewFileName to (current_path & "/NewFile" & loop_count)
end if

if exists NewFileName as POSIX file then
else
do shell script "touch " & NewFileName
set good_filename to true
end if

set loop_count to (loop_count + 1)

end repeat

end tell

Add full path to title bar of Finder

Very simple, from the terminal:

defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES

Then in the terminal, to affect the change in your open Finder windows:

killall Finder

To revert, change YES to NO

(Btw, you can have a more UI oriented path shown by choosing View|Show Path Bar for the Finder but I find it easier to view the path in the title bar since I spend a lot of time in *nix)

This works in 10.6.6 but I'm not sure what other OSX versions it works on.

Thursday, March 3, 2011

Very cool feature of OSX to make up for uncool features...

The Finder in OSX is okay for the most part; however, Apple can be a strange mix of the 'well designed UI' approach and the 'keyboard shortcuts rule' approach. Often these approaches complement each other well - sometimes they do not.

One of the things about the Finder I don't like is that there's no path bar or button for simply letting you designate a path. I discovered that there is a 'Go To Folder' shortcut (command-shift-g) which proffers a little dialog box that I can do this with but there's no integrated path bar.

This is certainly an acceptable (mostly) alternative, but I really don't want to have to remember another intermittently used keyboard shortcut (I have several IDE's, Emacs, and different operating systems worth of shortcuts to remember as well, so one less would be nice.)

It turns out, very nicely, that you can add custom buttons to the Finder window simply by dragging an application onto the Finder's toolbar. So, I created a little AppleScript application that simply emitted command-shift-g to most recent finder window, and I gave it an icon. Now my finder window has a little terminal icon (I'll replace the icon later when I have more time) where I can click and it pops up a path dialog to change directories as seen below:



It is the little square black icon just to the right of middle.

Now, to do the same thing you need to open the AppleScript Editor and add the following text to your empty script:

tell application "Finder"
activate
tell application "System Events" to keystroke "g" using {command down, shift down}
end tell


Open a Finder window if one isn't already open and then tell the AppleScript Editor to run the script to verify that it is functioning as expected.

You now want to save the script as an Application - I saved my script into my Applications folder accordingly (you can do what you like.)

Now, you can skip this step if you wish, but I wanted a custom icon (instead of the default script icon) as my button in the Finder window so I found an image that I wanted to use (after looking for about 8 seconds) and opened it. I then selected the portion of the image I wanted and chose 'Copy' (you can use the preview window for this or some other image viewing/editing application.) This placed the image I wanted to use on the clipboard.

In order to change the icon on OSX 10.6.6 I then located the script application and brought up the 'Get Info' dialog on it. I then clicked on the application's icon in the upper left hand corner of the Get Info dialog so that it was selected, I then pasted the clipboard contents which deposited the image into the icon.

The last step is to simply open a Finder window and then drag the application from where you have located it onto the Finder's toolbar and it should appear.

Monday, February 28, 2011

OSX 10.6.5 update breaks apachectl script

If you're wanting to manipulate Apache via the apachectl script, OSX 10.6.5 apparently changed a line in the script in such a fashion that it no longer functions.

In the interest of brevity I simply recommend what others have suggested, change the line:

ULIMIT_MAX_FILES="ulimit -S -n 'ulimit -H -n'"

To simply be:

ULIMIT_MAX_FILES=""

If you need greater control of the directive, knock yourself out :)

Friday, February 25, 2011

Parallels performance tests

I spent part of my day evaluating performance for Windows 7 Ultimate 64-bit under Parallels on Mac OSX Snow Leopard.

Disheartening is the way I would put it. Thinks work well for the most part, but in other ways it falls short.

I really was expecting better results than a 50% performance hit compiling with VS 2010 Professional. Clean, Rebuild of 27 projects as Win32 Debug in the solution, roughly 400,000 lines of C++ code = 4 minutes 18 seconds on average. Under Windows 7 native that time was cut to an average of 1 minute 50 seconds. No concurrent builds allowed.

The virtual machine running off the bootcamp partition is allocated 6 processors and 8GB of memory. The native machine has 12 cores with 24 hardware threads (Parallels doesn't seem to provide hardware threads to VM as I allocate 6 cores and 6 procs show up in the Task Manager [you would think 12 would.]) This is why I expected a performance drop, but not a more than 100% improvement under the native OS.

Anyhow, still very impressive software, and it is nice to have OSX and Win 7 running side by side. I'm probably doing something wrong anyhow (historical precedent would suggest...)

Thursday, February 24, 2011

Parallels and PRL_ERR_DISK_GPT_MBR_NOT_EQUAL

This should help out some poor b**tard like me... I installed Parallels today to give it a spin because I heard that you can now run a virtual machine directly off your Boot Camp partition (ergo I can run pure Windows like I need to in order to properly test software, and I can run the very same partition as a virtual machine in OSX.)

Well, as usual, I ran into some hiccups; however, this time the hiccups were from something I'd done (but still shouldn't have been hiccups really.

For some reason, when I tried to get Parallels to use my Boot Camp partition, I was getting a 'cannot configure the boot camp partition' error and when I looked at the details I received a very mysterious PRL_ERR_DISK_GPT_MBR_NOT_EQUAL error.

Looking at this error suggests there some sort of problem with the GPT and the MBR (if you don't know what these are you aren't ready for this post, wikipedia is your friend) where something was not what someone expected.

Well, I know that after creating my Boot Camp partition in OSX that I'd messed around with that partition space in Windows 7 to create and extended partition by shrinking the Boot Camp partition. OSX didn't seem to care about this and was quite happy to mount the partitions for read only access. Well, it turns out that Parallels cares about this a lot and when it looks at the GPT to see what the MBR should be it throws up because the GPT states that the end of the Boot Camp partition is something it is not.

Sooooo... Long story short, it turns out I'm lucky that I'm using reFIT to handle my multi-boot system because when reFIT starts up you can run a little utility called gptsync (choose 'run partition tool' from the reFIT boot menu) which apparently will square up what is stated in the GPT with what is stated in the MBR (technically it modifies the MBR so be careful.)

BTW, gptsync doesn't handle extended partitions so I had to move all of that data onto the main Boot Camp partition and delete the partition then re-extend the Boot Camp partition over that space so it resembled what OSX remembered from earlier - then I could run gptsync.

Booting OSX and running Parallels at this point worked fine. As an aside, I was wondering if this was a Parallels limitation but it turned out to be a problem (again with virtually no intelligent description) for VMWare's Fusion 3.1 as well.

Hope this helps somebody! :)

UPDATE: Don't forget, both in VMWare Fusion and Parallels, to delete any previous virtual machine you had tried to make using that Boot Camp partition because it has erroneous GPT data - start with a fresh virtual machine.

Saturday, February 19, 2011

Home and End keys in most editors for OSX

http://www.starryhope.com/tech/apple/2006/keyfixer/

God bless that guy, I really didn't want to create a custom keybinding dictionary. Works for my Ergonomic 7000. 'Nuff said.

Wednesday, February 16, 2011

If your non-Apple keyboard won't eject using F12...

...make sure that if your keyboard preferences (either in Apple's preferences or a preference list created by keyboard install software on your machine) offer a keyboard type of 'Generic', try setting it to this value.

My new Microsoft Ergonomic 7000 Wireless was set to ANSI for some reason after installation of the software on OSX and F12 would bring up dashboard (like it should) but would not trigger the open/close tray command when depressed longer (as it was supposed to.)

Switching the setting from 'Ansi' to 'Generic' solved this for me (for this keyboard the value was under 'Options' in the system preferences->Microsoft Keyboard.)

Hope this helps someone someday :).

Monday, February 7, 2011

Bought a new crApple Mac Pro for work...

...the other day.

Un-freaking-beleivable how ridiculously stupidly overpriced the thing is. Oh, don't get me wrong, it's sexy, sleek, and oh so very shiny with 12 cores, and multiple terabytes of drives (et cetera); but, how on earth are there people so stupid that they actually buy memory from crApple? 24GB of memory (you start with 6GB) from Apple is more than $2100. You can buy 24GB from Crucial for about $420 and then you get to keep 2 of the 1GB sticks that crApple gives you by default for a total of 26GB, plus you get save $1700 (think of all the iPads, iPhones, iPods, iTouches, iWhatevers you could buy with that.)

I love the Woz, hate the Jobs...