Skip to content

Instantly share code, notes, and snippets.

@al3x
al3x / gist:7379
Created August 27, 2008 00:01
An Ant build task for TextMate that works off your currently selected directory in the project drawer. I added it to the Scala bundle. Be sure to set Output to "Show as HTML".
. "$TM_SUPPORT_PATH/lib/webpreview.sh"
require_cmd "${TM_ANT:=ant}" "Ant was not found, please ensure that it has been installed and your \$PATH is set correctly."
html_header "Ant Build"
cd "$TM_SELECTED_FILE";
result=`"$TM_ANT"`;
echo "<pre>$result</pre>";
@al3x
al3x / Twitter Search command for Mozilla Ubiquity
Created August 27, 2008 22:18
Twitter Search command for Mozilla Ubiquity
makeSearchCommand({
name: "tsearch",
url: "http://search.twitter.com/search?q={QUERY}",
icon: "http://twitter.com/favicon.ico",
description: "Searches Twitter for your words.",
preview: function(pblock, directObject) {
var searchTerm = directObject.text;
var pTemplate = "Searches Twitter for <b>${query}</b>";
var pData = {query: searchTerm};
pblock.innerHTML = CmdUtils.renderTemplate(pTemplate, pData);
@al3x
al3x / al3x_ubiquity.js
Created August 28, 2008 00:03
Ubiquity commands for bit.ly, Instapaper, Soup.io, Google Reader, Twitter Search, Yep, and zapping CSS
CmdUtils.CreateCommand({
name: "bitly",
takes: {"url to shorten": noun_arb_text},
preview: "Replaces the selected URL with a bit.ly-shortened URL.",
description: "Replaces the selected URL with a bit.ly-shortened URL.",
icon: "http://bit.ly/favicon.png",
homepage: "http://static.al3x.net/ubiquity.html",
author: { name: "Alex Payne", email: "al3x@al3x.net"},
license: "WTFPL",
execute: function( urlToShorten ) {
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>ruby.gem.server</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/gem</string>
<string>server</string>
trait WhoAreYou {
def whatClassAmI: Class[_] = this.getClass
println("I've been mixed into " + whatClassAmI)
if (whatClassAmI == classOf[Bar]) {
println("Holy cow batman, I'm part of a Bar")
}
}
class Foo extends WhoAreYou
@al3x
al3x / gist:17018
Created October 15, 2008 21:40 — forked from mzsanford/gist:17017
Jetty from Scala
import java.util.logging.Logger
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
import org.mortbay.jetty.Server
import org.mortbay.jetty.handler.AbstractHandler
object Test extends AbstractHandler {
val log = Logger.getLogger("handler")
def main(args : Array[String]) = {
@al3x
al3x / Dear Red States
Created October 26, 2008 19:20
An email forwarded to me. I LOL'd.
Dear Red States,
We've decided we're leaving. We intend to form our own country, and we're taking the other Blue
States with us. In case you aren't aware, that includes Hawaii, California, Oregon, Washington,
Minnesota, Wisconsin, Michigan, Illinois, New York, and all of the Northeastern states. After this
election, we'll be adding Colorado and New Mexico. We believe this split will be beneficial to the
nation, especially to the people of our new country - Nuevo California.
To sum up briefly: You get Texas, Oklahoma and all the slave states; we get stem cell research, the
best beaches, and the best ski resorts. We get Elliot Spitzer; you get Ken Lay. We get the Statue of
@al3x
al3x / euler 52
Created October 27, 2008 19:49 — forked from anonymous/euler 52
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
URL: http://projecteuler.net/index.php?section=problems&id=52
Problem summary goes here:
It can be seen that the number, 125874, and its double, 251748, contain
exactly the same digits, but in a different order.
@al3x
al3x / gist:20577
Created October 29, 2008 01:39
.screenrc
startup_message off
defscrollback 5000
autodetach on
hardstatus alwayslastline "%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{r}(%{W}%n*%f %t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m/%d %{W}%c %{g}]"
#!/usr/bin/php -q
<?php
// modified from http://3v1n0.tuxfamily.org/scripts/detextile/HTML-to-Textile.php
class html2textile {
function detextile($text) {
$text = preg_replace("/(<\/?)(\w+)([^>]*>)/e", "'\\1'.strtolower('\\2').'\\3'", $text);
$text = preg_replace("/<br[ \/]*>\s*/","\n",$text);
$text = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $text);
$text = stripslashes($text);
$oktags = array('p','ol','ul','li','i','b','em','strong','span','a','h[1-6]',