Skip to content

Instantly share code, notes, and snippets.

View datt's full-sized avatar
🏠
Working from home

Dattatraya Dongare datt

🏠
Working from home
View GitHub Profile
@datt
datt / install.sh
Last active January 11, 2021 08:02
rails setup commands on aws
sudo apt-get install git
sudo apt-get install nginx
sudo apt-get install nodejs
sudo apt-get install imagemagick
sudo apt-get install libpq-dev #postgres ext lib required
sudo apt update
sudo apt-get install libmagick++-dev #imagemagick dependency
# Installing Ruby using .rbenv
sudo apt install git curl autoconf bison build-essential \
@datt
datt / crontab
Created April 27, 2016 07:01
Postgres Backup script
Daily backup at 2 a.m.
0 2 * * * /root/scripts/postgres_backup.sh
@datt
datt / postgres_backup.sh
Last active November 6, 2023 10:33
Postgres Backup script
#!/bin/bash -x
export PGPASSWORD=myPGPassword
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#Script Begin
DATE=`date +%d_%m_%Y_%H_%M`
if ! /usr/bin/pg_dump -O -U postgres -h localhost project_production -f /root/backups/postgres/daily/project_production_pg_$DATE.sql; then
/bin/echo "#########################################################" >> /var/log/postgres_backup.log
/bin/echo "Postgres Backup backup failed on `date +%d-%m-%Y`" >> /var/log/postgresql_backup.log
@datt
datt / routes.rb
Last active August 29, 2015 14:19
temperory routes and controller for html pages for #FrontEnd. #tmp #controller create a folder named as tmp in views, whatever is the name of the page, can be in accessed from /page_name. e.g. if page name is /help_desk.html.haml, can be accessed as /help_desk
get '/tmp/:page' => 'tmp#index'
get '/tmp/:page/:inner_page' => 'tmp#index'
@datt
datt / year_range.rb
Created January 12, 2015 16:01
fake year range string
# Usage YearRange.new(2).range_string
# "1990-1991 | 2011-2013"
class YearRange
def initialize(range = 1)
@range = range
@years = (1980..2015).to_a
end
def collect
divide_factor = @years.size/@range
@datt
datt / sublime.yml
Last active November 23, 2016 11:54
#sublime #settings for Rails project : indentation, rulers etc.
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"draw_white_space": "all",
"font_size": 11,
"ignored_packages":
[
"Vintage"
],
"margin": 2,
"rulers":
@datt
datt / gist:7986091
Created December 16, 2013 12:16 — forked from dhh/gist:1014971
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@datt
datt / postgres_useful_commands.sh
Last active April 2, 2017 13:37
useful database commands for dump i.e. backup and restore postgresql and mongodb
#resetting the password of postgresql
sudo -u postgres psql postgres
postgres=# \password postgres
# restoring postgres dump database
pg_restore -c -i -U postgres -h localhost -d database_name -v "dump_file" -W
pg_restore --verbose --host localhost --username postgres --clean --no-owner --no-acl --dbname database_name dump_file.dump
# for mac: full path is required.
Applications/Postgres.app/Contents/Versions/9.4/bin/pg_restore -c -i -U postgres -h localhost -d database_name -v "dump_file" -W
@datt
datt / displayjwplayer.js
Last active December 29, 2015 17:29
Initialize jwplayer for showing video on a element.
function displayVideo(elementID, options) {
var defaults;
defaults = {
height: 347,
width: 624,
swfPath: '/jwplayer/jwplayer.flash.swf',
controls: false,
autostart: true
};
var settings = $.extend({}, defaults, options);
@datt
datt / base_creator.rb
Last active December 29, 2015 13:09
The common creator methods can be written in base creator which can be again overridden by other creators. An example of using creator is also given. To know more about Creator follow (https://github.com/datt/Creators)
class BaseCreator < Creators::Base
EXTRA_PARAMS = [:action, :controller, :format,:utf8,:authenticity_token]
def initialize(raw_params, model)
super(raw_params,model)
end
def refine_params
@params.deep_symbolize_keys.delete_if{|k,v| EXTRA_PARAMS.include? k }