Skip to content

Instantly share code, notes, and snippets.

View c9s's full-sized avatar

c9s

  • Taipei, Taiwan
  • 00:28 (UTC +08:00)
  • X @c9s
View GitHub Profile
@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
@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=
@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
@c9s
c9s / GoogleSpreadSheetInviteToSlack.js
Last active August 29, 2015 14:20
InviteToSlack from Google SpreadSheet
/*
The original script: https://github.com/dherbst/slack-invite-script/blob/master/code.js
*/
/*
Get channels from: curl 'https://golang.slack.com/api/channels.list?token={token}' | json_pp
*/
function getInviteChannels() {
return ['C123123123'];
@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`
@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:

09:07 -!- Irssi: Join to #webconf.tw was synced in 133 secs
09:08 < MouseMs> 大家早安
09:08 < locy69> 早安
09:09 < StarNight> 早安!~
09:10 < MouseMs> [SITCON] 答案填寫單將於9:30開放submit答案 PS:同時也會開放第五題唷 今天的題目都比較簡單 歡迎大家挑戰:)
09:13 < bency> 早安
09:13 < BeataLin> 早安!
09:21 < SITCON> 今天也有3題等著大家挑戰唷^^
09:23 < kikiqqp_> 今天R0的有線網路有點怪怪的
09:25 < ChAndrew> Good Morning!!
@audreyt
audreyt / rot.ls
Created December 7, 2012 15:26
ROT encode/decode
#!/usr/bin/env lsc
# 使用前請先 curl -O http://cpansearch.perl.org/src/DANKOGAI/Unicode-Unihan-0.04/srctxt/Mandarin.txt
require! fs
c2p = {}; p2c = {}
for l in "#{fs.read-file-sync 'Mandarin.txt'}" / /\n/
[code, pin] = l / /\s+/
continue unless code is /^....$/ # BMP
@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 架構比較

******