Downside of a virtualized workflow

I’ve been using a virtualized workflow for almost a year now and it’s been great. My work for clients, projects, and specific interests are partitioned off into separate vms in proxmox and vscode’s remote ssh plus easy port forwarding helps a lot in making the whole thing feel local.

However I just recently experienced an internet interruption and thus felt a downside of this workflow: my vms and docker containers are not connectable anymore 🙁

Authentication Zero gem

https://github.com/lazaronixon/authentication-zero

Found an interesting authentication gem for rails; instead of the usual delegation to the gem (where oftentimes you’re not sure what’s actually happening) this instead generates the authentication code so the author is in control of what’s happening.

From the readme:

The purpose of authentication zero is to generate a pre-built authentication system into a rails application (web or api-only) that follows both security and rails best practices. By generating code into the user’s application instead of using a library, the user has complete freedom to modify the authentication system so it works best with their app.

Readeck and Proxmox helper scripts

I just setup readeck https://readeck.org/en/ on proxmox via proxmox helper scripts https://helper-scripts.com/scripts

Just like wordpress, it’s not that I can’t do the installation myself but more like it’s convenient and it’s mostly the same things I would do anyway, so might as well just take a look at a script someone else wrote )and do a cursory check) and use that instead.

Re: readeck it seems like a good idea and being self hosted I can be sure the stuff I save won’t be lost when the host service goes away (I’m looking at you Google Reader).

Widget Options

Another useful plugin I found and am using is widget options https://wordpress.org/plugins/widget-options/

I have the recent posts widget that looks good on desktop but becomes redundant in tablet and mobile, so I wanted to hide them in those devices. Instead of writing custom css, this plugin does it for me 🙂

Static vs Cloudflare Tunnels?

I just tried generating some static pages and deploying it to cloudflare pages with this wordpress installation and while it seemed successful (at least from the publishing point of view) it made it difficult to work with some of the plugins that make things convenient.

The Google SiteKit plugin especially. For some reason it refuses to use a custom domain and insists on using the current site’s url as the domain for connecting with Google analytics. So that means I can’t really host things local and then generate from local to static without some janky setup like having the hosts file for this domain to point locally.

Speeding up WordPress

Moving the WordPress and mariadb to the fast cache drive makes things a bit faster

I was wondering why working on this WordPress blog (e.g. activating themed or plugins) was super slow. Then I realized I set the location of the installation and the db on the slow drives 😕

So in unRAID, I stopped docker and ran the mover (with the shared set to have the cache as primary storage, array as secondary, and the mover set from array to cache).

Magic Post Thumbnail

I just tried this wordpress plugin called magic post thumbnail https://wordpress.org/plugins/magic-post-thumbnail/ which automatically generates a featured image for a post that doesn’t have a featured image.

I’m also using a plugin called auto post thumbnail https://wordpress.org/plugins/auto-post-thumbnail/ that uses the first image in a post as the featured image if there’s no custom featured image set. However, I also do have some posts (such as this one) where I don’t really have any picture or illustration to accompany the post.

Daily Scrum is not about daily updates

If your “product owner” demands the team update them everyday and turns the daily Scrum into a daily update, that’s not scrum anymore.

The daily Scrum is for the team to coordinate with each other so they can work towards the sprint goal.

If the only time the product owner touches base with the dev team is through the daily “updates” provided to them, they’re not on top things and not really doing their job.

TIL: git update-index –skip-worktree <filename>

TIL about this option.

git update-index --skip-worktree .obsidian/workspace.json

I have obsidian on multiple machines synced via git and I’m always wrestling with .obsidian/workspace.json conflicts, and today I thought enough is enough and I ought to fix this.

Looks like with this option, I can set it so that local changes are persisted even if the remote file has changed.

TIL: ~/.gem/bin

I use ubuntu snap for installing ruby in my development machine (because it’s easy) and TIL that the gem binaries are installed in ~/.gem/bin

That means I just need to add this to my PATH and I get to use the binaries. I had to do this to get the syntax_tree gem executable be found by vscode.

Docker Compose All The Things

After getting the GPD Win Max 2 and using it as my everyday machine bothe for work and for personal use, I’ve started enforcing the philosophy of not installing any project dependencies locally, and instead leverage containerization technology (mostly via docker). I’ve talked about this in a previous post and you can probably think of this post as an improvement on top of that.

