Skip to content

Instantly share code, notes, and snippets.

View manderly's full-sized avatar

Mandi Burley manderly

View GitHub Profile
@manderly
manderly / prepare-commit-msg
Created February 9, 2015 18:20
Git hook: Automatically add branch name to the end of every commit message
# Automatically adds branch name to the end of every commit message. Handy for git/JIRA integrations.
# Make a copy of .git/hooks/prepare-commit-msg.sample in your repo and name the file prepare-commit-msg (remove "sample" extension)
# Paste the following into the file, save the file, and try it out in bash
NAME=$(git branch | grep '*' | sed 's/* //')
echo $(cat "$1") "$NAME" > "$1"
@manderly
manderly / leetcode22-november22.ts
Created November 12, 2022 13:46
Leetcode #22 Generate Parenthesis updated November 2022
function nextPermutation(previousPermutations: string[][]): string[] {
const nextPermutationsLength = previousPermutations.length;
let nextPermutations = [];
for (let i = 0; i < nextPermutationsLength; i++) {
// each of the previous permutations becomes our "inner" permutations (array)
const innerPermutations = previousPermutations[i];
// calculate how many outer permutations we need based on where we are in the loop
const outerPermutationsLength = nextPermutationsLength - 1 - i;
@manderly
manderly / heroGenerator.gd
Created December 17, 2018 02:39
Godot project hero generator code copied 12/16/2018
extends Node
#heroGenerator.gd
#makes a level 1 hero with random class and name
var nameGenerator = load("res://nameGenerator.gd").new()
var humanFemaleHeads = ["human_female_01.png", "human_female_02.png", "human_female_03.png", "human_female_04.png", "human_female_05.png", "human_female_06.png", "human_female_07.png", "human_female_08.png", "human_female_09.png", "human_female_10.png", "human_female_11.png"]
var humanMaleHeads = ["human_male_01.png", "human_male_02.png", "human_male_03.png", "human_male_04.png", "human_male_05.png", "human_male_06.png", "human_male_07.png", "human_male_08.png", "human_male_08.png", "human_male_09.png"]
var elfFemaleHeads = ["elf_female_01.png"]
func _ready():
@manderly
manderly / baseHero.gd
Created December 17, 2018 02:37
baseHero.gd
extends KinematicBody2D
#Hero properties - not governed by external spreadsheet data
#These are set when a hero is randomly generated in heroGenerator.gd
var heroID = -1
var heroName = "Default Name"
var heroClass = "NONE"
var level = -1
var xp = -1
var currentRoom = 0 #outside by default
@manderly
manderly / parsely.js
Created December 17, 2018 22:09
node js project that builds static data files for my Godot project
/* Parsely v.0.1
Developed for Guild Leader project (December 2018)
To use: place .json files in parsely/names, parsely/staticData, parsely/timedNodeData, etc.
In Terminal:
node parsely.js
Exported .gd files are placed directly in gameData folder.
@manderly
manderly / leetcode22.ts
Created August 23, 2021 15:29
Leetcode 22: Generate Parentheses
function generateParenthesis(n: number): string[] {
if (n === 1) { return ["()"]; }
let result = new Set<string>();
let previousCombos = generateParenthesis(n-1);
for (let i in previousCombos) {
let combo = previousCombos[i];
// wrap all previous entries in parens and put those in the set
@manderly
manderly / leetcode1101
Created August 1, 2021 16:58
Leetcode 1101 The Earliest Moment When Everyone Become Friends
function earliestAcq(logs: number[][], n: number): number {
logs.sort((a:number[], b:number[]) => {
return (a[0] - b[0]);
});
let mapOfSets = new Map();
// put every friend ID into its own individual set - O(n)
for (let i = 0; i < n; i++) {
let allPosts = [ {id: 123, name: "test post 1"},
{id: 456, name: "test post 2"}
];
let allReplies = [ {id: 1, replyTo: 123, name: 'reply 1', read: false},
{id: 2, replyTo: 123, name: 'reply 2', read: false},
{id: 3, replyTo: 456, name: 'reply 3', read: false}
];
// simulate a server response with 1s wait time
const getRepliesToPost = async (id: number) => {
// Closure example, sort of a companion to my JS example:
// https://repl.it/@MandiGrant/JSClosureExample
// combineNames is a function that returns a function.
var combineNames = (firstName) {
return (lastName) => firstName + ' ' + lastName;
};
/* If you call it like this,