Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/ruby
require 'rss'
# Usage
# $ ./railscasts.rb http://railscasts.com/subscriptions/YOURRAILSCASTRSS/\/
# episodes.rss
# OR
# $ ./railscasts.rb
p 'Downloading rss index'
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@quangthe
quangthe / introrx.md
Created April 16, 2018 02:45 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
You can ssh into the VM by finding the IP (from kubectl config view) and using username "docker" password "tcuser":
ssh docker@192.168.XX.XX
@quangthe
quangthe / backup-db-and-odoo-files.py
Last active March 22, 2019 03:33
Backup db and odoo files. Odoo 11. Docker
#! /usr/bin/python
import boto3
import subprocess
import datetime
import os
import zipfile
import humanize
WORKING_DIR = "/tmp"
@quangthe
quangthe / backup-tienluong-db.py
Created March 21, 2019 07:01
Backup tienluong postgres db app
#! /usr/bin/python
import boto3
import subprocess
import datetime
import os
now = datetime.datetime.now()
bucket = "dtcorpbackup"
filename = "dump_{}-{:0>2}-{:0>2}_{:0>2}:{:0>2}:{:0>2}.sql".format(now.year, now.month, now.day, now.hour, now.minute, now.second)
@quangthe
quangthe / setup-tienluong-db.py
Created March 21, 2019 09:28
Restore tienluong db from dump/snapshot file (stored in S3)
#!/usr/bin/env bash
# Run this script to prepare DB for "prod" profile.
# Require environment variable:
# AWS_ACCESS_KEY_ID
# AWS_SECRET_ACCESS_KEY
set -e
BUCKET=dtcorpbackup
echo "Get latest backup"
@quangthe
quangthe / get-rds-free-storage.sh
Last active March 26, 2019 02:56
Query AWS RDS free storage
usage()
{
echo "usage: get-rds-free-storage.sh -i instance -r region"
}
REGION="ap-southeast-1"
START="$(date -v '-5M' -u '+%Y-%m-%dT%H:%M:%SZ')" # 5 minutes ago
END="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
INSTANCE_NAME="mydb"
function (user, context, callback) {
var namespace = "http://cibot.vn/";
context.accessToken[namespace + "authorization"] = {
groups: user.groups,
roles: user.roles,
permissions: user.permissions
};
return callback(null, user, context);
}
@quangthe
quangthe / add-app-metadata-to-jwt.js
Created March 27, 2019 08:27 — forked from philipisapain/add-app-metadata-to-jwt.js
Auth0 Rule for adding app_metadata to JWT
function (user, context, callback) {
var namespace = 'https://tojs.io/';
context.accessToken[namespace + 'user_authorization'] = {
groups: user.app_metadata.groups,
roles: user.app_metadata.roles,
permissions: user.app_metadata.permissions
};
return callback(null, user, context);
}