I’ve been successfully using this following pattern both for work projects as well as personal ones, and I thought I’d like to share them.

Get Workflow Data From CircleCI

I needed to analyze some data regarding the costs of my client’s current CI system, and CircleCI’s insights dashboard–while itself is impressive–isn’t quite up to task.

Sometimes you just need the plain old “spreadsheet analysis technique” to make progress.

Here’s a quick ruby script I’ve written to get data from all the workflows for a particular project, and write them down into a csv for easy importation into a spreadsheet program.

Advantages of Using Docker Compose in Your Projects

It’s that time of the year again when I get a larger drive, refresh my operating system, and back up important files.

Ever since I’ve settled on having my home folder always be on a separated drive, it’s been really easy to change operating systems, and even moving to a different (more powerful) computer isn’t as much of a chore. If I need to upgrade storage capacity, I just copy everything in my home folder onto the new drive (either by imaging or rsync) and then make sure that when I setup the new OS, that new drive is mounted in /home.

One thing that’s been really convenient for me is the ability to even move database data along with my home folder. This has been largely because I’ve been using docker (and docker-compose) more and more on my projects.

Vue on Rails

A gentle introduction to modern client-side web frameworks for Rails developers.

Presented at the KL Ruby Brigade.

Featured Pattern: Rescue, Log, Rethrow

Whenever you use a method that you know might throw an exception but shouldn’t, the rescue-log-rethrow pattern is useful to figure out what happened while preserving the contracts implied in the code.

TDD and the Scientific Method

TDD’s mantra is the following: Red, Green, Refactor. In other words: write a failing test, write code to make the test fast, and then make the code better (having the test as a safety net).

A Strange Case of Inheritance Behavior

While working some code to work with the Zuora SOAP API, I got bit by a strange case of inheritance behavior. It would seem that this is related to what self is bound to during the execution of the statement. Here it is, distilled to its essentials:

2016 04 08 Linklog

Here’s this week’s linklog:

Producing Documentation for your Rails API
The Making of an Expert
Apprenticeship Patterns
So Good They Can’t Ignore You
Architecture: the Lost Years

String Interpolation with Templates Using String#

I was working on a feature for upcloudify that will use Slack notifications instead of email notifications. One of the challenges I faced was how to build-in flexibility for generating messages. I would want that the user be able to provide their own custom notification message, but at the same time be able to provide placeholders for items like the S3 download link.

Opalbox—Run Ruby Code Inside Pages

Opal is a Ruby to JavaScript compiler, and OpalBox is a jQuery plugin to easily create a textarea that can take ruby code and allow it to run.

I just added OpalBox to this blog and it’s been quite interesting. I’ve learned how to resize a textarea based on its content (you need javascript to do that because CSS just doesn’t cut it) and I’ve added in a shortcode.

update:

Angelmmiguel (the author of opalbox) has just released 0.1.0 that fixes the issue :)

Exploring Query Objects

A CodeClimate Article gave a number of ways to decompose fat ActiveRecord models, and one of them was: Extract Query Objects. I’ve been trying to explore and get myself familiar with a good standard of how to implement Query Objects, and here is my take.

I’ll be trying out a new format in these articles. I’ll be using something of a Q/A style similar to Socratic Questioning

Using Hash Fetch

I fat-finger my code a lot and produce a lot of typos. I do test driven development so it’s not as bad, but what’s annoying is when I typo a hash key and the test blows up with a failure due to a nil – resulting in a very confusing error message.

ActiveRecord and Forty Two

I was making a gem to have Google Spreadsheets as the backing store for an ActiveRecord adapter when I came upon this interesting method:

Safely Passing Ruby Code in a Rake Task

I wanted to make a rake task that would accept something like 1.month or 1.day as one of it’s arguments. The immediate tool I reached for was eval and it worked like a charm. However, Code Climate (the tool we use to check for static analysis) complains about eval and understandably so; the use of eval is a practice full of danger and security vulnerabilities.

I’m using it inside a rake task that is never exposed to third parties, and anyone malicious enough to run the rake task with a bad parameter to be eval’d would already have had access to the system anyway, and able to wreak even greater havoc than by running the malicious code through the rake task. I believe this is an accepted risk scenario, and Crystal (one of my colleagues who was reviewing my code) suggested that since I had a valid point, I can just turn off the Code Climate check for this particular instance.

