Skip to content

Instantly share code, notes, and snippets.

Matt McKellar-Spence MattMS

Block or report user

Report or block MattMS

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
View .vscode launch.json
{
"configurations": [
{
"args": [],
"console": "internalConsole",
"cwd": "${workspaceFolder}",
"name": ".NET Core Launch (console)",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.0/fsql.dll",
"request": "launch",
@MattMS
MattMS / Fabulous WPF with VS Code.md
Last active Aug 4, 2019
Debug Fabulous WPF with VS Code
View Fabulous WPF with VS Code.md

Debugging WPF application with VS Code

The following code is based on the SqueakyApp demo using Fabulous.XamarinForms

Files

The launch.json and tasks.json are placed inside the .vscode directory beside the sln file. These files are usually created by VS Code, but since there is not a .NET Framework option by default, you can choose the .NET Core options and edit the files after.

launch.json

View WinFormsWithLayout.fs
open System
open System.Drawing
open System.Windows.Forms
let addClickHandler click (button: Button) =
button.Click.AddHandler (new EventHandler (click))
button
let addControl (child: Control) (parent: Control) =
parent.Controls.Add child
@MattMS
MattMS / BasicWinForms.fs
Last active Jul 20, 2019
Basic F# WinForms demo
View BasicWinForms.fs
open System
open System.Windows.Forms
let makeButton label click =
let button = new Button()
button.Text <- label
let clickHandler = new EventHandler(click)
button.Click.AddHandler clickHandler
button
@MattMS
MattMS / MinimumWinForms.fs
Last active Jul 24, 2019
Minimum required for a WinForms application in F# in .NET Framework 4.7
View MinimumWinForms.fs
open System
open System.Windows.Forms
[<STAThread>]
do
Application.EnableVisualStyles()
Application.Run(new Form())
@MattMS
MattMS / paragraphs.js
Last active Jun 25, 2019
Text to HTML conversion.
View paragraphs.js
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
Messing around with Ramda to create a state-changing thing.
View not_redux.js
/* 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
Create HTML with Python
View h.py
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 Mar 21, 2019
Simplify calling curried functions.
View eat.md

Eat

Use eat to simplify calling curried functions.

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

CoffeeScript

eat = (curries...)->
@MattMS
MattMS / Python logger list.py
Created Jan 24, 2018
List the names of all loggers.
View Python logger list.py
# 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
You can’t perform that action at this time.