Skip to content

Instantly share code, notes, and snippets.

Abhishek Srivastava abhishek77in

Block or report user

Report or block abhishek77in

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Print Margin Setting
var printPage = (function () {
var style = document.createElement('style');
return function (rule) {
style.innerHTML = rule;
printPage.size = function (marginTop) {
printPage('@media print { @page {margin-top: ' + marginTop + 'cm} }');
abhishek77in / nginx.conf
Created Apr 16, 2016 — forked from thewebfellas/nginx.conf
sample nginx.conf for thin
View nginx.conf
user nginx;
worker_processes 5;
error_log /var/log/nginx.error.log;
pid /var/run/;
events {
worker_connections 1024;
abhishek77in /
Created Apr 11, 2016 — forked from blacktm/
A Bash script to install Ruby 2.3 on the Raspberry Pi (Raspbian)
# -----------------------------------------------------------------------
# Installs Ruby 2.3 using rbenv/ruby-build on the Raspberry Pi (Raspbian)
# Run from the web:
# bash <(curl -s raw_script_url_here)
# -----------------------------------------------------------------------
# Set up variables
abhishek77in / subdomain_validator.rb
Created Feb 2, 2016 — forked from stuartbain/subdomain_validator.rb
Custom validator for Subdomains
View subdomain_validator.rb
class SubdomainValidator < ActiveModel::EachValidator
def validate_each(object, attribute, value)
return unless value.present?
reserved_names = %w(www ftp mail pop smtp admin ssl sftp)
reserved_names = options[:reserved] if options[:reserved]
if reserved_names.include?(value)
object.errors[attribute] << 'cannot be a reserved name'
abhishek77in / flatten_hash.rb
Created Aug 8, 2014
Flatten ruby hash, Could be used to convert nested ruby hash (or json) to csv
View flatten_hash.rb
def flatten_hash(hash, results = {}, parent_key = '')
return results unless hash.kind_of?(Hash)
hash.keys.each do |key|
# current_key = "#{parent_key}[#{key}]" # uncomment this if you want to keep parent key as a partof key for flattened hash (csv column name)
current_key = key
if hash[key].kind_of?(Hash)
results = flatten_hash(hash[key], results, current_key)
if hash[key].kind_of?(Array)
abhishek77in /
Last active Dec 16, 2018
Import heroku database to local machine
heroku pg:backups:capture --app sushi
curl -o latest.dump `heroku pg:backups public-url --app sushi`
curl -o latest.dump `heroku pg:backups:url b001 --app sushi`
pg_restore --verbose --clean --no-acl --no-owner -d <app_name>_development latest.dump
# Restore data from trial server
curl -o latest.dump `heroku pg:backups public-url --app labsmart-trial`
be rake db:drop db:create
pg_restore --verbose --clean --no-acl --no-owner -d azurite_development latest.dump
abhishek77in / endless-scroll.js
Last active Dec 26, 2015
Simple script for implementing endless scroll
View endless-scroll.js
var offset = 4;
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > ($(document).height() - 150)) {
offset = offset + 4;
function loadMore(offset) {
View DevOps

Restore postgres database from sql file -

psql <databasename> -U <username> < ~/Downloads/<filename>.sql

Find and replace a word in a directory -

find path-to-directory -type f -not -path "./directory/*" -exec sed -i '' 's/old-word/new-word/g' {} \;

To compress directory with Tar -

abhishek77in /
Last active Dec 19, 2015
Hacker Notes Javascript Frameworks, Web Servers
You can’t perform that action at this time.