Skip to content

Instantly share code, notes, and snippets.

View tzaffi's full-sized avatar
🐙
Octopii are cool

Zeph Grunschlag tzaffi

🐙
Octopii are cool
View GitHub Profile
@tzaffi
tzaffi / generalized_josephus.py
Created September 29, 2014 06:14
Solution to the generalized Josephus problem
def generalized_josephus(self, x):
# express x as a radix d number-sequence
rad_d = Radix.tuple(x, base=self.d)
# then apply the generalized josephus transformation to convert to a radix c number-sequence
rad_c = [self.alpha_vector[rad_d[0]-1]]
for dig in rad_d[1:]:
rad_c.append(self.beta_vector[dig])
# convert rad_c to a number and return
@tzaffi
tzaffi / Tutorial1.ipynb
Created December 19, 2014 20:12
playing around with Johnathan Frederic's iPython tutorial
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tzaffi
tzaffi / Ultility.asp
Created March 6, 2015 14:53
Global variables from hell. Before:
dim Root, Utility, ErrorOccurred, ErrorType, CookieTimeStamp, FormTimeStamp, FormID, PageClass, PageID, PageTitle, InterfaceID, strTempUI, RV, cmd, RS, Instructions, WayBackOn, Title, a, b, c, d, e, f, PersonID, Redirect, Crypto, Mail, Field, Condition, Value, Field1, Condition1, Value1, OrderBy, Table, ExtendedField, USPos, HyphenPos, FieldID, TotalSpans, andor, FieldID1, Table1, ExtendedField1, USPos1, HyphenPos1, MoreSearch, SearchSql, objRegExp, SearchCondition, SearchCondition1, clause, DateField, DateField1, NumericField, NumericField1, intPageCount, PagePos, PageSize, intStart, intFinish, OrderByDir, OrderByCol, sql, WayBackArray(), RP, ArticleTitle, CancelDate, ErrorMessage, Course, CourseArray, RequestID, Editor, Choice, DeputyFor, DeputyForArray, cwcid, cwredir, series, School, Degree, PageSize1, PagePos1, OrderByCol1, OrderByDir1, PageSize2, PagePos2, OrderByCol2, OrderByDir2, NonePending, StatusID, FolderID, FolderName, WillBring, RequestArray, CourseID, CourseName, SearchArray, KeyWords, ft, Cho
@tzaffi
tzaffi / Utility.asp
Created March 6, 2015 14:54
After. Still aweful.
'This is truly wretched. Global variables from hell:
dim Root, Utility, ErrorOccurred, ErrorType, CookieTimeStamp, FormTimeStamp, FormID, PageClass, PageID
dim PageTitle, InterfaceID, strTempUI, RV, cmd, RS, Instructions, WayBackOn, Title, a, b, c, d, e, f
dim PersonID, Redirect, Crypto, Mail, Field, Condition, Value, Field1, Condition1, Value1, OrderBy
dim Table, ExtendedField, USPos, HyphenPos, FieldID, TotalSpans, andor, FieldID1, Table1, ExtendedField1
dim USPos1, HyphenPos1, MoreSearch, SearchSql, objRegExp, SearchCondition, SearchCondition1, clause
dim DateField, DateField1, NumericField, NumericField1, intPageCount, PagePos, PageSize, intStart
dim intFinish, OrderByDir, OrderByCol, sql, WayBackArray(), RP, ArticleTitle, CancelDate, ErrorMessage
dim Course, CourseArray, RequestID, Editor, Choice, DeputyFor, DeputyForArray, cwcid, cwredir, series
dim School, Degree, PageSize1, PagePos1, OrderByCol1, OrderByDir1, PageSize2, PagePos2, OrderByCol2
@tzaffi
tzaffi / Well Formed AWS Lambda for DynamoDB
Created October 7, 2015 23:52
Well Formed AWS Lambda for DynamoDB
// Set up AWS client
var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB();
// TODO update AWS configuration to set region
AWS.config.update({region : 'us-east-1'});
exports.handler = function(event, context) {
// Keep tracxk of how many requests are in flight
@tzaffi
tzaffi / SES-SNS-Gmail2Sheet.js
Last active April 6, 2016 18:26
Add this to your sheet scripts to enable parsing through your SNS SES notifications and create a useful sheet for analyzing recipients, including bad ones.
/************
* Inspired by:
* https://ctrlq.org/code/20053-save-gmail-to-google-spreadsheet
* https://gist.github.com/oshliaer/70e04a67f1f5fd96a708
*************/
var IS_DEBUG = false;
var RUN_SIZE = 10; //this variable is ignored unless IS_DEBUG true
// Cf. https://developers.google.com/apps-script/reference/gmail/gmail-message#methods
@tzaffi
tzaffi / .screenrc-main-example
Created July 29, 2016 16:53 — forked from ChrisWills/.screenrc-main-example
A nice default screenrc
# GNU Screen - main configuration file
# All other .screenrc files will source this file to inherit settings.
# Author: Christian Wills - cwills.sys@gmail.com
# Allow bold colors - necessary for some reason
attrcolor b ".I"
# Tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
import traceback
import requests
import sys
import linecache
import requests
# Put your actual Sentry DSN URL here:
SENTRY_DSN = 'https://YOUR_SENTRY_KEY@ACCOUNT.ingest.sentry.io/ISSUES_ID'
@tzaffi
tzaffi / MostRecentOfDeleted.sh
Last active October 6, 2020 02:15
#CrazyOneliner show the most recent git commit of all deleted files in your current branch
git status|grep deleted|cut -d " " -f 5 > deleted.deleteme&&git stash&&git checkout master&&cat d.d.d.d|xargs -t -I@ git --no-pager log -1 --format=%cd @&&git checkout - >/dev/null&&git stash apply >/dev/null&&rm d.d.d.d
# EXPLANATION
# 1. list all the deleted files in current branch (first 3 piped commands)
# 2. save them in a file called "deleted.deleteme" (output of 3rd command)
# 3. save their most recent commit dates back into "deleted.deleteme" by changing into the master branch and coming back (commands 4 thru 9)
# 4. cleanup by removing "deleted.deleteme"
WARNING: I hope you don't have a file called `d.d.d.d` as it will be deleted!
@tzaffi
tzaffi / pgpy_example.py
Last active September 23, 2021 19:11
PGPy - creating keys, encrypting and decrypting
from pgpy import PGPUID, PGPKey, PGPMessage
from pgpy.constants import (
PubKeyAlgorithm,
KeyFlags,
HashAlgorithm,
SymmetricKeyAlgorithm,
CompressionAlgorithm,
)
# 1. Recipient sets up user, and generates a key for that user