cover.jpeg

A Quick Update

This year, I really wanted to work on my output, and I think I’m doing pretty well. Here are some things that I’ve been publishing: Regular monthly blog posts on yakushima.blog A few posts this year on the Geolonia blog for work However, updates on this personal blog has been not so great – the previous post is the “2023 review” post, after all. I’ve been updating this blog from 2012, when we officially incorporated Flagship.

Read more

Convert old-style Ruby hashes to new-style.

Search: :([^s:@]+)s*=>s* Replace: 1:

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".

Read more

Moved!

Just writing to let you know that I’ve switched servers for this blog! I’ve been meaning to get this on to a faster server that I have control over for awhile, and I finally got around to doing it. For those of you who are curious, this site is being served by WordPress Multisite, on a Sakura 2G VPS. And because everyone likes talking about stacks: Kidding. MariaDB NGINX PHP WordPress That’s it!

Read more

Making a (proper) WordPress Theme

One of the things that I’ve built regularly are custom WordPress themes for clients. Let me clarify – a custom theme for each client. One theme per client. So, I decided to try my hand at making a “proper” WordPress theme – a theme for regular users. And I submitted it to the WordPress themes gallery. Successfully! [caption id=“attachment_304” align=“aligncenter” width=“640”] wp386 - my first public WordPress theme![/caption] There were, however, quite a few catches along the way.

Read more

Facebook: Pop-in.

What do you do when you have a Facebook app tab (inside an iframe, mind you) that’s externally linkable? Pop-in. Let’s break this down. if (self === top) { This conditional will be true when the browser is not inside an iframe. window.location.href = 'https://www.facebook.com/test/app_1234'; If we are not inside an iframe, then redirect to the following URL.

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. Fork away! Source code

Amazon IAM Policies: Granting one user access to a S3 bucket

It may be easy to use the same master Access Key and Secret Access Key for all your apps using Amazon AWS, but it’s definitely not secure and recommended against. That said, I had a little trouble writing the IAM policy granting a single user access to a single S3 bucket. I finally had time to sit down and figure it out today, and turns out - it’s pretty easy. Up to this point, I’m assuming that you’ve already created your user, but if you haven’t - the IAM management console is located here: https://console.

Read more

Ruby/WordPress

Too long? tl;dr. Situation: You’re migrating a big site to WordPress. You don’t want to make 1,000+ posts manually, do you? Meet Ruby/WordPress. I’ve made a quick little Ruby gem that interfaces with your WordPress database, so you can manipulate it within Ruby. This opens up a whole world of possibilites - the most exciting being Nokogiri, of course. Here’s a quick code sample that will create 100 new posts!

Read more

LocationMatch and ProxyPass

Want to mix LocationMatch and ProxyPass? Not so fast. <LocationMatch ^/(regex/here/.*)$> ProxyPassMatch http://backend/$1 </LocationMatch> Don’t forget to use ProxyPassReverse if you need it (it shouldn’t be inside the LocationMatch directive, though). References: ProxyPassMatch docs Bug 50048 - ProxyPass(Match) within Location(Match)

Ruby 2.0.0 p195 PSA

In Ruby 2.0.0 patchlevel 195, you can no longer mix old- and new-style hash syntaxes in method arguments. For example: Wrong method hello: 'there', :goodbye => 'goodnight' Right method { hello: 'there', :goodbye => 'goodnight' } or method :hello => 'there', :goodbye => 'goodnight' Apparently this has been fixed in another patch to Ruby 2.0.0, but that doesn’t really matter, since p195 is out right now. Source: https://gist.github.com/stephencelis/5595842