Skip to content

Instantly share code, notes, and snippets.

@heatherbooker
heatherbooker / jekyll-new
Last active March 9, 2017 05:05 — forked from xianny/jekyll-new
jekyll-new-post
#!/bin/bash
# This script creates a new post or draft in jekyll with pre-filled front matter.
# Run `./script <some title for your post>` to generate a post.
# Use `-d` option (BEFORE your post title) for a draft.
FILEDIR="_posts/"
ISDRAFT=false
while getopts "d" opt; do
case $opt in
// To run: copy this file (or open it using the "Raw" button in the right-hand corner) and save it as linkedList.js
// Then in the terminal, run `node linkedList.js | less` to view output and compare expected to actual values.
class LinkedList {
constructor(firstItem) {
this.list = {
data: firstItem,
link: {}
};
const vertices = ['james', 'jon', 'joe', 'moe', 'moda'];
const vertices2 = ['jon', 'joe', 'moe'];
const vertices3 = ['james', 'joe', 'moda'];
const edges = [['james', 'jon'], ['james', 'joe'], ['jon', 'joe'], ['joe', 'moe'], ['moe', 'moda'], ['moda', 'james']];
const edges2 = [['jon','joe'], ['joe', 'moe'], ['moe', 'jon']];
const edges3 = [['james', 'joe'], ['moda', 'james']];
function createAdjacencyList(vertices, edges) {
const words = ['dark', 'dapper'];
let trie = [];
words.forEach(word => {
addToTrie(word, 0, trie);
});
const nodes = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'];
const tree = { node: nodes[0], children: [{}, {}] };
addNodes(tree.children[0], nodes[1], 1);
addNodes(tree.children[1], nodes[2], 2);
function addNodes(theRoot, node, index) {
if (!nodes[index]) {
const fs = require('fs');
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
const tsvFileName = process.argv[2];
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/tachyons/4.5.5/tachyons.min.css">
</head>
<body class="sans-serif center" style="width:80%; display: flex; justify-content: center; flex-wrap: wrap">
<div style="width: 100%">
<button class="bg-orange" style="margin: 30px; height:160px; width: 260px" onclick="playGame()">
function Queue(originalQueue) {
let queue = originalQueue || [];
function removeElement(q, i) {
const index = i === 'last' ? q.length - 1 : i;
if (!q[index + 1]) {
q[index] = undefined;
q.length = q.length - 1;
}
}
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});
@heatherbooker
heatherbooker / computer.js
Last active September 7, 2016 02:11
Improved version of ticTacToe for command line
function chooseMove(board) {
function getAvailableLocations() {
var availableLocations = [];
for (var location in board) {
// Since key === value is the default, if this is true,
// it means the spot has not yet been played.
if (location === board[location]) {