Mojolicious is a fun module/framework/thing for me. How do I love Mojolicious? Let me count the ways (sorry Shakespeare):
- Mojo has ridiculously few dependencies, especially when compared to other web frameworks
- Mojo brings web servers (morbo and hypnotoad) with it
- Mojo does MVC, or doesn’t do MVC, whatever I want to do
- Mojo has templates, and they’re outstanding
- Mojo does routes very simply, which is badass
- I can write an entire web application in only one file (though it could get big and may not be advisable) using Mojolicious::Lite
- Mojo has helpers which are actually helpful
- Mojo is crazy fast, so fast that if there is a performance problem I’m pretty sure it’s me
- The more I use Mojo, the more I find cool stuff that it can do Continue reading “Gist of the Day: Mojo Merging Hashes”
I am very sorry that I missed posting this yesterday, I kinda got crazy sleepy and went to bed shortly after getting home from work.
AS PROMISED, however, this next Gist is the SL4A Android component. This program gives you two buttons: “Process Queue” and “Exit the program!” With these two buttons you can either process a message from the queue (see previous post) or exit the program. Processing the queue involves sending an SMS message and then repeating the message with TTS. Continue reading “Gist of the Day: Using Mojo, Mongo, and SL4A to send SMS Messages (2 of 2)”
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):
So I’m on very little sleep after a long three days of travel which is not yet done. Nonetheless, the show must go on!
Today I have for you a demo program I wrote for CMI.pm a while back (last July I believe) on how to use Perl with SL4A (Scripting Languages 4 Android). This sample code loads a screen which does one of two things: says “something nice” or exits the program. This program demonstrates how to make an event loop for SL4A, how to load an external XML UI resource for Android, and also uses some very basic functionality of SL4A (TTS speak, in particular).
As I am very tired – three hours of very interrupted sleep – I will not be writing any more than this, but I will, of course show you… Continue reading “Gist of the Day: Old SL4A Example!”
I’m pretty sure there’s a more efficient way of doing this, but here’s what I’ve quickly typed up in 10 minutes sitting in my hotel. It just takes in a number, and then the size (in bits) of the number. It returns the number of bits it counts. I believe there is a very common algorithm called the Hamming algorithm, but as I don’t know that algorithm I’ve kinda worked this up instead.
This post is super short as I have a very busy day ahead of me. I’m going to go ahead and just post the code and call it a day. Sorry for the brief post. Continue reading “Gist of the Day: Counting Bits”
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”
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”
Here’s the scenario: you have two lists of integers, and you have a sum. Write an algorithm – in Perl, of course – to find which two items when summed give you a specified number. If no pairing exists, don’t return anything. If a pairing does exist, return the first pair you encounter. Remember, you could get two very large input lists. Continue reading “Gist of the Day: Find Which List Items Make Up a Given Sum”
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
Continue reading “Gist of the Day: Re-Inventing Hashes… In Perl.”
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()”