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
ending = ['.asia', '.be', '.biz', '.ch', '.co', '.co.uk', '.de', '.es', '.eu', '.fr', '.gr', '.im', '.info', '.io', '.it', '.me', '.me.uk', '.org', '.org.uk', '.pro', '.pt', '.ru','.se', '.tel', '.tv', '.us', '.so'] | |
file = open('/usr/share/dict/words', 'r') | |
for line in file: | |
for domain in ending: | |
if line == line[:-(len(domain))] + domain.replace('.', '') + '\n': | |
print line[:-(len(domain))] + domain.replace('.', '') |
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
Array.prototype.nice_join = function(sep) { | |
return this.length > 1 ? | |
this.slice(0, this.length - 1).join(sep) + ' & ' + this[this.length - 1] : | |
this.join(' ' + sep + ' '); | |
} |
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
<html> | |
<head> | |
</head> | |
<body> | |
<style> | |
#main { | |
position : absolute; | |
z-index : -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
/** | |
* web worker manager | |
* @param fun function to carry out in the web worker | |
* @param mes message to send to the web worker | |
* @param com function to do on completion | |
* @param err (optional) function to do on error | |
*/ | |
function wor(fun, mes, com, err) { | |
var wor = new Worker(URL.createObjectURL(new Blob([ | |
'self.onmessage = ' + fun.toString()], { |
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
/** | |
* @param one point start of the first line | |
* @param two point end of the first line | |
* @param three point start of the second line | |
* @param four point end of the second line | |
* @return boolean whether the lines intersect or not | |
*/ | |
function intersection(one, two, three, four) { | |
var x = ((one.x * two.y - one.y * two.x) * (three.x - four.x) - | |
(one.x - two.x) * (three.x * four.y - three.y * four.x)) / |
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
/* | |
* @param item what to look for in the array | |
* @return boolean whether the item is in the list or not | |
*/ | |
Array.prototype.contains = function(item) { | |
return this.indexOf(item) >== 0; | |
} |
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
/** | |
* @param eve an event object from function listening on the element, such as mousedown | |
* @return object describing the position of the mouse on the canvas | |
*/ | |
function mouse_pos(eve) { | |
var rect = eve.target.getBoundingClientRect(); | |
return { | |
y : eve.clientY - rect.top, | |
x : eve.clientX - rect.left | |
}; |
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/bash | |
# @author gideon mw jones | |
# @created 2013-12-27 | |
# @version 1 | |
# creates a directory structure board for snakes & ladders | |
BRDSZ=100 | |
# initialising board & links |
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/bash | |
# usage: | |
# copy-directory-structure.sh <target> <destination> | |
if [ ! -d $2 ]; then | |
mkdir $2 | |
fi | |
find $1 -type d > $2/.lst |
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
/** | |
* @param $dat a php array or variable | |
* prints the parameter to the javascript console, only suitable for use inside dom elements | |
*/ | |
function var_dump_js($dat) { | |
echo '<script type=\'text/javascript\'>console.log(' . json_encode($dat) . ');</script>'; | |
} |
OlderNewer