This file contains 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
(when (not (boundp 'inf-ruby-implementations)) | |
(setq inf-ruby-implementations nil)) | |
(defun ~/paths-to-root (file-name) | |
(let* ((path-parts (s-split "/" (file-name-directory file-name) t)) | |
(build-path (lambda (path-parts) | |
(concat "/" (s-join "/" path-parts)))) | |
(paths (reduce (lambda (state _) | |
(let* ((old-path-parts (cdr state)) | |
(new-path-parts (-butlast old-path-parts)) |
This file contains 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
# @return [Array<String>] | |
def gem_paths | |
Gem.path.flat_map { |path| Dir.glob("#{path}/gems/*") } | |
end | |
# @param [String] gem_name | |
# @return [Boolean] | |
# @raise [LoadError] | |
def require_gem(gem_name) | |
if defined?(::Bundler) |
This file contains 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
module Walk | |
refine Array do | |
def walk(inner_f, outer_f) | |
outer_f.(self.map(&inner_f)) | |
end | |
end | |
refine Hash do | |
def walk(inner_f, outer_f) |
This file contains 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 saturn) | |
;; --------------------------------------------------------------------- | |
;; Signature parsing | |
(defprotocol IParse | |
(-parse [x])) | |
(extend-protocol IParse |
This file contains 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
module Json.Decode.Generic where | |
import Json.Decode as Decode exposing (Decoder, (:=)) | |
import Array exposing (Array) | |
import Dict exposing (Dict) | |
type JsonValue = JsonNull | |
| JsonBool Bool | |
| JsonString String | |
| JsonFloat Float |
This file contains 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
module Main where | |
import qualified System.Directory as Directory | |
import qualified System.FilePath as FilePath | |
import Control.Monad (forM, forM_, liftM) | |
import qualified Data.HashMap.Strict as HashMap | |
import Text.Printf (printf) | |
isFile :: FilePath -> IO Bool | |
isFile = Directory.doesFileExist |
This file contains 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
(letfn [(variadic? [arglist] | |
(boolean (some #{'&} arglist))) | |
(arglistc [arglist] | |
(if (variadic? arglist) | |
Double/POSITIVE_INFINITY | |
(count arglist))) | |
(partial-arglists [arglists argc] | |
(drop-while |
This file contains 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 sablono.impl.atom | |
(:require | |
[sablono.interpreter])) | |
(extend-protocol sablono.interpreter/IInterpreter | |
Atom | |
(interpret [this] | |
(let [;; Watch key for the component observing `this` atom. | |
watch-key (gensym)] | |
(js/React.createElement |
This file contains 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
(deftype Chain [f args] | |
clojure.lang.IDeref | |
(deref [this] | |
(apply f (for [arg args] | |
(if (instance? Chain arg) | |
@arg | |
arg)))) | |
clojure.lang.IFn | |
(invoke [this] this) |
This file contains 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 has-method? | |
"True if multi-fn has a method for a dispatch-val." | |
[multi-fn dispatch-val] | |
(if-let [method (get-method multi-fn dispatch-val)] | |
(if-let [default-method (.-default-dispatch-val multi-fn)] | |
(not= method default-method) | |
true) | |
false)) |