Thoughts on life, computers, and eternal happiness

I'm young and I make emotionally-charged posts in a stream-of-consciousness style. Drunk with passion, I will be wrong most of the time. Call me on it and help me learn. It is embarrassing to look back at my mistakes, but I will grow.

Tuesday, April 22, 2008

Summer of code!

I found out today that my proposal for Google Summer of Code 2008 has been accepted. This means I will be spending my summer working on netconf, a network configuration management system for Debian. I was so excited to get started that I already had two patches accepted before my application was even accepted :) Here's my full proposal (txt, 7.3k). Here's probably the most useful information from the proposal, my proposed week-by-week timeline:
  1. Before 5/26: Study the current netconf codebase, document and clean up code, write tests, stash away old documentation and code in current repo
  2. Week 1 [5/26]: Implement inet6 /etc/network/interfaces methods
  3. Week 2 [6/1]: Implement inet6/v4tunnel method
  4. Week 3 [6/8]: Design policy system and config format, initial implementation
  5. Week 4 [6/15]: Finish implementing policy system
  6. Week 5 [6/22]: Implement netlink socket listener + events
  7. Week 6 [6/29]: Implement wireless-tools and wpa-supplicant integration
  8. Week 7 [7/6]: Continue implementing wireless-tools and wpa-supplicant integration
  9. Week 8 [7/13]: Mid-term GSoC reviews; At this point, we should be very close to 1.0. The time that follows should be used as buffer space for things that may end up taking longer than estimated. Assuming a perfect world, full moon, and star alignment, the following weeks will be used to implement optional fun features.
  10. Week 9 [7/20]: Implement LinkLocal integration
  11. Week 10 [7/27]: Implement Additional DHCP options, http_proxy options
  12. Week 11 [8/3]: Implement ppp/wvdial functionality [Martin has offered to supply the hardware if necessary]
  13. Week 12 [8/10]: Run through the TODO [3] and implement minor leftover features
  14. Week 13 [8/17]: GSoC 2008 ends; have a beer :)
  15. After week 13: Continue to work with the netconf team to get 1.0 out the door; begin work on next challenges
I'll keep this blog updated with my progress, covering both my successes and failures.

Monday, January 07, 2008

Embrace the Magpie!

Jeff Atwood says we should stop trying out the shiny new things! As the general population tends to agree, customers don't care what languages and tools we use. Jeff makes some good points. I would prefer a more positive and slight tweak to the approach, however: "Embrace the Magpie!"
Who cares what technology you use, as long as it works, and both you and your users are happy with it?
Where's the obsession with quality that we should have? What if I use a six year old development environment riddled with bugs? Sure, the code I develop works, but it's a pain to write code when my development environment crashes regularly. What if static typing and unquantifiable things are slowing my productivity? The ITAPPMONROBOT works, but just passing by it in the datacenter worries me to no end. The pursuit of shiny and new things is exactly my goal. But that's just it, it's my goal. There are two types of goals to make the distinction between: 1. Your personal goals (use shiny new things and anything else that makes me happy) 2. Your job's goals (make the customer happy through whatever means necessary) When I'm at work, I'm going to make sure the customer is happy. When I'm at home, however, I'm going to hack on the things I care about, and I will definitely play with the latest technology. I refuse to feel bad about embracing new technology. I'll dabble in each language and play with every tool, and take ideas from them all. The funny thing is, it'll actually have a pretty neat side effect of improving my ability to satisfy customers. Why do you think Google lets their employees devote part of their time to personal pursuits? When you really boil it down, the point of Jeff's post is simply: Don't read programming reddit at work :).

Sunday, August 12, 2007

A simple Erlang IRC bot

I've been experimenting with Erlang for a while now, and it's been an experience. I've had a little rougher time with it than most people, but most of the blogs I've been reading are written by exceptional or brilliant programmers, so I'm not too concerned :). I went ahead and wrote myself a little Erlang IRC bot, as I had a hard time finding one that I could extend that isn't 5 years old and way too big or doesn't even work when installed using apt-get install (not to mention I couldn't find its source, either). Here's what I came up with:
-module(bot).
-author("jonathan.roes@gmail.com").
-export([connect/2, loop/1]).
-define(nickname, "jroes-test").
-define(channel, "#jroes-test").

