Skip to content

Instantly share code, notes, and snippets.

View rajraj's full-sized avatar

Rajesh Rajappan rajraj

View GitHub Profile
@rajraj
rajraj / gist:1834639
Created February 15, 2012 09:13
Backup and Restore MySql Database
# Backup Mysql database
$ mysqldump -u root -p contracts_production > contracts.sql
# Restore Mysql database from sql file
$ mysql -u root -p contracts_production < contracts.sql
@rajraj
rajraj / .bash_profile
Created March 29, 2012 07:25 — forked from henrik/.bashrc
Git branch and dirty state in Bash prompt.
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
# Edit .bash_profile
$ nano ~/.bash_profile
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
@rajraj
rajraj / sublime_keybinings
Last active October 11, 2015 14:08
Sublime Text Keybinings
[
{ "keys": ["ctrl+shift+z"], "command": "insert_snippet", "args": {"contents": "<%= ${0:$TM_SELECTED_TEXT} %>"}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "text.html, source.yaml, meta.erb" }
]
},
{ "keys": ["ctrl+alt+x"], "command": "insert_snippet", "args": {"contents": "<% ${0:$TM_SELECTED_TEXT} %>"}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "text.html, source.yaml, meta.erb" }
]
@rajraj
rajraj / centos_install_mysql
Last active October 13, 2015 09:28
CentOS: Installing MySQL Database with YUM
$ sudo yum -y update
$ sudo yum -y install mysql-server mysql-devel
$ sudo /etc/init.d/mysqld start
$ sudo /usr/bin/mysql_secure_installation
# To auto-start on boot:
sudo /sbin/chkconfig --level 2345 mysqld on
# Check if the above worked by executing the following command:
/sbin/chkconfig --list | grep mysqld
class Person
attr_reader :name
def initialize(name)
@name = name
end
def introduce
"hello, my name is #{@name}"
end
module FormatAttributes
def formats(*attributes)
@format_attributes = attributes
end
def format_attributes
@format_attributes
end
end
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require File.dirname(__FILE__) + '/blueprints'
require 'faker'
require 'rails/test_help'
require 'minitest/autorun'
require 'minitest/pride'
class MiniTest::Unit::TestCase
include MiniTest::ActiveRecordAssertions
Running `mix ecto.migrate` attached to terminal... up, run.6992
** (Postgrex.Error) tcp connect: econnrefused
(ecto) lib/ecto/adapters/sql/worker.ex:29: Ecto.Adapters.SQL.Worker.query!/4
(ecto) lib/ecto/adapters/sql.ex:187: Ecto.Adapters.SQL.use_worker/3
(ecto) lib/ecto/adapters/postgres.ex:59: Ecto.Adapters.Postgres.ddl_exists?/3
(ecto) lib/ecto/migration/schema_migration.ex:19: Ecto.Migration.SchemaMigration.ensure_schema_migrations_table!/1
(ecto) lib/ecto/migrator.ex:36: Ecto.Migrator.migrated_versions/1
(ecto) lib/ecto/migrator.ex:134: Ecto.Migrator.run/4
(mix) lib/mix/cli.ex:55: Mix.CLI.run_task/2
https://www.youtube.com/watch?v=fzJcrH6dGGs
@rajraj
rajraj / fedora-install-nodejs.sh
Created December 14, 2015 16:51 — forked from trajakovic/fedora-install-nodejs.sh
Install node.js on fedora (23+).(v5.0.0)
#!/usr/bin/env bash
func_check_for_root() {
if [ ! $( id -u ) -eq 0 ]; then
echo "ERROR: $0 Must be run as root, Script terminating" ;exit 7
fi
}
func_check_for_root
#SETUP PARAMS