View client repl.clj
1 2 3 4 5 6 7 8 9 10
user=> (use 'ws-test)
nil
user=> @state
{}
user=> (connect "localhost")
true
user=> @@connection
<< stream: {:type "splice", :sink {:type "netty", :sink? true, :closed? false}, :source {:pending-puts 0, :drained? false, :buffer-size 0, :permanent? false, :type "manifold", :sink? true, :closed? false, :pending-takes 1, :buffer-capacity 16, :source? true}} >>
user=> (send-message @@connection {:msg "It works!" :count 1})
<< true >>
View backup.sh
1 2 3 4 5 6 7 8 9 10
#!/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="me@myhost.com"
 
cd $BACKUP_DIR
View gist:4ede2106ad196939339d
1 2 3 4 5 6 7 8 9 10
ykar@FL372:/tmp$ sudo pip uninstall helen_electricity_usage
Uninstalling helen-electricity-usage:
/usr/local/lib/python2.7/site-packages/helen_electricity_usage-0.0.3.dist-info/DESCRIPTION.rst
/usr/local/lib/python2.7/site-packages/helen_electricity_usage-0.0.3.dist-info/METADATA
/usr/local/lib/python2.7/site-packages/helen_electricity_usage-0.0.3.dist-info/RECORD
/usr/local/lib/python2.7/site-packages/helen_electricity_usage-0.0.3.dist-info/WHEEL
/usr/local/lib/python2.7/site-packages/helen_electricity_usage-0.0.3.dist-info/metadata.json
/usr/local/lib/python2.7/site-packages/helen_electricity_usage-0.0.3.dist-info/top_level.txt
/usr/local/lib/python2.7/site-packages/helen_electricity_usage/__init__.py
/usr/local/lib/python2.7/site-packages/helen_electricity_usage/__init__.pyc
View get-timezone-delta.clj
1 2 3 4 5 6 7
(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)))
View create-tech-radar.py
1 2 3 4 5 6 7 8 9 10
#!/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)">
View gist:25ebbb38e910c691a52d
1 2 3 4 5 6 7 8 9 10
-- #!/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
View gist:0a4c13e6e349e2270b86
1
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
View hwoteams.js
1 2 3 4 5 6 7 8 9
// Install:
// npm install lodash request cheerio
// Usage:
// nodejs hwoteams.js
 
var request = require('request')
, cheerio = require('cheerio');
var fs = require('fs');
var _ = require('lodash');
View gist:7831661
1 2 3 4
// 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
 
View getFieldsAccessor.py
1 2 3 4 5
#
# Third iteration, now with reduce!
#
def getFieldAccessor(fields):
return lambda a: reduce(lambda x, y: x[y], fields, a)
Something went wrong with that request. Please try again.