Skip to content

Instantly share code, notes, and snippets.

View jiangtao's full-sized avatar
:octocat:
但行好事,也问前程。Up!Up!Up!

jiangtao

:octocat:
但行好事,也问前程。Up!Up!Up!
View GitHub Profile
@jiangtao
jiangtao / fileSaver.html
Created May 16, 2020 12:13
download any file in broswer
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="btn" >download</div>
<script>
@jiangtao
jiangtao / extractStyle.js
Created December 24, 2018 06:29
Dom Extract Inner Style and Style Tag To One Style
/**
* 基于tokenizer,做页面处理
*/
const fs = require('fs')
const html = fs.readFileSync('./index.html', {
encoding: 'utf-8'
})
const $ = require('cheerio').load(html, {
withDomLvl1: false,
normalizeWhitespace: false,
@jiangtao
jiangtao / promise_catch.js
Created November 15, 2018 09:05
promise catch
const sleep = (fn, d = 500, fail = '') => new Promise((resolve, reject) => {
setTimeout(() => {
if(fail.length) {
reject(fail)
return
} else {
resolve(fn())
}
}, d)
@jiangtao
jiangtao / nginx_vue_history.conf
Created November 14, 2017 06:39
nginx vue history conf
server {
listen 8100;
root $HOME/Places/Code/pay-day-loan/dist;
index index.html
server_name 127.0.0.1;
location / {
try_files $uri $uri/ @rewrites;
}
location @rewrites {
@jiangtao
jiangtao / cloudSettings
Last active July 14, 2020 06:25
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-01-30T15:00:17.026Z","extensionVersion":"v3.4.3"}
@jiangtao
jiangtao / index.pug
Created August 22, 2017 10:24
WIP: Gyro fill effect
h2 Gyro filling
.progress-badge.js-progress-badge.is-filling.is-filling-from-empty
// BADGE
.badge.badge--empty
.badge__fill.js-badge-gyro
.badge__fill-inner
@jiangtao
jiangtao / object.js
Created August 10, 2017 03:46
simple uri object setter and getter
const PATH = require('path')
function set(obj, path, value) {
let keys = PATH.normalize(path).split('/').filter(Boolean)
let k
while(keys.length) {
k = keys.shift()
if(!obj[k] || typeof obj[k] != 'object') {
obj[k] = keys.length == 0 ? value : {}
}
@jiangtao
jiangtao / convert.sh
Last active July 31, 2017 09:34
pandoc convert
#!/bin/bash
from="src"
to="dist"
type="docx"
# 检测brew
if ! command -v brew >/dev/null 2>&1; then
echo "brew没有安装,请安装"
exit 0
fi
@jiangtao
jiangtao / flexbox.less
Created May 5, 2017 03:18 — forked from jayj/flexbox.less
CSS3 Flexbox - LESS Mixins
// --------------------------------------------------
// Flexbox LESS mixins
// The spec: http://www.w3.org/TR/css3-flexbox
// --------------------------------------------------
// Flexbox display
// flex or inline-flex
.flex-display(@display: flex) {
display: ~"-webkit-@{display}";
display: ~"-ms-@{display}box"; // IE10 uses -ms-flexbox
(function (win) {
var ratio, scaleValue, renderTime,
document = window.document,
docElem = document.documentElement,
vpm = document.querySelector('meta[name="viewport"]');
if (vpm) {
var tempArray = vpm.getAttribute("content").match(/initial\-scale=(["']?)([\d\.]+)\1?/);
if (tempArray) {
scaleValue = parseFloat(tempArray[2]);
ratio = parseInt(1 / scaleValue);