Skip to content

Instantly share code, notes, and snippets.

View deanrad's full-sized avatar
🎯
Staying On Target

Dean Radcliffe deanrad

🎯
Staying On Target
View GitHub Profile
@deanrad
deanrad / deanhtml5-intro.md
Last active August 29, 2015 13:55
yo Deanhtml5

Get started with the deanhtml5 generator

  • Install node v 10 or greater (Tried NVM ?? )
  • Install NPM, run npm install -g yeoman
  • Run npm install -g generator-deanhtml5
  • Make a directory and in it run yo deanhtml5
  • Give the app a title, and answer any other prompts
  • Begin to fiddle with the app and tests

You now have an HTML5 app, which needs no back end process to run it but:

@deanrad
deanrad / update_system.sh
Last active August 29, 2015 13:57
Keep Systems Up to date
xcode-select --install
@deanrad
deanrad / morning_routine.sh
Last active August 29, 2015 13:57
A cup of morning Comment Sense
# let your comment-sense dir be PWD
set -e # abort on error
echo "Good morning. Updating projects..."
git checkout master
git pull
bundle install
rake db:migrate
RAILS_ENV=test rake db:migrate
echo "Yay all is good"
@deanrad
deanrad / bracket_balancer.rb
Last active August 29, 2015 13:58
4clojure #177 - Bracket Balancer
#!/usr/bin/ruby
# Solution by Dean Radcliffe to 4clojure problem #177
# Disclaimer: not production-ready
# Strategy: Build a tree from parens. Return tree as truthy value, else nil
# TODO clojurify this
require 'ostruct' #convenient hash-like data structure
require 'pp' #pretty printer (optional)
def closer? char
@deanrad
deanrad / update gems.md
Last active August 29, 2015 13:58
Updating Gems checklist
  • Git pull and all tests pass
  • Run bundle outdated > gem_outdated

For a given gem to update:

  • Do a dependency report gem dependency -R GEMNAME

  • Delete the version specifier in Gemfile

  • Run bundle install

  • Commit Gemfile and Gemfile.lock

  • Optionally do gem cleanup on your system

@deanrad
deanrad / k-sets.rb
Created April 14, 2014 19:32
k-sets
def ksets s=[1,2,3], k=s.size
s.inject([[]]) do |acc, v|
acc + acc.map{|exist| [v] + exist}
end.select{|s| s.length == k}
end
@deanrad
deanrad / kcomb.clj
Created April 18, 2014 16:52
K-sets clojure explorations
;; Anything you type in here will be executed
;; immediately with the results shown on the
;; right.
(defn kcomb [k vect]
(cond
(= k 0) '(())
(empty? vect) '()
:else (concat (map
#(cons (first vect) %)
@deanrad
deanrad / requirejs.coffee
Created April 27, 2014 15:21
Alternate requirejs syntax
# TL;DR: Instead of a verb-oriented 'define' function with anonymous arguments, a
# 'descriptive' function with named arguments
#
module deps:[‘a’, ‘b’], factory:(a, b)->
# compare with
define ['a', 'b'], (a, b) ->
# module 'BlahBlah', deps:[‘a’, ‘b’], factory:(a, b)->
@deanrad
deanrad / min-triangle-path.clj
Last active August 29, 2015 14:00
4clojure problem 79
; thanks to @eigenhombre i was reminded that we can only take "plinko" paths
; also props for introducing me to letfn
;
; this is what led to the insight that a vector becomes 2 possible vectors
; much like the branching universe theory, and we must mapcat those as we go !
; Key insight
; You branch in predictable way like the game of PLINKO on The Price is Right :)
; Eg at each step, the branches multiply thusly:
; ([0 0]) becomes ([0 0 0] [0 0 1])
diff --git a/test/spec/test_reactive.coffee b/test/spec/test_reactive.coffee
index c8cd535..fac783e 100644
--- a/test/spec/test_reactive.coffee
+++ b/test/spec/test_reactive.coffee
@@ -561,9 +561,11 @@ describe 'RawHtml', ->
).toThrow()
describe 'rxt', ->
- it 'should take as contents (arrays of) strings, elements, RawHtml, or $', ->
+ it 'should take as contents (arrays of) numbers, strings, elements, RawHtml, $ or null', ->