Skip to content

Instantly share code, notes, and snippets.

View rajeevkannav's full-sized avatar

Rajeev Sharma rajeevkannav

View GitHub Profile
@rajeevkannav
rajeevkannav / mysqldump.rb
Created February 27, 2014 21:13
mysqldump
namespace :mysql do
desc "simple mysql db dump" +
'Can be used as rake mysql:dumpher[backup_location, expected_dumpfile_size, email_notification_required]' +
'For e.g In My case rake mysql:dumpher[/home/rajeev/Public,20,true] RAILS_ENV=production'
task :dumpher, [:target_bucket, :expected_dump_size, :notify] => [:environment] do |t, args|
args.with_defaults(host: 'localhost', target_bucket: '/', expected_dump_size: 25)
_db_config = ActiveRecord::Base.configurations[Rails.env]
_db = _db_config['database']
file = "#{_db}_#{Time.now.strftime('%Y_%m_%d_%H_%M_%S')}.sql.gz"

Commands examples

If the namespace is not used then the commands will perform on top of the default database. bundle exec rake db:create bundle exec rake db:migrate

By using the namespace we are going to use all the configuration for our alternate DB. bundle exec rake store:db:create bundle exec rake store:db:migrate

@rajeevkannav
rajeevkannav / gist:47f7ab1aeba41bd011b2
Last active August 29, 2015 14:04
DoubleLinkedListRuby
class Node
attr_accessor :prev_node, :next_node
def initialize(data)
@data = data
end
def has_next?()
@next_node ? true : false
end
#!/bin/sh
## Description:
## install script of s3fs
##
## Usage:
## install-s3fs.sh [mountpoint] [bucketName] [accessKeyId] [secretAccessKey]
MOUNT_POINT=$1
BUCKET_NAME=$2
@rajeevkannav
rajeevkannav / Ubuntu Developer Script For Ionic Framework
Created October 29, 2014 06:17
Ubuntu Developer Script For Ionic Framework
#!/bin/bash
# Ubuntu Developer Script For Ionic Framework
# Created by Nic Raboy
# http://www.nraboy.com
#
#
# Downloads and configures the following:
#
# Java JDK
# Apache Ant

Postgres 9.2 - Install, Setup and Quick Reference

Set the default template to UTF8

$ su postgres
$ psql -U postgres
psql (9.2.4)
Type "help" for help.
class API::V1::BaseController < ApplicationController
skip_before_filter :verify_authenticity_token
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'
@rajeevkannav
rajeevkannav / RELK.sh
Last active August 29, 2015 14:24 — forked from adionditsak/RELK.sh
#/bin/bash
##########################################################
### INTRODUCTION
##########################################################
: '
Install and configure R (Redis) + ELK server from scratch on CentOS 6.5.
* Logstash version 1.4.2
* Elasticsearch version 1.3.2
Linux-Shell-Script
@rajeevkannav
rajeevkannav / gist:2212477
Created March 27, 2012 04:14 — forked from ascrivner-zz/gist:120346
Deploying a Rails App with EC2 + S3 + Ubuntu
Deploying a Rails App with EC2 + S3 + Ubuntu
============================================
Create EC2 Instance
-------------------
create new instance ami-bf5eb9d6 [http://alestic.com/](http://alestic.com/)
create new elastic ip
attach elastic ip to instance
point dns to elastic ip