This file contains hidden or 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
<html> | |
<head> | |
<title>Stripe Gradient</title> | |
</head> | |
<body> | |
<canvas id="gradient-canvas" data-js-darken-top data-transition-in> | |
<!-- | |
Remove data-js-darken-top to keep the same brightness in the upper part of the canvas | |
--> | |
</canvas> |
This file contains hidden or 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 ListNode(val, next) { | |
this.val = (val === undefined ? 0 : val) | |
this.next = (next === undefined ? null : next) | |
} | |
function List2Array (list, arr = []) { | |
arr.push(list.val) | |
if (list.next instanceof ListNode) { | |
List2Array(list.next, arr) | |
} |
This file contains hidden or 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
div { | |
background: lightblue; | |
} |
This file contains hidden or 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
/** | |
* VuexLastingPlugin | |
* | |
* @desc Store vuex states in storage | |
* @author JrainLau [email protected] | |
* | |
* @param {Object} options options | |
* @param {String|Array} options.watch the state to store | |
* @param {Boolean} options.debug debug mode | |
* @param {Boolean} options.autoInit init state from storage automatically |
This file contains hidden or 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
// sending to sender-client only | |
socket.emit('message', "this is a test"); | |
// sending to all clients, include sender | |
io.emit('message', "this is a test"); | |
// sending to all clients except sender | |
socket.broadcast.emit('message', "this is a test"); | |
// sending to all clients in 'game' room(channel) except sender |
This file contains hidden or 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
const puppeteer = require('puppeteer') | |
const fs = require('fs') | |
const cateNames = ['aero', 'auroras', 'black', 'bokeh', 'colorful', 'creative', 'fresh', 'macro', 'patterns', 'rainbow', 'vector_art', 'white', 'animals', 'birds', 'horses', 'insects', 'others', 'pets', 'reptiles_&_frogs', 'sea', 'wild', 'architecture', 'army', 'artistic', '3d', 'abstract', 'anime', 'drawings', 'fantasy', 'graffiti', 'grunge', 'sculpture', 'typography', 'urban', 'black_and_white', 'cartoons', 'bee_movie', 'bolt', 'brave', 'cars', 'coraline', 'futurama', 'gnomeo_&_juliet', 'ice_age', 'incredibles', 'kung_fu_panda', 'madagascar', 'monsters_inc', 'ninja_turtles', 'old_disney', 'open_season', 'others', 'planet_51', 'ratatouille', 'shrek', 'south_park', 'tangled', 'the_princess_and_the_frog', 'the_simpsons', 'tinker_bell', 'toy_story', 'up', 'walle', 'celebrities', 'models', 'movies', 'music', 'charity', 'city', 'computers', 'android', 'firefox', 'hardware', 'linux', 'mac', 'nvidia', 'others', 'vaio', 'web', 'windows', 'cute', 'eleme |
This file contains hidden or 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
// v2 | |
function angle (x, y) { | |
let angleRate = 360 * Math.atan(y / x) / (2 * Math.PI) |> parseInt |> Math.abs | |
if (y >= 0 && x < 0) { | |
angleRate = 180 - angleRate | |
} else if (y < 0 && x <= 0) { | |
angleRate += 180 | |
} else if (y < 0 && x > 0) { | |
angleRate = 360 - angleRate |
This file contains hidden or 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
export const getCursorPosition = (element) => { | |
let caretOffset = 0 | |
const doc = element.ownerDocument || element.document | |
const win = doc.defaultView || doc.parentWindow | |
const sel = win.getSelection() | |
if (sel.rangeCount > 0) { | |
const range = win.getSelection().getRangeAt(0) | |
const preCaretRange = range.cloneRange() | |
preCaretRange.selectNodeContents(element) | |
preCaretRange.setEnd(range.endContainer, range.endOffset) |
This file contains hidden or 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
import chooseImg from 'chooseImg' | |
const onPaste = (e) => { | |
if (!(e.clipboardData && e.clipboardData.items)) { | |
return | |
} | |
return new Promise((resolve, reject) => { | |
for (let i = 0, len = e.clipboardData.items.length; i < len; i++) { | |
const item = e.clipboardData.items[i] | |
if (item.kind === 'string') { |
This file contains hidden or 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 toPreviewer (dataUrl, cb) { | |
cb && cb(dataUrl) | |
} | |
function compress (img, fileType, maxWidth) { | |
let canvas = document.createElement('canvas') | |
let ctx = canvas.getContext('2d') | |
const proportion = img.width / img.height | |
const width = maxWidth |
NewerOlder