Skip to content

Instantly share code, notes, and snippets.

@jacius
jacius / 0.log
Created September 5, 2016 19:01
Scary Rust Compiler Error
% rustc --version
rustc 1.10.0 (cfcb716cf 2016-07-03)
% cargo run
Compiling scary-compiler-message v0.1.0 (file:///Users/jac/scary-compiler-message)
src/main.rs:27:36: 27:40 error: no method named `iter` found for type `(specs::Storage<Foo, std::sync::RwLockReadGuard<'_, specs::Allocator>, std::sync::RwLockReadGuard<'_, specs::MaskedStorage<Foo>>>, specs::Storage<Bar, std::sync::RwLockReadGuard<'_, specs::Allocator>, std::sync::RwLockReadGuard<'_, specs::MaskedStorage<Bar>>>)` in the current scope
src/main.rs:27 for (foo, bar) in (foos, bars).iter() {
^~~~
src/main.rs:27:36: 27:40 note: the method `iter` exists but the following trait bounds were not satisfied: `specs::Storage<Foo, std::sync::RwLockReadGuard<'_, specs::Allocator>, std::sync::RwLockReadGuard<'_, specs::MaskedStorage<Foo>>> : specs::Join`, `specs::Storage<Bar, std::sync::RwLockReadGuard<'_, specs::Allocator>, std::sync::RwLockReadGuard<'_, specs::MaskedStorage<Bar>>> : specs::Join`, `spe
@jacius
jacius / benchmark-float.scm
Created January 16, 2016 21:05
Benchmark for various ways of representing C structs in CHICKEN Scheme
#|
Benchmark for various ways of representing C structs in CHICKEN
Scheme. Compile with different flags to switch the representation.
Allocate memory in non-managed memory:
csc -D use-alloc -O3 -profile ./benchmark-float.scm
./benchmark-float 2> profile-alloc.txt
@jacius
jacius / heap.rs
Created July 7, 2014 18:06
Implementation of a generic binary heap data structure in Rust (0.11). Just for funsies.
pub struct Heap<T> {
data: Vec<T>
}
impl<T: PartialOrd> Heap<T> {
/// Create a new empty heap.
pub fn new() -> Heap<T> {
Heap { data: Vec::<T>::new() }
}
@jacius
jacius / 1. README.md
Last active March 17, 2019 23:55
Chicken Scheme + WebGL (Three.js)
@jacius
jacius / 1. README.md
Last active July 18, 2021 05:49
HTML5 canvas with Chicken Scheme
@jacius
jacius / Makefile
Last active December 12, 2015 08:59
Using Chicken Scheme to generate HTML and JS
generated = hello.html hello.js spock-runtime-min.js
all: $(generated)
clean:
rm $(generated)
%.html: %.html.scm
csi -s $< > $@
@jacius
jacius / merge-plists.lisp
Created November 24, 2011 05:55
merge-plists
;; I'm sure this could be improved a lot! I'm still a lisp newbie.
(defun merge-plists (&rest plists)
"Merge all the given plists into a new plist. The new plist has all
the keys from each plist, with values of keys in later lists
overriding the values of the same keys in earlier plists.
No particular order of key/value pairs is guaranteed.
E.g.:
> (afw/util:merge-plists '(:a 1 :b 2) '(:a 3 :c 4) '(:d 5))
(:D 5 :C 4 :A 3 :B 2)"
window.onload = ->
paper = Raphael 0, 0, 320, 200
circle = paper.circle 50, 40, 10
circle.attr "fill", "#f00"
circle.node.onclick = -> alert "Stop poking me!"
window.onkeypress = (ev) ->
ev = window.event || ev
switch ev.keyCode
when 37 then circle.attr( "cx", circle.attr("cx") - 5 )
when 38 then circle.attr( "cy", circle.attr("cy") - 5 )
#! /usr/bin/ruby
# Plot random pixels.
require 'rubygame'
include Rubygame
Width = 640
Height = 400
@jacius
jacius / regexp_highlighting.rb
Created December 24, 2009 07:54
weird regexps
%r<this is a valid regexp>e.to_s
# That's right.
%r(this one is valid, but...()
it actually closes right here:)i.inspect
# Tricky.
%r[this is valid too]x.clone
# Correct.