Skip to content

Instantly share code, notes, and snippets.

View selfsame's full-sized avatar

Joseph Parker selfsame

View GitHub Profile
@nasser
nasser / tris.clj
Created November 15, 2014 00:21
triangle index functions
(defn tri-strip
([size] (tri-strip 0 size))
([start size]
(->> (range start (+ start size))
(partition 4 1)
(map (fn [[a b c d]] [a b c
c b d]))
flatten)))
(defn tri-fan
(ns user
(:use arcadia.core)
(:import [UnityEngine
Vector3
Time
Gizmos
Color
Debug
Plane
Mathf]))
(ns creator.core
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [om.core :as om :include-macros true]
[cljs.core.async :as async :refer [chan <! >! put!]]
[om-tools.core :refer-macros [defcomponent]]
[cljs.reader :as reader]
[goog.dom :as gdom]
[om-tools.dom :as dom :include-macros true])
(:import [goog.net XhrIo]))
(fn best-hand
[hand]
(let [ranks (map second hand)
suits (map first hand)
rank-freqs (sort (vals (frequencies ranks)))]
(letfn [(flush? [hand]
(apply = suits))
(straight? [hand]
(let [straight-hands (set (map set (partition 5 1 [\A \2 \3 \4 \5
\6 \7 \8 \9 \T
@thomasballinger
thomasballinger / subprocess.py
Created December 15, 2013 23:26
Using a pseudo-terminal to interact with interactive Python in a subprocess
from subprocess import Popen, PIPE
import pty
import os
from select import select
import sys
import tty
master, slave = pty.openpty()
p = Popen(['python'], stdin=slave, stdout=PIPE, stderr=PIPE)
pin = os.fdopen(master, 'w')