Skip to content

Instantly share code, notes, and snippets.

View c9s's full-sized avatar

c9s

  • Taipei, Taiwan
  • 21:49 (UTC +08:00)
  • X @c9s
View GitHub Profile
@paulmillr
paulmillr / active.md
Last active April 14, 2024 16:20
Most active GitHub users (by contributions). http://twitter.com/paulmillr

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 Wed, 21 Sep 2022 till Thu, 21 Sep 2023.

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)
@nikic
nikic / objects_arrays.md
Last active April 12, 2024 17:05
Post explaining why objects often use less memory than arrays (in PHP)

Why objects (usually) use less memory than arrays in PHP

This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)

The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array part of it away. So how does that work?

The key here is that objects usually have a predefined set of keys, whereas arrays don't:

@pixelhandler
pixelhandler / pre-push.sh
Last active April 8, 2024 01:04
Git pre-push hook to prevent force pushing master branch
#!/bin/sh
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
# 1. Copy the file into your repo at `.git/hooks/pre-push`
# 2. Set executable permissions, run `chmod +x .git/hooks/pre-push`

開源之道

Original transcript: http://allisonrandal.com/2012/04/15/open-source-enlightenment/

這幾年來,我慢慢覺得,我們參與開源社群,就像是在一條道路上並肩而行:這不僅讓我們成為更好的程式設計者,也讓我們通過與人合作,而成為更好的人。

您可以將它想成一條修行之道,讓身而為人的我們能夠不斷成長。接下來,我想談談我對開源世界的個人觀點,希望能與您分享。

首先,人是一切開源專案的核心。程式碼是很重要,但最核心的永遠是人。

@kingkool68
kingkool68 / changelog.sh
Last active September 17, 2023 21:08
Bash script to generate a markdown change log of GitHub pull requests between tagged releases
#!/bin/bash
# Generate a Markdown change log of pull requests from commits between two tags
# Author: Russell Heimlich
# URL: https://gist.github.com/kingkool68/09a201a35c83e43af08fcbacee5c315a
# HOW TO USE
# Copy this script to a directory under Git version control
# Make the script executable i.e. chmod +x changelog.sh
# Run it! ./changelog.sh
# Check CHANGELOG.md to see your results
@erning
erning / mms.md
Created November 28, 2011 09:36
多关键字的文本精确匹配搜索

多关键字的文本精确匹配搜索 (mss - Multi-String Search)

基本的要求是对给定的一个文本块进行关键字匹配,进行匹配的关键字是多个,而且可能非常多(成千上万),然后输出各个匹配到的关键字的位置。这可用用作关键字的高亮显示,当然也可用进行敏感词过滤。

参考linux命令行fgrep

功能

输入一段文本,输出匹配到的关键字在输入文本中的位置。

例如,关键词列表:

@c9s
c9s / .env.local
Last active March 6, 2023 13:37
BBGO 之 MAX 交易所網格設定指南
# API Key 可以在以下頁面建立:
# https://max.maicoin.com/api_tokens/new
#
MAX_API_KEY=
MAX_API_SECRET=
@audreyt
audreyt / posa.mkdn
Last active November 28, 2022 21:24
EtherCalc.tw

從 SocialCalc 到 EtherCalc

先前在《開源應用程式架構》 一書中,我介紹了 SocialCalc 這個在瀏覽器中運行的試算表編輯器,以取代伺服器為中心的 WikiCalc 架構。SocialCalc 在瀏覽器中執行所有的運算,只有在載入和儲存試算表時才會使用伺服器。

追求效能是 Socialtext 團隊在 2006 年時設計 SocialCalc 的主要目的。重點在於:在 JavaScript 環境下執行客戶端運算,儘管在當年的速度僅有伺服器端 Perl 運算的十分之一,但仍然勝過 AJAX 來回傳輸資料造成的網路延遲:


WikiCalc 與 SocialCalc 架構比較

******
@c9s
c9s / SharkLong.go
Created September 30, 2022 10:02 — forked from austin362667/SharkLong.go
Harmonic Pattern Strategy: Shark Long
func (s Harmonic) SharkLong(highs, lows *types.Queue, p float64) float64 {
score := 0.
for x := 5; x < 300; x++ {
X := lows.Index(x)
for a := 4; a < x; a++ {
if highs.Index(a-1) < highs.Index(a) && highs.Index(a) > highs.Index(a+1) {
A := highs.Index(a)
XA := math.Abs(X - A)
hB := A - 0.382*XA
lB := A - 0.618*XA
@austin362667
austin362667 / SharkLong.go
Created September 28, 2022 04:32
Harmonic Pattern Strategy: Shark Long
func (s Harmonic) SharkLong(highs, lows *types.Queue, p float64) float64 {
score := 0.
for x := 5; x < 300; x++ {
X := lows.Index(x)
for a := 4; a < x; a++ {
if highs.Index(a-1) < highs.Index(a) && highs.Index(a) > highs.Index(a+1) {
A := highs.Index(a)
XA := math.Abs(X - A)
hB := A - 0.382*XA
lB := A - 0.618*XA