Skip to content

Instantly share code, notes, and snippets.

@heatherbooker
heatherbooker / jekyll-new
Last active Mar 9, 2017 — forked from xianny/jekyll-new
jekyll-new-post
View jekyll-new
#!/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
View linkedList.js
// 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: {}
};
View adjacencyList.js
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) {
View trie.js
const words = ['dark', 'dapper'];
let trie = [];
words.forEach(word => {
addToTrie(word, 0, trie);
});
View tree.js
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]) {
View tsv_file_parser.js
const fs = require('fs');
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
const tsvFileName = process.argv[2];
View setSolver.html
<!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()">
View deque.js
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;
}
}
View hackerRankSolution.js
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 Sep 7, 2016
Improved version of ticTacToe for command line
View computer.js
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]) {