Skip to content

Instantly share code, notes, and snippets.

View ankibalyan's full-sized avatar

Ankit Balyan ankibalyan

View GitHub Profile
@ankibalyan
ankibalyan / gist:a202d701505dba2e2ac561b1d4bf2363
Last active December 3, 2018 19:19
My Vim Settings (Basic Version) ~/.vimrc
syntax on
set ai
set number
set mouse+=a
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab " use spaces instead of tabs.
set smarttab " let's tab key insert 'tab stops', and bksp deletes tabs.
set shiftround " tab / shifting moves to closest tabstop.
ServerAliveInterval 60
StrictHostKeyChecking no
Host awesome-dev
Hostname xx.xx.xxx.xx
User <username>
IdentityFile ~/.ssh/dev-serverkeyfile.pem
Host awesome-prod
Hostname xx.xx.xxx.xx
User <username>
@ankibalyan
ankibalyan / gist:388d7de1f5475d8ed85b367e490c7551
Created October 9, 2017 09:15
Redirects from nginx based on user agent
# APP redirects
if ($http_user_agent ~* "iphone|ipod|ipad|appletv") {
rewrite ^/adl/(.*)$ https://itunes.apple.com/us/app/apple-store/id375380948?mt=8&params=$1 redirect;
}
if ($http_user_agent ~* "android") {
rewrite ^/adl/(.*)$ https://play.google.com/store/apps/details?id=com.app.witpay&params=$1 redirect;
}
if ($http_user_agent ~* "Windows") {
rewrite ^/adl/(.*)$ https://example.com/$1 redirect;
@ankibalyan
ankibalyan / ubuntu upstart service
Created June 20, 2017 17:01
Upstart service for ubuntu that starts automatically on system restarts, and restarts on failure
#! /etc/systemd/system/name.service
[Unit]
Description==describe you upstart service
# if mysql service is prerequisite
Requires=mysql.service
After=mysql.service
# if anyother service is prerequisite
@ankibalyan
ankibalyan / post-receive
Created June 20, 2017 07:23
Git push to deploy post receve script
#!/bin/bash
target_branch="production"
working_tree="PATH_TO_DEPLOY"
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ -n "$branch" ] && [ "$target_branch" == "$branch" ]; then
@ankibalyan
ankibalyan / tuning_nginx_nodejs
Created December 16, 2016 13:04 — forked from carlessistare/tuning_nginx_nodejs
Tuning Nginx for heavy loading with nodejs as upstream. Short requests and a lot of concurrence.
# This number should be, at maximum, the number of CPU cores on your system.
# (since nginx doesn't benefit from more than one worker per CPU.)
worker_processes 8;
# Determines how many clients will be served by each worker process.
# (Max clients = worker_connections * worker_processes)
# "Max clients" is also limited by the number of socket connections available on the system (~64k)
# run ss -s and u'll see a timewait param
# The reason for TIMED_WAIT is to handle the case of packets arriving after the socket is closed.
@ankibalyan
ankibalyan / mongodb.md
Created December 16, 2016 05:40
#mongodb cheat sheet

MongoDB cheat sheet

Overview

Overview

MongoDB is a document database that provides high performance, high availability, and easy scalability.

  • Document Database
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { FilesCollection } from 'meteor/ostrio:files';
import * as fs from 'fs';
import multer from 'multer';
export const Avatars = new FilesCollection({
collectionName: 'avatars',
allowClientCode: false,
onBeforeUpload: function (file) {
#Install Ubuntu Linux, nginx, MySQL, PHP 7.0 (LEMP) stack
#nginx
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install nginx
sudo apt-get update
check localhost or server ip address
"welcome message by nginx"
To stop your web server, you can type:
@ankibalyan
ankibalyan / excel_libs.txt
Last active February 6, 2016 09:13
Read/write Excel Lib Notes
https://github.com/PHPOffice/PHPExcel
http://pear.php.net/package/Spreadsheet_Excel_Writer/
https://github.com/iliaal/php_excel
http://code.google.com/p/php-excel/
https://github.com/elidickinson/php-export-data