Skip to content

Instantly share code, notes, and snippets.

View rcook's full-sized avatar

Richard Cook rcook

View GitHub Profile
@rcook
rcook / LICENSE
Last active August 7, 2021 04:42 — forked from jbonney/crontab.sh
The MIT License (MIT)
Copyright (c) 2014 Richard Cook
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@rcook
rcook / .gitignore
Last active March 30, 2020 05:46
Simple demonstration of traits in C++: see http://www.clopenset.com/content/traits-c
cpp-traits
cpp-traits-v2
cpp-traits-v2.exe
@rcook
rcook / LICENSE
Last active March 30, 2020 05:46
Parse string representation of integer in Haskell
The MIT License (MIT)
Copyright (c) 2014 Richard Cook
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
#pragma once
template<typename T>
class Cons
{
public:
const T &value() const
{ return m_value; }
const Cons<T> *next() const
@rcook
rcook / main.cpp
Created July 7, 2014 16:03
C++ builder/named argument pattern with unique_ptr
#include <iostream>
#include <memory>
#include <vector>
// Backported from C++14
template<typename T, typename ...Args>
std::unique_ptr<T> make_unique(Args &&... args)
{
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}

Keybase proof

I hereby claim:

  • I am rcook on github.
  • I am rcook (https://keybase.io/rcook) on keybase.
  • I have a public key whose fingerprint is 94D7 D1B7 A37F E32B 0FA8 A803 FBD1 C693 7FBB E94E

To claim this, I am signing this object:

module Main where
import qualified Data.Map as Map
type Env = Map.Map String Expression
data ArithmeticExpression = Add Expression Expression
| Multiply Expression Expression
deriving Show
data Expression = Constant Integer
@rcook
rcook / After.java
Last active August 29, 2015 14:12
Visitor pattern (re)visited
import java.util.ArrayList;
import java.util.Iterator;
class EatingException extends Exception {
public EatingException() { }
}
interface FruitVisitor {
void visitApple(Apple apple) throws EatingException;
void visitOrange(Orange orange) throws EatingException;