Skip to content

Instantly share code, notes, and snippets.

@wfaler
wfaler / startup_shutdown_java_process.sh
Last active December 28, 2015 20:49
Startup and shutdown script for a Java process on a *nix OS
# startup.sh
#bin/bash
if [ ! -z $1 ]
then
mkdir -p ~/.[appname]
nohup java -Xmx[heapsize] -jar -D[system-property]=$1 [appname].jar > [appname].log &
ps -ef | grep java | grep [startup class] | awk '{print $2}' > ~/.[appname]/[appname].pid
else
echo "startup failed, no [parameter] argument passed"
@wfaler
wfaler / WordAbbrevationPermutations.scala
Created July 5, 2013 15:41
WordAbbrevationPermutations.scala
object WordAbbrevationPermutations extends App{
val list = "FOOO" :: "BAR" :: "BAZ" :: Nil //FBB, FBA, FBZ, FAB..
abbrevations(list).foreach(println)
def abbrevations(list: List[String]): List[String] ={
list match{
case head :: Nil => head.map(_.toString).toList
case head :: tail => head.flatMap(c => abbrevations(tail).map(s => c.toString + s)).toList
}
@wfaler
wfaler / Build.scala
Last active December 18, 2015 01:29
SBT template build
import sbt._
import Keys._
object TemplateBuild extends Build {
val description = SettingKey[String]("description")
resolvers ++= repos
val parentSettings = Defaults.defaultSettings ++ Seq(
parallelExecution := false,
@wfaler
wfaler / detdata.clj
Created April 13, 2013 18:51
defdata example
(defdata MyDataType [name age]
{:name non-empty-string? :age number?} ;; map with validation functions for each key in a concrete instance
SomeProtocol ;; optional protocol/interface implementations
(some-protocol-fn-impl [a] (println a)) ;; implementation of protocol functions
)
@wfaler
wfaler / m2.large
Created April 5, 2013 20:55
m2.4xlarge benchmark with Geekbench: 68.4 GiB of memory 26 EC2 Compute Units (8 virtual cores with 3.25 EC2 Compute Units each) 1690 GB of instance storage 64-bit platform I/O Performance: High EBS-Optimized Available: 1000 Mbps API name: m2.4xlarge
ubuntu@ip-10-29-141-177:~/dist/Geekbench-2.4.2-Linux$ ./geekbench_x86_64
Geekbench 2.4.2 : http://www.primatelabs.com/geekbench/
System Information
Operating System Ubuntu 12.10 3.5.0-17-generic x86_64
Model
Motherboard
Processor Intel Xeon E5-2665 @ 2.40 GHz
1 Processor, 8 Threads
Processor ID GenuineIntel Family 6 Model 45 Stepping 7
@wfaler
wfaler / gist:5322384
Created April 5, 2013 20:30
geekbench, AWS EC2 m1.large
046334981291/UbuntuQuetzal_64_py27 (Ubuntu 64bit image), m1.large instance, zone: us-east-1d
Geekbench Score: 3047
ubuntu@ip-10-85-131-166:~/dist/Geekbench-2.4.2-Linux$ ./geekbench_x86_64
Geekbench 2.4.2 : http://www.primatelabs.com/geekbench/
System Information
Operating System Ubuntu 12.10 3.5.0-17-generic x86_64
Model
Motherboard
@wfaler
wfaler / gist:5248274
Created March 26, 2013 19:13
sync folder with checksum
rsync -rtvucz --delete from/ to/
@wfaler
wfaler / dotemacs.el
Last active December 15, 2015 08:39
.emacs
(require 'package)
(add-to-list 'package-archives
'("marmalade" .
"http://marmalade-repo.org/packages/"))
(package-initialize)
(setq indent-tabs-mode nil)
(setq tab-width 2)
(add-to-list 'load-path "~/.emacs.d/ensime_2.10.0-0.9.8.9/elisp/")
(require 'ensime)
@wfaler
wfaler / GenericMonoid.hs
Created March 23, 2013 16:14
Generic Deriving in Haskell. Swiped and adapted from elsewhere online (think it's derived from Michael Snoymann's work)
{-# LANGUAGE DeriveGeneric, TypeOperators, FlexibleContexts #-}
-- Use GHC 7.4's Generic class for creating Monoid instances
import GHC.Generics
import Data.Monoid
import Data.Map (Map)
-- Generic version of Monoid. We'll need to create an instance for each of the
-- Generic types.
class GMonoid f where
gmempty :: f a
@wfaler
wfaler / QuickCheck.java
Created March 3, 2013 19:49
QuickCheck with Java (this will fail until you implement equals on name
import net.java.quickcheck.Generator;
import net.java.quickcheck.generator.PrimitiveGenerators;
import net.java.quickcheck.generator.iterable.Iterables;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class QuickcheckTest {
@Test