Skip to content

Instantly share code, notes, and snippets.

View dound's full-sized avatar

David Underhill dound

View GitHub Profile
@dound
dound / hide-matchines-files-in-pr.js
Created October 13, 2023 00:15
Hide certain file paths in a GitHub PR
function markMatchingFilesAsViewed() {
// hide files with GeneratedCode in their path, or ending with .meta or .asset
const regex = /(GeneratedCode)|(.meta$)|(.asset$)/
const fileDivs = document.getElementsByClassName('file-header');
let numMatches = 0;
let numClicks = 0;
for (const fileDiv of fileDivs) {
const filePath = fileDiv.getElementsByClassName('Truncate')[0]?.children[0]?.getAttribute('title') ?? ''
if (filePath.match(regex)) {
console.log(filePath);
@dound
dound / tweak-gdoc-comment-width.js
Last active April 13, 2022 20:41
Copy/paste into the chrome console to make a google doc's comments wider (F12 --> Console Tab --> copy/paste the below code & press enter).
// This script makes Chrome display Google Doc comments in a wider box (only for while you view the doc).
// 1) Open the google doc in Chrome
// 2) Press F12 (the developer tools should open)
// 3) Click the "Console" tab
// 4) Copy/Paste this code into the console and press "enter" to run it
// 5) Press "X" to close the developer tools
//
// To go back to normal size, refresh the page.
(() => {
const newCommentColumnWidth = 500; // TWEAK THIS
@dound
dound / keys_only_query_with_query_pb2.py
Created November 1, 2018 19:44
demo of how to make a query_pb2 that only fetches keys (use a projection)
from apache_beam.io.gcp.datastore.v1 import helper
ds = helper.get_datastore('pgdragonsong-dev')
from google.cloud.proto.datastore.v1 import datastore_pb2, entity_pb2, query_pb2
req = datastore_pb2.RunQueryRequest()
partition = entity_pb2.PartitionId()
partition.project_id = 'pgdragonsong-dev'
req.partition_id.CopyFrom(partition)
q = query_pb2.Query()
q.kind.add().name = 'TmpForDeletion'
@dound
dound / git-remove-history.sh
Created August 20, 2018 02:09
rewrite git history
#!/bin/bash
set -o errexit
# Author: David Underhill
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if [ $# -eq 0 ]; then
exit 0
// Quick and dirty script for fetching and parsing results from www.runraceresults.com
// Intended to be run from the Chrome console
// load jquery
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// Parses a page of results from the results-container
var parseResultsPage = function(body) {
@dound
dound / app.yaml
Created October 21, 2013 19:59
GAE app and an associated request-making test script for determining the GAE concurrent request per instance limit described in GAE Issue 7927 (https://code.google.com/p/googleappengine/issues/detail?id=7927). As of Oct-2013, the concurrent request limit *per instance* for python is 8.
application: some-app
version: sometestversion
runtime: python27
api_version: 1
threadsafe: true
inbound_services:
- warmup
handlers:
@dound
dound / augmentGAEInstancesPage.js
Created October 3, 2013 23:19
Augments the Google App Engine (GAE) instances overview page with the (instantaneous) average instance lifespan. Longer is better!
// ==UserScript==
// @name Augment GAE Instance List
// @version 0.1
// @namespace http://www.dound.com/
// @description augments instance page with average lifetime
// @match https://appengine.google.com/instances*
// @require https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// ==/UserScript==
window.setTimeout(function () {
@dound
dound / augmentGAEDashboard.js
Last active January 29, 2022 07:14
Augments the Google App Engine (GAE) dashboard with additional cost metrics.
// ==UserScript==
// @name Augment GAE Dashboard
// @version 0.3
// @namespace http://www.dound.com/
// @description modifies issue style
// @match https://appengine.google.com/dashboard?*app_id=*
// @require https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// ==/UserScript==
// Assumes discounted instance hour pricing.
@dound
dound / optimal_training.py
Created September 4, 2012 08:46
Compute optimal mix of cottages, barracks, and troops to train to maximize might (or combat power). View stats computed with this script here: bit.ly/UoSdYS
#/usr/bin/env python
"""Computes optimal mix for maximum might or combat power gain."""
from scipy import optimize
# number of places you can build in each city
SLOTS_PER_CITY = 31
# T1, T2, T3 (combat units)
TIER_BASE_TRAINING_TIME = (90, 480, 1200)
@dound
dound / basic_counter.py
Created February 10, 2012 00:52
A simple, high accuracy counter (not appropriate for higher frequency usage [>1 update/sec for any key])
from google.appengine.ext import db
class Counter(db.Model):
"""Persistent storage of a counter's values"""
# key_name is the counter's name
value = db.IntegerProperty(indexed=False)
@classmethod
def get(cls, name):