Skip to content

Instantly share code, notes, and snippets.

View LearningNerd's full-sized avatar

Liz Krane LearningNerd

View GitHub Profile
@LearningNerd
LearningNerd / codedark.vim
Last active March 26, 2019 18:50
My current vimrc file! A lot of this stuff is junk, some won't work out of the box (I forgot I DO have a plugin named AsyncRun and some stuff references a command line tool named grip), but maybe the key binding, search, autocompletion, and some of the other commands will be helpful :)
" Vim Code Dark (color scheme)
" with some customizations by Liz
" https://github.com/tomasiser/vim-code-dark
"
" NOTE: PUT THIS INSIDE A /colors FOLDER!!!
" My directory structure is like:
" .vim/ folder contains:
" vimrc (file, notice there's no . before the name)
" colors/ folder containing several color themes, including this one
@LearningNerd
LearningNerd / gamelogic.js
Last active April 6, 2023 19:36
Tic Tac Toe in the command line with NodeJS. Run with: node playtictactoe.js
module.exports = class TicTacToe {
constructor() {
this.board = [
["", "", ""],
["", "", ""],
["", "", ""]
];
this.currentPlayer = "X";
this.lastMove; // keep track of most recent move, for hasWon() check
@LearningNerd
LearningNerd / mob-coding-challenge.js
Created December 5, 2018 20:24
A saved mob programming session with Learn Teach Code!
// Type JavaScript here!
@LearningNerd
LearningNerd / generator-example.js
Created October 9, 2018 21:40
Just a quick example of a generator function, mostly borrowed from https://davidwalsh.name/async-generators
// Just a quick example of a generator function,
// mostly borrowed from https://davidwalsh.name/async-generators
function request(param) {
console.log("called request() with " + param);
makeAsyncCall( param, function(response){
it.next( response );
} );
}
@LearningNerd
LearningNerd / helper.js
Last active September 30, 2022 16:07
Using import/export for front-end modules, example 1
export function helper(x) {
console.log(x);
}
@LearningNerd
LearningNerd / recursionDrawingAttempt1.js
Last active July 21, 2018 05:37
Playing with recursion and ways to visualize it. And recursive tree traversal.
/////////////////////////////////////////////////////////////////////////////////////
// Using code from recursionExample.js, modifying it to try to visualize with p5js
// ToC:
// - animateRecursivelyAddToTen(sum, frameQueue)
// - drawFrame(frameQueue, currentIndex)
// - Params for drawing, global vars: counter for clicks, frameQueue
// - Set up event listener and run clickHandler > run drawFrame
// - Set up p5js (setup() and unused draw() function)
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
// GENERATING A RANDOM BINARY SEARCH TREE of a given height (numeric data)
// Next to-do: Generate a BST of a given number of nodes ?
/////////////////////////////////////////////////////////////////////////////////////
///////////////// SET UP AS STEP-THROUGH VERSION /////////////////////
document.addEventListener("click", drawRandomBST);
// PARAMETERS FOR FUNCTION:
@LearningNerd
LearningNerd / generateAndDrawTree1.js
Last active July 12, 2018 17:52
Working with binary trees and drawing them (p5js canvas library)
/////////////////////////////////////////////////////////////////////////////////////
// GENERATING AND DRAWING TREES OF n LEVELS -- for now, easy mode -- perfect binary trees
// Note: using p5js for drawing functions; didn't include p5js setup() here
/////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////
// SETUP / INITIALIZING VARIBALES
///////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
// Loops, and stepping through loops one step at a time, triggered by an external event
////////////////////////////////////////////////////////////////////////////////////////////////////
let testArray = [1,2,3,4,5];
////////////////////////////////////////////////////////////////////////////////////////////////////
// FIRST -- a simple while loop, for comparison:
////////////////////////////////////////////////////////////////////////////////////////////////////
let index = 0;
@LearningNerd
LearningNerd / replaceNumbersWithIncrement.js
Created June 9, 2018 05:21
This code snippet finds 1 to 2 digit numbers in a string matching a pattern (hard-coded for now), and replaces each number with itself + 1
/////////////////////////////////////////////////////////////////////////
// Replacing parts of a string with incremental numbers
////////////////////////////////////////////////////////////////////////
// This code snippet finds 1 to 2 digit numbers in a string matching a pattern
// (hard-coded for now), and replaces each number with itself + 1
// **** For a very specific use case, but easy enough to repurpose as needed :)
// Regex matches 1 to 2 digits preceded by the string ":
function replaceNumbersWithIncrement(givenString) {