Skip to content

Instantly share code, notes, and snippets.

View ibarland's full-sized avatar

Ian Barland ibarland

  • Radford University
  • Blacksburg, VA, USA
View GitHub Profile
@ibarland
ibarland / ibarland-image.rkt
Created October 8, 2015 21:40
a 'rendered by racket' logo
#lang racket
(require 2htdp/image)
(provide (except-out (all-defined-out)
crop-text-image ; interface not yet finalized.
RX-DESCENDER
RX-ASCENDER
FONTS-WITH-SPACE-ABOVE
))
(module+ test
(require rackunit))
@ibarland
ibarland / digraphs.el
Created January 4, 2016 03:36
emacs-lisp for entering digraphs (C-c d followed by two normal characters, to insert a unicode character)
; For vim's digraphs (in .el form) see:
; https://raw.githubusercontent.com/JNRowe/emacs-configs/master/digraphs.el
; This file omits characters I'd never use, and also uses my own mnemonics.
(define-prefix-command 'digraph-map)
(global-set-key (kbd "C-c d") digraph-map)
(defun register-digraphs (key digraphs &rest _description)
"Given a list of 2-char digraphs, and a resulting (unicode) character, enable each digraph via prefix-command `digraph-map`"
(mapc (lambda (d) (define-key digraph-map d `(lambda () (interactive) (insert ,key)))) digraphs))
assert Arrays.deepEquals(
rotateMatrix( new String[][]{ {" ", "X", " "}
{" ", "X", "X"},
{" ", " ", " "} } ),
new String[][]{ {" ", " ", " "}
{" ", "X", "X"},
{" ", "X", " "} } )
@ibarland
ibarland / lists-algebraic.py
Last active April 1, 2018 19:56
Python implementation of lists, as approached by bootstrapworld.org / How to Design Programs -- that is as an "algebraic data type".
# Data definition: A list is either
# - [], OR
# put( {someItem}, {someList} ) (that is: one item "put" onto the front of some existing (slightly shorter) list)
#### helper functions for lists (which we represent internally as the python-builtin-list-type, unsurprisingly).
# put: T, list<T> → list<T> (constructor)
# Construct a new list, by adding one item to the front of an existing list
@ibarland
ibarland / languages-count-1-10.rkt
Last active August 14, 2018 18:10
The counting numbers 1-10, in various languages.
(define numbers-in-languages '#hash(
; (language . #[ 0 1 2 3 4 5 6 7 8 9 10 ])
(english . #[ zero one two three four five six seven eight nine ten ])
(spanish . #[ cero uno dos tres quatro cinqo seis siete ocho nueve dies ])
(italian . #[ zero uno due tre quattro cinque sei sette otto nove dieci ])
(german . #[ null eins zwei drei vier fuenf sechs sieben acht neun zehn ])
(dutch . #[ nul een twee drie vier vijf zes zeven acht negen tien ])
(croatian . #[ nula jedan dva tri cetiri pet sest sedam osam devet deset ])
(hungarian . #[ nulla egy ketto harom negy ot hat het nyolc kilenc tiz ])
(finnish . #[ nolla yksi kaksi kolme nelja viisi kuusi seitseman kahdeksan yhdeksan
@ibarland
ibarland / chownR_if.py
Last active May 30, 2019 21:52
chownR_If: For every file+dir rooted at `root`, if the owner of that file/dir is `targetUid`, then change the owner to `replacementUid`.
#! /usr/bin/env python3
import os
def chownIf(path, targetUid, replacementUid ):
"""If the owner of `path` is `targetUid`, then change the owner to `replacementUid`.
(UID's are numeric, not string.)
BUG -- this doesn't work: Also, if a link is owned by root(0), change it to `replacementUid` as well.
"""
ownerUid = os.stat(path).st_uid
@ibarland
ibarland / .emacs
Last active July 24, 2022 03:02
copy/paste for evil (emacs/vim) users
; Improve how OS's "copy" interacts with evil mode.
; We want yank'd/kill'd text to be added to the system clipboard, w/o explicit visual text-selection (via mouse-drag, say).
;
; The problem:
; While 'select-enable-clipboard' works find for non-evil emacs users,
; it interferes with evil/vim's `evil-change` and relatives:
; E.g. you want to replace a couple words with the clipboard,
; so you try typing "c2w cmd-V" -- BUT the c2w itself changes the clipboard
; (if `select-enable-clipboard` is set), so you end up pasting in exactly the two words
; you wanted to replace.
name: palindrome
source code: |
# https://turingmachine.io/ can run this TM format.
# Starting with a^m b^n where m>n, compute a^m b^m
# (that is: add b's at the end, to end up with equal a's,b's.)
# From Rich (Ch17a slides, slide 13)
#
input: '_aaaabb'
blank: '_' # or try: '␣' '❏'
start state: 1
@ibarland
ibarland / tm-dup.yaml
Last active November 4, 2020 12:08
A TM to duplicate a string
name: divisible by 3
source code: |-
# A TM to duplicate a string.
# (That is, compute f(w) = ww.)
#
# @author: ibarland@radford.edu
# run this at: https://turingmachine.io/?import-gist=7732e683354339c9993fb0fe5390af90
# assignment: https://www.radford.edu/itec420/2020fall-ibarland/Homeworks/hw06.html
#
input: 'abbab'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.