Skip to content

Instantly share code, notes, and snippets.

View miaopeng's full-sized avatar
🎯
🎧 🎨 🎦 🚶

Peng Miao (mios) miaopeng

🎯
🎧 🎨 🎦 🚶
  • 观云
  • Beijing, China
View GitHub Profile
@miaopeng
miaopeng / index.html
Created April 28, 2022 08:40 — forked from iamsaso/index.html
GraphiQL with JWT
<!DOCTYPE html>
<html>
<head>
<style>
body {
height: 100%;
margin: 0;
width: 100%;
overflow: hidden;
}
//**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});
}
@miaopeng
miaopeng / test.js
Created February 24, 2021 09:33 — forked from smalljam/test.js
xlsx library patch, so we can make bold cells and align them to the right
var XLSX = require('xlsx')
function Workbook() {
this.SheetNames = ['Report'];
this.Sheets = {};
}
var wb = new Workbook();
var ws = {
// /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
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));
}
var path = require('path');
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var Clean = require('clean-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var jsBuildPath = path.resolve(__dirname, 'build');
var config = {
entry: {
@miaopeng
miaopeng / gist:b865ae1d7d1d55c8afe7
Last active September 11, 2015 05:09 — forked from kejun/gist:72112e5848f5e3921b0d
react + linear partition算法实现的图墙布局
var React = require('react');
var EventListener = require('react/lib/EventListener');
var partition = require('linear-partitioning');
var TileLayout = React.createClass({
getDefaultProps: function() {
return {
gutter: 0,
photos: []
}