- Partial application is fundamental to functional-style programming
- It is the binding of arguments to parameters before a function is invoked
- This technique is often used by ECMAScript developers who are:
- seeking to avoid the use of
new
and/orthis
- deliberately trying to avoid function genericism
- trying to improve consistency of style
- seeking to avoid the use of
- Partial application is currently supported by
Function.prototype.bind
, but the syntax is verbose, and the target of the bound function comes first, diluting the semantic - Writing a custom function to provide partial application is straightforward (indeed there are many open source libraries providing this such as
_.partial
), however developers taking this approach are constrained in their ability to achieve syntactic tenseness lest they surprise other developers - A terse, native syntax for partial application that does not affect the target of a function will improve consistency, clarity of intent and legibility
var need = require('niid').need; | |
var mix = require('mixx').mix; | |
var defaultOptions = Object.freeze({ foo: undefined, | |
bar: undefined, | |
bam: null, | |
baz: null }); | |
function MyThing(options) { | |
need(options, 'foo', 'bar'); // `foo` and `bar` are required. |
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<style> | |
a { | |
line-height: 2rem; | |
} | |
</style> | |
</head> |
'use strict'; | |
var x; | |
function Func() { | |
x = "foo"; | |
var y = "bar"; | |
} | |
Func(); |
return _bookmarks.map(function (a) { | |
return _.any(a, function (i) { | |
return i === id; | |
}); | |
}).reduce(function (prev, curr) { | |
return prev || curr; | |
}); |
///<summary> | |
/// Returns a dictionary of lists keyed by row index. | |
/// Each list in the dictionary corresponds to a row of values. | |
/// "kvp" stands for "key-value pair". | |
///</summary> | |
public class ListHelper | |
{ | |
public static Dictionary<int, List<T>> ToVertical<T>(IEnumerable<T> list, int maxColumns) { | |
if(list == null) { | |
throw new ArgumentNullException("list"); |
var countries = [ "A", "B", "C", "D", "E", "F", "G", "H", "I" ] | |
var grouped = []; | |
var count = countries.length; | |
var columns = 4; | |
var rows = Math.floor(count/columns); | |
countries.map(function(c,i,a){ | |
return { key: i%rows, value: c }; | |
}).forEach(function(kvp) { |
#Branching | |
Show All Branches: `git branch` | |
Switch to branch: `git checkout <branch name>` | |
New branch: `git checkout -b <branch name>` | |
Delete branch: `git checkout -D <branch name>` |
(function( $ ){ | |
$.fn.youtubeGallery = function( options ) { | |
var html = ''; | |
var playListBaseURL = 'http://gdata.youtube.com/feeds/api/playlists/'; | |
var videoBaseURL = 'http://www.youtube.com/watch?v='; | |
var youtubeBaseURL = 'http://www.youtube.com/'; | |
var that = this; | |
There have been several HOWTOs posted regarding streaming the 2012 Olympics using HTTP / SOCKS proxies via SSH and other similar methods. None of these actually work using the latest Flash on Mountain Lion (with Firefox, Chrome or Safari). Additionally, the third-party streaming sites don't provide BBC's amazing interface, which lets you quickly skip to individual competitors and events. However, setting up an OpenVPN server does work, with some tweaks. You'll get the exact same UX that people in England receive.
-
Get a Linode VM in the UK. The 512MB server for $20 works just fine. (If you want to use my referral link, go for it: http://bit.ly/OuzdVe)
-
Follow the standard OpenVPN installation documentation. (Basically, 'apt-get install openvpn' or 'yum install openvpn' and then follow these docs: http://openvpn.net/index.php/open-source/documentation/howto.html). For an OS X client, I prefer Viscosity: http://www.thesparklabs