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 / README.md
Last active March 5, 2020 20:17
virtualenv shortcuts; useful on the CLI

Install Instructions

  1. Put contents of virtualenv.sh in your ~.bashrc or ~.bash_profile
  2. Run source ~.bashrc or source ~.bash_profle to make the new commands available.

Pre-requisite

  1. Python 3 installed
  2. pip3 install virtualenv

Usage in an Existing Project

@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 / insert.sql
Created December 12, 2019 20:31
BizAggs Insert
//SET (FILE_ID, FILE_DATE) = ('GUID-919262.FWLINE.BIZAGGS.SEP19-Partac', '2019-09');
SET (FILE_ID, FILE_DATE) = ('GUID-920914.FWLINE.BIZAGGS.OCT19-Partab', '2019-10');
INSERT INTO PROSPECTDW.PUBLIC.BIZAGGS
(
"BIZAGGID", "BIN", "FILE_DATE", "FILE_ID",
@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)