Skip to content

Instantly share code, notes, and snippets.

@wfaler
wfaler / cake-pattern-example.scala
Created October 22, 2012 16:57
simple-cake-pattern-example.scala
// simple example of the cake pattern
// abstract DAO trait
trait Repository[A, B]{
// saves an entity, returns an ID
def save(entity: A): B
// more features..
}
trait RdbmsRepository extends Repository[MyUserCaseClass, Long]{
@wfaler
wfaler / bind-consul.sh
Created September 9, 2015 19:01
use consul as DNS for local services, fronted by Bind for the rest
sudo apt-get install bind9 bind9utils bind9-doc
wget https://dl.bintray.com/mitchellh/consul/0.5.2_linux_amd64.zip
/etc/bind/named.conf.options:
options {
directory "/var/cache/bind";
recursion yes;
allow-query { localhost; };
forwarders {
@wfaler
wfaler / xmonad.hs
Created June 26, 2018 06:30
xmonad for ultra-wide screen
import XMonad
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.DynamicLog
import Control.Monad
import qualified Data.Map as M
import Graphics.X11.Xlib
import XMonad.Prompt

This agreement is based on the Apache Software Foundation Contributor License Agreement. (v r190612)

Thank you for your interest in software projects stewarded by Chaordic GmbH (“Chaordic”). In order to clarify the intellectual property license granted with Contributions from any person or entity, Chaordic must have a Contributor License Agreement (CLA) on file that has been agreed to by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as the protection of Chaordic and its users; it does not change your rights to use your own Contributions for any other purpose. This Agreement allows an individual to contribute to Chaordic on that individual’s own behalf, or an entity (the “Corporation”) to submit Contributions to Chaordic, to authorize Contributions submitted by its designated employees to Chaordic, and to grant copyright and patent licenses thereto.

You accept and agree to the following terms and conditions for Your present and

@wfaler
wfaler / ssh-key.yml
Created May 11, 2014 20:04
Ensure your Ansible script doesn't hang on doing ssh operations (like pulling from github)
- name: ensure known hosts
shell: touch ~/.ssh/known_hosts creates=~/.ssh/known_hosts
- name: remove github.com from known host
shell: ssh-keygen -R github.com
- name: ensure github.com in known host
shell: ssh-keyscan -H github.com > ~/.ssh/known_hosts
@wfaler
wfaler / scalap_extracted.scala
Created April 10, 2011 18:24
Scalap signature reading extracted into what will be a util class for Scala 2.9 reflection compatibility.
package com.recursivity.commons.bean.scalap
import scala.tools.scalap.scalax.rules.scalasig._
import tools.scalap._
import scalax.rules.scalasig.ClassFileParser.{ConstValueIndex, Annotation}
import reflect.generic.ByteCodecs
import java.io.{StringWriter, ByteArrayOutputStream, PrintStream}
@wfaler
wfaler / home.nix
Last active April 13, 2021 19:59
Home manager setup
{ config, pkgs, ... }:
{
nixpkgs.overlays = [ (self: super: {
jre = super.jdk11;
}) ];
nixpkgs.config.allowUnfree = true;
home.packages = [
pkgs.kubectl
@wfaler
wfaler / fix bt audio on mac
Last active August 7, 2019 08:05
Fixes stuttering bt on mac.
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Max (editable)" 80
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" 80
defaults write com.apple.BluetoothAudioAgent "Apple Initial Bitpool (editable)" 80
defaults write com.apple.BluetoothAudioAgent "Apple Initial Bitpool Min (editable)" 80
defaults write com.apple.BluetoothAudioAgent "Negotiated Bitpool" 80
@wfaler
wfaler / init.el
Last active December 17, 2018 12:11
Latest init.el, updated for Haskell and engine
(require 'package)
(setq package-list '(markdown-mode
yaml-mode
rjsx-mode
elm-mode
typescript-mode
json-mode
dhall-mode
php-mode
@wfaler
wfaler / prepend-test.scala
Last active June 29, 2017 09:13
Finding out type of prepend.Out
case class Record[A](userId: UUID, createdAt: LocalDateTime, version: Long, data: A)
type MetaData = UUID :: LocalDateTime :: Long :: HNil
def length[R <: HList](record: Record[A])
(implicit gen: Generic.Aux[A, R],
prepend: Prepend[R, MetaData]) = {
val data = gen.to(record.data)
val meta = record.userId :: record.createdAt :: record.version :: HNil