See how a minor change to your commit message style can make you a better programmer.
Format: <type>(<scope>): <subject>
<scope>
is optional
#!/bin/bash | |
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF | |
appify v3.0.1 for Mac OS X - http://mths.be/appify | |
Creates the simplest possible Mac app from a shell script. | |
Appify takes a shell script as its first argument: | |
`basename "$0"` my-script.sh |
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
#/etc/nginx/conf.d/default.conf | |
server { | |
server_name domain.com; | |
rewrite ^(.*) http://www.domain.com$1 permanent; | |
} | |
server { | |
#listen 000.000.000.000:80; | |
server_name www.domain.com; | |
root /var/www/www.domain.com; |
My Elasticsearch cheatsheet with example usage via rest api (still a work-in-progress)
>>> docker exec -it CONTAINERID /bin/sh
/app # telnet
/bin/sh: telnet: not found
/app # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
v3.7.0-243-gf26e75a186 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]
v3.7.0-229-g087f28e29d [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]
# PLEASE REPLACE <username>, <public_key>, <admin_user> | |
# Add new user with sudo admin | |
useradd -m -d /home/<username> -s /bin/bash <username> | |
mkdir -p '/home/<username>/.ssh/' | |
touch /home/<username>/.ssh/authorized_keys | |
echo -n "<public_key>" >> /home/<username>/.ssh/authorized_keys | |
chown -R <username>:<username> /home/<username>/.ssh |
UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker
now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.
Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/
sudo amazon-linux-extras install docker
sudo service docker start
# Docker postgres backup data | |
docker exec -t -e PGPASSWORD={password} {container_name} pg_dump -U {username} --column-inserts --data-only --schema={schema} {database_name} > /path/to/exported/file.sql | |
# Docker postgres run script from outside | |
docker cp /host_path.sql captrondb:/container_inside.sql | |
docker exec -u {login_user} {container_name} psql {database_name} {db_username} -f /container_inside.sql # with continer username | |
docker exec {container_name} psql {database_name} {db_username} -f /container_inside.sql # without continer username |