Skip to content

Instantly share code, notes, and snippets.

View masnun's full-sized avatar

Abu Ashraf Masnun masnun

View GitHub Profile
@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 / 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.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 / 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 / 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
#!/bin/bash
# Expand globs to null when there are no matches
shopt -s nullglob
# Look for either a '<subdir>/console' or a 'symfony' file
until
file=(*/console symfony); [[ -f "$file" ]] && php "$file" "$@" && exit;
do
[[ "$PWD" == "/" ]] && break;
{% extends 'emails/html/base.html' %}
{% block body %}
<h2 class="null" style="color: rgb(51, 51, 51); font-family: Arial, Verdana, sans-serif; line-height: 20.796875px;"><span style="font-size:14px;"><span style="line-height: 1.6em; color: rgb(32, 32, 32); font-family: Arial;">Hi &lt;First Name&gt;,</span></span></h2>
<p style="color: rgb(51, 51, 51); font-family: Arial, Verdana, sans-serif; font-size: 13px; line-height: 20.796875px;"><br />
<span style="font-size:14px;">Thanks&nbsp;for booking at <a href="http://www.aircourts.com" target="_self">aircourts.com</a>!&nbsp;</span><br />
&nbsp;</p>
from subprocess import Popen, PIPE, call
from sys import argv, exit
from time import sleep
from os import getpid
def get_process_list(app):
ps_aux = Popen(["ps", "aux"], stdout=PIPE)
grep = Popen(["grep", app], stdin=ps_aux.stdout, stdout=PIPE)
awk = Popen(["awk", "{print $2}"], stdin=grep.stdout, stdout=PIPE)
ps_aux.stdout.close()
@masnun
masnun / lein.clj
Last active August 29, 2015 14:11
(require '[clojure.tools.namespace.repl :refer [refresh]])
(refresh)
(-main)
(defproject my-project "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:main my-project.core
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:profiles {:dev {:source-paths ["startup"]}}
:dependencies [[org.clojure/clojure "1.6.0"]