Skip to content

Instantly share code, notes, and snippets.

@maio
maio / graphql-basics-workshop-pastebin.md
Last active December 10, 2018 10:20
GraphQL Basics Workshop
@maio
maio / avast-workshop-tests.org
Created December 14, 2016 05:34
Avast Workshop - Tests

Avast Workshop - Tests

@maio
maio / real-cpu-usage-chart.10s.sh
Last active January 5, 2016 14:17
CPU usage chart for BitBar
#!/bin/bash
# Real CPU Usage Chart
# BitBar plugin
#
# by Marian Schubert
# Based on work by Mat Ryer and Tyler Bunnell
#
# This script requires https://github.com/holman/spark
#
@maio
maio / core.clj
Last active September 22, 2015 01:31
YouTube IRC bot
(ns fetaoin.core
(:require [irclj.core :as irc]
[clojure.data.json :as json]))
;; HTTP stuff
(defn fetch-json [url]
(json/read-str (slurp url)))
;; YouTube API
(def api-key "sekret")
@maio
maio / deaccent.clj
Created December 26, 2014 13:06
Remove accent from string using Clojure
(defn deaccent [str]
"Remove accent from string"
;; http://www.matt-reid.co.uk/blog_post.php?id=69
(let [normalized (java.text.Normalizer/normalize str java.text.Normalizer$Form/NFD)]
(clojure.string/replace normalized #"\p{InCombiningDiacriticalMarks}+" "")))
(ns kata.core-test
(:require [clojure.test :refer :all]))
;; Langton's Ant - http://en.wikipedia.org/wiki/Langton's_ant
;;
;; At a white square, turn 90° right, flip the color of the square, move forward one unit
;; At a black square, turn 90° left, flip the color of the square, move forward one unit
(def flip
{:black :white
@maio
maio / DefaultKeyBinding.dict
Created June 5, 2014 09:26
OSX KeyBindings
maio:~ $ cat ~/Library/KeyBindings/DefaultKeyBinding.dict
{
"~d" = "deleteWordForward:";
"^w" = "deleteWordBackward:";
"~f" = "moveWordForward:";
"~b" = "moveWordBackward:";
"^/" = "undo:";
"^g" = {
"^g" = ("insertText:", "marian.schubert@gmail.com");
"^d" = ("insertText:", "marian.schubert@gooddata.com");
@maio
maio / ant.js
Last active August 29, 2015 14:00
Langton's Ant (Dojo #7)
describe('Ant', function () {
it('turns right on white cell', function() {
expect(resolveAntDirection('north', 'white')).toEqual(turnRight('north'));
expect(resolveAntDirection('south', 'white')).toEqual(turnRight('south'));
expect(resolveAntDirection('west', 'white')).toEqual(turnRight('west'));
});
it('turns left on black cell', function() {
expect(resolveAntDirection('north', 'black')).toEqual(turnLeft('north'));
expect(resolveAntDirection('south', 'black')).toEqual(turnLeft('south'));
(ns kata.core-test
(:use clojure.test)
(:require [clojure.string :as str]))
(def default-delimiter ",|\n")
(defn parse-delimiter [s]
(if-let [[_ delimiter x] (first (re-seq #"//(.)\n(.*)" s))]
[(re-pattern delimiter) x]
[(re-pattern default-delimiter) s]))
@maio
maio / .gitconfig
Created June 20, 2013 07:59
git fight
[alias]
fight = !bash -c 'echo "$0: `git grep $0 | wc -l`" && echo "$1: `git grep $1 | wc -l`"'
# Usage:
#
# $ git fight cancelled canceled
# cancelled: 664
# canceled: 19