Skip to content

Instantly share code, notes, and snippets.

@shawnlauzon
shawnlauzon / function_guesser.dart
Last active May 20, 2020 22:45
Brute force guesser of a function, simply applies each of the possible functions to get a final result
guessFunction([
MapEntry('𝜖', epsilon.rad),
MapEntry('α', st.angle().rad),
MapEntry('α', st.angle().rad),
MapEntry('𝜖', epsilon.rad)
]);
void guessFunction(List<MapEntry<String, num>> vals) {
final unaryOps = {
@shawnlauzon
shawnlauzon / GenPassword.groovy
Created April 24, 2012 18:43
Generate a password of the given size using any set of characters
int password_length = 12
if (args.size() > 0) {
password_length = args[0] as int
}
String validChars ="qwertyuiopasdfghjklzxcvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNM"
int maxIndex = validChars.length()
def rnd = new Random()
@shawnlauzon
shawnlauzon / convertStringToRegex
Created December 28, 2011 03:31
I wrote this to convert a string to a regular expression, since it was very similar. However I removed it because the algorithm they used was messed up.
/**
* Given the badgeLayout that is almost-regex, convert it to something that
* is actually regex.
*/
private void storeBadgeLayoutAsRegex(Context context, String str) {
// Given this:
// \02\02\02\0D\0A\03\1F\0D\0A{FIRSTNAME}\03\20\03{NICKNAME}\03\20\03{LASTNAME}\03\1F\0D\0A{TITLE}\03\1F\0D\0A{COMPANY}\03\1F\0D\0A{ADDRESS1}\03\1F\0D\0A{CITY}\03\20\03{STATE}\03\20\03{ZIPCODE}\03\1F\0D\0A{COUNTRY}\03\1F\0D\0A{PHONE}\03\1F\0D\0A{FAX}\03\1F\0D\0A{EMAIL}\03\1F\0D\0A\0D\0A\0D\0A\1A
// or
// {SHOW_CODE}^{BADGEID}^{LASTNAME}^{FIRSTNAME}^{TITLE}^{COMPANY}^{ADDRESS1}^{ADDRESS2}^{CITY}^{STATE}^{ZIPCODE}^{COUNTRY}^{PHONE}^{FAX}^{EMAIL}^{REG_TYPE}^{CATEGORY}^{SPECIALTY}^{RANK}^{COMPANY2}^{ADDRESS3}^{ADDRESSTYPE}^