I thought that was justified, but I also thought it was a slippery slope. I’m sure there are ways to pass in a string and have it dynamically interpreted, without having to expose the system to a security vulnerability.

Ruby Development in Windows Revisited

Some time ago I wrote about how I set up my machine so I can program hassle-free in ruby while running Windows. It was more of a reminder to myself than anything, if I ever needed to set things up the same way again.

Fast forward to 2015. When a colleague saw my workstation and realized I was running Windows, he was quite surprised and asked me how I was doing it. I thought of pointing him to my old blog post, but I felt that:

  • It was outdated (the setup described was from 2012, written in 2014)
  • It was incomplete (it’s just a checklist of what I’ve installed)

I’ve improved on the whole setup since, and I thought it’s time to share the whole updated setup so that anyone else interested can benefit.

Using Dependency Injection and yield to Refactor a Legacy App

I had to create an automated report for finance and accounting that will send particular columns and their data in a csv once a month.

Being the lazy developer that I am, I tried looking for code that already existed. I was planning to wrap up that code in a rake task and use whenever to schedule a cron job to send the report monthly.

While I was able to find pre-existing code that did what finance wanted (I checked with them as well if the output showed what they needed), the code itself wasn’t easily convertible to a rake task.

Preparing for a Hackathon: Choosing Your Platform

One of the best things you can do during your hackathon presentation is to have your hack available on a publicly accessible platform. You can definitely just host your app in your local machine for the demo, but it is more powerful and impressive if you can involve everyone else in a room and get them to play with your hack during your demo.

Setting Up and Automating my Hugo Blog Deployment to Github Pages

Update

This is largely obsolete. I have setup a new process to deploy to Amazon S3 amd I recommend it over Github Pages.

I’m currently moving my blog posts (and collecting all my blog entries from various blogging platforms) and putting them into Hugo. In case you’re wondering how I’ve set mine up, here’s a guide of what I’ve done.

Redoing my Blogs

Yet again I’ve ported my blog into yet another blogging platform - Hugo. I feel so strongly that I’d be staying for quite some time on this platform that I’ve been porting over all my other posts in all my other various blogs over here.

It’s quite an interesting blogging platform. It outputs static files, which means hosting options are very cheap with a wide variety of providers.

How I Hire Developers

I was invited to pressent at the KL Ruby Brigade and I thought I shuld mix things around by talking about something not very technical but still very much relevant to the audience.

Since I’m in charge (but saying “in-charge” is a bit of a misnomer since in Mindvalley we don’t really have predefined job descriptions) of the internship program for new tech hires, I figures I should share some of the things I consider when interviewing and hiring people.

Getting Data From a Join Table in Rails

A friend asked in my Ruby Facebook group about a problem he was having that I feel I’ve encountered before (or will be encountering in the future). It’s about having to retrieve data that is associated with a join table.

Here’s the question:

I have set ActiveRecords models like these

I want to do something like current_user.boards.first.role which I expect to load the membership details of current_user AND the first board. Do you have any idea how can I achieve this? Do you suggest another approach?

Setup and Configuration of my Machines

Work In Progress

I’m still in the middle of writing this article, and I probably will be always updating this.

I’ve just recently (re)installed Linux on my Acer V5 122p. Had to fiddle around with UEFI settings thinking to preserve my Windows 8.1 partition, but eventually I had to bite the bullet. I wiped the whole partition clean and turned off UEFI so my installation would be a lot simpler.

API Documentation with Grape and Swagger

TL;DR Use Swagger and Grape to create self-documenting APIs that automatically update themselves from metadata in the code. It also provides an API explorer to play around with.

During the AngelHack KL event, I (being the backend developer of the team) had to create an API to facilitate communication between the iPhone app and Twilio. Since it was a hackathon, there was not a lot of time to completely hash out API protocols (as well as explaining to my team mates how RESTful APIs work).

I was able to solve this by using Grape and Swagger. I can develop the API at my own time. When a particular endpoint was finished, I can push to production and my team mate is immediately able to see the documentation. He was also able to make use of the API explorer to test out the API’s responses to his queries.

We were able to quickly develop the whole project quickly and easily because of this, and here’s a quick look at using Swagger with Grape.

