Skip to content

Instantly share code, notes, and snippets.

View isaklafleur's full-sized avatar

Isak La Fleur Engdahl isaklafleur

  • Spain, Sweden, Brazil
View GitHub Profile
@isaklafleur
isaklafleur / factorialFunction.js
Created October 9, 2017 21:02
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:
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 October 9, 2017 20:00
Week 1 - Day 1 (JS Basic Algorithms)
// 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 April 25, 2017 11:21
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 April 21, 2017 07:50
Build a JSX Live Compiler as a React Component
body {
margin: 0;
padding: 0;
font-family: monospace;
}
header {
display: block;
height: 5vh;
overflow: auto;
@isaklafleur
isaklafleur / React Cheat Sheet
Last active January 19, 2018 21:10
React Cheat Sheet
...
@isaklafleur
isaklafleur / My linux & mac command line Cheat Sheet
Last active April 20, 2017 11:32
My linux/mac command line Cheat Sheet
// remove a non empty folder
$ rm -rf lampp
@isaklafleur
isaklafleur / My Node.js Cheat Sheet
Last active April 20, 2017 11:52
My NPM 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 April 3, 2017 13:09
My CSS & HTML Cheat Cheat
<!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>
@isaklafleur
isaklafleur / My Git and GitHub Cheat Sheet
Last active April 21, 2017 07:50
My Git and GitHub Cheat Sheet
...