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 / 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 / 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 / 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 / GitHub curl.sh
Last active February 6, 2025 20:47 — 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 / 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 / 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 / curry.js
Last active August 29, 2015 14:04 — forked from unscriptable/curry.js
Curry implementation in Node
module.exports = curry;
function curry (f) {
var arity = f.length;
var params = [];
var end = createEnd(f, arity);
return createCurried(params, arity, end);
}
function createEnd (f, arity) {
@Integralist
Integralist / ext.vim
Last active February 11, 2019 10:32 — forked from sjl/ext.vim
Some basic examples of executing external commands within Vim's COMMAND-LINE mode
" run command
" no stdin
" output displayed in "Press enter to continue" style
" current buffer untouched
:!uptime
" run command
" pipe range of text to command on stdin
" output replaces the range in the current buffer
:RANGE!grep foo
@Integralist
Integralist / zsh.md
Last active August 29, 2015 14:11 — forked from jcleveley-zz/zsh.md
Zsh tips

Path replacement

Moving from: /www/site1/media/css/main to /www/site2/media/css/main can be a pain, but not in zsh:

cd site1 site2

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors