<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>All Things Related</title>
	<atom:link href="http://dasacc22.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://dasacc22.wordpress.com</link>
	<description></description>
	<lastBuildDate>Sun, 22 Jan 2012 17:47:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='dasacc22.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>All Things Related</title>
		<link>http://dasacc22.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://dasacc22.wordpress.com/osd.xml" title="All Things Related" />
	<atom:link rel='hub' href='http://dasacc22.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Fast Web Development with Damsel for Python</title>
		<link>http://dasacc22.wordpress.com/2012/01/22/fast-web-development-with-damsel-for-python/</link>
		<comments>http://dasacc22.wordpress.com/2012/01/22/fast-web-development-with-damsel-for-python/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 08:53:51 +0000</pubDate>
		<dc:creator>dasacc22</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dasacc22.wordpress.com/2012/01/22/fast-web-development-with-damsel-for-python/</guid>
		<description><![CDATA[Time feels surmountable when looking forward. In retrospect, I see surmise. My title to this post feels like a real plug piece, but I guess that&#8217;s what happens when you&#8217;re looking to get indexed. Recently, I tagged two new versions of dmsl in git. If you&#8217;ve never heard of dmsl, please go check out the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=407&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Time feels surmountable when looking forward. In retrospect, I see surmise.</p>
<p>My title to this post feels like a real plug piece, but I guess that&#8217;s what happens when you&#8217;re looking to get indexed. Recently, I tagged two new versions of dmsl in git. If you&#8217;ve never heard of dmsl, please go check out the README on github to see what it&#8217;s all about.</p>
<p><a href="https://github.com/dasacc22/dmsl">https://github.com/dasacc22/dmsl</a></p>
<p>I started off implementing haml in python which gave way to a unique direction for the project. I&#8217;ve been using it quite actively in work and am continuously enamored with its simplicity and power. Of course I wrote it and there might be a sense of bias, but this isn&#8217;t the first or second or third or fourth attempt I&#8217;ve made to write something like this. Each of those projects were short lived in the same way that once they were mostly complete, they just flat out didn&#8217;t &#8220;have it&#8221; for me.</p>
<p>0.3-stable is a wrap up of features and fixes over the course of many months of use and has, in the end, proven reliable. This tag is available on github. There were still some annoyances in the code related to speed and the dependency on lxml though that I badly wanted to fix.</p>
<p>The speed issue was solely in the use of a class inheriting python&#8217;s Formatter to handle extensions to string substitutions. These substitutions alone could take three times as much of the time as the parser for the whole document. Granted, on a whole, this was still quite a bit faster then a number of template engines out there, but I felt this could be drastically reduced.</p>
<p>The second issue was the dependency on lxml. Simply put, I wanted that to go.</p>
<p>So recently I addressed these issues and tagged 0.4 in git. I&#8217;ve also made this tag available on pypi. If installing from pypi, the only dependency is a build environment and python headers for building the C extensions. If building from github, you will need cython 0.15.1+ installed.</p>
<p>0.4 also has another change with how context variables end up in the templates sandbox. Previously, these items were packed in a kwargs dict available to templates. In 0.4, this is no longer the case and those items are unpacked in the environment for use. Planned though is the ability to revert to the old behaviour as needed for upgrading older installs.</p>
<p>While I feel the changes in 0.4 are drastic, unit tests pass and I&#8217;ve upgraded my personal projects successfully to do a little stress testing while also using it in another upcoming public project with success.</p>
<p>So check it out and tell me what you think.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dasacc22.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dasacc22.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dasacc22.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dasacc22.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dasacc22.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dasacc22.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dasacc22.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dasacc22.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dasacc22.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dasacc22.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dasacc22.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dasacc22.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dasacc22.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dasacc22.wordpress.com/407/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=407&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dasacc22.wordpress.com/2012/01/22/fast-web-development-with-damsel-for-python/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/20d3d9aff719d2d9779b382ca810a8fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dasacc22</media:title>
		</media:content>
	</item>
		<item>
		<title>daml 0.1.4 Release, A Python Markup Language for the Web</title>
		<link>http://dasacc22.wordpress.com/2010/12/22/daml-0-1-4-release/</link>
		<comments>http://dasacc22.wordpress.com/2010/12/22/daml-0-1-4-release/#comments</comments>
		<pubDate>Wed, 22 Dec 2010 22:08:58 +0000</pubDate>
		<dc:creator>dasacc22</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[DAML]]></category>
		<category><![CDATA[HAML]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[haml]]></category>
		<category><![CDATA[daml]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://dasacc22.wordpress.com/?p=133</guid>
		<description><![CDATA[Since my initial post outlining daml as a haml-for-python, a lot has changed. Now it has become something more and plays a new role in a bigger project I am working on. Let&#8217;s look at some of the new syntax changes. CSS Selector Style Attributes Declaring attributes now follows css selectors appended to a tag [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=133&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Since my initial post outlining daml as a haml-for-python, a lot has changed. Now it has become something more and plays a new role in a bigger project I am working on. Let&#8217;s look at some of the new syntax changes.</p>
<h4>CSS Selector Style Attributes</h4>
<p>Declaring attributes now follows css selectors appended to a tag hash. For example,</p>
<pre>
%html
    %body
        #content.main[attr=val][apples=yes] some content
</pre>
<h4>Inlining Tag Hashes</h4>
<p>One can now inline tag hashes. The functionality is still being worked on and is broken beyond a single tier. The intent is to handle use cases such as,</p>
<pre>
%html
    %body
        %ul#nav
            %li %a[href=/] Home
            %li %a[href=/contact] Contact

        #wrapper #container
            #top
            #content
</pre>
<h4>Implicit Python Declaration</h4>
<p>Since my last post, all python code had to be preceded with a colon (:). Now, this is only necessary when embedding a function call in plain text (or calling a filter). For Example,</p>
<pre>
def greet(s):
    return 'Hello, {0}.'.format(s)

nav = ['www', 'www2', 'www3']

%html
    %body
        %p A greeting for you. :greet('Daniel')
        %ul for x in nav:
            %li {x}
</pre>
<p>The trade off to the above is explicit line breaks for multiline text as similarly done in python,</p>
<pre>
%html
    %body This is some text \
        that spans multiple \
        lines.
</pre>
<p>I am still putting alot of thought into this portion of the syntax and it will most likely see some changes in a number of months. Explicit line breaks can become rather confusing when handling complex mixed contents, but again, tools such as daml aren&#8217;t particularly suited for writing page content, but rather establishing layout.</p>
<h4>New Filters</h4>
<p>I added two new filters as a test, these may be removed in future releases (and migrated to my personal set of daml extensions). They are for declaring css and js files. I think the syntax speaks for itself in function,</p>
<pre>
%html
    %head
        :css /css/
            main.css
            extra.css
            lib/that_lib.css

        :js /js/lib/
            utils.js
            js.js
            jquery.min.js
            etc.js
    %body
        %h1 I do enjoy filters!
</pre>
<p>I think such filters could be upgraded to support appending additional files, but again, I dont really have a place for such things that aren&#8217;t a necessity to a fully featured template engine.</p>
<h4>In Summary</h4>
<p>This release requires cython &gt;= 0.13 and lxml. I use this regularly on Windows 7 x64 and linux. The 0.1.4 release can be found on pypi, <a href="http://pypi.python.org/pypi/dmsl/0.2">http://pypi.python.org/pypi/dmsl/0.2</a> and you can follow development at github, <a href="https://github.com/dasacc22/dmsl">https://github.com/dasacc22/dmsl</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dasacc22.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dasacc22.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dasacc22.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dasacc22.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dasacc22.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dasacc22.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dasacc22.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dasacc22.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dasacc22.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dasacc22.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dasacc22.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dasacc22.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dasacc22.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dasacc22.wordpress.com/133/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=133&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dasacc22.wordpress.com/2010/12/22/daml-0-1-4-release/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/20d3d9aff719d2d9779b382ca810a8fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dasacc22</media:title>
		</media:content>
	</item>
		<item>
		<title>Python implementation of HAML</title>
		<link>http://dasacc22.wordpress.com/2010/05/03/python-implementation-of-haml/</link>
		<comments>http://dasacc22.wordpress.com/2010/05/03/python-implementation-of-haml/#comments</comments>
		<pubDate>Tue, 04 May 2010 01:41:11 +0000</pubDate>
		<dc:creator>dasacc22</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[DAML]]></category>
		<category><![CDATA[HAML]]></category>
		<category><![CDATA[haml]]></category>
		<category><![CDATA[daml]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[markup]]></category>
		<category><![CDATA[abstraction]]></category>
		<category><![CDATA[clean]]></category>

		<guid isPermaLink="false">http://dasacc22.wordpress.com/?p=114</guid>
		<description><![CDATA[UPDATE Dmsl is an active project on github and I am looking for active developers that can submit any bugs they may come across. I have been using it in production environments for nearly one year as of 12/2011. Refer to the repository README for an in depth look at current development, http://github.com/dasacc22/dmsl/blob/master/README So it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=114&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE</strong> Dmsl is an active project on <a href="http://github.com/dasacc22/dmsl/">github</a> and I am looking for active developers that can submit any bugs they may come across. I have been using it in production environments for nearly one year as of 12/2011. Refer to the repository README for an in depth look at current development, <a href="http://github.com/dasacc22/dmsl/blob/master/README">http://github.com/dasacc22/dmsl/blob/master/README</a></p>
<p>So it has been a busy past few days. During which I have written up an implementation of HAML in python. The closest thing I saw to this before was GRHML, whose site seems non-functional and I had a hard time finding information on its status. So without further ado, let me introduce DAML, my HAML implementation.</p>
<pre>
:title = 'Hello World!'

%html
    %head
        %title {title}
    %body
        :include('header.html')

        :greeting = lambda x: '%p Hello, {0}'.format(x)

        :greeting('user')
        :greeting('me')
        :greeting('world')

        :items = ['a', 'b', 'c', 'd']

        :def is_last(i):
        :   return len(items) is i+1 and '(class=last)' or ''

        %h2 Loop Method 2 (python list comprehension)
        %ul
            :['%li{0} {1}'.format(is_last(i), x) for i, x in enumerate(items)]

        :include('footer.html')
</pre>
<p>Ok, now this isn&#8217;t all it does but let me talk about a couple things first. For one, this project, as of today, is only 3 or 4 days old. Its hard for me to recall b/c I&#8217;ve poured a lot of time into trying to make this run as fast as possible. Today on the other hand has produced a lot of slow downs and hackish code for implementing features like Django code blocks. For you XSL people (which would be me) that means a way to name and call templates from other templates. So anyway, a lot of this code from today (and yesterday) needs some love.  With that said, lets go over some differences between HAML and DAML when it comes to marking up HTML.</p>
<p>You&#8217;ll notice right away that declaring tags is straight forward and precisely the same. I&#8217;ve never actually used HAML so I dont know its exact syntax, but I spent a lot of time perusing the documentation for HAML. Now the actual text processor in DAML is quite fast for building documents. At one point during development, when i was still testing speeds in comparison to HAML, I had results along the lines of 0.21ms processing time for DAML versus 2.4ms processing time for HAML. This was for plain-jane HTML declaration. Lets look at some of that now with DAML.</p>
<pre>
%html
    %head
        %title Good Stuff

    %body
        #header Some stuff here
            and indentions of plain text
            will all be part of this div

            .span while this child div whose class="span"
                will be embedded within the above div

            while this text is tailed
            and multilined too

        %p and heres some random content too
            %strong that can be played
            however you like.

        %p one thing worth noting is that new tags
            %strong need
            to be on
            %em new lines
            so keep that in mind.
</pre>
<p>All of this renders fine of course. But I still have a TODO list for handling stuff unrelated to python expression evaluating. Namely comments, escaping, whitespace control. This is pretty much in line with HAML thus far although I often see blank lines in HAML appended with equals-sign and I cant recall what for. Regardless, the next thing to note is the use of variables. Which loosely follows the string.Formatter (and would fully support it if not for speed issues at the moment, but soon hopefully). Lets go over an example of setting and using variables.</p>
<pre>
:title = 'Hello World!'
%h1 {title}
</pre>
<p>Simple, eh? Now here&#8217;s the deal. There is a sand-boxed python eval going on. All lines starting with :colons are getting added to an evaluation queue that gets compiled and eval&#8217;d. Currently you would tag variables just like using string.Formatter and in the future, this will support all the goodies associated with it. Currently though whats going on is its simply accessing the variable declared (versus string.Formatter being setup with the documents namespace and getting called). Never-the-less, this works fine so far. Lets look at some other things we can do with &#8220;:&#8221;</p>
<pre>
:l = []
:for x in range(20):
:    l.append(x)

%div
    :['%p {0}'.format(x+1) for x in l]
</pre>
<p>Notice first, that you can basically freely declare normal python code blocks. You can also declare functions to make use of as shown with the initial intro document. I would say, ideally, the syntax I would want to go for in the majority of cases is something like (for-loop with plain-text block not yet functional)</p>
<pre>
#body
    :items = ['a', 'b', 'c', 'd']
    :is_last = lambda i: len(items) is i+1 and '(class=last)' or ''
    %ul
        :for i, x in enumerate(items):
            %li:is_last(i) {x}

    #div.class(attr=val, attr2=val2) oh and here's this too
</pre>
<p>So this is something I am working towards, but you can totally declare :func(*args) inline right now and it works. Notice, going back to the plain-text that you can freely declare %tag#id.class(attr=val) in almost any order, the only except is you can not start a line with (attr=val) nor can you declare (attr=val)(attr=val) though the latter may be added. Part of my TODO list is to have the ability to span attributes across multiple lines.</p>
<p>Ill touch on one last bit here, I implemented something similar to django blocks (at its most basic level). Its a wee bit limited until i implement multiline filter options as part of the preprocessor I *just* started working on not but 4 hours ago. But let me show what the final syntax would look like</p>
<pre>
:extends('template.daml')

:block header
    %h1 {title} OVERRIDE!
</pre>
<p>Now the above doesn&#8217;t work until i finish a bit on this preprocessor but to show you how that will work, let me show you how the above does currently work</p>
<pre>
:extends('template.daml')

:block('header\n    %h1 {title} OVERRIDE!')
</pre>
<p>Now that does work, and as you can see, my preprocessor is basically going to go through for indented portions of text under colon directive calls and push it into the related function thats in the sandboxed globals. This basically means that you can write all sorts of text filters and everything really really easy b/c then back on your end you may have a need to do &#8220;blank&#8221; with &#8220;blah. So..</p>
<pre>
my_python_code.py
-------------------------
def my_filter(s):
    s = s.splitlines()
    for x in s:
        pass # do blank with blah
    return s
</pre>
<p>I&#8217;ve basically tried to unify a number of features of HAML here so that anything can be easily overridden or customized and extended. Nothing thats just built-in and untouchable. There&#8217;s even more to come surely but I am honestly way burnt out on this.</p>
<p>Let me lastly explain just how FAST this works currently. Now before I went in today/yesterday adding in all these crazy bits and pieces, I grabbed the bench suite from genshi that benchmarks all the most popular python templating engines. I wrote my template to do everything to spec as the others were doing and these were my results.</p>
<p>Mako: 0.38ms<br />
DAML: 0.44ms<br />
Cheetah: 0.66ms<br />
Genshi-Text: 0.96ms</p>
<p>and after that it just trailed off into really big numbers with Genshi coming in at 1.5ms?? and django at 2.4ms?? So this thing has the potential to be FAST. Now since the hackery I&#8217;ve pulled in the past number of hours I&#8217;ve actually almost doubled my processing time and the above test for DAML now runs at 0.85ms but keep in mind i have done no optimization/refactoring/code-cleanup/obvious-bug-fixes-needed to the codebase i just recently committed. So that portion needs some love and I&#8217;d love to get the speed back down to what it was just early yesterday morning.</p>
<p>Now, if your interested in the project, pleeease check it out at github, <a href="http://github.com/dasacc22/dmsl">http://github.com/dasacc22/dmsl</a> and play around with it. I&#8217;m going to slow my development down to a crawl comparitively as I&#8217;m really burnt out. I wont be implementing any new features and I&#8217;ll be cleaning up my code base yet again and trying to write beautiful code to everything ive hacked together today/last-nite.</p>
<p>And please feel free to contact me by email or comments or however regarding this project. I would like to get the code cleaned up so that I can collaborate on different things to really bring this project up to par.</p>
<p>Thanks, and enjoy<br />
<a href="http://github.com/dasacc22/dmsl">http://github.com/dasacc22/dmsl</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dasacc22.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dasacc22.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dasacc22.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dasacc22.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dasacc22.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dasacc22.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dasacc22.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dasacc22.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dasacc22.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dasacc22.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dasacc22.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dasacc22.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dasacc22.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dasacc22.wordpress.com/114/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=114&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dasacc22.wordpress.com/2010/05/03/python-implementation-of-haml/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/20d3d9aff719d2d9779b382ca810a8fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dasacc22</media:title>
		</media:content>
	</item>
		<item>
		<title>Line 6 UX2 and Linux</title>
		<link>http://dasacc22.wordpress.com/2010/02/24/line-6-ux2-and-linux/</link>
		<comments>http://dasacc22.wordpress.com/2010/02/24/line-6-ux2-and-linux/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 15:06:45 +0000</pubDate>
		<dc:creator>dasacc22</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Line 6]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[UX2]]></category>

		<guid isPermaLink="false">http://dasacc22.wordpress.com/?p=111</guid>
		<description><![CDATA[I originally wrote a bad/sad review about the Line 6 UX2 not working under linux as can be seen here: http://line6.com/community/thread/17663 I was looking to sell it recently when I decided to give it another look over and try out the drivers done for the PodXT devices by someone as can be found here: http://www.tanzband-scream.at/line6/ [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=111&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I originally wrote a bad/sad review about the Line 6 UX2 not working under linux as can be seen here:<br />
<a href="http://line6.com/community/thread/17663">http://line6.com/community/thread/17663</a></p>
<p>I was looking to sell it recently when I decided to give it another look over and try out the drivers done for the PodXT devices by someone as can be found here:<br />
<a href="http://www.tanzband-scream.at/line6/">http://www.tanzband-scream.at/line6/</a></p>
<p>The 0.8.1 release failed to compile so i checked out the trunk of the development version<br />
$&gt; svn co https://line6linux.svn.sourceforge.net/svnroot/line6linux<br />
$&gt; cd line6linux/driver/trunk<br />
$&gt; make<br />
$&gt; sudo make install</p>
<p>To my surprise, it worked fairly ok. My line 6 ux2 device lit up and seemed ready to go. One of the first things I noticed was that there was a constant buzzing out of the right channel monitor. This was alleviated by simply plugging my guitar in. Next, I read through the docs to get some general info. I went ahead and fired up alsamixer, increased pcm output and zero&#8217;d out the monitor. Note: the docs say to set pcm output to zero as they can be much louder then the guitar monitor. I had no trouble with this when i increased output to 75, volume was normal.</p>
<p>So then I fired up jack and played around with a couple settings. To my surprise I was able to get latency down to 1.5 ms according to ardour (2.87 according to qjackctl)! Either way, this was much lower then I ever managed with my edirol which normally clocked in around 15ms and was littered with xruns that were very audible in the recording. Normally around 22ms I could achieve good sound with no xruns. After a short recording session, I noticed qjackctl had logged numerous xruns but I never heard a thing. Once during the recording, ardour disconnected from jack but this could be totally unrelated.</p>
<p>This is fine news indeed and prompts me to want to hold on to this device. The bad news is I have been unable to get the microphone inputs working. I haven&#8217;t had time to look into it fully but hopefully after exploring the line6linux docs some more, I can have some success with getting this working.</p>
<p>So all in all, this is great. What I would really like to see is Line6 spend a few resources on this project or doing something themselves. But that aside, hardware wise (i guess), this little bugger rocks!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dasacc22.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dasacc22.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dasacc22.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dasacc22.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dasacc22.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dasacc22.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dasacc22.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dasacc22.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dasacc22.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dasacc22.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dasacc22.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dasacc22.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dasacc22.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dasacc22.wordpress.com/111/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=111&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dasacc22.wordpress.com/2010/02/24/line-6-ux2-and-linux/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/20d3d9aff719d2d9779b382ca810a8fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dasacc22</media:title>
		</media:content>
	</item>
		<item>
		<title>Binding (and unbinding) JQuery Event Handlers in a Complex Web App</title>
		<link>http://dasacc22.wordpress.com/2009/12/06/binding-and-unbinding-jquery-event-handlers-in-a-complex-web-app/</link>
		<comments>http://dasacc22.wordpress.com/2009/12/06/binding-and-unbinding-jquery-event-handlers-in-a-complex-web-app/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 01:07:35 +0000</pubDate>
		<dc:creator>dasacc22</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://dasacc22.wordpress.com/?p=101</guid>
		<description><![CDATA[I&#8217;m commonly placed in a tough situation. Here I am, working on a web related project and I would like to implement a lot of complex features via javascript. JQuery is the first library I&#8217;ve used and it has allowed me to at least dream of a functional, yet complex, web application. Typically, the first [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=101&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m commonly placed in a tough situation. Here I am, working on a web related project and I would like to implement a lot of complex features via javascript. JQuery is the first library I&#8217;ve used and it has allowed me to at least dream of a functional, yet complex, web application. Typically, the first 25% of the javascript related work is a total breeze, thanks to jquery. The next 30-50% of the work becomes totally convulated, thanks to jquery being my crutch, and never diving in and bothering to understand javascript all these years. The final percent is ussually left on a wish-list of too-buggy-to-deploy and wouldn&#8217;t-it-be-nice.</p>
<p>Here I am again, endeavoring to build a complex and functional web application and this time I really want to get it right, and low and behold, I&#8217;m beginning to run into one of those typical problems.</p>
<p><strong>Binding Events with JQuery</strong></p>
<p>JQuery really makes this easy. I love it. I remember first starting off and writing a little bit of code like this:</p>
<pre>$('.button').click(function() {
  $.get('/some/stuff', function() {
    $('.somestuff').append(....);
  });
});</pre>
<p>and what not. Then I discovered that beloved .load() function. Really cut down on a lot of legwork I was doing. But there was always a slight problem. I always ended up with conflicting binds. There were various ways I worked around this, among other problems before .live() was around, but it was always a bit of a conundrum. I think this mostly deals with the approach JQuery takes towards usability. The focus is quickly accessing an object and binding the specified event, nothing more. It makes no effort to force any sort of design paradigm, which leads me to wonder, how should I handle this? I figure the first place to look for inspiration are in libraries I already currently use that solve this sort of design pattern.</p>
<p><strong>Pyglet Event Handling for OpenGL/Python</strong></p>
<p>I&#8217;ve used <a href="http://www.pyglet.org">pyglet</a> for a while now. It has a few design patterns for handling events that go something like this:</p>
<pre># first, it allows for decorators over a method
@windows.event
def mouse_press(...):
    pass # and do stuff

# and also a window method to push handlers of class instances
class SomeStuff(object):
    def mouse_press(...):
        pass # and go

some_stuff = SomeStuff()
window.push_handlers(some_stuff)

# and likewise, you can pop those handlers
window.pop_handlers(some_stuff)</pre>
<p>The first design pattern doesn&#8217;t really solve any particular problem of mine and is pretty much already what is going on using jquery events. But the second pattern is something I would have considered impossible for me to accomplish in javascript, I&#8217;ve just never understood the language enough to consider it doable. But recently, I&#8217;ve been coming to understand the language a lot more and wrote a small utility for making better use of prototypal inheritance in javascript, <a href="http://js.dasa.cc">js.js</a>, and it struck me that this would be pretty easy to implement.</p>
<p><strong>A Design Paradigm for JQuery Event Handling</strong></p>
<p>First, its important to understand a small bit about the js.js utility. It&#8217;s somewhat based off of Crockford&#8217;s function that prototyped an empty constructor with a passed in object. The difference here is that js.js calls magic methods (instead of being an empty constructor) and allows one to pass in multiple objects and functions to be prototyped.</p>
<p>The design consists of two parts. A jquery plugin in the form of $.events.push() and $.events.pop() and a prototype inheritance pattern, optionally using the js.js function.</p>
<p>This is the plugin code:</p>
<pre>$.extend({
    events: {
        recurse: function(args, action) {
            for (var x in args) {
                var obj = args[x];
                for (var k in obj) {
                    if (typeof obj[k].bind != "undefined") {
                        if (action == "push") {
                            $(obj[k].bind).bind(k, obj[k], obj);
                        } else {
                            $(obj[k].bind).unbind(k, obj[k]);
                        }
                    } else if (typeof obj[k].live != "undefined") {
                        if (action == "push") {
                            $(obj[k].live).live(k, obj[k], obj);
                        } else {
                            $(obj[k].live).die(k, obj[k]);
                        }
                    }
                }
            }
        },
        push: function() {
            this.recurse(arguments, "push");
        },
        pop: function(obj) {
            this.recurse(arguments, "pop");
        }
    }
});</pre>
<p>The scenario is this. A lot of ajax events are very similar and would work across different loaded pages/forms. Where necessary, one could override an event to add extra functionality:</p>
<pre>controls = {
  index: function(params) { $(...).load(...); },
  form: function(params) { $(...).load(...); },
  save: function(data) { $.post(..., this.index); }
}

events = {
  keyup: function() { ... },
  submit: function() { ...; this.save(data); return false; }
}
events.keyup.live = '.main .filter'; // just demonstrating access to live and bind
events.submit.bind = '.main .form';

user = function() {
  this.init = function() {
    $('a[href=#user]').bind('click', this.click, this);
  }
  this.click = function() {
    highlight(...);
    // do some more stuff;
    this.index();
    this.form();

    $.events.pop(one, two, three);
    $.events.push(this);
  }
}

var User = prototype(user, events, controls, object);

$(function() {
  var u = new User({url: '/db/User'});
});</pre>
<p>This allows for common parts to be factored out when shared by many different objects. Picture five other objects alongside User. Some might override events and call the original, for example, events.submit.call(this, &#8230;).</p>
<p>This is a little rudimentary to start, but its a start none-the-less.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dasacc22.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dasacc22.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dasacc22.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dasacc22.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dasacc22.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dasacc22.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dasacc22.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dasacc22.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dasacc22.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dasacc22.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dasacc22.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dasacc22.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dasacc22.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dasacc22.wordpress.com/101/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=101&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dasacc22.wordpress.com/2009/12/06/binding-and-unbinding-jquery-event-handlers-in-a-complex-web-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/20d3d9aff719d2d9779b382ca810a8fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dasacc22</media:title>
		</media:content>
	</item>
		<item>
		<title>js.js say whaa</title>
		<link>http://dasacc22.wordpress.com/2009/12/05/js-js-say-whaa/</link>
		<comments>http://dasacc22.wordpress.com/2009/12/05/js-js-say-whaa/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 21:19:04 +0000</pubDate>
		<dc:creator>dasacc22</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dasacc22.wordpress.com/?p=96</guid>
		<description><![CDATA[whaa? oh, right. Well Ive dug in deep to javascript. Well sorta, and it was all in an effort to evaluate whether to use prototype.js or mootools. My choice? neither. Instead I&#8217;ll focus my energy on expanding the default object in my js.js file. I know, its totally unoriginal. But lets face the facts, its [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=96&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>whaa? oh, right. Well Ive dug in deep to javascript. Well sorta, and it was all in an effort to evaluate whether to use prototype.js or mootools. My choice? neither. Instead I&#8217;ll focus my energy on expanding the default object in my js.js file. I know, its totally unoriginal. But lets face the facts, its 488 bytes.</p>
<p>And hot damn its amazing what 488 bytes can do. You can check it out here:<br />
<a href="http://js.dasa.cc">http://js.dasa.cc</a></p>
<p>Ive placed it in the public domain and what not. I think the focus will be mostly on custom constructors and lettings prototype() paste it all together. And of course, it can just be a staging ground for continued explicit prototypal declaration. It just uses whats there, and thats pretty sweet.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dasacc22.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dasacc22.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dasacc22.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dasacc22.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dasacc22.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dasacc22.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dasacc22.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dasacc22.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dasacc22.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dasacc22.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dasacc22.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dasacc22.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dasacc22.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dasacc22.wordpress.com/96/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=96&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dasacc22.wordpress.com/2009/12/05/js-js-say-whaa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/20d3d9aff719d2d9779b382ca810a8fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dasacc22</media:title>
		</media:content>
	</item>
		<item>
		<title>A New Way to Prototype with Javascript</title>
		<link>http://dasacc22.wordpress.com/2009/12/05/a-new-way-to-prototype-with-javascript/</link>
		<comments>http://dasacc22.wordpress.com/2009/12/05/a-new-way-to-prototype-with-javascript/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 18:17:59 +0000</pubDate>
		<dc:creator>dasacc22</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[meta]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://dasacc22.wordpress.com/?p=88</guid>
		<description><![CDATA[Ive been doing alot of reading. One place that I keep happening upon is Crockford&#8217;s javascript pages. I dont reallly know who that is, but I&#8217;ve occasionally read he&#8217;s some sort of javascript legend. Well, I was looking over one of his pages, describing instantiating new objects, specifically: http://javascript.crockford.com/prototypal.html He talked about prototypal behavior, how [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=88&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ive been doing alot of reading. One place that I keep happening upon is Crockford&#8217;s javascript pages. I dont reallly know who that is, but I&#8217;ve occasionally read he&#8217;s some sort of javascript legend. Well, I was looking over one of his pages, describing instantiating new objects, specifically:<br />
<a href="http://javascript.crockford.com/prototypal.html">http://javascript.crockford.com/prototypal.html</a></p>
<p>He talked about prototypal behavior, how it should work, and his simple function for doing so. Effectively, creating a blank function definition and then setting its prototype to the passed in object. I suddenly realized something. Ive been going about it all wrong with this class() business. Furthermore, what I had in place was his function but on steroids. Instead of initializing a blank function, I have what i was considering a sort of meta object that links to magic methods. And instead of setting the prototype to the object passed in, I set it to the all the objects passed in. So I took this thought and made some minor changes to the code, including being able to pass in objects, not just functions. Now I can write stuff like this,</p>
<pre>x = {get: function() { return this.url; }};

function y() {
    this.get_url = function() {
        return x.get.call(this);
    }
};

var super_object = prototype(y, x);</pre>
<p>and now super_object has the methods of y and x, where the order of the arguments decides precedence of inheritance. So I can create a new instance by</p>
<pre>var a = new super_object({url: '/test/this'});
a.get_url() // returns '/test/this'
a.get() // returns '/test/this'</pre>
<p>There some behind the scenes action here. What I did was abstract out the meta object with the intention of overriding it. But on some more thought, I think I will simply make it explicit, this way one could define any number of meta objects with their own magic methods, or if it so fits, simply pass in a blank function() {}, following Crockford&#8217;s lead. So it would look more like</p>
<pre>var super_object = prototype(y, x, meta); // or whatever you call your meta, or
var super_object = prototype(y, x, function(){}); // for no magic methods or special constructors</pre>
<p>Speaking on speed, Its important to note that there are no call&#8217;s or apply&#8217;s ever, though thats not to say one couldn&#8217;t write it into a custom meta object. Point being, it runs fast, just as fast as typing it all out manually. It doesn&#8217;t strive to be &#8220;classical&#8221; in any way. It simply focuses on custom constructors for multiple objects and a simple way to combine multiple objects, given order of precedence of arguments. It could be just as easily used in conjunction with explicit prototypal declarations. Seems like a win-win for keeping it simple.</p>
<p><strong>*** Edit ***</strong> I forgot to mention, in the above example, x is an object that super_object inherited, but say you override x&#8217;s method and then needed to call it? well its a good bit shorter since its already an object, simply</p>
<p>x.get.call(this)</p>
<p>No need for specifying the prototype. I think this could easily become a simple design paradigm I might follow, Ill need more experience to judge properly though</p>
<p><strong>*** Edit2 ***</strong> Heres a link to <a href="http://js.dasa.cc">the code</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dasacc22.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dasacc22.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dasacc22.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dasacc22.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dasacc22.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dasacc22.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dasacc22.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dasacc22.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dasacc22.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dasacc22.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dasacc22.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dasacc22.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dasacc22.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dasacc22.wordpress.com/88/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=88&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dasacc22.wordpress.com/2009/12/05/a-new-way-to-prototype-with-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/20d3d9aff719d2d9779b382ca810a8fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dasacc22</media:title>
		</media:content>
	</item>
		<item>
		<title>Javascript&#8217;s not all bad</title>
		<link>http://dasacc22.wordpress.com/2009/12/05/javascripts-not-all-bad/</link>
		<comments>http://dasacc22.wordpress.com/2009/12/05/javascripts-not-all-bad/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 12:18:24 +0000</pubDate>
		<dc:creator>dasacc22</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[getter]]></category>
		<category><![CDATA[setter]]></category>

		<guid isPermaLink="false">http://dasacc22.wordpress.com/?p=80</guid>
		<description><![CDATA[I gotta admit, through all the frustration and experimentation ive gone through with the language recently, its not so bad. At first I thought, &#8220;expressive? no way&#8221; b/c it seems like when you go to be expressive, you crop up with irreparable errors that eventually force you into one &#8220;expression&#8221;. Frustration follows each step, as [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=80&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I gotta admit, through all the frustration and experimentation ive gone through with the language recently, its not so bad. At first I thought, &#8220;expressive? no way&#8221; b/c it seems like when you go to be expressive, you crop up with irreparable errors that eventually force you into one &#8220;expression&#8221;. Frustration follows each step, as is learning for me, yet I carry on.</p>
<p>Now Im feeling the chains loosened. Not so much do I feel tied to a particular paradigm when writing out bits of javascript, particularly, paradigms that Ive brought over from projects Ive worked on in python. Im looking at new ways to do things in javascript, in particular I was pretty happy to see getters and setters in javascript 1.5, Ive always enjoyed them for a couple reasons.</p>
<p><strong>Getters and Setters provide a consistent API</strong><br />
Alot of times, we find ourselves writing utilities and libraries of utilities to perform particular actions. When using these libraries (or someone else&#8217;s for that matter), its important to have a consistent API so one can think about the task at hand, not the details of the API. If you have a series of attributes on an object, but some of them might be dependent on others, getters and setters might prove useful for consistency in accessing object properties. If you have the following properties, parent, children, x, y, w, h, batch, visible, well keeping in mind to call get_parent() or batch() or whatever while calling .w and .visible for others really blows. All I can say is that I hope theres auto generated documentation to keep at hand, which will be a pain if theres long time periods in between using the library.</p>
<p><strong>Getters and Setters provide a mechanism for error checking</strong><br />
Another use I&#8217;ve found for getters and setters is error checking. It provides a centralized point to assert the value is something valid before getting or setting. So say I have</p>
<p>widget.x = input</p>
<p>Theres alot of places I could check input, but if Im getting input and setting x from different scenarios that crop up, being able to check it with a setter on x would consolidate alot of code.</p>
<p>Anyway, having access to getters and setters in javascript will be useful to say the least. Embracing the functional style of javascript looks like a win-win situation. Unlike others, I have no gripes with calling object.prototype.method.call(this) but even that is probably unnecessary in alot of situations, trying to fit a bull with a shoehorn.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dasacc22.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dasacc22.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dasacc22.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dasacc22.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dasacc22.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dasacc22.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dasacc22.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dasacc22.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dasacc22.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dasacc22.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dasacc22.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dasacc22.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dasacc22.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dasacc22.wordpress.com/80/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=80&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dasacc22.wordpress.com/2009/12/05/javascripts-not-all-bad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/20d3d9aff719d2d9779b382ca810a8fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dasacc22</media:title>
		</media:content>
	</item>
		<item>
		<title>Whats wrong with javascript prototype?</title>
		<link>http://dasacc22.wordpress.com/2009/12/04/whats-wrong-with-javascript-prototype/</link>
		<comments>http://dasacc22.wordpress.com/2009/12/04/whats-wrong-with-javascript-prototype/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 21:31:42 +0000</pubDate>
		<dc:creator>dasacc22</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[prototypal]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://dasacc22.wordpress.com/?p=76</guid>
		<description><![CDATA[** Edit **You can see my current approach to these frustrations here: http://js.dasa.cc O thats easy, ok lets write up a base object we&#8217;ll want to inherit from (note, I would not actually write a this.get_name to retrieve a this.name, duh, its all in the spirit of an easy read) function A(name, age) { this.name [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=76&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>** Edit **</strong>You can see my current approach to these frustrations here: <a href="http://js.dasa.cc">http://js.dasa.cc</a></p>
<p>O thats easy, ok lets write up a base object we&#8217;ll want to inherit from (note, I would not actually write a this.get_name to retrieve a this.name, duh, its all in the spirit of an easy read)</p>
<pre>function A(name, age) {
  this.name = name;
  this.age = age;
  this.get_name = function() { return this.name; }
  this.get_age = function() { return this.age; }
}</pre>
<p>Good, ready? oh shit, wait a sec, according to MDC we were being naive. Now the only way to call the get_name and get_age functions is with an instance of A. Well crap, that doesn&#8217;t help inheritance much, prototypal or not. Alright so lets do this right.</p>
<pre>function A(name, age) {
  this.age = age;
  this.name = name;
}
A.prototype = {
  get_age: function() { return this.age; },
  get_name: function() { return this.name; }
}</pre>
<p>Yeay, yippie for us, now lets extend A with B</p>
<pre>function B() {};
B.prototype = new A;</pre>
<p>Yeay, yippie, now lets make C with an extra param and function and extend A.</p>
<pre>function C(name, age, title, money) {
  this.title = title;
  this.money = money;
};
C.prototype = new A;
C.prototype = {
  get_title: function() { return this.title; },
  get_money: function() { return this.money; }
}</pre>
<p>Good? alright lets.. o crap! it doesn&#8217;t work. Right, right, thats right, I totally erased the A prototype by using the prototype = {} syntax, ok so that syntax is no good for working with inheritance unless its the top level thing, but crap, i dont wanna think about that. Whatever, lets just fix C for now though readability will be a little funky, hey .. i know! lets just say if i use the prototype = {}; syntax, thats a way to differentiate it as a top level parent! yeah! thats great justification *cough*not*cough*</p>
<p>anyway</p>
<pre>function C(name, age, title, money) {
  this.title = title;
  this.money = money;
};
C.prototype = new A;
C.prototype.get_title = function() { return this.title; }
C.prototype.get_money = function() { return this.money; }</pre>
<p>ok, lets fire this bad boy up and test C.. Where the hell is my name? and age!? son of a.., I see, so i need to manually call the constructor of the same damn thing that I C.prototype=&#8217;d</p>
<p>alright, its cool, lets fix it, I can dig it. Lets add that A.call</p>
<pre>function C(name, age, title, money) {
  A.call(this, name, age);
  this.title = title;
  this.money = money;
};
C.prototype = new A;
C.prototype.get_title = function() { return this.title; }
C.prototype.get_money = function() { return this.money; }</pre>
<p>Sweet buttery buttons! It works! wait a sec.. why is this code running slower then before? Yeah yeah, theres creating the name and age now that wasn&#8217;t before but its more&#8230; its .call() ! Wth?! why is this causing it to go slower? Alright alright, its cool, lets just&#8230; migrate these object property inits out of the contructor and into a prototype function that will handle the needs of all that inherit it since its mostly the same.</p>
<p>Ah hell, im hungry, maybe another day..</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dasacc22.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dasacc22.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dasacc22.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dasacc22.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dasacc22.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dasacc22.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dasacc22.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dasacc22.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dasacc22.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dasacc22.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dasacc22.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dasacc22.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dasacc22.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dasacc22.wordpress.com/76/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=76&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dasacc22.wordpress.com/2009/12/04/whats-wrong-with-javascript-prototype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/20d3d9aff719d2d9779b382ca810a8fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dasacc22</media:title>
		</media:content>
	</item>
		<item>
		<title>A Javascript Class with magic methods</title>
		<link>http://dasacc22.wordpress.com/2009/12/04/a-javascript-class-with-magic-methods/</link>
		<comments>http://dasacc22.wordpress.com/2009/12/04/a-javascript-class-with-magic-methods/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 16:07:05 +0000</pubDate>
		<dc:creator>dasacc22</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[extend]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[magic methods]]></category>

		<guid isPermaLink="false">http://dasacc22.wordpress.com/?p=66</guid>
		<description><![CDATA[Hey, ok so this is what i have so far, totally preliminary function class() { var that = function() { this.__init__(arguments[0]); }; that.prototype = new object; for (var x=arguments.length-1; x&#62;=0; --x) { var m = new arguments[x]; for (var i in m) { that.prototype[i] = m[i]; } } this[arguments[0].name] = that; } function object() { [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=66&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hey, ok so this is what i have so far, totally preliminary</p>
<pre>function class() {
    var that = function() {
        this.__init__(arguments[0]);
    };
    that.prototype = new object;

    for (var x=arguments.length-1; x&gt;=0; --x) {
        var m = new arguments[x];
        for (var i in m) { that.prototype[i] = m[i]; }
    }
    this[arguments[0].name] = that;
}

function object() {
    this.__init__ = function(kwargs) {
        for (var k in kwargs) {
            this[k] = kwargs[k];
        }
    }
}</pre>
<p>Short, right?</p>
<p>Then I can write something like this,</p>
<pre>class(A, object)
function A() {
    this.get_name = function() {
        return this.name;
    }
}

class(B, A)
function B() {
    this.get_age = function() {
        return this.age;
    }
}

class(C, object)
function C() {
    this.__init__ = function() {
        this.name = "OVERRIDE";
    }
}

var a = new A({name: "Daniel", age: "24"});
var b = new B({name: "David", age: "25"});
var c = new C({name: "John", age: "26"});</pre>
<p>effectively just sticking a little header over normal javascript functions, and everything works as one would expect.</p>
<p>a.name // returns Daniel<br />
a.age // returns 24<br />
b.get_age() // returns 25<br />
b.get_name() // returns David<br />
c.name // returns OVERRIDE</p>
<p>And to boot, it executes at the same speed as writing it the &#8220;native&#8221; way. Here&#8217;s what i have for &#8220;native&#8221; (im a noob so correct any errors)</p>
<pre>function object() {}
object.prototype.init = function(kwargs) {
    for (var k in kwargs) {
        this[k] = kwargs[k];
    }
}

function A(kwargs) {
    this.init(kwargs);
}
A.prototype = new object;
A.prototype.get_name = function() {
    return this.name;
}

function B(kwargs) {
    this.init(kwargs);
}
B.prototype = new A;
B.prototype.get_age = function() {
    return this.age;
}

function C() {
    this.name = "OVERRIDE";
}</pre>
<p>I ran a test importing each implementation, respectively, and got similar results in execution speed and memory size. I created 100,000 thousand objects of each A, B, C and each method occupied 78mb according to top, and each method consistently ran between 2100-2300 ms with variance that occasionally hit 3000 ms. Ultimately its not surprising as all the class function i wrote does is auto write how you would do it natively. What Im surprised about is theres no extra cruft when the javascript runtime compiler handles it. I never intended this to be useful, it was all part of an experiment delving into javascript scope and messing with constructors so i could evaluate the use of a library like prototype.js or mootools.</p>
<p>But hell, so far this little bit of code is turning out to be fairly useful. I imagine if i write more magic methods, the memory size will increase by a small amount. I half expected to see a difference in memory since the C is much more stripped down in &#8220;native&#8221; version vs the version with __init__ cruft from object function.</p>
<p>This has all been using spidermonkey-bin (smjs) so now im curious to see how other javascript implementations handle the details, as from the get-go i expected a huge increase in memory (not that I know anything about anything) from functions existing in the constructor and then being linked to a prototype, and all those &#8220;new&#8221; instances called in class. But it all seems negligible, in spidermonkey anyway. This could be a totally different story in IE, lol</p>
<p>for reference, heres my lame-o profile code (i know, i know, but it was enough to find all sorts of issues when exploring javascript scope and constructors)</p>
<pre>var date1 = new Date();
var milliseconds1 = date1.getTime(); 

load('custom.js'); // point this to which script to test
var l = [];
for (var j = 0; j &lt; 100000; ++j) {
    l.push(new A({name: &quot;Daniel&quot;, age: &quot;24&quot;}));
    l.push(new B({name: &quot;David&quot;, age: &quot;25&quot;}));
    l.push(new C({name: &quot;John&quot;, age: &quot;26&quot;}));
}

var date2 = new Date();
var milliseconds2 = date2.getTime(); 

var difference = milliseconds2 - milliseconds1;
print(l.length)
print(difference)</pre>
<p><strong>*** EDIT ***</strong> Also, function object needs a class(object) so you can call its magic methods, so in C this.__init__ = function(kwargs) { object.prototype.__init__.call(this, kwargs) }<br />
Of which, im a little confused, b/c I originally expected to not work. Anytime a Class(X) is called, its constructor gets replaced, so another Class(X) later on will be referring to that replaced class which i thought would cause some kind of error, or so i would think. So deep inheritance might cause some bad mojo with the amount of memory or hell if i know. I haven&#8217;t looked into that yet<br />
<strong>*** EDIT 2 ***</strong> Also, im not sure how much of a &#8220;class&#8221; this is really, if it turns out useful i may find a different name, maybe just call it &#8220;prototype&#8221; so like<br />
prototype(A, object)<br />
function A() {};<br />
var a = new A({name: &#8220;daniel&#8221;});</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dasacc22.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dasacc22.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dasacc22.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dasacc22.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dasacc22.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dasacc22.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dasacc22.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dasacc22.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dasacc22.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dasacc22.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dasacc22.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dasacc22.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dasacc22.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dasacc22.wordpress.com/66/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasacc22.wordpress.com&amp;blog=4458998&amp;post=66&amp;subd=dasacc22&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dasacc22.wordpress.com/2009/12/04/a-javascript-class-with-magic-methods/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/20d3d9aff719d2d9779b382ca810a8fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dasacc22</media:title>
		</media:content>
	</item>
	</channel>
</rss>
