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
%span{ style: "font-family: 'FontAwesome';" } | |
- (61440..61720).each do |n| | |
= ('&#' + n.to_s).html_safe; |
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
-- MySQL | |
-- Search all tables, databse-wide, for a column name. | |
-- EXACT MATCH | |
SELECT DISTINCT TABLE_NAME | |
FROM INFORMATION_SCHEMA.COLUMNS | |
WHERE COLUMN_NAME IN ('col_name') | |
AND TABLE_SCHEMA='db_name'; | |
-- PARTIAL MATCH |
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
# Someetimes `vagrant up` fails with a message like: | |
# Installing the 'vagrant-butcher' plugin. This can take a few minutes... | |
# Bundler, the underlying system Vagrant uses to install plugins, | |
# reported an error. The error is shown below. These errors are usually | |
# caused by misconfigured plugin installations or transient network | |
# issues. The error from Bundler is: | |
# | |
# An error occurred while installing rack (2.0.1), and Bundler cannot continue. | |
# Make sure that `gem install rack -v '2.0.1'` succeeds before bundling. |
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
def whitelist_dict(dic, keys): | |
# Filters a Dict by only including certain keys. | |
key_set = set(keys) & set(dic.keys()) | |
return { key: dic[key] for key in key_set } |
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
def merge_dicts(x, y): | |
z = x.copy() | |
z.update(y) | |
return z |
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
// First: | |
// npm install jsonwebtoken | |
// https://github.com/auth0/node-jsonwebtoken | |
// | |
// Then launch `node` shell. | |
var jwtLib = require('jsonwebtoken'); | |
var jwtStr = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb250ZXh0Ijoic3N2cHpmYWZoZCIsInN1YiI6InVybjpzd2l0Y2hjb25uZXg6dXNlcjo0MCIsImlzcyI6InVybjpzd2l0Y2hjb25uZXg6c3ZjOmF1dGgiLCJleHAiOjE0NzMzNjMxNTMsImlhdCI6MTQ3MzM2Mjg1MywiYXVkIjoidXJuOnN3aXRjaGNvbm5leDpzdmM6bW9iaWxlIn0.tZj08Vlci3g7SYUm-8MxfH_Ty_1rtBGgUzC311-NSaU'; |
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
# ssh-keygen creates Keys that aren't in PEM format, but JWT tokens mandate | |
# PEM format. So, we have to convert them with OpenSSL. | |
ssh-keygen -t rsa -b 4096 -f jwtRS256.key | |
# Press Enter when prompted for passphrase. | |
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub | |
cat jwtRS256.key | |
cat jwtRS256.key.pub |
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
logging.addLevelName(51, 'AUTH') | |
log = logging.getLogger() | |
# log.setLevel(10) | |
print log.level | |
print log.getEffectiveLevel() | |
log.log(10, '********** 10 ************') | |
log.log(20, '********** 20 ************') | |
log.log(30, '********** 30 ************') |
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 RECURSIVE pg_inherit(inhrelid, inhparent) AS | |
(select inhrelid, inhparent | |
FROM pg_inherits | |
UNION | |
SELECT child.inhrelid, parent.inhparent | |
FROM pg_inherit child, pg_inherits parent | |
WHERE child.inhparent = parent.inhrelid), | |
pg_inherit_short AS (SELECT * FROM pg_inherit WHERE inhparent NOT IN (SELECT inhrelid FROM pg_inherit)) | |
SELECT table_schema | |
, TABLE_NAME |
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
-- Index Size and Usage | |
SELECT | |
t.schemaname, | |
t.tablename, | |
indexname, | |
c.reltuples AS num_rows, | |
pg_size_pretty(pg_relation_size(quote_ident(t.schemaname)::text || '.' || quote_ident(t.tablename)::text)) AS table_size, | |
pg_size_pretty(pg_relation_size(quote_ident(t.schemaname)::text || '.' || quote_ident(indexrelname)::text)) AS index_size, | |
CASE WHEN indisunique THEN 'Y' | |
ELSE 'N' |