Skip to content

Instantly share code, notes, and snippets.

def get_file_modified_datetime(filename):
return time.ctime(os.stat(filename).st_mtime)
@wh13371
wh13371 / tickle.py
Created February 19, 2015 15:52
python - tickle - a script template
#! /usr/bin/python
import sys
import os
import stat
def a():
"""#! /usr/bin/python
@wh13371
wh13371 / treesize.sh
Created February 21, 2015 09:31
.bashrc "treesize" function
treesize(){
du -k --max-depth=1 | sort -nr | awk '
BEGIN {
split("KB,MB,GB,TB", Units, ",");
}
{
u = 1;
while ($1 >= 1024) {
$1 = $1 / 1024;
u += 1
@wh13371
wh13371 / .bash_profile
Last active August 29, 2015 14:15
.bash_profile - mac
# myMAC .bash_profile
# a decent bash prompt
# \d = date - \t = time - \u = user - \h = host - \w = cwd
#PS1='\[\e[1;33m\]\d \[\e[1;34m\]\t \[\e[1;36m\]\u\[\e[1;35m\]@\[\e[1;31m\]\h \[\e[1;33m\](\[\e[1;36m\]\w\[\e[1;33m\]) \[\e[1;37m\]% \e[m'
PS1='\[\e[1;35m\][\[\e[1;33m\]\d \[\e[1;34m\]\t \[\e[1;35m\]\u\[\e[1;36m\]@\[\e[1;31m\]\h\[\e[1;33m\](\[\e[1;36m\]\w\[\e[1;33m\])\[\e[1;35m\]]\[\e[1;37m\]% \e[m'
alias docs='cd ~/Documents'
alias h=history
alias mx="chmod a+x"
@wh13371
wh13371 / clip.py
Created April 4, 2015 14:45
linux = python clip
#! /usr/bin/python
from gtk import Clipboard
import sys
def clip_in(text):
cb = Clipboard()
cb.set_text(text)
cb.store()
# create a folder, for hacking, if !exist
mkdir -p tmp
@wh13371
wh13371 / bin_folder.txt
Created April 6, 2015 09:33
use "$home\Copy\bin" as me "bin" folder - via ".bash_profile" that way it's backed up
# User specific environment and startup programs
# original
#PATH=$PATH:$HOME/bin
# via Copy - so its backed up
PATH=$PATH:$HOME/Copy/bin
export PATH
@wh13371
wh13371 / move_files.sh
Created June 9, 2015 07:46
linux - move files
FOLDER_YESTERDAY=`date +%Y%m%d --date=yesterday`
FOLDER_TODAY=`date +%Y%m%d`
mkdir -p "${FOLDER_TODAY}"
mv "${FOLDER_YESTERDAY}"/*.log "${FOLDER_TODAY}/"
@wh13371
wh13371 / epoch.sh
Created July 6, 2015 15:31
bash - epoch
#!/bin/bash
epoch=$(date +%s)
t=$(date +%Y_%m_%d_%H_%M_%S)
sleep 0.1
echo $epoch
@wh13371
wh13371 / dos2unix.txt
Created July 6, 2015 15:32
OSX - dos2unix
tr -d '\r' < print.sh > moo.sh