Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View sgrove's full-sized avatar
💭
Infinigraph, and beyond!

Sean Grove sgrove

💭
Infinigraph, and beyond!
View GitHub Profile
@sgrove
sgrove / framebuffer.cljs
Created June 4, 2015 22:08
Framebuffer draw call working and not working
(defn draw-fn [gl driver programs]
(fn [state]
(let [{:keys [p mv
color-texture specular-texture
sphere
model
rotation]} (:scene state)
now (/ (.getTime (js/Date.)) 50)
rotation (- (utils/deg->rad now))
program (get programs :simple)
@sgrove
sgrove / buffferSubDataSuccess.cljs
Created June 16, 2015 21:04
bufferSubData Success!
(defn tick
"Takes the old world value and produces a new world value, suitable
for rendering"
[state time]
;; We get the elapsed time since the last render to compensate for
;; lag, etc.
(let [time-now (.getTime (js/Date.))
elapsed (- time-now (:last-rendered state))
pyramid-diff (/ (* 50 elapsed) 100000)
cube-diff (/ (* 75 elapsed) 100000)
@sgrove
sgrove / test_01.cljs
Created June 17, 2015 22:15
Basic GD vertices test
(ns gampg.perf.test-01
(:require [gamma.api :as g]
[gamma.program :as p]
[gamma-driver.api :as gd]
[gamma-driver.drivers.basic :as driver]
[thi.ng.geom.core :as geom]
[thi.ng.geom.core.matrix :as mat :refer [M44]]))
(def title
"1. Testing basic performance")
$ rm -rf ~/.m2/repository/org/clojure/clojurescript/0.0-2411; rm -rf resources/public/js/bin-debug/; rm -rf resources/public/js/out/; lein clean; lein cljsbuild once dev
Compiling ClojureScript.
Retrieving org/clojure/clojurescript/0.0-2411/clojurescript-0.0-2411.jar from central
Compiling "resources/public/js/bin-debug/main.js" from ["src/cljs"]...
WARNING: Wrong number of args (1) passed to UUID at line 561 file:/Users/s/.m2/repository/org/clojure/clojurescript/0.0-2411/clojurescript-0.0-2411.jar!/cljs/reader.cljs
WARNING: Use of undeclared Var clojure.browser.repl/bootstrap at line 86 file:/Users/s/.m2/repository/weasel/weasel/0.7.0-SNAPSHOT/weasel-0.7.0-SNAPSHOT.jar!/weasel/repl.cljs
WARNING: Use of undeclared Var clojure.browser.repl/bootstrap at line 86 resources/public/js/bin-debug/weasel/repl.cljs
WARNING: Wrong number of args (1) passed to UUID at line 561 resources/public/js/bin-debug/cljs/reader.cljs
Successfully compiled "resources/public/js/bin-debug/main.js" in 6.157 seconds.
@sgrove
sgrove / clj-handle-alt-and-case.cljs
Created July 27, 2015 20:26
align-cljlet support for case and alt!
diff --git a/elpa/align-cljlet-0.3/align-cljlet.el b/elpa/align-cljlet-0.3/align-cljlet.el
index 072d19a..e105dc1 100644
--- a/elpa/align-cljlet-0.3/align-cljlet.el
+++ b/elpa/align-cljlet-0.3/align-cljlet.el
@@ -98,6 +98,8 @@
(string-match " *cond" name)
(string-match " *condp" name)
(string-match " *defroutes" name)
+ (string-match " *case" name)
+ (string-match " *alt" name)
I thought I'd jot down a few notes about our experience posting to <a href="http://news.ycombinator.com">hn</a>.
I had just finished "an acceptable code base" for <a href="http://www.chuwe.com">chuwe.com</a> (our Q&A site for the startup/smallbiz community) and decided that Sunday was the day. Actually, we decided Friday, but personnel issues pushed it back until Sunday.
Our goal was simple - it wasn't a "real" launch per se. We wanted to open the site, get mass feedback in one big jolt, then close it and continue with our original invite-only model.
A Short Crisis
In any case, we posted to HN - my first time showing personal code to so many people. It's difficult to tell if there will be any big problems ahead of time. To minimize the possibility, I followed BDD - we had functional-tests, unit-tests, etc. In fact, we had about a 1:1 code-to-test coverage ratio (whether that's meaningful or not, I don't know). Testing made refactoring fly by, it reassured me that things still worked, and just made m
; T).
; etc.
; --> LET IF LET PROG1 LET LET* MULTIPLE-VALUE-BIND LET UNLESS IF TYPEP LET AND
; --> IF AND THE LOCALLY AND THE >= IF
; ==>
; (< SB-C::X SB-C::Y)
;
; note: forced to do GENERIC-< (cost 10)
; unable to do inline fixnum comparison (cost 3) because:
sean-groves-macbook:bin sgrove$ lein install
Exception in thread "main" java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V (core.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:5274)
at clojure.lang.Compiler.eval(Compiler.java:5250)
at clojure.lang.Compiler.load(Compiler.java:5663)
at clojure.lang.RT.loadResourceScript(RT.java:330)
at clojure.lang.RT.loadResourceScript(RT.java:321)
at clojure.lang.RT.load(RT.java:399)
at clojure.lang.RT.load(RT.java:371)
at clojure.core$load__5663$fn__5671.invoke(core.clj:4255)
class Validated:
__fields__ = {} # field -> validator list
def validate(self):
errors = []
for field, validators in self.__fields__.iteritems():
if not hasattr(self, field):
errors.append("field %s missing" % field)
continue
field_errors = []
@sgrove
sgrove / example.clj
Created September 10, 2015 15:33
cljs + webpack interop sketch
;; Example config
:libs [;; Provides is what you would (:require [ReactMotion :as rm
;; and ends up as exports.ReactMotion
{:provides ["ReactMotion"]
:native-name ["react-motion"]
:preprocess :webpack
:webpack-options {. .}}
{:provides ["React"]
:native-name ["react"]
:preprocess :webpack