Skip to content

Instantly share code, notes, and snippets.

@chebert
chebert / SendToTmux
Last active August 29, 2015 14:14
Send keys to another buffer in a tmux session. Pretty handy.
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$""
@chebert
chebert / pacman.c
Last active April 26, 2018 09:48
pacman ncurses
/*
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 / pacman.lisp
Created September 30, 2015 19:14
pacman, ncurses, 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 / matrix.lisp
Last active December 27, 2019 14:06
Example of How Matrices could be implemented using Vectors In 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 / lisp.el
Created September 3, 2017 01:05
chebert-eval-print-last-sexp
(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))
(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 / tetris.c
Created June 30, 2018 17:42
Tetris in C using NCURSES
/*
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>
@chebert
chebert / freecell.c
Created June 30, 2018 18:01
Freecell in C using NCURSES
/*
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 / pacman.c
Created June 30, 2018 18:19
Pacman in C using NCURSES
/*
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 / LICENSE-CC-BY-4.0.md
Created January 28, 2020 14:11
License for public Gists for Chebert.

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.