Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
body {
background: repeat url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/7QCIUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAGscAVoAAxslRxwCAAACAAAcAnQAV8KpIENoYWV5b3VuZ1dpbGxOZXZlckNoYWVvbGQgLSBodHRwOi8vd3d3LnJlZGJ1YmJsZS5jb20vcGVvcGxlL0NoYWV5b3VuZ1dpbGxOZXZlckNoYWVvbAD/4gxYSUNDX1BST0ZJTEUAAQEAAAxITGlubwIQAABtbnRyUkdCIFhZWiAHzgACAAkABgAxAABhY3NwTVNGVAAAAABJRUMgc1JHQgAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLUhQICAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFjcHJ0AAABUAAAADNkZXNjAAABhAAAAGx3dHB0AAAB8AAAABRia3B0AAACBAAAABRyWFlaAAACGAAAABRnWFlaAAACLAAAABRiWFlaAAACQAAAABRkbW5kAAACVAAAAHBkbWRkAAACxAAAAIh2dWVkAAADTAAAAIZ2aWV3AAAD1AAAACRsdW1pAAAD+AAAABRtZWFzAAAEDAAAACR0ZWNoAAAEMAAAAAxyVFJDAAAEPAAACAxnVFJDAAAEPAAACAxiVFJDAAAEPAAACAx0ZXh0AAAAAENvcHlyaWdodCAoYykgMTk5OCBIZXdsZXR0LVBhY2thcmQgQ29tcGFueQAAZGVzYwAAAAAAAAASc1JHQiBJRUM2MTk2Ni0yLjEAAAAAAAAAAAAAABJzUkdCIElFQzYxOTY2LTIuMQAAAAAAAA
#
# FP solve the Change Problem
# eg. myChange = calcChange(cost, myPayment)
#
# Used in fold() to build change object
# Should be nested in calcChange, but is lifted for cleanliness
coinAccStructure = (acc, coinValue) ->
amountRemaining = acc["remaining"]
acc[coinValue] = Math.floor(amountRemaining / coinValue)
@atcruice
atcruice / reduce_return.md
Last active August 29, 2015 14:07
ruby_nuggets.map { | nugget | dʒɪst(nugget) }

All variable names have been changed to protect the innocent. Likeness to any variables presently in or out of scope is purely coincidental.

Got caught by the following snippet this morning:

# given a heterogeneous array,
# I'm only interested in positive integers
# and I really only need one
first_positive_integer = array.reduce([]) do |memo, obj|
@atcruice
atcruice / gist:8a3b0ab197bd5931a48c
Created May 10, 2014 12:08
C++ stream redirection for testing
// save current buffer
streambuf* coutBak = cout.rdbuf();
// setup temp stream
stringstream coutBuf;
// redirect to temp
cout.rdbuf(coutBuf.rdbuf());
// test against contents of coutBuf.str()
@atcruice
atcruice / gtestXcode5Guide.md
Created March 26, 2014 12:24
A guide for using the Google Testing Framework with Xcode 5 on Mac OS X

XcodeGuide (updated)

A guide for using the Google Testing Framework with Xcode 5 on Mac OS X

Assumed knowledge

  • basic command line chops
  • elementary Xcode 5 skills: project creation, target creation, scheme management/editing and building

Quick start

  1. Download the source from the website using this command: