Powershell File Archiver

I recently ran into a rather awkward case in which I had to move all files (not directories) within a file structure that were older than a particular age. Ideally, at least on a Windows machine, I would just use Robocopy with the /MOV (juxtaposed to /MOVE which also moves the directory structure) and /MINAGE:### (days) parameters. Unfortunately, it was not available, and for various reasons, I could not copy a replacement for it nor install an alternate tool for the job. Xcopy can copy files newer than a date, so it was indirectly possible to use that, but too annoying. It did have PowerShell 2.0 installed. I put together this quick script for handling the task.

Hopefully someone might find it useful. It was quickly written, so there probably is a better way of doing the task.

Revealing One’s Self — A Quick Quine

Due to it being brought up in a conversation, I had made a somewhat quick “Quine” in HTML/JavaScript (since it web ready). It took me about 2 hours since I had made a not-so-obvious but syntactically correct typo that resulted in “runnable output” but not correct output: the second generation would run, but the output was mutated further.

After I had completed my development, I did come across someone else’s work on an HTML/JavaScript quine which produced a much nicer output, but used a slightly different method (link). I may end up rewriting the quine using the same method, but with “prettier” output. Quines are not limited to text based formats; I had also found where someone had developed a quine based on a zip file. I will point out that the zip quine may crash some older anti-virus software that attempts to unzip files to look for malware.

As a side note, quines are a namesake of Willard Van Orman Quine, but were given that name by Douglas Hofstadter.

Launching Powershell Script in Restricted Environment

On occasion, I end up needing to launch a Powershell script in an environment that is “Restricted” which includes not being able to execute Cmdlets directly. To get around this, I had made a skeleton cmd.exe batch file that will launch a Powershell script with the same filename.

It locates the Powershell executable and invokes it for the script. It uses a pushd-based workaround for invoking from a network path (which cmd.exe does not appreciate). The sample cannot be used as it since it is simplified for demonstration of concept. There probably is a better way, but I found that this tends to work consistently. This particular version also includes a basic logging subroutine for the pre- and post- execution.

Protected: War of the Words

This content is password protected. To view it please enter your password below:

Traits of Leaders and Followers

It is often enough in the early mornings when I am sipping on my mug of coffee that I amuse myself with reflective thoughts; today I happen to pondered the idea of leadership. Leadership is an important idea in the States, while not everyone can be a “person in-charge” as nothing would get done, the qualities of a leader are none-the-less highly valued. Continuing this line of thought, I considered what qualities might be found in a leader, or at least one possessing leadership. Certainly, I have heard of various rhetoric, each presenting its own ideal leader, as such, I selected three traits on which to focus: independent thought, critical thinking, and effective communication. After I had done so, I had let go a small smile as it occurred to me, there is quite a bit of overlap with my ideas of leadership and my ideas on a good follower.

Independent thought I will define as the ability to think for one’s self. This trait, in my opinion, is important for leader and follower alike. A leader has to be able to make decisions for his (or her) self in addition for his subordinates. The follower is not excluded from this, while submitting to leadership is desirable in a follower, a good follower is able to form his own opinion and ideas.

Related to the first trait of independent thought, but not the same is the second trait critical thinking. Paraphrasing from a popular, user-editable encyclopedia, critical thinking is discerning judgement as well as actively evaluating information to reach an answer or conclusion. For both leader and follower, this trait is often, but not always, the source for the first trait, and neither of these traits are, in my opinion, truly complete without the other. A leader has the responsibility to his subordinates to think through the (organization’s) goals and objectives to assess feasibility, cost/benefits, and morality as part of planning and executing. The follower has similar responsibility to the leadership, it will often be the case that the follower will have a more detailed, up-close perspective in an execution. Each of their responsibilities would include to provide feedback of his own critical thinking.

Thought and thinking are each in the mind and so that action can be taken or feedback given it must be communicated. Effective communication, another trait I believe is important for both leader and follower, is likely the most difficult to achieve as communication, by nature, involves multiple parties thus complicating the process. A leader needs to communicate to his subordinates those goals, objectives, and plans in order to successfully orchestrate the group. Likewise, a follower supports his leader by providing feedback on understanding of given communication, information on setbacks and opportunities, as well as personal views concerning the goals, objectives, and plans for the group.

These traits are certainly not the only traits of leadership or good followers, however, I feel that these overlapping ones are critical for both. Consider the size of many organizations, it is often enough that one can be in position of both a leader and a follower at the same time: following the direction of those leaders above, giving feedback all the while providing direction to subordinates and receiving feedback from each of them. Given the importance of each of these trait, perhaps we should take care to ensure each are adequately developed.

Volumes of Data And Data of Volumes – Part 2

After much contemplation, I couldn’t make a decision based solely on technical merit; as such, I have used a different criteria for my decision: experience gain. It has been a while since I wrote a program of any significant size in C++, so I made that my decision. From that point I chose a couple tentative libraries to use and/or learn:

  • Boost – To be used primarily for multithreading in current plans, but has various other uses.
  • CGAL – Depends on Boost (likely for its linear algebra support) provides various geometry and math functions.

As the project (and its needs) grows, I may use additional libraries, or create a few as needed. For the first version of the project, I will likely use very little segregation of files to lower overhead. Once the project reaches a minimal size (yet to be determined), I will segregate my source.

Given that I have previously decided to make the following choices:

  • Primary interface will be text based
  • Using CMake for generating Makefiles (first time using)
  • Using MSYS/MinGW as my primary build environment (I laptop came installed with Windows 7)
  • Focus on portability will likely start after I do initial tests with Raytracing

Since there are likely things I will have to learn in this project, as I do so I will (time permitting) put together tutorials on whatever challenge happens to come up for whoever might come across this blog.

Volumes of Data And Data of Volumes – Part 1

So, I’ve been ray tracing, as a hobby, for a few years now, primarily using POV-Ray. More recently, I decide that I might try to build one.

While originally I decided to build one in Javascript for challenge, having seen Slime‘s several times in the past. I had considered rewriting from scratch, making it use Asynchronous Module Definition (AMD, require.js) format modules, make use of html5 canvas, and use a combination of setTimeout and Future/Promise to make it “multithreaded”. I may still take that route, but I wanted to consider my other options before I commit to one.

My initial thoughts:

JavaScript – Very portable, and with current computing power and modern engines, a real contender. It very easily lends itself to distributed rendering if some server side support is added. Server side support can be a different language, or node.js can also provide. Functions being a first class citizen may prove powerful.

C# – Moderately portable, if considerations are made for Mono or Dot-GNU. At least on Windows has decent support for multi-threading, I have not sufficiently investigated Mono or Dot-GNU. Support for generics will be useful, and if Linq is used, data structures can easily be queried. Windows Communication Foundation may ease ability to do distributed rendering, but will be limited to the MS platforms. This might be solved with serialization and the http classes that from research on forums seems stable on Mono.

Java – Reasonably portable, would run anywhere JRE would run. Has similar benefits as C#, but will need to be more careful with circular references due to the garbage collector. Good threading and web services support.

C++ – If standard c++, excellent portability if OS specific code is isolated. Excellent support for generic types and functions in the form of templates. I am to understand that gcc and Visual C++ supports lambdas now, so that would be worth investigating. I could go with CLI C++, I can maintain  some cross-compatibility with Mono (if no native code or P/Invoke), and gain access to a few of the libraries, however, I doubt the cost vs. benefit would be worth it (too many restrictions)

C – Similar portability to C++, although I lose the benefits (and pitfalls) of object oriented classes as well as templates. If well written, it can have a smaller memory footprint than C++, although compilers get better everyday. With the features I wish to have available, it may end up being a more complex code base before all is done.

Before I can actually choose my language, I need to have a better idea of what features I want to have, and how soon. Sure, long term, I may wish to support all the features of products such as POV-Ray, YafaRay, Maya, or Cinema 4D; however, such a task is unreasonable. As such, to avoid overwhelming myself, I need to outline for myself a general plan of features for short-term, mid-term, and long(er)-term. First of all to make the initial design decisions, then in order to plan my development so that I do not have too much scope creep.

Very Short term:

  • Basic 3D geometry/math support
    • Scalar Operations, such as dot products, scalar multiplication, etc
    • Matrix Operations, such as transposing, matrix multiplication, etc
  • Ray casting – Ray caster is to ray tracer as bicycle is to motorcycle, they have some similarities, but one is more complex than the other
  • Basic multi-threading support – Explicit threads
  • Goal: A sphere or cube over a checkered plane

Short term:

  • Remainder of 3D geometry/math support
  • Foundations for CSG
  • Foundations for Bounding boxes
  • Foundations for memory structures (will need to decide among different structures)
  • Thread-pooling
  • Basic lighting model
  • Goal: Randomly generated primitives, possibly CSG, over a checkered plane


  • Basic scripting language (this will require decisions, JavaScript can use itself, Java has Rhino for JavaScript, C and C++ has scripting libraries for several languages, C# has the CodeDOM that could be used to translate JIT compile one)
  • Flesh out Bounding boxes, CSG, and memory structures
  • At least one more lighting model
  • Basic UI
  • Front-end and Back-end should be separate
  • Goal: Scene generated from script


  • Surface Normals
  • Textures and Materials
  • All major geometry types (2D and 3D primitives, surface maps, possibly isosurfaces, optimized mesh support)
  • Goal: Improved scene generated from script

Nice to have:

  • Radiosity
  • Photon mapping
  • Procedural scene changes and physics
  • Media effects
  • Spectral rendering

Definitely a lofty project, but persistence will pay off: after all Romulas may have drawn his line in the sand in a few minutes, but Rome itself wasn’t built in a day.

Next time, on this topic, I will have my decision and how I match the requirements to it, and my basic plans.



“Ask your compiler about the availability of generic types that provided similar functionality with little to no extra cost.”

Generic types are a feature in several languages (or platforms) that allows a parametrized type. The meaning of the previous statement is probably not clear for the uninitiated. So, lets have a cup of Java:

ArrayList<String> stringCheeseList = new ArrayList<String>();stringCheeseList.add(“Cheddar”);

ArrayList<Integer> intLifeList = new ArrayList<Integer>();

Okay, in the above, we have two collections, both of the collections are technically the same class of java.util.ArrayList, however, they have an important difference, they each accept a different type of object. Many languages that support generics have at least compile-time type checking to verify that only the correct kind can be passed to the properties or method of the specific type. For example, an attempt to compile intLifeList.add(“777″) would result in an error. As a result, simple mistakes that could have run-time impact can be avoided, plus the code better documents itself. While Java does a method called “Type erasure” to handle generics, some languages/platforms store the additional metadata (information about itself) of the generic type parameter and will do addition run-time verifications and/or optimizations (usually during the Just-In-Time [JIT] Compile of the byte code). It should also be to note that generics, while often used for collections, are not exclusive to collection types; they can be used for semi-specialized class wrappers, not to mention, some languages allow for methods to be marked generic without the containing class to be generic such as in the declaration of bool DoStuff<T>(T inputStuff).

Now, while we have seen the good of generics, everything does come at a price. For Java, the implementation has a decent price for objects as the code. After verification at compile-time, does the so called “Type erasure” that translates the code to as though generic types don’t exists. The ArrayList<Integer>() above becomes a simple ArrayList() and an Integer i = intLifeList.get(0) becomes Integer i = (Integer)intLifeList.get(0); inserting a cast to covert the Object to Integer. The biggest cost with the collection is likely from a Java issue not related to the generic type: Integer is a boxed type of int.

C++ has a form of generic programming called templates (on the MS platform, they also have .NET generics, which will be touched on later). Templates are quite versatile, but more-or-less  operate under the same principals as other languages with generics (I’m not even going to touch template-metaprogramming). It is possible for template use to generate extra machine code for some compilers in various types of uses. While that is one of the potential costs of generics in C++, I will restrict the scope of this post for both brevity and the fact I haven’t used them (as in wrote and examine the results) enough to be able to give a clear outline of when that can occur on any given compiler.

For the CLR (Microsoft.NET’s common language run-time), the cost is paid differently, the extra metadata is loaded with the initialization of the generic type. The reason for the cost is the run-time type checking of the platform. This additional cost isn’t without benefit, however. At least according to Microsoft’s documentation, while CLR generic can produce some extra code, the JIT compiler does its generic handling at run-time using the metadata, allowing the environment to better reuse code it already generated. Also, the environment will also avoid (un)boxing operations on primitives using the additional run-time information.

As we can see, while generics aren’t without cost, they can have some very positive benefits on type-safety and potentially documentation. So next time you are hacking together your programming project, give them a try, you are bound to learn something.


“Radical,” It is a term that, to many, strikes mostly at the image of over-sized, adolescent, reptilian martial artists with a penchant for fighting crime and habit of consuming pizza. Some mathematicians may claim that the term keeps them from being square, we programmers typically use either Math.pow(x, .5) or Math.sqrt(x) for that purpose. In Japanese Kanji (as well as its source, Chinese characters), the term “radical” refers to part of the character itself, typically giving hint as to its meaning, or sometimes pronunciation.

“Radical” itself is an English term, which (at least according to Wikipedia) comes from the Latin term “Radix” meaning root, likely owing to name of the symbol used in math for the square, cube, and nth roots. In Japanese, the term is called “Bushu” with the Kanji of 部首 (assuming that you have the correct fonts installed to see the characters rather than boxes or something else random). There are just a little over 200 of these radicals, them being kanji themselves. The radical portion of the character can be often compressed to fit. Take one of the words for “love”, Ai, for example has the infamous kanji of 愛: likely hard to see in the current font, but crunched at the center is the radical. That radical is the kanji for heart, 心, pronounced kokoro.

Two more examples:

引 : Draw (as in a bow) Several pronunciations including hiki (He-Key) has the radical of 弓, the kanji for bow, pronounced yumi (You-Me)

花: Flower, has pronunciation of hana, has the radical of 艸, one of the kanji for grass, pronounced kusa, in this case, primarily used as a radical, as opposed to 草. Note that the other kanji for grass and the kanji for flower have the same part on top.

The Domain Has Once Again Opened

After many years of having nothing, instead of rolling my own, I went ahead and installed WordPress. This leads to the topic of time management, a troublesome topic to developers such as myself. Sometimes to get the task done, one cannot do it all him (or her) self. If I can manage to manage my time effectively, I should have 2-3 posts per week on whatever topic that happen to pass through my mind.