This file contains hidden or 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
# https://goenning.net/2017/01/25/adding-custom-data-go-binaries-compile-time/ | |
# https://golang.org/cmd/link/ | |
GIT_HASH=$(shell git rev-parse HEAD) | |
FLAGS=-ldflags "-X main.version=$(GIT_HASH)" | |
build: | |
@go build $(FLAGS) | |
run: |
This file contains hidden or 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
// based on an example at https://www.voip-info.org/asterisk-manager-example-php/ | |
<?php | |
/** | |
* Connect to Asterisk Manager Interface (AMI). | |
* | |
* Setup an AMI user in /etc/asterisk/manager.conf | |
*/ | |
class AsteriskManager { |
This file contains hidden or 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
# all lines that don't start with [ are combined with the previous line | |
[/var/log/some.log] | |
type: some-type | |
multiline_regex_before = ^[^[]].* |
This file contains hidden or 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
# test.conf | |
input { | |
file { | |
path => "/tmp/some-file.log" | |
start_position => beginning | |
sincedb_path => "/dev/null" | |
type => "some-type" | |
} | |
} |
This file contains hidden or 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
-- copy query to CSV | |
\copy (select * from some_table) TO '/tmp/query-xxx.csv' CSV HEADER | |
-- dump table to SQL inserts | |
pg_dump -h <host> -U <user> --schema=<schema> --table=<schema.table> --data-only --column-inserts <database> > output.sql |
This file contains hidden or 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
# find running queries | |
SELECT * FROM pg_stat_activity; | |
# cancel the query | |
SELECT pg_cancel_backend(<pid>) | |
# if it won't die: | |
SELECT pg_terminate_backend(<pid>) |
This file contains hidden or 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
# https://www.ssh.com/ssh/agent | |
# https://developer.github.com/v3/guides/using-ssh-agent-forwarding/#setting-up-ssh-agent-forwarding | |
# on the remote host | |
# /etc/ssh/sshd_config must have 'AllowAgentForwarding yes' | |
# on your local machine | |
# /etc/ssh/ssh_config must have 'ForwardAgent yes' | |
cat >> ~/.ssh/config <<EOF |
This file contains hidden or 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
# remove each family of keys that match the specified pattern from the Asterisk database | |
# 4 digits | |
FAMILY_PATTERN="[0-9][0-9][0-9][0-9]" | |
for FAMILY in `asterisk -rx "database show" | cut -d' ' -f1 | egrep -a "/${FAMILY_PATTERN}/" | cut -d'/' -f2 | uniq`; do | |
asterisk -rx "database deltree ${FAMILY}"; | |
done |
This file contains hidden or 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
# format the output of stat and show the active user (as a string) | |
stat -f "%Su" /dev/console |
This file contains hidden or 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
find /some/path -type f -exec grep 'find this text' -l {} \; -exec sed -i '' 's/find this text/replace with this text/g' {} \; |