Skip to content

Instantly share code, notes, and snippets.

View Integralist's full-sized avatar
🎯
Making an impact

Mark McDonnell Integralist

🎯
Making an impact
View GitHub Profile
@Integralist
Integralist / Process for rebasing Pull Request.md
Last active August 29, 2015 14:05
Process for rebasing Pull Request
  1. On the PR branch
  2. git rebase -i master (i.e. git rebase -i {parent_commit_of_first_commit_in_PR})
  3. Change top commit (the oldest) to reword
  4. Change all other commits to fixup
  5. In commit message (line 1) change title to reflect entire PR
  6. In commit message (line 2) add Closes #n and/or Fixes #n
  7. In commit message (line 3) add Authors: @integralist
  8. git checkout master
  9. git merge {PR_branch} or git cherry-pick {new_rebased_commit}
  10. git branch -D {PR_branch}
@Integralist
Integralist / 1. Breakdown of Monads.js
Last active March 6, 2016 18:02
Monads in JavaScript and the power of composability
// The Monad design pattern functions
// i.e. compose, bind, unit, lift
// These are functions that are part of the design pattern's "interface"
// Their implementation can change (well, maybe not `compose`)
// but these function identifiers should be implemented
// as other devs will use those identifiers as a common language
// when discussing the Monad pattern
// compose = returns a function that takes a data structure (accepted data structure argument is passed to `g` and then result of that is passed to `f`)
@Integralist
Integralist / git apply gist diff.sh
Last active April 16, 2019 02:20
Get a git diff and apply git diff using gist ruby gem -> https://github.com/defunkt/gist (also see this alternative using `git format-patch`: https://gist.github.com/Integralist/87852ced09d7918322c0)
git show HEAD HEAD~1 # (or use a hash instead: `git show {commit} {commit} {commit}`)
git diff --cached | gist -p -f test.diff
curl https://gist.githubusercontent.com/anonymous/x/raw/x/test.diff | git apply
curl https://gist.githubusercontent.com/anonymous/x/raw/x/test.diff | git apply --reverse
@Integralist
Integralist / data structures.md
Last active January 30, 2019 15:41
Data Structures
@Integralist
Integralist / 1. API.rb
Last active August 29, 2015 14:03
Ruby OOP vs FP (examples are from ThoughtBot's Weekly Iteration -> you should subscribe!)
# Examples taken from ThoughtBot's Weekly Iteration
# We need to implement a solution that allows us to cleanly use two separate APIs
# Our fake APIs
PayPal.charge!(auth_code, 25)
Stripe::CreditCard.new(credit_card_token).charge(25)
@Integralist
Integralist / Auto Currying JavaScript Function.js
Created June 27, 2014 22:24
Auto Currying JavaScript Function
// Copied from http://javascriptweblog.wordpress.com/2010/06/14/dipping-into-wu-js-autocurry/
var autoCurry = (function () {
var toArray = function toArray(arr, from) {
return Array.prototype.slice.call(arr, from || 0);
},
curry = function curry(fn /* variadic number of args */) {
var args = toArray(arguments, 1);
return function curried() {
@Integralist
Integralist / 1. Tree
Last active August 29, 2015 14:02
Best way to modular Grunt tasks
|— Gruntfile
|— package.json
|— grunt
| – contrib-requirejs.js
@Integralist
Integralist / 0. JavaScript Function Programming TOC.md
Last active July 3, 2018 04:57
JavaScript Function Programming (scratch pad) -> Most of the code here is modified from the excellent O'Reilly book "Functional JavaScript".

This code is modified from the excellent O'Reilly book "Functional JavaScript". You should buy it, I highly recommend it! Don't kid yourself into thinking this gist even remotely covers the great content from a 200+ page technical book on the subject; it doesn't. Buy the book and get the in-depth knowledge for yourself. It's worth it.

  • Dynamic Dispatch
  • Dynamic Method
  • Ghost Methods
  • Dynamic Proxies
  • Blank Slate
  • Kernel Method
  • Flattening the Scope (aka Nested Lexical Scopes)
  • Context Probe
  • Class Eval (not really a 'spell' more just a demonstration of its usage)
  • Class Macros
@Integralist
Integralist / Ruby Array Guarding.md
Created May 9, 2014 07:32
Ruby Array Guarding

Below is an example of trying to protect against a request for data failing to return the expected data structure (in this case an Array)...

expect_an_array_back = SomeClass.make_a_request_for_data

if expect_an_array_back.any?
  expect_an_array_back.each do |user|
    # ...
  end
end