From | To | Expression |
---|
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 sched, time | |
from time import strftime, localtime | |
import sys | |
from subprocess import check_output | |
import re | |
scheduler = sched.scheduler(time.time, time.sleep) | |
def sched_call(calls_per_second, callback, *args, **kw): | |
period = 1.0 / calls_per_second |
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 networkx as nx | |
import pprint | |
from operator import itemgetter | |
G = nx.read_graphml('metro.graphml') | |
print "graph has %d nodes with %d edges"\ | |
% (nx.number_of_nodes(G), nx.number_of_edges(G)) |
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 -*- | |
# vim: ai ts=4 sts=4 et sw=4 nu | |
from __future__ import (unicode_literals, absolute_import, | |
division, print_function) | |
""" | |
package.module | |
~~~~~~~~~~~~~ |
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
def id_generator(size=8, chars=string.ascii_lowercase + string.digits): | |
return ''.join(random.choice(chars) for x in range(size)) |
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 time | |
import datetime | |
print "Time in seconds since the epoch: %s" %time.time() | |
print "Current date and time: " , datetime.datetime.now() | |
print "Or like this: " ,datetime.datetime.now().strftime("%y-%m-%d-%H-%M") | |
print "Current year: ", datetime.date.today().strftime("%Y") | |
print "Month of year: ", datetime.date.today().strftime("%B") |
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
def profileit(func): | |
def wrapper(*args, **kwargs): | |
datafn = func.__name__ + ".profile" | |
prof = cProfile.Profile() | |
retval = prof.runcall(func, *args, **kwargs) | |
prof.dump_stats(datafn) | |
return retval | |
return wrapper |
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/sh | |
# remove openJDK | |
sudo apt-get purge openjdk-\* | |
# Install Oracle JDK | |
sudo apt-get install python-software-properties | |
sudo add-apt-repository ppa:webupd8team/java | |
sudo apt-get update | |
sudo apt-get install oracle-java6-installer |
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
export CLICOLOR=1 | |
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx | |
# tell grep to highlight matches | |
export GREP_OPTIONS='--color=auto' | |
# alias | |
alias ls='ls -FGal' |
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
#Enabling colors in git command-line interface | |
git config color.ui true |
OlderNewer