<?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/"
	>

<channel>
	<title>SamuraiBlog.com</title>
	<atom:link href="http://samuraiblog.com/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://samuraiblog.com/wordpress</link>
	<description>Cursing and Cigarettes</description>
	<pubDate>Sat, 24 Apr 2010 01:36:47 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>OMG just ate an amazing burger at Pearls!</title>
		<link>http://samuraiblog.com/wordpress/2010/04/23/omg-just-ate-an-amazing-burger-at-pearls/</link>
		<comments>http://samuraiblog.com/wordpress/2010/04/23/omg-just-ate-an-amazing-burger-at-pearls/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 01:20:17 +0000</pubDate>
		<dc:creator>Samuel Sutch</dc:creator>
		
		<category><![CDATA[Editorial]]></category>

		<category><![CDATA[bloodyhell rant socialnetworking facebook twitter vanity]]></category>

		<guid isPermaLink="false">http://samuraiblog.com/wordpress/?p=235</guid>
		<description><![CDATA[The general uselessness of social networks like Facebook is starting to overtake it&#8217;s actual value. It&#8217;s excruciatingly unimportant to tell EVERYONE in 140 characters or less about a burger you just ate, or that you stained your pants while eating it. It&#8217;s disgusting to assume anyone, even your closest friends, significant others or family will [...]]]></description>
			<content:encoded><![CDATA[<p>The general uselessness of social networks like Facebook is starting to overtake it&#8217;s actual value. It&#8217;s excruciatingly unimportant to tell EVERYONE in 140 characters or less about a burger you just ate, or that you stained your pants while eating it. It&#8217;s disgusting to assume anyone, even your closest friends, significant others or family will care. Facebook and other social networks&#8217; core functionality is vanity which is why I find it so despicable.</p>
<p>Without any assumptions, the most disturbing side effect a social network has on its users - that they live a filtered, sculpted meta-life online - is one of it&#8217;s most attractive feature. Several aspects are in play to destroy the reality of life.</p>
<p><strong>Numbers, numbers numbers.</strong> Numbers everywhere. How many tweets? How many followers, friends, comments, wall posts! The endless stroking one&#8217;s ego tends to develop addictive qualities. One gets a constant benchmark on their social life. Give anyone the potential to socially live from the comfort of their couch and see what happens (well, we&#8217;re watching it right now).</p>
<blockquote><p>
I read about that on your Facebook status.
</p></blockquote>
<p><small>Hearing this flatters way too many people.</small></p>
<p>How exciting can life be when you publicize it, even if just to your friends? Isn&#8217;t that who you&#8217;ll likely be hanging out with on Friday? What are you going to talk about, everything that happened on your Twitter stream since you last saw each other?</p>
<p>If this sounds like the frustrated rant of an old fashioned minimalist, that would be accurate. I am seriously worried my race. People are forgetting how to talk, forgetting that they would have something to talk about if they hadn&#8217;t already said it all to everyone. </p>
<p>Before the internet, when you experienced something, it was personal, and you shared it with people who cared. You cultured the experience, made it a story, thought about it&#8217;s delivery and made it engaging. This is something that the &#8220;OMGLOLWTF&#8221; generation is going to loose. Slowly, but surely, human communication will change more than it had since the invention of the printing press or since the popularity of television.</p>
<p>Facebook even has the balls to recommend I contact people or &#8220;Say Hi&#8221; to those whom I haven&#8217;t contacted in a while, basically everyone connected to my account. Facebook realizes that having a social life is <strong>so complicated</strong> it has to remind it&#8217;s users how to do it right! Is it just me, or is this shit getting fucking out of control? </p>
<p><strong>All the while, companies like Facebook get fat, more powerful, finding <em>evil</em> ways to grow their wealth and influence with the information we, their users gave them, for free, mostly in vein, by exploiting our weaknesses, however small, subliminal, saturating our senses with hyper-targeted advertising.</strong></p>
<p>Sounds to me like we are inadvertently being turned into slaves.</p>
<p>Please, parents: don&#8217;t create Facebook pages for your kids, at least give them a few years of real life and let them discover it on their own.</p>
]]></content:encoded>
			<wfw:commentRss>http://samuraiblog.com/wordpress/2010/04/23/omg-just-ate-an-amazing-burger-at-pearls/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Web Console and Browser Added to django-json-rpc</title>
		<link>http://samuraiblog.com/wordpress/2009/11/07/django-json-rpc-web-console/</link>
		<comments>http://samuraiblog.com/wordpress/2009/11/07/django-json-rpc-web-console/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 04:48:41 +0000</pubDate>
		<dc:creator>Samuel Sutch</dc:creator>
		
		<category><![CDATA[Articles]]></category>

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

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

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

		<category><![CDATA[django-json-rpc]]></category>

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

		<guid isPermaLink="false">http://samuraiblog.com/wordpress/?p=218</guid>
		<description><![CDATA[This morning I put the finishing touches on the web console and service browser for <a href="http://github.com/samuraisam/django-json-rpc">django-json-rpc</a>. It's a fully-bundled utility to aid in rapid development of your web service. It's available on github now and will be a published to PyPI soon as I work out one more interface bug. A <a href="http://logjamm.in/django-json-rpc/json/browse/">live demo</a> is available. Screen after the jump.]]></description>
			<content:encoded><![CDATA[<p>This morning I put the finishing touches on the web console and service browser for <a href="http://github.com/samuraisam/django-json-rpc">django-json-rpc</a>. It&#8217;s a fully-bundled utility to aid in rapid development of your web service. It&#8217;s available on github now and will be a published to PyPI soon as I work out one more interface bug. A <a href="http://logjamm.in/django-json-rpc/json/browse/">live demo</a> is available. Check it out:</p>
<p><img src="http://samuraiblog.com/wordpress/wp-content/uploads/2009/11/jsonrpcbrowserscreen.png" alt="jsonrpcbrowserscreen" title="jsonrpcbrowserscreen" width="504" height="639" class="aligncenter size-full wp-image-226" /></p>
]]></content:encoded>
			<wfw:commentRss>http://samuraiblog.com/wordpress/2009/11/07/django-json-rpc-web-console/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JSON-RPC in Objective-C</title>
		<link>http://samuraiblog.com/wordpress/2009/11/06/json-rpc-in-objective-c/</link>
		<comments>http://samuraiblog.com/wordpress/2009/11/06/json-rpc-in-objective-c/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 12:11:28 +0000</pubDate>
		<dc:creator>Samuel Sutch</dc:creator>
		
		<category><![CDATA[Articles]]></category>

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

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

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

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

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

		<category><![CDATA[json-rpc]]></category>

		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://samuraiblog.com/wordpress/?p=208</guid>
		<description><![CDATA[Handling JSON in Objective-C is already pretty easy with the excellent strict parser provided by json-framework. However, interacting with a web service in a graphical application can be hard to get right. Frequently unresponsive or unpredictable behavior is a big turnoff for users. Recently I have been developing a lot for the iPhone and more [...]]]></description>
			<content:encoded><![CDATA[<p>Handling JSON in Objective-C is already pretty easy with the excellent strict parser provided by <a href="http://code.google.com/p/json-framework/">json-framework</a>. However, interacting with a web service in a graphical application can be hard to get right. Frequently unresponsive or unpredictable behavior is a big turnoff for users. Recently I have been developing a lot for the iPhone and more often than not, ideas that beget these applications revolve around central web applications. Many client-server interactions usually boil down to the familiar CRUD apps we&#8217;re all so familiar generating with Rails and Django but require much more effort.</p>
<p>Writing applications for a mobile device introduces several challenges: limited memory, slow network and a language and framework designed without an eye on modern agile web services. Recently while writing an iPhone application with heavy web interaction I got lazy doing all that work and wrote <a href="http://github.com/samuraisam/DeferredKit">DeferredKit</a> - a port of <a href="http://twistedmatrix.com/projects/core/documentation/howto/defer.html">Twisted&#8217;s Deferred</a> with many extensions for us Objective-C coders. DeferredKit makes asynchronous programming in Objective-C really easy with very little overhead and includes an asynchronous JSON-RPC client. It allows you to write code like this:</p>
<pre lang="c">
  - (void)doRegistration {
    [[[[[DKDeferred jsonService:SERVICE_URL]
       myApp] register:array_(self.username, self.password)]
      addCallback:callbackTS(self, doRegistrationCompleted:)]
     addErrback:callbackTS(self, doRegistrationFailed:)];
  }

  - (id)doRegistrationCompleted:(id)result {
    // do something with result
    return result;
  }

  - (id)doRegistrationFailed:(NSError *)err {
    // do something with error
    return err;
  }
</pre>
<h3>Jumping In</h3>
<p>Getting started with DeferredKit is relatively easy. Download the <a href="http://github.com/samuraisam/DeferredKit/tarball/master"source tarball</a> or pull DeferredKit from github and drop everything from <code>DeferredKit/CocoaDeferred/Source</code> into your project (you can also compile DeferredKit as a direct dependency in Xcode, a how-to is in the README).</p>
<p>First, a bit of explanation. Despite the recent addition of blocks to the Objective-C language, the blocks runtime is not available to us iPhone developers (or anybody who wants to deploy to targets older than 10.6, sadly). Also, since there is no native function object in Objective-C, functions can not be passed around as first-class citizens, stored in collection types, persisted, etc. DeferredKit provides one called <code>DKCallback</code>. You will almost never have to touch the interface of <code>DKCallback</code> since handy macros are provided to generate function objects.</p>
<p>A deferred is defined as an object that encapsulates a return value that is not yet available (meaning, it will be returned from the network when done downloading, or return from a thread when done computing). The deferred then dispatches the value to a series of callbacks as soon as it becomes available.</p>
<p>JSON-RPC is exposed in DeferredKit through a class called <code>DKJSONServiceProxy</code> which employs a bit of magic to enable the dynamic method calling pattern you saw above. For convenience, <code>autorelease</code> constructors are also provided in DKDeferred:</p>
<pre lang="c">
  id service = [DKDeferred jsonService:@"http://myservice.net/json/" name:@"myapp.sayHello"];
</pre>
<p><small>(note: don&#8217;t forget to <code>#import DKDeferred+JSON.h</code>)</small></p>
<p>Calling a method returns a deferred:</p>
<pre lang="c">
  DKDeferred *d = [service :args_array];
</pre>
<p>To which you must add at least one callback for the call to be performed. In this case, <code>callbackTS</code> builds a callback with a <code>target</code> (can be any object), and a <code>selector</code> to be performed. A callback could also be a function pointer, <code>NSInvocation</code> or any object conforming to the DKCallback protocol.</p>
<pre lang="c">
  [d addCallback:callbackTS(self, gotSayHelloResults:)];
</pre>
<p>In case your JSON-RPC server returns an error (via the <code>error</code> key) or encounters a network error or parse error, deferred will automatically call any errbacks, or &#8220;error callbacks,&#8221; added with an <code>NSError</code> object.</p>
<pre lang="c">
  [d addErrback:callbackTS(self, handleSayHelloError:)];
</pre>
<p>Callbacks and errbacks are written as a function or method which takes a single argument, the result and returns <code>id</code>. JSON-RPC results will always be an <code>NSDictionary</code> with a <code>result</code> key, among others.</p>
<pre lang="c">
  - (id)gotSayHelloResults:(id)results {
    self.helloLabel.text = [results objectForKey:@"result"];
    return nil;
  }
</pre>
<p>Errbacks are the same as callbacks except they will always be called with an <code>NSError</code> argument. The <code>userDict</code> dictionary will be populated with the error dictionary produced by your JSON-RPC server. <code>userDict</code> will be different for different error types however, so be sure to check which kind of error is being returned.</p>
<pre lang="c">
  - (id)handleSayHelloError:(NSError *)err {
    [self alertError:[[[error userDict] objectForKey:@"error"] objectForKey:@"message"]];
    return nil;
  }
</pre>
<h3>Conclusion</h3>
<p>I&#8217;ve only had the opportunity to touch on the basics of DeferredKit, but a post is coming soon with more details. It is a tested, lightweight framework for writing asynchronous code and can greatly improve your productivity when working with web services.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://samuraiblog.com/wordpress/2009/11/06/json-rpc-in-objective-c/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Django and JSON-RPC</title>
		<link>http://samuraiblog.com/wordpress/2009/11/03/django-and-json-rpc/</link>
		<comments>http://samuraiblog.com/wordpress/2009/11/03/django-and-json-rpc/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 09:47:36 +0000</pubDate>
		<dc:creator>Samuel Sutch</dc:creator>
		
		<category><![CDATA[Articles]]></category>

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

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

		<category><![CDATA[django-json-rpc]]></category>

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

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

		<guid isPermaLink="false">http://samuraiblog.com/wordpress/?p=167</guid>
		<description><![CDATA[In application development, I&#8217;ve yet to be the bearer of a product who&#8217;s primary functionality has not been aided or entirely supported by a central web application. It is uncommon for developers in this situation to have the luxury of using a common programming language between server and client implementations. A lot of developers will [...]]]></description>
			<content:encoded><![CDATA[<p>In application development, I&#8217;ve yet to be the bearer of a product who&#8217;s primary functionality has not been aided or entirely supported by a central web application. It is uncommon for developers in this situation to have the luxury of using a common programming language between server and client implementations. A lot of developers will end up rolling their own RPC which evolves over the lifetime of the product to meet its needs. This puts unneeded strain on the developer to fulfill the role of RPC expert as well as interface designer, and expert-everything-else.</p>
<p>I have done many primarily-RPC web applications using tomcat or PHP or twisted, but by far the best way is using Python and Django. However, I have always viewed the state of RPC in Django broken. While using Django for all sorts of other web application purposes is incredibly easy, getting started with RPC presents a lot more friction.</p>
<p>Introducing <a href="http://github.com/samuraisam/django-json-rpc">django-json-rpc</a>, a very easy way to expose your web application to the world of integrated applications.</p>
<p>Installation is as simple as:</p>
<pre lang="shell">
  easy_install django-json-rpc
</pre>
<p>Add a mount point to your <code>urls.py</code> file and import django-json-rpc.</p>
<pre lang="python">
  from jsonrpc import jsonrpc_site

  urlpatterns += patterns('',
    (r'^json/', jsonrpc_site.dispatch)
  )
</pre>
<p>The interface to django-json-rpc is exposed through only one function - the <code>jsonrpc_method</code> decorator. Functions that use this decorator may be placed anywhere in the source tree and need only import <code>jsonrpc.jsonrpc_method</code>.</p>
<pre lang="python">
  from jsonrpc import jsonrpc_method

  @jsonrpc_method('app.sayHello')
  def say_hello(request, name):
    return "Hello, " + name
</pre>
<p>To hook your views into the default jsonrpc site, they must simply be imported somewhere by Django. The best place for this is in your <code>urls.py</code> file, which should now look something like this:</p>
<pre lang="python">
  from jsonrpc import jsonrpc_site
  import myapp.views

  urlpatterns += patterns('',
    (r'^json/', jsonrpc_site.dispatch)
  )
</pre>
<p>Test your service with the provided Proxy:</p>
<pre lang="shell">
  ./manage.py runserver 8080

  ./manage.py shell
</pre>
<pre lang="python">
  >>> from jsonrpc.proxy import ServiceProxy
  >>> s = ServiceProxy('http://localhost:8080/json/')
  >>> s.app.sayHello('Sam')
  {u'error': None, u'id': u'jsonrpc', u'result': u'Hello Sam'}
</pre>
<h3>HTTP GET</h3>
<p>Django-json-rpc supports JSON-RPC version 1.1 which includes support for HTTP GET, meaning, all your REST are belong to us as well. Add the HTTP GET mount point to your <code>urls.py</code> file:</p>
<pre lang="python">
  from jsonrpc import jsonrpc_site
  import myapp.views

  urlpatterns += patterns('',
    (r'^json/', jsonrpc_site.dispatch),
    (r'^json/(?P<method>[a-zA-Z0-9.]+)$', jsonrpc_site.dispatch)
  )
</method></pre>
<p>It is required by django-json-rpc to mark each method safe for dispatch through HTTP GET. <code>jsonrpc_method('sayHello')</code> becomes:</p>
<pre lang="python">
  jsonrpc_method('app.sayHello', safe=True)
</pre>
<p>Now your method will be available at <code>http://localhost:8080/json/app.sayHello?name=Sam</code>. HTTP GET requests only support string and number typed arguments.</p>
<h3>Authentication</h3>
<p>The django-json-rpc package also supports authentication, by default using <code>django.contrib.auth</code>&#8217;s model backend - the <code>User</code> object we&#8217;re all so familiar with, however you may provide any method, including using any authentication middleware. If you aren&#8217;t using middleware, <code>username</code> and <code>password</code> arguments will automatically be added to the beginning of the argument list for your method.</p>
<pre lang="python">
  @jsonrpc_method('app.sayHello', authenticated=True)
  def say_hello(request):
    return "Hello, " + request.user.first_name
</pre>
<pre lang="python">
  >>> s.app.sayHello('samuraiblog', 'password')
  {u'error': None, u'id': u'jsonrpc', u'result': u'Hello Sam'}
</pre>
<h3>Version Agnostic</h3>
<p>django-json-rpc will continue to work regardless of which version JSON-RPC client you happen to be using. It supports all argument types supported in JSON-RPC versions 1.0, 1.1 and 2.0, and will respond if a client specifies the version in either the <code>jsonrpc</code> or <code>version</code> key.</p>
<h3>Conclusion</h3>
<p>I have used this package for the development of several commercial iPhone applications and it has greatly improved my productivity in developing a web service backend. Up next? A django-xmlrpc? Haha! Fuck that!</p>
]]></content:encoded>
			<wfw:commentRss>http://samuraiblog.com/wordpress/2009/11/03/django-and-json-rpc/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Compressing NSData objects using zlib</title>
		<link>http://samuraiblog.com/wordpress/2009/11/02/compressing-nsdata-objects-using-zlib/</link>
		<comments>http://samuraiblog.com/wordpress/2009/11/02/compressing-nsdata-objects-using-zlib/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 11:28:35 +0000</pubDate>
		<dc:creator>Samuel Sutch</dc:creator>
		
		<category><![CDATA[Articles]]></category>

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

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

		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://samuraiblog.com/wordpress/?p=185</guid>
		<description><![CDATA[This entirely iPhone friendly tutorial highlights how easy it is to compress our familiar NSData objects using zlib - the most commonly used compression library on the planet. This is the same library that compresses the PNGs and PDFs, ZIPs and GZIPed files that make up your daily life.
The zlib c library, which is bundled [...]]]></description>
			<content:encoded><![CDATA[<p>This entirely iPhone friendly tutorial highlights how easy it is to compress our familiar NSData objects using zlib - the most commonly used compression library on the planet. This is the same library that compresses the PNGs and PDFs, ZIPs and GZIPed files that make up your daily life.</p>
<p>The <a href="http://www.zlib.net/">zlib c library</a>, which is bundled with all Mac OS X and iPhone 2.0+ devices offers an extensive but non obtrusive API for compressing data. The most basic functions are the stream API which serve nicely when, for instance, dealing with a large files, or matching a specific compression requirement. The method presented here is one which is utility provided by the atop the streaming API. Readers familiar with python will recognize this if ever you&#8217;ve had to handle data with the zlib module.</p>
<p>First, Allocate a data structure of type <code>const ByteF</code> containing the bytes in our uncompressed <code>NSData</code> structure.</p>
<pre lang="c">
  const Bytef *inBytes = (const Bytef *)[uncompressedData bytes];
</pre>
<p>Allocate enough data to start compressing data. The zlib manual recommends allocating 1% more than the length of your uncompressed data, plus twelve bytes. This gives zlib enough room to start compressing data, resizing the output buffer as needed.</p>
<pre lang="c">
  uLongf outLength = ([uncompressedData length] * 1.1) + 12;
  Bytef *outBytes = (Bytef *)malloc(outLength);
</pre>
<p>Now simply call <code>compress</code>:</p>
<pre lang="c">
  int z_result = compress(outBytes, &#038;outLength, inBytes, [uncompressedData length]);
</pre>
<p><code>compress</code> will return one of three constants. To handle errors, check for the return value. Depending on your situation, you could return an NSError. In this case, I return an empty NSData and check for return value length.</p>
<pre lang="c">
  NSData *ret;
  if (z_result == Z_OK) {
    ret = [NSData dataWithBytesNoCopy:outBytes length:outLength freeWhenDone:YES];
  } else {
    ret = [NSData data];
    switch (z_result) {
      case Z_MEM_ERROR:
        printf("compressData got Z_MEM_ERROR out of memory. :(");
      case Z_BUF_ERROR:
        printf("compressData got Z_BUF_ERROR output buffer wasn't larege enough :(");
      default:
        break;
    }
  }
}
</pre>
<h4>compressData function</h4>
<pre lang="c">
NSData* compressData(NSData *uncompressedData) {
  if ([uncompressedData length] == 0)
    return uncompressedData;
  const Bytef *inBytes = (const Bytef *)[uncompressedData bytes];
  uLongf outLength = ([uncompressedData length] * 1.1) + 12;
  Bytef *outBytes = (Bytef *)malloc(outLength);
  int z_result = compress(outBytes, &#038;outLength, inBytes, [uncompressedData length]);
  NSData *ret;
  if (z_result == Z_OK) {
    ret = [NSData dataWithBytesNoCopy:outBytes length:outLength freeWhenDone:YES];
  } else {
    ret = [NSData data];
    switch (z_result) {
      case Z_MEM_ERROR:
        printf("compressData got Z_MEM_ERROR out of memory. :(");
      case Z_BUF_ERROR:
        printf("compressData got Z_BUF_ERROR output buffer wasn't larege enough :(");
      default:
        break;
    }
  }
  return ret;
}
</pre>
<h4>compressData that returns an <code>NSError</code>.</h4>
<pre lang="c">
#define ZLIB_COMPRESS_DOMAIN @"zlib_compress_domain"

NSError* compressData2(NSData *inData, NSData **outData) {
  if ([inData length] == 0) {
    *outData = inData;
    return nil;
  }
  const Bytef *inBytes = (const Bytef *)[inData bytes];
  uLongf outLength = ([inData length] * 1.1) + 12;
  Bytef *outBytes = (Bytef *)malloc(outLength);
  int z_result = compress(outBytes, &#038;outLength, inBytes, [inData length]);
  if (z_result == Z_OK) {
    *outData = [NSData dataWithBytesNoCopy:outBytes length:outLength freeWhenDone:YES];
    free(outBytes);
    return nil;
  }
  return [NSError errorWithDomain:ZLIB_COMPRESS_DOMAIN
    code:z_result userInfo:[NSDictionary dictionary]];
}
</pre>
<h4>NSData category</h4>
<pre lang="c">
@interface NSData (CompressionAdditions)

- (NSData *)compress;
- (NSData *)compress:(NSError **)errorOut;

@end

@implementation NSData (CompressionAdditions)

- (NSData *)compress {
  return compressData(self);
}

- (NSData *)compress:(NSError **)errorOut {
  NSData *ret;
  *errorOut = compressData2(self, &#038;ret);
  return ret;
}

@end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://samuraiblog.com/wordpress/2009/11/02/compressing-nsdata-objects-using-zlib/feed/</wfw:commentRss>
		</item>
		<item>
		<title>File Uploads in twisted.web</title>
		<link>http://samuraiblog.com/wordpress/2009/10/30/file-uploads-in-twisted-web/</link>
		<comments>http://samuraiblog.com/wordpress/2009/10/30/file-uploads-in-twisted-web/#comments</comments>
		<pubDate>Sat, 31 Oct 2009 06:36:42 +0000</pubDate>
		<dc:creator>Samuel Sutch</dc:creator>
		
		<category><![CDATA[Articles]]></category>

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

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

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

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

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

		<category><![CDATA[twisted.web]]></category>

		<guid isPermaLink="false">http://samuraiblog.com/wordpress/?p=172</guid>
		<description><![CDATA[Twisted is a python package for building asynchronous applications. It&#8217;s wide range of uses and sub-packages are daunting; I&#8217;ve developed with Twisted for several years now and still find it&#8217;s vast expanse of code intimidating. Twisted in 60 seconds is an excellent resource for anyone beginning with twisted and twisted.web. Here, we&#8217;re filling yet another [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://twistedmatrix.com/trac/">Twisted</a> is a python package for building asynchronous applications. It&#8217;s wide range of uses and sub-packages are daunting; I&#8217;ve developed with Twisted for several years now and still find it&#8217;s vast expanse of code intimidating. <a href="http://jcalderone.livejournal.com/50562.html">Twisted in 60 seconds</a> is an excellent resource for anyone beginning with twisted and twisted.web. Here, we&#8217;re filling yet another gap in the twisted documentation.</p>
<p>Not surprisingly, handling file uploads in twisted.web is straight forward. Files are accessed through the <code>args</code> attribute of the <code>request</code> parameter to your render method. Since there can be multiple files for that given field, whether there are one or more, <code>request.args[FIELD_NAME]</code> will always be an array.</p>
<pre lang="python">
from twisted.internet import reactor
from twisted.web import resource, server

class FileUploadService(resource.Resource):
  def render_GET(self, request):
    return '''
<form enctype="multipart/form-data" method="post" action=".">
<input type="file" name="da_file"/>
<input type="submit"/>
              </form>

'''

  def render_POST(self, request):
    return 'You submitted a file that was %i bytes' % len(request.args['da_file'][0])

root = resource.Resource()
root.putChild("upload", FileUploadService())
factory = server.Site(root)
reactor.listenTCP(8088, factory)
reactor.run()
</pre>
<p>According to the twisted.web documentation. This method of handling file uploads is not preferred. In fact, the preferred way is to use the more complex twisted.web2 package which supports streaming uploads. However, the twisted devs are working on porting most of twisted.web2&#8217;s features to twisted.web in an effort to consolidate the two. In production code, I have chosen to stick with twisted.web since it seems to be the package which will remain the most compatible with future versions of Twisted.</p>
]]></content:encoded>
			<wfw:commentRss>http://samuraiblog.com/wordpress/2009/10/30/file-uploads-in-twisted-web/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Create a Long-Running-Process Server for Django</title>
		<link>http://samuraiblog.com/wordpress/2009/03/06/create-a-long-running-process-server-for-django/</link>
		<comments>http://samuraiblog.com/wordpress/2009/03/06/create-a-long-running-process-server-for-django/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 07:47:58 +0000</pubDate>
		<dc:creator>Samuel Sutch</dc:creator>
		
		<category><![CDATA[Code]]></category>

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

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

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

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

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

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

		<guid isPermaLink="false">http://samuraiblog.com/wordpress/?p=127</guid>
		<description><![CDATA[Have you ever wanted to put up a server made exclusively to handle the expensive actions in your web app? In this article I will be showing you how to create a server to that will be set up to receive commands from your web server and process them in the context of your django [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever wanted to put up a server made exclusively to handle the expensive actions in your web app? In this article I will be showing you how to create a server to that will be set up to receive commands from your web server and process them in the context of your django web app. This technique could be used many places such as a desktop GUI application, or a web service architecture.</p>
<p>Say you have work unit  WU which takes <a title="python pickle module" href="http://docs.python.org/library/pickle.html" target="_blank">pickleable</a> arguments (a, b, c). If your work unit is thread-safe (it modifies no global variables, and causes no side effects in your application) it can be preformed on in another process, or even on another machine, allowing you to return control to the user immediately.</p>
<p>For example, I want to add the ability for a user to import their contacts using X contacts service:</p>
<p><strong>Fig 1: project/views.py</strong></p>
<pre lang="python" line="1">def import_contacts(request):
    from my.specialsauce.contacts import run_contacts_import
    contacts = run_contacts_import(request)
    return render_to_response('t/contacts-import.html', {'contacts': contacts})</pre>
<p>Currently, the view retrieves and imports the users contacts in the view, making the user wait until the operation has completed to see the returned page. What if we could implement this in a way which would return control to the user immediately, firing off run_contacts_import in another thread, another process, or even another server!</p>
<p>To do this we will need Django, <a href="http://pypi.python.org/pypi/multiprocessing">multiprocessing</a> and Python 2.5+. Now, I will assume you are already as far as <strong>Fig 1</strong>. Say a user with 10,000 contacts (or even 100) ambles along and imports their contacts. Both users are going to be waiting much longer than the average gmail-generation-web-user can be expected to wait. They will hit refresh, restarting this process and crashing your server.</p>
<p>Since the <a href="http://docs.djangoproject.com/en/dev/ref/request-response/">Django request</a> object is pickleable, we can pass it as an argument to another process using multiprocessing.</p>
<p><strong>Fig 2: project/views.py</strong></p>
<pre lang="python" line="1">from multiprocessing import Pool

m = Pool(10)

def import_contacts(request):
    # run_contacts_import will have to update request.session['CONTACT_IMPORT_STATUS']
    has_status = 'CONTACT_IMPORT_STATUS' in request.session
    status = has_status and request.session['CONTACT_IMPORT_STATUS'] == True
    if status is True:
        return HttpResponseRedirect('/import-finished/')
    elif not status and has_status:
        return render_to_response('t/contacts-import-not-finished.html', {})
    elif not has_status:
        from my.specialsauce.contacts import run_contacts_import
        m.apply_async(run_contacts_import, args=(request,))
        return render_to_response('t/contacts-import.html', {'contacts': contacts})</pre>
<p>This seems simple enough, and upon first inspection, seems to work rather decently. However, this adds a global variable to our Django process, which is a bad idea. Using this technique, it would be best to create a lock, spawn off a new thread, and acquire/release the lock while running apply_async (blegh). Unfortunately, this can eventually make your Django server unresponsive as many users come to run the expensive process (simply via system load). We need to move this process, and possibly a few others off our new server.</p>
<p>To do this, the Python multiprocessing package provides the high-level <a href="http://docs.python.org/library/multiprocessing.html#module-multiprocessing.managers">Manager</a> class. The Manager class is used to pipe commands between managers in different instances of the python interpreter.</p>
<h3>Create the Manager Class</h3>
<p>First, we need to create the Manager class that will eventually be implemented as our server. Create a file called managers.py in project/managers.py.</p>
<p><strong>Fig 3: project/managers.py</strong></p>
<pre lang="python" line="1">from multiprocessing.managers import BaseManager

from my.specialsauce.contacts import run_contacts_import

# This is the shared object. It simply implements a function which applies to the instance variable
# pool, which will be installed when the server is actually started (in a snippet below)
class ContactImporter(object):
    def __init__(self, pool=None):
        self.pool = pool

    def run_import(self, *args):
        self.pool.apply_async(run_contacts_import, args=args)

# instantiate the shared object
importer = ContactImporter()

# our manager
class CManager(BaseManager):
    pass

# you need to register a function which will return the shared object
# the shared object could be anything pickleable in python, in this case
# our new-style class descending from object
CManager.register('get_importer', callable=lambda:importer)</pre>
<h3>Create the Server</h3>
<p>We are going to be making a daemon server that we can start and stop using your projects manage.py file. To do this create a file called lrpserver.py in project/management/commands/lrpserver.py.</p>
<p><strong>Fig 4: project/management/commands/lrpserver.py</strong></p>
<pre lang="python" line="1">import os
import sys
import time
from optparse import make_option
from signal import SIGTERM

from multiprocessing import Pool

from django.core.management.base import BaseCommand
from django.conf import settings

from project.managers import CManager, importer

class Command(BaseCommand):
    option_list = BaseCommand.option_list + (
        make_option('--pidfile', dest='pidfile', default='', help="Specifies the PID file to use."),
        make_option('--start', dest='start', default='no', help='Starts the daemon'),
        make_option('--stop', dest='stop', default='no', help='Stops the daemon'),
        make_option('--restart', dest='restart', default='no', help='Restarts the daemon')
    )
    def handle(self, *args, **options):
        pidfile = options.get('pidfile')
        if not pidfile:
            print "--pidfile arg required"
            sys.exit(1)
        start = options.get('start')
        stop = options.get('stop')
        restart = options.get('restart')
        server = getattr(settings, 'LRP_SERVER_HOST', None)
        port = getattr(settings, 'LRP_SERVER_PORT', None)
        authkey = getattr(settings, 'LRP_SERVER_AUTHKEY', None)

        if server is None or port is None or authkey is None:
            print 'LRP_SERVER_HOST, LRP_SERVER_PORT and LRP_SERVER_AUTHKEY values required in settings file.'
            sys.exit(1)

        # This daemonizes our process and starts the server
        def _start():
            print 'Starting Long Running Process Server'
            from django.utils.daemonize import become_daemon
            become_daemon()
            fp = open(pidfile, "w")
            fp.write('%d\n' % os.getpid())
            fp.close()

            # set the pool that importer.run_import requires
            importer.pool = Pool(processes=10)
            # create an instance of CManager, get a server instance and start the server loop
            m = CManager(address=(server, port), authkey=authkey)
            s = m.get_server()
            s.serve_forever()

        def _stop():
            try:
                fp = open(pidfile, 'r')
                pid = int(fp.read().strip())
                fp.close()
            except IOError:
                pid = None
            if not pid:
                print 'Long Running Process Server Not Currently Running'
                return
            try:
                print 'Stopping Long Running Process Server'
                while 1:
                    os.kill(pid, SIGTERM)
                    time.sleep(0.1)
            except OSError, err:
                err = str(err)
                if err.lower().find('no such process') > 0:
                    if os.path.exists(pidfile):
                        os.remove(pidfile)
                else:
                    print err
                    sys.exit(1)

        def _restart():
            _stop()
            _start()

        if str(start) == 'yes':
            return _start()
        elif str(stop) == 'yes':
            return _stop()
        elif str(restart) == 'yes':
            return _restart()
        else:
            print 'Options: pidfile=%s start=%s stop=%s restart=%s' % (pidfile, start, stop, restart)
            print 'One of --(start|stop|restart)=yes is required.'
</pre>
<h3>Add the Required Settings to Your settings.py File</h3>
<p>The server and client require three settings, the host name of your server, the port on which the server is listening and the auth key of the required to access the server. In your settings.py file add the following with your values. For now, use the blank string &#8221; as the setting for host name. This instructs the server to serve from localhost. (Hint: If you do not know this value use socket.getfqdn()). </p>
<p><strong>Fig 5: settings.py</strong></p>
<pre lang="python" line="1">LRP_SERVER_HOST = ''
LRP_SERVER_PORT = 5667
LRP_SERVER_AUTHKEY = 'password'</pre>
<h3>Modify Your View Code</h3>
<p>To connect to the server, you must spawn a thread which creates an instance of the manager, connects and sends the command.</p>
<p><strong>Fig 6: project/views.py</strong></p>
<pre lang="python" line="1">from threading import Thread
from multiprocessing.managers import BaseManager

from django.conf import settings

class CManager(BaseManager):
    pass

CManager.register('get_importer')

# This function will become a thread which instantiates the Manager class,
# connects and starts the long running process
def _start_import_thread(request):
    gci_manager = CManager(address=(settings.GCI_SERVER_HOST, settings.GCI_SERVER_PORT),
                           authkey=settings.GCI_SERVER_AUTHKEY)
    gci_manager.connect()
    importer = gci_manager.get_importer()
    importer.run_import(request)

# This is not a view, it's a helper function which starts
# the thread above
def start_contacts_import(request):
    t = Thread(target=_start_import_thread, args=[request])
    t.setDaemon(True)
    t.start()

def import_contacts(request):
    # run_contacts_import will have to update request.session['CONTACT_IMPORT_STATUS']
    has_status = 'CONTACT_IMPORT_STATUS' in request.session
    status = has_status and request.session['CONTACT_IMPORT_STATUS'] == True
    if status is True:
        return HttpResponseRedirect('/import-finished/')
    elif not status and has_status:
        return render_to_response('t/contacts-import-not-finished.html', {})
    elif not has_status:
        start_contacts_import(request)
        return render_to_response('t/contacts-import.html', {'contacts': contacts})</pre>
<h3>Start the Server and Let it Fly!</h3>
<p>And finally we may start the server.</p>
<pre lang="bash" line="1">python manage.py lrpserver.py --pidfile=/home/django/run/lrp.pid --start=yes</pre>
<p>Now you can run your view.</p>
<h3>Follow-Up</h3>
<p>This process is applicable to more than just crawlers and contact importers. It can be used to minimize the load on your server for any number of tasks such as image and other file processing or running large database updates. The server can be <strong>put on another machine</strong> simply by duplicating your django installation on another machine and using that machine&#8217;s socket.getfqdn() (or ip address) value as the host name in your configs. You can also add a <strong>javascript status updater</strong> to notify the user of progress information related to their request.</p>
]]></content:encoded>
			<wfw:commentRss>http://samuraiblog.com/wordpress/2009/03/06/create-a-long-running-process-server-for-django/feed/</wfw:commentRss>
		</item>
		<item>
		<title>43-Creature-Machine</title>
		<link>http://samuraiblog.com/wordpress/2008/06/03/43-creature-machine/</link>
		<comments>http://samuraiblog.com/wordpress/2008/06/03/43-creature-machine/#comments</comments>
		<pubDate>Wed, 04 Jun 2008 01:16:06 +0000</pubDate>
		<dc:creator>Samuel Sutch</dc:creator>
		
		<category><![CDATA[Creative Writing]]></category>

		<category><![CDATA[1920's]]></category>

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

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

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

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

		<guid isPermaLink="false">http://samuraiblog.com/creative-writing/43-creature-machine</guid>
		<description><![CDATA[Boneless creature of iron and oil,
Legless, headless and mindful of all.
Another series of rooms a-boil,
To chamber my froth, life, at your call.
This is my first creative writing post. It&#8217;s not much right now, as I&#8217;m still trying to figure out my first assignment. It seems I have some time today to write. No work until [...]]]></description>
			<content:encoded><![CDATA[<p>Boneless creature of iron and oil,<br />
Legless, headless and mindful of all.<br />
Another series of rooms a-boil,<br />
To chamber my froth, life, at your call.</p>
<p>This is my first creative writing post. It&#8217;s not much right now, as I&#8217;m still trying to figure out my first assignment. It seems I have some time today to write. No work until Thursday at 3P. Good. Poems are cool to write. :)</p>
<h3 id="h5jt0"><strong id="h5jt1">Genesis Log Page 43 </strong></h3>
<p id="h5jt2">June 9&#8242;th 1929; 1:30 AM<br id="u9d.0" /></p>
<p id="h5jt2">Twenty years ago today, I began building a machine. Now, nearly the size of a $2/hr room in San Francisco, I have finally been able to name this monster with a name signifying it&#8217;s being. Genesis. Why? Fuck you, that&#8217;s why. I call it Genesis.</p>
<p id="h5jt5">Sure, that may be a piss-poor explanation, but this machine is beyond the realm of revolutionary. Fuck, it can build itself! Well, since last night that statement has been false. There&#8217;s a guy I met who owns a metal shop. Genesis, in big, brassy letters. On the door or awning or something&#8211;and it wouldn&#8217;t be so much for the letters, because obviously I could handle that myself, as to, finally validate our existence to the world&#8211;but not until this bitch is again reproducing.</p>
<p id="h5jt9">June 9&#8242;th 1929; Around 3 AM</p>
<p id="h5jt12">I&#8217;ve stopped working on the machine for a few minutes to log my progress and have a cigarette. Along the way I&#8217;ve discovered the master unit started binding on all metal materials. Explanation at this point is beyond me. Note to self: Discover a method to minimize vibrations in the cutting module near the back end of master unit without disturbing the spacing of lower modules (which would of course throw timing off too). <br id="h5jt13" /></p>
<p id="h5jt16">June 9&#8242;th 1929; 4:30 AM</p>
<p id="h5jt19">Another smoke and log break. Two smokes, and now for the log. I should really get an eraser. I tried coating a fraction (every other twice) of the fingers (in the master unit, both main and secondary clusters) in a light polytetrafluoroethylene, but did too many. The machine dropped the first production unit and spilled molten glass all over the conveyance, which is luckily made of iron slats. The scrap pan below caught the rest. I cleaned the glass. And I still have no fucking clue why it was loading glass. Maybe it&#8217;s getting a bit late.</p>
<p id="h5jt22">June 9&#8242;th 1929; 5AM</p>
<p id="h5jt25">Another smoke. This is killing me. Not the smokes, they are too, it&#8217;s the nicotine. I guess it is the smokes</p>
<p id="h5jt28">June 9&#8242;th 1929; Around 6AM</p>
<p id="h5jt31">During my last log entry I had an idea regarding my smoking habit. I took four cigarette butts and coated them with the polytetrafluoroethylene and wedged them under plates that mount the cutting module. No more vibrations. Rather, few enough, and muted enough, that it can manage. Didn&#8217;t fix any other problems though. Also not really a production-ready design decision. Why is it still choosing glass? A logical explanation continues to allude me. Everything seems to work but the final product is still a heap of shit!</p>
<p id="h5jt31">June 9&#8242;th 1929; 8AM</p>
<p id="h5jt31">The cigarette idea was a bad one. Polytetrafluoroethylenes main property is that it&#8217;s slippery as fuck. I won&#8217;t bother with the coefficients, it&#8217;s just amazing stuff. Once it started producing again, before any new parts could get to the assembler, one butt shot clear across the room and landed in my hair. Note to self: don&#8217;t be an idiot, cigarettes should not be a part of any sound engineering decision. Nothing else in this shop can harness the vibrations of that tad of cotton wrapped in paper, however; so tomorrow during the day I&#8217;ll design something similar to a cigarette butt.</p>
<p id="h5jt31">I&#8217;ve also realized these coatings reach a sweat spot after breaking in. Though the master unit still malfunctions like fuck, due to the slick shit, I can turn it up past ten which blurrs the movements of the finger clusters in my vision. This really helps with motivation to continue. My shoulders hurt. If I had a stroke right now I&#8217;d be very pissed.<br id="ihqj1" /></p>
<p id="h5jt34">June 9&#8242;th 1929; 9AM RECAP</p>
<p id="h5jt37">They day is getting a bit long and I&#8217;m afraid all of this noise is going to start attracting some unwanted attention. Will continue tomorrow night. Both Genesis and I are very tired. Oh, the glass. I figured out why it was choosing glass. The entire time it was trying to install vacuum tubes everywhere. Perhaps it decided it needed more logic but wasn&#8217;t keeping track of what part of what module of what unit it was constructing.</p>
<p id="h5jt40">The final machine we made today did, however, surprise me. When it came out, it turned itself on. Not sure if Genesis wired it that way, or if Genesis somehow evolutionarily developed the machine as I worked on her. We did generate four full iterations last night, not counting the most recent. It&#8217;s still a heap of shit, and just sits there. Still, I&#8217;ve yet to see how it&#8217;s actually built. I tried plugging Genesis&#8217; material harness into it, but it had no valve control and spilled shit all over the floor. Another try, more spilt shit.</p>
<p>I get a different feeling from this machine though, and perhaps I won&#8217;t recycle it. It&#8217;s no where near as complete as the first successful repro, but seems to have more life. It sits, on. Powering itself much like it&#8217;s mother machine, but doing much, much less. I got the feeling when it powered on automatically, it may be that action that continues to prod at me. Or it could be that I&#8217;ve recycled four other machines tonight, is it my own guilt?</p>
<p>Most likely, it&#8217;s two fucking packs of Lucky Strikes. I need a regular god damn night job.</p>
]]></content:encoded>
			<wfw:commentRss>http://samuraiblog.com/wordpress/2008/06/03/43-creature-machine/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Blogs are Stupid, Write Blogs!</title>
		<link>http://samuraiblog.com/wordpress/2008/04/07/blogs-are-stupid/</link>
		<comments>http://samuraiblog.com/wordpress/2008/04/07/blogs-are-stupid/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 18:19:53 +0000</pubDate>
		<dc:creator>Samuel Sutch</dc:creator>
		
		<category><![CDATA[Rants]]></category>

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

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

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

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

		<category><![CDATA[san francisco]]></category>

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

		<guid isPermaLink="false">http://samuraiblog.com/rants/blogs-are-stupid</guid>
		<description><![CDATA[I was reading a blog, just now, not much unlike a lot of time that I spend reading blogs. Reddit.com is the death knell of productivity and it links to a shit load of blogs. The concept of a blog is great but I&#8217;m slowly realizing how stupid they really are. People get their feelings [...]]]></description>
			<content:encoded><![CDATA[<p>I was reading a blog, just now, not much unlike a lot of time that I spend reading blogs. Reddit.com is the death knell of productivity and it links to a shit load of blogs. The concept of a blog is great but I&#8217;m slowly realizing how stupid they really are. People get their feelings out, they write&#8230; and all is well in that regard. But blogs that are written to be read are fucking dumb. No one reads blogs until they have absolutely nothing else to do, eager to soak up more useless information seasoned with useless personal life information. As content, blogs suck.</p>
<p>People however do not read regular news, either. Newspapers are only read by a small microcosm of people&#8230; as a film maker I can not even count on people reading title cards. And yet, people read everything. Advertisements anyway, flashy shit that catches their attention in one word or less. I live in San Fran-fucking-cisco and it seems like the advertisement capitol of the world (though I realize that&#8217;s not true, many cities have LITTLE or NO regulation on the matter).</p>
<p>Practically every word one sees in this city is intended to sell the viewer something. There is signage everywhere, and it&#8217;s insane. I bargain that people&#8217;s senses, their ability to read or underlying, subconscious desire to read gets so watered down that when they actually _should_ be reading and _should_ be paying attention that they&#8217;re not. Fuckers. It&#8217;s subconscious though, and they can&#8217;t do anything about it. I just fucking ignore it.</p>
<p>And I certainly don&#8217;t expect people to realize what they should be reading.. and what they shouldn&#8217;t. No, they would have to be told to.</p>
<blockquote><p><strong>DON&#8217;T READ THIS SIGN</strong></p></blockquote>
<p>Perhaps it&#8217;s the problem with how little people are involved with art, and how it can help one become a better person. One learns an unmeasurable amount about themselves when creating art, no matter what it is, as long as it makes them artistic and they realize what that can do for them. Few people I&#8217;ve met other than artists even realize what self expression is, much less how to do it. It doesn&#8217;t involve buying new sneakers, or even buying old sneakers. It doesn&#8217;t involve buying anything, in fact, and it god damn well shouldn&#8217;t.</p>
<p>Pick up an art and start expression your emotions with it. Stick with it for long enough until you no longer are thinking about _the art_ and thinking about yourself. So many people think they can express themselves by how they dress&#8230; and mostly what that indicates is that person has absolutely no idea how to express themselves, and this is their closest interpretation. First time expressionists&#8230; we&#8217;ll call them expressionists, should also not look at blogging as a form of self expression. Choose something that is definitely not on a computer. Choose painting or acting (but for god sakes keep your head straight&#8230; remember to express!)</p>
<p>Most bloggers that I know, or not necessarily bloggers&#8230; people who write &#8220;blogs.&#8221; IE: friends, people from school, the regular joe schmoe&#8230; like me (?)&#8230; will pull up Firefox to write a blog, open tabs for My$psace, F@cebook, Gmail, etc, etc, read through those first, spend hours perhaps re-connecting with their friends they re-connected to last night. Their heads are wrapped up in an entirely wrong space. Social time is not expression time, for me anyway. I don&#8217;t believe people can really express themselves in social situations and that is increasingly what computers are becoming for young people.</p>
<p>Wow the thought process was weird on that entry&#8230;</p>
<p>If you are planning on blogging, just remember this: shut the fuck up. Just write exactly how you feel, as fast as you can. Force yourself to ignore punctuation, spelling, grammar&#8230; whether your writing&#8217;ll get you into trouble or not or whether your piece makes sense, those mechanics can get in the way of getting out what you really want to write, perhaps working through an inner mental problem (if you do it this way, writing will help you think).</p>
]]></content:encoded>
			<wfw:commentRss>http://samuraiblog.com/wordpress/2008/04/07/blogs-are-stupid/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A Cinematic Gaming Experience</title>
		<link>http://samuraiblog.com/wordpress/2008/02/18/a-cinematic-gaming-experience/</link>
		<comments>http://samuraiblog.com/wordpress/2008/02/18/a-cinematic-gaming-experience/#comments</comments>
		<pubDate>Mon, 18 Feb 2008 23:19:18 +0000</pubDate>
		<dc:creator>Samuel Sutch</dc:creator>
		
		<category><![CDATA[Articles]]></category>

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

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

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

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

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

		<guid isPermaLink="false">http://samuraiblog.com/articles/a-cinematic-gaming-experience</guid>
		<description><![CDATA[In Half Life 2: Episode 2, the end arena is an amazing experience and something that (though I don&#8217;t claim to have a pulse, really, on the gaming industry) should stand out among all other games. SPOILER [: You are placed in a massive, valley-wide arena to fight a ridiculous onslaught of striders and hunters. [...]]]></description>
			<content:encoded><![CDATA[<p>In Half Life 2: Episode 2, the end arena is an amazing experience and something that (though I don&#8217;t claim to have a pulse, really, on the gaming industry) should stand out among all other games. <strong>SPOILER [: </strong>You are placed in a massive, valley-wide arena to fight a ridiculous onslaught of striders and hunters. Enemies that are used as bosses throughout the series are now trying to destroy the only chance your kind has for survival: and they're pummeling you with many times as many as you'd be expected to handle in the past. <strong>:]</strong></p>
<p>The environment is a beautiful wooded mountain valley. There are many completely-destroyable buildings throughout the valley: and they destroy beautifully on a massive scale. A building destroyed by a strider completely breaks down into the many components of buildings-2 x 4s, and other building products that all crash and explode, each piece falling randomly-the animations are not scripted.</p>
<p>After your trouble with the strider/hunter battle, the cinematic experience really takes off. Even though it&#8217;s the end of the game, movie mode is put on overdrive. The characters all seem to pour into their performances. You&#8217;re knocked to the ground and your camera movement is restricted. Shit goes on around you that you can&#8217;t help. Some people may be annoyed by this-but it&#8217;s vital. The restricted camera movement, the low angle, you, Gordan Freeman, pinned to the ground and helpless, like a human on the very same level as the rest cast-is all really engaging.</p>
<p>Imagine a movie director: Terry Gilliam, and a movie: 12 Monkeys. By the time of 12 Monkeys, a re-make of an older French experimental film, La Jete, Terry Gilliam is already a brilliant and accomplished director. It is classic of his style to use camera angles to convey a feeling, perhaps that of the protagonist or subject of the scene. Though it&#8217;s just not camera angles that contribute to the feel of the Gilliam film-it&#8217;s the entire experience. Terry Gilliam creates cinematic experiences.</p>
<p>The game industry has always been one that emphasizes experiences. As games push the boundaries of realism, they will naturally draw upon their past experience as super-naturalistic experiences to become hyper-real: as in movies, they will exaggerate real life in real life terms in an effort to be more engaging and more realistic. Game companies know this, look at The Sims 2. Though they had the capability to create a life simulator, it&#8217;s much more fun in the cartoony manor they executed it.  The Sims, however, can be analogous to a Judd Apatow (Superbad, 40 Yr Old Virgin) movie. They have some real elements but are largely a projection of real life, an obvious fabrication.</p>
<p>A movie like 12 Monkeys, however, is much more fitting as an analogy for the Half Life series. Sims, as with 40 Yr Old Virgin embodies what our psyche wishes it could be: fun, without care, essentially, as infants. Half Life 2 follows a much more serious thread: world destruction and the destruction of our race. It&#8217;s cinematic story line includes charismatic, likable characters, one of whom you <em>get to be</em>. The story line is as thick as it&#8217;s directing: you are but a mere human, your entire race is being used as slaves and thinned out, restricted from reproducing - your race backlashes and you can now reproduce, and who is this Alyx character, among the other Gordon admirers, her family and her familys collegues? It&#8217;s all rather impressive for a game. Which will, within a minute&#8217;s time take you frome near death to flirtatious conversation. Very compelling.</p>
<p>Where am I going with this? No where. I&#8217;ve come back to this post at least 10 times, wanted to post it and then haven&#8217;t because I have no ending.I&#8217;m just hoping games get more and more cinematic and compelling! I&#8217;m tired of Doom 3! Fuck Doom 3! What did Doom 3 innovate (or Quake 4 or COD 2,3,4 or Crysis or &#8230;)? </p>
]]></content:encoded>
			<wfw:commentRss>http://samuraiblog.com/wordpress/2008/02/18/a-cinematic-gaming-experience/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
