Skip to content

Instantly share code, notes, and snippets.

View EnixCoda's full-sized avatar
👨‍🚀
in space

Enix EnixCoda

👨‍🚀
in space
View GitHub Profile
@EnixCoda
EnixCoda / .gitconfig
Created March 29, 2021 15:14
Multiple git configs & users on single machine, require git version >= 2.13
[user]
name = globalName
email = global@mail.com
useConfigOnly = true # recommended to keep
[includeIf "gitdir:~/special-workspace/"]
path = ~/special.gitconfig
@EnixCoda
EnixCoda / jest-puppeteer.config.js
Last active June 8, 2023 05:21
Test local Chrome extensions with Jest and Puppeteer
// install dependencies first:
// $ yarn add jest jest-puppeteer puppeteer -D
const path = require('path')
const CRX_PATH = path.resolve(__dirname, 'path/to/local/extension/dir')
module.exports = {
launch: {
headless: false, // required for loading extensions
@EnixCoda
EnixCoda / machine.js
Created November 28, 2019 02:24
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@EnixCoda
EnixCoda / styled.js
Last active October 14, 2019 01:49
simple styled-components
/*
* Usages
*
* native tags
* styled.div`color: red;`
*
* custom components
* styled((props) => <div {...props} />)`color: red;`
*
*/
@EnixCoda
EnixCoda / index.jsx
Created November 22, 2018 10:00
render with global data and inner counter
const globalData = []
class Component extends React.Component {
componentDidMount() {
setInterval(() => {
globalData.push(0)
this.setState((count = 0) => count + 1,)
}, 100)
}
render() {
@EnixCoda
EnixCoda / index.js
Created September 22, 2018 06:23
turn ref into render props
class _ControllerX extends React.Component {
static propTypes = {
forwardRef: PropTypes.func
}
ref = r => this.r = r
someCallback() {
this.r.method()
}
@EnixCoda
EnixCoda / polyfill.js
Created August 9, 2018 01:50
Async/Await polyfill
module.exports = function decorate(func) {
const f = func()
return (function run(input) { f.next(input).then(run) })()
}
@EnixCoda
EnixCoda / NodeJS.v.10.7.0.md
Last active November 1, 2018 19:16
safe-touch benchmark, MacBookPro 2015 15'
***********************************************************
try...catch VS safe-touch
Will run 100,000 times for each test case.

Will test with these retrieve methods:
  function impossibleRetrieve(_) { return _[Math.random()][Math.random()] }
  function shallowRetrieve(_) { return _.key }
  function deepRetrieve(_) { return _.a.b.c.d.e.f.g.h.i }
@EnixCoda
EnixCoda / battery.js
Created March 22, 2017 05:01
ECNU宿舍电量查询脚本
const http = require('http')
const options = {
host: 'wx.ecnu.edu.cn',
path: '/CorpWeChat/card/dogetEle.html',
method: 'POST',
headers: {
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'application/x-www-form-urlencoded'
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Luck Money</title>
<style>
* {
margin: 6px;
}