Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike Fikes mfikes

View GitHub Profile
View goog-dep-index.md

For Planck, I needed to build an index on the Google Closure sources. So I did so, by hacking together some regexs on deps.js.

Only recently did I learn that my "hack" was essentially already in ClojureScript. Spookily even down to the aspects of prefixing with "goog/" and memoizing the hack fn:

Planck's memoized hack: here

ClojureScript's equivalent: here

@mfikes
mfikes / chambered.js
Last active Aug 29, 2015
chambered keyword support
View chambered.js
;(function(){
"undefined" !== typeof Math.imul && (Math.imul.c ? Math.imul.c(4294967295, 5) : Math.imul.call(null, 4294967295, 5));
var e = function() {
function a(a) {
return a * b.b();
}
function c() {
return Math.random.b ? Math.random.b() : Math.random.call(null);
}
var b = null, b = function(b) {
View users_master_view_controller.clj
(ns classroom-checkout.users-master-view-controller
(:require [fikesfarm.ios.interop :refer [TableViewDataSource TableViewDelegate FetchedResultsControllerDelegate fetched-results-change-type' table-view-row-animations]]
[classroom-checkout.user-detail-view-controller :refer [user]]
[classroom-checkout.database :refer [database-manager create-user!]])
(:require-macros [fikesfarm.ios.util :refer [reify]]))
(def view-controller (atom nil))
(def table-view (atom nil))
(def edit-bar-button-item (atom nil))
(def add-bar-button-item (atom nil))
View BooksViewControllerObjC
#import "FCCBooksMasterViewController.h"
#import "FCJTableView.h"
#import "FCJBarButtonItem.h"
@implementation FCCBooksMasterViewController
- (void)handleViewDidLoad {
[[self getFunction:@"view-did-load!"]
callWithArguments:@[self,
View BooksMasterViewControllerCljs
(ns classroom-checkout.books-master-view-controller
(:require [fikesfarm.ios.interop :refer [TableViewDataSource TableViewDelegate FetchedResultsControllerDelegate
fetched-results-change-type' table-view-row-animations
user-interface-idiom-ipad? table-view-cell-editing-styles]]
[classroom-checkout.book-detail-view-controller]
[classroom-checkout.database :refer [database-manager create-book! delete-book!]]
[classroom-checkout.utils :refer [full-title]])
(:require-macros [fikesfarm.ios.util :refer [reify export-view-did-load]]))
(def view-controller (atom nil))
View delete_recursively.clj
(defn delete-recursively [fname]
(letfn [(func [f]
(when (.isDirectory f)
(doseq [f2 (.listFiles f)]
(func f2)))
(clojure.java.io/delete-file f))]
(func (clojure.java.io/file fname))))
(defn delete-recursively' [fname]
(let [func (fn func [f]
@mfikes
mfikes / recursive_let_fn.clj
Created Dec 12, 2014
Recursive fn defined in let block
View recursive_let_fn.clj
(defmacro memoize-rec [form]
(let [[fn* fname params & body] form
params-with-fname (vec (cons fname params))]
`(let [f# (memoize (fn ~params-with-fname
(let [~fname (partial ~fname ~fname)] ~@body)))]
(partial f# f#))))
(let [fib (fn fib [n]
(if (< n 2)
n
@mfikes
mfikes / gist:ab60ff79b8a88de1e9b7
Last active Aug 29, 2015
JavaScriptCore for ClojureScript test-misc
View gist:ab60ff79b8a88de1e9b7
I when running (deftest test-misc...) in embedded JavaScriptCore instance
in iOS simulator, JavaScriptCore crashes with the trace below. I'm working
to isolate this to file a report with Apple and to better understand what
generated JavaScript may be causing it (perhaps we can work around).
(lldb) bt
* thread #1: tid = 0x3f7e, 0x0111e583 JavaScriptCore`WTFCrash + 67, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xbbadbeef)
frame #0: 0x0111e583 JavaScriptCore`WTFCrash + 67
frame #1: 0x011395a9 JavaScriptCore`WTF::fastMalloc(unsigned long) + 1929
frame #2: 0x00c9cb56 JavaScriptCore`WTF::Vector<JSC::UnlinkedInstruction, 0ul, WTF::UnsafeVectorOverflow>::expandCapacity(unsigned long) + 86
@mfikes
mfikes / test2.clj
Created Dec 16, 2014
Failing iOS test
View test2.clj
(ns classroom-checkout.test2
(:refer-clojure :exclude [iter])
(:require [cljs.test :refer-macros [deftest testing is]]
[clojure.string :as s]
[clojure.set :as set]))
;; this fails in v8 - why?
;; (assert (= "symbol\"'string" (pr-str (str 'symbol \" \' "string"))))
(deftest test-misc
@mfikes
mfikes / both.clj
Created Jan 6, 2015
Try to support both interfaces
View both.clj
(defrecord WebsocketEnv []
cljs.repl/IJavaScriptEnv
(-setup [this _] (websocket-setup-env this))
(-evaluate [_ _ _ js] (websocket-eval js))
(-load [this ns url] (load-javascript this ns url))
(-tear-down [_] (websocket-tear-down-env)))
(if false
(reify cljs.repl/IJavaScriptEnv