Skip to content

Instantly share code, notes, and snippets.

Avatar

Matt Foxx FoxxMD

View GitHub Profile
@tomhicks
tomhicks / plink-plonk.js
Last active Dec 1, 2020
Listen to your web pages
View plink-plonk.js
@Jobarion
Jobarion / THX.java
Last active Jul 21, 2019
THX Deep Note Generator
View THX.java
/*
MIT License
Copyright (c) 2018 Jonas Balsfulland
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@kitze
kitze / store.js
Created Jan 24, 2018
simplified redux
View store.js
import produce from 'immer';
import {createStore} from 'redux';
const handleActions = (actionsMap, defaultState) => (
state = defaultState,
{type, payload}
) =>
produce(state, draft => {
const action = actionsMap[type];
action && action(draft, payload);
@ljharb
ljharb / array_iteration_thoughts.md
Last active Nov 10, 2020
Array iteration methods summarized
View array_iteration_thoughts.md

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it much simpler to think about both the old list and the new one, what they contain, and

@andrewmclagan
andrewmclagan / Normalizr.php
Last active Aug 3, 2018
Normalized fractal response
View Normalizr.php
<?php
namespace App\Http;
use League\Fractal\Pagination\CursorInterface;
use League\Fractal\Pagination\PaginatorInterface;
use League\Fractal\Resource\ResourceInterface;
use League\Fractal\Serializer\ArraySerializer;
class Normalizr extends ArraySerializer
@cyrusboadway
cyrusboadway / google-domains-dynamic-dns-update.sh
Created Feb 20, 2016
Script to update a Google Domains DNS record
View google-domains-dynamic-dns-update.sh
#!/bin/bash
### Google Domains provides an API to update a DNS "Syntheitc record". This script
### updates a record with the script-runner's public IP, as resolved using a DNS
### lookup.
###
### Google Dynamic DNS: https://support.google.com/domains/answer/6147083
### Synthetic Records: https://support.google.com/domains/answer/6069273
USERNAME=""
View reduce-node-modules-bloat.md

How you can help reduce node_modules bloat

This recent reddit thread reveals discontent among the web development community about the sheer volume of stuff in a typical node_modules dir. 140MB in this case!

Is it a design flaw in npm?

Opinions in the thread varied from "I'm surprised npm even works" to "everything is fine". I'm not going to offer an opinion, just these two observations:

  1. node_modules dirs typically do contain lots of stuff that doesn't need to be there.
  2. The latest version mitigates overall size by flattening the dependency tree, but some of the bloat is beyond npm's control.
@kentcdodds
kentcdodds / JavaScript.xml
Created Aug 3, 2015
Some of my WebStorm live templates
View JavaScript.xml
<templateSet group="JavaScript">
<template name="us" value="'use strict';&#10;$END$" description="Inserts 'use strict' statement" toReformat="true" toShortenFQNames="true">
<context />
</template>
<template name="f" value="function $NAME$($PARAM$) {&#10; $END$&#10;}" description="Inserts function expression" toReformat="true" toShortenFQNames="true">
<variable name="NAME" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="PARAM" expression="" defaultValue="&quot;&quot;" alwaysStopAt="true" />
<context>
<option name="JAVA_SCRIPT" value="true" />
</context>
View answer.md

What is the appeal of dynamically-typed languages?

Kris Nuttycombe asks:

I genuinely wish I understood the appeal of unityped languages better. Can someone who really knows both well-typed and unityped explain?

I think the terms well-typed and unityped are a bit of question-begging here (you might as well say good-typed versus bad-typed), so instead I will say statically-typed and dynamically-typed.

I'm going to approach this article using Scala to stand-in for static typing and Python for dynamic typing. I feel like I am credibly proficient both languages: I don't currently write a lot of Python, but I still have affection for the language, and have probably written hundreds of thousands of lines of Python code over the years.

You can’t perform that action at this time.