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/bin/env bash | |
| # Use cases | |
| # | |
| # Anonymous function expressions assigned by `=` operator to a variable: | |
| # (with and without arguments) | |
| # | |
| # const aFunc = function () {}; | |
| # | |
| # Anonymous function expressions declared as a property of an object: |
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
| def attrs | |
| @attrs ||= Reading.new.attributes.keys.take(5).last(4) | |
| end | |
| def data | |
| @data ||= File.read("tmp/output_small_test.csv") | |
| end | |
| def rows | |
| data.split() |
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 User < ActiveRecord::Base | |
| DO_NOT_MODIFY = ["encrypted_password", "state"] | |
| def do_not_modify | |
| DO_NOT_MODIFY | |
| end | |
| def strip_string_attributes | |
| string_attributes.each do |k,v| | |
| # this is a side-effect and mutates instance state |
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
| git log --oneline --after="2016-03-28" --before="2016-04-03" --pretty=format:"%ad, %s" --date=short |
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
| koans: | |
| image: clojure | |
| command: lein koan run | |
| volumes: | |
| - ./clojure-koans:/clojure-koans | |
| working_dir: /clojure-koans | |
| repl: | |
| image: clojure | |
| command: lein repl |
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
| num = 1000000000000000000000000000000000000000000 | |
| (0..100).each_with_index {|n, i| puts n if num == 10 ** n } |
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 anagram | |
| (:require [clojure.string :refer [lower-case split]])) | |
| (defn- duplicate? [a b] | |
| (= (lower-case a) (lower-case b))) | |
| (defn- unique-candidates [source candidates] | |
| (remove #(duplicate? % source) candidates)) | |
| (defn- canonicalize [word] |
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
| require 'sinatra' | |
| get '/' do | |
| @name = # GET GIST HERE!!! | |
| erb :home | |
| 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
| class Player | |
| attr_accessor :warrior, :direction, :health, :hurt, :step | |
| def initialize | |
| self.direction = :backward | |
| self.hurt = false | |
| self.step = true | |
| end | |
| def play_turn(warrior) |
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 game | |
| (:use clojure.test)) | |
| (defn vitality [cell-state live-neighbors] | |
| (or (= live-neighbors 3) (and cell-state (= live-neighbors 2)))) | |
| (defn count-live-neighbors [grid position] | |
| (let [row (first position) | |
| column (last position)] | |
| (def neighbors |
NewerOlder