Kill All Processes


  • Must have a UNIX terminal


to kill by name one can type:

ps -ef | grep ${NAME}

after you will retrieve a list of all the processes with that name then all thats left is to

kill -9 ${pid}

passing in the respected pid


To kill all processes of a username its as simple as

pkill -u ${username}

Hope this saves you a little bit of time.




Flyway with MAVEN


  • Have a project setup using MAVEN
  • The example will be connecting to a MYSQL database but FLYWAY can connect to several different types of databases

What is Quick Search?

Flyway is a tool used to manage a scheme across several developers. Using GIT or SVN flyway allows you to commit SQL that other developers will pull down and using the flyway:migrate command the needed SQL queries will be performed to their database. The process for getting FLYWAY stood up is fairy straight forward and for any further documentation can be viewed HERE.


First and for most lets add the FLYWAY plugin to our pom.xml file. So open up your pom.xml file and add the following snippet:


The above snippet is to connect to a MYSQL database however many different types of databases can be connected to. To connect to different databases you would need the change the dependency to use the correct connector for your db.



  • {IP_ADDRESS} with the ip address of your database instance.
  • {PORT_NUMBER} with the port number to connect to your database instance.
  • {DATABASE_NAME} with your database name.
  • {USERNAME} with a user to connect to the database with.
  • {PASSWORD} with the password for the user to use to connect to the database.


mvn clean package

To pull down any FLYWAY artifacts that aren’t in your local repository yet.

Next you need to create the directory:


under your “resources” directory. This is the default location of where FLYWAY is looking for new scripts to be executed.

Next up run:

mvn flyway:baseline

This command will create a new table called “scheme_versions” that FLYWAY uses to know which scripts have and have not been executed.


Now lets test it out by adding a dummy file under the “db/migrations”  called “V1_1__Create_dummy_table.sql” with the following content in it:

create table DUMMY1 (
    ID int not null,
    NAME varchar(100) not null

Notice the same of the script. All scripts in this directory must be called “V{VERSION_NUMBER}__{DESCRIPTION_OF_SQL_SCRIPT}.sql“. FLYWAY parses the version part of the file name to keep an index of which scripts have/havent been executed yet.

To run any pending migrations (any migrations in this directory that have yet to get applied to your database) run the following command:

mvn compile flyway:migrate

And there you have it. Your project is now integrated in with FLYWAY!

Go you!





Practice World Geography

World geography has always been a weak point for me but recently I found a website to help improve it. If you are also looking to improve your knowledge of other counties/capitals/and locations I recommend visiting HERE. It provides study cards, tests, matching games, and more of all of the countries and capitals.

Hope you enjoy.

Chrome Quick Search


  • Google Chrome is installed (can be download HERE)

What is Quick Search?

Quick Search is a built in tool that Google Chrome offers to be able to jump right to a search on other websites such as youtube, wikipedia, amazon, etc. Based on how we use these sites it could add up to saving a decent amount of time and takes very little effort on getting it setup.


For this guide we will walk through setting up quick search for YOUTUBE, AMAZON, and  WIKIPEDIA.

First of all open up Google Chrome and go to Settings.

Then click the “Manage Search Engine” button on the screen.

A popup of all of the currently supported search tools should appear (as depicted below). As you can see websites such as wikipedia and amazon are already shown on this list. First we will make them a little bit easier to use with quick search. Lets change the second field of each of them to what is shown in the picture.

Search Engine Settings

After Applying that setting when you type




in the navigation bar you will automatically search either wikipedia or amazon.

Now lets add youtube to this list.

So navigate back to Settings -> Manage Search Engines popup and go down to “Other Search Engines”

Fill out the boxes with:

Add a new Search Engine: youtube
Keyword: y
URL with %s in place of query:

Click done and now you can just type


to quickly search anything on youtube

Elasticsearch Ruby on Rails intergration


  • Ruby on Rails installed
  • Basic project created
  • Basic knowledge on Ruby on Rails
  • Mac or Linux OS
  • Homebrew is installed (If not, follow the instructions located HERE)

What is Elasticsearch?

Elasticsearch is a easy to use, free search engine that has recently been picking up steam in the market. It is developed by “Elastic” who has developed a number of tools including Logstash and Kibana (Which i will be going over when i find the need to integrate them into my current project). To view more about Elasticsearch visit their website located HERE.


First of all we need to download Elasticsearch

brew install elasticsearch

now start it up

elasticsearch --config=/usr/local/opt/elasticsearch/config/elasticsearch.yml

to verify that elasticsearch is up and running curl localhost

curl -X GET http://localhost:9200

to retrieve the given output

  "status" : 200,
  "name" : "Nameless One",
  "version" : {
    "number" : "1.2.2",
    "build_hash" : "9902f08efc3ad14ce27882b991c4c56b920c9872",
    "build_timestamp" : "2014-07-09T12:02:32Z",
    "build_snapshot" : false,
    "lucene_version" : "4.8"
  "tagline" : "You Know, for Search"

Good job, you now have elasticsearch installed and running. Next we will be integrating it into our Ruby on Rails project. To do this we will be using the “elasaticsearch-rails” gem who’s github documentation is available HERE.

First of all lets add the gems to our Gemfile

gem 'elasticsearch-model', git: 'git://'
gem 'elasticsearch-rails', git: 'git://'

and run bundle install

bundle install

Next we need to let ruby know which models we wish to be searchable by elasticsearch. To do this we need to change our model a little bit. I want my “Movie” model to be searchable so that is the one I’m going to be changing.

require 'elasticsearch/model'

class Movie < ActiveRecord::Base
  include Elasticsearch::Model


Notice I added the require and inclusion of the elasticsearch/model

Now we need to create the appropriate index in elasticsearch and import our models associated data. To do this it is easiest to open the rails console

rails c

and initialize the index importing the current data

Movie.index force: true

That is all it takes to setup and map elasticsearch to a model. To verify it you can now search in that given application via"Titanic")

and retrieve relevant results. For more in-depth documentation please visit this gems details page located HERE.

Ruby recommendation engine done easy


  • Ruby on Rails installed
  • Basic project created
  • Basic knowledge on Ruby on Rails
  • Mac or Linux OS


For this how to blog we will be adding a recommendation engine to an existing Ruby on Rails project. The recommendation gem which we will be leveraging is “recommendable” which can be viewed on github HERE and additional documentation can be viewed HERE. Before we begin it is mentioned that there is a limitation to using this gem. The limitation is that using this gem only one model will be able to have a recommendation engine associated to it. If that is not a issue then let us proceed.

To get things started let us add the following line to our Gemfile

gem 'recommendable'

and execute

bundle install

to install the gem and all of its dependencies.

Next up we need to create a new file in the config/initializers directory. The content of this file should look like:

require 'redis'

Recommendable.configure do |config|
  # Recommendable's connection to Redis
  config.redis = => 'localhost', :port => 6379, :db => 0)

  # A prefix for all keys Recommendable uses
  config.redis_namespace = :recommendable

  # Whether or not to automatically enqueue users to have their recommendations
  # refreshed after they like/dislike an item
  config.auto_enqueue = true

  # The number of nearest neighbors (k-NN) to check when updating
  # recommendations for a user. Set to `nil` if you want to check all
  # other users as opposed to a subset of the nearest ones.
  config.nearest_neighbors = nil

