Skip to content

Instantly share code, notes, and snippets.

@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 '(
(cl:defpackage #:pipe-client
(:use #:cl))
(in-package #:pipe-client)
;;; Create/Close pipe
(defun create-pipe-client! (pipe-filename)
"Creates a pipe-client with the given pipe-filename.
Returns a valid pipe handle or signals an error.
Assumes a pipe-server is already open with the same pipe-filname."
@chebert
chebert / run_pipe_server.h
Created May 22, 2022 15:05
RunPipeServer header
#ifndef RUN_PIPE_SERVER_H
#define RUN_PIPE_SERVER_H
#include <stdint.h>
#ifndef REQUEST_BUFFER_SIZE
#define REQUEST_BUFFER_SIZE (1024*1024*128)
#endif
#ifndef RESPONSE_BUFFER_SIZE
@chebert
chebert / run_pipe_server.c
Last active May 22, 2022 15:04
Full RunPipeServer.c implementation
#include "run_pipe_server.h"
#include <windows.h>
#include <stdio.h>
// Create a named pipe with the given pipe_filename.
static Pipe CreateServerPipe(String pipe_filename);
// Wait for a client connection to pipe.
static b4 ConnectPipe(Pipe);
// Loop that processes and responds to client requests from Pipe, until the client disconnects.
;;; Slime/Swank Setup
(defun multiline? (string)
"True if the string has multiple lines."
(position ?\n string))
(defun multiline-comment (string)
"Return string formatted as a multi-line Lisp comment"
(concat "#||\n" string "\n||#\n"))
@chebert
chebert / base_test.cpp
Last active May 5, 2020 16:20
Focused recreation of problem I'm encountering with using OpenGL versions >3.1 on my laptop
/* Folder structure
workspace
|- build.bat -- listing below
|- Glew dlls
|- SDL2 dlls
|- include\
|- SDL2\ -- SDL2 header files
|- GL\ -- Glew header files
|- lib\
|- Glew libs
@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.

@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 / 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 / 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>