Skip to content

Instantly share code, notes, and snippets.

@GarrisonJ
GarrisonJ / ROP.md
Last active September 16, 2019 21:35

ROP Guide (Draft V1)

The original Railway Oriented Programming (ROP) blogpost can be found here: https://fsharpforfunandprofit.com/rop/

Summary

  • ROP abstracts away error handling so we can pull it out of business logic
  • ROP helps us remember to handle errors by failing to compile when we forget
  • If you have a method than can fail, have it return a Result<T> instead
  • When your method succeeds return Success
@GarrisonJ
GarrisonJ / gist:49e1d144a279f503eb77
Created June 28, 2014 17:37
Simplenote Spellcheck
document.getElementById('txtarea').spellcheck = true;
#!/usr/bin/env ruby
require "socket"
require "openssl"
require "net/http"
require 'json'
# Variables
@help_msg = ""
@server = "irc.cat.pdx.edu"
@port = "6697"
#!/usr/bin/env ruby
require "socket"
require "openssl"
# Variables
@help_msg = ""
@server = "irc.cat.pdx.edu"
@port = "6697"
@nick = "spark"
@channel = "#robots"
@GarrisonJ
GarrisonJ / BayesTheorem.py
Created July 25, 2013 05:50
A simple Bayesian classifier written in python.
# Copyright (c) 2013, Garrison Jensen <garrison.jensen@gmail.com>
# All rights reserved.
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
class PyBay:
TokBad = {} # Bad tokens
TokGood = {} # Good tokens
TotalTok = 0 # Count of total tokens
BadTokCount = 0 # Count of bad tokens
GoodCount = 0.0 # Count of good strings
@GarrisonJ
GarrisonJ / fizzbuzz.lol
Created July 24, 2013 16:59
FizzBuzz in lolcode
OBTW
This code follows the LOLCODE 1.2 spec (http://lolcode.com/specs/1.2).
As of 2013/07/22 this code compiled using the online compiler at http://repl.it/languages/LOLCODE without issue.
TLDR
HAI
I HAS A VAR ITZ 1
IM IN YR LOOP UPPIN YR VAR TIL BOTH SAEM VAR AN 101
I HAS A FIFTEN ITZ MOD OF VAR AN 15
I HAS A FIVE ITZ MOD OF VAR AN 5
@GarrisonJ
GarrisonJ / FermatPrimalityTest.c
Last active December 18, 2015 16:18
FermatPrimalityTest
#include <time.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
// Test primality of number
//
// n - Number to test primality
// k - Number of times to test n
// If k <= 0 then the prime number theorem (1/ln(n)) is used
@GarrisonJ
GarrisonJ / spark.rb
Last active December 10, 2015 13:18 — forked from jcromartie/spark.rb
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# prints a sparkline in the terminal using the supplied list of numbers
# examples:
# spark.rb 10 20 30 100 90 80
# spark.rb 1 2 0.4 0.1 1.3 0.7
@ticks = %w[▁ ▂ ▃ ▄ ▅ ▆ ▇]
values = ARGV.map { |x| x.to_f }