Skip to content

Instantly share code, notes, and snippets.

View rahbirul's full-sized avatar

Rahbirul Rubayeet rahbirul

View GitHub Profile
@rahbirul
rahbirul / gist:2320255
Created April 6, 2012 14:20
NewsLook feeds
+-----+-------------------------------+----------------------------------------------------------------------------------------+-----------+
| id | name | url | source_id |
+-----+-------------------------------+----------------------------------------------------------------------------------------+-----------+
| 685 | PBS Arts & Society | http://newscred:newscred@www.newslook.com/rss/v2/532-pbs-arts-society.rss | 6068 |
| 672 | Xinhua Environment | http://newscred:newscred@www.newslook.com/rss/v2/517-xinhua-environment.rss | 6067 |
| 673 | Xinhua Arts & Entertainment | http://newscred:newscred@www.newslook.com/rss/v2/518-xinhua-arts-entertainment.rss | 6067 |
| 674 | Xinhua Travel | http://newscred:newscred@www.newslook.com/rss/v2/519-xinhua-travel.rss | 6067 |
| 675 | Xinhua Sports
@rahbirul
rahbirul / apache_log_parser.py
Created April 12, 2012 11:52
Python script for parsing Apache access log
from re import compile, search
from sys import exit
from time import strptime
from datetime import datetime, timedelta, tzinfo
#change this variable to point to the location of the apache access log file
LOG_FILE_LOCATION = '/var/log/httpd/access_log'
LINES_PROCESSED = 0
@rahbirul
rahbirul / .vimrc
Created January 3, 2013 07:30
My .vimrc
set number
set shiftwidth=4 softtabstop=4
set ai " auto indenting
set history=100 " keep 100 lines of history
set ruler " show the cursor position
syntax on " syntax highlighting
set hlsearch " highlight the last searched term
filetype plugin on " use the file type plugins
" When editing a file, always jump to the last cursor position
@rahbirul
rahbirul / PyChrome.htm
Last active December 12, 2015 00:08
Python Editor Bookmarklet. Tested on Chrome. 1. Open a new browser tab in Google Chrome 2. Copy the code in the gist 3. Paste on the URL bar and hit return/enter. Start coding. 4. Save as a bookmark. Influenced by https://coderwall.com/p/lhsrcq
data:text/html;charset=utf-8, <title>PyChrome</title> <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/twilight");e.getSession().setMode("ace/mode/python");</script>
import sys
import math
def average(li):
return sum(li) * 1.0 / len(li)
def stddev(numbers):
avg = average(numbers)
@rahbirul
rahbirul / qps.sh
Created July 25, 2013 08:57
Calculate QPS (queries per second) from an Apache log.
#!/bin/bash
#Naive calculation of QPS from Apache Log
#Usage: qps.sh /path/to/logfile
LOG=$1
START=$(head -n 1 $LOG | cut -d ' ' -f 4 | tr -d [)
END=$(tail -n 1 $LOG | cut -d ' ' -f 4 | tr -d [)
@rahbirul
rahbirul / compress.py
Created November 30, 2015 07:49
aaabbbccc -> a3b3c3
def compress(input):
if len(input) == 0:
return ""
output = []
count = 1
prev = input[0]
for c in input[1:-1]:
if c == prev:
count += 1
else:
@rahbirul
rahbirul / export_delicious_links.py
Created April 17, 2017 15:44
Python script for scraping Del.icio.us and exporting all bookmarks