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 / duck typing rspec.rb
Last active August 29, 2015 14:04 — forked from cupakromer/gist:974c6fb9d0d6de3c2a6e
Test "Duck Typing" using RSpec 3's `instance_double`
class Calculator
def reduce(operator)
fail "You shouldn't be calling this directly!"
end
end
def uses_a_duck_type(calculation)
calculation.reduce(:+)
end
@Integralist
Integralist / mocking-and-faking.md
Last active August 29, 2015 13:57
Examples of mocking and faking data using PHPUnit

The problem with Faking it

The Problem

Developer (A) creates 2 classes, MyClass and Dependency:

class MyClass
{
    private $dependency;
@Integralist
Integralist / GitHub curl.sh
Last active September 7, 2023 03:53 — forked from madrobby/gist:9476733
Download a single file from a private GitHub repo. You'll need an access token as described in this GitHub Help article: https://help.github.com/articles/creating-an-access-token-for-command-line-use
curl --header 'Authorization: token INSERTACCESSTOKENHERE' \
--header 'Accept: application/vnd.github.v3.raw' \
--remote-name \
--location https://api.github.com/repos/owner/repo/contents/path
# Example...
TOKEN="INSERTACCESSTOKENHERE"
OWNER="BBC-News"
REPO="responsive-news"
@Integralist
Integralist / dynamo_db_query_example.md
Last active August 29, 2015 13:56 — forked from kenoir/dynamo_db_query_example.md
Playing around with DynamoDB (old)

AWS query-instance_method docs

export AWS_ACCESS_KEY_ID=‘XXXX’
export AWS_SECRET_ACCESS_KEY=‘XXXX’
# ENV['AWS_ACCESS_KEY_ID']
# ENV['AWS_SECRET_ACCESS_KEY']
@Integralist
Integralist / inherit-by-proxy.js
Last active December 20, 2015 01:09 — forked from jeremyckahn/inherit-by-proxy.js
JavaScript: inheritance by proxy
function inherit (child, parent) {
function proxy () {};
proxy.prototype = parent.prototype;
child.prototype = new proxy();
};
function Parent () {}
function Child () {}
inherit(Child, Parent);
@Integralist
Integralist / find-or-fallback.js
Last active December 19, 2015 21:18 — forked from WebReflection/find-or-fallback.js
JavaScript function that lets you query for the API or provide a fallback if not available
function findOrFallback(where, what, fallback) {
for(var
vendors = ['', 'webkit', 'moz', 'ms', 'o'],
first = what.charAt(0),
others = first.toUpperCase(),
suffix = what.slice(1),
i = 0, length = vendors.length,
current;
i < length; i++
) {
@Integralist
Integralist / reading_time.rb
Last active December 18, 2015 16:39 — forked from zachleat/reading_time.rb
Ruby: calculate reading time based on length of text
# Outputs the reading time
# Read this in “about 4 minutes”
# Put into your _plugins dir in your Jekyll site
# Usage: Read this in about {{ page.content | reading_time }}
module ReadingTimeFilter
def reading_time( input )
words_per_minute = 180
@Integralist
Integralist / addEventListener-polyfill.js
Last active December 17, 2015 04:09 — forked from eirikbacker/addEventListener-polyfill.js
addEventListener polyfill
//addEventListener polyfill 1.0 / Eirik Backer / MIT Licence
(function(win, doc){
if(win.addEventListener)return; //No need to polyfill
function docHijack(p){var old = doc[p];doc[p] = function(v){return addListen(old(v))}}
function addEvent(on, fn, self){
return (self = this).attachEvent('on' + on, function(e){
var e = e || win.event;
e.preventDefault = e.preventDefault || function(){e.returnValue = false}
e.stopPropagation = e.stopPropagation || function(){e.cancelBubble = true}
@Integralist
Integralist / pr.md
Last active December 16, 2015 12:19 — forked from piscisaureus/pr.md
Accessing PR information within your .git folder

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@Integralist
Integralist / cranium.js
Created January 18, 2013 12:03 — forked from addyosmani/cranium.js
Cranium (Backbone API)
/* Cranium MVC
* A minimalist MVC implementation written for
* demonstration purposes at my workshops
* http://addyosmani.com
* Copyright (c) 2012 Addy Osmani; Licensed MIT */
var Cranium = Cranium || {};
// Set DOM selection utility