Skip to content

Instantly share code, notes, and snippets.

View saxbophone's full-sized avatar
🏳️‍⚧️

saxbophone

🏳️‍⚧️
View GitHub Profile
@saxbophone
saxbophone / self.sh
Created April 30, 2015 13:36
Recursive shell script using Unix at daemon
#!/bin/bash
# A recursively self-calling shell script, using Unix at daemon
# for scheduling future runs of itself.
# ...
# Put whatever you want your script to do here
# ...
# This bit will schedule this file to run again
@saxbophone
saxbophone / forkbomb.py
Created May 12, 2015 14:52
Python Forkbomb (kinda)
def inf():
try:
while True:
try:
pass
except KeyboardInterrupt:
inf()
except KeyboardInterrupt:
inf()
@saxbophone
saxbophone / .bashrc
Created May 13, 2015 17:02
Alias csh and tcsh commands to an essay on why not to use the C shell for which they refer to!
# Don't use the C-Shell!
alias csh='wget -qO- http://www.grymoire.com/unix/CshTop10.txt | less'
alias tcsh='wget -qO- http://www.grymoire.com/unix/CshTop10.txt | less'
@saxbophone
saxbophone / test_type_safety.py
Created June 3, 2015 00:38
Sample Initial test for my idea for a type safety function decorator for Python
import unittest
from type_safety import typed
class TypeSafetyTestCase(unittest.TestCase):
def test_positional_typing(self):
"""
When the @typed() decorator is used with a list of types
it should force these types on the corresponding positional
@saxbophone
saxbophone / permakey.py
Created July 11, 2015 16:00
Generates random permutations (non-repeating sets of integers guaranteed to hold all integers within a certain range).
from random import randint
from oset import oset
def k(l):
"""
Generate a random set of non-repeating integers, containing all integers from 0 to l.
"""
s = oset()
@saxbophone
saxbophone / sequence.py
Created July 30, 2015 16:05
Python Sequence theory generator
def sequence(i):
store = (i + 1) * (i / 2)
while True:
yield store
store = (store + 1) * (store / 2)
@saxbophone
saxbophone / generators.py
Created July 31, 2015 01:32
Having some fun with Python Generators...
def fibonacci(a=0, b=1):
yield a
yield b
while True:
a = a+b
yield a
b = b+a
yield b
@saxbophone
saxbophone / fake_server.sh
Created August 4, 2015 16:34
Fake Server - could-be one-liner in bash
fake_server() {
# function that takes port to listen on as first argument, file to read from as second
# perpetually listens on given port and outputs the contents of given file on connections
while true; do nc -l $1 < $2; done;
}
@saxbophone
saxbophone / sort.py
Created August 6, 2015 16:41
Python Recursive Sort
def sort(unsorted, asc=True):
if len(unsorted) == 1:
return [unsorted[0]]
else:
smallest = 0
for i in range(len(unsorted)):
if unsorted[i] > smallest:
smallest = unsorted[i]
unsorted.remove(smallest)
if asc:
@saxbophone
saxbophone / minestrap.sh
Created August 28, 2015 20:58
Minecraft Server Bootstrap
#!/usr/bin/env bash
###########################################################################
# #
# MINESTRAPS - A no-shit bootstrap script for Minecraft on Amazon Linux #
# Written By Joshua Saxby 2015 #
# #
###########################################################################
# Initialise config variables