Skip to content

Instantly share code, notes, and snippets.

View md2perpe's full-sized avatar

Per Persson md2perpe

View GitHub Profile
@fundon
fundon / aop.php
Created July 6, 2011 09:40
PHP, Aspect Oriented Programming(AOP). @author: wuzhenyu
<?php
function e($str){echo $str , "\n";}
class AOP
{
static function getInstance()
{
$args = func_get_args();
$class = array_shift($args);
@luqui
luqui / continuous.mkd
Created July 2, 2011 07:38
Continuous well-orders

Let [ ] : Ord -> Relation Nat be a function that realizes an ordinal into a well-ordering of the naturals with that order type.

Given a relation R on the naturals, we define the restricted relation R(<n) to be R but just acting on the first n naturals.

Defn: [ ] is continuous iff for every series of ordinals a_i whose limit is l, for every natural n, there exists an i such that for all j > i, [a_i](<n) = [l](<n).

Intuitively, if you are only looking at a finite prefix of the naturals, you can get to a limit ordinal by going finitely high up its limit sequence.

@dg
dg / ObjectTrait.php
Created July 2, 2011 04:20
Nette\ObjectTrait
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004, 2011 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
<?php
require_once "lib/compra.php";
require_once "lib/sheen.php";
require_once "lib/beggar.php";
use compra\Compra;
use sheen\View;
use beggar\Request;
function templatize($req, $res) {
@svebal
svebal / modifier.parseXML.php
Created June 10, 2011 05:55 — forked from derpixler/modifier.parseXML.php
Smarty Modifier parseXML to Array
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage PluginsModifier
*/
/**
* Smarty {$xml|parseXML} function plugin
*
@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
@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
@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.
@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.
@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
}