Skip to content

Instantly share code, notes, and snippets.

View MattMS's full-sized avatar
🤔

Matt McKellar-Spence MattMS

🤔
View GitHub Profile
@MattMS
MattMS / MinimumWinForms.fs
Last active July 24, 2019 13:11
Minimum required for a WinForms application in F# in .NET Framework 4.7
open System
open System.Windows.Forms
[<STAThread>]
do
Application.EnableVisualStyles()
Application.Run(new Form())
@MattMS
MattMS / paragraphs.js
Last active June 25, 2019 09:43
Text to HTML conversion.
var split_p_and_br = s => s.trim().split(/\n\n/).map(s => s.replace(/\n/g, '<br />'))
var split_p = s => s.trim().split(/\n\n/).map(s => s.replace(/\n/g, ' '))
var join_p = p => p.join('</p><p>')
var fin = t => `<p>${t}</p>`
var a = `
hello
@MattMS
MattMS / not_redux.js
Last active May 25, 2019 02:35
Messing around with Ramda to create a state-changing thing.
/* Example of something that is inspired by Redux, but totally not a replacement for it.
This is NOT intended to be used in anything serious; go find a proper library instead.
[MIT licensed](https://opensource.org/licenses/MIT)
So do whatever you want with any or all of this but don't blame me for anything.
Copyright 2019 Matt McKellar-Spence
*/
const {append, cond, inc, join, lensIndex, lensPath, map, over, pathEq, pipe, prop, T, toPairs, toString} = require('ramda')
@MattMS
MattMS / h.py
Created May 12, 2019 09:16
Create HTML with Python
def _add_global(name, value):
globals()[name] = value
def _replace_underscore(text):
return text.replace('_', '-')
class h:
def __init__(self, *children, **attributes):
self.attributes = attributes
self.children = children
@MattMS
MattMS / eat.md
Last active March 21, 2019 12:34
Simplify calling curried functions.

Eat

Use eat to simplify calling curried functions.

You can rewrite a(b)(c) as eat(a, b, c).

CoffeeScript

eat = (curries...)-&gt;
@MattMS
MattMS / Python logger list.py
Created January 24, 2018 06:03
List the names of all loggers.
# Need to import at this level.
# Cannot `from logging.Logger.manager import loggerDict`.
import logging
print(sorted(logging.Logger.manager.loggerDict.keys()))
# https://mail.python.org/pipermail/python-list/2012-June/625343.html
# by Michael Hrivnak
@MattMS
MattMS / Docker_remove_untagged_Images.sh
Created November 13, 2017 07:47
Delete all Docker Images with no ("<none>") tag.
#!/bin/sh
docker images | awk '$2 == "<none>" {print $3}' | xargs docker rmi

Compose Express calls

compose = (calls)-> (req, res, next)->
	if calls.length
		calls[0] req, res, ->
			call = compose calls.slice 1
			call req, res, next
	else if next
		next()
@MattMS
MattMS / small_file_contents.fish
Last active July 21, 2017 02:16
Print file name (minus `.txt` extension), `=`, then file contents
#!/usr/bin/env fish
set ext '.txt'
for f in (ls | grep $ext)
echo (basename $f $ext)=(cat $f)
end
@MattMS
MattMS / Append to PATH.fish
Created July 13, 2017 04:10
Append to current folder to PATH in Fish Shell
set PATH $PATH .