Skip to content

Instantly share code, notes, and snippets.

@wfaler
wfaler / errors.el
Created April 17, 2014 19:55
emacs haskell install errors
Generating autoloads for inf-haskell.el...done
Generating autoloads for w3m-haddock.el...
Generating autoloads for w3m-haddock.el...done
Saving file /home/wfaler/.emacs.d/el-get/haskell-mode/haskell-mode-autoloads.el...
Wrote /home/wfaler/.emacs.d/el-get/haskell-mode/haskell-mode-autoloads.el
(No changes need to be saved)
sed -e 's/@@GIT_VERSION@@/13.10-77-g35527f9/g;s/@GIT_VERSION@/13.10-77-g35527f9/g;s/@@VERSION@@/13.10/g;s/@VERSION@/13.10/g' < haskell-mode.texi > haskell-mode.tmp.texi
makeinfo -o haskell-mode.info haskell-mode.tmp.texi
make: makeinfo: Command not found
make: *** [haskell-mode.info] Error 127
@wfaler
wfaler / slickcount.scala
Created April 15, 2014 12:57
Ugly aggregation & count
import scala.slick.jdbc.{GetResult, StaticQuery => Q}
case class FooCount(n: String, c: Int)
implicit val getStatusCountResult = GetResult(r => Foo(r.nextString, r.nextInt))
val q = Q.queryNA[FooCount]("SELECT foo, count(foo) FROM bar GROUP BY foo")
- name: ensure postgres key is present
action: apt_key id=ACCC4CF8 state=present url="https://www.postgresql.org/media/keys/ACCC4CF8.asc"
@wfaler
wfaler / ImmutableBean.java
Created March 8, 2014 14:34
ImmutableBean
public final class ImmutableBean{
public final String name;
public final Integer age;
public ImmutableBean(String name, Integer age){
if(name == null || name.length < 1 || age == null || age < 0)
throw new IllegalArgumentException("name must be set and age must be 0 or over");
this.name = name;
// how to decode case objects and UUID in the example below? Encoding works fine.
sealed trait Foo
case object Bar extends Foo
case object Baz extends Foo
case class SomeThing(uuid: UUID, foo: Foo)
implicit def SomeThingCodec = casecodec2(SomeThing.apply,SomeThing.unapply)("uuid", "foo")
implicit def UUIDEncodeJson = new EncodeJson[UUID]{ def encode(uuid: UUID) = jString(uuid.toString)}
@wfaler
wfaler / emacs.txt
Created January 26, 2014 14:02
emacs shortcuts
M-x shell opens shell
C-x C-f open file
C-x C-c exit emacs
C-x C-k kill line after cursor
M-k kill sentence
M-d kill word
C-x Del kill previous sentence
C-g exit mini-buffer
C-space start marking text
@wfaler
wfaler / java-box.sh
Created January 25, 2014 11:36
Java box on Ubuntu 12.04
apt-get update
apt-get upgrade
apt-get install python-software-properties
add-apt-repository ppa:cassou/emacs
add-apt-repository ppa:webupd8team/java
apt-get update
apt-get install emacs24
apt-get install oracle-java7-installer
@wfaler
wfaler / dotemacs.el
Created December 12, 2013 22:27
dotemacs.el
(require 'package)
(add-to-list 'package-archives
'("marmalade" .
"http://marmalade-repo.org/packages/"))
(package-initialize)
(load-theme 'solarized-dark t)
(global-set-key (kbd "M-3") '(lambda () (interactive) (insert "#")))
@wfaler
wfaler / tmux
Created December 1, 2013 19:26
tmux shortcuts
ctrl-b "Prefix", gets into command mode
ctrl-b w list tmux windows
ctrl-b [number] jumps to tmux window number
ctrl-b n go to next window
ctrl-b p go to previous window
ctrl-b & close current window
ctrl-b c new window
ctrl-b , rename window
ctrl-b f find window by name
ctrl-b % split window horizontally into two panes
@wfaler
wfaler / change-file-to-utf8.sh
Created November 28, 2013 17:52
Note on how to change files to UTF-8 encoding regardless of original encoding
TMPFILE="utf8.tmp"
cp $1 $TMPFILE
enc=`file -i $1 | awk 'BEGIN {FS = "="} ; {print $2; }'` # gets encoding of a file
iconv -f $enc -t utf-8 $TMPFILE > $1 # changes encoding to UTF-8
rm $TMPFILE