Skip to content

Instantly share code, notes, and snippets.

@bcooksey
bcooksey / guess_language.py
Created August 18, 2023 15:12
Guess Repo Language
#!/usr/bin/python
import os
import sys
import http.client
from collections import defaultdict
if len(sys.argv) < 2:
print('You need to provide a URL')
exit()
@bcooksey
bcooksey / macro.js
Created June 29, 2022 20:42
Google Sheets with Macro to Reformat and Bold Text in a Cell
/** @OnlyCurrentDoc */
function ReformatandBold() {
var spreadsheet = SpreadsheetApp.getActive();
var cellText = spreadsheet.getCurrentCell().getValue();
var newCellText = '';
var subCompetencies = [];
cellText.split('[').forEach((element) => {
if (!element){
return;
@bcooksey
bcooksey / a-instructions.md
Last active August 5, 2022 14:21
Compute Jira Cycle Times from a Jira Issue Export
  1. Download the script to your local machine
  2. Create a credentials JSON file on your local machine:
    1. If you do not have an API token for Jira, generate one by going here
    2. Create a JSON file on your local machine like {"subdomain": "<your_domain>", "username": "<your_login_email>", "api_token": "<your_api_token>"}. Name it anything you want.
  3. Run an export in Jira to get the issues you want. You only need the columns that the script requires
  4. Run compute-jira-cycle-times.py <path_to_credential_file> <path_to_export>
  5. You can take the new CSV generated and put it in Google Sheets, Excel, or Pages to create some charts and work with the data.
@bcooksey
bcooksey / find_codeowners.py
Created October 9, 2020 19:43
Compare a spreadsheet of file paths against a GitHub CODEOWNERS file and output the matches
#-*- coding: utf-8 -*-
import csv
import sys
from pathlib import PurePath
if len(sys.argv) < 3:
print('Must specify <path_to_csv_with_file_names> <path_to_codeowners>')
sys.exit(1)
@bcooksey
bcooksey / instructions.md
Last active June 2, 2022 03:45
GNU Screen Pairing

This doc outlines how to setup a remote pairing session using SSH and GNU Screen. These instructions were adapted from https://www.agileventures.org/remote-pair-programming/gnu-screen-pairing-notes

Prerequisit: The person on the guest machine needs a user account created on the host that they can connect to via SSH.

On the Host Machine

  1. Install Screen
    • Mac: Should already be installed, but you can also find it on homebrew
    • Ubuntu: sudo apt-get install screen
  2. (Platform dependent) Add the set-uid bit to screen chmod 4755 /usr/bin/screen
@bcooksey
bcooksey / running-pace.py
Created June 6, 2016 20:49
Python script to compute your average pace-per-mile from a total distance and a total time. See script for usage
#!/usr/bin/python
# Given a distance and time, computes your pace-per-mile:
# <distance in mi> - Total milage, in a format like `3.1` or `0.25`
# <time> - Total time. Allowed formats are `M:SS` or `H:MM:SS`
import sys
if len(sys.argv) == 1:
print 'Usage: <distance in mi> <time>'
sys.exit()
@bcooksey
bcooksey / dshell
Last active August 20, 2020 15:35
dshell: A little wrapper around the docker-compose run command that intelligently gets you a shell inside a container
#!/bin/bash
if [ ! -z $1 ]; then
MATCHER=$1
else
# Try to guess the project based on directory name
MATCHER=`pwd | sed 's/\/.*\///'`
fi
echo "Looking for web container named '$MATCHER'..."
@bcooksey
bcooksey / contact.rb
Created December 19, 2013 15:28 — forked from endymion/contact.rb
Implementation of our REST Hooks API in ruby
class Contact < ActiveRecord::Base
...
def after_create
if Hook.hooks_exist?('new_contact', self)
Resque.enqueue(Hook, self.class.name, self.id)
# To trigger directly without Resque: Hook.trigger('new_contact', self)
end
end
@bcooksey
bcooksey / hook.rb
Created June 18, 2013 17:07 — forked from endymion/contact.rb
This is the orignal, see the new one
class Hook < ActiveRecord::Base
attr_accessible :event, :account_id, :subscription_url, :target_url
validates_presence_of :event, :account_id, :subscription_url, :target_url
# Looks for an appropriate REST hook that matches the record, and triggers the hook if one exists.
def self.trigger(event, record)
hooks = Hook.find(:all, :conditions => {
:event => event,
:account_id => record.account_id,
})