Skip to content

Instantly share code, notes, and snippets.

apiVersion: v1
kind: Endpoints
metadata:
name: cloudtower-perf
namespace: prometheus
subsets:
- addresses:
- ip: 1.2.3.5
nodeName: tower.smartx.com
- ip: 1.2.3.6
// ==UserScript==
// @name i18n editor
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @include /?i18n-editor/
// @grant none
// @require https://cdn.jsdelivr.net/npm/jszip@3.6.0/dist/jszip.min.js
// @require https://raw.githubusercontent.com/eligrey/FileSaver.js/master/dist/FileSaver.js
@Yuyz0112
Yuyz0112 / machine.js
Last active March 7, 2020 07:14
Generated by XState Viz: https://xstate.js.org/viz
function lastOf(arr) {
return arr[arr.length - 1];
}
function getCurrentStatement(ast) {
if (ast.body.length === 0) {
throw new Error("No statement found");
}
return lastOf(ast.body);
}
function getCurrentFrom(ast) {
@Yuyz0112
Yuyz0112 / hooks.js
Created January 17, 2019 09:53
rrweb + cypress
const sessionId = Cypress.env('sessionId');
const appFrame = window.parent.document.querySelectorAll('iframe')[0];
Cypress.on('window:load', () => {
appFrame.contentWindow.eval(`
const request = new XMLHttpRequest();
request.open('GET', 'https://cdn.jsdelivr.net/npm/rrweb@0.7.4/dist/rrweb.min.js', false);
request.send('');
const script = document.createElement('script');
script.type = 'text/javascript';
>>> callback here
added element type node <body>​…​</body>​
[found with selector "div p"]
added element type node <div>​…​</div>​
[found with selector "div p"]
added element type node <p>​</p>​
added element type node <script>​</script>​
>>> callback here
added element type node <a>​</a>​
@Yuyz0112
Yuyz0112 / async.js
Created September 11, 2018 02:32
show the differences between callback, promise and async-await
function longTask(int, callback) {
if (int < 0) {
callback(new Error('less than 0'));
} else {
callback(null, 'done');
}
}
// callback
longTask(1, (err, result) => {});
docker run -i \
--rm \
--name node-test \
-v "$PWD":/code \
-w /code node:latest \
/bin/bash -c "npm i --silent --progress=false --registry=https://registry.npm.taobao.org && npm run test"
const lodash = require('lodash');
const toArray = require('../utils/toArray');
const { CONSTANTS: C } = require('../globals');
const NAME_ALIAS = '名称';
function hint(options) {
const rules = ['Check your selector value.'];
if (!options.debug) {
rules.push('Add { debug: true } to your options to get more info.');
const fs = require('fs');
const path = require('path');
const argv = require('minimist')(process.argv.slice(2));
const lodash = require('lodash');
const setUrl = require('./utils/setUrl');
const flattenArgs = args => {
let argsArr;
if (!args) {
argsArr = [];
docker rm -f $(docker ps -a -q | awk '{if($1!~/92033adc934d/) print}')
docker network rm $(docker network ls | awk '{if($2~/-network/) print $2}')