Skip to content

Instantly share code, notes, and snippets.

View sunnylost's full-sized avatar
💭
I may be slow to respond.

sunnylost sunnylost

💭
I may be slow to respond.
View GitHub Profile
@sunnylost
sunnylost / douban.js
Created December 11, 2021 14:56
豆瓣读书使用 jiumo 搜索快捷脚本
// ==UserScript==
// @name 豆瓣jiumo图书搜索
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 将书籍标题替换为 jiumo 搜索链接
// @author You
// @match https://book.douban.com/subject/*
// @grant none
// ==/UserScript==
@sunnylost
sunnylost / transform.js
Created November 7, 2020 05:29
Transform lodash to lodash-es
const fs = require('fs')
const path = require('path')
const parser = require('@babel/parser')
const traverse = require('@babel/traverse').default
const generator = require('@babel/generator').default
const t = require('@babel/types')
const prettier = require('prettier')
let code = fs.readFileSync(path.resolve(__dirname, './test/1.js'), {
encoding: 'utf8'
@sunnylost
sunnylost / index.js
Created June 9, 2017 10:33
Multi-thread Share
let cluster = require( 'cluster' ),
gid = 0,
callbackMap = new Map
if ( cluster.isMaster ) {
const cache = new Map
cluster.on( 'message', ( worker, message ) => {
let value
@sunnylost
sunnylost / honukai.zsh-theme
Created May 5, 2016 02:56
oh-my-zsh theme: honukai(modified)
# Clean, simple, compatible and meaningful.
# Tested on Linux, Unix and Windows under ANSI colors.
# It is recommended to use with a dark background and the font Inconsolata.
# Colors: black, red, green, yellow, *blue, magenta, cyan, and white.
#
# http://ysmood.org/wp/2013/03/my-ys-terminal-theme/
# Mar 2013 ys
# Machine name.
function box_name {
@sunnylost
sunnylost / ScrollToTop.js
Last active August 22, 2016 10:11
Tampermonkey scripts
// ==UserScript==
// @name Scroll To Top
// @namespace sunnylost
// @version v1.3.2
// @grant unsafeWindow
// @grant GM_addStyle
// @include http://*
// @include https://*
// ==/UserScript==
/* jshint esnext:true, lastsemic:true, asi:true */
@sunnylost
sunnylost / 2016.md
Last active January 6, 2016 06:44
New Year's Resolution

Project

  • Virtual DOM
  • Static Web Server
  • Web Server

JavaScript

  • Proxy
  • WeakSet
//https://gist.github.com/DmitrySoshnikov/29f7a9425cdab69ea68f
var grammar = {
1: [ 'S', '( S )' ],
2: [ 'S', 'e' ]
},
table = {
S: {
'(': 1,
@sunnylost
sunnylost / collatz.es6
Last active August 29, 2015 14:24
奇偶归一猜想(Collatz)
let cache = {
1: 1
},
MAX = 1e6,
odd = n => 3 * n + 1,
even = n => n / 2,
isEven = n => n % 2 == 0,
collatzSequence = n => {
let chains = [ n ]
@sunnylost
sunnylost / template.html
Last active August 29, 2015 14:08
A simple template checker
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Check Template</title>
</head>
<body>
<iframe id="iframe" style="visibility:hidden;"></iframe>
<script type="text/tmpl" id="t1">
@sunnylost
sunnylost / build.js
Created August 19, 2014 10:39
Build.js
var fs = require('fs'),
through = require('through2'),
uglify = require('uglify-js');
var BASE = './script-ss/',
DEST = './script-min/',
SPECIAL_TAG = '/*common*/';
var modules = [];