Skip to content

Instantly share code, notes, and snippets.

@bosmacs
bosmacs / gist:1223228
Created September 16, 2011 21:40
OpenCTM Brewfile
require 'formula'
class Openctm < Formula
url 'http://downloads.sourceforge.net/project/openctm/OpenCTM-1.0.3/OpenCTM-1.0.3-src.tar.bz2'
homepage 'http://openctm.sourceforge.net/'
md5 '55948e7c2ad8c5807cd1b9b48718075b'
def install
inreplace ["Makefile.macosx"] do |s|
s.gsub! "/usr/local", prefix
@bosmacs
bosmacs / gist:1065098
Created July 5, 2011 15:47 — forked from gruber/gist:1063605
Simple Inbox Archiving Script for Apple Mail
-- See article here: http://daringfireball.net/2007/07/simple_inbox_sweeper
-- The following should be one long line:
set _description to "All unflagged, read messages in each IMAP account
inbox will be moved to the “Archive” mailbox corresponding to that
account. This action is not undoable."
tell application "Mail"
display alert "Archive read messages from IMAP inboxes?" buttons ¬
{"Cancel", "Archive"} cancel button 1 message _description
@bosmacs
bosmacs / latex.template
Created June 28, 2011 19:39 — forked from michaelt/latex.template
Simple Pandoc latex.template with comments
%!TEX TS-program = xelatex
\documentclass[12pt]{scrartcl}
% The declaration of the document class:
% The second line here, i.e.
% \documentclass[12pt]{scrartcl}
% is a standard LaTeX document class declaration:
% we say what kind of document we are making in curly brackets,
% and specify any options in square brackets.
tell application "Safari"
set _source to do JavaScript "window.document.documentElement.outerHTML" in document 1
set _name to name of document 1
end tell
tell application "BBEdit"
make new text window with properties ¬
{contents:_source, source language:"HTML", name:"Generated source: " & _name}
select insertion point before character 1 of text window 1
/*
© 2010 Jens Ayton
This code may be used freely.
*/
uniform float uValue; // Value/brighness component.
const float kPi = 3.141592653589793;
from twisted.internet.protocol import DatagramProtocol
from twisted.internet import reactor
forwardMap = {
5500 : [ "192.168.110.32:5500", "10.0.1.1:5500" ],
5499 : [ "192.168.110.32:5499" ],
15501 : [ "localhost:5501" ]
}
import urlgrabber
import urlgrabber.progress
u = urlgrabber.grabber.URLGrabber()
u.urlgrab('http://pypi.python.org/packages/source/u/urlgrabber/urlgrabber-3.1.0.tar.gz', progress_obj=urlgrabber.progress.TextMeter())
uniform sampler2D tex0;
uniform sampler2D tex1;
void main()
{
vec4 t0 = texture2D(tex0, gl_TexCoord[0].st);
vec4 t1 = texture2D(tex1, gl_TexCoord[0].st);
gl_FragColor = (1.0 - t1.a) * t0 + t1.a * t1;
}
# add list comprehensions to arrays, used like so:
# >> (1..25).to_a.comprehend { |x| x**2 if not x % 2 == 0 }
# => [1, 9, 25, 49, 81, 121, 169, 225, 289, 361, 441, 529, 625]
class Array
def comprehend(&block)
block ? map(&block).compact : self
end
end