Skip to content

Instantly share code, notes, and snippets.

@deepakkumarnd
deepakkumarnd / postgresql_db_setup.sh
Created July 29, 2018 05:35
Install and setup postgresql in ubuntu for rails application
# script has to be run as root
apt-get update
apt-get install postgresql postgresql-contrib
apt-get install libpq-dev
su - postgres
createuser --interactive
---
# The paths in which to look for gems
# :gempath:
# Force specification of gem server host on push
# disable_default_gem_server:
sources:
- http://gems.rubyforge.org/
- http://rubygems.org/
@deepakkumarnd
deepakkumarnd / command_center.sh
Created February 2, 2017 15:15
Linux command help snippets
# Check if a port is open using iptables
$ iptables -nL | grep
@deepakkumarnd
deepakkumarnd / Rakefile
Created November 17, 2016 07:13 — forked from schickling/Rakefile
Activerecord without Rails
require "active_record"
namespace :db do
db_config = YAML::load(File.open('config/database.yml'))
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'})
desc "Create the database"
task :create do
ActiveRecord::Base.establish_connection(db_config_admin)
@deepakkumarnd
deepakkumarnd / benchmark.sh
Created November 4, 2016 11:49 — forked from peterjmit/benchmark.sh
Bash Benchmark Script (using time)
#!/bin/bash
# REQUIRES SUDO
# Benchmark runner
repeats=20
output_file='benchmark_results.csv'
command_to_run='echo 1'
run_tests() {
# --------------------------------------------------------------------------
What is docker ?
Docker is a container runner/manager. Docker containers wrap up a piece of software
in a complete filesystem that contains everything it needs to run: code, runtime,
system tools, system libraries – anything you can install on a server. This guarantees
that it will always run the same, regardless of the environment it is running in.
## Install (ubuntu 14.04)
$ uname -a
What is docker ?
Docker is a container runner/manager. Docker containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, runtime, system tools, system libraries – anything you can install on a server. This guarantees that it will always run the same, regardless of the environment it is running in.
@deepakkumarnd
deepakkumarnd / query.rb
Last active August 29, 2015 14:24 — forked from austenito/query.rb
if Moped.logger == Rails.logger
Moped.logger = Logger.new($stdout)
true
else
Moped.logger = Rails.logger
false
end
@deepakkumarnd
deepakkumarnd / simple_expression_evaluator.rb
Last active August 29, 2015 14:19
simple expression evaluator
PRECDENCE = {
'(' => 0,
')' => 0,
'+' => 1,
'-' => 1,
'*' => 2,
'/' => 2
}
class Expression
@deepakkumarnd
deepakkumarnd / extract_options.rb
Last active August 29, 2015 14:19
Extracting user supplied options
...
# possible options and possible values
# use nil to use any values
VALID_OPTIONS = {
type: %w(default success info warning danger),
name: nil
}
...