This file contains hidden or 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
class BinaryTree[A <% Ordered[A]]private (datum: A,less: Option[BinaryTree[A]],more: Option[BinaryTree[A]]) { | |
def this(datum: A) = this(datum, None,None) | |
def add(a: A):BinaryTree[A] = { | |
def addTo(branch: Option[BinaryTree[A]]) = Some(branch.map(_.add(a)).getOrElse(new BinaryTree(a))) | |
if (a <= datum) | |
new BinaryTree(datum, addTo(less), more) |
This file contains hidden or 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
case class Tree[A](datum:A, children:List[Tree[A]]) { | |
def map[B](fn: A => B): Tree[B] = { | |
new Tree[B](fn(datum),children.map(_.map(fn))) | |
} | |
def foreach(fn: A => Unit) { | |
fn(datum) | |
children.foreach(_.foreach(fn)) | |
} | |
This file contains hidden or 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 'rubygems' | |
require 'twitter' | |
require 'mechanize' | |
consumer_token = 'token' | |
consumer_secret = 'secret' | |
twitter_name = ARGV[0] | |
twitter_password = ARGV[1] |
This file contains hidden or 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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> | |
<head> | |
<title>foo</title> | |
</head> | |
<body style="overflow:hidden"> | |
<div id="FB_HiddenIFrameContainer" style="display:none; position:absolute; left:-100px; top:-100px; width:0px; height: 0px;"></div> | |
<script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script> |
This file contains hidden or 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
function profilePic(selector, id){ | |
var element = $j(selector); | |
var oldId = element.attr('uid'); | |
if (oldId != id){ | |
element.attr('uid',id); | |
FB.XFBML.Host.addElement(new FB.XFBML.ProfilePic(element.get(0))); | |
} | |
} |
This file contains hidden or 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
package hoffrocket | |
import _root_.net.liftweb.mapper._ | |
import _root_.java.sql.{PreparedStatement,Types, Connection,DriverManager} | |
import scala.collection.mutable.HashMap | |
import _root_.net.liftweb.util._ | |
import Helpers._ | |
/** |
This file contains hidden or 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
case class MySetHtml(uid:String, xhtml:NodeSeq) extends JsCmd { | |
def filterScripts(xhtml:NodeSeq):(String, NodeSeq) = { | |
def xform(in: NodeSeq): NodeSeq = in flatMap { | |
case e: Elem if e.label == "script" => NodeSeq.Empty | |
case e: Elem => Elem(e.prefix, e.label, e.attributes, e.scope, xform(e.child) :_*) | |
case g: Group => xform(g.child) | |
case x => x | |
} |
This file contains hidden or 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
trait ScriptFilter extends JsCmd { | |
def content:NodeSeq | |
override def fixHtml(uid: String, content: NodeSeq): String = { | |
def xform(in: NodeSeq): NodeSeq = in flatMap { | |
case e: Elem if e.label == "script" => NodeSeq.Empty | |
case e: Elem => Elem(e.prefix, e.label, e.attributes, e.scope, xform(e.child) :_*) | |
case g: Group => xform(g.child) | |
case x => x |
This file contains hidden or 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 _root_.net.liftweb.mapper._ | |
trait HasCreatedMetaMapper[T <: HasCreated[T]] { | |
self: T with LongKeyedMetaMapper[T] => | |
import java.util.Date | |
def findByCreated(startDate:Date, endDate:Date) = findAll(By_>(created_at, startDate), By_<(created_at, endDate)) | |
def findByCreatedSince(startDate: Date) = findAll(By_>(created_at, startDate)) | |
} | |
trait HasCreated [T <: HasCreated[T]] extends KeyedMapper[Long, T] { |
This file contains hidden or 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 java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.io.Reader; | |
import java.io.UnsupportedEncodingException; | |
import java.net.HttpURLConnection; | |
import java.net.URL; | |
import java.net.URLEncoder; | |
public class FS { |
OlderNewer