This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from subprocess import check_output | |
from sys import argv | |
from time import time | |
cmd = lambda pid: "stat -t /proc/%s | awk '{print $14}'" % (pid,) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pidlist=`ps ax | grep -i -E $1 | grep -v grep | awk '{print $1}' | grep -v PID | xargs echo` | |
for pid in $pidlist; do | |
sincetime $pid | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- basic imports | |
import XMonad | |
-- needed for layouts | |
import XMonad.Layout.Grid | |
-- needed for hot keys | |
import XMonad.Util.EZConfig(additionalKeys) | |
import XMonad.Actions.CycleWS (nextWS, prevWS, shiftToNext, shiftToPrev) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymc | |
import numpy | |
def model(disasters): | |
size = len(disasters) | |
low = pymc.Exponential('low', beta=1.) | |
high = pymc.Exponential('high', beta=2.) | |
@pymc.stochastic(dtype=int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymongo | |
import re | |
import time | |
from datetime import datetime, timedelta | |
patt = re.compile("\d*/\d*\s\d*%") | |
class Operations(object): | |
def __init__(self, db, host='localhost'): | |
self.conn = pymongo.Connection(host) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Singleton(type): | |
""" This is a Singleton metaclass. All classes affected by this metaclass | |
have the property that only one instance is created for each set of arguments | |
passed to the class constructor.""" | |
def __init__(cls, name, bases, dict): | |
super(Singleton, cls).__init__(cls, bases, dict) | |
cls._instanceDict = {} | |
def __call__(cls, *args, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas | |
import datetime | |
from pylab import * | |
data = pandas.read_csv('file.csv', index_col = 0, header = 0, sep = '\t') | |
timesIndex = data.index | |
dynamapsIndex = data.columns | |
levels = map(lambda x : round(x,1), linspace(data.min().min(), data.max().max(), 101)) | |
contourf(data, levels = levels, cmap=plt.cm.jet_r, interpolation = 'bicubic') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mpl_toolkits.basemap import Basemap | |
import numpy as np | |
import matplotlib.pyplot as plt | |
m = Basemap(llcrnrlon=-73.45,llcrnrlat=-35,urcrnrlon=-30.1,urcrnrlat=6, resolution='i',projection='lcc',lon_0=-45,lat_0=-23.7) | |
m.drawcoastlines() | |
m.fillcontinents(color='beige',lake_color='aqua') | |
# draw parallels and meridians. | |
m.drawparallels(np.arange(-40,10,1.)) | |
m.drawmeridians(np.arange(-80.,-0,1.)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Based on an answer by John Machin on Stack Overflow (http://stackoverflow.com/users/84270/john-machin) | |
#http://stackoverflow.com/questions/8733233/filtering-out-certain-bytes-in-python | |
def isValidXMLChar(char): | |
codepoint = ord(char) | |
return 0x20 <= codepoint <= 0xD7FF or \ | |
codepoint in (0x9, 0xA, 0xD) or \ | |
0xE000 <= codepoint <= 0xFFFD or \ | |
0x10000 <= codepoint <= 0x10FFFF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Crawling brazilian soccer results from | |
http://futpedia.globo.com/campeonato/campeonato-brasileiro/2011#/fase=fase-unica/rodada=1 | |
With: | |
http://www.clips.ua.ac.be/pages/pattern-web | |
""" | |
import pandas | |
from pattern import web |
OlderNewer