HTML:
<div class="box">
<div class="sidebar">
侧边栏
</div>
<div class="main">
主要内容
// ⚠ IMPORTANT: this is old and doesn't work for many different edge cases but I'll keep it as-is for any of you want it | |
// ⚠ IMPORTANT: you can find more robust versions in the comments or use a library implementation such as lodash's `merge` | |
// Merge a `source` object to a `target` recursively | |
const merge = (target, source) => { | |
// Iterate through `source` properties and if an `Object` set property to merge of `target` and `source` properties | |
for (const key of Object.keys(source)) { | |
if (source[key] instanceof Object) Object.assign(source[key], merge(target[key], source[key])) | |
} |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>My Iframe</title> | |
</head> | |
<body> | |
<button>Botão</button> | |
<script type="text/javascript"> |
user www-data; | |
http { | |
## | |
# Basic Settings | |
## | |
sendfile on; | |
tcp_nopush on; |
#!/usr/bin/env node | |
console.log('npx is cool!') |
{ | |
"editor.wordSeparators": "`~!@#$%^&*()=+[{]}\\|;:'\",.<>/?", | |
"editor.tabSize": 2, | |
"editor.detectIndentation": false, | |
"files.associations": { | |
"*.wxml": "html", | |
"*.wxss": "css", | |
"*.html": "html" | |
}, | |
"window.zoomLevel": 1, |
// By @coderitual | |
// https://twitter.com/coderitual/status/1112297299307384833 | |
// Remove any duplicates from an array of primitives. | |
const unique = [...new Set(arr)] | |
// Sleep in async functions. Use: await sleep(2000). | |
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms))); | |
// Type this in your code to break chrome debugger in that line. |
HTML:
<div class="box">
<div class="sidebar">
侧边栏
</div>
<div class="main">
主要内容
function cached(callback){ | |
let cached = {} | |
return function(id){ | |
const hit = cached[id] | |
return hit || (cached[id] = callback[id]) | |
} | |
} | |
//使用 | |
const idToTemplate = cached(id => { |
/* | |
* Taken from http://stackoverflow.com/questions/5867534/how-to-save-canvas-data-to-file/5971674#5971674 | |
*/ | |
var fs = require('fs'); | |
// string generated by canvas.toDataURL() | |
var img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0" | |
+ "NAAAAKElEQVQ4jWNgYGD4Twzu6FhFFGYYNXDUwGFpIAk2E4dHDRw1cDgaCAASFOffhEIO" | |
+ "3gAAAABJRU5ErkJggg=="; | |
// strip off the data: url prefix to get just the base64-encoded bytes |