% Connect to an IRC server with a given Host and Port.  Set up the TCP option to
% give us messages on a line-by-line basis.
connect(Host, Port) ->
        {ok, Sock} = gen_tcp:connect(Host, Port, [{packet, line}]),
        % According to RFC1459, we need to tell the server our nickname and username
        gen_tcp:send(Sock, "NICK " ++ ?nickname ++ "\r\n"),
        gen_tcp:send(Sock, "USER " ++ ?nickname ++ " blah blah blah blah\r\n"),
        loop(Sock).
        
% Now that we're connected, receive TCP messages and parse them.
loop(Sock) ->
        receive
                {tcp, Sock, Data} ->
                        io:format("[~w] Received: ~s", [Sock, Data]),
                        parse_line(Sock, string:tokens(Data, ": ")),
                        loop(Sock);
                quit ->
                        io:format("[~w] Received quit message, exiting...~n", [Sock]),
                        gen_tcp:close(Sock),
                        exit(stopped)
        end.

% The following is an example of the message this fun intends to parse.  Here we see
% the limitation that tokenizing the string on both :'s and spaces puts on us.
% [#Port<0.124>] Received: :jroes!jroes@mask-2EDB8BDB.net PRIVMSG #jroes-test :jroes-test: wassup?
parse_line(Sock, [User,"PRIVMSG",Channel,?nickname|_]) ->
        Nick = lists:nth(1, string:tokens(User, "!")),
        irc_privmsg(Sock, Channel, "You talkin to me, " ++ Nick ++ "?");
        
% If the second token is "376", then join our channel.  376 indicates End of MOTD.
parse_line(Sock, [_,"376"|_]) ->
        gen_tcp:send(Sock, "JOIN :" ++ ?channel ++ "\r\n");

% The server will periodically send PINGs and expect you to PONG back to make sure
% you haven't lost the connection.
parse_line(Sock, ["PING"|Rest]) ->
        gen_tcp:send(Sock, "PONG " ++ Rest ++ "\r\n");

parse_line(_, _) ->
        0.

% This just helps us write a PRIVMSG back to a client without having to type
% the newlines and :'s ourselves so much.  It'll be more useful later.
irc_privmsg(Sock, To, Message) ->
        gen_tcp:send(Sock, "PRIVMSG " ++ To ++ " :" ++ Message ++ "\r\n").
To run and play with:
jroes@halcyon:~/src$ wget http://jroes.net/bot.erl
jroes@halcyon:~/src$ erl
1> c("bot.erl").
{ok,bot}
2> Bot = spawn(bot, connect, ["irc.server.com", 6667]).
3> Bot ! quit.
Next up: Extending it so the code can be changed/added to at runtime, retrieving data from a webservice.

Thursday, July 05, 2007

The custom parameter that should have already been in .NET 2.0

I don't know why, but there's no DataSource parameter for member variables of the page. So, you can't choose one of your variables, like Page.Cow to be passed to a DataSourceControl. I went ahead and implemented one. Since there's no easy way that I've seen so far to paste code into a blog post on Blogger, I've just uploaded it to pastebin. This works for the situation I'm in right now, but I wouldn't be the least bit surprised if I hiccuped on a few of those Reflection types - Field, Member, Property, what's the difference? :) I should really read the Reflection documentation, but trying stuff until it works in QuickWatch is so much easier... Which reminds me, anyone know why I can't see variables declared inside an If block?

Saturday, September 23, 2006

I fixed the rest of the bugs that I know about for lnlink now. The latest changes are now merged with the stable version so there is no longer a "beta" lnlink.

I want to make a screencast to show off the functionality, and I also want to start thinking about putting this into a Firefox extension. The next thing that I think would be pretty neat is to have some sort of autocompletion when you're typing a localname. Also, it would be cool if this could happen in the location bar, too. I think this is actually pretty important in furthering the adoption of LocalNames, because most people have a hard time with memory and can't always remember exactly what they name a page. I know that I for one have difficulty remembering them.

Friday, September 22, 2006

LocalNames Greasemonkey script update

I fixed the LocalNames Greasemonkey script tremendously. It had a number of bugs stemming from the fact that it would just try to keep track of the last characters you'd pressed to figure out the last word you typed and see if it matched the regex for text between double brackets. One of them was that if you deleted anything it wouldn't update its last word buffer. The other was that if you hit spacebar twice and then started typing a LocalName it wouldn't load up. Now it just waits for you to hit a space, then looks up every LocalName that could be in the textarea and updates it. I haven't gotten it to mess up on me yet! I still need to figure out how to get it to work in GMail, Blogger, and Meebo. Once it works there, I'll probably use it 24/7.

Make sure you refresh any pages where you have textareas that you want to test it out in when you re-install the script. It has to re-add its listener events to the textareas, which can only be done when you refresh the page.

EDIT:

Okay, I really should go to sleep, but I just got the script working in GMail, Meebo, and Blogger. There are only two problems:

1. It'll drop you to the bottom of the textarea sometimes when you type a localname. -- 9/22 2:09pm: Fixed this bug with a bit of mathematical thinking. 2. If you type an invalid localname, it'll go haywire and start telling you the record can't be found over and over and over and over again every time you hit spacebar. Watch out for that one :) -- 9/23 4:47pm: Fixed this bug. Nothing will happen if you type an invalid LocalName now, not even a "record not found". When I convert the script into a full-blown firefox extension, I plan on giving a bunch of different options for what to do when LocalNames aren't found.

Since it has so many crazy little bugs, I'm just going to sneak you a beta and leave the other one around. But, how cool is it to be chatting with your friends via IM and then slip in a localname!? AWESOME!

Todo: Fix bugs mentioned above. Make a screencast.

Here's the latest lnlink beta.

Thursday, September 21, 2006

Why I would probably use .NET instead of Python for any project I do in the near future

I want to start off by saying that I really, really, love Python. Python is a great language. I like the way it feels, I like the way it works, and I like that it's always there for me when I'm in need.

Now, having said that, if I were going to start on a web project in the next... 20 minutes, or few hours, or weeks, or months, I'd probably use .NET (VB or C#). Why? Because you can get a whole lot more done in a whole lot less time.

1. I don't have to remember every class I want to use

I jump into my new project, type a few lines at the command line to start a new project with Django, or import web.py, or whatever crazy cool new hip happenin' web framework I want to play with (don't get me wrong, they are all really cool and have lots of advantages, especially the way database functionality works, MVC, and pretty url handling). I start on my first page, the index page. I jump into the function that will display the contents of the page. Oh, crap, what's the function to send a 200 OK HTTP response? Oh, crap, what's that function called that parses the template I made? Oh, crap, what's that function called that selects the data I want from the database and passes it to my template? I'm too forgetful for that kind of stuff. I need intellisense. And, yes, I know Vim 7 has C-x u. But, I've never gotten that to work. And I tried, I tried really hard, I swear. And, typing C-x u is a pain in the damn ass anyways. Why can't it just pop up when I hit the period key?

2. Debugging isn't really really really really really easy

In .NET, I start my page in "Debug" mode, and set a breakpoint on something I think might break. The code runs until my breakpoint, and then I can just move the mouse over anything that I have a question about -- did this function call work the way I expected it to? Does this variable have what I expected it to have in it at this point? All that stuff is right there, really cool, working perfectly. I can even watch variables change value while stepping through the code. It's all so visual and easy to use. I have never seen anything that exists like this for Python code.

3. I don't have to type 3000 pounds of HTML to get a table on the screen

Ok, now, I really believe in semantic markup, and sometimes .NET really gets on my nerves because everything is table-based and ugly, and I know I'm not supposed to use tables for layout. However, sometimes you really don't want to type html head title blah blah blah just to get some things on the screen really quick. It should be pretty trivial (especially considering CSS has absolute positioning and all kinds of nice fancy stuff) to just drag some stuff on a screen and get rolling. I'll admit it, this isn't really a good excuse to use .NET, the other 2 stand on their own. I could live without this if the other 2 were present.

Now, of course, there are things I can't stand about .NET. One of them is that I can't use Vim. I love Vim, I am too addicted to the hjkl layout to switch to anything. I gave Emacs a good week or two before I couldn't take it anymore, so please don't try to convert me. Actually, I found something cool a while back that lets you edit .NET code in Vim, but you had to pay for it, and I'm stingy. I won't even link to it because I find it so disgusting that someone would rip the whole Vim idea and then try to sell it. I hope they don't make a cent, honestly.

Another thing I don't like about .NET -- no one does unit testing. I want to unit test everything, I want it to be a nice integrated part of the GUI. But, it's just not there.

I don't understand why there hasn't been a lot of movement toward some really nice environments that directly compete against .NET and friends in the Linux world. Maybe I'm just not looking in the right places. The best I could find is pida, which, by the way, I think is really really cool. But, alas, there is not a large fanbase, and there is not a lot of development going on with it from what I can tell.