This file contains hidden or 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
| # Number of possible starting configurations of an enigma machine | |
| letters = 26 | |
| rotors_total = 5 | |
| rotors_machine = 3 | |
| cables = 10 # Must be < letters/2 | |
| def f(n): # Factorial | |
| s = 1; | |
| for i in xrange(2, n+1): | |
| s *= i |
This file contains hidden or 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
| var valid_first = []; | |
| var valid_second = []; | |
| for (var i = 0, len = 0xFFFF; i < len; i++) { | |
| try{ | |
| var char = String.fromCharCode(i); | |
| if(char.toLowerCase() != char.toUpperCase() && valid_second.indexOf(char.toLowerCase().charCodeAt(0)) >= 0){ | |
| continue; | |
| } | |
| document.body.setAttribute('a' + char, ''); | |
| document.body.removeAttribute('a' + char); |
This file contains hidden or 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 getAllProperties(obj){ | |
| var allProps = Object.getOwnPropertyNames(obj); | |
| Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).forEach(function add(prop){ | |
| if (allProps.indexOf(prop) === -1) | |
| allProps.push(prop) | |
| }); | |
| return allProps | |
| } | |
| function jsrecursivegrep(obj, value, length){ |
This file contains hidden or 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
| /* | |
| You can use this to convert a DOM element or a HTML string to markdown. | |
| Usage examples: | |
| var markdown = toMarkdown(document.getElementById("content")); | |
| // With jQuery you can easily convert HTML strings | |
| var markdown = toMarkdown($("<ul><li>Hi!</li></ul>")[0]); |
This file contains hidden or 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 xml.etree.cElementTree as etree | |
| def traverseEtree(tree,traverser): | |
| traverser.start(tree) | |
| traverser.data(tree.text) | |
| for child in tree: | |
| traverseEtree(child,traverser) | |
| traverser.end(tree) | |
| traverser.data(tree.tail) |
NewerOlder