Skip to content

Instantly share code, notes, and snippets.

View mpj's full-sized avatar

Mattias Petter Johansson mpj

View GitHub Profile
@mpj
mpj / monad-stream-example.js
Last active September 14, 2022 06:42
This is the code from Monads - episode #21 of FunFunFunction (https://www.youtube.com/playlist?list=PL0zVEGEvSaeFSwPn06GKArptSxiP1Gff8)
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: https://cloud.google.com/translate/v2/getting_started
const apiKey =
'AIzaSyB4DyRHIsNhogQXmH16YKbZfR-lTXrQpq0'
const url =
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Intro to XState</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div id="box"></div>
@mpj
mpj / vanilla-hofs-with-reduce.js
Created February 3, 2020 14:16
code from episode
const isMoreThan5 = number => number > 5
const numbers = [ 2, 4, 8, 9 ]
const result = filter(isMoreThan5, numbers)
const addThree = number => number + 3
const result = map(addThree, numbers)
result
function map(transform, array) {
const initialArray = []
const mapReducer = (mappedArray, currentItem) =>
# handy little script i wrote to compress the enourmous image folder my girlfriend had,
sudo port install ImageMagick
find . -type f -name '*.jp*' -exec mogrify -resize '1280>' -compress jpeg -quality 85 {} \;
someOrder = {
items: [
{ name: 'Dragon food' , price: 8, quantity: 8 },
{ name: 'Dragon cage (small)', price: 800, quantity: 2 },
{ name: 'Shipping', price: 40, shipping: true }
]
}
orderTotal = (order) => {
totalNormalItems =
@mpj
mpj / README.md
Last active December 12, 2020 00:15
REALLY quick and dirty static file dev server

Usage

node dirtyserve.js

The point your browser to

http://localhost:3000/myfile.xxx

and the server will try to serve that file from the local server.

@mpj
mpj / 1hello.md
Last active May 29, 2020 02:52
Arrow functions
@mpj
mpj / draft.md
Last active April 23, 2020 16:49
Feedback for episode draft: 7 critical traits for a normal programmer

7 critical traits for a normal programmer

EARLY DRAFT FOR NEXT EPISODE, PLEASE PROVIDE FEEDBACK

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: [https://twitter.com/mpjme/status/855691565460848640]

@mpj
mpj / code2.jsx
Last active March 24, 2020 16:57
code2.jsx
import React, { useEffect, useState } from 'react';
import logo from './logo.svg';
import './App.css';
import { Map, TileLayer, Marker, Popup, Tooltip } from 'react-leaflet'
import tmi from 'tmi.js'
// https://nominatim.openstreetmap.org/search?format=json&q=stockholm,sweden
// Firebase App (the core Firebase SDK) is always required and must be listed first
import * as firebase from "firebase/app"
@mpj
mpj / code.jsx
Created March 23, 2020 16:49
Code for episode
import React, { useEffect, useState } from 'react';
import logo from './logo.svg';
import './App.css';
import { Map, TileLayer, Marker, Popup, Tooltip } from 'react-leaflet'
import tmi from 'tmi.js'
// !<command> <args> ? !register Sweden ?
// !checkin SE I am streaming