Go concurrency patterns — Rob Pike talks and advanced techniques

Advanced Go Concurrency Patterns

Go’s concurrency patterns are worth collecting in one place. Mostly notes from official talks: definitions, idioms, and a few advanced techniques.

Sources:
Advanced Go Concurrency Patterns

Go Concurrency Patterns

Concurrency Is Not Parallelism

Read More

Go memory model — happens-before, channels, and sync primitives

Go Memory Model

Notes on how the Go memory model orders reads and writes.

Memory model

Happens before

The model defines when reads and writes are ordered. Without a defined order, you cannot rely on result ordering.

For a write w to V to be observed by a read r:

  1. r does not happen before w, and
  2. no other write w' happens after w and before r.

For w to be the only value r can see (no concurrent conflicting writes):

  1. w happens before r, and
  2. every other write to V happens after r or before w.

Read More

MySQL — comparing dotted version strings

mysql中比较版本字符串

Use case: pick the newest row whose version is still less than or equal to the current app version.

String compare bites you:

1
select "5.1.3" > "5.1.24";

MySQL returns 1 (true) because it compares lexicographically — at the patch segment, 3 is greater than 2.

Stack Overflow has a solid thread on this:
compare version numbers in MySQL

Read More

跨域登录态共享

登录态共享

登录态共享?什么鬼,不知道的就可以不用看啦,需要时再说,说不定到时也用不到,笑脸~~

场景

解决多个子系统中共用模块(比方说工单系统)可以共享子系统的登录态
为简化问题,设定场景:
登录系统A,点工单操作跳转系统B,并且无需登录(至于系统登录何时失效暂不考虑)

还有:别问我为什么不用单点登录(SSO),那个,不想说,笑脸~~

先别废话,直接代码上

Read More

php踩坑记录

函数

mb_strlen 不生效

有一天发现本地mb_strlen('哈')本地为1,服务器为3,猜测应该是配置问题
看文档关键在于mb_internal_encoding

1
2
3
4
5
6
7
8
9
mixed mb_strlen ( string $str [, string $encoding = mb_internal_encoding() ] )

继续搜 mbstring.internal_encoding (定义内部字符的默认编码)

Warning: This feature has been DEPRECATED as of PHP 5.6.0. Relying on this feature is highly discouraged.。

PHP 5.6 及更新版的用户应该将此选项留空,并设置 default_charset 作为代替。

好吧,服务器 default_charset 没设置,然后默认用 ISO-8859-1

Read More