Skip to content

Instantly share code, notes, and snippets.

Avatar

Isak La Fleur Engdahl isaklafleur

View GitHub Profile
@isaklafleur
isaklafleur / factorialFunction.js
Created Oct 9, 2017
An example of Recursion. A factorial function is defined as: factorial of n is n times the factorial of n - 1, except for factorial of 0 which is 1. Therefore, we can write this as:
View factorialFunction.js
function factorial(number) {
if (number === 0) { return 1; }
return number * factorial(number - 1);
}
// factorial(0) -> 1
// factorial(1) -> 1
// factorial(2) -> 2
// factorial(3) -> 6
// factorial(4) -> 24
@isaklafleur
isaklafleur / solution.js
Last active Oct 9, 2017
Week 1 - Day 1 (JS Basic Algorithms)
View solution.js
// Name and inputs
const hacker1 = "Isak";
const hacker2 = prompt("What is the name of the navigator?");
console.log(`The driver's name is ${hacker1}`);
console.log(`The navigator's name is ${hacker2}`);
// Conditionals
if (hacker1.length > hacker2.length) {
console.log(
@isaklafleur
isaklafleur / MongoDB Cheat Sheet
Last active Apr 25, 2017
MongoDB Cheat Sheet
View MongoDB Cheat Sheet
// use mongoimport to import a data in JSON format into the database
$ mongoimport --db pacman --collection enemies --file pacman.json
$ mongoimport --db restaurants --collection restaurants --drop --file ~/downloads/primer-dataset.json
// Insert one document in the database
$ db.enemies.insertOne({ name: 'pacman' });
// can use javascript in MongoDB
$ const t = { name: 'Isak' }
$ db.enemies.insertOne(t);
@isaklafleur
isaklafleur / App.css
Last active Apr 21, 2017
Build a JSX Live Compiler as a React Component
View App.css
body {
margin: 0;
padding: 0;
font-family: monospace;
}
header {
display: block;
height: 5vh;
overflow: auto;
@isaklafleur
isaklafleur / My linux & mac command line Cheat Sheet
Last active Apr 20, 2017
My linux/mac command line Cheat Sheet
View My linux & mac command line Cheat Sheet
// remove a non empty folder
$ rm -rf lampp
View My Node.js Cheat Sheet
Full documentation: https://docs.npmjs.com/getting-started/
// Listing globally installed NPM packages and version
npm list -g --depth=0
// Global packages can be uninstalled with
npm uninstall -g <package>
ex. npm uninstall -g jshint
@isaklafleur
isaklafleur / index.html
Created Apr 3, 2017
My CSS & HTML Cheat Cheat
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="style.css" rel="stylesheet">
</head>
<body>
<h1 id="unique">Unique ID</h1>