View decorators.py
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 logging | |
import time | |
from functools import wraps | |
from typing import ( | |
Callable, | |
Optional, | |
) | |
View build-instructions
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
Prerequisties install: | |
- sudo apt-get install build-essential checkinstall | |
These are the dependancies required by python: | |
- sudo apt-get install libbz2-dev libc6-dev libgdbm-dev libncursesw5-dev libreadline-gplv2-dev libssl-dev libsqlite3-dev tk-dev | |
Download the tar source file from python.org (at the time of writing 3.6.1 is the latest release): | |
- wget -O ~/Downloads/python3.6.1.tgz https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz | |
Via command line navigate to the downloaded file directory: |
View energy_plan_rate_calculator.py
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
# Cost per units and standard day charge | |
ELEC_PKWH = 12.2 | |
ELEC_DAILY = 11.420 | |
GAS_PKWH = 2.973 | |
GAS_DAILY = 12.910 | |
# Number of units i use | |
ELEC_USAGE = 4000 |
View canvas cloud
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
canvas = document.getElementById('cloud'); | |
var ctx = cloud.getContext("2d"); | |
ctx.beginPath(); | |
// left | |
ctx.arc(40,65,40,0,2*Math.PI) | |
ctx.fillStyle = "rgb(255,255,255)"; | |
ctx.fill(); |
View Test pac file
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
function FindProxyForURL(url, host) { | |
if (dnsDomainIs(host, ".localhost")) | |
return "DIRECT"; | |
if (url.substring(0, 6)=="https:") | |
return "DIRECT"; | |
return "PROXY 192.168.100.202:9999"; | |
} |
View xor.py
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
# Simple XOR encyption | |
def xor(self, string, key): | |
return ''.join(chr(ord(x) ^ ord(y)) for x, y in zip(string, cycle(key))) | |
View gist:25d86505ff46729de5cf
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
""" | |
This is a simple bit of code which solves the 100 lightbulbs problem. | |
Its not the most efficient but it does the job. | |
""" | |
def switch(list_length, iterations): | |
switches_on = [] | |
switches = { i:False for i in range(1,list_length+1)} |
View gunicorn-initd-script
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 | |
### BEGIN INIT INFO | |
# Provides: webapp | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: gunicorn init.d script for ubuntu and debian | |
# Description: gunicorn init.d script for running gunicorn on ubuntu or debian based systems | |
# start script using `/etc/init.d/webapp start` |
View django-secret-keygen.py
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
""" | |
Pseudo-random django secret key generator. | |
- Does print SECRET key to terminal which can be seen as unsafe. | |
""" | |
import string | |
import random | |
from __future__ import print_function |