Skip to content

Instantly share code, notes, and snippets.

View goodwillhacking's full-sized avatar
🔨
Building

Goodwill Hacking goodwillhacking

🔨
Building
View GitHub Profile
@goodwillhacking
goodwillhacking / compress_test.js
Created November 17, 2016 03:38 — forked from comerford/compress_test.js
Generating data for MongoDB compression testing
// these docs, in 2.6, get bucketed into the 256 bucket (size without header = 240)
// From Object.bsonsize(db.data.findOne()), the size is actually 198 for reference, so add 16 to that for an exact fit
// with that doc size, 80,000 is a nice round number under the 16MiB limit, so will use that for the inner loop
// We are shooting for ~16 GiB of data, without indexes, so do 1,024 iterations (512 from each client)
// This will mean being a little short (~500MiB) in terms of target data size, but keeps things simple
for(var j = 0; j < 512; j++){ //
bigDoc = [];
for(var i = 0; i < 80000; i++){
@goodwillhacking
goodwillhacking / pycon-views.py
Created November 30, 2016 18:03 — forked from miguelgrinberg/pycon-views.py
Generate statistics about PyCon 2014 videos
import argparse
import re
from multiprocessing.pool import ThreadPool as Pool
import requests
import bs4
root_url = 'http://pyvideo.org'
index_url = root_url + '/category/50/pycon-us-2014'
@goodwillhacking
goodwillhacking / curl.md
Created April 11, 2018 17:02 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@goodwillhacking
goodwillhacking / jupyter_logging.py
Created August 22, 2022 16:10 — forked from wassname/jupyter_logging.py
simple logging for jupyter or python which outputs to stdout (or a console or terminal) and a log file
"""
In jupyter notebook simple logging to console
"""
import logging
import sys
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
# Test
logger = logging.getLogger('LOGGER_NAME')
@goodwillhacking
goodwillhacking / extract_kubecfg_cert.sh
Created August 26, 2022 17:21 — forked from xueshanf/extract_kubecfg_cert.sh
Extract kubernetes cluster credentials from kubecfg
#!/bin/bash
# Input: ./extract_kubecfg_cert.sh my-cluster-name username
# Output: ./my-cluster-name-ca.crt ./username.crt ./username.key
# Exit on error
abort(){
echo $1 && exit 1
}
# Prerequistes

Keybase proof

I hereby claim:

  • I am goodwillhacking on github.
  • I am nkaronji (https://keybase.io/nkaronji) on keybase.
  • I have a public key whose fingerprint is E4BB BC95 D381 F176 8320 A5C0 9114 2493 2FEC B8C4

To claim this, I am signing this object:

@goodwillhacking
goodwillhacking / renew_certificates.py
Created July 17, 2023 04:11 — forked from jh0ker/renew_certificates.py
Python 3.5 - Script to check letsencrypt certificates for all domains, renew them if required, concatenate them into bundles and restart haproxy
from os import listdir, system
from os.path import join
from subprocess import run, PIPE
import logging
import re
from datetime import datetime, timedelta
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s',
level=logging.INFO,
filename='/root/renew_certificates.log',
@goodwillhacking
goodwillhacking / nginx.service
Last active March 7, 2024 05:45
Systemd nginx service file to run as non-root user
[Unit] Description=nginx
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=exec
User=nginx
Group=nginx
SupplementaryGroups=acme
RuntimeDirectory=nginx
@goodwillhacking
goodwillhacking / haproxy.cfg
Created March 10, 2024 20:23
haproxy.cfg - loadbalance a kuber cluster
global
log stdout local0 notice
chroot /var/lib/haproxy
stats socket /run/haproxy-admin.sock mode 660 level admin expose-fd listeners
stats timeout 20s
maxconn 4096
user haproxy
group haproxy
# daemon
@goodwillhacking
goodwillhacking / ai-gpt.md
Last active March 16, 2024 02:05
Helpful Tools and Services

Flow GPT

Gemini

Copilot

ChatGPT

Claude (Anthropic)

DALL-E3

Mistral

Llama2