Skip to content

Instantly share code, notes, and snippets.

View ryanoneill's full-sized avatar

Ryan O'Neill ryanoneill

  • San Francisco, CA
View GitHub Profile
@ryanoneill
ryanoneill / index.html
Created April 9, 2012 04:11
Very Simple Web Page for Lift on Heroku
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<title>Home</title>
</head>
<body class="lift:content_id=main">
<div id="main" class="lift:surround?with=default;at=content">
<h2>Welcome to your project!</h2>
<p>
@ryanoneill
ryanoneill / Boot.scala
Created April 9, 2012 04:07
Very Simple Boot file for Lift on Heroku
package bootstrap
package liftweb
import net.liftweb.http.LiftRules
import net.liftweb.sitemap.{SiteMap,Menu}
class Boot {
def boot {
LiftRules.addToPackages("code")
@ryanoneill
ryanoneill / HelloWorld.scala
Created April 9, 2012 04:01
Lift Web Framework HelloWorld snippet
package code
package snippet
import scala.xml.{NodeSeq, Text}
import net.liftweb.util._
import net.liftweb.common._
import java.util.Date
import Helpers._
class HelloWorld {
@ryanoneill
ryanoneill / JettyLauncher.scala
Created April 9, 2012 03:49
JettyLauncher for Lift Framework for use with Heroku
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.servlet.{DefaultServlet, ServletContextHandler}
import org.eclipse.jetty.server.nio.SelectChannelConnector
import net.liftweb.http.LiftFilter
object JettyLauncher extends App {
// Slightly modified from
// https://github.com/ghostm/lift_blank_heroku
// to change Application to App
// Original version was modified based on the
@ryanoneill
ryanoneill / Problem10.scala
Created April 3, 2012 21:02
Ninety-Nine Scala Problems: Problem 10 - Run-length encoding of a list.
// http://aperiodic.net/phil/scala/s-99/
// P10 (*) Run-length encoding of a list.
// Use the result of problem P09 to implement the so-called run-length encoding data compression method. Consecutive duplicates of elements are encoded as tuples (N, E) where N is the number of duplicates of the element E.
// Example:
// scala> encode(List('a, 'a, 'a, 'a, 'b, 'c, 'c, 'a, 'a, 'd, 'e, 'e, 'e, 'e))
// res0: List[(Int, Symbol)] = List((4,'a), (1,'b), (2,'c), (2,'a), (1,'d), (4,'e))
import Problem09.pack
@ryanoneill
ryanoneill / Problem09.scala
Created April 3, 2012 20:02
Ninety-Nine Scala Problems: Problem 09 - Pack consecutive duplicates of list elements into sublists.
// http://aperiodic.net/phil/scala/s-99/
// P09 (**) Pack consecutive duplicates of list elements into sublists.
// If a list contains repeated elements they should be placed in separate sublists.
// Example:
// scala> pack(List('a, 'a, 'a, 'a, 'b, 'c, 'c, 'a, 'a, 'd, 'e, 'e, 'e, 'e))
// res0: List[List[Symbol]] = List(List('a, 'a, 'a, 'a), List('b), List('c, 'c), List('a, 'a), List('d), List('e, 'e, 'e, 'e))
object Problem09 {
@ryanoneill
ryanoneill / Problem08.scala
Created April 3, 2012 19:48
Ninety-Nine Scala Problems: Problem 08 - Eliminate consecutive duplicates of list elements.
// http://aperiodic.net/phil/scala/s-99/
// P08 (**) Eliminate consecutive duplicates of list elements.
// If a list contains repeated elements they should be replaced with a single copy of the element. The order of the elements should not be changed.
// Example:
// scala> compress(List('a, 'a, 'a, 'a, 'b, 'c, 'c, 'a, 'a, 'd, 'e, 'e, 'e, 'e))
// res0: List[Symbol] = List('a, 'b, 'c, 'a, 'd, 'e)
object Problem08 {
@ryanoneill
ryanoneill / Problem07.scala
Created April 3, 2012 19:39
Ninety-Nine Scala Problems: Problem 07 - Flatten a nested list structure.
// http://aperiodic.net/phil/scala/s-99/
// P07 (**) Flatten a nested list structure.
// Example:
// scala> flatten(List(List(1, 1), 2, List(3, List(5, 8))))
// res0: List[Any] = List(1, 1, 2, 3, 5, 8)
object Problem07 {
def main(args: Array[String]) {
val values = List(List(1, 1), 2, List(3, List(5, 8)))
@ryanoneill
ryanoneill / Problem06.scala
Created April 3, 2012 19:37
Ninety-Nine Scala Problems: Problem 06 - Find out whether a list is a palindrome.
// http://aperiodic.net/phil/scala/s-99/
// P06 (*) Find out whether a list is a palindrome.
// Example:
// scala> isPalindrome(List(1, 2, 3, 2, 1))
// res0: Boolean = true
object Problem06 {
def main(args: Array[String]) {
val values = List(1, 2, 3, 2, 1)
@ryanoneill
ryanoneill / Problem05.scala
Created April 3, 2012 19:32
Ninety-Nine Scala Problems: Problem 05 - Reverse a list.
// From: http://aperiodic.net/phil/scala/s-99/
// P05 (*) Reverse a list.
// Example:
// scala> reverse(List(1, 1, 2, 3, 5, 8))
// res0: List[Int] = List(8, 5, 3, 2, 1, 1)
object Problem05 {
def main(args: Array[String]) {
val values = List(1, 1, 2, 3, 5, 8)