Skip to content

Instantly share code, notes, and snippets.

@damnit
damnit / hello_flask.py
Created August 22, 2014 07:41
browse your home folder :)
from flask import Flask
import os
import threading
app = Flask(__name__)
@app.route('/')
def root():
folder_contents = ""
for node in os.listdir(os.environ.get('HOME')):
# -*- coding: utf-8 -*-
from __future__ import print_function
import hashlib
class City(object):
""" This is the Foo object
"""
def __init__(self, name, population):
self._name = name
@damnit
damnit / unikot.py
Last active August 29, 2015 14:05
this module gives a shit about encoding
# -*- coding: utf-8 -*-
""" This module gives a shit about encoding. """
from __future__ import print_function
import sys
if __name__ == '__main__':
print('---------------------------')
print('| Unicode Analysis Script |')
print('---------------------------')
@damnit
damnit / list_join.py
Created July 30, 2014 13:51
the functional approach of ".".join
def list_join(sep, items):
""" method wrapper for str.join alternative.
>>> foo = ['foo', 'bar', 'baz']
>>> sep = ","
>>> sep.join(foo)
'foo,bar,baz'
>>> list_join(',', foo)
'foo,bar,baz'
"""
return reduce(lambda x, y: '%s%s%s' % (x, sep, y), items)
@damnit
damnit / multipull.sh
Last active August 29, 2015 14:04
multipull dirname
#!/bin/bash
FOLDERS=`find "$1" -maxdepth 1 -type d ! -path "$1" | sed "s|^"$1"/||"`
for i in $FOLDERS; do
printf "\e[34m$1/$i\e[0m\n"
cd "./$1/$i"
git pull
cd ../..
done