Skip to content

Instantly share code, notes, and snippets.

@jjorissen52
jjorissen52 / contained.py
Last active January 15, 2023 21:38
Example of a python script which can specify its own dependencies, including python itself
#! /usr/bin/env nix-shell
#! nix-shell -i python3 -p python3 -p python3Packages.requests -p python3Packages.fire
import requests
import fire
class CLI:
def get(self, url):
return requests.get(url).status_code
@jjorissen52
jjorissen52 / deep_clone.sh
Created June 29, 2022 21:25
Clone all repos in all organizations you have access to
#!/usr/bin/env bash
# This script backs up all repositories in all organizations that the gh user has
# has access to.
cwd="$PWD"
orgs="$(gh api /user/memberships/orgs --jq '.[].organization.login')"
while read org; do
orgdir="./backups/$org"
mkdir -p "$orgdir"
#!/usr/local/bin/python3
"""
This script makes it slightly easier to discover and inspect GCP IAM roles via CLI.
MIT License
Copyright (c) 2022 JP Jorissen
@jjorissen52
jjorissen52 / epic-dump.json
Created April 24, 2021 01:03
Some JSON for Demonstration of possible Nushell Bug
{
"author": {
"name": "Epic RPG Helper",
"discriminator": "5967",
"bot": true,
"icon_url": null,
"guild": {
"name": "Bot Farm",
"id": 679068101194547200
}
# Generated by Django 3.2 on 2021-04-23 19:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('djstripe', '0007_2_4'),
]
@jjorissen52
jjorissen52 / README.md
Created April 22, 2021 20:57
Mining Git Commits

Here is a simple proof-of-concept for viewing your most recent commits machine-wide using nushell!

Start nushell:

nu

Load the script below (with modifications for your machine, of course) and run your pipeline:

@jjorissen52
jjorissen52 / DjangoKube.md
Last active May 27, 2024 10:27
Django with Kubernetes

If you are hosting a Django app with Kubernetes, there are a few things that you need to take care of.

Containerizing

Here is a sample Dockerfile for a containerized app:

FROM python:3.9-buster

RUN apt-get update \
    --fix-missing \
@jjorissen52
jjorissen52 / mpip.sh
Created December 23, 2020 22:59
Thin wrapper around pip that manages your requirements file.
# licensed under the UNLICENSE https://unlicense.org/
mpip() {
if [[ "$1" == "install" ]]; then
touch requirements.txt
local old_req="$(< requirements.txt)"
local new_req="$old_req"
shift 1
local install_list=($@)
python -m pip install "$@"
@jjorissen52
jjorissen52 / django_setup.py
Created September 25, 2020 17:50
Import Django in Script or Jupyter Notebook
import os
import dotenv
dotenv.read_dotenv(override=True)
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_project.settings")
# django.setup() is called as a side-effect
from django.core.wsgi import get_wsgi_application
_ = get_wsgi_application()
@jjorissen52
jjorissen52 / .bashrc
Created August 10, 2020 20:43
Goodies from my .bashrc file
alias ll="ls -l"
alias la="ls -al"
alias lh="ls -lh"
alias code="code-insiders"
gcloud-projects-set() {
# Make a gcloud config for this project locally if there isn't one already.
# if there is one, go ahead and activate.
local script_dir=$PWD
local configname="$1"