Skip to content

Instantly share code, notes, and snippets.

View aking's full-sized avatar
🕶️
Focusing

Adam King aking

🕶️
Focusing
  • Now: EpicGames iOS Platform Engineer. Prev: 3D Game Programmer (NDS/Wii/iOS/PSP/Android)
  • Ottawa, Canada
View GitHub Profile

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).

Code Splitting

NOTE: This gist uses the master branch of ClojureScript. Clone ClojureScript and from the checkout run ./script/bootstrap and ./script/uberjar. This will produce target/cljs.jar which you can use to follow this guide.

As client applications become larger it becomes desirable to load only the code actually required to run a particular logical screen. Previously ClojureScript :modules compiler option permitted such code splitting, but this feature only worked under :advanced compilation and users would still have to manage loading these splits. :modules also required manual

package computer;
// Referenced classes of package computer:
// KeyMapping
public class AWTKeyMapping extends KeyMapping
{
public AWTKeyMapping()
;;
;; NS CHEATSHEET
;;
;; * :require makes functions available with a namespace prefix.
;;
;; * :use makes functions available without a namespace prefix
;; (i.e., refers functions to the current namespace).
;;
;; * :import refers Java classes to the current namespace.
;;
@aking
aking / debug.clj
Created January 12, 2010 16:42 — forked from khinsen/debug.clj
;; Slightly enhanced version of Alex Osborne's debug-repl (http://gist.github.com/252421)
;; Typing () quits the debug REPL, making it possible to continue without terminating the
;; input stream by typing Ctrl-D.
;; Inspired by George Jahad's version: http://georgejahad.com/clojure/debug-repl.html
(ns debug
[:require clojure.main])
(defmacro local-bindings