Skip to content

Instantly share code, notes, and snippets.

let inline isPhom x y z =
let sx, sy, sz = x%13,y%13,z%13
if sx = sy && sy = sz then true
else
let tx, ty, tz = x/13, y/13, z/13
if tx = ty && ty = tz then
let a = max sx sy |> max sz
let c = min sx sy |> min sz
let b = (sx + sy + sz)/3
a = b + 1 && a = c + 2
public class UChecker:IDisposable
{
public int[,] CardSet;
public int[,] PhomMark;
private int _countNotPickedCard;
private int _countCardNotInPhom;
public int CountCardNotInPhom { get { return _countCardNotInPhom;} set{ _countCardNotInPhom = value;}}
private int _countEatenCardInHand;
public class Point
{
public double X;
public double Y;
public double Z;
}
// inspired by stylus: http://learnboost.github.com/stylus/
// constant
transparent = 0.8
fonts = Segoe UI, Arial
// function
border-radius()
-moz-border-radius arguments
-webkit-border-radius arguments
@vietnt
vietnt / gist:1103568
Created July 25, 2011 04:39
template_engine
// inspired by python, razor
ul
@foreach (var item in menus)
li
a [href='@item.Link']
@item.Text
p
Sum: @x + @y = @(x + y)
@vietnt
vietnt / gist:1165535
Created August 23, 2011 15:48
new language
int Sum(int[] list)
<- 0 += x in list
int Max(int[] list)
<- max = x
if x > max
x in list
max = int.MinValue
QSort(int[] list, int lo, int hi)
@vietnt
vietnt / gist:1170434
Created August 25, 2011 10:58
_new real-code
ITemplate Compile (string path, string id, string input, List<string> usings)
<- assembly.CreateInstance (typeName)
typeName = "Templates_Template_{0}_{1}".FormatWith (id, DateTime.Now.Ticks)
assembly = results.CompiledAssembly
results = provider.CompileAssemblyFromSource (options, code)
provider = new CSharpProvider
<- new Dictionary<string, string>
<- {"CompilerVersion", "v4.0"}
ITemplate Compile(string assemblyPath, string templateId, string input, List<string> usings)
{
var providerOptions = new Dictionary<string, string>();
providerOptions.Add("CompilerVersion", "v4.0");
ITemplate _template = null;
var usingBuilder = new StringBuilder();
foreach (var @using in _usings)
{
public Slice Get(Slice key, int transactionId = -1)
{
var record = UseTransaction (transactionId, tr=>tr.Records.FindLast (r=> r.Key == key));
if (record != null) return record.Value;
var r = log.Get(key);
if (v != null) return v;
return InternalGet(key);
}
@vietnt
vietnt / gist:1196575
Created September 6, 2011 04:22
simple ioc
open System
open System.Linq
open System.Collections.Generic
open System.Collections.Concurrent
open Microsoft.FSharp.Collections
open System.Reflection
type Container() =
let _map = new HashMultiMap<Type,Type>(HashIdentity.Structural)
let _activated = new ConcurrentDictionary<Type, obj>()