Skip to content

Instantly share code, notes, and snippets.

@ofan
ofan / lisp.cpp
Last active April 11, 2024 11:28
Lisp interpreter in 90 lines of C++
Lisp interpreter in 90 lines of C++
I've enjoyed reading Peter Norvig's recent articles on Lisp. He implements a Scheme interpreter in 90 lines of Python in the first, and develops it further in the second.
Just for fun I wondered if I could write one in C++. My goals would be
1. A Lisp interpreter that would complete Peter's Lis.py test cases correctly...
2. ...in no more than 90 lines of C++.
Although I've been thinking about this for a few weeks, as I write this I have not written a line of the code. I'm pretty sure I will achieve 1, and 2 will be... a piece of cake!
@ZeronSix
ZeronSix / gist:7772309
Last active April 2, 2020 11:24
Simple Unity3D TMX parser.
using UnityEngine;
using UnityEditor;
using System;
using System.Xml.Linq;
using System.Collections.Generic;
public enum MapType {
Isometric,
Orthogonal
}
@HaiyangXu
HaiyangXu / Server.py
Created May 18, 2014 14:00
A simper python http server can handle mime type properly
# -*- coding: utf-8 -*-
#test on python 3.4 ,python of lower version has different module organization.
import http.server
from http.server import HTTPServer, BaseHTTPRequestHandler
import socketserver
PORT = 8080
Handler = http.server.SimpleHTTPRequestHandler
Below I collected relevant links and papers more or less pertaining to the subject of tetrahedral meshes.
It's an ever-growing list.
------------------------------
Relevant links:
http://en.wikipedia.org/wiki/Types_of_mesh
http://en.wikipedia.org/wiki/Tetrahedron
http://en.wikipedia.org/wiki/Simplicial_complex
@dwilliamson
dwilliamson / FileWatcher.cpp
Created January 22, 2015 21:39
Single-threaded file watcher with overlapped I/O and filtering of multiple notifications
class FileWatcher
{
public:
FileWatcher(const Path& path)
: m_Path(path)
, m_DirHandle(INVALID_HANDLE_VALUE)
, m_BufferSize(CORE_KB(100))
, m_Buffer(nullptr)
, m_ChangedFiles(1024)
{
@paniq
paniq / mt.glsl
Last active June 23, 2019 04:58
World's Tiniest* Marching Tetrahedron
// World's Tiniest* Marching Tetrahedron
// by Leonard Ritter (leonard.ritter@duangle.com)
// this code is public domain
// 0
// +
// / | \
// 3 +-----+ 1
// \ | /
@gasi
gasi / compare.c
Created May 13, 2015 21:22
VIPS compare function (`vips_stats` example)
/*
* Compile with:
*
* gcc -g -Wall compare.c `pkg-config vips --cflags --libs` -o compare
*
* Run with:
*
* ./compare actual expected
*
* Examples:
@ftiasch
ftiasch / server.py
Created August 13, 2015 09:52
python SimpleHTTPServer with custom MIME types
import SimpleHTTPServer
import SocketServer
PORT = 8000
class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
pass
Handler.extensions_map['.shtml'] = 'text/html'
@p2004a
p2004a / defer.cpp
Last active April 13, 2024 18:24
Simple defer macro for c++
// SPDX-FileCopyrightText: 2015 Marek Rusinowski
// SPDX-License-Identifier: MIT
#include <memory>
#include <cstdio>
template<typename F>
class defer_finalizer {
F f;
bool moved;
public:
@dcommander
dcommander / Makefile
Last active April 2, 2024 10:12
Simple program to demonstrate OpenGL rendering without an X server
all: egltest
egltest: egltest.c
cc -O3 -Wall -Werror -I. -o $@ $^ -lOpenGL -lEGL
clean:
rm -f *.o egltest