Bash Scripts for Automate Tasks

Automation is a beautiful thing, right down to our work environments – and if you are developing in a unix-based environment then that would include the command line.

First step is setting up a scripts folder in your working directory:

cd ~/src # your working directory
mkdir bash # create directory
cd bash
vi my_script.sh # create scripts!

Next step, start writing scripts – below is a simple example that I use for preparing the database in my Rails development environment:

#!/bin/bash
migration # alias, setup in my ~/.bash_profile
rake db:seed
rake db:test:prepare

Last step, give your scripts proper executable permission using the unix chmod utility then run them from the command line:

chmod 755 my_script.sh
./myscript.sh # this should run the script...

In conclusion, bash scripts can be used as macros of accomplishing a series of common tasks. If you wish to make them portable, then remember to save them into a repository so that they can be saved onto any other of your machines.

Getting Started with Angular on Rails

 

angularailsAfter struggling with installing Angular into my Rails app, Storm Savvy, I went in search for better answers and found a good resource from Lean Pub on the topic.

I normally turn to Lean Pub when in need of a guide on a specific topic, and this was such a case – the book includes chapters to specific use cases for Angular within Rails.

Where I started initially with a good tutorial from Adam Anderson for bootstrapping Angular into Rails, the Lean Pub book helped fill in the gaps.

Much of my gap in knowledge was in how exactly Angular fits into the Rails asset pipeline and gets loaded with the Rails App.

That said, I still have much to learn on bringing Angular into Rails but have at least moved on from my initial sticking point of loading the app and getting into the inner workings of Angular.

Quick Start Pointers for the Vim Editor

vim

Being my editor of choice, I enjoy developing in vim for its simplicity and light-weight (saving resources for other tasks).

One drawback to getting started is the steep learning-curve – all input vim is done via touch typing which no mouse… NO MOUSE.

Sure, vim has included a visual mode and other modern features but at the core and its major advantage is being able to complete all your tasks without your fingers even leaving the home row of ASDF.

Enough of my personal thoughts on vim, here some quick start pointers for those of you who wish to start on vim:

  1. Follow the tutorials: Practice makes perfect, so practice before you actually practice with your code.
  2. Consider some plugins: I recommend Janus which provides some nice syntax tools but vim has a wide variety of plugins, so feel free to experiment as needed.
  3. The shell is your friend: Using vim means spending more time on the command line, so practice command tasks (e.g. copy, paste, etc.) using the basic bash/unix utilities.
  4. Consult the wiki: Vim has a great wiki containing detailed information on many common tasks and commands.

In conclusion, the initial time investment into vim is reaped later when many tasks can be completed with the shell (between tabs, in my case).