Skip to content

Instantly share code, notes, and snippets.

View domgetter's full-sized avatar

Dominic Muller domgetter

View GitHub Profile
#
# Please don't use this in any Ruby library or code.
# This is for proof-of-concept purposes only and will break Ruby functionality
#
class Proc
alias :greedy_curry :curry
def curry
if self.has_kwarg_parameters?
class Identity
def initialize(obj)
@obj = obj
end
def self.wrap(obj)
Identity.new(obj)
end
obj = "hello"; puts obj.methods.map {|m| obj.method(m)}
#<Method: String#<=>>
#<Method: String#==>
#<Method: String#===>
#<Method: String#eql?>
#<Method: String#hash>
#<Method: String#casecmp>
#<Method: String#+>
#<Method: String#*>
@domgetter
domgetter / git_ls.rb
Created November 7, 2015 09:18
Prints out the directory listing for the most recent commit in a repository.
puts `git ls-tree HEAD -r -t -l`.split("\n").map {|l| tabs = l.scan('/').length; " "*tabs + l.split.last.split('/').last}
Areas of programming to get good at
Computer Science
Algorithms
Data Structures
Time/Space complexities
Coding
Collections
Arrays
Key-Value stores
@domgetter
domgetter / recur_all_the_things.clj
Created October 23, 2015 20:15
Recur recursive version of iterative functions
;function fib(n) {
; var next, acc = 1, 0;
; while(n > 0) {
; next, acc = next + acc, next;
; n--;
; }
; return acc;
;}
(defn fib [n next acc]
@domgetter
domgetter / ruby_DFT.rb
Last active October 20, 2015 21:58
The Discrete Fourier Transform in Ruby
# This is O(n^2), it is NOT the FFT
require 'complex'
# This is our data
arr = [1,-1]*50
# This is the number of harmonics we wish to calculate
n_max = 20
# This is what will hold the result
(ns ^:figwheel-no-load reagenttest.dev
(:require [reagenttest.core :as core]
[figwheel.client :as figwheel :include-macros true]))
(enable-console-print!)
(figwheel/watch-and-reload
:websocket-url "ws://localhost:3449/figwheel-ws"
:jsload-callback core/mount-root)
(defproject reagenttest "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.7.0"]
[ring-server "0.4.0"]
[reagent "0.5.1"]
[reagent-forms "0.5.9"]
(ns reagenttest.core
(:require [reagent.core :as reagent :refer [atom]]
[reagent.session :as session]
[secretary.core :as secretary :include-macros true]
[goog.events :as events]
[goog.history.EventType :as EventType])
(:import goog.History))
;; -------------------------
;; Views