Skip to content

Instantly share code, notes, and snippets.

View milesegan's full-sized avatar
💭
/╲/\╭(ఠఠ益ఠఠ)╮/\╱\

Miles Egan milesegan

💭
/╲/\╭(ఠఠ益ఠఠ)╮/\╱\
View GitHub Profile
;; to create the test file:
;; java slurptest.clj makewords 100
;;
;; to run the test
;; java -Xmx3G -Xms3G clojure.main slurptest.clj slurp|slurp2
(import '[java.io BufferedReader InputStreamReader])
(ns slurptest
(:require [clojure.java.io :as jio]))
<lift:surround with="default" at="content">
<lift:comet type="Chat">
<h3>welcome to lift chat</h3>
<ul id="ul_dude">
<chat:line></chat:line>
</ul>
<lift:form>
<chat:input/>
<input type="submit" value="chat"/>
package code.comet
import net.liftweb._
import http._
import actor._
import js._
import JsCmds._
import js.jquery.JqJsCmds.{AppendHtml, FadeOut, Hide, FadeIn}
import java.util.Date
import scala.xml._
package code.comet
import net.liftweb._
import http._
import actor._
import js._
import JsCmds._
import js.jquery.JqJsCmds.{AppendHtml, FadeOut, Hide, FadeIn}
import java.util.Date
import scala.xml._
@milesegan
milesegan / parse_layout
Created January 17, 2011 22:29
photoshop slice export parser
#!/usr/bin/env python
import os, re, sys
from xml.etree.ElementTree import ElementTree
def hash_style(s):
s = re.split(r";\s+", s)
s = [re.split(r":", x) for x in s]
s = [(x[0], re.sub(r"[^0-9]", "", x[1])) for x in s if re.match(r"^\d", x[1])]
return dict(s)
@milesegan
milesegan / Make Knob.js
Created January 21, 2011 19:23
knob rotation image sequence generator script for photoshop
// photoshop knob generation script
// This script assumes your source document contains a layer group
// called "indicator" that can be successively rotated around its
// center to generate a series of rotation state images.
// - Miles Egan January 2011
// change this to the number of discrete rotations you want
var numRotations = 65;
var rotAngle = 270;
var step = rotAngle / (numRotations - 1);
@milesegan
milesegan / gist:877898
Created March 19, 2011 23:20
c99 variable-length array example
// the old way:
int calculate_z(int a, int b)
{
int *buffer = malloc(a * sizeof(int));
// ...
free(buffer);
}
// the new way:
int calculate_z(int a, int b)
@milesegan
milesegan / gist:877903
Created March 19, 2011 23:26
c99 designated initializer example
AudioStreamBasicDescription fmt = (AudioStreamBasicDescription) {
.mChannelsPerFrame = 1,
.mBytesPerFrame = sizeof(int16_t),
.mBytesPerPacket = sizeof(int16_t),
.mFramesPerPacket = 1,
.mBitsPerChannel = sizeof(int16_t) * 8,
.mFormatID = kAudioFormatLinearPCM,
.mSampleRate = 44100.0,
.mFormatFlags = kAudioFormatFlagIsBigEndian |
kAudioFormatFlagIsPacked |
@milesegan
milesegan / gist:877906
Created March 19, 2011 23:30
c99 fft example
float imag[size_2];
float real[size_2];
DSPSplitComplex comp = (DSPSplitComplex) { .imagp = imag, .realp = real };
vDSP_ctoz((DSPComplex *)windowedSamples, 2, &comp, 1, size_2);
vDSP_fft_zrip(self.fftSetup, &comp, 1, logSize, kFFTDirection_Forward);
@milesegan
milesegan / EmbedYouTubeTag.rb
Created June 27, 2011 08:02
embed_youtube tag plugin for Jekyll
# Provides an "embed_youtube" tag for Jekyll's Liquid templates.
# Much cleaner than pasting in <object> tags.
require 'uri'
module Jekyll
class EmbedYouTubeTag < Liquid::Tag
def initialize(tag_name, text, tokens)