start new:
tmux
start new with session name:
tmux new -s myname
| copyToClipboard(str) { | |
| /* ——— Derived from: https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f | |
| improved to add iOS device compatibility——— */ | |
| const el = document.createElement('textarea'); // Create a <textarea> element | |
| let storeContentEditable = el.contentEditable; | |
| let storeReadOnly = el.readOnly; | |
| el.value = str; // Set its value to the string that you want copied | |
| el.contentEditable = true; |
| function getPaginatedItems(items, page, pageSize) { | |
| var pg = page || 1, | |
| pgSize = pageSize || 100, | |
| offset = (pg - 1) * pgSize, | |
| pagedItems = _.drop(items, offset).slice(0, pgSize); | |
| return { | |
| page: pg, | |
| pageSize: pgSize, | |
| total: items.length, | |
| total_pages: Math.ceil(items.length / pgSize), |
| var Promise = require('bluebird'); | |
| var funcs = Promise.resolve([500, 100, 400, 200].map((n) => makeWait(n))); | |
| funcs | |
| .each(iterator) // logs: 500, 100, 400, 200 | |
| .then(console.log) // logs: [ [Function], [Function], [Function], [Function] ] | |
| funcs | |
| .mapSeries(iterator) // logs: 500, 100, 400, 200 |
| var request = require("request"); | |
| var async = require("async"); | |
| var fs = require("fs"); | |
| function searchFor(searchQuery, pageNum, callback) { | |
| for(var i = 0; i < pageNum; i++) { | |
| (function(i) { | |
| request.get("https://www.google.fr/search?q=" + searchQuery + "&start=" + i * 10, function(err, res) { | |
| if(err) throw err; |
| /** | |
| * Changes value to past tense. | |
| * Simple filter does not support irregular verbs such as eat-ate, fly-flew, etc. | |
| * http://jsfiddle.net/bryan_k/0xczme2r/ | |
| * | |
| * @param {String} value The value string. | |
| */ | |
| Vue.filter('past-tense', function(value) { | |
| // Slightly follows http://www.oxforddictionaries.com/us/words/verb-tenses-adding-ed-and-ing | |
| var vowels = ['a', 'e', 'i', 'o', 'u']; |