Skip to content

Instantly share code, notes, and snippets.

View shanecelis's full-sized avatar

Shane Celis shanecelis

View GitHub Profile
@shanecelis
shanecelis / line-pragma.scm
Last active October 3, 2015 08:17
Recognize #line <line-number> <filename> statements in your Guile code.
;; line-pragma.scm
;;
;; This code extends the reader to recognize #l and is meant to
;; be used the same way as the #line pragma in C. This way you can
;; sprinkle your code with lines like this:
;;
;; (define (f x)
;; #line 314 "increment-literately.w"
;; (+ x 1))
;;
@shanecelis
shanecelis / gist:2779930
Created May 24, 2012 07:01 — forked from branan/gist:1562391
Example OpenGL3.2 buffer/shader usage
/*
Original: 1562391 by branan
Updated to use GLFW so it works on Mac OS X Lion
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#define GLFW_NO_GLU
#define GLFW_INCLUDE_GL3
@shanecelis
shanecelis / visualization-library-with-sdl-example.cpp
Created June 9, 2012 18:36
Example of using the Visualization Library without a GUI wrapper
/* visualization-library-with-sdl-example.cpp
This is an example of using the Visualization Library (VL) [1]
without using any of its GUI wrappers. It will render a spinning
cube just like the basic scene setup example[2]. However, it does
not respond to mouse events.
As a suggestion for the future work on VL, I would recommend
separating the OpenGLContext class which is required for rendering
from what is required for providing a GUI abstraction that will
/* -----------------------------------------------------------------------------
- Project: Remote control Crawling robot
- Author: panerqiang@sunfounder.com, modified by Shane Celis @shanecelis
- License: GPL v3
- Date: 2015/2/10
* -----------------------------------------------------------------------------
- Overview
- This project was written for the Crawling robot desigened by Sunfounder.
This version of the robot has 4 legs, and each leg is driven by 3 servos.
This robot is driven by a Ardunio Nano Board with an expansion Board.
#!/bin/sh
#
# shrinkpdf
#
# Shane Celis
if [ $# -ne 1 ] && [ $# -ne 2 ]; then
echo "usage: shrinkpdf <in.pdf> [out.pdf]" >&2;
echo "Shrink the size of the given PDF. By default it outputs to file 'out.pdf'." >&2;
exit 2;
;; Possible bug, or at least unexpected behavior, for typed array
;; literals. Demonstration below. The same storage is used
;; for the same literal.
;;
;; Run on guile (GNU Guile) 2.0.5 on Mac OS X.
;;
;; Shane Celis
(define x #f64(0. 1. 2.))
(define y #f64(0. 1. 2.))
;; Set the first element of x to 1.
/*
This file demonstrates a bug with C goto labels and Guile.
$ gcc `pkg-config guile-2.0 --cflags --libs` goto_label_bug.c -o goto_label_bug
goto_label_bug.c: In function 'main':
goto_label_bug.c:10: error: expected expression before 'SCM'
$ gcc `pkg-config guile-2.0 --cflags --libs` goto_label_bug.c -o goto_label_bug -D INSERT_NOOP
$ # No problem.
@shanecelis
shanecelis / show-errors.c
Created July 18, 2013 17:47
This file exhibits a lots of warnings in a C file that calls GNU Guile. The warnings are shown only when there is a compilation error.
/*
This file exhibits a lots of warnings in a C file that calls GNU
Guile. The warnings are shown only when there is a compilation error.
Shane Celis
*/
#include <libguile.h>
#define C_STRING_TO_SYMBOL(str) scm_string_to_symbol(scm_from_locale_string(str))
@shanecelis
shanecelis / make-trampoline.scm
Created August 29, 2013 17:48
Derivative of make-trampoline by Mark Weaver from #guile on irc.freenode.net
(define (make-trampoline module name)
"Creates a trampoline out of a symbol in a given module, e.g. (lambda () (name))"
(let ((var (module-variable module name)))
(unless var
(scm-error 'no-such-variable "make-trampoline" "Can't make a trampoline for variable named '~a that does not exist in module ~a." (list name module) #f))
(let ((proc (lambda () ((variable-ref var)))))
(set-procedure-property! proc 'name
(string->symbol (format #f "~a-trampoline" name)))
proc)))