Archive for the ‘ General ’ Category

Netcat flexibility

I thought I’d take a moment to write a quick blurb about a wonderfully flexible and useful utility I use somewhat frequently: netcat. Netcat is a relatively easy to use network utility. It allows quick creation of network connections. It’s most useful to me when used in conjunction with other programs to quickly tack on network capabilities. Have you ever had to copy a directory tree quickly from one machine to another on a LAN? Most people would choose scp or rsync over ssh for something like this. What about when the tree size is really quite large and you would like to squeeze every ounce of speed out of the copy? If encryption is not important (e.g. on a LAN), why waste the CPU cycles on it? One trick to avoid encryption for these copy tasks is to use netcat with tar. For example, say I had a somewhat large directory structure on my work box and I wanted to copy the raw bytes across the network to my laptop using netcat. On the laptop, after changing directories to where I want the tree extracted, I would fire up netcat to listen on an arbitrary port and to pipe any incoming data to tar for extraction. The command to do this might look like:

 
nc -l -p 3333 | tar -xvf -
 

On my work computer, if in my current directory I had a sub-directory named ‘tree’, I would execute the following command:

 
tar -cvf - tree | nc <laptop_ip> 3333
 

This command tells tar to create an archive of the directory ‘tree’ and output the resultant archive to stdout (-). We then pipe that output to netcat which sends it across the wire to <laptop_ip> on port 3333. Netcat on the laptop receives the archive byte stream and passes that byte stream to the running instance of tar (tar -xvf -) which will take the byte stream and extract that archive to the current directory. Done deal. I use this quite often for LAN copies and I feel I must repeat that this is probably not a good idea if you are copying sensitive data across the internet. Use rsync over ssh or plain old scp for those instances. I’m sure there are many more cases where you will find netcat to be the right utility for the job. I find that many utilities I use on a Linux system are very good at a singular purpose. I find it extremely elegant that Linux (and other *NIX variant) systems were designed to allow this kind of modularity and easy cooperation between thousands of programs by a simple concept such as piping. It makes me happy. :)

Until later.

The Magic of Binary

In my endeavors as a software developer I gain deeper understanding of Computer Science each year. One thing that has always intrigued me has been binary numbering. As far as I know, everything wonderful and awesome we can do on our computers eventually boils down to a machine interpreting ones and zeroes. For example, the very keyboard on which I type has circuitry that associates each key or combination of keys with a certain numerical code. The computer receives this number and, because of the context in which it was received, knows to interpret this number as a certain letter. The letter ‘A’, for example, has decimal value of 65. It’s hexadecimal representation would be 0×41 and it’s binary representation 01000001. Not to deviate too much from my theme, but even the numbering for the ASCII codes has been extremely well thought out. For upper-case letters, there is always a 010 prefix and for lower-case the prefix is always 011. After the prefix, we are left with 5 bits to represent the letter. We can calculate the number of possible arrangements for a number of bits using 2^n where n is the number of bits. This leaves 32 possible arrangements for 5 bits, which is more than the number of letters in our alphabet. To translate from an ASCII letter to its numerical counterpart and vice versa then becomes easy. Let’s take the letter ‘P’ for example. ‘P’ is the 16th letter of our alphabet. It is a capital letter so it’s prefix would be 010. The number sixteen in binary is 10000. We add that to our prefix and get 01010000, which has a decimal value of 80. Therefore, the key code for the letter ‘P’ is 80. I digress. This is just one of the many amazing ways binary is used in Computer Science. As I said, it’s amazing to me that everything eventually boils down to these ones and zeroes and even electrical high and low signals. Another example would be the screen drawn in front of you. Each pixel (picture element) on your screen has a value associated with it stored in video memory that the video card interprets as a color. The video card knows what signals to send to the monitor to draw this color. The resolution on my screen right now is 1440×900. This means that the screen draws 1440 pixels wide and 900 pixels high. That’s 1,296,000 values floating around in my video memory. Of course, you may have double or triple buffering and this number would be 2 or 3 times as high and as I’m driving three monitors with my new Radeon HD 7770 I’d have to add that multiplication. Again, I digress. The real magic of binary for me is the simple fact that everything we do on our computers is just an interpretation of these high/low, 1/0 values. It all comes down to context and interpretation. I might have a hex value of c0a80032 which in decimal is 3232235570. You might never know what this number means unless you know the context from which it came. If I told you however, that this number was my local IP address right now, you might sooner work it out by breaking it down in octets. 0xc0 = 192, 0xa8 = 168, 0×00 = 0, 0×32 = 50. 192.168.0.50. Also, anyone who’s done a bit of network coding might pick out 0xc0a8 as 192.168. :P Binary is magical to me because it represents possibilities. It is the basis on which our layers of abstraction in the computing world are built and there are so many layers of abstraction that after years of studying I feel I’ve only scratched the surface!

