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, | |
) | |
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: |
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 |
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(); |
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"; | |
} |
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))) | |
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)} |
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` |
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 |