// /swr/project.js
import useSWR, { mutate } from 'swr'
export async function fetchProject (id) {
mutate(`/api/project/${id}`, fetch(`/api/project/${id}`))
}
export default function useProject (id) {
// don't pass the fetcher so it won't fetch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
body { | |
height: 100%; | |
margin: 0; | |
width: 100%; | |
overflow: hidden; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//**dataURL to blob** | |
function dataURLtoBlob(dataurl) { | |
var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1], | |
bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n); | |
while(n--){ | |
u8arr[n] = bstr.charCodeAt(n); | |
} | |
return new Blob([u8arr], {type:mime}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var XLSX = require('xlsx') | |
function Workbook() { | |
this.SheetNames = ['Report']; | |
this.Sheets = {}; | |
} | |
var wb = new Workbook(); | |
var ws = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new MutationObserver(function(mutations) { | |
console.log("title changed!", mutations); | |
}).observe( | |
document.querySelector('title'), | |
{ childList: true } | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>环形图</title> | |
</head> | |
<body> | |
<div id="div"></div> | |
<script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getUUID() { | |
const canvas = document.createElement('canvas'); | |
const ctx = canvas.getContext('2d'); | |
ctx.fillStyle = '#ff0000'; | |
ctx.fillRect(0,0,8,10); | |
const b64 = canvas.toDataURL().replace('data:image/png;base64,', ''); | |
const bin = window.atob(b64); | |
return bin2hex(bin.slice(-16, -12)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getBase64(img, callback) { | |
const reader = new FileReader(); | |
reader.addEventListener('load', () => callback(reader.result)); | |
reader.readAsDataURL(img); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const fs = require('mz/fs'); | |
const path = require('path'); | |
const Controller = require('egg').Controller; | |
const pump = require('mz-modules/pump'); | |
class UploadController extends Controller { | |
async pic() { | |
const { ctx } = this; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('fs').stat(BINPATH + 'selenium.jar', function (err, stat) { // got it? | |
if (err || !stat || stat.size < 1) { | |
require('selenium-download').ensure(BINPATH, function(error) { | |
if (error) throw new Error(error); // no point continuing so exit! | |
console.log('✔ Selenium & Chromedriver downloaded to:', BINPATH); | |
}); | |
} | |
}); |
NewerOlder