<?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>SQUARISM &#187; Blog</title>
	<atom:link href="http://squarism.com/category/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://squarism.com</link>
	<description>addicted to pixels</description>
	<lastBuildDate>Tue, 20 Jul 2010 15:12:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Fit-PC2 and Ubuntu 10.04</title>
		<link>http://squarism.com/2010/07/10/fit-pc2-and-ubuntu-10-04/</link>
		<comments>http://squarism.com/2010/07/10/fit-pc2-and-ubuntu-10-04/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 14:51:02 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://squarism.com/?p=619</guid>
		<description><![CDATA[I had Ubuntu 9.04 running on my Fit-PC2 and I wanted to move up to 10.04. I ran: sudo apt-get update; sudo apt-get dist-upgrade and it chugged along doing the update. Install went fine and I was impressed that you can jump major revs like that. Although there was one bit of weirdness: when I [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://squarism.com/wp-content/uploads/2010/07/fitpc2.jpg" alt="" title="fitpc2" width="620" height="382" class="aligncenter size-full wp-image-620" /></p>
<p>I had Ubuntu 9.04 running on my Fit-PC2 and I wanted to move up to 10.04.  I ran: <code>sudo apt-get update; sudo apt-get dist-upgrade</code> and it chugged along doing the update.  Install went fine and I was impressed that you can jump major revs like that.</p>
<p>Although there was one bit of weirdness: when I did the dist-upgrade I noticed that it was going to upgrade openoffice.  I didn't want openoffice at all on there so I was going to remove it before it upgraded.  So I hit Ctrl-C which promptly locked the whole box.  I thought it was heat related and so I got an ice pack and wrapped the Fit in ice.  I tried it again, Ctrl-C locks the box.  Like, the whole box.  Caps lock dead.  Anyway, I've never seen that before.  When I let the dist-upgrade go, it worked fine.</p>
<p>When it booted 10.04, my display was set to 1280x1024 and was running slow.  It was running the vesa driver.  So I downloaded the paulsbo driver for the GMA500 (the 'gpu' that the Fit-PC2 uses) and although the module built fine, it really screwed up everything.  The screen would blank, X would be trying to start, there'd be video garbage doing all kinds of weird things.</p>
<p>So I wiped the whole thing and installed 9.10 and followed the 9.10 installation instructions on the Fit wiki.  I installed the netbook-remix distro (i386) and the install instructions still work.  Now I just need to get rid of the netbook-remix gui.  Too bad they don't have desktop-switcher anymore.</p>
<p>Also, I was playing around with <a href="http://xmonad.org/">Xmonad</a> which is interesting if not a bit understated.  It reminds me of when I used Enlightenment back in 1999.  The styles are different but the amount of config editing is the same.</p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2010/07/10/fit-pc2-and-ubuntu-10-04/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reversing sentences with Ruby.</title>
		<link>http://squarism.com/2010/05/01/reversing-sentences-with-ruby/</link>
		<comments>http://squarism.com/2010/05/01/reversing-sentences-with-ruby/#comments</comments>
		<pubDate>Sat, 01 May 2010 19:01:28 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://squarism.com/?p=433</guid>
		<description><![CDATA[A question came up today about how to reverse a sentence. Word by word, preserving periods etc. I've done stuff like this before but I really saw an opportunity to solve this contrived quiz type question with TDD. It's perfect really. Tedious string checking? Screw it. Let my test tell me when I'm done. Ok [...]]]></description>
			<content:encoded><![CDATA[<p>A question came up today about how to reverse a sentence.  Word by word, preserving periods etc.  I've done stuff like this before but I really saw an opportunity to solve this <em>contrived</em> quiz type question with <a href="http://en.wikipedia.org/wiki/Test-driven_development">TDD</a>.  It's perfect really.  Tedious string checking?  Screw it.  Let my test tell me when I'm done.</p>
<p>Ok so I could have probably done this more comfortably in Java but it would have been more lines.  I banged this out in Ruby, including "learning" test cases (it's really easy) in about an hour.  At one point I realized how easy string manipulation is in Ruby for this and I literally said, "holy shit Ruby is amazing".  And then the edge cases started happening.  I was only handling periods and my algorithm fell over flat on three sentences because I was trying to do a string[start, end] when it's really string[start, length].  I fixed it with learning the String#slice syntax.</p>
<p>Ok enough fanboi service.  There's two files.  One's the test and one's the class.  Run the test and not the class (ie: ruby tc_reverser.rb).</p>
<p>tc_reverser.rb:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'test/unit'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'reverser'</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Be wary of newlines in the test and expected trings.</span>
  <span style="color:#008000; font-style:italic;"># Do not try to word wrap with escapes.  It's very picky.</span>
<span style="color:#9966CC; font-weight:bold;">class</span> TestReverser <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">Test::Unit::TestCase</span>
  <span style="color:#008000; font-style:italic;"># Optional</span>
  <span style="color:#008000; font-style:italic;">#def setup</span>
  <span style="color:#008000; font-style:italic;">#end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> teardown
    <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@test_passed</span> <span style="color:#9966CC; font-weight:bold;">then</span>
      <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;<span style="color:#000099;">\n</span> #{@r.reverse}&quot;</span>  <span style="color:#008000; font-style:italic;"># more verbose for successful passes</span>
      <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{@method_name.upcase} OK.<span style="color:#000099;">\n</span><span style="color:#000099;">\n</span>&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">else</span>
      <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{@method_name.upcase} FAIL.<span style="color:#000099;">\n</span><span style="color:#000099;">\n</span>&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># simple test</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> test_reverser
    test = <span style="color:#996600;">&quot;You space bastard.  You killed my pine.&quot;</span>
    expected = <span style="color:#996600;">&quot;Bastard space you.  Pine my killed you.&quot;</span>
    <span style="color:#0066ff; font-weight:bold;">@r</span> = Reverser.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>test<span style="color:#006600; font-weight:bold;">&#41;</span>
    assert_equal<span style="color:#006600; font-weight:bold;">&#40;</span>expected, <span style="color:#0066ff; font-weight:bold;">@r</span>.<span style="color:#9900CC;">reverse</span>, <span style="color:#996600;">&quot;Fail.&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>        
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Test multiple sentence delimiters  </span>
  <span style="color:#9966CC; font-weight:bold;">def</span> test_multiple_sentence_delimiters
    test = <span style="color:#996600;">&quot;Shape up, man.  You're a slacker.  Do you want to be a slacker for the rest of your life?&quot;</span>
    expected = <span style="color:#996600;">&quot;Man, up shape.  Slacker a you're.  Life your of rest the for slacker a be to want you do?&quot;</span>
    <span style="color:#0066ff; font-weight:bold;">@r</span> = Reverser.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>test<span style="color:#006600; font-weight:bold;">&#41;</span>
    assert_equal<span style="color:#006600; font-weight:bold;">&#40;</span>expected, <span style="color:#0066ff; font-weight:bold;">@r</span>.<span style="color:#9900CC;">reverse</span>, <span style="color:#996600;">&quot;Fail.&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Test no periods, question mark and commas</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> test_question_comma
    test = <span style="color:#996600;">&quot;Then tell me, future boy, huh, who's president of the United States in 1985?&quot;</span>
    expected = <span style="color:#996600;">&quot;1985 in States United the of president who's, huh, boy future, me tell then?&quot;</span>
    <span style="color:#0066ff; font-weight:bold;">@r</span> = Reverser.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>test<span style="color:#006600; font-weight:bold;">&#41;</span>
    assert_equal<span style="color:#006600; font-weight:bold;">&#40;</span>expected, <span style="color:#0066ff; font-weight:bold;">@r</span>.<span style="color:#9900CC;">reverse</span>, <span style="color:#996600;">&quot;Fail.&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Big test  </span>
  <span style="color:#9966CC; font-weight:bold;">def</span> test_everything
    test = <span style="color:#996600;">&quot;Our first television set. Dad just picked it up today. Do you have a television? Well, yeah, you know, we have two of them. Wow! You must be rich. Oh, honey, he's teasing you. Nobody has two television sets.&quot;</span>
    expected = <span style="color:#996600;">&quot;Set television first our.  Today up it picked just dad.  Television a have you do?  Them of two have we, know you, yeah, well.  Wow!  Rich be must you.  You teasing he's, honey, oh.  Sets television two has nobody.&quot;</span>
    <span style="color:#0066ff; font-weight:bold;">@r</span> = Reverser.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>test<span style="color:#006600; font-weight:bold;">&#41;</span>
    assert_equal<span style="color:#006600; font-weight:bold;">&#40;</span>expected, <span style="color:#0066ff; font-weight:bold;">@r</span>.<span style="color:#9900CC;">reverse</span>, <span style="color:#996600;">&quot;Fail.&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>I have to apologize for the scrollbars in the above posted code.  I tried many different ways of escaping carriage returns for better formatting but it would have required a lot of changes to deal with the \n and so on in the tests.  I had something nicely formatted working but the tabs and spaces for alignment then screwed the test and broke the pretty formatting a different way.</p>
<p>reverser.rb:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># A class that reverses sentences.</span>
<span style="color:#008000; font-style:italic;"># &quot;My dog has fleas.&quot; --&gt; &quot;Fleas has dog my.&quot;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> Reverser
&nbsp;
  <span style="color:#008000; font-style:italic;"># tasty constructor, full of taste</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>text<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@text</span> = text
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> reverse
    delim_location = <span style="color:#006666;">0</span>  <span style="color:#008000; font-style:italic;"># char by char, remember !?. for sentence determination</span>
    delim_last_location = <span style="color:#006666;">0</span>  <span style="color:#008000; font-style:italic;"># allows us to move on to the next sentence</span>
    delim_i = <span style="color:#006666;">0</span>  <span style="color:#008000; font-style:italic;"># an iterator</span>
&nbsp;
    new_sentence = <span style="color:#996600;">&quot;&quot;</span>  <span style="color:#008000; font-style:italic;"># inits an empty string for string methods to work</span>
&nbsp;
    new_sentence_array = <span style="color:#CC0066; font-weight:bold;">Array</span>.<span style="color:#9900CC;">new</span>
    punc_array = <span style="color:#CC0066; font-weight:bold;">Array</span>.<span style="color:#9900CC;">new</span>  <span style="color:#008000; font-style:italic;"># list of punctuation marks in order</span>
    <span style="color:#0066ff; font-weight:bold;">@text</span>.<span style="color:#9900CC;">each_char</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>char<span style="color:#006600; font-weight:bold;">|</span>
      delim_i <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#006666;">1</span>  <span style="color:#008000; font-style:italic;"># iterator</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>char == <span style="color:#996600;">&quot;.&quot;</span> <span style="color:#006600; font-weight:bold;">||</span> char == <span style="color:#996600;">&quot;?&quot;</span> <span style="color:#006600; font-weight:bold;">||</span> char == <span style="color:#996600;">&quot;!&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#008000; font-style:italic;"># we hit a deliminter (?!.), remember it</span>
        sentence = <span style="color:#0066ff; font-weight:bold;">@text</span>.<span style="color:#9900CC;">slice</span><span style="color:#006600; font-weight:bold;">&#40;</span>delim_last_location..<span style="color:#9900CC;">delim_i</span><span style="color:#006600; font-weight:bold;">&#41;</span> 
        sentence.<span style="color:#9900CC;">strip</span>!
        new_sentence_array.<span style="color:#9900CC;">push</span><span style="color:#006600; font-weight:bold;">&#40;</span>sentence<span style="color:#006600; font-weight:bold;">&#41;</span>
        punc_array.<span style="color:#9900CC;">push</span><span style="color:#006600; font-weight:bold;">&#40;</span>char<span style="color:#006600; font-weight:bold;">&#41;</span>             
        delim_last_location = delim_i  <span style="color:#008000; font-style:italic;"># remember our substring position</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    i = <span style="color:#006666;">0</span>
    new_sentence_array.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>s<span style="color:#006600; font-weight:bold;">|</span>
        returned_sentence = do_reverse<span style="color:#006600; font-weight:bold;">&#40;</span>s<span style="color:#006600; font-weight:bold;">&#41;</span>  <span style="color:#008000; font-style:italic;"># reverse words sentence by sentence</span>
        new_sentence <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#996600;">&quot;#{returned_sentence}#{punc_array[i]}&quot;</span>  <span style="color:#008000; font-style:italic;"># append the delimiter back</span>
&nbsp;
        <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>i<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006666;">1</span> != new_sentence_array.<span style="color:#9900CC;">length</span><span style="color:#006600; font-weight:bold;">&#41;</span>  <span style="color:#008000; font-style:italic;"># look ahead for last sentence</span>
          new_sentence <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#996600;">&quot;  &quot;</span>  <span style="color:#008000; font-style:italic;"># only append spaces if this is not the last sentence</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
        i <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#006666;">1</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
&nbsp;
    new_sentence  <span style="color:#008000; font-style:italic;"># return new_sentence</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> do_reverse<span style="color:#006600; font-weight:bold;">&#40;</span>s<span style="color:#006600; font-weight:bold;">&#41;</span>
    s.<span style="color:#CC0066; font-weight:bold;">chop!</span>  <span style="color:#008000; font-style:italic;"># trim delimiter</span>
    text_array = s.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot; &quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>  <span style="color:#008000; font-style:italic;"># split on spaces to array</span>
    text_array<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">downcase</span>!  <span style="color:#008000; font-style:italic;"># downcase first word</span>
    text_array.<span style="color:#9900CC;">reverse</span>!  <span style="color:#008000; font-style:italic;"># destructive reverse</span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># need to move commas back</span>
    text_array_i = <span style="color:#006666;">0</span>
    text_array.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>e<span style="color:#006600; font-weight:bold;">|</span>
       text_array_i <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#006666;">1</span>
        <span style="color:#9966CC; font-weight:bold;">if</span> e.<span style="color:#9966CC; font-weight:bold;">include</span>? <span style="color:#996600;">&quot;,&quot;</span>
          e.<span style="color:#CC0066; font-weight:bold;">chop!</span>   <span style="color:#008000; font-style:italic;"># modify original array</span>
          text_array<span style="color:#006600; font-weight:bold;">&#91;</span>text_array_i <span style="color:#006600; font-weight:bold;">-</span> <span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#996600;">&quot;,&quot;</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    text_array<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">capitalize</span>!
    text_array = text_array.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot; &quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>  <span style="color:#008000; font-style:italic;"># destructive join</span>
    text_array.<span style="color:#9900CC;">to_s</span>  <span style="color:#008000; font-style:italic;"># return reversed array</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>When you run the test case it looks like this:</p>
<blockquote><p>Loaded suite ~/src/ruby/tc_reverser<br />
Started</p>
<p> Set television first our.  Today up it picked just dad.  Television a have you do?  Them of two have we, know you, yeah, well.  Wow!  Rich be must you.  You teasing he's, honey, oh.  Sets television two has nobody.<br />
TEST_EVERYTHING OK!</p>
<p>.<br />
 Man, up shape.  Slacker a you're.  Life your of rest the for slacker a be to want you do?<br />
TEST_MULTIPLE_SENTENCE_DELIMITERS OK!</p>
<p>.<br />
 1985 in States United the of president who's, huh, boy future, me tell then?<br />
TEST_QUESTION_COMMA OK!</p>
<p>.<br />
 Bastard space you.  Pine my killed you.<br />
TEST_REVERSER OK!</p>
<p>.<br />
Finished in 0.003567 seconds.<br />
<font color="green">4 tests, 4 assertions, 0 failures, 0 errors</font>
</p></blockquote>
<p>Marty McFly would be proud.  So some limitations.  First, I don't handle elipsis (...) characters at all.  It splits on sentence delimiters which one is a period.  The eplisis would cause major weirdness.  I also don't handle recapitalizing the word "Dad" as you can see in the "test_everything" test.  This would require language parsing or a massive pick list.  I also don't handle slang or abbreviations.  For example, "You told 'em?"  would turn into "'em told you?" which might not be exactly right.</p>
<p>There are many other edge cases that this thing would fall flat on.  My test case tests what functionality I wanted and nothing more.</p>
<p>Ruby's String#slice was super handy on this as well as capitalize, reverse and even a regex split that I didn't use (amazing!).  You can see it here.  It would split text into an array really easily:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">sentence_array = <span style="color:#0066ff; font-weight:bold;">@text</span>.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#91;</span>\.\!\?<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span>  <span style="color:#008000; font-style:italic;"># split with regular expression</span>
&nbsp;
new_sentence_array = <span style="color:#CC0066; font-weight:bold;">Array</span>.<span style="color:#9900CC;">new</span>
sentence_array.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>s<span style="color:#006600; font-weight:bold;">|</span>
    new_sentence_array.<span style="color:#9900CC;">push</span><span style="color:#006600; font-weight:bold;">&#40;</span>do_reverse<span style="color:#006600; font-weight:bold;">&#40;</span>s<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">puts</span> sentence_array<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#0000FF; font-weight:bold;">return</span></pre></div></div>

<p>But then I'd lose the delimiter character (!?. etc) and would have to save it, search it or some other nonsense.  Still, really neat that you can split on a regex.</p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2010/05/01/reversing-sentences-with-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPadDC 2010</title>
		<link>http://squarism.com/2010/04/17/ipaddc-2010/</link>
		<comments>http://squarism.com/2010/04/17/ipaddc-2010/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 03:26:25 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://squarism.com/?p=414</guid>
		<description><![CDATA[Some notes from the 2010 iPadDC conference, I typed as fast as I could. 2nd annual iPhone OS barcamp style un-conference with many good speakers and donuts. Yum. Full slides might be available under the #iPadDC hashtag. Rob Rhyne @capttaco iPad UI Design Walter Gropius, founded the Bauhaus. He loved Claire De Lune from Ocean's [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://squarism.com/2010/04/17/ipaddc-2010/ipaddc/" rel="attachment wp-att-417"><img src="http://squarism.com/wp-content/uploads/2010/04/iPadDC-580x435.jpg" alt="" title="iPadDC" width="580" height="435" class="aligncenter size-large wp-image-417" /></a></p>
<p>Some notes from the 2010 iPadDC conference, I typed as fast as I could.  2nd annual iPhone OS barcamp style un-conference with many good speakers and donuts.  Yum.</p>
<p>Full slides might be available under the <a href="http://twitter.com/ipaddc">#iPadDC hashtag</a>.</p>
<h2>Rob Rhyne @capttaco</h2>
<h3>iPad UI Design</h3>
<p><a href="http://en.wikipedia.org/wiki/Walter_Gropius">Walter Gropius</a>, founded the Bauhaus.<br />
He loved Claire De Lune from Ocean's Eleven, builds up in fountain scene.<br />
Find the simple.<br />
Discover the hook and bust your ass to make your app enjoyable.<br />
When in doubt, polish.<br />
Demo'd his mock up/wireframe iPhone app <a href="http://giveabrief.com/">Brief</a>.  Really looks nice.  http://giveabrief.com/<br />
Ruby based BS script for mock up movement.<br />
Mentioned we should check out a Brett Victor mock up talk at WWDC.  Video might be hard to find.</p>
<h2>Nic Schlueter @schlu</h2>
<h3>Pleasing Everyone</h3>
<p>blog.simpltry.com<br />
Taxi Magic (super awesome), PM Android and WebOS<br />
JSConf<br />
Very cool taxi booking and payment app.<br />
Order of market importance<br />
iPhone -> Android -> Blackberry -> iPad -> WebOS -> WinMobile Phone 7 -> WinMobile 6.5<br />
Basically WinMobile is dead.</p>
<p>Things to worry about<br />
- Isms (metaphors per platform)<br />
- Cross Device Within Platform<br />
- Location<br />
- Multitasking<br />
- App Stores</p>
<p>Androidisms<br />
Back button kills app. Home keeps it alive. These are hardware buttons so this is the way it is. You can't disable this. Android phones don't get latest versions of the OS. And they don't care because they're going to sell a newer phone. So you have to support old OS's.</p>
<p>BlackBerryism<br />
- Learn to love the menus<br />
- Hardware back button<br />
- T-Mobile users prepare for pain<br />
- Blackberry users never upgrade their OS<br />
- Very low expectations</p>
<p>WebOSisms<br />
- hardware back<br />
- software swipe down menu, supported by almost all apps<br />
- most similar to iPhone</p>
<p>Platform Quirks (deep dive)<br />
Android<br />
- screen resolution<br />
     - biggest challenge<br />
     - must support landscape if you want cred!<br />
     - watch the font size<br />
     - large variety in PPI and resolution in phones<br />
     - so you have to use different pixel density features of fonts?<br />
- Which OS to Target<br />
     - 1.6 unless you have a good reason<br />
     - 6-9 mo you can safely target 2.0 or 2.1<br />
     - expensive to test old devices (subscriptions)<br />
     - device manufacturers don't make it a priority to update device OS</p>
<p>Blackberry<br />
- layout manager not quite as flexible as Android, you have to do lots of detection on your end<br />
- Currently a lot of resolutions<br />
- In the future, should be less than Android<br />
- Which OS to target. The Blackberry App World allows you to submit apps targeted from 4.2.1+.<br />
- Enterprises might want you to target older devices.<br />
- Too many threads bug<br />
     - 6-7 threads seem to be the max. Nasty. A problem on older BBs.</p>
<p>Future Proof<br />
- build support into your price<br />
     - either the app is going to suck or you'll be broke if you don't<br />
- unreleased phones will break your app</p>
<p>T-Mobile<br />
- some crazy APN process to enable 3rd party internet support on your app</p>
<p>BB partner<br />
$2000/year to be a partner. They'll send source code. 1-on-1 support person. If you're serious about BB, it's worth it.</p>
<p>WebOS<br />
- multi-resolutions, not that bad. It's all CSS3.<br />
- Bottom position sticky to the bottom.<br />
- PDK makes games fairly trivial. C &#038; C++ are easily portable.<br />
- Single threaded, not a problem with Ajax async for network calls etc.<br />
- Ares web based IDE developing in the browser.<br />
- Is it worth it? Probably not. Still better than WindowsMobile! HAHA</p>
<p>iPhone location services are awesome, spoiled. Others aren't as good. The Droid rate limits how frequently you can get a location. Even between app restarts. Check time on the last known location. Nasty behavior for him to figure out.</p>
<p>BB Location. Slow GPS only. Not on older phones.<br />
WebOS Location is basically fine.</p>
<p>Multitasking<br />
- Do not do things that kill the battery. Location or network.<br />
- Consider the user experience if a user comes back to a screen days later.<br />
Android<br />
- full access<br />
- prog con running<br />
- save state when users leave app<br />
- your app gets killed in low mem situtations<br />
BB<br />
- full access<br />
- your prog con running<br />
- do what you want (spawn, background, you can watch sms/email - poor man's push)<br />
WebOS<br />
- full access<br />
- won't kill your app, prevents users from starting a new app if too much mem in use<br />
- You must have a card or icon when running in bg, or prepare to be killed</p>
<p>App Stores<br />
Apple - submit, wait, pray (14 days to 24 hours to 3 days). Apple is the only one with identifiers for betas. 70/30<br />
Android - no permission, 325 character description limit, can only sell from certain countries. Money collected from Google Checkout. Betas run from your own server. Free to publish. 70/30<br />
Blackberry - 3ish day approval time. $2.99 minimum price. Betas run through your own server. $200 per app. 80/20 split<br />
WebOS - 5ish day approval. $50 per app. 70/30.</p>
<h2>Dana Nuon @wdnuon</h2>
<h3>iBooks Page Curl in Six Lines of Code</h3>
<p>Transforming page by page turning with deformation. Method returns a vector which is applied to a flat matrix. Each vertex in a matrix has an X/Y. The function adds a Z.</p>
<p>He basically showed how to implement the Apple iBook page turn effect in six lines of code using a Xerox algorithm from a one page PDF with some super heavy conic math. Super awesome demos he had.  He's been doing this stuff for a while.  Very experienced, very nice chats after his talk.</p>
<h2>Luis de la Rosa @louielouie</h2>
<h3>Seven Ways to Improve Your App with Servers</h3>
<p>Pro: Access more data, differentiate<br />
Con: More work, maintenance</p>
<p>JSON vs XML<br />
JSON - smaller, more efficient - TouchJSON<br />
XML - built-in, ubiquitous - TouchXML<br />
runner-ups: plist (no server will recognize this), custom binary</p>
<p>API enables community (high score list). More processing power (upload image to amazon mechanical turk)</p>
<p>Debugging. Inspect traffic. Charles Proxy. Adjust WiFi proxy preference. Debug with proxy.</p>
<p>Push notification: Your Server -> Apple Push Server -> iPad -> Popup: Your App: Hello World!<br />
- Registration<br />
- Push message, badge, sound. Message 5lines, 24 char<br />
- Best Practice, custom data to highlight item. Push some JSON to highlight.</p>
<p>In-App Purchase<br />
Three types:<br />
- Consumable (example: uBoot torpedos).<br />
- Non-consumable (ie: uBoot levels) - usually built-in<br />
- Subscriptions (magazine)</p>
<p>In-App Purchase Server Product Model<br />
- App store handles CC but then passes it to you.<br />
iPad -> App Store -> Your Server -> iPad</p>
<p>Sync<br />
User data survives data / app loss. Or enable multiple devices per user. Out of scope: WiFi Sync (sync to mac) + GameKit (P2P)</p>
<p>Analytics<br />
- Track usage<br />
- Easy to setup<br />
- Best practice: Send specific custom data (which level are people playing the most?)<br />
- Best practice: Crash handler</p>
<p>Advertising<br />
- Make money with free app<br />
- Design: Dedicate some space<br />
- Animation may help</p>
<p>How to implement<br />
- Hire a consultant like Happy Apps<br />
- DIY<br />
- 3rd party providers like Millennial Media<br />
- Apple (they don't do much)</p>
<h2>Christopher Brown</h2>
<h3>iPad Advertising</h3>
<p>Answered questions and talked about how to do analytics, marketing, ads and what iAds might affect the space.  He had solid metrics and graphs that I can't type out like he did last year with his Tap Metrics talk.</p>
<h2>David Smith</h2>
<h3>14 Days and 11 Apps Later</h3>
<p>An amazing walkthrough his flurry of app submissions.  He walked through ideas he and his team had for the iPad, demo'd his <em>ELEVEN APPS</em> and showed sales results.  Shotgun approach gets a bit of cash but not really going to start a business.  He had a lot of great insight like, "it's not about making money but about getting your $99 worth and learning".  I'm not doing his talk justice.  Cool guy.</p>
<h2>James Norton @jnorton</h2>
<h3>OpenGL ES 2.0 &#038; the OpenGL Shading Language</h3>
<p>Graphics Pipeline<br />
Why 2.0?<br />
- Programmable shaders enable things that are difficult or impossible without them<br />
- Computations in the GPU<br />
- Can free up memory by replacing static textures</p>
<p>Shaders (introduced in 2.0)<br />
- Vertex Shaders operate on vertex data (attributes)<br />
     - Enables CPU to offload many vertex computations to GPU<br />
- Fragment Shaders operate on fragment (pixel) data<br />
     - Allow per-pixel effects like per-pixel lighting, procedural textures (bump mapping or env mapping), noise, etc</p>
<p>Shading Language<br />
- Based on C<br />
- Variables, structures, arrays, operators, functions, flow control<br />
- Additional types to support gfx operations (vectors and matrices)</p>
<p>Differences from C<br />
- Stricter type conversions<br />
- No pointers<br />
- Function parameters can be qualified with modification: in (default), inout, out<br />
- For loopers require iteration count to be known at compile time<br />
- Array indices must be constants</p>
<p>Variable Types<br />
- Scalars - float, int, bool</p>
<p>Vectors and Matrices<br />
- Ops work with vec and matrices too<br />
- Multiplication op handles vec matrix and mat/matrix multiplies correctly<br />
- Math ops likely to be HW accel<br />
- Position component access<br />
<code><br />
vec2 pos = vec2(0,1.0)<br />
float xPost = pos.x;<br />
float yPos = pos.y;<br />
</code></p>
<p>Variable Constructors<br />
<code>vec2 texCoord = vec2(0.5, 0.5);</code></p>
<p>Type conversion<br />
<code>int count = 4;<br />
float fCount = float(count);<br />
</code></p>
<p>Flexible<br />
<code>vec3 pos = vec3(1.0,1.0,1.0);<br />
vec2 something = vec2(pos);<br />
</code></p>
<p>Precision Qualifiers<br />
lowp,mediump,highp (high precision)<br />
highp vec4 color;<br />
MUST declare default or per var precision for float in frag shaders</p>
<p>Type Modifiers<br />
- Uniforms - readonly variables passed in by the application<br />
- Attributes - per-vertex input to the vertex shader<br />
- Varyings - user to communicate form vertex shaders to fragment shader</p>
<p>Simple Shaders<br />
Vertex Shader<br />
<code>attribute vec4 position;<br />
attribute vec2 texCoord;<br />
varying vec2 fTexCoord;</p>
<p>void main(void) {<br />
     gl_Position = position; // no view transformation<br />
     fTexCoord = texCoord; // will be linearly interpolated<br />
}<br />
</code></p>
<p>Fragment Shader<br />
<code>precision highp float;<br />
varying vec2 fTexCoord;</p>
<p>uniform sampler2D myTextureSampler;</p>
<p>void main(void) {<br />
     gl_FragColor = texture2D(myTextureSampler,fTexCoord);<br />
}<br />
</code></p>
<p>TV Noise Fade in Demo<br />
Sigmoid Function: s(t) = 1 / (1 + e^ -f(t-t0) )<br />
Vertex Shader simply passes position to gl_Position like before.</p>
<p>Fragment Shader preample<br />
<code>precision highp float;      // use high p as defaulit for floats<br />
uniforma smapler2D test_pattern_texture;     // texture sampler for text patter<br />
uniform highp float time;     //time since animation start<br />
varying highp vec2 vTexCoord;</p>
<p>void main() {<br />
     float weight = sigmoid(time);<br />
     float randStatic = rand(vTextCoord);<br />
     float randDynamic = rand(vec2(randStatic,weight));<br />
     vec4 texVal = texture2D(test_pattern_texture, vTexCoord);<br />
     //don't add noise to the black border<br />
     if(textVal != vec4(0,0,0,1)){<br />
          gl_FragColor = weight * texVal + (12.0 - weight) * randDynamic;<br />
     } else {<br />
          gl_FragColor = texVal;<br />
     }<br />
}</p>
<p>// sigmoid function<br />
float sigmoid(highp float t) {<br />
float f = 10.0;<br />
float t0 = 1.25;<br />
return 1.0 / (1.0 + exp(f * -(t - t0)));<br />
}</p>
<p>// pseudo random number generator<br />
float rand(highp vec2 pos){<br />
     return fract(sin(dot(pos, vec2(12.0909, 78 ....<br />
}<br />
</code></p>
<p>Final Thoughts<br />
- OpenGL ES 2.0 allows developers more flexibility than OpenGL ES 1.1. Only will run on 3GS, iPad<br />
- Gold book (the purple book).<br />
- Orange book later for advanced.</p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2010/04/17/ipaddc-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to pair a Bluetooth Keyboard with an iPad</title>
		<link>http://squarism.com/2010/04/03/how-to-pair-a-bluetooth-keyboard-with-an-ipad/</link>
		<comments>http://squarism.com/2010/04/03/how-to-pair-a-bluetooth-keyboard-with-an-ipad/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 22:47:12 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://squarism.com/?p=399</guid>
		<description><![CDATA[I figured out something that was a bit unintuitive. I have an Apple Wireless Bluetooth keyboard paired with a Mac. I wanted to see if it works on my iPad. I went to Bluetooth->Disconnect on the Mac and the keyboard showed up in the iPad Bluetooth discovery screen but it wouldn't pair. I just happened [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://squarism.com/2010/04/03/how-to-pair-a-bluetooth-keyboard-with-an-ipad/bluetooth_keyboard_and_ipad/" rel="attachment wp-att-402"><img src="http://squarism.com/wp-content/uploads/2010/04/Bluetooth_Keyboard_and_iPad.png" alt="" title="Bluetooth_Keyboard_and_iPad" width="600" height="450" class="aligncenter size-full wp-image-402" /></a><br />
I figured out something that was a bit unintuitive.  I have an Apple Wireless Bluetooth keyboard paired with a Mac.  I wanted to see if it works on my iPad.  I went to Bluetooth->Disconnect on the Mac and the keyboard showed up in the iPad Bluetooth discovery screen but it wouldn't pair.</p>
<p>I just happened to find a method to get this working:</p>
<ul>
<li>Select disconnect on the Mac.</li>
<li>Turn off bluetooth completely on the Mac.</li>
<li>Hold down the power button on the keyboard to turn it off.</li>
<li>Press the power button once on the keyboard to turn it on.</li>
<li>The keyboard will show up in the iPad bluetooth list as before but now when you click it, the keyboard light will start flashing as it pairs.</li>
<li>The iPad will tell you to type a code and enter.</li>
<li>Good to go!</li>
</ul>
<p><a href="http://squarism.com/2010/04/03/how-to-pair-a-bluetooth-keyboard-with-an-ipad/bluetooth_ipad/" rel="attachment wp-att-406"><img src="http://squarism.com/wp-content/uploads/2010/04/Bluetooth_iPad.png" alt="" title="Bluetooth_iPad" width="1024" height="261" class="aligncenter size-full wp-image-406" /></a></p>
<p>It works for text areas in the browser and email windows.  The on-screen keyboard doesn't appear.  It's way faster to enter a blog post like this (hehe).  It doesn't seem to work for navigating menus (with the arrow keys or anything).  Think of it as a replacement for the on screen keyboard.</p>
<p>Also, be aware that you do have to unpair with the computer.  Pairing means 1-to-1.  Not 1-to-many.  This is how bluetooth (even on PC) works unfortunately.  If you want to broadcast keyboard strokes out to many computers you'll have to use something like VNC.  Unfortunately there isn't a VNC server that I know of for the iPad yet (if ever).  The iPhone versions of VNC require you to jailbreak your phone which can be a pain if you like "quick and easy".  I rarely use my bluetooth keyboard on my media center so I didn't buy a second one.  Your mileage may vary.</p>
<p><a href="http://squarism.com/2010/04/03/how-to-pair-a-bluetooth-keyboard-with-an-ipad/bluetooth_ipad_test/" rel="attachment wp-att-405"><img src="http://squarism.com/wp-content/uploads/2010/04/Bluetooth_iPad_test.png" alt="" title="Bluetooth_iPad_test" width="455" height="112" class="aligncenter size-full wp-image-405" /></a></p>
<p>Hope this helps someone!  Post a comment if it did.</p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2010/04/03/how-to-pair-a-bluetooth-keyboard-with-an-ipad/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>iPadcolypse</title>
		<link>http://squarism.com/2010/04/03/ipadcolypse/</link>
		<comments>http://squarism.com/2010/04/03/ipadcolypse/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 22:25:22 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://squarism.com/?p=397</guid>
		<description><![CDATA[The Wiff was using the yahoo tv guide (free app) and wants one. It's got potential as a living room multitasker thingy. I got the 32gb. The 64gb is useless because you still have to pick your media you want to sync. Maybe the 16gb would have been better but I wanted to cram a [...]]]></description>
			<content:encoded><![CDATA[<p>The Wiff was using the yahoo tv guide (free app) and wants one.  It's got potential as a living room multitasker thingy.  I got the 32gb.  The 64gb is useless because you still have to pick your media you want to sync.  Maybe the 16gb would have been better but I wanted to cram a bunch of stuff on it.  If they had a 1TB one (lol) then you could sync your whole iTunes library and movies etc etc.  I wish it had an SD slot and some other expansion stuff on it.  Like it just mounting up as a disk.</p>
<p>But I did grab an app called "GoodReader".  It'll probably be replaced by something better (a lot of apps are rushed first to market attempts) but it has DropBox download support (not sync).  So I just threw my ebook PDFs (like from other publishers such as PragProg other than the Kindle) and that's how I got PDFs on it.</p>
<p>Among the star apps so far:<br />
- Kindle app (free), pretty nice.  Nicer than the Kindle.  I wish it had two page view like iBooks does.  iBooks doesn't have shit for selection right now.  No tech books.  All my tech books are in the Kindle store or PDF.<br />
- Twitterific (widscreen is the best mode, probably more improvements later)<br />
- NY Times (please release digital Wired mag like this)<br />
- Yahoo Entertainment app<br />
- ABC app, plays episodes in crappy SD but free<br />
- Weatherbug (super slick Radar and forecast all in one huge data overload view)<br />
- Evernote (online notebook).  Not as slick as it should be.  No formatting options while editing.<br />
- BBC news (meh kinda redudant)<br />
- Plants vs Zombies (PvZ), perfect port</p>
<p>All the official apps are super polished.  I haven't bought the iLife suite apps.  I don't think I need them (maybe I will at work?).  I'm waiting for a few of my favorite devs to update their apps:<br />
- Mint<br />
- IRC chat called FlowChat<br />
- Lux Touch (woo multitouch strategy)<br />
- Some kind of SSH awesomeness.<br />
- Ruler app (just because I could measure bigger things?)<br />
- Official facebook app<br />
- How about a WoW auction app?!?!  COME ON!  Even if I don't play.</p>
<p>Many apps are $10.  So I'm holding out for more free competition.</p>
<p>There's a scrabble app that plays with your phone.  You put your tiles on your phone as the tile rack so you can hide your letters.  Everyone plays on the iPad.  I haven't tried it but what a great idea!  I'd like to see the MS Surface stuff on these devices like that.  Imagine some geeky strategy game or RPG.  Or Battleship.</p>
<p>I have to figure out how to sync my calendar and all the stuff I set up on my phone.  I'm trying to keep the two devices separate.  For example, I don't need any apps that scan barcodes because it doesn't have a camera.  :P</p>
<p>I'm surprised how fast this thing is.  I see why so many games are coming out.  Sorry for the short write-up but I'm in toy overload mode.</p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2010/04/03/ipadcolypse/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dokuwiki April Fools 2010</title>
		<link>http://squarism.com/2010/04/01/dokuwiki-april-fools-2010/</link>
		<comments>http://squarism.com/2010/04/01/dokuwiki-april-fools-2010/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 22:43:34 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://squarism.com/?p=388</guid>
		<description><![CDATA[I was checking out some syntax on dokuwiki's website and suddenly a duck appeared from the right hand side. When I hovered over it, I got a web browser crosshair. When I clicked on it (*bang*), a bullet hole image appeared in the web page and the duck (*quack*) fell to the bottom of the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://squarism.com/2010/04/01/dokuwiki-april-fools-2010/dokuwiki_april_fools_2010/" rel="attachment wp-att-389"><img src="http://squarism.com/wp-content/uploads/2010/04/dokuwiki_april_fools_2010.png" alt="" title="dokuwiki_april_fools_2010" width="482" height="226" class="aligncenter size-full wp-image-389" /></a></p>
<p>I was checking out some syntax on <a href="http://www.dokuwiki.org/dokuwiki">dokuwiki's website</a> and suddenly a duck appeared from the right hand side.  When I hovered over it, I got a web browser crosshair.  When I clicked on it (*bang*), a bullet hole image appeared in the web page and the duck (*quack*) fell to the bottom of the browser window.</p>
<p>Duck hunt!</p>
<p>I didn't see it blogged about yet so there ya go.  Techcrunch has <a href="http://techcrunch.com/april-fools-shenanigans/">a good wrap-up</a> of 2010 april fool's jokes.  This year didn't seem as big as last year's.</p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2010/04/01/dokuwiki-april-fools-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SCP vs RSync vs SMB vs FTP</title>
		<link>http://squarism.com/2010/02/11/scp-vs-rsync-vs-smb-vs-ftp/</link>
		<comments>http://squarism.com/2010/02/11/scp-vs-rsync-vs-smb-vs-ftp/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 04:55:00 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://squarism.com/?p=327</guid>
		<description><![CDATA[@fearthepenguin made an rsync comment that made me curious. He said that rsync in cygwin is faster than native SMB in Windows. Ok I haven't done this test in a while, let's get a reminder about how fat SMB is. Test Setup SOHO gigabit switch. Ubuntu 9.10 and octo-core 2008 Mac Pro running 10.6. Both [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://twitter.com/fearthepenguin">@fearthepenguin</a> made an rsync comment that made me curious.  He said that rsync in cygwin is faster than native SMB in Windows.  Ok I haven't done this test in a while, let's get a reminder about how fat SMB is.</p>
<h5>Test Setup</h5>
<p>SOHO gigabit switch.  Ubuntu 9.10 and octo-core 2008 Mac Pro running 10.6.  Both pretty fast boxes.  Regular SATA drives in each, not very fast I/O.  Whatever, network should be the bottleneck.</p>
<p>Get my test file generated.<br />
<code>$ dd if=/dev/zero of=1gb_file.zeros bs=1G count=1<br />
1073741824 bytes (1.1 GB) copied, 133.577 s, 8.0 MB/s</code></p>
<p>Ignore that 8.0 MB/s.  You can do a blocksize trick to make it output a file faster, I just didn't feel like looking up the switches.  Now you can see Mr. 1GB Zero File in all it's empty and big glory.<br />
<code><br />
$ ls -lh<br />
total 1.2G<br />
-rw-r--r--  1 dude herd 1.0G 2010-02-11 12:29 1gb_file.zeros</code></p>
<h5>The Tests</h5>
<p><strong>RSync</strong><br />
Copy from ubuntu box to Mac Pro:<br />
<code>$ time rsync -t /tmp/1gb_file.zeros dude@mac:~/tmp<br />
real	0m17.694s<br />
user	0m11.577s<br />
sys	0m3.056s<br />
</code></p>
<p><strong>SMB</strong><br />
Mount Mac share from Ubuntu box.  Copy same file from ubuntu box to Mac Pro over SMB mount.  I never do this.  It's stupid, slow, strips permissions and requires a mount.  In the name of science!<br />
<code># time cp /tmp/1gb_file.zeros /mnt/tmp<br />
real	0m32.649s<br />
user	0m0.008s<br />
sys	0m0.568s<br />
</code></p>
<p><strong>FTP</strong><br />
Ok let's goddamn turn on OSX FTP and test that too.  FTP is stupid.<br />
<code>The remote file "1gb_file.zeros" already exists.<br />
	Local:    1073741824 bytes, dated Thu 11 Feb 2010 12:29:06 PM EST.<br />
	(Files are identical, skipped)<br />
</code></p>
<p>Hey at least FTP is showing some smarts about it.  Or maybe ncftp just rules.  I dunno.  Deleted it and got FTP time.</p>
<p><code>$ time ncftpput -u dude -p whoa mac /dest/tmp /tmp/1gb_file.zeros<br />
/tmp/1gb_file.zeros:                          1.00 GB   39.09 MB/s<br />
real	0m26.507s<br />
user	0m0.036s<br />
sys	0m0.828s<br />
</code></p>
<p><strong>SCP</strong><br />
Is SCP any different than rsync?<br />
<code>$ time scp /tmp/1gb_file.zeros dude@mac:~/tmp<br />
1gb_file.zeros                                100% 1024MB  42.7MB/s   00:24<br />
real	0m24.303s<br />
user	0m9.641s<br />
sys	0m2.212s<br />
</code></p>
<p>Weird.  It is.  I wonder if rsync has compression flags whereas ssh does not without the -C magic switches.  You can get SCP to be pretty quick with blowfish or arcfour:</p>
<p><code>$ time scp -c arcfour /tmp/1gb_file.zeros dude@mac:~/tmp<br />
1gb_file.zeros                                100% 1024MB  46.6MB/s   00:22<br />
real	0m21.653s<br />
user	0m5.452s<br />
sys	0m2.032s</code></p>
<h5>Conclusion</h5>
<table width=75%>
<th></th>
<th>rsync</th>
<th>SMB</th>
<th>FTP</th>
<th>SCP</th>
<th>SCP arcfour</th>
<tr>
<td>time</td>
<td>17.694</td>
<td>32.649</td>
<td>26.507</td>
<td>24.303</td>
<td>21.653</td>
</tr>
<tr>
<td>MB/sec</td>
<td>57.87</td>
<td>31.36</td>
<td>38.63</td>
<td>42.13</td>
<td>47.29</td>
</tr>
</table>
<p>So RSync is pretty quick and SMB is pretty slow.  @fearthepenguin was right.</p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2010/02/11/scp-vs-rsync-vs-smb-vs-ftp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Buying a cat with logic switches</title>
		<link>http://squarism.com/2010/01/23/cat-logic/</link>
		<comments>http://squarism.com/2010/01/23/cat-logic/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 18:43:19 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://squarism.com/?p=301</guid>
		<description><![CDATA[Charles Petzold's book Code is an awesome read. I'm reading it again actually. It's so elegant and simple. Walks you through history and experiments in a style I find extremely invoking. I wanted to build a logic switch but I don't want to blow anything up so I tried this java applet at falstad.com and [...]]]></description>
			<content:encoded><![CDATA[<p>Charles Petzold's book <a href="http://www.amazon.com/Code-Language-Computer-Hardware-Software/dp/0735611319">Code</a> is an awesome read.  I'm reading it again actually.  It's so elegant and simple.  Walks you through history and experiments in a style I find <em>extremely</em> invoking.  I wanted to build a logic switch but I don't want to blow anything up so I tried <a href="http://www.falstad.com/circuit/">this java applet</a> at falstad.com and it works pretty well.  I tried qucs but it's way too complicate for me and doesn't include an LED.</p>
<p>An example from Code (this is not the exact example) is where he's trying to buy a pet from a pet store and he creates a logic circuit that will light up a light bulb when the pet is correct.  Let's say I'm looking for a normal gray cat as a house pet (not a tiger! rawr!).  When I flip all the switches correctly, the LED lights up but if I get a gray tiger (that's technically a cat) then the LED (the red dot) says nope.</p>
<p>The salesman brings me a gray tiger.  Nope.<br />
<img src="http://squarism.com/wp-content/uploads/2010/01/logic_gray_tiger-300x200.png" alt="logic_gray_tiger" title="logic_gray_tiger" width="300" height="200" class="aligncenter size-medium wp-image-302" /></p>
<p>The salesman brings me a gray cat that's not a tiger.  Yep.<br />
<img src="http://squarism.com/wp-content/uploads/2010/01/logic_gray_cat-300x200.png" alt="logic_gray_cat" title="logic_gray_cat" width="300" height="200" class="aligncenter size-medium wp-image-303" /></p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2010/01/23/cat-logic/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>iPhoneDevCampDC 2009</title>
		<link>http://squarism.com/2009/08/11/iphonedevcampdc-2009/</link>
		<comments>http://squarism.com/2009/08/11/iphonedevcampdc-2009/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 03:32:53 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Noteworthy]]></category>

		<guid isPermaLink="false">http://squarism.com/?p=254</guid>
		<description><![CDATA[Went to the first annual iPhone Dev Camp here in DC. It was a barcamp style event over two days. It was very enjoyable although there were quite a few heavy hitters there (I wasn't one of them). There were a few different types of people there and I was one of the ones who [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://squarism.com/wp-content/uploads/2009/08/iphonedevdc.jpg" alt="iphonedevdc" title="iphonedevdc" width="604" height="237" class="aligncenter size-full wp-image-256" /><br />
Went to the first annual iPhone Dev Camp here in DC.  It was a barcamp style event over two days.  It was very enjoyable although there were quite a few heavy hitters there (I wasn't one of them).  There were a few different types of people there and I was one of the ones who doesn't have anything on the app store and isn't making any money off iPhone dev.  A few people there had apps I knew from the press as well as an author (Dave Mark -- who was great) that I've read quite a bit from.</p>
<p>What follows is some of the notes that I took at the conference.  It's by no means a transcription.</p>
<h2>Peter Corbett - Apps for Democracy</h2>
<p>@corbet3000<br />
He met with Vivek Kundra (CTO/fed CIO DC) and started a dontest for DC, open data.  Citizens created "fix my city" type apps.  43 webapps created, $2.3 EST value, $50k cost, 5000% roi.  Huge success.</p>
<p>A few examples:</p>
<ul>
<li>areyousafedc iphone app - a tachometer as you walk, green = safe, red = danger.  Pulls data from open city sources, crime reports etc.  Very simple interface, pretty cool</li>
<li>wethepeoplewiki.com - structured wiki, real-time crime data.  I didn't get this.</li>
<li>park it dc - very cool parking meter app.  People report broken meters, displays broken meters on a google map mashup.  City found their contractors were fixing their meters in avg of 7 days but their SLA was 24 hours.  Broken meters not cities fault, app helped DC discover the real problem.</li>
<li>iPhone demo at DC311 - http://victorshillo.com/dc311/2/</li>
</ul>
<p>Really good presentation.  Peter is a cool guy.  Nice, technical and well connected.  Peter did another awesome presentation called <a href="http://www.youtube.com/watch?v=wZI2_fHFJ2s">No one cares about your crappy webapp</a> at an Ignite Baltimore conference.  I tried to tell him how awesome that was but it's hard to put into words.</p>
<h2>Jonathan Blocksom - OpenGL</h2>
<p>@jblocksom</p>
<p>http://www.gollygee.com/weblogs/jblocksom</p>
<p>Jonathan works at google.  He had an android shirt on.  It was pretty funny.  I seriously think he was there to convert some people.  :P  He was really nice and I enjoyed talking to him about gamedev (even if most of my stuff has been in Java).  He did a really nice overview of OpenGL, computer graphics and his game Bubbles.  His game has been on the app store since the beginning of the app store opening.</p>
<ul>
<li>Z buffering is checking if a pixel is behind another, won't render.</li>
<li>Use the iPhone boilerplate template to learn</li>
<li>Overview of the various buffers that the template creates.</li>
<li>You can use the bullet SDK, collada to import 3d models etc</li>
<li>You can use the Texture2D class to easily import textures from the apple Lunar lander sample code</li>
<li>You can use the touch fighter sample code.  It shows how to  overlay a high score list over opengl view</li>
<li>Don't mix OpenGL and cocoa views together for performance reasons</li>
<li>He gave an overview of his sales history which was interesting.</li>
</ul>
<p>A lot of people showed their sales tapering off after an initial burst of sales.  Sometimes press coverage or even competing apps would create another bust of sales.</p>
<h2>Leon Palm - Computer Vision</h2>
<p>Leon also works at Google (not that anyone is judging people based on their day job.  Hey, google is a cool company (currently).  He was a really smart and nice guy.  Easy to talk to.  Had a cool Sudoku solver app to demo.  I thought I had seen his app covered in the press but that turned out to be a competing one (oops!).  His presentation walked through how the app works.  Some parts are super confusing and hard but he did a good job in breaking it down.</p>
<p>How his app works:</p>
<ul>
<li>Evolution algorithm</li>
<li>RANSAC to find the line</li>
<li>Walk the intersection of the lines</li>
<li>Find 8x8 inliers in checkers, 7x8 in connect four</li>
<li>Have lines, apply transform matrix to rectify image</li>
<li>Get pieces is easy</li>
<li>Sample region at expected center, create int array for piece config</li>
<li>Use open source solver etc</li>
</ul>
<p>Drawing the results back.<br />
We have: piece colors, positions, sizes and warp matrix.  Derectify image and draw over solution.</p>
<p>Conclusion: easy to do if task is broken down.  Use existing knowledge (whitepapers).  Filtering/tweaking is the most important part.  You have to tweak it to work with cameras lighting and make it accurate.  He said tweaking and adjusting took the most time.  I believe it.</p>
<p>I have done some test type stuff with OpenCV but Leon had really taken this all the way to the finish line.  It was a really in-depth talk that was academically the most complicated of all the talks.</p>
<h2>Kiril - Working w Designers from Imagini Studios</h2>
<p>Kiril is the artist that worked on Harbor Master.  It's a "line drawing" game similar to Flight Control.  Apparently it's doing very well on the app store.  These guys were super pro.  They had a great presentation, super personalities and they had found success being an indie game dev shop.  I was really green but then I hadn't put in the hours etc.</p>
<p>Kiril talked about his mock ups, how he worked with the developers (2 of them) and showed his different iterative art pieces.  He mentioned <a href="http://ffffound.com/">ffffound</a> for art inspiration.  And his most important advice to developers: <em>don't think that mockups are the final product.</em>  He said many people can't make the jump from concept to final product.</p>
<h2>Christopher Brown - App Store Data!</h2>
<p>Christopher runs an analytics company called Tap Metrics.  They had a super slick web app that scrapes data from the app store (I imagine only a few people can do this).  He had run many reports and shared some interesting trends:</p>
<ul>
<li>Most people that buy an app stay in that category and buy again</li>
<li>94% of apps are in English, meaning German/English counts.  Germany only counts wouldn't count.  All -> EN -> DE, FR, JP</li>
<li>1% conversion freemium rate free->pro.  Meaning 1M free downloads.<br />
1.99 better segment, .99 is saturated
</ul>
<p>If I was on the store, I'd talk to Chris about metrics.  I can't imagine anyone else having something similar in polish.  I hope he gets some traction (if he hasn't already) on his work.  It was impressive.</p>
<h2>Dave Smith - Audio on the iPhone</h2>
<p>Dave had a presentation that I really enjoyed having worked with various audio APIs.  I asked the most questions on this one.  He walked through his audiobook app (which was really neat).  He was friendly to talk to (for further notice ... everyone was nice).  He gave a good overview of real code and a real working audiobook app he works on.  The app displays the text version of the audiobook while it plays and stays in sync.  It's very polished.</p>
<p>Some random notes (I wrote as fast as I could):</p>
<ul>
<li>AVAudioPlayer level above openAL</li>
<li>mp3 format is hw decompression, good for batt/performance</li>
<li>To get started, add AVFoundation, AudioToolbox frameworks to project</li>
<li>Make a pointer: AVAudioPlayer* player</li>
<li>- (IBAction)play:(id)sender;  // methods for button actions etc</li>
<li>In interface builder, mapping actions using touchUpInside is the best option to capture user button push</li>
<li>Useful command line utility in OSX: /usr/bin/afconvert -iaf4 (convert aiff to compressed formats, pre-compress best for iphone optimization)</li>
<li>UInt32 category = kAudioSessionCategory_MediaPlayback  // kAudioSessionCategory_* has many diff options</li>
</ul>
<p>He always released his memory correctly.  :)<br />
<code>[player pause]<br />
[player release]<br />
player = nil // nice GC technique</code></p>
<p>His start method created the player and played at the same time.  Pause destroyed it.  This might seem odd but he said, "don't keep player instances around for a long time, non deterministic things can start happening."</p>
<h2>Sze Wong - $1M app</h2>
<p>Sze asked the question "what would a $1M iphone app look like?".  He also talked about enterprise development and asked if the iPhone could be a serious contender.  He has a metric ton of experience doing enterprise and mobile development.  He seems to like the iPhone (hey a lot of us are sick of doing J2EE) as a refreshing platform.</p>
<p>Sze had a really nice presentation that didn't materialize for me until he showed his demo.  I can only describe it as Oracle Forms for the iPhone.  He has a slick web ui that can generate custom forms for many different uses.  His forms could even include a signature box that the iPhone can use to create a UPS type delivery board.  It was pretty compelling and he had a lot of nice backend stuff (like JSON, RSS, XLS exporters) created in the web ui.</p>
<h2>Other topics</h2>
<p>Things wound down and at the end they had a panel of the experts there give answers to various questions by Dave Mark.  It was really neat to see an improvised conference.</p>
<ul>
<li>A lot of people mentioned the importance of Touch Arcade.</li>
<li>Someone mentioned nsfetchrequest for nstableviews?</li>
<li>Ad hoc distribution for beta testers?  I need to research that.</li>
<li>Imangi Studios mentioned getsatisfaction, a customer support portal to outsource support</li>
</ul>
<p>Fun conference.  I hope to see them next year or sooner.  I think ruby dcamp is next for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2009/08/11/iphonedevcampdc-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Better tetris collision detection</title>
		<link>http://squarism.com/2009/07/09/better-tetris-collision-detection/</link>
		<comments>http://squarism.com/2009/07/09/better-tetris-collision-detection/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 02:44:26 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://squarism.com/?p=244</guid>
		<description><![CDATA[As I said in the TODO part of the Making Tetris post, a better way to do collision detection is to have the blocks on the field be bits. This is typically what I saw in academic assignments and student presentations. This is probably the right way to do it in other words. It's more [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://squarism.com/wp-content/uploads/2009/07/deadgrid.png" alt="deadgrid" title="deadgrid" width="336" height="358" class="aligncenter size-full wp-image-247" /></p>
<p>As I said in the TODO part of the <a href="http://squarism.com/2009/06/22/making-tetris/4/">Making Tetris post</a>, a better way to do collision detection is to have the blocks on the field be bits.  This is typically what I saw in academic assignments and student presentations.  This is probably the right way to do it in other words.  It's more efficient and it's more simple (<a href="http://en.wikipedia.org/wiki/KISS_principle">KISS</a>).</p>
<p>Even though this isn't how I did it in the game, I still wanted to play around with the concept so I made a little prototype that demonstrates the basic gist.  Instead of a piece, it's a single block.  Instead of a tetris grid of finished blocks, it's random blocks.  It's really the same thing, it just looks and plays with different shapes.</p>
<p>So here it is.  Space randomizes the grid and the arrow keys move.  <a href="http://squarism.com/files/deadgrid">Play It!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2009/07/09/better-tetris-collision-detection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
