This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns user | |
(:use arcadia.core) | |
(:import [UnityEngine | |
Vector3 | |
Time | |
Gizmos | |
Color | |
Debug | |
Plane | |
Mathf])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
puts open("db/#{ARGV.first}").read |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Copyright (c) Alan Dipert. All rights reserved. | |
;; The use and distribution terms for this software are covered by the | |
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) | |
;; By using this software in any fashion, you are agreeing to be bound by | |
;; the terms of this license. | |
;; You must not remove this notice, or any other, from this software. | |
(defn paths | |
"Enumerate paths into a nested map." | |
([root] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn fuzzy-finder-fn [name-fn resource-fn] | |
(fn [string-or-regex] | |
(let [f (if (instance? System.Text.RegularExpressions.Regex string-or-regex) | |
#(re-find string-or-regex (name-fn %)) | |
(let [^String s string-or-regex] | |
#(let [^String n (name-fn %)] | |
(.Contains n s))))] | |
(filter f (resource-fn))))) | |
;; example: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro chance [& body] | |
(let [r (gensym "chance") | |
pairs (sort-by first (partition 2 body)) | |
odds (map first pairs) | |
exprs (map last pairs) | |
sum (apply + odds) | |
fracs (map #(float (/ % sum)) odds) | |
frac-pairs (partition 2 (interleave fracs exprs))] | |
`(let [~r (rand)] | |
(cond |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns curve) | |
(defn power [x a] | |
(Math/Pow x a)) | |
(defmacro v* [a b] `(Vector2/op_Multiply ~a ~b)) | |
(defmacro v+ | |
([a] a) | |
([a b] `(Vector2/op_Addition ~a ~b)) | |
([a b & vs] (reduce |
OlderNewer