Skip to content

Instantly share code, notes, and snippets.

James Coglan jcoglan

Block or report user

Report or block jcoglan

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 rust-types.md

Rust types reference

Prelude

  • std::borrow::ToOwned
  • std::boxed::Box
  • std::clone::Clone
  • std::cmp::{PartialEq, PartialOrd, Eq, Ord}
  • std::convert::{AsRef, AsMut, Into, From}
  • std::default::Default
View blame.rb
require_relative "./base"
require_relative "../diff"
require_relative "../rev_list"
module Command
class Blame < Base
def run
@lines = []
@commits = []
View call_monitor.rb
require "set"
mods = Class.ancestors +
Method.ancestors +
UnboundMethod.ancestors
reserved = %i[
==
===
=~
View maze.txt
o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o---o o o---o o o o o o o o o o o o o o o o o o o o
| | | |
o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o---o---
View git-log-times.sh
#!/bin/bash
cd ~/src
dir="git-long-uninteresting-branch"
git init $dir > /dev/null
cd $dir
export GIT_COMMITTER_DATE="1600000000"
View water.txt
.................................................................................................|...............................................................#....#..................
........#........................................................................................|...............................................................#....#..................
........#.............#..........................................................................|...............................................................#....#..................
........#.............#..........................................................................|...............................................................#....#..................
........#.............#..........................................................................|...#....#......................................................#....#..................
........#.............#.......................................................................
View numbers.rb
module Pack
module Numbers
module VarIntLE
def self.write(size, shift)
bytes = []
mask = 2 ** shift - 1
until size <= mask
bytes << (0x80 | size & mask)
View superpermutation.rb
class SuperPermutation
CHARS = ('a'..'z').map(&:to_sym)
def initialize(size)
@size = size
@chars = CHARS.take(@size)
@used = {}
@index = Hash.new { |h, k| h[k] = [] }
@chars.permutation.each do |seq|
View folds.txt
rule Foldl-0 {
foldl $f $init ∅ = $init
}
rule Foldl-N {
$init $f $head = $init' / foldl $f $init' $tail = $res
------------------------------------------------------
foldl $f $init ($head $tail) = $res
}
View README.md

Haskell

There follows an extremely rough approximation to Haskell's type checker, written as a logic program. Mostly to explore type inference and syntactic sugar.

For the most part, we won't need a lot of syntactic checks in this implementation, but for terms with no internal structure, like variables and numbers, it's useful to specify their members.

You can’t perform that action at this time.