Skip to content

Instantly share code, notes, and snippets.

View pawan-yadav's full-sized avatar

Pawan Yadav pawan-yadav

View GitHub Profile
@pawan-yadav
pawan-yadav / gist:cc7525499b3c1e5907d7d3330e702f8f
Created February 1, 2019 06:39
Set Database password on server local
https://www.postgresql.org/docs/9.3/libpq-pgpass.html
home/sd2labs
host:5432:DBNAME:USER:PASSWORD
chmod 0600 ~/.pgpass
@pawan-yadav
pawan-yadav / server.md
Created March 2, 2017 06:10 — forked from jtadeulopes/server.md
Server setup with ubuntu, nginx and puma for rails app.

Update and upgrade the system

sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get autoremove
sudo reboot

Configure timezone

@pawan-yadav
pawan-yadav / contact_batch_email.html.erb
Created February 21, 2017 08:25 — forked from Joseworks/contact_batch_email.html.erb
Send batch emails on ActiveAdmin Rails 4.2.0
<!-- Contact batch email -->
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<div>Name: <%= @name %></div>
<br>
<div>Subject: <%= @subject %></div>
$('#pincode').on('input', function() {
pin = $('#pincode').val();
$('#pincode-value').val(pin);
});
$('#pincode-value').on('input', function() {
@pawan-yadav
pawan-yadav / gist:0d373942913912cbc3f5fe687e1d62ad
Created January 4, 2017 06:55
Rails Model CheatSheet updated version
items = Model
.where(first_name: 'Harvey')
.where('id = 3')
.where('id = ?', 3)
.order(:title)
.order(title: :desc)
.order("title DESC")
.reorder(:title) # discards other .order's
# Rails Models
### Generating models
$ rails g model User
### Associations
belongs_to
has_one
@pawan-yadav
pawan-yadav / gist:bc3b54f4dcbe89cc941de442c6d5a8d2
Created December 29, 2016 12:55 — forked from arjunvenkat/gist:1115bc41bf395a162084
Seeding a Rails database with a CSV file

How to seed a Rails database with a CSV file

1. Setup

First, Create a folder inside of lib called seeds

Put your CSV file example.csv into the lib/seeds folder. In the example below, the file is called real_estate_transactions.csv

Make sure you've created a resource with the appropriate columns to match your seed data. The names don't have to match up.