Skip to content

Instantly share code, notes, and snippets.

@cthom06
cthom06 / test.cs
Last active December 30, 2015 05:09
array example
using System;
namespace Foo
{
class Program
{
public static void Main(string[] args)
{
const int TestSize = 1000000;
@cthom06
cthom06 / gist:5501614
Last active December 16, 2015 21:39
Playing with laziness in f#
module LazyStuff.Main
open System
(* I dont know if this is actually fast *)
type FastLazy<'a> = {
mutable Value : 'a option;
Func : unit -> 'a;
}
with
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication8
{
class Program
{
@cthom06
cthom06 / Skim.fs
Last active December 15, 2015 23:49
module Skim.Main
open System
open System.IO
open System.Linq
type Sexp =
| Atom of Value
| List of Sexp list
and Value =
open System;
exception ParseError of string
(* A token represent a single element of the parse tree *)
type Token =
| EOFToken
| NumberToken of double
| IdentifierToken of string
| OperatorToken of char
@cthom06
cthom06 / newplus.user.js
Created April 11, 2012 17:21
Widen content on Google plus
// ==UserScript==
// @match https://plus.google.com/*
// ==/UserScript==
var s = document.createElement("style");
s.type = "text/css";
s.innerText = ".w5faHc {display: none;} .ncGWdc, .v1WCLe, .SG, .Te { width: auto;}";
document.head.appendChild(s);
func wrapHandler(f func(user, request), perm int) func(request) {
return func(r request) {
user := getuser(r)
if user.priv < perm {
write("no permission foo'!")
} else {
f(user, r)
}
}
}
import pyaudio, threading, base64, speex, audioop, socket, sys
class Packet:
""" Use this class to parse dAmn packets.
Data is stored in the attributes cmd, param,
args, body and raw.
"""
def __init__(self, data=None, sep='='):
self.cmd, self.param, self.args, self.body, self.raw = None, None, {}, None, data
========= ./examples/1linefac.pet =========
fac:=|x{if(x|{x*fac(x-1)}|{1})}main:=|{x:=2*2y:=6+1print("fac(x)"fac(x)"fac(y)"fac(y))}main()
--------------------------------------
fac(x) 24 fac(y) 5040
========= ./examples/badscope.pet =========
package damn
import (
"os"
"bytes"
)
type PacketBody struct {
Args map[string]string
Body string