<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>milewide</title>
 <link href="http://hamant.net/atom.xml" rel="self"/>
 <link href="http://hamant.net/"/>
 <updated>2013-08-15T01:54:46-04:00</updated>
 <id>http://hamant.net/</id>
 <author>
   <name>Chris Hamant</name>
   <email>chris@hamant.net</email>
 </author>

 
 <entry>
   <title>Significant Whitespace Has Made Me An Ass</title>
   <link href="http://hamant.net/2011/11/23/whitespace-makes-me-an-ass/"/>
   <updated>2011-11-23T00:00:00-05:00</updated>
   <id>http://hamant.net/2011/11/23/whitespace-makes-me-an-ass</id>
   <content type="html">&lt;h1 id=&quot;significant-whitespace-has-made-me-an-asshole&quot;&gt;Significant Whitespace has made me an asshole&lt;/h1&gt;

&lt;p&gt;I’ve been programming for a good period of my life and had exposure to a whole variety of different programming languages and styles of coding. It started with simple stuff such as Basic, Logo et al - and through the years I’ve had exposure to the whole slew of mainstream *nix scripting languages (Perl, Python, Ruby, PHP) and systems languages (C,C++,C#,Java). Lately I’ve found myself in a position where I work primarily alone doing prototyping using HTML, CSS, and Javascript (with sprinkled with various ‘backend’ tools). So I feel pretty comfortable reading code written in whole variety of paradigms and styles…&lt;/p&gt;

&lt;p&gt;However, in the last couple years I’ve been doing quite a bit more python than ever before along with using various tools that cross-compile to html, javascript and css (Haml, SASS,Jade, SCSS, Stylus, Coffeescript et al). I recently realized that I pretty much have surrounded myself with a set of tools that require me to author code in a fashion where whitespace means something… &lt;/p&gt;

&lt;p&gt;Python is widely regarded for it’s ‘readability’ - some of which is attributed to its syntax surely, but I think a large part of it is due to the requirements of the interpreter on consistent whitespace. Classes, functions and nearly everything is always well formatted - as enforced by the interpreter.&lt;/p&gt;

&lt;p&gt;Haml and Jade (and their ilk) have allowed me to strip away the unnecessary visual distractions from authoring HTML, allowing me to focus solely on the hierarchy, structure and semantics of the HTML tree itself. Sass/Scss/Stylus/Less are the perfect compliment to such HTML authoring tools as I’m already cleanly utilizing the selectors when authoring the Haml/Jade. These CSS tools don’t necessarily always require adherence to whitespace utilization, but the hierarchy does mean something and one will typically keep things nicely nested and indented out of habit (at least I do).&lt;/p&gt;

&lt;h2 id=&quot;the-problem&quot;&gt;The Problem&lt;/h2&gt;

&lt;p&gt;Because of my own little self-inflicted bubble when I need to collaborate with other people - most of whom aren’t aware of such toolings, nor can the be expected to considering it isn’t what they typically do - I’m constantly reformatting other people’s code to fit my worldview… It is somewhat of a compulsion that I can’t help.
When I’m handed a complex set php/jsp pages - something even the author will readily admit is spaghetti - its almost as if my brain can’t even make heads or tails of it anymore. It is almost as if I’ve lost the ability to understand or read this code anymore. The compulsion to refactor and reformat is greater than my need to “get the shit done”.&lt;/p&gt;

&lt;p&gt;It’s almost as if significant whitespace has made me an asshole… I leave on the display of whitespace characters in every editor I use and freak out when someone checks in code that violates whatever convention the rest of the file uses (whatever that may be).&lt;/p&gt;

&lt;p&gt;OCD is a bitch.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Getting Your Black Belt In 30 Years</title>
   <link href="http://hamant.net/2011/05/27/black-belt-30yrs/"/>
   <updated>2011-05-27T00:00:00-04:00</updated>
   <id>http://hamant.net/2011/05/27/black-belt-30yrs</id>
   <content type="html">&lt;p&gt;I have many interests, hobbies and desires. I guess many would view this as the classic “Jack of All Trades — Master of None” type thing… I’d like it if I had the time to master all them. This is a real struggle for me; One seems to have to whittle down the set of interests into things that either bring financial rewards, maybe the few of the things bring the most personal pleasure and focus on those if one hopes to gain any real or deep knowledge on anything.&lt;/p&gt;

&lt;p&gt;I was browsing the internets today (same thing we do every day Pinky) and came across this &lt;a href=&quot;http://norvig.com/chomsky.html&quot;&gt;amazing article&lt;/a&gt; by &lt;a href=&quot;http://en.wikipedia.org/wiki/Peter_Norvig&quot;&gt;Peter Norvig&lt;/a&gt;. However, it wasn’t that article that spoke to me today… I was reminded of (and reread) &lt;a href=&quot;http://norvig.com/21-days.html&quot;&gt;this older article&lt;/a&gt;. After some time I now realize how very true this is… I would say that I have a surface level knowledge of many things (deep enough to fool many non-experts anyway) — but feel I’ve mastered very little. Maybe even nothing? &lt;em&gt;These things take time&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;One of my hobbies are practicing the martial arts. I enjoy all the physical and mental aspects of training. When I first started training as a teen (and off and on many years to follow) I really focused hard on the getting the next kyu rank/ the next belt. But due to other obligations, I’ve not been able to train as hard as I should and it’s taken me a very long to get the coveted “Black Belt”. Somewhere along the way though — my intentions and reasons to train really changed. Even before I reached this “milestone” I realized that this is just step — not and endpoint. I haven’t really “mastered” anything… I’ll probably train the rest of my life and never feel as competent and fluid with my movement as I wish I could be.　&lt;em&gt;All I can do is keep going (頑張って)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;As well, growing up as a child, I had the impression that all the adults and parents around me had all of their shit together. They had their purpose and knew their place in life. Having been a parent for a decade now with children creeping up on their teens I now realize just how hard everyone fakes it. There is wisdom and experience with age sure, but I feel that we’re all kind of limping along in life without completely having a clue as to why. Everyone has their ideas and theories sure… but I wouldn’t say that I truly “have my shit together” — nor have I met another person void of their own set of problems and issues they are working through. &lt;em&gt;All I can do is keep going&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;So it is with my education. I was a bit late starting higher my higher education… but when I finally did I dove in headfirst. I actually felt kind of disappointed when I graduated and got a diploma. I thought to myself, “This is it? — There is still so much to learn…” Not that I expected to learn all there is to know in school, more that I was overwhelmed by the realization of just how much that I don’t (and possibly will never) know. In a notebook next to a drawing of his, Michelangelo wrote the words &lt;em&gt;Ancora Imparo&lt;/em&gt; — loosely: &lt;em&gt;Yet I am (still) learning&lt;/em&gt; — I’m surely never be at the level Michelangelo was at as an artist in anything I do, however, &lt;em&gt;All I can do is keep learning&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;It is all just a bit humbling I guess.&lt;/p&gt;

&lt;p&gt;Maybe I don’t have to worry so much about learning everything there is to know in life. I’ll probably continue to try advancing my understanding on many fronts (just my nature) but I guess in the end I just hope to be a better person… Hopefully to gain some insight into how/why I exist in this crazy world. Happiness even?&lt;/p&gt;

&lt;p&gt;To me it comes down to these two things. 頑張って — and never cease to learn new things…&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>SSH Port Forwarding Tricks</title>
   <link href="http://hamant.net/2011/05/09/ssh-tricks/"/>
   <updated>2011-05-09T00:00:00-04:00</updated>
   <id>http://hamant.net/2011/05/09/ssh-tricks</id>
   <content type="html">&lt;h2 class=&quot;subtitle&quot; id=&quot;that-probably-violate-your-companys-security-policy&quot;&gt;…that probably violate your company’s security policy&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://www.openssh.com/&quot;&gt;SSH&lt;/a&gt; is a very powerful tool that replaces the &lt;em&gt;beleaguered&lt;/em&gt; (excellent word) telnet, rlogin and rsh family of tools (Don’t know what these are? &lt;a href=&quot;http://lmgtfy.com/?q=telnet&quot;&gt;here&lt;/a&gt;). There are thousands of guides, HOWTOs, books, and wikis on which to find information about SSH.&lt;/p&gt;

&lt;p&gt;Here are a few useful tips (that I always find useful) consolidated for your pleasure.&lt;/p&gt;

&lt;h2 id=&quot;port-forwarding&quot;&gt;Port Forwarding&lt;/h2&gt;

&lt;p&gt;Sometimes you need to access to a service or TCP port on a host you might not have direct access to, or it is behind a firewall of some kind.&lt;/p&gt;

&lt;h3 id=&quot;access-service-behind-firewall-on-remote-host&quot;&gt;Access service behind firewall on remote host&lt;/h3&gt;

&lt;p&gt;For example, say you are running MongoDB - but have the port it is listening to blocked by local firewall (good idea). Your firewall is blocking everything but ports 80,443, and 22 (or another port you configured  SSH to listen on (another good idea)). How can you access your mongo instance? You could just ssh into the box itself and run your commands locally… but that isn’t any fun. Mongodb listens by default on port 27017 - because of your firewall rules this port is only accessible from the ‘l0’ localhost interface (again- good idea). Assuming you have shell access on this remote machine, you could do something like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ssh -L 4321:localhost:27017 username@yourmongodb.host
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;What this command does is forward and requests made to &lt;code&gt;localhost port#4321&lt;/code&gt; to &lt;code&gt;port#27017&lt;/code&gt; on &lt;code&gt;yourmongodb.host&lt;/code&gt;. Note that in this case the ‘localhost’ is referring to the remote ‘localhost’ not your ‘localhost’. This distinction is highlighted in the next example.&lt;/p&gt;

&lt;h3 id=&quot;access-a-service-through-the-remote-host&quot;&gt;Access a service ‘through’ the remote host&lt;/h3&gt;

&lt;p&gt;Another example. Say you really really can’t wait for the new &lt;a href=&quot;http://www.bbc.co.uk/doctorwho/dw&quot;&gt;Dr. Who&lt;/a&gt; to air on delay on BBC America and you happen to have access to a machine located somewhere in the UK… My lawyers inform me that I should probably put disclaimer stating that I’m not advocating you bypass any geographical restrictions they place on their content - just an example.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ssh -L 4321:bbc.co.uk:80 username@yourmachine.com
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This creates a tunnel from your local machine (port 4321) through &lt;code&gt;yourmachine.com&lt;/code&gt; to &lt;code&gt;bbc.co.uk&lt;/code&gt; (port 80). So if you make a request to &lt;code&gt;localhost:4321&lt;/code&gt; this will be tunneled to &lt;code&gt;bbc.co.uk&lt;/code&gt;. The host &lt;code&gt;bbc.co.uk&lt;/code&gt; will see the request as if it originated from &lt;code&gt;yourmachine.com&lt;/code&gt; not your actual IP address. (note that due to way streaming work - this likely will not actually work to stream video from the BBC, although you might want to see &lt;code&gt;-D&lt;/code&gt; below for other alternatives)&lt;/p&gt;

&lt;h3 id=&quot;reverse-port-forwarding&quot;&gt;Reverse port forwarding&lt;/h3&gt;

&lt;p&gt;This application is very similar to the above mentioned port forwarding exercises, but works in reverse.
For example, you have something running on site.com (which you can access via ssh) - but for some reason want to forward a service running on your local machine (web server on port 80 in this case). &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ssh -R 80:localhost:4321 user@site.com
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can now access http://site.com:4321 and see the webserver running on your machine’s port 80. (actually this won’t work, a little more work is involved as the remote site will only forward this from localhost by default, not all network interfaces, &lt;a href=&quot;http://www.openbsd.org/cgi-bin/man.cgi?query=ssh&quot;&gt;rtfm&lt;/a&gt; - good for example though). Note that like -L, one could also use this in conjunction with yet another host.&lt;/p&gt;

&lt;h2 id=&quot;socks-proxies&quot;&gt;SOCKS Proxies&lt;/h2&gt;

&lt;p&gt;SSH also has a built-in socks5 proxy server.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ssh -D 4321 username@yourmachine.com
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Will create a SOCKS5 proxy on localhost port #4321. This allows you to enter into your browser’s (or whole machine’s) proxy settings and point your OS’s (or browser’s) SOCKS proxy to localhost. This is useful for a variety of reasons… Similar to the ‘Access a service through remote host’ use case above - but on a broader scope as all requests will be forwarded through the remote host. This is also very good for protecting yourself at coffee shops and public wifi access points. Setup a server listening for SSH connections on port 443 (rare to find this blocked - and one would have to use &lt;a href=&quot;http://en.wikipedia.org/wiki/Deep_packet_inspection&quot;&gt;deep packet inspection&lt;/a&gt; to disambiguate the traffic) and you have the ability to create your own SOCKs proxy at will to help mitigate the threats of public wifi — or is it just me that worries? I recommend setting up a &lt;a href=&quot;http://www.linode.com/?r=f62b30ace9d03e44b746a44c0aff0ca7740bda77&quot; title=&quot;note the blantant plugging of referral code&quot;&gt;linode&lt;/a&gt; just for that purpose.&lt;/p&gt;

&lt;p&gt;All of these can be used in various combinations to bend TCP ports to your will.&lt;/p&gt;

&lt;p&gt;Hope somebody finds it useful…&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Hello World v3.0</title>
   <link href="http://hamant.net/2011/04/29/hello-worldv30/"/>
   <updated>2011-04-29T00:00:00-04:00</updated>
   <id>http://hamant.net/2011/04/29/hello-worldv30</id>
   <content type="html">&lt;p&gt;Well - I’ve always been here… Just maybe a little quieter.&lt;/p&gt;

&lt;p&gt;I think I’m done being quiet. Nothing really holding me back anymore but myself. I feel the need to create things, yet I spend so much of my time spinning the wheels without putting the nose to the grindstone. Maybe afraid to launch? Afraid of some kind of failure? Who knows… &lt;/p&gt;

&lt;p&gt;I think I fail a little bit everyday already. But lately this failure has been punctuated with tiny victories. This is enough to make me want to open the doors and maybe share a little bit of myself with the world. I’m surely not the smartest guy you’ll meet,not the best husband and father, nor the best programmer, nor even someone worth listening to.&lt;/p&gt;

&lt;p&gt;No one is forcing you read this!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;So here we go.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There really isn’t going to be a theme or anything. Expect pure brain dump (it is going to be messy). There is no ‘content strategy’ here. I might go on about movies you can’t find, music you won’t want to hear, political fringes, do my part to recycle internet memes, fold some tinfoil hats, maybe throw in a bit of computer nerdery and philosophy into the mix. But you probably won’t find too much useful here… Some things longer than tumble and other things as short as goo.gl - wait and see! I guess somebody could find something useful someday.&lt;/p&gt;

&lt;p&gt;I’ll bring back the dead by visiting archive.org soon. Until then enjoy feeding on some of my other distributed internet output.&lt;/p&gt;

&lt;p&gt;–csh&lt;/p&gt;
</content>
 </entry>
 
 
</feed>