Skip to content

Instantly share code, notes, and snippets.

View n1shantshrivastava's full-sized avatar

Nishant Shrivastava n1shantshrivastava

View GitHub Profile
@n1shantshrivastava
n1shantshrivastava / RequestGenerator.php
Created April 10, 2014 10:37
RequestGenerator, a simple PHP class for handling Curl Request.
<?php
/**
* Class : RequestGenerator
* Type : Component
* @author Nishant Shrivastava <[email protected]>
*/
class RequestGeneratorComponent extends CComponent {
/**
<?php
class Curl {
/**
* cURL request method
*
* @var string
*/
protected $_method = 'GET';
<?php
function http_file_get_contents( $url ) {
$response = file_get_contents( $url );
return $response;
}
?>
@n1shantshrivastava
n1shantshrivastava / readme.md
Last active August 13, 2021 19:56
Send Mail Configuration : Disable Local Delivery

What I did to disable local delivery. I'll be using the example.com domain.

Requirements:

  • example.com A entry pointing to IP address assigned to one of the eth interfaces.
  • /etc/hosts defining example.com assigned to the very same IP address as above
  • example.com MX records pointing to Google servers (ASPMX.L.GOOGLE.COM, etc)
  • default sendmail installation (mine was on Ubuntu)
#!/bin/bash -e
####
# shlog is a bash script that allow you to record a shell session by logging
# command history and giving diff of edited files
####
# User notes:
# - Install:
# Load the script using 'source shlog.bash' (add it to your .bashrc
# to load it automatically)

Mongo DB dump & restore

To dump database

 mongodump --host localhost --port 27017  --db dbname --out dump_dir_name

To dump specific collection

 mongodump --host localhost --port 27017  --db dbname --collection collectioname --out dump_dir_name

##To restore db mongorestore --host localhost --port 27017 dump_dir_name

load 'deploy'
# ================================================================
# ROLES
# ================================================================
role :app, "173.203.86.155:22", {:primary=>true}
role :db, "173.203.86.155:22", {:primary=>true}
@n1shantshrivastava
n1shantshrivastava / virtual_domain_php.conf
Last active December 16, 2015 17:41
[PHP] A simple virtual host cofiguration.
<virtualhost *:80>
ServerName app.com
ServerAlias www.app.com
DocumentRoot /var/www/nishant/blog
ErrorLog /var/log/apache2/blog_error_log
CustomLog /var/log/apache2/blog_access_log common
<Directory /var/www/nishant/blog>
AllowOverride All
</Directory>
</virtualhost>

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
echo "This script requires superuser access to install packages."
echo "You will be prompted for your password by sudo."
# clear any previous sudo permission
sudo -k
# run inside sudo
sudo sh <<SCRIPT
# installing apache
echo ">>> Installing Apache2."