Maker's Schedule, Manager's Schedule

Paul Graham’s (of YCombinator fame) essay on the difference between the Maker’s Schedule and the Manager’s Schedule is a timeless piece of advice that is sadly not as well known as it should be. The essay provides an interesting, if not logical reason behind why programmer’s skip meetings called by managers, while managers often tend to interrupt programmers.

Here are some of the important points in his essay:

Ruby Development in Windows

I’ve done the unthinkable and I have a confession to make.

I’ve switched my development machines to Windows.

Here’s the story of my heresy … and my possible salvation.

Ruby and Blocks

One of the most often used and ironically least understood concepts in the Ruby programming language is the block. If you’ve used one of the Enumerable mixed-in objects, you’ve encountered the block syntax.

Install ruby-2.0.0-p195 on Ubuntu 12.04

It’s always easier to deal with a ruby binary that’s installed server-wide rather than a local user installation (done via rvm or rbenv). Server initialization scripts don’t need to do path magic and profile sourcing in order to find the correct binary. Here I how to install ruby-2.0.0-p195 in a way that your system administrator will love you for.

Rolling Restarts with Capistrano and Linode

Here I show how to perform a rolling restart using Capistrano, and making sure that the load balancer (in this case Linode) properly reroutes traffic to the still-running servers while the others are being restarted.

WARNING I’m still ironing out a few bugs for the rolling deployments. The issue appears to be that Capistrano executes deploy:create_symlink in parallel so the apps still experience downtime before the restart happens. The concept itself is sound but the code is not yet production ready!!

Running PrivatePub/Faye Standalone in Heroku for Free

PrivatePub is an awesome gem by the renowned Ryan Bates of Railscast fame. It provides an easy way to use Faye as a pubsub provider. Watch this episode to see it in action.

You don’t have to bundle the gem with a Rails application though; you can deploy PrivatePub standalone as a rack application in Heroku. This allows you to run PrivatePub in a web dyno instead of a worker, allowing for easier maintenance (separation of repositories/codebases) and as a side effect, save on hosting costs.

My Development Setup

At Mindvalley employees can have any kind of hardware/software they want, provided that they can prove it is necessary for the work they’re doing, or at least it increases their productivity. In my case, I opted for the setup as seen here (picture courtesy of my colleague):

View this post on Instagram

@parasquid's #workstation #mindvalley

A post shared by Wu Han Ngeow (@ngeow) on

Look, Ma! Four eyes!!

(the blank monitor on the left was an Ubuntu VM on screensaver mode)

Having Fun With Remote Shells

I just bought a VPS (virtual private server) a couple of days ago, and I’m enjoying tinkering with it. It’s not the most powerful beast though; it only has 64MB RAM and 128MB swap. I won’t say the name of the company I’m subscribed to since my box isn’t exactly the bastion of security, but you should be able to discern the shell provider from how I describe my escapades :D

Recommended Programs

While mucking around my computer and generally getting bored, I found a few neat programs to install. They’re really cool, and your Linux computer shouldn’t be without them :)

  • Firefox AdBlocker - blocks ads from websites. Definitely heaven sent, as browsing becomes faster without all those ads being loaded (the extension dynamically modifies the page to comment out the ads, so they don’t get rendered). You can get to choose which ones to block too. Get the AdBlocker and teach those popup advertisers a lesson.
  • Yakuake - cool konsole for KDE. Anyone who had played quake before would recognize the interface. No need to reserve a space for the taskbar entry in the main panel. Plus, a terminal emulator is just one keypress away :)
  • kde WorldClock - nice way to impress your friends by showing you are a “Citizen of the World.” Set this as your desktop background and you’ll immediately know if it’s day or night in a particular region of the Earth.

Reinstalling Kubuntu

My data drive had some corruption as regards its file system tree, and i was forced to rebuild it. I figured I’ll just reinstall Kubuntu too since I inadverdently installed Ubuntu Desktop, which kinda doubled the applications I have on the menu.

Here are some of the things I did in order to remind myself in case my system crashes again:

  • Make a dos partition writable - the options in fstab for the partition should be: user,exec,rw,umask=000 0 0
  • Get Automatix and install some of the necessary non-free software
  • Install packages used for compiling source code: sudo apt-get install build-essential

I’ll add to the list as I walk through the rebuilding of my settings.