Pages

Thursday, January 7, 2016

The inspiration that Seth Macfarlane is to me

From an article titled "Why do we still believe in Astrology":

...  the entire system does everything it can to remove us from being
present with our situation. Instead of dealing with our own
insecurities, fears and uncertainties, we turn to the cosmos for a
reason. And there is certainly no dearth of folk ready to offer one
up.

Perhaps the best response I’ve heard to this mindset was given by
actor/writer Seth Macfarlane last week. Having discussed the random
nature of the universe in his new show, ‘Cosmos: A Spacetime Odyssey,’
starring Neil deGrasse Tyson, Bill Maher asked him how he replies when
someone says to him, ‘You know, everything happens for a reason.’
Without missing a beat, Macfarlane replied,

This was not the coffee that I ordered!

http://bigthink.com/21st-century-spirituality/why-do-we-still-believe-in-astrology

Friday, May 1, 2015

Rename file in Sublime Text 3

To rename a file in Sublime Text 3, install the following package.

git@github.com:brianlow/FileRename.git

Clone the package:
git clone git@github.com:brianlow/FileRename.git

Copy the package in the following directory (OS X):
~/Library/Application Support/Sublime Text 3/Packages/User

Restart Sublime Text and press CMD+SHIFT+P. In the textbox type 'File Rename'. When the package is highlighted, press Enter. You will be able to rename the current file.



Tuesday, February 24, 2015

Testing with Ruby

To get started with Ruby testing, I am using RSpec ruby framework.
http://rspec.info/

To use RSpec, first you will need to have the gem "guard" which is a command line tool to work with RSpec.
$ gen install guard.

$ bundle exec guard list
This will give you a list of frameworks installed and ready for guard to work with.

After that run
$ bundle exec guard.

This will take you to the guard prompt . Do the following to run all tests.

$ guard(main)> all rspec.

You are up and running!

Ruby Installation

Introduction:

Assumes:
* You already have a Ruby project which you want to set up with little or no Ruby knowledge.
* You are on OS X.

I am off to learning Ruby for my new project. It makes me both excited and scared at the same time as I love learning new languages and tools but Ruby is a different beast than any I have tamed before. My understanding of Ruby leads me to believe that Ruby is:

1. A server side language.
2. Very different syntax than C, C++, and Java.
3. Is more than Ruby itself; there are gems and rails I don't know about.
4. It can be used to host apps on cloud servers like AWS.

It is a personal journey and like any other beginner, I am pretty sure the above four bullets will need to be modified once I develop more understanding.

Installing Ruby:

I have started by watching the following course videos:
https://onemonth.com/courses/one-month-rails

Installing Ruby using homebrew resulted in the installation of ruby 2.2.0p0 (2014-12-25 revision 49005). Turns out I need 2.1.5. So using the rbenv to make changes and install the specific version:
https://github.com/sstephenson/rbenv#installation

$ rbenv install 2.1.5

in ~/.bash_profile, add
export PATH="/Users/{home}/.rbenv/versions/2.1.5/bin/":$PATH
where {home} is your own user name.

$ rbenv rehash

$ eval "$(rbenv init -)"

$ gem install bundler

(Deviating but a necessary step is: $brew install qt; $brew linkapps qt) .

Run "$ bundle install" from your Ruby project folder in which "Gemfiles" exist.

Getting Postgres running:

Install Postgress.app from http://postgresapp.com/.

Use commands:

$ createuser -s -r postgres
$ rake db:create
$ rake db:migrate
to create and get the db running.

Install Pow.cx:
From http://pow.cx, install Pow.cx. This utility will get your Ruby server app running without setting up a whole lot of configuration. Just create a symlink to your app in .pow as mentioned on the page.

There you go. If you have symlinked your project to "myapp" you should be able to type http://myapp.dev in your browser and see your app running.



Thursday, August 7, 2014

Change the name of remote git branch

Warning: Reader is strongly encouraged to take a backup of the local repository before performing the steps mentioned in this post.

This post is intended to guide the reader about how to change the name of a remote branch in Github. Suppose there is a branch named feature/branch_a, and it is to be renamed to test/branch_a. The initial remote and local repositories may look something like this:

Remote:

enter image description here

Local:

enter image description here
* Command(s):
-  git branch -v (Shows a list of all branches, with current branch highlighted)

With the branch feature/branch_a checked out, create a new branch with the name test/branch_a.

enter image description here
* Command(s):
-  git branch -v (Shows a list of all branches, with current branch highlighted)
-  git checkout -b test/branch_a (Creates a new branch and at the same time switches to the branch)

Push the branch on the remote server, and then delete the older branch from both remote and local repositories.

enter image description here
* Command(s):
-  git push --set-upstream origin test/branch_a (link locally create branch to the remote server, and push it)
-  git push origin :feature/branch_a test/branch_a (Deletes branch from remote and replaces it with the new one)

That is it! You are good to go.

enter image description here

Enjoy!

Thursday, July 31, 2014

Use Jekyll to create a blog and host it on Github

Github is an attractive option for hosting a technical blog. The process is as simple as creating a repository, and adding index.html to it. Details can be looked up at https://pages.github.com/. Github uses Jekyll to generate the site. Jekyll is a simple, blog aware, static site generator. Using markup for the blog entries is one of the features of Jekyll. The installation can be done via gem ruby tool. http://jekyllrb.com/docs/quickstart/
Once installed, follow the following steps:
  • Clone the github page repository.
    git clone abc.github.io
  • Create a new file in the local git repository.
    touch Gemfile
  • Edit the file and put the following lines in it.
    source 'https://rubygems.org'
    gem 'github-pages'
  • Install Bundler http://bundler.io/
    gem install bundler
    bundle install
  • To run Jekyll with Bundler, issue the following command in the root repository.
    bundle exec jekyll serve
  • The site should now be available at:
    http://localhost:4000
More can be read about working with Jekyll at http://jekyllrb.com/docs/structure/. A very good example can be found at https://github.com/maciakl/Sample-Jekyll-Site/.