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 / 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 / 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.)

##The Challenge

Write a function that prints a nice Christmas tree of any size to the DOM with it's own star at the top using the shortest code possible. The tree star is an asterisk (*), the tree body is made out of 0 The tree must be at least 10 rows high, and at the bottom of the tree should be a trunk made of 2 pipe characters (|). Every row should be properly indented in the way that the previous row are centered over the next one. Any given row must have 2 more 0s than the previous, except for the first one that is the star and the second, which has only one 0. The result is something like this:

          *
          0
         000
 00000
@JoeKarlsson
JoeKarlsson / README.md
Created February 1, 2016 22:44 — forked from thgaskell/README.md
Basic Authentication with Passport

Basic Authentication with Passport

Basic authentication is one of the simplest authentication strategies because it doesn't require cookies, sessions, or even a login form! Instead, it uses HTTP headers which means credentials are transmitted on each request.

Installation

You will need to install passport and passport-http. The passport-http module is what allows you set up the Basic Authentication Scheme, in addition to a couple other authentication strategies.

$ npm install express passport passport-http --save

Debriefing Classroom Tips

Debrief by questions.

Helps us stay focused on the question and helps see if there are any patterns across cohorts.

Debrief in small groups then medium groups.

We usually debrief in small groups (groups of 4 with whom we observed), and then in combined groups (groups of 8 with 2 groups who saw some of the same classrooms at different times). Smaller networks may have a small-group followed by a whole-group structure.

Share talk time.

We often use a guideline like “everyone speaks once before anyone speaks twice” or “three before me” to help balance air time and hear from everyone.