Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing on work

見える biezhi

🎯
Focusing on work
View GitHub Profile
@onlyeat3
onlyeat3 / A.java
Created Aug 16, 2017
获取lambda表达式的元信息
View A.java
@FunctionalInterface
public interface A<T, R> extends Function<T, R>, Serializable {
}
@biezhi
biezhi / git_cmd.md
Last active May 7, 2017
git常用命令
View git_cmd.md

把本地的dev分支强制(-f)推送到远程master

git push origin dev:master -f

删除远程分支

View code_review_checklist.txt
- General
[ ] The code works
[ ] The code is easy to understand
[ ] Follows coding conventions
[ ] Names are simple and if possible short
[ ] Names are spelt correctly
[ ] Names contain units where applicable
[ ] Enums are used instead of int constants where applicable
[ ] There are no usages of 'magic numbers'
[ ] All variables are in the smallest scope possible
@tonymtz
tonymtz / gist:d75101d9bdf764c890ef
Last active Nov 22, 2020
Uninstall nodejs from OSX Yosemite
View gist:d75101d9bdf764c890ef
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active Nov 19, 2020
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew
View fix-homebrew-npm.md

READ THIS Very Important Update

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@hgfischer
hgfischer / benchmark+go+nginx.md
Last active Nov 15, 2020
Benchmarking Nginx with Go
View benchmark+go+nginx.md

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
@ekho
ekho / pg_random_int_array.sql
Last active Jul 14, 2020
Postgresql function for generating random integer array
View pg_random_int_array.sql
CREATE OR REPLACE FUNCTION random_int_array(dim integer, min integer, max integer) RETURNS integer[] AS $BODY$
begin
return (select array_agg(round(random() * (max - min)) + min) from generate_series (0, dim));
end
$BODY$ LANGUAGE plpgsql;
-- usage example
select random_int_array(15, 6, 40);
-- return example
@paulmillr
paulmillr / active.md
Last active Nov 20, 2020
Most active GitHub users (by contributions). http://twitter.com/paulmillr
View active.md

Most active GitHub users (git.io/top)

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Tue, 06 Dec 2016 17:06:46 GMT till Wed, 06 Dec 2017 17:06:46 GMT.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
  .filter(user => user.followers > 1000)
View AbstractLocalCache.java
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
/**
* 一种本地缓存的无锁实现思路
* 适用场景:预先知道的需要缓存的一批数据,比如卖家品牌授权,馆信息,达人信息
* 数据更新不太频繁,定时更新或者更新由自己手动控制
*/
public abstract class AbstractLocalCache<K, V> {
You can’t perform that action at this time.