Skip to content

Instantly share code, notes, and snippets.

Matt Jordan mbjordan

Block or report user

Report or block mbjordan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mbjordan
mbjordan / note.md
Last active Dec 9, 2015
Very simple JavaScript partial and partialRight functions
View note.md

Using Array.slice can be bad news!

Instead, a simple function to convert the arguments object to an Array can be used:

function argumentsToArray(args, pointer) {
    var arr = new Array(args.length);
    for (var idx = 0; idx < arr.length; idx++) {
        if (!!pointer && (pointer - 1) === idx) continue;
        arr[idx] = args[idx];
View ajaxGetter.ex1.js
ajaxGetter('/api/users', {
'userId': 1234
})
.then( /* do something */ )
.catch( /* Handle Errors */ )
View partial.js
function partial(fn) { // `fn` is the original function
// `args_a` are the arguments (barring `fn`) of the first call.
var args_a = Array.prototype.slice.call(arguments, 1);
// Now, we return a new function, with the first set of arguments already applied.
return function partialApplicator() {
// `args_b` are the arguments applied at the second call
var args_b = Array.prototype.slice.call(arguments);
// Now, concatenate both Arrays and apply them to the original function
@mbjordan
mbjordan / IntendedDirectoryStructure
Created Sep 24, 2015
Branching for Github Pages
View IntendedDirectoryStructure
Repo-Name
|-- master
|-- gh-pages
View AlienBlood2.itermcolors
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.085725627839565277</real>
<key>Green Component</key>
<real>0.14950284361839294</real>
View docs-standard.md

methodName

[A brief description of the method/module, etc.]

Use: methodName(arg1[, arg2]);

Arguments:

  • arg1 - [isRequired?] - A description of the argument
  • arg2 - [isRequired?] - A description of the argument
View ratelimit.nginxconf
upstream myapp {
server 127.0.0.1:8081;
}
limit_req_zone $binary_remote_addr zone=login:10m rate=1r/s;
server {
listen 443 ssl spdy;
server_name _;
@mbjordan
mbjordan / queryString2Obj.js
Created Jun 18, 2015
JavaScript - Convert a query string to an object literal.
View queryString2Obj.js
function queryString2Obj(str) {
var ampArr = str.replace(/(^\?)/, '').split('&');
function decode(estr) {
return decodeURIComponent(estr).replace(/\+/g, ' ');
}
function mapHandler(cv) {
cv = cv.split('=');
this[cv[0]] = decode(cv[1]);
@mbjordan
mbjordan / broncos.itermcolors
Created May 14, 2015
Denver Broncos iTerm2 Color scheme
View broncos.itermcolors
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.19177328050136566</real>
<key>Green Component</key>
<real>0.15017002820968628</real>
View 1-restify-server-cheatsheet.js
// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
You can’t perform that action at this time.