Skip to content

Instantly share code, notes, and snippets.

View markhibberd's full-sized avatar

markhibberd markhibberd

View GitHub Profile
@munificent
munificent / gist:9749671
Last active June 23, 2022 04:04
You appear to be creating a new IDE...
You appear to be advocating a new:
[ ] cloud-hosted [ ] locally installable [ ] web-based [ ] browser-based [ ] language-agnostic
[ ] language-specific IDE. Your IDE will not succeed. Here is why it will not succeed.
You appear to believe that:
[ ] Syntax highlighting is what makes programming difficult
[ ] Garbage collection is free
[ ] Computers have infinite memory
[ ] Nobody really needs:
@etorreborre
etorreborre / staging.sh
Created March 6, 2014 05:33
I like the new sbt-sonatype plugin
[info] Closing and promoting the Sonatype repo
[info] Nexus repository URL: https://oss.sonatype.org/service/local
[info] Reading staging repository profiles...
[info] Reading staging profiles...
[info] Closing staging repository [comnicta-1031] status:open, profile:com.nicta(9713afb98e890)
[info] Checking activity logs of comnicta-1031 ...
[info] Close process is in progress ...
[info] Checking activity logs of comnicta-1031 ...
[info] Close process is in progress ...
[info] Checking activity logs of comnicta-1031 ...

NOTE: This was first authored on 26 Feb 2014. Things may have changed since then.

C++'s Templates

C++'s templates could be seen as forming a duck typed, purely functional code generation program that is run at compile time. Types are not checked at the initial invocation stage, rather the template continues to expand until it is either successful, or runs into an operation that is not supported by that specific type – in that case the compiler spits out a 'stack trace' of the state of the template expansion.

To see this in action, lets look at a very simple example:

template 
@krishnanraman
krishnanraman / r in scala.txt
Last active October 2, 2020 00:00
Using R from Scala
Step 0. You must have the latest & greatest version of R, and scala 2.10.1, for all of this to work.
Step 1. Download and unzip the MacOS X Binary jvmr_1.0.4.tgz from here: http://cran.r-project.org/web/packages/jvmr/index.html
Step 2. Create a lib folder, and copy jvmr_2.10-1.0.4.jar to that folder.
Step 3. Start R
Step 4. At the R console
>install.packages("jvmr")
@tonymorris
tonymorris / scalaz.scala
Created January 5, 2014 01:16
Questions about \/ and Validation
// Questions about \/ and Validation
object scalaz {
/*
This explanation might help. This is a compilable source file with revisions
available at https://gist.github.com/tonymorris/8263051
Fact: All monads are applicative functors. As has been seen we can witness the
`Applicative` that arises from the `Monad` primitives. Let's illustrate this:
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
[info] benchmark us linear runtime
[info] example 47.3 =
[info] integers 89.2 ==
[info] jp10 180.6 ====
[info] jp100 1089.3 =========================
[info] jp50 585.0 =============
[info] numbers 363.8 ========
[info] twitter1 15.4 =
[info] twitter10 96.8 ==
[info] twitter100 936.2 =====================
@etorreborre
etorreborre / stackedAround.scala
Created October 23, 2013 04:08
Stack Around contexts
import org.specs2._
import matcher._
import execute._
import specification._
// the "larger" context must be mixed-in last
class MySpec extends mutable.Specification with Db with Web {
// prints
// on the web
// in the db
trait Functor {
type M <: { type T }
def fmap[A, B](fa: M { type T = A })(f: A => B): M { type T = B }
}
implicit class EitherRightFunctor extends Functor { self =>
type L
type M = Either { type A = self.L ; type T = B } //doesn't this specify a subtype of Either, rather than Either itself?
def fmap[A0, B0](fa: M { type A = self.L ; type B = A0 })(f: A0 => B0): Either { type A = self.L ; type B = B0 } =
@markhibberd
markhibberd / Setup.hs
Last active December 20, 2015 09:59
Generating runtime source at build step.
#!/usr/bin/env runhaskell
import Data.Time (formatTime, getCurrentTime)
import Data.List (intercalate)
import Distribution.PackageDescription
import Distribution.Verbosity
import Distribution.Simple
import Distribution.Simple.Setup (BuildFlags(..), fromFlag)
import Distribution.Simple.LocalBuildInfo