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
#!/bin/sh -e | |
HOME="/home/user" | |
HOST="foobar" | |
BACKUP_DIR="/var/backup/$HOST" | |
BACKUP_FILE="$HOST-`date -I`.tar.bz2.gpg" | |
MYSQL_FILE="mysql-`date -I`.bak.gpg" | |
RECIPIENT="[email protected]" | |
cd $BACKUP_DIR |
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 get-timezone-delta [dateformat utc-time-string local-time-string] | |
(let [utc-time (f/parse dateformat utc-time-string) | |
local-time (f/parse dateformat local-time-string) | |
abs-delta (t/in-hours (t/interval (t/earliest utc-time local-time) (t/latest utc-time local-time)))] | |
(if (t/after? utc-time local-time) | |
(- abs-delta) | |
abs-delta))) |
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/python | |
import sys | |
from math import sin, cos | |
prefix = """<svg width="800" height="800" xmlns="http://www.w3.org/2000/svg" > | |
<g transform="translate(400,400)"> | |
<circle r="350" style="fill: rgb(190, 195, 230);"></circle> | |
</g> | |
<g transform="translate(400,400)"> |
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 runhaskell | |
import Control.Applicative | |
import Control.Monad | |
plus3 x = x + 3 | |
data List a = Nil | Cons a (List a) | |
deriving (Show) | |
instance Functor List where |
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
for f in *.avi; do file=`basename "$f" .avi`; ffmpeg -i "$f" -acodec libfaac -ab 160000 -vcodec libx264 -b 1200k -threads 0 -f mp4 "$file.mp4"; done |
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
// Install: | |
// npm install lodash request cheerio | |
// Usage: | |
// nodejs hwoteams.js | |
var request = require('request') | |
, cheerio = require('cheerio'); | |
var fs = require('fs'); | |
var _ = require('lodash'); |
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
// Detect primes naively | |
def prime(x: Int): Option[Int] = if ((2 until x).forall(x % _ != 0)) Some(x) else None | |
def primeRatio(x: Int): Double = (x - (1 until x).map(prime).count(_ == None)).toDouble/x | |
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
# | |
# Third iteration, now with reduce! | |
# | |
def getFieldAccessor(fields): | |
return lambda a: reduce(lambda x, y: x[y], fields, a) |
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
/** | |
* Select random letters according to the distribution of letters in Finnish language: | |
* https://docs.google.com/spreadsheet/ccc?key=0AiZHeDrg3BuddFZfTXVnclQ5UWNkaGVuWmdVT3dzMEE&usp=sharing | |
* Ignore the uncommon letters c, z, w, q, x and å | |
*/ | |
import scala.util.Random | |
object RandomLetters { | |
val rnd = Random |
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/python | |
# Select random letters according to the distribution of letters in Finnish language: | |
# https://docs.google.com/spreadsheet/ccc?key=0AiZHeDrg3BuddFZfTXVnclQ5UWNkaGVuWmdVT3dzMEE&usp=sharing | |
# Ignore the uncommon letters c, z, w, q, x and ao | |
import random | |
from itertools import repeat | |
from collections import Counter |