after that you need to modify the Model you wish to add the recommendation system to. Im going to modify the User model because that is where I’m adding it.

class User < ActiveRecord::Base
  recommends :movies, :books

As you can see, all you need to do here is add a line linking recommends to different existing database tables.

Now all you need to do is install redis which is a queuing system the recommends gem uses. This can be done easily on mac with the following line:

brew install redis

Or on linux via:

sudo apt-get install redis-server

Once it is installed configure it to startup at login

ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

 and restart your server and you are good to go. For information on how to use the gem please visit

Ajax requests for partial renders for Ruby on Rails


  • Ruby on Rails installed
  • Basic project created
  • Basic knowledge on Ruby on Rails


Consider the basic scenario…

You have one div in the view you wish to be refreshed with different content when a button is clicked however you do not with the entire page to be redrawn.

So in my index method one could have:

# /controller/movie_controller.rb
def index
  @movie = Movie.first

And for simplicity sake, the view for this controller could be:

# /views/movie/index.html
<%= render partial: "movie_media_box", locals: {movie: @movie} %>

This renders the html located in the “/views/movie/_movie_media_box.html.erb here and passes it the “movie” variable. A basic partial to be changed would look like:

# /views/movie/_movie_media_box.html.erb
<div id=movie-<>>

Now, the button you wish to trigger the changing of this div should look something like:

# Anywhere you want it
<%= link_to "change", {:controller => "movies", :action => "change_movie", :id =>}, :remote => true%>

What this is doing is creating a link which will call the “change_movie” method in the “movies” controller passing it “id” as a parameter. The “remote =>true” is letting rails know to handle this as a ajax request.

The “change_movie” method should look similar to:

# /controller/movie_controller.rb
def change_movie
  @previous_id = params["id"]
  @new_movie = Movie.last
  respond_to do |format|

Notice how this is not returning a html file, instead it is returning a JS file which is named “/views/movie/change_movie.js.erb”. In this file is where will be changing the content of that div.

# /views/movie/change_movie.js.erb
$("#movie-<%=@previous_id%>").html("<%= escape_javascript(render partial: 'movie_media_box', locals: { movie: @new_movie } ) %>")

This is using jQuery to find the div with the id “movie-X” and replace the html inside of it with the partial “movie_media_box” passing it “@new_movie” instead of the previous movie being used.

And thats it, you now have a basic ajax request working for partial renders for Ruby On Rails!

I referred to: to get my first understanding on how to do this.