Skip to content

Instantly share code, notes, and snippets.

View fizerkhan's full-sized avatar

Fizer Khan (பைசர் கான்) fizerkhan

View GitHub Profile
(function() {
"use strict";
angular
.module( appName, [ ] )
.config([ "$provide", function( $provide )
{
// Use the `decorator` solution to substitute or attach behaviors to
// original service instance;
@fizerkhan
fizerkhan / nginx.conf
Created February 4, 2016 08:35 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@fizerkhan
fizerkhan / .vimrc
Last active November 5, 2015 09:49
VIM Configurations
syntax on " enable syntax processing
set tabstop=4 " number of visual spaces per TAB
set softtabstop=4 " number of spaces in tab when editing
set expandtab " tabs are spaces
set number " show line numbers
@fizerkhan
fizerkhan / haproxy.cfg
Created October 26, 2015 08:25 — forked from GABeech/haproxy.cfg
Stack Exchange HAProxy
# This is an example of the Stack Exchange Tier 1 HAProxy config
# The only things that have been changed from what we are running are:
# 1. User names have been removed
# 2. All Passwords have been remove
# 3. IPs have been changed to use the example/documentation ranges
# 4. Rate limit numbers have been changed to randome numbers, don't read into them
userlist stats-auth
group admin users $admin_user
user $admin_user insecure-password $some_password
@fizerkhan
fizerkhan / autofocus.js
Last active August 29, 2015 14:26 — forked from mlynch/autofocus.js
AngularJS Autofocus directive
/**
* the HTML5 autofocus property can be finicky when it comes to dynamically loaded
* templates and such with AngularJS. Use this simple directive to
* tame this beast once and for all.
*
* Usage:
* <input type="text" autofocus>
*/
angular.module('utils.autofocus', [])
@fizerkhan
fizerkhan / grunt-version.md
Last active August 29, 2015 14:23
Generate version.json using git hash, version number, and date
npm install grunt-git-describe --save-dev

One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-git-describe');

Add Grunt configuration

@fizerkhan
fizerkhan / TwentyBot
Last active August 29, 2015 14:21 — forked from CodyWalker/TwentyBot
function countPieces() {
it = b.pieces();
var i = 0;
while (it.current()){ i++; it.next() }
return i;
}
function getRandPiece() {
var it = b.pieces();
var n = Math.floor(Math.random()*countPieces());
@fizerkhan
fizerkhan / s3.sh
Last active August 29, 2015 14:20 — forked from chrismdp/s3.sh
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@fizerkhan
fizerkhan / deployment.md
Created April 30, 2015 09:39
Fast code deployments with Docker in Digital ocean
  1. Commit and push to GitHub.
  2. Ansible connects to our servers, pulls latest master from GitHub.
  3. Ansible touches the app’s uwsgi.ini file to trigger UWSGI to reload.

Supervisor configuration:

We are using Supervisor inside the Docker container to start the processes run by the container. Our supervisord.conf looks like the following:

struct { initialized bool; configHandlers []nsq.configHandler; DialTimeout time.Duration "opt:\"dial_timeout\" default:\"1s\""; ReadTimeout time.Duration "opt:\"read_timeout\" min:\"100ms\" max:\"5m\" default:\"60s\""; WriteTimeout time.Duration "opt:\"write_timeout\" min:\"100ms\" max:\"5m\" default:\"1s\""; LocalAddr net.Addr "opt:\"local_addr\""; LookupdPollInterval time.Duration "opt:\"lookupd_poll_interval\" min:\"5s\" max:\"5m\" default:\"60s\""; LookupdPollJitter float64 "opt:\"lookupd_poll_jitter\" min:\"0\" max:\"1\" default:\"0.3\""; MaxRequeueDelay time.Duration "opt:\"max_requeue_delay\" min:\"0\" max:\"60m\" default:\"15m\""; DefaultRequeueDelay time.Duration "opt:\"default_requeue_delay\" min:\"0\" max:\"60m\" default:\"90s\""; BackoffMultiplier time.Duration "opt:\"backoff_multiplier\" min:\"0\" max:\"60m\" default:\"1s\""; MaxAttempts uint16 "opt:\"max_attempts\" min:\"0\" max:\"65535\" default:\"5\""; LowRdyIdleTimeout time.Duration "opt:\"low_rdy_idle_timeout\" min:\"1s\" max:\"5m\" default: