Skip to content

Instantly share code, notes, and snippets.

View dreamingbinary's full-sized avatar
💭
I love to build

Charles Le dreamingbinary

💭
I love to build
  • Los Angeles, Earth.
View GitHub Profile
@dreamingbinary
dreamingbinary / build-and-lint.yml
Created December 22, 2023 00:34 — forked from YonatanKra/build-and-lint.yml
Reusable workflows
name: 🏗 Lint & Build
on: workflow_call
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
@dreamingbinary
dreamingbinary / bulk-transfer-repos.py
Created August 21, 2023 17:47 — forked from marcelkornblum/bulk-transfer-repos.py
Simple Python script to rip everything from BitBucket across to Github with minimal interaction
# heavily inspired by https://gist.github.com/rbellamy/3c5033ba605a090824e8
# gets everything from bitbucket and brings it across to GH, adding LFS where necessary for file size
# then archives everything brought over
#
# runs on Python 3; does clone --mirror and push --mirror, cleaning up after itself
#
# you need git-lfs installed on the local system
# also make sure you've got git credential caching set up https://help.github.com/articles/caching-your-github-password-in-git/
import json
@dreamingbinary
dreamingbinary / http-benchmark.md
Created November 23, 2022 21:04 — forked from denji/http-benchmark.md
HTTP(S) Benchmark Tools / Toolkit for testing/debugging HTTP(S) and restAPI (RESTful)
@dreamingbinary
dreamingbinary / ssh-tunnel-to-private-rds.sh
Created June 24, 2022 21:38 — forked from jeffjohnson9046/ssh-tunnel-to-private-rds.sh
Connect to a private AWS RDS instance that is only accessible through a bastion (and not the internet)
# Assume the following scenario:
# * You have a bastion/jump server that is publicly available
# * You have an RDS instance that is _not_ publicly accessible, but the bastion can get to it
#
# We have this setup with some of our k8s clusters: the cluster was created via kops, which _also_ sets up a VPC, a
# bastion server, all that good stuff. We use a "private" network topology to minimize public access to any of the
# resources in the cluster.
#
# We _also_ create our RDS instances in the same VPC. The bastion and nodes get access to the RDS instance, but it isn't
# available to us common folk out here on the internet. That's good; we want to minimize access to the database, too.
@dreamingbinary
dreamingbinary / nginxproxy.md
Created January 8, 2022 02:23 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@dreamingbinary
dreamingbinary / camel_case_to_snake_case.py
Created April 3, 2020 20:49 — forked from jaytaylor/camel_case_to_snake_case.py
Convert camel-case to snake-case in python.
#!/usr/bin/env python
"""
Convert camel-case to snake-case in python.
e.g.: CamelCase -> snake_case
Relevant StackOverflow question: http://stackoverflow.com/a/1176023/293064
"""
@dreamingbinary
dreamingbinary / pi.py
Created January 24, 2020 17:20 — forked from jhidding/pi.py
Compute Pi using Numba and Dask
# requirements: python3, numba, dask
import random
import numba
import dask
@dask.delayed
@numba.jit(nopython=True, nogil=True)
def calc_pi(N):
@dreamingbinary
dreamingbinary / utf-8_gzip.py
Created November 6, 2019 21:34 — forked from dmdavis/utf-8_gzip.py
Python: Compress a UTF-8 file using GZIP compression
def compress_utf8_file(fullpath, delete_original = True):
"""Compress a UTF-8 encoded file using GZIP compression named *.gz. If `delete_original` is `True` [default: True],
the original file specified by `delete_original` is removed after compression."""
with codecs.open(fullpath, 'r', 'utf-8') as fin:
with gzip.open(fullpath + '.gz', 'wb') as fout:
for line in fin:
fout.write(unicode(line).encode('utf-8'))
if delete_original:
os.remove(fullpath)
@dreamingbinary
dreamingbinary / all_aws_lambda_modules_python.md
Last active October 2, 2019 18:42 — forked from gene1wood/all_aws_lambda_modules_python.md
AWS Lambda function to list all available Python modules for Python 3.7

This gist contains lists of modules available in

in AWS Lambda.

It also contains the code to run in Lambda to generate these lists. In addition there is a less_versbose module in the code that you can call to get a list of the top level modules installed and the version of those modules (if they contain a version in the module)

@dreamingbinary
dreamingbinary / find_user_from_access_key.py
Created September 9, 2018 21:08 — forked from andymotta/find_user_from_access_key.py
Find an AWS IAM user corresponding to an AWS Access Key (boto3)
# Find the IAM username belonging to the TARGET_ACCESS_KEY
import boto3
from botocore.exceptions import ClientError
iam = boto3.client('iam')
def find_user(key):
try:
key_info = iam.get_access_key_last_used(AccessKeyId=key)