Skip to content

Instantly share code, notes, and snippets.

View drewdaemon's full-sized avatar

Drew Tate drewdaemon

  • Elastic
View GitHub Profile
def qr_gram_schmidt(A):
"""Compute the reduced QR decomposition of A via Modified Gram-Schmidt.
Parameters:
A ((m,n) ndarray): A matrix of rank n.
Returns:
Q ((m,n) ndarray): An orthonormal matrix.
R ((n,n) ndarray): An upper triangular matrix.
"""
@drewdaemon
drewdaemon / du-report
Created June 12, 2019 19:39
Disk Usage Report Generator
sudo du -hd 1 / >> totaldisk.txt
sudo du -hd 1 ~/ >> userdisk.txt
@drewdaemon
drewdaemon / .gitconfig
Created July 10, 2019 17:59
Helpful aliases for merging/rebasing off master
[alias]
pmerge = "!f() { git fetch origin \"$1\":\"$1\" && git merge \"$1\"; }; f"
pbase = "!f() { git fetch origin \"$1\":\"$1\" && git rebase \"$1\"; }; f"
const i18n = {
create: function () {
this.interpolate = (template, fillers) => {
let ret = template;
for (const key of Object.keys(fillers)) {
ret = ret.replace(`{${key}}`, fillers[key])
}
return ret;
};
@drewdaemon
drewdaemon / ThumbnailGenerator.js
Last active May 13, 2022 12:58
Front end JS for generating image thumbnails from base64-encoded images.
function ThumbnailGenerator() {
this.resizeCanvas = document.createElement('canvas');
this.generate = function (imgSrc, thumbDims, compression) {
[this.resizeCanvas.width, this.resizeCanvas.height] = [thumbDims.x, thumbDims.y];
const ctx = this.resizeCanvas.getContext("2d");
const tmp = new Image();
const ret = new Promise(resolve => {
const HAND_IMAGE = `data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wgARCAHdAd0DAREAAhEBAxEB/8QAHAAAAgIDAQEAAAAAAAAAAAAAAAEDBAIFBgcI/8QAGgEBAQEBAQEBAAAAAAAAAAAAAAECAwQFBv/aAAwDAQACEAMQAAAB+ldGAAgA7CAAABtIJBNdz6+J/O/QX5btzQb1uemiS8znqYZ3P0zXzOe1yn59+lsz1qHU3DnWY9s9/wAG/vACgAKxwWgCCFTEOCilkgjLQCGJGhSGoAIoAaYIk43z+3zbwfYzV3UFVcues21mysq572evDTYtLXKhjr181a3VJeuKMz7J9D4W86cUNoAAsJFa0GkEFMRlCrGHSgh6AQDsEBiQaAQgBWKwjy3xfV5DzfShakM2aMulO21w22ZWnWp0zrrmjrny/Pv0c77XWZ5mxrGqzPZfo/C6DpxFLQACQsFFEAlQ6BQWpGCKHawkEVoMEaDQIIEYgFl4b877usnsxyk1nPLWZusk7zfK5iwzdHcgvKPtw0nPvuZ3l0kylspzHr30fh9D04CloIByKwABDGIAlxpqxWLMyBRFYlyVsjRIgViRgKG1FHzt8378075ElznhzN1LMdrMWs2C2lZXuJOvn5qd9tjvlq2gkqOXsv0fj9F084CoYgC5BigCkMFwVmQCCGyAqpoBK0YgEMBBA1qca8F+d9y07IymIs75DTrcY3hJNFzWiG4w78OKnfd463tNi6KTn3L3r6PxOi6cUACEZBcoYoAoAFxXIAEENkVK0aJWCMFQkBgEYry3Lv4p4PtbObkuB
@drewdaemon
drewdaemon / manifest.json
Created August 13, 2019 02:51
Chrome Extension Manifest for Pokemon Evolution Extension
{
"name": "Pokemon Evolution",
"version": "1.0",
"description": "Provides in-browser tools for Pokemon Go users.",
"permissions": [],
"browser_action": {
"default_popup": "popup.html",
"default_title": "Pokemon Evolution"
},
"manifest_version": 2
import { APIGatewayProxyHandler } from 'aws-lambda';
import 'source-map-support/register';
import axios from 'axios';
import * as cheerio from 'cheerio';
import LIBRARY_SEARCH_URL from './endpoint';
const SELECTORS = {
RESULT_ENTRIES: '.results_cell',
TITLE_LINK: '.displayDetailLink',
THUMBNAIL: '.thumbnail img',
import { APIGatewayProxyHandler } from 'aws-lambda';
import 'source-map-support/register';
import * as cheerio from 'cheerio';
import Axios from 'axios';
const BASE_URL = 'https://www.cs.utah.edu';
const SELECTORS = {
FACULTY_ENTRIES: 'table#people:nth-child(3) tr.professor',
NAME: '#info > tbody > tr:nth-child(1) > td > h8',
const createObservable = () => {
let observers = [];
const subscribe = (observer) => {
observers.push(observer);
return () => {
observers = observers.filter(o => o !== observer);
};
};