Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mushfiq's full-sized avatar

Mushfiq mushfiq

View GitHub Profile
import nltk
import random
class Categorizer(object):
def __init__(self, categories):
self.categories = categories
def prep_seed(self, content):
"""Convert seed content into nltk.Text"""
raw = nltk.clean_html(content)
@mushfiq
mushfiq / gplaces_api_client.php
Last active August 29, 2015 14:17
This gist has a sample API call using PHP Google places API client.
<?php
require_once 'googleplaces.class.php';
$googlePlaces = new GooglePlaces(array(
'apiKey' => "YOUR_API_KEY"
));
$query['query'] = "Burger in Berlin";
$places = $googlePlaces->getLocationsByTextSearch($query);
$decoded_data = json_decode($places, true);
@mushfiq
mushfiq / movie_info.py
Created February 26, 2012 19:22
IMDB Movie Info CRAWLER
import re
import requests
import urllib
import json
# MOVIE_NAME = 'The Other Dream Team'
BASE_URL = 'http://www.imdbapi.com/?'
NAME_LIST = file('movies.txt','r')
@mushfiq
mushfiq / Demo_google_crawl.py
Created June 16, 2012 05:54
Sample google crawler
'''A sample google search script,you have to install python module "google before running it"'''
import sys
import time
from google import search
def do(keyword,stop):
count = 0
for url in search(keyword,lang='en',num=10,pause=3):
count +=1
print url
@mushfiq
mushfiq / cors.py
Last active October 7, 2015 14:34
python decorator for bottle framework to enable CORS to an endpoint.
from bottle import Bottle,response
def allow_cors(func):
""" this is a decorator which enable CORS for specified endpoint """
def wrapper(*args, **kwargs):
response.headers['Access-Control-Allow-Origin'] = 'example.com' # * in case you want to be accessed via any website
return func(*args, **kwargs)
return wrapper
@mushfiq
mushfiq / javascript_design_pattern.js
Created September 25, 2012 04:59
Javascript pattern
app = {};
app.run = function run() {
//console.log('Running app...');
app.init();
}
app.init = function () {
//console.log('Running init...');
app.bind();
}
@mushfiq
mushfiq / js_url_based_design_pattern.js
Created September 25, 2012 05:37
Javascript url based pattern
var app = this.app || {};
// Application Settings
app.settings = {
'ajax' : {
'timeout' : 50000,
'delay' : 0
}
}
@mushfiq
mushfiq / Use Python Getter Setter.py
Last active October 13, 2015 17:37
Python Class Properties using decorators
class Book(object):
@property
def title(self):
return self._title
@title.setter
def title(self, value):
if value is None or "" == value.strip():
raise ValueError("Title should have proper value!")
from itertools import izip
A = [1, 2]
B = [3, 4]
C = [5, 6]
def iterate_using_zip(item1, item2, item3):
for a,b,c in zip(item1, item2, item3):
print a,b,c
@mushfiq
mushfiq / .vimrc
Created February 1, 2013 12:53
My .vimrc configuration which is bare bone configuration for any kind of .vim power use :)
set nocompatible
set number
set title
syntax on
set hlsearch
set ls=2
set showmode