Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

shane shanezhiu

🎯
Focusing
View GitHub Profile
@shanezhiu
shanezhiu / HTTP Cookie header parser
Created Dec 5, 2017 — forked from pokeb/HTTP Cookie header parser
Quick and dirty HTTP cookie header parser in PHP
View HTTP Cookie header parser
View 并发并行, 异步同步, 阻塞非阻塞.md

后台开发中总是在”并行,并发,异步,同步,阻塞,非阻塞”之间转,自己经常就被转得晕头转向。由于对基于经验的答复不满意,因此决定将我这几个月对这些概念千丝万缕的思绪整理出来。

【并发与并行】

  • 并发:    仅仅包含宏观上的意义,即多个任务同时被处理;而微观上可能仅仅是一个cpu分时间片去完成了多个任务,这个时候多个任务是被顺序处理的。

  • 并行:    则更加严格,在宏观和微观上都应该具有多个任务同时被处理的含义,这个意义上多个任务被并行处理的,单cpu永远不可能并行。

  • 并行和并发是站在两个不同角度上理解产生的概念。

  • 并行一定是并发,并发却不一定是并行。

@shanezhiu
shanezhiu / uuids.php
Last active Jan 20, 2019
生成UUIDS
View uuids.php
<?php
// 第一种方法
function UUIDS()
{
if (function_exists('com_create_guid'))
{
$uuid = com_create_guid();
return substr($uuid, 1, -1);
}
@shanezhiu
shanezhiu / slope_vs_starting.md
Created Feb 15, 2020 — forked from gtallen1187/slope_vs_starting.md
A little bit of slope makes up for a lot of y-intercept
View slope_vs_starting.md

"A little bit of slope makes up for a lot of y-intercept"

01/13/2012. From a lecture by Professor John Ousterhout at Stanford, class CS140

Here's today's thought for the weekend. A little bit of slope makes up for a lot of Y-intercept.

[Laughter]

@shanezhiu
shanezhiu / quote.txt
Created Apr 21, 2020 — forked from OnesimusUnbound/quote.txt
Programming Quotes
View quote.txt
[T]he difference between a bad programmer and a
good one is whether he considers his code or his
data structures more important. Bad programmers
worry about the code. Good programmers worry about
data structures and their relationships.
-- Linus Torvalds
~~~
Clarity and brevity sometimes are at odds.
When they are, I choose clarity.
-- Jacob Kaplan-Moss
@shanezhiu
shanezhiu / exceptions-tree.php
Created Sep 29, 2020 — forked from mlocati/exceptions-tree.php
Throwable and Exceptions tree
View exceptions-tree.php
<?php
if (!function_exists('interface_exists')) {
die('PHP version too old');
}
$throwables = listThrowableClasses();
$throwablesPerParent = splitInParents($throwables);
printTree($throwablesPerParent);
if (count($throwablesPerParent) !== 0) {
die('ERROR!!!');
@shanezhiu
shanezhiu / tmux-cheatsheet.markdown
Created Nov 16, 2020 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表 & 简明教程
View tmux-cheatsheet.markdown

注意:本文内容适用于 Tmux 2.3 及以上的版本,但是绝大部分的特性低版本也都适用,鼠标支持、VI 模式、插件管理在低版本可能会与本文不兼容。

Tmux 快捷键 & 速查表 & 简明教程

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

@shanezhiu
shanezhiu / semantic-pedantic.md
Created Dec 5, 2020 — forked from jashkenas/semantic-pedantic.md
Why Semantic Versioning Isn't
View semantic-pedantic.md

Spurred by recent events (https://news.ycombinator.com/item?id=8244700), this is a quick set of jotted-down thoughts about the state of "Semantic" Versioning, and why we should be fighting the good fight against it.

For a long time in the history of software, version numbers indicated the relative progress and change in a given piece of software. A major release (1.x.x) was major, a minor release (x.1.x) was minor, and a patch release was just a small patch. You could evaluate a given piece of software by name + version, and get a feeling for how far away version 2.0.1 was from version 2.8.0.

But Semantic Versioning (henceforth, SemVer), as specified at http://semver.org/, changes this to prioritize a mechanistic understanding of a codebase over a human one. Any "breaking" change to the software must be accompanied with a new major version number. It's alright for robots, but bad for us.

SemVer tries to compress a huge amount of information — the nature of the change, the percentage of users that wil

@shanezhiu
shanezhiu / git-commit-template.md
Created Dec 13, 2020 — forked from lisawolderiksen/git-commit-template.md
Use a Git commit message template to write better commit messages
View git-commit-template.md

Using Git Commit Message Templates to Write Better Commit Messages

One of my colleagues shared an article on writing (good) Git commit messages today: How to Write a Git Commit Message. This excellent article explains why good Git commit messages are important, and explains what constitutes a good commit message. I wholeheartedly agree with what @cbeams writes in his article. (Have you read it yet? If not, go read it now. I'll wait.) It's sensible stuff. So I decided to start following the