<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>
I’m Mustafa Paksoy and I write code for a living. I post assorted items of interest here.



I also take pictures and dabble in Twitter.
</description><title>rapid habits ❧ mustafa paksoy</title><generator>Tumblr (3.0; @paksoy)</generator><link>http://paksoy.net/</link><item><title>Find file, cd to parent directory</title><description>&lt;p&gt;For jumping around in elaborate source trees.&lt;/p&gt;

&lt;p&gt;Usage:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cdto [search root directory] [case insensitive filename]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you just want to search current directory:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cdto [case insensitive filename]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Automatically appends * to search filename.&lt;/p&gt;

&lt;script src="http://gist.github.com/327229.js?file=cdto.sh"&gt;&lt;/script&gt;</description><link>http://paksoy.net/post/437611482</link><guid>http://paksoy.net/post/437611482</guid><pubDate>Tue, 09 Mar 2010 17:48:00 -0500</pubDate><category>bash</category><category>cli</category></item><item><title>Works as intended </title><description>&lt;p&gt;&lt;a href="http://i.seemikecode.com/" title="Remote programming interview tool" target="_blank"&gt;See[Mike]Code&lt;/a&gt; is a nifty tool for conducting remote programming interviews. One of the comments on the site bemoans the potential downsides of asking real programming questions during interviews:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The problem is often with the interview questions, for example:&lt;/p&gt;
  
  &lt;p&gt;“Write a loop that counts from 1 to 10” or “What’s the number after F in hexadecimal?”&lt;/p&gt;
  
  &lt;p&gt;As a web developer who has 5 years experience and build a number of large web applications for satisfied clients, I have never had to do anything with hex and simply would not know the answer in an interview.&lt;/p&gt;
  
  &lt;p&gt;However if I needed to do it in a job I would reference the API’s and be able to answer this in less than 2 minutes….&lt;/p&gt;
  
  &lt;p&gt;— ProgrammerJ&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I don’t doubt that the commenter is a successful web developer, but no amount of API documentation would fix not knowing what hex notation is. Some basic computer science knowledge is required to capably consume technical documentation.&lt;/p&gt;</description><link>http://paksoy.net/post/405136240</link><guid>http://paksoy.net/post/405136240</guid><pubDate>Mon, 22 Feb 2010 11:53:00 -0500</pubDate><category>programming</category><category>interviewing</category></item><item><title>Highcharts: Beautiful Charts in Pure JavaScript</title><description>&lt;a href="http://www.highcharts.com/demo/"&gt;Highcharts: Beautiful Charts in Pure JavaScript&lt;/a&gt;: &lt;p&gt;Beautiful pure JavaScript HTML charts. Doesn’t even use the canvas element from what I can tell, which means better IE support. Also, plenty of DOM nodes to attach even handlers to.&lt;/p&gt;

&lt;p&gt;Spending server cycles to generate raster images of charts is getting silly.&lt;/p&gt;</description><link>http://paksoy.net/post/265201516</link><guid>http://paksoy.net/post/265201516</guid><pubDate>Tue, 01 Dec 2009 14:51:00 -0500</pubDate></item><item><title>Photo</title><description>&lt;img src="http://30.media.tumblr.com/tumblr_kt3vucH9na1qz98l3o1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;</description><link>http://paksoy.net/post/243703247</link><guid>http://paksoy.net/post/243703247</guid><pubDate>Sat, 14 Nov 2009 10:47:00 -0500</pubDate></item><item><title>Honor among developers: self-assessing productivity</title><description>&lt;p&gt;There is a &lt;a href="http://news.ycombinator.com/item?id=901600" title="Hacker news thread:     What we actually know about software development, and why we believe it’s true" target="_blank"&gt;discussion brewing on HN&lt;/a&gt; today about measuring programmer productivity. Reg Braithwaite &lt;a href="http://github.com/raganwald/homoiconic/blob/master/2009-02-12/a_question.md" title="Reg Braithwaite" target="_blank"&gt;chimes in to ask a very pertinent question&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Programmers talk about productivity all the time. They say they’re more productive with static typing or without it. With Ruby or with Java. … It seems every programmer I meet has strong opinions about when they are more productive and when they are not. So, here’s my question:&lt;/p&gt;
  
  &lt;p&gt;How are all these people measuring programmer productivity?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The observation is spot-on. Most developers know exactly what makes them more, or, less productive. They may not be able to assess if something they haven’t used yet will boost their productivity; but of the tools and habits they have tried in the past, they have strong feelings about their current choice.&lt;/p&gt;

