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
/*! | |
* backbone.collectioncache.js v0.0.2 | |
* Copyright 2012, Tim Branyen (@tbranyen) | |
* backbone.collectioncache.js may be freely distributed under the MIT license. | |
*/ | |
(function(window) { | |
"use strict"; | |
// Dependencies |
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
// Application. | |
var app = require("app"); | |
// Page specific Views. | |
var Views = require("modules/page/views"); | |
module.exports = Backbone.Model.extend({ | |
defaults: { | |
title: "Unknown Page" | |
}, |
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 makePromise() { | |
return new Promise(() => {}); | |
} | |
async function main() { | |
console.log('start'); | |
await makePromise(); | |
console.log('end'); | |
} |
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
touchpad_id=$(xinput --list | grep "TouchPad" | xargs -n 1 | grep "id=" | sed 's/id=//g') | |
accel_speed_code=$(xinput --list-props $touchpad_id | awk '/Accel Speed \(/ {print $4}' | grep -o '[0-9]\+') | |
# Default acceleration is too slow (non-existent) | |
xinput --set-prop $touchpad_id $accel_speed_code .75 |
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
Promise.makeCancellable = promise => { | |
const deferred = {}; | |
const promise = new Promise((resolve, reject) => { | |
deferred.reject = reject; | |
// Invoke the fetch argument with the matching args... only resolve if not | |
// aborted. | |
promise | |
.then(resp => !deferred.aborted && resolve(resp)) | |
.catch(ex => !deferred.aborted && reject(ex)); |
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 { useState, Component } from 'react'; | |
class MyComponent extends Component { | |
render() { | |
const [ count, setCount ] = this.state; | |
return ( | |
<div>{count}</div> | |
); | |
} |
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
it('will treekshake a static named import', async () => { | |
const input = register('./a')` | |
const { a } = require('./b'); | |
console.log(a); | |
`; | |
register('./b')` | |
function b() {} | |
exports.a = 'hello world'; |
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 something = require('something'); | |
const { somethingElse } = require('something-else'); | |
const { exports } = module; | |
exports.somethingElse = somethingElse; | |
module.exports = something; | |
Object.assign(module.exports, exports); |
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 { webapp, register } = require('webapp'); | |
async function main() { | |
const input = register('./input.js')` | |
const msg = 'Hello world!'; | |
console.log(msg); | |
`; | |
const { source } = await webapp({ | |
input, |
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
Object.defineProperty(window, Symbol.for('registry'), { | |
value: new Map(), | |
}); | |
window.importScript = src => { | |
const registry = window[Symbol.for('registry')]; | |
if (registry.has(src)) { | |
return registry.get(src).promise; | |
} |