<?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>Ranok&#039;s Ramblings &#187; erlang</title>
	<atom:link href="http://www.r4n0k.com/tag/erlang/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.r4n0k.com</link>
	<description>A peek into my life, and the projects I never complete</description>
	<lastBuildDate>Sat, 04 Feb 2012 16:36:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Introduction to Mnesia I</title>
		<link>http://www.r4n0k.com/2009/10/14/introduction-to-mnesia-i/</link>
		<comments>http://www.r4n0k.com/2009/10/14/introduction-to-mnesia-i/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 18:56:31 +0000</pubDate>
		<dc:creator>ranok</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[dbms]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[mnesia]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.r4n0k.com/?p=203</guid>
		<description><![CDATA[Today in my Advanced Concepts in Operating Systems class I led the discussion on the Mnesia paper from PADL&#8217;99, while this paper has numerous typos it does do an excellent job highlighting the features and advantages of Mnesia. For those of you who are unaware, Mnesia is a distributed, fault-tolerant object DBMS written in Erlang. [...]]]></description>
			<content:encoded><![CDATA[<p>Today in my Advanced Concepts in Operating Systems class I led the discussion on the <a href="http://www.erlang.se/publications/mnesia_overview.pdf">Mnesia paper</a> from PADL&#8217;99, while this paper has numerous typos it does do an excellent job highlighting the features and advantages of Mnesia. For those of you who are unaware, Mnesia is a distributed, fault-tolerant object DBMS written in Erlang. One thing about Mnesia that I have found to be lacking is a tutorial written for the lay person from the ground up, this gap I intend to try and fill. This multi-segment tutorial assumes you have knowledge of Erlang, and the basic  concepts of manipulating data with DBMSes, other than that, I hope to provide enough information and code to demystify a fairly complex system. However, I still am on the road to mastery, so if I make any errors, or you have any tips for improvement, I&#8217;d be happy to add them in.</p>
<p>To get started, start up the Erlang shell (erl) with a name, I will use -sname foo in the following examples. Below is a transcript of starting up and creating a disk-based</p>
<div class="hl-container">
<div class="hl-main">
<pre><span class="hl-code">ranok@orion:~/Desktop$ erl -sname foo
Erlang R13B01 (erts-5.7.2) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.2  (abort with ^G)
(foo@orion)1&gt; mnesia:create_schema([node()]).
ok
(foo@orion)2&gt; mnesia:start().
ok</span></pre>
</div>
</div>
<p>The most important call made here, create_schema, takes a list of nodes to replicate the schema table to on disk. You can add additional disk-based nodes or ram-based copies later (we&#8217;ll get to the details later). After you&#8217;ve created the schema (this will make a folder for all the Mnesia table data), you can start the application with the start function.</p>
<p>Now that we have the database running, we need at least one table to store the data in, we will start with a very simple record to just store simple key/value data. The nice thing about Mnesia, is that the data we store can be pretty much anything, from a simple atom to a function. We will start learning the basics from the mnesia_test module, which I have <a href="http://code.jitunleashed.com/mnesia/mnesia_test.erl">uploaded here</a>.</p>
<p>The first few lines of the module start off like any Erlang code, a module declaration, what functions to export, including the QLC (Query List Comprehensions) include file (you may need to find it for your system) and a record definition:</p>
<div class="hl-container">
<div class="hl-main">
<pre><span class="hl-code">-record(data, {key, value}).</span></pre>
</div>
</div>
<p>Which will define our record for the table also named data. In the function setup_and_start/0, we tie in what we already went over with the create_table function, which in our case looks like</p>
<div class="hl-container">
<div class="hl-main">
<pre><span class="hl-code">mnesia:create_table(data, [{disc_copies, [node()]}, {attributes, record_info(fields, data)}])</span></pre>
</div>
</div>
<p>The <a href="http://erlang.org/doc/man/mnesia.html#create_table-2">create_table</a> function has a number of options, the most basic of which we will deal with at the moment: the name of the new table, where and how the table will be stored and what fields the table has (this code used the record_info() function to pull those out of the data record for us). Now that we have our table, we need a way to get the data in and out of it.</p>
<p>Many databases provide the ability for multiple queries to be joined into one transaction to be executed atomically. Mnesia is no different, but for the most part, all queries are executed through the transaction manager (there is a dirty interface which will be discussed later), this makes working in a distributed environment much easier. The way to perform a transaction in Mnesia is to pass a fun to the mnesia:transaction() function that will atomically run.</p>
<p>The actual function to enter data (both insert and update) is write(Record). We wrap this into the mnesia_test:insert(Key, Val) function displayed below:</p>
<div class="hl-container">
<div class="hl-main">
<pre><span class="hl-code">insert(Key, Val) -&gt;
Record = #data{key = Key, value = Val},
F = fun() -&gt;
mnesia:write(Record)
end,
mnesia:transaction(F).</span></pre>
</div>
</div>
<p>To now retrieve this data back from the database, the read function is now used, the read function takes two arguments: the table name (in this case, data) and the key to retrieve. The mnesia_test retrieve function wraps this nicely for us, and is shown below:</p>
<div class="hl-container">
<div class="hl-main">
<pre><span class="hl-code">retrieve(Key) -&gt;
F = fun() -&gt;
mnesia:read({data, Key})
end,
{atomic, Data} = mnesia:transaction(F),
Data.</span></pre>
</div>
</div>
<p>mnesia:transaction will either return {aborted, Reason} or {atomic, Rows}, where Rows is a list of all the retrieved data. If the key we tried to retrieve could not be found, then it will return an empty list.</p>
<p>Say however, we want to search the table for certain values that are not the index of the table. For that there is the matching functions, the simplest of them is the match_object whose usage can be seen here:</p>
<div class="hl-container">
<div class="hl-main">
<pre><span class="hl-code">search(Val) -&gt;
F = fun() -&gt;
mnesia:match_object(#data{key = '_', value = Val})
end,
{atomic, Data} = mnesia:transaction(F),
Data.</span></pre>
</div>
</div>
<p>As you can see, simply fill in all the values that are known and that you want to search for, and use the &#8216;_&#8217; unmatched value for all the other values. This transaction will return the same forms as the read transaction.</p>
<p>There is another method for filtering through Mnesia tables, which is very similar to the list comprehensions builtin to Erlang which is called QLC. The QLC version of the above function is below:</p>
<div class="hl-container">
<div class="hl-main">
<pre><span class="hl-code">search_qlc(Val) -&gt;
F = fun() -&gt;
qlc:eval(
qlc:q(
[X || X &lt;- mnesia:table(data), X#data.value == Val]
))
end,
{atomic, Data} = mnesia:transaction(F),
Data.</span></pre>
</div>
</div>
<p>What the query here is doing is is returning a list of Xs where every possible X comes from our data table, and X#data.value == Val. This should be very intuitive for those of you who are familiar with list comprehensions. What qlc:q() does is form a query handle (much like a function object) which gets evaluated by qlc:eval() inside of our transaction object. Again, this will return the same values from mnesia:transaction.</p>
<p>Well, that about covers the basics of Mnesia, you now should be able to setup Mnesia on your computer, create a table and insert/retrieve data from it. In the next installment, we will look at distributed Mnesia and the dirty interface, which provides faster queries by bypassing the transaction manager. After that we will put all of what we&#8217;ve learned into creating a system that will take advantage of Mnesia and give a pseudo real-world problem a fitting solution. Please check back soon for the next installment!</p>
<p>Peace and chow,</p>
<p>Ranok</p>
]]></content:encoded>
			<wfw:commentRss>http://www.r4n0k.com/2009/10/14/introduction-to-mnesia-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Inets &#8211; Erlang&#8217;s Builtin Web Daemon</title>
		<link>http://www.r4n0k.com/2009/05/02/using-inets-erlangs-builtin-web-daemon/</link>
		<comments>http://www.r4n0k.com/2009/05/02/using-inets-erlangs-builtin-web-daemon/#comments</comments>
		<pubDate>Sat, 02 May 2009 21:31:03 +0000</pubDate>
		<dc:creator>ranok</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[inets]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[osp]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.r4n0k.com/?p=183</guid>
		<description><![CDATA[A feature I&#8217;ve been meaning to add to Open Server Platform for a while is a web management system, where an administrator can login and manage the cluster and the servlets running on it. I&#8217;d like there to be a user friendly interface for administrators to start, stop and migrate servlets across the different nodes [...]]]></description>
			<content:encoded><![CDATA[<p>A feature I&#8217;ve been meaning to add to <a href="http://www.openserverplatform.com">Open Server Platform</a> for a while is a web management system, where an administrator can login and manage the cluster and the servlets running on it. I&#8217;d like there to be a user friendly interface for administrators to start, stop and migrate servlets across the different nodes of the system and a way to upload a servlet file and have it compiled and distributed across the cluster.</p>
<p>The simplest way to start serving web content with Erlang is to use the inets server and the httpd service. This is a HTTP/1.1 server built into the Erlang distribution that supports some more advanced features, most interesting of all, the ability to use Erlang to dynamically generate content. It is however very poorly documented, and there are a few very annoying things I came across that I&#8217;m posting to hopefully help anyone else trying to get it working.</p>
<ol>
<li>The order of modules in the <code>{modules, []}</code> directive matters, if you want to have mod_dir work, it needs to be specified *AFTER* the mod_alias.</li>
<li>The logging is rather horrid, the transfer.log will not log anything except for HTTP 200 for every request, even if it failed.</li>
<li>You must specify <code>{bind_address, any}</code> in the configuration to use the <code>httpd:reload_config</code> function, otherwise it will return <code>{error, not_started}</code></li>
<li>If you just want to server static content, you will need at a minimum the following modules: mod_get, mod_head, mod_log, mod_actions and mod_range. However, adding mod_alias is recommended along with the <code>{directory_index, ["index.html"]}</code> directive to stop it from failing (HTTP 500) on a directory request.</li>
<li>To use dynamic content, create a module that exports callbacks of the form: <code>function(SessionID, _Env, _Input)</code>. To write Str back to the client, use the <code>mod_esi:deliver(SessionID, Str)</code> function.</li>
</ol>
<p>I hope that this helps out!</p>
<p>Peace and chow,</p>
<p>Ranok</p>
]]></content:encoded>
			<wfw:commentRss>http://www.r4n0k.com/2009/05/02/using-inets-erlangs-builtin-web-daemon/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Open Server Platform Version 0.3 Released!</title>
		<link>http://www.r4n0k.com/2009/04/21/osp-version-03-released/</link>
		<comments>http://www.r4n0k.com/2009/04/21/osp-version-03-released/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 23:14:27 +0000</pubDate>
		<dc:creator>ranok</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[mnesia]]></category>
		<category><![CDATA[osp]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://www.r4n0k.com/?p=179</guid>
		<description><![CDATA[Today I finally got around to going through and testing the RC for version 0.3 of Open Server Platform. Everything seemed to work as planned, except for a few known issues that will be fixed in the next release, which should be coming down the pipe soon. Improvements: Added replication nodes to increase fail-safe reliability [...]]]></description>
			<content:encoded><![CDATA[<p>Today I finally got around to going through and testing the RC for <a href="http://groups.google.com/group/openserverplatform/browse_thread/thread/101e2a449b87e648">version 0.3</a> of <a href="http://openserverplatform.com/">Open Server Platform</a>. Everything seemed to work as planned, except for a few known issues that will be fixed in the next release, which should be coming down the pipe soon.</p>
<p>Improvements:</p>
<ul>
<li>Added replication nodes to increase fail-safe reliability</li>
<li>Added commands to the administration console to stop and live migrate applications</li>
<li>Can use configuration files to assist in the start up of OSP</li>
<li>Many bug fixes and documentation updates</li>
<li>The HTTPd servlet example now supports large files and the HEAD command</li>
</ul>
<p>So, please check it out and let me know what you think!</p>
<p>Peace and chow,</p>
<p>Ranok</p>
]]></content:encoded>
			<wfw:commentRss>http://www.r4n0k.com/2009/04/21/osp-version-03-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Back in the Groove</title>
		<link>http://www.r4n0k.com/2009/04/07/back-in-the-groove/</link>
		<comments>http://www.r4n0k.com/2009/04/07/back-in-the-groove/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 04:23:12 +0000</pubDate>
		<dc:creator>ranok</dc:creator>
				<category><![CDATA[For Fun]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[osp]]></category>

		<guid isPermaLink="false">http://www.r4n0k.com/?p=176</guid>
		<description><![CDATA[After taking off the afternoon due to a migraine, and napping for a few hours until it passed, I was looking over some old projects, and decided to get motivated to work on my various Erlang hackery projects. I checked out a fresh copy of Open Server Platform on my new computer, and decided to [...]]]></description>
			<content:encoded><![CDATA[<p>After taking off the afternoon due to a migraine, and napping for a few hours until it passed, I was looking over some old projects, and decided to get motivated to work on my various Erlang hackery projects. I checked out a fresh copy of <a href="http://openserverplatform.com/">Open Server Platform</a> on my <a href="http://www.flickr.com/photos/ranok/3309567067/">new</a> <a href="http://www.flickr.com/photos/ranok/3310396142/">computer</a>, and decided to hack on it some more. There are a number of loose ends I&#8217;d like to tie up before the 0.3 release, but, before I could get down to coding, SVN get my so frustrated that I could no longer deal with it and switched to git, creating a <a href="http://github.com/ranok/open-server-platform/tree/master">new repository on Github</a>. I will keep the <a href="http://code.google.com/p/openserverplatform/">Google Code repository</a> the &#8216;defacto&#8217; repository, where the safer code gets committed, but use Github for the more bleeding edge development due to it&#8217;s simplified branching and merging (among other things).</p>
<p>In the new git setup, I have two branches (aside from master, which follows the SVN repository): otp and no-otp. The no-otp version is currently the stable code that runs just fine, but doesn&#8217;t take advantage of Erlang&#8217;s OTP framework. The otp branch is the more cutting edge OTP aware version, which I hope to fully migrate to soon. With full support for OTP, I should be able to use an already existing distribution platform, and more battle tested redundancy.</p>
<p>This evening, I fixed a long standing bug in the example HTTPd where the server would crash when opening large files due to a shortcut I took with first implementing the server. Originally, the server would read the entire file into a string and then send that to the client, as you can probably see, there is a problem when the server tries to read in a 3.9 GB file (my test file). Now, my servlet takes a much more sane approach, read in the file 1 kilobyte at time, sending that to the client before reading more. This new approach works perfectly, though I had to add some messiness for handling CGI/PHP files and different MIME types. I also added support for the HTTP HEAD command.</p>
<p>Peace and chow,</p>
<p>Ranok</p>
]]></content:encoded>
			<wfw:commentRss>http://www.r4n0k.com/2009/04/07/back-in-the-groove/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Next Semester Projects</title>
		<link>http://www.r4n0k.com/2008/12/25/next-semester-projects/</link>
		<comments>http://www.r4n0k.com/2008/12/25/next-semester-projects/#comments</comments>
		<pubDate>Thu, 25 Dec 2008 13:33:03 +0000</pubDate>
		<dc:creator>ranok</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[DNSCurve]]></category>
		<category><![CDATA[DNSSEC]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[fang]]></category>
		<category><![CDATA[osp]]></category>

		<guid isPermaLink="false">http://www.r4n0k.com/?p=143</guid>
		<description><![CDATA[Seeing as I&#8217;m going to have no homework for the next semester (!!) I&#8217;m hoping to get some more projects underway in my down time. I&#8217;m going to use this post as a dump of my current interests and as a road-map for where I want to go in the next few months. I&#8217;m sure [...]]]></description>
			<content:encoded><![CDATA[<p>Seeing as I&#8217;m going to have no homework for the next semester (!!) I&#8217;m hoping to get some more projects underway in my down time. I&#8217;m going to use this post as a dump of my current interests and as a road-map for where I want to go in the next few months. I&#8217;m sure this will change as time goes on, but I need to start somewhere!</p>
<p>Projects in progress:</p>
<ul>
<li><a href="http://www.jacobtorrey.com/FANG/">FANG</a> &#8211; I&#8217;d like to polish the multi-processing system, add namespaces, and tie it into the Erlang stdlib. Also add macros (real macros!) to FANG.</li>
<li><a href="http://www.openserverplatform.com">OSP</a> &#8211; I&#8217;m going to be using OSP as a basis for LadieBug (mentioned below). This will hopefully give me perspective into what I should work on in OSP to make it more friendly for development.</li>
</ul>
<p>New projects:</p>
<ul>
<li>I&#8217;d like to take advantage of LaunchPad&#8217;s &#8216;Personal Package Archive&#8217; system to host a few of my own Ubuntu packages, namely a more up-to-date version of Erlang&#8217;s OTP system.</li>
<li>LadieBug &#8211; To take advantage of OSP&#8217;s distributed data store, I&#8217;d like to implement my own caching, recursive DNS server that would be both DNSSEC and DNSCurve compliant and would share the cache over the entire cluster, making it more scalable and reduce the number of needless queries.</li>
</ul>
<p>That&#8217;s about all I can think of at the moment, if anyone would like to help me on any of these, feel free to comment below and we can get in touch.</p>
<p>Peace and chow,</p>
<p>Ranok</p>
]]></content:encoded>
			<wfw:commentRss>http://www.r4n0k.com/2008/12/25/next-semester-projects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FANG Version 0.1 Released!</title>
		<link>http://www.r4n0k.com/2008/12/06/fang-version-01-released/</link>
		<comments>http://www.r4n0k.com/2008/12/06/fang-version-01-released/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 15:46:39 +0000</pubDate>
		<dc:creator>ranok</dc:creator>
				<category><![CDATA[For Fun]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[fang]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.r4n0k.com/?p=129</guid>
		<description><![CDATA[I spent my birthday yesterday polishing up FANG for it&#8217;s initial release to the public, after adding some error handling so it would fail more gracefully and adding the ability to parse in files and save the current state of the system to a file for later retrieval. I also did away with the rather [...]]]></description>
			<content:encoded><![CDATA[<p>I spent my birthday yesterday polishing up FANG for it&#8217;s initial release to the public, after adding some error handling so it would fail more gracefully and adding the ability to parse in files and save the current state of the system to a file for later retrieval. I also did away with the rather hideous use of the process dictionary and moved to an auto balanced tree structure for storing the data.</p>
<p>Over break, I&#8217;m hoping to add enough other features to warrant a 0.2 release, which I&#8217;d like to have support for soft-processes (ala Erlang), multi-node support and transactional shared memory (using Mnesia). I would also like to add permissions and process jailing for the soft-processes to allow for running untrusted code in a sandbox of sorts.</p>
<p>I&#8217;ve started a very simple (and ugly) site to put my progress and releases. You can <a href="http://www.jacobtorrey.com/FANG/">check it out here</a> and please comment with suggestions or other features you&#8217;d think would be a valuable addition. Good luck on everyone&#8217;s finals and projects! Have a wonderful break!</p>
<p>Peace and chow,</p>
<p>Ranok</p>
]]></content:encoded>
			<wfw:commentRss>http://www.r4n0k.com/2008/12/06/fang-version-01-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Programming Language: FANG</title>
		<link>http://www.r4n0k.com/2008/10/28/new-programming-language-fang/</link>
		<comments>http://www.r4n0k.com/2008/10/28/new-programming-language-fang/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 01:52:40 +0000</pubDate>
		<dc:creator>ranok</dc:creator>
				<category><![CDATA[For Fun]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.r4n0k.com/?p=95</guid>
		<description><![CDATA[For the past few days, I have been slaving away working on my latest creation: FANG, a programming language that I&#8217;m hoping will combine some of the best features I&#8217;ve found in my studies and remove some of the cruft. It will have scheme/lisp like syntax and Erlang like processes, and some other neat features [...]]]></description>
			<content:encoded><![CDATA[<p>For the past few days, I have been slaving away working on my latest creation: FANG, a programming language that I&#8217;m hoping will combine some of the best features I&#8217;ve found in my studies and remove some of the cruft. It will have scheme/lisp like syntax and Erlang like processes, and some other neat features from other languages I&#8217;ve come across. After this weekend, I have a rough start which supports variables, lambda functions, and auto-memoizing clean functions. You can <a href="http://svn.cslabs.clarkson.edu/svn/fang/erl/">download the source from SVN</a> (username = password = anonymous) and check it out. Please feel free to comment with features to add, or things to change.</p>
<p>Features I want FANG to have:</p>
<ul>
<li>Clean scheme/lisp syntax and macros</li>
<li>Lightweight processes and multi-node support</li>
<li>Arbitrary precision number support</li>
<li>Process jailing and permission setting</li>
<li>Simple networking and file I/O</li>
<li>Others I&#8217;m sure I forgot&#8230;</li>
</ul>
<p>Code Examples:</p>
<ul>
<li>(defvar &#8216;fib (lambda &#8216;(n) &#8216;(if (&lt; n 3) (1) (+ (fib (- n 1)) (fib (- n 2)))))) &#8211; A plain recursive function that automatically will get memoized, so it&#8217;s rather speedy (use dirty-lambda to turn off the memoization)</li>
<li>(defvar &#8216;max (lambda &#8216;(a b) &#8216;(if (&gt; a b) (a) (b)))) &#8211; A simple max function used in findset</li>
<li>(defvar &#8216;findset (lambda &#8216;(l) &#8216;(if (== (length l) 0) 0 (if (== 1 (length l)) (hd l) (max (+ (hd l) (if (== 2 (length l))) 0 (findset (tl (tl l)))) (findset (tl l))))))) &#8211; A function for a homework assignment to find the highest weighted independent set in a path</li>
<li>(defvar &#8216;fact (lambda &#8216;(n) &#8216;(if (== 0 n) (1) (* n (fact (- n 1)))))) &#8211; A memoized factorial function</li>
</ul>
<p>Peace and chow,</p>
<p>Ranok</p>
]]></content:encoded>
			<wfw:commentRss>http://www.r4n0k.com/2008/10/28/new-programming-language-fang/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JInterface BigInteger Fun!</title>
		<link>http://www.r4n0k.com/2008/10/01/jinterface-biginteger-fun/</link>
		<comments>http://www.r4n0k.com/2008/10/01/jinterface-biginteger-fun/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 02:29:54 +0000</pubDate>
		<dc:creator>ranok</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jinterface]]></category>

		<guid isPermaLink="false">http://www.r4n0k.com/?p=83</guid>
		<description><![CDATA[For one of my cryptography assignments, I had to implement RSA encryption. I figured I&#8217;d use my current language of choice, Erlang, to try and tackle this challenge. After implementing some nicely optimized tail-recursive algorithms, I found that Erlang was very slow at doing large numerical operations. Feeling as if I&#8217;d hit a brick wall, [...]]]></description>
			<content:encoded><![CDATA[<p>For one of my cryptography assignments, I had to implement RSA encryption. I figured I&#8217;d use my current language of choice, Erlang, to try and tackle this challenge. After implementing some nicely optimized tail-recursive algorithms, I found that Erlang was very slow at doing large numerical operations. Feeling as if I&#8217;d hit a brick wall, I started looking into using other languages as libraries for the math operations. At first, I was looking at connecting Erlang to <a href="http://gmplib.org/">GMP</a> though the ei library for data conversion. Alas, I was not really feeling like programming in C at the moment, and so I got really excited when I found <a href="http://www.erlang.org/doc/apps/jinterface/index.html">JInterface</a>, a java library to connect to Erlang nodes using the native networking protocol. After playing around with the code for a little, I ported most of the important BigInteger methods to an Erlang wrapper module javabignum, which would deal with starting the Java server, and handle all the communication to and from the server. This solution worked wonderfully, and I implemented a simple RSA cipher in less than 30 lines of Erlang code! To checkout the code, visit the <a href="http://svn.cslabs.clarkson.edu/svn/gmperl/java/">SVN repository</a> using the username &#8216;anonymous&#8217; and the password &#8216;anonymous&#8217;.</p>
<p>Peace and chow,</p>
<p>Ranok</p>
]]></content:encoded>
			<wfw:commentRss>http://www.r4n0k.com/2008/10/01/jinterface-biginteger-fun/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OSP Update</title>
		<link>http://www.r4n0k.com/2008/09/04/osp-update/</link>
		<comments>http://www.r4n0k.com/2008/09/04/osp-update/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 10:02:18 +0000</pubDate>
		<dc:creator>ranok</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[osp]]></category>

		<guid isPermaLink="false">http://www.r4n0k.com/?p=73</guid>
		<description><![CDATA[In spirit of last night&#8217;s COSI meeting, I figured I should get ahead of the game and post a little bit about what I&#8217;ve been up to with OSP. There were a number of shortcomings with the 0.2 release in terms of permanent storage and replication. Since r65 (version 0.2) there have been a number [...]]]></description>
			<content:encoded><![CDATA[<p>In spirit of last night&#8217;s COSI meeting, I figured I should get ahead of the game and post a little bit about what I&#8217;ve been up to with OSP. There were a number of shortcomings with the 0.2 release in terms of permanent storage and replication. Since r65 (version 0.2) there have been a number of changes, mostly some old ones centered on ERLFS and the most recent ones, which tweak the mnesia settings. Below are some important revisions and their impact:</p>
<ul>
<li>r88 &#8211; Now will autosense is a node has a disk, and will determine whether or not to keep a copy of the applications table on the disk or just in RAM</li>
<li>r89 &#8211; Made gen-join.pl which asks the user a bunch of questions to make a join script for easier setup</li>
<li>r93 &#8211; When you first install OSP, you should run ./setup-osp.sh to initialize the database on the first/master node</li>
<li>r96 &#8211; Added the add-backup-server, which will make a disk copy of all the tables to that backup server incase of node failure, there&#8217;s a backup copy</li>
</ul>
<p>While thse changes are small, they are still very needed in creating an actual application. Currently, OSP is at r97, only 3 away from the big 100. I thought that we should have a mini OSP party when we reach r100, but since OSP is distributed, so should the party. So when you get word of the 100th commit, please raise a glass or eat a slice of cake.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.r4n0k.com/2008/09/04/osp-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OSP Version 0.2 Released!</title>
		<link>http://www.r4n0k.com/2008/04/07/osp-version-02-released/</link>
		<comments>http://www.r4n0k.com/2008/04/07/osp-version-02-released/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 00:53:28 +0000</pubDate>
		<dc:creator>ranok</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[mnesia]]></category>
		<category><![CDATA[osp]]></category>
		<category><![CDATA[servlet]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.r4n0k.com/?p=39</guid>
		<description><![CDATA[After less than a week OSP has reached another milestone in it&#8217;s development! Version 0.2 was just released with a few big fixes, performance improvments and added functionality. Also the documentation has been improved and made consistant with the code. The most important bug fix was a performance issue that caused a slowdown over time, [...]]]></description>
			<content:encoded><![CDATA[<p>After less than a week OSP has reached another milestone in it&#8217;s development! Version 0.2 was just released with a few big fixes, performance improvments and added functionality. Also the documentation has been improved and made consistant with the code.</p>
<p>The most important bug fix was a performance issue that caused a slowdown over time, this has been fixed and along with it, the performance and scalability has increased! The biggest feature added was support for UDP (and soon SCTP, and SSL) which can be set without changing the code! Imagine writing a server and deploying it using TCP, UDP, SSL and SCTP, just by changing one line in the XML servlet.</p>
<p>Setup should be simple too, just download from <a href="http://code.google.com/p/openserverplatform/">Google Code</a>, extract, make and then compile your servlet. Now on the first node, run ./start-osp.sh and then you can telnet to port 9876 and administer your cluster.</p>
<p>Links:</p>
<ul>
<li><a href="http://www.openserverplatform.com">Open Server Platform home</a></li>
<li><a href="http://groups.google.com/group/openserverplatform">OSP Group</a></li>
<li><a href="http://code.google.com/p/openserverplatform/">OSP Code</a></li>
</ul>
<p>Enjoy,</p>
<p>Ranok</p>
]]></content:encoded>
			<wfw:commentRss>http://www.r4n0k.com/2008/04/07/osp-version-02-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

