Skip to content

Instantly share code, notes, and snippets.

@vinhlh
vinhlh / dumper.go
Last active November 5, 2020 01:06
Dump AWS Dynamo DB tables to yaml files for fixtures. To run DH_SPEC_FILE=.config.yml go run ./cmd/dumper/main.go
package main
import (
"fmt"
"log"
"os"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
(function(modules) {
// The module cache
var installedModules = {};
// The require function
function __webpack_require__(moduleId) {
// Check if module is in cache
if(installedModules[moduleId])
return installedModules[moduleId].exports;
@vinhlh
vinhlh / .travis.yml
Created February 28, 2017 09:54
Multiple deployments to multiple S3 buckets and single and final hook
language: node_js
node_js:
- 6
cache:
directories:
- dir_1/node_modules
before_install:
- cd dir_1
@vinhlh
vinhlh / .travis.yml
Last active February 28, 2017 04:07
TravisCI
language: node_js
node_js:
- 6
cache:
directories:
- vinhlh.static/node_modules
install:
# for invalidating CloudFront distribution
@vinhlh
vinhlh / policy.json
Last active February 28, 2017 04:06
Continuous Deployment TravisCI
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:DeleteObject",
"s3:GetObject",
"s3:GetObjectAcl",
"s3:PutObject",
@vinhlh
vinhlh / download.js
Last active February 5, 2023 05:05
Download all videos of a course from Egghead
// Requirements
// - React Dev Tools is installed.
//
// 1. Select scrollable-holder > f listType=course
// 2. Open Console
// 3. Run
$r.props.list.lessons.map(({ download_url }) => download_url)
// It will return a list of URLs like this
["https://d3j4ov1z2pxjvg.cloudfront.net/lessons/eggh…Yk8rdCRrG717PA__&Key-Pair-Id=APKAIEGNPCBY26T6OCUQ", "https://d3j4ov1z2pxjvg.cloudfront.net/lessons/eggh…JqohRQd8QSziCQ__&Key-Pair-Id=APKAIEGNPCBY26T6OCUQ", "https://d3j4ov1z2pxjvg.cloudfront.net/lessons/eggh…CWI7XuOLvgo6gg__&Key-Pair-Id=APKAIEGNPCBY26T6OCUQ", "https://d3j4ov1z2pxjvg.cloudfront.net/lessons/eggh…ttRijk5eKVqmWg__&Key-Pair-Id=APKAIEGNPCBY26T6OCUQ", "https://d3j4ov1z2pxjvg.cloudfront.net/lessons/eggh…-BkUuXhdRKojMA__&Key-Pair-Id=APKAIEGNPCBY26T6OCUQ", "https://d3j4ov1z2pxjvg.cloudfront.net/lessons/eggh…KJ50oYPlKNYp4A__&Key-Pair-Id=APKAIEGNPCBY26T6OCUQ", "https://d3j4ov1z2pxjvg.cloudfront.net/lessons/eggh…PzTlKj~APZyNDw__&Key-Pair-Id=APKAIEGNPCBY26T6OCUQ", "https://d3j4ov1z2pxjvg.cloudfront.net/lessons/eggh…-
@vinhlh
vinhlh / s3-policy.json
Created February 7, 2017 06:45
Managing Secrets for Amazon EC2 Container Service–Based Applications
{
"Version": "2012-10-17",
"Id": "PutObjPolicy",
"Statement": [
{
"Sid": "DenyUnEncryptedObjectUploads",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::oms-services.secrets/*",
@vinhlh
vinhlh / secrets-entrypoint.sh
Last active February 7, 2017 06:29
Managing Secrets for Amazon EC2 Container Service–Based Applications Raw
#!/bin/sh
# Check that the environment variable has been set correctly
if [ -z "$SECRETS_BUCKET_NAME" ]; then
echo >&2 'error: missing SECRETS_BUCKET_NAME environment variable'
exit 1
fi
# Containers that are running on your container instances
# have access to all of the permissions that are supplied to the container instance role.
@vinhlh
vinhlh / Dockerfile
Last active February 7, 2017 06:31
Managing Secrets for Amazon EC2 Container Service–Based Applications
# s3 bucket for storing secrets
ENV SECRETS_BUCKET_NAME oms-services.secrets
# pull secrets data
COPY secrets-entrypoint.sh /secrets-entrypoint.sh
RUN chmod +x /secrets-entrypoint.sh
ENTRYPOINT ["/secrets-entrypoint.sh"]
# ./cyclops.conf is pulled from S3
CMD cyclops -c ./cyclops.conf -p 80
@vinhlh
vinhlh / raven.lazy.js
Created December 6, 2016 06:55
Loading raven.js without blocking onload event
/**
* Setup Js error lazy tracking
* - Pros: doesn't block rendering, onload event
* - Cons: lower quality error reports for lazy errors
*
* @author vinhlh
*
* @param {object} window
* @param {object} labJs
* @param {string} ravenCdn