Skip to content

Instantly share code, notes, and snippets.

View masnun's full-sized avatar

Abu Ashraf Masnun masnun

View GitHub Profile
@masnun
masnun / async.py
Last active September 27, 2018 05:56
Async Requests in Python with Multiprocessing
from multiprocessing import Pool
from time import sleep
from random import randint
import os
class AsyncFactory:
def __init__(self, func, cb_func):
self.func = func
self.cb_func = cb_func
@masnun
masnun / GridCalculator.php
Last active January 1, 2016 14:49
Grid Calculator
<?php
/**
* Author: Abu Ashraf Masnun
* URL: http://masnun.me
*/
class GridCalculator implements Iterator
{
private $maximumX, $maximumY, $minimumX, $minimumY;
@masnun
masnun / test.py
Last active January 1, 2016 13:39
Zooz Client in Python
from zooz import ZoozClient
zooz = ZoozClient(unique_id='<unique id>',
app_key='<app key>',
sandbox=True)
transaction = {'cmd': 'openTrx',
'amount': '0.99',
'currencyCode': 'USD'}
@masnun
masnun / vimrc
Created August 12, 2013 19:55
Vimrc
"==================
" My Configuration
"==================
syntax on
set wrapscan
set number
set backspace=start,indent,eol
set t_Co=256
colorscheme wombat256mod
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
@masnun
masnun / test.js
Last active December 19, 2015 22:08
(function (text) {
this.text = text;
this.greet = function (closure) {
closure("Hello " + this.text + "!")();
}
return this;
})('Javascript').greet(function (text) {
return function () {
console.log(text);
}
@masnun
masnun / preference.json
Created April 18, 2013 11:08
Sublime Text 2 Preference
{
"auto_indent": true,
"bold_folder_labels": true,
"color_scheme": "Packages/Dayle Rees Color Schemes/LaravelDarker.tmTheme",
"draw_white_space": "all",
"fade_fold_buttons": false,
"fold_buttons": true,
"folder_exclude_patterns":
[
".svn",
@masnun
masnun / Execution Time
Last active December 15, 2015 17:59
Mapping With Lambda
Lighthouse: ~/Codes/compare
→ time python test.py
python test.py 0.05s user 0.01s system 96% cpu 0.067 total
Lighthouse: ~/Codes/compare
→ time php test.php
php test.php 0.56s user 0.03s system 99% cpu 0.598 total
Lighthouse: ~/Codes/compare
@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
@masnun
masnun / DefaultController.php
Created August 23, 2012 18:59
Symfony2 entity problem
$entityManager = $this->getDoctrine()->getEntityManager();
$user = new User();
$user->setAddress("Khulna");
$user->setBio("Good guy!");
$user->setEmail("[email protected]");
$user->setName("Masnun");
$user->setIdentityProvider("facebook");
$user->setProviderId("masnun");
$user->setPhone("8801711960803");
@masnun
masnun / eid.py
Created August 19, 2012 14:09
Pythonic Eid Greeting
#!/usr/bin/env python
class Eid(object):
def __get__(self,instance,owner):
return "Eid-Ul-Fitr "
class Salutation(object):
def __get__(self,instance,owner):
return "Mubarak!"