46:6f:72:20:42:72:69:65

Long time, no post

Well, as with all the other blogs I’ve ever had this one fell apart. But, I suppose I can still resurrect it. I haven’t worked on the AjaxChat plugin for wordpress in a good minute, but that also is receiving attention anew. I updated my version of wordpress to the latest one and modified the plug-in to work with the latest version. The latest version of the plugin is 0.4.4 and is available at [http://wordpress.org/extend/plugins/ajaxchat]. It works for me at least, with a fresh install of WordPress and the plugin. Let me know if you have any problems with it. Thanks.

Time flies

It’s amazing how quickly it does. I looked down and realized I hadn’t wrote anything in about 2 weeks. Where did the time go? I suppose I’ve been relatively busy lately. My spare time has been spent mostly playing around with project ideas. I have a good many projects that are currently in progress, but this is because I have the attention span of a kid who has just finished drinking a cappuccino. I switch to something else when I get bored with one project. I guess the most recent project is AjaxIRC. I’ve been implementing an IRC client completely in the browser. It uses a C daemon on the server side to connect to the IRC server and creates a unix socket for comms. The JavaScript on the site sends data through a php script, which sends it through the unix socket, to the IRC server. Data being received is dropped into a memcached implementation by the C daemon and fetched out by a PHP script, which is polled by the JavaScript. Hrmph, that’s a mouthful. Anyway, I’ve kind of taken a pause from that as well as I’ve had something else burning on my mind. I recently became aware of the TI LaunchPad with the MSP430 microcontroller. It just so happens that I’ve really been having a lot of fun playing with low-level electronics these past few weeks. In fact, I took a laser diode out of a DVD burner, hooked up an external power source to it. Then, I used the parallel port on my computer to drive a transistor to switch the power source on and off. Wham, programmable laser light on my computer. Right now it just informs me of new emails, but it was fun nonetheless. Anyways, this development board from TI (LaunchPad), is looking pretty neat and super cheap. It’s just under $5.00. We’ve got a couple of them on the way now for some testing. Very neat intro to microcontrollers for hobbyists such as myself. Should be able to do some interesting things with them. Anywho, that’s all for now I guess. Oh, and also, I’m going to throw up my GPG public key on my contact page as I’ve officially started signing all my emails and encrypting any important ones. It’s also on the MIT PGP key server. Later.

Another beautiful day in South Florida.

And yet again, it’s sunny and beautiful outside.  I really am starting to like the Fort Lauderdale area.  The weather is fantastic, the beach is about 10 minutes away and for the first time I’m truly content with where I am.  This morning was a little hectic as I had one of our server’s power supply fail, but that was remedied fairly quickly because we happened to have a spare handy.  Also, the server really wasn’t a critical one.  The server that went down was our MySQL cluster management node, which can go down without affecting anything, so long as the NDB nodes all stay up (which they did.)  All of our mission critical applications are run on servers with redundant power supplies and software failover.  I actually have a nifty diagram of our recent server setup that I’ll attach below.  Anyways, not too much going on today.  I’m thinking about writing an ajax instant messaging to integrate with wordpress, so perhaps I’ll start on that.  57:6f:72:64

Maybe this blog will stick around…

This will be no less than the 3rd time I’ve created a blog where I intend to establish my presence on the net.  It usually happens that I just end up not posting for a while and deciding to delete it.  The reason this one might stick around is because I have officially gotten rid of both my facebook account and my myspace account.  Good riddance.  Turns out, according to recent news, that both companies were either currently selling or planning to sell users’ personal information and that just isn’t kosher.  Well, right now, I’m back down in sunny Fort Lauderdale, FL and life is seemingly good ;) .  Been coding for a company called Faith Farm Ministries; mostly just web apps that help them out a bit, ie: a price checker for their new furniture items, a messaging system/bulletin board for the employees, a transparent proxy to keep certain people from visiting social networking or other recreational web sites when they should be working, etc. etc.  Pretty basic stuff, but for any who would like to check it out, click on Projects in the links section on the right side of the page.  I’m also planning to add a little place to leave a note, and perhaps instant and/or sms messaging via this site.  Until later.

 
Ubiety v0.0.1
Chat ()