<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Mo Jebus &#187; Programming</title>
	<link>http://moronicbajebus.com</link>
	<description>Banana Ice Cream!</description>
	<pubDate>Thu, 13 Nov 2008 01:24:05 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>
	<language>en</language>
			<item>
		<title>DOM Selectors API</title>
		<link>http://moronicbajebus.com/2006/10/12/dom-selectors-api/</link>
		<comments>http://moronicbajebus.com/2006/10/12/dom-selectors-api/#comments</comments>
		<pubDate>Thu, 12 Oct 2006 14:57:24 +0000</pubDate>
		<dc:creator>Seamus</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[Frontpage]]></category>

		<guid isPermaLink="false">http://moronicbajebus.com/2006/10/12/dom-selectors-api/</guid>
		<description><![CDATA[A quick glance at the Selectors API indicates to me that I am not alone in my desire to retrieve DOM elements with CSS selector syntax.  
]]></description>
			<content:encoded><![CDATA[<p>A quick glance at the <a href="http://www.w3.org/TR/2006/WD-selectors-api-20060926/">Selectors API</a> indicates to me that I am not alone in <a href="/2006/08/31/better-javascript/">my desire</a> to retrieve DOM elements with CSS selector syntax.  </p>
]]></content:encoded>
			<wfw:commentRss>http://moronicbajebus.com/2006/10/12/dom-selectors-api/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Better Javascript</title>
		<link>http://moronicbajebus.com/2006/08/31/better-javascript/</link>
		<comments>http://moronicbajebus.com/2006/08/31/better-javascript/#comments</comments>
		<pubDate>Thu, 31 Aug 2006 20:34:53 +0000</pubDate>
		<dc:creator>Seamus</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[Frontpage]]></category>

		<guid isPermaLink="false">http://moronicbajebus.com/?p=96</guid>
		<description><![CDATA[Javascript needs to grow.  The Javascript libraries such as Prototype and JQuery should barely exist.  Before you say anything, let me refine the statement. Firstly, I am not discrediting them because they are very usefully libraries.  Why should they barely exist?  Much of their functionality, as I believe, should be provided [...]]]></description>
			<content:encoded><![CDATA[<p>Javascript needs to grow.  <strong>The Javascript libraries such as Prototype and JQuery should barely exist. </strong> Before you say anything, let me refine the statement. Firstly, I am not discrediting them because they are very usefully libraries.  Why should they barely exist?  Much of their functionality, as I believe, should be provided by the semantics of Javascript and its core libraries (DOM, regexp, window, etc).  This functionality is the majority of my use of JQuery and Prototype.  </p>
<h2>My Wish List of Core Functionality</h2>
<ul>
<li>
<h3>Inheritance</h3>
<p>An easy way to inherit a class, call the parent&#8217;s constructor, call a parent&#8217;s version of a method, and to set members as protected, private, or public.  There <a href="http://dean.edwards.name/weblog/2006/05/prototype-and-base/">are</a> <a href="http://truecode.blogspot.com/2006/08/object-oriented-super-class-method.html">examples</a> that go towards achieve this; but, native support is magnitudes of an improvement just for the sake of improved readability.  (It would be really sweet to have reflection.) For what Mozilla is planning for Javascript 2.0, a more <a href="http://www.mozilla.org/js/language/js20/core/classes.html">traditional class</a> support will be added.
  </li>
<li>
<h3>Get Elements with XPath and CSS Syntax</h3>
<p>There are many more ways to specify elements than by tag name and id. For example class name, attribute, relationship placement,  any of the CSS selectors, and any combination of all them.  This is where <a href="http://jquery.com/docs/BaseTraverse/">JQuery shines</a>; it allows for all of these.  <a href="http://www.w3schools.com/xpath/default.asp">XPath</a> allows for much of this and is <a href="http://www-xray.ast.cam.ac.uk/~jgraham/mozilla/xpath-tutorial.html">starting to gain</a> browser support (Mozilla and Opera).  Now I often want to use a CSS style because I have been using it to match elements for several years now. In the end, I just want something that is rich enough to get elements which may be a combination of XPath, XQuery, CSS syntax, and simple new methods such as <a href="http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/">getElementsByClassName</a>.</p>
</li>
<li>
<h3>Add/Remove Class</h3>
<p>Prototype has <a href="http://www.sergiopereira.com/articles/prototype.js.html#Element">it</a>, JQuery has <a href="http://jquery.com/docs/BaseStyle/">it</a>, and YUI has http://developer.yahoo.com/yui/docs/dom/YAHOO.util.Dom.html#addClass. People want it so just add the functionality of adding a class name, removing a class name, retrieving a list of class names, and checking if an element has a class name to the DOM Element.
</li>
<li>
<h3>DOM Aliases for Common Task</h3>
<p>Back in my early programming class, I learned that if you constantly reuse the same few lines of code (even if they are simple task) to save yourself time and wrap them up in a function.   I mention this because it leads me to the fact that a lot of commonly reused DOM code exist.  </p>
<ul>
<li>
<h3>Creating an element with only a text node as child</h3>
<p><code>var elem = document.createElement(&quot;span&quot;);<br />
var text = document.createTextNode(&quot;Some text.&quot;);<br />
elem.appendChild(text);<br />
//OR<br />
var elem = document.createElement(&quot;span&quot;);<br />
elem.appendChild(document.createTextNode(&quot;Some text.&quot;));<br />
</code></p>
<p>I suggest for the addition of <code>document.createElement( &lt;tag name&gt; [, &lt;text for child text node&gt;])</code>.</p>
</li>
<li>
<h3>Insert an element before or after another element</h3>
<p><code><a href="http://developer.mozilla.org/en/docs/DOM:element.insertBefore">Element.insertBefore</a> and Element.insertAfter</code> never seemed intuitive to me.  At first glance I thought it worked as such <code>referenceElement.insertBefore(newElement)</code> instead of <code>parentElement.insertBefore(newElement, referenceElement)</code>.  So what do I do most of the time (well I use JQuery&#8217;s $.before): <code>referenceElement.parentNode.insertBefore(newElement, referenceElement)</code>. To make matters worse, to insert an element after another element I use the following (again not really because I use JQuery&#8217;s $.after): <code>referenceElement.parentNode.insertBefore(newElement, referenceElement.nextSibling)</code>.<br />
My suggestion is overload the method insertBefore so that if only one parameter is passed that it then will act as I how I first thought it did and to likewise add a simlar insertAfter method.
</li>
</ul>
</li>
</ul>
<p>There is plenty more I can add but not today.  In conclusion, I feel that developing in Javascript gets bogged down because of the extra brain power to remember the work around or the extra brain power to deterimne which library to use to mask the laborious details.</p>
]]></content:encoded>
			<wfw:commentRss>http://moronicbajebus.com/2006/08/31/better-javascript/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Add A Class Randomly From a Set</title>
		<link>http://moronicbajebus.com/2006/07/30/add-a-class-randomly-from-a-set/</link>
		<comments>http://moronicbajebus.com/2006/07/30/add-a-class-randomly-from-a-set/#comments</comments>
		<pubDate>Sun, 30 Jul 2006 21:11:25 +0000</pubDate>
		<dc:creator>Seamus</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[CSS]]></category>

		<category><![CDATA[Frontpage]]></category>

		<guid isPermaLink="false">http://moronicbajebus.com/?p=94</guid>
		<description><![CDATA[I was recently asked by a friend for information about how to have a random background image. Well not completely random, the background image should be from a set of images.  My idea: add a class, randomly from a set, to the body (or another element) with Javascript. I could just change the style [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently asked by a friend for information about how to have a random background image. Well not completely random, the background image should be from a set of images.  My idea: add a class, randomly from a set, to the body (or another element) with Javascript. I could just change the style attribute for the background image; but, what if the text is white and one of the images happens to be very light in color? So now I have the issue of ensure that there is adequate contrast in color between the background and text.  Plus there could always be other wishes such as being able to change the border color.  So, for me, changing the class gives far greater flexibility for a script. Now I show you my very <a href="/wordpress/wp-content/files/add-a-class-randomly-from-a-set/randomClassName.html">simple example of the code</a>.</p>
<h2>How to use:</h2>
<ol>
<li>Download <a href="http://jquery.com/">JQuery</a></li>
<li>Download <a href="/wordpress/wp-content/files/add-a-class-randomly-from-a-set/AddAClassNameAtRandomToAnElement.js">AddAClassNameAtRandomToAnElement.js</a></li>
<li>Include jquery.js and AddAClassNameAtRandomToAnElement.js in your html: <br />
           <code>&lt;script src=&#34;jquery.js&#34;>&lt;/script><br />
&lt;script src=&#34;AddAClassNameAtRandomToAnElement.js&#34;></code></li>
<li>Create the set of classes to have randomly selected and the query of the element to add the class to: <br />
<code>&lt;script> <br />
var setOfRandomClassNames = new Array(&#34;aa&#34;, &#34;bb&#34;, &#34;cc&#34;); // three classes with the names: aa, bb, and cc<br />
 //var queryForElementsToAddRandomClassTo = &#34;body&#34;; // adds the class name to the body <br />
 var queryForElementsToAddRandomClassTo = &#34;#cow&#34;; // adds the class name to an element with the id of cow<br />
&#8230;</code></li>
<li>Add the call to add the class:<br />
<code>&#8230;<br />$(document).ready(function(){ <br />
&nbsp; &nbsp;$(queryForElementsToAddRandomClassTo).addRandomClass(setOfRandomClassNames);}<br />
});<br />
&#8230;&lt;/script></code></li>
</ol>
<h2>Update</h2>
<p>I changed it from an independent function to a method (<a href="http://jquery.com/docs/Plugin/">JQuery Plugin</a>) of the $ as <a href="/2006/07/30/add-a-class-randomly-from-a-set/#comment-482">John Resig suggested</a>.  Keep up the good work on JQuery John!</p>
]]></content:encoded>
			<wfw:commentRss>http://moronicbajebus.com/2006/07/30/add-a-class-randomly-from-a-set/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Upload File Permissions On AFS</title>
		<link>http://moronicbajebus.com/2006/07/14/php-upload-file-permissions-on-afs/</link>
		<comments>http://moronicbajebus.com/2006/07/14/php-upload-file-permissions-on-afs/#comments</comments>
		<pubDate>Fri, 14 Jul 2006 17:35:49 +0000</pubDate>
		<dc:creator>Seamus</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Frontpage]]></category>

		<guid isPermaLink="false">http://moronicbajebus.com/?p=73</guid>
		<description><![CDATA[A common problem (as a quick search shows) when creating a file upload script in PHP is the permissions on the destination directory. The PHP engine must have permissions to write a file to the destination directory. For Linux and Unix file system, the standard way is to use CHMOD; but, the method is different [...]]]></description>
			<content:encoded><![CDATA[<p>A common problem (as a quick search shows) when creating a file upload script in PHP is the permissions on the destination directory. The PHP engine must have permissions to write a file to the destination directory. For Linux and Unix file system, the standard way is to use CHMOD; but, the method is different if the file system is <a href="http://en.wikipedia.org/wiki/Andrew_file_system">AFS</a> which I have seen the most use by colleges such as UMBC.  Here’s how I went about fixing it:</p>
<p>The error message:<br />
<code>Warning: move_upload_file(): Unable to move "(src)" to "(destination)" in (php file path) on line NNN</code></p>
<p>The fix:<br />
I had to give permissions to add files (i) to the destination directory to the user that PHP is running as.  I found the user for PHP by looking at user’s on the directory PHP is located in: “<code><a href="http://www.openafs.org/pages/doc/AdminReference/auarf148.htm#HDRFS_LISTACL">fs listacl</a></code>”. I found PHP by running <code>php_info()</code> and seeing where many of the file paths share in location. Most of the file paths are the same up till the last directory so use the common part of the different paths. I found PHP to be located at <code>(common path)/bin</code>.</p>
<p><code>> cd (common path)/bin<br />
> fs <a href="http://www.openafs.org/pages/doc/AdminReference/auarf148.htm#HDRFS_LISTACL">listacl</a><br />
Access list for . is<br />
Normal rights:<br />
  (the-php-user) rl<br />
  system:administrators rlidwka</code></p>
<p>Since I knew the user wasn’t system:administrators it had to be the other user. </p>
<p>Going back to the parent directory of the destination directory for my file upload, I set permission for the-php-user:<br />
<code>> cd ~/www/<br />
> fs <a href="http://www.openafs.org/pages/doc/AdminReference/auarf157.htm#HDRFS_SETACL">sa</a> (desination directory) (the-php-user) rlidwka</code></p>
<p>This may not be complete but I hope it helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://moronicbajebus.com/2006/07/14/php-upload-file-permissions-on-afs/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Pointer With Lipstick</title>
		<link>http://moronicbajebus.com/2006/02/17/pointer-with-lipstick/</link>
		<comments>http://moronicbajebus.com/2006/02/17/pointer-with-lipstick/#comments</comments>
		<pubDate>Fri, 17 Feb 2006 17:47:42 +0000</pubDate>
		<dc:creator>Seamus</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Frontpage]]></category>

		<category><![CDATA[Rant]]></category>

		<guid isPermaLink="false">http://moronicbajebus.com/?p=67</guid>
		<description><![CDATA[I forget which one of my professors said it but I still think it holds true, &#8220;a reference is just a cross dressing pointer.&#8221;
]]></description>
			<content:encoded><![CDATA[<p>I forget which one of my professors said it but I still think it holds true, &#8220;a reference is just a cross dressing pointer.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://moronicbajebus.com/2006/02/17/pointer-with-lipstick/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Package Troubleshooting</title>
		<link>http://moronicbajebus.com/2006/02/13/package-troubleshooting/</link>
		<comments>http://moronicbajebus.com/2006/02/13/package-troubleshooting/#comments</comments>
		<pubDate>Tue, 14 Feb 2006 02:59:48 +0000</pubDate>
		<dc:creator>Seamus</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Frontpage]]></category>

		<guid isPermaLink="false">http://moronicbajebus.com/?p=65</guid>
		<description><![CDATA[A simply learned lesson in using Java packages causing the errors out the wa-zoo when trying to run the program.]]></description>
			<content:encoded><![CDATA[<p>I had trouble with my early Java programs when I would use <a href="http://www.yoda.arachsys.com/java/packages.html">packages</a>.  If I left my files in the default package, it worked fine. But when I added them to a package, I could build them finejust not run them.  I found it to be a common problem among other students and I spent far too much time trying to search for an answer.</p>
<p>ExampleWithPackage.java source:<code>
<pre>package com.moronicbajebus; 

public class ExampleWithPackage {
	public static void main(String[] args) {
		//&#8230;
	}
}</pre>
<p></code></p>
<p>The error output from running it in the command line from the directory <code>working-directory</code>:<br />
<code>
<pre>.../working-directory&gt;java ExampleWithPackage
Exception in thread "main" java.lang.NoClassDefFoundError: ExampleWithPackage (wrong name: com/moronicbajebus/ExampleWithPackage)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)</pre>
<p></code></p>
<p><strong>The java files must be in directory tree that matches the package name</strong> from the working directory (the one you are in if you are using a command line).  I need to create a directory named <code>com</code> in <code>working-directory</code>; and then, I need to create a directory named <code>moronicbajebus</code> in the newly created <code>com</code> directory. Then I place <code>ExampleWithPackage.java</code> in the  <code>moronicbajebus</code> directory. </p>
<p>Now the program will run with one more minor change, Now the program will run with one more minor change, I have to also give the package with the class:<br />
<code>.../working-directory&gt;java <strong>com.moronicbajebus.</strong>ExampleWithPackage</code></p>
<p>Remember dont choke your computer, <a href="http://gallery.actsofvolition.com/photos/signs/photo25270">choke your dog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://moronicbajebus.com/2006/02/13/package-troubleshooting/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Count Binary</title>
		<link>http://moronicbajebus.com/2006/02/03/count-binary/</link>
		<comments>http://moronicbajebus.com/2006/02/03/count-binary/#comments</comments>
		<pubDate>Fri, 03 Feb 2006 15:38:54 +0000</pubDate>
		<dc:creator>Seamus</dc:creator>
		
		<category><![CDATA[External]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Frontpage]]></category>

		<guid isPermaLink="false">http://moronicbajebus.com/?p=60</guid>
		<description><![CDATA[A cartoon to teach you to count with your toes and fingers in binary.
]]></description>
			<content:encoded><![CDATA[<p>A <a href="http://www.instructables.com/ex/i/B6FF02487C871028A786001143E7E506/">cartoon to teach you</a> to count with your toes and fingers in binary.</p>
]]></content:encoded>
			<wfw:commentRss>http://moronicbajebus.com/2006/02/03/count-binary/feed/</wfw:commentRss>
		</item>
		<item>
		<title>First Run With Pear</title>
		<link>http://moronicbajebus.com/2006/01/19/first-run-with-pear/</link>
		<comments>http://moronicbajebus.com/2006/01/19/first-run-with-pear/#comments</comments>
		<pubDate>Thu, 19 Jan 2006 05:56:29 +0000</pubDate>
		<dc:creator>Seamus</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Frontpage]]></category>

		<guid isPermaLink="false">http://moronicbajebus.com/wordpress/?p=42</guid>
		<description><![CDATA[At my job, I have recently been between projects. I have recently discovered PEAR which the concept of a library of PHP classes is something that I have wanted. I wanted to install these classes on the schools server. Since I cannot add packages to the main repository I took to following the directions on [...]]]></description>
			<content:encoded><![CDATA[<p>At my job, I have recently been between projects. I have recently discovered <a href="http://pear.php.net">PEAR</a> which the concept of a library of PHP classes is something that I have wanted. I wanted to install these classes on the schools server. Since I cannot add packages to the main repository I took to following the <a href="http://pear.php.net/manual/en/installation.shared.php">directions on creating an individuals repository</a> using the directions for doing exactly that on a shared host.</p>
<p>The directions worked as described on my personal web server; but the directions did not work on the UMBCs server. Here are a list of things I did to get it to work:</p>
<ol>
<li>The pear command did not work from command line. To find where it was located I did some searching. I started from where I knew PHP was located by using provided by <code>php_info()</code> and I found the pear program  located in the bin directory. To make simpler for myself, I added the location of pear to my path environment variable.</li>
<li>To figure out what version of PEAR you are using, run the command <code>pear V</code>.</li>
<li>The pear directory was not being created when I would run the command. The pear directory should have been in my home directory because it was specified there with the shortcut <code>~/</code> but since it was not I used the full path to my home directory which then created the pear directory where it I wanted it.</li>
<li>I first located the PEAR repository directory in my home directory and I got the following errors in the PHP files: <code>Fatal error: main(): Failed opening required '&lt;package&gt;'</code>.  I discovered PHP did not have group permissions to access my home directory so I placed the repository in my web directory as a quick and simple fix.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://moronicbajebus.com/2006/01/19/first-run-with-pear/feed/</wfw:commentRss>
		</item>
		<item>
		<title>API Design</title>
		<link>http://moronicbajebus.com/2006/01/03/api-design/</link>
		<comments>http://moronicbajebus.com/2006/01/03/api-design/#comments</comments>
		<pubDate>Wed, 04 Jan 2006 04:02:13 +0000</pubDate>
		<dc:creator>Seamus</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Frontpage]]></category>

		<guid isPermaLink="false">http://moronicbajebus.com/wordpress/2006/01/03/api-design/</guid>
		<description><![CDATA[What makes a good design for an Application Programming Interface.]]></description>
			<content:encoded><![CDATA[<p>A good design for an <a href="http://en.wikipedia.org/wiki/Application_programming_interface">Application Programming Interface</a> (API) can speed up development. But what is a <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=142428">good</a> <a href="http://www.cincomsmalltalk.com/blog/blogView?showComments=true&#038;entry=3258158706">API</a> <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=4826">design</a>? My short list, based on using them, for a good design:</p>
<ul>
<li>I should not be hassled with tedious initialization. In my networking class, I was required to use the standard C network library. This requires a function call for near each stage of creation of the network connection, which I quickly pushed into a function that took the simple parameters for the IP address or URL and the port number. The function shaved off at least ten minutes for my next projects.</li>
<li>I like it when I can make a guess the name of a call (method or function) which this again saves me time from having to look it up.</li>
<li>Documentation. I will need to look up information at some point about the API.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://moronicbajebus.com/2006/01/03/api-design/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
