Skip to content

Instantly share code, notes, and snippets.

View magicdawn's full-sized avatar
🐟
Fishing

Tao magicdawn

🐟
Fishing
View GitHub Profile
@magicdawn
magicdawn / vscode-big-clock.less
Last active April 9, 2022 02:35
vscode-big-clock
#rid9\.datetime {
position: fixed;
top: 85px;
right: 105px;
font-size: 75px;
color: red;
line-height: 1.4 !important;
height: unset !important;
font-family: 'M+ 1m', 'Hack';
@magicdawn
magicdawn / ascii-logo-for-cli.js
Created January 1, 2021 18:26
ascii logo for cli
const gradient = require('gradient-string')
const figlet = require('figlet')
console.log(
gradient.rainbow(
figlet.textSync('Hello World !', {
font: 'Standard',
horizontalLayout: 'full',
})
)
@magicdawn
magicdawn / collision.js
Last active September 8, 2018 02:43
stable collison detect use in mapbox symbol layer
/**
* 初始的 filter
*/
export function initialFilter({ map, list }) {
list.forEach(item => setBox({ map, item }))
let i = 0
while (i < list.length) {
let prev = list.slice(0, i)
@magicdawn
magicdawn / yargs.js
Last active July 19, 2017 13:15
yargs
const i = yargs
.usage('$0 -u <url> [options]')
.option('url', {
alias: 'u',
describe: '专辑/歌单 url',
required: true,
type: 'string',
})
.option('concurrency', {
alias: 'c',
@magicdawn
magicdawn / ImageCaptcha.js
Created November 21, 2016 14:21
image captcha with node-gd
'use strict'
const fs = require('fs')
const _ = require('lodash')
const onecolor = require('onecolor')
const gd = require('node-gd')
// https://github.com/y-a-v-a/node-gd/blob/master/docs/index.md
// Set full path to font file
const fontpath = __home + '/files/fonts/arial.ttf'
@magicdawn
magicdawn / kuaidi.js
Last active April 15, 2016 06:50
kuaidi.js
/**
* http://v2ex.com/t/271065
* http://www.kuaidadi.com/assets/js/animate.js
*
* ES6 环境可用
* babelify: regenerator 到ES5可用。
*/
const pify = require('promise.ify').noerr;
const cowrap = require('co').wrap;
@magicdawn
magicdawn / _parse.js
Created October 21, 2014 13:16
JSON._parse not quoted key string
module.exports = parse
function parse(s) {
s = s.replace(/'/g, "\'")
.replace(/"/g, '\"')
.replace(/\n/g, '\\n')
.replace(/\r/, '\\r')
var code = "return " + s
var f = new Function(code)
@magicdawn
magicdawn / _require.js
Created October 12, 2014 01:14
nodejs module 热更新
/*
require -> Module.prototype.require -> Module.load(request,module)
require.reslove -> Module._resolveFilename(request, module);
*/
var Module = module.constructor
Module.prototype._require = function(request) {
@magicdawn
magicdawn / test_Object#hash
Created October 5, 2014 05:56
test Object#hash
Object.prototype.hash1 = function(string) {
var code = "try{ return this."+ string +" } catch(e){ return undefined }"
return (new Function(code)).call(this);
};
var test = {
'a':{
'b':{
'c':{