Skip to content

Instantly share code, notes, and snippets.

@zinthose
zinthose / TGUPxxxx.nsi
Created December 9, 2011 14:38
Repackage of TGUP using NSIS
/*
NSIS Package Code originally developed by Dane Robert Jones <danerjones@gmail.com>
NSIS is an Open Source Software Packaging Suite available at: http://nsis.sourceforge.net/Main_Page
*/
!define VERSION_MA 0 # <-- The Major version number (DEFAULT: 0)
!define VERSION_MI 18 # <-- The Minor version mumber (DEFAULT: 0)
!define UPX "${NSISDIR}\Tools\upx.exe" # <-- Path to UPX (If not defined UPX will not be used)
!define ICON_PATH "inst.ico" # <-- Path to icon used (If not defined the default NSIS icon will be used)
@zinthose
zinthose / fix_stupid.py
Last active March 20, 2020 17:14
Just something I threw together to help a team I work with deal with stupid people submitting log files.
import re, os, sys
# This simple script will scan all log files in a folder to verify the name matches the player name used in the game.
# If not, the script will list the logs that don't match the name and prompt to correct using the log specified name.
path_to_check = os.getcwd() # <-- Default is current direcctory, this should be changed if the script is not run in the same folder as the log files.
log_file_extention = ".log"
regular_expression_to_get_actual_in_game_name = r"playerName = (\w+)"
@zinthose
zinthose / StemLeaf.bas
Last active October 5, 2021 01:59
Simple VBA function for use in Excel to create Stem-Leaf plots.
Public Enum StemType
StemHigh = 1
StemLow = -1
StemDefault = 0
End Enum
Public Enum StemSort
StemSortNone = 0
@zinthose
zinthose / text2Value.ts
Last active April 9, 2021 04:17
Simple TypeScript method that can take a text value of a number and convert it into a number value. Script is not particularly optimized or maybe not even an ideal solution but it fit my purposes for a particular project.
/**
* Method takes a string representaion of a positive number from -999,999,999,999,999 to 999,999,999,999,999 and converts into a number.
*
* @example
* ```
* const txtValue = "negative nine hundred and ninety nine trillion nine hundred and ninety nine billion nine hundred and ninety nine million nine hundred and ninety nine thousand nine hundred and ninety nine";
* console.log( text2Value(txtValue) );
* > -999999999999999
* ```
* @param text String representation of positive number
@zinthose
zinthose / es6-mode.js
Last active April 15, 2021 02:03 — forked from tejashah88/es6-mode.js
An ES6 function to compute the mode(s) of an array. All modes found will return sorted in ascending order.
// Credits go to @Anjuna5 for original code: https://stackoverflow.com/a/39838257/9779148
const mode = arr => [...new Set(arr)]
.map(value => [value, arr.filter((v) => v === value).length])
.sort((a,b) => b[1] - a[1])
.filter((v, i, a) => v[1] === a[0][1])
.map(v => v[0])
.sort((a,b) => a - b);
@zinthose
zinthose / redtext.js
Last active October 10, 2021 01:49
Simple single line Javascript command you can paste into the WebDev console of your browser to get the "Red Text" values from a webassign.net assignment page. The data is newline delimited so it can be easily pasted into excel for further analysis.
// Use this one for pasting into a single column
copy(Array.from(document.querySelectorAll("div.qws.initialized.focused font[color=red]")).map(e=>e.textContent).join("\n"));
// Use this one for pasting into a single row
copy(Array.from(document.querySelectorAll("div.qws.initialized.focused font[color=red]")).map(e=>e.textContent).join("\t"));
// OTHER: I've used this for wierd outliers but the output data is kinda suspect.
copy([...[...document.querySelectorAll('div.qws.initialized.focused *')].filter(el => (el.childElementCount === 0 && el.innerText !== "" && getComputedStyle(el).color === 'rgb(181, 33, 32)'))].map(e=>e.textContent).join("\n"));
@zinthose
zinthose / redtext.userscript.js
Last active November 13, 2021 20:44
Tamper Monkey UserScript to extract RedText values from WebAssign assignment pages. Just press CTRL+SPACE!
// ==UserScript==
// @name Get RedText
// @namespace https://gist.github.com/0xFireball/0b0673fd7801de9f82278725d1250cbb
// @version 0.3
// @description Get's the text text from the WebAssign assignment pages and places them into the clipboard tab delimited. This is good for pasting values directly into excel.
// @author Dane Jones
// @require https://code.jquery.com/jquery-2.1.4.min.js
// @require https://raw.githubusercontent.com/kamranahmedse/jquery-toast-plugin/bd761d335919369ed5a27d1899e306df81de44b8/dist/jquery.toast.min.js
// @match https://www.webassign.net/web/*
// @icon https://www.google.com/s2/favicons?domain=webassign.net
@zinthose
zinthose / nextBusinessDay.py
Created December 23, 2021 01:32
Gets the next business day taking into account holidays.
from datetime import datetime, timedelta
import holidays
def nextBusinessDay(today=None, additional_offset=0, skip_holidays = True, format=r"%m/%d/%Y", holiday_settings = {'country':'US'}):
# pip install holidays
h_days = holidays.CountryHoliday(**holiday_settings)
# Get todays date if not initially set
if today==None:
today = datetime.now().date()
@zinthose
zinthose / buildURL.ts
Created December 26, 2021 23:02
Simple function to build a URL with URI parameters. Function allows for default values and a mechanism to require parameters.
/**
* Simple object that requires each keyed value to be a string.
*/
interface StringObject {[key: string]: string;}
/**
* Utility function to create a URL with parameters.
* @param url Base URL to build for.
* @param uri_values URI parameters to encode add to URL
@zinthose
zinthose / purgeValues.py
Last active January 18, 2023 05:22
Python function to recursively remove all matching `purgeTest` values from dictionaries and lists, and returns the result as a new dictionary or list. By default this will remove all `None`, empty string values, and empty lists. If the `preserve_list_structure` argument is set to True, then empty lists will not be removed to preserver list struc…
from typing import Callable
def purgeValues(value: dict | list, preserve_list_structure: bool = False, purgeTest: Callable[[any], any] = lambda x: x is None or (type(x) is str and len(x) == 0) or (type(x) is list and len(x) == 0)):
"""Purge values from a dictionary or list.
--------------------
Recursively remove all matching purgeTest values from dictionaries and lists, and returns
the result as a new dictionary or list.
By default this will remove all `None`, empty string values, and empty lists.
If the `preserve_list_structure` argument is set to True, then empty lists will not be