Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

kejun kejun

💭
I may be slow to respond.
View GitHub Profile
View gist:44c1411433c59d763968270fedcf2b66
const babel = require('@babel/core');
const t = require('@babel/types');
const sampleCode = `\
import {uniq, extend, flatten, cloneDeep } from "lodash";
export default function Test() {
return (
<Sky.Card>
Test
<Wind.Button type="primary" loading>{intl('sas.baseline.inDetection')}</Wind.Button>
View 浏览器指纹.js
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));
}
View gist:a825285adb69de0a77b578cc265f3a20
;(() => {
const mergeText = (str, text) => {
if (str === '') {
return text;
}
if (!text || text === ' ' || str === text) {
return str;
}
str = str.replace(/\s+/g, ' ')
.replace(/\t|\r|\n/g, '');
View demo
// pug
div.menu
ul
each v in [1,2,3,4,5,6,7,8]
li
a( href='#' )= v
// css
@mixin circle-layout($radius, $dot-radius, $num) {
$deg: 360deg / $num;
View gist:d6e4a5380a0d84f04f4f0623e14768e5
/**
* r: circle -> r, ellipse -> rx, ry
*/
export const getCenterPoint = (x, y, r) => (r.rx ? {
x: x + r.rx,
y: y + r.ry,
rx: r.rx,
ry: r.ry,
} : {
x: x + r,
View config-files
package.json
{
"devDependencies": {
"autoprefixer": "^7.2.5",
"babel-preset-env": "^1.6.1",
"node-sass": "^4.7.2",
"postcss-inline-svg": "^3.0.0",
"postcss-write-svg": "^3.0.1"
},
"dependencies": {
View dabblet.css
body { background: #333;}
a {
display: inline-block;
}
a img{
position: relative;
z-index: -1;
}
View npm scripts
"scripts": {
"build": "webpack --progress --profile --colors",
"build-watch": "webpack --progress --profile --colors --watch",
"dev": "webpack-dev-server --devtool eval --progress --colors --hot --content-base demo",
"test": "echo \"Error: no test specified\" && exit 1"
}
View sample-webpack-config.js
const path = require('path');
const webpack = require('webpack');
const CleanPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const extractSass = new ExtractTextPlugin({
filename: 'css/[name].css'
});
const jsBuildPath = path.resolve(__dirname, 'dist');
@kejun
kejun / gist:72112e5848f5e3921b0d
Created Mar 7, 2015
react + linear partition算法实现的图墙布局
View gist:72112e5848f5e3921b0d
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: []
}
You can’t perform that action at this time.