Skip to content

Instantly share code, notes, and snippets.

View TanAlex's full-sized avatar

Tingli Tan TanAlex

View GitHub Profile
test: &test
name: Install and Test
image: node:10.15.0
caches:
- node
script:
- npm install
- npm test
- npm run build
artifacts: # defining the artifacts to be passed to each future step.
image: node:10.15.0
test: &test
name: Install and Test
script:
- cd my-tools
- npm install
- npm test
- npm pack
artifacts: # defining the artifacts to be passed to each future step.
# - dist/**
@TanAlex
TanAlex / handler.js
Created May 24, 2020 18:58
lambda@edge function handle 404,403 response from s3 origin
'use strict';
const http = require('https');
const indexPage = 'index.html';
exports.handler = async (event, context, callback) => {
const cf = event.Records[0].cf;
const request = cf.request;
const response = cf.response;
@TanAlex
TanAlex / lambda-at-edge.tf
Created May 24, 2020 19:08
Terraform Snippet to deploy lambda@edge
data "archive_file" "folder_index_redirect_zip" {
type = "zip"
output_path = "${path.module}/folder_index_redirect.js.zip"
source_file = "${path.module}/folder_index_redirect.js"
}
resource "aws_iam_role_policy" "lambda_execution" {
name_prefix = "lambda-execution-policy-"
role = aws_iam_role.lambda_execution.id
@TanAlex
TanAlex / retrieve_tgz_and_extract.py
Created February 15, 2023 06:58
[DS Python Snippets] DS Python Snippets #DataScience #Python
from pathlib import Path
import pandas as pd
import tarfile
import urllib.request
def load_housing_data():
tarball_path = Path("datasets/housing.tgz")
if not tarball_path.is_file():
Path("datasets").mkdir(parents=True, exist_ok=True)
url = "https://github.com/ageron/data/raw/main/housing.tgz"