Skip to content

Instantly share code, notes, and snippets.

@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 / 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"
@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
@vinhlh
vinhlh / typeahead.facebook.js
Created November 18, 2016 10:27
Typehead facebook search implement
m.prototype.throttleSendRemoteQuery = function() {
'use strict';
var n = c('FacebarGlobalOptions').sendRemoteQueryThrottleTime;
if (n === 0) {
this.sendRemoteQueryThrottled = this.sendRemoteQuery;
} else if (c('FacebarGlobalOptions').lazyThrottleRemoteQuery) {
var o = Date.now()
, p = c('FacebarGlobalOptions').enableSendRemoteQueryDelay
, q = c('FacebarGlobalOptions').sendRemoteQueryDelayTime;
this.sendRemoteQueryThrottled = function() {
@vinhlh
vinhlh / PdfViewer.js
Created May 22, 2016 08:11
React PDF Viewer component using PDF.js (setup the iframe url by https://gist.github.com/vinhlh/22c92f1a9f4fdb72fdbabefee34cef4d)
import React, { Component, PropTypes } from 'react'
import { PDF_VIEWER } from '../configs'
const propTypes = {
ratio : PropTypes.number,
file : PropTypes.string.isRequired
}
const defaultProps = {
ratio: 56.25
(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 / 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/*",