&lt;p&gt;In an intangible way, every good developer I’ve met knows when she has had a productive day. It’s mostly a feeling that comes without rational explanation. This intuition is what developers are using when they express their choice for Java or Ruby. They have used both, and they know which &lt;em&gt;felt&lt;/em&gt; right and which did not.&lt;/p&gt;

&lt;p&gt;But there is a catch: you can’t harness this intuition if there are incentives to assess your own productivity too positively. Say, like, an annual performance review that your job depends on. Yet, this isn’t because developers are crooks. Something so intangible like an intuition is susceptible to being skewed for very innocent psychological reasons. 
This is also why a good manager will allow you to freely raise the issue when you haven’t been productive. It’s the only way she can find out why and address the root cause whatever it may be.&lt;/p&gt;

&lt;p&gt;Professional assessment attaches very real consequences to being productive. You can’t let a developer search her own soul about if she should get a raise this year. She would really like to believe she should. However, if you simply want to make your team as productive as possible, let them be honest with you about it (and, by extension with themselves).&lt;/p&gt;</description><link>http://paksoy.net/post/223053466</link><guid>http://paksoy.net/post/223053466</guid><pubDate>Sun, 25 Oct 2009 16:23:00 -0400</pubDate></item><item><title>Push notifications in the age firewalls</title><description>&lt;p&gt;In the world of client-server networking, web browsers are the ultimate clients. They are always sending &lt;code&gt;SYN&lt;/code&gt; packets, but never receiving any. They are always establishing outgoing connections, but never get to listen to any ports.&lt;/p&gt;

&lt;p&gt;Due to the ubiquity of the web, we have built our networks around the need to browse. Most NATs will not let any incoming connection near the private subnet. Similarly, our corporate firewalls cull incoming connections with extreme prejudice. As a result, an outgoing SYN packet on port 80 is the X86 of network connectivity. It’s as portable a networking tool as it gets, but it’s getting kludgier by the minute.&lt;/p&gt;

&lt;p&gt;Polling is a particularly unfortunate result of this outgoing connection based architecture. Take RSS readers: imagine a website that posts 10 new items a day, if you poll this site every 5 minutes, you are wasting your time 97% of the time. Granted, you are getting &lt;code&gt;304 Not Modified&lt;/code&gt; responses without any HTTP response body. But these requests still consume threads, CPU and network resources on the server. At the end of the day we are also only getting 2.5 minutes of average latency, which in computer terms, is not very fast. In short, &lt;a href="http://code.google.com/p/pubsubhubbub/wiki/WhyPollingSucks" title="PubSub Hubbub on why polling sucks" target="_blank"&gt;polling sucks.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://code.google.com/p/pubsubhubbub/" title="PubSub Hubbub Project Homepage" target="_blank"&gt;The PubSub Hubbub protocol&lt;/a&gt; aims to solve this problem by allowing the server to push content to the readers directly. Unfortunately, as explained above, the server cannot establish a connection to a lot of clients out there. You would be able to connect to web based feed readers like Google Reader, because Google understands how to configure a network to allow incoming connections. But the average user either is not permitted to modify their network configuration (office) or don’t know how to do it themselves (home). As cool as PubSub is, it just does not solve the problem at hand.&lt;/p&gt;

&lt;p&gt;Which brings me to the actual solution to the HTTP push problem: long polling. With long polling, instead of promptly responding with a 304, the server lets the connection go idle as long as there is no content to send. The client on the other hand, reinitiates a new request as soon as it gets a response. The server also does not need to allocate threads to each incoming request, a single thread can wait on multiple incoming requests and respond to them as new data becomes available. The client gets an almost immediate notification, the server does not have to waste time handing out 304s. Everybody is happy.&lt;/p&gt;

