This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WITH sz AS ( | |
| SELECT nspname || '.' || relname AS "relation", | |
| pg_size_bytes(pg_size_pretty(pg_relation_size(C.oid))) / (1024.0 * 1024.0 * 1024.0) AS "size_gb", | |
| pg_size_pretty(pg_relation_size(C.oid)) AS "size" | |
| FROM pg_class C | |
| LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) | |
| WHERE nspname NOT IN ('pg_catalog', 'information_schema') | |
| ORDER BY pg_relation_size(C.oid) DESC | |
| LIMIT 50 | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| connection = engine.connect() | |
| trans = connection.begin() | |
| try: | |
| connection.execute("DELETE * FROM blah") | |
| connection.execute("INSERT INTO blah VALUES ('blah')") | |
| trans.commit() | |
| except: | |
| trans.rollback() | |
| raise |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const extractJWTPayload = (jwt) => { | |
| const jwtComponents = jwt.split('.'); | |
| // A JWT string is divided into 3 components, the second of which | |
| // contains the payload (user information) which is what we care about. | |
| if (jwtComponents.length !== 3) | |
| throw new Error('invalid jwt'); | |
| // Base64 decode with urlsafe character set | |
| const decoded = atob(jwtComponents[1].replace(/_/g, '/').replace(/-/g, '+')); | |
| return JSON.parse(decoded).data; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| psql --host=mypostgresql.c6c8mwvfdgv0.us-west-2.rds.amazonaws.com --port=5432 --username= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fetch('/myurl', { | |
| method: 'POST', | |
| credentials: 'include', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ foo, bar }) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # property validation | |
| expect(result).to.all.have.property('propName'); | |
| expect(result).to.all.have.property('propName', 'propVal'); | |
| expect(obj).to.have.deep.property('field1.field2').that.is.oneOf([ 0, 1, 2 ]) | |
| expect(obj).to.have.deep.property('field1.field2').that.is.within(0, 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Lowercase all files in a directory | |
| for f in `ls`; do mv "$f" "`echo "$f" | awk '{print tolower($0)}'`"; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| lsof -ti :<port> | xargs kill |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PS1="\033[32m\u\033[m@\033[33m\h \033[34m\w\n\033[m$ " |
NewerOlder