Skip to content

Instantly share code, notes, and snippets.

View carsongee's full-sized avatar

Carson Gee carsongee

View GitHub Profile
@carsongee
carsongee / harness_url_parser.py
Created January 24, 2024 01:40
Harness URL Parser snippet
from typing import NamedTuple
from urllib.parse import urlparse
class HarnessPipeline(NamedTuple):
account: str
org: str
project: str
pipeline: str
@classmethod
@carsongee
carsongee / t.py
Last active December 10, 2020 23:59
Quick & dirty python timer for copy/paste perf. Handy for quick measurements of functions with the decorator or blocks with the context manager
from contextlib import contextmanager
from functools import wraps
from time import perf_counter
@contextmanager
def t(name: str):
start = perf_counter()
yield
print(f'TIMER {name}: {perf_counter() - start}')
@carsongee
carsongee / github_org_stats.py
Last active March 6, 2024 21:53
Grab Contributor Statistics for a Given GitHub Organization
#!/usr/bin/env python
# This is free and unencumbered software released into the public domain.
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
@carsongee
carsongee / mitx-stack-server-vars.yml
Created August 17, 2015 17:20
MITx stack server vars
edx_platform_repo: "https://github.com/mitocw/edx-platform.git"
edx_platform_version: "mitx-release"
edxapp_use_custom_theme: true
edxapp_theme_name: mitx
edxapp_theme_source_repo: 'https://{{ COMMON_GIT_MIRROR }}/mitocw/edx-theme.git'
edxapp_theme_version: 'mitx-loloadx'
EDXAPP_MKTG_URL_LINK_MAP:
CONTACT: !!null
FAQ: !!null
HONOR: !!null
@carsongee
carsongee / in_vs_for.py
Last active August 29, 2015 14:24
Python For loop vs in
def x_in_loop():
x = range(500)
for i in x:
if x == 253:
return True
return False
def x_in_range():
x = range(500)
return 253 in x
@carsongee
carsongee / update_libc.yml
Last active August 29, 2015 14:14
ansible play to update libc6 for GHOST and reboot serially. works for rhel and debian based distros
- name: Update libc6 and reboot
hosts: all
sudo: yes
# Comment out to apply to all servers
serial: 1
tasks:
- name: "Install packages and update cache"
apt: name="{{ item }}" state=latest update_cache=yes
with_items:
@carsongee
carsongee / course_git_backup.sh
Created January 20, 2015 14:50
course backup to git script for edx-platform
#!/bin/bash
# This script assumes that the git repository is already cloned
# App specifics
EDXAPP_USER="edxapp"
EDXAPP_VENV="/edx/app/edxapp/venvs/edxapp"
EDXAPP_DIR="/edx/app/edxapp/edx-platform"
# Git specifics
export GIT_KEY="/edx/app/course_git_backup/git_backup_deploy"
@carsongee
carsongee / tail_jenkins.py
Last active February 15, 2021 14:04
Tail Jenkins Jobs
#!/usr/bin/env python
"""
Tail a Jenkins build in a terminal
"""
import os
import requests
import sys
import time
@carsongee
carsongee / .screenrc
Created October 8, 2014 13:49
.screenrc
# no startup msg
startup_message off
# always use a login shell
shell -$SHELL
# auto-log
logfile $HOME/log/screen-logs/%Y%m%d-%n.log
deflog on
escape ^Oo
@carsongee
carsongee / test_dns.sh
Created October 2, 2014 15:12
DNS Resolution Check
#!/bin/bash
hostname=example.com
while true; do
ip=$(dig +short $hostname | tail -n 1)
if [ ! -n "$ip" ]; then
echo "Failed at $(date)"
fi
sleep 1