Skip to content

Instantly share code, notes, and snippets.

View JoeKarlsson's full-sized avatar
🏠
Working from home

Joe Karlsson JoeKarlsson

🏠
Working from home
View GitHub Profile
@JoeKarlsson
JoeKarlsson / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
var fs = require('fs'); // require is a special function provided by node
var path = require('path'); //require path function provided by node
var pathName = process.argv[2]; //full path name passed in as array
var ext = process.argv[3]; //extenstion we need to filter array by passed in as string
var filteredList = undefined; //Global variable. We do not know the file type, so I set to undefined.
function filteredLS(callback) {
fs.readdir(pathName, function doneReading(err, files) { //Async node call. Pass in pathname and async function
@JoeKarlsson
JoeKarlsson / stack-challenge.md
Last active September 4, 2015 20:19 — forked from jaywon/stack-challenge.md
Use a Linked List to simulate a stack trace

###Console History Sim Stack Trace Challenge

Using a linked list, we are going to demonstrate a use case for a linked list and simulate a stack like you see in a stack trace that replays the history of what we typed.

  1. Add a text box to an HTML page and a 2 buttons, save and dump.
  2. Every time the user clicks the first button to save, we are going to save the text input to our linked list as the most recent node or head.
  3. Whenever someone clicks the dump button we are going to dump out all of the input they've typed in to that point from most recent to oldest. This should be written as HTML to the page.
@JoeKarlsson
JoeKarlsson / README.md
Last active September 16, 2015 01:08 — forked from jaywon/README.md
JavaScript OOP Reflector

##Your Challenge Reflection is a common utility in Object Oriented languages for inspecting classes and deriving information about what properties/methods they expose and other classes they inherit from. We will be writing our own JavaScript reflector today!

We are going to write a simple utility that will inspect a given object, and tell us about the object and it's inheritance chain.

###Your Tasks

  1. Create 3 classes:
  • User
  • GroupUser
  • SuperUser
@JoeKarlsson
JoeKarlsson / Missile.js
Last active September 14, 2016 02:23
ES6 OOP Example
'use strict'
const Rocket = require('./Rocket.js');
module.exports = class Missle extends Rocket {
constructor( speed, year ) {
super('Mach 10', 'North Korea', year)
this._speed = speed;
}
@JoeKarlsson
JoeKarlsson / palindromic.js
Created December 10, 2015 20:38
Solution for Palindromic Number Generator - https://gist.github.com/sgnl/db8a16af1747ba8f4217
function palindromic(number, steps) {
var returnObj = {};
steps = steps || '0';
// check if number passed in is palindrome
var numberStrReversed = number.toString().split("").reverse().join("");
if (number.toString() === numberStrReversed) {
returnObj.value = number;
returnObj.steps = parseInt(steps);
@JoeKarlsson
JoeKarlsson / js-constructors.js
Created December 11, 2015 00:21
invoke function from js-constructors.js
/**
* @method invoke
*
* Allows the spellcaster to cast spells.
* The first parameter should either be a `Spell` or `DamageSpell`.
* If it is a `DamageSpell`, the second parameter should be a `Spellcaster`.
* The function should return `false` if the above conditions are not satisfied.
*
* You should use `instanceof` to check for these conditions.
*
@JoeKarlsson
JoeKarlsson / sorting-algorithms.md
Last active June 15, 2020 01:21
Five popular sorting algorithms implemented manually and visualized with DOM manipulation
@JoeKarlsson
JoeKarlsson / pig-latin-translator.md
Last active November 27, 2023 04:15
Pig Latin Translator

Pig Latin Translator

A new alien species has moved to earth and they only speak pig-latin! The president has called you and says that they need your help!

Your mission is to create a module that is capable of taking an english sentence and translating it into pig latin. We must also be able to understand what our new alien friends are saying, so the module needs to be able to convert pig-latin back to english.

TL;DR: Create a module that translates a string into Pig Latin, and is capable of translating Pig Latin back into in the native language.

How Pig Latin Works

Basically, the Pig Latin system used here works as follows:

@JoeKarlsson
JoeKarlsson / algorithm_tests.md
Last active December 17, 2015 01:33
Write tests for your algorithm

###Test...Solve...Refactor...Commit

###The Challenge This is only a test

We are going to be doing a quickfire challenge to solve the following objectives in a short amount of time in the following order:

  1. In your algorithm repository, create a new branch called 'tests'
  2. Setup mocha/chai to be our testing framework
  3. Write tests for the algorithm we are working on (Quicksort, Bubblesort, Mergesort, etc.)