Skip to content

Instantly share code, notes, and snippets.

View gpampara's full-sized avatar

Gary Pamparà gpampara

  • Pretoria, South Africa
View GitHub Profile
/*
Operations are allowed on UnitIntervals that violate the closedness
of the structure, but these violations are not realized until the
underlying value is determined.
*/
final class UnitInterval private (private val underlying: Double) {
def - (other: UnitInterval) =
new UnitInterval(underlying - other.underlying)
@gpampara
gpampara / TimeVaryingGBestPSO.scala
Created July 9, 2018 10:22
Time varying gbest pso
package cilib
package example
import cilib.pso._
import cilib.pso.Defaults._
import cilib.exec._
import eu.timepit.refined.auto._
import scalaz._
### Keybase proof
I hereby claim:
* I am gpampara on github.
* I am gpampara (https://keybase.io/gpampara) on keybase.
* I have a public key ASAtNa0VALoo2M0QosPJCbti-9sHpkkWSoxfY5EJ9TPflAo
To claim this, I am signing this object:
// Normal null checking
Outer outer = new Outer();
if (outer != null && outer.nested != null && outer.nested.inner != null) {
System.out.println(outer.nested.inner.foo);
}
// Safer
def resolve[A](x: A): Option[A] = Option(x)
Option(new Outer()).flatMap(x => resolve(x.nested)).flatMap(x => resolve(x.inner)).map(x => System.out.println(x))
@gpampara
gpampara / gist:00616c89e4c33f6deed6
Last active August 29, 2015 14:23
ghc-mod master and GHC 7.10.1
1. After installing GHC, checkout ghc-mod (https://github.com/kazu-yamamoto/ghc-mod) and build master using 7.10.1
2. Update your PATH to include the locaiton of the built 'ghc-mod' and 'ghci-mod' binaries
3. Update your emacs config to load up PATH to correctly locate ghc-mod. I needed to add some elisp to my emacs config
;; Some shell variable magic
(let ((path (shell-command-to-string ". ~/.zshrc; echo -n $PATH")))
(setenv "PATH" path)
(setq exec-path
#!/bin/sh
# Must be called with two command-line args.
# Example: git-svn-relocate.sh http://old.server https://new.server
if [ $# -ne 2 ]
then
echo "Please invoke this script with two command-line arguments (old and new SVN URLs)."
exit $E_NO_ARGS
fi