Skip to content

Instantly share code, notes, and snippets.

@panesofglass
panesofglass / reload.fs
Created June 11, 2012 02:57
Better than a REPL - Reload!
// 1. Watch source files for changes.
// 2. When a change is detected, recompile.
// 3. When assembly changes are detected, reload. (katana?)
// 4. Allow editing of files in a gui (dropbox integration?)
#if INTERACTIVE
#r @"..\packages\FAKE.1.64.6\tools\FakeLib.dll"
#endif
open System
@loudej
loudej / option-a.cs
Created June 12, 2012 20:56
Unify Request and Response representation
namespace Owin
{
public delegate void AppDelegate(
IDictionary<string, object> env,
ResultDelegate result,
Action<Exception> fault);
public delegate void ResultDelegate(
string status,
IDictionary<string, string[]> headers,
@palladin
palladin / gist:3121922
Created July 16, 2012 10:09
HLists, Peano & Type-level computations
type HList = interface end
and HNil = HNil with
static member inline (|*|) (f, HNil) = f $ HNil
interface HList
and HCons<'a, 'b when 'b :> HList> = HCons of 'a * 'b with
static member inline (|*|) (f, HCons(x, xs)) = f $ HCons(x, xs)
interface HList
type Peano = interface end
and Zero = Zero with
@einblicker
einblicker / HANSEI.fs
Created August 3, 2012 07:50
HANSEI in F#
//HANSEIとはprobabilistic programmingを行うためのtaglessなインタプリタのこと。
//確率モデルをプログラムの形で書くとパラメータの推論を自動で行なってくれる。
//oleg氏の論文だとreify/reflectを使ったdirect styleのモナドで記述されている。
//http://okmij.org/ftp/kakuritu
//要はこちらのスライドで紹介されているものをmonadやHOASを使って内部DSLとして実装したもの。
//http://www.slideshare.net/tsubosaka/infernetlda
//こちらの方の記事も参考になる。
//http://d.hatena.ne.jp/rst76/20100706/1278430517
@dgabriele
dgabriele / bp.cpp
Created August 11, 2012 18:59
lock-free Bloom filter with quiescent consistency
#include <iostream>
#include <atomic>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <stdint.h>
#include <limits.h>
class bloom_filter
@SidneyAllen
SidneyAllen / StackMob.cs
Created August 30, 2012 19:37 — forked from nixbb/StackMob.cs
StackMob OAuth 2.0 Unity 3D Example
using UnityEngine;
using System.Collections;
using System.Security.Cryptography;
using System;
using System.Text;
public class StackMob : MonoBehaviour
{
public const string acceptHeader = "application/vnd.stackmob+json; version=0"; // 0 = development, 1 = production
public const string apiKey = "e78a2646-d479-47b1-9ae5-65732c5eabdc"; // nixApp
@bittercoder
bittercoder / create_users.py
Created August 31, 2012 01:22
Using Python requests library to generate 15,000 ET users
#!/usr/bin/env python
# Generate 15,000 users in Enterprise Tester with admin permissions...
import json
import requests
from requests.auth import HTTPBasicAuth
server = 'http://localhost:8080/EnterpriseTester'
proxyDict = { 'http': '127.0.0.1:8888'} # so we can capture requests in fiddler
auth = HTTPBasicAuth('Administrator', 'password')
@basvandijk
basvandijk / TaglessSerialization.hs
Created September 8, 2012 10:31
Tagless, Applicative, bidirectional serialization combinators
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
import Control.Applicative
class Field a where
fieldType :: a -> String
fieldRead :: String -> a
@gclaramunt
gclaramunt / Ids.scala
Created September 9, 2012 03:05
Tagged Ids using Phantom types
trait Entity
trait User extends Entity
trait Product extends Entity
case class Id[T<:Entity](id:String)
def buy(pId:Id[Product],uId:Id[User])="Bought product %s for user %s".format(pId.id,uId.id)
val pId=new Id[Product]("1")
@endolith
endolith / export_google_starred_locations.py
Created October 16, 2012 02:29
Export Google Maps starred locations
# -*- coding: utf-8 -*-
"""
Go to Google Bookmarks: https://www.google.com/bookmarks/
On the bottom left, click "Export bookmarks": https://www.google.com/bookmarks/bookmarks.html?hl=en
After downloading the html file, run this script on it to generate a KML.
"""