Skip to content

Instantly share code, notes, and snippets.

View masnun's full-sized avatar

Abu Ashraf Masnun masnun

View GitHub Profile
@masnun
masnun / annotations.php
Created August 12, 2012 15:54
Demonstration of Doctrine Annotation Reader
<?php
/**
*@Annotation
*/
class AnnotatedDescription
{
public $value;
public $type;
public $desc;
}
package middlewares
import (
"encoding/json"
"fmt"
"net/http"
)
func Recovery(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@masnun
masnun / alexa.py
Created July 24, 2012 16:02
Python One-liner to get your site's Alexa Rank
#!/usr/bin/env python
import urllib, sys, bs4
print bs4.BeautifulSoup(urllib.urlopen("http://data.alexa.com/data?cli=10&dat=s&url="+ sys.argv[1]).read(), "xml").find("REACH")['RANK']
@masnun
masnun / .zshrc
Created January 18, 2013 08:22
Zsh configuration
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="custom"
# Example aliases
function wait(signal, ms) {
return new Promise((res, rej) => {
const timeOut = setTimeout(() => {
console.log("I was called");
res("ok");
}, ms);
signal.catch(err => {
rej(err);
clearTimeout(timeOut);
class RangeIterator implements Iterator<number> {
constructor(private n: number, private to: number) {}
next(): IteratorResult<number> {
if (this.n <= this.to) {
return { done: false, value: this.n++ };
} else {
return { done: true, value: undefined };
}
}
}
package main
import (
"encoding/json"
"github.com/masnun/gopher-and-rabbit"
"github.com/streadway/amqp"
"log"
"math/rand"
"time"
)
package main
import (
"encoding/json"
"log"
"os"
gopher_and_rabbit "github.com/masnun/gopher-and-rabbit"
"github.com/streadway/amqp"
)
package main
import (
"encoding/json"
"net/http"
"github.com/go-chi/chi"
)
func main() {
import * as fs from "fs";
import * as AWS from "aws-sdk";
const BUCKET_NAME = "<<bucket name>>";
const IAM_USER_KEY = "<<user key>>";
const IAM_USER_SECRET = "<<user secret>>";
const s3bucket = new AWS.S3({
accessKeyId: IAM_USER_KEY,
secretAccessKey: IAM_USER_SECRET