Skip to content

Instantly share code, notes, and snippets.

View lancelet's full-sized avatar
🖖
Reconfiguring the Primary Power Coupling

Jonathan Merritt lancelet

🖖
Reconfiguring the Primary Power Coupling
View GitHub Profile
@lancelet
lancelet / drip-classpath-test.sh
Created November 19, 2012 19:10
Does drip pick up classpath changes?
#!/bin/bash
#-----
# Test to see if drip picks up classpath changes.
#
# NB: For safety, create a new directory in which to execute this script!
#
# The drip utility (https://github.com/flatland/drip) is a way to launch a JVM
# quickly. It works by keeping "a fresh JVM spun up in reserve with the
# correct classpath and other JVM options".
#
@lancelet
lancelet / .emacs
Last active December 17, 2015 11:29
NOTE: This now has its own repository: https://github.com/lancelet/dotemacs Yes, it's sad, I know. My .emacs file. It comes with an accompanying shell script which sets up the ~/.emacs.d/vendor directory with required additions. This isn't guaranteed to work for anyone but me.
;---------------------------------------;
; JONATHAN MERRITT'S EMACS STARTUP FILE ;
;---------------------------------------;
; Setup:
;
; 1. Create vendor directory:
; > mkdir -p ~/.emacs.d/vendor
;
; 2. Install milkypostman/powerline (cute status bar / modeline):
; > cd ~/.emacs.d/vendor
@lancelet
lancelet / gist:595a48ee9db984727e0b
Created July 3, 2014 01:09
Project typeclasses over collections?
import scala.collection.immutable._
object TypeclassProjection {
trait Show[T] {
def show(t: T): String
}
object Show {
def apply[T](showFn: T => String): Show[T] = new Show[T] { def show(t: T): String = showFn(t) }
}
@lancelet
lancelet / yi.hs
Created October 20, 2014 04:24
yi.hs configuration (modeline doesn't seem to cooperate)
-- in ~/.config/yi/yi.hs
import Data.Monoid ((<>))
import Yi (Attributes(..), Config, UIConfig(..), configUI, defaultEmacsConfig, emptyAttributes, override, yi)
import Yi.Style (Color(..), UIStyle(..), grey, withBg, withFg)
import Yi.Style.Library (defaultTheme)
config :: Config
config = defaultEmacsConfig
{ configUI = (configUI defaultEmacsConfig)
@lancelet
lancelet / monop.hs
Last active August 29, 2015 14:17
Monoid operations on the free monoid
import Data.Monoid (Monoid(..))
{-
Summary
If we have a type, 'a', and some monoid defined for 'a', then 'Operation' is an AST representing
computations that could be done by the monoid. 'Operation' can represent something like
[ 1, 2, 3 ] ++ ( [4, 5, 6] ++ [] )
or
@lancelet
lancelet / WillBeTrue.scala
Last active March 2, 2016 10:19
WillBeTrue
// (This is an older version of the Gist here: https://gist.github.com/lancelet/0d0713af7eb1401c9b1a)
// (Only hanging around because I posted it to a Gitter group.)
// Intended to be run in shapeless current master sbt console; use :paste
//--- paste this first to define the macro
import scala.language.experimental.macros
import scala.reflect.macros.whitebox
import scala.util.control.NonFatal
@lancelet
lancelet / WillBeTrue.scala
Created March 2, 2016 10:09
WillBeTrue (Improved)
// Intended to be run in shapeless sbt console; use :paste
//--- paste this first to define the macro
import scala.language.experimental.macros
import scala.reflect.macros.whitebox
import scala.util.control.NonFatal
object WillBeTrue {
@lancelet
lancelet / rk4.hs
Last active October 31, 2017 06:13
Runge-Kutta integration of some equations in Haskell
#! /usr/bin/env nix-shell
#! nix-shell -i runghc -p 'ghc.withPackages (ps: [ ps.hmatrix ])'
import Numeric.LinearAlgebra
-- | Represents the coupled ODEs (Example (1)):
--
-- y[0] = position = p
-- y[1] = velocity = v
--
@lancelet
lancelet / Main.hs
Created December 26, 2017 02:14
OpenCL + Vector + Kernel Quasiquoting
{-# LANGUAGE QuasiQuotes #-}
module Main where
import Control.Parallel.OpenCL
import Data.Vector.Storable (Vector)
import qualified Data.Vector.Storable as V
import Data.Vector.Storable.Mutable (IOVector)
import qualified Data.Vector.Storable.Mutable as MV
import Foreign (castPtr, nullPtr, sizeOf)
import Foreign.C.Types (CFloat)
@lancelet
lancelet / candy.hs
Created November 24, 2018 06:32
FP vs OO; A Better Way to Count Candy
#!/usr/bin/env stack
{- stack
script
--resolver lts-12.19
--package containers
--package double-conversion
--package text
--package text-show
-}
{-