Skip to content

Instantly share code, notes, and snippets.

View wulucxy's full-sized avatar

qingtong wulucxy

View GitHub Profile
@wulucxy
wulucxy / 批量分组
Last active May 3, 2022 08:01
#javascript
const largeRecipientList = new Array(2000).fill().map((_, idx) => `customer${idx}@nowhere.com`)
// largeRecipientList is an array of email addresses
const recipientLimit = 100
const batches = largeRecipientList.reduce((batches, r) => {
const lastBatch = batches[batches.length - 1]
if(lastBatch.length < recipientLimit)
lastBatch.push(r)
else
batches.push([r])
return batches
const slope = getSlope(firstPoint, secondPoint);
const perpSlope = getPerpSlope(slope);
let perpPointOne = findPointOnLine(firstPoint, perpSlope, 10);
let perpPointTwo = findPointOnLine(firstPoint, perpSlope, -10);
ctx.moveTo(perpPointOne.x, perpPointOne.y);
ctx.lineTo(perpPointTwo.x, perpPointTwo.y);
perpPointOne = findPointOnLine(secondPoint, perpSlope, 10);
@wulucxy
wulucxy / tags literal
Created October 6, 2021 15:37
javascript
function tag(static, ...tags) {
return static.reduce((all, part, index) => {
return all + tags[index - 1] + part
})
}
var name = 'test'
var emotion = 'thrilled'
@wulucxy
wulucxy / dbc
Last active April 16, 2021 02:26
#dbc #契约式设计
// 示例来源:https://qiita.com/Jxck_/items/defd80843a4beb5fcfc8
# 定义公共的契约调用规则
function contract(rule) {
return function(target, name, descriptor) {
let rule = new Rule(target, name, descriptor);
let original = descriptor.value;
descriptor.value = function() {
if (rule.before) rule.before.apply(rule, arguments);
if (rule.invaliant) rule.invaliant(this);
module.exports = {
singleQuote: true,
semi: false
}
usually use the -p flag with a git checkout from the other branch which I find easier and more granular than most other methods I have come across.
In principle:
git checkout <other_branch_name> <files/to/grab in/list/separated/by/spaces> -p
example:
git checkout mybranch config/important.yml app/models/important.rb -p
You then get a dialog asking you which changes you want in "blobs" this pretty much works out to every chunk of continuous code change which you can then signal y (Yes) n (No) etc for each chunk of code.
1. 发生了什么?what
2. 什么时候发生的?when
3. 发生在哪个页面? where
4. 影响哪些用户?who
5. 为什么会发生问题?why
6. 怎么解决?how
# Docker Commands, Help & Tips
### Show commands & management commands
```
$ docker
```
### Docker version info
@wulucxy
wulucxy / appCtl
Created February 8, 2020 04:06
#shell
#!/bin/sh
DIR=`pwd`
NODE=`which node`
# get action
ACTION=$1
# help
usage() {
echo "Usage: ./appctl.sh {start|stop|restart}"
exit 1;
@wulucxy
wulucxy / 基准测试
Created February 8, 2020 03:38
#benchmark
const { performance } = require('perf_hooks');
var mapLoop = function(arr, callback){
return arr.map(callback)
}
var forLoop = function(arr, callback){
for(let i=0; i < arr.length; i++){
callback(arr[i], i, arr)
}