Skip to content

Instantly share code, notes, and snippets.

View albertyw's full-sized avatar
🦫

Albert Wang albertyw

🦫
View GitHub Profile
@albertyw
albertyw / generate_origin_certificate.py
Created November 9, 2025 03:56
Generate Cloudflare origin certificate for multiple domains
"""
This script generates an origin certificate from Cloudlare using their API.
It requires the 'requests' library to make HTTP requests.
"""
from cryptography import x509
from cryptography.x509.oid import NameOID
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import rsa
import requests
@albertyw
albertyw / Dockerfile-drone-nolimit
Last active February 7, 2022 02:30 — forked from mvdan/Dockerfile-drone-nolimit
Dockerfile to build Drone CI as a standalone server with its nolimit flag - https://hub.docker.com/r/mvdan/drone-nolimit
FROM golang:1.14.4 AS builder
RUN apt-get update && apt-get install -y ca-certificates
RUN git clone -b v2.9.1 --depth=1 https://github.com/drone/drone
RUN cd drone && go install -trimpath -ldflags='-w -s' -tags nolimit ./cmd/drone-server
FROM debian:buster-slim
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
@albertyw
albertyw / convert.sh
Last active July 16, 2021 05:28
Download and convert youtube playlists to MP3
#!/bin/bash
# This script converts an mp4 into an mp3
# It works by running ffmpeg in a docker container
set -euo pipefail
IFS=$'\n'
convert () {
input="$1"
@albertyw
albertyw / netdata-app
Created January 31, 2021 08:21
netdata nginx config
### Redirects ###
# Change IP address to domain name
server {
listen 80;
server_name netdata.albertyw.com;
return 301 https://netdata.albertyw.com$request_uri;
}
### Servers ###
@albertyw
albertyw / process.py
Created March 23, 2018 08:19
subprocess example
import subprocess
import time
commands = ['./time.sh'] * 5
outputs = [None] * len(commands)
processes = [None] * len(commands)
start = time.time()
@albertyw
albertyw / start_daemon.sh
Last active August 29, 2015 14:03
general init.d script
#!/bin/sh
### BEGIN INIT INFO
# Provides: ASDF
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: ASDF
# Description: ASDF
@albertyw
albertyw / recurse.py
Created October 28, 2013 05:23
Recursive JSON URL Follower
import urllib2
import json
url="http://letsrevolutionizetesting.com/challenge.json"
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36')]
def follow(url):
print url
page = opener.open(url).read()
@albertyw
albertyw / mit-ips.csv
Last active April 18, 2017 04:55
Internal MIT Allocations of IP Address Blocks. Some parts of this are dated.
OTHER AI 128.52.0.0/16 Artificial Intelligence Laboratory
OTHER WHOI 128.128.0.0/16 Woods Hole Oceanographic Institute
OTHER LINCOLN 129.55.0.0/16 Lincoln Laboratories
OTHER NEARNET 192.52.0.0/16 NEARnet
OTHER HAYSTACK 192.52.64.0/24 Haystack Observatory (EAPS/CSR)
INFRA EXTERNAL-ETHER 192.54.222.0/24 MIT External Ethernet
OTHER SAP-FDDI 192.168.1.0/24 FDDI for SAP (Unconnected)
OTHER EXTERNAL-FDDI 192.233.33.0/24 MIT External FDDI
INFRA NET1-RESERVED 18.1.0.0/16
INFRA N42-DHREG 18.2.0.0/21 Building N42 DHREG hack
@albertyw
albertyw / common-letters.py
Created August 29, 2013 01:41
Most Common Letters
"""
Sort the letters of the alphabet by their frequency in the 1000 most common words
"""
# Read text file
WORDS_LIST_FILE = "common-words-list.txt"
file_handle = open(WORDS_LIST_FILE, 'r')
text = file_handle.read()
file_handle.close()
text = text.lower().replace("\n",'')
@albertyw
albertyw / ftpsize.py
Created July 8, 2013 12:37
Script to find the total size of an ftp directory by recursively opening directories
"""
This script finds the total size of an ftp directory by recursively opening directories
@author: Albert Wang ([email protected])
September 18, 2010
"""
from ftplib import FTP
import re
import sys