Skip to content

Instantly share code, notes, and snippets.

Avatar
🏡
Working from home

Yrjö Kari-Koskinen ykarikos

🏡
Working from home
  • Tomorrow Tech
  • Helsinki
View GitHub Profile
View hwoteams.js
// Install:
// npm install lodash request cheerio
// Usage:
// nodejs hwoteams.js
var request = require('request')
, cheerio = require('cheerio');
var fs = require('fs');
var _ = require('lodash');
@ykarikos
ykarikos / gist:0a4c13e6e349e2270b86
Last active Aug 29, 2015
convert bunch of avi files to mp4 for ipad with ffmpeg
View gist:0a4c13e6e349e2270b86
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
@ykarikos
ykarikos / gist:25ebbb38e910c691a52d
Created Sep 26, 2014
Reaktor dev day Monads workshop exercise
View gist:25ebbb38e910c691a52d
-- #!/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
@ykarikos
ykarikos / create-tech-radar.py
Created Oct 28, 2014
Transform Tech radar questionnaire input into svg
View create-tech-radar.py
#!/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)">
@ykarikos
ykarikos / get-timezone-delta.clj
Created Dec 10, 2014
Calculate timezone difference between two dates
View get-timezone-delta.clj
(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 backup.sh
#!/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
@ykarikos
ykarikos / client repl.clj
Last active Aug 29, 2015
Full duplex Websocket connections with manifold streams and aleph http lib
View client repl.clj
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 >>
@ykarikos
ykarikos / gist:f1e6e208789e300f7adc
Created May 30, 2015
Talvikin numeroharjoittelu
View gist:f1e6e208789e300f7adc
(use '[clojure.java.shell :only [sh]])
(defn say [& args] (apply sh "say" args))
(defn say-and-print [n]
(let [n-str (str n)]
(println n-str)
(Thread/sleep 2000)
(say n-str)))
View keybase.md

Keybase proof

I hereby claim:

  • I am ykarikos on github.
  • I am ykk (https://keybase.io/ykk) on keybase.
  • I have a public key whose fingerprint is 2E71 56C3 7760 E735 B175 E053 0E4E A201 3B3A BE42

To claim this, I am signing this object:

@ykarikos
ykarikos / gist:0d5cfa0d0ee467808810
Created Sep 17, 2015
Check that NS record match in all zone name servers
View gist:0d5cfa0d0ee467808810
MASTER=a.iana-servers.net.; DOMAIN=example.com.; dig +short -t NS $DOMAIN @$MASTER |sort >/tmp/$MASTER; for h in `cat /tmp/$MASTER`; do echo - Querying $h:; dig +short -t NS $DOMAIN @$h |sort |diff /tmp/$MASTER -; done