example: hello world
case name | text |
---|---|
camel case | helloWorld |
snake case | hello_world |
kebab case | hello-world |
pascal case | HelloWorld |
upper snake case | HELLO_WORLD |
/** | |
* Copyright 2018 Google Inc. All rights reserved. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
const curry = fn => | |
judge = (...args) => | |
args.length === fn.length | |
? fn(...args) | |
: (arg) => judge(...args, arg) |
const downloadImage = imagePath => | |
new Promise((resolve, reject) => { | |
fetch(imagePath, { | |
headers: new Headers({ | |
Origin: location.origin | |
}), | |
mode: "cors" | |
}) | |
.then(res => res.blob()) | |
.then(blob => { |
set user [lindex $argv 0] | |
set host [lindex $argv 1] | |
set port [lindex $argv 2] | |
set password [lindex $argv 3] | |
set timeout -1 | |
spawn ssh $user@$host -oStrictHostKeyChecking=no -oCheckHostIP=no -p $port | |
expect "*assword:*" | |
send "$password\r" | |
interact |
const { log, warn, info } = console; | |
const isDevMode = process.env.NODE_ENV === "development"; | |
const color = c => isDevMode ? c : ''; | |
Object.assign(global.console, { | |
log: (...args) => log('[log]', ...args), | |
warn: (...args) => warn(color('\x1b[33m%s\x1b[0m'), '[warn]', '[nodepress]', ...args), | |
info: (...args) => info(color('\x1b[34m%s\x1b[0m'), '[info]', '[nodepress]', ...args), | |
error: (...args) => info(color('\x1b[31m%s\x1b[0m'), '[error]', '[nodepress]', ...args), | |
}); |
example: hello world
case name | text |
---|---|
camel case | helloWorld |
snake case | hello_world |
kebab case | hello-world |
pascal case | HelloWorld |
upper snake case | HELLO_WORLD |
function applyMixins(derivedCtor: any, baseCtors: any[]) { | |
baseCtors.forEach(baseCtor => { | |
Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => { | |
Object.defineProperty(derivedCtor.prototype, name, Object.getOwnPropertyDescriptor(baseCtor.prototype, name)); | |
}); | |
}); | |
} |
bindPasteEventHandle() { | |
document.addEventListener("paste", this.pasteHandler); | |
} | |
async pasteHandler(event) { | |
var items = event.clipboardData && event.clipboardData.items; | |
if (!items) return; | |
let imageRegex = /^https?:\.*?\/.*?\.(jpg|jpeg|png)$/i; | |
let file = null; | |
let fileStr = null; |
// https://stackoverflow.com/a/20732091 | |
function humanFileSize(size) { | |
var i = Math.floor( Math.log(size) / Math.log(1024) ); | |
return ( size / Math.pow(1024, i) ).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i]; | |
}; |