Skip to content

Instantly share code, notes, and snippets.

Mattias Petter Johansson mpj

Block or report user

Report or block mpj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
mpj / example01.js
Created Aug 14, 2017
Code for the async/await episode of Fun Fun Function.
View example01.js
const response = await fetch(`${userId}`)
const data = await response.json()
return data.imageUrl

5 tips to quickly understand a new code base

When you work as a programmer, it’s only a small percentage of your time that is spent on writing code. The vast majority of your time is spent trying to understand code that is already written. Either code of others, or code that you yourself wrote a last year.

It’s especially tricky to get into a completely new codebase. You might when you start a new job or perhaps your team takes ownership of a new system.

I have done this a couple of times now, and I have a process for it now, and I figure that it might be interesting to some people to hear about it, and that is what we are going to explore today.

In case you’re new - this is FunFunFunction, a weekly show where we try to become more confident and excited about programming by exploring old wisdom, wild ideas and having fun. At the end of this episode, I’m going to ask to subscribe.

mpj /
Last active Nov 11, 2019
Feedback for episode draft: 7 critical traits for a normal programmer

7 critical traits for a normal programmer


This week I tweeted and tooted this question:

”What do you think are critical traits in a programmer? NOT to be super 10x or anything - just to feel good and function well professionally.”

Link to full threads here: []

mpj / afternoon.html
Last active Oct 25, 2019
Neural Vanilla Workshop
View afternoon.html
<!-- -->
<link href="style.css" rel="stylesheet" />
<div class="legend legendX">Scariness</div>
<div class="legend legendY">Actual power</div>
<canvas id="mycanvas" width="1000" height="1000"></canvas>

The future is here: Classless object-oriented programming in JavaScript.

Douglas Crockford, author of JavaScript: The Good parts, recently gave a talk called The Better Parts, where he demonstrates how he creates objects in JavaScript nowadays. He doesn't call his approach anything, but I will refer to it as Crockford Classless.

Crockford Classless is completely free of class, new, this, prototype and even Crockfords own invention Object.create.

I think it's really, really sleek, and this is what it looks like:

function dog(spec) {
mpj / 0-array.js
Last active Sep 23, 2019
Code to the video - "Map: Part 2 of Functional Programming in JavaScript"
View 0-array.js
var animals = [
{ name: 'Fluffykins', species: 'rabbit' },
{ name: 'Caro', species: 'dog' },
{ name: 'Hamilton', species: 'dog' },
{ name: 'Harold', species: 'fish' },
{ name: 'Ursula', species: 'cat' },
{ name: 'Jimmy', species: 'fish' }
mpj /
Created May 3, 2015
Java/Node socket client interaction
public class SocketServer {
public static final int port = 12345;
private ServerSocket server;
public void listen() {
mpj / rulething.html
Created Sep 10, 2016
Code from episode
View rulething.html
.row div {
height: 8px;
display: inline-block;
width: 8px;
.row {
background-color: red;
mpj / episode.js
Created Jan 15, 2017
Code from the "Dependency Injection Basics" episode of Fun Fun Function
View episode.js
const assert = require('assert')
function getAnimals(fetch, id) {
return fetch('' + id)
.then(response => response.json())
.then(data => data.results[0])
describe('getAnimals', () => {
it('calls fetch with the correct url', () => {
View monad-stream-example.js
const fetch = require('node-fetch')
const Bacon = require('baconjs')
function getInPortuguese(word) {
// Google Translate API is a paid (but dirt cheap) service. This is my key
// and will be disabled by the time the video is out. To generate your own,
// go here:
const apiKey =
const url =
You can’t perform that action at this time.