I use the terminal for a lot of my work, so when I need to process output from other tools, I have a lot of options. I started out using shell scripts, but eventually moved on to scripting languages — first with Perl, then Ruby, with occasional Python. Lately I’ve been getting familiar with my shell (bash) again, finding new ways to stretch its usefulness as a tool on its own, without pulling in typical auxiliary support from grep, sed, or awk.
Bash is a big program, and the bulky man page can hide some gems. One area where it’s quite capable, which I only recently dug into, is string handling. Except it’s not really called that, so you might not have noticed it. As James Coglan rightfully puts it: Read more on String Tricks that Bash Knows…
I love writing code in high-level languages, like Ruby. But a lot of cool and useful libraries are written in lower-level languages, like C. Alas! What is a programmer to do?
There are three common approaches to solving this conundrum:
Port all or part of the library to your language of choice.
Write an extension in C code to bridge the gap between the library and your language.
Wrap the library using your language’s foreign function interface (FFI) support.
I used each of these three approaches over the 7-year history of developing Rubygame. I began with a combination of Ruby port and C extension, then migrated to a combination of Ruby port and FFI wrapper using Ruby-FFI. And a few years ago, fellow Atom Shawn Anderson wrote about his experience creating a Ruby-FFI wrapper for the Chipmunk game physics engine.
Based on our experience, we have to say: FFI is awesome. An FFI wrapper is much easier to write and maintain than a C extension, more portable across platforms and language implementations, and easier for users to install.
My first experience with Thor wasn’t great. I had heard that it could be used as a Rake replacement. Now, I have no problem with Rake (I like Rake!), but I’m always open to trying something new. I didn’t like the new thing.
Well, I didn’t like it until I tried to use Thor for what it claims to be good at (go figure). In fact, I much prefer Thor to something like Ruby’s OptionParser and other similar libraries. I can’t put my finger on exactly why, but I find command line interfaces I create with Thor much more aesthetically pleasing than other comparable libraries.
I needed to expose an internal CouchDB server to the outside world. When it was only accessible behind a firewall, it was not a big deal to throw an Admin Party. But opening it up to the outside world meant having to figure out how to lock down the CouchDB server. This post collects some of the articles and code snippets I tracked down while researching how to secure a CouchDB server.
Atomic Object is proud to sponsor Pry, an open source IRB replacement created by John Mair (aka banisterfiend). John and other Pry contributors have been hard at work not only building a better general purpose ruby shell, but one with goals as lofty as reproducing a REPL-based dev environment like SLIME for lisp.
When it comes to exporting a tab-delimited file from a mysql database table, you have a couple different options without having to resort to heavier programming in Ruby, PHP, Java, etc. Instead, you can use MySQL’s SELECT INTO OUTFILE, run a SELECT statement and redirect the output to a file, or use mysqldump.
I started looking into this because I needed to dump a table with 140,000 rows with over 100 columns into a tab-delimited file, without the assistance of an admin tool with a convenient GUI. So, with a little help from my children’s favorite cartoon, Phineas and Ferb, here are examples of the three methods I came across during my search.
We recently moved this blog from Mephisto hosted internally to WordPress on page.ly. One of our goals was to migrate our existing library of posts forward into the new site. We accomplished this, but not without some work massaging a WordPress export file. If you are migrating from Mephisto to WordPress, you might find our efforts useful.
Getting Started with WXR
We started with over 400 posts authored by around 30 people over the course of 5 years. The first task was to generate a ‘WordPress export file’ from our existing content. This Python script proved to be a great starting point. To use that, we made a dump of our Mephisto (MySQL) database, loaded that into a development environment, and pointed the script at it. This resulted in a .wxr file, which is a specific form of RSSXML.
It happens countless times for many reasons. You attempt to start or restart your MySQL server after a small configuration change and MySQL stubbornly refuses to start. Or, if it does start, some important functionality, such as InnoDB support, is missing.
Most Linux users will be familiar with the following pleasant response: