Skip to content

Instantly share code, notes, and snippets.

🐟
Fishing

Tao magicdawn

🐟
Fishing
Block or report user

Report or block magicdawn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@magicdawn
magicdawn / collision.js
Last active Sep 8, 2018
stable collison detect use in mapbox symbol layer
View collision.js
/**
* 初始的 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)
View yargs.js
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 Nov 21, 2016
image captcha with node-gd
View ImageCaptcha.js
'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'
View 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 Oct 21, 2014
JSON._parse not quoted key string
View _parse.js
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 Oct 12, 2014
nodejs module 热更新
View _require.js
/*
require -> Module.prototype.require -> Module.load(request,module)
require.reslove -> Module._resolveFilename(request, module);
*/
var Module = module.constructor
Module.prototype._require = function(request) {
View 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':{
View alias_task.rake
def alias_task(name, old_name)
t = Rake::Task[old_name]
desc t.full_comment if t.full_comment
task name, *t.arg_names do |_, args|
# values_at is broken on Rake::TaskArguments
args = t.arg_names.map { |a| args[a] }
t.invoke(args)
end
end
@magicdawn
magicdawn / Microsoft YaHei.css
Created Sep 13, 2014
微软雅黑,重定向字体版
View Microsoft YaHei.css
/*
* 代码整理自 百度贴吧-chrome吧 @晓风残破
* http://tieba.baidu.com/p/3285731258
*
*/
*{
text-shadow: silver 0px 0px 1px;
}
You can’t perform that action at this time.