<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Vershun's Brain Dump &#187; Computers</title>
	<atom:link href="http://www.vershun.com/category/computers/feed" rel="self" type="application/rss+xml" />
	<link>http://www.vershun.com</link>
	<description>Worthless Mind Excretion</description>
	<lastBuildDate>Tue, 31 Aug 2010 06:05:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Flex Fast Compiler Update</title>
		<link>http://www.vershun.com/computers/flex-fast-compiler-update.html</link>
		<comments>http://www.vershun.com/computers/flex-fast-compiler-update.html#comments</comments>
		<pubDate>Sat, 01 May 2010 08:25:35 +0000</pubDate>
		<dc:creator>Vershun</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[fast compilation]]></category>
		<category><![CDATA[fast compile times]]></category>
		<category><![CDATA[fcsh]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://www.vershun.com/?p=319</guid>
		<description><![CDATA[Since this app seemed to be fairly well received, I made a few changes and threw the code up on github. I fixed a few issues regarding doing thread-unsafe things.  I also put in functionality for your compilation defaults to load from a file.  Disabled the use of multiple tabs (1 FCSH per instance of [...]]]></description>
			<content:encoded><![CDATA[<p>Since this app seemed to be fairly well received, I made a few changes and threw the code up on github.</p>
<p>I fixed a few issues regarding doing thread-unsafe things.  I also put in functionality for your compilation defaults to load from a file.  Disabled the use of multiple tabs (1 FCSH per instance of the app).</p>
<p>Github project URL: <a href="http://github.com/EvanMGates/Flex-FCSH-Frontend">http://github.com/EvanMGates/Flex-FCSH-Frontend</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.vershun.com/computers/flex-fast-compiler-update.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex Fast Compiler (FCSH frontend)</title>
		<link>http://www.vershun.com/computers/flex-fast-compiler-fcsh-frontend.html</link>
		<comments>http://www.vershun.com/computers/flex-fast-compiler-fcsh-frontend.html#comments</comments>
		<pubDate>Sun, 14 Mar 2010 07:39:06 +0000</pubDate>
		<dc:creator>Vershun</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[fcsh]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[Flex Builder 3]]></category>
		<category><![CDATA[slow compile]]></category>

		<guid isPermaLink="false">http://www.vershun.com/?p=310</guid>
		<description><![CDATA[Fast Flex Compiler (GUI frontend to FCSH with incremental compiling). SOURCE JAR Unzip source with 7-Zip, run jar with java -jar FastFlexCompile.jar. So if you&#8217;ve been working on large-scale projects in Flex (especially if they&#8217;re monolithic beasts), you have undoubtably noticed how slow the compiler is in Flex Builder 3. This is because (from what [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Fast Flex Compiler (GUI frontend to FCSH with incremental compiling).</strong></p>
<p><a href="http://www.vershun.com/projects/FastFlexCompiler/FastFlexCompileSource.7z">SOURCE</a> <a href="http://www.vershun.com/projects/FastFlexCompiler/FastFlexCompile.jar">JAR</a></p>
<p>Unzip source with 7-Zip, run jar with java -jar FastFlexCompile.jar.</p>
<p>So if you&#8217;ve been working on large-scale projects in Flex (especially if they&#8217;re monolithic beasts), you have undoubtably noticed how slow the compiler is in Flex Builder 3.  This is because (from what I could find) Flex Builder 3 doesn&#8217;t allow incremental compilations, which drastically speeds up compiling.</p>
<p><a href="http://www.vershun.com/wp-content/uploads/2010/03/FastFlexCompile.jpg"><img class="aligncenter size-medium wp-image-315" title="FastFlexCompile" src="http://www.vershun.com/wp-content/uploads/2010/03/FastFlexCompile-300x238.jpg" alt="" width="300" height="238" /></a></p>
<p>FCSH, which comes with the Flex SDK, does.  The problem with FCSH is it&#8217;s a pain in the ass to get setup and when you do every time you want to recompile you have to type &#8220;compile {target number},&#8221; it does not support the up arrow key for last command.</p>
<p>To make things a bit easier and to add highlighting, which I find useful, I made a quick Java Swing frontend to FCSH so you can enjoy quick compilation without dealing with FCSH directly.</p>
<p>To start:  Run the app by using the command:</p>
<blockquote><p>java -jar FlexFastCompile.jar</p></blockquote>
<p>Put in your SDK path using forward slashes for a Windows machine, making sure to omit the trailing &#8220;/&#8221;<br />
e.g.</p>
<blockquote><p>C:/Development/Flex Builder 3/sdks/3.5.0</p></blockquote>
<p>Put in your mxmlc command line arguments.  If you&#8217;re unfamiliar with the switches, check out the documentation <a title="MXMLC options" href="http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_13.html">here</a>.  The common ones are: -o (output swf), -file-specs=(application file), -libarary-path+=(library path) for library directories, and -sp+=(path) for source paths.</p>
<p>Click &#8220;Spawn New Compiler.&#8221;  This will execute FCSH and hold the session open in the tabbed window below.  To recompile that instance, hit the &#8220;Recompile&#8221; button.</p>
<p>You can change your sdk and arguments and open up multiple FCSH sessions in the tabbed windows.  Be sure to watch your memory usage as too many FCSH sessions can eat up your RAM right quick.</p>
<p><strong>Developer Notes</strong></p>
<p>The GUI and class skeletons was thrown together in NetBeans using Swing components.  The projects was then transferred into Eclipse because I&#8217;m more familiar with it.  There are probably still some artifacts from NetBeans in the source.</p>
<p>So the implementation ain&#8217;t pretty, and I&#8217;m actually passing the Swing JTextArea component down to the output reader threads directly (didn&#8217;t feel like messing with thread management much for such a quick and dirty project).  To avoid the possibility of race conditions, I&#8217;m using the JTextArea as a lock for the synchronized block that handles the highlighting (:cringe:).  If you want to customize this code for further development, that would be the first place I&#8217;d start.</p>
<p>To change the highlighting just edit the wordToLinePainter map in the FCSHOutputDump class.  Changing the colors can be done in FCSHOutputDump by editing the DefaultHighlightPainter instantiations.</p>
<p>Feel free to use the code for whateverthehell you want.  There&#8217;s no license on here and no warranties as well.  I ask if you do use or modify the code shoot me an e-mail or comment (I like to know if projects are useful or not).  Thanks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vershun.com/computers/flex-fast-compiler-fcsh-frontend.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Decentralized Distributed Flash Proof of Concept</title>
		<link>http://www.vershun.com/computers/decentralized-distributed-flash-proof-of-concept.html</link>
		<comments>http://www.vershun.com/computers/decentralized-distributed-flash-proof-of-concept.html#comments</comments>
		<pubDate>Sun, 14 Feb 2010 02:45:22 +0000</pubDate>
		<dc:creator>Vershun</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[decentralized]]></category>
		<category><![CDATA[distributed computing]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://www.vershun.com/?p=304</guid>
		<description><![CDATA[Finished my lil&#8217; project I&#8217;ve been working on. You can view it by clicking the link below. View the app and participate in the network. It doesn&#8217;t really have a name, but for the purposes of this post I&#8217;ll refer to it as DDFPOC (Decentralized Distributed Flash Proof-Of-Concept). DDFPOC is a prototype for a new [...]]]></description>
			<content:encoded><![CDATA[<p>Finished my lil&#8217; project I&#8217;ve been working on.  You can view it by clicking the link below.</p>
<p><a href="http://www.vershun.com/projects/decentralizedpoc/ui/DecentralizedProcessing.html">View the app and participate in the network.</a></p>
<p>It doesn&#8217;t really have a name, but for the purposes of this post I&#8217;ll refer to it as DDFPOC (Decentralized Distributed Flash Proof-Of-Concept).</p>
<p>DDFPOC is a prototype for a new way of utilizing web traffic for computational purposes.  Inspired by projects like <a href="http://boinc.berkeley.edu/">BOINC</a> and <a href="http://folding.stanford.edu/">Folding@Home</a>, I wanted to find a way to have casual web surfers participate in a computational network just by visiting a webpage.  Deviating from the BOINC and Folding@Home models and my prior <a href="http://www.vershun.com/computers/hidden-flash-applications-as-distributed-computing-clients.html">Flash-based distributed computing POC</a>, I also wanted information sharing across the clients as opposed to a central location that aggregates all the separate work units together.  Finally, I wanted to have a visual representation of the network so the users could see what&#8217;s happening within the network and what the work units were doing.</p>
<p><strong>Implementation Details</strong></p>
<p>The client-side application was programmed entirely in Flex and uses the awesome dependency graph provided with <a href="http://flare.prefuse.org/">Flare</a>.  The server-side code is in PHP5.  The Flash application makes framework and worker requests to the server in set intervals.  The framework requests are to get the status of the network &#8212; who is currently in the network, who&#8217;s connected to who, and statistics.  The worker messages are for sending and receiving messages about the current worker.</p>
<p>Spoiler: it&#8217;s not really decentralized.  I didn&#8217;t make the program to do Flash-to-Flash communication, so messages passed between clients are routed through the server.</p>
<div id="attachment_305" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.vershun.com/wp-content/uploads/2010/02/implementationNetwork.jpg"><img class="size-medium wp-image-305" title="implementationNetwork" src="http://www.vershun.com/wp-content/uploads/2010/02/implementationNetwork-300x225.jpg" alt="" width="300" height="225" /></a><p class="wp-caption-text">Green is a message in, red is that same message out.</p></div>
<p>There are 2 main parts to both the Flex and the PHP: the framework and the worker.  For Flex, the worker module only has to implement an interface.  If this project continues forward (which I doubt due to my project ADD), I would like to be able to add and remove worker modules during runtime.  That way the client could choose which project they would like to donate their CPU cycles to (much like BOINC).  The PHP is a bit more messy, and there&#8217;s a couple places where the implementation of the worker is coupled with the user management (such as clearing out expired users).  Aside from these few places, though, the PHP worker is pretty encapsulated and I don&#8217;t think it would be much work to make it entirely so.</p>
<p><strong>What&#8217;s With The Number Guesser?</strong></p>
<p>I chose to implement a random number guesser as the first POC worker for the following reasons: it&#8217;s easy to understand, the knowledge sharing is trivial, it didn&#8217;t have to be very visual.</p>
<p>On the PHP side: if there is no work unit out (a number had recently been found), the PHP worker generates a new number between 1-1000 and informs the client that there&#8217;s a new work unit.</p>
<p>On the Flash side: keep guessing numbers between 1-1000 until you find the answer or someone else does.</p>
<p>The knowledge sharing works as follows:  keep track of the numbers you guess and tell the neighbors you&#8217;re linked to what numbers you&#8217;ve tried.  When a neighbor informs you of their guesses, add them to your &#8220;already guessed&#8221; pile.  Forward on to your neighbor&#8217;s guesses to your neighbors.  Eventually the network will guess the number using all of the clients&#8217; memory of guessed numbers.</p>
<p><strong>In The Future</strong></p>
<p>This project was made to be throw-away, but if it were to continue forward I&#8217;d first like to completely decouple the framework and worker on the server side.  Next would be making the Flash worker load dynamically.</p>
<p>What I&#8217;d love to see is an actual application for this.</p>
<p><strong>Notes</strong></p>
<p>Keep in mind this is a POC and isn&#8217;t well tested, I expect bugs <img src='http://www.vershun.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<p>Also, if there&#8217;s any interest I&#8217;d be happy to release the source code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vershun.com/computers/decentralized-distributed-flash-proof-of-concept.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Barebones application for visualizing swarms (2D)</title>
		<link>http://www.vershun.com/computers/visualizing-swarms/barebones-application-for-visualizing-swarms-2d.html</link>
		<comments>http://www.vershun.com/computers/visualizing-swarms/barebones-application-for-visualizing-swarms-2d.html#comments</comments>
		<pubDate>Sun, 17 May 2009 04:36:41 +0000</pubDate>
		<dc:creator>Vershun</dc:creator>
				<category><![CDATA[Visualizing Swarms]]></category>

		<guid isPermaLink="false">http://www.vershun.com/?p=254</guid>
		<description><![CDATA[So I&#8217;ve decided to play around a bit for my own giggles and make some swarm stuff.  Emergent behavior is the bee&#8217;s knees and I think it will be a lot of fun to code up some visual representations of it. This is the very first step in the processes.  It&#8217;s not quite a &#8220;framework,&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve decided to play around a bit for my own giggles and make some swarm stuff.  Emergent behavior is the bee&#8217;s knees and I think it will be a lot of fun to code up some visual representations of it.</p>
<p>This is the very first step in the processes.  It&#8217;s not quite a &#8220;framework,&#8221; but more of a template.  Click to activate the ants, slide to change the speed.</p>
<p><object width="505" height="375" data="http://www.vershun.com/projects/ants_template/ants.swf" type="application/x-shockwave-flash"><param name="quality" value="high" /><param name="bgcolor" value="#869ca7" /><param name="allowScriptAccess" value="sameDomain" /><param name="src" value="http://www.vershun.com/projects/ants_template/srcview" /></object></p>
<p>You can right click and view source.  The code is very rudimentary and the only slightly interesting part is how the ants decide to move.</p>
<blockquote>
<pre>var stuckCounter:int = 90;

do
{
	var randomAngle:uint = rotation + ((Math.random() * stuckCounter) - (stuckCounter / 2));
	var randomDistance:uint = Math.random() * 70 + 10;

	var randX:int = randomDistance * Math.cos(randomAngle * (Ant.TO_RADIANS));
	var randY:int = randomDistance * Math.sin(randomAngle * (Ant.TO_RADIANS));
	stuckCounter++;
} while (environment.isObstructionInPath(x, y, x + randX, y + randY));</pre>
</blockquote>
<p>The code is pretty self explanatory (hopefully), but basically the ant is choosing a random direction within its scope (45 degrees both left and right of it&#8217;s current rotation), generates a random distance to travel, and checks with the environment to make sure there&#8217;s no obstructions within its projected trajectory.  If there&#8217;s an obstruction, add 1 degree to the randomizer and repeat.  Using randomly chosen angles along with a slow increase in the randomized range helps give a more realistic look of obstacle avoidance than other methods (say, flipping rotation).</p>
<p>I&#8217;ll be adding more to this section when I get some motivated down time to play, but this week it&#8217;s all about the R&#038;R.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vershun.com/computers/visualizing-swarms/barebones-application-for-visualizing-swarms-2d.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easter Boredom Project:  The Adaptive Culture Model</title>
		<link>http://www.vershun.com/computers/easter-boredom-project-the-adaptive-culture-model.html</link>
		<comments>http://www.vershun.com/computers/easter-boredom-project-the-adaptive-culture-model.html#comments</comments>
		<pubDate>Tue, 14 Apr 2009 04:28:35 +0000</pubDate>
		<dc:creator>Vershun</dc:creator>
				<category><![CDATA[Computers]]></category>

		<guid isPermaLink="false">http://www.vershun.com/?p=236</guid>
		<description><![CDATA[So 3-4 years ago I picked up a really neat book on Swarm Intelligence and in it there were a few pages on the Adaptive Culture Model.  I really liked the concept (algorithmically simple and pretty) so I coded up a quick and dirty OpenGL app for it. Well, for whatever reason, I thought of it [...]]]></description>
			<content:encoded><![CDATA[<p>So 3-4 years ago I picked up a really neat book on <a href="http://www.amazon.com/Swarm-Intelligence-Morgan-Kaufmann-Artificial/dp/1558605959/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1239681005&amp;sr=8-1">Swarm Intelligence</a> and in it there were a few pages on the Adaptive Culture Model.  I really liked the concept (algorithmically simple and pretty) so I coded up a quick and dirty OpenGL app for it.</p>
<p>Well, for whatever reason, I thought of it a couple days ago and took a day off doing actual work to play with ACM in Flex.</p>
<p>Quick concept rundown.  So basically (from what I remember, don&#8217;t quote me) the adaptive culture model describes how information is spread throughout a population, specifically beneficial traits.  I guess an example of this would be success and proximity.  You notice a neighbor being successful, so you incorporate some of their traits into your life in hopes of you being more successful.  This goes from neighbor to neighbor until the successful traits are assimulated into the whole population.  Geography is just an example.  This can also model information spreading through virtual networks and other such fun stuff.</p>
<p>I implemented a quick and dirty presentation of this concept in Flex.  Success is rated by closeness to the target color you choose.  When you click on a couple squares it randomly checks a neighbor to see if it is more successful.  If it is, the neighbor assimilates one of its neighbors traits, which in this case is randomly either the red, green, or blue component.  If the square updates it notifies its neighbors of the change and they go through the same process.</p>
<p>You can change the color while the program is running if you feel like it.  There&#8217;s a lot more stuff that&#8217;s easily configurable but I got bored of this and am setting it aside for a while.  I&#8217;ll release the source when I come back to it later.</p>
<p> <br />
<object width="500" height="400" data="http://www.vershun.com/projects/ACMv1/ACM.swf" type="application/x-shockwave-flash"><param name="quality" value="high" /><param name="bgcolor" value="#869ca7" /><param name="allowScriptAccess" value="sameDomain" /><param name="src" value="http://www.vershun.com/projects/ACMv1/ACM.swf" /></object><br />
 </p>
<p>It might take a few clicks for the process to start.  Just select your color and keep clicking; when the queue starts filling up you&#8217;ll know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vershun.com/computers/easter-boredom-project-the-adaptive-culture-model.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hidden Flash Applications as Distributed Computing Clients</title>
		<link>http://www.vershun.com/computers/hidden-flash-applications-as-distributed-computing-clients.html</link>
		<comments>http://www.vershun.com/computers/hidden-flash-applications-as-distributed-computing-clients.html#comments</comments>
		<pubDate>Wed, 31 Dec 2008 21:46:15 +0000</pubDate>
		<dc:creator>Vershun</dc:creator>
				<category><![CDATA[Computers]]></category>

		<guid isPermaLink="false">http://www.vershun.com/?p=218</guid>
		<description><![CDATA[Made a quick and dirty program that I ran last night. So it sends a request for a &#8220;work unit&#8221; on a different server I have running a PHP script that builds some simple XML that looks something like: &#60;assignment&#62; &#60;type&#62;MD5&#60;/type&#62; &#60;hash&#62;6ded1c8c8b157a391e618ca39eb11e39&#60;/hash&#62; &#60;prefix&#62;Ab$x&#60;/prefix&#62; &#60;/assignment&#62; The program grinds through building MD5 hashes using the prefix and [...]]]></description>
			<content:encoded><![CDATA[<p>Made a quick and dirty program that I ran last night.</p>
<p>So it sends a request for a &#8220;work unit&#8221; on a different server I have running a PHP script that builds some simple XML that looks something like:</p>
<blockquote><p>&lt;assignment&gt;<br />
&lt;type&gt;MD5&lt;/type&gt;<br />
&lt;hash&gt;6ded1c8c8b157a391e618ca39eb11e39&lt;/hash&gt;<br />
&lt;prefix&gt;Ab$x&lt;/prefix&gt;<br />
&lt;/assignment&gt;</p></blockquote>
<p>The program grinds through building MD5 hashes using the prefix and the next 2 characters.  Since this was just a test I&#8217;m only testing 126 characters so each work unit generates 15876 MD5 hashes and compares it to the target hash defined in the XML.</p>
<p>I made it so it&#8217;ll never find the hash because I wanted to test full work unit work so after it failed to find a match it returns its results to the server and requests a new assignment from the server.</p>
<p>Rinse.  Repeat.</p>
<p>So I got 57 hits during the testing phase with a return of 1128 work units.  This is roughly 18 million MD5 hashes tested.</p>
<p>I&#8217;m probably not going to pursue the MD5 collision thing (there&#8217;s much better ways of finding collisions instead of just brute forcing it anyway), but it&#8217;s an example of how hidden Flash applications can be used to put your traffic to work.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vershun.com/computers/hidden-flash-applications-as-distributed-computing-clients.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hooray for days off work!</title>
		<link>http://www.vershun.com/computers/hooray-for-days-off-work.html</link>
		<comments>http://www.vershun.com/computers/hooray-for-days-off-work.html#comments</comments>
		<pubDate>Sun, 08 Jun 2008 09:33:52 +0000</pubDate>
		<dc:creator>Vershun</dc:creator>
				<category><![CDATA[Computers]]></category>

		<guid isPermaLink="false">http://www.vershun.com/?p=63</guid>
		<description><![CDATA[Our planned day off didn&#8217;t come together very well.  However, we only worked 15 hours today! 5:30 AM right now and still on the grind &#62;.&#60;  If C# would fucking support SOCKS proxies I&#8217;d probably be in bed right now. So I&#8217;m building an HTTP proxy bridge that will be run locally and cycle through [...]]]></description>
			<content:encoded><![CDATA[<p>Our planned day off didn&#8217;t come together very well.  However, we only worked 15 hours today!</p>
<p>5:30 AM right now and still on the grind &gt;.&lt;  If C# would fucking support SOCKS proxies I&#8217;d probably be in bed right now.</p>
<p>So I&#8217;m building an HTTP proxy bridge that will be run locally and cycle through proxy lists, that way C# (or any other language that doesn&#8217;t support SOCKS) can use the local HTTP proxy and still get the benefits of other proxies.  If anyone is interested e-mail me and I&#8217;ll throw over the program and API specs probably.</p>
<p>Edit:</p>
<p>Went home at 6:30 AM.  Certainly can&#8217;t complain about a morning like this though:</p>
<p><img src="http://www.vershun.com/images/ohio-trip/morning.JPG" alt="Morning in Middletown Ohio" width="568" height="426" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.vershun.com/computers/hooray-for-days-off-work.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Skeleton to load in netflixprize values</title>
		<link>http://www.vershun.com/computers/skeleton-to-load-in-netflixprize-values.html</link>
		<comments>http://www.vershun.com/computers/skeleton-to-load-in-netflixprize-values.html#comments</comments>
		<pubDate>Thu, 11 Oct 2007 04:17:32 +0000</pubDate>
		<dc:creator>Vershun</dc:creator>
				<category><![CDATA[Computers]]></category>

		<guid isPermaLink="false">http://www.vershun.com/computers/skeleton-to-load-in-netflixprize-values.html</guid>
		<description><![CDATA[It&#8217;s probably not the best code, but it doesn&#8217;t leave too large of a memory footprint and gives you nice access to the data. This was compiled with Dev-C++ but should be find under Linux if you change the system(&#8220;pause&#8221;);. Oh and the filepath, of course. WordPress wreaked havoc on the code hopefully it works [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s probably not the best code, but it doesn&#8217;t leave too large of a memory footprint and gives you nice access to the data.</p>
<p>This was compiled with Dev-C++ but should be find under Linux if you change the system(&#8220;pause&#8221;);.  Oh and the filepath, of course.  WordPress wreaked havoc on the code hopefully it works (I doubt anyone will use it anyway this is mainly for my own personal giggles).</p>
<pre>
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;

//Constants
const int NUM_USERS = 480189;
const int NUM_MOVIES = 17770;
const int HASH_MOD = 500000;

/*** training grid
*  Matrix is sparsely populated and will get stack overflows if I try to fill
*  it with a static array.  Use a doubly linked list for rows and columns (movies
*  and users, respectively).
*/
typedef struct rating_node
{
   int movieid, userid;
   char rating;  //char to save space, static cast
   struct rating_node *next_movie;  //This traverses the row, goes to next user in rating matrix
   struct rating_node *next_user;  //This traverses the column, use this for going down movie list
} rating;

//for user hash table
typedef struct hash_node
{
   int userid;
   struct hash_node *next_uid;  //This traverses the hash nodes, use this for finding correct userid
   struct rating_node *user_col;  //This is a pointer to the head node for the user column
} hash;

//Prototypes

//Load Netflix data into arrays
void buildMatrixFromData(rating **movies, hash **users, char *trainingSetPath); //where movies and users are the head node arrays
//Training algorithm
static inline void train_set(int user, int movie, double rating);
//Add a node to the movie row
static inline void addToMovieRow(rating **head, rating *newnode);
//Add a new user on user column
void addToUserCol(hash ***head, rating *newnode);

//Debugging prototypes
void printMovieRow(rating *headnode);
void printUserColumn(hash **headnode, int userid);
void printNode(rating *node);

int main()
{
    //build the head node vectors
    rating *movies[NUM_MOVIES];  //static array of linked list elements
    hash *users[HASH_MOD];  //This is a hash table with linked heads that go to the linked list user columns.
    //Note:  I didn't check for relative primes (I'm pissed enough about recoding but performance was terrible).

    buildMatrixFromData(movies, users, "C:\netflix\training_set\training_set");

    system("pause");
}

void buildMatrixFromData(rating **movies, hash **users, char *trainingSetPath)
{
    int mid = 1;
    int uid, rat, idx;

    for(mid = 1; mid &lt; NUM_MOVIES; mid++)
    {
        FILE *fp;

        char filename[strlen(trainingSetPath) + 15];
        char num[12];
        strcpy(filename, trainingSetPath);
        sprintf(num, "mv_%07d.txt", mid);
        strcat(filename, num);

        fp = fopen(filename, "r");

        //the first line is junk, skip it
        fscanf(fp, "%d:", &amp;uid);

        while(fscanf(fp, "%d,%d,%*s", &amp;uid, &amp;rat) != EOF)
        {
          //Create new node for rating
          rating *newrat;
          if ((newrat = (rating*)malloc(sizeof(*newrat))) == NULL)
          {
             exit(EXIT_FAILURE);
          }
          newrat-&gt;movieid = mid;
          newrat-&gt;rating = rat;
          newrat-&gt;userid = uid;
          newrat-&gt;next_movie = newrat-&gt;next_user = NULL;

          addToMovieRow(&amp;movies[mid-1], newrat);

          addToUserCol(&amp;users, newrat);
        }
        fclose(fp);

        //For testing movie vector
        //printMovieRow(movies[mid-1]);
    }

    //For testing hash table
    //printUserColumn(users, 1806515);
}

static inline void addToMovieRow(rating **head, rating *newnode)
{
     //base case
     if(head == NULL)
     {
             *head = newnode;
     }
     else
     {
         newnode-&gt;next_user = *head;
         *head = newnode;
     }
}

void addToUserCol(hash ***head, rating *newnode)
{
     //use hash
     hash **hashhead = &amp;((*head)[newnode-&gt;userid % HASH_MOD]);
     hash *tmp = (*head)[newnode-&gt;userid % HASH_MOD];
     //base case
     if(tmp == NULL)
     {
         //Create the new hashnode
         hash *newhash = (hash*)malloc(sizeof(*newhash));
         newhash-&gt;next_uid = NULL;
         newhash-&gt;user_col = newnode;
         newhash-&gt;userid = newnode-&gt;userid;
         *hashhead = newhash;
     }
     else
     {
         while(tmp != NULL)
         {
             if(tmp-&gt;userid == newnode-&gt;userid)
             {
                 newnode-&gt;next_movie = tmp-&gt;user_col;
                 tmp-&gt;user_col = newnode;
                 return;
             }
             tmp = tmp-&gt;next_uid;
         }
         //userid not in hash list
         hash *newhash = (hash*)malloc(sizeof(*newhash));
         newhash-&gt;next_uid = *hashhead;
         newhash-&gt;user_col = newnode;
         newhash-&gt;userid = newnode-&gt;userid;
         *hashhead = newhash;
     }
}

void printMovieRow(rating *headnode)
{
     if(headnode == NULL)
     {
             printf("Head node empty!n");
     }
     else
     {
         rating *tmp = headnode;
         while(tmp != NULL)
         {
             printNode(tmp);
             tmp = tmp-&gt;next_user;
         }
     }
}

void printUserColumn(hash **headnode, int userid)
{
     hash *head = headnode[userid % HASH_MOD];
     if(head == NULL)
     {
             printf("Head node empty!n");
     }
     else
     {
         hash *tmp = head;
         while(tmp != NULL)
         {
             if(tmp-&gt;userid == userid)
             {
                //Found our head, traverse down it printing nodes
                rating *rat = tmp-&gt;user_col;
                while(rat != NULL)
                {
                    printNode(rat);
                    rat = rat-&gt;next_movie;
                }
             }
             tmp = tmp-&gt;next_uid;
         }
     }
}

void printNode(rating *node)
{
     printf("mid: %d,  rating: %d,  uid: %dn", node-&gt;movieid, node-&gt;rating, node-&gt;userid);
}</pre>
<p>Note on the data structures:   You can basically think of this as a matrix.  The rows are the movies and you can access the linked list of users through the static array &#8220;movies.&#8221;  The columns require a bit of work.  For speed purposes (and because they&#8217;re not sequential) they&#8217;re stored as a hash table.  To get to a specific user, mod the user&#8217;s id by HASH_MOD (this value is fairly arbitrary, I just went for a high number so there should be minimal collisions).  This will get you the head node of the hash linked list.  Traverse through using next_uid checking the userid in the hash node until you find yours.  The pointer &#8220;user_col&#8221; points to the head rating node for that user.</p>
<p>Just a skeleton, if anyone has any other ideas or suggestions be sure to hit me up, this was just a quick, whirlwind approach I had.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vershun.com/computers/skeleton-to-load-in-netflixprize-values.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Debian Etch on IBM JS20s</title>
		<link>http://www.vershun.com/computers/installing-debian-etch-on-ibm-js20s.html</link>
		<comments>http://www.vershun.com/computers/installing-debian-etch-on-ibm-js20s.html#comments</comments>
		<pubDate>Fri, 22 Jun 2007 17:48:34 +0000</pubDate>
		<dc:creator>Vershun</dc:creator>
				<category><![CDATA[Computers]]></category>
<category>debian</category><category>etch</category><category>IBM</category><category>installing</category><category>JS20</category><category>linux</category>
		<guid isPermaLink="false">http://www.vershun.com/computers/installing-debian-etch-on-ibm-js20s.html</guid>
		<description><![CDATA[The developers at Debian have made installing Etch on the IBM JS20 pretty easy for us. You no longer have to hack out a PReP boot using SuSE or any of those sorts of old hacks. There are, however, a couple of gotchas that still exist. Here&#8217;s a simple guide to get Debian up on [...]]]></description>
			<content:encoded><![CDATA[<p>The developers at Debian have made installing Etch on the IBM JS20 pretty easy for us.  You no longer have to hack out a PReP boot using SuSE or any of those sorts of old hacks.  There are, however, a couple of gotchas that still exist.</p>
<p>Here&#8217;s a simple guide to get Debian up on your IBM JS20 using CD as a medium:</p>
<p>Download the PowerPC architecture ISO from Debian&#8217;s site.  I&#8217;d recommend getting the netinst just for getting the base system up.</p>
<p>Burn the CD and put it in the JS20&#8242;s media bay.  Push the CD button on the blade you&#8217;re installing to (it should light up green).</p>
<p>Go into your management module and set the boot sequence of that blade to CD-ROM (under Blade Tasks -&gt; Configuration).</p>
<p>Reboot the blade and start up a rconsole, you can do this by:</p>
<blockquote><p>sudo rpower -n node reboot &amp;&amp; sudo roconsole -n node -c -t &amp;</p></blockquote>
<p>When you get the boot:   screen, use the 64-bit kernel by typing in &#8220;install64&#8243; or &#8220;expert64&#8243;, depending on how much you&#8217;d like to customize the installation.</p>
<p>Go through the installation process as normal.  Make SURE you do not change the /dev/hda1 partition.  It should be about 8.2 megs and formatted as a PReP boot.</p>
<p>After your installation, the CD will pop out of the tray and will reboot.  This isn&#8217;t good for us since we need the CD for the next step and so you&#8217;ll have to physically put it back it.</p>
<p>Boot off the CD once more, but load up the kernel  &#8220;rescue64&#8243;.  Go through the steps and spawn a shell on your root partition.</p>
<p>The reason why you&#8217;re using the rescue CD is because inittab will try to spawn getty on virtual terminals instead of SOL&#8217;s interface.   Edit the /etc/inittab in your favorite editor and add the line:</p>
<blockquote><p>hvc0:1235:respawn:/sbin/getty -L 9600 hvc0 vt100</p></blockquote>
<p>Above the other getty commands (should start with 1, 2, .. 7).</p>
<p>Now go back into the management module, change the boot sequence to Hard Drive 0, and reboot your blade for a fresh install of Debian Etch!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vershun.com/computers/installing-debian-etch-on-ibm-js20s.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IBM&#8217;s JS20 SOL keeps returning to system&gt; with any keystroke</title>
		<link>http://www.vershun.com/computers/ibm-js20-sol-returning-to-system-with-keystroke.html</link>
		<comments>http://www.vershun.com/computers/ibm-js20-sol-returning-to-system-with-keystroke.html#comments</comments>
		<pubDate>Tue, 19 Jun 2007 23:05:55 +0000</pubDate>
		<dc:creator>Vershun</dc:creator>
				<category><![CDATA[Computers]]></category>
<category>IBM</category><category>JS20</category><category>SOL</category><category>system</category>
		<guid isPermaLink="false">http://www.vershun.com/computers/ibms-js20s-sol-keeps-returning-to-system-with-any-keystroke.html</guid>
		<description><![CDATA[This is ridiculously annoying, since the SOL allows you to watch console prompts come up but kicks you out if you try to send any characters. rpowering the blade won&#8217;t work, so what you have to do is physically pull the blade and pop it back in. While it&#8217;s out you might want to take [...]]]></description>
			<content:encoded><![CDATA[<p>This is ridiculously annoying, since the SOL allows you to watch console prompts come up but kicks you out if you try to send any characters.  rpowering the blade won&#8217;t work, so what you have to do is physically pull the blade and pop it back in.  While it&#8217;s out you might want to take a look at the hardware and make sure everything looks fine.</p>
<p>After inserting the blade, either flip up the LED shield and hit the power button or you can do a rpower -n node on and SOL should come up within a couple seconds.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vershun.com/computers/ibm-js20-sol-returning-to-system-with-keystroke.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
