This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as zlib from 'minizlib'; | |
new zlib.Gzip({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
echo "Checking zsh installed by Homebrew ..." | |
if version="$(brew list --versions zsh)"; then | |
echo "Found: $version" | |
else | |
echo "Could not find zsh installed by Homebrew" | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
if [[ "$MACKEREL_AGENT_PLUGIN_META" == 1 ]]; then | |
cat <<EOF | |
# mackerel-agent-plugin | |
{ | |
"graphs": { | |
"filecount.#": { | |
"label": "File count", | |
"unit": "integer", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
cmdname="${BASH_SOURCE[0]##*/}" | |
temp=$(mktemp -t "$cmdname") | |
trap 'unlink "$temp"' EXIT | |
go test -cover -coverprofile="$temp" "$@" | |
go tool cover -html="$temp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"sync" | |
"sync/atomic" | |
"time" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"strings" | |
) | |
func main() {} | |
func JoinPlus(xs []string, sep string) string { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
git status >/dev/null || exit 1 | |
err= | |
error_message() { | |
printf '%s\n\n' "$*" >&2 | |
err=1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euxo pipefail | |
git clone https://github.com/vim/vim.git /tmp/vim | |
cd /tmp/vim | |
BACKUP_DIR=/tmp/vim-backup | |
mkdir -p "$BACKUP_DIR" | |
while true; do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Xs struct { | |
xs []*X | |
idx int | |
} | |
func (xs *Xs) prepend(x *X) *Xs { | |
if xs.idx == 0 { | |
ys := make([]*X, (len(xs.xs)+1)*2) | |
xs.idx = len(xs.xs) + 1 | |
copy(ys[xs.idx+1:], xs.xs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const opt = (s) => `${group(s)}?`; | |
const chars = (s) => `[${s}]`; | |
const group = (s) => /^\[[^\]]+\][*+]$/.test(s) ? s : `(?:${s})`; | |
const or = (...xs) => xs.join('|'); | |
const many = (s) => group(`${s}*`); | |
const many1 = (s) => group(`${s}+`); | |
const integer = or('0', `[1-9]${many('[0-9]')}`); | |
const name = (n, s) => `(?<${n}>${s})`; |
NewerOlder