Skip to content

Instantly share code, notes, and snippets.

@games
games / restart-ssh.sh
Created July 2, 2022 10:05
Restart ssh-again on mac
killall ssh-agent
eval `ssh-agent`
ssh-add --apple-load-keychain
ssh-add -L
@games
games / ce.fsx
Created November 17, 2017 12:16
open System
open System.Diagnostics
[<Sealed>]
type MaybeBuilder () =
[<DebuggerStepThrough>]
member inline __.Return value: 'T option = Some value
[<DebuggerStepThrough>]
member inline __.ReturnFrom value: 'T option = value
let (>>=) x f = Option.map f x
let (>>*) x f = Option.bind f x
let third (_, _, c) = c
type Region = Europe | USA | Japan | Others
type Car = { name: string; region: Region; price: decimal; capacity: float }
let taxRateTable = [Europe, [(0.0, 2.0, 1.0m);
@games
games / VideoSprite.ts
Last active July 4, 2021 19:20
VideoSprite
namespace trio {
export var defaultVideoShader: VideoShader;
export class VideoSprite extends PIXI.Sprite {
constructor(texture: PIXI.Texture, withAlpha: boolean = true) {
super(texture);
if (withAlpha) {
if (!defaultVideoShader) {
@games
games / VideoShader.ts
Created October 19, 2015 08:33
VideoShader
namespace trio {
var vertexShader = `
precision lowp float;
attribute vec2 aVertexPosition;
attribute vec2 aTextureCoord;
attribute vec4 aColor;
uniform mat3 projectionMatrix;
#include <iostream>
// { 1 2 3 4 }
// { 5 6 7 8 }
// { 9 10 11 12 }
// {13 14 15 16 }
//
// 4
// 3 8
// 2 7 12
module mytest
open System
open NUnit.Framework
let seq (l: int list) =
let rec helper (acc: int list) (rest: int list) =
match acc, rest with
| [], a :: b -> helper [a] b
| _, [] -> acc
@games
games / gist:5967b2a96a6b093aa001
Last active August 29, 2015 14:23
pick some one from list by weight
let pick items weight =
let rec pick based =
function
| [] -> None
| (w, _) as h :: _ when weight <= w + based -> Some h
| (w, _) :: t -> pick (based + w) t
pick 0.0 items
@games
games / gist:2b0b86d1ee332bed5c47
Last active August 29, 2015 14:23
levenshtein distance
module test
open NUnit.Framework
open FsUnit
open System
let min (a: int) (b: int) (c: int) =
Math.Min(a, Math.Min(b, c))
@games
games / gist:594d4c72e2f8078433e0
Last active August 29, 2015 14:18
a test for Task in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication1 {
class Test {