This file contains hidden or 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
tell application "Google Chrome" | |
activate | |
tell application "System Events" | |
tell process "Google Chrome" | |
keystroke "r" using {command down, shift down} | |
end tell | |
end tell | |
end tell | |
-- Save that in a text file somewhere and run it from terminal with: |
This file contains hidden or 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 oauth.digest | |
(:import (javax.crypto Mac) | |
(javax.crypto.spec SecretKeySpec))) | |
(defn hmac | |
"Calculate HMAC signature for given data." | |
[^String key ^String data] | |
(let [hmac-sha1 "HmacSHA1" | |
signing-key (SecretKeySpec. (.getBytes key) hmac-sha1) | |
mac (doto (Mac/getInstance hmac-sha1) (.init signing-key))] |
This file contains hidden or 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 rxjs.client.core | |
(:use [jayq.core :only [$ on off document-ready]] | |
[jayq.util :only [log]])) | |
(defn on-as-observable [$elem events & [sel data]] | |
(js/Rx.Observable.create | |
(fn [observer] | |
(let [handler (fn [evt-object] | |
(.onNext observer evt-object))] | |
(on $elem events sel data handler) |
This file contains hidden or 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 debounce [func wait immediate] | |
(let [timeout (atom nil)] | |
(fn [] | |
(this-as this | |
(let [context this | |
args js/arguments | |
later (fn [] | |
(reset! timeout nil) | |
(when-not immediate | |
(.apply func context args)))] |
This file contains hidden or 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
;; vanilla version | |
(defn make-lock [] | |
(atom nil)) | |
(defn has-lock? [lock id] | |
(= id @lock)) | |
(defn set-lock! [lock id new-id] | |
(let [lock-id @lock] |
This file contains hidden or 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
(defrecord web-socket | |
Object | |
(send [msg] ...) | |
(close [_] ...)) |
This file contains hidden or 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 fj | |
(:import [java.util.concurrent RecursiveTask | |
ForkJoinPool])) | |
(set! *warn-on-reflection* true) | |
;; ----------------------------------------------- | |
;; Helpers to provide an idiomatic interface to FJ | |
(defprotocol IFJTask |
This file contains hidden or 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 locals | |
"Returns a map of locals, as keywords, to their values." | |
[] | |
(let [locals (keys &env)] | |
`(zipmap ~@(map vec [(map keyword locals) locals])))) | |
(let [x 10] | |
(let [y 20 | |
z (+ x y)] | |
(locals))) |
This file contains hidden or 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
/* | |
Silly example - close over s (say a string) returning an instance | |
of an anonymous type that acts like a ClojureScript collection | |
(defn make-conjable [s] | |
(reify | |
ICollection | |
(-conj [_ c] (str s c)))) | |
*/ |
This file contains hidden or 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) Rich Hickey. 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) | |
;; which can be found in the file epl-v10.html at the root of this distribution. | |
;; 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. | |
(ns repl.test | |
(:require [clojure.browser.repl :as repl] |