Skip to content

Instantly share code, notes, and snippets.

Steve Kehlet skehlet

Block or report user

Report or block skehlet

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View file_ends_with_newline
$ docker run --rm -it ubuntu bash
root@b327e1a0640b:/# function file_ends_with_newline() {
> [[ $(tail -c1 "$1" | wc -l) -gt 0 ]]
> }
root@b327e1a0640b:/#
root@b327e1a0640b:/# touch empty.txt
root@b327e1a0640b:/#
root@b327e1a0640b:/#
root@b327e1a0640b:/# file_ends_with_newline empty.txt && echo ends in newline || echo does NOT end in newline
does NOT end in newline
View c
#!/bin/bash
#
# Wrapper for any AWS-related command using aws that handles the 1 hour MFA token.
#
# Create an aws-role.config.json file in the same directory as this script that looks like:
# {
# "<your-profile-nickname>": {
# "profile": "<your-hub>",
# "region": "<your-default-region>",
# "mfa_arn": "<your-mfa-arn>",
View aws-role
#!/bin/bash
#
# Wrapper for any AWS-related command using aws that handles the 1 hour MFA token.
#
# Create an aws-role.config.json file in the same directory as this script that looks like:
# {
# "spoke-account": {
# "profile": "hub",
# "region": "us-west-2",
# "mfa_arn": "<your-mfa-arn>",
View gist:c3daebdf63cc4ba6cc6c3ebbfd9d98bd
#!/bin/bash
set -e
unset AWS_ACCESS_KEY_ID
unset AWS_SECRET_ACCESS_KEY
unset AWS_SESSION_TOKEN
unset AWS_DEFAULT_REGION
unset AWS_DEFAULT_OUTPUT
unset AWS_PROFILE
unset AWS_CA_BUNDLE
View gist:47c7f92daa0bd3d1a3aee2bb001da140
postgres=# SELECT version();
version
---------------------------------------------------------------------------------------------------------------
PostgreSQL 9.4.4 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44), 64-bit
(1 row)
postgres=# SELECT name, current_setting(name), SOURCE
postgres-# FROM pg_settings
postgres-# WHERE SOURCE NOT IN ('default', 'override');
name | current_setting | source
@skehlet
skehlet / gist:08aeed3d06f1c35bc780
Created Mar 17, 2016
my custom postgres settings
View gist:08aeed3d06f1c35bc780
postgres=# SELECT version();
version
---------------------------------------------------------------------------------------------------------------
PostgreSQL 9.4.5 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44), 64-bit
(1 row)
postgres=# SELECT name, current_setting(name), SOURCE
postgres-# FROM pg_settings
postgres-# WHERE SOURCE NOT IN ('default', 'override');
name | current_setting | source
View postgres show blocked and blocking queries
SELECT
COALESCE(blockingl.relation::regclass::text,blockingl.locktype) as locked_item,
blockeda.procpid AS blocked_pid,
blockeda.current_query as blocked_query,
blockedl.mode as blocked_mode,
blockinga.procpid AS blocking_pid,
blockinga.current_query as blocking_query,
blockingl.mode as blocking_mode
FROM pg_catalog.pg_locks blockedl
JOIN pg_stat_activity blockeda ON blockedl.pid = blockeda.procpid
@skehlet
skehlet / gist:fd4945f9c9ce6ed075f1
Created Aug 28, 2015
my non-default postgres config
View gist:fd4945f9c9ce6ed075f1
psql (9.4.4)
Type "help" for help.
postgres=#
postgres=# SELECT name, current_setting(name), source
postgres-# FROM pg_settings
postgres-# WHERE source NOT IN ('default', 'override');
name | current_setting | source
---------------------------------+----------------------------------+--------------------
application_name | psql | client
View gist:3589b0d83f2cafe19624
listen_addresses = '*'
port = 5432
max_connections = 300
shared_buffers = 2GB
work_mem = 10MB
maintenance_work_mem = 256MB
max_stack_depth = 8MB
wal_buffers = 16MB
checkpoint_segments = 32
checkpoint_completion_target = .9
View gist:bcdbc1ce1f212d3b7bb2
mydb=> SELECT name, current_setting(name), source
mydb-> FROM pg_settings
mydb-> WHERE source NOT IN ('default', 'override');
name | current_setting | source
---------------------------------+------------------+--------------------
application_name | psql | client
archive_command | exit 0 | configuration file
archive_mode | on | configuration file
autovacuum | on | configuration file
autovacuum_analyze_scale_factor | 0.1 | configuration file
You can’t perform that action at this time.