Skip to content

Instantly share code, notes, and snippets.

View JSoon's full-sized avatar
🍼
🦁

J.Soon JSoon

🍼
🦁
  • Chengdu, China
View GitHub Profile
@JSoon
JSoon / webkit-pseudo-elements.md
Created October 9, 2021 06:27 — forked from leostratus/webkit-pseudo-elements.md
Webkit Pseudo-Element Selectors (Shadow DOM Elements)

An ongoing project to catalogue all of these sneaky, hidden, bleeding edge selectors as I prepare my JSConf EU 2012 talk.

Everything is broken up by tag, but within each the selectors aren't particularly ordered.

I have not tested/verified all of these. Have I missed some or got it wrong? Let me know. - A

A friendly reminder that you may need to set this property on your target/selected element to get the styling results you want:

-webkit-appearance:none;

@JSoon
JSoon / formatNumber.js
Created August 21, 2020 09:17
格式化数字, 保留小数位精度
import BigNumber from 'bignumber.js';
/**
* 格式化数字, 保留小数位精度
* @param {number} originNumber 数字
* @param {number} precision 小数位精度
*/
const formatNumber = (originNumber = 0, precision = 2) => {
if (Number.isNaN(Number(originNumber))) {
throw new Error('数字格式错误');
@JSoon
JSoon / vscode_reduce_cpu_usage.md
Created July 21, 2020 02:36 — forked from messified/vscode_reduce_cpu_usage.md
VSCode Reduce CPU Usage

VSCode Reduce CPU Usage

Update your settings.json with the code below, then restart vscode:

{
    "files.exclude": {
        "**/.git": true,
        "**/.svn": true,
 "**/.hg": true,
@JSoon
JSoon / root.js
Created March 25, 2020 01:48 — forked from antonlvovych/root.js
Get root path of node.js application
var path = require('path');
module.exports = (function () {
return path.dirname(require.main.filename || process.mainModule.filename);
})();
// Example of usage:
var root = require('root'); // In root will be absolute path to your application
@JSoon
JSoon / ioredis-keyspace-notification.js
Created September 11, 2019 08:54
ioredis实现Redis Keyspace Notifications
// 参考文献
// https://redis.io/topics/notifications
// https://medium.com/@micah1powell/using-redis-keyspace-notifications-for-a-reminder-service-with-node-c05047befec3
const Redis = require('ioredis');
//#region Redis测试
// subscriber
let RedisSubTester = new Redis({
port: 6379, // Redis port
@JSoon
JSoon / ajaxRetryAfterFailure.js
Created July 18, 2019 02:46
ajax请求失败后重试封装方法
/**
* @description 带重试器的jQuery ajax封装方法
*
* @param {object} opts $.ajax options
*/
function JQ_AJAX(opts) {
var tryCount = opts.tryCount || 0; // 当前重试次数,默认0次
var retryLimit = opts.retryLimit || -1; // 当前最大重试次数,默认-1,请求失败不重试
@JSoon
JSoon / test.js
Created December 14, 2018 01:32 — forked from jmyrland/test.js
Socket-io load test?
/**
* Modify the parts you need to get it working.
*/
var should = require('should');
var request = require('../node_modules/request');
var io = require('socket.io-client');
var serverUrl = 'http://localhost';
@JSoon
JSoon / terminal-git-branch-name.md
Created September 25, 2018 06:58 — forked from joseluisq/terminal-git-branch-name.md
Add Git Branch Name to Terminal Prompt (Mac)

Add Git Branch Name to Terminal Prompt (Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@JSoon
JSoon / colorToGrayscale.html
Last active July 19, 2018 07:46
【canvas】将彩色图片转换为灰度图片
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>colorToGrayscale</title>
</head>
<body>
@JSoon
JSoon / tvNoiseEffect.html
Last active July 19, 2018 07:46
【canvas】电视机无信号噪点动效,利用正弦函数模拟真实噪声影像
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>电视机无信号噪点动效,利用正弦函数模拟真实噪声影像</title>
<style>
.tv-box {