Skip to content

Instantly share code, notes, and snippets.

(use posix)
(define (make-serialport file)
(let ((fileno
(file-open
file
(bitwise-ior open/rdwr open/noctty open/nonblock))))
; Enable blocking reads on the FD
(let ((current-fl (file-control fileno fcntl/getfl 0)))
@DerGuteMoritz
DerGuteMoritz / client.scm
Created March 12, 2012 14:11
Channel based chat example
(use unix-sockets channel srfi-18 parley)
(define output-channel
(make-channel))
(channel-enqueue output-channel (parley "Your name: "))
(define-values (in out)
(unix-connect "sock"))
(use tcp srfi-18 channel)
(define port 4321)
(print "connecting to " port)
(define (signal? msg)
(eq? (car msg) 'signal))
(define procedures
@DerGuteMoritz
DerGuteMoritz / dolor.xml
Created February 19, 2012 18:43
Example code for ssax
<?xml version="1.0"?>
<!-- <!DOCTYPE poem SYSTEM "dolor.dtd"> -->
<poem>
<title>Dolor</title>
<!-- Here's a simple example of an XML document -->
<author>
<last>Roethke</last>
<first>Theodore</first>
@DerGuteMoritz
DerGuteMoritz / gist:1245359
Created September 27, 2011 15:23
Rails routes with_options
# Rails < 3.0
map.with_options :member => { :some_default_member_route => :get } do |default|
default.resources :frobs
default.resources :foos, :collection => { :some_special_collection => :get }
end
# Rails >= 3.0
default_resource_routes = lambda do
require 'rubygems'
require 'nokogiri'
module SXML
def self.transform(sxml, doc = Nokogiri::XML::Document.new)
el = Nokogiri::XML::Element.new(sxml[0].to_s, doc)
sxml[1..-1].each do |e|
case e
def rispp_box1(title, options = {}, &block)
SXML.transform([:div, { :class => 'box1' },
[:div, { :class => 'wrap' },
[:h2, { :class => options[:class] }],
capture { block.call(title, options) }]])
end
remove Lock = Caps_Lock
remove Control = Control_L
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L
#!/bin/bash
cache=/tmp/proglist
if [ "$1" = "reset" -o ! -e "$cache" ]; then
ls -lL $(echo "$PATH" | sed 'y/:/ /') 2>/dev/null \
| awk '$1 ~ /^[^d].*x/ { print $NF }' \
| sort | uniq > $cache
fi
puts "this is bar"