Skip to content

Instantly share code, notes, and snippets.

View billykong's full-sized avatar
💭
Meow

Billy Kong billykong

💭
Meow
View GitHub Profile
@billykong
billykong / vimrc
Created January 30, 2023 12:31
My vimrc
filetype off
filetype plugin indent on
set nocompatible
set modelines=0
set tabstop=4
set shiftwidth=4
set softtabstop=4

Question:

Why is git-crypt not encrypting my files?

Answer

We must git-crypt unlock the repository first for git-crypt to encrypt the file for us upon commit.

A pre-commit hook to avoid accidental commit of sensitive data:

#!/bin/sh
#pre-commit
@billykong
billykong / aws-cdk-fargate-rds-stack.ts
Created May 28, 2020 12:53
aws-cdk stack for a load-balanced ECS Fargate service with RDS
import { Vpc, Subnet, SubnetType, SecurityGroup, Peer, Port } from '@aws-cdk/aws-ec2';
import ecs = require('@aws-cdk/aws-ecs');
import ecs_patterns = require('@aws-cdk/aws-ecs-patterns');
import { CfnDBCluster, CfnDBSubnetGroup } from '@aws-cdk/aws-rds';
import secretsManager = require('@aws-cdk/aws-secretsmanager');
import ssm = require('@aws-cdk/aws-ssm');
import * as cdk from '@aws-cdk/core';
export class AwsCdkFargateRdsStackStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
@billykong
billykong / fixing-script-for-updated-aws-cli-ecr-login.md
Created March 19, 2020 02:39
Uses `aws ecr get-login-password` after `aws ecr get-login` depreciation

aws ecr get-login depreciated

$ aws ecr get-login --region ap-southeast-1
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
 aws   help

How to .gitignore Everything in Folder Recursively Except for Specific File Types

*
!*/
!.gitignore
!**/**/*.md
!**/**/*.htm*

The above .gitignore content ignore everything in the folder and subfolder execpt for the markdown .md htm or html files .htm*.

Update rvm

gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
rvm get stable

Get latest ruby

rvm install 2.7

Create gemset and use it with ruby:2.7

rvm gemset create jekyll
rvm use 2.7@jekyll
@billykong
billykong / gist:beaa99f362a505f9a62d4cb9ecc20d59
Created November 7, 2017 07:17 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@billykong
billykong / forloop_vs_map+lambda.py
Last active April 19, 2017 16:23
python forloop vs map+lambda
for t in content.findAll(class_=re.compile('.*btn.*')):
t.decompose() # this works, undesired parts of content is decomposed
# ================================
[t.decompose() for t in content.findAll(class_=re.compile('.*btn.*'))] # this works
# ================================
# map uses generator, t.decompose() is not called until someone access t
@billykong
billykong / create_dict_from_dict_using_dic_comprehension.py
Last active April 5, 2017 12:27
Create dictionary from another dictionary with dictionary comprehension
cookie = {
'domain': 'pythonscraping.com',
'httponly': False,
'name': 'has_js',
'path': '/',
'secure': False,
'value': '1'
}
keys = ['name', 'value', 'domain', 'path', 'expiry'] # 'expiry' is absent from the cookie dict