Skip to content

Instantly share code, notes, and snippets.

View asimihsan's full-sized avatar

Asim Ihsan asimihsan

View GitHub Profile
@asimihsan
asimihsan / logging_test.py
Created August 20, 2013 14:04
First draft attempt at benchmarking logging vs. sys.stderr.write'ing. See: https://pypi.python.org/pypi/benchmark/
import logging
import sys
logger = logging.getLogger('simple_example')
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
logger.addHandler(ch)
@asimihsan
asimihsan / _naughty.py
Last active December 20, 2015 00:19
Get a Python C extension to segfault
from cffi import FFI
def _make_divide():
libraries = ['c']
extra_compile_args = []
extra_link_args = []
ffi = FFI()
ffi.cdef(r"""
int divide(int a, int b);
@asimihsan
asimihsan / init.pp
Created July 18, 2013 16:13
Puppet module class for installing OpenCV from source on Ubuntu.
class opencv {
Exec { path => "/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin", }
$version = "2.4.6.1"
$libopencv_core_filename = "libopencv_core.so.2.4.6"
case $operatingsystem {
# Install OpenCV from source. This is an instructive example
# and may come in handy if we need to move to a version of
@asimihsan
asimihsan / test.py
Created June 23, 2013 12:03
Start of something that'll use phantomjs to get performance info about getting a site, and then capture packets in the background.
import multiprocessing
import pprint
import time
import scapy.all as scapy
import subprocess
import sys
import os
import signal
import psutil
@asimihsan
asimihsan / Vagrantfile
Created June 16, 2013 14:20
Vagrant + Puppet config for setting up Fedora 18 x64 with Python, pip, and virtualenv.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "fedora-18-x64"
config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210.box"
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "manifests"
puppet.manifest_file = "init.pp"
end
@asimihsan
asimihsan / office_365_notifications.js
Created May 14, 2013 09:59
A Greasemonkey script to show notifications when there is any new mail in an Office 365 Outlook Web App tab.
// ==UserScript==
// @name Office 365 notifications
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description Show a Google Chrome notification when there is any unread mail.
// @match https://*/owa/*
// @copyright 2012+, You
// ==/UserScript==
var current_unread_count = 0;
@asimihsan
asimihsan / list_vs_dict.py
Last active December 15, 2015 14:49
Benchmarking the use of dictionaries vs. lists.
#!/usr/bin/env python
# Some example results on my machine:
# ─[2013-03-30 16:19:13] ai@Mill ~/Programming/python
# ╰─$ ./list_vs_dict.py
# build_list vs. build_dict: '-9.68'%
# access_list vs. access_dict: '-59.29'%
# ╭─[2013-03-30 16:20:10] ai@Mill ~/Programming/python
# ╰─$ ./list_vs_dict.py
# build_list vs. build_dict: '-18.42'%
@asimihsan
asimihsan / bira-date.zsh-theme
Created March 30, 2013 15:38
ZSH "bira" theme with ISO 8601 date in prompt
# ~/.oh-my-zsh/themes/bira-date.zsh-theme
# ZSH Theme - Preview: http://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}'
local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}'
local rvm_ruby=''
if which rvm-prompt &> /dev/null; then
rvm_ruby='%{$fg[red]%}‹$(rvm-prompt i v g)›%{$reset_color%}'
@asimihsan
asimihsan / markdown_extras.py
Created July 5, 2012 09:04
markdown2 wrapper to get table of contents and pygments CSS
import os
import sys
import markdown2
from pygments.formatters import HtmlFormatter
def main():
# ------------------------------------------------------------------------
# Parse and validate inputs.
# ------------------------------------------------------------------------
input_filepath = sys.argv[1]
@asimihsan
asimihsan / spark.patch
Created May 17, 2012 08:31
Disable Spark automatic scroll on activity
Index: src/java/org/jivesoftware/spark/ui/ChatArea.java
===================================================================
--- src/java/org/jivesoftware/spark/ui/ChatArea.java (revision 13060)
+++ src/java/org/jivesoftware/spark/ui/ChatArea.java (working copy)
@@ -298,7 +298,7 @@
final Document doc = getDocument();
styles.removeAttribute("link");
doc.insertString(doc.getLength(), text, styles);
- setCaretPosition(doc.getLength());
+ //setCaretPosition(doc.getLength());