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
| # Using these pry gems -- copy to your Gemfile | |
| # group :development, :test do | |
| # gem 'pry', '>= 0.14.1' # Console with powerful introspection capabilities | |
| # # Need to use master of pry-byebug to use latest pry version | |
| # gem 'pry-byebug', github: 'deivid-rodriguez/pry-byebug' # Integrates pry with byebug | |
| # gem 'pry-doc' # Provide MRI Core documentation | |
| # gem 'pry-rails' # Causes rails console to open pry. `DISABLE_PRY_RAILS=1 rails c` can still open with IRB | |
| # gem 'pry-rescue' # Start a pry session whenever something goes wrong. | |
| # gem 'pry-theme' # An easy way to customize Pry colors via theme files | |
| # |
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
| ;; - unmix1 is my go-to solution | |
| ;; - unmix2 is 21% faster than unmix1 | |
| ;; - unmix3 is 212% faster than unmix1 | |
| ;; - unmix3 is a classic car-cdr lispy solution | |
| ;; | |
| ;; Benchmarked with criterium | |
| (defn unmix1 [s] | |
| (reduce (fn [memo [a b]] (str memo b a)) | |
| "" |
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
| For each Ruby module/class, we have Ruby methods on the left and the equivalent | |
| Clojure functions and/or relevant notes are on the right. | |
| For clojure functions, symbols indicate existing method definitions, in the | |
| clojure namespace if none is explicitly given. clojure.contrib.*/* functions can | |
| be obtained from http://github.com/kevinoneill/clojure-contrib/tree/master, | |
| ruby-to-clojure.*/* functions can be obtained from the source files in this | |
| gist. | |
| If no method symbol is given, we use the following notation: |
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
| #!/usr/local/bin/sbcl --script | |
| (load (merge-pathnames ".sbclrc" (user-homedir-pathname))) | |
| (ql:quickload "cl-json" :silent t) | |
| (require "inferior-shell") | |
| (defparameter *ssh-user* "ec2-user") | |
| (defparameter *ssh-key-path* "~/.ssh/us-east-1-platform-key.pem") |
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
| defmodule BinarySearch do | |
| def find(item, _left, [i | _right]) when i == item, do: true | |
| def find(item, _left, [i | right]) when i < item, do: find(item, right) | |
| def find(item, left, [i | _right]) when i > item, do: find(item, left) | |
| def find(_item, _left, []), do: false | |
| def find(item, list) do | |
| {left, right} = split(list) | |
| find(item, left, right) | |
| end |
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
| ;; Align command !!! | |
| ;; from http://stackoverflow.com/questions/3633120/emacs-hotkey-to-align-equal-signs | |
| ;; another information: https://gist.github.com/700416 | |
| ;; use rx function http://www.emacswiki.org/emacs/rx | |
| (defun align-to-colon (begin end) | |
| "Align region to colon (:) signs" | |
| (interactive "r") |
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
| class HStruct | |
| def self.new(*members, defaults: {}, &block) | |
| invalid_defaults = defaults.keys - members | |
| fail "Invalid defaults #{invalid_defaults}" if invalid_defaults.any? | |
| klass = Class.new do | |
| @members = members | |
| @defaults = defaults | |
| class << self |
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
| module Coercible | |
| module Types | |
| BOOL_MAP = { 'true' => true, 'false' => false, true => true, false => false } | |
| BOOL = proc { |v| BOOL_MAP[v] } | |
| INTEGER = proc { |v| v.to_i } | |
| ARRAY = proc { |v, rule| Array(v).map(&ARRAY_MAP[rule[:of]]) } | |
| ARRAY_MAP = { Integer => :to_i, String => :to_s, nil => proc { |v| v } } | |
| module_function |
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
| const test = require('tape'); | |
| function resolver(deps) { | |
| function directDeps(className) { | |
| return deps[className] || []; | |
| } | |
| function transitiveDeps(className) { | |
| return directDeps(className).reduce((set, className) => { | |
| [className, ...transitiveDeps(className)].forEach((v) => set.add(v)); |
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
| const test = require('tape'); | |
| function resolver(deps) { | |
| function directDeps(className) { | |
| return deps[className] || []; | |
| } | |
| function transitiveDeps(className) { | |
| return directDeps(className).reduce((set, className) => { | |
| [className, ...transitiveDeps(className)].forEach((v) => set.add(v)); |