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
#!/usr/bin/env ruby | |
# Alignes the source | |
def align(text, regexp, width) | |
text.to_a.map do |line| | |
if offset = offsetOfRegexpInLine(line, regexp) | |
if shouldInsertBefore(line, regexp) | |
before = line[0..offset-1] | |
before + ' ' * (width - (before.length)) + line[offset..line.length-1] | |
else | |
before = line[0..offset] |
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
package com.reversebackup | |
import scala.xml._ | |
import scala.xml.transform._ | |
import scala.xml.XML | |
/* | |
This snippet creates two methods: removeAllNamedTagsTransformer & createRewriteRule. | |
They both create a RuleTransformer which removes all tags with a specific name. | |
However, it seems that it doesn't work if the name of the parameter is 'name'. |
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
/* | |
I want to use pattern matching in coffeescript as a more capable switch. It uses destructuring | |
assignments to figure out which of the cases that matches. So it can match on the entire | |
structure of the object instead of just an integer. | |
(* in F# *) | |
let list = [1;2;3;4] | |
match list with | |
| [] -> printfn "empty list" | |
| x :: xs -> printfn "first element is " + x |
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
# | |
# This script will install the following Textmate bundles | |
# | |
# Languages | |
# - c https://github.com/textmate/c.tmbundle | |
# - coffeescript https://github.com/jashkenas/coffee-script-tmbundle | |
# - context free https://github.com/textmate/context-free.tmbundle | |
# - erlang https://github.com/textmate/erlang.tmbundle | |
# - haskell https://github.com/textmate/haskell.tmbundle.git | |
# - html https://github.com/textmate/html.tmbundle |
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
package sidewayscoding.example | |
// normal imports goes here | |
import net.liftweb.http.js.JE._ // implicit string => Str | |
import net.liftweb.http.js.JsCmds._ // implicit JsExp => JsCmd | |
import net.liftweb.http.js.jquery.JqJE.{JqId,JqAttr, Jq} | |
class Test { | |
def test = |
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
// In a method that returns a NodeSeq. | |
// compiles | |
val seq = for { | |
moduleId <- S.param("moduleId") | |
moduleInstanceId <- S.param("id") | |
backupId <- S.param("backupId") | |
} yield bind("backup", xhtml, "path" -> backupId) | |
seq openOr (redirectTo("/")) |
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
/** | |
* THE FOLLOWING EXERCISE IS FROM (THE SAMPLE OF) "PURELY FUNCTIONAL DATA STRUCTURES" | |
* http://www.amazon.com/Purely-Functional-Structures-Chris-Okasaki/dp/0521663504/ref=sr_1_1?s=books&ie=UTF8&qid=1282766033&sr=1-1 | |
* | |
* Exercise 2.1 | |
* | |
* Write a function suffixes of type a list -> a list list that takes | |
* a list xs and returns a list of all the suffixes of xs in decreasing | |
* order of length. For example: | |
* |
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 sbt._ | |
class Project(info: ProjectInfo) extends DefaultProject(info) | |
{ | |
lazy val sctags = compileWithSctags | |
protected def compileWithSctags = task { | |
val compilerConfig = new MainCompileConfig { | |
override def baseCompileOptions = CompileOption("-Xplugin:sctags_2.8.0.Beta1-RC2-1.0.jar") :: super.baseCompileOptions.toList |
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
<%@ var word:String %> | |
So Long, and Thanks for All the ${word} |