Skip to content

Instantly share code, notes, and snippets.

function parse_request() {
// get current url
$current = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
// calculate the path
$part = substr( $current, strlen( site_url() ) );
if ( $part[0] == '/' ) {
$part = substr( $part, 1 );
}
// strip parameters
$real = explode( '?', $part );
@brandon-braner
brandon-braner / Dockerfile
Created April 8, 2017 00:32
Ubuntu & Python 3.6
FROM ubuntu:16.04
MAINTAINER Brandon Braner
RUN apt-get install gnupg && gpg --keyserver pgpkeys.mit.edu --recv-key 8B48AD6246925553 && gpg --keyserver pgpkeys.mit.edu --recv-key 7638D0442B90D010 \
&& gpg -a --export 8B48AD6246925553 | apt-key add - && gpg -a --export 7638D0442B90D010 | apt-key add - \
&& echo "deb http://ftp.de.debian.org/debian experimental main" >> /etc/apt/sources.list \
&& echo "deb http://ftp.de.debian.org/debian unstable main" >> /etc/apt/sources.list \
&& apt-get update && apt-get -y upgrade \
&& apt-get install -y nginx && apt install -y python3.6 \
@brandon-braner
brandon-braner / message_rate_limit.py
Created December 4, 2017 18:34
Simple function to rate limit message printing
def print_message(message):
"""
Function to limit the printing of messages
This will limit the printing of messages to amount per second
:param message:
:return:
"""
window = 1
max_messages = 5
message_count = 0
version: '3'
services:
node1:
image: docker.elastic.co/elasticsearch/elasticsearch:7.12.1
container_name: node1-7.12.1
environment:
- node.name=node1
- cluster.name=elasticsearch-first-steps
- discovery.type=single-node
- bootstrap.memory_lock=true
@brandon-braner
brandon-braner / main.py
Last active September 21, 2021 02:16
Trying to get supabase auth working
from supabase_py import create_client, Client
SUPABASE_URL = "https://url.supabase.co"
SUPABASE_KEY = "secret_key"
#### Start signin
# api call to sign in and get the user access token for futuer api calls
supabase: Client = create_client(SUPABASE_URL, SUPABASE_KEY)
user = supabase.auth.sign_in(
@brandon-braner
brandon-braner / pyenv_setup.md
Last active December 16, 2021 15:09
Get pyenv working on M1

Tested on M1 Max on MacOS Monterey in Parallels

Install homebrew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install pyenv

brew update brew install pyenv

Add the following to ~/.zprofile

@brandon-braner
brandon-braner / review_notes.md
Created January 22, 2022 03:08
review notes

Nate notes

general notes

  • nice use of HttpException I didn't know that would return a proper error
  • maybe add type hints if we have time
  • no defensive programming around function/method parameters/arguments

files and git

  • Add a readme.md to the root. Mine was a copy and paste of the requirements and a quick blurb of what I implemented.
@brandon-braner
brandon-braner / nginx.yaml
Created October 20, 2022 03:00
ngnix ingress service k8
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: hello-kubernetes
labels:
app: hello-kubernetes
spec:
rules:
- http:
paths:
@brandon-braner
brandon-braner / k8s_cheatsheet.md
Last active December 15, 2022 21:07
Kubernetes Imperative Commands

Create a pod

kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...] [options]

create nginx pod with env vars exposed on port 80

kubectl run nginx-pod --image=nginx --env="DNS_DOMAIN=cluster" --env="SOME_SECRET=secret" --port=80

create python pod and print the version number.

@brandon-braner
brandon-braner / dep-in.py
Last active June 22, 2023 14:21
FastAPI Depdency Injection Example
from fastapi import FastAPI, Depends
from myservice import UserService, User, UserCreate
app = FastAPI()
class UserService:
def create_user(self):
return 'doing something that creates user'