<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Fayland and Perl Programming</title>
    <link rel="alternate" type="text/html" href="http://blog.fayland.org/" />
    <link rel="self" type="application/atom+xml" href="http://blog.fayland.org/atom.xml" />
    <id>tag:blog.fayland.org,2011-01-06://2</id>
    <updated>2012-04-26T03:24:51Z</updated>
    
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type 5.04</generator>

<entry>
    <title>MongoDB and Perl</title>
    <link rel="alternate" type="text/html" href="http://blog.fayland.org/2012/04/mongodb-and-perl.html" />
    <id>tag:blog.fayland.org,2012://2.29</id>

    <published>2012-04-26T03:17:16Z</published>
    <updated>2012-04-26T03:24:51Z</updated>

    <summary>it&apos;s really a pain to work with MongoDB in Perl. Perl has no &apos;type&apos; so when you get INT value from DBI, it might be really &quot;1&quot; instead of int 1.I got some data dumped from MySQL to MongoDB and...</summary>
    <author>
        <name>Fayland Lam</name>
        
    </author>
    
    <category term="mongodb" label="MongoDB" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://blog.fayland.org/">
        <![CDATA[it's really a pain to work with MongoDB in Perl. Perl has no 'type' so when you get INT value from DBI, it might be really "1" instead of int 1.<div><br /></div><div>I got some data dumped from MySQL to MongoDB and found all the 'time' field is wrapped as "1335350669" instead of&nbsp;1335350669.</div><div><br /></div><div>and when you insert it from code like { time =&gt; time() }, you really have&nbsp;1335350670 instead of "1335350670". it breaks the sort. it breaks the deletion. it breaks everything.</div><div><br /></div><div>blabla, to fix that, we just need update it in mongodb like below.</div><div><br /></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>PRIMARY&gt; db.jobs.find().forEach(</div><div>&nbsp; &nbsp; function(job) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; job.time = parseInt(job.time);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; db.jobs.save(job);</div><div>&nbsp; &nbsp; });</div></div><div><br /></div></blockquote></div><div>but it's still a pain. I didn't check MongoDBx::Class or&nbsp;Mongoose yet, but Moose's type should be able to fix it I think.</div><div><br /></div><div>Thanks</div>]]>
        
    </content>
</entry>

