Skip to content

Instantly share code, notes, and snippets.

View phillipkent's full-sized avatar

Phillip Kent phillipkent

View GitHub Profile
@phillipkent
phillipkent / hextiling
Created March 22, 2013 15:54
Design Science - Programs in Processing - program for pattern generation using hexagonal tiling
/* hextiling
Hexagonal tiling
Version: 1.3 DEVELOPMENT, 2013-03-22
By Phillip Kent
Based on litmus2_hextiling prepared for the Cheltenham Science Festival 2013
[http://design-science.org.uk/litmus-paper/]
Acknowledgements:
@phillipkent
phillipkent / TrigMountains.pde
Created March 27, 2013 14:16
Design Science - Programs in Processing - Using randomness to create visual richness
/* TrigMountains
Version: 1.0, 2012-10-26
By Phillip Kent
http://www.phillipkent.net
Illustrates the use of randomness to generate visual richness.
In each drawing cycle, a sine-shaped solid is plotted, with random magnitude, period
and colour.
*/
@phillipkent
phillipkent / greedy-egyptian-fractions.py
Created March 29, 2013 11:17
Greedy algorithm for Egyptian fractions
# Greedy Algorithm for Egyptian Fractions
# To express a / b as a sum of unit fractions (1 / c_1) + ... + (1 / c_n)
def main():
print("*** Greedy algorithm for Egyptian fractions ***\n")
while 1:
try:
a = int(input("Enter a: "))
b = int(input("Enter b: "))
result = iterate(a,b)
@phillipkent
phillipkent / nplustransform.py
Last active December 15, 2015 22:19
N-plus-transform: An implementation in Python of the Oulipo 'S+7' ('noun + 7') text transformation. [http://www.oulipo.net/contraintes/docs/s-7 , http://www.spoonbill.org/n+7/ ] Requires the NLTK toolkit http://nltk.org, and uses a nouns list sourced from http://www.ashley-bovan.co.uk/words/partsofspeech.html
'''
Created on 14 Mar 2013
@author: phillip
INCOMPLETE CODE UNDER DEVELOPMENT
'''
# Oulipo's 'N plus' transformation for text
#
# Words list 'nouns91k.txt' contains 91000 nouns, found at
# http://www.ashley-bovan.co.uk/words/partsofspeech.html
@phillipkent
phillipkent / AnagramTest.java
Last active December 21, 2015 17:18
Anagram Test method in Java. Original question from Gayle Laakmann, "Cracking the Coding Interview", Chapter 1
// Anagram Test: Test if two strings are anagrams of each other
// Original question: Gayle Laakmann, "Cracking the Coding Interview", Chapter 1
//Anagram rules:
// spaces are ignored
// case is ignored
// punctuation is ignored
// letters a..z and digits 0..9 are significant (?)
//Program logic:
#!/usr/bin/python
#
# This file is part of cloudmonkey version 5.1.0
# [https://pypi.python.org/pypi/cloudmonkey/5.1.0]
# Modified for use with Interoute VDC
# [information: http://cloudstore.interoute.com/main/knowledge-centre/library/vdc-api-introduction-api]
#
#
@phillipkent
phillipkent / cloudmonkey.json
Created July 23, 2014 09:49
Problem JSON object
{
"count": 12,
"virtualmachine": [
{
"account": "Interoute Tutorial",
"affinitygroup": [],
"cpunumber": 1,
"cpuspeed": 2000,
"cpuused": "0%",
"created": "2014-06-17T10:34:59+0000",

"check-vm-state.sh" A shell script for using the Virtual Data Centre API

[content to come]

@phillipkent
phillipkent / docker_test_haproxy.cfg
Created February 23, 2015 11:21
Example haproxy.cfg file for a Docker test installation of WordPress containers [http://cloudstore.interoute.com/main/knowledge-centre/blog/coreos-docker-vdc-part3]
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
user haproxy
group haproxy
defaults
log global
mode http
option httplog
@phillipkent
phillipkent / citeulike_init_session.py
Created May 16, 2016 11:07
Using the 'requests' module in Python, initiate a session with citeulike.org and run queries on citeulike accounts
# citeulike_init_session.py
#
# by Phillip Kent
#
# Using the 'requests' module in Python [http://docs.python-requests.org], initiate a session with citeulike.org
# to generate a login cookie. A simple function cquery is defined to make queries on a specified citeulike account and
# return results as a Python dictionary (equivalent to JSON format)
#
# You can use this interactively on the Python commandline by running:
# $ python -i citeulike_init_session.py