I recently needed to extract a feature from a project to its own repo so I could publish as a standalone library:
# from
/some-project/src/some-folder/some-feature/*
// decorated search function | |
const search = last(function (query) { | |
return new Promise(function (resolve, reject) { | |
setTimeout(() => { | |
// randomly fail | |
Math.random() < .25 | |
? reject(new Error('failed for query ' + query)) | |
: resolve(String(query).toUpperCase()) | |
}, Math.random() * 2000) | |
}) |
/** | |
* INSTRUCTIONS | |
* | |
* Video at: https://youtube.com/watch?v=AzSDmfDDijQ | |
* | |
* 1. copy the code below into a bookmark | |
* 2. go to https://www.facebook.com/stories/ | |
* 3. click on a story | |
* 4. hit pause on one you like | |
* 5. find and run your bookmark |
import Vue from 'vue' | |
export function cached (target: Function) { | |
// get descriptors | |
const descriptors: any = Object.getOwnPropertyDescriptors(target.prototype) | |
const getters = Object | |
.keys(descriptors) | |
.filter(key => descriptors[key].get && !descriptors[key].set) | |
// we have getters! |
body { | |
padding-left: 400px; | |
} | |
div[class^=RebrandPlayerQueueItem__QueueItem] { | |
width: 400px; | |
} | |
div.player-height-placeholder div[class^=playerQueue__UpNextArea] { | |
z-index: 1000 !important; |
/** | |
* Helper function to reduce boilerplate in route creation | |
* | |
* @param {string} path The route's path | |
* @param {object} page A page component definition | |
* @param {Function} page A function that returns a page import | |
* @param {string} page A string path to a file in the view/pages folder | |
* @param {object} attrs Any additional attributes | |
*/ | |
export function route (path, page, attrs = {}) { |
cells (row, col, name) { | |
if (!this.hot) { | |
return null | |
} | |
const rowData = this.hot.getSourceDataAtRow(row) | |
if (rowData) { | |
if (rowData.state === NegotiationItemState.removed) { | |
return { readOnly: true } | |
} |
javascript: | |
` | |
WorkFlowy x 2 | |
============= | |
- A browser Bookmarklet to give you a dual panel WorkFlowy view | |
Features / Usage: |
// collection.js | |
export function forEach (arr, callback) { ... } | |
export function map (arr, callback) { ... } | |
export function get (arr, id, key = 'id') { ... } | |
export function getIndex (arr, id, key = 'id') { ... } | |
export function add (arr, item, index = -1) { ... } | |
export function update (arr, id, values) { ... } | |
export function move (fromArr, id, toIndex, toArr = fromArr) { ... } | |
export function moveByIndex (fromArr, fromIndex, toIndex, toArr = fromArr) { ... } | |
export function remove (arr, id) { ... } |
(function track (id) { | |
// prepare data | |
window.dataLayer = window.dataLayer || [] | |
function gtag () { dataLayer.push(arguments) } | |
gtag('js', new Date()) | |
gtag('config', id) | |
// load analytics | |
var script = document.createElement('script') |