Skip to content

Instantly share code, notes, and snippets.

View stesla's full-sized avatar

Samantha Tesla stesla

  • DRW
  • Chicago, Illinois, USA
View GitHub Profile
@stesla
stesla / .asoundrc
Last active December 17, 2015 08:19
When I upgraded to Ubuntu 11.10, I removed PulseAudio entirely because amixer didn't work right with it, and XMonad.Actions.Volume wraps amixer. Well, it turns out all I needed was to add this file at ~/.asoundrc to make ALSA default to the pulse device, and it all would have worked (as it is now).
pcm.!default {
type pulse
}
ctl.!default {
type pulse
}
@stesla
stesla / echo.go
Created February 17, 2012 16:16
A simple websocket echo server
package main
import (
"net/http"
"io"
"code.google.com/p/go.net/websocket"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
@stesla
stesla / sweet.sh
Created November 1, 2011 02:45
I Love Bash
#!/bin/bash
server=$1
if [ -z "$server" ]; then
echo "USAGE: ${0##*/} server"
exit 1
fi
while read first rest; do
for second in $rest; do
(ns proxy-test.core)
(defn make-foo []
(proxy [Runnable] []
(run []
(println "foo" (class this)))))
(defn make-bar []
(proxy [Runnable] []
(run []
function setAttrs(obj, attrs) {
_.each(attrs, function(value, attr) {
obj.setAttribute(attr, value);
});
};
var paper = document.getElementById("js-svg");
var svgns = "http://www.w3.org/2000/svg";
var svg = paper.appendChild(document.createElementNS(svgns,"svg"));
var rect = svg.appendChild(document.createElementNS(svgns,"rect"));
<svg class="paper" xmlns="http://www.w3.org/2000/svg"
version="1.1" width="785" height="200">
<rect x="50" y="50" width="300" height="100" r="0"
rx="0" ry="0" fill="cyan" stroke="black"
stroke-width="5px"/>
<ellipse cx="600" cy="100" rx="150" ry="50"
fill="orange" stroke="black"
stroke-width="5px"/>
</svg>
var paper = Raphael("gradients", 785, 200);
var circle = paper.circle(130, 100, 75);
// Simple 90 degree gradient from white to black
circle.attr("fill", "90-#fff-#000");
// 0 degree gradient from white to black, via red at 20%
circle.clone().translate(175).attr("fill", "0-#fff-#f00:20-#000");
// Radial gradient from white to black
circle.clone().translate(350).attr("fill", "r#fff-#000");
// Radiel gradient from white to black at focus point (0.25, 0.75)
circle.clone().translate(525).attr("fill", "r(0.25, 0.75)#fff-#000");
var paper = Raphael("animation", 785, 200);
var left, right, circle = paper.circle(30, 100, 20).attr("fill", "black");
right = function() {
circle.animate({cx: 700, r: 80, fill: "red"}, 3000, "bounce");
circle.node.onclick = left;
};
left = function() {
circle.animate({cx: 30, r: 10, fill: "black"}, 3000, "bounce");
circle.node.onclick = right;
}
var paper = Raphael("path-curves", 785, 200);
var path = "M 100 100"
+ "C 120 10 180 10 200 100"
+ "S 280 190 300 100"
+ "S 380 10 400 100"
+ "S 480 190 500 100"
+ "S 580 10 600 100"
+ "S 680 190 700 100";
paper.path(path);
var paper = Raphael("text", 785, 200);
var attr = {
fill: "purple",
font: "80px Helvetica, Arial",
"text-anchor": "start"
};
paper.text(35, 120, "SVG is great for text!").attr(attr);