Skip to content

Instantly share code, notes, and snippets.

@jtbonhomme
jtbonhomme / jira-behing-nginx-ssl
Created September 26, 2015 07:49 — forked from alertor/jira-behing-nginx-ssl
Atlassian JIRA behind nginx + SSL
# force HTTP to HTTPS - /etc/nginx/conf.d/nonssl.conf
server {
listen 80;
server_name jira.example.com;
access_log off;
return 301 https://$server_name$request_uri;
}
# /etc/nginx/conf.d/jira.conf
server {
@jtbonhomme
jtbonhomme / nc.md
Last active April 2, 2024 10:57
Using Netcat for File Transfers

Netcat is like a swiss army knife for geeks. It can be used for just about anything involving TCP or UDP. One of its most practical uses is to transfer files. Non *nix people usually don't have SSH setup, and it is much faster to transfer stuff with netcat then setup SSH. netcat is just a single executable, and works across all platforms (Windows,Mac OS X, Linux).

Destination

On the receiving (destination) terminal, run:

nc -l -p 1234 > out.file 
@jtbonhomme
jtbonhomme / hasMany.go
Created May 22, 2018 11:11
Gorm example of foreign key definition for a hasMany relation
package main
import (
"fmt"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/postgres"
)
// Customer ...
type Customer struct {
@jtbonhomme
jtbonhomme / gist:9d9c2acd2f1aa6cb0320
Created November 20, 2015 17:33 — forked from mharsch/gist:5188206
serve HLS (HTTP Live Streaming) content from node.js

HLS streaming from node

Provided that you already have a file or stream segmenter generating your .m3u8 playlist and .ts segment files (such as the ffmpeg 'hls' muxer), this little node server will serve up those files to an HLS compatible client (e.g. Safari). If you're using node for your streaming app already, this obviates the need to serve the HLS stream from a separate web server.

loosely based on https://gist.github.com/bnerd/2011232

// loosely based on https://gist.github.com/bnerd/2011232
// requires node.js >= v0.10.0
// assumes that HLS segmenter filename base is 'out'
// and that the HLS playlist and .ts files are in the current directory
@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 / 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-receive
Last active April 13, 2021 10:41
gitlab pre-receive custom hook
#!/bin/bash
#
# pre-receive hook for Commit Check
#
COMPANY_EMAIL="mycorp.org"
readonly PROGNAME=$(basename $0)
readonly PROGDIR=$(readlink -m $(dirname $0))
@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 / 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)