&lt;p&gt;With that we have implemented yet another version reverse-tunneling to deal with NAT. Honestly, for the near future, we are going to have to fit the square peg of push notification into the round hole of browser acting as a client.&lt;/p&gt;</description><link>http://paksoy.net/post/215597761</link><guid>http://paksoy.net/post/215597761</guid><pubDate>Sat, 17 Oct 2009 12:59:00 -0400</pubDate><category>http</category><category>push</category><category>networking</category></item><item><title>Come on Neo, Ctrl-C sends SIGTERM, not CTRL-X.

(From the...</title><description>&lt;img src="http://27.media.tumblr.com/tumblr_kojzloKRIn1qz98l3o1_500.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Come on Neo, &lt;code&gt;Ctrl-C&lt;/code&gt; sends &lt;a href="http://en.wikipedia.org/wiki/SIGTERM" title="Wikipedia article on SIGTERM" target="_blank"&gt;SIGTERM&lt;/a&gt;, not &lt;code&gt;CTRL-X&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;(From the beginning of first movie of course.)&lt;/p&gt;</description><link>http://paksoy.net/post/165400959</link><guid>http://paksoy.net/post/165400959</guid><pubDate>Mon, 17 Aug 2009 23:41:00 -0400</pubDate></item><item><title>Only Twitter can save us from URL shorteners</title><description>&lt;p&gt;Twitter should make URL shortening moot by allowing a link to be included with each Tweet at a fixed character cost of 5-10 characters.&lt;/p&gt;

&lt;p&gt;Everybody hates URL shorteners. They slow down page loads, can frame your content, steal your PageRank and even &lt;a href="http://www.techcrunch.com/2009/08/09/trim-throws-in-the-towel/" title="TechCrunch article: tr.im throws in the towel" target="_blank"&gt;drop dead without notice&lt;/a&gt; (&lt;a href="http://blog.tr.im/post/160697842/tr-im-resurrected" title="tr.im declares they are back in business" target="_blank"&gt;and come back alive in a similarly suprising fashion&lt;/a&gt;). I mean, even &lt;a href="http://www.codinghorror.com/blog/archives/001276.html" title="Jeff Atwood on URL Shorteners" target="_blank"&gt;Jeff Atwood thinks they are hack&lt;/a&gt;, and he’s a very practical fellow.&lt;/p&gt;

&lt;p&gt;To remedy these issues, some well-intentioned people are putting together &lt;a href="http://code.google.com/p/shortlink/wiki/Specification" target="_blank"&gt;a spec for webmasters to declare their own short URLs&lt;/a&gt;. The thinking goes, other short URL services would first check the target page and use the webmaster specified short URL if one exists. The difficulty of getting URL shorteners to cooperate aside, there is a more fundamental problem here: we should not need short URLs in the first place.&lt;/p&gt;

&lt;p&gt;Let me be more direct: Twitter is the only reason URL shorteners are rearing their collective head again. This, at the end of the day, is simply a design defect. While the 140 character limit is what makes Twitter special, the interaction between this limit and URLs at large has the harmful side-effect of requiring third parties to build applications for the sole-purpose of providing 301 redirects. See above for potential issues with such applications.&lt;/p&gt;

&lt;p&gt;As new usage patterns emerge for their platform, Twitter do a great job improving their API to provide the smooth, seamless experience that their users have come to expect. Even better, their developer community does a great job including such improvements in their apps. This, after all, is exactly what is happening with &lt;a href="http://apiwiki.twitter.com/Twitter-REST-API-Method:-statuses-retweet" title="Twitter's new retweet API" target="_blank"&gt;the Re-tweet API&lt;/a&gt; right now.&lt;/p&gt;

&lt;p&gt;The solution to the URL shortening problem is for Twitter to allow one URL to be included with each Tweet for a negligible character cost (say, 5-10 characters). They could then use their default short URL provider for SMS updates, which do have technical character count limit. More importantly, Twitter could sell the click-through stats of all URLs, shortened or not. Power users of all stripes might be willing to pay for this functionality.&lt;/p&gt;

&lt;p&gt;Any experienced developer can tell you that there are a million ways of implementing any piece of functionality. Some are just better than others. They cause less exposure to bugs, implementation issues, or even attack surface. Sure, you could try to implement &lt;a href="http://www.jcryption.org/" title="jCryption: JavaScript date encryption" target="_blank"&gt;transport-layer encryption with JavaScript&lt;/a&gt; but it’s just &lt;a href="http://news.ycombinator.com/item?id=748430" title="Hacker News discussion thread on jCryption" target="_blank"&gt;not the right place to do it&lt;/a&gt;. Similarly, making long URLs play nice with the character limit is a task best handled within Twitter’s API by Twitter themselves.&lt;/p&gt;</description><link>http://paksoy.net/post/164888805</link><guid>http://paksoy.net/post/164888805</guid><pubDate>Mon, 17 Aug 2009 10:01:00 -0400</pubDate><category>twitter</category><category>web</category><category>opinion</category></item><item><title>How Dropbox saved my command line</title><description>&lt;p&gt;I live in the command line across many Unix-like platforms and networks. I have two Mac laptops, two Linux workstations, shell logins scattered across the multiverse, and even a couple Windows VMs to boot. I’ve tried versioning my shell configuration files, but that requires me to check in/check out my changes across all environments. This turned out to be less than ideal. More manual effort, more hassle.&lt;/p&gt;

&lt;p&gt;Enter &lt;a href="http://www.getdropbox.com" target="_blank"&gt;Dropbox&lt;/a&gt; that syncs the files across multiple machines seamlessly and even gives you a bit of revision history. I concocted a system on top of Dropbox that allows me to have global, per OS, and per machine shell configs. For example, here are all the Bash config files I keep in sync via Dropbox (machine names changed to protect the innocent):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ls ~/Dropbox/shell/bash
bashbootstrap  bashrc
bashrc-Darwin  bashrc-Darwin-laptopname  bashrc-Darwin-mininame
bashrc-Linux  bashrc-Linux-machineone  bashrc-Linux-machinetwo
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Let’s ignore the &lt;code&gt;bashbootstrap&lt;/code&gt; file for the moment. You will notice that we have a globally-applied config file, &lt;code&gt;bashrc&lt;/code&gt;, two OS specific config files, &lt;code&gt;bashrc-Linux&lt;/code&gt;, &lt;code&gt;bashrc-Darwin&lt;/code&gt;, and several machine specific ones. (By the way, Darwin is the name of OS X’s BSD-like kernel.)&lt;/p&gt;

&lt;p&gt;What ties it all together is the &lt;code&gt;bashbootstrap&lt;/code&gt; file. It loads each applicable config file in order of increasing specificity, this allows per OS and per machine overrides to have higher precedence. Additionally, we silently skip missing config files; you need not create empty config files for each of your machines to keep the script happy.&lt;/p&gt;

&lt;p&gt;On a new machine, after installing Dropbox on &lt;code&gt;~/Dropbox&lt;/code&gt;, I move away the default &lt;code&gt;.bashrc&lt;/code&gt; and just symlink the bootstrap file in its place instead:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mv ~/.bashrc ~/.bashrc.bak
$ ln -s ~/Dropbox/shell/bash/bashbootstrap  ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Oh, and here are the contents of the &lt;code&gt;bashbootstrap&lt;/code&gt; file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;if [ -z "$PS1" ]; then
   return
fi

dropboxshelldir=~/Dropbox/shell
dropboxdir=$dropboxshelldir/bash
masterbashrc=$dropboxdir/bashrc
osbashrc=$masterbashrc-`uname`
localbashrc=$osbashrc-`hostname | cut -d. -f1`

echo -n "Applicable shell configs: "
for bashfile in "$masterbashrc" "$osbashrc" "$localbashrc"; do
  if [ -r $bashfile ]; then
    . $bashfile
    echo -n "`basename $bashfile` "
  fi
done
echo

# Set convenience aliases
myed=${VISUAL:-${EDITOR:-vim}}
alias editbashrc="$myed $masterbashrc"
alias editosbashrc="$myed $osbashrc"
alias editlocalbashrc="$myed $localbashrc"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;One final note, this script also provides three convenience aliases for editing your Bash config files without having to remember where they are stored.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;editbashrc&lt;/code&gt;:&lt;/strong&gt; Edit the global config file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;editosbashrc&lt;/code&gt;:&lt;/strong&gt; Edit the OS-specific config file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;editlocalbashrc&lt;/code&gt;:&lt;/strong&gt; Edit the machine-specific config file.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I only tested this on Bash, but it could work on other Bash like shells. But, as they say, your mileage may vary.&lt;/p&gt;

&lt;p&gt;Did I mention that if you &lt;a href="https://www.getdropbox.com/referrals/NTY0Mjg3NDk" title="Dropbox referral signup" target="_blank"&gt;sign up to Dropbox with my referral&lt;/a&gt; we both get 250 megs of additional storage? Neat!&lt;/p&gt;</description><link>http://paksoy.net/post/159917345</link><guid>http://paksoy.net/post/159917345</guid><pubDate>Mon, 10 Aug 2009 13:32:28 -0400</pubDate><category>bash</category><category>dropbox</category><category>howto</category></item><item><title>The poor man’s Bash Tab-completion</title><description>&lt;p&gt;Bash has a built-in tab completion utility that sports an impressive array features and the ability to generate suggestions using complex logic. But what if you just want to add a static list of suggestions to a command? It took a little digging around the &lt;a href="http://www.gnu.org/software/bash/manual/bashref.html#Programmable-Completion" title="Bash Manual: Programmable Completion" target="_blank"&gt;Bash manual&lt;/a&gt; but I finally found the magic words you need to add to you &lt;code&gt;.bashrc&lt;/code&gt; file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;complete -o default -W "list of space separated words" [command]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Obviously, you need to replace &lt;code&gt;list of space separated words&lt;/code&gt; and &lt;code&gt;[command]&lt;/code&gt; with values of your choice.  For the curious, let’s take this command apart and see what’s going on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;complete&lt;/strong&gt;: Built in Bash command for controlling built-in tab completion behavior&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;-o default&lt;/strong&gt;: Tell Bash to fall back on the default filename completion if no matches are found.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;-W “list of space separated words”&lt;/strong&gt;: This is where the magic happens. &lt;code&gt;-W&lt;/code&gt; allows us to just provide a static list of suggestions. There are other flags that will dynamically evaluate suggestions at runtime, but we’ll leave that to a future post.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;[command]&lt;/strong&gt;: The command that tab-completion will apply to.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Say I want to just add the suggestions “all” and “clean” to the command &lt;code&gt;make&lt;/code&gt;. The line I need to append to my &lt;code&gt;.bashrc&lt;/code&gt; becomes:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;complete -o default -W "all clean" make
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Bonus: get a little dynamic&lt;/h2&gt;

&lt;p&gt;Using &lt;a href="http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_04.html#sect_03_04_04" title="Bash manual on command substitution" target="_blank"&gt;command substitution&lt;/a&gt;
we can also generate the list of suggestions at Bash start time. This is very useful for completing names that can be found in other configuration files (like, say, &lt;a href="http://www.commandlinefu.com/commands/view/2759/ssh-autocomplete" title="Command-line Fu discussion about SSH auto-completion" target="_blank"&gt;SSH host-name completion&lt;/a&gt;).&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;complete -o default -W "`echo $(cat /path/to/file | grep 'lines i want')`" \
    [command]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(You might notice that we are using command substitution twice in the example above, once with back-ticks the other time using &lt;code&gt;$(command)&lt;/code&gt;. This is necessary because the &lt;code&gt;-W&lt;/code&gt; argument does not accept new-line characters as delimiters. &lt;code&gt;echo&lt;/code&gt;ing will convert these new-lines in to spaces.)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Update:&lt;/em&gt; The friendly folks over at &lt;a href="http://news.ycombinator.com/item?id=751068" title="Hacker News discussion thread on this post" target="_blank"&gt;HN&lt;/a&gt; have pointed out that there non-stupid ways of putting together the aforementioned command substitution. Thanks for the correction folks! Here’s a better way to do it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;complete -o default -W "$(grep 'lines i want' /path/to/file | tr '\n' ' ')" \
    [command]
&lt;/code&gt;&lt;/pre&gt;</description><link>http://paksoy.net/post/158766842</link><guid>http://paksoy.net/post/158766842</guid><pubDate>Sat, 08 Aug 2009 18:14:00 -0400</pubDate><category>bash</category><category>cli</category><category>howto</category></item><item><title>Add ellipses (…) to overflowing text content</title><description>&lt;a href="http://msdn.microsoft.com/en-us/library/ms531174(VS.85).aspx"&gt;Add ellipses (…) to overflowing text content&lt;/a&gt;: &lt;p&gt;This is one of those rare moments when IE has a neat bit of CSS functionality that other browsers don’t have. Sure you could try emulating this behavior in other browsers with the &lt;code&gt;onoverflow&lt;/code&gt; event handler, but it would be a hackish and fragile implementation.&lt;/p&gt;

&lt;p&gt;Minimalist standards documents aside, some pieces of functionality are best supported by the browser, like &lt;code&gt;contentEditable&lt;/code&gt;.&lt;/p&gt;</description><link>http://paksoy.net/post/83613054</link><guid>http://paksoy.net/post/83613054</guid><pubDate>Wed, 04 Mar 2009 19:32:00 -0500</pubDate><category>web development</category><category>css</category><category>internet explorer</category></item><item><title>"Participants seeking to dodge troubles [related to derivatives] face the same problem as someone..."</title><description>“Participants seeking to dodge troubles [related to derivatives] face the same problem as someone seeking to avoid venereal disease. It’s not just whom you sleep with, but also whom they are sleeping with.”&lt;br/&gt;&lt;br/&gt; - &lt;em&gt;Warren Buffet as quoted in the &lt;a href="http://www.nytimes.com/2009/03/01/business/01buffett.html" target="_blank"&gt;NY Times&lt;/a&gt;.&lt;/em&gt;</description><link>http://paksoy.net/post/82384805</link><guid>http://paksoy.net/post/82384805</guid><pubDate>Sat, 28 Feb 2009 19:25:03 -0500</pubDate></item><item><title>Sita Sings the Blues</title><description>&lt;a href="http://www.thirteen.org/sites/reel13/indies/indie-sita-sings-the-blues/241/"&gt;Sita Sings the Blues&lt;/a&gt;: &lt;p&gt;Lovely animated film about &lt;a href="http://en.wikipedia.org/wiki/Ramayana" target="_blank"&gt;Ramayana&lt;/a&gt; by Nina Paley, the complete thing is available online for free. via &lt;a href="http://www.kottke.org/09/02/sita-sings-the-blues" target="_blank"&gt;kottke.org&lt;/a&gt;.&lt;/p&gt;</description><link>http://paksoy.net/post/82214354</link><guid>http://paksoy.net/post/82214354</guid><pubDate>Sat, 28 Feb 2009 02:07:00 -0500</pubDate></item><item><title>Add your favorite editors to the Mac Finder</title><description>&lt;a href="http://www.shinyfrog.net/en/finder-droplets-for-mac-editors"&gt;Add your favorite editors to the Mac Finder&lt;/a&gt;: &lt;p&gt;I confess, I still use Vim for most of my text editing.&lt;/p&gt;</description><link>http://paksoy.net/post/75067969</link><guid>http://paksoy.net/post/75067969</guid><pubDate>Mon, 02 Feb 2009 11:42:00 -0500</pubDate><category>tips</category><category>vim</category><category>os x</category></item><item><title>Background meet foreground.</title><description>&lt;img src="http://26.media.tumblr.com/j0XRBhsnbdykfqjrrx5OovEzo1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Background meet foreground.&lt;/p&gt;</description><link>http://paksoy.net/post/50451891</link><guid>http://paksoy.net/post/50451891</guid><pubDate>Tue, 16 Sep 2008 17:12:26 -0400</pubDate></item><item><title>Public interfaces and incremental improvement</title><description>&lt;p&gt;Facebook just came out with their new layout. From what I’ve seen on the internets, most people &lt;a href="http://www.coedmagazine.com/entertainment/13142" target="_blank"&gt;hate it&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I’m not a very heavy Facebook user, so maybe I’m not hitting all the use-cases that my fellow internet citizens are hitting. The only problem I can see with the new layout is that “info” and “wall” now live in separate tabs. Even this is pretty acceptable for me. The wall and info sections of a profile usually work separately, so not having the context of one while using the other is not cumbersome.&lt;/p&gt;

&lt;p&gt;If I had to guess (and I do), I’d say that they are trying to “solve” profiles with too many apps installed. There’s simply no way that 10 independently developed applications can live on a single page harmoniously. The page becomes too busy with all the &lt;s&gt;useles&lt;/s&gt;different apps competing for screen real estate. By creating a tab for each app, sane Facebook users can install more apps without worrying about their MySpace tendencies shining through. To put it another way, with a fixed amount of profile screen real-estate, the benefit of adding a new app diminishes with each installation. With the new layout, you get more screen space as you install apps, and they can be as useful as they can possibly be.&lt;/p&gt;

&lt;p&gt;Which brings me to what I really wanted to say: once an interface (UI or API) is public, anything short of opt-in incremental changes are going to cause public uproar. This is regardless of the benefits, the change itself is most burdensome for the users.&lt;/p&gt;</description><link>http://paksoy.net/post/50111900</link><guid>http://paksoy.net/post/50111900</guid><pubDate>Sun, 14 Sep 2008 10:28:00 -0400</pubDate></item><item><title>Log analysis with MySQL</title><description>&lt;p&gt;Digging through log files has got to be the least-sexy aspect of web app development. I’ve found that using MySQL makes this process a little less painful and easier to standardize. At the very least, you don’t end up with 5 perl scripts every time you try to analyze a particular piece of data that you can never reuse. Here’s the workflow that I’ve found to work well for me:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Grab logs with your preferred method (&lt;code&gt;scp&lt;/code&gt;, &lt;code&gt;wget&lt;/code&gt;, &lt;code&gt;curl&lt;/code&gt; you name it)&lt;/li&gt;
&lt;li&gt;Select the columns you want out of the log file using &lt;code&gt;cut&lt;/code&gt;. If your input is not Tab-delimited, you will have to specify your delimiter with &lt;code&gt;-d&lt;/code&gt; and override your output delimiter with &lt;code&gt;--output-delimiter="\t"&lt;/code&gt;. For example, to select the first and third columns out of a CSV file: &lt;code&gt;cut -d, -f1,3 --output-delimiter="\t"&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Create a new MySQL table that has a column per log line column. For example: `mysql -e “create table pageviews (page varchar(32), cputime int)” logs&lt;/li&gt;
&lt;li&gt;Import the data from the text file:&lt;code&gt;mysqlimport --local pageviews.txt&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;Please note:&lt;/em&gt; the table that you are importing into needs to have the same name as the text file. So if the file is called &lt;code&gt;httperrors.txt&lt;/code&gt; your MySQL table needs to be called &lt;code&gt;httperrors&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That’s about it. Now you can use familiar SQL to run any analysis on your data that you want.&lt;/p&gt;

&lt;p&gt;For example:
    SELECT page, COUNT(1) FROM log WHERE cputime &gt; 500 GROUP BY page ORDER BY 2 DESC;&lt;/p&gt;

&lt;p&gt;That will give me all the requests that took longer than 500 ms of CPU time broken down by page in my app. As simple as that.&lt;/p&gt;

&lt;p&gt;How is that for data warehousing?&lt;/p&gt;</description><link>http://paksoy.net/post/44215168</link><guid>http://paksoy.net/post/44215168</guid><pubDate>Mon, 11 Aug 2008 18:37:00 -0400</pubDate><category>howto</category><category>mysql</category></item><item><title>Lego fun snacks</title><description>&lt;a href="http://penny-arcade.com/2008/6/18/amazing/"&gt;Lego fun snacks&lt;/a&gt;</description><link>http://paksoy.net/post/39431012</link><guid>http://paksoy.net/post/39431012</guid><pubDate>Sun, 22 Jun 2008 17:58:42 -0400</pubDate></item><item><title>Let me enumerate the times…</title><description>&lt;p&gt;
Sometimes you have to iterate over a collection and count the steps you’ve taken. For example, let’s write a really simple function that returns the index of the leftmost occurrence of a given character in the given string.
&lt;/p&gt;
&lt;pre&gt;
def indexof(str, char):
  i = 0
  for c in str:
    if c == char:
      return i
    i += 1
  return -1
&lt;/pre&gt;

&lt;p&gt;
Or, we could write it as:
&lt;/p&gt;
&lt;pre&gt;
def indexof(str, char):
  for i in range(len(str)):
    if str[i] == char:
      return i
  return -1
&lt;/pre&gt;

&lt;p&gt;
The second one looks a little bit better. Still, I wish we could write the loop
so that the &lt;code&gt;for&lt;/code&gt; statement (i.e. the first line of the loop) expresses
all aspects of the iteration. In other words, if we are both stepping over the
string and incrementing a counter, it is best if they
happen simultaneously each time we step through the loop.
&lt;/p&gt;
&lt;p&gt;
Turns out it’s not uncommon to need a counter variable while iterating over the
elements of some collection. So Python has a builtin function specifically for
this  purpose: &lt;code&gt;enumerate&lt;/code&gt; (new in Python 2.3). At each iteration
it returns a 2-tuple of &lt;code&gt;(counter, object)&lt;/code&gt;. So our &lt;code&gt;indexof&lt;/code&gt;
becomes:
&lt;/p&gt;
&lt;pre&gt;
def indexof(str, char):
  for index, curchar in enumerate(str):
    if curchar == char:
      return index
  return -1
&lt;/pre&gt;

&lt;p&gt;
Now we don’t have to clumsily
declare a counter variable and increment it manually.  Our final
implementation also works with generators and unindexable
collections that we cannot subscript (i.e. do
&lt;code&gt;collection[index]&lt;/code&gt;).
&lt;/p&gt;</description><link>http://paksoy.net/post/35897567</link><guid>http://paksoy.net/post/35897567</guid><pubDate>Sat, 24 May 2008 09:06:00 -0400</pubDate></item><item><title>Is it OK to remove code you don't understand?</title><description>&lt;p&gt;
&lt;strong&gt;No.&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Should be obvious but we all do it. People are merciless (or, dare I say, reckless) when trimming Other People’s Code. I was reminded of this fact by a recently well publicized occurrence of let’s-just-remove-the-line-that-warns.
&lt;/p&gt;
&lt;p&gt;
First of all let me just say, yes, you should always check your warnings. They are great for catching your own suboptimal programming practices. And in languages like C where there aren’t almost any foot-shooting prevention mechanisms built into the language, compiler warnings are a godsend (people invented &lt;a href="http://en.wikipedia.org/wiki/Lint_%28software%29" target="_blank"&gt;&lt;code&gt;lint&lt;/code&gt;&lt;/a&gt; for a reason). So it’s no surprise many programmers get indoctrinated at an early age not to ignore compiler/debugger warnings.
&lt;/p&gt;
&lt;p&gt;
Unfortunately, sometimes one gets a little overzealous and removes a line, say, that makes a random number generator, um, random.
Apparently such &lt;a href="http://xkcd.com/424/" target="_blank"&gt;a line of code&lt;/a&gt; in the Debian SSL library was generating warnings and had to be &lt;a href="http://metasploit.com/users/hdm/tools/debian-openssl/" target="_blank"&gt;silenced with prejudice&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
So let this be my plea to the code-literate masses:
“Do not remove code you don’t understand.”
&lt;/p&gt;</description><link>http://paksoy.net/post/35112344</link><guid>http://paksoy.net/post/35112344</guid><pubDate>Wed, 21 May 2008 16:44:23 -0400</pubDate></item></channel></rss>
