Skip to content

Instantly share code, notes, and snippets.

View masnun's full-sized avatar

Abu Ashraf Masnun masnun

View GitHub Profile
@masnun
masnun / .bash_profile
Created June 24, 2012 18:23
My Bash Profile
############# Aliases ##############
#AMP
alias php.ini='subl /usr/local/etc/php/5.4/php.ini'
alias httpd.conf='subl /etc/apache2/httpd.conf'
alias vhosts='subl /private/etc/apache2/extra/httpd-vhosts.conf'
alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
@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 / sf.sh
Created August 8, 2012 14:28
Symfony command line tool shortcut
#!/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;
@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;
}
@masnun
masnun / rmpyc.py
Created August 15, 2012 23:17
Remove .pyc files recursively (shell command + django manage.py plugin)
# File: <appname>/management/commands/rmpyc.py
# management and commands directories must be python packages (each must have a __init__.py file)
from django.core.management.base import BaseCommand, CommandError
from subprocess import Popen, STDOUT, PIPE
import shlex, os
class Command(BaseCommand):
def handle(self, *args, **options):
@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!"
@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("masnun@gmail.com");
$user->setName("Masnun");
$user->setIdentityProvider("facebook");
$user->setProviderId("masnun");
$user->setPhone("8801711960803");
@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 / 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 / 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",