Skip to content

Instantly share code, notes, and snippets.

View shiningjason's full-sized avatar

Jason Chung shiningjason

  • Taiwan
View GitHub Profile
@shiningjason
shiningjason / package.json
Last active September 27, 2020 06:59
yarn-publish
{"name":"yarn-publish","version":"0.0.0","bin":"./yarn-publish.sh"}
@shiningjason
shiningjason / parse_yaml.sh
Created June 19, 2020 08:28
Read YAML file from Bash script
#!/bin/bash
parse_yaml() {
local yaml_file=$1
local prefix=$2
local indentUnit=${3:-2}
local s="[[:space:]]"
local w="[a-zA-Z0-9_]"
awk '
@shiningjason
shiningjason / TestDelegatePerformance.cs
Last active August 5, 2019 07:30
Test Delegate Getter Performance
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
namespace ConsoleApp
{
internal class Program
{
@shiningjason
shiningjason / DateRangePicker.js
Created May 23, 2019 17:30
Custom DateRangePicker with ant design
import { Col, DatePicker, Row } from 'antd'
import moment from 'moment'
import { arrayOf, func, instanceOf, string } from 'prop-types'
import React, { useEffect, useRef, useState } from 'react'
const isSameDate = (date1, date2) =>
date1 === date2 || (date1 && date1.isSame(date2))
const isSameDateRange = (range1, range2) =>
isSameDate(range1[0], range2[0]) && isSameDate(range1[1], range2[1])
@shiningjason
shiningjason / index.js
Last active March 27, 2019 06:25
Delete git branches interactively
#!/usr/bin/env node
const inquirer = require('inquirer')
const git = require('simple-git/promise')
;(async () => {
const repo = git()
const { branches } = await repo.branchLocal()
const branchNames = Object.values(branches).map(b => b.name)
const { willDeleteBranches } = await inquirer.prompt([
@shiningjason
shiningjason / index.js
Created October 18, 2018 05:41
document.ready in vanilla JS
(function initDocumentReadyListener() {
var ie = !!(window.attachEvent && !window.opera);
var wk = /webkit\/(\d+)/i.test(navigator.userAgent) && (RegExp.$1 < 525);
var fn = [];
var run = function () { for (var i = 0; i < fn.length; i++) fn[i](); };
var d = document;
d.ready = function (f) {
if (!ie && !wk && d.addEventListener) return d.addEventListener('DOMContentLoaded', f, false);
if (fn.push(f) > 1) return;
if (ie) {
@shiningjason
shiningjason / createAsyncComponent.js
Created July 29, 2018 15:48
createAsyncComponent.js
import React from 'react'
export default function createAsyncComponent(loader, options = {}) {
const { Placeholder } = options
let Component
return class AsyncComponent extends React.Component {
static load() {
return loader().then(ResolvedComponent => {
Component = ResolvedComponent.default || ResolvedComponent
})
@shiningjason
shiningjason / ng-react-adapter.js
Last active March 28, 2018 08:48
Angular react adapter
import React from 'react'
import ReactDOM from 'react-dom'
import { object, string } from 'prop-types'
import isEqual from 'lodash/isEqual'
import Knob from '@app/components/dumbs/knob'
function createNgComponent(ReactComponent) {
const propTypes = {
className: string,
@shiningjason
shiningjason / buildWasmWithEMSDK.sh
Last active June 15, 2017 05:20
Build WebAssembly with Emscripten
# ========================
# 1. Clone and build emsdk
# ========================
# />
git clone https://github.com/juj/emsdk.git
cd emsdk
./emsdk install --build=Release sdk-incoming-64bit binaryen-master-64bit
./emsdk activate --global --build=Release sdk-incoming-64bit binaryen-master-64bit
@shiningjason
shiningjason / buildWasmWithLLVM.sh
Last active April 11, 2020 00:35
Build WebAssembly with LLVM/Clang/binaryen/wabt
# =======================
# 1. Clone and build LLVM
# =======================
# />
gcc -v
make -v
cmake --version
brew install cmake
xcode-select --install