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
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 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 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 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 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 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 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
$ time last > /dev/null | |
real 0m0.006s | |
user 0m0.004s | |
sys 0m0.004s | |
$ time last -i > /dev/null | |
real 0m0.005s | |
user 0m0.008s | |
sys 0m0.000s |
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
# There are more, but these were all I needed for the current project | |
sed -i 's/“/“/g' *.md | |
sed -i 's/”/”/g' *.md | |
sed -i 's/©/©/g' *.md | |
# Check if we have any HTML entities remaining (requires some manual filtering by eye) | |
grep '&' *.md |
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
RED="\[\033[0;31m\]" | |
RESET="\[\033[00m\]" | |
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then | |
#host="@${RED}medtech${RESET}" | |
host="@\h" | |
fi | |
if [ "$color_prompt" = yes ]; then | |
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u${host}\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' |
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
if [ "$color_prompt" = yes ]; then | |
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' | |
else | |
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' | |
fi |