Skip to content

Instantly share code, notes, and snippets.

View md2perpe's full-sized avatar

Per Persson md2perpe

View GitHub Profile
@jdp
jdp / bleb.php
Created July 8, 2010 07:03
BlebCT's PHP framework
<?php
/**
* The Bleb PHP Framework
*
* @author Justin Poliey <jdp34@njit.edu>
* @copyright BlebCT 2010
* @package bleb
*/
namespace Bleb {
{-# LANGUAGE MultiParamTypeClasses #-}
module Main where
import Reactive -- see http://gist.github.com/643798
data Operation = Push Double
| Drop
| Add
| Subtract
{-# LANGUAGE MultiParamTypeClasses #-}
module Reactive (Reaction(beginning), Reactive(react), simulate) where
class Reaction r where
beginning :: r
class (Reaction r) => Reactive r e where
react :: r -> e -> r
main = interact prg
prg :: String -> String -- pure function!
prg s = unlines $ [ "What is your name?"
, "Hi, " ++ name ++ "!"
, "Where do you live?"
, place ++ " is very nice, isn't it?" ]
++ re 2 (lns !! 2)
where lns = lines s
@GodsBoss
GodsBoss / gist:960745
Created May 7, 2011 19:06
Access to protected base class members of a subclass via another subclass.
<?php
class Base{
protected $x;
public function getX(){
return $this->x;}}
/**
* This class tries to ensure that $x is always an integer.
@kencan
kencan / Fib.scala
Created May 30, 2011 15:12
Fast Fibonacci implementation
def fibFast1(num: Int): BigInt = {
var a: BigInt = 1
var b: BigInt = 0
var c: BigInt = 1
for(bit <- bits(num)){
bit match {
case 1 => {
a = (a+c)*b
b = b*b + c*c
}
@johan
johan / github-logo.svg
Created June 4, 2011 11:15
Github social coding logo, minimal SVG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johan
johan / octocat.svg
Created June 4, 2011 11:16
Github octocat avatar, SVG format
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@panesofglass
panesofglass / ObjectPool.fs
Created June 9, 2011 05:33
Updated ObjectPool from fssnip.net/5H
namespace Fracture
/// Agent alias for MailboxProcessor
type Agent<'a> = MailboxProcessor<'a>
/// One of three messages for our Object Pool agent
type PoolMessage<'a> =
| Get of AsyncReplyChannel<'a>
| Count of AsyncReplyChannel<int>
| Put of 'a
@jorgeortiz85
jorgeortiz85 / FoldUnion.scala
Created June 9, 2011 17:11
Folding over Scala union types
type ¬[A] = A => Nothing
type ∨[T, U] = ¬[¬[T] with ¬[U]]
type ¬¬[A] = ¬[¬[A]]
type |∨|[T, U] = { type λ[X] = ¬¬[X] <:< (T ∨ U) }
class FoldUnion[T](t: T) {
def boxClass(x: java.lang.Class[_]): java.lang.Class[_] = x.toString match {
case "byte" => manifest[java.lang.Byte].erasure
case "char" => manifest[java.lang.Character].erasure
case "short" => manifest[java.lang.Short].erasure