Skip to content

Instantly share code, notes, and snippets.

@pmwhite
pmwhite / Makefile
Created September 24, 2018 12:39
LSP C Programming
hw1WriteData: hw1WriteData.c
gcc -o hw1WriteData hw1WriteData.c
hw1ReadData: hw1ReadData.c
gcc -o hw1ReadData hw1ReadData.c
@pmwhite
pmwhite / passmanure.sh
Last active February 4, 2018 22:55
A simple passmenu script which supports username fields
shopt -s nullglob globstar
# settings
typeDelay=30
user=0
while [ -n "$1" ]; do
case "$1" in
--user) user=1; shift;;
*) break;;
@pmwhite
pmwhite / glob.txt
Created January 31, 2018 20:11
Why is normal vim here?
/home/philip λ>readlink -f $(which vim)
/nix/store/qi7n9xamd2gw2hzq5z3izj7mxskqylyy-vim-8.0.1150/bin/vim
/home/philip λ>readlink -f $(which test-vim)
/nix/store/sdzmghl3rjl51kc2vc2a7jw0n0kafqd0-test-vim/bin/test-vim
/home/philip λ>nix-env -e vim
/home/philip λ>readlink -f $(which vim)
/nix/store/qi7n9xamd2gw2hzq5z3izj7mxskqylyy-vim-8.0.1150/bin/vim
/home/philip λ>
@pmwhite
pmwhite / configuration.nix
Created January 31, 2018 19:46
NixOS configuration
{ config, pkgs, ... }:
{
imports = [ ./hardware-configuration.nix ];
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "mordor"; # Define your hostname.
@pmwhite
pmwhite / curry.js
Created July 22, 2017 01:30
javascript curryiing
function plus(x) {
return function(y) {
return x + y;
};
}
addFive = plus(5);
addFive(4); // 9
addFive(3); // 8
@pmwhite
pmwhite / fsfuncs.md
Created July 21, 2017 18:10
How F# functions work

How F# functions work.

Functions in functional programming take some time to get used to, but I want to try to simplify it a little.

Expressions

In functional programming, nearly everything is an expression. Although you must eventually do something, generally you should try to isolate those parts by themselves.

In a language like Java, if is a statement:

@pmwhite
pmwhite / macaulay.cpp
Last active May 29, 2017 16:56
Macaulay something
#include <iostream>
using namespace std;
class Pascal {
public:
int row;
int column;
int value;
Pascal(int v, int r, int c) : value(v), row(r), column(c) { }
#include <vector>
struct SensorRange {
int first;
int last;
}
// Find the first and the last sensors that see something
SensorRange activeSensorRange(vector<bool> sensorData) {
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.IO;
using System.Threading;
namespace Air1SongTracker
{
struct Item
@pmwhite
pmwhite / HalfBakedGenericDataStructure.idr
Last active November 22, 2015 20:14
An attempt to make a combination between an extensible record and extensible union types with idris.
module Main
import Data.Vect
-- I'm modelling this after Edwin Brady's extensible records snippet - http://lpaste.net/104020
-- I tried to make a corresponding extensible union type.
-- It ended up morphing into a type that has a parameter that specifies how many
-- fields can be filled. In my head, this type should consume (subsume?) both
-- types.