Skip to content

Instantly share code, notes, and snippets.

View ijse's full-sized avatar
🎯
Focusing

Li Yi ijse

🎯
Focusing
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Untitled benchmark</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@ijse
ijse / EventBus.js
Created May 22, 2017 08:33
Simple and no-deps EventEmitter implement for Browser
export default class EventBus {
constructor () {
this.bus = document.createElement('span')
}
on (eventName, fn) {
const handler = event => {
fn && fn(...event.params)
}
this.bus.addEventListener(eventName, handler)
@ijse
ijse / findata.json
Last active May 15, 2017 08:13
tiger findata
{
"ret": 0,
"items": [
{
"market": "US",
"sectors": [
{
"name": "工业产品",
"industries": [
{
@ijse
ijse / tooltip.less
Created December 5, 2016 03:07
Pure CSS Tooltips
[tooltip],
[tooltip-top],
[tooltip-right],
[tooltip-left],
[tooltip-bottom] {
@bgcolor: #495364;
position: relative;
cursor: pointer;
&:before,
&:after {
@ijse
ijse / github-api-merge-branch.sh
Created October 15, 2016 10:33
call github api to merge branches
#!/bin/bash
# Merge Github branch
#
# Usage:
# shells/merge-branch.sh <base-branch> <head-branch> [commit message]
request=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )/request.sh
# The name of the base branch that the head will be merged into.
#!/bin/bash
# Request Github Api
#
# Usage:
# shells/request.sh <GET|POST> <api> [params]
#
# Sample:
# ./shells/request.sh POST merges \
# "{\"base\":\"master\",\"head\":\"develop\",\"commit_message\":\"$message\"}"
@ijse
ijse / brainfuck-at-codewars.js
Created September 14, 2016 11:58
brainfuck
// Brainfuck.
//
// codewars: https://www.codewars.com/kata/my-smallest-code-interpreter-aka-brainf-star-star-k/train/javascript
// brainfuck debug tool: http://www.iamcal.com/misc/bf_debug/
// brainfuck on wikipedia: https://zh.wikipedia.org/wiki/Brainfuck
function brainLuck(code, input){
let codeInArray = code.split('');
let inputInArray = input.split('');
console.log(code);
@ijse
ijse / dynamic-viewport.js
Created August 10, 2016 07:15
dynamic set html font-size
(function (doc, win) {
var docEl = doc.documentElement,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function () {
var clientWidth = docEl.clientWidth;
if (!clientWidth) return;
docEl.style.fontSize = 36 * (clientWidth / 320) + 'px';
};
if (!doc.addEventListener) return;
win.addEventListener(resizeEvt, recalc, false);
@ijse
ijse / file.js
Last active March 29, 2016 02:34
webpack-dev-middleware getFilenameFromUrl compare
var url = require('url');
var options = {
publicPath: '/test'
};
var compiler = {
outputPath: '/'
};
function pathJoin(a, b) {
return a == "/" ? "/" + b : (a||"") + "/" + b;
var isMobile = false;
$editor.on('click', '.comment-bar', function(event) {
if(isMobile) return null;
handleBarClick(event);
});
$editor.on('touchstart', '.comment-bar', function(event) {
isMobile = true;
handleBarClick(event);