Skip to content

Instantly share code, notes, and snippets.

@StrongerMyself
StrongerMyself / machine.js
Last active August 2, 2023 15:57
Generated by XState Viz: https://xstate.js.org/viz
const release = Machine( {
id: "release",
initial: "start",
context: {
level: "patch",
tag: "0.0.1",
fixVersion: "SSR_release_v0.0.1",
},
states: {
start: {
$gridPad: 20px
$gridColLen: 12
.g-row
display: flex
flex-wrap: wrap
width: calc(100% + #{$gridPad})
margin-left: -#{$gridPad / 2}
margin-right: -#{$gridPad / 2}
.g-col
const isMobile = {
android: () => navigator.userAgent.match(/Android/i),
blackberry: () => navigator.userAgent.match(/BlackBerry/i),
ios: () => navigator.userAgent.match(/iPhone|iPad|iPod/i),
opera: () => navigator.userAgent.match(/Opera Mini/i),
windows: () => navigator.userAgent.match(/IEMobile/i),
any: () => (
isMobile.android() ||
isMobile.blackberry() ||
isMobile.ios() ||
git reset --soft HEAD^
window.onkeydown = function(e) {
if (e.keyCode == 27) {
var focused = document.activeElement;
if (focused.tagName == 'INPUT' || focused.tagName == 'TEXTAREA') {
focused['blur']()
}
}
}
;(function() {
const baseToggle = (target, fn = () => {}) => {
let button = target.closest('[data-tggl-button]')
if (!button) return
let hideClass = button.getAttribute('data-tggl-button') || 'hide'
let parent = button.closest('[data-tggl-parent]')
if (!parent) return
let items = parent.querySelectorAll('[data-tggl-item]')
;(function() {
const elems = document.querySelectorAll('[data-tooltip]')
const tip = document.createElement('div')
tip.classList.add('tooltip')
document.body.append(tip)
const mouseMove = (e) => {
let { clientX, clientY } = e
let current
elems.forEach(elem => {
const http = require('http');
const httpProxy = require('http-proxy');
const options = {
changeOrigin: true,
protocol: 'https',
target: 'https://yobit.net',
host: 'yobit.net',
};
@StrongerMyself
StrongerMyself / line-chart.js
Created August 20, 2019 14:08
d3-v5-line-chart
import * as d3 from 'd3'
import c from '../styles.css'
const svg = d3.select('svg')
const margin = { top: 20, right: 20, bottom: 110, left: 40 }
const width = +svg.attr('width') - margin.left - margin.right
const height = +svg.attr('height') - margin.top - margin.bottom
const margin2 = { top: 430, right: 20, bottom: 30, left: 40 }
const height2 = +svg.attr('height') - margin2.top - margin2.bottom
@StrongerMyself
StrongerMyself / schemaRelBySpec.ts
Last active July 5, 2019 07:08
Graphql parser AST query for optimal ORM query. Get relation map by spec relation list.
import { GraphQLResolveInfo } from 'graphql'
const unique = (arr = []) => {
let obj = {}
for (let i = 0;i < arr.length;i++) {
let str = arr[i]
if (!!str) obj[str] = true
}
return Object.keys(obj)
}