Skip to content

Instantly share code, notes, and snippets.

View hufeng's full-sized avatar
🎯
Focusing coding

胡锋 hufeng

🎯
Focusing coding
View GitHub Profile
@hufeng
hufeng / fastbrew.sh
Last active April 26, 2023 06:19
build a fast homebrew
#!/usr/bin/env bash
echo "Let's configure a fast homebrew environment for you. 🚀"
# set homebrew environment variables
export HOMEBREW_INSTALL_FROM_API=1
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
@hufeng
hufeng / command.rs
Created November 16, 2020 12:33
rust - command -demo
use std::env::args;
use std::process::Command;
fn main() {
// get command args
let arg: Vec<String> = args().collect();
// get compile filename
let filename = &arg[1];
println!("{}", filename);
// compile
```typescript
export const tpl = (strs: TemplateStringsArray, ...value: Array<Function>) => {
return (props: Object) => {
const merge = [] as Array<any>;
const params = value.map(v => v(props));
const pLen = params.length;
const sLen = strs.length;
for (let i = 0; i < sLen; i++) {
merge.push(strs[i]);
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
const declare = require('@babel/helper-plugin-utils').declare;
@hufeng
hufeng / nanjing.js
Created December 20, 2018 03:54
随机生成南京范围经纬度
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
//南京经纬度范围
//经度范围:118.35-119.233
//维度范围:31.236-32.611
/**
* 南京经度随机
@hufeng
hufeng / output
Created October 21, 2018 13:32 — forked from andrzejsliwa/output
Erlang tracing (nested and flat)
~/erlang_learning $ erl
Erlang R15B03 (erts-5.9.3.1) [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false] [dtrace]
Eshell V5.9.3.1 (abort with ^G)
(erlang_learning@127.0.0.1)1> trace(recursive).
ok
(erlang_learning@127.0.0.1)2> recursive:fac(10).
call: <0.42.0> recursive:fac(10), level: 0
call: <0.42.0> recursive:fac(9), level: 1
call: <0.42.0> recursive:fac(8), level: 2
@hufeng
hufeng / rollup.config.js
Created September 10, 2018 09:25 — forked from EmielM/rollup.config.js
react-native rollup bundle attempt
import fs from 'fs';
import path from 'path';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';
import typescript from 'rollup-plugin-typescript';
import replace from 'rollup-plugin-replace';
function findVersion(file, extensions) {
for (let e of extensions) {
@hufeng
hufeng / introrx.md
Created December 5, 2017 04:51 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
结合iflux的架构特点怎么才能设计好一个真正好用的校验库,确实有点考验人。
之前的iflux解决一部分校验问题,但是也暴露了一些问题。
解决问题的问题:
1. 以store为中心,校验声明式,配置规则和message,错误信息自动绑定到store
2. 异步直接走正常的逻辑,不直接支持
但是根据我们的业务场景也暴露了一些问题,
/**
* React支持es6的class语法,但是在class中并没有一个很好的概念来对应mixin
*
* 我们也要考虑弱化mixin
*
* 那怎么做呢?使用高阶函数来解决这个问题
*
* 但是有个难点还会是需要再想想,怎么把store的更新和react的render结合起来,做到透明
* 比如
*/