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
(defn luhn-check-digit [numStr] | |
(let [char-to-integer (fn [c] (Integer/parseInt (str c))) | |
prod-tuple (fn [t] (* (t 0) (t 1))) | |
sum-digits (fn [n] (if (> n 9) (- n 9) n))] | |
(->> numStr | |
reverse | |
(map char-to-integer) | |
(zip (cycle [2 1])) | |
(map (comp sum-digits prod-tuple)) | |
(reduce +) |
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
require 'rexml/document' | |
def showxml(fn) | |
doc = REXML::Document.new(open(fn)) | |
doc.elements.each("//.") { |e| | |
x=e | |
ps = [] | |
while x != nil do | |
ps << x.name | |
x = x.parent |
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 sshlog () { | |
if [ "x$1" = "x" ]; then | |
echo "simple logging wrapper for ssh." | |
echo "use as usual ssh" | |
ssh | |
else | |
TARGET=$1 | |
mkdir -p ~/ssh-log | |
LOGFILE=~/ssh-log/$TARGET.$(date +%Y-%m-%d_%H.%M.%S).log | |
ssh $@ | python $HOME/timestamp-logger.py $LOGFILE |
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 Text.Regex.TDFA | |
import Data.Time.Format | |
import Data.Time.Clock | |
import System.Locale | |
import Data.Maybe | |
import qualified Data.ByteString.Lazy.Char8 as B | |
parseTimestamp :: B.ByteString -> UTCTime | |
parseTimestamp s = fromJust $ parseTime defaultTimeLocale "%F %T%Q/%Z" (B.unpack s) |
NewerOlder