Skip to content

Instantly share code, notes, and snippets.

View oakmac's full-sized avatar

Chris Oakman oakmac

View GitHub Profile

Keybase proof

I hereby claim:

  • I am oakmac on github.
  • I am oakmac (https://keybase.io/oakmac) on keybase.
  • I have a public key ASBq3O96XUXHblMPchU-ST63SOPAvBVkY_7X1GubvsVLuwo

To claim this, I am signing this object:

@oakmac
oakmac / index.html
Created February 25, 2017 20:08
dynamically inject script
<script>
(function() {
var useDevScript = (document.location.search.indexOf('devscript=true') !== -1);
var src = useDevScript ? 'js/FULL-VERSION.js' : 'js/MINIFIED-VERSION.js';
var scriptEl = document.createElement('script');
scriptEl.type = 'text/javascript';
scriptEl.src = src;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(scriptEl, s);
})();
@oakmac
oakmac / interop.cljs
Created December 20, 2016 21:38
ClojureScript Interop Example
;; var aphrodite = require('aphrodite');
(def js-aphrodite (js/require "aphrodite"))
;; aphrodite.StyleSheet.extend([foo, bar]);
(defn aphrodite-extend [args]
(apply (aget js-aphrodite "StyleSheet" "extend") args))
use std::collections::HashMap;
static PARENS: HashMap = HashMap::new();
PARENS.insert("{", "}");
PARENS.insert("}", "{");
PARENS.insert("[", "]");
PARENS.insert("]", "[");
PARENS.insert("(", ")");
PARENS.insert(")", "(");
static PARENS: HashMap = HashMap::new();
fn set_parens() {
PARENS.insert("{", "}");
PARENS.insert("}", "{");
PARENS.insert("[", "]");
PARENS.insert("]", "[");
PARENS.insert("(", ")");
PARENS.insert(")", "(");
}
diff --git a/parinferlib.el b/parinferlib.el
index f5ddd7d..fa694fb 100644
--- a/parinferlib.el
+++ b/parinferlib.el
@@ -627,15 +627,14 @@
(defun parinferlib--init-indent (result)
(let ((mode (gethash :mode result))
(in-str? (gethash :isInStr result)))
- (case mode
- ((:indent)
@oakmac
oakmac / jquery-animate.cljs
Created March 17, 2016 19:44
jquery-animate.cljs
;; JS:
;; $('html,body').animate({ scrollTop: element.offset().top }, 'slow');
(def $ js/jQuery)
(let [js-anim-dest (js-obj "scrollTop" (aget (.offset element) "top"))])
(.animate ($ "html,body") js-anim-dest "slow")
(let [a (:a my-map)
b (:b my-map)
c (:c my-map)]
(do-a-thing a b c))
@oakmac
oakmac / example.cljs
Created February 13, 2016 19:30
branching off CLJS code
(when js/webRequest
;; code that references webRequest goes here
)
oakmac@oakmac-desktop:~/parinfer/lib$ node test/perf.js
Processing long_map_with_strings : 303 lines, 4380 chars
indent: 8.528ms
paren: 4.110ms
Processing really_long_file : 2865 lines, 112431 chars
indent: 11.779ms
paren: 17.577ms
Processing really_long_file_with_unclosed_paren : 2865 lines, 112432 chars