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
# Shows the exit value of the last executed command | |
function previous_command_status() | |
{ | |
local exit_code=$?; | |
case "$exit_code" in | |
0) printf "\033[1;4;32m%-${COLUMNS}s\033[00m" "Command successful";; | |
126) printf "\033[1;4;31m%-${COLUMNS}s\033[00m" "Permission problem or command is not an executable";; | |
127) printf "\033[1;4;31m%-${COLUMNS}s\033[00m" "Command not found";; | |
130) printf "\033[1;4;31m%-${COLUMNS}s\033[00m" "Script canceled";; | |
*) printf "\033[1;4;31m%-${COLUMNS}s\033[00m" "Command failed with exit code $exit_code";; |
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 lookAndSay(num) { | |
var look = /(1+|2+|3+)/g; | |
function say(match, position) { | |
return match.length.toString() + match.substring(0, 1); | |
} | |
return num.toString().replace(look, say); | |
} | |
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 lookAndSay(num) { | |
// TODO: Needs more JQuery | |
return num.toString().replace(/(1+|2+|3+)/g, function(match) { return match.length.toString() + match.substring(0, 1); }); | |
} |
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
# Caesar cipher encoding | |
echo "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG" | tr '[A-Z]' '[X-ZA-W]' | |
# output: QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD | |
# Caesar cipher decoding | |
echo "QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD" | tr '[X-ZA-W]' '[A-Z]' | |
# output: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG | |
# Can also be adjusted to ROT13 instead |
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
#!/usr/bin/env python3 | |
import sys, locale; | |
print(sys.stdout.encoding); | |
print(locale.getpreferredencoding()); | |
# http://www.macfreek.nl/memory/Encoding_of_Python_stdout#StreamWriter_Wrapper_around_Stdout | |
if sys.stdout.encoding != 'UTF-8': | |
sys.stdout = codecs.getwriter('utf-8')(sys.stdout.buffer, 'strict') | |
if sys.stderr.encoding != 'UTF-8': | |
sys.stderr = codecs.getwriter('utf-8')(sys.stderr.buffer, 'strict') |
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
switch (true) | |
{ | |
case (!isset($_GET['action']): | |
require('menu.html'); | |
break; | |
case ($_GET['action'] == 'debug'): | |
require('core/actions/debug.php'); | |
break; | |
case ($_GET['action'] == 'submit'): | |
require('core/actions/submit.php'); |
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
<pre><?php | |
class Module | |
{ | |
// ---- Static methods ---- | |
private static $config = array(); | |
public static function get_config($module_name, $field) | |
{ | |
if (!isset(Module::$config[$module_name])) |
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
[ a b ] | |
[ c d ] | |
[ e f ] | |
[ e c a ] | |
(╯°□°)╯︵ [ f d b ] |
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
// Alerts the user if they typed one of the following (with our without a preceeding backslash) | |
// exit | |
// quit | |
module.exports = (robot) -> | |
robot.respond /([^:]+): \\?(exit|quit)/i, (msg) -> | |
user = msg.match[1] | |
msg.send("#{user}: Try /exit") |
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
// Yells at users for thinking this is an SSH shell | |
// Responds to the following commands (case sensitive, obviously): | |
// ls | |
// rm | |
// cat | |
module.exports = (robot) -> | |
robot.respond /([^:]+): (ls|rm|cat)/, (msg) -> | |
user = msg.match[1] | |
msg.send("Damn it, #{user}. This is a chat room, not a shell!") |