This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const extendObj = | |
R.curry((key, valueCreator, obj) => Object.assign({}, obj, { [key]: valueCreator(obj) })); | |
// e.g. | |
fetch(url).then(results => results.json()) | |
.then( | |
R.map(extendObj('deployment_id', () => deploymentId))) | |
.then( | |
R.map(extendObj('friendly_created_at', r => moment(r.created_at).format('YYYY-MM-DD HH:mm')))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Update, upgrade, and clean | |
sudo apt-get -y update && sudo apt-get -y dist-upgrade && sudo apt-get -y autoclean && sudo apt-get -y autoremove | |
# Update rpi firmware | |
sudo apt-get -y install rpi-update && sudo rpi-update | |
sudo reboot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Codemod to convert AMD modules to ES2015 syntax | |
*/ | |
module.exports = function(file, api) { | |
const j = api.jscodeshift; | |
const toSourceOpts = { quote: 'single' }; | |
/** | |
* UNUSED | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function () { | |
return withNoopToggle; | |
function withNoopToggle() { | |
/** | |
* If toggle is false, do not execute named methods. | |
*/ | |
this.noopToggle = function (methods, toggle) { | |
methods.forEach(function (method) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Compose() { | |
this.initialState({ | |
characterCount: 0 | |
}); | |
this.after('initialize', function () { | |
this.provideObservableResource('dockedCompose.state', this.state); | |
this.attachChild(CharacterCount, this.$node); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Verifying that +andyhume is my openname (Bitcoin username). https://onename.io/andyhume |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// All these methods return promises, so I can chain thens like below. | |
function test() { | |
page.loadAndWaitForSignInUi() | |
.then(function() { | |
return page.setViewportSize(1300, 500); | |
}) | |
.then(function() { | |
return page.patchStreamScribe(); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import timeit | |
import math | |
import sys | |
import socket | |
repeat = 10 | |
url = 'http://m.guardian.co.uk' | |
ua = 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3' | |
if len(sys.argv) > 1 and sys.argv[1] > 0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Standard implementation, just before closing body tag --> | |
_ophan.loaded = function() { | |
Ophan.logPageView(); | |
} | |
<script src="http://s.ophan.co.uk/js/ophan.min.js" async defer></script> | |
</body> | |
<!-- Or something more custom using require --> | |
require(["http://s.ophan.co.uk/js/ophan.min.js", adverts, id], function(ophan, adverts, id) { | |
ophan.additionalData({"isLoggedIn": id.isLoggedIn()}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function WorkerPool(url) { | |
this.url = url; | |
this.pool = []; | |
} | |
WorkerPool.prototype.getWorker = function() { | |
var w; | |
if (this.pool.length > 0) { | |
w = this.pool.pop(); | |
} else { | |
w = new Worker(this.url); |