<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Alson Kemp</title>
	<atom:link href="http://www.alsonkemp.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alsonkemp.com</link>
	<description>Hackfoofery</description>
	<lastBuildDate>Tue, 14 May 2013 03:34:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Go experiment: de-noising</title>
		<link>http://www.alsonkemp.com/programming/go-experiment-de-noising/</link>
		<comments>http://www.alsonkemp.com/programming/go-experiment-de-noising/#comments</comments>
		<pubDate>Tue, 14 May 2013 03:34:46 +0000</pubDate>
		<dc:creator>alson</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.alsonkemp.com/?p=467</guid>
		<description><![CDATA[CoffeeScript is a great example of how to de-noise a language like Javascript. (Of course, I know people that consider braces to be a good thing, but lots of us consider them noise and prefer significant whitespace, so I&#8217;m speaking to those folks.) What would Go code look like with some of CoffeeScript&#8217;s denoising? TL;DR [...]]]></description>
				<content:encoded><![CDATA[<p>CoffeeScript is a great example of how to de-noise a language like Javascript. (Of course, I know people that consider braces to be a good thing, but lots of us consider them noise and prefer significant whitespace, so I&#8217;m speaking to those folks.) What would Go code look like with some of CoffeeScript&#8217;s denoising?</p>

<p>TL;DR : the answer is that de-noised Go would not look much different than normal Go&#8230;</p>

<p>As an experiment, I picked some rules from CoffeeScript and re-wrote the <a href="http://benchmarksgame.alioth.debian.org/u32q/program.php?test=mandelbrot&amp;lang=go&amp;id=6">Mandelbrot</a> example from The Computer Benchmarks Game.  Note: this is someone else&#8217;s original Go code, so I can&#8217;t vouch for the quality of the Go code&#8230;.</p>

<p>Here&#8217;s the original Go code:</p>

<p><pre><pre>/* targeting a q6600 system, one cpu worker per core */
const pool = 4

const ZERO float64 = 0
const LIMIT = 2.0
const ITER = 50&nbsp;&nbsp; // Benchmark parameter
const SIZE = 16000

var rows []byte
var bytesPerRow int

// This func is responsible for rendering a row of pixels,
// and when complete writing it out to the file.

func renderRow(w, h, bytes int, workChan chan int,iter int, finishChan chan bool) {

&nbsp;&nbsp; var Zr, Zi, Tr, Ti, Cr float64
&nbsp;&nbsp; var x,i int

&nbsp;&nbsp; for y := range workChan {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;offset := bytesPerRow * y
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ci := (2*float64(y)/float64(h) - 1.0)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for x = 0; x &lt; w; x++ {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Zr, Zi, Tr, Ti = ZERO, ZERO, ZERO, ZERO
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Cr = (2*float64(x)/float64(w) - 1.5)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for i = 0; i &lt; iter &amp;&amp; Tr+Ti &lt;= LIMIT*LIMIT; i++ {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Zi = 2*Zr*Zi + Ci
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Zr = Tr - Ti + Cr
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Tr = Zr * Zr
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ti = Zi * Zi
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Store the value in the array of ints
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if Tr+Ti &lt;= LIMIT*LIMIT {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rows[offset+x/8] |= (byte(1) &lt;&lt; uint(7-(x%8)))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp; }
&nbsp;&nbsp; /* tell master I&#039;m finished */
&nbsp;&nbsp; finishChan &lt;- true
</pre></pre></p>

<p>My <em>quick</em> de-noising rules are:</p>

<ul>
    <li><span style="line-height: 13px;">Eliminate <i>var</i> since it can be inferred.</span></li>
    <li>Use &#8216;:&#8217; instead of <em>const</em> (a la Ruby&#8217;s symbols).</li>
    <li>Eliminate <em>func</em> in favor of &#8216;-&gt; and variables for functions.</li>
    <li>Replace braces {} with significant whitespace</li>
    <li>Replace C-style comments with shell comments &#8220;#&#8221;</li>
   <li>Try to leave other spacing along to not fudge on line count</li>
   <li>Replace simple loops with an &#8220;in&#8221; and range form</li>
</ul>

<p>The de-noised Go code:</p>

<p><pre><pre>
# targeting a q6600 system, one cpu worker per core
:pool = 4

:ZERO float64 = 0&nbsp;&nbsp;# These are constants
:LIMIT = 2.0
:ITER = 50&nbsp;&nbsp; # Benchmark parameter
:SIZE = 16000

rows []byte
bytesPerRow int

# This func is responsible for rendering a row of pixels,
# and when complete writing it out to the file.

renderRow = (w, h, bytes int, workChan chan int,iter int, finishChan chan bool) -&gt;

&nbsp;&nbsp; Zr, Zi, Tr, Ti, Cr float64
&nbsp;&nbsp; x,i int

&nbsp;&nbsp; for y := range workChan
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;offset := bytesPerRow * y
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ci := (2*float64(y)/float64(h) - 1.0)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for x in [0..w]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Zr, Zi, Tr, Ti = ZERO, ZERO, ZERO, ZERO
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Cr = (2*float64(x)/float64(w) - 1.5)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = 0
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while i++ &lt; iter &amp;&amp; Tr+Ti &lt;= LIMIT*LIMIT
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Zi = 2*Zr*Zi + Ci
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Zr = Tr - Ti + Cr
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Tr = Zr * Zr
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ti = Zi * Zi

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Store the value in the array of ints
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if Tr+Ti &lt;= LIMIT*LIMIT
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rows[offset+x/8] |= (byte(1) &lt;&lt; uint(7-(x%8)))
&nbsp;&nbsp; # tell master I&#039;m finished
&nbsp;&nbsp; finishChan &lt;- true
</pre></pre></p>

<p>That seems to be a pretty small win in return for a syntax adjustment that does not produce significantly enhanced readability.  Some bits are nice: I prefer the significant whitespace, but the braces just aren&#8217;t that obtrusive in Go; I do prefer the shell comment style, but it&#8217;s not a deal breaker; the simplified loop is nice, but not incredible; eliding &#8220;var&#8221; is okay, but harms readability given the need to declare the types of some variables; I do prefer the colon for constants.  Whereas Coffeescript can dramatically shorten and de-noise a Javascript file, it looks as though Go is already pretty terse.</p>

<p>Obviously, I didn&#8217;t deal with all of Go in this experiment, so I&#8217;ll look over more of it soon, but Go appears to be quite terse already given its design&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alsonkemp.com/programming/go-experiment-de-noising/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[Synthetic] Performance of the Go frontend for GCC</title>
		<link>http://www.alsonkemp.com/programming/synthetic-performance-of-the-go-frontend-for-gcc/</link>
		<comments>http://www.alsonkemp.com/programming/synthetic-performance-of-the-go-frontend-for-gcc/#comments</comments>
		<pubDate>Sun, 05 May 2013 18:35:57 +0000</pubDate>
		<dc:creator>alson</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.alsonkemp.com/?p=468</guid>
		<description><![CDATA[First, a note: this is a tiny synthetic bench.  It&#8217;s not intended to answer the question: is GCCGo a good compiler.  It is intended to answer the question: as someone investigating Go, should I also investigate GCCGo? While reading some announcements about the impending release of Go 1.1, I noticed that GCC was implementing a Go [...]]]></description>
				<content:encoded><![CDATA[<p>First, a note: this is a tiny synthetic bench.  It&#8217;s not intended to answer the question: is GCCGo a good compiler.  It is intended to answer the question: as someone investigating Go, should I also investigate GCCGo?</p>

<p>While reading some announcements about the impending <a href="http://tip.golang.org/doc/go1.1#gccgo" target="_blank">release of Go 1.1</a>, I noticed that GCC was implementing a Go frontend.  Interesting.  So the benefits of the Go language coupled with the GCC toolchain?  Sounds good.  The benefits of the Go language combing with GCC&#8217;s decades of x86 optimization?  Sounds great.</p>

<p>So I grabbed GCCGo and built it.  Instructions here: <a href="http://golang.org/doc/install/gccgo">http://golang.org/doc/install/gccgo</a></p>

<p>Important bits:</p>

<ul>
    <li><span style="line-height: 13px;">Definitely follow the instructions to build GCC in a separate directory from the source.</span></li>
    <li>My configuration was:</li>
</ul>

<p><pre>/tmp/gccgo/configure --disable-multilib --enable-languages=c,c++,go</pre></p>

<p>I used the Mandelbrot script from <a href="http://benchmarksgame.alioth.debian.org" target="_blank">The Benchmarks Game</a> at <a href="http://benchmarksgame.alioth.debian.org/u32q/program.php?test=mandelbrot&amp;lang=go&amp;id=6" target="_blank">mandlebrot.go</a>.  Compiled using go and gccgo, respectively:</p>

<p><pre><pre>go build mandel.go
gccgo -v -lpthread -B /tmp/gccgo-build/gcc/ -B /tmp/gccgo-build/lto-plugin/ \
&nbsp;&nbsp;-B /tmp/gccgo-build/x86_64-unknown-linux-gnu/libgo/ \
&nbsp;&nbsp;-I /tmp/gccgo-build/x86_64-unknown-linux-gnu/libgo/ \
&nbsp;&nbsp;-m64 -fgo-relative-import-path=_/home/me/apps/go/bin \
&nbsp;&nbsp;-o ./mandel.gccgo ./mandel.go -O3</pre></pre></p>

<p>Since I didn&#8217;t install GCCGo and after flailing at compiler options for getting &#8220;go build&#8221; to find includes, libraries, etc, I gave up on the simple &#8220;go -compiler&#8221; syntax for gccgo.  So the above gccgo command is the sausage-making version.</p>

<p>So the two files:</p>

<p><pre><pre>4,532,110 mandel.gccgo&nbsp;&nbsp;- Compiled in 0.3s
1,877,120 mandel.golang - Compiled in 0.5s</pre></pre></p>

<p>As a HackerNewser <a href="https://news.ycombinator.com/item?id=5659952" target="_blank">noted</a>, stripping the executables could be good. Stripped:</p>

<p><pre><pre>1,605,472 mandel.gccgo
1,308,840 mandel.golang</pre></pre></p>

<p>Note: the stripped GCCGo executables don&#8217;t actually work, so take the &#8220;stripped&#8221; value with a grain of salt for the moment. Bug <a href="https://bugs.archlinux.org/task/35048" target="_blank">here</a>.</p>

<p>GCCGo produced an *unstripped* executable 2.5x as large as Go produced. Stripped, the executables were similar, but the GCCGo executable didn&#8217;t work.  So far the Go compiler is winning.</p>

<p>Performance [on a tiny, synthetic, CPU bound, floating point math dominated program]:</p>

<p><pre><pre>time ./mandel.golang 16000 &gt; /dev/null 

real&nbsp;&nbsp;0m10.610s
user&nbsp;&nbsp;0m41.091s
sys&nbsp;&nbsp;0m0.068s

time ./mandel.gccgo 16000 &gt; /dev/null 

real&nbsp;&nbsp;0m9.719s
user&nbsp;&nbsp;0m37.758s
sys&nbsp;&nbsp;0m0.064s</pre></pre></p>

<p>So GCCGo produces executables that are about 10% faster than does Go, but the executable is nearly 3x the size.  I think I&#8217;ll stick with the Go compiler for now, especially since the tooling built into/around Go is very solid.</p>

<p>Additional notes from <a href="https://news.ycombinator.com/item?id=5659246" target="_blank">HN discussion</a>:</p>

<ul>
    <li><span style="line-height: 13px;">GCC was 4.8.0.  Go was 1.1rc1.  Both AMD64.</span></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.alsonkemp.com/programming/synthetic-performance-of-the-go-frontend-for-gcc/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Parsing a DICOM file for fun and profit</title>
		<link>http://www.alsonkemp.com/turbinado/parsing-a-dicom-file-for-fun-and-profit/</link>
		<comments>http://www.alsonkemp.com/turbinado/parsing-a-dicom-file-for-fun-and-profit/#comments</comments>
		<pubDate>Sat, 19 Jan 2013 03:34:43 +0000</pubDate>
		<dc:creator>alson</dc:creator>
				<category><![CDATA[Turbinado]]></category>

		<guid isPermaLink="false">http://www.alsonkemp.com/?p=458</guid>
		<description><![CDATA[For various reasons, I needed to have a CT scan of my jaw done.  This is a very high resolution 3D scan.  The technician needed to review the scan to make sure it was of high quality and I stood behind him and looked over his shoulder.  The software was pretty impressive, but the 3D [...]]]></description>
				<content:encoded><![CDATA[<p>For various reasons, I needed to have a CT scan of my jaw done.  This is a very high resolution 3D scan.  The technician needed to review the scan to make sure it was of high quality and I stood behind him and looked over his shoulder.  The software was pretty impressive, but the 3D model and resolution were really impressive.  And then I left the office and drove home&#8230;</p>

<p>&#8230; and as I was driving, I thought: wouldn&#8217;t it be fun to have a copy of the data?; perhaps I could build a point cloud and shoot it into a crystal (as I&#8217;d done with fractals)?  So I called back the lab (<a href="http://www.parkxraylab.com/">Park XRay</a>) and asked if I could have a copy of the data.  &#8221;Sure!  It&#8217;s your skull.&#8221; was the reply and they delivered an extra copy to my dentist.</p>

<p>The files were in DICOM format and were produced or for-use by iCATVision.  Fortunately, Python has a <a href="https://code.google.com/p/pydicom/">DICOM</a> library, so it was fairly easy to parse the files.  My code is on <a href="https://github.com/alsonkemp/jaw-dicom">GitHub</a>.  [The code is not pretty, but it worked.]</p>

<p>I&#8217;ve previously &#8220;printed&#8221; point clouds into crystals using <a href="http://www.precisionlaserart.com/">Precision Laser Art</a>, so I needed to convert the 448 16-bit slices of my jaw into 1-bit XYZ point clouds.  &#8221;visualize.py&#8221; provides a simple 2D visualization of the slices.  Most importantly, it let me tune the threshold values for the quantizer so that the point cloud would highlight interesting structures in my jaw.  Here&#8217;s the interface (perhaps it&#8217;s obvious, but I&#8217;m not a UX expert&#8230;):</p>

<p><a href="http://d1r5286bar8cf9.cloudfront.net/wp-content/uploads/2013/01/jaw.png"><img class="alignnone size-full wp-image-459" title="Visualizing my jaw..." src="http://d1r5286bar8cf9.cloudfront.net/wp-content/uploads/2013/01/jaw.png" alt="" width="805" height="870" /></a></p>

<p>Once I&#8217;d tuned the parameters, I added those parameters to &#8220;process.py&#8221; and generated the giant XYZ point cloud.  The format of the point cloud is just:</p>

<p><pre style="padding-left: 30px;">X1 Y1 Z1</pre>
<pre style="padding-left: 30px;">X2 Y2 Z2</pre>
<pre style="padding-left: 30px;">X3 Y3 Z3</pre>
<pre style="padding-left: 30px;">[repeat about 3 million times...]</pre></p>

<p>I sent my order to <a href="http://www.precisionlaserart.com">Precision Laser Art</a> and, after 7 days and $100, received this:</p>

<p><a href="http://d1r5286bar8cf9.cloudfront.net/wp-content/uploads/2013/01/box.png"><img class="alignnone size-full wp-image-460" title="box" src="http://d1r5286bar8cf9.cloudfront.net/wp-content/uploads/2013/01/box.png" alt="" width="472" height="426" /></a></p>

<p>Which had a nicely cushioned interior:</p>

<p><a href="http://d1r5286bar8cf9.cloudfront.net/wp-content/uploads/2013/01/debox.png"><img class="alignnone size-full wp-image-461" title="debox" src="http://d1r5286bar8cf9.cloudfront.net/wp-content/uploads/2013/01/debox.png" alt="" width="442" height="582" /></a></p>

<p>And this is the resulting crystal.  It&#8217;s the C-888 80mm cube.</p>

<p><a href="http://d1r5286bar8cf9.cloudfront.net/wp-content/uploads/2013/01/crystal1.png"><img class="alignnone size-full wp-image-464" title="crystal" src="http://d1r5286bar8cf9.cloudfront.net/wp-content/uploads/2013/01/crystal1.png" alt="" width="427" height="380" /></a></p>

<p>While it&#8217;s not amazingly easy to see in this photo, my vertebrae and hyoid bone are clearly visible in the crystal.</p>

<p>Anyhow, the point is: medical data is cool.  You <strong>can</strong> get it, so <strong>get it</strong> and <strong>play with it</strong>!  ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alsonkemp.com/turbinado/parsing-a-dicom-file-for-fun-and-profit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Checking memcached stats and preventing empty responses</title>
		<link>http://www.alsonkemp.com/tools/checking-memcached-stats-and-preventing-empty-responses/</link>
		<comments>http://www.alsonkemp.com/tools/checking-memcached-stats-and-preventing-empty-responses/#comments</comments>
		<pubDate>Wed, 10 Oct 2012 16:32:30 +0000</pubDate>
		<dc:creator>alson</dc:creator>
				<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.alsonkemp.com/?p=449</guid>
		<description><![CDATA[A quick google for how to check stats for memcached quickly turns up the following command: echo stats &#124; nc internal.ip 11211 Netcat is a utility for poking about in just about all network interfaces or protocols, so can be used to pipe  information to memcached.  Note: you&#8217;ll need to have netcat installed in order [...]]]></description>
				<content:encoded><![CDATA[<p>A quick google for how to check stats for memcached quickly turns up the following command:</p>

<p><pre>echo stats | nc internal.ip 11211</pre></p>

<p>Netcat is a utility for poking about in just about all network interfaces or protocols, so can be used to pipe  information to memcached.  Note: you&#8217;ll need to have netcat installed in order to have the &#8220;nc&#8221; command and Debian/Ubuntu have both netcat-traditional and netcat-openbsd. Install the openbsd version.</p>

<p>The problem I had was that checking stats returned a blank response about 90% of the time.  The cause of this issue is that netcat sends the string &#8220;stats&#8221; to memcached, declares victory and then closes the connection before memcached has a chance to reply.  Solution? Just tell netcat to wait a bit using the &#8220;-i&#8221; flag which waits after sending lines of text. Like this:</p>

<p><pre>echo stats | nc -i 1 internal.ip 11211</pre></p>

<p>To check a remote machine, I wound up with:</p>

<p><pre> ssh the_remote_machine &quot;echo stats | nc -i 1 internal.ip 11211&quot;</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.alsonkemp.com/tools/checking-memcached-stats-and-preventing-empty-responses/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django: handling configs for multiple environments</title>
		<link>http://www.alsonkemp.com/turbinado/django-handling-configs-for-multiple-environments/</link>
		<comments>http://www.alsonkemp.com/turbinado/django-handling-configs-for-multiple-environments/#comments</comments>
		<pubDate>Sun, 07 Oct 2012 18:42:07 +0000</pubDate>
		<dc:creator>alson</dc:creator>
				<category><![CDATA[Turbinado]]></category>

		<guid isPermaLink="false">http://www.alsonkemp.com/?p=445</guid>
		<description><![CDATA[A common way to manage settings across environments in Django is to create a local_settings.py file and then copy into it environment specific settings during deployment.  Although much of our web work is done in Django now, the Rails way of managing environments is superior. In your project, create a settings_env directory and put into [...]]]></description>
				<content:encoded><![CDATA[<p>A common way to manage settings across environments in Django is to create a local_settings.py file and then copy into it environment specific settings during deployment.  Although much of our web work is done in Django now, the Rails way of managing environments is superior.</p>

<p>In your project, create a settings_env directory and put into it local.py, dev.py, etc files for environment specific setup.</p>

<p><pre><pre>## ^^ standard settings.py above
# Import environment specific settings
# Pull in the settings for specific environments
# It&#039;s the last argument.
env = os.environ.get(&#039;DJANGO_ENV&#039;)

if env == &quot;production&quot; : from settings_env.dw&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import *
elif env == &quot;staging&quot;&nbsp;&nbsp;: from settings_env.staging import *
elif env == &quot;dev&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: from settings_env.dev&nbsp;&nbsp;&nbsp;&nbsp; import *
elif env == &quot;local&quot;&nbsp;&nbsp;&nbsp;&nbsp;: from settings_env.local&nbsp;&nbsp; import *
else: 
&nbsp;&nbsp;&nbsp;&nbsp;print &quot;######################################################&quot;
&nbsp;&nbsp;&nbsp;&nbsp;print &quot; No environment specified or specified environment&quot;
&nbsp;&nbsp;&nbsp;&nbsp;print &quot; does not exist in /settings_env/.&quot;
&nbsp;&nbsp;&nbsp;&nbsp;print &quot; Continuing with no settings overrides.&quot;
&nbsp;&nbsp;&nbsp;&nbsp;print &quot; To specify an environment (e.g. production), use&quot;
&nbsp;&nbsp;&nbsp;&nbsp;print &quot;&nbsp;&nbsp;DJANGO_ENV=production ./manage.py runserver&quot;
&nbsp;&nbsp;&nbsp;&nbsp;print &quot;######################################################&quot;
&nbsp;&nbsp;&nbsp;&nbsp;quit()
if DEBUG=True:
&nbsp;&nbsp;## ^^ settings.py for DEBUG = True below</pre></pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.alsonkemp.com/turbinado/django-handling-configs-for-multiple-environments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tunnel MySQL over SSH to remote server issue</title>
		<link>http://www.alsonkemp.com/turbinado/tunnel-mysql-over-ssh-to-remote-server-issue/</link>
		<comments>http://www.alsonkemp.com/turbinado/tunnel-mysql-over-ssh-to-remote-server-issue/#comments</comments>
		<pubDate>Fri, 07 Sep 2012 18:29:50 +0000</pubDate>
		<dc:creator>alson</dc:creator>
				<category><![CDATA[Turbinado]]></category>

		<guid isPermaLink="false">http://www.alsonkemp.com/?p=441</guid>
		<description><![CDATA[There are a million pages about this, but I just bumped into a tricky issue and figured I&#8217;d drop a quick note about it. First off, tunnel MySQL to the server (on a UNIXy box) by doing: ssh  -L 33306:localhost:3306 your-server.com Simply, that tells SSH to listen on local port 33306, a port chosen because [...]]]></description>
				<content:encoded><![CDATA[<p>There are a million pages about this, but I just bumped into a tricky issue and figured I&#8217;d drop a quick note about it.</p>

<p>First off, tunnel MySQL to the server (on a UNIXy box) by doing:</p>

<p><pre>ssh  -L 33306:localhost:3306 your-server.com</pre></p>

<p>Simply, that tells SSH to listen on local port 33306, a port chosen because it&#8217;s an obvious variation on MySQL&#8217;s default of 3306).  When something connects to that port, SSH will accept the connection and will forward it to the remote host, which will then connect it to the appropriate host and port on the far side.  In this case, we&#8217;re asking the server to connect to port 3306 on localhost, but you could connect to any server and any port.</p>

<p>The tricky issue was that on my Debian laptop, MySQL uses socket file for communcation <strong>even if you specify a port</strong>.  So this will fail and have you talking with your local MySQL instance:</p>

<p><pre>mysql --port=33306  -u your_remote_user -pyour_remote_password</pre></p>

<p>In order to force MySQL to use TCP (instead of sockets), you can force the connection protocol or specify a host (note: you can&#8217;t use &#8216;localhost&#8217;; you need to use 127.0.01):</p>

<p><pre><pre>mysql --protocol=tcp --port=33306 \
   -u your_remote_user -pyour_remote_password
mysql -h 127.0.0.1 --port=33306  \
   -u your_remote_user -pyour_remote_password</pre></pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.alsonkemp.com/turbinado/tunnel-mysql-over-ssh-to-remote-server-issue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Apache process is only using one core!</title>
		<link>http://www.alsonkemp.com/geekery/my-apache-process-is-only-using-one-core/</link>
		<comments>http://www.alsonkemp.com/geekery/my-apache-process-is-only-using-one-core/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 03:41:14 +0000</pubDate>
		<dc:creator>alson</dc:creator>
				<category><![CDATA[Geekery]]></category>

		<guid isPermaLink="false">http://www.alsonkemp.com/?p=423</guid>
		<description><![CDATA[I was recently working on a client site (a good-sized one) and was checking on the health of their application servers.  I noticed that each of their app servers was running a few of the cores much harder than the other cores.  This was in the evening and they get most of their traffic during [...]]]></description>
				<content:encoded><![CDATA[<p>I was recently working on a client site (a good-sized one) and was checking on the health of their application servers.  I noticed that each of their app servers was running a few of the cores much harder than the other cores.  This was in the evening and they get most of their traffic during the day; it runs Django under mod_wsgi in daemon mode with 8 processes and 25 threads per process.  Further, the boxes were not VPSs/VMs, but were dedicated, multicore boxes.  So they had multicore hardware and the web server was running in a multicore friendly way.</p>

<p>At the time, the load for each box was around 0.5.  And various process IDs rotated as the top CPU users, so process IDs weren&#8217;t bound to a core.  The ratio of traffic between the cores (ignoring actual core number and focusing on the utilization of each core, since each box was different) was something like:</p>

<blockquote>
<pre>Core # : Core Utilization</pre>
<pre>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: 15%</pre>
<pre>2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: 2%</pre>
<pre>3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: 1%</pre>
<pre>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: 0%</pre>
</blockquote>

<p>So why would one processor bear most of the load?  I googled and googled, and found little useful information.   I banged on one server with Apache&#8217;s benching tool (&#8220;ab&#8221;) while watching core utilization and, sure enough, all cores shared the load equally.  So what was going on?</p>

<p>I&#8217;m not sure if it&#8217;s the Linux kernel or a natural outcome of CPU caches, but the simplest explanation is that <strong>in low load situations</strong> processes are similar, due to <a href="http://en.wikipedia.org/wiki/Cache_coherence" target="_blank">cache coherence</a>, will flock to the same core.  Rather than spreading a set of processes across a set of cores that don&#8217;t necessarily share the same cache, processes naturally gravitate to the cores that experience the lowest cache misses.</p>

<p>Upshot: it&#8217;s rational for the system to schedule most operations of a process or group of similar processes on one core when a system is relatively lightly loaded.  This is especially true if the cores are &#8220;Hyperthreading&#8221; and are sharing resources (read: their caches)!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alsonkemp.com/geekery/my-apache-process-is-only-using-one-core/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ExtJS 4 Models + node.js</title>
		<link>http://www.alsonkemp.com/geekery/extjs-4-models-node-js/</link>
		<comments>http://www.alsonkemp.com/geekery/extjs-4-models-node-js/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 18:50:36 +0000</pubDate>
		<dc:creator>alson</dc:creator>
				<category><![CDATA[Geekery]]></category>

		<guid isPermaLink="false">http://www.alsonkemp.com/?p=409</guid>
		<description><![CDATA[Finally starting to play with node.js.   Also, getting back into developing with the lovely ExtJS.  ExtJS 4 added strong support for client side models. I was thinking that it&#8217;d be nice to share a lot of code for models between the client and server.   Turns out that it&#8217;s not that difficult.   Super [...]]]></description>
				<content:encoded><![CDATA[<p>Finally starting to play with <a href="http://nodejs.org" target="_blank">node.js</a>.   Also, getting back into developing with the lovely <a href="http://www.sencha.com/products/extjs/" target="_blank">ExtJS</a>.  ExtJS 4 added strong support for <a href="http://www.sencha.com/blog/ext-js-4-anatomy-of-a-model/">client side models</a>.</p>

<p>I was thinking that it&#8217;d be nice to share a lot of code for models between the client and server.   Turns out that it&#8217;s not that difficult.   Super quick-n-dirty code below.  Now the question is: how much duplication can be removed from client and server models?  I don&#8217;t want to include all server-side code in client-side code, so might do something like:</p>

<ul>
    <li>/common/models/user.js &#8211; ExtJS model;</li>
    <li>/client/models/user.js &#8211; tune the model for client side (e.g. add a REST connection to the server);</li>
    <li>/server/models/user.js &#8211; includes client/models/user.js;  overrides critical bits (e.g. the Proxy); adds a bunch of server specific code.</li>
</ul>

<p>If all of my models are in model.*, then I can probably iterate through them and auto-generate Mongoose models when the server boots&#8230;  Fun.</p>

<p>This is definitely a hack, but isn&#8217;t as frighteningly ugly as I expected:</p>


<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">fs <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fs'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// stub out a fake browser for ext-core-debug.js</span>
navigator <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
window <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
  navigator <span style="color: #339933;">:</span> <span style="color: #3366CC;">'Linux'</span><span style="color: #339933;">,</span>
  attachEvent<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
navigator <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'userAgent'</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'node'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
document <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
  documentElement<span style="color: #339933;">:</span><span style="color: #3366CC;">''</span><span style="color: #339933;">,</span>
  getElementsByTagName <span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>



<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Helper function </span>
<span style="color: #000066; font-weight: bold;">function</span> injectJS<span style="color: #009900;">&#40;</span>f<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  eval<span style="color: #009900;">&#40;</span>fs.<span style="color: #660066;">readFileSync</span><span style="color: #009900;">&#40;</span>f<span style="color: #339933;">,</span> encoding<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;ascii&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//Pull in ExtJS components</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./ext-core-debug.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/util/Filter.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/util/Sorter.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/util/Observable.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/Connection.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/Ajax.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/util/Stateful.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/util/Inflector.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/util/MixedCollection.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/ResultSet.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/Batch.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/Reader.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/JsonReader.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/Writer.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/JsonWriter.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/Errors.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/Operation.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/Proxy.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/ServerProxy.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/AjaxProxy.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/RestProxy.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/validations.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/util/Date.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/SortTypes.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/Association.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/Types.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/util/Observable.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/util/HashMap.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/AbstractManager.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/PluginMgr.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/Field.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/BelongsToAssociation.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/HasManyAssociation.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/PolymorphicAssociation.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/data/Model.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
injectJS<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./src/ModelMgr.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Register the model</span>
Ext.<span style="color: #660066;">regModel</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'models.User'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
      fields<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
          <span style="color: #009900;">&#123;</span>name<span style="color: #339933;">:</span> <span style="color: #3366CC;">'name'</span><span style="color: #339933;">,</span>  type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'string'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
          <span style="color: #009900;">&#123;</span>name<span style="color: #339933;">:</span> <span style="color: #3366CC;">'age'</span><span style="color: #339933;">,</span>   type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'int'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
          <span style="color: #009900;">&#123;</span>name<span style="color: #339933;">:</span> <span style="color: #3366CC;">'phone'</span><span style="color: #339933;">,</span> type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'string'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
          <span style="color: #009900;">&#123;</span>name<span style="color: #339933;">:</span> <span style="color: #3366CC;">'alive'</span><span style="color: #339933;">,</span> type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'boolean'</span><span style="color: #339933;">,</span> defaultValue<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    validations<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
        <span style="color: #009900;">&#123;</span>type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'presence'</span><span style="color: #339933;">,</span>  field<span style="color: #339933;">:</span> <span style="color: #3366CC;">'age'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#123;</span>type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'length'</span><span style="color: #339933;">,</span>    field<span style="color: #339933;">:</span> <span style="color: #3366CC;">'name'</span><span style="color: #339933;">,</span>     min<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    changeName<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">var</span> oldName <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #000066; font-weight: bold;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        newName <span style="color: #339933;">=</span> oldName <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; The Barbarian&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #000066; font-weight: bold;">set</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'name'</span><span style="color: #339933;">,</span> newName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Create an instance</span>
<span style="color: #000066; font-weight: bold;">var</span> user <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">ModelMgr</span>.<span style="color: #660066;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
      name <span style="color: #339933;">:</span> <span style="color: #3366CC;">'Conan'</span><span style="color: #339933;">,</span>
        age  <span style="color: #339933;">:</span> <span style="color: #CC0000;">24</span><span style="color: #339933;">,</span>
        phone<span style="color: #339933;">:</span> <span style="color: #3366CC;">'555-555-5555'</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'models.User'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Use the instance</span>
user.<span style="color: #660066;">changeName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
user.<span style="color: #000066; font-weight: bold;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//returns &quot;Conan The Barbarian&quot;</span>
user.<span style="color: #660066;">validate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
user.<span style="color: #660066;">addEvents</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'changed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
user.<span style="color: #660066;">events</span><span style="color: #339933;">;</span>
user.<span style="color: #660066;">fireEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'changed'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'my hair'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
repl <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;repl&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
repl.<span style="color: #660066;">start</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ExtJS&amp;gt; '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.alsonkemp.com/geekery/extjs-4-models-node-js/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>KickLabs (SF Incubator)</title>
		<link>http://www.alsonkemp.com/geekery/kicklabs-sf-incubator/</link>
		<comments>http://www.alsonkemp.com/geekery/kicklabs-sf-incubator/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 18:18:32 +0000</pubDate>
		<dc:creator>alson</dc:creator>
				<category><![CDATA[Geekery]]></category>

		<guid isPermaLink="false">http://www.alsonkemp.com/?p=397</guid>
		<description><![CDATA[Great incubator just opened in downtown San Francisco: KickLabs.  Ridiculously great space, a great team and a list of exciting events.  Definitely a place to get to know. And they welcome entrepreneurs of all ages!]]></description>
				<content:encoded><![CDATA[<p>Great incubator just opened in downtown San Francisco: <a href="http://www.kicklabs.com" target="_blank">KickLabs</a>.  Ridiculously great space, a great team and a list of exciting events.  Definitely a place to get to know.</p>

<p>And they welcome entrepreneurs of all ages!</p>

<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/4GaiuTQJF6s&amp;hl=en_US&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="640" height="385" src="http://www.youtube.com/v/4GaiuTQJF6s&amp;hl=en_US&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.alsonkemp.com/geekery/kicklabs-sf-incubator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting high on your own stash&#8230;</title>
		<link>http://www.alsonkemp.com/turbinado/getting-high-on-your-own-stash/</link>
		<comments>http://www.alsonkemp.com/turbinado/getting-high-on-your-own-stash/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 21:24:48 +0000</pubDate>
		<dc:creator>alson</dc:creator>
				<category><![CDATA[Turbinado]]></category>

		<guid isPermaLink="false">http://www.alsonkemp.com/turbinado/getting-high-on-your-own-stash/</guid>
		<description><![CDATA[Lots of talk around right now about how distracted we are by technology. Too much reporting-speak about it, though. Here&#8217;s a different, more personal take: http://tweetagewasteland.com/2010/06/say-hello-to-my-little-friend/ Great quote: When the WiFi went down during the official iPhone 4 demo, didn’t you sort of wish Steve Jobs would turn to the crowd and say, “You know [...]]]></description>
				<content:encoded><![CDATA[<p>Lots of talk around right now about how distracted we are by technology.  Too much reporting-speak about it, though.  Here&#8217;s a different, more personal take:
<a href="http://tweetagewasteland.com/2010/06/say-hello-to-my-little-friend/">http://tweetagewasteland.com/2010/06/say-hello-to-my-little-friend/</a></p>

<p>Great quote:</p>

<blockquote>When the WiFi went down during the official iPhone 4 demo, didn’t you sort of wish Steve Jobs would turn to the crowd and say, “You know what, let’s just talk.”</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.alsonkemp.com/turbinado/getting-high-on-your-own-stash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Object Caching 700/808 objects using disk: basic
Content Delivery Network via Amazon Web Services: CloudFront: d1r5286bar8cf9.cloudfront.net

 Served from: www.alsonkemp.com @ 2013-05-22 17:08:14 by W3 Total Cache -->