November 14, 2014

How to Listen to Podcasts

In the interest of using the best tool for the task, I've found that a simple zsh shell script is, by far, the easiest way to listen to podcasts, especially when used with the venerable mplayer:

November 11, 2014

How to Automate Your Rails Devops

This blog is all about automating my life, so that I can focus on what humans are good at and leave computers to focus on what they're good at. I live the dictum that figure it out once, automate it and forget about it. And by forget, I mean blog. I just added a mina autodeployment script for todo and I've decided to share my script below. So, without further ado, here we are:

# config/deploy.rb
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
# require 'mina/rbenv'  # for rbenv support. (
require 'mina/rvm'    # for rvm support, like todo does. (

# Basic settings:
#   domain       - The hostname to SSH to.
#   deploy_to    - Path to deploy into.
#   repository   - Git repo to clone from. (needed by mina/git)
#   branch       - Branch name to deploy. (needed by mina/git)

set :domain, ''
set :deploy_to, '/home/hdiwan/todos'
set :repository, ''
set :branch, 'master'

# For system-wide RVM install.
#   set :rvm_path, '/usr/local/rvm/bin/rvm'

# Manually create these paths in shared/ (eg: shared/config/database.yml) in your server.
# They will be linked in the 'deploy:link_shared_paths' step.
set :shared_paths, ['config/database.yml', 'log']

# Optional settings:
#   set :user, 'foobar'    # Username in the server to SSH to.
#   set :port, '30000'     # SSH port number.
#   set :forward_agent, true     # SSH forward_agent.

# This task is the environment that is loaded for most commands, such as
# `mina deploy` or `mina rake`.
task :environment do
  # If you're using rbenv, use this to load the rbenv environment.
  # Be sure to commit your .rbenv-version to your repository.
  # invoke :'rbenv:load'

  # For those using RVM, use this to load an RVM version@gemset.
  invoke :'rvm:use[ruby-2.0.0@todo]'
  # Probably should use mina-scp, but what the hell, this works well.
  system 'scp ./db/development.sqlite3'

# Put any custom mkdir's in here for when `mina setup` is ran.
# For Rails apps, we'll make some of the shared paths that are shared between
# all releases.
task :setup => :environment do
  queue! %[mkdir -p "#{deploy_to}/#{shared_path}/log"]
  queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/log"]

  queue! %[mkdir -p "#{deploy_to}/#{shared_path}/config"]
  queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/config"]

  queue! %[touch "#{deploy_to}/#{shared_path}/config/database.yml"]
  queue  %[echo "-----> Be sure to edit '#{deploy_to}/#{shared_path}/config/database.yml'."]

desc "Deploys the current version to the server."
task :deploy => :environment do
  deploy do
    # Put things that will set up an empty directory into a fully set-up
    # instance of your project.
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'
    invoke :'rails:db_migrate'
    invoke :'rails:assets_precompile'
    invoke :'deploy:cleanup'

    to :launch do
      queue "mkdir -p #{deploy_to}/#{current_path}/tmp/"
      queue "touch #{deploy_to}/#{current_path}/tmp/restart.txt"

# For help in making your deploy script, see the Mina documentation:
#  -
#  -
#  -
#  -

The only thing I have to do manually is restart the server.

November 4, 2014

How to Keep Track of Tasks #2

I did add multiple user support and updated the application serverside. The next few steps are to add full JSON support and allow for Google and Facebook login. The source code has been updated and checked in. The tl;dr of the changes is that devise was used for multiuser support.

November 2, 2014

How to keep Track of Tasks

I just wrote and open-sourced a task management system. You can download and set it up on your system by the following:

  1. Install the latest ruby 2.0, sqlite, and git.
  2. gem install bundler --no-ri --no-rdoc
  3. git clone
  4. gem install rails --no-ri --no-rdoc
  5. in the todos directory, run bundle and it will install all necessary dependencies.
  6. Now try rails server
  7. Point your browser here and you'll see it ask you for a username/password (the username is "hd1" and password is "December" by default).
  8. Oh, and, if you want to process the data programmatically as json, you can grab a read-only view of it here, following authentication. These instructions are tested on Mac, Windows7 and Unix. If you should have any problems, do leave a comment.

October 29, 2014

October 22, 2014

How to Sign Gmail Using PGP

The shell script below, written using bash takes the contents of the clipboard, signs it with GPG and pastes the signed content on the clipboard. The pbcopy and pbpaste commands are Mac-specific, so it restricts you to that platform.

October 18, 2014

How to Manage pf Rules

The above script manage a pf ruleset. It does rely on your services file being located at /etc/services, which if you're using pf, ought not be a problem. Planned functionality include allowing for destination-specific rules, writing to remote locations, differentiating UDP, TCP, and ICMP, and anything else the lot of you leave a comment requesting. If you get impatient, the source will always be in the embed above.