Skip to content

Instantly share code, notes, and snippets.

@martinandersen3d
martinandersen3d / CheckType.js
Last active January 29, 2020 14:25
javascript type checking mini library
/*
Check Type, is used in the beginning of a method.
Here we will check that the Method Parameters is of the correct type.
*/
class Check {
constructor(obj, errorCode) {
this.obj = obj;
@martinandersen3d
martinandersen3d / settings.json
Created December 14, 2019 00:13 — forked from lighthouse-dev/settings.json
vs-code settings.json inspiration fra anden bruger
{
// "workbench.iconTheme": "material-icon-theme",
"window.zoomLevel": 0,
// "materialTheme.fixIconsRunning": false,
// "[javascript]": {
// "editor.tabSize": 2
// },
// "[html]": {
// "editor.tabSize": 2
@martinandersen3d
martinandersen3d / VS Code JSON Settings
Created December 14, 2019 05:59 — forked from uysalserkan/VS Code JSON Settings
JSON settings instpiration
{
// Most Commonly Used
// Controls auto save of dirty files. Accepted values: 'off', 'afterDelay', 'onFocusChange' (editor loses focus), 'onWindowChange' (window loses focus). If set to 'afterDelay', you can configure the delay in 'files.autoSaveDelay'.
"files.autoSave": "off",
// Controls the font size in pixels.
"editor.fontSize": 14,
// Controls the font family.
# Git aliases
alias gs="git status"
alias ga="git add"
alias gaa="git add ."
alias gc="git commit"
alias gp="git push"
alias gpl="git pull"
alias gcm="git commit -m"
alias gl="git log"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>HTML inputmode attribute</title>
<style>
* {
padding: 0;
//Array custom sort() function
let log = console.log;
let movies = ['Star Wars', 'Star Trek', 'Jaws', 'Jurassic Park', 'Gross Pointe Blank', 'Eternal Sunshine of the Spotless Mind', 'Memento', 'Dog Soldiers', 'The Host', 'Gran Torino', 'Close Encounters of the Third Kind', 'Good Will Hunting', 'Layer Cake', 'Casino Royale', 'Almost Famous'];
let numbers = [40,16,67,345,22,23,142,63,59,283];
let people = [
{"id":123, "name":"Rick Deckard", "email":"rick@bladerunner.org"},
{"id":456, "name":"Roy Batty", "email":"roy@replicant.io"},
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>LuxonJS The Modern MomentJS</title>
<meta name="viewport" content="width=device-width">
<style>
#output{
font-size: 2rem;
}
//Array reduce method
//reduce all the values in an array into a single result
// Uses a callback function just like map, forEach, filter, etc
// array.reduce(callback, initialValue)
// also has a second parameter which is an initialValue
let numbers = [12, 34, 56, 78, 91];
//find the sum of all the numbers
@martinandersen3d
martinandersen3d / gist:5b4425d08acd8e9eb8123180f446bfda
Last active December 26, 2019 02:19 — forked from henriquemoody/http-status-codes.php
List of HTTP status codes in PHP
<?php
/**
* Content from http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
**/
return array(
100 => 'Continue',
101 => 'Switching Protocols',
102 => 'Processing', // WebDAV; RFC 2518
200 => 'OK',
@martinandersen3d
martinandersen3d / vscode hotkeys generate PNG HTLM PDF from hotkeys.js
Last active January 10, 2020 01:43
vscode hotkeys - Generate PNG, HTML, PDF from your custom hotkeys in vscode
const fs = require('fs');
const strip = require('strip-comments');
const puppeteer = require('puppeteer');
var content = fs.readFileSync('keybindings.json', 'utf8');
let removeComment = strip(content);
// Remove trailing commas in json:
let regex = /\,(?!\s*?[\{\[\"\'\w])/g;
let input = removeComment; // this is the initial string of data