Skip to content

Instantly share code, notes, and snippets.

View quelgar's full-sized avatar
🇦🇺

Lachlan O'Dea quelgar

🇦🇺
View GitHub Profile
@quelgar
quelgar / gist:2497604
Created April 26, 2012 08:24
sbt setting to not check scala-tools
externalResolvers <<= resolvers map { rs =>
Resolver.withDefaultResolvers(rs, scalaTools = false)
}
@quelgar
quelgar / filesizerer.scala
Created July 15, 2012 01:45
Simple Scala example of a pure functional program that does I/O
/*
* Referentially transparent program to print the size of files.
*
* Techniques inspired by:
* "Dead-Simple Dependency Injection"
* Rúnar Óli Bjarnason
* Northeast Scala Symposium, 2012
*
* To run: "scala filesizerer.scala"
* When prompted, enter a file name.
@quelgar
quelgar / jsmap.hs
Last active February 22, 2017 14:54
Is Javascript's array map function basically a comonadic cobind (=>> in Haskell)? Have a look as the jsmap function below.
-- Inspired by http://nedbatchelder.com/blog/201301/stupid_languages.html
-- which describes how the Javascript array.map function seems weird
-- and also http://blog.sigfpe.com/2008/03/comonadic-arrays.html
-- which describes the comonad for arrays
import Data.Array
import Data.Char
class Functor w => Comonad w where
(=>>) :: w a -> (w a -> b) -> w b
@quelgar
quelgar / LensURI.scala
Last active December 18, 2015 17:39
Using Lenses with java.net.URI.
import java.net.URI
/**
* State co-monad.
*
* `Store[F, _]` is the co-monad.
*/
final case class Store[F, R](get: F, set: F => R) {
def map[S](f: R => S): Store[F, S] = Store(get, f compose set)
@quelgar
quelgar / most.hs
Created September 26, 2013 01:35
Find the most frequently occurring item that occurs more than once. Idea from http://skipoleschris.blogspot.com.au/2010/11/functional-programming-challenge-most.html
import qualified Data.Map as Map
-- Find the most frequently occurring item that occurs more than once
-- Idea from http://skipoleschris.blogspot.com.au/2010/11/functional-programming-challenge-most.html
most :: Ord a => [a] -> Maybe a
most xs = fst $ foldl most' (Nothing, Map.empty) xs where
most' (winning, seen) x = (winning', seen') where
winning' = if count > winningCount then Just x else winning
import java.util.*;
import java.util.stream.Stream;
/**
* Find the most frequently occurring item that occurs more than once.
* Idea from http://skipoleschris.blogspot.com.au/2010/11/functional-programming-challenge-most.html
*/
public final class Most {
@quelgar
quelgar / gist:8515708
Created January 20, 2014 06:11
The unconstructable Scala class. If you can figure out how to successfully construct an instance of the class Outer, please let me know how.
final case class Outer(inner: Outer#Inner) {
final case class Inner(a: String)
}
@quelgar
quelgar / iodemo.html
Last active August 29, 2015 13:56
Basic demonstration of purely functional I/O in Javascript. This is just a demonstration of the concept, I doubt it's suitable for real-world use!
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Functional I/O Demo</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.0.min.js"></script>

Lachlan C++ Style Guide

Google also have their own C++ Style Guide that you may find more useful.

C++

I do not use C++.

Pros:

Keybase proof

I hereby claim:

  • I am quelgar on github.
  • I am quelgar (https://keybase.io/quelgar) on keybase.
  • I have a public key whose fingerprint is 943B 4775 C45A 895B DEB2 B425 2DCC 6D93 44B3 8C1B

To claim this, I am signing this object: