Skip to content

Instantly share code, notes, and snippets.

View ihanson's full-sized avatar

Ira Hanson ihanson

View GitHub Profile
@ihanson
ihanson / sha256.txt
Created September 26, 2022 22:49
SHA256 implemented in an Excel formula
=LAMBDA(str,LET(
RightShift,LAMBDA(num,bits,QUOTIENT(num,2^bits)),
RightRotate,LAMBDA(word,bits,LET(b,MOD(bits,32),MOD(word,2^b)*2^(32-b)+RightShift(word,b))),
BitwiseOp,LAMBDA(op,LAMBDA(f,LAMBDA(lw,rw,f(f,op,lw,rw,0,0)))(
LAMBDA(f,op,lw,rw,r,i,IF(
i>31,r,
f(f,op,RightShift(lw,1),RightShift(rw,1),r+op(MOD(lw,2),MOD(rw,2))*(2^i),i+1)
))
)),
BXOR,BitwiseOp(LAMBDA(l,r,IF(l=r,0,1))),
@ihanson
ihanson / attach-pull-request
Created March 22, 2012 07:13
Attaching a pull request to an existing GitHub issue
#!/usr/bin/env bash
read -p "GitHub username: " -ei $(git config --get github.user) USERNAME
read -sp "GitHub password: " PASSWORD
echo
read -p "Submit pull request to user: " TO_USER
read -p "Submit pull request to repository: " TO_REPO
read -p "Submit pull request to branch: " -ei master TO_BRANCH
read -p "Submit pull request from user: " -ei $USERNAME FROM_USER
read -p "Submit pull request from branch: " FROM_BRANCH
@ihanson
ihanson / perfect.js
Created October 20, 2011 17:25
Typographical Perfectionist
/** Run this code as a bookmarklet to replace certain
* punctuation marks (dashes, quotation marks, apostrophes,
* and ellipses) with their typographically correct
* variants.
*
* If a quotation mark or apostrophe ends up as the wrong
* character, click it to correct it.
*/
(function () {
"use strict";