Skip to content

Instantly share code, notes, and snippets.

@Velrok
Velrok / autorepl.sh
Created August 6, 2014 14:03
run 'lein repl' on entering a leiningen project folder without a running repl #zsh
# run lein repl if no repl was allready started for this project
function chpwd {
if [[ -e "$(pwd)/project.clj" ]] && [[ ! -e "$(pwd)/.nrepl-port" ]]
then
echo "Detected clojure project but no .nrepl-port -> running: lein repl."
lein repl &
fi
}
[{:key :email-consent
:type :yes-no
:tags [#{:application/energy-offline}]
:schema (shared/map-has {:email-consent shared/Yes-No})
:group groups/account
:label "Would you like E.ON to email you account management reminders?"
:help-text "E.ON may also use these details to write to you about your account once your switch is complete."}]
@Velrok
Velrok / swarm.json
Created December 21, 2014 23:26
Example swarm config file.
{
"app_name": "mb",
"services": [
{
"service_name": "mb-service",
"components": [
{
"component_name": "mb",
"image": "registry.giantswarm.io/velrok/mb:$version",
"ports": [ "3000/tcp" ],
@Velrok
Velrok / deploy.sh
Created December 21, 2014 23:28
Example deploy script for giantswarm.io
swarm delete -y mb
swarm create --var=version=$(cat ./VERSION) swarm.json
sleep 1
swarm start mb
sleep 1
swarm status mb
@Velrok
Velrok / build.sh
Created December 21, 2014 23:30
Example build script for a clojure app via giantswarm.io
#!/bin/bash
set -e
lein ring uberjar
./increment_version.rb $@
docker build --rm=true -t registry.giantswarm.io/velrok/mb:$(cat ./VERSION) .
docker push registry.giantswarm.io/velrok/mb:$(cat ./VERSION)
@Velrok
Velrok / Dockerfile
Created December 21, 2014 23:31
Example Dockerfile for a clojure app.
FROM java:7
MAINTAINER Velrok
RUN mkdir -p /opt/mb
ADD ./target/mb.jar /opt/mb/mb.jar
ADD ./VERSION /opt/mb/VERSION
ADD ./public /opt/mb/public
WORKDIR /opt/mb
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>velrok.gittify-uswitch-notes.plist</string>
<key>WorkingDirectory</key>
<string>/Users/waldemarschwan/Google Drive/notes</string>
@Velrok
Velrok / dump_mondo_trx.sh
Created November 14, 2015 15:10
Dump all available mondo transactions.
#!/bin/bash
set -e
# yo need to set
# all values must be url encoded!
# export MONDO_EMAIL
# export MONDO_PASSWORD
# export MONDO_CLIENT_ID
# export MONDO_CLIENT_SECRET
@Velrok
Velrok / afile_client.erl
Created April 22, 2016 22:49
learning Erlang
-module(afile_client).
-export([ls/1, get_file/2, put_file/3]).
ls(Server) ->
Server ! {self(), list_dir},
receive
{Server, FileList} ->
FileList
end.
@Velrok
Velrok / ewan-shuffle.clj
Last active January 30, 2017 13:48
Create an algorithm that ensures that for any given sequence there is no more than a run of 2 of the same type. Try to preserve the order as much as possible.
(ns user)
;@here if anyone wants a small friday challenge. Create an algorithm that
;ensures that for any given sequence there is no more than a run of 2 of the
;same type. Try to preserve the order as much as possible.
;ie: not a random shuffle. There can be a continuous run of more than 2
;at the end of the sequence
(def problem [:a :a :a :a :a :a :b :b :c :a :b :b :b])
(def large-problem (doall (map (fn [_]
(->> #{:a :b :c}