This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
© 2010 Jens Ayton | |
This code may be used freely. | |
*/ | |
uniform float uValue; // Value/brighness component. | |
const float kPi = 3.141592653589793; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%!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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <complex.h> | |
int main() { | |
_Complex unsigned int c = 4ju; | |
printf("%f", cimagf(c)); | |
} |
OlderNewer