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
# prettyprint json i jinja | |
def ppjson(value, indent=2): | |
return json.dumps(value, indent=indent) | |
jinja2.filters.FILTERS['ppjson'] = ppjson |
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
# *if* colorama is installed, get colors | |
try: | |
from colorama import Fore, Back, Style, init | |
init(autoreset=True) | |
# fallback so that the imported classes always exist | |
except ImportError: | |
class ColorFallback(): | |
__getattr__ = lambda self, name: '' |
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 hug | |
from werkzeug.utils import find_modules | |
@hug.get('/hi') | |
def say_hi(): | |
return "Hi from root" | |
@hug.extend_api('/something') |
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
{% extends 'base.html' %} | |
{% load my_extras %} | |
{% block content %} | |
<section class="section container"> | |
<table class="table"> | |
<thead> | |
<tr> | |
{% for field in fields %} |
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 django.db import models | |
from django.db.models import Count | |
class Game(models.Model): | |
"""A game to be played and/or owned""" | |
name = models.CharField(max_length=255) | |
class Player(models.Model): | |
"""Someone who plays games""" | |
name = models.CharField(max_length=255) |
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
# Backoffice script | |
# We got a file from some system, but before it could be passed on the file had to be split from sheets into separate files. | |
from xlrd import open_workbook | |
from xlwt import Workbook | |
""" Split sheets in excel to different files. """ | |
rb = open_workbook('path/file.xls',formatting_info=True) |
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/python | |
""" | |
04.12.2015 | |
Based on "tag" in filename, move file into directory named with the same tag. | |
""" | |
import sys, os, time, shutil, re | |
path = './' #this folder |
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
""" | |
Comment from today, script from years ago. | |
Not sure if I ever fixed this. | |
This script was suppose to loop through a shit-ton of excel like files; | |
Get all the headers, make a list of all the headers it encountered, and then report back with how many times a header was encountered. | |
Everything gets written to files at the end. | |
- Heads with counter | |
- Errors | |
- Files it could not read (not excel/csv | |
I think it would silently fail on the different types of csv-dialects it could encounter. |