<entry>
    <title>api and android app</title>
    <link rel="alternate" type="text/html" href="http://blog.fayland.org/2012/04/api-and-android-app.html" />
    <id>tag:blog.fayland.org,2012://2.28</id>

    <published>2012-04-14T12:20:56Z</published>
    <updated>2012-04-14T13:04:01Z</updated>

    <summary>I&apos;m a fan of Android. even I like my iPad and MBP very much too.I&apos;d like to write an App for Android. and here is all the story.first of all, I need write an API which supports JSONP. since it...</summary>
    <author>
        <name>Fayland Lam</name>
        
    </author>
    
    <category term="android" label="Android" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="api" label="API" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="coffeescript" label="coffeescript" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="findmjob" label="findmjob" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="Perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://blog.fayland.org/">
        <![CDATA[I'm a fan of Android. even I like my iPad and MBP very much too.<div><br /></div><div>I'd like to write an App for Android. and here is all the story.</div><div><br /></div><div>first of all, I need write an API which supports JSONP. since it would be very simple, I don't want to mix it up with Dancer. at last, I wrote something based on <a href="https://github.com/stevan/webmachine-perl">webmachine-perl</a>. I like the idea behind the webmachine. the chain design looks pretty nice. even I don't use that too much.</div><div><br /></div><div>the code is at</div><div><br /></div><div><a href="https://github.com/fayland/findmjob.com/blob/master/api/app.psgi">https://github.com/fayland/findmjob.com/blob/master/api/app.psgi</a></div><div><a href="https://github.com/fayland/findmjob.com/blob/master/api/lib/FindmJob/Resource.pm">https://github.com/fayland/findmjob.com/blob/master/api/lib/FindmJob/Resource.pm</a></div><div><br /></div><div>and live demo as</div><div><br /></div><div><a href="http://api.findmjob.com/search?callback=jQuery171016797792096622288_1334322201618&amp;q=perl&amp;loc=&amp;_=1334322214418">http://api.findmjob.com/search?callback=jQuery171016797792096622288_1334322201618&amp;q=perl&amp;loc=&amp;_=1334322214418</a></div><div><br /></div><div>after API is done. now comes the android app part. Sorry that I don't know much about Java. and I failed to download appmobi/jqmobi (the download never ends here). so at last I picked up&nbsp;<a href="http://phonegap.com/">phonegap</a>.</div><div><br /></div><div>the progress went pretty smooth. mixed with jQuery Mobile, I have it out after few hours.</div><div><br /></div><div>you can download it for fun from&nbsp;<a href="http://static.findmjob.com/FindmJob.apk">http://static.findmjob.com/FindmJob.apk</a></div><div>it's pretty simple, just with one JSONP request and not much different than the demo.</div><div><br /></div><div>even there, I'd like to share the code with you:</div><div><br /></div><div><a href="https://github.com/fayland/findmjob.com/blob/master/mobile/android/assets/www/index.html">https://github.com/fayland/findmjob.com/blob/master/mobile/android/assets/www/index.html</a></div><div><a href="https://github.com/fayland/findmjob.com/blob/master/mobile/android/assets/www/mobile.coffee">https://github.com/fayland/findmjob.com/blob/master/mobile/android/assets/www/mobile.coffee</a></div><div><br /></div><div>it's very cool and I'm excited! (badly Google costs 25$ for submitting it and I don't want to do it for now)</div><div><br /></div><div>Thanks.</div><div><br /></div><div><br /></div><div><br /></div>]]>
        
    </content>
</entry>

<entry>
    <title>sphinx search with varchar primary key</title>
    <link rel="alternate" type="text/html" href="http://blog.fayland.org/2012/04/sphinx-search-with-varchar-primary-key.html" />
    <id>tag:blog.fayland.org,2012://2.27</id>

    <published>2012-04-08T01:59:10Z</published>
    <updated>2012-04-08T02:07:22Z</updated>

    <summary><![CDATA[usually when you index the mysql data into sphinx, you'll use id int/bigint for the primary key. but it's broken for me on http://findmjob.com/, we use uuid everywhere for the primary key.here is the solution for it. use&nbsp;@id := @id...]]></summary>
    <author>
        <name>Fayland Lam</name>
        
    </author>
    
    <category term="findmjob" label="findmjob" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="sphinx" label="sphinx" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://blog.fayland.org/">
        <![CDATA[usually when you index the mysql data into sphinx, you'll use id int/bigint for the primary key. but it's broken for me on <a href="http://findmjob.com/">http://findmjob.com/</a>, we use uuid everywhere for the primary key.<div><br /></div><div>here is the solution for it. use&nbsp;@id := @id + 1 for the indexer, and use&nbsp;sql_field_string to get the real id when matched. <a href="https://github.com/fayland/findmjob.com/blob/master/etc/sphinx.conf">sample code</a> below:</div><div><br /></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>sql_query_pre = SET NAMES utf8</div><div>sql_query_pre = SET @id := 1;</div></div><div>sql_query<span class="Apple-tab-span" style="white-space: pre; ">		</span>= \</div><div>&nbsp; &nbsp; SELECT @id := @id + 1 AS tid, id, title, description, location, contact, inserted_at FROM job ORDER BY inserted_at DESC LIMIT 10000</div><div><br /></div><div>sql_field_string = id</div></blockquote><div><br /></div>it requires latest sphinx to support&nbsp;sql_field_string. and the latest CPAN module too.</div><div><br /></div><div>and Perl code for it will be normal like before. and instead you use -&gt;{doc}, you need use the attribtues -&gt;{id} like</div><div><br /></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div>my @jobids = map { $_-&gt;{id} } @{$ret-&gt;{matches}};</div></blockquote><br /></div><div>so now we have sphinx search supports in my new site, eg:&nbsp;<a href="http://findmjob.com/search/Perl.html?q=Perl">http://findmjob.com/search/Perl.html?q=Perl</a></div><div><br /></div><div>Thanks.</div>]]>
        
    </content>
</entry>

<entry>
    <title>DBIx::Class with Moose has</title>
    <link rel="alternate" type="text/html" href="http://blog.fayland.org/2012/04/dbixclass-with-moose-has.html" />
    <id>tag:blog.fayland.org,2012://2.26</id>

    <published>2012-04-04T13:10:22Z</published>
    <updated>2012-04-04T13:25:24Z</updated>

    <summary><![CDATA[well, I don't know how to name it.DBIx::Class is one of my&nbsp;favorite modules. for its structure, with DBIx::Class you can make all your code very well&nbsp;organized and clean. writing code with DBIx::Class means you can use it in framework like...]]></summary>
    <author>
        <name>Fayland Lam</name>
        
    </author>
    
    <category term="dbixclass" label="DBIx::Class" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="findmjob" label="findmjob" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="moose" label="Moose" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://blog.fayland.org/">
        <![CDATA[well, I don't know how to name it.<div><br /></div><div><a href="https://metacpan.org/release/DBIx-Class">DBIx::Class</a> is one of my&nbsp;favorite modules. for its structure, with DBIx::Class you can make all your code very well&nbsp;organized and clean. writing code with DBIx::Class means you can use it in framework like Catalyst or Mojo or Dancer, and you can use it in any perl script (cron usually). for me, DBIx::Class is the right model, TT2 is the right template, and framework is just for URL dispatch.</div><div><br /></div><div><a href="https://metacpan.org/release/Moose">Moose</a> is another module I like. Role, and clean OO.</div><div><br /></div><div>by using&nbsp;DBIx::Class::Schema::Loader&nbsp;make_schema_at, with&nbsp;use_moose =&gt; 1 on (eg:&nbsp;<a href="https://github.com/fayland/findmjob.com/blob/master/script/make_schema_at.pl">https://github.com/fayland/findmjob.com/blob/master/script/make_schema_at.pl</a>), we can generate very clean Result module with Moose.</div><div><br /></div><div>sometimes you want make assessor based on the table column. like for each job in table, we all have a URL which is based on the id and title in the table, it's so related to those two fields, so we'd better to put it in the Result.</div><div>with DBIx::Class, it's very simple. (<a href="https://github.com/fayland/findmjob.com/blob/master/lib/FindmJob/Schema/Result/Job.pm">sample code</a>)</div><div><br /></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>package FindmJob::Schema::Result::Job;</div><div><br /></div><div>....</div><div><br /></div><div>use FindmJob::Utils 'seo_title';</div><div>has 'url' =&gt; ( is =&gt; 'ro', isa =&gt; 'Str', lazy_build =&gt; 1 );</div><div>sub _build_url {</div><div>&nbsp; &nbsp; my ($self) = @_;</div><div><br /></div><div>&nbsp; &nbsp; return "/job/" . $self-&gt;id . "/" . seo_title($self-&gt;title) . ".html";</div><div>}</div></div></blockquote></div><div><br /></div><div>after that, we can always call $job-&gt;url after we -&gt;search for -&gt;find it. very neat. live demo like:&nbsp;</div><div><br /></div><div><a href="http://findmjob.com/job/Il2bUdB74RGuDaqxKQ5yzw/Senior-Perl-Developer.html">http://findmjob.com/job/Il2bUdB74RGuDaqxKQ5yzw/Senior-Perl-Developer.html</a></div><div><br /></div><div>have fun. Thanks</div>]]>
        
    </content>
</entry>

<entry>
    <title>better pagination url design in Dancer</title>
    <link rel="alternate" type="text/html" href="http://blog.fayland.org/2012/04/better-pagination-url-design-in-dancer.html" />
    <id>tag:blog.fayland.org,2012://2.25</id>

    <published>2012-04-02T11:23:18Z</published>
    <updated>2012-04-02T11:32:09Z</updated>

    <summary>usually People do param for pager like ?page=1 or ?p=1, it maybe not that good for search engine because they may not go scrape inside. so we may come out a solution with /page=1/ or /p=1/ or even /p.1/ etc.in...</summary>
    <author>
        <name>Fayland Lam</name>
        
    </author>
    
    <category term="dancer" label="Dancer" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="findmjob" label="findmjob" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://blog.fayland.org/">
        <![CDATA[usually People do param for pager like ?page=1 or ?p=1, it maybe not that good for search engine because they may not go scrape inside. so we may come out a solution with /page=1/ or /p=1/ or even /p.1/ etc.<div><br /></div><div>in <a href="http://search.cpan.org/perldoc?Dancer">Dancer</a>, it's very tricky to do add pagination regex in all URLs. and thank God, we have 'forward' and with code like below, it becomes very simple and easy to use.</div><div><br /></div><div>Perl code:</div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>get qr'.*?/p\.(\d+).*?' =&gt; sub {</div><div>&nbsp; &nbsp; my $uri = request-&gt;uri;</div><div>&nbsp; &nbsp; $uri =~ s'/p\.(\d+)'';</div><div>&nbsp; &nbsp; var page =&gt; $1;</div><div>&nbsp; &nbsp; $uri =~ s/\/$//;</div><div>&nbsp; &nbsp; forward $uri;</div><div>};</div></div><div><br /></div><div><div>get '/' =&gt; sub {</div><div>&nbsp; &nbsp; my $p = vars-&gt;{page} || 1; $p = 1 unless $p =~ /^\d+$/;</div></div></blockquote><br /></div><div>we use regex to get the page stuff, then remove it from the request uri then using <b>forward</b>&nbsp;to do a internal request.</div><div><br /></div><div>the TT2 pager code can check at&nbsp;<a href="https://github.com/fayland/findmjob.com/blob/master/templates/pager.tt">https://github.com/fayland/findmjob.com/blob/master/templates/pager.tt</a></div><div><br /></div><div>live demo as:&nbsp;<a href="http://findmjob.com/tag/perl/">http://findmjob.com/tag/perl</a>/ and&nbsp;<a href="http://findmjob.com/tag/perl/p.2/">http://findmjob.com/tag/perl/p.2/</a></div><div><br /></div><div>have fun.</div>]]>
        
    </content>
</entry>

<entry>
    <title>findmjob.com</title>
    <link rel="alternate" type="text/html" href="http://blog.fayland.org/2012/04/findmjobcom.html" />
    <id>tag:blog.fayland.org,2012://2.24</id>

    <published>2012-04-02T07:35:19Z</published>
    <updated>2012-04-02T07:43:46Z</updated>

    <summary>maybe to earn some money (not for fun this time), I decided to write a new website http://findmjob.com/I sit front of my computer and coded it for 2 days and here is it. it&apos;s out.it&apos;s very simple and without much...</summary>
    <author>
        <name>Fayland Lam</name>
        
    </author>
    
    <category term="findmjob" label="findmjob" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="github" label="github" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://blog.fayland.org/">
        <![CDATA[maybe to earn some money (not for fun this time), I decided to write a new website <a href="http://findmjob.com/">http://findmjob.com/</a><div><br /></div><div>I sit front of my computer and coded it for 2 days and here is it. it's out.<br /><div><br /></div><div>it's very simple and without much stuff yet. and the final goal is undecided. but there it is. I'm very pleased to see it in public.</div><div><br /></div><div>since there is no reason to keep it private, I opened source it in github:&nbsp;<a href="https://github.com/fayland/findmjob.com">https://github.com/fayland/findmjob.com</a></div><div><br /></div><div>for programmer, it's very simple to write website. but it's very hard to make it a success. so suggestions are welcome.</div></div><div><br /></div><div>Thanks.</div>]]>
        
    </content>
</entry>

<entry>
    <title>Net-GitHub-0.43_01</title>
    <link rel="alternate" type="text/html" href="http://blog.fayland.org/2012/03/net-github-043-01.html" />
    <id>tag:blog.fayland.org,2012://2.23</id>

    <published>2012-03-30T12:43:06Z</published>
    <updated>2012-03-30T12:51:34Z</updated>

    <summary>Github is moving on with their API that &quot;We will terminate API v1 and API v2 in 1 month on May 1st, 2012.&quot;.I know lots of people are preferring that they want token instead of writing user/pass in the config...</summary>
    <author>
        <name>Fayland Lam</name>
        
    </author>
    
    <category term="cpan" label="CPAN" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="github" label="github" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://blog.fayland.org/">
        <![CDATA[Github is <a href="https://github.com/blog/1090-github-api-moving-on">moving on with their API</a> that "We will terminate API v1 and API v2 in 1 month on May 1st, 2012.".<div><br /></div><div>I know lots of people are preferring that they want token instead of writing user/pass in the config or code.</div><div>and now we have the choice with create access_token with code instead of web flow.</div><div><br /></div><div>it's time to kick Net::GitHub default to V3 now. so here comes the beta release. and tests/patches are welcome.</div><div><br /></div><div><a href="http://fayland.org/CPAN/Net-GitHub-0.43_01.tar.gz">http://fayland.org/CPAN/Net-GitHub-0.43_01.tar.gz</a>&nbsp;(it will be on CPAN soon too)</div><div><br /></div><div>Tips to create access_token with script:</div><div><br /></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>use Net::GitHub;</div><div>my $gh = Net::GitHub-&gt;new( login =&gt; 'fayland', pass =&gt; 'secret' );</div><div>my $oauth = $gh-&gt;oauth;</div><div>my $o = $oauth-&gt;create_authorization( {</div><div>&nbsp; &nbsp; scopes =&gt; ['user', 'public_repo', 'repo', 'gist'], # just ['public_repo']</div><div>&nbsp; &nbsp; note &nbsp; =&gt; 'test purpose',</div><div>} );</div><div>print $o-&gt;{token};</div></div></blockquote></div><div><br /></div><div>record the token down, and later on we can always use that token without writing down user/pass.</div><div><br /></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>my $github = Net::GitHub-&gt;new(</div><div>&nbsp; &nbsp; access_token =&gt; $token, # from above</div><div>);</div></div><div><br /></div></blockquote>Thanks.</div>]]>
        
    </content>
</entry>

<entry>
    <title>Plack::Middleware::FileWrap</title>
    <link rel="alternate" type="text/html" href="http://blog.fayland.org/2011/12/plackmiddlewarefilewrap.html" />
    <id>tag:blog.fayland.org,2011://2.22</id>

    <published>2011-12-04T08:51:48Z</published>
    <updated>2011-12-04T08:56:28Z</updated>

    <summary>When you really go coding, you&apos;ll meet lots of issues. then you&apos;ll write solution for them. that&apos;s straight.Today I have another CPAN module Plack::Middleware::FileWrap out to fit my demand: I&apos;ll have lots of plain HTML files, they&apos;ll share the same...</summary>
    <author>
        <name>Fayland Lam</name>
        
    </author>
    
    <category term="kindergarden" label="KinderGarden" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="plack" label="Plack" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://blog.fayland.org/">
        <![CDATA[<div>When you really go coding, you'll meet lots of issues. then you'll write solution for them. that's straight.</div><div><br /></div><div>Today I have another CPAN module <a href="http://search.cpan.org/dist/Plack-Middleware-FileWrap/">Plack::Middleware::FileWrap</a> out to fit my demand: I'll have lots of plain HTML files, they'll share the same header/footer and I don't want to use stupid iframe.</div><div><br /></div><div>under Plack, it just means wrap $res-&gt;[2] with file content or strings.&nbsp;</div><div><br /></div><div>so here comes Plack::Middleware::FileWrap, very simple if you looked at the <a href="https://github.com/fayland/Plack-Middleware-FileWrap/blob/master/lib/Plack/Middleware/FileWrap.pm">source code</a>.</div><div><br /></div><div>then I used it in the KinderGarden project, with snippets:</div><div><br /></div><div>&nbsp; &nbsp; mount '/static/docs/' =&gt; builder {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; enable 'FileWrap', headers =&gt; ["$root/static/docs/header.html"], footers =&gt; ["$root/static/docs/footer.html"];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Plack::App::File-&gt;new( root =&gt; "$root/static/docs" )-&gt;to_app;</div><div>&nbsp; &nbsp; },</div><div>&nbsp; &nbsp;&nbsp;</div><div>Live demo as <a href="http://kindergarden.fayland.org/static/docs/TestLocally.html">http://kindergarden.fayland.org/static/docs/TestLocally.html</a></div><div><br /></div><div>now all the files under static/docs will wrapped with header.html and footer.html (header.html/footer.html itself too!)</div><div><br /></div><div>for some advanced example, like if you just want to apply to html files, then you can code something like:</div><div><br /></div><div>&nbsp; &nbsp; mount '/static/docs/' =&gt; builder {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; enable_if { $_[0]-&gt;{PATH_INFO} =~ /\.html/ } 'FileWrap',</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; headers =&gt; ["$root/static/docs/header.html"], footers =&gt; ["$root/static/docs/footer.html"];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Plack::App::File-&gt;new( root =&gt; "$root/static/docs" )-&gt;to_app;</div><div>&nbsp; &nbsp; },</div><div>&nbsp; &nbsp;&nbsp;</div><div>I didn't put the Content-Type check b/c I think it's better to be handled with enable_if.</div><div><br /></div><div>Enjoy. Thanks</div>]]>
        
    </content>
</entry>

<entry>
    <title>git submodule</title>
    <link rel="alternate" type="text/html" href="http://blog.fayland.org/2011/12/git-submodule.html" />
    <id>tag:blog.fayland.org,2011://2.21</id>

    <published>2011-12-03T10:56:57Z</published>
    <updated>2011-12-03T11:30:13Z</updated>

    <summary><![CDATA[When you include another open source in your own project, it's usually pretty hard to keep it up to date. it becomes even more harder if you have some modification on it.recently I have bootstrap&nbsp;in my KinderGarden&nbsp;project, it's very easy...]]></summary>
    <author>
        <name>Fayland Lam</name>
        
    </author>
    
    <category term="git" label="git" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="kindergarden" label="KinderGarden" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://blog.fayland.org/">
        <![CDATA[When you include another open source in your own project, it's usually pretty hard to keep it up to date. it becomes even more harder if you have some modification on it.<div><br /></div><div>recently I have <a href="https://github.com/twitter/bootstrap">bootstrap</a>&nbsp;in my <a href="https://github.com/PerlChina/kindergarden">KinderGarden</a>&nbsp;project, it's very easy to use git submodule to handle it.</div><div><br /></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>kindergarden&gt; git submodule add https://github.com/twitter/bootstrap.git static/bootstrap</div></div><div>kindergarden&gt; git add .gitmodules static/bootstrap</div><div>kindergarden&gt; git commit -a -m "remote bootstrap"</div><div>kindergarden&gt; git push</div><div><div>kindergarden&gt; git submodule init</div></div></blockquote><br /></div><div>in delopy or other machine:</div><div><br /></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>kindergarden$ git submodule init</div><div>kindergarden$ git submodule update</div></div></blockquote><div><br /></div>pretty easy and simple, and the logic behind is simple too. reference as <a href="http://help.github.com/submodules/">http://help.github.com/submodules/</a>&nbsp;or&nbsp;<a href="http://progit.org/book/ch6-6.html">http://progit.org/book/ch6-6.html</a></div><div><br /></div><div>BTW, I added Live.com OAuth2 supports to KinderGarden.</div><div><br /></div><div>Enjoy. Thanks</div>]]>
        
    </content>
</entry>

<entry>
    <title>2011 CN Perl Advent</title>
    <link rel="alternate" type="text/html" href="http://blog.fayland.org/2011/12/2011-cn-perl-advent.html" />
    <id>tag:blog.fayland.org,2011://2.20</id>

    <published>2011-12-01T11:16:26Z</published>
    <updated>2011-12-01T11:17:33Z</updated>

    <summary><![CDATA[Hi, it's time for advent again!and here it is:&nbsp;http://perlchina.github.com/advent.perlchina.org/the repos is at&nbsp;https://github.com/PerlChina/advent.perlchina.orgEnjoy!...]]></summary>
    <author>
        <name>Fayland Lam</name>
        
    </author>
    
    <category term="advent" label="advent" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://blog.fayland.org/">
        <![CDATA[Hi, it's time for advent again!<div><br /></div><div>and here it is:&nbsp;<a href="http://perlchina.github.com/advent.perlchina.org/">http://perlchina.github.com/advent.perlchina.org/</a></div><div><br /></div><div>the repos is at&nbsp;<a href="https://github.com/PerlChina/advent.perlchina.org">https://github.com/PerlChina/advent.perlchina.org</a></div><div><br /></div><div>Enjoy!</div>]]>
        
    </content>
</entry>

<entry>
    <title>KinderGarden</title>
    <link rel="alternate" type="text/html" href="http://blog.fayland.org/2011/11/kindergarden.html" />
    <id>tag:blog.fayland.org,2011://2.19</id>

    <published>2011-11-27T04:43:24Z</published>
    <updated>2011-11-27T04:46:45Z</updated>

    <summary><![CDATA[as talked yesterday, I get it uploaded into github. well, under PerlChina.&nbsp;https://github.com/PerlChina/kindergardenI really want to draw more people to add more features and fix more bugs.and I added one new feature with Mojolicious&nbsp;which is&nbsp;http://kindergarden.fayland.org/app/whereilivefeel free to view the source and...]]></summary>
    <author>
        <name>Fayland Lam</name>
        
    </author>
    
    <category term="kindergarden" label="KinderGarden" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="mojolicious" label="Mojolicious" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perlchina" label="PerlChina" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://blog.fayland.org/">
        <![CDATA[as talked yesterday, I get it uploaded into github. well, under PerlChina.&nbsp;<a href="https://github.com/PerlChina/kindergarden">https://github.com/PerlChina/kindergarden</a><div><br /></div><div>I really want to draw more people to add more features and fix more bugs.</div><div><br /></div><div>and I added one new feature with <a href="http://mojolicio.us/">Mojolicious</a>&nbsp;which is&nbsp;<a href="http://kindergarden.fayland.org/app/whereilive">http://kindergarden.fayland.org/app/whereilive</a></div><div><br /></div><div>feel free to view the source and let me know what you think!</div><div><br /></div><div>Thanks.</div>]]>
        
    </content>
</entry>

<entry>
    <title>Dancer::Template::Xslate</title>
    <link rel="alternate" type="text/html" href="http://blog.fayland.org/2011/11/dancertemplatexslate.html" />
    <id>tag:blog.fayland.org,2011://2.18</id>

    <published>2011-11-26T05:50:34Z</published>
    <updated>2011-11-26T06:10:21Z</updated>

    <summary><![CDATA[I'm writing some toy once again with Plack and Dancer (and Mojo later).this time, I'm playing Plack::Middleware::OAuth and Dancer::Template::Xslate a bit. the website is&nbsp;http://kindergarden.fayland.org/&nbsp;and I'll open source it if someone is interested. for now, it's just 'Login with ...' OAuth...]]></summary>
    <author>
        <name>Fayland Lam</name>
        
    </author>
    
    <category term="dancer" label="dancer" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="Perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="plack" label="Plack" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="xslate" label="Xslate" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://blog.fayland.org/">
        <![CDATA[I'm writing some toy once again with Plack and Dancer (and Mojo later).<div><br /></div><div>this time, I'm playing <a href="http://search.cpan.org/perldoc?Plack::Middleware::OAuth">Plack::Middleware::OAuth</a> and <a href="http://search.cpan.org/perldoc?Dancer::Template::Xslate">Dancer::Template::Xslate</a> a bit. the website is&nbsp;<a href="http://kindergarden.fayland.org/">http://kindergarden.fayland.org/</a>&nbsp;and I'll open source it if someone is interested. for now, it's just 'Login with ...' OAuth and nothing else. (layout is built with&nbsp;<a href="http://twitter.github.com/bootstrap/">twitter bootstrap</a>)</div><div><br /></div><div>the Dancer::Template::Xslate has some bugs and I tried to submit few commits through github to fix it. (at least it's working for me now)</div><div><br /></div><div>here is a tip to add function like&nbsp;gravatar into Xslate within Dancer.</div><div><br /></div><div>problem as <a href="http://search.cpan.org/perldoc?Text::Xslate">Text::Xslate</a> supports <b>function</b> param when -&gt;new but Dancer YAML config can't have Perl code inside. and it's very tricky or hard to fix the engine 'template' b/c we can never modify it. it has 'my $_engine;' inside code and you can't modify it at all.</div><div><br /></div><div>after a while, I find a good solution with the <b>module</b> param of the Text::Xslate. it's very neat. sample code as below:</div><div><br /></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div># config.yml</div><div>template: xslate</div><div>engines:</div><div>&nbsp; xslate:</div><div>&nbsp; &nbsp; syntax: 'TTerse'</div><div>&nbsp; &nbsp; extension: 'tt'</div><div>&nbsp; &nbsp; header:</div><div>&nbsp; &nbsp; &nbsp; - 'layout/header.tt'</div><div>&nbsp; &nbsp; footer:</div><div>&nbsp; &nbsp; &nbsp; - 'layout/footer.tt'</div><div>&nbsp; &nbsp; module:</div><div>&nbsp; &nbsp; &nbsp; - KinderGardenX::Text::Xslate::Bridge::KinderGarden</div></div><div><br /></div><div>#&nbsp;KinderGardenX::Text::Xslate::Bridge::KinderGarden</div><div><div>package KinderGardenX::Text::Xslate::Bridge::KinderGarden;</div><div><br /></div><div>use strict;</div><div>use warnings;</div><div>use parent qw(Text::Xslate::Bridge);</div><div><br /></div><div>use Gravatar::URL;</div><div><br /></div><div>my %funtion_methods = (</div><div>&nbsp; &nbsp; gravatar_url =&gt; \&amp;gravatar_url,</div><div>);</div><div><br /></div><div>__PACKAGE__-&gt;bridge(</div><div>&nbsp; &nbsp; function =&gt; \%funtion_methods,</div><div>);</div><div><br /></div><div>1;</div></div><div><br /></div><div># template</div><div><br /></div><div><div>&nbsp; &nbsp; &lt;img src="[% gravatar_url( email =&gt; user.email, size =&gt; 30) %]" /&gt;</div><div>&nbsp; &nbsp; &lt;img src="[% gravatar_url( email =&gt; user.email, size =&gt; 50) %]" /&gt;</div><div>&nbsp; &nbsp; &lt;img src="[% gravatar_url( email =&gt; user.email) %]" /&gt;</div></div><div><br /></div></blockquote>Note there is always more than one way to do it.&nbsp;</div><div><br /></div><div>Thanks.</div>]]>
        
    </content>
</entry>

<entry>
    <title>new baby</title>
    <link rel="alternate" type="text/html" href="http://blog.fayland.org/2011/11/new-baby.html" />
    <id>tag:blog.fayland.org,2011://2.17</id>

    <published>2011-11-08T11:47:34Z</published>
    <updated>2011-11-08T11:50:24Z</updated>

    <summary>I&apos;m very happy to share the good news with all the world. my second kid, another boy, was born today. 9:45am Beijing Time, Nov 8th, 2011. 2800g. and everything is good. Thanks....</summary>
    <author>
        <name>Fayland Lam</name>
        
    </author>
    
    
    <content type="html" xml:lang="en-us" xml:base="http://blog.fayland.org/">
        I&apos;m very happy to share the good news with all the world. my second kid, another boy, was born today. 9:45am Beijing Time, Nov 8th, 2011. 2800g. and everything is good. Thanks.
        
    </content>
</entry>

<entry>
    <title>remove/add job to crontab by commandline</title>
    <link rel="alternate" type="text/html" href="http://blog.fayland.org/2011/10/removeadd-job-to-crontab-by-commandline.html" />
    <id>tag:blog.fayland.org,2011://2.16</id>

    <published>2011-10-13T03:30:03Z</published>
    <updated>2011-10-13T03:35:55Z</updated>

    <summary><![CDATA[1. add job to crontab(crontab -u fayland -l ; echo "*/5 * * * * perl /home/fayland/test.pl") | crontab -u fayland -2. remove job from crontabcrontab -u fayland -l | grep -v 'perl /home/fayland/test.pl' &nbsp;| crontab -u fayland -3. remove...]]></summary>
    <author>
        <name>Fayland Lam</name>
        
    </author>
    
    <category term="crontab" label="crontab" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="linux" label="linux" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://blog.fayland.org/">
        <![CDATA[1. add job to crontab<div><br /></div><div>(crontab -u fayland -l ; echo "*/5 * * * * perl /home/fayland/test.pl") | crontab -u fayland -</div><div><br /></div><div>2. remove job from crontab</div><div><br /></div><div>crontab -u fayland -l | grep -v 'perl /home/fayland/test.pl' &nbsp;| crontab -u fayland -</div><div><br /></div><div>3. remove all crontab</div><div><br /></div><div>crontab -r</div><div><br /></div><div>nothing is tricky. expect it took me 10 minutes to figure out '-' is the one I want. (- is STDOUT in Linux).</div><div><br /></div><div>Thanks.</div>]]>
        
    </content>
</entry>

<entry>
    <title>sphinx 0.99 bug (attributes count vs fields count)</title>
    <link rel="alternate" type="text/html" href="http://blog.fayland.org/2011/09/sphinx-099-bug-attributes-count-vs-fields-count.html" />
    <id>tag:blog.fayland.org,2011://2.15</id>

    <published>2011-09-29T10:33:00Z</published>
    <updated>2011-09-29T10:39:29Z</updated>

    <summary>when you have 4 columns in sql_query, and you want 3 columns as attributes. you&apos;ll get a failure. 0 size sphinx files.it&apos;s quite annoying, and it cost me almost 4 hours to figure it out. I&apos;m so dumb and so...</summary>
    <author>
        <name>Fayland Lam</name>
        
    </author>
    
    <category term="sphinx" label="sphinx" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://blog.fayland.org/">
        <![CDATA[when you have 4 columns in sql_query, and you want 3 columns as attributes. you'll get a failure. 0 size sphinx files.<div><br /></div><div>it's quite annoying, and it cost me almost 4 hours to figure it out. I'm so dumb and so are you, SPHINX.</div><div><br /></div><div>a simple solution is to add a dumb col in the SELECT of sql_query like</div><div><br /></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div>SELECT id,&nbsp;radians(longitude) as long_radians, radians(latitude) as lat_radians, 'dumb' FROM table</div><div><br /></div></blockquote>OK. actually 'dumb' is dumb because it takes more disk than 'a'.<div><br /></div><div>for a detailed issue description, please check&nbsp;<a href="http://sphinxsearch.com/forum/view.html?id=8345">http://sphinxsearch.com/forum/view.html?id=8345</a></div><div><br /></div><div>Thanks.</div>]]>
        
    </content>
</entry>

</feed>

