Skip to content

Instantly share code, notes, and snippets.

View brandonpayton's full-sized avatar

Brandon Payton brandonpayton

View GitHub Profile
@aidvu
aidvu / Makefile
Last active March 21, 2023 21:06
Modify ping reply TTL with XDP
KDIR ?= /lib/modules/$(shell uname -r)
SDIR ?= $(KDIR)/source
CLANG ?= clang
LLC ?= llc
#ARCH := $(subst x86_64,x86,$(shell arch))
ARCH := x86
BIN := modify-ping-ttl.o
CLANG_FLAGS = -I. -I$(SDIR)/arch/$(ARCH)/include \
-I$(SDIR)/arch/$(ARCH)/include/generated \
@westonruter
westonruter / add-customize-changeset-locked-notification-dismiss-button.js
Last active November 21, 2017 05:03
Add button to dismiss changeset locked notification in Customizer without taking over the lock from the other user
wp.customize.notifications.bind( 'add', function( notification ) {
if ( 'changeset_locked' === notification.code ) {
notification.render = (function( render ) {
return function() {
var li = render.call( notification ), button;
button = jQuery( '<button type="button" class="button button-secondary">Dismiss</button>' );
button.on( 'click', function() {
notification.parent.remove( notification.code );
} );
li.find( '.action-buttons' ).append( button );

Motivation

  • expression-oriented programming one of the great advances of FP
  • expressions plug together like legos, making more malleable programming experience in-the-small

Examples

Write in an expression-oriented style, scoping variables as locally as possible:

import Network.Socket
import Control.Concurrent
import qualified System.IO as IO
type HandlerFunc = SockAddr -> String -> IO ()
serveLog :: String -- ^ Port number or name; 514 is default
-> HandlerFunc -- ^ Function to handle incoming messages
-> IO ()
serveLog port handlerfunc = withSocketsDo $