Skip to content

Instantly share code, notes, and snippets.

View vnykmshr's full-sized avatar

Vinayak Mishra vnykmshr

View GitHub Profile
@vnykmshr
vnykmshr / install-node.sh
Created September 30, 2013 11:09
Installs node.js from source. Also installs missing libraries needed to run node.js. Update node version to latest stable release.
#!/bin/sh
## Install pre-requisites
sudo apt-get install -y git-core build-essential openssl libssl-dev pkg-config
## Ensure python <3 is available
ret=`python -c 'import sys; print("%i" % (sys.hexversion<0x03000000))'`
if [ $ret -eq 0 ]; then
echo "we require python version <3"
mkdir /tmp/bin; ln -s /usr/bin/python2.7 /tmp/bin/python;
@vnykmshr
vnykmshr / email-check.js
Last active December 25, 2015 14:09
Simple Email Validations
/**
* Simple email validation
* ensures at least one `@` sign, at least one char in local part,
* at least one `.` in domain part and is at least one char long
*/
isEmail: function (em) {
em = em || '';
var indx = em.lastIndexOf('@');
return indx > 0 && (em.lastIndexOf('.') > indx) && (em.length - indx > 1);
}
@vnykmshr
vnykmshr / install-nagios-client.sh
Created October 15, 2013 11:28
Download and Install Nagios client plugin along with NRPE plugin. This script is written for a Ubuntu server but you can easily modify it to suit your needs. Post installation, modify `/etc/xinetd.d/nrpe` to restrict request origin, update `/etc/services` to add `nrpe` service.
#!/bin/bash
# Nagios client install script
# Vinayak Mishra <viks@vnykmshr.com>
set -e -x
# ensure only root can run the script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
@vnykmshr
vnykmshr / robots.txt
Created October 18, 2013 22:31
Who exactly is crawling your site? Find out more - http://danbirken.com/seo/2013/10/17/who-exactly-is-crawling-my-site.html. Adding author's robots.txt here for reference.
User-Agent: Googlebot
Allow: /
User-Agent: Googlebot-Mobile
Allow: /
User-Agent: msnbot
Allow: /
User-Agent: bingbot
@vnykmshr
vnykmshr / magento-varnish-3.0.config
Created March 12, 2014 13:53
Magento varnish 3.0 config
# This configuration is what is provided by PageCache by Varnish for Magento module:
# http://www.magentocommerce.com/magento-connect/pagecache-powered-by-varnish.html
# default backend definition. Set this to point to your content server.
backend default {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 5s;
.first_byte_timeout = 10s;
@vnykmshr
vnykmshr / magento.vnykmshr.com
Created March 12, 2014 14:00
Nginx server configuration for Magento
server {
listen 8080;
server_name magento.vnykmshr.com;
root /var/www/magento/releases/current;
index index.html index.php;
access_log /var/log/nginx/magento.access.log;
error_log /var/log/nginx/magento.error.log;
location / {
@vnykmshr
vnykmshr / magento-setup.steps
Last active March 9, 2016 08:36
Magento: Nginx + Varnish + Mysql stack
apt-get update
apt-get upgrade
apt-get install mysql-server
mysql_secure_installation
apt-get install nginx
apt-get install git-core
@vnykmshr
vnykmshr / phabricator.sh
Last active February 22, 2016 20:41
Ubuntu phabricator setup
#!/bin/bash
confirm() {
echo "Press RETURN to continue, or ^C to cancel.";
read -e ignored
}
GIT='git'
LTS="Ubuntu 10.04"
@vnykmshr
vnykmshr / latest-nginx.sh
Last active August 29, 2015 13:57
Install latest nginx
# install the Nginx team’s package signing key
curl http://nginx.org/keys/nginx_signing.key | apt-key add -
# Add the repo to apt sources:
echo -e "deb http://nginx.org/packages/ubuntu/ `lsb_release -cs` nginx\ndeb-src http://nginx.org/packages/ubuntu/ `lsb_release -cs` nginx" > /etc/apt/sources.list.d/nginx.list
# Resynchronize the package index files from their sources:
apt-get update
# install nginx
@vnykmshr
vnykmshr / nginx-site-config.conf
Created March 25, 2014 17:24
Nginx config for a sample magento setup
## nginx.conf
#######################################################################
#
# This is the main Nginx configuration file.
#
# More information about the configuration options is available on
# * the English wiki - http://wiki.nginx.org/Main
#
#######################################################################