One of the largest critiques I see about regular expressions is that they lack readability. Well, in Perl 5.10 named capture was added (http://perldoc.perl.org/perlretut.html) which I think adds an awful lot of readability to Perl regular expressions. Continue reading Gist of the Day: Named Capture in Perl Regular Expressions (Briefly)
Parallel processing is all the rage these days, and life has me at a point where I’m needing to use it. I am having to minimize dependencies in the task at hand, so I’m having to forego my usual CPAN modules and use basic system calls. It’s not terribly complicated, but just to refresh myself on the basics I went ahead and whipped up a quick demo that I thought others might find useful. This is a very simple demonstration of how to use
wait(). Continue reading Gist of the Day: Playing with Forks
I got a little bored with what I had been posting (I suspect you did, too), so I’m doing something neat. I’m going to write a full (though limited) program for you. Here are the user stories (if you don’t know what user stories are, see here before continuing):
- As a web user I can enter a phone number and a SMS message into a queue so that it can be sent by a mobile handset.
- As a mobile handset user, I can push a button to dequeue a message and send it via SMS so that I might risk my device’s stability and my own financial solvency by opening up the internet to sending messages through my phone. Continue reading Gist of the Day: Using Mojo, Mongo, and SL4A to send SMS Messages (1 of 2)
Hi, did ya miss me? I’m blogging from O’Hare today, it’s going to be a busy week for me with lots of air travel. That won’t stop me from polluting the Internet with yet another blog post though, don’t you worry!
One of the things that we sometimes encounter is a binary file created by some C program writing a
struct straight to disk. If we want to get any of that data we will need to parse this file, and read that struct. It’s a little tricky, and you kinda have to know a little bit about either the system on which he program was run, or the intentional decisions made by the program about how the file was written. The most important thing you need to know is the endianness of the binary data. Continue reading Gist of the Day: C Structs from Binary Files Using Perl
This is a really cool idea, it’s a site-specific browser, similar to Fluid on OS X. This has alerts and such that come up as well, and it’ll sit in your KDE task bar. I’m digging it so far. I suspect that it’ll play nice in other DEs as well.
The app is available as a .deb as well as a source package, and many different OS’ and configurations are available. I’m using the Ubuntu package since I’m in Kubuntu land. This app does appear to be receiving updates, the most recent one according to openDesktop.org was on September 3rd, 2013.
Here are the features I see:
- Supports SSL Facebook (very important for me since I have an ISP which engages in DPI)
- Works with two-factor authentication with Facebook
- Simply uses the web UI of Facebook (I see this as a plus, not a minus, that way I’m not stuck waiting for someone to implement changes that Facebook threw into an API update)
- Very lovely Facebook blue window border, fits in very nicely
Here are some areas that I would like to see improved:
- I’d like to be able to resize the window
- I’d like it not to crash when something tries to use Flash (too much stuff on Flash crashes)
- It’d be neat to not have to log in again every time I opened the app.
I think that with only some minor changes, this app could be one that I keep running in the background all the time. I’d love to see something like it for Twitter as well.
Here’s the app: Facebook openDesktop.org.
I’ve been doing a lot of stuff lately with data structures and algorithms. This is one that seemed remarkably complicated to me – and still kinda does – when I started. It’s not as trivial as a binary tree mainly because there are far fewer rules. There’s a whole lot of stuff you can do with graphs, and this is by no means an advanced or complicated usage of them. This is as simple a task you can do with a graph.
The task at hand is to find all possible paths between two vertices. Continue reading Gist of the Day: Find All Paths for an Undirected Graph
So, I’ve been looking into how process control works in GNU/Linux environments, and I thought I’d share some stuff with you guys since you totally care.
- This post on informIT explains how processes die in Linux.
- This is an article (it’s a part of some actual documentation) about signals and signal handling, but it also covers a bit of
ptrace()and how to properly handle child processes and
- This article is from the same site as the previous one, but it covers process control. I really appreciated how this one went into depth about how the exit status works with processes exiting, and also how it went into zombies and how they work.
That’s all I have for now. Please use the comments section if you’d like to suggest additional articles.
Before you begin the well-deserved flaming, please understand that I do not intend on submitting this to CPAN. This is purely an academic exercise to demonstrate the algorithm (poorly), and to help me practice some stuff. I understand that this isn’t terribly efficient, and I am quite confident that one could do this much faster (and probably has many times over). I wrote this for fun, and for boredom, and I’m posting it because I thought it was cool and because I promised you I’d post stuff.
This algorithm is pretty simple. The premise is that you take a key value of some sort, you hash it using any algorithm, and then you take the mod of that hash value by the capacity of your hash table, and that gives you an index! It’s pretty simple, and even in the implementation I have here I believe it’s not a terrible look-up time.
The basic idea is this:
$array_index = hashval($key) % $array_capacity
I feel really bad for leaving you all high and dry yesterday… really bad… okay, you’re right, I don’t really feel all that bad.
I have a doosey for you all today though, no doubt about it! One of the most common trends in computers these days is multi-processing. Multiple cores means one program can do more work by spawning extra threads or child processes. I’ve already done a bit of stuff with threading, so here’s a bunch of stuff with forking (tee-hee). Continue reading Gist of the Day: Process Control with fork(), exec(), and kill()
I biked a bunch tonight, and worked a bit late, and then watched Torchwood on Netflix… so, sorry for slacking.
Here’s the Gist of the Day, it’s just a simple Tree in Python with comparison. Very very simple, but I’m trying to get a better understanding of Python. I’m hoping next to implement something graph-related tomorrow. Continue reading Gist of the Day: Simple Tree in Python