Skip to content

Instantly share code, notes, and snippets.

View jroesch's full-sized avatar

Jared Roesch jroesch

View GitHub Profile
@jroesch
jroesch / gist:4067988
Created November 13, 2012 19:55
IP masking routines in Haskell
module IP where
import Data.Bits
-- takes a String "255.0.0.0/8" and gives us a integer representation
fromIP :: String -> Int
fromIP ip = (((a' `shiftL` 24) + (b' `shiftL` 16) + (c' `shiftL` 8) + d'), maskv)
where
(a, '.':rest) = span (/= '.') ip
(b, '.':rest1) = span (/= '.') rest
@jroesch
jroesch / Tap.scala
Last active December 9, 2015 19:08
An implementation of Ruby's Object#tap method.
package com.jroesch.tap
class Tapable[A](tapped: A) {
def tap : A = {
println(tapped)
tapped
}
def tap[B](f : A => B) : A = {
f(tapped)
@jroesch
jroesch / Template.hs
Last active December 11, 2015 05:49
Working notes for a Haskell Lecture
{-# LANGUAGE FlexibleInstances #-}
module Main where
import System.IO
import qualified Data.Map as M
import Debug.Trace
-- Let's first build a simple parser
-- Token Type
@jroesch
jroesch / ScalaNotes.md
Last active December 12, 2015 01:18
Working notes for a Scala talk

#Scala

Introduction

Now that we have looked at Haskell last week, let's turn our sights to Scala. Scala is a really interesting, and more practically exciting language, because of its current adoption state.

Scala on the JVM

Background

- Pure OO, everything is an Object
- Functional/OO hybrid
- runs on the JVM
- powerful Type System
  • Java performance
@jroesch
jroesch / Typeclass.md
Last active October 23, 2016 15:37
A description of how to translate Haskell style typeclasses to Scala.

Given a Haskell Typeclass:

class Point a where 
     distance :: a -> a -> Double

data Point2D = Point2D { x :: Int
                       , y :: Int } deriving (Show, Eq)

instance Point Point2D where
 distance (Point2D x y) (Point2D x' y') = 
@jroesch
jroesch / fp-links.md
Last active December 12, 2015 04:08
A set of links introducing Haskell and Scala.
@jroesch
jroesch / scala-jobs
Last active December 12, 2015 04:08 — forked from ymasory/bay-scala-jobs
Companies hiring Scala developers in the Bay Area.
- CloudPhysics
- Wordnik
- 10Gen
- Audax Health
- Bizo
- Box
- Coraid
- Ephox
@jroesch
jroesch / Curry.rb
Last active December 14, 2015 04:18
Curried methods in Ruby.
class Object
def curry
CurriedMethod.new self
end
class CurriedMethod
def initialize(object)
@receiver = object
end
@jroesch
jroesch / AdaptiveSplitView.jsm
Created February 26, 2013 02:00
Code Dump of Brian Hackett's JIT Inspector. For reference while gathering IonMonkey TI for comparison with MCJS.
/* vim:set ts=2 sw=2 sts=2 et: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
@jroesch
jroesch / gist:5079271
Created March 4, 2013 01:18
Type System Feature listing, for Lab presentation.
# Scala Type System Features
- Inheritance
- Mixins
- Self types
- path dependent types
- bounded quantification
- existential types
- f-bounded polymorpism
- ad-hoc polymorphism (type classes)
- view bounds