Skip to content

Instantly share code, notes, and snippets.

View mbbx6spp's full-sized avatar
🎯
Focusing

Susan Potter mbbx6spp

🎯
Focusing
View GitHub Profile
@mbbx6spp
mbbx6spp / SCALA_WTFS.md
Last active August 29, 2015 13:55
Small sample of reasons why the Scala standard library (especially collections) might need rewriting (many taken from Paul Phillips talks on the Scala Collections library):

Scala WTFs

Small sample of reasons why the Scala standard library (especially collections) might need rewriting (many taken from Paul Phillips talks on the Scala Collections library):

scala> List("a", "b", "c").toSet // the only reasonable line of code in here                          
res1: scala.collection.immutable.Set[String] = Set(a, b, c)
                                                           
scala> List("a", "b", "c").toSet() // seen this when learning Scala first time. ROFL.                        
res2: Boolean = false                                      
@mbbx6spp
mbbx6spp / README.md
Last active August 29, 2015 13:56 — forked from netj/memusg

time for memory

How is there not a standard tool for this already? Bogus.

Tonight I'll rewrite the above shell script in C because it makes no sense to not write something so simple in C and package it up and distribute (at least for Linux and Darwin which is what I care about most).

*<RANT> Also note I begrudgingly add this for Darwin only because every dev I work with at work uses it. Hate it. Pointless when deploying to other NIXes. Why? </RANT>

@mbbx6spp
mbbx6spp / PARAMETRICITY1.md
Last active August 29, 2015 14:06
WIP: Quick, informal introduction to parametricity

Parametricity, Part 1

The basic idea of parametricity is that from the parametric type signatures of "generic" pure functions we can formulate theorems about the the way it behaves. And much more so than functions of specific types.

Assumptions

  1. We assume pure functions only. The notion doesn't hold if a function is dependent on anything outside of it's explicit inputs. It can't. Thankfully all business logic can actually be implemented using pure functions which even a compiler can verify (in my experience) if you write in a decent programming language and don't have insane engineers on your team. Obviously your mileage may vary (YMMV).
  2. The definition language supports parametric polymorphism. Parametric polymorphism is when a function or a data type can be written generically so that it can handle values identically without depending on their type.

Motivations

@mbbx6spp
mbbx6spp / deployer.scala
Last active August 29, 2015 14:06
Monads for free: building a deployment system with pluggable "backends" or "transports" using Category Theory :)
package deployer
import scalaz._
import Scalaz._
import Free._
sealed abstract class ActionExit(code: Int)
final case object ActionExitSuccess extends ActionExit(0)
final case object ActionExitCatchallError extends ActionExit(1)
final case object ActionExitPermError extends ActionExit(126)
@mbbx6spp
mbbx6spp / forcomp.scala
Last active August 29, 2015 14:07
Showing how you might use a for-comprehension in Scala (it isn't a for-loop, promise)
import scalaz._
import Scalaz._
sealed trait DataSourceAttribute
final case object DataSourceHost extends DataSourceAttribute
final case object DataSourcePort extends DataSourceAttribute
final case object DataSourceDriver extends DataSourceAttribute
final case object DataSourceProtocol extends DataSourceAttribute
final case object DataSourceName extends DataSourceAttribute
@mbbx6spp
mbbx6spp / RESULTS.md
Last active August 29, 2015 14:08
Simple ERB micro benchmarks to (in)validate my assumptions of readable vs "more performant" templating code. Basically I had to eat my words.

Results of the benchmark on my MBP with Ruby v1.9.3-p545 looked like this:

$ ruby erb_benchmark.rb                                                                                      
Run options: --seed 1619

# Running tests:


@mbbx6spp
mbbx6spp / keybase.md
Created November 7, 2014 13:55
Keybase.io verification

Keybase proof

I hereby claim:

  • I am mbbx6spp on github.
  • I am mbbx6spp (https://keybase.io/mbbx6spp) on keybase.
  • I have a public key whose fingerprint is CE87 D62D 2F78 7073 7B09 498E BCC9 DA82 9DB1 2C14

To claim this, I am signing this object:

<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script>
<script>
function mkCipher(cipherModule, encoding) {
var that = this;
that.encrypt = cipherModule.encrypt;
that.decrypt = function (data, passphrase) {
var decrypted = cipherModule.decrypt(data, passphrase);
return decrypted.toString(encoding);
};
@mbbx6spp
mbbx6spp / cheatsheet
Last active August 29, 2015 14:09
Skype emoticon art
:)
:):)
:):):)
:):):):)
:):):):):)
:):):):):):)
:):):):):):):)
:):):):):):):):)
:):):):):):):):):)
:):):):):):):):)
$ ./fuck_ruby.rb 2413
Rational
$ ./fuck_ruby.rb
Fixnum