Skip to content

Instantly share code, notes, and snippets.

@mcfog
mcfog / Ability Model.xmind
Last active March 26, 2023 14:55
软件技术人员能力模型
https://press.one/p/address/v?s=0d80826215b9101cfb46e551202cb9db44c6ae6c608020ad301cd46d3f8eb0dde15718edd6f46e768dec4617dad23bc203f0d791a3369e08fa6b4fc0ef2244371&h=973c23a77c5d9bf694f718f3afd579fa5e97a411cd71e4d6dadf8299133a7b6f&a=ee8917ea16dc93624aa7d604e7a328db246c787d&f=P1&v=2
@mcfog
mcfog / paging.js
Created March 13, 2017 05:30
answer for promise paging exercise
//ref https://www.v2ex.com/t/346533#r_4122841
const api = (num) => {
const allNum = 3 + parseInt(7 * Math.random());//你不知到总页数的
const quality = 0.15;//接口质量指数
return new Promise((resolve, reject) => {
setTimeout(_=>{//超时逻辑
reject({
code: 'CODE_TIMEOUT',
msg: 'timeout'
@mcfog
mcfog / gitabbr.fish
Last active November 29, 2019 07:43
abbr g git
abbr ga 'git add'
abbr gaa 'git add --all'
abbr gb 'git branch'
abbr gbda git\ branch\ --merged\ \|\ command\ grep\ -vE\ \"\^\(\\\*\|\\s\*master\\s\*\\\$\)\"\ \|\ command\ xargs\ -n\ 1\ git\ branch\ -d
abbr gbnm 'git branch --no-merged'
abbr gbr 'git branch --remote'
abbr gc 'git commit -v'
abbr gc! 'git commit -v --amend'
abbr gca 'git commit -v -a'
#!/usr/bin/env awk -f
/success/ { print "\033[92m" $0 "\033[0m"; next; }
/error/ { print "\033[91m" $0 "\033[0m"; next; }
/./ { print $0 }
{
init: function(elevators, floors) {
elevators.forEach(initElevator);
floors.forEach(initFloor);
var topFloor = floors.length - 1;
function initElevator(elevator) {
elevator.on("idle", function() {
});
function defer() {
var resolve, reject;
var promise = new Promise(function(realResolve, realReject) {
resolve = realResolve;
reject = realReject;
});
return {
resolve: resolve,
reject: reject,
<?php
class Paginator implements \IteratorAggregate
{
const TPL_WRAPPER = 'wrapper';
const TPL_NUM = 'num';
const TPL_NUM_CURRENT = 'currentNum';
const TPL_TAG = 'tag';
const TPL_NEXT = 'next';
const TPL_PREV = 'prev';
@mcfog
mcfog / mixins.less
Created November 3, 2014 11:17
less垂直居中
.vertical-align-middle(@child: ~".content") {
&:before {
display: inline-block;
content: '';
height: 100%;
vertical-align: middle;
margin-right: -0.25em;
}
@{child} {
display: inline-block;
@mcfog
mcfog / NotSimpleXMLElement.php
Created August 18, 2014 12:35
带array正反转换的XMLElement
<?php
class NotSimpleXMLElement extends SimpleXMLElement
{
const ATTR = 'attr';
const NAME = 'name';
const CHILDREN = 'children';