Magic words:
psql -U postgres
If run with -E
flag, it will describe the underlaying queries of the \
commands (cool for learning!).
Most \d
commands support additional param of __schema__.name__
and accept wildcards like *.*
#!/bin/sh | |
head -n 4096 /dev/urandom | openssl sha1 |
# Get SHA256 of a text | |
# Usage: sha256 password | |
# output: 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8 | |
function sha256() { | |
echo -n $1 | shasum -a 256 | |
# Source: http://albertech.blogspot.fr/2015/02/generate-sha-256-hash-from-command-line.html | |
} |
#!/usr/bin/sh | |
# Requires OpenSCAD on $PATH | |
# Automatically re-exports all changed .scad files pre-commit | |
git diff --cached --name-only | grep ".scad$" | while read -r file; do | |
basename="${file%.*}" | |
echo "Exporting $file to $basename.stl..." | |
openscad -o "$basename.stl" "$file" | |
done |
#!/bin/bash | |
# A bash script to create a time machine disk image suitable for | |
# backups with OS X 10.6 (Snow Leopard) | |
# This script probably only works for me, so try it at your own peril! | |
# Use, distribute, and modify as you see fit but leave this header intact. | |
# (R) sunkid - September 5, 2009 | |
# | |
# This will create a time machine ready disk image named with your | |
# computer's name with a maximum size of 600GB and copy it to | |
# /Volumes/backup. The image "file" (it's a directory, really) will |
1. Create new container | |
a) docker run -i -t ubuntu /bin/bash | |
b) docker run --name rails_dev_container -i -t ubuntu ubuntu /bin/bash | |
The command line flags - i -t provide an interactive shell in the new container | |
2. Show running docker containers ==> docker ps | |
3. Show list of current containers ==> | |
a) docker ps -a (Show all containers, both stopped and running) | |
b) docker ps -n x (shows the last x containers, running or stopped, ex: docker ps -n 5) |
FILE SPACING: | |
# double space a file | |
sed G | |
# double space a file which already has blank lines in it. Output file | |
# should contain no more than one blank line between lines of text. | |
sed '/^$/d;G' |
val factorialOfFive = {1 to 5}.toList.reduceLeft(_*_) |
Here are 10 one-liners which show the power of scala programming, impress your friends and woo women; ok, maybe not. However, these one liners are a good set of examples using functional programming and scala syntax you may not be familiar with. I feel there is no better way to learn than to see real examples.
Updated: June 17, 2011 - I'm amazed at the popularity of this post, glad everyone enjoyed it and to see it duplicated across so many languages. I've included some of the suggestions to shorten up some of my scala examples. Some I intentionally left longer as a way for explaining / understanding what the functions were doing, not necessarily to produce the shortest possible code; so I'll include both.
The map
function takes each element in the list and applies it to the corresponding function. In this example, we take each element and multiply it by 2. This will return a list of equivalent size, compare to o