Skip to content

Instantly share code, notes, and snippets.

Christopher Hebert chebert

Block or report user

Report or block chebert

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
@chebert
chebert / LICENSE-CC-BY-4.0.md
Created Jan 28, 2020
License for public Gists for Chebert.
View LICENSE-CC-BY-4.0.md

LICENSE-CC-BY-4.0.md

UNLESS OTHERWISE NOTED, THE CONTENTS OF THESE PUBLIC GISTS ARE LICENSED UNDER THE CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE.

https://creativecommons.org/licenses/by/4.0/ Approved for Free Cultural Works

License Summary of CC-BY 4.0 International

This section is a human-readable summary of (and not a substitute for) the full license included below.

@chebert
chebert / pacman.c
Created Jun 30, 2018
Pacman in C using NCURSES
View pacman.c
/*
map ,g :!clang -DDEBUG % -o %:r -lncurses && ./%:r <CR>
gcc pacman.c -o pacman -lncurses
./pacman
*/
/*
* TODO
* minor: ghosts should go all the way to their bottom positions (TILE_CENTER)
@chebert
chebert / freecell.c
Created Jun 30, 2018
Freecell in C using NCURSES
View freecell.c
/*
map ,g :!gcc % -o %:r -lncurses && ./%:r <CR>
gcc freecell.c -o freecell -lncurses
./freecell
*/
#include <assert.h>
#include <stdint.h>
#include <ncurses.h>
@chebert
chebert / tetris.c
Created Jun 30, 2018
Tetris in C using NCURSES
View tetris.c
/*
map <leader>g :!gcc % -o %:r -lncurses && ./%:r <CR>
gcc tetris.c -o tetris -lncurses
./tetris
*/
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
View machine-state.lisp
(defrecord machine-state
;; Registers
pc sp a b c d e f h l
;; Memory Regions
video-ram ext-ram work-ram sprite-ram mmap-i/o z-ram
;; Debug Fields
;; Lists of what the last instruction changed
affected-regs affected-flags memory-updates
;; The instruction that was just disassembled this step.
@chebert
chebert / lisp.el
Created Sep 3, 2017
chebert-eval-print-last-sexp
View lisp.el
(defun multiline? (string)
(position ?\n string))
(defun multiline-comment (string)
(concat "#||\n" string "\n||#\n"))
;; Note: Redefining to send the error message too.
(defun chebert-eval-async (sexp &optional cont package)
"Evaluate EXPR on the superior Lisp and call CONT with the result."
(declare (indent 1))
@chebert
chebert / matrix.lisp
Last active Dec 27, 2019
Example of How Matrices could be implemented using Vectors In Lisp
View matrix.lisp
(defun make-vector (length elt) (make-array length :initial-element elt))
(defun vector-elt (vec i) (aref vec i))
(defun vector-set! (vec i elt) (setf (aref vec i) elt))
(defun matrix (m n vec) (list m n vec))
(defun matrix-m (m) (first m))
(defun matrix-n (m) (second m))
(defun matrix-vec (m) (third m))
(defun num-elements (m n)
@chebert
chebert / pacman.lisp
Created Sep 30, 2015
pacman, ncurses, lisp
View pacman.lisp
(defpackage :pacman
(:use :cl))
(in-package :pacman)
;;; The charms/ll library contains all of the FFI bindings to Ncurses.
(ql:quickload :cl-charms)
;;; Here are all of the functions I'll be using from Ncurses.
(import '(
@chebert
chebert / pacman.c
Last active Apr 26, 2018
pacman ncurses
View pacman.c
/*
map ,g :!gcc % -o %:r -lncurses && ./%:r <CR>
*/
#include <assert.h>
#include <stdint.h>
#include <ncurses.h>
#include <sys/time.h>
#include <time.h>
#include <stdlib.h>
@chebert
chebert / SendToTmux
Last active Aug 29, 2015
Send keys to another buffer in a tmux session. Pretty handy.
View SendToTmux
nmap <silent> <leader>s :set opfunc=SendToTmux<CR>g@
nmap <silent> <leader>ss :call SendLineToTmux()<CR>
vmap <silent> <leader>s :<C-U>call SendToTmux(visualmode(), 1)<CR>
function! SendLineToTmux()
let line = line('.')
let col = col('.')
" TODO: this assumes the leader is ','
:normal 0,s$""
You can’t perform that action at this time.