Skip to content

Instantly share code, notes, and snippets.

@jtbonhomme
jtbonhomme / clickhouse-cheatsheet.md
Created May 6, 2021 07:45 — forked from shved/clickhouse-cheatsheet.md
ClickHouse client cheatsheet

Cheatseet assumes you're just playing around on a not clustered ClickHouse server.

docker run -it yandex/clickhouse-client --host your.toy.server.host --port 9500 --user default --password password123 --multiline

SHOW DATABASES

SHOW TABLES (in current database)

SHOW DICTIONARIES (in current database)

@jtbonhomme
jtbonhomme / pre-push
Created March 25, 2021 19:15
This git hook prevents to push on remote any branch which matches with a regex (`DO-NOT-PUSH.*`)
# Save this into .git/hooks/pre-push, then chmod +x .git/hooks/pre-push
if [[ `grep 'DO-NOT-PUSH.*'` ]]; then
echo "You really don't want to push this branch. Aborting."
exit 1
fi
@jtbonhomme
jtbonhomme / Install_tmux
Created March 4, 2021 18:20 — forked from simme/Install_tmux
Install and configure tmux on Mac OS X
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@jtbonhomme
jtbonhomme / README.md
Created February 28, 2020 07:24 — forked from ryu1kn/README.md
Getting GCP access token from a service account key JSON file

Getting GCP access token from a service account key

Use your service account's key JSON file to get an access token to call Google APIs.

Good for seeing how things work, including the creation of JWT token.

To create a JWT token, you can replace create-jwt-token.sh script with tools like step.

If you just want to get an access token for a service account,

@jtbonhomme
jtbonhomme / gist:86801e198cee5c7a661a9890d5bb3586
Last active December 14, 2019 15:39 — forked from cablespaghetti/gist:54de0ae93449e4698f0206a0e85514be
Terraform for Autoscaling Group with spot instances
#
# Configuration for Autoscaling group.
#
resource "aws_launch_template" "eks-cluster-worker-nodes" {
iam_instance_profile = { name = "${aws_iam_instance_profile.eks-cluster-worker-nodes.name}" }
image_id = "${data.aws_ami.eks-worker.id}"
name = "${var.cluster-name}-eks-cluster-worker-nodes"
vpc_security_group_ids = ["${aws_security_group.eks-cluster-worker-nodes.id}"]
key_name = "${var.ssh-key-name}"
instance_type = "${local.host-types[0]}"
@jtbonhomme
jtbonhomme / setup.sh
Created November 5, 2019 12:18 — forked from bradp/setup.sh
New Mac Setup Script
echo "Creating an SSH key for you..."
ssh-keygen -t rsa
echo "Please add this public key to Github \n"
echo "https://github.com/account/ssh \n"
read -p "Press [Enter] key after this..."
echo "Installing xcode-stuff"
xcode-select --install
@jtbonhomme
jtbonhomme / grace.go
Created October 30, 2019 10:04 — forked from rcrowley/grace.go
Graceful stop in Go
package main
import (
"log"
"net"
"os"
"os/signal"
"sync"
"syscall"
"time"
@jtbonhomme
jtbonhomme / postgres-cheatsheet.md
Created October 30, 2019 07:26 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@jtbonhomme
jtbonhomme / rand.go
Created September 6, 2019 07:52
Use crypto/rand library to generate random numbers
package main
import (
"crypto/rand"
"fmt"
)
func main() {
c := 10
b := make([]byte, c)