Skip to content

Instantly share code, notes, and snippets.

def ts_weeks_ago(n):
"""
Gets the unix timestamp n weeks ago
"""
return time.time() - (n*7*24*60*60*1000)
@puneetlakhina
puneetlakhina / centospy26.sh
Created May 30, 2012 18:25
CentOS python 2.6 installation
sudo rpm -Uvh http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
sudo yum install gcc python26-devel
sudo yum install python26-setuptools
sudo easy_install-2.6 pip
sudo easy_install-2.6 -U distribute
@puneetlakhina
puneetlakhina / p4cl
Created June 6, 2012 18:03
Create an empty perforce changelist
#!/bin/bash
p4 change -o | grep '^\(Change\|Client\|User\|Description\)' | sed "s/Description:/Description:$1/" | p4 change -i | cut -d ' ' -f 2
@puneetlakhina
puneetlakhina / csshorizontalstatus.css
Created June 29, 2012 23:24
CSS for Horizontal Success/Fail/Warn with bootstrap
.status-ul {
list-style: none;
padding:0;
margin:0;
font-size: 8px;
}
.status-item {
display:inline;
border-style: solid;
@puneetlakhina
puneetlakhina / Median.java
Created July 30, 2012 23:01
Get median from a list
public double getMedian(List<? extends Number> values) {
if(values.size() % 2 != 0) {
return values.get(values.size()/2).doubleValue();
} else {
return (values.get((values.size()/2) - 1).doubleValue() + values.get(values.size()/2).doubleValue())/2;
}
}