Skip to content

Instantly share code, notes, and snippets.

View ghostcode's full-sized avatar
🎯
Focusing

Zhuxy ghostcode

🎯
Focusing
View GitHub Profile
@ghostcode
ghostcode / nginx-webp-sample.conf
Created August 9, 2021 02:19 — forked from uhop/nginx-webp-sample.conf
Serving WEBP with nginx conditionally.
user www-data;
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
#!/usr/bin/env node
console.log('npx is cool!')
@ghostcode
ghostcode / VS-Code-Setting.json
Last active April 12, 2019 06:15
VS-Code的配置文件
{
"editor.wordSeparators": "`~!@#$%^&*()=+[{]}\\|;:'\",.<>/?",
"editor.tabSize": 2,
"editor.detectIndentation": false,
"files.associations": {
"*.wxml": "html",
"*.wxss": "css",
"*.html": "html"
},
"window.zoomLevel": 1,
@ghostcode
ghostcode / oneliners.js
Created April 2, 2019 15:36 — forked from mikowl/oneliners.js
👑 Awesome one-liners you might find useful while coding.
// 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.
@ghostcode
ghostcode / flex-layout-fixed-side.md
Last active March 28, 2019 06:49
flex布局左侧固定右边自适应

HTML:

<div class="box">
  <div class="sidebar">
    侧边栏
  </div>
  <div class="main">
    主要内容
 
@ghostcode
ghostcode / cached.js
Created March 21, 2019 14:34
Vue源码cached函数
function cached(callback){
let cached = {}
return function(id){
const hit = cached[id]
return hit || (cached[id] = callback[id])
}
}
//使用
const idToTemplate = cached(id => {
@ghostcode
ghostcode / base64-image-upload.js
Created August 2, 2018 07:24 — forked from madhums/base64-image-upload.js
save base64 encoded image
/*
* 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
@ghostcode
ghostcode / README.md
Created June 28, 2018 08:20 — forked from pbojinov/README.md
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

在Mac、Linux 终端显示 Git 当前所在分支

  1. 进入你的home目录
cd ~
  1. 编辑.bashrc文件
@ghostcode
ghostcode / 提问的智慧.md
Created May 17, 2018 16:18 — forked from zer4tul/提问的智慧.md
Simplified Chinese edition of "How To Ask Questions The Smart Way"