Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Pengson wangpin34

🎯
Focusing
View GitHub Profile
View rss-feeds.yaml
categories:
- category: tech
feeds:
- http://rachelbythebay.com/w/atom.xml
- http://feeds.feedburner.com/ruanyifeng
- http://blog.samaltman.com/posts.atom
- https://dave.cheney.net/feed/atom
@wangpin34
wangpin34 / .npmrc
Last active Nov 16, 2020
vscode dev settings
View .npmrc
// saved at root of repo, or global
registry = https://registry.npm.taobao.org
sass_binary_site = https://npm.taobao.org/mirrors/node-sass/
electron_mirror = https://npm.taobao.org/mirrors/electron/
View mobile.md

单位

inch(英寸)

pixel(像素)

ppi (Pixel Per Inch)

ppi,每英寸像素数量。

pix -> ppi

根据像素和屏幕尺寸计算 ppi。

/*
View download.js
function download(text, name, type) {
var a = document.createElement('a')
a.style.display = "block";
var file = new Blob([text], {type: type});
a.href = URL.createObjectURL(file);
a.download = name;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
View float.js
function repeatChar(char, times) {
if (typeof String.prototype.repeat === 'function') {
return char.repeat(times)
}
let count = 0
const array = []
while (count < times) {
count += 1
array.push(char)
}
@wangpin34
wangpin34 / index.js
Last active Sep 9, 2019
light lodash
View index.js
const debounce = (func, delay) => {
let inDebounce
return function() {
const context = this
const args = arguments
clearTimeout(inDebounce)
inDebounce = setTimeout(() => func.apply(context, args), delay)
}
}
@wangpin34
wangpin34 / main.go
Last active Aug 20, 2019
golang list: general helper functions
View main.go
/*
*
* Demo: https://repl.it/@wangpin34/array-utils
*/
/*
* Filter elements which pass the test function
*/
func filter(in interface{}, testFunc func(interface{}) bool) *[]interface{} {
b, _ := json.Marshal(in)
@wangpin34
wangpin34 / env.js
Last active Nov 16, 2020
load env variables of different stacks
View env.js
const dotenv = require('dotenv')
const path = require('path')
const fs = require('fs')
function load() {
if (process.env.stack) {
return dotenv.config({ path: path.join(__dirname, `.env.${process.env.stack}`) })
}
return dotenv.config()
}
View stacks.ini
.env.dev
.env.qa
.env.stg
.env.prod
@wangpin34
wangpin34 / index.js
Created May 10, 2019
only allow input numbers
View index.js
function handleKeydown(e) {
if (e.shiftKey) {
if (e.which !== 9) {
e.preventDefault()
}
}
if (e.which > 57) {
e.preventDefault()
}
if (e.which === 32) {