Skip to content

Instantly share code, notes, and snippets.

@Yuyz0112
Yuyz0112 / playground.rs
Created June 27, 2017 08:05 — forked from anonymous/playground.rs
Shared via Rust Playground
// This is a bigger error exercise than the previous ones!
// You can do it!
//
// Edit the `read_and_validate` function so that it compiles and
// passes the tests... so many things could go wrong!
//
// - Reading from stdin could produce an io::Error
// - Parsing the input could produce a num::ParseIntError
// - Validating the input could produce a CreationError (defined below)
//
@Yuyz0112
Yuyz0112 / generate.js
Created January 8, 2018 06:53
generate table
// Usage: node generate.js 10x300
const fs = require('fs');
const path = require('path');
const placeholder = (rowIndex, colIndex) => Math.random().toString(36).substring((rowIndex + colIndex) % 7);
const tpl = (col, row) => {
const colArr = new Array(col).fill();
const rowArr = new Array(row).fill();
return `
@Yuyz0112
Yuyz0112 / tslint.json
Created June 26, 2018 05:46
my tslint config
{
"extends": [
"tslint-react"
],
"rules": {
"align": [
true,
"parameters",
"arguments",
"statements"
@Yuyz0112
Yuyz0112 / rmi.sh
Created June 26, 2018 05:47
remove all <none> images
docker rmi $(docker images -qa -f "dangling=true")
docker rm -f $(docker ps -a -q | awk '{if($1!~/92033adc934d/) print}')
docker network rm $(docker network ls | awk '{if($2~/-network/) print $2}')
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 = [];
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.');
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"
@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) => {});
>>> 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>​