Skip to content

Instantly share code, notes, and snippets.

@wfaler
wfaler / invoke-compiler.scala
Last active August 29, 2015 14:20
compile scala dynamically
import scala.tools.nsc._
import java.io._
val scalaLibraryPath = "/Users/wfaler/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.11.2.jar"
val s = new Settings()
s.bootclasspath.append(scalaLibraryPath)
s.classpath.append(scalaLibraryPath)
val g = new Global(s)
@wfaler
wfaler / heist-config-from014.hs
Created March 30, 2015 21:30
heistconfig-0.14
import Control.Lens
import Heist
heistConfig =
(set hcNamespace "") $
(set hcInterpretedSplices defaultInterpretedSplices) $
(set hcLoadTimeSplices defaultLoadTimeSplices) $
(set hcTemplateLocations [loadTemplates "templates"]) $
emptyHeistConfig
@wfaler
wfaler / init.el
Created March 4, 2015 22:09
init.el
(require 'package)
(setq package-list '(markdown-mode
yaml-mode
js2-mode
find-file-in-project
auto-complete
ghc
nix-mode
dockerfile-mode
ensime
@wfaler
wfaler / docker-notes
Created March 4, 2015 22:06
docker-notes
docker rmi [image id] # remove image
docker ps -a # list all images
docker rm [container id/name] # remove container
docker stop [container id/name]
# start docker, bind container port 4000 to 4000 on host, use host network to access container (only in dev!)
docker run -p 4000:4000 --name [name] --net=host -d [image name] [command]
@wfaler
wfaler / country.json
Created January 8, 2015 16:56
country.json
{"name":"Afghanistan","country_code":"AF"}
@wfaler
wfaler / init.el
Created January 1, 2015 15:15
Auto-setup of Haskell with syntax checking and completion. Requires following cabal packages: happy, alex, ghc-mod. Put this file in ~/.emacs.d/init.el
(require 'package)
(setq package-list '(markdown-mode
yaml-mode
js2-mode
find-file-in-project
auto-complete
ghc
haskell-mode
flycheck
flycheck-haskell
@wfaler
wfaler / iomaybe.hs
Created November 12, 2014 15:40
Must be a better way? some configuration of MaybeT?
ioMaybe :: Maybe a -> (a -> IO (Maybe b)) -> IO (Maybe b)
ioMaybe (Just a) fn = fn a
ioMaybe Nothing _ = return Nothing
@wfaler
wfaler / WTF-SCALA.scala
Created September 19, 2014 15:27
WTF-SCALA.scala
class Foo{
val foo = List(bar)
val bar = baz
val baz = "foo"
}
// compiles
@wfaler
wfaler / init.el
Created May 26, 2014 20:34
Get PATH variables to graphical emacs in OS X
(defun set-exec-path-from-shell-PATH ()
(let ((path-from-shell (replace-regexp-in-string
"[ \t\n]*$"
""
(shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
(setenv "PATH" path-from-shell)
(setq eshell-path-env path-from-shell) ; for eshell users
(setq exec-path (split-string path-from-shell path-separator))))
@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