- keycastr
- skitch
- sketch
- gitup
- sublime text
- hyper (mostly for screenshot)
- docker
- devdocs app https://github.com/egoist/devdocs-app
- feeds
- vscode
//Component | |
import Counter from '../store/counter'; | |
export default { | |
data() { | |
return { | |
}; | |
}, | |
computed: { | |
counter() { |
// Format json and highlight it as well. | |
// Now you can use the package https://github.com/luyilin/json-format-highlight directly! :D | |
// default colors of key and types of value | |
const defaultColors = { | |
keyColor: 'dimgray', | |
numberColor: 'lightskyblue', | |
stringColor: 'lightcoral', | |
trueColor: 'lightseagreen', | |
falseColor: '#f66578', |
function decodeBase62(number) { | |
var alphabet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' | |
var out = 0 | |
var len = number.length - 1 | |
for (var t = 0; t <= len; t++) { | |
out = out + alphabet.indexOf(number.substr(t, 1)) * Math.pow(62, len - t) | |
} | |
return out | |
} |
const promisePool = <T>(list: Iterable<() => PromiseLike<T>>, limit: number): Promise<T[]> => { | |
const result: Promise<T>[] = []; | |
const iterator = list[Symbol.iterator](); | |
return new Promise((resolve, reject) => { | |
const settle = (next: ReturnType<typeof iterator["next"]>) => { | |
if (next.done) { | |
Promise.all(result).then(resolve, reject); | |
return; |
// A thing I want to do | |
// This flow only involves **one** promise, for example an ajax call | |
// None of the subsequent `then` or `catch` calls, return new promises. | |
var explode = false; | |
var promise = new Promise(function(resolve, reject) { | |
if (explode) { |
const functions = require('firebase-functions'); | |
const TelegramBot = require('node-telegram-bot-api'); | |
const token = "***" | |
const chatID = 1024 // your telegram id, you must first send a message to your bot | |
exports.notifyIAP = functions.analytics.event('in_app_purchase').onLog((event) => { | |
const purchaseValue = event.valueInUSD; | |
if (purchaseValue > 0) { | |
const bot = new TelegramBot(token, {polling: false}); |
This vanilla ES6 function async
allows code to yield
(i.e. await
) the asynchronous result of any Promise
within. The usage is almost identical to ES7's async/await
keywords.
async/await
control flow is promising because it allows the programmer to reason linearly about complex asynchronous code. It also has the benefit of unifying traditionally disparate synchronous and asynchronous error handling code into one try/catch block.
This is expository code for the purpose of learning ES6. It is not 100% robust. If you want to use this style of code in the real world you might want to explore a well-tested library like co, task.js or use async/await
with Babel. Also take a look at the official async/await
draft section on desugaring.
- node.js - 4.3.2+ (maybe earlier with
import { useLayoutEffect, useCallback, useState } from 'react' | |
export const useRect = (ref) => { | |
const [rect, setRect] = useState(getRect(ref ? ref.current : null)) | |
const handleResize = useCallback(() => { | |
if (!ref.current) { | |
return | |
} |
This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.
I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.
Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.