Skip to content

Instantly share code, notes, and snippets.

View fizerkhan's full-sized avatar

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

View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
# Directories
alias ..='cd ..'
alias cdd="cd -"
# Git
alias g='git status'
alias ga='git add -A'
alias gc='git commit -a -s'
alias gcb='git checkout -b' # Check out a new branch
alias hack='bash ~/hack.sh' # Hack on the branch
@fizerkhan
fizerkhan / gist:5633503
Created May 23, 2013 08:28
Extract largest image thumbnail from url using node and cheerio
var cheerio = require('cheerio')
, Shred = require('shred')
, shred = new Shred()
, http = require('http')
, URL = require('url');
var server = http.createServer(function(request, response) {
var url, urlToDiscover;
url = URL.parse(request.url, true);
cheerio = require('cheerio')
Shred = require('shred')
shred = new Shred()
http = require('http')
URL = require('url')
server = http.createServer (request, response) ->
url = URL.parse(request.url, true)
urlToDiscover = url.query['url']
startDiscovery urlToDiscover, (theImageURL) ->
@fizerkhan
fizerkhan / gist:5728714
Created June 7, 2013 11:44
HTTP status codes
HTTP defines a bunch of meaningful status codes that can be returned from your API. These can be leveraged to help the API consumers route their responses accordingly. I've curated a short list of the ones that you definitely should be using:
* 200 OK - Response to a successful GET, PUT, PATCH or DELETE. Can also be used for a POST that doesn't result in a creation.
* 201 Created - Response to a POST that results in a creation. Should be combined with a Location header * pointing to the location of the new resource
* 204 No Content - Response to a successful request that won't be returning a body (like a DELETE request)
* 304 Not Modified - Used when HTTP caching headers are in play
* 400 Bad Request - The request is malformed, such as if the body does not parse
* 401 Unauthorized - When no or invalid authentication details are provided. Also useful to trigger an auth * popup if the API is used from a browser
* 403 Forbidden - When authentication succeeded but authenticated user doesn't have access to the re
@fizerkhan
fizerkhan / gist:5907107
Last active December 19, 2015 05:49
Twitter, Facebook and Google Plus share links and how to use them

The share links are much better than share buttons. Because Share button need script to be loaded and also track our web pages to find number of shares or tweets. If you dont want complex script loading and share count. You can go ahead with simple share links.

Facebook share link

For Facebook, you just need to add this link in everyone of your posts.

http://facebook.com/sharer.php?u=http://url-of-the-post

Twitter share link

var _ = require('underscore'),
rabbit = require('rabbit-pool'),
logging = require('logging')(module);
var exchange,
handlers = {},
messages = [];
#!/bin/bash
#Force file syncronization and lock writes
mongo admin --eval "printjson(db.fsyncLock())"
MONGODUMP_PATH="/usr/bin/mongodump"
MONGO_HOST="prod.example.com"
MONGO_PORT="27017"
MONGO_DATABASE="dbname"