Categories
English Uncategorized

Podcasts I’m Listening To (November 2015 Edition)

My wife Naoko wrote a reply to this post. It was fun comparing how different the podcasts we listen to are. 🙂

First, I’d like to plug a podcast that I’m a semi-regular guest on, techsTalking(5417), a podcast where technology people just talk about whatever is on our mind.

Here are some other podcasts that I’m currently subscribed to:

  • The Incomparable — a podcast about anything geeky. Star Wars? Check. Star Trek? Check. Silly drafts? Check. Crazy movies? Check.
  • The Incomparable Game Show — born from The Incomparable proper, regular panelists play crazy games for your entertainment. On the podcast.
  • Incomparable Radio Theater — The Incomparable podcast, once upon a time, liked to do funny things on April Fools. Like, say: release a full-length episode in the format of old-time radio drama. Including equally funny sponsors (some fake, some real). Now, they’ve spun it off in to a separate podcast.
  • Random Trek — Incomparable regular Scott McNulty hosts a podcast with non-random guests talking about random episodes of Star Trek.
  • Robot or Not? — Is it a robot? Or not?
  • Astronomy Cast — A weekly “facts-based journey through the cosmos”.
  • Reconcilable Differences — Two of my favorite podcasters, John Siracusa and Merlin Mann, get together on one podcast.

A few other podcasts I listen to occasionally:

And assorted programming-specific podcasts.

Categories
English Uncategorized

Homebrew and PostgreSQL 9.4

Edit 2016/1/9 I have updated these instructions for upgrading from PostgreSQL 9.4 to 9.5.

As you may know, I am a big PostgreSQL user and fan. I also use Homebrew to manage 3rd party software packages on my Mac. PostgreSQL 9.4 was just released a couple days ago with some really cool features — a binary-format JSON datatype for speed and flexibility (indexes on JSON keys? Of course.), and some really good performance improvements. Read the release blog post and release notes for more information.

However, if you’ve used PostgreSQL before, you know that upgrading can be a little difficult. Here’s what you have to do to upgrade your Homebrew-installed PostgreSQL 9.3 to 9.4. Keep in mind, these steps are for a standard Homebrew installation — as long as you haven’t configured custom data directory paths, it should work.

  1. Turn PostgreSQL off first, just in case:
    $ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
    
  2. Update PostgreSQL itself:
    $ brew update && brew upgrade postgresql
    
  3. Make a new, pristine 9.4 database:
    $ initdb /usr/local/var/postgres9.4 -E utf8
    
  4. Migrate the data to the new 9.4 database:
    $ pg_upgrade \
      -d /usr/local/var/postgres \
      -D /usr/local/var/postgres9.4 \
      -b /usr/local/Cellar/postgresql/9.3.5_1/bin/ \
      -B /usr/local/Cellar/postgresql/9.4.0/bin/ \
      -v
    
  5. Move 9.4 data directory back to where PostgreSQL expects it to be:
    $ mv /usr/local/var/postgres /usr/local/var/postgres9.3
    $ mv /usr/local/var/postgres9.4 /usr/local/var/postgres
    
  6. Start PostgreSQL back up!
    $ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
    

Note: If you’re using the pg gem for Rails, you should recompile:

$ gem uninstall pg
$ gem install pg
Categories
English Uncategorized

Kerbal Space Program – Asteroid Redirect Mission

Kerbal Space Program — KSP for short — is an incredibly addictive game about… Space exploration! In the game, you are in charge of the space program on planet Kerbin. Kerbin is located in a solar system quite similar to our own solar system, with a few differences. I’ve been playing this game for a few months, and finally decided to write a blog post about my experiences and thoughts.

Jeb on Mün

Note that KSP is still being developed with regular updates. Consider it alpha software — feature set is incomplete, and there may be bugs along the way. Regardless, KSP has fostered a very strong community of fans, players, and even modders. I haven’t developed a mod / plugin for KSP myself, but it is architected to be easily extensible. My favorites are MechJeb – autopilot and maneuver assistant and Kethane – in-situ resource utilization, but there are many more to choose from.

As of version 0.23.5, there are two modes of play – “Sandbox” and “Career”. Career mode is relatively new to the game (since 0.22), and is still being heavily developed. The point of the game in Career mode is to build rockets, use those rockets to send Kerbals to space, and gather science! In return for these science points, you can unlock additional parts to make bigger and faster rockets.

Rocket Science

When I was a kid, I often enjoyed constructing and flying model rockets with my father and brothers. I never understood the phrase “it’s not rocket science” — I thought building rockets were relatively easy. Make an aerodynamic body, attach the motor, and light the fuse!

I was wrong. I can’t begin to start on how many ways I was wrong. KSP taught me not only where I was wrong, but how wrong I was.

New words, words I have never heard before, words like “periapsis” and “apoapsis”, became not only familiar, but required knowledge. I realized that rocket science is not only about building rockets, but also about controlling them.

Periapsis. Apoapsis. Hohmann transfer. Plane-change maneuver. Gravity assist. The Tsiolkovsky rocket equation. Specific impulse. ΔV.

These words all mean something in KSP. You can play the game without really knowing about them, but if you want to get good, you probably should.

I wish I had this game when I was a child, not only because it would’ve been great fun, but also because it would have taught me the importance of physics and mathematics from an early age. In elementary school, our teachers would always tell us that math was very important! But they didn’t have any concrete examples. KSP changes all of that. NASA has already seen the potential in this game — the latest version was actually a collaboration between the KSP developers and NASA. While entry into the classroom may be difficult, I believe that this game has incredible value for children. How many times have you heard “<insert product here> makes math fun!”? KSP is one of the few games that actually makes math fun.

And now, here are some photos of me “researching” and “preparing” for this blog post 🙂

Categories
English Uncategorized

Ruby 2.1.0-preview2

Ruby 2.1 is coming soon!

Personally, I’ve noticed quite a few speedups, and it seems like they’ve fixed a large memory problem I was running in to on pre-release staging environments:

fix memory consuming issue on RGenGC (r43532 and r43755)

I’d be interested in your experiences!

Categories
English Uncategorized

Git and Local / Server Hooks

I have been a proponent of pre-commit hooks for a very long time. After doing some searching, I found this lovely gem. It consists of a bunch of checks before you commit your code into the repository. A couple of my favorites:

  • php – Runs a PHP syntax check on all PHP files
  • merge_conflict – Makes sure you aren’t about to commit merge conflicts (you know, >>>>>>>> HEAD, stuff like that)
  • ruby_symbol_hashrockets – Prevents you from committing old-style Ruby hashes ( :hello => 'there' )

And much more. Highly recommended!

Categories
English Uncategorized WordPress

Turbolinks and WordPress

Rails Turbolinks is pretty cool, right? I thought it would be pretty cool to use it on WordPress, too.

There are probably a lot of bugs, and it probably doesn’t work well with JavaScript-heavy sites. I’ve included the jQuery compatibility layer, but it’s still not perfect. Use at your own risk.

To install, just search the WordPress plugin repository for “turbolinks”

wp-turbolinks

Or, available for download here:

http://wordpress.org/plugins/wp-turbolinks/

Contributors welcome!!!

Categories
Automate your Workflow English Uncategorized WordPress

Vagrant, WordPress, and Theme Development

I’ve been playing around with Vagrant recently. It really is a great tool for setting up development environments quickly and cleanly – no more local MySQL databases with 100 separate databases!

There are a few ways to solve this problem that many WordPress developers have:

  1. Use WordPress Multisite mode.
  2. Regularly clean your databases up and delete old ones.
  3. Use a common WordPress install, switching themes.
  4. Use Vagrant.

I’m going to be talking about the last option, Vagrant, in this blog post. I’ll list out a few reasons why Vagrant was attractive to me in the first place:

  • Isolation – this was appealing not only to reduce my database clutter, but also to be sure that the development and production environments were as similar as possible (within reason – of course).
  • Portability – another killer feature of Vagrant. Check out the repository, vagrant up, and you’re ready to go.
  • Coolness – don’t you love the idea of having contained, automatically managed environments for your projects? No? Well, I do.

Here’s what I came up with: vagrant-wp-theme-template.

It’s a template based on Underscores (_s), a template theme for WordPress themes. I’ve made two modifications: convert the CSS to SCSS, and the JavaScript to CoffeeScript. Grunt, an excellent automation tool, is used to compile the sources into CSS and JavaScript.

I’ve made the template compatible with _s, so just follow the instructions for _s regarding naming your theme, then the directions for getting your development environment set up. If you want to use an existing theme, just drop it inside the theme folder (and don’t forget to update the name in the Vagrantfile!)

I’m always open to new ideas and pull requests – please don’t hesitate to contribute!

Finally, this wouldn’t have been possible without the help of @miya0001‘s vagrant-chef-centos-wordpress, which this template is built off of. Thanks!

Categories
English Uncategorized

Marshal.dump and load with ActiveRecord

If you aren’t familiar with Marshal.dump and Marshal.load, you probably should be. It’s used to serialize Ruby objects into binary data – mostly caching.

Now, if you’re trying to implement a Russian-doll caching system with objects, you probably have run into the issue of eager-loading associations using #includes not being cached.

my_data = Rails.cache.fetch('an_object') do
  MyData.where(condition: 1).includes(:user).first
end

my_data.user
# On cache miss:
# => SELECT "my_datas".* FROM "my_datas" WHERE "condition" = 1 ORDER BY "id" ASC LIMIT 1
# => SELECT "users".* FROM "users" WHERE "id" = 1
# On cache hit:
# => SELECT "users".* FROM "users" WHERE "id" = 1

So, I wrote a quick module to make Marshal.dump and Marshal.load dump and load the association data, as well.

https://gist.github.com/keichan34/6448987

NB: This hack works with Rails 4, but I haven’t tried it on any other versions. YMMV.

Categories
English Uncategorized

Rails Security 101

I’ve come across too many Rails apps with the secret_token in version control. Don’t do that.

Categories
English Uncategorized

S3 Uploader

There have been more than a few times where someone needs to send a big file to me. So, I made a quick and dirty tool to allow anyone to upload files directly to a S3 bucket.

No more shuffling links around, worrying about them expiring, and wondering whether the data stored is safe or not.

Screen Shot 2013-08-06 at 5.17.27 PM

Fork away!

Source code