Skip to content

Instantly share code, notes, and snippets.

View wangpin34's full-sized avatar
🎯
Focusing

Penn wangpin34

🎯
Focusing
View GitHub Profile
@wangpin34
wangpin34 / rss-feeds.yaml
Last active February 2, 2021 09:41
rss-feeds
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 / env.js
Last active November 16, 2020 02:17
load env variables of different stacks
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()
}
@wangpin34
wangpin34 / .npmrc
Last active November 16, 2020 02:03
vscode dev settings
// 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/

单位

inch(英寸)

pixel(像素)

ppi (Pixel Per Inch)

ppi,每英寸像素数量。

pix -> ppi

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

/*
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 September 9, 2019 08:10
light lodash
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 August 20, 2019 02:57
golang list: general helper functions
/*
*
* 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)
.env.dev
.env.qa
.env.stg
.env.prod
@wangpin34
wangpin34 / index.js
Created May 10, 2019 06:23
only allow input numbers
function handleKeydown(e) {
if (e.shiftKey) {
if (e.which !== 9) {
e.preventDefault()
}
}
if (e.which > 57) {
e.preventDefault()
}
if (e.which === 32) {
@wangpin34
wangpin34 / react-json-view-thinking.md
Last active December 13, 2018 06:23
react json viewer

app.js

import React, { Component } from 'react';
import './app.scss';

const Bracket = ({b}) => <span className="bracket">&nbsp;{b}&nbsp;</span>;
const ListWrapper = ({children}) => <section>{children}</section>;
const MapWrapper = ({children}) => <section>{children}</section>;

const NodeKey = ({k}) => (<label>{'"' + k + '"'}:</label>);